self.addEventListener("install",e=>("addRoutes"in e&&e.addRoutes([{condition:{urlPattern:"http://localhost:8182/.*"},source:"network"},{condition:{urlPattern:"http://127.0.0.1:8182/.*"},source:"network"},{condition:{urlPattern:{baseURL:self.origin,pathname:"/project-selene.zip"}},source:"network"},{condition:{urlPattern:{pathname:"/static/*",hostname:"*"}},source:{cacheName:"selene-loader"}},{condition:{urlPattern:{pathname:"/index.html",hostname:"*"}},source:{cacheName:"selene-loader"}},{condition:{urlPattern:{pathname:"/main.css",hostname:"*"}},source:{cacheName:"selene-loader"}},{condition:{urlPattern:{pathname:"/favicon.ico",hostname:"*"}},source:{cacheName:"selene-loader"}},{condition:{urlPattern:{pathname:"/api/*",hostname:"*"}},source:"race-network-and-fetch-handler"}]),self.skipWaiting(),e.waitUntil(caches.open("selene-loader").then(t=>t.add("static/js/prefix.js")).catch(()=>{}))));self.addEventListener("activate",e=>e.waitUntil(self.clients.claim()));self.addEventListener("fetch",e=>e.respondWith(e.request.headers.get("Accept")==="text/event-stream"?fetch(e.request):new URL(e.request.url).pathname.startsWith("/fs/")?h(e):f(e.request)));var d=0,n={};self.addEventListener("message",e=>{if(e.origin===self.origin&&e.data.type==="response"){let t=e.data;t.success?n[t.id]?.resolve?.(t.response):n[t.id]?.reject?.(t.response),delete n[t.id]}});async function h(e){let t=await self.clients.get(e.clientId);if(!t||t.type!=="window")return fetch(e.request);let r=new TransformStream,a=e.request.body;if((e.request.method==="POST"||e.request.method==="PUT")&&!a){let c=new TransformStream;a=c.readable;let s=c.writable.getWriter();e.request.arrayBuffer().then(l=>{s.write(new Uint8Array(l)),s.close()}).catch(()=>s.abort())}let o=d++,{promise:i}=n[o]=Promise.withResolvers();return t.postMessage({type:"fetch",id:o,data:{request:{method:e.request.method,url:e.request.url,headers:u(e.request.headers),body:a,clientId:e.clientId},response:r.writable}},a?[r.writable,a]:[r.writable]),new Response(r.readable,await i)}function u(e){let t={};return e.forEach((r,a)=>t[a]=r),t}async function f(e){if(e.url.startsWith("chrome-extension")||e.method!=="GET")return fetch(e);if(!navigator.onLine){let t=await caches.match(e);if(t)return t}try{let t=await fetch(e);return await(await caches.open("selene-loader")).put(e,t.clone()),t}catch{let t=await caches.match(e);return t||new Response("Network error happened",{status:408,headers:{"Content-Type":"text/plain"}})}}
//# sourceMappingURL=serviceworker.js.map
