{ "version": 3, "sources": ["libs/conversation/core/src/lib/conversation.constants.ts", "libs/conversation/core/src/lib/inbox-utils.ts", "libs/conversation/core/src/lib/participant-utils.ts", "libs/conversation/core/src/lib/participant.service.ts", "libs/conversation/core/src/lib/inbox.service.ts"], "sourcesContent": ["import { Timestamp } from 'firebase/firestore';\nimport { ConversationChannel } from '@vendasta/conversation';\n\nexport const PAGE_SIZE = 20;\nexport const FIRESTORE_MESSAGE_LIMIT = 20;\nexport const FIRESTORE_CONVERSATION_LIMIT = 20;\nexport const INBOX = 'Inbox';\nexport const DELETED_TIMESTAMP_FIRESTORE = new Timestamp(10800, 0);\n// List of United States territories that are excluded from SMS feature\n// [Armed Forces Americas, Armed Forces Europe, Armed Forces Pacific, American Samoa, Micronesia, Guam, Marshall Islands, Northern Mariana Islands, Puerto Rico, Palau, U.S. Virgin Islands]\nexport const MARKETING_SERVICES_PIDS = ['VMKS', 'VMKA', 'VMKW', 'VMKV'];\nexport const SUPPORT_PID = 'VMF';\n\nexport const MAX_FILES = 1;\nexport const MAX_RECORDING_TIME = 60000;\n\nexport const POSTHOG_CHANNEL_NAME = new Map([\n [ConversationChannel.CONVERSATION_CHANNEL_UNDEFINED, 'undefined'],\n [ConversationChannel.CONVERSATION_CHANNEL_INTERNAL, 'platform'],\n [ConversationChannel.CONVERSATION_CHANNEL_SMS, 'sms'],\n [ConversationChannel.CONVERSATION_CHANNEL_FACEBOOK, 'facebook'],\n [ConversationChannel.CONVERSATION_CHANNEL_GOOGLE_MESSAGES, 'google_messages'],\n [ConversationChannel.CONVERSATION_CHANNEL_OPENAI, 'openai'],\n [ConversationChannel.CONVERSATION_CHANNEL_EMAIL, 'email'],\n [ConversationChannel.CONVERSATION_CHANNEL_GOOGLE_BUSINESS_COMMUNICATIONS, 'google_business_communications'],\n [ConversationChannel.CONVERSATION_CHANNEL_WEB_CHAT, 'webchat'],\n]);\n", "/**\n * check if the window view port reach out the max width query\n * @return {boolean}\n */\nexport function isMobile(): boolean {\n return window.matchMedia('(max-width:600px)').matches;\n}\n\n/**\n * check if the window view port reach out the max width query\n * @return {boolean}\n */\nexport function isWideScreen(): boolean {\n return window.matchMedia('(max-width:1440px)').matches;\n}\n", "import { GlobalParticipantType, NamespaceDetail, Participant, ParticipantType } from '@vendasta/conversation';\nimport { CrmObject, FieldValue } from '@vendasta/crm';\nimport { INBOX_CRM_SOURCE_NAME, STANDARD_CRM_FIELD_EXTERNAL_IDS } from './inbox.constants';\nimport { ConversationAvailableChannels, ConversationDetail } from './interface/conversation.interface';\nimport { InboxContact } from './interface/inbox.interface';\n\nexport function getSubjectParticipantByType(participants: Participant[], type: ParticipantType): Participant | null {\n return (\n participants?.find((participant) => participant?.isSubjectParticipant && participant?.participantType === type) ??\n null\n );\n}\n\n/**\n * isSameParticipant returns true if the target participant is the same based on the fields that makes a participant unique\n * @param userId\n * @param partnerId\n * @param accountGroupId\n * @param {Participant} targetParticipant\n * @returns {boolean}\n */\nexport function isSameParticipant(\n userId: string,\n partnerId: string,\n accountGroupId: string,\n targetParticipant: Participant,\n): boolean {\n return (\n targetParticipant?.internalParticipantId === userId &&\n targetParticipant?.partnerId === partnerId &&\n targetParticipant?.accountGroupId === accountGroupId\n );\n}\n\n/** Create a map of contact fields, using fieldID as key\n * @param {CrmObject} customerFields - contactFields\n * @return {Map} - Map of contact fields\n */\nexport function createContactFieldMap(contactFields: CrmObject): Map {\n const contactFieldMap = new Map();\n contactFields.fields.forEach((field) => {\n if (field?.fieldId) contactFieldMap.set(field.externalId, field);\n });\n return contactFieldMap;\n}\n\n/** Return an InboxContact object from CrmObject\n * @param {string} accountGroupId - accountGroupId\n * @param {CrmObject} contactFields - accountGroupId\n * @return {InboxContact} - Inbox Contact object\n */\nexport function getInboxContactFromCrm(accountGroupId: string, contactFields: CrmObject): InboxContact {\n const contactFieldMap = createContactFieldMap(contactFields);\n const inboxContact: InboxContact = {\n contactId: contactFields.crmObjectId,\n firstName: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.firstName)?.stringValue ?? '',\n lastName: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.lastName)?.stringValue ?? '',\n email: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.email)?.stringValue ?? '',\n phone: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.phoneNumber)?.stringValue ?? '',\n permissionToContact: true, //TODO (MEGA-221): hydrate this field when CRM service support it or delete it if not needed\n accountGroupId: accountGroupId,\n };\n return inboxContact;\n}\n\nexport function createCrmField(fieldName: string, stringValue: string): FieldValue | null {\n if (!fieldName || !stringValue) return null;\n return {\n externalId: fieldName,\n stringValue: stringValue,\n } as FieldValue;\n}\n\nexport function buildCrmFieldsForCreateContact(inboxContact: InboxContact): FieldValue[] {\n const object = [\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.firstName, inboxContact?.firstName),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.lastName, inboxContact?.lastName),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.phoneNumber, inboxContact?.phone),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.email, inboxContact?.email),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.source, INBOX_CRM_SOURCE_NAME),\n ].filter((field) => !!field);\n return object;\n}\n\n/**\n * Checks if the contact information is missing\n * @param {ConversationDetail} conversationDetail - Conversation Detail information\n * @param {ConversationAvailableChannels} availableChannels - Conversation Available Channels\n * @return {boolean}\n */\nexport function isContactInformationMissing(\n conversationDetail: ConversationDetail,\n availableChannels: ConversationAvailableChannels,\n): boolean {\n if (!conversationDetail?.conversation) return false;\n\n const recipients = conversationDetail?.participants\n ?.filter((p) => p.isSubjectParticipant && p.internalParticipantId)\n .filter((participant) => participant.participantType === ParticipantType.PARTICIPANT_TYPE_CUSTOMER);\n\n if (recipients?.length === 0) return false;\n\n const contactParticipant = conversationDetail?.participants?.find(\n (participant) => participant?.internalParticipantId === recipients[0].internalParticipantId,\n );\n\n return (\n !contactParticipant?.phoneNumber && !contactParticipant?.email && !availableChannels?.availableChannels?.length\n );\n}\n\n/**\n * Checks if the NamespaceDetail information used for describe participant hierarchy contains a participantType\n * @param {NamespaceDetail[]} hierarchy - Participant Hierarchy\n * @param {GlobalParticipantType} participantType - Participant Type\n * @return {boolean}\n */\nexport function isSubjectParticipantInHierarchy(\n hierarchy: NamespaceDetail[],\n participantType: GlobalParticipantType,\n): boolean {\n if (!hierarchy || !hierarchy.length) return false;\n return hierarchy.some((namespace) => namespace.participantType === participantType);\n}\n", "import { Inject, Injectable, OnDestroy } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { PAGE_ROUTES } from '@galaxy/crm/static';\nimport {\n ConversationApiService,\n ConversationChannel,\n GetMultiParticipantsRequest,\n GetMultiParticipantsResponse,\n GetParticipantsByKeyRequest,\n GetParticipantsByKeyResponse,\n GlobalParticipantType,\n Participant,\n ParticipantKey,\n ParticipantType,\n NamespaceDetail,\n} from '@vendasta/conversation';\nimport {\n CRMApiService,\n CreateCrmObjectRequest,\n CreateCrmObjectResponse,\n CrmObject,\n CrmObjectSearch,\n ListCrmObjectsRequest,\n} from '@vendasta/crm';\nimport { SnackbarService } from '@vendasta/galaxy/snackbar-service';\nimport {\n BehaviorSubject,\n EMPTY,\n Observable,\n Subject,\n catchError,\n combineLatest,\n defaultIfEmpty,\n firstValueFrom,\n map,\n of,\n shareReplay,\n switchMap,\n take,\n} from 'rxjs';\nimport { CONTACTS_PAGE_SIZE } from './inbox.constants';\nimport { InboxContact } from './interface/inbox.interface';\nimport { buildCrmFieldsForCreateContact, getInboxContactFromCrm } from './participant-utils';\nimport { ACCOUNT_GROUP_ID_TOKEN, GROUP_ID_TOKEN, PARTNER_ID_TOKEN, USER_ID_TOKEN } from './tokens';\n\nexport class ParticipantBuilder {\n private readonly participant: Participant;\n constructor() {\n this.participant = new Participant();\n }\n\n partnerId(partnerId: string): ParticipantBuilder {\n this.participant.partnerId = partnerId;\n return this;\n }\n\n accountGroupId(accountGroupId: string): ParticipantBuilder {\n this.participant.accountGroupId = accountGroupId;\n return this;\n }\n\n channel(channel: ConversationChannel): ParticipantBuilder {\n this.participant.channel = channel;\n return this;\n }\n\n participantType(participantType: ParticipantType): ParticipantBuilder {\n this.participant.participantType = participantType;\n return this;\n }\n\n internalParticipantId(internalParticipantId: string): ParticipantBuilder {\n this.participant.internalParticipantId = internalParticipantId;\n return this;\n }\n\n isSubjectParticipant(isSubjectParticipant: boolean): ParticipantBuilder {\n this.participant.isSubjectParticipant = isSubjectParticipant;\n return this;\n }\n\n build(): Participant {\n return this.participant;\n }\n}\n\n@Injectable()\nexport class ParticipantService implements OnDestroy {\n constructor(\n @Inject(USER_ID_TOKEN) readonly userId$: Observable,\n @Inject(PARTNER_ID_TOKEN) readonly partnerId$: Observable,\n @Inject(ACCOUNT_GROUP_ID_TOKEN) readonly accountGroupId$: Observable,\n @Inject(GROUP_ID_TOKEN) readonly groupId$: Observable,\n private conversationApiService: ConversationApiService,\n private crmService: CRMApiService,\n private readonly snackbarService: SnackbarService,\n private readonly router: Router,\n ) {}\n private unsubscribe$ = new Subject();\n private contacts$$: BehaviorSubject> = new BehaviorSubject([]);\n\n readonly participantDetails$ = combineLatest([\n this.partnerId$,\n this.accountGroupId$,\n this.userId$,\n this.groupId$,\n ]).pipe(\n map(([partnerId, accountGroupId, userId, groupId]) => {\n return {\n partnerId: partnerId ?? '',\n accountGroupId: accountGroupId ?? '',\n userId: userId ?? '',\n groupId: groupId ?? '',\n };\n }),\n );\n\n readonly currentParticipant$: Observable = this.participantDetails$.pipe(\n switchMap((details) => this.getParticipant(details)),\n shareReplay({ bufferSize: 1, refCount: true }),\n );\n\n public contacts$ = this.contacts$$.asObservable();\n ngOnDestroy(): void {\n this.unsubscribe$.next();\n this.unsubscribe$.complete();\n }\n\n getParticipant(participantDetails: {\n userId: string;\n partnerId: string;\n accountGroupId: string;\n groupId?: string;\n }): Observable {\n const participantKey = {\n internalParticipantId: participantDetails.userId,\n partnerId: participantDetails.partnerId ?? '',\n accountGroupId: participantDetails.accountGroupId ?? '',\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_IAM_USER,\n namespaceHierarchy: this.buildNamespaceHierarchy(\n participantDetails.partnerId,\n participantDetails.accountGroupId,\n participantDetails.groupId,\n ),\n } as ParticipantKey;\n return this.getParticipantsByKey(participantKey).pipe(\n catchError((err) => {\n console.error(err);\n return EMPTY;\n }),\n map((resp) => {\n return resp?.participant;\n }),\n defaultIfEmpty({} as Participant),\n shareReplay({ bufferSize: 1, refCount: true }),\n );\n }\n\n // buildNamespaceHierarchy is a helper function to build the namespace hierarchy for a participant\n buildNamespaceHierarchy(partnerId: string, accountGroupId: string, groupId?: string): NamespaceDetail[] {\n const namespaceHierarchy = [\n new NamespaceDetail({\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_PARTNER,\n internalParticipantId: partnerId,\n }),\n ];\n\n // either group or account group will be set.\n if (groupId) {\n namespaceHierarchy.push(\n new NamespaceDetail({\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_GROUP,\n internalParticipantId: groupId,\n }),\n );\n } else if (accountGroupId) {\n namespaceHierarchy.push(\n new NamespaceDetail({\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_ACCOUNT_GROUP,\n internalParticipantId: accountGroupId,\n }),\n );\n }\n return namespaceHierarchy;\n }\n\n buildIAMUserParticipant(channel: ConversationChannel, isSubjectParticipant?: boolean): Observable {\n return combineLatest([this.partnerId$, this.accountGroupId$, this.userId$]).pipe(\n map(([partnerId, accountGroupId, userId]) => {\n return this.buildIamUser(partnerId, accountGroupId, userId, channel, isSubjectParticipant);\n }),\n );\n }\n\n public buildIamUser(\n partnerId: string,\n accountGroupId: string,\n userId: string,\n channel: ConversationChannel,\n isSubjectParticipant?: boolean,\n ): Participant {\n return accountGroupId\n ? new ParticipantBuilder()\n .partnerId(partnerId)\n .accountGroupId(accountGroupId)\n .channel(channel)\n .participantType(ParticipantType.PARTICIPANT_TYPE_IAM_USER)\n .internalParticipantId(userId)\n .isSubjectParticipant(isSubjectParticipant ?? false)\n .build()\n : new ParticipantBuilder()\n .partnerId(partnerId)\n .channel(channel)\n .participantType(ParticipantType.PARTICIPANT_TYPE_IAM_USER)\n .internalParticipantId(userId)\n .isSubjectParticipant(isSubjectParticipant ?? false)\n .build();\n }\n\n public buildAccountGroup(partnerId: string, accountGroupId: string, channel: ConversationChannel): Participant {\n return new ParticipantBuilder()\n .partnerId(partnerId)\n .accountGroupId(accountGroupId)\n .channel(channel)\n .participantType(ParticipantType.PARTICIPANT_TYPE_ACCOUNT_GROUP)\n .internalParticipantId('')\n .isSubjectParticipant(true)\n .build();\n }\n\n public buildPartner(partnerId: string, channel: ConversationChannel): Participant {\n return new ParticipantBuilder()\n .partnerId(partnerId)\n .channel(channel)\n .participantType(ParticipantType.PARTICIPANT_TYPE_PARTNER)\n .internalParticipantId('')\n .isSubjectParticipant(true)\n .build();\n }\n\n public buildVendor(vendorId: string, channel: ConversationChannel): Participant {\n return new ParticipantBuilder()\n .partnerId(vendorId)\n .channel(channel)\n .participantType(ParticipantType.PARTICIPANT_TYPE_VENDOR)\n .internalParticipantId('')\n .isSubjectParticipant(true)\n .build();\n }\n\n public addContact(contact: InboxContact): Observable {\n if (!contact) return of({} as InboxContact);\n return this.createCrmContact(contact);\n }\n\n private createCrmContact(contact: InboxContact): Observable {\n return this.crmService\n .createContact({\n namespace: contact.accountGroupId,\n crmObject: {\n fields: buildCrmFieldsForCreateContact(contact),\n },\n } as CreateCrmObjectRequest)\n .pipe(\n map((crmObjectResponse: CreateCrmObjectResponse) => {\n contact.contactId = crmObjectResponse?.crmObjectId;\n return contact;\n }),\n );\n }\n\n public searchContacts(term: string, accountGroupId: string): void {\n if (term?.length <= 2) {\n this.contacts$$.next([] as Array);\n return;\n }\n\n this.getContactsFromCrmService(accountGroupId, term)\n .pipe(take(1))\n .subscribe((contactList) => {\n this.contacts$$.next(contactList);\n });\n }\n\n /**\n * Get contact list from CRM Service\n * @param {string} accountGroupId - accountGroupId\n * @param {string} term - search term\n * @return {Observable>} - Inbox Contact list observable\n */\n private getContactsFromCrmService(accountGroupId: string, term: string): Observable> {\n return this.crmService\n .listContacts({\n namespace: accountGroupId,\n search: { searchTerm: term } as CrmObjectSearch,\n pagingOptions: {\n pageSize: CONTACTS_PAGE_SIZE,\n },\n } as ListCrmObjectsRequest)\n .pipe(\n map((response) =>\n response?.crmObjects\n ?.filter((contact) => !!contact)\n .map((contact: CrmObject) => getInboxContactFromCrm(accountGroupId, contact)),\n ),\n catchError(() => of([] as Array)),\n );\n }\n\n /**\n * get multi participants from the Conversation µs\n * @param {string[]} participantIds - the participant IDs\n * @return {Observable}\n */\n public getMultiParticipants(\n participantIds: string[],\n conversationId: string,\n ): Observable {\n if (!participantIds || participantIds.length === 0) {\n console.error('the participantIds is not valid');\n return of({ participants: [] as Participant[] } as GetMultiParticipantsResponse);\n }\n\n const req = {\n conversationId: conversationId,\n participantIds: participantIds,\n } as GetMultiParticipantsRequest;\n return this.conversationApiService.getMultiParticipants(req).pipe(\n catchError((err) => {\n console.error('getMultiParticipants error:', err?.message);\n return of({} as GetMultiParticipantsResponse);\n }),\n );\n }\n\n /**\n * get participants by key from the Conversation µs\n */\n public getParticipantsByKey(participantKeyInfo: ParticipantKey): Observable {\n const req = {\n participantKey: participantKeyInfo,\n } as GetParticipantsByKeyRequest;\n\n return this.conversationApiService.getParticipantsByKey(req);\n }\n\n organizationId$ = combineLatest([this.partnerId$, this.accountGroupId$]).pipe(\n map(([partnerId, accountGroupId]) => {\n return accountGroupId || partnerId;\n }),\n );\n\n //TODO: (MEGA-433) Improve inbox logic to get hydrated participant information from getMultiConversationDetail participants\n // instead of subjectParticipants. This will allow us to remove unnecessary conversation Id argument.\n /**\n * View recipient contact information\n * @param contactId - contact ID\n * @param participantType - Firestore Participant Type\n * @param conversationId - Conversation ID\n */\n async viewContact(\n contactId: string,\n participantType: ParticipantType,\n conversationId: string,\n firestoreDocId?: string,\n ): Promise {\n if (!contactId || !participantType) {\n this.snackbarService.openErrorSnack('INBOX.TOPBAR.ERROR_LOADING_RECIPIENT');\n return;\n }\n\n const accountGroupId = await firstValueFrom(this.accountGroupId$);\n\n const returnUrl = `/account/location/${accountGroupId}/inbox/channel/${firestoreDocId}`;\n const routeTemplate = `/account/location/${accountGroupId}/crm/${PAGE_ROUTES.CONTACT.ROOT}/${PAGE_ROUTES.CONTACT.SUBROUTES.PROFILE}`;\n this.router.navigate([routeTemplate.replace(':crmObjectId', contactId)], {\n queryParams: { returnUrl: returnUrl },\n });\n }\n}\n", "import { Inject, inject, Injectable, OnDestroy } from '@angular/core';\nimport { FeatureFlagService } from '@galaxy/partner';\nimport { AddressAPIService } from '@vendasta/address';\nimport { GlobalParticipantType, InboxApiService, PlatformLocation } from '@vendasta/conversation';\nimport { IAMService, Role, UserIdentifier } from '@vendasta/iamv2';\nimport {\n catchError,\n combineLatest,\n distinctUntilChanged,\n firstValueFrom,\n map,\n Observable,\n of,\n shareReplay,\n Subject,\n switchMap,\n take,\n} from 'rxjs';\nimport { MARKETING_SERVICES_PIDS } from './conversation.constants';\nimport { isWideScreen } from './inbox-utils';\nimport {\n EXCLUDED_GEOGRAPHICAL_US_STATES,\n INBOX_EMAIL,\n INBOX_OPEN_DEFAULT,\n INBOX_SMS_A2P,\n MESSAGE_TEMPLATE_CARD,\n WEB_CHAT_FOR_PARTNER_INBOX,\n WEBCHAT_SETTING_CARD,\n} from './inbox.constants';\nimport {\n ACCOUNT_GROUP_ID_TOKEN,\n CONVERSATION_CONFIG_TOKEN,\n CONVERSATION_COUNTRY_TOKEN,\n CONVERSATION_GEOGRAPHICAL_STATE_TOKEN,\n CONVERSATION_GOOGLE_BUSINESS_MESSAGES_AVAILABLE_TOKEN,\n CONVERSATION_PLATFORM_LOCATION_TOKEN,\n CONVERSATION_SMS_ENABLED_TOKEN,\n CONVERSATION_WEB_CHAT_ENABLED_TOKEN,\n FEATURE_FLAG_TOKEN,\n PARTNER_ID_TOKEN,\n USER_ID_TOKEN,\n GROUP_ID_TOKEN,\n} from './tokens';\nimport { GetAccountInfoResponse, ParticipantType, SmsService } from '@vendasta/smsv2';\nimport { HttpErrorResponse } from '@angular/common/http';\nimport { ParticipantService } from './participant.service';\n\nconst isSuperAdminFn = (partner: Role): boolean => !!partner?.attributes.attributes['is_super_admin']?.boolAttribute;\n\n@Injectable()\nexport class InboxService implements OnDestroy {\n private readonly unsubscribe$$ = new Subject();\n private readonly smsService = this.isBusinessApp ? inject(SmsService) : null;\n\n readonly iamUser$ = this.userId$.pipe(\n switchMap((userId) => this.iamService.getUser({ userId: userId } as UserIdentifier)),\n );\n\n readonly canAccessEmbeddedSettings$ = combineLatest([this.iamUser$, this.partnerId$]).pipe(\n map(([user, currentPartnerId]) => {\n if (!this.isPartnerCenter) return false;\n const { partnerId: userPartnerID, roles: { partner } = {} } = user;\n const isSuperAdmin = isSuperAdminFn(partner);\n return (currentPartnerId === userPartnerID && !!partner) || isSuperAdmin;\n }),\n shareReplay(1),\n );\n\n readonly showAvailabilityMessageSettings$ = combineLatest([this.iamUser$, this.partnerId$]).pipe(\n map(([user, currentPartnerId]) => {\n const { partnerId: userPartnerID, roles: { partner } = {} } = user;\n const isSuperAdmin = isSuperAdminFn(partner);\n return (\n ((currentPartnerId === userPartnerID && !!partner) || isSuperAdmin) &&\n MARKETING_SERVICES_PIDS.includes(currentPartnerId)\n );\n }),\n shareReplay(1),\n );\n\n private readonly featureFlags$ = this.partnerId$.pipe(\n switchMap((partnerId) => {\n return this.featureFlagService\n .batchGetStatus(partnerId, '', [\n INBOX_OPEN_DEFAULT,\n INBOX_SMS_A2P,\n WEBCHAT_SETTING_CARD,\n MESSAGE_TEMPLATE_CARD,\n WEB_CHAT_FOR_PARTNER_INBOX,\n INBOX_EMAIL,\n ])\n .pipe(take(1), shareReplay(1));\n }),\n );\n\n readonly partnerHasA2PAccess$ = this.featureFlags$.pipe(\n map((res) => res[INBOX_SMS_A2P]),\n distinctUntilChanged(),\n shareReplay(1),\n );\n\n readonly SMSNumber$ = this.accountGroupId$.pipe(\n switchMap((accountGroupId) => {\n if (!this.smsService || !accountGroupId) return of(null);\n return this.smsService.getAccountInfo({\n internalId: accountGroupId,\n type: ParticipantType.PARTICIPANT_TYPE_ACCOUNT_GROUP,\n });\n }),\n catchError((error: HttpErrorResponse) => {\n console.error('error to get account info:', error.message);\n return of({} as GetAccountInfoResponse);\n }),\n map((accountInfo) => accountInfo?.phoneNumber),\n distinctUntilChanged(),\n shareReplay(1),\n );\n\n constructor(\n private readonly featureFlagService: FeatureFlagService,\n private readonly participantService: ParticipantService,\n @Inject(ACCOUNT_GROUP_ID_TOKEN) private readonly accountGroupId$: Observable,\n @Inject(CONVERSATION_COUNTRY_TOKEN) readonly country$: Observable,\n @Inject(CONVERSATION_GEOGRAPHICAL_STATE_TOKEN) private readonly geographicalState$: Observable,\n @Inject(PARTNER_ID_TOKEN) private readonly partnerId$: Observable,\n @Inject(FEATURE_FLAG_TOKEN)\n @Inject(CONVERSATION_PLATFORM_LOCATION_TOKEN)\n readonly platformLocation: PlatformLocation,\n private readonly addressService: AddressAPIService,\n @Inject(CONVERSATION_SMS_ENABLED_TOKEN) private smsEnabled$: Observable,\n @Inject(CONVERSATION_WEB_CHAT_ENABLED_TOKEN) private webChatEnabled$: Observable,\n @Inject(CONVERSATION_GOOGLE_BUSINESS_MESSAGES_AVAILABLE_TOKEN)\n private googleBusinessMessagesAvailable$: Observable,\n @Inject(USER_ID_TOKEN) private readonly userId$: Observable,\n private iamService: IAMService,\n private readonly inboxApiService: InboxApiService,\n @Inject(GROUP_ID_TOKEN) private readonly groupId$: Observable,\n ) {}\n\n hasAccessToInboxPage$ =\n inject(CONVERSATION_CONFIG_TOKEN)?.hasAccessToInboxPage$?.pipe(map((result) => !!result)) || of(true);\n allowSmbChatWithPartner$ =\n inject(CONVERSATION_CONFIG_TOKEN)?.allowSmbChatWithPartner$?.pipe(map((result) => !!result)) || of(false);\n\n /**\n * Check if account can access SMS feature.\n * SMS is only accessible for US/CA accounts.\n */\n get canAccessSMS$(): Observable {\n const hasAccessByCountry$ = this.geographicalState$.pipe(\n switchMap((geographicalState) => this.hasAccessByCountry(geographicalState)),\n );\n return combineLatest([this.hasAccessToInboxPage$, hasAccessByCountry$, this.smsEnabled$]).pipe(\n map(([hasAccessToInboxPage, hasAccessByCountry, smsEnabled]) => {\n return hasAccessToInboxPage && hasAccessByCountry && smsEnabled;\n }),\n distinctUntilChanged(),\n shareReplay(1),\n );\n }\n\n reauthorizeGoogleAccount() {\n // TODO: (BREW-316) - Reauthorize Google Account\n }\n\n get canAccess$(): Observable {\n return combineLatest([this.hasAccessToInboxPage$, this.hasAccessByCountry()]).pipe(\n map(([hasAccess, hasAccessByCountry]) => hasAccess && hasAccessByCountry),\n take(1),\n shareReplay(1),\n );\n }\n\n private hasAccessByCountry(accountGroupGeographicalState?: string): Observable {\n // https://address-demo.apigateway.co/address.v1.Address/ListAllCountryOptions\n // Australia - AU / United Kingdom - GB\n const availableCountries = ['ca', 'us'];\n return this.country$.pipe(\n switchMap((accountGroupCountry) => {\n const country = accountGroupCountry?.toLowerCase() || '';\n if (!availableCountries?.includes(country)) {\n return of(false);\n }\n if (country === 'us' && accountGroupGeographicalState) {\n return this.hasAccessByUSState(accountGroupGeographicalState).pipe(\n take(1),\n map((hasAccessByUSState) => hasAccessByUSState),\n );\n }\n return of(true);\n }),\n );\n }\n\n /**\n * Check if account is a US account\n * If the Country is US and the state doesn't belong to a valid US state the validation would be false.\n */\n private isUsAccountWithSmsAccess$(accountGroupGeographicalState?: string): Observable {\n return this.country$.pipe(\n switchMap((accountGroupCountry) => {\n const country = accountGroupCountry?.toLowerCase() || '';\n if (country === 'us' && accountGroupGeographicalState) {\n return this.hasAccessByUSState(accountGroupGeographicalState);\n }\n return of(false);\n }),\n );\n }\n\n private hasAccessByUSState(accountGroupState: string): Observable {\n const state = accountGroupState?.toLowerCase() || '';\n return this.addressService.getCountryConfiguration('US', undefined).pipe(\n take(1),\n map((countryInfo) => {\n const filteredStateList = countryInfo?.zones?.reduce((accumulator, currentValue) => {\n if (!EXCLUDED_GEOGRAPHICAL_US_STATES.includes(currentValue?.code)) {\n return [...accumulator, currentValue?.code?.toLocaleLowerCase()];\n }\n return accumulator;\n }, []);\n return filteredStateList?.includes(state);\n }),\n catchError((error) => {\n console.error('Error getting country configuration:', error.message);\n return of(false);\n }),\n );\n }\n\n readonly showInboxViews$ = of(!this.isBusinessApp);\n\n readonly canAccessInboxGetStartedCard$ = combineLatest([\n this.smsEnabled$,\n this.googleBusinessMessagesAvailable$,\n ]).pipe(\n map(([smsEnable, googleBusinessMessagesEnable]) => {\n return smsEnable && googleBusinessMessagesEnable;\n }),\n distinctUntilChanged(),\n );\n\n readonly openInboxDefault$ = this.featureFlags$.pipe(\n map((featureFlags) => {\n return featureFlags[INBOX_OPEN_DEFAULT] && this.isPartnerCenter && !isWideScreen();\n }),\n shareReplay(1),\n );\n\n readonly canAccessWebChatSettings$ = combineLatest([this.featureFlags$, this.webChatEnabled$]).pipe(\n map(([featureFlags, webchatEnabled]) => {\n const canAccessBA = featureFlags[WEBCHAT_SETTING_CARD] && this.isBusinessApp && webchatEnabled;\n const canAccessPCC = featureFlags[WEB_CHAT_FOR_PARTNER_INBOX] && this.isPartnerCenter;\n return canAccessBA || canAccessPCC;\n }),\n shareReplay(1),\n );\n\n readonly canAccessEmailChannel$ = this.featureFlags$.pipe(\n map((featureFlags) => {\n return featureFlags[INBOX_EMAIL] && this.isBusinessApp;\n }),\n );\n\n readonly canAccessMessageTemplateSettingsCard$ = this.featureFlags$.pipe(\n map((featureFlags) => featureFlags[MESSAGE_TEMPLATE_CARD]),\n shareReplay(1),\n );\n\n readonly multiLocationEnabled$ = this.groupId$.pipe(\n switchMap((groupId) => {\n if (!groupId || !this.isBusinessApp) {\n return of({ configuration: { multiLocationEnabled: false } });\n }\n return this.inboxApiService\n .getConfiguration({\n subjectParticipant: {\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_GROUP,\n internalParticipantId: groupId,\n },\n })\n .pipe(catchError(() => of({ configuration: { multiLocationEnabled: false } })));\n }),\n map((config) => {\n return config.configuration.multiLocationEnabled ?? false;\n }),\n catchError(() => of(false)),\n shareReplay(1),\n );\n\n /**\n * check if the current platform location is the business app\n * @return {boolean}\n */\n get isBusinessApp(): boolean {\n return this.platformLocation === PlatformLocation.PLATFORM_LOCATION_BUSINESS_APP;\n }\n\n /**\n * check if the current platform location is the partner center\n * @return {boolean}\n */\n get isPartnerCenter(): boolean {\n return this.platformLocation === PlatformLocation.PLATFORM_LOCATION_PARTNER_CENTER;\n }\n\n /**\n * check if the current platform location is the sales center\n * @return {boolean}\n */\n get isSalesCenter(): boolean {\n return this.platformLocation === PlatformLocation.PLATFORM_LOCATION_SALES_CENTER;\n }\n\n /**\n * check if displaying the A2P card in business app inbox setting page\n * @return {Promise}\n */\n async displayA2pCard$(): Promise {\n const hasAccessByCountry$ = this.geographicalState$.pipe(\n switchMap((geographicalState) => this.hasAccessByCountry(geographicalState)),\n );\n\n return await firstValueFrom(\n combineLatest([\n this.hasAccessToInboxPage$,\n hasAccessByCountry$,\n this.partnerHasA2PAccess$,\n this.smsEnabled$,\n ]).pipe(\n map(([hasAccessToInboxPage, hasAccessByCountry, partnerHasA2PAccess, smsEnable]): boolean => {\n return this.isBusinessApp && hasAccessToInboxPage && hasAccessByCountry && partnerHasA2PAccess && smsEnable;\n }),\n ),\n );\n }\n\n async buildTemplateTrackProperties() {\n return {\n accountGroupId: await firstValueFrom(this.accountGroupId$),\n participantName: (await firstValueFrom(this.participantService.currentParticipant$)).name || '',\n partnerId: await firstValueFrom(this.partnerId$),\n location: PlatformLocation[this.platformLocation],\n };\n }\n\n async buildAiKnowledgeAppConfigurationUrl(widgetId: string): Promise {\n const accountGroupId = await firstValueFrom(this.accountGroupId$);\n if (accountGroupId) {\n return `/account/location/${accountGroupId}/settings/widgets/${widgetId}/edit`;\n }\n return `/(inbox:inbox/widgets/${widgetId}/edit)`;\n }\n\n buildAppId(widgetId: string): string {\n return `APP-WEBCHAT-${widgetId}`;\n }\n\n ngOnDestroy(): void {\n this.unsubscribe$$.next();\n this.unsubscribe$$.complete();\n }\n}\n"], "mappings": "s1BAKO,IAAMA,GAA+B,GAErC,IAAMC,GAA8B,IAAIC,GAAU,MAAO,CAAC,EAGpDC,GAA0B,CAAC,OAAQ,OAAQ,OAAQ,MAAM,EACzDC,GAAc,MAEdC,GAAY,EACZC,GAAqB,IAErBC,GAAuB,IAAIC,IAAiC,CACvE,CAACC,EAAoBC,+BAAgC,WAAW,EAChE,CAACD,EAAoBE,8BAA+B,UAAU,EAC9D,CAACF,EAAoBG,yBAA0B,KAAK,EACpD,CAACH,EAAoBI,8BAA+B,UAAU,EAC9D,CAACJ,EAAoBK,qCAAsC,iBAAiB,EAC5E,CAACL,EAAoBM,4BAA6B,QAAQ,EAC1D,CAACN,EAAoBO,2BAA4B,OAAO,EACxD,CAACP,EAAoBQ,oDAAqD,gCAAgC,EAC1G,CAACR,EAAoBS,8BAA+B,SAAS,CAAC,CAC/D,ECtBK,SAAUC,IAAQ,CACtB,OAAOC,OAAOC,WAAW,mBAAmB,EAAEC,OAChD,CAMM,SAAUC,IAAY,CAC1B,OAAOH,OAAOC,WAAW,oBAAoB,EAAEC,OACjD,CCRM,SAAUE,GAA4BC,EAA6BC,EAAqB,CAC5F,OACED,GAAcE,KAAMC,GAAgBA,GAAaC,sBAAwBD,GAAaE,kBAAoBJ,CAAI,GAC9G,IAEJ,CA2BM,SAAUK,GAAsBC,EAAwB,CAC5D,IAAMC,EAAkB,IAAIC,IAC5BF,OAAAA,EAAcG,OAAOC,QAASC,GAAS,CACjCA,GAAOC,SAASL,EAAgBM,IAAIF,EAAMG,WAAYH,CAAK,CACjE,CAAC,EACMJ,CACT,CAOM,SAAUQ,GAAuBC,EAAwBV,EAAwB,CACrF,IAAMC,EAAkBF,GAAsBC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0B,EAAAJ,EAC1BK,EAAqC,EAAAL,EACrCM,CAAgB,EAAAN,EAEhBO,EAAoC,EAAAP,EAAAQ,EAAA,EAAAR,EAGpCS,EAA8B,EAAAT,EAC9BU,EAAmC,EAAAV,EACnCW,EAAqD,EAAAX,EAErDY,CAAa,EAAAZ,EAAAa,EAAA,EAAAb,EAAAc,EAAA,EAAAd,EAGbe,CAAc,CAAA,CAAA,wBAtFb/J,EAAYgK,QAAZhK,EAAYiK,SAAA,CAAA,EAAnB,IAAOjK,EAAPkK,SAAOlK,CAAY,GAAA", "names": ["FIRESTORE_CONVERSATION_LIMIT", "DELETED_TIMESTAMP_FIRESTORE", "Timestamp", "MARKETING_SERVICES_PIDS", "SUPPORT_PID", "MAX_FILES", "MAX_RECORDING_TIME", "POSTHOG_CHANNEL_NAME", "Map", "ConversationChannel", "CONVERSATION_CHANNEL_UNDEFINED", "CONVERSATION_CHANNEL_INTERNAL", "CONVERSATION_CHANNEL_SMS", "CONVERSATION_CHANNEL_FACEBOOK", "CONVERSATION_CHANNEL_GOOGLE_MESSAGES", "CONVERSATION_CHANNEL_OPENAI", "CONVERSATION_CHANNEL_EMAIL", "CONVERSATION_CHANNEL_GOOGLE_BUSINESS_COMMUNICATIONS", "CONVERSATION_CHANNEL_WEB_CHAT", "isMobile", "window", "matchMedia", "matches", "isWideScreen", "getSubjectParticipantByType", "participants", "type", "find", "participant", "isSubjectParticipant", "participantType", "createContactFieldMap", "contactFields", "contactFieldMap", "Map", "fields", "forEach", "field", "fieldId", "set", "externalId", "getInboxContactFromCrm", "accountGroupId", "contactId", "crmObjectId", "firstName", "get", "STANDARD_CRM_FIELD_EXTERNAL_IDS", "stringValue", "lastName", "email", "phone", "phoneNumber", "permissionToContact", "createCrmField", "fieldName", "buildCrmFieldsForCreateContact", "inboxContact", "source", "INBOX_CRM_SOURCE_NAME", "filter", "isContactInformationMissing", "conversationDetail", "availableChannels", "conversation", "recipients", "participants", "p", "isSubjectParticipant", "internalParticipantId", "participant", "participantType", "ParticipantType", "PARTICIPANT_TYPE_CUSTOMER", "length", "contactParticipant", "find", "ParticipantBuilder", "constructor", "participant", "Participant", "partnerId", "accountGroupId", "channel", "participantType", "internalParticipantId", "isSubjectParticipant", "build", "ParticipantService", "userId$", "partnerId$", "accountGroupId$", "groupId$", "conversationApiService", "crmService", "snackbarService", "router", "unsubscribe$", "Subject", "contacts$$", "BehaviorSubject", "participantDetails$", "combineLatest", "pipe", "map", "userId", "groupId", "currentParticipant$", "switchMap", "details", "getParticipant", "shareReplay", "bufferSize", "refCount", "contacts$", "asObservable", "organizationId$", "ngOnDestroy", "next", "complete", "participantDetails", "participantKey", "GlobalParticipantType", "GLOBAL_PARTICIPANT_TYPE_IAM_USER", "namespaceHierarchy", "buildNamespaceHierarchy", "getParticipantsByKey", "catchError", "err", "console", "error", "EMPTY", "resp", "defaultIfEmpty", "NamespaceDetail", "GLOBAL_PARTICIPANT_TYPE_PARTNER", "push", "GLOBAL_PARTICIPANT_TYPE_GROUP", "GLOBAL_PARTICIPANT_TYPE_ACCOUNT_GROUP", "buildIAMUserParticipant", "buildIamUser", "ParticipantType", "PARTICIPANT_TYPE_IAM_USER", "buildAccountGroup", "PARTICIPANT_TYPE_ACCOUNT_GROUP", "buildPartner", "PARTICIPANT_TYPE_PARTNER", "buildVendor", "vendorId", "PARTICIPANT_TYPE_VENDOR", "addContact", "contact", "createCrmContact", "of", "createContact", "namespace", "crmObject", "fields", "buildCrmFieldsForCreateContact", "crmObjectResponse", "contactId", "crmObjectId", "searchContacts", "term", "length", "getContactsFromCrmService", "take", "subscribe", "contactList", "listContacts", "search", "searchTerm", "pagingOptions", "pageSize", "CONTACTS_PAGE_SIZE", "response", "crmObjects", "filter", "getInboxContactFromCrm", "getMultiParticipants", "participantIds", "conversationId", "participants", "req", "message", "participantKeyInfo", "viewContact", "firestoreDocId", "__async", "openErrorSnack", "firstValueFrom", "returnUrl", "routeTemplate", "PAGE_ROUTES", "CONTACT", "ROOT", "SUBROUTES", "PROFILE", "navigate", "replace", "queryParams", "\u0275\u0275inject", "USER_ID_TOKEN", "PARTNER_ID_TOKEN", "ACCOUNT_GROUP_ID_TOKEN", "GROUP_ID_TOKEN", "ConversationApiService", "CRMApiService", "SnackbarService", "Router", "factory", "\u0275fac", "_ParticipantService", "isSuperAdminFn", "partner", "attributes", "boolAttribute", "InboxService", "constructor", "featureFlagService", "participantService", "accountGroupId$", "country$", "geographicalState$", "partnerId$", "platformLocation", "addressService", "smsEnabled$", "webChatEnabled$", "googleBusinessMessagesAvailable$", "userId$", "iamService", "inboxApiService", "groupId$", "unsubscribe$$", "Subject", "smsService", "isBusinessApp", "inject", "SmsService", "iamUser$", "pipe", "switchMap", "userId", "getUser", "canAccessEmbeddedSettings$", "combineLatest", "map", "user", "currentPartnerId", "isPartnerCenter", "partnerId", "userPartnerID", "roles", "isSuperAdmin", "shareReplay", "showAvailabilityMessageSettings$", "MARKETING_SERVICES_PIDS", "includes", "featureFlags$", "batchGetStatus", "INBOX_OPEN_DEFAULT", "INBOX_SMS_A2P", "WEBCHAT_SETTING_CARD", "MESSAGE_TEMPLATE_CARD", "WEB_CHAT_FOR_PARTNER_INBOX", "INBOX_EMAIL", "take", "partnerHasA2PAccess$", "res", "distinctUntilChanged", "SMSNumber$", "accountGroupId", "of", "getAccountInfo", "internalId", "type", "ParticipantType", "PARTICIPANT_TYPE_ACCOUNT_GROUP", "catchError", "error", "console", "message", "accountInfo", "phoneNumber", "hasAccessToInboxPage$", "CONVERSATION_CONFIG_TOKEN", "result", "allowSmbChatWithPartner$", "showInboxViews$", "canAccessInboxGetStartedCard$", "smsEnable", "googleBusinessMessagesEnable", "openInboxDefault$", "featureFlags", "isWideScreen", "canAccessWebChatSettings$", "webchatEnabled", "canAccessBA", "canAccessPCC", "canAccessEmailChannel$", "canAccessMessageTemplateSettingsCard$", "multiLocationEnabled$", "groupId", "configuration", "multiLocationEnabled", "getConfiguration", "subjectParticipant", "participantType", "GlobalParticipantType", "GLOBAL_PARTICIPANT_TYPE_GROUP", "internalParticipantId", "config", "canAccessSMS$", "hasAccessByCountry$", "geographicalState", "hasAccessByCountry", "hasAccessToInboxPage", "smsEnabled", "reauthorizeGoogleAccount", "canAccess$", "hasAccess", "accountGroupGeographicalState", "availableCountries", "accountGroupCountry", "country", "toLowerCase", "hasAccessByUSState", "isUsAccountWithSmsAccess$", "accountGroupState", "state", "getCountryConfiguration", "undefined", "countryInfo", "zones", "reduce", "accumulator", "currentValue", "EXCLUDED_GEOGRAPHICAL_US_STATES", "code", "toLocaleLowerCase", "PlatformLocation", "PLATFORM_LOCATION_BUSINESS_APP", "PLATFORM_LOCATION_PARTNER_CENTER", "isSalesCenter", "PLATFORM_LOCATION_SALES_CENTER", "displayA2pCard$", "__async", "firstValueFrom", "partnerHasA2PAccess", "buildTemplateTrackProperties", "participantName", "currentParticipant$", "name", "location", "buildAiKnowledgeAppConfigurationUrl", "widgetId", "buildAppId", "ngOnDestroy", "next", "complete", "\u0275\u0275inject", "FeatureFlagService", "ParticipantService", "ACCOUNT_GROUP_ID_TOKEN", "CONVERSATION_COUNTRY_TOKEN", "CONVERSATION_GEOGRAPHICAL_STATE_TOKEN", "PARTNER_ID_TOKEN", "CONVERSATION_PLATFORM_LOCATION_TOKEN", "AddressAPIService", "CONVERSATION_SMS_ENABLED_TOKEN", "CONVERSATION_WEB_CHAT_ENABLED_TOKEN", "CONVERSATION_GOOGLE_BUSINESS_MESSAGES_AVAILABLE_TOKEN", "USER_ID_TOKEN", "IAMService", "InboxApiService", "GROUP_ID_TOKEN", "factory", "\u0275fac", "_InboxService"] }