@seamly/web-ui 19.0.0-beta.2 → 19.1.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 (69) hide show
  1. package/build/dist/lib/index.debug.js +152 -64
  2. package/build/dist/lib/index.debug.min.js +1 -1
  3. package/build/dist/lib/index.debug.min.js.LICENSE.txt +40 -8
  4. package/build/dist/lib/index.js +595 -462
  5. package/build/dist/lib/index.min.js +1 -1
  6. package/build/dist/lib/standalone.js +716 -490
  7. package/build/dist/lib/standalone.min.js +1 -1
  8. package/build/dist/lib/storage.js +8 -1
  9. package/build/dist/lib/storage.min.js +1 -1
  10. package/build/dist/lib/style-guide.js +1920 -1814
  11. package/build/dist/lib/style-guide.min.js +1 -1
  12. package/package.json +1 -1
  13. package/src/javascripts/api/errors/seamly-base-error.js +10 -0
  14. package/src/javascripts/api/errors/seamly-configuration-error.js +4 -6
  15. package/src/javascripts/api/errors/seamly-general-error.js +4 -6
  16. package/src/javascripts/api/errors/seamly-offline-error.js +4 -6
  17. package/src/javascripts/api/errors/seamly-session-expired-error.js +4 -6
  18. package/src/javascripts/api/errors/seamly-unauthorized-error.js +4 -6
  19. package/src/javascripts/api/errors/seamly-unavailable-error.js +17 -0
  20. package/src/javascripts/api/index.js +10 -11
  21. package/src/javascripts/domains/app/actions.js +33 -24
  22. package/src/javascripts/domains/app/index.js +2 -1
  23. package/src/javascripts/domains/config/reducer.js +1 -0
  24. package/src/javascripts/domains/config/selectors.js +1 -1
  25. package/src/javascripts/domains/errors/index.js +32 -0
  26. package/src/javascripts/domains/i18n/actions.js +9 -24
  27. package/src/javascripts/domains/i18n/reducer.js +15 -3
  28. package/src/javascripts/domains/i18n/utils.js +2 -7
  29. package/src/javascripts/domains/interrupt/middleware.js +12 -9
  30. package/src/javascripts/domains/interrupt/reducer.js +10 -9
  31. package/src/javascripts/domains/store/index.js +7 -2
  32. package/src/javascripts/domains/store/state-reducer.js +10 -6
  33. package/src/javascripts/domains/visibility/actions.js +73 -0
  34. package/src/javascripts/domains/visibility/constants.js +8 -0
  35. package/src/javascripts/domains/visibility/hooks.js +24 -0
  36. package/src/javascripts/domains/visibility/index.js +8 -0
  37. package/src/javascripts/domains/visibility/reducer.js +19 -0
  38. package/src/javascripts/domains/visibility/selectors.js +9 -0
  39. package/src/javascripts/domains/visibility/utils.js +42 -0
  40. package/src/javascripts/index.js +3 -12
  41. package/src/javascripts/lib/engine/index.js +1 -0
  42. package/src/javascripts/lib/redux-helpers/index.js +45 -13
  43. package/src/javascripts/lib/store/providers/session-storage.js +6 -1
  44. package/src/javascripts/style-guide/components/app.js +1 -1
  45. package/src/javascripts/style-guide/components/static-core.js +6 -1
  46. package/src/javascripts/style-guide/states.js +48 -21
  47. package/src/javascripts/ui/components/conversation/conversation.js +2 -2
  48. package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +1 -8
  49. package/src/javascripts/ui/components/conversation/event/text.js +19 -13
  50. package/src/javascripts/ui/components/core/seamly-core.js +3 -0
  51. package/src/javascripts/ui/components/core/seamly-event-subscriber.js +3 -3
  52. package/src/javascripts/ui/components/core/seamly-initializer.js +2 -6
  53. package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +2 -3
  54. package/src/javascripts/ui/components/core/seamly-new-notifications.js +2 -2
  55. package/src/javascripts/ui/components/core/seamly-read-state.js +2 -2
  56. package/src/javascripts/ui/components/entry/toggle-button.js +2 -2
  57. package/src/javascripts/ui/components/layout/agent-info.js +2 -2
  58. package/src/javascripts/ui/components/layout/app-frame.js +2 -3
  59. package/src/javascripts/ui/components/layout/chat-frame.js +2 -2
  60. package/src/javascripts/ui/components/layout/modal-wrapper.js +3 -6
  61. package/src/javascripts/ui/components/layout/view.js +3 -6
  62. package/src/javascripts/ui/hooks/seamly-hooks.js +0 -2
  63. package/src/javascripts/ui/hooks/use-seamly-chat.js +3 -5
  64. package/src/javascripts/ui/hooks/use-seamly-commands.js +7 -29
  65. package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +2 -2
  66. package/src/javascripts/ui/utils/general-utils.js +0 -9
  67. package/src/javascripts/ui/utils/seamly-utils.js +0 -66
  68. package/src/javascripts/ui/hooks/use-seamly-stored-visibility.js +0 -31
  69. package/src/javascripts/ui/hooks/use-seamly-visibility.js +0 -98
