import{W as a}from"./index-Ec65i0Q1.js";import{i as o,g as r,o as c,a as d,d as l}from"./firebase-COmdod-u.js";import"./three-Cs75aIhT.js";import"./react-CYZQF_UV.js";import"./livekit-IBzVVcEu.js";class s extends a{constructor(){super(),o().then(i=>{if(!i)return;const e=r();c(e,t=>this.handleNotificationReceived(t))})}async checkPermissions(){return await o()?{receive:this.convertNotificationPermissionToPermissionState(Notification.permission)}:{receive:"denied"}}async requestPermissions(){if(!await o())return{receive:"denied"};const e=await Notification.requestPermission();return{receive:this.convertNotificationPermissionToPermissionState(e)}}async isSupported(){return{isSupported:await o()}}async getToken(i){const e=r();return{token:await d(e,{vapidKey:i.vapidKey,serviceWorkerRegistration:i.serviceWorkerRegistration})}}async deleteToken(){const i=r();await l(i)}async getDeliveredNotifications(){this.throwUnavailableError()}async removeDeliveredNotifications(i){this.throwUnavailableError()}async removeAllDeliveredNotifications(){this.throwUnavailableError()}async subscribeToTopic(i){this.throwUnavailableError()}async unsubscribeFromTopic(i){this.throwUnavailableError()}async createChannel(i){this.throwUnavailableError()}async deleteChannel(i){this.throwUnavailableError()}async listChannels(){this.throwUnavailableError()}handleNotificationReceived(i){const t={notification:this.createNotificationResult(i)};this.notifyListeners(s.notificationReceivedEvent,t)}createNotificationResult(i){var e,t,n;return{body:(e=i.notification)===null||e===void 0?void 0:e.body,data:i.data,id:i.messageId,image:(t=i.notification)===null||t===void 0?void 0:t.image,title:(n=i.notification)===null||n===void 0?void 0:n.title}}convertNotificationPermissionToPermissionState(i){let e="prompt";switch(i){case"granted":e="granted";break;case"denied":e="denied";break}return e}throwUnavailableError(){throw this.unavailable("Not available on web.")}}s.notificationReceivedEvent="notificationReceived";export{s as FirebaseMessagingWeb};
