diff --git a/assets/index-DL1n5f57.js b/assets/index-Btp85TCW.js similarity index 99% rename from assets/index-DL1n5f57.js rename to assets/index-Btp85TCW.js index 94629bd..dd4dcf0 100644 --- a/assets/index-DL1n5f57.js +++ b/assets/index-Btp85TCW.js @@ -871,7 +871,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho "stateMutability": "view", "type": "function" } - ]`;class eC{constructor(e){ue(this,"isFetchingBalances",_r(!1));ue(this,"isFetchingTokenInfo",_r(!1));ue(this,"balances",_r([]));ue(this,"userAddedTokens",_r([]));ue(this,"local",{userAddedTokens:new hu(Ul.TOKENS_USER_ADDITIONS)});this.store=e}async loadBalances(e,r){const n=r.filter(o=>o.type===Mt.MAINNET),i=[];this.isFetchingBalances.set(!0),await Promise.allSettled(n.map(async o=>{if(!o.rpcUrl){console.warn(`No RPC URL found for network ${o.name}`);return}const a=new rp(o.rpcUrl);a.on("error",c=>{Ei(c,"NETWORK_ERROR")&&a.destroy()});try{const c=await a.getBalance(e);i.push({contractType:Ph.NATIVE,contractAddress:Mu,tokenID:"",accountAddress:e,balance:c.toString(),chainId:o.chainId,blockHash:ky,blockNumber:0,contractInfo:p_e(_Se(o.chainId)),uniqueCollectibles:"0",isSummary:!0})}catch(c){console.error(c)}})),this.balances.set(i);const s=this.local.userAddedTokens.get()??[];this.userAddedTokens.set(s),s.length>0&&await Promise.allSettled(s.map(async o=>{await this.loadUserAddedTokenBalance(e,o)})),this.isFetchingBalances.set(!1)}async loadUserAddedTokenBalance(e,r){const n=this.store.get(In).providerForChainId(r.chainId);try{const s=await new Si(r.address,v5,n).balanceOf(e),o=this.balances.get(),a=o.findIndex(l=>l.contractAddress===r.address&&l.chainId===r.chainId),c={contractType:r.contractType,contractAddress:r.address,tokenID:"",accountAddress:e,balance:s.toString(),chainId:r.chainId,blockHash:ky,blockNumber:0,contractInfo:{address:r.address,chainId:r.chainId,decimals:r.decimals,name:r.symbol,symbol:r.symbol,type:"ERC20",logoURI:"",deployed:!0,bytecodeHash:"",extensions:{link:"",description:"",ogImage:"",originAddress:"",originChainId:0,blacklist:!1,verified:!0,verifiedBy:"User",featured:!1},updatedAt:"0"},uniqueCollectibles:"0",isSummary:!0};a!==-1?o[a]=c:o.push(c),this.balances.set([...o])}catch(i){console.error(i)}}async updateTokenBalance(e){const r=this.store.get(In).providerForChainId(e.chainId);this.isFetchingBalances.set(!0);const n=this.store.get(oi).accountAddress.get();if(!n){console.warn("No account found");return}const i=this.balances.get();try{let s;e.contractType===Ph.NATIVE?s=await r.getBalance(n):s=await new Si(e.contractAddress,v5,r).balanceOf(n),i.map(o=>{o.contractAddress===e.contractAddress&&o.chainId===e.chainId&&(o.balance=s.toString())}),this.balances.set([...i])}catch(s){console.error(s)}this.isFetchingBalances.set(!1)}async addToken(e){const r=this.local.userAddedTokens.get()??[];if(r.some(s=>s.chainId===e.chainId&&s.address===e.address))throw new Error(`Token with chainId ${e.chainId} and address ${e.address} already exists`);r.push(e),this.local.userAddedTokens.set(r),this.userAddedTokens.set([...r]);const i=this.store.get(oi).accountAddress.get();i&&(this.isFetchingBalances.set(!0),await this.loadUserAddedTokenBalance(i,e),this.isFetchingBalances.set(!1))}async removeToken(e){const n=(this.local.userAddedTokens.get()??[]).filter(s=>!(s.chainId===e.chainId&&s.address===e.address));this.local.userAddedTokens.set(n),this.userAddedTokens.set([...n]);const i=this.balances.get().filter(s=>!(s.chainId===e.chainId&&s.contractAddress===e.address));this.balances.set([...i])}async getTokenInfo(e,r){const n=this.store.get(In).providerForChainId(e);this.isFetchingTokenInfo.set(!0);try{const i=this.store.get(oi).accountAddress.get(),s=new Si(r,v5,n),o=await s.decimals(),a=await s.symbol(),c=await s.balanceOf(i);if(this.isFetchingTokenInfo.set(!1),o&&a)return{decimals:Number(o),symbol:a,balance:Ih(c,o)};throw new Error(`Could not get decimals and symbol for token at ${r}`)}catch(i){throw console.error(i),new Error(`Error getting token info ${JSON.stringify(i)}`)}}clear(){this.local.userAddedTokens.set([]),this.isFetchingBalances.set(!1),this.isFetchingTokenInfo.set(!1),this.balances.set([])}}class oi{constructor(e){ue(this,"isLoadingAccount",_r(!1));ue(this,"account");ue(this,"accountAddress",_r(void 0));this.store=e,this.loadAccount(),this.store.get(In).networks.subscribe(n=>{this.account&&this.loadAccount()}),this.accountAddress.subscribe(n=>{n&&this.store.get(In).accountLoaded.set(!0)})}async signInWithRecoveryMnemonic(e,r,n){try{this.isLoadingAccount.set(!0);const i=B4.fromPhrase(r),s=new JE([i]),a=this.store.get(In).networks.get(),c=new fx({address:e,tracker:aT,contexts:ite,orchestrator:s,networks:a});n?await this.encryptRecoveryMnemonicWithPassword(r,c.address,n):await this.encryptRecoveryMnemonic(r,c.address),this.account=c,this.accountAddress.set(c.address)}catch(i){console.warn(i)}this.isLoadingAccount.set(!1)}async loadAccount(e){const r=await u5(yl.SECURITY),n=await r.get(yl.SECURITY,"mnemonic");var i=await r.get(yl.SECURITY,"key");let s;n&&(i?s=await this.decryptRecoveryMnemonic(n,i):s=await this.decryptRecoveryMnemonicWithPassword(n,e)),s?e?this.signInWithRecoveryMnemonic(s.wallet,s.mnemonic,e):this.signInWithRecoveryMnemonic(s.wallet,s.mnemonic):setTimeout(()=>{this.isLoadingAccount.set(!1)},200)}async encryptRecoveryMnemonic(e,r){const n=await o7e(),i=JSON.stringify({wallet:r,mnemonic:e}),s=await RU(n,i);s.salt=kU(r);const o=await u5(yl.SECURITY);await o.put(yl.SECURITY,n,"key"),await o.put(yl.SECURITY,s,"mnemonic")}async encryptRecoveryMnemonicWithPassword(e,r,n){const i=kU(r),s=await PU(n,i),o=JSON.stringify({wallet:r,mnemonic:e}),a=await RU(s,o);a.salt=i,await(await u5(yl.SECURITY)).put(yl.SECURITY,a,"mnemonic")}async decryptRecoveryMnemonic(e,r){const n=await MU(r,e);return JSON.parse(n)}async decryptRecoveryMnemonicWithPassword(e,r){const n=e.salt,i=await PU(r,n),s=await MU(i,e);return JSON.parse(s)}logout(){this.account=void 0,this.accountAddress.set(void 0),x7e(yl.SECURITY);const e=this.store.get(In),r=this.store.get(eC);e.clear(),r.clear(),localStorage.clear(),window.location.reload()}}const v_e=()=>{const t=e=>{e.preventDefault(),window.open("https://github.com/0xsequence/wallet-recovery-app","_blank","noopener,noreferrer")};return j.jsxs(j.Fragment,{children:[j.jsx("style",{children:` + ]`;class eC{constructor(e){ue(this,"isFetchingBalances",_r(!1));ue(this,"isFetchingTokenInfo",_r(!1));ue(this,"balances",_r([]));ue(this,"userAddedTokens",_r([]));ue(this,"local",{userAddedTokens:new hu(Ul.TOKENS_USER_ADDITIONS)});this.store=e}async loadBalances(e,r){const n=r.filter(o=>o.type===Mt.MAINNET),i=[];this.isFetchingBalances.set(!0),await Promise.allSettled(n.map(async o=>{if(!o.rpcUrl){console.warn(`No RPC URL found for network ${o.name}`);return}const a=new rp(o.rpcUrl);a.on("error",c=>{Ei(c,"NETWORK_ERROR")&&a.destroy()});try{const c=await a.getBalance(e);i.push({contractType:Ph.NATIVE,contractAddress:Mu,tokenID:"",accountAddress:e,balance:c.toString(),chainId:o.chainId,blockHash:ky,blockNumber:0,contractInfo:p_e(_Se(o.chainId)),uniqueCollectibles:"0",isSummary:!0})}catch(c){console.error(c)}})),this.balances.set(i);const s=this.local.userAddedTokens.get()??[];this.userAddedTokens.set(s),s.length>0&&await Promise.allSettled(s.map(async o=>{await this.loadUserAddedTokenBalance(e,o)})),this.isFetchingBalances.set(!1)}async loadUserAddedTokenBalance(e,r){const n=this.store.get(In).providerForChainId(r.chainId);try{const s=await new Si(r.address,v5,n).balanceOf(e),o=this.balances.get(),a=o.findIndex(l=>l.contractAddress===r.address&&l.chainId===r.chainId),c={contractType:r.contractType,contractAddress:r.address,tokenID:"",accountAddress:e,balance:s.toString(),chainId:r.chainId,blockHash:ky,blockNumber:0,contractInfo:{address:r.address,chainId:r.chainId,decimals:r.decimals,name:r.symbol,symbol:r.symbol,type:"ERC20",logoURI:"",deployed:!0,bytecodeHash:"",extensions:{link:"",description:"",ogImage:"",originAddress:"",originChainId:0,blacklist:!1,verified:!0,verifiedBy:"User",featured:!1},updatedAt:"0"},uniqueCollectibles:"0",isSummary:!0};a!==-1?o[a]=c:o.push(c),this.balances.set([...o])}catch(i){console.error(i)}}async updateTokenBalance(e){const r=this.store.get(In).providerForChainId(e.chainId);this.isFetchingBalances.set(!0);const n=this.store.get(oi).accountAddress.get();if(!n){console.warn("No account found");return}const i=this.balances.get();try{let s;e.contractType===Ph.NATIVE?s=await r.getBalance(n):s=await new Si(e.contractAddress,v5,r).balanceOf(n),i.map(o=>{o.contractAddress===e.contractAddress&&o.chainId===e.chainId&&(o.balance=s.toString())}),this.balances.set([...i])}catch(s){console.error(s)}this.isFetchingBalances.set(!1)}async addToken(e){const r=this.local.userAddedTokens.get()??[];if(r.some(s=>s.chainId===e.chainId&&s.address===e.address))throw new Error(`Token with chainId ${e.chainId} and address ${e.address} already exists`);r.push(e),this.local.userAddedTokens.set(r),this.userAddedTokens.set([...r]);const i=this.store.get(oi).accountAddress.get();i&&(this.isFetchingBalances.set(!0),await this.loadUserAddedTokenBalance(i,e),this.isFetchingBalances.set(!1))}async removeToken(e){const n=(this.local.userAddedTokens.get()??[]).filter(s=>!(s.chainId===e.chainId&&s.address===e.address));this.local.userAddedTokens.set(n),this.userAddedTokens.set([...n]);const i=this.balances.get().filter(s=>!(s.chainId===e.chainId&&s.contractAddress===e.address));this.balances.set([...i])}async getTokenInfo(e,r){const n=this.store.get(In).providerForChainId(e);this.isFetchingTokenInfo.set(!0);try{const i=this.store.get(oi).accountAddress.get(),s=new Si(r,v5,n),o=await s.decimals(),a=await s.symbol(),c=await s.balanceOf(i);if(this.isFetchingTokenInfo.set(!1),o&&a)return{decimals:Number(o),symbol:a,balance:Ih(c,o)};throw new Error(`Could not get decimals and symbol for token at ${r}`)}catch(i){throw console.error(i),new Error(`Error getting token info ${JSON.stringify(i)}`)}}clear(){this.local.userAddedTokens.set([]),this.isFetchingBalances.set(!1),this.isFetchingTokenInfo.set(!1),this.balances.set([])}}class oi{constructor(e){ue(this,"isLoadingAccount",_r(!1));ue(this,"account");ue(this,"accountAddress",_r(void 0));this.store=e,this.loadAccount(),this.store.get(In).networks.subscribe(n=>{this.account&&this.loadAccount()}),this.accountAddress.subscribe(n=>{n&&this.store.get(In).accountLoaded.set(!0)})}async signInWithRecoveryMnemonic(e,r,n){try{this.isLoadingAccount.set(!0);const i=B4.fromPhrase(r),s=new JE([i]),a=this.store.get(In).networks.get(),c=new fx({address:e,tracker:aT,contexts:ite,orchestrator:s,networks:a});n?await this.encryptRecoveryMnemonicWithPassword(r,c.address,n):await this.encryptRecoveryMnemonic(r,c.address),this.account=c,this.accountAddress.set(c.address)}catch(i){console.warn(i)}this.isLoadingAccount.set(!1)}async loadAccount(e){const r=await u5(yl.SECURITY),n=await r.get(yl.SECURITY,"mnemonic");n&&this.isLoadingAccount.set(!0);var i=await r.get(yl.SECURITY,"key");let s;n&&(i?s=await this.decryptRecoveryMnemonic(n,i):s=await this.decryptRecoveryMnemonicWithPassword(n,e)),s?e?this.signInWithRecoveryMnemonic(s.wallet,s.mnemonic,e):this.signInWithRecoveryMnemonic(s.wallet,s.mnemonic):setTimeout(()=>{this.isLoadingAccount.set(!1)},200)}async encryptRecoveryMnemonic(e,r){const n=await o7e(),i=JSON.stringify({wallet:r,mnemonic:e}),s=await RU(n,i);s.salt=kU(r);const o=await u5(yl.SECURITY);await o.put(yl.SECURITY,n,"key"),await o.put(yl.SECURITY,s,"mnemonic")}async encryptRecoveryMnemonicWithPassword(e,r,n){const i=kU(r),s=await PU(n,i),o=JSON.stringify({wallet:r,mnemonic:e}),a=await RU(s,o);a.salt=i,await(await u5(yl.SECURITY)).put(yl.SECURITY,a,"mnemonic")}async decryptRecoveryMnemonic(e,r){const n=await MU(r,e);return JSON.parse(n)}async decryptRecoveryMnemonicWithPassword(e,r){const n=e.salt,i=await PU(r,n),s=await MU(i,e);return JSON.parse(s)}logout(){this.account=void 0,this.accountAddress.set(void 0),x7e(yl.SECURITY);const e=this.store.get(In),r=this.store.get(eC);e.clear(),r.clear(),localStorage.clear(),window.location.reload()}}const v_e=()=>{const t=e=>{e.preventDefault(),window.open("https://github.com/0xsequence/wallet-recovery-app","_blank","noopener,noreferrer")};return j.jsxs(j.Fragment,{children:[j.jsx("style",{children:` .github-corner { fill: #777; color: #151513; @@ -1020,7 +1020,7 @@ __p += '`),Dr&&(qe+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+qe+`return __p -}`;var gr=CN(function(){return Lr(se,Rt+"return "+qe).apply(r,he)});if(gr.source=qe,FA(gr))throw gr;return gr}function afe(d){return Jr(d).toLowerCase()}function cfe(d){return Jr(d).toUpperCase()}function lfe(d,p,_){if(d=Jr(d),d&&(_||p===r))return td(d);if(!d||!(p=Ho(p)))return d;var q=yo(d),J=yo(p),se=Bx(q,J),he=Lx(q,J)+1;return ud(q,se,he).join("")}function ffe(d,p,_){if(d=Jr(d),d&&(_||p===r))return d.slice(0,Dm(d)+1);if(!d||!(p=Ho(p)))return d;var q=yo(d),J=Lx(q,yo(p))+1;return ud(q,0,J).join("")}function ufe(d,p,_){if(d=Jr(d),d&&(_||p===r))return d.replace(Bt,"");if(!d||!(p=Ho(p)))return d;var q=yo(d),J=Bx(q,yo(p));return ud(q,J).join("")}function dfe(d,p){var _=ae,q=K;if(On(p)){var J="separator"in p?p.separator:J;_="length"in p?pr(p.length):_,q="omission"in p?Ho(p.omission):q}d=Jr(d);var se=d.length;if(Qr(d)){var he=yo(d);se=he.length}if(_>=se)return d;var me=_-Sf(q);if(me<1)return q;var Ce=he?ud(he,0,me).join(""):d.slice(0,me);if(J===r)return Ce+q;if(he&&(me+=Ce.length-me),jA(J)){if(d.slice(me).search(J)){var Be,Le=Ce;for(J.global||(J=Nm(J.source,Jr(tr.exec(J))+"g")),J.lastIndex=0;Be=J.exec(Le);)var qe=Be.index;Ce=Ce.slice(0,qe===r?me:qe)}}else if(d.indexOf(Ho(J),me)!=me){var ft=Ce.lastIndexOf(J);ft>-1&&(Ce=Ce.slice(0,ft))}return Ce+q}function hfe(d){return d=Jr(d),d&&Dt.test(d)?d.replace(ir,qx):d}var pfe=Jp(function(d,p,_){return d+(_?" ":"")+p.toUpperCase()}),qA=AD("toUpperCase");function EN(d,p,_){return d=Jr(d),p=_?r:p,p===r?Fx(d)?JC(d):UC(d):d.match(p)||[]}var CN=br(function(d,p){try{return li(d,r,p)}catch(_){return FA(_)?_:new Xt(_)}}),vfe=Rf(function(d,p){return go(p,function(_){_=ul(_),Pf(d,_,BA(d[_],d))}),d});function gfe(d){var p=d==null?0:d.length,_=Wt();return d=p?ln(d,function(q){if(typeof q[1]!="function")throw new mo(o);return[_(q[0]),q[1]]}):[],br(function(q){for(var J=-1;++Jx)return[];var _=k,q=hr(d,k);p=Wt(p),d-=k;for(var J=l0(q,p);++_0||p<0)?new kr(_):(d<0?_=_.takeRight(-d):d&&(_=_.drop(d)),p!==r&&(p=pr(p),_=p<0?_.dropRight(-p):_.take(p-d)),_)},kr.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},kr.prototype.toArray=function(){return this.take(k)},ll(kr.prototype,function(d,p){var _=/^(?:filter|find|map|reject)|While$/.test(p),q=/^(?:head|last)$/.test(p),J=ne[q?"take"+(p=="last"?"Right":""):p],se=q||/^find/.test(p);J&&(ne.prototype[p]=function(){var he=this.__wrapped__,me=q?[1]:arguments,Ce=he instanceof kr,Be=me[0],Le=Ce||sr(he),qe=function(Ar){var Dr=J.apply(ne,al([Ar],me));return q&&ft?Dr[0]:Dr};Le&&_&&typeof Be=="function"&&Be.length!=1&&(Ce=Le=!1);var ft=this.__chain__,Rt=!!this.__actions__.length,Yt=se&&!ft,gr=Ce&&!Rt;if(!se&&Le){he=gr?he:new kr(this);var Qt=d.apply(he,me);return Qt.__actions__.push({func:l3,args:[qe],thisArg:r}),new Sa(Qt,ft)}return Yt&&gr?d.apply(this,me):(Qt=this.thru(qe),Yt?q?Qt.value()[0]:Qt.value():Qt)})}),go(["pop","push","shift","sort","splice","unshift"],function(d){var p=$p[d],_=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",q=/^(?:pop|shift)$/.test(d);ne.prototype[d]=function(){var J=arguments;if(q&&!this.__chain__){var se=this.value();return p.apply(sr(se)?se:[],J)}return this[_](function(he){return p.apply(sr(he)?he:[],J)})}}),ll(kr.prototype,function(d,p){var _=ne[p];if(_){var q=_.name+"";Gr.call(mc,q)||(mc[q]=[]),mc[q].push({name:p,func:_})}}),mc[r3(r,E).name]=[{name:"wrapper",func:r}],kr.prototype.clone=hse,kr.prototype.reverse=pse,kr.prototype.value=vse,ne.prototype.at=zae,ne.prototype.chain=Hae,ne.prototype.commit=Gae,ne.prototype.next=Wae,ne.prototype.plant=Yae,ne.prototype.reverse=Qae,ne.prototype.toJSON=ne.prototype.valueOf=ne.prototype.value=Jae,ne.prototype.first=ne.prototype.head,z&&(ne.prototype[z]=Kae),ne},rd=ZC();pn?((pn.exports=rd)._=rd,rn._=rd):Cr._=rd}).call(xi)})(f8,f8.exports);var xqe=f8.exports,jT={exports:{}};(function(t,e){var r=typeof self<"u"?self:xi,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function c(v){return v&&DataView.prototype.isPrototypeOf(v)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(v){return v&&l.indexOf(Object.prototype.toString.call(v))>-1};function u(v){if(typeof v!="string"&&(v=String(v)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(v))throw new TypeError("Invalid character in header field name");return v.toLowerCase()}function h(v){return typeof v!="string"&&(v=String(v)),v}function g(v){var b={next:function(){var M=v.shift();return{done:M===void 0,value:M}}};return a.iterable&&(b[Symbol.iterator]=function(){return b}),b}function y(v){this.map={},v instanceof y?v.forEach(function(b,M){this.append(M,b)},this):Array.isArray(v)?v.forEach(function(b){this.append(b[0],b[1])},this):v&&Object.getOwnPropertyNames(v).forEach(function(b){this.append(b,v[b])},this)}y.prototype.append=function(v,b){v=u(v),b=h(b);var M=this.map[v];this.map[v]=M?M+", "+b:b},y.prototype.delete=function(v){delete this.map[u(v)]},y.prototype.get=function(v){return v=u(v),this.has(v)?this.map[v]:null},y.prototype.has=function(v){return this.map.hasOwnProperty(u(v))},y.prototype.set=function(v,b){this.map[u(v)]=h(b)},y.prototype.forEach=function(v,b){for(var M in this.map)this.map.hasOwnProperty(M)&&v.call(b,this.map[M],M,this)},y.prototype.keys=function(){var v=[];return this.forEach(function(b,M){v.push(M)}),g(v)},y.prototype.values=function(){var v=[];return this.forEach(function(b){v.push(b)}),g(v)},y.prototype.entries=function(){var v=[];return this.forEach(function(b,M){v.push([M,b])}),g(v)},a.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function m(v){if(v.bodyUsed)return Promise.reject(new TypeError("Already read"));v.bodyUsed=!0}function S(v){return new Promise(function(b,M){v.onload=function(){b(v.result)},v.onerror=function(){M(v.error)}})}function E(v){var b=new FileReader,M=S(b);return b.readAsArrayBuffer(v),M}function A(v){var b=new FileReader,M=S(b);return b.readAsText(v),M}function P(v){for(var b=new Uint8Array(v),M=new Array(b.length),B=0;B-1?b:v}function U(v,b){b=b||{};var M=b.body;if(v instanceof U){if(v.bodyUsed)throw new TypeError("Already read");this.url=v.url,this.credentials=v.credentials,b.headers||(this.headers=new y(v.headers)),this.method=v.method,this.mode=v.mode,this.signal=v.signal,!M&&v._bodyInit!=null&&(M=v._bodyInit,v.bodyUsed=!0)}else this.url=String(v);if(this.credentials=b.credentials||this.credentials||"same-origin",(b.headers||!this.headers)&&(this.headers=new y(b.headers)),this.method=I(b.method||this.method||"GET"),this.mode=b.mode||this.mode||null,this.signal=b.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&M)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(M)}U.prototype.clone=function(){return new U(this,{body:this._bodyInit})};function ie(v){var b=new FormData;return v.trim().split("&").forEach(function(M){if(M){var B=M.split("="),x=B.shift().replace(/\+/g," "),C=B.join("=").replace(/\+/g," ");b.append(decodeURIComponent(x),decodeURIComponent(C))}}),b}function ae(v){var b=new y,M=v.replace(/\r?\n[\t ]+/g," ");return M.split(/\r?\n/).forEach(function(B){var x=B.split(":"),C=x.shift().trim();if(C){var w=x.join(":").trim();b.append(C,w)}}),b}L.call(U.prototype);function K(v,b){b||(b={}),this.type="default",this.status=b.status===void 0?200:b.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in b?b.statusText:"OK",this.headers=new y(b.headers),this.url=b.url||"",this._initBody(v)}L.call(K.prototype),K.prototype.clone=function(){return new K(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},K.error=function(){var v=new K(null,{status:0,statusText:""});return v.type="error",v};var R=[301,302,303,307,308];K.redirect=function(v,b){if(R.indexOf(b)===-1)throw new RangeError("Invalid status code");return new K(null,{status:b,headers:{location:v}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(b,M){this.message=b,this.name=M;var B=Error(b);this.stack=B.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function D(v,b){return new Promise(function(M,B){var x=new U(v,b);if(x.signal&&x.signal.aborted)return B(new o.DOMException("Aborted","AbortError"));var C=new XMLHttpRequest;function w(){C.abort()}C.onload=function(){var k={status:C.status,statusText:C.statusText,headers:ae(C.getAllResponseHeaders()||"")};k.url="responseURL"in C?C.responseURL:k.headers.get("X-Request-URL");var O="response"in C?C.response:C.responseText;M(new K(O,k))},C.onerror=function(){B(new TypeError("Network request failed"))},C.ontimeout=function(){B(new TypeError("Network request failed"))},C.onabort=function(){B(new o.DOMException("Aborted","AbortError"))},C.open(x.method,x.url,!0),x.credentials==="include"?C.withCredentials=!0:x.credentials==="omit"&&(C.withCredentials=!1),"responseType"in C&&a.blob&&(C.responseType="blob"),x.headers.forEach(function(k,O){C.setRequestHeader(O,k)}),x.signal&&(x.signal.addEventListener("abort",w),C.onreadystatechange=function(){C.readyState===4&&x.signal.removeEventListener("abort",w)}),C.send(typeof x._bodyInit>"u"?null:x._bodyInit)})}return D.polyfill=!0,s.fetch||(s.fetch=D,s.Headers=y,s.Request=U,s.Response=K),o.Headers=y,o.Request=U,o.Response=K,o.fetch=D,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(jT,jT.exports);var Eqe=jT.exports;const vV=$u(Eqe);var Cqe=Object.defineProperty,Aqe=Object.defineProperties,Sqe=Object.getOwnPropertyDescriptors,gV=Object.getOwnPropertySymbols,_qe=Object.prototype.hasOwnProperty,Iqe=Object.prototype.propertyIsEnumerable,yV=(t,e,r)=>e in t?Cqe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mV=(t,e)=>{for(var r in e||(e={}))_qe.call(e,r)&&yV(t,r,e[r]);if(gV)for(var r of gV(e))Iqe.call(e,r)&&yV(t,r,e[r]);return t},bV=(t,e)=>Aqe(t,Sqe(e));const Tqe={Accept:"application/json","Content-Type":"application/json"},Pqe="POST",wV={headers:Tqe,method:Pqe},xV=10;let rl=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new wa.EventEmitter,this.isAvailable=!1,this.registering=!1,!$q(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}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 r=Uu(e),n=await(await vV(this.url,bV(mV({},wV),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!$q(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Uu({id:1,jsonrpc:"2.0",method:"test",params:[]});await vV(e,bV(mV({},wV),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);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 r=typeof e.data=="string"?cp(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=TC(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return Kne(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>xV&&this.events.setMaxListeners(xV)}};const EV="error",kqe="wss://relay.walletconnect.org",Rqe="wc",Mqe="universal_provider",CV=`${Rqe}@2:${Mqe}:`,mie="https://rpc.walletconnect.org/v1/",Av="generic",Oqe=`${mie}bundler`,pc={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Dqe=Object.defineProperty,Nqe=Object.defineProperties,Bqe=Object.getOwnPropertyDescriptors,AV=Object.getOwnPropertySymbols,Lqe=Object.prototype.hasOwnProperty,Fqe=Object.prototype.propertyIsEnumerable,SV=(t,e,r)=>e in t?Dqe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,E6=(t,e)=>{for(var r in e||(e={}))Lqe.call(e,r)&&SV(t,r,e[r]);if(AV)for(var r of AV(e))Fqe.call(e,r)&&SV(t,r,e[r]);return t},jqe=(t,e)=>Nqe(t,Bqe(e));function ga(t,e,r){var n;const i=xg(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${mie}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function Tp(t){return t.includes(":")?t.split(":")[1]:t}function bie(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Uqe(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function p7(t={},e={}){const r=_V(t),n=_V(e);return xqe.merge(r,n)}function _V(t){var e,r,n,i;const s={};if(!pw(t))return s;for(const[o,a]of Object.entries(t)){const c=TO(o)?[o]:a.chains,l=a.methods||[],f=a.events||[],u=a.rpcMap||{},h=Hb(o);s[h]=jqe(E6(E6({},s[h]),a),{chains:A5(c,(e=s[h])==null?void 0:e.chains),methods:A5(l,(r=s[h])==null?void 0:r.methods),events:A5(f,(n=s[h])==null?void 0:n.events),rpcMap:E6(E6({},u),(i=s[h])==null?void 0:i.rpcMap)})}return s}function $qe(t){return t.includes(":")?t.split(":")[2]:t}function IV(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=TO(r)?[r]:n.chains?n.chains:bie(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function v7(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const wie={},zr=t=>wie[t],g7=(t,e)=>{wie[t]=e};class qqe{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}var Vqe=Object.defineProperty,zqe=Object.defineProperties,Hqe=Object.getOwnPropertyDescriptors,TV=Object.getOwnPropertySymbols,Gqe=Object.prototype.hasOwnProperty,Wqe=Object.prototype.propertyIsEnumerable,PV=(t,e,r)=>e in t?Vqe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kV=(t,e)=>{for(var r in e||(e={}))Gqe.call(e,r)&&PV(t,r,e[r]);if(TV)for(var r of TV(e))Wqe.call(e,r)&&PV(t,r,e[r]);return t},RV=(t,e)=>zqe(t,Hqe(e));class Kqe{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(pc.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,r){const n=r||ga(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(Tp(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. 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 r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:RV(kV({},o.sessionProperties||{}),{capabilities:RV(kV({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(rh("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${Oqe}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}class Yqe{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class Qqe{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class Jqe{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){if(!this.httpProviders[e]){const n=r||ga(`${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(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new hc(new rl(n,zr("disableProviderPing")))}}class Zqe{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=Tp(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class Xqe{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class eVe{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class tVe{constructor(e){this.name="near",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||ga(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace);return typeof n>"u"?void 0:new hc(new rl(n,zr("disableProviderPing")))}}class rVe{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||ga(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace);return typeof n>"u"?void 0:new hc(new rl(n))}}class nVe{constructor(e){this.name=Av,this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=xg(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}var iVe=Object.defineProperty,sVe=Object.defineProperties,oVe=Object.getOwnPropertyDescriptors,MV=Object.getOwnPropertySymbols,aVe=Object.prototype.hasOwnProperty,cVe=Object.prototype.propertyIsEnumerable,OV=(t,e,r)=>e in t?iVe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,C6=(t,e)=>{for(var r in e||(e={}))aVe.call(e,r)&&OV(t,r,e[r]);if(MV)for(var r of MV(e))cVe.call(e,r)&&OV(t,r,e[r]);return t},y7=(t,e)=>sVe(t,oVe(e));let lVe=class xie{constructor(e){this.events=new iO,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:Ix(_C({level:(e==null?void 0:e.logger)||EV})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new xie(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:C6({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,IC(s,o))).catch(o=>r(o,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:sn("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,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=IV(this.session.namespaces);this.namespaces=p7(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=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 i().then(s=>{this.session=s;const o=IV(s.namespaces);this.namespaces=p7(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==yie)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===Av?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(cf(r)){for(const n of r)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: ${r.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 MC.init({core:this.providerOpts.core,logger:this.providerOpts.logger||EV,relayUrl:this.providerOpts.relayUrl||kqe,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(r=>Hb(r)))];g7("client",this.client),g7("events",this.events),g7("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=Uqe(r,this.session),i=bie(n),s=p7(this.namespaces,this.optionalNamespaces),o=y7(C6({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new Kqe({namespace:o});break;case"algorand":this.rpcProviders[r]=new Jqe({namespace:o});break;case"solana":this.rpcProviders[r]=new Yqe({namespace:o});break;case"cosmos":this.rpcProviders[r]=new Qqe({namespace:o});break;case"polkadot":this.rpcProviders[r]=new qqe({namespace:o});break;case"cip34":this.rpcProviders[r]=new Zqe({namespace:o});break;case"elrond":this.rpcProviders[r]=new Xqe({namespace:o});break;case"multiversx":this.rpcProviders[r]=new eVe({namespace:o});break;case"near":this.rpcProviders[r]=new tVe({namespace:o});break;case"tezos":this.rpcProviders[r]=new rVe({namespace:o});break;default:this.rpcProviders[Av]?this.rpcProviders[Av].updateNamespace(o):this.rpcProviders[Av]=new nVe({namespace:o})}})}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:r}=e,{event:n}=r;if(n.name==="accountsChanged"){const i=n.data;i&&cf(i)&&this.events.emit("accountsChanged",i.map($qe))}else if(n.name==="chainChanged"){const i=r.chainId,s=r.event.data,o=Hb(i),a=v7(i)!==v7(s)?`${o}:${v7(s)}`:i;this.onChainChanged(a)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n;const{namespaces:i}=r,s=(n=this.client)==null?void 0:n.session.get(e);this.session=y7(C6({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",y7(C6({},sn("USER_DISCONNECTED")),{data:e.topic}))}),this.on(pc.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Av]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>Hb(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=Hb(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);i&&(r||this.getProvider(n).setDefaultChain(i),this.namespaces[n]?this.namespaces[n].defaultChain=i:this.namespaces[`${n}:${i}`]?this.namespaces[`${n}:${i}`].defaultChain=i:this.namespaces[`${n}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}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,r){this.client.core.storage.setItem(`${CV}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${CV}/${e}`)}};const fVe=lVe,uVe="wc",dVe="ethereum_provider",hVe=`${uVe}@2:${dVe}:`,pVe="https://rpc.walletconnect.org/v1/",UT=["eth_sendTransaction","personal_sign"],vVe=["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"],$T=["chainChanged","accountsChanged"],gVe=["chainChanged","accountsChanged","message","disconnect","connect"];var yVe=Object.defineProperty,mVe=Object.defineProperties,bVe=Object.getOwnPropertyDescriptors,DV=Object.getOwnPropertySymbols,wVe=Object.prototype.hasOwnProperty,xVe=Object.prototype.propertyIsEnumerable,NV=(t,e,r)=>e in t?yVe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sv=(t,e)=>{for(var r in e||(e={}))wVe.call(e,r)&&NV(t,r,e[r]);if(DV)for(var r of DV(e))xVe.call(e,r)&&NV(t,r,e[r]);return t},m7=(t,e)=>mVe(t,bVe(e));function u8(t){return Number(t[0].split(":")[1])}function A6(t){return`0x${t.toString(16)}`}function EVe(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=t;if(!cf(e))throw new Error("Invalid chains");const c={chains:e,methods:n||UT,events:s||$T,rpcMap:Sv({},e.length?{[u8(e)]:a[u8(e)]}:{})},l=s==null?void 0:s.filter(g=>!$T.includes(g)),f=n==null?void 0:n.filter(g=>!UT.includes(g));if(!r&&!o&&!i&&!(l!=null&&l.length)&&!(f!=null&&f.length))return{required:e.length?c:void 0};const u=(l==null?void 0:l.length)&&(f==null?void 0:f.length)||!r,h={chains:[...new Set(u?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:vVe))],events:[...new Set(c.events.concat(o!=null&&o.length?o:gVe))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?h:void 0}}let CVe=class Eie{constructor(){this.events=new wa.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=hVe,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new Eie;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,n){this.signer.sendAsync(e,r,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:r,optional:n}=EVe(this.rpc);try{const i=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(m7(Sv({namespaces:Sv({},r&&{[this.namespace]:r})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(l=>{o(l)}).catch(l=>{a(new Error(l.message))})});if(!i)return;const s=iq(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:A6(this.chainId)})}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){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(s,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(m7(Sv({},e),{chains:this.rpc.chains}),r).then(c=>{s(c)}).catch(c=>{o(new Error(c.message))})}),i=n.session;if(i){const s=iq(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:A6(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:r}=e,{event:n}=r;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 r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",A6(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",m7(Sv({},sn("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,n;this.rpc.showQrModal&&((r=this.modal)==null||r.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 r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",A6(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,n;const i=(r=e==null?void 0:e.chains)!=null?r:[],s=(n=e==null?void 0:e.optionalChains)!=null?n:[],o=i.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=i.length?(e==null?void 0:e.methods)||UT:[],c=i.length?(e==null?void 0:e.events)||$T:[],l=(e==null?void 0:e.optionalMethods)||[],f=(e==null?void 0:e.optionalEvents)||[],u=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),h=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:i==null?void 0:i.map(g=>this.formatChainId(g)),optionalChains:s.map(g=>this.formatChainId(g)),methods:a,events:c,optionalMethods:l,optionalEvents:f,rpcMap:u,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:h,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const n={};return e.forEach(i=>{n[i]=this.getRpcUrl(i,r)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?u8(this.rpc.chains):u8(this.rpc.optionalChains),this.signer=await fVe.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 r;try{const{WalletConnectModal:n}=await _Pe(()=>import("./index-Bv3bTALs.js").then(i=>i.i),[]);r=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(Sv({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:r,optionalChains:n,rpcMap:i}=e;r&&cf(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)})),n&&cf(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(s=>this.formatChainId(s)),n.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)}))}getRpcUrl(e,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${pVe}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}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(r=>this.parseAccount(r))}};var Cie={exports:{}};/*! +}`;var gr=CN(function(){return Lr(se,Rt+"return "+qe).apply(r,he)});if(gr.source=qe,FA(gr))throw gr;return gr}function afe(d){return Jr(d).toLowerCase()}function cfe(d){return Jr(d).toUpperCase()}function lfe(d,p,_){if(d=Jr(d),d&&(_||p===r))return td(d);if(!d||!(p=Ho(p)))return d;var q=yo(d),J=yo(p),se=Bx(q,J),he=Lx(q,J)+1;return ud(q,se,he).join("")}function ffe(d,p,_){if(d=Jr(d),d&&(_||p===r))return d.slice(0,Dm(d)+1);if(!d||!(p=Ho(p)))return d;var q=yo(d),J=Lx(q,yo(p))+1;return ud(q,0,J).join("")}function ufe(d,p,_){if(d=Jr(d),d&&(_||p===r))return d.replace(Bt,"");if(!d||!(p=Ho(p)))return d;var q=yo(d),J=Bx(q,yo(p));return ud(q,J).join("")}function dfe(d,p){var _=ae,q=K;if(On(p)){var J="separator"in p?p.separator:J;_="length"in p?pr(p.length):_,q="omission"in p?Ho(p.omission):q}d=Jr(d);var se=d.length;if(Qr(d)){var he=yo(d);se=he.length}if(_>=se)return d;var me=_-Sf(q);if(me<1)return q;var Ce=he?ud(he,0,me).join(""):d.slice(0,me);if(J===r)return Ce+q;if(he&&(me+=Ce.length-me),jA(J)){if(d.slice(me).search(J)){var Be,Le=Ce;for(J.global||(J=Nm(J.source,Jr(tr.exec(J))+"g")),J.lastIndex=0;Be=J.exec(Le);)var qe=Be.index;Ce=Ce.slice(0,qe===r?me:qe)}}else if(d.indexOf(Ho(J),me)!=me){var ft=Ce.lastIndexOf(J);ft>-1&&(Ce=Ce.slice(0,ft))}return Ce+q}function hfe(d){return d=Jr(d),d&&Dt.test(d)?d.replace(ir,qx):d}var pfe=Jp(function(d,p,_){return d+(_?" ":"")+p.toUpperCase()}),qA=AD("toUpperCase");function EN(d,p,_){return d=Jr(d),p=_?r:p,p===r?Fx(d)?JC(d):UC(d):d.match(p)||[]}var CN=br(function(d,p){try{return li(d,r,p)}catch(_){return FA(_)?_:new Xt(_)}}),vfe=Rf(function(d,p){return go(p,function(_){_=ul(_),Pf(d,_,BA(d[_],d))}),d});function gfe(d){var p=d==null?0:d.length,_=Wt();return d=p?ln(d,function(q){if(typeof q[1]!="function")throw new mo(o);return[_(q[0]),q[1]]}):[],br(function(q){for(var J=-1;++Jx)return[];var _=k,q=hr(d,k);p=Wt(p),d-=k;for(var J=l0(q,p);++_0||p<0)?new kr(_):(d<0?_=_.takeRight(-d):d&&(_=_.drop(d)),p!==r&&(p=pr(p),_=p<0?_.dropRight(-p):_.take(p-d)),_)},kr.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},kr.prototype.toArray=function(){return this.take(k)},ll(kr.prototype,function(d,p){var _=/^(?:filter|find|map|reject)|While$/.test(p),q=/^(?:head|last)$/.test(p),J=ne[q?"take"+(p=="last"?"Right":""):p],se=q||/^find/.test(p);J&&(ne.prototype[p]=function(){var he=this.__wrapped__,me=q?[1]:arguments,Ce=he instanceof kr,Be=me[0],Le=Ce||sr(he),qe=function(Ar){var Dr=J.apply(ne,al([Ar],me));return q&&ft?Dr[0]:Dr};Le&&_&&typeof Be=="function"&&Be.length!=1&&(Ce=Le=!1);var ft=this.__chain__,Rt=!!this.__actions__.length,Yt=se&&!ft,gr=Ce&&!Rt;if(!se&&Le){he=gr?he:new kr(this);var Qt=d.apply(he,me);return Qt.__actions__.push({func:l3,args:[qe],thisArg:r}),new Sa(Qt,ft)}return Yt&&gr?d.apply(this,me):(Qt=this.thru(qe),Yt?q?Qt.value()[0]:Qt.value():Qt)})}),go(["pop","push","shift","sort","splice","unshift"],function(d){var p=$p[d],_=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",q=/^(?:pop|shift)$/.test(d);ne.prototype[d]=function(){var J=arguments;if(q&&!this.__chain__){var se=this.value();return p.apply(sr(se)?se:[],J)}return this[_](function(he){return p.apply(sr(he)?he:[],J)})}}),ll(kr.prototype,function(d,p){var _=ne[p];if(_){var q=_.name+"";Gr.call(mc,q)||(mc[q]=[]),mc[q].push({name:p,func:_})}}),mc[r3(r,E).name]=[{name:"wrapper",func:r}],kr.prototype.clone=hse,kr.prototype.reverse=pse,kr.prototype.value=vse,ne.prototype.at=zae,ne.prototype.chain=Hae,ne.prototype.commit=Gae,ne.prototype.next=Wae,ne.prototype.plant=Yae,ne.prototype.reverse=Qae,ne.prototype.toJSON=ne.prototype.valueOf=ne.prototype.value=Jae,ne.prototype.first=ne.prototype.head,z&&(ne.prototype[z]=Kae),ne},rd=ZC();pn?((pn.exports=rd)._=rd,rn._=rd):Cr._=rd}).call(xi)})(f8,f8.exports);var xqe=f8.exports,jT={exports:{}};(function(t,e){var r=typeof self<"u"?self:xi,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function c(v){return v&&DataView.prototype.isPrototypeOf(v)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(v){return v&&l.indexOf(Object.prototype.toString.call(v))>-1};function u(v){if(typeof v!="string"&&(v=String(v)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(v))throw new TypeError("Invalid character in header field name");return v.toLowerCase()}function h(v){return typeof v!="string"&&(v=String(v)),v}function g(v){var b={next:function(){var M=v.shift();return{done:M===void 0,value:M}}};return a.iterable&&(b[Symbol.iterator]=function(){return b}),b}function y(v){this.map={},v instanceof y?v.forEach(function(b,M){this.append(M,b)},this):Array.isArray(v)?v.forEach(function(b){this.append(b[0],b[1])},this):v&&Object.getOwnPropertyNames(v).forEach(function(b){this.append(b,v[b])},this)}y.prototype.append=function(v,b){v=u(v),b=h(b);var M=this.map[v];this.map[v]=M?M+", "+b:b},y.prototype.delete=function(v){delete this.map[u(v)]},y.prototype.get=function(v){return v=u(v),this.has(v)?this.map[v]:null},y.prototype.has=function(v){return this.map.hasOwnProperty(u(v))},y.prototype.set=function(v,b){this.map[u(v)]=h(b)},y.prototype.forEach=function(v,b){for(var M in this.map)this.map.hasOwnProperty(M)&&v.call(b,this.map[M],M,this)},y.prototype.keys=function(){var v=[];return this.forEach(function(b,M){v.push(M)}),g(v)},y.prototype.values=function(){var v=[];return this.forEach(function(b){v.push(b)}),g(v)},y.prototype.entries=function(){var v=[];return this.forEach(function(b,M){v.push([M,b])}),g(v)},a.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function m(v){if(v.bodyUsed)return Promise.reject(new TypeError("Already read"));v.bodyUsed=!0}function S(v){return new Promise(function(b,M){v.onload=function(){b(v.result)},v.onerror=function(){M(v.error)}})}function E(v){var b=new FileReader,M=S(b);return b.readAsArrayBuffer(v),M}function A(v){var b=new FileReader,M=S(b);return b.readAsText(v),M}function P(v){for(var b=new Uint8Array(v),M=new Array(b.length),B=0;B-1?b:v}function U(v,b){b=b||{};var M=b.body;if(v instanceof U){if(v.bodyUsed)throw new TypeError("Already read");this.url=v.url,this.credentials=v.credentials,b.headers||(this.headers=new y(v.headers)),this.method=v.method,this.mode=v.mode,this.signal=v.signal,!M&&v._bodyInit!=null&&(M=v._bodyInit,v.bodyUsed=!0)}else this.url=String(v);if(this.credentials=b.credentials||this.credentials||"same-origin",(b.headers||!this.headers)&&(this.headers=new y(b.headers)),this.method=I(b.method||this.method||"GET"),this.mode=b.mode||this.mode||null,this.signal=b.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&M)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(M)}U.prototype.clone=function(){return new U(this,{body:this._bodyInit})};function ie(v){var b=new FormData;return v.trim().split("&").forEach(function(M){if(M){var B=M.split("="),x=B.shift().replace(/\+/g," "),C=B.join("=").replace(/\+/g," ");b.append(decodeURIComponent(x),decodeURIComponent(C))}}),b}function ae(v){var b=new y,M=v.replace(/\r?\n[\t ]+/g," ");return M.split(/\r?\n/).forEach(function(B){var x=B.split(":"),C=x.shift().trim();if(C){var w=x.join(":").trim();b.append(C,w)}}),b}L.call(U.prototype);function K(v,b){b||(b={}),this.type="default",this.status=b.status===void 0?200:b.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in b?b.statusText:"OK",this.headers=new y(b.headers),this.url=b.url||"",this._initBody(v)}L.call(K.prototype),K.prototype.clone=function(){return new K(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},K.error=function(){var v=new K(null,{status:0,statusText:""});return v.type="error",v};var R=[301,302,303,307,308];K.redirect=function(v,b){if(R.indexOf(b)===-1)throw new RangeError("Invalid status code");return new K(null,{status:b,headers:{location:v}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(b,M){this.message=b,this.name=M;var B=Error(b);this.stack=B.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function D(v,b){return new Promise(function(M,B){var x=new U(v,b);if(x.signal&&x.signal.aborted)return B(new o.DOMException("Aborted","AbortError"));var C=new XMLHttpRequest;function w(){C.abort()}C.onload=function(){var k={status:C.status,statusText:C.statusText,headers:ae(C.getAllResponseHeaders()||"")};k.url="responseURL"in C?C.responseURL:k.headers.get("X-Request-URL");var O="response"in C?C.response:C.responseText;M(new K(O,k))},C.onerror=function(){B(new TypeError("Network request failed"))},C.ontimeout=function(){B(new TypeError("Network request failed"))},C.onabort=function(){B(new o.DOMException("Aborted","AbortError"))},C.open(x.method,x.url,!0),x.credentials==="include"?C.withCredentials=!0:x.credentials==="omit"&&(C.withCredentials=!1),"responseType"in C&&a.blob&&(C.responseType="blob"),x.headers.forEach(function(k,O){C.setRequestHeader(O,k)}),x.signal&&(x.signal.addEventListener("abort",w),C.onreadystatechange=function(){C.readyState===4&&x.signal.removeEventListener("abort",w)}),C.send(typeof x._bodyInit>"u"?null:x._bodyInit)})}return D.polyfill=!0,s.fetch||(s.fetch=D,s.Headers=y,s.Request=U,s.Response=K),o.Headers=y,o.Request=U,o.Response=K,o.fetch=D,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(jT,jT.exports);var Eqe=jT.exports;const vV=$u(Eqe);var Cqe=Object.defineProperty,Aqe=Object.defineProperties,Sqe=Object.getOwnPropertyDescriptors,gV=Object.getOwnPropertySymbols,_qe=Object.prototype.hasOwnProperty,Iqe=Object.prototype.propertyIsEnumerable,yV=(t,e,r)=>e in t?Cqe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mV=(t,e)=>{for(var r in e||(e={}))_qe.call(e,r)&&yV(t,r,e[r]);if(gV)for(var r of gV(e))Iqe.call(e,r)&&yV(t,r,e[r]);return t},bV=(t,e)=>Aqe(t,Sqe(e));const Tqe={Accept:"application/json","Content-Type":"application/json"},Pqe="POST",wV={headers:Tqe,method:Pqe},xV=10;let rl=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new wa.EventEmitter,this.isAvailable=!1,this.registering=!1,!$q(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}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 r=Uu(e),n=await(await vV(this.url,bV(mV({},wV),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!$q(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Uu({id:1,jsonrpc:"2.0",method:"test",params:[]});await vV(e,bV(mV({},wV),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);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 r=typeof e.data=="string"?cp(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=TC(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return Kne(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>xV&&this.events.setMaxListeners(xV)}};const EV="error",kqe="wss://relay.walletconnect.org",Rqe="wc",Mqe="universal_provider",CV=`${Rqe}@2:${Mqe}:`,mie="https://rpc.walletconnect.org/v1/",Av="generic",Oqe=`${mie}bundler`,pc={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Dqe=Object.defineProperty,Nqe=Object.defineProperties,Bqe=Object.getOwnPropertyDescriptors,AV=Object.getOwnPropertySymbols,Lqe=Object.prototype.hasOwnProperty,Fqe=Object.prototype.propertyIsEnumerable,SV=(t,e,r)=>e in t?Dqe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,E6=(t,e)=>{for(var r in e||(e={}))Lqe.call(e,r)&&SV(t,r,e[r]);if(AV)for(var r of AV(e))Fqe.call(e,r)&&SV(t,r,e[r]);return t},jqe=(t,e)=>Nqe(t,Bqe(e));function ga(t,e,r){var n;const i=xg(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${mie}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function Tp(t){return t.includes(":")?t.split(":")[1]:t}function bie(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Uqe(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function p7(t={},e={}){const r=_V(t),n=_V(e);return xqe.merge(r,n)}function _V(t){var e,r,n,i;const s={};if(!pw(t))return s;for(const[o,a]of Object.entries(t)){const c=TO(o)?[o]:a.chains,l=a.methods||[],f=a.events||[],u=a.rpcMap||{},h=Hb(o);s[h]=jqe(E6(E6({},s[h]),a),{chains:A5(c,(e=s[h])==null?void 0:e.chains),methods:A5(l,(r=s[h])==null?void 0:r.methods),events:A5(f,(n=s[h])==null?void 0:n.events),rpcMap:E6(E6({},u),(i=s[h])==null?void 0:i.rpcMap)})}return s}function $qe(t){return t.includes(":")?t.split(":")[2]:t}function IV(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=TO(r)?[r]:n.chains?n.chains:bie(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function v7(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const wie={},zr=t=>wie[t],g7=(t,e)=>{wie[t]=e};class qqe{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}var Vqe=Object.defineProperty,zqe=Object.defineProperties,Hqe=Object.getOwnPropertyDescriptors,TV=Object.getOwnPropertySymbols,Gqe=Object.prototype.hasOwnProperty,Wqe=Object.prototype.propertyIsEnumerable,PV=(t,e,r)=>e in t?Vqe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kV=(t,e)=>{for(var r in e||(e={}))Gqe.call(e,r)&&PV(t,r,e[r]);if(TV)for(var r of TV(e))Wqe.call(e,r)&&PV(t,r,e[r]);return t},RV=(t,e)=>zqe(t,Hqe(e));class Kqe{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(pc.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,r){const n=r||ga(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(Tp(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. 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 r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:RV(kV({},o.sessionProperties||{}),{capabilities:RV(kV({},a||{}),{[s]:c})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return c}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}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,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(rh("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${Oqe}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}class Yqe{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class Qqe{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class Jqe{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){if(!this.httpProviders[e]){const n=r||ga(`${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(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new hc(new rl(n,zr("disableProviderPing")))}}class Zqe{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=Tp(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class Xqe{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class eVe{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Tp(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}class tVe{constructor(e){this.name="near",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||ga(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace);return typeof n>"u"?void 0:new hc(new rl(n,zr("disableProviderPing")))}}class rVe{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||ga(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(pc.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace);return typeof n>"u"?void 0:new hc(new rl(n))}}class nVe{constructor(e){this.name=Av,this.namespace=e.namespace,this.events=zr("events"),this.client=zr("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,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(pc.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=xg(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||ga(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new hc(new rl(n,zr("disableProviderPing")))}}var iVe=Object.defineProperty,sVe=Object.defineProperties,oVe=Object.getOwnPropertyDescriptors,MV=Object.getOwnPropertySymbols,aVe=Object.prototype.hasOwnProperty,cVe=Object.prototype.propertyIsEnumerable,OV=(t,e,r)=>e in t?iVe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,C6=(t,e)=>{for(var r in e||(e={}))aVe.call(e,r)&&OV(t,r,e[r]);if(MV)for(var r of MV(e))cVe.call(e,r)&&OV(t,r,e[r]);return t},y7=(t,e)=>sVe(t,oVe(e));let lVe=class xie{constructor(e){this.events=new iO,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:Ix(_C({level:(e==null?void 0:e.logger)||EV})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new xie(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:C6({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,IC(s,o))).catch(o=>r(o,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:sn("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,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=IV(this.session.namespaces);this.namespaces=p7(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=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 i().then(s=>{this.session=s;const o=IV(s.namespaces);this.namespaces=p7(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==yie)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===Av?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(cf(r)){for(const n of r)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: ${r.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 MC.init({core:this.providerOpts.core,logger:this.providerOpts.logger||EV,relayUrl:this.providerOpts.relayUrl||kqe,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(r=>Hb(r)))];g7("client",this.client),g7("events",this.events),g7("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=Uqe(r,this.session),i=bie(n),s=p7(this.namespaces,this.optionalNamespaces),o=y7(C6({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new Kqe({namespace:o});break;case"algorand":this.rpcProviders[r]=new Jqe({namespace:o});break;case"solana":this.rpcProviders[r]=new Yqe({namespace:o});break;case"cosmos":this.rpcProviders[r]=new Qqe({namespace:o});break;case"polkadot":this.rpcProviders[r]=new qqe({namespace:o});break;case"cip34":this.rpcProviders[r]=new Zqe({namespace:o});break;case"elrond":this.rpcProviders[r]=new Xqe({namespace:o});break;case"multiversx":this.rpcProviders[r]=new eVe({namespace:o});break;case"near":this.rpcProviders[r]=new tVe({namespace:o});break;case"tezos":this.rpcProviders[r]=new rVe({namespace:o});break;default:this.rpcProviders[Av]?this.rpcProviders[Av].updateNamespace(o):this.rpcProviders[Av]=new nVe({namespace:o})}})}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:r}=e,{event:n}=r;if(n.name==="accountsChanged"){const i=n.data;i&&cf(i)&&this.events.emit("accountsChanged",i.map($qe))}else if(n.name==="chainChanged"){const i=r.chainId,s=r.event.data,o=Hb(i),a=v7(i)!==v7(s)?`${o}:${v7(s)}`:i;this.onChainChanged(a)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n;const{namespaces:i}=r,s=(n=this.client)==null?void 0:n.session.get(e);this.session=y7(C6({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",y7(C6({},sn("USER_DISCONNECTED")),{data:e.topic}))}),this.on(pc.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Av]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>Hb(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=Hb(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);i&&(r||this.getProvider(n).setDefaultChain(i),this.namespaces[n]?this.namespaces[n].defaultChain=i:this.namespaces[`${n}:${i}`]?this.namespaces[`${n}:${i}`].defaultChain=i:this.namespaces[`${n}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}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,r){this.client.core.storage.setItem(`${CV}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${CV}/${e}`)}};const fVe=lVe,uVe="wc",dVe="ethereum_provider",hVe=`${uVe}@2:${dVe}:`,pVe="https://rpc.walletconnect.org/v1/",UT=["eth_sendTransaction","personal_sign"],vVe=["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"],$T=["chainChanged","accountsChanged"],gVe=["chainChanged","accountsChanged","message","disconnect","connect"];var yVe=Object.defineProperty,mVe=Object.defineProperties,bVe=Object.getOwnPropertyDescriptors,DV=Object.getOwnPropertySymbols,wVe=Object.prototype.hasOwnProperty,xVe=Object.prototype.propertyIsEnumerable,NV=(t,e,r)=>e in t?yVe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sv=(t,e)=>{for(var r in e||(e={}))wVe.call(e,r)&&NV(t,r,e[r]);if(DV)for(var r of DV(e))xVe.call(e,r)&&NV(t,r,e[r]);return t},m7=(t,e)=>mVe(t,bVe(e));function u8(t){return Number(t[0].split(":")[1])}function A6(t){return`0x${t.toString(16)}`}function EVe(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=t;if(!cf(e))throw new Error("Invalid chains");const c={chains:e,methods:n||UT,events:s||$T,rpcMap:Sv({},e.length?{[u8(e)]:a[u8(e)]}:{})},l=s==null?void 0:s.filter(g=>!$T.includes(g)),f=n==null?void 0:n.filter(g=>!UT.includes(g));if(!r&&!o&&!i&&!(l!=null&&l.length)&&!(f!=null&&f.length))return{required:e.length?c:void 0};const u=(l==null?void 0:l.length)&&(f==null?void 0:f.length)||!r,h={chains:[...new Set(u?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:vVe))],events:[...new Set(c.events.concat(o!=null&&o.length?o:gVe))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?h:void 0}}let CVe=class Eie{constructor(){this.events=new wa.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=hVe,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new Eie;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,n){this.signer.sendAsync(e,r,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:r,optional:n}=EVe(this.rpc);try{const i=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(m7(Sv({namespaces:Sv({},r&&{[this.namespace]:r})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(l=>{o(l)}).catch(l=>{a(new Error(l.message))})});if(!i)return;const s=iq(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:A6(this.chainId)})}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){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(s,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(m7(Sv({},e),{chains:this.rpc.chains}),r).then(c=>{s(c)}).catch(c=>{o(new Error(c.message))})}),i=n.session;if(i){const s=iq(i.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:A6(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:r}=e,{event:n}=r;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 r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",A6(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",m7(Sv({},sn("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,n;this.rpc.showQrModal&&((r=this.modal)==null||r.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 r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",A6(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,n;const i=(r=e==null?void 0:e.chains)!=null?r:[],s=(n=e==null?void 0:e.optionalChains)!=null?n:[],o=i.concat(s);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=i.length?(e==null?void 0:e.methods)||UT:[],c=i.length?(e==null?void 0:e.events)||$T:[],l=(e==null?void 0:e.optionalMethods)||[],f=(e==null?void 0:e.optionalEvents)||[],u=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),h=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:i==null?void 0:i.map(g=>this.formatChainId(g)),optionalChains:s.map(g=>this.formatChainId(g)),methods:a,events:c,optionalMethods:l,optionalEvents:f,rpcMap:u,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:h,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const n={};return e.forEach(i=>{n[i]=this.getRpcUrl(i,r)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?u8(this.rpc.chains):u8(this.rpc.optionalChains),this.signer=await fVe.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 r;try{const{WalletConnectModal:n}=await _Pe(()=>import("./index-DBvK_T1-.js").then(i=>i.i),[]);r=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(Sv({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:r,optionalChains:n,rpcMap:i}=e;r&&cf(r)&&(this.rpc.chains=r.map(s=>this.formatChainId(s)),r.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)})),n&&cf(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(s=>this.formatChainId(s)),n.forEach(s=>{this.rpc.rpcMap[s]=(i==null?void 0:i[s])||this.getRpcUrl(s)}))}getRpcUrl(e,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${pVe}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}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(r=>this.parseAccount(r))}};var Cie={exports:{}};/*! * EventEmitter2 * https://github.com/hij1nx/EventEmitter2 * diff --git a/assets/index-CshDNFfX.js b/assets/index-CtcyC_mc.js similarity index 99% rename from assets/index-CshDNFfX.js rename to assets/index-CtcyC_mc.js index 0ef3cb6..b54a7a1 100644 --- a/assets/index-CshDNFfX.js +++ b/assets/index-CtcyC_mc.js @@ -1,4 +1,4 @@ -import{T as xt,M as re,R as N,E as k,C as x,a as X,b as Wo,O as Z,c as ht}from"./index-Bv3bTALs.js";import"./index-DL1n5f57.js";/** +import{T as xt,M as re,R as N,E as k,C as x,a as X,b as Wo,O as Z,c as ht}from"./index-DBvK_T1-.js";import"./index-Btp85TCW.js";/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause diff --git a/assets/index-Bv3bTALs.js b/assets/index-DBvK_T1-.js similarity index 98% rename from assets/index-Bv3bTALs.js rename to assets/index-DBvK_T1-.js index 786b7e2..95466a3 100644 --- a/assets/index-Bv3bTALs.js +++ b/assets/index-DBvK_T1-.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CshDNFfX.js","assets/index-DL1n5f57.js","assets/index-BJqNCU1U.css"])))=>i.map(i=>d[i]); -import{_ as pe}from"./index-DL1n5f57.js";const me=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,he=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},F=e=>typeof e=="object"&&e!==null,C=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>F(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(w,!0),l.set(o,[g,w]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(w,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(C.has(O)){const[y,H]=C.get(O);A.value=c(y,H(),I)}Object.defineProperty(w,j,A)}),Object.preventExtensions(w)},d=new WeakMap,f=[1,1],W=o=>{if(!F(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,w=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],w(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const k=r[3](A(U));y.set(U,[r,k])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&w(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),k=Reflect.get(i,a,h);if(U&&(e(k,r)||d.has(r)&&e(k,d.get(r))))return!0;Z(a),F(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(L=>{r.status="fulfilled",r.value=L,w(["resolve",[a],L])}).catch(L=>{r.status="rejected",r.reason=L,w(["reject",[a],L])});else{!C.has(r)&&s(r)&&(V=W(r));const L=!x.has(V)&&C.get(V);L&&H(a,L)}return Reflect.set(i,a,V,h),w(["set",[a],r,k]),!0}});d.set(o,R);const fe=[q,O,c,ue];return C.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,C,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=C.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function we(e,t){const s=C.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return D(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=Buffer.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},be=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:be,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(we(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),b={state:_,subscribe(e){return D(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),b.setChains(e.chains),b.setIsAuth(!!e.enableAuthMode),b.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),b.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var _e=Object.defineProperty,se=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=We({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",$.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Le=Object.defineProperty,oe=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Pe.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ne={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=$.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=b.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Ae({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=$.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),b.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),J={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=b.state;if(m.removeWalletConnectDeepLink(),b.setWalletConnectUri(e==null?void 0:e.uri),b.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=b.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var Me=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))De.call(t,s)&&le(e,s,t[s]);return e};function Ue(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const N=P({themeMode:Ue()?"dark":"light"}),ce={state:N,subscribe(e){return D(N,()=>e(N))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(N.themeMode=t),s&&(N.themeVariables=je({},s))}},S=P({open:!1,message:"",variant:"success"}),Re={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Te{constructor(t){this.openModal=J.open,this.closeModal=J.close,this.subscribeModal=J.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-CshDNFfX.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),b.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,Ne as E,J as M,b as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CtcyC_mc.js","assets/index-Btp85TCW.js","assets/index-BJqNCU1U.css"])))=>i.map(i=>d[i]); +import{_ as pe}from"./index-Btp85TCW.js";const me=Symbol(),ee=Object.getPrototypeOf,Y=new WeakMap,he=e=>e&&(Y.has(e)?Y.get(e):ee(e)===Object.prototype||ee(e)===Array.prototype),ge=e=>he(e)&&e[me]||null,te=(e,t=!0)=>{Y.set(e,t)},z={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},F=e=>typeof e=="object"&&e!==null,C=new WeakMap,x=new WeakSet,ye=(e=Object.is,t=(o,g)=>new Proxy(o,g),s=o=>F(o)&&!x.has(o)&&(Array.isArray(o)||!(Symbol.iterator in o))&&!(o instanceof WeakMap)&&!(o instanceof WeakSet)&&!(o instanceof Error)&&!(o instanceof Number)&&!(o instanceof Date)&&!(o instanceof String)&&!(o instanceof RegExp)&&!(o instanceof ArrayBuffer),n=o=>{switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:throw o}},l=new WeakMap,c=(o,g,I=n)=>{const v=l.get(o);if((v==null?void 0:v[0])===g)return v[1];const w=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o));return te(w,!0),l.set(o,[g,w]),Reflect.ownKeys(o).forEach(j=>{if(Object.getOwnPropertyDescriptor(w,j))return;const O=Reflect.get(o,j),A={value:O,enumerable:!0,configurable:!0};if(x.has(O))te(O,!1);else if(O instanceof Promise)delete A.value,A.get=()=>I(O);else if(C.has(O)){const[y,H]=C.get(O);A.value=c(y,H(),I)}Object.defineProperty(w,j,A)}),Object.preventExtensions(w)},d=new WeakMap,f=[1,1],W=o=>{if(!F(o))throw new Error("object required");const g=d.get(o);if(g)return g;let I=f[0];const v=new Set,w=(i,a=++f[0])=>{I!==a&&(I=a,v.forEach(r=>r(i,a)))};let j=f[1];const O=(i=++f[1])=>(j!==i&&!v.size&&(j=i,y.forEach(([a])=>{const r=a[1](i);r>I&&(I=r)})),I),A=i=>(a,r)=>{const h=[...a];h[1]=[i,...h[1]],w(h,r)},y=new Map,H=(i,a)=>{if((z?"production":void 0)!=="production"&&y.has(i))throw new Error("prop listener already exists");if(v.size){const r=a[3](A(i));y.set(i,[a,r])}else y.set(i,[a])},Z=i=>{var a;const r=y.get(i);r&&(y.delete(i),(a=r[1])==null||a.call(r))},ue=i=>(v.add(i),v.size===1&&y.forEach(([r,h],U)=>{if((z?"production":void 0)!=="production"&&h)throw new Error("remove already exists");const k=r[3](A(U));y.set(U,[r,k])}),()=>{v.delete(i),v.size===0&&y.forEach(([r,h],U)=>{h&&(h(),y.set(U,[r]))})}),q=Array.isArray(o)?[]:Object.create(Object.getPrototypeOf(o)),R=t(q,{deleteProperty(i,a){const r=Reflect.get(i,a);Z(a);const h=Reflect.deleteProperty(i,a);return h&&w(["delete",[a],r]),h},set(i,a,r,h){const U=Reflect.has(i,a),k=Reflect.get(i,a,h);if(U&&(e(k,r)||d.has(r)&&e(k,d.get(r))))return!0;Z(a),F(r)&&(r=ge(r)||r);let V=r;if(r instanceof Promise)r.then(L=>{r.status="fulfilled",r.value=L,w(["resolve",[a],L])}).catch(L=>{r.status="rejected",r.reason=L,w(["reject",[a],L])});else{!C.has(r)&&s(r)&&(V=W(r));const L=!x.has(V)&&C.get(V);L&&H(a,L)}return Reflect.set(i,a,V,h),w(["set",[a],r,k]),!0}});d.set(o,R);const fe=[q,O,c,ue];return C.set(R,fe),Reflect.ownKeys(o).forEach(i=>{const a=Object.getOwnPropertyDescriptor(o,i);"value"in a&&(R[i]=o[i],delete a.value,delete a.writable),Object.defineProperty(q,i,a)}),R})=>[W,C,x,e,t,s,n,l,c,d,f],[ve]=ye();function P(e={}){return ve(e)}function D(e,t,s){const n=C.get(e);(z?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let l;const c=[],d=n[3];let f=!1;const o=d(g=>{c.push(g),l||(l=Promise.resolve().then(()=>{l=void 0,f&&t(c.splice(0))}))});return f=!0,()=>{f=!1,o()}}function we(e,t){const s=C.get(e);(z?"production":void 0)!=="production"&&!s&&console.warn("Please use proxy object");const[n,l,c]=s;return c(n,l(),t)}const u=P({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),de={state:u,subscribe(e){return D(u,()=>e(u))},push(e,t){e!==u.view&&(u.view=e,t&&(u.data=t),u.history.push(e))},reset(e){u.view=e,u.history=[e]},replace(e){u.history.length>1&&(u.history[u.history.length-1]=e,u.view=e)},goBack(){if(u.history.length>1){u.history.pop();const[e]=u.history.slice(-1);u.view=e}},setData(e){u.data=e}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return m.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;if(n.startsWith("https://t.me")){const c=Buffer.from(t).toString("base64").replace(/[=]/g,"");n.endsWith("/")&&(n=n.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const d=new URL(n);return d.searchParams.set("startapp",c),d.toString()}n.endsWith("/")||(n=`${n}/`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){const s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(m.WCM_VERSION,"2.7.0")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=de.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},be=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),p=P({enabled:be,userSessionId:"",events:[],connectedWalletId:void 0}),Ie={state:p,subscribe(e){return D(p.events,()=>e(we(p.events[p.events.length-1])))},initialize(){p.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(p.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){p.connectedWalletId=e},click(e){if(p.enabled){const t={type:"CLICK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},track(e){if(p.enabled){const t={type:"TRACK",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}},view(e){if(p.enabled){const t={type:"VIEW",name:e.name,userSessionId:p.userSessionId,timestamp:Date.now(),data:e};p.events.push(t)}}},_=P({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),b={state:_,subscribe(e){return D(_,()=>e(_))},setChains(e){_.chains=e},setWalletConnectUri(e){_.walletConnectUri=e},setIsCustomDesktop(e){_.isCustomDesktop=e},setIsCustomMobile(e){_.isCustomMobile=e},setIsDataLoaded(e){_.isDataLoaded=e},setIsUiLoaded(e){_.isUiLoaded=e},setIsAuth(e){_.isAuth=e}},B=P({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),$={state:B,subscribe(e){return D(B,()=>e(B))},setConfig(e){var t,s;Ie.initialize(),b.setChains(e.chains),b.setIsAuth(!!e.enableAuthMode),b.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),b.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),m.setModalVersionInStorage(),Object.assign(B,e)}};var _e=Object.defineProperty,se=Object.getOwnPropertySymbols,Ee=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,ne=(e,t,s)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,We=(e,t)=>{for(var s in t||(t={}))Ee.call(t,s)&&ne(e,s,t[s]);if(se)for(var s of se(t))Oe.call(t,s)&&ne(e,s,t[s]);return e};const G="https://explorer-api.walletconnect.com",Q="wcm",X="js-2.7.0";async function K(e,t){const s=We({sdkType:Q,sdkVersion:X},t),n=new URL(e,G);return n.searchParams.append("projectId",$.state.projectId),Object.entries(s).forEach(([c,d])=>{d&&n.searchParams.append(c,String(d))}),(await fetch(n)).json()}const M={async getDesktopListings(e){return K("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return K("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return K("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return K("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${G}/w3m/v1/getWalletImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`},getAssetImageUrl(e){return`${G}/w3m/v1/getAssetImage/${e}?projectId=${$.state.projectId}&sdkType=${Q}&sdkVersion=${X}`}};var Le=Object.defineProperty,oe=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,re=(e,t,s)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ae=(e,t)=>{for(var s in t||(t={}))Ce.call(t,s)&&re(e,s,t[s]);if(oe)for(var s of oe(t))Pe.call(t,s)&&re(e,s,t[s]);return e};const ae=m.isMobile(),E=P({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),Ne={state:E,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=$.state;if(e==="NONE"||t==="ALL"&&!e)return E.recomendedWallets;if(m.isArray(e)){const n={recommendedIds:e.join(",")},{listings:l}=await M.getAllListings(n),c=Object.values(l);c.sort((d,f)=>{const W=e.indexOf(d.id),o=e.indexOf(f.id);return W-o}),E.recomendedWallets=c}else{const{chains:s,isAuth:n}=b.state,l=s==null?void 0:s.join(","),c=m.isArray(t),d={page:1,sdks:n?"auth_v1":void 0,entries:m.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:c?t.join(","):void 0},{listings:f}=ae?await M.getMobileListings(d):await M.getDesktopListings(d);E.recomendedWallets=Object.values(f)}return E.recomendedWallets},async getWallets(e){const t=Ae({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:n}=$.state,{recomendedWallets:l}=E;if(n==="ALL")return E.wallets;l.length?t.excludedIds=l.map(I=>I.id).join(","):m.isArray(s)&&(t.excludedIds=s.join(",")),m.isArray(n)&&(t.excludedIds=[t.excludedIds,n].filter(Boolean).join(",")),b.state.isAuth&&(t.sdks="auth_v1");const{page:c,search:d}=e,{listings:f,total:W}=ae?await M.getMobileListings(t):await M.getDesktopListings(t),o=Object.values(f),g=d?"search":"wallets";return E[g]={listings:[...E[g].listings,...o],total:W,page:c??1},{listings:o,total:W}},getWalletImageUrl(e){return M.getWalletImageUrl(e)},getAssetImageUrl(e){return M.getAssetImageUrl(e)},resetSearch(){E.search={listings:[],total:0,page:1}}},T=P({open:!1}),J={state:T,subscribe(e){return D(T,()=>e(T))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:n}=b.state;if(m.removeWalletConnectDeepLink(),b.setWalletConnectUri(e==null?void 0:e.uri),b.setChains(e==null?void 0:e.chains),de.reset("ConnectWallet"),s&&n)T.open=!0,t();else{const l=setInterval(()=>{const c=b.state;c.isUiLoaded&&c.isDataLoaded&&(clearInterval(l),T.open=!0,t())},200)}})},close(){T.open=!1}};var Me=Object.defineProperty,ie=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,je=(e,t)=>{for(var s in t||(t={}))Se.call(t,s)&&le(e,s,t[s]);if(ie)for(var s of ie(t))De.call(t,s)&&le(e,s,t[s]);return e};function Ue(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const N=P({themeMode:Ue()?"dark":"light"}),ce={state:N,subscribe(e){return D(N,()=>e(N))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(N.themeMode=t),s&&(N.themeVariables=je({},s))}},S=P({open:!1,message:"",variant:"success"}),Re={state:S,subscribe(e){return D(S,()=>e(S))},openToast(e,t){S.open=!0,S.message=e,S.variant=t},closeToast(){S.open=!1}};class Te{constructor(t){this.openModal=J.open,this.closeModal=J.close,this.subscribeModal=J.subscribe,this.setTheme=ce.setThemeConfig,ce.setThemeConfig(t),$.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await pe(()=>import("./index-CtcyC_mc.js"),__vite__mapDeps([0,1,2]));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),b.setIsUiLoaded(!0)}}}const Ve=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Te},Symbol.toStringTag,{value:"Module"}));export{m as C,Ne as E,J as M,b as O,de as R,ce as T,Re as a,Ie as b,$ as c,Ve as i}; diff --git a/index.html b/index.html index 7667ffb..598a7f0 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Sequence Recovery Wallet - +