@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
@@ -193,6 +193,13 @@ module.exports = __webpack_require__(8933);
193
193
 
194
194
  /***/ }),
195
195
 
196
+ /***/ 1864:
197
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
198
+
199
+ module.exports = __webpack_require__(3383);
200
+
201
+ /***/ }),
202
+
196
203
  /***/ 4943:
197
204
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
198
205
 
@@ -249,6 +256,13 @@ module.exports = __webpack_require__(9534);
249
256
 
250
257
  /***/ }),
251
258
 
259
+ /***/ 1611:
260
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
261
+
262
+ module.exports = __webpack_require__(6507);
263
+
264
+ /***/ }),
265
+
252
266
  /***/ 6902:
253
267
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
254
268
 
@@ -6853,6 +6867,17 @@ var path = __webpack_require__(4058);
6853
6867
  module.exports = path.Object.getOwnPropertySymbols;
6854
6868
 
6855
6869
 
6870
+ /***/ }),
6871
+
6872
+ /***/ 3966:
6873
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
6874
+
6875
+ __webpack_require__(7405);
6876
+ var path = __webpack_require__(4058);
6877
+
6878
+ module.exports = path.Object.getPrototypeOf;
6879
+
6880
+
6856
6881
  /***/ }),
6857
6882
 
6858
6883
  /***/ 8494:
@@ -11742,6 +11767,29 @@ $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, {
11742
11767
  });
11743
11768
 
11744
11769
 
11770
+ /***/ }),
11771
+
11772
+ /***/ 7405:
11773
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
11774
+
11775
+ var $ = __webpack_require__(6887);
11776
+ var fails = __webpack_require__(5981);
11777
+ var toObject = __webpack_require__(9678);
11778
+ var nativeGetPrototypeOf = __webpack_require__(249);
11779
+ var CORRECT_PROTOTYPE_GETTER = __webpack_require__(4160);
11780
+
11781
+ var FAILS_ON_PRIMITIVES = fails(function () { nativeGetPrototypeOf(1); });
11782
+
11783
+ // `Object.getPrototypeOf` method
11784
+ // https://tc39.es/ecma262/#sec-object.getprototypeof
11785
+ $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES, sham: !CORRECT_PROTOTYPE_GETTER }, {
11786
+ getPrototypeOf: function getPrototypeOf(it) {
11787
+ return nativeGetPrototypeOf(toObject(it));
11788
+ }
11789
+ });
11790
+
11791
+
11792
+
11745
11793
  /***/ }),
11746
11794
 
11747
11795
  /***/ 1724:
@@ -13361,6 +13409,16 @@ var parent = __webpack_require__(4426);
13361
13409
  module.exports = parent;
13362
13410
 
13363
13411
 
13412
+ /***/ }),
13413
+
13414
+ /***/ 3383:
13415
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
13416
+
13417
+ var parent = __webpack_require__(5999);
13418
+
13419
+ module.exports = parent;
13420
+
13421
+
13364
13422
  /***/ }),
13365
13423
 
13366
13424
  /***/ 4471:
@@ -13441,6 +13499,16 @@ var parent = __webpack_require__(498);
13441
13499
  module.exports = parent;
13442
13500
 
13443
13501
 
13502
+ /***/ }),
13503
+
13504
+ /***/ 6507:
13505
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
13506
+
13507
+ var parent = __webpack_require__(3966);
13508
+
13509
+ module.exports = parent;
13510
+
13511
+
13444
13512
  /***/ }),
13445
13513
 
13446
13514
  /***/ 3059:
