const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/wallets-C7O8bt0K.js","assets/thirdweb-Co3M1EyP.js","assets/store-CraP4F4Y.js","assets/ui-BJj_Hssx.js","assets/vendor-64qtqz3S.js","assets/index-BNXDN8h1.js","assets/index-DLwPbJ_o.css","assets/index-DSskmJfT.js","assets/index-DnKfU2ei.js","assets/index-nibyPLVP.js","assets/ethereum-Csz0KDPf.js"])))=>i.map(i=>d[i]);
import{_ as g}from"./thirdweb-Co3M1EyP.js";import{i as o,j as T,k as f,l as C,m as p,o as m}from"./wallets-C7O8bt0K.js";import"./store-CraP4F4Y.js";import"./ui-BJj_Hssx.js";import"./vendor-64qtqz3S.js";import"./index-BNXDN8h1.js";import"./index-DSskmJfT.js";import"./index-DnKfU2ei.js";import"./index-nibyPLVP.js";import"./ethereum-Csz0KDPf.js";async function j(c){const{wallet:r,walletConnectClient:w,thirdwebClient:h,event:{topic:_,id:d,params:{chainId:n,request:e}},handlers:a}=c,i=r.getAccount();if(!i)throw new Error("No account connected to provided wallet");let t;try{switch(e.method){case"personal_sign":{a!=null&&a.personal_sign?t=await a.personal_sign({account:i,params:e.params}):t=await m({account:i,params:e.params});break}case"eth_sign":{a!=null&&a.eth_sign?t=await a.eth_sign({account:i,params:e.params}):t=await m({account:i,params:e.params});break}case"eth_signTypedData":{a!=null&&a.eth_signTypedData?t=await a.eth_signTypedData({account:i,params:e.params}):t=await p({account:i,params:e.params});break}case"eth_signTypedData_v4":{a!=null&&a.eth_signTypedData_v4?t=await a.eth_signTypedData_v4({account:i,params:e.params}):t=await p({account:i,params:e.params});break}case"eth_signTransaction":{a!=null&&a.eth_signTransaction?t=await a.eth_signTransaction({account:i,params:e.params}):t=await C({account:i,params:e.params});break}case"eth_sendTransaction":{const s=o(n);a!=null&&a.eth_sendTransaction?t=await a.eth_sendTransaction({account:i,chainId:s,params:e.params}):t=await f({account:i,chainId:s,params:e.params,thirdwebClient:h});break}case"eth_sendRawTransaction":{const s=o(n);a!=null&&a.eth_sendRawTransaction?t=await a.eth_sendRawTransaction({account:i,chainId:s,params:e.params}):t=await T({account:i,chainId:s,params:e.params});break}case"wallet_addEthereumChain":{if(a!=null&&a.wallet_addEthereumChain)t=await a.wallet_addEthereumChain({params:e.params,wallet:r});else throw new Error("Unsupported request method: wallet_addEthereumChain");break}case"wallet_switchEthereumChain":{if(a!=null&&a.wallet_switchEthereumChain)t=await a.wallet_switchEthereumChain({params:e.params,wallet:r});else{const{handleSwitchChain:s}=await g(async()=>{const{handleSwitchChain:l}=await import("./wallets-C7O8bt0K.js").then(u=>u.a8);return{handleSwitchChain:l}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]));t=await s({params:e.params,wallet:r})}break}default:{const s=a==null?void 0:a[e.method];if(s)t=await s({account:i,chainId:o(n),params:e.params});else throw new Error(`Unsupported request method: ${e.method}`)}}}catch(s){t={code:typeof s=="object"&&s!==null&&"code"in s?s.code:500,message:typeof s=="object"&&s!==null&&"message"in s?s.message:"Unknown error"}}w.respond({response:{id:d,jsonrpc:"2.0",result:t},topic:_})}export{j as fulfillRequest};
