@seamly/web-ui 20.8.0-alpha.1 → 20.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/build/dist/lib/index.debug.js +46 -46
  2. package/build/dist/lib/index.debug.min.js +1 -1
  3. package/build/dist/lib/index.debug.min.js.LICENSE.txt +1 -1
  4. package/build/dist/lib/index.js +351 -260
  5. package/build/dist/lib/index.min.js +1 -1
  6. package/build/dist/lib/standalone.js +542 -252
  7. package/build/dist/lib/standalone.min.js +1 -1
  8. package/build/dist/lib/style-guide.js +156 -69
  9. package/build/dist/lib/style-guide.min.js +1 -1
  10. package/build/dist/lib/styles.css +1 -1
  11. package/package.json +1 -1
  12. package/src/javascripts/config.types.ts +1 -0
  13. package/src/javascripts/domains/config/slice.ts +2 -0
  14. package/src/javascripts/domains/i18n/slice.ts +0 -3
  15. package/src/javascripts/domains/store/slice.ts +16 -13
  16. package/src/javascripts/domains/store/store.types.ts +12 -1
  17. package/src/javascripts/domains/translations/hooks.ts +54 -48
  18. package/src/javascripts/domains/translations/selectors.ts +12 -0
  19. package/src/javascripts/domains/translations/slice.ts +70 -17
  20. package/src/javascripts/domains/translations/translations.types.ts +8 -1
  21. package/src/javascripts/schema.ts +3 -10
  22. package/src/javascripts/style-guide/components/app.js +2 -2
  23. package/src/javascripts/style-guide/states.js +61 -3
  24. package/src/javascripts/ui/components/conversation/conversation.js +7 -3
  25. package/src/javascripts/ui/components/conversation/event/card-message.js +1 -1
  26. package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +1 -1
  27. package/src/javascripts/ui/components/conversation/event/choice-prompt.js +1 -1
  28. package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +9 -2
  29. package/src/javascripts/ui/components/conversation/event/cta.js +1 -1
  30. package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +39 -3
  31. package/src/javascripts/ui/components/conversation/event/image.js +1 -1
  32. package/src/javascripts/ui/components/conversation/event/participant.js +1 -1
  33. package/src/javascripts/ui/components/conversation/event/splash.js +1 -1
  34. package/src/javascripts/ui/components/conversation/event/text.js +1 -1
  35. package/src/javascripts/ui/components/conversation/event/translation.js +1 -1
  36. package/src/javascripts/ui/components/conversation/event/upload.js +1 -1
  37. package/src/javascripts/ui/components/conversation/event/video.js +1 -1
  38. package/src/javascripts/ui/components/conversation/message-container.js +1 -23
  39. package/src/javascripts/ui/components/core/seamly-event-subscriber.js +3 -2
  40. package/src/javascripts/ui/components/faq/faq.js +3 -1
  41. package/src/javascripts/ui/components/options/options-button.js +3 -1
  42. package/src/javascripts/ui/components/suggestions/index.js +5 -2
  43. package/src/javascripts/ui/hooks/seamly-state-hooks.js +6 -0
  44. package/src/stylesheets/5-components/_message-carousel.scss +10 -8
  45. package/CHANGELOG.md +0 -987
  46. package/src/javascripts/domains/translations/selectors.js +0 -11
@@ -3055,13 +3055,14 @@ exports.initialConfigState = Object.assign(Object.assign({}, config_1.defaultCon
3055
3055
  connectWhenInView: true,
3056
3056
  showDisclaimer: false,
3057
3057
  showFaq: false,
3058
+ showSuggestions: true,
3058
3059
  customComponents: {},
3059
3060
  defaults: {
3060
3061
  visible: null
3061
3062
  },
3062
3063
  preChatEvents: []
3063
3064
  });