@@ -17971,13 +18039,10 @@ __webpack_require__.d(__webpack_exports__, {
17971
18039
  "Interrupt": function() { return /* reexport */ interrupt; },
17972
18040
  "MessageContainer": function() { return /* reexport */ message_container; },
17973
18041
  "SeamlyApiContext": function() { return /* reexport */ SeamlyApiContext; },
17974
- "SeamlyConfigurationError": function() { return /* reexport */ SeamlyConfigurationError; },
17975
18042
  "SeamlyEventBusContext": function() { return /* reexport */ SeamlyEventBusContext; },
17976
18043
  "SeamlyGeneralError": function() { return /* reexport */ SeamlyGeneralError; },
17977
18044
  "SeamlyLiveRegionContext": function() { return /* reexport */ SeamlyLiveRegionContext; },
17978
18045
  "SeamlyOfflineError": function() { return /* reexport */ SeamlyOfflineError; },
17979
- "SeamlySessionExpiredError": function() { return /* reexport */ SeamlySessionExpiredError; },
17980
- "SeamlyUnauthorizedError": function() { return /* reexport */ SeamlyUnauthorizedError; },
17981
18046
  "StoreProvider": function() { return /* reexport */ StoreProvider; },
17982
18047
  "Text": function() { return /* reexport */ event_text; },
17983
18048
  "ToggleButton": function() { return /* reexport */ toggle_button; },
@@ -18003,7 +18068,7 @@ __webpack_require__.d(__webpack_exports__, {
18003
18068
  "useSeamlyIdleDetachCountdown": function() { return /* reexport */ use_seamly_idle_detach_countdown; },
18004
18069
  "useSeamlyMessageContainerClassNames": function() { return /* reexport */ useSeamlyMessageContainerClassNames; },
18005
18070
  "useSeamlyOptions": function() { return /* reexport */ useSeamlyOptions; },
18006
- "useSeamlyVisibility": function() { return /* reexport */ use_seamly_visibility; },
18071
+ "useSeamlyVisibility": function() { return /* reexport */ useVisibility; },
18007
18072
  "useTranslatedEventData": function() { return /* reexport */ useTranslatedEventData; },
18008
18073
  "useTranslations": function() { return /* reexport */ useTranslations; },
18009
18074
  "useTranslationsContainer": function() { return /* reexport */ useTranslationsContainer; },
@@ -20185,7 +20250,6 @@ const millisecondsToSeconds = milliseconds => {
20185
20250
  const microsecondsToMilliseconds = microseconds => {
20186
20251
  return Math.ceil(microseconds / 1000);
20187
20252
  };
20188
- const sanitizeText = text => text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/\//g, '&#x2F;');
20189
20253
  const getTimeFromSeconds = seconds => {
20190
20254
  const minutes = Math.floor(seconds / 60);
20191
20255
  const secondsPartial = seconds - minutes * 60;
@@ -20286,6 +20350,20 @@ const omit = (obj, keys) => {
20286
20350
  return accum;
20287
20351
  }, {});
20288
20352
  };
20353
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/object/assign.js
20354
+ var object_assign = __webpack_require__(1864);
20355
+ var assign_default = /*#__PURE__*/__webpack_require__.n(object_assign);
20356
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/date/now.js
20357
+ var now = __webpack_require__(1128);
20358
+ var now_default = /*#__PURE__*/__webpack_require__.n(now);
20359
+ ;// CONCATENATED MODULE: ./src/javascripts/lib/id.js
20360
+
20361
+
20362
+ function randomId() {
20363
+ var _context;
20364
+
20365
+ return '_' + (Number(slice_default()(_context = String(Math.random())).call(_context, 2)) + now_default()() + Math.round(performance.now())).toString(36);
20366
+ }
20289
20367
  ;// CONCATENATED MODULE: ./src/javascripts/lib/redux-helpers/index.js
20290
20368
 
20291
20369
 
@@ -20298,10 +20376,12 @@ const omit = (obj, keys) => {
20298
20376
 
20299
20377
 
20300
20378
 
20379
+
20301
20380
  function redux_helpers_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
20302
20381
 
20303
20382
  function redux_helpers_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; for_each_default()(_context2 = redux_helpers_ownKeys(Object(source), true)).call(_context2, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context3; for_each_default()(_context3 = redux_helpers_ownKeys(Object(source))).call(_context3, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
20304
20383
 
20384
+
20305
20385
  const SLICE_DELIMITER = '/';
20306
20386
  const DOMAIN_DELIMITER = '//';
20307
20387
  function prefixType(prefix, fn, delimiter = '/') {
@@ -20314,7 +20394,9 @@ function createAction(type, identityReducer = payload => ({
20314
20394
  type
20315
20395
  }, identityReducer(...params));
20316
20396
 
20317
- action.toString = () => type.toString();
20397
+ action.toString = () => String(type);
20398
+
20399
+ action.match = obj => (obj === null || obj === void 0 ? void 0 : obj.type) === String(type);
20318
20400
 
20319
20401
  return action;
20320
20402
  }
@@ -20340,24 +20422,73 @@ function createActions(baseType, ...args) {
20340
20422
  const create = prefixType(baseType, createAction, SLICE_DELIMITER);
20341
20423
  return map_default()(handlers).call(handlers, handler => create(...handler));
20342
20424
  }
20343
- function createThunk(type, thunkCreator) {
20344
- const fn = (...args) => {
20345
- const thunk = thunkCreator(...args);
20346
- thunk.type = type;
20347
- return thunk;
20348
- };
20425
+ function createThunk(type, payloadCreator) {
20426
+ const [pending, fulfilled, rejected] = createActions(type, {
20427
+ pending: (arg, requestId) => ({
20428
+ meta: {
20429
+ arg,
20430
+ requestId,
20431
+ status: 'pending'
20432
+ }
20433
+ }),
20434
+ fulfilled: (arg, payload, requestId) => ({
20435
+ payload,
20436
+ meta: {
20437
+ arg,
20438
+ requestId,
20439
+ status: 'fulfilled'
20440
+ }
20441
+ }),
20442
+ rejected: (arg, error, requestId) => ({
20443
+ error,
20444
+ meta: {
20445
+ arg,
20446
+ requestId,
20447
+ status: 'rejected',
20448
+ error: String(error)
20449
+ }
20450
+ })
20451
+ });
20452
+
20453
+ const thunkCreator = arg => (dispatch, getState, extra) => {
20454
+ const requestId = randomId();
20455
+
20456
+ const promise = (async () => {
20457
+ let finalAction;
20458
+
20459
+ try {
20460
+ dispatch(pending(arg, requestId));
20461
+ const prms = payloadCreator(arg, {
20462
+ dispatch,
20463
+ getState,
20464
+ extra
20465
+ });
20466
+ const result = await prms;
20467
+ finalAction = fulfilled(arg, result, requestId);
20468
+ } catch (error) {
20469
+ finalAction = rejected(arg, error, requestId);
20470
+ }
20349
20471
 
20350
- fn.toString = () => type;
20472
+ dispatch(finalAction);
20473
+ return finalAction;
20474
+ })();
20351
20475
 
20352
- return fn;
20476
+ return assign_default()(promise, {
20477
+ type,
20478
+ arg,
20479
+ requestId
20480
+ });
20481
+ };
20482
+
20483
+ return assign_default()(thunkCreator, {
20484
+ type,
20485
+ pending,
20486
+ fulfilled,
20487
+ rejected
20488
+ });
20353
20489
  }
20354
20490
  function createReducer(domain, handlers = {}, defaultState) {
20355
- const reducer = (state, action) => {
20356
- if (state === undefined) {
20357
- // eslint-disable-next-line no-param-reassign
20358
- state = defaultState;
20359
- }
20360
-
20491
+ const reducer = (state = defaultState, action) => {
20361
20492
  const typeReducer = handlers === null || handlers === void 0 ? void 0 : handlers[action === null || action === void 0 ? void 0 : action.type];
20362
20493
  return typeReducer ? typeReducer(state, action) : state;
20363
20494
  };
@@ -20391,6 +20522,53 @@ const initialize = utils_createAction('initialize', config => ({
20391
20522
  const update = utils_createAction('update', config => ({
20392
20523
  config
20393
20524
  }));
20525
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/constants.js
20526
+ const StoreKey = 'visibility';
20527
+ const visibilityStates = {
20528
+ hidden: 'hidden',
20529
+ minimized: 'minimized',
20530
+ open: 'open',
20531
+ initialize: null
20532
+ };
20533
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/config/selectors.js
20534
+
20535
+
20536
+
20537
+
20538
+
20539
+
20540
+
20541
+
20542
+
20543
+
20544
+ function selectors_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
20545
+
20546
+ function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = selectors_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = selectors_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
20547
+
20548
+
20549
+
20550
+
20551
+ const selectConfig = createSelector(selectState, config => {
20552
+ let newConfig = selectors_objectSpread({
20553
+ visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? visibilityStates.open : visibilityStates.minimized,
20554
+ appContainerClassNames: config.appContainerClassNames || []
20555
+ }, config);
20556
+
20557
+ if (typeof newConfig.appContainerClassNames === 'function') {
20558
+ newConfig = selectors_objectSpread(selectors_objectSpread({}, newConfig), {}, {
20559
+ appContainerClassNames: newConfig.appContainerClassNames(newConfig)
20560
+ });
20561
+ }
20562
+
20563
+ return newConfig;
20564
+ });
20565
+
20566
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/config/hooks.js
20567
+
20568
+
20569
+ function useConfig() {
20570
+ return useSelector(selectConfig);
20571
+ }
20394
20572
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/sort.js
20395
20573
  var sort = __webpack_require__(7302);
20396
20574
  var sort_default = /*#__PURE__*/__webpack_require__.n(sort);
@@ -20445,12 +20623,6 @@ const entryTypes = {
20445
20623
  text: 'text',
20446
20624
  upload: 'upload'
20447
20625
  };
20448
- const visibilityStates = {
20449
- hidden: 'hidden',
20450
- minimized: 'minimized',
20451
- open: 'open',
20452
- initialize: null
20453
- };
20454
20626
  const readStates = {
20455
20627
  received: 'received',
20456
20628
  read: 'read'
@@ -20497,7 +20669,6 @@ const seamlyActions = {
20497
20669
  SET_PARTICIPANT: 'SET_PARTICIPANT',
20498
20670
  SET_HEADER_TITLE: 'SET_HEADER_TITLE',
20499
20671
  SET_HEADER_SUB_TITLE: 'SET_HEADER_SUB_TITLE',
20500
- SET_VISIBILITY: 'SET_VISIBILITY',
20501
20672
  RESET_HISTORY_LOADED_FLAG: 'RESET_HISTORY_LOADED_FLAG',
20502
20673
  SET_ACTIVE_SERVICE: 'SET_ACTIVE_SERVICE',
20503
20674
  INIT_IDLE_DETACH_COUNTDOWN: 'INIT_IDLE_DETACH_COUNTDOWN',
@@ -20525,8 +20696,6 @@ const seamlyActions = {
20525
20696
  SET_UPLOAD_ERROR: 'SET_UPLOAD_ERROR',
20526
20697
  CLEAR_UPLOAD: 'CLEAR_UPLOAD',
20527
20698
  CLEAR_ALL_UPLOADS: 'CLEAR_ALL_UPLOADS',
20528
- RESET_UPLOAD_STATE: 'RESET_UPLOAD_STATE',
20529
- RESET_ENTRY_STATE: 'RESET_ENTRY_STATE',
20530
20699
  SET_SEAMLY_CONTAINER_ELEMENT: 'SET_SEAMLY_CONTAINER_ELEMENT'
20531
20700
  };
20532
20701
  const cardTypes = {
@@ -20545,7 +20714,6 @@ const {
20545
20714
  SET_PARTICIPANT,
20546
20715
  SET_HEADER_TITLE,
20547
20716
  SET_HEADER_SUB_TITLE,
20548
- SET_VISIBILITY,
20549
20717
  RESET_HISTORY_LOADED_FLAG,
20550
20718
  SET_ACTIVE_SERVICE,
20551
20719
  INIT_IDLE_DETACH_COUNTDOWN,
@@ -20573,8 +20741,6 @@ const {
20573
20741
  SET_UPLOAD_ERROR,
20574
20742
  CLEAR_UPLOAD,
20575
20743
  CLEAR_ALL_UPLOADS,
20576
- RESET_UPLOAD_STATE,
20577
- RESET_ENTRY_STATE,
20578
20744
  SET_SEAMLY_CONTAINER_ELEMENT
20579
20745
  } = seamlyActions;
20580
20746
  const isUnreadMessage = ({
@@ -20962,11 +21128,6 @@ const seamlyStateReducer = (state, action) => {
20962
21128
  resumeConversationPrompt: false
20963
21129
  });
20964
21130
 
20965
- case SET_VISIBILITY:
20966
- return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
20967
- visible: action.visible
20968
- });
20969
-
20970
21131
  case SET_PARTICIPANT:
20971
21132
  case CLEAR_PARTICIPANTS:
20972
21133
  return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
@@ -21174,26 +21335,6 @@ const seamlyStateReducer = (state, action) => {
21174
21335
  currentUploads: []
21175
21336
  });
21176
21337
 
21177
- case RESET_UPLOAD_STATE:
21178
- return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
21179
- showFileUpload: false,
21180
- currentUploads: []
21181
- });
21182
-
21183
- case RESET_ENTRY_STATE:
21184
- {
21185
- return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
21186
- entryMeta: {
21187
- default: payloadTypes.text,
21188
- active: payloadTypes.text,
21189
- userSelected: null,
21190
- blockAutoEntrySwitch: false,
21191
- options: {},
21192
- optionsOverride: {}
21193
- }
21194
- });
21195
- }
21196
-
21197
21338
  case SET_SEAMLY_CONTAINER_ELEMENT:
21198
21339
  {
21199
21340
  return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
@@ -21205,67 +21346,6 @@ const seamlyStateReducer = (state, action) => {
21205
21346
  return state;
21206
21347
  }
21207
21348
  };
21208
- const calculateVisibility = ({
21209
- hasResponded,
21210
- previousVisibility,
21211
- requestedVisibility,
21212
- config
21213
- }) => {
21214
- const {
21215
- defaults,
21216
- layoutMode,
21217
- hideOnNoUserResponse
21218
- } = config;
21219
- const {
21220
- visible: defaultVisibility
21221
- } = defaults || {}; // Requesting open should override the responded check.
21222
-
21223
- if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
21224
- return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
21225
- }
21226
-
21227
- const baseVisibility = layoutMode === 'inline' ? visibilityStates.open : visibilityStates.minimized;
21228
- return requestedVisibility || previousVisibility || defaultVisibility || baseVisibility;
21229
- };
21230
- ;// CONCATENATED MODULE: ./src/javascripts/domains/config/selectors.js
21231
-
21232
-
21233
-
21234
-
21235
-
21236
-
21237
-
21238
-
21239
-
21240
-
21241
- function selectors_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21242
-
21243
- function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = selectors_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = selectors_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
21244
-
21245
-
21246
-
21247
-
21248
- const selectConfig = createSelector(selectState, config => {
21249
- let newConfig = selectors_objectSpread({
21250
- visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? visibilityStates.open : visibilityStates.minimized,
21251
- appContainerClassNames: config.appContainerClassNames || []
21252
- }, config);
21253
-
21254
- if (typeof newConfig.appContainerClassNames === 'function') {
21255
- newConfig = selectors_objectSpread(selectors_objectSpread({}, newConfig), {}, {
21256
- appContainerClassNames: newConfig.appContainerClassNames(newConfig)
21257
- });
21258
- }
21259
-
21260
- return newConfig;
21261
- });
21262
-
21263
- ;// CONCATENATED MODULE: ./src/javascripts/domains/config/hooks.js
21264
-
21265
-
21266
- function useConfig() {
21267
- return useSelector(selectConfig);
21268
- }
21269
21349
  ;// CONCATENATED MODULE: ./src/javascripts/domains/config/middleware.js
21270
21350
 
21271
21351
 
@@ -21362,7 +21442,7 @@ const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig
21362
21442
  defaults: {}
21363
21443
  });
21364
21444
 
21365
- const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback'];
21445
+ const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback'];
21366
21446
 
21367
21447
  const updateState = (state, {
21368
21448
  config
@@ -21641,7 +21721,6 @@ function createMutex() {
21641
21721
 
21642
21722
  const {
21643
21723
  createAction: i18n_utils_createAction,
21644
- createActions: utils_createActions,
21645
21724
  createThunk: i18n_utils_createThunk,
21646
21725
  createReducer: i18n_utils_createReducer,
21647
21726
  selectState: utils_selectState
@@ -21660,38 +21739,19 @@ const selectLocale = createSelector(utils_selectState, state => state.locale);
21660
21739
  const setInitialLocale = i18n_utils_createAction('setInitialLocale', locale => ({
21661
21740
  locale
21662
21741
  }));
21663
- const [setLocaleStart, setLocaleResolve, setLocaleReject] = utils_createActions('setLocale', {
21664
- start: locale => ({
21665
- locale
21666
- }),
21667
- resolve: (locale, translations) => ({
21668
- locale,
21669
- translations
21670
- }),
21671
- reject: (locale, error) => ({
21672
- locale,
21673
- error
21674
- })
21675
- });
21676
21742
  const mutex = createMutex();
21677
- const setLocale = i18n_utils_createThunk('setLocale', locale => async (dispatch, getState, {
21678
- api
21743
+ const setLocale = i18n_utils_createThunk('setLocale', async (locale, {
21744
+ getState,
21745
+ extra: {
21746
+ api
21747
+ }
21679
21748
  }) => {
21680
- await mutex.runExclusively(async () => {
21681
- const currentLocale = selectLocale(getState());
21682
-
21683
- if (currentLocale === locale) {
21684
- return;
21749
+ return mutex.runExclusively(() => {
21750
+ if (locale === selectLocale(getState())) {
21751
+ return undefined;
21685
21752
  }
21686
21753
 
21687
- dispatch(setLocaleStart(locale));
21688
-
21689
- try {
21690
- const translations = await api.getTranslations(locale);
21691
- dispatch(setLocaleResolve(locale, translations));
21692
- } catch (error) {
21693
- dispatch(setLocaleReject(locale, error));
21694
- }
21754
+ return api.getTranslations(locale);
21695
21755
  });
21696
21756
  });
21697
21757
  ;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
@@ -22427,7 +22487,11 @@ const defaultState = {
22427
22487
  'errors.general.title': 'Something went wrong',
22428
22488
  '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.',
22429
22489
  '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.',
22430
- 'errors.seamlyOffline.title': 'Connection issues'
22490
+ 'errors.seamlyOffline.title': 'Connection issues',
22491
+ 'errors.seamlyUnavailable.buttonText': 'Try again',
22492
+ 'errors.seamlyUnavailable.message': 'The server could not be reached. Try again in a little while.',
22493
+ 'errors.seamlyUnavailable.srText': 'The chat server could not be reached. Try again in a little while.',
22494
+ 'errors.seamlyUnavailable.title': 'Server unavailable'
22431
22495
  },
22432
22496
  isLoading: false,
22433
22497
  initialLocale: undefined
@@ -22438,15 +22502,23 @@ const defaultState = {
22438
22502
  }) => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22439
22503
  initialLocale: locale
22440
22504
  }),
22441
- [setLocaleStart]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22505
+ [setLocale.pending]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22442
22506
  isLoading: true
22443
22507
  }),
22444
- [setLocaleResolve]: (state, {
22445
- locale,
22446
- translations
22508
+ [setLocale.fulfilled]: (state, {
22509
+ payload: translations,
22510
+ meta: {
22511
+ arg: locale
22512
+ }
22447
22513
  }) => {
22448
22514
  var _context, _context2;
22449
22515
 
22516
+ if (!translations) {
22517
+ return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22518
+ isLoading: false
22519
+ });
22520
+ }
22521
+
22450
22522
  return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22451
22523
  isLoading: false,
22452
22524
  locale,
@@ -22455,7 +22527,7 @@ const defaultState = {
22455
22527
  }), {})
22456
22528
  });
22457
22529
  },
22458
- [setLocaleReject]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22530
+ [setLocale.rejected]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
22459
22531
  isLoading: false
22460
22532
  })
22461
22533
  }, defaultState));
@@ -22694,20 +22766,9 @@ const useFileUploads = () => {
22694
22766
  isComplete: every_default()(currentUploads).call(currentUploads, file => file.complete)
22695
22767
  };
22696
22768
  };
22697
- // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/date/now.js
22698
- var now = __webpack_require__(1128);
22699
- var now_default = /*#__PURE__*/__webpack_require__.n(now);
22700
22769
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/trim.js
22701
22770
  var trim = __webpack_require__(5843);
22702
22771
  var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
22703
- ;// CONCATENATED MODULE: ./src/javascripts/lib/id.js
22704
-
22705
-
22706
- function randomId() {
22707
- var _context;
22708
-
22709
- return '_' + (Number(slice_default()(_context = String(Math.random())).call(_context, 2)) + now_default()() + Math.round(performance.now())).toString(36);
22710
- }
22711
22772
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/utility-hooks.js
22712
22773
 
22713
22774
 
@@ -22809,15 +22870,28 @@ function useInterrupt() {
22809
22870
  error
22810
22871
  };
22811
22872
  }
22812
- ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-general-error.js
22813
- class SeamlyGeneralError extends Error {
22814
- constructor(params) {
22815
- super(params);
22873
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/object/get-prototype-of.js
22874
+ var get_prototype_of = __webpack_require__(1611);
22875
+ var get_prototype_of_default = /*#__PURE__*/__webpack_require__.n(get_prototype_of);
22876
+ ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-base-error.js
22877
+
22878
+ class SeamlyBaseError extends Error {
22879
+ constructor(originalError, ...params) {
22880
+ super(...params);
22816
22881
 
22817
22882
  if (Error.captureStackTrace) {
22818
- Error.captureStackTrace(this, SeamlyGeneralError);
22883
+ Error.captureStackTrace(this, get_prototype_of_default()(this));
22819
22884
  }
22820
22885
 
22886
+ this.originalError = originalError;
22887
+ }
22888
+
22889
+ }
22890
+ ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-general-error.js
22891
+
22892
+ class SeamlyGeneralError extends SeamlyBaseError {
22893
+ constructor(originalError, ...params) {
22894
+ super(originalError, ...params);
22821
22895
  this.name = 'SeamlyGeneralError';
22822
22896
  this.langKey = 'errors.general';
22823
22897
  this.action = 'reset';
@@ -22825,59 +22899,62 @@ class SeamlyGeneralError extends Error {
22825
22899
 
22826
22900
  }
22827
22901
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-configuration-error.js
22828
- class SeamlyConfigurationError extends Error {
22829
- constructor(params) {
22830
- super(params);
22831
-
22832
- if (Error.captureStackTrace) {
22833
- Error.captureStackTrace(this, SeamlyConfigurationError);
22834
- }
22835
22902
 
22903
+ class SeamlyConfigurationError extends SeamlyBaseError {
22904
+ constructor(originalError, ...params) {
22905
+ super(originalError, ...params);
22836
22906
  this.name = 'SeamlyConfigurationError';
22837
22907
  this.langKey = 'errors.configError';
22838
22908
  }
22839
22909
 
22840
22910
  }
22841
22911
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-session-expired-error.js
22842
- class SeamlySessionExpiredError extends Error {
22843
- constructor(params) {
22844
- super(params);
22845
-
22846
- if (Error.captureStackTrace) {
22847
- Error.captureStackTrace(this, SeamlySessionExpiredError);
22848
- }
22849
22912
 
22913
+ class SeamlySessionExpiredError extends SeamlyBaseError {
22914
+ constructor(originalError, ...params) {
22915
+ super(originalError, ...params);
22850
22916
  this.name = 'SeamlySessionExpiredError';
22851
22917
  this.action = 'reset';
22852
22918
  }
22853
22919
 
22854
22920
  }
22855
22921
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-offline-error.js
22856
- class SeamlyOfflineError extends Error {
22857
- constructor(params) {
22858
- super(params);
22859
-
22860
- if (Error.captureStackTrace) {
22861
- Error.captureStackTrace(this, SeamlyOfflineError);
22862
- }
22863
22922
 
22923
+ class SeamlyOfflineError extends SeamlyBaseError {
22924
+ constructor(originalError, ...params) {
22925
+ super(originalError, ...params);
22864
22926
  this.name = 'SeamlyOfflineError';
22865
22927
  this.langKey = 'errors.seamlyOffline';
22866
22928
  }
22867
22929
 
22868
22930
  }
22869
22931
  ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-unauthorized-error.js
22870
- class SeamlyUnauthorizedError extends Error {
22932
+
22933
+ class SeamlyUnauthorizedError extends SeamlyBaseError {
22934
+ constructor(originalError, ...params) {
22935
+ super(originalError, ...params);
22936
+ this.name = 'SeamlyUnauthorizedError';
22937
+ this.langKey = 'errors.general';
22938
+ this.action = 'reset';
22939
+ }
22940
+
22941
+ }
22942
+ ;// CONCATENATED MODULE: ./src/javascripts/api/errors/seamly-unavailable-error.js
22943
+ /**
22944
+ * This error is used to alert the user that there's a problem with the connection
22945
+ * when initialising the application because of a connection issue on either the server
22946
+ * or the client side.
22947
+ */
22948
+ class SeamlyUnavailableError extends Error {
22871
22949
  constructor(params) {
22872
22950
  super(params);
22873
22951
 
22874
22952
  if (Error.captureStackTrace) {
22875
- Error.captureStackTrace(this, SeamlyUnauthorizedError);
22953
+ Error.captureStackTrace(this, SeamlyUnavailableError);
22876
22954
  }
22877
22955
 
22878
- this.name = 'SeamlyUnauthorizedError';
22879
- this.langKey = 'errors.general';
22880
- this.action = 'reset';
22956
+ this.name = 'SeamlyUnavailableError';
22957
+ this.langKey = 'errors.seamlyUnavailable';
22881
22958
  }
22882
22959
 
22883
22960
  }
@@ -22889,81 +22966,201 @@ class SeamlyUnauthorizedError extends Error {
22889
22966
 
22890
22967
 
22891
22968
 
22892
- const handledErrorTypes = [SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError];
22893
- function middleware_createMiddleware() {
22969
+ const handledErrorTypes = [SeamlyGeneralError, SeamlyConfigurationError, SeamlySessionExpiredError, SeamlyOfflineError, SeamlyUnauthorizedError, SeamlyUnavailableError];
22970
+ function middleware_createMiddleware({
22971
+ api
22972
+ }) {
22894
22973
  return () => next => action => {
22895
- if (action.type === String(set)) {
22896
- if (!some_default()(handledErrorTypes).call(handledErrorTypes, ErrorType => action.error instanceof ErrorType)) {
22897
- throw action.error;
22974
+ const {
22975
+ error
22976
+ } = action;
22977
+
22978
+ if (error) {
22979
+ if (!some_default()(handledErrorTypes).call(handledErrorTypes, ErrorType => error instanceof ErrorType)) {
22980
+ throw error;
22981
+ } else if (error.action === 'reset') {
22982
+ // [SMLY-942] We clear the store before a reset to force a new conversation if the page is refreshed before the conversation is reset
22983
+ api.disconnect().then(() => {
22984
+ api.clearStore();
22985
+ });
22898
22986
  }
22899
22987
  }
22900
22988
 
22901
22989
  return next(action);
22902
22990
  };
22903
22991
  }
22904
- ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/reducer.js
22992
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/app/utils.js
22993
+
22994
+ const {
22995
+ createAction: app_utils_createAction,
22996
+ createThunk: app_utils_createThunk,
22997
+ createReducer: app_utils_createReducer,
22998
+ selectState: app_utils_selectState
22999
+ } = createDomain('app');
23000
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/app/selectors.js
23001
+
23002
+
23003
+ const selectUserHasResponded = createSelector(app_utils_selectState, state => state.userHasResponded);
23004
+
23005
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/utils.js
23006
+
23007
+
23008
+ const {
23009
+ createAction: visibility_utils_createAction,
23010
+ createActions: utils_createActions,
23011
+ createThunk: visibility_utils_createThunk,
23012
+ createReducer: visibility_utils_createReducer,
23013
+ selectState: visibility_utils_selectState
23014
+ } = createDomain('visibility');
23015
+ const calculateVisibility = ({
23016
+ hasResponded,
23017
+ previousVisibility,
23018
+ requestedVisibility,
23019
+ config
23020
+ }) => {
23021
+ const {
23022
+ defaults,
23023
+ layoutMode,
23024
+ hideOnNoUserResponse
23025
+ } = config;
23026
+ const {
23027
+ visible: defaultVisibility
23028
+ } = defaults || {}; // Requesting open should override the responded check.
22905
23029
 
23030
+ if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
23031
+ return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
23032
+ }
22906
23033
 
23034
+ const baseVisibility = layoutMode === 'inline' ? visibilityStates.open : visibilityStates.minimized;
23035
+ return requestedVisibility || previousVisibility || defaultVisibility || baseVisibility;
23036
+ };
23037
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/selectors.js
22907
23038
 
22908
23039
 
23040
+ const selectVisibility = createSelector(visibility_utils_selectState, state => state.visibility);
22909
23041
 
23042
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/actions.js
22910
23043
 
22911
23044
 
22912
23045
 
22913
23046
 
22914
23047
 
22915
- function interrupt_reducer_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
22916
23048
 
22917
- function interrupt_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = interrupt_reducer_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = interrupt_reducer_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
22918
23049
 
22919
23050
 
22920
23051
 
22921
- const reducer_initialState = {
22922
- error: undefined
22923
- };
22924
- /* harmony default export */ var interrupt_reducer = (interrupt_utils_createReducer({
22925
- [set]: (state, {
22926
- error
22927
- }) => {
22928
- return interrupt_reducer_objectSpread(interrupt_reducer_objectSpread({}, state), {}, {
22929
- error
22930
- });
22931
- },
22932
- [clear]: () => {
22933
- return reducer_initialState;
23052
+
23053
+ function actions_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23054
+
23055
+ function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = actions_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = actions_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
23056
+
23057
+
23058
+
23059
+
23060
+
23061
+
23062
+
23063
+
23064
+ const setFromStorage = visibility_utils_createAction('setFromStorage', visibility => ({
23065
+ visibility
23066
+ }));
23067
+ const validVisibilityStates = [visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden];
23068
+ const actions_setVisibility = visibility_utils_createThunk('set', (requestedVisibility, {
23069
+ getState,
23070
+ extra: {
23071
+ api,
23072
+ eventBus
22934
23073
  }
22935
- }, reducer_initialState));
22936
- ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/index.js
23074
+ }) => {
23075
+ const state = getState();
23076
+ const previousVisibility = selectVisibility(state);
23077
+ const hasResponded = selectUserHasResponded(state);
23078
+ const hasConversation = api.hasConversation();
23079
+ const config = selectConfig(state);
23080
+ const {
23081
+ visibilityCallback = calculateVisibility,
23082
+ layoutMode
23083
+ } = config;
23084
+ const {
23085
+ unreadEvents: unreadMessageCount
23086
+ } = seamly_state_hooks_selectState(state);
23087
+ const calculatedVisibility = visibilityCallback({
23088
+ hasConversation,
23089
+ hasResponded,
23090
+ previousVisibility,
23091
+ requestedVisibility,
23092
+ config
23093
+ });
23094
+
23095
+ if (!includes_default()(validVisibilityStates).call(validVisibilityStates, calculatedVisibility)) {
23096
+ console.error('The visibilityCallback function should return "open", "minimized" or "hidden".');
23097
+ return undefined;
23098
+ }
23099
+
23100
+ if (previousVisibility === calculatedVisibility) {
23101
+ return undefined;
23102
+ } // Store the user-requested visibility in order to reinitialize after refresh
22937
23103
 
22938
23104
 
23105
+ api.store.set(StoreKey, actions_objectSpread(actions_objectSpread({}, api.store.get(StoreKey) || {}), {}, {
23106
+ [layoutMode]: requestedVisibility
23107
+ }));
22939
23108
 
23109
+ if (requestedVisibility) {
23110
+ eventBus.emit('ui.visible', requestedVisibility, {
23111
+ visibility: requestedVisibility,
23112
+ hasConversation,
23113
+ hasResponded,
23114
+ unreadMessageCount
23115
+ });
23116
+ }
22940
23117
 
23118
+ return calculatedVisibility;
23119
+ });
23120
+ const actions_initialize = visibility_utils_createThunk('initialize', async (locale, {
23121
+ dispatch,
23122
+ getState,
23123
+ extra: {
23124
+ api
23125
+ }
23126
+ }) => {
23127
+ var _api$store$get;
22941
23128
 
23129
+ // initialize stored visibility
23130
+ const {
23131
+ layoutMode
23132
+ } = selectConfig(getState());
23133
+ const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
22942
23134
 
22943
- ;// CONCATENATED MODULE: ./src/javascripts/domains/app/utils.js
23135
+ if (storedVisibility) {
23136
+ dispatch(setFromStorage(storedVisibility));
23137
+ }
22944
23138
 
22945
- const {
22946
- createAction: app_utils_createAction,
22947
- createThunk: app_utils_createThunk,
22948
- createReducer: app_utils_createReducer,
22949
- selectState: app_utils_selectState
22950
- } = createDomain('app');
23139
+ dispatch(actions_setVisibility(visibilityStates.initialize));
23140
+ });
22951
23141
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/actions.js
22952
23142
 
22953
23143
 
22954
23144
 
22955
23145
 
22956
23146
 
23147
+
23148
+
22957
23149
  const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
22958
23150
  hasResponded
22959
23151
  }));
22960
- const actions_initialize = app_utils_createThunk('initialize', config => async (dispatch, getState, {
22961
- api
23152
+ const app_actions_initialize = app_utils_createThunk('initialize', async (config, {
23153
+ dispatch,
23154
+ extra: {
23155
+ api
23156
+ }
22962
23157
  }) => {
22963
- try {
22964
- var _config$context;
23158
+ var _config$context;
22965
23159
 
22966
- dispatch(initialize(config));
23160
+ dispatch(initialize(config));
23161
+ let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
23162
+
23163
+ try {
22967
23164
  const {
22968
23165
  features,
22969
23166
  defaultLocale
@@ -22972,38 +23169,39 @@ const actions_initialize = app_utils_createThunk('initialize', config => async (
22972
23169
  type: seamlyActions.SET_FEATURES,
22973
23170
  features
22974
23171
  });
22975
- let locale = (config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale) || defaultLocale;
23172
+ locale = locale || defaultLocale;
22976
23173
  dispatch(setInitialLocale(locale));
23174
+ } catch (e) {
23175
+ throw new SeamlyUnavailableError();
23176
+ }
22977
23177
 
22978
- try {
22979
- if (api.hasConversation()) {
22980
- var _initialState$transla;
23178
+ try {
23179
+ if (api.hasConversation()) {
23180
+ var _initialState$transla;
22981
23181
 
22982
- const initialState = await api.getConversationIntitialState();
22983
- dispatch({
22984
- type: seamlyActions.SET_INITIAL_STATE,
22985
- initialState
22986
- });
22987
- locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
23182
+ const initialState = await api.getConversationIntitialState();
23183
+ dispatch({
23184
+ type: seamlyActions.SET_INITIAL_STATE,
23185
+ initialState
23186
+ });
23187
+ locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
22988
23188
 
22989
- if ('userResponded' in initialState) {
22990
- dispatch(setHasResponded(initialState.userResponded));
22991
- }
23189
+ if ('userResponded' in initialState) {
23190
+ dispatch(setHasResponded(initialState.userResponded));
22992
23191
  }
22993
- } catch (error) {
22994
- dispatch(set(error));
23192
+ }
23193
+ } catch (e) {
23194
+ if (e instanceof SeamlySessionExpiredError) {
23195
+ throw e;
22995
23196
  }
22996
23197
 
23198
+ throw new SeamlyUnavailableError();
23199
+ } finally {
22997
23200
  await dispatch(setLocale(locale));
22998
- } catch (error) {
22999
- dispatch(set(error));
23201
+ dispatch(actions_initialize());
23000
23202
  }
23001
23203
  });
23002
- ;// CONCATENATED MODULE: ./src/javascripts/domains/app/selectors.js
23003
-
23004
-
23005
- const selectUserHasResponded = createSelector(app_utils_selectState, state => state.userHasResponded);
23006
-
23204
+ const actions_reset = app_utils_createAction('reset', () => {});
23007
23205
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/hooks.js
23008
23206
 
23009
23207
 
@@ -23027,7 +23225,7 @@ function app_reducer_objectSpread(target) { for (var i = 1; i < arguments.length
23027
23225
 
23028
23226
 
23029
23227
 
23030
- const app_reducer_initialState = {
23228
+ const reducer_initialState = {
23031
23229
  userHasResponded: false
23032
23230
  };
23033
23231
  /* harmony default export */ var app_reducer = (app_utils_createReducer({
@@ -23036,12 +23234,118 @@ const app_reducer_initialState = {
23036
23234
  }) => app_reducer_objectSpread(app_reducer_objectSpread({}, state), {}, {
23037
23235
  userHasResponded: hasResponded
23038
23236
  })
23039
- }, app_reducer_initialState));
23237
+ }, reducer_initialState));
23040
23238
  ;// CONCATENATED MODULE: ./src/javascripts/domains/app/index.js
23041
23239
 
23042
23240
 
23043
23241
 
23044
23242
 
23243
+
23244
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/reducer.js
23245
+
23246
+
23247
+
23248
+
23249
+
23250
+
23251
+
23252
+
23253
+
23254
+
23255
+ function interrupt_reducer_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23256
+
23257
+ function interrupt_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = interrupt_reducer_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = interrupt_reducer_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
23258
+
23259
+
23260
+
23261
+
23262
+ const interrupt_reducer_initialState = {
23263
+ error: undefined
23264
+ };
23265
+
23266
+ const handleError = (state, {
23267
+ error
23268
+ }) => interrupt_reducer_objectSpread(interrupt_reducer_objectSpread({}, state), {}, {
23269
+ error
23270
+ });
23271
+
23272
+ /* harmony default export */ var interrupt_reducer = (interrupt_utils_createReducer({
23273
+ [set]: handleError,
23274
+ [app_actions_initialize.rejected]: handleError,
23275
+ [clear]: () => interrupt_reducer_initialState,
23276
+ [actions_reset]: () => interrupt_reducer_initialState
23277
+ }, interrupt_reducer_initialState));
23278
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/interrupt/index.js
23279
+
23280
+
23281
+
23282
+
23283
+
23284
+
23285
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/hooks.js
23286
+
23287
+
23288
+
23289
+
23290
+
23291
+
23292
+ const useVisibility = () => {
23293
+ const dispatch = useStoreDispatch();
23294
+ const visible = useSelector(selectVisibility);
23295
+ const isVisible = visible ? visible !== visibilityStates.hidden : false;
23296
+ const {
23297
+ layoutMode
23298
+ } = useConfig();
23299
+ const isOpen = visible && layoutMode ? visible === visibilityStates.open || layoutMode === 'inline' && visible !== visibilityStates.hidden : false;
23300
+ const setVisibility = F(visibility => dispatch(actions_setVisibility(visibility)), [dispatch]);
23301
+ return {
23302
+ isVisible,
23303
+ isOpen,
23304
+ visible,
23305
+ setVisibility
23306
+ };
23307
+ };
23308
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/reducer.js
23309
+
23310
+
23311
+
23312
+
23313
+
23314
+
23315
+
23316
+
23317
+
23318
+
23319
+ function visibility_reducer_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23320
+
23321
+ function visibility_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = visibility_reducer_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = visibility_reducer_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
23322
+
23323
+
23324
+
23325
+
23326
+ const visibility_reducer_initialState = {
23327
+ visibility: visibilityStates.initialize
23328
+ };
23329
+ /* harmony default export */ var visibility_reducer = (visibility_utils_createReducer({
23330
+ [setFromStorage]: (state, {
23331
+ visibility
23332
+ }) => visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
23333
+ visibility
23334
+ }),
23335
+ [actions_setVisibility.fulfilled]: (state, {
23336
+ payload: visibility
23337
+ }) => visibility ? visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
23338
+ visibility
23339
+ }) : state
23340
+ }, visibility_reducer_initialState));
23341
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/index.js
23342
+
23343
+
23344
+
23345
+
23346
+
23347
+
23348
+
23045
23349
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-commands.js
23046
23350
 
23047
23351
 
@@ -23075,15 +23379,10 @@ function use_seamly_commands_objectSpread(target) { for (var i = 1; i < argument
23075
23379
 
23076
23380
  const {
23077
23381
  ADD_EVENT: use_seamly_commands_ADD_EVENT,
23078
- CLEAR_EVENTS: use_seamly_commands_CLEAR_EVENTS,
23079
23382
  SET_IS_LOADING: use_seamly_commands_SET_IS_LOADING,
23080
- CLEAR_PARTICIPANTS: use_seamly_commands_CLEAR_PARTICIPANTS,
23081
23383
  SET_HEADER_SUB_TITLE: use_seamly_commands_SET_HEADER_SUB_TITLE,
23082
23384
  SET_INITIAL_STATE: use_seamly_commands_SET_INITIAL_STATE,
23083
- CLEAR_FEATURES: use_seamly_commands_CLEAR_FEATURES,
23084
- SET_FEATURES: use_seamly_commands_SET_FEATURES,
23085
- RESET_UPLOAD_STATE: use_seamly_commands_RESET_UPLOAD_STATE,
23086
- RESET_ENTRY_STATE: use_seamly_commands_RESET_ENTRY_STATE
23385
+ SET_FEATURES: use_seamly_commands_SET_FEATURES
23087
23386
  } = seamlyActions;
23088
23387
 
23089
23388
  const useSeamlyCommands = () => {
@@ -23095,7 +23394,7 @@ const useSeamlyCommands = () => {
23095
23394
  const hasConversation = useSeamlyHasConversation();
23096
23395
  const {
23097
23396
  visible: visibility
23098
- } = useSeamlyStateContext();
23397
+ } = useVisibility();
23099
23398
  const unreadMessageCount = useSeamlyUnreadCount();
23100
23399
  const emitEvent = F((...args) => {
23101
23400
  eventBus.emit(...args);
@@ -23117,26 +23416,12 @@ const useSeamlyCommands = () => {
23117
23416
  });
23118
23417
  }, [api, appConfig, emitEvent, hasResponded, hasConversation, visibility, unreadMessageCount]);
23119
23418
  const reset = F(async () => {
23419
+ dispatch(actions_reset());
23120
23420
  dispatch(clear());
23121
- dispatch({
23122
- type: use_seamly_commands_CLEAR_EVENTS
23123
- });
23124
23421
  dispatch({
23125
23422
  type: use_seamly_commands_SET_IS_LOADING,
23126
23423
  isLoading: true
23127
23424
  });
23128
- dispatch({
23129
- type: use_seamly_commands_CLEAR_PARTICIPANTS
23130
- });
23131
- dispatch({
23132
- type: use_seamly_commands_RESET_UPLOAD_STATE
23133
- });
23134
- dispatch({
23135
- type: use_seamly_commands_RESET_ENTRY_STATE
23136
- });
23137
- dispatch({
23138
- type: use_seamly_commands_CLEAR_FEATURES
23139
- });
23140
23425
  const {
23141
23426
  agentName
23142
23427
  } = appConfig.defaults || {};
@@ -23188,21 +23473,13 @@ const useSeamlyCommands = () => {
23188
23473
 
23189
23474
  const message = use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, getTextMessageBase(body)), config);
23190
23475
 
23191
- const sanitizedText = sanitizeText(body);
23192
-
23193
- const sanitizedMessage = use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, message), {}, {
23194
- body: {
23195
- text: sanitizedText
23196
- }
23197
- });
23198
-
23199
23476
  api.send('message', message);
23200
23477
  emitEvent('message', message);
23201
23478
  dispatch({
23202
23479
  type: use_seamly_commands_ADD_EVENT,
23203
23480
  event: {
23204
23481
  type: 'message',
23205
- payload: sanitizedMessage
23482
+ payload: message
23206
23483
  }
23207
23484
  });
23208
23485
  }, [api, dispatch, emitEvent, getTextMessageBase]);
@@ -23498,132 +23775,6 @@ const useSeamlyEntry = () => {
23498
23775
  setBlockAutoEntrySwitch
23499
23776
  };
23500
23777
  };
23501
- ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-stored-visibility.js
23502
-
23503
-
23504
-
23505
-
23506
-
23507
-
23508
-
23509
-
23510
-
23511
-
23512
- function use_seamly_stored_visibility_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
23513
-
23514
- 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) { var _context; for_each_default()(_context = use_seamly_stored_visibility_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = use_seamly_stored_visibility_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
23515
-
23516
-
23517
-
23518
-
23519
-
23520
- const useSeamlyStoredVisibility = () => {
23521
- const {
23522
- layoutMode
23523
- } = useConfig();
23524
- const key = 'visibility';
23525
- const {
23526
- get,
23527
- set
23528
- } = useSeamlyObjectStore();
23529
- let storedVisibilityObj = {};
23530
- const savedVisibility = get ? get(key) : {};
23531
-
23532
- if (savedVisibility) {
23533
- storedVisibilityObj = savedVisibility;
23534
- }
23535
-
23536
- const setStoredVisibility = F(state => {
23537
- const saved = get ? get(key) : {};
23538
- set(key, use_seamly_stored_visibility_objectSpread(use_seamly_stored_visibility_objectSpread({}, saved), {}, {
23539
- [layoutMode]: state
23540
- }));
23541
- }, [set, get, layoutMode]);
23542
- return [layoutMode ? storedVisibilityObj[layoutMode] : null, set && layoutMode ? setStoredVisibility : null];
23543
- };
23544
-
23545
- /* harmony default export */ var use_seamly_stored_visibility = (useSeamlyStoredVisibility);
23546
- ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-visibility.js
23547
-
23548
-
23549
-
23550
-
23551
-
23552
-
23553
-
23554
-
23555
-
23556
-
23557
- const {
23558
- SET_VISIBILITY: use_seamly_visibility_SET_VISIBILITY
23559
- } = seamlyActions;
23560
-
23561
- const useSeamlyVisibility = () => {
23562
- const config = useConfig();
23563
- const {
23564
- layoutMode,
23565
- visibilityCallback
23566
- } = config;
23567
- const {
23568
- visible
23569
- } = useSeamlyStateContext();
23570
- const {
23571
- emitEvent
23572
- } = use_seamly_commands();
23573
- const dispatch = use_seamly_dispatch();
23574
- const [storedVisibility, setStoredVisibility] = use_seamly_stored_visibility();
23575
- const hasResponded = useUserHasResponded();
23576
- const hasConversation = useSeamlyHasConversation();
23577
- const unreadMessageCount = useSeamlyUnreadCount();
23578
- const isVisible = visible ? visible !== visibilityStates.hidden : false;
23579
- const isOpen = visible && layoutMode ? visible === visibilityStates.open || layoutMode === 'inline' && visible !== visibilityStates.hidden : false;
23580
- const setVisibility = F(visibility => {
23581
- var _context;
23582
-
23583
- const visibilityFn = visibilityCallback || calculateVisibility;
23584
- const requestedVisibility = visibilityFn({
23585
- hasConversation,
23586
- hasResponded,
23587
- previousVisibility: storedVisibility || null,
23588
- requestedVisibility: visibility,
23589
- config
23590
- });
23591
-
23592
- if (!includes_default()(_context = [visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden]).call(_context, requestedVisibility)) {
23593
- console.error('The visibilityCallback function should return "open", "minimized" or "hidden".');
23594
- return;
23595
- }
23596
-
23597
- if (requestedVisibility !== visible) {
23598
- if (setStoredVisibility) {
23599
- setStoredVisibility(requestedVisibility);
23600
- } // Don't broadcast the init visibility state
23601
-
23602
-
23603
- if (visibility) {
23604
- emitEvent('ui.visible', requestedVisibility, {
23605
- visibility: requestedVisibility,
23606
- hasConversation,
23607
- hasResponded,
23608
- unreadMessageCount
23609
- });
23610
- }
23611
-
23612
- dispatch({
23613
- type: use_seamly_visibility_SET_VISIBILITY,
23614
- visible: requestedVisibility
23615
- });
23616
- }
23617
- }, [visible, emitEvent, dispatch, hasConversation, hasResponded, storedVisibility, visibilityCallback, config, setStoredVisibility, unreadMessageCount]);
23618
- return {
23619
- isVisible,
23620
- isOpen,
23621
- visible,
23622
- setVisibility
23623
- };
23624
- };
23625
-
23626
- /* harmony default export */ var use_seamly_visibility = (useSeamlyVisibility);
23627
23778
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-chat.js
23628
23779
 
23629
23780
 
@@ -23646,9 +23797,8 @@ const useSeamlyChat = () => {
23646
23797
  const {
23647
23798
  isOpen,
23648
23799
  isVisible,
23649
- visible,
23650
23800
  setVisibility
23651
- } = use_seamly_visibility();
23801
+ } = useVisibility();
23652
23802
  const dispatch = use_seamly_dispatch();
23653
23803
  const events = useEvents();
23654
23804
  const spinnerTimeout = hooks_module_s(null);
@@ -23692,7 +23842,6 @@ const useSeamlyChat = () => {
23692
23842
  prevIsOpen.current = isOpen;
23693
23843
  prevIsVisible.current = isVisible;
23694
23844
  }, [isOpen, isVisible, sendAssertive, t]);
23695
- hooks_module_y(() => {}, [visible, sendAssertive]);
23696
23845
  hooks_module_y(() => {
23697
23846
  // This delays the start of the loading inidicator we set when we initialise
23698
23847
  // the application. This is done to only avoid BSOD on initial load if DCX is slow.
@@ -23798,7 +23947,7 @@ const useSeamlyIdleDetachCountdown = () => {
23798
23947
  } = useSeamlyStateContext();
23799
23948
  const {
23800
23949
  isOpen: isSeamlyOpen
23801
- } = use_seamly_visibility();
23950
+ } = useVisibility();
23802
23951
  const stableState = hooks_module_s({});
23803
23952
  stableState.current = {
23804
23953
  hasCountdown: idleDetachCountdown.hasCountdown,
@@ -23998,8 +24147,6 @@ const useSeamlyResumeConversationPrompt = () => {
23998
24147
 
23999
24148
 
24000
24149
 
24001
-
24002
-
24003
24150
  // This hook isn't used within the core
24004
24151
  // But it is used in implementations
24005
24152
  // and imported directly from this file
@@ -24174,7 +24321,7 @@ const ModalWrapper = ({
24174
24321
  const {
24175
24322
  isOpen,
24176
24323
  setVisibility
24177
- } = use_seamly_visibility();
24324
+ } = useVisibility();
24178
24325
  const container = hooks_module_s(null);
24179
24326
  const focusTrap = hooks_module_s(null);
24180
24327
 
@@ -25121,11 +25268,11 @@ function updateFormControl(state, formId, name, controlState) {
25121
25268
 
25122
25269
 
25123
25270
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/assign.js
25124
- var object_assign = __webpack_require__(2088);
25271
+ var core_js_object_assign = __webpack_require__(2088);
25125
25272
  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/extends.js
25126
25273
 
25127
25274
  function _extends() {
25128
- _extends = object_assign || function (target) {
25275
+ _extends = core_js_object_assign || function (target) {
25129
25276
  for (var i = 1; i < arguments.length; i++) {
25130
25277
  var source = arguments[i];
25131
25278
 
@@ -26036,7 +26183,7 @@ const AppFrame = ({
26036
26183
  isOpen,
26037
26184
  isVisible,
26038
26185
  setVisibility
26039
- } = use_seamly_visibility();
26186
+ } = useVisibility();
26040
26187
  const {
26041
26188
  zIndex,
26042
26189
  showFaq
@@ -26793,7 +26940,7 @@ function ChatFrame({
26793
26940
  } = useInterrupt();
26794
26941
  const {
26795
26942
  isOpen
26796
- } = use_seamly_visibility();
26943
+ } = useVisibility();
26797
26944
 
26798
26945
  const getContent = () => {
26799
26946
  if (hasInterrupt) {
@@ -26825,6 +26972,7 @@ function ChatFrame({
26825
26972
 
26826
26973
 
26827
26974
 
26975
+
26828
26976
  const ToggleButton = ({
26829
26977
  onOpenChat
26830
26978
  }) => {
@@ -26834,7 +26982,7 @@ const ToggleButton = ({
26834
26982
  const titleId = useGeneratedId();
26835
26983
  const {
26836
26984
  isOpen
26837
- } = use_seamly_visibility();
26985
+ } = useVisibility();
26838
26986
  const prevIsOpen = hooks_module_s(null);
26839
26987
  const buttonRef = hooks_module_s(null);
26840
26988
  const lastEventRef = hooks_module_s();
@@ -26915,6 +27063,7 @@ const ToggleButton = ({
26915
27063
 
26916
27064
 
26917
27065
 
27066
+
26918
27067
  const AgentInfo = () => {
26919
27068
  const {
26920
27069
  t
@@ -26926,7 +27075,7 @@ const AgentInfo = () => {
26926
27075
  const unreadMessageCount = useSeamlyUnreadCount();
26927
27076
  const {
26928
27077
  isOpen
26929
- } = use_seamly_visibility();
27078
+ } = useVisibility();
26930
27079
  const currentAgent = useSeamlyCurrentAgent();
26931
27080
  const {
26932
27081
  hasInterrupt
@@ -28430,7 +28579,6 @@ mustache.Writer = Writer;
28430
28579
 
28431
28580
 
28432
28581
 
28433
-
28434
28582
  mustache_mustache.escape = function (escapeText) {
28435
28583
  return escapeText;
28436
28584
  };
@@ -28439,7 +28587,7 @@ const parseLinkVariable = variable => {
28439
28587
  return `<a href='${variable.url}' data-link-id='${variable.id}' ${variable.newTab ? 'target="_blank"' : ''}>${variable.name}</a>`;
28440
28588
  };
28441
28589
 
28442
- function parseRichtText(text, variables = {}) {
28590
+ function parseRichText(text, variables = {}) {
28443
28591
  var _context;
28444
28592
 
28445
28593
  const view = {};
@@ -28467,15 +28615,6 @@ function parseRichtText(text, variables = {}) {
28467
28615
  mustache_mustache.escape = oldEscape;
28468
28616
  return output;
28469
28617
  }
28470
-
28471
- const useTextRendering = ({
28472
- text,
28473
- variables = {}
28474
- }) => {
28475
- return hooks_module_A(() => parseRichtText(text, variables), [text, variables]);
28476
- };
28477
-
28478
- /* harmony default export */ var use_text_rendering = (useTextRendering);
28479
28618
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/text.js
28480
28619
 
28481
28620
 
@@ -28500,32 +28639,37 @@ function text_objectSpread(target) { for (var i = 1; i < arguments.length; i++)
28500
28639
 
28501
28640
 
28502
28641
 
28642
+
28503
28643
  const Text = _ref => {
28504
28644
  let {
28505
28645
  event
28506
28646
  } = _ref,
28507
28647
  props = _objectWithoutProperties(_ref, text_excluded);
28508
28648
 
28509
- const {
28510
- payload
28511
- } = event;
28512
28649
  const [body] = useTranslatedEventData(event);
28513
- const eventClick = use_event_link_click_handler(payload.id);
28514
- const eventBody = use_text_rendering({
28515
- text: parse_body(body.text),
28516
- variables: body.variables
28517
- });
28650
+ const eventClick = use_event_link_click_handler(event.payload.id);
28651
+ const containerProps = hooks_module_A(() => {
28652
+ if (!event.payload.fromClient) {
28653
+ return {
28654
+ bodyProps: {
28655
+ dangerouslySetInnerHTML: {
28656
+ __html: parseRichText(parse_body(body.text), body.variables)
28657
+ }
28658
+ }
28659
+ };
28660
+ }
28661
+
28662
+ return {
28663
+ children: jsxRuntime_module_e("p", {
28664
+ children: body.text
28665
+ })
28666
+ };
28667
+ }, [body, event]);
28518
28668
  return jsxRuntime_module_e(message_container, text_objectSpread(text_objectSpread({
28519
28669
  type: "text",
28520
28670
  event: event,
28521
28671
  onClick: eventClick
28522
- }, props), {}, {
28523
- bodyProps: {
28524
- dangerouslySetInnerHTML: {
28525
- __html: eventBody
28526
- }
28527
- }
28528
- }));
28672
+ }, props), containerProps));
28529
28673
  };
28530
28674
 
28531
28675
  /* harmony default export */ var event_text = (Text);
@@ -29775,6 +29919,7 @@ const PrivacyDisclaimer = () => {
29775
29919
 
29776
29920
 
29777
29921
 
29922
+
29778
29923
  const Conversation = () => {
29779
29924
  const {
29780
29925
  t
@@ -29784,7 +29929,7 @@ const Conversation = () => {
29784
29929
  const isLoading = useSeamlyIsLoading();
29785
29930
  const {
29786
29931
  isOpen
29787
- } = use_seamly_visibility();
29932
+ } = useVisibility();
29788
29933
  const skiplinkTargetId = useSkiplink();
29789
29934
  const focusSkiplinkTarget = useSkiplinkTargetFocusing();
29790
29935
  hooks_module_y(() => {
@@ -30891,10 +31036,11 @@ const Interrupt = ({
30891
31036
 
30892
31037
 
30893
31038
 
31039
+
30894
31040
  const View = () => {
30895
31041
  const {
30896
31042
  isVisible
30897
- } = use_seamly_visibility();
31043
+ } = useVisibility();
30898
31044
  const {
30899
31045
  openChat,
30900
31046
  closeChat
@@ -30960,7 +31106,7 @@ const SeamlyInstanceFunctionsLoader = () => {
30960
31106
  const {
30961
31107
  setVisibility,
30962
31108
  visible
30963
- } = use_seamly_visibility();
31109
+ } = useVisibility();
30964
31110
  const currentVisibility = hooks_module_s(visible);
30965
31111
  const eventBus = hooks_module_T(SeamlyEventBusContext);
30966
31112
  const api = useSeamlyApiContext();
@@ -31088,6 +31234,7 @@ const SeamlyInstanceFunctionsLoader = () => {
31088
31234
 
31089
31235
 
31090
31236
 
31237
+
31091
31238
  const {
31092
31239
  SET_EVENTS_READ: seamly_read_state_SET_EVENTS_READ
31093
31240
  } = seamlyActions;
@@ -31101,7 +31248,7 @@ const SeamlyReadState = () => {
31101
31248
  const {
31102
31249
  isOpen,
31103
31250
  isVisible
31104
- } = use_seamly_visibility();
31251
+ } = useVisibility();
31105
31252
  const {
31106
31253
  sendAction
31107
31254
  } = use_seamly_commands();
@@ -31160,6 +31307,7 @@ const SeamlyReadState = () => {
31160
31307
 
31161
31308
 
31162
31309
 
31310
+
31163
31311
  const SeamlyNewNotifications = () => {
31164
31312
  const {
31165
31313
  t
@@ -31173,7 +31321,7 @@ const SeamlyNewNotifications = () => {
31173
31321
  } = useLiveRegion();
31174
31322
  const {
31175
31323
  isOpen
31176
- } = use_seamly_visibility();
31324
+ } = useVisibility();
31177
31325
  const prevIsOpen = hooks_module_s(null);
31178
31326
  const debounceFunc = hooks_module_s(null);
31179
31327
  const notifyUnread = hooks_module_A(() => {
@@ -31391,23 +31539,18 @@ const SeamlyActivityMonitor = ({
31391
31539
 
31392
31540
 
31393
31541
 
31394
-
31395
31542
  const SeamlyInitializer = () => {
31396
31543
  const {
31397
31544
  initUserSelectedOptions
31398
31545
  } = useSeamlyOptions();
31399
31546
  const seamlyInitialized = hooks_module_s(false);
31400
- const {
31401
- setVisibility
31402
- } = use_seamly_visibility();
31403
31547
  const config = useConfig();
31404
31548
  hooks_module_y(() => {
31405
31549
  if (config.api && !seamlyInitialized.current) {
31406
31550
  seamlyInitialized.current = true;
31407
31551
  initUserSelectedOptions();
31408
- setVisibility(visibilityStates.initialize);
31409
31552
  }
31410
- }, [initUserSelectedOptions, config, setVisibility]);
31553
+ }, [initUserSelectedOptions, config]);
31411
31554
  return null;
31412
31555
  };
31413
31556
 
@@ -31639,18 +31782,18 @@ const SeamlyEventSubscriber = ({
31639
31782
  case 'error':
31640
31783
  switch (payload.type) {
31641
31784
  case 'find_conversation_erred':
31642
- dispatch(set(new SeamlySessionExpiredError()));
31785
+ dispatch(set(new SeamlySessionExpiredError(event)));
31643
31786
  break;
31644
31787
 
31645
31788
  case 'seamly_offline':
31646
- dispatch(set(new SeamlyOfflineError()));
31789
+ dispatch(set(new SeamlyOfflineError(event)));
31647
31790
  dispatch({
31648
31791
  type: seamly_event_subscriber_CLEAR_EVENTS
31649
31792
  });
31650
31793
  break;
31651
31794
 
31652
31795
  default:
31653
- dispatch(set(new SeamlyGeneralError()));
31796
+ dispatch(set(new SeamlyGeneralError(event)));
31654
31797
  break;
31655
31798
  }
31656
31799
 
@@ -31823,6 +31966,50 @@ const SeamlyFileUpload = ({
31823
31966
  };
31824
31967
 
31825
31968
  /* harmony default export */ var seamly_file_upload = (SeamlyFileUpload);
31969
+ ;// CONCATENATED MODULE: ./src/javascripts/domains/errors/index.js
31970
+
31971
+
31972
+ const {
31973
+ createAction: errors_createAction
31974
+ } = createDomain('errors');
31975
+ const catchError = errors_createAction('catch-error', error => ({
31976
+ error
31977
+ }));
31978
+ function errors_createMiddleware({
31979
+ api: seamlyApi
31980
+ }) {
31981
+ return ({
31982
+ getState
31983
+ }) => {
31984
+ const handleError = error => {
31985
+ const {
31986
+ errorCallback,
31987
+ namespace,
31988
+ api,
31989
+ layoutMode
31990
+ } = selectConfig(getState());
31991
+ errorCallback === null || errorCallback === void 0 ? void 0 : errorCallback(error, {
31992
+ namespace,
31993
+ api,
31994
+ layoutMode,
31995
+ conversationUrl: seamlyApi.getConversationUrl()
31996
+ });
31997
+ };
31998
+
31999
+ return next => action => {
32000
+ try {
32001
+ if (action.error) {
32002
+ handleError(action.error);
32003
+ }
32004
+
32005
+ return next(action);
32006
+ } catch (error) {
32007
+ handleError(error);
32008
+ throw error;
32009
+ }
32010
+ };
32011
+ };
32012
+ }
31826
32013
  ;// CONCATENATED MODULE: ./src/javascripts/ui/components/core/seamly-core.js
31827
32014
 
31828
32015
 
@@ -31838,6 +32025,8 @@ const SeamlyFileUpload = ({
31838
32025
 
31839
32026
 
31840
32027
 
32028
+
32029
+
31841
32030
  const SeamlyCore = ({
31842
32031
  store,
31843
32032
  children,
@@ -31845,6 +32034,7 @@ const SeamlyCore = ({
31845
32034
  eventBus,
31846
32035
  api
31847
32036
  }) => {
32037
+ hooks_module_q(error => store.dispatch(catchError(error)));
31848
32038
  return jsxRuntime_module_e(StoreProvider, {
31849
32039
  store: store,
31850
32040
  children: jsxRuntime_module_e(SeamlyEventBusContext.Provider, {
@@ -33606,11 +33796,21 @@ class ConversationProducer {
33606
33796
  }
33607
33797
  ;// CONCATENATED MODULE: ./src/javascripts/lib/store/providers/session-storage.js
33608
33798
 
33799
+
33609
33800
  function store(key) {
33610
33801
  const KEY = 'cvco.' + key;
33611
33802
  return {
33612
33803
  get() {
33613
- return JSON.parse(sessionStorage.getItem(KEY));
33804
+ var _context;
33805
+
33806
+ const candidates = [KEY, slice_default()(_context = KEY.split('.')).call(_context, 0, -1).join('.')];
33807
+ let val;
33808
+
33809
+ do {
33810
+ val = sessionStorage.getItem(candidates[0]);
33811
+ } while (candidates.shift() && !val);
33812
+
33813
+ return JSON.parse(val);
33614
33814
  },
33615
33815
 
33616
33816
  set(value) {
@@ -33860,7 +34060,6 @@ class API {
33860
34060
  }) // withCredentials() is necessary to allow browsers to save received
33861
34061
  // cookies in CORS requests.
33862
34062
  .withCredentials().send({
33863
- authorizationRequired: true,
33864
34063
  externalId: this.externalId || undefined
33865
34064
  });
33866
34065
  const {
@@ -33881,7 +34080,7 @@ class API {
33881
34080
  return initialState;
33882
34081
  } catch (error) {
33883
34082
  if (error.status >= 500) {
33884
- throw new SeamlyGeneralError();
34083
+ throw new SeamlyGeneralError(error);
33885
34084
  }
33886
34085
 
33887
34086
  throw error;
@@ -33927,15 +34126,15 @@ class API {
33927
34126
  };
33928
34127
  } catch (error) {
33929
34128
  if (error.status === 401) {
33930
- throw new SeamlyUnauthorizedError();
34129
+ throw new SeamlyUnauthorizedError(error);
33931
34130
  }
33932
34131
 
33933
34132
  if (error.status === 404) {
33934
- throw new SeamlySessionExpiredError();
34133
+ throw new SeamlySessionExpiredError(error);
33935
34134
  }
33936
34135
 
33937
34136
  if (error.status >= 500) {
33938
- throw new SeamlyGeneralError();
34137
+ throw new SeamlyGeneralError(error);
33939
34138
  }
33940
34139
 
33941
34140
  throw error;
@@ -34000,11 +34199,11 @@ class API {
34000
34199
  return body.config;
34001
34200
  }).catch(error => {
34002
34201
  if (error.status === 404) {
34003
- throw new SeamlyConfigurationError();
34202
+ throw new SeamlyConfigurationError(error);
34004
34203
  }
34005
34204
 
34006
34205
  if (error.status >= 500) {
34007
- throw new SeamlyGeneralError();
34206
+ throw new SeamlyGeneralError(error);
34008
34207
  }
34009
34208
 
34010
34209
  throw error;
@@ -34021,15 +34220,15 @@ class API {
34021
34220
  return omit(body.conversation, ['accessToken', 'channelName']);
34022
34221
  }).catch(error => {
34023
34222
  if (error.status === 401) {
34024
- throw new SeamlyUnauthorizedError();
34223
+ throw new SeamlyUnauthorizedError(error);
34025
34224
  }
34026
34225
 
34027
34226
  if (error.status === 404) {
34028
- throw new SeamlySessionExpiredError();
34227
+ throw new SeamlySessionExpiredError(error);
34029
34228
  }
34030
34229
 
34031
34230
  if (error.status >= 500) {
34032
- throw new SeamlyGeneralError();
34231
+ throw new SeamlyGeneralError(error);
34033
34232
  }
34034
34233
 
34035
34234
  throw error;
@@ -34052,7 +34251,7 @@ class API {
34052
34251
  return body.translations;
34053
34252
  } catch (error) {
34054
34253
  if (error.status >= 500) {
34055
- throw new SeamlyGeneralError();
34254
+ throw new SeamlyGeneralError(error);
34056
34255
  }
34057
34256
 
34058
34257
  throw error;
@@ -34191,9 +34390,24 @@ function options_middleware_createMiddleware({
34191
34390
  ;// CONCATENATED MODULE: ./src/javascripts/domains/options/index.js
34192
34391
 
34193
34392
  ;// CONCATENATED MODULE: ./src/javascripts/domains/store/state-reducer.js
34393
+
34394
+
34395
+
34396
+
34397
+
34398
+
34399
+
34400
+
34401
+
34402
+
34403
+ function state_reducer_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); if (enumerableOnly) { symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
34404
+
34405
+ function state_reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; for_each_default()(_context = state_reducer_ownKeys(Object(source), true)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }); } else if ((get_own_property_descriptors_default())) { define_properties_default()(target, get_own_property_descriptors_default()(source)); } else { var _context2; for_each_default()(_context2 = state_reducer_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } } return target; }
34406
+
34194
34407
  // Legacy state reducer. Do not add new features here but extract/create new reducers as needed
34195
34408
 
34196
34409
 
34410
+
34197
34411
  const state_reducer_initialState = {
34198
34412
  events: [],
34199
34413
  initialState: {},
@@ -34204,7 +34418,6 @@ const state_reducer_initialState = {
34204
34418
  isActive: false
34205
34419
  },
34206
34420
  resumeConversationPrompt: false,
34207
- visible: visibilityStates.hidden,
34208
34421
  serviceInfo: {
34209
34422
  activeServiceSessionId: ''
34210
34423
  },
@@ -34241,6 +34454,15 @@ const state_reducer_initialState = {
34241
34454
  seamlyContainerElement: null
34242
34455
  };
34243
34456
  function stateReducer(state = state_reducer_initialState, action) {
34457
+ if (action.type === String(actions_reset)) {
34458
+ const {
34459
+ visible
34460
+ } = state;
34461
+ return state_reducer_objectSpread(state_reducer_objectSpread({}, state_reducer_initialState), {}, {
34462
+ visible
34463
+ });
34464
+ }
34465
+
34244
34466
  return seamlyStateReducer(state, action);
34245
34467
  }
34246
34468
  ;// CONCATENATED MODULE: ./src/javascripts/domains/store/index.js
@@ -34254,9 +34476,12 @@ function stateReducer(state = state_reducer_initialState, action) {
34254
34476
 
34255
34477
 
34256
34478
 
34479
+
34480
+
34257
34481
  function store_createStore({
34258
34482
  initialState,
34259
- api
34483
+ api,
34484
+ eventBus
34260
34485
  } = {}) {
34261
34486
  const store = createReduxStore({
34262
34487
  reducers: {
@@ -34266,12 +34491,18 @@ function store_createStore({
34266
34491
  [String(forms_reducer)]: forms_reducer,
34267
34492
  [String(translations_reducer)]: translations_reducer,
34268
34493
  [String(i18n_reducer)]: i18n_reducer,
34269
- [String(interrupt_reducer)]: interrupt_reducer
34494
+ [String(interrupt_reducer)]: interrupt_reducer,
34495
+ [String(visibility_reducer)]: visibility_reducer
34270
34496
  },
34271
34497
  initialState,
34272
- middlewares: [es.withExtraArgument({
34498
+ middlewares: [errors_createMiddleware({
34499
+ api
34500
+ }), es.withExtraArgument({
34501
+ api,
34502
+ eventBus
34503
+ }), createMiddleware(), middleware_createMiddleware({
34273
34504
  api
34274
- }), createMiddleware(), middleware_createMiddleware(), options_middleware_createMiddleware({
34505
+ }), options_middleware_createMiddleware({
34275
34506
  api
34276
34507
  }), translations_middleware_createMiddleware()]
34277
34508
  });
@@ -34349,9 +34580,10 @@ class Engine {
34349
34580
  });
34350
34581
 
34351
34582
  const store = store_createStore({
34352
- api: this.api
34583
+ api: this.api,
34584
+ eventBus: this.eventBus
34353
34585
  });
34354
- await store.dispatch(actions_initialize(renderConfig));
34586
+ await store.dispatch(app_actions_initialize(renderConfig));
34355
34587
 
34356
34588
  if (View) {
34357
34589
  S(jsxRuntime_module_e(seamly_core, {
@@ -34701,12 +34933,6 @@ function initializeExternalApi(appConfig) {
34701
34933
 
34702
34934
  // Used by: StyleGuide
34703
34935
 
34704
- // Used by: StyleGuide
34705
-
34706
- // Used by: StyleGuide
34707
-
34708
- // Used by: StyleGuide
34709
-
34710
34936
 
34711
34937
  }();
34712
34938
  /******/ return __webpack_exports__;