@@ -9947,13 +9947,10 @@ __webpack_require__.d(__webpack_exports__, {
9947
9947
  "Interrupt": () => (/* reexport */ interrupt),
9948
9948
  "MessageContainer": () => (/* reexport */ message_container),
9949
9949
  "SeamlyApiContext": () => (/* reexport */ SeamlyApiContext),
9950
- "SeamlyConfigurationError": () => (/* reexport */ SeamlyConfigurationError),
9951
9950
  "SeamlyEventBusContext": () => (/* reexport */ SeamlyEventBusContext),
9952
9951
  "SeamlyGeneralError": () => (/* reexport */ SeamlyGeneralError),
9953
9952
  "SeamlyLiveRegionContext": () => (/* reexport */ SeamlyLiveRegionContext),
9954
9953
  "SeamlyOfflineError": () => (/* reexport */ SeamlyOfflineError),
9955
- "SeamlySessionExpiredError": () => (/* reexport */ SeamlySessionExpiredError),
9956
- "SeamlyUnauthorizedError": () => (/* reexport */ SeamlyUnauthorizedError),
9957
9954
  "StoreProvider": () => (/* reexport */ StoreProvider),
9958
9955
  "Text": () => (/* reexport */ event_text),
9959
9956
  "ToggleButton": () => (/* reexport */ toggle_button),
@@ -9979,7 +9976,7 @@ __webpack_require__.d(__webpack_exports__, {
9979
9976
  "useSeamlyIdleDetachCountdown": () => (/* reexport */ use_seamly_idle_detach_countdown),
9980
9977
  "useSeamlyMessageContainerClassNames": () => (/* reexport */ useSeamlyMessageContainerClassNames),
9981
9978
  "useSeamlyOptions": () => (/* reexport */ useSeamlyOptions),
9982
- "useSeamlyVisibility": () => (/* reexport */ use_seamly_visibility),
9979
+ "useSeamlyVisibility": () => (/* reexport */ useVisibility),
9983
9980
  "useTranslatedEventData": () => (/* reexport */ useTranslatedEventData),
9984
9981
  "useTranslations": () => (/* reexport */ useTranslations),
9985
9982
  "useTranslationsContainer": () => (/* reexport */ useTranslationsContainer),
@@ -12009,7 +12006,6 @@ const millisecondsToSeconds = milliseconds => {
12009
12006
  const microsecondsToMilliseconds = microseconds => {
12010
12007
  return Math.ceil(microseconds / 1000);
12011
12008
  };
12012
- const sanitizeText = text => text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/\//g, '&#x2F;');
12013
12009
  const getTimeFromSeconds = seconds => {
12014
12010
  const minutes = Math.floor(seconds / 60);
12015
12011
  const secondsPartial = seconds - minutes * 60;
@@ -12103,6 +12099,10 @@ const omit = (obj, keys) => Object.keys(obj).reduce((accum, key) => {
12103
12099
  if (!keys.includes(key)) accum[key] = obj[key];
12104
12100
  return accum;
12105
12101
  }, {});
12102
+ ;// CONCATENATED MODULE: ./src/javascripts/lib/id.js
12103
+ function randomId() {
12104
+ return '_' + (Number(String(Math.random()).slice(2)) + Date.now() + Math.round(performance.now())).toString(36);
12105
+ }
12106
12106
  ;// CONCATENATED MODULE: ./src/javascripts/lib/redux-helpers/index.js
12107
12107
  function redux_helpers_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12108
12108
 
@@ -12110,6 +12110,7 @@ function redux_helpers_objectSpread(target) { for (var i = 1; i < arguments.leng
12110
12110
 
12111
12111
  function redux_helpers_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12112
12112
 
12113
+
12113
12114
  const SLICE_DELIMITER = '/';
12114
12115
  const DOMAIN_DELIMITER = '//';
12115
12116
  function prefixType(prefix, fn, delimiter = '/') {
@@ -12122,7 +12123,9 @@ function createAction(type, identityReducer = payload => ({
12122
12123
  type
12123
12124
  }, identityReducer(...params));
12124
12125
 
12125
- action.toString = () => type.toString();
12126
+ action.toString = () => String(type);
12127
+
12128
+ action.match = obj => (obj === null || obj === void 0 ? void 0 : obj.type) === String(type);
12126
12129
 
12127
12130
  return action;
12128
12131
  }
@@ -12145,24 +12148,73 @@ function createActions(baseType, ...args) {
12145
12148
  const create = prefixType(baseType, createAction, SLICE_DELIMITER);
12146
12149
  return handlers.map(handler => create(...handler));
12147
12150
  }
12148
- function createThunk(type, thunkCreator) {
12149
- const fn = (...args) => {
12150
- const thunk = thunkCreator(...args);
12151
- thunk.type = type;
12152
- return thunk;
12153
- };
12151
+ function createThunk(type, payloadCreator) {
12152
+ const [pending, fulfilled, rejected] = createActions(type, {
12153
+ pending: (arg, requestId) => ({
12154
+ meta: {
12155
+ arg,
12156
+ requestId,
12157
+ status: 'pending'
12158
+ }
12159
+ }),
12160
+ fulfilled: (arg, payload, requestId) => ({
12161
+ payload,
12162
+ meta: {
12163
+ arg,
12164
+ requestId,
12165
+ status: 'fulfilled'
12166
+ }
12167
+ }),
12168
+ rejected: (arg, error, requestId) => ({
12169
+ error,
12170
+ meta: {
12171
+ arg,
12172
+ requestId,
12173
+ status: 'rejected',
12174
+ error: String(error)
12175
+ }
12176
+ })
12177
+ });
12178
+
12179
+ const thunkCreator = arg => (dispatch, getState, extra) => {
12180
+ const requestId = randomId();
12181
+
12182
+ const promise = (async () => {
12183
+ let finalAction;
12184
+
12185
+ try {
12186
+ dispatch(pending(arg, requestId));
12187
+ const prms = payloadCreator(arg, {
12188
+ dispatch,
12189
+ getState,
12190
+ extra
12191
+ });
12192
+ const result = await prms;
12193
+ finalAction = fulfilled(arg, result, requestId);
12194
+ } catch (error) {
12195
+ finalAction = rejected(arg, error, requestId);
12196
+ }
12197
+
12198
+ dispatch(finalAction);
12199
+ return finalAction;
12200
+ })();
12154
12201
 
12155
- fn.toString = () => type;
12202
+ return Object.assign(promise, {
12203
+ type,
12204
+ arg,
12205
+ requestId
12206
+ });
12207
+ };
12156
12208
 
12157
- return fn;
12209
+ return Object.assign(thunkCreator, {
12210
+ type,
12211
+ pending,
12212
+ fulfilled,
12213
+ rejected
12214
+ });
12158
12215
  }
12159
12216
  function createReducer(domain, handlers = {}, defaultState) {
12160
- const reducer = (state, action) => {
12161
- if (state === undefined) {
12162
- // eslint-disable-next-line no-param-reassign
12163
- state = defaultState;
12164
- }
12165
-
12217
+ const reducer = (state = defaultState, action) => {
12166
12218
  const typeReducer = handlers === null || handlers === void 0 ? void 0 : handlers[action === null || action === void 0 ? void 0 : action.type];
12167
12219
  return typeReducer ? typeReducer(state, action) : state;
12168
12220
  };
@@ -12196,6 +12248,45 @@ const initialize = utils_createAction('initialize', config => ({
12196
12248
  const update = utils_createAction('update', config => ({
12197
12249
  config
12198
12250
  }));
12251
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/constants.js
12252
+ const StoreKey = 'visibility';
12253
+ const visibilityStates = {
12254
+ hidden: 'hidden',
12255
+ minimized: 'minimized',
12256
+ open: 'open',
12257
+ initialize: null
12258
+ };
12259
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/config/selectors.js
12260
+ function selectors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12261
+
12262
+ function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_ownKeys(Object(source), true).forEach(function (key) { selectors_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12263
+
12264
+ function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12265
+
12266
+
12267
+
12268
+
12269
+ const selectConfig = createSelector(selectState, config => {
12270
+ let newConfig = selectors_objectSpread({
12271
+ visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? visibilityStates.open : visibilityStates.minimized,
12272
+ appContainerClassNames: config.appContainerClassNames || []
12273
+ }, config);
12274
+
12275
+ if (typeof newConfig.appContainerClassNames === 'function') {
12276
+ newConfig = selectors_objectSpread(selectors_objectSpread({}, newConfig), {}, {
12277
+ appContainerClassNames: newConfig.appContainerClassNames(newConfig)
12278
+ });
12279
+ }
12280
+
12281
+ return newConfig;
12282
+ });
12283
+
12284
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/config/hooks.js
12285
+
12286
+
12287
+ function useConfig() {
12288
+ return useSelector(selectConfig);
12289
+ }
12199
12290
  ;// CONCATENATED MODULE: ./src/javascripts/ui/utils/seamly-utils.js
12200
12291
  function seamly_utils_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12201
12292
 
@@ -12227,12 +12318,6 @@ const entryTypes = {
12227
12318
  text: 'text',
12228
12319
  upload: 'upload'
12229
12320
  };
12230
- const visibilityStates = {
12231
- hidden: 'hidden',
12232
- minimized: 'minimized',
12233
- open: 'open',
12234
- initialize: null
12235
- };
12236
12321
  const readStates = {
12237
12322
  received: 'received',
12238
12323
  read: 'read'
@@ -12279,7 +12364,6 @@ const seamlyActions = {
12279
12364
  SET_PARTICIPANT: 'SET_PARTICIPANT',
12280
12365
  SET_HEADER_TITLE: 'SET_HEADER_TITLE',
12281
12366
  SET_HEADER_SUB_TITLE: 'SET_HEADER_SUB_TITLE',
12282
- SET_VISIBILITY: 'SET_VISIBILITY',
12283
12367
  RESET_HISTORY_LOADED_FLAG: 'RESET_HISTORY_LOADED_FLAG',
12284
12368
  SET_ACTIVE_SERVICE: 'SET_ACTIVE_SERVICE',
12285
12369
  INIT_IDLE_DETACH_COUNTDOWN: 'INIT_IDLE_DETACH_COUNTDOWN',
@@ -12307,8 +12391,6 @@ const seamlyActions = {
12307
12391
  SET_UPLOAD_ERROR: 'SET_UPLOAD_ERROR',
12308
12392
  CLEAR_UPLOAD: 'CLEAR_UPLOAD',
12309
12393
  CLEAR_ALL_UPLOADS: 'CLEAR_ALL_UPLOADS',
12310
- RESET_UPLOAD_STATE: 'RESET_UPLOAD_STATE',
12311
- RESET_ENTRY_STATE: 'RESET_ENTRY_STATE',
12312
12394
  SET_SEAMLY_CONTAINER_ELEMENT: 'SET_SEAMLY_CONTAINER_ELEMENT'
12313
12395
  };
12314
12396
  const cardTypes = {
@@ -12327,7 +12409,6 @@ const {
12327
12409
  SET_PARTICIPANT,
12328
12410
  SET_HEADER_TITLE,
12329
12411
  SET_HEADER_SUB_TITLE,
12330
- SET_VISIBILITY,
12331
12412
  RESET_HISTORY_LOADED_FLAG,
12332
12413
  SET_ACTIVE_SERVICE,
12333
12414
  INIT_IDLE_DETACH_COUNTDOWN,
@@ -12355,8 +12436,6 @@ const {
12355
12436
  SET_UPLOAD_ERROR,
12356
12437
  CLEAR_UPLOAD,
12357
12438
  CLEAR_ALL_UPLOADS,
12358
- RESET_UPLOAD_STATE,
12359
- RESET_ENTRY_STATE,
12360
12439
  SET_SEAMLY_CONTAINER_ELEMENT
12361
12440
  } = seamlyActions;
12362
12441
  const isUnreadMessage = ({
@@ -12735,11 +12814,6 @@ const seamlyStateReducer = (state, action) => {
12735
12814
  resumeConversationPrompt: false
12736
12815
  });
12737
12816
 
12738
- case SET_VISIBILITY:
12739
- return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
12740
- visible: action.visible
12741
- });
12742
-
12743
12817
  case SET_PARTICIPANT:
12744
12818
  case CLEAR_PARTICIPANTS:
12745
12819
  return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
@@ -12947,26 +13021,6 @@ const seamlyStateReducer = (state, action) => {
12947
13021
  currentUploads: []
12948
13022
  });
12949
13023
 
12950
- case RESET_UPLOAD_STATE:
12951
- return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
12952
- showFileUpload: false,
12953
- currentUploads: []
12954
- });
12955
-
12956
- case RESET_ENTRY_STATE:
12957
- {
12958
- return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
12959
- entryMeta: {
12960
- default: payloadTypes.text,
12961
- active: payloadTypes.text,
12962
- userSelected: null,
12963
- blockAutoEntrySwitch: false,
12964
- options: {},
12965
- optionsOverride: {}
12966
- }
12967
- });
12968
- }
12969
-
12970
13024
  case SET_SEAMLY_CONTAINER_ELEMENT:
12971
13025
  {
12972
13026
  return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
@@ -12978,59 +13032,6 @@ const seamlyStateReducer = (state, action) => {
12978
13032
  return state;
12979
13033
  }
12980
13034
  };
12981
- const calculateVisibility = ({
12982
- hasResponded,
12983
- previousVisibility,
12984
- requestedVisibility,
12985
- config
12986
- }) => {
12987
- const {
12988
- defaults,
12989
- layoutMode,
12990
- hideOnNoUserResponse
12991
- } = config;
12992
- const {
12993
- visible: defaultVisibility
12994
- } = defaults || {}; // Requesting open should override the responded check.
12995
-
12996
- if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
12997
- return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
12998
- }
12999
-
13000
- const baseVisibility = layoutMode === 'inline' ? visibilityStates.open : visibilityStates.minimized;
13001
- return requestedVisibility || previousVisibility || defaultVisibility || baseVisibility;
13002
- };
13003
- ;// CONCATENATED MODULE: ./src/javascripts/domains/config/selectors.js
13004
- function selectors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13005
-
13006
- function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_ownKeys(Object(source), true).forEach(function (key) { selectors_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13007
-
13008
- function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13009
-
13010
-
13011
-
13012
-
13013
- const selectConfig = createSelector(selectState, config => {
13014
- let newConfig = selectors_objectSpread({
13015
- visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? visibilityStates.open : visibilityStates.minimized,
13016
- appContainerClassNames: config.appContainerClassNames || []
13017
- }, config);
13018
-
13019
- if (typeof newConfig.appContainerClassNames === 'function') {
13020
- newConfig = selectors_objectSpread(selectors_objectSpread({}, newConfig), {}, {
13021
- appContainerClassNames: newConfig.appContainerClassNames(newConfig)
13022
- });
13023
- }
13024
-
13025
- return newConfig;
13026
- });
13027
-
13028
- ;// CONCATENATED MODULE: ./src/javascripts/domains/config/hooks.js
13029
-
13030
-
13031
- function useConfig() {
13032
- return useSelector(selectConfig);
13033
- }
13034
13035
  ;// CONCATENATED MODULE: ./src/javascripts/domains/config/middleware.js
13035
13036
 
13036
13037
 
@@ -13123,7 +13124,7 @@ const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig
13123
13124
  defaults: {}
13124
13125
  });
13125
13126
 
13126
- const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback'];
13127
+ const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback'];
13127
13128
 
13128
13129
  const updateState = (state, {
13129
13130
  config
@@ -13387,7 +13388,6 @@ function createMutex() {
13387
13388
 
13388
13389
  const {
13389
13390
  createAction: i18n_utils_createAction,
13390
- createActions: utils_createActions,
13391
13391
  createThunk: i18n_utils_createThunk,
13392
13392
  createReducer: i18n_utils_createReducer,
13393
13393
  selectState: utils_selectState
@@ -13406,38 +13406,19 @@ const selectLocale = createSelector(utils_selectState, state => state.locale);
13406
13406
  const setInitialLocale = i18n_utils_createAction('setInitialLocale', locale => ({
13407
13407
  locale
13408
13408
  }));
13409
- const [setLocaleStart, setLocaleResolve, setLocaleReject] = utils_createActions('setLocale', {
13410
- start: locale => ({
13411
- locale
13412
- }),
13413
- resolve: (locale, translations) => ({
13414
- locale,
13415
- translations
13416
- }),
13417
- reject: (locale, error) => ({
13418
- locale,
13419
- error
13420
- })
13421
- });
13422
13409
  const mutex = createMutex();
13423
- const setLocale = i18n_utils_createThunk('setLocale', locale => async (dispatch, getState, {
13424
- api
13410
+ const setLocale = i18n_utils_createThunk('setLocale', async (locale, {
13411
+ getState,
13412
+ extra: {
13413
+ api
13414
+ }
13425
13415
  }) => {
13426
- await mutex.runExclusively(async () => {
13427
- const currentLocale = selectLocale(getState());
13428
-
13429
- if (currentLocale === locale) {
13430
- return;
13416
+ return mutex.runExclusively(() => {
13417
+ if (locale === selectLocale(getState())) {
13418
+ return undefined;
13431
13419
  }
13432
13420
 
13433
- dispatch(setLocaleStart(locale));
13434
-
13435
- try {
13436
- const translations = await api.getTranslations(locale);
13437
- dispatch(setLocaleResolve(locale, translations));
13438
- } catch (error) {
13439
- dispatch(setLocaleReject(locale, error));
13440
- }
13421
+ return api.getTranslations(locale);
13441
13422
  });
13442
13423
  });
13443
13424
  ;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
@@ -14163,7 +14144,11 @@ const defaultState = {
14163
14144
  'errors.general.title': 'Something went wrong',
14164
14145
  'errors.seamlyOffline.message': 'There might be a problem with your or our network connection. The chat session should resume as soon the connection is available again.',
14165
14146
  'errors.seamlyOffline.srText': 'The chat has connection issues. There might be a problem with your or our network connection. The chat session should resume as soon as the connection is available again.',
14166
- 'errors.seamlyOffline.title': 'Connection issues'
14147
+ 'errors.seamlyOffline.title': 'Connection issues',
14148
+ 'errors.seamlyUnavailable.buttonText': 'Try again',
14149
+ 'errors.seamlyUnavailable.message': 'The server could not be reached. Try again in a little while.',
14150
+ 'errors.seamlyUnavailable.srText': 'The chat server could not be reached. Try again in a little while.',
14151
+ 'errors.seamlyUnavailable.title': 'Server unavailable'
14167
14152
  },
14168
14153
  isLoading: false,
14169
14154
  initialLocale: undefined
@@ -14174,13 +14159,21 @@ const defaultState = {
14174
14159
  }) => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14175
14160
  initialLocale: locale
14176
14161
  }),
14177
- [setLocaleStart]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14162
+ [setLocale.pending]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14178
14163
  isLoading: true
14179
14164
  }),
14180
- [setLocaleResolve]: (state, {
14181
- locale,
14182
- translations
14165
+ [setLocale.fulfilled]: (state, {
14166
+ payload: translations,
14167
+ meta: {
14168
+ arg: locale
14169
+ }
14183
14170
  }) => {
14171
+ if (!translations) {
14172
+ return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14173
+ isLoading: false
14174
+ });
14175
+ }
14176
+
14184
14177
  return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14185
14178
  isLoading: false,
14186
14179
  locale,
@@ -14189,7 +14182,7 @@ const defaultState = {
14189
14182
  }), {})
14190
14183
  });
14191
14184
  },
14192
- [setLocaleReject]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14185
+ [setLocale.rejected]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
14193
14186
  isLoading: false
14194
14187
  })
14195
14188
  }, defaultState));
@@ -14402,10 +14395,6 @@ const useFileUploads = () => {
14402
14395
  isComplete: currentUploads.every(file => file.complete)
14403
14396
  };
14404
14397
  };
14405
- ;// CONCATENATED MODULE: ./src/javascripts/lib/id.js
14406
- function randomId() {
14407
- return '_' + (Number(String(Math.random()).slice(2)) + Date.now() + Math.round(performance.now())).toString(36);
14408
- }
14409
14398
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/utility-hooks.js
14410
14399
 
14411
14400
 
@@ -14498,15 +14487,24 @@ function useInterrupt() {
14498
14487
  error
14499
14488
  };
14500
14489
  }
14501
- ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-general-error.js
14502
- class SeamlyGeneralError extends Error {
14503
- constructor(params) {
14504
- super(params);
14490
+ ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-base-error.js
14491
+ class SeamlyBaseError extends Error {
14492
+ constructor(originalError, ...params) {
14493
+ super(...params);
14505
14494
 
14506
14495
  if (Error.captureStackTrace) {
14507
- Error.captureStackTrace(this, SeamlyGeneralError);
14496
+ Error.captureStackTrace(this, Object.getPrototypeOf(this));
14508
14497
  }
14509
14498
 
14499
+ this.originalError = originalError;
14500
+ }
14501
+
14502
+ }
14503
+ ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-general-error.js
14504
+
14505
+ class SeamlyGeneralError extends SeamlyBaseError {
14506
+ constructor(originalError, ...params) {
14507
+ super(originalError, ...params);
14510
14508
  this.name = 'SeamlyGeneralError';
14511
14509
  this.langKey = 'errors.general';
14512
14510
  this.action = 'reset';
@@ -14514,59 +14512,62 @@ class SeamlyGeneralError extends Error {
14514
14512
 
14515
14513
  }
14516
14514
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-configuration-error.js
14517
- class SeamlyConfigurationError extends Error {
14518
- constructor(params) {
14519
- super(params);
14520
-
14521
- if (Error.captureStackTrace) {
14522
- Error.captureStackTrace(this, SeamlyConfigurationError);
14523
- }
14524
14515
 
14516
+ class SeamlyConfigurationError extends SeamlyBaseError {
14517
+ constructor(originalError, ...params) {
14518
+ super(originalError, ...params);
14525
14519
  this.name = 'SeamlyConfigurationError';
14526
14520
  this.langKey = 'errors.configError';
14527
14521
  }
14528
14522
 
14529
14523
  }
14530
14524
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-session-expired-error.js
14531
- class SeamlySessionExpiredError extends Error {
14532
- constructor(params) {
14533
- super(params);
14534
-
14535
- if (Error.captureStackTrace) {
14536
- Error.captureStackTrace(this, SeamlySessionExpiredError);
14537
- }
14538
14525
 
14526
+ class SeamlySessionExpiredError extends SeamlyBaseError {
14527
+ constructor(originalError, ...params) {
14528
+ super(originalError, ...params);
14539
14529
  this.name = 'SeamlySessionExpiredError';
14540
14530
  this.action = 'reset';
14541
14531
  }
14542
14532
 
14543
14533
  }
14544
14534
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-offline-error.js
14545
- class SeamlyOfflineError extends Error {
14546
- constructor(params) {
14547
- super(params);
14548
-
14549
- if (Error.captureStackTrace) {
14550
- Error.captureStackTrace(this, SeamlyOfflineError);
14551
- }
14552
14535
 
14536
+ class SeamlyOfflineError extends SeamlyBaseError {
14537
+ constructor(originalError, ...params) {
14538
+ super(originalError, ...params);
14553
14539
  this.name = 'SeamlyOfflineError';
14554
14540
  this.langKey = 'errors.seamlyOffline';
14555
14541
  }
14556
14542
 
14557
14543
  }
14558
14544
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-unauthorized-error.js
14559
- class SeamlyUnauthorizedError extends Error {
14545
+
14546
+ class SeamlyUnauthorizedError extends SeamlyBaseError {
14547
+ constructor(originalError, ...params) {
14548
+ super(originalError, ...params);
14549
+ this.name = 'SeamlyUnauthorizedError';
14550
+ this.langKey = 'errors.general';
14551
+ this.action = 'reset';
14552
+ }
14553
+
14554
+ }
14555
+ ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-unavailable-error.js
14556
+ /**
14557
+ * This error is used to alert the user that there's a problem with the connection
14558
+ * when initialising the application because of a connection issue on either the server
14559
+ * or the client side.
14560
+ */
14561
+ class SeamlyUnavailableError extends Error {
14560
14562
  constructor(params) {
14561
14563
  super(params);
14562
14564
 
14563
14565
  if (Error.captureStackTrace) {
14564
- Error.captureStackTrace(this, SeamlyUnauthorizedError);
14566
+ Error.captureStackTrace(this, SeamlyUnavailableError);
14565
14567
  }
14566
14568
 
14567
- this.name = 'SeamlyUnauthorizedError';
14568
- this.langKey = 'errors.general';
14569
- this.action = 'reset';
14569
+ this.name = 'SeamlyUnavailableError';
14570
+ this.langKey = 'errors.seamlyUnavailable';
14570
14571
  }
14571
14572
 
14572
14573
  }
@@ -14577,73 +14578,192 @@ class SeamlyUnauthorizedError extends Error {
14577
14578
 
14578
14579
 
14579
14580
 
14580
- const handledErrorTypes = [SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError];
14581
- function middleware_createMiddleware() {
14581
+ const handledErrorTypes = [SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError, SeamlyUnavailableError];
14582
+ function middleware_createMiddleware({
14583
+ api
14584
+ }) {
14582
14585
  return () => next => action => {
14583
- if (action.type === String(set)) {
14584
- if (!handledErrorTypes.some(ErrorType => action.error instanceof ErrorType)) {
14585
- throw action.error;
14586
+ const {
14587
+ error
14588
+ } = action;
14589
+
14590
+ if (error) {
14591
+ if (!handledErrorTypes.some(ErrorType => error instanceof ErrorType)) {
14592
+ throw error;
14593
+ } else if (error.action === 'reset') {
14594
+ // [SMLY-942] We clear the store before a reset to force a new conversation if the page is refreshed before the conversation is reset
14595
+ api.disconnect().then(() => {
14596
+ api.clearStore();
14597
+ });
14586
14598
  }
14587
14599
  }
14588
14600
 
14589
14601
  return next(action);
14590
14602
  };
14591
14603
  }
14592
- ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/reducer.js
14593
- function interrupt_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14604
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/app/utils.js
14594
14605
 
14595
- function interrupt_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { interrupt_reducer_ownKeys(Object(source), true).forEach(function (key) { interrupt_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { interrupt_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14606
+ const {
14607
+ createAction: app_utils_createAction,
14608
+ createThunk: app_utils_createThunk,
14609
+ createReducer: app_utils_createReducer,
14610
+ selectState: app_utils_selectState
14611
+ } = createDomain('app');
14612
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/app/selectors.js
14596
14613
 
14597
- function interrupt_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14598
14614
 
14615
+ const selectUserHasResponded = createSelector(app_utils_selectState, state => state.userHasResponded);
14599
14616
 
14617
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/utils.js
14600
14618
 
14601
- const reducer_initialState = {
14602
- error: undefined
14619
+
14620
+ const {
14621
+ createAction: visibility_utils_createAction,
14622
+ createActions: utils_createActions,
14623
+ createThunk: visibility_utils_createThunk,
14624
+ createReducer: visibility_utils_createReducer,
14625
+ selectState: visibility_utils_selectState
14626
+ } = createDomain('visibility');
14627
+ const calculateVisibility = ({
14628
+ hasResponded,
14629
+ previousVisibility,
14630
+ requestedVisibility,
14631
+ config
14632
+ }) => {
14633
+ const {
14634
+ defaults,
14635
+ layoutMode,
14636
+ hideOnNoUserResponse
14637
+ } = config;
14638
+ const {
14639
+ visible: defaultVisibility
14640
+ } = defaults || {}; // Requesting open should override the responded check.
14641
+
14642
+ if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
14643
+ return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
14644
+ }
14645
+
14646
+ const baseVisibility = layoutMode === 'inline' ? visibilityStates.open : visibilityStates.minimized;
14647
+ return requestedVisibility || previousVisibility || defaultVisibility || baseVisibility;
14603
14648
  };
14604
- /* harmony default export */ const interrupt_reducer = (interrupt_utils_createReducer({
14605
- [set]: (state, {
14606
- error
14607
- }) => {
14608
- return interrupt_reducer_objectSpread(interrupt_reducer_objectSpread({}, state), {}, {
14609
- error
14610
- });
14611
- },
14612
- [clear]: () => {
14613
- return reducer_initialState;
14649
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/selectors.js
14650
+
14651
+
14652
+ const selectVisibility = createSelector(visibility_utils_selectState, state => state.visibility);
14653
+
14654
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/actions.js
14655
+ function actions_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14656
+
14657
+ function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { actions_ownKeys(Object(source), true).forEach(function (key) { actions_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { actions_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14658
+
14659
+ function actions_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14660
+
14661
+
14662
+
14663
+
14664
+
14665
+
14666
+
14667
+ const setFromStorage = visibility_utils_createAction('setFromStorage', visibility => ({
14668
+ visibility
14669
+ }));
14670
+ const validVisibilityStates = [visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden];
14671
+ const actions_setVisibility = visibility_utils_createThunk('set', (requestedVisibility, {
14672
+ getState,
14673
+ extra: {
14674
+ api,
14675
+ eventBus
14614
14676
  }
14615
- }, reducer_initialState));
14616
- ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/index.js
14677
+ }) => {
14678
+ const state = getState();
14679
+ const previousVisibility = selectVisibility(state);
14680
+ const hasResponded = selectUserHasResponded(state);
14681
+ const hasConversation = api.hasConversation();
14682
+ const config = selectConfig(state);
14683
+ const {
14684
+ visibilityCallback = calculateVisibility,
14685
+ layoutMode
14686
+ } = config;
14687
+ const {
14688
+ unreadEvents: unreadMessageCount
14689
+ } = seamly_state_hooks_selectState(state);
14690
+ const calculatedVisibility = visibilityCallback({
14691
+ hasConversation,
14692
+ hasResponded,
14693
+ previousVisibility,
14694
+ requestedVisibility,
14695
+ config
14696
+ });
14617
14697
 
14698
+ if (!validVisibilityStates.includes(calculatedVisibility)) {
14699
+ console.error('The visibilityCallback function should return "open", "minimized" or "hidden".');
14700
+ return undefined;
14701
+ }
14618
14702
 
14703
+ if (previousVisibility === calculatedVisibility) {
14704
+ return undefined;
14705
+ } // Store the user-requested visibility in order to reinitialize after refresh
14619
14706
 
14620
14707
 
14708
+ api.store.set(StoreKey, actions_objectSpread(actions_objectSpread({}, api.store.get(StoreKey) || {}), {}, {
14709
+ [layoutMode]: requestedVisibility
14710
+ }));
14621
14711
 
14712
+ if (requestedVisibility) {
14713
+ eventBus.emit('ui.visible', requestedVisibility, {
14714
+ visibility: requestedVisibility,
14715
+ hasConversation,
14716
+ hasResponded,
14717
+ unreadMessageCount
14718
+ });
14719
+ }
14622
14720
 
14623
- ;// CONCATENATED MODULE: ./src/javascripts/domains/app/utils.js
14721
+ return calculatedVisibility;
14722
+ });
14723
+ const actions_initialize = visibility_utils_createThunk('initialize', async (locale, {
14724
+ dispatch,
14725
+ getState,
14726
+ extra: {
14727
+ api
14728
+ }
14729
+ }) => {
14730
+ var _api$store$get;
14624
14731
 
14625
- const {
14626
- createAction: app_utils_createAction,
14627
- createThunk: app_utils_createThunk,
14628
- createReducer: app_utils_createReducer,
14629
- selectState: app_utils_selectState
14630
- } = createDomain('app');
14732
+ // initialize stored visibility
14733
+ const {
14734
+ layoutMode
14735
+ } = selectConfig(getState());
14736
+ const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
14737
+
14738
+ if (storedVisibility) {
14739
+ dispatch(setFromStorage(storedVisibility));
14740
+ }
14741
+
14742
+ dispatch(actions_setVisibility(visibilityStates.initialize));
14743
+ });
14631
14744
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/actions.js
14632
14745
 
14633
14746
 
14634
14747
 
14635
14748
 
14636
14749
 
14750
+
14751
+
14637
14752
  const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
14638
14753
  hasResponded
14639
14754
  }));
14640
- const actions_initialize = app_utils_createThunk('initialize', config => async (dispatch, getState, {
14641
- api
14755
+ const app_actions_initialize = app_utils_createThunk('initialize', async (config, {
14756
+ dispatch,
14757
+ extra: {
14758
+ api
14759
+ }
14642
14760
  }) => {
14643
- try {
14644
- var _config$context;
14761
+ var _config$context;
14762
+
14763
+ dispatch(initialize(config));
14764
+ let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
14645
14765
 
14646
- dispatch(initialize(config));
14766
+ try {
14647
14767
  const {
14648
14768
  features,
14649
14769
  defaultLocale
@@ -14652,38 +14772,39 @@ const actions_initialize = app_utils_createThunk('initialize', config => async (
14652
14772
  type: seamlyActions.SET_FEATURES,
14653
14773
  features
14654
14774
  });
14655
- let locale = (config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) || defaultLocale;
14775
+ locale = locale || defaultLocale;
14656
14776
  dispatch(setInitialLocale(locale));
14777
+ } catch (e) {
14778
+ throw new SeamlyUnavailableError();
14779
+ }
14657
14780
 
14658
- try {
14659
- if (api.hasConversation()) {
14660
- var _initialState$transla;
14781
+ try {
14782
+ if (api.hasConversation()) {
14783
+ var _initialState$transla;
14661
14784
 
14662
- const initialState = await api.getConversationIntitialState();
14663
- dispatch({
14664
- type: seamlyActions.SET_INITIAL_STATE,
14665
- initialState
14666
- });
14667
- locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
14785
+ const initialState = await api.getConversationIntitialState();
14786
+ dispatch({
14787
+ type: seamlyActions.SET_INITIAL_STATE,
14788
+ initialState
14789
+ });
14790
+ locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
14668
14791
 
14669
- if ('userResponded' in initialState) {
14670
- dispatch(setHasResponded(initialState.userResponded));
14671
- }
14792
+ if ('userResponded' in initialState) {
14793
+ dispatch(setHasResponded(initialState.userResponded));
14672
14794
  }
14673
- } catch (error) {
14674
- dispatch(set(error));
14795
+ }
14796
+ } catch (e) {
14797
+ if (e instanceof SeamlySessionExpiredError) {
14798
+ throw e;
14675
14799
  }
14676
14800
 
14801
+ throw new SeamlyUnavailableError();
14802
+ } finally {
14677
14803
  await dispatch(setLocale(locale));
14678
- } catch (error) {
14679
- dispatch(set(error));
14804
+ dispatch(actions_initialize());
14680
14805
  }
14681
14806
  });
14682
- ;// CONCATENATED MODULE: ./src/javascripts/domains/app/selectors.js
14683
-
14684
-
14685
- const selectUserHasResponded = createSelector(app_utils_selectState, state => state.userHasResponded);
14686
-
14807
+ const actions_reset = app_utils_createAction('reset', () => {});
14687
14808
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/hooks.js
14688
14809
 
14689
14810
 
@@ -14699,7 +14820,7 @@ function app_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.
14699
14820
 
14700
14821
 
14701
14822
 
14702
- const app_reducer_initialState = {
14823
+ const reducer_initialState = {
14703
14824
  userHasResponded: false
14704
14825
  };
14705
14826
  /* harmony default export */ const app_reducer = (app_utils_createReducer({
@@ -14708,12 +14829,102 @@ const app_reducer_initialState = {
14708
14829
  }) => app_reducer_objectSpread(app_reducer_objectSpread({}, state), {}, {
14709
14830
  userHasResponded: hasResponded
14710
14831
  })
14711
- }, app_reducer_initialState));
14832
+ }, reducer_initialState));
14712
14833
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/index.js
14713
14834
 
14714
14835
 
14715
14836
 
14716
14837
 
14838
+
14839
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/reducer.js
14840
+ function interrupt_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14841
+
14842
+ function interrupt_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { interrupt_reducer_ownKeys(Object(source), true).forEach(function (key) { interrupt_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { interrupt_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14843
+
14844
+ function interrupt_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14845
+
14846
+
14847
+
14848
+
14849
+ const interrupt_reducer_initialState = {
14850
+ error: undefined
14851
+ };
14852
+
14853
+ const handleError = (state, {
14854
+ error
14855
+ }) => interrupt_reducer_objectSpread(interrupt_reducer_objectSpread({}, state), {}, {
14856
+ error
14857
+ });
14858
+
14859
+ /* harmony default export */ const interrupt_reducer = (interrupt_utils_createReducer({
14860
+ [set]: handleError,
14861
+ [app_actions_initialize.rejected]: handleError,
14862
+ [clear]: () => interrupt_reducer_initialState,
14863
+ [actions_reset]: () => interrupt_reducer_initialState
14864
+ }, interrupt_reducer_initialState));
14865
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/index.js
14866
+
14867
+
14868
+
14869
+
14870
+
14871
+
14872
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/hooks.js
14873
+
14874
+
14875
+
14876
+
14877
+
14878
+
14879
+ const useVisibility = () => {
14880
+ const dispatch = useStoreDispatch();
14881
+ const visible = useSelector(selectVisibility);
14882
+ const isVisible = visible ? visible !== visibilityStates.hidden : false;
14883
+ const {
14884
+ layoutMode
14885
+ } = useConfig();
14886
+ const isOpen = visible && layoutMode ? visible === visibilityStates.open || layoutMode === 'inline' && visible !== visibilityStates.hidden : false;
14887
+ const setVisibility = (0,hooks_namespaceObject.useCallback)(visibility => dispatch(actions_setVisibility(visibility)), [dispatch]);
14888
+ return {
14889
+ isVisible,
14890
+ isOpen,
14891
+ visible,
14892
+ setVisibility
14893
+ };
14894
+ };
14895
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/reducer.js
14896
+ function visibility_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14897
+
14898
+ function visibility_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { visibility_reducer_ownKeys(Object(source), true).forEach(function (key) { visibility_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { visibility_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14899
+
14900
+ function visibility_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14901
+
14902
+
14903
+
14904
+
14905
+ const visibility_reducer_initialState = {
14906
+ visibility: visibilityStates.initialize
14907
+ };
14908
+ /* harmony default export */ const visibility_reducer = (visibility_utils_createReducer({
14909
+ [setFromStorage]: (state, {
14910
+ visibility
14911
+ }) => visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
14912
+ visibility
14913
+ }),
14914
+ [actions_setVisibility.fulfilled]: (state, {
14915
+ payload: visibility
14916
+ }) => visibility ? visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
14917
+ visibility
14918
+ }) : state
14919
+ }, visibility_reducer_initialState));
14920
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/index.js
14921
+
14922
+
14923
+
14924
+
14925
+
14926
+
14927
+
14717
14928
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-commands.js
14718
14929
  function use_seamly_commands_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14719
14930
 
@@ -14736,15 +14947,10 @@ function use_seamly_commands_defineProperty(obj, key, value) { if (key in obj) {
14736
14947
 
14737
14948
  const {
14738
14949
  ADD_EVENT: use_seamly_commands_ADD_EVENT,
14739
- CLEAR_EVENTS: use_seamly_commands_CLEAR_EVENTS,
14740
14950
  SET_IS_LOADING: use_seamly_commands_SET_IS_LOADING,
14741
- CLEAR_PARTICIPANTS: use_seamly_commands_CLEAR_PARTICIPANTS,
14742
14951
  SET_HEADER_SUB_TITLE: use_seamly_commands_SET_HEADER_SUB_TITLE,
14743
14952
  SET_INITIAL_STATE: use_seamly_commands_SET_INITIAL_STATE,
14744
- CLEAR_FEATURES: use_seamly_commands_CLEAR_FEATURES,
14745
- SET_FEATURES: use_seamly_commands_SET_FEATURES,
14746
- RESET_UPLOAD_STATE: use_seamly_commands_RESET_UPLOAD_STATE,
14747
- RESET_ENTRY_STATE: use_seamly_commands_RESET_ENTRY_STATE
14953
+ SET_FEATURES: use_seamly_commands_SET_FEATURES
14748
14954
  } = seamlyActions;
14749
14955
 
14750
14956
  const useSeamlyCommands = () => {
@@ -14756,7 +14962,7 @@ const useSeamlyCommands = () => {
14756
14962
  const hasConversation = useSeamlyHasConversation();
14757
14963
  const {
14758
14964
  visible: visibility
14759
- } = useSeamlyStateContext();
14965
+ } = useVisibility();
14760
14966
  const unreadMessageCount = useSeamlyUnreadCount();
14761
14967
  const emitEvent = (0,hooks_namespaceObject.useCallback)((...args) => {
14762
14968
  eventBus.emit(...args);
@@ -14778,26 +14984,12 @@ const useSeamlyCommands = () => {
14778
14984
  });
14779
14985
  }, [api, appConfig, emitEvent, hasResponded, hasConversation, visibility, unreadMessageCount]);
14780
14986
  const reset = (0,hooks_namespaceObject.useCallback)(async () => {
14987
+ dispatch(actions_reset());
14781
14988
  dispatch(clear());
14782
- dispatch({
14783
- type: use_seamly_commands_CLEAR_EVENTS
14784
- });
14785
14989
  dispatch({
14786
14990
  type: use_seamly_commands_SET_IS_LOADING,
14787
14991
  isLoading: true
14788
14992
  });
14789
- dispatch({
14790
- type: use_seamly_commands_CLEAR_PARTICIPANTS
14791
- });
14792
- dispatch({
14793
- type: use_seamly_commands_RESET_UPLOAD_STATE
14794
- });
14795
- dispatch({
14796
- type: use_seamly_commands_RESET_ENTRY_STATE
14797
- });
14798
- dispatch({
14799
- type: use_seamly_commands_CLEAR_FEATURES
14800
- });
14801
14993
  const {
14802
14994
  agentName
14803
14995
  } = appConfig.defaults || {};
@@ -14849,21 +15041,13 @@ const useSeamlyCommands = () => {
14849
15041
 
14850
15042
  const message = use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, getTextMessageBase(body)), config);
14851
15043
 
14852
- const sanitizedText = sanitizeText(body);
14853
-
14854
- const sanitizedMessage = use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, message), {}, {
14855
- body: {
14856
- text: sanitizedText
14857
- }
14858
- });
14859
-
14860
15044
  api.send('message', message);
14861
15045
  emitEvent('message', message);
14862
15046
  dispatch({
14863
15047
  type: use_seamly_commands_ADD_EVENT,
14864
15048
  event: {
14865
15049
  type: 'message',
14866
- payload: sanitizedMessage
15050
+ payload: message
14867
15051
  }
14868
15052
  });
14869
15053
  }, [api, dispatch, emitEvent, getTextMessageBase]);
@@ -15146,121 +15330,6 @@ const useSeamlyEntry = () => {
15146
15330
  setBlockAutoEntrySwitch
15147
15331
  };
15148
15332
  };
15149
- ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-stored-visibility.js
15150
- function use_seamly_stored_visibility_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15151
-
15152
- function use_seamly_stored_visibility_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_seamly_stored_visibility_ownKeys(Object(source), true).forEach(function (key) { use_seamly_stored_visibility_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_seamly_stored_visibility_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15153
-
15154
- function use_seamly_stored_visibility_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15155
-
15156
-
15157
-
15158
-
15159
-
15160
- const useSeamlyStoredVisibility = () => {
15161
- const {
15162
- layoutMode
15163
- } = useConfig();
15164
- const key = 'visibility';
15165
- const {
15166
- get,
15167
- set
15168
- } = useSeamlyObjectStore();
15169
- let storedVisibilityObj = {};
15170
- const savedVisibility = get ? get(key) : {};
15171
-
15172
- if (savedVisibility) {
15173
- storedVisibilityObj = savedVisibility;
15174
- }
15175
-
15176
- const setStoredVisibility = (0,hooks_namespaceObject.useCallback)(state => {
15177
- const saved = get ? get(key) : {};
15178
- set(key, use_seamly_stored_visibility_objectSpread(use_seamly_stored_visibility_objectSpread({}, saved), {}, {
15179
- [layoutMode]: state
15180
- }));
15181
- }, [set, get, layoutMode]);
15182
- return [layoutMode ? storedVisibilityObj[layoutMode] : null, set && layoutMode ? setStoredVisibility : null];
15183
- };
15184
-
15185
- /* harmony default export */ const use_seamly_stored_visibility = (useSeamlyStoredVisibility);
15186
- ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-visibility.js
15187
-
15188
-
15189
-
15190
-
15191
-
15192
-
15193
-
15194
-
15195
-
15196
- const {
15197
- SET_VISIBILITY: use_seamly_visibility_SET_VISIBILITY
15198
- } = seamlyActions;
15199
-
15200
- const useSeamlyVisibility = () => {
15201
- const config = useConfig();
15202
- const {
15203
- layoutMode,
15204
- visibilityCallback
15205
- } = config;
15206
- const {
15207
- visible
15208
- } = useSeamlyStateContext();
15209
- const {
15210
- emitEvent
15211
- } = use_seamly_commands();
15212
- const dispatch = use_seamly_dispatch();
15213
- const [storedVisibility, setStoredVisibility] = use_seamly_stored_visibility();
15214
- const hasResponded = useUserHasResponded();
15215
- const hasConversation = useSeamlyHasConversation();
15216
- const unreadMessageCount = useSeamlyUnreadCount();
15217
- const isVisible = visible ? visible !== visibilityStates.hidden : false;
15218
- const isOpen = visible && layoutMode ? visible === visibilityStates.open || layoutMode === 'inline' && visible !== visibilityStates.hidden : false;
15219
- const setVisibility = (0,hooks_namespaceObject.useCallback)(visibility => {
15220
- const visibilityFn = visibilityCallback || calculateVisibility;
15221
- const requestedVisibility = visibilityFn({
15222
- hasConversation,
15223
- hasResponded,
15224
- previousVisibility: storedVisibility || null,
15225
- requestedVisibility: visibility,
15226
- config
15227
- });
15228
-
15229
- if (![visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden].includes(requestedVisibility)) {
15230
- console.error('The visibilityCallback function should return "open", "minimized" or "hidden".');
15231
- return;
15232
- }
15233
-
15234
- if (requestedVisibility !== visible) {
15235
- if (setStoredVisibility) {
15236
- setStoredVisibility(requestedVisibility);
15237
- } // Don't broadcast the init visibility state
15238
-
15239
-
15240
- if (visibility) {
15241
- emitEvent('ui.visible', requestedVisibility, {
15242
- visibility: requestedVisibility,
15243
- hasConversation,
15244
- hasResponded,
15245
- unreadMessageCount
15246
- });
15247
- }
15248
-
15249
- dispatch({
15250
- type: use_seamly_visibility_SET_VISIBILITY,
15251
- visible: requestedVisibility
15252
- });
15253
- }
15254
- }, [visible, emitEvent, dispatch, hasConversation, hasResponded, storedVisibility, visibilityCallback, config, setStoredVisibility, unreadMessageCount]);
15255
- return {
15256
- isVisible,
15257
- isOpen,
15258
- visible,
15259
- setVisibility
15260
- };
15261
- };
15262
-
15263
- /* harmony default export */ const use_seamly_visibility = (useSeamlyVisibility);
15264
15333
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.js
15265
15334
 
15266
15335
 
@@ -15282,9 +15351,8 @@ const useSeamlyChat = () => {
15282
15351
  const {
15283
15352
  isOpen,
15284
15353
  isVisible,
15285
- visible,
15286
15354
  setVisibility
15287
- } = use_seamly_visibility();
15355
+ } = useVisibility();
15288
15356
  const dispatch = use_seamly_dispatch();
15289
15357
  const events = useEvents();
15290
15358
  const spinnerTimeout = (0,hooks_namespaceObject.useRef)(null);
@@ -15328,7 +15396,6 @@ const useSeamlyChat = () => {
15328
15396
  prevIsOpen.current = isOpen;
15329
15397
  prevIsVisible.current = isVisible;
15330
15398
  }, [isOpen, isVisible, sendAssertive, t]);
15331
- (0,hooks_namespaceObject.useEffect)(() => {}, [visible, sendAssertive]);
15332
15399
  (0,hooks_namespaceObject.useEffect)(() => {
15333
15400
  // This delays the start of the loading inidicator we set when we initialise
15334
15401
  // the application. This is done to only avoid BSOD on initial load if DCX is slow.
@@ -15426,7 +15493,7 @@ const useSeamlyIdleDetachCountdown = () => {
15426
15493
  } = useSeamlyStateContext();
15427
15494
  const {
15428
15495
  isOpen: isSeamlyOpen
15429
- } = use_seamly_visibility();
15496
+ } = useVisibility();
15430
15497
  const stableState = (0,hooks_namespaceObject.useRef)({});
15431
15498
  stableState.current = {
15432
15499
  hasCountdown: idleDetachCountdown.hasCountdown,
@@ -15625,8 +15692,6 @@ const useSeamlyResumeConversationPrompt = () => {
15625
15692
 
15626
15693
 
15627
15694
 
15628
-
15629
-
15630
15695
  // This hook isn't used within the core
15631
15696
  // But it is used in implementations
15632
15697
  // and imported directly from this file
@@ -15772,7 +15837,7 @@ const ModalWrapper = ({
15772
15837
  const {
15773
15838
  isOpen,
15774
15839
  setVisibility
15775
- } = use_seamly_visibility();
15840
+ } = useVisibility();
15776
15841
  const container = (0,hooks_namespaceObject.useRef)(null);
15777
15842
  const focusTrap = (0,hooks_namespaceObject.useRef)(null);
15778
15843
 
@@ -17530,7 +17595,7 @@ const AppFrame = ({
17530
17595
  isOpen,
17531
17596
  isVisible,
17532
17597
  setVisibility
17533
- } = use_seamly_visibility();
17598
+ } = useVisibility();
17534
17599
  const {
17535
17600
  zIndex,
17536
17601
  showFaq
@@ -18256,7 +18321,7 @@ function ChatFrame({
18256
18321
  } = useInterrupt();
18257
18322
  const {
18258
18323
  isOpen
18259
- } = use_seamly_visibility();
18324
+ } = useVisibility();
18260
18325
 
18261
18326
  const getContent = () => {
18262
18327
  if (hasInterrupt) {
@@ -18288,6 +18353,7 @@ function ChatFrame({
18288
18353
 
18289
18354
 
18290
18355
 
18356
+
18291
18357
  const ToggleButton = ({
18292
18358
  onOpenChat
18293
18359
  }) => {
@@ -18297,7 +18363,7 @@ const ToggleButton = ({
18297
18363
  const titleId = useGeneratedId();
18298
18364
  const {
18299
18365
  isOpen
18300
- } = use_seamly_visibility();
18366
+ } = useVisibility();
18301
18367
  const prevIsOpen = (0,hooks_namespaceObject.useRef)(null);
18302
18368
  const buttonRef = (0,hooks_namespaceObject.useRef)(null);
18303
18369
  const lastEventRef = (0,hooks_namespaceObject.useRef)();
@@ -18378,6 +18444,7 @@ const ToggleButton = ({
18378
18444
 
18379
18445
 
18380
18446
 
18447
+
18381
18448
  const AgentInfo = () => {
18382
18449
  const {
18383
18450
  t
@@ -18389,7 +18456,7 @@ const AgentInfo = () => {
18389
18456
  const unreadMessageCount = useSeamlyUnreadCount();
18390
18457
  const {
18391
18458
  isOpen
18392
- } = use_seamly_visibility();
18459
+ } = useVisibility();
18393
18460
  const currentAgent = useSeamlyCurrentAgent();
18394
18461
  const {
18395
18462
  hasInterrupt
@@ -19868,7 +19935,6 @@ mustache.Writer = Writer;
19868
19935
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js
19869
19936
 
19870
19937
 
19871
-
19872
19938
  mustache_mustache.escape = function (escapeText) {
19873
19939
  return escapeText;
19874
19940
  };
@@ -19877,7 +19943,7 @@ const parseLinkVariable = variable => {
19877
19943
  return `<a href='${variable.url}' data-link-id='${variable.id}' ${variable.newTab ? 'target="_blank"' : ''}>${variable.name}</a>`;
19878
19944
  };
19879
19945
 
19880
- function parseRichtText(text, variables = {}) {
19946
+ function parseRichText(text, variables = {}) {
19881
19947
  const view = {};
19882
19948
  Object.entries(variables).forEach(([key, variable]) => {
19883
19949
  switch (variable.type) {
@@ -19901,15 +19967,6 @@ function parseRichtText(text, variables = {}) {
19901
19967
  mustache_mustache.escape = oldEscape;
19902
19968
  return output;
19903
19969
  }
19904
-
19905
- const useTextRendering = ({
19906
- text,
19907
- variables = {}
19908
- }) => {
19909
- return (0,hooks_namespaceObject.useMemo)(() => parseRichtText(text, variables), [text, variables]);
19910
- };
19911
-
19912
- /* harmony default export */ const use_text_rendering = (useTextRendering);
19913
19970
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/text.js
19914
19971
  const text_excluded = ["event"];
19915
19972
 
@@ -19930,32 +19987,37 @@ function text_objectWithoutPropertiesLoose(source, excluded) { if (source == nul
19930
19987
 
19931
19988
 
19932
19989
 
19990
+
19933
19991
  const Text = _ref => {
19934
19992
  let {
19935
19993
  event
19936
19994
  } = _ref,
19937
19995
  props = text_objectWithoutProperties(_ref, text_excluded);
19938
19996
 
19939
- const {
19940
- payload
19941
- } = event;
19942
19997
  const [body] = useTranslatedEventData(event);
19943
- const eventClick = use_event_link_click_handler(payload.id);
19944
- const eventBody = use_text_rendering({
19945
- text: parse_body(body.text),
19946
- variables: body.variables
19947
- });
19998
+ const eventClick = use_event_link_click_handler(event.payload.id);
19999
+ const containerProps = (0,hooks_namespaceObject.useMemo)(() => {
20000
+ if (!event.payload.fromClient) {
20001
+ return {
20002
+ bodyProps: {
20003
+ dangerouslySetInnerHTML: {
20004
+ __html: parseRichText(parse_body(body.text), body.variables)
20005
+ }
20006
+ }
20007
+ };
20008
+ }
20009
+
20010
+ return {
20011
+ children: (0,jsx_runtime_namespaceObject.jsx)("p", {
20012
+ children: body.text
20013
+ })
20014
+ };
20015
+ }, [body, event]);
19948
20016
  return (0,jsx_runtime_namespaceObject.jsx)(message_container, text_objectSpread(text_objectSpread({
19949
20017
  type: "text",
19950
20018
  event: event,
19951
20019
  onClick: eventClick
19952
- }, props), {}, {
19953
- bodyProps: {
19954
- dangerouslySetInnerHTML: {
19955
- __html: eventBody
19956
- }
19957
- }
19958
- }));
20020
+ }, props), containerProps));
19959
20021
  };
19960
20022
 
19961
20023
  /* harmony default export */ const event_text = (Text);
@@ -21129,6 +21191,7 @@ const PrivacyDisclaimer = () => {
21129
21191
 
21130
21192
 
21131
21193
 
21194
+
21132
21195
  const Conversation = () => {
21133
21196
  const {
21134
21197
  t
@@ -21138,7 +21201,7 @@ const Conversation = () => {
21138
21201
  const isLoading = useSeamlyIsLoading();
21139
21202
  const {
21140
21203
  isOpen
21141
- } = use_seamly_visibility();
21204
+ } = useVisibility();
21142
21205
  const skiplinkTargetId = useSkiplink();
21143
21206
  const focusSkiplinkTarget = useSkiplinkTargetFocusing();
21144
21207
  (0,hooks_namespaceObject.useEffect)(() => {
@@ -22227,10 +22290,11 @@ const Interrupt = ({
22227
22290
 
22228
22291
 
22229
22292
 
22293
+
22230
22294
  const View = () => {
22231
22295
  const {
22232
22296
  isVisible
22233
- } = use_seamly_visibility();
22297
+ } = useVisibility();
22234
22298
  const {
22235
22299
  openChat,
22236
22300
  closeChat
@@ -22293,7 +22357,7 @@ const SeamlyInstanceFunctionsLoader = () => {
22293
22357
  const {
22294
22358
  setVisibility,
22295
22359
  visible
22296
- } = use_seamly_visibility();
22360
+ } = useVisibility();
22297
22361
  const currentVisibility = (0,hooks_namespaceObject.useRef)(visible);
22298
22362
  const eventBus = (0,hooks_namespaceObject.useContext)(SeamlyEventBusContext);
22299
22363
  const api = useSeamlyApiContext();
@@ -22417,6 +22481,7 @@ const SeamlyInstanceFunctionsLoader = () => {
22417
22481
 
22418
22482
 
22419
22483
 
22484
+
22420
22485
  const {
22421
22486
  SET_EVENTS_READ: seamly_read_state_SET_EVENTS_READ
22422
22487
  } = seamlyActions;
@@ -22430,7 +22495,7 @@ const SeamlyReadState = () => {
22430
22495
  const {
22431
22496
  isOpen,
22432
22497
  isVisible
22433
- } = use_seamly_visibility();
22498
+ } = useVisibility();
22434
22499
  const {
22435
22500
  sendAction
22436
22501
  } = use_seamly_commands();
@@ -22485,6 +22550,7 @@ const SeamlyReadState = () => {
22485
22550
 
22486
22551
 
22487
22552
 
22553
+
22488
22554
  const SeamlyNewNotifications = () => {
22489
22555
  const {
22490
22556
  t
@@ -22498,7 +22564,7 @@ const SeamlyNewNotifications = () => {
22498
22564
  } = useLiveRegion();
22499
22565
  const {
22500
22566
  isOpen
22501
- } = use_seamly_visibility();
22567
+ } = useVisibility();
22502
22568
  const prevIsOpen = (0,hooks_namespaceObject.useRef)(null);
22503
22569
  const debounceFunc = (0,hooks_namespaceObject.useRef)(null);
22504
22570
  const notifyUnread = (0,hooks_namespaceObject.useMemo)(() => {
@@ -22713,23 +22779,18 @@ const SeamlyActivityMonitor = ({
22713
22779
 
22714
22780
 
22715
22781
 
22716
-
22717
22782
  const SeamlyInitializer = () => {
22718
22783
  const {
22719
22784
  initUserSelectedOptions
22720
22785
  } = useSeamlyOptions();
22721
22786
  const seamlyInitialized = (0,hooks_namespaceObject.useRef)(false);
22722
- const {
22723
- setVisibility
22724
- } = use_seamly_visibility();
22725
22787
  const config = useConfig();
22726
22788
  (0,hooks_namespaceObject.useEffect)(() => {
22727
22789
  if (config.api && !seamlyInitialized.current) {
22728
22790
  seamlyInitialized.current = true;
22729
22791
  initUserSelectedOptions();
22730
- setVisibility(visibilityStates.initialize);
22731
22792
  }
22732
- }, [initUserSelectedOptions, config, setVisibility]);
22793
+ }, [initUserSelectedOptions, config]);
22733
22794
  return null;
22734
22795
  };
22735
22796
 
@@ -22961,18 +23022,18 @@ const SeamlyEventSubscriber = ({
22961
23022
  case 'error':
22962
23023
  switch (payload.type) {
22963
23024
  case 'find_conversation_erred':
22964
- dispatch(set(new SeamlySessionExpiredError()));
23025
+ dispatch(set(new SeamlySessionExpiredError(event)));
22965
23026
  break;
22966
23027
 
22967
23028
  case 'seamly_offline':
22968
- dispatch(set(new SeamlyOfflineError()));
23029
+ dispatch(set(new SeamlyOfflineError(event)));
22969
23030
  dispatch({
22970
23031
  type: seamly_event_subscriber_CLEAR_EVENTS
22971
23032
  });
22972
23033
  break;
22973
23034
 
22974
23035
  default:
22975
- dispatch(set(new SeamlyGeneralError()));
23036
+ dispatch(set(new SeamlyGeneralError(event)));
22976
23037
  break;
22977
23038
  }
22978
23039
 
@@ -23142,6 +23203,50 @@ const SeamlyFileUpload = ({
23142
23203
  };
23143
23204
 
23144
23205
  /* harmony default export */ const seamly_file_upload = (SeamlyFileUpload);
23206
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/errors/index.js
23207
+
23208
+
23209
+ const {
23210
+ createAction: errors_createAction
23211
+ } = createDomain('errors');
23212
+ const catchError = errors_createAction('catch-error', error => ({
23213
+ error
23214
+ }));
23215
+ function errors_createMiddleware({
23216
+ api: seamlyApi
23217
+ }) {
23218
+ return ({
23219
+ getState
23220
+ }) => {
23221
+ const handleError = error => {
23222
+ const {
23223
+ errorCallback,
23224
+ namespace,
23225
+ api,
23226
+ layoutMode
23227
+ } = selectConfig(getState());
23228
+ errorCallback === null || errorCallback === void 0 ? void 0 : errorCallback(error, {
23229
+ namespace,
23230
+ api,
23231
+ layoutMode,
23232
+ conversationUrl: seamlyApi.getConversationUrl()
23233
+ });
23234
+ };
23235
+
23236
+ return next => action => {
23237
+ try {
23238
+ if (action.error) {
23239
+ handleError(action.error);
23240
+ }
23241
+
23242
+ return next(action);
23243
+ } catch (error) {
23244
+ handleError(error);
23245
+ throw error;
23246
+ }
23247
+ };
23248
+ };
23249
+ }
23145
23250
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/core/seamly-core.js
23146
23251
 
23147
23252
 
@@ -23157,6 +23262,8 @@ const SeamlyFileUpload = ({
23157
23262
 
23158
23263
 
23159
23264
 
23265
+
23266
+
23160
23267
  const SeamlyCore = ({
23161
23268
  store,
23162
23269
  children,
@@ -23164,6 +23271,7 @@ const SeamlyCore = ({
23164
23271
  eventBus,
23165
23272
  api
23166
23273
  }) => {
23274
+ (0,hooks_namespaceObject.useErrorBoundary)(error => store.dispatch(catchError(error)));
23167
23275
  return (0,jsx_runtime_namespaceObject.jsx)(StoreProvider, {
23168
23276
  store: store,
23169
23277
  children: (0,jsx_runtime_namespaceObject.jsx)(SeamlyEventBusContext.Provider, {
@@ -24799,7 +24907,14 @@ function store(key) {
24799
24907
  const KEY = 'cvco.' + key;
24800
24908
  return {
24801
24909
  get() {
24802
- return JSON.parse(sessionStorage.getItem(KEY));
24910
+ const candidates = [KEY, KEY.split('.').slice(0, -1).join('.')];
24911
+ let val;
24912
+
24913
+ do {
24914
+ val = sessionStorage.getItem(candidates[0]);
24915
+ } while (candidates.shift() && !val);
24916
+
24917
+ return JSON.parse(val);
24803
24918
  },
24804
24919
 
24805
24920
  set(value) {
@@ -25033,7 +25148,6 @@ class API {
25033
25148
  }) // withCredentials() is necessary to allow browsers to save received
25034
25149
  // cookies in CORS requests.
25035
25150
  .withCredentials().send({
25036
- authorizationRequired: true,
25037
25151
  externalId: this.externalId || undefined
25038
25152
  });
25039
25153
  const {
@@ -25054,7 +25168,7 @@ class API {
25054
25168
  return initialState;
25055
25169
  } catch (error) {
25056
25170
  if (error.status >= 500) {
25057
- throw new SeamlyGeneralError();
25171
+ throw new SeamlyGeneralError(error);
25058
25172
  }
25059
25173
 
25060
25174
  throw error;
@@ -25100,15 +25214,15 @@ class API {
25100
25214
  };
25101
25215
  } catch (error) {
25102
25216
  if (error.status === 401) {
25103
- throw new SeamlyUnauthorizedError();
25217
+ throw new SeamlyUnauthorizedError(error);
25104
25218
  }
25105
25219
 
25106
25220
  if (error.status === 404) {
25107
- throw new SeamlySessionExpiredError();
25221
+ throw new SeamlySessionExpiredError(error);
25108
25222
  }
25109
25223
 
25110
25224
  if (error.status >= 500) {
25111
- throw new SeamlyGeneralError();
25225
+ throw new SeamlyGeneralError(error);
25112
25226
  }
25113
25227
 
25114
25228
  throw error;
@@ -25173,11 +25287,11 @@ class API {
25173
25287
  return body.config;
25174
25288
  }).catch(error => {
25175
25289
  if (error.status === 404) {
25176
- throw new SeamlyConfigurationError();
25290
+ throw new SeamlyConfigurationError(error);
25177
25291
  }
25178
25292
 
25179
25293
  if (error.status >= 500) {
25180
- throw new SeamlyGeneralError();
25294
+ throw new SeamlyGeneralError(error);
25181
25295
  }
25182
25296
 
25183
25297
  throw error;
@@ -25194,15 +25308,15 @@ class API {
25194
25308
  return omit(body.conversation, ['accessToken', 'channelName']);
25195
25309
  }).catch(error => {
25196
25310
  if (error.status === 401) {
25197
- throw new SeamlyUnauthorizedError();
25311
+ throw new SeamlyUnauthorizedError(error);
25198
25312
  }
25199
25313
 
25200
25314
  if (error.status === 404) {
25201
- throw new SeamlySessionExpiredError();
25315
+ throw new SeamlySessionExpiredError(error);
25202
25316
  }
25203
25317
 
25204
25318
  if (error.status >= 500) {
25205
- throw new SeamlyGeneralError();
25319
+ throw new SeamlyGeneralError(error);
25206
25320
  }
25207
25321
 
25208
25322
  throw error;
@@ -25225,7 +25339,7 @@ class API {
25225
25339
  return body.translations;
25226
25340
  } catch (error) {
25227
25341
  if (error.status >= 500) {
25228
- throw new SeamlyGeneralError();
25342
+ throw new SeamlyGeneralError(error);
25229
25343
  }
25230
25344
 
25231
25345
  throw error;
@@ -25351,9 +25465,16 @@ function options_middleware_createMiddleware({
25351
25465
  ;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
25352
25466
 
25353
25467
  ;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
25468
+ function state_reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
25469
+
25470
+ function state_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { state_reducer_ownKeys(Object(source), true).forEach(function (key) { state_reducer_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { state_reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25471
+
25472
+ function state_reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25473
+
25354
25474
  // Legacy state reducer. Do not add new features here but extract/create new reducers as needed
25355
25475
 
25356
25476
 
25477
+
25357
25478
  const state_reducer_initialState = {
25358
25479
  events: [],
25359
25480
  initialState: {},
@@ -25364,7 +25485,6 @@ const state_reducer_initialState = {
25364
25485
  isActive: false
25365
25486
  },
25366
25487
  resumeConversationPrompt: false,
25367
- visible: visibilityStates.hidden,
25368
25488
  serviceInfo: {
25369
25489
  activeServiceSessionId: ''
25370
25490
  },
@@ -25401,6 +25521,15 @@ const state_reducer_initialState = {
25401
25521
  seamlyContainerElement: null
25402
25522
  };
25403
25523
  function stateReducer(state = state_reducer_initialState, action) {
25524
+ if (action.type === String(actions_reset)) {
25525
+ const {
25526
+ visible
25527
+ } = state;
25528
+ return state_reducer_objectSpread(state_reducer_objectSpread({}, state_reducer_initialState), {}, {
25529
+ visible
25530
+ });
25531
+ }
25532
+
25404
25533
  return seamlyStateReducer(state, action);
25405
25534
  }
25406
25535
  ;// CONCATENATED MODULE: ./src/javascripts/domains/store/index.js
@@ -25414,9 +25543,12 @@ function stateReducer(state = state_reducer_initialState, action) {
25414
25543
 
25415
25544
 
25416
25545
 
25546
+
25547
+
25417
25548
  function store_createStore({
25418
25549
  initialState,
25419
- api
25550
+ api,
25551
+ eventBus
25420
25552
  } = {}) {
25421
25553
  const store = createReduxStore({
25422
25554
  reducers: {
@@ -25426,12 +25558,18 @@ function store_createStore({
25426
25558
  [String(forms_reducer)]: forms_reducer,
25427
25559
  [String(translations_reducer)]: translations_reducer,
25428
25560
  [String(i18n_reducer)]: i18n_reducer,
25429
- [String(interrupt_reducer)]: interrupt_reducer
25561
+ [String(interrupt_reducer)]: interrupt_reducer,
25562
+ [String(visibility_reducer)]: visibility_reducer
25430
25563
  },
25431
25564
  initialState,
25432
- middlewares: [es.withExtraArgument({
25565
+ middlewares: [errors_createMiddleware({
25566
+ api
25567
+ }), es.withExtraArgument({
25568
+ api,
25569
+ eventBus
25570
+ }), createMiddleware(), middleware_createMiddleware({
25433
25571
  api
25434
- }), createMiddleware(), middleware_createMiddleware(), options_middleware_createMiddleware({
25572
+ }), options_middleware_createMiddleware({
25435
25573
  api
25436
25574
  }), translations_middleware_createMiddleware()]
25437
25575
  });
@@ -25504,9 +25642,10 @@ class Engine {
25504
25642
  });
25505
25643
 
25506
25644
  const store = store_createStore({
25507
- api: this.api
25645
+ api: this.api,
25646
+ eventBus: this.eventBus
25508
25647
  });
25509
- await store.dispatch(actions_initialize(renderConfig));
25648
+ await store.dispatch(app_actions_initialize(renderConfig));
25510
25649
 
25511
25650
  if (View) {
25512
25651
  (0,external_preact_namespaceObject.render)((0,jsx_runtime_namespaceObject.jsx)(seamly_core, {
@@ -25826,12 +25965,6 @@ function initializeExternalApi(appConfig) {
25826
25965
 
25827
25966
  // Used by: StyleGuide
25828
25967
 
25829
- // Used by: StyleGuide
25830
-
25831
- // Used by: StyleGuide
25832
-
25833
- // Used by: StyleGuide
25834
-
25835
25968
 
25836
25969
  })();
25837
25970