@dcl/auth-site 4.20.1-29269215567.commit-a168e3f → 4.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{ConstantsUtil-D1WLKDE-.js → ConstantsUtil-SfeDQRNO.js} +1 -1
- package/assets/{ContentfulRichText-FVjmh8mR.js → ContentfulRichText-B493-l1G.js} +1 -1
- package/assets/{ExchangeController-BxyxYUKZ.js → ExchangeController-Cl7LpW_9.js} +1 -1
- package/assets/{HelpersUtil-DtAz3pBV.js → HelpersUtil-BqxjBOsb.js} +1 -1
- package/assets/LoginPage-3mBiytHd.js +1 -0
- package/assets/{NetworkUtil-BcejqRTW.js → NetworkUtil-WtQP9K5L.js} +1 -1
- package/assets/{SwapController-73H8AJso.js → SwapController-C3sOw1fb.js} +1 -1
- package/assets/{W3MFrameProviderSingleton-Ch6ChvE7.js → W3MFrameProviderSingleton-GariHyC1.js} +3 -3
- package/assets/{biconomy-D8d8IXiO.js → biconomy-ok_Fev4O.js} +1 -1
- package/assets/{browser-W1csxV8_.js → browser-CL7pc_C2.js} +1 -1
- package/assets/browser-ponyfill-B9OjpPGs.js +1 -0
- package/assets/{ccip-DCHn-5Ly.js → ccip-BlbxM0LQ.js} +1 -1
- package/assets/{ccip-D27X7965.js → ccip-CFiU7kCg.js} +1 -1
- package/assets/{chains-Cn1WlLOp.js → chains-CGXwPY-w.js} +1 -1
- package/assets/{common-tpLjuIr4.js → common-CvKtb4n1.js} +1 -1
- package/assets/{controller-UwO1SN8i.js → controller-BFbz0Wfy.js} +2 -2
- package/assets/{data-capture-Dh-nweo4.js → data-capture-Bjp5qmbu.js} +1 -1
- package/assets/{email-1UrgYZj-.js → email-dOZOTXLM.js} +1 -1
- package/assets/{embedded-wallet-CLpjPJB3.js → embedded-wallet-4C0zCBzD.js} +1 -1
- package/assets/{engine-DCBK_VOQ.js → engine-BF4fgHph.js} +1 -1
- package/assets/{estimate-l1-fee-BiwlHSf1.js → estimate-l1-fee-DFM9SNlY.js} +1 -1
- package/assets/{ethereum--b_BvyFy.js → ethereum-D1IvEqvR.js} +1 -1
- package/assets/{extractIPFS-B5PPp_Gm.js → extractIPFS-DJ38044A.js} +1 -1
- package/assets/{features-C5Jgw5I-.js → features-Dq7eLLHj.js} +1 -1
- package/assets/{fetchTokenMetadata-vXUP7U_6.js → fetchTokenMetadata-DFbXfV36.js} +1 -1
- package/assets/{fortmatic-vxyuQsp3.js → fortmatic-VXwlmn3x.js} +1 -1
- package/assets/{get-ecosystem-wallet-info-k8z19lvl.js → get-ecosystem-wallet-info-7Lw-sZ_z.js} +1 -1
- package/assets/{getBalance-BMgSFA2M.js → getBalance-lwqG5BkA.js} +1 -1
- package/assets/{getInstalledModules-DfESwpSd.js → getInstalledModules-BqEUrGDu.js} +1 -1
- package/assets/{getNFT-CR4D5mRM.js → getNFT-CdoOvyuq.js} +2 -2
- package/assets/{getNFT-Drb8KYgY.js → getNFT-qEDnShr-.js} +1 -1
- package/assets/{if-defined-BLUpxRFe.js → if-defined-CqpJarBn.js} +1 -1
- package/assets/{in-app-wallet-calls-CpSZ4AEs.js → in-app-wallet-calls-DnbOJdqi.js} +1 -1
- package/assets/{index-BgJCDn2i.js → index-48_zL_8V.js} +3 -3
- package/assets/{index-uMURdbl1.js → index-4Rm21Jcs.js} +1 -1
- package/assets/{index-ChZiIgQr.js → index-B4nv3uRr.js} +1 -1
- package/assets/{index-CRvP0-6j.js → index-B90inivw.js} +1 -1
- package/assets/{index-Dc7LPwqa.js → index-BGzx8xC8.js} +1 -1
- package/assets/{index-FC7wyxSL.js → index-BNctYT5W.js} +1 -1
- package/assets/{index-bVJLpFe9.js → index-BZnk5nGE.js} +1 -1
- package/assets/{index-BRSVe_Ha.js → index-BehUnmBQ.js} +1 -1
- package/assets/{index-B0b0mXhy.js → index-BgA11815.js} +1 -1
- package/assets/{index-CLhB4G-z.js → index-BgjSH5C0.js} +2 -2
- package/assets/{index-BBbd2JGA.js → index-Bmtxr8ck.js} +1 -1
- package/assets/{index-D7YbgLzU.js → index-BnEh4tgY.js} +1 -1
- package/assets/{index-BfS3YMbV.js → index-BnMK4rtE.js} +1 -1
- package/assets/{index-BjRsFS7f.js → index-BxDS7YgF.js} +1 -1
- package/assets/{index-BqsCFid8.js → index-C0a8a3_a.js} +1 -1
- package/assets/{index-CYQL0N_2.js → index-C2wXt8bX.js} +1 -1
- package/assets/{index-wa52fI50.js → index-C9zadnoP.js} +1 -1
- package/assets/{index-Byc3YIzR.js → index-CA_7NqLN.js} +2 -2
- package/assets/{index-BjMnYwkm.js → index-CJQ7XUF1.js} +1 -1
- package/assets/{index-C7rQpKd5.js → index-CMVgYvcj.js} +1 -1
- package/assets/{index-D4MI3QNi.js → index-CNiv2JYH.js} +1 -1
- package/assets/{index-ButPZc2m.js → index-COjWxfCR.js} +1 -1
- package/assets/{index-Dpiro8hw.js → index-CSkZf6TU.js} +1 -1
- package/assets/{index-0Xh_8t-W.js → index-CVYOFAvL.js} +1 -1
- package/assets/{index-BxcO2eus.js → index-CVqr-7Pt.js} +1 -1
- package/assets/{index-6iU19F1Q.js → index-CZRVN2vE.js} +1 -1
- package/assets/{index-CfRwmSIm.js → index-C_o5O_iU.js} +9 -9
- package/assets/{index-BqL1TOTU.js → index-CgTPsSZC.js} +1 -1
- package/assets/{index-t4TDOvhg.js → index-CmYKoHtM.js} +1 -1
- package/assets/{index-DbBb4_zM.js → index-CpyBHHGL.js} +1 -1
- package/assets/{index-BeJFBKfZ.js → index-CusnlpEv.js} +1 -1
- package/assets/{index-gEWsoeoj.js → index-Czf8Yu5V.js} +1 -1
- package/assets/{index-BGImxKnk.js → index-D28HIM1b.js} +1 -1
- package/assets/{index-BbU4jWmF.js → index-D3-eBZaP.js} +1 -1
- package/assets/{index-Dy0kafyd.js → index-DJKVllQq.js} +1 -1
- package/assets/{index-Boyp-nKd.js → index-DLztodpx.js} +3 -3
- package/assets/{index-BnBi3XT_.js → index-DO37X-UR.js} +1 -1
- package/assets/{index-FTloM5tR.js → index-DWhePAr8.js} +1 -1
- package/assets/index-DdAb4cgP.css +1 -0
- package/assets/{index-hV7VprO9.js → index-DhrbQM9o.js} +1 -1
- package/assets/{index-Dw0jehUl.js → index-DkoCaWFP.js} +1 -1
- package/assets/{index-y1LmxmxV.js → index-DpgCenmo.js} +1 -1
- package/assets/{index-B0zN8-JK.js → index-Dqf3E5Am.js} +1 -1
- package/assets/{index-BOhMx_xq.js → index-DxTxoCQ5.js} +1 -1
- package/assets/{index-BgXz7S15.js → index-MOkgM3CG.js} +1 -1
- package/assets/{index-B61juR-E.js → index-aGypPCn4.js} +1 -1
- package/assets/{index-DqsqcBWz.js → index-lExqs17M.js} +1 -1
- package/assets/{index-Bw38Qien.js → index-ltBsvN7l.js} +1 -1
- package/assets/{index.es-bckiMtUI.js → index.es-DnpWJXa6.js} +1 -1
- package/assets/{index.es-CwJH2io5.js → index.es-obcdOSPN.js} +1 -1
- package/assets/{native-BxoXPUnu.js → native-B7Tb9XD0.js} +1 -1
- package/assets/{networks-DJg10bEc.js → networks-xZgfuUkI.js} +3 -3
- package/assets/{onramp-B4pEvCie.js → onramp-DRY-VmEl.js} +1 -1
- package/assets/{openzeppelin-aTaIao0N.js → openzeppelin-BZfSJIk4.js} +1 -1
- package/assets/{ownerOf-_31Y1xvr.js → ownerOf-Chv3cItD.js} +1 -1
- package/assets/{parseNft-BreIwf-v.js → parseNft-d6d6Hp6d.js} +2 -2
- package/assets/{pay-with-exchange-DWzTSiHz.js → pay-with-exchange-Fws3sgDP.js} +1 -1
- package/assets/{qr-overlay-ri_FAG95.js → qr-overlay-CRwPPsut.js} +3 -3
- package/assets/{receive-BhwBfPBx.js → receive-ENeHUThj.js} +1 -1
- package/assets/{ref-C6y6rEPL.js → ref-BJXu_ix1.js} +1 -1
- package/assets/{resolveImplementation-DDfKMK0l.js → resolveImplementation-BDMCDrvF.js} +1 -1
- package/assets/{secp256k1-fwuTEIeg.js → secp256k1-CAuxtucr.js} +1 -1
- package/assets/{send-DQ_s7hBA.js → send-BVveMXEO.js} +1 -1
- package/assets/{send-eip712-transaction-P-r3Ko22.js → send-eip712-transaction-BLYLbaE2.js} +1 -1
- package/assets/{send-gasless-transaction-CA021mhn.js → send-gasless-transaction-H5yovUSA.js} +2 -2
- package/assets/{session-proposal-2lV42kFm.js → session-proposal-BOVuEqZb.js} +1 -1
- package/assets/{session-request-BG0E-HG_.js → session-request-u0q6IDVU.js} +2 -2
- package/assets/{socials-BwTV76GY.js → socials-CT51nzyt.js} +1 -1
- package/assets/{swaps-BlfTMX7q.js → swaps-DcnyL-aF.js} +1 -1
- package/assets/{thirdweb-CT38Qh_V.js → thirdweb-RfTGDewD.js} +5 -5
- package/assets/{totalSupply-DKb8yY1T.js → totalSupply-D1tOGyvE.js} +1 -1
- package/assets/{transactions-CacIfnoG.js → transactions-LbE_YtGz.js} +1 -1
- package/assets/{ui-WV8OFH8_.js → ui-CUXWd4jk.js} +5 -5
- package/assets/{vendor-0sbCgRYC.js → vendor-DlkLYSlV.js} +1 -1
- package/assets/{w3m-modal-DD7YQQ5K.js → w3m-modal-BSFcMGCh.js} +1 -1
- package/assets/{wallets-chAGIjBC.js → wallets-OS7LlF3P.js} +5 -5
- package/assets/{web-connector-B_sMPq36.js → web-connector-3zdQreYv.js} +3 -3
- package/index.html +5 -5
- package/package.json +3 -3
- package/assets/LoginPage-DeOWBfwU.js +0 -1
- package/assets/browser-ponyfill-mmJvcXGA.js +0 -1
- package/assets/index-zwxMhp39.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/features-
|
|
2
|
-
var rf=Object.defineProperty;var nf=(s,e,t)=>e in s?rf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var W=(s,e,t)=>nf(s,typeof e!="symbol"?e+"":e,t);import{p as Wi,aA as ur,aB as of,_ as Je}from"./thirdweb-CT38Qh_V.js";import{w as af,p as cf,B as Wr,q as _s,X as Ph,C as $,Y as lf,O as K,s as hf,c as uf,Z as pa,_ as $h,$ as pt,a0 as gt,L as Ls,a1 as df,a2 as ff,a as $e,b as Ee,A as je,u as Fe,P as pe,e as Io,i as he,k as ae,d as we,z as pf,j as gf,a3 as Xa,a4 as mf,M as us,y as Qa,a5 as On,E as Mt,J as yf,T as Bt,a6 as Ni,I as Lr,o as et,U as Gr,R as Ms,a7 as Yr,S as ec,a8 as wf,l as Nn,W as tc,v as bf,a9 as vf,aa as Ef}from"./W3MFrameProviderSingleton-Ch6ChvE7.js";import{B as ie,g as X}from"./ui-WV8OFH8_.js";import{b7 as If,b8 as xf,b9 as Af,ba as Sf,bb as _f,bc as Cf,e as si,N as ga}from"./index-CfRwmSIm.js";import{d as Er,a as Zr,s as ma,I as Ci,e as Pf,g as xt,t as ot,h as j,j as ls,C as $f,k as Of,l as Gi,m as xo,n as Nf,q as Tf,c as qt,r as Pi,o as ya,u as Rf,v as wa,w as ba,b as sr,P as sc,Q as kf,x as Uf,y as zs,f as Oh,z as Zt,A as Lt,B as ds,D as Bf}from"./index-Dw0jehUl.js";import{c as Df,a as Lf,k as Mf,d as qf,s as jf,g as ic}from"./index-nibyPLVP.js";import"./index-BgXz7S15.js";import{f as Nh}from"./index.es-CwJH2io5.js";import{C as Q,N as Ff}from"./NetworkUtil-BcejqRTW.js";import{t as rc}from"./fromHex-CMtWckFK.js";const Yi={id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},Ao={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},zf={providers:Ph,selectedProvider:null,error:null,purchaseCurrency:Yi,paymentCurrency:Ao,purchaseCurrencies:[Yi],paymentCurrencies:[],quotesLoading:!1},re=cf(zf),Kf={state:re,subscribe(s){return uf(re,()=>s(re))},subscribeKey(s,e){return hf(re,s,e)},setSelectedProvider(s){var e,t;if(s&&s.name==="meld"){const i=$.state.activeChain,r=i===Q.CHAIN.SOLANA?"SOL":"USDC",n=i?((t=(e=$.state.chains.get(i))==null?void 0:e.accountState)==null?void 0:t.address)??"":"",o=new URL(s.url);o.searchParams.append("publicKey",lf),o.searchParams.append("destinationCurrencyCode",r),o.searchParams.append("walletAddress",n),o.searchParams.append("externalCustomerId",K.state.projectId),re.selectedProvider={...s,url:o.toString()}}else re.selectedProvider=s},setOnrampProviders(s){if(Array.isArray(s)&&s.every(e=>typeof e=="string")){const e=s,t=Ph.filter(i=>e.includes(i.name));re.providers=t}else re.providers=[]},setPurchaseCurrency(s){re.purchaseCurrency=s},setPaymentCurrency(s){re.paymentCurrency=s},setPurchaseAmount(s){So.state.purchaseAmount=s},setPaymentAmount(s){So.state.paymentAmount=s},async getAvailableCurrencies(){const s=await Wr.getOnrampOptions();re.purchaseCurrencies=s.purchaseCurrencies,re.paymentCurrencies=s.paymentCurrencies,re.paymentCurrency=s.paymentCurrencies[0]||Ao,re.purchaseCurrency=s.purchaseCurrencies[0]||Yi,await _s.fetchCurrencyImages(s.paymentCurrencies.map(e=>e.id)),await _s.fetchTokenImages(s.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var s,e;re.quotesLoading=!0;try{const t=await Wr.getOnrampQuote({purchaseCurrency:re.purchaseCurrency,paymentCurrency:re.paymentCurrency,amount:((s=re.paymentAmount)==null?void 0:s.toString())||"0",network:(e=re.purchaseCurrency)==null?void 0:e.symbol});return re.quotesLoading=!1,re.purchaseAmount=Number(t==null?void 0:t.purchaseAmount.amount),t}catch(t){return re.error=t.message,re.quotesLoading=!1,null}finally{re.quotesLoading=!1}},resetState(){re.selectedProvider=null,re.error=null,re.purchaseCurrency=Yi,re.paymentCurrency=Ao,re.purchaseCurrencies=[Yi],re.paymentCurrencies=[],re.paymentAmount=void 0,re.purchaseAmount=void 0,re.quotesLoading=!1}},So=af(Kf);function Hf(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function Ce(s,...e){try{return Hf(s(...e))}catch(t){return Promise.reject(t)}}function Vf(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function Wf(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function Mr(s){if(Vf(s))return String(s);if(Wf(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return Mr(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const _o="base64:";function Gf(s){return typeof s=="string"?s:_o+Jf(s)}function Yf(s){return typeof s!="string"||!s.startsWith(_o)?s:Zf(s.slice(_o.length))}function Zf(s){return globalThis.Buffer?ie.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function Jf(s){return globalThis.Buffer?ie.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Xe(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function Xf(...s){return Xe(s.join(":"))}function Ir(s){return s=Xe(s),s?s+":":""}function Qf(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function ep(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const tp="memory",sp=()=>{const s=new Map;return{name:tp,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function ip(s={}){const e={mounts:{"":s.driver||sp()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,h)=>{if(e.watching){h=Xe(h);for(const u of e.watchListeners)u(l,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await nc(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of l){const g=typeof p=="string",y=Xe(g?p:p.key),A=g?void 0:p.value,R=g||!p.options?h:{...h,...p.options},x=t(y);f(x).items.push({key:y,value:A,relativeKey:x.relativeKey,options:R})}return Promise.all([...d.values()].map(p=>u(p))).then(p=>p.flat())},c={hasItem(l,h={}){l=Xe(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.hasItem,u,h)},getItem(l,h={}){l=Xe(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.getItem,u,h).then(f=>Er(f))},getItems(l,h={}){return a(l,h,u=>u.driver.getItems?Ce(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:Xf(u.base,f.key),value:Er(f.value)}))):Promise.all(u.items.map(d=>Ce(u.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:Er(f)})))))},getItemRaw(l,h={}){l=Xe(l);const{relativeKey:u,driver:d}=t(l);return d.getItemRaw?Ce(d.getItemRaw,u,h):Ce(d.getItem,u,h).then(f=>Yf(f))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Xe(l);const{relativeKey:d,driver:f}=t(l);f.setItem&&(await Ce(f.setItem,d,Mr(h),u),f.watch||r("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return Ce(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:Mr(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>Ce(u.driver.setItem,d.relativeKey,Mr(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Xe(l);const{relativeKey:d,driver:f}=t(l);if(f.setItemRaw)await Ce(f.setItemRaw,d,h,u);else if(f.setItem)await Ce(f.setItem,d,Gf(h),u);else return;f.watch||r("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Xe(l);const{relativeKey:u,driver:d}=t(l);d.removeItem&&(await Ce(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await Ce(d.removeItem,u+"$",h),d.watch||r("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Xe(l);const{relativeKey:u,driver:d}=t(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await Ce(d.getMeta,u,h)),!h.nativeOnly){const p=await Ce(d.getItem,u+"$",h).then(g=>Er(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){var y;l=Ir(l);const u=i(l,!0);let d=[];const f=[];let p=!0;for(const A of u){(y=A.driver.flags)!=null&&y.maxDepth||(p=!1);const R=await Ce(A.driver.getKeys,A.relativeBase,h);for(const x of R){const E=A.mountpoint+Xe(x);d.some(O=>E.startsWith(O))||f.push(E)}d=[A.mountpoint,...d.filter(x=>!x.startsWith(A.mountpoint))]}const g=h.maxDepth!==void 0&&!p;return f.filter(A=>(!g||Qf(A,h.maxDepth))&&ep(A,l))},async clear(l,h={}){l=Ir(l),await Promise.all(i(l,!1).map(async u=>{if(u.driver.clear)return Ce(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(f=>u.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>oc(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=Ir(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(nc(h,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){var u,d;l=Ir(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((d=(u=e.unwatch)[l])==null||d.call(u),delete e.unwatch[l]),h&&await oc(e.mounts[l]),e.mountpoints=e.mountpoints.filter(f=>f!==l),delete e.mounts[l])},getMount(l=""){l=Xe(l)+":";const h=t(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Xe(l),i(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function nc(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function oc(s){typeof s.dispose=="function"&&await Ce(s.dispose)}const rp="idb-keyval";var np=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=Df(s.dbName,s.storeName)),{name:rp,options:s,async hasItem(r){return!(typeof await ic(t(r),i)>"u")},async getItem(r){return await ic(t(r),i)??null},setItem(r,n){return jf(t(r),n,i)},removeItem(r){return qf(t(r),i)},getKeys(){return Mf(i)},clear(){return Lf(i)}}};const op="WALLET_CONNECT_V2_INDEXED_DB",ap="keyvaluestorage";let cp=class{constructor(){this.indexedDb=ip({driver:np({dbName:op,storeName:ap})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ma(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Tn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof X<"u"?X:typeof self<"u"?self:{},qr={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Tn<"u"&&Tn.localStorage?qr.exports=Tn.localStorage:typeof window<"u"&&window.localStorage?qr.exports=window.localStorage:qr.exports=new e})();function lp(s){var e;return[s[0],Zr((e=s[1])!=null?e:"")]}let hp=class{constructor(){this.localStorage=qr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(lp)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return Zr(t)}async setItem(e,t){this.localStorage.setItem(e,ma(t))}async removeItem(e){this.localStorage.removeItem(e)}};const up="wc_storage_version",ac=1,dp=async(s,e,t)=>{const i=up,r=await e.getItem(i);if(r&&r>=ac){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await s.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,ac),t(e),fp(s,o)},fp=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let pp=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new hp;this.storage=e;try{const t=new cp;dp(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var gp=Object.defineProperty,mp=(s,e,t)=>e in s?gp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,cc=(s,e,t)=>mp(s,typeof e!="symbol"?e+"":e,t);let yp=class extends Ci{constructor(e){super(),this.opts=e,cc(this,"protocol","wc"),cc(this,"version",2)}};var wp=Object.defineProperty,bp=(s,e,t)=>e in s?wp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,vp=(s,e,t)=>bp(s,e+"",t);let Ep=class extends Ci{constructor(e,t){super(),this.core=e,this.logger=t,vp(this,"records",new Map)}},Ip=class{constructor(e,t){this.logger=e,this.core=t}},xp=class extends Ci{constructor(e,t){super(),this.relayer=e,this.logger=t}},Ap=class extends Ci{constructor(e){super()}},Sp=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},_p=class extends Ci{constructor(e,t){super(),this.relayer=e,this.logger=t}},Cp=class extends Ci{constructor(e,t){super(),this.core=e,this.logger=t}},Pp=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}};class $p{constructor(e,t){this.projectId=e,this.logger=t}}let Op=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Np=Object.defineProperty,Tp=(s,e,t)=>e in s?Np(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,lc=(s,e,t)=>Tp(s,typeof e!="symbol"?e+"":e,t);let Rp=class{constructor(e){this.opts=e,lc(this,"protocol","wc"),lc(this,"version",2)}},kp=class{constructor(e){this.client=e}};const Up="0.1.1";function Bp(){return Up}class ye extends Error{constructor(e,t={}){const i=(()=>{var c;if(t.cause instanceof ye){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof ye&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...i||r?["",i?`Details: ${i}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/features-Dq7eLLHj.js","assets/W3MFrameProviderSingleton-GariHyC1.js","assets/ui-CUXWd4jk.js","assets/vendor-DlkLYSlV.js","assets/thirdweb-RfTGDewD.js","assets/index-MOkgM3CG.js","assets/index-C_o5O_iU.js","assets/index-DdAb4cgP.css","assets/browser-ponyfill-B9OjpPGs.js","assets/NetworkUtil-WtQP9K5L.js","assets/embedded-wallet-4C0zCBzD.js","assets/index-BgA11815.js","assets/index-BxDS7YgF.js","assets/if-defined-CqpJarBn.js","assets/ref-BJXu_ix1.js","assets/index-D28HIM1b.js","assets/HelpersUtil-BqxjBOsb.js","assets/ConstantsUtil-SfeDQRNO.js","assets/index-CZRVN2vE.js","assets/index-BnEh4tgY.js","assets/index-CusnlpEv.js","assets/index-D3-eBZaP.js","assets/index-CVqr-7Pt.js","assets/NavigationUtil-DmfK5sOV.js","assets/index-DkoCaWFP.js","assets/index-nibyPLVP.js","assets/index.es-obcdOSPN.js","assets/fromHex-CMtWckFK.js","assets/email-dOZOTXLM.js","assets/index-Bmtxr8ck.js","assets/index-CVYOFAvL.js","assets/socials-CT51nzyt.js","assets/index-DpgCenmo.js","assets/index-ltBsvN7l.js","assets/index-CMVgYvcj.js","assets/browser-CL7pc_C2.js","assets/index-lExqs17M.js","assets/swaps-DcnyL-aF.js","assets/index-B90inivw.js","assets/SwapController-C3sOw1fb.js","assets/index-4Rm21Jcs.js","assets/MathUtil-BGCe3rZ3.js","assets/send-BVveMXEO.js","assets/index-C0a8a3_a.js","assets/index-BNctYT5W.js","assets/index-C2wXt8bX.js","assets/index-DWhePAr8.js","assets/receive-ENeHUThj.js","assets/onramp-DRY-VmEl.js","assets/index-CgTPsSZC.js","assets/index-Dqf3E5Am.js","assets/index-CJQ7XUF1.js","assets/pay-with-exchange-Fws3sgDP.js","assets/ExchangeController-Cl7LpW_9.js","assets/transactions-LbE_YtGz.js","assets/index-C9zadnoP.js","assets/index-aGypPCn4.js","assets/index-DJKVllQq.js","assets/index-DxTxoCQ5.js","assets/data-capture-Bjp5qmbu.js","assets/index-B4nv3uRr.js","assets/index-DhrbQM9o.js","assets/w3m-modal-BSFcMGCh.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var rf=Object.defineProperty;var nf=(s,e,t)=>e in s?rf(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var W=(s,e,t)=>nf(s,typeof e!="symbol"?e+"":e,t);import{p as Wi,aA as ur,aB as of,_ as Je}from"./thirdweb-RfTGDewD.js";import{w as af,p as cf,B as Wr,q as _s,X as Ph,C as $,Y as lf,O as K,s as hf,c as uf,Z as pa,_ as $h,$ as pt,a0 as gt,L as Ls,a1 as df,a2 as ff,a as $e,b as Ee,A as je,u as Fe,P as pe,e as Io,i as he,k as ae,d as we,z as pf,j as gf,a3 as Xa,a4 as mf,M as us,y as Qa,a5 as On,E as Mt,J as yf,T as Bt,a6 as Ni,I as Lr,o as et,U as Gr,R as Ms,a7 as Yr,S as ec,a8 as wf,l as Nn,W as tc,v as bf,a9 as vf,aa as Ef}from"./W3MFrameProviderSingleton-GariHyC1.js";import{B as ie,g as X}from"./ui-CUXWd4jk.js";import{b7 as If,b8 as xf,b9 as Af,ba as Sf,bb as _f,bc as Cf,e as si,N as ga}from"./index-C_o5O_iU.js";import{d as Er,a as Zr,s as ma,I as Ci,e as Pf,g as xt,t as ot,h as j,j as ls,C as $f,k as Of,l as Gi,m as xo,n as Nf,q as Tf,c as qt,r as Pi,o as ya,u as Rf,v as wa,w as ba,b as sr,P as sc,Q as kf,x as Uf,y as zs,f as Oh,z as Zt,A as Lt,B as ds,D as Bf}from"./index-DkoCaWFP.js";import{c as Df,a as Lf,k as Mf,d as qf,s as jf,g as ic}from"./index-nibyPLVP.js";import"./index-MOkgM3CG.js";import{f as Nh}from"./index.es-obcdOSPN.js";import{C as Q,N as Ff}from"./NetworkUtil-WtQP9K5L.js";import{t as rc}from"./fromHex-CMtWckFK.js";const Yi={id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},Ao={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},zf={providers:Ph,selectedProvider:null,error:null,purchaseCurrency:Yi,paymentCurrency:Ao,purchaseCurrencies:[Yi],paymentCurrencies:[],quotesLoading:!1},re=cf(zf),Kf={state:re,subscribe(s){return uf(re,()=>s(re))},subscribeKey(s,e){return hf(re,s,e)},setSelectedProvider(s){var e,t;if(s&&s.name==="meld"){const i=$.state.activeChain,r=i===Q.CHAIN.SOLANA?"SOL":"USDC",n=i?((t=(e=$.state.chains.get(i))==null?void 0:e.accountState)==null?void 0:t.address)??"":"",o=new URL(s.url);o.searchParams.append("publicKey",lf),o.searchParams.append("destinationCurrencyCode",r),o.searchParams.append("walletAddress",n),o.searchParams.append("externalCustomerId",K.state.projectId),re.selectedProvider={...s,url:o.toString()}}else re.selectedProvider=s},setOnrampProviders(s){if(Array.isArray(s)&&s.every(e=>typeof e=="string")){const e=s,t=Ph.filter(i=>e.includes(i.name));re.providers=t}else re.providers=[]},setPurchaseCurrency(s){re.purchaseCurrency=s},setPaymentCurrency(s){re.paymentCurrency=s},setPurchaseAmount(s){So.state.purchaseAmount=s},setPaymentAmount(s){So.state.paymentAmount=s},async getAvailableCurrencies(){const s=await Wr.getOnrampOptions();re.purchaseCurrencies=s.purchaseCurrencies,re.paymentCurrencies=s.paymentCurrencies,re.paymentCurrency=s.paymentCurrencies[0]||Ao,re.purchaseCurrency=s.purchaseCurrencies[0]||Yi,await _s.fetchCurrencyImages(s.paymentCurrencies.map(e=>e.id)),await _s.fetchTokenImages(s.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){var s,e;re.quotesLoading=!0;try{const t=await Wr.getOnrampQuote({purchaseCurrency:re.purchaseCurrency,paymentCurrency:re.paymentCurrency,amount:((s=re.paymentAmount)==null?void 0:s.toString())||"0",network:(e=re.purchaseCurrency)==null?void 0:e.symbol});return re.quotesLoading=!1,re.purchaseAmount=Number(t==null?void 0:t.purchaseAmount.amount),t}catch(t){return re.error=t.message,re.quotesLoading=!1,null}finally{re.quotesLoading=!1}},resetState(){re.selectedProvider=null,re.error=null,re.purchaseCurrency=Yi,re.paymentCurrency=Ao,re.purchaseCurrencies=[Yi],re.paymentCurrencies=[],re.paymentAmount=void 0,re.purchaseAmount=void 0,re.quotesLoading=!1}},So=af(Kf);function Hf(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function Ce(s,...e){try{return Hf(s(...e))}catch(t){return Promise.reject(t)}}function Vf(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function Wf(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function Mr(s){if(Vf(s))return String(s);if(Wf(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return Mr(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const _o="base64:";function Gf(s){return typeof s=="string"?s:_o+Jf(s)}function Yf(s){return typeof s!="string"||!s.startsWith(_o)?s:Zf(s.slice(_o.length))}function Zf(s){return globalThis.Buffer?ie.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function Jf(s){return globalThis.Buffer?ie.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Xe(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function Xf(...s){return Xe(s.join(":"))}function Ir(s){return s=Xe(s),s?s+":":""}function Qf(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function ep(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const tp="memory",sp=()=>{const s=new Map;return{name:tp,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function ip(s={}){const e={mounts:{"":s.driver||sp()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},i=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(l,h)=>{if(e.watching){h=Xe(h);for(const u of e.watchListeners)u(l,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await nc(e.mounts[l],r,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,f=p=>{let g=d.get(p.base);return g||(g={driver:p.driver,base:p.base,items:[]},d.set(p.base,g)),g};for(const p of l){const g=typeof p=="string",y=Xe(g?p:p.key),A=g?void 0:p.value,R=g||!p.options?h:{...h,...p.options},x=t(y);f(x).items.push({key:y,value:A,relativeKey:x.relativeKey,options:R})}return Promise.all([...d.values()].map(p=>u(p))).then(p=>p.flat())},c={hasItem(l,h={}){l=Xe(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.hasItem,u,h)},getItem(l,h={}){l=Xe(l);const{relativeKey:u,driver:d}=t(l);return Ce(d.getItem,u,h).then(f=>Er(f))},getItems(l,h={}){return a(l,h,u=>u.driver.getItems?Ce(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(f=>({key:Xf(u.base,f.key),value:Er(f.value)}))):Promise.all(u.items.map(d=>Ce(u.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:Er(f)})))))},getItemRaw(l,h={}){l=Xe(l);const{relativeKey:u,driver:d}=t(l);return d.getItemRaw?Ce(d.getItemRaw,u,h):Ce(d.getItem,u,h).then(f=>Yf(f))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Xe(l);const{relativeKey:d,driver:f}=t(l);f.setItem&&(await Ce(f.setItem,d,Mr(h),u),f.watch||r("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return Ce(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:Mr(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>Ce(u.driver.setItem,d.relativeKey,Mr(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Xe(l);const{relativeKey:d,driver:f}=t(l);if(f.setItemRaw)await Ce(f.setItemRaw,d,h,u);else if(f.setItem)await Ce(f.setItem,d,Gf(h),u);else return;f.watch||r("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Xe(l);const{relativeKey:u,driver:d}=t(l);d.removeItem&&(await Ce(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await Ce(d.removeItem,u+"$",h),d.watch||r("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Xe(l);const{relativeKey:u,driver:d}=t(l),f=Object.create(null);if(d.getMeta&&Object.assign(f,await Ce(d.getMeta,u,h)),!h.nativeOnly){const p=await Ce(d.getItem,u+"$",h).then(g=>Er(g));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){var y;l=Ir(l);const u=i(l,!0);let d=[];const f=[];let p=!0;for(const A of u){(y=A.driver.flags)!=null&&y.maxDepth||(p=!1);const R=await Ce(A.driver.getKeys,A.relativeBase,h);for(const x of R){const E=A.mountpoint+Xe(x);d.some(O=>E.startsWith(O))||f.push(E)}d=[A.mountpoint,...d.filter(x=>!x.startsWith(A.mountpoint))]}const g=h.maxDepth!==void 0&&!p;return f.filter(A=>(!g||Qf(A,h.maxDepth))&&ep(A,l))},async clear(l,h={}){l=Ir(l),await Promise.all(i(l,!1).map(async u=>{if(u.driver.clear)return Ce(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(f=>u.driver.removeItem(f,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>oc(l)))},async watch(l){return await n(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=Ir(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(nc(h,r,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){var u,d;l=Ir(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&((d=(u=e.unwatch)[l])==null||d.call(u),delete e.unwatch[l]),h&&await oc(e.mounts[l]),e.mountpoints=e.mountpoints.filter(f=>f!==l),delete e.mounts[l])},getMount(l=""){l=Xe(l)+":";const h=t(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Xe(l),i(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function nc(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function oc(s){typeof s.dispose=="function"&&await Ce(s.dispose)}const rp="idb-keyval";var np=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=Df(s.dbName,s.storeName)),{name:rp,options:s,async hasItem(r){return!(typeof await ic(t(r),i)>"u")},async getItem(r){return await ic(t(r),i)??null},setItem(r,n){return jf(t(r),n,i)},removeItem(r){return qf(t(r),i)},getKeys(){return Mf(i)},clear(){return Lf(i)}}};const op="WALLET_CONNECT_V2_INDEXED_DB",ap="keyvaluestorage";let cp=class{constructor(){this.indexedDb=ip({driver:np({dbName:op,storeName:ap})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ma(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Tn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof X<"u"?X:typeof self<"u"?self:{},qr={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Tn<"u"&&Tn.localStorage?qr.exports=Tn.localStorage:typeof window<"u"&&window.localStorage?qr.exports=window.localStorage:qr.exports=new e})();function lp(s){var e;return[s[0],Zr((e=s[1])!=null?e:"")]}let hp=class{constructor(){this.localStorage=qr.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(lp)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return Zr(t)}async setItem(e,t){this.localStorage.setItem(e,ma(t))}async removeItem(e){this.localStorage.removeItem(e)}};const up="wc_storage_version",ac=1,dp=async(s,e,t)=>{const i=up,r=await e.getItem(i);if(r&&r>=ac){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await s.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(i,ac),t(e),fp(s,o)},fp=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let pp=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new hp;this.storage=e;try{const t=new cp;dp(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var gp=Object.defineProperty,mp=(s,e,t)=>e in s?gp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,cc=(s,e,t)=>mp(s,typeof e!="symbol"?e+"":e,t);let yp=class extends Ci{constructor(e){super(),this.opts=e,cc(this,"protocol","wc"),cc(this,"version",2)}};var wp=Object.defineProperty,bp=(s,e,t)=>e in s?wp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,vp=(s,e,t)=>bp(s,e+"",t);let Ep=class extends Ci{constructor(e,t){super(),this.core=e,this.logger=t,vp(this,"records",new Map)}},Ip=class{constructor(e,t){this.logger=e,this.core=t}},xp=class extends Ci{constructor(e,t){super(),this.relayer=e,this.logger=t}},Ap=class extends Ci{constructor(e){super()}},Sp=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},_p=class extends Ci{constructor(e,t){super(),this.relayer=e,this.logger=t}},Cp=class extends Ci{constructor(e,t){super(),this.core=e,this.logger=t}},Pp=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}};class $p{constructor(e,t){this.projectId=e,this.logger=t}}let Op=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Np=Object.defineProperty,Tp=(s,e,t)=>e in s?Np(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,lc=(s,e,t)=>Tp(s,typeof e!="symbol"?e+"":e,t);let Rp=class{constructor(e){this.opts=e,lc(this,"protocol","wc"),lc(this,"version",2)}},kp=class{constructor(e){this.client=e}};const Up="0.1.1";function Bp(){return Up}class ye extends Error{constructor(e,t={}){const i=(()=>{var c;if(t.cause instanceof ye){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&typeof t.cause.details=="string"?t.cause.details:(c=t.cause)!=null&&c.message?t.cause.message:t.details})(),r=t.cause instanceof ye&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,a=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...i||r?["",i?`Details: ${i}`:void 0,r?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
3
3
|
`);super(a,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Bp()}`}),this.cause=t.cause,this.details=i,this.docs=o,this.docsPath=r,this.shortMessage=e}walk(e){return Th(this,e)}}function Th(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause?Th(s.cause,e):e?null:s}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const va=BigInt(0),Co=BigInt(1);function dr(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ea(s){if(!dr(s))throw new Error("Uint8Array expected")}function ir(s,e){if(typeof e!="boolean")throw new Error(s+" boolean expected, got "+e)}function xr(s){const e=s.toString(16);return e.length&1?"0"+e:e}function Rh(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?va:BigInt("0x"+s)}const kh=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Dp=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function rr(s){if(Ea(s),kh)return s.toHex();let e="";for(let t=0;t<s.length;t++)e+=Dp[s[t]];return e}const Wt={_0:48,_9:57,A:65,F:70,a:97,f:102};function hc(s){if(s>=Wt._0&&s<=Wt._9)return s-Wt._0;if(s>=Wt.A&&s<=Wt.F)return s-(Wt.A-10);if(s>=Wt.a&&s<=Wt.f)return s-(Wt.a-10)}function Jr(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(kh)return Uint8Array.fromHex(s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=hc(s.charCodeAt(n)),a=hc(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function Js(s){return Rh(rr(s))}function Uh(s){return Ea(s),Rh(rr(Uint8Array.from(s).reverse()))}function fr(s,e){return Jr(s.toString(16).padStart(e*2,"0"))}function Bh(s,e){return fr(s,e).reverse()}function Et(s,e,t){let i;if(typeof e=="string")try{i=Jr(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(dr(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}function Xr(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Ea(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}const Rn=s=>typeof s=="bigint"&&va<=s;function Ia(s,e,t){return Rn(s)&&Rn(e)&&Rn(t)&&e<=s&&s<t}function yi(s,e,t,i){if(!Ia(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}function Lp(s){let e;for(e=0;s>va;s>>=Co,e+=1);return e}const gn=s=>(Co<<BigInt(s))-Co,kn=s=>new Uint8Array(s),uc=s=>Uint8Array.from(s);function Mp(s,e,t){if(typeof s!="number"||s<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let i=kn(s),r=kn(s),n=0;const o=()=>{i.fill(1),r.fill(0),n=0},a=(...u)=>t(r,i,...u),c=(u=kn(0))=>{r=a(uc([0]),u),i=a(),u.length!==0&&(r=a(uc([1]),u),i=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const d=[];for(;u<e;){i=a();const f=i.slice();d.push(f),u+=i.length}return Xr(...d)};return(u,d)=>{o(),c(u);let f;for(;!(f=d(l()));)c();return o(),f}}const qp={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||dr(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function mn(s,e,t={}){const i=(r,n,o)=>{const a=qp[n];if(typeof a!="function")throw new Error("invalid validator function");const c=s[r];if(!(o&&c===void 0)&&!a(c,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+c)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}function dc(s){const e=new WeakMap;return(t,...i)=>{const r=e.get(t);if(r!==void 0)return r;const n=s(t,...i);return e.set(t,n),n}}function jp(s,e){if(mc(s)>e)throw new cg({givenSize:mc(s),maxSize:e})}const Gt={zero:48,nine:57,A:65,F:70,a:97,f:102};function fc(s){if(s>=Gt.zero&&s<=Gt.nine)return s-Gt.zero;if(s>=Gt.A&&s<=Gt.F)return s-(Gt.A-10);if(s>=Gt.a&&s<=Gt.f)return s-(Gt.a-10)}function Fp(s,e={}){const{dir:t,size:i=32}=e;if(i===0)return s;if(s.length>i)throw new lg({size:s.length,targetSize:i,type:"Bytes"});const r=new Uint8Array(i);for(let n=0;n<i;n++){const o=t==="right";r[o?n:i-n-1]=s[o?n:s.length-n-1]}return r}function Dh(s,e){if($s(s)>e)throw new Xp({givenSize:$s(s),maxSize:e})}function zp(s,e){if(typeof e=="number"&&e>0&&e>$s(s)-1)throw new qh({offset:e,position:"start",size:$s(s)})}function Kp(s,e,t){if(typeof e=="number"&&typeof t=="number"&&$s(s)!==t-e)throw new qh({offset:t,position:"end",size:$s(s)})}function Lh(s,e={}){const{dir:t,size:i=32}=e;if(i===0)return s;const r=s.replace("0x","");if(r.length>i*2)throw new Qp({size:Math.ceil(r.length/2),targetSize:i,type:"Hex"});return`0x${r[t==="right"?"padEnd":"padStart"](i*2,"0")}`}const Hp="#__bigint";function xa(s,e,t){return JSON.stringify(s,(i,r)=>typeof r=="bigint"?r.toString()+Hp:r,t)}const Vp=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Wp(s,e={}){const{strict:t=!1}=e;if(!s)throw new pc(s);if(typeof s!="string")throw new pc(s);if(t&&!/^0x[0-9a-fA-F]*$/.test(s))throw new gc(s);if(!s.startsWith("0x"))throw new gc(s)}function Gp(...s){return`0x${s.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Aa(s){return s instanceof Uint8Array?Qr(s):Array.isArray(s)?Qr(new Uint8Array(s)):s}function Qr(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=Vp[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Dh(i,e.size),Mh(i,e.size)):i}function Un(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new Jp({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const c=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Yp(c,i):c}function Yp(s,e){return Lh(s,{dir:"left",size:e})}function Mh(s,e){return Lh(s,{dir:"right",size:e})}function es(s,e,t,i={}){const{strict:r}=i;zp(s,e);const n=`0x${s.replace("0x","").slice((e??0)*2,(t??s.length)*2)}`;return r&&Kp(n,e,t),n}function $s(s){return Math.ceil((s.length-2)/2)}function Zp(s,e={}){const{strict:t=!1}=e;try{return Wp(s,{strict:t}),!0}catch{return!1}}class Jp extends ye{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number \`${n}\` is not in safe${r?` ${r*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class pc extends ye{constructor(e){super(`Value \`${typeof e=="object"?xa(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class gc extends ye{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let Xp=class extends ye{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}};class qh extends ye{constructor({offset:e,position:t,size:i}){super(`Slice ${t==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${i}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}let Qp=class extends ye{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};const eg=new TextEncoder;function tg(s){if(!(s instanceof Uint8Array)){if(!s)throw new Ar(s);if(typeof s!="object")throw new Ar(s);if(!("BYTES_PER_ELEMENT"in s))throw new Ar(s);if(s.BYTES_PER_ELEMENT!==1||s.constructor.name!=="Uint8Array")throw new Ar(s)}}function sg(s){return s instanceof Uint8Array?s:typeof s=="string"?rg(s):ig(s)}function ig(s){return s instanceof Uint8Array?s:new Uint8Array(s)}function rg(s,e={}){const{size:t}=e;let i=s;t&&(Dh(s,t),i=Mh(s,t));let r=i.slice(2);r.length%2&&(r=`0${r}`);const n=r.length/2,o=new Uint8Array(n);for(let a=0,c=0;a<n;a++){const l=fc(r.charCodeAt(c++)),h=fc(r.charCodeAt(c++));if(l===void 0||h===void 0)throw new ye(`Invalid byte sequence ("${r[c-2]}${r[c-1]}" in "${r}").`);o[a]=l*16+h}return o}function ng(s,e={}){const{size:t}=e,i=eg.encode(s);return typeof t=="number"?(jp(i,t),og(i,t)):i}function og(s,e){return Fp(s,{dir:"right",size:e})}function mc(s){return s.length}function ag(s){try{return tg(s),!0}catch{return!1}}class Ar extends ye{constructor(e){super(`Value \`${typeof e=="object"?xa(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class cg extends ye{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class lg extends ye{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function jh(s,e={}){const{as:t=typeof s=="string"?"Hex":"Bytes"}=e,i=If(sg(s));return t==="Bytes"?i:Qr(i)}class hg extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const ug={checksum:new hg(8192)},Bn=ug.checksum;function Fh(s,e={}){const{compressed:t}=e,{prefix:i,x:r,y:n}=s;if(t===!1||typeof r=="bigint"&&typeof n=="bigint"){if(i!==4)throw new yc({prefix:i,cause:new yg});return}if(t===!0||typeof r=="bigint"&&typeof n>"u"){if(i!==3&&i!==2)throw new yc({prefix:i,cause:new mg});return}throw new gg({publicKey:s})}function dg(s){const e=(()=>{if(Zp(s))return zh(s);if(ag(s))return fg(s);const{prefix:t,x:i,y:r}=s;return typeof i=="bigint"&&typeof r=="bigint"?{prefix:t??4,x:i,y:r}:{prefix:t,x:i}})();return Fh(e),e}function fg(s){return zh(Qr(s))}function zh(s){if(s.length!==132&&s.length!==130&&s.length!==68)throw new wg({publicKey:s});if(s.length===130){const i=BigInt(es(s,0,32)),r=BigInt(es(s,32,64));return{prefix:4,x:i,y:r}}if(s.length===132){const i=Number(es(s,0,1)),r=BigInt(es(s,1,33)),n=BigInt(es(s,33,65));return{prefix:i,x:r,y:n}}const e=Number(es(s,0,1)),t=BigInt(es(s,1,33));return{prefix:e,x:t}}function pg(s,e={}){Fh(s);const{prefix:t,x:i,y:r}=s,{includePrefix:n=!0}=e;return Gp(n?Un(t,{size:1}):"0x",Un(i,{size:32}),typeof r=="bigint"?Un(r,{size:32}):"0x")}class gg extends ye{constructor({publicKey:e}){super(`Value \`${xa(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class yc extends ye{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class mg extends ye{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class yg extends ye{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let wg=class extends ye{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${$s(Aa(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const bg=/^0x[a-fA-F0-9]{40}$/;function Kh(s,e={}){const{strict:t=!0}=e;if(!bg.test(s))throw new wc({address:s,cause:new Ig});if(t){if(s.toLowerCase()===s)return;if(Hh(s)!==s)throw new wc({address:s,cause:new xg})}}function Hh(s){if(Bn.has(s))return Bn.get(s);Kh(s,{strict:!1});const e=s.substring(2).toLowerCase(),t=jh(ng(e),{as:"Bytes"}),i=e.split("");for(let n=0;n<40;n+=2)t[n>>1]>>4>=8&&i[n]&&(i[n]=i[n].toUpperCase()),(t[n>>1]&15)>=8&&i[n+1]&&(i[n+1]=i[n+1].toUpperCase());const r=`0x${i.join("")}`;return Bn.set(s,r),r}function vg(s,e={}){const{checksum:t=!1}=e;return Kh(s),t?Hh(s):s}function Eg(s,e={}){const t=jh(`0x${pg(s).slice(4)}`).substring(26);return vg(`0x${t}`,e)}class wc extends ye{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Ig extends ye{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class xg extends ye{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rt=BigInt(0),Ve=BigInt(1),Ks=BigInt(2),Ag=BigInt(3),Vh=BigInt(4),Wh=BigInt(5),Gh=BigInt(8);function tt(s,e){const t=s%e;return t>=rt?t:e+t}function yt(s,e,t){let i=s;for(;e-- >rt;)i*=i,i%=t;return i}function Po(s,e){if(s===rt)throw new Error("invert: expected non-zero number");if(e<=rt)throw new Error("invert: expected positive modulus, got "+e);let t=tt(s,e),i=e,r=rt,n=Ve;for(;t!==rt;){const a=i/t,c=i%t,l=r-n*a;i=t,t=c,r=n,n=l}if(i!==Ve)throw new Error("invert: does not exist");return tt(r,e)}function Yh(s,e){const t=(s.ORDER+Ve)/Vh,i=s.pow(e,t);if(!s.eql(s.sqr(i),e))throw new Error("Cannot find square root");return i}function Sg(s,e){const t=(s.ORDER-Wh)/Gh,i=s.mul(e,Ks),r=s.pow(i,t),n=s.mul(e,r),o=s.mul(s.mul(n,Ks),r),a=s.mul(n,s.sub(o,s.ONE));if(!s.eql(s.sqr(a),e))throw new Error("Cannot find square root");return a}function _g(s){if(s<BigInt(3))throw new Error("sqrt is not defined for small field");let e=s-Ve,t=0;for(;e%Ks===rt;)e/=Ks,t++;let i=Ks;const r=Sa(s);for(;bc(r,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return Yh;let n=r.pow(i,e);const o=(e+Ve)/Ks;return function(c,l){if(c.is0(l))return l;if(bc(c,l)!==1)throw new Error("Cannot find square root");let h=t,u=c.mul(c.ONE,n),d=c.pow(l,e),f=c.pow(l,o);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let p=1,g=c.sqr(d);for(;!c.eql(g,c.ONE);)if(p++,g=c.sqr(g),p===h)throw new Error("Cannot find square root");const y=Ve<<BigInt(h-p-1),A=c.pow(u,y);h=p,u=c.sqr(A),d=c.mul(d,u),f=c.mul(f,A)}return f}}function Cg(s){return s%Vh===Ag?Yh:s%Gh===Wh?Sg:_g(s)}const Pg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $g(s){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Pg.reduce((i,r)=>(i[r]="function",i),e);return mn(s,t)}function Og(s,e,t){if(t<rt)throw new Error("invalid exponent, negatives unsupported");if(t===rt)return s.ONE;if(t===Ve)return e;let i=s.ONE,r=e;for(;t>rt;)t&Ve&&(i=s.mul(i,r)),r=s.sqr(r),t>>=Ve;return i}function Zh(s,e,t=!1){const i=new Array(e.length).fill(t?s.ZERO:void 0),r=e.reduce((o,a,c)=>s.is0(a)?o:(i[c]=o,s.mul(o,a)),s.ONE),n=s.inv(r);return e.reduceRight((o,a,c)=>s.is0(a)?o:(i[c]=s.mul(o,i[c]),s.mul(o,a)),n),i}function bc(s,e){const t=(s.ORDER-Ve)/Ks,i=s.pow(e,t),r=s.eql(i,s.ONE),n=s.eql(i,s.ZERO),o=s.eql(i,s.neg(s.ONE));if(!r&&!n&&!o)throw new Error("invalid Legendre symbol result");return r?1:n?0:-1}function Jh(s,e){e!==void 0&&xf(e);const t=e!==void 0?e:s.toString(2).length,i=Math.ceil(t/8);return{nBitLength:t,nByteLength:i}}function Sa(s,e,t=!1,i={}){if(s<=rt)throw new Error("invalid field: expected ORDER > 0, got "+s);const{nBitLength:r,nByteLength:n}=Jh(s,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:s,isLE:t,BITS:r,BYTES:n,MASK:gn(r),ZERO:rt,ONE:Ve,create:c=>tt(c,s),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return rt<=c&&c<s},is0:c=>c===rt,isOdd:c=>(c&Ve)===Ve,neg:c=>tt(-c,s),eql:(c,l)=>c===l,sqr:c=>tt(c*c,s),add:(c,l)=>tt(c+l,s),sub:(c,l)=>tt(c-l,s),mul:(c,l)=>tt(c*l,s),pow:(c,l)=>Og(a,c,l),div:(c,l)=>tt(c*Po(l,s),s),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Po(c,s),sqrt:i.sqrt||(c=>(o||(o=Cg(s)),o(a,c))),toBytes:c=>t?Bh(c,n):fr(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return t?Uh(c):Js(c)},invertBatch:c=>Zh(a,c),cmov:(c,l,h)=>h?l:c});return Object.freeze(a)}function Xh(s){if(typeof s!="bigint")throw new Error("field order must be bigint");const e=s.toString(2).length;return Math.ceil(e/8)}function Qh(s){const e=Xh(s);return e+Math.ceil(e/2)}function Ng(s,e,t=!1){const i=s.length,r=Xh(e),n=Qh(e);if(i<16||i<n||i>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+i);const o=t?Uh(s):Js(s),a=tt(o,e-Ve)+Ve;return t?Bh(a,r):fr(a,r)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vc=BigInt(0),$o=BigInt(1);function Dn(s,e){const t=e.negate();return s?t:e}function eu(s,e){if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+s)}function Ln(s,e){eu(s,e);const t=Math.ceil(e/s)+1,i=2**(s-1),r=2**s,n=gn(s),o=BigInt(s);return{windows:t,windowSize:i,mask:n,maxNumber:r,shiftBy:o}}function Ec(s,e,t){const{windowSize:i,mask:r,maxNumber:n,shiftBy:o}=t;let a=Number(s&r),c=s>>o;a>i&&(a-=n,c+=$o);const l=e*i,h=l+Math.abs(a)-1,u=a===0,d=a<0,f=e%2!==0;return{nextN:c,offset:h,isZero:u,isNeg:d,isNegF:f,offsetF:l}}function Tg(s,e){if(!Array.isArray(s))throw new Error("array expected");s.forEach((t,i)=>{if(!(t instanceof e))throw new Error("invalid point at index "+i)})}function Rg(s,e){if(!Array.isArray(s))throw new Error("array of scalars expected");s.forEach((t,i)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+i)})}const Mn=new WeakMap,tu=new WeakMap;function qn(s){return tu.get(s)||1}function kg(s,e){return{constTimeNegate:Dn,hasPrecomputes(t){return qn(t)!==1},unsafeLadder(t,i,r=s.ZERO){let n=t;for(;i>vc;)i&$o&&(r=r.add(n)),n=n.double(),i>>=$o;return r},precomputeWindow(t,i){const{windows:r,windowSize:n}=Ln(i,e),o=[];let a=t,c=a;for(let l=0;l<r;l++){c=a,o.push(c);for(let h=1;h<n;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(t,i,r){let n=s.ZERO,o=s.BASE;const a=Ln(t,e);for(let c=0;c<a.windows;c++){const{nextN:l,offset:h,isZero:u,isNeg:d,isNegF:f,offsetF:p}=Ec(r,c,a);r=l,u?o=o.add(Dn(f,i[p])):n=n.add(Dn(d,i[h]))}return{p:n,f:o}},wNAFUnsafe(t,i,r,n=s.ZERO){const o=Ln(t,e);for(let a=0;a<o.windows&&r!==vc;a++){const{nextN:c,offset:l,isZero:h,isNeg:u}=Ec(r,a,o);if(r=c,!h){const d=i[l];n=n.add(u?d.negate():d)}}return n},getPrecomputes(t,i,r){let n=Mn.get(i);return n||(n=this.precomputeWindow(i,t),t!==1&&Mn.set(i,r(n))),n},wNAFCached(t,i,r){const n=qn(t);return this.wNAF(n,this.getPrecomputes(n,t,r),i)},wNAFCachedUnsafe(t,i,r,n){const o=qn(t);return o===1?this.unsafeLadder(t,i,n):this.wNAFUnsafe(o,this.getPrecomputes(o,t,r),i,n)},setWindowSize(t,i){eu(i,e),tu.set(t,i),Mn.delete(t)}}}function Ug(s,e,t,i){Tg(t,s),Rg(i,e);const r=t.length,n=i.length;if(r!==n)throw new Error("arrays of points and scalars must have equal length");const o=s.ZERO,a=Lp(BigInt(r));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=gn(c),h=new Array(Number(l)+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let d=o;for(let f=u;f>=0;f-=c){h.fill(o);for(let g=0;g<n;g++){const y=i[g],A=Number(y>>BigInt(f)&l);h[A]=h[A].add(t[g])}let p=o;for(let g=h.length-1,y=o;g>0;g--)y=y.add(h[g]),p=p.add(y);if(d=d.add(p),f!==0)for(let g=0;g<c;g++)d=d.double()}return d}function su(s){return $g(s.Fp),mn(s,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jh(s.n,s.nBitLength),...s,p:s.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ic(s){s.lowS!==void 0&&ir("lowS",s.lowS),s.prehash!==void 0&&ir("prehash",s.prehash)}function Bg(s){const e=su(s);mn(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:i,a:r}=e;if(t){if(!i.eql(r,i.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class Dg extends Error{constructor(e=""){super(e)}}const ss={Err:Dg,_tlv:{encode:(s,e)=>{const{Err:t}=ss;if(s<0||s>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const i=e.length/2,r=xr(i);if(r.length/2&128)throw new t("tlv.encode: long form length too big");const n=i>127?xr(r.length/2|128):"";return xr(s)+n+r+e},decode(s,e){const{Err:t}=ss;let i=0;if(s<0||s>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[i++]!==s)throw new t("tlv.decode: wrong tlv");const r=e[i++],n=!!(r&128);let o=0;if(!n)o=r;else{const c=r&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(i,i+c);if(l.length!==c)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(i+=c,o<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(s){const{Err:e}=ss;if(s<rs)throw new e("integer: negative integers are not allowed");let t=xr(s);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(s){const{Err:e}=ss;if(s[0]&128)throw new e("invalid signature integer: negative");if(s[0]===0&&!(s[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Js(s)}},toSig(s){const{Err:e,_int:t,_tlv:i}=ss,r=Et("signature",s),{v:n,l:o}=i.decode(48,r);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,n),{v:l,l:h}=i.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(s){const{_tlv:e,_int:t}=ss,i=e.encode(2,t.encode(s.r)),r=e.encode(2,t.encode(s.s)),n=i+r;return e.encode(48,n)}};function jn(s,e){return rr(fr(s,e))}const rs=BigInt(0),Pe=BigInt(1);BigInt(2);const Fn=BigInt(3),Lg=BigInt(4);function Mg(s){const e=Bg(s),{Fp:t}=e,i=Sa(e.n,e.nBitLength),r=e.toBytes||((x,E,O)=>{const T=E.toAffine();return Xr(Uint8Array.from([4]),t.toBytes(T.x),t.toBytes(T.y))}),n=e.fromBytes||(x=>{const E=x.subarray(1),O=t.fromBytes(E.subarray(0,t.BYTES)),T=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:O,y:T}});function o(x){const{a:E,b:O}=e,T=t.sqr(x),U=t.mul(T,x);return t.add(t.add(U,t.mul(x,E)),O)}function a(x,E){const O=t.sqr(E),T=o(x);return t.eql(O,T)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const c=t.mul(t.pow(e.a,Fn),Lg),l=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(c,l)))throw new Error("bad curve params: a or b");function h(x){return Ia(x,Pe,e.n)}function u(x){const{allowedPrivateKeyLengths:E,nByteLength:O,wrapPrivateKey:T,n:U}=e;if(E&&typeof x!="bigint"){if(dr(x)&&(x=rr(x)),typeof x!="string"||!E.includes(x.length))throw new Error("invalid private key");x=x.padStart(O*2,"0")}let D;try{D=typeof x=="bigint"?x:Js(Et("private key",x,O))}catch{throw new Error("invalid private key, expected hex or "+O+" bytes, got "+typeof x)}return T&&(D=tt(D,U)),yi("private key",D,Pe,U),D}function d(x){if(!(x instanceof g))throw new Error("ProjectivePoint expected")}const f=dc((x,E)=>{const{px:O,py:T,pz:U}=x;if(t.eql(U,t.ONE))return{x:O,y:T};const D=x.is0();E==null&&(E=D?t.ONE:t.inv(U));const P=t.mul(O,E),B=t.mul(T,E),M=t.mul(U,E);if(D)return{x:t.ZERO,y:t.ZERO};if(!t.eql(M,t.ONE))throw new Error("invZ was invalid");return{x:P,y:B}}),p=dc(x=>{if(x.is0()){if(e.allowInfinityPoint&&!t.is0(x.py))return;throw new Error("bad point: ZERO")}const{x:E,y:O}=x.toAffine();if(!t.isValid(E)||!t.isValid(O))throw new Error("bad point: x or y not FE");if(!a(E,O))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(E,O,T){if(E==null||!t.isValid(E))throw new Error("x required");if(O==null||!t.isValid(O)||t.is0(O))throw new Error("y required");if(T==null||!t.isValid(T))throw new Error("z required");this.px=E,this.py=O,this.pz=T,Object.freeze(this)}static fromAffine(E){const{x:O,y:T}=E||{};if(!E||!t.isValid(O)||!t.isValid(T))throw new Error("invalid affine point");if(E instanceof g)throw new Error("projective point not allowed");const U=D=>t.eql(D,t.ZERO);return U(O)&&U(T)?g.ZERO:new g(O,T,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(E){const O=Zh(t,E.map(T=>T.pz));return E.map((T,U)=>T.toAffine(O[U])).map(g.fromAffine)}static fromHex(E){const O=g.fromAffine(n(Et("pointHex",E)));return O.assertValidity(),O}static fromPrivateKey(E){return g.BASE.multiply(u(E))}static msm(E,O){return Ug(g,i,E,O)}_setWindowSize(E){R.setWindowSize(this,E)}assertValidity(){p(this)}hasEvenY(){const{y:E}=this.toAffine();if(t.isOdd)return!t.isOdd(E);throw new Error("Field doesn't support isOdd")}equals(E){d(E);const{px:O,py:T,pz:U}=this,{px:D,py:P,pz:B}=E,M=t.eql(t.mul(O,B),t.mul(D,U)),C=t.eql(t.mul(T,B),t.mul(P,U));return M&&C}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:E,b:O}=e,T=t.mul(O,Fn),{px:U,py:D,pz:P}=this;let B=t.ZERO,M=t.ZERO,C=t.ZERO,b=t.mul(U,U),I=t.mul(D,D),m=t.mul(P,P),w=t.mul(U,D);return w=t.add(w,w),C=t.mul(U,P),C=t.add(C,C),B=t.mul(E,C),M=t.mul(T,m),M=t.add(B,M),B=t.sub(I,M),M=t.add(I,M),M=t.mul(B,M),B=t.mul(w,B),C=t.mul(T,C),m=t.mul(E,m),w=t.sub(b,m),w=t.mul(E,w),w=t.add(w,C),C=t.add(b,b),b=t.add(C,b),b=t.add(b,m),b=t.mul(b,w),M=t.add(M,b),m=t.mul(D,P),m=t.add(m,m),b=t.mul(m,w),B=t.sub(B,b),C=t.mul(m,I),C=t.add(C,C),C=t.add(C,C),new g(B,M,C)}add(E){d(E);const{px:O,py:T,pz:U}=this,{px:D,py:P,pz:B}=E;let M=t.ZERO,C=t.ZERO,b=t.ZERO;const I=e.a,m=t.mul(e.b,Fn);let w=t.mul(O,D),S=t.mul(T,P),N=t.mul(U,B),v=t.add(O,T),_=t.add(D,P);v=t.mul(v,_),_=t.add(w,S),v=t.sub(v,_),_=t.add(O,U);let L=t.add(D,B);return _=t.mul(_,L),L=t.add(w,N),_=t.sub(_,L),L=t.add(T,U),M=t.add(P,B),L=t.mul(L,M),M=t.add(S,N),L=t.sub(L,M),b=t.mul(I,_),M=t.mul(m,N),b=t.add(M,b),M=t.sub(S,b),b=t.add(S,b),C=t.mul(M,b),S=t.add(w,w),S=t.add(S,w),N=t.mul(I,N),_=t.mul(m,_),S=t.add(S,N),N=t.sub(w,N),N=t.mul(I,N),_=t.add(_,N),w=t.mul(S,_),C=t.add(C,w),w=t.mul(L,_),M=t.mul(v,M),M=t.sub(M,w),w=t.mul(v,S),b=t.mul(L,b),b=t.add(b,w),new g(M,C,b)}subtract(E){return this.add(E.negate())}is0(){return this.equals(g.ZERO)}wNAF(E){return R.wNAFCached(this,E,g.normalizeZ)}multiplyUnsafe(E){const{endo:O,n:T}=e;yi("scalar",E,rs,T);const U=g.ZERO;if(E===rs)return U;if(this.is0()||E===Pe)return this;if(!O||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,E,g.normalizeZ);let{k1neg:D,k1:P,k2neg:B,k2:M}=O.splitScalar(E),C=U,b=U,I=this;for(;P>rs||M>rs;)P&Pe&&(C=C.add(I)),M&Pe&&(b=b.add(I)),I=I.double(),P>>=Pe,M>>=Pe;return D&&(C=C.negate()),B&&(b=b.negate()),b=new g(t.mul(b.px,O.beta),b.py,b.pz),C.add(b)}multiply(E){const{endo:O,n:T}=e;yi("scalar",E,Pe,T);let U,D;if(O){const{k1neg:P,k1:B,k2neg:M,k2:C}=O.splitScalar(E);let{p:b,f:I}=this.wNAF(B),{p:m,f:w}=this.wNAF(C);b=R.constTimeNegate(P,b),m=R.constTimeNegate(M,m),m=new g(t.mul(m.px,O.beta),m.py,m.pz),U=b.add(m),D=I.add(w)}else{const{p:P,f:B}=this.wNAF(E);U=P,D=B}return g.normalizeZ([U,D])[0]}multiplyAndAddUnsafe(E,O,T){const U=g.BASE,D=(B,M)=>M===rs||M===Pe||!B.equals(U)?B.multiplyUnsafe(M):B.multiply(M),P=D(this,O).add(D(E,T));return P.is0()?void 0:P}toAffine(E){return f(this,E)}isTorsionFree(){const{h:E,isTorsionFree:O}=e;if(E===Pe)return!0;if(O)return O(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:E,clearCofactor:O}=e;return E===Pe?this:O?O(g,this):this.multiplyUnsafe(e.h)}toRawBytes(E=!0){return ir("isCompressed",E),this.assertValidity(),r(g,this,E)}toHex(E=!0){return ir("isCompressed",E),rr(this.toRawBytes(E))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const{endo:y,nBitLength:A}=e,R=kg(g,y?Math.ceil(A/2):A);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:h}}function qg(s){const e=su(s);return mn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function jg(s){const e=qg(s),{Fp:t,n:i,nByteLength:r,nBitLength:n}=e,o=t.BYTES+1,a=2*t.BYTES+1;function c(m){return tt(m,i)}function l(m){return Po(m,i)}const{ProjectivePoint:h,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=Mg({...e,toBytes(m,w,S){const N=w.toAffine(),v=t.toBytes(N.x),_=Xr;return ir("isCompressed",S),S?_(Uint8Array.from([w.hasEvenY()?2:3]),v):_(Uint8Array.from([4]),v,t.toBytes(N.y))},fromBytes(m){const w=m.length,S=m[0],N=m.subarray(1);if(w===o&&(S===2||S===3)){const v=Js(N);if(!Ia(v,Pe,t.ORDER))throw new Error("Point is not on curve");const _=d(v);let L;try{L=t.sqrt(_)}catch(V){const H=V instanceof Error?": "+V.message:"";throw new Error("Point is not on curve"+H)}const q=(L&Pe)===Pe;return(S&1)===1!==q&&(L=t.neg(L)),{x:v,y:L}}else if(w===a&&S===4){const v=t.fromBytes(N.subarray(0,t.BYTES)),_=t.fromBytes(N.subarray(t.BYTES,2*t.BYTES));return{x:v,y:_}}else{const v=o,_=a;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+_+", got "+w)}}});function p(m){const w=i>>Pe;return m>w}function g(m){return p(m)?c(-m):m}const y=(m,w,S)=>Js(m.slice(w,S));class A{constructor(w,S,N){yi("r",w,Pe,i),yi("s",S,Pe,i),this.r=w,this.s=S,N!=null&&(this.recovery=N),Object.freeze(this)}static fromCompact(w){const S=r;return w=Et("compactSignature",w,S*2),new A(y(w,0,S),y(w,S,2*S))}static fromDER(w){const{r:S,s:N}=ss.toSig(Et("DER",w));return new A(S,N)}assertValidity(){}addRecoveryBit(w){return new A(this.r,this.s,w)}recoverPublicKey(w){const{r:S,s:N,recovery:v}=this,_=U(Et("msgHash",w));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");const L=v===2||v===3?S+e.n:S;if(L>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const q=v&1?"03":"02",Y=h.fromHex(q+jn(L,t.BYTES)),V=l(L),H=c(-_*V),J=c(N*V),G=h.BASE.multiplyAndAddUnsafe(Y,H,J);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Jr(this.toDERHex())}toDERHex(){return ss.hexFromSig(this)}toCompactRawBytes(){return Jr(this.toCompactHex())}toCompactHex(){const w=r;return jn(this.r,w)+jn(this.s,w)}}const R={isValidPrivateKey(m){try{return u(m),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const m=Qh(e.n);return Ng(e.randomBytes(m),e.n)},precompute(m=8,w=h.BASE){return w._setWindowSize(m),w.multiply(BigInt(3)),w}};function x(m,w=!0){return h.fromPrivateKey(m).toRawBytes(w)}function E(m){if(typeof m=="bigint")return!1;if(m instanceof h)return!0;const S=Et("key",m).length,N=t.BYTES,v=N+1,_=2*N+1;if(!(e.allowedPrivateKeyLengths||r===v))return S===v||S===_}function O(m,w,S=!0){if(E(m)===!0)throw new Error("first arg must be private key");if(E(w)===!1)throw new Error("second arg must be public key");return h.fromHex(w).multiply(u(m)).toRawBytes(S)}const T=e.bits2int||function(m){if(m.length>8192)throw new Error("input is too large");const w=Js(m),S=m.length*8-n;return S>0?w>>BigInt(S):w},U=e.bits2int_modN||function(m){return c(T(m))},D=gn(n);function P(m){return yi("num < 2^"+n,m,rs,D),fr(m,r)}function B(m,w,S=M){if(["recovered","canonical"].some(Z=>Z in S))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:v}=e;let{lowS:_,prehash:L,extraEntropy:q}=S;_==null&&(_=!0),m=Et("msgHash",m),Ic(S),L&&(m=Et("prehashed msgHash",N(m)));const Y=U(m),V=u(w),H=[P(V),P(Y)];if(q!=null&&q!==!1){const Z=q===!0?v(t.BYTES):q;H.push(Et("extraEntropy",Z))}const J=Xr(...H),G=Y;function ce(Z){const ue=T(Z);if(!f(ue))return;const Ke=l(ue),Ye=h.BASE.multiply(ue).toAffine(),He=c(Ye.x);if(He===rs)return;const mt=c(Ke*c(G+He*V));if(mt===rs)return;let Rs=(Ye.x===He?0:2)|Number(Ye.y&Pe),ni=mt;return _&&p(mt)&&(ni=g(mt),Rs^=1),new A(He,ni,Rs)}return{seed:J,k2sig:ce}}const M={lowS:e.lowS,prehash:!1},C={lowS:e.lowS,prehash:!1};function b(m,w,S=M){const{seed:N,k2sig:v}=B(m,w,S),_=e;return Mp(_.hash.outputLen,_.nByteLength,_.hmac)(N,v)}h.BASE._setWindowSize(8);function I(m,w,S,N=C){var Rs;const v=m;w=Et("msgHash",w),S=Et("publicKey",S);const{lowS:_,prehash:L,format:q}=N;if(Ic(N),"strict"in N)throw new Error("options.strict was renamed to lowS");if(q!==void 0&&q!=="compact"&&q!=="der")throw new Error("format must be compact or der");const Y=typeof v=="string"||dr(v),V=!Y&&!q&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!Y&&!V)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,J;try{if(V&&(H=new A(v.r,v.s)),Y){try{q!=="compact"&&(H=A.fromDER(v))}catch(ni){if(!(ni instanceof ss.Err))throw ni}!H&&q!=="der"&&(H=A.fromCompact(v))}J=h.fromHex(S)}catch{return!1}if(!H||_&&H.hasHighS())return!1;L&&(w=e.hash(w));const{r:G,s:ce}=H,Z=U(w),ue=l(ce),Ke=c(Z*ue),Ye=c(G*ue),He=(Rs=h.BASE.multiplyAndAddUnsafe(J,Ke,Ye))==null?void 0:Rs.toAffine();return He?c(He.x)===G:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:O,sign:b,verify:I,ProjectivePoint:h,Signature:A,utils:R}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fg(s){return{hash:s,hmac:(e,...t)=>Sf(s,e,_f(...t)),randomBytes:Af}}function zg(s,e){const t=i=>jg({...s,...Fg(i)});return{...t(e),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const iu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Kg=BigInt(0),Hg=BigInt(1),Oo=BigInt(2),Ac=(s,e)=>(s+e/Oo)/e;function Vg(s){const e=iu,t=BigInt(3),i=BigInt(6),r=BigInt(11),n=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=s*s*s%e,h=l*l*s%e,u=yt(h,t,e)*h%e,d=yt(u,t,e)*h%e,f=yt(d,Oo,e)*l%e,p=yt(f,r,e)*f%e,g=yt(p,n,e)*p%e,y=yt(g,a,e)*g%e,A=yt(y,c,e)*y%e,R=yt(A,a,e)*g%e,x=yt(R,t,e)*h%e,E=yt(x,o,e)*p%e,O=yt(E,i,e)*l%e,T=yt(O,Oo,e);if(!No.eql(No.sqr(T),s))throw new Error("Cannot find square root");return T}const No=Sa(iu,void 0,void 0,{sqrt:Vg}),Wg=zg({a:Kg,b:BigInt(7),Fp:No,n:xc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:s=>{const e=xc,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Hg*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),n=t,o=BigInt("0x100000000000000000000000000000000"),a=Ac(n*s,e),c=Ac(-i*s,e);let l=tt(s-a*t-c*r,e),h=tt(-a*i-c*n,e);const u=l>o,d=h>o;if(u&&(l=e-l),d&&(h=e-h),l>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+s);return{k1neg:u,k1:l,k2neg:d,k2:h}}}},Cf);function Gg(s){if(s.length!==130&&s.length!==132)throw new Zg({signature:s});const e=BigInt(es(s,0,32)),t=BigInt(es(s,32,64)),i=(()=>{const r=+`0x${s.slice(130)}`;if(!Number.isNaN(r))try{return Yg(r)}catch{throw new Jg({value:r})}})();return typeof i>"u"?{r:e,s:t}:{r:e,s:t,yParity:i}}function Yg(s){if(s===0||s===27)return 0;if(s===1||s===28)return 1;if(s>=35)return s%2===0?1:0;throw new Xg({value:s})}class Zg extends ye{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${$s(Aa(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Jg extends ye{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class Xg extends ye{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function Qg(s){return Eg(em(s))}function em(s){const{payload:e,signature:t}=s,{r:i,s:r,yParity:n}=t,a=new Wg.Signature(BigInt(i),BigInt(r)).addRecoveryBit(n).recoverPublicKey(Aa(e).substring(2));return dg(a)}function tm(s){const e=s.length;let t=0,i=0;for(;i<e;){let r=s.charCodeAt(i++);if(r&4294967168)if(!(r&4294965248))t+=2;else{if(r>=55296&&r<=56319&&i<e){const n=s.charCodeAt(i);(n&64512)===56320&&(++i,r=((r&1023)<<10)+(n&1023)+65536)}r&4294901760?t+=4:t+=3}else{t++;continue}}return t}function sm(s,e,t){const i=s.length;let r=t,n=0;for(;n<i;){let o=s.charCodeAt(n++);if(o&4294967168)if(!(o&4294965248))e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&n<i){const a=s.charCodeAt(n);(a&64512)===56320&&(++n,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128):(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128)}else{e[r++]=o;continue}e[r++]=o&63|128}}const im=new TextEncoder,rm=50;function nm(s,e,t){im.encodeInto(s,e.subarray(t))}function om(s,e,t){s.length>rm?nm(s,e,t):sm(s,e,t)}const am=4096;function ru(s,e,t){let i=e;const r=i+t,n=[];let o="";for(;i<r;){const a=s[i++];if(!(a&128))n.push(a);else if((a&224)===192){const c=s[i++]&63;n.push((a&31)<<6|c)}else if((a&240)===224){const c=s[i++]&63,l=s[i++]&63;n.push((a&31)<<12|c<<6|l)}else if((a&248)===240){const c=s[i++]&63,l=s[i++]&63,h=s[i++]&63;let u=(a&7)<<18|c<<12|l<<6|h;u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u)}else n.push(a);n.length>=am&&(o+=String.fromCharCode(...n),n.length=0)}return n.length>0&&(o+=String.fromCharCode(...n)),o}const cm=new TextDecoder,lm=200;function hm(s,e,t){const i=s.subarray(e,e+t);return cm.decode(i)}function um(s,e,t){return t>lm?hm(s,e,t):ru(s,e,t)}class Sr{constructor(e,t){W(this,"type");W(this,"data");this.type=e,this.data=t}}class ht extends Error{constructor(e){super(e);const t=Object.create(ht.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:ht.name})}}const Ti=4294967295;function dm(s,e,t){const i=t/4294967296,r=t;s.setUint32(e,i),s.setUint32(e+4,r)}function nu(s,e,t){const i=Math.floor(t/4294967296),r=t;s.setUint32(e,i),s.setUint32(e+4,r)}function ou(s,e){const t=s.getInt32(e),i=s.getUint32(e+4);return t*4294967296+i}function fm(s,e){const t=s.getUint32(e),i=s.getUint32(e+4);return t*4294967296+i}const pm=-1,gm=4294967296-1,mm=17179869184-1;function ym({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=mm)if(e===0&&s<=gm){const t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{const t=s/4294967296,i=s&4294967295,r=new Uint8Array(8),n=new DataView(r.buffer);return n.setUint32(0,e<<2|t&3),n.setUint32(4,i),r}else{const t=new Uint8Array(12),i=new DataView(t.buffer);return i.setUint32(0,e),nu(i,4,s),t}}function wm(s){const e=s.getTime(),t=Math.floor(e/1e3),i=(e-t*1e3)*1e6,r=Math.floor(i/1e9);return{sec:t+r,nsec:i-r*1e9}}function bm(s){if(s instanceof Date){const e=wm(s);return ym(e)}else return null}function vm(s){const e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const t=e.getUint32(0),i=e.getUint32(4),r=(t&3)*4294967296+i,n=t>>>2;return{sec:r,nsec:n}}case 12:{const t=ou(e,4),i=e.getUint32(0);return{sec:t,nsec:i}}default:throw new ht(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function Em(s){const e=vm(s);return new Date(e.sec*1e3+e.nsec/1e6)}const Im={type:pm,encode:bm,decode:Em},pn=class pn{constructor(){W(this,"__brand");W(this,"builtInEncoders",[]);W(this,"builtInDecoders",[]);W(this,"encoders",[]);W(this,"decoders",[]);this.register(Im)}register({type:e,encode:t,decode:i}){if(e>=0)this.encoders[e]=t,this.decoders[e]=i;else{const r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=i}}tryToEncode(e,t){for(let i=0;i<this.builtInEncoders.length;i++){const r=this.builtInEncoders[i];if(r!=null){const n=r(e,t);if(n!=null){const o=-1-i;return new Sr(o,n)}}}for(let i=0;i<this.encoders.length;i++){const r=this.encoders[i];if(r!=null){const n=r(e,t);if(n!=null){const o=i;return new Sr(o,n)}}}return e instanceof Sr?e:null}decode(e,t,i){const r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,i):new Sr(t,e)}};W(pn,"defaultCodec",new pn);let en=pn;function xm(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function To(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):xm(s)?new Uint8Array(s):Uint8Array.from(s)}const Am=100,Sm=2048;class _a{constructor(e){W(this,"extensionCodec");W(this,"context");W(this,"useBigInt64");W(this,"maxDepth");W(this,"initialBufferSize");W(this,"sortKeys");W(this,"forceFloat32");W(this,"ignoreUndefined");W(this,"forceIntegerToFloat");W(this,"pos");W(this,"view");W(this,"bytes");W(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??en.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Am,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??Sm,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new _a({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){const t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){const t=new ArrayBuffer(e),i=new Uint8Array(t),r=new DataView(t);i.set(this.bytes),this.view=r,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const i=tm(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),om(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,t){const i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);const i=To(e);this.writeU8a(i)}encodeArray(e,t){const i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(const r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let i=0;for(const r of t)e[r]!==void 0&&i++;return i}encodeMap(e,t){const i=Object.keys(e);this.sortKeys&&i.sort();const r=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(const n of i){const o=e[n];this.ignoreUndefined&&o===void 0||(this.encodeString(n),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){const i=e.data(this.pos+6),r=i.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(i);return}const t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),dm(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),nu(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function _m(s,e){return new _a(e).encodeSharedRef(s)}function zn(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}const Cm=16,Pm=16;class $m{constructor(e=Cm,t=Pm){W(this,"hit",0);W(this,"miss",0);W(this,"caches");W(this,"maxKeyLength");W(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,i){const r=this.caches[i-1];e:for(const n of r){const o=n.bytes;for(let a=0;a<i;a++)if(o[a]!==e[t+a])continue e;return n.str}return null}store(e,t){const i=this.caches[e.length-1],r={bytes:e,str:t};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=r:i.push(r)}decode(e,t,i){const r=this.find(e,t,i);if(r!=null)return this.hit++,r;this.miss++;const n=ru(e,t,i),o=Uint8Array.prototype.slice.call(e,t,t+i);return this.store(o,n),n}}const Ro="array",Zi="map_key",au="map_value",Om=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new ht("The type of key must be string or number but "+typeof s)};class Nm{constructor(){W(this,"stack",[]);W(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const t=this.getUninitializedStateFromPool();t.type=Ro,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){const t=this.getUninitializedStateFromPool();t.type=Zi,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Ro){const i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===Zi||e.type===au){const i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const Ri=-1,Ca=new DataView(new ArrayBuffer(0)),Tm=new Uint8Array(Ca.buffer);try{Ca.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const Sc=new RangeError("Insufficient data"),Rm=new $m;class Pa{constructor(e){W(this,"extensionCodec");W(this,"context");W(this,"useBigInt64");W(this,"rawStrings");W(this,"maxStrLength");W(this,"maxBinLength");W(this,"maxArrayLength");W(this,"maxMapLength");W(this,"maxExtLength");W(this,"keyDecoder");W(this,"mapKeyConverter");W(this,"totalPos",0);W(this,"pos",0);W(this,"view",Ca);W(this,"bytes",Tm);W(this,"headByte",Ri);W(this,"stack",new Nm);W(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??en.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Ti,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Ti,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Ti,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Ti,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Ti,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:Rm,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??Om}clone(){return new Pa({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Ri,this.stack.reset()}setBuffer(e){const t=To(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Ri&&!this.hasRemaining(1))this.setBuffer(e);else{const t=this.bytes.subarray(this.pos),i=To(e),r=new Uint8Array(t.length+i.length);r.set(t),r.set(i,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:t,pos:i}=this;return new RangeError(`Extra ${t.byteLength-i} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,i;for await(const a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{i=this.doDecodeSync(),t=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}const{headByte:r,pos:n,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${zn(r)} at ${o} (${n} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let i=t,r=-1;for await(const n of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(n),i&&(r=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){const r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){const r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{const r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){const r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){const r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){const r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){const r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){const r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){const r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){const r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){const r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){const r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){const r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){const r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){const r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){const r=this.lookU32();t=this.decodeExtension(r,4)}else throw new ht(`Unrecognized type byte: ${zn(e)}`);this.complete();const i=this.stack;for(;i.length>0;){const r=i.top();if(r.type===Ro)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,i.release(r);else continue e;else if(r.type===Zi){if(t==="__proto__")throw new ht("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=au;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,i.release(r);else{r.key=null,r.type=Zi;continue e}}return t}}readHeadByte(){return this.headByte===Ri&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Ri}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new ht(`Unrecognized array type byte: ${zn(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new ht(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new ht(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){var n;if(e>this.maxStrLength)throw new ht(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Sc;const i=this.pos+t;let r;return this.stateIsMapKey()&&((n=this.keyDecoder)!=null&&n.canBeCached(e))?r=this.keyDecoder.decode(this.bytes,i,e):r=um(this.bytes,i,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Zi:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new ht(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Sc;const i=this.pos+t,r=this.bytes.subarray(i,i+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new ht(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=fm(this.view,this.pos);return this.pos+=8,e}readI64(){const e=ou(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}function km(s,e){return new Pa(e).decode(s)}var Um={};const Bm=":";function os(s){const[e,t]=s.split(Bm);return{namespace:e,reference:t}}function cu(s,e){return s.includes(":")?[s]:e.chains||[]}const Dm={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Lm={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function F(s,e){const{message:t,code:i}=Lm[s];return{message:e?`${t} ${e}`:t,code:i}}function me(s,e){const{message:t,code:i}=Dm[s];return{message:e?`${t} ${e}`:t,code:i}}var Mm=Object.defineProperty,qm=Object.defineProperties,jm=Object.getOwnPropertyDescriptors,_c=Object.getOwnPropertySymbols,Fm=Object.prototype.hasOwnProperty,zm=Object.prototype.propertyIsEnumerable,ko=(s,e,t)=>e in s?Mm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Cc=(s,e)=>{for(var t in e||(e={}))Fm.call(e,t)&&ko(s,t,e[t]);if(_c)for(var t of _c(e))zm.call(e,t)&&ko(s,t,e[t]);return s},Km=(s,e)=>qm(s,jm(e)),Pc=(s,e,t)=>ko(s,typeof e!="symbol"?e+"":e,t);const Hm="ReactNative",ft={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Vm="js";function tn(){return typeof Wi<"u"&&typeof Wi.versions<"u"&&typeof Wi.versions.node<"u"}function Ns(){return!ls.getDocument()&&!!ls.getNavigator()&&navigator.product===Hm}function Wm(){return Ns()&&typeof X<"u"&&typeof(X==null?void 0:X.Platform)<"u"&&(X==null?void 0:X.Platform.OS)==="android"}function Gm(){return Ns()&&typeof X<"u"&&typeof(X==null?void 0:X.Platform)<"u"&&(X==null?void 0:X.Platform.OS)==="ios"}function $i(){return!tn()&&!!ls.getNavigator()&&!!ls.getDocument()}function pr(){return Ns()?ft.reactNative:tn()?ft.node:$i()?ft.browser:ft.unknown}function $c(){var s;try{return Ns()&&typeof X<"u"&&typeof(X==null?void 0:X.Application)<"u"?(s=X.Application)==null?void 0:s.applicationId:void 0}catch{return}}function Ym(s,e){const t=new URLSearchParams(s);return Object.entries(e).sort(([i],[r])=>i.localeCompare(r)).forEach(([i,r])=>{r!=null&&t.set(i,String(r))}),t.toString()}function Zm(s){var e,t;const i=lu();try{return s!=null&&s.url&&i.url&&new URL(s.url).host!==new URL(i.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${s.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),s.url=i.url),(e=s==null?void 0:s.icons)!=null&&e.length&&s.icons.length>0&&(s.icons=s.icons.filter(r=>r!=="")),Km(Cc(Cc({},i),s),{url:(s==null?void 0:s.url)||i.url,name:(s==null?void 0:s.name)||i.name,description:(s==null?void 0:s.description)||i.description,icons:(t=s==null?void 0:s.icons)!=null&&t.length&&s.icons.length>0?s.icons:i.icons})}catch(r){return console.warn("Error populating app metadata",r),s||i}}function lu(){return Pf.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function Jm(){if(pr()===ft.reactNative&&typeof X<"u"&&typeof(X==null?void 0:X.Platform)<"u"){const{OS:t,Version:i}=X.Platform;return[t,i].join("-")}const s=Of();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function Xm(){var s;const e=pr();return e===ft.browser?[e,((s=ls.getLocation())==null?void 0:s.host)||"unknown"].join(":"):e}function hu(s,e,t){const i=Jm(),r=Xm();return[[s,e].join("-"),[Vm,t].join("-"),i,r].join("/")}function Qm({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=t.split("?"),h=hu(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},d=Ym(l[1]||"",u);return l[0]+"?"+d}function Hs(s,e){return s.filter(t=>e.includes(t)).length===s.length}function Uo(s){return Object.fromEntries(s.entries())}function Bo(s){return new Map(Object.entries(s))}function qs(s=j.FIVE_MINUTES,e){const t=j.toMiliseconds(s||j.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const l=F("EXPIRED"),h=new Error(e||l.message);h.code=l.code,c(h)},t),i=a,r=c})}}function Ft(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function uu(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function ey(s){return uu("topic",s)}function ty(s){return uu("id",s)}function du(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function Ie(s,e){return j.fromMiliseconds(Date.now()+j.toMiliseconds(s))}function jt(s){return Date.now()>=j.toMiliseconds(s)}function le(s,e){return`${s}${e?`:${e}`:""}`}function Kt(s=[],e=[]){return[...new Set([...s,...e])]}async function sy({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=iy(n,s,e),a=pr();if(a===ft.browser){if(!((i=ls.getDocument())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}ry(o)}else a===ft.reactNative&&typeof(X==null?void 0:X.Linking)<"u"&&await X.Linking.openURL(o)}catch(r){console.error(r)}}function iy(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${cy(i,!0)}`}else r=`${r}/wc?${i}`;return r}function ry(s){let e="_self";ay()?e="_top":(oy()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function ny(s,e){let t="";try{if($i()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Oc(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Nc(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function $a(){return typeof Wi<"u"&&Um.IS_VITEST==="true"}function oy(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function ay(){try{return window.self!==window.top}catch{return!1}}function cy(s,e=!1){const t=ie.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function fu(s){return ie.from(s,"base64").toString("utf-8")}function ly(s){return new Promise(e=>setTimeout(e,s))}let hy=class{constructor({limit:e}){Pc(this,"limit"),Pc(this,"set"),this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const t=this.set.values().next().value;t&&this.set.delete(t)}this.set.add(e)}}has(e){return this.set.has(e)}};const _r=BigInt(2**32-1),Tc=BigInt(32);function pu(s,e=!1){return e?{h:Number(s&_r),l:Number(s>>Tc&_r)}:{h:Number(s>>Tc&_r)|0,l:Number(s&_r)|0}}function gu(s,e=!1){const t=s.length;let i=new Uint32Array(t),r=new Uint32Array(t);for(let n=0;n<t;n++){const{h:o,l:a}=pu(s[n],e);[i[n],r[n]]=[o,a]}return[i,r]}const Rc=(s,e,t)=>s>>>t,kc=(s,e,t)=>s<<32-t|e>>>t,bs=(s,e,t)=>s>>>t|e<<32-t,vs=(s,e,t)=>s<<32-t|e>>>t,zi=(s,e,t)=>s<<64-t|e>>>t-32,Ki=(s,e,t)=>s>>>t-32|e<<64-t,uy=(s,e)=>e,dy=(s,e)=>s,fy=(s,e,t)=>s<<t|e>>>32-t,py=(s,e,t)=>e<<t|s>>>32-t,gy=(s,e,t)=>e<<t-32|s>>>64-t,my=(s,e,t)=>s<<t-32|e>>>64-t;function Pt(s,e,t,i){const r=(e>>>0)+(i>>>0);return{h:s+t+(r/2**32|0)|0,l:r|0}}const Oa=(s,e,t)=>(s>>>0)+(e>>>0)+(t>>>0),Na=(s,e,t,i)=>e+t+i+(s/2**32|0)|0,yy=(s,e,t,i)=>(s>>>0)+(e>>>0)+(t>>>0)+(i>>>0),wy=(s,e,t,i,r)=>e+t+i+r+(s/2**32|0)|0,by=(s,e,t,i,r)=>(s>>>0)+(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0),vy=(s,e,t,i,r,n)=>e+t+i+r+n+(s/2**32|0)|0,oi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function yn(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function hs(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Tt(s,...e){if(!yn(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function wn(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");hs(s.outputLen),hs(s.blockLen)}function Os(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Ta(s,e){Tt(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function nr(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function At(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}function Kn(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Rt(s,e){return s<<32-e|s>>>e}const mu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function yu(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}const Jt=mu?s=>s:s=>yu(s);function Ey(s){for(let e=0;e<s.length;e++)s[e]=yu(s[e]);return s}const Es=mu?s=>s:Ey,wu=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Iy=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function wi(s){if(Tt(s),wu)return s.toHex();let e="";for(let t=0;t<s.length;t++)e+=Iy[s[t]];return e}const Yt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Uc(s){if(s>=Yt._0&&s<=Yt._9)return s-Yt._0;if(s>=Yt.A&&s<=Yt.F)return s-(Yt.A-10);if(s>=Yt.a&&s<=Yt.f)return s-(Yt.a-10)}function sn(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(wu)return Uint8Array.fromHex(s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=Uc(s.charCodeAt(n)),a=Uc(s.charCodeAt(n+1));if(o===void 0||a===void 0){const c=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[r]=o*16+a}return i}function bu(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function Nt(s){return typeof s=="string"&&(s=bu(s)),Tt(s),s}function Is(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Tt(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let bn=class{};function gr(s){const e=i=>s().update(Nt(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function xy(s){const e=(i,r)=>s(r).update(Nt(i)).digest(),t=s({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}function ii(s=32){if(oi&&typeof oi.getRandomValues=="function")return oi.getRandomValues(new Uint8Array(s));if(oi&&typeof oi.randomBytes=="function")return Uint8Array.from(oi.randomBytes(s));throw new Error("crypto.getRandomValues must be defined")}const Ay=BigInt(0),ki=BigInt(1),Sy=BigInt(2),_y=BigInt(7),Cy=BigInt(256),Py=BigInt(113),vu=[],Eu=[],Iu=[];for(let s=0,e=ki,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],vu.push(2*(5*i+t)),Eu.push((s+1)*(s+2)/2%64);let r=Ay;for(let n=0;n<7;n++)e=(e<<ki^(e>>_y)*Py)%Cy,e&Sy&&(r^=ki<<(ki<<BigInt(n))-ki);Iu.push(r)}const xu=gu(Iu,!0),$y=xu[0],Oy=xu[1],Bc=(s,e,t)=>t>32?gy(s,e,t):fy(s,e,t),Dc=(s,e,t)=>t>32?my(s,e,t):py(s,e,t);function Ny(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=t[c],h=t[c+1],u=Bc(l,h,1)^t[a],d=Dc(l,h,1)^t[a+1];for(let f=0;f<50;f+=10)s[o+f]^=u,s[o+f+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Eu[o],c=Bc(r,n,a),l=Dc(r,n,a),h=vu[o];r=s[h],n=s[h+1],s[h]=c,s[h+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=$y[i],s[1]^=Oy[i]}At(t)}let Ty=class Au extends bn{constructor(e,t,i,r=!1,n=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,hs(i),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=nr(this.state)}clone(){return this._cloneInto()}keccak(){Es(this.state32),Ny(this.state32,this.rounds),Es(this.state32),this.posOut=0,this.pos=0}update(e){Os(this),e=Nt(e),Tt(e);const{blockLen:t,state:i}=this,r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Os(this,!1),Tt(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return hs(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ta(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,At(this.state)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new Au(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const Ry=(s,e,t)=>gr(()=>new Ty(e,s,t)),ky=Ry(1,136,256/8);function Uy(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),c=i?4:0,l=i?0:4;s.setUint32(e+c,o,i),s.setUint32(e+l,a,i)}function By(s,e,t){return s&e^~s&t}function Dy(s,e,t){return s&e^s&t^e&t}let Su=class extends bn{constructor(e,t,i,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Kn(this.buffer)}update(e){Os(this),e=Nt(e),Tt(e);const{view:t,buffer:i,blockLen:r}=this,n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const c=Kn(e);for(;r<=n-o;o+=r)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Os(this),Ta(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,At(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(i,0),o=0);for(let u=o;u<r;u++)t[u]=0;Uy(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=Kn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=n,e.length=r,e.pos=a,r%t&&e.buffer.set(i),e}clone(){return this._cloneInto()}};const fs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),De=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Le=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ly=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ps=new Uint32Array(64);class My extends Su{constructor(e=32){super(64,e,8,!1),this.A=fs[0]|0,this.B=fs[1]|0,this.C=fs[2]|0,this.D=fs[3]|0,this.E=fs[4]|0,this.F=fs[5]|0,this.G=fs[6]|0,this.H=fs[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:c}=this;return[e,t,i,r,n,o,a,c]}set(e,t,i,r,n,o,a,c){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,t){for(let u=0;u<16;u++,t+=4)ps[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=ps[u-15],f=ps[u-2],p=Rt(d,7)^Rt(d,18)^d>>>3,g=Rt(f,17)^Rt(f,19)^f>>>10;ps[u]=g+ps[u-7]+p+ps[u-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=Rt(a,6)^Rt(a,11)^Rt(a,25),f=h+d+By(a,c,l)+Ly[u]+ps[u]|0,p=(Rt(i,2)^Rt(i,13)^Rt(i,22))+Dy(i,r,n)|0;h=l,l=c,c=a,a=o+f|0,o=n,n=r,r=i,i=f+p|0}i=i+this.A|0,r=r+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(i,r,n,o,a,c,l,h)}roundClean(){At(ps)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}}const _u=gu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(s=>BigInt(s))),qy=_u[0],jy=_u[1],gs=new Uint32Array(80),ms=new Uint32Array(80);let Ra=class extends Su{constructor(e=64){super(128,e,16,!1),this.Ah=Le[0]|0,this.Al=Le[1]|0,this.Bh=Le[2]|0,this.Bl=Le[3]|0,this.Ch=Le[4]|0,this.Cl=Le[5]|0,this.Dh=Le[6]|0,this.Dl=Le[7]|0,this.Eh=Le[8]|0,this.El=Le[9]|0,this.Fh=Le[10]|0,this.Fl=Le[11]|0,this.Gh=Le[12]|0,this.Gl=Le[13]|0,this.Hh=Le[14]|0,this.Hl=Le[15]|0}get(){const{Ah:e,Al:t,Bh:i,Bl:r,Ch:n,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:u,Fl:d,Gh:f,Gl:p,Hh:g,Hl:y}=this;return[e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y]}set(e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y){this.Ah=e|0,this.Al=t|0,this.Bh=i|0,this.Bl=r|0,this.Ch=n|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=g|0,this.Hl=y|0}process(e,t){for(let x=0;x<16;x++,t+=4)gs[x]=e.getUint32(t),ms[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){const E=gs[x-15]|0,O=ms[x-15]|0,T=bs(E,O,1)^bs(E,O,8)^Rc(E,O,7),U=vs(E,O,1)^vs(E,O,8)^kc(E,O,7),D=gs[x-2]|0,P=ms[x-2]|0,B=bs(D,P,19)^zi(D,P,61)^Rc(D,P,6),M=vs(D,P,19)^Ki(D,P,61)^kc(D,P,6),C=yy(U,M,ms[x-7],ms[x-16]),b=wy(C,T,B,gs[x-7],gs[x-16]);gs[x]=b|0,ms[x]=C|0}let{Ah:i,Al:r,Bh:n,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:u,El:d,Fh:f,Fl:p,Gh:g,Gl:y,Hh:A,Hl:R}=this;for(let x=0;x<80;x++){const E=bs(u,d,14)^bs(u,d,18)^zi(u,d,41),O=vs(u,d,14)^vs(u,d,18)^Ki(u,d,41),T=u&f^~u&g,U=d&p^~d&y,D=by(R,O,U,jy[x],ms[x]),P=vy(D,A,E,T,qy[x],gs[x]),B=D|0,M=bs(i,r,28)^zi(i,r,34)^zi(i,r,39),C=vs(i,r,28)^Ki(i,r,34)^Ki(i,r,39),b=i&n^i&a^n&a,I=r&o^r&c^o&c;A=g|0,R=y|0,g=f|0,y=p|0,f=u|0,p=d|0,{h:u,l:d}=Pt(l|0,h|0,P|0,B|0),l=a|0,h=c|0,a=n|0,c=o|0,n=i|0,o=r|0;const m=Oa(B,C,I);i=Na(m,P,M,b),r=m|0}({h:i,l:r}=Pt(this.Ah|0,this.Al|0,i|0,r|0)),{h:n,l:o}=Pt(this.Bh|0,this.Bl|0,n|0,o|0),{h:a,l:c}=Pt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=Pt(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:d}=Pt(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Pt(this.Fh|0,this.Fl|0,f|0,p|0),{h:g,l:y}=Pt(this.Gh|0,this.Gl|0,g|0,y|0),{h:A,l:R}=Pt(this.Hh|0,this.Hl|0,A|0,R|0),this.set(i,r,n,o,a,c,l,h,u,d,f,p,g,y,A,R)}roundClean(){At(gs,ms)}destroy(){At(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class Fy extends Ra{constructor(){super(48),this.Ah=De[0]|0,this.Al=De[1]|0,this.Bh=De[2]|0,this.Bl=De[3]|0,this.Ch=De[4]|0,this.Cl=De[5]|0,this.Dh=De[6]|0,this.Dl=De[7]|0,this.Eh=De[8]|0,this.El=De[9]|0,this.Fh=De[10]|0,this.Fl=De[11]|0,this.Gh=De[12]|0,this.Gl=De[13]|0,this.Hh=De[14]|0,this.Hl=De[15]|0}}const Me=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class zy extends Ra{constructor(){super(32),this.Ah=Me[0]|0,this.Al=Me[1]|0,this.Bh=Me[2]|0,this.Bl=Me[3]|0,this.Ch=Me[4]|0,this.Cl=Me[5]|0,this.Dh=Me[6]|0,this.Dl=Me[7]|0,this.Eh=Me[8]|0,this.El=Me[9]|0,this.Fh=Me[10]|0,this.Fl=Me[11]|0,this.Gh=Me[12]|0,this.Gl=Me[13]|0,this.Hh=Me[14]|0,this.Hl=Me[15]|0}}const vn=gr(()=>new My),Ky=gr(()=>new Ra),Hy=gr(()=>new Fy),Vy=gr(()=>new zy),Wy=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),Ae=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),z=new Uint32Array(32);function ys(s,e,t,i,r,n){const o=r[n],a=r[n+1];let c=z[2*s],l=z[2*s+1],h=z[2*e],u=z[2*e+1],d=z[2*t],f=z[2*t+1],p=z[2*i],g=z[2*i+1],y=Oa(c,h,o);l=Na(y,l,u,a),c=y|0,{Dh:g,Dl:p}={Dh:g^l,Dl:p^c},{Dh:g,Dl:p}={Dh:uy(g,p),Dl:dy(g)},{h:f,l:d}=Pt(f,d,g,p),{Bh:u,Bl:h}={Bh:u^f,Bl:h^d},{Bh:u,Bl:h}={Bh:bs(u,h,24),Bl:vs(u,h,24)},z[2*s]=c,z[2*s+1]=l,z[2*e]=h,z[2*e+1]=u,z[2*t]=d,z[2*t+1]=f,z[2*i]=p,z[2*i+1]=g}function ws(s,e,t,i,r,n){const o=r[n],a=r[n+1];let c=z[2*s],l=z[2*s+1],h=z[2*e],u=z[2*e+1],d=z[2*t],f=z[2*t+1],p=z[2*i],g=z[2*i+1],y=Oa(c,h,o);l=Na(y,l,u,a),c=y|0,{Dh:g,Dl:p}={Dh:g^l,Dl:p^c},{Dh:g,Dl:p}={Dh:bs(g,p,16),Dl:vs(g,p,16)},{h:f,l:d}=Pt(f,d,g,p),{Bh:u,Bl:h}={Bh:u^f,Bl:h^d},{Bh:u,Bl:h}={Bh:zi(u,h,63),Bl:Ki(u,h,63)},z[2*s]=c,z[2*s+1]=l,z[2*e]=h,z[2*e+1]=u,z[2*t]=d,z[2*t+1]=f,z[2*i]=p,z[2*i+1]=g}function Gy(s,e={},t,i,r){if(hs(t),s<0||s>t)throw new Error("outputLen bigger than keyLen");const{key:n,salt:o,personalization:a}=e;if(n!==void 0&&(n.length<1||n.length>t))throw new Error("key length must be undefined or 1.."+t);if(o!==void 0&&o.length!==i)throw new Error("salt must be undefined or "+i);if(a!==void 0&&a.length!==r)throw new Error("personalization must be undefined or "+r)}class Yy extends bn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,hs(e),hs(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=nr(this.buffer)}update(e){Os(this),e=Nt(e),Tt(e);const{blockLen:t,buffer:i,buffer32:r}=this,n=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<n;){this.pos===t&&(Es(r),this.compress(r,0,!1),Es(r),this.pos=0);const l=Math.min(t-this.pos,n-c),h=o+c;if(l===t&&!(h%4)&&c+l<n){const u=new Uint32Array(a,h,Math.floor((n-c)/4));Es(u);for(let d=0;c+t<n;d+=r.length,c+=t)this.length+=t,this.compress(u,d,!1);Es(u);continue}i.set(e.subarray(c,c+l),this.pos),this.pos+=l,this.length+=l,c+=l}return this}digestInto(e){Os(this),Ta(e,this);const{pos:t,buffer32:i}=this;this.finished=!0,At(this.buffer.subarray(t)),Es(i),this.compress(i,0,!0),Es(i);const r=nr(e);this.get().forEach((n,o)=>r[o]=Jt(n))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){const{buffer:t,length:i,finished:r,destroyed:n,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(t),e.destroyed=n,e.finished=r,e.length=i,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class Zy extends Yy{constructor(e={}){const t=e.dkLen===void 0?64:e.dkLen;super(128,t),this.v0l=Ae[0]|0,this.v0h=Ae[1]|0,this.v1l=Ae[2]|0,this.v1h=Ae[3]|0,this.v2l=Ae[4]|0,this.v2h=Ae[5]|0,this.v3l=Ae[6]|0,this.v3h=Ae[7]|0,this.v4l=Ae[8]|0,this.v4h=Ae[9]|0,this.v5l=Ae[10]|0,this.v5h=Ae[11]|0,this.v6l=Ae[12]|0,this.v6h=Ae[13]|0,this.v7l=Ae[14]|0,this.v7h=Ae[15]|0,Gy(t,e,64,16,16);let{key:i,personalization:r,salt:n}=e,o=0;if(i!==void 0&&(i=Nt(i),o=i.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,n!==void 0){n=Nt(n);const a=nr(n);this.v4l^=Jt(a[0]),this.v4h^=Jt(a[1]),this.v5l^=Jt(a[2]),this.v5h^=Jt(a[3])}if(r!==void 0){r=Nt(r);const a=nr(r);this.v6l^=Jt(a[0]),this.v6h^=Jt(a[1]),this.v7l^=Jt(a[2]),this.v7h^=Jt(a[3])}if(i!==void 0){const a=new Uint8Array(this.blockLen);a.set(i),this.update(a)}}get(){let{v0l:e,v0h:t,v1l:i,v1h:r,v2l:n,v2h:o,v3l:a,v3h:c,v4l:l,v4h:h,v5l:u,v5h:d,v6l:f,v6h:p,v7l:g,v7h:y}=this;return[e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y]}set(e,t,i,r,n,o,a,c,l,h,u,d,f,p,g,y){this.v0l=e|0,this.v0h=t|0,this.v1l=i|0,this.v1h=r|0,this.v2l=n|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=l|0,this.v4h=h|0,this.v5l=u|0,this.v5h=d|0,this.v6l=f|0,this.v6h=p|0,this.v7l=g|0,this.v7h=y|0}compress(e,t,i){this.get().forEach((c,l)=>z[l]=c),z.set(Ae,16);let{h:r,l:n}=pu(BigInt(this.length));z[24]=Ae[8]^n,z[25]=Ae[9]^r,i&&(z[28]=~z[28],z[29]=~z[29]);let o=0;const a=Wy;for(let c=0;c<12;c++)ys(0,4,8,12,e,t+2*a[o++]),ws(0,4,8,12,e,t+2*a[o++]),ys(1,5,9,13,e,t+2*a[o++]),ws(1,5,9,13,e,t+2*a[o++]),ys(2,6,10,14,e,t+2*a[o++]),ws(2,6,10,14,e,t+2*a[o++]),ys(3,7,11,15,e,t+2*a[o++]),ws(3,7,11,15,e,t+2*a[o++]),ys(0,5,10,15,e,t+2*a[o++]),ws(0,5,10,15,e,t+2*a[o++]),ys(1,6,11,12,e,t+2*a[o++]),ws(1,6,11,12,e,t+2*a[o++]),ys(2,7,8,13,e,t+2*a[o++]),ws(2,7,8,13,e,t+2*a[o++]),ys(3,4,9,14,e,t+2*a[o++]),ws(3,4,9,14,e,t+2*a[o++]);this.v0l^=z[0]^z[16],this.v0h^=z[1]^z[17],this.v1l^=z[2]^z[18],this.v1h^=z[3]^z[19],this.v2l^=z[4]^z[20],this.v2h^=z[5]^z[21],this.v3l^=z[6]^z[22],this.v3h^=z[7]^z[23],this.v4l^=z[8]^z[24],this.v4h^=z[9]^z[25],this.v5l^=z[10]^z[26],this.v5h^=z[11]^z[27],this.v6l^=z[12]^z[28],this.v6h^=z[13]^z[29],this.v7l^=z[14]^z[30],this.v7h^=z[15]^z[31],At(z)}destroy(){this.destroyed=!0,At(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Jy=xy(s=>new Zy(s)),Xy="https://rpc.walletconnect.org/v1";function Cu(s){const e=`Ethereum Signed Message:
|
|
4
4
|
${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+ie.from(ky(t)).toString("hex")}async function Qy(s,e,t,i,r,n){switch(t.t){case"eip191":return await ew(s,e,t.s);case"eip1271":return await tw(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function ew(s,e,t){const i=Gg(t);return Qg({payload:Cu(e),signature:i}).toLowerCase()===s.toLowerCase()}async function tw(s,e,t,i,r,n){const o=os(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l=t.substring(2),h=(l.length/2).toString(16).padStart(64,"0"),u=(e.startsWith("0x")?e:Cu(e)).substring(2),d=a+u+c+h+l,f=await fetch(`${n||Xy}/?chainId=${i}&projectId=${r}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:sw(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function sw(){return Date.now()+Math.floor(Math.random()*1e3)}function iw(s){const e=atob(s),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);const i=t[0];if(i===0)throw new Error("No signatures found");const r=1+i*64;if(t.length<r)throw new Error("Transaction data too short for claimed signature count");if(t.length<100)throw new Error("Transaction too short");const n=ie.from(s,"base64").slice(1,65);return ur.encode(n)}function rw(s){const e=new Uint8Array(ie.from(s,"base64")),t=Array.from("TransactionData::").map(n=>n.charCodeAt(0)),i=new Uint8Array(t.length+e.length);i.set(t),i.set(e,t.length);const r=Jy(i,{dkLen:32});return ur.encode(r)}function Lc(s){const e=new Uint8Array(vn(nw(s)));return ur.encode(e)}function nw(s){if(s instanceof Uint8Array)return s;if(Array.isArray(s))return new Uint8Array(s);if(typeof s=="object"&&s!=null&&s.data)return new Uint8Array(Object.values(s.data));if(typeof s=="object"&&s)return new Uint8Array(Object.values(s));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function Mc(s){const e=ie.from(s,"base64"),t=km(e).txn;if(!t)throw new Error("Invalid signed transaction: missing 'txn' field");const i=_m(t),r=ie.from("TX"),n=ie.concat([r,ie.from(i)]),o=Vy(n);return of.encode(o).replace(/=+$/,"")}function Hn(s){const e=[];let t=BigInt(s);for(;t>=BigInt(128);)e.push(Number(t&BigInt(127)|BigInt(128))),t>>=BigInt(7);return e.push(Number(t)),ie.from(e)}function ow(s){const e=ie.from(s.signed.bodyBytes,"base64"),t=ie.from(s.signed.authInfoBytes,"base64"),i=ie.from(s.signature.signature,"base64"),r=[];r.push(ie.from([10])),r.push(Hn(e.length)),r.push(e),r.push(ie.from([18])),r.push(Hn(t.length)),r.push(t),r.push(ie.from([26])),r.push(Hn(i.length)),r.push(i);const n=ie.concat(r),o=vn(n);return ie.from(o).toString("hex").toUpperCase()}function aw(s){var e,t;const i=[];try{if(typeof s=="string")return i.push(s),i;if(typeof s!="object")return i;s!=null&&s.id&&i.push(s.id);const r=(t=(e=s==null?void 0:s.capabilities)==null?void 0:e.caip345)==null?void 0:t.transactionHashes;r&&i.push(...r)}catch(r){console.warn("getWalletSendCallsHashes failed: ",r)}return i}var cw=Object.defineProperty,lw=Object.defineProperties,hw=Object.getOwnPropertyDescriptors,qc=Object.getOwnPropertySymbols,uw=Object.prototype.hasOwnProperty,dw=Object.prototype.propertyIsEnumerable,jc=(s,e,t)=>e in s?cw(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,fw=(s,e)=>{for(var t in e||(e={}))uw.call(e,t)&&jc(s,t,e[t]);if(qc)for(var t of qc(e))dw.call(e,t)&&jc(s,t,e[t]);return s},pw=(s,e)=>lw(s,hw(e));const Pu="did:pkh:",gw={eip155:"Ethereum",solana:"Solana",bip122:"Bitcoin"},mw=s=>s?gw[s]||s:"",En=s=>s==null?void 0:s.split(":"),yw=s=>{const e=s&&En(s);if(e)return s.includes(Pu)?e[3]:e[1]},ww=s=>{const e=s&&En(s);if(e)return s.includes(Pu)?e[2]:e[0]},Do=s=>{const e=s&&En(s);if(e)return e[2]+":"+e[3]},rn=s=>{const e=s&&En(s);if(e)return e.pop()};async function Fc(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=$u(r,r.iss),o=rn(r.iss);return await Qy(o,n,i,Do(r.iss),t)}const $u=(s,e)=>{const t=ww(e);if(!t)throw new Error("Invalid issuer: "+e);const i=`${s.domain} wants you to sign in with your ${mw(t)} account:`,r=rn(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=s.statement||void 0;const o=`URI: ${s.aud||s.uri}`,a=`Version: ${s.version}`,c=`Chain ID: ${yw(e)}`,l=`Nonce: ${s.nonce}`,h=`Issued At: ${s.iat}`,u=s.exp?`Expiration Time: ${s.exp}`:void 0,d=s.nbf?`Not Before: ${s.nbf}`:void 0,f=s.requestId?`Request ID: ${s.requestId}`:void 0,p=s.resources?`Resources:${s.resources.map(y=>`
|
|
5
5
|
- ${y}`).join("")}`:void 0,g=jr(s.resources);if(g){const y=or(g);n=Cw(n,y)}return[i,r,"",n,"",o,a,c,l,h,u,d,f,p].filter(y=>y!=null).join(`
|
|
@@ -223,4 +223,4 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+ie.from(ky(t)).toString(
|
|
|
223
223
|
outline: none;
|
|
224
224
|
appearance: none;
|
|
225
225
|
}
|
|
226
|
-
`,Vi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class UA extends df{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new ff({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async writeSolanaTransaction(){return Promise.resolve({hash:""})}async getAccounts({namespace:e}){var r,n,o;const t=this.provider,i=(((o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)||[]).filter((a,c,l)=>l.indexOf(a)===c);return Promise.resolve({accounts:i.map(a=>$e.createAccount({caipAddress:a,type:e==="bip122"?"payment":"eoa"}))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var o,a,c,l,h;if(!(e.caipNetwork&&Ee.BALANCE_SUPPORTED_CHAINS.includes((o=e.caipNetwork)==null?void 0:o.chainNamespace))||(a=e.caipNetwork)!=null&&a.testnet)return{balance:"0.00",symbol:((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""};const i=$.getAccountData();if(i!=null&&i.balanceLoading&&e.chainId===((l=$.state.activeCaipNetwork)==null?void 0:l.id))return{balance:(i==null?void 0:i.balance)||"0.00",symbol:(i==null?void 0:i.balanceSymbol)||""};const n=(await $.fetchTokenBalance()).find(u=>{var d,f;return u.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&u.symbol===((f=e.caipNetwork)==null?void 0:f.nativeCurrency.symbol)});return{balance:(n==null?void 0:n.quantity.numeric)||"0.00",symbol:(n==null?void 0:n.symbol)||((h=e.caipNetwork)==null?void 0:h.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=$.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===Q.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Bf.encode(new TextEncoder().encode(i)),pubkey:r}},(a=$.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(c=$.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}emitFirstAvailableConnection(){}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,n,o,a,c,l;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===Q.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:rc(t.id)}]}))}catch(h){if(h.code===Vi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===Vi.ERROR_INVALID_CHAIN_ID||h.code===Vi.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===Vi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=i.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:rc(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(c=t.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const BA=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],Dr={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return!!s.isEnabled&&e.includes("email")},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.email:!!s},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e.filter(t=>t!=="email"):!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.socials:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.socials:!1:s},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.swaps:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.swaps:!1:s},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.onramp:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.onramp:!1:s},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.activity:!!s},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.reownBranding:!!s},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>s.isEnabled&&(s.config??[]),processFallback:s=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>typeof s>"u"?Ee.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!s},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.headless}},DA={localSettingsOverridden:new Set,getApiConfig(s,e){return e==null?void 0:e.find(t=>t.id===s)},addWarning(s,e){if(s!==void 0){const t=Dr[e],i=t.isLegacy?`"features.${t.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(i)}},processFeature(s,e,t,i,r){const n=Dr[s],o=e[n.localFeatureName];if(r&&!n.isAvailableOnBasic)return!1;if(i){const a=this.getApiConfig(n.apiFeatureName,t);return(a==null?void 0:a.config)===null?this.processFallbackFeature(s,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,s),this.processApiFeature(s,a)):!1}return this.processFallbackFeature(s,o)},processApiFeature(s,e){return Dr[s].processApi(e)},processFallbackFeature(s,e){return Dr[s].processFallback(e)},async fetchRemoteFeatures(s){const e=s.basic??!1,t=s.features||{};this.localSettingsOverridden.clear();let i=null,r=!1;try{i=await _s.fetchProjectConfig(),r=i!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=r&&!e?Ee.DEFAULT_REMOTE_FEATURES:Ee.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of BA){const a=this.processFeature(o,t,i,r,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Ee.DEFAULT_REMOTE_FEATURES}if(r&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;je.open({debugMessage:Fe.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return n}};class LA{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(t,i)=>{var r,n,o;if(t){const a=(r=$.getCaipNetworks(t))==null?void 0:r.find(h=>h.id===i);if(a)return a;const c=(n=$.getNetworkData(t))==null?void 0:n.caipNetwork;return c||((o=$.getRequestedCaipNetworks(t).filter(h=>h.chainNamespace===t))==null?void 0:o[0])}return $.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const t=this.getCaipNetwork();if(t)return t.id},this.getCaipNetworks=t=>$.getCaipNetworks(t),this.getActiveChainNamespace=()=>$.state.activeChain,this.setRequestedCaipNetworks=(t,i)=>{$.setRequestedCaipNetworks(t,i)},this.getApprovedCaipNetworkIds=()=>$.getAllApprovedCaipNetworkIds(),this.getCaipAddress=t=>{var i,r;return $.state.activeChain===t||!t?$.state.activeCaipAddress:(r=(i=$.state.chains.get(t))==null?void 0:i.accountState)==null?void 0:r.caipAddress},this.setClientId=t=>{Wr.setClientId(t)},this.getProvider=t=>pe.getProvider(t),this.getProviderType=t=>pe.getProviderId(t),this.getPreferredAccountType=t=>Io(t),this.setCaipAddress=(t,i,r=!1)=>{$.setAccountProp("caipAddress",t,i,r),$.setAccountProp("address",$e.getPlainAddress(t),i,r)},this.setBalance=(t,i,r)=>{$.setAccountProp("balance",t,r),$.setAccountProp("balanceSymbol",i,r)},this.setProfileName=(t,i)=>{$.setAccountProp("profileName",t,i)},this.setProfileImage=(t,i)=>{$.setAccountProp("profileImage",t,i)},this.setUser=(t,i)=>{$.setAccountProp("user",t,i)},this.resetAccount=t=>{$.resetAccount(t)},this.setCaipNetwork=t=>{$.setActiveCaipNetwork(t)},this.setCaipNetworkOfNamespace=(t,i)=>{$.setChainNetworkData(i,{caipNetwork:t})},this.setStatus=(t,i)=>{$.setAccountProp("status",t,i),he.isConnected()?ae.setConnectionStatus("connected"):ae.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=t=>{var i;return(i=$.getAccountData(t))==null?void 0:i.address},this.setConnectors=t=>{const i=[...he.state.allConnectors,...t];he.setConnectors(i)},this.setConnections=(t,i)=>{ae.setConnections(t,i),we.setConnections(t,i)},this.fetchIdentity=t=>Wr.fetchIdentity(t),this.getReownName=t=>pf.getNamesForAddress(t),this.getConnectors=()=>he.getConnectors(),this.getConnectorImage=t=>gf.getConnectorImage(t),this.getConnections=t=>this.remoteFeatures.multiWallet?Xa.getConnectionsData(t).connections:(je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=t=>this.remoteFeatures.multiWallet?Xa.getConnectionsData(t).recentConnections:(je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async t=>{if(!this.remoteFeatures.multiWallet){je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await we.switchConnection(t)},this.deleteConnection=t=>{if(!this.remoteFeatures.multiWallet){je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}ae.deleteAddressFromConnection(t),we.syncStorageConnections()},this.setConnectedWalletInfo=(t,i)=>{const r=pe.getProviderId(i),n=t?{...t,type:r}:void 0;$.setAccountProp("connectedWalletInfo",n,i)},this.getIsConnectedState=()=>!!$.state.activeCaipAddress,this.addAddressLabel=(t,i,r)=>{var o;const n=((o=$.getAccountData(r))==null?void 0:o.addressLabels)||{};$.setAccountProp("addressLabels",{...n,[t]:i},r)},this.removeAddressLabel=(t,i)=>{var n;const r=((n=$.getAccountData(i))==null?void 0:n.addressLabels)||{};$.setAccountProp("addressLabels",{...r,[t]:void 0},i)},this.getAddress=t=>{var r;const i=t||$.state.activeChain;return(r=$.getAccountData(i))==null?void 0:r.address},this.resetNetwork=t=>{$.resetNetwork(t)},this.addConnector=t=>{he.addConnector(t)},this.resetWcConnection=()=>{we.resetWcConnection()},this.setAddressExplorerUrl=(t,i)=>{$.setAccountProp("addressExplorerUrl",t,i)},this.setSmartAccountDeployed=(t,i)=>{$.setAccountProp("smartAccountDeployed",t,i)},this.setPreferredAccountType=(t,i)=>{$.setAccountProp("preferredAccountType",t,i)},this.setEIP6963Enabled=t=>{K.setEIP6963Enabled(t)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,t){const i=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(i!=null&&i.length)return[...new Set(i)];const r=t==null?void 0:t.map(n=>n.chainNamespace);return[...new Set(r)]}async initialize(e){var t,i,r,n,o,a;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),(t=e.features)!=null&&t.headless&&!mf.hasInjectedConnectors()&&_s.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),K.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await DA.fetchRemoteFeatures(e)),await _s.fetchUsage(),K.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&So.setOnrampProviders(this.remoteFeatures.onramp),((i=K.state.remoteFeatures)!=null&&i.email||Array.isArray((r=K.state.remoteFeatures)==null?void 0:r.socials)&&((n=K.state.remoteFeatures)==null?void 0:n.socials.length)>0)&&await this.checkAllowedOrigins(),(o=K.state.features)!=null&&o.reownAuthentication||(a=K.state.remoteFeatures)!=null&&a.reownAuthentication){const{ReownAuthentication:c}=await Je(async()=>{const{ReownAuthentication:h}=await import("./features-C5Jgw5I-.js");return{ReownAuthentication:h}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),l=K.state.siwx;l instanceof c||(l&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),K.setSIWX(new c))}}async openSend(e){var n;const t=e.namespace||$.state.activeChain,i=this.getCaipAddress(t),r=(n=this.getCaipNetwork(t))==null?void 0:n.id;if(!i)throw new Error("openSend: caipAddress not found");if((r==null?void 0:r.toString())!==e.chainId.toString()){const o=$.getCaipNetworkById(e.chainId,t);if(!o)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(o,{throwOnFailure:!0})}try{const o=Gd.getTokenSymbolByAddress(e.assetAddress);o&&await _s.fetchTokenImages([o])}catch{}return await us.open({view:"WalletSend",data:{send:e}}),new Promise((o,a)=>{const c=Qa.subscribeKey("hash",u=>{u&&(h(),o({hash:u}))}),l=us.subscribe(u=>{u.open||(h(),a(new Error("Modal closed")))}),h=this.createCleanupHandler([c,l])})}toModalOptions(){function e(i){return(i==null?void 0:i.view)==="Swap"}function t(i){return(i==null?void 0:i.view)==="WalletSend"}return{isSwap:e,isSend:t}}async checkAllowedOrigins(){try{const e=await _s.fetchAllowedOrigins();if(!$e.isClient())return;const t=window.location.origin;On.isOriginAllowed(t,e,Q.DEFAULT_ALLOWED_ANCESTORS)||je.open(Fe.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":je.open(Fe.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;je.open({displayMessage:Fe.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Fe.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(t=>{try{t()}catch{}})}}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,delete t.universalProvider,Mt.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){yf.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&Bt.setThemeMode(e.themeMode),e.themeVariables&&Bt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");$.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const t=this.getDefaultNetwork();t&&$.setActiveCaipNetwork(t)}initializeConnectionController(e){we.initialize(e.adapters??[]),we.setWcBasic(e.basic??!1)}initializeConnectorController(){he.initialize(this.chainNamespaces)}initializeProjectSettings(e){K.setProjectId(e.projectId),K.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var r;K.setDebug(e.debug!==!1),K.setEnableWalletGuide(e.enableWalletGuide!==!1),K.setEnableWallets(e.enableWallets!==!1),K.setEIP6963Enabled(e.enableEIP6963!==!1),K.setEnableCoinbase(e.enableCoinbase!==!1),K.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),K.setEnableReconnect(e.enableReconnect!==!1),K.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),K.setCoinbasePreference(e.coinbasePreference),K.setEnableAuthLogger(e.enableAuthLogger!==!1),K.setCustomRpcUrls(e.customRpcUrls),K.setEnableEmbedded(e.enableEmbedded),K.setAllWallets(e.allWallets),K.setIncludeWalletIds(e.includeWalletIds),K.setExcludeWalletIds(e.excludeWalletIds),K.setFeaturedWalletIds(e.featuredWalletIds),K.setTokens(e.tokens),K.setTermsConditionsUrl(e.termsConditionsUrl),K.setPrivacyPolicyUrl(e.privacyPolicyUrl),K.setCustomWallets(e.customWallets),K.setFeatures(e.features),K.setAllowUnsupportedChain(e.allowUnsupportedChain),K.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),K.setPreferUniversalLinks(e.experimental_preferUniversalLinks),K.setDefaultAccountTypes(e.defaultAccountTypes);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),K.setMetadata(e.metadata),K.setDisableAppend(e.disableAppend),K.setEnableEmbedded(e.enableEmbedded),K.setSIWX(e.siwx),this.features=K.state.features??{},!e.projectId){je.open(Fe.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===Q.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");K.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return $e.isClient()?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=Ni.getUnsupportedNetwork(`${t}:${e}`);$.setActiveCaipNetwork(i)}}getDefaultNetwork(){return Ni.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return Ni.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return Ni.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?Ni.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){var i,r;try{this.setLoading(!0,e);let n={connections:[]};const o=this.getAdapter(e);return(((r=(i=$.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.caipAddress)||!K.state.enableReconnect)&&(o!=null&&o.disconnect)&&(n=await o.disconnect({id:t})),this.setLoading(!1,e),n}catch(n){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${n.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var l;const e=$.state.activeChain,t=this.getAdapter(e),i=(l=this.getCaipNetwork(e))==null?void 0:l.id,r=we.getConnections(e),n=this.remoteFeatures.multiWallet,o=r.length>0;if(!t)throw new Error("Adapter not found");const a=await t.connectWalletConnect(i);(!o||!n)&&this.close(),this.setClientId((a==null?void 0:a.clientId)||null),ae.setConnectedNamespaces([...$.state.chains.keys()]),await this.syncWalletConnectAccount(),await Lr.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=$.state.activeChain,o=this.getAdapter(n);if(!n)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),ae.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{var l;const{id:t,chainNamespace:i,initialDisconnect:r}=e||{},n=i||$.state.activeChain,o=he.getConnectorId(n),a=t===Q.CONNECTOR_ID.AUTH||o===Q.CONNECTOR_ID.AUTH,c=t===Q.CONNECTOR_ID.WALLET_CONNECT||o===Q.CONNECTOR_ID.WALLET_CONNECT;try{const h=Array.from($.state.chains.keys());let u=i?[i]:h;(c||a)&&(u=h);const d=u.map(async g=>{const y=he.getConnectorId(g),A=t||y,R=await this.disconnectConnector(g,A);R&&(a&&ae.deleteConnectedSocialProvider(),R.connections.forEach(x=>{ae.addDisconnectedConnectorId(x.connectorId,g)})),r&&this.onDisconnectNamespace({chainNamespace:g,closeModal:!1})}),f=await Promise.allSettled(d);Qa.resetSend(),we.resetWcConnection(),(l=Lr.getSIWX())!=null&&l.signOutOnDisconnect&&await Lr.clearSessions(),he.setFilterByNamespace(void 0),we.syncStorageConnections();const p=f.filter(g=>g.status==="rejected");if(p.length>0)throw new Error(p.map(g=>g.reason.message).join(", "));Mt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:i||"all"}})}catch(h){throw new Error(`Failed to disconnect chains: ${h.message}`)}},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=$.state.activeChain,i=this.getAdapter($.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!i)throw new Error("signMessage: adapter not found");const r=this.getAddress(t);if(!r)throw new Error("signMessage: address not found");const n=await(i==null?void 0:i.signMessage({message:e,address:r,provider:pe.getProvider(t)}));return(n==null?void 0:n.signature)||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(Ee.SEND_SUPPORTED_NAMESPACES.includes(t)){const i=this.getAdapter(t);if(!i)throw new Error("sendTransaction: adapter not found");const r=pe.getProvider(t),n=await(i==null?void 0:i.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===Q.CHAIN.EVM){const i=this.getAdapter(t);if(!i)throw new Error("estimateGas: adapter is required but got undefined");const r=pe.getProvider(t),n=this.getCaipNetwork();if(!n)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(i==null?void 0:i.estimateGas({...e,provider:r,caipNetwork:n}));return(o==null?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var r;const e=$.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const t=this.getAddress(e);if(!t)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:t,chainId:Number((r=this.getCaipNetwork())==null?void 0:r.id),chainNamespace:e});const i=$.getAccountData();return(i==null?void 0:i.profileImage)||!1},getEnsAddress:async e=>await On.resolveReownName(e),writeContract:async e=>{const t=$.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeContract({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},writeSolanaTransaction:async e=>{const t=$.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeSolanaTransaction({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},parseUnits:(e,t)=>{const i=this.getAdapter($.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter($.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("walletGetAssets: adapter is required but got undefined");return await(t==null?void 0:t.walletGetAssets(e))??{}},updateBalance:e=>{const t=this.getAddress(e),i=this.getCaipNetwork(e);!i||!t||this.updateNativeBalance(t,i==null?void 0:i.id,e)}},we.setClient(this.connectionControllerClient)}async onConnectExternal(e){var l,h,u,d,f,p,g,y;const t=$.state.activeChain,i=e.chain||t,r=this.getAdapter(i);let n=!0;if(e.type===et.CONNECTOR_TYPE_AUTH&&Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(x=>he.getConnectorId(x)===Q.CONNECTOR_ID.AUTH)&&e.chain!==t&&(n=!1),e.chain&&e.chain!==t&&!e.caipNetwork){const A=this.getCaipNetworks().find(R=>R.chainNamespace===e.chain);A&&n&&this.setCaipNetwork(A)}if(!i)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(i),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:((l=e.caipNetwork)==null?void 0:l.id)||(o==null?void 0:o.id),rpcUrl:((f=(d=(u=(h=e.caipNetwork)==null?void 0:h.rpcUrls)==null?void 0:u.default)==null?void 0:d.http)==null?void 0:f[0])||((y=(g=(p=o==null?void 0:o.rpcUrls)==null?void 0:p.default)==null?void 0:g.http)==null?void 0:y[0])});if(c)return ae.addConnectedNamespace(i),this.syncProvider({...c,chainNamespace:i}),this.setStatus("connected",i),this.syncConnectedWalletInfo(i),ae.removeDisconnectedConnectorId(e.id,i),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,t){var a;const i=e.type===et.CONNECTOR_TYPE_AUTH,r=Gr.getOtherAuthNamespaces((a=t==null?void 0:t.connectedCaipNetwork)==null?void 0:a.chainNamespace),n=$.state.activeCaipNetwork,o=this.getAdapter(n==null?void 0:n.chainNamespace);i&&(await Promise.all(r.map(async c=>{var l,h,u;try{const d=pe.getProvider(c),f=this.getCaipNetwork(c),p=this.getAdapter(c);await(p==null?void 0:p.connect({...e,provider:d,socialUri:void 0,chainId:f==null?void 0:f.id,rpcUrl:(u=(h=(l=f==null?void 0:f.rpcUrls)==null?void 0:l.default)==null?void 0:h.http)==null?void 0:u[0]}))&&(ae.addConnectedNamespace(c),ae.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(d){je.warn(Fe.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Fe.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,d instanceof Error?d.message:void 0),Fe.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),n&&await(o==null?void 0:o.switchNetwork({caipNetwork:n})))}getApprovedCaipNetworksData(){var t,i,r,n,o;if(pe.getProviderId($.state.activeChain)===et.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=pe.getProviderId(t);if(e.chainNamespace===$.state.activeChain){const n=this.getAdapter(t);await(n==null?void 0:n.switchNetwork({caipNetwork:e}))}else if(this.setCaipNetwork(e),r===et.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Ls.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n,o;const r=e==null?void 0:e.find(a=>a.namespace===i);return r?(r.construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:(o=this.caipNetworks)==null?void 0:o.filter(({chainNamespace:a})=>a===i)}),t[i]=r):t[i]=new UA({namespace:i,networks:this.getCaipNetworks()}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const t=this.getAdapter(e);if(!t)throw new Error("adapter not found");await t.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=ae.getConnectionStatus();K.state.enableReconnect===!1?this.setStatus("disconnected",e):i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(ae.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var l,h;const o=this.getCaipNetworks().find(u=>u.id.toString()===n.toString()||u.caipNetworkId.toString()===n.toString()),a=$.state.activeChain===e,c=(h=(l=$.state.chains.get(e))==null?void 0:l.accountState)==null?void 0:h.address;if(o){const u=a&&r?r:c;u&&this.syncAccount({address:u,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,n=Array.from(we.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||n.length===0})}),t.on("connections",r=>{this.setConnections(r,e)}),t.on("pendingTransactions",()=>{const r=this.getAddress(e),n=$.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n,connector:o})=>{var h,u;this.handlePreviousConnectorConnection(o);const a=$.state.activeChain===e;o!=null&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o==null?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=(u=(h=$.getNetworkData(e))==null?void 0:h.caipNetwork)==null?void 0:u.id,l=n||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,n,e),ae.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var c;const t=e==null?void 0:e.chain,i=e==null?void 0:e.id,r=he.getConnectorId(t),n=(c=K.state.remoteFeatures)==null?void 0:c.multiWallet,a=t&&i&&r&&r!==i&&!n;try{a&&await we.disconnect({id:r,namespace:t})}catch(l){console.warn("Error disconnecting previous connector",l)}}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&await((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null?void 0:r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>we.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||ae.deleteRecentWallet();const t=ae.getRecentWallet();Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:$e.isMobile()?"mobile":"qrcode",name:(t==null?void 0:t.name)||"Unknown",reconnect:!0,view:Ms.state.view,walletRank:t==null?void 0:t.order}})}async syncNamespaceConnection(e){try{e===Q.CHAIN.EVM&&$e.isSafeApp()&&he.setConnectorId(Q.CONNECTOR_ID.SAFE,e);const t=he.getConnectorId(e);switch(this.setStatus("connecting",e),t){case Q.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case Q.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:i}=e||{};$.resetAccount(t),$.resetNetwork(t),ae.removeConnectedNamespace(t);const r=Array.from($.state.chains.keys());(t?[t]:r).forEach(o=>ae.addDisconnectedConnectorId(he.getConnectorId(o)||"",o)),he.removeConnectorId(t),pe.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),i!==!1&&us.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),i=this.getCaipAddress(e),r=this.getCaipNetwork(e);return t==null?void 0:t.syncConnections({connectToFirstConnector:!i,caipNetwork:r})}))}async syncAdapterConnection(e){var a,c,l,h,u;const t=this.getAdapter(e),i=this.getCaipNetwork(e),r=he.getConnectorId(e),o=he.getConnectors(e).find(d=>d.id===r);try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const d=await(t==null?void 0:t.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));d?(this.syncProvider({...d,chainNamespace:e}),await this.syncAccount({...d,chainNamespace:e}),this.setStatus("connected",e),Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:d.address,properties:{method:"browser",name:((h=o.info)==null?void 0:h.name)||o.name||"Unknown",reconnect:!0,view:Ms.state.view,walletRank:(u=o==null?void 0:o.explorerWallet)==null?void 0:u.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var i,r;const e=Object.keys(((r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)||{}),t=this.chainNamespaces.map(async n=>{var u,d,f,p,g;const o=this.getAdapter(n);if(!o)return;const a=((p=(f=(d=(u=this.universalProvider)==null?void 0:u.session)==null?void 0:d.namespaces)==null?void 0:f[n])==null?void 0:p.accounts)||[],c=(g=$.state.activeCaipNetwork)==null?void 0:g.id,l=a.find(y=>{const{chainId:A}=Ls.parseCaipAddress(y);return A===(c==null?void 0:c.toString())})||a[0];if(l){const y=Ls.validateCaipAddress(l),{chainId:A,address:R}=Ls.parseCaipAddress(y);if(pe.setProviderId(n,et.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&$.state.activeCaipNetwork&&o.namespace!==Q.CHAIN.EVM){const x=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:$.state.activeCaipNetwork});pe.setProvider(n,x)}else pe.setProvider(n,this.universalProvider);he.setConnectorId(Q.CONNECTOR_ID.WALLET_CONNECT,n),ae.addConnectedNamespace(n),await this.syncAccount({address:R,chainId:A,chainNamespace:n})}else e.includes(n)&&this.setStatus("disconnected",n);const h=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(n),$.setApprovedCaipNetworksData(n,{approvedCaipNetworkIds:h.approvedCaipNetworkIds,supportsAllNetworks:h.supportsAllNetworks})});await Promise.all(t)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){pe.setProviderId(r,e),pe.setProvider(r,t),he.setConnectorId(i,r)}async syncAccount(e){var u,d;const t=e.chainNamespace===$.state.activeChain,i=$.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=ae.getActiveNetworkProps(),c=(i==null?void 0:i.id)||a,l=((u=$.state.activeCaipNetwork)==null?void 0:u.name)===Q.UNSUPPORTED_NETWORK_NAME,h=$.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let f=this.getCaipNetworks().find(A=>A.id.toString()===c.toString()),p=this.getCaipNetworks().find(A=>A.chainNamespace===o);if(!h&&!f&&!p){const A=this.getApprovedCaipNetworkIds()||[],R=A.find(E=>{var O;return((O=Ls.parseCaipNetworkId(E))==null?void 0:O.chainId)===c.toString()}),x=A.find(E=>{var O;return((O=Ls.parseCaipNetworkId(E))==null?void 0:O.chainNamespace)===o});f=this.getCaipNetworks().find(E=>E.caipNetworkId===R),p=this.getCaipNetworks().find(E=>E.caipNetworkId===x||"deprecatedCaipNetworkId"in E&&E.deprecatedCaipNetworkId===x)}const g=f||p;(g==null?void 0:g.chainNamespace)===$.state.activeChain?K.state.enableNetworkSwitch&&!K.state.allowUnsupportedChain&&((d=$.state.activeCaipNetwork)==null?void 0:d.name)===Q.UNSUPPORTED_NETWORK_NAME?$.showUnsupportedChainUI():this.setCaipNetwork(g):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o);const y=this.getAddress(o);Gr.isLowerCaseMatch(r,y)||this.syncAccountInfo(r,g==null?void 0:g.id,o),t?await this.syncBalance({address:r,chainId:g==null?void 0:g.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:n,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i,!0),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=he.getConnectorId(e),i=pe.getProviderId(e);if(i===et.CONNECTOR_TYPE_ANNOUNCED||i===et.CONNECTOR_TYPE_INJECTED){if(t){const o=this.getConnectors().find(a=>{var u,d;const c=a.id===t,l=((u=a.info)==null?void 0:u.rdns)===t,h=(d=a.connectors)==null?void 0:d.some(f=>{var p;return f.id===t||((p=f.info)==null?void 0:p.rdns)===t});return c||l||!!h});if(o){const{info:a,name:c,imageUrl:l}=o,h=l||this.getConnectorImage(o);this.setConnectedWalletInfo({name:c,icon:h,...a},e)}}}else if(i===et.CONNECTOR_TYPE_WALLET_CONNECT){const n=pe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t&&(t===Q.CONNECTOR_ID.COINBASE_SDK||t===Q.CONNECTOR_ID.COINBASE)){const n=this.getConnectors().find(l=>l.id===t),o=(n==null?void 0:n.name)||"Coinbase Wallet",a=(n==null?void 0:n.imageUrl)||this.getConnectorImage(n),c=n==null?void 0:n.info;this.setConnectedWalletInfo({...c,name:o,icon:a},e)}}async syncBalance(e){!Ff.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,i){const r=this.getAdapter(i),n=$.getCaipNetworkByNamespace(i,t);if(r){const o=await r.getBalance({address:e,chainId:t,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,i),o}}async initializeUniversalAdapter(){var r,n,o,a,c,l,h,u,d,f;const e=oA.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),t={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(n=this.options)!=null&&n.metadata?(o=this.options)==null?void 0:o.metadata.name:"",description:(a=this.options)!=null&&a.metadata?(c=this.options)==null?void 0:c.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(h=this.options)==null?void 0:h.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};K.setManualWCControl(!!((f=this.options)!=null&&f.manualWCControl)),this.universalProvider=this.options.universalProvider??await j2.init(t);const i=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await i()}catch(p){if(p instanceof Error&&p.message.includes("Missing or invalid. Record was recently deleted"))return;throw p}},K.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{On.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:t=>{we.setUri(t)},onConnect:t=>{const{address:i}=$e.getAccount(t[0]);for(const r of this.chainNamespaces)ae.removeDisconnectedConnectorId(Q.CONNECTOR_ID.WALLET_CONNECT,r);we.finalizeWcConnection(i)},onDisconnect:()=>{$.state.noAdapters&&this.resetAccount(e),we.resetWcConnection()},onChainChanged:t=>{const i=$.state.activeChain,r=i&&he.state.activeConnectorIds[i]===Q.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&($.state.noAdapters||r)){const n=this.getCaipNetworks().find(a=>a.id.toString()===t.toString()||a.caipNetworkId.toString()===t.toString()),o=this.getCaipNetwork();if(!n){this.setUnsupportedNetwork(t);return}(o==null?void 0:o.id.toString())!==(n==null?void 0:n.id.toString())&&(o==null?void 0:o.chainNamespace)===(n==null?void 0:n.chainNamespace)&&this.setCaipNetwork(n)}},onAccountsChanged:t=>{const i=$.state.activeChain,r=i&&he.state.activeConnectorIds[i]===Q.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&($.state.noAdapters||r)){const n=t==null?void 0:t[0];n&&this.syncAccount({address:n.address,chainId:n.chainId,chainNamespace:n.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&$e.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Mt.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}getDisabledCaipNetworks(){const e=$.getAllApprovedCaipNetworkIds(),t=$.getAllRequestedCaipNetworks();return $e.sortRequestedNetworks(e,t).filter(r=>$.isCaipNetworkDisabled(r))}handleAlertError(e){const t=Object.entries(Fe.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Fe.ALERT_ERRORS[o];a&&(je.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r,n;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:(n=this.caipNetworks)==null?void 0:n.filter(({chainNamespace:o})=>o===t)}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&we.setUri(e.uri);const{isSwap:t,isSend:i}=this.toModalOptions();return t(e)?us.open({...e,data:{swap:e.arguments}}):i(e)&&e.arguments?this.openSend(e.arguments):us.open(e)}async close(){await this.injectModalUi(),us.close()}setLoading(e,t){us.setLoading(e,t)}async disconnect(e){await we.disconnect({namespace:e})}getSIWX(){return K.state.siwx}getError(){return""}getChainId(){var e;return(e=$.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e,{throwOnFailure:t=!1}={}){const i=this.getCaipNetworks().find(r=>r.id===e.id);if(!i){je.open(Fe.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await $.switchActiveNetwork(i,{throwOnFailure:t})}getWalletProvider(){return $.state.activeChain?pe.state.providers[$.state.activeChain]:null}getWalletProviderType(){return pe.getProviderId($.state.activeChain)}subscribeProviders(e){return pe.subscribeProviders(e)}getThemeMode(){return Bt.state.themeMode}getThemeVariables(){return Bt.state.themeVariables}setThemeMode(e){Bt.setThemeMode(e),fa(Bt.state.themeMode)}setTermsConditionsUrl(e){K.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){K.setPrivacyPolicyUrl(e)}setThemeVariables(e){Bt.setThemeVariables(e),kA(Bt.state.themeVariables)}subscribeTheme(e){return Bt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?we.subscribe(e):(je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var i,r;if(e)return(r=(i=$.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.connectedWalletInfo;const t=$.getAccountData();return t==null?void 0:t.connectedWalletInfo}getAccount(e){const t=e||$.state.activeChain,i=he.getAuthConnector(t),r=$.getAccountData(t),n=ae.getConnectedConnectorId($.state.activeChain),o=we.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>{const{caipNetwork:l}=c;return l?c.accounts.map(({address:h,type:u,publicKey:d})=>$e.createAccount({caipAddress:`${l.caipNetworkId}:${h}`,type:u||"eoa",publicKey:d})):[]});if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:$e.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:i&&n===Q.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:ae.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:Io(t),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=[],r=()=>{const o=this.getAccount(t);o&&e(o)};if(t){const o=$.subscribeChainProp("accountState",r,t);i.push(o)}else{const o=$.subscribe(r);i.push(o)}const n=he.subscribe(r);return i.push(n),()=>{i.forEach(o=>o())}}subscribeNetwork(e){return $.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId})})}subscribeWalletInfo(e,t){return t?$.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo),t):$.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){return $.subscribeChainProp("accountState",t=>e(t==null?void 0:t.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){return $.subscribeKey("activeCaipNetwork",e)}getState(){return Yr.state}getRemoteFeatures(){return K.state.remoteFeatures}subscribeState(e){return Yr.subscribe(e)}subscribeRemoteFeatures(e){return K.subscribeKey("remoteFeatures",e)}showErrorMessage(e){ec.showError(e)}showSuccessMessage(e){ec.showSuccess(e)}getEvent(){return{...Mt.state}}subscribeEvents(e){return Mt.subscribe(e)}replace(e){Ms.replace(e)}redirect(e){Ms.push(e)}popTransactionStack(e){Ms.popTransactionStack(e)}isOpen(){return us.state.open}isTransactionStackEmpty(){return Ms.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){K.setFeatures(e)}updateRemoteFeatures(e){K.setRemoteFeatures(e)}updateOptions(e){const i={...K.state||{},...e};K.setOptions(i)}setConnectMethodsOrder(e){K.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){K.setWalletFeaturesOrder(e)}setCollapseWallets(e){K.setCollapseWallets(e)}setSocialsOrder(e){K.setSocialsOrder(e)}getConnectMethodsOrder(){return wf.getConnectOrderMethod(K.state.features,he.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(r=>r.id===i.id)||$.addNetwork(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===t)&&$.removeNetwork(e,t)}}let _h=!1;class sf extends LA{async onAuthProviderConnected(e){const t=Gr.userChainIdToChainNamespace(e==null?void 0:e.chainId);if(e.message&&e.signature&&e.siwxMessage&&await Lr.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!t)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const i=t===Q.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=K.state.defaultAccountTypes[t],n=Io(t),o=e.preferredAccountType||n||r;this.setCaipAddress(i,t);const{signature:a,siwxMessage:c,message:l,...h}=e,u=$.getAccountData(t);this.setUser({...(u==null?void 0:u.user)||{},...h},t),this.setSmartAccountDeployed(!!e.smartAccountDeployed,t),this.setPreferredAccountType(o,t),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:t})]),this.setLoading(!1,t)}setupAuthConnectorListeners(e){e.onRpcRequest(t=>{Nn.checkIfRequestExists(t)?Nn.checkIfRequestIsSafe(t)||this.handleUnsafeRPCRequest():(this.open(),console.error(tc.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:t.method}),setTimeout(()=>{this.showErrorMessage(tc.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((t,i)=>{const r=Nn.checkIfRequestIsSafe(i),n=this.getAddress(),o=$.state.activeCaipNetwork;r||(n&&(o!=null&&o.id)&&this.updateNativeBalance(n,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const t=$.state.activeChain;if(!t)throw new Error("AppKit:onNotConnected - namespace is required");he.getConnectorId(t)===Q.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,t),this.setLoading(!1,t))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:t,type:i})=>{const r=$.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");t&&this.setPreferredAccountType(i,r)})}async syncAuthConnectorTheme(e){if(!e)return;const t=Bt.getSnapshot();await e.syncTheme({themeMode:t.themeMode,themeVariables:t.themeVariables,w3mThemeVariables:bf(t.themeVariables,t.themeMode)})}async syncAuthConnector(e,t){var h,u,d,f,p,g,y,A,R;const i=Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t),r=t===$.state.activeChain;if(!i)return;this.setLoading(!0,t);const n=e.getLoginEmailUsed();this.setLoading(n,t),n&&this.setStatus("connecting",t);const o=e.getEmail(),a=e.getUsername(),c=((h=$.getAccountData(t))==null?void 0:h.user)||{};this.setUser({...c,username:a,email:o},t),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(t&&i&&r)if(l&&((u=this.connectionControllerClient)!=null&&u.connectExternal)){await e.init(),await this.syncAuthConnectorTheme(e),await((p=this.connectionControllerClient)==null?void 0:p.connectExternal({id:Q.CONNECTOR_ID.AUTH,info:{name:Q.CONNECTOR_ID.AUTH},type:et.CONNECTOR_TYPE_AUTH,provider:e,chainId:(f=(d=$.getNetworkData(t))==null?void 0:d.caipNetwork)==null?void 0:f.id,chain:t})),this.setStatus("connected",t);const x=ae.getConnectedSocialProvider();x?Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:x,reconnect:!0}}):Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:((R=(A=(y=(g=this.universalProvider)==null?void 0:g.session)==null?void 0:y.peer)==null?void 0:A.metadata)==null?void 0:R.name)||"Unknown",reconnect:!0,view:Ms.state.view,walletRank:void 0}})}else he.getConnectorId(t)===Q.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",t),ae.removeConnectedNamespace(t));this.setLoading(!1,t)}async checkExistingTelegramSocialConnection(e){var t;try{if(!$e.isTelegram())return;const i=ae.getTelegramSocialProvider();if(!i||!$e.isClient())return;const n=new URL(window.location.href).searchParams.get("result_uri");if(!n)return;i&&$.setAccountProp("socialProvider",i,e),await((t=this.authProvider)==null?void 0:t.init());const o=he.getAuthConnector();i&&o&&(this.setLoading(!0,e),await we.connectExternal({id:o.id,type:o.type,socialUri:n},o.chain),ae.setConnectedSocialProvider(i),ae.removeTelegramSocialProvider(),Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:i}}))}catch(i){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",i)}try{const i=new URL(window.location.href);i.searchParams.delete("result_uri"),window.history.replaceState({},document.title,i.toString())}catch(i){console.error("tma social login failed",i)}}createAuthProvider(e){var l,h,u,d;if(!Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const i=(l=this.remoteFeatures)==null?void 0:l.email,r=Array.isArray((h=this.remoteFeatures)==null?void 0:h.socials)&&this.remoteFeatures.socials.length>0,n=i||r,a=Gr.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&((u=this.options)!=null&&u.projectId)&&n&&(this.authProvider=vf.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:(d=this.getCaipNetwork(a))==null?void 0:d.caipNetworkId,abortController:Fe.EmbeddedWalletAbortController,onTimeout:f=>{f==="iframe_load_failed"?je.open(Fe.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):f==="iframe_request_timeout"?je.open(Fe.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):f==="unverified_domain"&&je.open(Fe.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:f=>Ef(f),getCaipNetworks:f=>$.getCaipNetworks(f)}),Yr.subscribeOpen(f=>{var p;!f&&this.isTransactionStackEmpty()&&((p=this.authProvider)==null||p.rejectRpcRequests())}));const c=e===$.state.activeChain&&K.state.enableReconnect;K.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){var t,i,r;this.createAuthProvider(e),this.authProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setAuthProvider)==null||r.call(i,this.authProvider))}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&_s.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){var o,a,c;if(!e)return;const t=$.state.activeChain,i=e.chainNamespace,r=this.getAddressByChainNamespace(i);if(i===t&&((o=$.getAccountData(i))!=null&&o.caipAddress)){const l=this.getAdapter(i);await(l==null?void 0:l.switchNetwork({caipNetwork:e})),this.setCaipNetwork(e)}else{const h=pe.getProviderId(t)===et.CONNECTOR_TYPE_AUTH,u=pe.getProviderId(i),d=u===et.CONNECTOR_TYPE_AUTH,f=Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(i);if(!i)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((h&&u===void 0||d)&&f)try{if($.state.activeChain=e.chainNamespace,r){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}else await((c=(a=this.connectionControllerClient)==null?void 0:a.connectExternal)==null?void 0:c.call(a,{id:Q.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:i,chainId:e.id,type:et.CONNECTOR_TYPE_AUTH,caipNetwork:e}));this.setCaipNetwork(e)}catch{const g=this.getAdapter(i);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}else if(u===et.CONNECTOR_TYPE_WALLET_CONNECT){if(!$.state.noAdapters){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}this.setCaipNetwork(e),this.syncWalletConnectAccount()}else this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:i})}}async initialize(e){var t;await super.initialize(e),(t=this.chainNamespaces)==null||t.forEach(i=>{this.createAuthProviderForAdapter(i)}),await this.injectModalUi(),Yr.set({initialized:!0})}async syncIdentity({address:e,chainId:t,chainNamespace:i}){var a;if(i!==Q.CHAIN.EVM)return;const r=`${i}:${t}`,n=(a=this.caipNetworks)==null?void 0:a.find(c=>c.caipNetworkId===r);if(n!=null&&n.testnet){this.setProfileName(null,i),this.setProfileImage(null,i);return}const o=he.getConnectorId(i)===Q.CONNECTOR_ID.AUTH;try{const{name:c,avatar:l}=await this.fetchIdentity({address:e});!c&&o?await this.syncReownName(e,i):(this.setProfileName(c,i),this.setProfileImage(l,i))}catch{t!==1&&this.setProfileImage(null,i)}}syncConnectedWalletInfo(e){const t=pe.getProviderId(e);if(t===et.CONNECTOR_TYPE_AUTH){const i=this.authProvider;if(i){const r=ae.getConnectedSocialProvider()??"email",n=i.getEmail()??i.getUsername();this.setConnectedWalletInfo({name:t,identifier:n,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(!$e.isClient())return;const e={...Ee.DEFAULT_FEATURES,...this.options.features};if(!e.headless&&!_h)try{const t=this.remoteFeatures;if(await this.loadModalComponents(e,t),$e.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!K.state.disableAppend&&!K.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}_h=!0}catch(t){console.error("Error injecting modal UI:",t)}}async loadModalComponents(e,t){if(!$e.isClient())return;const i=[];(t.email||t.socials&&t.socials.length>0)&&i.push(Je(()=>import("./embedded-wallet-CLpjPJB3.js"),__vite__mapDeps([10,11,4,1,2,3,5,6,7,8,9,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]))),t.email&&i.push(Je(()=>import("./email-1UrgYZj-.js"),__vite__mapDeps([28,11,4,29,22,15,1,2,3,5,6,7,8,9,21,13,14,20,30,18,24,25,26,27]))),t.socials&&i.push(Je(()=>import("./socials-BwTV76GY.js"),__vite__mapDeps([31,11,4,13,32,14,1,2,3,5,6,7,8,9,33,21,17,20,15,34,12,35,36,24,25,26,27]))),t.swaps&&t.swaps.length>0&&i.push(Je(()=>import("./swaps-BlfTMX7q.js"),__vite__mapDeps([37,11,4,20,15,21,13,38,1,2,3,5,6,7,8,9,39,36,40,12,41,18,14,24,25,26,27]))),e.send&&i.push(Je(()=>import("./send-DQ_s7hBA.js"),__vite__mapDeps([42,11,4,20,15,21,13,43,14,1,2,3,5,6,7,8,9,44,22,40,12,36,39,18,45,46,24,25,26,27]))),e.receive&&i.push(Je(()=>import("./receive-BhwBfPBx.js"),__vite__mapDeps([47,11,4,13,12,34,35,1,2,3,5,6,7,8,9,24,25,26,27]))),t.onramp&&t.onramp.length>0&&i.push(Je(()=>import("./onramp-B4pEvCie.js"),__vite__mapDeps([48,11,4,13,49,15,32,14,1,2,3,5,6,7,8,9,12,50,51,22,20,21,18,24,25,26,27]))),t.payWithExchange&&i.push(Je(()=>import("./pay-with-exchange-DWzTSiHz.js"),__vite__mapDeps([52,11,4,13,12,19,49,15,36,20,44,14,22,1,2,3,5,6,7,8,9,53,21,18,45,43,24,25,26,27]))),t.activity&&i.push(Je(()=>import("./transactions-CacIfnoG.js"),__vite__mapDeps([54,11,4,55,21,13,22,12,36,1,2,3,5,6,7,8,9,24,25,26,27]))),(e.pay||t.payments)&&i.push(Je(()=>import("./index-B61juR-E.js"),__vite__mapDeps([56,57,11,4,13,20,15,19,12,49,58,21,43,1,2,3,5,6,7,8,9,36,41,24,25,26,27]))),t.emailCapture&&i.push(Je(()=>import("./data-capture-Dh-nweo4.js"),__vite__mapDeps([59,11,4,29,22,15,1,2,3,5,6,7,8,9,0,24,25,26,27]))),await Promise.all([...i,Je(()=>import("./index-ChZiIgQr.js"),__vite__mapDeps([60,11,4,13,12,15,46,1,2,3,5,6,7,8,9,21,61,51,22,16,17,58,19,49,20,53,55,36,45,38,41,43,14,18,30,32,33,34,35,23,50,24,25,26,27])),Je(()=>import("./w3m-modal-DD7YQQ5K.js"),__vite__mapDeps([62,11,4,13,1,2,3,5,6,7,8,9,57,20,15,19,12,49,58,21,43,36,41,16,17,38,61,51,22,39,24,25,26,27]))])}}const MA="1.8.19";function qA(s){return new sf({...s,sdkVersion:$e.generateSdkVersion(s.adapters??[],"html",MA)})}const US=Object.freeze(Object.defineProperty({__proto__:null,AppKit:sf,CoreHelperUtil:$e,WcConstantsUtil:Vi,createAppKit:qA},Symbol.toStringTag,{value:"Module"}));export{Ne as A,Si as E,So as O,xS as a,IS as b,_S as c,NS as d,kS as e,SS as f,AS as g,$S as h,Vr as i,As as j,TS as k,Zd as l,US as m,RS as r,ua as u,RA as v,OS as w};
|
|
226
|
+
`,Vi={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};class UA extends df{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new ff({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async writeSolanaTransaction(){return Promise.resolve({hash:""})}async getAccounts({namespace:e}){var r,n,o;const t=this.provider,i=(((o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)||[]).filter((a,c,l)=>l.indexOf(a)===c);return Promise.resolve({accounts:i.map(a=>$e.createAccount({caipAddress:a,type:e==="bip122"?"payment":"eoa"}))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var o,a,c,l,h;if(!(e.caipNetwork&&Ee.BALANCE_SUPPORTED_CHAINS.includes((o=e.caipNetwork)==null?void 0:o.chainNamespace))||(a=e.caipNetwork)!=null&&a.testnet)return{balance:"0.00",symbol:((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""};const i=$.getAccountData();if(i!=null&&i.balanceLoading&&e.chainId===((l=$.state.activeCaipNetwork)==null?void 0:l.id))return{balance:(i==null?void 0:i.balance)||"0.00",symbol:(i==null?void 0:i.balanceSymbol)||""};const n=(await $.fetchTokenBalance()).find(u=>{var d,f;return u.chainId===`${(d=e.caipNetwork)==null?void 0:d.chainNamespace}:${e.chainId}`&&u.symbol===((f=e.caipNetwork)==null?void 0:f.nativeCurrency.symbol)});return{balance:(n==null?void 0:n.quantity.numeric)||"0.00",symbol:(n==null?void 0:n.symbol)||((h=e.caipNetwork)==null?void 0:h.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,c;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=$.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===Q.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Bf.encode(new TextEncoder().encode(i)),pubkey:r}},(a=$.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(c=$.state.activeCaipNetwork)==null?void 0:c.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}emitFirstAvailableConnection(){}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,n,o,a,c,l;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===Q.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:rc(t.id)}]}))}catch(h){if(h.code===Vi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===Vi.ERROR_INVALID_CHAIN_ID||h.code===Vi.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===Vi.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((l=i.provider)==null?void 0:l.request({method:"wallet_addEthereumChain",params:[{chainId:rc(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(c=t.blockExplorers)==null?void 0:c.default.url]}]}))}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}const BA=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication","headless"],Dr={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return!!s.isEnabled&&e.includes("email")},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.email:!!s},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e.filter(t=>t!=="email"):!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.socials:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.socials:!1:s},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.swaps:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.swaps:!1:s},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>{if(!(s!=null&&s.config))return!1;const e=s.config;return s.isEnabled&&e.length>0?e:!1},processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.onramp:typeof s=="boolean"?s?Ee.DEFAULT_REMOTE_FEATURES.onramp:!1:s},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.activity:!!s},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>s===void 0?Ee.DEFAULT_REMOTE_FEATURES.reownBranding:!!s},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>s.isEnabled&&(s.config??[]),processFallback:s=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:s=>typeof s>"u"?Ee.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!s},headless:{apiFeatureName:"headless",localFeatureName:"headless",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:s=>!!s.isEnabled,processFallback:()=>Ee.DEFAULT_REMOTE_FEATURES.headless}},DA={localSettingsOverridden:new Set,getApiConfig(s,e){return e==null?void 0:e.find(t=>t.id===s)},addWarning(s,e){if(s!==void 0){const t=Dr[e],i=t.isLegacy?`"features.${t.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(i)}},processFeature(s,e,t,i,r){const n=Dr[s],o=e[n.localFeatureName];if(r&&!n.isAvailableOnBasic)return!1;if(i){const a=this.getApiConfig(n.apiFeatureName,t);return(a==null?void 0:a.config)===null?this.processFallbackFeature(s,o):a!=null&&a.config?(o!==void 0&&this.addWarning(o,s),this.processApiFeature(s,a)):!1}return this.processFallbackFeature(s,o)},processApiFeature(s,e){return Dr[s].processApi(e)},processFallbackFeature(s,e){return Dr[s].processFallback(e)},async fetchRemoteFeatures(s){const e=s.basic??!1,t=s.features||{};this.localSettingsOverridden.clear();let i=null,r=!1;try{i=await _s.fetchProjectConfig(),r=i!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const n=r&&!e?Ee.DEFAULT_REMOTE_FEATURES:Ee.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of BA){const a=this.processFeature(o,t,i,r,e);Object.assign(n,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),Ee.DEFAULT_REMOTE_FEATURES}if(r&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;je.open({debugMessage:Fe.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return n}};class LA{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(t,i)=>{var r,n,o;if(t){const a=(r=$.getCaipNetworks(t))==null?void 0:r.find(h=>h.id===i);if(a)return a;const c=(n=$.getNetworkData(t))==null?void 0:n.caipNetwork;return c||((o=$.getRequestedCaipNetworks(t).filter(h=>h.chainNamespace===t))==null?void 0:o[0])}return $.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const t=this.getCaipNetwork();if(t)return t.id},this.getCaipNetworks=t=>$.getCaipNetworks(t),this.getActiveChainNamespace=()=>$.state.activeChain,this.setRequestedCaipNetworks=(t,i)=>{$.setRequestedCaipNetworks(t,i)},this.getApprovedCaipNetworkIds=()=>$.getAllApprovedCaipNetworkIds(),this.getCaipAddress=t=>{var i,r;return $.state.activeChain===t||!t?$.state.activeCaipAddress:(r=(i=$.state.chains.get(t))==null?void 0:i.accountState)==null?void 0:r.caipAddress},this.setClientId=t=>{Wr.setClientId(t)},this.getProvider=t=>pe.getProvider(t),this.getProviderType=t=>pe.getProviderId(t),this.getPreferredAccountType=t=>Io(t),this.setCaipAddress=(t,i,r=!1)=>{$.setAccountProp("caipAddress",t,i,r),$.setAccountProp("address",$e.getPlainAddress(t),i,r)},this.setBalance=(t,i,r)=>{$.setAccountProp("balance",t,r),$.setAccountProp("balanceSymbol",i,r)},this.setProfileName=(t,i)=>{$.setAccountProp("profileName",t,i)},this.setProfileImage=(t,i)=>{$.setAccountProp("profileImage",t,i)},this.setUser=(t,i)=>{$.setAccountProp("user",t,i)},this.resetAccount=t=>{$.resetAccount(t)},this.setCaipNetwork=t=>{$.setActiveCaipNetwork(t)},this.setCaipNetworkOfNamespace=(t,i)=>{$.setChainNetworkData(i,{caipNetwork:t})},this.setStatus=(t,i)=>{$.setAccountProp("status",t,i),he.isConnected()?ae.setConnectionStatus("connected"):ae.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=t=>{var i;return(i=$.getAccountData(t))==null?void 0:i.address},this.setConnectors=t=>{const i=[...he.state.allConnectors,...t];he.setConnectors(i)},this.setConnections=(t,i)=>{ae.setConnections(t,i),we.setConnections(t,i)},this.fetchIdentity=t=>Wr.fetchIdentity(t),this.getReownName=t=>pf.getNamesForAddress(t),this.getConnectors=()=>he.getConnectors(),this.getConnectorImage=t=>gf.getConnectorImage(t),this.getConnections=t=>this.remoteFeatures.multiWallet?Xa.getConnectionsData(t).connections:(je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=t=>this.remoteFeatures.multiWallet?Xa.getConnectionsData(t).recentConnections:(je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async t=>{if(!this.remoteFeatures.multiWallet){je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await we.switchConnection(t)},this.deleteConnection=t=>{if(!this.remoteFeatures.multiWallet){je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}ae.deleteAddressFromConnection(t),we.syncStorageConnections()},this.setConnectedWalletInfo=(t,i)=>{const r=pe.getProviderId(i),n=t?{...t,type:r}:void 0;$.setAccountProp("connectedWalletInfo",n,i)},this.getIsConnectedState=()=>!!$.state.activeCaipAddress,this.addAddressLabel=(t,i,r)=>{var o;const n=((o=$.getAccountData(r))==null?void 0:o.addressLabels)||{};$.setAccountProp("addressLabels",{...n,[t]:i},r)},this.removeAddressLabel=(t,i)=>{var n;const r=((n=$.getAccountData(i))==null?void 0:n.addressLabels)||{};$.setAccountProp("addressLabels",{...r,[t]:void 0},i)},this.getAddress=t=>{var r;const i=t||$.state.activeChain;return(r=$.getAccountData(i))==null?void 0:r.address},this.resetNetwork=t=>{$.resetNetwork(t)},this.addConnector=t=>{he.addConnector(t)},this.resetWcConnection=()=>{we.resetWcConnection()},this.setAddressExplorerUrl=(t,i)=>{$.setAccountProp("addressExplorerUrl",t,i)},this.setSmartAccountDeployed=(t,i)=>{$.setAccountProp("smartAccountDeployed",t,i)},this.setPreferredAccountType=(t,i)=>{$.setAccountProp("preferredAccountType",t,i)},this.setEIP6963Enabled=t=>{K.setEIP6963Enabled(t)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e)}getChainNamespacesSet(e,t){const i=e==null?void 0:e.map(n=>n.namespace).filter(n=>!!n);if(i!=null&&i.length)return[...new Set(i)];const r=t==null?void 0:t.map(n=>n.chainNamespace);return[...new Set(r)]}async initialize(e){var t,i,r,n,o,a;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),(t=e.features)!=null&&t.headless&&!mf.hasInjectedConnectors()&&_s.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1,fetchRecommendedWallets:!0}),K.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),!e.basic&&!e.manualWCControl&&(this.remoteFeatures=await DA.fetchRemoteFeatures(e)),await _s.fetchUsage(),K.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&So.setOnrampProviders(this.remoteFeatures.onramp),((i=K.state.remoteFeatures)!=null&&i.email||Array.isArray((r=K.state.remoteFeatures)==null?void 0:r.socials)&&((n=K.state.remoteFeatures)==null?void 0:n.socials.length)>0)&&await this.checkAllowedOrigins(),(o=K.state.features)!=null&&o.reownAuthentication||(a=K.state.remoteFeatures)!=null&&a.reownAuthentication){const{ReownAuthentication:c}=await Je(async()=>{const{ReownAuthentication:h}=await import("./features-Dq7eLLHj.js");return{ReownAuthentication:h}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),l=K.state.siwx;l instanceof c||(l&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),K.setSIWX(new c))}}async openSend(e){var n;const t=e.namespace||$.state.activeChain,i=this.getCaipAddress(t),r=(n=this.getCaipNetwork(t))==null?void 0:n.id;if(!i)throw new Error("openSend: caipAddress not found");if((r==null?void 0:r.toString())!==e.chainId.toString()){const o=$.getCaipNetworkById(e.chainId,t);if(!o)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(o,{throwOnFailure:!0})}try{const o=Gd.getTokenSymbolByAddress(e.assetAddress);o&&await _s.fetchTokenImages([o])}catch{}return await us.open({view:"WalletSend",data:{send:e}}),new Promise((o,a)=>{const c=Qa.subscribeKey("hash",u=>{u&&(h(),o({hash:u}))}),l=us.subscribe(u=>{u.open||(h(),a(new Error("Modal closed")))}),h=this.createCleanupHandler([c,l])})}toModalOptions(){function e(i){return(i==null?void 0:i.view)==="Swap"}function t(i){return(i==null?void 0:i.view)==="WalletSend"}return{isSwap:e,isSend:t}}async checkAllowedOrigins(){try{const e=await _s.fetchAllowedOrigins();if(!$e.isClient())return;const t=window.location.origin;On.isOriginAllowed(t,e,Q.DEFAULT_ALLOWED_ANCESTORS)||je.open(Fe.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":je.open(Fe.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;je.open({displayMessage:Fe.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Fe.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(t=>{try{t()}catch{}})}}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,delete t.universalProvider,Mt.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initAdapterController(){yf.initialize(this.chainAdapters)}initializeThemeController(e){e.themeMode&&Bt.setThemeMode(e.themeMode),e.themeVariables&&Bt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient)throw new Error("ConnectionControllerClient must be set");$.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient});const t=this.getDefaultNetwork();t&&$.setActiveCaipNetwork(t)}initializeConnectionController(e){we.initialize(e.adapters??[]),we.setWcBasic(e.basic??!1)}initializeConnectorController(){he.initialize(this.chainNamespaces)}initializeProjectSettings(e){K.setProjectId(e.projectId),K.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var r;K.setDebug(e.debug!==!1),K.setEnableWalletGuide(e.enableWalletGuide!==!1),K.setEnableWallets(e.enableWallets!==!1),K.setEIP6963Enabled(e.enableEIP6963!==!1),K.setEnableCoinbase(e.enableCoinbase!==!1),K.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),K.setEnableReconnect(e.enableReconnect!==!1),K.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),K.setCoinbasePreference(e.coinbasePreference),K.setEnableAuthLogger(e.enableAuthLogger!==!1),K.setCustomRpcUrls(e.customRpcUrls),K.setEnableEmbedded(e.enableEmbedded),K.setAllWallets(e.allWallets),K.setIncludeWalletIds(e.includeWalletIds),K.setExcludeWalletIds(e.excludeWalletIds),K.setFeaturedWalletIds(e.featuredWalletIds),K.setTokens(e.tokens),K.setTermsConditionsUrl(e.termsConditionsUrl),K.setPrivacyPolicyUrl(e.privacyPolicyUrl),K.setCustomWallets(e.customWallets),K.setFeatures(e.features),K.setAllowUnsupportedChain(e.allowUnsupportedChain),K.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),K.setPreferUniversalLinks(e.experimental_preferUniversalLinks),K.setDefaultAccountTypes(e.defaultAccountTypes);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),K.setMetadata(e.metadata),K.setDisableAppend(e.disableAppend),K.setEnableEmbedded(e.enableEmbedded),K.setSIWX(e.siwx),this.features=K.state.features??{},!e.projectId){je.open(Fe.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===Q.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");K.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return $e.isClient()?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=Ni.getUnsupportedNetwork(`${t}:${e}`);$.setActiveCaipNetwork(i)}}getDefaultNetwork(){return Ni.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return Ni.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return Ni.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?Ni.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){var i,r;try{this.setLoading(!0,e);let n={connections:[]};const o=this.getAdapter(e);return(((r=(i=$.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.caipAddress)||!K.state.enableReconnect)&&(o!=null&&o.disconnect)&&(n=await o.disconnect({id:t})),this.setLoading(!1,e),n}catch(n){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${n.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var l;const e=$.state.activeChain,t=this.getAdapter(e),i=(l=this.getCaipNetwork(e))==null?void 0:l.id,r=we.getConnections(e),n=this.remoteFeatures.multiWallet,o=r.length>0;if(!t)throw new Error("Adapter not found");const a=await t.connectWalletConnect(i);(!o||!n)&&this.close(),this.setClientId((a==null?void 0:a.clientId)||null),ae.setConnectedNamespaces([...$.state.chains.keys()]),await this.syncWalletConnectAccount(),await Lr.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=$.state.activeChain,o=this.getAdapter(n);if(!n)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),ae.addConnectedNamespace(n),this.syncConnectedWalletInfo(n))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{var l;const{id:t,chainNamespace:i,initialDisconnect:r}=e||{},n=i||$.state.activeChain,o=he.getConnectorId(n),a=t===Q.CONNECTOR_ID.AUTH||o===Q.CONNECTOR_ID.AUTH,c=t===Q.CONNECTOR_ID.WALLET_CONNECT||o===Q.CONNECTOR_ID.WALLET_CONNECT;try{const h=Array.from($.state.chains.keys());let u=i?[i]:h;(c||a)&&(u=h);const d=u.map(async g=>{const y=he.getConnectorId(g),A=t||y,R=await this.disconnectConnector(g,A);R&&(a&&ae.deleteConnectedSocialProvider(),R.connections.forEach(x=>{ae.addDisconnectedConnectorId(x.connectorId,g)})),r&&this.onDisconnectNamespace({chainNamespace:g,closeModal:!1})}),f=await Promise.allSettled(d);Qa.resetSend(),we.resetWcConnection(),(l=Lr.getSIWX())!=null&&l.signOutOnDisconnect&&await Lr.clearSessions(),he.setFilterByNamespace(void 0),we.syncStorageConnections();const p=f.filter(g=>g.status==="rejected");if(p.length>0)throw new Error(p.map(g=>g.reason.message).join(", "));Mt.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:i||"all"}})}catch(h){throw new Error(`Failed to disconnect chains: ${h.message}`)}},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=$.state.activeChain,i=this.getAdapter($.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!i)throw new Error("signMessage: adapter not found");const r=this.getAddress(t);if(!r)throw new Error("signMessage: address not found");const n=await(i==null?void 0:i.signMessage({message:e,address:r,provider:pe.getProvider(t)}));return(n==null?void 0:n.signature)||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(Ee.SEND_SUPPORTED_NAMESPACES.includes(t)){const i=this.getAdapter(t);if(!i)throw new Error("sendTransaction: adapter not found");const r=pe.getProvider(t),n=await(i==null?void 0:i.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}));return(n==null?void 0:n.hash)||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===Q.CHAIN.EVM){const i=this.getAdapter(t);if(!i)throw new Error("estimateGas: adapter is required but got undefined");const r=pe.getProvider(t),n=this.getCaipNetwork();if(!n)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(i==null?void 0:i.estimateGas({...e,provider:r,caipNetwork:n}));return(o==null?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var r;const e=$.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const t=this.getAddress(e);if(!t)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:t,chainId:Number((r=this.getCaipNetwork())==null?void 0:r.id),chainNamespace:e});const i=$.getAccountData();return(i==null?void 0:i.profileImage)||!1},getEnsAddress:async e=>await On.resolveReownName(e),writeContract:async e=>{const t=$.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeContract({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},writeSolanaTransaction:async e=>{const t=$.state.activeChain,i=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!i)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),n=this.getCaipAddress(),o=pe.getProvider(t);if(!r||!n)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const a=await(i==null?void 0:i.writeSolanaTransaction({...e,caipNetwork:r,provider:o,caipAddress:n}));return a==null?void 0:a.hash},parseUnits:(e,t)=>{const i=this.getAdapter($.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter($.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter($.state.activeChain);if(!t)throw new Error("walletGetAssets: adapter is required but got undefined");return await(t==null?void 0:t.walletGetAssets(e))??{}},updateBalance:e=>{const t=this.getAddress(e),i=this.getCaipNetwork(e);!i||!t||this.updateNativeBalance(t,i==null?void 0:i.id,e)}},we.setClient(this.connectionControllerClient)}async onConnectExternal(e){var l,h,u,d,f,p,g,y;const t=$.state.activeChain,i=e.chain||t,r=this.getAdapter(i);let n=!0;if(e.type===et.CONNECTOR_TYPE_AUTH&&Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(x=>he.getConnectorId(x)===Q.CONNECTOR_ID.AUTH)&&e.chain!==t&&(n=!1),e.chain&&e.chain!==t&&!e.caipNetwork){const A=this.getCaipNetworks().find(R=>R.chainNamespace===e.chain);A&&n&&this.setCaipNetwork(A)}if(!i)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(i),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:((l=e.caipNetwork)==null?void 0:l.id)||(o==null?void 0:o.id),rpcUrl:((f=(d=(u=(h=e.caipNetwork)==null?void 0:h.rpcUrls)==null?void 0:u.default)==null?void 0:d.http)==null?void 0:f[0])||((y=(g=(p=o==null?void 0:o.rpcUrls)==null?void 0:p.default)==null?void 0:g.http)==null?void 0:y[0])});if(c)return ae.addConnectedNamespace(i),this.syncProvider({...c,chainNamespace:i}),this.setStatus("connected",i),this.syncConnectedWalletInfo(i),ae.removeDisconnectedConnectorId(e.id,i),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,t){var a;const i=e.type===et.CONNECTOR_TYPE_AUTH,r=Gr.getOtherAuthNamespaces((a=t==null?void 0:t.connectedCaipNetwork)==null?void 0:a.chainNamespace),n=$.state.activeCaipNetwork,o=this.getAdapter(n==null?void 0:n.chainNamespace);i&&(await Promise.all(r.map(async c=>{var l,h,u;try{const d=pe.getProvider(c),f=this.getCaipNetwork(c),p=this.getAdapter(c);await(p==null?void 0:p.connect({...e,provider:d,socialUri:void 0,chainId:f==null?void 0:f.id,rpcUrl:(u=(h=(l=f==null?void 0:f.rpcUrls)==null?void 0:l.default)==null?void 0:h.http)==null?void 0:u[0]}))&&(ae.addConnectedNamespace(c),ae.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(d){je.warn(Fe.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Fe.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,d instanceof Error?d.message:void 0),Fe.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),n&&await(o==null?void 0:o.switchNetwork({caipNetwork:n})))}getApprovedCaipNetworksData(){var t,i,r,n,o;if(pe.getProviderId($.state.activeChain)===et.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=pe.getProviderId(t);if(e.chainNamespace===$.state.activeChain){const n=this.getAdapter(t);await(n==null?void 0:n.switchNetwork({caipNetwork:e}))}else if(this.setCaipNetwork(e),r===et.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=Ls.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n,o;const r=e==null?void 0:e.find(a=>a.namespace===i);return r?(r.construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:(o=this.caipNetworks)==null?void 0:o.filter(({chainNamespace:a})=>a===i)}),t[i]=r):t[i]=new UA({namespace:i,networks:this.getCaipNetworks()}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e);const t=this.getAdapter(e);if(!t)throw new Error("adapter not found");await t.syncConnectors(),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)})),this.initAdapterController()}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=ae.getConnectionStatus();K.state.enableReconnect===!1?this.setStatus("disconnected",e):i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(ae.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var l,h;const o=this.getCaipNetworks().find(u=>u.id.toString()===n.toString()||u.caipNetworkId.toString()===n.toString()),a=$.state.activeChain===e,c=(h=(l=$.state.chains.get(e))==null?void 0:l.accountState)==null?void 0:h.address;if(o){const u=a&&r?r:c;u&&this.syncAccount({address:u,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,n=Array.from(we.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||n.length===0})}),t.on("connections",r=>{this.setConnections(r,e)}),t.on("pendingTransactions",()=>{const r=this.getAddress(e),n=$.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n,connector:o})=>{var h,u;this.handlePreviousConnectorConnection(o);const a=$.state.activeChain===e;o!=null&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o==null?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=(u=(h=$.getNetworkData(e))==null?void 0:h.caipNetwork)==null?void 0:u.id,l=n||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,n,e),ae.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var c;const t=e==null?void 0:e.chain,i=e==null?void 0:e.id,r=he.getConnectorId(t),n=(c=K.state.remoteFeatures)==null?void 0:c.multiWallet,a=t&&i&&r&&r!==i&&!n;try{a&&await we.disconnect({id:r,namespace:t})}catch(l){console.warn("Error disconnecting previous connector",l)}}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&await((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null?void 0:r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>we.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||ae.deleteRecentWallet();const t=ae.getRecentWallet();Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:$e.isMobile()?"mobile":"qrcode",name:(t==null?void 0:t.name)||"Unknown",reconnect:!0,view:Ms.state.view,walletRank:t==null?void 0:t.order}})}async syncNamespaceConnection(e){try{e===Q.CHAIN.EVM&&$e.isSafeApp()&&he.setConnectorId(Q.CONNECTOR_ID.SAFE,e);const t=he.getConnectorId(e);switch(this.setStatus("connecting",e),t){case Q.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case Q.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:i}=e||{};$.resetAccount(t),$.resetNetwork(t),ae.removeConnectedNamespace(t);const r=Array.from($.state.chains.keys());(t?[t]:r).forEach(o=>ae.addDisconnectedConnectorId(he.getConnectorId(o)||"",o)),he.removeConnectorId(t),pe.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),i!==!1&&us.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),i=this.getCaipAddress(e),r=this.getCaipNetwork(e);return t==null?void 0:t.syncConnections({connectToFirstConnector:!i,caipNetwork:r})}))}async syncAdapterConnection(e){var a,c,l,h,u;const t=this.getAdapter(e),i=this.getCaipNetwork(e),r=he.getConnectorId(e),o=he.getConnectors(e).find(d=>d.id===r);try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(i!=null&&i.id))throw new Error("CaipNetwork not found");const d=await(t==null?void 0:t.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:(l=(c=(a=i==null?void 0:i.rpcUrls)==null?void 0:a.default)==null?void 0:c.http)==null?void 0:l[0]}));d?(this.syncProvider({...d,chainNamespace:e}),await this.syncAccount({...d,chainNamespace:e}),this.setStatus("connected",e),Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:d.address,properties:{method:"browser",name:((h=o.info)==null?void 0:h.name)||o.name||"Unknown",reconnect:!0,view:Ms.state.view,walletRank:(u=o==null?void 0:o.explorerWallet)==null?void 0:u.order}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var i,r;const e=Object.keys(((r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)||{}),t=this.chainNamespaces.map(async n=>{var u,d,f,p,g;const o=this.getAdapter(n);if(!o)return;const a=((p=(f=(d=(u=this.universalProvider)==null?void 0:u.session)==null?void 0:d.namespaces)==null?void 0:f[n])==null?void 0:p.accounts)||[],c=(g=$.state.activeCaipNetwork)==null?void 0:g.id,l=a.find(y=>{const{chainId:A}=Ls.parseCaipAddress(y);return A===(c==null?void 0:c.toString())})||a[0];if(l){const y=Ls.validateCaipAddress(l),{chainId:A,address:R}=Ls.parseCaipAddress(y);if(pe.setProviderId(n,et.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&$.state.activeCaipNetwork&&o.namespace!==Q.CHAIN.EVM){const x=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:$.state.activeCaipNetwork});pe.setProvider(n,x)}else pe.setProvider(n,this.universalProvider);he.setConnectorId(Q.CONNECTOR_ID.WALLET_CONNECT,n),ae.addConnectedNamespace(n),await this.syncAccount({address:R,chainId:A,chainNamespace:n})}else e.includes(n)&&this.setStatus("disconnected",n);const h=this.getApprovedCaipNetworksData();this.syncConnectedWalletInfo(n),$.setApprovedCaipNetworksData(n,{approvedCaipNetworkIds:h.approvedCaipNetworkIds,supportsAllNetworks:h.supportsAllNetworks})});await Promise.all(t)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){pe.setProviderId(r,e),pe.setProvider(r,t),he.setConnectorId(i,r)}async syncAccount(e){var u,d;const t=e.chainNamespace===$.state.activeChain,i=$.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=ae.getActiveNetworkProps(),c=(i==null?void 0:i.id)||a,l=((u=$.state.activeCaipNetwork)==null?void 0:u.name)===Q.UNSUPPORTED_NETWORK_NAME,h=$.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!h)&&c){let f=this.getCaipNetworks().find(A=>A.id.toString()===c.toString()),p=this.getCaipNetworks().find(A=>A.chainNamespace===o);if(!h&&!f&&!p){const A=this.getApprovedCaipNetworkIds()||[],R=A.find(E=>{var O;return((O=Ls.parseCaipNetworkId(E))==null?void 0:O.chainId)===c.toString()}),x=A.find(E=>{var O;return((O=Ls.parseCaipNetworkId(E))==null?void 0:O.chainNamespace)===o});f=this.getCaipNetworks().find(E=>E.caipNetworkId===R),p=this.getCaipNetworks().find(E=>E.caipNetworkId===x||"deprecatedCaipNetworkId"in E&&E.deprecatedCaipNetworkId===x)}const g=f||p;(g==null?void 0:g.chainNamespace)===$.state.activeChain?K.state.enableNetworkSwitch&&!K.state.allowUnsupportedChain&&((d=$.state.activeCaipNetwork)==null?void 0:d.name)===Q.UNSUPPORTED_NETWORK_NAME?$.showUnsupportedChainUI():this.setCaipNetwork(g):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o);const y=this.getAddress(o);Gr.isLowerCaseMatch(r,y)||this.syncAccountInfo(r,g==null?void 0:g.id,o),t?await this.syncBalance({address:r,chainId:g==null?void 0:g.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:n,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i,!0),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=he.getConnectorId(e),i=pe.getProviderId(e);if(i===et.CONNECTOR_TYPE_ANNOUNCED||i===et.CONNECTOR_TYPE_INJECTED){if(t){const o=this.getConnectors().find(a=>{var u,d;const c=a.id===t,l=((u=a.info)==null?void 0:u.rdns)===t,h=(d=a.connectors)==null?void 0:d.some(f=>{var p;return f.id===t||((p=f.info)==null?void 0:p.rdns)===t});return c||l||!!h});if(o){const{info:a,name:c,imageUrl:l}=o,h=l||this.getConnectorImage(o);this.setConnectedWalletInfo({name:c,icon:h,...a},e)}}}else if(i===et.CONNECTOR_TYPE_WALLET_CONNECT){const n=pe.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t&&(t===Q.CONNECTOR_ID.COINBASE_SDK||t===Q.CONNECTOR_ID.COINBASE)){const n=this.getConnectors().find(l=>l.id===t),o=(n==null?void 0:n.name)||"Coinbase Wallet",a=(n==null?void 0:n.imageUrl)||this.getConnectorImage(n),c=n==null?void 0:n.info;this.setConnectedWalletInfo({...c,name:o,icon:a},e)}}async syncBalance(e){!Ff.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,i){const r=this.getAdapter(i),n=$.getCaipNetworkByNamespace(i,t);if(r){const o=await r.getBalance({address:e,chainId:t,caipNetwork:n,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,i),o}}async initializeUniversalAdapter(){var r,n,o,a,c,l,h,u,d,f;const e=oA.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),t={projectId:(r=this.options)==null?void 0:r.projectId,metadata:{name:(n=this.options)!=null&&n.metadata?(o=this.options)==null?void 0:o.metadata.name:"",description:(a=this.options)!=null&&a.metadata?(c=this.options)==null?void 0:c.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(h=this.options)==null?void 0:h.metadata.url:"",icons:(u=this.options)!=null&&u.metadata?(d=this.options)==null?void 0:d.metadata.icons:[""]},logger:e};K.setManualWCControl(!!((f=this.options)!=null&&f.manualWCControl)),this.universalProvider=this.options.universalProvider??await j2.init(t);const i=this.universalProvider.disconnect.bind(this.universalProvider);this.universalProvider.disconnect=async()=>{try{return await i()}catch(p){if(p instanceof Error&&p.message.includes("Missing or invalid. Record was recently deleted"))return;throw p}},K.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{On.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:t=>{we.setUri(t)},onConnect:t=>{const{address:i}=$e.getAccount(t[0]);for(const r of this.chainNamespaces)ae.removeDisconnectedConnectorId(Q.CONNECTOR_ID.WALLET_CONNECT,r);we.finalizeWcConnection(i)},onDisconnect:()=>{$.state.noAdapters&&this.resetAccount(e),we.resetWcConnection()},onChainChanged:t=>{const i=$.state.activeChain,r=i&&he.state.activeConnectorIds[i]===Q.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&($.state.noAdapters||r)){const n=this.getCaipNetworks().find(a=>a.id.toString()===t.toString()||a.caipNetworkId.toString()===t.toString()),o=this.getCaipNetwork();if(!n){this.setUnsupportedNetwork(t);return}(o==null?void 0:o.id.toString())!==(n==null?void 0:n.id.toString())&&(o==null?void 0:o.chainNamespace)===(n==null?void 0:n.chainNamespace)&&this.setCaipNetwork(n)}},onAccountsChanged:t=>{const i=$.state.activeChain,r=i&&he.state.activeConnectorIds[i]===Q.CONNECTOR_ID.WALLET_CONNECT;if(i===e&&($.state.noAdapters||r)){const n=t==null?void 0:t[0];n&&this.syncAccount({address:n.address,chainId:n.chainId,chainNamespace:n.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&$e.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){Mt.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}getDisabledCaipNetworks(){const e=$.getAllApprovedCaipNetworkIds(),t=$.getAllRequestedCaipNetworks();return $e.sortRequestedNetworks(e,t).filter(r=>$.isCaipNetworkDisabled(r))}handleAlertError(e){const t=Object.entries(Fe.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Fe.ALERT_ERRORS[o];a&&(je.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r,n;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:(n=this.caipNetworks)==null?void 0:n.filter(({chainNamespace:o})=>o===t)}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&we.setUri(e.uri);const{isSwap:t,isSend:i}=this.toModalOptions();return t(e)?us.open({...e,data:{swap:e.arguments}}):i(e)&&e.arguments?this.openSend(e.arguments):us.open(e)}async close(){await this.injectModalUi(),us.close()}setLoading(e,t){us.setLoading(e,t)}async disconnect(e){await we.disconnect({namespace:e})}getSIWX(){return K.state.siwx}getError(){return""}getChainId(){var e;return(e=$.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e,{throwOnFailure:t=!1}={}){const i=this.getCaipNetworks().find(r=>r.id===e.id);if(!i){je.open(Fe.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await $.switchActiveNetwork(i,{throwOnFailure:t})}getWalletProvider(){return $.state.activeChain?pe.state.providers[$.state.activeChain]:null}getWalletProviderType(){return pe.getProviderId($.state.activeChain)}subscribeProviders(e){return pe.subscribeProviders(e)}getThemeMode(){return Bt.state.themeMode}getThemeVariables(){return Bt.state.themeVariables}setThemeMode(e){Bt.setThemeMode(e),fa(Bt.state.themeMode)}setTermsConditionsUrl(e){K.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){K.setPrivacyPolicyUrl(e)}setThemeVariables(e){Bt.setThemeVariables(e),kA(Bt.state.themeVariables)}subscribeTheme(e){return Bt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?we.subscribe(e):(je.open(Q.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var i,r;if(e)return(r=(i=$.state.chains.get(e))==null?void 0:i.accountState)==null?void 0:r.connectedWalletInfo;const t=$.getAccountData();return t==null?void 0:t.connectedWalletInfo}getAccount(e){const t=e||$.state.activeChain,i=he.getAuthConnector(t),r=$.getAccountData(t),n=ae.getConnectedConnectorId($.state.activeChain),o=we.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>{const{caipNetwork:l}=c;return l?c.accounts.map(({address:h,type:u,publicKey:d})=>$e.createAccount({caipAddress:`${l.caipNetworkId}:${h}`,type:u||"eoa",publicKey:d})):[]});if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:$e.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:i&&n===Q.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:ae.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:Io(t),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=[],r=()=>{const o=this.getAccount(t);o&&e(o)};if(t){const o=$.subscribeChainProp("accountState",r,t);i.push(o)}else{const o=$.subscribe(r);i.push(o)}const n=he.subscribe(r);return i.push(n),()=>{i.forEach(o=>o())}}subscribeNetwork(e){return $.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId})})}subscribeWalletInfo(e,t){return t?$.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo),t):$.subscribeChainProp("accountState",i=>e(i==null?void 0:i.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){return $.subscribeChainProp("accountState",t=>e(t==null?void 0:t.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){return $.subscribeKey("activeCaipNetwork",e)}getState(){return Yr.state}getRemoteFeatures(){return K.state.remoteFeatures}subscribeState(e){return Yr.subscribe(e)}subscribeRemoteFeatures(e){return K.subscribeKey("remoteFeatures",e)}showErrorMessage(e){ec.showError(e)}showSuccessMessage(e){ec.showSuccess(e)}getEvent(){return{...Mt.state}}subscribeEvents(e){return Mt.subscribe(e)}replace(e){Ms.replace(e)}redirect(e){Ms.push(e)}popTransactionStack(e){Ms.popTransactionStack(e)}isOpen(){return us.state.open}isTransactionStackEmpty(){return Ms.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){K.setFeatures(e)}updateRemoteFeatures(e){K.setRemoteFeatures(e)}updateOptions(e){const i={...K.state||{},...e};K.setOptions(i)}setConnectMethodsOrder(e){K.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){K.setWalletFeaturesOrder(e)}setCollapseWallets(e){K.setCollapseWallets(e)}setSocialsOrder(e){K.setSocialsOrder(e)}getConnectMethodsOrder(){return wf.getConnectOrderMethod(K.state.features,he.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(r=>r.id===i.id)||$.addNetwork(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===t)&&$.removeNetwork(e,t)}}let _h=!1;class sf extends LA{async onAuthProviderConnected(e){const t=Gr.userChainIdToChainNamespace(e==null?void 0:e.chainId);if(e.message&&e.signature&&e.siwxMessage&&await Lr.addEmbeddedWalletSession({chainId:e.siwxMessage.chainId,accountAddress:e.address,notBefore:e.siwxMessage.notBefore,statement:e.siwxMessage.statement,resources:e.siwxMessage.resources,requestId:e.siwxMessage.requestId,issuedAt:e.siwxMessage.issuedAt,domain:e.siwxMessage.domain,uri:e.siwxMessage.uri,version:e.siwxMessage.version,nonce:e.siwxMessage.nonce},e.message,e.signature),!t)throw new Error("AppKit:onAuthProviderConnected - namespace is required");const i=t===Q.CHAIN.EVM?`eip155:${e.chainId}:${e.address}`:`${e.chainId}:${e.address}`,r=K.state.defaultAccountTypes[t],n=Io(t),o=e.preferredAccountType||n||r;this.setCaipAddress(i,t);const{signature:a,siwxMessage:c,message:l,...h}=e,u=$.getAccountData(t);this.setUser({...(u==null?void 0:u.user)||{},...h},t),this.setSmartAccountDeployed(!!e.smartAccountDeployed,t),this.setPreferredAccountType(o,t),await Promise.all([this.syncAuthConnectorTheme(this.authProvider),this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:t})]),this.setLoading(!1,t)}setupAuthConnectorListeners(e){e.onRpcRequest(t=>{Nn.checkIfRequestExists(t)?Nn.checkIfRequestIsSafe(t)||this.handleUnsafeRPCRequest():(this.open(),console.error(tc.RPC_METHOD_NOT_ALLOWED_MESSAGE,{method:t.method}),setTimeout(()=>{this.showErrorMessage(tc.RPC_METHOD_NOT_ALLOWED_UI_MESSAGE)},300),e.rejectRpcRequests())}),e.onRpcError(()=>{this.isOpen()&&(this.isTransactionStackEmpty()?this.close():this.popTransactionStack("error"))}),e.onRpcSuccess((t,i)=>{const r=Nn.checkIfRequestIsSafe(i),n=this.getAddress(),o=$.state.activeCaipNetwork;r||(n&&(o!=null&&o.id)&&this.updateNativeBalance(n,o.id,o.chainNamespace),this.isTransactionStackEmpty()?this.close():this.popTransactionStack("success"))}),e.onNotConnected(()=>{const t=$.state.activeChain;if(!t)throw new Error("AppKit:onNotConnected - namespace is required");he.getConnectorId(t)===Q.CONNECTOR_ID.AUTH&&(this.setCaipAddress(null,t),this.setLoading(!1,t))}),e.onConnect(this.onAuthProviderConnected.bind(this)),e.onSocialConnected(this.onAuthProviderConnected.bind(this)),e.onSetPreferredAccount(({address:t,type:i})=>{const r=$.state.activeChain;if(!r)throw new Error("AppKit:onSetPreferredAccount - namespace is required");t&&this.setPreferredAccountType(i,r)})}async syncAuthConnectorTheme(e){if(!e)return;const t=Bt.getSnapshot();await e.syncTheme({themeMode:t.themeMode,themeVariables:t.themeVariables,w3mThemeVariables:bf(t.themeVariables,t.themeMode)})}async syncAuthConnector(e,t){var h,u,d,f,p,g,y,A,R;const i=Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(t),r=t===$.state.activeChain;if(!i)return;this.setLoading(!0,t);const n=e.getLoginEmailUsed();this.setLoading(n,t),n&&this.setStatus("connecting",t);const o=e.getEmail(),a=e.getUsername(),c=((h=$.getAccountData(t))==null?void 0:h.user)||{};this.setUser({...c,username:a,email:o},t),this.setupAuthConnectorListeners(e);const{isConnected:l}=await e.isConnected();if(t&&i&&r)if(l&&((u=this.connectionControllerClient)!=null&&u.connectExternal)){await e.init(),await this.syncAuthConnectorTheme(e),await((p=this.connectionControllerClient)==null?void 0:p.connectExternal({id:Q.CONNECTOR_ID.AUTH,info:{name:Q.CONNECTOR_ID.AUTH},type:et.CONNECTOR_TYPE_AUTH,provider:e,chainId:(f=(d=$.getNetworkData(t))==null?void 0:d.caipNetwork)==null?void 0:f.id,chain:t})),this.setStatus("connected",t);const x=ae.getConnectedSocialProvider();x?Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",address:this.getAddress(),properties:{provider:x,reconnect:!0}}):Mt.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:this.getAddress(),properties:{method:"email",name:((R=(A=(y=(g=this.universalProvider)==null?void 0:g.session)==null?void 0:y.peer)==null?void 0:A.metadata)==null?void 0:R.name)||"Unknown",reconnect:!0,view:Ms.state.view,walletRank:void 0}})}else he.getConnectorId(t)===Q.CONNECTOR_ID.AUTH&&(this.setStatus("disconnected",t),ae.removeConnectedNamespace(t));this.setLoading(!1,t)}async checkExistingTelegramSocialConnection(e){var t;try{if(!$e.isTelegram())return;const i=ae.getTelegramSocialProvider();if(!i||!$e.isClient())return;const n=new URL(window.location.href).searchParams.get("result_uri");if(!n)return;i&&$.setAccountProp("socialProvider",i,e),await((t=this.authProvider)==null?void 0:t.init());const o=he.getAuthConnector();i&&o&&(this.setLoading(!0,e),await we.connectExternal({id:o.id,type:o.type,socialUri:n},o.chain),ae.setConnectedSocialProvider(i),ae.removeTelegramSocialProvider(),Mt.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:i}}))}catch(i){this.setLoading(!1,e),console.error("checkExistingSTelegramocialConnection error",i)}try{const i=new URL(window.location.href);i.searchParams.delete("result_uri"),window.history.replaceState({},document.title,i.toString())}catch(i){console.error("tma social login failed",i)}}createAuthProvider(e){var l,h,u,d;if(!Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(e))return;const i=(l=this.remoteFeatures)==null?void 0:l.email,r=Array.isArray((h=this.remoteFeatures)==null?void 0:h.socials)&&this.remoteFeatures.socials.length>0,n=i||r,a=Gr.getActiveNamespaceConnectedToAuth()||e;!this.authProvider&&((u=this.options)!=null&&u.projectId)&&n&&(this.authProvider=vf.getInstance({projectId:this.options.projectId,enableLogger:this.options.enableAuthLogger,chainId:(d=this.getCaipNetwork(a))==null?void 0:d.caipNetworkId,abortController:Fe.EmbeddedWalletAbortController,onTimeout:f=>{f==="iframe_load_failed"?je.open(Fe.ALERT_ERRORS.IFRAME_LOAD_FAILED,"error"):f==="iframe_request_timeout"?je.open(Fe.ALERT_ERRORS.IFRAME_REQUEST_TIMEOUT,"error"):f==="unverified_domain"&&je.open(Fe.ALERT_ERRORS.UNVERIFIED_DOMAIN,"error")},getActiveCaipNetwork:f=>Ef(f),getCaipNetworks:f=>$.getCaipNetworks(f)}),Yr.subscribeOpen(f=>{var p;!f&&this.isTransactionStackEmpty()&&((p=this.authProvider)==null||p.rejectRpcRequests())}));const c=e===$.state.activeChain&&K.state.enableReconnect;K.state.enableReconnect===!1?this.syncAuthConnectorTheme(this.authProvider):this.authProvider&&c&&(this.syncAuthConnector(this.authProvider,e),this.checkExistingTelegramSocialConnection(e))}createAuthProviderForAdapter(e){var t,i,r;this.createAuthProvider(e),this.authProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setAuthProvider)==null||r.call(i,this.authProvider))}initControllers(e){super.initControllers(e),this.options.excludeWalletIds&&_s.initializeExcludedWallets({ids:this.options.excludeWalletIds})}async switchCaipNetwork(e){var o,a,c;if(!e)return;const t=$.state.activeChain,i=e.chainNamespace,r=this.getAddressByChainNamespace(i);if(i===t&&((o=$.getAccountData(i))!=null&&o.caipAddress)){const l=this.getAdapter(i);await(l==null?void 0:l.switchNetwork({caipNetwork:e})),this.setCaipNetwork(e)}else{const h=pe.getProviderId(t)===et.CONNECTOR_TYPE_AUTH,u=pe.getProviderId(i),d=u===et.CONNECTOR_TYPE_AUTH,f=Q.AUTH_CONNECTOR_SUPPORTED_CHAINS.includes(i);if(!i)throw new Error("AppKit:switchCaipNetwork - networkNamespace is required");if((h&&u===void 0||d)&&f)try{if($.state.activeChain=e.chainNamespace,r){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}else await((c=(a=this.connectionControllerClient)==null?void 0:a.connectExternal)==null?void 0:c.call(a,{id:Q.CONNECTOR_ID.AUTH,provider:this.authProvider,chain:i,chainId:e.id,type:et.CONNECTOR_TYPE_AUTH,caipNetwork:e}));this.setCaipNetwork(e)}catch{const g=this.getAdapter(i);await(g==null?void 0:g.switchNetwork({caipNetwork:e}))}else if(u===et.CONNECTOR_TYPE_WALLET_CONNECT){if(!$.state.noAdapters){const p=this.getAdapter(i);await(p==null?void 0:p.switchNetwork({caipNetwork:e}))}this.setCaipNetwork(e),this.syncWalletConnectAccount()}else this.setCaipNetwork(e),r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:i})}}async initialize(e){var t;await super.initialize(e),(t=this.chainNamespaces)==null||t.forEach(i=>{this.createAuthProviderForAdapter(i)}),await this.injectModalUi(),Yr.set({initialized:!0})}async syncIdentity({address:e,chainId:t,chainNamespace:i}){var a;if(i!==Q.CHAIN.EVM)return;const r=`${i}:${t}`,n=(a=this.caipNetworks)==null?void 0:a.find(c=>c.caipNetworkId===r);if(n!=null&&n.testnet){this.setProfileName(null,i),this.setProfileImage(null,i);return}const o=he.getConnectorId(i)===Q.CONNECTOR_ID.AUTH;try{const{name:c,avatar:l}=await this.fetchIdentity({address:e});!c&&o?await this.syncReownName(e,i):(this.setProfileName(c,i),this.setProfileImage(l,i))}catch{t!==1&&this.setProfileImage(null,i)}}syncConnectedWalletInfo(e){const t=pe.getProviderId(e);if(t===et.CONNECTOR_TYPE_AUTH){const i=this.authProvider;if(i){const r=ae.getConnectedSocialProvider()??"email",n=i.getEmail()??i.getUsername();this.setConnectedWalletInfo({name:t,identifier:n,social:r},e)}}else super.syncConnectedWalletInfo(e)}async injectModalUi(){if(!$e.isClient())return;const e={...Ee.DEFAULT_FEATURES,...this.options.features};if(!e.headless&&!_h)try{const t=this.remoteFeatures;if(await this.loadModalComponents(e,t),$e.isClient()&&!document.querySelector("w3m-modal")){const r=document.createElement("w3m-modal");!K.state.disableAppend&&!K.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",r)}_h=!0}catch(t){console.error("Error injecting modal UI:",t)}}async loadModalComponents(e,t){if(!$e.isClient())return;const i=[];(t.email||t.socials&&t.socials.length>0)&&i.push(Je(()=>import("./embedded-wallet-4C0zCBzD.js"),__vite__mapDeps([10,11,4,1,2,3,5,6,7,8,9,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]))),t.email&&i.push(Je(()=>import("./email-dOZOTXLM.js"),__vite__mapDeps([28,11,4,29,22,15,1,2,3,5,6,7,8,9,21,13,14,20,30,18,24,25,26,27]))),t.socials&&i.push(Je(()=>import("./socials-CT51nzyt.js"),__vite__mapDeps([31,11,4,13,32,14,1,2,3,5,6,7,8,9,33,21,17,20,15,34,12,35,36,24,25,26,27]))),t.swaps&&t.swaps.length>0&&i.push(Je(()=>import("./swaps-DcnyL-aF.js"),__vite__mapDeps([37,11,4,20,15,21,13,38,1,2,3,5,6,7,8,9,39,36,40,12,41,18,14,24,25,26,27]))),e.send&&i.push(Je(()=>import("./send-BVveMXEO.js"),__vite__mapDeps([42,11,4,20,15,21,13,43,14,1,2,3,5,6,7,8,9,44,22,40,12,36,39,18,45,46,24,25,26,27]))),e.receive&&i.push(Je(()=>import("./receive-ENeHUThj.js"),__vite__mapDeps([47,11,4,13,12,34,35,1,2,3,5,6,7,8,9,24,25,26,27]))),t.onramp&&t.onramp.length>0&&i.push(Je(()=>import("./onramp-DRY-VmEl.js"),__vite__mapDeps([48,11,4,13,49,15,32,14,1,2,3,5,6,7,8,9,12,50,51,22,20,21,18,24,25,26,27]))),t.payWithExchange&&i.push(Je(()=>import("./pay-with-exchange-Fws3sgDP.js"),__vite__mapDeps([52,11,4,13,12,19,49,15,36,20,44,14,22,1,2,3,5,6,7,8,9,53,21,18,45,43,24,25,26,27]))),t.activity&&i.push(Je(()=>import("./transactions-LbE_YtGz.js"),__vite__mapDeps([54,11,4,55,21,13,22,12,36,1,2,3,5,6,7,8,9,24,25,26,27]))),(e.pay||t.payments)&&i.push(Je(()=>import("./index-aGypPCn4.js"),__vite__mapDeps([56,57,11,4,13,20,15,19,12,49,58,21,43,1,2,3,5,6,7,8,9,36,41,24,25,26,27]))),t.emailCapture&&i.push(Je(()=>import("./data-capture-Bjp5qmbu.js"),__vite__mapDeps([59,11,4,29,22,15,1,2,3,5,6,7,8,9,0,24,25,26,27]))),await Promise.all([...i,Je(()=>import("./index-B4nv3uRr.js"),__vite__mapDeps([60,11,4,13,12,15,46,1,2,3,5,6,7,8,9,21,61,51,22,16,17,58,19,49,20,53,55,36,45,38,41,43,14,18,30,32,33,34,35,23,50,24,25,26,27])),Je(()=>import("./w3m-modal-BSFcMGCh.js"),__vite__mapDeps([62,11,4,13,1,2,3,5,6,7,8,9,57,20,15,19,12,49,58,21,43,36,41,16,17,38,61,51,22,39,24,25,26,27]))])}}const MA="1.8.19";function qA(s){return new sf({...s,sdkVersion:$e.generateSdkVersion(s.adapters??[],"html",MA)})}const US=Object.freeze(Object.defineProperty({__proto__:null,AppKit:sf,CoreHelperUtil:$e,WcConstantsUtil:Vi,createAppKit:qA},Symbol.toStringTag,{value:"Module"}));export{Ne as A,Si as E,So as O,xS as a,IS as b,_S as c,NS as d,kS as e,SS as f,AS as g,$S as h,Vr as i,As as j,TS as k,Zd as l,US as m,RS as r,ua as u,RA as v,OS as w};
|