const VERSION = "zimphony-webmail-pwa-v1";

self.addEventListener("install", () => {
  void self.skipWaiting();
});

self.addEventListener("activate", (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((key) => key.startsWith("zimphony-webmail-pwa-") && key !== VERSION).map((key) => caches.delete(key)))).then(() => self.clients.claim())
  );
});

// Intentionally no fetch handler. Mail, API responses, and sessions remain network-only.
