const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/UnlockedWallet-B6hSmM5s.js","chunks/index-YPJa-kxZ.js","chunks/_virtual_wxt-plugins-D2Qy6pl9.js","chunks/TeamThemeProvider-BMMWqJEv.js","chunks/debounce-D1Adyjvd.js","chunks/headers-DBBLE3ii.js","chunks/gateway-auth-C4f--iOs.js","chunks/vault-state-DXmi8wtw.js"])))=>i.map(i=>d[i]);
import{_ as C,__tla as __tla_0}from"./index-YPJa-kxZ.js";import{ar as f,au as S,__tla as __tla_1}from"./_virtual_wxt-plugins-D2Qy6pl9.js";import{av as X,__tla as __tla_2}from"./_virtual_wxt-plugins-D2Qy6pl9.js";import{C as l,c as T}from"./contract-state-cache-5DyKqU8u.js";import{au as g,av as M,aw as _,ax as h,__tla as __tla_3}from"./UnlockedWallet-B6hSmM5s.js";import{__tla as __tla_4}from"./TeamThemeProvider-BMMWqJEv.js";import{__tla as __tla_5}from"./debounce-D1Adyjvd.js";import{__tla as __tla_6}from"./headers-DBBLE3ii.js";import{__tla as __tla_7}from"./gateway-auth-C4f--iOs.js";import{__tla as __tla_8}from"./vault-state-DXmi8wtw.js";let U,q,V,w;let __tla=Promise.all([(()=>{try{return __tla_0}catch{}})(),(()=>{try{return __tla_1}catch{}})(),(()=>{try{return __tla_2}catch{}})(),(()=>{try{return __tla_3}catch{}})(),(()=>{try{return __tla_4}catch{}})(),(()=>{try{return __tla_5}catch{}})(),(()=>{try{return __tla_6}catch{}})(),(()=>{try{return __tla_7}catch{}})(),(()=>{try{return __tla_8}catch{}})()]).then(async()=>{const y=1;function E(t){let e=0x811c9dc5;for(let n=0;n<t.length;n+=64)e^=t.charCodeAt(n),e=Math.imul(e,0x1000193);return`${t.length}:${(e>>>0).toString(16)}`}async function x(t){if(!globalThis.crypto?.subtle)return E(t);const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return Array.from(new Uint8Array(e),n=>n.toString(16).padStart(2,"0")).join("")}async function $(t,e){const n=await M(h,t);return n?.schemaVersion!==y||n.stateFingerprint!==e?null:n.snapshot}function v(t,e,n){_(h,t,{schemaVersion:y,stateFingerprint:e,storedAt:Date.now(),snapshot:n})}function k(...t){for(const e of t)g(h,e)}const O=64,{load:H,invalidate:b,clear:N,cache:d}=T(l,O),i=new Map,u=new Map;async function p(t){const e=await fetch(t.indexerUrl,{method:"POST",headers:t.resolveIndexerHeaders?await t.resolveIndexerHeaders(t.indexerUrl):{"Content-Type":"application/json"},signal:AbortSignal.timeout(1e4),body:JSON.stringify({query:`
        query MTS_${t.field==="contract"?"CURRENT_CONTRACT":"CONTRACT_ACTION"}_STATE($address: HexEncoded!) {
          ${t.field}(address: $address) {
            state
          }
        }
      `,variables:{address:t.contractAddress}})});if(!e.ok)return{supported:!0,state:null};const o=(await e.json())?.data;if(!o||!Object.prototype.hasOwnProperty.call(o,t.field))return{supported:!1,state:null};const r=o[t.field]?.state;return{supported:!0,state:typeof r=="string"&&r.length>0?r:null}}async function R(t,e,n){const o=f(e);try{if(u.get(t)!==!1){const a=await p({indexerUrl:t,contractAddress:o,field:"contract",resolveIndexerHeaders:n});if(u.set(t,a.supported),a.supported)return a.state}return(await p({indexerUrl:t,contractAddress:o,field:"contractAction",resolveIndexerHeaders:n})).state}catch{return null}}V=async function(t){const e=f(t.contractAddress),n=t.variant??"global",o=`${t.network}:${n}:${e}`;return H(o,async()=>{try{const{getTokenMetaCache:r}=await C(async()=>{const{getTokenMetaCache:s}=await import("./UnlockedWallet-B6hSmM5s.js").then(async m=>{await m.__tla;return m}).then(A=>A.ed);return{getTokenMetaCache:s}},__vite__mapDeps([0,1,2,3,4,5,6,7])),c=r().get(e);if(c?.state){const s=await w({network:t.network,contractAddress:c.contractAddress||e,stateHex:c.state,variant:n});if(s)return s}}catch{}if(t.indexerUrl){const r=await R(t.indexerUrl,e,t.resolveIndexerHeaders);if(r){const a=await w({network:t.network,contractAddress:e,stateHex:r,variant:n});if(a)return a}}return null},t.force)};U=function(){N(),i.clear(),u.clear()};q=function(t){const e=t.contractAddress.replace(/^0x/i,"").toLowerCase(),n=[`${t.network}:global:${e}`,`${t.network}:personal:${e}`];b(...n);for(const o of n)i.delete(o);k(...n)};w=async function(t){try{const e=f(t.contractAddress),n=t.variant??"global",o=`${t.network}:${n}:${e}`,r=await x(t.stateHex),a=d.get(o);if(a?.snapshot&&i.get(o)===r)return a.snapshot;const c=await $(o,r);if(c)return d.set(o,{expiresAt:Date.now()+l,snapshot:c}),i.set(o,r),c;const s=await S({stateHex:t.stateHex,contractAddress:e,variant:n});return s&&(d.set(o,{expiresAt:Date.now()+l,snapshot:s}),i.set(o,r),v(o,r,s)),s}catch{return null}}});export{l as CONTRACT_STATE_CACHE_TTL_MS,U as clearMtsCollectionSnapshotCache,X as decodeMtsCollectionSnapshot,q as invalidateMtsContractSnapshot,V as loadMtsCollectionSnapshot,w as preloadMtsSnapshotFromState,__tla};