!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).firebase)}(this,function(at){"use strict";try{(function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(at),n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var p=function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;ns[0]&&t[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(){for(var e=[],t=0;t"})):"Error",e=this.serviceName+": "+e+" ("+o+").",s=new l(o,e),a=0,u=Object.keys(i);a=s.createTime+6048e5?[2,function(i,o,s){return d(this,void 0,void 0,function(){var t,n,r;return h(this,function(e){switch(e.label){case 0:return e.trys.push([0,3,,5]),[4,function(o,s){return d(this,void 0,void 0,function(){var t,n,r,i;return h(this,function(e){switch(e.label){case 0:return[4,Ge(o)];case 1:t=e.sent(),n=ze(s.subscriptionOptions),n={method:"PATCH",headers:t,body:JSON.stringify(n)},e.label=2;case 2:return e.trys.push([2,5,,6]),[4,fetch($e(o.appConfig)+"/"+s.token,n)];case 3:return[4,e.sent().json()];case 4:return r=e.sent(),[3,6];case 5:throw i=e.sent(),Pe.create("token-update-failed",{errorInfo:i});case 6:if(r.error)throw i=r.error.message,Pe.create("token-update-failed",{errorInfo:i});if(!r.token)throw Pe.create("token-update-no-token");return[2,r.token]}})})}(o,i)];case 1:return t=e.sent(),n=p(p({},i),{token:t,createTime:Date.now()}),[4,Ue(o,n)];case 2:return e.sent(),[2,t];case 3:return r=e.sent(),[4,Ye(o,s)];case 4:throw e.sent(),r;case 5:return[2]}})})}({token:s.token,createTime:Date.now(),subscriptionOptions:a},c,l)]:[2,s.token];case 9:return[2]}var t,n,r,i,o})})}function Ye(n,r){return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return[4,Fe(n)];case 1:return(t=e.sent())?[4,He(n,t.token)]:[3,4];case 2:return e.sent(),[4,function(r){return d(this,void 0,void 0,function(){var t,n;return h(this,function(e){switch(e.label){case 0:return t=We(r),[4,Ve()];case 1:return n=e.sent(),[4,(n=n.transaction(Be,"readwrite")).objectStore(Be).delete(t)];case 2:return e.sent(),[4,n.complete];case 3:return e.sent(),[2]}})})}(n)];case 3:e.sent(),e.label=4;case 4:return[4,r.pushManager.getSubscription()];case 5:return(t=e.sent())?[2,t.unsubscribe()]:[2,!0]}})})}function Ze(n,r){return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return[4,function(o,s){return d(this,void 0,void 0,function(){var t,n,r,i;return h(this,function(e){switch(e.label){case 0:return[4,Ge(o)];case 1:t=e.sent(),n=ze(s),n={method:"POST",headers:t,body:JSON.stringify(n)},e.label=2;case 2:return e.trys.push([2,5,,6]),[4,fetch($e(o.appConfig),n)];case 3:return[4,e.sent().json()];case 4:return r=e.sent(),[3,6];case 5:throw i=e.sent(),Pe.create("token-subscribe-failed",{errorInfo:i});case 6:if(r.error)throw i=r.error.message,Pe.create("token-subscribe-failed",{errorInfo:i});if(!r.token)throw Pe.create("token-subscribe-no-token");return[2,r.token]}})})}(n,r)];case 1:return t=e.sent(),t={token:t,createTime:Date.now(),subscriptionOptions:r},[4,Ue(n,t)];case 2:return e.sent(),[2,t.token]}})})}function Qe(e){var t={from:e.from,collapseKey:e.collapse_key};return function(e,t){if(!t.notification)return;e.notification={};var n=t.notification.title;n&&(e.notification.title=n);n=t.notification.body;n&&(e.notification.body=n);t=t.notification.image;t&&(e.notification.image=t)}(t,e),function(e,t){if(!t.data)return;e.data=t.data}(t,e),function(e,t){if(!t.fcmOptions)return;e.fcmOptions={};var n=t.fcmOptions.link;n&&(e.fcmOptions.link=n);t=t.fcmOptions.analytics_label;t&&(e.fcmOptions.analyticsLabel=t)}(t,e),t}function Xe(e){return"object"==typeof e&&e&&Ee in e}var et=(Object.defineProperty(tt.prototype,"app",{get:function(){return this.firebaseDependencies.app},enumerable:!1,configurable:!0}),tt.prototype.setBackgroundMessageHandler=function(e){if(this.isOnBackgroundMessageUsed=!1,!e||"function"!=typeof e)throw Pe.create("invalid-bg-handler");this.bgMessageHandler=e},tt.prototype.onBackgroundMessage=function(e){var t=this;return this.isOnBackgroundMessageUsed=!0,this.bgMessageHandler=e,function(){t.bgMessageHandler=null}},tt.prototype.getToken=function(){var n;return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return this.vapidKey?[3,2]:[4,Fe(this.firebaseDependencies)];case 1:t=e.sent(),this.vapidKey=null!==(n=null===(n=null==t?void 0:t.subscriptionOptions)||void 0===n?void 0:n.vapidKey)&&void 0!==n?n:je,e.label=2;case 2:return[2,Je(this.firebaseDependencies,self.registration,this.vapidKey)]}})})},tt.prototype.deleteToken=function(){return Ye(this.firebaseDependencies,self.registration)},tt.prototype.requestPermission=function(){throw Pe.create("only-available-in-window")},tt.prototype.usePublicVapidKey=function(e){if(null!==this.vapidKey)throw Pe.create("use-vapid-key-after-get-token");if("string"!=typeof e||0===e.length)throw Pe.create("invalid-vapid-key");this.vapidKey=e},tt.prototype.useServiceWorker=function(){throw Pe.create("only-available-in-window")},tt.prototype.onMessage=function(){throw Pe.create("only-available-in-window")},tt.prototype.onTokenRefresh=function(){throw Pe.create("only-available-in-window")},tt.prototype.onPush=function(a){return d(this,void 0,void 0,function(){var i,o,s;return h(this,function(e){switch(e.label){case 0:return(s=function(e){var t=e.data;if(!t)return null;try{return t.json()}catch(e){return null}}(a))?[4,nt()]:(console.debug("FirebaseMessaging: failed to get parsed MessagePayload from the PushEvent. Skip handling the push."),[2]);case 1:return(i=e.sent(),i.some(function(e){return"visible"===e.visibilityState&&!e.url.startsWith("chrome-extension://")}))?[2,function(e,t){var n,r;t.isFirebaseMessaging=!0,t.messageType=_e.PUSH_RECEIVED;try{for(var i=c(e),o=i.next();!o.done;o=i.next()){o.value.postMessage(t)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}(i,s)]:(o=!1,s.notification?[4,function(e){var t=e.actions,n=Notification.maxActions;t&&n&&t.length>n&&console.warn("This browser only supports "+n+" actions. The remaining actions will not be displayed.");return self.registration.showNotification(null!==(n=e.title)&&void 0!==n?n:"",e)}(((r=p({},(t=s).notification)).data=((n={})[De]=t,n),r))]:[3,3]);case 2:e.sent(),o=!0,e.label=3;case 3:return!0===o&&!1===this.isOnBackgroundMessageUsed?[2]:(this.bgMessageHandler&&(s=Qe(s),"function"==typeof this.bgMessageHandler?this.bgMessageHandler(s):this.bgMessageHandler.next(s)),[2])}var t,n,r})})},tt.prototype.onSubChange=function(n){var r;return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return n.newSubscription?[3,2]:[4,Ye(this.firebaseDependencies,self.registration)];case 1:return e.sent(),[2];case 2:return[4,Fe(this.firebaseDependencies)];case 3:return t=e.sent(),[4,Ye(this.firebaseDependencies,self.registration)];case 4:return e.sent(),[4,Je(this.firebaseDependencies,self.registration,null!==(r=null===(r=null==t?void 0:t.subscriptionOptions)||void 0===r?void 0:r.vapidKey)&&void 0!==r?r:je)];case 5:return e.sent(),[2]}})})},tt.prototype.onNotificationClick=function(a){var u;return d(this,void 0,void 0,function(){var n,r,i,o,s;return h(this,function(e){switch(e.label){case 0:return(n=null===(u=null===(u=a.notification)||void 0===u?void 0:u.data)||void 0===u?void 0:u[De])?a.action?[2]:(a.stopImmediatePropagation(),a.notification.close(),(r=function(e){var t,n=null!==(t=null===(t=e.fcmOptions)||void 0===t?void 0:t.link)&&void 0!==t?t:null===(n=e.notification)||void 0===n?void 0:n.click_action;if(n)return n;return Xe(e.data)?self.location.origin:null}(n))?(i=new URL(r,self.location.href),o=new URL(self.location.origin),i.host!==o.host?[2]:[4,function(u){return d(this,void 0,void 0,function(){var t,n,r,i,o,s,a;return h(this,function(e){switch(e.label){case 0:return[4,nt()];case 1:t=e.sent();try{for(n=c(t),r=n.next();!r.done;r=n.next())if(i=r.value,o=new URL(i.url,self.location.href),u.host===o.host)return[2,i]}catch(e){s={error:e}}finally{try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}}return[2,null]}})})}(i)]):[2]):[2];case 1:return(s=e.sent())?[3,4]:[4,self.clients.openWindow(r)];case 2:return s=e.sent(),[4,(t=3e3,new Promise(function(e){setTimeout(e,t)}))];case 3:return e.sent(),[3,6];case 4:return[4,s.focus()];case 5:s=e.sent(),e.label=6;case 6:return s?(n.messageType=_e.NOTIFICATION_CLICKED,n.isFirebaseMessaging=!0,[2,s.postMessage(n)]):[2]}var t})})},tt);function tt(e){var t=this;this.firebaseDependencies=e,this.isOnBackgroundMessageUsed=null,this.vapidKey=null,this.bgMessageHandler=null,self.addEventListener("push",function(e){e.waitUntil(t.onPush(e))}),self.addEventListener("pushsubscriptionchange",function(e){e.waitUntil(t.onSubChange(e))}),self.addEventListener("notificationclick",function(e){e.waitUntil(t.onNotificationClick(e))})}function nt(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}var rt=(Object.defineProperty(it.prototype,"app",{get:function(){return this.firebaseDependencies.app},enumerable:!1,configurable:!0}),it.prototype.messageEventListener=function(i){return d(this,void 0,void 0,function(){var n,r;return h(this,function(e){switch(e.label){case 0:return(n=i.data).isFirebaseMessaging?(this.onMessageCallback&&n.messageType===_e.PUSH_RECEIVED&&("function"==typeof this.onMessageCallback?this.onMessageCallback((delete(t=Object.assign({},n)).messageType,delete t.isFirebaseMessaging,t)):this.onMessageCallback.next(Object.assign({},n))),Xe(r=n.data)&&"1"===r["google.c.a.e"]?[4,this.logEvent(n.messageType,r)]:[3,2]):[2];case 1:e.sent(),e.label=2;case 2:return[2]}var t})})},it.prototype.getVapidKey=function(){return this.vapidKey},it.prototype.getSwReg=function(){return this.swRegistration},it.prototype.getToken=function(t){return d(this,void 0,void 0,function(){return h(this,function(e){switch(e.label){case 0:return"default"!==Notification.permission?[3,2]:[4,Notification.requestPermission()];case 1:e.sent(),e.label=2;case 2:if("granted"!==Notification.permission)throw Pe.create("permission-blocked");return[4,this.updateVapidKey(null==t?void 0:t.vapidKey)];case 3:return e.sent(),[4,this.updateSwReg(null==t?void 0:t.serviceWorkerRegistration)];case 4:return e.sent(),[2,Je(this.firebaseDependencies,this.swRegistration,this.vapidKey)]}})})},it.prototype.updateVapidKey=function(t){return d(this,void 0,void 0,function(){return h(this,function(e){return t?this.vapidKey=t:this.vapidKey||(this.vapidKey=je),[2]})})},it.prototype.updateSwReg=function(t){return d(this,void 0,void 0,function(){return h(this,function(e){switch(e.label){case 0:return t||this.swRegistration?[3,2]:[4,this.registerDefaultSw()];case 1:e.sent(),e.label=2;case 2:if(!t&&this.swRegistration)return[2];if(!(t instanceof ServiceWorkerRegistration))throw Pe.create("invalid-sw-registration");return this.swRegistration=t,[2]}})})},it.prototype.registerDefaultSw=function(){return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=this,[4,navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"})];case 1:return t.swRegistration=e.sent(),this.swRegistration.update().catch(function(){}),[3,3];case 2:throw t=e.sent(),Pe.create("failed-service-worker-registration",{browserErrorMessage:t.message});case 3:return[2]}})})},it.prototype.deleteToken=function(){return d(this,void 0,void 0,function(){return h(this,function(e){switch(e.label){case 0:return this.swRegistration?[3,2]:[4,this.registerDefaultSw()];case 1:e.sent(),e.label=2;case 2:return[2,Ye(this.firebaseDependencies,this.swRegistration)]}})})},it.prototype.requestPermission=function(){return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return"granted"===Notification.permission?[2]:[4,Notification.requestPermission()];case 1:if("granted"===(t=e.sent()))return[2];throw"denied"===t?Pe.create("permission-blocked"):Pe.create("permission-default")}})})},it.prototype.usePublicVapidKey=function(e){if(null!==this.vapidKey)throw Pe.create("use-vapid-key-after-get-token");if("string"!=typeof e||0===e.length)throw Pe.create("invalid-vapid-key");this.vapidKey=e},it.prototype.useServiceWorker=function(e){if(!(e instanceof ServiceWorkerRegistration))throw Pe.create("invalid-sw-registration");if(this.swRegistration)throw Pe.create("use-sw-after-get-token");this.swRegistration=e},it.prototype.onMessage=function(e){var t=this;return this.onMessageCallback=e,function(){t.onMessageCallback=null}},it.prototype.setBackgroundMessageHandler=function(){throw Pe.create("only-available-in-sw")},it.prototype.onBackgroundMessage=function(){throw Pe.create("only-available-in-sw")},it.prototype.onTokenRefresh=function(){return function(){}},it.prototype.logEvent=function(n,r){return d(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return t=function(e){switch(e){case _e.NOTIFICATION_CLICKED:return"notification_open";case _e.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}(n),[4,this.firebaseDependencies.analyticsProvider.get()];case 1:return e.sent().logEvent(t,{message_id:r[Ee],message_name:r["google.c.a.c_l"],message_time:r["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)}),[2]}})})},it);function it(e){var t=this;this.firebaseDependencies=e,this.vapidKey=null,this.onMessageCallback=null,navigator.serviceWorker.addEventListener("message",function(e){return t.messageEventListener(e)})}function ot(e){return Pe.create("missing-app-config-values",{valueName:e})}L={isSupported:st};function st(){return self&&"ServiceWorkerGlobalScope"in self?"indexedDB"in self&&null!==indexedDB&&"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):"indexedDB"in window&&null!==indexedDB&&navigator.cookieEnabled&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}t.default.INTERNAL.registerComponent(new y("messaging",function(e){var t=e.getProvider("app").getImmediate(),e={app:t,appConfig:function(e){var t,n;if(!e||!e.options)throw ot("App Configuration Object");if(!e.name)throw ot("App Name");var r=e.options;try{for(var i=c(["projectId","apiKey","appId","messagingSenderId"]),o=i.next();!o.done;o=i.next()){var s=o.value;if(!r[s])throw ot(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return{appName:e.name,projectId:r.projectId,apiKey:r.apiKey,appId:r.appId,senderId:r.messagingSenderId}}(t),installations:e.getProvider("installations").getImmediate(),analyticsProvider:e.getProvider("analytics-internal")};if(!st())throw Pe.create("unsupported-browser");return new(self&&"ServiceWorkerGlobalScope"in self?et:rt)(e)},"PUBLIC").setServiceProps(L))}).apply(this,arguments)}catch(e){throw console.error(e),new Error("Cannot instantiate firebase-messaging.js - be sure to load firebase-app.js first.")}}); //# sourceMappingURL=firebase-messaging.js.map