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E,EAC5D4B,KACCyS,EAAWC,GAAI,CAAG,KAAMA,EAAE,EAAC,EAC3BzS,EAAI4R,GAAOA,EAAItT,KAAKqU,aAAa,CAAC,EAEnCxO,UAAU,CACTE,KAAMiN,GAAKvB,EAAGuB,CAAC,EACfhP,MAAOmQ,GAAKvL,QAAQ5E,MAAMmQ,CAAC,EAC5B,CAEL,EAAC,CACH,EAEAG,eAAgBN,EAAiB,CAC/B,MAAK,MAAKxE,aAEH,CAAC,CAAC,KAAKA,aAAaiE,QAAQc,cAAcZ,KAAKrU,GAAKA,EAAEmP,MAAQuF,CAAS,EADrE,EAEX,EAEQC,wBAAwBpU,EAAU,CACxC,GAAMU,GAAM,kCAAqC,KAAK2L,aAAa,MACnEtM,EAAaC,EAAMU,CAAG,EACtBV,EAAMgU,GAAE,CACV,IAAAzU,CAAA,CAAAK,IAAA,UAAA8L,CAAA,aAAAA,CAAA,EA/YWO,GAAYzF,EAAAqB,CAAA,EAAArB,EAAAmO,EAAA,EAAAnO,EAAAoO,EAAA,EAAApO,EAAAzH,EAAA,EAAAyH,EAAAqO,EAAA,EAAArO,EAAAsO,EAAA,EAAAtO,EAAAuO,GAAA,GAAAvO,EAAAwO,EAAA,EAAAxO,EAAAE,EAAA,GAAAF,EAAAyO,EAAA,EAAAzO,EAAA0O,EAAA,EAAA1O,EAAAoF,EAAA,EAAApF,EAAAuF,EAAA,KAAAxM,CAAA,CAAAC,KAAA,CAAAC,CAAA,EAAAC,KAAA,CAAZuM,EAAYtM,QAAZsM,EAAYrM,KAAAC,WAFX,MAAM,GAEd,GAAOoM,GAAPkJ,QAAOlJ,EAAY,aAAAmJ,CAAA,IAAAC,CAAA,CAAAC,CAAA,IAAAC,CAAA,CAAAC,EAAA,IAAApT,CAAA,CAAAqT,CAAA,IAAAzN,CAAA,CAAA0N,EAAA,IAAApB,CAAA","names":["UserInfoGQL","Query","constructor","arguments","document","gql","UserFragment","UserProfileBaseFragment","t","ɵprov","p","token","factory","ɵfac","providedIn","_UserInfoGQL","clearByRegEx","cache","regExText","rootQuery","data","ROOT_QUERY","regEx","RegExp","Object","keys","forEach","key","match","evict","id","fieldName","ERR_SW_NOT_SUPPORTED","errorObservable","message","defer","throwError","Error","NgswCommChannel","serviceWorker","worker","events","registration","controllerChanges","fromEvent","pipe","map","controller","currentController","of","controllerWithChanges","concat","filter","c","switchMap","getRegistration","event","type","publish","connect","postMessage","action","payload","take","tap","sw","__spreadValues","toPromise","then","postMessageWithOperation","operationNonce","waitForOperationCompleted","Promise","all","result","generateNonce","Math","round","random","eventsOfType","filterFn","includes","nextEventOfType","nonce","error","isEnabled","SwPush","_SwPush","pushManager","subscriptionChanges","Subject","messages","NEVER","notificationClicks","subscription","workerDrivenSubscriptions","pm","getSubscription","merge","requestSubscription","options","reject","pushOptions","userVisibleOnly","decodeBase64","serverPublicKey","replace","applicationServerKey","Uint8Array","ArrayBuffer","length","i","charCodeAt","subscribe","sub","next","unsubscribe","doUnsubscribe","success","input","atob","ɵɵinject","ɵɵdefineInjectable","SwUpdate","_SwUpdate","versionUpdates","unrecoverable","checkForUpdate","activateUpdate","SCRIPT","InjectionToken","ngswAppInitializer","injector","script","platformId","isPlatformBrowser","navigator","enabled","ngZone","get","NgZone","appRef","ApplicationRef","runOutsideAngular","onControllerChange","d","addEventListener","onDestroy","removeEventListener","readyToRegister$","registrationStrategy","strategy","args","split","delayWithTimeout","whenStable","register","scope","catch","err","console","timeout","delay","isStable","stable","ngswCommChannelFactory","opts","SwRegistrationOptions","provideServiceWorker","makeEnvironmentProviders","provide","useValue","useFactory","deps","PLATFORM_ID","APP_INITIALIZER","Injector","multi","ServiceWorkerModule","_ServiceWorkerModule","ngModule","providers","ɵmod","ɵɵdefineNgModule","ɵinj","ɵɵdefineInjector","injectAsync","providerLoader","__async","InjectAsyncImpl","overrides","WeakMap","override","mock","set","has","EnvironmentInjector","destroyRef","DestroyRef","environmentInjector","newInjector","createEnvironmentInjector","destroy","r","_InjectAsyncImpl","saveProductGQL","Mutation","_saveProductGQL","removeProductGQL","_removeProductGQL","UsersService","onUserChange","_onUserChangeSubject","asObservable","currentUserId","_currentUserId","authService","languagesService","userInfoGQL","router","blockUiService","analyticsService","userInteractionService","swUpdate","apollo","platform","_currentCompanyId","inject","isLoggedIn","userAction","toSignal","onUserAction$","initSnackBar","evt","snackBar","open","duration","verticalPosition","afterDismissed","location","reload","_currentUserRoles","BehaviorSubject","authTokenChange","roles","iif","watch","lang","getCurrentLangCode","fetchPolicy","valueChanges","userById","user","_id","currentRoles","rolesAreEquals","refreshToken","validated","client","modify","identify","fields","followCompanyGQL","unFollowCompanyGQL","FollowCompanyGQL","UnFollowCompanyGQL","followCompanyGql","unFollowCompanyGql","_currentUser","logout","invalidate","navigate","openCompanyWizard","company","show","ensureDialogService","matDialogsHelperService","updateToken","setauthToken","isInRole","_roles","UserRolesEnum","stand_admin","some","role","canLoadBusinnesSection","permissionRoles","customer","admin","canActivateModule","companyId","userRoles","standAdminRole","roles1","roles2","JSON","stringify","slice","sort","setCurrentCompanyRole","checkPermission","cb","basic","openLogin","loggedIn","checkPermissionLoad","resetTimer","timer","clearTimeout","startTimerAndOpenLogin","environment","debugOn","setTimeout","run","confirmAction","confirm","from","MatDialogsHelperModule","createNgModule","moduleRef","MatDialogsHelperService","MatSnackBarModule","MatSnackBar","toggleFollowCompany","u","isFollowedCompany","ecTrackAddRemoveToCart","mutate","update","clearFollowedCompaniesCache","res","unFollowCompany","followCompany","profile","followedCompanies","find","fc","gc","toggleSaveProduct","product","productId","clearSavedProductsCache","catchError","e","saveProduct","removeProduct","isSavedProduct","savedProducts","AuthService","LanguagesService","Router","BlockUiService","AnalyticsService","UserInteractionService","Apollo","Platform","_UsersService","M","a","A","b","et","V","Wt"],"ignoreList":[2],"sources":["src/app/shared/services/users/user-info.gql.service.ts","src/app/shared/services/common/cache.utilities.ts","node_modules/@angular/service-worker/fesm2022/service-worker.mjs","src/app/shared/services/inject-async.ts","src/app/shared/services/users/save-product.gql.service copy.ts","src/app/shared/services/users/remove-product.gql.service.ts","src/app/shared/services/users/users.service.ts"],"sourcesContent":["import {Query, gql} from 'apollo-angular';\r\nimport { Injectable } from '@angular/core';\r\nimport { UserInfo } from './types/user-info';\r\nimport { UserFragment } from './fragments/user.fragment';\r\nimport { UserProfileBaseFragment } from './fragments/user-profile.fragment';\r\n\r\n\r\nexport interface UserInfoResponse {\r\n userById: UserInfo;\r\n}\r\n\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class UserInfoGQL extends Query {\r\n document = gql`\r\n query userInfo($id: ObjectId!, $lang: String!){\r\n userById(id: $id, lang: $lang){\r\n ...userFields\r\n profile {\r\n ...userProfileBase\r\n }\r\n }\r\n }\r\n ${UserFragment}\r\n ${UserProfileBaseFragment}\r\n `;\r\n}\r\n","export const clearByRegEx = (cache: any, regExText: string) => {\r\n // https://medium.com/@martinseanhunt/how-to-invalidate-cached-data-in-apollo-and-handle-updating-paginated-queries-379e4b9e4698\r\n // https://medium.com/rbi-tech/tips-and-tricks-for-working-with-apollo-cache-3b5a757f10a0\r\n // https://danreynolds.ca/tech/2020/05/04/Apollo-3-Client-Cache/\r\n const rootQuery = cache.data.data.ROOT_QUERY;\r\n const regEx = new RegExp(regExText);\r\n Object.keys(rootQuery).forEach(key => {\r\n if (key.match(regEx)) { // matches all news cache keys that rely on newsStatus arg\r\n cache.evict({ id: 'ROOT_QUERY', fieldName: key }); // delete cache entry\r\n }\r\n });\r\n}\r\n","/**\n * @license Angular v18.0.0\n * (c) 2010-2024 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport * as i0 from '@angular/core';\nimport { Injectable, InjectionToken, NgZone, ApplicationRef, makeEnvironmentProviders, PLATFORM_ID, APP_INITIALIZER, Injector, NgModule } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { defer, throwError, fromEvent, of, concat, Subject, NEVER, merge } from 'rxjs';\nimport { map, filter, switchMap, publish, take, tap, delay } from 'rxjs/operators';\nconst ERR_SW_NOT_SUPPORTED = 'Service workers are disabled or not supported by this browser';\nfunction errorObservable(message) {\n return defer(() => throwError(new Error(message)));\n}\n/**\n * @publicApi\n */\nclass NgswCommChannel {\n constructor(serviceWorker) {\n this.serviceWorker = serviceWorker;\n if (!serviceWorker) {\n this.worker = this.events = this.registration = errorObservable(ERR_SW_NOT_SUPPORTED);\n } else {\n const controllerChangeEvents = fromEvent(serviceWorker, 'controllerchange');\n const controllerChanges = controllerChangeEvents.pipe(map(() => serviceWorker.controller));\n const currentController = defer(() => of(serviceWorker.controller));\n const controllerWithChanges = concat(currentController, controllerChanges);\n this.worker = controllerWithChanges.pipe(filter(c => !!c));\n this.registration = this.worker.pipe(switchMap(() => serviceWorker.getRegistration()));\n const rawEvents = fromEvent(serviceWorker, 'message');\n const rawEventPayload = rawEvents.pipe(map(event => event.data));\n const eventsUnconnected = rawEventPayload.pipe(filter(event => event && event.type));\n const events = eventsUnconnected.pipe(publish());\n events.connect();\n this.events = events;\n }\n }\n postMessage(action, payload) {\n return this.worker.pipe(take(1), tap(sw => {\n sw.postMessage({\n action,\n ...payload\n });\n })).toPromise().then(() => undefined);\n }\n postMessageWithOperation(type, payload, operationNonce) {\n const waitForOperationCompleted = this.waitForOperationCompleted(operationNonce);\n const postMessage = this.postMessage(type, payload);\n return Promise.all([postMessage, waitForOperationCompleted]).then(([, result]) => result);\n }\n generateNonce() {\n return Math.round(Math.random() * 10000000);\n }\n eventsOfType(type) {\n let filterFn;\n if (typeof type === 'string') {\n filterFn = event => event.type === type;\n } else {\n filterFn = event => type.includes(event.type);\n }\n return this.events.pipe(filter(filterFn));\n }\n nextEventOfType(type) {\n return this.eventsOfType(type).pipe(take(1));\n }\n waitForOperationCompleted(nonce) {\n return this.eventsOfType('OPERATION_COMPLETED').pipe(filter(event => event.nonce === nonce), take(1), map(event => {\n if (event.result !== undefined) {\n return event.result;\n }\n throw new Error(event.error);\n })).toPromise();\n }\n get isEnabled() {\n return !!this.serviceWorker;\n }\n}\n\n/**\n * Subscribe and listen to\n * [Web Push\n * Notifications](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices) through\n * Angular Service Worker.\n *\n * @usageNotes\n *\n * You can inject a `SwPush` instance into any component or service\n * as a dependency.\n *\n * \n *\n * To subscribe, call `SwPush.requestSubscription()`, which asks the user for permission.\n * The call returns a `Promise` with a new\n * [`PushSubscription`](https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription)\n * instance.\n *\n * \n *\n * A request is rejected if the user denies permission, or if the browser\n * blocks or does not support the Push API or ServiceWorkers.\n * Check `SwPush.isEnabled` to confirm status.\n *\n * Invoke Push Notifications by pushing a message with the following payload.\n *\n * ```ts\n * {\n * \"notification\": {\n * \"actions\": NotificationAction[],\n * \"badge\": USVString,\n * \"body\": DOMString,\n * \"data\": any,\n * \"dir\": \"auto\"|\"ltr\"|\"rtl\",\n * \"icon\": USVString,\n * \"image\": USVString,\n * \"lang\": DOMString,\n * \"renotify\": boolean,\n * \"requireInteraction\": boolean,\n * \"silent\": boolean,\n * \"tag\": DOMString,\n * \"timestamp\": DOMTimeStamp,\n * \"title\": DOMString,\n * \"vibrate\": number[]\n * }\n * }\n * ```\n *\n * Only `title` is required. See `Notification`\n * [instance\n * properties](https://developer.mozilla.org/en-US/docs/Web/API/Notification#Instance_properties).\n *\n * While the subscription is active, Service Worker listens for\n * [PushEvent](https://developer.mozilla.org/en-US/docs/Web/API/PushEvent)\n * occurrences and creates\n * [Notification](https://developer.mozilla.org/en-US/docs/Web/API/Notification)\n * instances in response.\n *\n * Unsubscribe using `SwPush.unsubscribe()`.\n *\n * An application can subscribe to `SwPush.notificationClicks` observable to be notified when a user\n * clicks on a notification. For example:\n *\n * \n *\n * You can read more on handling notification clicks in the [Service worker notifications\n * guide](ecosystem/service-workers/push-notifications).\n *\n * @see [Push Notifications](https://developers.google.com/web/fundamentals/codelabs/push-notifications/)\n * @see [Angular Push Notifications](https://blog.angular-university.io/angular-push-notifications/)\n * @see [MDN: Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API)\n * @see [MDN: Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API)\n * @see [MDN: Web Push API Notifications best practices](https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices)\n *\n * @publicApi\n */\nlet SwPush = /*#__PURE__*/(() => {\n class SwPush {\n /**\n * True if the Service Worker is enabled (supported by the browser and enabled via\n * `ServiceWorkerModule`).\n */\n get isEnabled() {\n return this.sw.isEnabled;\n }\n constructor(sw) {\n this.sw = sw;\n this.pushManager = null;\n this.subscriptionChanges = new Subject();\n if (!sw.isEnabled) {\n this.messages = NEVER;\n this.notificationClicks = NEVER;\n this.subscription = NEVER;\n return;\n }\n this.messages = this.sw.eventsOfType('PUSH').pipe(map(message => message.data));\n this.notificationClicks = this.sw.eventsOfType('NOTIFICATION_CLICK').pipe(map(message => message.data));\n this.pushManager = this.sw.registration.pipe(map(registration => registration.pushManager));\n const workerDrivenSubscriptions = this.pushManager.pipe(switchMap(pm => pm.getSubscription()));\n this.subscription = merge(workerDrivenSubscriptions, this.subscriptionChanges);\n }\n /**\n * Subscribes to Web Push Notifications,\n * after requesting and receiving user permission.\n *\n * @param options An object containing the `serverPublicKey` string.\n * @returns A Promise that resolves to the new subscription object.\n */\n requestSubscription(options) {\n if (!this.sw.isEnabled || this.pushManager === null) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const pushOptions = {\n userVisibleOnly: true\n };\n let key = this.decodeBase64(options.serverPublicKey.replace(/_/g, '/').replace(/-/g, '+'));\n let applicationServerKey = new Uint8Array(new ArrayBuffer(key.length));\n for (let i = 0; i < key.length; i++) {\n applicationServerKey[i] = key.charCodeAt(i);\n }\n pushOptions.applicationServerKey = applicationServerKey;\n return this.pushManager.pipe(switchMap(pm => pm.subscribe(pushOptions)), take(1)).toPromise().then(sub => {\n this.subscriptionChanges.next(sub);\n return sub;\n });\n }\n /**\n * Unsubscribes from Service Worker push notifications.\n *\n * @returns A Promise that is resolved when the operation succeeds, or is rejected if there is no\n * active subscription or the unsubscribe operation fails.\n */\n unsubscribe() {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const doUnsubscribe = sub => {\n if (sub === null) {\n throw new Error('Not subscribed to push notifications.');\n }\n return sub.unsubscribe().then(success => {\n if (!success) {\n throw new Error('Unsubscribe failed!');\n }\n this.subscriptionChanges.next(null);\n });\n };\n return this.subscription.pipe(take(1), switchMap(doUnsubscribe)).toPromise();\n }\n decodeBase64(input) {\n return atob(input);\n }\n static {\n this.ɵfac = function SwPush_Factory(t) {\n return new (t || SwPush)(i0.ɵɵinject(NgswCommChannel));\n };\n }\n static {\n this.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: SwPush,\n factory: SwPush.ɵfac\n });\n }\n }\n return SwPush;\n})();\n/*#__PURE__*/(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\n\n/**\n * Subscribe to update notifications from the Service Worker, trigger update\n * checks, and forcibly activate updates.\n *\n * @see {@link ecosystem/service-workers/communications Service worker communication guide}\n *\n * @publicApi\n */\nlet SwUpdate = /*#__PURE__*/(() => {\n class SwUpdate {\n /**\n * True if the Service Worker is enabled (supported by the browser and enabled via\n * `ServiceWorkerModule`).\n */\n get isEnabled() {\n return this.sw.isEnabled;\n }\n constructor(sw) {\n this.sw = sw;\n if (!sw.isEnabled) {\n this.versionUpdates = NEVER;\n this.unrecoverable = NEVER;\n return;\n }\n this.versionUpdates = this.sw.eventsOfType(['VERSION_DETECTED', 'VERSION_INSTALLATION_FAILED', 'VERSION_READY', 'NO_NEW_VERSION_DETECTED']);\n this.unrecoverable = this.sw.eventsOfType('UNRECOVERABLE_STATE');\n }\n /**\n * Checks for an update and waits until the new version is downloaded from the server and ready\n * for activation.\n *\n * @returns a promise that\n * - resolves to `true` if a new version was found and is ready to be activated.\n * - resolves to `false` if no new version was found\n * - rejects if any error occurs\n */\n checkForUpdate() {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const nonce = this.sw.generateNonce();\n return this.sw.postMessageWithOperation('CHECK_FOR_UPDATES', {\n nonce\n }, nonce);\n }\n /**\n * Updates the current client (i.e. browser tab) to the latest version that is ready for\n * activation.\n *\n * In most cases, you should not use this method and instead should update a client by reloading\n * the page.\n *\n *
\n *\n * Updating a client without reloading can easily result in a broken application due to a version\n * mismatch between the application shell and other page resources,\n * such as lazy-loaded chunks, whose filenames may change between\n * versions.\n *\n * Only use this method, if you are certain it is safe for your specific use case.\n *\n *
\n *\n * @returns a promise that\n * - resolves to `true` if an update was activated successfully\n * - resolves to `false` if no update was available (for example, the client was already on the\n * latest version).\n * - rejects if any error occurs\n */\n activateUpdate() {\n if (!this.sw.isEnabled) {\n return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));\n }\n const nonce = this.sw.generateNonce();\n return this.sw.postMessageWithOperation('ACTIVATE_UPDATE', {\n nonce\n }, nonce);\n }\n static {\n this.ɵfac = function SwUpdate_Factory(t) {\n return new (t || SwUpdate)(i0.ɵɵinject(NgswCommChannel));\n };\n }\n static {\n this.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: SwUpdate,\n factory: SwUpdate.ɵfac\n });\n }\n }\n return SwUpdate;\n})();\n/*#__PURE__*/(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\n\n/*!\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nconst SCRIPT = /*#__PURE__*/new InjectionToken(ngDevMode ? 'NGSW_REGISTER_SCRIPT' : '');\nfunction ngswAppInitializer(injector, script, options, platformId) {\n return () => {\n if (!(isPlatformBrowser(platformId) && 'serviceWorker' in navigator && options.enabled !== false)) {\n return;\n }\n const ngZone = injector.get(NgZone);\n const appRef = injector.get(ApplicationRef);\n // Set up the `controllerchange` event listener outside of\n // the Angular zone to avoid unnecessary change detections,\n // as this event has no impact on view updates.\n ngZone.runOutsideAngular(() => {\n // Wait for service worker controller changes, and fire an INITIALIZE action when a new SW\n // becomes active. This allows the SW to initialize itself even if there is no application\n // traffic.\n const sw = navigator.serviceWorker;\n const onControllerChange = () => sw.controller?.postMessage({\n action: 'INITIALIZE'\n });\n sw.addEventListener('controllerchange', onControllerChange);\n appRef.onDestroy(() => {\n sw.removeEventListener('controllerchange', onControllerChange);\n });\n });\n let readyToRegister$;\n if (typeof options.registrationStrategy === 'function') {\n readyToRegister$ = options.registrationStrategy();\n } else {\n const [strategy, ...args] = (options.registrationStrategy || 'registerWhenStable:30000').split(':');\n switch (strategy) {\n case 'registerImmediately':\n readyToRegister$ = of(null);\n break;\n case 'registerWithDelay':\n readyToRegister$ = delayWithTimeout(+args[0] || 0);\n break;\n case 'registerWhenStable':\n readyToRegister$ = !args[0] ? whenStable(injector) : merge(whenStable(injector), delayWithTimeout(+args[0]));\n break;\n default:\n // Unknown strategy.\n throw new Error(`Unknown ServiceWorker registration strategy: ${options.registrationStrategy}`);\n }\n }\n // Don't return anything to avoid blocking the application until the SW is registered.\n // Also, run outside the Angular zone to avoid preventing the app from stabilizing (especially\n // given that some registration strategies wait for the app to stabilize).\n // Catch and log the error if SW registration fails to avoid uncaught rejection warning.\n ngZone.runOutsideAngular(() => readyToRegister$.pipe(take(1)).subscribe(() => navigator.serviceWorker.register(script, {\n scope: options.scope\n }).catch(err => console.error('Service worker registration failed with:', err))));\n };\n}\nfunction delayWithTimeout(timeout) {\n return of(null).pipe(delay(timeout));\n}\nfunction whenStable(injector) {\n const appRef = injector.get(ApplicationRef);\n return appRef.isStable.pipe(filter(stable => stable));\n}\nfunction ngswCommChannelFactory(opts, platformId) {\n return new NgswCommChannel(isPlatformBrowser(platformId) && opts.enabled !== false ? navigator.serviceWorker : undefined);\n}\n/**\n * Token that can be used to provide options for `ServiceWorkerModule` outside of\n * `ServiceWorkerModule.register()`.\n *\n * You can use this token to define a provider that generates the registration options at runtime,\n * for example via a function call:\n *\n * {@example service-worker/registration-options/module.ts region=\"registration-options\"\n * header=\"app.module.ts\"}\n *\n * @publicApi\n */\nclass SwRegistrationOptions {}\n/**\n * @publicApi\n *\n * Sets up providers to register the given Angular Service Worker script.\n *\n * If `enabled` is set to `false` in the given options, the module will behave as if service\n * workers are not supported by the browser, and the service worker will not be registered.\n *\n * Example usage:\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideServiceWorker('ngsw-worker.js')\n * ],\n * });\n * ```\n */\nfunction provideServiceWorker(script, options = {}) {\n return makeEnvironmentProviders([SwPush, SwUpdate, {\n provide: SCRIPT,\n useValue: script\n }, {\n provide: SwRegistrationOptions,\n useValue: options\n }, {\n provide: NgswCommChannel,\n useFactory: ngswCommChannelFactory,\n deps: [SwRegistrationOptions, PLATFORM_ID]\n }, {\n provide: APP_INITIALIZER,\n useFactory: ngswAppInitializer,\n deps: [Injector, SCRIPT, SwRegistrationOptions, PLATFORM_ID],\n multi: true\n }]);\n}\n\n/**\n * @publicApi\n */\nlet ServiceWorkerModule = /*#__PURE__*/(() => {\n class ServiceWorkerModule {\n /**\n * Register the given Angular Service Worker script.\n *\n * If `enabled` is set to `false` in the given options, the module will behave as if service\n * workers are not supported by the browser, and the service worker will not be registered.\n */\n static register(script, options = {}) {\n return {\n ngModule: ServiceWorkerModule,\n providers: [provideServiceWorker(script, options)]\n };\n }\n static {\n this.ɵfac = function ServiceWorkerModule_Factory(t) {\n return new (t || ServiceWorkerModule)();\n };\n }\n static {\n this.ɵmod = /* @__PURE__ */i0.ɵɵdefineNgModule({\n type: ServiceWorkerModule\n });\n }\n static {\n this.ɵinj = /* @__PURE__ */i0.ɵɵdefineInjector({\n providers: [SwPush, SwUpdate]\n });\n }\n }\n return ServiceWorkerModule;\n})();\n/*#__PURE__*/(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\n// This file only reexports content of the `src` folder. Keep it that way.\n\n// This file is not used to build this module. It is only used during editing\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { ServiceWorkerModule, SwPush, SwRegistrationOptions, SwUpdate, provideServiceWorker };\n","import {\r\n DestroyRef,\r\n EnvironmentInjector,\r\n Injectable,\r\n Injector,\r\n Provider,\r\n ProviderToken,\r\n Type,\r\n createEnvironmentInjector,\r\n } from '@angular/core';\r\n \r\n /**\r\n * inject a service asynchronously\r\n *\r\n * @param: injector. If the injector is a NodeInjector the loaded module will be destroyed alonside its injector\r\n */\r\n export async function injectAsync(\r\n injector: Injector,\r\n providerLoader: () => Promise>,\r\n ): Promise {\r\n const injectImpl = injector.get(InjectAsyncImpl);\r\n return injectImpl.get(injector, providerLoader);\r\n }\r\n \r\n @Injectable({providedIn: 'root'})\r\n class InjectAsyncImpl {\r\n private overrides = new WeakMap(); // no need to cleanup\r\n override(type: Type, mock: Type) {\r\n this.overrides.set(type, mock);\r\n }\r\n \r\n async get(injector: Injector, providerLoader: () => Promise>): Promise {\r\n const type = await providerLoader();\r\n \r\n // Check if we have overrides, O(1), low overhead\r\n if (this.overrides.has(type)) {\r\n const override = this.overrides.get(type);\r\n return new override();\r\n }\r\n \r\n if (!(injector instanceof EnvironmentInjector)) {\r\n // this is the DestroyRef of the component\r\n const destroyRef = injector.get(DestroyRef);\r\n \r\n // This is the parent injector of the injector we're creating\r\n const environmentInjector = injector.get(EnvironmentInjector);\r\n \r\n // Creating an environment injector to destroy it afterwards\r\n const newInjector = createEnvironmentInjector([type as Provider], environmentInjector);\r\n \r\n // Destroy the injector to trigger DestroyRef.onDestroy on our service\r\n destroyRef.onDestroy(() => {\r\n newInjector.destroy();\r\n });\r\n \r\n // We want to create the new instance of our service with our new injector\r\n injector = newInjector;\r\n }\r\n \r\n return injector.get(type)!;\r\n }\r\n }\r\n","import { IUser } from '@collections/users/interfaces/user.interface';\r\nimport { Mutation, gql} from 'apollo-angular';\r\nimport { Injectable } from '@angular/core';\r\n\r\nexport interface SaveProductResponse {\r\n saveProduct: IUser;\r\n}\r\n\r\n@Injectable({providedIn: 'root'})\r\nexport class saveProductGQL extends Mutation {\r\n document = gql`\r\n mutation saveProduct ($productId: ObjectId!, $lang: String!){\r\n saveProduct(lang: $lang, productId: $productId){\r\n _id\r\n profile {\r\n _id\r\n lang\r\n savedProducts (lang: $lang) {\r\n _id\r\n }\r\n }\r\n }\r\n }\r\n `;\r\n}","import { IUser } from '@collections/users/interfaces/user.interface';\r\nimport { Mutation, gql} from 'apollo-angular';\r\nimport { Injectable } from '@angular/core';\r\n\r\nexport interface RemoveProductResponse {\r\n removeProduct: IUser;\r\n}\r\n\r\n@Injectable({providedIn: 'root'})\r\nexport class removeProductGQL extends Mutation {\r\n document = gql`\r\n mutation removeProduct ($productId: ObjectId!, $lang: String!){\r\n removeProduct(lang: $lang, productId: $productId){\r\n _id\r\n profile {\r\n _id\r\n lang\r\n savedProducts (lang: $lang) {\r\n _id\r\n }\r\n }\r\n }\r\n }\r\n `;\r\n}\r\n","import { BlockUiService } from 'app/shared/components/block-ui/block-ui.service';\r\nimport { catchError, filter, take } from 'rxjs/operators';\r\nimport { MatSnackBar } from '@angular/material/snack-bar';\r\nimport { LanguagesService } from './../languages/languages.service';\r\nimport { UserRolesEnum } from '@collections/users/enums';\r\nimport { Injectable, Optional, createNgModule, ApplicationRef, inject, NgZone, EnvironmentInjector, signal } from '@angular/core';\r\nimport { Observable, iif, of, BehaviorSubject, from } from 'rxjs';\r\nimport { switchMap, map, tap } from 'rxjs/operators';\r\nimport { AuthService } from '@shared/auth/auth.service';\r\nimport { UserInfo } from '@shared/services/users/types/user-info';\r\nimport { UserInfoGQL } from './user-info.gql.service';\r\nimport { Apollo } from 'apollo-angular';\r\nimport type { MatDialogsHelperService } from 'app/shared/mat-dialogs-helper/mat-dialogs-helper.service';\r\nimport { AnalyticsService } from '../google-tag-manager/analytics/analytics.service';\r\nimport { ICompany } from '@collections/companies/interfaces';\r\nimport { FollowCompanyGQL } from './follow-company.gql.service';\r\nimport { UnFollowCompanyGQL } from './unfollow-company.gql.service';\r\nimport { IUser } from '@collections/users/interfaces';\r\nimport { clearByRegEx } from 'app/shared/services/common/cache.utilities';\r\nimport { UserInteractionService } from '../user-interaction/user-interaction.service';\r\nimport { Router } from '@angular/router';\r\nimport { SwUpdate, VersionReadyEvent } from '@angular/service-worker';\r\nimport { Platform } from '@angular/cdk/platform';\r\nimport { injectAsync } from '../inject-async';\r\nimport { environment } from '@env/environment';\r\nimport { toSignal } from '@angular/core/rxjs-interop';\r\nimport { IProduct } from '@collections/products/interfaces';\r\nimport { saveProductGQL } from './save-product.gql.service copy';\r\nimport { removeProductGQL } from './remove-product.gql.service';\r\n \r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class UsersService {\r\n private _currentUserRoles: string[];\r\n private _onUserChangeSubject: BehaviorSubject;\r\n private _currentCompanyId = '';\r\n private _currentUserId: string;\r\n private matDialogsHelperService: MatDialogsHelperService;\r\n private readonly environmentInjector = inject(EnvironmentInjector);\r\n private followCompanyGql: FollowCompanyGQL;\r\n private unFollowCompanyGql: UnFollowCompanyGQL;\r\n\r\n private snackBar: MatSnackBar;\r\n\r\n get onUserChange(): Observable {\r\n return this._onUserChangeSubject.asObservable();\r\n }\r\n\r\n get currentUserId(): string {\r\n return this._currentUserId;\r\n }\r\n\r\n private _currentUser: UserInfo;\r\n isLoggedIn = false;\r\n ngZone = inject(NgZone);\r\n userAction = toSignal(this.userInteractionService.onUserAction$);\r\n\r\n constructor(\r\n private appRef: ApplicationRef,\r\n private authService: AuthService,\r\n private languagesService: LanguagesService,\r\n private userInfoGQL: UserInfoGQL,\r\n private router: Router,\r\n private blockUiService: BlockUiService,\r\n @Optional() public analyticsService: AnalyticsService,\r\n private userInteractionService: UserInteractionService,\r\n @Optional() private swUpdate: SwUpdate,\r\n private apollo: Apollo,\r\n private platform: Platform,\r\n private saveProductGQL: saveProductGQL,\r\n private removeProductGQL: removeProductGQL\r\n ) {\r\n\r\n this.userInteractionService.onUserAction$\r\n .subscribe(() => {\r\n this.initSnackBar().subscribe(() => {\r\n if (this.swUpdate.isEnabled) {\r\n this.swUpdate.versionUpdates\r\n .pipe(filter((evt): evt is VersionReadyEvent => evt.type === 'VERSION_READY'))\r\n .subscribe(() => {\r\n this.snackBar.open(\r\n $localize`New Application version is available. Reloading...`, $localize`Warning`, {\r\n duration: 4000,\r\n verticalPosition: 'top'\r\n }).afterDismissed().subscribe(() => {\r\n // reload service worker\r\n document.location.reload();\r\n });\r\n });\r\n }\r\n });\r\n });\r\n\r\n this._currentUserRoles = [];\r\n this._onUserChangeSubject = new BehaviorSubject(null);\r\n this.authService.authTokenChange\r\n .pipe(\r\n tap((token) => {\r\n this._currentUserRoles = token?.roles ?? [];\r\n }),\r\n switchMap(token =>\r\n iif(() => (token !== null),\r\n this.userInfoGQL.watch({\r\n id: token?.id,\r\n lang: this.languagesService.getCurrentLangCode()\r\n }, {\r\n fetchPolicy: 'cache-first'\r\n }).valueChanges\r\n .pipe(\r\n map(result => result.data.userById),\r\n tap(user => {\r\n this._currentUserId = user._id;\r\n const currentRoles = user.roles;\r\n // se i ruoli su database sono diversi da quelli nel token, che persiste nel localstorage,\r\n // eseguo il refresh del token\r\n if (!this.rolesAreEquals(token.roles, currentRoles)) {\r\n this.authService.refreshToken()\r\n .subscribe(token => this._currentUserRoles = currentRoles);\r\n } else {\r\n this._currentUserRoles = currentRoles;\r\n }\r\n if (token.validated !== user.validated) {\r\n const { cache } = this.apollo.client;\r\n cache.modify({\r\n id: cache.identify(user),\r\n fields: {\r\n validated() {\r\n return token.validated;\r\n },\r\n }\r\n });\r\n }\r\n })\r\n ),\r\n of(null)\r\n .pipe(\r\n tap(() => this._currentUserRoles = []) // logout\r\n )\r\n ))\r\n ).subscribe(user => this._onUserChangeSubject.next(user));\r\n\r\n this.onUserChange\r\n .pipe(\r\n filter(user => !!user),\r\n take(1)\r\n ).subscribe(async () => {\r\n const [followCompanyGQL, unFollowCompanyGQL] = await Promise.all([\r\n injectAsync(this.environmentInjector, () =>\r\n import('./follow-company.gql.service').then((c) => c.FollowCompanyGQL),\r\n ),\r\n injectAsync(this.environmentInjector, () =>\r\n import('./unfollow-company.gql.service').then((c) => c.UnFollowCompanyGQL),\r\n )\r\n ]);\r\n this.followCompanyGql = followCompanyGQL;\r\n this.unFollowCompanyGql = unFollowCompanyGQL;\r\n })\r\n\r\n this.onUserChange\r\n .subscribe(async (user) => {\r\n this._currentUser = user;\r\n /* Deactivated sigup-wizard since the reg-wall was added */\r\n // if(this.platform.isBrowser) {\r\n // if(user) {\r\n // this.resetTimer();\r\n // } else {\r\n // this.startTimerAndOpenLogin();\r\n // }\r\n // }\r\n\r\n });\r\n }\r\n\r\n logout(): void {\r\n this.authService.invalidate();\r\n this.router.navigate(['/']);\r\n }\r\n\r\n openCompanyWizard(company?: ICompany) {\r\n this.blockUiService.show($localize`Loading...`);\r\n this.ensureDialogService()\r\n .pipe(\r\n switchMap(() => {\r\n return this.matDialogsHelperService.openCompanyWizard(company)\r\n })\r\n ).subscribe();\r\n }\r\n\r\n updateToken(token: string): void {\r\n this.authService.setauthToken(token);\r\n }\r\n\r\n public isInRole(roles: UserRolesEnum[]): boolean {\r\n if (!roles) {\r\n return true;\r\n }\r\n const _roles: string[] = roles.map(r => r === UserRolesEnum.stand_admin ? UserRolesEnum.stand_admin + this._currentCompanyId : r);\r\n return this._currentUserRoles.some((role) => _roles.includes(role));\r\n }\r\n\r\n\r\n canLoadBusinnesSection(): boolean {\r\n const permissionRoles = [UserRolesEnum.customer, UserRolesEnum.admin];\r\n return this._currentUserRoles.some((role: UserRolesEnum) => permissionRoles.includes(role));\r\n }\r\n\r\n canActivateModule(companyId: string): boolean {\r\n const userRoles = this._currentUserRoles;\r\n if (userRoles.includes(UserRolesEnum.admin)) {\r\n return true;\r\n }\r\n const standAdminRole = UserRolesEnum.stand_admin + companyId;\r\n if (userRoles.includes(standAdminRole)) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n\r\n private rolesAreEquals(roles1: string[], roles2: string[]): boolean {\r\n return JSON.stringify(roles1.slice().sort()) === JSON.stringify(roles2.slice().sort());\r\n }\r\n\r\n setCurrentCompanyRole(companyId: string): void {\r\n this._currentCompanyId = companyId;\r\n }\r\n\r\n checkPermission(cb: Function, roles = [UserRolesEnum.basic]): void {\r\n if (this.isInRole(roles)) {\r\n cb();\r\n } else {\r\n this.openLogin()\r\n .subscribe((loggedIn) => loggedIn ? cb() : null);\r\n }\r\n }\r\n\r\n checkPermissionLoad(roles = [UserRolesEnum.basic]): boolean {\r\n if (this.isInRole(roles)) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n private timer: any; // dichiarazione del timer\r\n\r\n resetTimer(): void {\r\n if (this.timer) {\r\n clearTimeout(this.timer);\r\n this.timer = null;\r\n }\r\n }\r\n\r\n startTimerAndOpenLogin(cb: Function = () => {}): void {\r\n \r\n // Resetta il timer esistente se presente (resetta il timer ogni volta che viene chiamata la startTimerAndOpenLogin) (serve per evitare che quando apro il sito mi apre il popup due volte)\r\n\r\n if (!this._currentUser && !this.timer && !environment.debugOn) { //se non è loggato allora appare il popup di 60s\r\n/* if(this.isInRole([UserRolesEnum.basic])){\r\n return;\r\n } */\r\n this.ngZone.runOutsideAngular(() => {\r\n this.timer = setTimeout(() => {\r\n this.openLogin().subscribe((loggedIn) => {\r\n if (!loggedIn) {\r\n this.resetTimer();\r\n this.ngZone.run(() => {\r\n this.startTimerAndOpenLogin(cb);\r\n })\r\n } else {\r\n cb();\r\n }\r\n });\r\n }, 60000); // 60 secondi\r\n })\r\n\r\n }\r\n }\r\n\r\n openLogin(): Observable {\r\n this.blockUiService.show($localize`Loading...`);\r\n return this.ensureDialogService()\r\n .pipe(\r\n switchMap(() => {\r\n return this.matDialogsHelperService.openLogin();\r\n })\r\n );\r\n }\r\n\r\n confirmAction(options: any): Observable {\r\n return this.ensureDialogService()\r\n .pipe(\r\n switchMap(() => {\r\n return this.matDialogsHelperService.confirm(options);\r\n })\r\n );\r\n }\r\n\r\n private ensureDialogService(): Observable {\r\n return this.matDialogsHelperService ?\r\n of(true) :\r\n from(import('app/shared/mat-dialogs-helper/mat-dialogs-helper.module'))\r\n .pipe(\r\n map(({MatDialogsHelperModule}) => {\r\n return createNgModule(MatDialogsHelperModule, this.appRef.injector);\r\n }),\r\n switchMap(moduleRef => {\r\n return from(import('app/shared/mat-dialogs-helper/mat-dialogs-helper.service'))\r\n .pipe(\r\n tap(({MatDialogsHelperService}) => {\r\n this.matDialogsHelperService = moduleRef.injector.get(MatDialogsHelperService)\r\n })\r\n )\r\n }),\r\n map(() => true),\r\n take(1)\r\n );\r\n }\r\n\r\n initSnackBar(): Observable {\r\n return from(import('@angular/material/snack-bar'))\r\n .pipe(\r\n map(({MatSnackBarModule}) => {\r\n return createNgModule(MatSnackBarModule, this.appRef.injector);\r\n }),\r\n switchMap(moduleRef => {\r\n return from(import('@angular/material/snack-bar'))\r\n .pipe(\r\n map(({MatSnackBar}) => {\r\n this.snackBar = moduleRef.injector.get(MatSnackBar);\r\n return true;\r\n })\r\n )\r\n }),\r\n take(1)\r\n );\r\n }\r\n\r\n toggleFollowCompany(company: ICompany, cb = (u: IUser) => {}): void {\r\n const lang = this.languagesService.getCurrentLangCode();\r\n this.checkPermission(() => {\r\n if (!this.isFollowedCompany(company._id)) {\r\n this.analyticsService.ecTrackAddRemoveToCart(company, true);\r\n this.followCompanyGql.mutate({\r\n id: this.currentUserId,\r\n lang: lang,\r\n companyId: company._id\r\n }, {\r\n update: (cache) => {\r\n this.clearFollowedCompaniesCache(cache);\r\n }\r\n })\r\n .pipe(\r\n map(res => res.data.followCompany)\r\n )\r\n .subscribe(u => cb(u));\r\n } else {\r\n this.analyticsService.ecTrackAddRemoveToCart(company, false);\r\n this.unFollowCompanyGql.mutate({\r\n id: this.currentUserId,\r\n lang: lang,\r\n companyId: company._id\r\n }, {\r\n update: (cache) => {\r\n this.clearFollowedCompaniesCache(cache);\r\n }\r\n })\r\n .pipe(\r\n map(res => res.data.unFollowCompany)\r\n )\r\n .subscribe(u => cb(u));\r\n }\r\n });\r\n }\r\n\r\n isFollowedCompany(companyId: string): boolean {\r\n return !!this._currentUser?.profile?.followedCompanies?.find(fc => fc._id === companyId);\r\n }\r\n\r\n private clearFollowedCompaniesCache(cache: any): void {\r\n const key = `^followedCompaniesByUser:.*\\\"userId\\\":\\\"${this.currentUserId}\\\".*`;\r\n clearByRegEx(cache,key);\r\n cache.gc();\r\n }\r\n\r\n toggleSaveProduct(product: IProduct, action: 'save' | 'remove', cb = (u: IUser) => {}): void {\r\n const lang = this.languagesService.getCurrentLangCode();\r\n this.checkPermission(() => {\r\n if (action === 'save') {\r\n // this.analyticsService.ecTrackAddRemoveToCart(company, true);\r\n this.saveProductGQL.mutate({\r\n productId: product._id,\r\n lang: lang\r\n }, { update: (cache) => this.clearSavedProductsCache(cache) })\r\n .pipe(\r\n catchError(e => { throw e }),\r\n map(res => res.data.saveProduct)\r\n )\r\n .subscribe({\r\n next: u => cb(u),\r\n error: e => console.error(e)\r\n })\r\n } \r\n else {\r\n // this.analyticsService.ecTrackAddRemoveToCart(company, false);\r\n this.removeProductGQL.mutate({\r\n productId: product._id,\r\n lang: lang\r\n }, { update: (cache) => this.clearSavedProductsCache(cache) })\r\n .pipe(\r\n catchError(e => { throw e }),\r\n map(res => res.data.removeProduct)\r\n )\r\n .subscribe({\r\n next: u => cb(u),\r\n error: e => console.error(e)\r\n })\r\n }\r\n });\r\n }\r\n\r\n isSavedProduct( productId: string ): boolean {\r\n if (!this._currentUser) \r\n return false;\r\n return !!this._currentUser.profile.savedProducts.find(p => p._id === productId)\r\n }\r\n\r\n private clearSavedProductsCache(cache: any): void {\r\n const key = `^savedProductsPage:.*\\\"userId\\\":\\\"${this.currentUserId}\\\".*`;\r\n clearByRegEx(cache,key);\r\n cache.gc();\r\n }\r\n\r\n}\r\n"]}