@xapp/chat-widget 1.80.0 → 1.81.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 (34) hide show
  1. package/dist/components/AdminBar/AdminBar.d.ts +0 -0
  2. package/dist/components/CardContainer/CardContainer.d.ts +0 -0
  3. package/dist/components/ChatActionButtons/ChatActionButton.d.ts +0 -0
  4. package/dist/components/ChatActionButtons/ChatActionButtons.d.ts +0 -0
  5. package/dist/components/ChatMedia/ChatMedia.d.ts +1 -1
  6. package/dist/components/ChatMessage/ChatMessage.d.ts +0 -0
  7. package/dist/components/ChatMessagePart/ChatMessagePart.d.ts +0 -0
  8. package/dist/components/ChatRating/ChatRating.d.ts +0 -0
  9. package/dist/components/Icons/CloseIcon.d.ts +0 -0
  10. package/dist/components/Icons/LeftDownArrowIcon.d.ts +0 -0
  11. package/dist/components/Icons/SendIcon.d.ts +0 -0
  12. package/dist/components/Input/Input.d.ts +0 -0
  13. package/dist/components/MessageList/MessageList.d.ts +0 -0
  14. package/dist/components/MessageSvg/MessageSvg.d.ts +0 -0
  15. package/dist/components/QueuePosition/QueuePosition.d.ts +0 -0
  16. package/dist/components/ServerOffline/ServerOffline.d.ts +0 -0
  17. package/dist/components/UknownMessage/UnknownMessage.d.ts +0 -0
  18. package/dist/index.css +1 -1
  19. package/dist/index.es.js +824 -712
  20. package/dist/index.es.js.map +1 -1
  21. package/dist/index.js +979 -867
  22. package/dist/index.js.map +1 -1
  23. package/dist/store/ChatAction.d.ts +0 -0
  24. package/dist/store/ChatState.d.ts +0 -0
  25. package/dist/store/actions/types.d.ts +0 -0
  26. package/dist/storybook/store.d.ts +2 -2
  27. package/dist/utils/useChatDispatch.d.ts +0 -0
  28. package/dist/xapp/ChatServer.d.ts +0 -0
  29. package/dist/xapp/LogChat.d.ts +0 -0
  30. package/dist/xapp/StentorRouterChat.d.ts +0 -0
  31. package/dist/xapp-chat-widget.css +1 -1
  32. package/dist/xapp-chat-widget.js +4 -5
  33. package/dist/xapp-chat-widget.js.map +1 -1
  34. package/package.json +23 -19
package/dist/index.es.js CHANGED
@@ -1,5 +1,6 @@
1
- import React$1, { useRef, useEffect, useCallback, createContext, useMemo, useContext, useState, useLayoutEffect } from 'react';
1
+ import require$$1, { useRef, useEffect, useCallback, createContext, useMemo, useContext, memo, useState, useLayoutEffect } from 'react';
2
2
  export { default as React } from 'react';
3
+ import require$$0, { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
4
  import { useSelector, useDispatch, Provider } from 'react-redux';
4
5
 
5
6
  var ActionButton = function (_a) {
@@ -10,7 +11,7 @@ var ActionButton = function (_a) {
10
11
  onClick(label);
11
12
  }
12
13
  }
13
- return (React$1.createElement("button", { disabled: disable, type: type, className: "action-button ".concat(addClass), onClick: handleClick }, label));
14
+ return (jsx("button", { disabled: disable, type: type, className: "action-button ".concat(addClass), onClick: handleClick, children: label }));
14
15
  };
15
16
 
16
17
  /******************************************************************************
@@ -402,22 +403,21 @@ var Avatar = function (props) {
402
403
  child = getVisitorSvg();
403
404
  }
404
405
  var hasImage = !!style.backgroundImage || !!child;
405
- return (React$1.createElement("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent" }, child));
406
+ return (jsx("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent", children: child }));
406
407
  };
407
408
  /**
408
409
  * Generates an SVG based on the
409
410
  * @returns
410
411
  */
411
412
  function getVisitorSvg() {
412
- return (React$1.createElement("svg", { width: "16", height: "19", viewBox: "0 0 16 19", style: { margin: "0 auto", display: "block" } },
413
- React$1.createElement("path", { d: "M11.5 5c0-1.933-1.567-3.5-3.5-3.5S4.5 3.067 4.5 5 6.067 8.5 8 8.5s3.5-1.567 3.5-3.5zM3 5c0-2.76 2.24-5 5-5s5 2.24 5 5-2.24 5-5 5-5-2.24-5-5zM1.955 17.294c.21-.642.504-1.285.898-1.88C3.963 13.74 5.615 12.75 8 12.75c2.385 0 4.038.99 5.147 2.664.394.595.69 1.238.898 1.88.124.382.19.672.214.822.063.41.447.69.856.625.41-.063.69-.447.625-.856-.034-.225-.118-.59-.27-1.053-.247-.763-.598-1.527-1.073-2.244C13.024 12.51 10.917 11.25 8 11.25c-2.916 0-5.024 1.26-6.397 3.336-.475.717-.826 1.48-1.074 2.245-.152.463-.236.83-.27 1.054-.065.41.215.793.624.857.41.065.793-.215.857-.624.025-.15.09-.44.215-.822z", fill: "#FFF", fillRule: "evenodd" })));
413
+ return (jsx("svg", { width: "16", height: "19", viewBox: "0 0 16 19", style: { margin: "0 auto", display: "block" }, children: jsx("path", { d: "M11.5 5c0-1.933-1.567-3.5-3.5-3.5S4.5 3.067 4.5 5 6.067 8.5 8 8.5s3.5-1.567 3.5-3.5zM3 5c0-2.76 2.24-5 5-5s5 2.24 5 5-2.24 5-5 5-5-2.24-5-5zM1.955 17.294c.21-.642.504-1.285.898-1.88C3.963 13.74 5.615 12.75 8 12.75c2.385 0 4.038.99 5.147 2.664.394.595.69 1.238.898 1.88.124.382.19.672.214.822.063.41.447.69.856.625.41-.063.69-.447.625-.856-.034-.225-.118-.59-.27-1.053-.247-.763-.598-1.527-1.073-2.244C13.024 12.51 10.917 11.25 8 11.25c-2.916 0-5.024 1.26-6.397 3.336-.475.717-.826 1.48-1.074 2.245-.152.463-.236.83-.27 1.054-.065.41.215.793.624.857.41.065.793-.215.857-.624.025-.15.09-.44.215-.822z", fill: "#FFF", fillRule: "evenodd" }) }));
414
414
  }
415
415
  function GenerateAvatar(props) {
416
416
  var initials = (props === null || props === void 0 ? void 0 : props.initials) || "?";
417
417
  var size = (props === null || props === void 0 ? void 0 : props.size) || 40;
418
418
  var backgroundColor = (props === null || props === void 0 ? void 0 : props.backgroundColor) || "#007bff";
419
419
  var textColor = (props === null || props === void 0 ? void 0 : props.textColor) || "#ffffff";
420
- var image = React$1.useMemo(function () {
420
+ var image = useMemo(function () {
421
421
  return generateImage(initials, size, backgroundColor, textColor);
422
422
  }, [initials, size, backgroundColor, textColor]);
423
423
  return image;
@@ -455,9 +455,7 @@ function getItemUrl(item) {
455
455
  return item.url || item.imageActionUrl;
456
456
  }
457
457
 
458
- function useChatDispatch() {
459
- return useDispatch();
460
- }
458
+ var useChatDispatch = useDispatch.withTypes();
461
459
 
462
460
  var OptionalLink = function (props) {
463
461
  var chatDispatch = useChatDispatch();
@@ -469,10 +467,10 @@ var OptionalLink = function (props) {
469
467
  }
470
468
  }, [url, onOpen]);
471
469
  if (url) {
472
- return (React$1.createElement("div", { onClick: handleOpenUrl, className: className }, props.children));
470
+ return (jsx("div", { onClick: handleOpenUrl, className: className, children: props.children }));
473
471
  }
474
472
  else {
475
- return (React$1.createElement("div", { onClick: props.onClick, className: className }, props.children));
473
+ return (jsx("div", { onClick: props.onClick, className: className, children: props.children }));
476
474
  }
477
475
  };
478
476
 
@@ -493,17 +491,17 @@ var ActionItem = function (props) {
493
491
  }
494
492
  }, [item, onExecute, onButtonClick]);
495
493
  var className = "xappw-chat-action-item ".concat(singleButton ? "xappw-chat-action-item--action" : "", " ").concat(props.className);
496
- return (React$1.createElement(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl }, props.children));
494
+ return (jsx(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl, children: props.children }));
497
495
  };
498
496
 
499
497
  var ChatImage = function (props) {
500
498
  var cleanUrl = props.imageUrl.replace(/'/g, "%27");
501
- var content = React$1.createElement("div", { className: "chat-card-img__content", style: { backgroundImage: "url(".concat(cleanUrl, ")") } });
499
+ var content = (jsx("div", { className: "chat-card-img__content", style: { backgroundImage: "url(".concat(cleanUrl, ")") } }));
502
500
  if (!props.imageActionUrl) {
503
- return (React$1.createElement("div", { className: "chat-card-img" }, content));
501
+ return jsx("div", { className: "chat-card-img", children: content });
504
502
  }
505
503
  else {
506
- return (React$1.createElement("a", { href: props.imageActionUrl, "aria-label": "read more", target: "_blank", rel: "noopener noreferrer", className: "chat-card-img" }, content));
504
+ return (jsx("a", { href: props.imageActionUrl, "aria-label": "read more", target: "_blank", rel: "noopener noreferrer", className: "chat-card-img", children: content }));
507
505
  }
508
506
  };
509
507
 
@@ -514,13 +512,12 @@ var ActionItemImage = function (props) {
514
512
  var itemUrl = getItemUrl(item);
515
513
  if (item.imageUrl) {
516
514
  var imageActionUrl = !singleButton ? item.imageActionUrl : null;
517
- return (React$1.createElement("div", { className: props.className },
518
- React$1.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
515
+ return (jsx("div", { className: props.className, children: jsx(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl }) }));
519
516
  }
520
517
  else if (props.emptyImageVisible) {
521
- return (React$1.createElement("div", { className: props.className }));
518
+ return jsx("div", { className: props.className });
522
519
  }
523
- return React$1.createElement(React$1.Fragment, null);
520
+ return jsx(Fragment, {});
524
521
  };
525
522
 
526
523
  var ChatActionButtonInner = function (props) {
@@ -528,44 +525,35 @@ var ChatActionButtonInner = function (props) {
528
525
  var handleButton = useCallback(function () {
529
526
  onClick(button);
530
527
  }, [button, onClick]);
531
- return (React$1.createElement(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label }));
528
+ return jsx(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label });
532
529
  };
533
- var ChatActionButton = React$1.memo(ChatActionButtonInner);
530
+ var ChatActionButton = memo(ChatActionButtonInner);
534
531
 
535
532
  var ChatActionButtonsInner = function (props) {
536
- return (React$1.createElement("div", { className: "buttons-container " + (props.className || "") }, props.buttons.map(function (button, i) {
537
- return React$1.createElement(ChatActionButton, { button: button, onClick: props.onClick, key: i });
538
- })));
533
+ return (jsx("div", { className: "buttons-container " + (props.className || ""), children: props.buttons.map(function (button, i) {
534
+ return jsx(ChatActionButton, { button: button, onClick: props.onClick }, i);
535
+ }) }));
539
536
  };
540
- var ChatActionButtons = React$1.memo(ChatActionButtonsInner);
537
+ var ChatActionButtons = memo(ChatActionButtonsInner);
541
538
 
542
539
  var CarouselItem = function (props) {
543
540
  var _a;
544
541
  var item = props.item;
545
- return (React$1.createElement(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
546
- React$1.createElement("div", { className: "chat-list-item" },
547
- React$1.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
548
- item.title && React$1.createElement("div", { className: "chat-list-item__title" },
549
- React$1.createElement("span", null, item.title)),
550
- item.subTitle && React$1.createElement("div", { className: "chat-list-item__subtitle" },
551
- React$1.createElement("span", null, item.subTitle)),
552
- !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))));
542
+ return (jsx(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl, children: jsxs("div", { className: "chat-list-item", children: [jsx(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }), item.title && (jsx("div", { className: "chat-list-item__title", children: jsx("span", { children: item.title }) })), item.subTitle && (jsx("div", { className: "chat-list-item__subtitle", children: jsx("span", { children: item.subTitle }) })), !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && (jsx(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))] }) }));
553
543
  };
554
544
 
555
545
  function getLeftArrowSvg() {
556
- return (React$1.createElement("svg", { viewBox: "-5 -18 10 36" },
557
- React$1.createElement("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
546
+ return (jsx("svg", { viewBox: "-5 -18 10 36", children: jsx("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" }) }));
558
547
  }
559
548
  var ChevronLeft = function (props) {
560
- return (React$1.createElement("button", { onClick: props.onClick, className: "xa-chevron" }, getLeftArrowSvg()));
549
+ return (jsx("button", { onClick: props.onClick, className: "xa-chevron", children: getLeftArrowSvg() }));
561
550
  };
562
551
 
563
552
  function getRightArrowSvg() {
564
- return (React$1.createElement("svg", { viewBox: "-5 -18 10 36" },
565
- React$1.createElement("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
553
+ return (jsx("svg", { viewBox: "-5 -18 10 36", children: jsx("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" }) }));
566
554
  }
567
555
  var ChevronRight = function (props) {
568
- return (React$1.createElement("button", { onClick: props.onClick, className: "xa-chevron" }, getRightArrowSvg()));
556
+ return (jsx("button", { onClick: props.onClick, className: "xa-chevron", children: getRightArrowSvg() }));
569
557
  };
570
558
 
571
559
  var Carousel = function (props) {
@@ -604,15 +592,9 @@ var Carousel = function (props) {
604
592
  var hasOnlyOneItem = props.list.items.length === 1;
605
593
  var hasImage = props.list.items.some(function (item) { return item.imageUrl; });
606
594
  var listItems = props.list.items.map(function (item, itemIndex) {
607
- return (React$1.createElement("div", { className: "xappw-carousel-items__item", key: "item-key-".concat(itemIndex) },
608
- React$1.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
595
+ return (jsx("div", { className: "xappw-carousel-items__item", children: jsx(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl }) }, "item-key-".concat(itemIndex)));
609
596
  });
610
- return (React$1.createElement("div", { className: "xappw-carousel" },
611
- !hasOnlyOneItem && (React$1.createElement("div", { className: "xappw-carousel__prev" },
612
- React$1.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } }))),
613
- React$1.createElement("div", { ref: listRef, className: "xappw-carousel-items ".concat(hasOnlyOneItem ? "xappw-carousel-items--one-item" : "") }, listItems),
614
- !hasOnlyOneItem && (React$1.createElement("div", { className: "xappw-carousel__next" },
615
- React$1.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } })))));
597
+ return (jsxs("div", { className: "xappw-carousel", children: [!hasOnlyOneItem && (jsx("div", { className: "xappw-carousel__prev", children: jsx(ChevronLeft, { onClick: function () { return scrollMe(-1); } }) })), jsx("div", { ref: listRef, className: "xappw-carousel-items ".concat(hasOnlyOneItem ? "xappw-carousel-items--one-item" : ""), children: listItems }), !hasOnlyOneItem && (jsx("div", { className: "xappw-carousel__next", children: jsx(ChevronRight, { onClick: function () { return scrollMe(1); } }) }))] }));
616
598
  };
617
599
 
618
600
  function useDimensions() {
@@ -714,9 +696,7 @@ var CtaBubbleTail = function (props) {
714
696
  var _a, _b;
715
697
  var _c = useDimensions(), ref = _c[0], rect = _c[1];
716
698
  var viewPort = { x: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, y: (_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0 };
717
- return (React$1.createElement("div", { ref: ref, className: "cta-bubble__tail" },
718
- React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y) },
719
- React$1.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" }))));
699
+ return (jsx("div", { ref: ref, className: "cta-bubble__tail", children: jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y), children: jsx("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" }) }) }));
720
700
  };
721
701
  var CtaBubble = function (props) {
722
702
  var _a, _b, _c, _d;
@@ -730,17 +710,12 @@ var CtaBubble = function (props) {
730
710
  }
731
711
  };
732
712
  console.log("Returning CTABubble with message: ", props.children);
