import{g as u}from"./chunk-DQIhPnbi.js";const c=document.getElementById("ipfs-status"),l=document.getElementById("ipfs-dot"),t=document.getElementById("helios-status"),i=document.getElementById("helios-dot"),h=document.getElementById("helios-error-card"),g=document.getElementById("helios-error-detail");function n(e,o){e.classList.remove("ok","bad","syncing"),o!=="idle"&&e.classList.add(o)}function s(e,o){e.classList.remove("ok","bad"),o!=="idle"&&e.classList.add(o)}async function b(){try{await fetch("http://bafkqaaa.ipfs.localhost:8080/",{mode:"no-cors",cache:"no-store",signal:AbortSignal.timeout(1500)}),c.textContent="online",s(c,"ok"),n(l,"ok")}catch{c.textContent="offline",s(c,"bad"),n(l,"bad")}}function d(e){g.textContent=e,h.hidden=!1}function r(){h.hidden=!0}function m(e){if(s(t,"idle"),!e){t.textContent="unknown",n(i,"idle"),r();return}switch(e.state){case"idle":t.textContent="not started",n(i,"idle"),r();break;case"booting":t.textContent="booting…",n(i,"syncing"),r();break;case"syncing":t.textContent="syncing…",n(i,"syncing"),r();break;case"synced":e.rpcHealth?.state==="failing"?(t.textContent="RPC failing",s(t,"bad"),n(i,"bad"),d(e.rpcHealth.lastError??"The Ethereum RPC is rejecting requests.")):(t.textContent="online",s(t,"ok"),n(i,"ok"),r());break;case"error":t.textContent="error",s(t,"bad"),n(i,"bad"),d(e.error??"Unknown error");break}}async function w(){for(;;){try{const e=await chrome.runtime.sendMessage({type:"get-helios-status"});m(e?.status??null)}catch{m(null)}await new Promise(e=>setTimeout(e,1e3))}}document.getElementById("open-options")?.addEventListener("click",async()=>{const e=await u(),o=!e.onboardingComplete&&!e.rpcUrl?chrome.runtime.getURL("onboarding.html"):chrome.runtime.getURL("options.html");await chrome.tabs.create({url:o}),window.close()});document.getElementById("open-bookmarks")?.addEventListener("click",async()=>{await chrome.tabs.create({url:chrome.runtime.getURL("bookmarks.html")}),window.close()});document.getElementById("open-home")?.addEventListener("click",async()=>{await chrome.tabs.create({url:chrome.runtime.getURL("home.html")}),window.close()});async function f(){if(!(await u()).onboardingComplete){const o=chrome.runtime.getURL("onboarding.html"),a=(await chrome.tabs.query({url:o}))[0];a?.id!=null?(await chrome.tabs.update(a.id,{active:!0}),a.windowId!=null&&await chrome.windows.update(a.windowId,{focused:!0})):await chrome.tabs.create({url:o}),window.close();return}b(),w()}f();
//# sourceMappingURL=chunk-CLiREbEk.js.map
