self.addEventListener('notificationclick', (event) => { event.notification.close() event.waitUntil((async () => { const windows = await clients.matchAll({ type: 'window', includeUncontrolled: true }) for (const client of windows) { if ('focus' in client) return client.focus() } if (clients.openWindow) return clients.openWindow('/') })()) })