@koredev/agentai-web-sdk 1.3.7-rc → 1.3.9-rc

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.
@@ -1,374 +1,183 @@
1
1
  "use strict";
2
2
  self["webpackHotUpdateaa_sdk"]("KoreAASDK",{
3
3
 
4
- /***/ "./src/components/common/templatemanager/tabs/search/search.tsx":
5
- /*!**********************************************************************!*\
6
- !*** ./src/components/common/templatemanager/tabs/search/search.tsx ***!
7
- \**********************************************************************/
4
+ /***/ "./src/components/common/services/web-socket-service.ts":
5
+ /*!**************************************************************!*\
6
+ !*** ./src/components/common/services/web-socket-service.ts ***!
7
+ \**************************************************************/
8
8
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9
9
 
10
10
  __webpack_require__.r(__webpack_exports__);
11
11
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
- /* harmony export */ Search: () => (/* binding */ Search),
13
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
14
- /* harmony export */ searchInputTemplate: () => (/* binding */ searchInputTemplate)
12
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
15
13
  /* harmony export */ });
16
- /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.module.js");
17
- /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "./node_modules/preact/hooks/dist/hooks.module.js");
18
- /* harmony import */ var _constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../constants/events.cnst */ "./src/components/common/constants/events.cnst.ts");
19
- /* harmony import */ var _search_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./search.scss */ "./src/components/common/templatemanager/tabs/search/search.scss");
20
- /* harmony import */ var _suggestions_article_article__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../suggestions/article/article */ "./src/components/common/templatemanager/tabs/suggestions/article/article.tsx");
21
- /* harmony import */ var _suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../suggestions/faq/faq */ "./src/components/common/templatemanager/tabs/suggestions/faq/faq.tsx");
22
- /* harmony import */ var _suggestions_snippet_snippet__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../suggestions/snippet/snippet */ "./src/components/common/templatemanager/tabs/suggestions/snippet/snippet.tsx");
23
- /* harmony import */ var _suggestions_file_file__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../suggestions/file/file */ "./src/components/common/templatemanager/tabs/suggestions/file/file.tsx");
24
- /* harmony import */ var _templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../templatemanager/base/domManager */ "./src/components/common/templatemanager/base/domManager.tsx");
25
- /* harmony import */ var _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../constants/projConsts */ "./src/components/common/constants/projConsts.ts");
26
- /* harmony import */ var _suggestion_placeholder_suggestion_placeholder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../suggestion-placeholder/suggestion-placeholder */ "./src/components/common/templatemanager/tabs/suggestion-placeholder/suggestion-placeholder.tsx");
27
- /* harmony import */ var _atom_actionButtons__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../atom/actionButtons */ "./src/components/common/templatemanager/tabs/atom/actionButtons.tsx");
28
- var __assign = (undefined && undefined.__assign) || function () {
29
- __assign = Object.assign || function(t) {
30
- for (var s, i = 1, n = arguments.length; i < n; i++) {
31
- s = arguments[i];
32
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
33
- t[p] = s[p];
34
- }
35
- return t;
36
- };
37
- return __assign.apply(this, arguments);
38
- };
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
- function searchInputTemplate() {
52
- return (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "input-block aa-input-block" },
53
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("input", { id: "aa-search-input", type: "text", className: "input-control", "aria-describedby": "search", placeholder: "Ask a customer", value: "" }),
54
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", className: "aa-input-search-icon" },
55
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8.33342 1.66675C4.65152 1.66675 1.66675 4.65152 1.66675 8.33342C1.66675 12.0153 4.65152 15.0001 8.33342 15.0001C9.87401 15.0001 11.2925 14.4775 12.4215 13.6L16.9108 18.0893C17.2363 18.4148 17.7639 18.4148 18.0893 18.0893C18.4148 17.7639 18.4148 17.2363 18.0893 16.9108L13.6 12.4215C14.4775 11.2925 15.0001 9.87401 15.0001 8.33342C15.0001 4.65152 12.0153 1.66675 8.33342 1.66675ZM3.33341 8.33342C3.33341 5.57199 5.57199 3.33341 8.33342 3.33341C11.0948 3.33341 13.3334 5.57199 13.3334 8.33342C13.3334 11.0948 11.0948 13.3334 8.33342 13.3334C5.57199 13.3334 3.33341 11.0948 3.33341 8.33342Z", fill: "#667085" })),
56
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("button", { className: "clear-search aa-input-search-close aa-hidden" },
57
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none" },
58
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("path", { d: "M15 5.2002L5 15.2002M5 5.2002L15 15.2002", stroke: "#667085", "stroke-width": "1.66667", "stroke-linecap": "round", "stroke-linejoin": "round" }))));
59
- }
60
- function Search(_a) {
61
- var _b, _c, _d;
62
- var hostInstance = _a.hostInstance;
63
- var _e = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)({ value: '', isEntered: false, stTime: null, edTime: null }), searchText = _e[0], setSearchText = _e[1];
64
- var _f = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)(''), autocompleteText = _f[0], setAutocompleteText = _f[1];
65
- // const [rootServiceInstance.answerPlaceableIDs, setAnswerPlaceableIDs] = useState<AnswerPlaceableID[]>([]);
66
- var _g = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)({}), searchResponse = _g[0], setSearchResponse = _g[1];
67
- var _h = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)(false), searched = _h[0], setSearched = _h[1];
68
- var _j = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)(false), showSpinner = _j[0], setShowSpinner = _j[1];
69
- var rootServiceInstance = hostInstance.rootService;
70
- var classConstants = _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst;
71
- var idConstants = _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.IdMapConstant;
72
- var startTime = null;
73
- var endTime = null;
74
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
75
- var handleAgentAssistAgentResponse = function (agentResponse) {
76
- var _a;
77
- if ((agentResponse === null || agentResponse === void 0 ? void 0 : agentResponse.suggestions) && ((_a = Object.keys(agentResponse === null || agentResponse === void 0 ? void 0 : agentResponse.suggestions)) === null || _a === void 0 ? void 0 : _a.length) > 0 && (agentResponse.isSearch || agentResponse.uiunqref)) {
78
- handleSearchResponse(agentResponse);
79
- setShowSpinner(false);
80
- rootServiceInstance.searchedResultData = agentResponse;
14
+ /* harmony import */ var socket_io_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! socket.io-client */ "./node_modules/socket.io-client/build/esm/index.js");
15
+ /* harmony import */ var _constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../constants/events.cnst */ "./src/components/common/constants/events.cnst.ts");
16
+
17
+
18
+ var websocketservice = /** @class */ (function () {
19
+ function websocketservice(hostIns) {
20
+ this.prevTimeStamp = 0;
21
+ this.intervalTime = 510;
22
+ this.count = 1;
23
+ this.hostIns = hostIns;
24
+ }
25
+ websocketservice.prototype.socketConnection = function (configOptions) {
26
+ var _this = this;
27
+ var _a, _b;
28
+ this.configOptions = configOptions;
29
+ var finalUrl = ((_a = configOptions === null || configOptions === void 0 ? void 0 : configOptions.connectionDetails) === null || _a === void 0 ? void 0 : _a.domainURL) + '/koreagentassist';
30
+ var config = {
31
+ url: finalUrl,
32
+ options: {
33
+ path: '/agentassist/api/v1/chat',
34
+ autoConnect: true,
35
+ transports: ['websocket', 'polling', 'flashsocket'],
36
+ reconnection: true,
37
+ reconnectionDelay: 5000,
38
+ reconnectionAttempts: 13,
39
+ query: { 'jToken': (_b = configOptions === null || configOptions === void 0 ? void 0 : configOptions.connectionDetails) === null || _b === void 0 ? void 0 : _b.token }
81
40
  }
82
41
  };
83
- hostInstance.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.DATA_EVENTS.AGENT_AI_AGENT_RESPONSE, handleAgentAssistAgentResponse);
84
- var handleMenuResponse = function (menuResp) {
85
- console.log("menuResp", menuResp);
86
- };
87
- hostInstance.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.DATA_EVENTS.AGENT_MENU_RESPONSE, handleMenuResponse);
88
- addSearchBlock();
89
- return function () {
90
- hostInstance.off(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.DATA_EVENTS.AGENT_AI_AGENT_RESPONSE, handleAgentAssistAgentResponse);
91
- hostInstance.off(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.DATA_EVENTS.AGENT_MENU_RESPONSE, handleMenuResponse);
92
- };
93
- }, []);
94
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
95
- rootServiceInstance.handleSearchText(searchText, hostInstance);
96
- }, [searchText]);
97
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
98
- enableOrdisableInputCloseIcon(showSpinner);
99
- }, [showSpinner]);
100
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
101
- var _a;
102
- if (!rootServiceInstance.faqAnswerIdsPlace && searchResponse && ((_a = Object.keys(searchResponse)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
103
- setSuggestions();
104
- checkFaqAnswerNotRenderCountAndRequest();
105
- }
106
- }, [searchResponse]);
107
- var enableOrdisableInputCloseIcon = function (spinner) {
108
- var _a;
109
- var inputEle = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(classConstants.SEARCH_INPUT_BLOCK);
110
- if (inputEle) {
111
- var closeIcon = inputEle === null || inputEle === void 0 ? void 0 : inputEle.querySelector(classConstants.SEARCH_INPUT_CLOSE);
112
- closeIcon.disabled = spinner;
113
- }
114
- };
115
- var addSearchBlock = function () {
116
- var _a, _b, _c, _d, _e;
117
- var inputHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(searchInputTemplate, {}, hostInstance);
118
- if (inputHtml) {
119
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.BEFORE_VIEW_INIT, inputHtml, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.SEARCH_INPUT });
120
- (_c = (_b = (_a = hostInstance === null || hostInstance === void 0 ? void 0 : hostInstance.chatEle) === null || _a === void 0 ? void 0 : _a.querySelector(classConstants.SEARCH_SUGGESTION_WRAPPER)) === null || _b === void 0 ? void 0 : _b.querySelector("#".concat(idConstants.SEARCH_SUGGESTION_BLOCK))) === null || _c === void 0 ? void 0 : _c.append(inputHtml);
121
- (_d = hostInstance.eventManager) === null || _d === void 0 ? void 0 : _d.addEventListener("#".concat(idConstants.SEARCH_INPUT), 'keyup', function (e) {
122
- if (e.key === 'Enter' && e.target.value) {
123
- getSearchResults(e);
124
- }
125
- else {
126
- onSearch(e);
127
- }
128
- }, inputHtml);
129
- (_e = hostInstance.eventManager) === null || _e === void 0 ? void 0 : _e.addEventListener(classConstants.SEARCH_INPUT_CLOSE, 'click', function (e) {
130
- clearSearch();
131
- }, inputHtml);
132
- }
133
- };
134
- var onSearch = function (event) {
135
- setSearchText({ value: event.target.value, isEntered: false });
136
- var searchText = event.target.value;
137
- // if (rootService.settingsData?.searchAssistConfig?.showAutoSuggestions) {
138
- if (searchText.length > 0) {
139
- if (autocompleteText === searchText || autocompleteText.includes(searchText)) {
140
- // setSecondaryIp(true);
141
- }
142
- else {
143
- // setSecondaryIp(false);
42
+ this._agentAssistSocket = (0,socket_io_client__WEBPACK_IMPORTED_MODULE_0__.io)(config.url, config.options);
43
+ this._agentAssistSocket.connect();
44
+ this.listenEvents();
45
+ this._agentAssistSocket.on("connect", function () {
46
+ console.log("connect");
47
+ _this.hostIns.emit('ON_SOCKET_CONNECTION', configOptions);
48
+ if (!_this.hostIns.rootService.socketConnect) {
49
+ _this.hostIns.rootService.socketConnect = true;
50
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.INTERNAL_EVENTS.GET_CHECKLISTS, true);
144
51
  }
145
- }
146
- else {
147
- // setSecondaryIp(true);
148
- clearSearch();
149
- }
150
- if ((searchText === null || searchText === void 0 ? void 0 : searchText.length) > 0 && !startTime) {
151
- startTime = new Date();
152
- }
153
- };
154
- var getSearchResults = function (event) {
155
- setShowSpinner(true);
156
- setValue(event.target.value, true);
157
- setAutocompleteText('');
158
- setTimeout(function () {
159
- setShowSpinner(false);
160
- }, 15000);
161
- };
162
- var setValue = function (value, isEntered) {
163
- if (isEntered === void 0) { isEntered = false; }
164
- var stTime = null;
165
- var edTime = null;
166
- if (isEntered) {
167
- stTime = startTime;
168
- edTime = new Date();
169
- }
170
- setSearchText({ value: value, isEntered: isEntered, stTime: stTime, edTime: edTime });
171
- };
172
- var clearSearch = function () {
173
- setSearchText({ value: '', isEntered: false });
174
- setAutocompleteText('');
175
- setSearched(false);
176
- setSearchResponse({});
177
- startTime = null;
178
- rootServiceInstance.faqAnswerIdsPlace = false;
52
+ });
53
+ // Handle initial connection errors
54
+ this._agentAssistSocket.on("connect_error", function (error) {
55
+ console.log("connect_error", error);
56
+ });
57
+ // Handle connection timeout
58
+ this._agentAssistSocket.on("connect_timeout", function () {
59
+ console.log("connect_timeout");
60
+ });
61
+ // Handle successful reconnection
62
+ this._agentAssistSocket.on("reconnect", function (attemptNumber) {
63
+ console.log("reconnect", attemptNumber);
64
+ });
65
+ // Handle each reconnection attempt
66
+ this._agentAssistSocket.on("reconnect_attempt", function (attemptNumber) {
67
+ console.log("reconnect_attempt", attemptNumber);
68
+ });
69
+ // Handle failed reconnection attempts
70
+ this._agentAssistSocket.on("reconnect_error", function (error) {
71
+ console.log("reconnect_error", error);
72
+ });
73
+ // Handle final failed reconnection after all attempts
74
+ this._agentAssistSocket.on("reconnect_failed", function () {
75
+ console.log("reconnect_failed");
76
+ });
77
+ // Handle ping timeout
78
+ this._agentAssistSocket.on("ping_timeout", function () {
79
+ console.log("ping_timeout");
80
+ });
179
81
  };
