// mdcms service worker — generated by mdcms build
const CACHE_NAME = 'mdcms-eb384247';
const PRECACHE_URLS = [
  "index.html",
  "config.yml",
  "nav.yml",
  "search.json",
  "theme.yml",
  "pages/about.md",
  "pages/docs.md",
  "pages/home.md",
  "posts/.gitkeep",
  "assets/fonts/.gitkeep",
  "assets/icons/.gitkeep",
  "assets/icons/arrow_drop_down.svg",
  "assets/icons/arrow_right.svg",
  "assets/icons/dangerous.svg",
  "assets/icons/dark_mode.svg",
  "assets/icons/error.svg",
  "assets/icons/exclamation.svg",
  "assets/icons/history.svg",
  "assets/icons/info.svg",
  "assets/icons/language.svg",
  "assets/icons/light_mode.svg",
  "assets/icons/menu.svg",
  "assets/icons/mobile_arrow_down.svg",
  "assets/icons/report.svg",
  "assets/icons/search.svg",
  "assets/icons/success.svg",
  "assets/icons/text_compare.svg",
  "assets/icons/warning.svg",
  "assets/images/.gitkeep",
  "assets/images/favicon.png"
];

self.addEventListener('install', event => {
  event.waitUntil(
    caches.open(CACHE_NAME).then(cache => cache.addAll(PRECACHE_URLS))
  );
  self.skipWaiting();
});

self.addEventListener('activate', event => {
  event.waitUntil(
    caches.keys().then(keys =>
      Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
    )
  );
  self.clients.claim();
});

self.addEventListener('fetch', event => {
  if (event.request.method !== 'GET') return;
  event.respondWith(
    caches.match(event.request).then(cached => cached || fetch(event.request))
  );
});
