1// Served from the site root so the browser can register it as the FCM 2// background service worker. Loaded directly (not bundled), so it can't 3// read Vite env vars â Firebase web config values are public client 4// identifiers, not secrets, so inlining them here is standard practice. 5importScripts('https://www.gstatic.com/firebasejs/10.14.1/firebase-app-compat.js'); 6importScripts('https://www.gstatic.com/firebasejs/10.14.1/firebase-messaging-compat.js'); 7 8firebase.initializeApp({ 9 apiKey: "AIzaSyAaiGD0yIdxhmFRi0IEI2xvVT8hIF0W3fY", 10 authDomain: "qalum-ai.firebaseapp.com", 11 projectId: "qalum-ai", 12 storageBucket: "qalum-ai.firebasestorage.app", 13 messagingSenderId: "456541972099", 14 appId: "1:456541972099:web:895adfd53918c77eef5db6", 15}); 16 17const messaging = firebase.messaging(); 18 19messaging.onBackgroundMessage((payload) => { 20 const { title, body, icon } = payload.notification || {}; 21 const data = payload.data || {}; 22 self.registration.showNotification(title || 'Qalum AI', { 23 body, 24 icon: icon || '/assets/images/logo.png', 25 // Carry the click target + any ids so notificationclick can route. 26 data: { link: data.link || '/dashboard/notifications', ...data }, 27 }); 28}); 29 30// Tapping the OS notification focuses an existing tab (navigating it to the 31// deep link) or opens a new one â so the user lands on the hunted content. 32self.addEventListener('notificationclick', (event) => { 33 event.notification.close(); 34 const target = (event.notification.data && event.notification.data.link) || '/dashboard/notifications'; 35 event.waitUntil( 36 (async () => { 37 const allClients = await self.clients.matchAll({ type: 'window', includeUncontrolled: true }); 38 for (const client of allClients) { 39 if ('focus' in client) { 40 try { 41 if ('navigate' in client) await client.navigate(target); 42 } catch (_e) { 43 /* cross-origin or blocked â fall through to focus */ 44 } 45 return client.focus(); 46 } 47 } 48 if (self.clients.openWindow) return self.clients.openWindow(target); 49 })() 50 ); 51});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.