import {
  init,
  withBackgroundPrecache,
  withBlobProxy,
  withCleanup,
  withFetchStrategy,
  withPrecache,
  withUpdatePolling,
} from '@civility/workers'

init([
  withPrecache([
    '/',
    'https://bpev.me/civility.min.css',
    '/dist/icons/128x128.png',
    '/dist/icons/192x192.png',
    '/dist/icons/256x256.png',
    '/dist/icons/512x512.png',
    '/dist/icons/icon.png',
    '/dist/icons/icon.ico',
    '/index.html',
    '/static/styles/maplibre-gl.css',
    '/static/styles/theme.css',

    '/static/icons/arrow-left.svg',
    '/static/icons/book.svg',
    '/static/icons/bookmark.svg',
    '/static/icons/check-circle.svg',
    '/static/icons/check-square.svg',
    '/static/icons/chevron-down.svg',
    '/static/icons/circle.svg',
    '/static/icons/copy.svg',
    '/static/icons/download.svg',
    '/static/icons/edit.svg',
    '/static/icons/external-link.svg',
    '/static/icons/filter.svg',
    '/static/icons/globe.svg',
    '/static/icons/heart.svg',
    '/static/icons/home.svg',
    '/static/icons/image.svg',
    '/static/icons/instagram.svg',
    '/static/icons/layers.svg',
    '/static/icons/link.svg',
    '/static/icons/map-pin.svg',
    '/static/icons/more-vertical.svg',
    '/static/icons/navigation.svg',
    '/static/icons/share-2.svg',
    '/static/icons/tag.svg',
    '/static/icons/tool.svg',
    '/static/icons/x.svg',
    '/static/icons/youtube.svg',

    '/static/icons/trains/station.svg',
    '/static/tiles/tiles.json',
    '/dist/index.js',
    '/dist/meta.json',
    '/manifest.json',
  ]),
  withBackgroundPrecache(),
  withCleanup(),
  withUpdatePolling(),
  // Serves `<img src="/blob/sha256:…">` from the local blob store, falling
  // back to the sync server with auth attached (how lazy blob bodies load).
  // dbName must match BLOB_DB in store/app.ts.
  withBlobProxy({ dbName: 'me.bpev.maps.blobs' }),
  withFetchStrategy(),
])
