const o="_inflight_txs";async function c(){try{return(await chrome.storage.local.get(o))[o]??[]}catch{return[]}}async function r(e){try{await chrome.storage.local.set({[o]:e})}catch(a){console.error("[Inflight] Storage write failed:",a)}}async function l(e){const a=await c(),n=Date.now(),t=a.filter(i=>n-i.createdAt<18e5&&i.status!=="confirmed"&&i.status!=="failed").filter(i=>i.id!==e.id);for(;t.length>=20;)t.shift();t.push(e),await r(t)}async function f(e,a){const n=await c(),s=n.findIndex(t=>t.id===e);s<0||(n[s]={...n[s],...a},await r(n))}async function u(e){const a=await c();await r(a.filter(n=>n.id!==e))}async function w(e,a){const n=await c(),s=Date.now();return n.filter(t=>t.walletScope===e&&t.network===a&&(t.status==="saved"||t.status==="submitting")&&t.attempts<3&&s-t.createdAt<18e5)}export{w as getRecoverableTxs,u as removeInflightTx,l as saveInflightTx,f as updateInflightTx};