180
- var handleSearchResponse = function (response) {
181
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
182
- setSearched(true);
183
- if (response === null || response === void 0 ? void 0 : response.suggestions) {
184
- if (!response.uiunqref) {
185
- rootServiceInstance.faqAnswerIdsPlace = false;
186
- var sResponse = (rootServiceInstance.formatSearchResponse(response, true, 0));
187
- if (sResponse && Object.keys(sResponse).length > 0) {
188
- sResponse = __assign(__assign({}, sResponse), { totalSearchResults: (((_a = sResponse.dialogs) === null || _a === void 0 ? void 0 : _a.length) || 0) +
189
- (((_b = sResponse.faqs) === null || _b === void 0 ? void 0 : _b.length) || 0) +
190
- (((_c = sResponse.articles) === null || _c === void 0 ? void 0 : _c.length) || 0) +
191
- (((_d = sResponse.files) === null || _d === void 0 ? void 0 : _d.length) || 0) +
192
- (((_e = sResponse.snippets) === null || _e === void 0 ? void 0 : _e.length) || 0) });
193
- setSearchResponse(sResponse);
194
- }
195
- }
196
- else if (response.uiunqref) {
197
- var ambiguityTokenExt_1 = JSON.parse(atob(response.uiunqref));
198
- response.suggestions.faqs = rootServiceInstance.formatFAQResponse(response.suggestions.faqs);
199
- rootServiceInstance.faqAnswerIdsPlace = ambiguityTokenExt_1 && (ambiguityTokenExt_1 === null || ambiguityTokenExt_1 === void 0 ? void 0 : ambiguityTokenExt_1.question) === response.suggestions.faqs[0].question ? true : false;
200
- if (rootServiceInstance.faqAnswerIdsPlace) {
201
- var faqWithoutAnswerIndex = (_g = (_f = response === null || response === void 0 ? void 0 : response.suggestions) === null || _f === void 0 ? void 0 : _f.faqs) === null || _g === void 0 ? void 0 : _g.findIndex(function (faq, index) {
202
- if (faq.question === ambiguityTokenExt_1.question) {
203
- return faq;
204
- }
205
- });
206
- var faqWithoutAnswer_1 = {};
207
- if (faqWithoutAnswerIndex >= 0) {
208
- faqWithoutAnswer_1 = (_h = response === null || response === void 0 ? void 0 : response.suggestions) === null || _h === void 0 ? void 0 : _h.faqs[faqWithoutAnswerIndex];
209
- }
210
- if (faqWithoutAnswer_1 && ((_j = Object.keys(faqWithoutAnswer_1)) === null || _j === void 0 ? void 0 : _j.length) > 0) {
211
- var existingFaqs_1 = [];
212
- setSearchResponse(function (prevResponse) {
213
- var _a;
214
- existingFaqs_1 = (_a = prevResponse === null || prevResponse === void 0 ? void 0 : prevResponse.faqs) === null || _a === void 0 ? void 0 : _a.map(function (faq, idx) {
215
- if (faqWithoutAnswer_1 && faqWithoutAnswer_1.answer && idx === ambiguityTokenExt_1.index) {
216
- faq.answer = faqWithoutAnswer_1.answer;
217
- }
218
- if (faqWithoutAnswer_1) {
219
- faq.showSpinner = false;
220
- }
221
- return faq;
222
- });
223
- return prevResponse;
224
- });
225
- rootServiceInstance.handleFaqAmbiguityDescElement(idConstants.SEARCH_FAQ_SUGGESTION, ambiguityTokenExt_1, existingFaqs_1, hostInstance);
226
- setSearchResponse(function (prevResponse) { return (__assign(__assign({}, prevResponse), { faqs: existingFaqs_1 })); });
227
- }
228
- }
229
- }
82
+ websocketservice.prototype.emitEvents = function (eventName, requestParams, keepOldTraceId) {
83
+ if (keepOldTraceId === void 0) { keepOldTraceId = false; }
84
+ var _a = this.configOptions.connectionDetails, fromSAT = _a.fromSAT, source = _a.source, autoBotId = _a.autoBotId, channel = _a.channel, interactiveLanguage = _a.interactiveLanguage, botId = _a.botId;
85
+ if (requestParams) {
86
+ requestParams.isExtAD = fromSAT ? false : true;
87
+ requestParams.source = source;
88
+ requestParams.experience = channel;
89
+ requestParams.traceId = (keepOldTraceId && requestParams.traceId) ? requestParams.traceId : 'ua-f0f3edc3-16ca-4e02-9363-4f48c602df62';
90
+ requestParams.language = interactiveLanguage;
230
91
  }
231
- else {
232
- setSearchResponse({});
92
+ if (eventName == 'internal_transfer') {
93
+ requestParams.botId = botId;
233
94
  }
95
+ this._agentAssistSocket.emit(eventName, requestParams);
234
96
  };
235
- var removeSuggestionFromDom = function (suggestionslist) {
236
- suggestionslist === null || suggestionslist === void 0 ? void 0 : suggestionslist.forEach(function (element) {
237
- if (element) {
238
- element.innerHTML = '';
239
- }
97
+ websocketservice.prototype.listenEvents = function () {
98
+ var _this = this;
99
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_response, function (data) {
100
+ _this.hostIns.rootService.assistTabSessionId = '';
101
+ if (data.sessionId) {
102
+ _this.hostIns.rootService.assistTabSessionId = data === null || data === void 0 ? void 0 : data.sessionId;
103
+ }
104
+ var settimeoutTime = _this.getTimeout();
105
+ setTimeout(function () {
106
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_AI_RESPONSE, data);
107
+ }, settimeoutTime);
108
+ });
109
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_menu_response, function (data) {
110
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_AI_MENU_RESPONSE, data);
111
+ });
112
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_coaching_response, function (data) {
113
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_COACHING_RESPONSES, data);
114
+ });
115
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.checklist_step_response, function (data) {
116
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.CHECKLIST_STEP_RESPONSE, data);
117
+ });
118
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.checklist_response, function (data) {
119
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.CHECKLIST_RESPONSE, data);
120
+ });
121
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.realtime_sentiment_response, function (data) {
122
+ });
123
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_agent_response, function (data) {
124
+ var settimeoutTime = _this.getTimeout();
125
+ setTimeout(function () {
126
+ _this.hostIns.rootService.sentSearchResponse = false;
127
+ _this.hostIns.rootService.myBotTabSessionId = '';
128
+ if (data.sessionId) {
129
+ _this.hostIns.rootService.myBotTabSessionId = data === null || data === void 0 ? void 0 : data.sessionId;
130
+ }
131
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_AI_AGENT_RESPONSE, data);
132
+ }, settimeoutTime);
133
+ });
134
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_endoftask, function (data) {
135
+ var settimeoutTime = _this.getTimeout();
136
+ setTimeout(function () {
137
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.END_OF_TASK_RESPONSE, data);
138
+ }, settimeoutTime);
139
+ });
140
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.user_message, function (data) {
141
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.USER_TRANSCRIPT_RESPONSE, data);
142
+ });
143
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_message, function (data) {
144
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_TRANSCRIPT_RESPONSE, data);
145
+ });
146
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_assist_user_message, function (data) {
147
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_ASSIST_USER_MESSAGE, data);
148
+ });
149
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agent_feedback_response, function (data) {
150
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.AGENT_FEEDBACK_RESPONSE, data);
151
+ });
152
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.response_resolution_comments, function (data) {
153
+ _this.hostIns.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.DATA_EVENTS.RESOLUTION_COMMENTS_RESPONSE, data);
154
+ });
155
+ this._agentAssistSocket.on(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_1__.EVENTS.agentassist_control_response, function (data) {
240
156
  });
