const CACHE='stepaway-v2-20-app-fix';
const CORE=['./','index.html','index.php','share.html','share.php','manifest.webmanifest','assets/css/app.css','assets/js/app.js','api.php?endpoint=content&file=cards','api.php?endpoint=content&file=cases','api.php?endpoint=content&file=campaigns','api.php?endpoint=content&file=wrinkles','api.php?endpoint=content&file=settings','api.php?endpoint=content&file=pack-index'];
self.addEventListener('install',e=>{e.waitUntil(caches.open(CACHE).then(c=>c.addAll(CORE)).then(()=>self.skipWaiting()))});
self.addEventListener('activate',e=>{e.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim()))});
self.addEventListener('fetch',e=>{if(e.request.method!=='GET')return;e.respondWith(caches.match(e.request).then(c=>c||fetch(e.request).then(r=>{const cp=r.clone();caches.open(CACHE).then(cache=>cache.put(e.request,cp)).catch(()=>{});return r}).catch(()=>caches.match('index.html'))))});
