/*! * @license Firebase v4.10.1 * Build: rev-e70ef37 * Terms: https://firebase.google.com/terms/ */ try{webpackJsonpFirebase([3],{117:function(e,t,r){r(118)},118:function(e,t,r){"use strict";function o(e){var t=new Uint8Array(e);return window.btoa(String.fromCharCode.apply(null,t))}function n(e){if(e.objectStoreNames.contains(v)){var t=e.transaction(v),r=t.objectStore(v),o=new m,n=r.openCursor();n.onerror=function(e){console.warn("Unable to cleanup old IDB.",e)},n.onsuccess=function(){var t=n.result;if(t){var r=t.value;o.deleteToken(r.fcmSenderId,r.fcmToken,r.fcmPushSet),t.continue()}else e.close(),indexedDB.deleteDatabase(y)}}}function i(){var e=indexedDB.open(y);e.onerror=function(e){},e.onsuccess=function(t){n(e.result)}}function s(){}function a(e){var t=function(e){return self&&"ServiceWorkerGlobalScope"in self?new Y(e):new j(e)},r={Messaging:j};e.INTERNAL.registerService("messaging",t,r)}Object.defineProperty(t,"__esModule",{value:!0});var c,u=r(2),_=r(0),d={AVAILABLE_IN_WINDOW:"only-available-in-window",AVAILABLE_IN_SW:"only-available-in-sw",SHOULD_BE_INHERITED:"should-be-overriden",BAD_SENDER_ID:"bad-sender-id",INCORRECT_GCM_SENDER_ID:"incorrect-gcm-sender-id",PERMISSION_DEFAULT:"permission-default",PERMISSION_BLOCKED:"permission-blocked",UNSUPPORTED_BROWSER:"unsupported-browser",NOTIFICATIONS_BLOCKED:"notifications-blocked",FAILED_DEFAULT_REGISTRATION:"failed-serviceworker-registration",SW_REGISTRATION_EXPECTED:"sw-registration-expected",GET_SUBSCRIPTION_FAILED:"get-subscription-failed",INVALID_SAVED_TOKEN:"invalid-saved-token",SW_REG_REDUNDANT:"sw-reg-redundant",TOKEN_SUBSCRIBE_FAILED:"token-subscribe-failed",TOKEN_SUBSCRIBE_NO_TOKEN:"token-subscribe-no-token",TOKEN_SUBSCRIBE_NO_PUSH_SET:"token-subscribe-no-push-set",TOKEN_UNSUBSCRIBE_FAILED:"token-unsubscribe-failed",TOKEN_UPDATE_FAILED:"token-update-failed",TOKEN_UPDATE_NO_TOKEN:"token-update-no-token",USE_SW_BEFORE_GET_TOKEN:"use-sw-before-get-token",INVALID_DELETE_TOKEN:"invalid-delete-token",DELETE_TOKEN_NOT_FOUND:"delete-token-not-found",DELETE_SCOPE_NOT_FOUND:"delete-scope-not-found",BG_HANDLER_FUNCTION_EXPECTED:"bg-handler-function-expected",NO_WINDOW_CLIENT_TO_MSG:"no-window-client-to-msg",UNABLE_TO_RESUBSCRIBE:"unable-to-resubscribe",NO_FCM_TOKEN_FOR_RESUBSCRIBE:"no-fcm-token-for-resubscribe",FAILED_TO_DELETE_TOKEN:"failed-to-delete-token",NO_SW_IN_REG:"no-sw-in-reg",BAD_SCOPE:"bad-scope",BAD_VAPID_KEY:"bad-vapid-key",BAD_SUBSCRIPTION:"bad-subscription",BAD_TOKEN:"bad-token",BAD_PUSH_SET:"bad-push-set",FAILED_DELETE_VAPID_KEY:"failed-delete-vapid-key",INVALID_PUBLIC_VAPID_KEY:"invalid-public-vapid-key",USE_PUBLIC_KEY_BEFORE_GET_TOKEN:"use-public-key-before-get-token",PUBLIC_KEY_DECRYPTION_FAILED:"public-vapid-key-decryption-failed"},p=(c={},c[d.AVAILABLE_IN_WINDOW]="This method is available in a Window context.",c[d.AVAILABLE_IN_SW]="This method is available in a service worker context.",c["should-be-overriden"]="This method should be overriden by extended classes.",c["bad-sender-id"]="Please ensure that 'messagingSenderId' is set correctly in the options passed into firebase.initializeApp().",c["permission-default"]="The required permissions were not granted and dismissed instead.",c["permission-blocked"]="The required permissions were not granted and blocked instead.",c["unsupported-browser"]="This browser doesn't support the API's required to use the firebase SDK.",c["notifications-blocked"]="Notifications have been blocked.",c[d.FAILED_DEFAULT_REGISTRATION]="We are unable to register the default service worker. {$browserErrorMessage}",c["sw-registration-expected"]="A service worker registration was the expected input.",c["get-subscription-failed"]="There was an error when trying to get any existing Push Subscriptions.",c["invalid-saved-token"]="Unable to access details of the saved token.",c["sw-reg-redundant"]="The service worker being used for push was made redundant.",c["token-subscribe-failed"]="A problem occured while subscribing the user to FCM: {$message}",c["token-subscribe-no-token"]="FCM returned no token when subscribing the user to push.",c["token-subscribe-no-push-set"]="FCM returned an invalid response when getting an FCM token.",c["token-unsubscribe-failed"]="A problem occured while unsubscribing the user from FCM: {$message}",c["token-update-failed"]="A problem occured while updating the user from FCM: {$message}",c["token-update-no-token"]="FCM returned no token when updating the user to push.",c["use-sw-before-get-token"]="You must call useServiceWorker() before calling getToken() to ensure your service worker is used.",c["invalid-delete-token"]="You must pass a valid token into deleteToken(), i.e. the token from getToken().",c["delete-token-not-found"]="The deletion attempt for token could not be performed as the token was not found.",c["delete-scope-not-found"]="The deletion attempt for service worker scope could not be performed as the scope was not found.",c["bg-handler-function-expected"]="The input to setBackgroundMessageHandler() must be a function.",c["no-window-client-to-msg"]="An attempt was made to message a non-existant window client.",c["unable-to-resubscribe"]="There was an error while re-subscribing the FCM token for push messaging. Will have to resubscribe the user on next visit. {$message}",c["no-fcm-token-for-resubscribe"]="Could not find an FCM token and as a result, unable to resubscribe. Will have to resubscribe the user on next visit.",c["failed-to-delete-token"]="Unable to delete the currently saved token.",c["no-sw-in-reg"]="Even though the service worker registration was successful, there was a problem accessing the service worker itself.",c["incorrect-gcm-sender-id"]="Please change your web app manifest's 'gcm_sender_id' value to '103953800507' to use Firebase messaging.",c["bad-scope"]="The service worker scope must be a string with at least one character.",c["bad-vapid-key"]="The public VAPID key is not a Uint8Array with 65 bytes.",c["bad-subscription"]="The subscription must be a valid PushSubscription.",c["bad-token"]="The FCM Token used for storage / lookup was not a valid token string.",c["bad-push-set"]="The FCM push set used for storage / lookup was not not a valid push set string.",c["failed-delete-vapid-key"]="The VAPID key could not be deleted.",c["invalid-public-vapid-key"]="The public VAPID key must be a string.",c[d.PUBLIC_KEY_DECRYPTION_FAILED]="The public VAPID key did not equal 65 bytes when decrypted.",c),f={codes:d,map:p},h=function(){function e(e,t){this.e=new _.ErrorFactory("messaging","Messaging",f.map),this.t=e,this.r=t,this.o=null,this.TRANSACTION_READ_WRITE="readwrite"}return e.prototype.openDatabase=function(){var e=this;return this.o?this.o:(this.o=new Promise(function(t,r){var o=indexedDB.open(e.t,e.r);o.onerror=function(e){r(e.target.error)},o.onsuccess=function(e){t(e.target.result)},o.onupgradeneeded=function(t){try{var o=t.target.result;e.onDBUpgrade(o,t)}catch(e){o.close(),r(e)}}}),this.o)},e.prototype.closeDatabase=function(){var e=this;return Promise.resolve().then(function(){if(e.o)return e.o.then(function(t){t.close(),e.o=null})})},e.prototype.onDBUpgrade=function(e,t){throw this.e.create(f.codes.SHOULD_BE_INHERITED)},e}(),l=h,g=function(e){return o(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},E=new Uint8Array([4,51,148,247,223,161,235,177,220,3,162,94,21,113,219,72,211,46,237,237,178,52,219,183,71,58,12,143,196,204,225,111,60,140,132,223,171,182,102,62,242,12,212,139,254,227,249,118,47,20,28,99,8,106,111,45,177,26,149,176,206,55,192,156,110]),S={userVisibleOnly:!0,applicationServerKey:E},T={DEFAULT_PUBLIC_VAPID_KEY:E,SUBSCRIPTION_DETAILS:S,ENDPOINT:"https://fcm.googleapis.com"},b=function(){function e(){this.e=new _.ErrorFactory("messaging","Messaging",f.map)}return e.prototype.getToken=function(e,t,r){var o=this,n=g(t.getKey("p256dh")),i=g(t.getKey("auth")),s="authorized_entity="+e+"&endpoint="+t.endpoint+"&encryption_key="+n+"&encryption_auth="+i;r!==T.DEFAULT_PUBLIC_VAPID_KEY&&(s+="&application_pub_key="+g(r));var a=new Headers;a.append("Content-Type","application/x-www-form-urlencoded");var c={method:"POST",headers:a,body:s};return fetch(T.ENDPOINT+"/fcm/connect/subscribe",c).then(function(e){return e.json()}).catch(function(){throw o.e.create(f.codes.TOKEN_SUBSCRIBE_FAILED)}).then(function(e){var t=e;if(t.error){var r=t.error.message;throw o.e.create(f.codes.TOKEN_SUBSCRIBE_FAILED,{message:r})}if(!t.token)throw o.e.create(f.codes.TOKEN_SUBSCRIBE_NO_TOKEN);if(!t.pushSet)throw o.e.create(f.codes.TOKEN_SUBSCRIBE_NO_PUSH_SET);return{token:t.token,pushSet:t.pushSet}})},e.prototype.updateToken=function(e,t,r,o,n){var i=this,s=g(o.getKey("p256dh")),a=g(o.getKey("auth")),c="push_set="+r+"&token="+t+"&authorized_entity="+e+"&endpoint="+o.endpoint+"&encryption_key="+s+"&encryption_auth="+a;n!==T.DEFAULT_PUBLIC_VAPID_KEY&&(c+="&application_pub_key="+g(n));var u=new Headers;u.append("Content-Type","application/x-www-form-urlencoded");var _,d={method:"POST",headers:u,body:c};return fetch(T.ENDPOINT+"/fcm/connect/subscribe",d).then(function(e){return _=e,e.json()}).catch(function(){throw i.e.create(f.codes.TOKEN_UPDATE_FAILED)}).then(function(e){if(!_.ok){var t=e.error.message;throw i.e.create(f.codes.TOKEN_UPDATE_FAILED,{message:t})}if(!e.token)throw i.e.create(f.codes.TOKEN_UPDATE_NO_TOKEN);return e.token})},e.prototype.deleteToken=function(e,t,r){var o=this,n="authorized_entity="+e+"&token="+t+"&pushSet="+r,i=new Headers;i.append("Content-Type","application/x-www-form-urlencoded");var s={method:"POST",headers:i,body:n};return fetch(T.ENDPOINT+"/fcm/connect/unsubscribe",s).then(function(e){if(!e.ok)return e.json().then(function(e){if(e.error){var t=e.error.message;throw o.e.create(f.codes.TOKEN_UNSUBSCRIBE_FAILED,{message:t})}},function(e){throw o.e.create(f.codes.TOKEN_UNSUBSCRIBE_FAILED)})})},e}(),m=b,y="undefined",v="fcm_token_object_Store",D="fcm_token_details_db",I=2;s.prototype.fcmToken,s.prototype.swScope,s.prototype.vapidKey,s.prototype.subscription,s.prototype.fcmSenderId,s.prototype.fcmPushSet;var k=function(e){function t(){return e.call(this,D,I)||this}return u.__extends(t,e),t.prototype.onDBUpgrade=function(e,t){if(t.oldVersion<1){var r=e.createObjectStore("fcm_token_object_Store",{keyPath:"swScope"});r.createIndex("fcmSenderId","fcmSenderId",{unique:!1}),r.createIndex("fcmToken","fcmToken",{unique:!0})}t.oldVersion<2&&i()},t.prototype.n=function(e){return u.__awaiter(this,void 0,void 0,function(){return u.__generator(this,function(t){return!e.fcmToken||"string"==typeof e.fcmToken&&0!==e.fcmToken.length?!e.swScope||"string"==typeof e.swScope&&0!==e.swScope.length?!e.vapidKey||e.vapidKey instanceof Uint8Array&&65===e.vapidKey.length?!e.subscription||e.subscription instanceof PushSubscription?!e.fcmSenderId||"string"==typeof e.fcmSenderId&&0!==e.fcmSenderId.length?!e.fcmPushSet||"string"==typeof e.fcmPushSet&&0!==e.fcmPushSet.length?[2]:[2,Promise.reject(this.e.create(f.codes.BAD_PUSH_SET))]:[2,Promise.reject(this.e.create(f.codes.BAD_SENDER_ID))]:[2,Promise.reject(this.e.create(f.codes.BAD_SUBSCRIPTION))]:[2,Promise.reject(this.e.create(f.codes.BAD_VAPID_KEY))]:[2,Promise.reject(this.e.create(f.codes.BAD_SCOPE))]:[2,Promise.reject(this.e.create(f.codes.BAD_TOKEN))]})})},t.prototype.getTokenDetailsFromToken=function(e){var t=this;return e?this.n({fcmToken:e}).then(function(){return t.openDatabase()}).then(function(t){return new Promise(function(r,o){var n=t.transaction(["fcm_token_object_Store"]),i=n.objectStore("fcm_token_object_Store"),s=i.index("fcmToken"),a=s.get(e);a.onerror=function(e){o(e.target.error)},a.onsuccess=function(e){var t=e.target.result?e.target.result:null;r(t)}})}):Promise.reject(this.e.create(f.codes.BAD_TOKEN))},t.prototype.getTokenDetailsFromSWScope=function(e){var t=this;return e?this.n({swScope:e}).then(function(){return t.openDatabase()}).then(function(t){return new Promise(function(r,o){var n=t.transaction(["fcm_token_object_Store"]),i=n.objectStore("fcm_token_object_Store"),s=i.get(e);s.onerror=function(e){o(e.target.error)},s.onsuccess=function(e){var t=e.target.result?e.target.result:null;r(t)}})}):Promise.reject(this.e.create(f.codes.BAD_SCOPE))},t.prototype.saveTokenDetails=function(e){var t=this,r=e.swScope,o=e.vapidKey,n=e.subscription,i=e.fcmSenderId,s=e.fcmToken,a=e.fcmPushSet;return r?o?n?i?s?a?this.n({swScope:r,vapidKey:o,subscription:n,fcmSenderId:i,fcmToken:s,fcmPushSet:a}).then(function(){return t.openDatabase()}).then(function(e){var c={swScope:r,vapidKey:g(o),endpoint:n.endpoint,auth:g(n.getKey("auth")),p256dh:g(n.getKey("p256dh")),fcmSenderId:i,fcmToken:s,fcmPushSet:a,createTime:Date.now()};return new Promise(function(r,o){var n=e.transaction(["fcm_token_object_Store"],t.TRANSACTION_READ_WRITE),i=n.objectStore("fcm_token_object_Store"),s=i.put(c);s.onerror=function(e){o(e.target.error)},s.onsuccess=function(e){r()}})}):Promise.reject(this.e.create(f.codes.BAD_PUSH_SET)):Promise.reject(this.e.create(f.codes.BAD_TOKEN)):Promise.reject(this.e.create(f.codes.BAD_SENDER_ID)):Promise.reject(this.e.create(f.codes.BAD_SUBSCRIPTION)):Promise.reject(this.e.create(f.codes.BAD_VAPID_KEY)):Promise.reject(this.e.create(f.codes.BAD_SCOPE))},t.prototype.deleteToken=function(e){var t=this;return"string"!=typeof e||0===e.length?Promise.reject(this.e.create(f.codes.INVALID_DELETE_TOKEN)):this.getTokenDetailsFromToken(e).then(function(e){if(!e)throw t.e.create(f.codes.DELETE_TOKEN_NOT_FOUND);return t.openDatabase().then(function(r){return new Promise(function(o,n){var i=r.transaction(["fcm_token_object_Store"],t.TRANSACTION_READ_WRITE),s=i.objectStore("fcm_token_object_Store"),a=s.delete(e.swScope);a.onerror=function(e){n(e.target.error)},a.onsuccess=function(r){if(0===r.target.result)return void n(t.e.create(f.codes.FAILED_TO_DELETE_TOKEN));o(e)}})})})},t}(l),w=k,N="fcm_vapid_details_db",P=1,A=function(e){function t(){return e.call(this,N,P)||this}return u.__extends(t,e),t.prototype.onDBUpgrade=function(e){e.createObjectStore("fcm_vapid_object_Store",{keyPath:"swScope"})},t.prototype.getVapidFromSWScope=function(e){return"string"!=typeof e||0===e.length?Promise.reject(this.e.create(f.codes.BAD_SCOPE)):this.openDatabase().then(function(t){return new Promise(function(r,o){var n=t.transaction(["fcm_vapid_object_Store"]),i=n.objectStore("fcm_vapid_object_Store"),s=i.get(e);s.onerror=function(){o(s.error)},s.onsuccess=function(){var e=s.result,t=null;e&&(t=e.vapidKey),r(t)}})})},t.prototype.saveVapidDetails=function(e,t){var r=this;if("string"!=typeof e||0===e.length)return Promise.reject(this.e.create(f.codes.BAD_SCOPE));if(null===t||65!==t.length)return Promise.reject(this.e.create(f.codes.BAD_VAPID_KEY));var o={swScope:e,vapidKey:t};return this.openDatabase().then(function(e){return new Promise(function(t,n){var i=e.transaction(["fcm_vapid_object_Store"],r.TRANSACTION_READ_WRITE),s=i.objectStore("fcm_vapid_object_Store"),a=s.put(o);a.onerror=function(){n(a.error)},a.onsuccess=function(){t()}})})},t.prototype.deleteVapidDetails=function(e){var t=this;return this.getVapidFromSWScope(e).then(function(r){if(!r)throw t.e.create(f.codes.DELETE_SCOPE_NOT_FOUND);return t.openDatabase().then(function(o){return new Promise(function(n,i){var s=o.transaction(["fcm_vapid_object_Store"],t.TRANSACTION_READ_WRITE),a=s.objectStore("fcm_vapid_object_Store"),c=a.delete(e);c.onerror=function(){i(c.error)},c.onsuccess=function(){if(0===c.result)return void i(t.e.create(f.codes.FAILED_DELETE_VAPID_KEY));n(r)}})})})},t}(l),O=A,F="messagingSenderId",C=function(){function e(e){var t=this;if(this.e=new _.ErrorFactory("messaging","Messaging",f.map),!e.options[F]||"string"!=typeof e.options[F])throw this.e.create(f.codes.BAD_SENDER_ID);this.i=e.options[F],this.s=new w,this.a=new O,this.c=new m,this.app=e,this.INTERNAL={},this.INTERNAL.delete=function(){return t.delete()}}return e.prototype.getToken=function(){var e=this,t=this.u();if("granted"!==t)return"denied"===t?Promise.reject(this.e.create(f.codes.NOTIFICATIONS_BLOCKED)):Promise.resolve(null);var r;return this._().then(function(t){return r=t,e.s.getTokenDetailsFromSWScope(r.scope)}).then(function(t){return t?e.manageExistingToken(t,r):e.getNewToken(r)})},e.prototype.manageExistingToken=function(e,t){var r=this;return this.isTokenStillValid(e).then(function(o){return o?Date.now()