733
- return (React$1.createElement("div", { ref: ref, style: {
713
+ return (jsxs("div", { ref: ref, style: {
734
714
  border: props.borderStyle ? "solid" : "none",
735
715
  borderWidth: ((_a = props.borderStyle) === null || _a === void 0 ? void 0 : _a.width) || "0px",
736
716
  borderColor: ((_b = props.borderStyle) === null || _b === void 0 ? void 0 : _b.color) || "transparent",
737
717
  animation: "".concat(animation, " 1s infinite"),
738
- }, className: "cta-bubble", onClick: props.onClick },
739
- React$1.createElement(CtaBubbleTail, { width: (_c = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _c !== void 0 ? _c : 0, height: (_d = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _d !== void 0 ? _d : 0, direction: 60, angle: 45, length: 16 }),
740
- React$1.createElement("div", { className: "cta-bubble__content" }, props.children),
741
- props.dismissible && (React$1.createElement("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss" },
742
- React$1.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
743
- React$1.createElement("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }))))));
718
+ }, className: "cta-bubble", onClick: props.onClick, children: [jsx(CtaBubbleTail, { width: (_c = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _c !== void 0 ? _c : 0, height: (_d = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _d !== void 0 ? _d : 0, direction: 60, angle: 45, length: 16 }), jsx("div", { className: "cta-bubble__content", children: props.children }), props.dismissible && (jsx("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss", children: jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }));
744
719
  };
745
720
 
746
721
  var CtaBubbleContainer = function (props) {
@@ -835,7 +810,7 @@ var CtaBubbleContainer = function (props) {
835
810
  // Final render decision
836
811
  var shouldRender = visible && showBubble;
837
812
  log("[CtaBubbleContainer] Render decision: visible=".concat(visible, ", showBubble=").concat(showBubble, ", shouldRender=").concat(shouldRender));
838
- return (React$1.createElement(React$1.Fragment, null, visible && showBubble && (React$1.createElement(CtaBubble, { onClick: onClick, animate: animate, buttonAnimation: buttonAnimation, dismissible: dismissible, onDismiss: handleDismiss }, children))));
813
+ return (jsx(Fragment, { children: visible && showBubble && (jsx(CtaBubble, { onClick: onClick, animate: animate, buttonAnimation: buttonAnimation, dismissible: dismissible, onDismiss: handleDismiss, children: children })) }));
839
814
  };
840
815
 
841
816
  var ChatButton = function (_a) {
@@ -914,23 +889,19 @@ var ChatButton = function (_a) {
914
889
  }, [mobileWidth]);
915
890
  var maxSvgSize = 22;
916
891
  var svgSize = Math.min(maxSvgSize, (+buttonWidth / +defaultWidgetButtonWidth) * maxSvgSize);
917
- return (React$1.createElement("button", { "aria-label": "open chat", className: "xapp-chat-button ".concat(addClass || "").trim(), onClick: onClick },
918
- React$1.createElement("div", { id: "xapp-widget-button", className: "xapp-chat-button__btn", style: {
919
- width: "".concat(buttonWidth, "px"),
920
- height: "".concat(buttonWidth, "px"),
921
- borderRadius: "".concat(+buttonWidth / 2, "px"),
922
- border: borderStyle && borderStyle.width ? "solid" : "none",
923
- borderWidth: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.width) || "0px",
924
- borderColor: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.color) || "transparent",
925
- animation: "".concat(animation, " 1s infinite"),
926
- } }, imageUrl ? (
927
- // Display image from URL
928
- React$1.createElement("img", { src: imageUrl, alt: "Chat Icon" })) : (
929
- // Fallback to default SVG
930
- React$1.createElement("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22" },
931
- React$1.createElement("path", { d: "M13 22l-4-6H2c-1.11-.043-2-.935-2-2V2C0 .89.89 0 2 0h18c1.11 0 2 .892 2 2v12c0 1.067-.89 1.957-2 2h-3l-4 6zm3-8h4c-.005.3-.01-12 0-12-.01.004-18 .006-18 0 .005.006 0 12 0 12h8l3 5 3-5z", fill: "#FFF", fillRule: "evenodd" })))),
932
- configToApply && configToApply.message && !hasInteracted && (React$1.createElement("div", { className: "xapp-chat-button__cta" },
933
- React$1.createElement(CtaBubbleContainer, { timeout: configToApply === null || configToApply === void 0 ? void 0 : configToApply.timeout, delay: configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay, animate: animate, buttonAnimation: animation, dismissible: configToApply === null || configToApply === void 0 ? void 0 : configToApply.dismissible, visible: !visible /** Why is this !visible */, onDismiss: onCtaDismiss }, configToApply === null || configToApply === void 0 ? void 0 : configToApply.message)))));
892
+ return (jsxs("button", { "aria-label": "open chat", className: "xapp-chat-button ".concat(addClass || "").trim(), onClick: onClick, children: [jsx("div", { id: "xapp-widget-button", className: "xapp-chat-button__btn", style: {
893
+ width: "".concat(buttonWidth, "px"),
894
+ height: "".concat(buttonWidth, "px"),
895
+ borderRadius: "".concat(+buttonWidth / 2, "px"),
896
+ border: borderStyle && borderStyle.width ? "solid" : "none",
897
+ borderWidth: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.width) || "0px",
898
+ borderColor: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.color) || "transparent",
899
+ animation: "".concat(animation, " 1s infinite"),
900
+ }, children: imageUrl ? (
901
+ // Display image from URL
902
+ jsx("img", { src: imageUrl, alt: "Chat Icon" })) : (
903
+ // Fallback to default SVG
904
+ jsx("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22", children: jsx("path", { d: "M13 22l-4-6H2c-1.11-.043-2-.935-2-2V2C0 .89.89 0 2 0h18c1.11 0 2 .892 2 2v12c0 1.067-.89 1.957-2 2h-3l-4 6zm3-8h4c-.005.3-.01-12 0-12-.01.004-18 .006-18 0 .005.006 0 12 0 12h8l3 5 3-5z", fill: "#FFF", fillRule: "evenodd" }) })) }), configToApply && configToApply.message && !hasInteracted && (jsx("div", { className: "xapp-chat-button__cta", children: jsx(CtaBubbleContainer, { timeout: configToApply === null || configToApply === void 0 ? void 0 : configToApply.timeout, delay: configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay, animate: animate, buttonAnimation: animation, dismissible: configToApply === null || configToApply === void 0 ? void 0 : configToApply.dismissible, visible: !visible /** Why is this !visible */, onDismiss: onCtaDismiss, children: configToApply === null || configToApply === void 0 ? void 0 : configToApply.message }) }))] }));
934
905
  };
935
906
 
936
907
  var ChatCard = function (props) {
@@ -940,40 +911,32 @@ var ChatCard = function (props) {
940
911
  var image;
941
912
  var content;
942
913
  if (card.imageUrl) {
943
- image = React$1.createElement("div", { className: "chat-card-container__img" },
944
- React$1.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
914
+ image = (jsx("div", { className: "chat-card-container__img", children: jsx(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }) }));
945
915
  }
946
916
  if (card.title) {
947
- title =
948
- React$1.createElement("div", { className: "chat-card-title" },
949
- React$1.createElement("span", null, card.title));
917
+ title = (jsx("div", { className: "chat-card-title", children: jsx("span", { children: card.title }) }));
950
918
  }
951
919
  if (card.content) {
952
- content =
953
- React$1.createElement("div", { className: "chat-card-sub-title" },
954
- React$1.createElement("span", null, card.content));
955
- }
956
- return (React$1.createElement("div", { className: "chat-card-container" },
957
- image,
958
- title,
959
- content,
960
- !!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
920
+ content = (jsx("div", { className: "chat-card-sub-title", children: jsx("span", { children: card.content }) }));
921
+ }
922
+ return (jsxs("div", { className: "chat-card-container", children: [image, title, content, !!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && (jsx(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick }))] }));
961
923
  };
962
924
 
963
925
  var ChatChip = function (props) {
964
926
  var option = props.option;
965
- var className = option.actionUrl ? "chat-chip chat-chip-link" : "chat-chip";
966
- return (React$1.createElement("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className },
967
- React$1.createElement("span", null, typeof option === "object" ? option.label : option)));
927
+ var className = option.actionUrl
928
+ ? "chat-chip chat-chip-link"
929
+ : "chat-chip";
930
+ return (jsx("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className, children: jsx("span", { children: typeof option === "object" ? option.label : option }) }));
968
931
  };
969
932
 
970
933
  /**
971
934
  * Render option list. We just follow the order.
972
935
  */
973
936
  var ChatChips = function (props) {
974
- return (React$1.createElement("div", { className: "chat-chips" }, props.options.map(function (option, i) {
975
- return React$1.createElement(ChatChip, { key: i, onClick: props.onOptionClick, option: option });
976
- })));
937
+ return (jsx("div", { className: "chat-chips", children: props.options.map(function (option, i) {
938
+ return jsx(ChatChip, { onClick: props.onOptionClick, option: option }, i);
939
+ }) }));
977
940
  };
978
941
 
979
942
  var defaultBehavior = {
@@ -1388,6 +1351,12 @@ var LogChat = /** @class */ (function () {
1388
1351
  });
1389
1352
  });
1390
1353
  };
1354
+ LogChat.prototype.notifyDisconnecting = function () {
1355
+ log("CLIENT: notifyDisconnecting:");
1356
+ if (this.inner.notifyDisconnecting) {
1357
+ this.inner.notifyDisconnecting();
1358
+ }
1359
+ };
1391
1360
  return LogChat;
1392
1361
  }());
1393
1362
 
@@ -1397,13 +1366,12 @@ function getDefaultExportFromCjs (x) {
1397
1366
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1398
1367
  }
1399
1368
 
1400
- var React = React$1;
1369
+ var jsxRuntime = require$$0;
1370
+ var react = require$$1;
1401
1371
 
1402
1372
  var IconButton = function (props) {
1403
1373
  var Icon = props.icon;
1404
- return (React.createElement("div", { tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "xapp-search-icon-button ".concat(props.className || ""), onClick: props.onClick },
1405
- React.createElement("div", { className: "xapp-search-icon-button__content" },
1406
- React.createElement(Icon, null))));
1374
+ return (jsxRuntime.jsx("div", { tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "xapp-search-icon-button ".concat(props.className || ""), onClick: props.onClick, children: jsxRuntime.jsx("div", { className: "xapp-search-icon-button__content", children: jsxRuntime.jsx(Icon, {}) }) }));
1407
1375
  };
1408
1376
 
1409
1377
  // compile time full switch-case verification
@@ -1413,17 +1381,17 @@ function throwBadKind(x) {
1413
1381
 
1414
1382
  var RichTextBoldSpan = function (props) {
1415
1383
  var format = props.format, text = props.text;
1416
- return (React.createElement("span", { "data-rich-text-type": "bold", className: "xapp-search-rich-text-bold-span" }, text.substring(format.start, format.end)));
1384
+ return (jsxRuntime.jsx("span", { "data-rich-text-type": "bold", className: "xapp-search-rich-text-bold-span", children: text.substring(format.start, format.end) }));
1417
1385
  };
1418
1386
 
1419
1387
  var RichTextInputSpan = function (props) {
1420
1388
  var format = props.format, text = props.text, readOnly = props.readOnly, onClick = props.onClick;
1421
1389
  var defaultValue = format.text || text.substring(format.start, format.end);
1422
- var _a = React.useState(defaultValue), value = _a[0], setValue = _a[1];
1423
- var handleChange = React.useCallback(function (ev) {
1390
+ var _a = react.useState(defaultValue), value = _a[0], setValue = _a[1];
1391
+ var handleChange = react.useCallback(function (ev) {
1424
1392
  setValue(ev.target.value);
1425
1393
  }, []);
1426
- var handleClick = React.useCallback(function (ev) {
1394
+ var handleClick = react.useCallback(function (ev) {
1427
1395
  if (onClick) {
1428
1396
  var res = onClick(format);
1429
1397
  if (res === false) {
@@ -1433,14 +1401,14 @@ var RichTextInputSpan = function (props) {
1433
1401
  }
1434
1402
  }, [onClick, format]);
1435
1403
  if (readOnly) {
1436
- return (React.createElement("span", { className: "xapp-search-rich-text-input-span xapp-search-rich-text-input-span--readonly", onClick: handleClick }, defaultValue));
1404
+ return (jsxRuntime.jsx("span", { className: "xapp-search-rich-text-input-span xapp-search-rich-text-input-span--readonly", onClick: handleClick, children: defaultValue }));
1437
1405
  }
1438
- return (React.createElement("input", { type: "text", value: value, className: "xapp-search-rich-text-input-span", "data-rich-text-type": "inputText", onChange: handleChange, onClick: handleClick, readOnly: readOnly }));
1406
+ return (jsxRuntime.jsx("input", { type: "text", value: value, className: "xapp-search-rich-text-input-span", "data-rich-text-type": "inputText", onChange: handleChange, onClick: handleClick, readOnly: readOnly }));
1439
1407
  };
1440
1408
 
1441
1409
  var RichTextNormalSpan = function (props) {
1442
1410
  var format = props.format, text = props.text;
1443
- return (React.createElement("span", { "data-rich-text-type": "normal", className: "xapp-search-rich-text-normal-span" }, text.substring(format.start, format.end)));
1411
+ return (jsxRuntime.jsx("span", { "data-rich-text-type": "normal", className: "xapp-search-rich-text-normal-span", children: text.substring(format.start, format.end) }));
1444
1412
  };
1445
1413
 
1446
1414
  var RichTextSpan = function (props) {
@@ -1448,11 +1416,11 @@ var RichTextSpan = function (props) {
1448
1416
  var type = format.type;
1449
1417
  switch (type) {
1450
1418
  case "normal":
1451
- return (React.createElement(RichTextNormalSpan, { text: text, format: format, readOnly: readOnly }));
1419
+ return jsxRuntime.jsx(RichTextNormalSpan, { text: text, format: format, readOnly: readOnly });
1452
1420
  case "bold":
1453
- return (React.createElement(RichTextBoldSpan, { text: text, format: format, readOnly: readOnly }));
1421
+ return jsxRuntime.jsx(RichTextBoldSpan, { text: text, format: format, readOnly: readOnly });
1454
1422
  case "inputText":
1455
- return (React.createElement(RichTextInputSpan, { text: text, format: format, readOnly: readOnly, onClick: onClick }));
1423
+ return (jsxRuntime.jsx(RichTextInputSpan, { text: text, format: format, readOnly: readOnly, onClick: onClick }));
1456
1424
  default:
1457
1425
  throwBadKind(type);
1458
1426
  }
@@ -1537,7 +1505,7 @@ function parseContent(node) {
1537
1505
  formats.push({
1538
1506
  type: type,
1539
1507
  start: text.length,
1540
- end: text.length + innerText.length
1508
+ end: text.length + innerText.length,
1541
1509
  });
1542
1510
  text += innerText;
1543
1511
  }
@@ -1548,7 +1516,7 @@ function parseContent(node) {
1548
1516
  formats.push({
1549
1517
  type: "normal",
1550
1518
  start: text.length,
1551
- end: text.length + innerText.length
1519
+ end: text.length + innerText.length,
1552
1520
  });
1553
1521
  text += innerText;
1554
1522
  }
@@ -1556,7 +1524,7 @@ function parseContent(node) {
1556
1524
  });
1557
1525
  return cleanRichTextValue({
1558
1526
  text: text,
1559
- formats: formats
1527
+ formats: formats,
1560
1528
  });
1561
1529
  }
1562
1530
  function cleanContent(node) {
@@ -1574,22 +1542,21 @@ function cleanContent(node) {
1574
1542
  try {
1575
1543
  (_a = c.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(c);
1576
1544
  }
1577
- catch (_b) {
1578
- }
1545
+ catch (_b) { }
1579
1546
  }
1580
1547
  }
1581
1548
  var RichText = function (props) {
1582
1549
  var value = props.value, className = props.className, readOnly = props.readOnly, onInput = props.onInput, onChange = props.onChange, onSpanClick = props.onSpanClick;
1583
1550
  var formatsRaw = value.formats, text = value.text;
1584
- var formats = React.useMemo(function () { return extendFormat(formatsRaw, text.length); }, [formatsRaw, text.length]);
1585
- var handleInput = React.useCallback(function (ev) {
1551
+ var formats = react.useMemo(function () { return extendFormat(formatsRaw, text.length); }, [formatsRaw, text.length]);
1552
+ var handleInput = react.useCallback(function (ev) {
1586
1553
  var target = ev.currentTarget;
1587
1554
  var newValue = parseContent(target);
1588
1555
  if (onInput) {
1589
1556
  onInput(newValue);
1590
1557
  }
1591
1558
  }, [onInput]);
1592
- var handleBlur = React.useCallback(function (ev) {
1559
+ var handleBlur = react.useCallback(function (ev) {
1593
1560
  var target = ev.currentTarget;
1594
1561
  var newValue = parseContent(target);
1595
1562
  cleanContent(target);
@@ -1597,49 +1564,53 @@ var RichText = function (props) {
1597
1564
  onChange(newValue);
1598
1565
  }
1599
1566
  }, [onChange]);
1600
- return (React.createElement("div", { id: props.id, className: "xapp-search-rich-text ".concat(className || ""), contentEditable: !readOnly, suppressContentEditableWarning: true, onInput: handleInput, onBlur: handleBlur, onKeyDown: props.onKeyDown }, formats.map(function (format, index) { return (React.createElement(RichTextSpan, { key: index, format: format, text: text, readOnly: readOnly, onClick: onSpanClick })); })));
1567
+ return (jsxRuntime.jsx("div", { id: props.id, className: "xapp-search-rich-text ".concat(className || ""), contentEditable: !readOnly, suppressContentEditableWarning: true, onInput: handleInput, onBlur: handleBlur, onKeyDown: props.onKeyDown, children: formats.map(function (format, index) { return (jsxRuntime.jsx(RichTextSpan, { format: format, text: text, readOnly: readOnly, onClick: onSpanClick }, index)); }) }));
1601
1568
  };
1602
1569
 
1603
1570
  var RichInput = function (props) {
1604
1571
  var id = props.id, value = props.value, type = props.type, autoFocus = props.autoFocus, spellCheck = props.spellCheck, tabIndex = props.tabIndex, onChange = props.onChange, onInput = props.onInput, onKeyDown = props.onKeyDown, onSearch = props.onSearch;
1605
1572
  var rich = value.formats.some(function (f) { return f.type === "inputText"; });
1606
- var handleChange = React.useCallback(function (ev) {
1607
- onChange({
1608
- text: ev.target.value,
1609
- formats: []
1610
- });
1573
+ var handleChange = react.useCallback(function (ev) {
1574
+ if (onChange) {
1575
+ onChange({
1576
+ text: ev.target.value,
1577
+ formats: [],
1578
+ });
1579
+ }
1611
1580
  }, [onChange]);
1612
- var handleRichChange = React.useCallback(function (val) {
1613
- onChange(val);
1581
+ var handleRichChange = react.useCallback(function (val) {
1582
+ if (onChange) {
1583
+ onChange(val);
1584
+ }
1614
1585
  }, [onChange]);
1615
- var handleInput = React.useCallback(function (ev) {
1586
+ var handleInput = react.useCallback(function (ev) {
1616
1587
  if (onInput) {
1617
1588
  onInput({
1618
1589
  text: ev.target.value,
1619
- formats: []
1590
+ formats: [],
1620
1591
  });
1621
1592
  }
1622
1593
  }, [onInput]);
1623
- var handleRichInput = React.useCallback(function (val) {
1594
+ var handleRichInput = react.useCallback(function (val) {
1624
1595
  if (onInput) {
1625
1596
  onInput(val);
1626
1597
  }
1627
1598
  }, [onInput]);
1628
- var handleKeyDown = React.useCallback(function (event) {
1599
+ var handleKeyDown = react.useCallback(function (event) {
1629
1600
  if (onKeyDown) {
1630
1601
  onKeyDown(event);
1631
1602
  }
1632
1603
  }, [onKeyDown]);
1633
- var inputRef = React.useRef(null);
1604
+ var inputRef = react.useRef(null);
1634
1605
  var inputNode = inputRef.current;
1635
- React.useEffect(function () {
1606
+ react.useEffect(function () {
1636
1607
  if (inputNode && onSearch) {
1637
1608
  var handler_1 = function (ev) {
1638
1609
  var target = ev.target;
1639
1610
  if (target) {
1640
1611
  onSearch({
1641
1612
  text: target.value,
1642
- formats: []
1613
+ formats: [],
1643
1614
  });
1644
1615
  }
1645
1616
  };
@@ -1650,12 +1621,11 @@ var RichInput = function (props) {
1650
1621
  }
1651
1622
  return undefined;
1652
1623
  }, [inputNode, onSearch]);
1653
- return (React.createElement("div", { className: "xappw-rich-input ".concat(props.className) }, rich ?
1654
- React.createElement(RichText, { id: id, value: value, onChange: handleRichChange, onInput: handleRichInput, onKeyDown: handleKeyDown, className: "xappw-rich-input__input ".concat(props.className, "__input") }) : React.createElement("input", { id: id, ref: inputRef, type: type, value: value.text, autoComplete: "off", autoFocus: autoFocus, placeholder: props.placeholder, spellCheck: spellCheck, tabIndex: tabIndex ? Number(tabIndex) : 0, className: "xappw-rich-input__input ".concat(props.className, "__input"), onFocus: props.onFocus, onChange: handleChange, onInput: handleInput, onKeyDown: handleKeyDown })));
1624
+ return (jsxRuntime.jsx("div", { className: "xappw-rich-input ".concat(props.className), children: rich ? (jsxRuntime.jsx(RichText, { id: id, value: value, onChange: handleRichChange, onInput: handleRichInput, onKeyDown: handleKeyDown, className: "xappw-rich-input__input ".concat(props.className, "__input") })) : (jsxRuntime.jsx("input", { id: id, ref: inputRef, type: type, value: value.text, autoComplete: "off", autoFocus: autoFocus, placeholder: props.placeholder, spellCheck: spellCheck, tabIndex: tabIndex ? Number(tabIndex) : 0, className: "xappw-rich-input__input ".concat(props.className, "__input"), onFocus: props.onFocus, onChange: handleChange, onInput: handleInput, onKeyDown: handleKeyDown })) }));
1655
1625
  };
1656
1626
 
1657
1627
  var SuggestionsGroupHeading = function (props) {
1658
- return (React.createElement("div", { className: "xappw-suggestions-group-heading" }, props.label));
1628
+ return jsxRuntime.jsx("div", { className: "xappw-suggestions-group-heading", children: props.label });
1659
1629
  };
1660
1630
 
1661
1631
  function getScrollContainer(node) {
@@ -1667,22 +1637,22 @@ function getScrollContainer(node) {
1667
1637
  }
1668
1638
  var SuggestionsItem = function (props) {
1669
1639
  var data = props.data, current = props.current, ActionsComponent = props.actions, onClick = props.onClick, onHover = props.onHover, onSpanClick = props.onSpanClick;
1670
- var handleClick = React.useCallback(function () {
1640
+ var handleClick = react.useCallback(function () {
1671
1641
  onClick(data);
1672
1642
  }, [data, onClick]);
1673
- var handleHover = React.useCallback(function () {
1643
+ var handleHover = react.useCallback(function () {
1674
1644
  if (onHover) {
1675
1645
  onHover(data);
1676
1646
  }
1677
1647
  }, [data, onHover]);
1678
- var handleSpanClick = React.useCallback(function (span) {
1648
+ var handleSpanClick = react.useCallback(function (span) {
1679
1649
  if (onSpanClick) {
1680
1650
  return onSpanClick(data, span);
1681
1651
  }
1682
1652
  return undefined;
1683
1653
  }, [onSpanClick, data]);
1684
- var ref = React.useRef(null);
1685
- React.useEffect(function () {
1654
+ var ref = react.useRef(null);
1655
+ react.useEffect(function () {
1686
1656
  var node = ref.current;
1687
1657
  if (current && node) {
1688
1658
  var scrollContainer = getScrollContainer(node);
@@ -1699,22 +1669,13 @@ var SuggestionsItem = function (props) {
1699
1669
  }
1700
1670
  }
1701
1671
  }, [current]);
1702
- return (React.createElement("div", { ref: ref, className: "xappw-suggestions-item ".concat(current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover },
1703
- React.createElement(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true, onSpanClick: handleSpanClick }),
1704
- ActionsComponent &&
1705
- React.createElement("div", { className: "xappw-suggestions-item__actions" },
1706
- React.createElement(ActionsComponent, { data: data, current: current }))));
1672
+ return (jsxRuntime.jsxs("div", { ref: ref, className: "xappw-suggestions-item ".concat(current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover, children: [jsxRuntime.jsx(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true, onSpanClick: handleSpanClick }), ActionsComponent && (jsxRuntime.jsx("div", { className: "xappw-suggestions-item__actions", children: jsxRuntime.jsx(ActionsComponent, { data: data, current: current }) }))] }));
1707
1673
  };
1708
1674
 
1709
1675
  var SuggestionsGroup = function (props) {
1710
1676
  var group = props.group, currentIndex = props.currentIndex, itemActions = props.itemActions;
1711
1677
  var heading = group.heading, items = group.items;
1712
- return (React.createElement("div", { className: "xappw-suggestions-group" },
1713
- React.createElement("div", { className: "xappw-suggestions-group__heading" },
1714
- React.createElement(SuggestionsGroupHeading, { label: heading })),
1715
- React.createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
1716
- return React.createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover, onSpanClick: props.onSpanClick });
1717
- }))));
1678
+ return (jsxRuntime.jsxs("div", { className: "xappw-suggestions-group", children: [jsxRuntime.jsx("div", { className: "xappw-suggestions-group__heading", children: jsxRuntime.jsx(SuggestionsGroupHeading, { label: heading }) }), jsxRuntime.jsx("div", { className: "xappw-suggestions-group__items", children: items.map(function (item, itemIndex) { return (jsxRuntime.jsx(SuggestionsItem, { data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover, onSpanClick: props.onSpanClick }, itemIndex)); }) })] }));
1718
1679
  };
1719
1680
 
1720
1681
  function getItemsLength(result) {
@@ -1723,7 +1684,7 @@ function getItemsLength(result) {
1723
1684
 
1724
1685
  var SuggestionsList = function (props) {
1725
1686
  var suggestions = props.suggestions, itemActions = props.itemActions, className = props.className;
1726
- var length = React.useMemo(function () {
1687
+ var length = react.useMemo(function () {
1727
1688
  if (suggestions) {
1728
1689
  return getItemsLength(suggestions);
1729
1690
  }
@@ -1731,11 +1692,11 @@ var SuggestionsList = function (props) {
1731
1692
  }, [suggestions]);
1732
1693
  var currentIndex = length >= 0 ? props.index : NaN;
1733
1694
  var indexWalker = 0;
1734
- return (React.createElement("div", { className: "xappw-suggestions-list ".concat(className || "") }, suggestions === null || suggestions === void 0 ? void 0 : suggestions.map(function (group, index) {
1735
- var res = (React.createElement(SuggestionsGroup, { key: index, group: group, currentIndex: currentIndex - indexWalker, itemActions: itemActions, onItemClick: props.onItemClick, onItemHover: props.onItemHover, onSpanClick: props.onSpanClick }));
1736
- indexWalker += group.items.length;
1737
- return res;
1738
- })));
1695
+ return (jsxRuntime.jsx("div", { className: "xappw-suggestions-list ".concat(className || ""), children: suggestions === null || suggestions === void 0 ? void 0 : suggestions.map(function (group, index) {
1696
+ var res = (jsxRuntime.jsx(SuggestionsGroup, { group: group, currentIndex: currentIndex - indexWalker, itemActions: itemActions, onItemClick: props.onItemClick, onItemHover: props.onItemHover, onSpanClick: props.onSpanClick }, index));
1697
+ indexWalker += group.items.length;
1698
+ return res;
1699
+ }) }));
1739
1700
  };
1740
1701
 
1741
1702
  function findItemByIndex(groups, index) {
@@ -1754,65 +1715,6 @@ function findItemByIndex(groups, index) {
1754
1715
  return undefined;
1755
1716
  }
1756
1717
 
1757
- function parseSuggestionsFormat(format) {
1758
- var types = Object.keys(format);
1759
- var type = types[0];
1760
- var item = format[type];
1761
- if (!item) {
1762
- throw new Error();
1763
- }
1764
- return {
1765
- type: type,
1766
- start: item.start,
1767
- end: item.end
1768
- };
1769
- }
1770
- function parseSuggestionsFormats(formats) {
1771
- return formats.map(parseSuggestionsFormat);
1772
- }
1773
- function parseSuggestionsResponseItem(item) {
1774
- return {
1775
- text: item.suggestion,
1776
- content: item.answer,
1777
- formats: parseSuggestionsFormats(item.format),
1778
- type: item.type
1779
- };
1780
- }
1781
- function getHeading(type) {
1782
- switch (type) {
1783
- case "FAQ":
1784
- return "FAQs";
1785
- case "INTENT":
1786
- return "Suggestions";
1787
- case "HISTORICAL":
1788
- return "Suggestions";
1789
- default:
1790
- return type;
1791
- }
1792
- }
1793
- function parseSuggestionsResponse(response, direction) {
1794
- if (direction === void 0) { direction = 1; }
1795
- if (!response) {
1796
- return undefined;
1797
- }
1798
- var items = sortSuggestionItems(response.suggestions, direction);
1799
- return items.reduce(function (result, current) {
1800
- var mappedItem = parseSuggestionsResponseItem(current);
1801
- if (result.length) {
1802
- var prevGroup = result[result.length - 1];
1803
- if (prevGroup.heading === getHeading(current.type)) {
1804
- prevGroup.items.push(mappedItem);
1805
- return result;
1806
- }
1807
- }
1808
- result.push({
1809
- heading: getHeading(current.type),
1810
- items: [mappedItem]
1811
- });
1812
- return result;
1813
- }, []);
1814
- }
1815
-
1816
1718
  /******************************************************************************
1817
1719
  Copyright (c) Microsoft Corporation.
1818
1720
 
@@ -1895,6 +1797,65 @@ function sortSuggestionItems(items, direction) {
1895
1797
  return __spreadArray([], items).sort(function (left, right) { return compareSuggestionItems(left, right, direction); });
1896
1798
  }
1897
1799
 
1800
+ function parseSuggestionsFormat(format) {
1801
+ var types = Object.keys(format);
1802
+ var type = types[0];
1803
+ var item = format[type];
1804
+ if (!item) {
1805
+ throw new Error();
1806
+ }
1807
+ return {
1808
+ type: type,
1809
+ start: item.start,
1810
+ end: item.end,
1811
+ };
1812
+ }
1813
+ function parseSuggestionsFormats(formats) {
1814
+ return formats.map(parseSuggestionsFormat);
1815
+ }
1816
+ function parseSuggestionsResponseItem(item) {
1817
+ return {
1818
+ text: item.suggestion,
1819
+ content: item.answer,
1820
+ formats: parseSuggestionsFormats(item.format),
1821
+ type: item.type,
1822
+ };
1823
+ }
1824
+ function getHeading(type) {
1825
+ switch (type) {
1826
+ case "FAQ":
1827
+ return "FAQs";
1828
+ case "INTENT":
1829
+ return "Suggestions";
1830
+ case "HISTORICAL":
1831
+ return "Suggestions";
1832
+ default:
1833
+ return type;
1834
+ }
1835
+ }
1836
+ function parseSuggestionsResponse(response, direction) {
1837
+ if (direction === void 0) { direction = 1; }
1838
+ if (!response) {
1839
+ return undefined;
1840
+ }
1841
+ var items = sortSuggestionItems(response.suggestions, direction);
1842
+ return items.reduce(function (result, current) {
1843
+ var mappedItem = parseSuggestionsResponseItem(current);
1844
+ if (result.length) {
1845
+ var prevGroup = result[result.length - 1];
1846
+ if (prevGroup.heading === getHeading(current.type)) {
1847
+ prevGroup.items.push(mappedItem);
1848
+ return result;
1849
+ }
1850
+ }
1851
+ result.push({
1852
+ heading: getHeading(current.type),
1853
+ items: [mappedItem],
1854
+ });
1855
+ return result;
1856
+ }, []);
1857
+ }
1858
+
1898
1859
  /**
1899
1860
  * Append the provided query params to the URL
1900
1861
  *
@@ -1917,11 +1878,11 @@ function noop$1() {
1917
1878
  }
1918
1879
  function useJsonFetch(url, options) {
1919
1880
  if (options === void 0) { options = defaultOptions$2; }
1920
- var _a = React.useState({
1881
+ var _a = react.useState({
1921
1882
  state: "paused"
1922
1883
  }), value = _a[0], setValue = _a[1];
1923
1884
  var pause = options.pause;
1924
- React.useEffect(function () {
1885
+ react.useEffect(function () {
1925
1886
  if (pause) {
1926
1887
  setValue({
1927
1888
  state: "paused"
@@ -1986,7 +1947,7 @@ function useJsonFetch(url, options) {
1986
1947
 
1987
1948
  function useSuggestionsFetch$1(options) {
1988
1949
  var baseUrl = options.url, context = options.context, query = options.query;
1989
- var url = React.useMemo(function () {
1950
+ var url = react.useMemo(function () {
1990
1951
  if (!baseUrl) {
1991
1952
  return undefined;
1992
1953
  }
@@ -2944,7 +2905,7 @@ var serverInfo = {
2944
2905
  displayName: "XAPP Server"};
2945
2906
  var StentorRouterChat = /** @class */ (function () {
2946
2907
  function StentorRouterChat(config, options) {
2947
- var _a, _b;
2908
+ var _a, _b, _c, _d, _e;
2948
2909
  this.isDisposed = false;
2949
2910
  this._userId = "";
2950
2911
  this._sessionId = "";
@@ -2954,6 +2915,12 @@ var StentorRouterChat = /** @class */ (function () {
2954
2915
  this.isAdmin = false;
2955
2916
  this.urlAttributes = {};
2956
2917
  this.handlers = {};
2918
+ // Sleep delay management
2919
+ // Use number | NodeJS.Timeout for cross-environment compatibility (browser vs Node.js)
2920
+ this.sleepTimeoutId = null;
2921
+ // Message deduplication
2922
+ this.receivedMessageIds = new Set();
2923
+ this.MESSAGE_DEDUP_CACHE_SIZE = 1000;
2957
2924
  this.config = config;
2958
2925
  this.options = options;
2959
2926
  // Dig out the path parameters. Put them into the attributes.
@@ -2980,6 +2947,9 @@ var StentorRouterChat = /** @class */ (function () {
2980
2947
  log("WS url: ".concat(this.serverUrl, " isAdmin: ").concat(this.isAdmin, " attributes: ").concat(JSON.stringify(this.attributes), " appId: ").concat(this.appId));
2981
2948
  this.configurableMessages = getConfigurableMessagesConfig(options.configurableMessages);
2982
2949
  this.noOfServerErrors = 0;
2950
+ // Initialize sleep delay (default 60 seconds for websocketraw)
2951
+ this.SLEEP_DELAY_MS = (_e = (_d = (_c = options === null || options === void 0 ? void 0 : options.env) === null || _c === void 0 ? void 0 : _c.connection) === null || _d === void 0 ? void 0 : _d.backgroundSleepDelay) !== null && _e !== void 0 ? _e : 60000;
2952
+ log("Background sleep delay set to ".concat(this.SLEEP_DELAY_MS, "ms"));
2983
2953
  }
2984
2954
  StentorRouterChat.prototype.init = function (dispatch) {
2985
2955
  var _this = this;
@@ -3017,10 +2987,38 @@ var StentorRouterChat = /** @class */ (function () {
3017
2987
  var _a = _this.configurableMessages[data.tries], retry = _a.retry, delay = _a.delay, text = _a.text;
3018
2988
  _this.sendFailureMessage(retry, data.delay || delay, text, sender);
3019
2989
  };
3020
- this.handlers["new message"] = function (data, sender, ts, attributes) {
2990
+ this.handlers["new message"] = function (data, sender, ts, attributes, messageId) {
3021
2991
  // Because the router's internal message format is Stentor channel compatible.
3022
2992
  // So the data is either a stentor Request (from widget) or a stentor Response (from bot)
3023
2993
  var _a;
2994
+ // Deduplicate messages if messageId is provided
2995
+ if (messageId) {
2996
+ // Validate messageId to prevent memory exhaustion attacks
2997
+ if (messageId.length > 256) {
2998
+ log("Rejecting message with oversized messageId (".concat(messageId.length, " chars)"));
2999
+ return;
3000
+ }
3001
+ if (_this.receivedMessageIds.has(messageId)) {
3002
+ log("Deduplicating message with id: ".concat(messageId));
3003
+ return;
3004
+ }
3005
+ _this.receivedMessageIds.add(messageId);
3006
+ // Limit the size of the set to prevent memory issues
3007
+ // Batch eviction: remove ~10% of entries when limit exceeded
3008
+ // Note: Set maintains insertion order per ES2015 spec. Iteration yields
3009
+ // values in insertion order, so we evict the earliest-added entries.
3010
+ // After deletions, remaining entries maintain their relative order.
3011
+ if (_this.receivedMessageIds.size > _this.MESSAGE_DEDUP_CACHE_SIZE) {
3012
+ var idsToRemove = Math.floor(_this.MESSAGE_DEDUP_CACHE_SIZE * 0.1);
3013
+ var iterator = _this.receivedMessageIds.values();
3014
+ for (var i = 0; i < idsToRemove; i++) {
3015
+ var oldest = iterator.next().value;
3016
+ if (oldest) {
3017
+ _this.receivedMessageIds.delete(oldest);
3018
+ }
3019
+ }
3020
+ }
3021
+ }
3024
3022
  var message;
3025
3023
  if (sender.deviceId === "Bot") {
3026
3024
  var response = data;
@@ -3032,6 +3030,11 @@ var StentorRouterChat = /** @class */ (function () {
3032
3030
  if (typeof ((_a = _this.options.hooks) === null || _a === void 0 ? void 0 : _a.onResponse) === "function") {
3033
3031
  _this.options.hooks.onResponse(response);
3034
3032
  }
3033
+ // Session is initialized after first bot response (same as StentorDirectChat)
3034
+ if (_this.isNewSession) {
3035
+ _this.isNewSession = false;
3036
+ log("Session initialized after receiving first bot response");
3037
+ }
3035
3038
  message = responseToMessage(response);
3036
3039
  }
3037
3040
  else if (sender.deviceId === "Widget") {
@@ -3054,35 +3057,43 @@ var StentorRouterChat = /** @class */ (function () {
3054
3057
  },
3055
3058
  });
3056
3059
  };
3057
- this.handlers["user joined"] = function (_data, sender, ts, _attributes) {
3060
+ this.handlers["user joined"] = function (data, sender, ts, _attributes) {
3058
3061
  var _a, _b;
3059
3062
  var nick = senderToNick(sender);
3060
3063
  log("Received \"user joined\" event - deviceId: ".concat(sender.deviceId, ", userId: ").concat(sender.userId, ", displayName: ").concat(sender.displayName, ", nick: ").concat(nick));
3061
3064
  log("Dispatching chat.memberjoin for ".concat(sender.displayName || "Unknown"));
3065
+ var userData = data;
3062
3066
  _this.dispatch({
3063
3067
  type: "chat",
3064
3068
  detail: {
3065
3069
  type: "chat.memberjoin",
3066
3070
  user: {
3067
- avatarPath: (_b = (_a = _this.options) === null || _a === void 0 ? void 0 : _a.bot) === null || _b === void 0 ? void 0 : _b.avatarPath,
3071
+ avatarPath: sender.avatarPath || ((_b = (_a = _this.options) === null || _a === void 0 ? void 0 : _a.bot) === null || _b === void 0 ? void 0 : _b.avatarPath),
3068
3072
  displayName: sender.displayName,
3069
3073
  nick: nick,
3070
3074
  },
3071
3075
  timestamp: ts || new Date().getTime(),
3076
+ showDivider: userData === null || userData === void 0 ? void 0 : userData.showDivider,
3077
+ message: userData === null || userData === void 0 ? void 0 : userData.message,
3078
+ hideUserInfo: userData === null || userData === void 0 ? void 0 : userData.hideUserInfo,
3072
3079
  },
3073
3080
  });
3074
3081
  log("chat.memberjoin dispatched for nick: ".concat(nick));
3075
3082
  };
3076
- this.handlers["user left"] = function (_data, sender, ts, _attributes) {
3083
+ this.handlers["user left"] = function (data, sender, ts, _attributes) {
3084
+ var userData = data;
3077
3085
  _this.dispatch({
3078
3086
  type: "chat",
3079
3087
  detail: {
3080
3088
  type: "chat.memberleave",
3081
3089
  user: {
3090
+ avatarPath: sender.avatarPath,
3082
3091
  displayName: sender.displayName,
3083
3092
  nick: senderToNick(sender),
3084
3093
  },
3085
3094
  timestamp: ts || new Date().getTime(),
3095
+ showDivider: userData === null || userData === void 0 ? void 0 : userData.showDivider,
3096
+ message: userData === null || userData === void 0 ? void 0 : userData.message,
3086
3097
  },
3087
3098
  });
3088
3099
  };
@@ -3153,6 +3164,88 @@ var StentorRouterChat = /** @class */ (function () {
3153
3164
  _this.dispatch(dismissWsButton(data.id));
3154
3165
  }, WS_BUTTON_DISMISS_ANIMATION_DURATION);
3155
3166
  };
3167
+ this.handlers["system-message"] = function (data, sender, ts, _attributes) {
3168
+ log("Received \"system-message\" event - id: ".concat(data.id, ", message: ").concat(data.message, ", dismissId: ").concat(data.dismissId));
3169
+ // If there's a dismissId, dispatch dismiss action first
3170
+ if (data.dismissId) {
3171
+ _this.dispatch({
3172
+ type: "chat",
3173
+ detail: {
3174
+ type: "chat.systemmessagedismiss",
3175
+ user: {
3176
+ displayName: sender.displayName || "System",
3177
+ nick: senderToNick(sender),
3178
+ },
3179
+ id: data.dismissId,
3180
+ timestamp: ts || new Date().getTime(),
3181
+ },
3182
+ });
3183
+ }
3184
+ // Then dispatch the new system message
3185
+ _this.dispatch({
3186
+ type: "chat",
3187
+ detail: {
3188
+ type: "chat.systemmessage",
3189
+ user: {
3190
+ displayName: sender.displayName || "System",
3191
+ nick: senderToNick(sender),
3192
+ },
3193
+ id: data.id,
3194
+ message: data.message,
3195
+ dismissId: data.dismissId,
3196
+ timestamp: ts || new Date().getTime(),
3197
+ },
3198
+ });
3199
+ };
3200
+ this.handlers["system-message-dismiss"] = function (data, sender, ts, _attributes) {
3201
+ log("Received \"system-message-dismiss\" event - id: ".concat(data.id));
3202
+ _this.dispatch({
3203
+ type: "chat",
3204
+ detail: {
3205
+ type: "chat.systemmessagedismiss",
3206
+ user: {
3207
+ displayName: sender.displayName || "System",
3208
+ nick: senderToNick(sender),
3209
+ },
3210
+ id: data.id,
3211
+ timestamp: ts || new Date().getTime(),
3212
+ },
3213
+ });
3214
+ };
3215
+ this.handlers["missed messages"] = function (data, _sender, _ts, _attributes) {
3216
+ var _a;
3217
+ var missedData = data;
3218
+ log("Received \"missed messages\" event with ".concat(((_a = missedData === null || missedData === void 0 ? void 0 : missedData.messages) === null || _a === void 0 ? void 0 : _a.length) || 0, " messages"));
3219
+ // Process each missed message
3220
+ if ((missedData === null || missedData === void 0 ? void 0 : missedData.messages) && Array.isArray(missedData.messages)) {
3221
+ missedData.messages.forEach(function (missedMessage) {
3222
+ log("Processing missed message: event=".concat(missedMessage.event, ", messageId=").concat(missedMessage.messageId));
3223
+ // Route the missed message to the appropriate handler
3224
+ var handler = _this.handlers[missedMessage.event];
3225
+ if (handler && missedMessage.event !== "missed messages") {
3226
+ handler(missedMessage.data, missedMessage.sender, missedMessage.timeMs, missedMessage.attributes, missedMessage.messageId);
3227
+ }
3228
+ else {
3229
+ log("No handler for missed message event: ".concat(missedMessage.event));
3230
+ }
3231
+ });
3232
+ }
3233
+ };
3234
+ this.handlers["request missed messages"] = function () {
3235
+ // This is a client→server event, so no handler needed on client side
3236
+ log("Request missed messages handler (no-op on client side)");
3237
+ };
3238
+ // No-op handlers for user activity events (client→server only)
3239
+ // These prevent error logs if the server echoes these events back
3240
+ this.handlers["user backgrounded"] = function () {
3241
+ log("User backgrounded handler (no-op on client side)");
3242
+ };
3243
+ this.handlers["user foregrounded"] = function () {
3244
+ log("User foregrounded handler (no-op on client side)");
3245
+ };
3246
+ this.handlers["user disconnecting"] = function () {
3247
+ log("User disconnecting handler (no-op on client side)");
3248
+ };
3156
3249
  // Register the router as a pseudo-agent (serverInfo) so it can send messages (like internal errors)
3157
3250
  this.dispatch({
3158
3251
  type: "chat",
@@ -3261,7 +3354,7 @@ var StentorRouterChat = /** @class */ (function () {
3261
3354
  var message = JSON.parse(me.data);
3262
3355
  var handler = _this.handlers[message.event];
3263
3356
  if (handler) {
3264
- _this.handlers[message.event](message.data, message.sender, message.timeMs, message.attributes);
3357
+ _this.handlers[message.event](message.data, message.sender, message.timeMs, message.attributes, message.messageId);
3265
3358
  }
3266
3359
  else {
3267
3360
  err("Unknown router message event: ".concat(message.event));
@@ -3455,22 +3548,57 @@ var StentorRouterChat = /** @class */ (function () {
3455
3548
  StentorRouterChat.prototype.dispose = function () {
3456
3549
  log("DISPOSE called - cleaning up connection");
3457
3550
  this.isDisposed = true;
3551
+ // Clear any pending sleep timeout
3552
+ if (this.sleepTimeoutId) {
3553
+ clearTimeout(this.sleepTimeoutId);
3554
+ this.sleepTimeoutId = null;
3555
+ }
3458
3556
  if (this.ws) {
3459
3557
  this.wsClose();
3460
3558
  }
3461
3559
  log("Closed web socket (dispose)");
3462
3560
  };
3463
3561
  StentorRouterChat.prototype.sleep = function () {
3464
- this.isDisposed = true;
3465
- if (this.ws) {
3466
- this.wsClose();
3467
- }
3468
- log("SLEEP called - closed web socket");
3469
- log("Closed web socket (sleep)");
3562
+ var _this = this;
3563
+ log("SLEEP called - scheduling delayed close");
3564
+ // Notify router that user has backgrounded the tab
3565
+ if (this.checkConnection()) {
3566
+ log("SLEEP - Notifying router of user backgrounded");
3567
+ this.emit("user backgrounded");
3568
+ }
3569
+ // Cancel any pending sleep timeout
3570
+ if (this.sleepTimeoutId) {
3571
+ clearTimeout(this.sleepTimeoutId);
3572
+ this.sleepTimeoutId = null;
3573
+ }
3574
+ // Schedule WebSocket close after delay
3575
+ // Note: Don't set isDisposed here - only in dispose(). Setting it here would
3576
+ // prevent reconnection when the user returns to the tab after the timeout.
3577
+ this.sleepTimeoutId = window.setTimeout(function () {
3578
+ if (_this.ws) {
3579
+ _this.wsClose();
3580
+ }
3581
+ log("SLEEP - closed web socket after ".concat(_this.SLEEP_DELAY_MS, "ms delay"));
3582
+ _this.sleepTimeoutId = null;
3583
+ }, this.SLEEP_DELAY_MS);
3584
+ log("SLEEP - WebSocket will close in ".concat(this.SLEEP_DELAY_MS, "ms if not woken up"));
3470
3585
  };
3471
3586
  StentorRouterChat.prototype.wakeup = function () {
3472
- this.isDisposed = false;
3587
+ var _this = this;
3473
3588
  log("WAKEUP called - userId:", this._userId);
3589
+ // Cancel pending sleep if user returned before timeout
3590
+ if (this.sleepTimeoutId) {
3591
+ clearTimeout(this.sleepTimeoutId);
3592
+ this.sleepTimeoutId = null;
3593
+ log("WAKEUP - Cancelled pending sleep, keeping WebSocket open");
3594
+ // Notify router that user has foregrounded the tab (connection still open)
3595
+ if (this.checkConnection()) {
3596
+ log("WAKEUP - Notifying router of user foregrounded");
3597
+ this.emit("user foregrounded");
3598
+ }
3599
+ return; // WebSocket is still open, no need to reconnect
3600
+ }
3601
+ this.isDisposed = false;
3474
3602
  // wait for the session setup
3475
3603
  if (!this._userId) {
3476
3604
  log("WAKEUP - No userId, returning early");
@@ -3484,6 +3612,47 @@ var StentorRouterChat = /** @class */ (function () {
3484
3612
  // Fire up the WebSocket
3485
3613
  log("WAKEUP - Calling autoReconnect");
3486
3614
  this.autoReconnect(this.wsCreate.bind(this, "wakeup"));
3615
+ // Request any missed messages and notify router after reconnection is established
3616
+ // Use waitFor to poll for connection readiness with timeout
3617
+ waitFor(this.checkConnection.bind(this), 100, 5000, "wakeup-connection")
3618
+ .then(function () {
3619
+ // Notify router that user has foregrounded the tab (after reconnect)
3620
+ log("WAKEUP - Notifying router of user foregrounded (after reconnect)");
3621
+ _this.emit("user foregrounded");
3622
+ _this.requestMissedMessages();
3623
+ })
3624
+ .catch(function () {
3625
+ log("WAKEUP - Connection not ready after 5s, skipping missed messages request");
3626
+ });
3627
+ };
3628
+ StentorRouterChat.prototype.requestMissedMessages = function () {
3629
+ log("Requesting missed messages from server");
3630
+ this.emit("request missed messages");
3631
+ };
3632
+ /**
3633
+ * Notifies the router that the user is disconnecting (e.g., closing tab, navigating away).
3634
+ * This is a best-effort notification - it may not arrive before the page unloads.
3635
+ * Should be called from a beforeunload event handler.
3636
+ */
3637
+ StentorRouterChat.prototype.notifyDisconnecting = function () {
3638
+ if (!this.checkConnection()) {
3639
+ return;
3640
+ }
3641
+ log("Notifying router of user disconnecting");
3642
+ var payload = JSON.stringify({
3643
+ event: "user disconnecting",
3644
+ data: { reason: "tab_close" },
3645
+ sender: this.visitorInfo,
3646
+ sessionId: this._sessionId,
3647
+ timeMs: Date.now()
3648
+ });
3649
+ try {
3650
+ this.ws.send(payload);
3651
+ }
3652
+ catch (e) {
3653
+ // Best-effort - page is unloading, so we can't do much if send fails
3654
+ log("Failed to send disconnect notification:", e);
3655
+ }
3487
3656
  };
3488
3657
  StentorRouterChat.prototype.bargeOut = function (_cb) {
3489
3658
  return __awaiter$1(this, void 0, void 0, function () {
@@ -7727,7 +7896,7 @@ var StentorServerChat = /** @class */ (function () {
7727
7896
  type: "chat.memberjoin",
7728
7897
  user: {
7729
7898
  displayName: data.username,
7730
- nick: "agent:robot",
7899
+ nick: data.nick || "agent:robot",
7731
7900
  avatarPath: data.avatarPath
7732
7901
  },
7733
7902
  timestamp: +new Date(),
@@ -7886,7 +8055,7 @@ function useChatServer(config, options) {
7886
8055
  var dispatch = useChatDispatch();
7887
8056
  var deps = [options, config, dispatch];
7888
8057
  // Track previous values to detect what changed
7889
- var prevDepsRef = useRef();
8058
+ var prevDepsRef = useRef(undefined);
7890
8059
  // Log what caused the "effect"
7891
8060
  // useWhatChanged(deps, "options, config, dispatch");
7892
8061
  useEffect(function () {
@@ -7959,17 +8128,16 @@ var ChatChipsContainer = function (_) {
7959
8128
  }));
7960
8129
  }
7961
8130
  }
7962
- return (React$1.createElement("div", { className: "message-list-container__chips ".concat(!(chips === null || chips === void 0 ? void 0 : chips.length) ? "message-list-container__chips--empty" : "") },
7963
- React$1.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
8131
+ return (jsx("div", { className: "message-list-container__chips ".concat(!(chips === null || chips === void 0 ? void 0 : chips.length) ? "message-list-container__chips--empty" : ""), children: jsx(ChatChips, { options: chips, onOptionClick: optionOnChange }) }));
7964
8132
  };
7965
8133
 
7966
8134
  var ButtonGroup = function (_a) {
7967
8135
  var children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b;
7968
- return (React$1.createElement("div", { className: "button-group ".concat(className) }, children));
8136
+ return (jsx("div", { className: "button-group ".concat(className), children: children }));
7969
8137
  };
7970
8138
 
7971
8139
  var CancelButton = function (props) {
7972
- return (React$1.createElement("div", { id: "xapp-widget-close", "aria-label": "close widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "cancel-button", onClick: props.onClick }));
8140
+ return (jsx("div", { id: "xapp-widget-close", "aria-label": "close widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "cancel-button", onClick: props.onClick }));
7973
8141
  };
7974
8142
 
7975
8143
  var lib = {};
@@ -8054,10 +8222,8 @@ var ChatMenuItem = function (props) {
8054
8222
  props.onClick(props.label);
8055
8223
  }
8056
8224
  }
8057
- var content = props.subtitle ? (React$1.createElement("span", null,
8058
- React$1.createElement("div", null, props.label),
8059
- React$1.createElement("div", { className: "chat-menu-item--subtitle" }, props.subtitle))) : (React$1.createElement("span", null, props.label));
8060
- return (React$1.createElement("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick }, content));
8225
+ var content = props.subtitle ? (jsxs("span", { children: [jsx("div", { children: props.label }), jsx("div", { className: "chat-menu-item--subtitle", children: props.subtitle })] })) : (jsx("span", { children: props.label }));
8226
+ return (jsx("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick, children: content }));
8061
8227
  };
8062
8228
 
8063
8229
  var _this = undefined;
@@ -8067,28 +8233,24 @@ var ChatMenu = function (props) {
8067
8233
  var handleOpenUrl = useOpenUrlCallback();
8068
8234
  var chatDispatch = useChatDispatch();
8069
8235
  var visuals = useSelector(function (state) { return state.visuals; });
8070
- return (React$1.createElement("div", { className: "chat-menu-".concat(openFrom, " ").concat(opened ? "chat-menu-".concat(openFrom, "--opened") : "chat-menu-".concat(openFrom, "--closed")) }, items.map(function (item, i) {
8071
- if (lib.isStandardMenuItem(item)) {
8072
- return React$1.createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: item.label, subtitle: item.subtitle });
8073
- }
8074
- else if (lib.isStaticImageMenuItem(item)) {
8075
- return (React$1.createElement("div", { key: i, className: "chat-menu-item-static" },
8076
- React$1.createElement("img", { style: {
8077
- maxHeight: "100%",
8078
- maxWidth: "auto"
8079
- }, src: item.imageUrl, alt: "Menu Item" })));
8080
- }
8081
- else if (lib.isStaticTextMenuItem(item)) {
8082
- return (React$1.createElement("div", { key: i, className: "chat-menu-item-static-text" },
8083
- React$1.createElement("div", null,
8084
- React$1.createElement("div", null, item.title),
8085
- React$1.createElement("div", { className: "chat-menu-item-static-text--body" }, item.body))));
8086
- }
8087
- else if (lib.isOpenURLMenuItem(item)) {
8088
- return React$1.createElement("button", { key: i, className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior) }, item.text);
8089
- }
8090
- return React$1.createElement("p", null, "Unknown");
8091
- })));
8236
+ return (jsx("div", { className: "chat-menu-".concat(openFrom, " ").concat(opened ? "chat-menu-".concat(openFrom, "--opened") : "chat-menu-".concat(openFrom, "--closed")), children: items.map(function (item, i) {
8237
+ if (lib.isStandardMenuItem(item)) {
8238
+ return (jsx(ChatMenuItem, { onClick: props.onItemClick, label: item.label, subtitle: item.subtitle }, i));
8239
+ }
8240
+ else if (lib.isStaticImageMenuItem(item)) {
8241
+ return (jsx("div", { className: "chat-menu-item-static", children: jsx("img", { style: {
8242
+ maxHeight: "100%",
8243
+ maxWidth: "auto",
8244
+ }, src: item.imageUrl, alt: "Menu Item" }) }, i));
8245
+ }
8246
+ else if (lib.isStaticTextMenuItem(item)) {
8247
+ return (jsx("div", { className: "chat-menu-item-static-text", children: jsxs("div", { children: [jsx("div", { children: item.title }), jsx("div", { className: "chat-menu-item-static-text--body", children: item.body })] }) }, i));
8248
+ }
8249
+ else if (lib.isOpenURLMenuItem(item)) {
8250
+ return (jsx("button", { className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior), children: item.text }, i));
8251
+ }
8252
+ return jsx("p", { children: "Unknown" });
8253
+ }) }));
8092
8254
  };
8093
8255
 
8094
8256
  var DrawerBars = function (props) {
@@ -8100,23 +8262,23 @@ var DrawerBars = function (props) {
8100
8262
  function getBars() {
8101
8263
  var barElements = [];
8102
8264
  for (var bar = 0; bar < bars; bar++) {
8103
- barElements.push(React$1.createElement("div", { key: "drawer-bar-".concat(bar), className: "drawer-bar bar".concat(bar) }));
8265
+ barElements.push(jsx("div", { className: "drawer-bar bar".concat(bar) }, "drawer-bar-".concat(bar)));
8104
8266
  }
8105
8267
  return barElements;
8106
8268
  }
8107
- return (React$1.createElement("button", { className: "drawer-bars", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, "aria-label": "open menu", "aria-hidden": false, onClick: props.onToggle }, getBars()));
8269
+ return (jsx("button", { className: "drawer-bars", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, "aria-label": "open menu", "aria-hidden": false, onClick: props.onToggle, children: getBars() }));
8108
8270
  };
8109
8271
 
8110
8272
  var MenuButton = function (props) {
8111
- return (React$1.createElement("div", { id: "xapp-widget-menu", "aria-label": "open menu", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "menu-button", onClick: props.onClick }));
8273
+ return (jsx("div", { id: "xapp-widget-menu", "aria-label": "open menu", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "menu-button", onClick: props.onClick }));
8112
8274
  };
8113
8275
 
8114
8276
  var MinimizeButton = function (props) {
8115
- return (React$1.createElement("div", { id: "xapp-widget-minimize", "aria-label": "minimize widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "minimize-button ".concat(props.showInRight ? "positionRight" : ""), onClick: props.onClick }));
8277
+ return (jsx("div", { id: "xapp-widget-minimize", "aria-label": "minimize widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "minimize-button ".concat(props.showInRight ? "positionRight" : ""), onClick: props.onClick }));
8116
8278
  };
8117
8279
 
8118
8280
  var RefreshButton = function (props) {
8119
- return (React$1.createElement("div", { id: "xapp-widget-refresh", "aria-label": "refresh chat", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "refresh-button ".concat(props.showInRight ? "positionRight" : props.showInLeft ? "positionLeft" : ""), onClick: props.onClick }));
8281
+ return (jsx("div", { id: "xapp-widget-refresh", "aria-label": "refresh chat", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "refresh-button ".concat(props.showInRight ? "positionRight" : props.showInLeft ? "positionLeft" : ""), onClick: props.onClick }));
8120
8282
  };
8121
8283
 
8122
8284
  var DEFAULT_STATUS_CONFIG = {
@@ -8139,14 +8301,119 @@ function getStatusText(status, config) {
8139
8301
  return (_d = config === null || config === void 0 ? void 0 : config.connecting) !== null && _d !== void 0 ? _d : DEFAULT_STATUS_CONFIG.connecting;
8140
8302
  }
8141
8303
  }
8304
+ /**
8305
+ * Determines if a string contains HTML tags
8306
+ */
8307
+ function isHtmlString(text) {
8308
+ if (typeof text !== "string") {
8309
+ return false;
8310
+ }
8311
+ // Check for common HTML patterns
8312
+ var htmlPattern = /<\/?[a-z][\s\S]*>/i;
8313
+ return htmlPattern.test(text);
8314
+ }
8315
+ /**
8316
+ * Sanitizes HTML string by removing potentially dangerous elements and attributes
8317
+ */
8318
+ function sanitizeHtml(html) {
8319
+ try {
8320
+ // Check if DOMParser is available
8321
+ if (typeof DOMParser === "undefined") {
8322
+ log("DOMParser not available, returning text content only");
8323
+ return html.replace(/<[^>]*>/g, ""); // Strip all HTML tags as fallback
8324
+ }
8325
+ // Create a temporary DOM element to parse the HTML
8326
+ var doc_1 = new DOMParser().parseFromString(html, "text/html");
8327
+ // Check if parsing was successful
8328
+ if (!doc_1 || !doc_1.body) {
8329
+ log("DOMParser failed to parse HTML, returning text content only");
8330
+ return html.replace(/<[^>]*>/g, ""); // Strip all HTML tags as fallback
8331
+ }
8332
+ // List of allowed tags (whitelist approach)
8333
+ var allowedTags_1 = ["span", "div", "p", "strong", "em", "b", "i", "u", "br"];
8334
+ // List of allowed style properties
8335
+ var allowedStyleProps_1 = [
8336
+ "color", "background-color", "font-size", "font-weight", "font-style",
8337
+ "text-align", "display", "flex", "align-items", "justify-content",
8338
+ "gap", "margin", "padding", "width", "height", "border-radius"
8339
+ ];
8340
+ // Recursive function to clean nodes
8341
+ var cleanNode_1 = function (node) {
8342
+ if (node.nodeType === Node.ELEMENT_NODE) {
8343
+ var element_1 = node;
8344
+ var tagName = element_1.tagName.toLowerCase();
8345
+ // Remove if not in allowed tags, but preserve text content
8346
+ if (!allowedTags_1.includes(tagName)) {
8347
+ // Replace the element with its text content
8348
+ var textNode = doc_1.createTextNode(element_1.textContent || "");
8349
+ element_1.replaceWith(textNode);
8350
+ return;
8351
+ }
8352
+ // Remove all attributes except style
8353
+ var attributes = Array.from(element_1.attributes);
8354
+ attributes.forEach(function (attr) {
8355
+ if (attr.name !== "style") {
8356
+ element_1.removeAttribute(attr.name);
8357
+ }
8358
+ });
8359
+ // Clean style attribute - only allow safe properties
8360
+ if (element_1.hasAttribute("style")) {
8361
+ var styleText = element_1.getAttribute("style") || "";
8362
+ var cleanedStyles_1 = [];
8363
+ // Parse individual style properties
8364
+ styleText.split(";").forEach(function (declaration) {
8365
+ var _a = declaration.split(":"), prop = _a[0], valueParts = _a.slice(1);
8366
+ var value = valueParts.join(":").trim(); // Rejoin in case value contains colons
8367
+ var propTrimmed = prop.trim();
8368
+ if (propTrimmed && value && allowedStyleProps_1.includes(propTrimmed.toLowerCase())) {
8369
+ // Additional validation: ensure value doesn't contain javascript: or expression()
8370
+ if (!/javascript:|expression\(|@import|behavior:/i.test(value)) {
8371
+ cleanedStyles_1.push("".concat(propTrimmed, ": ").concat(value));
8372
+ }
8373
+ }
8374
+ });
8375
+ if (cleanedStyles_1.length > 0) {
8376
+ element_1.setAttribute("style", cleanedStyles_1.join("; "));
8377
+ }
8378
+ else {
8379
+ element_1.removeAttribute("style");
8380
+ }
8381
+ }
8382
+ // Recursively clean child nodes
8383
+ var children = Array.from(element_1.childNodes);
8384
+ children.forEach(function (child) { return cleanNode_1(child); });
8385
+ }
8386
+ };
8387
+ // Clean each child of the body, not the body itself
8388
+ Array.from(doc_1.body.childNodes).forEach(function (child) { return cleanNode_1(child); });
8389
+ return doc_1.body.innerHTML;
8390
+ }
8391
+ catch (error) {
8392
+ log("Error sanitizing HTML: ".concat(error));
8393
+ // Fallback: strip all HTML tags
8394
+ return html.replace(/<[^>]*>/g, "");
8395
+ }
8396
+ }
8397
+ /**
8398
+ * Safely renders subtitle text that can be plain text, JSX, or HTML string
8399
+ */
8400
+ function renderSubtitleText(text) {
8401
+ // If it's an HTML string, sanitize and render it using dangerouslySetInnerHTML
8402
+ if (isHtmlString(text)) {
8403
+ var sanitizedHtml = sanitizeHtml(text);
8404
+ return jsx("span", { dangerouslySetInnerHTML: { __html: sanitizedHtml } });
8405
+ }
8406
+ // Otherwise, render as-is (handles JSX and plain text)
8407
+ return text;
8408
+ }
8142
8409
  var refreshButtonAriaLabel = "To refresh chat click on clockwise gapped circle arrow icon in top right side of widget. ";
8143
8410
  var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top right side of widget. ";
8144
8411
  var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
8145
8412
  var ChatHeader = function (props) {
8146
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
8413
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
8147
8414
  var innerDispatch = useChatDispatch();
8148
8415
  var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
8149
- var _s = useState(false), drawerOpen = _s[0], setDrawerState = _s[1]; // false initially
8416
+ var _r = useState(false), drawerOpen = _r[0], setDrawerState = _r[1]; // false initially
8150
8417
  var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
8151
8418
  var showMenuLeft = menuPosition === "HEADER_LEFT";
8152
8419
  var showMenuRight = menuPosition === "HEADER_RIGHT";
@@ -8178,50 +8445,30 @@ var ChatHeader = function (props) {
8178
8445
  if (canCancel) {
8179
8446
  ariaLabel = "".concat(ariaLabel).concat(closeButtonAriaLabel);
8180
8447
  }
8181
- return (React$1.createElement(React$1.Fragment, null,
8182
- React$1.createElement("div", { className: "status-container background-header", "aria-label": ariaLabel, "aria-hidden": false },
8183
- showMenuLeft && menuItems.length ? (React$1.createElement(React$1.Fragment, null,
8184
- React$1.createElement("div", { className: "chat-footer__menu-icon" },
8185
- React$1.createElement(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer })))) : (React$1.createElement(React$1.Fragment, null)),
8186
- ((_b = props === null || props === void 0 ? void 0 : props.agent) === null || _b === void 0 ? void 0 : _b.avatarPath) === undefined ? (React$1.createElement("div", null)) : (React$1.createElement("div", { className: "status-container__avatar" },
8187
- React$1.createElement(Avatar, { entity: props.agent }))),
8188
- React$1.createElement("div", { className: "\n ".concat("status-text", "\n ").concat(showMenuLeft && menuItems.length
8189
- ? "status-text-positionWithMenu"
8190
- : ((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined
8191
- ? "status-text-positionLeftNoAvatar"
8192
- : "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter)
8193
- ? "status-text-positionCenter"
8194
- : "", " \n ") },
8195
- React$1.createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status)),
8196
- ((_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.enabled) && (React$1.createElement("span", { className: "status-text-subtitle" }, (_k = (_j = (_h = props.config) === null || _h === void 0 ? void 0 : _h.subtitle) === null || _j === void 0 ? void 0 : _j.text) !== null && _k !== void 0 ? _k : ""))),
8197
- React$1.createElement(ButtonGroup, null,
8198
- hasRightMenu && (React$1.createElement(MenuButton, { onClick: toggleDrawer, tabIndex: menuButtonTabIndex })),
8199
- props.canRefresh && (React$1.createElement(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_m = (_l = props.config) === null || _l === void 0 ? void 0 : _l.actions) === null || _m === void 0 ? void 0 : _m.refreshTabIndex, showInLeft: false, showInRight: false })),
8200
- props.canMinimize && (React$1.createElement(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_p = (_o = props.config) === null || _o === void 0 ? void 0 : _o.actions) === null || _p === void 0 ? void 0 : _p.minimizeTabIndex, showInRight: false })),
8201
- props.canCancel && (React$1.createElement(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_r = (_q = props.config) === null || _q === void 0 ? void 0 : _q.actions) === null || _r === void 0 ? void 0 : _r.cancelTabIndex })))),
8202
- drawerOpen ? (React$1.createElement("div", { className: "xa-chat-menu-container" },
8203
- React$1.createElement(ChatMenu, { openFrom: showMenuRight ? "right" : "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }))) : (React$1.createElement(React$1.Fragment, null))));
8448
+ return (jsxs(Fragment, { children: [jsxs("div", { className: "status-container background-header", "aria-label": ariaLabel, "aria-hidden": false, children: [showMenuLeft && menuItems.length ? (jsx(Fragment, { children: jsx("div", { className: "chat-footer__menu-icon", children: jsx(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }) }) })) : (jsx(Fragment, {})), ((_b = props === null || props === void 0 ? void 0 : props.agent) === null || _b === void 0 ? void 0 : _b.avatarPath) === undefined ? (jsx("div", {})) : (jsx("div", { className: "status-container__avatar", children: jsx(Avatar, { entity: props.agent }) })), jsxs("div", { className: "\n ".concat("status-text", "\n ").concat(showMenuLeft && menuItems.length
8449
+ ? "status-text-positionWithMenu"
8450
+ : ((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined
8451
+ ? "status-text-positionLeftNoAvatar"
8452
+ : "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter)
8453
+ ? "status-text-positionCenter"
8454
+ : "", " \n "), children: [jsx("span", { className: "status-text-title", children: getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status) }), ((_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.enabled) && (jsx("span", { className: "status-text-subtitle", children: renderSubtitleText((_j = (_h = props.config) === null || _h === void 0 ? void 0 : _h.subtitle) === null || _j === void 0 ? void 0 : _j.text) }))] }), jsxs(ButtonGroup, { children: [hasRightMenu && (jsx(MenuButton, { onClick: toggleDrawer, tabIndex: menuButtonTabIndex })), props.canRefresh && (jsx(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_l = (_k = props.config) === null || _k === void 0 ? void 0 : _k.actions) === null || _l === void 0 ? void 0 : _l.refreshTabIndex, showInLeft: false, showInRight: false })), props.canMinimize && (jsx(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_o = (_m = props.config) === null || _m === void 0 ? void 0 : _m.actions) === null || _o === void 0 ? void 0 : _o.minimizeTabIndex, showInRight: false })), props.canCancel && (jsx(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.actions) === null || _q === void 0 ? void 0 : _q.cancelTabIndex }))] })] }), drawerOpen ? (jsx("div", { className: "xa-chat-menu-container", children: jsx(ChatMenu, { openFrom: showMenuRight ? "right" : "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) })) : (jsx(Fragment, {}))] }));
8204
8455
  };
8205
8456
 
8206
- var UnknownMessage = function () { return React$1.createElement(React$1.Fragment, null); };
8457
+ var UnknownMessage = function () { return jsx(Fragment, {}); };
8207
8458
 
8208
8459
  function renderAvatar(entity) {
8209
- return (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar" },
8210
- React$1.createElement(Avatar, { entity: entity })));
8460
+ return (jsx("div", { className: "xappw-chat-msg-part__avatar", children: jsx(Avatar, { entity: entity }) }));
8211
8461
  }
8212
8462
  var ChatMessagePart = function (props) {
8213
8463
  var _a;
8214
8464
  var position = (_a = props.avatarPosition) !== null && _a !== void 0 ? _a : "left";
8215
8465
  var containerClass = "xappw-chat-msg-part" +
8216
- (position === "below" ? " xappw-chat-msg-part--avatar-below" : "");
8217
- var user = props.user;
8218
- return (React$1.createElement("div", { className: containerClass }, position === "left" ? (React$1.createElement(React$1.Fragment, null,
8219
- props.showAvatar && renderAvatar(user),
8220
- props.children)) : (React$1.createElement(React$1.Fragment, null,
8221
- props.children,
8222
- props.showAvatar && (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar-wrapper" },
8223
- renderAvatar(user),
8224
- (user === null || user === void 0 ? void 0 : user.displayName) && (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar-name" }, user.displayName))))))));
8466
+ (position === "below" ? " xappw-chat-msg-part--avatar-below" : "") +
8467
+ (position === "bottom" ? " xappw-chat-msg-part--avatar-bottom" : "");
8468
+ var user = props.user, hideUserInfo = props.hideUserInfo;
8469
+ // Hide user info if hideUserInfo is true and position is "bottom"
8470
+ var shouldHideUserInfo = hideUserInfo && position === "bottom";
8471
+ return (jsx("div", { className: containerClass, children: position === "left" ? (jsxs(Fragment, { children: [props.showAvatar && renderAvatar(user), props.children] })) : (jsxs(Fragment, { children: [props.children, props.showAvatar && !shouldHideUserInfo && (jsxs("div", { className: "xappw-chat-msg-part__avatar-wrapper", children: [renderAvatar(user), (user === null || user === void 0 ? void 0 : user.displayName) && (jsx("div", { className: "xappw-chat-msg-part__avatar-name", children: user.displayName }))] }))] })) }));
8225
8472
  };
8226
8473
 
8227
8474
  function useExecuteActionCallback() {
@@ -8272,14 +8519,12 @@ var CardMiddlewareWidget = function (props) {
8272
8519
  var card = useMemo(function () { return convertFromCardDisplay(msg); }, [msg]);
8273
8520
  var user = ctx.user;
8274
8521
  var handleButton = useButtonCallback();
8275
- return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
8276
- React$1.createElement("div", { className: "chat-msg" },
8277
- React$1.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
8522
+ return (jsx(ChatMessagePart, { showAvatar: true, user: user, children: jsx("div", { className: "chat-msg", children: jsx(ChatCard, { card: card, onButtonClick: handleButton }) }) }));
8278
8523
  };
8279
8524
  var CardMiddleware = function (next) { return function (props) {
8280
8525
  var msg = props.msg, ctx = props.ctx;
8281
8526
  if (isCard(msg)) {
8282
- return React$1.createElement(CardMiddlewareWidget, { msg: msg, ctx: ctx });
8527
+ return jsx(CardMiddlewareWidget, { msg: msg, ctx: ctx });
8283
8528
  }
8284
8529
  return next(props);
8285
8530
  }; };
@@ -8363,16 +8608,14 @@ function useLateMiddleware() {
8363
8608
  }
8364
8609
 
8365
8610
  function getSvg() {
8366
- return (React$1.createElement("svg", { viewBox: "0 0 20 20" },
8367
- React$1.createElement("path", { d: "M17 17H3V3h5V1H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5h-2z" }),
8368
- React$1.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
8611
+ return (jsxs("svg", { viewBox: "0 0 20 20", children: [jsx("path", { d: "M17 17H3V3h5V1H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5h-2z" }), jsx("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })] }));
8369
8612
  }
8370
8613
  var ExternalLink = function (props) {
8371
8614
  var url = props.url;
8372
8615
  var handleClick = useCallback(function (ev) {
8373
8616
  ev.preventDefault();
8374
8617
  }, []);
8375
- return (React$1.createElement("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick }, getSvg()));
8618
+ return (jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick, children: getSvg() }));
8376
8619
  };
8377
8620
 
8378
8621
  function firstIndex(val, patterns) {
@@ -8485,7 +8728,7 @@ var SmartLink = function (props) {
8485
8728
  var handleClick = useCallback(function (ev) {
8486
8729
  ev.preventDefault();
8487
8730
  }, []);
8488
- return (React$1.createElement("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: className, onClick: handleClick }, reduceLink(url, 40)));
8731
+ return (jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: className, onClick: handleClick, children: reduceLink(url, 40) }));
8489
8732
  };
8490
8733
 
8491
8734
  var ListItem = function (props) {
@@ -8493,18 +8736,7 @@ var ListItem = function (props) {
8493
8736
  var item = props.item;
8494
8737
  var layout = props.layout || "normal";
8495
8738
  var url = item.url || item.imageActionUrl;
8496
- return (React$1.createElement(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
8497
- React$1.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout) },
8498
- React$1.createElement("div", { className: "xappw-vlist-item__description" },
8499
- item.title && React$1.createElement("div", { className: "xappw-vlist-item__title" },
8500
- React$1.createElement("span", null, item.title)),
8501
- url && React$1.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
8502
- item.subTitle && React$1.createElement("div", { className: "xappw-vlist-item__subtitle" },
8503
- React$1.createElement("span", null, item.subTitle)),
8504
- !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
8505
- React$1.createElement("div", { className: "xappw-vlist-item__side" },
8506
- url && React$1.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
8507
- React$1.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
8739
+ return (jsx(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl, children: jsxs("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout), children: [jsxs("div", { className: "xappw-vlist-item__description", children: [item.title && (jsx("div", { className: "xappw-vlist-item__title", children: jsx("span", { children: item.title }) })), url && jsx(SmartLink, { url: url, className: "xappw-vlist-item__link" }), item.subTitle && (jsx("div", { className: "xappw-vlist-item__subtitle", children: jsx("span", { children: item.subTitle }) })), !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && (jsx(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick }))] }), jsxs("div", { className: "xappw-vlist-item__side", children: [url && jsx(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }), jsx(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })] })] }) }));
8508
8740
  };
8509
8741
 
8510
8742
  var List = function (props) {
@@ -8513,13 +8745,9 @@ var List = function (props) {
8513
8745
  var hasImage = list.items.some(function (item) { return item.imageUrl; });
8514
8746
  var titlesOnly = !list.items.some(function (item) { var _a; return item.subTitle || ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length); });
8515
8747
  var listItems = list.items.map(function (item, itemIndex) {
8516
- return (React$1.createElement("div", { className: "xappw-vlist-container__item", key: "item-key-".concat(itemIndex) },
8517
- React$1.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
8748
+ return (jsx("div", { className: "xappw-vlist-container__item", children: jsx(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl }) }, "item-key-".concat(itemIndex)));
8518
8749
  });
8519
- return (React$1.createElement("div", { className: "xappw-vlist" },
8520
- React$1.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
8521
- props.list.title && React$1.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
8522
- listItems)));
8750
+ return (jsx("div", { className: "xappw-vlist", children: jsxs("div", { ref: listRef, className: "xappw-vlist-container", children: [props.list.title && jsx("div", { className: "xappw-vlist__header", children: props.list.title }), listItems] }) }));
8523
8751
  };
8524
8752
 
8525
8753
  var ListMiddlewareWidget = function (props) {
@@ -8534,16 +8762,12 @@ var ListMiddlewareWidget = function (props) {
8534
8762
  }, [executeActionCallback]);
8535
8763
  var handleButton = useButtonCallback();
8536
8764
  var user = ctx.user;
8537
- return (React$1.createElement(ChatMessagePart, { showAvatar: false, user: user },
8538
- list.type === "CAROUSEL" && (React$1.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
8539
- React$1.createElement(Carousel, { list: list, onExecute: handleExecute.bind(null, "carousel"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))),
8540
- list.type === "LIST" && (React$1.createElement("div", { className: "chat-msg chat-msg--expand" },
8541
- React$1.createElement(List, { list: list, onExecute: handleExecute.bind(null, "list"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl })))));
8765
+ return (jsxs(ChatMessagePart, { showAvatar: false, user: user, children: [list.type === "CAROUSEL" && (jsx("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava", children: jsx(Carousel, { list: list, onExecute: handleExecute.bind(null, "carousel"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }) })), list.type === "LIST" && (jsx("div", { className: "chat-msg chat-msg--expand", children: jsx(List, { list: list, onExecute: handleExecute.bind(null, "list"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }) }))] }));
8542
8766
  };
8543
8767
  var ListMiddleware = function (next) { return function (props) {
8544
8768
  var msg = props.msg, ctx = props.ctx;
8545
8769
  if (isList(msg)) {
8546
- return React$1.createElement(ListMiddlewareWidget, { msg: msg, ctx: ctx });
8770
+ return jsx(ListMiddlewareWidget, { msg: msg, ctx: ctx });
8547
8771
  }
8548
8772
  return next(props);
8549
8773
  }; };
@@ -8555,10 +8779,7 @@ var MultiSelect = function (props) {
8555
8779
  var id = ev.target.value;
8556
8780
  onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
8557
8781
  }, [checked, onChange]);
8558
- return (React$1.createElement("ul", { className: "xappw-multiselect" }, items === null || items === void 0 ? void 0 : items.map(function (item) { return (React$1.createElement("li", { key: item.id },
8559
- React$1.createElement("label", null,
8560
- React$1.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
8561
- React$1.createElement("span", null, item.title)))); })));
8782
+ return (jsx("ul", { className: "xappw-multiselect", children: items === null || items === void 0 ? void 0 : items.map(function (item) { return (jsx("li", { children: jsxs("label", { children: [jsx("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }), jsx("span", { children: item.title })] }) }, item.id)); }) }));
8562
8783
  };
8563
8784
 
8564
8785
  function isMultiSelect(display) {
@@ -8578,20 +8799,16 @@ var MultiSelectMiddlewareWidget = function (props) {
8578
8799
  payload: JSON.stringify({
8579
8800
  type: "OPTION_SELECT_REQUEST",
8580
8801
  intentId: "OptionSelect",
8581
- selected: Object.keys(checked).map(function (k) { return ({ id: k }); })
8582
- })
8802
+ selected: Object.keys(checked).map(function (k) { return ({ id: k }); }),
8803
+ }),
8583
8804
  });
8584
8805
  }, [ctx, checked]);
8585
- return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
8586
- React$1.createElement("div", { className: "chat-msg" },
8587
- React$1.createElement("div", null,
8588
- React$1.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
8589
- React$1.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
8806
+ return (jsx(ChatMessagePart, { showAvatar: true, user: user, children: jsx("div", { className: "chat-msg", children: jsxs("div", { children: [jsx(MultiSelect, { items: items, checked: checked, onChange: setChecked }), jsx(ActionButton, { label: "Submit", onClick: handleSubmit })] }) }) }));
8590
8807
  };
8591
8808
  var MultiSelectMiddleware = function (next) { return function (props) {
8592
8809
  var msg = props.msg, ctx = props.ctx;
8593
8810
  if (isMultiSelect(msg)) {
8594
- return React$1.createElement(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
8811
+ return jsx(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
8595
8812
  }
8596
8813
  return next(props);
8597
8814
  }; };
@@ -8621,8 +8838,7 @@ function getTailSvgPath(owner) {
8621
8838
  return "m 0 0 v 240 h 60 c -40 -40 -60 -160 -60 -240";
8622
8839
  }
8623
8840
  function getTailSvg(owner) {
8624
- return (React$1.createElement("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240" },
8625
- React$1.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
8841
+ return (jsx("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240", children: jsx("path", { d: getTailSvgPath(owner), fill: "currentColor" }) }));
8626
8842
  }
8627
8843
  var ChatMessageBubble = function (props) {
8628
8844
  var owner = props.owner, onClick = props.onClick;
@@ -8631,15 +8847,13 @@ var ChatMessageBubble = function (props) {
8631
8847
  onClick();
8632
8848
  }
8633
8849
  }, [onClick]);
8634
- return (React$1.createElement("div", { onClick: handleClick, className: "chat-text-bubble ".concat(owner === "mine" ? "chat-text-bubble--mine" : "chat-text-bubble--others") },
8635
- (props.hasTail) && getTailSvg(owner),
8636
- props.children));
8850
+ return (jsxs("div", { onClick: handleClick, className: "chat-text-bubble ".concat(owner === "mine" ? "chat-text-bubble--mine" : "chat-text-bubble--others"), children: [props.hasTail && getTailSvg(owner), props.children] }));
8637
8851
  };
8638
8852
 
8639
8853
  var ChatMarkdownMessage = function (props) {
8640
8854
  var onOpenUrl = props.onOpenUrl;
8641
8855
  var agentMessage = isAgent(props.message.user.nick);
8642
- var ref = useRef();
8856
+ var ref = useRef(null);
8643
8857
  var chatDispatch = useChatDispatch();
8644
8858
  var visuals = useSelector(function (state) { return state.visuals; });
8645
8859
  var html = props.message.msg.html;
@@ -8667,11 +8881,7 @@ var ChatMarkdownMessage = function (props) {
8667
8881
  }
8668
8882
  return undefined;
8669
8883
  }, [ref, html, onOpenUrl, handleLinkClick]);
8670
- return (React$1.createElement("div", { className: "chat-msg" },
8671
- React$1.createElement("div", { className: "chat-text-container" },
8672
- React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
8673
- React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + (agentMessage ? " the bot said" : " the user said")),
8674
- React$1.createElement("div", { ref: ref })))));
8884
+ return (jsx("div", { className: "chat-msg", children: jsx("div", { className: "chat-text-container", children: jsxs(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling, children: [jsx("span", { className: "message-sr-only", children: "at " + props.time + (agentMessage ? " the bot said" : " the user said") }), jsx("div", { ref: ref })] }) }) }));
8675
8885
  };
8676
8886
 
8677
8887
  var ChatPermissionMessage = function (props) {
@@ -8689,14 +8899,14 @@ var ChatPermissionMessage = function (props) {
8689
8899
  ctx.write({
8690
8900
  type: "msg",
8691
8901
  user: author,
8692
- msg: msg
8902
+ msg: msg,
8693
8903
  });
8694
8904
  }, [ctx, author]);
8695
8905
  var writeAsUser = useCallback(function (msg) {
8696
8906
  ctx.write({
8697
8907
  type: "msg",
8698
8908
  user: user,
8699
- msg: msg
8909
+ msg: msg,
8700
8910
  });
8701
8911
  }, [ctx, user]);
8702
8912
  var handleFail = useCallback(function () {
@@ -8704,28 +8914,30 @@ var ChatPermissionMessage = function (props) {
8704
8914
  type: "msg",
8705
8915
  user: undefined,
8706
8916
  msg: {
8707
- text: denyLabel
8708
- }
8917
+ text: denyLabel,
8918
+ },
8709
8919
  });
8710
8920
  }, [ctx]);
8711
8921
  var handleSend = useCallback(function (msg) {
8712
8922
  ctx.send({
8713
8923
  type: "permissionGrant",
8714
8924
  user: author,
8715
- msg: msg
8925
+ msg: msg,
8716
8926
  });
8717
8927
  }, [author, ctx]);
8718
8928
  var handleResult = useCallback(function (position, userMsg) {
8719
8929
  handleSend({
8720
8930
  text: userMsg,
8721
- location: position ? {
8722
- latitude: position.coords.latitude,
8723
- longitude: position.coords.longitude
8724
- } : undefined,
8725
- permissionRequest: permissionRequest
8931
+ location: position
8932
+ ? {
8933
+ latitude: position.coords.latitude,
8934
+ longitude: position.coords.longitude,
8935
+ }
8936
+ : undefined,
8937
+ permissionRequest: permissionRequest,
8726
8938
  });
8727
8939
  writeAsUser({
8728
- text: userMsg
8940
+ text: userMsg,
8729
8941
  });
8730
8942
  var agentMsg = position ? permissionRequest === null || permissionRequest === void 0 ? void 0 : permissionRequest.approve : permissionRequest === null || permissionRequest === void 0 ? void 0 : permissionRequest.deny;
8731
8943
  if (agentMsg) {
@@ -8745,25 +8957,17 @@ var ChatPermissionMessage = function (props) {
8745
8957
  }
8746
8958
  }, [handleFail, handleResult]);
8747
8959
  if (!permissionRequest) {
8748
- return React$1.createElement(React$1.Fragment, null);
8960
+ return jsx(Fragment, {});
8749
8961
  }
8750
- return (React$1.createElement("div", { className: "chat-msg" },
8751
- React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + (agentMessage ? " the bot said" : " the user said")),
8752
- React$1.createElement("div", { className: "buttons-container" },
8753
- React$1.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
8754
- React$1.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
8962
+ return (jsxs("div", { className: "chat-msg", children: [jsx("span", { className: "message-sr-only", children: "at " + props.time + (agentMessage ? " the bot said" : " the user said") }), jsxs("div", { className: "buttons-container", children: [jsx(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }), jsx(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny })] })] }));
8755
8963
  };
8756
8964
 
8757
8965
  var ChatTextMessage = function (props) {
8758
8966
  var message = props.message;
8759
8967
  var date = new Date(message.timestamp);
8760
- var time = date.getHours() + ':' + date.getMinutes();
8968
+ var time = date.getHours() + ":" + date.getMinutes();
8761
8969
  var agentMessage = isAgent(props.message.user.nick);
8762
- return (React$1.createElement("div", { className: "chat-msg" },
8763
- React$1.createElement("div", { className: "chat-text-container" },
8764
- React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
8765
- React$1.createElement("span", { className: "message-sr-only" }, "at " + time + (agentMessage ? " the bot said" : " the user said")),
8766
- React$1.createElement("span", null, message.msg.text)))));
8970
+ return (jsx("div", { className: "chat-msg", children: jsx("div", { className: "chat-text-container", children: jsxs(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling, children: [jsx("span", { className: "message-sr-only", children: "at " + time + (agentMessage ? " the bot said" : " the user said") }), jsx("span", { children: message.msg.text })] }) }) }));
8767
8971
  };
8768
8972
 
8769
8973
  var ChatScheduleWidget = function (props) {
@@ -8774,10 +8978,7 @@ var ChatScheduleWidget = function (props) {
8774
8978
  function handleClick() {
8775
8979
  openUrl(scheduleWidgetUrl, chatDispatch, visuals);
8776
8980
  }
8777
- return (React$1.createElement("div", { className: "chat-schedule-button-container" },
8778
- React$1.createElement("button", { className: "chat-schedule-button", onClick: handleClick },
8779
- React$1.createElement("i", { className: "fa fa-lg fa-calendar" }),
8780
- React$1.createElement("span", null, display.label || "Schedule Now!"))));
8981
+ return (jsx("div", { className: "chat-schedule-button-container", children: jsxs("button", { className: "chat-schedule-button", onClick: handleClick, children: [jsx("i", { className: "fa fa-lg fa-calendar" }), jsx("span", { children: display.label || "Schedule Now!" })] }) }));
8781
8982
  };
8782
8983
 
8783
8984
  function getClassName(msg) {
@@ -8791,13 +8992,17 @@ var avaKeys = ["text", "html", "card", "list"];
8791
8992
  * @returns
8792
8993
  */
8793
8994
  var ChatMessage = function (props) {
8995
+ var _a;
8794
8996
  var middleware = props.messageMiddleware || StandardMiddlewares;
8795
8997
  var chatConfig = useContext(ChatConfigContext);
8796
8998
  // console.log(`########### chatConfig: ${JSON.stringify(chatConfig, null, 2)}`);
8797
8999
  var ctx = props.middlewareContext;
8798
9000
  var user = props.agent;
9001
+ // Get hideUserInfo from the agent info based on the message sender's nick
9002
+ var agentInfo = (_a = props.agents) === null || _a === void 0 ? void 0 : _a[props.message.user.nick];
9003
+ var hideUserInfo = (agentInfo === null || agentInfo === void 0 ? void 0 : agentInfo.hideUserInfo) || false;
8799
9004
  function renderByType() {
8800
- var _a;
9005
+ var _a, _b, _c, _d;
8801
9006
  var msg = props.message.msg;
8802
9007
  switch (props.message.type) {
8803
9008
  // TODO: props actually requires it to be "chat.msg". Fix prop typing?
@@ -8805,38 +9010,27 @@ var ChatMessage = function (props) {
8805
9010
  // Here is the deal. If we have text (output speech), then text - card - list - options
8806
9011
  // OR card OR list only. Avatar with text bubble.
8807
9012
  var avaKey = avaKeys.find(function (key) { return !!msg[key]; });
8808
- return (React$1.createElement(React$1.Fragment, null,
8809
- msg.text &&
8810
- React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "text", user: user, avatarPosition: chatConfig.env.theme.messages.avatarPosition },
8811
- React$1.createElement(ChatTextMessage, { message: props.message, sibling: props.sibling })),
8812
- msg.html &&
8813
- React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "html", user: user, avatarPosition: chatConfig.env.theme.messages.avatarPosition },
8814
- React$1.createElement(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_a = props.middlewareContext) === null || _a === void 0 ? void 0 : _a.openUrl })),
8815
- msg.displays && middleware && msg.displays.map(function (display, index) {
8816
- if (display.type === "ScheduleButton") {
8817
- return (React$1.createElement(ChatScheduleWidget, { minimizeOnClick: props.minimizeOnClick, display: display }));
8818
- }
8819
- var Middleware = middleware;
8820
- return (React$1.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext }));
8821
- }),
8822
- msg.permissionRequest && ctx &&
8823
- React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user, avatarPosition: chatConfig.env.theme.messages.avatarPosition },
8824
- React$1.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: ctx }))));
9013
+ return (jsxs(Fragment, { children: [msg.text &&
9014
+ jsx(ChatMessagePart, { showAvatar: avaKey === "text", user: user, avatarPosition: (_a = chatConfig.env.theme.messages) === null || _a === void 0 ? void 0 : _a.avatarPosition, hideUserInfo: hideUserInfo, children: jsx(ChatTextMessage, { message: props.message, sibling: props.sibling }) }), msg.html &&
9015
+ jsx(ChatMessagePart, { showAvatar: avaKey === "html", user: user, avatarPosition: (_b = chatConfig.env.theme.messages) === null || _b === void 0 ? void 0 : _b.avatarPosition, hideUserInfo: hideUserInfo, children: jsx(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_c = props.middlewareContext) === null || _c === void 0 ? void 0 : _c.openUrl }) }), msg.displays && middleware && msg.displays.map(function (display, index) {
9016
+ if (display.type === "ScheduleButton") {
9017
+ return (jsx(ChatScheduleWidget, { minimizeOnClick: props.minimizeOnClick, display: display }));
9018
+ }
9019
+ var Middleware = middleware;
9020
+ return (jsx(Middleware, { msg: display, ctx: props.middlewareContext }, index));
9021
+ }), msg.permissionRequest && ctx &&
9022
+ jsx(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user, avatarPosition: (_d = chatConfig.env.theme.messages) === null || _d === void 0 ? void 0 : _d.avatarPosition, hideUserInfo: hideUserInfo, children: jsx(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: ctx }) })] }));
8825
9023
  }
8826
- return (React$1.createElement(React$1.Fragment, null));
9024
+ return (jsx(Fragment, {}));
8827
9025
  }
8828
9026
  function renderTimestamp() {
8829
9027
  var timestamp = props.message.timestamp;
8830
9028
  var ts = new Date(timestamp);
8831
9029
  var timeAgo = getTimeAgo(ts);
8832
- return (React$1.createElement("div", { className: "chat-msg-timestamp ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor") },
8833
- React$1.createElement("span", null, timeAgo)));
9030
+ return (jsx("div", { className: "chat-msg-timestamp ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor"), children: jsx("span", { children: timeAgo }) }));
8834
9031
  }
8835
9032
  // empty
8836
- return (React$1.createElement("div", { className: "chat-msg-container-wrapper ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor", " ").concat(props.sibling ? "sibling" : "") },
8837
- React$1.createElement("div", { className: "chat-msg-container ".concat(getClassName(props.message)) },
8838
- renderByType(),
8839
- renderTimestamp())));
9033
+ return (jsx("div", { className: "chat-msg-container-wrapper ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor", " ").concat(props.sibling ? "sibling" : ""), children: jsxs("div", { className: "chat-msg-container ".concat(getClassName(props.message)), children: [renderByType(), renderTimestamp()] }) }));
8840
9034
  };
8841
9035
 
8842
9036
  /**
@@ -9071,18 +9265,12 @@ var AdminBar = function (_a) {
9071
9265
  }
9072
9266
  }
9073
9267
  function renderJoin() {
9074
- return (React$1.createElement("form", { className: "xappw-admin-input-form", onSubmit: onSubmit },
9075
- React$1.createElement("div", { className: "xappw-admin-input-form__buttons" },
9076
- React$1.createElement(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Join", disable: disable })),
9077
- React$1.createElement("div", { className: "xappw-admin-input" },
9078
- React$1.createElement("input", { ref: name, id: "adminBarInput", placeholder: "Type your name here...", className: "xappw-admin-input__input", onChange: handleInputChange }))));
9268
+ return (jsxs("form", { className: "xappw-admin-input-form", onSubmit: onSubmit, children: [jsx("div", { className: "xappw-admin-input-form__buttons", children: jsx(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Join", disable: disable }) }), jsx("div", { className: "xappw-admin-input", children: jsx("input", { ref: name, id: "adminBarInput", placeholder: "Type your name here...", className: "xappw-admin-input__input", onChange: handleInputChange }) })] }));
9079
9269
  }
9080
9270
  function renderLeave() {
9081
- return (React$1.createElement("form", { className: "xappw-admin-input-form", onSubmit: onSubmit },
9082
- React$1.createElement("div", { className: "xappw-admin-input-form__buttons" },
9083
- React$1.createElement(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Leave" }))));
9271
+ return (jsx("form", { className: "xappw-admin-input-form", onSubmit: onSubmit, children: jsx("div", { className: "xappw-admin-input-form__buttons", children: jsx(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Leave" }) }) }));
9084
9272
  }
9085
- return (React$1.createElement("div", { className: "xappw-admin-input-container visible" }, joined ? renderLeave() : renderJoin()));
9273
+ return (jsx("div", { className: "xappw-admin-input-container visible", children: joined ? renderLeave() : renderJoin() }));
9086
9274
  };
9087
9275
 
9088
9276
  var classnames = {exports: {}};
@@ -9181,39 +9369,32 @@ var MarkdownBuilder = function (_a) {
9181
9369
  var level = hashes.length;
9182
9370
  return "<h".concat(level, ">").concat(headerText, "</h").concat(level, ">");
9183
9371
  });
9184
- return (React$1.createElement("div", { className: containerClass, dangerouslySetInnerHTML: { __html: parsedText } }));
9372
+ return (jsx("div", { className: containerClass, dangerouslySetInnerHTML: { __html: parsedText } }));
9185
9373
  };
9186
9374
 
9187
9375
  var ChatBranding = function (_a) {
9188
9376
  var text = _a.text;
9189
9377
  var regex = /\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/;
9190
9378
  var match = text === null || text === void 0 ? void 0 : text.match(regex);
9191
- return match ? React$1.createElement(MarkdownBuilder, { text: text, applyBrandingClass: true, linkColor: "white" })
9192
- :
9193
- React$1.createElement("div", { className: "chat-footer__branding", style: { color: "white" } }, text);
9379
+ return match ? (jsx(MarkdownBuilder, { text: text, applyBrandingClass: true, linkColor: "white" })) : (jsx("div", { className: "chat-footer__branding", style: { color: "white" }, children: text }));
9194
9380
  };
9195
9381
 
9196
9382
  var CloseIcon = function () {
9197
9383
  // Sergey, I added this style, you will probably want to change it to be more appropriate
9198
- return (React$1.createElement("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
9199
- React$1.createElement("path", { d: "M1.293 1.293a1 1 0 0 1 1.414 0L8 6.586l5.293-5.293a1 1 0 1 1 1.414 1.414L9.414 8l5.293 5.293a1 1 0 0 1-1.414 1.414L8 9.414l-5.293 5.293a1 1 0 0 1-1.414-1.414L6.586 8 1.293 2.707a1 1 0 0 1 0-1.414z" })));
9384
+ return (jsx("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16", children: jsx("path", { d: "M1.293 1.293a1 1 0 0 1 1.414 0L8 6.586l5.293-5.293a1 1 0 1 1 1.414 1.414L9.414 8l5.293 5.293a1 1 0 0 1-1.414 1.414L8 9.414l-5.293 5.293a1 1 0 0 1-1.414-1.414L6.586 8 1.293 2.707a1 1 0 0 1 0-1.414z" }) }));
9200
9385
  };
9201
9386
 
9202
9387
  var LeftDownArrowIcon = function () {
9203
- return (React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
9204
- React$1.createElement("path", { fillRule: "evenodd", d: "M2 13.5a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 0-1H3.707L13.854 2.854a.5.5 0 0 0-.708-.708L3 12.293V7.5a.5.5 0 0 0-1 0v6z" })));
9388
+ return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16", children: jsx("path", { fillRule: "evenodd", d: "M2 13.5a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 0-1H3.707L13.854 2.854a.5.5 0 0 0-.708-.708L3 12.293V7.5a.5.5 0 0 0-1 0v6z" }) }));
9205
9389
  };
9206
9390
 
9207
9391
  var SendIcon = function () {
9208
- return (React$1.createElement("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg" },
9209
- React$1.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
9210
- React$1.createElement("path", { d: "M12670 7345 c-63 -18 -272 -77 -465 -130 -192 -53 -478 -132 -635 -175 -508 -141 -1091 -302 -2345 -649 -676 -187 -2038 -563 -3025 -836 -987 -273 -2072 -573 -2410 -666 -338 -94 -802 -222 -1030 -285 -1857 -514 -2579 -714 -2684 -742 -38 -10 -65 -21 -60 -24 5 -3 67 -22 139 -41 72 -20 326 -90 565 -157 239 -67 611 -170 825 -230 215 -60 586 -163 825 -230 239 -67 491 -137 560 -156 l126 -34 974 439 c1397 629 4128 1858 6050 2724 910 410 1826 822 2035 917 209 94 387 173 395 176 35 10 -66 -39 -8200 -3928 -586 -280 -1068 -512 -1071 -516 -3 -4 33 -117 82 -252 76 -213 355 -996 765 -2147 65 -183 120 -330 122 -329 1 2 114 558 250 1236 l248 1233 3455 2064 c1900 1135 3670 2193 3933 2351 264 158 491 293 505 301 62 33 -5 -12 -271 -182 -1671 -1070 -7188 -4613 -7188 -4617 0 -7 3661 -2455 3669 -2454 4 1 3713 6853 3977 7347 8 15 11 27 7 26 -5 0 -60 -15 -123 -34z" }),
9211
- React$1.createElement("path", { d: "M5030 2232 c-15 -61 -479 -1861 -531 -2058 -21 -83 -39 -154 -39 -158 0 -3 369 330 820 740 452 411 817 750 813 754 -11 10 -1025 754 -1039 763 -8 4 -16 -10 -24 -41z" }))));
9392
+ return (jsx("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg", children: jsxs("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none", children: [jsx("path", { d: "M12670 7345 c-63 -18 -272 -77 -465 -130 -192 -53 -478 -132 -635 -175 -508 -141 -1091 -302 -2345 -649 -676 -187 -2038 -563 -3025 -836 -987 -273 -2072 -573 -2410 -666 -338 -94 -802 -222 -1030 -285 -1857 -514 -2579 -714 -2684 -742 -38 -10 -65 -21 -60 -24 5 -3 67 -22 139 -41 72 -20 326 -90 565 -157 239 -67 611 -170 825 -230 215 -60 586 -163 825 -230 239 -67 491 -137 560 -156 l126 -34 974 439 c1397 629 4128 1858 6050 2724 910 410 1826 822 2035 917 209 94 387 173 395 176 35 10 -66 -39 -8200 -3928 -586 -280 -1068 -512 -1071 -516 -3 -4 33 -117 82 -252 76 -213 355 -996 765 -2147 65 -183 120 -330 122 -329 1 2 114 558 250 1236 l248 1233 3455 2064 c1900 1135 3670 2193 3933 2351 264 158 491 293 505 301 62 33 -5 -12 -271 -182 -1671 -1070 -7188 -4613 -7188 -4617 0 -7 3661 -2455 3669 -2454 4 1 3713 6853 3977 7347 8 15 11 27 7 26 -5 0 -60 -15 -123 -34z" }), jsx("path", { d: "M5030 2232 c-15 -61 -479 -1861 -531 -2058 -21 -83 -39 -154 -39 -158 0 -3 369 330 820 740 452 411 817 750 813 754 -11 10 -1025 754 -1039 763 -8 4 -16 -10 -24 -41z" })] }) }));
9212
9393
  };
9213
9394
 
9214
9395
  var SendButton = function (props) {
9215
9396
  var _a = props.disabled, disabled = _a === void 0 ? false : _a;
9216
- var _b = React$1.useState(false), isHovered = _b[0], setIsHovered = _b[1];
9397
+ var _b = require$$1.useState(false), isHovered = _b[0], setIsHovered = _b[1];
9217
9398
  // Determine which icon to show based on state
9218
9399
  var getIconSrc = function () {
9219
9400
  if (disabled && props.sendButtonIconDisabled) {
@@ -9224,8 +9405,7 @@ var SendButton = function (props) {
9224
9405
  }
9225
9406
  return props.sendButtonIcon;
9226
9407
  };
9227
- return (React$1.createElement(React$1.Fragment, null, !props.sendButtonIcon ? (React$1.createElement(IconButton_1, { className: "xappw-send-button ".concat(props.className || "", " ").concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex, onClick: disabled ? undefined : props.onClick, icon: SendIcon })) : (React$1.createElement("button", { className: "xappw-custom-send-button ".concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: props.onClick, disabled: disabled, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } },
9228
- React$1.createElement("img", { src: getIconSrc(), alt: "Send button", draggable: false, className: "send-button-icon" })))));
9408
+ return (jsx(Fragment, { children: !props.sendButtonIcon ? (jsx(IconButton_1, { className: "xappw-send-button ".concat(props.className || "", " ").concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex, onClick: disabled ? undefined : props.onClick, icon: SendIcon })) : (jsx("button", { className: "xappw-custom-send-button ".concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: props.onClick, disabled: disabled, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, children: jsx("img", { src: getIconSrc(), alt: "Send button", draggable: false, className: "send-button-icon" }) })) }));
9229
9409
  };
9230
9410
 
9231
9411
  var Input = function (props) {
@@ -9276,17 +9456,12 @@ var Input = function (props) {
9276
9456
  }
9277
9457
  }
9278
9458
  }, [suggestion, onChange, onSuggestionCommand]);
9279
- return (React$1.createElement("div", { className: "xappw-input-container ".concat(props.addClass, " ").concat(dragover ? "drag-drop-zone" : ""), "aria-label": "To start typing click on rounded rectangle at the bottom of widget. To send your message click icon on right side of rounded rectangle at the bottom of widget" +
9459
+ return (jsx("div", { className: "xappw-input-container ".concat(props.addClass, " ").concat(dragover ? "drag-drop-zone" : ""), "aria-label": "To start typing click on rounded rectangle at the bottom of widget. To send your message click icon on right side of rounded rectangle at the bottom of widget" +
9280
9460
  value.text
9281
9461
  ? "To clear input field click on clear icon on the left of send button"
9282
- : "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave },
9283
- React$1.createElement("form", { className: "xappw-input-form", onSubmit: handleOnSubmit },
9284
- React$1.createElement(RichInput_1, { key: "input", id: "chatWidgetInput", className: "xappw-input", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "type your question here", tabIndex: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.tabIndex, onInput: onChange, onChange: onChange, onKeyDown: handleKeyDown,
9285
- // onFocus={onFocus}
9286
- value: value, spellCheck: true }),
9287
- React$1.createElement("div", { className: "xappw-input-form__buttons" },
9288
- value.text && (React$1.createElement(IconButton_1, { icon: CloseIcon, tabIndex: (_a = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.clearButton) === null || _a === void 0 ? void 0 : _a.tabIndex, className: "xappw-input-form__btn", onClick: handleClear })),
9289
- React$1.createElement(SendButton, { className: "xappw-input-form__btn", sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, tabIndex: (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.sendButton) === null || _b === void 0 ? void 0 : _b.tabIndex, disabled: !value.text, onClick: handleOnSubmit })))));
9462
+ : "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave, children: jsxs("form", { className: "xappw-input-form", onSubmit: handleOnSubmit, children: [jsx(RichInput_1, { id: "chatWidgetInput", className: "xappw-input", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "type your question here", tabIndex: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.tabIndex, onInput: onChange, onChange: onChange, onKeyDown: handleKeyDown,
9463
+ // onFocus={onFocus}
9464
+ value: value, spellCheck: true }, "input"), jsxs("div", { className: "xappw-input-form__buttons", children: [value.text && (jsx(IconButton_1, { icon: CloseIcon, tabIndex: (_a = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.clearButton) === null || _a === void 0 ? void 0 : _a.tabIndex, className: "xappw-input-form__btn", onClick: handleClear })), jsx(SendButton, { className: "xappw-input-form__btn", sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, tabIndex: (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.sendButton) === null || _b === void 0 ? void 0 : _b.tabIndex, disabled: !value.text, onClick: handleOnSubmit })] })] }) }));
9290
9465
  };
9291
9466
 
9292
9467
  function createActions(onItemUse) {
@@ -9298,9 +9473,9 @@ function createActions(onItemUse) {
9298
9473
  ev.stopPropagation();
9299
9474
  }, [data]);
9300
9475
  if (!canUse) {
9301
- return React$1.createElement(React$1.Fragment, null);
9476
+ return jsx(Fragment, {});
9302
9477
  }
9303
- return (React$1.createElement(IconButton_1, { className: "xappw-suggestions__use", onClick: handleUse, icon: LeftDownArrowIcon }));
9478
+ return (jsx(IconButton_1, { className: "xappw-suggestions__use", onClick: handleUse, icon: LeftDownArrowIcon }));
9304
9479
  };
9305
9480
  }
9306
9481
  var Suggestions = function (props) {
@@ -9335,16 +9510,14 @@ var Suggestions = function (props) {
9335
9510
  var lines = content.split('\n');
9336
9511
  return lines.map(function (line) {
9337
9512
  if (line) {
9338
- return React$1.createElement(MarkdownBuilder, { text: line });
9513
+ return jsx(MarkdownBuilder, { text: line });
9339
9514
  }
9340
- return React$1.createElement(React$1.Fragment, null);
9515
+ return jsx(Fragment, {});
9341
9516
  });
9342
9517
  };
9343
9518
  var containerClass = "xappw-suggestions ".concat(props.className || "", " ").concat(props.hasWsButton ? "xappw-suggestions--with-ws-button" : "").trim();
9344
- return (React$1.createElement("div", { className: containerClass },
9345
- (activeItem === null || activeItem === void 0 ? void 0 : activeItem.content) && React$1.createElement("div", { className: "xappw-suggestions__answer" }, transformContent(activeItem.content)),
9346
- fixedSuggestions && fixedSuggestions.length > 0 &&
9347
- React$1.createElement(SuggestionsList_1, { suggestions: fixedSuggestions, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem, onSpanClick: handleSpanClick })));
9519
+ return (jsxs("div", { className: containerClass, children: [(activeItem === null || activeItem === void 0 ? void 0 : activeItem.content) && jsx("div", { className: "xappw-suggestions__answer", children: transformContent(activeItem.content) }), fixedSuggestions && fixedSuggestions.length > 0 &&
9520
+ jsx(SuggestionsList_1, { suggestions: fixedSuggestions, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem, onSpanClick: handleSpanClick })] }));
9348
9521
  };
9349
9522
 
9350
9523
  var ChatFooter = function (props) {
@@ -9406,19 +9579,10 @@ var ChatFooter = function (props) {
9406
9579
  var handleAdminJoin = function (status) {
9407
9580
  setEnableInput(status);
9408
9581
  };
9409
- return (React$1.createElement("div", { className: "chat-footer background-footer", "aria-label": menuItems.length ? "to open menu click a button above the rounded rectangle at the bottom of widget" : "", "aria-hidden": false },
9410
- showMenu && menuItems.length ?
9411
- React$1.createElement(React$1.Fragment, null,
9412
- drawerOpen ? React$1.createElement(ChatMenu, { opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) : React$1.createElement(React$1.Fragment, null),
9413
- React$1.createElement("div", { className: "chat-footer__menu-icon" },
9414
- React$1.createElement(DrawerBars, { tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }))) : React$1.createElement(React$1.Fragment, null),
9415
- React$1.createElement(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, searchTerms: suggestionSearch, hasWsButton: hasWsButton, onItemClick: handleItemClick, onItemUse: handleItemUse }),
9416
- isAdmin && isChatting && visible && React$1.createElement(AdminBar, { onAdminJoin: handleAdminJoin }),
9417
- React$1.createElement("div", { style: { pointerEvents: enableInput ? "auto" : "none", opacity: enableInput ? 1 : 0.5 } },
9418
- React$1.createElement(Input, { addClass: "chat-footer__input " + (isChatting && visible ? "visible" : ""), suggestion: suggestions.item, value: input, placeholder: placeholder, sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, footerConfig: footerConfig, inputConfig: inputConfig, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
9419
- // onFocus={this.inputOnFocus}
9420
- onFileUpload: props.onFileUpload })),
9421
- brandingEnabled && brandingText && React$1.createElement(ChatBranding, { text: brandingText })));
9582
+ return (jsxs("div", { className: "chat-footer background-footer", "aria-label": menuItems.length ? "to open menu click a button above the rounded rectangle at the bottom of widget" : "", "aria-hidden": false, children: [showMenu && menuItems.length ?
9583
+ jsxs(Fragment, { children: [drawerOpen ? jsx(ChatMenu, { opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) : jsx(Fragment, {}), jsx("div", { className: "chat-footer__menu-icon", children: jsx(DrawerBars, { tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }) })] }) : jsx(Fragment, {}), jsx(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, searchTerms: suggestionSearch, hasWsButton: hasWsButton, onItemClick: handleItemClick, onItemUse: handleItemUse }), isAdmin && isChatting && visible && jsx(AdminBar, { onAdminJoin: handleAdminJoin }), jsx("div", { style: { pointerEvents: enableInput ? "auto" : "none", opacity: enableInput ? 1 : 0.5 }, children: jsx(Input, { addClass: "chat-footer__input " + (isChatting && visible ? "visible" : ""), suggestion: suggestions.item, value: input, placeholder: placeholder, sendButtonIcon: sendButtonIcon, sendButtonIconHover: sendButtonIconHover, sendButtonIconDisabled: sendButtonIconDisabled, footerConfig: footerConfig, inputConfig: inputConfig, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
9584
+ // onFocus={this.inputOnFocus}
9585
+ onFileUpload: props.onFileUpload }) }), brandingEnabled && brandingText && jsx(ChatBranding, { text: brandingText })] }));
9422
9586
  };
9423
9587
 
9424
9588
  var noop = function () { };
@@ -9451,27 +9615,16 @@ var MiddlewareContextFactory = /** @class */ (function () {
9451
9615
 
9452
9616
  var CardContainer = function (props) {
9453
9617
  function renderIcon() {
9454
- var isString = typeof (props.icon) === "string";
9455
- return (React$1.createElement("div", { className: "card-container__icon" }, !isString && props.icon));
9456
- }
9457
- return (React$1.createElement("div", { className: "card-container ".concat(props.addClass) },
9458
- renderIcon(),
9459
- React$1.createElement("div", { className: "card-container__content ".concat(props.contentAddClass) },
9460
- React$1.createElement("div", { className: "card-container__title" }, props.title),
9461
- props.children)));
9618
+ var isString = typeof props.icon === "string";
9619
+ return jsx("div", { className: "card-container__icon", children: !isString && props.icon });
9620
+ }
9621
+ return (jsxs("div", { className: "card-container ".concat(props.addClass), children: [renderIcon(), jsxs("div", { className: "card-container__content ".concat(props.contentAddClass), children: [jsx("div", { className: "card-container__title", children: props.title }), props.children] })] }));
9462
9622
  };
9463
9623
 
9464
- var defaultProps$2 = {
9465
- agent: {},
9466
- hasRating: false,
9467
- shouldDisplay: true,
9468
- onRate: function () {
9624
+ var ChatRating = function (_a) {
9625
+ var _b = _a.agent, agent = _b === void 0 ? {} : _b, _c = _a.hasRating, hasRating = _c === void 0 ? false : _c, _d = _a.shouldDisplay, shouldDisplay = _d === void 0 ? true : _d, _e = _a.onRate, onRate = _e === void 0 ? function () {
9469
9626
  // no-op
9470
- }
9471
- };
9472
- var ChatRating = function (props) {
9473
- if (props === void 0) { props = defaultProps$2; }
9474
- var onRate = props.onRate;
9627
+ } : _e;
9475
9628
  var rateBadButtonOnClick = useCallback(function () {
9476
9629
  onRate("bad");
9477
9630
  }, [onRate]);
@@ -9482,22 +9635,14 @@ var ChatRating = function (props) {
9482
9635
  onRate(undefined);
9483
9636
  }, [onRate]);
9484
9637
  // Do not think this prop should be here
9485
- if (!props.shouldDisplay) {
9638
+ if (!shouldDisplay) {
9486
9639
  return null;
9487
9640
  }
9488
- if (!props.hasRating) {
9489
- return (React$1.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
9490
- props.agent.displayName,
9491
- " has requested you to rate the chat service.",
9492
- React$1.createElement("div", { className: "buttons-container" },
9493
- React$1.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
9494
- React$1.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
9641
+ if (!hasRating) {
9642
+ return (jsxs(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card", children: [agent.displayName, " has requested you to rate the chat service.", jsxs("div", { className: "buttons-container", children: [jsx(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }), jsx(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick })] })] }));
9495
9643
  }
9496
9644
  else {
9497
- return (React$1.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
9498
- "You have rated the chat service.",
9499
- React$1.createElement("div", { className: "buttons-container" },
9500
- React$1.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
9645
+ return (jsxs(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card", children: ["You have rated the chat service.", jsx("div", { className: "buttons-container", children: jsx(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }) })] }));
9501
9646
  }
9502
9647
  };
9503
9648
 
@@ -9506,9 +9651,7 @@ var ChatRatingContainer = function (props) {
9506
9651
  var handleRate = useCallback(function (rating) {
9507
9652
  dispatch(sendChatRating(rating));
9508
9653
  }, [dispatch]);
9509
- return (React$1.createElement(React$1.Fragment, null,
9510
- React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
9511
- React$1.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate })));
9654
+ return (jsxs(Fragment, { children: [jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), jsx(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate })] }));
9512
9655
  };
9513
9656
 
9514
9657
  var dateFns = {};
@@ -31033,23 +31176,18 @@ var FailureMessage = function (props) {
31033
31176
  return compileSlotValues(text, slots);
31034
31177
  }, [text, slots]);
31035
31178
  if (countdown === 0) {
31036
- return React$1.createElement(React$1.Fragment, null);
31179
+ return jsx(Fragment, {});
31037
31180
  }
31038
- return (React$1.createElement(React$1.Fragment, null, agent_names.map(function (agent) {
31039
- var _a, _b;
31040
- return (React$1.createElement("div", { className: "chat-msg-container-wrapper", key: "failure-msg-".concat((_a = agent === null || agent === void 0 ? void 0 : agent.user) === null || _a === void 0 ? void 0 : _a.nick) },
31041
- React$1.createElement("div", { className: "chat-msg-container agent", key: (_b = agent === null || agent === void 0 ? void 0 : agent.user) === null || _b === void 0 ? void 0 : _b.nick },
31042
- React$1.createElement(ChatMessagePart, { user: agent === null || agent === void 0 ? void 0 : agent.user, showAvatar: true },
31043
- React$1.createElement("div", { className: "chat-msg" },
31044
- React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
31045
- React$1.createElement("span", { className: "message-sr-only" }, "at " + time + " the bot said"),
31046
- React$1.createElement("span", null, typeof failureMessage === "object" ? failureMessage.displayText : failureMessage)))))));
31047
- })));
31181
+ return (jsx(Fragment, { children: agent_names.map(function (agent) {
31182
+ var _a, _b;
31183
+ return (jsx("div", { className: "chat-msg-container-wrapper", children: jsx("div", { className: "chat-msg-container agent", children: jsx(ChatMessagePart, { user: agent === null || agent === void 0 ? void 0 : agent.user, showAvatar: true, children: jsx("div", { className: "chat-msg", children: jsxs(ChatMessageBubble, { owner: "others", hasTail: true, children: [jsx("span", { className: "message-sr-only", children: "at " + time + " the bot said" }), jsx("span", { children: typeof failureMessage === "object"
31184
+ ? failureMessage.displayText
31185
+ : failureMessage })] }) }) }) }, (_a = agent === null || agent === void 0 ? void 0 : agent.user) === null || _a === void 0 ? void 0 : _a.nick) }, "failure-msg-".concat((_b = agent === null || agent === void 0 ? void 0 : agent.user) === null || _b === void 0 ? void 0 : _b.nick)));
31186
+ }) }));
31048
31187
  };
31049
31188
 
31050
31189
  var MessageSvg = function (_) {
31051
- return (React$1.createElement("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12" },
31052
- React$1.createElement("path", { d: "M14.4 0H1.6C.72 0 .008.675.008 1.5L0 10.5c0 .825.72 1.5 1.6 1.5h12.8c.88 0 1.6-.675 1.6-1.5v-9c0-.825-.72-1.5-1.6-1.5zm0 3L8 6.75 1.6 3V1.5L8 5.25l6.4-3.75V3z", fill: "#424242", fillRule: "evenodd" })));
31190
+ return (jsx("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12", children: jsx("path", { d: "M14.4 0H1.6C.72 0 .008.675.008 1.5L0 10.5c0 .825.72 1.5 1.6 1.5h12.8c.88 0 1.6-.675 1.6-1.5v-9c0-.825-.72-1.5-1.6-1.5zm0 3L8 6.75 1.6 3V1.5L8 5.25l6.4-3.75V3z", fill: "#424242", fillRule: "evenodd" }) }));
31053
31191
  };
31054
31192
 
31055
31193
  var MessageForm = function (props) {
@@ -31077,7 +31215,7 @@ var MessageForm = function (props) {
31077
31215
  props.onSubmit({
31078
31216
  name: (_c = name.current) === null || _c === void 0 ? void 0 : _c.value,
31079
31217
  email: (_d = email.current) === null || _d === void 0 ? void 0 : _d.value,
31080
- message: (_e = message.current) === null || _e === void 0 ? void 0 : _e.value
31218
+ message: (_e = message.current) === null || _e === void 0 ? void 0 : _e.value,
31081
31219
  });
31082
31220
  setSent(true);
31083
31221
  }
@@ -31085,30 +31223,16 @@ var MessageForm = function (props) {
31085
31223
  setSent(false);
31086
31224
  }
31087
31225
  function renderSent() {
31088
- return (React$1.createElement("div", { key: "sent", className: "message-form--sent" },
31089
- "Your message has been sent. We will get back to you as soon as possible.",
31090
- React$1.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
31226
+ return (jsxs("div", { className: "message-form--sent", children: ["Your message has been sent. We will get back to you as soon as possible.", jsx(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })] }, "sent"));
31091
31227
  }
31092
31228
  function renderForm() {
31093
- return (React$1.createElement("form", { ref: form, key: "not-sent", className: "message-form", onSubmit: send },
31094
- React$1.createElement("div", { className: "content" },
31095
- React$1.createElement("div", { className: "section" },
31096
- React$1.createElement("label", { className: "label" }, "Name"),
31097
- React$1.createElement("input", { ref: name, maxLength: 255 })),
31098
- React$1.createElement("div", { className: "section" },
31099
- React$1.createElement("label", { className: "label" }, "Email"),
31100
- React$1.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
31101
- React$1.createElement("div", { className: "section" },
31102
- React$1.createElement("label", { className: "label" }, "Message"),
31103
- React$1.createElement("textarea", { required: true, ref: message }))),
31104
- React$1.createElement("div", { className: "button-container" },
31105
- React$1.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
31106
- }
31107
- return (React$1.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React$1.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
31229
+ return (jsxs("form", { ref: form, className: "message-form", onSubmit: send, children: [jsxs("div", { className: "content", children: [jsxs("div", { className: "section", children: [jsx("label", { className: "label", children: "Name" }), jsx("input", { ref: name, maxLength: 255 })] }), jsxs("div", { className: "section", children: [jsx("label", { className: "label", children: "Email" }), jsx("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })] }), jsxs("div", { className: "section", children: [jsx("label", { className: "label", children: "Message" }), jsx("textarea", { required: true, ref: message })] })] }), jsx("div", { className: "button-container", children: jsx(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }) })] }, "not-sent"));
31230
+ }
31231
+ return (jsx(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: jsx(MessageSvg, {}), children: sent ? renderSent() : renderForm() }));
31108
31232
  };
31109
31233
 
31110
31234
  var OfflineForm = function (props) {
31111
- return React$1.createElement(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
31235
+ return jsx(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
31112
31236
  };
31113
31237
 
31114
31238
  var OfflineFormContainer = function (props) {
@@ -31116,9 +31240,7 @@ var OfflineFormContainer = function (props) {
31116
31240
  var handleSubmit = useCallback(function (data) {
31117
31241
  dispatch(sendOfflineMsg(data));
31118
31242
  }, [dispatch]);
31119
- return (React$1.createElement(React$1.Fragment, null,
31120
- React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
31121
- React$1.createElement(OfflineForm, { onSubmit: handleSubmit })));
31243
+ return (jsxs(Fragment, { children: [jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), jsx(OfflineForm, { onSubmit: handleSubmit })] }));
31122
31244
  };
31123
31245
 
31124
31246
  var PrechatForm = function (props) {
@@ -31128,7 +31250,7 @@ var PrechatForm = function (props) {
31128
31250
  onSubmit(msg);
31129
31251
  setSent(true);
31130
31252
  }, [onSubmit]);
31131
- return (React$1.createElement(React$1.Fragment, null, !sent && React$1.createElement(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit })));
31253
+ return jsx(Fragment, { children: !sent && jsx(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit }) });
31132
31254
  };
31133
31255
 
31134
31256
  var PrechatFormContainer = function (props) {
@@ -31144,34 +31266,34 @@ var PrechatFormContainer = function (props) {
31144
31266
  }, sessionId));
31145
31267
  dispatch(executeAction(data.message));
31146
31268
  }, [dispatch, sessionId]);
31147
- return (React$1.createElement(React$1.Fragment, null,
31148
- React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
31149
- React$1.createElement(PrechatForm, { onSubmit: handleSubmit })));
31269
+ return (jsxs(Fragment, { children: [jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), jsx(PrechatForm, { onSubmit: handleSubmit })] }));
31150
31270
  };
31151
31271
 
31152
- var defaultProps$1 = {
31153
- position: 0
31154
- };
31155
- var QueuePosition = function (props) {
31156
- if (props === void 0) { props = defaultProps$1; }
31157
- if (props.position <= 0)
31272
+ var QueuePosition = function (_a) {
31273
+ var _b = _a.position, position = _b === void 0 ? 0 : _b;
31274
+ if (position <= 0)
31158
31275
  return null;
31159
- return (React$1.createElement("div", { className: "system-msg-container" },
31160
- React$1.createElement("span", { className: "system-msg" },
31161
- "Queue position: ",
31162
- props.position)));
31276
+ return (jsx("div", { className: "system-msg-container", children: jsxs("span", { className: "system-msg", children: ["Queue position: ", position] }) }));
31163
31277
  };
31164
31278
 
31165
31279
  function isServerUser(user) {
31166
31280
  var _a;
31167
31281
  return (_a = user.nick) === null || _a === void 0 ? void 0 : _a.endsWith(ROUTER_USER);
31168
31282
  }
31283
+ function shouldShowDivider(message) {
31284
+ return (message.type === "chat.memberjoin" && message.showDivider) ||
31285
+ (message.type === "chat.memberleave" && message.showDivider);
31286
+ }
31169
31287
  function getMessageByType(msg) {
31170
31288
  switch (msg.type) {
31171
31289
  case "chat.memberjoin":
31172
- return "".concat(msg.user.displayName || "Bot", " has joined the chat");
31290
+ // Use custom message if provided, otherwise use default
31291
+ return msg.message || "".concat(msg.user.displayName || "Bot", " has joined the chat");
31173
31292
  case "chat.memberleave":
31174
- return "".concat(msg.user.displayName || "Bot", " has left the chat");
31293
+ // Use custom message if provided, otherwise use default
31294
+ return msg.message || "".concat(msg.user.displayName || "Bot", " has left the chat");
31295
+ case "chat.systemmessage":
31296
+ return msg.message;
31175
31297
  case "chat.rating":
31176
31298
  if (!msg.newRating) {
31177
31299
  return "You have removed the chat rating";
@@ -31185,10 +31307,12 @@ function getMessageByType(msg) {
31185
31307
  }
31186
31308
  }
31187
31309
  var SystemMessage = function (props) {
31310
+ var _a;
31188
31311
  if (!isServerUser(props.message.user)) {
31189
- return (React$1.createElement("div", { className: "system-msg-container" },
31190
- React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
31191
- React$1.createElement("span", { className: "system-msg" }, getMessageByType(props.message))));
31312
+ var message = props.message;
31313
+ var showDivider = shouldShowDivider(message);
31314
+ var avatarUrl = (_a = message.user) === null || _a === void 0 ? void 0 : _a.avatarPath;
31315
+ return (jsxs("div", { className: "system-msg-container", children: [showDivider && avatarUrl && (jsxs("div", { className: "system-msg-divider", children: [jsx("div", { className: "divider-line" }), jsx("div", { className: "divider-avatar", children: jsx("img", { src: avatarUrl, alt: "".concat(message.user.displayName || "User", "'s avatar") }) }), jsx("div", { className: "divider-line" })] })), jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), jsx("span", { className: "system-msg", children: getMessageByType(props.message) })] }));
31192
31316
  }
31193
31317
  else {
31194
31318
  return null;
@@ -31199,10 +31323,7 @@ function convertToSentenceCase(s) {
31199
31323
  }
31200
31324
 
31201
31325
  var TypingIndicator = function (_) {
31202
- return (React$1.createElement("div", { className: "typing-indicator" },
31203
- React$1.createElement("div", { className: "typing-indicator-part" }),
31204
- React$1.createElement("div", { className: "typing-indicator-part" }),
31205
- React$1.createElement("div", { className: "typing-indicator-part" })));
31326
+ return (jsxs("div", { className: "typing-indicator", children: [jsx("div", { className: "typing-indicator-part" }), jsx("div", { className: "typing-indicator-part" }), jsx("div", { className: "typing-indicator-part" })] }));
31206
31327
  };
31207
31328
 
31208
31329
  /**
@@ -31210,42 +31331,19 @@ var TypingIndicator = function (_) {
31210
31331
  */
31211
31332
  var TypingStatus = function (props) {
31212
31333
  var agentsTyping = Object.values(props.agents).filter(function (agent) { return agent.typing; });
31213
- return (React$1.createElement(React$1.Fragment, null, agentsTyping.map(function (agent, index) {
31214
- var _a, _b;
31215
- var key = ((_a = agent.user) === null || _a === void 0 ? void 0 : _a.nick) || "".concat(index);
31216
- var displayName = ((_b = agent.user) === null || _b === void 0 ? void 0 : _b.displayName) || "Somebody";
31217
- return (React$1.createElement("span", { key: "typing-status-".concat(index) }, !props.textTypingStatusEnabled ? (React$1.createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-".concat(key) },
31218
- React$1.createElement("div", { key: key, className: "chat-msg-container agent chat-typing-progress" },
31219
- React$1.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
31220
- React$1.createElement("div", { className: "chat-msg" },
31221
- React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
31222
- React$1.createElement(TypingIndicator, null))))))) : (React$1.createElement("div", { key: "typing-status-".concat(key), className: "chat-msg-agent-typing" },
31223
- displayName,
31224
- " is typing"))));
31225
- })));
31334
+ return (jsx(Fragment, { children: agentsTyping.map(function (agent, index) {
31335
+ var _a, _b;
31336
+ var key = ((_a = agent.user) === null || _a === void 0 ? void 0 : _a.nick) || "".concat(index);
31337
+ var displayName = ((_b = agent.user) === null || _b === void 0 ? void 0 : _b.displayName) || "Somebody";
31338
+ return (jsx("span", { children: !props.textTypingStatusEnabled ? (jsx("div", { className: "chat-msg-container-wrapper", children: jsx("div", { className: "chat-msg-container agent chat-typing-progress", children: jsx(ChatMessagePart, { user: agent.user, showAvatar: true, children: jsx("div", { className: "chat-msg", children: jsx(ChatMessageBubble, { owner: "others", hasTail: true, children: jsx(TypingIndicator, {}) }) }) }) }, key) }, "typing-status-".concat(key))) : (jsxs("div", { className: "chat-msg-agent-typing", children: [displayName, " is typing"] }, "typing-status-".concat(key))) }, "typing-status-".concat(index)));
31339
+ }) }));
31226
31340
  };
31227
31341
 
31228
- var defaultProps = {
31229
- visible: true,
31230
- messages: [],
31231
- agents: {},
31232
- isOffline: true,
31233
- isChatting: false,
31234
- queuePosition: 0,
31235
- lastRatingRequestTimestamp: 0,
31236
- hasRating: false,
31237
- visitorId: "",
31238
- onSend: function () { return Promise.resolve(); },
31239
- onWrite: function () { return Promise.resolve(); },
31240
- onOpenUrl: function () { },
31241
- minimizeOnClick: function () { },
31242
- };
31243
- var MessageList = function (props) {
31244
- if (props === void 0) { props = defaultProps; }
31245
- var onSend = props.onSend, onWrite = props.onWrite, onOpenUrl = props.onOpenUrl, minimizeOnClick = props.minimizeOnClick;
31342
+ var MessageList = function (_a) {
31343
+ _a.visible; var _c = _a.messages, messages = _c === void 0 ? [] : _c, _d = _a.agents, agents = _d === void 0 ? {} : _d; _a.isOffline; _a.isChatting; var _g = _a.queuePosition, queuePosition = _g === void 0 ? 0 : _g, _h = _a.lastRatingRequestTimestamp, lastRatingRequestTimestamp = _h === void 0 ? 0 : _h, _j = _a.hasRating, hasRating = _j === void 0 ? false : _j; _a.visitorId; var messageMiddleware = _a.messageMiddleware, textTypingStatusEnabled = _a.textTypingStatusEnabled, agent = _a.agent, hasWsButton = _a.hasWsButton, _l = _a.onSend, onSend = _l === void 0 ? function () { return Promise.resolve(); } : _l, _m = _a.onWrite, onWrite = _m === void 0 ? function () { return Promise.resolve(); } : _m, _o = _a.onOpenUrl, onOpenUrl = _o === void 0 ? function () { } : _o, _p = _a.minimizeOnClick, minimizeOnClick = _p === void 0 ? function () { } : _p; _a.children;
31246
31344
  var messagesEndRef = useRef(null);
31247
31345
  var containerRef = useRef(null);
31248
- var prevHasWsButtonRef = useRef(props.hasWsButton);
31346
+ var prevHasWsButtonRef = useRef(hasWsButton);
31249
31347
  // Check if user is scrolled to bottom
31250
31348
  var isAtBottom = useCallback(function () {
31251
31349
  if (!containerRef.current)
@@ -31263,11 +31361,11 @@ var MessageList = function (props) {
31263
31361
  // Always scroll to bottom when messages change
31264
31362
  useEffect(function () {
31265
31363
  scrollToBottom("smooth");
31266
- }, [props.messages, props.agents, scrollToBottom]);
31364
+ }, [messages, agents, scrollToBottom]);
31267
31365
  // Handle WS button dismissal - only scroll when button is removed
31268
31366
  useEffect(function () {
31269
31367
  var prevHasButton = prevHasWsButtonRef.current;
31270
- var currentHasButton = props.hasWsButton;
31368
+ var currentHasButton = hasWsButton;
31271
31369
  // Update ref for next render
31272
31370
  prevHasWsButtonRef.current = currentHasButton;
31273
31371
  // Only handle button dismissal (was true, now false)
@@ -31282,7 +31380,7 @@ var MessageList = function (props) {
31282
31380
  }
31283
31381
  }
31284
31382
  return undefined;
31285
- }, [props.hasWsButton, isAtBottom, scrollToBottom]);
31383
+ }, [hasWsButton, isAtBottom, scrollToBottom]);
31286
31384
  var handleSend = useCallback(function (msg) {
31287
31385
  onSend(msg);
31288
31386
  messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
@@ -31314,7 +31412,7 @@ var MessageList = function (props) {
31314
31412
  user = msg.user;
31315
31413
  }
31316
31414
  else {
31317
- user = ((_c = props.agents[msg.user.nick]) === null || _c === void 0 ? void 0 : _c.user) || props.agent;
31415
+ user = ((_c = agents[msg.user.nick]) === null || _c === void 0 ? void 0 : _c.user) || agent;
31318
31416
  // Still nothing?
31319
31417
  if (!user) {
31320
31418
  log("Could not get a user from agents list with nick: \"".concat(msg.user.nick, "\""));
@@ -31324,26 +31422,23 @@ var MessageList = function (props) {
31324
31422
  switch (msg.type) {
31325
31423
  case "chat.file":
31326
31424
  case "chat.msg":
31327
- return (React$1.createElement(ChatMessage, { key: "cm-".concat(msg.type, "-").concat(msg.timestamp), message: msg, sibling: sibling, agent: user, messageMiddleware: props.messageMiddleware, middlewareContext: ctxCache.resolve(user), minimizeOnClick: minimizeOnClick }));
31425
+ return (jsx(ChatMessage, { message: msg, sibling: sibling, agent: user, messageMiddleware: messageMiddleware, middlewareContext: ctxCache.resolve(user), minimizeOnClick: minimizeOnClick }, "cm-".concat(msg.type, "-").concat(msg.timestamp)));
31328
31426
  case "chat.failureMsg":
31329
- return (React$1.createElement(FailureMessage, __assign({ key: "fm-".concat(msg.type, "-").concat(msg.timestamp), agents: props.agents, time: time }, msg.failureMsg)));
31427
+ return (jsx(FailureMessage, __assign({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
31330
31428
  case "chat.memberjoin":
31331
31429
  case "chat.memberleave":
31430
+ case "chat.systemmessage":
31332
31431
  case "chat.rating":
31333
31432
  case "chat.typing":
31334
- return (React$1.createElement(SystemMessage, { key: "sm-".concat(msg.type, "-").concat(msg.timestamp), time: time, message: msg }));
31433
+ return (jsx(SystemMessage, { time: time, message: msg }, "sm-".concat(msg.type, "-").concat(msg.timestamp)));
31335
31434
  case "chat.request.rating":
31336
- return (React$1.createElement(ChatRatingContainer, { key: "cr-".concat(msg.type, "-").concat(msg.timestamp), agent: user, hasRating: props.hasRating, time: time, shouldDisplay: msg.timestamp === props.lastRatingRequestTimestamp }));
31435
+ return (jsx(ChatRatingContainer, { agent: user, hasRating: hasRating, time: time, shouldDisplay: msg.timestamp === lastRatingRequestTimestamp }, "cr-".concat(msg.type, "-").concat(msg.timestamp)));
31337
31436
  case "chat.offline":
31338
- return React$1.createElement(OfflineFormContainer, { key: "offline-".concat(msg.timestamp), time: time });
31437
+ return jsx(OfflineFormContainer, { time: time }, "offline-".concat(msg.timestamp));
31339
31438
  case "chat.prechat":
31340
- return React$1.createElement(PrechatFormContainer, { key: "prechat", time: time });
31439
+ return jsx(PrechatFormContainer, { time: time }, "prechat");
31341
31440
  default:
31342
- return (React$1.createElement("span", { key: "default-".concat(msg.timestamp) },
31343
- React$1.createElement("span", { className: "message-sr-only" }, "at " + time + " system message"),
31344
- React$1.createElement("div", { key: "uhm-".concat(+new Date()) },
31345
- "Unhandled message: ",
31346
- JSON.stringify(msg))));
31441
+ return (jsxs("span", { children: [jsx("span", { className: "message-sr-only", children: "at " + time + " system message" }), jsxs("div", { children: ["Unhandled message: ", JSON.stringify(msg)] }, "uhm-".concat(+new Date()))] }, "default-".concat(msg.timestamp)));
31347
31442
  }
31348
31443
  }
31349
31444
  /**
@@ -31352,14 +31447,14 @@ var MessageList = function (props) {
31352
31447
  */
31353
31448
  function renderAll() {
31354
31449
  var lastMsgIndex = -1;
31355
- for (var i = props.messages.length - 1; i > 0; i--) {
31356
- if (props.messages[i].type === "chat.msg") {
31450
+ for (var i = messages.length - 1; i > 0; i--) {
31451
+ if (messages[i].type === "chat.msg") {
31357
31452
  lastMsgIndex = i;
31358
31453
  break;
31359
31454
  }
31360
31455
  }
31361
- return props.messages.map(function (message, index) {
31362
- // const next = props.messages[index + 1];
31456
+ return messages.map(function (message, index) {
31457
+ // const next = messages[index + 1];
31363
31458
  var _a, _b;
31364
31459
  // let sibling = false;
31365
31460
  // const currentNick = message.nick;
@@ -31375,6 +31470,7 @@ var MessageList = function (props) {
31375
31470
  // "chat.failureMsg",
31376
31471
  "chat.memberjoin",
31377
31472
  "chat.memberleave",
31473
+ // "chat.systemmessage", // System messages don't show timestamps
31378
31474
  "chat.rating",
31379
31475
  // "chat.typing",
31380
31476
  "chat.request.rating",
@@ -31384,11 +31480,11 @@ var MessageList = function (props) {
31384
31480
  // show first and las TS and after at least 5 minutes gap. Don't show "router user"
31385
31481
  var showTs = false;
31386
31482
  if (tsTypes.includes(message.type) && !((_b = (_a = message.user) === null || _a === void 0 ? void 0 : _a.nick) === null || _b === void 0 ? void 0 : _b.endsWith(ROUTER_USER))) {
31387
- if (index === 0 || index === props.messages.length - 1 || index === lastMsgIndex) {
31483
+ if (index === 0 || index === messages.length - 1 || index === lastMsgIndex) {
31388
31484
  showTs = true;
31389
31485
  }
31390
31486
  else {
31391
- var previous = props.messages[index - 1];
31487
+ var previous = messages[index - 1];
31392
31488
  if (message.timestamp && previous.timestamp) {
31393
31489
  showTs = message.timestamp - previous.timestamp > 300 * 1000; // 5 minutes
31394
31490
  }
@@ -31399,26 +31495,14 @@ var MessageList = function (props) {
31399
31495
  showTs = false;
31400
31496
  }
31401
31497
  var ts = showTs ? new Date(message.timestamp).toLocaleString() : undefined;
31402
- return (React$1.createElement("span", { key: "message-list-render-all-".concat(index) },
31403
- showTs && (React$1.createElement("div", { className: "ts-msg-container" },
31404
- React$1.createElement("span", { className: "ts-msg" }, ts))),
31405
- renderByType(message, false)));
31498
+ return (jsxs("span", { children: [showTs && (jsx("div", { className: "ts-msg-container", children: jsx("span", { className: "ts-msg", children: ts }) })), renderByType(message, false)] }, "message-list-render-all-".concat(index)));
31406
31499
  });
31407
31500
  }
31408
- var agents = props.agents, queuePosition = props.queuePosition;
31409
- return (React$1.createElement("div", { className: "message-list-container", ref: containerRef },
31410
- React$1.createElement("div", { className: "message-list-container__msgs" },
31411
- renderAll(),
31412
- React$1.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
31413
- React$1.createElement(QueuePosition, { position: queuePosition }),
31414
- React$1.createElement(TypingStatus, { agents: agents, textTypingStatusEnabled: props.textTypingStatusEnabled })),
31415
- React$1.createElement(ChatChipsContainer, null)));
31501
+ return (jsxs("div", { className: "message-list-container", ref: containerRef, children: [jsxs("div", { className: "message-list-container__msgs", children: [renderAll(), jsx("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }), jsx(QueuePosition, { position: queuePosition }), jsx(TypingStatus, { agents: agents, textTypingStatusEnabled: textTypingStatusEnabled })] }), jsx(ChatChipsContainer, {})] }));
31416
31502
  };
31417
31503
 
31418
31504
  var ServerOffline = function () {
31419
- return React$1.createElement("div", { className: "server-offline" },
31420
- React$1.createElement("h2", null, "Chat is currently unavailable"),
31421
- React$1.createElement("h3", null, "Server is offline"));
31505
+ return (jsxs("div", { className: "server-offline", children: [jsx("h2", { children: "Chat is currently unavailable" }), jsx("h3", { children: "Server is offline" })] }));
31422
31506
  };
31423
31507
 
31424
31508
  function buildStyleContent(theme) {
@@ -31428,7 +31512,7 @@ function buildStyleContent(theme) {
31428
31512
  function WidgetStylesheet(props) {
31429
31513
  var theme = props.theme;
31430
31514
  var stylesContent = buildStyleContent(theme);
31431
- return React$1.createElement("style", null, stylesContent);
31515
+ return jsx("style", { children: stylesContent });
31432
31516
  }
31433
31517
  function buildVariables(gen) {
31434
31518
  var result = gen.next();
@@ -31975,31 +32059,7 @@ var ErrorOverlay = function (_a) {
31975
32059
  if (errors.length === 0) {
31976
32060
  return null;
31977
32061
  }
31978
- return (React$1.createElement("div", { className: "error-overlay error-overlay--".concat(position, " ").concat(isMinimized ? "minimized" : "") },
31979
- React$1.createElement("div", { className: "error-overlay-header" },
31980
- React$1.createElement("span", { className: "error-overlay-title" },
31981
- "Debug Console (",
31982
- errors.length,
31983
- ")"),
31984
- React$1.createElement("div", { className: "error-overlay-actions" },
31985
- React$1.createElement("button", { onClick: copyToClipboard, title: "Copy all to clipboard" }, "\uD83D\uDCCB"),
31986
- React$1.createElement("button", { onClick: clearErrors, title: "Clear all" }, "\uD83D\uDDD1\uFE0F"),
31987
- React$1.createElement("button", { onClick: togglePosition, title: "Move to ".concat(position === "bottom" ? "top" : "bottom") }, position === "bottom" ? "⬆️" : "⬇️"),
31988
- React$1.createElement("button", { onClick: toggleEnabled, title: "Disable Error Overlay" }, "\uD83D\uDD27"),
31989
- React$1.createElement("button", { onClick: function () { return setIsMinimized(!isMinimized); }, title: "Minimize/Maximize" }, isMinimized ? "▲" : "▼"),
31990
- React$1.createElement("button", { onClick: function () { return setIsVisible(false); }, title: "Close" }, "\u2715"))),
31991
- !isMinimized && (React$1.createElement("div", { className: "error-overlay-content" }, errors.map(function (error) { return (React$1.createElement("div", { key: error.id, className: "error-entry error-".concat(error.type) },
31992
- React$1.createElement("div", { className: "error-header" },
31993
- React$1.createElement("span", { className: "error-time" }, new Date(error.timestamp).toLocaleTimeString()),
31994
- error.count > 1 && (React$1.createElement("span", { className: "error-count" },
31995
- "(",
31996
- error.count,
31997
- "x)")),
31998
- React$1.createElement("span", { className: "error-badge error-badge-".concat(error.type) }, error.type)),
31999
- React$1.createElement("div", { className: "error-message" }, error.message),
32000
- error.stack && (React$1.createElement("details", { className: "error-stack" },
32001
- React$1.createElement("summary", null, "Stack trace"),
32002
- React$1.createElement("pre", null, error.stack))))); })))));
32062
+ return (jsxs("div", { className: "error-overlay error-overlay--".concat(position, " ").concat(isMinimized ? "minimized" : ""), children: [jsxs("div", { className: "error-overlay-header", children: [jsxs("span", { className: "error-overlay-title", children: ["Debug Console (", errors.length, ")"] }), jsxs("div", { className: "error-overlay-actions", children: [jsx("button", { onClick: copyToClipboard, title: "Copy all to clipboard", children: "\uD83D\uDCCB" }), jsx("button", { onClick: clearErrors, title: "Clear all", children: "\uD83D\uDDD1\uFE0F" }), jsx("button", { onClick: togglePosition, title: "Move to ".concat(position === "bottom" ? "top" : "bottom"), children: position === "bottom" ? "⬆️" : "⬇️" }), jsx("button", { onClick: toggleEnabled, title: "Disable Error Overlay", children: "\uD83D\uDD27" }), jsx("button", { onClick: function () { return setIsMinimized(!isMinimized); }, title: "Minimize/Maximize", children: isMinimized ? "▲" : "▼" }), jsx("button", { onClick: function () { return setIsVisible(false); }, title: "Close", children: "\u2715" })] })] }), !isMinimized && (jsx("div", { className: "error-overlay-content", children: errors.map(function (error) { return (jsxs("div", { className: "error-entry error-".concat(error.type), children: [jsxs("div", { className: "error-header", children: [jsx("span", { className: "error-time", children: new Date(error.timestamp).toLocaleTimeString() }), error.count > 1 && (jsxs("span", { className: "error-count", children: ["(", error.count, "x)"] })), jsx("span", { className: "error-badge error-badge-".concat(error.type), children: error.type })] }), jsx("div", { className: "error-message", children: error.message }), error.stack && (jsxs("details", { className: "error-stack", children: [jsx("summary", { children: "Stack trace" }), jsx("pre", { children: error.stack })] }))] }, error.id)); }) }))] }));
32003
32063
  };
32004
32064
 
32005
32065
  var WsButton = function (_a) {
@@ -32026,23 +32086,19 @@ var WsButton = function (_a) {
32026
32086
  }
32027
32087
  return classes.join(" ");
32028
32088
  }, [button.isDismissing]);
32029
- return (React$1.createElement("div", { className: containerClassName },
32030
- React$1.createElement("button", { className: className, onClick: handleClick, disabled: button.pressBehavior === "disabled" || button.isPressed, "aria-label": button.text, "aria-busy": button.isPressed && button.pressBehavior === "spinning" },
32031
- button.isPressed && button.pressBehavior === "spinning" && (React$1.createElement("span", { className: "ws-button__spinner" })),
32032
- React$1.createElement("span", { className: "ws-button__text" }, button.text))));
32089
+ return (jsx("div", { className: containerClassName, children: jsxs("button", { className: className, onClick: handleClick, disabled: button.pressBehavior === "disabled" || button.isPressed, "aria-label": button.text, "aria-busy": button.isPressed && button.pressBehavior === "spinning", children: [button.isPressed && button.pressBehavior === "spinning" && (jsx("span", { className: "ws-button__spinner" })), jsx("span", { className: "ws-button__text", children: button.text })] }) }));
32033
32090
  };
32034
32091
 
32035
32092
  var ModalContent = function (_a) {
32036
32093
  var onClose = _a.onClose, onReset = _a.onReset;
32037
- return (React$1.createElement("div", { className: "modalContent" },
32038
- React$1.createElement("div", { className: "modalBody" },
32039
- React$1.createElement("h2", null, "Restart Conversation"),
32040
- React$1.createElement("p", null, "Would you like to refresh and return to the starting point of the conversation?")),
32041
- React$1.createElement("div", { className: "modalActions" },
32042
- React$1.createElement("button", { onClick: onClose, className: "cancelBtn" }, "Cancel"),
32043
- React$1.createElement("button", { onClick: onReset, className: "restartBtn" }, "Restart"))));
32094
+ return (jsxs("div", { className: "modalContent", children: [jsxs("div", { className: "modalBody", children: [jsx("h2", { children: "Restart Conversation" }), jsx("p", { children: "Would you like to refresh and return to the starting point of the conversation?" })] }), jsxs("div", { className: "modalActions", children: [jsx("button", { onClick: onClose, className: "cancelBtn", children: "Cancel" }), jsx("button", { onClick: onReset, className: "restartBtn", children: "Restart" })] })] }));
32044
32095
  };
32045
32096
 
32097
+ /**
32098
+ * Debounce delay for typing indicator in milliseconds.
32099
+ * After this delay of inactivity, the "stop typing" event will be sent.
32100
+ */
32101
+ var TYPING_INDICATOR_DEBOUNCE_MS = 2000;
32046
32102
  var ChatWidgetWrapper = function (props) {
32047
32103
  var _a;
32048
32104
  var _b = useState(props.config), rawConfig = _b[0], setRawConfig = _b[1];
@@ -32113,20 +32169,13 @@ var ChatWidgetWrapper = function (props) {
32113
32169
  var modeClass = "widget-container--".concat(mode);
32114
32170
  // Show loading state while config is being fetched
32115
32171
  if (configLoading) {
32116
- return (React$1.createElement("div", { className: "widget-container widget-container--loading ".concat(modeClass) },
32117
- React$1.createElement("div", { className: "xa-spinner-container visible" },
32118
- React$1.createElement("div", { className: "xa-spinner" }))));
32172
+ return (jsx("div", { className: "widget-container widget-container--loading ".concat(modeClass), children: jsx("div", { className: "xa-spinner-container visible", children: jsx("div", { className: "xa-spinner" }) }) }));
32119
32173
  }
32120
32174
  // Show error state if config failed to load
32121
32175
  if (configError) {
32122
- return (React$1.createElement("div", { className: "widget-container widget-container--error ".concat(modeClass) },
32123
- React$1.createElement("div", { className: "widget-error-message" },
32124
- "Failed to load chat configuration: ",
32125
- configError.message)));
32126
- }
32127
- return (React$1.createElement(ChatConfigContext.Provider, { value: config },
32128
- React$1.createElement(ChatServerContext.Provider, { value: chatServer },
32129
- React$1.createElement(ChatWidget, __assign({}, props, { config: rawConfig })))));
32176
+ return (jsx("div", { className: "widget-container widget-container--error ".concat(modeClass), children: jsxs("div", { className: "widget-error-message", children: ["Failed to load chat configuration: ", configError.message] }) }));
32177
+ }
32178
+ return (jsx(ChatConfigContext.Provider, { value: config, children: jsx(ChatServerContext.Provider, { value: chatServer, children: jsx(ChatWidget, __assign({}, props, { config: rawConfig })) }) }));
32130
32179
  };
32131
32180
  var ChatWidget = function (props) {
32132
32181
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
@@ -32162,7 +32211,11 @@ var ChatWidget = function (props) {
32162
32211
  chatState.visuals.visible ||
32163
32212
  (((_m = props.config) === null || _m === void 0 ? void 0 : _m.autoOpenOnWidth) &&
32164
32213
  window.matchMedia("(min-width: ".concat((_o = props.config) === null || _o === void 0 ? void 0 : _o.autoOpenOnWidth, ")")).matches)), visible = _8[0], setVisibleState = _8[1];
32165
- var _9 = useState(false), typing = _9[0], setTypingState = _9[1]; // false initially
32214
+ var _9 = useState(false); _9[0]; var setTypingState = _9[1]; // false initially - state kept for potential external observers
32215
+ // Ref to track typing state for use in timeout callbacks
32216
+ var typingRef = useRef(false);
32217
+ // Timeout ref for debouncing "stop typing" events
32218
+ var stopTypingTimeoutRef = useRef(null);
32166
32219
  var chatServer = useContext(ChatServerContext);
32167
32220
  var patternsConfig = (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.autoOpenOnPattern) === null || _q === void 0 ? void 0 : _q.patterns;
32168
32221
  var currentUrl = window.location.href;
@@ -32197,6 +32250,10 @@ var ChatWidget = function (props) {
32197
32250
  }
32198
32251
  return function () {
32199
32252
  document.removeEventListener("keydown", handleKeyDown);
32253
+ // Cleanup typing timeout on unmount
32254
+ if (stopTypingTimeoutRef.current) {
32255
+ clearTimeout(stopTypingTimeoutRef.current);
32256
+ }
32200
32257
  };
32201
32258
  // eslint-disable-next-line react-hooks/exhaustive-deps
32202
32259
  }, []);
@@ -32225,6 +32282,22 @@ var ChatWidget = function (props) {
32225
32282
  chatServer.wakeup();
32226
32283
  }
32227
32284
  }, [chatServer, innerDispatch, isTabVisible]);
32285
+ // Handle beforeunload to notify router when user is leaving
32286
+ useEffect(function () {
32287
+ if (!chatServer) {
32288
+ return undefined;
32289
+ }
32290
+ var handleBeforeUnload = function () {
32291
+ log("beforeunload - notifying router of user disconnecting");
32292
+ if (chatServer.notifyDisconnecting) {
32293
+ chatServer.notifyDisconnecting();
32294
+ }
32295
+ };
32296
+ window.addEventListener("beforeunload", handleBeforeUnload);
32297
+ return function () {
32298
+ window.removeEventListener("beforeunload", handleBeforeUnload);
32299
+ };
32300
+ }, [chatServer]);
32228
32301
  useEffect(function () {
32229
32302
  // For reopen widget after move on same window
32230
32303
  // if (get("opened")) {
@@ -32253,19 +32326,34 @@ var ChatWidget = function (props) {
32253
32326
  chatState.visuals.opened,
32254
32327
  mode,
32255
32328
  ]);
32256
- function handleOnChange() {
32257
- if (!typing) {
32258
- dispatch(sendTyping(true));
32259
- setTypingState(true);
32260
- }
32261
- stopTyping();
32262
- }
32263
- function stopTyping() {
32264
- if (!typing)
32329
+ var stopTyping = useCallback(function () {
32330
+ if (!typingRef.current)
32265
32331
  return;
32332
+ // Clear the timeout if it exists
32333
+ if (stopTypingTimeoutRef.current) {
32334
+ clearTimeout(stopTypingTimeoutRef.current);
32335
+ stopTypingTimeoutRef.current = null;
32336
+ }
32266
32337
  dispatch(sendTyping(false));
32267
32338
  setTypingState(false);
32268
- }
32339
+ typingRef.current = false;
32340
+ }, [dispatch]);
32341
+ var handleOnChange = useCallback(function () {
32342
+ // Send "typing" event only on first keystroke
32343
+ if (!typingRef.current) {
32344
+ dispatch(sendTyping(true));
32345
+ setTypingState(true);
32346
+ typingRef.current = true;
32347
+ }
32348
+ // Clear any existing timeout
32349
+ if (stopTypingTimeoutRef.current) {
32350
+ clearTimeout(stopTypingTimeoutRef.current);
32351
+ }
32352
+ // Set a new timeout to send "stop typing" after inactivity
32353
+ stopTypingTimeoutRef.current = window.setTimeout(function () {
32354
+ stopTyping();
32355
+ }, TYPING_INDICATOR_DEBOUNCE_MS);
32356
+ }, [dispatch, stopTyping]);
32269
32357
  function handleSendMessage(msg) {
32270
32358
  dispatch(sendMessage(msg));
32271
32359
  }
@@ -32417,20 +32505,7 @@ var ChatWidget = function (props) {
32417
32505
  avatarPath: config.avatarUrl,
32418
32506
  display_name: "Agent",
32419
32507
  };
32420
- return (React$1.createElement(React$1.Fragment, null,
32421
- React$1.createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
32422
- React$1.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
32423
- React$1.createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }),
32424
- React$1.createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.typingStatus) === null || _w === void 0 ? void 0 : _w.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }),
32425
- React$1.createElement("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
32426
- React$1.createElement("div", { className: "xa-spinner" })),
32427
- connectionStatus === "offline" && React$1.createElement(ServerOffline, null),
32428
- chatState.wsButton && visible && (React$1.createElement(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })),
32429
- React$1.createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_x = config === null || config === void 0 ? void 0 : config.input) === null || _x === void 0 ? void 0 : _x.placeholder, sendButtonIcon: (_z = (_y = config === null || config === void 0 ? void 0 : config.footer) === null || _y === void 0 ? void 0 : _y.sendButton) === null || _z === void 0 ? void 0 : _z.icon, sendButtonIconHover: (_1 = (_0 = config === null || config === void 0 ? void 0 : config.footer) === null || _0 === void 0 ? void 0 : _0.sendButton) === null || _1 === void 0 ? void 0 : _1.iconHover, sendButtonIconDisabled: (_3 = (_2 = config === null || config === void 0 ? void 0 : config.footer) === null || _2 === void 0 ? void 0 : _2.sendButton) === null || _3 === void 0 ? void 0 : _3.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: props.config.menu, footerConfig: (_4 = props.config) === null || _4 === void 0 ? void 0 : _4.footer, inputConfig: (_5 = props.config) === null || _5 === void 0 ? void 0 : _5.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }),
32430
- React$1.createElement("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick },
32431
- React$1.createElement(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }))),
32432
- React$1.createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: config === null || config === void 0 ? void 0 : config.cta, imageUrl: (_6 = config === null || config === void 0 ? void 0 : config.chatButton) === null || _6 === void 0 ? void 0 : _6.imageUrl, visible: visible, hasInteracted: (_7 = chatState.visuals) === null || _7 === void 0 ? void 0 : _7.hasInteracted, onCtaDismiss: handleCtaDismiss }),
32433
- React$1.createElement(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })));
32508
+ return (jsxs(Fragment, { children: [jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()), children: [jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }), jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.typingStatus) === null || _w === void 0 ? void 0 : _w.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && jsx(ServerOffline, {}), chatState.wsButton && visible && (jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_x = config === null || config === void 0 ? void 0 : config.input) === null || _x === void 0 ? void 0 : _x.placeholder, sendButtonIcon: (_z = (_y = config === null || config === void 0 ? void 0 : config.footer) === null || _y === void 0 ? void 0 : _y.sendButton) === null || _z === void 0 ? void 0 : _z.icon, sendButtonIconHover: (_1 = (_0 = config === null || config === void 0 ? void 0 : config.footer) === null || _0 === void 0 ? void 0 : _0.sendButton) === null || _1 === void 0 ? void 0 : _1.iconHover, sendButtonIconDisabled: (_3 = (_2 = config === null || config === void 0 ? void 0 : config.footer) === null || _2 === void 0 ? void 0 : _2.sendButton) === null || _3 === void 0 ? void 0 : _3.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: props.config.menu, footerConfig: (_4 = props.config) === null || _4 === void 0 ? void 0 : _4.footer, inputConfig: (_5 = props.config) === null || _5 === void 0 ? void 0 : _5.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), jsx(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: config === null || config === void 0 ? void 0 : config.cta, imageUrl: (_6 = config === null || config === void 0 ? void 0 : config.chatButton) === null || _6 === void 0 ? void 0 : _6.imageUrl, visible: visible, hasInteracted: (_7 = chatState.visuals) === null || _7 === void 0 ? void 0 : _7.hasInteracted, onCtaDismiss: handleCtaDismiss }), jsx(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })] }));
32434
32509
  };
32435
32510
 
32436
32511
  // src/utils/formatProdErrorMessage.ts
@@ -33747,15 +33822,23 @@ function memberJoin(state, detail) {
33747
33822
  // }
33748
33823
  var agents = __assign({}, state.agents);
33749
33824
  var prevAgentInfo = state.agents[detail.user.nick];
33750
- agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false });
33825
+ agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
33751
33826
  if (isAgent(detail.user.nick)) {
33752
- if (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) {
33827
+ // Always show join messages with special visual features (divider or custom message)
33828
+ // These are important conversation markers, not routine join notifications
33829
+ var hasSpecialVisuals = detail.showDivider || detail.message;
33830
+ if ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) {
33753
33831
  log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already joined. NOT adding duplicate join message to chat."));
33754
33832
  }
33755
33833
  else {
33756
- log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
33834
+ if (hasSpecialVisuals) {
33835
+ log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining with special visuals (divider or custom message). Adding join message to chat."));
33836
+ }
33837
+ else {
33838
+ log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
33839
+ }
33757
33840
  }
33758
- return __assign(__assign({}, state), { isChatting: true, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? state.chats : joinMessages(state.chats, detail), agents: agents });
33841
+ return __assign(__assign({}, state), { isChatting: true, chats: ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) ? state.chats : joinMessages(state.chats, detail), agents: agents });
33759
33842
  }
33760
33843
  else {
33761
33844
  log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
@@ -33771,9 +33854,22 @@ function memberLeave(state, detail) {
33771
33854
  var agentsJoined = Object.values(agents).filter(function (agent) { return agent.joined; });
33772
33855
  var isChatting = agentsJoined.length > 0;
33773
33856
  if (isAgent(detail.user.nick)) {
33857
+ var hasSpecialVisuals = detail.showDivider || detail.message;
33858
+ if (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) {
33859
+ if (hasSpecialVisuals) {
33860
+ log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving with special visuals (divider or custom message). Adding leave message to chat."));
33861
+ }
33862
+ else {
33863
+ log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
33864
+ }
33865
+ }
33866
+ else {
33867
+ log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already left. NOT adding duplicate leave message to chat."));
33868
+ }
33774
33869
  return __assign(__assign({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
33775
33870
  }
33776
33871
  else {
33872
+ log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
33777
33873
  return __assign(__assign({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
33778
33874
  }
33779
33875
  }
@@ -33799,6 +33895,10 @@ function resetReducer(state) {
33799
33895
  visuals: {} });
33800
33896
  }
33801
33897
 
33898
+ // Type guard for ChatSystemMessageDetail
33899
+ function isChatSystemMessage(chat) {
33900
+ return chat.type === "chat.systemmessage";
33901
+ }
33802
33902
  // todo: create reducer (requires redux-thunk dependency)
33803
33903
  function appendMessageToState(state, msg) {
33804
33904
  state.chats = joinMessages(state.chats, msg);
@@ -33867,6 +33967,20 @@ function update(state, action) {
33867
33967
  return memberJoin(state, action.detail);
33868
33968
  case "chat.memberleave":
33869
33969
  return memberLeave(state, action.detail);
33970
+ case "chat.systemmessage":
33971
+ // Add the system message to the chat
33972
+ appendMessageToState(newState, action.detail);
33973
+ return newState;
33974
+ case "chat.systemmessagedismiss":
33975
+ // Remove system message(s) with the specified id
33976
+ var dismissId_1 = action.detail.id;
33977
+ return __assign(__assign({}, newState), { chats: newState.chats.filter(function (chat) {
33978
+ // Keep all non-system messages, and system messages that don't match the id
33979
+ if (isChatSystemMessage(chat)) {
33980
+ return chat.id !== dismissId_1;
33981
+ }
33982
+ return true;
33983
+ }) });
33870
33984
  case "chat.queue.position":
33871
33985
  newState.queuePosition = action.detail.queuePosition;
33872
33986
  return newState;
@@ -34058,12 +34172,11 @@ var ChatWidgetContainer = function (props) {
34058
34172
  });
34059
34173
  }, [connection, (_a = props.config) === null || _a === void 0 ? void 0 : _a.userId, (_b = props.config) === null || _b === void 0 ? void 0 : _b.accessToken, (_c = props.config) === null || _c === void 0 ? void 0 : _c.attributes, (_d = props.config) === null || _d === void 0 ? void 0 : _d.sessionExpiration, (_e = props.config) === null || _e === void 0 ? void 0 : _e.enableErrorOverlay]);
34060
34174
  if ((_f = props.config) === null || _f === void 0 ? void 0 : _f.disabled) {
34061
- return React$1.createElement(React$1.Fragment, null);
34175
+ return jsx(Fragment, {});
34062
34176
  }
34063
34177
  var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
34064
34178
  });
34065
- return (React$1.createElement(Provider, { store: chatStore },
34066
- React$1.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
34179
+ return (jsx(Provider, { store: chatStore, children: jsx(ChatWidgetWrapper, __assign({}, widgetProps)) }));
34067
34180
  };
34068
34181
 
34069
34182
  // Function to create a static reducer
@@ -34097,11 +34210,10 @@ var StaticChatWidgetContainer = function (props) {
34097
34210
  var config = useMemo(function () {
34098
34211
  return __assign(__assign({}, props.config), { connection: {
34099
34212
  serverUrl: "",
34100
- type: "local"
34213
+ type: "local",
34101
34214
  } });
34102
34215
  }, [props.config]);
34103
- return (React$1.createElement(Provider, { store: store },
34104
- React$1.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
34216
+ return (jsx(Provider, { store: store, children: jsx(ChatWidgetWrapper, __assign({}, props, { config: config })) }));
34105
34217
  };
34106
34218
 
34107
34219
  function createStateFromMessages(messages) {
@@ -34114,7 +34226,7 @@ var StaticMessagesChatWidgetContainer = function (props) {
34114
34226
  var state = useMemo(function () {
34115
34227
  return createStateFromMessages(messages);
34116
34228
  }, [messages]);
34117
- return (React$1.createElement(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config }));
34229
+ return jsx(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config });
34118
34230
  };
34119
34231
 
34120
34232
  export { ActionButton, Avatar, CardMiddleware, Carousel, CarouselItem, ChatWidgetContainer as Chat, ChatButton, ChatCard, ChatChip, ChatChips, ChatHeader, ChatMenu, ChatMessage, ChatMessageBubble, ChatMessagePart, ChatWidgetWrapper as ChatWidget, CtaBubble, CtaBubbleContainer, List, ListItem, ListMiddleware, MessageList, MiddlewareContextFactory, StaticChatWidgetContainer, StaticMessagesChatWidgetContainer, joinMiddlewares, responseToMessage, useLateMiddleware, useStandardMiddleware };