241
157
  };
242
- var setSuggestions = function () {
243
- var _a, _b, _c, _d, _e, _f, _g;
244
- var faqSuggestionElement = document.getElementById(idConstants.SEARCH_FAQ_SUGGESTION);
245
- var snippetSuggestionElement = document.getElementById(idConstants.SEARCH_SNIPPET_SUGGESTION);
246
- var articleSuggestionElement = document.getElementById(idConstants.SEARCH_ARTICLE_SUGGESTION);
247
- var fileSuggestionElement = document.getElementById(idConstants.SEARCH_FILE_SUGGESTION);
248
- removeSuggestionFromDom([faqSuggestionElement, snippetSuggestionElement, articleSuggestionElement, fileSuggestionElement]);
249
- if ((_a = ((searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.faqs) || [])) === null || _a === void 0 ? void 0 : _a.length) {
250
- var faqHtml = void 0;
251
- var faqMoreLessActionHtml = void 0;
252
- faqHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_suggestions_faq_faq__WEBPACK_IMPORTED_MODULE_5__.FAQSuggestion, { searchResponse: searchResponse, hostInstance: hostInstance, faqs: searchResponse.faqs, viewCount: 2 }, hostInstance);
253
- faqMoreLessActionHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_atom_actionButtons__WEBPACK_IMPORTED_MODULE_11__.HandleViewMoreLessButtons, { hostInstance: hostInstance, faqs: searchResponse.faqs, moreClick: false, suggestionLength: (_b = searchResponse.faqs) === null || _b === void 0 ? void 0 : _b.length, showLessText: 'Show less FAQs', showMoreText: 'Show more FAQs' }, hostInstance);
254
- if (faqMoreLessActionHtml) {
255
- faqHtml === null || faqHtml === void 0 ? void 0 : faqHtml.append(faqMoreLessActionHtml);
256
- }
257
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.BEFORE_VIEW_INIT, faqHtml, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.SEARCH_FAQ_TEMPLATE, data: searchResponse.faqs });
258
- faqSuggestionElement === null || faqSuggestionElement === void 0 ? void 0 : faqSuggestionElement.append(faqHtml);
259
- if (faqHtml) {
260
- rootServiceInstance.handleSeeMoreButtonsForFaq(faqSuggestionElement, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.DESC_TEXT_SUGGESTION, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.MORE_BTN_CONTAINER, hostInstance);
261
- }
262
- var faqListHTML = faqHtml.querySelectorAll(classConstants.SUGGESTION_EACH);
263
- rootServiceInstance.renderEachFaqInSuggestionList(searchResponse, faqListHTML, hostInstance, false, {});
264
- //more and less article button click events handling
265
- if (faqMoreLessActionHtml) {
266
- rootServiceInstance.handleSuggestionMoreClickEvent(faqMoreLessActionHtml, faqSuggestionElement, faqListHTML, hostInstance);
267
- rootServiceInstance.handleSuggestionLessClickEvent(faqMoreLessActionHtml, faqSuggestionElement, faqListHTML, hostInstance);
268
- }
158
+ websocketservice.prototype.getTimeout = function () {
159
+ var timestamp1 = Date.now();
160
+ var settimeoutTime = this.intervalTime;
161
+ if ((timestamp1 - this.prevTimeStamp) < this.intervalTime) {
162
+ settimeoutTime = (settimeoutTime * this.count) + (this.intervalTime - (timestamp1 - this.prevTimeStamp));
163
+ this.count += 1;
269
164
  }
270
- if ((_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.snippets) === null || _c === void 0 ? void 0 : _c.length) {
271
- var snippetHtml = void 0;
272
- snippetHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_suggestions_snippet_snippet__WEBPACK_IMPORTED_MODULE_6__.SnippetSuggestion, { searchResponse: searchResponse, hostInstance: hostInstance, snippets: searchResponse.snippets, suggestionIndex: 0 }, hostInstance);
273
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.BEFORE_VIEW_INIT, snippetHtml, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.SEARCH_SNIPPET_TEMPLATE, data: searchResponse.snippets });
274
- snippetSuggestionElement === null || snippetSuggestionElement === void 0 ? void 0 : snippetSuggestionElement.append(snippetHtml);
275
- if (snippetHtml) {
276
- rootServiceInstance.handleSeeMoreButtonsForSearchAssist(snippetSuggestionElement, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.DESC_TEXT_SNIPPET_EXTERNAL, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.EXTERNAL_SNIPPET_MORE_BTN_CONTAINER, hostInstance);
277
- rootServiceInstance.handleSeeMoreButtonsForSearchAssist(snippetSuggestionElement, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.DESC_TEXT_SNIPPET_INTERNAL, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.INTERNAL_SNIPPET_MORE_BTN_CONTAINER, hostInstance);
278
- }
279
- // send, copy and link buttons of article click events handling.
280
- var snippetListHtml = snippetHtml.querySelectorAll(classConstants.SUGGESTION_EACH);
281
- rootServiceInstance.renderEachSnippetInSuggestionList(searchResponse, snippetListHtml, hostInstance);
282
- }
283
- if (((_d = ((searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.articles) || [])) === null || _d === void 0 ? void 0 : _d.length) > 0) {
284
- var articleHtml = void 0;
285
- var articleMoreLessActionHtml = void 0;
286
- articleHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_suggestions_article_article__WEBPACK_IMPORTED_MODULE_4__.ArticleSuggestion, { searchResponse: searchResponse, hostInstance: hostInstance, articles: searchResponse.articles, viewCount: 2 }, hostInstance);
287
- articleMoreLessActionHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_atom_actionButtons__WEBPACK_IMPORTED_MODULE_11__.HandleViewMoreLessButtons, { hostInstance: hostInstance, articles: searchResponse.articles, moreClick: false, suggestionLength: (_e = searchResponse.articles) === null || _e === void 0 ? void 0 : _e.length, showLessText: 'Show less web pages', showMoreText: 'Show more web pages' }, hostInstance);
288
- if (articleMoreLessActionHtml) {
289
- articleHtml === null || articleHtml === void 0 ? void 0 : articleHtml.append(articleMoreLessActionHtml);
290
- }
291
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.BEFORE_VIEW_INIT, articleHtml, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.SEARCH_ARTICE_TEMPLATE, data: searchResponse.articles });
292
- articleSuggestionElement === null || articleSuggestionElement === void 0 ? void 0 : articleSuggestionElement.append(articleHtml);
293
- if (articleHtml) {
294
- rootServiceInstance.handleSeeMoreButtonsForSearchAssist(articleSuggestionElement, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.DESC_TEXT_SUGGESTION, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.MORE_BTN_CONTAINER, hostInstance);
295
- }
296
- // send, copy and link buttons of article click events handling.
297
- var articlesListHTML = articleHtml.querySelectorAll(classConstants.SUGGESTION_EACH);
298
- rootServiceInstance.renderEachArticleInSuggestionList(searchResponse, articlesListHTML, hostInstance);
299
- //more and less article button click events handling
300
- if (articleMoreLessActionHtml) {
301
- rootServiceInstance.handleSuggestionMoreClickEvent(articleMoreLessActionHtml, articleSuggestionElement, articlesListHTML, hostInstance);
302
- rootServiceInstance.handleSuggestionLessClickEvent(articleMoreLessActionHtml, articleSuggestionElement, articlesListHTML, hostInstance);
303
- }
304
- }
305
- if ((_f = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.files) === null || _f === void 0 ? void 0 : _f.length) {
306
- var fileHtml = void 0;
307
- var fileMoreLessActionHtml = void 0;
308
- fileHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_suggestions_file_file__WEBPACK_IMPORTED_MODULE_7__.FileSuggestion, { searchResponse: searchResponse, hostInstance: hostInstance, files: searchResponse.files }, hostInstance);
309
- fileMoreLessActionHtml = (0,_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_8__.getHTML)(_atom_actionButtons__WEBPACK_IMPORTED_MODULE_11__.HandleViewMoreLessButtons, { hostInstance: hostInstance, files: searchResponse.files, moreClick: false, suggestionLength: (_g = searchResponse.files) === null || _g === void 0 ? void 0 : _g.length, showLessText: 'Show Less Files', showMoreText: 'Show More Files' }, hostInstance);
310
- if (fileMoreLessActionHtml) {
311
- fileHtml === null || fileHtml === void 0 ? void 0 : fileHtml.append(fileMoreLessActionHtml);
312
- }
313
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.BEFORE_VIEW_INIT, fileHtml, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_2__.SDK_EVENTS.SEARCH_FILE_TEMPLATE, data: searchResponse.files });
314
- fileSuggestionElement === null || fileSuggestionElement === void 0 ? void 0 : fileSuggestionElement.append(fileHtml);
315
- if (fileHtml) {
316
- rootServiceInstance.handleSeeMoreButtonsForSearchAssist(fileSuggestionElement, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.DESC_TEXT_SUGGESTION, _constants_projConsts__WEBPACK_IMPORTED_MODULE_9__.ClassMapConstanst.MORE_BTN_CONTAINER, hostInstance);
317
- }
318
- // send, copy and link buttons of article click events handling.
319
- var filesListHtml = fileHtml.querySelectorAll(classConstants.SUGGESTION_EACH);
320
- rootServiceInstance.renderEachFileInSuggestionList(searchResponse, filesListHtml, hostInstance);
321
- //more and less article button click events handling
322
- if (fileMoreLessActionHtml) {
323
- rootServiceInstance.handleSuggestionMoreClickEvent(fileMoreLessActionHtml, fileSuggestionElement, filesListHtml, hostInstance);
324
- rootServiceInstance.handleSuggestionLessClickEvent(fileMoreLessActionHtml, fileSuggestionElement, filesListHtml, hostInstance);
325
- }
165
+ else {
166
+ this.count = 1;
326
167
  }
