@xapp/chat-widget 1.80.0 → 1.81.0
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.
- package/dist/components/AdminBar/AdminBar.d.ts +0 -0
- package/dist/components/CardContainer/CardContainer.d.ts +0 -0
- package/dist/components/ChatActionButtons/ChatActionButton.d.ts +0 -0
- package/dist/components/ChatActionButtons/ChatActionButtons.d.ts +0 -0
- package/dist/components/ChatMedia/ChatMedia.d.ts +1 -1
- package/dist/components/ChatMessage/ChatMessage.d.ts +0 -0
- package/dist/components/ChatMessagePart/ChatMessagePart.d.ts +0 -0
- package/dist/components/ChatRating/ChatRating.d.ts +0 -0
- package/dist/components/Icons/CloseIcon.d.ts +0 -0
- package/dist/components/Icons/LeftDownArrowIcon.d.ts +0 -0
- package/dist/components/Icons/SendIcon.d.ts +0 -0
- package/dist/components/Input/Input.d.ts +0 -0
- package/dist/components/MessageList/MessageList.d.ts +0 -0
- package/dist/components/MessageSvg/MessageSvg.d.ts +0 -0
- package/dist/components/QueuePosition/QueuePosition.d.ts +0 -0
- package/dist/components/ServerOffline/ServerOffline.d.ts +0 -0
- package/dist/components/UknownMessage/UnknownMessage.d.ts +0 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +644 -699
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +799 -854
- package/dist/index.js.map +1 -1
- package/dist/store/ChatAction.d.ts +0 -0
- package/dist/store/ChatState.d.ts +0 -0
- package/dist/storybook/store.d.ts +2 -2
- package/dist/xapp/StentorRouterChat.d.ts +0 -0
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +4 -4
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +21 -16
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var require$$1 = require('react');
|
|
4
|
+
var require$$0 = require('react/jsx-runtime');
|
|
4
5
|
var reactRedux = require('react-redux');
|
|
5
6
|
|
|
6
7
|
var ActionButton = function (_a) {
|
|
@@ -11,7 +12,7 @@ var ActionButton = function (_a) {
|
|
|
11
12
|
onClick(label);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
return (
|
|
15
|
+
return (require$$0.jsx("button", { disabled: disable, type: type, className: "action-button ".concat(addClass), onClick: handleClick, children: label }));
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
/******************************************************************************
|
|
@@ -168,14 +169,14 @@ function isAgent(nick) {
|
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
function useIsMounted() {
|
|
171
|
-
var ref =
|
|
172
|
-
|
|
172
|
+
var ref = require$$1.useRef(false);
|
|
173
|
+
require$$1.useEffect(function () {
|
|
173
174
|
ref.current = true;
|
|
174
175
|
return function () {
|
|
175
176
|
ref.current = false;
|
|
176
177
|
};
|
|
177
178
|
}, []);
|
|
178
|
-
return
|
|
179
|
+
return require$$1.useCallback(function () { return ref.current; }, []);
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
var RetryOptions = /** @class */ (function () {
|
|
@@ -347,9 +348,9 @@ var defaultWidgetButtonWidth = "48";
|
|
|
347
348
|
var defaultMobileWidgetButtonWidth = "30";
|
|
348
349
|
var defaultNonMobileScreenWidth = "400";
|
|
349
350
|
var scheduleWidgetUrl = "ScheduleButton";
|
|
350
|
-
var ChatConfigContext =
|
|
351
|
+
var ChatConfigContext = require$$1.createContext(null);
|
|
351
352
|
function useWidgetEnv() {
|
|
352
|
-
var ctx =
|
|
353
|
+
var ctx = require$$1.useContext(ChatConfigContext);
|
|
353
354
|
return ctx === null || ctx === void 0 ? void 0 : ctx.env;
|
|
354
355
|
}
|
|
355
356
|
function getServerConfig(env) {
|
|
@@ -365,7 +366,7 @@ function getServerConfig(env) {
|
|
|
365
366
|
function useServerConfig(env, nonce) {
|
|
366
367
|
var connection = getServerConfig(env);
|
|
367
368
|
var accountKey = connection.accountKey, serverUrl = connection.serverUrl, type = connection.type, timeout = connection.timeout;
|
|
368
|
-
return
|
|
369
|
+
return require$$1.useMemo(function () { return ({
|
|
369
370
|
accountKey: accountKey,
|
|
370
371
|
serverUrl: serverUrl,
|
|
371
372
|
timeout: timeout,
|
|
@@ -384,7 +385,7 @@ var Avatar = function (props) {
|
|
|
384
385
|
var style = {};
|
|
385
386
|
var child;
|
|
386
387
|
var entity = props.entity;
|
|
387
|
-
var chatConfig =
|
|
388
|
+
var chatConfig = require$$1.useContext(ChatConfigContext);
|
|
388
389
|
var avatarPath = entity === null || entity === void 0 ? void 0 : entity.avatarPath;
|
|
389
390
|
if (!avatarPath) {
|
|
390
391
|
var avatarImage = GenerateAvatar({
|
|
@@ -403,22 +404,21 @@ var Avatar = function (props) {
|
|
|
403
404
|
child = getVisitorSvg();
|
|
404
405
|
}
|
|
405
406
|
var hasImage = !!style.backgroundImage || !!child;
|
|
406
|
-
return (
|
|
407
|
+
return (require$$0.jsx("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent", children: child }));
|
|
407
408
|
};
|
|
408
409
|
/**
|
|
409
410
|
* Generates an SVG based on the
|
|
410
411
|
* @returns
|
|
411
412
|
*/
|
|
412
413
|
function getVisitorSvg() {
|
|
413
|
-
return (
|
|
414
|
-
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" })));
|
|
414
|
+
return (require$$0.jsx("svg", { width: "16", height: "19", viewBox: "0 0 16 19", style: { margin: "0 auto", display: "block" }, children: require$$0.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" }) }));
|
|
415
415
|
}
|
|
416
416
|
function GenerateAvatar(props) {
|
|
417
417
|
var initials = (props === null || props === void 0 ? void 0 : props.initials) || "?";
|
|
418
418
|
var size = (props === null || props === void 0 ? void 0 : props.size) || 40;
|
|
419
419
|
var backgroundColor = (props === null || props === void 0 ? void 0 : props.backgroundColor) || "#007bff";
|
|
420
420
|
var textColor = (props === null || props === void 0 ? void 0 : props.textColor) || "#ffffff";
|
|
421
|
-
var image =
|
|
421
|
+
var image = require$$1.useMemo(function () {
|
|
422
422
|
return generateImage(initials, size, backgroundColor, textColor);
|
|
423
423
|
}, [initials, size, backgroundColor, textColor]);
|
|
424
424
|
return image;
|
|
@@ -464,16 +464,16 @@ var OptionalLink = function (props) {
|
|
|
464
464
|
var chatDispatch = useChatDispatch();
|
|
465
465
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
466
466
|
var url = props.url, className = props.className, onOpen = props.onOpen;
|
|
467
|
-
var handleOpenUrl =
|
|
467
|
+
var handleOpenUrl = require$$1.useCallback(function () {
|
|
468
468
|
if (onOpen) {
|
|
469
469
|
onOpen(url, chatDispatch, visuals);
|
|
470
470
|
}
|
|
471
471
|
}, [url, onOpen]);
|
|
472
472
|
if (url) {
|
|
473
|
-
return (
|
|
473
|
+
return (require$$0.jsx("div", { onClick: handleOpenUrl, className: className, children: props.children }));
|
|
474
474
|
}
|
|
475
475
|
else {
|
|
476
|
-
return (
|
|
476
|
+
return (require$$0.jsx("div", { onClick: props.onClick, className: className, children: props.children }));
|
|
477
477
|
}
|
|
478
478
|
};
|
|
479
479
|
|
|
@@ -481,7 +481,7 @@ var ActionItem = function (props) {
|
|
|
481
481
|
var _a;
|
|
482
482
|
var item = props.item, onButtonClick = props.onButtonClick, onExecute = props.onExecute;
|
|
483
483
|
var singleButton = ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) === 1;
|
|
484
|
-
var handleClick =
|
|
484
|
+
var handleClick = require$$1.useCallback(function () {
|
|
485
485
|
var _a;
|
|
486
486
|
var btns = (_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length;
|
|
487
487
|
// If there is only one button, it takes precedent
|
|
@@ -494,17 +494,17 @@ var ActionItem = function (props) {
|
|
|
494
494
|
}
|
|
495
495
|
}, [item, onExecute, onButtonClick]);
|
|
496
496
|
var className = "xappw-chat-action-item ".concat(singleButton ? "xappw-chat-action-item--action" : "", " ").concat(props.className);
|
|
497
|
-
return (
|
|
497
|
+
return (require$$0.jsx(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl, children: props.children }));
|
|
498
498
|
};
|
|
499
499
|
|
|
500
500
|
var ChatImage = function (props) {
|
|
501
501
|
var cleanUrl = props.imageUrl.replace(/'/g, "%27");
|
|
502
|
-
var content =
|
|
502
|
+
var content = (require$$0.jsx("div", { className: "chat-card-img__content", style: { backgroundImage: "url(".concat(cleanUrl, ")") } }));
|
|
503
503
|
if (!props.imageActionUrl) {
|
|
504
|
-
return
|
|
504
|
+
return require$$0.jsx("div", { className: "chat-card-img", children: content });
|
|
505
505
|
}
|
|
506
506
|
else {
|
|
507
|
-
return (
|
|
507
|
+
return (require$$0.jsx("a", { href: props.imageActionUrl, "aria-label": "read more", target: "_blank", rel: "noopener noreferrer", className: "chat-card-img", children: content }));
|
|
508
508
|
}
|
|
509
509
|
};
|
|
510
510
|
|
|
@@ -515,63 +515,53 @@ var ActionItemImage = function (props) {
|
|
|
515
515
|
var itemUrl = getItemUrl(item);
|
|
516
516
|
if (item.imageUrl) {
|
|
517
517
|
var imageActionUrl = !singleButton ? item.imageActionUrl : null;
|
|
518
|
-
return (
|
|
519
|
-
React$1.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
|
|
518
|
+
return (require$$0.jsx("div", { className: props.className, children: require$$0.jsx(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl }) }));
|
|
520
519
|
}
|
|
521
520
|
else if (props.emptyImageVisible) {
|
|
522
|
-
return
|
|
521
|
+
return require$$0.jsx("div", { className: props.className });
|
|
523
522
|
}
|
|
524
|
-
return
|
|
523
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
525
524
|
};
|
|
526
525
|
|
|
527
526
|
var ChatActionButtonInner = function (props) {
|
|
528
527
|
var button = props.button, onClick = props.onClick;
|
|
529
|
-
var handleButton =
|
|
528
|
+
var handleButton = require$$1.useCallback(function () {
|
|
530
529
|
onClick(button);
|
|
531
530
|
}, [button, onClick]);
|
|
532
|
-
return
|
|
531
|
+
return require$$0.jsx(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label });
|
|
533
532
|
};
|
|
534
|
-
var ChatActionButton =
|
|
533
|
+
var ChatActionButton = require$$1.memo(ChatActionButtonInner);
|
|
535
534
|
|
|
536
535
|
var ChatActionButtonsInner = function (props) {
|
|
537
|
-
return (
|
|
538
|
-
|
|
539
|
-
|
|
536
|
+
return (require$$0.jsx("div", { className: "buttons-container " + (props.className || ""), children: props.buttons.map(function (button, i) {
|
|
537
|
+
return require$$0.jsx(ChatActionButton, { button: button, onClick: props.onClick }, i);
|
|
538
|
+
}) }));
|
|
540
539
|
};
|
|
541
|
-
var ChatActionButtons =
|
|
540
|
+
var ChatActionButtons = require$$1.memo(ChatActionButtonsInner);
|
|
542
541
|
|
|
543
542
|
var CarouselItem = function (props) {
|
|
544
543
|
var _a;
|
|
545
544
|
var item = props.item;
|
|
546
|
-
return (
|
|
547
|
-
React$1.createElement("div", { className: "chat-list-item" },
|
|
548
|
-
React$1.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
|
|
549
|
-
item.title && React$1.createElement("div", { className: "chat-list-item__title" },
|
|
550
|
-
React$1.createElement("span", null, item.title)),
|
|
551
|
-
item.subTitle && React$1.createElement("div", { className: "chat-list-item__subtitle" },
|
|
552
|
-
React$1.createElement("span", null, item.subTitle)),
|
|
553
|
-
!!((_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 }))));
|
|
545
|
+
return (require$$0.jsx(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl, children: require$$0.jsxs("div", { className: "chat-list-item", children: [require$$0.jsx(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }), item.title && (require$$0.jsx("div", { className: "chat-list-item__title", children: require$$0.jsx("span", { children: item.title }) })), item.subTitle && (require$$0.jsx("div", { className: "chat-list-item__subtitle", children: require$$0.jsx("span", { children: item.subTitle }) })), !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && (require$$0.jsx(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))] }) }));
|
|
554
546
|
};
|
|
555
547
|
|
|
556
548
|
function getLeftArrowSvg() {
|
|
557
|
-
return (
|
|
558
|
-
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" })));
|
|
549
|
+
return (require$$0.jsx("svg", { viewBox: "-5 -18 10 36", children: require$$0.jsx("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" }) }));
|
|
559
550
|
}
|
|
560
551
|
var ChevronLeft = function (props) {
|
|
561
|
-
return (
|
|
552
|
+
return (require$$0.jsx("button", { onClick: props.onClick, className: "xa-chevron", children: getLeftArrowSvg() }));
|
|
562
553
|
};
|
|
563
554
|
|
|
564
555
|
function getRightArrowSvg() {
|
|
565
|
-
return (
|
|
566
|
-
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" })));
|
|
556
|
+
return (require$$0.jsx("svg", { viewBox: "-5 -18 10 36", children: require$$0.jsx("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" }) }));
|
|
567
557
|
}
|
|
568
558
|
var ChevronRight = function (props) {
|
|
569
|
-
return (
|
|
559
|
+
return (require$$0.jsx("button", { onClick: props.onClick, className: "xa-chevron", children: getRightArrowSvg() }));
|
|
570
560
|
};
|
|
571
561
|
|
|
572
562
|
var Carousel = function (props) {
|
|
573
|
-
var listRef =
|
|
574
|
-
var _a =
|
|
563
|
+
var listRef = require$$1.useRef(null);
|
|
564
|
+
var _a = require$$1.useState(0), visibleIndex = _a[0], setSetVisibleIndex = _a[1];
|
|
575
565
|
function scrollMe(direction) {
|
|
576
566
|
var _a, _b;
|
|
577
567
|
var scrollArea = listRef.current;
|
|
@@ -605,21 +595,15 @@ var Carousel = function (props) {
|
|
|
605
595
|
var hasOnlyOneItem = props.list.items.length === 1;
|
|
606
596
|
var hasImage = props.list.items.some(function (item) { return item.imageUrl; });
|
|
607
597
|
var listItems = props.list.items.map(function (item, itemIndex) {
|
|
608
|
-
return (
|
|
609
|
-
React$1.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
598
|
+
return (require$$0.jsx("div", { className: "xappw-carousel-items__item", children: require$$0.jsx(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl }) }, "item-key-".concat(itemIndex)));
|
|
610
599
|
});
|
|
611
|
-
return (
|
|
612
|
-
!hasOnlyOneItem && (React$1.createElement("div", { className: "xappw-carousel__prev" },
|
|
613
|
-
React$1.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } }))),
|
|
614
|
-
React$1.createElement("div", { ref: listRef, className: "xappw-carousel-items ".concat(hasOnlyOneItem ? "xappw-carousel-items--one-item" : "") }, listItems),
|
|
615
|
-
!hasOnlyOneItem && (React$1.createElement("div", { className: "xappw-carousel__next" },
|
|
616
|
-
React$1.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } })))));
|
|
600
|
+
return (require$$0.jsxs("div", { className: "xappw-carousel", children: [!hasOnlyOneItem && (require$$0.jsx("div", { className: "xappw-carousel__prev", children: require$$0.jsx(ChevronLeft, { onClick: function () { return scrollMe(-1); } }) })), require$$0.jsx("div", { ref: listRef, className: "xappw-carousel-items ".concat(hasOnlyOneItem ? "xappw-carousel-items--one-item" : ""), children: listItems }), !hasOnlyOneItem && (require$$0.jsx("div", { className: "xappw-carousel__next", children: require$$0.jsx(ChevronRight, { onClick: function () { return scrollMe(1); } }) }))] }));
|
|
617
601
|
};
|
|
618
602
|
|
|
619
603
|
function useDimensions() {
|
|
620
|
-
var ref =
|
|
621
|
-
var _a =
|
|
622
|
-
|
|
604
|
+
var ref = require$$1.useRef(null);
|
|
605
|
+
var _a = require$$1.useState(), dimensions = _a[0], setDimensions = _a[1];
|
|
606
|
+
require$$1.useLayoutEffect(function () {
|
|
623
607
|
var _a, _b;
|
|
624
608
|
setDimensions((_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.toJSON());
|
|
625
609
|
}, []);
|
|
@@ -715,9 +699,7 @@ var CtaBubbleTail = function (props) {
|
|
|
715
699
|
var _a, _b;
|
|
716
700
|
var _c = useDimensions(), ref = _c[0], rect = _c[1];
|
|
717
701
|
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 };
|
|
718
|
-
return (
|
|
719
|
-
React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y) },
|
|
720
|
-
React$1.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" }))));
|
|
702
|
+
return (require$$0.jsx("div", { ref: ref, className: "cta-bubble__tail", children: require$$0.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y), children: require$$0.jsx("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" }) }) }));
|
|
721
703
|
};
|
|
722
704
|
var CtaBubble = function (props) {
|
|
723
705
|
var _a, _b, _c, _d;
|
|
@@ -731,17 +713,12 @@ var CtaBubble = function (props) {
|
|
|
731
713
|
}
|
|
732
714
|
};
|
|
733
715
|
console.log("Returning CTABubble with message: ", props.children);
|
|
734
|
-
return (
|
|
716
|
+
return (require$$0.jsxs("div", { ref: ref, style: {
|
|
735
717
|
border: props.borderStyle ? "solid" : "none",
|
|
736
718
|
borderWidth: ((_a = props.borderStyle) === null || _a === void 0 ? void 0 : _a.width) || "0px",
|
|
737
719
|
borderColor: ((_b = props.borderStyle) === null || _b === void 0 ? void 0 : _b.color) || "transparent",
|
|
738
720
|
animation: "".concat(animation, " 1s infinite"),
|
|
739
|
-
}, className: "cta-bubble", onClick: props.onClick },
|
|
740
|
-
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 }),
|
|
741
|
-
React$1.createElement("div", { className: "cta-bubble__content" }, props.children),
|
|
742
|
-
props.dismissible && (React$1.createElement("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss" },
|
|
743
|
-
React$1.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
744
|
-
React$1.createElement("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }))))));
|
|
721
|
+
}, className: "cta-bubble", onClick: props.onClick, children: [require$$0.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 }), require$$0.jsx("div", { className: "cta-bubble__content", children: props.children }), props.dismissible && (require$$0.jsx("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss", children: require$$0.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: require$$0.jsx("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }));
|
|
745
722
|
};
|
|
746
723
|
|
|
747
724
|
var CtaBubbleContainer = function (props) {
|
|
@@ -759,14 +736,14 @@ var CtaBubbleContainer = function (props) {
|
|
|
759
736
|
hasChildren: !!children,
|
|
760
737
|
childrenContent: children,
|
|
761
738
|
});
|
|
762
|
-
var startTime =
|
|
739
|
+
var startTime = require$$1.useMemo(function () {
|
|
763
740
|
var time = visible ? new Date().valueOf() : undefined;
|
|
764
741
|
log("[CtaBubbleContainer] StartTime calculated: visible=".concat(visible, ", startTime=").concat(time));
|
|
765
742
|
return time;
|
|
766
743
|
}, [visible]);
|
|
767
|
-
var _a =
|
|
744
|
+
var _a = require$$1.useState(false), showBubble = _a[0], setShowBubble = _a[1];
|
|
768
745
|
log("[CtaBubbleContainer] Current state: showBubble=".concat(showBubble));
|
|
769
|
-
|
|
746
|
+
require$$1.useEffect(function () {
|
|
770
747
|
log("[CtaBubbleContainer] useEffect triggered with:", {
|
|
771
748
|
startTime: startTime,
|
|
772
749
|
startTimeExists: !!startTime,
|
|
@@ -836,14 +813,14 @@ var CtaBubbleContainer = function (props) {
|
|
|
836
813
|
// Final render decision
|
|
837
814
|
var shouldRender = visible && showBubble;
|
|
838
815
|
log("[CtaBubbleContainer] Render decision: visible=".concat(visible, ", showBubble=").concat(showBubble, ", shouldRender=").concat(shouldRender));
|
|
839
|
-
return (
|
|
816
|
+
return (require$$0.jsx(require$$0.Fragment, { children: visible && showBubble && (require$$0.jsx(CtaBubble, { onClick: onClick, animate: animate, buttonAnimation: buttonAnimation, dismissible: dismissible, onDismiss: handleDismiss, children: children })) }));
|
|
840
817
|
};
|
|
841
818
|
|
|
842
819
|
var ChatButton = function (_a) {
|
|
843
820
|
var _b;
|
|
844
821
|
var onClick = _a.onClick, addClass = _a.addClass, config = _a.config, visible = _a.visible, borderStyle = _a.borderStyle, imageUrl = _a.imageUrl, hasInteracted = _a.hasInteracted, onCtaDismiss = _a.onCtaDismiss;
|
|
845
|
-
var _c =
|
|
846
|
-
var _d =
|
|
822
|
+
var _c = require$$1.useState(defaultWidgetButtonWidth), buttonWidth = _c[0], setButtonWidth = _c[1];
|
|
823
|
+
var _d = require$$1.useState(false), animate = _d[0], setAnimate = _d[1];
|
|
847
824
|
var mobileWidth = ((_b = config === null || config === void 0 ? void 0 : config.mobile) === null || _b === void 0 ? void 0 : _b.applyAtLessThanWidth) || defaultNonMobileScreenWidth;
|
|
848
825
|
// Determines mobile or normal
|
|
849
826
|
var getConfigToApply = function () {
|
|
@@ -856,7 +833,7 @@ var ChatButton = function (_a) {
|
|
|
856
833
|
}
|
|
857
834
|
};
|
|
858
835
|
var configToApply = getConfigToApply();
|
|
859
|
-
|
|
836
|
+
require$$1.useEffect(function () {
|
|
860
837
|
var _a;
|
|
861
838
|
var delayTimer;
|
|
862
839
|
var timeoutTimer;
|
|
@@ -899,7 +876,7 @@ var ChatButton = function (_a) {
|
|
|
899
876
|
};
|
|
900
877
|
}, [configToApply, setAnimate, hasInteracted]);
|
|
901
878
|
var animation = animate && !hasInteracted ? (configToApply === null || configToApply === void 0 ? void 0 : configToApply.animation) || "wiggle" : "none";
|
|
902
|
-
|
|
879
|
+
require$$1.useEffect(function () {
|
|
903
880
|
var handleResize = function () {
|
|
904
881
|
var screenWidth = window.innerWidth;
|
|
905
882
|
var newButtonWidth = screenWidth < parseInt(mobileWidth, 10)
|
|
@@ -915,23 +892,19 @@ var ChatButton = function (_a) {
|
|
|
915
892
|
}, [mobileWidth]);
|
|
916
893
|
var maxSvgSize = 22;
|
|
917
894
|
var svgSize = Math.min(maxSvgSize, (+buttonWidth / +defaultWidgetButtonWidth) * maxSvgSize);
|
|
918
|
-
return (
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
React$1.createElement("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22" },
|
|
932
|
-
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" })))),
|
|
933
|
-
configToApply && configToApply.message && !hasInteracted && (React$1.createElement("div", { className: "xapp-chat-button__cta" },
|
|
934
|
-
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)))));
|
|
895
|
+
return (require$$0.jsxs("button", { "aria-label": "open chat", className: "xapp-chat-button ".concat(addClass || "").trim(), onClick: onClick, children: [require$$0.jsx("div", { id: "xapp-widget-button", className: "xapp-chat-button__btn", style: {
|
|
896
|
+
width: "".concat(buttonWidth, "px"),
|
|
897
|
+
height: "".concat(buttonWidth, "px"),
|
|
898
|
+
borderRadius: "".concat(+buttonWidth / 2, "px"),
|
|
899
|
+
border: borderStyle && borderStyle.width ? "solid" : "none",
|
|
900
|
+
borderWidth: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.width) || "0px",
|
|
901
|
+
borderColor: (borderStyle === null || borderStyle === void 0 ? void 0 : borderStyle.color) || "transparent",
|
|
902
|
+
animation: "".concat(animation, " 1s infinite"),
|
|
903
|
+
}, children: imageUrl ? (
|
|
904
|
+
// Display image from URL
|
|
905
|
+
require$$0.jsx("img", { src: imageUrl, alt: "Chat Icon" })) : (
|
|
906
|
+
// Fallback to default SVG
|
|
907
|
+
require$$0.jsx("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22", children: require$$0.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 && (require$$0.jsx("div", { className: "xapp-chat-button__cta", children: require$$0.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 }) }))] }));
|
|
935
908
|
};
|
|
936
909
|
|
|
937
910
|
var ChatCard = function (props) {
|
|
@@ -941,40 +914,32 @@ var ChatCard = function (props) {
|
|
|
941
914
|
var image;
|
|
942
915
|
var content;
|
|
943
916
|
if (card.imageUrl) {
|
|
944
|
-
image =
|
|
945
|
-
React$1.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
|
|
917
|
+
image = (require$$0.jsx("div", { className: "chat-card-container__img", children: require$$0.jsx(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }) }));
|
|
946
918
|
}
|
|
947
919
|
if (card.title) {
|
|
948
|
-
title =
|
|
949
|
-
React$1.createElement("div", { className: "chat-card-title" },
|
|
950
|
-
React$1.createElement("span", null, card.title));
|
|
920
|
+
title = (require$$0.jsx("div", { className: "chat-card-title", children: require$$0.jsx("span", { children: card.title }) }));
|
|
951
921
|
}
|
|
952
922
|
if (card.content) {
|
|
953
|
-
content =
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
}
|
|
957
|
-
return (React$1.createElement("div", { className: "chat-card-container" },
|
|
958
|
-
image,
|
|
959
|
-
title,
|
|
960
|
-
content,
|
|
961
|
-
!!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
|
|
923
|
+
content = (require$$0.jsx("div", { className: "chat-card-sub-title", children: require$$0.jsx("span", { children: card.content }) }));
|
|
924
|
+
}
|
|
925
|
+
return (require$$0.jsxs("div", { className: "chat-card-container", children: [image, title, content, !!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && (require$$0.jsx(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick }))] }));
|
|
962
926
|
};
|
|
963
927
|
|
|
964
928
|
var ChatChip = function (props) {
|
|
965
929
|
var option = props.option;
|
|
966
|
-
var className = option.actionUrl
|
|
967
|
-
|
|
968
|
-
|
|
930
|
+
var className = option.actionUrl
|
|
931
|
+
? "chat-chip chat-chip-link"
|
|
932
|
+
: "chat-chip";
|
|
933
|
+
return (require$$0.jsx("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className, children: require$$0.jsx("span", { children: typeof option === "object" ? option.label : option }) }));
|
|
969
934
|
};
|
|
970
935
|
|
|
971
936
|
/**
|
|
972
937
|
* Render option list. We just follow the order.
|
|
973
938
|
*/
|
|
974
939
|
var ChatChips = function (props) {
|
|
975
|
-
return (
|
|
976
|
-
|
|
977
|
-
|
|
940
|
+
return (require$$0.jsx("div", { className: "chat-chips", children: props.options.map(function (option, i) {
|
|
941
|
+
return require$$0.jsx(ChatChip, { onClick: props.onOptionClick, option: option }, i);
|
|
942
|
+
}) }));
|
|
978
943
|
};
|
|
979
944
|
|
|
980
945
|
var defaultBehavior = {
|
|
@@ -1093,7 +1058,7 @@ function execute(url, dispatch, visuals, behavior) {
|
|
|
1093
1058
|
}
|
|
1094
1059
|
function useOpenUrlCallback() {
|
|
1095
1060
|
var env = useWidgetEnv();
|
|
1096
|
-
return
|
|
1061
|
+
return require$$1.useCallback(function (url, dispatch, visuals, behavior) {
|
|
1097
1062
|
if (!behavior) {
|
|
1098
1063
|
behavior = (env === null || env === void 0 ? void 0 : env.urls) ? resolveUrlPolicy(url, env.urls) : defaultBehavior;
|
|
1099
1064
|
}
|
|
@@ -1398,13 +1363,12 @@ function getDefaultExportFromCjs (x) {
|
|
|
1398
1363
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1399
1364
|
}
|
|
1400
1365
|
|
|
1401
|
-
var
|
|
1366
|
+
var jsxRuntime = require$$0;
|
|
1367
|
+
var react = require$$1;
|
|
1402
1368
|
|
|
1403
1369
|
var IconButton = function (props) {
|
|
1404
1370
|
var Icon = props.icon;
|
|
1405
|
-
return (
|
|
1406
|
-
React.createElement("div", { className: "xapp-search-icon-button__content" },
|
|
1407
|
-
React.createElement(Icon, null))));
|
|
1371
|
+
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, {}) }) }));
|
|
1408
1372
|
};
|
|
1409
1373
|
|
|
1410
1374
|
// compile time full switch-case verification
|
|
@@ -1414,17 +1378,17 @@ function throwBadKind(x) {
|
|
|
1414
1378
|
|
|
1415
1379
|
var RichTextBoldSpan = function (props) {
|
|
1416
1380
|
var format = props.format, text = props.text;
|
|
1417
|
-
return (
|
|
1381
|
+
return (jsxRuntime.jsx("span", { "data-rich-text-type": "bold", className: "xapp-search-rich-text-bold-span", children: text.substring(format.start, format.end) }));
|
|
1418
1382
|
};
|
|
1419
1383
|
|
|
1420
1384
|
var RichTextInputSpan = function (props) {
|
|
1421
1385
|
var format = props.format, text = props.text, readOnly = props.readOnly, onClick = props.onClick;
|
|
1422
1386
|
var defaultValue = format.text || text.substring(format.start, format.end);
|
|
1423
|
-
var _a =
|
|
1424
|
-
var handleChange =
|
|
1387
|
+
var _a = react.useState(defaultValue), value = _a[0], setValue = _a[1];
|
|
1388
|
+
var handleChange = react.useCallback(function (ev) {
|
|
1425
1389
|
setValue(ev.target.value);
|
|
1426
1390
|
}, []);
|
|
1427
|
-
var handleClick =
|
|
1391
|
+
var handleClick = react.useCallback(function (ev) {
|
|
1428
1392
|
if (onClick) {
|
|
1429
1393
|
var res = onClick(format);
|
|
1430
1394
|
if (res === false) {
|
|
@@ -1434,14 +1398,14 @@ var RichTextInputSpan = function (props) {
|
|
|
1434
1398
|
}
|
|
1435
1399
|
}, [onClick, format]);
|
|
1436
1400
|
if (readOnly) {
|
|
1437
|
-
return (
|
|
1401
|
+
return (jsxRuntime.jsx("span", { className: "xapp-search-rich-text-input-span xapp-search-rich-text-input-span--readonly", onClick: handleClick, children: defaultValue }));
|
|
1438
1402
|
}
|
|
1439
|
-
return (
|
|
1403
|
+
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 }));
|
|
1440
1404
|
};
|
|
1441
1405
|
|
|
1442
1406
|
var RichTextNormalSpan = function (props) {
|
|
1443
1407
|
var format = props.format, text = props.text;
|
|
1444
|
-
return (
|
|
1408
|
+
return (jsxRuntime.jsx("span", { "data-rich-text-type": "normal", className: "xapp-search-rich-text-normal-span", children: text.substring(format.start, format.end) }));
|
|
1445
1409
|
};
|
|
1446
1410
|
|
|
1447
1411
|
var RichTextSpan = function (props) {
|
|
@@ -1449,11 +1413,11 @@ var RichTextSpan = function (props) {
|
|
|
1449
1413
|
var type = format.type;
|
|
1450
1414
|
switch (type) {
|
|
1451
1415
|
case "normal":
|
|
1452
|
-
return
|
|
1416
|
+
return jsxRuntime.jsx(RichTextNormalSpan, { text: text, format: format, readOnly: readOnly });
|
|
1453
1417
|
case "bold":
|
|
1454
|
-
return
|
|
1418
|
+
return jsxRuntime.jsx(RichTextBoldSpan, { text: text, format: format, readOnly: readOnly });
|
|
1455
1419
|
case "inputText":
|
|
1456
|
-
return (
|
|
1420
|
+
return (jsxRuntime.jsx(RichTextInputSpan, { text: text, format: format, readOnly: readOnly, onClick: onClick }));
|
|
1457
1421
|
default:
|
|
1458
1422
|
throwBadKind(type);
|
|
1459
1423
|
}
|
|
@@ -1538,7 +1502,7 @@ function parseContent(node) {
|
|
|
1538
1502
|
formats.push({
|
|
1539
1503
|
type: type,
|
|
1540
1504
|
start: text.length,
|
|
1541
|
-
end: text.length + innerText.length
|
|
1505
|
+
end: text.length + innerText.length,
|
|
1542
1506
|
});
|
|
1543
1507
|
text += innerText;
|
|
1544
1508
|
}
|
|
@@ -1549,7 +1513,7 @@ function parseContent(node) {
|
|
|
1549
1513
|
formats.push({
|
|
1550
1514
|
type: "normal",
|
|
1551
1515
|
start: text.length,
|
|
1552
|
-
end: text.length + innerText.length
|
|
1516
|
+
end: text.length + innerText.length,
|
|
1553
1517
|
});
|
|
1554
1518
|
text += innerText;
|
|
1555
1519
|
}
|
|
@@ -1557,7 +1521,7 @@ function parseContent(node) {
|
|
|
1557
1521
|
});
|
|
1558
1522
|
return cleanRichTextValue({
|
|
1559
1523
|
text: text,
|
|
1560
|
-
formats: formats
|
|
1524
|
+
formats: formats,
|
|
1561
1525
|
});
|
|
1562
1526
|
}
|
|
1563
1527
|
function cleanContent(node) {
|
|
@@ -1575,22 +1539,21 @@ function cleanContent(node) {
|
|
|
1575
1539
|
try {
|
|
1576
1540
|
(_a = c.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(c);
|
|
1577
1541
|
}
|
|
1578
|
-
catch (_b) {
|
|
1579
|
-
}
|
|
1542
|
+
catch (_b) { }
|
|
1580
1543
|
}
|
|
1581
1544
|
}
|
|
1582
1545
|
var RichText = function (props) {
|
|
1583
1546
|
var value = props.value, className = props.className, readOnly = props.readOnly, onInput = props.onInput, onChange = props.onChange, onSpanClick = props.onSpanClick;
|
|
1584
1547
|
var formatsRaw = value.formats, text = value.text;
|
|
1585
|
-
var formats =
|
|
1586
|
-
var handleInput =
|
|
1548
|
+
var formats = react.useMemo(function () { return extendFormat(formatsRaw, text.length); }, [formatsRaw, text.length]);
|
|
1549
|
+
var handleInput = react.useCallback(function (ev) {
|
|
1587
1550
|
var target = ev.currentTarget;
|
|
1588
1551
|
var newValue = parseContent(target);
|
|
1589
1552
|
if (onInput) {
|
|
1590
1553
|
onInput(newValue);
|
|
1591
1554
|
}
|
|
1592
1555
|
}, [onInput]);
|
|
1593
|
-
var handleBlur =
|
|
1556
|
+
var handleBlur = react.useCallback(function (ev) {
|
|
1594
1557
|
var target = ev.currentTarget;
|
|
1595
1558
|
var newValue = parseContent(target);
|
|
1596
1559
|
cleanContent(target);
|
|
@@ -1598,49 +1561,53 @@ var RichText = function (props) {
|
|
|
1598
1561
|
onChange(newValue);
|
|
1599
1562
|
}
|
|
1600
1563
|
}, [onChange]);
|
|
1601
|
-
return (
|
|
1564
|
+
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)); }) }));
|
|
1602
1565
|
};
|
|
1603
1566
|
|
|
1604
1567
|
var RichInput = function (props) {
|
|
1605
1568
|
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;
|
|
1606
1569
|
var rich = value.formats.some(function (f) { return f.type === "inputText"; });
|
|
1607
|
-
var handleChange =
|
|
1608
|
-
onChange
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1570
|
+
var handleChange = react.useCallback(function (ev) {
|
|
1571
|
+
if (onChange) {
|
|
1572
|
+
onChange({
|
|
1573
|
+
text: ev.target.value,
|
|
1574
|
+
formats: [],
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1612
1577
|
}, [onChange]);
|
|
1613
|
-
var handleRichChange =
|
|
1614
|
-
onChange
|
|
1578
|
+
var handleRichChange = react.useCallback(function (val) {
|
|
1579
|
+
if (onChange) {
|
|
1580
|
+
onChange(val);
|
|
1581
|
+
}
|
|
1615
1582
|
}, [onChange]);
|
|
1616
|
-
var handleInput =
|
|
1583
|
+
var handleInput = react.useCallback(function (ev) {
|
|
1617
1584
|
if (onInput) {
|
|
1618
1585
|
onInput({
|
|
1619
1586
|
text: ev.target.value,
|
|
1620
|
-
formats: []
|
|
1587
|
+
formats: [],
|
|
1621
1588
|
});
|
|
1622
1589
|
}
|
|
1623
1590
|
}, [onInput]);
|
|
1624
|
-
var handleRichInput =
|
|
1591
|
+
var handleRichInput = react.useCallback(function (val) {
|
|
1625
1592
|
if (onInput) {
|
|
1626
1593
|
onInput(val);
|
|
1627
1594
|
}
|
|
1628
1595
|
}, [onInput]);
|
|
1629
|
-
var handleKeyDown =
|
|
1596
|
+
var handleKeyDown = react.useCallback(function (event) {
|
|
1630
1597
|
if (onKeyDown) {
|
|
1631
1598
|
onKeyDown(event);
|
|
1632
1599
|
}
|
|
1633
1600
|
}, [onKeyDown]);
|
|
1634
|
-
var inputRef =
|
|
1601
|
+
var inputRef = react.useRef(null);
|
|
1635
1602
|
var inputNode = inputRef.current;
|
|
1636
|
-
|
|
1603
|
+
react.useEffect(function () {
|
|
1637
1604
|
if (inputNode && onSearch) {
|
|
1638
1605
|
var handler_1 = function (ev) {
|
|
1639
1606
|
var target = ev.target;
|
|
1640
1607
|
if (target) {
|
|
1641
1608
|
onSearch({
|
|
1642
1609
|
text: target.value,
|
|
1643
|
-
formats: []
|
|
1610
|
+
formats: [],
|
|
1644
1611
|
});
|
|
1645
1612
|
}
|
|
1646
1613
|
};
|
|
@@ -1651,12 +1618,11 @@ var RichInput = function (props) {
|
|
|
1651
1618
|
}
|
|
1652
1619
|
return undefined;
|
|
1653
1620
|
}, [inputNode, onSearch]);
|
|
1654
|
-
return (
|
|
1655
|
-
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 })));
|
|
1621
|
+
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 })) }));
|
|
1656
1622
|
};
|
|
1657
1623
|
|
|
1658
1624
|
var SuggestionsGroupHeading = function (props) {
|
|
1659
|
-
return
|
|
1625
|
+
return jsxRuntime.jsx("div", { className: "xappw-suggestions-group-heading", children: props.label });
|
|
1660
1626
|
};
|
|
1661
1627
|
|
|
1662
1628
|
function getScrollContainer(node) {
|
|
@@ -1668,22 +1634,22 @@ function getScrollContainer(node) {
|
|
|
1668
1634
|
}
|
|
1669
1635
|
var SuggestionsItem = function (props) {
|
|
1670
1636
|
var data = props.data, current = props.current, ActionsComponent = props.actions, onClick = props.onClick, onHover = props.onHover, onSpanClick = props.onSpanClick;
|
|
1671
|
-
var handleClick =
|
|
1637
|
+
var handleClick = react.useCallback(function () {
|
|
1672
1638
|
onClick(data);
|
|
1673
1639
|
}, [data, onClick]);
|
|
1674
|
-
var handleHover =
|
|
1640
|
+
var handleHover = react.useCallback(function () {
|
|
1675
1641
|
if (onHover) {
|
|
1676
1642
|
onHover(data);
|
|
1677
1643
|
}
|
|
1678
1644
|
}, [data, onHover]);
|
|
1679
|
-
var handleSpanClick =
|
|
1645
|
+
var handleSpanClick = react.useCallback(function (span) {
|
|
1680
1646
|
if (onSpanClick) {
|
|
1681
1647
|
return onSpanClick(data, span);
|
|
1682
1648
|
}
|
|
1683
1649
|
return undefined;
|
|
1684
1650
|
}, [onSpanClick, data]);
|
|
1685
|
-
var ref =
|
|
1686
|
-
|
|
1651
|
+
var ref = react.useRef(null);
|
|
1652
|
+
react.useEffect(function () {
|
|
1687
1653
|
var node = ref.current;
|
|
1688
1654
|
if (current && node) {
|
|
1689
1655
|
var scrollContainer = getScrollContainer(node);
|
|
@@ -1700,22 +1666,13 @@ var SuggestionsItem = function (props) {
|
|
|
1700
1666
|
}
|
|
1701
1667
|
}
|
|
1702
1668
|
}, [current]);
|
|
1703
|
-
return (
|
|
1704
|
-
React.createElement(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true, onSpanClick: handleSpanClick }),
|
|
1705
|
-
ActionsComponent &&
|
|
1706
|
-
React.createElement("div", { className: "xappw-suggestions-item__actions" },
|
|
1707
|
-
React.createElement(ActionsComponent, { data: data, current: current }))));
|
|
1669
|
+
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 }) }))] }));
|
|
1708
1670
|
};
|
|
1709
1671
|
|
|
1710
1672
|
var SuggestionsGroup = function (props) {
|
|
1711
1673
|
var group = props.group, currentIndex = props.currentIndex, itemActions = props.itemActions;
|
|
1712
1674
|
var heading = group.heading, items = group.items;
|
|
1713
|
-
return (
|
|
1714
|
-
React.createElement("div", { className: "xappw-suggestions-group__heading" },
|
|
1715
|
-
React.createElement(SuggestionsGroupHeading, { label: heading })),
|
|
1716
|
-
React.createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
|
|
1717
|
-
return React.createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover, onSpanClick: props.onSpanClick });
|
|
1718
|
-
}))));
|
|
1675
|
+
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)); }) })] }));
|
|
1719
1676
|
};
|
|
1720
1677
|
|
|
1721
1678
|
function getItemsLength(result) {
|
|
@@ -1724,7 +1681,7 @@ function getItemsLength(result) {
|
|
|
1724
1681
|
|
|
1725
1682
|
var SuggestionsList = function (props) {
|
|
1726
1683
|
var suggestions = props.suggestions, itemActions = props.itemActions, className = props.className;
|
|
1727
|
-
var length =
|
|
1684
|
+
var length = react.useMemo(function () {
|
|
1728
1685
|
if (suggestions) {
|
|
1729
1686
|
return getItemsLength(suggestions);
|
|
1730
1687
|
}
|
|
@@ -1732,11 +1689,11 @@ var SuggestionsList = function (props) {
|
|
|
1732
1689
|
}, [suggestions]);
|
|
1733
1690
|
var currentIndex = length >= 0 ? props.index : NaN;
|
|
1734
1691
|
var indexWalker = 0;
|
|
1735
|
-
return (
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1692
|
+
return (jsxRuntime.jsx("div", { className: "xappw-suggestions-list ".concat(className || ""), children: suggestions === null || suggestions === void 0 ? void 0 : suggestions.map(function (group, index) {
|
|
1693
|
+
var res = (jsxRuntime.jsx(SuggestionsGroup, { group: group, currentIndex: currentIndex - indexWalker, itemActions: itemActions, onItemClick: props.onItemClick, onItemHover: props.onItemHover, onSpanClick: props.onSpanClick }, index));
|
|
1694
|
+
indexWalker += group.items.length;
|
|
1695
|
+
return res;
|
|
1696
|
+
}) }));
|
|
1740
1697
|
};
|
|
1741
1698
|
|
|
1742
1699
|
function findItemByIndex(groups, index) {
|
|
@@ -1755,65 +1712,6 @@ function findItemByIndex(groups, index) {
|
|
|
1755
1712
|
return undefined;
|
|
1756
1713
|
}
|
|
1757
1714
|
|
|
1758
|
-
function parseSuggestionsFormat(format) {
|
|
1759
|
-
var types = Object.keys(format);
|
|
1760
|
-
var type = types[0];
|
|
1761
|
-
var item = format[type];
|
|
1762
|
-
if (!item) {
|
|
1763
|
-
throw new Error();
|
|
1764
|
-
}
|
|
1765
|
-
return {
|
|
1766
|
-
type: type,
|
|
1767
|
-
start: item.start,
|
|
1768
|
-
end: item.end
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
function parseSuggestionsFormats(formats) {
|
|
1772
|
-
return formats.map(parseSuggestionsFormat);
|
|
1773
|
-
}
|
|
1774
|
-
function parseSuggestionsResponseItem(item) {
|
|
1775
|
-
return {
|
|
1776
|
-
text: item.suggestion,
|
|
1777
|
-
content: item.answer,
|
|
1778
|
-
formats: parseSuggestionsFormats(item.format),
|
|
1779
|
-
type: item.type
|
|
1780
|
-
};
|
|
1781
|
-
}
|
|
1782
|
-
function getHeading(type) {
|
|
1783
|
-
switch (type) {
|
|
1784
|
-
case "FAQ":
|
|
1785
|
-
return "FAQs";
|
|
1786
|
-
case "INTENT":
|
|
1787
|
-
return "Suggestions";
|
|
1788
|
-
case "HISTORICAL":
|
|
1789
|
-
return "Suggestions";
|
|
1790
|
-
default:
|
|
1791
|
-
return type;
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
function parseSuggestionsResponse(response, direction) {
|
|
1795
|
-
if (direction === void 0) { direction = 1; }
|
|
1796
|
-
if (!response) {
|
|
1797
|
-
return undefined;
|
|
1798
|
-
}
|
|
1799
|
-
var items = sortSuggestionItems(response.suggestions, direction);
|
|
1800
|
-
return items.reduce(function (result, current) {
|
|
1801
|
-
var mappedItem = parseSuggestionsResponseItem(current);
|
|
1802
|
-
if (result.length) {
|
|
1803
|
-
var prevGroup = result[result.length - 1];
|
|
1804
|
-
if (prevGroup.heading === getHeading(current.type)) {
|
|
1805
|
-
prevGroup.items.push(mappedItem);
|
|
1806
|
-
return result;
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
result.push({
|
|
1810
|
-
heading: getHeading(current.type),
|
|
1811
|
-
items: [mappedItem]
|
|
1812
|
-
});
|
|
1813
|
-
return result;
|
|
1814
|
-
}, []);
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
1715
|
/******************************************************************************
|
|
1818
1716
|
Copyright (c) Microsoft Corporation.
|
|
1819
1717
|
|
|
@@ -1896,6 +1794,65 @@ function sortSuggestionItems(items, direction) {
|
|
|
1896
1794
|
return __spreadArray([], items).sort(function (left, right) { return compareSuggestionItems(left, right, direction); });
|
|
1897
1795
|
}
|
|
1898
1796
|
|
|
1797
|
+
function parseSuggestionsFormat(format) {
|
|
1798
|
+
var types = Object.keys(format);
|
|
1799
|
+
var type = types[0];
|
|
1800
|
+
var item = format[type];
|
|
1801
|
+
if (!item) {
|
|
1802
|
+
throw new Error();
|
|
1803
|
+
}
|
|
1804
|
+
return {
|
|
1805
|
+
type: type,
|
|
1806
|
+
start: item.start,
|
|
1807
|
+
end: item.end,
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
function parseSuggestionsFormats(formats) {
|
|
1811
|
+
return formats.map(parseSuggestionsFormat);
|
|
1812
|
+
}
|
|
1813
|
+
function parseSuggestionsResponseItem(item) {
|
|
1814
|
+
return {
|
|
1815
|
+
text: item.suggestion,
|
|
1816
|
+
content: item.answer,
|
|
1817
|
+
formats: parseSuggestionsFormats(item.format),
|
|
1818
|
+
type: item.type,
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1821
|
+
function getHeading(type) {
|
|
1822
|
+
switch (type) {
|
|
1823
|
+
case "FAQ":
|
|
1824
|
+
return "FAQs";
|
|
1825
|
+
case "INTENT":
|
|
1826
|
+
return "Suggestions";
|
|
1827
|
+
case "HISTORICAL":
|
|
1828
|
+
return "Suggestions";
|
|
1829
|
+
default:
|
|
1830
|
+
return type;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
function parseSuggestionsResponse(response, direction) {
|
|
1834
|
+
if (direction === void 0) { direction = 1; }
|
|
1835
|
+
if (!response) {
|
|
1836
|
+
return undefined;
|
|
1837
|
+
}
|
|
1838
|
+
var items = sortSuggestionItems(response.suggestions, direction);
|
|
1839
|
+
return items.reduce(function (result, current) {
|
|
1840
|
+
var mappedItem = parseSuggestionsResponseItem(current);
|
|
1841
|
+
if (result.length) {
|
|
1842
|
+
var prevGroup = result[result.length - 1];
|
|
1843
|
+
if (prevGroup.heading === getHeading(current.type)) {
|
|
1844
|
+
prevGroup.items.push(mappedItem);
|
|
1845
|
+
return result;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
result.push({
|
|
1849
|
+
heading: getHeading(current.type),
|
|
1850
|
+
items: [mappedItem],
|
|
1851
|
+
});
|
|
1852
|
+
return result;
|
|
1853
|
+
}, []);
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1899
1856
|
/**
|
|
1900
1857
|
* Append the provided query params to the URL
|
|
1901
1858
|
*
|
|
@@ -1918,11 +1875,11 @@ function noop$1() {
|
|
|
1918
1875
|
}
|
|
1919
1876
|
function useJsonFetch(url, options) {
|
|
1920
1877
|
if (options === void 0) { options = defaultOptions$2; }
|
|
1921
|
-
var _a =
|
|
1878
|
+
var _a = react.useState({
|
|
1922
1879
|
state: "paused"
|
|
1923
1880
|
}), value = _a[0], setValue = _a[1];
|
|
1924
1881
|
var pause = options.pause;
|
|
1925
|
-
|
|
1882
|
+
react.useEffect(function () {
|
|
1926
1883
|
if (pause) {
|
|
1927
1884
|
setValue({
|
|
1928
1885
|
state: "paused"
|
|
@@ -1987,7 +1944,7 @@ function useJsonFetch(url, options) {
|
|
|
1987
1944
|
|
|
1988
1945
|
function useSuggestionsFetch$1(options) {
|
|
1989
1946
|
var baseUrl = options.url, context = options.context, query = options.query;
|
|
1990
|
-
var url =
|
|
1947
|
+
var url = react.useMemo(function () {
|
|
1991
1948
|
if (!baseUrl) {
|
|
1992
1949
|
return undefined;
|
|
1993
1950
|
}
|
|
@@ -3033,6 +2990,11 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3033
2990
|
if (typeof ((_a = _this.options.hooks) === null || _a === void 0 ? void 0 : _a.onResponse) === "function") {
|
|
3034
2991
|
_this.options.hooks.onResponse(response);
|
|
3035
2992
|
}
|
|
2993
|
+
// Session is initialized after first bot response (same as StentorDirectChat)
|
|
2994
|
+
if (_this.isNewSession) {
|
|
2995
|
+
_this.isNewSession = false;
|
|
2996
|
+
log("Session initialized after receiving first bot response");
|
|
2997
|
+
}
|
|
3036
2998
|
message = responseToMessage(response);
|
|
3037
2999
|
}
|
|
3038
3000
|
else if (sender.deviceId === "Widget") {
|
|
@@ -3055,35 +3017,43 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3055
3017
|
},
|
|
3056
3018
|
});
|
|
3057
3019
|
};
|
|
3058
|
-
this.handlers["user joined"] = function (
|
|
3020
|
+
this.handlers["user joined"] = function (data, sender, ts, _attributes) {
|
|
3059
3021
|
var _a, _b;
|
|
3060
3022
|
var nick = senderToNick(sender);
|
|
3061
3023
|
log("Received \"user joined\" event - deviceId: ".concat(sender.deviceId, ", userId: ").concat(sender.userId, ", displayName: ").concat(sender.displayName, ", nick: ").concat(nick));
|
|
3062
3024
|
log("Dispatching chat.memberjoin for ".concat(sender.displayName || "Unknown"));
|
|
3025
|
+
var userData = data;
|
|
3063
3026
|
_this.dispatch({
|
|
3064
3027
|
type: "chat",
|
|
3065
3028
|
detail: {
|
|
3066
3029
|
type: "chat.memberjoin",
|
|
3067
3030
|
user: {
|
|
3068
|
-
avatarPath: (_b = (_a = _this.options) === null || _a === void 0 ? void 0 : _a.bot) === null || _b === void 0 ? void 0 : _b.avatarPath,
|
|
3031
|
+
avatarPath: sender.avatarPath || ((_b = (_a = _this.options) === null || _a === void 0 ? void 0 : _a.bot) === null || _b === void 0 ? void 0 : _b.avatarPath),
|
|
3069
3032
|
displayName: sender.displayName,
|
|
3070
3033
|
nick: nick,
|
|
3071
3034
|
},
|
|
3072
3035
|
timestamp: ts || new Date().getTime(),
|
|
3036
|
+
showDivider: userData === null || userData === void 0 ? void 0 : userData.showDivider,
|
|
3037
|
+
message: userData === null || userData === void 0 ? void 0 : userData.message,
|
|
3038
|
+
hideUserInfo: userData === null || userData === void 0 ? void 0 : userData.hideUserInfo,
|
|
3073
3039
|
},
|
|
3074
3040
|
});
|
|
3075
3041
|
log("chat.memberjoin dispatched for nick: ".concat(nick));
|
|
3076
3042
|
};
|
|
3077
|
-
this.handlers["user left"] = function (
|
|
3043
|
+
this.handlers["user left"] = function (data, sender, ts, _attributes) {
|
|
3044
|
+
var userData = data;
|
|
3078
3045
|
_this.dispatch({
|
|
3079
3046
|
type: "chat",
|
|
3080
3047
|
detail: {
|
|
3081
3048
|
type: "chat.memberleave",
|
|
3082
3049
|
user: {
|
|
3050
|
+
avatarPath: sender.avatarPath,
|
|
3083
3051
|
displayName: sender.displayName,
|
|
3084
3052
|
nick: senderToNick(sender),
|
|
3085
3053
|
},
|
|
3086
3054
|
timestamp: ts || new Date().getTime(),
|
|
3055
|
+
showDivider: userData === null || userData === void 0 ? void 0 : userData.showDivider,
|
|
3056
|
+
message: userData === null || userData === void 0 ? void 0 : userData.message,
|
|
3087
3057
|
},
|
|
3088
3058
|
});
|
|
3089
3059
|
};
|
|
@@ -3154,6 +3124,54 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3154
3124
|
_this.dispatch(dismissWsButton(data.id));
|
|
3155
3125
|
}, WS_BUTTON_DISMISS_ANIMATION_DURATION);
|
|
3156
3126
|
};
|
|
3127
|
+
this.handlers["system-message"] = function (data, sender, ts, _attributes) {
|
|
3128
|
+
log("Received \"system-message\" event - id: ".concat(data.id, ", message: ").concat(data.message, ", dismissId: ").concat(data.dismissId));
|
|
3129
|
+
// If there's a dismissId, dispatch dismiss action first
|
|
3130
|
+
if (data.dismissId) {
|
|
3131
|
+
_this.dispatch({
|
|
3132
|
+
type: "chat",
|
|
3133
|
+
detail: {
|
|
3134
|
+
type: "chat.systemmessagedismiss",
|
|
3135
|
+
user: {
|
|
3136
|
+
displayName: sender.displayName || "System",
|
|
3137
|
+
nick: senderToNick(sender),
|
|
3138
|
+
},
|
|
3139
|
+
id: data.dismissId,
|
|
3140
|
+
timestamp: ts || new Date().getTime(),
|
|
3141
|
+
},
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
// Then dispatch the new system message
|
|
3145
|
+
_this.dispatch({
|
|
3146
|
+
type: "chat",
|
|
3147
|
+
detail: {
|
|
3148
|
+
type: "chat.systemmessage",
|
|
3149
|
+
user: {
|
|
3150
|
+
displayName: sender.displayName || "System",
|
|
3151
|
+
nick: senderToNick(sender),
|
|
3152
|
+
},
|
|
3153
|
+
id: data.id,
|
|
3154
|
+
message: data.message,
|
|
3155
|
+
dismissId: data.dismissId,
|
|
3156
|
+
timestamp: ts || new Date().getTime(),
|
|
3157
|
+
},
|
|
3158
|
+
});
|
|
3159
|
+
};
|
|
3160
|
+
this.handlers["system-message-dismiss"] = function (data, sender, ts, _attributes) {
|
|
3161
|
+
log("Received \"system-message-dismiss\" event - id: ".concat(data.id));
|
|
3162
|
+
_this.dispatch({
|
|
3163
|
+
type: "chat",
|
|
3164
|
+
detail: {
|
|
3165
|
+
type: "chat.systemmessagedismiss",
|
|
3166
|
+
user: {
|
|
3167
|
+
displayName: sender.displayName || "System",
|
|
3168
|
+
nick: senderToNick(sender),
|
|
3169
|
+
},
|
|
3170
|
+
id: data.id,
|
|
3171
|
+
timestamp: ts || new Date().getTime(),
|
|
3172
|
+
},
|
|
3173
|
+
});
|
|
3174
|
+
};
|
|
3157
3175
|
// Register the router as a pseudo-agent (serverInfo) so it can send messages (like internal errors)
|
|
3158
3176
|
this.dispatch({
|
|
3159
3177
|
type: "chat",
|
|
@@ -7728,7 +7746,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
7728
7746
|
type: "chat.memberjoin",
|
|
7729
7747
|
user: {
|
|
7730
7748
|
displayName: data.username,
|
|
7731
|
-
nick: "agent:robot",
|
|
7749
|
+
nick: data.nick || "agent:robot",
|
|
7732
7750
|
avatarPath: data.avatarPath
|
|
7733
7751
|
},
|
|
7734
7752
|
timestamp: +new Date(),
|
|
@@ -7881,16 +7899,16 @@ function createChatServerCore(config, options) {
|
|
|
7881
7899
|
function createChatServer(config, options) {
|
|
7882
7900
|
return new LogChat(createChatServerCore(config, options));
|
|
7883
7901
|
}
|
|
7884
|
-
var ChatServerContext =
|
|
7902
|
+
var ChatServerContext = require$$1.createContext(null);
|
|
7885
7903
|
function useChatServer(config, options) {
|
|
7886
|
-
var _a =
|
|
7904
|
+
var _a = require$$1.useState(), server = _a[0], setServer = _a[1];
|
|
7887
7905
|
var dispatch = useChatDispatch();
|
|
7888
7906
|
var deps = [options, config, dispatch];
|
|
7889
7907
|
// Track previous values to detect what changed
|
|
7890
|
-
var prevDepsRef =
|
|
7908
|
+
var prevDepsRef = require$$1.useRef(undefined);
|
|
7891
7909
|
// Log what caused the "effect"
|
|
7892
7910
|
// useWhatChanged(deps, "options, config, dispatch");
|
|
7893
|
-
|
|
7911
|
+
require$$1.useEffect(function () {
|
|
7894
7912
|
// Log when effect runs and what changed (for debugging connection issues)
|
|
7895
7913
|
if (prevDepsRef.current) {
|
|
7896
7914
|
var _a = prevDepsRef.current, prevOptions = _a[0], prevConfig = _a[1], prevDispatch = _a[2];
|
|
@@ -7929,8 +7947,8 @@ function useChatServer(config, options) {
|
|
|
7929
7947
|
|
|
7930
7948
|
function useChatServerDispatch() {
|
|
7931
7949
|
var inner = useChatDispatch();
|
|
7932
|
-
var chatServer =
|
|
7933
|
-
return
|
|
7950
|
+
var chatServer = require$$1.useContext(ChatServerContext);
|
|
7951
|
+
return require$$1.useCallback(function (action) {
|
|
7934
7952
|
if (!action) {
|
|
7935
7953
|
console.warn("react bug? Someone invokes with null");
|
|
7936
7954
|
return;
|
|
@@ -7960,17 +7978,16 @@ var ChatChipsContainer = function (_) {
|
|
|
7960
7978
|
}));
|
|
7961
7979
|
}
|
|
7962
7980
|
}
|
|
7963
|
-
return (
|
|
7964
|
-
React$1.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
7981
|
+
return (require$$0.jsx("div", { className: "message-list-container__chips ".concat(!(chips === null || chips === void 0 ? void 0 : chips.length) ? "message-list-container__chips--empty" : ""), children: require$$0.jsx(ChatChips, { options: chips, onOptionClick: optionOnChange }) }));
|
|
7965
7982
|
};
|
|
7966
7983
|
|
|
7967
7984
|
var ButtonGroup = function (_a) {
|
|
7968
7985
|
var children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b;
|
|
7969
|
-
return (
|
|
7986
|
+
return (require$$0.jsx("div", { className: "button-group ".concat(className), children: children }));
|
|
7970
7987
|
};
|
|
7971
7988
|
|
|
7972
7989
|
var CancelButton = function (props) {
|
|
7973
|
-
return (
|
|
7990
|
+
return (require$$0.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 }));
|
|
7974
7991
|
};
|
|
7975
7992
|
|
|
7976
7993
|
var lib = {};
|
|
@@ -8055,10 +8072,8 @@ var ChatMenuItem = function (props) {
|
|
|
8055
8072
|
props.onClick(props.label);
|
|
8056
8073
|
}
|
|
8057
8074
|
}
|
|
8058
|
-
var content = props.subtitle ? (
|
|
8059
|
-
|
|
8060
|
-
React$1.createElement("div", { className: "chat-menu-item--subtitle" }, props.subtitle))) : (React$1.createElement("span", null, props.label));
|
|
8061
|
-
return (React$1.createElement("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick }, content));
|
|
8075
|
+
var content = props.subtitle ? (require$$0.jsxs("span", { children: [require$$0.jsx("div", { children: props.label }), require$$0.jsx("div", { className: "chat-menu-item--subtitle", children: props.subtitle })] })) : (require$$0.jsx("span", { children: props.label }));
|
|
8076
|
+
return (require$$0.jsx("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick, children: content }));
|
|
8062
8077
|
};
|
|
8063
8078
|
|
|
8064
8079
|
var _this = undefined;
|
|
@@ -8068,28 +8083,24 @@ var ChatMenu = function (props) {
|
|
|
8068
8083
|
var handleOpenUrl = useOpenUrlCallback();
|
|
8069
8084
|
var chatDispatch = useChatDispatch();
|
|
8070
8085
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8071
|
-
return (
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
return React$1.createElement("button", { key: i, className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior) }, item.text);
|
|
8090
|
-
}
|
|
8091
|
-
return React$1.createElement("p", null, "Unknown");
|
|
8092
|
-
})));
|
|
8086
|
+
return (require$$0.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) {
|
|
8087
|
+
if (lib.isStandardMenuItem(item)) {
|
|
8088
|
+
return (require$$0.jsx(ChatMenuItem, { onClick: props.onItemClick, label: item.label, subtitle: item.subtitle }, i));
|
|
8089
|
+
}
|
|
8090
|
+
else if (lib.isStaticImageMenuItem(item)) {
|
|
8091
|
+
return (require$$0.jsx("div", { className: "chat-menu-item-static", children: require$$0.jsx("img", { style: {
|
|
8092
|
+
maxHeight: "100%",
|
|
8093
|
+
maxWidth: "auto",
|
|
8094
|
+
}, src: item.imageUrl, alt: "Menu Item" }) }, i));
|
|
8095
|
+
}
|
|
8096
|
+
else if (lib.isStaticTextMenuItem(item)) {
|
|
8097
|
+
return (require$$0.jsx("div", { className: "chat-menu-item-static-text", children: require$$0.jsxs("div", { children: [require$$0.jsx("div", { children: item.title }), require$$0.jsx("div", { className: "chat-menu-item-static-text--body", children: item.body })] }) }, i));
|
|
8098
|
+
}
|
|
8099
|
+
else if (lib.isOpenURLMenuItem(item)) {
|
|
8100
|
+
return (require$$0.jsx("button", { className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, chatDispatch, visuals, item.behavior), children: item.text }, i));
|
|
8101
|
+
}
|
|
8102
|
+
return require$$0.jsx("p", { children: "Unknown" });
|
|
8103
|
+
}) }));
|
|
8093
8104
|
};
|
|
8094
8105
|
|
|
8095
8106
|
var DrawerBars = function (props) {
|
|
@@ -8101,23 +8112,23 @@ var DrawerBars = function (props) {
|
|
|
8101
8112
|
function getBars() {
|
|
8102
8113
|
var barElements = [];
|
|
8103
8114
|
for (var bar = 0; bar < bars; bar++) {
|
|
8104
|
-
barElements.push(
|
|
8115
|
+
barElements.push(require$$0.jsx("div", { className: "drawer-bar bar".concat(bar) }, "drawer-bar-".concat(bar)));
|
|
8105
8116
|
}
|
|
8106
8117
|
return barElements;
|
|
8107
8118
|
}
|
|
8108
|
-
return (
|
|
8119
|
+
return (require$$0.jsx("button", { className: "drawer-bars", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, "aria-label": "open menu", "aria-hidden": false, onClick: props.onToggle, children: getBars() }));
|
|
8109
8120
|
};
|
|
8110
8121
|
|
|
8111
8122
|
var MenuButton = function (props) {
|
|
8112
|
-
return (
|
|
8123
|
+
return (require$$0.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 }));
|
|
8113
8124
|
};
|
|
8114
8125
|
|
|
8115
8126
|
var MinimizeButton = function (props) {
|
|
8116
|
-
return (
|
|
8127
|
+
return (require$$0.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 }));
|
|
8117
8128
|
};
|
|
8118
8129
|
|
|
8119
8130
|
var RefreshButton = function (props) {
|
|
8120
|
-
return (
|
|
8131
|
+
return (require$$0.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 }));
|
|
8121
8132
|
};
|
|
8122
8133
|
|
|
8123
8134
|
var DEFAULT_STATUS_CONFIG = {
|
|
@@ -8140,21 +8151,126 @@ function getStatusText(status, config) {
|
|
|
8140
8151
|
return (_d = config === null || config === void 0 ? void 0 : config.connecting) !== null && _d !== void 0 ? _d : DEFAULT_STATUS_CONFIG.connecting;
|
|
8141
8152
|
}
|
|
8142
8153
|
}
|
|
8154
|
+
/**
|
|
8155
|
+
* Determines if a string contains HTML tags
|
|
8156
|
+
*/
|
|
8157
|
+
function isHtmlString(text) {
|
|
8158
|
+
if (typeof text !== "string") {
|
|
8159
|
+
return false;
|
|
8160
|
+
}
|
|
8161
|
+
// Check for common HTML patterns
|
|
8162
|
+
var htmlPattern = /<\/?[a-z][\s\S]*>/i;
|
|
8163
|
+
return htmlPattern.test(text);
|
|
8164
|
+
}
|
|
8165
|
+
/**
|
|
8166
|
+
* Sanitizes HTML string by removing potentially dangerous elements and attributes
|
|
8167
|
+
*/
|
|
8168
|
+
function sanitizeHtml(html) {
|
|
8169
|
+
try {
|
|
8170
|
+
// Check if DOMParser is available
|
|
8171
|
+
if (typeof DOMParser === "undefined") {
|
|
8172
|
+
log("DOMParser not available, returning text content only");
|
|
8173
|
+
return html.replace(/<[^>]*>/g, ""); // Strip all HTML tags as fallback
|
|
8174
|
+
}
|
|
8175
|
+
// Create a temporary DOM element to parse the HTML
|
|
8176
|
+
var doc_1 = new DOMParser().parseFromString(html, "text/html");
|
|
8177
|
+
// Check if parsing was successful
|
|
8178
|
+
if (!doc_1 || !doc_1.body) {
|
|
8179
|
+
log("DOMParser failed to parse HTML, returning text content only");
|
|
8180
|
+
return html.replace(/<[^>]*>/g, ""); // Strip all HTML tags as fallback
|
|
8181
|
+
}
|
|
8182
|
+
// List of allowed tags (whitelist approach)
|
|
8183
|
+
var allowedTags_1 = ["span", "div", "p", "strong", "em", "b", "i", "u", "br"];
|
|
8184
|
+
// List of allowed style properties
|
|
8185
|
+
var allowedStyleProps_1 = [
|
|
8186
|
+
"color", "background-color", "font-size", "font-weight", "font-style",
|
|
8187
|
+
"text-align", "display", "flex", "align-items", "justify-content",
|
|
8188
|
+
"gap", "margin", "padding", "width", "height", "border-radius"
|
|
8189
|
+
];
|
|
8190
|
+
// Recursive function to clean nodes
|
|
8191
|
+
var cleanNode_1 = function (node) {
|
|
8192
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
8193
|
+
var element_1 = node;
|
|
8194
|
+
var tagName = element_1.tagName.toLowerCase();
|
|
8195
|
+
// Remove if not in allowed tags, but preserve text content
|
|
8196
|
+
if (!allowedTags_1.includes(tagName)) {
|
|
8197
|
+
// Replace the element with its text content
|
|
8198
|
+
var textNode = doc_1.createTextNode(element_1.textContent || "");
|
|
8199
|
+
element_1.replaceWith(textNode);
|
|
8200
|
+
return;
|
|
8201
|
+
}
|
|
8202
|
+
// Remove all attributes except style
|
|
8203
|
+
var attributes = Array.from(element_1.attributes);
|
|
8204
|
+
attributes.forEach(function (attr) {
|
|
8205
|
+
if (attr.name !== "style") {
|
|
8206
|
+
element_1.removeAttribute(attr.name);
|
|
8207
|
+
}
|
|
8208
|
+
});
|
|
8209
|
+
// Clean style attribute - only allow safe properties
|
|
8210
|
+
if (element_1.hasAttribute("style")) {
|
|
8211
|
+
var styleText = element_1.getAttribute("style") || "";
|
|
8212
|
+
var cleanedStyles_1 = [];
|
|
8213
|
+
// Parse individual style properties
|
|
8214
|
+
styleText.split(";").forEach(function (declaration) {
|
|
8215
|
+
var _a = declaration.split(":"), prop = _a[0], valueParts = _a.slice(1);
|
|
8216
|
+
var value = valueParts.join(":").trim(); // Rejoin in case value contains colons
|
|
8217
|
+
var propTrimmed = prop.trim();
|
|
8218
|
+
if (propTrimmed && value && allowedStyleProps_1.includes(propTrimmed.toLowerCase())) {
|
|
8219
|
+
// Additional validation: ensure value doesn't contain javascript: or expression()
|
|
8220
|
+
if (!/javascript:|expression\(|@import|behavior:/i.test(value)) {
|
|
8221
|
+
cleanedStyles_1.push("".concat(propTrimmed, ": ").concat(value));
|
|
8222
|
+
}
|
|
8223
|
+
}
|
|
8224
|
+
});
|
|
8225
|
+
if (cleanedStyles_1.length > 0) {
|
|
8226
|
+
element_1.setAttribute("style", cleanedStyles_1.join("; "));
|
|
8227
|
+
}
|
|
8228
|
+
else {
|
|
8229
|
+
element_1.removeAttribute("style");
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
// Recursively clean child nodes
|
|
8233
|
+
var children = Array.from(element_1.childNodes);
|
|
8234
|
+
children.forEach(function (child) { return cleanNode_1(child); });
|
|
8235
|
+
}
|
|
8236
|
+
};
|
|
8237
|
+
// Clean each child of the body, not the body itself
|
|
8238
|
+
Array.from(doc_1.body.childNodes).forEach(function (child) { return cleanNode_1(child); });
|
|
8239
|
+
return doc_1.body.innerHTML;
|
|
8240
|
+
}
|
|
8241
|
+
catch (error) {
|
|
8242
|
+
log("Error sanitizing HTML: ".concat(error));
|
|
8243
|
+
// Fallback: strip all HTML tags
|
|
8244
|
+
return html.replace(/<[^>]*>/g, "");
|
|
8245
|
+
}
|
|
8246
|
+
}
|
|
8247
|
+
/**
|
|
8248
|
+
* Safely renders subtitle text that can be plain text, JSX, or HTML string
|
|
8249
|
+
*/
|
|
8250
|
+
function renderSubtitleText(text) {
|
|
8251
|
+
// If it's an HTML string, sanitize and render it using dangerouslySetInnerHTML
|
|
8252
|
+
if (isHtmlString(text)) {
|
|
8253
|
+
var sanitizedHtml = sanitizeHtml(text);
|
|
8254
|
+
return require$$0.jsx("span", { dangerouslySetInnerHTML: { __html: sanitizedHtml } });
|
|
8255
|
+
}
|
|
8256
|
+
// Otherwise, render as-is (handles JSX and plain text)
|
|
8257
|
+
return text;
|
|
8258
|
+
}
|
|
8143
8259
|
var refreshButtonAriaLabel = "To refresh chat click on clockwise gapped circle arrow icon in top right side of widget. ";
|
|
8144
8260
|
var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top right side of widget. ";
|
|
8145
8261
|
var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
|
|
8146
8262
|
var ChatHeader = function (props) {
|
|
8147
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
8263
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
8148
8264
|
var innerDispatch = useChatDispatch();
|
|
8149
8265
|
var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
|
|
8150
|
-
var
|
|
8266
|
+
var _r = require$$1.useState(false), drawerOpen = _r[0], setDrawerState = _r[1]; // false initially
|
|
8151
8267
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
8152
8268
|
var showMenuLeft = menuPosition === "HEADER_LEFT";
|
|
8153
8269
|
var showMenuRight = menuPosition === "HEADER_RIGHT";
|
|
8154
8270
|
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items;
|
|
8155
8271
|
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex;
|
|
8156
8272
|
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex;
|
|
8157
|
-
var menuItems =
|
|
8273
|
+
var menuItems = require$$1.useMemo(function () { return (menuItemsRaw ? menuItemsRaw : []); }, [menuItemsRaw]);
|
|
8158
8274
|
// Check if we have a right-side menu
|
|
8159
8275
|
var hasRightMenu = showMenuRight && menuItems.length > 0;
|
|
8160
8276
|
function toggleDrawer() {
|
|
@@ -8179,55 +8295,35 @@ var ChatHeader = function (props) {
|
|
|
8179
8295
|
if (canCancel) {
|
|
8180
8296
|
ariaLabel = "".concat(ariaLabel).concat(closeButtonAriaLabel);
|
|
8181
8297
|
}
|
|
8182
|
-
return (
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
React$1.createElement("div", { className: "\n ".concat("status-text", "\n ").concat(showMenuLeft && menuItems.length
|
|
8190
|
-
? "status-text-positionWithMenu"
|
|
8191
|
-
: ((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined
|
|
8192
|
-
? "status-text-positionLeftNoAvatar"
|
|
8193
|
-
: "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter)
|
|
8194
|
-
? "status-text-positionCenter"
|
|
8195
|
-
: "", " \n ") },
|
|
8196
|
-
React$1.createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status)),
|
|
8197
|
-
((_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 : ""))),
|
|
8198
|
-
React$1.createElement(ButtonGroup, null,
|
|
8199
|
-
hasRightMenu && (React$1.createElement(MenuButton, { onClick: toggleDrawer, tabIndex: menuButtonTabIndex })),
|
|
8200
|
-
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 })),
|
|
8201
|
-
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 })),
|
|
8202
|
-
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 })))),
|
|
8203
|
-
drawerOpen ? (React$1.createElement("div", { className: "xa-chat-menu-container" },
|
|
8204
|
-
React$1.createElement(ChatMenu, { openFrom: showMenuRight ? "right" : "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }))) : (React$1.createElement(React$1.Fragment, null))));
|
|
8298
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "status-container background-header", "aria-label": ariaLabel, "aria-hidden": false, children: [showMenuLeft && menuItems.length ? (require$$0.jsx(require$$0.Fragment, { children: require$$0.jsx("div", { className: "chat-footer__menu-icon", children: require$$0.jsx(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }) }) })) : (require$$0.jsx(require$$0.Fragment, {})), ((_b = props === null || props === void 0 ? void 0 : props.agent) === null || _b === void 0 ? void 0 : _b.avatarPath) === undefined ? (require$$0.jsx("div", {})) : (require$$0.jsx("div", { className: "status-container__avatar", children: require$$0.jsx(Avatar, { entity: props.agent }) })), require$$0.jsxs("div", { className: "\n ".concat("status-text", "\n ").concat(showMenuLeft && menuItems.length
|
|
8299
|
+
? "status-text-positionWithMenu"
|
|
8300
|
+
: ((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined
|
|
8301
|
+
? "status-text-positionLeftNoAvatar"
|
|
8302
|
+
: "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter)
|
|
8303
|
+
? "status-text-positionCenter"
|
|
8304
|
+
: "", " \n "), children: [require$$0.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) && (require$$0.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) }))] }), require$$0.jsxs(ButtonGroup, { children: [hasRightMenu && (require$$0.jsx(MenuButton, { onClick: toggleDrawer, tabIndex: menuButtonTabIndex })), props.canRefresh && (require$$0.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 && (require$$0.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 && (require$$0.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 ? (require$$0.jsx("div", { className: "xa-chat-menu-container", children: require$$0.jsx(ChatMenu, { openFrom: showMenuRight ? "right" : "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) })) : (require$$0.jsx(require$$0.Fragment, {}))] }));
|
|
8205
8305
|
};
|
|
8206
8306
|
|
|
8207
|
-
var UnknownMessage = function () { return
|
|
8307
|
+
var UnknownMessage = function () { return require$$0.jsx(require$$0.Fragment, {}); };
|
|
8208
8308
|
|
|
8209
8309
|
function renderAvatar(entity) {
|
|
8210
|
-
return (
|
|
8211
|
-
React$1.createElement(Avatar, { entity: entity })));
|
|
8310
|
+
return (require$$0.jsx("div", { className: "xappw-chat-msg-part__avatar", children: require$$0.jsx(Avatar, { entity: entity }) }));
|
|
8212
8311
|
}
|
|
8213
8312
|
var ChatMessagePart = function (props) {
|
|
8214
8313
|
var _a;
|
|
8215
8314
|
var position = (_a = props.avatarPosition) !== null && _a !== void 0 ? _a : "left";
|
|
8216
8315
|
var containerClass = "xappw-chat-msg-part" +
|
|
8217
|
-
(position === "below" ? " xappw-chat-msg-part--avatar-below" : "")
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
props.showAvatar && (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar-wrapper" },
|
|
8224
|
-
renderAvatar(user),
|
|
8225
|
-
(user === null || user === void 0 ? void 0 : user.displayName) && (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar-name" }, user.displayName))))))));
|
|
8316
|
+
(position === "below" ? " xappw-chat-msg-part--avatar-below" : "") +
|
|
8317
|
+
(position === "bottom" ? " xappw-chat-msg-part--avatar-bottom" : "");
|
|
8318
|
+
var user = props.user, hideUserInfo = props.hideUserInfo;
|
|
8319
|
+
// Hide user info if hideUserInfo is true and position is "bottom"
|
|
8320
|
+
var shouldHideUserInfo = hideUserInfo && position === "bottom";
|
|
8321
|
+
return (require$$0.jsx("div", { className: containerClass, children: position === "left" ? (require$$0.jsxs(require$$0.Fragment, { children: [props.showAvatar && renderAvatar(user), props.children] })) : (require$$0.jsxs(require$$0.Fragment, { children: [props.children, props.showAvatar && !shouldHideUserInfo && (require$$0.jsxs("div", { className: "xappw-chat-msg-part__avatar-wrapper", children: [renderAvatar(user), (user === null || user === void 0 ? void 0 : user.displayName) && (require$$0.jsx("div", { className: "xappw-chat-msg-part__avatar-name", children: user.displayName }))] }))] })) }));
|
|
8226
8322
|
};
|
|
8227
8323
|
|
|
8228
8324
|
function useExecuteActionCallback() {
|
|
8229
8325
|
var dispatch = useChatServerDispatch();
|
|
8230
|
-
return
|
|
8326
|
+
return require$$1.useCallback(function (text, meta) {
|
|
8231
8327
|
dispatch(executeAction(text, meta));
|
|
8232
8328
|
}, [dispatch]);
|
|
8233
8329
|
}
|
|
@@ -8237,7 +8333,7 @@ function useButtonCallback() {
|
|
|
8237
8333
|
var chatDispatch = useChatDispatch();
|
|
8238
8334
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8239
8335
|
var executeAction = useExecuteActionCallback();
|
|
8240
|
-
return
|
|
8336
|
+
return require$$1.useCallback(function (button) {
|
|
8241
8337
|
if (button.actionUrl) {
|
|
8242
8338
|
handleOpenUrl(button.actionUrl, chatDispatch, visuals);
|
|
8243
8339
|
}
|
|
@@ -8270,17 +8366,15 @@ function isList(display) {
|
|
|
8270
8366
|
|
|
8271
8367
|
var CardMiddlewareWidget = function (props) {
|
|
8272
8368
|
var msg = props.msg, ctx = props.ctx;
|
|
8273
|
-
var card =
|
|
8369
|
+
var card = require$$1.useMemo(function () { return convertFromCardDisplay(msg); }, [msg]);
|
|
8274
8370
|
var user = ctx.user;
|
|
8275
8371
|
var handleButton = useButtonCallback();
|
|
8276
|
-
return (
|
|
8277
|
-
React$1.createElement("div", { className: "chat-msg" },
|
|
8278
|
-
React$1.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
|
|
8372
|
+
return (require$$0.jsx(ChatMessagePart, { showAvatar: true, user: user, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx(ChatCard, { card: card, onButtonClick: handleButton }) }) }));
|
|
8279
8373
|
};
|
|
8280
8374
|
var CardMiddleware = function (next) { return function (props) {
|
|
8281
8375
|
var msg = props.msg, ctx = props.ctx;
|
|
8282
8376
|
if (isCard(msg)) {
|
|
8283
|
-
return
|
|
8377
|
+
return require$$0.jsx(CardMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
8284
8378
|
}
|
|
8285
8379
|
return next(props);
|
|
8286
8380
|
}; };
|
|
@@ -8322,9 +8416,9 @@ function createSubscribableArray(originalValue) {
|
|
|
8322
8416
|
};
|
|
8323
8417
|
}
|
|
8324
8418
|
function useSubscribableArray(array) {
|
|
8325
|
-
var _a =
|
|
8419
|
+
var _a = require$$1.useState(array.getArray()), res = _a[0], setRes = _a[1];
|
|
8326
8420
|
var mounted = useIsMounted();
|
|
8327
|
-
|
|
8421
|
+
require$$1.useEffect(function () {
|
|
8328
8422
|
var subscription = array.subscribe(function (newVal) {
|
|
8329
8423
|
if (mounted()) {
|
|
8330
8424
|
setRes(newVal);
|
|
@@ -8356,7 +8450,7 @@ function useGlobalSubscribableArray(storage) {
|
|
|
8356
8450
|
}
|
|
8357
8451
|
function useLateMiddlewaresBuilder(storage) {
|
|
8358
8452
|
var middlewares = useGlobalSubscribableArray(storage);
|
|
8359
|
-
return
|
|
8453
|
+
return require$$1.useMemo(function () { return joinMiddlewares(middlewares); }, [middlewares]);
|
|
8360
8454
|
}
|
|
8361
8455
|
var storage = createStorage(globalThis, "xappMsgMiddlewares");
|
|
8362
8456
|
function useLateMiddleware() {
|
|
@@ -8364,16 +8458,14 @@ function useLateMiddleware() {
|
|
|
8364
8458
|
}
|
|
8365
8459
|
|
|
8366
8460
|
function getSvg() {
|
|
8367
|
-
return (
|
|
8368
|
-
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" }),
|
|
8369
|
-
React$1.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
|
|
8461
|
+
return (require$$0.jsxs("svg", { viewBox: "0 0 20 20", children: [require$$0.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" }), require$$0.jsx("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })] }));
|
|
8370
8462
|
}
|
|
8371
8463
|
var ExternalLink = function (props) {
|
|
8372
8464
|
var url = props.url;
|
|
8373
|
-
var handleClick =
|
|
8465
|
+
var handleClick = require$$1.useCallback(function (ev) {
|
|
8374
8466
|
ev.preventDefault();
|
|
8375
8467
|
}, []);
|
|
8376
|
-
return (
|
|
8468
|
+
return (require$$0.jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick, children: getSvg() }));
|
|
8377
8469
|
};
|
|
8378
8470
|
|
|
8379
8471
|
function firstIndex(val, patterns) {
|
|
@@ -8483,10 +8575,10 @@ function reduceLink(url, maxLength) {
|
|
|
8483
8575
|
|
|
8484
8576
|
var SmartLink = function (props) {
|
|
8485
8577
|
var url = props.url, className = props.className;
|
|
8486
|
-
var handleClick =
|
|
8578
|
+
var handleClick = require$$1.useCallback(function (ev) {
|
|
8487
8579
|
ev.preventDefault();
|
|
8488
8580
|
}, []);
|
|
8489
|
-
return (
|
|
8581
|
+
return (require$$0.jsx("a", { href: url, "aria-label": "read more", target: "_blank", rel: "noreferrer", className: className, onClick: handleClick, children: reduceLink(url, 40) }));
|
|
8490
8582
|
};
|
|
8491
8583
|
|
|
8492
8584
|
var ListItem = function (props) {
|
|
@@ -8494,33 +8586,18 @@ var ListItem = function (props) {
|
|
|
8494
8586
|
var item = props.item;
|
|
8495
8587
|
var layout = props.layout || "normal";
|
|
8496
8588
|
var url = item.url || item.imageActionUrl;
|
|
8497
|
-
return (
|
|
8498
|
-
React$1.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout) },
|
|
8499
|
-
React$1.createElement("div", { className: "xappw-vlist-item__description" },
|
|
8500
|
-
item.title && React$1.createElement("div", { className: "xappw-vlist-item__title" },
|
|
8501
|
-
React$1.createElement("span", null, item.title)),
|
|
8502
|
-
url && React$1.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
|
|
8503
|
-
item.subTitle && React$1.createElement("div", { className: "xappw-vlist-item__subtitle" },
|
|
8504
|
-
React$1.createElement("span", null, item.subTitle)),
|
|
8505
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
|
|
8506
|
-
React$1.createElement("div", { className: "xappw-vlist-item__side" },
|
|
8507
|
-
url && React$1.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
|
|
8508
|
-
React$1.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
|
|
8589
|
+
return (require$$0.jsx(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl, children: require$$0.jsxs("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout), children: [require$$0.jsxs("div", { className: "xappw-vlist-item__description", children: [item.title && (require$$0.jsx("div", { className: "xappw-vlist-item__title", children: require$$0.jsx("span", { children: item.title }) })), url && require$$0.jsx(SmartLink, { url: url, className: "xappw-vlist-item__link" }), item.subTitle && (require$$0.jsx("div", { className: "xappw-vlist-item__subtitle", children: require$$0.jsx("span", { children: item.subTitle }) })), !!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && (require$$0.jsx(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick }))] }), require$$0.jsxs("div", { className: "xappw-vlist-item__side", children: [url && require$$0.jsx(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }), require$$0.jsx(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })] })] }) }));
|
|
8509
8590
|
};
|
|
8510
8591
|
|
|
8511
8592
|
var List = function (props) {
|
|
8512
8593
|
var list = props.list;
|
|
8513
|
-
var listRef =
|
|
8594
|
+
var listRef = require$$1.useRef(null);
|
|
8514
8595
|
var hasImage = list.items.some(function (item) { return item.imageUrl; });
|
|
8515
8596
|
var titlesOnly = !list.items.some(function (item) { var _a; return item.subTitle || ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length); });
|
|
8516
8597
|
var listItems = list.items.map(function (item, itemIndex) {
|
|
8517
|
-
return (
|
|
8518
|
-
React$1.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
8598
|
+
return (require$$0.jsx("div", { className: "xappw-vlist-container__item", children: require$$0.jsx(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl }) }, "item-key-".concat(itemIndex)));
|
|
8519
8599
|
});
|
|
8520
|
-
return (
|
|
8521
|
-
React$1.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
|
|
8522
|
-
props.list.title && React$1.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
|
|
8523
|
-
listItems)));
|
|
8600
|
+
return (require$$0.jsx("div", { className: "xappw-vlist", children: require$$0.jsxs("div", { ref: listRef, className: "xappw-vlist-container", children: [props.list.title && require$$0.jsx("div", { className: "xappw-vlist__header", children: props.list.title }), listItems] }) }));
|
|
8524
8601
|
};
|
|
8525
8602
|
|
|
8526
8603
|
var ListMiddlewareWidget = function (props) {
|
|
@@ -8528,38 +8605,31 @@ var ListMiddlewareWidget = function (props) {
|
|
|
8528
8605
|
if (!ctx) {
|
|
8529
8606
|
throw new TypeError("ctx not provided to ".concat(ListMiddlewareWidget.name));
|
|
8530
8607
|
}
|
|
8531
|
-
var list =
|
|
8608
|
+
var list = require$$1.useMemo(function () { return convertFromListDisplay(msg); }, [msg]);
|
|
8532
8609
|
var executeActionCallback = useExecuteActionCallback();
|
|
8533
|
-
var handleExecute =
|
|
8610
|
+
var handleExecute = require$$1.useCallback(function (ui, text, token) {
|
|
8534
8611
|
executeActionCallback(text, { token: token, action: "click", ui: ui });
|
|
8535
8612
|
}, [executeActionCallback]);
|
|
8536
8613
|
var handleButton = useButtonCallback();
|
|
8537
8614
|
var user = ctx.user;
|
|
8538
|
-
return (
|
|
8539
|
-
list.type === "CAROUSEL" && (React$1.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
|
|
8540
|
-
React$1.createElement(Carousel, { list: list, onExecute: handleExecute.bind(null, "carousel"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))),
|
|
8541
|
-
list.type === "LIST" && (React$1.createElement("div", { className: "chat-msg chat-msg--expand" },
|
|
8542
|
-
React$1.createElement(List, { list: list, onExecute: handleExecute.bind(null, "list"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl })))));
|
|
8615
|
+
return (require$$0.jsxs(ChatMessagePart, { showAvatar: false, user: user, children: [list.type === "CAROUSEL" && (require$$0.jsx("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava", children: require$$0.jsx(Carousel, { list: list, onExecute: handleExecute.bind(null, "carousel"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }) })), list.type === "LIST" && (require$$0.jsx("div", { className: "chat-msg chat-msg--expand", children: require$$0.jsx(List, { list: list, onExecute: handleExecute.bind(null, "list"), onButtonClick: handleButton, onOpenUrl: ctx.openUrl }) }))] }));
|
|
8543
8616
|
};
|
|
8544
8617
|
var ListMiddleware = function (next) { return function (props) {
|
|
8545
8618
|
var msg = props.msg, ctx = props.ctx;
|
|
8546
8619
|
if (isList(msg)) {
|
|
8547
|
-
return
|
|
8620
|
+
return require$$0.jsx(ListMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
8548
8621
|
}
|
|
8549
8622
|
return next(props);
|
|
8550
8623
|
}; };
|
|
8551
8624
|
|
|
8552
8625
|
var MultiSelect = function (props) {
|
|
8553
8626
|
var items = props.items, checked = props.checked, onChange = props.onChange;
|
|
8554
|
-
var handleToggle =
|
|
8627
|
+
var handleToggle = require$$1.useCallback(function (ev) {
|
|
8555
8628
|
var _a;
|
|
8556
8629
|
var id = ev.target.value;
|
|
8557
8630
|
onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
|
|
8558
8631
|
}, [checked, onChange]);
|
|
8559
|
-
return (
|
|
8560
|
-
React$1.createElement("label", null,
|
|
8561
|
-
React$1.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
|
|
8562
|
-
React$1.createElement("span", null, item.title)))); })));
|
|
8632
|
+
return (require$$0.jsx("ul", { className: "xappw-multiselect", children: items === null || items === void 0 ? void 0 : items.map(function (item) { return (require$$0.jsx("li", { children: require$$0.jsxs("label", { children: [require$$0.jsx("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }), require$$0.jsx("span", { children: item.title })] }) }, item.id)); }) }));
|
|
8563
8633
|
};
|
|
8564
8634
|
|
|
8565
8635
|
function isMultiSelect(display) {
|
|
@@ -8570,29 +8640,25 @@ function convertToMultiSelectItems(display) {
|
|
|
8570
8640
|
}
|
|
8571
8641
|
var MultiSelectMiddlewareWidget = function (props) {
|
|
8572
8642
|
var msg = props.msg, ctx = props.ctx;
|
|
8573
|
-
var items =
|
|
8643
|
+
var items = require$$1.useMemo(function () { return convertToMultiSelectItems(msg); }, [msg]);
|
|
8574
8644
|
var user = ctx.user;
|
|
8575
|
-
var _a =
|
|
8576
|
-
var handleSubmit =
|
|
8645
|
+
var _a = require$$1.useState({}), checked = _a[0], setChecked = _a[1];
|
|
8646
|
+
var handleSubmit = require$$1.useCallback(function () {
|
|
8577
8647
|
ctx.send({
|
|
8578
8648
|
type: "custom",
|
|
8579
8649
|
payload: JSON.stringify({
|
|
8580
8650
|
type: "OPTION_SELECT_REQUEST",
|
|
8581
8651
|
intentId: "OptionSelect",
|
|
8582
|
-
selected: Object.keys(checked).map(function (k) { return ({ id: k }); })
|
|
8583
|
-
})
|
|
8652
|
+
selected: Object.keys(checked).map(function (k) { return ({ id: k }); }),
|
|
8653
|
+
}),
|
|
8584
8654
|
});
|
|
8585
8655
|
}, [ctx, checked]);
|
|
8586
|
-
return (
|
|
8587
|
-
React$1.createElement("div", { className: "chat-msg" },
|
|
8588
|
-
React$1.createElement("div", null,
|
|
8589
|
-
React$1.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
|
|
8590
|
-
React$1.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
|
|
8656
|
+
return (require$$0.jsx(ChatMessagePart, { showAvatar: true, user: user, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsxs("div", { children: [require$$0.jsx(MultiSelect, { items: items, checked: checked, onChange: setChecked }), require$$0.jsx(ActionButton, { label: "Submit", onClick: handleSubmit })] }) }) }));
|
|
8591
8657
|
};
|
|
8592
8658
|
var MultiSelectMiddleware = function (next) { return function (props) {
|
|
8593
8659
|
var msg = props.msg, ctx = props.ctx;
|
|
8594
8660
|
if (isMultiSelect(msg)) {
|
|
8595
|
-
return
|
|
8661
|
+
return require$$0.jsx(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
8596
8662
|
}
|
|
8597
8663
|
return next(props);
|
|
8598
8664
|
}; };
|
|
@@ -8604,14 +8670,14 @@ var StandardMiddlewaresBuilder = joinMiddlewares([
|
|
|
8604
8670
|
]);
|
|
8605
8671
|
function useStandardMiddlewareBuilder() {
|
|
8606
8672
|
var lateMiddleware = useLateMiddleware();
|
|
8607
|
-
return
|
|
8673
|
+
return require$$1.useMemo(function () { return joinMiddlewares([
|
|
8608
8674
|
lateMiddleware,
|
|
8609
8675
|
StandardMiddlewaresBuilder,
|
|
8610
8676
|
]); }, [lateMiddleware]);
|
|
8611
8677
|
}
|
|
8612
8678
|
function useStandardMiddleware() {
|
|
8613
8679
|
var builder = useStandardMiddlewareBuilder();
|
|
8614
|
-
return
|
|
8680
|
+
return require$$1.useMemo(function () { return builder(UnknownMessage); }, [builder]);
|
|
8615
8681
|
}
|
|
8616
8682
|
var StandardMiddlewares = StandardMiddlewaresBuilder(UnknownMessage);
|
|
8617
8683
|
|
|
@@ -8622,36 +8688,33 @@ function getTailSvgPath(owner) {
|
|
|
8622
8688
|
return "m 0 0 v 240 h 60 c -40 -40 -60 -160 -60 -240";
|
|
8623
8689
|
}
|
|
8624
8690
|
function getTailSvg(owner) {
|
|
8625
|
-
return (
|
|
8626
|
-
React$1.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
|
|
8691
|
+
return (require$$0.jsx("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240", children: require$$0.jsx("path", { d: getTailSvgPath(owner), fill: "currentColor" }) }));
|
|
8627
8692
|
}
|
|
8628
8693
|
var ChatMessageBubble = function (props) {
|
|
8629
8694
|
var owner = props.owner, onClick = props.onClick;
|
|
8630
|
-
var handleClick =
|
|
8695
|
+
var handleClick = require$$1.useCallback(function () {
|
|
8631
8696
|
if (onClick) {
|
|
8632
8697
|
onClick();
|
|
8633
8698
|
}
|
|
8634
8699
|
}, [onClick]);
|
|
8635
|
-
return (
|
|
8636
|
-
(props.hasTail) && getTailSvg(owner),
|
|
8637
|
-
props.children));
|
|
8700
|
+
return (require$$0.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] }));
|
|
8638
8701
|
};
|
|
8639
8702
|
|
|
8640
8703
|
var ChatMarkdownMessage = function (props) {
|
|
8641
8704
|
var onOpenUrl = props.onOpenUrl;
|
|
8642
8705
|
var agentMessage = isAgent(props.message.user.nick);
|
|
8643
|
-
var ref =
|
|
8706
|
+
var ref = require$$1.useRef(null);
|
|
8644
8707
|
var chatDispatch = useChatDispatch();
|
|
8645
8708
|
var visuals = reactRedux.useSelector(function (state) { return state.visuals; });
|
|
8646
8709
|
var html = props.message.msg.html;
|
|
8647
|
-
var handleLinkClick =
|
|
8710
|
+
var handleLinkClick = require$$1.useCallback(function (ev) {
|
|
8648
8711
|
if (onOpenUrl) {
|
|
8649
8712
|
var link = ev.target;
|
|
8650
8713
|
ev.preventDefault();
|
|
8651
8714
|
onOpenUrl(link.href, chatDispatch, visuals);
|
|
8652
8715
|
}
|
|
8653
8716
|
}, [onOpenUrl]);
|
|
8654
|
-
|
|
8717
|
+
require$$1.useEffect(function () {
|
|
8655
8718
|
if (ref.current) {
|
|
8656
8719
|
ref.current.innerHTML = html;
|
|
8657
8720
|
if (onOpenUrl) {
|
|
@@ -8668,11 +8731,7 @@ var ChatMarkdownMessage = function (props) {
|
|
|
8668
8731
|
}
|
|
8669
8732
|
return undefined;
|
|
8670
8733
|
}, [ref, html, onOpenUrl, handleLinkClick]);
|
|
8671
|
-
return (
|
|
8672
|
-
React$1.createElement("div", { className: "chat-text-container" },
|
|
8673
|
-
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
8674
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + (agentMessage ? " the bot said" : " the user said")),
|
|
8675
|
-
React$1.createElement("div", { ref: ref })))));
|
|
8734
|
+
return (require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx("div", { className: "chat-text-container", children: require$$0.jsxs(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling, children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + (agentMessage ? " the bot said" : " the user said") }), require$$0.jsx("div", { ref: ref })] }) }) }));
|
|
8676
8735
|
};
|
|
8677
8736
|
|
|
8678
8737
|
var ChatPermissionMessage = function (props) {
|
|
@@ -8686,57 +8745,59 @@ var ChatPermissionMessage = function (props) {
|
|
|
8686
8745
|
var author = message.user;
|
|
8687
8746
|
var allowLabel = "Allow";
|
|
8688
8747
|
var denyLabel = "Deny";
|
|
8689
|
-
var writeAsAgent =
|
|
8748
|
+
var writeAsAgent = require$$1.useCallback(function (msg) {
|
|
8690
8749
|
ctx.write({
|
|
8691
8750
|
type: "msg",
|
|
8692
8751
|
user: author,
|
|
8693
|
-
msg: msg
|
|
8752
|
+
msg: msg,
|
|
8694
8753
|
});
|
|
8695
8754
|
}, [ctx, author]);
|
|
8696
|
-
var writeAsUser =
|
|
8755
|
+
var writeAsUser = require$$1.useCallback(function (msg) {
|
|
8697
8756
|
ctx.write({
|
|
8698
8757
|
type: "msg",
|
|
8699
8758
|
user: user,
|
|
8700
|
-
msg: msg
|
|
8759
|
+
msg: msg,
|
|
8701
8760
|
});
|
|
8702
8761
|
}, [ctx, user]);
|
|
8703
|
-
var handleFail =
|
|
8762
|
+
var handleFail = require$$1.useCallback(function () {
|
|
8704
8763
|
ctx.send({
|
|
8705
8764
|
type: "msg",
|
|
8706
8765
|
user: undefined,
|
|
8707
8766
|
msg: {
|
|
8708
|
-
text: denyLabel
|
|
8709
|
-
}
|
|
8767
|
+
text: denyLabel,
|
|
8768
|
+
},
|
|
8710
8769
|
});
|
|
8711
8770
|
}, [ctx]);
|
|
8712
|
-
var handleSend =
|
|
8771
|
+
var handleSend = require$$1.useCallback(function (msg) {
|
|
8713
8772
|
ctx.send({
|
|
8714
8773
|
type: "permissionGrant",
|
|
8715
8774
|
user: author,
|
|
8716
|
-
msg: msg
|
|
8775
|
+
msg: msg,
|
|
8717
8776
|
});
|
|
8718
8777
|
}, [author, ctx]);
|
|
8719
|
-
var handleResult =
|
|
8778
|
+
var handleResult = require$$1.useCallback(function (position, userMsg) {
|
|
8720
8779
|
handleSend({
|
|
8721
8780
|
text: userMsg,
|
|
8722
|
-
location: position
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8781
|
+
location: position
|
|
8782
|
+
? {
|
|
8783
|
+
latitude: position.coords.latitude,
|
|
8784
|
+
longitude: position.coords.longitude,
|
|
8785
|
+
}
|
|
8786
|
+
: undefined,
|
|
8787
|
+
permissionRequest: permissionRequest,
|
|
8727
8788
|
});
|
|
8728
8789
|
writeAsUser({
|
|
8729
|
-
text: userMsg
|
|
8790
|
+
text: userMsg,
|
|
8730
8791
|
});
|
|
8731
8792
|
var agentMsg = position ? permissionRequest === null || permissionRequest === void 0 ? void 0 : permissionRequest.approve : permissionRequest === null || permissionRequest === void 0 ? void 0 : permissionRequest.deny;
|
|
8732
8793
|
if (agentMsg) {
|
|
8733
8794
|
writeAsAgent(agentMsg);
|
|
8734
8795
|
}
|
|
8735
8796
|
}, [permissionRequest, writeAsUser, writeAsAgent, handleSend]);
|
|
8736
|
-
var handleDeny =
|
|
8797
|
+
var handleDeny = require$$1.useCallback(function (label) {
|
|
8737
8798
|
handleResult(undefined, label);
|
|
8738
8799
|
}, [handleResult]);
|
|
8739
|
-
var handleAllow =
|
|
8800
|
+
var handleAllow = require$$1.useCallback(function (label) {
|
|
8740
8801
|
if (navigator.geolocation) {
|
|
8741
8802
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
8742
8803
|
handleResult(position, label);
|
|
@@ -8746,25 +8807,17 @@ var ChatPermissionMessage = function (props) {
|
|
|
8746
8807
|
}
|
|
8747
8808
|
}, [handleFail, handleResult]);
|
|
8748
8809
|
if (!permissionRequest) {
|
|
8749
|
-
return
|
|
8810
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
8750
8811
|
}
|
|
8751
|
-
return (
|
|
8752
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + (agentMessage ? " the bot said" : " the user said")),
|
|
8753
|
-
React$1.createElement("div", { className: "buttons-container" },
|
|
8754
|
-
React$1.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
|
|
8755
|
-
React$1.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
|
|
8812
|
+
return (require$$0.jsxs("div", { className: "chat-msg", children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + (agentMessage ? " the bot said" : " the user said") }), require$$0.jsxs("div", { className: "buttons-container", children: [require$$0.jsx(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }), require$$0.jsx(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny })] })] }));
|
|
8756
8813
|
};
|
|
8757
8814
|
|
|
8758
8815
|
var ChatTextMessage = function (props) {
|
|
8759
8816
|
var message = props.message;
|
|
8760
8817
|
var date = new Date(message.timestamp);
|
|
8761
|
-
var time = date.getHours() +
|
|
8818
|
+
var time = date.getHours() + ":" + date.getMinutes();
|
|
8762
8819
|
var agentMessage = isAgent(props.message.user.nick);
|
|
8763
|
-
return (
|
|
8764
|
-
React$1.createElement("div", { className: "chat-text-container" },
|
|
8765
|
-
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
8766
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + time + (agentMessage ? " the bot said" : " the user said")),
|
|
8767
|
-
React$1.createElement("span", null, message.msg.text)))));
|
|
8820
|
+
return (require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx("div", { className: "chat-text-container", children: require$$0.jsxs(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling, children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + (agentMessage ? " the bot said" : " the user said") }), require$$0.jsx("span", { children: message.msg.text })] }) }) }));
|
|
8768
8821
|
};
|
|
8769
8822
|
|
|
8770
8823
|
var ChatScheduleWidget = function (props) {
|
|
@@ -8775,10 +8828,7 @@ var ChatScheduleWidget = function (props) {
|
|
|
8775
8828
|
function handleClick() {
|
|
8776
8829
|
openUrl(scheduleWidgetUrl, chatDispatch, visuals);
|
|
8777
8830
|
}
|
|
8778
|
-
return (
|
|
8779
|
-
React$1.createElement("button", { className: "chat-schedule-button", onClick: handleClick },
|
|
8780
|
-
React$1.createElement("i", { className: "fa fa-lg fa-calendar" }),
|
|
8781
|
-
React$1.createElement("span", null, display.label || "Schedule Now!"))));
|
|
8831
|
+
return (require$$0.jsx("div", { className: "chat-schedule-button-container", children: require$$0.jsxs("button", { className: "chat-schedule-button", onClick: handleClick, children: [require$$0.jsx("i", { className: "fa fa-lg fa-calendar" }), require$$0.jsx("span", { children: display.label || "Schedule Now!" })] }) }));
|
|
8782
8832
|
};
|
|
8783
8833
|
|
|
8784
8834
|
function getClassName(msg) {
|
|
@@ -8792,13 +8842,17 @@ var avaKeys = ["text", "html", "card", "list"];
|
|
|
8792
8842
|
* @returns
|
|
8793
8843
|
*/
|
|
8794
8844
|
var ChatMessage = function (props) {
|
|
8845
|
+
var _a;
|
|
8795
8846
|
var middleware = props.messageMiddleware || StandardMiddlewares;
|
|
8796
|
-
var chatConfig =
|
|
8847
|
+
var chatConfig = require$$1.useContext(ChatConfigContext);
|
|
8797
8848
|
// console.log(`########### chatConfig: ${JSON.stringify(chatConfig, null, 2)}`);
|
|
8798
8849
|
var ctx = props.middlewareContext;
|
|
8799
8850
|
var user = props.agent;
|
|
8851
|
+
// Get hideUserInfo from the agent info based on the message sender's nick
|
|
8852
|
+
var agentInfo = (_a = props.agents) === null || _a === void 0 ? void 0 : _a[props.message.user.nick];
|
|
8853
|
+
var hideUserInfo = (agentInfo === null || agentInfo === void 0 ? void 0 : agentInfo.hideUserInfo) || false;
|
|
8800
8854
|
function renderByType() {
|
|
8801
|
-
var _a;
|
|
8855
|
+
var _a, _b, _c, _d;
|
|
8802
8856
|
var msg = props.message.msg;
|
|
8803
8857
|
switch (props.message.type) {
|
|
8804
8858
|
// TODO: props actually requires it to be "chat.msg". Fix prop typing?
|
|
@@ -8806,38 +8860,27 @@ var ChatMessage = function (props) {
|
|
|
8806
8860
|
// Here is the deal. If we have text (output speech), then text - card - list - options
|
|
8807
8861
|
// OR card OR list only. Avatar with text bubble.
|
|
8808
8862
|
var avaKey = avaKeys.find(function (key) { return !!msg[key]; });
|
|
8809
|
-
return (
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
}
|
|
8820
|
-
var Middleware = middleware;
|
|
8821
|
-
return (React$1.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext }));
|
|
8822
|
-
}),
|
|
8823
|
-
msg.permissionRequest && ctx &&
|
|
8824
|
-
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user, avatarPosition: chatConfig.env.theme.messages.avatarPosition },
|
|
8825
|
-
React$1.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: ctx }))));
|
|
8863
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [msg.text &&
|
|
8864
|
+
require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "text", user: user, avatarPosition: (_a = chatConfig.env.theme.messages) === null || _a === void 0 ? void 0 : _a.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.jsx(ChatTextMessage, { message: props.message, sibling: props.sibling }) }), msg.html &&
|
|
8865
|
+
require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "html", user: user, avatarPosition: (_b = chatConfig.env.theme.messages) === null || _b === void 0 ? void 0 : _b.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.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) {
|
|
8866
|
+
if (display.type === "ScheduleButton") {
|
|
8867
|
+
return (require$$0.jsx(ChatScheduleWidget, { minimizeOnClick: props.minimizeOnClick, display: display }));
|
|
8868
|
+
}
|
|
8869
|
+
var Middleware = middleware;
|
|
8870
|
+
return (require$$0.jsx(Middleware, { msg: display, ctx: props.middlewareContext }, index));
|
|
8871
|
+
}), msg.permissionRequest && ctx &&
|
|
8872
|
+
require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user, avatarPosition: (_d = chatConfig.env.theme.messages) === null || _d === void 0 ? void 0 : _d.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.jsx(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: ctx }) })] }));
|
|
8826
8873
|
}
|
|
8827
|
-
return (
|
|
8874
|
+
return (require$$0.jsx(require$$0.Fragment, {}));
|
|
8828
8875
|
}
|
|
8829
8876
|
function renderTimestamp() {
|
|
8830
8877
|
var timestamp = props.message.timestamp;
|
|
8831
8878
|
var ts = new Date(timestamp);
|
|
8832
8879
|
var timeAgo = getTimeAgo(ts);
|
|
8833
|
-
return (
|
|
8834
|
-
React$1.createElement("span", null, timeAgo)));
|
|
8880
|
+
return (require$$0.jsx("div", { className: "chat-msg-timestamp ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor"), children: require$$0.jsx("span", { children: timeAgo }) }));
|
|
8835
8881
|
}
|
|
8836
8882
|
// empty
|
|
8837
|
-
return (
|
|
8838
|
-
React$1.createElement("div", { className: "chat-msg-container ".concat(getClassName(props.message)) },
|
|
8839
|
-
renderByType(),
|
|
8840
|
-
renderTimestamp())));
|
|
8883
|
+
return (require$$0.jsx("div", { className: "chat-msg-container-wrapper ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor", " ").concat(props.sibling ? "sibling" : ""), children: require$$0.jsxs("div", { className: "chat-msg-container ".concat(getClassName(props.message)), children: [renderByType(), renderTimestamp()] }) }));
|
|
8841
8884
|
};
|
|
8842
8885
|
|
|
8843
8886
|
/**
|
|
@@ -8881,7 +8924,7 @@ function checkSessionExpiration(duration, lastMessageTimestamp, _lastTimestamp)
|
|
|
8881
8924
|
}
|
|
8882
8925
|
|
|
8883
8926
|
function useExternalScript(url) {
|
|
8884
|
-
|
|
8927
|
+
require$$1.useEffect(function () {
|
|
8885
8928
|
if (!url) {
|
|
8886
8929
|
return;
|
|
8887
8930
|
}
|
|
@@ -8923,7 +8966,7 @@ function useChatServerVisitorId() {
|
|
|
8923
8966
|
});
|
|
8924
8967
|
var visitorAccessToken = reactRedux.useSelector(function (state) { return state.accessToken; });
|
|
8925
8968
|
var attributes = reactRedux.useSelector(function (state) { return state.attributes; });
|
|
8926
|
-
return
|
|
8969
|
+
return require$$1.useMemo(function () { return ({
|
|
8927
8970
|
dispatch: dispatch,
|
|
8928
8971
|
visitorId: clientVisitorId,
|
|
8929
8972
|
accessToken: visitorAccessToken,
|
|
@@ -8934,11 +8977,11 @@ function useChatServerVisitorId() {
|
|
|
8934
8977
|
//send whenever server settings or visitor id changes
|
|
8935
8978
|
function useGreeting(active) {
|
|
8936
8979
|
var curr = useChatServerVisitorId();
|
|
8937
|
-
var snapshotRef =
|
|
8938
|
-
var ctx =
|
|
8980
|
+
var snapshotRef = require$$1.useRef(null);
|
|
8981
|
+
var ctx = require$$1.useContext(ChatConfigContext);
|
|
8939
8982
|
var isAdmin = ctx.env.isAdmin;
|
|
8940
8983
|
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
8941
|
-
|
|
8984
|
+
require$$1.useEffect(function () {
|
|
8942
8985
|
if (active) {
|
|
8943
8986
|
if (snapshotRef.current !== curr) {
|
|
8944
8987
|
snapshotRef.current = curr;
|
|
@@ -8983,18 +9026,18 @@ function norm(index, len) {
|
|
|
8983
9026
|
return (index + len) % len;
|
|
8984
9027
|
}
|
|
8985
9028
|
function useSuggestions(search, context) {
|
|
8986
|
-
var _a =
|
|
8987
|
-
var _b =
|
|
8988
|
-
var _c =
|
|
8989
|
-
var _d =
|
|
8990
|
-
|
|
9029
|
+
var _a = require$$1.useState(), suggestions = _a[0], setSuggestions = _a[1];
|
|
9030
|
+
var _b = require$$1.useState(-1), suggestionIndex = _b[0], setSuggestionIndex = _b[1];
|
|
9031
|
+
var _c = require$$1.useState(search), query = _c[0], setQuery = _c[1];
|
|
9032
|
+
var _d = require$$1.useState(context), contextState = _d[0], setContextState = _d[1];
|
|
9033
|
+
require$$1.useEffect(function () {
|
|
8991
9034
|
setQuery(search);
|
|
8992
9035
|
}, [search]);
|
|
8993
|
-
|
|
9036
|
+
require$$1.useEffect(function () {
|
|
8994
9037
|
setContextState(context);
|
|
8995
9038
|
}, [context]);
|
|
8996
|
-
var suggestionItem =
|
|
8997
|
-
var shift =
|
|
9039
|
+
var suggestionItem = require$$1.useMemo(function () { return suggestions ? findItemByIndex_1(suggestions, suggestionIndex) : undefined; }, [suggestions, suggestionIndex]);
|
|
9040
|
+
var shift = require$$1.useCallback(function (delta) {
|
|
8998
9041
|
if (suggestions) {
|
|
8999
9042
|
var len_1 = getItemsLength_1(suggestions);
|
|
9000
9043
|
setSuggestionIndex(function (index) { return norm(index + delta + ((index < 0 && delta <= 0) ? 1 : 0), len_1); });
|
|
@@ -9003,7 +9046,7 @@ function useSuggestions(search, context) {
|
|
|
9003
9046
|
setSuggestionIndex(-1);
|
|
9004
9047
|
}
|
|
9005
9048
|
}, [suggestions]);
|
|
9006
|
-
var execute =
|
|
9049
|
+
var execute = require$$1.useCallback(function (cmd) {
|
|
9007
9050
|
switch (cmd) {
|
|
9008
9051
|
case "prev":
|
|
9009
9052
|
shift(-1);
|
|
@@ -9020,7 +9063,7 @@ function useSuggestions(search, context) {
|
|
|
9020
9063
|
}, [shift]);
|
|
9021
9064
|
var suggestionsResponse = useSuggestionsFetch(query || "", contextState);
|
|
9022
9065
|
var suggestionsData = suggestionsResponse.state === "success" ? suggestionsResponse.data : undefined;
|
|
9023
|
-
var raw =
|
|
9066
|
+
var raw = require$$1.useMemo(function () {
|
|
9024
9067
|
return suggestionsData ?
|
|
9025
9068
|
parseSuggestionsResponse_1(suggestionsData, -1).map(function (suggestion) {
|
|
9026
9069
|
return {
|
|
@@ -9029,14 +9072,14 @@ function useSuggestions(search, context) {
|
|
|
9029
9072
|
};
|
|
9030
9073
|
}) : undefined;
|
|
9031
9074
|
}, [suggestionsData]);
|
|
9032
|
-
|
|
9075
|
+
require$$1.useEffect(function () {
|
|
9033
9076
|
var prev = suggestionItem;
|
|
9034
9077
|
setSuggestions(raw);
|
|
9035
9078
|
if (!prev || !raw) {
|
|
9036
9079
|
setSuggestionIndex(-1);
|
|
9037
9080
|
}
|
|
9038
9081
|
}, [raw, suggestionItem]);
|
|
9039
|
-
return
|
|
9082
|
+
return require$$1.useMemo(function () { return ({
|
|
9040
9083
|
suggestions: suggestions,
|
|
9041
9084
|
index: suggestionIndex,
|
|
9042
9085
|
execute: execute,
|
|
@@ -9046,11 +9089,11 @@ function useSuggestions(search, context) {
|
|
|
9046
9089
|
|
|
9047
9090
|
var AdminBar = function (_a) {
|
|
9048
9091
|
var onAdminJoin = _a.onAdminJoin;
|
|
9049
|
-
var name =
|
|
9092
|
+
var name = require$$1.useRef(null);
|
|
9050
9093
|
// We can manage this locally
|
|
9051
9094
|
// const hasAdminJoined = useSelector<ChatState, boolean | undefined>(state => state.hasAdminJoined);
|
|
9052
|
-
var _b =
|
|
9053
|
-
var _c =
|
|
9095
|
+
var _b = require$$1.useState(false), joined = _b[0], setJoined = _b[1];
|
|
9096
|
+
var _c = require$$1.useState(""), inputName = _c[0], setInputName = _c[1];
|
|
9054
9097
|
function handleInputChange(event) {
|
|
9055
9098
|
setInputName(event.target.value);
|
|
9056
9099
|
}
|
|
@@ -9072,18 +9115,12 @@ var AdminBar = function (_a) {
|
|
|
9072
9115
|
}
|
|
9073
9116
|
}
|
|
9074
9117
|
function renderJoin() {
|
|
9075
|
-
return (
|
|
9076
|
-
React$1.createElement("div", { className: "xappw-admin-input-form__buttons" },
|
|
9077
|
-
React$1.createElement(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Join", disable: disable })),
|
|
9078
|
-
React$1.createElement("div", { className: "xappw-admin-input" },
|
|
9079
|
-
React$1.createElement("input", { ref: name, id: "adminBarInput", placeholder: "Type your name here...", className: "xappw-admin-input__input", onChange: handleInputChange }))));
|
|
9118
|
+
return (require$$0.jsxs("form", { className: "xappw-admin-input-form", onSubmit: onSubmit, children: [require$$0.jsx("div", { className: "xappw-admin-input-form__buttons", children: require$$0.jsx(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Join", disable: disable }) }), require$$0.jsx("div", { className: "xappw-admin-input", children: require$$0.jsx("input", { ref: name, id: "adminBarInput", placeholder: "Type your name here...", className: "xappw-admin-input__input", onChange: handleInputChange }) })] }));
|
|
9080
9119
|
}
|
|
9081
9120
|
function renderLeave() {
|
|
9082
|
-
return (
|
|
9083
|
-
React$1.createElement("div", { className: "xappw-admin-input-form__buttons" },
|
|
9084
|
-
React$1.createElement(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Leave" }))));
|
|
9121
|
+
return (require$$0.jsx("form", { className: "xappw-admin-input-form", onSubmit: onSubmit, children: require$$0.jsx("div", { className: "xappw-admin-input-form__buttons", children: require$$0.jsx(ActionButton, { addClass: "xappw-admin-input-form__btn", type: "submit", label: "Leave" }) }) }));
|
|
9085
9122
|
}
|
|
9086
|
-
return (
|
|
9123
|
+
return (require$$0.jsx("div", { className: "xappw-admin-input-container visible", children: joined ? renderLeave() : renderJoin() }));
|
|
9087
9124
|
};
|
|
9088
9125
|
|
|
9089
9126
|
var classnames = {exports: {}};
|
|
@@ -9182,39 +9219,32 @@ var MarkdownBuilder = function (_a) {
|
|
|
9182
9219
|
var level = hashes.length;
|
|
9183
9220
|
return "<h".concat(level, ">").concat(headerText, "</h").concat(level, ">");
|
|
9184
9221
|
});
|
|
9185
|
-
return (
|
|
9222
|
+
return (require$$0.jsx("div", { className: containerClass, dangerouslySetInnerHTML: { __html: parsedText } }));
|
|
9186
9223
|
};
|
|
9187
9224
|
|
|
9188
9225
|
var ChatBranding = function (_a) {
|
|
9189
9226
|
var text = _a.text;
|
|
9190
9227
|
var regex = /\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/;
|
|
9191
9228
|
var match = text === null || text === void 0 ? void 0 : text.match(regex);
|
|
9192
|
-
return match ?
|
|
9193
|
-
:
|
|
9194
|
-
React$1.createElement("div", { className: "chat-footer__branding", style: { color: "white" } }, text);
|
|
9229
|
+
return match ? (require$$0.jsx(MarkdownBuilder, { text: text, applyBrandingClass: true, linkColor: "white" })) : (require$$0.jsx("div", { className: "chat-footer__branding", style: { color: "white" }, children: text }));
|
|
9195
9230
|
};
|
|
9196
9231
|
|
|
9197
9232
|
var CloseIcon = function () {
|
|
9198
9233
|
// Sergey, I added this style, you will probably want to change it to be more appropriate
|
|
9199
|
-
return (
|
|
9200
|
-
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" })));
|
|
9234
|
+
return (require$$0.jsx("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16", children: require$$0.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" }) }));
|
|
9201
9235
|
};
|
|
9202
9236
|
|
|
9203
9237
|
var LeftDownArrowIcon = function () {
|
|
9204
|
-
return (
|
|
9205
|
-
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" })));
|
|
9238
|
+
return (require$$0.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16", children: require$$0.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" }) }));
|
|
9206
9239
|
};
|
|
9207
9240
|
|
|
9208
9241
|
var SendIcon = function () {
|
|
9209
|
-
return (
|
|
9210
|
-
React$1.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
|
|
9211
|
-
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" }),
|
|
9212
|
-
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" }))));
|
|
9242
|
+
return (require$$0.jsx("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg", children: require$$0.jsxs("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none", children: [require$$0.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" }), require$$0.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" })] }) }));
|
|
9213
9243
|
};
|
|
9214
9244
|
|
|
9215
9245
|
var SendButton = function (props) {
|
|
9216
9246
|
var _a = props.disabled, disabled = _a === void 0 ? false : _a;
|
|
9217
|
-
var _b =
|
|
9247
|
+
var _b = require$$1.useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
9218
9248
|
// Determine which icon to show based on state
|
|
9219
9249
|
var getIconSrc = function () {
|
|
9220
9250
|
if (disabled && props.sendButtonIconDisabled) {
|
|
@@ -9225,14 +9255,13 @@ var SendButton = function (props) {
|
|
|
9225
9255
|
}
|
|
9226
9256
|
return props.sendButtonIcon;
|
|
9227
9257
|
};
|
|
9228
|
-
return (
|
|
9229
|
-
React$1.createElement("img", { src: getIconSrc(), alt: "Send button", draggable: false, className: "send-button-icon" })))));
|
|
9258
|
+
return (require$$0.jsx(require$$0.Fragment, { children: !props.sendButtonIcon ? (require$$0.jsx(IconButton_1, { className: "xappw-send-button ".concat(props.className || "", " ").concat(disabled ? 'disabled' : ''), tabIndex: props.tabIndex, onClick: disabled ? undefined : props.onClick, icon: SendIcon })) : (require$$0.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: require$$0.jsx("img", { src: getIconSrc(), alt: "Send button", draggable: false, className: "send-button-icon" }) })) }));
|
|
9230
9259
|
};
|
|
9231
9260
|
|
|
9232
9261
|
var Input = function (props) {
|
|
9233
9262
|
var _a, _b;
|
|
9234
9263
|
var value = props.value, placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, sendButtonIconHover = props.sendButtonIconHover, sendButtonIconDisabled = props.sendButtonIconDisabled, suggestion = props.suggestion, footerConfig = props.footerConfig, inputConfig = props.inputConfig, onChange = props.onChange, onSubmit = props.onSubmit, onSuggestionCommand = props.onSuggestionCommand;
|
|
9235
|
-
var _c =
|
|
9264
|
+
var _c = require$$1.useState(false), dragover = _c[0], setDragover = _c[1];
|
|
9236
9265
|
function onDragOver(event) {
|
|
9237
9266
|
setDragover(true);
|
|
9238
9267
|
event.preventDefault();
|
|
@@ -9245,17 +9274,17 @@ var Input = function (props) {
|
|
|
9245
9274
|
function onDragLeave() {
|
|
9246
9275
|
setDragover(false);
|
|
9247
9276
|
}
|
|
9248
|
-
var handleOnSubmit =
|
|
9277
|
+
var handleOnSubmit = require$$1.useCallback(function (event) {
|
|
9249
9278
|
event && event.preventDefault();
|
|
9250
9279
|
onSubmit(value); // send to the widget
|
|
9251
9280
|
}, [value, onSubmit]);
|
|
9252
|
-
var handleClear =
|
|
9281
|
+
var handleClear = require$$1.useCallback(function () {
|
|
9253
9282
|
onChange({
|
|
9254
9283
|
text: "",
|
|
9255
9284
|
formats: [],
|
|
9256
9285
|
});
|
|
9257
9286
|
}, [onChange]);
|
|
9258
|
-
var handleKeyDown =
|
|
9287
|
+
var handleKeyDown = require$$1.useCallback(function (event) {
|
|
9259
9288
|
if (suggestion) {
|
|
9260
9289
|
if (event.key === "End" || event.key === "ArrowRight" || event.key === "Enter") {
|
|
9261
9290
|
onChange(suggestion);
|
|
@@ -9277,38 +9306,33 @@ var Input = function (props) {
|
|
|
9277
9306
|
}
|
|
9278
9307
|
}
|
|
9279
9308
|
}, [suggestion, onChange, onSuggestionCommand]);
|
|
9280
|
-
return (
|
|
9309
|
+
return (require$$0.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" +
|
|
9281
9310
|
value.text
|
|
9282
9311
|
? "To clear input field click on clear icon on the left of send button"
|
|
9283
|
-
: "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
// onFocus={onFocus}
|
|
9287
|
-
value: value, spellCheck: true }),
|
|
9288
|
-
React$1.createElement("div", { className: "xappw-input-form__buttons" },
|
|
9289
|
-
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 })),
|
|
9290
|
-
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 })))));
|
|
9312
|
+
: "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave, children: require$$0.jsxs("form", { className: "xappw-input-form", onSubmit: handleOnSubmit, children: [require$$0.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,
|
|
9313
|
+
// onFocus={onFocus}
|
|
9314
|
+
value: value, spellCheck: true }, "input"), require$$0.jsxs("div", { className: "xappw-input-form__buttons", children: [value.text && (require$$0.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 })), require$$0.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 })] })] }) }));
|
|
9291
9315
|
};
|
|
9292
9316
|
|
|
9293
9317
|
function createActions(onItemUse) {
|
|
9294
9318
|
return function (innerProps) {
|
|
9295
9319
|
var data = innerProps.data;
|
|
9296
9320
|
var canUse = data.type !== "FAQ";
|
|
9297
|
-
var handleUse =
|
|
9321
|
+
var handleUse = require$$1.useCallback(function (ev) {
|
|
9298
9322
|
onItemUse(data);
|
|
9299
9323
|
ev.stopPropagation();
|
|
9300
9324
|
}, [data]);
|
|
9301
9325
|
if (!canUse) {
|
|
9302
|
-
return
|
|
9326
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
9303
9327
|
}
|
|
9304
|
-
return (
|
|
9328
|
+
return (require$$0.jsx(IconButton_1, { className: "xappw-suggestions__use", onClick: handleUse, icon: LeftDownArrowIcon }));
|
|
9305
9329
|
};
|
|
9306
9330
|
}
|
|
9307
9331
|
var Suggestions = function (props) {
|
|
9308
9332
|
var data = props.data, onItemUse = props.onItemUse, searchTerms = props.searchTerms;
|
|
9309
|
-
var _a =
|
|
9310
|
-
var _b =
|
|
9311
|
-
|
|
9333
|
+
var _a = require$$1.useState(), fixedSuggestions = _a[0], setFixedSuggestions = _a[1];
|
|
9334
|
+
var _b = require$$1.useState(), activeItem = _b[0], setActiveItem = _b[1];
|
|
9335
|
+
require$$1.useEffect(function () {
|
|
9312
9336
|
if (data) {
|
|
9313
9337
|
setFixedSuggestions(data);
|
|
9314
9338
|
}
|
|
@@ -9319,8 +9343,8 @@ var Suggestions = function (props) {
|
|
|
9319
9343
|
}, [data, searchTerms]);
|
|
9320
9344
|
var len = data === null || data === void 0 ? void 0 : data.length;
|
|
9321
9345
|
var currentIndex = len > 0 ? props.index : NaN;
|
|
9322
|
-
var item =
|
|
9323
|
-
var handleSpanClick =
|
|
9346
|
+
var item = require$$1.useMemo(function () { return findItemByIndex_1(data, currentIndex); }, [data, currentIndex]);
|
|
9347
|
+
var handleSpanClick = require$$1.useCallback(function (target, span) {
|
|
9324
9348
|
if (span.type === "inputText") {
|
|
9325
9349
|
onItemUse(target);
|
|
9326
9350
|
setActiveItem(undefined);
|
|
@@ -9328,32 +9352,30 @@ var Suggestions = function (props) {
|
|
|
9328
9352
|
}
|
|
9329
9353
|
return undefined;
|
|
9330
9354
|
}, [onItemUse]);
|
|
9331
|
-
|
|
9355
|
+
require$$1.useEffect(function () {
|
|
9332
9356
|
setActiveItem(item);
|
|
9333
9357
|
}, [item]);
|
|
9334
|
-
var actions =
|
|
9358
|
+
var actions = require$$1.useMemo(function () { return createActions(onItemUse); }, [onItemUse]);
|
|
9335
9359
|
var transformContent = function (content) {
|
|
9336
9360
|
var lines = content.split('\n');
|
|
9337
9361
|
return lines.map(function (line) {
|
|
9338
9362
|
if (line) {
|
|
9339
|
-
return
|
|
9363
|
+
return require$$0.jsx(MarkdownBuilder, { text: line });
|
|
9340
9364
|
}
|
|
9341
|
-
return
|
|
9365
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
9342
9366
|
});
|
|
9343
9367
|
};
|
|
9344
9368
|
var containerClass = "xappw-suggestions ".concat(props.className || "", " ").concat(props.hasWsButton ? "xappw-suggestions--with-ws-button" : "").trim();
|
|
9345
|
-
return (
|
|
9346
|
-
|
|
9347
|
-
fixedSuggestions && fixedSuggestions.length > 0 &&
|
|
9348
|
-
React$1.createElement(SuggestionsList_1, { suggestions: fixedSuggestions, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem, onSpanClick: handleSpanClick })));
|
|
9369
|
+
return (require$$0.jsxs("div", { className: containerClass, children: [(activeItem === null || activeItem === void 0 ? void 0 : activeItem.content) && require$$0.jsx("div", { className: "xappw-suggestions__answer", children: transformContent(activeItem.content) }), fixedSuggestions && fixedSuggestions.length > 0 &&
|
|
9370
|
+
require$$0.jsx(SuggestionsList_1, { suggestions: fixedSuggestions, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem, onSpanClick: handleSpanClick })] }));
|
|
9349
9371
|
};
|
|
9350
9372
|
|
|
9351
9373
|
var ChatFooter = function (props) {
|
|
9352
9374
|
var _a, _b, _c;
|
|
9353
9375
|
var isAdmin = props.isAdmin, isChatting = props.isChatting, visible = props.visible, placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, sendButtonIconHover = props.sendButtonIconHover, sendButtonIconDisabled = props.sendButtonIconDisabled, footerConfig = props.footerConfig, menuConfig = props.menuConfig, inputConfig = props.inputConfig, hasWsButton = props.hasWsButton, onSubmit = props.onSubmit;
|
|
9354
9376
|
var innerDispatch = useChatDispatch();
|
|
9355
|
-
var _d =
|
|
9356
|
-
var _e =
|
|
9377
|
+
var _d = require$$1.useState(false), drawerOpen = _d[0], setDrawerState = _d[1]; // false initially
|
|
9378
|
+
var _e = require$$1.useState(), suggestionSearch = _e[0], setSuggestionSearch = _e[1];
|
|
9357
9379
|
var contexts = reactRedux.useSelector(function (state) { return state.activeContexts; });
|
|
9358
9380
|
var suggestions = useSuggestions(suggestionSearch, contexts);
|
|
9359
9381
|
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
@@ -9361,12 +9383,12 @@ var ChatFooter = function (props) {
|
|
|
9361
9383
|
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items;
|
|
9362
9384
|
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex;
|
|
9363
9385
|
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex;
|
|
9364
|
-
var menuItems =
|
|
9386
|
+
var menuItems = require$$1.useMemo(function () { return menuItemsRaw ? menuItemsRaw : []; }, [menuItemsRaw]);
|
|
9365
9387
|
var brandingEnabled = (_b = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.branding) === null || _b === void 0 ? void 0 : _b.enabled;
|
|
9366
9388
|
var brandingText = (_c = footerConfig === null || footerConfig === void 0 ? void 0 : footerConfig.branding) === null || _c === void 0 ? void 0 : _c.text;
|
|
9367
9389
|
// If they are NOT an admin, automatically enabled the input
|
|
9368
|
-
var _f =
|
|
9369
|
-
var _g =
|
|
9390
|
+
var _f = require$$1.useState(!isAdmin), enableInput = _f[0], setEnableInput = _f[1];
|
|
9391
|
+
var _g = require$$1.useState({
|
|
9370
9392
|
text: "",
|
|
9371
9393
|
formats: []
|
|
9372
9394
|
}), input = _g[0], setInput = _g[1];
|
|
@@ -9387,7 +9409,7 @@ var ChatFooter = function (props) {
|
|
|
9387
9409
|
setSuggestionSearch(val.text);
|
|
9388
9410
|
}
|
|
9389
9411
|
// Clears out suggestion and input text
|
|
9390
|
-
var handleSubmit =
|
|
9412
|
+
var handleSubmit = require$$1.useCallback(function (message) {
|
|
9391
9413
|
// Clears out the suggestions
|
|
9392
9414
|
setSuggestionSearch("");
|
|
9393
9415
|
// Clears out the input
|
|
@@ -9397,29 +9419,20 @@ var ChatFooter = function (props) {
|
|
|
9397
9419
|
});
|
|
9398
9420
|
onSubmit(message.text);
|
|
9399
9421
|
}, [onSubmit]);
|
|
9400
|
-
var handleItemClick =
|
|
9422
|
+
var handleItemClick = require$$1.useCallback(function (data) {
|
|
9401
9423
|
handleSubmit(data);
|
|
9402
9424
|
}, [handleSubmit]);
|
|
9403
|
-
var handleItemUse =
|
|
9425
|
+
var handleItemUse = require$$1.useCallback(function (data) {
|
|
9404
9426
|
setInput(data);
|
|
9405
9427
|
setSuggestionSearch(data.text);
|
|
9406
9428
|
}, []);
|
|
9407
9429
|
var handleAdminJoin = function (status) {
|
|
9408
9430
|
setEnableInput(status);
|
|
9409
9431
|
};
|
|
9410
|
-
return (
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
React$1.createElement("div", { className: "chat-footer__menu-icon" },
|
|
9415
|
-
React$1.createElement(DrawerBars, { tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }))) : React$1.createElement(React$1.Fragment, null),
|
|
9416
|
-
React$1.createElement(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, searchTerms: suggestionSearch, hasWsButton: hasWsButton, onItemClick: handleItemClick, onItemUse: handleItemUse }),
|
|
9417
|
-
isAdmin && isChatting && visible && React$1.createElement(AdminBar, { onAdminJoin: handleAdminJoin }),
|
|
9418
|
-
React$1.createElement("div", { style: { pointerEvents: enableInput ? "auto" : "none", opacity: enableInput ? 1 : 0.5 } },
|
|
9419
|
-
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,
|
|
9420
|
-
// onFocus={this.inputOnFocus}
|
|
9421
|
-
onFileUpload: props.onFileUpload })),
|
|
9422
|
-
brandingEnabled && brandingText && React$1.createElement(ChatBranding, { text: brandingText })));
|
|
9432
|
+
return (require$$0.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 ?
|
|
9433
|
+
require$$0.jsxs(require$$0.Fragment, { children: [drawerOpen ? require$$0.jsx(ChatMenu, { opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) : require$$0.jsx(require$$0.Fragment, {}), require$$0.jsx("div", { className: "chat-footer__menu-icon", children: require$$0.jsx(DrawerBars, { tabIndex: menuButtonTabIndex, onToggle: toggleDrawer }) })] }) : require$$0.jsx(require$$0.Fragment, {}), require$$0.jsx(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, searchTerms: suggestionSearch, hasWsButton: hasWsButton, onItemClick: handleItemClick, onItemUse: handleItemUse }), isAdmin && isChatting && visible && require$$0.jsx(AdminBar, { onAdminJoin: handleAdminJoin }), require$$0.jsx("div", { style: { pointerEvents: enableInput ? "auto" : "none", opacity: enableInput ? 1 : 0.5 }, children: require$$0.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,
|
|
9434
|
+
// onFocus={this.inputOnFocus}
|
|
9435
|
+
onFileUpload: props.onFileUpload }) }), brandingEnabled && brandingText && require$$0.jsx(ChatBranding, { text: brandingText })] }));
|
|
9423
9436
|
};
|
|
9424
9437
|
|
|
9425
9438
|
var noop = function () { };
|
|
@@ -9452,64 +9465,43 @@ var MiddlewareContextFactory = /** @class */ (function () {
|
|
|
9452
9465
|
|
|
9453
9466
|
var CardContainer = function (props) {
|
|
9454
9467
|
function renderIcon() {
|
|
9455
|
-
var isString = typeof
|
|
9456
|
-
return
|
|
9457
|
-
}
|
|
9458
|
-
return (
|
|
9459
|
-
renderIcon(),
|
|
9460
|
-
React$1.createElement("div", { className: "card-container__content ".concat(props.contentAddClass) },
|
|
9461
|
-
React$1.createElement("div", { className: "card-container__title" }, props.title),
|
|
9462
|
-
props.children)));
|
|
9468
|
+
var isString = typeof props.icon === "string";
|
|
9469
|
+
return require$$0.jsx("div", { className: "card-container__icon", children: !isString && props.icon });
|
|
9470
|
+
}
|
|
9471
|
+
return (require$$0.jsxs("div", { className: "card-container ".concat(props.addClass), children: [renderIcon(), require$$0.jsxs("div", { className: "card-container__content ".concat(props.contentAddClass), children: [require$$0.jsx("div", { className: "card-container__title", children: props.title }), props.children] })] }));
|
|
9463
9472
|
};
|
|
9464
9473
|
|
|
9465
|
-
var
|
|
9466
|
-
agent
|
|
9467
|
-
hasRating: false,
|
|
9468
|
-
shouldDisplay: true,
|
|
9469
|
-
onRate: function () {
|
|
9474
|
+
var ChatRating = function (_a) {
|
|
9475
|
+
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 () {
|
|
9470
9476
|
// no-op
|
|
9471
|
-
}
|
|
9472
|
-
|
|
9473
|
-
var ChatRating = function (props) {
|
|
9474
|
-
if (props === void 0) { props = defaultProps$2; }
|
|
9475
|
-
var onRate = props.onRate;
|
|
9476
|
-
var rateBadButtonOnClick = React$1.useCallback(function () {
|
|
9477
|
+
} : _e;
|
|
9478
|
+
var rateBadButtonOnClick = require$$1.useCallback(function () {
|
|
9477
9479
|
onRate("bad");
|
|
9478
9480
|
}, [onRate]);
|
|
9479
|
-
var rateGoodButtonOnClick =
|
|
9481
|
+
var rateGoodButtonOnClick = require$$1.useCallback(function () {
|
|
9480
9482
|
onRate("good");
|
|
9481
9483
|
}, [onRate]);
|
|
9482
|
-
var rateAgainButtonOnClick =
|
|
9484
|
+
var rateAgainButtonOnClick = require$$1.useCallback(function () {
|
|
9483
9485
|
onRate(undefined);
|
|
9484
9486
|
}, [onRate]);
|
|
9485
9487
|
// Do not think this prop should be here
|
|
9486
|
-
if (!
|
|
9488
|
+
if (!shouldDisplay) {
|
|
9487
9489
|
return null;
|
|
9488
9490
|
}
|
|
9489
|
-
if (!
|
|
9490
|
-
return (
|
|
9491
|
-
props.agent.displayName,
|
|
9492
|
-
" has requested you to rate the chat service.",
|
|
9493
|
-
React$1.createElement("div", { className: "buttons-container" },
|
|
9494
|
-
React$1.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
|
|
9495
|
-
React$1.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
|
|
9491
|
+
if (!hasRating) {
|
|
9492
|
+
return (require$$0.jsxs(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card", children: [agent.displayName, " has requested you to rate the chat service.", require$$0.jsxs("div", { className: "buttons-container", children: [require$$0.jsx(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }), require$$0.jsx(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick })] })] }));
|
|
9496
9493
|
}
|
|
9497
9494
|
else {
|
|
9498
|
-
return (
|
|
9499
|
-
"You have rated the chat service.",
|
|
9500
|
-
React$1.createElement("div", { className: "buttons-container" },
|
|
9501
|
-
React$1.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
|
|
9495
|
+
return (require$$0.jsxs(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card", children: ["You have rated the chat service.", require$$0.jsx("div", { className: "buttons-container", children: require$$0.jsx(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }) })] }));
|
|
9502
9496
|
}
|
|
9503
9497
|
};
|
|
9504
9498
|
|
|
9505
9499
|
var ChatRatingContainer = function (props) {
|
|
9506
9500
|
var dispatch = useChatServerDispatch();
|
|
9507
|
-
var handleRate =
|
|
9501
|
+
var handleRate = require$$1.useCallback(function (rating) {
|
|
9508
9502
|
dispatch(sendChatRating(rating));
|
|
9509
9503
|
}, [dispatch]);
|
|
9510
|
-
return (
|
|
9511
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
9512
|
-
React$1.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate })));
|
|
9504
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate })] }));
|
|
9513
9505
|
};
|
|
9514
9506
|
|
|
9515
9507
|
var dateFns = {};
|
|
@@ -31005,9 +30997,9 @@ function compileSlotValues(responseOutput, slots, replaceWhenUndefined) {
|
|
|
31005
30997
|
|
|
31006
30998
|
var FailureMessage = function (props) {
|
|
31007
30999
|
var agents = props.agents, text = props.text, delay = props.delay, time = props.time;
|
|
31008
|
-
var _a =
|
|
31000
|
+
var _a = require$$1.useState(delay), countdown = _a[0], setCountdown = _a[1];
|
|
31009
31001
|
var agent_names = Object.values(agents).filter(function (agent) { return agent.requestFailed; });
|
|
31010
|
-
|
|
31002
|
+
require$$1.useEffect(function () {
|
|
31011
31003
|
if (delay !== 0) {
|
|
31012
31004
|
var countdownValue_1 = delay;
|
|
31013
31005
|
var myInterval_1 = setInterval(function () {
|
|
@@ -31022,7 +31014,7 @@ var FailureMessage = function (props) {
|
|
|
31022
31014
|
setCountdown(5);
|
|
31023
31015
|
}
|
|
31024
31016
|
}, [delay]);
|
|
31025
|
-
var slots =
|
|
31017
|
+
var slots = require$$1.useMemo(function () {
|
|
31026
31018
|
return {
|
|
31027
31019
|
sec: {
|
|
31028
31020
|
name: "sec",
|
|
@@ -31030,35 +31022,30 @@ var FailureMessage = function (props) {
|
|
|
31030
31022
|
},
|
|
31031
31023
|
};
|
|
31032
31024
|
}, [countdown]);
|
|
31033
|
-
var failureMessage =
|
|
31025
|
+
var failureMessage = require$$1.useMemo(function () {
|
|
31034
31026
|
return compileSlotValues(text, slots);
|
|
31035
31027
|
}, [text, slots]);
|
|
31036
31028
|
if (countdown === 0) {
|
|
31037
|
-
return
|
|
31029
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
31038
31030
|
}
|
|
31039
|
-
return (
|
|
31040
|
-
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
31046
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + time + " the bot said"),
|
|
31047
|
-
React$1.createElement("span", null, typeof failureMessage === "object" ? failureMessage.displayText : failureMessage)))))));
|
|
31048
|
-
})));
|
|
31031
|
+
return (require$$0.jsx(require$$0.Fragment, { children: agent_names.map(function (agent) {
|
|
31032
|
+
var _a, _b;
|
|
31033
|
+
return (require$$0.jsx("div", { className: "chat-msg-container-wrapper", children: require$$0.jsx("div", { className: "chat-msg-container agent", children: require$$0.jsx(ChatMessagePart, { user: agent === null || agent === void 0 ? void 0 : agent.user, showAvatar: true, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsxs(ChatMessageBubble, { owner: "others", hasTail: true, children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + " the bot said" }), require$$0.jsx("span", { children: typeof failureMessage === "object"
|
|
31034
|
+
? failureMessage.displayText
|
|
31035
|
+
: 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)));
|
|
31036
|
+
}) }));
|
|
31049
31037
|
};
|
|
31050
31038
|
|
|
31051
31039
|
var MessageSvg = function (_) {
|
|
31052
|
-
return (
|
|
31053
|
-
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" })));
|
|
31040
|
+
return (require$$0.jsx("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12", children: require$$0.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" }) }));
|
|
31054
31041
|
};
|
|
31055
31042
|
|
|
31056
31043
|
var MessageForm = function (props) {
|
|
31057
|
-
var name =
|
|
31058
|
-
var email =
|
|
31059
|
-
var message =
|
|
31060
|
-
var form =
|
|
31061
|
-
var _a =
|
|
31044
|
+
var name = require$$1.useRef(null);
|
|
31045
|
+
var email = require$$1.useRef(null);
|
|
31046
|
+
var message = require$$1.useRef(null);
|
|
31047
|
+
var form = require$$1.useRef(null);
|
|
31048
|
+
var _a = require$$1.useState(false), sent = _a[0], setSent = _a[1];
|
|
31062
31049
|
function emailChanged() {
|
|
31063
31050
|
var _a, _b, _c;
|
|
31064
31051
|
if ((_a = email.current) === null || _a === void 0 ? void 0 : _a.validity.patternMismatch) {
|
|
@@ -31078,7 +31065,7 @@ var MessageForm = function (props) {
|
|
|
31078
31065
|
props.onSubmit({
|
|
31079
31066
|
name: (_c = name.current) === null || _c === void 0 ? void 0 : _c.value,
|
|
31080
31067
|
email: (_d = email.current) === null || _d === void 0 ? void 0 : _d.value,
|
|
31081
|
-
message: (_e = message.current) === null || _e === void 0 ? void 0 : _e.value
|
|
31068
|
+
message: (_e = message.current) === null || _e === void 0 ? void 0 : _e.value,
|
|
31082
31069
|
});
|
|
31083
31070
|
setSent(true);
|
|
31084
31071
|
}
|
|
@@ -31086,56 +31073,40 @@ var MessageForm = function (props) {
|
|
|
31086
31073
|
setSent(false);
|
|
31087
31074
|
}
|
|
31088
31075
|
function renderSent() {
|
|
31089
|
-
return (
|
|
31090
|
-
"Your message has been sent. We will get back to you as soon as possible.",
|
|
31091
|
-
React$1.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
|
|
31076
|
+
return (require$$0.jsxs("div", { className: "message-form--sent", children: ["Your message has been sent. We will get back to you as soon as possible.", require$$0.jsx(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })] }, "sent"));
|
|
31092
31077
|
}
|
|
31093
31078
|
function renderForm() {
|
|
31094
|
-
return (
|
|
31095
|
-
|
|
31096
|
-
|
|
31097
|
-
React$1.createElement("label", { className: "label" }, "Name"),
|
|
31098
|
-
React$1.createElement("input", { ref: name, maxLength: 255 })),
|
|
31099
|
-
React$1.createElement("div", { className: "section" },
|
|
31100
|
-
React$1.createElement("label", { className: "label" }, "Email"),
|
|
31101
|
-
React$1.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
|
|
31102
|
-
React$1.createElement("div", { className: "section" },
|
|
31103
|
-
React$1.createElement("label", { className: "label" }, "Message"),
|
|
31104
|
-
React$1.createElement("textarea", { required: true, ref: message }))),
|
|
31105
|
-
React$1.createElement("div", { className: "button-container" },
|
|
31106
|
-
React$1.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
|
|
31107
|
-
}
|
|
31108
|
-
return (React$1.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React$1.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
|
|
31079
|
+
return (require$$0.jsxs("form", { ref: form, className: "message-form", onSubmit: send, children: [require$$0.jsxs("div", { className: "content", children: [require$$0.jsxs("div", { className: "section", children: [require$$0.jsx("label", { className: "label", children: "Name" }), require$$0.jsx("input", { ref: name, maxLength: 255 })] }), require$$0.jsxs("div", { className: "section", children: [require$$0.jsx("label", { className: "label", children: "Email" }), require$$0.jsx("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })] }), require$$0.jsxs("div", { className: "section", children: [require$$0.jsx("label", { className: "label", children: "Message" }), require$$0.jsx("textarea", { required: true, ref: message })] })] }), require$$0.jsx("div", { className: "button-container", children: require$$0.jsx(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }) })] }, "not-sent"));
|
|
31080
|
+
}
|
|
31081
|
+
return (require$$0.jsx(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: require$$0.jsx(MessageSvg, {}), children: sent ? renderSent() : renderForm() }));
|
|
31109
31082
|
};
|
|
31110
31083
|
|
|
31111
31084
|
var OfflineForm = function (props) {
|
|
31112
|
-
return
|
|
31085
|
+
return require$$0.jsx(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
|
|
31113
31086
|
};
|
|
31114
31087
|
|
|
31115
31088
|
var OfflineFormContainer = function (props) {
|
|
31116
31089
|
var dispatch = useChatServerDispatch();
|
|
31117
|
-
var handleSubmit =
|
|
31090
|
+
var handleSubmit = require$$1.useCallback(function (data) {
|
|
31118
31091
|
dispatch(sendOfflineMsg(data));
|
|
31119
31092
|
}, [dispatch]);
|
|
31120
|
-
return (
|
|
31121
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
31122
|
-
React$1.createElement(OfflineForm, { onSubmit: handleSubmit })));
|
|
31093
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx(OfflineForm, { onSubmit: handleSubmit })] }));
|
|
31123
31094
|
};
|
|
31124
31095
|
|
|
31125
31096
|
var PrechatForm = function (props) {
|
|
31126
|
-
var _a =
|
|
31097
|
+
var _a = require$$1.useState(false), sent = _a[0], setSent = _a[1];
|
|
31127
31098
|
var onSubmit = props.onSubmit;
|
|
31128
|
-
var handleSubmit =
|
|
31099
|
+
var handleSubmit = require$$1.useCallback(function (msg) {
|
|
31129
31100
|
onSubmit(msg);
|
|
31130
31101
|
setSent(true);
|
|
31131
31102
|
}, [onSubmit]);
|
|
31132
|
-
return
|
|
31103
|
+
return require$$0.jsx(require$$0.Fragment, { children: !sent && require$$0.jsx(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit }) });
|
|
31133
31104
|
};
|
|
31134
31105
|
|
|
31135
31106
|
var PrechatFormContainer = function (props) {
|
|
31136
31107
|
var dispatch = useChatServerDispatch();
|
|
31137
31108
|
var sessionId = reactRedux.useSelector(function (state) { return state.sessionId; });
|
|
31138
|
-
var handleSubmit =
|
|
31109
|
+
var handleSubmit = require$$1.useCallback(function (data) {
|
|
31139
31110
|
// Don't send empty messages
|
|
31140
31111
|
if (!data.message)
|
|
31141
31112
|
return;
|
|
@@ -31145,34 +31116,34 @@ var PrechatFormContainer = function (props) {
|
|
|
31145
31116
|
}, sessionId));
|
|
31146
31117
|
dispatch(executeAction(data.message));
|
|
31147
31118
|
}, [dispatch, sessionId]);
|
|
31148
|
-
return (
|
|
31149
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + props.time + " system message"),
|
|
31150
|
-
React$1.createElement(PrechatForm, { onSubmit: handleSubmit })));
|
|
31119
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx(PrechatForm, { onSubmit: handleSubmit })] }));
|
|
31151
31120
|
};
|
|
31152
31121
|
|
|
31153
|
-
var
|
|
31154
|
-
position:
|
|
31155
|
-
|
|
31156
|
-
var QueuePosition = function (props) {
|
|
31157
|
-
if (props === void 0) { props = defaultProps$1; }
|
|
31158
|
-
if (props.position <= 0)
|
|
31122
|
+
var QueuePosition = function (_a) {
|
|
31123
|
+
var _b = _a.position, position = _b === void 0 ? 0 : _b;
|
|
31124
|
+
if (position <= 0)
|
|
31159
31125
|
return null;
|
|
31160
|
-
return (
|
|
31161
|
-
React$1.createElement("span", { className: "system-msg" },
|
|
31162
|
-
"Queue position: ",
|
|
31163
|
-
props.position)));
|
|
31126
|
+
return (require$$0.jsx("div", { className: "system-msg-container", children: require$$0.jsxs("span", { className: "system-msg", children: ["Queue position: ", position] }) }));
|
|
31164
31127
|
};
|
|
31165
31128
|
|
|
31166
31129
|
function isServerUser(user) {
|
|
31167
31130
|
var _a;
|
|
31168
31131
|
return (_a = user.nick) === null || _a === void 0 ? void 0 : _a.endsWith(ROUTER_USER);
|
|
31169
31132
|
}
|
|
31133
|
+
function shouldShowDivider(message) {
|
|
31134
|
+
return (message.type === "chat.memberjoin" && message.showDivider) ||
|
|
31135
|
+
(message.type === "chat.memberleave" && message.showDivider);
|
|
31136
|
+
}
|
|
31170
31137
|
function getMessageByType(msg) {
|
|
31171
31138
|
switch (msg.type) {
|
|
31172
31139
|
case "chat.memberjoin":
|
|
31173
|
-
|
|
31140
|
+
// Use custom message if provided, otherwise use default
|
|
31141
|
+
return msg.message || "".concat(msg.user.displayName || "Bot", " has joined the chat");
|
|
31174
31142
|
case "chat.memberleave":
|
|
31175
|
-
|
|
31143
|
+
// Use custom message if provided, otherwise use default
|
|
31144
|
+
return msg.message || "".concat(msg.user.displayName || "Bot", " has left the chat");
|
|
31145
|
+
case "chat.systemmessage":
|
|
31146
|
+
return msg.message;
|
|
31176
31147
|
case "chat.rating":
|
|
31177
31148
|
if (!msg.newRating) {
|
|
31178
31149
|
return "You have removed the chat rating";
|
|
@@ -31186,10 +31157,12 @@ function getMessageByType(msg) {
|
|
|
31186
31157
|
}
|
|
31187
31158
|
}
|
|
31188
31159
|
var SystemMessage = function (props) {
|
|
31160
|
+
var _a;
|
|
31189
31161
|
if (!isServerUser(props.message.user)) {
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
|
|
31162
|
+
var message = props.message;
|
|
31163
|
+
var showDivider = shouldShowDivider(message);
|
|
31164
|
+
var avatarUrl = (_a = message.user) === null || _a === void 0 ? void 0 : _a.avatarPath;
|
|
31165
|
+
return (require$$0.jsxs("div", { className: "system-msg-container", children: [showDivider && avatarUrl && (require$$0.jsxs("div", { className: "system-msg-divider", children: [require$$0.jsx("div", { className: "divider-line" }), require$$0.jsx("div", { className: "divider-avatar", children: require$$0.jsx("img", { src: avatarUrl, alt: "".concat(message.user.displayName || "User", "'s avatar") }) }), require$$0.jsx("div", { className: "divider-line" })] })), require$$0.jsx("span", { className: "message-sr-only", children: "at " + props.time + " system message" }), require$$0.jsx("span", { className: "system-msg", children: getMessageByType(props.message) })] }));
|
|
31193
31166
|
}
|
|
31194
31167
|
else {
|
|
31195
31168
|
return null;
|
|
@@ -31200,10 +31173,7 @@ function convertToSentenceCase(s) {
|
|
|
31200
31173
|
}
|
|
31201
31174
|
|
|
31202
31175
|
var TypingIndicator = function (_) {
|
|
31203
|
-
return (
|
|
31204
|
-
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
31205
|
-
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
31206
|
-
React$1.createElement("div", { className: "typing-indicator-part" })));
|
|
31176
|
+
return (require$$0.jsxs("div", { className: "typing-indicator", children: [require$$0.jsx("div", { className: "typing-indicator-part" }), require$$0.jsx("div", { className: "typing-indicator-part" }), require$$0.jsx("div", { className: "typing-indicator-part" })] }));
|
|
31207
31177
|
};
|
|
31208
31178
|
|
|
31209
31179
|
/**
|
|
@@ -31211,64 +31181,41 @@ var TypingIndicator = function (_) {
|
|
|
31211
31181
|
*/
|
|
31212
31182
|
var TypingStatus = function (props) {
|
|
31213
31183
|
var agentsTyping = Object.values(props.agents).filter(function (agent) { return agent.typing; });
|
|
31214
|
-
return (
|
|
31215
|
-
|
|
31216
|
-
|
|
31217
|
-
|
|
31218
|
-
|
|
31219
|
-
|
|
31220
|
-
React$1.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
|
|
31221
|
-
React$1.createElement("div", { className: "chat-msg" },
|
|
31222
|
-
React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
31223
|
-
React$1.createElement(TypingIndicator, null))))))) : (React$1.createElement("div", { key: "typing-status-".concat(key), className: "chat-msg-agent-typing" },
|
|
31224
|
-
displayName,
|
|
31225
|
-
" is typing"))));
|
|
31226
|
-
})));
|
|
31184
|
+
return (require$$0.jsx(require$$0.Fragment, { children: agentsTyping.map(function (agent, index) {
|
|
31185
|
+
var _a, _b;
|
|
31186
|
+
var key = ((_a = agent.user) === null || _a === void 0 ? void 0 : _a.nick) || "".concat(index);
|
|
31187
|
+
var displayName = ((_b = agent.user) === null || _b === void 0 ? void 0 : _b.displayName) || "Somebody";
|
|
31188
|
+
return (require$$0.jsx("span", { children: !props.textTypingStatusEnabled ? (require$$0.jsx("div", { className: "chat-msg-container-wrapper", children: require$$0.jsx("div", { className: "chat-msg-container agent chat-typing-progress", children: require$$0.jsx(ChatMessagePart, { user: agent.user, showAvatar: true, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx(ChatMessageBubble, { owner: "others", hasTail: true, children: require$$0.jsx(TypingIndicator, {}) }) }) }) }, key) }, "typing-status-".concat(key))) : (require$$0.jsxs("div", { className: "chat-msg-agent-typing", children: [displayName, " is typing"] }, "typing-status-".concat(key))) }, "typing-status-".concat(index)));
|
|
31189
|
+
}) }));
|
|
31227
31190
|
};
|
|
31228
31191
|
|
|
31229
|
-
var
|
|
31230
|
-
visible:
|
|
31231
|
-
|
|
31232
|
-
|
|
31233
|
-
|
|
31234
|
-
isChatting: false,
|
|
31235
|
-
queuePosition: 0,
|
|
31236
|
-
lastRatingRequestTimestamp: 0,
|
|
31237
|
-
hasRating: false,
|
|
31238
|
-
visitorId: "",
|
|
31239
|
-
onSend: function () { return Promise.resolve(); },
|
|
31240
|
-
onWrite: function () { return Promise.resolve(); },
|
|
31241
|
-
onOpenUrl: function () { },
|
|
31242
|
-
minimizeOnClick: function () { },
|
|
31243
|
-
};
|
|
31244
|
-
var MessageList = function (props) {
|
|
31245
|
-
if (props === void 0) { props = defaultProps; }
|
|
31246
|
-
var onSend = props.onSend, onWrite = props.onWrite, onOpenUrl = props.onOpenUrl, minimizeOnClick = props.minimizeOnClick;
|
|
31247
|
-
var messagesEndRef = React$1.useRef(null);
|
|
31248
|
-
var containerRef = React$1.useRef(null);
|
|
31249
|
-
var prevHasWsButtonRef = React$1.useRef(props.hasWsButton);
|
|
31192
|
+
var MessageList = function (_a) {
|
|
31193
|
+
_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;
|
|
31194
|
+
var messagesEndRef = require$$1.useRef(null);
|
|
31195
|
+
var containerRef = require$$1.useRef(null);
|
|
31196
|
+
var prevHasWsButtonRef = require$$1.useRef(hasWsButton);
|
|
31250
31197
|
// Check if user is scrolled to bottom
|
|
31251
|
-
var isAtBottom =
|
|
31198
|
+
var isAtBottom = require$$1.useCallback(function () {
|
|
31252
31199
|
if (!containerRef.current)
|
|
31253
31200
|
return true;
|
|
31254
31201
|
var _a = containerRef.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
31255
31202
|
return Math.abs(scrollHeight - clientHeight - scrollTop) < 10;
|
|
31256
31203
|
}, []);
|
|
31257
31204
|
// Scroll to bottom
|
|
31258
|
-
var scrollToBottom =
|
|
31205
|
+
var scrollToBottom = require$$1.useCallback(function (behavior) {
|
|
31259
31206
|
if (behavior === void 0) { behavior = "smooth"; }
|
|
31260
31207
|
if (messagesEndRef.current) {
|
|
31261
31208
|
messagesEndRef.current.scrollIntoView({ behavior: behavior });
|
|
31262
31209
|
}
|
|
31263
31210
|
}, []);
|
|
31264
31211
|
// Always scroll to bottom when messages change
|
|
31265
|
-
|
|
31212
|
+
require$$1.useEffect(function () {
|
|
31266
31213
|
scrollToBottom("smooth");
|
|
31267
|
-
}, [
|
|
31214
|
+
}, [messages, agents, scrollToBottom]);
|
|
31268
31215
|
// Handle WS button dismissal - only scroll when button is removed
|
|
31269
|
-
|
|
31216
|
+
require$$1.useEffect(function () {
|
|
31270
31217
|
var prevHasButton = prevHasWsButtonRef.current;
|
|
31271
|
-
var currentHasButton =
|
|
31218
|
+
var currentHasButton = hasWsButton;
|
|
31272
31219
|
// Update ref for next render
|
|
31273
31220
|
prevHasWsButtonRef.current = currentHasButton;
|
|
31274
31221
|
// Only handle button dismissal (was true, now false)
|
|
@@ -31283,16 +31230,16 @@ var MessageList = function (props) {
|
|
|
31283
31230
|
}
|
|
31284
31231
|
}
|
|
31285
31232
|
return undefined;
|
|
31286
|
-
}, [
|
|
31287
|
-
var handleSend =
|
|
31233
|
+
}, [hasWsButton, isAtBottom, scrollToBottom]);
|
|
31234
|
+
var handleSend = require$$1.useCallback(function (msg) {
|
|
31288
31235
|
onSend(msg);
|
|
31289
31236
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
31290
31237
|
}, [onSend]);
|
|
31291
|
-
var handleWrite =
|
|
31238
|
+
var handleWrite = require$$1.useCallback(function (msg) {
|
|
31292
31239
|
onWrite(msg);
|
|
31293
31240
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
31294
31241
|
}, [onWrite]);
|
|
31295
|
-
var ctxCache =
|
|
31242
|
+
var ctxCache = require$$1.useMemo(function () {
|
|
31296
31243
|
return new MiddlewareContextFactory({
|
|
31297
31244
|
send: handleSend,
|
|
31298
31245
|
write: handleWrite,
|
|
@@ -31315,7 +31262,7 @@ var MessageList = function (props) {
|
|
|
31315
31262
|
user = msg.user;
|
|
31316
31263
|
}
|
|
31317
31264
|
else {
|
|
31318
|
-
user = ((_c =
|
|
31265
|
+
user = ((_c = agents[msg.user.nick]) === null || _c === void 0 ? void 0 : _c.user) || agent;
|
|
31319
31266
|
// Still nothing?
|
|
31320
31267
|
if (!user) {
|
|
31321
31268
|
log("Could not get a user from agents list with nick: \"".concat(msg.user.nick, "\""));
|
|
@@ -31325,26 +31272,23 @@ var MessageList = function (props) {
|
|
|
31325
31272
|
switch (msg.type) {
|
|
31326
31273
|
case "chat.file":
|
|
31327
31274
|
case "chat.msg":
|
|
31328
|
-
return (
|
|
31275
|
+
return (require$$0.jsx(ChatMessage, { message: msg, sibling: sibling, agent: user, messageMiddleware: messageMiddleware, middlewareContext: ctxCache.resolve(user), minimizeOnClick: minimizeOnClick }, "cm-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31329
31276
|
case "chat.failureMsg":
|
|
31330
|
-
return (
|
|
31277
|
+
return (require$$0.jsx(FailureMessage, __assign({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31331
31278
|
case "chat.memberjoin":
|
|
31332
31279
|
case "chat.memberleave":
|
|
31280
|
+
case "chat.systemmessage":
|
|
31333
31281
|
case "chat.rating":
|
|
31334
31282
|
case "chat.typing":
|
|
31335
|
-
return (
|
|
31283
|
+
return (require$$0.jsx(SystemMessage, { time: time, message: msg }, "sm-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31336
31284
|
case "chat.request.rating":
|
|
31337
|
-
return (
|
|
31285
|
+
return (require$$0.jsx(ChatRatingContainer, { agent: user, hasRating: hasRating, time: time, shouldDisplay: msg.timestamp === lastRatingRequestTimestamp }, "cr-".concat(msg.type, "-").concat(msg.timestamp)));
|
|
31338
31286
|
case "chat.offline":
|
|
31339
|
-
return
|
|
31287
|
+
return require$$0.jsx(OfflineFormContainer, { time: time }, "offline-".concat(msg.timestamp));
|
|
31340
31288
|
case "chat.prechat":
|
|
31341
|
-
return
|
|
31289
|
+
return require$$0.jsx(PrechatFormContainer, { time: time }, "prechat");
|
|
31342
31290
|
default:
|
|
31343
|
-
return (
|
|
31344
|
-
React$1.createElement("span", { className: "message-sr-only" }, "at " + time + " system message"),
|
|
31345
|
-
React$1.createElement("div", { key: "uhm-".concat(+new Date()) },
|
|
31346
|
-
"Unhandled message: ",
|
|
31347
|
-
JSON.stringify(msg))));
|
|
31291
|
+
return (require$$0.jsxs("span", { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + " system message" }), require$$0.jsxs("div", { children: ["Unhandled message: ", JSON.stringify(msg)] }, "uhm-".concat(+new Date()))] }, "default-".concat(msg.timestamp)));
|
|
31348
31292
|
}
|
|
31349
31293
|
}
|
|
31350
31294
|
/**
|
|
@@ -31353,14 +31297,14 @@ var MessageList = function (props) {
|
|
|
31353
31297
|
*/
|
|
31354
31298
|
function renderAll() {
|
|
31355
31299
|
var lastMsgIndex = -1;
|
|
31356
|
-
for (var i =
|
|
31357
|
-
if (
|
|
31300
|
+
for (var i = messages.length - 1; i > 0; i--) {
|
|
31301
|
+
if (messages[i].type === "chat.msg") {
|
|
31358
31302
|
lastMsgIndex = i;
|
|
31359
31303
|
break;
|
|
31360
31304
|
}
|
|
31361
31305
|
}
|
|
31362
|
-
return
|
|
31363
|
-
// const next =
|
|
31306
|
+
return messages.map(function (message, index) {
|
|
31307
|
+
// const next = messages[index + 1];
|
|
31364
31308
|
var _a, _b;
|
|
31365
31309
|
// let sibling = false;
|
|
31366
31310
|
// const currentNick = message.nick;
|
|
@@ -31376,6 +31320,7 @@ var MessageList = function (props) {
|
|
|
31376
31320
|
// "chat.failureMsg",
|
|
31377
31321
|
"chat.memberjoin",
|
|
31378
31322
|
"chat.memberleave",
|
|
31323
|
+
// "chat.systemmessage", // System messages don't show timestamps
|
|
31379
31324
|
"chat.rating",
|
|
31380
31325
|
// "chat.typing",
|
|
31381
31326
|
"chat.request.rating",
|
|
@@ -31385,11 +31330,11 @@ var MessageList = function (props) {
|
|
|
31385
31330
|
// show first and las TS and after at least 5 minutes gap. Don't show "router user"
|
|
31386
31331
|
var showTs = false;
|
|
31387
31332
|
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))) {
|
|
31388
|
-
if (index === 0 || index ===
|
|
31333
|
+
if (index === 0 || index === messages.length - 1 || index === lastMsgIndex) {
|
|
31389
31334
|
showTs = true;
|
|
31390
31335
|
}
|
|
31391
31336
|
else {
|
|
31392
|
-
var previous =
|
|
31337
|
+
var previous = messages[index - 1];
|
|
31393
31338
|
if (message.timestamp && previous.timestamp) {
|
|
31394
31339
|
showTs = message.timestamp - previous.timestamp > 300 * 1000; // 5 minutes
|
|
31395
31340
|
}
|
|
@@ -31400,26 +31345,14 @@ var MessageList = function (props) {
|
|
|
31400
31345
|
showTs = false;
|
|
31401
31346
|
}
|
|
31402
31347
|
var ts = showTs ? new Date(message.timestamp).toLocaleString() : undefined;
|
|
31403
|
-
return (
|
|
31404
|
-
showTs && (React$1.createElement("div", { className: "ts-msg-container" },
|
|
31405
|
-
React$1.createElement("span", { className: "ts-msg" }, ts))),
|
|
31406
|
-
renderByType(message, false)));
|
|
31348
|
+
return (require$$0.jsxs("span", { children: [showTs && (require$$0.jsx("div", { className: "ts-msg-container", children: require$$0.jsx("span", { className: "ts-msg", children: ts }) })), renderByType(message, false)] }, "message-list-render-all-".concat(index)));
|
|
31407
31349
|
});
|
|
31408
31350
|
}
|
|
31409
|
-
|
|
31410
|
-
return (React$1.createElement("div", { className: "message-list-container", ref: containerRef },
|
|
31411
|
-
React$1.createElement("div", { className: "message-list-container__msgs" },
|
|
31412
|
-
renderAll(),
|
|
31413
|
-
React$1.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
|
|
31414
|
-
React$1.createElement(QueuePosition, { position: queuePosition }),
|
|
31415
|
-
React$1.createElement(TypingStatus, { agents: agents, textTypingStatusEnabled: props.textTypingStatusEnabled })),
|
|
31416
|
-
React$1.createElement(ChatChipsContainer, null)));
|
|
31351
|
+
return (require$$0.jsxs("div", { className: "message-list-container", ref: containerRef, children: [require$$0.jsxs("div", { className: "message-list-container__msgs", children: [renderAll(), require$$0.jsx("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }), require$$0.jsx(QueuePosition, { position: queuePosition }), require$$0.jsx(TypingStatus, { agents: agents, textTypingStatusEnabled: textTypingStatusEnabled })] }), require$$0.jsx(ChatChipsContainer, {})] }));
|
|
31417
31352
|
};
|
|
31418
31353
|
|
|
31419
31354
|
var ServerOffline = function () {
|
|
31420
|
-
return
|
|
31421
|
-
React$1.createElement("h2", null, "Chat is currently unavailable"),
|
|
31422
|
-
React$1.createElement("h3", null, "Server is offline"));
|
|
31355
|
+
return (require$$0.jsxs("div", { className: "server-offline", children: [require$$0.jsx("h2", { children: "Chat is currently unavailable" }), require$$0.jsx("h3", { children: "Server is offline" })] }));
|
|
31423
31356
|
};
|
|
31424
31357
|
|
|
31425
31358
|
function buildStyleContent(theme) {
|
|
@@ -31429,7 +31362,7 @@ function buildStyleContent(theme) {
|
|
|
31429
31362
|
function WidgetStylesheet(props) {
|
|
31430
31363
|
var theme = props.theme;
|
|
31431
31364
|
var stylesContent = buildStyleContent(theme);
|
|
31432
|
-
return
|
|
31365
|
+
return require$$0.jsx("style", { children: stylesContent });
|
|
31433
31366
|
}
|
|
31434
31367
|
function buildVariables(gen) {
|
|
31435
31368
|
var result = gen.next();
|
|
@@ -31767,13 +31700,13 @@ var safeStringify = function (arg) {
|
|
|
31767
31700
|
};
|
|
31768
31701
|
var ErrorOverlay = function (_a) {
|
|
31769
31702
|
var enableErrorOverlay = _a.enableErrorOverlay;
|
|
31770
|
-
var _b =
|
|
31771
|
-
var _c =
|
|
31772
|
-
var _d =
|
|
31773
|
-
var _e =
|
|
31774
|
-
var _f =
|
|
31703
|
+
var _b = require$$1.useState([]), errors = _b[0], setErrors = _b[1];
|
|
31704
|
+
var _c = require$$1.useState(false), isMinimized = _c[0], setIsMinimized = _c[1];
|
|
31705
|
+
var _d = require$$1.useState(true), isVisible = _d[0], setIsVisible = _d[1];
|
|
31706
|
+
var _e = require$$1.useState(false), isEnabled = _e[0], setIsEnabled = _e[1];
|
|
31707
|
+
var _f = require$$1.useState("bottom"), position = _f[0], setPosition = _f[1];
|
|
31775
31708
|
// Check if error overlay should be enabled and load position
|
|
31776
|
-
|
|
31709
|
+
require$$1.useEffect(function () {
|
|
31777
31710
|
var _a;
|
|
31778
31711
|
var checkEnabled = function () {
|
|
31779
31712
|
var _a;
|
|
@@ -31812,7 +31745,7 @@ var ErrorOverlay = function (_a) {
|
|
|
31812
31745
|
console.log("[ErrorOverlay] Component mounted, enabled:", enabled, "position:", savedPosition || "bottom");
|
|
31813
31746
|
}, [enableErrorOverlay]);
|
|
31814
31747
|
// Define addError with useCallback to prevent stale closures
|
|
31815
|
-
var addError =
|
|
31748
|
+
var addError = require$$1.useCallback(function (error) {
|
|
31816
31749
|
console.log("[ErrorOverlay] Adding error:", error);
|
|
31817
31750
|
setErrors(function (prev) {
|
|
31818
31751
|
var timestamp = new Date().toISOString();
|
|
@@ -31831,7 +31764,7 @@ var ErrorOverlay = function (_a) {
|
|
|
31831
31764
|
return updated.slice(-50);
|
|
31832
31765
|
});
|
|
31833
31766
|
}, []);
|
|
31834
|
-
|
|
31767
|
+
require$$1.useEffect(function () {
|
|
31835
31768
|
if (!isEnabled) {
|
|
31836
31769
|
console.log("[ErrorOverlay] Not enabled, skipping error interception");
|
|
31837
31770
|
return undefined;
|
|
@@ -31976,41 +31909,17 @@ var ErrorOverlay = function (_a) {
|
|
|
31976
31909
|
if (errors.length === 0) {
|
|
31977
31910
|
return null;
|
|
31978
31911
|
}
|
|
31979
|
-
return (
|
|
31980
|
-
React$1.createElement("div", { className: "error-overlay-header" },
|
|
31981
|
-
React$1.createElement("span", { className: "error-overlay-title" },
|
|
31982
|
-
"Debug Console (",
|
|
31983
|
-
errors.length,
|
|
31984
|
-
")"),
|
|
31985
|
-
React$1.createElement("div", { className: "error-overlay-actions" },
|
|
31986
|
-
React$1.createElement("button", { onClick: copyToClipboard, title: "Copy all to clipboard" }, "\uD83D\uDCCB"),
|
|
31987
|
-
React$1.createElement("button", { onClick: clearErrors, title: "Clear all" }, "\uD83D\uDDD1\uFE0F"),
|
|
31988
|
-
React$1.createElement("button", { onClick: togglePosition, title: "Move to ".concat(position === "bottom" ? "top" : "bottom") }, position === "bottom" ? "⬆️" : "⬇️"),
|
|
31989
|
-
React$1.createElement("button", { onClick: toggleEnabled, title: "Disable Error Overlay" }, "\uD83D\uDD27"),
|
|
31990
|
-
React$1.createElement("button", { onClick: function () { return setIsMinimized(!isMinimized); }, title: "Minimize/Maximize" }, isMinimized ? "▲" : "▼"),
|
|
31991
|
-
React$1.createElement("button", { onClick: function () { return setIsVisible(false); }, title: "Close" }, "\u2715"))),
|
|
31992
|
-
!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) },
|
|
31993
|
-
React$1.createElement("div", { className: "error-header" },
|
|
31994
|
-
React$1.createElement("span", { className: "error-time" }, new Date(error.timestamp).toLocaleTimeString()),
|
|
31995
|
-
error.count > 1 && (React$1.createElement("span", { className: "error-count" },
|
|
31996
|
-
"(",
|
|
31997
|
-
error.count,
|
|
31998
|
-
"x)")),
|
|
31999
|
-
React$1.createElement("span", { className: "error-badge error-badge-".concat(error.type) }, error.type)),
|
|
32000
|
-
React$1.createElement("div", { className: "error-message" }, error.message),
|
|
32001
|
-
error.stack && (React$1.createElement("details", { className: "error-stack" },
|
|
32002
|
-
React$1.createElement("summary", null, "Stack trace"),
|
|
32003
|
-
React$1.createElement("pre", null, error.stack))))); })))));
|
|
31912
|
+
return (require$$0.jsxs("div", { className: "error-overlay error-overlay--".concat(position, " ").concat(isMinimized ? "minimized" : ""), children: [require$$0.jsxs("div", { className: "error-overlay-header", children: [require$$0.jsxs("span", { className: "error-overlay-title", children: ["Debug Console (", errors.length, ")"] }), require$$0.jsxs("div", { className: "error-overlay-actions", children: [require$$0.jsx("button", { onClick: copyToClipboard, title: "Copy all to clipboard", children: "\uD83D\uDCCB" }), require$$0.jsx("button", { onClick: clearErrors, title: "Clear all", children: "\uD83D\uDDD1\uFE0F" }), require$$0.jsx("button", { onClick: togglePosition, title: "Move to ".concat(position === "bottom" ? "top" : "bottom"), children: position === "bottom" ? "⬆️" : "⬇️" }), require$$0.jsx("button", { onClick: toggleEnabled, title: "Disable Error Overlay", children: "\uD83D\uDD27" }), require$$0.jsx("button", { onClick: function () { return setIsMinimized(!isMinimized); }, title: "Minimize/Maximize", children: isMinimized ? "▲" : "▼" }), require$$0.jsx("button", { onClick: function () { return setIsVisible(false); }, title: "Close", children: "\u2715" })] })] }), !isMinimized && (require$$0.jsx("div", { className: "error-overlay-content", children: errors.map(function (error) { return (require$$0.jsxs("div", { className: "error-entry error-".concat(error.type), children: [require$$0.jsxs("div", { className: "error-header", children: [require$$0.jsx("span", { className: "error-time", children: new Date(error.timestamp).toLocaleTimeString() }), error.count > 1 && (require$$0.jsxs("span", { className: "error-count", children: ["(", error.count, "x)"] })), require$$0.jsx("span", { className: "error-badge error-badge-".concat(error.type), children: error.type })] }), require$$0.jsx("div", { className: "error-message", children: error.message }), error.stack && (require$$0.jsxs("details", { className: "error-stack", children: [require$$0.jsx("summary", { children: "Stack trace" }), require$$0.jsx("pre", { children: error.stack })] }))] }, error.id)); }) }))] }));
|
|
32004
31913
|
};
|
|
32005
31914
|
|
|
32006
31915
|
var WsButton = function (_a) {
|
|
32007
31916
|
var button = _a.button, onPress = _a.onPress;
|
|
32008
|
-
var handleClick =
|
|
31917
|
+
var handleClick = require$$1.useCallback(function () {
|
|
32009
31918
|
if (button.pressBehavior !== "disabled" && !button.isPressed) {
|
|
32010
31919
|
onPress(button.id);
|
|
32011
31920
|
}
|
|
32012
31921
|
}, [button.pressBehavior, button.isPressed, button.id, onPress]);
|
|
32013
|
-
var className =
|
|
31922
|
+
var className = require$$1.useMemo(function () {
|
|
32014
31923
|
var classes = ["ws-button"];
|
|
32015
31924
|
if (button.pressBehavior === "disabled" || button.isPressed) {
|
|
32016
31925
|
classes.push("ws-button--disabled");
|
|
@@ -32020,37 +31929,33 @@ var WsButton = function (_a) {
|
|
|
32020
31929
|
}
|
|
32021
31930
|
return classes.join(" ");
|
|
32022
31931
|
}, [button.pressBehavior, button.isPressed]);
|
|
32023
|
-
var containerClassName =
|
|
31932
|
+
var containerClassName = require$$1.useMemo(function () {
|
|
32024
31933
|
var classes = ["ws-button-container"];
|
|
32025
31934
|
if (button.isDismissing) {
|
|
32026
31935
|
classes.push("ws-button-container--dismissing");
|
|
32027
31936
|
}
|
|
32028
31937
|
return classes.join(" ");
|
|
32029
31938
|
}, [button.isDismissing]);
|
|
32030
|
-
return (
|
|
32031
|
-
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" },
|
|
32032
|
-
button.isPressed && button.pressBehavior === "spinning" && (React$1.createElement("span", { className: "ws-button__spinner" })),
|
|
32033
|
-
React$1.createElement("span", { className: "ws-button__text" }, button.text))));
|
|
31939
|
+
return (require$$0.jsx("div", { className: containerClassName, children: require$$0.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" && (require$$0.jsx("span", { className: "ws-button__spinner" })), require$$0.jsx("span", { className: "ws-button__text", children: button.text })] }) }));
|
|
32034
31940
|
};
|
|
32035
31941
|
|
|
32036
31942
|
var ModalContent = function (_a) {
|
|
32037
31943
|
var onClose = _a.onClose, onReset = _a.onReset;
|
|
32038
|
-
return (
|
|
32039
|
-
React$1.createElement("div", { className: "modalBody" },
|
|
32040
|
-
React$1.createElement("h2", null, "Restart Conversation"),
|
|
32041
|
-
React$1.createElement("p", null, "Would you like to refresh and return to the starting point of the conversation?")),
|
|
32042
|
-
React$1.createElement("div", { className: "modalActions" },
|
|
32043
|
-
React$1.createElement("button", { onClick: onClose, className: "cancelBtn" }, "Cancel"),
|
|
32044
|
-
React$1.createElement("button", { onClick: onReset, className: "restartBtn" }, "Restart"))));
|
|
31944
|
+
return (require$$0.jsxs("div", { className: "modalContent", children: [require$$0.jsxs("div", { className: "modalBody", children: [require$$0.jsx("h2", { children: "Restart Conversation" }), require$$0.jsx("p", { children: "Would you like to refresh and return to the starting point of the conversation?" })] }), require$$0.jsxs("div", { className: "modalActions", children: [require$$0.jsx("button", { onClick: onClose, className: "cancelBtn", children: "Cancel" }), require$$0.jsx("button", { onClick: onReset, className: "restartBtn", children: "Restart" })] })] }));
|
|
32045
31945
|
};
|
|
32046
31946
|
|
|
31947
|
+
/**
|
|
31948
|
+
* Debounce delay for typing indicator in milliseconds.
|
|
31949
|
+
* After this delay of inactivity, the "stop typing" event will be sent.
|
|
31950
|
+
*/
|
|
31951
|
+
var TYPING_INDICATOR_DEBOUNCE_MS = 2000;
|
|
32047
31952
|
var ChatWidgetWrapper = function (props) {
|
|
32048
31953
|
var _a;
|
|
32049
|
-
var _b =
|
|
32050
|
-
var _c =
|
|
32051
|
-
var _d =
|
|
31954
|
+
var _b = require$$1.useState(props.config), rawConfig = _b[0], setRawConfig = _b[1];
|
|
31955
|
+
var _c = require$$1.useState(!!props.getConfig), configLoading = _c[0], setConfigLoading = _c[1];
|
|
31956
|
+
var _d = require$$1.useState(), configError = _d[0], setConfigError = _d[1];
|
|
32052
31957
|
// Load config from callback if provided
|
|
32053
|
-
|
|
31958
|
+
require$$1.useEffect(function () {
|
|
32054
31959
|
var cancelled = false;
|
|
32055
31960
|
if (props.getConfig) {
|
|
32056
31961
|
setConfigLoading(true);
|
|
@@ -32084,12 +31989,12 @@ var ChatWidgetWrapper = function (props) {
|
|
|
32084
31989
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32085
31990
|
}, [props.getConfig, props.config]);
|
|
32086
31991
|
var connection = useConnectionInfo(rawConfig);
|
|
32087
|
-
var config =
|
|
31992
|
+
var config = require$$1.useMemo(function () {
|
|
32088
31993
|
var _a;
|
|
32089
31994
|
return (__assign(__assign({}, rawConfig), { connection: connection, assetUrl: (_a = connection === null || connection === void 0 ? void 0 : connection.serverUrl) !== null && _a !== void 0 ? _a : defaultServerUrl, env: rawConfig }));
|
|
32090
31995
|
}, [connection, rawConfig]);
|
|
32091
31996
|
var token = reactRedux.useSelector(function (state) { return state.connection.token; });
|
|
32092
|
-
var options =
|
|
31997
|
+
var options = require$$1.useMemo(function () {
|
|
32093
31998
|
var configurableMessages = getConfigurableMessages();
|
|
32094
31999
|
if ((rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.configurableMessages) &&
|
|
32095
32000
|
Array.isArray(rawConfig.configurableMessages.items) &&
|
|
@@ -32114,20 +32019,13 @@ var ChatWidgetWrapper = function (props) {
|
|
|
32114
32019
|
var modeClass = "widget-container--".concat(mode);
|
|
32115
32020
|
// Show loading state while config is being fetched
|
|
32116
32021
|
if (configLoading) {
|
|
32117
|
-
return (
|
|
32118
|
-
React$1.createElement("div", { className: "xa-spinner-container visible" },
|
|
32119
|
-
React$1.createElement("div", { className: "xa-spinner" }))));
|
|
32022
|
+
return (require$$0.jsx("div", { className: "widget-container widget-container--loading ".concat(modeClass), children: require$$0.jsx("div", { className: "xa-spinner-container visible", children: require$$0.jsx("div", { className: "xa-spinner" }) }) }));
|
|
32120
32023
|
}
|
|
32121
32024
|
// Show error state if config failed to load
|
|
32122
32025
|
if (configError) {
|
|
32123
|
-
return (
|
|
32124
|
-
|
|
32125
|
-
|
|
32126
|
-
configError.message)));
|
|
32127
|
-
}
|
|
32128
|
-
return (React$1.createElement(ChatConfigContext.Provider, { value: config },
|
|
32129
|
-
React$1.createElement(ChatServerContext.Provider, { value: chatServer },
|
|
32130
|
-
React$1.createElement(ChatWidget, __assign({}, props, { config: rawConfig })))));
|
|
32026
|
+
return (require$$0.jsx("div", { className: "widget-container widget-container--error ".concat(modeClass), children: require$$0.jsxs("div", { className: "widget-error-message", children: ["Failed to load chat configuration: ", configError.message] }) }));
|
|
32027
|
+
}
|
|
32028
|
+
return (require$$0.jsx(ChatConfigContext.Provider, { value: config, children: require$$0.jsx(ChatServerContext.Provider, { value: chatServer, children: require$$0.jsx(ChatWidget, __assign({}, props, { config: rawConfig })) }) }));
|
|
32131
32029
|
};
|
|
32132
32030
|
var ChatWidget = function (props) {
|
|
32133
32031
|
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;
|
|
@@ -32136,7 +32034,7 @@ var ChatWidget = function (props) {
|
|
|
32136
32034
|
// From Redux
|
|
32137
32035
|
var chatState = reactRedux.useSelector(function (state) { return state; });
|
|
32138
32036
|
// Refresh modalReference
|
|
32139
|
-
var modalRef =
|
|
32037
|
+
var modalRef = require$$1.useRef({});
|
|
32140
32038
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
32141
32039
|
var dockedMode = mode === "docked";
|
|
32142
32040
|
var staticMode = mode === "static";
|
|
@@ -32158,13 +32056,17 @@ var ChatWidget = function (props) {
|
|
|
32158
32056
|
chatState.visuals = {};
|
|
32159
32057
|
}
|
|
32160
32058
|
// Our state - pull from storage
|
|
32161
|
-
var _8 =
|
|
32059
|
+
var _8 = require$$1.useState((!canMinimize && !canCancel) ||
|
|
32162
32060
|
// !!get("visible") ||
|
|
32163
32061
|
chatState.visuals.visible ||
|
|
32164
32062
|
(((_m = props.config) === null || _m === void 0 ? void 0 : _m.autoOpenOnWidth) &&
|
|
32165
32063
|
window.matchMedia("(min-width: ".concat((_o = props.config) === null || _o === void 0 ? void 0 : _o.autoOpenOnWidth, ")")).matches)), visible = _8[0], setVisibleState = _8[1];
|
|
32166
|
-
var _9 =
|
|
32167
|
-
|
|
32064
|
+
var _9 = require$$1.useState(false); _9[0]; var setTypingState = _9[1]; // false initially - state kept for potential external observers
|
|
32065
|
+
// Ref to track typing state for use in timeout callbacks
|
|
32066
|
+
var typingRef = require$$1.useRef(false);
|
|
32067
|
+
// Timeout ref for debouncing "stop typing" events
|
|
32068
|
+
var stopTypingTimeoutRef = require$$1.useRef(null);
|
|
32069
|
+
var chatServer = require$$1.useContext(ChatServerContext);
|
|
32168
32070
|
var patternsConfig = (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.autoOpenOnPattern) === null || _q === void 0 ? void 0 : _q.patterns;
|
|
32169
32071
|
var currentUrl = window.location.href;
|
|
32170
32072
|
var patternExist = patternsConfig && patternsConfig.length > 0;
|
|
@@ -32172,7 +32074,7 @@ var ChatWidget = function (props) {
|
|
|
32172
32074
|
var configWidth = (_s = (_r = props.config) === null || _r === void 0 ? void 0 : _r.autoOpenOnPattern) === null || _s === void 0 ? void 0 : _s.minimumWidth;
|
|
32173
32075
|
// eslint-disable-next-line no-restricted-globals
|
|
32174
32076
|
var currentWidth = screen.width;
|
|
32175
|
-
var setVisible =
|
|
32077
|
+
var setVisible = require$$1.useCallback(function (newVisible) {
|
|
32176
32078
|
if (staticMode) {
|
|
32177
32079
|
return;
|
|
32178
32080
|
}
|
|
@@ -32182,7 +32084,7 @@ var ChatWidget = function (props) {
|
|
|
32182
32084
|
visible: newVisible,
|
|
32183
32085
|
}));
|
|
32184
32086
|
}, [innerDispatch, staticMode]);
|
|
32185
|
-
|
|
32087
|
+
require$$1.useEffect(function () {
|
|
32186
32088
|
var _a, _b;
|
|
32187
32089
|
var handleKeyDown = function (event) {
|
|
32188
32090
|
var body = document.getElementsByTagName("body")[0];
|
|
@@ -32198,11 +32100,15 @@ var ChatWidget = function (props) {
|
|
|
32198
32100
|
}
|
|
32199
32101
|
return function () {
|
|
32200
32102
|
document.removeEventListener("keydown", handleKeyDown);
|
|
32103
|
+
// Cleanup typing timeout on unmount
|
|
32104
|
+
if (stopTypingTimeoutRef.current) {
|
|
32105
|
+
clearTimeout(stopTypingTimeoutRef.current);
|
|
32106
|
+
}
|
|
32201
32107
|
};
|
|
32202
32108
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32203
32109
|
}, []);
|
|
32204
|
-
var _10 =
|
|
32205
|
-
|
|
32110
|
+
var _10 = require$$1.useState(!document.hidden), isTabVisible = _10[0], setIsTabVisible = _10[1];
|
|
32111
|
+
require$$1.useEffect(function () {
|
|
32206
32112
|
var handleVisibilityChange = function () {
|
|
32207
32113
|
setIsTabVisible(!document.hidden);
|
|
32208
32114
|
};
|
|
@@ -32211,7 +32117,7 @@ var ChatWidget = function (props) {
|
|
|
32211
32117
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
32212
32118
|
};
|
|
32213
32119
|
}, []);
|
|
32214
|
-
|
|
32120
|
+
require$$1.useEffect(function () {
|
|
32215
32121
|
// Too early?
|
|
32216
32122
|
if (!chatServer) {
|
|
32217
32123
|
log("Tab visibility changed but no chatServer yet");
|
|
@@ -32226,7 +32132,7 @@ var ChatWidget = function (props) {
|
|
|
32226
32132
|
chatServer.wakeup();
|
|
32227
32133
|
}
|
|
32228
32134
|
}, [chatServer, innerDispatch, isTabVisible]);
|
|
32229
|
-
|
|
32135
|
+
require$$1.useEffect(function () {
|
|
32230
32136
|
// For reopen widget after move on same window
|
|
32231
32137
|
// if (get("opened")) {
|
|
32232
32138
|
// setVisible(true);
|
|
@@ -32254,19 +32160,34 @@ var ChatWidget = function (props) {
|
|
|
32254
32160
|
chatState.visuals.opened,
|
|
32255
32161
|
mode,
|
|
32256
32162
|
]);
|
|
32257
|
-
function
|
|
32258
|
-
if (!
|
|
32259
|
-
dispatch(sendTyping(true));
|
|
32260
|
-
setTypingState(true);
|
|
32261
|
-
}
|
|
32262
|
-
stopTyping();
|
|
32263
|
-
}
|
|
32264
|
-
function stopTyping() {
|
|
32265
|
-
if (!typing)
|
|
32163
|
+
var stopTyping = require$$1.useCallback(function () {
|
|
32164
|
+
if (!typingRef.current)
|
|
32266
32165
|
return;
|
|
32166
|
+
// Clear the timeout if it exists
|
|
32167
|
+
if (stopTypingTimeoutRef.current) {
|
|
32168
|
+
clearTimeout(stopTypingTimeoutRef.current);
|
|
32169
|
+
stopTypingTimeoutRef.current = null;
|
|
32170
|
+
}
|
|
32267
32171
|
dispatch(sendTyping(false));
|
|
32268
32172
|
setTypingState(false);
|
|
32269
|
-
|
|
32173
|
+
typingRef.current = false;
|
|
32174
|
+
}, [dispatch]);
|
|
32175
|
+
var handleOnChange = require$$1.useCallback(function () {
|
|
32176
|
+
// Send "typing" event only on first keystroke
|
|
32177
|
+
if (!typingRef.current) {
|
|
32178
|
+
dispatch(sendTyping(true));
|
|
32179
|
+
setTypingState(true);
|
|
32180
|
+
typingRef.current = true;
|
|
32181
|
+
}
|
|
32182
|
+
// Clear any existing timeout
|
|
32183
|
+
if (stopTypingTimeoutRef.current) {
|
|
32184
|
+
clearTimeout(stopTypingTimeoutRef.current);
|
|
32185
|
+
}
|
|
32186
|
+
// Set a new timeout to send "stop typing" after inactivity
|
|
32187
|
+
stopTypingTimeoutRef.current = window.setTimeout(function () {
|
|
32188
|
+
stopTyping();
|
|
32189
|
+
}, TYPING_INDICATOR_DEBOUNCE_MS);
|
|
32190
|
+
}, [dispatch, stopTyping]);
|
|
32270
32191
|
function handleSendMessage(msg) {
|
|
32271
32192
|
dispatch(sendMessage(msg));
|
|
32272
32193
|
}
|
|
@@ -32405,7 +32326,7 @@ var ChatWidget = function (props) {
|
|
|
32405
32326
|
var config = props.config, onConnectionStatusChange = props.onConnectionStatusChange;
|
|
32406
32327
|
useGreeting(!isOffline && !props.preChatFormEnabled && visible);
|
|
32407
32328
|
var connectionStatus = chatState.connection.connectionStatus;
|
|
32408
|
-
|
|
32329
|
+
require$$1.useEffect(function () {
|
|
32409
32330
|
if (onConnectionStatusChange) {
|
|
32410
32331
|
onConnectionStatusChange(connectionStatus);
|
|
32411
32332
|
}
|
|
@@ -32418,20 +32339,7 @@ var ChatWidget = function (props) {
|
|
|
32418
32339
|
avatarPath: config.avatarUrl,
|
|
32419
32340
|
display_name: "Agent",
|
|
32420
32341
|
};
|
|
32421
|
-
return (
|
|
32422
|
-
React$1.createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
32423
|
-
React$1.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
32424
|
-
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 }),
|
|
32425
|
-
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 }),
|
|
32426
|
-
React$1.createElement("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
32427
|
-
React$1.createElement("div", { className: "xa-spinner" })),
|
|
32428
|
-
connectionStatus === "offline" && React$1.createElement(ServerOffline, null),
|
|
32429
|
-
chatState.wsButton && visible && (React$1.createElement(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })),
|
|
32430
|
-
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 }),
|
|
32431
|
-
React$1.createElement("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick },
|
|
32432
|
-
React$1.createElement(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }))),
|
|
32433
|
-
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 }),
|
|
32434
|
-
React$1.createElement(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })));
|
|
32342
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.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 }), require$$0.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 }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.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 }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), require$$0.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 }), require$$0.jsx(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })] }));
|
|
32435
32343
|
};
|
|
32436
32344
|
|
|
32437
32345
|
// src/utils/formatProdErrorMessage.ts
|
|
@@ -33748,15 +33656,23 @@ function memberJoin(state, detail) {
|
|
|
33748
33656
|
// }
|
|
33749
33657
|
var agents = __assign({}, state.agents);
|
|
33750
33658
|
var prevAgentInfo = state.agents[detail.user.nick];
|
|
33751
|
-
agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false });
|
|
33659
|
+
agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
|
|
33752
33660
|
if (isAgent(detail.user.nick)) {
|
|
33753
|
-
|
|
33661
|
+
// Always show join messages with special visual features (divider or custom message)
|
|
33662
|
+
// These are important conversation markers, not routine join notifications
|
|
33663
|
+
var hasSpecialVisuals = detail.showDivider || detail.message;
|
|
33664
|
+
if ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) {
|
|
33754
33665
|
log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already joined. NOT adding duplicate join message to chat."));
|
|
33755
33666
|
}
|
|
33756
33667
|
else {
|
|
33757
|
-
|
|
33668
|
+
if (hasSpecialVisuals) {
|
|
33669
|
+
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."));
|
|
33670
|
+
}
|
|
33671
|
+
else {
|
|
33672
|
+
log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
|
|
33673
|
+
}
|
|
33758
33674
|
}
|
|
33759
|
-
return __assign(__assign({}, state), { isChatting: true, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? state.chats : joinMessages(state.chats, detail), agents: agents });
|
|
33675
|
+
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 });
|
|
33760
33676
|
}
|
|
33761
33677
|
else {
|
|
33762
33678
|
log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
|
|
@@ -33772,9 +33688,22 @@ function memberLeave(state, detail) {
|
|
|
33772
33688
|
var agentsJoined = Object.values(agents).filter(function (agent) { return agent.joined; });
|
|
33773
33689
|
var isChatting = agentsJoined.length > 0;
|
|
33774
33690
|
if (isAgent(detail.user.nick)) {
|
|
33691
|
+
var hasSpecialVisuals = detail.showDivider || detail.message;
|
|
33692
|
+
if (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) {
|
|
33693
|
+
if (hasSpecialVisuals) {
|
|
33694
|
+
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."));
|
|
33695
|
+
}
|
|
33696
|
+
else {
|
|
33697
|
+
log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
|
|
33698
|
+
}
|
|
33699
|
+
}
|
|
33700
|
+
else {
|
|
33701
|
+
log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already left. NOT adding duplicate leave message to chat."));
|
|
33702
|
+
}
|
|
33775
33703
|
return __assign(__assign({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
|
|
33776
33704
|
}
|
|
33777
33705
|
else {
|
|
33706
|
+
log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
|
|
33778
33707
|
return __assign(__assign({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
|
|
33779
33708
|
}
|
|
33780
33709
|
}
|
|
@@ -33800,6 +33729,10 @@ function resetReducer(state) {
|
|
|
33800
33729
|
visuals: {} });
|
|
33801
33730
|
}
|
|
33802
33731
|
|
|
33732
|
+
// Type guard for ChatSystemMessageDetail
|
|
33733
|
+
function isChatSystemMessage(chat) {
|
|
33734
|
+
return chat.type === "chat.systemmessage";
|
|
33735
|
+
}
|
|
33803
33736
|
// todo: create reducer (requires redux-thunk dependency)
|
|
33804
33737
|
function appendMessageToState(state, msg) {
|
|
33805
33738
|
state.chats = joinMessages(state.chats, msg);
|
|
@@ -33868,6 +33801,20 @@ function update(state, action) {
|
|
|
33868
33801
|
return memberJoin(state, action.detail);
|
|
33869
33802
|
case "chat.memberleave":
|
|
33870
33803
|
return memberLeave(state, action.detail);
|
|
33804
|
+
case "chat.systemmessage":
|
|
33805
|
+
// Add the system message to the chat
|
|
33806
|
+
appendMessageToState(newState, action.detail);
|
|
33807
|
+
return newState;
|
|
33808
|
+
case "chat.systemmessagedismiss":
|
|
33809
|
+
// Remove system message(s) with the specified id
|
|
33810
|
+
var dismissId_1 = action.detail.id;
|
|
33811
|
+
return __assign(__assign({}, newState), { chats: newState.chats.filter(function (chat) {
|
|
33812
|
+
// Keep all non-system messages, and system messages that don't match the id
|
|
33813
|
+
if (isChatSystemMessage(chat)) {
|
|
33814
|
+
return chat.id !== dismissId_1;
|
|
33815
|
+
}
|
|
33816
|
+
return true;
|
|
33817
|
+
}) });
|
|
33871
33818
|
case "chat.queue.position":
|
|
33872
33819
|
newState.queuePosition = action.detail.queuePosition;
|
|
33873
33820
|
return newState;
|
|
@@ -34047,7 +33994,7 @@ var ChatWidgetContainer = function (props) {
|
|
|
34047
33994
|
var _a, _b, _c, _d, _e, _f;
|
|
34048
33995
|
var messageMiddleware = useStandardMiddleware();
|
|
34049
33996
|
var connection = useServerConfig(props.config);
|
|
34050
|
-
var chatStore =
|
|
33997
|
+
var chatStore = require$$1.useMemo(function () {
|
|
34051
33998
|
var _a, _b, _c, _d, _e;
|
|
34052
33999
|
return createChatStore({
|
|
34053
34000
|
connection: connection,
|
|
@@ -34059,12 +34006,11 @@ var ChatWidgetContainer = function (props) {
|
|
|
34059
34006
|
});
|
|
34060
34007
|
}, [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]);
|
|
34061
34008
|
if ((_f = props.config) === null || _f === void 0 ? void 0 : _f.disabled) {
|
|
34062
|
-
return
|
|
34009
|
+
return require$$0.jsx(require$$0.Fragment, {});
|
|
34063
34010
|
}
|
|
34064
34011
|
var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
|
|
34065
34012
|
});
|
|
34066
|
-
return (
|
|
34067
|
-
React$1.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
|
|
34013
|
+
return (require$$0.jsx(reactRedux.Provider, { store: chatStore, children: require$$0.jsx(ChatWidgetWrapper, __assign({}, widgetProps)) }));
|
|
34068
34014
|
};
|
|
34069
34015
|
|
|
34070
34016
|
// Function to create a static reducer
|
|
@@ -34092,17 +34038,16 @@ function createStaticStore(state) {
|
|
|
34092
34038
|
|
|
34093
34039
|
var StaticChatWidgetContainer = function (props) {
|
|
34094
34040
|
var state = props.state;
|
|
34095
|
-
var store =
|
|
34041
|
+
var store = require$$1.useMemo(function () {
|
|
34096
34042
|
return createStaticStore(state);
|
|
34097
34043
|
}, [state]);
|
|
34098
|
-
var config =
|
|
34044
|
+
var config = require$$1.useMemo(function () {
|
|
34099
34045
|
return __assign(__assign({}, props.config), { connection: {
|
|
34100
34046
|
serverUrl: "",
|
|
34101
|
-
type: "local"
|
|
34047
|
+
type: "local",
|
|
34102
34048
|
} });
|
|
34103
34049
|
}, [props.config]);
|
|
34104
|
-
return (
|
|
34105
|
-
React$1.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
|
|
34050
|
+
return (require$$0.jsx(reactRedux.Provider, { store: store, children: require$$0.jsx(ChatWidgetWrapper, __assign({}, props, { config: config })) }));
|
|
34106
34051
|
};
|
|
34107
34052
|
|
|
34108
34053
|
function createStateFromMessages(messages) {
|
|
@@ -34112,13 +34057,13 @@ function createStateFromMessages(messages) {
|
|
|
34112
34057
|
|
|
34113
34058
|
var StaticMessagesChatWidgetContainer = function (props) {
|
|
34114
34059
|
var messages = props.messages;
|
|
34115
|
-
var state =
|
|
34060
|
+
var state = require$$1.useMemo(function () {
|
|
34116
34061
|
return createStateFromMessages(messages);
|
|
34117
34062
|
}, [messages]);
|
|
34118
|
-
return
|
|
34063
|
+
return require$$0.jsx(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config });
|
|
34119
34064
|
};
|
|
34120
34065
|
|
|
34121
|
-
exports.React =
|
|
34066
|
+
exports.React = require$$1;
|
|
34122
34067
|
exports.ActionButton = ActionButton;
|
|
34123
34068
|
exports.Avatar = Avatar;
|
|
34124
34069
|
exports.CardMiddleware = CardMiddleware;
|