impact-chatbot 2.4.0 → 3.0.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/ag-grid/AgGridComponent.d.ts +2 -0
- package/dist/components/ag-grid/columnFormatter.d.ts +10 -0
- package/dist/components/ag-grid/constants.d.ts +3 -0
- package/dist/components/ag-grid/formatters.d.ts +11 -0
- package/dist/components/ag-grid/index.d.ts +3 -0
- package/dist/components/core-chart/CoreChart.d.ts +22 -0
- package/dist/components/core-chart/index.d.ts +2 -0
- package/dist/components/date-range-picker/DateRangePickerComponent.d.ts +4 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/constants.d.ts +1 -0
- package/dist/hooks/useBotConfiguration.d.ts +1 -1
- package/dist/index.cjs.css +93 -0
- package/dist/index.cjs.js +2187 -1789
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.css +93 -0
- package/dist/index.esm.js +2050 -1669
- package/dist/index.esm.js.map +1 -1
- package/dist/provider/ChatbotProvider.d.ts +32 -0
- package/dist/provider/types.d.ts +49 -0
- package/dist/services/apiConstants.d.ts +14 -0
- package/dist/services/chatbot-services.d.ts +42 -9
- package/dist/services/http.d.ts +53 -0
- package/dist/store/actions.d.ts +13 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/reducer.d.ts +205 -0
- package/dist/store/types.d.ts +18 -0
- package/dist/utils/coreUtils.d.ts +16 -9
- package/package.json +33 -5
- package/dist/components/allocation-detail-panel/AllocationDetailPanel.d.ts +0 -2
- package/dist/components/allocation-detail-panel/AllocationPlanCard.d.ts +0 -4
- package/dist/components/allocation-detail-panel/components/PanelHeader.d.ts +0 -8
- package/dist/components/allocation-detail-panel/components/PanelSection.d.ts +0 -4
- package/dist/components/allocation-detail-panel/components/ReportSummaryCard.d.ts +0 -4
- package/dist/components/allocation-detail-panel/components/StructuredComparison.d.ts +0 -4
- package/dist/components/allocation-detail-panel/styles.d.ts +0 -1
- package/dist/components/chatbot-input/index_new.d.ts +0 -3
- package/dist/components/chatbot-input/index_old_backup.d.ts +0 -3
- package/dist/components/chatbot-save-filter-component/ChatbotSaveFilterComponent.d.ts +0 -2
- package/dist/components/message-template/components/message-content/SurfaceFrameContent.d.ts +0 -37
- package/dist/components/message-template/components/message-content/surfaceWidgets.d.ts +0 -22
- package/dist/core/commonComponents/custom-group-accordion/index.d.ts +0 -5
- package/dist/core/constants/index.d.ts +0 -5
- package/dist/core/utils/functions.d.ts +0 -8
- package/dist/core/utils/replaceSpecialCharacter.d.ts +0 -1
- /package/dist/{core/styles → styles}/colours.d.ts +0 -0
- /package/dist/{core/styles → styles}/globalStyles.d.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,69 +1,573 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { isUndefined, cloneDeep, isEmpty as isEmpty$1, isNull, isArray as isArray$1, isObject, throttle } from 'lodash';
|
|
2
|
+
import { isUndefined, cloneDeep, isEmpty as isEmpty$1, isNull, isArray as isArray$1, isObject, isNil, throttle } from 'lodash';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useCallback, useState,
|
|
5
|
-
import { COMBINED_CROSS_DIMENSIONAL_API, BASE_API } from 'config/api';
|
|
6
|
-
import axiosInstance from 'core/Utils/axios';
|
|
7
|
-
import { tenantConfigApiCache } from 'core/actions/tenantConfigActions';
|
|
8
|
-
import { getModuleLevelAccessUtility } from 'core/actions/userAccessActions';
|
|
9
|
-
import { addSnack } from 'core/actions/snackbarActions';
|
|
4
|
+
import { createContext, useEffect, useContext, useCallback, useState, useRef, Fragment as Fragment$1, useReducer, useMemo } from 'react';
|
|
10
5
|
import axios from 'axios';
|
|
11
6
|
import moment from 'moment';
|
|
12
7
|
import isEmpty from 'lodash/isEmpty.js';
|
|
13
8
|
import isArray from 'lodash/isArray.js';
|
|
14
9
|
import { makeStyles } from '@mui/styles';
|
|
15
|
-
import { useSelector, useDispatch
|
|
10
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
16
11
|
import ReactMarkdown from 'react-markdown';
|
|
17
12
|
import rehypeSanitize from 'rehype-sanitize';
|
|
18
13
|
import remarkBreaks from 'remark-breaks';
|
|
19
14
|
import remarkGfm from 'remark-gfm';
|
|
20
15
|
import DOMPurify from 'dompurify';
|
|
21
16
|
import { useNavigate, useLocation } from 'react-router-dom-v5-compat';
|
|
22
|
-
import { setSelectedFilters, setFilterConfiguration, getFilterUserConfiguration } from 'core/actions/filterAction';
|
|
23
|
-
import { setThinkingContext, setChatbotContext, setStepFormStreamData, setMinimizedStreamData, setPersistedFormValues, setCurrentAgentChatId, clearPersistedFormValues, setHierarchyKeyValue, setChatbotFilterOptions, setSavedFilterSets } from 'core/actions/smartBotActions';
|
|
24
17
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
25
18
|
import styled from 'styled-components';
|
|
26
|
-
import { CircularProgress, Typography, Grid
|
|
27
|
-
import { fetchBaseUrl, pxToRem as pxToRem$1, replaceSpecialCharacter as replaceSpecialCharacter$1, fetchLegacyAgentScreen } from 'core/Utils/functions/utils';
|
|
19
|
+
import { CircularProgress, Typography, Grid } from '@mui/material';
|
|
28
20
|
import { Button, Modal, Slider, Select, DatePicker, DateRangePicker, Checkbox, RadioButtonGroup, Input, Tabs, Loader, Prompt, Tooltip, ChatBotComponent } from 'impact-ui-v3';
|
|
29
21
|
import isArray$2 from 'lodash/isArray';
|
|
30
22
|
import isEmpty$2 from 'lodash/isEmpty';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
23
|
+
import { AllEnterpriseModule, ServerSideRowModelModule } from 'ag-grid-enterprise';
|
|
24
|
+
import { ClientSideRowModelModule, ValidationModule } from 'ag-grid-community';
|
|
25
|
+
import { AgGridProvider } from 'ag-grid-react';
|
|
26
|
+
import { TableV36 } from 'impact-ui-v3/TableV36';
|
|
27
|
+
import classNames from 'classnames';
|
|
28
|
+
import HighchartsReact from 'highcharts-react-official';
|
|
29
|
+
import Highcharts from 'highcharts/esm/highcharts.js';
|
|
30
|
+
import 'highcharts/esm/highcharts-more.js';
|
|
31
|
+
import 'highcharts/esm/highcharts-3d.js';
|
|
32
|
+
import 'highcharts/esm/modules/exporting.js';
|
|
33
|
+
import 'highcharts/esm/modules/export-data.js';
|
|
34
|
+
import 'highcharts/esm/modules/map.js';
|
|
35
|
+
import 'highcharts/esm/modules/pattern-fill.js';
|
|
36
|
+
import 'highcharts/esm/modules/treemap.js';
|
|
37
|
+
import 'highcharts/esm/modules/heatmap.js';
|
|
38
|
+
import 'highcharts/esm/modules/pareto.js';
|
|
36
39
|
import makeStyles$1 from '@mui/styles/makeStyles';
|
|
37
40
|
import ChevronRightIcon$1 from '@mui/icons-material/ChevronRight';
|
|
38
|
-
import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined';
|
|
39
|
-
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
|
40
41
|
import FormatListBulletedOutlinedIcon from '@mui/icons-material/FormatListBulletedOutlined';
|
|
41
42
|
import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined';
|
|
42
|
-
import colours$1 from 'core/Styles/colours';
|
|
43
43
|
import SaveOutlinedIcon from '@mui/icons-material/SaveOutlined';
|
|
44
|
-
import
|
|
45
|
-
import NoFilterSetSavedIcon from 'core/coreAssets/chatbot/noFilterSetSaved.svg';
|
|
46
|
-
import CoreComponentScreen from 'core/commonComponents/coreComponentScreen';
|
|
47
|
-
import { fetchFilterFieldValues, formattedFilterConfiguration } from 'core/commonComponents/coreComponentScreen/utils';
|
|
48
|
-
import { createPortal } from 'react-dom';
|
|
49
|
-
import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
|
|
50
|
-
import OpenInFullIcon from '@mui/icons-material/OpenInFull';
|
|
51
|
-
import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
|
|
52
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
53
|
-
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
54
|
-
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
|
55
|
-
import { getApplicationCodeFromURL } from 'core/Utils/utils';
|
|
44
|
+
import 'react-dates/lib/css/_datepicker.css';
|
|
56
45
|
|
|
57
46
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
47
|
+
* Internal HTTP client module for impact-chatbot.
|
|
48
|
+
*
|
|
49
|
+
* Instead of importing `axiosInstance` from `core/Utils/axios` (which ties the
|
|
50
|
+
* package to the host's core submodule), every service file in this package
|
|
51
|
+
* imports `getHttpClient()` from this module.
|
|
52
|
+
*
|
|
53
|
+
* The client is set once at startup via `initHttpClient()`, which is called
|
|
54
|
+
* from `ChatbotProvider` when the component tree mounts.
|
|
55
|
+
*
|
|
56
|
+
* Phase 3 of the segregation roadmap.
|
|
57
|
+
*/
|
|
58
|
+
// ── Module-level singletons ────────────────────────────────────────────────
|
|
59
|
+
let _httpClient = null;
|
|
60
|
+
let _apiConstants = null;
|
|
61
|
+
/**
|
|
62
|
+
* Called once when <ChatbotProvider> mounts.
|
|
63
|
+
* Stores the consumer-provided HTTP client and API constants so every
|
|
64
|
+
* internal service can access them without prop-drilling.
|
|
65
|
+
*/
|
|
66
|
+
function initHttpClient(httpClient, apiConstants) {
|
|
67
|
+
_httpClient = httpClient;
|
|
68
|
+
_apiConstants = apiConstants;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the HTTP client set by the consumer.
|
|
72
|
+
*
|
|
73
|
+
* All internal service files use this as a drop-in replacement for the old
|
|
74
|
+
* `import axiosInstance from "core/Utils/axios"`.
|
|
75
|
+
*
|
|
76
|
+
* The returned client is "callable" in the same way Axios instances are — it
|
|
77
|
+
* supports `.get()`, `.post()`, `.put()`, `.delete()` and can also be invoked
|
|
78
|
+
* directly as a function (Axios config object style). To support the latter
|
|
79
|
+
* pattern transparently we return a wrapper that delegates to the right method.
|
|
80
|
+
*/
|
|
81
|
+
function getHttpClient() {
|
|
82
|
+
if (!_httpClient) {
|
|
83
|
+
throw new Error("[impact-chatbot] HTTP client not initialized. " +
|
|
84
|
+
"Ensure <ChatbotProvider> is rendered before any API call.");
|
|
85
|
+
}
|
|
86
|
+
return _httpClient;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Callable wrapper that mimics `axiosInstance({ url, method, data, params, ... })`.
|
|
90
|
+
*
|
|
91
|
+
* The old code uses `axiosInstance(config)` everywhere (Axios request-config
|
|
92
|
+
* style). This function translates that call into the structural `HttpClient`
|
|
93
|
+
* interface (.get / .post / .put / .delete).
|
|
94
|
+
*/
|
|
95
|
+
function httpRequest(config) {
|
|
96
|
+
const client = getHttpClient();
|
|
97
|
+
const method = (config.method || "GET").toUpperCase();
|
|
98
|
+
// Build a config object to pass as the last argument (covers params,
|
|
99
|
+
// headers, signal, responseType, onDownloadProgress, etc.)
|
|
100
|
+
const requestConfig = { ...config };
|
|
101
|
+
delete requestConfig.url;
|
|
102
|
+
delete requestConfig.method;
|
|
103
|
+
delete requestConfig.data;
|
|
104
|
+
switch (method) {
|
|
105
|
+
case "GET":
|
|
106
|
+
return client.get(config.url, requestConfig);
|
|
107
|
+
case "POST":
|
|
108
|
+
return client.post(config.url, config.data, requestConfig);
|
|
109
|
+
case "PUT":
|
|
110
|
+
return client.put(config.url, config.data, requestConfig);
|
|
111
|
+
case "DELETE":
|
|
112
|
+
return client.delete(config.url, requestConfig);
|
|
113
|
+
case "PATCH":
|
|
114
|
+
// PATCH is not on the base HttpClient interface but Axios instances
|
|
115
|
+
// support it. Fall through to a generic call.
|
|
116
|
+
if (client.patch) {
|
|
117
|
+
return client.patch(config.url, config.data, requestConfig);
|
|
118
|
+
}
|
|
119
|
+
// Fallback: use post with _method override or just post
|
|
120
|
+
return client.post(config.url, config.data, {
|
|
121
|
+
...requestConfig,
|
|
122
|
+
headers: { ...requestConfig.headers, "X-HTTP-Method-Override": "PATCH" },
|
|
123
|
+
});
|
|
124
|
+
default:
|
|
125
|
+
// For any other method, try calling the client directly (it may be
|
|
126
|
+
// a real Axios instance that supports arbitrary methods).
|
|
127
|
+
if (typeof client === "function") {
|
|
128
|
+
return client(config);
|
|
129
|
+
}
|
|
130
|
+
return client.get(config.url, requestConfig);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the API constants set by the consumer.
|
|
60
135
|
*/
|
|
136
|
+
function getApiConstants() {
|
|
137
|
+
if (!_apiConstants) {
|
|
138
|
+
throw new Error("[impact-chatbot] API constants not initialized. " +
|
|
139
|
+
"Ensure <ChatbotProvider> is rendered before any API call.");
|
|
140
|
+
}
|
|
141
|
+
return _apiConstants;
|
|
142
|
+
}
|
|
61
143
|
|
|
144
|
+
// Special character mapping for text replacement
|
|
145
|
+
const SPECIAL_CHARACTER_MAPPING = {
|
|
146
|
+
__ia_char_01: "'",
|
|
147
|
+
__ia_char_02: '"',
|
|
148
|
+
__ia_char_03: "/",
|
|
149
|
+
__ia_char_04: "\\",
|
|
150
|
+
__ia_char_05: "`",
|
|
151
|
+
__ia_char_06: "~",
|
|
152
|
+
__ia_char_07: "!",
|
|
153
|
+
__ia_char_08: "@",
|
|
154
|
+
__ia_char_09: "#",
|
|
155
|
+
__ia_char_10: "$",
|
|
156
|
+
__ia_char_11: "%",
|
|
157
|
+
__ia_char_12: "^",
|
|
158
|
+
__ia_char_13: "&",
|
|
159
|
+
__ia_char_14: "*",
|
|
160
|
+
__ia_char_15: "(",
|
|
161
|
+
__ia_char_16: ")",
|
|
162
|
+
__ia_char_19: "=",
|
|
163
|
+
__ia_char_20: "+",
|
|
164
|
+
__ia_char_21: "{",
|
|
165
|
+
__ia_char_22: "}",
|
|
166
|
+
__ia_char_23: "[",
|
|
167
|
+
__ia_char_24: "]",
|
|
168
|
+
__ia_char_25: "|",
|
|
169
|
+
__ia_char_26: ":",
|
|
170
|
+
__ia_char_27: ";",
|
|
171
|
+
__ia_char_28: "<",
|
|
172
|
+
__ia_char_29: ">",
|
|
173
|
+
__ia_char_30: ",",
|
|
174
|
+
__ia_char_31: ".",
|
|
175
|
+
__ia_char_32: "?",
|
|
176
|
+
__ia_char_33: "/",
|
|
177
|
+
};
|
|
62
178
|
const COMBINED_CROSS_DIMENSIONAL_API_V4 = "/combined-cross-dimensional-v4";
|
|
179
|
+
const navigationOptions = [
|
|
180
|
+
{
|
|
181
|
+
link: "/inventory-smart/decision-dashboard",
|
|
182
|
+
screen_name: "Dashboard",
|
|
183
|
+
flow_type: "navigation",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
link: `/inventory-smart/create-allocation/?step=0`,
|
|
187
|
+
flow_type: "navigation",
|
|
188
|
+
screen_name: "Allocation",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
link: "/inventory-smart/configuration",
|
|
192
|
+
flow_type: "navigation",
|
|
193
|
+
screen_name: "Configurations",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
link: "/inventory-smart/store-eligibility-grouping",
|
|
197
|
+
flow_type: "navigation",
|
|
198
|
+
screen_name: "Grouping",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
link: "/inventory-smart/constraints",
|
|
202
|
+
flow_type: "navigation",
|
|
203
|
+
screen_name: "Constraints",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
link: "/inventory-smart/ada/dashboard",
|
|
207
|
+
flow_type: "navigation",
|
|
208
|
+
screen_name: "ADA Visual",
|
|
209
|
+
},
|
|
210
|
+
];
|
|
211
|
+
const insightsOptions = [
|
|
212
|
+
{
|
|
213
|
+
link: "/inventory-smart/decision-dashboard",
|
|
214
|
+
screen_name: "Dashboard",
|
|
215
|
+
flow_type: "insights",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
link: `/inventory-smart/create-allocation/?step=0`,
|
|
219
|
+
flow_type: "insights",
|
|
220
|
+
screen_name: "Allocation",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
link: "/inventory-smart/store-eligibility-grouping",
|
|
224
|
+
flow_type: "insights",
|
|
225
|
+
screen_name: "Configurations",
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
link: "/inventory-smart/configuration",
|
|
229
|
+
flow_type: "insights",
|
|
230
|
+
screen_name: "Grouping",
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
link: "/inventory-smart/constraints",
|
|
234
|
+
flow_type: "insights",
|
|
235
|
+
screen_name: "Constraints",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
link: "/inventory-smart/ada/dashboard",
|
|
239
|
+
flow_type: "insights",
|
|
240
|
+
screen_name: "ADA Visual",
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
const screenOptions = [
|
|
244
|
+
{
|
|
245
|
+
link: "/inventory-smart/decision-dashboard",
|
|
246
|
+
screen_name: "InventoryDashboard",
|
|
247
|
+
filterCongfigurationName: "decisionDashboardFilterConfiguration",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
link: "/inventory-smart/product-profile",
|
|
251
|
+
screen_name: "Product Profile",
|
|
252
|
+
filterCongfigurationName: "productProfileDashboardFilterConfig",
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
link: `/inventory-smart/create-allocation/?step=0`,
|
|
256
|
+
screen_name: "Allocation",
|
|
257
|
+
filterCongfigurationName: "createAllocationFilterConfiguration",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
link: "/inventory-smart/store-eligibility-grouping",
|
|
261
|
+
screen_name: "Inventorysmart Store Eligibility Group",
|
|
262
|
+
filterCongfigurationName: "storeGroupingFilterConfiguration",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
link: "/inventory-smart/configuration",
|
|
266
|
+
screen_name: "Inventorysmart Configurations",
|
|
267
|
+
filterCongfigurationName: "productStatusFilterConfiguration",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
link: "/inventory-smart/constraints",
|
|
271
|
+
screen_name: "Inventorysmart Constraints",
|
|
272
|
+
filterCongfigurationName: "rulesConstraintsFilterConfig",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
link: "/inventory-smart/allocation-reports",
|
|
276
|
+
screen_name: "Inventorysmart Reportings",
|
|
277
|
+
filterCongfigurationName: "lostSalesFilterConfiguration",
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
link: "/inventory-smart/ada/dashboard",
|
|
281
|
+
screen_name: "Inventorysmart ADA Dashboard",
|
|
282
|
+
filterCongfigurationName: "adaVisualFilterConfiguration",
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Core utility functions copied from core/Utils/functions/utils
|
|
288
|
+
* These are internalized to make chatbot-v2 self-contained
|
|
289
|
+
*/
|
|
290
|
+
/**
|
|
291
|
+
* pxToRem function will convert the px value to rem value
|
|
292
|
+
*/
|
|
293
|
+
const pxToRem = (pxValue) => {
|
|
294
|
+
try {
|
|
295
|
+
return pxValue / 16 + "rem";
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
console.error("pxToRem error:", error);
|
|
299
|
+
return "0rem";
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Replace special characters in a string
|
|
304
|
+
*/
|
|
305
|
+
const replaceSpecialCharacter$2 = (str) => {
|
|
306
|
+
if (typeof str === "object") {
|
|
307
|
+
return str;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
let result = str;
|
|
311
|
+
if (SPECIAL_CHARACTER_MAPPING) {
|
|
312
|
+
Object.keys(SPECIAL_CHARACTER_MAPPING).forEach((key) => {
|
|
313
|
+
if (result?.includes(key)) {
|
|
314
|
+
result = result.replaceAll(key, SPECIAL_CHARACTER_MAPPING[key]);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* @function
|
|
323
|
+
* @description Function is used to return string by replacing the special characters with respective key mapped to SPECIAL_CHARACTER_MAPPING
|
|
324
|
+
* @param {String} str
|
|
325
|
+
* @returns {String} key of mapped special character used in the string
|
|
326
|
+
*/
|
|
327
|
+
const replaceSpecialCharToCharCode = (str) => {
|
|
328
|
+
let re = new RegExp(`[${Object.values(SPECIAL_CHARACTER_MAPPING).join("")}]`, "g");
|
|
329
|
+
return str.replace(re, function (matched) {
|
|
330
|
+
let code;
|
|
331
|
+
for (const [key, value] of Object.entries(SPECIAL_CHARACTER_MAPPING)) {
|
|
332
|
+
if (value === matched) {
|
|
333
|
+
code = key;
|
|
334
|
+
return code;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return code;
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Get user name from session storage
|
|
342
|
+
* Matches core/Utils/functions/utils.getUserName exactly
|
|
343
|
+
*/
|
|
344
|
+
const getUserName = () => {
|
|
345
|
+
const userDetails = JSON.parse(sessionStorage.getItem("userDetails") || "{}");
|
|
346
|
+
return userDetails?.user_name || "User";
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Get formatted application name based on URL path segment
|
|
350
|
+
* Matches core/Utils/functions/utils.getFormattedApplicationName exactly
|
|
351
|
+
*/
|
|
352
|
+
/**
|
|
353
|
+
* Get application code from localStorage applicationCodesList by matching application name.
|
|
354
|
+
* Mirrors core/Utils/utils.getApplicationCodeFromURL exactly.
|
|
355
|
+
*/
|
|
356
|
+
const getApplicationCodeFromURL = (applicationName) => {
|
|
357
|
+
try {
|
|
358
|
+
const applicationCodesList = JSON.parse(localStorage.getItem("applicationCodesList") || "[]");
|
|
359
|
+
const matched = applicationCodesList?.find((app) => app.name?.toUpperCase() === applicationName?.toUpperCase());
|
|
360
|
+
return matched?.application_code || "";
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
console.error("getApplicationCodeFromURL error:", error);
|
|
364
|
+
return "";
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
const getFormattedApplicationName = (applicationURL) => {
|
|
368
|
+
switch (applicationURL) {
|
|
369
|
+
case "user-management":
|
|
370
|
+
case "tenantconfig":
|
|
371
|
+
return "application access management";
|
|
372
|
+
case "assort-smart":
|
|
373
|
+
return "AssortSmart";
|
|
374
|
+
case "configurator":
|
|
375
|
+
return "module configurator";
|
|
376
|
+
case "inventory-smart":
|
|
377
|
+
return "InventorySmart";
|
|
378
|
+
case "ada":
|
|
379
|
+
return "ADA";
|
|
380
|
+
case "plan-smart":
|
|
381
|
+
return "PlanSmart";
|
|
382
|
+
case "adaconfigurator":
|
|
383
|
+
return "ADAConfigurator";
|
|
384
|
+
case "item-smart":
|
|
385
|
+
return "ItemSmart";
|
|
386
|
+
case "item-smart-new":
|
|
387
|
+
return "ItemSmart-New";
|
|
388
|
+
case "source-smart":
|
|
389
|
+
return "SourceSmart";
|
|
390
|
+
case "pricesmart-markdown":
|
|
391
|
+
return "PriceSmart Markdown";
|
|
392
|
+
case "pricesmart-promo":
|
|
393
|
+
return "PriceSmart Promo";
|
|
394
|
+
case "agentic-assort":
|
|
395
|
+
return "AssortSmart";
|
|
396
|
+
case "size-smart":
|
|
397
|
+
return "SizeSmart";
|
|
398
|
+
default:
|
|
399
|
+
return "workflow input center";
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* API endpoint constants used by chatbot service functions.
|
|
405
|
+
*
|
|
406
|
+
* Previously scattered across `config/api`, `core/actions/tenantConfigActions`,
|
|
407
|
+
* and `core/actions/userAccessActions` in the host app. Now internalized so the
|
|
408
|
+
* package is fully self-contained.
|
|
409
|
+
*/
|
|
410
|
+
// ─── Tenant Config & Application ─────────────────────────────────────────────
|
|
411
|
+
const GET_TENANT_CONFIG = "core/tenant-config";
|
|
412
|
+
const GET_APPLICATION_MASTER = "/core/applications";
|
|
413
|
+
// ─── User Management ─────────────────────────────────────────────────────────
|
|
414
|
+
const GET_USERS_URL = "/core/user-mgmt/list";
|
|
415
|
+
const GET_MODULE_LEVEL_ACCESS = "/master/user-management/module-hierarchy";
|
|
416
|
+
const GET_USER_APP_ACCESS_HIERARCHY = "/master/user-management/app-role-hierarchy";
|
|
417
|
+
// ─── Filter ──────────────────────────────────────────────────────────────────
|
|
418
|
+
const SAVE_FILTER_GET = "/core/filter/user-preference/screen";
|
|
63
419
|
|
|
420
|
+
// ─── In-memory tenant-config cache ──────────────────────────────────────
|
|
421
|
+
// Mirrors core tenantConfigApiCache but uses a simple Map instead of Redux.
|
|
422
|
+
const _tenantConfigCache = {};
|
|
423
|
+
/**
|
|
424
|
+
* processData – filters a tenant-config API response by attribute_name.
|
|
425
|
+
* Mirrors core/Utils/functions/utils.processData exactly.
|
|
426
|
+
*/
|
|
427
|
+
const processData = (responseData, queryParam) => {
|
|
428
|
+
if (Object.keys(queryParam).length === 0) {
|
|
429
|
+
return responseData;
|
|
430
|
+
}
|
|
431
|
+
const { data } = responseData;
|
|
432
|
+
const filteredData = data?.data?.filter((item) => item.name === queryParam?.attribute_name);
|
|
433
|
+
return {
|
|
434
|
+
...responseData,
|
|
435
|
+
data: {
|
|
436
|
+
...data,
|
|
437
|
+
data: filteredData,
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* tenantConfigApiCache – fetches tenant config for an application code,
|
|
443
|
+
* caching the full response in memory. Returns a thunk (function) to
|
|
444
|
+
* match the core signature: `tenantConfigApiCache(appCode, query)()`
|
|
445
|
+
*
|
|
446
|
+
* Mirrors core/actions/tenantConfigActions.tenantConfigApiCache.
|
|
447
|
+
*/
|
|
448
|
+
const tenantConfigApiCache = (applicationCode = 1, queryParam = {}) => async () => {
|
|
449
|
+
const cachedData = _tenantConfigCache[applicationCode];
|
|
450
|
+
if (cachedData) {
|
|
451
|
+
return processData(cachedData, queryParam);
|
|
452
|
+
}
|
|
453
|
+
const resp = await httpRequest({
|
|
454
|
+
url: `${GET_TENANT_CONFIG}/${applicationCode}`,
|
|
455
|
+
params: {},
|
|
456
|
+
method: "GET",
|
|
457
|
+
});
|
|
458
|
+
_tenantConfigCache[applicationCode] = resp;
|
|
459
|
+
return processData(resp, queryParam);
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* getApplicationMaster – fetches the list of applications.
|
|
463
|
+
* Mirrors core/actions/tenantConfigActions.getApplicationMaster.
|
|
464
|
+
* The original returns a thunk `(postBody) => async () => ...`.
|
|
465
|
+
* We simplify to a direct async call since the package never passes postBody.
|
|
466
|
+
*/
|
|
467
|
+
const getApplicationMaster = async () => {
|
|
468
|
+
return httpRequest({
|
|
469
|
+
url: GET_APPLICATION_MASTER,
|
|
470
|
+
method: "GET",
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
// Resolve the current user's code via the users API, matching the logged-in
|
|
474
|
+
// email (localStorage "name"). Mirrors core/Utils/functions/utils.getCurrentUserId.
|
|
475
|
+
const getCurrentUserId = async () => {
|
|
476
|
+
try {
|
|
477
|
+
const postBody = {
|
|
478
|
+
meta: {
|
|
479
|
+
search: [],
|
|
480
|
+
range: [],
|
|
481
|
+
sort: [],
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
const users = await httpRequest({
|
|
485
|
+
url: GET_USERS_URL,
|
|
486
|
+
method: "POST",
|
|
487
|
+
data: postBody,
|
|
488
|
+
});
|
|
489
|
+
const loggedInUserEmail = localStorage.getItem("name");
|
|
490
|
+
const user = users?.data?.data?.filter((item) => {
|
|
491
|
+
return item.email === loggedInUserEmail;
|
|
492
|
+
});
|
|
493
|
+
return user[0]?.user_code;
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
console.error("getCurrentUserId error", error);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
// Helper to get current application details from localStorage
|
|
500
|
+
const getCurrentApplicationDetails = () => {
|
|
501
|
+
if (localStorage.getItem("applicationCodesList") &&
|
|
502
|
+
localStorage.getItem("applicationCodesList") !== "undefined") {
|
|
503
|
+
const applicationCodesList = JSON.parse(localStorage.getItem("applicationCodesList"));
|
|
504
|
+
const applicationURL = window.location.pathname.split("/")?.[1];
|
|
505
|
+
const applicationName = getFormattedApplicationName(applicationURL);
|
|
506
|
+
const applicationCode = applicationCodesList?.find((app) => app.name?.toUpperCase() === applicationName?.toUpperCase());
|
|
507
|
+
return {
|
|
508
|
+
applicationCode: applicationCode?.application_code,
|
|
509
|
+
applicationName,
|
|
510
|
+
applicationCodesList,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
return { applicationCode: "", applicationName: "", applicationCodesList: [] };
|
|
514
|
+
};
|
|
515
|
+
// Fetch application code – mirrors core/Utils/functions/utils.fetchApplicationCode
|
|
516
|
+
const fetchApplicationCodeFromConfig = async () => {
|
|
517
|
+
const { applicationCode, applicationCodesList } = getCurrentApplicationDetails();
|
|
518
|
+
let finalApplicationCode = applicationCode;
|
|
519
|
+
let finalApplicationCodesList = applicationCodesList;
|
|
520
|
+
if (!finalApplicationCode) {
|
|
521
|
+
let applicationURL = window.location.pathname.split("/")?.[1];
|
|
522
|
+
let applicationName = getFormattedApplicationName(applicationURL);
|
|
523
|
+
if (applicationName === "workflow input center") {
|
|
524
|
+
applicationName = "Workflow Input Center";
|
|
525
|
+
}
|
|
526
|
+
let getApplicationMasterList = await getApplicationMaster();
|
|
527
|
+
localStorage.setItem("applicationCodesList", JSON.stringify(getApplicationMasterList?.data?.data));
|
|
528
|
+
finalApplicationCodesList = getApplicationMasterList?.data?.data;
|
|
529
|
+
finalApplicationCodesList?.forEach((app) => {
|
|
530
|
+
if (app.name === applicationName) {
|
|
531
|
+
finalApplicationCode = app.application_code;
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
applicationCode: finalApplicationCode,
|
|
537
|
+
applicationCodesList: finalApplicationCodesList,
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
// Fetch base URL from tenant config – mirrors core/Utils/functions/utils.fetchBaseUrl exactly
|
|
541
|
+
const fetchBaseUrl = async () => {
|
|
542
|
+
try {
|
|
543
|
+
let { applicationCode } = await fetchApplicationCodeFromConfig();
|
|
544
|
+
let baseUrlData = await tenantConfigApiCache(applicationCode, {
|
|
545
|
+
attribute_name: "base_url",
|
|
546
|
+
})();
|
|
547
|
+
return baseUrlData?.data?.data?.[0]?.attribute_value?.value;
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
console.error("fetchBaseUrl error", error);
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
// Fetch legacy agent screen flag – mirrors core/Utils/functions/utils.fetchLegacyAgentScreen exactly
|
|
555
|
+
const fetchLegacyAgentScreen = async () => {
|
|
556
|
+
try {
|
|
557
|
+
let { applicationCode } = await fetchApplicationCodeFromConfig();
|
|
558
|
+
let legacyAgentScreenData = await tenantConfigApiCache(applicationCode, {
|
|
559
|
+
attribute_name: "legacy_agent_screen",
|
|
560
|
+
})();
|
|
561
|
+
return legacyAgentScreenData?.data?.data?.[0]?.attribute_value?.value;
|
|
562
|
+
}
|
|
563
|
+
catch (error) {
|
|
564
|
+
console.error("fetchLegacyAgentScreen error", error);
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
64
568
|
const resolveChatQuery = (body, flowType) => {
|
|
65
569
|
try {
|
|
66
|
-
return
|
|
570
|
+
return httpRequest({
|
|
67
571
|
url: `/core/chatbot/${flowType}`,
|
|
68
572
|
method: "PUT",
|
|
69
573
|
data: body,
|
|
@@ -76,7 +580,7 @@ const resolveChatQuery = (body, flowType) => {
|
|
|
76
580
|
};
|
|
77
581
|
const fetchRelatedQuestions = (flowType, screen_name) => {
|
|
78
582
|
try {
|
|
79
|
-
return
|
|
583
|
+
return httpRequest({
|
|
80
584
|
url: `/core/chatbot/${flowType}/question/${screen_name}`,
|
|
81
585
|
method: "GET",
|
|
82
586
|
});
|
|
@@ -145,7 +649,7 @@ const getAgentExceptionUserList = (applicationCode) => {
|
|
|
145
649
|
};
|
|
146
650
|
const refreshAndUpdateUserManualApi = async (body) => {
|
|
147
651
|
try {
|
|
148
|
-
return
|
|
652
|
+
return httpRequest({
|
|
149
653
|
url: `core/chatbot/manualdoc`,
|
|
150
654
|
method: "PUT",
|
|
151
655
|
data: body,
|
|
@@ -158,7 +662,7 @@ const refreshAndUpdateUserManualApi = async (body) => {
|
|
|
158
662
|
};
|
|
159
663
|
const fetchScreensForModule = async (flowType) => {
|
|
160
664
|
try {
|
|
161
|
-
return
|
|
665
|
+
return httpRequest({
|
|
162
666
|
url: `core/chatbot/${flowType}/screen`,
|
|
163
667
|
method: "GET",
|
|
164
668
|
});
|
|
@@ -171,7 +675,7 @@ const fetchScreensForModule = async (flowType) => {
|
|
|
171
675
|
// Like/Dislike Messages
|
|
172
676
|
const likeDislikeComment = async (payload) => {
|
|
173
677
|
try {
|
|
174
|
-
return
|
|
678
|
+
return httpRequest({
|
|
175
679
|
url: `core/chatbot/analytics/like`,
|
|
176
680
|
data: payload,
|
|
177
681
|
method: "POST",
|
|
@@ -185,7 +689,7 @@ const likeDislikeComment = async (payload) => {
|
|
|
185
689
|
// Like/Dislike Messages for agent
|
|
186
690
|
const likeDislikeCommentForAgent = async (payload, baseUrl) => {
|
|
187
691
|
try {
|
|
188
|
-
return
|
|
692
|
+
return httpRequest({
|
|
189
693
|
url: `${baseUrl}/chatbot/agent/analytics/like`,
|
|
190
694
|
data: payload,
|
|
191
695
|
method: "POST",
|
|
@@ -198,7 +702,7 @@ const likeDislikeCommentForAgent = async (payload, baseUrl) => {
|
|
|
198
702
|
};
|
|
199
703
|
const fetchIntentApiResponse = async (input = "@apply_filter What is sales discount in cabezon mtd?") => {
|
|
200
704
|
try {
|
|
201
|
-
return
|
|
705
|
+
return httpRequest({
|
|
202
706
|
url: `core/chatbot/intent`,
|
|
203
707
|
method: "POST",
|
|
204
708
|
data: {
|
|
@@ -212,7 +716,7 @@ const fetchIntentApiResponse = async (input = "@apply_filter What is sales disco
|
|
|
212
716
|
};
|
|
213
717
|
const fetchAgentsInfo = async (baseUrl) => {
|
|
214
718
|
try {
|
|
215
|
-
return
|
|
719
|
+
return httpRequest({
|
|
216
720
|
url: `${baseUrl}/chatbot/agent/info`,
|
|
217
721
|
method: 'GET'
|
|
218
722
|
});
|
|
@@ -224,7 +728,7 @@ const fetchAgentsInfo = async (baseUrl) => {
|
|
|
224
728
|
};
|
|
225
729
|
const initiateAgent = async (payload, baseUrl) => {
|
|
226
730
|
try {
|
|
227
|
-
return
|
|
731
|
+
return httpRequest({
|
|
228
732
|
url: `${baseUrl}/chatbot/agent/init`,
|
|
229
733
|
method: 'POST',
|
|
230
734
|
data: payload,
|
|
@@ -237,7 +741,7 @@ const initiateAgent = async (payload, baseUrl) => {
|
|
|
237
741
|
};
|
|
238
742
|
const uploadFile = async (payload) => {
|
|
239
743
|
try {
|
|
240
|
-
return
|
|
744
|
+
return httpRequest({
|
|
241
745
|
url: `core/chatbot/upload/signed-url`,
|
|
242
746
|
method: 'POST',
|
|
243
747
|
data: payload,
|
|
@@ -250,7 +754,7 @@ const uploadFile = async (payload) => {
|
|
|
250
754
|
};
|
|
251
755
|
const triggerRefresh = async (baseUrl) => {
|
|
252
756
|
try {
|
|
253
|
-
return
|
|
757
|
+
return httpRequest({
|
|
254
758
|
url: `core/chatbot/trigger-refresh`,
|
|
255
759
|
method: 'GET'
|
|
256
760
|
});
|
|
@@ -262,7 +766,7 @@ const triggerRefresh = async (baseUrl) => {
|
|
|
262
766
|
};
|
|
263
767
|
const fetchChatbotFilterConfig = async () => {
|
|
264
768
|
try {
|
|
265
|
-
return
|
|
769
|
+
return httpRequest({
|
|
266
770
|
url: `core/filter/generic-schema-mapping?screen_name=Chatbot`,
|
|
267
771
|
method: "GET",
|
|
268
772
|
});
|
|
@@ -273,45 +777,43 @@ const fetchChatbotFilterConfig = async () => {
|
|
|
273
777
|
}
|
|
274
778
|
};
|
|
275
779
|
const getFilterOptions = (postBody) => async () => {
|
|
276
|
-
return
|
|
780
|
+
return httpRequest({
|
|
277
781
|
url: sessionStorage.getItem("crossFilterVersion") === "cross-filter-v4"
|
|
278
782
|
? COMBINED_CROSS_DIMENSIONAL_API_V4
|
|
279
|
-
: COMBINED_CROSS_DIMENSIONAL_API,
|
|
783
|
+
: getApiConstants().COMBINED_CROSS_DIMENSIONAL_API,
|
|
280
784
|
method: "POST",
|
|
281
785
|
data: postBody,
|
|
282
786
|
});
|
|
283
787
|
};
|
|
284
|
-
const
|
|
788
|
+
const stopAgentFlow = async (payload, baseUrl) => {
|
|
285
789
|
try {
|
|
286
|
-
return
|
|
287
|
-
url: `${baseUrl}/chatbot/agent/
|
|
790
|
+
return httpRequest({
|
|
791
|
+
url: `${baseUrl}/chatbot/agent/stop`,
|
|
288
792
|
method: 'POST',
|
|
289
793
|
data: payload,
|
|
290
794
|
});
|
|
291
795
|
}
|
|
292
796
|
catch (error) {
|
|
293
|
-
console.error('
|
|
797
|
+
console.error('stopAgentFlow error:', error);
|
|
294
798
|
return null;
|
|
295
799
|
}
|
|
296
800
|
};
|
|
297
|
-
|
|
298
|
-
* user and answers {rows, total}. */
|
|
299
|
-
const postUiQuery = async (payload, baseUrl) => {
|
|
801
|
+
const getTableRecords = async (payload, baseUrl, tableName) => {
|
|
300
802
|
try {
|
|
301
|
-
return
|
|
302
|
-
url: `${baseUrl}/chatbot/agent/
|
|
803
|
+
return httpRequest({
|
|
804
|
+
url: `${baseUrl}/chatbot/agent/tabular-data/${tableName}`,
|
|
303
805
|
method: 'POST',
|
|
304
806
|
data: payload,
|
|
305
807
|
});
|
|
306
808
|
}
|
|
307
809
|
catch (error) {
|
|
308
|
-
console.error('
|
|
810
|
+
console.error('getTableRecords error:', error);
|
|
309
811
|
return null;
|
|
310
812
|
}
|
|
311
813
|
};
|
|
312
814
|
const getTableRecordsByUrl = async (payload, url) => {
|
|
313
815
|
try {
|
|
314
|
-
return
|
|
816
|
+
return httpRequest({
|
|
315
817
|
url: url,
|
|
316
818
|
method: 'POST',
|
|
317
819
|
data: payload,
|
|
@@ -322,21 +824,148 @@ const getTableRecordsByUrl = async (payload, url) => {
|
|
|
322
824
|
return null;
|
|
323
825
|
}
|
|
324
826
|
};
|
|
827
|
+
// ─── Internalized from core/actions/userAccessActions.js ─────────────────────
|
|
828
|
+
// Previously injected via ChatbotProvider actions; now lives inside the package
|
|
829
|
+
// so consumers don't need to provide these functions.
|
|
830
|
+
/**
|
|
831
|
+
* convertAccessHierarchyToOldFormat — transforms the new module-level access
|
|
832
|
+
* response into the legacy format the chatbot code expects.
|
|
833
|
+
* Mirrors core/Utils/functions/utils.convertAccessHierarchyToOldFormat exactly.
|
|
834
|
+
*/
|
|
835
|
+
const convertAccessHierarchyToOldFormat = (appModuleActions, accessHierarchy = []) => {
|
|
836
|
+
const result = {};
|
|
837
|
+
for (const [module, access] of Object.entries(appModuleActions)) {
|
|
838
|
+
const updatedAccess = Object.fromEntries(Object.entries(access).map(([key, value]) => [
|
|
839
|
+
key,
|
|
840
|
+
value === "limited" ? accessHierarchy : {},
|
|
841
|
+
]));
|
|
842
|
+
result[module] = updatedAccess;
|
|
843
|
+
}
|
|
844
|
+
return result;
|
|
845
|
+
};
|
|
846
|
+
/**
|
|
847
|
+
* getUserAccessHierarchy — fetches the access hierarchy for an application.
|
|
848
|
+
* Mirrors core/actions/userAccessActions.getUserAccessHierarchy.
|
|
849
|
+
*/
|
|
850
|
+
const getUserAccessHierarchy = (app) => {
|
|
851
|
+
return httpRequest({
|
|
852
|
+
url: GET_USER_APP_ACCESS_HIERARCHY,
|
|
853
|
+
method: "GET",
|
|
854
|
+
params: { app },
|
|
855
|
+
});
|
|
856
|
+
};
|
|
857
|
+
/**
|
|
858
|
+
* getModuleLevelAccessHelper — fetches module-level access permissions.
|
|
859
|
+
* Mirrors core/actions/userAccessActions.getModuleLevelAccessHelper.
|
|
860
|
+
*/
|
|
861
|
+
const getModuleLevelAccessHelper = (app, modules) => {
|
|
862
|
+
const body = {
|
|
863
|
+
applications: {
|
|
864
|
+
[app]: modules,
|
|
865
|
+
},
|
|
866
|
+
};
|
|
867
|
+
return httpRequest({
|
|
868
|
+
url: GET_MODULE_LEVEL_ACCESS,
|
|
869
|
+
data: body,
|
|
870
|
+
method: "POST",
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
/**
|
|
874
|
+
* getModuleLevelAccessUtility — fetches both the access hierarchy and module
|
|
875
|
+
* permissions in parallel, then merges them into the legacy format.
|
|
876
|
+
* Mirrors core/actions/userAccessActions.getModuleLevelAccessUtility exactly.
|
|
877
|
+
*
|
|
878
|
+
* Unlike the original (which was a Redux thunk returning a function), this is
|
|
879
|
+
* a direct async function: `await getModuleLevelAccessUtility({...})`.
|
|
880
|
+
*/
|
|
881
|
+
const getModuleLevelAccessUtility = async ({ app, module: modules, }) => {
|
|
882
|
+
const [hierarchyResponse, accessResponse] = await Promise.all([
|
|
883
|
+
getUserAccessHierarchy(app),
|
|
884
|
+
getModuleLevelAccessHelper(app, modules),
|
|
885
|
+
]);
|
|
886
|
+
return convertAccessHierarchyToOldFormat(accessResponse?.data?.data[app], hierarchyResponse?.data?.data);
|
|
887
|
+
};
|
|
888
|
+
// ─── Internalized from core/actions/filterAction.js ──────────────────────────
|
|
889
|
+
/**
|
|
890
|
+
* getFilterUserConfiguration — fetches saved filter configurations for a screen.
|
|
891
|
+
* Mirrors core/actions/filterAction.getFilterUserConfiguration exactly.
|
|
892
|
+
*
|
|
893
|
+
* Unlike the original (which was a bare async function), the interface is the
|
|
894
|
+
* same: `const data = await getFilterUserConfiguration("Chatbot")`.
|
|
895
|
+
*/
|
|
896
|
+
const getFilterUserConfiguration = async (screenName) => {
|
|
897
|
+
const { data } = await httpRequest({
|
|
898
|
+
url: `${SAVE_FILTER_GET}/${screenName}`,
|
|
899
|
+
method: "GET",
|
|
900
|
+
});
|
|
901
|
+
return data.data;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Stable default selector references used as fallbacks when the consumer
|
|
906
|
+
* does not provide selectors via the provider. Module-level constants
|
|
907
|
+
* avoid creating new function references on every render (which would
|
|
908
|
+
* cause useSelector to re-subscribe and potentially loop).
|
|
909
|
+
*/
|
|
910
|
+
const NULL_SELECTOR = () => null;
|
|
911
|
+
const EMPTY_ARRAY_SELECTOR = () => [];
|
|
912
|
+
const ChatbotContext = createContext(null);
|
|
913
|
+
/**
|
|
914
|
+
* Wrap <SmartBot> with this provider to inject host-level dependencies
|
|
915
|
+
* (HTTP client, API constants, actions, selectors, heavy components).
|
|
916
|
+
*
|
|
917
|
+
* On mount (and whenever the value changes) the provider also initializes
|
|
918
|
+
* the module-level HTTP client singleton so that service files can call
|
|
919
|
+
* `getHttpClient()` / `httpRequest()` without prop-drilling.
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* <ChatbotProvider value={{ httpClient: axiosInstance, apiConstants: { BASE_API, COMBINED_CROSS_DIMENSIONAL_API } }}>
|
|
923
|
+
* <SmartBot userName={userName} />
|
|
924
|
+
* </ChatbotProvider>
|
|
925
|
+
*/
|
|
926
|
+
const ChatbotProvider = ({ value, children }) => {
|
|
927
|
+
// Eagerly initialize the HTTP singleton so even the very first render
|
|
928
|
+
// cycle of child components (which may trigger API calls in useEffect)
|
|
929
|
+
// has the client available.
|
|
930
|
+
if (value?.httpClient && value?.apiConstants) {
|
|
931
|
+
initHttpClient(value.httpClient, value.apiConstants);
|
|
932
|
+
}
|
|
933
|
+
// Also keep it in sync if the consumer swaps the value at runtime.
|
|
934
|
+
useEffect(() => {
|
|
935
|
+
if (value?.httpClient && value?.apiConstants) {
|
|
936
|
+
initHttpClient(value.httpClient, value.apiConstants);
|
|
937
|
+
}
|
|
938
|
+
}, [value?.httpClient, value?.apiConstants]);
|
|
939
|
+
return (jsx(ChatbotContext.Provider, { value: value, children: children }));
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* Hook consumed by internal package components to access host dependencies.
|
|
943
|
+
* Throws if called outside a <ChatbotProvider>.
|
|
944
|
+
*/
|
|
945
|
+
function useChatbotDeps() {
|
|
946
|
+
const ctx = useContext(ChatbotContext);
|
|
947
|
+
if (!ctx) {
|
|
948
|
+
throw new Error("useChatbotDeps() must be used within a <ChatbotProvider>. " +
|
|
949
|
+
"Wrap your <SmartBot> component with <ChatbotProvider value={{...}}>.");
|
|
950
|
+
}
|
|
951
|
+
return ctx;
|
|
952
|
+
}
|
|
325
953
|
|
|
326
|
-
const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction
|
|
954
|
+
const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction) => {
|
|
955
|
+
const { callbacks } = useChatbotDeps();
|
|
327
956
|
const displaySnackMessages = useCallback((message, variant) => {
|
|
328
|
-
try {
|
|
329
|
-
|
|
330
|
-
message
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
957
|
+
try {
|
|
958
|
+
if (callbacks?.onSnackbar) {
|
|
959
|
+
callbacks.onSnackbar(message, variant);
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
console.warn("onSnackbar callback not provided via ChatbotProvider");
|
|
963
|
+
}
|
|
335
964
|
}
|
|
336
965
|
catch (error) {
|
|
337
966
|
console.error("displaySnackMessages error", error);
|
|
338
967
|
}
|
|
339
|
-
}, [
|
|
968
|
+
}, [callbacks]);
|
|
340
969
|
const refreshAndUpdateUserManual = useCallback(async () => {
|
|
341
970
|
try {
|
|
342
971
|
setRefreshLoader(true);
|
|
@@ -365,8 +994,7 @@ const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction, dispatch)
|
|
|
365
994
|
let accessDataResponse = await getModuleLevelAccessUtility({
|
|
366
995
|
app: APP,
|
|
367
996
|
module: [MODULE],
|
|
368
|
-
|
|
369
|
-
})();
|
|
997
|
+
});
|
|
370
998
|
let rolesBasedModulesPermission = Object.fromEntries(Object.entries(accessDataResponse).map(([module, actions]) => [
|
|
371
999
|
module,
|
|
372
1000
|
Object.keys(actions),
|
|
@@ -486,10 +1114,30 @@ const updateQuestionFeedback = async (sessionId, isLiked) => {
|
|
|
486
1114
|
return null;
|
|
487
1115
|
}
|
|
488
1116
|
};
|
|
1117
|
+
// PATCH /questions/{session_id} — persist how long a turn took.
|
|
1118
|
+
// All three fields are required; `duration` is an integer in milliseconds.
|
|
1119
|
+
const updateQuestionTiming = async (sessionId, { startTime, endTime, duration } = {}) => {
|
|
1120
|
+
try {
|
|
1121
|
+
return axios({
|
|
1122
|
+
url: `${getChatHistoryBaseUrl()}/questions/${sessionId}`,
|
|
1123
|
+
method: "PATCH",
|
|
1124
|
+
headers: { "Content-Type": "application/json" },
|
|
1125
|
+
data: {
|
|
1126
|
+
start_time: startTime,
|
|
1127
|
+
end_time: endTime,
|
|
1128
|
+
duration,
|
|
1129
|
+
},
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
catch (error) {
|
|
1133
|
+
console.error("updateQuestionTiming error", error);
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
489
1137
|
const fetchConversations = async (currentMode) => {
|
|
490
1138
|
try {
|
|
491
1139
|
// Will be replaced with actual API call
|
|
492
|
-
return
|
|
1140
|
+
return httpRequest({
|
|
493
1141
|
url: `core/chatbot/conversation/${currentMode}`,
|
|
494
1142
|
method: "GET"
|
|
495
1143
|
});
|
|
@@ -516,7 +1164,7 @@ const fetchConversations = async (currentMode) => {
|
|
|
516
1164
|
};
|
|
517
1165
|
const createConversation = async (payload) => {
|
|
518
1166
|
try {
|
|
519
|
-
return
|
|
1167
|
+
return httpRequest({
|
|
520
1168
|
url: `core/chatbot/conversation`,
|
|
521
1169
|
method: "POST",
|
|
522
1170
|
data: payload
|
|
@@ -529,7 +1177,7 @@ const createConversation = async (payload) => {
|
|
|
529
1177
|
};
|
|
530
1178
|
const updateConversation = async (conversationId, payload) => {
|
|
531
1179
|
try {
|
|
532
|
-
return
|
|
1180
|
+
return httpRequest({
|
|
533
1181
|
url: `core/chatbot/conversation/update`,
|
|
534
1182
|
method: "POST",
|
|
535
1183
|
data: payload
|
|
@@ -542,7 +1190,7 @@ const updateConversation = async (conversationId, payload) => {
|
|
|
542
1190
|
};
|
|
543
1191
|
const deleteConversation = async (conversationId) => {
|
|
544
1192
|
try {
|
|
545
|
-
return
|
|
1193
|
+
return httpRequest({
|
|
546
1194
|
url: `core/chatbot/conversation/${conversationId}`,
|
|
547
1195
|
method: "DELETE"
|
|
548
1196
|
});
|
|
@@ -554,7 +1202,7 @@ const deleteConversation = async (conversationId) => {
|
|
|
554
1202
|
};
|
|
555
1203
|
const saveChat = async (payload) => {
|
|
556
1204
|
try {
|
|
557
|
-
return
|
|
1205
|
+
return httpRequest({
|
|
558
1206
|
url: `core/chatbot/conversation`,
|
|
559
1207
|
method: "POST",
|
|
560
1208
|
data: payload
|
|
@@ -785,7 +1433,6 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
785
1433
|
isDisabled: data?.data?.isDisabled,
|
|
786
1434
|
orientation: data?.data?.orientation,
|
|
787
1435
|
options: data?.data?.options,
|
|
788
|
-
defaultSelected: data?.data?.defaultSelected,
|
|
789
1436
|
paramName: data?.data?.param_name
|
|
790
1437
|
}
|
|
791
1438
|
};
|
|
@@ -865,17 +1512,6 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
865
1512
|
bodyType: "html",
|
|
866
1513
|
bodyText: { content: data?.data?.content || "" },
|
|
867
1514
|
};
|
|
868
|
-
case "allocation_plan_card":
|
|
869
|
-
return {
|
|
870
|
-
...data,
|
|
871
|
-
timeStamp: timeString,
|
|
872
|
-
userType: "bot",
|
|
873
|
-
userName: userName,
|
|
874
|
-
headerTitle: "",
|
|
875
|
-
noShowHeaderTitle: true,
|
|
876
|
-
bodyType: "allocation_plan_card",
|
|
877
|
-
bodyText: data?.data || data,
|
|
878
|
-
};
|
|
879
1515
|
case "image":
|
|
880
1516
|
return {
|
|
881
1517
|
...data,
|
|
@@ -903,18 +1539,6 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
903
1539
|
thinkingResponse: utilityObject?.thinkingResponse,
|
|
904
1540
|
enableLikes: true
|
|
905
1541
|
};
|
|
906
|
-
case "surface_frame":
|
|
907
|
-
// A generated UI surface drawn by the UI service's renderer page (Impact UI 5), which SurfaceFrameContent embeds
|
|
908
|
-
return {
|
|
909
|
-
...data,
|
|
910
|
-
agentId: agentId,
|
|
911
|
-
timeStamp: timeString,
|
|
912
|
-
userType: "bot",
|
|
913
|
-
userName: userName,
|
|
914
|
-
headerTitle: data?.data?.surface?.title || "",
|
|
915
|
-
bodyType: "surface_frame",
|
|
916
|
-
bodyText: data?.data,
|
|
917
|
-
};
|
|
918
1542
|
default:
|
|
919
1543
|
return null;
|
|
920
1544
|
}
|
|
@@ -1166,275 +1790,6 @@ const extractSavedFilterData = (selectedFilterSet, userText = "", existingExplic
|
|
|
1166
1790
|
return { userExplicitInput, textWithColumnNames };
|
|
1167
1791
|
};
|
|
1168
1792
|
|
|
1169
|
-
// Special character mapping for text replacement
|
|
1170
|
-
const SPECIAL_CHARACTER_MAPPING = {
|
|
1171
|
-
__ia_char_01: "'",
|
|
1172
|
-
__ia_char_02: '"',
|
|
1173
|
-
__ia_char_03: "/",
|
|
1174
|
-
__ia_char_04: "\\",
|
|
1175
|
-
__ia_char_05: "`",
|
|
1176
|
-
__ia_char_06: "~",
|
|
1177
|
-
__ia_char_07: "!",
|
|
1178
|
-
__ia_char_08: "@",
|
|
1179
|
-
__ia_char_09: "#",
|
|
1180
|
-
__ia_char_10: "$",
|
|
1181
|
-
__ia_char_11: "%",
|
|
1182
|
-
__ia_char_12: "^",
|
|
1183
|
-
__ia_char_13: "&",
|
|
1184
|
-
__ia_char_14: "*",
|
|
1185
|
-
__ia_char_15: "(",
|
|
1186
|
-
__ia_char_16: ")",
|
|
1187
|
-
__ia_char_19: "=",
|
|
1188
|
-
__ia_char_20: "+",
|
|
1189
|
-
__ia_char_21: "{",
|
|
1190
|
-
__ia_char_22: "}",
|
|
1191
|
-
__ia_char_23: "[",
|
|
1192
|
-
__ia_char_24: "]",
|
|
1193
|
-
__ia_char_25: "|",
|
|
1194
|
-
__ia_char_26: ":",
|
|
1195
|
-
__ia_char_27: ";",
|
|
1196
|
-
__ia_char_28: "<",
|
|
1197
|
-
__ia_char_29: ">",
|
|
1198
|
-
__ia_char_30: ",",
|
|
1199
|
-
__ia_char_31: ".",
|
|
1200
|
-
__ia_char_32: "?",
|
|
1201
|
-
__ia_char_33: "/",
|
|
1202
|
-
};
|
|
1203
|
-
const navigationOptions = [
|
|
1204
|
-
{
|
|
1205
|
-
link: "/inventory-smart/decision-dashboard",
|
|
1206
|
-
screen_name: "Dashboard",
|
|
1207
|
-
flow_type: "navigation",
|
|
1208
|
-
},
|
|
1209
|
-
{
|
|
1210
|
-
link: `/inventory-smart/create-allocation/?step=0`,
|
|
1211
|
-
flow_type: "navigation",
|
|
1212
|
-
screen_name: "Allocation",
|
|
1213
|
-
},
|
|
1214
|
-
{
|
|
1215
|
-
link: "/inventory-smart/configuration",
|
|
1216
|
-
flow_type: "navigation",
|
|
1217
|
-
screen_name: "Configurations",
|
|
1218
|
-
},
|
|
1219
|
-
{
|
|
1220
|
-
link: "/inventory-smart/store-eligibility-grouping",
|
|
1221
|
-
flow_type: "navigation",
|
|
1222
|
-
screen_name: "Grouping",
|
|
1223
|
-
},
|
|
1224
|
-
{
|
|
1225
|
-
link: "/inventory-smart/constraints",
|
|
1226
|
-
flow_type: "navigation",
|
|
1227
|
-
screen_name: "Constraints",
|
|
1228
|
-
},
|
|
1229
|
-
{
|
|
1230
|
-
link: "/inventory-smart/ada/dashboard",
|
|
1231
|
-
flow_type: "navigation",
|
|
1232
|
-
screen_name: "ADA Visual",
|
|
1233
|
-
},
|
|
1234
|
-
];
|
|
1235
|
-
const insightsOptions = [
|
|
1236
|
-
{
|
|
1237
|
-
link: "/inventory-smart/decision-dashboard",
|
|
1238
|
-
screen_name: "Dashboard",
|
|
1239
|
-
flow_type: "insights",
|
|
1240
|
-
},
|
|
1241
|
-
{
|
|
1242
|
-
link: `/inventory-smart/create-allocation/?step=0`,
|
|
1243
|
-
flow_type: "insights",
|
|
1244
|
-
screen_name: "Allocation",
|
|
1245
|
-
},
|
|
1246
|
-
{
|
|
1247
|
-
link: "/inventory-smart/store-eligibility-grouping",
|
|
1248
|
-
flow_type: "insights",
|
|
1249
|
-
screen_name: "Configurations",
|
|
1250
|
-
},
|
|
1251
|
-
{
|
|
1252
|
-
link: "/inventory-smart/configuration",
|
|
1253
|
-
flow_type: "insights",
|
|
1254
|
-
screen_name: "Grouping",
|
|
1255
|
-
},
|
|
1256
|
-
{
|
|
1257
|
-
link: "/inventory-smart/constraints",
|
|
1258
|
-
flow_type: "insights",
|
|
1259
|
-
screen_name: "Constraints",
|
|
1260
|
-
},
|
|
1261
|
-
{
|
|
1262
|
-
link: "/inventory-smart/ada/dashboard",
|
|
1263
|
-
flow_type: "insights",
|
|
1264
|
-
screen_name: "ADA Visual",
|
|
1265
|
-
},
|
|
1266
|
-
];
|
|
1267
|
-
const screenOptions = [
|
|
1268
|
-
{
|
|
1269
|
-
link: "/inventory-smart/decision-dashboard",
|
|
1270
|
-
screen_name: "InventoryDashboard",
|
|
1271
|
-
filterCongfigurationName: "decisionDashboardFilterConfiguration",
|
|
1272
|
-
},
|
|
1273
|
-
{
|
|
1274
|
-
link: "/inventory-smart/product-profile",
|
|
1275
|
-
screen_name: "Product Profile",
|
|
1276
|
-
filterCongfigurationName: "productProfileDashboardFilterConfig",
|
|
1277
|
-
},
|
|
1278
|
-
{
|
|
1279
|
-
link: `/inventory-smart/create-allocation/?step=0`,
|
|
1280
|
-
screen_name: "Allocation",
|
|
1281
|
-
filterCongfigurationName: "createAllocationFilterConfiguration",
|
|
1282
|
-
},
|
|
1283
|
-
{
|
|
1284
|
-
link: "/inventory-smart/store-eligibility-grouping",
|
|
1285
|
-
screen_name: "Inventorysmart Store Eligibility Group",
|
|
1286
|
-
filterCongfigurationName: "storeGroupingFilterConfiguration",
|
|
1287
|
-
},
|
|
1288
|
-
{
|
|
1289
|
-
link: "/inventory-smart/configuration",
|
|
1290
|
-
screen_name: "Inventorysmart Configurations",
|
|
1291
|
-
filterCongfigurationName: "productStatusFilterConfiguration",
|
|
1292
|
-
},
|
|
1293
|
-
{
|
|
1294
|
-
link: "/inventory-smart/constraints",
|
|
1295
|
-
screen_name: "Inventorysmart Constraints",
|
|
1296
|
-
filterCongfigurationName: "rulesConstraintsFilterConfig",
|
|
1297
|
-
},
|
|
1298
|
-
{
|
|
1299
|
-
link: "/inventory-smart/allocation-reports",
|
|
1300
|
-
screen_name: "Inventorysmart Reportings",
|
|
1301
|
-
filterCongfigurationName: "lostSalesFilterConfiguration",
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
link: "/inventory-smart/ada/dashboard",
|
|
1305
|
-
screen_name: "Inventorysmart ADA Dashboard",
|
|
1306
|
-
filterCongfigurationName: "adaVisualFilterConfiguration",
|
|
1307
|
-
},
|
|
1308
|
-
];
|
|
1309
|
-
|
|
1310
|
-
/**
|
|
1311
|
-
* Core utility functions copied from core/Utils/functions/utils
|
|
1312
|
-
* These are internalized to make chatbot-v2 self-contained
|
|
1313
|
-
*/
|
|
1314
|
-
/**
|
|
1315
|
-
* Replace special characters in a string
|
|
1316
|
-
*/
|
|
1317
|
-
const replaceSpecialCharacter = (str) => {
|
|
1318
|
-
if (typeof str === "object") {
|
|
1319
|
-
return str;
|
|
1320
|
-
}
|
|
1321
|
-
else {
|
|
1322
|
-
let result = str;
|
|
1323
|
-
if (SPECIAL_CHARACTER_MAPPING) {
|
|
1324
|
-
Object.keys(SPECIAL_CHARACTER_MAPPING).forEach((key) => {
|
|
1325
|
-
if (result?.includes(key)) {
|
|
1326
|
-
result = result.replaceAll(key, SPECIAL_CHARACTER_MAPPING[key]);
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1329
|
-
}
|
|
1330
|
-
return result;
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
/**
|
|
1334
|
-
* @function
|
|
1335
|
-
* @description Function is used to return string by replacing the special characters with respective key mapped to SPECIAL_CHARACTER_MAPPING
|
|
1336
|
-
* @param {String} str
|
|
1337
|
-
* @returns {String} key of mapped special character used in the string
|
|
1338
|
-
*/
|
|
1339
|
-
const replaceSpecialCharToCharCode = (str) => {
|
|
1340
|
-
let re = new RegExp(`[${Object.values(SPECIAL_CHARACTER_MAPPING).join("")}]`, "g");
|
|
1341
|
-
return str.replace(re, function (matched) {
|
|
1342
|
-
let code;
|
|
1343
|
-
for (const [key, value] of Object.entries(SPECIAL_CHARACTER_MAPPING)) {
|
|
1344
|
-
if (value === matched) {
|
|
1345
|
-
code = key;
|
|
1346
|
-
return code;
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
return code;
|
|
1350
|
-
});
|
|
1351
|
-
};
|
|
1352
|
-
|
|
1353
|
-
/**
|
|
1354
|
-
* Utility functions extracted from core/Utils/functions/utils.js
|
|
1355
|
-
* Only includes functions used by chatbot-v2
|
|
1356
|
-
*/
|
|
1357
|
-
|
|
1358
|
-
// Users listing endpoint (same as core's GET_USERS). Inlined here so this
|
|
1359
|
-
// standalone package doesn't depend on the core user-management service.
|
|
1360
|
-
const GET_USERS_URL = "/core/user-mgmt/list";
|
|
1361
|
-
|
|
1362
|
-
// Convert pixels to rem
|
|
1363
|
-
const pxToRem = (px) => `${px / 16}rem`;
|
|
1364
|
-
|
|
1365
|
-
// Resolve the current user's code via the users API, matching the logged-in
|
|
1366
|
-
// email (localStorage "name"). Mirrors core/Utils/functions/utils.getCurrentUserId
|
|
1367
|
-
// so the multi-chat history APIs receive a real user_id (sessionStorage may not
|
|
1368
|
-
// carry it in the standalone package host).
|
|
1369
|
-
const getCurrentUserId = async () => {
|
|
1370
|
-
try {
|
|
1371
|
-
const postBody = {
|
|
1372
|
-
meta: {
|
|
1373
|
-
search: [],
|
|
1374
|
-
range: [],
|
|
1375
|
-
sort: [],
|
|
1376
|
-
},
|
|
1377
|
-
};
|
|
1378
|
-
const users = await axiosInstance({
|
|
1379
|
-
url: GET_USERS_URL,
|
|
1380
|
-
method: "POST",
|
|
1381
|
-
data: postBody,
|
|
1382
|
-
});
|
|
1383
|
-
const loggedInUserEmail = localStorage.getItem("name");
|
|
1384
|
-
const user = users?.data?.data?.filter((item) => {
|
|
1385
|
-
return item.email === loggedInUserEmail;
|
|
1386
|
-
});
|
|
1387
|
-
return user[0]?.user_code;
|
|
1388
|
-
} catch (error) {
|
|
1389
|
-
console.error("getCurrentUserId error", error);
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
|
-
|
|
1393
|
-
// Get user name from session storage
|
|
1394
|
-
const getUserName = () => {
|
|
1395
|
-
const userDetails = JSON.parse(sessionStorage.getItem("userDetails") || "{}");
|
|
1396
|
-
return userDetails?.user_name || "User";
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
// Get formatted application name based on URL
|
|
1400
|
-
const getFormattedApplicationName = (applicationURL) => {
|
|
1401
|
-
switch (applicationURL) {
|
|
1402
|
-
case "user-management":
|
|
1403
|
-
case "tenantconfig":
|
|
1404
|
-
return "application access management";
|
|
1405
|
-
case "assort-smart":
|
|
1406
|
-
return "AssortSmart";
|
|
1407
|
-
case "configurator":
|
|
1408
|
-
return "module configurator";
|
|
1409
|
-
case "inventory-smart":
|
|
1410
|
-
return "InventorySmart";
|
|
1411
|
-
case "ada":
|
|
1412
|
-
return "ADA";
|
|
1413
|
-
case "plan-smart":
|
|
1414
|
-
return "PlanSmart";
|
|
1415
|
-
case "adaconfigurator":
|
|
1416
|
-
return "ADAConfigurator";
|
|
1417
|
-
case "item-smart":
|
|
1418
|
-
return "ItemSmart";
|
|
1419
|
-
case "item-smart-new":
|
|
1420
|
-
return "ItemSmart-New";
|
|
1421
|
-
case "source-smart":
|
|
1422
|
-
return "SourceSmart";
|
|
1423
|
-
case "pricesmart-markdown":
|
|
1424
|
-
return "PriceSmart Markdown";
|
|
1425
|
-
case "pricesmart-promo":
|
|
1426
|
-
return "PriceSmart Promo";
|
|
1427
|
-
case "agentic-assort":
|
|
1428
|
-
return "AssortSmart";
|
|
1429
|
-
case "source-smart":
|
|
1430
|
-
return "SourceSmart"
|
|
1431
|
-
case "size-smart":
|
|
1432
|
-
return "SizeSmart"
|
|
1433
|
-
default:
|
|
1434
|
-
return "workflow input center";
|
|
1435
|
-
}
|
|
1436
|
-
};
|
|
1437
|
-
|
|
1438
1793
|
/**
|
|
1439
1794
|
* Resolves a link href to an in-app route (path + search + hash) when the link
|
|
1440
1795
|
* points to a screen of this application, otherwise returns null.
|
|
@@ -2446,10 +2801,6 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
2446
2801
|
answer_mode: data?.answerMode || "auto",
|
|
2447
2802
|
...(!isEmpty(utilityObjectData?.additionalArgs) ? utilityObjectData.additionalArgs : {}),
|
|
2448
2803
|
};
|
|
2449
|
-
if (data?.uiContext && typeof data.uiContext === "object") {
|
|
2450
|
-
// a follow-up asked from a generated surface: which surface, and its input values
|
|
2451
|
-
payload.ui_context = data.uiContext;
|
|
2452
|
-
}
|
|
2453
2804
|
// Handle @ filter mentions - user_explicit_input contains filter values
|
|
2454
2805
|
if (!isEmpty(data?.userExplicitInput)) {
|
|
2455
2806
|
payload.user_explicit_input = data?.userExplicitInput;
|
|
@@ -2468,12 +2819,12 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
2468
2819
|
: chatbotContext[key]?.type === "number" ? Number(value) : value.toString();
|
|
2469
2820
|
// Decode special characters for chat_input display
|
|
2470
2821
|
if (isArray(value)) {
|
|
2471
|
-
value = value.map((item) => replaceSpecialCharacter(item.toString()));
|
|
2822
|
+
value = value.map((item) => replaceSpecialCharacter$2(item.toString()));
|
|
2472
2823
|
}
|
|
2473
2824
|
else {
|
|
2474
|
-
value = replaceSpecialCharacter(value.toString());
|
|
2825
|
+
value = replaceSpecialCharacter$2(value.toString());
|
|
2475
2826
|
}
|
|
2476
|
-
payload.chat_input = payload.chat_input + `${replaceSpecialCharacter(value)},`;
|
|
2827
|
+
payload.chat_input = payload.chat_input + `${replaceSpecialCharacter$2(value)},`;
|
|
2477
2828
|
}
|
|
2478
2829
|
}
|
|
2479
2830
|
dispatch(setChatbotContext({}));
|
|
@@ -2617,7 +2968,72 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
2617
2968
|
};
|
|
2618
2969
|
};
|
|
2619
2970
|
|
|
2971
|
+
/**
|
|
2972
|
+
* SmartBot Redux action type constants.
|
|
2973
|
+
* These MUST match the consumer's core/actions/types.js values exactly
|
|
2974
|
+
* so actions dispatched by the package are handled by the host reducer.
|
|
2975
|
+
*/
|
|
2976
|
+
const SET_SMART_BOT_ACTIVE = "SET_SMART_BOT_ACTIVE";
|
|
2977
|
+
const SET_IS_SMART_BOT_RESTRICTED = "SET_IS_SMART_BOT_RESTRICTED";
|
|
2978
|
+
const SET_CHATBOT_CONTEXT = "SET_CHATBOT_CONTEXT";
|
|
2979
|
+
const SET_THINKING_CONTEXT = "SET_THINKING_CONTEXT";
|
|
2980
|
+
const SET_HIERARCHY_KEY_VALUE_PAIR = "SET_HIERARCHY_KEY_VALUE_PAIR";
|
|
2981
|
+
const SET_CURRENT_AGENT_CHAT_ID = "SET_CURRENT_AGENT_CHAT_ID";
|
|
2982
|
+
const SET_PERSISTED_FORM_VALUES = "SET_PERSISTED_FORM_VALUES";
|
|
2983
|
+
const CLEAR_PERSISTED_FORM_VALUES = "CLEAR_PERSISTED_FORM_VALUES";
|
|
2984
|
+
const SET_SAVED_FILTER_SETS = "SET_SAVED_FILTER_SETS";
|
|
2985
|
+
const SET_STEP_FORM_RESTREAM_PAYLOAD = "SET_STEP_FORM_RESTREAM_PAYLOAD";
|
|
2986
|
+
const SET_STEP_FORM_STREAM_DATA = "SET_STEP_FORM_STREAM_DATA";
|
|
2987
|
+
const SET_MINIMIZED_STREAM_DATA = "SET_MINIMIZED_STREAM_DATA";
|
|
2988
|
+
const SET_CHATBOT_FILTER_OPTIONS = "SET_CHATBOT_FILTER_OPTIONS";
|
|
2989
|
+
|
|
2990
|
+
/**
|
|
2991
|
+
* SmartBot Redux action creators.
|
|
2992
|
+
* Each is a thunk `(value) => (dispatch) => dispatch({...})` matching the
|
|
2993
|
+
* consumer's core/actions/smartBotActions.js signatures exactly.
|
|
2994
|
+
*/
|
|
2995
|
+
const setSmartBotActive = (value) => (dispatch) => {
|
|
2996
|
+
dispatch({ type: SET_SMART_BOT_ACTIVE, payload: value });
|
|
2997
|
+
};
|
|
2998
|
+
const setIsSmartBotRestricted = (value) => (dispatch) => {
|
|
2999
|
+
dispatch({ type: SET_IS_SMART_BOT_RESTRICTED, payload: value });
|
|
3000
|
+
};
|
|
3001
|
+
const setChatbotContext = (value) => (dispatch) => {
|
|
3002
|
+
dispatch({ type: SET_CHATBOT_CONTEXT, payload: value });
|
|
3003
|
+
};
|
|
3004
|
+
const setThinkingContext = (value) => (dispatch) => {
|
|
3005
|
+
dispatch({ type: SET_THINKING_CONTEXT, payload: value });
|
|
3006
|
+
};
|
|
3007
|
+
const setHierarchyKeyValue = (value) => (dispatch) => {
|
|
3008
|
+
dispatch({ type: SET_HIERARCHY_KEY_VALUE_PAIR, payload: value });
|
|
3009
|
+
};
|
|
3010
|
+
const setCurrentAgentChatId = (value) => (dispatch) => {
|
|
3011
|
+
dispatch({ type: SET_CURRENT_AGENT_CHAT_ID, payload: value });
|
|
3012
|
+
};
|
|
3013
|
+
const setPersistedFormValues = (value) => (dispatch) => {
|
|
3014
|
+
dispatch({ type: SET_PERSISTED_FORM_VALUES, payload: value });
|
|
3015
|
+
};
|
|
3016
|
+
const clearPersistedFormValues = () => (dispatch) => {
|
|
3017
|
+
dispatch({ type: CLEAR_PERSISTED_FORM_VALUES });
|
|
3018
|
+
};
|
|
3019
|
+
const setStepFormRestreamPayload = (value) => (dispatch) => {
|
|
3020
|
+
dispatch({ type: SET_STEP_FORM_RESTREAM_PAYLOAD, payload: value });
|
|
3021
|
+
};
|
|
3022
|
+
const setSavedFilterSets = (value) => (dispatch) => {
|
|
3023
|
+
dispatch({ type: SET_SAVED_FILTER_SETS, payload: value });
|
|
3024
|
+
};
|
|
3025
|
+
const setStepFormStreamData = (value) => (dispatch) => {
|
|
3026
|
+
dispatch({ type: SET_STEP_FORM_STREAM_DATA, payload: value });
|
|
3027
|
+
};
|
|
3028
|
+
const setMinimizedStreamData = (value) => (dispatch) => {
|
|
3029
|
+
dispatch({ type: SET_MINIMIZED_STREAM_DATA, payload: value });
|
|
3030
|
+
};
|
|
3031
|
+
const setChatbotFilterOptions = (value) => (dispatch) => {
|
|
3032
|
+
dispatch({ type: SET_CHATBOT_FILTER_OPTIONS, payload: value });
|
|
3033
|
+
};
|
|
3034
|
+
|
|
2620
3035
|
const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId, setUniqueChatId, setAdditionalArgs, answerMode) => {
|
|
3036
|
+
const { callbacks } = useChatbotDeps();
|
|
2621
3037
|
const navSessionIdRef = useRef(navSessionId);
|
|
2622
3038
|
useEffect(() => {
|
|
2623
3039
|
navSessionIdRef.current = navSessionId;
|
|
@@ -2845,15 +3261,8 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
|
|
|
2845
3261
|
else if (data.actionType === "indirect") {
|
|
2846
3262
|
setUserInput(data.displayText);
|
|
2847
3263
|
}
|
|
2848
|
-
else if (data.screen_name) {
|
|
2849
|
-
fetchUserResultsFromQuery(data, true, "", activeConversationId);
|
|
2850
|
-
}
|
|
2851
3264
|
else {
|
|
2852
|
-
|
|
2853
|
-
// treat the chip's displayText as a regular user query so it flows
|
|
2854
|
-
// through the navigation streaming endpoint instead of the
|
|
2855
|
-
// fetchRelatedQuestions screen-based endpoint.
|
|
2856
|
-
fetchUserResultsFromQuery(data, false, data.displayText, activeConversationId);
|
|
3265
|
+
fetchUserResultsFromQuery(data, true, "", activeConversationId);
|
|
2857
3266
|
}
|
|
2858
3267
|
}, [activeConversationId, baseUrl]);
|
|
2859
3268
|
const fetchUserResultsFromQuery = useCallback(async (refObject, fetchQuestions = false, inputValue = userInput, conversationId = activeConversationId) => {
|
|
@@ -3066,7 +3475,9 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
|
|
|
3066
3475
|
});
|
|
3067
3476
|
}
|
|
3068
3477
|
for (const key in preSelectedFilters) {
|
|
3069
|
-
|
|
3478
|
+
if (callbacks?.onSetSelectedFilters) {
|
|
3479
|
+
callbacks.onSetSelectedFilters({ [key]: preSelectedFilters[key] });
|
|
3480
|
+
}
|
|
3070
3481
|
}
|
|
3071
3482
|
for (const key in preSelectedFilters) {
|
|
3072
3483
|
preSelectedFilters[key].forEach((selectedFilter) => {
|
|
@@ -3084,7 +3495,9 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
|
|
|
3084
3495
|
filterConfig: updateFilterConfigData,
|
|
3085
3496
|
appliedFilterData: appliedFilterData,
|
|
3086
3497
|
};
|
|
3087
|
-
|
|
3498
|
+
if (callbacks?.onSetFilterConfiguration) {
|
|
3499
|
+
callbacks.onSetFilterConfiguration(obj);
|
|
3500
|
+
}
|
|
3088
3501
|
const applyFilterBtn = document.getElementById("filterBtn");
|
|
3089
3502
|
setTimeout(() => {
|
|
3090
3503
|
applyFilterBtn.click();
|
|
@@ -4014,19 +4427,6 @@ const useStyles$b = makeStyles((theme) => ({
|
|
|
4014
4427
|
fontSize: "14px",
|
|
4015
4428
|
marginRight: "7px",
|
|
4016
4429
|
},
|
|
4017
|
-
userViewBlock: {
|
|
4018
|
-
display: "inline-flex", // Automatically adjust width to fit content
|
|
4019
|
-
alignSelf: "flex-end", // Align message bubble to the right
|
|
4020
|
-
background: theme.palette.grey[300], // Grey background for the message bubble
|
|
4021
|
-
padding: "0.75rem", // Padding around the message
|
|
4022
|
-
borderRadius: "0.5rem",
|
|
4023
|
-
marginBottom: "0.5rem",
|
|
4024
|
-
maxWidth: "80%", // Cap the width for long messages
|
|
4025
|
-
minWidth: "20%", // Ensure small messages like "Hi" take minimal space
|
|
4026
|
-
wordWrap: "break-word", // Wrap long words or URLs
|
|
4027
|
-
textAlign: "left",
|
|
4028
|
-
width: "fit-content",
|
|
4029
|
-
},
|
|
4030
4430
|
firstRow: {
|
|
4031
4431
|
display: "flex",
|
|
4032
4432
|
alignItems: "center", // Align time and double ticks vertically
|
|
@@ -4062,9 +4462,6 @@ const useStyles$b = makeStyles((theme) => ({
|
|
|
4062
4462
|
fontSize: "14px",
|
|
4063
4463
|
lineHeight: "21px",
|
|
4064
4464
|
},
|
|
4065
|
-
boldText: {
|
|
4066
|
-
fontWeight: 600,
|
|
4067
|
-
},
|
|
4068
4465
|
combinedBlockHeaderTitle: {
|
|
4069
4466
|
marginBottom: "0.5rem",
|
|
4070
4467
|
},
|
|
@@ -4631,8 +5028,9 @@ const useChatState = () => {
|
|
|
4631
5028
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
4632
5029
|
const [deleteTargetId, setDeleteTargetId] = useState(null);
|
|
4633
5030
|
// Selectors
|
|
4634
|
-
const
|
|
4635
|
-
const
|
|
5031
|
+
const { selectors } = useChatbotDeps();
|
|
5032
|
+
const filterReducerState = useSelector(selectors?.getFilterState ?? NULL_SELECTOR);
|
|
5033
|
+
const notificationData = useSelector(selectors?.getNotificationData ?? EMPTY_ARRAY_SELECTOR);
|
|
4636
5034
|
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
4637
5035
|
const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
|
|
4638
5036
|
// All useRef declarations
|
|
@@ -5597,73 +5995,6 @@ const QuestionsContent = ({ bodyText, props }) => {
|
|
|
5597
5995
|
}) }));
|
|
5598
5996
|
};
|
|
5599
5997
|
|
|
5600
|
-
/**
|
|
5601
|
-
* One widget per generated surface in a stream: the agent may send a surface more than once (a placeholder
|
|
5602
|
-
* while it is composed, `status: "pending"`, version 0; then the surface, version 1; or its withdrawal), and
|
|
5603
|
-
* frame protocol 1 replaces a surface by its id (agent-ui-service-ssr docs/chat-frame-widget.md, rule 4).
|
|
5604
|
-
* No imports: the stream reader (AxiosEventSource) uses it too. Ported from core's smartBot
|
|
5605
|
-
* (insideinsight/core feat/iui-surface, e386f8f0).
|
|
5606
|
-
*/
|
|
5607
|
-
/** A surface's version; one when it gives none. */
|
|
5608
|
-
const surfaceVersion = (surface) => (Number.isFinite(surface?.version) ? surface.version : 1);
|
|
5609
|
-
const surfaceIdOf = (widget) => (widget?.type === "surface_frame" ? widget?.data?.surface?.id : undefined);
|
|
5610
|
-
/** A stream's widgets with these added: a surface_frame widget whose surface the list already holds replaces
|
|
5611
|
-
* it in place (a lower version is dropped); any other widget is added at the end. */
|
|
5612
|
-
const mergeSurfaceWidgets = (previous, incoming) => {
|
|
5613
|
-
const merged = Array.isArray(previous) ? previous.slice() : previous ? [previous] : [];
|
|
5614
|
-
for (const widget of Array.isArray(incoming) ? incoming : [incoming]) {
|
|
5615
|
-
const id = surfaceIdOf(widget);
|
|
5616
|
-
const at = id === undefined ? -1 : merged.findIndex((w) => surfaceIdOf(w) === id);
|
|
5617
|
-
if (at < 0)
|
|
5618
|
-
merged.push(widget);
|
|
5619
|
-
else if (surfaceVersion(widget.data.surface) >= surfaceVersion(merged[at].data.surface))
|
|
5620
|
-
merged[at] = widget;
|
|
5621
|
-
}
|
|
5622
|
-
return merged;
|
|
5623
|
-
};
|
|
5624
|
-
/*
|
|
5625
|
-
* Across the chat's messages (one page per surface): a surface revised in a later turn is shown, newest
|
|
5626
|
-
* version, where that turn put it; each earlier widget of it collapses to a line. Every SurfaceFrameContent
|
|
5627
|
-
* says which version it shows; a widget whose surface another widget shows in a higher version collapses.
|
|
5628
|
-
* Placeholders and withdrawn surfaces take no part. Equal versions (the same surface drawn in two places)
|
|
5629
|
-
* both show.
|
|
5630
|
-
*/
|
|
5631
|
-
const shownVersions = new Map(); // surface id -> Map(widget token -> version)
|
|
5632
|
-
const watchers = new Set();
|
|
5633
|
-
let lastToken = 0;
|
|
5634
|
-
/** A token for one widget. */
|
|
5635
|
-
const surfaceToken = () => {
|
|
5636
|
-
lastToken += 1;
|
|
5637
|
-
return lastToken;
|
|
5638
|
-
};
|
|
5639
|
-
const notify = () => watchers.forEach((watch) => watch());
|
|
5640
|
-
/** This widget shows `version` of surface `id`. */
|
|
5641
|
-
const showSurface = (id, token, version) => {
|
|
5642
|
-
if (!shownVersions.has(id))
|
|
5643
|
-
shownVersions.set(id, new Map());
|
|
5644
|
-
shownVersions.get(id).set(token, version);
|
|
5645
|
-
notify();
|
|
5646
|
-
};
|
|
5647
|
-
/** This widget no longer shows surface `id`. */
|
|
5648
|
-
const hideSurface = (id, token) => {
|
|
5649
|
-
const versions = shownVersions.get(id);
|
|
5650
|
-
if (!versions)
|
|
5651
|
-
return;
|
|
5652
|
-
versions.delete(token);
|
|
5653
|
-
if (versions.size === 0)
|
|
5654
|
-
shownVersions.delete(id);
|
|
5655
|
-
notify();
|
|
5656
|
-
};
|
|
5657
|
-
/** Whether another widget shows surface `id` in a version higher than `version`. */
|
|
5658
|
-
const newerShown = (id, version) => [...(shownVersions.get(id)?.values() ?? [])].some((v) => v > version);
|
|
5659
|
-
/** Calls `watch` whenever a widget starts or stops showing a surface; returns the unsubscribe. */
|
|
5660
|
-
const watchSurfaces = (watch) => {
|
|
5661
|
-
watchers.add(watch);
|
|
5662
|
-
return () => {
|
|
5663
|
-
watchers.delete(watch);
|
|
5664
|
-
};
|
|
5665
|
-
};
|
|
5666
|
-
|
|
5667
5998
|
// Utility: check whether a string is a likely complete JSON value
|
|
5668
5999
|
const isLikelyCompleteJson = (message) => {
|
|
5669
6000
|
try {
|
|
@@ -5871,8 +6202,10 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5871
6202
|
let previousWidgetData = isArray$1(messageToStoreRef.current.appendedData)
|
|
5872
6203
|
? messageToStoreRef.current.appendedData
|
|
5873
6204
|
: [messageToStoreRef.current.appendedData];
|
|
5874
|
-
|
|
5875
|
-
|
|
6205
|
+
messageToStoreRef.current.appendedData = [
|
|
6206
|
+
...previousWidgetData,
|
|
6207
|
+
...finalWidgetData,
|
|
6208
|
+
];
|
|
5876
6209
|
messageToStoreRef.current.sessionId = parsedData.session_id;
|
|
5877
6210
|
messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
|
|
5878
6211
|
? parsedData.chat_id
|
|
@@ -5912,8 +6245,10 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5912
6245
|
let previousWidgetData = isArray$1(messageToStoreRef.current.appendedData)
|
|
5913
6246
|
? messageToStoreRef.current.appendedData
|
|
5914
6247
|
: [messageToStoreRef.current.appendedData];
|
|
5915
|
-
|
|
5916
|
-
|
|
6248
|
+
messageToStoreRef.current.appendedData = [
|
|
6249
|
+
...previousWidgetData,
|
|
6250
|
+
...finalWidgetData,
|
|
6251
|
+
];
|
|
5917
6252
|
messageToStoreRef.current.additionalArgs = parsedData?.additional_args
|
|
5918
6253
|
? parsedData.additional_args
|
|
5919
6254
|
: {};
|
|
@@ -5959,7 +6294,7 @@ const AxiosSource = (url, opts, messageToStoreRef) => {
|
|
|
5959
6294
|
let lastProcessedLength = 0;
|
|
5960
6295
|
// Carry-over for partial SSE frames between progress events
|
|
5961
6296
|
let carryOver = "";
|
|
5962
|
-
|
|
6297
|
+
httpRequest({
|
|
5963
6298
|
method: opts.method || "GET",
|
|
5964
6299
|
url: url,
|
|
5965
6300
|
headers: opts.headers,
|
|
@@ -6176,6 +6511,7 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
6176
6511
|
messageStoreRef.current.initValue = false;
|
|
6177
6512
|
stepFormStreamControl.initValue = false;
|
|
6178
6513
|
}
|
|
6514
|
+
const { BASE_API } = getApiConstants();
|
|
6179
6515
|
const endPoint = baseUrl
|
|
6180
6516
|
? `${BASE_API}${baseUrl}/chatbot/agent/init`
|
|
6181
6517
|
: `${BASE_API}/core/chatbot/agent/init`;
|
|
@@ -6451,6 +6787,794 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
|
|
|
6451
6787
|
return (jsxs("div", { className: classes.buttonContainer, children: [bodyText.message && (jsx("div", { className: classes.message, children: bodyText.message })), jsx("div", { className: classes.buttonRow, children: renderButtons() })] }));
|
|
6452
6788
|
};
|
|
6453
6789
|
|
|
6790
|
+
// AG Grid Enterprise License Key
|
|
6791
|
+
const AG_GRID_V36_LICENCE_KEY = "Using_this_{AG_Grid}_Enterprise_key_{AG-082017}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Impact_Analytics}_is_granted_a_{Multiple_Applications}_Developer_License_for_{1}_Front-End_JavaScript_developer___All_Front-End_JavaScript_developers_need_to_be_licensed_in_addition_to_the_ones_working_with_{AG_Grid}_Enterprise___This_key_has_not_been_granted_a_Deployment_License_Add-on___This_key_works_with_{AG_Grid}_Enterprise_versions_released_before_{28_February_2027}____[v3]_[01]_MTgwMzc3MjgwMDAwMA==d3fb103fa88b52d1f7ad90bf7e94f9a5";
|
|
6792
|
+
// Default decimal rounding
|
|
6793
|
+
const DEFAULT_ROUNDOFF = 2;
|
|
6794
|
+
// Column types that should not be rounded
|
|
6795
|
+
const IGNORE_ROUNDOFF = ["int"];
|
|
6796
|
+
|
|
6797
|
+
const modules = [
|
|
6798
|
+
AllEnterpriseModule,
|
|
6799
|
+
ClientSideRowModelModule,
|
|
6800
|
+
ServerSideRowModelModule,
|
|
6801
|
+
ValidationModule,
|
|
6802
|
+
];
|
|
6803
|
+
// ─── Local State ────────────────────────────────────────────────────────────
|
|
6804
|
+
const ACTIONS = {
|
|
6805
|
+
SET_AGGRID_STATE: "SET_AGGRID_STATE",
|
|
6806
|
+
SET_CLIENT_SIDE_TABLE_DATA: "SET_CLIENT_SIDE_TABLE_DATA",
|
|
6807
|
+
SET_PAGINATION_ENABLED: "SET_PAGINATION_ENABLED",
|
|
6808
|
+
};
|
|
6809
|
+
const initialState = {
|
|
6810
|
+
agGrid: {},
|
|
6811
|
+
clientSideTableData: [],
|
|
6812
|
+
paginationEnabled: true,
|
|
6813
|
+
};
|
|
6814
|
+
const agGridReducer = (state, action) => {
|
|
6815
|
+
switch (action.type) {
|
|
6816
|
+
case ACTIONS.SET_AGGRID_STATE:
|
|
6817
|
+
return { ...state, agGrid: action.payload };
|
|
6818
|
+
case ACTIONS.SET_CLIENT_SIDE_TABLE_DATA:
|
|
6819
|
+
return { ...state, clientSideTableData: action.payload };
|
|
6820
|
+
case ACTIONS.SET_PAGINATION_ENABLED:
|
|
6821
|
+
return { ...state, paginationEnabled: action.payload };
|
|
6822
|
+
default:
|
|
6823
|
+
return state;
|
|
6824
|
+
}
|
|
6825
|
+
};
|
|
6826
|
+
// ─── Server-Side Datasource ─────────────────────────────────────────────────
|
|
6827
|
+
const createServerSideDatasource = (config) => ({
|
|
6828
|
+
getRows: async (params) => {
|
|
6829
|
+
const { cacheBlockSize, manualCallBackRef } = config;
|
|
6830
|
+
try {
|
|
6831
|
+
const { startRow, sortModel, filterModel } = params.request;
|
|
6832
|
+
const page = Math.floor(startRow / cacheBlockSize);
|
|
6833
|
+
// Build a simple meta payload with sort and search info
|
|
6834
|
+
const meta = { search: [], range: [], sort: [] };
|
|
6835
|
+
if (sortModel?.length) {
|
|
6836
|
+
meta.sort = sortModel.map((s) => ({
|
|
6837
|
+
column: s.colId,
|
|
6838
|
+
order: s.sort,
|
|
6839
|
+
}));
|
|
6840
|
+
}
|
|
6841
|
+
const manualCallBack = manualCallBackRef.current;
|
|
6842
|
+
if (!manualCallBack) {
|
|
6843
|
+
params.fail();
|
|
6844
|
+
return;
|
|
6845
|
+
}
|
|
6846
|
+
const paginatedRows = await manualCallBack(meta, page, params);
|
|
6847
|
+
if (!paginatedRows?.data?.length) {
|
|
6848
|
+
if (params.request.startRow === 0) {
|
|
6849
|
+
params.api.showNoRowsOverlay();
|
|
6850
|
+
}
|
|
6851
|
+
params.success({ rowData: [], rowCount: startRow });
|
|
6852
|
+
return;
|
|
6853
|
+
}
|
|
6854
|
+
params.api.hideOverlay();
|
|
6855
|
+
const rowCount = paginatedRows.data.length < cacheBlockSize
|
|
6856
|
+
? startRow + paginatedRows.data.length
|
|
6857
|
+
: paginatedRows.totalCount;
|
|
6858
|
+
params.success({ rowData: paginatedRows.data, rowCount });
|
|
6859
|
+
}
|
|
6860
|
+
catch (error) {
|
|
6861
|
+
console.error("Server-side datasource error:", error);
|
|
6862
|
+
params.fail();
|
|
6863
|
+
}
|
|
6864
|
+
},
|
|
6865
|
+
});
|
|
6866
|
+
// ─── Component ──────────────────────────────────────────────────────────────
|
|
6867
|
+
const AgGridComponent = (props) => {
|
|
6868
|
+
const {
|
|
6869
|
+
// Data
|
|
6870
|
+
rowModelType = "clientSide", cacheBlockSize, serverSideStoreType,
|
|
6871
|
+
// Selection
|
|
6872
|
+
onSelectionChanged,
|
|
6873
|
+
// ─── Impact UI / Custom Props ───
|
|
6874
|
+
customClass = "",
|
|
6875
|
+
// Callbacks
|
|
6876
|
+
selectAllHeaderComponent, uniqueRowId, manualCallBack,
|
|
6877
|
+
// Sizing
|
|
6878
|
+
sizeColumnsToFitFlag = false, } = props;
|
|
6879
|
+
const [localState, localDispatch] = useReducer(agGridReducer, initialState);
|
|
6880
|
+
const manualCallBackRef = useRef(manualCallBack);
|
|
6881
|
+
manualCallBackRef.current = manualCallBack;
|
|
6882
|
+
const setPaginationEnabled = useCallback((shouldEnable) => localDispatch({
|
|
6883
|
+
type: ACTIONS.SET_PAGINATION_ENABLED,
|
|
6884
|
+
payload: shouldEnable,
|
|
6885
|
+
}), []);
|
|
6886
|
+
// Default column definition
|
|
6887
|
+
const defaultColDef = useMemo(() => ({
|
|
6888
|
+
resizable: true,
|
|
6889
|
+
sortable: false,
|
|
6890
|
+
minWidth: 150,
|
|
6891
|
+
wrapText: false,
|
|
6892
|
+
autoHeight: false,
|
|
6893
|
+
}), []);
|
|
6894
|
+
// Grid options for row selection
|
|
6895
|
+
const gridOptions = useMemo(() => {
|
|
6896
|
+
const opts = {};
|
|
6897
|
+
if (selectAllHeaderComponent) {
|
|
6898
|
+
opts.rowSelection = {
|
|
6899
|
+
mode: "multiRow",
|
|
6900
|
+
groupSelects: "self",
|
|
6901
|
+
checkboxes: true,
|
|
6902
|
+
};
|
|
6903
|
+
opts.selectionColumnDef = {
|
|
6904
|
+
pinned: "left",
|
|
6905
|
+
suppressSizeToFit: true,
|
|
6906
|
+
lockPosition: "left",
|
|
6907
|
+
suppressHeaderMenuButton: true,
|
|
6908
|
+
minWidth: 56,
|
|
6909
|
+
maxWidth: 56,
|
|
6910
|
+
cellStyle: { display: "flex" },
|
|
6911
|
+
headerClass: "ag-selection-column-header",
|
|
6912
|
+
};
|
|
6913
|
+
}
|
|
6914
|
+
// When no selectAllHeaderComponent, don't set rowSelection at all
|
|
6915
|
+
// — AG Grid will default to no selection column
|
|
6916
|
+
return opts;
|
|
6917
|
+
}, [selectAllHeaderComponent]);
|
|
6918
|
+
// Server-side datasource
|
|
6919
|
+
const datasource = useMemo(() => {
|
|
6920
|
+
if (!rowModelType || rowModelType === "clientSide")
|
|
6921
|
+
return undefined;
|
|
6922
|
+
if (rowModelType === "serverSide") {
|
|
6923
|
+
return createServerSideDatasource({
|
|
6924
|
+
cacheBlockSize: cacheBlockSize || 100,
|
|
6925
|
+
manualCallBackRef,
|
|
6926
|
+
});
|
|
6927
|
+
}
|
|
6928
|
+
return undefined;
|
|
6929
|
+
}, [rowModelType, cacheBlockSize]);
|
|
6930
|
+
// Process columns
|
|
6931
|
+
const processedColumns = useMemo(() => {
|
|
6932
|
+
try {
|
|
6933
|
+
if (isEmpty$1(props.columns))
|
|
6934
|
+
return [];
|
|
6935
|
+
return cloneDeep(props.columns);
|
|
6936
|
+
}
|
|
6937
|
+
catch (error) {
|
|
6938
|
+
console.error("Error processing columns:", error);
|
|
6939
|
+
return [];
|
|
6940
|
+
}
|
|
6941
|
+
}, [props.columns]);
|
|
6942
|
+
// Update client-side data when rowdata changes
|
|
6943
|
+
useEffect(() => {
|
|
6944
|
+
if (isEmpty$1(props.rowdata) && isEmpty$1(localState?.clientSideTableData))
|
|
6945
|
+
return;
|
|
6946
|
+
localDispatch({
|
|
6947
|
+
type: ACTIONS.SET_CLIENT_SIDE_TABLE_DATA,
|
|
6948
|
+
payload: props.rowdata ?? [],
|
|
6949
|
+
});
|
|
6950
|
+
if (props?.pagination === true) {
|
|
6951
|
+
const pageSize = props?.paginationPageSize || 10;
|
|
6952
|
+
const shouldEnable = (props.rowdata?.length || 0) > pageSize;
|
|
6953
|
+
if (shouldEnable !== localState.paginationEnabled) {
|
|
6954
|
+
setPaginationEnabled(shouldEnable);
|
|
6955
|
+
}
|
|
6956
|
+
}
|
|
6957
|
+
}, [props.rowdata]);
|
|
6958
|
+
// Export to Excel handler
|
|
6959
|
+
const handleExportToExcel = () => {
|
|
6960
|
+
const api = localState.agGrid?.api;
|
|
6961
|
+
if (!api)
|
|
6962
|
+
return;
|
|
6963
|
+
api.exportDataAsExcel();
|
|
6964
|
+
};
|
|
6965
|
+
// Build customSystemButton with download
|
|
6966
|
+
const resolvedCustomSystemButton = useMemo(() => {
|
|
6967
|
+
// If props.customSystemButton is provided, use it directly
|
|
6968
|
+
// The parent (TableContent) already builds the full JSX
|
|
6969
|
+
return props.customSystemButton || null;
|
|
6970
|
+
}, [props.customSystemButton]);
|
|
6971
|
+
return (jsx(AgGridProvider, { modules: modules, licenseKey: AG_GRID_V36_LICENCE_KEY, children: jsx("div", { className: classNames("core-ag-theme-alpine", customClass), children: jsx(TableV36
|
|
6972
|
+
// AG Grid Props
|
|
6973
|
+
, {
|
|
6974
|
+
// AG Grid Props
|
|
6975
|
+
columnDefs: processedColumns, rowData: !rowModelType || rowModelType === "clientSide"
|
|
6976
|
+
? localState?.clientSideTableData
|
|
6977
|
+
: undefined, serverSideDatasource: rowModelType === "serverSide" ? datasource : null, tableHeader: props?.tableHeader ?? null, pagination: props?.pagination === false ? false : localState.paginationEnabled, domLayout: props?.domLayout ?? "autoHeight", animateRows: false, suppressFieldDotNotation: props?.suppressFieldDotNotation ?? false, paginationPageSizeSelector: props?.paginationPageSize
|
|
6978
|
+
? [props.paginationPageSize]
|
|
6979
|
+
: [10, 20], suppressColumnMoveAnimation: true, onGridReady: (params) => {
|
|
6980
|
+
localDispatch({
|
|
6981
|
+
type: ACTIONS.SET_AGGRID_STATE,
|
|
6982
|
+
payload: params,
|
|
6983
|
+
});
|
|
6984
|
+
}, onFirstDataRendered: (params) => {
|
|
6985
|
+
if (sizeColumnsToFitFlag) {
|
|
6986
|
+
params.api.sizeColumnsToFit();
|
|
6987
|
+
}
|
|
6988
|
+
}, onSelectionChanged: (event) => {
|
|
6989
|
+
if (onSelectionChanged && typeof onSelectionChanged === "function") {
|
|
6990
|
+
onSelectionChanged(event);
|
|
6991
|
+
}
|
|
6992
|
+
}, onGridSizeChanged: (params) => {
|
|
6993
|
+
if (sizeColumnsToFitFlag) {
|
|
6994
|
+
params.api.sizeColumnsToFit();
|
|
6995
|
+
}
|
|
6996
|
+
}, getRowId: uniqueRowId
|
|
6997
|
+
? (params) => String(params.data?.[uniqueRowId] ?? "")
|
|
6998
|
+
: undefined, rowModelType: rowModelType, cacheBlockSize: cacheBlockSize, serverSideStoreType: serverSideStoreType, tooltipShowMode: "whenTruncated", enableBrowserTooltips: false,
|
|
6999
|
+
// Core props
|
|
7000
|
+
defaultColDef: defaultColDef, ...gridOptions,
|
|
7001
|
+
// Impact UI Props
|
|
7002
|
+
hideTableSetting: props?.hideTableSetting ?? false, topRightOptions: props?.topRightOptions ?? null, customSystemButton: resolvedCustomSystemButton, hideTableActions: props?.hideTableActions ?? false, isSaveViewEnabled: props?.isSaveViewEnabled ?? false, hidePaginationPageSizeSelector: true, hideRowHeightOptionMenu: true, enableHeaderTextWrap: true, hideTableFormat: true, hideMarginBottom: true, cardContainer: true, showDownloadButton: props?.downloadAsExcel && !props?.customSystemButton, onDownloadButtonClick: handleExportToExcel }) }) }));
|
|
7003
|
+
};
|
|
7004
|
+
|
|
7005
|
+
// ─── Number Formatter Cache ─────────────────────────────────────────────────
|
|
7006
|
+
const formatCache = new Map();
|
|
7007
|
+
const getNumberFormatter = (minimumFractionDigits = DEFAULT_ROUNDOFF, maximumFractionDigits = DEFAULT_ROUNDOFF, p_instance) => {
|
|
7008
|
+
if (IGNORE_ROUNDOFF?.includes(p_instance?.colDef?.type)) {
|
|
7009
|
+
return new Intl.NumberFormat("en-US");
|
|
7010
|
+
}
|
|
7011
|
+
const cacheKey = `${minimumFractionDigits}-${maximumFractionDigits}`;
|
|
7012
|
+
if (!formatCache.has(cacheKey)) {
|
|
7013
|
+
formatCache.set(cacheKey, new Intl.NumberFormat("en-US", {
|
|
7014
|
+
minimumFractionDigits,
|
|
7015
|
+
maximumFractionDigits,
|
|
7016
|
+
}));
|
|
7017
|
+
}
|
|
7018
|
+
return formatCache.get(cacheKey);
|
|
7019
|
+
};
|
|
7020
|
+
// ─── Formatting Functions ───────────────────────────────────────────────────
|
|
7021
|
+
const numbersWithComma = (value, roundOffTo, disableCommaFormatting = false, displayBlank = false) => {
|
|
7022
|
+
const nf = getNumberFormatter(roundOffTo, roundOffTo, value);
|
|
7023
|
+
if (value?.value === "-" || value?.value === null) {
|
|
7024
|
+
if (displayBlank)
|
|
7025
|
+
return "";
|
|
7026
|
+
else
|
|
7027
|
+
return "-";
|
|
7028
|
+
}
|
|
7029
|
+
else if (disableCommaFormatting) {
|
|
7030
|
+
return value?.value || "";
|
|
7031
|
+
}
|
|
7032
|
+
else if (value?.value) {
|
|
7033
|
+
if (Number.isInteger(value?.value)) {
|
|
7034
|
+
let tempValue = parseInt(value?.value) > -1 ? Math.abs(value?.value) : value?.value;
|
|
7035
|
+
return nf.format(tempValue);
|
|
7036
|
+
}
|
|
7037
|
+
else {
|
|
7038
|
+
let replaceCommaValue = (value?.value).toString().replace(",", "");
|
|
7039
|
+
let tempValue = parseFloat(replaceCommaValue) > -1
|
|
7040
|
+
? Math.abs(replaceCommaValue)
|
|
7041
|
+
: replaceCommaValue;
|
|
7042
|
+
if (roundOffTo > 0) {
|
|
7043
|
+
return nf.format(Number.parseFloat(tempValue).toFixed(roundOffTo));
|
|
7044
|
+
}
|
|
7045
|
+
else {
|
|
7046
|
+
return nf.format(Math.round(tempValue));
|
|
7047
|
+
}
|
|
7048
|
+
}
|
|
7049
|
+
}
|
|
7050
|
+
else if (value?.value === 0) {
|
|
7051
|
+
return nf.format(value?.value);
|
|
7052
|
+
}
|
|
7053
|
+
else {
|
|
7054
|
+
return value?.value || "";
|
|
7055
|
+
}
|
|
7056
|
+
};
|
|
7057
|
+
const percentFormatter = function (value, roundOffTo, dontMultiply, displayBlank = false) {
|
|
7058
|
+
if (value && value.value && !isNaN(Number(value.value))) {
|
|
7059
|
+
let cellData;
|
|
7060
|
+
let multiplier = dontMultiply ? 1 : 100;
|
|
7061
|
+
if (typeof value.value == Number || !isNaN(Number(value.value))) {
|
|
7062
|
+
cellData = value.value;
|
|
7063
|
+
let newVal = (cellData * multiplier).toFixed(roundOffTo);
|
|
7064
|
+
if (Math.abs(Number(newVal)) === 0) {
|
|
7065
|
+
newVal = 0?.toFixed(roundOffTo);
|
|
7066
|
+
}
|
|
7067
|
+
return newVal + "%";
|
|
7068
|
+
}
|
|
7069
|
+
else {
|
|
7070
|
+
return value.value;
|
|
7071
|
+
}
|
|
7072
|
+
}
|
|
7073
|
+
else if (value.value === 0) {
|
|
7074
|
+
return value.value?.toFixed(roundOffTo) + "%";
|
|
7075
|
+
}
|
|
7076
|
+
else if (displayBlank && (value.value === null || isNaN(value.value))) {
|
|
7077
|
+
return "";
|
|
7078
|
+
}
|
|
7079
|
+
else {
|
|
7080
|
+
return "-";
|
|
7081
|
+
}
|
|
7082
|
+
};
|
|
7083
|
+
const decimalsFormatter = function (x, toFix, shouldRoundOff, displayBlank = false) {
|
|
7084
|
+
const nf = getNumberFormatter(toFix, toFix, x);
|
|
7085
|
+
if (displayBlank && (x.value === null || isNaN(x.value))) {
|
|
7086
|
+
return "";
|
|
7087
|
+
}
|
|
7088
|
+
if (x?.colDef?.extra?.displayActualValue) {
|
|
7089
|
+
return x.value;
|
|
7090
|
+
}
|
|
7091
|
+
if (toFix === 3) {
|
|
7092
|
+
if (x.value === null || isNaN(x.value))
|
|
7093
|
+
return "-";
|
|
7094
|
+
else
|
|
7095
|
+
return parseFloat(x.value).toFixed(3);
|
|
7096
|
+
}
|
|
7097
|
+
if (x.value === 0) {
|
|
7098
|
+
return nf.format(0);
|
|
7099
|
+
}
|
|
7100
|
+
else if (x.value > 0) {
|
|
7101
|
+
if (toFix === 0) {
|
|
7102
|
+
return Math.round(x.value);
|
|
7103
|
+
}
|
|
7104
|
+
let roundOffTo = x?.colDef?.extra?.hasOwnProperty("roundOffTo")
|
|
7105
|
+
? x?.colDef?.extra?.roundOffTo
|
|
7106
|
+
: toFix
|
|
7107
|
+
? toFix
|
|
7108
|
+
: 2;
|
|
7109
|
+
if (x?.colDef?.extra?.doNotRoundOff)
|
|
7110
|
+
return parseFloat(x.value).toFixed(roundOffTo);
|
|
7111
|
+
else {
|
|
7112
|
+
let roundOffNumber = +("1" + "0".repeat(roundOffTo));
|
|
7113
|
+
let multipliedValue = x.value * roundOffNumber;
|
|
7114
|
+
let res = multipliedValue < 1 && multipliedValue > 0
|
|
7115
|
+
? parseFloat(multipliedValue.toFixed(roundOffTo))
|
|
7116
|
+
: Math.round(multipliedValue) / roundOffNumber;
|
|
7117
|
+
return shouldRoundOff ? nf.format(res) : res;
|
|
7118
|
+
}
|
|
7119
|
+
}
|
|
7120
|
+
else {
|
|
7121
|
+
if (!x?.value || isNaN(Number(x?.value))) {
|
|
7122
|
+
if (x?.node?.group) {
|
|
7123
|
+
return "";
|
|
7124
|
+
}
|
|
7125
|
+
return "-";
|
|
7126
|
+
}
|
|
7127
|
+
if (toFix === 0 && x.value < 0) {
|
|
7128
|
+
return Math.round(x.value);
|
|
7129
|
+
}
|
|
7130
|
+
if (toFix > 0 &&
|
|
7131
|
+
x.value < 0 &&
|
|
7132
|
+
(x.is_negative_value_allowed || !x.is_negative_value_allowed)) {
|
|
7133
|
+
return shouldRoundOff
|
|
7134
|
+
? nf.format(parseFloat((Math.round(x.value * 100) / 100).toFixed(toFix)))
|
|
7135
|
+
: parseFloat((Math.round(x.value * 100) / 100).toFixed(toFix));
|
|
7136
|
+
}
|
|
7137
|
+
return shouldRoundOff
|
|
7138
|
+
? nf.format(parseFloat(x.value))
|
|
7139
|
+
: parseFloat(x.value);
|
|
7140
|
+
}
|
|
7141
|
+
};
|
|
7142
|
+
const currencyFormatter = function (value, roundOffTo, symbol) {
|
|
7143
|
+
const nf = getNumberFormatter(roundOffTo, roundOffTo, value);
|
|
7144
|
+
if (!value.value && value.value !== 0) {
|
|
7145
|
+
return value.value || "";
|
|
7146
|
+
}
|
|
7147
|
+
if (typeof value.value == Number || !isNaN(Number(value.value))) {
|
|
7148
|
+
let valsfor;
|
|
7149
|
+
const cellData = value.value;
|
|
7150
|
+
const toVal = Math.abs(value.value);
|
|
7151
|
+
if (toVal < 1 && toVal > -1) {
|
|
7152
|
+
valsfor = toVal.toFixed(roundOffTo);
|
|
7153
|
+
}
|
|
7154
|
+
else {
|
|
7155
|
+
valsfor = roundOffTo ? toVal : Math.round(toVal);
|
|
7156
|
+
}
|
|
7157
|
+
let newvalsfor = nf.format(Math.abs(Number(valsfor)).toFixed(roundOffTo));
|
|
7158
|
+
if (cellData >= 0) {
|
|
7159
|
+
return `${symbol}` + newvalsfor;
|
|
7160
|
+
}
|
|
7161
|
+
else {
|
|
7162
|
+
return `-${symbol}` + newvalsfor;
|
|
7163
|
+
}
|
|
7164
|
+
}
|
|
7165
|
+
else {
|
|
7166
|
+
return value?.value
|
|
7167
|
+
? value?.value
|
|
7168
|
+
: value?.cell?.row?.subRows?.length > 0
|
|
7169
|
+
? ""
|
|
7170
|
+
: "-";
|
|
7171
|
+
}
|
|
7172
|
+
};
|
|
7173
|
+
// Date format constants used by formattedDate
|
|
7174
|
+
const DATE_FORMATS = [
|
|
7175
|
+
"YYYY-MM-DD",
|
|
7176
|
+
"YYYY-MM-DDTHH:mm:ss",
|
|
7177
|
+
"YYYY-MM-DDTHH:mm:ssZ",
|
|
7178
|
+
"YYYY-MM-DDTHH:mm:ss.SSSZ",
|
|
7179
|
+
"MM/DD/YYYY",
|
|
7180
|
+
"DD/MM/YYYY",
|
|
7181
|
+
"MM-DD-YYYY",
|
|
7182
|
+
"DD-MM-YYYY",
|
|
7183
|
+
"YYYY/MM/DD",
|
|
7184
|
+
moment.ISO_8601,
|
|
7185
|
+
];
|
|
7186
|
+
const formattedDate = (date, format, currentDateFormat) => {
|
|
7187
|
+
const updatedCurrentFormat = date && moment(date, DATE_FORMATS);
|
|
7188
|
+
return date && updatedCurrentFormat.isValid()
|
|
7189
|
+
? moment(date, currentDateFormat ? currentDateFormat : updatedCurrentFormat._f).format(format)
|
|
7190
|
+
: "-";
|
|
7191
|
+
};
|
|
7192
|
+
const arrayToCommaFormatter = (value) => {
|
|
7193
|
+
if (value) {
|
|
7194
|
+
return isArray$1(value) && value?.length ? value?.join(", ") : value;
|
|
7195
|
+
}
|
|
7196
|
+
return "";
|
|
7197
|
+
};
|
|
7198
|
+
// ─── Non-Editable Cell Value Formatter ──────────────────────────────────────
|
|
7199
|
+
const DEFAULT_DATE_FORMAT$1 = "MM/DD/YYYY";
|
|
7200
|
+
const getDateFormat = (column) => {
|
|
7201
|
+
if (column?.dateFormatter)
|
|
7202
|
+
return column.dateFormatter;
|
|
7203
|
+
if (column?.formatter)
|
|
7204
|
+
return column.formatter;
|
|
7205
|
+
const tenantDateFormat = typeof localStorage !== "undefined"
|
|
7206
|
+
? localStorage.getItem("tenantDateFormat")
|
|
7207
|
+
: null;
|
|
7208
|
+
return tenantDateFormat || DEFAULT_DATE_FORMAT$1;
|
|
7209
|
+
};
|
|
7210
|
+
const replaceSpecialCharacter$1 = (str) => {
|
|
7211
|
+
if (!str)
|
|
7212
|
+
return str;
|
|
7213
|
+
return String(str)
|
|
7214
|
+
.replace(/__ia_char_38__/g, "&")
|
|
7215
|
+
.replace(/__ia_char_60__/g, "<")
|
|
7216
|
+
.replace(/__ia_char_62__/g, ">")
|
|
7217
|
+
.replace(/__ia_char_34__/g, '"')
|
|
7218
|
+
.replace(/__ia_char_39__/g, "'")
|
|
7219
|
+
.replace(/__ia_char_96__/g, "`");
|
|
7220
|
+
};
|
|
7221
|
+
const fetchDefaultValue = (ins) => {
|
|
7222
|
+
if (isNil(ins?.value))
|
|
7223
|
+
return "";
|
|
7224
|
+
if (Array.isArray(ins.value))
|
|
7225
|
+
return ins.value
|
|
7226
|
+
.map((item) => !isNil(item) ? replaceSpecialCharacter$1(item.toString()) : "")
|
|
7227
|
+
.toString();
|
|
7228
|
+
else if (typeof ins.value === "boolean")
|
|
7229
|
+
return ins.value.toString();
|
|
7230
|
+
else
|
|
7231
|
+
return ins.value;
|
|
7232
|
+
};
|
|
7233
|
+
const getRoundOff$1 = (formatter) => {
|
|
7234
|
+
const map = {
|
|
7235
|
+
roundOff: 0,
|
|
7236
|
+
roundOfftoOneDecimals: 1,
|
|
7237
|
+
roundOfftoTwoDecimals: 2,
|
|
7238
|
+
roundOfftoThreeDecimals: 3,
|
|
7239
|
+
};
|
|
7240
|
+
return map[formatter] ?? DEFAULT_ROUNDOFF;
|
|
7241
|
+
};
|
|
7242
|
+
/**
|
|
7243
|
+
* Returns a valueFormatter function for non-editable cells based on column type.
|
|
7244
|
+
* This is the simplified version that handles display-only columns.
|
|
7245
|
+
*/
|
|
7246
|
+
const nonEditableCellValueFormatter = (item, forFooter, shouldRoundOff) => {
|
|
7247
|
+
const roundOffTo = getRoundOff$1(item.formatter);
|
|
7248
|
+
switch (item.type) {
|
|
7249
|
+
case "percentage":
|
|
7250
|
+
return (ins) => percentFormatter(ins, roundOffTo, (forFooter && item.is_editable) ||
|
|
7251
|
+
item?.multiplier ||
|
|
7252
|
+
item?.extra?.multiplier
|
|
7253
|
+
? true
|
|
7254
|
+
: false, item?.extra?.displayBlank);
|
|
7255
|
+
case "int":
|
|
7256
|
+
return (ins) => numbersWithComma(ins, roundOffTo, item?.extra?.disableCommaFormatting, item?.extra?.displayBlank);
|
|
7257
|
+
case "float":
|
|
7258
|
+
return (ins) => decimalsFormatter(ins, roundOffTo, shouldRoundOff, item?.extra?.displayBlank);
|
|
7259
|
+
case "dollar":
|
|
7260
|
+
return (ins) => currencyFormatter(ins, roundOffTo, "$");
|
|
7261
|
+
case "euro":
|
|
7262
|
+
return (ins) => currencyFormatter(ins, roundOffTo, "€");
|
|
7263
|
+
case "bool":
|
|
7264
|
+
return (ins) => ins?.value || "";
|
|
7265
|
+
case "array":
|
|
7266
|
+
return (ins) => arrayToCommaFormatter(ins.value);
|
|
7267
|
+
case "percent_range":
|
|
7268
|
+
return (ins) => (ins?.value ? `${ins.value} %` : "");
|
|
7269
|
+
case "formatted_number":
|
|
7270
|
+
return (ins) => Number(ins?.value)?.toFixed(2) || "";
|
|
7271
|
+
case "date":
|
|
7272
|
+
case "datetime":
|
|
7273
|
+
case "dateStr":
|
|
7274
|
+
case "DateTimeField":
|
|
7275
|
+
return (ins) => {
|
|
7276
|
+
if (item?.extra?.displayBlank && ins?.value === null) {
|
|
7277
|
+
return "";
|
|
7278
|
+
}
|
|
7279
|
+
else {
|
|
7280
|
+
return formattedDate(ins?.value, getDateFormat(item));
|
|
7281
|
+
}
|
|
7282
|
+
};
|
|
7283
|
+
case "list":
|
|
7284
|
+
case "dynamic-list":
|
|
7285
|
+
return (ins) => {
|
|
7286
|
+
const listValue = ins?.value;
|
|
7287
|
+
const toDisplay = (v) => {
|
|
7288
|
+
if (isNil(v))
|
|
7289
|
+
return "";
|
|
7290
|
+
const raw = isObject(v) ? v?.value : v;
|
|
7291
|
+
return replaceSpecialCharacter$1(String(raw));
|
|
7292
|
+
};
|
|
7293
|
+
if (Array.isArray(listValue))
|
|
7294
|
+
return listValue.map(toDisplay).filter(Boolean).join(", ");
|
|
7295
|
+
if (isObject(listValue))
|
|
7296
|
+
return toDisplay(listValue);
|
|
7297
|
+
return fetchDefaultValue(ins);
|
|
7298
|
+
};
|
|
7299
|
+
default:
|
|
7300
|
+
return (ins) => {
|
|
7301
|
+
if (item.formatter && item.formatter === "numbersWithComma") {
|
|
7302
|
+
return numbersWithComma(ins, roundOffTo);
|
|
7303
|
+
}
|
|
7304
|
+
else if (ins.value === 0 || ins.value === false || ins.value) {
|
|
7305
|
+
return fetchDefaultValue(ins);
|
|
7306
|
+
}
|
|
7307
|
+
return "";
|
|
7308
|
+
};
|
|
7309
|
+
}
|
|
7310
|
+
};
|
|
7311
|
+
|
|
7312
|
+
// ─── Constants ──────────────────────────────────────────────────────────────
|
|
7313
|
+
const NUMERIC_TYPES = new Set(["int", "percentage", "float", "dollar", "euro"]);
|
|
7314
|
+
// Plain text types that use valueFormatter instead of cellRenderer
|
|
7315
|
+
const PLAIN_TEXT_TYPES = new Set([
|
|
7316
|
+
"percentage",
|
|
7317
|
+
"int",
|
|
7318
|
+
"float",
|
|
7319
|
+
"dollar",
|
|
7320
|
+
"euro",
|
|
7321
|
+
"bool",
|
|
7322
|
+
"date",
|
|
7323
|
+
"datetime",
|
|
7324
|
+
"dateStr",
|
|
7325
|
+
"DateTimeField",
|
|
7326
|
+
"list",
|
|
7327
|
+
"dynamic-list",
|
|
7328
|
+
"str",
|
|
7329
|
+
"link",
|
|
7330
|
+
"percent_range",
|
|
7331
|
+
"formatted_number",
|
|
7332
|
+
]);
|
|
7333
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
7334
|
+
const replaceSpecialCharacter = (str) => {
|
|
7335
|
+
if (!str)
|
|
7336
|
+
return str;
|
|
7337
|
+
return String(str)
|
|
7338
|
+
.replace(/__ia_char_38__/g, "&")
|
|
7339
|
+
.replace(/__ia_char_60__/g, "<")
|
|
7340
|
+
.replace(/__ia_char_62__/g, ">")
|
|
7341
|
+
.replace(/__ia_char_34__/g, '"')
|
|
7342
|
+
.replace(/__ia_char_39__/g, "'")
|
|
7343
|
+
.replace(/__ia_char_96__/g, "`");
|
|
7344
|
+
};
|
|
7345
|
+
const generateHeader = (item) => {
|
|
7346
|
+
item.label = item.label
|
|
7347
|
+
? replaceSpecialCharacter(item.label.toString())
|
|
7348
|
+
: item.label;
|
|
7349
|
+
return item.label;
|
|
7350
|
+
};
|
|
7351
|
+
const getNestedTableData = (data, columnName, label) => {
|
|
7352
|
+
if (!data)
|
|
7353
|
+
return "";
|
|
7354
|
+
// Handle dot-separated paths
|
|
7355
|
+
if (columnName && columnName.includes(".")) {
|
|
7356
|
+
const parts = columnName.split(".");
|
|
7357
|
+
let value = data;
|
|
7358
|
+
for (const part of parts) {
|
|
7359
|
+
if (value == null)
|
|
7360
|
+
return "";
|
|
7361
|
+
value = value[part];
|
|
7362
|
+
}
|
|
7363
|
+
return value;
|
|
7364
|
+
}
|
|
7365
|
+
return data[columnName];
|
|
7366
|
+
};
|
|
7367
|
+
const getRoundOff = (formatter) => {
|
|
7368
|
+
const map = {
|
|
7369
|
+
roundOff: 0,
|
|
7370
|
+
roundOfftoOneDecimals: 1,
|
|
7371
|
+
roundOfftoTwoDecimals: 2,
|
|
7372
|
+
roundOfftoThreeDecimals: 3,
|
|
7373
|
+
};
|
|
7374
|
+
return map[formatter] ?? DEFAULT_ROUNDOFF;
|
|
7375
|
+
};
|
|
7376
|
+
const formatDecimalNumber = (value, roundOffTo) => {
|
|
7377
|
+
if (value === "" || value === null || value === undefined)
|
|
7378
|
+
return "";
|
|
7379
|
+
const num = Number(value);
|
|
7380
|
+
if (isNaN(num))
|
|
7381
|
+
return value;
|
|
7382
|
+
return roundOffTo === 0 ? Math.round(num) : num.toFixed(roundOffTo);
|
|
7383
|
+
};
|
|
7384
|
+
// ─── Base Props ─────────────────────────────────────────────────────────────
|
|
7385
|
+
const applyBaseProps = (item) => {
|
|
7386
|
+
if (!item.originalLabel)
|
|
7387
|
+
item.originalLabel = item.label;
|
|
7388
|
+
Object.assign(item, {
|
|
7389
|
+
headerClass: item?.label?.split(" ").join("_"),
|
|
7390
|
+
field: item.column_name,
|
|
7391
|
+
accessor: item.column_name,
|
|
7392
|
+
id: item.column_name,
|
|
7393
|
+
sortable: item.is_sortable ?? true,
|
|
7394
|
+
sort: item?.extra?.defaultSortBy,
|
|
7395
|
+
headerName: generateHeader(item),
|
|
7396
|
+
pinned: item?.extra?.pinned || (item.is_frozen ? "left" : null),
|
|
7397
|
+
required: item.is_required,
|
|
7398
|
+
resizable: !item.not_resizable,
|
|
7399
|
+
columnGroupShow: item?.columnGroupShow || item?.extra?.columnGroupShow,
|
|
7400
|
+
floatingFilter: false,
|
|
7401
|
+
filter: false,
|
|
7402
|
+
});
|
|
7403
|
+
if (item?.extra?.width) {
|
|
7404
|
+
item.suppressSizeToFit = true;
|
|
7405
|
+
item.width = item.extra.width;
|
|
7406
|
+
}
|
|
7407
|
+
// Right-align numeric types
|
|
7408
|
+
if (item?.extra?.rightAlign ||
|
|
7409
|
+
["int", "percentage", "float", "dollar", "trend", "euro"]?.includes(item?.type)) {
|
|
7410
|
+
item.cellStyle = { ...item?.cellStyle, textAlign: "right" };
|
|
7411
|
+
item.headerClass = `${item?.headerClass || ""} number-cell`;
|
|
7412
|
+
item.cellClass = `${item?.cellClass || ""} number-cell`;
|
|
7413
|
+
}
|
|
7414
|
+
// Handle sub_headers (grouped columns)
|
|
7415
|
+
if (item.sub_headers?.length) {
|
|
7416
|
+
item.children = item.sub_headers.map((data) => formatColumn(data));
|
|
7417
|
+
}
|
|
7418
|
+
return item;
|
|
7419
|
+
};
|
|
7420
|
+
// ─── Numeric Config ─────────────────────────────────────────────────────────
|
|
7421
|
+
const applyNumericConfig = (item) => {
|
|
7422
|
+
if (!NUMERIC_TYPES.has(item.type))
|
|
7423
|
+
return;
|
|
7424
|
+
item.headerClass = `${item.headerClass} flex-reverse-column`;
|
|
7425
|
+
item.cellClass = `${item.cellClass} flex-reverse-cell`;
|
|
7426
|
+
if (item.extra?.overrideWidth)
|
|
7427
|
+
item.extra = { ...item.extra, width: item.extra.overrideWidth };
|
|
7428
|
+
if (!item?.extra?.ignoreSuppressSizeToFit)
|
|
7429
|
+
item.suppressSizeToFit = true;
|
|
7430
|
+
// Tooltip for numeric columns
|
|
7431
|
+
if (!item.extra?.hideToolTip) {
|
|
7432
|
+
const fixedUpto = item.type === "percentage" ? 4 : 2;
|
|
7433
|
+
item.tooltipField = null;
|
|
7434
|
+
item.tooltipValueGetter = (params) => {
|
|
7435
|
+
if (params.value === "-")
|
|
7436
|
+
return "";
|
|
7437
|
+
if (item.extra?.staticToolTip != null &&
|
|
7438
|
+
item.extra?.hasOwnProperty("staticToolTip")) {
|
|
7439
|
+
if ((item.extra?.showNullAsEmpty && params?.value === null) ||
|
|
7440
|
+
!item.extra?.showNullAsEmpty) {
|
|
7441
|
+
return item.extra.staticToolTip;
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7444
|
+
return !Number.isInteger(Number(params.value))
|
|
7445
|
+
? params.value
|
|
7446
|
+
? Number(params.value).toFixed(fixedUpto)
|
|
7447
|
+
: 0
|
|
7448
|
+
: params.value;
|
|
7449
|
+
};
|
|
7450
|
+
}
|
|
7451
|
+
// Value getters for numeric types
|
|
7452
|
+
if (item.type === "percentage") {
|
|
7453
|
+
item.valueGetter = (params) => params?.data?.[params?.column?.colId] === undefined
|
|
7454
|
+
? ""
|
|
7455
|
+
: params?.data?.[params?.column?.colId];
|
|
7456
|
+
}
|
|
7457
|
+
if (["int", "dollar", "euro"].includes(item.type) &&
|
|
7458
|
+
!item?.extra?.ignoreValueGetter) {
|
|
7459
|
+
item.valueGetter = (params) => {
|
|
7460
|
+
const roundOffTo = getRoundOff(item.formatter);
|
|
7461
|
+
let finalValue = formatDecimalNumber(params.data?.[item.column_name] ?? "", roundOffTo);
|
|
7462
|
+
if (isNaN(parseInt(finalValue)))
|
|
7463
|
+
return item.extra?.isHyphenDisplayedForEmpty ? "-" : "";
|
|
7464
|
+
return item.type === "int" ? parseInt(finalValue) : finalValue;
|
|
7465
|
+
};
|
|
7466
|
+
}
|
|
7467
|
+
if (item.type === "float" && !item?.extra?.ignoreValueGetter) {
|
|
7468
|
+
getRoundOff(item.formatter);
|
|
7469
|
+
item.valueGetter = (params) => {
|
|
7470
|
+
const value = params?.data?.[item.column_name];
|
|
7471
|
+
if (value === "" || value == null)
|
|
7472
|
+
return value;
|
|
7473
|
+
const num = Number(value);
|
|
7474
|
+
return isNaN(num) ? value : num;
|
|
7475
|
+
};
|
|
7476
|
+
}
|
|
7477
|
+
};
|
|
7478
|
+
// ─── Text Config ────────────────────────────────────────────────────────────
|
|
7479
|
+
const applyTextConfig = (item) => {
|
|
7480
|
+
if (item.type !== "str" && item.type !== "link")
|
|
7481
|
+
return;
|
|
7482
|
+
if (!item.is_editable || item.type === "link") {
|
|
7483
|
+
item.valueGetter = (params) => {
|
|
7484
|
+
if (!params?.data)
|
|
7485
|
+
return;
|
|
7486
|
+
let cellValue = getNestedTableData(params.data, item.column_name, item.label) ?? "";
|
|
7487
|
+
let finalValue = cellValue
|
|
7488
|
+
? replaceSpecialCharacter(cellValue.toString())
|
|
7489
|
+
: cellValue;
|
|
7490
|
+
if (finalValue == null || finalValue === "")
|
|
7491
|
+
return item.extra?.isHyphenDisplayedForEmpty ? "-" : "";
|
|
7492
|
+
return finalValue;
|
|
7493
|
+
};
|
|
7494
|
+
}
|
|
7495
|
+
};
|
|
7496
|
+
// ─── Cross-Cutting ──────────────────────────────────────────────────────────
|
|
7497
|
+
const applyCrossCutting = (item) => {
|
|
7498
|
+
// Default tooltip for non-numeric, non-action types
|
|
7499
|
+
if (!NUMERIC_TYPES.has(item.type) && !item.extra?.hideToolTip) {
|
|
7500
|
+
item.tooltipValueGetter = (params) => {
|
|
7501
|
+
if (!params?.value)
|
|
7502
|
+
return;
|
|
7503
|
+
if (Array.isArray(params.value))
|
|
7504
|
+
return params.value.map((o) => o.label || o).join(" | ");
|
|
7505
|
+
const v = typeof params.value === "object" ? params.value.value : params.value;
|
|
7506
|
+
return v ? replaceSpecialCharacter(v.toString()) : v;
|
|
7507
|
+
};
|
|
7508
|
+
}
|
|
7509
|
+
// Default comparator
|
|
7510
|
+
item.comparator = (a, b) => {
|
|
7511
|
+
if (typeof a === "string" && typeof b === "string" && isNaN(+a) && a !== "-" && b !== "-") {
|
|
7512
|
+
return a.localeCompare(b);
|
|
7513
|
+
}
|
|
7514
|
+
if (a == null && b == null)
|
|
7515
|
+
return 0;
|
|
7516
|
+
if (a == null)
|
|
7517
|
+
return -1;
|
|
7518
|
+
if (b == null)
|
|
7519
|
+
return 1;
|
|
7520
|
+
if (a === b)
|
|
7521
|
+
return 0;
|
|
7522
|
+
return a > b ? 1 : -1;
|
|
7523
|
+
};
|
|
7524
|
+
};
|
|
7525
|
+
// ─── Cell Renderer ──────────────────────────────────────────────────────────
|
|
7526
|
+
const applyCellRenderer = (item) => {
|
|
7527
|
+
// Only handle non-editable columns (chatbot tables are display-only)
|
|
7528
|
+
if (PLAIN_TEXT_TYPES.has(item.type)) {
|
|
7529
|
+
const formatter = nonEditableCellValueFormatter(item, null, true);
|
|
7530
|
+
item.valueFormatter = (params) => formatter(params);
|
|
7531
|
+
}
|
|
7532
|
+
else {
|
|
7533
|
+
// For types we don't handle, just display the raw value
|
|
7534
|
+
item.valueFormatter = (params) => {
|
|
7535
|
+
if (params?.value === 0 || params?.value === false || params?.value) {
|
|
7536
|
+
return params.value;
|
|
7537
|
+
}
|
|
7538
|
+
return "";
|
|
7539
|
+
};
|
|
7540
|
+
}
|
|
7541
|
+
};
|
|
7542
|
+
// ─── Pipeline ───────────────────────────────────────────────────────────────
|
|
7543
|
+
const formatColumn = (item) => {
|
|
7544
|
+
applyBaseProps(item);
|
|
7545
|
+
// Type-specific
|
|
7546
|
+
applyNumericConfig(item);
|
|
7547
|
+
applyTextConfig(item);
|
|
7548
|
+
// Cross-cutting
|
|
7549
|
+
applyCrossCutting(item);
|
|
7550
|
+
// Cell renderer (non-editable only)
|
|
7551
|
+
applyCellRenderer(item);
|
|
7552
|
+
return item;
|
|
7553
|
+
};
|
|
7554
|
+
// ─── Entry Point ────────────────────────────────────────────────────────────
|
|
7555
|
+
/**
|
|
7556
|
+
* Simplified column formatter for chatbot tables.
|
|
7557
|
+
* Handles non-editable display-only columns. Does not support editable cells,
|
|
7558
|
+
* advanced search, range filters, or complex cell renderers.
|
|
7559
|
+
*
|
|
7560
|
+
* API-compatible with the core agGridColumnFormatter signature:
|
|
7561
|
+
* agGridColumnFormatter(data, levelsJson, actions, formatSetAllLabel, hideValueGetter, isView)
|
|
7562
|
+
* but ignores all args except `data`.
|
|
7563
|
+
*/
|
|
7564
|
+
function agGridColumnFormatter(data, _levelsJson, _actions, _formatSetAllLabel, _hideValueGetter, _isView) {
|
|
7565
|
+
if (!data)
|
|
7566
|
+
return data;
|
|
7567
|
+
return data.filter((item) => {
|
|
7568
|
+
if (item.special_field)
|
|
7569
|
+
return false;
|
|
7570
|
+
formatColumn(item);
|
|
7571
|
+
if (item?.columns) {
|
|
7572
|
+
item.columns = item.columns.map((innerItem) => formatColumn(innerItem));
|
|
7573
|
+
}
|
|
7574
|
+
return true;
|
|
7575
|
+
});
|
|
7576
|
+
}
|
|
7577
|
+
|
|
6454
7578
|
var _path$k;
|
|
6455
7579
|
function _extends$p() { return _extends$p = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$p.apply(null, arguments); }
|
|
6456
7580
|
var SvgExpand = function SvgExpand(props) {
|
|
@@ -6498,7 +7622,7 @@ const TableContent = ({ bodyText }) => {
|
|
|
6498
7622
|
const dispatch = useDispatch();
|
|
6499
7623
|
useEffect(() => {
|
|
6500
7624
|
let formattedColumns = getFormattedTableConfig(table_config);
|
|
6501
|
-
formattedColumns = agGridColumnFormatter(formattedColumns
|
|
7625
|
+
formattedColumns = agGridColumnFormatter(formattedColumns);
|
|
6502
7626
|
if (isEmpty$1(columns)) {
|
|
6503
7627
|
setColumns(formattedColumns);
|
|
6504
7628
|
}
|
|
@@ -6593,6 +7717,40 @@ const TableContent = ({ bodyText }) => {
|
|
|
6593
7717
|
}) }) })] }));
|
|
6594
7718
|
};
|
|
6595
7719
|
|
|
7720
|
+
// Set default Highcharts options
|
|
7721
|
+
Highcharts.setOptions({
|
|
7722
|
+
lang: {
|
|
7723
|
+
decimalPoint: '.',
|
|
7724
|
+
thousandsSep: ',',
|
|
7725
|
+
},
|
|
7726
|
+
});
|
|
7727
|
+
/**
|
|
7728
|
+
* CoreChart Component
|
|
7729
|
+
* A simple wrapper around the Highcharts React component.
|
|
7730
|
+
* Directly passes the provided options to Highcharts.
|
|
7731
|
+
*
|
|
7732
|
+
* @param {Object} props - Component props
|
|
7733
|
+
* @param {Object} props.options - Highcharts options configuration
|
|
7734
|
+
* @param {Function} [props.handleChartRef] - Optional callback to get a reference to the chart
|
|
7735
|
+
* @param {Object} [props.containerProps] - Optional props for the chart container
|
|
7736
|
+
* @returns {JSX.Element} Rendered chart component
|
|
7737
|
+
*/
|
|
7738
|
+
const CoreChart = (props) => {
|
|
7739
|
+
const { options, handleChartRef, containerProps = {} } = props;
|
|
7740
|
+
const chartRef = useRef(null);
|
|
7741
|
+
useEffect(() => {
|
|
7742
|
+
if (handleChartRef && chartRef && chartRef.current) {
|
|
7743
|
+
handleChartRef(chartRef.current);
|
|
7744
|
+
}
|
|
7745
|
+
}, [chartRef, handleChartRef]);
|
|
7746
|
+
// Create a new options object with credits disabled
|
|
7747
|
+
const chartOptions = {
|
|
7748
|
+
...options,
|
|
7749
|
+
credits: options.credits || { enabled: false }
|
|
7750
|
+
};
|
|
7751
|
+
return (jsx("div", { children: jsx(HighchartsReact, { highcharts: Highcharts, options: chartOptions, ref: chartRef, ...containerProps }) }));
|
|
7752
|
+
};
|
|
7753
|
+
|
|
6596
7754
|
const GraphContent = ({ bodyText }) => {
|
|
6597
7755
|
const { chartOptions, title } = bodyText || {};
|
|
6598
7756
|
const classes = useStyles$b();
|
|
@@ -7390,7 +8548,7 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
|
|
|
7390
8548
|
? primaryValues.map((value) => {
|
|
7391
8549
|
const stringValue = String(value);
|
|
7392
8550
|
return {
|
|
7393
|
-
label: replaceSpecialCharacter(stringValue),
|
|
8551
|
+
label: replaceSpecialCharacter$2(stringValue),
|
|
7394
8552
|
value: stringValue,
|
|
7395
8553
|
};
|
|
7396
8554
|
})
|
|
@@ -7402,7 +8560,7 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
|
|
|
7402
8560
|
extraOptionsMap[key] = responseData[key].map((value) => {
|
|
7403
8561
|
const stringValue = String(value);
|
|
7404
8562
|
return {
|
|
7405
|
-
label: replaceSpecialCharacter(stringValue),
|
|
8563
|
+
label: replaceSpecialCharacter$2(stringValue),
|
|
7406
8564
|
value: stringValue,
|
|
7407
8565
|
};
|
|
7408
8566
|
});
|
|
@@ -7422,7 +8580,7 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
|
|
|
7422
8580
|
primaryOptions = responseData[altKey].map((value) => {
|
|
7423
8581
|
const stringValue = String(value);
|
|
7424
8582
|
return {
|
|
7425
|
-
label: replaceSpecialCharacter(stringValue),
|
|
8583
|
+
label: replaceSpecialCharacter$2(stringValue),
|
|
7426
8584
|
value: stringValue,
|
|
7427
8585
|
};
|
|
7428
8586
|
});
|
|
@@ -7511,7 +8669,7 @@ const LOAD_MORE_COUNT = 100;
|
|
|
7511
8669
|
const SEARCH_DISPLAY_LIMIT = 500;
|
|
7512
8670
|
const formatOption = (option) => ({
|
|
7513
8671
|
...option,
|
|
7514
|
-
label: replaceSpecialCharacter(option.label.toString()),
|
|
8672
|
+
label: replaceSpecialCharacter$2(option.label.toString()),
|
|
7515
8673
|
});
|
|
7516
8674
|
const formatSlice = (options, start, end) => {
|
|
7517
8675
|
return options.slice(start, end).map(formatOption);
|
|
@@ -7997,36 +9155,13 @@ const CheckboxGroupContent = ({ bodyText, isFormDisabled = false, messageIndex }
|
|
|
7997
9155
|
const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
7998
9156
|
const formKey = `${messageIndex}_${bodyText?.paramName}`;
|
|
7999
9157
|
const classes = useStyles$b();
|
|
8000
|
-
const { label, isDisabled, orientation, options
|
|
9158
|
+
const { label, isDisabled, orientation, options } = bodyText;
|
|
8001
9159
|
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
8002
9160
|
const chatbotContextRef = useRef(chatbotContext);
|
|
8003
9161
|
chatbotContextRef.current = chatbotContext;
|
|
8004
9162
|
const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
8005
9163
|
const dispatch = useDispatch();
|
|
8006
|
-
const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ??
|
|
8007
|
-
// When a defaultSelected value is provided and nothing was previously persisted,
|
|
8008
|
-
// seed Redux state so submit-validation and context are aware of the pre-selection.
|
|
8009
|
-
// Uses getState inside a thunk to read the latest chatbotContext at dispatch time,
|
|
8010
|
-
// avoiding stale-ref overwrites when multiple radio widgets mount in the same flush.
|
|
8011
|
-
useEffect(() => {
|
|
8012
|
-
if (defaultSelected && !persistedFormValues[formKey]) {
|
|
8013
|
-
dispatch((dispatchAction, getState) => {
|
|
8014
|
-
const currentContext = getState().smartBotReducer.chatbotContext;
|
|
8015
|
-
dispatchAction({
|
|
8016
|
-
type: "SET_CHATBOT_CONTEXT",
|
|
8017
|
-
payload: {
|
|
8018
|
-
...currentContext,
|
|
8019
|
-
[bodyText?.paramName]: {
|
|
8020
|
-
...currentContext?.[bodyText?.paramName],
|
|
8021
|
-
[bodyText?.paramName]: defaultSelected,
|
|
8022
|
-
updated: true,
|
|
8023
|
-
},
|
|
8024
|
-
},
|
|
8025
|
-
});
|
|
8026
|
-
});
|
|
8027
|
-
dispatch(setPersistedFormValues({ [formKey]: defaultSelected }));
|
|
8028
|
-
}
|
|
8029
|
-
}, []);
|
|
9164
|
+
const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? null);
|
|
8030
9165
|
if (isEmpty$1(bodyText))
|
|
8031
9166
|
return null;
|
|
8032
9167
|
const handleChange = (selectedOption) => {
|
|
@@ -8089,196 +9224,19 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
|
8089
9224
|
};
|
|
8090
9225
|
return (jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsx(Input, { label: label, placeholder: placeholder, value: value, onChange: handleChange, required: isRequired, isDisabled: isDisabled || isFormDisabled, type: inputType || "text", labelOrientation: labelOrientation, maxLength: maxLength, minLength: minLength }) }));
|
|
8091
9226
|
};
|
|
8092
|
-
|
|
8093
|
-
const ImageContent = ({ bodyText }) => {
|
|
8094
|
-
const { gcs_uri, caption } = bodyText || {};
|
|
8095
|
-
return (jsxs("div", { style: {
|
|
8096
|
-
display: "flex",
|
|
8097
|
-
flexDirection: "column",
|
|
8098
|
-
gap: "8px",
|
|
8099
|
-
width: "100%",
|
|
8100
|
-
}, children: [gcs_uri && (jsx("img", { src: gcs_uri, alt: caption || "Image", style: {
|
|
8101
|
-
maxWidth: "100%",
|
|
8102
|
-
borderRadius: "8px",
|
|
8103
|
-
objectFit: "contain",
|
|
8104
|
-
} })), caption && (jsx("div", { children: jsx(TextRenderer, { text: caption }) }))] }));
|
|
8105
|
-
};
|
|
8106
|
-
|
|
8107
|
-
const SUBMIT = { buttons: [{ label: "Submit", variant: "primary" }] };
|
|
8108
|
-
/** A follow-up's limits: longer ones are ignored. */
|
|
8109
|
-
const PROMPT_TEXT_MAX = 1000;
|
|
8110
|
-
const PROMPT_CONTEXT_MAX = 16000;
|
|
8111
|
-
/** The window event the chat listens to for a follow-up asked from a surface. */
|
|
8112
|
-
const PROMPT_EVENT = "iris:prompt";
|
|
8113
|
-
/** The source a surface names for this temp table, if it names it: the only tables its page may ask pages
|
|
8114
|
-
* of, and the endpoint address the agent gave (the page's own copy of the source is not trusted for it). */
|
|
8115
|
-
const sourceOf = (surface, table) => Object.values(surface?.data || {}).map((entry) => entry?.source).find((source) => typeof source?.table === "string" && source.table === table);
|
|
8116
|
-
/** Whether the surface binds this tool: the only tools its page may ask to read again. */
|
|
8117
|
-
const bindsTool = (surface, tool) => typeof tool === "string" && tool !== "rows" && Object.values(surface?.data || {}).some((entry) => entry?.tool === tool);
|
|
8118
|
-
const baseUrl = () => sessionStorage.getItem("stepForm_baseUrl") || "";
|
|
8119
|
-
/** One page of a source, from the agent's paging endpoint (its pages hold at most 10 rows): at the address
|
|
8120
|
-
* the agent gave, as TableContent does with temp_table_url, else under the stream's base URL. `search`: a
|
|
8121
|
-
* filter Control over the kept rows (catalog 0.3), each `{field, value}` an exact match the endpoint applies. */
|
|
8122
|
-
const pageOf = async ({ source, page, pageSize, sort, search }) => {
|
|
8123
|
-
const payload = {
|
|
8124
|
-
limit: { page, page_size: pageSize },
|
|
8125
|
-
search: (Array.isArray(search) ? search : [])
|
|
8126
|
-
.filter((s) => s && typeof s.field === "string" && s.value !== undefined && s.value !== null)
|
|
8127
|
-
.slice(0, 5)
|
|
8128
|
-
.map((s) => ({ column: s.field, pattern: String(s.value), search_type: "equals" })),
|
|
8129
|
-
sort: (Array.isArray(sort) ? sort : []).map((s) => ({ column: s.field, order: s.order === "desc" ? "desc" : "asc" })),
|
|
8130
|
-
};
|
|
8131
|
-
const response = source.url
|
|
8132
|
-
? await getTableRecordsByUrl(payload, source.url)
|
|
8133
|
-
: await getTableRecords(payload, baseUrl(), source.table);
|
|
8134
|
-
const rows = response?.data?.data;
|
|
8135
|
-
const total = response?.data?.total_count;
|
|
8136
|
-
if (!Array.isArray(rows) || !Number.isFinite(total))
|
|
8137
|
-
throw new Error("no rows");
|
|
8138
|
-
return { rows, total };
|
|
8139
|
-
};
|
|
8140
|
-
/** A read tool the surface binds, run again by the agent with these arguments. */
|
|
8141
|
-
const readOf = async ({ surface, tool, args }) => {
|
|
8142
|
-
const response = await postUiQuery({ surface, tool, args: args && typeof args === "object" ? args : {} }, baseUrl());
|
|
8143
|
-
const rows = response?.data?.rows;
|
|
8144
|
-
const total = response?.data?.total;
|
|
8145
|
-
if (!Array.isArray(rows) || !Number.isFinite(total))
|
|
8146
|
-
throw new Error(response?.data?.error || "no rows");
|
|
8147
|
-
return { rows, total };
|
|
8148
|
-
};
|
|
8149
|
-
/** The page's origin, for http(s) addresses only; anything else is refused. */
|
|
8150
|
-
const frameOrigin = (src) => {
|
|
8151
|
-
try {
|
|
8152
|
-
const url = new URL(src, window.location.href);
|
|
8153
|
-
return url.protocol === "https:" || url.protocol === "http:" ? url.origin : null;
|
|
8154
|
-
}
|
|
8155
|
-
catch {
|
|
8156
|
-
return null;
|
|
8157
|
-
}
|
|
8158
|
-
};
|
|
8159
|
-
/** A follow-up within the limits, or null. */
|
|
8160
|
-
const promptOf = (data, surfaceId) => {
|
|
8161
|
-
const text = typeof data?.text === "string" ? data.text.trim() : "";
|
|
8162
|
-
const context = data?.context && typeof data.context === "object" ? { ...data.context, surface: surfaceId } : { surface: surfaceId };
|
|
8163
|
-
let size = Infinity;
|
|
8164
|
-
try {
|
|
8165
|
-
size = JSON.stringify(context).length;
|
|
8166
|
-
}
|
|
8167
|
-
catch {
|
|
8168
|
-
// a context that cannot be sent is not sent
|
|
8169
|
-
}
|
|
8170
|
-
if (!text || text.length > PROMPT_TEXT_MAX || size > PROMPT_CONTEXT_MAX)
|
|
8171
|
-
return null;
|
|
8172
|
-
return { text, uiContext: context };
|
|
8173
|
-
};
|
|
8174
|
-
const SurfaceFrameContent = ({ frame, isFormDisabled = false, messageIndex = 0 }) => {
|
|
8175
|
-
const dispatch = useDispatch();
|
|
8176
|
-
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
8177
|
-
const contextRef = useRef(chatbotContext);
|
|
8178
|
-
contextRef.current = chatbotContext;
|
|
8179
|
-
const iframeRef = useRef(null);
|
|
8180
|
-
const ready = useRef(false);
|
|
8181
|
-
const [height, setHeight] = useState(120);
|
|
8182
|
-
const [form, setForm] = useState({ values: {}, inputs: [], missing: [] });
|
|
8183
|
-
const formRef = useRef(form);
|
|
8184
|
-
formRef.current = form;
|
|
8185
|
-
const src = frame?.src;
|
|
8186
|
-
const incoming = frame?.surface;
|
|
8187
|
-
// the surface shown: a newer version of the same surface replaces it, a lower one is ignored
|
|
8188
|
-
const [surface, setSurface] = useState(incoming);
|
|
8189
|
-
useEffect(() => {
|
|
8190
|
-
if (incoming && (!surface || incoming.id !== surface.id || surfaceVersion(incoming) >= surfaceVersion(surface)))
|
|
8191
|
-
setSurface(incoming);
|
|
8192
|
-
}, [incoming]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8193
|
-
const origin = useMemo(() => frameOrigin(src), [src]);
|
|
8194
|
-
const ask = surface?.mode === "ask";
|
|
8195
|
-
// which version of its surface each widget shows, across the chat's messages
|
|
8196
|
-
const token = useRef(null);
|
|
8197
|
-
if (token.current === null)
|
|
8198
|
-
token.current = surfaceToken();
|
|
8199
|
-
const [, setShownChange] = useState(0);
|
|
8200
|
-
useEffect(() => watchSurfaces(() => setShownChange((n) => n + 1)), []);
|
|
8201
|
-
useEffect(() => {
|
|
8202
|
-
if (!surface?.id || surface.status === "pending" || surface.status === "withdrawn")
|
|
8203
|
-
return undefined;
|
|
8204
|
-
showSurface(surface.id, token.current, surfaceVersion(surface));
|
|
8205
|
-
return () => hideSurface(surface.id, token.current);
|
|
8206
|
-
}, [surface?.id, surface?.version, surface?.status]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8207
|
-
const send = (target, values) => target?.postMessage({ type: "iui:surface", surface, values, disabled: Boolean(isFormDisabled), query: true, ...(ask ? { submit: false } : {}) }, origin);
|
|
8208
|
-
useEffect(() => {
|
|
8209
|
-
if (!origin || !surface)
|
|
8210
|
-
return undefined;
|
|
8211
|
-
const onMessage = (event) => {
|
|
8212
|
-
const target = iframeRef.current?.contentWindow;
|
|
8213
|
-
if (!target || event.source !== target || event.origin !== origin)
|
|
8214
|
-
return;
|
|
8215
|
-
const data = event.data || {};
|
|
8216
|
-
// every message but iui:ready and iui:height names its surface: this widget answers for its own only
|
|
8217
|
-
const own = data.surface === undefined || data.surface === surface.id;
|
|
8218
|
-
if (data.type === "iui:ready") {
|
|
8219
|
-
ready.current = true;
|
|
8220
|
-
send(target, undefined);
|
|
8221
|
-
}
|
|
8222
|
-
else if (data.type === "iui:height" && Number.isFinite(data.height))
|
|
8223
|
-
setHeight(Math.max(40, Math.ceil(data.height)));
|
|
8224
|
-
else if (data.type === "iui:query" && own) {
|
|
8225
|
-
const reply = (body) => target.postMessage({ type: "iui:data", surface: surface.id, id: data.id, ...body }, origin);
|
|
8226
|
-
const args = data.args || {};
|
|
8227
|
-
if (data.tool === "rows") {
|
|
8228
|
-
const source = sourceOf(surface, args.source?.table);
|
|
8229
|
-
if (!source)
|
|
8230
|
-
reply({ error: "not a table of this answer" });
|
|
8231
|
-
else
|
|
8232
|
-
pageOf({ ...args, source }).then(reply, () => reply({ error: "the rows could not be loaded" }));
|
|
8233
|
-
}
|
|
8234
|
-
else if (bindsTool(surface, data.tool)) {
|
|
8235
|
-
readOf({ surface: surface.id, tool: data.tool, args }).then(reply, () => reply({ error: "the data could not be loaded" }));
|
|
8236
|
-
}
|
|
8237
|
-
else
|
|
8238
|
-
reply({ error: "not a tool of this answer" });
|
|
8239
|
-
}
|
|
8240
|
-
else if (data.type === "iui:prompt" && data.surface === surface.id) {
|
|
8241
|
-
const prompt = promptOf(data, surface.id);
|
|
8242
|
-
if (prompt)
|
|
8243
|
-
window.dispatchEvent(new CustomEvent(PROMPT_EVENT, { detail: prompt }));
|
|
8244
|
-
}
|
|
8245
|
-
else if (data.type === "iui:change" && ask && own) {
|
|
8246
|
-
const values = data.values || {};
|
|
8247
|
-
setForm({ values, inputs: Array.isArray(data.inputs) ? data.inputs : Object.keys(values), missing: Array.isArray(data.missing) ? data.missing : [] });
|
|
8248
|
-
// as this chat's own inputs record their values, for the step form's Submit (ButtonContent)
|
|
8249
|
-
const context = { ...contextRef.current };
|
|
8250
|
-
for (const [name, value] of Object.entries(values)) {
|
|
8251
|
-
const empty = value === "" || value === null || value === undefined || (Array.isArray(value) && value.length === 0);
|
|
8252
|
-
context[name] = { ...context[name], [name]: value, updated: !empty };
|
|
8253
|
-
}
|
|
8254
|
-
dispatch(setChatbotContext(context));
|
|
8255
|
-
// only what was filled in: ButtonContent sends a persisted value even when it is empty
|
|
8256
|
-
const filled = Object.entries(values).filter(([name]) => context[name].updated);
|
|
8257
|
-
dispatch(setPersistedFormValues(Object.fromEntries(filled.map(([name, value]) => [`${messageIndex}_${name}`, value]))));
|
|
8258
|
-
}
|
|
8259
|
-
// anything else: a message type this chat does not know, ignored
|
|
8260
|
-
};
|
|
8261
|
-
window.addEventListener("message", onMessage);
|
|
8262
|
-
return () => window.removeEventListener("message", onMessage);
|
|
8263
|
-
}, [origin, surface, isFormDisabled, ask, messageIndex]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8264
|
-
// a newer version of the surface goes into the page that shows it
|
|
8265
|
-
useEffect(() => {
|
|
8266
|
-
if (ready.current)
|
|
8267
|
-
send(iframeRef.current?.contentWindow, undefined);
|
|
8268
|
-
}, [surface]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8269
|
-
// a submitted form is posted again, disabled, with what was filled in
|
|
8270
|
-
useEffect(() => {
|
|
8271
|
-
if (isFormDisabled && ask)
|
|
8272
|
-
send(iframeRef.current?.contentWindow, formRef.current.values);
|
|
8273
|
-
}, [isFormDisabled]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8274
|
-
// a surface that will not come after all (its composition failed): nothing to draw
|
|
8275
|
-
if (!origin || !surface || surface.status === "withdrawn")
|
|
8276
|
-
return null;
|
|
8277
|
-
// a later message shows this surface revised: one line here, the surface there
|
|
8278
|
-
if (newerShown(surface.id, surfaceVersion(surface))) {
|
|
8279
|
-
return (jsx(Box, { "data-iui-host": "surface-frame", "data-iui-superseded": surface.id, my: 1, sx: { fontSize: 13, color: "text.secondary" }, children: `Revised below${surface.title ? `: ${surface.title}` : ""}.` }));
|
|
8280
|
-
}
|
|
8281
|
-
return (jsxs(Box, { "data-iui-host": "surface-frame", my: 1, children: [jsx("iframe", { ref: iframeRef, src: src, title: surface.title || "Generated answer", sandbox: "allow-scripts allow-same-origin", referrerPolicy: "no-referrer", style: { width: "100%", height, border: 0, display: "block" } }), ask ? (jsx(ButtonContent, { bodyText: SUBMIT, isFormDisabled: isFormDisabled, isStepFormSubmit: true, isFormValid: form.inputs.length > 0 && form.missing.length === 0, formParamNames: form.inputs, messageIndex: messageIndex })) : null] }));
|
|
9227
|
+
|
|
9228
|
+
const ImageContent = ({ bodyText }) => {
|
|
9229
|
+
const { gcs_uri, caption } = bodyText || {};
|
|
9230
|
+
return (jsxs("div", { style: {
|
|
9231
|
+
display: "flex",
|
|
9232
|
+
flexDirection: "column",
|
|
9233
|
+
gap: "8px",
|
|
9234
|
+
width: "100%",
|
|
9235
|
+
}, children: [gcs_uri && (jsx("img", { src: gcs_uri, alt: caption || "Image", style: {
|
|
9236
|
+
maxWidth: "100%",
|
|
9237
|
+
borderRadius: "8px",
|
|
9238
|
+
objectFit: "contain",
|
|
9239
|
+
} })), caption && (jsx("div", { children: jsx(TextRenderer, { text: caption }) }))] }));
|
|
8282
9240
|
};
|
|
8283
9241
|
|
|
8284
9242
|
// Key used to persist timeout state in sessionStorage (survives component remounts from tab switches)
|
|
@@ -8343,12 +9301,14 @@ const SavedFilterCascadeBridge = ({ chatbotContext, crossFilterConfigs }) => {
|
|
|
8343
9301
|
*/
|
|
8344
9302
|
const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null, botProps = null, currentMode = "", agentId = "", sessionId = "", }) => {
|
|
8345
9303
|
const dispatch = useDispatch();
|
|
9304
|
+
const { selectors, components } = useChatbotDeps();
|
|
9305
|
+
const hasFilterComponent = !!components?.FilterComponent;
|
|
8346
9306
|
const savedFilterSets = useSelector((state) => state.smartBotReducer.savedFilterSets);
|
|
8347
9307
|
const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
8348
9308
|
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
8349
9309
|
const stepFormStreamData = useSelector((state) => state.smartBotReducer.stepFormStreamData);
|
|
8350
9310
|
const chatbotFilterOptions = useSelector((state) => state.smartBotReducer.chatbotFilterOptions);
|
|
8351
|
-
const dimensionHierarchies = useSelector(
|
|
9311
|
+
const dimensionHierarchies = useSelector(selectors?.getDimensionHierarchies ?? NULL_SELECTOR);
|
|
8352
9312
|
const [isFormSubmitted, setIsFormSubmitted] = useState(false);
|
|
8353
9313
|
const [isTimedOut, setIsTimedOut] = useState(() => sessionStorage.getItem(STEP_FORM_TIMEOUT_KEY) === "true");
|
|
8354
9314
|
const timeoutRef = useRef(null);
|
|
@@ -8708,17 +9668,11 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
8708
9668
|
case "radio":
|
|
8709
9669
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
8710
9670
|
case "button":
|
|
8711
|
-
// A form in the renderer page has its Submit drawn by SurfaceFrameContent, which knows the page's inputs
|
|
8712
|
-
if (formData.some((item) => item?.type === "surface_frame"))
|
|
8713
|
-
return null;
|
|
8714
9671
|
return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled && checkboxGroupsValid, formParamNames: formParamNames, messageIndex: messageIndex }, key);
|
|
8715
9672
|
case "input":
|
|
8716
9673
|
return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
8717
9674
|
case "image":
|
|
8718
9675
|
return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
8719
|
-
case "surface_frame":
|
|
8720
|
-
// The whole form in the renderer page; the widget draws this form's Submit (its inputs are in the page)
|
|
8721
|
-
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, messageIndex: messageIndex }, parsedData.bodyText?.surface?.id || key);
|
|
8722
9676
|
default:
|
|
8723
9677
|
return null;
|
|
8724
9678
|
}
|
|
@@ -8746,7 +9700,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
8746
9700
|
});
|
|
8747
9701
|
if (formFields.length === 0 && buttonItems.length === 0)
|
|
8748
9702
|
return null;
|
|
8749
|
-
return (jsxs("div", { className: "step-form-content", children: [showSavedFilters && filterSetOptions.length > 0 && (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(Select, { currentOptions: filterSetCurrentOptions, setCurrentOptions: setFilterSetCurrentOptions, label: "Saved Filter Sets", labelOrientation: "top", isRequired: false, isDisabled: savedFilterDisabled, handleChange: (selected) => onFilterSetChange(selected), isCloseWhenClickOutside: true, setIsOpen: setIsFilterSetOpen, isOpen: isFilterSetOpen, selectedOptions: selectedFilterSet, setSelectedOptions: setSelectedFilterSet, initialOptions: filterSetOptions, isMulti: false, isClearable: true }) })), showSavedFilters && filterSetOptions.length > 0 && (jsx("hr", { style: { border: "none", borderTop: "1px solid #E0E0E0", margin: "12px 0" } })), jsx("div", { children: crossFilterConfigs.length >= 1 ? (jsxs(CrossFilterProvider, { filters: crossFilterConfigs, fetchOptionsFn: (filterConfig, existingSelections, allFilters) => fetchCrossFilterOptions(filterConfig, existingSelections, allFilters, preSelectedFilters), initialSelections: crossFilterInitialSelections, fetchOnMount: false, children: [jsx(SavedFilterCascadeBridge, { chatbotContext: chatbotContext, crossFilterConfigs: crossFilterConfigs }), formFields] })) : (formFields) }), buttonItems] }));
|
|
9703
|
+
return (jsxs("div", { className: "step-form-content", children: [hasFilterComponent && showSavedFilters && filterSetOptions.length > 0 && (jsx("div", { style: { width: "100%", marginTop: "10px" }, children: jsx(Select, { currentOptions: filterSetCurrentOptions, setCurrentOptions: setFilterSetCurrentOptions, label: "Saved Filter Sets", labelOrientation: "top", isRequired: false, isDisabled: savedFilterDisabled, handleChange: (selected) => onFilterSetChange(selected), isCloseWhenClickOutside: true, setIsOpen: setIsFilterSetOpen, isOpen: isFilterSetOpen, selectedOptions: selectedFilterSet, setSelectedOptions: setSelectedFilterSet, initialOptions: filterSetOptions, isMulti: false, isClearable: true }) })), hasFilterComponent && showSavedFilters && filterSetOptions.length > 0 && (jsx("hr", { style: { border: "none", borderTop: "1px solid #E0E0E0", margin: "12px 0" } })), jsx("div", { children: crossFilterConfigs.length >= 1 ? (jsxs(CrossFilterProvider, { filters: crossFilterConfigs, fetchOptionsFn: (filterConfig, existingSelections, allFilters) => fetchCrossFilterOptions(filterConfig, existingSelections, allFilters, preSelectedFilters), initialSelections: crossFilterInitialSelections, fetchOnMount: false, children: [jsx(SavedFilterCascadeBridge, { chatbotContext: chatbotContext, crossFilterConfigs: crossFilterConfigs }), formFields] })) : (formFields) }), buttonItems] }));
|
|
8750
9704
|
};
|
|
8751
9705
|
/** Reset the timeout flag (call when a new conversation/message starts) */
|
|
8752
9706
|
const resetStepFormTimeoutFlag = () => {
|
|
@@ -9114,7 +10068,7 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
|
|
|
9114
10068
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
9115
10069
|
const dotClass = status === "completed"
|
|
9116
10070
|
? "completed"
|
|
9117
|
-
: status === "in-progress"
|
|
10071
|
+
: status === "in-progress"
|
|
9118
10072
|
? "in-progress"
|
|
9119
10073
|
: status === "error"
|
|
9120
10074
|
? "error"
|
|
@@ -9152,560 +10106,87 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
|
|
|
9152
10106
|
const lastQuestion = questions[questions.length - 1];
|
|
9153
10107
|
const lastQuestionSteps = questionsStepsMap[lastQuestion];
|
|
9154
10108
|
const lastQuestionCompleted = lastQuestionSteps &&
|
|
9155
|
-
lastQuestionSteps.length > 0 &&
|
|
9156
|
-
lastQuestionSteps.every((s) => s.step_status === "completed");
|
|
9157
|
-
const hasStepFormData = Object.keys(stepFormDataMap).length > 0;
|
|
9158
|
-
useEffect(() => {
|
|
9159
|
-
if (done) {
|
|
9160
|
-
// Don't auto-switch to agent_response tab when there's a step form pending user interaction
|
|
9161
|
-
if (hasStepFormData) {
|
|
9162
|
-
setFinalStepDone(true);
|
|
9163
|
-
return;
|
|
9164
|
-
}
|
|
9165
|
-
if (!finalStepDone) {
|
|
9166
|
-
if (currentMode === "navigation") {
|
|
9167
|
-
let updatedSteps = steps.map((step) => ({
|
|
9168
|
-
...step,
|
|
9169
|
-
step_status: "completed",
|
|
9170
|
-
}));
|
|
9171
|
-
updatedSteps = [...updatedSteps, {
|
|
9172
|
-
header: "Finished",
|
|
9173
|
-
sub_header: "Analysis complete",
|
|
9174
|
-
step_status: "not-completed",
|
|
9175
|
-
}];
|
|
9176
|
-
setSteps(cloneDeep(updatedSteps));
|
|
9177
|
-
setTimeout(() => {
|
|
9178
|
-
updatedSteps = updatedSteps.map((step) => ({
|
|
9179
|
-
...step,
|
|
9180
|
-
step_status: "completed",
|
|
9181
|
-
}));
|
|
9182
|
-
setSteps(cloneDeep(updatedSteps));
|
|
9183
|
-
setFinalStepDone(true);
|
|
9184
|
-
}, 300);
|
|
9185
|
-
setTimeout(() => {
|
|
9186
|
-
setTabValue("agent_response");
|
|
9187
|
-
}, 500);
|
|
9188
|
-
}
|
|
9189
|
-
else {
|
|
9190
|
-
setFinalStepDone(true);
|
|
9191
|
-
setTabValue("agent_response");
|
|
9192
|
-
}
|
|
9193
|
-
}
|
|
9194
|
-
}
|
|
9195
|
-
}, [done]);
|
|
9196
|
-
// Reset showThinking when a new question arrives or stream finishes
|
|
9197
|
-
useEffect(() => {
|
|
9198
|
-
if (done || !lastQuestionCompleted) {
|
|
9199
|
-
setShowThinking(false);
|
|
9200
|
-
}
|
|
9201
|
-
}, [done, questions.length, lastQuestionCompleted]);
|
|
9202
|
-
const hasQuestions = questions.length > 0;
|
|
9203
|
-
if (!hasQuestions) {
|
|
9204
|
-
const fallbackQuestion = "Processing Request";
|
|
9205
|
-
const fallbackSteps = steps.length > 0
|
|
9206
|
-
? steps
|
|
9207
|
-
: [
|
|
9208
|
-
{
|
|
9209
|
-
header: "Processing Request",
|
|
9210
|
-
sub_header: "Analyzing the current request",
|
|
9211
|
-
step_status: "not-completed",
|
|
9212
|
-
},
|
|
9213
|
-
];
|
|
9214
|
-
return (jsx("div", { className: classes.progressBarContainer, children: jsx(ProgressBarItem$1, { question: fallbackQuestion, questionSteps: fallbackSteps, isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }));
|
|
9215
|
-
}
|
|
9216
|
-
return (jsxs("div", { className: classes.progressBarContainer, children: [questions.map((question, index) => {
|
|
9217
|
-
const questionData = questionsStepsMap[question];
|
|
9218
|
-
const questionSteps = questionData || [
|
|
9219
|
-
{
|
|
9220
|
-
header: "Processing Request",
|
|
9221
|
-
sub_header: "Analyzing the current request",
|
|
9222
|
-
step_status: "not-completed",
|
|
9223
|
-
},
|
|
9224
|
-
];
|
|
9225
|
-
const formEntry = stepFormDataMap[question] || null;
|
|
9226
|
-
const formData = formEntry ? (Array.isArray(formEntry) ? formEntry : formEntry.widgets) : null;
|
|
9227
|
-
const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
|
|
9228
|
-
const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
|
|
9229
|
-
const isLast = index === questions.length - 1;
|
|
9230
|
-
return (jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, index: index, chatSessionId: chatSessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
|
|
9231
|
-
? () => setShowThinking(true)
|
|
9232
|
-
: undefined }, index));
|
|
9233
|
-
}), showThinking && !done && (jsx("div", { style: {
|
|
9234
|
-
animation: "thinkingFadeIn 0.4s ease forwards",
|
|
9235
|
-
}, children: jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
|
|
9236
|
-
};
|
|
9237
|
-
|
|
9238
|
-
const useAllocationPanelStyles = makeStyles((theme) => ({
|
|
9239
|
-
// AllocationPlanCard styles (inside chatbot)
|
|
9240
|
-
planCard: {
|
|
9241
|
-
border: "1.5px solid #e2e8f0",
|
|
9242
|
-
borderRadius: "14px",
|
|
9243
|
-
padding: "14px 16px",
|
|
9244
|
-
display: "flex",
|
|
9245
|
-
alignItems: "center",
|
|
9246
|
-
gap: "14px",
|
|
9247
|
-
cursor: "pointer",
|
|
9248
|
-
position: "relative",
|
|
9249
|
-
overflow: "hidden",
|
|
9250
|
-
transition: "border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease",
|
|
9251
|
-
background: "#fafbff",
|
|
9252
|
-
"&:hover": {
|
|
9253
|
-
borderColor: "#b4beff",
|
|
9254
|
-
boxShadow: "0 2px 12px rgba(66, 89, 238, 0.10)",
|
|
9255
|
-
background: "linear-gradient(135deg, #f5f7ff 0%, #eef1ff 60%, #e8ecff 100%)",
|
|
9256
|
-
},
|
|
9257
|
-
},
|
|
9258
|
-
planCardIcon: {
|
|
9259
|
-
width: "48px",
|
|
9260
|
-
height: "48px",
|
|
9261
|
-
borderRadius: "12px",
|
|
9262
|
-
background: "linear-gradient(135deg, #e8edff 0%, #dbe1ff 100%)",
|
|
9263
|
-
display: "flex",
|
|
9264
|
-
alignItems: "center",
|
|
9265
|
-
justifyContent: "center",
|
|
9266
|
-
flexShrink: 0,
|
|
9267
|
-
"& svg": {
|
|
9268
|
-
color: "#4259EE",
|
|
9269
|
-
fontSize: "22px",
|
|
9270
|
-
},
|
|
9271
|
-
},
|
|
9272
|
-
planCardContent: {
|
|
9273
|
-
flex: 1,
|
|
9274
|
-
minWidth: 0,
|
|
9275
|
-
},
|
|
9276
|
-
planCardTitle: {
|
|
9277
|
-
fontSize: "14px",
|
|
9278
|
-
fontWeight: 700,
|
|
9279
|
-
color: "#1e293b",
|
|
9280
|
-
lineHeight: 1.4,
|
|
9281
|
-
marginBottom: "4px",
|
|
9282
|
-
},
|
|
9283
|
-
planCardLinks: {
|
|
9284
|
-
display: "flex",
|
|
9285
|
-
alignItems: "center",
|
|
9286
|
-
gap: "4px",
|
|
9287
|
-
flexWrap: "wrap",
|
|
9288
|
-
fontSize: "13px",
|
|
9289
|
-
color: "#64748b",
|
|
9290
|
-
},
|
|
9291
|
-
planCardLink: {
|
|
9292
|
-
color: "#64748b",
|
|
9293
|
-
cursor: "pointer",
|
|
9294
|
-
textDecoration: "none",
|
|
9295
|
-
transition: "color 0.2s ease",
|
|
9296
|
-
"&:hover": {
|
|
9297
|
-
color: "#4259EE",
|
|
9298
|
-
},
|
|
9299
|
-
},
|
|
9300
|
-
planCardLinkSeparator: {
|
|
9301
|
-
color: "#94a3b8",
|
|
9302
|
-
margin: "0 3px",
|
|
9303
|
-
},
|
|
9304
|
-
planCardOpenIcon: {
|
|
9305
|
-
flexShrink: 0,
|
|
9306
|
-
color: "#94a3b8",
|
|
9307
|
-
fontSize: "20px !important",
|
|
9308
|
-
padding: "6px",
|
|
9309
|
-
borderRadius: "8px",
|
|
9310
|
-
border: "1px solid #e2e8f0",
|
|
9311
|
-
background: "#ffffff",
|
|
9312
|
-
transition: "border-color 0.25s ease, color 0.25s ease",
|
|
9313
|
-
"$planCard:hover &": {
|
|
9314
|
-
borderColor: "#b4beff",
|
|
9315
|
-
color: "#4259EE",
|
|
9316
|
-
},
|
|
9317
|
-
},
|
|
9318
|
-
|
|
9319
|
-
// PanelHeader styles
|
|
9320
|
-
panelHeader: {
|
|
9321
|
-
display: "flex",
|
|
9322
|
-
alignItems: "center",
|
|
9323
|
-
justifyContent: "space-between",
|
|
9324
|
-
padding: "16px",
|
|
9325
|
-
borderBottom: "1px solid #f0f0f0",
|
|
9326
|
-
flexShrink: 0,
|
|
9327
|
-
},
|
|
9328
|
-
panelHeaderLeft: {
|
|
9329
|
-
display: "flex",
|
|
9330
|
-
alignItems: "center",
|
|
9331
|
-
gap: "8px",
|
|
9332
|
-
flex: 1,
|
|
9333
|
-
minWidth: 0,
|
|
9334
|
-
},
|
|
9335
|
-
panelHeaderIcon: {
|
|
9336
|
-
color: "#666",
|
|
9337
|
-
fontSize: "20px",
|
|
9338
|
-
cursor: "pointer",
|
|
9339
|
-
},
|
|
9340
|
-
panelTitle: {
|
|
9341
|
-
fontSize: "14px",
|
|
9342
|
-
fontWeight: 600,
|
|
9343
|
-
color: "#1a1a1a",
|
|
9344
|
-
lineHeight: 1.4,
|
|
9345
|
-
overflow: "hidden",
|
|
9346
|
-
textOverflow: "ellipsis",
|
|
9347
|
-
whiteSpace: "nowrap",
|
|
9348
|
-
},
|
|
9349
|
-
panelHeaderActions: {
|
|
9350
|
-
display: "flex",
|
|
9351
|
-
alignItems: "center",
|
|
9352
|
-
gap: "6px",
|
|
9353
|
-
flexShrink: 0,
|
|
9354
|
-
},
|
|
9355
|
-
panelHeaderActionBtn: {
|
|
9356
|
-
width: "28px !important",
|
|
9357
|
-
height: "28px !important",
|
|
9358
|
-
borderRadius: "8px !important",
|
|
9359
|
-
background: "#f1f5f9 !important",
|
|
9360
|
-
color: "#475569 !important",
|
|
9361
|
-
padding: "0 !important",
|
|
9362
|
-
"&:hover": {
|
|
9363
|
-
background: "#e2e8f0 !important",
|
|
9364
|
-
color: "#1e293b !important",
|
|
9365
|
-
},
|
|
9366
|
-
},
|
|
9367
|
-
|
|
9368
|
-
// ReportSummaryCard styles
|
|
9369
|
-
reportSummaryCard: {
|
|
9370
|
-
border: "1px solid #f0c36d",
|
|
9371
|
-
borderRadius: "8px",
|
|
9372
|
-
padding: "14px",
|
|
9373
|
-
margin: "16px 0",
|
|
9374
|
-
background: "#fffdf5",
|
|
9375
|
-
},
|
|
9376
|
-
reportBadge: {
|
|
9377
|
-
display: "inline-block",
|
|
9378
|
-
fontSize: "11px",
|
|
9379
|
-
fontWeight: 500,
|
|
9380
|
-
padding: "3px 8px",
|
|
9381
|
-
borderRadius: "4px",
|
|
9382
|
-
marginBottom: "8px",
|
|
9383
|
-
border: "1px solid #f0c36d",
|
|
9384
|
-
color: "#8b6914",
|
|
9385
|
-
background: "transparent",
|
|
9386
|
-
},
|
|
9387
|
-
reportDescription: {
|
|
9388
|
-
fontSize: "12px",
|
|
9389
|
-
lineHeight: 1.6,
|
|
9390
|
-
color: "#333",
|
|
9391
|
-
marginBottom: "10px",
|
|
9392
|
-
},
|
|
9393
|
-
baselinePlanRow: {
|
|
9394
|
-
fontSize: "12px",
|
|
9395
|
-
color: "#666",
|
|
9396
|
-
display: "flex",
|
|
9397
|
-
alignItems: "center",
|
|
9398
|
-
gap: "4px",
|
|
9399
|
-
},
|
|
9400
|
-
baselinePlanLink: {
|
|
9401
|
-
color: "#2563eb",
|
|
9402
|
-
textDecoration: "underline",
|
|
9403
|
-
cursor: "pointer",
|
|
9404
|
-
wordBreak: "break-all",
|
|
9405
|
-
},
|
|
9406
|
-
|
|
9407
|
-
// PanelSection (Accordion) styles
|
|
9408
|
-
sectionAccordion: {
|
|
9409
|
-
boxShadow: "none !important",
|
|
9410
|
-
border: "none !important",
|
|
9411
|
-
borderRadius: "12px !important",
|
|
9412
|
-
marginBottom: "10px !important",
|
|
9413
|
-
background: "#f8fafc !important",
|
|
9414
|
-
"&:before": {
|
|
9415
|
-
display: "none !important",
|
|
9416
|
-
content: "none !important",
|
|
9417
|
-
background: "none !important",
|
|
9418
|
-
width: "0 !important",
|
|
9419
|
-
height: "0 !important",
|
|
9420
|
-
},
|
|
9421
|
-
"&.Mui-expanded": {
|
|
9422
|
-
margin: "0 0 10px 0 !important",
|
|
9423
|
-
background: "#ffffff !important",
|
|
9424
|
-
boxShadow: "0 1px 8px rgba(0, 0, 0, 0.06) !important",
|
|
9425
|
-
border: "1px solid #e2e8f0 !important",
|
|
9426
|
-
},
|
|
9427
|
-
},
|
|
9428
|
-
sectionSummary: {
|
|
9429
|
-
minHeight: "48px !important",
|
|
9430
|
-
padding: "0 16px !important",
|
|
9431
|
-
border: "none !important",
|
|
9432
|
-
flexDirection: "row-reverse !important",
|
|
9433
|
-
gap: "10px",
|
|
9434
|
-
"&:before": {
|
|
9435
|
-
display: "none !important",
|
|
9436
|
-
content: "none !important",
|
|
9437
|
-
background: "none !important",
|
|
9438
|
-
width: "0 !important",
|
|
9439
|
-
height: "0 !important",
|
|
9440
|
-
},
|
|
9441
|
-
"& .MuiAccordionSummary-content": {
|
|
9442
|
-
margin: "12px 0 !important",
|
|
9443
|
-
},
|
|
9444
|
-
"& .MuiAccordionSummary-expandIconWrapper": {
|
|
9445
|
-
color: "#64748b",
|
|
9446
|
-
transform: "rotate(-90deg)",
|
|
9447
|
-
padding: "0 !important",
|
|
9448
|
-
marginRight: "0 !important",
|
|
9449
|
-
"&.Mui-expanded": {
|
|
9450
|
-
transform: "rotate(0deg)",
|
|
9451
|
-
},
|
|
9452
|
-
},
|
|
9453
|
-
},
|
|
9454
|
-
sectionTitle: {
|
|
9455
|
-
fontSize: "14px",
|
|
9456
|
-
fontWeight: 600,
|
|
9457
|
-
color: "#1e293b",
|
|
9458
|
-
},
|
|
9459
|
-
sectionDetails: {
|
|
9460
|
-
padding: "0 16px 16px !important",
|
|
9461
|
-
border: "none !important",
|
|
9462
|
-
"&:before": {
|
|
9463
|
-
display: "none !important",
|
|
9464
|
-
content: "none !important",
|
|
9465
|
-
background: "none !important",
|
|
9466
|
-
width: "0 !important",
|
|
9467
|
-
height: "0 !important",
|
|
9468
|
-
},
|
|
9469
|
-
},
|
|
9470
|
-
|
|
9471
|
-
// StructuredComparison styles
|
|
9472
|
-
comparisonSubtitle: {
|
|
9473
|
-
fontSize: "12px",
|
|
9474
|
-
color: "#666",
|
|
9475
|
-
marginBottom: "12px",
|
|
9476
|
-
lineHeight: 1.5,
|
|
9477
|
-
},
|
|
9478
|
-
scenarioLabel: {
|
|
9479
|
-
fontSize: "12px",
|
|
9480
|
-
fontWeight: 500,
|
|
9481
|
-
color: "#1a1a1a",
|
|
9482
|
-
padding: "8px 12px",
|
|
9483
|
-
background: "#f8f9fa",
|
|
9484
|
-
borderRadius: "6px",
|
|
9485
|
-
marginBottom: "12px",
|
|
9486
|
-
},
|
|
9487
|
-
comparisonCard: {
|
|
9488
|
-
background: "#f8f9fa",
|
|
9489
|
-
borderRadius: "8px",
|
|
9490
|
-
padding: "12px",
|
|
9491
|
-
marginBottom: "10px",
|
|
9492
|
-
},
|
|
9493
|
-
comparisonParamRow: {
|
|
9494
|
-
display: "flex",
|
|
9495
|
-
alignItems: "center",
|
|
9496
|
-
gap: "8px",
|
|
9497
|
-
marginBottom: "10px",
|
|
9498
|
-
},
|
|
9499
|
-
comparisonParamName: {
|
|
9500
|
-
fontSize: "13px",
|
|
9501
|
-
fontWeight: 600,
|
|
9502
|
-
color: "#1a1a1a",
|
|
9503
|
-
},
|
|
9504
|
-
comparisonTag: {
|
|
9505
|
-
display: "inline-block",
|
|
9506
|
-
fontSize: "10px",
|
|
9507
|
-
fontWeight: 500,
|
|
9508
|
-
padding: "2px 6px",
|
|
9509
|
-
borderRadius: "4px",
|
|
9510
|
-
color: "#2563eb",
|
|
9511
|
-
border: "1px solid #bfdbfe",
|
|
9512
|
-
background: "#eff6ff",
|
|
9513
|
-
},
|
|
9514
|
-
comparisonValues: {
|
|
9515
|
-
display: "flex",
|
|
9516
|
-
alignItems: "center",
|
|
9517
|
-
gap: "8px",
|
|
9518
|
-
},
|
|
9519
|
-
comparisonValueBox: {
|
|
9520
|
-
flex: 1,
|
|
9521
|
-
background: theme.palette.common.white,
|
|
9522
|
-
borderRadius: "6px",
|
|
9523
|
-
padding: "8px 10px",
|
|
9524
|
-
border: "1px solid #e8e8e8",
|
|
9525
|
-
},
|
|
9526
|
-
comparisonValueLabel: {
|
|
9527
|
-
fontSize: "10px",
|
|
9528
|
-
color: "#999",
|
|
9529
|
-
marginBottom: "2px",
|
|
9530
|
-
},
|
|
9531
|
-
comparisonValueText: {
|
|
9532
|
-
fontSize: "12px",
|
|
9533
|
-
fontWeight: 600,
|
|
9534
|
-
color: "#1a1a1a",
|
|
9535
|
-
},
|
|
9536
|
-
comparisonArrow: {
|
|
9537
|
-
color: "#999",
|
|
9538
|
-
fontSize: "16px",
|
|
9539
|
-
flexShrink: 0,
|
|
9540
|
-
},
|
|
9541
|
-
|
|
9542
|
-
// Panel-specific HTML content wrapper (font size/line-height for panel context)
|
|
9543
|
-
panelHtmlContainer: {
|
|
9544
|
-
fontSize: "12px",
|
|
9545
|
-
lineHeight: 1.6,
|
|
9546
|
-
},
|
|
9547
|
-
|
|
9548
|
-
// Slide-in keyframes for panel entry
|
|
9549
|
-
"@keyframes panelSlideIn": {
|
|
9550
|
-
"0%": {
|
|
9551
|
-
transform: "translateX(100%)",
|
|
9552
|
-
opacity: 0,
|
|
9553
|
-
},
|
|
9554
|
-
"100%": {
|
|
9555
|
-
transform: "translateX(0)",
|
|
9556
|
-
opacity: 1,
|
|
9557
|
-
},
|
|
9558
|
-
},
|
|
9559
|
-
// AllocationDetailPanel container (portaled)
|
|
9560
|
-
panelContainer: {
|
|
9561
|
-
position: "fixed",
|
|
9562
|
-
top: 56,
|
|
9563
|
-
right: 0,
|
|
9564
|
-
width: "calc(50vw - 32px)",
|
|
9565
|
-
maxWidth: "520px",
|
|
9566
|
-
height: "calc(100vh - 56px)",
|
|
9567
|
-
zIndex: 99999,
|
|
9568
|
-
display: "flex",
|
|
9569
|
-
flexDirection: "column",
|
|
9570
|
-
background: "#ffffff",
|
|
9571
|
-
boxShadow: "-4px 0 16px rgba(0, 0, 0, 0.15)",
|
|
9572
|
-
borderLeft: "1px solid #e8e8e8",
|
|
9573
|
-
borderRadius: "12px 0 0 12px",
|
|
9574
|
-
overflow: "hidden",
|
|
9575
|
-
animation: "$panelSlideIn 0.3s ease forwards",
|
|
9576
|
-
transition: "width 0.3s ease, max-width 0.3s ease, border-radius 0.3s ease",
|
|
9577
|
-
},
|
|
9578
|
-
// Expanded / maximized panel — covers the chatbot area too
|
|
9579
|
-
panelExpanded: {
|
|
9580
|
-
width: "calc(100vw - 4rem)",
|
|
9581
|
-
maxWidth: "calc(100vw - 4rem)",
|
|
9582
|
-
borderRadius: "0",
|
|
9583
|
-
},
|
|
9584
|
-
panelScrollBody: {
|
|
9585
|
-
flex: 1,
|
|
9586
|
-
overflowY: "auto",
|
|
9587
|
-
padding: "0 16px 24px",
|
|
9588
|
-
},
|
|
9589
|
-
|
|
9590
|
-
// Footer
|
|
9591
|
-
panelFooter: {
|
|
9592
|
-
display: "flex",
|
|
9593
|
-
justifyContent: "flex-end",
|
|
9594
|
-
alignItems: "center",
|
|
9595
|
-
gap: "10px",
|
|
9596
|
-
padding: "12px 16px",
|
|
9597
|
-
borderTop: "1px solid #e2e8f0",
|
|
9598
|
-
background: "#ffffff",
|
|
9599
|
-
flexShrink: 0,
|
|
9600
|
-
position: "relative",
|
|
9601
|
-
},
|
|
9602
|
-
footerBtnOutlined: {
|
|
9603
|
-
display: "inline-flex",
|
|
9604
|
-
alignItems: "center",
|
|
9605
|
-
justifyContent: "center",
|
|
9606
|
-
height: "32px",
|
|
9607
|
-
padding: "0 12px",
|
|
9608
|
-
fontSize: "14px",
|
|
9609
|
-
fontWeight: 600,
|
|
9610
|
-
fontFamily: "Manrope, sans-serif",
|
|
9611
|
-
lineHeight: 1,
|
|
9612
|
-
borderRadius: "8px",
|
|
9613
|
-
border: "1px solid #d1d5db",
|
|
9614
|
-
background: "#ffffff",
|
|
9615
|
-
color: "#1e293b",
|
|
9616
|
-
cursor: "pointer",
|
|
9617
|
-
textTransform: "none",
|
|
9618
|
-
},
|
|
9619
|
-
footerBtnPrimary: {
|
|
9620
|
-
display: "inline-flex",
|
|
9621
|
-
alignItems: "center",
|
|
9622
|
-
justifyContent: "center",
|
|
9623
|
-
height: "32px",
|
|
9624
|
-
padding: "0 12px",
|
|
9625
|
-
fontSize: "14px",
|
|
9626
|
-
fontWeight: 600,
|
|
9627
|
-
fontFamily: "Manrope, sans-serif",
|
|
9628
|
-
lineHeight: 1,
|
|
9629
|
-
borderRadius: "8px",
|
|
9630
|
-
border: "1px solid #4259EE",
|
|
9631
|
-
background: "#4259EE",
|
|
9632
|
-
color: "#ffffff",
|
|
9633
|
-
cursor: "pointer",
|
|
9634
|
-
textTransform: "none",
|
|
9635
|
-
},
|
|
9636
|
-
|
|
9637
|
-
// Footer options popover
|
|
9638
|
-
optionsCard: {
|
|
9639
|
-
position: "absolute",
|
|
9640
|
-
bottom: "100%",
|
|
9641
|
-
right: 0,
|
|
9642
|
-
marginBottom: "8px",
|
|
9643
|
-
background: "#ffffff",
|
|
9644
|
-
borderRadius: "12px",
|
|
9645
|
-
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.12)",
|
|
9646
|
-
border: "1px solid #e2e8f0",
|
|
9647
|
-
padding: "8px",
|
|
9648
|
-
minWidth: "280px",
|
|
9649
|
-
zIndex: 1,
|
|
9650
|
-
},
|
|
9651
|
-
optionRow: {
|
|
9652
|
-
display: "flex",
|
|
9653
|
-
alignItems: "center",
|
|
9654
|
-
gap: "10px",
|
|
9655
|
-
padding: "10px 12px",
|
|
9656
|
-
borderRadius: "8px",
|
|
9657
|
-
cursor: "pointer",
|
|
9658
|
-
fontSize: "13px",
|
|
9659
|
-
fontWeight: 500,
|
|
9660
|
-
color: "#1e293b",
|
|
9661
|
-
background: "#f8fafc",
|
|
9662
|
-
marginBottom: "4px",
|
|
9663
|
-
border: "none",
|
|
9664
|
-
width: "100%",
|
|
9665
|
-
textAlign: "left",
|
|
9666
|
-
fontFamily: "Manrope, sans-serif",
|
|
9667
|
-
"&:hover": {
|
|
9668
|
-
background: "#eef2ff",
|
|
9669
|
-
},
|
|
9670
|
-
"&:last-child": {
|
|
9671
|
-
marginBottom: 0,
|
|
9672
|
-
},
|
|
9673
|
-
},
|
|
9674
|
-
optionIcon: {
|
|
9675
|
-
color: "#6366f1",
|
|
9676
|
-
fontSize: "16px",
|
|
9677
|
-
},
|
|
9678
|
-
}));
|
|
9679
|
-
|
|
9680
|
-
const AllocationPlanCard = ({ bodyText }) => {
|
|
9681
|
-
const classes = useAllocationPanelStyles();
|
|
9682
|
-
const title = bodyText?.title || "Allocation Plan";
|
|
9683
|
-
const links = bodyText?.links || [];
|
|
9684
|
-
const panelData = bodyText?.panel_data || null;
|
|
9685
|
-
const handleCardClick = (target) => {
|
|
9686
|
-
if (!panelData)
|
|
9687
|
-
return;
|
|
9688
|
-
const openPanel = () => {
|
|
9689
|
-
window.dispatchEvent(new CustomEvent("openAllocationDetailPanel", {
|
|
9690
|
-
detail: { panelData, activeSection: target || null },
|
|
9691
|
-
}));
|
|
9692
|
-
};
|
|
9693
|
-
// Check if the chatbot is in a collapsed/minimized state by looking for
|
|
9694
|
-
// the "Expand chatbot" button (present only when collapsed)
|
|
9695
|
-
const expandBtn = document.querySelector('button[aria-label="Expand chatbot"]');
|
|
9696
|
-
if (expandBtn) {
|
|
9697
|
-
// Maximize first, then open the panel after chatbot finishes expanding
|
|
9698
|
-
window.dispatchEvent(new CustomEvent("smartBotMaximize"));
|
|
9699
|
-
setTimeout(openPanel, 350);
|
|
10109
|
+
lastQuestionSteps.length > 0 &&
|
|
10110
|
+
lastQuestionSteps.every((s) => s.step_status === "completed");
|
|
10111
|
+
const hasStepFormData = Object.keys(stepFormDataMap).length > 0;
|
|
10112
|
+
useEffect(() => {
|
|
10113
|
+
if (done) {
|
|
10114
|
+
// Don't auto-switch to agent_response tab when there's a step form pending user interaction
|
|
10115
|
+
if (hasStepFormData) {
|
|
10116
|
+
setFinalStepDone(true);
|
|
10117
|
+
return;
|
|
10118
|
+
}
|
|
10119
|
+
if (!finalStepDone) {
|
|
10120
|
+
if (currentMode === "navigation") {
|
|
10121
|
+
let updatedSteps = steps.map((step) => ({
|
|
10122
|
+
...step,
|
|
10123
|
+
step_status: "completed",
|
|
10124
|
+
}));
|
|
10125
|
+
updatedSteps = [...updatedSteps, {
|
|
10126
|
+
header: "Finished",
|
|
10127
|
+
sub_header: "Analysis complete",
|
|
10128
|
+
step_status: "not-completed",
|
|
10129
|
+
}];
|
|
10130
|
+
setSteps(cloneDeep(updatedSteps));
|
|
10131
|
+
setTimeout(() => {
|
|
10132
|
+
updatedSteps = updatedSteps.map((step) => ({
|
|
10133
|
+
...step,
|
|
10134
|
+
step_status: "completed",
|
|
10135
|
+
}));
|
|
10136
|
+
setSteps(cloneDeep(updatedSteps));
|
|
10137
|
+
setFinalStepDone(true);
|
|
10138
|
+
}, 300);
|
|
10139
|
+
setTimeout(() => {
|
|
10140
|
+
setTabValue("agent_response");
|
|
10141
|
+
}, 500);
|
|
10142
|
+
}
|
|
10143
|
+
else {
|
|
10144
|
+
setFinalStepDone(true);
|
|
10145
|
+
setTabValue("agent_response");
|
|
10146
|
+
}
|
|
10147
|
+
}
|
|
9700
10148
|
}
|
|
9701
|
-
|
|
9702
|
-
|
|
10149
|
+
}, [done]);
|
|
10150
|
+
// Reset showThinking when a new question arrives or stream finishes
|
|
10151
|
+
useEffect(() => {
|
|
10152
|
+
if (done || !lastQuestionCompleted) {
|
|
10153
|
+
setShowThinking(false);
|
|
9703
10154
|
}
|
|
9704
|
-
};
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
10155
|
+
}, [done, questions.length, lastQuestionCompleted]);
|
|
10156
|
+
const hasQuestions = questions.length > 0;
|
|
10157
|
+
if (!hasQuestions) {
|
|
10158
|
+
const fallbackQuestion = "Processing Request";
|
|
10159
|
+
const fallbackSteps = steps.length > 0
|
|
10160
|
+
? steps
|
|
10161
|
+
: [
|
|
10162
|
+
{
|
|
10163
|
+
header: "Processing Request",
|
|
10164
|
+
sub_header: "Analyzing the current request",
|
|
10165
|
+
step_status: "not-completed",
|
|
10166
|
+
},
|
|
10167
|
+
];
|
|
10168
|
+
return (jsx("div", { className: classes.progressBarContainer, children: jsx(ProgressBarItem$1, { question: fallbackQuestion, questionSteps: fallbackSteps, isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }));
|
|
10169
|
+
}
|
|
10170
|
+
return (jsxs("div", { className: classes.progressBarContainer, children: [questions.map((question, index) => {
|
|
10171
|
+
const questionData = questionsStepsMap[question];
|
|
10172
|
+
const questionSteps = questionData || [
|
|
10173
|
+
{
|
|
10174
|
+
header: "Processing Request",
|
|
10175
|
+
sub_header: "Analyzing the current request",
|
|
10176
|
+
step_status: "not-completed",
|
|
10177
|
+
},
|
|
10178
|
+
];
|
|
10179
|
+
const formEntry = stepFormDataMap[question] || null;
|
|
10180
|
+
const formData = formEntry ? (Array.isArray(formEntry) ? formEntry : formEntry.widgets) : null;
|
|
10181
|
+
const showSavedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.showSavedFilters : true;
|
|
10182
|
+
const preSelectedFilters = formEntry && !Array.isArray(formEntry) ? formEntry.preSelectedFilters : null;
|
|
10183
|
+
const isLast = index === questions.length - 1;
|
|
10184
|
+
return (jsx(ProgressBarItem$1, { question: question, questionSteps: questionSteps, isLast: isLast && !showThinking, classes: classes, formData: formData, isFormDisabled: isFormDisabled, showSavedFilters: showSavedFilters, preSelectedFilters: preSelectedFilters, botProps: botProps, currentMode: currentMode, agentId: agentId, sessionId: sessionId, index: index, chatSessionId: chatSessionId, onAllSubItemsAnimated: isLast && lastQuestionCompleted && !done
|
|
10185
|
+
? () => setShowThinking(true)
|
|
10186
|
+
: undefined }, index));
|
|
10187
|
+
}), showThinking && !done && (jsx("div", { style: {
|
|
10188
|
+
animation: "thinkingFadeIn 0.4s ease forwards",
|
|
10189
|
+
}, children: jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
|
|
9709
10190
|
};
|
|
9710
10191
|
|
|
9711
10192
|
const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
@@ -9744,10 +10225,6 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
|
9744
10225
|
return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
9745
10226
|
case "html":
|
|
9746
10227
|
return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
9747
|
-
case "surface_frame":
|
|
9748
|
-
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
9749
|
-
case "allocation_plan_card":
|
|
9750
|
-
return jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
|
|
9751
10228
|
default:
|
|
9752
10229
|
return null;
|
|
9753
10230
|
}
|
|
@@ -10287,6 +10764,7 @@ const StreamedContent = ({ botData, botProps }) => {
|
|
|
10287
10764
|
// botData.inputBody = {
|
|
10288
10765
|
// "query": "get product status for this l2_name 10_Trey Heckmann"
|
|
10289
10766
|
// }
|
|
10767
|
+
const { BASE_API } = getApiConstants();
|
|
10290
10768
|
let endPoint = botData?.utilityObject?.endpoint
|
|
10291
10769
|
? `${BASE_API}${botData?.utilityObject?.endpoint}`
|
|
10292
10770
|
: `${BASE_API}/core/chatbot/navigation-v2`;
|
|
@@ -10619,8 +11097,7 @@ const StreamedContent = ({ botData, botProps }) => {
|
|
|
10619
11097
|
const widgetItems = isArray(data.widget_data)
|
|
10620
11098
|
? data.widget_data
|
|
10621
11099
|
: [data.widget_data];
|
|
10622
|
-
|
|
10623
|
-
setStreamingWidgetData((prev) => mergeSurfaceWidgets(prev, widgetItems));
|
|
11100
|
+
setStreamingWidgetData((prev) => [...prev, ...widgetItems]);
|
|
10624
11101
|
}
|
|
10625
11102
|
else if (data.message !== "[DONE]") {
|
|
10626
11103
|
if (!thinkingDoneRef?.current && currentMode === "agent") {
|
|
@@ -11790,8 +12267,6 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
11790
12267
|
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
11791
12268
|
case "graph":
|
|
11792
12269
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
11793
|
-
case "surface_frame":
|
|
11794
|
-
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
11795
12270
|
case "radio":
|
|
11796
12271
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
11797
12272
|
case "checkbox":
|
|
@@ -11871,8 +12346,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
11871
12346
|
}
|
|
11872
12347
|
});
|
|
11873
12348
|
if (newWidgets.length > 0) {
|
|
11874
|
-
|
|
11875
|
-
setWidgetContent((prev) => mergeSurfaceWidgets(prev, newWidgets));
|
|
12349
|
+
setWidgetContent((prev) => [...prev, ...newWidgets]);
|
|
11876
12350
|
}
|
|
11877
12351
|
return;
|
|
11878
12352
|
}
|
|
@@ -12003,7 +12477,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
12003
12477
|
let newQuestions = [...questionsRef.current];
|
|
12004
12478
|
let newQuestionsStepsMap = cloneDeep(questionsStepsMapRef.current);
|
|
12005
12479
|
let newStepFormDataMap = cloneDeep(stepFormDataMapRef.current);
|
|
12006
|
-
|
|
12480
|
+
const newWidgets = [];
|
|
12007
12481
|
chunks.forEach((data) => {
|
|
12008
12482
|
if (data.status === "questions") {
|
|
12009
12483
|
const incomingQuestions = data.widget_data?.[0]?.questions || [];
|
|
@@ -12100,8 +12574,10 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
12100
12574
|
}
|
|
12101
12575
|
if (data.status === "widget") {
|
|
12102
12576
|
const widgetItems = isArray$2(data.widget_data) ? data.widget_data : [data.widget_data];
|
|
12103
|
-
|
|
12104
|
-
|
|
12577
|
+
widgetItems.forEach((item) => {
|
|
12578
|
+
if (item)
|
|
12579
|
+
newWidgets.push(item);
|
|
12580
|
+
});
|
|
12105
12581
|
}
|
|
12106
12582
|
if (data.status === "content" && data.message) {
|
|
12107
12583
|
newWidgets.push({ type: "text", response: data.message });
|
|
@@ -12228,10 +12704,6 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
12228
12704
|
return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
12229
12705
|
case "html":
|
|
12230
12706
|
return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
12231
|
-
case "surface_frame":
|
|
12232
|
-
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
12233
|
-
case "allocation_plan_card":
|
|
12234
|
-
return jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
|
|
12235
12707
|
default:
|
|
12236
12708
|
return null;
|
|
12237
12709
|
}
|
|
@@ -12310,8 +12782,6 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
12310
12782
|
return jsx(TableContent, { bodyText: botData.bodyText });
|
|
12311
12783
|
case "graph":
|
|
12312
12784
|
return jsx(GraphContent, { bodyText: botData.bodyText });
|
|
12313
|
-
case "surface_frame":
|
|
12314
|
-
return jsx(SurfaceFrameContent, { frame: botData.bodyText });
|
|
12315
12785
|
case "slider":
|
|
12316
12786
|
return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
12317
12787
|
case "select":
|
|
@@ -12334,8 +12804,6 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
12334
12804
|
return jsx(ImageContent, { bodyText: botData.bodyText });
|
|
12335
12805
|
case "html":
|
|
12336
12806
|
return jsx(HtmlContent, { bodyText: botData.bodyText });
|
|
12337
|
-
case "allocation_plan_card":
|
|
12338
|
-
return jsx(AllocationPlanCard, { bodyText: botData.bodyText });
|
|
12339
12807
|
case "combined":
|
|
12340
12808
|
return jsx(CombinedContent, { botData: botData, props: props });
|
|
12341
12809
|
case "dynamic":
|
|
@@ -12451,7 +12919,7 @@ var SvgGenericModuleIcon = function SvgGenericModuleIcon(props) {
|
|
|
12451
12919
|
|
|
12452
12920
|
const fetchAllMemories = async (baseUrl) => {
|
|
12453
12921
|
try {
|
|
12454
|
-
let data = await
|
|
12922
|
+
let data = await httpRequest({
|
|
12455
12923
|
url: `${baseUrl}/chatbot/agent/memory/get_all`,
|
|
12456
12924
|
method: "GET",
|
|
12457
12925
|
});
|
|
@@ -12464,7 +12932,7 @@ const fetchAllMemories = async (baseUrl) => {
|
|
|
12464
12932
|
};
|
|
12465
12933
|
const editMemory = async (baseUrl, memoryId, data) => {
|
|
12466
12934
|
try {
|
|
12467
|
-
let response = await
|
|
12935
|
+
let response = await httpRequest({
|
|
12468
12936
|
url: `${baseUrl}/chatbot/agent/memory/update/${memoryId}`,
|
|
12469
12937
|
method: "PUT",
|
|
12470
12938
|
data,
|
|
@@ -12478,7 +12946,7 @@ const editMemory = async (baseUrl, memoryId, data) => {
|
|
|
12478
12946
|
};
|
|
12479
12947
|
const deleteMemory = async (baseUrl, memoryId) => {
|
|
12480
12948
|
try {
|
|
12481
|
-
let response = await
|
|
12949
|
+
let response = await httpRequest({
|
|
12482
12950
|
url: `${baseUrl}/chatbot/agent/memory/delete/${memoryId}`,
|
|
12483
12951
|
method: "DELETE",
|
|
12484
12952
|
});
|
|
@@ -12842,11 +13310,11 @@ function UploadModal(props) {
|
|
|
12842
13310
|
const useStyles$2 = makeStyles(() => ({
|
|
12843
13311
|
input: {
|
|
12844
13312
|
width: "100%",
|
|
12845
|
-
padding: `${pxToRem
|
|
13313
|
+
padding: `${pxToRem(8)} ${pxToRem(12)}`,
|
|
12846
13314
|
fontFamily: "Manrope",
|
|
12847
|
-
fontSize: pxToRem
|
|
12848
|
-
border: `${pxToRem
|
|
12849
|
-
borderRadius: pxToRem
|
|
13315
|
+
fontSize: pxToRem(14),
|
|
13316
|
+
border: `${pxToRem(1)} solid ${colours.neutralBorder}`,
|
|
13317
|
+
borderRadius: pxToRem(4),
|
|
12850
13318
|
outline: "none",
|
|
12851
13319
|
boxSizing: "border-box",
|
|
12852
13320
|
},
|
|
@@ -13023,6 +13491,219 @@ var SvgClearFilter = function SvgClearFilter(props) {
|
|
|
13023
13491
|
})))));
|
|
13024
13492
|
};
|
|
13025
13493
|
|
|
13494
|
+
// Internalized constants (were from config/constants)
|
|
13495
|
+
const DEFAULT_DATE_FORMAT = "MM/DD/YYYY";
|
|
13496
|
+
const START_DATE = "2000-01-01";
|
|
13497
|
+
const END_DATE = "2050-12-31";
|
|
13498
|
+
const useStyles$1 = makeStyles$1((theme) => ({
|
|
13499
|
+
monthYearDropDown: {
|
|
13500
|
+
display: "inline-flex",
|
|
13501
|
+
},
|
|
13502
|
+
styledSelect: {
|
|
13503
|
+
border: "none",
|
|
13504
|
+
margin: "0 0.5rem",
|
|
13505
|
+
outline: "none",
|
|
13506
|
+
...theme.typography.subtitle1,
|
|
13507
|
+
fontWeight: 600,
|
|
13508
|
+
},
|
|
13509
|
+
}));
|
|
13510
|
+
/**
|
|
13511
|
+
*
|
|
13512
|
+
* @param {moment} startDate
|
|
13513
|
+
* @param {moment} endDate
|
|
13514
|
+
* @param {string} disableType
|
|
13515
|
+
* @returns year
|
|
13516
|
+
*
|
|
13517
|
+
* This function takes in start date, end date and disable type as parameters
|
|
13518
|
+
* and based on the disable type conditions, it will return the current year,
|
|
13519
|
+
* from the calendar rendering should start
|
|
13520
|
+
*
|
|
13521
|
+
* For ex: if the dates are past disabled, we will either start rendering the calendar from
|
|
13522
|
+
* the start date year or if start date is not mentioned, we will render from the present year
|
|
13523
|
+
* Similarly if we have future disabled, we will either end rendering the calendar from the
|
|
13524
|
+
* end date year or if end date is not mentioned, we will render till the present year
|
|
13525
|
+
*/
|
|
13526
|
+
const getCurrentYear = (startDate, endDate, disableType) => {
|
|
13527
|
+
//If it is past disabled and we have a valid start date
|
|
13528
|
+
if (disableType &&
|
|
13529
|
+
disableType?.includes("Past") &&
|
|
13530
|
+
moment(startDate).isValid()) {
|
|
13531
|
+
return moment(startDate).year(); //return start date year
|
|
13532
|
+
}
|
|
13533
|
+
//If it is future disabled and we have a valid end date
|
|
13534
|
+
if (disableType &&
|
|
13535
|
+
disableType?.includes("Future") &&
|
|
13536
|
+
moment(endDate).isValid()) {
|
|
13537
|
+
return moment(endDate).year(); //return end date year
|
|
13538
|
+
}
|
|
13539
|
+
return moment().year(); //else return present date year
|
|
13540
|
+
};
|
|
13541
|
+
const DateRangePickerComponent = (props) => {
|
|
13542
|
+
useStyles$1();
|
|
13543
|
+
const [focusedInput, setfocusedInput] = useState(null);
|
|
13544
|
+
const [yearArray, setyearArray] = useState([moment().year()]);
|
|
13545
|
+
const [startDate, setStartDate] = useState(props.startDate);
|
|
13546
|
+
const [endDate, setEndDate] = useState(props.endDate);
|
|
13547
|
+
const [reset, setReset] = useState(false);
|
|
13548
|
+
// Read tenantDateFormat from props first, fallback to localStorage
|
|
13549
|
+
const tenantDateFormat = props.tenantDateFormat ||
|
|
13550
|
+
(typeof localStorage !== "undefined"
|
|
13551
|
+
? localStorage.getItem("tenantDateFormat")
|
|
13552
|
+
: null) ||
|
|
13553
|
+
DEFAULT_DATE_FORMAT;
|
|
13554
|
+
useEffect(() => {
|
|
13555
|
+
if ((startDate && props.startDate && startDate.diff(props.startDate)) ||
|
|
13556
|
+
(endDate && props.endDate && endDate.diff(props.endDate)) ||
|
|
13557
|
+
(!startDate && props.startDate) ||
|
|
13558
|
+
(!endDate && props.endDate)) {
|
|
13559
|
+
setStartDate(props.startDate);
|
|
13560
|
+
setEndDate(props.endDate);
|
|
13561
|
+
}
|
|
13562
|
+
else if (isNull(props.startDate) &&
|
|
13563
|
+
isNull(props.endDate) &&
|
|
13564
|
+
!isNull(startDate) &&
|
|
13565
|
+
!isNull(endDate)) {
|
|
13566
|
+
setStartDate(null);
|
|
13567
|
+
setEndDate(null);
|
|
13568
|
+
}
|
|
13569
|
+
}, [props.startDate, props.endDate]);
|
|
13570
|
+
const configureYear = () => {
|
|
13571
|
+
const startYear = props.startDate
|
|
13572
|
+
? props.startDate.isBefore(props.startYear)
|
|
13573
|
+
: props.startYear;
|
|
13574
|
+
const currentYearBasedOnDate = getCurrentYear(startYear, props.endDate, props.disableType);
|
|
13575
|
+
let yearArr = [currentYearBasedOnDate];
|
|
13576
|
+
//till 2050, it will add all the years
|
|
13577
|
+
for (let i = 0; i < 2050 - currentYearBasedOnDate; i++) {
|
|
13578
|
+
if (props.disableType && props.disableType.includes("Future")) {
|
|
13579
|
+
yearArr.push(yearArr[i] - 1);
|
|
13580
|
+
}
|
|
13581
|
+
else {
|
|
13582
|
+
yearArr.push(yearArr[i] + 1);
|
|
13583
|
+
}
|
|
13584
|
+
}
|
|
13585
|
+
if (props.startYear) {
|
|
13586
|
+
// Start year from 2019 incase of cluster plan
|
|
13587
|
+
let startYear = props.startYear;
|
|
13588
|
+
let pastYearArray = [];
|
|
13589
|
+
while (startYear < yearArr[0]) {
|
|
13590
|
+
pastYearArray.push(startYear);
|
|
13591
|
+
startYear++;
|
|
13592
|
+
}
|
|
13593
|
+
yearArr.unshift(...pastYearArray);
|
|
13594
|
+
}
|
|
13595
|
+
const currentYear = moment().year();
|
|
13596
|
+
if (!yearArr.includes(currentYear)) {
|
|
13597
|
+
yearArr.unshift(currentYear);
|
|
13598
|
+
}
|
|
13599
|
+
setyearArray(yearArr);
|
|
13600
|
+
};
|
|
13601
|
+
const isOutsideRange = (day) => {
|
|
13602
|
+
switch (props.disableType) {
|
|
13603
|
+
case "disableOnlyPast":
|
|
13604
|
+
//disables strictly past i.e current/today's date is not included
|
|
13605
|
+
return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isBefore(moment().format(DEFAULT_DATE_FORMAT)));
|
|
13606
|
+
case "disablePast":
|
|
13607
|
+
//disables past i.e current/today's date is included
|
|
13608
|
+
return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isSame(moment().format(DEFAULT_DATE_FORMAT), "days") ||
|
|
13609
|
+
moment(day.format(DEFAULT_DATE_FORMAT)).isBefore(moment().format(DEFAULT_DATE_FORMAT)));
|
|
13610
|
+
case "disableOnlyFuture":
|
|
13611
|
+
//disables strictly future i.e current/today's date is not included
|
|
13612
|
+
return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isAfter(moment().format(DEFAULT_DATE_FORMAT)));
|
|
13613
|
+
case "disableFuture":
|
|
13614
|
+
//disables future i.e current/today's date is included
|
|
13615
|
+
return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isSame(moment().format(DEFAULT_DATE_FORMAT), "days") ||
|
|
13616
|
+
moment(day.format(DEFAULT_DATE_FORMAT)).isAfter(moment().format(DEFAULT_DATE_FORMAT)));
|
|
13617
|
+
case "customRange":
|
|
13618
|
+
//we can pass custom range which evaluates if the date to be disabled or not
|
|
13619
|
+
//For example: disabling specific dates or only fridays etc..
|
|
13620
|
+
return props.customOutsideRange(day);
|
|
13621
|
+
default:
|
|
13622
|
+
//By default, it doesn't disable any date
|
|
13623
|
+
return false;
|
|
13624
|
+
}
|
|
13625
|
+
};
|
|
13626
|
+
const dateRangeCalculator = async (startDate, endDate) => {
|
|
13627
|
+
/**
|
|
13628
|
+
* If the date selection is weekly, we keep start date as starting day of the week,
|
|
13629
|
+
* i.e if we select a day, we return the output as starting day in that week
|
|
13630
|
+
*/
|
|
13631
|
+
let weekStart = props.weeklySelection
|
|
13632
|
+
? moment(startDate).startOf("week")
|
|
13633
|
+
: startDate;
|
|
13634
|
+
/**
|
|
13635
|
+
* If we make the date selection as weekly
|
|
13636
|
+
* End date would be end of the week but if the end date
|
|
13637
|
+
* is outside the range i.e future including today, we set
|
|
13638
|
+
* enddate as one day prior to today i.e subtract 1 day from today
|
|
13639
|
+
* We also make sure if the endDate is either null or invalid, we don't check for outside range
|
|
13640
|
+
*/
|
|
13641
|
+
const validEndDate = endDate &&
|
|
13642
|
+
endDate.isValid() &&
|
|
13643
|
+
isOutsideRange(moment(endDate).endOf("week"))
|
|
13644
|
+
? moment().subtract(1, "days")
|
|
13645
|
+
: moment(endDate).endOf("week");
|
|
13646
|
+
let weekEnd = props.weeklySelection ? validEndDate : endDate;
|
|
13647
|
+
if (weekStart && !weekStart.isValid()) {
|
|
13648
|
+
weekStart = null;
|
|
13649
|
+
}
|
|
13650
|
+
if (weekEnd && !weekEnd.isValid()) {
|
|
13651
|
+
weekEnd = null;
|
|
13652
|
+
}
|
|
13653
|
+
//If we clear, both weekStart and weekEnd will become null
|
|
13654
|
+
//Then we shift the month and year to current date
|
|
13655
|
+
if (!weekStart && !weekEnd) {
|
|
13656
|
+
await setTimeout(() => {
|
|
13657
|
+
}, 100);
|
|
13658
|
+
}
|
|
13659
|
+
props.onDatesChange(weekStart, weekEnd);
|
|
13660
|
+
};
|
|
13661
|
+
const isDayBlocked = (date) => {
|
|
13662
|
+
if (focusedInput === "startDate") {
|
|
13663
|
+
return (props.enabledStartDays &&
|
|
13664
|
+
!props.enabledStartDays.includes(moment(date).format("dddd")));
|
|
13665
|
+
}
|
|
13666
|
+
if (focusedInput === "endDate") {
|
|
13667
|
+
return (props.enabledEndDays &&
|
|
13668
|
+
!props.enabledEndDays.includes(moment(date).format("dddd")));
|
|
13669
|
+
}
|
|
13670
|
+
return false;
|
|
13671
|
+
};
|
|
13672
|
+
useEffect(() => {
|
|
13673
|
+
configureYear();
|
|
13674
|
+
}, []);
|
|
13675
|
+
useEffect(() => {
|
|
13676
|
+
if (props.resetOptions) {
|
|
13677
|
+
setStartDate(null);
|
|
13678
|
+
setEndDate(null);
|
|
13679
|
+
}
|
|
13680
|
+
}, [props.resetOptions]);
|
|
13681
|
+
const defaultYears = useMemo(() => {
|
|
13682
|
+
const startYear = Number(START_DATE.split("-")[0]);
|
|
13683
|
+
const endYear = Number(END_DATE.split("-")[0]);
|
|
13684
|
+
return Array.from({ length: endYear - startYear + 1 }, (_, index) => ({
|
|
13685
|
+
label: String(startYear + index),
|
|
13686
|
+
value: String(startYear + index),
|
|
13687
|
+
}));
|
|
13688
|
+
}, []); // Only calculate once
|
|
13689
|
+
const yearList = props?.customYears ?? defaultYears;
|
|
13690
|
+
useEffect(() => {
|
|
13691
|
+
if (props?.extra?.autoApplyDateRange && !reset) {
|
|
13692
|
+
dateRangeCalculator(startDate, endDate);
|
|
13693
|
+
}
|
|
13694
|
+
}, [startDate, endDate]);
|
|
13695
|
+
return (jsx("div", { id: "dateRangePicker", children: jsx(DateRangePicker, { label: props?.label || "", placeholder: props?.placeholder || "", setStartDate: setStartDate, setEndDate: setEndDate, startDate: startDate, endDate: endDate, isDisabled: props.disabled, showClearDates: true, displayFormat: tenantDateFormat, startDateId: props.startDateId || "startDate", endDateId: props.endDateId || "endDate", withPortal: !props.noPortal, isOutsideRange: isOutsideRange, isDayBlocked: isDayBlocked, autoFocus: true, showMonthYearSelect: true, isRequired: props.isRequired, onPrimaryButtonClick: () => dateRangeCalculator(startDate, endDate), onSecondaryButtonClick: () => {
|
|
13696
|
+
setStartDate(null);
|
|
13697
|
+
setEndDate(null);
|
|
13698
|
+
}, onResetClick: () => {
|
|
13699
|
+
setStartDate(null);
|
|
13700
|
+
setEndDate(null);
|
|
13701
|
+
setReset(true);
|
|
13702
|
+
dateRangeCalculator(null, null);
|
|
13703
|
+
setTimeout(() => setReset(false), 0);
|
|
13704
|
+
}, customYears: yearList, hideKeyboardShortcutsPanel: true, enabledStartDays: props.enabledStartDays, enabledEndDays: props.enabledEndDays, handleStartDateFocus: () => setfocusedInput("startDate"), handleEndDateFocus: () => setfocusedInput("endDate"), isAgGridCellRenderer: props?.isAgGridCellRenderer, labelOrientation: props?.labelOrientation || "top" }) }));
|
|
13705
|
+
};
|
|
13706
|
+
|
|
13026
13707
|
/**
|
|
13027
13708
|
* Component to render filter value input based on display_type
|
|
13028
13709
|
* This component handles different field types similar to form/index.jsx
|
|
@@ -13150,7 +13831,7 @@ const FilterValueInput = ({ filterConfig, value, onChange, options = [], isLoadi
|
|
|
13150
13831
|
const dateFormat = extra.dateFormat || "MM-DD-YYYY";
|
|
13151
13832
|
const disableType = extra.disableType || extra.disablePast ? "disablePast" : null;
|
|
13152
13833
|
const startYear = extra.startYear;
|
|
13153
|
-
return (jsx(
|
|
13834
|
+
return (jsx(DateRangePickerComponent, { label: filterConfig?.label || extra.label || "Select date range", startDateId: extra.startDateId || "start_date_id", endDateId: extra.endDateId || "end_date_id", showMonthYearSelect: extra.showMonthYearSelect !== false, startDate: localValue?.[0]
|
|
13154
13835
|
? moment.isMoment(localValue[0])
|
|
13155
13836
|
? localValue[0]
|
|
13156
13837
|
: moment(localValue[0]).isValid()
|
|
@@ -13303,7 +13984,7 @@ const fetchFilterValues = async (filterConfig, existingFilters = [], filterOptio
|
|
|
13303
13984
|
return {
|
|
13304
13985
|
// Show decoded label to the user, but keep the original
|
|
13305
13986
|
// encoded value (with __ia_char) for backend requests.
|
|
13306
|
-
label: replaceSpecialCharacter$
|
|
13987
|
+
label: replaceSpecialCharacter$2(stringValue),
|
|
13307
13988
|
value: stringValue,
|
|
13308
13989
|
};
|
|
13309
13990
|
});
|
|
@@ -13561,7 +14242,7 @@ const formatMentionDisplay = (filterName, values, maxVisible = 3) => {
|
|
|
13561
14242
|
const visibleValues = values.slice(0, maxVisible);
|
|
13562
14243
|
values.length - maxVisible;
|
|
13563
14244
|
// Decode any special character codes for display purposes only.
|
|
13564
|
-
const displayVisibleValues = visibleValues.map((v) => replaceSpecialCharacter(String(v)));
|
|
14245
|
+
const displayVisibleValues = visibleValues.map((v) => replaceSpecialCharacter$2(String(v)));
|
|
13565
14246
|
let display = `@${filterName}::${displayVisibleValues.join(",")}`;
|
|
13566
14247
|
return display;
|
|
13567
14248
|
};
|
|
@@ -13702,6 +14383,8 @@ const useMentionState = () => {
|
|
|
13702
14383
|
|
|
13703
14384
|
const ChatbotInput = (props) => {
|
|
13704
14385
|
const { newChatScreen, inputValue, setInputValue, isStopIcon, handleMicClick, handleRefresh, onSendIconClick, onStopIconClick, currentMode, filterOptions, onSaveClick, savedFilterSets, onFilterSetSelect, onTriggerRefresh, selectedFilterSet, onClearFilterSet, answerMode, setAnswerMode, } = props;
|
|
14386
|
+
const { components } = useChatbotDeps();
|
|
14387
|
+
const hasFilterComponent = !!components?.FilterComponent;
|
|
13705
14388
|
const editorRef = useRef(null);
|
|
13706
14389
|
const selectRef = useRef(null);
|
|
13707
14390
|
const filterSetSelectRef = useRef(null);
|
|
@@ -13744,7 +14427,7 @@ const ChatbotInput = (props) => {
|
|
|
13744
14427
|
// Decode special character placeholders only for the label shown
|
|
13745
14428
|
// to the user. The underlying value (used in payloads) remains
|
|
13746
14429
|
// unchanged so that backend continues to receive the ia_char codes.
|
|
13747
|
-
const label = replaceSpecialCharacter(rawLabel);
|
|
14430
|
+
const label = replaceSpecialCharacter$2(rawLabel);
|
|
13748
14431
|
// Handle duplicate labels
|
|
13749
14432
|
if (labelCount[label]) {
|
|
13750
14433
|
labelCount[label]++;
|
|
@@ -14697,7 +15380,7 @@ const ChatbotInput = (props) => {
|
|
|
14697
15380
|
*/
|
|
14698
15381
|
const handleSendMessage = () => {
|
|
14699
15382
|
// Decode any ia_char placeholders for display
|
|
14700
|
-
const formattedText = replaceSpecialCharacter(getFormattedTextForSending());
|
|
15383
|
+
const formattedText = replaceSpecialCharacter$2(getFormattedTextForSending());
|
|
14701
15384
|
if (!formattedText.trim() && isEmpty$1(chatbotContext))
|
|
14702
15385
|
return;
|
|
14703
15386
|
// Extract user explicit input from mentions
|
|
@@ -15008,12 +15691,12 @@ const ChatbotInput = (props) => {
|
|
|
15008
15691
|
!target.closest(".answer-mode-wrapper")) {
|
|
15009
15692
|
editorRef.current.focus();
|
|
15010
15693
|
}
|
|
15011
|
-
}, children: jsxs("div", { className: `chat-input-wrapper ${isFixed ? "stacked" : ""} ${selectedFilterSet ? "has-filter-selected" : ""} ${(!isFixed || inputValue === "") && !newChatScreen && !selectedFilterSet ? "empty" : ""} ${!newChatScreen && !isFixed && !selectedFilterSet ? "single-line-textarea" : ""}`, style: { height }, children: [jsxs("div", { className: "chat-input-left-actions", children: [jsxs("div", { className: "filter-set-trigger-wrapper", ref: filterSetSelectRef, children: [jsx(Tooltip, { title: hasMentionsInEditor || showMentionSelect ? "Cannot use filter set while @ mentions are active" : "Add filter set", children: jsx("button", { type: "button", className: `filter-set-plus-btn${hasMentionsInEditor || showMentionSelect ? " disabled" : ""}`, onClick: () => {
|
|
15694
|
+
}, children: jsxs("div", { className: `chat-input-wrapper ${isFixed ? "stacked" : ""} ${selectedFilterSet ? "has-filter-selected" : ""} ${(!isFixed || inputValue === "") && !newChatScreen && !selectedFilterSet ? "empty" : ""} ${!newChatScreen && !isFixed && !selectedFilterSet ? "single-line-textarea" : ""}`, style: { height }, children: [hasFilterComponent && (jsxs("div", { className: "chat-input-left-actions", children: [jsxs("div", { className: "filter-set-trigger-wrapper", ref: filterSetSelectRef, children: [jsx(Tooltip, { title: hasMentionsInEditor || showMentionSelect ? "Cannot use filter set while @ mentions are active" : "Add filter set", children: jsx("button", { type: "button", className: `filter-set-plus-btn${hasMentionsInEditor || showMentionSelect ? " disabled" : ""}`, onClick: () => {
|
|
15012
15695
|
if (hasMentionsInEditor || showMentionSelect)
|
|
15013
15696
|
return;
|
|
15014
15697
|
setShowFilterSetMenu(!showFilterSetMenu);
|
|
15015
15698
|
setIsFilterSetMenuOpen(!showFilterSetMenu);
|
|
15016
|
-
}, children: jsx(SvgAddFilter, {}) }) }), showFilterSetMenu && (jsx("div", { className: "filter-set-select-dropdown", children: jsx(Select, { currentOptions: filterSetMenuOptions, setCurrentOptions: () => { }, initialOptions: filterSetMenuOptions, placeholder: "Select...", handleChange: handleFilterSetMenuChange, isOpen: isFilterSetMenuOpen, setIsOpen: setIsFilterSetMenuOpen, selectedOptions: filterSetSelectedOptions, setSelectedOptions: () => { }, isCloseWhenClickOutside: false, isWithSearch: false, isMulti: false, disabled: false, isLoading: false, emptyMessage: "No options" }) }))] }), selectedFilterSet && (jsxs("div", { className: "filter-set-chip", children: [jsx(SvgFilterFolder, { className: "filter-set-chip-icon" }), jsx("span", { className: "filter-set-chip-label", children: selectedFilterSet.name || selectedFilterSet.label }), jsx("button", { type: "button", className: "filter-set-chip-clear", onClick: () => onClearFilterSet?.(), children: jsx(SvgClearFilter, {}) })] }))] }), jsx("div", { ref: editorRef, className: "chat-input-editor", contentEditable: true, tabIndex: 0, role: "textbox", "aria-label": "Ask anything...", "aria-multiline": "true", "data-placeholder": "Ask anything...", onInput: handleInput, onKeyDown: (e) => {
|
|
15699
|
+
}, children: jsx(SvgAddFilter, {}) }) }), showFilterSetMenu && (jsx("div", { className: "filter-set-select-dropdown", children: jsx(Select, { currentOptions: filterSetMenuOptions, setCurrentOptions: () => { }, initialOptions: filterSetMenuOptions, placeholder: "Select...", handleChange: handleFilterSetMenuChange, isOpen: isFilterSetMenuOpen, setIsOpen: setIsFilterSetMenuOpen, selectedOptions: filterSetSelectedOptions, setSelectedOptions: () => { }, isCloseWhenClickOutside: false, isWithSearch: false, isMulti: false, disabled: false, isLoading: false, emptyMessage: "No options" }) }))] }), selectedFilterSet && (jsxs("div", { className: "filter-set-chip", children: [jsx(SvgFilterFolder, { className: "filter-set-chip-icon" }), jsx("span", { className: "filter-set-chip-label", children: selectedFilterSet.name || selectedFilterSet.label }), jsx("button", { type: "button", className: "filter-set-chip-clear", onClick: () => onClearFilterSet?.(), children: jsx(SvgClearFilter, {}) })] }))] })), jsx("div", { ref: editorRef, className: "chat-input-editor", contentEditable: true, tabIndex: 0, role: "textbox", "aria-label": "Ask anything...", "aria-multiline": "true", "data-placeholder": "Ask anything...", onInput: handleInput, onKeyDown: (e) => {
|
|
15017
15700
|
if (e.key === "Escape") {
|
|
15018
15701
|
// Don't handle Escape for date range picker - it has its own Cancel button
|
|
15019
15702
|
if (showMentionSelect) {
|
|
@@ -15162,7 +15845,7 @@ const ChatbotInput = (props) => {
|
|
|
15162
15845
|
top: `680px`,
|
|
15163
15846
|
left: `${dropdownPosition.left}px`,
|
|
15164
15847
|
zIndex: 10000,
|
|
15165
|
-
}, children: jsx(
|
|
15848
|
+
}, children: jsx(DateRangePickerComponent
|
|
15166
15849
|
// disableType="disableOnlyPast"
|
|
15167
15850
|
, {
|
|
15168
15851
|
// disableType="disableOnlyPast"
|
|
@@ -15774,185 +16457,6 @@ const useConversationManagement = (chatDataRef, currentMode, activeConversationI
|
|
|
15774
16457
|
};
|
|
15775
16458
|
};
|
|
15776
16459
|
|
|
15777
|
-
const useStyles$1 = makeStyles({
|
|
15778
|
-
container: {
|
|
15779
|
-
display: "flex",
|
|
15780
|
-
flexDirection: "column",
|
|
15781
|
-
alignItems: "center",
|
|
15782
|
-
justifyContent: "center",
|
|
15783
|
-
width: "100%",
|
|
15784
|
-
height: "100%",
|
|
15785
|
-
padding: "16px",
|
|
15786
|
-
boxSizing: "border-box",
|
|
15787
|
-
},
|
|
15788
|
-
icon: {
|
|
15789
|
-
flexShrink: 0,
|
|
15790
|
-
overflow: "visible",
|
|
15791
|
-
},
|
|
15792
|
-
title: {
|
|
15793
|
-
color: "#31416E",
|
|
15794
|
-
textAlign: "center",
|
|
15795
|
-
fontFamily: "Manrope",
|
|
15796
|
-
fontSize: "20px",
|
|
15797
|
-
fontStyle: "normal",
|
|
15798
|
-
fontWeight: 800,
|
|
15799
|
-
lineHeight: "150%",
|
|
15800
|
-
margin: 0,
|
|
15801
|
-
padding: "20px 0 0 0",
|
|
15802
|
-
},
|
|
15803
|
-
subtitle: {
|
|
15804
|
-
color: "#31416E",
|
|
15805
|
-
textAlign: "center",
|
|
15806
|
-
fontFamily: "Manrope",
|
|
15807
|
-
fontSize: "14px",
|
|
15808
|
-
fontStyle: "normal",
|
|
15809
|
-
fontWeight: 400,
|
|
15810
|
-
lineHeight: "160%",
|
|
15811
|
-
margin: 0,
|
|
15812
|
-
padding: 0,
|
|
15813
|
-
},
|
|
15814
|
-
buttonWrapper: {
|
|
15815
|
-
marginTop: "16px",
|
|
15816
|
-
},
|
|
15817
|
-
hidden: {
|
|
15818
|
-
display: "none",
|
|
15819
|
-
},
|
|
15820
|
-
});
|
|
15821
|
-
const ChatbotSaveFilterComponent = (props) => {
|
|
15822
|
-
const classes = useStyles$1();
|
|
15823
|
-
const { savedFilterSets, partialClose, chatBotWidth } = props;
|
|
15824
|
-
const [showFilter, setShowFilter] = useState(!isEmpty$1(savedFilterSets));
|
|
15825
|
-
/**
|
|
15826
|
-
* onFilterDashboardClick function is called when we click the apply filter
|
|
15827
|
-
* button in the select filter option
|
|
15828
|
-
* @param {object} dependencyData
|
|
15829
|
-
*/
|
|
15830
|
-
const onFilterDashboardClick = async (dependencyData) => {
|
|
15831
|
-
console.log("dependencyData4321", dependencyData);
|
|
15832
|
-
};
|
|
15833
|
-
const setChatbotFilterConfiguration = async (screenName) => {
|
|
15834
|
-
if (isEmpty$1(props.chatbotFilterDashboardConfiguration)) {
|
|
15835
|
-
const data = await fetchFilterFieldValues("Chatbot", props.savedFilterSelection);
|
|
15836
|
-
if (isEmpty$1(props.filterDashboardConfiguration)) {
|
|
15837
|
-
let filterConfigData = [
|
|
15838
|
-
{
|
|
15839
|
-
filterDashboardData: data,
|
|
15840
|
-
isCrossDimensionFilter: false,
|
|
15841
|
-
screen_name: screenName,
|
|
15842
|
-
},
|
|
15843
|
-
];
|
|
15844
|
-
const filterConfig = formattedFilterConfiguration("chatbotFilterConfiguration", filterConfigData, "Chatbot");
|
|
15845
|
-
props.setFilterConfiguration(filterConfig);
|
|
15846
|
-
}
|
|
15847
|
-
}
|
|
15848
|
-
};
|
|
15849
|
-
useEffect(() => {
|
|
15850
|
-
setChatbotFilterConfiguration("Chatbot");
|
|
15851
|
-
}, []);
|
|
15852
|
-
useEffect(() => {
|
|
15853
|
-
if (!isEmpty$1(savedFilterSets)) {
|
|
15854
|
-
setShowFilter(true);
|
|
15855
|
-
}
|
|
15856
|
-
}, [savedFilterSets]);
|
|
15857
|
-
useEffect(() => {
|
|
15858
|
-
const drawer = document.querySelector(".MuiModal-root.MuiDrawer-root");
|
|
15859
|
-
if (drawer) {
|
|
15860
|
-
drawer.style.display = partialClose ? "none" : "";
|
|
15861
|
-
}
|
|
15862
|
-
}, [partialClose]);
|
|
15863
|
-
useEffect(() => {
|
|
15864
|
-
if (!showFilter)
|
|
15865
|
-
return;
|
|
15866
|
-
const Z_INDEX = "9999";
|
|
15867
|
-
const patchDrawer = () => {
|
|
15868
|
-
const drawer = document.querySelector(".MuiModal-root.MuiDrawer-root");
|
|
15869
|
-
if (drawer && drawer.style.zIndex !== Z_INDEX) {
|
|
15870
|
-
drawer.style.zIndex = Z_INDEX;
|
|
15871
|
-
}
|
|
15872
|
-
if (drawer) {
|
|
15873
|
-
drawer.style.setProperty("position", "relative");
|
|
15874
|
-
}
|
|
15875
|
-
const mainContainer = document.querySelector(".impact-drawer-filter-main-container");
|
|
15876
|
-
if (mainContainer) {
|
|
15877
|
-
mainContainer.style.setProperty("flex-direction", "column", "important");
|
|
15878
|
-
}
|
|
15879
|
-
const leftPanel = document.querySelector(".impact_drawer_filter_container_left_panel");
|
|
15880
|
-
if (leftPanel) {
|
|
15881
|
-
leftPanel.style.setProperty("height", "50px");
|
|
15882
|
-
leftPanel.style.setProperty("background", "white");
|
|
15883
|
-
leftPanel.style.setProperty("border", "none");
|
|
15884
|
-
}
|
|
15885
|
-
const filterHeader = document.querySelector(".impact_drawer_filter_header");
|
|
15886
|
-
if (filterHeader) {
|
|
15887
|
-
filterHeader.style.setProperty("display", "none");
|
|
15888
|
-
}
|
|
15889
|
-
const filterTabs = document.querySelector(".impact_drawer_filter_left_filters_tabs");
|
|
15890
|
-
if (filterTabs) {
|
|
15891
|
-
filterTabs.style.setProperty("flex-direction", "row");
|
|
15892
|
-
filterTabs.style.setProperty("background", "white");
|
|
15893
|
-
}
|
|
15894
|
-
const filterContainer = document.querySelector(".impact_drawer_filter_container.impact_drawer_filter_container_large");
|
|
15895
|
-
if (filterContainer) {
|
|
15896
|
-
const computedWidth = chatBotWidth ? `${chatBotWidth - 86}px` : "616px";
|
|
15897
|
-
filterContainer.style.setProperty("width", computedWidth);
|
|
15898
|
-
}
|
|
15899
|
-
const rightPanel = document.querySelector(".impact_drawer_filter_container .impact_drawer_filter_container_right_panel");
|
|
15900
|
-
if (rightPanel) {
|
|
15901
|
-
rightPanel.style.setProperty("height", "600px");
|
|
15902
|
-
rightPanel.style.setProperty("width", "100%");
|
|
15903
|
-
}
|
|
15904
|
-
const backdrop = document.querySelector(".MuiBackdrop-root.MuiModal-backdrop");
|
|
15905
|
-
if (backdrop) {
|
|
15906
|
-
backdrop.style.setProperty("position", "unset");
|
|
15907
|
-
}
|
|
15908
|
-
const drawerPaper = document.querySelector(".MuiDrawer-paper.MuiDrawer-paperAnchorRight");
|
|
15909
|
-
if (drawerPaper) {
|
|
15910
|
-
drawerPaper.style.setProperty("box-shadow", "none");
|
|
15911
|
-
drawerPaper.style.setProperty("top", "110px");
|
|
15912
|
-
drawerPaper.style.setProperty("right", "3px");
|
|
15913
|
-
}
|
|
15914
|
-
const filterSeparator = document.querySelector(".impact-drawer-filter-separator");
|
|
15915
|
-
if (filterSeparator) {
|
|
15916
|
-
filterSeparator.style.setProperty("display", "none");
|
|
15917
|
-
}
|
|
15918
|
-
const paperRounded = document.querySelector(".MuiPaper-root.MuiPaper-elevation0.MuiPaper-rounded");
|
|
15919
|
-
if (paperRounded) {
|
|
15920
|
-
paperRounded.style.setProperty("margin-right", "24px");
|
|
15921
|
-
}
|
|
15922
|
-
const filterFooter = document.querySelector(".impact_drawer_filter_footer");
|
|
15923
|
-
if (filterFooter) {
|
|
15924
|
-
filterFooter.style.setProperty("bottom", "120px");
|
|
15925
|
-
filterFooter.style.setProperty("left", "0");
|
|
15926
|
-
}
|
|
15927
|
-
const filterBody = document.querySelector(".impact_drawer_filter_body.impact_drawer_filter_footer_no_buttons");
|
|
15928
|
-
if (filterBody) {
|
|
15929
|
-
filterBody.style.setProperty("padding-right", "40px");
|
|
15930
|
-
}
|
|
15931
|
-
};
|
|
15932
|
-
patchDrawer();
|
|
15933
|
-
const observer = new MutationObserver(patchDrawer);
|
|
15934
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
15935
|
-
return () => observer.disconnect();
|
|
15936
|
-
}, [showFilter, chatBotWidth]);
|
|
15937
|
-
return (jsx("div", { className: partialClose ? classes.hidden : undefined, children: !showFilter ?
|
|
15938
|
-
jsxs("div", { className: classes.container, children: [jsx(NoFilterSetSavedIcon, { width: "189px", height: "126px", className: classes.icon }), jsx("p", { className: classes.title, children: "No filter set saved!" }), jsx("p", { className: classes.subtitle, children: "Create and save a filter set to use as your default scope or apply it anytime during a conversation" }), jsx("div", { className: classes.buttonWrapper, children: jsx(Button, { variant: "primary", onClick: () => setShowFilter(true), children: "Create A Filter Set" }) })] }) :
|
|
15939
|
-
jsx("div", { children: jsx(CoreComponentScreen, { showPageHeader: false,
|
|
15940
|
-
// Filter dashboard props
|
|
15941
|
-
showFilterDashboard: true, filterConfigKey: "chatbotFilterConfiguration", onApplyFilter: onFilterDashboardClick, autoApplyEnabled: false, hideNoDataFound: true, defaultOpenModel: true }) }) }));
|
|
15942
|
-
};
|
|
15943
|
-
const mapStateToProps = (state) => {
|
|
15944
|
-
return {
|
|
15945
|
-
chatbotFilterDashboardConfiguration: state.filterReducer.filterDashboardConfiguration["chatbotFilterConfiguration"],
|
|
15946
|
-
savedFilterSelection: state.filterReducer.savedFilterSelection,
|
|
15947
|
-
};
|
|
15948
|
-
};
|
|
15949
|
-
const mapDispatchToProps = (dispatch) => {
|
|
15950
|
-
return {
|
|
15951
|
-
setFilterConfiguration: (filterConfiguration) => dispatch(setFilterConfiguration(filterConfiguration)),
|
|
15952
|
-
};
|
|
15953
|
-
};
|
|
15954
|
-
var ChatbotSaveFilterComponent$1 = connect(mapStateToProps, mapDispatchToProps)(ChatbotSaveFilterComponent);
|
|
15955
|
-
|
|
15956
16460
|
var _mask$1, _path$5, _path2$1, _defs$1;
|
|
15957
16461
|
function _extends$6() { return _extends$6 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$6.apply(null, arguments); }
|
|
15958
16462
|
var SvgMimimizedIconLogo = function SvgMimimizedIconLogo(props) {
|
|
@@ -16468,148 +16972,72 @@ const MinimizedChatWidget = ({ onExpand }) => {
|
|
|
16468
16972
|
return (jsxs("div", { className: classes.widgetContainer, onClick: handleExpandClick, children: [jsxs("div", { className: classes.widgetHeader, children: [jsxs("div", { className: classes.headerLeft, children: [jsx("div", { className: !isCompleted ? classes.headerIconLogoSpin : classes.headerIconLogo, children: jsx(SvgMimimizedIconLogo, {}) }), jsx("span", { className: classes.headerText, children: isCompleted ? "Action completed" : actionLabel }), !isCompleted && (jsx("div", { className: classes.warningIcon, children: jsx(SvgStepError, {}) }))] }), jsx("button", { className: classes.minimizeBtn, onClick: handleMinimizeClick, "aria-label": "Minimize", children: jsx(SvgMinimizeDashIcon, {}) })] }), jsx("div", { className: classes.widgetContent, children: jsxs("div", { className: stepStatus === "step_form" ? classes.innerContentStepForm : classes.innerContent, children: [jsxs("div", { className: classes.innerFirstRow, children: [jsx("span", { className: classes.stepHeaderText, title: stepHeader, children: stepHeader }), jsx("button", { className: classes.expandBtn, onClick: handleExpandClick, "aria-label": "Expand chatbot", children: jsx(SvgExpandFullscreenIcon, {}) })] }), stepSubHeader && (jsxs("div", { className: classes.innerSecondRow, children: [jsxs("div", { className: stepStatus === "step_form" ? classes.subHeaderPillStepForm : classes.subHeaderPill, children: [stepStatus === "step_form" ? (jsx("div", { className: classes.exclamationIcon, children: jsx(SvgExclamationIcon, {}) })) : !isCompleted && (jsx("div", { className: classes.loaderIcon, children: jsx(SvgLoadingCircle, {}) })), jsx("span", { className: classes.subHeaderText, title: stepSubHeader, children: stepSubHeader })] }), elapsedTime && (jsx("span", { className: classes.timeText, children: elapsedTime }))] }))] }) })] }));
|
|
16469
16973
|
};
|
|
16470
16974
|
|
|
16471
|
-
|
|
16472
|
-
|
|
16473
|
-
|
|
16474
|
-
|
|
16475
|
-
|
|
16476
|
-
|
|
16477
|
-
|
|
16478
|
-
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
|
|
16486
|
-
}
|
|
16487
|
-
|
|
16488
|
-
|
|
16489
|
-
|
|
16490
|
-
|
|
16491
|
-
|
|
16492
|
-
|
|
16493
|
-
|
|
16494
|
-
};
|
|
16495
|
-
|
|
16496
|
-
const PanelSection = ({ section }) => {
|
|
16497
|
-
const classes = useAllocationPanelStyles();
|
|
16498
|
-
if (!section)
|
|
16499
|
-
return null;
|
|
16500
|
-
const renderContent = () => {
|
|
16501
|
-
switch (section.content_type) {
|
|
16502
|
-
case "html":
|
|
16503
|
-
case "custom_html":
|
|
16504
|
-
return (jsx("div", { className: classes.panelHtmlContainer, children: jsx(HtmlContent, { bodyText: { content: section.content } }) }));
|
|
16505
|
-
case "structured":
|
|
16506
|
-
return jsx(StructuredComparison, { content: section.content });
|
|
16507
|
-
default:
|
|
16508
|
-
return null;
|
|
16509
|
-
}
|
|
16510
|
-
};
|
|
16511
|
-
return (jsxs(Accordion, { defaultExpanded: section.default_expanded, className: classes.sectionAccordion, disableGutters: true, children: [jsx(AccordionSummary, { expandIcon: jsx(ExpandMoreIcon, {}), className: classes.sectionSummary, children: jsx("span", { className: classes.sectionTitle, children: section.title }) }), jsx(AccordionDetails, { className: classes.sectionDetails, children: renderContent() })] }));
|
|
16512
|
-
};
|
|
16513
|
-
|
|
16514
|
-
const shiftChatbot = (panelEl) => {
|
|
16515
|
-
const chatbot = document.querySelector(".chatbot-component-container");
|
|
16516
|
-
if (!chatbot)
|
|
16517
|
-
return;
|
|
16518
|
-
const panelWidth = panelEl ? panelEl.offsetWidth : 0;
|
|
16519
|
-
const currentLeft = parseFloat(chatbot.style.left) || 0;
|
|
16520
|
-
chatbot.dataset.origLeft = chatbot.style.left;
|
|
16521
|
-
chatbot.style.transition = "left 0.3s ease";
|
|
16522
|
-
chatbot.style.left = (currentLeft - panelWidth) + "px";
|
|
16975
|
+
/**
|
|
16976
|
+
* SmartBot Redux reducer.
|
|
16977
|
+
* State shape and behaviour match the consumer's core/reducers/smartBotReducer.js exactly.
|
|
16978
|
+
*/
|
|
16979
|
+
const smartBotInitialState = {
|
|
16980
|
+
smartBotActive: false,
|
|
16981
|
+
isSmartBotRestricted: true,
|
|
16982
|
+
chatbotContext: {},
|
|
16983
|
+
thinkingContext: {
|
|
16984
|
+
thinkingContent: "",
|
|
16985
|
+
thinkingHeaderMessage: "Working for 0m:00s",
|
|
16986
|
+
streamStartTime: null,
|
|
16987
|
+
isStreamCompleted: false,
|
|
16988
|
+
finalElapsedSeconds: null,
|
|
16989
|
+
},
|
|
16990
|
+
heirarchyKeyValuePairs: {},
|
|
16991
|
+
currentAgentChatId: "",
|
|
16992
|
+
persistedFormValues: {},
|
|
16993
|
+
savedFilterSets: [],
|
|
16994
|
+
stepFormRestreamPayload: null,
|
|
16995
|
+
stepFormStreamData: null,
|
|
16996
|
+
minimizedStreamData: null,
|
|
16997
|
+
chatbotFilterOptions: [],
|
|
16523
16998
|
};
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
|
|
16531
|
-
|
|
16532
|
-
|
|
16533
|
-
|
|
16534
|
-
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
|
|
16999
|
+
function smartBotReducer(state = smartBotInitialState, action) {
|
|
17000
|
+
switch (action.type) {
|
|
17001
|
+
case SET_SMART_BOT_ACTIVE:
|
|
17002
|
+
return { ...state, smartBotActive: action.payload };
|
|
17003
|
+
case SET_IS_SMART_BOT_RESTRICTED:
|
|
17004
|
+
return { ...state, isSmartBotRestricted: action.payload };
|
|
17005
|
+
case SET_CHATBOT_CONTEXT:
|
|
17006
|
+
return { ...state, chatbotContext: action.payload };
|
|
17007
|
+
case SET_THINKING_CONTEXT:
|
|
17008
|
+
return { ...state, thinkingContext: action.payload };
|
|
17009
|
+
case SET_HIERARCHY_KEY_VALUE_PAIR:
|
|
17010
|
+
return { ...state, heirarchyKeyValuePairs: action.payload };
|
|
17011
|
+
case SET_CURRENT_AGENT_CHAT_ID:
|
|
17012
|
+
return { ...state, currentAgentChatId: action.payload };
|
|
17013
|
+
case SET_PERSISTED_FORM_VALUES:
|
|
17014
|
+
return {
|
|
17015
|
+
...state,
|
|
17016
|
+
persistedFormValues: {
|
|
17017
|
+
...state.persistedFormValues,
|
|
17018
|
+
...action.payload,
|
|
17019
|
+
},
|
|
17020
|
+
};
|
|
17021
|
+
case CLEAR_PERSISTED_FORM_VALUES:
|
|
17022
|
+
return { ...state, persistedFormValues: {} };
|
|
17023
|
+
case SET_SAVED_FILTER_SETS:
|
|
17024
|
+
return { ...state, savedFilterSets: action.payload };
|
|
17025
|
+
case SET_STEP_FORM_RESTREAM_PAYLOAD:
|
|
17026
|
+
return { ...state, stepFormRestreamPayload: action.payload };
|
|
17027
|
+
case SET_STEP_FORM_STREAM_DATA:
|
|
17028
|
+
return { ...state, stepFormStreamData: action.payload };
|
|
17029
|
+
case SET_MINIMIZED_STREAM_DATA:
|
|
17030
|
+
return { ...state, minimizedStreamData: action.payload };
|
|
17031
|
+
case SET_CHATBOT_FILTER_OPTIONS:
|
|
17032
|
+
return { ...state, chatbotFilterOptions: action.payload };
|
|
17033
|
+
default:
|
|
17034
|
+
return state;
|
|
16538
17035
|
}
|
|
16539
|
-
}
|
|
16540
|
-
const AllocationDetailPanel = () => {
|
|
16541
|
-
const classes = useAllocationPanelStyles();
|
|
16542
|
-
const [panelData, setPanelData] = useState(null);
|
|
16543
|
-
const [activeFooterAction, setActiveFooterAction] = useState(null);
|
|
16544
|
-
const [isExpanded, setIsExpanded] = useState(false);
|
|
16545
|
-
const panelRef = useRef(null);
|
|
16546
|
-
const handleOpen = useCallback((e) => {
|
|
16547
|
-
const { panelData: data } = e.detail || {};
|
|
16548
|
-
if (data) {
|
|
16549
|
-
setPanelData(data);
|
|
16550
|
-
}
|
|
16551
|
-
}, []);
|
|
16552
|
-
const handleClose = useCallback(() => {
|
|
16553
|
-
restoreChatbot();
|
|
16554
|
-
setPanelData(null);
|
|
16555
|
-
setIsExpanded(false);
|
|
16556
|
-
}, []);
|
|
16557
|
-
useEffect(() => {
|
|
16558
|
-
window.addEventListener("openAllocationDetailPanel", handleOpen);
|
|
16559
|
-
window.addEventListener("closeAllocationDetailPanel", handleClose);
|
|
16560
|
-
return () => {
|
|
16561
|
-
window.removeEventListener("openAllocationDetailPanel", handleOpen);
|
|
16562
|
-
window.removeEventListener("closeAllocationDetailPanel", handleClose);
|
|
16563
|
-
};
|
|
16564
|
-
}, [handleOpen, handleClose]);
|
|
16565
|
-
// Shift the chatbot once the panel has rendered
|
|
16566
|
-
useEffect(() => {
|
|
16567
|
-
if (panelData && panelRef.current) {
|
|
16568
|
-
// Use requestAnimationFrame to ensure the panel is laid out
|
|
16569
|
-
requestAnimationFrame(() => {
|
|
16570
|
-
shiftChatbot(panelRef.current);
|
|
16571
|
-
});
|
|
16572
|
-
}
|
|
16573
|
-
}, [panelData]);
|
|
16574
|
-
// Listen for direct clicks on the impact-ui collapse button
|
|
16575
|
-
useEffect(() => {
|
|
16576
|
-
if (!panelData)
|
|
16577
|
-
return;
|
|
16578
|
-
const collapseBtn = document.querySelector('button[aria-label="Collapse chatbot"]');
|
|
16579
|
-
if (!collapseBtn)
|
|
16580
|
-
return;
|
|
16581
|
-
const onCollapse = () => handleClose();
|
|
16582
|
-
collapseBtn.addEventListener("click", onCollapse);
|
|
16583
|
-
return () => collapseBtn.removeEventListener("click", onCollapse);
|
|
16584
|
-
}, [panelData, handleClose]);
|
|
16585
|
-
if (!panelData)
|
|
16586
|
-
return null;
|
|
16587
|
-
const footerActions = panelData.footer_actions || [
|
|
16588
|
-
{ label: "Purge", variant: "outlined", action: "purge", options: [] },
|
|
16589
|
-
{ label: "Finalize Plan", variant: "primary", action: "finalize", options: [] },
|
|
16590
|
-
];
|
|
16591
|
-
const handleOptionClick = (option) => {
|
|
16592
|
-
setActiveFooterAction(null);
|
|
16593
|
-
window.dispatchEvent(new CustomEvent("allocationPanelAction", {
|
|
16594
|
-
detail: { value: option.value, label: option.label },
|
|
16595
|
-
}));
|
|
16596
|
-
};
|
|
16597
|
-
const handleFooterBtnClick = (btn) => {
|
|
16598
|
-
if (btn.options && btn.options.length > 0) {
|
|
16599
|
-
setActiveFooterAction(activeFooterAction === btn.action ? null : btn.action);
|
|
16600
|
-
}
|
|
16601
|
-
else {
|
|
16602
|
-
console.log("[AllocationPanel] footer action:", btn.action);
|
|
16603
|
-
}
|
|
16604
|
-
};
|
|
16605
|
-
const panel = (jsxs("div", { ref: panelRef, className: `${classes.panelContainer} ${isExpanded ? classes.panelExpanded : ""}`, "data-testid": "allocation-detail-panel", children: [jsx(PanelHeader, { title: panelData.title, actions: panelData.actions || {}, onClose: handleClose, isExpanded: isExpanded, onToggleExpand: () => setIsExpanded((prev) => !prev) }), jsxs("div", { className: classes.panelScrollBody, children: [jsx(ReportSummaryCard, { reportSummary: panelData.report_summary }), (panelData.sections || []).map((section) => (jsx(PanelSection, { section: section }, section.id)))] }), jsxs("div", { className: classes.panelFooter, children: [activeFooterAction && (jsx("div", { className: classes.optionsCard, children: footerActions
|
|
16606
|
-
.find((a) => a.action === activeFooterAction)
|
|
16607
|
-
?.options?.map((opt, idx) => (jsxs("button", { className: classes.optionRow, onClick: () => handleOptionClick(opt), children: [jsx("span", { className: classes.optionIcon, children: "\u2606" }), opt.label] }, idx))) })), footerActions.map((btn, idx) => (jsx("button", { className: btn.variant === "primary" ? classes.footerBtnPrimary : classes.footerBtnOutlined, onClick: () => handleFooterBtnClick(btn), children: btn.label }, idx)))] })] }));
|
|
16608
|
-
return createPortal(panel, document.body);
|
|
16609
|
-
};
|
|
17036
|
+
}
|
|
16610
17037
|
|
|
16611
17038
|
const SmartBot = (props) => {
|
|
16612
17039
|
const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
|
|
17040
|
+
const { callbacks, components, selectors } = useChatbotDeps();
|
|
16613
17041
|
const { showModal, setShowModal, minimizedMode, setMinimizedMode, userInput, setUserInput, position, setPosition, flowType, setFlowType, screenName, setScreenName, questionIndex, setQuestionIndex, currentAppLink, setCurrentAppLink, loader, setLoader, enableRefreshAction, setEnableRefreshAction, refreshLoader, setRefreshLoader, chatDataState, setChatDataState, showExtendedContent, setShowExtendedContent, currentMode, setCurrentMode, selectedModule, setSelectedModule, isCardVisible, setIsCardVisible, templateData, setTemplateData, showAlert, setShowAlert, grabPositionRef, chatDataRef, chatBodyRef, minimizedBtnRef, chatDataScreenLinkRef, navigate, location, dispatch, globalClasses, classes, dateFormat, filterReducerState, activeConversationId, setActiveConversationId, isModuleChanged, setIsModuleChanged, showChatPlaceholder, setShowChatPlaceholder, currentAgentId, setCurrentAgentId, baseUrl = customBaseUrl, setBaseUrl, currentSessionId, setCurrentSessionId, notificationData, agentTaskCompleted, setAgentTaskCompleted, customChatConfig, setCustomChatConfig, setMiddleWareFunction, chatBotInfoRef, chatDataInfoRef, initValue, setInitValue, sessionId, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, legacyAgentScreen, setLegacyAgentScreen, uniqueChatId, setUniqueChatId, fieldNumber, setFieldNumber, thinkingContext, isModalOpen, setIsModalOpen, utilityList, setUtilityList, isUploadModalOpen, setIsUploadModalOpen, isRefreshTriggered, setIsRefreshTriggered, additionalArgs, setAdditionalArgs, showSavedFilters, setShowSavedFilters, navSessionId, setNavSessionId, renameOpen, setRenameOpen, renameTargetId, setRenameTargetId, renameValue, setRenameValue, deleteOpen, setDeleteOpen, deleteTargetId, setDeleteTargetId, } = useChatState();
|
|
16614
17042
|
// Add state for confirmation dialogs
|
|
16615
17043
|
useState(false);
|
|
@@ -16618,7 +17046,7 @@ const SmartBot = (props) => {
|
|
|
16618
17046
|
useState(false);
|
|
16619
17047
|
const [conversation, setConversation] = useState({});
|
|
16620
17048
|
const { chatbotContext, currentAgentChatId, minimizedStreamData } = useSelector((state) => state.smartBotReducer);
|
|
16621
|
-
const savedFilterDashboard = useSelector(
|
|
17049
|
+
const savedFilterDashboard = useSelector(selectors?.getSavedFilterDashboard ?? NULL_SELECTOR);
|
|
16622
17050
|
// Per-mode conversation ID tracking — prevents cross-mode contamination when
|
|
16623
17051
|
// switching tabs while streams are pending.
|
|
16624
17052
|
useRef({});
|
|
@@ -16648,7 +17076,7 @@ const SmartBot = (props) => {
|
|
|
16648
17076
|
useRef(0);
|
|
16649
17077
|
const { setUserFlow, setUserScreenAndFlow, fetchUserResultsFromQuery, getCurrentDateTimeString, setLink, } = useChatFlow(chatDataRef, setLoader, setFlowType, setScreenName, setUserInput, setQuestionIndex, setCurrentAppLink, flowType, screenName, questionIndex, userInput, dateFormat, currentMode, activeConversationId, setIsModuleChanged, chatBodyRef, filterReducerState, dispatch, navigate, setShowChatPlaceholder, baseUrl, setChatDataState, setCurrentSessionId, customChatConfig, chatDataInfoRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, initValue, sessionId, fieldNumber, setFieldNumber, additionalArgs, setActiveConversationId, navSessionId, setNavSessionId, setUniqueChatId, setAdditionalArgs, answerMode);
|
|
16650
17078
|
const { parseSavedFlow, saveCurrentChanges, endCurrentSession, clearChatSession, initiateNewChat, hasUnsavedChanges, } = useChatSession(chatDataRef, setFlowType, setScreenName, setUserInput, setTemplateData, chatDataScreenLinkRef, setShowModal, setMinimizedMode, setSelectedModule, setChatDataState, currentMode, setUserFlow, getCurrentDateTimeString, setCurrentAppLink, selectedModule, fetchUserResultsFromQuery, props.closeBot, activeConversationId, setActiveConversationId, setShowChatPlaceholder);
|
|
16651
|
-
const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction
|
|
17079
|
+
const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction);
|
|
16652
17080
|
const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
|
|
16653
17081
|
setChatDataState,
|
|
16654
17082
|
activeConversationId,
|
|
@@ -16735,7 +17163,6 @@ const SmartBot = (props) => {
|
|
|
16735
17163
|
// Minimize the chat window when the user follows an in-app link from a bot response
|
|
16736
17164
|
const handleMinimizeRequest = () => {
|
|
16737
17165
|
setPartialClose(true);
|
|
16738
|
-
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
16739
17166
|
};
|
|
16740
17167
|
window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
|
|
16741
17168
|
window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
|
|
@@ -16794,8 +17221,7 @@ const SmartBot = (props) => {
|
|
|
16794
17221
|
let accessDataResponse = await getModuleLevelAccessUtility({
|
|
16795
17222
|
app: applicationName,
|
|
16796
17223
|
module: ["Chatbot Upload"],
|
|
16797
|
-
|
|
16798
|
-
})();
|
|
17224
|
+
});
|
|
16799
17225
|
if (!isEmpty$1(accessDataResponse)) {
|
|
16800
17226
|
setUtilityList([
|
|
16801
17227
|
...utilityList,
|
|
@@ -16846,8 +17272,7 @@ const SmartBot = (props) => {
|
|
|
16846
17272
|
let accessDataResponse = await getModuleLevelAccessUtility({
|
|
16847
17273
|
app: applicationName,
|
|
16848
17274
|
module: ["ChatbotAgent"],
|
|
16849
|
-
|
|
16850
|
-
})();
|
|
17275
|
+
});
|
|
16851
17276
|
let showAgentIcon = await getAgentVisibilityData();
|
|
16852
17277
|
let appCode = getApplicationCodeFromURL(applicationName);
|
|
16853
17278
|
let hideNavbot = await getHideNavbotData(appCode);
|
|
@@ -16858,6 +17283,7 @@ const SmartBot = (props) => {
|
|
|
16858
17283
|
let multiChatCfUrl = await getMultiChatCfUrl(appCode);
|
|
16859
17284
|
setChatHistoryBaseUrl(multiChatCfUrl);
|
|
16860
17285
|
const filterNavigationTab = (tabs) => hideNavbot ? tabs.filter((tab) => tab.name !== "Navigation") : tabs;
|
|
17286
|
+
const filterSavedFiltersTab = (tabs) => components?.FilterComponent ? tabs : tabs.filter((tab) => tab.name !== "Saved Filters");
|
|
16861
17287
|
if (!isEmpty$1(accessDataResponse) &&
|
|
16862
17288
|
showAgentIcon?.data?.data[0]?.attribute_value?.value) {
|
|
16863
17289
|
let list = await getAgentExceptionUserList(appCode);
|
|
@@ -17071,7 +17497,7 @@ const SmartBot = (props) => {
|
|
|
17071
17497
|
icon: jsx(SvgNavigationIcon, {}),
|
|
17072
17498
|
}
|
|
17073
17499
|
];
|
|
17074
|
-
setTabList(filterNavigationTab(tabListData));
|
|
17500
|
+
setTabList(filterSavedFiltersTab(filterNavigationTab(tabListData)));
|
|
17075
17501
|
}
|
|
17076
17502
|
else {
|
|
17077
17503
|
setCurrentMode("navigation");
|
|
@@ -17394,7 +17820,7 @@ const SmartBot = (props) => {
|
|
|
17394
17820
|
fetchLegacyAgentInfo(); //Disabled temporarily since this was causing issue on homepage first render
|
|
17395
17821
|
}
|
|
17396
17822
|
}, [location]);
|
|
17397
|
-
const handleSendMessage = async (userInput, userExplicitInput = {}, textWithColumnNames = ""
|
|
17823
|
+
const handleSendMessage = async (userInput, userExplicitInput = {}, textWithColumnNames = "") => {
|
|
17398
17824
|
try {
|
|
17399
17825
|
// if (localStorage.getItem("isStreaming") === "true") {
|
|
17400
17826
|
// displaySnackMessages(
|
|
@@ -17458,7 +17884,6 @@ const SmartBot = (props) => {
|
|
|
17458
17884
|
userExplicitInput: userExplicitInput,
|
|
17459
17885
|
textWithColumnNames: textWithColumnNames,
|
|
17460
17886
|
answerMode: answerMode,
|
|
17461
|
-
...(uiContext ? { uiContext } : {}),
|
|
17462
17887
|
};
|
|
17463
17888
|
// if(!isEmpty(userInput)) {
|
|
17464
17889
|
// Clear the previous response's completed state so the incoming
|
|
@@ -17508,25 +17933,12 @@ const SmartBot = (props) => {
|
|
|
17508
17933
|
sessionStorage.removeItem("stepForm_chatId");
|
|
17509
17934
|
// dispatch(setChatbotContext({}));
|
|
17510
17935
|
setUserInput(params?.text);
|
|
17511
|
-
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames
|
|
17936
|
+
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames);
|
|
17512
17937
|
}
|
|
17513
17938
|
catch (error) {
|
|
17514
17939
|
console.error("onSendIconClick error", error);
|
|
17515
17940
|
}
|
|
17516
17941
|
};
|
|
17517
|
-
// A follow-up asked from a generated surface (SurfaceFrameContent's "iris:prompt"): sent as the user's next
|
|
17518
|
-
// message, with the surface's context as ui_context. Not while a turn runs or a form waits for its Submit.
|
|
17519
|
-
const surfacePromptRef = useRef(null);
|
|
17520
|
-
surfacePromptRef.current = (detail) => {
|
|
17521
|
-
if (!detail?.text || isStop || !isEmpty$1(chatbotContext))
|
|
17522
|
-
return;
|
|
17523
|
-
onSendIconClick({ text: detail.text, uiContext: detail.uiContext });
|
|
17524
|
-
};
|
|
17525
|
-
useEffect(() => {
|
|
17526
|
-
const onSurfacePrompt = (event) => surfacePromptRef.current?.(event.detail);
|
|
17527
|
-
window.addEventListener("iris:prompt", onSurfacePrompt);
|
|
17528
|
-
return () => window.removeEventListener("iris:prompt", onSurfacePrompt);
|
|
17529
|
-
}, []);
|
|
17530
17942
|
const onStopIconClick = (params) => {
|
|
17531
17943
|
try {
|
|
17532
17944
|
setIsStop(false);
|
|
@@ -17760,35 +18172,9 @@ const SmartBot = (props) => {
|
|
|
17760
18172
|
if (!root)
|
|
17761
18173
|
return;
|
|
17762
18174
|
const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
|
|
17763
|
-
if (collapseBtn)
|
|
18175
|
+
if (collapseBtn)
|
|
17764
18176
|
collapseBtn.click();
|
|
17765
|
-
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
17766
|
-
}
|
|
17767
|
-
}, []);
|
|
17768
|
-
// Expand the chatbot to its full docked view by programmatically clicking
|
|
17769
|
-
// impact-ui's "Expand chatbot" button. Used when the allocation panel opens
|
|
17770
|
-
// from minimized state.
|
|
17771
|
-
const expandChatBotIfCollapsed = useCallback(() => {
|
|
17772
|
-
setShowModal(true);
|
|
17773
|
-
setPartialClose(false);
|
|
17774
|
-
// Use a short delay so the chatbot DOM renders before we look for the button
|
|
17775
|
-
setTimeout(() => {
|
|
17776
|
-
const root = smartBotWrapperRef.current;
|
|
17777
|
-
if (!root)
|
|
17778
|
-
return;
|
|
17779
|
-
const expandBtn = root.querySelector('button[aria-label="Expand chatbot"]');
|
|
17780
|
-
if (expandBtn) {
|
|
17781
|
-
expandBtn.click();
|
|
17782
|
-
}
|
|
17783
|
-
}, 100);
|
|
17784
18177
|
}, []);
|
|
17785
|
-
// Listen for smartBotMaximize events (e.g. from allocation plan card)
|
|
17786
|
-
useEffect(() => {
|
|
17787
|
-
window.addEventListener("smartBotMaximize", expandChatBotIfCollapsed);
|
|
17788
|
-
return () => {
|
|
17789
|
-
window.removeEventListener("smartBotMaximize", expandChatBotIfCollapsed);
|
|
17790
|
-
};
|
|
17791
|
-
}, [expandChatBotIfCollapsed]);
|
|
17792
18178
|
// Auto-collapse to draggable mode when the user interacts outside the bot.
|
|
17793
18179
|
useEffect(() => {
|
|
17794
18180
|
const handleOutsideInteraction = (e) => {
|
|
@@ -17810,9 +18196,6 @@ const SmartBot = (props) => {
|
|
|
17810
18196
|
// Ignore clicks inside the expanded table modal portal
|
|
17811
18197
|
if (e.target.closest?.(".test-modal"))
|
|
17812
18198
|
return;
|
|
17813
|
-
// Ignore clicks inside the allocation detail panel
|
|
17814
|
-
if (e.target.closest?.('[data-testid="allocation-detail-panel"]'))
|
|
17815
|
-
return;
|
|
17816
18199
|
collapseChatBotIfExpanded();
|
|
17817
18200
|
};
|
|
17818
18201
|
document.addEventListener("mousedown", handleOutsideInteraction, true);
|
|
@@ -17833,7 +18216,7 @@ const SmartBot = (props) => {
|
|
|
17833
18216
|
return (jsxs(Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsx(MinimizedChatWidget, { onExpand: () => {
|
|
17834
18217
|
setShowModal(true);
|
|
17835
18218
|
setPartialClose(false);
|
|
17836
|
-
} })), jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsx(RenameModal, { open: renameOpen, renameValue: renameValue, setRenameValue: setRenameValue, onConfirm: handleRenameConfirm, onCancel: handleRenameCancel }), jsx(DeleteConfirmModal, { open: deleteOpen, onConfirm: handleDeleteConfirm, onCancel: handleDeleteCancel }), jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat,
|
|
18219
|
+
} })), jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsx(RenameModal, { open: renameOpen, renameValue: renameValue, setRenameValue: setRenameValue, onConfirm: handleRenameConfirm, onCancel: handleRenameCancel }), jsx(DeleteConfirmModal, { open: deleteOpen, onConfirm: handleDeleteConfirm, onCancel: handleDeleteCancel }), jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
|
|
17837
18220
|
// onSaveClick={saveCurrentChat}
|
|
17838
18221
|
savedFilterSets: savedFilterSets, selectedFilterSet: selectedFilterSet, onFilterSetSelect: (filterSet) => setSelectedFilterSet(filterSet), onClearFilterSet: () => setSelectedFilterSet(null), onTriggerRefresh: triggerRefreshAction, answerMode: answerMode, setAnswerMode: setAnswerMode })) : showSavedFilters ? jsx(Fragment, {}) : null, isChatBotOpen: showModal || forceOpen, historyPanelData: historyPanelData, onHistorySearchChange: (params) => { console.log("History Search Change", params); }, onHistorySelectConversation: (params) => {
|
|
17839
18222
|
const convId = params?.conversation_id;
|
|
@@ -17876,7 +18259,7 @@ const SmartBot = (props) => {
|
|
|
17876
18259
|
}
|
|
17877
18260
|
}, onHistoryMenuAction: (action, conversationData) => {
|
|
17878
18261
|
handleHistoryMenuAction(action, conversationData);
|
|
17879
|
-
}, activeConversationId: activeConversationId,
|
|
18262
|
+
}, activeConversationId: activeConversationId, isConversationLoading: conversationLoading,
|
|
17880
18263
|
// landingScreen={true}
|
|
17881
18264
|
handleNewChatClick: () => {
|
|
17882
18265
|
localStorage.setItem("isStreaming", "false");
|
|
@@ -17939,7 +18322,6 @@ const SmartBot = (props) => {
|
|
|
17939
18322
|
dispatch(setMinimizedStreamData(null));
|
|
17940
18323
|
}
|
|
17941
18324
|
setPartialClose(true);
|
|
17942
|
-
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
17943
18325
|
}
|
|
17944
18326
|
},
|
|
17945
18327
|
// assistantChats={assistantChats}
|
|
@@ -17949,7 +18331,7 @@ const SmartBot = (props) => {
|
|
|
17949
18331
|
}, moduleList: modules, tabList: tabList, utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
|
|
17950
18332
|
jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber, setAdditionalArgs: setAdditionalArgs, displayQuestions: displayQuestions, questions: questions, setActiveConversationId: setActiveConversationId, selectedFilterSet: selectedFilterSet, answerMode: answerMode })
|
|
17951
18333
|
:
|
|
17952
|
-
jsx(
|
|
18334
|
+
components?.FilterComponent ? jsx(components.FilterComponent, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth, onSetFilterConfiguration: callbacks?.onSetFilterConfiguration }) : null, inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
|
|
17953
18335
|
freeTextHeading: "Try adding more details :",
|
|
17954
18336
|
freeTextContent: "Iris works better when you provide more context and pointed questions",
|
|
17955
18337
|
}, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {
|
|
@@ -17970,9 +18352,8 @@ const SmartBot = (props) => {
|
|
|
17970
18352
|
setChatBotWidth(params);
|
|
17971
18353
|
}, onMinimiseChatBot: () => {
|
|
17972
18354
|
setPartialClose(true);
|
|
17973
|
-
|
|
17974
|
-
} })] }), jsx(AllocationDetailPanel, {})] }));
|
|
18355
|
+
} })] })] }));
|
|
17975
18356
|
};
|
|
17976
18357
|
|
|
17977
|
-
export { SmartBot as default };
|
|
18358
|
+
export { ChatbotProvider, clearPersistedFormValues, SmartBot as default, setChatbotContext, setChatbotFilterOptions, setCurrentAgentChatId, setHierarchyKeyValue, setIsSmartBotRestricted, setMinimizedStreamData, setPersistedFormValues, setSavedFilterSets, setSmartBotActive, setStepFormRestreamPayload, setStepFormStreamData, setThinkingContext, smartBotInitialState, smartBotReducer, useChatbotDeps };
|
|
17978
18359
|
//# sourceMappingURL=index.esm.js.map
|