/* eslint-disable no-undef */
importScripts('https://www.gstatic.com/firebasejs/10.12.0/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/10.12.0/firebase-messaging-compat.js');

firebase.initializeApp({
  apiKey: 'AIzaSyCdFk-SKrv3Xyvx63VT3jqz2TJSGRp5zFY',
  authDomain: 'baboon-1125.firebaseapp.com',
  projectId: 'baboon-1125',
  storageBucket: 'baboon-1125.appspot.com',
  messagingSenderId: '777937716876',
  appId: '1:777937716876:web:0ebe6c4d231db36b27dda9',
});

const messaging = firebase.messaging();

messaging.onBackgroundMessage((payload) => {
  const { title, body, icon } = payload.notification || {};
  self.registration.showNotification(title || 'Baboon', {
    body: body || '',
    icon: icon || '/icons/icon-192x192.png',
  });
});
