importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js');

firebase.initializeApp({
  apiKey: "AIzaSyBcoY_1ajskqS2TsSqsc-YI8RRtek_h3eY",
  authDomain: "newline-691b4.firebaseapp.com",
  projectId: "newline-691b4",
  storageBucket: "newline-691b4.firebasestorage.app",
  messagingSenderId: "509141563045",
  appId: "1:509141563045:web:4401a378be720ee0893f4c",
  measurementId: "G-YHTZBEVDKR"
});

const messaging = firebase.messaging();

messaging.onBackgroundMessage((payload) => {
  console.log("Background Message:", payload);

  self.registration.showNotification(
    payload.notification?.title || "Notification",
    {
      body: payload.notification?.body || "",
      icon: payload.notification?.image || "/logo192.png"
    }
  );
});