const CACHE='linkexpress-v2.9.12';
const ASSETS=['./assets/app.css?v=2.9.12','./assets/app.js?v=2.9.12','./assets/map-tools.js?v=2.9.12','./assets/favicon.svg','./assets/logo-linkexpress.svg','./manifest.php'];
self.addEventListener('install',event=>{self.skipWaiting();event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(ASSETS)).catch(()=>{}));});
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(key=>key!==CACHE).map(key=>caches.delete(key)))).then(()=>self.clients.claim())));
self.addEventListener('fetch',event=>{
  if(event.request.method!=='GET')return;
  const url=new URL(event.request.url);
  const isStatic=url.pathname.includes('/assets/')||url.pathname.endsWith('/manifest.json')||url.pathname.endsWith('/manifest.php');
  if(!isStatic)return;
  event.respondWith(fetch(event.request).then(response=>{const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy));return response;}).catch(()=>caches.match(event.request)));
});
