@xapp/chat-widget 1.30.0 → 1.33.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/ChatMedia/ChatMedia.d.ts +4 -1
- package/dist/components/Input/Input.d.ts +5 -5
- package/dist/components/Input/Input.stories.d.ts +2 -1
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/SendButton/SendButton.d.ts +1 -0
- package/dist/components/Suggestions/Suggestions.d.ts +5 -4
- package/dist/components/Suggestions/Suggestions.stories.d.ts +0 -1
- package/dist/components/Suggestions/data.d.ts +2 -23
- package/dist/components/WidgetStylesheet/WidgetStylesheet.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +1109 -699
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1210 -800
- package/dist/index.js.map +1 -1
- package/dist/store/ChatStore.d.ts +1 -1
- package/dist/storybook/RichTextValues.d.ts +2 -0
- package/dist/utils/useDimensions.d.ts +2 -2
- package/dist/utils/useSuggestions.d.ts +4 -4
- package/dist/utils/useSuggestionsFetch.d.ts +2 -19
- package/package.json +24 -23
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useMemo, useContext, useCallback, useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
1
|
+
import React$1, { createContext, useMemo, useContext, useCallback, useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
2
2
|
export { default as React } from 'react';
|
|
3
3
|
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
4
4
|
import { createStore as createStore$1, applyMiddleware, compose } from 'redux';
|
|
@@ -11,25 +11,9 @@ var ActionButton = function (props) {
|
|
|
11
11
|
props.onClick(props.label);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
return (React.createElement("button", { type: props.type, className: "action-button "
|
|
14
|
+
return (React$1.createElement("button", { type: props.type, className: "action-button ".concat(props.addClass), onClick: handleClick }, props.label));
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
var paramsObj = {};
|
|
18
|
-
// todo: read only from xappScriptNode?
|
|
19
|
-
for (var _i = 0, _a = document.scripts; _i < _a.length; _i++) {
|
|
20
|
-
var script = _a[_i];
|
|
21
|
-
if (!script.src) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
var params = script.src.split("?");
|
|
25
|
-
if (params.length < 2) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
var searchParams = new URLSearchParams(params[1]);
|
|
29
|
-
searchParams.forEach(function (value, key) {
|
|
30
|
-
paramsObj[key] = value;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
17
|
var defaultServerUrl = process.env.SERVER_URL;
|
|
34
18
|
process.env.ACCOUNT_KEY;
|
|
35
19
|
var ChatConfigContext = createContext(null);
|
|
@@ -88,7 +72,7 @@ var __assign = function() {
|
|
|
88
72
|
return __assign.apply(this, arguments);
|
|
89
73
|
};
|
|
90
74
|
|
|
91
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
75
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
92
76
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
93
77
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
94
78
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -98,7 +82,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
98
82
|
});
|
|
99
83
|
}
|
|
100
84
|
|
|
101
|
-
function __generator(thisArg, body) {
|
|
85
|
+
function __generator$1(thisArg, body) {
|
|
102
86
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
103
87
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
104
88
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
@@ -126,7 +110,7 @@ function __generator(thisArg, body) {
|
|
|
126
110
|
}
|
|
127
111
|
}
|
|
128
112
|
|
|
129
|
-
function __spreadArray(to, from, pack) {
|
|
113
|
+
function __spreadArray$1(to, from, pack) {
|
|
130
114
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
131
115
|
if (ar || !(i in from)) {
|
|
132
116
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -1466,14 +1450,14 @@ function log() {
|
|
|
1466
1450
|
args[_i] = arguments[_i];
|
|
1467
1451
|
}
|
|
1468
1452
|
// TODO: only log in debug
|
|
1469
|
-
console.log.apply(console, __spreadArray([getCurrentDateString()], args, false));
|
|
1453
|
+
console.log.apply(console, __spreadArray$1([getCurrentDateString()], args, false));
|
|
1470
1454
|
}
|
|
1471
1455
|
function err() {
|
|
1472
1456
|
var args = [];
|
|
1473
1457
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1474
1458
|
args[_i] = arguments[_i];
|
|
1475
1459
|
}
|
|
1476
|
-
console.error.apply(console, __spreadArray([getCurrentDateString()], args, false));
|
|
1460
|
+
console.error.apply(console, __spreadArray$1([getCurrentDateString()], args, false));
|
|
1477
1461
|
}
|
|
1478
1462
|
var logOnce = function (key) {
|
|
1479
1463
|
var args = [];
|
|
@@ -1488,8 +1472,8 @@ var logOnce = function (key) {
|
|
|
1488
1472
|
};
|
|
1489
1473
|
|
|
1490
1474
|
function getVisitorSvg() {
|
|
1491
|
-
return (React.createElement("svg", { width: "16", height: "19", viewBox: "0 0 16 19" },
|
|
1492
|
-
React.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" })));
|
|
1475
|
+
return (React$1.createElement("svg", { width: "16", height: "19", viewBox: "0 0 16 19" },
|
|
1476
|
+
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" })));
|
|
1493
1477
|
}
|
|
1494
1478
|
var Avatar = function (props) {
|
|
1495
1479
|
var _a, _b;
|
|
@@ -1503,20 +1487,20 @@ var Avatar = function (props) {
|
|
|
1503
1487
|
if (avatarPath) {
|
|
1504
1488
|
// absolute or relative url (chat server may send relative, if it hosts the file)
|
|
1505
1489
|
if (avatarPath.startsWith("http")) {
|
|
1506
|
-
style.backgroundImage = "url('"
|
|
1490
|
+
style.backgroundImage = "url('".concat(avatarPath, "')");
|
|
1507
1491
|
}
|
|
1508
1492
|
else if (ctx === null || ctx === void 0 ? void 0 : ctx.assetUrl) {
|
|
1509
|
-
style.backgroundImage = "url('"
|
|
1493
|
+
style.backgroundImage = "url('".concat(ctx === null || ctx === void 0 ? void 0 : ctx.assetUrl, "/").concat(avatarPath, "')");
|
|
1510
1494
|
}
|
|
1511
1495
|
style.backgroundColor = "none";
|
|
1512
1496
|
}
|
|
1513
|
-
(_a = style.backgroundImage) !== null && _a !== void 0 ? _a : (style.backgroundImage = "url('"
|
|
1497
|
+
(_a = style.backgroundImage) !== null && _a !== void 0 ? _a : (style.backgroundImage = "url('".concat((_b = ctx === null || ctx === void 0 ? void 0 : ctx.env) === null || _b === void 0 ? void 0 : _b.avatarUrl, "')"));
|
|
1514
1498
|
}
|
|
1515
1499
|
else {
|
|
1516
1500
|
child = getVisitorSvg();
|
|
1517
1501
|
}
|
|
1518
1502
|
var hasImage = !!style.backgroundImage || !!child;
|
|
1519
|
-
return (React.createElement("div", { className: "avatar "
|
|
1503
|
+
return (React$1.createElement("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent" }, child));
|
|
1520
1504
|
};
|
|
1521
1505
|
|
|
1522
1506
|
/**
|
|
@@ -1543,10 +1527,10 @@ var OptionalLink = function (props) {
|
|
|
1543
1527
|
}
|
|
1544
1528
|
}, [url, onOpen]);
|
|
1545
1529
|
if (url) {
|
|
1546
|
-
return (React.createElement("div", { onClick: handleOpenUrl, className: className }, props.children));
|
|
1530
|
+
return (React$1.createElement("div", { onClick: handleOpenUrl, className: className }, props.children));
|
|
1547
1531
|
}
|
|
1548
1532
|
else {
|
|
1549
|
-
return (React.createElement("div", { onClick: props.onClick, className: className }, props.children));
|
|
1533
|
+
return (React$1.createElement("div", { onClick: props.onClick, className: className }, props.children));
|
|
1550
1534
|
}
|
|
1551
1535
|
};
|
|
1552
1536
|
|
|
@@ -1566,18 +1550,18 @@ var ActionItem = function (props) {
|
|
|
1566
1550
|
onExecute(item.title, item.token);
|
|
1567
1551
|
}
|
|
1568
1552
|
}, [item, onExecute, onButtonClick]);
|
|
1569
|
-
var className = "xappw-chat-action-item "
|
|
1570
|
-
return (React.createElement(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl }, props.children));
|
|
1553
|
+
var className = "xappw-chat-action-item ".concat(singleButton ? "xappw-chat-action-item--action" : "", " ").concat(props.className);
|
|
1554
|
+
return (React$1.createElement(OptionalLink, { className: className, url: getItemUrl(item), onClick: handleClick, onOpen: props.onOpenUrl }, props.children));
|
|
1571
1555
|
};
|
|
1572
1556
|
|
|
1573
1557
|
var ChatImage = function (props) {
|
|
1574
1558
|
var cleanUrl = props.imageUrl.replace(/'/g, "%27");
|
|
1575
|
-
var content = React.createElement("div", { className: "chat-card-img__content", style: { backgroundImage: "url("
|
|
1559
|
+
var content = React$1.createElement("div", { className: "chat-card-img__content", style: { backgroundImage: "url(".concat(cleanUrl, ")") } });
|
|
1576
1560
|
if (!props.imageActionUrl) {
|
|
1577
|
-
return (React.createElement("div", { className: "chat-card-img" }, content));
|
|
1561
|
+
return (React$1.createElement("div", { className: "chat-card-img" }, content));
|
|
1578
1562
|
}
|
|
1579
1563
|
else {
|
|
1580
|
-
return (React.createElement("a", { href: props.imageActionUrl, target: "_blank", rel: "noopener noreferrer", className: "chat-card-img" }, content));
|
|
1564
|
+
return (React$1.createElement("a", { href: props.imageActionUrl, target: "_blank", rel: "noopener noreferrer", className: "chat-card-img" }, content));
|
|
1581
1565
|
}
|
|
1582
1566
|
};
|
|
1583
1567
|
|
|
@@ -1588,13 +1572,13 @@ var ActionItemImage = function (props) {
|
|
|
1588
1572
|
var itemUrl = getItemUrl(item);
|
|
1589
1573
|
if (item.imageUrl) {
|
|
1590
1574
|
var imageActionUrl = !singleButton ? item.imageActionUrl : null;
|
|
1591
|
-
return (React.createElement("div", { className: props.className },
|
|
1592
|
-
React.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
|
|
1575
|
+
return (React$1.createElement("div", { className: props.className },
|
|
1576
|
+
React$1.createElement(ChatImage, { imageUrl: item.imageUrl, imageActionUrl: !itemUrl && imageActionUrl })));
|
|
1593
1577
|
}
|
|
1594
1578
|
else if (props.emptyImageVisible) {
|
|
1595
|
-
return (React.createElement("div", { className: props.className }));
|
|
1579
|
+
return (React$1.createElement("div", { className: props.className }));
|
|
1596
1580
|
}
|
|
1597
|
-
return React.createElement(React.Fragment, null);
|
|
1581
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
1598
1582
|
};
|
|
1599
1583
|
|
|
1600
1584
|
var ChatActionButtonInner = function (props) {
|
|
@@ -1602,44 +1586,44 @@ var ChatActionButtonInner = function (props) {
|
|
|
1602
1586
|
var handleButton = useCallback(function () {
|
|
1603
1587
|
onClick(button);
|
|
1604
1588
|
}, [button, onClick]);
|
|
1605
|
-
return (React.createElement(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label }));
|
|
1589
|
+
return (React$1.createElement(ActionButton, { onClick: handleButton, addClass: "button-card", label: button.label }));
|
|
1606
1590
|
};
|
|
1607
|
-
var ChatActionButton = React.memo(ChatActionButtonInner);
|
|
1591
|
+
var ChatActionButton = React$1.memo(ChatActionButtonInner);
|
|
1608
1592
|
|
|
1609
1593
|
var ChatActionButtonsInner = function (props) {
|
|
1610
|
-
return (React.createElement("div", { className: "buttons-container " + (props.className || "") }, props.buttons.map(function (button, i) {
|
|
1611
|
-
return React.createElement(ChatActionButton, { button: button, onClick: props.onClick, key: i });
|
|
1594
|
+
return (React$1.createElement("div", { className: "buttons-container " + (props.className || "") }, props.buttons.map(function (button, i) {
|
|
1595
|
+
return React$1.createElement(ChatActionButton, { button: button, onClick: props.onClick, key: i });
|
|
1612
1596
|
})));
|
|
1613
1597
|
};
|
|
1614
|
-
var ChatActionButtons = React.memo(ChatActionButtonsInner);
|
|
1598
|
+
var ChatActionButtons = React$1.memo(ChatActionButtonsInner);
|
|
1615
1599
|
|
|
1616
1600
|
var CarouselItem = function (props) {
|
|
1617
1601
|
var _a;
|
|
1618
1602
|
var item = props.item;
|
|
1619
|
-
return (React.createElement(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
1620
|
-
React.createElement("div", { className: "chat-list-item" },
|
|
1621
|
-
React.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
|
|
1622
|
-
item.title && React.createElement("div", { className: "chat-list-item__title" },
|
|
1623
|
-
React.createElement("span", null, item.title)),
|
|
1624
|
-
item.subTitle && React.createElement("div", { className: "chat-list-item__subtitle" },
|
|
1625
|
-
React.createElement("span", null, item.subTitle)),
|
|
1626
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(ChatActionButtons, { className: "chat-list-item__actions", buttons: item.buttons, onClick: props.onButtonClick }))));
|
|
1603
|
+
return (React$1.createElement(ActionItem, { className: "chat-list-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
1604
|
+
React$1.createElement("div", { className: "chat-list-item" },
|
|
1605
|
+
React$1.createElement(ActionItemImage, { item: item, className: "chat-list-item__img", emptyImageVisible: props.emptyImageVisible }),
|
|
1606
|
+
item.title && React$1.createElement("div", { className: "chat-list-item__title" },
|
|
1607
|
+
React$1.createElement("span", null, item.title)),
|
|
1608
|
+
item.subTitle && React$1.createElement("div", { className: "chat-list-item__subtitle" },
|
|
1609
|
+
React$1.createElement("span", null, item.subTitle)),
|
|
1610
|
+
!!((_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 }))));
|
|
1627
1611
|
};
|
|
1628
1612
|
|
|
1629
1613
|
function getLeftArrowSvg() {
|
|
1630
|
-
return (React.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1631
|
-
React.createElement("path", { d: "M 2.5 -15 L -2.5 0 L 2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
1614
|
+
return (React$1.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1615
|
+
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" })));
|
|
1632
1616
|
}
|
|
1633
1617
|
var ChevronLeft = function (props) {
|
|
1634
|
-
return (React.createElement("div", { onClick: props.onClick, className: "chevron" }, getLeftArrowSvg()));
|
|
1618
|
+
return (React$1.createElement("div", { onClick: props.onClick, className: "chevron" }, getLeftArrowSvg()));
|
|
1635
1619
|
};
|
|
1636
1620
|
|
|
1637
1621
|
function getRightArrowSvg() {
|
|
1638
|
-
return (React.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1639
|
-
React.createElement("path", { d: "M -2.5 -15 L 2.5 0 L -2.5 15", stroke: "currentColor", strokeLinecap: "square", strokeWidth: "4px", fill: "none" })));
|
|
1622
|
+
return (React$1.createElement("svg", { viewBox: "-5 -18 10 36" },
|
|
1623
|
+
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" })));
|
|
1640
1624
|
}
|
|
1641
1625
|
var ChevronRight = function (props) {
|
|
1642
|
-
return (React.createElement("div", { onClick: props.onClick, className: "chevron" }, getRightArrowSvg()));
|
|
1626
|
+
return (React$1.createElement("div", { onClick: props.onClick, className: "chevron" }, getRightArrowSvg()));
|
|
1643
1627
|
};
|
|
1644
1628
|
|
|
1645
1629
|
var Carousel = function (props) {
|
|
@@ -1677,19 +1661,19 @@ var Carousel = function (props) {
|
|
|
1677
1661
|
}
|
|
1678
1662
|
var hasImage = props.list.items.some(function (item) { return item.imageUrl; });
|
|
1679
1663
|
var listItems = props.list.items.map(function (item, itemIndex) {
|
|
1680
|
-
return (React.createElement("div", { className: "xappw-carousel-items__item", key: "item-key-"
|
|
1681
|
-
React.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
1664
|
+
return (React$1.createElement("div", { className: "xappw-carousel-items__item", key: "item-key-".concat(itemIndex) },
|
|
1665
|
+
React$1.createElement(CarouselItem, { item: item, emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
1682
1666
|
});
|
|
1683
|
-
return (React.createElement("div", { className: "xappw-carousel" },
|
|
1684
|
-
React.createElement("div", { className: "xappw-carousel__prev" },
|
|
1685
|
-
React.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } })),
|
|
1686
|
-
React.createElement("div", { ref: listRef, className: "xappw-carousel-items" }, listItems),
|
|
1687
|
-
React.createElement("div", { className: "xappw-carousel__next" },
|
|
1688
|
-
React.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } }))));
|
|
1667
|
+
return (React$1.createElement("div", { className: "xappw-carousel" },
|
|
1668
|
+
React$1.createElement("div", { className: "xappw-carousel__prev" },
|
|
1669
|
+
React$1.createElement(ChevronLeft, { onClick: function () { return scrollMe(-1); } })),
|
|
1670
|
+
React$1.createElement("div", { ref: listRef, className: "xappw-carousel-items" }, listItems),
|
|
1671
|
+
React$1.createElement("div", { className: "xappw-carousel__next" },
|
|
1672
|
+
React$1.createElement(ChevronRight, { onClick: function () { return scrollMe(1); } }))));
|
|
1689
1673
|
};
|
|
1690
1674
|
|
|
1691
1675
|
function useDimensions() {
|
|
1692
|
-
var ref = useRef();
|
|
1676
|
+
var ref = useRef(null);
|
|
1693
1677
|
var _a = useState(), dimensions = _a[0], setDimensions = _a[1];
|
|
1694
1678
|
useLayoutEffect(function () {
|
|
1695
1679
|
var _a, _b;
|
|
@@ -1778,22 +1762,22 @@ function getTailSvgPath$1(props, viewport) {
|
|
|
1778
1762
|
start: far,
|
|
1779
1763
|
direction: rightDirection
|
|
1780
1764
|
});
|
|
1781
|
-
return "m "
|
|
1765
|
+
return "m ".concat(far.x, " ").concat(far.y, " L ").concat(left.x, " ").concat(left.y, " L ").concat(right.x, " ").concat(right.y, " z");
|
|
1782
1766
|
}
|
|
1783
1767
|
var CtaBubbleTail = function (props) {
|
|
1784
1768
|
var _a, _b;
|
|
1785
1769
|
var _c = useDimensions(), ref = _c[0], rect = _c[1];
|
|
1786
1770
|
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 };
|
|
1787
|
-
return React.createElement("div", { ref: ref, className: "cta-bubble__tail" },
|
|
1788
|
-
React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 "
|
|
1789
|
-
React.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" })));
|
|
1771
|
+
return React$1.createElement("div", { ref: ref, className: "cta-bubble__tail" },
|
|
1772
|
+
React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 ".concat(viewPort.x, " ").concat(viewPort.y) },
|
|
1773
|
+
React$1.createElement("path", { d: getTailSvgPath$1(props, viewPort), fill: "currentColor" })));
|
|
1790
1774
|
};
|
|
1791
1775
|
var CtaBubble = function (props) {
|
|
1792
1776
|
var _a, _b;
|
|
1793
1777
|
var _c = useDimensions(), ref = _c[0], rect = _c[1];
|
|
1794
|
-
return (React.createElement("div", { ref: ref, className: "cta-bubble", onClick: props.onClick },
|
|
1795
|
-
React.createElement(CtaBubbleTail, { width: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, height: (_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0, direction: 60, angle: 45, length: 16 }),
|
|
1796
|
-
React.createElement("div", { className: "cta-bubble__content" }, props.children)));
|
|
1778
|
+
return (React$1.createElement("div", { ref: ref, className: "cta-bubble", onClick: props.onClick },
|
|
1779
|
+
React$1.createElement(CtaBubbleTail, { width: (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0, height: (_b = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _b !== void 0 ? _b : 0, direction: 60, angle: 45, length: 16 }),
|
|
1780
|
+
React$1.createElement("div", { className: "cta-bubble__content" }, props.children)));
|
|
1797
1781
|
};
|
|
1798
1782
|
|
|
1799
1783
|
var CtaBubbleContainer = function (props) {
|
|
@@ -1824,16 +1808,16 @@ var CtaBubbleContainer = function (props) {
|
|
|
1824
1808
|
clearTimeout(handle);
|
|
1825
1809
|
};
|
|
1826
1810
|
}, [startTime, timeout]);
|
|
1827
|
-
return (React.createElement(React.Fragment, null, props.visible && !pastDue && React.createElement(CtaBubble, { onClick: props.onClick }, props.children)));
|
|
1811
|
+
return (React$1.createElement(React$1.Fragment, null, props.visible && !pastDue && React$1.createElement(CtaBubble, { onClick: props.onClick }, props.children)));
|
|
1828
1812
|
};
|
|
1829
1813
|
|
|
1830
1814
|
var ChatButton = function (props) {
|
|
1831
|
-
return (React.createElement("div", { className: "chat-button "
|
|
1832
|
-
React.createElement("div", { className: "chat-button__btn", onClick: props.onClick },
|
|
1833
|
-
React.createElement("svg", { width: "22", height: "22", viewBox: "0 0 22 22" },
|
|
1834
|
-
React.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" }))),
|
|
1835
|
-
props.config && props.config.message && (React.createElement("div", { className: "chat-button__cta" },
|
|
1836
|
-
React.createElement(CtaBubbleContainer, { timeout: props.config.timeout, visible: !props.visible, onClick: props.onClick }, props.config.message)))));
|
|
1815
|
+
return (React$1.createElement("div", { className: "chat-button ".concat(props.addClass) },
|
|
1816
|
+
React$1.createElement("div", { className: "chat-button__btn", onClick: props.onClick },
|
|
1817
|
+
React$1.createElement("svg", { width: "22", height: "22", viewBox: "0 0 22 22" },
|
|
1818
|
+
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" }))),
|
|
1819
|
+
props.config && props.config.message && (React$1.createElement("div", { className: "chat-button__cta" },
|
|
1820
|
+
React$1.createElement(CtaBubbleContainer, { timeout: props.config.timeout, visible: !props.visible, onClick: props.onClick }, props.config.message)))));
|
|
1837
1821
|
};
|
|
1838
1822
|
|
|
1839
1823
|
var ChatCard = function (props) {
|
|
@@ -1843,39 +1827,39 @@ var ChatCard = function (props) {
|
|
|
1843
1827
|
var image;
|
|
1844
1828
|
var content;
|
|
1845
1829
|
if (card.imageUrl) {
|
|
1846
|
-
image = React.createElement("div", { className: "chat-card-container__img" },
|
|
1847
|
-
React.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
|
|
1830
|
+
image = React$1.createElement("div", { className: "chat-card-container__img" },
|
|
1831
|
+
React$1.createElement(ChatImage, { imageUrl: card.imageUrl, imageActionUrl: card.imageActionUrl }));
|
|
1848
1832
|
}
|
|
1849
1833
|
if (card.title) {
|
|
1850
1834
|
title =
|
|
1851
|
-
React.createElement("div", { className: "chat-card-title" },
|
|
1852
|
-
React.createElement("span", null, card.title));
|
|
1835
|
+
React$1.createElement("div", { className: "chat-card-title" },
|
|
1836
|
+
React$1.createElement("span", null, card.title));
|
|
1853
1837
|
}
|
|
1854
1838
|
if (card.content) {
|
|
1855
1839
|
content =
|
|
1856
|
-
React.createElement("div", { className: "chat-card-sub-title" },
|
|
1857
|
-
React.createElement("span", null, card.content));
|
|
1840
|
+
React$1.createElement("div", { className: "chat-card-sub-title" },
|
|
1841
|
+
React$1.createElement("span", null, card.content));
|
|
1858
1842
|
}
|
|
1859
|
-
return (React.createElement("div", { className: "chat-card-container" },
|
|
1843
|
+
return (React$1.createElement("div", { className: "chat-card-container" },
|
|
1860
1844
|
image,
|
|
1861
1845
|
title,
|
|
1862
1846
|
content,
|
|
1863
|
-
!!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
|
|
1847
|
+
!!((_a = card.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: card.buttons, onClick: props.onButtonClick })));
|
|
1864
1848
|
};
|
|
1865
1849
|
|
|
1866
1850
|
var ChatChip = function (props) {
|
|
1867
1851
|
var option = props.option;
|
|
1868
1852
|
var className = option.actionUrl ? "chat-chip chat-chip-link" : "chat-chip";
|
|
1869
|
-
return (React.createElement("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className },
|
|
1870
|
-
React.createElement("span", null, option.label || option)));
|
|
1853
|
+
return (React$1.createElement("div", { onClick: function () { return props === null || props === void 0 ? void 0 : props.onClick(option); }, className: className },
|
|
1854
|
+
React$1.createElement("span", null, option.label || option)));
|
|
1871
1855
|
};
|
|
1872
1856
|
|
|
1873
1857
|
/**
|
|
1874
1858
|
* Render option list. We just follow the order.
|
|
1875
1859
|
*/
|
|
1876
1860
|
var ChatChips = function (props) {
|
|
1877
|
-
return (React.createElement("div", { className: "chat-chips" }, props.options.map(function (option, i) {
|
|
1878
|
-
return React.createElement(ChatChip, { key: i, onClick: props.onOptionClick, option: option });
|
|
1861
|
+
return (React$1.createElement("div", { className: "chat-chips" }, props.options.map(function (option, i) {
|
|
1862
|
+
return React$1.createElement(ChatChip, { key: i, onClick: props.onOptionClick, option: option });
|
|
1879
1863
|
})));
|
|
1880
1864
|
};
|
|
1881
1865
|
|
|
@@ -1900,7 +1884,7 @@ function resolveUrlPolicy(url, config) {
|
|
|
1900
1884
|
}
|
|
1901
1885
|
|
|
1902
1886
|
// compile time full switch-case verification
|
|
1903
|
-
function throwBadKind(x) {
|
|
1887
|
+
function throwBadKind$1(x) {
|
|
1904
1888
|
throw new Error("Unknown kind " + x);
|
|
1905
1889
|
}
|
|
1906
1890
|
|
|
@@ -1908,7 +1892,7 @@ function execute(url, behavior) {
|
|
|
1908
1892
|
var type = behavior.type;
|
|
1909
1893
|
switch (type) {
|
|
1910
1894
|
case "newWindow":
|
|
1911
|
-
window.open(url, "callout-option", "toolbar=0,status=0,width="
|
|
1895
|
+
window.open(url, "callout-option", "toolbar=0,status=0,width=".concat(behavior.width || 1000, ",height=").concat(behavior.height || 700));
|
|
1912
1896
|
break;
|
|
1913
1897
|
case "newTab":
|
|
1914
1898
|
window.open(url, "_blank");
|
|
@@ -1917,7 +1901,7 @@ function execute(url, behavior) {
|
|
|
1917
1901
|
window.open(url, "_self");
|
|
1918
1902
|
break;
|
|
1919
1903
|
default:
|
|
1920
|
-
throwBadKind(type);
|
|
1904
|
+
throwBadKind$1(type);
|
|
1921
1905
|
}
|
|
1922
1906
|
}
|
|
1923
1907
|
function useOpenUrlCallback() {
|
|
@@ -1950,7 +1934,7 @@ function executeAction(text, token) {
|
|
|
1950
1934
|
});
|
|
1951
1935
|
var visitor = getState().visitor;
|
|
1952
1936
|
dispatch(writeMessage({
|
|
1953
|
-
text: !token ? text : text
|
|
1937
|
+
text: !token ? text : "".concat(text, " (from the list)")
|
|
1954
1938
|
}, visitor));
|
|
1955
1939
|
}; };
|
|
1956
1940
|
}
|
|
@@ -2090,31 +2074,31 @@ var LogChat = /** @class */ (function () {
|
|
|
2090
2074
|
this.inner.init(dispatch);
|
|
2091
2075
|
};
|
|
2092
2076
|
LogChat.prototype.sendOfflineMsg = function (message, cb) {
|
|
2093
|
-
log("CLIENT: sendOfflineMsg: "
|
|
2077
|
+
log("CLIENT: sendOfflineMsg: ".concat(JSON.stringify(message)));
|
|
2094
2078
|
this.inner.sendOfflineMsg(message, cb);
|
|
2095
2079
|
};
|
|
2096
2080
|
LogChat.prototype.sendChatMsg = function (message, cb) {
|
|
2097
|
-
log("CLIENT: sendChatMsg: "
|
|
2081
|
+
log("CLIENT: sendChatMsg: ".concat(JSON.stringify(message)));
|
|
2098
2082
|
this.inner.sendChatMsg(message, cb);
|
|
2099
2083
|
};
|
|
2100
2084
|
LogChat.prototype.sendChatMsgRequest = function (message, cb) {
|
|
2101
|
-
log("CLIENT: sendChatMsgRequest: "
|
|
2085
|
+
log("CLIENT: sendChatMsgRequest: ".concat(JSON.stringify(message)));
|
|
2102
2086
|
this.inner.sendChatMsgRequest(message, cb);
|
|
2103
2087
|
};
|
|
2104
2088
|
LogChat.prototype.sendTyping = function (isTyping) {
|
|
2105
|
-
log("CLIENT: sendTyping: "
|
|
2089
|
+
log("CLIENT: sendTyping: ".concat(JSON.stringify(isTyping)));
|
|
2106
2090
|
this.inner.sendTyping(isTyping);
|
|
2107
2091
|
};
|
|
2108
2092
|
LogChat.prototype.setVisitorInfo = function (visitorInfo, cb) {
|
|
2109
|
-
log("CLIENT: setVisitorInfo: "
|
|
2093
|
+
log("CLIENT: setVisitorInfo: ".concat(JSON.stringify(visitorInfo)));
|
|
2110
2094
|
this.inner.setVisitorInfo(visitorInfo, cb);
|
|
2111
2095
|
};
|
|
2112
2096
|
LogChat.prototype.sendChatRating = function (rating) {
|
|
2113
|
-
log("CLIENT: sendChatRating: "
|
|
2097
|
+
log("CLIENT: sendChatRating: ".concat(JSON.stringify(rating)));
|
|
2114
2098
|
this.inner.sendChatRating(rating);
|
|
2115
2099
|
};
|
|
2116
2100
|
LogChat.prototype.sendFile = function (file, cb) {
|
|
2117
|
-
log("CLIENT: sendFile: "
|
|
2101
|
+
log("CLIENT: sendFile: ".concat(JSON.stringify(file)));
|
|
2118
2102
|
this.inner.sendFile(file, cb);
|
|
2119
2103
|
};
|
|
2120
2104
|
LogChat.prototype.markAsRead = function () {
|
|
@@ -2132,20 +2116,651 @@ var LogChat = /** @class */ (function () {
|
|
|
2132
2116
|
return LogChat;
|
|
2133
2117
|
}());
|
|
2134
2118
|
|
|
2119
|
+
var dist = {};
|
|
2120
|
+
|
|
2121
|
+
Object.defineProperty(dist, '__esModule', { value: true });
|
|
2122
|
+
|
|
2123
|
+
var React = React$1;
|
|
2124
|
+
|
|
2125
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
2126
|
+
|
|
2127
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
2128
|
+
|
|
2129
|
+
var IconButton = function (props) {
|
|
2130
|
+
var type = props.type || "button";
|
|
2131
|
+
var Icon = props.icon;
|
|
2132
|
+
return (React__default["default"].createElement("button", { type: type, className: "xapp-search-icon-button ".concat(props.className || ""), onClick: props.onClick },
|
|
2133
|
+
React__default["default"].createElement("div", { className: "xapp-search-icon-button__content" },
|
|
2134
|
+
React__default["default"].createElement(Icon, null))));
|
|
2135
|
+
};
|
|
2136
|
+
|
|
2137
|
+
var MessageBubble = function (props) {
|
|
2138
|
+
return (React__default["default"].createElement("div", { className: "xappw-message-bubble" }, props.children));
|
|
2139
|
+
};
|
|
2140
|
+
|
|
2141
|
+
// compile time full switch-case verification
|
|
2142
|
+
function throwBadKind(x) {
|
|
2143
|
+
throw new Error("Unknown kind " + x);
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
var RichTextBoldSpan = function (props) {
|
|
2147
|
+
var format = props.format, text = props.text;
|
|
2148
|
+
return (React__default["default"].createElement("span", { "data-rich-text-type": "bold", className: "xapp-search-rich-text-bold-span" }, text.substring(format.start, format.end)));
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
var RichTextInputSpan = function (props) {
|
|
2152
|
+
var format = props.format, text = props.text, readOnly = props.readOnly;
|
|
2153
|
+
var defaultValue = format.text || text.substring(format.start, format.end);
|
|
2154
|
+
var _a = React.useState(defaultValue), value = _a[0], setValue = _a[1];
|
|
2155
|
+
var handleChange = React.useCallback(function (ev) {
|
|
2156
|
+
setValue(ev.target.value);
|
|
2157
|
+
}, []);
|
|
2158
|
+
if (readOnly) {
|
|
2159
|
+
return (React__default["default"].createElement("span", { className: "xapp-search-rich-text-input-span xapp-search-rich-text-input-span--readonly" }, defaultValue));
|
|
2160
|
+
}
|
|
2161
|
+
return (React__default["default"].createElement("input", { type: "text", value: value, className: "xapp-search-rich-text-input-span", "data-rich-text-type": "inputText", onChange: handleChange, readOnly: readOnly }));
|
|
2162
|
+
};
|
|
2163
|
+
|
|
2164
|
+
var RichTextNormalSpan = function (props) {
|
|
2165
|
+
var format = props.format, text = props.text;
|
|
2166
|
+
return (React__default["default"].createElement("span", { "data-rich-text-type": "normal", className: "xapp-search-rich-text-normal-span" }, text.substring(format.start, format.end)));
|
|
2167
|
+
};
|
|
2168
|
+
|
|
2169
|
+
var RichTextSpan = function (props) {
|
|
2170
|
+
var format = props.format, text = props.text, readOnly = props.readOnly;
|
|
2171
|
+
var type = format.type;
|
|
2172
|
+
switch (type) {
|
|
2173
|
+
case "normal":
|
|
2174
|
+
return (React__default["default"].createElement(RichTextNormalSpan, { text: text, format: format, readOnly: readOnly }));
|
|
2175
|
+
case "bold":
|
|
2176
|
+
return (React__default["default"].createElement(RichTextBoldSpan, { text: text, format: format, readOnly: readOnly }));
|
|
2177
|
+
case "inputText":
|
|
2178
|
+
return (React__default["default"].createElement(RichTextInputSpan, { text: text, format: format, readOnly: readOnly }));
|
|
2179
|
+
default:
|
|
2180
|
+
throwBadKind(type);
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
|
|
2184
|
+
function cleanRichTextValue(value) {
|
|
2185
|
+
var text = value.text, formats = value.formats;
|
|
2186
|
+
var newFormats = [];
|
|
2187
|
+
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
2188
|
+
var format = formats_1[_i];
|
|
2189
|
+
var type = format.type;
|
|
2190
|
+
switch (type) {
|
|
2191
|
+
case "normal":
|
|
2192
|
+
continue;
|
|
2193
|
+
case "inputText":
|
|
2194
|
+
newFormats.push(format);
|
|
2195
|
+
break;
|
|
2196
|
+
case "bold":
|
|
2197
|
+
if (newFormats.length > 0) {
|
|
2198
|
+
var prev = newFormats[newFormats.length - 1];
|
|
2199
|
+
if (prev.type === type && prev.end === format.start) {
|
|
2200
|
+
newFormats.pop();
|
|
2201
|
+
newFormats.push({
|
|
2202
|
+
type: type,
|
|
2203
|
+
start: prev.start,
|
|
2204
|
+
end: format.end
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
else {
|
|
2209
|
+
newFormats.push(format);
|
|
2210
|
+
}
|
|
2211
|
+
break;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
return {
|
|
2215
|
+
text: text,
|
|
2216
|
+
formats: newFormats
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
function extendFormat(formats, length) {
|
|
2221
|
+
var res = [];
|
|
2222
|
+
var walkerIndex = 0;
|
|
2223
|
+
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
2224
|
+
var format = formats_1[_i];
|
|
2225
|
+
var start = format.start, end = format.end, type = format.type, text = format.text;
|
|
2226
|
+
if (walkerIndex < start) {
|
|
2227
|
+
res.push({
|
|
2228
|
+
type: "normal",
|
|
2229
|
+
start: walkerIndex,
|
|
2230
|
+
end: start
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
res.push({
|
|
2234
|
+
type: type,
|
|
2235
|
+
start: start,
|
|
2236
|
+
end: end,
|
|
2237
|
+
text: text
|
|
2238
|
+
});
|
|
2239
|
+
walkerIndex = end;
|
|
2240
|
+
}
|
|
2241
|
+
if (walkerIndex < length) {
|
|
2242
|
+
res.push({
|
|
2243
|
+
type: "normal",
|
|
2244
|
+
start: walkerIndex,
|
|
2245
|
+
end: length
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
return res;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
function parseContent(node) {
|
|
2252
|
+
var children = node.childNodes;
|
|
2253
|
+
var formats = [];
|
|
2254
|
+
var text = "";
|
|
2255
|
+
children.forEach(function (child) {
|
|
2256
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
2257
|
+
var node_1 = child;
|
|
2258
|
+
var innerText = node_1.tagName === "INPUT" ? node_1.value : node_1.innerText;
|
|
2259
|
+
var type = node_1.dataset.richTextType;
|
|
2260
|
+
formats.push({
|
|
2261
|
+
type: type,
|
|
2262
|
+
start: text.length,
|
|
2263
|
+
end: text.length + innerText.length
|
|
2264
|
+
});
|
|
2265
|
+
text += innerText;
|
|
2266
|
+
}
|
|
2267
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
2268
|
+
var node_2 = child;
|
|
2269
|
+
var innerText = node_2.nodeValue;
|
|
2270
|
+
if (innerText) {
|
|
2271
|
+
formats.push({
|
|
2272
|
+
type: "normal",
|
|
2273
|
+
start: text.length,
|
|
2274
|
+
end: text.length + innerText.length
|
|
2275
|
+
});
|
|
2276
|
+
text += innerText;
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
return cleanRichTextValue({
|
|
2281
|
+
text: text,
|
|
2282
|
+
formats: formats
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
function cleanContent(node) {
|
|
2286
|
+
var _a;
|
|
2287
|
+
var trash = [];
|
|
2288
|
+
var raw = node.childNodes;
|
|
2289
|
+
for (var i = 0; i < raw.length; i++) {
|
|
2290
|
+
var c = raw.item(i);
|
|
2291
|
+
if ((c === null || c === void 0 ? void 0 : c.nodeType) === Node.TEXT_NODE) {
|
|
2292
|
+
trash.push(c);
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
for (var _i = 0, trash_1 = trash; _i < trash_1.length; _i++) {
|
|
2296
|
+
var c = trash_1[_i];
|
|
2297
|
+
try {
|
|
2298
|
+
(_a = c.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(c);
|
|
2299
|
+
}
|
|
2300
|
+
catch (_b) {
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
var RichText = function (props) {
|
|
2305
|
+
var value = props.value, className = props.className, readOnly = props.readOnly, onInput = props.onInput, onChange = props.onChange;
|
|
2306
|
+
var formatsRaw = value.formats, text = value.text;
|
|
2307
|
+
var formats = React.useMemo(function () { return extendFormat(formatsRaw, text.length); }, [formatsRaw, text.length]);
|
|
2308
|
+
var handleInput = React.useCallback(function (ev) {
|
|
2309
|
+
var target = ev.currentTarget;
|
|
2310
|
+
var newValue = parseContent(target);
|
|
2311
|
+
if (onInput) {
|
|
2312
|
+
onInput(newValue);
|
|
2313
|
+
}
|
|
2314
|
+
}, [onInput]);
|
|
2315
|
+
var handleBlur = React.useCallback(function (ev) {
|
|
2316
|
+
var target = ev.currentTarget;
|
|
2317
|
+
var newValue = parseContent(target);
|
|
2318
|
+
cleanContent(target);
|
|
2319
|
+
if (onChange) {
|
|
2320
|
+
onChange(newValue);
|
|
2321
|
+
}
|
|
2322
|
+
}, [onChange]);
|
|
2323
|
+
return (React__default["default"].createElement("div", { id: props.id, className: "xapp-search-rich-text ".concat(className || ""), contentEditable: !readOnly, suppressContentEditableWarning: true, onInput: handleInput, onBlur: handleBlur }, formats.map(function (format, index) { return (React__default["default"].createElement(RichTextSpan, { format: format, text: text, key: index, readOnly: readOnly })); })));
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
var RichInput = function (props) {
|
|
2327
|
+
var id = props.id, value = props.value, type = props.type, autoFocus = props.autoFocus, onChange = props.onChange, onInput = props.onInput, onKeyDown = props.onKeyDown, onSearch = props.onSearch;
|
|
2328
|
+
var rich = value.formats.some(function (f) { return f.type === "inputText"; });
|
|
2329
|
+
var handleChange = React.useCallback(function (ev) {
|
|
2330
|
+
onChange({
|
|
2331
|
+
text: ev.target.value,
|
|
2332
|
+
formats: []
|
|
2333
|
+
});
|
|
2334
|
+
}, [onChange]);
|
|
2335
|
+
var handleRichChange = React.useCallback(function (val) {
|
|
2336
|
+
onChange(val);
|
|
2337
|
+
}, [onChange]);
|
|
2338
|
+
var handleInput = React.useCallback(function (ev) {
|
|
2339
|
+
if (onInput) {
|
|
2340
|
+
onInput({
|
|
2341
|
+
text: ev.target.value,
|
|
2342
|
+
formats: []
|
|
2343
|
+
});
|
|
2344
|
+
}
|
|
2345
|
+
}, [onInput]);
|
|
2346
|
+
var handleRichInput = React.useCallback(function (val) {
|
|
2347
|
+
if (onInput) {
|
|
2348
|
+
onInput(val);
|
|
2349
|
+
}
|
|
2350
|
+
}, [onInput]);
|
|
2351
|
+
var handleKeyDown = React.useCallback(function (event) {
|
|
2352
|
+
if (onKeyDown) {
|
|
2353
|
+
onKeyDown(event);
|
|
2354
|
+
}
|
|
2355
|
+
}, [onKeyDown]);
|
|
2356
|
+
var inputRef = React.useRef(null);
|
|
2357
|
+
var inputNode = inputRef.current;
|
|
2358
|
+
React.useEffect(function () {
|
|
2359
|
+
if (inputNode && onSearch) {
|
|
2360
|
+
var handler_1 = function (ev) {
|
|
2361
|
+
var target = ev.target;
|
|
2362
|
+
if (target) {
|
|
2363
|
+
onSearch({
|
|
2364
|
+
text: target.value,
|
|
2365
|
+
formats: []
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
inputNode.addEventListener("search", handler_1);
|
|
2370
|
+
return function () {
|
|
2371
|
+
inputNode.removeEventListener("search", handler_1);
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
return undefined;
|
|
2375
|
+
}, [inputNode, onSearch]);
|
|
2376
|
+
return (React__default["default"].createElement("div", { className: "xappw-rich-input ".concat(props.className) }, rich ?
|
|
2377
|
+
React__default["default"].createElement(RichText, { id: id, value: value, onChange: handleRichChange, onInput: handleRichInput, className: "xappw-rich-input__input ".concat(props.className, "__input") }) : React__default["default"].createElement("input", { id: id, ref: inputRef, type: type, value: value.text, autoFocus: autoFocus, placeholder: props.placeholder, className: "xappw-rich-input__input ".concat(props.className, "__input"), onFocus: props.onFocus, onChange: handleChange, onInput: handleInput, onKeyDown: handleKeyDown })));
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2380
|
+
var SuggestionsGroupHeading = function (props) {
|
|
2381
|
+
return (React__default["default"].createElement("div", { className: "xappw-suggestions-group-heading" }, props.label));
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
function getScrollContainer(node) {
|
|
2385
|
+
var walker = node;
|
|
2386
|
+
while (walker && !walker.classList.contains("xapp-search-result__suggestions")) {
|
|
2387
|
+
walker = walker.parentElement;
|
|
2388
|
+
}
|
|
2389
|
+
return walker || undefined;
|
|
2390
|
+
}
|
|
2391
|
+
var SuggestionsItem = function (props) {
|
|
2392
|
+
var data = props.data, current = props.current, ActionsComponent = props.actions, onClick = props.onClick, onHover = props.onHover;
|
|
2393
|
+
var handleClick = React.useCallback(function () {
|
|
2394
|
+
onClick(data);
|
|
2395
|
+
}, [data, onClick]);
|
|
2396
|
+
var handleHover = React.useCallback(function () {
|
|
2397
|
+
if (onHover) {
|
|
2398
|
+
onHover(data);
|
|
2399
|
+
}
|
|
2400
|
+
}, [data, onHover]);
|
|
2401
|
+
var ref = React.useRef(null);
|
|
2402
|
+
React.useEffect(function () {
|
|
2403
|
+
var node = ref.current;
|
|
2404
|
+
if (current && node) {
|
|
2405
|
+
var scrollContainer = getScrollContainer(node);
|
|
2406
|
+
if (scrollContainer) {
|
|
2407
|
+
var scrollBox = scrollContainer.getBoundingClientRect();
|
|
2408
|
+
var nodeBox = node.getBoundingClientRect();
|
|
2409
|
+
var maxTop = Math.max(scrollBox.top, nodeBox.top);
|
|
2410
|
+
var minBottom = Math.min(scrollBox.bottom, nodeBox.bottom);
|
|
2411
|
+
var visibleHeight = minBottom - maxTop;
|
|
2412
|
+
var actualHeight = nodeBox.height;
|
|
2413
|
+
if (visibleHeight < actualHeight * 0.99) {
|
|
2414
|
+
node.scrollIntoView({ behavior: "smooth" });
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
}, [current]);
|
|
2419
|
+
return (React__default["default"].createElement("div", { ref: ref, className: "xappw-suggestions-item ".concat(current ? "xappw-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover },
|
|
2420
|
+
React__default["default"].createElement(RichText, { value: data, className: "xappw-suggestions-item__texts", readOnly: true }),
|
|
2421
|
+
ActionsComponent &&
|
|
2422
|
+
React__default["default"].createElement("div", { className: "xappw-suggestions-item__actions" },
|
|
2423
|
+
React__default["default"].createElement(ActionsComponent, { data: data, current: current }))));
|
|
2424
|
+
};
|
|
2425
|
+
|
|
2426
|
+
var SuggestionsGroup = function (props) {
|
|
2427
|
+
var group = props.group, currentIndex = props.currentIndex, itemActions = props.itemActions;
|
|
2428
|
+
var heading = group.heading, items = group.items;
|
|
2429
|
+
return (React__default["default"].createElement("div", { className: "xappw-suggestions-group" },
|
|
2430
|
+
React__default["default"].createElement("div", { className: "xappw-suggestions-group__heading" },
|
|
2431
|
+
React__default["default"].createElement(SuggestionsGroupHeading, { label: heading })),
|
|
2432
|
+
React__default["default"].createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
|
|
2433
|
+
return React__default["default"].createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex, actions: itemActions, onClick: props.onItemClick, onHover: props.onItemHover });
|
|
2434
|
+
}))));
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
function getItemsLength(result) {
|
|
2438
|
+
return result.reduce(function (prev, cur) { return prev + cur.items.length; }, 0);
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
var SuggestionsList = function (props) {
|
|
2442
|
+
var suggestions = props.suggestions, itemActions = props.itemActions, className = props.className;
|
|
2443
|
+
var length = React.useMemo(function () { return getItemsLength(suggestions); }, [suggestions]);
|
|
2444
|
+
var currentIndex = length >= 0 ? props.index : NaN;
|
|
2445
|
+
var indexWalker = 0;
|
|
2446
|
+
return (React__default["default"].createElement("div", { className: "xappw-suggestions-list ".concat(className || "") }, suggestions.map(function (group, index) {
|
|
2447
|
+
var res = (React__default["default"].createElement(SuggestionsGroup, { key: index, group: group, currentIndex: currentIndex - indexWalker, itemActions: itemActions, onItemClick: props.onItemClick, onItemHover: props.onItemHover }));
|
|
2448
|
+
indexWalker += group.items.length;
|
|
2449
|
+
return res;
|
|
2450
|
+
})));
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
function findItemByIndex(groups, index) {
|
|
2454
|
+
if (index >= 0) {
|
|
2455
|
+
for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
|
|
2456
|
+
var group = groups_1[_i];
|
|
2457
|
+
for (var _a = 0, _b = group.items; _a < _b.length; _a++) {
|
|
2458
|
+
var item = _b[_a];
|
|
2459
|
+
if (index <= 0) {
|
|
2460
|
+
return item;
|
|
2461
|
+
}
|
|
2462
|
+
index--;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
return undefined;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
function parseSuggestionsFormat(format) {
|
|
2470
|
+
var types = Object.keys(format);
|
|
2471
|
+
var type = types[0];
|
|
2472
|
+
var item = format[type];
|
|
2473
|
+
if (!item) {
|
|
2474
|
+
throw new Error();
|
|
2475
|
+
}
|
|
2476
|
+
return {
|
|
2477
|
+
type: type,
|
|
2478
|
+
start: item.start,
|
|
2479
|
+
end: item.end
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
function parseSuggestionsFormats(formats) {
|
|
2483
|
+
return formats.map(parseSuggestionsFormat);
|
|
2484
|
+
}
|
|
2485
|
+
function parseSuggestionsResponseItem(item) {
|
|
2486
|
+
return {
|
|
2487
|
+
text: item.suggestion,
|
|
2488
|
+
content: item.answer,
|
|
2489
|
+
formats: parseSuggestionsFormats(item.format),
|
|
2490
|
+
type: item.type
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
function getHeading(type) {
|
|
2494
|
+
switch (type) {
|
|
2495
|
+
case "FAQ":
|
|
2496
|
+
return "FAQs";
|
|
2497
|
+
case "INTENT":
|
|
2498
|
+
return "Suggestions";
|
|
2499
|
+
case "HISTORICAL":
|
|
2500
|
+
return "Suggestions";
|
|
2501
|
+
default:
|
|
2502
|
+
return type;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
function parseSuggestionsResponse(response, direction) {
|
|
2506
|
+
if (direction === void 0) { direction = 1; }
|
|
2507
|
+
if (!response) {
|
|
2508
|
+
return undefined;
|
|
2509
|
+
}
|
|
2510
|
+
var items = sortSuggestionItems(response.suggestions, direction);
|
|
2511
|
+
return items.reduce(function (result, current) {
|
|
2512
|
+
var mappedItem = parseSuggestionsResponseItem(current);
|
|
2513
|
+
if (result.length) {
|
|
2514
|
+
var prevGroup = result[result.length - 1];
|
|
2515
|
+
if (prevGroup.heading === getHeading(current.type)) {
|
|
2516
|
+
prevGroup.items.push(mappedItem);
|
|
2517
|
+
return result;
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
result.push({
|
|
2521
|
+
heading: getHeading(current.type),
|
|
2522
|
+
items: [mappedItem]
|
|
2523
|
+
});
|
|
2524
|
+
return result;
|
|
2525
|
+
}, []);
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
/*! *****************************************************************************
|
|
2529
|
+
Copyright (c) Microsoft Corporation.
|
|
2530
|
+
|
|
2531
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2532
|
+
purpose with or without fee is hereby granted.
|
|
2533
|
+
|
|
2534
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2535
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2536
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2537
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2538
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2539
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2540
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2541
|
+
***************************************************************************** */
|
|
2542
|
+
|
|
2543
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2544
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2545
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2546
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2547
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2548
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2549
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
function __generator(thisArg, body) {
|
|
2554
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2555
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2556
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2557
|
+
function step(op) {
|
|
2558
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2559
|
+
while (_) try {
|
|
2560
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2561
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2562
|
+
switch (op[0]) {
|
|
2563
|
+
case 0: case 1: t = op; break;
|
|
2564
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2565
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2566
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2567
|
+
default:
|
|
2568
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2569
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2570
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2571
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2572
|
+
if (t[2]) _.ops.pop();
|
|
2573
|
+
_.trys.pop(); continue;
|
|
2574
|
+
}
|
|
2575
|
+
op = body.call(thisArg, _);
|
|
2576
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2577
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
function __spreadArray(to, from, pack) {
|
|
2582
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2583
|
+
if (ar || !(i in from)) {
|
|
2584
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2585
|
+
ar[i] = from[i];
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
var order = ["FAQ", "INTENT", "HISTORICAL"];
|
|
2592
|
+
var ordersMap = order.reduce(function (prev, cur, index) {
|
|
2593
|
+
prev[cur] = index;
|
|
2594
|
+
return prev;
|
|
2595
|
+
}, {});
|
|
2596
|
+
function compareSuggestionItems(left, right, direction) {
|
|
2597
|
+
return direction * (ordersMap[right.type] - ordersMap[left.type]);
|
|
2598
|
+
}
|
|
2599
|
+
function sortSuggestionItems(items, direction) {
|
|
2600
|
+
return __spreadArray([], items, true).sort(function (left, right) { return compareSuggestionItems(left, right, direction); });
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
/**
|
|
2604
|
+
* Append the provided query params to the URL
|
|
2605
|
+
*
|
|
2606
|
+
* It will overwrite existing params on the URL if there are conflicts
|
|
2607
|
+
* @param url
|
|
2608
|
+
* @param params
|
|
2609
|
+
*/
|
|
2610
|
+
function addQueryParametersToURL(url, params) {
|
|
2611
|
+
var existingParams = new URL(url).searchParams;
|
|
2612
|
+
params.forEach(function (value, key) {
|
|
2613
|
+
existingParams.append(key, value);
|
|
2614
|
+
});
|
|
2615
|
+
var newUrl = new URL(url);
|
|
2616
|
+
newUrl.search = existingParams.toString();
|
|
2617
|
+
return newUrl;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
var defaultOptions = {};
|
|
2621
|
+
function noop$1() {
|
|
2622
|
+
}
|
|
2623
|
+
function useJsonFetch(url, options) {
|
|
2624
|
+
if (options === void 0) { options = defaultOptions; }
|
|
2625
|
+
var _a = React.useState({
|
|
2626
|
+
state: "paused"
|
|
2627
|
+
}), value = _a[0], setValue = _a[1];
|
|
2628
|
+
var pause = options.pause;
|
|
2629
|
+
React.useEffect(function () {
|
|
2630
|
+
if (pause) {
|
|
2631
|
+
setValue({
|
|
2632
|
+
state: "paused"
|
|
2633
|
+
});
|
|
2634
|
+
return noop$1;
|
|
2635
|
+
}
|
|
2636
|
+
var controller = new AbortController();
|
|
2637
|
+
var signal = controller.signal;
|
|
2638
|
+
var mounted = true;
|
|
2639
|
+
(function () {
|
|
2640
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2641
|
+
var response, json, e_1;
|
|
2642
|
+
return __generator(this, function (_a) {
|
|
2643
|
+
switch (_a.label) {
|
|
2644
|
+
case 0:
|
|
2645
|
+
_a.trys.push([0, 4, , 5]);
|
|
2646
|
+
setValue({
|
|
2647
|
+
state: "fetching"
|
|
2648
|
+
});
|
|
2649
|
+
return [4 /*yield*/, fetch(url, { signal: signal })];
|
|
2650
|
+
case 1:
|
|
2651
|
+
response = _a.sent();
|
|
2652
|
+
if (!mounted) return [3 /*break*/, 3];
|
|
2653
|
+
return [4 /*yield*/, response.json()];
|
|
2654
|
+
case 2:
|
|
2655
|
+
json = _a.sent();
|
|
2656
|
+
if (response.ok) {
|
|
2657
|
+
setValue({
|
|
2658
|
+
state: "success",
|
|
2659
|
+
data: json
|
|
2660
|
+
});
|
|
2661
|
+
}
|
|
2662
|
+
else {
|
|
2663
|
+
setValue({
|
|
2664
|
+
state: "error",
|
|
2665
|
+
error: json
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
_a.label = 3;
|
|
2669
|
+
case 3: return [3 /*break*/, 5];
|
|
2670
|
+
case 4:
|
|
2671
|
+
e_1 = _a.sent();
|
|
2672
|
+
if (e_1.name === "AbortError") {
|
|
2673
|
+
setValue({
|
|
2674
|
+
state: "paused"
|
|
2675
|
+
});
|
|
2676
|
+
return [2 /*return*/];
|
|
2677
|
+
}
|
|
2678
|
+
throw e_1;
|
|
2679
|
+
case 5: return [2 /*return*/];
|
|
2680
|
+
}
|
|
2681
|
+
});
|
|
2682
|
+
});
|
|
2683
|
+
})();
|
|
2684
|
+
return function () {
|
|
2685
|
+
mounted = false;
|
|
2686
|
+
controller.abort();
|
|
2687
|
+
};
|
|
2688
|
+
}, [url, pause]);
|
|
2689
|
+
return value;
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
function useSuggestionsFetch$1(options) {
|
|
2693
|
+
var baseUrl = options.url, context = options.context, query = options.query;
|
|
2694
|
+
var url = React.useMemo(function () {
|
|
2695
|
+
if (!baseUrl) {
|
|
2696
|
+
return undefined;
|
|
2697
|
+
}
|
|
2698
|
+
var params = new URLSearchParams();
|
|
2699
|
+
params.append("size", "5");
|
|
2700
|
+
params.append("queryText", query);
|
|
2701
|
+
if (context === null || context === void 0 ? void 0 : context.length) {
|
|
2702
|
+
params.append("activeContexts", context.join(","));
|
|
2703
|
+
}
|
|
2704
|
+
return addQueryParametersToURL(baseUrl, params);
|
|
2705
|
+
}, [query, context, baseUrl]);
|
|
2706
|
+
var response = useJsonFetch(url ? "".concat(url.toString()) : "", {
|
|
2707
|
+
pause: !query || !baseUrl
|
|
2708
|
+
});
|
|
2709
|
+
return response;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* Quicker configurable uuid
|
|
2714
|
+
*
|
|
2715
|
+
* @export
|
|
2716
|
+
* @returns {string}
|
|
2717
|
+
*/
|
|
2718
|
+
function uuid() {
|
|
2719
|
+
var d = new Date().getTime();
|
|
2720
|
+
var newUuid = "xxxxxxxx-xxxx-65xx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
2721
|
+
/* tslint:disable:no-magic-numbers */
|
|
2722
|
+
/* tslint:disable:no-bitwise */
|
|
2723
|
+
var r = (d + Math.random() * 16) % 16 | 0;
|
|
2724
|
+
d = Math.floor(d / 16);
|
|
2725
|
+
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
2726
|
+
/* tslint:enable:no-magic-numbers */
|
|
2727
|
+
/* tslint:disable:no-bitwise */
|
|
2728
|
+
});
|
|
2729
|
+
return newUuid;
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
var IconButton_1 = dist.IconButton = IconButton;
|
|
2733
|
+
dist.MessageBubble = MessageBubble;
|
|
2734
|
+
var RichInput_1 = dist.RichInput = RichInput;
|
|
2735
|
+
dist.RichText = RichText;
|
|
2736
|
+
dist.SuggestionsGroup = SuggestionsGroup;
|
|
2737
|
+
dist.SuggestionsGroupHeading = SuggestionsGroupHeading;
|
|
2738
|
+
dist.SuggestionsItem = SuggestionsItem;
|
|
2739
|
+
var SuggestionsList_1 = dist.SuggestionsList = SuggestionsList;
|
|
2740
|
+
dist.addQueryParametersToURL = addQueryParametersToURL;
|
|
2741
|
+
dist.extendFormat = extendFormat;
|
|
2742
|
+
var findItemByIndex_1 = dist.findItemByIndex = findItemByIndex;
|
|
2743
|
+
var getItemsLength_1 = dist.getItemsLength = getItemsLength;
|
|
2744
|
+
var parseSuggestionsResponse_1 = dist.parseSuggestionsResponse = parseSuggestionsResponse;
|
|
2745
|
+
dist.sortSuggestionItems = sortSuggestionItems;
|
|
2746
|
+
dist.useJsonFetch = useJsonFetch;
|
|
2747
|
+
var useSuggestionsFetch_1 = dist.useSuggestionsFetch = useSuggestionsFetch$1;
|
|
2748
|
+
var uuid_1 = dist.uuid = uuid;
|
|
2749
|
+
|
|
2135
2750
|
function postMessageToStentor(data, url, key) {
|
|
2136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2751
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
2137
2752
|
var body, response;
|
|
2138
|
-
return __generator(this, function (_a) {
|
|
2753
|
+
return __generator$1(this, function (_a) {
|
|
2139
2754
|
switch (_a.label) {
|
|
2140
2755
|
case 0:
|
|
2141
2756
|
body = JSON.stringify(data);
|
|
2142
|
-
log("URL: "
|
|
2143
|
-
log("BODY: "
|
|
2757
|
+
log("URL: ".concat(url));
|
|
2758
|
+
log("BODY: ".concat(body));
|
|
2144
2759
|
return [4 /*yield*/, fetch(url, {
|
|
2145
2760
|
method: "POST",
|
|
2146
2761
|
headers: {
|
|
2147
2762
|
"Content-Type": "application/json",
|
|
2148
|
-
"Authorization": "Bearer "
|
|
2763
|
+
"Authorization": "Bearer ".concat(key),
|
|
2149
2764
|
"User-Agent": "Stentor Chat Server"
|
|
2150
2765
|
},
|
|
2151
2766
|
body: body,
|
|
@@ -2154,7 +2769,7 @@ function postMessageToStentor(data, url, key) {
|
|
|
2154
2769
|
case 1:
|
|
2155
2770
|
response = _a.sent();
|
|
2156
2771
|
if (!response.ok) {
|
|
2157
|
-
throw new Error("Status "
|
|
2772
|
+
throw new Error("Status ".concat(response.status, ", Text: ").concat(response.statusText));
|
|
2158
2773
|
}
|
|
2159
2774
|
return [2 /*return*/, response.json()];
|
|
2160
2775
|
}
|
|
@@ -2293,7 +2908,7 @@ function getPermissionRequestType(type) {
|
|
|
2293
2908
|
case "PERMISSION_LOCATION_PRECISE":
|
|
2294
2909
|
return "LOCATION_PRECISE";
|
|
2295
2910
|
default:
|
|
2296
|
-
throw new Error("Unsupported permission: "
|
|
2911
|
+
throw new Error("Unsupported permission: ".concat(type));
|
|
2297
2912
|
}
|
|
2298
2913
|
}
|
|
2299
2914
|
function getPermissionResponse(botResponse, now) {
|
|
@@ -2306,7 +2921,7 @@ function getPermissionResponse(botResponse, now) {
|
|
|
2306
2921
|
type: "permissionRequest",
|
|
2307
2922
|
timestamp: now,
|
|
2308
2923
|
msg: {
|
|
2309
|
-
text: (_a = outputSpeech === null || outputSpeech === void 0 ? void 0 : outputSpeech.displayText) !== null && _a !== void 0 ? _a : ""
|
|
2924
|
+
text: (_a = outputSpeech === null || outputSpeech === void 0 ? void 0 : outputSpeech.displayText) !== null && _a !== void 0 ? _a : "".concat(botResponse.data.permissionRequestTTSContext),
|
|
2310
2925
|
permissionRequest: {
|
|
2311
2926
|
time: now,
|
|
2312
2927
|
type: type,
|
|
@@ -2323,26 +2938,6 @@ function getPermissionResponse(botResponse, now) {
|
|
|
2323
2938
|
};
|
|
2324
2939
|
}
|
|
2325
2940
|
|
|
2326
|
-
/**
|
|
2327
|
-
* Quicker configurable uuid
|
|
2328
|
-
*
|
|
2329
|
-
* @export
|
|
2330
|
-
* @returns {string}
|
|
2331
|
-
*/
|
|
2332
|
-
function uuid() {
|
|
2333
|
-
var d = new Date().getTime();
|
|
2334
|
-
var newUuid = "xxxxxxxx-xxxx-65xx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
2335
|
-
/* tslint:disable:no-magic-numbers */
|
|
2336
|
-
/* tslint:disable:no-bitwise */
|
|
2337
|
-
var r = (d + Math.random() * 16) % 16 | 0;
|
|
2338
|
-
d = Math.floor(d / 16);
|
|
2339
|
-
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
2340
|
-
/* tslint:enable:no-magic-numbers */
|
|
2341
|
-
/* tslint:disable:no-bitwise */
|
|
2342
|
-
});
|
|
2343
|
-
return newUuid;
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
2941
|
var PERMISSION_QUESTION_EXPIRATION_MS = 300000; // 5 minutes
|
|
2347
2942
|
var StentorDirectChat = /** @class */ (function () {
|
|
2348
2943
|
function StentorDirectChat(config) {
|
|
@@ -2354,15 +2949,15 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2354
2949
|
*/
|
|
2355
2950
|
this.widget = {
|
|
2356
2951
|
setConnectionStatus: function (status) {
|
|
2357
|
-
log("SERVER: connection_update: "
|
|
2952
|
+
log("SERVER: connection_update: ".concat(JSON.stringify(status)));
|
|
2358
2953
|
_this.dispatch(setConnectionStatus(status));
|
|
2359
2954
|
},
|
|
2360
2955
|
setAccountStatus: function (status) {
|
|
2361
|
-
log("SERVER: account_status: "
|
|
2956
|
+
log("SERVER: account_status: ".concat(JSON.stringify(status)));
|
|
2362
2957
|
_this.dispatch(setAccountStatus(status));
|
|
2363
2958
|
},
|
|
2364
2959
|
sendNewMessage: function (data) {
|
|
2365
|
-
log("SERVER: new message: "
|
|
2960
|
+
log("SERVER: new message: ".concat(JSON.stringify(data)));
|
|
2366
2961
|
_this.dispatch({
|
|
2367
2962
|
type: "chat",
|
|
2368
2963
|
detail: {
|
|
@@ -2374,7 +2969,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2374
2969
|
});
|
|
2375
2970
|
},
|
|
2376
2971
|
userJoined: function (data) {
|
|
2377
|
-
log("SERVER: user joined: "
|
|
2972
|
+
log("SERVER: user joined: ".concat(JSON.stringify(data)));
|
|
2378
2973
|
_this.visitorInfo.token = data.token;
|
|
2379
2974
|
_this.dispatch({
|
|
2380
2975
|
type: "chat",
|
|
@@ -2386,7 +2981,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2386
2981
|
});
|
|
2387
2982
|
},
|
|
2388
2983
|
userLeft: function (data) {
|
|
2389
|
-
log("SERVER: user left: "
|
|
2984
|
+
log("SERVER: user left: ".concat(JSON.stringify(data)));
|
|
2390
2985
|
_this.dispatch({
|
|
2391
2986
|
type: "chat",
|
|
2392
2987
|
detail: {
|
|
@@ -2445,7 +3040,7 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2445
3040
|
StentorDirectChat.prototype.init = function (dispatch) {
|
|
2446
3041
|
this.dispatch = dispatch;
|
|
2447
3042
|
// TODO: Authenticate - or at least tell the server who you are
|
|
2448
|
-
log("got init auth: "
|
|
3043
|
+
log("got init auth: ".concat(this.config.key));
|
|
2449
3044
|
// We are connected
|
|
2450
3045
|
this.widget.setConnectionStatus("online");
|
|
2451
3046
|
this.widget.setAccountStatus("online");
|
|
@@ -2457,8 +3052,8 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2457
3052
|
cb();
|
|
2458
3053
|
};
|
|
2459
3054
|
StentorDirectChat.prototype.sendChatMsg = function (message, cb) {
|
|
2460
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2461
|
-
return __generator(this, function (_a) {
|
|
3055
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
3056
|
+
return __generator$1(this, function (_a) {
|
|
2462
3057
|
return [2 /*return*/, this.sendChatMsgRequest({
|
|
2463
3058
|
msg: message,
|
|
2464
3059
|
timestamp: new Date().getTime(),
|
|
@@ -2471,9 +3066,9 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2471
3066
|
};
|
|
2472
3067
|
StentorDirectChat.prototype.sendChatMsgRequest = function (serviceRequest, cb) {
|
|
2473
3068
|
var _a;
|
|
2474
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3069
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
2475
3070
|
var agentResponse;
|
|
2476
|
-
return __generator(this, function (_b) {
|
|
3071
|
+
return __generator$1(this, function (_b) {
|
|
2477
3072
|
switch (_b.label) {
|
|
2478
3073
|
case 0: return [4 /*yield*/, this.postMessage(serviceRequest)];
|
|
2479
3074
|
case 1:
|
|
@@ -2516,9 +3111,9 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2516
3111
|
};
|
|
2517
3112
|
StentorDirectChat.prototype.postMessage = function (message) {
|
|
2518
3113
|
var _a, _b, _c, _d;
|
|
2519
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3114
|
+
return __awaiter$1(this, void 0, void 0, function () {
|
|
2520
3115
|
var request, now, permissionRequest, expired, text, granted, userProfile, isEmail, botResponse, responseMessage;
|
|
2521
|
-
return __generator(this, function (_e) {
|
|
3116
|
+
return __generator$1(this, function (_e) {
|
|
2522
3117
|
switch (_e.label) {
|
|
2523
3118
|
case 0:
|
|
2524
3119
|
now = new Date().getTime();
|
|
@@ -2605,20 +3200,20 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2605
3200
|
};
|
|
2606
3201
|
}
|
|
2607
3202
|
}
|
|
2608
|
-
log("Visitor says: "
|
|
3203
|
+
log("Visitor says: ".concat(JSON.stringify(request, undefined, 2)));
|
|
2609
3204
|
// Bot is "typing"
|
|
2610
3205
|
this.widget.typing();
|
|
2611
3206
|
return [4 /*yield*/, postMessageToStentor(request, this.config.url, this.config.key).catch(function (postError) {
|
|
2612
|
-
err("POST failed: "
|
|
3207
|
+
err("POST failed: ".concat(postError.message));
|
|
2613
3208
|
return {
|
|
2614
|
-
text: "Bot doesn't respond. Reason: "
|
|
3209
|
+
text: "Bot doesn't respond. Reason: ".concat(postError.message)
|
|
2615
3210
|
};
|
|
2616
3211
|
})];
|
|
2617
3212
|
case 1:
|
|
2618
3213
|
botResponse = _e.sent();
|
|
2619
3214
|
// Bot stopped "typing"
|
|
2620
3215
|
this.widget.stopTyping();
|
|
2621
|
-
log("Bot says: "
|
|
3216
|
+
log("Bot says: ".concat(JSON.stringify(botResponse, undefined, 2)));
|
|
2622
3217
|
// Now translate the response to server dialect
|
|
2623
3218
|
// new session no more
|
|
2624
3219
|
this.isNewSession = false;
|
|
@@ -2642,15 +3237,15 @@ var StentorDirectChat = /** @class */ (function () {
|
|
|
2642
3237
|
};
|
|
2643
3238
|
StentorDirectChat.prototype.startSession = function () {
|
|
2644
3239
|
if (this.visitorInfo.visitorId) {
|
|
2645
|
-
this._userId = "stentor-widget-user-"
|
|
3240
|
+
this._userId = "stentor-widget-user-".concat(this.visitorInfo.visitorId);
|
|
2646
3241
|
}
|
|
2647
3242
|
else if (this.visitorInfo.email) {
|
|
2648
|
-
this._userId = "stentor-widget-user-"
|
|
3243
|
+
this._userId = "stentor-widget-user-".concat(this.visitorInfo.email);
|
|
2649
3244
|
}
|
|
2650
3245
|
else {
|
|
2651
|
-
this._userId = "stentor-widget-user-"
|
|
3246
|
+
this._userId = "stentor-widget-user-".concat(uuid_1());
|
|
2652
3247
|
}
|
|
2653
|
-
this._sessionId = "stentor-widget-session-"
|
|
3248
|
+
this._sessionId = "stentor-widget-session-".concat(uuid_1());
|
|
2654
3249
|
this.isNewSession = true;
|
|
2655
3250
|
};
|
|
2656
3251
|
Object.defineProperty(StentorDirectChat.prototype, "userId", {
|
|
@@ -5172,8 +5767,10 @@ class Socket extends Emitter_1 {
|
|
|
5172
5767
|
packet.options.compress = this.flags.compress !== false;
|
|
5173
5768
|
// event ack callback
|
|
5174
5769
|
if ("function" === typeof args[args.length - 1]) {
|
|
5175
|
-
|
|
5176
|
-
|
|
5770
|
+
const id = this.ids++;
|
|
5771
|
+
const ack = args.pop();
|
|
5772
|
+
this._registerAckCallback(id, ack);
|
|
5773
|
+
packet.id = id;
|
|
5177
5774
|
}
|
|
5178
5775
|
const isTransportWritable = this.io.engine &&
|
|
5179
5776
|
this.io.engine.transport &&
|
|
@@ -5189,6 +5786,31 @@ class Socket extends Emitter_1 {
|
|
|
5189
5786
|
this.flags = {};
|
|
5190
5787
|
return this;
|
|
5191
5788
|
}
|
|
5789
|
+
/**
|
|
5790
|
+
* @private
|
|
5791
|
+
*/
|
|
5792
|
+
_registerAckCallback(id, ack) {
|
|
5793
|
+
const timeout = this.flags.timeout;
|
|
5794
|
+
if (timeout === undefined) {
|
|
5795
|
+
this.acks[id] = ack;
|
|
5796
|
+
return;
|
|
5797
|
+
}
|
|
5798
|
+
// @ts-ignore
|
|
5799
|
+
const timer = this.io.setTimeoutFn(() => {
|
|
5800
|
+
delete this.acks[id];
|
|
5801
|
+
for (let i = 0; i < this.sendBuffer.length; i++) {
|
|
5802
|
+
if (this.sendBuffer[i].id === id) {
|
|
5803
|
+
this.sendBuffer.splice(i, 1);
|
|
5804
|
+
}
|
|
5805
|
+
}
|
|
5806
|
+
ack.call(this, new Error("operation has timed out"));
|
|
5807
|
+
}, timeout);
|
|
5808
|
+
this.acks[id] = (...args) => {
|
|
5809
|
+
// @ts-ignore
|
|
5810
|
+
this.io.clearTimeoutFn(timer);
|
|
5811
|
+
ack.apply(this, [null, ...args]);
|
|
5812
|
+
};
|
|
5813
|
+
}
|
|
5192
5814
|
/**
|
|
5193
5815
|
* Sends a packet.
|
|
5194
5816
|
*
|
|
@@ -5273,6 +5895,7 @@ class Socket extends Emitter_1 {
|
|
|
5273
5895
|
this.ondisconnect();
|
|
5274
5896
|
break;
|
|
5275
5897
|
case PacketType.CONNECT_ERROR:
|
|
5898
|
+
this.destroy();
|
|
5276
5899
|
const err = new Error(packet.data.message);
|
|
5277
5900
|
// @ts-ignore
|
|
5278
5901
|
err.data = packet.data.data;
|
|
@@ -5436,6 +6059,25 @@ class Socket extends Emitter_1 {
|
|
|
5436
6059
|
this.flags.volatile = true;
|
|
5437
6060
|
return this;
|
|
5438
6061
|
}
|
|
6062
|
+
/**
|
|
6063
|
+
* Sets a modifier for a subsequent event emission that the callback will be called with an error when the
|
|
6064
|
+
* given number of milliseconds have elapsed without an acknowledgement from the server:
|
|
6065
|
+
*
|
|
6066
|
+
* ```
|
|
6067
|
+
* socket.timeout(5000).emit("my-event", (err) => {
|
|
6068
|
+
* if (err) {
|
|
6069
|
+
* // the server did not acknowledge the event in the given delay
|
|
6070
|
+
* }
|
|
6071
|
+
* });
|
|
6072
|
+
* ```
|
|
6073
|
+
*
|
|
6074
|
+
* @returns self
|
|
6075
|
+
* @public
|
|
6076
|
+
*/
|
|
6077
|
+
timeout(timeout) {
|
|
6078
|
+
this.flags.timeout = timeout;
|
|
6079
|
+
return this;
|
|
6080
|
+
}
|
|
5439
6081
|
/**
|
|
5440
6082
|
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
5441
6083
|
* callback.
|
|
@@ -5842,13 +6484,7 @@ class Manager extends Emitter_1 {
|
|
|
5842
6484
|
_close() {
|
|
5843
6485
|
this.skipReconnect = true;
|
|
5844
6486
|
this._reconnecting = false;
|
|
5845
|
-
|
|
5846
|
-
// `onclose` will not fire because
|
|
5847
|
-
// an open event never happened
|
|
5848
|
-
this.cleanup();
|
|
5849
|
-
}
|
|
5850
|
-
this.backoff.reset();
|
|
5851
|
-
this._readyState = "closed";
|
|
6487
|
+
this.onclose("forced close");
|
|
5852
6488
|
if (this.engine)
|
|
5853
6489
|
this.engine.close();
|
|
5854
6490
|
}
|
|
@@ -5991,12 +6627,12 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
5991
6627
|
// TODO: Authenticate - or at least tell the server who you are
|
|
5992
6628
|
// Socket events
|
|
5993
6629
|
this.socket.on("account_status", function (data) {
|
|
5994
|
-
log("SERVER: account_status: "
|
|
6630
|
+
log("SERVER: account_status: ".concat(JSON.stringify(data)));
|
|
5995
6631
|
// Register the "communication" with the server
|
|
5996
6632
|
if (!_this.token) {
|
|
5997
|
-
_this.token =
|
|
6633
|
+
_this.token = uuid_1();
|
|
5998
6634
|
dispatch(receiveToken(_this.token));
|
|
5999
|
-
log("CLIENT: created token: "
|
|
6635
|
+
log("CLIENT: created token: ".concat(_this.token));
|
|
6000
6636
|
}
|
|
6001
6637
|
_this.socket.emit("connection update", _this.token);
|
|
6002
6638
|
dispatch({
|
|
@@ -6008,7 +6644,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6008
6644
|
});
|
|
6009
6645
|
});
|
|
6010
6646
|
this.socket.on("new message", function (data) {
|
|
6011
|
-
log("SERVER: new message: "
|
|
6647
|
+
log("SERVER: new message: ".concat(JSON.stringify(data)));
|
|
6012
6648
|
_this.dispatch({
|
|
6013
6649
|
type: "chat",
|
|
6014
6650
|
detail: {
|
|
@@ -6023,7 +6659,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6023
6659
|
});
|
|
6024
6660
|
});
|
|
6025
6661
|
this.socket.on("user joined", function (data) {
|
|
6026
|
-
log("SERVER: user joined: "
|
|
6662
|
+
log("SERVER: user joined: ".concat(JSON.stringify(data)));
|
|
6027
6663
|
_this.visitorInfo.token = data.token;
|
|
6028
6664
|
_this.dispatch({
|
|
6029
6665
|
type: "chat",
|
|
@@ -6039,7 +6675,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6039
6675
|
});
|
|
6040
6676
|
});
|
|
6041
6677
|
this.socket.on("user left", function (data) {
|
|
6042
|
-
log("SERVER: user left: "
|
|
6678
|
+
log("SERVER: user left: ".concat(JSON.stringify(data)));
|
|
6043
6679
|
_this.dispatch({
|
|
6044
6680
|
type: "chat",
|
|
6045
6681
|
detail: {
|
|
@@ -6053,7 +6689,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6053
6689
|
});
|
|
6054
6690
|
});
|
|
6055
6691
|
this.socket.on("typing", function (data) {
|
|
6056
|
-
log("SERVER: typing: "
|
|
6692
|
+
log("SERVER: typing: ".concat(JSON.stringify(data)));
|
|
6057
6693
|
_this.dispatch({
|
|
6058
6694
|
type: "chat",
|
|
6059
6695
|
detail: {
|
|
@@ -6067,7 +6703,7 @@ var StentorServerChat = /** @class */ (function () {
|
|
|
6067
6703
|
});
|
|
6068
6704
|
});
|
|
6069
6705
|
this.socket.on("stop typing", function (data) {
|
|
6070
|
-
log("SERVER: stop typing: "
|
|
6706
|
+
log("SERVER: stop typing: ".concat(JSON.stringify(data)));
|
|
6071
6707
|
_this.dispatch({
|
|
6072
6708
|
type: "chat",
|
|
6073
6709
|
detail: {
|
|
@@ -6151,7 +6787,7 @@ function createChatServerCore(config, token) {
|
|
|
6151
6787
|
case "local":
|
|
6152
6788
|
return new StentorLocalChat();
|
|
6153
6789
|
default:
|
|
6154
|
-
throw throwBadKind(config.type);
|
|
6790
|
+
throw throwBadKind$1(config.type);
|
|
6155
6791
|
}
|
|
6156
6792
|
}
|
|
6157
6793
|
function createChatServer(config, token) {
|
|
@@ -6200,8 +6836,8 @@ var ChatChipsContainer = function (_) {
|
|
|
6200
6836
|
dispatch(executeAction(getChatServerActionLinkLabel(option)));
|
|
6201
6837
|
}
|
|
6202
6838
|
}
|
|
6203
|
-
return (React.createElement("div", { className: "message-list-container__chips "
|
|
6204
|
-
React.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
6839
|
+
return (React$1.createElement("div", { className: "message-list-container__chips ".concat(!(chips === null || chips === void 0 ? void 0 : chips.length) ? "message-list-container__chips--empty" : "") },
|
|
6840
|
+
React$1.createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
6205
6841
|
};
|
|
6206
6842
|
|
|
6207
6843
|
var ChatMenuItem = function (props) {
|
|
@@ -6210,24 +6846,24 @@ var ChatMenuItem = function (props) {
|
|
|
6210
6846
|
props.onClick(props.label);
|
|
6211
6847
|
}
|
|
6212
6848
|
}
|
|
6213
|
-
return (React.createElement("button", { type: "button", className: "chat-menu-item", onClick: handleClick }, props.label));
|
|
6849
|
+
return (React$1.createElement("button", { type: "button", className: "chat-menu-item", onClick: handleClick }, props.label));
|
|
6214
6850
|
};
|
|
6215
6851
|
|
|
6216
6852
|
var ChatMenu = function (props) {
|
|
6217
6853
|
var items = props.items;
|
|
6218
|
-
return (React.createElement("div", { className: "chat-menu "
|
|
6219
|
-
return React.createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: label });
|
|
6854
|
+
return (React$1.createElement("div", { className: "chat-menu ".concat(props.opened ? "chat-menu--opened" : "chat-menu--closed") }, items.map(function (label, i) {
|
|
6855
|
+
return React$1.createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: label });
|
|
6220
6856
|
})));
|
|
6221
6857
|
};
|
|
6222
6858
|
|
|
6223
|
-
var UnknownMessage = function () { return React.createElement(React.Fragment, null); };
|
|
6859
|
+
var UnknownMessage = function () { return React$1.createElement(React$1.Fragment, null); };
|
|
6224
6860
|
|
|
6225
6861
|
function renderAvatar(entity) {
|
|
6226
|
-
return (React.createElement("div", { className: "xappw-chat-msg-part__avatar" },
|
|
6227
|
-
React.createElement(Avatar, { entity: entity })));
|
|
6862
|
+
return (React$1.createElement("div", { className: "xappw-chat-msg-part__avatar" },
|
|
6863
|
+
React$1.createElement(Avatar, { entity: entity })));
|
|
6228
6864
|
}
|
|
6229
6865
|
var ChatMessagePart = function (props) {
|
|
6230
|
-
return (React.createElement("div", { className: "xappw-chat-msg-part" },
|
|
6866
|
+
return (React$1.createElement("div", { className: "xappw-chat-msg-part" },
|
|
6231
6867
|
props.showAvatar && renderAvatar(props.user),
|
|
6232
6868
|
props.children));
|
|
6233
6869
|
};
|
|
@@ -6278,14 +6914,14 @@ var CardMiddlewareWidget = function (props) {
|
|
|
6278
6914
|
var card = useMemo(function () { return convertFromCardDisplay(msg); }, [msg]);
|
|
6279
6915
|
var user = ctx.user;
|
|
6280
6916
|
var handleButton = useButtonCallback();
|
|
6281
|
-
return (React.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6282
|
-
React.createElement("div", { className: "chat-msg" },
|
|
6283
|
-
React.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
|
|
6917
|
+
return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6918
|
+
React$1.createElement("div", { className: "chat-msg" },
|
|
6919
|
+
React$1.createElement(ChatCard, { card: card, onButtonClick: handleButton }))));
|
|
6284
6920
|
};
|
|
6285
6921
|
var CardMiddleware = function (next) { return function (props) {
|
|
6286
6922
|
var msg = props.msg, ctx = props.ctx;
|
|
6287
6923
|
if (isCard(msg)) {
|
|
6288
|
-
return React.createElement(CardMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6924
|
+
return React$1.createElement(CardMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6289
6925
|
}
|
|
6290
6926
|
return next(props);
|
|
6291
6927
|
}; };
|
|
@@ -6306,11 +6942,11 @@ function createSubscribableArray(originalValue) {
|
|
|
6306
6942
|
return {
|
|
6307
6943
|
getArray: function () { return cache; },
|
|
6308
6944
|
push: function (val) {
|
|
6309
|
-
cache = __spreadArray(__spreadArray([], cache, true), [val], false);
|
|
6945
|
+
cache = __spreadArray$1(__spreadArray$1([], cache, true), [val], false);
|
|
6310
6946
|
notify();
|
|
6311
6947
|
},
|
|
6312
6948
|
unshift: function (val) {
|
|
6313
|
-
cache = __spreadArray([val], cache, true);
|
|
6949
|
+
cache = __spreadArray$1([val], cache, true);
|
|
6314
6950
|
notify();
|
|
6315
6951
|
},
|
|
6316
6952
|
subscribe: function (callback) {
|
|
@@ -6363,22 +6999,22 @@ function useLateMiddlewaresBuilder(storage) {
|
|
|
6363
6999
|
var middlewares = useGlobalSubscribableArray(storage);
|
|
6364
7000
|
return useMemo(function () { return joinMiddlewares(middlewares); }, [middlewares]);
|
|
6365
7001
|
}
|
|
6366
|
-
var storage = createStorage(
|
|
7002
|
+
var storage = createStorage(globalThis, "xappMsgMiddlewares");
|
|
6367
7003
|
function useLateMiddleware() {
|
|
6368
7004
|
return useLateMiddlewaresBuilder(storage);
|
|
6369
7005
|
}
|
|
6370
7006
|
|
|
6371
7007
|
function getSvg() {
|
|
6372
|
-
return (React.createElement("svg", { viewBox: "0 0 20 20" },
|
|
6373
|
-
React.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" }),
|
|
6374
|
-
React.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
|
|
7008
|
+
return (React$1.createElement("svg", { viewBox: "0 0 20 20" },
|
|
7009
|
+
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" }),
|
|
7010
|
+
React$1.createElement("path", { d: "M19 1h-8l3.29 3.29-5.73 5.73 1.42 1.42 5.73-5.73L19 9V1z" })));
|
|
6375
7011
|
}
|
|
6376
7012
|
var ExternalLink = function (props) {
|
|
6377
7013
|
var url = props.url;
|
|
6378
7014
|
var handleClick = useCallback(function (ev) {
|
|
6379
7015
|
ev.preventDefault();
|
|
6380
7016
|
}, []);
|
|
6381
|
-
return (React.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick }, getSvg()));
|
|
7017
|
+
return (React$1.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: props.className, onClick: handleClick }, getSvg()));
|
|
6382
7018
|
};
|
|
6383
7019
|
|
|
6384
7020
|
function firstIndex(val, patterns) {
|
|
@@ -6430,7 +7066,7 @@ var parsers = [
|
|
|
6430
7066
|
pathParser,
|
|
6431
7067
|
queryParser
|
|
6432
7068
|
];
|
|
6433
|
-
function parse
|
|
7069
|
+
function parse(val) {
|
|
6434
7070
|
var parts = [];
|
|
6435
7071
|
var rest = val;
|
|
6436
7072
|
for (var _i = 0, parsers_1 = parsers; _i < parsers_1.length; _i++) {
|
|
@@ -6449,7 +7085,7 @@ var ellipsis = "/...";
|
|
|
6449
7085
|
function reduceLink(url, maxLength) {
|
|
6450
7086
|
if (url.length < maxLength)
|
|
6451
7087
|
return url;
|
|
6452
|
-
var parts = parse
|
|
7088
|
+
var parts = parse(url); // [scheme, domain, port, path, query, hash]
|
|
6453
7089
|
function getText() {
|
|
6454
7090
|
return parts.join("");
|
|
6455
7091
|
}
|
|
@@ -6491,7 +7127,7 @@ var SmartLink = function (props) {
|
|
|
6491
7127
|
var handleClick = useCallback(function (ev) {
|
|
6492
7128
|
ev.preventDefault();
|
|
6493
7129
|
}, []);
|
|
6494
|
-
return (React.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: className, onClick: handleClick }, reduceLink(url, 40)));
|
|
7130
|
+
return (React$1.createElement("a", { href: url, target: "_blank", rel: "noreferrer", className: className, onClick: handleClick }, reduceLink(url, 40)));
|
|
6495
7131
|
};
|
|
6496
7132
|
|
|
6497
7133
|
var ListItem = function (props) {
|
|
@@ -6499,18 +7135,18 @@ var ListItem = function (props) {
|
|
|
6499
7135
|
var item = props.item;
|
|
6500
7136
|
var layout = props.layout || "normal";
|
|
6501
7137
|
var url = item.url || item.imageActionUrl;
|
|
6502
|
-
return (React.createElement(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
6503
|
-
React.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--"
|
|
6504
|
-
React.createElement("div", { className: "xappw-vlist-item__description" },
|
|
6505
|
-
item.title && React.createElement("div", { className: "xappw-vlist-item__title" },
|
|
6506
|
-
React.createElement("span", null, item.title)),
|
|
6507
|
-
url && React.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
|
|
6508
|
-
item.subTitle && React.createElement("div", { className: "xappw-vlist-item__subtitle" },
|
|
6509
|
-
React.createElement("span", null, item.subTitle)),
|
|
6510
|
-
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
|
|
6511
|
-
React.createElement("div", { className: "xappw-vlist-item__side" },
|
|
6512
|
-
url && React.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
|
|
6513
|
-
React.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
|
|
7138
|
+
return (React$1.createElement(ActionItem, { className: "xappw-vlist-item-container", item: item, onButtonClick: props.onButtonClick, onExecute: props.onExecute, onOpenUrl: props.onOpenUrl },
|
|
7139
|
+
React$1.createElement("div", { className: "xappw-vlist-item xappw-vlist-item--".concat(layout) },
|
|
7140
|
+
React$1.createElement("div", { className: "xappw-vlist-item__description" },
|
|
7141
|
+
item.title && React$1.createElement("div", { className: "xappw-vlist-item__title" },
|
|
7142
|
+
React$1.createElement("span", null, item.title)),
|
|
7143
|
+
url && React$1.createElement(SmartLink, { url: url, className: "xappw-vlist-item__link" }),
|
|
7144
|
+
item.subTitle && React$1.createElement("div", { className: "xappw-vlist-item__subtitle" },
|
|
7145
|
+
React$1.createElement("span", null, item.subTitle)),
|
|
7146
|
+
!!((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length) && React$1.createElement(ChatActionButtons, { buttons: item.buttons, onClick: props.onButtonClick })),
|
|
7147
|
+
React$1.createElement("div", { className: "xappw-vlist-item__side" },
|
|
7148
|
+
url && React$1.createElement(ExternalLink, { url: "url", className: "xappw-vlist-item__external-link" }),
|
|
7149
|
+
React$1.createElement(ActionItemImage, { item: item, className: "xappw-vlist-item__img", emptyImageVisible: props.emptyImageVisible })))));
|
|
6514
7150
|
};
|
|
6515
7151
|
|
|
6516
7152
|
var List = function (props) {
|
|
@@ -6519,12 +7155,12 @@ var List = function (props) {
|
|
|
6519
7155
|
var hasImage = list.items.some(function (item) { return item.imageUrl; });
|
|
6520
7156
|
var titlesOnly = !list.items.some(function (item) { var _a; return item.subTitle || ((_a = item.buttons) === null || _a === void 0 ? void 0 : _a.length); });
|
|
6521
7157
|
var listItems = list.items.map(function (item, itemIndex) {
|
|
6522
|
-
return (React.createElement("div", { className: "xappw-vlist-container__item", key: "item-key-"
|
|
6523
|
-
React.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
7158
|
+
return (React$1.createElement("div", { className: "xappw-vlist-container__item", key: "item-key-".concat(itemIndex) },
|
|
7159
|
+
React$1.createElement(ListItem, { item: item, layout: titlesOnly ? "titles" : "normal", emptyImageVisible: hasImage, onExecute: props.onExecute, onButtonClick: props.onButtonClick, onOpenUrl: props.onOpenUrl })));
|
|
6524
7160
|
});
|
|
6525
|
-
return (React.createElement("div", { className: "xappw-vlist" },
|
|
6526
|
-
React.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
|
|
6527
|
-
props.list.title && React.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
|
|
7161
|
+
return (React$1.createElement("div", { className: "xappw-vlist" },
|
|
7162
|
+
React$1.createElement("div", { ref: listRef, className: "xappw-vlist-container" },
|
|
7163
|
+
props.list.title && React$1.createElement("div", { className: "xappw-vlist__header" }, props.list.title),
|
|
6528
7164
|
listItems)));
|
|
6529
7165
|
};
|
|
6530
7166
|
|
|
@@ -6534,16 +7170,16 @@ var ListMiddlewareWidget = function (props) {
|
|
|
6534
7170
|
var handleExecute = useExecuteActionCallback();
|
|
6535
7171
|
var handleButton = useButtonCallback();
|
|
6536
7172
|
var user = ctx.user;
|
|
6537
|
-
return (React.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6538
|
-
list.type === "CAROUSEL" && React.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
|
|
6539
|
-
React.createElement(Carousel, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl })),
|
|
6540
|
-
list.type === "LIST" && React.createElement("div", { className: "chat-msg chat-msg--expand" },
|
|
6541
|
-
React.createElement(List, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))));
|
|
7173
|
+
return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
7174
|
+
list.type === "CAROUSEL" && React$1.createElement("div", { className: "chat-msg chat-msg--fullwidth chat-msg--no-ava" },
|
|
7175
|
+
React$1.createElement(Carousel, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl })),
|
|
7176
|
+
list.type === "LIST" && React$1.createElement("div", { className: "chat-msg chat-msg--expand" },
|
|
7177
|
+
React$1.createElement(List, { list: list, onExecute: handleExecute, onButtonClick: handleButton, onOpenUrl: ctx.openUrl }))));
|
|
6542
7178
|
};
|
|
6543
7179
|
var ListMiddleware = function (next) { return function (props) {
|
|
6544
7180
|
var msg = props.msg, ctx = props.ctx;
|
|
6545
7181
|
if (isList(msg)) {
|
|
6546
|
-
return React.createElement(ListMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
7182
|
+
return React$1.createElement(ListMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6547
7183
|
}
|
|
6548
7184
|
return next(props);
|
|
6549
7185
|
}; };
|
|
@@ -6555,10 +7191,10 @@ var MultiSelect = function (props) {
|
|
|
6555
7191
|
var id = ev.target.value;
|
|
6556
7192
|
onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
|
|
6557
7193
|
}, [checked, onChange]);
|
|
6558
|
-
return (React.createElement("ul", { className: "xappw-multiselect" }, items.map(function (item) { return (React.createElement("li", { key: item.id },
|
|
6559
|
-
React.createElement("label", null,
|
|
6560
|
-
React.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
|
|
6561
|
-
React.createElement("span", null, item.title)))); })));
|
|
7194
|
+
return (React$1.createElement("ul", { className: "xappw-multiselect" }, items.map(function (item) { return (React$1.createElement("li", { key: item.id },
|
|
7195
|
+
React$1.createElement("label", null,
|
|
7196
|
+
React$1.createElement("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }),
|
|
7197
|
+
React$1.createElement("span", null, item.title)))); })));
|
|
6562
7198
|
};
|
|
6563
7199
|
|
|
6564
7200
|
function isMultiSelect(display) {
|
|
@@ -6582,16 +7218,16 @@ var MultiSelectMiddlewareWidget = function (props) {
|
|
|
6582
7218
|
})
|
|
6583
7219
|
});
|
|
6584
7220
|
}, [ctx, checked]);
|
|
6585
|
-
return (React.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
6586
|
-
React.createElement("div", { className: "chat-msg" },
|
|
6587
|
-
React.createElement("div", null,
|
|
6588
|
-
React.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
|
|
6589
|
-
React.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
|
|
7221
|
+
return (React$1.createElement(ChatMessagePart, { showAvatar: true, user: user },
|
|
7222
|
+
React$1.createElement("div", { className: "chat-msg" },
|
|
7223
|
+
React$1.createElement("div", null,
|
|
7224
|
+
React$1.createElement(MultiSelect, { items: items, checked: checked, onChange: setChecked }),
|
|
7225
|
+
React$1.createElement(ActionButton, { label: "Submit", onClick: handleSubmit })))));
|
|
6590
7226
|
};
|
|
6591
7227
|
var MultiSelectMiddleware = function (next) { return function (props) {
|
|
6592
7228
|
var msg = props.msg, ctx = props.ctx;
|
|
6593
7229
|
if (isMultiSelect(msg)) {
|
|
6594
|
-
return React.createElement(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
7230
|
+
return React$1.createElement(MultiSelectMiddlewareWidget, { msg: msg, ctx: ctx });
|
|
6595
7231
|
}
|
|
6596
7232
|
return next(props);
|
|
6597
7233
|
}; };
|
|
@@ -6621,8 +7257,8 @@ function getTailSvgPath(owner) {
|
|
|
6621
7257
|
return "m 0 0 v 240 h 60 c -40 -40 -60 -160 -60 -240";
|
|
6622
7258
|
}
|
|
6623
7259
|
function getTailSvg(owner) {
|
|
6624
|
-
return (React.createElement("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240" },
|
|
6625
|
-
React.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
|
|
7260
|
+
return (React$1.createElement("svg", { className: "chat-text-bubble__tail", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 80 240" },
|
|
7261
|
+
React$1.createElement("path", { d: getTailSvgPath(owner), fill: "currentColor" })));
|
|
6626
7262
|
}
|
|
6627
7263
|
var ChatMessageBubble = function (props) {
|
|
6628
7264
|
var owner = props.owner, onClick = props.onClick;
|
|
@@ -6631,7 +7267,7 @@ var ChatMessageBubble = function (props) {
|
|
|
6631
7267
|
onClick();
|
|
6632
7268
|
}
|
|
6633
7269
|
}, [onClick]);
|
|
6634
|
-
return (React.createElement("div", { onClick: handleClick, className: "chat-text-bubble "
|
|
7270
|
+
return (React$1.createElement("div", { onClick: handleClick, className: "chat-text-bubble ".concat(owner === "mine" ? "chat-text-bubble--mine" : "chat-text-bubble--others") },
|
|
6635
7271
|
(props.hasTail) && getTailSvg(owner),
|
|
6636
7272
|
props.children));
|
|
6637
7273
|
};
|
|
@@ -6665,10 +7301,10 @@ var ChatMarkdownMessage = function (props) {
|
|
|
6665
7301
|
}
|
|
6666
7302
|
return undefined;
|
|
6667
7303
|
}, [ref, html, onOpenUrl, handleLinkClick]);
|
|
6668
|
-
return (React.createElement("div", { className: "chat-msg" },
|
|
6669
|
-
React.createElement("div", { className: "chat-text-container" },
|
|
6670
|
-
React.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
6671
|
-
React.createElement("div", { ref: ref })))));
|
|
7304
|
+
return (React$1.createElement("div", { className: "chat-msg" },
|
|
7305
|
+
React$1.createElement("div", { className: "chat-text-container" },
|
|
7306
|
+
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
7307
|
+
React$1.createElement("div", { ref: ref })))));
|
|
6672
7308
|
};
|
|
6673
7309
|
|
|
6674
7310
|
var ChatPermissionMessage = function (props) {
|
|
@@ -6738,20 +7374,20 @@ var ChatPermissionMessage = function (props) {
|
|
|
6738
7374
|
}
|
|
6739
7375
|
}, [handleFail, handleResult]);
|
|
6740
7376
|
if (!permissionRequest) {
|
|
6741
|
-
return React.createElement(React.Fragment, null);
|
|
7377
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
6742
7378
|
}
|
|
6743
|
-
return (React.createElement("div", { className: "chat-msg" },
|
|
6744
|
-
React.createElement("div", { className: "buttons-container" },
|
|
6745
|
-
React.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
|
|
6746
|
-
React.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
|
|
7379
|
+
return (React$1.createElement("div", { className: "chat-msg" },
|
|
7380
|
+
React$1.createElement("div", { className: "buttons-container" },
|
|
7381
|
+
React$1.createElement(ActionButton, { label: allowLabel, addClass: "button", onClick: handleAllow }),
|
|
7382
|
+
React$1.createElement(ActionButton, { label: denyLabel, addClass: "button", onClick: handleDeny }))));
|
|
6747
7383
|
};
|
|
6748
7384
|
|
|
6749
7385
|
var ChatTextMessage = function (props) {
|
|
6750
7386
|
var agentMessage = isAgent(props.message.user.nick);
|
|
6751
|
-
return (React.createElement("div", { className: "chat-msg" },
|
|
6752
|
-
React.createElement("div", { className: "chat-text-container" },
|
|
6753
|
-
React.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
6754
|
-
React.createElement("span", null, props.message.msg.text)))));
|
|
7387
|
+
return (React$1.createElement("div", { className: "chat-msg" },
|
|
7388
|
+
React$1.createElement("div", { className: "chat-text-container" },
|
|
7389
|
+
React$1.createElement(ChatMessageBubble, { owner: agentMessage ? "others" : "mine", hasTail: agentMessage && !props.sibling },
|
|
7390
|
+
React$1.createElement("span", null, props.message.msg.text)))));
|
|
6755
7391
|
};
|
|
6756
7392
|
|
|
6757
7393
|
function getClassName(msg) {
|
|
@@ -6775,26 +7411,26 @@ var ChatMessage = function (props) {
|
|
|
6775
7411
|
// Here is the deal. If we have text (output speech), then text - card - list - options
|
|
6776
7412
|
// OR card OR list only. Avatar with text bubble.
|
|
6777
7413
|
var avaKey = avaKeys.find(function (key) { return !!msg[key]; });
|
|
6778
|
-
return (React.createElement(React.Fragment, null,
|
|
7414
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
6779
7415
|
msg.text &&
|
|
6780
|
-
React.createElement(ChatMessagePart, { showAvatar: avaKey === "text", user: user },
|
|
6781
|
-
React.createElement(ChatTextMessage, { message: props.message, sibling: props.sibling })),
|
|
7416
|
+
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "text", user: user },
|
|
7417
|
+
React$1.createElement(ChatTextMessage, { message: props.message, sibling: props.sibling })),
|
|
6782
7418
|
msg.html &&
|
|
6783
|
-
React.createElement(ChatMessagePart, { showAvatar: avaKey === "html", user: user },
|
|
6784
|
-
React.createElement(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_a = props.middlewareContext) === null || _a === void 0 ? void 0 : _a.openUrl })),
|
|
7419
|
+
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "html", user: user },
|
|
7420
|
+
React$1.createElement(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_a = props.middlewareContext) === null || _a === void 0 ? void 0 : _a.openUrl })),
|
|
6785
7421
|
msg.displays && middleware && msg.displays.map(function (display, index) {
|
|
6786
7422
|
var Middleware = middleware;
|
|
6787
|
-
return React.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext });
|
|
7423
|
+
return React$1.createElement(Middleware, { key: index, msg: display, ctx: props.middlewareContext });
|
|
6788
7424
|
}),
|
|
6789
7425
|
msg.permissionRequest &&
|
|
6790
|
-
React.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user },
|
|
6791
|
-
React.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: props.middlewareContext }))));
|
|
7426
|
+
React$1.createElement(ChatMessagePart, { showAvatar: avaKey === "permissionRequest", user: user },
|
|
7427
|
+
React$1.createElement(ChatPermissionMessage, { message: props.message, sibling: props.sibling, ctx: props.middlewareContext }))));
|
|
6792
7428
|
}
|
|
6793
|
-
return (React.createElement(React.Fragment, null));
|
|
7429
|
+
return (React$1.createElement(React$1.Fragment, null));
|
|
6794
7430
|
}
|
|
6795
7431
|
// empty
|
|
6796
|
-
return (React.createElement("div", { className: "chat-msg-container-wrapper "
|
|
6797
|
-
React.createElement("div", { className: "chat-msg-container "
|
|
7432
|
+
return (React$1.createElement("div", { className: "chat-msg-container-wrapper ".concat(isAgent(props.message.user.nick) ? "agent" : "visitor", " ").concat(props.sibling ? "sibling" : "") },
|
|
7433
|
+
React$1.createElement("div", { className: "chat-msg-container ".concat(getClassName(props.message)) }, renderByType())));
|
|
6798
7434
|
};
|
|
6799
7435
|
|
|
6800
7436
|
function useExternalScript(url) {
|
|
@@ -6822,7 +7458,7 @@ function getSafeCh(ch) {
|
|
|
6822
7458
|
if (ch >= "A" && ch <= "Z") {
|
|
6823
7459
|
return ch;
|
|
6824
7460
|
}
|
|
6825
|
-
return "_"
|
|
7461
|
+
return "_".concat(ch.charCodeAt(0), "_");
|
|
6826
7462
|
}
|
|
6827
7463
|
function getSrcId(url) {
|
|
6828
7464
|
var res = "es-";
|
|
@@ -6868,191 +7504,26 @@ function useGreeting(active) {
|
|
|
6868
7504
|
}
|
|
6869
7505
|
|
|
6870
7506
|
function match(item, pattern) {
|
|
6871
|
-
var value = item.
|
|
7507
|
+
var value = item.text;
|
|
6872
7508
|
return value.toLocaleLowerCase().indexOf(pattern.toLocaleLowerCase()) >= 0;
|
|
6873
|
-
}
|
|
6874
|
-
function mapFormat$1(formats, length) {
|
|
6875
|
-
var res = [];
|
|
6876
|
-
var walkerIndex = 0;
|
|
6877
|
-
for (var _i = 0, formats_1 = formats; _i < formats_1.length; _i++) {
|
|
6878
|
-
var format = formats_1[_i];
|
|
6879
|
-
var start = format.start, end = format.end, type = format.type;
|
|
6880
|
-
if (walkerIndex < start) {
|
|
6881
|
-
res.push({
|
|
6882
|
-
type: "normal",
|
|
6883
|
-
start: walkerIndex,
|
|
6884
|
-
end: start
|
|
6885
|
-
});
|
|
6886
|
-
}
|
|
6887
|
-
res.push({
|
|
6888
|
-
type: type,
|
|
6889
|
-
start: start,
|
|
6890
|
-
end: end
|
|
6891
|
-
});
|
|
6892
|
-
walkerIndex = end;
|
|
6893
|
-
}
|
|
6894
|
-
if (walkerIndex < length) {
|
|
6895
|
-
res.push({
|
|
6896
|
-
type: "normal",
|
|
6897
|
-
start: walkerIndex,
|
|
6898
|
-
end: length
|
|
6899
|
-
});
|
|
6900
|
-
}
|
|
6901
|
-
return res;
|
|
6902
|
-
}
|
|
6903
|
-
|
|
6904
|
-
/**
|
|
6905
|
-
* Append the provided query params to the URL
|
|
6906
|
-
*
|
|
6907
|
-
* It will overwrite existing params on the URL if there are conflicts
|
|
6908
|
-
* @param url
|
|
6909
|
-
* @param params
|
|
6910
|
-
*/
|
|
6911
|
-
function addQueryParametersToURL(url, params) {
|
|
6912
|
-
if (!url) {
|
|
6913
|
-
return undefined;
|
|
6914
|
-
}
|
|
6915
|
-
var existingParams = new URL(url).searchParams;
|
|
6916
|
-
params.forEach(function (value, key) {
|
|
6917
|
-
existingParams.append(key, value);
|
|
6918
|
-
});
|
|
6919
|
-
var newUrl = new URL(url);
|
|
6920
|
-
newUrl.search = existingParams.toString();
|
|
6921
|
-
return newUrl;
|
|
6922
|
-
}
|
|
6923
|
-
|
|
6924
|
-
var defaultOptions = {};
|
|
6925
|
-
function noop$1() {
|
|
6926
|
-
}
|
|
6927
|
-
function useJsonFetch(url, options) {
|
|
6928
|
-
if (options === void 0) { options = defaultOptions; }
|
|
6929
|
-
var _a = useState({
|
|
6930
|
-
fetching: true
|
|
6931
|
-
}), value = _a[0], setValue = _a[1];
|
|
6932
|
-
var pause = options.pause;
|
|
6933
|
-
useEffect(function () {
|
|
6934
|
-
if (pause) {
|
|
6935
|
-
setValue({
|
|
6936
|
-
fetching: true
|
|
6937
|
-
});
|
|
6938
|
-
return noop$1;
|
|
6939
|
-
}
|
|
6940
|
-
var controller = new AbortController();
|
|
6941
|
-
var signal = controller.signal;
|
|
6942
|
-
var mounted = true;
|
|
6943
|
-
(function () {
|
|
6944
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
6945
|
-
var response, json, e_1;
|
|
6946
|
-
return __generator(this, function (_a) {
|
|
6947
|
-
switch (_a.label) {
|
|
6948
|
-
case 0:
|
|
6949
|
-
_a.trys.push([0, 4, , 5]);
|
|
6950
|
-
return [4 /*yield*/, fetch(url, { signal: signal })];
|
|
6951
|
-
case 1:
|
|
6952
|
-
response = _a.sent();
|
|
6953
|
-
if (!mounted) return [3 /*break*/, 3];
|
|
6954
|
-
return [4 /*yield*/, response.json()];
|
|
6955
|
-
case 2:
|
|
6956
|
-
json = _a.sent();
|
|
6957
|
-
if (response.ok) {
|
|
6958
|
-
setValue({
|
|
6959
|
-
fetching: false,
|
|
6960
|
-
success: true,
|
|
6961
|
-
data: json
|
|
6962
|
-
});
|
|
6963
|
-
}
|
|
6964
|
-
else {
|
|
6965
|
-
setValue({
|
|
6966
|
-
fetching: false,
|
|
6967
|
-
success: false,
|
|
6968
|
-
error: json
|
|
6969
|
-
});
|
|
6970
|
-
}
|
|
6971
|
-
_a.label = 3;
|
|
6972
|
-
case 3: return [3 /*break*/, 5];
|
|
6973
|
-
case 4:
|
|
6974
|
-
e_1 = _a.sent();
|
|
6975
|
-
if (e_1.name === "AbortError") {
|
|
6976
|
-
return [2 /*return*/];
|
|
6977
|
-
}
|
|
6978
|
-
throw e_1;
|
|
6979
|
-
case 5: return [2 /*return*/];
|
|
6980
|
-
}
|
|
6981
|
-
});
|
|
6982
|
-
});
|
|
6983
|
-
})();
|
|
6984
|
-
return function () {
|
|
6985
|
-
mounted = false;
|
|
6986
|
-
controller.abort();
|
|
6987
|
-
};
|
|
6988
|
-
}, [url, pause]);
|
|
6989
|
-
return value;
|
|
6990
7509
|
}
|
|
6991
7510
|
|
|
6992
7511
|
function useSuggestionsFetch(search, context) {
|
|
6993
7512
|
var env = useWidgetEnv();
|
|
6994
7513
|
var baseUrl = env === null || env === void 0 ? void 0 : env.autocompleteSuggestionsUrl;
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
if (context === null || context === void 0 ? void 0 : context.length) {
|
|
7000
|
-
params.append("activeContexts", context.join(","));
|
|
7001
|
-
}
|
|
7002
|
-
return addQueryParametersToURL(baseUrl, params);
|
|
7003
|
-
}, [search, context, baseUrl]);
|
|
7004
|
-
var response = useJsonFetch(url ? "" + url.toString() : "", {
|
|
7005
|
-
pause: !search || !baseUrl
|
|
7514
|
+
return useSuggestionsFetch_1({
|
|
7515
|
+
url: baseUrl,
|
|
7516
|
+
query: search,
|
|
7517
|
+
context: context
|
|
7006
7518
|
});
|
|
7007
|
-
return useMemo(function () {
|
|
7008
|
-
if (!search) {
|
|
7009
|
-
return undefined;
|
|
7010
|
-
}
|
|
7011
|
-
if (response.fetching === false) {
|
|
7012
|
-
if (response.success) {
|
|
7013
|
-
return response.data;
|
|
7014
|
-
}
|
|
7015
|
-
else {
|
|
7016
|
-
return undefined;
|
|
7017
|
-
}
|
|
7018
|
-
}
|
|
7019
|
-
return undefined;
|
|
7020
|
-
}, [search, response]);
|
|
7021
7519
|
}
|
|
7022
7520
|
|
|
7023
7521
|
function norm(index, len) {
|
|
7024
7522
|
return (index + len) % len;
|
|
7025
7523
|
}
|
|
7026
|
-
function mapFormat(format) {
|
|
7027
|
-
var types = Object.keys(format);
|
|
7028
|
-
var type = types[0];
|
|
7029
|
-
var item = format[type];
|
|
7030
|
-
return {
|
|
7031
|
-
type: type,
|
|
7032
|
-
start: item.start,
|
|
7033
|
-
end: item.end
|
|
7034
|
-
};
|
|
7035
|
-
}
|
|
7036
|
-
function mapFormats(formats) {
|
|
7037
|
-
return formats.map(mapFormat);
|
|
7038
|
-
}
|
|
7039
|
-
function parseItem(responseItem) {
|
|
7040
|
-
var suggestion = responseItem.suggestion;
|
|
7041
|
-
return {
|
|
7042
|
-
suggestion: suggestion,
|
|
7043
|
-
answer: responseItem.answer,
|
|
7044
|
-
type: responseItem.type,
|
|
7045
|
-
format: mapFormats(responseItem.format)
|
|
7046
|
-
};
|
|
7047
|
-
}
|
|
7048
|
-
function parse(response) {
|
|
7049
|
-
return {
|
|
7050
|
-
items: response.suggestions.map(parseItem)
|
|
7051
|
-
};
|
|
7052
|
-
}
|
|
7053
7524
|
function useSuggestions(search, context) {
|
|
7054
7525
|
var _a = useState(), suggestions = _a[0], setSuggestions = _a[1];
|
|
7055
|
-
var _b = useState(
|
|
7526
|
+
var _b = useState(-1), suggestionIndex = _b[0], setSuggestionIndex = _b[1];
|
|
7056
7527
|
var _c = useState(search), query = _c[0], setQuery = _c[1];
|
|
7057
7528
|
var _d = useState(context), contextState = _d[0], setContextState = _d[1];
|
|
7058
7529
|
useEffect(function () {
|
|
@@ -7061,15 +7532,10 @@ function useSuggestions(search, context) {
|
|
|
7061
7532
|
useEffect(function () {
|
|
7062
7533
|
setContextState(context);
|
|
7063
7534
|
}, [context]);
|
|
7064
|
-
var suggestionItem = useMemo(function () {
|
|
7065
|
-
if (suggestionIndex >= 0 && suggestions) {
|
|
7066
|
-
return suggestions.items[suggestionIndex];
|
|
7067
|
-
}
|
|
7068
|
-
return undefined;
|
|
7069
|
-
}, [suggestions, suggestionIndex]);
|
|
7535
|
+
var suggestionItem = useMemo(function () { return suggestions ? findItemByIndex_1(suggestions, suggestionIndex) : undefined; }, [suggestions, suggestionIndex]);
|
|
7070
7536
|
var shift = useCallback(function (delta) {
|
|
7071
7537
|
if (suggestions) {
|
|
7072
|
-
var len_1 = suggestions
|
|
7538
|
+
var len_1 = getItemsLength_1(suggestions);
|
|
7073
7539
|
setSuggestionIndex(function (index) { return norm(index + delta + ((index < 0 && delta <= 0) ? 1 : 0), len_1); });
|
|
7074
7540
|
}
|
|
7075
7541
|
else {
|
|
@@ -7091,20 +7557,26 @@ function useSuggestions(search, context) {
|
|
|
7091
7557
|
break;
|
|
7092
7558
|
}
|
|
7093
7559
|
}, [shift]);
|
|
7094
|
-
var suggestionsResponse = useSuggestionsFetch(query, contextState);
|
|
7560
|
+
var suggestionsResponse = useSuggestionsFetch(query || "", contextState);
|
|
7561
|
+
var suggestionsData = suggestionsResponse.state === "success" ? suggestionsResponse.data : undefined;
|
|
7095
7562
|
var raw = useMemo(function () {
|
|
7096
|
-
return
|
|
7097
|
-
}, [
|
|
7563
|
+
return suggestionsData ? parseSuggestionsResponse_1(suggestionsData, -1) : undefined;
|
|
7564
|
+
}, [suggestionsData]);
|
|
7098
7565
|
useEffect(function () {
|
|
7099
7566
|
var prev = suggestionItem;
|
|
7100
7567
|
setSuggestions(raw);
|
|
7101
7568
|
if (prev && raw) {
|
|
7102
|
-
var prevValue = prev.
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7569
|
+
var prevValue = prev.text;
|
|
7570
|
+
var index = 0;
|
|
7571
|
+
for (var _i = 0, raw_1 = raw; _i < raw_1.length; _i++) {
|
|
7572
|
+
var group = raw_1[_i];
|
|
7573
|
+
for (var _a = 0, _b = group.items; _a < _b.length; _a++) {
|
|
7574
|
+
var item = _b[_a];
|
|
7575
|
+
if (match(item, prevValue)) {
|
|
7576
|
+
setSuggestionIndex(index);
|
|
7577
|
+
break;
|
|
7578
|
+
}
|
|
7579
|
+
index++;
|
|
7108
7580
|
}
|
|
7109
7581
|
}
|
|
7110
7582
|
}
|
|
@@ -7121,42 +7593,35 @@ function useSuggestions(search, context) {
|
|
|
7121
7593
|
}
|
|
7122
7594
|
|
|
7123
7595
|
var DrawerBars = function (props) {
|
|
7124
|
-
return (React.createElement("div", { className: "drawer-bars", onClick: props.onToggle },
|
|
7125
|
-
React.createElement("div", { className: "drawer-bar bar1" }),
|
|
7126
|
-
React.createElement("div", { className: "drawer-bar bar2" })));
|
|
7127
|
-
};
|
|
7128
|
-
|
|
7129
|
-
var IconButton = function (props) {
|
|
7130
|
-
var type = props.type || "button";
|
|
7131
|
-
var Icon = props.icon;
|
|
7132
|
-
return (React.createElement("button", { type: type, className: "xappw-icon-button " + (props.className || ""), onClick: props.onClick },
|
|
7133
|
-
React.createElement(Icon, null)));
|
|
7596
|
+
return (React$1.createElement("div", { className: "drawer-bars", onClick: props.onToggle },
|
|
7597
|
+
React$1.createElement("div", { className: "drawer-bar bar1" }),
|
|
7598
|
+
React$1.createElement("div", { className: "drawer-bar bar2" })));
|
|
7134
7599
|
};
|
|
7135
7600
|
|
|
7136
7601
|
var CloseIcon = function () {
|
|
7137
7602
|
// Sergey, I added this style, you will probably want to change it to be more appropriate
|
|
7138
|
-
return (React.createElement("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7139
|
-
React.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" })));
|
|
7603
|
+
return (React$1.createElement("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7604
|
+
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" })));
|
|
7140
7605
|
};
|
|
7141
7606
|
|
|
7142
7607
|
var LeftDownArrowIcon = function () {
|
|
7143
|
-
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7144
|
-
React.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" })));
|
|
7608
|
+
return (React$1.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
7609
|
+
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" })));
|
|
7145
7610
|
};
|
|
7146
7611
|
|
|
7147
7612
|
var SendIcon = function () {
|
|
7148
|
-
return (React.createElement("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg" },
|
|
7149
|
-
React.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
|
|
7150
|
-
React.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" }),
|
|
7151
|
-
React.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" }))));
|
|
7613
|
+
return (React$1.createElement("svg", { viewBox: "80.208 98.129 313.069 282.823", xmlns: "http://www.w3.org/2000/svg" },
|
|
7614
|
+
React$1.createElement("g", { transform: "matrix(0.024498, 0, 0, -0.038359, 79.83091, 381.182404)", fill: "currentColor", stroke: "none" },
|
|
7615
|
+
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" }),
|
|
7616
|
+
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" }))));
|
|
7152
7617
|
};
|
|
7153
7618
|
|
|
7154
7619
|
var SendButton = function (props) {
|
|
7155
|
-
return (React.createElement(
|
|
7620
|
+
return (React$1.createElement(IconButton_1, { className: "xappw-send-button ".concat(props.className || ""), onClick: props.onClick, icon: SendIcon }));
|
|
7156
7621
|
};
|
|
7157
7622
|
|
|
7158
7623
|
var Input = function (props) {
|
|
7159
|
-
var value = props.value, suggestion = props.suggestion, onChange = props.onChange, onSuggestionCommand = props.onSuggestionCommand;
|
|
7624
|
+
var value = props.value, suggestion = props.suggestion, onChange = props.onChange, onSubmit = props.onSubmit, onSuggestionCommand = props.onSuggestionCommand;
|
|
7160
7625
|
var _a = useState(false), dragover = _a[0], setDragover = _a[1];
|
|
7161
7626
|
function onDragOver(event) {
|
|
7162
7627
|
setDragover(true);
|
|
@@ -7170,32 +7635,30 @@ var Input = function (props) {
|
|
|
7170
7635
|
function onDragLeave() {
|
|
7171
7636
|
setDragover(false);
|
|
7172
7637
|
}
|
|
7173
|
-
|
|
7638
|
+
var handleOnSubmit = useCallback(function (event) {
|
|
7174
7639
|
event && event.preventDefault();
|
|
7175
|
-
|
|
7176
|
-
}
|
|
7177
|
-
var handleOnChange = useCallback(function (event) {
|
|
7178
|
-
var val = event.target.value;
|
|
7179
|
-
onChange(val);
|
|
7180
|
-
}, [onChange]);
|
|
7640
|
+
onSubmit(value); // send to the widget
|
|
7641
|
+
}, [value, onSubmit]);
|
|
7181
7642
|
var handleClear = useCallback(function () {
|
|
7182
|
-
onChange(
|
|
7643
|
+
onChange({
|
|
7644
|
+
text: "",
|
|
7645
|
+
formats: []
|
|
7646
|
+
});
|
|
7183
7647
|
}, [onChange]);
|
|
7184
7648
|
var handleKeyDown = useCallback(function (event) {
|
|
7185
7649
|
if (suggestion) {
|
|
7186
7650
|
if (event.key === "End" || event.key === "ArrowRight" || event.key === "Enter") {
|
|
7187
|
-
|
|
7188
|
-
onChange(newVal);
|
|
7651
|
+
onChange(suggestion);
|
|
7189
7652
|
return;
|
|
7190
7653
|
}
|
|
7191
7654
|
}
|
|
7192
7655
|
if (onSuggestionCommand) {
|
|
7193
7656
|
if (event.key === "ArrowUp") {
|
|
7194
|
-
onSuggestionCommand("
|
|
7657
|
+
onSuggestionCommand("prev");
|
|
7195
7658
|
event.preventDefault();
|
|
7196
7659
|
}
|
|
7197
7660
|
else if (event.key === "ArrowDown") {
|
|
7198
|
-
onSuggestionCommand("
|
|
7661
|
+
onSuggestionCommand("next");
|
|
7199
7662
|
event.preventDefault();
|
|
7200
7663
|
}
|
|
7201
7664
|
else if (event.key === "Escape") {
|
|
@@ -7204,116 +7667,59 @@ var Input = function (props) {
|
|
|
7204
7667
|
}
|
|
7205
7668
|
}
|
|
7206
7669
|
}, [suggestion, onChange, onSuggestionCommand]);
|
|
7207
|
-
return (React.createElement("div", { className: "xappw-input-container "
|
|
7208
|
-
React.createElement("form", { className: "xappw-input-form", onSubmit: handleOnSubmit },
|
|
7209
|
-
|
|
7210
|
-
React.createElement("input", { key: "input", className: "xappw-input", placeholder: "Type your question here...", onChange: handleOnChange, onKeyDown: handleKeyDown,
|
|
7670
|
+
return (React$1.createElement("div", { className: "xappw-input-container ".concat(props.addClass, " ").concat(dragover ? "drag-drop-zone" : ""), onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave },
|
|
7671
|
+
React$1.createElement("form", { className: "xappw-input-form", onSubmit: handleOnSubmit },
|
|
7672
|
+
React$1.createElement(RichInput_1, { key: "input", className: "xappw-input", placeholder: "Type your question here...", onInput: onChange, onChange: onChange, onKeyDown: handleKeyDown,
|
|
7211
7673
|
// onFocus={onFocus}
|
|
7212
|
-
value: value
|
|
7213
|
-
React.createElement("div", { className: "xappw-input-form__buttons" },
|
|
7214
|
-
value && React.createElement(
|
|
7215
|
-
React.createElement(SendButton, { onClick: handleOnSubmit })))));
|
|
7216
|
-
};
|
|
7217
|
-
|
|
7218
|
-
var SuggestionsItem = function (props) {
|
|
7219
|
-
var data = props.data, onClick = props.onClick, onUse = props.onUse, onHover = props.onHover;
|
|
7220
|
-
var suggestion = data.suggestion;
|
|
7221
|
-
var handleClick = useCallback(function () {
|
|
7222
|
-
onClick(data);
|
|
7223
|
-
}, [data, onClick]);
|
|
7224
|
-
var handleUse = useCallback(function (ev) {
|
|
7225
|
-
onUse(data);
|
|
7226
|
-
ev.stopPropagation();
|
|
7227
|
-
}, [data, onUse]);
|
|
7228
|
-
var handleHover = useCallback(function () {
|
|
7229
|
-
onHover(data);
|
|
7230
|
-
}, [data, onHover]);
|
|
7231
|
-
var formats = useMemo(function () { return mapFormat$1(data.format, suggestion.length); }, [data.format, suggestion]);
|
|
7232
|
-
var canUse = data.type !== "FAQ";
|
|
7233
|
-
return (React.createElement("div", { className: "xapp-suggestions-item " + (props.current ? "xapp-suggestions-item--current" : ""), onClick: handleClick, onMouseEnter: handleHover },
|
|
7234
|
-
React.createElement("div", { className: "xapp-suggestions-item__texts" }, formats.map(function (format, index) { return (React.createElement("span", { className: "xapp-suggestions-item__text xapp-suggestions-item__text--" + format.type, key: index }, suggestion.substring(format.start, format.end))); })),
|
|
7235
|
-
canUse && React.createElement(IconButton, { className: "xapp-suggestions-item__use", onClick: handleUse, icon: LeftDownArrowIcon })));
|
|
7674
|
+
value: value }),
|
|
7675
|
+
React$1.createElement("div", { className: "xappw-input-form__buttons" },
|
|
7676
|
+
value.text && React$1.createElement(IconButton_1, { icon: CloseIcon, className: "xappw-input-form__btn", onClick: handleClear }),
|
|
7677
|
+
React$1.createElement(SendButton, { className: "xappw-input-form__btn", onClick: handleOnSubmit })))));
|
|
7236
7678
|
};
|
|
7237
7679
|
|
|
7238
|
-
function
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
}
|
|
7250
|
-
|
|
7251
|
-
var group = props.group, currentIndex = props.currentIndex;
|
|
7252
|
-
var type = group.type, items = group.items, startIndex = group.startIndex;
|
|
7253
|
-
return (React.createElement("div", { className: "xappw-suggestions-group" },
|
|
7254
|
-
React.createElement("label", { className: "xappw-suggestions-group__label" }, getLabel(type)),
|
|
7255
|
-
React.createElement("div", { className: "xappw-suggestions-group__items" }, items.map(function (item, itemIndex) {
|
|
7256
|
-
return React.createElement(SuggestionsItem, { key: itemIndex, data: item, current: currentIndex === itemIndex + startIndex, onClick: props.onItemClick, onUse: props.onItemUse, onHover: props.onItemHover });
|
|
7257
|
-
}))));
|
|
7258
|
-
};
|
|
7259
|
-
|
|
7260
|
-
function normalizeType(type) {
|
|
7261
|
-
switch (type) {
|
|
7262
|
-
case "HISTORICAL":
|
|
7263
|
-
return "INTENT";
|
|
7264
|
-
default:
|
|
7265
|
-
return type;
|
|
7266
|
-
}
|
|
7267
|
-
}
|
|
7268
|
-
var order = ["FAQ", "INTENT", "HISTORICAL"];
|
|
7269
|
-
var ordersMap = order.reduce(function (prev, cur, index) {
|
|
7270
|
-
prev[cur] = index;
|
|
7271
|
-
return prev;
|
|
7272
|
-
}, {});
|
|
7273
|
-
function compareSuggestionItems(left, right) {
|
|
7274
|
-
return (ordersMap[right.type] - ordersMap[left.type]);
|
|
7680
|
+
function createActions(onItemUse) {
|
|
7681
|
+
return function (innerProps) {
|
|
7682
|
+
var data = innerProps.data;
|
|
7683
|
+
var canUse = data.type !== "FAQ";
|
|
7684
|
+
var handleUse = useCallback(function (ev) {
|
|
7685
|
+
onItemUse(data);
|
|
7686
|
+
ev.stopPropagation();
|
|
7687
|
+
}, [data]);
|
|
7688
|
+
if (!canUse) {
|
|
7689
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
7690
|
+
}
|
|
7691
|
+
return (React$1.createElement(IconButton_1, { className: "xappw-suggestions__use", onClick: handleUse, icon: LeftDownArrowIcon }));
|
|
7692
|
+
};
|
|
7275
7693
|
}
|
|
7276
7694
|
var Suggestions = function (props) {
|
|
7277
|
-
var
|
|
7695
|
+
var data = props.data, onItemUse = props.onItemUse;
|
|
7696
|
+
var len = data.length;
|
|
7278
7697
|
var currentIndex = len > 0 ? props.index : NaN;
|
|
7279
7698
|
var _a = useState(), activeItem = _a[0], setActiveItem = _a[1];
|
|
7280
|
-
var item =
|
|
7699
|
+
var item = useMemo(function () { return findItemByIndex_1(data, currentIndex); }, [data, currentIndex]);
|
|
7281
7700
|
useEffect(function () {
|
|
7282
7701
|
setActiveItem(item);
|
|
7283
7702
|
}, [item]);
|
|
7284
|
-
var
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
if (prevGroup.type === normalizeType(current.type)) {
|
|
7290
|
-
prevGroup.items.push(current);
|
|
7291
|
-
return result;
|
|
7292
|
-
}
|
|
7293
|
-
}
|
|
7294
|
-
result.push({
|
|
7295
|
-
type: normalizeType(current.type),
|
|
7296
|
-
items: [current],
|
|
7297
|
-
startIndex: index
|
|
7298
|
-
});
|
|
7299
|
-
return result;
|
|
7300
|
-
}, []);
|
|
7301
|
-
}, [props.data]);
|
|
7302
|
-
return (React.createElement("div", { className: "xappw-suggestions " + (props.className || "") },
|
|
7303
|
-
(activeItem === null || activeItem === void 0 ? void 0 : activeItem.answer) && React.createElement("div", { className: "xappw-suggestions__answer" }, activeItem.answer),
|
|
7304
|
-
!!groups.length && React.createElement("div", { className: "xappw-suggestions__groups" }, groups.map(function (group, index) { return (React.createElement(SuggestionsGroupItem, { key: index, group: group, currentIndex: currentIndex, onItemClick: props.onItemClick, onItemUse: props.onItemUse, onItemHover: setActiveItem })); }))));
|
|
7703
|
+
var actions = useMemo(function () { return createActions(onItemUse); }, [onItemUse]);
|
|
7704
|
+
return (React$1.createElement("div", { className: "xappw-suggestions ".concat(props.className || "") },
|
|
7705
|
+
(activeItem === null || activeItem === void 0 ? void 0 : activeItem.content) && React$1.createElement("div", { className: "xappw-suggestions__answer" }, activeItem.content),
|
|
7706
|
+
!!data.length &&
|
|
7707
|
+
React$1.createElement(SuggestionsList_1, { suggestions: data, index: currentIndex, className: "xappw-suggestions__groups", itemActions: actions, onItemClick: props.onItemClick, onItemHover: setActiveItem })));
|
|
7305
7708
|
};
|
|
7306
7709
|
|
|
7307
7710
|
var ChatFooter = function (props) {
|
|
7308
|
-
var _a, _b, _c
|
|
7711
|
+
var _a, _b, _c;
|
|
7309
7712
|
var onSubmit = props.onSubmit;
|
|
7310
|
-
var
|
|
7311
|
-
var
|
|
7713
|
+
var _d = useState(false), drawer = _d[0], setDrawerState = _d[1]; // false initially
|
|
7714
|
+
var _e = useState(), suggestionSearch = _e[0], setSuggestionSearch = _e[1];
|
|
7312
7715
|
var contexts = useSelector(function (state) { return state.activeContexts; });
|
|
7313
7716
|
var suggestions = useSuggestions(suggestionSearch, contexts);
|
|
7314
7717
|
var menuItemsRaw = (_b = (_a = useWidgetEnv()) === null || _a === void 0 ? void 0 : _a.menu) === null || _b === void 0 ? void 0 : _b.items;
|
|
7315
7718
|
var menuItems = useMemo(function () { return menuItemsRaw ? menuItemsRaw.map(function (item) { return item.label; }) : []; }, [menuItemsRaw]);
|
|
7316
|
-
var
|
|
7719
|
+
var _f = useState({
|
|
7720
|
+
text: "",
|
|
7721
|
+
formats: []
|
|
7722
|
+
}), input = _f[0], setInput = _f[1];
|
|
7317
7723
|
function toggleDrawer() {
|
|
7318
7724
|
var newDrawer = !drawer;
|
|
7319
7725
|
setDrawerState(newDrawer);
|
|
@@ -7325,29 +7731,32 @@ var ChatFooter = function (props) {
|
|
|
7325
7731
|
}
|
|
7326
7732
|
function handleChange(val) {
|
|
7327
7733
|
setInput(val);
|
|
7328
|
-
props.onChange(val);
|
|
7329
|
-
setSuggestionSearch(val);
|
|
7734
|
+
props.onChange(val.text);
|
|
7735
|
+
setSuggestionSearch(val.text);
|
|
7330
7736
|
}
|
|
7331
7737
|
var handleSubmit = useCallback(function (message) {
|
|
7332
7738
|
setSuggestionSearch("");
|
|
7333
|
-
setInput(
|
|
7334
|
-
|
|
7739
|
+
setInput({
|
|
7740
|
+
text: "",
|
|
7741
|
+
formats: []
|
|
7742
|
+
});
|
|
7743
|
+
onSubmit(message.text);
|
|
7335
7744
|
}, [onSubmit]);
|
|
7336
7745
|
var handleItemClick = useCallback(function (data) {
|
|
7337
|
-
handleSubmit(data
|
|
7746
|
+
handleSubmit(data);
|
|
7338
7747
|
}, [handleSubmit]);
|
|
7339
7748
|
var handleItemUse = useCallback(function (data) {
|
|
7340
|
-
setInput(data
|
|
7341
|
-
setSuggestionSearch(data.
|
|
7749
|
+
setInput(data);
|
|
7750
|
+
setSuggestionSearch(data.text);
|
|
7342
7751
|
}, []);
|
|
7343
|
-
return (React.createElement("div", { className: "chat-footer" },
|
|
7752
|
+
return (React$1.createElement("div", { className: "chat-footer" },
|
|
7344
7753
|
menuItems.length ?
|
|
7345
|
-
React.createElement(React.Fragment, null,
|
|
7346
|
-
React.createElement(ChatMenu, { opened: drawer, onItemClick: handleMenuItem, items: menuItems }),
|
|
7347
|
-
React.createElement("div", { className: "chat-footer__menu-icon" },
|
|
7348
|
-
React.createElement(DrawerBars, { onToggle: toggleDrawer }))) : React.createElement(React.Fragment, null),
|
|
7349
|
-
((
|
|
7350
|
-
React.createElement(Input, { addClass: "chat-footer__input " + (props.isChatting ? "visible" : ""), suggestion: suggestions.item, value: input, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
|
|
7754
|
+
React$1.createElement(React$1.Fragment, null,
|
|
7755
|
+
React$1.createElement(ChatMenu, { opened: drawer, onItemClick: handleMenuItem, items: menuItems }),
|
|
7756
|
+
React$1.createElement("div", { className: "chat-footer__menu-icon" },
|
|
7757
|
+
React$1.createElement(DrawerBars, { onToggle: toggleDrawer }))) : React$1.createElement(React$1.Fragment, null),
|
|
7758
|
+
((_c = suggestions.suggestions) === null || _c === void 0 ? void 0 : _c.length) > 0 && React$1.createElement(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, onItemClick: handleItemClick, onItemUse: handleItemUse }),
|
|
7759
|
+
React$1.createElement(Input, { addClass: "chat-footer__input " + (props.isChatting ? "visible" : ""), suggestion: suggestions.item, value: input, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
|
|
7351
7760
|
// onFocus={this.inputOnFocus}
|
|
7352
7761
|
onFileUpload: props.onFileUpload })));
|
|
7353
7762
|
};
|
|
@@ -7383,12 +7792,12 @@ var MiddlewareContextFactory = /** @class */ (function () {
|
|
|
7383
7792
|
var CardContainer = function (props) {
|
|
7384
7793
|
function renderIcon() {
|
|
7385
7794
|
var isString = typeof (props.icon) === "string";
|
|
7386
|
-
return (React.createElement("div", { className: "card-container__icon" }, !isString && props.icon));
|
|
7795
|
+
return (React$1.createElement("div", { className: "card-container__icon" }, !isString && props.icon));
|
|
7387
7796
|
}
|
|
7388
|
-
return (React.createElement("div", { className: "card-container "
|
|
7797
|
+
return (React$1.createElement("div", { className: "card-container ".concat(props.addClass) },
|
|
7389
7798
|
renderIcon(),
|
|
7390
|
-
React.createElement("div", { className: "card-container__content "
|
|
7391
|
-
React.createElement("div", { className: "card-container__title" }, props.title),
|
|
7799
|
+
React$1.createElement("div", { className: "card-container__content ".concat(props.contentAddClass) },
|
|
7800
|
+
React$1.createElement("div", { className: "card-container__title" }, props.title),
|
|
7392
7801
|
props.children)));
|
|
7393
7802
|
};
|
|
7394
7803
|
|
|
@@ -7417,18 +7826,18 @@ var ChatRating = function (props) {
|
|
|
7417
7826
|
return null;
|
|
7418
7827
|
}
|
|
7419
7828
|
if (!props.hasRating) {
|
|
7420
|
-
return (React.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7829
|
+
return (React$1.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7421
7830
|
props.agent.displayName,
|
|
7422
7831
|
" has requested you to rate the chat service.",
|
|
7423
|
-
React.createElement("div", { className: "buttons-container" },
|
|
7424
|
-
React.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
|
|
7425
|
-
React.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
|
|
7832
|
+
React$1.createElement("div", { className: "buttons-container" },
|
|
7833
|
+
React$1.createElement(ActionButton, { addClass: "button button-rate-bad", label: "Rate Bad", onClick: rateBadButtonOnClick }),
|
|
7834
|
+
React$1.createElement(ActionButton, { addClass: "button button-rate-good", label: "Rate Good", onClick: rateGoodButtonOnClick }))));
|
|
7426
7835
|
}
|
|
7427
7836
|
else {
|
|
7428
|
-
return (React.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7837
|
+
return (React$1.createElement(CardContainer, { title: "Chat Rating", addClass: "chat-rating-card" },
|
|
7429
7838
|
"You have rated the chat service.",
|
|
7430
|
-
React.createElement("div", { className: "buttons-container" },
|
|
7431
|
-
React.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
|
|
7839
|
+
React$1.createElement("div", { className: "buttons-container" },
|
|
7840
|
+
React$1.createElement(ActionButton, { addClass: "button button-rate-again", label: "Rate again", onClick: rateAgainButtonOnClick }))));
|
|
7432
7841
|
}
|
|
7433
7842
|
};
|
|
7434
7843
|
|
|
@@ -7437,12 +7846,12 @@ var ChatRatingContainer = function (props) {
|
|
|
7437
7846
|
var handleRate = useCallback(function (rating) {
|
|
7438
7847
|
dispatch(sendChatRating(rating));
|
|
7439
7848
|
}, [dispatch]);
|
|
7440
|
-
return React.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate });
|
|
7849
|
+
return React$1.createElement(ChatRating, { agent: props.agent, hasRating: props.hasRating, shouldDisplay: props.shouldDisplay, onRate: handleRate });
|
|
7441
7850
|
};
|
|
7442
7851
|
|
|
7443
7852
|
var MessageSvg = function (_) {
|
|
7444
|
-
return (React.createElement("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12" },
|
|
7445
|
-
React.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" })));
|
|
7853
|
+
return (React$1.createElement("svg", { className: "message-svg", width: "16", height: "12", viewBox: "0 0 16 12" },
|
|
7854
|
+
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" })));
|
|
7446
7855
|
};
|
|
7447
7856
|
|
|
7448
7857
|
var MessageForm = function (props) {
|
|
@@ -7478,30 +7887,30 @@ var MessageForm = function (props) {
|
|
|
7478
7887
|
setSent(false);
|
|
7479
7888
|
}
|
|
7480
7889
|
function renderSent() {
|
|
7481
|
-
return (React.createElement("div", { key: "sent", className: "message-form--sent" },
|
|
7890
|
+
return (React$1.createElement("div", { key: "sent", className: "message-form--sent" },
|
|
7482
7891
|
"Your message has been sent. We will get back to you as soon as possible.",
|
|
7483
|
-
React.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
|
|
7892
|
+
React$1.createElement(ActionButton, { addClass: "button-resend", label: "Send another", onClick: sendAnother })));
|
|
7484
7893
|
}
|
|
7485
7894
|
function renderForm() {
|
|
7486
|
-
return (React.createElement("form", { ref: form, key: "not-sent", className: "message-form", onSubmit: send },
|
|
7487
|
-
React.createElement("div", { className: "content" },
|
|
7488
|
-
React.createElement("div", { className: "section" },
|
|
7489
|
-
React.createElement("label", { className: "label" }, "Name"),
|
|
7490
|
-
React.createElement("input", { ref: name, maxLength: 255 })),
|
|
7491
|
-
React.createElement("div", { className: "section" },
|
|
7492
|
-
React.createElement("label", { className: "label" }, "Email"),
|
|
7493
|
-
React.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
|
|
7494
|
-
React.createElement("div", { className: "section" },
|
|
7495
|
-
React.createElement("label", { className: "label" }, "Message"),
|
|
7496
|
-
React.createElement("textarea", { required: true, ref: message }))),
|
|
7497
|
-
React.createElement("div", { className: "button-container" },
|
|
7498
|
-
React.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
|
|
7499
|
-
}
|
|
7500
|
-
return (React.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
|
|
7895
|
+
return (React$1.createElement("form", { ref: form, key: "not-sent", className: "message-form", onSubmit: send },
|
|
7896
|
+
React$1.createElement("div", { className: "content" },
|
|
7897
|
+
React$1.createElement("div", { className: "section" },
|
|
7898
|
+
React$1.createElement("label", { className: "label" }, "Name"),
|
|
7899
|
+
React$1.createElement("input", { ref: name, maxLength: 255 })),
|
|
7900
|
+
React$1.createElement("div", { className: "section" },
|
|
7901
|
+
React$1.createElement("label", { className: "label" }, "Email"),
|
|
7902
|
+
React$1.createElement("input", { ref: email, onChange: emailChanged, type: "email", required: true, pattern: EMAIL_REGEX })),
|
|
7903
|
+
React$1.createElement("div", { className: "section" },
|
|
7904
|
+
React$1.createElement("label", { className: "label" }, "Message"),
|
|
7905
|
+
React$1.createElement("textarea", { required: true, ref: message }))),
|
|
7906
|
+
React$1.createElement("div", { className: "button-container" },
|
|
7907
|
+
React$1.createElement(ActionButton, { type: "submit", addClass: "message-form__submit", label: "Send" }))));
|
|
7908
|
+
}
|
|
7909
|
+
return (React$1.createElement(CardContainer, { title: props.title, addClass: "offline-card", contentAddClass: sent ? "sent" : "", icon: React$1.createElement(MessageSvg, null) }, sent ? renderSent() : renderForm()));
|
|
7501
7910
|
};
|
|
7502
7911
|
|
|
7503
7912
|
var OfflineForm = function (props) {
|
|
7504
|
-
return React.createElement(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
|
|
7913
|
+
return React$1.createElement(MessageForm, { title: "Offline message card title", onSubmit: props.onSubmit });
|
|
7505
7914
|
};
|
|
7506
7915
|
|
|
7507
7916
|
var OfflineFormContainer = function (_) {
|
|
@@ -7509,7 +7918,7 @@ var OfflineFormContainer = function (_) {
|
|
|
7509
7918
|
var handleSubmit = useCallback(function (data) {
|
|
7510
7919
|
dispatch(sendOfflineMsg(data));
|
|
7511
7920
|
}, [dispatch]);
|
|
7512
|
-
return React.createElement(OfflineForm, { onSubmit: handleSubmit });
|
|
7921
|
+
return React$1.createElement(OfflineForm, { onSubmit: handleSubmit });
|
|
7513
7922
|
};
|
|
7514
7923
|
|
|
7515
7924
|
var PrechatForm = function (props) {
|
|
@@ -7519,7 +7928,7 @@ var PrechatForm = function (props) {
|
|
|
7519
7928
|
onSubmit(msg);
|
|
7520
7929
|
setSent(true);
|
|
7521
7930
|
}, [onSubmit]);
|
|
7522
|
-
return (React.createElement(React.Fragment, null, !sent && React.createElement(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit })));
|
|
7931
|
+
return (React$1.createElement(React$1.Fragment, null, !sent && React$1.createElement(MessageForm, { title: "Introduce yourself!", onSubmit: handleSubmit })));
|
|
7523
7932
|
};
|
|
7524
7933
|
|
|
7525
7934
|
var PrechatFormContainer = function (_) {
|
|
@@ -7534,7 +7943,7 @@ var PrechatFormContainer = function (_) {
|
|
|
7534
7943
|
}));
|
|
7535
7944
|
dispatch(executeAction(data.message));
|
|
7536
7945
|
}, [dispatch]);
|
|
7537
|
-
return React.createElement(PrechatForm, { onSubmit: handleSubmit });
|
|
7946
|
+
return React$1.createElement(PrechatForm, { onSubmit: handleSubmit });
|
|
7538
7947
|
};
|
|
7539
7948
|
|
|
7540
7949
|
var defaultProps$1 = {
|
|
@@ -7544,8 +7953,8 @@ var QueuePosition = function (props) {
|
|
|
7544
7953
|
if (props === void 0) { props = defaultProps$1; }
|
|
7545
7954
|
if (props.position <= 0)
|
|
7546
7955
|
return null;
|
|
7547
|
-
return (React.createElement("div", { className: "system-msg-container" },
|
|
7548
|
-
React.createElement("span", { className: "system-msg" },
|
|
7956
|
+
return (React$1.createElement("div", { className: "system-msg-container" },
|
|
7957
|
+
React$1.createElement("span", { className: "system-msg" },
|
|
7549
7958
|
"Queue position: ",
|
|
7550
7959
|
props.position)));
|
|
7551
7960
|
};
|
|
@@ -7553,34 +7962,34 @@ var QueuePosition = function (props) {
|
|
|
7553
7962
|
function getMessageByType(msg) {
|
|
7554
7963
|
switch (msg.type) {
|
|
7555
7964
|
case "chat.memberjoin":
|
|
7556
|
-
return msg.user.displayName
|
|
7965
|
+
return "".concat(msg.user.displayName, " has joined the chat");
|
|
7557
7966
|
case "chat.memberleave":
|
|
7558
|
-
return msg.user.displayName
|
|
7967
|
+
return "".concat(msg.user.displayName, " has left the chat");
|
|
7559
7968
|
case "chat.rating":
|
|
7560
7969
|
if (!msg.newRating) {
|
|
7561
7970
|
return "You have removed the chat rating";
|
|
7562
7971
|
}
|
|
7563
7972
|
else {
|
|
7564
7973
|
var rating = convertToSentenceCase(msg.newRating);
|
|
7565
|
-
return "You have rated the chat service "
|
|
7974
|
+
return "You have rated the chat service ".concat(rating);
|
|
7566
7975
|
}
|
|
7567
7976
|
default:
|
|
7568
7977
|
return JSON.stringify(msg);
|
|
7569
7978
|
}
|
|
7570
7979
|
}
|
|
7571
7980
|
var SystemMessage = function (props) {
|
|
7572
|
-
return (React.createElement("div", { className: "system-msg-container" },
|
|
7573
|
-
React.createElement("span", { className: "system-msg" }, getMessageByType(props.message))));
|
|
7981
|
+
return (React$1.createElement("div", { className: "system-msg-container" },
|
|
7982
|
+
React$1.createElement("span", { className: "system-msg" }, getMessageByType(props.message))));
|
|
7574
7983
|
};
|
|
7575
7984
|
function convertToSentenceCase(s) {
|
|
7576
7985
|
return s[0].toUpperCase() + s.slice(1);
|
|
7577
7986
|
}
|
|
7578
7987
|
|
|
7579
7988
|
var TypingIndicator = function (_) {
|
|
7580
|
-
return (React.createElement("div", { className: "typing-indicator" },
|
|
7581
|
-
React.createElement("div", { className: "typing-indicator-part" }),
|
|
7582
|
-
React.createElement("div", { className: "typing-indicator-part" }),
|
|
7583
|
-
React.createElement("div", { className: "typing-indicator-part" })));
|
|
7989
|
+
return (React$1.createElement("div", { className: "typing-indicator" },
|
|
7990
|
+
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
7991
|
+
React$1.createElement("div", { className: "typing-indicator-part" }),
|
|
7992
|
+
React$1.createElement("div", { className: "typing-indicator-part" })));
|
|
7584
7993
|
};
|
|
7585
7994
|
|
|
7586
7995
|
/**
|
|
@@ -7589,13 +7998,13 @@ var TypingIndicator = function (_) {
|
|
|
7589
7998
|
var TypingStatus = function (props) {
|
|
7590
7999
|
var agent_names = Object.values(props.agents)
|
|
7591
8000
|
.filter(function (agent) { return agent.typing; });
|
|
7592
|
-
return (React.createElement(React.Fragment, null, agent_names.map(function (agent) {
|
|
7593
|
-
return (React.createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-"
|
|
7594
|
-
React.createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
|
|
7595
|
-
React.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
|
|
7596
|
-
React.createElement("div", { className: "chat-msg" },
|
|
7597
|
-
React.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
7598
|
-
React.createElement(TypingIndicator, null)))))));
|
|
8001
|
+
return (React$1.createElement(React$1.Fragment, null, agent_names.map(function (agent) {
|
|
8002
|
+
return (React$1.createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-".concat(agent.user.nick) },
|
|
8003
|
+
React$1.createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
|
|
8004
|
+
React$1.createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
|
|
8005
|
+
React$1.createElement("div", { className: "chat-msg" },
|
|
8006
|
+
React$1.createElement(ChatMessageBubble, { owner: "others", hasTail: true },
|
|
8007
|
+
React$1.createElement(TypingIndicator, null)))))));
|
|
7599
8008
|
})));
|
|
7600
8009
|
};
|
|
7601
8010
|
|
|
@@ -7645,20 +8054,20 @@ var MessageList = function (props) {
|
|
|
7645
8054
|
switch (msg.type) {
|
|
7646
8055
|
case "chat.file":
|
|
7647
8056
|
case "chat.msg":
|
|
7648
|
-
return (React.createElement(ChatMessage, { key: msg.type + msg.timestamp, message: msg, sibling: sibling, agent: user, messageMiddleware: props.messageMiddleware, middlewareContext: ctxCache.resolve(user) }));
|
|
8057
|
+
return (React$1.createElement(ChatMessage, { key: msg.type + msg.timestamp, message: msg, sibling: sibling, agent: user, messageMiddleware: props.messageMiddleware, middlewareContext: ctxCache.resolve(user) }));
|
|
7649
8058
|
case "chat.memberjoin":
|
|
7650
8059
|
case "chat.memberleave":
|
|
7651
8060
|
case "chat.rating":
|
|
7652
8061
|
case "chat.typing":
|
|
7653
|
-
return (React.createElement(SystemMessage, { key: msg.type + msg.timestamp, message: msg }));
|
|
8062
|
+
return (React$1.createElement(SystemMessage, { key: msg.type + msg.timestamp, message: msg }));
|
|
7654
8063
|
case "chat.request.rating":
|
|
7655
|
-
return (React.createElement(ChatRatingContainer, { key: msg.type + msg.timestamp, agent: user, hasRating: props.hasRating, shouldDisplay: msg.timestamp === props.lastRatingRequestTimestamp }));
|
|
8064
|
+
return (React$1.createElement(ChatRatingContainer, { key: msg.type + msg.timestamp, agent: user, hasRating: props.hasRating, shouldDisplay: msg.timestamp === props.lastRatingRequestTimestamp }));
|
|
7656
8065
|
case "chat.offline":
|
|
7657
|
-
return React.createElement(OfflineFormContainer, { key: "offline-"
|
|
8066
|
+
return React$1.createElement(OfflineFormContainer, { key: "offline-".concat(msg.timestamp) });
|
|
7658
8067
|
case "chat.prechat":
|
|
7659
|
-
return React.createElement(PrechatFormContainer, { key: "prechat" });
|
|
8068
|
+
return React$1.createElement(PrechatFormContainer, { key: "prechat" });
|
|
7660
8069
|
default:
|
|
7661
|
-
return React.createElement("div", { key: +new Date() },
|
|
8070
|
+
return React$1.createElement("div", { key: +new Date() },
|
|
7662
8071
|
"Unhandled message: ",
|
|
7663
8072
|
JSON.stringify(msg));
|
|
7664
8073
|
}
|
|
@@ -7681,23 +8090,23 @@ var MessageList = function (props) {
|
|
|
7681
8090
|
});
|
|
7682
8091
|
}
|
|
7683
8092
|
var agents = props.agents, queuePosition = props.queuePosition;
|
|
7684
|
-
return (React.createElement("div", { className: "message-list-container" },
|
|
7685
|
-
React.createElement("div", { className: "message-list-container__msgs" },
|
|
8093
|
+
return (React$1.createElement("div", { className: "message-list-container" },
|
|
8094
|
+
React$1.createElement("div", { className: "message-list-container__msgs" },
|
|
7686
8095
|
renderAll(),
|
|
7687
|
-
React.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
|
|
7688
|
-
React.createElement(QueuePosition, { position: queuePosition }),
|
|
7689
|
-
React.createElement(TypingStatus, { agents: agents })),
|
|
7690
|
-
React.createElement(ChatChipsContainer, null)));
|
|
8096
|
+
React$1.createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
|
|
8097
|
+
React$1.createElement(QueuePosition, { position: queuePosition }),
|
|
8098
|
+
React$1.createElement(TypingStatus, { agents: agents })),
|
|
8099
|
+
React$1.createElement(ChatChipsContainer, null)));
|
|
7691
8100
|
};
|
|
7692
8101
|
|
|
7693
8102
|
var ServerOffline = function () {
|
|
7694
|
-
return React.createElement("div", { className: "server-offline" },
|
|
7695
|
-
React.createElement("h2", null, "Chat is currently unavailable"),
|
|
7696
|
-
React.createElement("h3", null, "Server is offline"));
|
|
8103
|
+
return React$1.createElement("div", { className: "server-offline" },
|
|
8104
|
+
React$1.createElement("h2", null, "Chat is currently unavailable"),
|
|
8105
|
+
React$1.createElement("h3", null, "Server is offline"));
|
|
7697
8106
|
};
|
|
7698
8107
|
|
|
7699
8108
|
var MinimizeButton = function (props) {
|
|
7700
|
-
return React.createElement("div", { className: "minimize-button", onClick: props.onClick });
|
|
8109
|
+
return React$1.createElement("div", { className: "minimize-button", onClick: props.onClick });
|
|
7701
8110
|
};
|
|
7702
8111
|
|
|
7703
8112
|
var DEFAULT_STATUS_CONFIG = {
|
|
@@ -7717,23 +8126,23 @@ function getStatusText(status, config) {
|
|
|
7717
8126
|
}
|
|
7718
8127
|
var StatusContainer = function (props) {
|
|
7719
8128
|
var _a;
|
|
7720
|
-
return (React.createElement("div", { className: "status-container" },
|
|
7721
|
-
React.createElement("div", { className: "status-container__avatar" },
|
|
7722
|
-
React.createElement(Avatar, { entity: props.agent })),
|
|
7723
|
-
React.createElement("div", { className: "status-text" },
|
|
7724
|
-
React.createElement("span", null, getStatusText(props.accountStatus, (_a = props.config) === null || _a === void 0 ? void 0 : _a.status))),
|
|
8129
|
+
return (React$1.createElement("div", { className: "status-container" },
|
|
8130
|
+
React$1.createElement("div", { className: "status-container__avatar" },
|
|
8131
|
+
React$1.createElement(Avatar, { entity: props.agent })),
|
|
8132
|
+
React$1.createElement("div", { className: "status-text" },
|
|
8133
|
+
React$1.createElement("span", null, getStatusText(props.accountStatus, (_a = props.config) === null || _a === void 0 ? void 0 : _a.status))),
|
|
7725
8134
|
props.canMinimize &&
|
|
7726
|
-
React.createElement(MinimizeButton, { onClick: props.minimizeOnClick })));
|
|
8135
|
+
React$1.createElement(MinimizeButton, { onClick: props.minimizeOnClick })));
|
|
7727
8136
|
};
|
|
7728
8137
|
|
|
7729
8138
|
function buildStyleContent(theme) {
|
|
7730
8139
|
var _a, _b, _c, _d;
|
|
7731
|
-
return "\n:root {\n"
|
|
8140
|
+
return "\n:root {\n".concat(buildVariables(withPrefix("\t--xapp-", union(single("primary-color", theme === null || theme === void 0 ? void 0 : theme.primaryColor), withPrefix("widget-", union(getSize(theme === null || theme === void 0 ? void 0 : theme.size), getMargins(theme === null || theme === void 0 ? void 0 : theme.margin), getBorderStyle(theme === null || theme === void 0 ? void 0 : theme.border))), getChatButtonStyle(theme === null || theme === void 0 ? void 0 : theme.chatButton), withPrefix("header-", getHeaderStyle(theme === null || theme === void 0 ? void 0 : theme.header)), withPrefix("footer-", getFooterStyle(theme === null || theme === void 0 ? void 0 : theme.footer)), withPrefix("content-", union(getBackgroundStyle((_a = theme === null || theme === void 0 ? void 0 : theme.content) === null || _a === void 0 ? void 0 : _a.background))), withPrefix("messages-", getMessagesStyle(theme === null || theme === void 0 ? void 0 : theme.messages)), withPrefix("send-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.sendButton)), withPrefix("menu-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.menuButton)), withPrefix("menu-", getMenuStyle(theme === null || theme === void 0 ? void 0 : theme.menu)), withPrefix("minimize-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.minimizeButton)), withPrefix("carousel-", union(withPrefix("title-", getTextStyle((_b = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _b === void 0 ? void 0 : _b.title)), withPrefix("subtitle-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.subtitle)), withPrefix("action-", getButtonStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.button)))), withPrefix("input-", getInputStyle(theme === null || theme === void 0 ? void 0 : theme.input)), withPrefix("cta-", getCtaStyle(theme === null || theme === void 0 ? void 0 : theme.cta))))), "\n}");
|
|
7732
8141
|
}
|
|
7733
8142
|
function WidgetStylesheet(props) {
|
|
7734
8143
|
var theme = props.theme;
|
|
7735
8144
|
var stylesContent = buildStyleContent(theme);
|
|
7736
|
-
return (React.createElement("style", null, stylesContent));
|
|
8145
|
+
return (React$1.createElement("style", null, stylesContent));
|
|
7737
8146
|
}
|
|
7738
8147
|
function buildVariables(gen) {
|
|
7739
8148
|
var result = gen.next();
|
|
@@ -7741,7 +8150,7 @@ function buildVariables(gen) {
|
|
|
7741
8150
|
while (result.done === false) {
|
|
7742
8151
|
var _a = result.value, key = _a[0], value = _a[1];
|
|
7743
8152
|
if (value !== undefined && value !== null && value !== "") {
|
|
7744
|
-
res += key
|
|
8153
|
+
res += "".concat(key, ": ").concat(value, ";\n\r");
|
|
7745
8154
|
}
|
|
7746
8155
|
result = gen.next();
|
|
7747
8156
|
}
|
|
@@ -7749,14 +8158,14 @@ function buildVariables(gen) {
|
|
|
7749
8158
|
}
|
|
7750
8159
|
function withPrefix(prefix, gen) {
|
|
7751
8160
|
var result;
|
|
7752
|
-
return __generator(this, function (_a) {
|
|
8161
|
+
return __generator$1(this, function (_a) {
|
|
7753
8162
|
switch (_a.label) {
|
|
7754
8163
|
case 0:
|
|
7755
8164
|
result = gen.next();
|
|
7756
8165
|
_a.label = 1;
|
|
7757
8166
|
case 1:
|
|
7758
8167
|
if (!!result.done) return [3 /*break*/, 3];
|
|
7759
|
-
return [4 /*yield*/, [""
|
|
8168
|
+
return [4 /*yield*/, ["".concat(prefix).concat(result.value[0]), result.value[1]]];
|
|
7760
8169
|
case 2:
|
|
7761
8170
|
_a.sent();
|
|
7762
8171
|
result = gen.next();
|
|
@@ -7771,7 +8180,7 @@ function union() {
|
|
|
7771
8180
|
for (_i = 0; _i < arguments.length; _i++) {
|
|
7772
8181
|
children[_i] = arguments[_i];
|
|
7773
8182
|
}
|
|
7774
|
-
return __generator(this, function (_b) {
|
|
8183
|
+
return __generator$1(this, function (_b) {
|
|
7775
8184
|
switch (_b.label) {
|
|
7776
8185
|
case 0:
|
|
7777
8186
|
_a = 0, children_1 = children;
|
|
@@ -7796,7 +8205,7 @@ function union() {
|
|
|
7796
8205
|
});
|
|
7797
8206
|
}
|
|
7798
8207
|
function single(key, value) {
|
|
7799
|
-
return __generator(this, function (_a) {
|
|
8208
|
+
return __generator$1(this, function (_a) {
|
|
7800
8209
|
switch (_a.label) {
|
|
7801
8210
|
case 0: return [4 /*yield*/, [key, value]];
|
|
7802
8211
|
case 1:
|
|
@@ -7806,7 +8215,7 @@ function single(key, value) {
|
|
|
7806
8215
|
});
|
|
7807
8216
|
}
|
|
7808
8217
|
function empty() {
|
|
7809
|
-
return __generator(this, function (_a) {
|
|
8218
|
+
return __generator$1(this, function (_a) {
|
|
7810
8219
|
return [2 /*return*/];
|
|
7811
8220
|
});
|
|
7812
8221
|
}
|
|
@@ -7826,7 +8235,7 @@ function getMessageStyle(style) {
|
|
|
7826
8235
|
return union(single('bubble-color', style === null || style === void 0 ? void 0 : style.bubbleColor), getTextStyle(style === null || style === void 0 ? void 0 : style.text));
|
|
7827
8236
|
}
|
|
7828
8237
|
function getSize(style) {
|
|
7829
|
-
return __generator(this, function (_a) {
|
|
8238
|
+
return __generator$1(this, function (_a) {
|
|
7830
8239
|
switch (_a.label) {
|
|
7831
8240
|
case 0: return [4 /*yield*/, ['width', style === null || style === void 0 ? void 0 : style.width]];
|
|
7832
8241
|
case 1:
|
|
@@ -7839,7 +8248,7 @@ function getSize(style) {
|
|
|
7839
8248
|
});
|
|
7840
8249
|
}
|
|
7841
8250
|
function getMargins(style) {
|
|
7842
|
-
return __generator(this, function (_a) {
|
|
8251
|
+
return __generator$1(this, function (_a) {
|
|
7843
8252
|
switch (_a.label) {
|
|
7844
8253
|
case 0:
|
|
7845
8254
|
if (!style) return [3 /*break*/, 5];
|
|
@@ -7861,7 +8270,7 @@ function getMargins(style) {
|
|
|
7861
8270
|
});
|
|
7862
8271
|
}
|
|
7863
8272
|
function getPaddings(style) {
|
|
7864
|
-
return __generator(this, function (_a) {
|
|
8273
|
+
return __generator$1(this, function (_a) {
|
|
7865
8274
|
switch (_a.label) {
|
|
7866
8275
|
case 0:
|
|
7867
8276
|
if (!style) return [3 /*break*/, 5];
|
|
@@ -7883,7 +8292,7 @@ function getPaddings(style) {
|
|
|
7883
8292
|
});
|
|
7884
8293
|
}
|
|
7885
8294
|
function getTextStyle(style) {
|
|
7886
|
-
return __generator(this, function (_a) {
|
|
8295
|
+
return __generator$1(this, function (_a) {
|
|
7887
8296
|
switch (_a.label) {
|
|
7888
8297
|
case 0:
|
|
7889
8298
|
if (!style) return [3 /*break*/, 6];
|
|
@@ -7908,7 +8317,7 @@ function getTextStyle(style) {
|
|
|
7908
8317
|
});
|
|
7909
8318
|
}
|
|
7910
8319
|
function getBackgroundStyle(style) {
|
|
7911
|
-
return __generator(this, function (_a) {
|
|
8320
|
+
return __generator$1(this, function (_a) {
|
|
7912
8321
|
switch (_a.label) {
|
|
7913
8322
|
case 0: return [4 /*yield*/, ["background", style]];
|
|
7914
8323
|
case 1:
|
|
@@ -7918,7 +8327,7 @@ function getBackgroundStyle(style) {
|
|
|
7918
8327
|
});
|
|
7919
8328
|
}
|
|
7920
8329
|
function getButtonStyle(style) {
|
|
7921
|
-
return __generator(this, function (_a) {
|
|
8330
|
+
return __generator$1(this, function (_a) {
|
|
7922
8331
|
switch (_a.label) {
|
|
7923
8332
|
case 0: return [4 /*yield*/, ['button-color', style === null || style === void 0 ? void 0 : style.color]];
|
|
7924
8333
|
case 1:
|
|
@@ -7934,7 +8343,7 @@ function getMenuStyle(style) {
|
|
|
7934
8343
|
return union(withPrefix("item-", getMenuItemStyle(style === null || style === void 0 ? void 0 : style.item)));
|
|
7935
8344
|
}
|
|
7936
8345
|
function getBorderStyle(style) {
|
|
7937
|
-
return __generator(this, function (_a) {
|
|
8346
|
+
return __generator$1(this, function (_a) {
|
|
7938
8347
|
switch (_a.label) {
|
|
7939
8348
|
case 0:
|
|
7940
8349
|
if (!style) return [3 /*break*/, 4];
|
|
@@ -7985,9 +8394,9 @@ var ChatWidgetWrapper = function (props) {
|
|
|
7985
8394
|
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 }));
|
|
7986
8395
|
}, [connection, rawConfig]);
|
|
7987
8396
|
var chatServer = useChatServer(connection);
|
|
7988
|
-
return (React.createElement(ChatConfigContext.Provider, { value: config },
|
|
7989
|
-
React.createElement(ChatServerContext.Provider, { value: chatServer },
|
|
7990
|
-
React.createElement(ChatWidget, __assign({}, props)))));
|
|
8397
|
+
return (React$1.createElement(ChatConfigContext.Provider, { value: config },
|
|
8398
|
+
React$1.createElement(ChatServerContext.Provider, { value: chatServer },
|
|
8399
|
+
React$1.createElement(ChatWidget, __assign({}, props)))));
|
|
7991
8400
|
};
|
|
7992
8401
|
var ChatWidget = function (props) {
|
|
7993
8402
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -7998,10 +8407,10 @@ var ChatWidget = function (props) {
|
|
|
7998
8407
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
7999
8408
|
var dockedMode = mode === "docked";
|
|
8000
8409
|
var staticMode = mode === "static";
|
|
8001
|
-
var modeClass = "widget-container--"
|
|
8410
|
+
var modeClass = "widget-container--".concat(mode);
|
|
8002
8411
|
var canMinimize = !dockedMode && !staticMode;
|
|
8003
8412
|
// Our state - pull from storage
|
|
8004
|
-
var _g = useState(!canMinimize || !!get("visible)") || (((_b = props.config) === null || _b === void 0 ? void 0 : _b.autoOpenOnWidth) && window.matchMedia("(min-width: "
|
|
8413
|
+
var _g = useState(!canMinimize || !!get("visible)") || (((_b = props.config) === null || _b === void 0 ? void 0 : _b.autoOpenOnWidth) && window.matchMedia("(min-width: ".concat((_c = props.config) === null || _c === void 0 ? void 0 : _c.autoOpenOnWidth, ")")).matches)), visible = _g[0], setVisibleState = _g[1];
|
|
8005
8414
|
var _h = useState(false), typing = _h[0], setTypingState = _h[1]; // false initially
|
|
8006
8415
|
var chatServer = useContext(ChatServerContext);
|
|
8007
8416
|
function setVisible(newVisible) {
|
|
@@ -8103,16 +8512,16 @@ var ChatWidget = function (props) {
|
|
|
8103
8512
|
}
|
|
8104
8513
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
8105
8514
|
useExternalScript((_d = props.config) === null || _d === void 0 ? void 0 : _d.middlewareUrl);
|
|
8106
|
-
return (React.createElement(React.Fragment, null,
|
|
8107
|
-
React.createElement("div", { className: "widget-container "
|
|
8108
|
-
React.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
8109
|
-
React.createElement(StatusContainer, { accountStatus: chatState.accountStatus, minimizeOnClick: minimizeOnClick, agent: (_e = chatState.agents["agent:robot"]) === null || _e === void 0 ? void 0 : _e.user, canMinimize: canMinimize, config: config === null || config === void 0 ? void 0 : config.header }),
|
|
8110
|
-
React.createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
8111
|
-
React.createElement("div", { className: "spinner-container "
|
|
8112
|
-
React.createElement("div", { className: "spinner" })),
|
|
8113
|
-
connectionStatus === "offline" && React.createElement(ServerOffline, null),
|
|
8114
|
-
React.createElement(ChatFooter, { isChatting: chatState.isChatting, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
|
|
8115
|
-
React.createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_f = props.config) === null || _f === void 0 ? void 0 : _f.cta, visible: visible })));
|
|
8515
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
8516
|
+
React$1.createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
8517
|
+
React$1.createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
8518
|
+
React$1.createElement(StatusContainer, { accountStatus: chatState.accountStatus, minimizeOnClick: minimizeOnClick, agent: (_e = chatState.agents["agent:robot"]) === null || _e === void 0 ? void 0 : _e.user, canMinimize: canMinimize, config: config === null || config === void 0 ? void 0 : config.header }),
|
|
8519
|
+
React$1.createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
8520
|
+
React$1.createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
8521
|
+
React$1.createElement("div", { className: "spinner" })),
|
|
8522
|
+
connectionStatus === "offline" && React$1.createElement(ServerOffline, null),
|
|
8523
|
+
React$1.createElement(ChatFooter, { isChatting: chatState.isChatting, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
|
|
8524
|
+
React$1.createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_f = props.config) === null || _f === void 0 ? void 0 : _f.cta, visible: visible })));
|
|
8116
8525
|
};
|
|
8117
8526
|
|
|
8118
8527
|
function tryParseJson(str) {
|
|
@@ -8151,7 +8560,7 @@ var BrowserStateStorage = /** @class */ (function () {
|
|
|
8151
8560
|
* @returns {string}
|
|
8152
8561
|
*/
|
|
8153
8562
|
function visitorFingerprint() {
|
|
8154
|
-
return
|
|
8563
|
+
return uuid_1();
|
|
8155
8564
|
}
|
|
8156
8565
|
|
|
8157
8566
|
var DEFAULT_VISITOR = {
|
|
@@ -8207,7 +8616,7 @@ function connectionReducer(state, action) {
|
|
|
8207
8616
|
}
|
|
8208
8617
|
|
|
8209
8618
|
function joinMessages(messages, msg) {
|
|
8210
|
-
return insertSorted(__spreadArray([], messages, true), msg, function (left, right) { return left.timestamp - right.timestamp; });
|
|
8619
|
+
return insertSorted(__spreadArray$1([], messages, true), msg, function (left, right) { return left.timestamp - right.timestamp; });
|
|
8211
8620
|
}
|
|
8212
8621
|
|
|
8213
8622
|
function memberJoin(state, detail) {
|
|
@@ -8238,7 +8647,7 @@ function memberLeave(state, detail) {
|
|
|
8238
8647
|
|
|
8239
8648
|
function resetReducer(state) {
|
|
8240
8649
|
if (state === void 0) { state = DEFAULT_STATE; }
|
|
8241
|
-
return __assign(__assign({}, createDefaultState()), { connection: __assign(__assign({}, state.connection), { nonce:
|
|
8650
|
+
return __assign(__assign({}, createDefaultState()), { connection: __assign(__assign({}, state.connection), { nonce: uuid_1() }), visitor: state.visitor, visitorId: state.visitorId });
|
|
8242
8651
|
}
|
|
8243
8652
|
|
|
8244
8653
|
// todo: create reducer (requires redux-thunk dependncy)
|
|
@@ -8337,7 +8746,7 @@ function mapSynthetic(state, action) {
|
|
|
8337
8746
|
}
|
|
8338
8747
|
};
|
|
8339
8748
|
default:
|
|
8340
|
-
throw new Error("Unknown synthetic action. Detail type: "
|
|
8749
|
+
throw new Error("Unknown synthetic action. Detail type: ".concat(action.detail.type));
|
|
8341
8750
|
}
|
|
8342
8751
|
}
|
|
8343
8752
|
function storeHandler(state, action) {
|
|
@@ -8352,13 +8761,14 @@ function storeHandler(state, action) {
|
|
|
8352
8761
|
}
|
|
8353
8762
|
}
|
|
8354
8763
|
|
|
8355
|
-
function createChatStore(config) {
|
|
8356
|
-
|
|
8764
|
+
function createChatStore(config, dataStorage) {
|
|
8765
|
+
if (dataStorage === void 0) { dataStorage = sessionStorage; }
|
|
8766
|
+
var storage = new BrowserStateStorage(dataStorage, "xappchat.".concat(config.serverUrl, ".").concat(config.accountKey));
|
|
8357
8767
|
var chatReducer = persistStateReducer(storage, DEFAULT_STATE, storeHandler);
|
|
8358
8768
|
var middlewares = [
|
|
8359
8769
|
thunk
|
|
8360
8770
|
];
|
|
8361
|
-
var composeEnhancers =
|
|
8771
|
+
var composeEnhancers = globalThis.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
8362
8772
|
return createStore$1(chatReducer, composeEnhancers(applyMiddleware.apply(void 0, middlewares)));
|
|
8363
8773
|
}
|
|
8364
8774
|
|
|
@@ -8368,11 +8778,11 @@ var ChatWidgetContainer = function (props) {
|
|
|
8368
8778
|
var connection = useServerConfig(props.config);
|
|
8369
8779
|
var chatStore = useMemo(function () { return createChatStore(connection); }, [connection]);
|
|
8370
8780
|
if ((_a = props.config) === null || _a === void 0 ? void 0 : _a.disabled) {
|
|
8371
|
-
return React.createElement(React.Fragment, null);
|
|
8781
|
+
return React$1.createElement(React$1.Fragment, null);
|
|
8372
8782
|
}
|
|
8373
8783
|
var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware });
|
|
8374
|
-
return (React.createElement(Provider, { store: chatStore },
|
|
8375
|
-
React.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
|
|
8784
|
+
return (React$1.createElement(Provider, { store: chatStore },
|
|
8785
|
+
React$1.createElement(ChatWidgetWrapper, __assign({}, widgetProps))));
|
|
8376
8786
|
};
|
|
8377
8787
|
|
|
8378
8788
|
function createStaticReducer(state) {
|
|
@@ -8402,13 +8812,13 @@ var StaticChatWidgetContainer = function (props) {
|
|
|
8402
8812
|
type: "local"
|
|
8403
8813
|
} });
|
|
8404
8814
|
}, [props.config]);
|
|
8405
|
-
return (React.createElement(Provider, { store: store },
|
|
8406
|
-
React.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
|
|
8815
|
+
return (React$1.createElement(Provider, { store: store },
|
|
8816
|
+
React$1.createElement(ChatWidgetWrapper, __assign({}, props, { config: config }))));
|
|
8407
8817
|
};
|
|
8408
8818
|
|
|
8409
8819
|
function createStateFromMessages(messages) {
|
|
8410
8820
|
var def = createDefaultState();
|
|
8411
|
-
return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray([], messages, true), isChatting: true });
|
|
8821
|
+
return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), isChatting: true });
|
|
8412
8822
|
}
|
|
8413
8823
|
|
|
8414
8824
|
var StaticMessagesChatWidgetContainer = function (props) {
|
|
@@ -8416,7 +8826,7 @@ var StaticMessagesChatWidgetContainer = function (props) {
|
|
|
8416
8826
|
var state = useMemo(function () {
|
|
8417
8827
|
return createStateFromMessages(messages);
|
|
8418
8828
|
}, [messages]);
|
|
8419
|
-
return (React.createElement(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config }));
|
|
8829
|
+
return (React$1.createElement(StaticChatWidgetContainer, { state: state, mode: props.mode, config: props.config }));
|
|
8420
8830
|
};
|
|
8421
8831
|
|
|
8422
8832
|
export { ActionButton, Avatar, CardMiddleware, Carousel, CarouselItem, ChatWidgetContainer as Chat, ChatButton, ChatCard, ChatChip, ChatChips, ChatMenu, ChatMessage, ChatMessageBubble, ChatMessagePart, ChatWidgetWrapper as ChatWidget, CtaBubble, CtaBubbleContainer, List, ListItem, ListMiddleware, MessageList, MiddlewareContextFactory, StaticChatWidgetContainer, StaticMessagesChatWidgetContainer, joinMiddlewares, responseToMessage, useLateMiddleware, useStandardMiddleware };
|