168
+ this.prevTimeStamp = timestamp1;
169
+ return settimeoutTime;
327
170
  };
328
- var checkFaqAnswerNotRenderCountAndRequest = function () {
329
- var _a, _b;
330
- var answerNotRenderedElements = (_a = searchResponse.faqs) === null || _a === void 0 ? void 0 : _a.filter(function (faq, index) {
331
- if (!faq.answer) {
332
- faq.index = index;
333
- return true;
334
- }
335
- return false;
336
- });
337
- if ((answerNotRenderedElements === null || answerNotRenderedElements === void 0 ? void 0 : answerNotRenderedElements.length) === 1) {
338
- getFaqAnswerAndToggle(answerNotRenderedElements[0], (_b = answerNotRenderedElements[0]) === null || _b === void 0 ? void 0 : _b.index);
171
+ websocketservice.prototype.disconnect = function () {
172
+ if (this._agentAssistSocket && this._agentAssistSocket.connected) {
173
+ this.hostIns.rootService.socketConnect = false;
174
+ this._agentAssistSocket.disconnect();
175
+ this._agentAssistSocket.off();
339
176
  }
340
177
  };
341
- var getFaqAnswerAndToggle = function (faq, index) {
342
- faq.toggle = !faq.toggle;
343
- faq.seeMoreWrapper = false;
344
- var faqId = idConstants.SEARCH_FAQ_SUGGESTION;
345
- rootServiceInstance.toggleArrows(index, faqId);
346
- rootServiceInstance.checkAnswerAndToggleForSearch(faq, index, hostInstance);
347
- };
348
- return ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "search-block-data-suggestions-wrapper aa-search-suggestion-wrapper" },
349
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { class: "search-block-data-suggestions" },
350
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "suggestionslist-conntent-search" },
351
- "const lenth = Object.keys(searchResponse)?.length;",
352
- (((_b = Object.keys(searchResponse)) === null || _b === void 0 ? void 0 : _b.length) > 0 || searched) && (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)(preact__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,
353
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)(_suggestion_placeholder_suggestion_placeholder__WEBPACK_IMPORTED_MODULE_10__.SuggestionPlaceholder, { hostInstance: hostInstance, searchResponse: searchResponse, isAssist: false })),
354
- (((_c = Object.keys(searchResponse)) === null || _c === void 0 ? void 0 : _c.length) == 0 && searched && !showSpinner) &&
355
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { class: "empty-search-container-wrapper" },
356
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("figure", null,
357
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("img", { src: "/src/assets/images/icons/search-empty.png" })),
358
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("h1", { className: "aa-text-md m-0 center" }, "No Search Result Found"),
359
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("p", { className: "aa-desc-sm m-0 center" }, "\"Could you rephrase your question or ask something else?\"")),
360
- (((_d = Object.keys(searchResponse)) === null || _d === void 0 ? void 0 : _d.length) == 0 && !searched && !showSpinner) &&
361
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { class: "empty-search-container-wrapper" },
362
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("figure", null,
363
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("img", { src: "/src/assets/images/icons/search-empty.png" })),
364
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("p", { className: "aa-desc-sm m-0 center" }, "Type to search"))),
365
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "search-block-input", id: "searchSuggestionsBlock" })),
366
- showSpinner &&
367
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { id: "loader", className: "loader-progress-individual" },
368
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "loading-border" }))));
369
- }
370
- ;
371
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Search);
178
+ return websocketservice;
179
+ }());
180
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (websocketservice);
372
181
 
373
182
 
374
183
  /***/ })
@@ -377,7 +186,7 @@ function Search(_a) {
377
186
  /******/ function(__webpack_require__) { // webpackRuntimeModules
378
187
  /******/ /* webpack/runtime/getFullHash */
379
188
  /******/ (() => {
380
- /******/ __webpack_require__.h = () => ("e47e6a4814e9ecc2c0b1")
189
+ /******/ __webpack_require__.h = () => ("9e6860066b06c8c263f3")
381
190
  /******/ })();
382
191
  /******/
383
192
  /******/ }