3064
- const configKeys = ['hideOnNoUserResponse', 'connectWhenInView', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon'];
3065
+ const configKeys = ['hideOnNoUserResponse', 'connectWhenInView', 'showDisclaimer', 'showFaq', 'showSuggestions', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon'];
3065
3066
 
3066
3067
  const updateState = (state, config) => {
3067
3068
  const _a = (0, general_utils_1.pick)(config, configKeys),
@@ -3368,11 +3369,9 @@ exports.Yh = exports._B = exports.W_ = void 0;
3368
3369
 
3369
3370
  const toolkit_1 = __webpack_require__(427);
3370
3371
 
3371
- const actions_1 = __webpack_require__(134);
3372
-
3373
- const actions_2 = __webpack_require__(915);
3372
+ const actions_1 = __webpack_require__(915);
3374
3373
 
3375
- const actions_3 = __webpack_require__(59);
3374
+ const actions_2 = __webpack_require__(59);
3376
3375
 
3377
3376
  const initialState = {
3378
3377
  translations: {
@@ -3410,15 +3409,11 @@ exports.W_ = (0, toolkit_1.createSlice)({
3410
3409
  },
3411
3410
  extraReducers: builder => {
3412
3411
  // Add reducers for additional action types here, and handle loading state as needed
3413
- builder.addCase(actions_2.initializeConfig.fulfilled, (state, {
3412
+ builder.addCase(actions_1.initializeConfig.fulfilled, (state, {
3414
3413
  payload
3415
3414
  }) => {
3416
3415
  state.initialLocale = payload.locale;
3417
- }).addCase(actions_1.initializeApp.fulfilled, (state, {
3418
- payload
3419
- }) => {
3420
- state.locale = payload.locale;
3421
- }).addCase(actions_3.setLocale.fulfilled, (state, {
3416
+ }).addCase(actions_2.setLocale.fulfilled, (state, {
3422
3417
  payload
3423
3418
  }) => {
3424
3419
  if (!(payload === null || payload === void 0 ? void 0 : payload.translations)) {
@@ -3489,15 +3484,14 @@ exports.ZP = exports.EC.reducer;
3489
3484
  /***/ 153:
3490
3485
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3491
3486
 
3492
- var __webpack_unused_export__;
3493
3487
 
3494
3488
 
3495
3489
  var _a;
3496
3490
 
3497
- __webpack_unused_export__ = ({
3491
+ Object.defineProperty(exports, "__esModule", ({
3498
3492
  value: true
3499
- });
3500
- __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = exports.To = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = exports.Zd = exports.dH = exports.NI = exports.Qv = void 0;
3493
+ }));
3494
+ exports.stopIdleDetachCountdownCounter = exports.showOption = exports.setUserSelectedOptions = exports.setUserSelectedOption = exports.setUserEntryType = exports.setUploadProgress = exports.setUploadError = exports.setUploadComplete = exports.setServiceEntryMetadata = exports.setServiceDataItem = exports.setSeamlyContainerElement = exports.setParticipant = exports.setLoadedImageEventIds = exports.setIsLoading = exports.setInitialState = exports.setHistory = exports.setHeaderTitle = exports.setHeaderSubTitle = exports.setFeatures = exports.setFeatureEnabledState = exports.setEventsRead = exports.setBlockAutoEntrySwitch = exports.setActiveService = exports.setActiveEntryType = exports.resetHistoryLoadedFlag = exports.registerUpload = exports.initResumeConversationPrompt = exports.initIdleDetachCountdown = exports.hideOption = exports.decrementIdleDetachCountdownCounter = exports.clearResumeConversationPrompt = exports.clearIdleDetachCountdown = exports.clearFeatures = exports.clearEvents = exports.clearAllUploads = exports.addEvent = exports.ackEvent = exports.storeSlice = exports.initialStoreState = exports.mergeHistory = exports.orderHistory = exports.isUnreadMessage = void 0;
3501
3495
 
3502
3496
  const toolkit_1 = __webpack_require__(427);
3503
3497
 
@@ -3516,7 +3510,7 @@ const isUnreadMessage = ({
3516
3510
  payload
3517
3511
  }) => type === seamly_utils_1.eventTypes.message && !payload.fromClient || type === seamly_utils_1.eventTypes.info && payload.type === seamly_utils_1.payloadTypes.text;
3518
3512
 
3519
- exports.Qv = isUnreadMessage;
3513
+ exports.isUnreadMessage = isUnreadMessage;
3520
3514
 
3521
3515
  const orderHistory = events => {
3522
3516
  return events.sort(({
@@ -3530,6 +3524,8 @@ const orderHistory = events => {
3530
3524
  }) => occurredAtA - occurredAtB);
3531
3525
  };
3532
3526
 
3527
+ exports.orderHistory = orderHistory;
3528
+
3533
3529
  const mergeHistory = (stateEvents, historyEvents) => {
3534
3530
  const newStateEvents = stateEvents.filter(stateEvent => // Deduplicate the event streams, giving events in historyEvents
3535
3531
  // precedence so the server is able to push changes to events.
@@ -3540,10 +3536,10 @@ const mergeHistory = (stateEvents, historyEvents) => {
3540
3536
  // these messages will be shown in the wrong order if not reversed. For
3541
3537
  // the normal merging logic there is no added effect.
3542
3538
  .reverse();
3543
- return orderHistory([...newHistoryEvents, ...newStateEvents]);
3539
+ return (0, exports.orderHistory)([...newHistoryEvents, ...newStateEvents]);
3544
3540
  };
3545
3541
 
3546
- exports.NI = mergeHistory;
3542
+ exports.mergeHistory = mergeHistory;
3547
3543
 
3548
3544
  const participantReducer = (participantInfo, action) => {
3549
3545
  // TODO: a) Styleguide only! b) Should be removed after styleguide overhaul.
@@ -3611,7 +3607,7 @@ const calculateNewEntryMeta = (entryMeta, channelEvent) => {
3611
3607
  });
3612
3608
  };
3613
3609
 
3614
- exports.dH = {
3610
+ exports.initialStoreState = {
3615
3611
  events: [],
3616
3612
  initialState: {
3617
3613
  userResponded: false
@@ -3663,9 +3659,9 @@ exports.dH = {
3663
3659
  },
3664
3660
  seamlyContainerElement: null
3665
3661
  };
3666
- exports.Zd = (0, toolkit_1.createSlice)({
3662
+ exports.storeSlice = (0, toolkit_1.createSlice)({
3667
3663
  name: 'store',
3668
- initialState: exports.dH,
3664
+ initialState: exports.initialStoreState,
3669
3665
  reducers: {
3670
3666
  addEvent: (state, action) => {
3671
3667
  var _a, _b;
@@ -3690,7 +3686,7 @@ exports.Zd = (0, toolkit_1.createSlice)({
3690
3686
  });
3691
3687
  }
3692
3688
 
3693
- const incrementUnread = (0, exports.Qv)(action.payload); // We check for duplicated and ignore them as in some error of the websocket
3689
+ const incrementUnread = (0, exports.isUnreadMessage)(action.payload); // We check for duplicated and ignore them as in some error of the websocket
3694
3690
  // a duplicate join can be active for a while until the server connection
3695
3691
  // times out.
3696
3692
 
@@ -3729,7 +3725,8 @@ exports.Zd = (0, toolkit_1.createSlice)({
3729
3725
  } = payload;
3730
3726
 
3731
3727
  if (matchedEvent) {
3732
- state.events = orderHistory(state.events.map(m => m.payload.id === matchedEvent.payload.id ? Object.assign(Object.assign({}, m), {
3728
+ state.events = (0, exports.orderHistory)( //@ts-ignore
3729
+ state.events.map(m => m.payload.id === matchedEvent.payload.id ? Object.assign(Object.assign({}, m), {
3733
3730
  payload: Object.assign(Object.assign({}, m.payload), {
3734
3731
  id,
3735
3732
  occurredAt
@@ -3773,7 +3770,7 @@ exports.Zd = (0, toolkit_1.createSlice)({
3773
3770
  }) => {
3774
3771
  var _a;
3775
3772
 
3776
- const events = (0, exports.NI)(state.events, history);
3773
+ const events = (0, exports.mergeHistory)(state.events, history);
3777
3774
  const mergedParticipants = Object.assign(Object.assign({}, state.participantInfo.participants), participants);
3778
3775
  const lastParticipantEvent = events.slice().reverse().find(m => (m.type === 'message' || m.type === 'participant') && !m.payload.fromClient);
3779
3776
  let lastParticipantId = null;
@@ -3789,9 +3786,11 @@ exports.Zd = (0, toolkit_1.createSlice)({
3789
3786
  }
3790
3787
 
3791
3788
  const {
3792
- entry,
3793
- uploads
3789
+ entry
3794
3790
  } = activeServiceSettings;
3791
+ const {
3792
+ upload
3793
+ } = entry.options;
3795
3794
  const historyNewEntryMeta = calculateNewEntryMeta(Object.assign(Object.assign(Object.assign({}, state.entryMeta), entry), {
3796
3795
  active: entry.default || seamly_utils_1.payloadTypes.text,
3797
3796
  options: Object.assign({}, entry && entry.options ? entry.options : {})
@@ -3806,7 +3805,7 @@ exports.Zd = (0, toolkit_1.createSlice)({
3806
3805
  const entryType = ((_a = lastParticipantEventPayload === null || lastParticipantEventPayload === void 0 ? void 0 : lastParticipantEventPayload.entry) === null || _a === void 0 ? void 0 : _a.type) || {};
3807
3806
  newFeatures = Object.assign(Object.assign({}, newFeatures), {
3808
3807
  uploads: {
3809
- enabled: !!(uploads && uploads.enabled),
3808
+ enabled: !!(upload && upload.enabled),
3810
3809
  enabledFromEntry: entryType === seamly_utils_1.entryTypes.upload
3811
3810
  }
3812
3811
  });
@@ -3894,8 +3893,8 @@ exports.Zd = (0, toolkit_1.createSlice)({
3894
3893
  setActiveService: (state, {
3895
3894
  payload
3896
3895
  }) => {
3897
- if (state.serviceInfo.activeServiceSessionId !== payload.activeServiceSessionId) {
3898
- state.serviceInfo.activeServiceSessionId = payload.activeServiceSessionId;
3896
+ if (state.serviceInfo.activeServiceSessionId !== payload) {
3897
+ state.serviceInfo.activeServiceSessionId = payload;
3899
3898
  }
3900
3899
  },
3901
3900
  setHeaderTitle: (state, {
@@ -3912,7 +3911,7 @@ exports.Zd = (0, toolkit_1.createSlice)({
3912
3911
  payload
3913
3912
  }) => {
3914
3913
  state.initialState = payload.initialState;
3915
- state.unreadEvents = exports.dH.unreadEvents;
3914
+ state.unreadEvents = exports.initialStoreState.unreadEvents;
3916
3915
  },
3917
3916
  setServiceDataItem: (state, {
3918
3917
  payload
@@ -4055,7 +4054,7 @@ exports.Zd = (0, toolkit_1.createSlice)({
4055
4054
  }
4056
4055
  },
4057
4056
  extraReducers: builder => {
4058
- builder.addCase(actions_1.resetApp.pending, () => exports.dH).addCase(actions_2.initializeConfig.fulfilled, (state, {
4057
+ builder.addCase(actions_1.resetApp.pending, () => exports.initialStoreState).addCase(actions_2.initializeConfig.fulfilled, (state, {
4059
4058
  payload
4060
4059
  }) => {
4061
4060
  var _a;
@@ -4071,8 +4070,8 @@ exports.Zd = (0, toolkit_1.createSlice)({
4071
4070
  });
4072
4071
  }
4073
4072
  });
4074
- _a = exports.Zd.actions, __webpack_unused_export__ = _a.ackEvent, __webpack_unused_export__ = _a.addEvent, __webpack_unused_export__ = _a.clearAllUploads, __webpack_unused_export__ = _a.clearEvents, __webpack_unused_export__ = _a.clearFeatures, __webpack_unused_export__ = _a.clearIdleDetachCountdown, __webpack_unused_export__ = _a.clearResumeConversationPrompt, __webpack_unused_export__ = _a.decrementIdleDetachCountdownCounter, __webpack_unused_export__ = _a.hideOption, __webpack_unused_export__ = _a.initIdleDetachCountdown, __webpack_unused_export__ = _a.initResumeConversationPrompt, __webpack_unused_export__ = _a.registerUpload, __webpack_unused_export__ = _a.resetHistoryLoadedFlag, __webpack_unused_export__ = _a.setActiveEntryType, __webpack_unused_export__ = _a.setActiveService, __webpack_unused_export__ = _a.setBlockAutoEntrySwitch, __webpack_unused_export__ = _a.setEventsRead, __webpack_unused_export__ = _a.setFeatureEnabledState, __webpack_unused_export__ = _a.setFeatures, __webpack_unused_export__ = _a.setHeaderSubTitle, __webpack_unused_export__ = _a.setHeaderTitle, __webpack_unused_export__ = _a.setHistory, __webpack_unused_export__ = _a.setInitialState, __webpack_unused_export__ = _a.setIsLoading, __webpack_unused_export__ = _a.setLoadedImageEventIds, exports.To = _a.setParticipant, __webpack_unused_export__ = _a.setSeamlyContainerElement, __webpack_unused_export__ = _a.setServiceDataItem, __webpack_unused_export__ = _a.setServiceEntryMetadata, __webpack_unused_export__ = _a.setUploadComplete, __webpack_unused_export__ = _a.setUploadError, __webpack_unused_export__ = _a.setUploadProgress, __webpack_unused_export__ = _a.setUserEntryType, __webpack_unused_export__ = _a.setUserSelectedOption, __webpack_unused_export__ = _a.setUserSelectedOptions, __webpack_unused_export__ = _a.showOption, __webpack_unused_export__ = _a.stopIdleDetachCountdownCounter;
4075
- exports.ZP = exports.Zd.reducer;
4073
+ _a = exports.storeSlice.actions, exports.ackEvent = _a.ackEvent, exports.addEvent = _a.addEvent, exports.clearAllUploads = _a.clearAllUploads, exports.clearEvents = _a.clearEvents, exports.clearFeatures = _a.clearFeatures, exports.clearIdleDetachCountdown = _a.clearIdleDetachCountdown, exports.clearResumeConversationPrompt = _a.clearResumeConversationPrompt, exports.decrementIdleDetachCountdownCounter = _a.decrementIdleDetachCountdownCounter, exports.hideOption = _a.hideOption, exports.initIdleDetachCountdown = _a.initIdleDetachCountdown, exports.initResumeConversationPrompt = _a.initResumeConversationPrompt, exports.registerUpload = _a.registerUpload, exports.resetHistoryLoadedFlag = _a.resetHistoryLoadedFlag, exports.setActiveEntryType = _a.setActiveEntryType, exports.setActiveService = _a.setActiveService, exports.setBlockAutoEntrySwitch = _a.setBlockAutoEntrySwitch, exports.setEventsRead = _a.setEventsRead, exports.setFeatureEnabledState = _a.setFeatureEnabledState, exports.setFeatures = _a.setFeatures, exports.setHeaderSubTitle = _a.setHeaderSubTitle, exports.setHeaderTitle = _a.setHeaderTitle, exports.setHistory = _a.setHistory, exports.setInitialState = _a.setInitialState, exports.setIsLoading = _a.setIsLoading, exports.setLoadedImageEventIds = _a.setLoadedImageEventIds, exports.setParticipant = _a.setParticipant, exports.setSeamlyContainerElement = _a.setSeamlyContainerElement, exports.setServiceDataItem = _a.setServiceDataItem, exports.setServiceEntryMetadata = _a.setServiceEntryMetadata, exports.setUploadComplete = _a.setUploadComplete, exports.setUploadError = _a.setUploadError, exports.setUploadProgress = _a.setUploadProgress, exports.setUserEntryType = _a.setUserEntryType, exports.setUserSelectedOption = _a.setUserSelectedOption, exports.setUserSelectedOptions = _a.setUserSelectedOptions, exports.showOption = _a.showOption, exports.stopIdleDetachCountdownCounter = _a.stopIdleDetachCountdownCounter;
4074
+ exports["default"] = exports.storeSlice.reducer;
4076
4075
 
4077
4076
  /***/ }),
4078
4077
 
@@ -4095,14 +4094,52 @@ const actions_1 = __webpack_require__(134);
4095
4094
 
4096
4095
  const actions_2 = __webpack_require__(915);
4097
4096
 
4097
+ const slice_1 = __webpack_require__(153);
4098
+
4098
4099
  exports.Z6 = {
4099
4100
  isActive: false,
4100
4101
  currentLocale: undefined,
4101
4102
  isAvailable: false,
4102
4103
  languages: [],
4103
- originalPayloadIds: [],
4104
- containerId: (0, toolkit_1.nanoid)()
4104
+ containerId: (0, toolkit_1.nanoid)(),
4105
+ translatedEventGroups: {}
4105
4106
  };
4107
+
4108
+ const getLastGroupId = (events, id) => {
4109
+ const eventGroup = [...events].reduce((acc, {
4110
+ payload
4111
+ }, _index, arr) => {
4112
+ var _a;
4113
+
4114
+ if (acc[id]) {
4115
+ // Splice to break early (make the reducer think we are done)
4116
+ // This is needed to avoid events of other groups from being added to the array.
4117
+ // @ts-ignore
4118
+ if ((payload === null || payload === void 0 ? void 0 : payload.type) === 'divider' && ((_a = payload === null || payload === void 0 ? void 0 : payload.body) === null || _a === void 0 ? void 0 : _a.translationEnabled)) {
4119
+ arr.splice(0);
4120
+ return acc;
4121
+ }
4122
+
4123
+ acc[id].push(payload.id);
4124
+ }
4125
+
4126
+ if (payload.id === id) acc[id] = [];
4127
+ return acc;
4128
+ }, {});
4129
+ const [[groupId, eventIds]] = Object.entries(eventGroup);
4130
+ const lastGroupId = events //@ts-ignore
4131
+ .filter(event => {
4132
+ var _a;
4133
+
4134
+ return ((_a = event.payload) === null || _a === void 0 ? void 0 : _a.type) === 'divider';
4135
+ }).map(event => event.payload.id).at(-1);
4136
+ return {
4137
+ lastGroupId,
4138
+ groupId,
4139
+ eventIds
4140
+ };
4141
+ };
4142
+
4106
4143
  exports.i$ = (0, toolkit_1.createSlice)({
4107
4144
  name: 'translation',
4108
4145
  initialState: exports.Z6,
@@ -4117,23 +4154,31 @@ exports.i$ = (0, toolkit_1.createSlice)({
4117
4154
  state.isActive = false;
4118
4155
  state.currentLocale = undefined;
4119
4156
  },
4120
- enableEvent: (state, {
4121
- payload
4122
- }) => {
4123
- if (!state.originalPayloadIds.includes(payload)) {
4124
- return;
4157
+ enableEventsTranslation: (state, {
4158
+ payload: {
4159
+ events,
4160
+ id
4125
4161
  }
4126
-
4127
- state.originalPayloadIds = state.originalPayloadIds.filter(id => id !== payload);
4128
- },
4129
- disableEvent: (state, {
4130
- payload
4131
4162
  }) => {
4132
- if (state.originalPayloadIds.includes(payload)) {
4133
- return;
4163
+ delete state.translatedEventGroups[id];
4164
+ const {
4165
+ lastGroupId
4166
+ } = getLastGroupId(events, id);
4167
+ state.lastGroupId = lastGroupId;
4168
+ },
4169
+ disableEventsTranslation: (state, {
4170
+ payload: {
4171
+ events,
4172
+ id
4134
4173
  }
4135
-
4136
- state.originalPayloadIds.push(payload);
4174
+ }) => {
4175
+ const {
4176
+ lastGroupId,
4177
+ groupId,
4178
+ eventIds
4179
+ } = getLastGroupId(events, id);
4180
+ state.lastGroupId = lastGroupId;
4181
+ state.translatedEventGroups[groupId] = eventIds;
4137
4182
  }
4138
4183
  },
4139
4184
  extraReducers: builder => {
@@ -4154,10 +4199,16 @@ exports.i$ = (0, toolkit_1.createSlice)({
4154
4199
  if (!feature) return;
4155
4200
  state.isAvailable = feature.enabled === true;
4156
4201
  state.languages = feature.languages;
4202
+ }).addCase(slice_1.addEvent, (state, {
4203
+ payload
4204
+ }) => {
4205
+ if (state.translatedEventGroups[state.lastGroupId]) {
4206
+ state.translatedEventGroups[state.lastGroupId].push(payload.payload.id);
4207
+ }
4157
4208
  });
4158
4209
  }
4159
4210
  });
4160
- _a = exports.i$.actions, __webpack_unused_export__ = _a.enableTranslation, __webpack_unused_export__ = _a.disableTranslation, __webpack_unused_export__ = _a.enableEvent, __webpack_unused_export__ = _a.disableEvent;
4211
+ _a = exports.i$.actions, __webpack_unused_export__ = _a.enableTranslation, __webpack_unused_export__ = _a.disableTranslation, __webpack_unused_export__ = _a.enableEventsTranslation, __webpack_unused_export__ = _a.disableEventsTranslation;
4161
4212
  exports.ZP = exports.i$.reducer;
4162
4213
 
4163
4214
  /***/ }),
@@ -4532,13 +4583,13 @@ class SeamlyBaseError extends Error {
4532
4583
 
4533
4584
  this.originalError = originalError;
4534
4585
 
4535
- if (originalError !== null && originalError !== void 0 && originalError.payload) {
4586
+ if (originalError?.payload) {
4536
4587
  this.originalEvent = originalError;
4537
4588
  this.originalError = originalError.payload.error;
4538
4589
  this.message = `Event of type ${originalError.payload.type} encountered`;
4539
4590
  }
4540
4591
 
4541
- if (originalError !== null && originalError !== void 0 && originalError.error) {
4592
+ if (originalError?.error) {
4542
4593
  this.originalError = originalError.error;
4543
4594
  }
4544
4595
  }
@@ -4741,7 +4792,7 @@ const SeamlyStaticCore = ({
4741
4792
 
4742
4793
  const newStore = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_11__.configureStore)({
4743
4794
  reducer: {
4744
- state: domains_store_slice__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP,
4795
+ state: domains_store_slice__WEBPACK_IMPORTED_MODULE_6__["default"],
4745
4796
  app: domains_app_slice__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .ZP,
4746
4797
  config: (domains_config_slice__WEBPACK_IMPORTED_MODULE_2___default()),
4747
4798
  i18n: domains_i18n_slice__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP,
@@ -4779,7 +4830,7 @@ const SeamlyStaticCore = ({
4779
4830
  newStore.dispatch((0,domains_i18n_slice__WEBPACK_IMPORTED_MODULE_4__/* .setInitialLocale */ ._B)('en-GB'));
4780
4831
  newStore.dispatch((0,domains_i18n_slice__WEBPACK_IMPORTED_MODULE_4__/* .setTranslations */ .Yh)(translations));
4781
4832
  participants.forEach(participant => {
4782
- newStore.dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_6__/* .setParticipant */ .To)({
4833
+ newStore.dispatch((0,domains_store_slice__WEBPACK_IMPORTED_MODULE_6__.setParticipant)({
4783
4834
  participant,
4784
4835
  fromClient: participant.id === 'user'
4785
4836
  }));
@@ -4900,7 +4951,8 @@ const baseState = {
4900
4951
  accountConfig: {},
4901
4952
  hideOnNoUserResponse: false,
4902
4953
  showFaq: false,
4903
- showDisclaimer: false
4954
+ showDisclaimer: false,
4955
+ showSuggestions: true
4904
4956
  },
4905
4957
  initialState: {},
4906
4958
  unreadEvents: 0,
@@ -5019,6 +5071,31 @@ const newTranslationDividerStart = {
5019
5071
  type: 'divider'
5020
5072
  }
5021
5073
  };
5074
+ const newTranslationDividerStartTwo = {
5075
+ type: 'info',
5076
+ payload: {
5077
+ body: {
5078
+ language: 'Nederlands',
5079
+ subtype: 'new_translation',
5080
+ text: '[NL] Automatic translation to Dutch started. Please note that automatic translations may contain errors.',
5081
+ translationEnabled: true,
5082
+ translationLocale: 'nl'
5083
+ },
5084
+ fromClient: false,
5085
+ fromHistory: true,
5086
+ id: (0,web_ui_.randomId)(),
5087
+ occurredAt: 1625658300534259,
5088
+ participant: null,
5089
+ service: {
5090
+ meta: {},
5091
+ name: null,
5092
+ serviceSessionId: null
5093
+ },
5094
+ transactionId: null,
5095
+ translatedBody: null,
5096
+ type: 'divider'
5097
+ }
5098
+ };
5022
5099
  const newTranslationDividerStop = {
5023
5100
  type: 'info',
5024
5101
  payload: {
@@ -5654,7 +5731,7 @@ const translationsSlice = {
5654
5731
  currentLocale: undefined,
5655
5732
  isAvailable: false,
5656
5733
  languages: [],
5657
- originalPayloadIds: [],
5734
+ translatedEventGroups: {},
5658
5735
  containerId: (0,web_ui_.randomId)()
5659
5736
  };
5660
5737
  const suggestions = [{
@@ -6549,11 +6626,19 @@ const standardState = {
6549
6626
  payload: states_objectSpread(states_objectSpread({}, choicePromptMessage.payload), {}, {
6550
6627
  id: `${choicePromptMessage.payload.id}XXX`
6551
6628
  })
6552
- }), longTextMessage, userMessage, textMessageBoldItalicUnderline, newTopicDivider, newTranslationDividerStart, newTranslationDividerStop, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage, newTranslationDividerStop, newTranslationDividerStart].map(addTranslationData),
6629
+ }), longTextMessage, userMessage, textMessageBoldItalicUnderline, newTopicDivider, newTranslationDividerStartTwo, newTranslationDividerStop, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage, newTranslationDividerStop].map(addTranslationData),
6553
6630
  translations: states_objectSpread(states_objectSpread({}, translationsSlice), {}, {
6554
6631
  currentLocale: 'nl',
6555
6632
  isActive: true,
6556
6633
  isAvailable: true,
6634
+ translatedEventGroups: {
6635
+ [newTranslationDividerStart.payload.id]: [infoMessage, shortTextMessage, states_objectSpread(states_objectSpread({}, choicePromptMessage), {}, {
6636
+ payload: states_objectSpread(states_objectSpread({}, choicePromptMessage.payload), {}, {
6637
+ id: `${choicePromptMessage.payload.id}XXX`
6638
+ })
6639
+ }), longTextMessage, userMessage, textMessageBoldItalicUnderline, newTopicDivider].map(p => p.payload.id),
6640
+ [newTranslationDividerStartTwo.payload.id]: [imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage].map(p => p.payload.id)
6641
+ },
6557
6642
  languages: [{
6558
6643
  locale: 'nl',
6559
6644
  nativeName: 'Dutch'
@@ -7076,7 +7161,8 @@ const StyleGuideApp = ({
7076
7161
  const bareState = mainState[feature][layoutMode];
7077
7162
  const {
7078
7163
  overrideMessages,
7079
- showFaq
7164
+ showFaq,
7165
+ showSuggestions
7080
7166
  } = bareState.config;
7081
7167
  const agent = participants.find(participant => participant.id === 'agent');
7082
7168
 
@@ -7087,10 +7173,11 @@ const StyleGuideApp = ({
7087
7173
  }, overrideMessages ? {
7088
7174
  messages: overrideMessages
7089
7175
  } : {}), {}, {
7090
- showFaq
7176
+ showFaq,
7177
+ showSuggestions
7091
7178
  }),
7092
7179
  headerTitles: app_objectSpread(app_objectSpread({}, bareState.headerTitles), {}, {
7093
- subTitle: (agent === null || agent === void 0 ? void 0 : agent.name) || bareState.headerTitles.subTitle
7180
+ subTitle: agent?.name || bareState.headerTitles.subTitle
7094
7181
  })
7095
7182
  });
7096
7183
 
@@ -7329,11 +7416,13 @@ function initializeStyleGuideExternalApi(appConfig, styleGuideConfig) {
7329
7416
 
7330
7417
  __webpack_require__.r(__webpack_exports__);
7331
7418
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7419
+ /* harmony export */ "selectEventIds": () => (/* binding */ selectEventIds),
7332
7420
  /* harmony export */ "selectEvents": () => (/* binding */ selectEvents),
7333
7421
  /* harmony export */ "selectEventsWithSuggestion": () => (/* binding */ selectEventsWithSuggestion),
7334
7422
  /* harmony export */ "selectState": () => (/* binding */ selectState),
7335
7423
  /* harmony export */ "useEntryTextLimit": () => (/* binding */ useEntryTextLimit),
7336
7424
  /* harmony export */ "useEvents": () => (/* binding */ useEvents),
7425
+ /* harmony export */ "useEventsIds": () => (/* binding */ useEventsIds),
7337
7426
  /* harmony export */ "useLastMessageEventId": () => (/* binding */ useLastMessageEventId),
7338
7427
  /* harmony export */ "useLoadedImageEventIds": () => (/* binding */ useLoadedImageEventIds),
7339
7428
  /* harmony export */ "useSeamlyCurrentAgent": () => (/* binding */ useSeamlyCurrentAgent),
@@ -7374,9 +7463,7 @@ const selectEventsWithSuggestion = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_
7374
7463
  events,
7375
7464
  serviceData
7376
7465
  }, config, hasUserResponded) => {
7377
- var _serviceData$suggesti;
7378
-
7379
- if (hasUserResponded || config.layoutMode === 'inline' || !(serviceData !== null && serviceData !== void 0 && serviceData.suggestion) || !(serviceData !== null && serviceData !== void 0 && (_serviceData$suggesti = serviceData.suggestion) !== null && _serviceData$suggesti !== void 0 && _serviceData$suggesti.body.length)) {
7466
+ if (hasUserResponded || config.layoutMode === 'inline' || !serviceData?.suggestion || !serviceData?.suggestion?.body.length) {
7380
7467
  return events;
7381
7468
  }
7382
7469
 
@@ -7387,12 +7474,10 @@ const selectEventsWithSuggestion = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_
7387
7474
  return [...events, suggestionsEvent];
7388
7475
  });
7389
7476
  const selectEvents = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_5__.createSelector)(selectEventsWithSuggestion, domains_config_selectors__WEBPACK_IMPORTED_MODULE_0__.selectConfig, (events, config) => {
7390
- var _config$messages;
7391
-
7392
7477
  const {
7393
7478
  enabled,
7394
7479
  threshold
7395
- } = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
7480
+ } = config?.messages?.timeIndicator ?? {};
7396
7481
 
7397
7482
  if (!enabled) {
7398
7483
  return events;
@@ -7418,6 +7503,10 @@ const selectEvents = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_5__.createSele
7418
7503
  return mappedEvents;
7419
7504
  });
7420
7505
  const useEvents = () => (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(selectEvents);
7506
+ const selectEventIds = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_5__.createSelector)(selectEvents, events => {
7507
+ return events.map(event => event.payload.id);
7508
+ });
7509
+ const useEventsIds = () => (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(selectEventIds);
7421
7510
  const useSeamlyIsLoading = () => useSeamlyStateContext().isLoading;
7422
7511
  const useSeamlyHeaderData = () => useSeamlyStateContext().headerTitles;
7423
7512
  const useSeamlyUnreadCount = () => useSeamlyStateContext().unreadEvents;
@@ -7426,10 +7515,8 @@ const useSkiplink = () => useSeamlyStateContext().skiplinkTargetId;
7426
7515
  const useSeamlyParticipant = participantId => useSeamlyStateContext().participantInfo.participants[participantId];
7427
7516
  const useSeamlyServiceInfo = () => useSeamlyStateContext().serviceInfo;
7428
7517
  const selectLastMessageEventId = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_5__.createSelector)(selectEvents, events => {
7429
- var _filteredEvents;
7430
-
7431
7518
  const filteredEvents = events.filter(event => event.type === 'message');
7432
- return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
7519
+ return filteredEvents[filteredEvents.length - 1]?.payload.id;
7433
7520
  });
7434
7521
  const useLastMessageEventId = () => (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(selectLastMessageEventId);
7435
7522
  const useSeamlyIsHistoryLoaded = () => useSeamlyStateContext().historyLoaded;