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IACI,OAAOhC,KAAKC,sBAAsB9B,SAC7B8D,MAAK,SAAAC,GAWF,OAVA,EAAKC,kCACL,EAAKpE,SAAS2B,UAAUC,uBAAuBC,EAAAA,GAAAA,IAAoC,iBAAkB,QAGhF,eAAd,OAAHsC,QAAG,IAAHA,OAAG,EAAHA,EAAKE,WACL,EAAKrE,SAAS0C,aAAaC,QAAQoB,EAAAA,GAAuC,QAC1EC,QAAQC,OAAO,oCAGnB,EAAKjE,SAASO,OAAOgD,MAAM,sCAAD,OAAuCY,GAAOA,EAAIE,UACrEF,CACX,GAKR,CAHA,MAAO7D,GAEH,MADA2B,KAAKjC,SAASO,OAAOC,MAAM,uBAAwBF,GAC7CA,CACV,CACJ,KAAC,EAtEY,CA/F6BgE,EAAAA,GAAW,2HAGrB,IAAK,KAAD,uCAInCC,EAAAA,IAAQ,uS,iLCtBN,IAAMC,EAAgC,CACzCC,YAAa,mHACbC,aAAc,YACdC,iBAAkB,+CAClBC,OAAQ,yBACRC,MAAO,8FACPC,eAAgB,4FAGPhE,EAAmB,iBACnBG,EAAsB,oBACtBC,EAAyB,uBACzB0B,EAA0C,8BAC1CmB,EAAwC,6B","sources":["app-react/services/progressive-web-app/progressive-web-app.service.tsx","common/const/service-worker-constants.ts"],"sourcesContent":["import { IServiceFactoryExtended } from '../service-factory-extended.interface';\nimport { IProgressiveWebAppService } from \"./progressive-web-app.service.interface\";\nimport { Check } from '@sparkware/app-utils';\nimport { observable, action, computed, makeObservable } from \"mobx\";\nimport { ServiceBase } from '../ServiceBase';\nimport { DomEventSubscription } from '../../../utils/event-listener-registration';\nimport {\n PWA_INSTALLED_CALLBACK, PWA_SHOULD_AUTO_POPUP_LOCAL_STORAGE_KEY,\n PWA_DISMISSED_POPUP_LOCAL_STORAGE_KEY,\n PWA_PROMPT_CALLBACK,\n PWA_PROMPT_EVENT,\n} from \"../../../common/const/service-worker-constants\";\nimport { OrbitUserFlowAnalyticsCategory } from \"../analytics/analytics.service.interface\";\n\n\nexport class ProgressiveWebAppService extends ServiceBase implements IProgressiveWebAppService {\n\n @observable.ref\n private _onBeforeInstallEvent = null;\n\n private _clickSubscription: DomEventSubscription;\n\n @computed\n public get isPWAInstallable(): boolean {\n return Check.isFunction(this._onBeforeInstallEvent?.prompt);\n }\n\n constructor(services: IServiceFactoryExtended) {\n super(services);\n\n makeObservable(this);\n\n // disable if user chose not install previously\n if (this._didUserDismissedInstall()) {\n return;\n }\n\n const pwaEvent = this.services.window.getGlobalProperty(PWA_PROMPT_EVENT);\n if (pwaEvent) {\n // this means beforeinstallprompt handler was already called\n this._init(pwaEvent);\n }\n\n // beforeinstallprompt can arrive after service constructor finishes\n // and also can be called multiple times\n\n // register beforeinstallprompt callback\n this.services.window.setGlobalProperty(PWA_PROMPT_CALLBACK, (pwaEvent) => {\n this._init(pwaEvent);\n });\n\n // register appinstalled callback\n this.services.window.setGlobalProperty(PWA_INSTALLED_CALLBACK, () => {\n this._onAppInstalled();\n });\n\n this._subscribeReactions();\n\n this._subscribeToMainScreenClick();\n\n // add to analytics PWA launch event\n if ((this.services.device.isStandalone && this.services.device.browser.isSafari) || this.services.device.isProgressiveWebApp) {\n this.services.analytics.sendOrbitUserFlowEvent(OrbitUserFlowAnalyticsCategory.PWA, 'Launch', this.services.user.cid);\n }\n }\n\n\n private async _subscribeReactions(): Promise {\n const cmsSegmentation = await this.services.cmsSegmentation;\n this.reaction(() => {\n return {\n isAuthorized: this.services.user.isAuthorized,\n isCstatus: cmsSegmentation.isCstatus,\n isUKOrIrl: cmsSegmentation.isUKOrIrl\n }\n }, data => {\n // If a user logged in (and has cstatus and isn't UK or Irl) he will mark as PWA installable client, which will later help do determine if installation popup should show \n if (data.isAuthorized) {\n const shouldAutoPopup = data.isCstatus && !data.isUKOrIrl;\n shouldAutoPopup && this.services.localStorage.setItem(PWA_SHOULD_AUTO_POPUP_LOCAL_STORAGE_KEY, shouldAutoPopup);\n }\n },\n {\n fireImmediately: true\n }\n );\n }\n\n @action.bound\n // can be called multiple times by beforeinstallprompt handler\n private _init(onBeforeInstallEvent: any) {\n // disable it for hybrid and mini Orbit\n if (this.services.miniOrbit.isEnabled || this.services.device.hybrid.isHybrid) {\n return;\n }\n\n this._onBeforeInstallEvent = onBeforeInstallEvent;\n }\n\n private _subscribeToMainScreenClick() {\n this._clickSubscription = this.services.dom.subscribeTo.click(this._tryToShowPwaInstall);\n }\n\n private _unsubscribeFromMainScreenClick() {\n if (this._clickSubscription) {\n this._clickSubscription.dispose();\n this._clickSubscription = null;\n }\n }\n\n @action.bound\n private _onAppInstalled() {\n this.services.analytics.sendOrbitUserFlowEvent(OrbitUserFlowAnalyticsCategory.PWA, 'Browser_Prompt', 'INSTALL');\n this.services.logger.debug('PWA installed');\n this.services.window.setGlobalProperty(PWA_PROMPT_CALLBACK, null);\n this._onBeforeInstallEvent = null;\n }\n\n /* Auto PWA Installation prompt strategy:\n PWA is installable on client's device\n > Client has logged in at least once and he is now logged out (annonymous) \n > When he was logged in it was with a user that has cStatus and isn't UK/IRL related \n > Client hasn't dismissed pwa installation popup before\n */\n\n private async _shouldAutoPrompt(): Promise {\n const cmsSegmentation = await this.services.cmsSegmentation;\n const sholdAutoPopup = this._shouldAutoPopupByStorage();\n const isDismissedPopup = this._didUserDismissedInstall(); // Check if user already got the PWA Installation prompt before and dismissed it\n const shouldPrompt = sholdAutoPopup && !isDismissedPopup && !cmsSegmentation.isAppBannerUKorIRL;\n return this.isPWAInstallable\n && shouldPrompt // PWA Installation prompt should be popped only for whos has logged in berfore at least one time\n && !this.services.user.isAuthorized; // PWA Installation prompt should be popped only for anonymous clients\n }\n\n private _tryToShowPwaInstall = async () => {\n if (await this._shouldAutoPrompt()) {\n this.prompt().catch(err => {\n this.services.logger.error('Attempt to show PWA prompt failed', err);\n });\n }\n }\n\n private _didUserDismissedInstall() {\n return this.services.localStorage.getItem(PWA_DISMISSED_POPUP_LOCAL_STORAGE_KEY) === 'true'\n }\n\n private _shouldAutoPopupByStorage() {\n return this.services.localStorage.getItem(PWA_SHOULD_AUTO_POPUP_LOCAL_STORAGE_KEY) === 'true'\n }\n\n prompt(): Promise {\n if (!this.isPWAInstallable) {\n return Promise.reject(\"Not a PWA\");\n }\n\n if (this._didUserDismissedInstall()) {\n return Promise.reject(\"PWA Install dismissed by client before\");\n }\n\n try {\n return this._onBeforeInstallEvent.prompt()\n .then(res => {\n this._unsubscribeFromMainScreenClick();\n this.services.analytics.sendOrbitUserFlowEvent(OrbitUserFlowAnalyticsCategory.PWA, 'Browser_Prompt', 'SHOW');\n\n // In case user dismissed the PWA installation prompt - store it so we won't pop it again\n if (res?.outcome === 'dismissed') {\n this.services.localStorage.setItem(PWA_DISMISSED_POPUP_LOCAL_STORAGE_KEY, 'true');\n Promise.reject('PWA Install dismissed by client');\n }\n\n this.services.logger.debug(`PWA prompt() success with outcome: ${res && res.outcome}`);\n return res;\n });\n }\n catch (err) {\n this.services.logger.error('Pwa exception caught', err);\n throw err;\n }\n }\n}\n","export const QA_ENV_URBAN_DEFAULT_SETTINGS = {\n defaultIcon: 'https://mirage-orbit-latest-eu.888casino.com/configurations/888casino_com/assets/images/888casinologo-mobile.svg',\n defaultTitle: '888Casino',\n defaultActionURL: 'https://mirage-orbit-latest-eu.888casino.com',\n appKey: '64FbuTbIS9aQUIwB0cWoMA',\n token: 'MTo2NEZidVRiSVM5YVFVSXdCMGNXb01BOkFVRXNxa2hEUE5rZUtTOW1DLVdvR3hwMHNjdHEtNF9xLXJ1M3ZGazVJWEU',\n vapidPublicKey: 'BJOvGd2nCaeEGqqKnsJJhWmJzMvJqO4t3wSCqzVJ6uhHWw3891tqJhs8muo958dtbggZe4vM122EtKE9HkvUf9U='\n};\n\nexport const PWA_PROMPT_EVENT = \"pwaPromptEvent\";\nexport const PWA_PROMPT_CALLBACK = \"pwaPromptCallback\";\nexport const PWA_INSTALLED_CALLBACK = \"pwaInstalledCallback\";\nexport const PWA_SHOULD_AUTO_POPUP_LOCAL_STORAGE_KEY = \"orbit-pwa-should-auto-popup\";\nexport const PWA_DISMISSED_POPUP_LOCAL_STORAGE_KEY = \"orbit-pwa-dismissed-install\";\n\n"],"names":["ProgressiveWebAppService","observable","action","services","_clickSubscription","_tryToShowPwaInstall","_shouldAutoPrompt","prompt","catch","err","logger","error","makeObservable","_didUserDismissedInstall","pwaEvent","window","getGlobalProperty","PWA_PROMPT_EVENT","_init","setGlobalProperty","PWA_PROMPT_CALLBACK","PWA_INSTALLED_CALLBACK","_onAppInstalled","_subscribeReactions","_subscribeToMainScreenClick","device","isStandalone","browser","isSafari","isProgressiveWebApp","analytics","sendOrbitUserFlowEvent","OrbitUserFlowAnalyticsCategory","user","cid","Check","this","_onBeforeInstallEvent","cmsSegmentation","reaction","isAuthorized","isCstatus","isUKOrIrl","data","shouldAutoPopup","localStorage","setItem","PWA_SHOULD_AUTO_POPUP_LOCAL_STORAGE_KEY","fireImmediately","onBeforeInstallEvent","miniOrbit","isEnabled","hybrid","isHybrid","dom","subscribeTo","click","dispose","debug","sholdAutoPopup","_shouldAutoPopupByStorage","isDismissedPopup","shouldPrompt","isAppBannerUKorIRL","isPWAInstallable","getItem","PWA_DISMISSED_POPUP_LOCAL_STORAGE_KEY","Promise","reject","then","res","_unsubscribeFromMainScreenClick","outcome","ServiceBase","computed","QA_ENV_URBAN_DEFAULT_SETTINGS","defaultIcon","defaultTitle","defaultActionURL","appKey","token","vapidPublicKey"],"sourceRoot":""}