diff --git a/README.md b/README.md index f64963ce..00fc7916 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Package | Downloads | Latest | Changelog @nuxtjs/meta | [![npm](https://img.shields.io/npm/dt/@nuxtjs/meta.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/meta) | [![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/meta/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/meta) | [Changelog](https://github.com/nuxt-community/pwa-module/blob/master/packages/meta/CHANGELOG.md) @nuxtjs/workbox | [![npm](https://img.shields.io/npm/dt/@nuxtjs/workbox.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/workbox) | [![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/workbox/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/workbox) | [Changelog](https://github.com/nuxt-community/pwa-module/blob/master/packages/workbox/CHANGELOG.md) @nuxtjs/icon | [![npm](https://img.shields.io/npm/dt/@nuxtjs/icon.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/icon) | [![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/icon/latest.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/icon) | [Changelog](https://github.com/nuxt-community/pwa-module/blob/master/packages/icon/CHANGELOG.md) +@nuxtjs/onesignal | [![npm](https://img.shields.io/npm/dt/@nuxtjs/onesignal.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/onesignal) | [![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/onesignal/latest.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/onesignal) | [Changelog](https://github.com/nuxt-community/pwa-module/blob/master/packages/onesignal/CHANGELOG.md) ## Contents @@ -32,6 +33,7 @@ Package | Downloads | Latest | Changelog - [Workbox](#workbox) - [Icon](#icon) - [Meta](#meta) +- [OneSignal](#onesignal) ## Quick Setup @@ -157,6 +159,75 @@ Please read this resources if you want to enable `mobileAppIOS` option: - https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html - https://medium.com/@firt/dont-use-ios-web-app-meta-tag-irresponsibly-in-your-progressive-web-apps-85d70f4438cb +## OneSignal +OneSignal is a Free, high volume and reliable push notification service for websites and mobile applications.[Learn More](https://documentation.onesignal.com/docs/product-overview) + +Setting and and using this module is little tricky as OneSignal requires to register it's own Service worker. (see [Web Push SDK Setup (HTTPS)](https://documentation.onesignal.com/docs/web-push-sdk-setup-https)) + +First add dependency as it is not being installed by default when using PWA module: + +```bash +yarn add @nuxtjs/onesignal +# OR +npm i @nuxtjs/onesignal +``` + +Then add module to `nuxt.config.js` **BEFORE** `@nuxtjs/pwa` and provide options under `oneSignal`: + +```js +modules: [ + '@nuxtjs/onesignal', + '@nuxtjs/pwa', +], + +// Options +oneSignal: { + appId: 'YOUR_APP_ID', + // ...your other init settings +} +``` + +### Async Functions +This module exposes oneSignal as `$OneSignal` everywhere. So you can call it. +Please note that because of async loading of OneSignal SDK script, every action should be pushed into `$OneSignal` stack. + +```js +// Inside page components +this.$OneSignal.push(() => { + this.$OneSignal.isPushNotificationsEnabled((isEnabled) => { + if (isEnabled) { + console.log('Push notifications are enabled!') + } else { + console.log('Push notifications are not enabled yet.') + } + }) +}) + +// Using window and array form +window.$OneSignal.push(['addListenerForNotificationOpened', (data) => { + console.log('Received NotificationOpened:', data } +]); +``` + +### Change OneSignal SDK Script URL + +By default this modules ships with latest SDK dist. + +You can use recommended CDN by using `cdn: true` or changing it to a custom value using `OneSignalSDK`. + +```js +oneSignal: { + // Use CDN + cdn: true, + + // Use any custom URL + OneSignalSDK: 'https://cdn.onesignal.com/sdks/OneSignalSDK.js' +} +``` + +### References + +Please see [Web Push SDK Reference](https://documentation.onesignal.com/docs/web-push-sdk) for all available options and API functions. ## License diff --git a/packages/onesignal/README.md b/packages/onesignal/README.md new file mode 100644 index 00000000..212ee9b8 --- /dev/null +++ b/packages/onesignal/README.md @@ -0,0 +1 @@ +👉 Please refer to [nuxt-community/pwa-module](https://github.com/nuxt-community/pwa-module) for documentation. diff --git a/packages/onesignal/dist/OneSignalSDK.js b/packages/onesignal/dist/OneSignalSDK.js new file mode 100644 index 00000000..75e27061 --- /dev/null +++ b/packages/onesignal/dist/OneSignalSDK.js @@ -0,0 +1,2 @@ +!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=55)}([function(e,t,n){"use strict";function i(e,t){function n(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function r(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function s(e,t){return function(n,i){t(n,i,e)}}function a(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{u(i.next(e))}catch(e){o(e)}}function a(e){try{u(i.throw(e))}catch(e){o(e)}}function u(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(s,a)}u((i=i.apply(e,t||[])).next())})}function c(e,t){function n(e){return function(t){return i([e,t])}}function i(n){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,o&&(s=o[2&n[0]?"return":n[0]?"throw":"next"])&&!(s=s.call(o,n[1])).done)return s;switch(o=0,s&&(n=[0,s.value]),n[0]){case 0:case 1:s=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,o=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(s=u.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function f(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function p(){for(var e=[],t=0;t1||r(e,t)})})}function r(e,t){try{o(l[e](t))}catch(e){u(d[0][3],e)}}function o(e){e.value instanceof g?Promise.resolve(e.value.v).then(s,a):u(d[0][2],e)}function s(e){r("next",e)}function a(e){r("throw",e)}function u(e,t){e(t),d.shift(),d.length&&r(d[0][0],d[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var c,l=n.apply(e,t||[]),d=[];return c={},i("next"),i("throw"),i("return"),c[Symbol.asyncIterator]=function(){return this},c}function v(e){function t(t,r){e[t]&&(n[t]=function(n){return(i=!i)?{value:g(e[t](n)),done:"return"===t}:r?r(n):n})}var n,i;return n={},t("next"),t("throw",function(e){throw e}),t("return"),n[Symbol.iterator]=function(){return this},n}function m(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator];return t?t.call(e):"function"==typeof d?d(e):e[Symbol.iterator]()}Object.defineProperty(t,"__esModule",{value:!0}),t.__extends=i,n.d(t,"__assign",function(){return S}),t.__rest=r,t.__decorate=o,t.__param=s,t.__metadata=a,t.__awaiter=u,t.__generator=c,t.__exportStar=l,t.__values=d,t.__read=f,t.__spread=p,t.__await=g,t.__asyncGenerator=h,t.__asyncDelegator=v,t.__asyncValues=m;var b=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])},S=Object.assign||function(e){for(var t,n=1,i=arguments.length;n=0&&t<=l.levels.SILENT))throw"log.setLevel() called with invalid level: "+t;if(c=t,!1!==n&&o(t),i.call(l,t,e),typeof console===a&&t-1||t.indexOf("FBAV")>-1)&&(!navigator.appVersion.match(/ wv/)&&(!(e.firefox&&Number(e.version)<48&&(e.mobile||e.tablet))&&(!!(e.firefox&&Number(e.version)>=44)||(!!(e.safari&&Number(e.version)>=7.1)||(!!(e.samsungBrowser&&Number(e.version)>=4)||(!!((e.chrome||e.chromium)&&Number(e.version)>=42)||(!!(e.yandexbrowser&&Number(e.version)>=15.12)||(!!(e.opera&&(e.mobile||e.tablet)&&Number(e.version)>=37||e.opera&&Number(e.version)>=42)||!!e.vivaldi)))))))))))}function a(){return V.chrome||V.chromium||V.opera||V.yandex}function u(e){var t=document.querySelectorAll(e);if(t.length>0)for(var n=0;n0)for(var s=0;s1&&n[1]||""}var n,i=t(/(ipod|iphone|ipad)/i).toLowerCase(),r=/like android/i.test(e),o=!r&&/android/i.test(e),a=/nexus\s*[0-6]\s*/i.test(e),u=!a&&/nexus\s*[0-9]+/i.test(e),c=/CrOS/.test(e),l=/silk/i.test(e),d=/sailfish/i.test(e),f=/tizen/i.test(e),p=/(web|hpw)os/i.test(e),g=/windows phone/i.test(e),h=(/SamsungBrowser/i.test(e),!g&&/windows/i.test(e)),v=!i&&!l&&/macintosh/i.test(e),m=!o&&!d&&!f&&!p&&/linux/i.test(e),b=t(/edge\/(\d+(\.\d+)?)/i),S=t(/version\/(\d+(\.\d+)?)/i),w=/tablet/i.test(e)&&!/tablet pc/i.test(e),_=!w&&/[^-]mobi/i.test(e),y=/xbox/i.test(e);/opera/i.test(e)?n={name:"Opera",opera:s,version:S||t(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(e)?n={name:"Opera",opera:s,version:t(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||S}:/SamsungBrowser/i.test(e)?n={name:"Samsung Internet for Android",samsungBrowser:s,version:S||t(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/coast/i.test(e)?n={name:"Opera Coast",coast:s,version:S||t(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(e)?n={name:"Yandex Browser",yandexbrowser:s,version:S||t(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(e)?n={name:"UC Browser",ucbrowser:s,version:t(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(e)?n={name:"Maxthon",maxthon:s,version:t(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(e)?n={name:"Epiphany",epiphany:s,version:t(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(e)?n={name:"Puffin",puffin:s,version:t(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(e)?n={name:"Sleipnir",sleipnir:s,version:t(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(e)?n={name:"K-Meleon",kMeleon:s,version:t(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:g?(n={name:"Windows Phone",windowsphone:s},b?(n.msedge=s,n.version=b):(n.msie=s,n.version=t(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:s,version:t(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:c?n={name:"Chrome",chromeos:s,chromeBook:s,chrome:s,version:t(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:s,version:b}:/vivaldi/i.test(e)?n={name:"Vivaldi",vivaldi:s,version:t(/vivaldi\/(\d+(\.\d+)?)/i)||S}:d?n={name:"Sailfish",sailfish:s,version:t(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:s,version:t(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(e)?(n={name:"Firefox",firefox:s,version:t(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=s)):l?n={name:"Amazon Silk",silk:s,version:t(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:s,version:t(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(e)?n={name:"SlimerJS",slimer:s,version:t(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:s,version:S||t(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:p?(n={name:"WebOS",webos:s,version:S||t(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=s)):/bada/i.test(e)?n={name:"Bada",bada:s,version:t(/dolfin\/(\d+(\.\d+)?)/i)}:f?n={name:"Tizen",tizen:s,version:t(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||S}:/qupzilla/i.test(e)?n={name:"QupZilla",qupzilla:s,version:t(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||S}:/chromium/i.test(e)?n={name:"Chromium",chromium:s,version:t(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||S}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:s,version:t(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:o?n={name:"Android",version:S}:/safari|applewebkit/i.test(e)?(n={name:"Safari",safari:s},S&&(n.version=S)):i?(n={name:"iphone"==i?"iPhone":"ipad"==i?"iPad":"iPod"},S&&(n.version=S)):n=/googlebot/i.test(e)?{name:"Googlebot",googlebot:s,version:t(/googlebot\/(\d+(\.\d+))/i)||S}:{name:t(/^(.*)\/(.*) /),version:function(t){var n=e.match(t);return n&&n.length>1&&n[2]||""}(/^(.*)\/(.*) /)},!n.msedge&&/(apple)?webkit/i.test(e)?(/(apple)?webkit\/537\.36/i.test(e)?(n.name=n.name||"Blink",n.blink=s):(n.name=n.name||"Webkit",n.webkit=s),!n.version&&S&&(n.version=S)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=s,n.version=n.version||t(/gecko\/(\d+(\.\d+)?)/i)),n.windowsphone||n.msedge||!o&&!n.silk?n.windowsphone||n.msedge||!i?v?n.mac=s:y?n.xbox=s:h?n.windows=s:m&&(n.linux=s):(n[i]=s,n.ios=s):n.android=s;var O="";n.windows?O=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}(t(/Windows ((NT|XP)( \d\d?.\d)?)/i)):n.windowsphone?O=t(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):n.mac?(O=t(/Mac OS X (\d+([_\.\s]\d+)*)/i),O=O.replace(/[_\s]/g,".")):i?(O=t(/os (\d+([_\s]\d+)*) like mac os x/i),O=O.replace(/[_\s]/g,".")):o?O=t(/android[ \/-](\d+(\.\d+)*)/i):n.webos?O=t(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?O=t(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?O=t(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(O=t(/tizen[\/\s](\d+(\.\d+)*)/i)),O&&(n.osversion=O);var E=!n.windows&&O.split(".")[0];return w||u||"ipad"==i||o&&(3==E||E>=4&&!_)||n.silk?n.tablet=s:(_||"iphone"==i||"ipod"==i||o||a||n.blackberry||n.webos||n.bada)&&(n.mobile=s),n.msedge||n.msie&&n.version>=10||n.yandexbrowser&&n.version>=15||n.vivaldi&&n.version>=1||n.chrome&&n.version>=20||n.samsungBrowser&&n.version>=4||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1||n.chromium&&n.version>=20?n.a=s:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6||n.chromium&&n.version<20?n.c=s:n.x=s,n}function t(e){return e.split(".").length}function n(e,t){var n,i=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n=0;){if(r[0][i]>r[1][i])return 1;if(r[0][i]!==r[1][i])return-1;if(0===i)return 0}}function r(t,n,r){var o=a;"string"==typeof n&&(r=n,n=void 0),void 0===n&&(n=!1),r&&(o=e(r));var s=""+o.version;for(var u in t)if(t.hasOwnProperty(u)&&o[u]){if("string"!=typeof t[u])throw new Error("Browser version in the minVersion map should be a string: "+u+": "+String(t));return i([s,t[u]])<0}return n}function o(e,t,n){return!r(e,t,n)}var s=!0,a=e("undefined"!=typeof navigator?navigator.userAgent||"":"");return a.test=function(e){for(var t=0;t to the first element in ."))}},e.getNotificationTypeFromOptIn=function(e){return 1==e||null==e?1:-2},e.wasHttpsNativePromptDismissed=function(){return"dismissed"===r.get("onesignal-notification-prompt")},e.markHttpPopoverShown=function(){sessionStorage.setItem("ONESIGNAL_HTTP_PROMPT_SHOWN","true")},e.isHttpPromptAlreadyShown=function(){return"true"==sessionStorage.getItem("ONESIGNAL_HTTP_PROMPT_SHOWN")},e.checkAndTriggerNotificationPermissionChanged=function(){Promise.all([g.default.get("Options","notificationPermission"),OneSignal.getNotificationPermission()]).then(function(e){var t=e[0],n=e[1];t!==n&&v.default.triggerNotificationPermissionChanged().then(function(){return g.default.put("Options",{key:"notificationPermission",value:n})})})},e.showNotifyButton=function(){if(u.default.isBrowser()&&!OneSignal.notifyButton){OneSignal.config.userConfig.notifyButton=OneSignal.config.userConfig.notifyButton||{},OneSignal.config.userConfig.bell&&(s(OneSignal.config.userConfig.bell,OneSignal.config.userConfig.notifyButton),s(OneSignal.config.userConfig.notifyButton,OneSignal.config.userConfig.bell));var e=OneSignal.config.userConfig.notifyButton.displayPredicate;e&&"function"==typeof e?Promise.resolve(OneSignal.config.userConfig.notifyButton.displayPredicate()).then(function(e){!1!==e?(OneSignal.notifyButton=new a.default(OneSignal.config.userConfig.notifyButton),OneSignal.notifyButton.create()):o.debug("Notify button display predicate returned false so not showing the notify button.")}):(OneSignal.notifyButton=new a.default(OneSignal.config.userConfig.notifyButton),OneSignal.notifyButton.create())}},e.getNotificationIcons=function(){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,s;return i.__generator(this,function(i){switch(i.label){case 0:return[4,e.getAppId()];case 1:if(!(t=i.sent())||!t.value)throw new c.InvalidStateError(c.InvalidStateReason.MissingAppId);return n=d.default.getOneSignalApiUrl().toString()+"/apps/"+t.value+"/icon",[4,fetch(n)];case 2:return r=i.sent(),[4,r.json()];case 3:if(s=i.sent(),s.errors)throw o.error("API call %c"+n,h.getConsoleStyle("code"),"failed with:",s.errors),new Error("Failed to get notification icons.");return[2,s]}})})},e.establishServiceWorkerChannel=function(){var e=this,t=OneSignal.context.workerMessenger;t.off(),t.on(m.WorkerMessengerCommand.NotificationDisplayed,function(e){o.debug(location.origin,"Received notification display event from service worker."),l.default.trigger(OneSignal.EVENTS.NOTIFICATION_DISPLAYED,e)}),t.on(m.WorkerMessengerCommand.NotificationClicked,function(t){return i.__awaiter(e,void 0,void 0,function(){var e,n;return i.__generator(this,function(i){switch(i.label){case 0:return d.default.getWindowEnv()!==p.WindowEnvironmentKind.OneSignalProxyFrame?[3,2]:[4,new Promise(function(e){var t=OneSignal.proxyFrame;t&&t.messenger.message(OneSignal.POSTMAM_COMMANDS.GET_EVENT_LISTENER_COUNT,OneSignal.EVENTS.NOTIFICATION_CLICKED,function(t){var n=t.data;e(n)})})];case 1:return e=i.sent(),[3,3];case 2:e=OneSignal.getListeners(OneSignal.EVENTS.NOTIFICATION_CLICKED).length,i.label=3;case 3:return 0!==e?[3,5]:(o.debug("notification.clicked event received, but no event listeners; storing event in IndexedDb for later retrieval."),n=t.url,t.url||(n=location.href),[4,g.default.put("NotificationOpened",{url:n,data:t,timestamp:Date.now()})]);case 4:return i.sent(),[3,6];case 5:l.default.trigger(OneSignal.EVENTS.NOTIFICATION_CLICKED,t),i.label=6;case 6:return[2]}})})}),t.on(m.WorkerMessengerCommand.RedirectPage,function(e){o.debug(d.default.getWindowEnv().toString()+" Picked up command.redirect to "+e+", forwarding to host page.");var t=OneSignal.proxyFrame;t&&t.messenger.message(OneSignal.POSTMAM_COMMANDS.SERVICEWORKER_COMMAND_REDIRECT,e)}),t.on(m.WorkerMessengerCommand.NotificationDismissed,function(e){l.default.trigger(OneSignal.EVENTS.NOTIFICATION_DISMISSED,e)})},e.getPromptOptionsQueryString=function(){var t=OneSignal.config.userConfig.promptOptions,n="";if(t)for(var i=e.getPromptOptionsPostHash(),r=0,o=Object.keys(i);r0?s.message:"Thanks for subscribing!",g=new URL(location.href).origin+"?_osp=do_not_open",h=s&&s.url&&s.url.length>0?s.url:g,f=c.decodeHtmlEntities(f),p=c.decodeHtmlEntities(p),d||(r.debug("Sending welcome notification."),a.default.sendNotification(n,[t],{en:f},{en:p},h,null,{__isOneSignalWelcomeNotification:!0},void 0),o.default.trigger(OneSignal.EVENTS.WELCOME_NOTIFICATION_SENT,{title:f,message:p,url:h})),i.label=3;case 3:return[2]}})})},e.onSubscriptionChanged_evaluateNotifyButtonDisplayPredicate=function(e){return i.__awaiter(this,void 0,void 0,function(){var e,t;return i.__generator(this,function(n){switch(n.label){case 0:return e=OneSignal.config.userConfig.notifyButton.displayPredicate,e&&"function"==typeof e&&OneSignal.notifyButton?[4,e()]:[3,2];case 1:t=n.sent(),!1!==t?(r.debug("Showing notify button because display predicate returned true."),OneSignal.notifyButton.launcher.show()):(r.debug("Hiding notify button because display predicate returned false."),OneSignal.notifyButton.launcher.hide()),n.label=2;case 2:return[2]}})})},e.triggerNotificationPermissionChanged=function(e){void 0===e&&(e=!1);var t,n;return Promise.all([OneSignal.getNotificationPermission(),u.default.get("Options","notificationPermission")]).then(function(i){var r=i[0],o=i[1];return t=r,n=r!==o||e,n?u.default.put("Options",{key:"notificationPermission",value:r}):null}).then(function(){n&&o.default.trigger(OneSignal.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,{to:t})})},e.triggerSubscriptionChanged=function(e){o.default.trigger(OneSignal.EVENTS.SUBSCRIPTION_CHANGED,e)},e.fireStoredNotificationClicks=function(e){return void 0===e&&(e=document.URL),i.__awaiter(this,void 0,void 0,function(){function t(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,s;return i.__generator(this,function(i){switch(i.label){case 0:return[4,u.default.getAppState()];case 1:return t=i.sent(),t.clickedNotifications[e.url]=null,[4,u.default.setAppState(t)];case 2:return i.sent(),(n=e.data,r=e.timestamp,r&&(s=(Date.now()-r)/1e3/60)>5)?[2]:(o.default.trigger(OneSignal.EVENTS.NOTIFICATION_CLICKED,n),[2])}})})}var n,r,s,a,c,l,d,f;return i.__generator(this,function(i){switch(i.label){case 0:return[4,u.default.getAppState()];case 1:return n=i.sent(),[4,u.default.get("Options","notificationClickHandlerMatch")];case 2:if("origin"!==(r=i.sent()))return[3,7];s=0,a=Object.keys(n.clickedNotifications),i.label=3;case 3:return s=200&&f<300?t:"no-user-id-error"!==e.identifyError(t)?Promise.reject(t):void 0})},e.identifyError=function(e){if(!e||!e.errors)return"no-error";var t=e.errors;return d.contains(t,"No user with this id found")||d.contains(t,"Could not find app_id for given player id.")?"no-user-id-error":"unknown-error"},e.getUserIdFromSubscriptionIdentifier=function(t,n,i){return e.post("players",{app_id:t,device_type:n,identifier:i}).then(function(e){return e&&e.id?e.id:null}).catch(function(e){return o.debug("Error getting user ID from subscription identifier:",e),null})},e.getPlayer=function(t,n){return e.get("players/"+n+"?app_id="+t)},e.updatePlayer=function(t,n,i){return e.put("players/"+n.value,s({app_id:t.value},i))},e.sendNotification=function(t,n,i,r,o,s,a,u){var c={app_id:t.value,contents:r,include_player_ids:n.map(function(e){return e.value}),isAnyWeb:!0,data:a,web_buttons:u};return i&&(c.headings=i),o&&(c.url=o),s&&(c.chrome_web_icon=s,c.firefox_icon=s),d.trimUndefined(c),e.post("notifications",c)},e.getAppConfig=function(t){return i.__awaiter(this,void 0,void 0,function(){var n,o,s;return i.__generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,new Promise(function(n,i){u.default.getWindowEnv()!==p.WindowEnvironmentKind.ServiceWorker?r(u.default.getOneSignalApiUrl().toString()+"/sync/"+t.value+"/web",null,function(e,t){e?i(e):t.success?n(t):i(t)}):n(e.get("sync/"+t.value+"/web",null))})];case 1:return n=i.sent(),o=new c.AppConfig,o.appId=t,n.features&&(n.features.cookie_sync&&n.features.cookie_sync.enable&&(o.cookieSyncEnabled=!0),n.features.metrics&&n.features.metrics.enable&&(o.metrics.enable=!0,o.metrics.mixpanelReportingToken=n.features.metrics.mixpanel_reporting_token)),n.config&&(n.config.http_use_onesignal_com&&(o.httpUseOneSignalCom=!0),n.config.safari_web_id&&(o.safariWebId=n.config.safari_web_id),n.config.subdomain&&(o.subdomain=n.config.subdomain),n.config.vapid_public_key&&(o.vapidPublicKey=n.config.vapid_public_key),n.config.onesignal_vapid_public_key&&(o.onesignalVapidPublicKey=n.config.onesignal_vapid_public_key)),[2,o];case 2:throw s=i.sent();case 3:return[2]}})})},e.createUser=function(t){return i.__awaiter(this,void 0,void 0,function(){var n;return i.__generator(this,function(i){switch(i.label){case 0:return[4,e.post("players",t.serialize())];case 1:return n=i.sent(),n&&n.success?[2,new l.Uuid(n.id)]:[2,null]}})})},e.updateUserSession=function(t,n){return i.__awaiter(this,void 0,void 0,function(){var r,o;return i.__generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e.post("players/"+t.value+"/on_session",n.serialize())];case 1:return r=i.sent(),r.id?[2,new l.Uuid(r.id)]:[2,t];case 2:throw o=i.sent(),o&&Array.isArray(o.errors)&&o.errors.length>0&&d.contains(o.errors[0],"app_id not found")?new f.OneSignalApiError(f.OneSignalApiErrorKind.MissingAppId):o;case 3:return[2]}})})},e}();t.default=g},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i;!function(e){e.Default="default",e.Granted="granted",e.Denied="denied"}(i||(i={})),t.NotificationPermission=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e.put=function(t,n){return void 0===e.store[t]&&(e.store[t]=[null,null]),e.store[t].push(n),e.store[t].length==e.LIMIT+1&&e.store[t].shift(),e.store[t]},e.get=function(t){return void 0===e.store[t]&&(e.store[t]=[null,null]),e.store[t]},e.getFirst=function(t){return e.get(t)[0]},e.getLast=function(t){return e.get(t)[1]},e.remove=function(t){delete e.store[t]},e.isEmpty=function(t){var n=e.get(t);return null===n[0]&&null===n[1]},e.store={},e.LIMIT=2,e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(9),o=n(1),s=n(5),a=n(13),u=n(10),c=n(3),l=n(66),d=n(67),f=n(68),p=n(69),g=n(40),h=function(){function e(t){var n=void 0===t?{}:t,r=n.enable,o=void 0!==r&&r,s=n.size,u=void 0===s?"medium":s,l=n.position,d=void 0===l?"bottom-right":l,f=n.theme,p=void 0===f?"default":f,h=n.showLauncherAfter,v=void 0===h?10:h,m=n.showBadgeAfter,b=void 0===m?300:m,S=n.text,w=void 0===S?{"tip.state.unsubscribed":"Subscribe to notifications","tip.state.subscribed":"You're subscribed to notifications","tip.state.blocked":"You've blocked notifications","message.prenotify":"Click to subscribe to notifications","message.action.subscribing":"Click {{prompt.native.grant}} to receive notifications","message.action.subscribed":"Thanks for subscribing!","message.action.resubscribed":"You're subscribed to notifications","message.action.unsubscribed":"You won't receive notifications again","dialog.main.title":"Manage Site Notifications","dialog.main.button.subscribe":"SUBSCRIBE","dialog.main.button.unsubscribe":"UNSUBSCRIBE","dialog.blocked.title":"Unblock Notifications","dialog.blocked.message":"Follow these instructions to allow notifications:"}:S,_=n.prenotify,y=void 0===_||_,O=n.showCredit,E=void 0===O||O,P=n.colors,I=void 0===P?null:P,C=n.offset,N=void 0===C?null:C,T=n.launcher,A=void 0===T?null:T,M=this;if(this.options={enable:o,size:u,position:d,theme:p,showLauncherAfter:v,showBadgeAfter:b,text:w,prenotify:y,showCredit:E,colors:I,offset:N},this.options.enable){if(!c.contains(["small","medium","large"],this.options.size))throw new Error("Invalid size "+this.options.size+" for notify button. Choose among 'small', 'medium', or 'large'.");if(!c.contains(["bottom-left","bottom-right"],this.options.position))throw new Error("Invalid position "+this.options.position+" for notify button. Choose either 'bottom-left', or 'bottom-right'.");if(!c.contains(["default","inverse"],this.options.theme))throw new Error("Invalid theme "+this.options.theme+" for notify button. Choose either 'default', or 'inverse'.");if(this.options.showLauncherAfter<0)throw new Error("Invalid delay duration of "+this.options.showLauncherAfter+" for showing the notify button. Choose a value above 0.");if(this.options.showBadgeAfter<0)throw new Error("Invalid delay duration of "+this.options.showBadgeAfter+" for showing the notify button's badge. Choose a value above 0.");this.size=this.options.size,this.position=this.options.position,this.text=this.options.text,this.text["tip.state.unsubscribed"]||(this.text["tip.state.unsubscribed"]="Subscribe to notifications"),this.text["tip.state.subscribed"]||(this.text["tip.state.subscribed"]="You're subscribed to notifications"),this.text["tip.state.blocked"]||(this.text["tip.state.blocked"]="You've blocked notifications"),this.text["message.prenotify"]||(this.text["message.prenotify"]="Click to subscribe to notifications"),this.text["message.action.subscribed"]||(this.text["message.action.subscribed"]="Thanks for subscribing!"),this.text["message.action.resubscribed"]||(this.text["message.action.resubscribed"]="You're subscribed to notifications"),this.text["message.action.subscribing"]||(this.text["message.action.subscribing"]="Click {{prompt.native.grant}} to receive notifications"),this.text["message.action.unsubscribed"]||(this.text["message.action.unsubscribed"]="You won't receive notifications again"),this.text["dialog.main.title"]||(this.text["dialog.main.title"]="Manage Site Notifications"),this.text["dialog.main.button.subscribe"]||(this.text["dialog.main.button.subscribe"]="SUBSCRIBE"),this.text["dialog.main.button.unsubscribe"]||(this.text["dialog.main.button.unsubscribe"]="UNSUBSCRIBE"),this.text["dialog.blocked.title"]||(this.text["dialog.blocked.title"]="Unblock Notifications"),this.text["dialog.blocked.message"]||(this.text["dialog.blocked.message"]="Follow these instructions to allow notifications:"),this._launcher=A,this.substituteText(),this.state=e.STATES.UNINITIALIZED,this._ignoreSubscriptionState=!1,OneSignal.on(e.EVENTS.SUBSCRIBE_CLICK,function(){M.dialog.subscribeButton.disabled=!0,M._ignoreSubscriptionState=!0,OneSignal.setSubscription(!0).then(function(){return M.dialog.subscribeButton.disabled=!1,M.dialog.hide()}).then(function(){return M.message.display(g.default.TYPES.MESSAGE,M.text["message.action.resubscribed"],g.default.TIMEOUT)}).then(function(){return M._ignoreSubscriptionState=!1,M.launcher.clearIfWasInactive(),M.launcher.inactivate()}).then(function(){return M.updateState()})}),OneSignal.on(e.EVENTS.UNSUBSCRIBE_CLICK,function(){M.dialog.unsubscribeButton.disabled=!0,OneSignal.setSubscription(!1).then(function(){return M.dialog.unsubscribeButton.disabled=!1,M.dialog.hide()}).then(function(){return M.launcher.clearIfWasInactive(),M.launcher.activate()}).then(function(){return M.message.display(g.default.TYPES.MESSAGE,M.text["message.action.unsubscribed"],g.default.TIMEOUT)}).then(function(){return M.updateState()})}),OneSignal.on(e.EVENTS.HOVERING,function(){return M.hovering=!0,M.launcher.activateIfInactive(),M.message.shown||M.dialog.shown?void(M.hovering=!1):M.message.contentType===g.default.TYPES.MESSAGE?void(M.hovering=!1):void new Promise(function(e){if(M.message.queued.length>0)return M.message.dequeue().then(function(t){M.message.content=t,M.message.contentType=g.default.TYPES.QUEUED,e()});M.message.content=c.decodeHtmlEntities(M.message.getTipForState()),M.message.contentType=g.default.TYPES.TIP,e()}).then(function(){return M.message.show()}).then(function(){M.hovering=!1})}),OneSignal.on(e.EVENTS.HOVERED,function(){M.message.contentType!==g.default.TYPES.MESSAGE&&M.dialog.hidden&&(M.hovering&&(M.hovering=!1,M.message.waitUntilShown().then(function(){return c.delay(g.default.TIMEOUT)}).then(function(){return M.message.hide()}).then(function(){M.launcher.wasInactive&&M.dialog.hidden&&(M.launcher.inactivate(),M.launcher.wasInactive=null)})),M.message.shown&&M.message.hide().then(function(){M.launcher.wasInactive&&M.dialog.hidden&&(M.launcher.inactivate(),M.launcher.wasInactive=null)}))}),OneSignal.on(OneSignal.EVENTS.SUBSCRIPTION_CHANGED,function(t){return i.__awaiter(M,void 0,void 0,function(){var n,r=this;return i.__generator(this,function(i){switch(i.label){case 0:return 1!=t?[3,2]:(this.badge.shown&&this.options.prenotify&&this.badge.hide(),null!==this.dialog.notificationIcons?[3,2]:[4,a.default.getNotificationIcons()]);case 1:n=i.sent(),this.dialog.notificationIcons=n,i.label=2;case 2:return OneSignal.getNotificationPermission(function(n){r.setState(t?e.STATES.SUBSCRIBED:"denied"===n?e.STATES.BLOCKED:e.STATES.UNSUBSCRIBED,r._ignoreSubscriptionState)}),[2]}})})}),OneSignal.on(e.EVENTS.STATE_CHANGED,function(t){M.launcher.element&&(t.to===e.STATES.SUBSCRIBED?M.launcher.inactivate():(t.to===e.STATES.UNSUBSCRIBED||e.STATES.BLOCKED)&&M.launcher.activate())}),OneSignal.on(OneSignal.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,function(){M.updateState()}),this.updateState()}}return Object.defineProperty(e,"EVENTS",{get:function(){return{STATE_CHANGED:"notifyButtonStateChange",LAUNCHER_CLICK:"notifyButtonLauncherClick",BELL_CLICK:"notifyButtonButtonClick",SUBSCRIBE_CLICK:"notifyButtonSubscribeClick",UNSUBSCRIBE_CLICK:"notifyButtonUnsubscribeClick",HOVERING:"notifyButtonHovering",HOVERED:"notifyButtonHover"}},enumerable:!0,configurable:!0}),Object.defineProperty(e,"STATES",{get:function(){return{UNINITIALIZED:"uninitialized",SUBSCRIBED:"subscribed",UNSUBSCRIBED:"unsubscribed",BLOCKED:"blocked"}},enumerable:!0,configurable:!0}),Object.defineProperty(e,"TEXT_SUBS",{get:function(){return{"prompt.native.grant":{default:"Allow",chrome:"Allow",firefox:"Always Receive Notifications",safari:"Allow"}}},enumerable:!0,configurable:!0}),e.prototype.substituteText=function(){for(var t in this.text)if(this.text.hasOwnProperty(t)){var n=this.text[t],i=r.name.toLowerCase();for(var o in e.TEXT_SUBS)if(e.TEXT_SUBS.hasOwnProperty(o)){var s=e.TEXT_SUBS[o],a=s[i];n&&c.contains(n,"{{")&&(this.text[t]=n.replace("{{"+o+"}}",void 0!==a?a:s.default))}}},e.prototype.showDialogProcedure=function(){var e=this;this.dialog.shown||this.dialog.show().then(function(){c.once(document,"click",function(t,n){e.dialog.element.contains(t.target)||(n(),e.dialog.shown&&e.dialog.hide().then(function(){e.launcher.inactivateIfWasInactive()}))},!0)})},e.prototype.create=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t,n,r,s,l=this;return i.__generator(this,function(i){switch(i.label){case 0:return this.options.enable?[4,OneSignal.context.dynamicResourceLoader.loadSdkStylesheet()]:[2];case 1:return 0!==(e=i.sent())?(o.debug("Not showing notify button because styles failed to load."),[2]):(this.container&&c.removeDomElement("#onesignal-bell-container"),c.addDomElement("body","beforeend",'
'),c.addDomElement(this.container,"beforeend",'
'),c.addDomElement(this.launcher.selector,"beforeend",'
'),c.addDomElement(this.launcher.selector,"beforeend",'
'),c.addDomElement(this.launcher.selector,"beforeend",'
'),c.addDomElement(this.message.selector,"beforeend",'
'),c.addDomElement(this.launcher.selector,"beforeend",'
'),c.addDomElement(this.dialog.selector,"beforeend",'
'),c.addDomElement(this.button.selector,"beforeEnd",''),[4,OneSignal.isPushNotificationsEnabled()]);case 2:return t=i.sent(),[4,OneSignal.getSubscription()];case 3:return n=i.sent(),[4,a.default.wasHttpsNativePromptDismissed()];case 4:return r=i.sent(),s=t?"small":this.options.size,[4,this.launcher.resize(s)];case 5:if(i.sent(),"bottom-left"===this.options.position)c.addCssClass(this.container,"onesignal-bell-container-bottom-left"),c.addCssClass(this.launcher.selector,"onesignal-bell-launcher-bottom-left");else{if("bottom-right"!==this.options.position)throw new Error("Invalid OneSignal notify button position "+this.options.position);c.addCssClass(this.container,"onesignal-bell-container-bottom-right"),c.addCssClass(this.launcher.selector,"onesignal-bell-launcher-bottom-right")}if("default"===this.options.theme)c.addCssClass(this.launcher.selector,"onesignal-bell-launcher-theme-default");else{if("inverse"!==this.options.theme)throw new Error("Invalid OneSignal notify button theme "+this.options.theme);c.addCssClass(this.launcher.selector,"onesignal-bell-launcher-theme-inverse")}return this.applyOffsetIfSpecified(),this.setCustomColorsIfSpecified(),this.patchSafariSvgFilterBug(),o.info("Showing the notify button."),[4,(t?this.launcher.inactivate():c.nothing()).then(function(){return OneSignal.getSubscription()}).then(function(e){return!t&&e||null!==l.dialog.notificationIcons?c.nothing():a.default.getNotificationIcons().then(function(e){l.dialog.notificationIcons=e})}).then(function(){return c.delay(l.options.showLauncherAfter)}).then(function(){return u.default.isUsingSubscriptionWorkaround()&&n&&!0!==r&&!t&&!0===OneSignal.config.userConfig.autoRegister&&!a.default.isHttpPromptAlreadyShown()?(o.debug("Not showing notify button because popover will be shown."),c.nothing()):l.launcher.show()}).then(function(){return c.delay(l.options.showBadgeAfter)}).then(function(){return l.options.prenotify&&!t&&OneSignal._isNewVisitor?l.message.enqueue(l.text["message.prenotify"]).then(function(){return l.badge.show()}):c.nothing()}).then(function(){return l.initialized=!0})];case 6:return i.sent(),[2]}})})},e.prototype.patchSafariSvgFilterBug=function(){if(!(r.safari&&Number(r.version)>=9.1)){var e="drop-shadow(0 2px 4px rgba(34,36,38,0.35));",t="drop-shadow(0 2px 4px rgba(34,36,38,0));",n="drop-shadow(0px 2px 2px rgba(34,36,38,.15));";this.graphic.setAttribute("style","filter: "+e+"; -webkit-filter: "+e+";"),this.badge.element.setAttribute("style","filter: "+t+"; -webkit-filter: "+t+";"),this.dialog.element.setAttribute("style","filter: "+n+"; -webkit-filter: "+n+";")}r.safari&&this.badge.element.setAttribute("style","display: none;")},e.prototype.applyOffsetIfSpecified=function(){var e=this.options.offset;e&&(this.launcher.element.style.cssText="",e.bottom&&(this.launcher.element.style.cssText+="bottom: "+e.bottom+";"),"bottom-right"===this.options.position?e.right&&(this.launcher.element.style.cssText+="right: "+e.right+";"):"bottom-left"===this.options.position&&e.left&&(this.launcher.element.style.cssText+="left: "+e.left+";"))},e.prototype.setCustomColorsIfSpecified=function(){var e=this.dialog.element.querySelector("button.action"),t=this.button.element.querySelector(".pulse-ring");this.graphic.querySelector(".background").style.cssText="";for(var n=this.graphic.querySelectorAll(".foreground"),i=0;i0?this.replies[e.toString()].push(i):this.replies[e.toString()]=[i]},e.prototype.findListenersForMessage=function(e){return this.replies[e.toString()]||[]},e.prototype.deleteListenerRecords=function(e){this.replies[e.toString()]=null},e.prototype.deleteAllListenerRecords=function(){this.replies={}},e.prototype.deleteListenerRecord=function(e,t){for(var n=this.replies[e.toString()],i=n.length-1;i>=0;i--){n[i]===t&&n.splice(i,1)}},e}();t.WorkerMessengerReplyBuffer=l;var d=function(){function e(e){this.context=e,this.replies=new l,this.debug=!0}return e.prototype.broadcast=function(e,t){return i.__awaiter(this,void 0,void 0,function(){var n,r,s,c,l;return i.__generator(this,function(i){switch(i.label){case 0:return n=o.default.getWindowEnv(),n===a.WindowEnvironmentKind.ServiceWorker?[3,1]:[2];case 1:return[4,self.clients.matchAll({type:"window",includeUncontrolled:!0})];case 2:for(r=i.sent(),s=0,c=r;s Page] Broadcasting '"+e.toString()+"' to window client "+l.url+"."),l.postMessage({command:e,payload:t});i.label=3;case 3:return[2]}})})},e.prototype.unicast=function(e,t,n){return i.__awaiter(this,void 0,void 0,function(){var s;return i.__generator(this,function(i){switch(i.label){case 0:if((s=o.default.getWindowEnv())!==a.WindowEnvironmentKind.ServiceWorker)return[3,1];if(!n)throw new r.InvalidArgumentError("windowClient",r.InvalidArgumentReason.Empty);return u.debug("[Worker Messenger] [SW -> Page] Unicasting '"+e.toString()+"' to window client "+n.url+"."),n.postMessage({command:e,payload:t}),[3,4];case 1:return[4,this.isWorkerControllingPage()];case 2:return i.sent()||u.debug("[Worker Messenger] The page is not controlled by the service worker yet. Waiting...",self.registration),[4,this.waitUntilWorkerControlsPage()];case 3:i.sent(),u.debug("[Worker Messenger] [Page -> SW] Unicasting '"+e.toString()+"' to service worker."),navigator.serviceWorker.controller.postMessage({command:e,payload:t}),i.label=4;case 4:return[2]}})})},e.prototype.listen=function(e){if(c.default.supportsServiceWorkers()){o.default.getWindowEnv()===a.WindowEnvironmentKind.ServiceWorker?(self.addEventListener("message",this.onWorkerMessageReceivedFromPage.bind(this)),u.debug("[Worker Messenger] Service worker is now listening for messages.")):this.listenForPage(e)}},e.prototype.listenForPage=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){switch(t.label){case 0:return e?[3,3]:[4,this.isWorkerControllingPage()];case 1:return t.sent()||u.debug("("+location.origin+") [Worker Messenger] The page is not controlled by the service worker yet. Waiting...",self.registration),[4,this.waitUntilWorkerControlsPage()];case 2:t.sent(),u.debug("("+location.origin+") [Worker Messenger] The page is now controlled by the service worker."),t.label=3;case 3:return navigator.serviceWorker.addEventListener("message",this.onPageMessageReceivedFromServiceWorker.bind(this)),u.debug("("+location.origin+") [Worker Messenger] Page is now listening for messages."),[2]}})})},e.prototype.onWorkerMessageReceivedFromPage=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,o,s,a,c,l,c,d,f,c;return i.__generator(this,function(i){for(t=e.data,n=this.replies.findListenersForMessage(t.command),r=[],o=[],u.debug("[Worker Messenger] Service worker received message:",e.data),s=0,a=n;s=0;l--)c=r[l],this.replies.deleteListenerRecord(t.command,c);for(d=0,f=o;d=0;l--)c=r[l],this.replies.deleteListenerRecord(t.command,c);for(d=0,f=o;d1){if(o=e({path:"/"},i.defaults,o),"number"==typeof o.expires){var a=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*o.expires),o.expires=a}try{s=JSON.stringify(r),/^[\{\[]/.test(s)&&(r=s)}catch(e){}return r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape),document.cookie=[t,"=",r,o.expires?"; expires="+o.expires.toUTCString():"",o.path?"; path="+o.path:"",o.domain?"; domain="+o.domain:"",o.secure?"; secure":""].join("")}t||(s={});for(var u=document.cookie?document.cookie.split("; "):[],c=/(%[0-9A-Z]{2})+/g,l=0;lOneSignal: This page cannot be directly opened, and must be opened as a result of a subscription call."),[2,Promise.resolve()]):(t=r(this.options),t.appId=t.appId.value,t.origin=t.origin,OneSignal.config=t||{},[4,u.default.downloadAndMergeAppConfig(t)]);case 1:return n=i.sent(),OneSignal.context=new a.default(n),OneSignal.context.workerMessenger.listen(!0),OneSignal.initialized=!0,this.loadPromise={},this.loadPromise.promise=new Promise(function(e,t){o.loadPromise.resolver=e,o.loadPromise.rejector=t}),this.establishCrossOriginMessaging(),[2,this.loadPromise.promise]}})})},e.prototype.establishCrossOriginMessaging=function(){},e.prototype.dispose=function(){this.messenger.destroy()},e.prototype.finishInitialization=function(){this.loadPromise.resolver()},e.prototype.subscribe=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t;return i.__generator(this,function(n){switch(n.label){case 0:return[4,OneSignal.isPushNotificationsEnabled()];case 1:return e=n.sent(),t=opener||parent,e?t&&window.close():o.default.registerForPush(),[2]}})})},e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(23),r=n(30),o=n(75),s=n(49),a=n(79),u=n(42),c=n(2),l=n(80),d=n(81),f=n(54),p=function(){function e(e){this.appConfig=e,this.cookieSyncer=new a.default(e.cookieSyncEnabled),this.subscriptionManager=new o.SubscriptionManager(this,{safariWebId:e.safariWebId,appId:e.appId,vapidPublicKey:e.vapidPublicKey,onesignalVapidPublicKey:e.onesignalVapidPublicKey});var t={workerAPath:new u.default("/"+c.default.getBuildEnvPrefix()+"OneSignalSDKWorker.js"),workerBPath:new u.default("/"+c.default.getBuildEnvPrefix()+"OneSignalSDKUpdaterWorker.js"),registrationOptions:{scope:"/"}};e.userConfig&&(e.userConfig.path&&(t.workerAPath=new u.default(e.userConfig.path+c.default.getBuildEnvPrefix()+e.userConfig.serviceWorkerPath),t.workerBPath=new u.default(e.userConfig.path+c.default.getBuildEnvPrefix()+e.userConfig.serviceWorkerUpdaterPath)),e.userConfig.serviceWorkerParam&&(t.registrationOptions=e.userConfig.serviceWorkerParam)),this.serviceWorkerManager=new r.ServiceWorkerManager(this,t),this.workerMessenger=new i.WorkerMessenger(this),this.dynamicResourceLoader=new s.DynamicResourceLoader,this.sessionManager=new l.SessionManager,this.permissionManager=new d.default,this.metricsManager=new f.default(e.metrics.enable,e.metrics.mixpanelReportingToken)}return e}();t.default=p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.None="None",e.UnitTesting="Unit Testing"}(t.TestEnvironmentKind||(t.TestEnvironmentKind={}))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._events={}}return e.prototype.on=function(e,t){return this._events[e]=this._events[e]||[],this._events[e].push(t),this},e.prototype.once=function(e,t){function n(){i.off(e,n),t.apply(this,arguments)}var i=this;return n.listener=t,this.on(e,n),this},e.prototype.off=function(e,t){var n=this._events[e];if(void 0!==n){for(var i=0;i0?t.bell.badge.show():Promise.resolve(t)}).then(e(n)):(t.bell.badge.decrement(),e(n))})},t}(s.default);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.HttpsPermissionRequest="HTTPS permission request"]="HttpsPermissionRequest",e[e.FullscreenHttpPermissionMessage="fullscreen HTTP permission message"]="FullscreenHttpPermissionMessage",e[e.FullscreenHttpsPermissionMessage="fullscreen HTTPS permission message"]="FullscreenHttpsPermissionMessage",e[e.SlidedownPermissionMessage="slidedown permission message"]="SlidedownPermissionMessage",e[e.SubscriptionBell="subscription bell"]="SubscriptionBell"}(t.PermissionPromptType||(t.PermissionPromptType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(18),r=function(){function e(e){if(!e)throw new i.InvalidArgumentError("path",i.InvalidArgumentReason.Empty);this.path=e.trim()}return e.prototype.getQueryString=function(){var e=this.path.indexOf("?");return-1===e?null:this.path.length>e?this.path.substring(e+1):null},e.prototype.getWithoutQueryString=function(){return this.path.split(e.QUERY_STRING)[0]},e.prototype.getFileName=function(){return this.getWithoutQueryString().split("\\").pop().split("/").pop()},e.prototype.getFileNameWithQuery=function(){return this.path.split("\\").pop().split("/").pop()},e.prototype.getFullPath=function(){return this.path},e.prototype.getPathWithoutFileName=function(){var e=this.getWithoutQueryString(),t=e.lastIndexOf(this.getFileName()),n=e.substring(0,t);return n=n.replace(/[\\\/]$/,"")},e.QUERY_STRING="?",e}();t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(9),o=n(44),s=n(27),a=n(1),u=n(8),c=n(45),l=n(6),d=n(46),f=n(18),p=n(16),g=n(70),h=n(47),v=n(14),m=n(14),b=n(31),S=n(5),w=n(15),_=n(71),y=n(32),O=n(13),E=n(10),P=n(51),I=n(21),C=n(84),N=n(48),T=n(2),A=n(30),M=n(35),k=n(20),R=n(41),x=n(4),D=n(86),W=n(19),U=n(87),L=n(88),B=n(11),F=n(39),j=n(3),H=n(89),V=n(33),K=n(90),G=function(){function e(){}return e.setDefaultNotificationUrl=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:if(!H.ValidatorUtils.isValidUrl(e,{allowNull:!0}))throw new f.InvalidArgumentError("url",f.InvalidArgumentReason.Malformed);return[4,j.awaitOneSignalInitAndSupported()];case 1:return n.sent(),j.logMethodCall("setDefaultNotificationUrl",e),[4,B.default.getAppState()];case 2:return t=n.sent(),t.defaultNotificationUrl=e,[4,B.default.setAppState(t)];case 3:return n.sent(),[2]}})})},e.setDefaultTitle=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return[4,j.awaitOneSignalInitAndSupported()];case 1:return n.sent(),j.logMethodCall("setDefaultTitle",e),[4,B.default.getAppState()];case 2:return t=n.sent(),t.defaultNotificationTitle=e,[4,B.default.setAppState(t)];case 3:return n.sent(),[2]}})})},e.syncHashedEmail=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,o;return i.__generator(this,function(i){switch(i.label){case 0:if(!e)throw new f.InvalidArgumentError("email",f.InvalidArgumentReason.Empty);if(t=j.prepareEmailForHashing(e),!j.isValidEmail(t))throw new f.InvalidArgumentError("email",f.InvalidArgumentReason.Malformed);return[4,j.awaitOneSignalInitAndSupported()];case 1:return i.sent(),j.logMethodCall("syncHashedEmail",e),[4,B.default.getAppConfig()];case 2:return n=i.sent().appId,[4,B.default.getSubscription()];case 3:if(!(r=i.sent().deviceId)||!r.value)throw new g.NotSubscribedError(g.NotSubscribedReason.NoDeviceId);return[4,W.default.updatePlayer(n,r,{em_m:L.default.md5(t),em_s:L.default.sha1(t),em_s256:L.default.sha256(t)})];case 4:if((o=i.sent())&&o.success)return[2,!0];throw o}})})},e.isPushNotificationsSupported=function(){return j.logMethodCall("isPushNotificationsSupported"),!0},e.init=function(t){return i.__awaiter(this,void 0,void 0,function(){function n(){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:if(e.__initAlreadyCalled)return[2];if(e.__initAlreadyCalled=!0,O.default.fixWordpressManifestIfMisplaced(),e.on(e.EVENTS.NATIVE_PROMPT_PERMISSIONCHANGED,w.default.onNotificationPermissionChange),e.on(e.EVENTS.SUBSCRIPTION_CHANGED,w.default._onSubscriptionChanged),e.on(e.EVENTS.SDK_INITIALIZED,y.default.onSdkInitialized),!E.default.isUsingSubscriptionWorkaround())return[3,2];if(e.appConfig=o,!o.subdomain)throw new b.SdkInitError(b.SdkInitErrorKind.MissingSubdomain);return t=e,[4,C.default.discoverAltOrigin(o)];case 1:t.proxyFrameHost=n.sent(),n.label=2;case 2:return window.addEventListener("focus",function(){O.default.checkAndTriggerNotificationPermissionChanged()}),y.default.initSaveState(document.title).then(function(){return y.default.saveInitOptions()}).then(function(){T.default.getWindowEnv()===x.WindowEnvironmentKind.CustomIframe?S.default.trigger(e.EVENTS.SDK_INITIALIZED):y.default.internalInit()}),[2]}})})}var o;return i.__generator(this,function(i){switch(i.label){case 0:return j.logMethodCall("init"),y.default.ponyfillSafariFetch(),y.default.errorIfInitAlreadyCalled(),[4,y.default.downloadAndMergeAppConfig(t)];case 1:return o=i.sent(),(a.debug("OneSignal: Final web app config: %c"+JSON.stringify(o,null,4),j.getConsoleStyle("code")),e.context=new M.default(o),e.config=e.context.appConfig,e.context.workerMessenger.listen(),r.safari&&!e.config.safariWebId)?(a.warn(new b.SdkInitError(b.SdkInitErrorKind.MissingSafariWebId)),[2]):("complete"===document.readyState||"interactive"===document.readyState?n():(a.debug("OneSignal: Waiting for DOMContentLoaded or readyStateChange event before continuing initialization..."),window.addEventListener("DOMContentLoaded",function(){n()}),document.onreadystatechange=function(){"complete"!==document.readyState&&"interactive"!==document.readyState||n()}),[2])}})})},e.showHttpPermissionRequest=function(t){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){return a.debug("Called showHttpPermissionRequest(), redirecting to HTTP prompt."),e.showHttpPrompt().catch(function(e){return a.info(e)}),[2]})})},e.showHttpPrompt=function(t){return i.__awaiter(this,void 0,void 0,function(){var n,r,o,s,u;return i.__generator(this,function(i){switch(i.label){case 0:return t||(t={}),[4,j.awaitOneSignalInitAndSupported()];case 1:if(i.sent(),e.__isPopoverShowing)throw new p.InvalidStateError(p.InvalidStateReason.RedundantPermissionMessage,{permissionPromptType:R.PermissionPromptType.SlidedownPermissionMessage});return[4,e.getNotificationPermission()];case 2:return n=i.sent(),[4,e.isPushNotificationsEnabled()];case 3:return r=i.sent(),[4,e.getSubscription()];case 4:return o=i.sent(),[4,O.default.wasHttpsNativePromptDismissed()];case 5:if((s=i.sent())&&!t.force)return a.info(new h.default),[2];if(n===k.NotificationPermission.Denied)return a.info(new v.default(m.PushPermissionNotGrantedErrorReason.Blocked)),[2];if(r)throw new d.default;if(!o)throw new g.NotSubscribedError(g.NotSubscribedReason.OptedOut);return O.default.markHttpPopoverShown(),[4,e.context.dynamicResourceLoader.loadSdkStylesheet()];case 6:return 0!==(u=i.sent())?(a.debug("Not showing slidedown permission message because styles failed to load."),[2]):(e.popover=new U.default(e.config.userConfig.promptOptions),e.popover.create(),a.debug("Showing the HTTP popover."),e.notifyButton&&e.notifyButton.options.enable&&"hidden"!==e.notifyButton.launcher.state&&e.notifyButton.launcher.waitUntilShown().then(function(){e.notifyButton.launcher.hide()}),e.once(U.default.EVENTS.SHOWN,function(){e.__isPopoverShowing=!0}),e.once(U.default.EVENTS.CLOSED,function(){e.__isPopoverShowing=!1,e.notifyButton&&e.notifyButton.options.enable&&e.notifyButton.launcher.show()}),e.once(U.default.EVENTS.ALLOW_CLICK,function(){e.popover.close(),a.debug("Setting flag to not show the popover to the user again."),P.default.markHttpsNativePromptDismissed(),e.registerForPushNotifications({autoAccept:!0})}),e.once(U.default.EVENTS.CANCEL_CLICK,function(){a.debug("Setting flag to not show the popover to the user again."),P.default.markHttpsNativePromptDismissed()}),[2])}})})},e.registerForPushNotifications=function(t){function n(){if(t&&t.httpPermissionRequest&&E.default.isUsingSubscriptionWorkaround())return void a.error(new K.DeprecatedApiError(K.DeprecatedApiReason.HttpPermissionRequest));E.default.isUsingSubscriptionWorkaround()?(e.subscriptionPopupHost=new D.default(e.proxyFrameHost.url,t),e.subscriptionPopupHost.load()):(t||(t={}),t.fromRegisterFor=!0,y.default.sessionInit(t))}if(e.initialized)return n();e.once(e.EVENTS.SDK_INITIALIZED,function(){return n()})},e.getNotificationPermission=function(t){return i.__awaiter(this,void 0,void 0,function(){var n;return i.__generator(this,function(i){switch(i.label){case 0:return[4,j.awaitOneSignalInitAndSupported()];case 1:return i.sent(),[4,e.context.permissionManager.getNotificationPermission(e.config.safariWebId)];case 2:return n=i.sent(),t&&t(n),[2,n]}})})},e.getTags=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r;return i.__generator(this,function(i){switch(i.label){case 0:return[4,j.awaitOneSignalInitAndSupported()];case 1:return i.sent(),j.logMethodCall("getTags",e),[4,B.default.getAppConfig()];case 2:return t=i.sent().appId,[4,B.default.getSubscription()];case 3:return n=i.sent().deviceId,n&&n.value?[4,W.default.getPlayer(t,n)]:(a.info(new g.NotSubscribedError(g.NotSubscribedReason.NoDeviceId)),[2,null]);case 4:return r=i.sent().tags,j.executeCallback(e,r),[2,r]}})})},e.sendTag=function(t,n,r){return i.__awaiter(this,void 0,void 0,function(){var o;return i.__generator(this,function(i){switch(i.label){case 0:return o={},o[t]=n,[4,e.sendTags(o,r)];case 1:return[2,i.sent()]}})})},e.sendTags=function(t,n){return i.__awaiter(this,void 0,void 0,function(){var r,o,s;return i.__generator(this,function(i){switch(i.label){case 0:return[4,j.awaitOneSignalInitAndSupported()];case 1:return i.sent(),(j.logMethodCall("sendTags",t,n),t&&0!==Object.keys(t).length)?(Object.keys(t).forEach(function(e){!1===t[e]&&(t[e]="false")}),[4,B.default.getAppConfig()]):(a.info(new f.InvalidArgumentError("tags",f.InvalidArgumentReason.Empty)),[2,null]);case 2:return r=i.sent().appId,[4,B.default.getSubscription()];case 3:return o=i.sent().deviceId,o&&o.value?[3,5]:[4,j.awaitSdkEvent(e.EVENTS.REGISTERED)];case 4:i.sent(),i.label=5;case 5:return[4,B.default.getSubscription()];case 6:return s=i.sent().deviceId,[4,W.default.updatePlayer(r,s,{tags:t})];case 7:return i.sent(),j.executeCallback(n,t),[2,t]}})})},e.deleteTag=function(t){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(n){switch(n.label){case 0:return[4,e.deleteTags([t])];case 1:return[2,n.sent()]}})})},e.deleteTags=function(t,n){return i.__awaiter(this,void 0,void 0,function(){var r,o,s,u,c,l;return i.__generator(this,function(i){switch(i.label){case 0:return[4,j.awaitOneSignalInitAndSupported()];case 1:if(i.sent(),j.logMethodCall("deleteTags",t,n),!H.ValidatorUtils.isValidArray(t))throw new f.InvalidArgumentError("tags",f.InvalidArgumentReason.Malformed);for(0===t.length&&a.info(new f.InvalidArgumentError("tags",f.InvalidArgumentReason.Empty)),r={},o=0,s=t;o2&&(t=30),o.debug("("+s.default.getWindowEnv().toString()+") OneSignal: User dismissed the native notification prompt; reprompt after "+t+" days."),[4,a.default.put("Options",{key:"promptDismissCount",value:e})];case 4:return n.sent(),[2,r.set("onesignal-notification-prompt","dismissed",{expires:t})]}})})},e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,r=n(0),o=n(7);!function(e){e[e.InvalidSafariSetup=0]="InvalidSafariSetup",e[e.Blocked=1]="Blocked",e[e.Dismissed=2]="Dismissed"}(i=t.SubscriptionErrorReason||(t.SubscriptionErrorReason={}));var s=function(e){function t(t){var n=this;switch(t){case i.InvalidSafariSetup:n=e.call(this,"The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session.")||this;break;case i.Blocked:n=e.call(this,"Notification permissions are blocked.")||this;break;case i.Dismissed:n=e.call(this,"The notification permission prompt was dismissed.")||this}return n}return r.__extends(t,e),t}(o.default);t.default=s},function(e,t,n){"use strict";function i(e){for(var t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/\-/g,"+").replace(/_/g,"/"),i=atob(n),r=new Uint8Array(i.length),o=0;o>18,n=(258048&o)>>12,i=(4032&o)>>6,r=63&o,s+=a[t]+a[n]+a[i]+a[r];return 1==l?(o=u[d],t=(252&o)>>2,n=(3&o)<<4,s+=a[t]+a[n]+"=="):2==l&&(o=u[d]<<8|u[d+1],t=(64512&o)>>10,n=(1008&o)>>4,i=(15&o)<<2,s+=a[t]+a[n]+a[i]+"="),s}function o(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))}function s(e){return decodeURIComponent(atob(e).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))}Object.defineProperty(t,"__esModule",{value:!0}),t.base64ToUint8Array=i,t.arrayBufferToBase64=r,t.base64Encode=o,t.base64Decode=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(8),o=n(53),s=n(6),a=function(){function e(){}return e.prototype.getPropertiesAsJson=function(){return{origin:location.origin,url:location.href,sdkVersion:s.default.version()}},e}();!function(e){e.HttpPermissionRequest="HttpPermissionRequest"}(t.ApiUsageMetricKind||(t.ApiUsageMetricKind={}));var u=function(e){function t(t){var n=e.call(this)||this;return n.apiName=t,n}return i.__extends(t,e),t.prototype.getEventName=function(){return"api-usage"},t.prototype.getPropertiesAsJson=function(){return r({},{api:this.apiName.toString()},e.prototype.getPropertiesAsJson.call(this))},t}(a);t.ApiUsageMetricEvent=u;var c=function(){function e(e,t){this.isFeatureEnabled=e,this.mixpanelReportingToken=t}return Object.defineProperty(e,"MIXPANEL_REPORTING_URL",{get:function(){return"https://api.mixpanel.com"},enumerable:!0,configurable:!0}),e.prototype.isEnabled=function(){return this.isFeatureEnabled&&!!this.mixpanelReportingToken},e.prototype.reportEvent=function(t){if(!this.isEnabled())return Promise.resolve(null);var n={event:t.getEventName(),properties:r({},{token:this.mixpanelReportingToken},t.getPropertiesAsJson())},i=o.base64Encode(JSON.stringify(n)),s={method:"GET",headers:new Headers,cache:"no-cache"};return fetch(e.MIXPANEL_REPORTING_URL+"/track/?data="+i,s)},e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),r=n(3),o=n(1),s=n(2),a=n(4);if(i.default.isBrowser())if(r.incrementSdkLoadCount(),r.getSdkLoadCount()>1)o.warn("OneSignal: The web push SDK is included more than once. For optimal performance, please include our SDK only once on your page."),o.debug("OneSignal: Exiting from SDK initialization to prevent double-initialization errors. Occurred "+r.getSdkLoadCount()+" times.");else{if("undefined"!=typeof OneSignal)var u=OneSignal;if(r.isPushNotificationsSupported()?window.OneSignal=n(43).default:(o.debug("OneSignal: Push notifications are not supported. A stubbed version of the SDK will be initialized."),window.OneSignal=n(91).default),u)for(var c=0;c0&&void 0!==arguments[0]?arguments[0]:"";i(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return Object.defineProperty(n,"message",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(n,"name",{configurable:!0,enumerable:!1,value:n.constructor.name,writable:!0}),Error.hasOwnProperty("captureStackTrace")?(Error.captureStackTrace(n,n.constructor),r(n)):(Object.defineProperty(n,"stack",{configurable:!0,enumerable:!1,value:new Error(e).stack,writable:!0}),n)}return o(t,e),t}(function(e){function t(){e.apply(this,arguments)}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Error));t.default=s,e.exports=t.default},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(7),TimeoutError=function(e){function TimeoutError(t){void 0===t&&(t="The asynchronous operation has timed out.");var n=e.call(this,t)||this;return n.message=t,n}return i.__extends(TimeoutError,e),TimeoutError}(r.default);t.default=TimeoutError},function(e,t){function n(){}function i(e,t,i){function o(){a.parentNode&&a.parentNode.removeChild(a),window[l]=n,u&&clearTimeout(u)}function s(){window[l]&&o()}"function"==typeof t&&(i=t,t={}),t||(t={});var a,u,c=t.prefix||"__jp",l=t.name||c+r++,d=t.param||"callback",f=null!=t.timeout?t.timeout:6e4,p=encodeURIComponent,g=document.getElementsByTagName("script")[0]||document.head;return f&&(u=setTimeout(function(){o(),i&&i(new Error("Timeout"))},f)),window[l]=function(e){o(),i&&i(null,e)},e+=(~e.indexOf("?")?"&":"?")+d+"="+p(l),e=e.replace("?&","?"),a=document.createElement("script"),a.src=e,g.parentNode.insertBefore(a,g),s}e.exports=i;var r=0},function(e,t,n){"use strict";function i(e){var t=arguments.length<=1||void 0===arguments[1]?"all":arguments[1];(0,o.default)(e);var n=s[t];return n&&n.test(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=n(61),o=function(e){return e&&e.__esModule?e:{default:e}}(r),s={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};e.exports=t.default},function(e,t,n){"use strict";function i(e){if("string"!=typeof e)throw new TypeError("This library (validator.js) validates strings only")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(7),PushNotSupportedError=function(e){function PushNotSupportedError(t){return e.call(this,"'"+t+"' is not a valid UUID")||this}return i.__extends(PushNotSupportedError,e),PushNotSupportedError}(r.default);t.default=PushNotSupportedError},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,r=n(0),o=n(7);!function(e){e[e.MissingAppId=0]="MissingAppId"}(i=t.OneSignalApiErrorKind||(t.OneSignalApiErrorKind={}));var s=function(e){function t(t){var n=this;switch(t){case i.MissingAppId:n=e.call(this,"The API call is missing an app ID.")||this}return n}return r.__extends(t,e),t}(o.default);t.OneSignalApiError=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e}();t.AppState=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e}();t.ServiceWorkerState=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(28),o=function(e){function t(){return e.call(this,".onesignal-bell-launcher-badge","onesignal-bell-launcher-badge-opened",null,"onesignal-bell-launcher-badge-active",null,"hidden")||this}return i.__extends(t,e),t.prototype.increment=function(){if(!isNaN(this.content)){var e=+this.content;e+=1,this.content=e.toString()}},t.prototype.show=function(){var t=e.prototype.show.call(this);return OneSignal.notifyButton.setCustomColorsIfSpecified(),t},t.prototype.decrement=function(){if(!isNaN(this.content)){var e=+this.content;e-=1,this.content=e>0?e.toString():""}},t}(r.default);t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(3),o=n(5),s=n(28),a=n(22),u=n(21),c=n(40),l=n(10),d=function(e){function t(t){var n=e.call(this,".onesignal-bell-launcher-button",null,null,"onesignal-bell-launcher-button-active",null,"shown","")||this;return n.bell=t,n.events={mouse:"bell.launcher.button.mouse"},n.element.addEventListener("touchstart",function(){n.onHovering(),n.onTap()},{passive:!0}),n.element.addEventListener("mouseenter",function(){n.onHovering()}),n.element.addEventListener("mouseleave",function(){n.onHovered()}),n.element.addEventListener("touchmove",function(){n.onHovered()},{passive:!0}),n.element.addEventListener("mousedown",function(){n.onTap()}),n.element.addEventListener("mouseup",function(){n.onEndTap()}),n.element.addEventListener("click",function(){n.onHovered(),n.onClick()}),n}return i.__extends(t,e),t.prototype.onHovering=function(){(u.default.isEmpty(this.events.mouse)||"out"===u.default.getLast(this.events.mouse))&&o.default.trigger(a.default.EVENTS.HOVERING),u.default.put(this.events.mouse,"over")},t.prototype.onHovered=function(){u.default.put(this.events.mouse,"out"),o.default.trigger(a.default.EVENTS.HOVERED)},t.prototype.onTap=function(){this.pulse(),this.activate(),this.bell.badge.activate()},t.prototype.onEndTap=function(){this.inactivate(),this.bell.badge.inactivate()},t.prototype.onClick=function(){var e=this;if(o.default.trigger(a.default.EVENTS.BELL_CLICK),o.default.trigger(a.default.EVENTS.LAUNCHER_CLICK),!this.bell.message.shown||this.bell.message.contentType!=c.default.TYPES.MESSAGE){var t=u.default.getLast("subscription.optedOut");return this.bell.unsubscribed?t?this.bell.launcher.activateIfInactive().then(function(){e.bell.showDialogProcedure()}):(OneSignal.registerForPushNotifications(),this.bell._ignoreSubscriptionState=!0,OneSignal.once(OneSignal.EVENTS.SUBSCRIPTION_CHANGED,function(){e.bell.message.display(c.default.TYPES.MESSAGE,e.bell.text["message.action.subscribed"],c.default.TIMEOUT).then(function(){e.bell._ignoreSubscriptionState=!1,e.bell.launcher.inactivate()})})):this.bell.subscribed?this.bell.launcher.activateIfInactive().then(function(){e.bell.showDialogProcedure()}):this.bell.blocked&&(l.default.isUsingSubscriptionWorkaround()?OneSignal.registerForPushNotifications():this.bell.launcher.activateIfInactive().then(function(){e.bell.showDialogProcedure()})),this.bell.message.hide()}},t.prototype.pulse=function(){r.removeDomElement(".pulse-ring"),r.addDomElement(this.element,"beforeend",'
'),this.bell.setCustomColorsIfSpecified()},t}(s.default);t.default=d},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(9),o=n(5),s=n(2),a=n(3),u=n(29),c=n(22),l=function(e){function t(t){var n=e.call(this,".onesignal-bell-launcher-dialog","onesignal-bell-launcher-dialog-opened",null,"hidden",["opacity","transform"],".onesignal-bell-launcher-dialog-body")||this;return n.bell=t,n.subscribeButtonId="#onesignal-bell-container .onesignal-bell-launcher #subscribe-button",n.unsubscribeButtonId="#onesignal-bell-container .onesignal-bell-launcher #unsubscribe-button",n.notificationIcons=null,n}return i.__extends(t,e),t.prototype.getPlatformNotificationIcon=function(){return this.notificationIcons?a.isChromeLikeBrowser()||r.firefox?this.notificationIcons.chrome||this.notificationIcons.safari:r.safari?this.notificationIcons.safari||this.notificationIcons.chrome:void 0:null},t.prototype.show=function(){var t=this;return this.updateBellLauncherDialogBody().then(function(){return e.prototype.show.call(t)})},Object.defineProperty(t.prototype,"subscribeButtonSelectorId",{get:function(){return"subscribe-button"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"unsubscribeButtonSelectorId",{get:function(){return"unsubscribe-button"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subscribeButton",{get:function(){return this.element.querySelector("#"+this.subscribeButtonSelectorId)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"unsubscribeButton",{get:function(){return this.element.querySelector("#"+this.unsubscribeButtonSelectorId)},enumerable:!0,configurable:!0}),t.prototype.updateBellLauncherDialogBody=function(){var e=this;return OneSignal.getSubscription().then(function(t){a.clearDomElementChildren(document.querySelector(e.nestedContentSelector));var n="Nothing to show.",i="";if(e.bell.options.showCredit&&(i='
Powered by OneSignal
'),e.bell.state===c.default.STATES.SUBSCRIBED&&!0===t||e.bell.state===c.default.STATES.UNSUBSCRIBED&&!1===t){var u="",l=e.getPlatformNotificationIcon();u=l?'
':'
';var d="";d=e.bell.state!==c.default.STATES.SUBSCRIBED?'":'",n="

"+e.bell.text["dialog.main.title"]+'

'+u+'
'+d+"
"+i}else if(e.bell.state===c.default.STATES.BLOCKED){var l=null;r.chrome?r.mobile||r.tablet||(l=s.default.getOneSignalApiUrl().origin+"/bell/chrome-unblock.jpg"):r.firefox?l=s.default.getOneSignalApiUrl().origin+"/bell/firefox-unblock.jpg":r.safari&&(l=s.default.getOneSignalApiUrl().origin+"/bell/safari-unblock.jpg");var f="";l&&(f=''),(r.mobile||r.tablet)&&r.chrome&&(f="
  1. Access Settings by tapping the three menu dots â‹®
  2. Click Site settings under Advanced.
  3. Click Notifications.
  4. Find and click this entry for this website.
  5. Click Notifications and set it to Allow.
"),n="

"+e.bell.text["dialog.blocked.title"]+'

'+e.bell.text["dialog.blocked.message"]+"

"+f+"
"+i}a.addDomElement(document.querySelector(e.nestedContentSelector),"beforeend",n),e.subscribeButton&&e.subscribeButton.addEventListener("click",function(){OneSignal.__doNotShowWelcomeNotification=!1,o.default.trigger(c.default.EVENTS.SUBSCRIBE_CLICK)}),e.unsubscribeButton&&e.unsubscribeButton.addEventListener("click",function(){return o.default.trigger(c.default.EVENTS.UNSUBSCRIBE_CLICK)}),e.bell.setCustomColorsIfSpecified()})},t}(u.default);t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(1),o=n(16),s=n(3),a=n(28),u=function(e){function t(t){var n=e.call(this,".onesignal-bell-launcher","onesignal-bell-launcher-active",null,null,"onesignal-bell-launcher-inactive","hidden","active")||this;return n.bell=t,n.wasInactive=!1,n}return i.__extends(t,e),t.prototype.resize=function(e){return i.__awaiter(this,void 0,void 0,function(){var t=this;return i.__generator(this,function(n){switch(n.label){case 0:if(!this.element)throw new o.InvalidStateError(o.InvalidStateReason.MissingDomElement);if("small"===e&&s.hasCssClass(this.element,"onesignal-bell-launcher-sm")||"medium"===e&&s.hasCssClass(this.element,"onesignal-bell-launcher-md")||"large"===e&&s.hasCssClass(this.element,"onesignal-bell-launcher-lg"))return[2,Promise.resolve(this)];if(s.removeCssClass(this.element,"onesignal-bell-launcher-sm"),s.removeCssClass(this.element,"onesignal-bell-launcher-md"),s.removeCssClass(this.element,"onesignal-bell-launcher-lg"),"small"===e)s.addCssClass(this.element,"onesignal-bell-launcher-sm");else if("medium"===e)s.addCssClass(this.element,"onesignal-bell-launcher-md");else{if("large"!==e)throw new Error("Invalid OneSignal bell size "+e);s.addCssClass(this.element,"onesignal-bell-launcher-lg")}return this.shown?[3,1]:[2,this];case 1:return[4,new Promise(function(e){if(0==t.targetTransitionEvents.length)return e(t);var n=setTimeout(function(){r.debug("Launcher did not completely resize (state: "+t.state+", activeState: "+t.activeState+").")},t.transitionCheckTimeout);s.once(t.element,"transitionend",function(i,r){if(i.target===t.element&&s.contains(t.targetTransitionEvents,i.propertyName))return clearTimeout(n),r(),e(t)},!0)})];case 2:return[2,n.sent()]}})})},t.prototype.activateIfInactive=function(){return this.inactive?(this.wasInactive=!0,this.activate()):s.nothing()},t.prototype.inactivateIfWasInactive=function(){return this.wasInactive?(this.wasInactive=!1,this.inactivate()):s.nothing()},t.prototype.clearIfWasInactive=function(){this.wasInactive=!1},t.prototype.inactivate=function(){var t=this;return this.bell.message.hide().then(function(){return t.bell.badge.content.length>0?t.bell.badge.hide().then(function(){return Promise.all([e.prototype.inactivate.call(t),t.resize("small")])}).then(function(){return t.bell.badge.show()}):Promise.all([e.prototype.inactivate.call(t),t.resize("small")])})},t.prototype.activate=function(){var t=this;return this.bell.badge.content.length>0?this.bell.badge.hide().then(function(){return Promise.all([e.prototype.activate.call(t),t.resize(t.bell.options.size)])}):Promise.all([e.prototype.activate.call(this),this.resize(this.bell.options.size)])},t}(a.default);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,r=n(0),o=n(7);!function(e){e[e.Unknown=0]="Unknown",e[e.NoDeviceId=1]="NoDeviceId",e[e.OptedOut=2]="OptedOut"}(i=t.NotSubscribedReason||(t.NotSubscribedReason={}));var NotSubscribedError=function(e){function NotSubscribedError(t){var n=this;switch(t){case i.Unknown||i.NoDeviceId:n=e.call(this,"This operation can only be performed after the user is subscribed.")||this;break;case i.OptedOut:n=e.call(this,"The user has manually opted out of receiving of notifications. This operation can only be performed after the user is fully resubscribed.")||this}return n.reason=i[t],n}return r.__extends(NotSubscribedError,e),NotSubscribedError}(o.default);t.NotSubscribedError=NotSubscribedError},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(1),o=n(5),s=n(48),a=n(2),u=n(4),c=n(72),l=n(82),d=n(83),f=n(3),p=function(){function e(){}return e.initHttp=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:switch(r.debug("Called %cinitHttp("+JSON.stringify(e,null,4)+")",f.getConsoleStyle("code")),t=a.default.getWindowEnv()){case u.WindowEnvironmentKind.OneSignalProxyFrame:return[3,1];case u.WindowEnvironmentKind.OneSignalSubscriptionPopup:return[3,3];case u.WindowEnvironmentKind.OneSignalSubscriptionModal:return[3,5]}return[3,6];case 1:return OneSignal.proxyFrame=new c.default(e),[4,OneSignal.proxyFrame.initialize()];case 2:return n.sent(),s.default.ensureBackwardsCompatibility(OneSignal),[3,7];case 3:return OneSignal.subscriptionPopup=new d.default(e),[4,OneSignal.subscriptionPopup.initialize()];case 4:return n.sent(),s.default.ensureBackwardsCompatibility(OneSignal),o.default.trigger("httpInitialize"),[3,7];case 5:return OneSignal.subscriptionModal=new l.default(e),OneSignal.subscriptionModal.establishCrossOriginMessaging(),OneSignal.subscriptionModal.initialize(),s.default.ensureBackwardsCompatibility(OneSignal),o.default.trigger("httpInitialize"),[3,7];case 6:return r.error("Unsupported HTTP initialization branch."),[3,7];case 7:return[2]}})})},e}();t.default=p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(1),o=n(8),s=n(5),a=n(32),u=n(13),c=n(51),l=n(2),d=n(17),f=n(11),p=n(3),g=n(34),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i.__extends(t,e),t.prototype.initialize=function(){var t=e.prototype.initialize.call(this);return s.default.trigger("httpInitialize"),t},t.prototype.establishCrossOriginMessaging=function(){this.messenger&&this.messenger.destroy(),this.messenger=new d.default(window,this.options.origin,this.options.origin),this.messenger.on(OneSignal.POSTMAM_COMMANDS.CONNECTED,this.onMessengerConnect.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.IFRAME_POPUP_INITIALIZE,this.onProxyFrameInitializing.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION,this.onRemoteNotificationPermission.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_GET,this.onRemoteDatabaseGet.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_PUT,this.onRemoteDatabasePut.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.REMOTE_DATABASE_REMOVE,this.onRemoteDatabaseRemove.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_FROM_PUSH,this.onUnsubscribeFromPush.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.MARK_PROMPT_DISMISSED,this.onMarkPromptDismissed.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.IS_SUBSCRIBED,this.onIsSubscribed.bind(this)),this.messenger.on(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_PROXY_FRAME,this.onUnsubscribeProxyFrame.bind(this)),this.messenger.listen()},t.prototype.retriggerRemoteEvent=function(e,t){this.messenger.message(OneSignal.POSTMAM_COMMANDS.REMOTE_RETRIGGER_EVENT,{eventName:e,eventData:t})},t.prototype.onMessengerConnect=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){return r.debug("("+l.default.getWindowEnv().toString()+") Successfully established cross-origin communication."),this.finishInitialization(),[2,!1]})})},t.prototype.onProxyFrameInitializing=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return r.info("("+l.default.getWindowEnv().toString()+") The iFrame has just received initOptions from the host page!"),OneSignal.config=o(e.data.hostInitOptions,OneSignal.config,{pageUrl:e.data.pageUrl,pageTitle:e.data.pageTitle}),a.default.installNativePromptPermissionChangedHook(),[4,f.default.get("Options","defaultUrl")];case 1:return t=n.sent(),t?[3,3]:[4,f.default.put("Options",{key:"defaultUrl",value:new URL(OneSignal.config.pageUrl).origin})];case 2:n.sent(),n.label=3;case 3:return[4,f.default.put("Options",{key:"lastKnownHostUrl",value:OneSignal.config.pageUrl})];case 4:return n.sent(),[4,a.default.initSaveState(OneSignal.config.pageTitle)];case 5:return n.sent(),[4,a.default.storeInitialValues()];case 6:return n.sent(),[4,a.default.saveInitOptions()];case 7:if(n.sent(),navigator.serviceWorker&&"https:"===window.location.protocol)try{u.default.establishServiceWorkerChannel()}catch(e){r.error("Error interacting with Service Worker inside an HTTP-hosted iFrame:",e)}return e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),[2]}})})},t.prototype.onRemoteNotificationPermission=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n;return i.__generator(this,function(i){switch(i.label){case 0:return t=OneSignal.context,[4,t.permissionManager.getReportedNotificationPermission(t.appConfig.safariWebId)];case 1:return n=i.sent(),e.reply(n),[2,!1]}})})},t.prototype.onRemoteDatabaseGet=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,o,s,a,u,c;return i.__generator(this,function(i){switch(i.label){case 0:for(t=e.data,n=[],r=0,o=t;r Host) User unsubscribed but permission granted. Re-prompting the user for push."),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,p.unsubscribeFromPush()];case 2:return n.sent(),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),[3,4];case 3:return t=n.sent(),r.debug("Failed to unsubscribe from push remotely:",t),[3,4];case 4:return[2]}})})},t.prototype.onMarkPromptDismissed=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){return r.debug("(Reposted from iFrame -> Host) Marking prompt as dismissed."),c.default.markHttpsNativePromptDismissed(),e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),[2,!1]})})},t.prototype.onIsSubscribed=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return[4,OneSignal.isPushNotificationsEnabled()];case 1:return t=n.sent(),e.reply(t),[2,!1]}})})},t.prototype.onUnsubscribeProxyFrame=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return[4,OneSignal.isPushNotificationsEnabled()];case 1:return t=n.sent(),t?[4,OneSignal.setSubscription(!1)]:[3,4];case 2:return n.sent(),[4,OneSignal.database.rebuild()];case 3:n.sent(),n.label=4;case 4:return e.reply(OneSignal.POSTMAM_COMMANDS.REMOTE_OPERATION_COMPLETE),[2,!1]}})})},t}(g.default);t.default=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(1),o=n(5),s=n(13),a=n(10),u=n(2),c=n(17),l=function(){function e(e,t){this.appId=e,this.registrationOptions=t}return e.prototype.load=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t;return i.__generator(this,function(n){switch(n.label){case 0:return[4,OneSignal.isPushNotificationsEnabled()];case 1:return e=n.sent(),[4,OneSignal.getNotificationPermission()];case 2:return t=n.sent(),this.url=u.default.getOneSignalApiUrl(),this.url.pathname="webPushModal",this.url.search=s.default.getPromptOptionsQueryString()+"&id="+this.appId.value+"&httpsPrompt=true&pushEnabled="+e+"&permissionBlocked="+("denied"===t)+"&promptType=modal",r.info("Loading iFrame for HTTPS subscription modal at "+this.url.toString()),this.modal=this.createHiddenSubscriptionDomModal(this.url.toString()),this.establishCrossOriginMessaging(),[2]}})})},e.prototype.createHiddenSubscriptionDomModal=function(e){var t=document.createElement("div");t.setAttribute("id","OneSignal-iframe-modal"),t.setAttribute("style","display:none !important"),t.innerHTML='
',document.body.appendChild(t);var n=document.createElement("style");n.innerHTML="@media (max-width: 560px) { .OneSignal-permission-iframe { width: 100%; height: 100%;} }",document.getElementsByTagName("head")[0].appendChild(n);var i=document.createElement("iframe");return i.className="OneSignal-permission-iframe",i.setAttribute("frameborder","0"),i.width=OneSignal._windowWidth.toString(),i.height=OneSignal._windowHeight.toString(),i.src=e,document.getElementById("notif-permission").appendChild(i),i},e.prototype.removeFrame=function(){var e=document.querySelector("#OneSignal-iframe-modal");e&&e.remove()},e.prototype.showSubscriptionDomModal=function(){document.getElementById("OneSignal-iframe-modal").setAttribute("style","")},e.prototype.establishCrossOriginMessaging=function(){this.messenger=new c.default(this.modal,this.url.origin,this.url.origin),this.messenger.startPostMessageReceive(),this.messenger.once(OneSignal.POSTMAM_COMMANDS.MODAL_LOADED,this.onModalLoaded.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.MODAL_PROMPT_ACCEPTED,this.onModalAccepted.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.MODAL_PROMPT_REJECTED,this.onModalRejected.bind(this)),this.messenger.once(OneSignal.POSTMAM_COMMANDS.POPUP_CLOSING,this.onModalClosing.bind(this))},e.prototype.onModalLoaded=function(e){this.showSubscriptionDomModal(),o.default.trigger("modalLoaded")},e.prototype.onModalAccepted=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return r.debug("User accepted the HTTPS modal prompt.",location.origin),OneSignal._sessionInitAlreadyRunning=!1,this.dispose(),s.default.triggerCustomPromptClicked("granted"),r.debug("Calling setSubscription(true)"),[4,a.default.registerForPush()];case 1:return e.sent(),[4,OneSignal.setSubscription(!0)];case 2:return e.sent(),[2]}})})},e.prototype.onModalRejected=function(e){r.debug("User rejected the HTTPS modal prompt."),OneSignal._sessionInitAlreadyRunning=!1,this.dispose(),s.default.triggerCustomPromptClicked("denied")},e.prototype.onModalClosing=function(e){r.info("Detected modal is closing."),this.dispose()},e.prototype.dispose=function(){this.messenger&&this.messenger.destroy(),this.removeFrame()},e.prototype.message=function(){this.messenger.message.apply(this.messenger,arguments)},e}();t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e.Mobile="mobile",e.Tablet="tablet",e.Desktop="desktop"}(t.DevicePlatformKind||(t.DevicePlatformKind={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(9),o=n(1),s=n(16),a=n(14),u=n(14),c=n(31),l=n(52),d=n(52),f=n(5),p=n(15),g=n(76),h=n(20),v=n(33),m=n(77),b=n(78),S=n(4),w=n(19),_=n(11),y=n(2),O=n(26),E=n(50),P=n(53),I=function(){function e(e,t){this.context=e,this.config=t}return e.prototype.isSafari=function(){return r.safari&&void 0!==window.safari&&void 0!==window.safari.pushNotification},e.prototype.subscribe=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t,n;return i.__generator(this,function(i){switch(i.label){case 0:switch(e=y.default.getWindowEnv()){case S.WindowEnvironmentKind.CustomIframe:case S.WindowEnvironmentKind.Unknown:case S.WindowEnvironmentKind.OneSignalSubscriptionModal:case S.WindowEnvironmentKind.OneSignalSubscriptionPopup:case S.WindowEnvironmentKind.OneSignalProxyFrame:throw new s.InvalidStateError(s.InvalidStateReason.UnsupportedEnvironment)}switch(n=e){case S.WindowEnvironmentKind.ServiceWorker:return[3,1];case S.WindowEnvironmentKind.Host:return[3,3]}return[3,9];case 1:return[4,this.subscribeFcmFromWorker()];case 2:return t=i.sent(),[3,9];case 3:return[4,OneSignal.getNotificationPermission()];case 4:if(i.sent()===h.NotificationPermission.Denied)throw new a.default(u.PushPermissionNotGrantedErrorReason.Blocked);return this.isSafari()?[4,this.subscribeSafari()]:[3,6];case 5:return t=i.sent(),[3,8];case 6:return[4,this.subscribeFcmFromPage()];case 7:t=i.sent(),i.label=8;case 8:return[3,9];case 9:return[2,this.registerSubscriptionWithOneSignal(t)]}})})},e.prototype.subscribePartially=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return[4,this.subscribeFcmFromPage()];case 1:return[2,e.sent()]}})})},e.prototype.requestPresubscribeNotificationPermission=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){return[2,e.requestNotificationPermission()]})})},e.prototype.unsubscribe=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:if(0!==e)return[3,1];throw new E.default;case 1:return 1!==e?[3,7]:y.default.getWindowEnv()!==S.WindowEnvironmentKind.ServiceWorker?[3,5]:[4,_.default.getSubscription()];case 2:return t=n.sent().deviceId,[4,w.default.updatePlayer(this.context.appConfig.appId,t,{notification_types:b.SubscriptionStateKind.MutedByApi})];case 3:return n.sent(),[4,_.default.put("Options",{key:"optedOut",value:!0})];case 4:return n.sent(),[3,6];case 5:throw new E.default;case 6:return[3,8];case 7:throw new E.default;case 8:return[2]}})})},e.requestNotificationPermission=function(){return new Promise(function(e){return window.Notification.requestPermission(e)})},e.prototype.registerSubscriptionWithOneSignal=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,s,a,u;return i.__generator(this,function(i){switch(i.label){case 0:return t=new v.PushRegistration,t.appId=this.config.appId,this.isSafari()?t.deliveryPlatform=g.DeliveryPlatformKind.Safari:r.firefox?t.deliveryPlatform=g.DeliveryPlatformKind.Firefox:t.deliveryPlatform=g.DeliveryPlatformKind.ChromeLike,t.subscriptionState=b.SubscriptionStateKind.Subscribed,e=m.RawPushSubscription.deserialize(e),t.subscription=e,[4,this.isAlreadyRegisteredWithOneSignal()];case 1:return i.sent()?[4,_.default.getSubscription()]:[3,6];case 2:return s=i.sent().deviceId,e.isNewSubscription()?[4,w.default.updateUserSession(s,t)]:[3,4];case 3:return n=i.sent(),o.info("Updated the subscriber's OneSignal session:",t),[3,5];case 4:n=s,o.debug("The existing push subscription was resubscribed, but not registering with OneSignal because the new subscription is identical."),i.label=5;case 5:return[3,8];case 6:return[4,w.default.createUser(t)];case 7:a=i.sent(),n=a,o.info("Subscribed to web push and registered with OneSignal:",t),i.label=8;case 8:return y.default.getWindowEnv()!==S.WindowEnvironmentKind.ServiceWorker&&f.default.trigger(OneSignal.EVENTS.REGISTERED),u=new O.Subscription,u.deviceId=n,u.optedOut=!1,this.isSafari()?u.subscriptionToken=e.safariDeviceToken:u.subscriptionToken=e.w3cEndpoint.toString(),[4,_.default.setSubscription(u)];case 9:return i.sent(),[2,u]}})})},e.prototype.isAlreadyRegisteredWithOneSignal=function(){return i.__awaiter(this,void 0,void 0,function(){var e;return i.__generator(this,function(t){switch(t.label){case 0:return[4,_.default.getSubscription()];case 1:return e=t.sent().deviceId,[2,!!e.value]}})})},e.prototype.subscribeSafariPromptPermission=function(){var e=this;return new Promise(function(t){window.safari.pushNotification.requestPermission(y.default.getOneSignalApiUrl().toString()+"/safari",e.config.safariWebId,{app_id:e.config.appId.value},function(e){t(e.deviceToken?e.deviceToken.toLowerCase():null)})})},e.prototype.subscribeSafari=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t,n;return i.__generator(this,function(i){switch(i.label){case 0:if(e=new m.RawPushSubscription,!this.config.safariWebId)throw new c.SdkInitError(c.SdkInitErrorKind.MissingSafariWebId);return t=window.safari.pushNotification.permission(this.config.safariWebId).deviceToken,e.existingSafariDeviceToken=t,t||f.default.trigger(OneSignal.EVENTS.PERMISSION_PROMPT_DISPLAYED),[4,this.subscribeSafariPromptPermission()];case 1:if(n=i.sent(),p.default.triggerNotificationPermissionChanged(),!n)throw new l.default(d.SubscriptionErrorReason.InvalidSafariSetup);return e.setFromSafariSubscription(n),[2,e]}})})},e.prototype.subscribeFcmFromPage=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t;return i.__generator(this,function(n){switch(n.label){case 0:return y.default.getWindowEnv()===S.WindowEnvironmentKind.ServiceWorker||window.Notification.permission!==h.NotificationPermission.Default?[3,2]:(f.default.trigger(OneSignal.EVENTS.PERMISSION_PROMPT_DISPLAYED),[4,this.requestPresubscribeNotificationPermission()]);case 1:switch(e=n.sent(),e===h.NotificationPermission.Default&&p.default.triggerNotificationPermissionChanged(!0),e){case h.NotificationPermission.Default:throw o.debug("Exiting subscription and not registering worker because the permission was dismissed."),OneSignal._sessionInitAlreadyRunning=!1,OneSignal._isRegisteringForPush=!1,new a.default(u.PushPermissionNotGrantedErrorReason.Dismissed);case h.NotificationPermission.Denied:throw o.debug("Exiting subscription and not registering worker because the permission was blocked."),OneSignal._sessionInitAlreadyRunning=!1,OneSignal._isRegisteringForPush=!1,new a.default(u.PushPermissionNotGrantedErrorReason.Blocked)}n.label=2;case 2:return[4,this.context.serviceWorkerManager.shouldInstallWorker()];case 3:return n.sent()?[4,this.context.serviceWorkerManager.installWorker()]:[3,5];case 4:n.sent(),n.label=5;case 5:return o.debug("Waiting for the service worker to activate..."),[4,navigator.serviceWorker.ready];case 6:return t=n.sent(),o.debug("Service worker is ready to continue subscribing."),[4,this.subscribeFcmVapidOrLegacyKey(t)];case 7:return[2,n.sent()]}})})},e.prototype.subscribeFcmFromWorker=function(){return i.__awaiter(this,void 0,void 0,function(){var e;return i.__generator(this,function(t){switch(t.label){case 0:if(!self.registration.active&&!r.firefox)throw new s.InvalidStateError(s.InvalidStateReason.ServiceWorkerNotActivated);return[4,self.registration.pushManager.permissionState({userVisibleOnly:!0})];case 1:if("denied"===(e=t.sent()))throw OneSignal._sessionInitAlreadyRunning=!1,new a.default(u.PushPermissionNotGrantedErrorReason.Blocked);if("prompt"===e)throw OneSignal._sessionInitAlreadyRunning=!1,new a.default(u.PushPermissionNotGrantedErrorReason.Default);return[4,this.subscribeFcmVapidOrLegacyKey(self.registration)];case 2:return[2,t.sent()]}})})},e.prototype.getVapidKeyForBrowser=function(){var e=void 0;return e=r.firefox?this.config.onesignalVapidPublicKey:this.config.vapidPublicKey,e?P.base64ToUint8Array(e).buffer:void 0},e.prototype.subscribeFcmVapidOrLegacyKey=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,s;return i.__generator(this,function(i){switch(i.label){case 0:return t={userVisibleOnly:!0,applicationServerKey:this.getVapidKeyForBrowser()?this.getVapidKeyForBrowser():void 0},[4,e.pushManager.getSubscription()];case 1:return(r=i.sent())&&r.options?(o.debug("[Subscription Manager] An existing push subscription exists and options is not null. Using existing options to resubscribe."),t=r.options,[3,4]):[3,2];case 2:return!r||r.options?[3,4]:(o.debug("[Subscription Manager] An existing push subscription exists and options is null. Unsubscribing from push first now."),[4,r.unsubscribe()]);case 3:i.sent(),i.label=4;case 4:return o.debug("[Subscription Manager] Subscribing to web push with these options:",t),[4,e.pushManager.subscribe(t)];case 5:return n=i.sent(),s=new m.RawPushSubscription,s.setFromW3cSubscription(n),r&&(s.existingW3cPushSubscription=new m.RawPushSubscription,s.existingW3cPushSubscription.setFromW3cSubscription(r)),[2,s]}})})},e}();t.SubscriptionManager=I},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.ChromeLike=5]="ChromeLike",e[e.Safari=7]="Safari",e[e.Firefox=8]="Firefox"}(t.DeliveryPlatformKind||(t.DeliveryPlatformKind={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e.prototype.isNewSubscription=function(){return this.existingW3cPushSubscription?this.existingW3cPushSubscription.w3cEndpoint.toString()!==this.w3cEndpoint.toString()||this.existingW3cPushSubscription.w3cP256dh!==this.w3cP256dh||this.existingW3cPushSubscription.w3cAuth!==this.w3cAuth:!this.existingSafariDeviceToken||this.existingSafariDeviceToken!==this.safariDeviceToken},e.prototype.setFromW3cSubscription=function(e){if(e&&(this.w3cEndpoint=new URL(e.endpoint),e.getKey)){var t=null;try{t=e.getKey("p256dh")}catch(e){}var n=null;try{n=e.getKey("auth")}catch(e){}if(t){var i=btoa(String.fromCharCode.apply(null,new Uint8Array(t)));this.w3cP256dh=i}if(n){var r=btoa(String.fromCharCode.apply(null,new Uint8Array(n)));this.w3cAuth=r}}},e.prototype.setFromSafariSubscription=function(e){this.safariDeviceToken=e},e.prototype.serialize=function(){return{w3cEndpoint:this.w3cEndpoint.toString(),w3cP256dh:this.w3cP256dh,w3cAuth:this.w3cAuth,safariDeviceToken:this.safariDeviceToken,existingPushSubscription:this.existingW3cPushSubscription?this.existingW3cPushSubscription.serialize():null,existingSafariDeviceToken:this.existingSafariDeviceToken}},e.deserialize=function(t){var n=new e;try{n.w3cEndpoint=new URL(t.w3cEndpoint)}catch(e){}return n.w3cP256dh=t.w3cP256dh,n.w3cAuth=t.w3cAuth,n.existingW3cPushSubscription=t.existingPushSubscription?e.deserialize(t.existingPushSubscription):null,n.safariDeviceToken=t.safariDeviceToken,n.existingSafariDeviceToken=t.existingSafariDeviceToken,n},e}();t.RawPushSubscription=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});!function(e){e[e.Subscribed=1]="Subscribed",e[e.MutedByApi=-2]="MutedByApi",e[e.MutedByUser=-3]="MutedByUser"}(t.SubscriptionStateKind||(t.SubscriptionStateKind={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),r=function(){function e(e){this.isFeatureEnabled=e}return Object.defineProperty(e,"SYNC_URL",{get:function(){return"https://rc.rlcdn.com/463096.gif?n=5"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DOM_ID",{get:function(){return"onesignal-cookie-sync"},enumerable:!0,configurable:!0}),e.prototype.getElement=function(){return document.getElementById(e.DOM_ID)},e.prototype.uninstall=function(){this.getElement()&&this.getElement().remove()},e.prototype.install=function(){if(!this.isFeatureEnabled)return void i.debug("Cookie sync feature is disabled.");this.uninstall();var t=document.createElement("img");t.setAttribute("id",e.DOM_ID),t.setAttribute("border","0"),t.setAttribute("hspace","0"),t.setAttribute("vspace","0"),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("src",e.SYNC_URL),document.querySelector("body").appendChild(t),i.debug("Enabled cookie sync feature.")},e}();t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),r=n(2),o=n(4),s=function(){function e(){}return e.prototype.getPageViewCount=function(){try{var t=sessionStorage.getItem(e.SESSION_STORAGE_KEY_NAME),n=parseInt(t);return isNaN(n)?0:n}catch(e){return 0}},e.prototype.setPageViewCount=function(t){try{sessionStorage.setItem(e.SESSION_STORAGE_KEY_NAME,t.toString()),r.default.getWindowEnv()===o.WindowEnvironmentKind.OneSignalSubscriptionPopup&&OneSignal.subscriptionPopup&&OneSignal.subscriptionPopup.message(OneSignal.POSTMAM_COMMANDS.SET_SESSION_COUNT)}catch(e){}},e.prototype.incrementPageViewCount=function(){if(!this.incrementedPageViewCount){var e=this.getPageViewCount()+1;this.setPageViewCount(e),i.debug("Incremented page view count to "+e+"."),this.incrementedPageViewCount=!0}},e.prototype.simulatePageNavigationOrRefresh=function(){this.incrementedPageViewCount=!1},e.prototype.isFirstPageView=function(){return 1===this.getPageViewCount()},e.SESSION_STORAGE_KEY_NAME="onesignal-pageview-count",e}();t.SessionManager=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(3),o=n(10),s=n(9),a=n(18),u=n(11),c=n(20),l=function(){function e(){}return Object.defineProperty(e,"STORED_PERMISSION_KEY",{get:function(){return"storedNotificationPermission"},enumerable:!0,configurable:!0}),e.prototype.getNotificationPermission=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return[4,this.getReportedNotificationPermission(e)];case 1:return t=n.sent(),[4,this.isPermissionEnvironmentAmbiguous(t)];case 2:return n.sent()?[2,this.getInterpretedAmbiguousPermission(t)]:[2,t]}})})},e.prototype.getReportedNotificationPermission=function(e){return i.__awaiter(this,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return s.safari?[2,this.getSafariNotificationPermission(e)]:[3,1];case 1:return[4,o.default.isUsingSubscriptionWorkaround()];case 2:return t=n.sent(),t?[4,r.awaitOneSignalInitAndSupported()]:[3,4];case 3:return n.sent(),[2,this.getOneSignalSubdomainNotificationPermission(e)];case 4:return[2,this.getW3cNotificationPermission()]}})})},e.prototype.getSafariNotificationPermission=function(e){if(e)return window.safari.pushNotification.permission(e).permission;throw new a.InvalidArgumentError("safariWebId",a.InvalidArgumentReason.Empty)},e.prototype.getW3cNotificationPermission=function(){return window.Notification.permission},e.prototype.getOneSignalSubdomainNotificationPermission=function(e){return new Promise(function(t){OneSignal.proxyFrameHost.message(OneSignal.POSTMAM_COMMANDS.REMOTE_NOTIFICATION_PERMISSION,{safariWebId:e},function(e){var n=e.data;t(n)})})},e.prototype.isPermissionEnvironmentAmbiguous=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,s;return i.__generator(this,function(i){switch(i.label){case 0:return t=r.redetectBrowserUserAgent(),(n=!t.safari&&!t.firefox&&e===c.NotificationPermission.Denied)?(s=this.isCurrentFrameContextCrossOrigin(),s?[3,2]:[4,o.default.hasInsecureParentOrigin()]):[3,3];case 1:s=i.sent(),i.label=2;case 2:n=s||o.default.isInsecureOrigin(),i.label=3;case 3:return[2,n]}})})},e.prototype.isCurrentFrameContextCrossOrigin=function(){var e;try{e=window.top.location.origin}catch(e){return!0}return window.top!==window&&e!==window.location.origin},e.prototype.getInterpretedAmbiguousPermission=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n;return i.__generator(this,function(i){switch(i.label){case 0:switch(t=e){case c.NotificationPermission.Denied:return[3,1]}return[3,3];case 1:return[4,this.getStoredPermission()];case 2:return n=i.sent(),n?[2,n]:[2,c.NotificationPermission.Default];case 3:return[2,e]}})})},e.prototype.getStoredPermission=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){switch(t.label){case 0:return[4,u.default.get("Options",e.STORED_PERMISSION_KEY)];case 1:return[2,t.sent()]}})})},e.prototype.setStoredPermission=function(t){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(n){switch(n.label){case 0:return[4,u.default.put("Options",{key:e.STORED_PERMISSION_KEY,value:t})];case 1:return n.sent(),[2]}})})},e.prototype.updateStoredPermission=function(){return i.__awaiter(this,void 0,void 0,function(){var e;return i.__generator(this,function(t){switch(t.label){case 0:return[4,this.getNotificationPermission(null)];case 1:return e=t.sent(),[4,this.setStoredPermission(e)];case 2:return[2,t.sent()]}})})},e}();t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(17),o=n(34),s=function(e){function t(t){return e.call(this,t)||this}return i.__extends(t,e),t.prototype.establishCrossOriginMessaging=function(){this.messenger&&this.messenger.destroy(),this.messenger=new r.default(window.parent,this.options.origin,this.options.origin)},t}(o.default);t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(1),o=n(2),s=n(17),a=n(34),u=function(e){function t(t){return e.call(this,t)||this}return i.__extends(t,e),t.prototype.establishCrossOriginMessaging=function(){this.messenger=new s.default(window.opener,this.options.origin,this.options.origin),this.messenger.once(OneSignal.POSTMAM_COMMANDS.CONNECTED,this.onMessengerConnected.bind(this)),this.messenger.postMessage(OneSignal.POSTMAM_COMMANDS.POPUP_BEGIN_MESSAGEPORT_COMMS,null),this.messenger.listen()},t.prototype.onMessengerConnected=function(e){r.debug("("+o.default.getWindowEnv().toString()+") The host page is now ready to receive commands from the HTTP popup."),this.finishInitialization()},t}(a.default);t.default=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(24),o=n(85),s=n(3),a=n(2),u=function(){function e(){}return e.discoverAltOrigin=function(t){return i.__awaiter(this,void 0,void 0,function(){var n,r,a,u,c,l,d,f,p,g,d;return i.__generator(this,function(i){switch(i.label){case 0:n=e.getOneSignalProxyIframeUrls(t),r=[],u=0,c=n,i.label=1;case 1:return u Host) Getting event listener count for ",t);var n=OneSignal.getListeners(t).length;return e.reply(n),!1},e.prototype.isSubscribed=function(){var e=this;return new Promise(function(t){e.messenger.message(OneSignal.POSTMAM_COMMANDS.IS_SUBSCRIBED,null,function(e){t(e.data)})})},e.prototype.unsubscribeFromPush=function(){var e=this;return new Promise(function(t){e.messenger.message(OneSignal.POSTMAM_COMMANDS.UNSUBSCRIBE_PROXY_FRAME,null,function(e){t()})})},e.prototype.message=function(){for(var e=[],t=0;t
'+this.options.actionMessage+'
',u.addDomElement("body","beforeend",'
'),u.addDomElement(this.container,"beforeend",'
'+c+"
"),u.addCssClass(this.container,r.mobile?"slide-up":"slide-down"),this.allowButton.addEventListener("click",this.onPopoverAllowed.bind(this)),this.cancelButton.addEventListener("click",this.onPopoverCanceled.bind(this)),s.default.trigger(e.EVENTS.SHOWN),i.label=2;case 2:return[2]}})})},e.prototype.onPopoverAllowed=function(t){s.default.trigger(e.EVENTS.ALLOW_CLICK)},e.prototype.onPopoverCanceled=function(t){s.default.trigger(e.EVENTS.CANCEL_CLICK),this.close()},e.prototype.close=function(){var t=this;u.addCssClass(this.container,"close-popover"),u.once(this.dialog,"animationend",function(n,i){n.target!==t.dialog||"slideDownExit"!==n.animationName&&"slideUpExit"!==n.animationName||(u.removeDomElement("#onesignal-popover-container"),i(),s.default.trigger(e.EVENTS.CLOSED))},!0)},e.prototype.getPlatformNotificationIcon=function(){return this.notificationIcons?u.isChromeLikeBrowser()||r.firefox?this.notificationIcons.chrome?this.notificationIcons.chrome:this.notificationIcons.firefox?this.notificationIcons.firefox:"default-icon":r.safari?this.notificationIcons.safari?this.notificationIcons.safari:this.notificationIcons.chrome?this.notificationIcons.chrome:"default-icon":void 0:"default-icon"},Object.defineProperty(e.prototype,"container",{get:function(){return document.querySelector("#onesignal-popover-container")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dialog",{get:function(){return document.querySelector("#onesignal-popover-dialog")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowButton",{get:function(){return document.querySelector("#onesignal-popover-allow-button")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cancelButton",{get:function(){return document.querySelector("#onesignal-popover-cancel-button")},enumerable:!0,configurable:!0}),e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=null;i={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}},i.bitArray={bitSlice:function(e,t,n){return e=i.bitArray._shiftRight(e.slice(t/32),32-(31&t)).slice(1),void 0===n?e:i.bitArray.clamp(e,n-t)},extract:function(e,t,n){var i=Math.floor(-t-n&31);return(-32&(t+n-1^t)?e[t/32|0]<<32-i^e[t/32+1|0]>>>i:e[t/32|0]>>>i)&(1<0&&t&&(e[n-1]=i.bitArray.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:function(e,t,n){return 32===e?t:(n?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(i.bitArray.bitLength(e)!==i.bitArray.bitLength(t))return!1;var n,r=0;for(n=0;n=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(o=0;o>>t),n=e[o]<<32-t;return a=e.length?e[e.length-1]:0,s=i.bitArray.getPartial(a),r.push(i.bitArray.partial(t+s&31,t+s>32?n:r.pop(),1)),r},_xor4:function(e,t){return[e[0]^t[0],e[1]^t[1],e[2]^t[2],e[3]^t[3]]},byteswapM:function(e){var t,n;for(t=0;t>>24|n>>>8&65280|(65280&n)<<8|n<<24;return e}},i.codec.utf8String={fromBits:function(e){var t,n,r="",o=i.bitArray.bitLength(e);for(t=0;t>>24),n<<=8;return decodeURIComponent(window.escape(r))},toBits:function(e){e=window.unescape(encodeURIComponent(e));var t,n=[],r=0;for(t=0;t>>24|i>>8&65280|(65280&i)<<8|(255&i)<<24},_T:[],_precompute:function(){var e;for(e=0;e<64;e++)this._T[e]=4294967296*Math.abs(Math.sin(e+1))|0},_block:function(e,t){var n,i,r,o,s,a=e.slice(0),u=this._h,c=this._T;for(i=u[0],r=u[1],o=u[2],s=u[3],this._BS(a,t?16:14),n=0;n<64;n++){var l,d,f,p;n<32?n<16?(l=r&o|~r&s,d=n,f=[7,12,17,22]):(l=s&r|~s&o,d=(5*n+1)%16,f=[5,9,14,20]):n<48?(l=r^o^s,d=(3*n+5)%16,f=[4,11,16,23]):(l=o^(r|~s),d=7*n%16,f=[6,10,15,21]),p=i+l+a[d]+c[n],i=s,s=o,o=r,r=(p<>>32-f[n%4])+r|0}u[0]+=i,u[1]+=r,u[2]+=o,u[3]+=s}},i.hash.sha256=function(e){this._key[0]||this._precompute(),e?(this._h=e._h.slice(0),this._buffer=e._buffer.slice(0),this._length=e._length):this.reset()},i.hash.sha256.hash=function(e){return(new i.hash.sha256).update(e).finalize()},i.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(e){"string"==typeof e&&(e=i.codec.utf8String.toBits(e));var t,n=this._buffer=i.bitArray.concat(this._buffer,e),r=this._length,o=this._length=r+i.bitArray.bitLength(e);if(o>9007199254740991)throw new i.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var s=new Uint32Array(n),a=0;for(t=512+r-(512+r&511);t<=o;t+=512)this._block(s.subarray(16*a,16*(a+1))),a+=1;n.splice(0,16*a)}else for(t=512+r-(512+r&511);t<=o;t+=512)this._block(n.splice(0,16));return this},finalize:function(){var e,t=this._buffer,n=this._h;for(t=i.bitArray.concat(t,[i.bitArray.partial(1,1)]),e=t.length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this._length/4294967296)),t.push(0|this._length);t.length;)this._block(t.splice(0,16));return this.reset(),n},_init:[],_key:[],_precompute:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}for(var t,n,i=0,r=2;i<64;r++){for(n=!0,t=2;t*t<=r;t++)if(r%t==0){n=!1;break}n&&(i<8&&(this._init[i]=e(Math.pow(r,.5))),this._key[i]=e(Math.pow(r,1/3)),i++)}},_block:function(e){var t,n,i,r,o=this._h,s=this._key,a=o[0],u=o[1],c=o[2],l=o[3],d=o[4],f=o[5],p=o[6],g=o[7];for(t=0;t<64;t++)t<16?n=e[t]:(i=e[t+1&15],r=e[t+14&15],n=e[15&t]=(i>>>7^i>>>18^i>>>3^i<<25^i<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+e[15&t]+e[t+9&15]|0),n=n+g+(d>>>6^d>>>11^d>>>25^d<<26^d<<21^d<<7)+(p^d&(f^p))+s[t],g=p,p=f,f=d,d=l+n|0,l=c,c=u,u=a,a=n+(u&c^l&(u^c))+(u>>>2^u>>>13^u>>>22^u<<30^u<<19^u<<10)|0;o[0]=o[0]+a|0,o[1]=o[1]+u|0,o[2]=o[2]+c|0,o[3]=o[3]+l|0,o[4]=o[4]+d|0,o[5]=o[5]+f|0,o[6]=o[6]+p|0,o[7]=o[7]+g|0}},i.hash.sha1=function(e){e?(this._h=e._h.slice(0),this._buffer=e._buffer.slice(0),this._length=e._length):this.reset()},i.hash.sha1.hash=function(e){return(new i.hash.sha1).update(e).finalize()},i.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(e){"string"==typeof e&&(e=i.codec.utf8String.toBits(e));var t,n=this._buffer=i.bitArray.concat(this._buffer,e),r=this._length,o=this._length=r+i.bitArray.bitLength(e);if(o>9007199254740991)throw new i.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var s=new Uint32Array(n),a=0;for(t=this.blockSize+r-(this.blockSize+r&this.blockSize-1);t<=o;t+=this.blockSize)this._block(s.subarray(16*a,16*(a+1))),a+=1;n.splice(0,16*a)}else for(t=this.blockSize+r-(this.blockSize+r&this.blockSize-1);t<=o;t+=this.blockSize)this._block(n.splice(0,16));return this},finalize:function(){var e,t=this._buffer,n=this._h;for(t=i.bitArray.concat(t,[i.bitArray.partial(1,1)]),e=t.length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this._length/4294967296)),t.push(0|this._length);t.length;)this._block(t.splice(0,16));return this.reset(),n},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(e,t,n,i){return e<=19?t&n|~t&i:e<=39?t^n^i:e<=59?t&n|t&i|n&i:e<=79?t^n^i:void 0},_S:function(e,t){return t<>>32-e},_block:function(e){var t,n,i,r,o,s,a,u,c=this._h;if("undefined"!=typeof Uint32Array){u=Array(80);for(var l=0;l<16;l++)u[l]=e[l]}else u=e;for(i=c[0],r=c[1],o=c[2],s=c[3],a=c[4],t=0;t<=79;t++)t>=16&&(u[t]=this._S(1,u[t-3]^u[t-8]^u[t-14]^u[t-16])),n=this._S(5,i)+this._f(t,r,o,s)+a+u[t]+this._key[Math.floor(t/20)]|0,a=s,s=o,o=this._S(30,r),r=i,i=n;c[0]=c[0]+i|0,c[1]=c[1]+r|0,c[2]=c[2]+o|0,c[3]=c[3]+s|0,c[4]=c[4]+a|0}};var r=function(){function e(){}return e.md5=function(e){return i.codec.hex.fromBits(i.hash.md5.hash(e))},e.sha1=function(e){return i.codec.hex.fromBits(i.hash.sha1.hash(e))},e.sha256=function(e){return i.codec.hex.fromBits(i.hash.sha256.hash(e))},e}();t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e.isValidUrl=function(e,t){if(t&&t.allowNull&&null===e)return!0;if(t&&t.allowEmpty&&(null===e||void 0===e))return!0;try{var n=new URL(e);return!t||!t.requireHttps||"https:"===n.protocol}catch(e){return!1}},e.isValidBoolean=function(e,t){return!(!t||!t.allowNull||null!==e)||(!0===e||!1===e)},e.isValidArray=function(e,t){return!(!t||!t.allowNull||null!==e)||(!(!t||!t.allowEmpty||null!==e&&void 0!==e)||e instanceof Array)},e}();t.ValidatorUtils=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,r=n(0),o=n(7),s=n(43),a=n(54);!function(e){e[e.HttpPermissionRequest=0]="HttpPermissionRequest"}(i=t.DeprecatedApiReason||(t.DeprecatedApiReason={}));var u=function(e){function t(t){var n=this;switch(t){case i.HttpPermissionRequest:n=e.call(this,"The HTTP permission request has been deprecated. Please remove any custom popups from your code.")||this,n.reportUsage()}return n}return r.__extends(t,e),t.prototype.reportUsage=function(){void 0!==s.default&&s.default.context&&s.default.context.metricsManager&&s.default.context.metricsManager.reportEvent(new a.ApiUsageMetricEvent(a.ApiUsageMetricKind.HttpPermissionRequest))},t}(o.default);t.DeprecatedApiError=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){}return e.promiseStub=function(){return{then:e.promiseStub,catch:e.promiseStub}},Object.defineProperty(e,"log",{get:function(){return{setLevel:function(){}}},enumerable:!0,configurable:!0}),e.isPushNotificationsSupported=function(){return!1},e.push=function(e){if("function"==typeof e)e();else{var t=e.shift();OneSignal[t].apply(null,e)}},e}();t.default=i;var r=i;r.init=r.showHttpPrompt=r.registerForPushNotifications=r.showHttpPermissionRequest=r.getNotificationPermission=r.on=r.off=r.once=r.config=r.SERVICE_WORKER_PATH=r.SERVICE_WORKER_UPDATER_PATH=r.checkAndWipeUserSubscription=r.subscriptionBell=r.notifyButton=function(){},r.setDefaultNotificationUrl=r.setDefaultTitle=r.syncHashedEmail=r.getTags=r.sendTag=r.sendTags=r.deleteTag=r.deleteTags=r.addListenerForNotificationOpened=r.getIdsAvailable=r.isPushNotificationsEnabled=r.setSubscription=r.getUserId=r.getRegistrationId=r.getSubscription=r.sendSelfNotification=r.promiseStub},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n(9),o=n(1),s=n(8),a=n(6),u=n(23),c=n(2),l=n(24),d=n(35),f=n(19),p=n(11),g=n(3),h=n(12),v=n(25),m=function(){function e(){}return Object.defineProperty(e,"VERSION",{get:function(){return a.default.version()},enumerable:!0,configurable:!0}),Object.defineProperty(e,"environment",{get:function(){return a.default},enumerable:!0,configurable:!0}),Object.defineProperty(e,"log",{get:function(){return o},enumerable:!0,configurable:!0}),Object.defineProperty(e,"database",{get:function(){return p.default},enumerable:!0,configurable:!0}),Object.defineProperty(e,"sdkEnvironment",{get:function(){return c.default},enumerable:!0,configurable:!0}),Object.defineProperty(e,"browser",{get:function(){return r},enumerable:!0,configurable:!0}),Object.defineProperty(e,"workerMessenger",{get:function(){return self.workerMessenger||(self.workerMessenger=new u.WorkerMessenger(null)),self.workerMessenger},enumerable:!0,configurable:!0}),e.run=function(){self.addEventListener("push",e.onPushReceived),self.addEventListener("notificationclose",e.onNotificationClosed),self.addEventListener("notificationclick",function(t){return t.waitUntil(e.onNotificationClicked(t))}),self.addEventListener("install",e.onServiceWorkerInstalled),self.addEventListener("activate",e.onServiceWorkerActivated),self.addEventListener("pushsubscriptionchange",e.onPushSubscriptionChange),o.debug("Setting up message listeners."),e.workerMessenger.listen(),e.setupMessageListeners()},e.getAppId=function(){return i.__awaiter(this,void 0,void 0,function(){var e,e;return i.__generator(this,function(t){switch(t.label){case 0:return self.location.search?(e=self.location.search.match(/appId=([0-9a-z-]+)&?/i)[1],[2,new h.Uuid(e)]):[3,1];case 1:return[4,p.default.getAppConfig()];case 2:return e=t.sent().appId,[2,e]}})})},e.setupMessageListeners=function(){return i.__awaiter(this,void 0,void 0,function(){var t=this;return i.__generator(this,function(n){return e.workerMessenger.on(u.WorkerMessengerCommand.WorkerVersion,function(t){o.debug("[Service Worker] Received worker version message."),e.workerMessenger.broadcast(u.WorkerMessengerCommand.WorkerVersion,a.default.version())}),e.workerMessenger.on(u.WorkerMessengerCommand.Subscribe,function(n){return i.__awaiter(t,void 0,void 0,function(){var t,r,s;return i.__generator(this,function(i){switch(i.label){case 0:return t=v.AppConfig.deserialize(n),o.debug("[Service Worker] Received subscribe message."),r=new d.default(t),[4,r.subscriptionManager.subscribe()];case 1:return s=i.sent(),e.workerMessenger.broadcast(u.WorkerMessengerCommand.Subscribe,s.serialize()),[2]}})})}),e.workerMessenger.on(u.WorkerMessengerCommand.AmpSubscriptionState,function(n){return i.__awaiter(t,void 0,void 0,function(){var t,n,r,s;return i.__generator(this,function(i){switch(i.label){case 0:return o.debug("[Service Worker] Received AMP subscription state message."),[4,self.registration.pushManager.getSubscription()];case 1:return(t=i.sent())?[3,2]:(e.workerMessenger.broadcast(u.WorkerMessengerCommand.AmpSubscriptionState,!1),[3,5]);case 2:return[4,self.registration.pushManager.permissionState(t.options)];case 3:return n=i.sent(),[4,p.default.getSubscription()];case 4:r=i.sent().optedOut,s=!!t&&"granted"===n&&!0!==r,e.workerMessenger.broadcast(u.WorkerMessengerCommand.AmpSubscriptionState,s),i.label=5;case 5:return[2]}})})}),e.workerMessenger.on(u.WorkerMessengerCommand.AmpSubscribe,function(){return i.__awaiter(t,void 0,void 0,function(){var t,n,r,s;return i.__generator(this,function(i){switch(i.label){case 0:return o.debug("[Service Worker] Received AMP subscribe message."),[4,e.getAppId()];case 1:return t=i.sent(),[4,f.default.getAppConfig(t)];case 2:return n=i.sent(),r=new d.default(n),[4,r.subscriptionManager.subscribe()];case 3:return s=i.sent(),e.workerMessenger.broadcast(u.WorkerMessengerCommand.AmpSubscribe,s.deviceId),[2]}})})}),e.workerMessenger.on(u.WorkerMessengerCommand.AmpUnsubscribe,function(){return i.__awaiter(t,void 0,void 0,function(){var t,n,r;return i.__generator(this,function(i){switch(i.label){case 0:return o.debug("[Service Worker] Received AMP unsubscribe message."),[4,e.getAppId()];case 1:return t=i.sent(),[4,f.default.getAppConfig(t)];case 2:return n=i.sent(),r=new d.default(n),[4,r.subscriptionManager.unsubscribe(1)];case 3:return i.sent(),e.workerMessenger.broadcast(u.WorkerMessengerCommand.AmpUnsubscribe,null),[2]}})})}),[2]})})},e.onPushReceived=function(t){o.debug("Called %conPushReceived("+JSON.stringify(t,null,4)+"):",g.getConsoleStyle("code"),t),t.waitUntil(e.parseOrFetchNotifications(t).then(function(t){if(!t||0==t.length)return o.debug("Because no notifications were retrieved, we'll display the last known notification, so long as it isn't the welcome notification."),e.displayBackupNotification();for(var n=[],i=0,r=t;i0))for(var n=0,i=t.buttons;n url.replace(/\/\//g, '/').replace(':/', '://') +const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0 + +// ============================================= +// oneSignal Module +// ============================================= + +module.exports = function nuxtOneSignal (moduleOptions) { + const hook = () => { + debug('Adding OneSignal') + addOneSignal.call(this, moduleOptions) + } + + if (this.options.mode === 'spa') { + return hook() + } + + this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook) +} + +// ============================================= +// addOneSignal +// ============================================= + +function addOneSignal (moduleOptions) { + // Router Base + const routerBase = this.options.router.base + let publicPath = fixUrl(`${routerBase}/${this.options.build.publicPath}`) + if (isUrl(this.options.build.publicPath)) { // CDN + publicPath = this.options.build.publicPath + if (publicPath.indexOf('//') === 0) { + publicPath = '/' + publicPath // Escape fixUrl + } + } + + // Merge options + const defaults = { + OneSignalSDK: undefined, + cdn: false, + GcmSenderId: '482941778795', + allowLocalhostAsSecureOrigin: true, + importScripts: [ + '/sw.js' + ] + } + + const options = Object.assign(defaults, moduleOptions, this.options.oneSignal) + + if (options.OneSignalSDK === undefined) { + if (options.cdn) { + // Use OneSignalSDK.js from CDN + options.OneSignalSDK = 'https://cdn.onesignal.com/sdks/OneSignalSDK.js' + } else { + // Use OneSignalSDK.js from Dist + const OneSignalSDKJS = readFileSync(path.resolve(__dirname, 'dist/OneSignalSDK.js')) + const OneSignalSDKHash = hashSum(OneSignalSDKJS) + const OneSignalSDKFile = `ons.${OneSignalSDKHash}.js` + + options.OneSignalSDK = fixUrl(publicPath + '/' + OneSignalSDKFile) + + this.options.build.plugins.push({ + apply (compiler) { + compiler.plugin('emit', function (compilation, cb) { + compilation.assets[OneSignalSDKFile] = { + source: () => OneSignalSDKJS, + size: () => OneSignalSDKJS.length + } + cb() + }) + } + }) + } + } + + // Add the oneSignal SDK script to head + this.options.head.script.push({ + async: true, + src: options.OneSignalSDK + }) + + // Adjust manifest for oneSignal + if (!this.options.manifest) { + this.options.manifest = {} + } + if (this.options.manifest.gcm_sender_id) { + debug('WARNING: Overriding gcm_sender_id for OnSignal') + } + this.options.manifest.gcm_sender_id = options.GcmSenderId + + // Adjust swURL option of Workbox for oneSignal + if (!this.options.workbox) { + this.options.workbox = {} + } + if (this.options.workbox.swURL) { + debug('WARNING: Overriding swURL for OneSignal') + } + this.options.workbox.swURL = 'OneSignalSDKWorker.js' + + // Provide OneSignalSDKWorker.js and OneSignalSDKUpdaterWorker.js + const makeSW = (name, scripts) => { + const workerScript = `importScripts(${scripts.map(i => `'${i}'`).join(', ')})\r\n` + writeFileSync(path.resolve(this.options.srcDir, 'static', name), workerScript, 'utf-8') + } + + makeSW('OneSignalSDKWorker.js', [].concat(options.importScripts || []).concat(options.OneSignalSDK)) + makeSW('OneSignalSDKUpdaterWorker.js', [options.OneSignalSDK]) + + // Add OneSignal init plugin + const onsOpts = Object.assign({}, options) + delete onsOpts.OneSignalSDK + delete onsOpts.cdn + delete onsOpts.GcmSenderId + delete onsOpts.importScripts + + this.addPlugin({ + src: path.resolve(__dirname, 'templates/plugin.js'), + ssr: false, + fileName: 'onesignal.js', + options: { + onsOpts + } + }) +} + +module.exports.meta = require('./package.json') diff --git a/packages/onesignal/package.json b/packages/onesignal/package.json new file mode 100755 index 00000000..c57599a6 --- /dev/null +++ b/packages/onesignal/package.json @@ -0,0 +1,10 @@ +{ + "name": "@nuxtjs/onesignal", + "version": "2.0.0", + "license": "MIT", + "main": "index.js", + "repository": "https://github.com/nuxt-community/pwa-module", + "publishConfig": { + "access": "public" + } +} diff --git a/packages/onesignal/templates/plugin.js b/packages/onesignal/templates/plugin.js new file mode 100755 index 00000000..2225230f --- /dev/null +++ b/packages/onesignal/templates/plugin.js @@ -0,0 +1,9 @@ +var OneSignal = window.OneSignal || []; + +OneSignal.push(['init', <%= JSON.stringify(options.onsOpts, null, 2) %>]); + +window.$OneSignal = OneSignal + +export default function (ctx, inject) { + inject('OneSignal', OneSignal) +} diff --git a/test/fixture/nuxt.config.js b/test/fixture/nuxt.config.js index c916a48a..f8968847 100644 --- a/test/fixture/nuxt.config.js +++ b/test/fixture/nuxt.config.js @@ -12,6 +12,7 @@ module.exports = { } }, modules: [ + '@nuxtjs/onesignal', '@nuxtjs/pwa' ], manifest: { @@ -23,5 +24,10 @@ module.exports = { importScripts: [ 'custom-sw.js' ] + }, + oneSignal: { + appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f', + OneSignalSDK: 'https://cdn.onesignal.com/sdks/OneSignalSDK.js' + } } diff --git a/test/fixture/static/OneSignalSDKUpdaterWorker.js b/test/fixture/static/OneSignalSDKUpdaterWorker.js new file mode 100644 index 00000000..d2011a28 --- /dev/null +++ b/test/fixture/static/OneSignalSDKUpdaterWorker.js @@ -0,0 +1 @@ +importScripts('https://cdn.onesignal.com/sdks/OneSignalSDK.js') diff --git a/test/fixture/static/OneSignalSDKWorker.js b/test/fixture/static/OneSignalSDKWorker.js new file mode 100644 index 00000000..3e40d995 --- /dev/null +++ b/test/fixture/static/OneSignalSDKWorker.js @@ -0,0 +1 @@ +importScripts('/sw.js', 'https://cdn.onesignal.com/sdks/OneSignalSDK.js')