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,KAAAQ,QAEjBqC,WAAW,KACP7C,KAAKQ,MAAMsC,SAASC,IAAgC,EACrD,IACP,CAACrB,SAAA1B,KAAA,mBAAA2B,iBAPQiB,GAAoBhB,MAAAC,MAAA,EAAAH,SAAA1B,KAAA,UAAAgC,EAAAgB,GAAA,MAApBJ,IAAoBlB,SAAA1B,KAAA,UAAAgC,EAAAiB,IAAA,WALlB,IACPC,MAAa,CAAEC,KAAM,kBAAmBC,QAASV,KAAuB,EACxEW,MAAe/C,aAGVsC,CAAoB","names":["Init","createAction","InitGoogleTagManagerSuccess","InitGoogleTagManagerError","INIT_GTM_ERROR","props","GTMInitializationErrorMessages","USER_DOES_NOT_CONSENT","GTMInitializationError","Error","constructor","message","super","this","errorKey","errorMessage","Object","setPrototypeOf","prototype","GoogleServicesEffects","actions$","store","userConsentService","initGoogleTagManager$","createEffect","pipe","ofType","concatLatestFrom","select","getCmsConfigValue","filter","_","enabledGTM","switchMap","waitForAnalyticsCookieConsent","take","map","hasTheUserConsented","error","static","t","i0","i1","i2","i3","core","jDH","factory","ɵfac","googleServicesReducerDefinition","createReducer","enabled","googleServicesInitialState","on","state","googleServicesReducer","action","GoogleServicesModule","setTimeout","dispatch","fromGoogleServicesActions","$C","G2t","provideState","name","reducer","provideEffects"],"ignoreList":[],"sourceRoot":"webpack:///","sources":["./code/apps/frontend/src/app/shared/google-services/store/google-services.actions.ts","./code/apps/frontend/src/app/shared/google-services/models/google-services.errors.ts","./code/apps/frontend/src/app/shared/google-services/store/google-services.effects.ts","./code/apps/frontend/src/app/shared/google-services/store/google-services.state.ts","./code/apps/frontend/src/app/shared/google-services/store/google-services.reducer.ts","./code/apps/frontend/src/app/shared/google-services/google-services.module.ts"],"sourcesContent":["import { createAction, props } from '@ngrx/store';\n\nexport const GoogleServicesActionTypes = {\n GOOGLE_SERVICES_INIT: '[Google Services] GOOGLE_SERVICES_INIT',\n INIT_GTM_SUCCESS: '[Google Services] INIT_GTM_SUCCESS',\n INIT_GTM_ERROR: '[Google Services] INIT_GTM_ERROR',\n};\n\nexport const Init = createAction(\n GoogleServicesActionTypes.GOOGLE_SERVICES_INIT\n);\n\n// #region GOOGLE TAG MANAGER\nexport const InitGoogleTagManagerSuccess = createAction(\n GoogleServicesActionTypes.INIT_GTM_SUCCESS\n);\n\nexport const InitGoogleTagManagerError = createAction(\n GoogleServicesActionTypes.INIT_GTM_ERROR,\n props<{ error: any }>()\n);\n// #endregion\n","export enum GTMInitializationErrorMessages {\n USER_DOES_NOT_CONSENT = 'Unable to initalize the GTM due the user has not authorised it',\n}\n\nexport class GTMInitializationError extends Error {\n public errorKey = '[Google Services] GTM_INITIALIZATION_ERROR';\n\n public errorMessage;\n\n constructor(message: GTMInitializationErrorMessages) {\n super(message);\n\n this.errorMessage = message;\n\n Object.setPrototypeOf(this, GTMInitializationError.prototype);\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Actions, ofType, createEffect } from '@ngrx/effects';\nimport { concatLatestFrom } from '@ngrx/operators';\nimport { Store } from '@ngrx/store';\nimport { switchMap, filter, take, map } from 'rxjs/operators';\n\nimport { GTMInitializationError, GTMInitializationErrorMessages } from '../models/google-services.errors';\n\nimport {\n Init,\n InitGoogleTagManagerError,\n InitGoogleTagManagerSuccess,\n} from './google-services.actions';\n\nimport { getCmsConfigValue } from '@core/infrastructure/state/core.selectors';\nimport { UserConsentService } from '@core/ui/services/user-consent.service';\n\n@Injectable()\nexport class GoogleServicesEffects {\n constructor(\n private readonly actions$: Actions,\n private readonly store: Store,\n private readonly userConsentService: UserConsentService\n ) { }\n\n public initGoogleTagManager$ = createEffect(() => {\n return this.actions$.pipe(\n ofType(Init),\n concatLatestFrom(() => this.store.select(getCmsConfigValue('enabled_gtm'))),\n filter(([_, enabledGTM]) => !!enabledGTM),\n switchMap(() => this.userConsentService.waitForAnalyticsCookieConsent().pipe(take(1))),\n map((hasTheUserConsented) => {\n if (!hasTheUserConsented) {\n const error = new GTMInitializationError(GTMInitializationErrorMessages.USER_DOES_NOT_CONSENT);\n return InitGoogleTagManagerError({ error });\n }\n\n return InitGoogleTagManagerSuccess();\n }),\n );\n });\n}\n","export interface GoogleServicesState {\n enabled: boolean;\n}\n\nexport const googleServicesInitialState: GoogleServicesState = {\n enabled: false,\n};\n","import { createReducer, on, Action } from '@ngrx/store';\n\nimport {\n InitGoogleTagManagerSuccess,\n} from './google-services.actions';\nimport { googleServicesInitialState, GoogleServicesState } from './google-services.state';\n\nconst googleServicesReducerDefinition = createReducer(\n googleServicesInitialState,\n\n on(InitGoogleTagManagerSuccess, (state: GoogleServicesState): GoogleServicesState => {\n return {\n ...state,\n enabled: true,\n };\n }),\n);\n\nexport function googleServicesReducer(state: GoogleServicesState, action: Action): GoogleServicesState {\n return googleServicesReducerDefinition(state, action);\n}\n","import { NgModule } from '@angular/core';\nimport { provideEffects } from '@ngrx/effects';\nimport { provideState, Store } from '@ngrx/store';\n\nimport * as fromGoogleServicesActions from './store/google-services.actions';\nimport { GoogleServicesEffects } from './store/google-services.effects';\nimport { googleServicesReducer } from './store/google-services.reducer';\n\n@NgModule({\n providers: [\n provideState({ name: 'google-services', reducer: googleServicesReducer }),\n provideEffects(GoogleServicesEffects),\n ],\n})\nexport class GoogleServicesModule {\n constructor(\n private readonly store: Store\n ) {\n setTimeout(() => {\n this.store.dispatch(fromGoogleServicesActions.Init());\n }, 500);\n }\n}\n"],"x_google_ignoreList":[]}