import{J as d,x as l,B as p,l as f,K as r,r as c}from"./thirdweb-Co3M1EyP.js";function u(e){if(e.startsWith("0x")||(e=`0x${e}`),e.startsWith("0x363d3d373d3d3d363d73"))return`0x${e.slice(22,62)}`;if(e.startsWith("0x36603057343d5230"))return`0x${e.slice(122,162)}`;if(e.startsWith("0x3d3d3d3d363d3d37363d73"))return`0x${e.slice(24,64)}`;if(e.startsWith("0x366000600037611000600036600073"))return`0x${e.slice(32,72)}`;if(e.startsWith("0x36600080376020600036600073"))return`0x${e.slice(28,68)}`;if(e.startsWith("0x365f5f375f5f365f73"))return`0x${e.slice(20,60)}`;if(e.length===48&&e.startsWith("0xef0100"))return`0x${e.slice(8,48)}`}const o="0x0000000000000000000000000000000000000000",x="0x0000000000000000000000000000000000000000000000000000000000000000";async function w(e){const[s,t]=await Promise.all([d(e),A(e)]),i=u(s);if(i)return{address:i,bytecode:await d(l({...e,address:i}))};t&&t!==o&&(e=l({...e,address:t}));const a=await Promise.all([h(e),S(e)]);for(const n of a)if(n&&p(n)&&n!==o){const m=await d({...e,address:n});return m==="0x"?{address:e.address,bytecode:s}:{address:n,bytecode:m}}return{address:e.address,bytecode:s}}async function A(e){const s=f({chain:e.chain,client:e.client});try{const t=await r(s,{address:e.address,position:"0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50"});return t.length>=40?`0x${t.slice(-40)}`:void 0}catch{return}}async function h(e){const s=f({chain:e.chain,client:e.client});try{const t=[r(s,{address:e.address,position:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"}),r(s,{address:e.address,position:"0xbaab7dbf64751104133af04abc7d9979f0fda3b059a322a8333f533d3f32bf7f"}),r(s,{address:e.address,position:"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3"})],a=(await Promise.all(t)).find(n=>n!==x);return a?`0x${a.slice(-40)}`:o}catch{return}}const g={inputs:[],name:"implementation",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"};async function S(e){try{return await c({contract:e,method:g})}catch{return}}export{w as resolveImplementation};
