impact-chatbot 2.4.2 → 3.1.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.
Files changed (39) hide show
  1. package/dist/components/ag-grid/AgGridComponent.d.ts +2 -0
  2. package/dist/components/ag-grid/columnFormatter.d.ts +10 -0
  3. package/dist/components/ag-grid/constants.d.ts +3 -0
  4. package/dist/components/ag-grid/formatters.d.ts +11 -0
  5. package/dist/components/ag-grid/index.d.ts +3 -0
  6. package/dist/components/core-chart/CoreChart.d.ts +22 -0
  7. package/dist/components/core-chart/index.d.ts +2 -0
  8. package/dist/components/date-range-picker/DateRangePickerComponent.d.ts +4 -0
  9. package/dist/components/date-range-picker/index.d.ts +2 -0
  10. package/dist/constants.d.ts +1 -0
  11. package/dist/hooks/useBotConfiguration.d.ts +1 -1
  12. package/dist/index.cjs.css +93 -0
  13. package/dist/index.cjs.js +2172 -926
  14. package/dist/index.cjs.js.map +1 -1
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.esm.css +93 -0
  17. package/dist/index.esm.js +2030 -801
  18. package/dist/index.esm.js.map +1 -1
  19. package/dist/provider/ChatbotProvider.d.ts +32 -0
  20. package/dist/provider/types.d.ts +49 -0
  21. package/dist/services/apiConstants.d.ts +14 -0
  22. package/dist/services/chatbot-services.d.ts +42 -14
  23. package/dist/services/http.d.ts +53 -0
  24. package/dist/store/actions.d.ts +13 -0
  25. package/dist/store/index.d.ts +3 -0
  26. package/dist/store/reducer.d.ts +205 -0
  27. package/dist/store/types.d.ts +18 -0
  28. package/dist/utils/coreUtils.d.ts +16 -9
  29. package/package.json +47 -5
  30. package/dist/components/chatbot-input/index_new.d.ts +0 -3
  31. package/dist/components/chatbot-input/index_old_backup.d.ts +0 -3
  32. package/dist/components/chatbot-save-filter-component/ChatbotSaveFilterComponent.d.ts +0 -2
  33. package/dist/components/skill-upload-modal/index.d.ts +0 -2
  34. package/dist/core/commonComponents/custom-group-accordion/index.d.ts +0 -5
  35. package/dist/core/constants/index.d.ts +0 -5
  36. package/dist/core/utils/functions.d.ts +0 -8
  37. package/dist/core/utils/replaceSpecialCharacter.d.ts +0 -1
  38. /package/dist/{core/styles → styles}/colours.d.ts +0 -0
  39. /package/dist/{core/styles → styles}/globalStyles.d.ts +0 -0
package/dist/index.esm.js CHANGED
@@ -1,50 +1,49 @@
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, useEffect, useRef, Fragment as Fragment$1, createContext, useContext, useMemo } from 'react';
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, connect } from 'react-redux';
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
19
  import { CircularProgress, Typography, Grid, Box, IconButton, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
27
- import { fetchBaseUrl, pxToRem as pxToRem$1, replaceSpecialCharacter as replaceSpecialCharacter$1, fetchLegacyAgentScreen } from 'core/Utils/functions/utils';
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 { stopAgentFlow } from 'core/commonComponents/smartBot/services/chatbot-services';
32
- import { updateQuestionTiming } from 'core/commonComponents/smartBot/services/conversation-service';
33
- import AgGridComponent from 'core/Utils/agGridV36';
34
- import agGridColumnFormatter from 'core/Utils/agGridV36/columnFormatter';
35
- import CoreChart from 'core/Utils/core-charts';
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
41
  import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined';
39
42
  import OpenInNewIcon from '@mui/icons-material/OpenInNew';
40
43
  import FormatListBulletedOutlinedIcon from '@mui/icons-material/FormatListBulletedOutlined';
41
44
  import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined';
42
- import colours$1 from 'core/Styles/colours';
43
45
  import SaveOutlinedIcon from '@mui/icons-material/SaveOutlined';
44
- import RangePicker from 'core/commonComponents/dateRangePicker';
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';
46
+ import 'react-dates/lib/css/_datepicker.css';
48
47
  import { createPortal } from 'react-dom';
49
48
  import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
50
49
  import OpenInFullIcon from '@mui/icons-material/OpenInFull';
@@ -52,18 +51,532 @@ import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
52
51
  import CloseIcon from '@mui/icons-material/Close';
53
52
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
54
53
  import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
55
- import { getApplicationCodeFromURL } from 'core/Utils/utils';
56
54
 
57
55
  /**
58
- * Constants extracted from core/constants
59
- * Only includes constants used by chatbot-v2
56
+ * Internal HTTP client module for impact-chatbot.
57
+ *
58
+ * Instead of importing `axiosInstance` from `core/Utils/axios` (which ties the
59
+ * package to the host's core submodule), every service file in this package
60
+ * imports `getHttpClient()` from this module.
61
+ *
62
+ * The client is set once at startup via `initHttpClient()`, which is called
63
+ * from `ChatbotProvider` when the component tree mounts.
64
+ *
65
+ * Phase 3 of the segregation roadmap.
66
+ */
67
+ // ── Module-level singletons ────────────────────────────────────────────────
68
+ let _httpClient = null;
69
+ let _apiConstants = null;
70
+ /**
71
+ * Called once when <ChatbotProvider> mounts.
72
+ * Stores the consumer-provided HTTP client and API constants so every
73
+ * internal service can access them without prop-drilling.
74
+ */
75
+ function initHttpClient(httpClient, apiConstants) {
76
+ _httpClient = httpClient;
77
+ _apiConstants = apiConstants;
78
+ }
79
+ /**
80
+ * Returns the HTTP client set by the consumer.
81
+ *
82
+ * All internal service files use this as a drop-in replacement for the old
83
+ * `import axiosInstance from "core/Utils/axios"`.
84
+ *
85
+ * The returned client is "callable" in the same way Axios instances are — it
86
+ * supports `.get()`, `.post()`, `.put()`, `.delete()` and can also be invoked
87
+ * directly as a function (Axios config object style). To support the latter
88
+ * pattern transparently we return a wrapper that delegates to the right method.
60
89
  */
90
+ function getHttpClient() {
91
+ if (!_httpClient) {
92
+ throw new Error("[impact-chatbot] HTTP client not initialized. " +
93
+ "Ensure <ChatbotProvider> is rendered before any API call.");
94
+ }
95
+ return _httpClient;
96
+ }
97
+ /**
98
+ * Callable wrapper that mimics `axiosInstance({ url, method, data, params, ... })`.
99
+ *
100
+ * The old code uses `axiosInstance(config)` everywhere (Axios request-config
101
+ * style). This function translates that call into the structural `HttpClient`
102
+ * interface (.get / .post / .put / .delete).
103
+ */
104
+ function httpRequest(config) {
105
+ const client = getHttpClient();
106
+ const method = (config.method || "GET").toUpperCase();
107
+ // Build a config object to pass as the last argument (covers params,
108
+ // headers, signal, responseType, onDownloadProgress, etc.)
109
+ const requestConfig = { ...config };
110
+ delete requestConfig.url;
111
+ delete requestConfig.method;
112
+ delete requestConfig.data;
113
+ switch (method) {
114
+ case "GET":
115
+ return client.get(config.url, requestConfig);
116
+ case "POST":
117
+ return client.post(config.url, config.data, requestConfig);
118
+ case "PUT":
119
+ return client.put(config.url, config.data, requestConfig);
120
+ case "DELETE":
121
+ return client.delete(config.url, requestConfig);
122
+ case "PATCH":
123
+ // PATCH is not on the base HttpClient interface but Axios instances
124
+ // support it. Fall through to a generic call.
125
+ if (client.patch) {
126
+ return client.patch(config.url, config.data, requestConfig);
127
+ }
128
+ // Fallback: use post with _method override or just post
129
+ return client.post(config.url, config.data, {
130
+ ...requestConfig,
131
+ headers: { ...requestConfig.headers, "X-HTTP-Method-Override": "PATCH" },
132
+ });
133
+ default:
134
+ // For any other method, try calling the client directly (it may be
135
+ // a real Axios instance that supports arbitrary methods).
136
+ if (typeof client === "function") {
137
+ return client(config);
138
+ }
139
+ return client.get(config.url, requestConfig);
140
+ }
141
+ }
142
+ /**
143
+ * Returns the API constants set by the consumer.
144
+ */
145
+ function getApiConstants() {
146
+ if (!_apiConstants) {
147
+ throw new Error("[impact-chatbot] API constants not initialized. " +
148
+ "Ensure <ChatbotProvider> is rendered before any API call.");
149
+ }
150
+ return _apiConstants;
151
+ }
61
152
 
153
+ // Special character mapping for text replacement
154
+ const SPECIAL_CHARACTER_MAPPING = {
155
+ __ia_char_01: "'",
156
+ __ia_char_02: '"',
157
+ __ia_char_03: "/",
158
+ __ia_char_04: "\\",
159
+ __ia_char_05: "`",
160
+ __ia_char_06: "~",
161
+ __ia_char_07: "!",
162
+ __ia_char_08: "@",
163
+ __ia_char_09: "#",
164
+ __ia_char_10: "$",
165
+ __ia_char_11: "%",
166
+ __ia_char_12: "^",
167
+ __ia_char_13: "&",
168
+ __ia_char_14: "*",
169
+ __ia_char_15: "(",
170
+ __ia_char_16: ")",
171
+ __ia_char_19: "=",
172
+ __ia_char_20: "+",
173
+ __ia_char_21: "{",
174
+ __ia_char_22: "}",
175
+ __ia_char_23: "[",
176
+ __ia_char_24: "]",
177
+ __ia_char_25: "|",
178
+ __ia_char_26: ":",
179
+ __ia_char_27: ";",
180
+ __ia_char_28: "<",
181
+ __ia_char_29: ">",
182
+ __ia_char_30: ",",
183
+ __ia_char_31: ".",
184
+ __ia_char_32: "?",
185
+ __ia_char_33: "/",
186
+ };
62
187
  const COMBINED_CROSS_DIMENSIONAL_API_V4 = "/combined-cross-dimensional-v4";
188
+ const navigationOptions = [
189
+ {
190
+ link: "/inventory-smart/decision-dashboard",
191
+ screen_name: "Dashboard",
192
+ flow_type: "navigation",
193
+ },
194
+ {
195
+ link: `/inventory-smart/create-allocation/?step=0`,
196
+ flow_type: "navigation",
197
+ screen_name: "Allocation",
198
+ },
199
+ {
200
+ link: "/inventory-smart/configuration",
201
+ flow_type: "navigation",
202
+ screen_name: "Configurations",
203
+ },
204
+ {
205
+ link: "/inventory-smart/store-eligibility-grouping",
206
+ flow_type: "navigation",
207
+ screen_name: "Grouping",
208
+ },
209
+ {
210
+ link: "/inventory-smart/constraints",
211
+ flow_type: "navigation",
212
+ screen_name: "Constraints",
213
+ },
214
+ {
215
+ link: "/inventory-smart/ada/dashboard",
216
+ flow_type: "navigation",
217
+ screen_name: "ADA Visual",
218
+ },
219
+ ];
220
+ const insightsOptions = [
221
+ {
222
+ link: "/inventory-smart/decision-dashboard",
223
+ screen_name: "Dashboard",
224
+ flow_type: "insights",
225
+ },
226
+ {
227
+ link: `/inventory-smart/create-allocation/?step=0`,
228
+ flow_type: "insights",
229
+ screen_name: "Allocation",
230
+ },
231
+ {
232
+ link: "/inventory-smart/store-eligibility-grouping",
233
+ flow_type: "insights",
234
+ screen_name: "Configurations",
235
+ },
236
+ {
237
+ link: "/inventory-smart/configuration",
238
+ flow_type: "insights",
239
+ screen_name: "Grouping",
240
+ },
241
+ {
242
+ link: "/inventory-smart/constraints",
243
+ flow_type: "insights",
244
+ screen_name: "Constraints",
245
+ },
246
+ {
247
+ link: "/inventory-smart/ada/dashboard",
248
+ flow_type: "insights",
249
+ screen_name: "ADA Visual",
250
+ },
251
+ ];
252
+ const screenOptions = [
253
+ {
254
+ link: "/inventory-smart/decision-dashboard",
255
+ screen_name: "InventoryDashboard",
256
+ filterCongfigurationName: "decisionDashboardFilterConfiguration",
257
+ },
258
+ {
259
+ link: "/inventory-smart/product-profile",
260
+ screen_name: "Product Profile",
261
+ filterCongfigurationName: "productProfileDashboardFilterConfig",
262
+ },
263
+ {
264
+ link: `/inventory-smart/create-allocation/?step=0`,
265
+ screen_name: "Allocation",
266
+ filterCongfigurationName: "createAllocationFilterConfiguration",
267
+ },
268
+ {
269
+ link: "/inventory-smart/store-eligibility-grouping",
270
+ screen_name: "Inventorysmart Store Eligibility Group",
271
+ filterCongfigurationName: "storeGroupingFilterConfiguration",
272
+ },
273
+ {
274
+ link: "/inventory-smart/configuration",
275
+ screen_name: "Inventorysmart Configurations",
276
+ filterCongfigurationName: "productStatusFilterConfiguration",
277
+ },
278
+ {
279
+ link: "/inventory-smart/constraints",
280
+ screen_name: "Inventorysmart Constraints",
281
+ filterCongfigurationName: "rulesConstraintsFilterConfig",
282
+ },
283
+ {
284
+ link: "/inventory-smart/allocation-reports",
285
+ screen_name: "Inventorysmart Reportings",
286
+ filterCongfigurationName: "lostSalesFilterConfiguration",
287
+ },
288
+ {
289
+ link: "/inventory-smart/ada/dashboard",
290
+ screen_name: "Inventorysmart ADA Dashboard",
291
+ filterCongfigurationName: "adaVisualFilterConfiguration",
292
+ },
293
+ ];
63
294
 
295
+ /**
296
+ * Core utility functions copied from core/Utils/functions/utils
297
+ * These are internalized to make chatbot-v2 self-contained
298
+ */
299
+ /**
300
+ * pxToRem function will convert the px value to rem value
301
+ */
302
+ const pxToRem = (pxValue) => {
303
+ try {
304
+ return pxValue / 16 + "rem";
305
+ }
306
+ catch (error) {
307
+ console.error("pxToRem error:", error);
308
+ return "0rem";
309
+ }
310
+ };
311
+ /**
312
+ * Replace special characters in a string
313
+ */
314
+ const replaceSpecialCharacter$2 = (str) => {
315
+ if (typeof str === "object") {
316
+ return str;
317
+ }
318
+ else {
319
+ let result = str;
320
+ if (SPECIAL_CHARACTER_MAPPING) {
321
+ Object.keys(SPECIAL_CHARACTER_MAPPING).forEach((key) => {
322
+ if (result?.includes(key)) {
323
+ result = result.replaceAll(key, SPECIAL_CHARACTER_MAPPING[key]);
324
+ }
325
+ });
326
+ }
327
+ return result;
328
+ }
329
+ };
330
+ /**
331
+ * @function
332
+ * @description Function is used to return string by replacing the special characters with respective key mapped to SPECIAL_CHARACTER_MAPPING
333
+ * @param {String} str
334
+ * @returns {String} key of mapped special character used in the string
335
+ */
336
+ const replaceSpecialCharToCharCode = (str) => {
337
+ let re = new RegExp(`[${Object.values(SPECIAL_CHARACTER_MAPPING).join("")}]`, "g");
338
+ return str.replace(re, function (matched) {
339
+ let code;
340
+ for (const [key, value] of Object.entries(SPECIAL_CHARACTER_MAPPING)) {
341
+ if (value === matched) {
342
+ code = key;
343
+ return code;
344
+ }
345
+ }
346
+ return code;
347
+ });
348
+ };
349
+ /**
350
+ * Get user name from session storage
351
+ * Matches core/Utils/functions/utils.getUserName exactly
352
+ */
353
+ const getUserName = () => {
354
+ const userDetails = JSON.parse(sessionStorage.getItem("userDetails") || "{}");
355
+ return userDetails?.user_name || "User";
356
+ };
357
+ /**
358
+ * Get formatted application name based on URL path segment
359
+ * Matches core/Utils/functions/utils.getFormattedApplicationName exactly
360
+ */
361
+ /**
362
+ * Get application code from localStorage applicationCodesList by matching application name.
363
+ * Mirrors core/Utils/utils.getApplicationCodeFromURL exactly.
364
+ */
365
+ const getApplicationCodeFromURL = (applicationName) => {
366
+ try {
367
+ const applicationCodesList = JSON.parse(localStorage.getItem("applicationCodesList") || "[]");
368
+ const matched = applicationCodesList?.find((app) => app.name?.toUpperCase() === applicationName?.toUpperCase());
369
+ return matched?.application_code || "";
370
+ }
371
+ catch (error) {
372
+ console.error("getApplicationCodeFromURL error:", error);
373
+ return "";
374
+ }
375
+ };
376
+ const getFormattedApplicationName = (applicationURL) => {
377
+ switch (applicationURL) {
378
+ case "user-management":
379
+ case "tenantconfig":
380
+ return "application access management";
381
+ case "assort-smart":
382
+ return "AssortSmart";
383
+ case "configurator":
384
+ return "module configurator";
385
+ case "inventory-smart":
386
+ return "InventorySmart";
387
+ case "ada":
388
+ return "ADA";
389
+ case "plan-smart":
390
+ return "PlanSmart";
391
+ case "adaconfigurator":
392
+ return "ADAConfigurator";
393
+ case "item-smart":
394
+ return "ItemSmart";
395
+ case "item-smart-new":
396
+ return "ItemSmart-New";
397
+ case "source-smart":
398
+ return "SourceSmart";
399
+ case "pricesmart-markdown":
400
+ return "PriceSmart Markdown";
401
+ case "pricesmart-promo":
402
+ return "PriceSmart Promo";
403
+ case "agentic-assort":
404
+ return "AssortSmart";
405
+ case "size-smart":
406
+ return "SizeSmart";
407
+ default:
408
+ return "workflow input center";
409
+ }
410
+ };
411
+
412
+ /**
413
+ * API endpoint constants used by chatbot service functions.
414
+ *
415
+ * Previously scattered across `config/api`, `core/actions/tenantConfigActions`,
416
+ * and `core/actions/userAccessActions` in the host app. Now internalized so the
417
+ * package is fully self-contained.
418
+ */
419
+ // ─── Tenant Config & Application ─────────────────────────────────────────────
420
+ const GET_TENANT_CONFIG = "core/tenant-config";
421
+ const GET_APPLICATION_MASTER = "/core/applications";
422
+ // ─── User Management ─────────────────────────────────────────────────────────
423
+ const GET_USERS_URL = "/core/user-mgmt/list";
424
+ const GET_MODULE_LEVEL_ACCESS = "/master/user-management/module-hierarchy";
425
+ const GET_USER_APP_ACCESS_HIERARCHY = "/master/user-management/app-role-hierarchy";
426
+ // ─── Filter ──────────────────────────────────────────────────────────────────
427
+ const SAVE_FILTER_GET = "/core/filter/user-preference/screen";
428
+
429
+ // ─── In-memory tenant-config cache ──────────────────────────────────────
430
+ // Mirrors core tenantConfigApiCache but uses a simple Map instead of Redux.
431
+ const _tenantConfigCache = {};
432
+ /**
433
+ * processData – filters a tenant-config API response by attribute_name.
434
+ * Mirrors core/Utils/functions/utils.processData exactly.
435
+ */
436
+ const processData = (responseData, queryParam) => {
437
+ if (Object.keys(queryParam).length === 0) {
438
+ return responseData;
439
+ }
440
+ const { data } = responseData;
441
+ const filteredData = data?.data?.filter((item) => item.name === queryParam?.attribute_name);
442
+ return {
443
+ ...responseData,
444
+ data: {
445
+ ...data,
446
+ data: filteredData,
447
+ },
448
+ };
449
+ };
450
+ /**
451
+ * tenantConfigApiCache – fetches tenant config for an application code,
452
+ * caching the full response in memory. Returns a thunk (function) to
453
+ * match the core signature: `tenantConfigApiCache(appCode, query)()`
454
+ *
455
+ * Mirrors core/actions/tenantConfigActions.tenantConfigApiCache.
456
+ */
457
+ const tenantConfigApiCache = (applicationCode = 1, queryParam = {}) => async () => {
458
+ const cachedData = _tenantConfigCache[applicationCode];
459
+ if (cachedData) {
460
+ return processData(cachedData, queryParam);
461
+ }
462
+ const resp = await httpRequest({
463
+ url: `${GET_TENANT_CONFIG}/${applicationCode}`,
464
+ params: {},
465
+ method: "GET",
466
+ });
467
+ _tenantConfigCache[applicationCode] = resp;
468
+ return processData(resp, queryParam);
469
+ };
470
+ /**
471
+ * getApplicationMaster – fetches the list of applications.
472
+ * Mirrors core/actions/tenantConfigActions.getApplicationMaster.
473
+ * The original returns a thunk `(postBody) => async () => ...`.
474
+ * We simplify to a direct async call since the package never passes postBody.
475
+ */
476
+ const getApplicationMaster = async () => {
477
+ return httpRequest({
478
+ url: GET_APPLICATION_MASTER,
479
+ method: "GET",
480
+ });
481
+ };
482
+ // Resolve the current user's code via the users API, matching the logged-in
483
+ // email (localStorage "name"). Mirrors core/Utils/functions/utils.getCurrentUserId.
484
+ const getCurrentUserId = async () => {
485
+ try {
486
+ const postBody = {
487
+ meta: {
488
+ search: [],
489
+ range: [],
490
+ sort: [],
491
+ },
492
+ };
493
+ const users = await httpRequest({
494
+ url: GET_USERS_URL,
495
+ method: "POST",
496
+ data: postBody,
497
+ });
498
+ const loggedInUserEmail = localStorage.getItem("name");
499
+ const user = users?.data?.data?.filter((item) => {
500
+ return item.email === loggedInUserEmail;
501
+ });
502
+ return user[0]?.user_code;
503
+ }
504
+ catch (error) {
505
+ console.error("getCurrentUserId error", error);
506
+ }
507
+ };
508
+ // Helper to get current application details from localStorage
509
+ const getCurrentApplicationDetails = () => {
510
+ if (localStorage.getItem("applicationCodesList") &&
511
+ localStorage.getItem("applicationCodesList") !== "undefined") {
512
+ const applicationCodesList = JSON.parse(localStorage.getItem("applicationCodesList"));
513
+ const applicationURL = window.location.pathname.split("/")?.[1];
514
+ const applicationName = getFormattedApplicationName(applicationURL);
515
+ const applicationCode = applicationCodesList?.find((app) => app.name?.toUpperCase() === applicationName?.toUpperCase());
516
+ return {
517
+ applicationCode: applicationCode?.application_code,
518
+ applicationName,
519
+ applicationCodesList,
520
+ };
521
+ }
522
+ return { applicationCode: "", applicationName: "", applicationCodesList: [] };
523
+ };
524
+ // Fetch application code – mirrors core/Utils/functions/utils.fetchApplicationCode
525
+ const fetchApplicationCodeFromConfig = async () => {
526
+ const { applicationCode, applicationCodesList } = getCurrentApplicationDetails();
527
+ let finalApplicationCode = applicationCode;
528
+ let finalApplicationCodesList = applicationCodesList;
529
+ if (!finalApplicationCode) {
530
+ let applicationURL = window.location.pathname.split("/")?.[1];
531
+ let applicationName = getFormattedApplicationName(applicationURL);
532
+ if (applicationName === "workflow input center") {
533
+ applicationName = "Workflow Input Center";
534
+ }
535
+ let getApplicationMasterList = await getApplicationMaster();
536
+ localStorage.setItem("applicationCodesList", JSON.stringify(getApplicationMasterList?.data?.data));
537
+ finalApplicationCodesList = getApplicationMasterList?.data?.data;
538
+ finalApplicationCodesList?.forEach((app) => {
539
+ if (app.name === applicationName) {
540
+ finalApplicationCode = app.application_code;
541
+ }
542
+ });
543
+ }
544
+ return {
545
+ applicationCode: finalApplicationCode,
546
+ applicationCodesList: finalApplicationCodesList,
547
+ };
548
+ };
549
+ // Fetch base URL from tenant config – mirrors core/Utils/functions/utils.fetchBaseUrl exactly
550
+ const fetchBaseUrl = async () => {
551
+ try {
552
+ let { applicationCode } = await fetchApplicationCodeFromConfig();
553
+ let baseUrlData = await tenantConfigApiCache(applicationCode, {
554
+ attribute_name: "base_url",
555
+ })();
556
+ return baseUrlData?.data?.data?.[0]?.attribute_value?.value;
557
+ }
558
+ catch (error) {
559
+ console.error("fetchBaseUrl error", error);
560
+ return null;
561
+ }
562
+ };
563
+ // Fetch legacy agent screen flag – mirrors core/Utils/functions/utils.fetchLegacyAgentScreen exactly
564
+ const fetchLegacyAgentScreen = async () => {
565
+ try {
566
+ let { applicationCode } = await fetchApplicationCodeFromConfig();
567
+ let legacyAgentScreenData = await tenantConfigApiCache(applicationCode, {
568
+ attribute_name: "legacy_agent_screen",
569
+ })();
570
+ return legacyAgentScreenData?.data?.data?.[0]?.attribute_value?.value;
571
+ }
572
+ catch (error) {
573
+ console.error("fetchLegacyAgentScreen error", error);
574
+ return null;
575
+ }
576
+ };
64
577
  const resolveChatQuery = (body, flowType) => {
65
578
  try {
66
- return axiosInstance({
579
+ return httpRequest({
67
580
  url: `/core/chatbot/${flowType}`,
68
581
  method: "PUT",
69
582
  data: body,
@@ -76,7 +589,7 @@ const resolveChatQuery = (body, flowType) => {
76
589
  };
77
590
  const fetchRelatedQuestions = (flowType, screen_name) => {
78
591
  try {
79
- return axiosInstance({
592
+ return httpRequest({
80
593
  url: `/core/chatbot/${flowType}/question/${screen_name}`,
81
594
  method: "GET",
82
595
  });
@@ -145,7 +658,7 @@ const getAgentExceptionUserList = (applicationCode) => {
145
658
  };
146
659
  const refreshAndUpdateUserManualApi = async (body) => {
147
660
  try {
148
- return axiosInstance({
661
+ return httpRequest({
149
662
  url: `core/chatbot/manualdoc`,
150
663
  method: "PUT",
151
664
  data: body,
@@ -158,7 +671,7 @@ const refreshAndUpdateUserManualApi = async (body) => {
158
671
  };
159
672
  const fetchScreensForModule = async (flowType) => {
160
673
  try {
161
- return axiosInstance({
674
+ return httpRequest({
162
675
  url: `core/chatbot/${flowType}/screen`,
163
676
  method: "GET",
164
677
  });
@@ -171,7 +684,7 @@ const fetchScreensForModule = async (flowType) => {
171
684
  // Like/Dislike Messages
172
685
  const likeDislikeComment = async (payload) => {
173
686
  try {
174
- return axiosInstance({
687
+ return httpRequest({
175
688
  url: `core/chatbot/analytics/like`,
176
689
  data: payload,
177
690
  method: "POST",
@@ -185,7 +698,7 @@ const likeDislikeComment = async (payload) => {
185
698
  // Like/Dislike Messages for agent
186
699
  const likeDislikeCommentForAgent = async (payload, baseUrl) => {
187
700
  try {
188
- return axiosInstance({
701
+ return httpRequest({
189
702
  url: `${baseUrl}/chatbot/agent/analytics/like`,
190
703
  data: payload,
191
704
  method: "POST",
@@ -198,7 +711,7 @@ const likeDislikeCommentForAgent = async (payload, baseUrl) => {
198
711
  };
199
712
  const fetchIntentApiResponse = async (input = "@apply_filter What is sales discount in cabezon mtd?") => {
200
713
  try {
201
- return axiosInstance({
714
+ return httpRequest({
202
715
  url: `core/chatbot/intent`,
203
716
  method: "POST",
204
717
  data: {
@@ -212,7 +725,7 @@ const fetchIntentApiResponse = async (input = "@apply_filter What is sales disco
212
725
  };
213
726
  const fetchAgentsInfo = async (baseUrl) => {
214
727
  try {
215
- return axiosInstance({
728
+ return httpRequest({
216
729
  url: `${baseUrl}/chatbot/agent/info`,
217
730
  method: 'GET'
218
731
  });
@@ -224,7 +737,7 @@ const fetchAgentsInfo = async (baseUrl) => {
224
737
  };
225
738
  const initiateAgent = async (payload, baseUrl) => {
226
739
  try {
227
- return axiosInstance({
740
+ return httpRequest({
228
741
  url: `${baseUrl}/chatbot/agent/init`,
229
742
  method: 'POST',
230
743
  data: payload,
@@ -237,7 +750,7 @@ const initiateAgent = async (payload, baseUrl) => {
237
750
  };
238
751
  const uploadFile = async (payload) => {
239
752
  try {
240
- return axiosInstance({
753
+ return httpRequest({
241
754
  url: `core/chatbot/upload/signed-url`,
242
755
  method: 'POST',
243
756
  data: payload,
@@ -248,33 +761,9 @@ const uploadFile = async (payload) => {
248
761
  return null;
249
762
  }
250
763
  };
251
- /** Saves a skill for the signed-in user: its SKILL.md and the files it refers to, each keyed by its path in
252
- * the skill's folder ({"SKILL.md": text, "references/x.md": text}). The agent checks it as its harness would
253
- * serve it and answers {name, version, characters, files, missing_files, trigger, trigger_said, turn_on}; a
254
- * skill it refuses is a 422 whose detail says why. Errors reach the caller, which shows them. */
255
- const uploadSkill = async (files, baseUrl) => {
256
- return axiosInstance({
257
- url: `${baseUrl}/chatbot/agent/skills`,
258
- method: 'POST',
259
- data: { files },
260
- });
261
- };
262
- /** Whether the agent takes skill uploads: its /info answer carries skills.upload beside the cards. Any
263
- * failure, or an agent that does not say so, is false (no "Upload Skill" item). */
264
- const fetchSkillUploadOn = async (baseUrl) => {
265
- try {
266
- const response = await fetchAgentsInfo(baseUrl);
267
- const body = response?.data || {};
268
- return body?.skills?.upload === true || body?.data?.skills?.upload === true;
269
- }
270
- catch (error) {
271
- console.error('fetchSkillUploadOn error:', error);
272
- return false;
273
- }
274
- };
275
764
  const triggerRefresh = async (baseUrl) => {
276
765
  try {
277
- return axiosInstance({
766
+ return httpRequest({
278
767
  url: `core/chatbot/trigger-refresh`,
279
768
  method: 'GET'
280
769
  });
@@ -286,7 +775,7 @@ const triggerRefresh = async (baseUrl) => {
286
775
  };
287
776
  const fetchChatbotFilterConfig = async () => {
288
777
  try {
289
- return axiosInstance({
778
+ return httpRequest({
290
779
  url: `core/filter/generic-schema-mapping?screen_name=Chatbot`,
291
780
  method: "GET",
292
781
  });
@@ -297,17 +786,30 @@ const fetchChatbotFilterConfig = async () => {
297
786
  }
298
787
  };
299
788
  const getFilterOptions = (postBody) => async () => {
300
- return axiosInstance({
789
+ return httpRequest({
301
790
  url: sessionStorage.getItem("crossFilterVersion") === "cross-filter-v4"
302
791
  ? COMBINED_CROSS_DIMENSIONAL_API_V4
303
- : COMBINED_CROSS_DIMENSIONAL_API,
792
+ : getApiConstants().COMBINED_CROSS_DIMENSIONAL_API,
304
793
  method: "POST",
305
794
  data: postBody,
306
795
  });
307
796
  };
797
+ const stopAgentFlow = async (payload, baseUrl) => {
798
+ try {
799
+ return httpRequest({
800
+ url: `${baseUrl}/chatbot/agent/stop`,
801
+ method: 'POST',
802
+ data: payload,
803
+ });
804
+ }
805
+ catch (error) {
806
+ console.error('stopAgentFlow error:', error);
807
+ return null;
808
+ }
809
+ };
308
810
  const getTableRecords = async (payload, baseUrl, tableName) => {
309
811
  try {
310
- return axiosInstance({
812
+ return httpRequest({
311
813
  url: `${baseUrl}/chatbot/agent/tabular-data/${tableName}`,
312
814
  method: 'POST',
313
815
  data: payload,
@@ -335,7 +837,7 @@ const postUiQuery = async (payload, baseUrl) => {
335
837
  };
336
838
  const getTableRecordsByUrl = async (payload, url) => {
337
839
  try {
338
- return axiosInstance({
840
+ return httpRequest({
339
841
  url: url,
340
842
  method: 'POST',
341
843
  data: payload,
@@ -345,22 +847,149 @@ const getTableRecordsByUrl = async (payload, url) => {
345
847
  console.error('getTableRecordsByUrl error:', error);
346
848
  return null;
347
849
  }
348
- };
850
+ };
851
+ // ─── Internalized from core/actions/userAccessActions.js ─────────────────────
852
+ // Previously injected via ChatbotProvider actions; now lives inside the package
853
+ // so consumers don't need to provide these functions.
854
+ /**
855
+ * convertAccessHierarchyToOldFormat — transforms the new module-level access
856
+ * response into the legacy format the chatbot code expects.
857
+ * Mirrors core/Utils/functions/utils.convertAccessHierarchyToOldFormat exactly.
858
+ */
859
+ const convertAccessHierarchyToOldFormat = (appModuleActions, accessHierarchy = []) => {
860
+ const result = {};
861
+ for (const [module, access] of Object.entries(appModuleActions)) {
862
+ const updatedAccess = Object.fromEntries(Object.entries(access).map(([key, value]) => [
863
+ key,
864
+ value === "limited" ? accessHierarchy : {},
865
+ ]));
866
+ result[module] = updatedAccess;
867
+ }
868
+ return result;
869
+ };
870
+ /**
871
+ * getUserAccessHierarchy — fetches the access hierarchy for an application.
872
+ * Mirrors core/actions/userAccessActions.getUserAccessHierarchy.
873
+ */
874
+ const getUserAccessHierarchy = (app) => {
875
+ return httpRequest({
876
+ url: GET_USER_APP_ACCESS_HIERARCHY,
877
+ method: "GET",
878
+ params: { app },
879
+ });
880
+ };
881
+ /**
882
+ * getModuleLevelAccessHelper — fetches module-level access permissions.
883
+ * Mirrors core/actions/userAccessActions.getModuleLevelAccessHelper.
884
+ */
885
+ const getModuleLevelAccessHelper = (app, modules) => {
886
+ const body = {
887
+ applications: {
888
+ [app]: modules,
889
+ },
890
+ };
891
+ return httpRequest({
892
+ url: GET_MODULE_LEVEL_ACCESS,
893
+ data: body,
894
+ method: "POST",
895
+ });
896
+ };
897
+ /**
898
+ * getModuleLevelAccessUtility — fetches both the access hierarchy and module
899
+ * permissions in parallel, then merges them into the legacy format.
900
+ * Mirrors core/actions/userAccessActions.getModuleLevelAccessUtility exactly.
901
+ *
902
+ * Unlike the original (which was a Redux thunk returning a function), this is
903
+ * a direct async function: `await getModuleLevelAccessUtility({...})`.
904
+ */
905
+ const getModuleLevelAccessUtility = async ({ app, module: modules, }) => {
906
+ const [hierarchyResponse, accessResponse] = await Promise.all([
907
+ getUserAccessHierarchy(app),
908
+ getModuleLevelAccessHelper(app, modules),
909
+ ]);
910
+ return convertAccessHierarchyToOldFormat(accessResponse?.data?.data[app], hierarchyResponse?.data?.data);
911
+ };
912
+ // ─── Internalized from core/actions/filterAction.js ──────────────────────────
913
+ /**
914
+ * getFilterUserConfiguration — fetches saved filter configurations for a screen.
915
+ * Mirrors core/actions/filterAction.getFilterUserConfiguration exactly.
916
+ *
917
+ * Unlike the original (which was a bare async function), the interface is the
918
+ * same: `const data = await getFilterUserConfiguration("Chatbot")`.
919
+ */
920
+ const getFilterUserConfiguration = async (screenName) => {
921
+ const { data } = await httpRequest({
922
+ url: `${SAVE_FILTER_GET}/${screenName}`,
923
+ method: "GET",
924
+ });
925
+ return data.data;
926
+ };
927
+
928
+ /**
929
+ * Stable default selector references used as fallbacks when the consumer
930
+ * does not provide selectors via the provider. Module-level constants
931
+ * avoid creating new function references on every render (which would
932
+ * cause useSelector to re-subscribe and potentially loop).
933
+ */
934
+ const NULL_SELECTOR = () => null;
935
+ const EMPTY_ARRAY_SELECTOR = () => [];
936
+ const ChatbotContext = createContext(null);
937
+ /**
938
+ * Wrap <SmartBot> with this provider to inject host-level dependencies
939
+ * (HTTP client, API constants, actions, selectors, heavy components).
940
+ *
941
+ * On mount (and whenever the value changes) the provider also initializes
942
+ * the module-level HTTP client singleton so that service files can call
943
+ * `getHttpClient()` / `httpRequest()` without prop-drilling.
944
+ *
945
+ * @example
946
+ * <ChatbotProvider value={{ httpClient: axiosInstance, apiConstants: { BASE_API, COMBINED_CROSS_DIMENSIONAL_API } }}>
947
+ * <SmartBot userName={userName} />
948
+ * </ChatbotProvider>
949
+ */
950
+ const ChatbotProvider = ({ value, children }) => {
951
+ // Eagerly initialize the HTTP singleton so even the very first render
952
+ // cycle of child components (which may trigger API calls in useEffect)
953
+ // has the client available.
954
+ if (value?.httpClient && value?.apiConstants) {
955
+ initHttpClient(value.httpClient, value.apiConstants);
956
+ }
957
+ // Also keep it in sync if the consumer swaps the value at runtime.
958
+ useEffect(() => {
959
+ if (value?.httpClient && value?.apiConstants) {
960
+ initHttpClient(value.httpClient, value.apiConstants);
961
+ }
962
+ }, [value?.httpClient, value?.apiConstants]);
963
+ return (jsx(ChatbotContext.Provider, { value: value, children: children }));
964
+ };
965
+ /**
966
+ * Hook consumed by internal package components to access host dependencies.
967
+ * Throws if called outside a <ChatbotProvider>.
968
+ */
969
+ function useChatbotDeps() {
970
+ const ctx = useContext(ChatbotContext);
971
+ if (!ctx) {
972
+ throw new Error("useChatbotDeps() must be used within a <ChatbotProvider>. " +
973
+ "Wrap your <SmartBot> component with <ChatbotProvider value={{...}}>.");
974
+ }
975
+ return ctx;
976
+ }
349
977
 
350
- const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction, dispatch) => {
978
+ const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction) => {
979
+ const { callbacks } = useChatbotDeps();
351
980
  const displaySnackMessages = useCallback((message, variant) => {
352
981
  try {
353
- dispatch(addSnack({
354
- message: message,
355
- options: {
356
- variant: variant,
357
- },
358
- }));
982
+ if (callbacks?.onSnackbar) {
983
+ callbacks.onSnackbar(message, variant);
984
+ }
985
+ else {
986
+ console.warn("onSnackbar callback not provided via ChatbotProvider");
987
+ }
359
988
  }
360
989
  catch (error) {
361
990
  console.error("displaySnackMessages error", error);
362
991
  }
363
- }, [dispatch]);
992
+ }, [callbacks]);
364
993
  const refreshAndUpdateUserManual = useCallback(async () => {
365
994
  try {
366
995
  setRefreshLoader(true);
@@ -389,8 +1018,7 @@ const useBotConfiguration = (setRefreshLoader, setEnableRefreshAction, dispatch)
389
1018
  let accessDataResponse = await getModuleLevelAccessUtility({
390
1019
  app: APP,
391
1020
  module: [MODULE],
392
- skipHierarchyCall: true,
393
- })();
1021
+ });
394
1022
  let rolesBasedModulesPermission = Object.fromEntries(Object.entries(accessDataResponse).map(([module, actions]) => [
395
1023
  module,
396
1024
  Object.keys(actions),
@@ -510,10 +1138,30 @@ const updateQuestionFeedback = async (sessionId, isLiked) => {
510
1138
  return null;
511
1139
  }
512
1140
  };
1141
+ // PATCH /questions/{session_id} — persist how long a turn took.
1142
+ // All three fields are required; `duration` is an integer in milliseconds.
1143
+ const updateQuestionTiming = async (sessionId, { startTime, endTime, duration } = {}) => {
1144
+ try {
1145
+ return axios({
1146
+ url: `${getChatHistoryBaseUrl()}/questions/${sessionId}`,
1147
+ method: "PATCH",
1148
+ headers: { "Content-Type": "application/json" },
1149
+ data: {
1150
+ start_time: startTime,
1151
+ end_time: endTime,
1152
+ duration,
1153
+ },
1154
+ });
1155
+ }
1156
+ catch (error) {
1157
+ console.error("updateQuestionTiming error", error);
1158
+ return null;
1159
+ }
1160
+ };
513
1161
  const fetchConversations = async (currentMode) => {
514
1162
  try {
515
1163
  // Will be replaced with actual API call
516
- return axiosInstance({
1164
+ return httpRequest({
517
1165
  url: `core/chatbot/conversation/${currentMode}`,
518
1166
  method: "GET"
519
1167
  });
@@ -540,7 +1188,7 @@ const fetchConversations = async (currentMode) => {
540
1188
  };
541
1189
  const createConversation = async (payload) => {
542
1190
  try {
543
- return axiosInstance({
1191
+ return httpRequest({
544
1192
  url: `core/chatbot/conversation`,
545
1193
  method: "POST",
546
1194
  data: payload
@@ -553,7 +1201,7 @@ const createConversation = async (payload) => {
553
1201
  };
554
1202
  const updateConversation = async (conversationId, payload) => {
555
1203
  try {
556
- return axiosInstance({
1204
+ return httpRequest({
557
1205
  url: `core/chatbot/conversation/update`,
558
1206
  method: "POST",
559
1207
  data: payload
@@ -566,7 +1214,7 @@ const updateConversation = async (conversationId, payload) => {
566
1214
  };
567
1215
  const deleteConversation = async (conversationId) => {
568
1216
  try {
569
- return axiosInstance({
1217
+ return httpRequest({
570
1218
  url: `core/chatbot/conversation/${conversationId}`,
571
1219
  method: "DELETE"
572
1220
  });
@@ -578,7 +1226,7 @@ const deleteConversation = async (conversationId) => {
578
1226
  };
579
1227
  const saveChat = async (payload) => {
580
1228
  try {
581
- return axiosInstance({
1229
+ return httpRequest({
582
1230
  url: `core/chatbot/conversation`,
583
1231
  method: "POST",
584
1232
  data: payload
@@ -1101,362 +1749,93 @@ const getDynamicFunction = async (path, functionName) => {
1101
1749
  // Dynamic imports are resolved by the host application's bundler
1102
1750
  // The path should be relative to the host app's dynamic folder
1103
1751
  const module = await import(/* webpackIgnore: true */ `dynamic/${path}`);
1104
- return module[functionName];
1105
- }
1106
- catch (error) {
1107
- console.error(`Error loading dynamic function ${functionName} from ${path}:`, error);
1108
- return null;
1109
- }
1110
- };
1111
- const generateConversationId = () => {
1112
- try {
1113
- return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
1114
- }
1115
- catch (error) {
1116
- console.error("generateConversationId error", error);
1117
- return 0;
1118
- }
1119
- };
1120
- /**
1121
- * Generates a conversation object structure with empty messages array and current timestamp
1122
- * @returns {object} - The conversation object structure
1123
- */
1124
- const generateConversationObject = (conversationId) => {
1125
- try {
1126
- return {
1127
- id: conversationId,
1128
- name: `Conversation ${conversationId}`,
1129
- timestamp: new Date().toISOString(),
1130
- messages: [],
1131
- };
1132
- }
1133
- catch (error) {
1134
- console.error("generateConversationObject error", error);
1135
- return {
1136
- id: conversationId,
1137
- name: `Conversation ${conversationId}`,
1138
- timestamp: new Date().toISOString(),
1139
- messages: [],
1140
- };
1141
- }
1142
- };
1143
- /**
1144
- * Extracts userExplicitInput and textWithColumnNames from a saved filter set.
1145
- * @param {object} selectedFilterSet - The selected saved filter set object
1146
- * @param {string} userText - The user's input text (used to build textWithColumnNames)
1147
- * @param {object} existingExplicitInput - Optional existing userExplicitInput to merge with (e.g. from @ mentions)
1148
- * @returns {{ userExplicitInput: object, textWithColumnNames: string }}
1149
- */
1150
- const extractSavedFilterData = (selectedFilterSet, userText = "", existingExplicitInput = {}) => {
1151
- let userExplicitInput = { ...existingExplicitInput };
1152
- let textWithColumnNames = "";
1153
- if (!selectedFilterSet?.saved_filter_preference) {
1154
- return { userExplicitInput: existingExplicitInput, textWithColumnNames };
1155
- }
1156
- selectedFilterSet.saved_filter_preference.forEach((filter) => {
1157
- const attrName = filter.attribute_name;
1158
- if (!attrName)
1159
- return;
1160
- let filterValues = [];
1161
- if (Array.isArray(filter.values)) {
1162
- filter.values.forEach((v) => {
1163
- if (v && Array.isArray(v.values)) {
1164
- filterValues.push(...v.values.map(String));
1165
- }
1166
- else if (typeof v === "string" || typeof v === "number") {
1167
- filterValues.push(String(v));
1168
- }
1169
- });
1170
- }
1171
- if (filterValues.length > 0) {
1172
- if (userExplicitInput[attrName]) {
1173
- userExplicitInput[attrName] = [
1174
- ...new Set([...userExplicitInput[attrName], ...filterValues]),
1175
- ];
1176
- }
1177
- else {
1178
- userExplicitInput[attrName] = [...new Set(filterValues)];
1179
- }
1180
- const filterText = `${attrName}: ${filterValues.join(", ")}`;
1181
- textWithColumnNames = textWithColumnNames
1182
- ? `${filterText} ${textWithColumnNames}`
1183
- : `${filterText} ${userText}`;
1184
- }
1185
- });
1186
- // Ensure textWithColumnNames ends with the user's text
1187
- if (textWithColumnNames && !textWithColumnNames.includes(userText) && userText.trim()) {
1188
- textWithColumnNames = `${textWithColumnNames} ${userText}`.trim();
1189
- }
1190
- return { userExplicitInput, textWithColumnNames };
1191
- };
1192
-
1193
- // Special character mapping for text replacement
1194
- const SPECIAL_CHARACTER_MAPPING = {
1195
- __ia_char_01: "'",
1196
- __ia_char_02: '"',
1197
- __ia_char_03: "/",
1198
- __ia_char_04: "\\",
1199
- __ia_char_05: "`",
1200
- __ia_char_06: "~",
1201
- __ia_char_07: "!",
1202
- __ia_char_08: "@",
1203
- __ia_char_09: "#",
1204
- __ia_char_10: "$",
1205
- __ia_char_11: "%",
1206
- __ia_char_12: "^",
1207
- __ia_char_13: "&",
1208
- __ia_char_14: "*",
1209
- __ia_char_15: "(",
1210
- __ia_char_16: ")",
1211
- __ia_char_19: "=",
1212
- __ia_char_20: "+",
1213
- __ia_char_21: "{",
1214
- __ia_char_22: "}",
1215
- __ia_char_23: "[",
1216
- __ia_char_24: "]",
1217
- __ia_char_25: "|",
1218
- __ia_char_26: ":",
1219
- __ia_char_27: ";",
1220
- __ia_char_28: "<",
1221
- __ia_char_29: ">",
1222
- __ia_char_30: ",",
1223
- __ia_char_31: ".",
1224
- __ia_char_32: "?",
1225
- __ia_char_33: "/",
1226
- };
1227
- const navigationOptions = [
1228
- {
1229
- link: "/inventory-smart/decision-dashboard",
1230
- screen_name: "Dashboard",
1231
- flow_type: "navigation",
1232
- },
1233
- {
1234
- link: `/inventory-smart/create-allocation/?step=0`,
1235
- flow_type: "navigation",
1236
- screen_name: "Allocation",
1237
- },
1238
- {
1239
- link: "/inventory-smart/configuration",
1240
- flow_type: "navigation",
1241
- screen_name: "Configurations",
1242
- },
1243
- {
1244
- link: "/inventory-smart/store-eligibility-grouping",
1245
- flow_type: "navigation",
1246
- screen_name: "Grouping",
1247
- },
1248
- {
1249
- link: "/inventory-smart/constraints",
1250
- flow_type: "navigation",
1251
- screen_name: "Constraints",
1252
- },
1253
- {
1254
- link: "/inventory-smart/ada/dashboard",
1255
- flow_type: "navigation",
1256
- screen_name: "ADA Visual",
1257
- },
1258
- ];
1259
- const insightsOptions = [
1260
- {
1261
- link: "/inventory-smart/decision-dashboard",
1262
- screen_name: "Dashboard",
1263
- flow_type: "insights",
1264
- },
1265
- {
1266
- link: `/inventory-smart/create-allocation/?step=0`,
1267
- flow_type: "insights",
1268
- screen_name: "Allocation",
1269
- },
1270
- {
1271
- link: "/inventory-smart/store-eligibility-grouping",
1272
- flow_type: "insights",
1273
- screen_name: "Configurations",
1274
- },
1275
- {
1276
- link: "/inventory-smart/configuration",
1277
- flow_type: "insights",
1278
- screen_name: "Grouping",
1279
- },
1280
- {
1281
- link: "/inventory-smart/constraints",
1282
- flow_type: "insights",
1283
- screen_name: "Constraints",
1284
- },
1285
- {
1286
- link: "/inventory-smart/ada/dashboard",
1287
- flow_type: "insights",
1288
- screen_name: "ADA Visual",
1289
- },
1290
- ];
1291
- const screenOptions = [
1292
- {
1293
- link: "/inventory-smart/decision-dashboard",
1294
- screen_name: "InventoryDashboard",
1295
- filterCongfigurationName: "decisionDashboardFilterConfiguration",
1296
- },
1297
- {
1298
- link: "/inventory-smart/product-profile",
1299
- screen_name: "Product Profile",
1300
- filterCongfigurationName: "productProfileDashboardFilterConfig",
1301
- },
1302
- {
1303
- link: `/inventory-smart/create-allocation/?step=0`,
1304
- screen_name: "Allocation",
1305
- filterCongfigurationName: "createAllocationFilterConfiguration",
1306
- },
1307
- {
1308
- link: "/inventory-smart/store-eligibility-grouping",
1309
- screen_name: "Inventorysmart Store Eligibility Group",
1310
- filterCongfigurationName: "storeGroupingFilterConfiguration",
1311
- },
1312
- {
1313
- link: "/inventory-smart/configuration",
1314
- screen_name: "Inventorysmart Configurations",
1315
- filterCongfigurationName: "productStatusFilterConfiguration",
1316
- },
1317
- {
1318
- link: "/inventory-smart/constraints",
1319
- screen_name: "Inventorysmart Constraints",
1320
- filterCongfigurationName: "rulesConstraintsFilterConfig",
1321
- },
1322
- {
1323
- link: "/inventory-smart/allocation-reports",
1324
- screen_name: "Inventorysmart Reportings",
1325
- filterCongfigurationName: "lostSalesFilterConfiguration",
1326
- },
1327
- {
1328
- link: "/inventory-smart/ada/dashboard",
1329
- screen_name: "Inventorysmart ADA Dashboard",
1330
- filterCongfigurationName: "adaVisualFilterConfiguration",
1331
- },
1332
- ];
1333
-
1752
+ return module[functionName];
1753
+ }
1754
+ catch (error) {
1755
+ console.error(`Error loading dynamic function ${functionName} from ${path}:`, error);
1756
+ return null;
1757
+ }
1758
+ };
1759
+ const generateConversationId = () => {
1760
+ try {
1761
+ return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
1762
+ }
1763
+ catch (error) {
1764
+ console.error("generateConversationId error", error);
1765
+ return 0;
1766
+ }
1767
+ };
1334
1768
  /**
1335
- * Core utility functions copied from core/Utils/functions/utils
1336
- * These are internalized to make chatbot-v2 self-contained
1769
+ * Generates a conversation object structure with empty messages array and current timestamp
1770
+ * @returns {object} - The conversation object structure
1337
1771
  */
1772
+ const generateConversationObject = (conversationId) => {
1773
+ try {
1774
+ return {
1775
+ id: conversationId,
1776
+ name: `Conversation ${conversationId}`,
1777
+ timestamp: new Date().toISOString(),
1778
+ messages: [],
1779
+ };
1780
+ }
1781
+ catch (error) {
1782
+ console.error("generateConversationObject error", error);
1783
+ return {
1784
+ id: conversationId,
1785
+ name: `Conversation ${conversationId}`,
1786
+ timestamp: new Date().toISOString(),
1787
+ messages: [],
1788
+ };
1789
+ }
1790
+ };
1338
1791
  /**
1339
- * Replace special characters in a string
1792
+ * Extracts userExplicitInput and textWithColumnNames from a saved filter set.
1793
+ * @param {object} selectedFilterSet - The selected saved filter set object
1794
+ * @param {string} userText - The user's input text (used to build textWithColumnNames)
1795
+ * @param {object} existingExplicitInput - Optional existing userExplicitInput to merge with (e.g. from @ mentions)
1796
+ * @returns {{ userExplicitInput: object, textWithColumnNames: string }}
1340
1797
  */
1341
- const replaceSpecialCharacter = (str) => {
1342
- if (typeof str === "object") {
1343
- return str;
1798
+ const extractSavedFilterData = (selectedFilterSet, userText = "", existingExplicitInput = {}) => {
1799
+ let userExplicitInput = { ...existingExplicitInput };
1800
+ let textWithColumnNames = "";
1801
+ if (!selectedFilterSet?.saved_filter_preference) {
1802
+ return { userExplicitInput: existingExplicitInput, textWithColumnNames };
1344
1803
  }
1345
- else {
1346
- let result = str;
1347
- if (SPECIAL_CHARACTER_MAPPING) {
1348
- Object.keys(SPECIAL_CHARACTER_MAPPING).forEach((key) => {
1349
- if (result?.includes(key)) {
1350
- result = result.replaceAll(key, SPECIAL_CHARACTER_MAPPING[key]);
1804
+ selectedFilterSet.saved_filter_preference.forEach((filter) => {
1805
+ const attrName = filter.attribute_name;
1806
+ if (!attrName)
1807
+ return;
1808
+ let filterValues = [];
1809
+ if (Array.isArray(filter.values)) {
1810
+ filter.values.forEach((v) => {
1811
+ if (v && Array.isArray(v.values)) {
1812
+ filterValues.push(...v.values.map(String));
1813
+ }
1814
+ else if (typeof v === "string" || typeof v === "number") {
1815
+ filterValues.push(String(v));
1351
1816
  }
1352
1817
  });
1353
1818
  }
1354
- return result;
1355
- }
1356
- };
1357
- /**
1358
- * @function
1359
- * @description Function is used to return string by replacing the special characters with respective key mapped to SPECIAL_CHARACTER_MAPPING
1360
- * @param {String} str
1361
- * @returns {String} key of mapped special character used in the string
1362
- */
1363
- const replaceSpecialCharToCharCode = (str) => {
1364
- let re = new RegExp(`[${Object.values(SPECIAL_CHARACTER_MAPPING).join("")}]`, "g");
1365
- return str.replace(re, function (matched) {
1366
- let code;
1367
- for (const [key, value] of Object.entries(SPECIAL_CHARACTER_MAPPING)) {
1368
- if (value === matched) {
1369
- code = key;
1370
- return code;
1819
+ if (filterValues.length > 0) {
1820
+ if (userExplicitInput[attrName]) {
1821
+ userExplicitInput[attrName] = [
1822
+ ...new Set([...userExplicitInput[attrName], ...filterValues]),
1823
+ ];
1824
+ }
1825
+ else {
1826
+ userExplicitInput[attrName] = [...new Set(filterValues)];
1371
1827
  }
1828
+ const filterText = `${attrName}: ${filterValues.join(", ")}`;
1829
+ textWithColumnNames = textWithColumnNames
1830
+ ? `${filterText} ${textWithColumnNames}`
1831
+ : `${filterText} ${userText}`;
1372
1832
  }
1373
- return code;
1374
- });
1375
- };
1376
-
1377
- /**
1378
- * Utility functions extracted from core/Utils/functions/utils.js
1379
- * Only includes functions used by chatbot-v2
1380
- */
1381
-
1382
- // Users listing endpoint (same as core's GET_USERS). Inlined here so this
1383
- // standalone package doesn't depend on the core user-management service.
1384
- const GET_USERS_URL = "/core/user-mgmt/list";
1385
-
1386
- // Convert pixels to rem
1387
- const pxToRem = (px) => `${px / 16}rem`;
1388
-
1389
- // Resolve the current user's code via the users API, matching the logged-in
1390
- // email (localStorage "name"). Mirrors core/Utils/functions/utils.getCurrentUserId
1391
- // so the multi-chat history APIs receive a real user_id (sessionStorage may not
1392
- // carry it in the standalone package host).
1393
- const getCurrentUserId = async () => {
1394
- try {
1395
- const postBody = {
1396
- meta: {
1397
- search: [],
1398
- range: [],
1399
- sort: [],
1400
- },
1401
- };
1402
- const users = await axiosInstance({
1403
- url: GET_USERS_URL,
1404
- method: "POST",
1405
- data: postBody,
1406
1833
  });
1407
- const loggedInUserEmail = localStorage.getItem("name");
1408
- const user = users?.data?.data?.filter((item) => {
1409
- return item.email === loggedInUserEmail;
1410
- });
1411
- return user[0]?.user_code;
1412
- } catch (error) {
1413
- console.error("getCurrentUserId error", error);
1414
- }
1415
- };
1416
-
1417
- // Get user name from session storage
1418
- const getUserName = () => {
1419
- const userDetails = JSON.parse(sessionStorage.getItem("userDetails") || "{}");
1420
- return userDetails?.user_name || "User";
1421
- };
1422
-
1423
- // Get formatted application name based on URL
1424
- const getFormattedApplicationName = (applicationURL) => {
1425
- switch (applicationURL) {
1426
- case "user-management":
1427
- case "tenantconfig":
1428
- return "application access management";
1429
- case "assort-smart":
1430
- return "AssortSmart";
1431
- case "configurator":
1432
- return "module configurator";
1433
- case "inventory-smart":
1434
- return "InventorySmart";
1435
- case "ada":
1436
- return "ADA";
1437
- case "plan-smart":
1438
- return "PlanSmart";
1439
- case "adaconfigurator":
1440
- return "ADAConfigurator";
1441
- case "item-smart":
1442
- return "ItemSmart";
1443
- case "item-smart-new":
1444
- return "ItemSmart-New";
1445
- case "source-smart":
1446
- return "SourceSmart";
1447
- case "pricesmart-markdown":
1448
- return "PriceSmart Markdown";
1449
- case "pricesmart-promo":
1450
- return "PriceSmart Promo";
1451
- case "agentic-assort":
1452
- return "AssortSmart";
1453
- case "source-smart":
1454
- return "SourceSmart"
1455
- case "size-smart":
1456
- return "SizeSmart"
1457
- default:
1458
- return "workflow input center";
1459
- }
1834
+ // Ensure textWithColumnNames ends with the user's text
1835
+ if (textWithColumnNames && !textWithColumnNames.includes(userText) && userText.trim()) {
1836
+ textWithColumnNames = `${textWithColumnNames} ${userText}`.trim();
1837
+ }
1838
+ return { userExplicitInput, textWithColumnNames };
1460
1839
  };
1461
1840
 
1462
1841
  /**
@@ -2492,12 +2871,12 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
2492
2871
  : chatbotContext[key]?.type === "number" ? Number(value) : value.toString();
2493
2872
  // Decode special characters for chat_input display
2494
2873
  if (isArray(value)) {
2495
- value = value.map((item) => replaceSpecialCharacter(item.toString()));
2874
+ value = value.map((item) => replaceSpecialCharacter$2(item.toString()));
2496
2875
  }
2497
2876
  else {
2498
- value = replaceSpecialCharacter(value.toString());
2877
+ value = replaceSpecialCharacter$2(value.toString());
2499
2878
  }
2500
- payload.chat_input = payload.chat_input + `${replaceSpecialCharacter(value)},`;
2879
+ payload.chat_input = payload.chat_input + `${replaceSpecialCharacter$2(value)},`;
2501
2880
  }
2502
2881
  }
2503
2882
  dispatch(setChatbotContext({}));
@@ -2641,7 +3020,72 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
2641
3020
  };
2642
3021
  };
2643
3022
 
3023
+ /**
3024
+ * SmartBot Redux action type constants.
3025
+ * These MUST match the consumer's core/actions/types.js values exactly
3026
+ * so actions dispatched by the package are handled by the host reducer.
3027
+ */
3028
+ const SET_SMART_BOT_ACTIVE = "SET_SMART_BOT_ACTIVE";
3029
+ const SET_IS_SMART_BOT_RESTRICTED = "SET_IS_SMART_BOT_RESTRICTED";
3030
+ const SET_CHATBOT_CONTEXT = "SET_CHATBOT_CONTEXT";
3031
+ const SET_THINKING_CONTEXT = "SET_THINKING_CONTEXT";
3032
+ const SET_HIERARCHY_KEY_VALUE_PAIR = "SET_HIERARCHY_KEY_VALUE_PAIR";
3033
+ const SET_CURRENT_AGENT_CHAT_ID = "SET_CURRENT_AGENT_CHAT_ID";
3034
+ const SET_PERSISTED_FORM_VALUES = "SET_PERSISTED_FORM_VALUES";
3035
+ const CLEAR_PERSISTED_FORM_VALUES = "CLEAR_PERSISTED_FORM_VALUES";
3036
+ const SET_SAVED_FILTER_SETS = "SET_SAVED_FILTER_SETS";
3037
+ const SET_STEP_FORM_RESTREAM_PAYLOAD = "SET_STEP_FORM_RESTREAM_PAYLOAD";
3038
+ const SET_STEP_FORM_STREAM_DATA = "SET_STEP_FORM_STREAM_DATA";
3039
+ const SET_MINIMIZED_STREAM_DATA = "SET_MINIMIZED_STREAM_DATA";
3040
+ const SET_CHATBOT_FILTER_OPTIONS = "SET_CHATBOT_FILTER_OPTIONS";
3041
+
3042
+ /**
3043
+ * SmartBot Redux action creators.
3044
+ * Each is a thunk `(value) => (dispatch) => dispatch({...})` matching the
3045
+ * consumer's core/actions/smartBotActions.js signatures exactly.
3046
+ */
3047
+ const setSmartBotActive = (value) => (dispatch) => {
3048
+ dispatch({ type: SET_SMART_BOT_ACTIVE, payload: value });
3049
+ };
3050
+ const setIsSmartBotRestricted = (value) => (dispatch) => {
3051
+ dispatch({ type: SET_IS_SMART_BOT_RESTRICTED, payload: value });
3052
+ };
3053
+ const setChatbotContext = (value) => (dispatch) => {
3054
+ dispatch({ type: SET_CHATBOT_CONTEXT, payload: value });
3055
+ };
3056
+ const setThinkingContext = (value) => (dispatch) => {
3057
+ dispatch({ type: SET_THINKING_CONTEXT, payload: value });
3058
+ };
3059
+ const setHierarchyKeyValue = (value) => (dispatch) => {
3060
+ dispatch({ type: SET_HIERARCHY_KEY_VALUE_PAIR, payload: value });
3061
+ };
3062
+ const setCurrentAgentChatId = (value) => (dispatch) => {
3063
+ dispatch({ type: SET_CURRENT_AGENT_CHAT_ID, payload: value });
3064
+ };
3065
+ const setPersistedFormValues = (value) => (dispatch) => {
3066
+ dispatch({ type: SET_PERSISTED_FORM_VALUES, payload: value });
3067
+ };
3068
+ const clearPersistedFormValues = () => (dispatch) => {
3069
+ dispatch({ type: CLEAR_PERSISTED_FORM_VALUES });
3070
+ };
3071
+ const setStepFormRestreamPayload = (value) => (dispatch) => {
3072
+ dispatch({ type: SET_STEP_FORM_RESTREAM_PAYLOAD, payload: value });
3073
+ };
3074
+ const setSavedFilterSets = (value) => (dispatch) => {
3075
+ dispatch({ type: SET_SAVED_FILTER_SETS, payload: value });
3076
+ };
3077
+ const setStepFormStreamData = (value) => (dispatch) => {
3078
+ dispatch({ type: SET_STEP_FORM_STREAM_DATA, payload: value });
3079
+ };
3080
+ const setMinimizedStreamData = (value) => (dispatch) => {
3081
+ dispatch({ type: SET_MINIMIZED_STREAM_DATA, payload: value });
3082
+ };
3083
+ const setChatbotFilterOptions = (value) => (dispatch) => {
3084
+ dispatch({ type: SET_CHATBOT_FILTER_OPTIONS, payload: value });
3085
+ };
3086
+
2644
3087
  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) => {
3088
+ const { callbacks } = useChatbotDeps();
2645
3089
  const navSessionIdRef = useRef(navSessionId);
2646
3090
  useEffect(() => {
2647
3091
  navSessionIdRef.current = navSessionId;
@@ -3090,7 +3534,9 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
3090
3534
  });
3091
3535
  }
3092
3536
  for (const key in preSelectedFilters) {
3093
- dispatch(setSelectedFilters({ [key]: preSelectedFilters[key] }));
3537
+ if (callbacks?.onSetSelectedFilters) {
3538
+ callbacks.onSetSelectedFilters({ [key]: preSelectedFilters[key] });
3539
+ }
3094
3540
  }
3095
3541
  for (const key in preSelectedFilters) {
3096
3542
  preSelectedFilters[key].forEach((selectedFilter) => {
@@ -3108,7 +3554,9 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
3108
3554
  filterConfig: updateFilterConfigData,
3109
3555
  appliedFilterData: appliedFilterData,
3110
3556
  };
3111
- dispatch(setFilterConfiguration(obj));
3557
+ if (callbacks?.onSetFilterConfiguration) {
3558
+ callbacks.onSetFilterConfiguration(obj);
3559
+ }
3112
3560
  const applyFilterBtn = document.getElementById("filterBtn");
3113
3561
  setTimeout(() => {
3114
3562
  applyFilterBtn.click();
@@ -4038,19 +4486,6 @@ const useStyles$b = makeStyles((theme) => ({
4038
4486
  fontSize: "14px",
4039
4487
  marginRight: "7px",
4040
4488
  },
4041
- userViewBlock: {
4042
- display: "inline-flex", // Automatically adjust width to fit content
4043
- alignSelf: "flex-end", // Align message bubble to the right
4044
- background: theme.palette.grey[300], // Grey background for the message bubble
4045
- padding: "0.75rem", // Padding around the message
4046
- borderRadius: "0.5rem",
4047
- marginBottom: "0.5rem",
4048
- maxWidth: "80%", // Cap the width for long messages
4049
- minWidth: "20%", // Ensure small messages like "Hi" take minimal space
4050
- wordWrap: "break-word", // Wrap long words or URLs
4051
- textAlign: "left",
4052
- width: "fit-content",
4053
- },
4054
4489
  firstRow: {
4055
4490
  display: "flex",
4056
4491
  alignItems: "center", // Align time and double ticks vertically
@@ -4086,9 +4521,6 @@ const useStyles$b = makeStyles((theme) => ({
4086
4521
  fontSize: "14px",
4087
4522
  lineHeight: "21px",
4088
4523
  },
4089
- boldText: {
4090
- fontWeight: 600,
4091
- },
4092
4524
  combinedBlockHeaderTitle: {
4093
4525
  marginBottom: "0.5rem",
4094
4526
  },
@@ -4655,8 +5087,9 @@ const useChatState = () => {
4655
5087
  const [deleteOpen, setDeleteOpen] = useState(false);
4656
5088
  const [deleteTargetId, setDeleteTargetId] = useState(null);
4657
5089
  // Selectors
4658
- const filterReducerState = useSelector((state) => state.filterReducer);
4659
- const notificationData = useSelector((state) => state.notificationReducer.notificationData);
5090
+ const { selectors } = useChatbotDeps();
5091
+ const filterReducerState = useSelector(selectors?.getFilterState ?? NULL_SELECTOR);
5092
+ const notificationData = useSelector(selectors?.getNotificationData ?? EMPTY_ARRAY_SELECTOR);
4660
5093
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
4661
5094
  const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
4662
5095
  // All useRef declarations
@@ -5983,7 +6416,7 @@ const AxiosSource = (url, opts, messageToStoreRef) => {
5983
6416
  let lastProcessedLength = 0;
5984
6417
  // Carry-over for partial SSE frames between progress events
5985
6418
  let carryOver = "";
5986
- axiosInstance({
6419
+ httpRequest({
5987
6420
  method: opts.method || "GET",
5988
6421
  url: url,
5989
6422
  headers: opts.headers,
@@ -6200,6 +6633,7 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
6200
6633
  messageStoreRef.current.initValue = false;
6201
6634
  stepFormStreamControl.initValue = false;
6202
6635
  }
6636
+ const { BASE_API } = getApiConstants();
6203
6637
  const endPoint = baseUrl
6204
6638
  ? `${BASE_API}${baseUrl}/chatbot/agent/init`
6205
6639
  : `${BASE_API}/core/chatbot/agent/init`;
@@ -6460,20 +6894,808 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
6460
6894
  }, 1000);
6461
6895
  }
6462
6896
  else {
6463
- chunksRef.push({ status: "content", message: "Please reach out to IA for this, as this didn't work even after retry" });
6464
- dispatch(setStepFormStreamData({ status: "error", chunks: [...chunksRef], sessionId }));
6897
+ chunksRef.push({ status: "content", message: "Please reach out to IA for this, as this didn't work even after retry" });
6898
+ dispatch(setStepFormStreamData({ status: "error", chunks: [...chunksRef], sessionId }));
6899
+ }
6900
+ }
6901
+ });
6902
+ };
6903
+ const renderButtons = () => {
6904
+ if (!Array.isArray(bodyText.buttons)) {
6905
+ return null;
6906
+ }
6907
+ return bodyText.buttons.map((button, index) => (jsx("div", { children: jsx(Button, { variant: button.variant || "primary", size: button.size || "medium", onClick: () => handleButtonClick(), disabled: button.disabled || isFormDisabled || (isStepFormSubmit && !isFormValid), className: button.className, icon: button.icon, iconPlacement: button.iconPlacement || "left", children: button.label }) }, index)));
6908
+ };
6909
+ return (jsxs("div", { className: classes.buttonContainer, children: [bodyText.message && (jsx("div", { className: classes.message, children: bodyText.message })), jsx("div", { className: classes.buttonRow, children: renderButtons() })] }));
6910
+ };
6911
+
6912
+ // AG Grid Enterprise License Key
6913
+ 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";
6914
+ // Default decimal rounding
6915
+ const DEFAULT_ROUNDOFF = 2;
6916
+ // Column types that should not be rounded
6917
+ const IGNORE_ROUNDOFF = ["int"];
6918
+
6919
+ const modules = [
6920
+ AllEnterpriseModule,
6921
+ ClientSideRowModelModule,
6922
+ ServerSideRowModelModule,
6923
+ ValidationModule,
6924
+ ];
6925
+ // ─── Local State ────────────────────────────────────────────────────────────
6926
+ const ACTIONS = {
6927
+ SET_AGGRID_STATE: "SET_AGGRID_STATE",
6928
+ SET_CLIENT_SIDE_TABLE_DATA: "SET_CLIENT_SIDE_TABLE_DATA",
6929
+ SET_PAGINATION_ENABLED: "SET_PAGINATION_ENABLED",
6930
+ };
6931
+ const initialState = {
6932
+ agGrid: {},
6933
+ clientSideTableData: [],
6934
+ paginationEnabled: true,
6935
+ };
6936
+ const agGridReducer = (state, action) => {
6937
+ switch (action.type) {
6938
+ case ACTIONS.SET_AGGRID_STATE:
6939
+ return { ...state, agGrid: action.payload };
6940
+ case ACTIONS.SET_CLIENT_SIDE_TABLE_DATA:
6941
+ return { ...state, clientSideTableData: action.payload };
6942
+ case ACTIONS.SET_PAGINATION_ENABLED:
6943
+ return { ...state, paginationEnabled: action.payload };
6944
+ default:
6945
+ return state;
6946
+ }
6947
+ };
6948
+ // ─── Server-Side Datasource ─────────────────────────────────────────────────
6949
+ const createServerSideDatasource = (config) => ({
6950
+ getRows: async (params) => {
6951
+ const { cacheBlockSize, manualCallBackRef } = config;
6952
+ try {
6953
+ const { startRow, sortModel, filterModel } = params.request;
6954
+ const page = Math.floor(startRow / cacheBlockSize);
6955
+ // Build a simple meta payload with sort and search info
6956
+ const meta = { search: [], range: [], sort: [] };
6957
+ if (sortModel?.length) {
6958
+ meta.sort = sortModel.map((s) => ({
6959
+ column: s.colId,
6960
+ order: s.sort,
6961
+ }));
6962
+ }
6963
+ const manualCallBack = manualCallBackRef.current;
6964
+ if (!manualCallBack) {
6965
+ params.fail();
6966
+ return;
6967
+ }
6968
+ const paginatedRows = await manualCallBack(meta, page, params);
6969
+ if (!paginatedRows?.data?.length) {
6970
+ if (params.request.startRow === 0) {
6971
+ params.api.showNoRowsOverlay();
6972
+ }
6973
+ params.success({ rowData: [], rowCount: startRow });
6974
+ return;
6975
+ }
6976
+ params.api.hideOverlay();
6977
+ const rowCount = paginatedRows.data.length < cacheBlockSize
6978
+ ? startRow + paginatedRows.data.length
6979
+ : paginatedRows.totalCount;
6980
+ params.success({ rowData: paginatedRows.data, rowCount });
6981
+ }
6982
+ catch (error) {
6983
+ console.error("Server-side datasource error:", error);
6984
+ params.fail();
6985
+ }
6986
+ },
6987
+ });
6988
+ // ─── Component ──────────────────────────────────────────────────────────────
6989
+ const AgGridComponent = (props) => {
6990
+ const {
6991
+ // Data
6992
+ rowModelType = "clientSide", cacheBlockSize, serverSideStoreType,
6993
+ // Selection
6994
+ onSelectionChanged,
6995
+ // ─── Impact UI / Custom Props ───
6996
+ customClass = "",
6997
+ // Callbacks
6998
+ selectAllHeaderComponent, uniqueRowId, manualCallBack,
6999
+ // Sizing
7000
+ sizeColumnsToFitFlag = false, } = props;
7001
+ const [localState, localDispatch] = useReducer(agGridReducer, initialState);
7002
+ const manualCallBackRef = useRef(manualCallBack);
7003
+ manualCallBackRef.current = manualCallBack;
7004
+ const setPaginationEnabled = useCallback((shouldEnable) => localDispatch({
7005
+ type: ACTIONS.SET_PAGINATION_ENABLED,
7006
+ payload: shouldEnable,
7007
+ }), []);
7008
+ // Default column definition
7009
+ const defaultColDef = useMemo(() => ({
7010
+ resizable: true,
7011
+ sortable: false,
7012
+ minWidth: 150,
7013
+ wrapText: false,
7014
+ autoHeight: false,
7015
+ }), []);
7016
+ // Grid options for row selection
7017
+ const gridOptions = useMemo(() => {
7018
+ const opts = {};
7019
+ if (selectAllHeaderComponent) {
7020
+ opts.rowSelection = {
7021
+ mode: "multiRow",
7022
+ groupSelects: "self",
7023
+ checkboxes: true,
7024
+ };
7025
+ opts.selectionColumnDef = {
7026
+ pinned: "left",
7027
+ suppressSizeToFit: true,
7028
+ lockPosition: "left",
7029
+ suppressHeaderMenuButton: true,
7030
+ minWidth: 56,
7031
+ maxWidth: 56,
7032
+ cellStyle: { display: "flex" },
7033
+ headerClass: "ag-selection-column-header",
7034
+ };
7035
+ }
7036
+ // When no selectAllHeaderComponent, don't set rowSelection at all
7037
+ // — AG Grid will default to no selection column
7038
+ return opts;
7039
+ }, [selectAllHeaderComponent]);
7040
+ // Server-side datasource
7041
+ const datasource = useMemo(() => {
7042
+ if (!rowModelType || rowModelType === "clientSide")
7043
+ return undefined;
7044
+ if (rowModelType === "serverSide") {
7045
+ return createServerSideDatasource({
7046
+ cacheBlockSize: cacheBlockSize || 100,
7047
+ manualCallBackRef,
7048
+ });
7049
+ }
7050
+ return undefined;
7051
+ }, [rowModelType, cacheBlockSize]);
7052
+ // Process columns
7053
+ const processedColumns = useMemo(() => {
7054
+ try {
7055
+ if (isEmpty$1(props.columns))
7056
+ return [];
7057
+ return cloneDeep(props.columns);
7058
+ }
7059
+ catch (error) {
7060
+ console.error("Error processing columns:", error);
7061
+ return [];
7062
+ }
7063
+ }, [props.columns]);
7064
+ // Update client-side data when rowdata changes
7065
+ useEffect(() => {
7066
+ if (isEmpty$1(props.rowdata) && isEmpty$1(localState?.clientSideTableData))
7067
+ return;
7068
+ localDispatch({
7069
+ type: ACTIONS.SET_CLIENT_SIDE_TABLE_DATA,
7070
+ payload: props.rowdata ?? [],
7071
+ });
7072
+ if (props?.pagination === true) {
7073
+ const pageSize = props?.paginationPageSize || 10;
7074
+ const shouldEnable = (props.rowdata?.length || 0) > pageSize;
7075
+ if (shouldEnable !== localState.paginationEnabled) {
7076
+ setPaginationEnabled(shouldEnable);
7077
+ }
7078
+ }
7079
+ }, [props.rowdata]);
7080
+ // Export to Excel handler
7081
+ const handleExportToExcel = () => {
7082
+ const api = localState.agGrid?.api;
7083
+ if (!api)
7084
+ return;
7085
+ api.exportDataAsExcel();
7086
+ };
7087
+ // Build customSystemButton with download
7088
+ const resolvedCustomSystemButton = useMemo(() => {
7089
+ // If props.customSystemButton is provided, use it directly
7090
+ // The parent (TableContent) already builds the full JSX
7091
+ return props.customSystemButton || null;
7092
+ }, [props.customSystemButton]);
7093
+ return (jsx(AgGridProvider, { modules: modules, licenseKey: AG_GRID_V36_LICENCE_KEY, children: jsx("div", { className: classNames("core-ag-theme-alpine", customClass), children: jsx(TableV36
7094
+ // AG Grid Props
7095
+ , {
7096
+ // AG Grid Props
7097
+ columnDefs: processedColumns, rowData: !rowModelType || rowModelType === "clientSide"
7098
+ ? localState?.clientSideTableData
7099
+ : 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
7100
+ ? [props.paginationPageSize]
7101
+ : [10, 20], suppressColumnMoveAnimation: true, onGridReady: (params) => {
7102
+ localDispatch({
7103
+ type: ACTIONS.SET_AGGRID_STATE,
7104
+ payload: params,
7105
+ });
7106
+ }, onFirstDataRendered: (params) => {
7107
+ if (sizeColumnsToFitFlag) {
7108
+ params.api.sizeColumnsToFit();
7109
+ }
7110
+ }, onSelectionChanged: (event) => {
7111
+ if (onSelectionChanged && typeof onSelectionChanged === "function") {
7112
+ onSelectionChanged(event);
7113
+ }
7114
+ }, onGridSizeChanged: (params) => {
7115
+ if (sizeColumnsToFitFlag) {
7116
+ params.api.sizeColumnsToFit();
7117
+ }
7118
+ }, getRowId: uniqueRowId
7119
+ ? (params) => String(params.data?.[uniqueRowId] ?? "")
7120
+ : undefined, rowModelType: rowModelType, cacheBlockSize: cacheBlockSize, serverSideStoreType: serverSideStoreType, tooltipShowMode: "whenTruncated", enableBrowserTooltips: false,
7121
+ // Core props
7122
+ defaultColDef: defaultColDef, ...gridOptions,
7123
+ // Impact UI Props
7124
+ 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 }) }) }));
7125
+ };
7126
+
7127
+ // ─── Number Formatter Cache ─────────────────────────────────────────────────
7128
+ const formatCache = new Map();
7129
+ const getNumberFormatter = (minimumFractionDigits = DEFAULT_ROUNDOFF, maximumFractionDigits = DEFAULT_ROUNDOFF, p_instance) => {
7130
+ if (IGNORE_ROUNDOFF?.includes(p_instance?.colDef?.type)) {
7131
+ return new Intl.NumberFormat("en-US");
7132
+ }
7133
+ const cacheKey = `${minimumFractionDigits}-${maximumFractionDigits}`;
7134
+ if (!formatCache.has(cacheKey)) {
7135
+ formatCache.set(cacheKey, new Intl.NumberFormat("en-US", {
7136
+ minimumFractionDigits,
7137
+ maximumFractionDigits,
7138
+ }));
7139
+ }
7140
+ return formatCache.get(cacheKey);
7141
+ };
7142
+ // ─── Formatting Functions ───────────────────────────────────────────────────
7143
+ const numbersWithComma = (value, roundOffTo, disableCommaFormatting = false, displayBlank = false) => {
7144
+ const nf = getNumberFormatter(roundOffTo, roundOffTo, value);
7145
+ if (value?.value === "-" || value?.value === null) {
7146
+ if (displayBlank)
7147
+ return "";
7148
+ else
7149
+ return "-";
7150
+ }
7151
+ else if (disableCommaFormatting) {
7152
+ return value?.value || "";
7153
+ }
7154
+ else if (value?.value) {
7155
+ if (Number.isInteger(value?.value)) {
7156
+ let tempValue = parseInt(value?.value) > -1 ? Math.abs(value?.value) : value?.value;
7157
+ return nf.format(tempValue);
7158
+ }
7159
+ else {
7160
+ let replaceCommaValue = (value?.value).toString().replace(",", "");
7161
+ let tempValue = parseFloat(replaceCommaValue) > -1
7162
+ ? Math.abs(replaceCommaValue)
7163
+ : replaceCommaValue;
7164
+ if (roundOffTo > 0) {
7165
+ return nf.format(Number.parseFloat(tempValue).toFixed(roundOffTo));
7166
+ }
7167
+ else {
7168
+ return nf.format(Math.round(tempValue));
7169
+ }
7170
+ }
7171
+ }
7172
+ else if (value?.value === 0) {
7173
+ return nf.format(value?.value);
7174
+ }
7175
+ else {
7176
+ return value?.value || "";
7177
+ }
7178
+ };
7179
+ const percentFormatter = function (value, roundOffTo, dontMultiply, displayBlank = false) {
7180
+ if (value && value.value && !isNaN(Number(value.value))) {
7181
+ let cellData;
7182
+ let multiplier = dontMultiply ? 1 : 100;
7183
+ if (typeof value.value == Number || !isNaN(Number(value.value))) {
7184
+ cellData = value.value;
7185
+ let newVal = (cellData * multiplier).toFixed(roundOffTo);
7186
+ if (Math.abs(Number(newVal)) === 0) {
7187
+ newVal = 0?.toFixed(roundOffTo);
7188
+ }
7189
+ return newVal + "%";
7190
+ }
7191
+ else {
7192
+ return value.value;
7193
+ }
7194
+ }
7195
+ else if (value.value === 0) {
7196
+ return value.value?.toFixed(roundOffTo) + "%";
7197
+ }
7198
+ else if (displayBlank && (value.value === null || isNaN(value.value))) {
7199
+ return "";
7200
+ }
7201
+ else {
7202
+ return "-";
7203
+ }
7204
+ };
7205
+ const decimalsFormatter = function (x, toFix, shouldRoundOff, displayBlank = false) {
7206
+ const nf = getNumberFormatter(toFix, toFix, x);
7207
+ if (displayBlank && (x.value === null || isNaN(x.value))) {
7208
+ return "";
7209
+ }
7210
+ if (x?.colDef?.extra?.displayActualValue) {
7211
+ return x.value;
7212
+ }
7213
+ if (toFix === 3) {
7214
+ if (x.value === null || isNaN(x.value))
7215
+ return "-";
7216
+ else
7217
+ return parseFloat(x.value).toFixed(3);
7218
+ }
7219
+ if (x.value === 0) {
7220
+ return nf.format(0);
7221
+ }
7222
+ else if (x.value > 0) {
7223
+ if (toFix === 0) {
7224
+ return Math.round(x.value);
7225
+ }
7226
+ let roundOffTo = x?.colDef?.extra?.hasOwnProperty("roundOffTo")
7227
+ ? x?.colDef?.extra?.roundOffTo
7228
+ : toFix
7229
+ ? toFix
7230
+ : 2;
7231
+ if (x?.colDef?.extra?.doNotRoundOff)
7232
+ return parseFloat(x.value).toFixed(roundOffTo);
7233
+ else {
7234
+ let roundOffNumber = +("1" + "0".repeat(roundOffTo));
7235
+ let multipliedValue = x.value * roundOffNumber;
7236
+ let res = multipliedValue < 1 && multipliedValue > 0
7237
+ ? parseFloat(multipliedValue.toFixed(roundOffTo))
7238
+ : Math.round(multipliedValue) / roundOffNumber;
7239
+ return shouldRoundOff ? nf.format(res) : res;
7240
+ }
7241
+ }
7242
+ else {
7243
+ if (!x?.value || isNaN(Number(x?.value))) {
7244
+ if (x?.node?.group) {
7245
+ return "";
7246
+ }
7247
+ return "-";
7248
+ }
7249
+ if (toFix === 0 && x.value < 0) {
7250
+ return Math.round(x.value);
7251
+ }
7252
+ if (toFix > 0 &&
7253
+ x.value < 0 &&
7254
+ (x.is_negative_value_allowed || !x.is_negative_value_allowed)) {
7255
+ return shouldRoundOff
7256
+ ? nf.format(parseFloat((Math.round(x.value * 100) / 100).toFixed(toFix)))
7257
+ : parseFloat((Math.round(x.value * 100) / 100).toFixed(toFix));
7258
+ }
7259
+ return shouldRoundOff
7260
+ ? nf.format(parseFloat(x.value))
7261
+ : parseFloat(x.value);
7262
+ }
7263
+ };
7264
+ const currencyFormatter = function (value, roundOffTo, symbol) {
7265
+ const nf = getNumberFormatter(roundOffTo, roundOffTo, value);
7266
+ if (!value.value && value.value !== 0) {
7267
+ return value.value || "";
7268
+ }
7269
+ if (typeof value.value == Number || !isNaN(Number(value.value))) {
7270
+ let valsfor;
7271
+ const cellData = value.value;
7272
+ const toVal = Math.abs(value.value);
7273
+ if (toVal < 1 && toVal > -1) {
7274
+ valsfor = toVal.toFixed(roundOffTo);
7275
+ }
7276
+ else {
7277
+ valsfor = roundOffTo ? toVal : Math.round(toVal);
7278
+ }
7279
+ let newvalsfor = nf.format(Math.abs(Number(valsfor)).toFixed(roundOffTo));
7280
+ if (cellData >= 0) {
7281
+ return `${symbol}` + newvalsfor;
7282
+ }
7283
+ else {
7284
+ return `-${symbol}` + newvalsfor;
7285
+ }
7286
+ }
7287
+ else {
7288
+ return value?.value
7289
+ ? value?.value
7290
+ : value?.cell?.row?.subRows?.length > 0
7291
+ ? ""
7292
+ : "-";
7293
+ }
7294
+ };
7295
+ // Date format constants used by formattedDate
7296
+ const DATE_FORMATS = [
7297
+ "YYYY-MM-DD",
7298
+ "YYYY-MM-DDTHH:mm:ss",
7299
+ "YYYY-MM-DDTHH:mm:ssZ",
7300
+ "YYYY-MM-DDTHH:mm:ss.SSSZ",
7301
+ "MM/DD/YYYY",
7302
+ "DD/MM/YYYY",
7303
+ "MM-DD-YYYY",
7304
+ "DD-MM-YYYY",
7305
+ "YYYY/MM/DD",
7306
+ moment.ISO_8601,
7307
+ ];
7308
+ const formattedDate = (date, format, currentDateFormat) => {
7309
+ const updatedCurrentFormat = date && moment(date, DATE_FORMATS);
7310
+ return date && updatedCurrentFormat.isValid()
7311
+ ? moment(date, currentDateFormat ? currentDateFormat : updatedCurrentFormat._f).format(format)
7312
+ : "-";
7313
+ };
7314
+ const arrayToCommaFormatter = (value) => {
7315
+ if (value) {
7316
+ return isArray$1(value) && value?.length ? value?.join(", ") : value;
7317
+ }
7318
+ return "";
7319
+ };
7320
+ // ─── Non-Editable Cell Value Formatter ──────────────────────────────────────
7321
+ const DEFAULT_DATE_FORMAT$1 = "MM/DD/YYYY";
7322
+ const getDateFormat = (column) => {
7323
+ if (column?.dateFormatter)
7324
+ return column.dateFormatter;
7325
+ if (column?.formatter)
7326
+ return column.formatter;
7327
+ const tenantDateFormat = typeof localStorage !== "undefined"
7328
+ ? localStorage.getItem("tenantDateFormat")
7329
+ : null;
7330
+ return tenantDateFormat || DEFAULT_DATE_FORMAT$1;
7331
+ };
7332
+ const replaceSpecialCharacter$1 = (str) => {
7333
+ if (!str)
7334
+ return str;
7335
+ return String(str)
7336
+ .replace(/__ia_char_38__/g, "&")
7337
+ .replace(/__ia_char_60__/g, "<")
7338
+ .replace(/__ia_char_62__/g, ">")
7339
+ .replace(/__ia_char_34__/g, '"')
7340
+ .replace(/__ia_char_39__/g, "'")
7341
+ .replace(/__ia_char_96__/g, "`");
7342
+ };
7343
+ const fetchDefaultValue = (ins) => {
7344
+ if (isNil(ins?.value))
7345
+ return "";
7346
+ if (Array.isArray(ins.value))
7347
+ return ins.value
7348
+ .map((item) => !isNil(item) ? replaceSpecialCharacter$1(item.toString()) : "")
7349
+ .toString();
7350
+ else if (typeof ins.value === "boolean")
7351
+ return ins.value.toString();
7352
+ else
7353
+ return ins.value;
7354
+ };
7355
+ const getRoundOff$1 = (formatter) => {
7356
+ const map = {
7357
+ roundOff: 0,
7358
+ roundOfftoOneDecimals: 1,
7359
+ roundOfftoTwoDecimals: 2,
7360
+ roundOfftoThreeDecimals: 3,
7361
+ };
7362
+ return map[formatter] ?? DEFAULT_ROUNDOFF;
7363
+ };
7364
+ /**
7365
+ * Returns a valueFormatter function for non-editable cells based on column type.
7366
+ * This is the simplified version that handles display-only columns.
7367
+ */
7368
+ const nonEditableCellValueFormatter = (item, forFooter, shouldRoundOff) => {
7369
+ const roundOffTo = getRoundOff$1(item.formatter);
7370
+ switch (item.type) {
7371
+ case "percentage":
7372
+ return (ins) => percentFormatter(ins, roundOffTo, (forFooter && item.is_editable) ||
7373
+ item?.multiplier ||
7374
+ item?.extra?.multiplier
7375
+ ? true
7376
+ : false, item?.extra?.displayBlank);
7377
+ case "int":
7378
+ return (ins) => numbersWithComma(ins, roundOffTo, item?.extra?.disableCommaFormatting, item?.extra?.displayBlank);
7379
+ case "float":
7380
+ return (ins) => decimalsFormatter(ins, roundOffTo, shouldRoundOff, item?.extra?.displayBlank);
7381
+ case "dollar":
7382
+ return (ins) => currencyFormatter(ins, roundOffTo, "$");
7383
+ case "euro":
7384
+ return (ins) => currencyFormatter(ins, roundOffTo, "€");
7385
+ case "bool":
7386
+ return (ins) => ins?.value || "";
7387
+ case "array":
7388
+ return (ins) => arrayToCommaFormatter(ins.value);
7389
+ case "percent_range":
7390
+ return (ins) => (ins?.value ? `${ins.value} %` : "");
7391
+ case "formatted_number":
7392
+ return (ins) => Number(ins?.value)?.toFixed(2) || "";
7393
+ case "date":
7394
+ case "datetime":
7395
+ case "dateStr":
7396
+ case "DateTimeField":
7397
+ return (ins) => {
7398
+ if (item?.extra?.displayBlank && ins?.value === null) {
7399
+ return "";
7400
+ }
7401
+ else {
7402
+ return formattedDate(ins?.value, getDateFormat(item));
6465
7403
  }
6466
- }
6467
- });
7404
+ };
7405
+ case "list":
7406
+ case "dynamic-list":
7407
+ return (ins) => {
7408
+ const listValue = ins?.value;
7409
+ const toDisplay = (v) => {
7410
+ if (isNil(v))
7411
+ return "";
7412
+ const raw = isObject(v) ? v?.value : v;
7413
+ return replaceSpecialCharacter$1(String(raw));
7414
+ };
7415
+ if (Array.isArray(listValue))
7416
+ return listValue.map(toDisplay).filter(Boolean).join(", ");
7417
+ if (isObject(listValue))
7418
+ return toDisplay(listValue);
7419
+ return fetchDefaultValue(ins);
7420
+ };
7421
+ default:
7422
+ return (ins) => {
7423
+ if (item.formatter && item.formatter === "numbersWithComma") {
7424
+ return numbersWithComma(ins, roundOffTo);
7425
+ }
7426
+ else if (ins.value === 0 || ins.value === false || ins.value) {
7427
+ return fetchDefaultValue(ins);
7428
+ }
7429
+ return "";
7430
+ };
7431
+ }
7432
+ };
7433
+
7434
+ // ─── Constants ──────────────────────────────────────────────────────────────
7435
+ const NUMERIC_TYPES = new Set(["int", "percentage", "float", "dollar", "euro"]);
7436
+ // Plain text types that use valueFormatter instead of cellRenderer
7437
+ const PLAIN_TEXT_TYPES = new Set([
7438
+ "percentage",
7439
+ "int",
7440
+ "float",
7441
+ "dollar",
7442
+ "euro",
7443
+ "bool",
7444
+ "date",
7445
+ "datetime",
7446
+ "dateStr",
7447
+ "DateTimeField",
7448
+ "list",
7449
+ "dynamic-list",
7450
+ "str",
7451
+ "link",
7452
+ "percent_range",
7453
+ "formatted_number",
7454
+ ]);
7455
+ // ─── Helpers ────────────────────────────────────────────────────────────────
7456
+ const replaceSpecialCharacter = (str) => {
7457
+ if (!str)
7458
+ return str;
7459
+ return String(str)
7460
+ .replace(/__ia_char_38__/g, "&")
7461
+ .replace(/__ia_char_60__/g, "<")
7462
+ .replace(/__ia_char_62__/g, ">")
7463
+ .replace(/__ia_char_34__/g, '"')
7464
+ .replace(/__ia_char_39__/g, "'")
7465
+ .replace(/__ia_char_96__/g, "`");
7466
+ };
7467
+ const generateHeader = (item) => {
7468
+ item.label = item.label
7469
+ ? replaceSpecialCharacter(item.label.toString())
7470
+ : item.label;
7471
+ return item.label;
7472
+ };
7473
+ const getNestedTableData = (data, columnName, label) => {
7474
+ if (!data)
7475
+ return "";
7476
+ // Handle dot-separated paths
7477
+ if (columnName && columnName.includes(".")) {
7478
+ const parts = columnName.split(".");
7479
+ let value = data;
7480
+ for (const part of parts) {
7481
+ if (value == null)
7482
+ return "";
7483
+ value = value[part];
7484
+ }
7485
+ return value;
7486
+ }
7487
+ return data[columnName];
7488
+ };
7489
+ const getRoundOff = (formatter) => {
7490
+ const map = {
7491
+ roundOff: 0,
7492
+ roundOfftoOneDecimals: 1,
7493
+ roundOfftoTwoDecimals: 2,
7494
+ roundOfftoThreeDecimals: 3,
6468
7495
  };
6469
- const renderButtons = () => {
6470
- if (!Array.isArray(bodyText.buttons)) {
6471
- return null;
6472
- }
6473
- return bodyText.buttons.map((button, index) => (jsx("div", { children: jsx(Button, { variant: button.variant || "primary", size: button.size || "medium", onClick: () => handleButtonClick(), disabled: button.disabled || isFormDisabled || (isStepFormSubmit && !isFormValid), className: button.className, icon: button.icon, iconPlacement: button.iconPlacement || "left", children: button.label }) }, index)));
7496
+ return map[formatter] ?? DEFAULT_ROUNDOFF;
7497
+ };
7498
+ const formatDecimalNumber = (value, roundOffTo) => {
7499
+ if (value === "" || value === null || value === undefined)
7500
+ return "";
7501
+ const num = Number(value);
7502
+ if (isNaN(num))
7503
+ return value;
7504
+ return roundOffTo === 0 ? Math.round(num) : num.toFixed(roundOffTo);
7505
+ };
7506
+ // ─── Base Props ─────────────────────────────────────────────────────────────
7507
+ const applyBaseProps = (item) => {
7508
+ if (!item.originalLabel)
7509
+ item.originalLabel = item.label;
7510
+ Object.assign(item, {
7511
+ headerClass: item?.label?.split(" ").join("_"),
7512
+ field: item.column_name,
7513
+ accessor: item.column_name,
7514
+ id: item.column_name,
7515
+ sortable: item.is_sortable ?? true,
7516
+ sort: item?.extra?.defaultSortBy,
7517
+ headerName: generateHeader(item),
7518
+ pinned: item?.extra?.pinned || (item.is_frozen ? "left" : null),
7519
+ required: item.is_required,
7520
+ resizable: !item.not_resizable,
7521
+ columnGroupShow: item?.columnGroupShow || item?.extra?.columnGroupShow,
7522
+ floatingFilter: false,
7523
+ filter: false,
7524
+ });
7525
+ if (item?.extra?.width) {
7526
+ item.suppressSizeToFit = true;
7527
+ item.width = item.extra.width;
7528
+ }
7529
+ // Right-align numeric types
7530
+ if (item?.extra?.rightAlign ||
7531
+ ["int", "percentage", "float", "dollar", "trend", "euro"]?.includes(item?.type)) {
7532
+ item.cellStyle = { ...item?.cellStyle, textAlign: "right" };
7533
+ item.headerClass = `${item?.headerClass || ""} number-cell`;
7534
+ item.cellClass = `${item?.cellClass || ""} number-cell`;
7535
+ }
7536
+ // Handle sub_headers (grouped columns)
7537
+ if (item.sub_headers?.length) {
7538
+ item.children = item.sub_headers.map((data) => formatColumn(data));
7539
+ }
7540
+ return item;
7541
+ };
7542
+ // ─── Numeric Config ─────────────────────────────────────────────────────────
7543
+ const applyNumericConfig = (item) => {
7544
+ if (!NUMERIC_TYPES.has(item.type))
7545
+ return;
7546
+ item.headerClass = `${item.headerClass} flex-reverse-column`;
7547
+ item.cellClass = `${item.cellClass} flex-reverse-cell`;
7548
+ if (item.extra?.overrideWidth)
7549
+ item.extra = { ...item.extra, width: item.extra.overrideWidth };
7550
+ if (!item?.extra?.ignoreSuppressSizeToFit)
7551
+ item.suppressSizeToFit = true;
7552
+ // Tooltip for numeric columns
7553
+ if (!item.extra?.hideToolTip) {
7554
+ const fixedUpto = item.type === "percentage" ? 4 : 2;
7555
+ item.tooltipField = null;
7556
+ item.tooltipValueGetter = (params) => {
7557
+ if (params.value === "-")
7558
+ return "";
7559
+ if (item.extra?.staticToolTip != null &&
7560
+ item.extra?.hasOwnProperty("staticToolTip")) {
7561
+ if ((item.extra?.showNullAsEmpty && params?.value === null) ||
7562
+ !item.extra?.showNullAsEmpty) {
7563
+ return item.extra.staticToolTip;
7564
+ }
7565
+ }
7566
+ return !Number.isInteger(Number(params.value))
7567
+ ? params.value
7568
+ ? Number(params.value).toFixed(fixedUpto)
7569
+ : 0
7570
+ : params.value;
7571
+ };
7572
+ }
7573
+ // Value getters for numeric types
7574
+ if (item.type === "percentage") {
7575
+ item.valueGetter = (params) => params?.data?.[params?.column?.colId] === undefined
7576
+ ? ""
7577
+ : params?.data?.[params?.column?.colId];
7578
+ }
7579
+ if (["int", "dollar", "euro"].includes(item.type) &&
7580
+ !item?.extra?.ignoreValueGetter) {
7581
+ item.valueGetter = (params) => {
7582
+ const roundOffTo = getRoundOff(item.formatter);
7583
+ let finalValue = formatDecimalNumber(params.data?.[item.column_name] ?? "", roundOffTo);
7584
+ if (isNaN(parseInt(finalValue)))
7585
+ return item.extra?.isHyphenDisplayedForEmpty ? "-" : "";
7586
+ return item.type === "int" ? parseInt(finalValue) : finalValue;
7587
+ };
7588
+ }
7589
+ if (item.type === "float" && !item?.extra?.ignoreValueGetter) {
7590
+ getRoundOff(item.formatter);
7591
+ item.valueGetter = (params) => {
7592
+ const value = params?.data?.[item.column_name];
7593
+ if (value === "" || value == null)
7594
+ return value;
7595
+ const num = Number(value);
7596
+ return isNaN(num) ? value : num;
7597
+ };
7598
+ }
7599
+ };
7600
+ // ─── Text Config ────────────────────────────────────────────────────────────
7601
+ const applyTextConfig = (item) => {
7602
+ if (item.type !== "str" && item.type !== "link")
7603
+ return;
7604
+ if (!item.is_editable || item.type === "link") {
7605
+ item.valueGetter = (params) => {
7606
+ if (!params?.data)
7607
+ return;
7608
+ let cellValue = getNestedTableData(params.data, item.column_name, item.label) ?? "";
7609
+ let finalValue = cellValue
7610
+ ? replaceSpecialCharacter(cellValue.toString())
7611
+ : cellValue;
7612
+ if (finalValue == null || finalValue === "")
7613
+ return item.extra?.isHyphenDisplayedForEmpty ? "-" : "";
7614
+ return finalValue;
7615
+ };
7616
+ }
7617
+ };
7618
+ // ─── Cross-Cutting ──────────────────────────────────────────────────────────
7619
+ const applyCrossCutting = (item) => {
7620
+ // Default tooltip for non-numeric, non-action types
7621
+ if (!NUMERIC_TYPES.has(item.type) && !item.extra?.hideToolTip) {
7622
+ item.tooltipValueGetter = (params) => {
7623
+ if (!params?.value)
7624
+ return;
7625
+ if (Array.isArray(params.value))
7626
+ return params.value.map((o) => o.label || o).join(" | ");
7627
+ const v = typeof params.value === "object" ? params.value.value : params.value;
7628
+ return v ? replaceSpecialCharacter(v.toString()) : v;
7629
+ };
7630
+ }
7631
+ // Default comparator
7632
+ item.comparator = (a, b) => {
7633
+ if (typeof a === "string" && typeof b === "string" && isNaN(+a) && a !== "-" && b !== "-") {
7634
+ return a.localeCompare(b);
7635
+ }
7636
+ if (a == null && b == null)
7637
+ return 0;
7638
+ if (a == null)
7639
+ return -1;
7640
+ if (b == null)
7641
+ return 1;
7642
+ if (a === b)
7643
+ return 0;
7644
+ return a > b ? 1 : -1;
6474
7645
  };
6475
- return (jsxs("div", { className: classes.buttonContainer, children: [bodyText.message && (jsx("div", { className: classes.message, children: bodyText.message })), jsx("div", { className: classes.buttonRow, children: renderButtons() })] }));
6476
7646
  };
7647
+ // ─── Cell Renderer ──────────────────────────────────────────────────────────
7648
+ const applyCellRenderer = (item) => {
7649
+ // Only handle non-editable columns (chatbot tables are display-only)
7650
+ if (PLAIN_TEXT_TYPES.has(item.type)) {
7651
+ const formatter = nonEditableCellValueFormatter(item, null, true);
7652
+ item.valueFormatter = (params) => formatter(params);
7653
+ }
7654
+ else {
7655
+ // For types we don't handle, just display the raw value
7656
+ item.valueFormatter = (params) => {
7657
+ if (params?.value === 0 || params?.value === false || params?.value) {
7658
+ return params.value;
7659
+ }
7660
+ return "";
7661
+ };
7662
+ }
7663
+ };
7664
+ // ─── Pipeline ───────────────────────────────────────────────────────────────
7665
+ const formatColumn = (item) => {
7666
+ applyBaseProps(item);
7667
+ // Type-specific
7668
+ applyNumericConfig(item);
7669
+ applyTextConfig(item);
7670
+ // Cross-cutting
7671
+ applyCrossCutting(item);
7672
+ // Cell renderer (non-editable only)
7673
+ applyCellRenderer(item);
7674
+ return item;
7675
+ };
7676
+ // ─── Entry Point ────────────────────────────────────────────────────────────
7677
+ /**
7678
+ * Simplified column formatter for chatbot tables.
7679
+ * Handles non-editable display-only columns. Does not support editable cells,
7680
+ * advanced search, range filters, or complex cell renderers.
7681
+ *
7682
+ * API-compatible with the core agGridColumnFormatter signature:
7683
+ * agGridColumnFormatter(data, levelsJson, actions, formatSetAllLabel, hideValueGetter, isView)
7684
+ * but ignores all args except `data`.
7685
+ */
7686
+ function agGridColumnFormatter(data, _levelsJson, _actions, _formatSetAllLabel, _hideValueGetter, _isView) {
7687
+ if (!data)
7688
+ return data;
7689
+ return data.filter((item) => {
7690
+ if (item.special_field)
7691
+ return false;
7692
+ formatColumn(item);
7693
+ if (item?.columns) {
7694
+ item.columns = item.columns.map((innerItem) => formatColumn(innerItem));
7695
+ }
7696
+ return true;
7697
+ });
7698
+ }
6477
7699
 
6478
7700
  var _path$k;
6479
7701
  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); }
@@ -6522,7 +7744,7 @@ const TableContent = ({ bodyText }) => {
6522
7744
  const dispatch = useDispatch();
6523
7745
  useEffect(() => {
6524
7746
  let formattedColumns = getFormattedTableConfig(table_config);
6525
- formattedColumns = agGridColumnFormatter(formattedColumns, {}, {}, false, null, false);
7747
+ formattedColumns = agGridColumnFormatter(formattedColumns);
6526
7748
  if (isEmpty$1(columns)) {
6527
7749
  setColumns(formattedColumns);
6528
7750
  }
@@ -6617,6 +7839,40 @@ const TableContent = ({ bodyText }) => {
6617
7839
  }) }) })] }));
6618
7840
  };
6619
7841
 
7842
+ // Set default Highcharts options
7843
+ Highcharts.setOptions({
7844
+ lang: {
7845
+ decimalPoint: '.',
7846
+ thousandsSep: ',',
7847
+ },
7848
+ });
7849
+ /**
7850
+ * CoreChart Component
7851
+ * A simple wrapper around the Highcharts React component.
7852
+ * Directly passes the provided options to Highcharts.
7853
+ *
7854
+ * @param {Object} props - Component props
7855
+ * @param {Object} props.options - Highcharts options configuration
7856
+ * @param {Function} [props.handleChartRef] - Optional callback to get a reference to the chart
7857
+ * @param {Object} [props.containerProps] - Optional props for the chart container
7858
+ * @returns {JSX.Element} Rendered chart component
7859
+ */
7860
+ const CoreChart = (props) => {
7861
+ const { options, handleChartRef, containerProps = {} } = props;
7862
+ const chartRef = useRef(null);
7863
+ useEffect(() => {
7864
+ if (handleChartRef && chartRef && chartRef.current) {
7865
+ handleChartRef(chartRef.current);
7866
+ }
7867
+ }, [chartRef, handleChartRef]);
7868
+ // Create a new options object with credits disabled
7869
+ const chartOptions = {
7870
+ ...options,
7871
+ credits: options.credits || { enabled: false }
7872
+ };
7873
+ return (jsx("div", { children: jsx(HighchartsReact, { highcharts: Highcharts, options: chartOptions, ref: chartRef, ...containerProps }) }));
7874
+ };
7875
+
6620
7876
  const GraphContent = ({ bodyText }) => {
6621
7877
  const { chartOptions, title } = bodyText || {};
6622
7878
  const classes = useStyles$b();
@@ -7414,7 +8670,7 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
7414
8670
  ? primaryValues.map((value) => {
7415
8671
  const stringValue = String(value);
7416
8672
  return {
7417
- label: replaceSpecialCharacter(stringValue),
8673
+ label: replaceSpecialCharacter$2(stringValue),
7418
8674
  value: stringValue,
7419
8675
  };
7420
8676
  })
@@ -7426,7 +8682,7 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
7426
8682
  extraOptionsMap[key] = responseData[key].map((value) => {
7427
8683
  const stringValue = String(value);
7428
8684
  return {
7429
- label: replaceSpecialCharacter(stringValue),
8685
+ label: replaceSpecialCharacter$2(stringValue),
7430
8686
  value: stringValue,
7431
8687
  };
7432
8688
  });
@@ -7446,7 +8702,7 @@ const fetchCrossFilterOptions = async (filterConfig, existingSelections = [], al
7446
8702
  primaryOptions = responseData[altKey].map((value) => {
7447
8703
  const stringValue = String(value);
7448
8704
  return {
7449
- label: replaceSpecialCharacter(stringValue),
8705
+ label: replaceSpecialCharacter$2(stringValue),
7450
8706
  value: stringValue,
7451
8707
  };
7452
8708
  });
@@ -7535,7 +8791,7 @@ const LOAD_MORE_COUNT = 100;
7535
8791
  const SEARCH_DISPLAY_LIMIT = 500;
7536
8792
  const formatOption = (option) => ({
7537
8793
  ...option,
7538
- label: replaceSpecialCharacter(option.label.toString()),
8794
+ label: replaceSpecialCharacter$2(option.label.toString()),
7539
8795
  });
7540
8796
  const formatSlice = (options, start, end) => {
7541
8797
  return options.slice(start, end).map(formatOption);
@@ -8367,12 +9623,14 @@ const SavedFilterCascadeBridge = ({ chatbotContext, crossFilterConfigs }) => {
8367
9623
  */
8368
9624
  const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, showSavedFilters = true, preSelectedFilters = null, botProps = null, currentMode = "", agentId = "", sessionId = "", }) => {
8369
9625
  const dispatch = useDispatch();
9626
+ const { selectors, components } = useChatbotDeps();
9627
+ const hasFilterComponent = !!components?.FilterComponent;
8370
9628
  const savedFilterSets = useSelector((state) => state.smartBotReducer.savedFilterSets);
8371
9629
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
8372
9630
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
8373
9631
  const stepFormStreamData = useSelector((state) => state.smartBotReducer.stepFormStreamData);
8374
9632
  const chatbotFilterOptions = useSelector((state) => state.smartBotReducer.chatbotFilterOptions);
8375
- const dimensionHierarchies = useSelector((state) => state.userRoleManagementService?.dimensionHierarchies);
9633
+ const dimensionHierarchies = useSelector(selectors?.getDimensionHierarchies ?? NULL_SELECTOR);
8376
9634
  const [isFormSubmitted, setIsFormSubmitted] = useState(false);
8377
9635
  const [isTimedOut, setIsTimedOut] = useState(() => sessionStorage.getItem(STEP_FORM_TIMEOUT_KEY) === "true");
8378
9636
  const timeoutRef = useRef(null);
@@ -8770,7 +10028,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
8770
10028
  });
8771
10029
  if (formFields.length === 0 && buttonItems.length === 0)
8772
10030
  return null;
8773
- 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] }));
10031
+ 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] }));
8774
10032
  };
8775
10033
  /** Reset the timeout flag (call when a new conversation/message starts) */
8776
10034
  const resetStepFormTimeoutFlag = () => {
@@ -10311,6 +11569,7 @@ const StreamedContent = ({ botData, botProps }) => {
10311
11569
  // botData.inputBody = {
10312
11570
  // "query": "get product status for this l2_name 10_Trey Heckmann"
10313
11571
  // }
11572
+ const { BASE_API } = getApiConstants();
10314
11573
  let endPoint = botData?.utilityObject?.endpoint
10315
11574
  ? `${BASE_API}${botData?.utilityObject?.endpoint}`
10316
11575
  : `${BASE_API}/core/chatbot/navigation-v2`;
@@ -12475,7 +13734,7 @@ var SvgGenericModuleIcon = function SvgGenericModuleIcon(props) {
12475
13734
 
12476
13735
  const fetchAllMemories = async (baseUrl) => {
12477
13736
  try {
12478
- let data = await axiosInstance({
13737
+ let data = await httpRequest({
12479
13738
  url: `${baseUrl}/chatbot/agent/memory/get_all`,
12480
13739
  method: "GET",
12481
13740
  });
@@ -12488,7 +13747,7 @@ const fetchAllMemories = async (baseUrl) => {
12488
13747
  };
12489
13748
  const editMemory = async (baseUrl, memoryId, data) => {
12490
13749
  try {
12491
- let response = await axiosInstance({
13750
+ let response = await httpRequest({
12492
13751
  url: `${baseUrl}/chatbot/agent/memory/update/${memoryId}`,
12493
13752
  method: "PUT",
12494
13753
  data,
@@ -12502,7 +13761,7 @@ const editMemory = async (baseUrl, memoryId, data) => {
12502
13761
  };
12503
13762
  const deleteMemory = async (baseUrl, memoryId) => {
12504
13763
  try {
12505
- let response = await axiosInstance({
13764
+ let response = await httpRequest({
12506
13765
  url: `${baseUrl}/chatbot/agent/memory/delete/${memoryId}`,
12507
13766
  method: "DELETE",
12508
13767
  });
@@ -12863,117 +14122,14 @@ function UploadModal(props) {
12863
14122
  return (jsx(Modal, { onClose: handleModalClose, onPrimaryButtonClick: handleFileUpload, onSecondaryButtonClick: handleModalClose, open: isUploadModalOpen, size: "small", title: "Upload Document", primaryButtonLabel: "Upload", secondaryButtonLabel: "Cancel", primaryButtonProps: { disabled: isLoading }, secondaryButtonProps: { disabled: isLoading }, children: isLoading ? (jsx(Loader, { text: "Uploading file..." })) : (jsxs("div", { className: classes.uploadModalInnerSec, children: [jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileSelect, accept: ".pdf", style: { display: "none" }, disabled: isLoading }), jsx(Button, { onClick: () => fileInputRef.current.click(), variant: "outlined", disabled: isLoading, children: "Select PDF File" }), selectedFile && (jsxs("p", { style: { marginTop: "10px" }, children: ["Selected File: ", selectedFile.name] }))] })) }));
12864
14123
  }
12865
14124
 
12866
- /** A skill is a folder: SKILL.md (its name and description, then its steps) and the files it refers to, such
12867
- * as references/mcp-contracts.md. Picked files are read here as text, keyed by their path in that folder,
12868
- * and saved for the signed-in user by the agent (POST {baseUrl}/chatbot/agent/skills). Unlike a paste into
12869
- * the chat, an upload keeps the line breaks and the skill's other files. */
12870
- const MAX_FILES = 50;
12871
- const TEXT_EXTENSIONS = [".md", ".txt", ".json", ".yaml", ".yml", ".csv"];
12872
- const isSkillFile = (path) => path === "SKILL.md" || path.endsWith("/SKILL.md");
12873
- const isText = (name) => TEXT_EXTENSIONS.some((ext) => name.toLowerCase().endsWith(ext));
12874
- /** What the agent answered; a 200 may be the object itself or wrapped as {data: {...}}. */
12875
- const savedOf = (response) => response?.data?.data || response?.data || {};
12876
- /** Why the agent did not save it: the 422's detail ("not saved: ..."), else the message or status. */
12877
- const whyNot = (error) => {
12878
- const body = error?.response?.data;
12879
- const said = body?.detail || body?.message || body?.data?.detail;
12880
- if (typeof said === "string" && said)
12881
- return said;
12882
- if (said)
12883
- return JSON.stringify(said);
12884
- return error?.response?.status ? `the agent answered ${error.response.status}` : String(error?.message || error);
12885
- };
12886
- function SkillUploadModal(props) {
12887
- const { isOpen, setIsOpen, baseUrl, displaySnackMessages, onUseText } = props;
12888
- const [picked, setPicked] = useState({});
12889
- const [skipped, setSkipped] = useState(0);
12890
- const [isSaving, setIsSaving] = useState(false);
12891
- const [saved, setSaved] = useState(null);
12892
- const [error, setError] = useState("");
12893
- const folderRef = useRef(null);
12894
- const filesRef = useRef(null);
12895
- const classes = useStyles$b();
12896
- const reset = () => {
12897
- setPicked({});
12898
- setSkipped(0);
12899
- setSaved(null);
12900
- setError("");
12901
- };
12902
- const handleClose = () => {
12903
- if (isSaving)
12904
- return;
12905
- setIsOpen(false);
12906
- reset();
12907
- };
12908
- const take = async (list) => {
12909
- if (!list)
12910
- return;
12911
- const next = { ...picked };
12912
- let left = 0;
12913
- for (const file of Array.from(list)) {
12914
- const path = file.webkitRelativePath || file.name;
12915
- if (!isText(file.name)) {
12916
- left += 1; // a folder may hold images or .DS_Store: only text files are a skill's
12917
- continue;
12918
- }
12919
- if (!(path in next) && Object.keys(next).length >= MAX_FILES) {
12920
- displaySnackMessages(`A skill can have at most ${MAX_FILES} files`, "error");
12921
- break;
12922
- }
12923
- next[path] = await file.text();
12924
- }
12925
- setPicked(next);
12926
- setSkipped(skipped + left);
12927
- setSaved(null);
12928
- setError("");
12929
- };
12930
- const paths = Object.keys(picked);
12931
- const hasSkill = paths.some(isSkillFile);
12932
- const handleSave = async () => {
12933
- if (!hasSkill) {
12934
- displaySnackMessages("Pick the skill's SKILL.md (or its folder) first", "error");
12935
- return;
12936
- }
12937
- try {
12938
- setIsSaving(true);
12939
- setError("");
12940
- const response = await uploadSkill(picked, baseUrl);
12941
- setSaved(savedOf(response));
12942
- displaySnackMessages("Skill saved", "success");
12943
- }
12944
- catch (err) {
12945
- console.error("uploadSkill error:", err);
12946
- setError(whyNot(err));
12947
- }
12948
- finally {
12949
- setIsSaving(false);
12950
- }
12951
- };
12952
- const use = (text) => {
12953
- onUseText?.(text);
12954
- setIsOpen(false);
12955
- reset();
12956
- };
12957
- const files = saved?.files || [];
12958
- const missing = saved?.missing_files || [];
12959
- const runText = saved?.name ? `Run skill ${saved.name} in Preview mode` : "";
12960
- return (jsx(Modal, { onClose: handleClose, onPrimaryButtonClick: saved ? handleClose : handleSave, onSecondaryButtonClick: handleClose, open: isOpen, size: "small", title: "Upload Skill", primaryButtonLabel: saved ? "Done" : "Save the skill", secondaryButtonLabel: "Cancel", primaryButtonProps: { disabled: isSaving || (!saved && !hasSkill) }, secondaryButtonProps: { disabled: isSaving }, children: isSaving ? (jsx(Loader, { text: "Saving the skill..." })) : saved ? (jsxs("div", { style: { padding: "16px 20px", lineHeight: 1.5 }, children: [jsxs("p", { style: { margin: "0 0 8px" }, children: ["Saved ", jsx("b", { children: saved.name }), " (version ", saved.version, typeof saved.characters === "number" ? `, ${saved.characters.toLocaleString()} characters` : "", files.length ? `, with ${files.join(", ")}` : "", ")."] }), missing.length > 0 && (jsxs("p", { style: { margin: "0 0 8px" }, children: ["It refers to ", missing.join(", "), ", which was not uploaded."] })), saved.trigger && (jsxs("p", { style: { margin: "0 0 8px" }, children: ["It has a trigger: it ", saved.trigger_said, ". It is not on yet. To turn it on, send Iris:", " ", jsx("i", { children: saved.turn_on })] })), jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginTop: "12px" }, children: [runText && (jsxs(Button, { variant: "outlined", onClick: () => use(runText), children: ["Put \"", runText, "\" in the chat"] })), saved.trigger && saved.turn_on && (jsxs(Button, { variant: "outlined", onClick: () => use(saved.turn_on), children: ["Put \"", saved.turn_on, "\" in the chat"] }))] })] })) : (jsxs("div", { className: classes.uploadModalInnerSec, style: { height: "auto", minHeight: "150px" }, children: [jsx("input", { type: "file", ref: folderRef, onChange: (e) => {
12961
- take(e.target.files);
12962
- e.target.value = "";
12963
- }, style: { display: "none" }, multiple: true, ...{ webkitdirectory: "", directory: "" } }), jsx("input", { type: "file", ref: filesRef, onChange: (e) => {
12964
- take(e.target.files);
12965
- e.target.value = "";
12966
- }, style: { display: "none" }, multiple: true, accept: TEXT_EXTENSIONS.join(",") }), jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", justifyContent: "center" }, children: [jsx(Button, { variant: "outlined", onClick: () => folderRef.current?.click(), children: "Pick the skill's folder" }), jsx(Button, { variant: "outlined", onClick: () => filesRef.current?.click(), children: "Pick its files" })] }), paths.length > 0 ? (jsxs("div", { style: { marginTop: "12px", width: "100%" }, children: [jsx("ul", { style: { margin: 0, paddingLeft: "18px", maxHeight: "140px", overflowY: "auto" }, children: paths.map((path) => (jsx("li", { children: path }, path))) }), !hasSkill && jsx("p", { style: { margin: "8px 0 0" }, children: "No SKILL.md picked yet." }), skipped > 0 && (jsxs("p", { style: { margin: "8px 0 0" }, children: [skipped, " file", skipped === 1 ? " was" : "s were", " left out: a skill's files are text (", TEXT_EXTENSIONS.join(" "), ")."] }))] })) : (jsx("p", { style: { marginTop: "12px", textAlign: "center" }, children: "A skill is a SKILL.md and any files it refers to. Once saved, ask Iris to run it by name, now or on a schedule." })), error && jsxs("p", { style: { marginTop: "10px", color: "#b42318" }, children: ["Not saved: ", error.replace(/^not saved:\s*/i, "")] })] })) }));
12967
- }
12968
-
12969
14125
  const useStyles$2 = makeStyles(() => ({
12970
14126
  input: {
12971
14127
  width: "100%",
12972
- padding: `${pxToRem$1(8)} ${pxToRem$1(12)}`,
14128
+ padding: `${pxToRem(8)} ${pxToRem(12)}`,
12973
14129
  fontFamily: "Manrope",
12974
- fontSize: pxToRem$1(14),
12975
- border: `${pxToRem$1(1)} solid ${colours$1.neutralBorder}`,
12976
- borderRadius: pxToRem$1(4),
14130
+ fontSize: pxToRem(14),
14131
+ border: `${pxToRem(1)} solid ${colours.neutralBorder}`,
14132
+ borderRadius: pxToRem(4),
12977
14133
  outline: "none",
12978
14134
  boxSizing: "border-box",
12979
14135
  },
@@ -13150,6 +14306,219 @@ var SvgClearFilter = function SvgClearFilter(props) {
13150
14306
  })))));
13151
14307
  };
13152
14308
 
14309
+ // Internalized constants (were from config/constants)
14310
+ const DEFAULT_DATE_FORMAT = "MM/DD/YYYY";
14311
+ const START_DATE = "2000-01-01";
14312
+ const END_DATE = "2050-12-31";
14313
+ const useStyles$1 = makeStyles$1((theme) => ({
14314
+ monthYearDropDown: {
14315
+ display: "inline-flex",
14316
+ },
14317
+ styledSelect: {
14318
+ border: "none",
14319
+ margin: "0 0.5rem",
14320
+ outline: "none",
14321
+ ...theme.typography.subtitle1,
14322
+ fontWeight: 600,
14323
+ },
14324
+ }));
14325
+ /**
14326
+ *
14327
+ * @param {moment} startDate
14328
+ * @param {moment} endDate
14329
+ * @param {string} disableType
14330
+ * @returns year
14331
+ *
14332
+ * This function takes in start date, end date and disable type as parameters
14333
+ * and based on the disable type conditions, it will return the current year,
14334
+ * from the calendar rendering should start
14335
+ *
14336
+ * For ex: if the dates are past disabled, we will either start rendering the calendar from
14337
+ * the start date year or if start date is not mentioned, we will render from the present year
14338
+ * Similarly if we have future disabled, we will either end rendering the calendar from the
14339
+ * end date year or if end date is not mentioned, we will render till the present year
14340
+ */
14341
+ const getCurrentYear = (startDate, endDate, disableType) => {
14342
+ //If it is past disabled and we have a valid start date
14343
+ if (disableType &&
14344
+ disableType?.includes("Past") &&
14345
+ moment(startDate).isValid()) {
14346
+ return moment(startDate).year(); //return start date year
14347
+ }
14348
+ //If it is future disabled and we have a valid end date
14349
+ if (disableType &&
14350
+ disableType?.includes("Future") &&
14351
+ moment(endDate).isValid()) {
14352
+ return moment(endDate).year(); //return end date year
14353
+ }
14354
+ return moment().year(); //else return present date year
14355
+ };
14356
+ const DateRangePickerComponent = (props) => {
14357
+ useStyles$1();
14358
+ const [focusedInput, setfocusedInput] = useState(null);
14359
+ const [yearArray, setyearArray] = useState([moment().year()]);
14360
+ const [startDate, setStartDate] = useState(props.startDate);
14361
+ const [endDate, setEndDate] = useState(props.endDate);
14362
+ const [reset, setReset] = useState(false);
14363
+ // Read tenantDateFormat from props first, fallback to localStorage
14364
+ const tenantDateFormat = props.tenantDateFormat ||
14365
+ (typeof localStorage !== "undefined"
14366
+ ? localStorage.getItem("tenantDateFormat")
14367
+ : null) ||
14368
+ DEFAULT_DATE_FORMAT;
14369
+ useEffect(() => {
14370
+ if ((startDate && props.startDate && startDate.diff(props.startDate)) ||
14371
+ (endDate && props.endDate && endDate.diff(props.endDate)) ||
14372
+ (!startDate && props.startDate) ||
14373
+ (!endDate && props.endDate)) {
14374
+ setStartDate(props.startDate);
14375
+ setEndDate(props.endDate);
14376
+ }
14377
+ else if (isNull(props.startDate) &&
14378
+ isNull(props.endDate) &&
14379
+ !isNull(startDate) &&
14380
+ !isNull(endDate)) {
14381
+ setStartDate(null);
14382
+ setEndDate(null);
14383
+ }
14384
+ }, [props.startDate, props.endDate]);
14385
+ const configureYear = () => {
14386
+ const startYear = props.startDate
14387
+ ? props.startDate.isBefore(props.startYear)
14388
+ : props.startYear;
14389
+ const currentYearBasedOnDate = getCurrentYear(startYear, props.endDate, props.disableType);
14390
+ let yearArr = [currentYearBasedOnDate];
14391
+ //till 2050, it will add all the years
14392
+ for (let i = 0; i < 2050 - currentYearBasedOnDate; i++) {
14393
+ if (props.disableType && props.disableType.includes("Future")) {
14394
+ yearArr.push(yearArr[i] - 1);
14395
+ }
14396
+ else {
14397
+ yearArr.push(yearArr[i] + 1);
14398
+ }
14399
+ }
14400
+ if (props.startYear) {
14401
+ // Start year from 2019 incase of cluster plan
14402
+ let startYear = props.startYear;
14403
+ let pastYearArray = [];
14404
+ while (startYear < yearArr[0]) {
14405
+ pastYearArray.push(startYear);
14406
+ startYear++;
14407
+ }
14408
+ yearArr.unshift(...pastYearArray);
14409
+ }
14410
+ const currentYear = moment().year();
14411
+ if (!yearArr.includes(currentYear)) {
14412
+ yearArr.unshift(currentYear);
14413
+ }
14414
+ setyearArray(yearArr);
14415
+ };
14416
+ const isOutsideRange = (day) => {
14417
+ switch (props.disableType) {
14418
+ case "disableOnlyPast":
14419
+ //disables strictly past i.e current/today's date is not included
14420
+ return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isBefore(moment().format(DEFAULT_DATE_FORMAT)));
14421
+ case "disablePast":
14422
+ //disables past i.e current/today's date is included
14423
+ return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isSame(moment().format(DEFAULT_DATE_FORMAT), "days") ||
14424
+ moment(day.format(DEFAULT_DATE_FORMAT)).isBefore(moment().format(DEFAULT_DATE_FORMAT)));
14425
+ case "disableOnlyFuture":
14426
+ //disables strictly future i.e current/today's date is not included
14427
+ return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isAfter(moment().format(DEFAULT_DATE_FORMAT)));
14428
+ case "disableFuture":
14429
+ //disables future i.e current/today's date is included
14430
+ return Boolean(moment(day.format(DEFAULT_DATE_FORMAT)).isSame(moment().format(DEFAULT_DATE_FORMAT), "days") ||
14431
+ moment(day.format(DEFAULT_DATE_FORMAT)).isAfter(moment().format(DEFAULT_DATE_FORMAT)));
14432
+ case "customRange":
14433
+ //we can pass custom range which evaluates if the date to be disabled or not
14434
+ //For example: disabling specific dates or only fridays etc..
14435
+ return props.customOutsideRange(day);
14436
+ default:
14437
+ //By default, it doesn't disable any date
14438
+ return false;
14439
+ }
14440
+ };
14441
+ const dateRangeCalculator = async (startDate, endDate) => {
14442
+ /**
14443
+ * If the date selection is weekly, we keep start date as starting day of the week,
14444
+ * i.e if we select a day, we return the output as starting day in that week
14445
+ */
14446
+ let weekStart = props.weeklySelection
14447
+ ? moment(startDate).startOf("week")
14448
+ : startDate;
14449
+ /**
14450
+ * If we make the date selection as weekly
14451
+ * End date would be end of the week but if the end date
14452
+ * is outside the range i.e future including today, we set
14453
+ * enddate as one day prior to today i.e subtract 1 day from today
14454
+ * We also make sure if the endDate is either null or invalid, we don't check for outside range
14455
+ */
14456
+ const validEndDate = endDate &&
14457
+ endDate.isValid() &&
14458
+ isOutsideRange(moment(endDate).endOf("week"))
14459
+ ? moment().subtract(1, "days")
14460
+ : moment(endDate).endOf("week");
14461
+ let weekEnd = props.weeklySelection ? validEndDate : endDate;
14462
+ if (weekStart && !weekStart.isValid()) {
14463
+ weekStart = null;
14464
+ }
14465
+ if (weekEnd && !weekEnd.isValid()) {
14466
+ weekEnd = null;
14467
+ }
14468
+ //If we clear, both weekStart and weekEnd will become null
14469
+ //Then we shift the month and year to current date
14470
+ if (!weekStart && !weekEnd) {
14471
+ await setTimeout(() => {
14472
+ }, 100);
14473
+ }
14474
+ props.onDatesChange(weekStart, weekEnd);
14475
+ };
14476
+ const isDayBlocked = (date) => {
14477
+ if (focusedInput === "startDate") {
14478
+ return (props.enabledStartDays &&
14479
+ !props.enabledStartDays.includes(moment(date).format("dddd")));
14480
+ }
14481
+ if (focusedInput === "endDate") {
14482
+ return (props.enabledEndDays &&
14483
+ !props.enabledEndDays.includes(moment(date).format("dddd")));
14484
+ }
14485
+ return false;
14486
+ };
14487
+ useEffect(() => {
14488
+ configureYear();
14489
+ }, []);
14490
+ useEffect(() => {
14491
+ if (props.resetOptions) {
14492
+ setStartDate(null);
14493
+ setEndDate(null);
14494
+ }
14495
+ }, [props.resetOptions]);
14496
+ const defaultYears = useMemo(() => {
14497
+ const startYear = Number(START_DATE.split("-")[0]);
14498
+ const endYear = Number(END_DATE.split("-")[0]);
14499
+ return Array.from({ length: endYear - startYear + 1 }, (_, index) => ({
14500
+ label: String(startYear + index),
14501
+ value: String(startYear + index),
14502
+ }));
14503
+ }, []); // Only calculate once
14504
+ const yearList = props?.customYears ?? defaultYears;
14505
+ useEffect(() => {
14506
+ if (props?.extra?.autoApplyDateRange && !reset) {
14507
+ dateRangeCalculator(startDate, endDate);
14508
+ }
14509
+ }, [startDate, endDate]);
14510
+ 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: () => {
14511
+ setStartDate(null);
14512
+ setEndDate(null);
14513
+ }, onResetClick: () => {
14514
+ setStartDate(null);
14515
+ setEndDate(null);
14516
+ setReset(true);
14517
+ dateRangeCalculator(null, null);
14518
+ setTimeout(() => setReset(false), 0);
14519
+ }, customYears: yearList, hideKeyboardShortcutsPanel: true, enabledStartDays: props.enabledStartDays, enabledEndDays: props.enabledEndDays, handleStartDateFocus: () => setfocusedInput("startDate"), handleEndDateFocus: () => setfocusedInput("endDate"), isAgGridCellRenderer: props?.isAgGridCellRenderer, labelOrientation: props?.labelOrientation || "top" }) }));
14520
+ };
14521
+
13153
14522
  /**
13154
14523
  * Component to render filter value input based on display_type
13155
14524
  * This component handles different field types similar to form/index.jsx
@@ -13277,7 +14646,7 @@ const FilterValueInput = ({ filterConfig, value, onChange, options = [], isLoadi
13277
14646
  const dateFormat = extra.dateFormat || "MM-DD-YYYY";
13278
14647
  const disableType = extra.disableType || extra.disablePast ? "disablePast" : null;
13279
14648
  const startYear = extra.startYear;
13280
- return (jsx(RangePicker, { 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]
14649
+ 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]
13281
14650
  ? moment.isMoment(localValue[0])
13282
14651
  ? localValue[0]
13283
14652
  : moment(localValue[0]).isValid()
@@ -13430,7 +14799,7 @@ const fetchFilterValues = async (filterConfig, existingFilters = [], filterOptio
13430
14799
  return {
13431
14800
  // Show decoded label to the user, but keep the original
13432
14801
  // encoded value (with __ia_char) for backend requests.
13433
- label: replaceSpecialCharacter$1(stringValue),
14802
+ label: replaceSpecialCharacter$2(stringValue),
13434
14803
  value: stringValue,
13435
14804
  };
13436
14805
  });
@@ -13688,7 +15057,7 @@ const formatMentionDisplay = (filterName, values, maxVisible = 3) => {
13688
15057
  const visibleValues = values.slice(0, maxVisible);
13689
15058
  values.length - maxVisible;
13690
15059
  // Decode any special character codes for display purposes only.
13691
- const displayVisibleValues = visibleValues.map((v) => replaceSpecialCharacter(String(v)));
15060
+ const displayVisibleValues = visibleValues.map((v) => replaceSpecialCharacter$2(String(v)));
13692
15061
  let display = `@${filterName}::${displayVisibleValues.join(",")}`;
13693
15062
  return display;
13694
15063
  };
@@ -13829,6 +15198,8 @@ const useMentionState = () => {
13829
15198
 
13830
15199
  const ChatbotInput = (props) => {
13831
15200
  const { newChatScreen, inputValue, setInputValue, isStopIcon, handleMicClick, handleRefresh, onSendIconClick, onStopIconClick, currentMode, filterOptions, onSaveClick, savedFilterSets, onFilterSetSelect, onTriggerRefresh, selectedFilterSet, onClearFilterSet, answerMode, setAnswerMode, } = props;
15201
+ const { components } = useChatbotDeps();
15202
+ const hasFilterComponent = !!components?.FilterComponent;
13832
15203
  const editorRef = useRef(null);
13833
15204
  const selectRef = useRef(null);
13834
15205
  const filterSetSelectRef = useRef(null);
@@ -13872,7 +15243,7 @@ const ChatbotInput = (props) => {
13872
15243
  // Decode special character placeholders only for the label shown
13873
15244
  // to the user. The underlying value (used in payloads) remains
13874
15245
  // unchanged so that backend continues to receive the ia_char codes.
13875
- const label = replaceSpecialCharacter(rawLabel);
15246
+ const label = replaceSpecialCharacter$2(rawLabel);
13876
15247
  // Handle duplicate labels
13877
15248
  if (labelCount[label]) {
13878
15249
  labelCount[label]++;
@@ -14829,7 +16200,7 @@ const ChatbotInput = (props) => {
14829
16200
  */
14830
16201
  const handleSendMessage = () => {
14831
16202
  // Decode any ia_char placeholders for display
14832
- const formattedText = replaceSpecialCharacter(getFormattedTextForSending());
16203
+ const formattedText = replaceSpecialCharacter$2(getFormattedTextForSending());
14833
16204
  if (!formattedText.trim() && isEmpty$1(chatbotContext))
14834
16205
  return;
14835
16206
  // Extract user explicit input from mentions
@@ -15140,12 +16511,12 @@ const ChatbotInput = (props) => {
15140
16511
  !target.closest(".answer-mode-wrapper")) {
15141
16512
  editorRef.current.focus();
15142
16513
  }
15143
- }, 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: () => {
16514
+ }, 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: () => {
15144
16515
  if (hasMentionsInEditor || showMentionSelect)
15145
16516
  return;
15146
16517
  setShowFilterSetMenu(!showFilterSetMenu);
15147
16518
  setIsFilterSetMenuOpen(!showFilterSetMenu);
15148
- }, 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) => {
16519
+ }, 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) => {
15149
16520
  if (e.key === "Escape") {
15150
16521
  // Don't handle Escape for date range picker - it has its own Cancel button
15151
16522
  if (showMentionSelect) {
@@ -15294,7 +16665,7 @@ const ChatbotInput = (props) => {
15294
16665
  top: `680px`,
15295
16666
  left: `${dropdownPosition.left}px`,
15296
16667
  zIndex: 10000,
15297
- }, children: jsx(RangePicker
16668
+ }, children: jsx(DateRangePickerComponent
15298
16669
  // disableType="disableOnlyPast"
15299
16670
  , {
15300
16671
  // disableType="disableOnlyPast"
@@ -15906,185 +17277,6 @@ const useConversationManagement = (chatDataRef, currentMode, activeConversationI
15906
17277
  };
15907
17278
  };
15908
17279
 
15909
- const useStyles$1 = makeStyles({
15910
- container: {
15911
- display: "flex",
15912
- flexDirection: "column",
15913
- alignItems: "center",
15914
- justifyContent: "center",
15915
- width: "100%",
15916
- height: "100%",
15917
- padding: "16px",
15918
- boxSizing: "border-box",
15919
- },
15920
- icon: {
15921
- flexShrink: 0,
15922
- overflow: "visible",
15923
- },
15924
- title: {
15925
- color: "#31416E",
15926
- textAlign: "center",
15927
- fontFamily: "Manrope",
15928
- fontSize: "20px",
15929
- fontStyle: "normal",
15930
- fontWeight: 800,
15931
- lineHeight: "150%",
15932
- margin: 0,
15933
- padding: "20px 0 0 0",
15934
- },
15935
- subtitle: {
15936
- color: "#31416E",
15937
- textAlign: "center",
15938
- fontFamily: "Manrope",
15939
- fontSize: "14px",
15940
- fontStyle: "normal",
15941
- fontWeight: 400,
15942
- lineHeight: "160%",
15943
- margin: 0,
15944
- padding: 0,
15945
- },
15946
- buttonWrapper: {
15947
- marginTop: "16px",
15948
- },
15949
- hidden: {
15950
- display: "none",
15951
- },
15952
- });
15953
- const ChatbotSaveFilterComponent = (props) => {
15954
- const classes = useStyles$1();
15955
- const { savedFilterSets, partialClose, chatBotWidth } = props;
15956
- const [showFilter, setShowFilter] = useState(!isEmpty$1(savedFilterSets));
15957
- /**
15958
- * onFilterDashboardClick function is called when we click the apply filter
15959
- * button in the select filter option
15960
- * @param {object} dependencyData
15961
- */
15962
- const onFilterDashboardClick = async (dependencyData) => {
15963
- console.log("dependencyData4321", dependencyData);
15964
- };
15965
- const setChatbotFilterConfiguration = async (screenName) => {
15966
- if (isEmpty$1(props.chatbotFilterDashboardConfiguration)) {
15967
- const data = await fetchFilterFieldValues("Chatbot", props.savedFilterSelection);
15968
- if (isEmpty$1(props.filterDashboardConfiguration)) {
15969
- let filterConfigData = [
15970
- {
15971
- filterDashboardData: data,
15972
- isCrossDimensionFilter: false,
15973
- screen_name: screenName,
15974
- },
15975
- ];
15976
- const filterConfig = formattedFilterConfiguration("chatbotFilterConfiguration", filterConfigData, "Chatbot");
15977
- props.setFilterConfiguration(filterConfig);
15978
- }
15979
- }
15980
- };
15981
- useEffect(() => {
15982
- setChatbotFilterConfiguration("Chatbot");
15983
- }, []);
15984
- useEffect(() => {
15985
- if (!isEmpty$1(savedFilterSets)) {
15986
- setShowFilter(true);
15987
- }
15988
- }, [savedFilterSets]);
15989
- useEffect(() => {
15990
- const drawer = document.querySelector(".MuiModal-root.MuiDrawer-root");
15991
- if (drawer) {
15992
- drawer.style.display = partialClose ? "none" : "";
15993
- }
15994
- }, [partialClose]);
15995
- useEffect(() => {
15996
- if (!showFilter)
15997
- return;
15998
- const Z_INDEX = "9999";
15999
- const patchDrawer = () => {
16000
- const drawer = document.querySelector(".MuiModal-root.MuiDrawer-root");
16001
- if (drawer && drawer.style.zIndex !== Z_INDEX) {
16002
- drawer.style.zIndex = Z_INDEX;
16003
- }
16004
- if (drawer) {
16005
- drawer.style.setProperty("position", "relative");
16006
- }
16007
- const mainContainer = document.querySelector(".impact-drawer-filter-main-container");
16008
- if (mainContainer) {
16009
- mainContainer.style.setProperty("flex-direction", "column", "important");
16010
- }
16011
- const leftPanel = document.querySelector(".impact_drawer_filter_container_left_panel");
16012
- if (leftPanel) {
16013
- leftPanel.style.setProperty("height", "50px");
16014
- leftPanel.style.setProperty("background", "white");
16015
- leftPanel.style.setProperty("border", "none");
16016
- }
16017
- const filterHeader = document.querySelector(".impact_drawer_filter_header");
16018
- if (filterHeader) {
16019
- filterHeader.style.setProperty("display", "none");
16020
- }
16021
- const filterTabs = document.querySelector(".impact_drawer_filter_left_filters_tabs");
16022
- if (filterTabs) {
16023
- filterTabs.style.setProperty("flex-direction", "row");
16024
- filterTabs.style.setProperty("background", "white");
16025
- }
16026
- const filterContainer = document.querySelector(".impact_drawer_filter_container.impact_drawer_filter_container_large");
16027
- if (filterContainer) {
16028
- const computedWidth = chatBotWidth ? `${chatBotWidth - 86}px` : "616px";
16029
- filterContainer.style.setProperty("width", computedWidth);
16030
- }
16031
- const rightPanel = document.querySelector(".impact_drawer_filter_container .impact_drawer_filter_container_right_panel");
16032
- if (rightPanel) {
16033
- rightPanel.style.setProperty("height", "600px");
16034
- rightPanel.style.setProperty("width", "100%");
16035
- }
16036
- const backdrop = document.querySelector(".MuiBackdrop-root.MuiModal-backdrop");
16037
- if (backdrop) {
16038
- backdrop.style.setProperty("position", "unset");
16039
- }
16040
- const drawerPaper = document.querySelector(".MuiDrawer-paper.MuiDrawer-paperAnchorRight");
16041
- if (drawerPaper) {
16042
- drawerPaper.style.setProperty("box-shadow", "none");
16043
- drawerPaper.style.setProperty("top", "110px");
16044
- drawerPaper.style.setProperty("right", "3px");
16045
- }
16046
- const filterSeparator = document.querySelector(".impact-drawer-filter-separator");
16047
- if (filterSeparator) {
16048
- filterSeparator.style.setProperty("display", "none");
16049
- }
16050
- const paperRounded = document.querySelector(".MuiPaper-root.MuiPaper-elevation0.MuiPaper-rounded");
16051
- if (paperRounded) {
16052
- paperRounded.style.setProperty("margin-right", "24px");
16053
- }
16054
- const filterFooter = document.querySelector(".impact_drawer_filter_footer");
16055
- if (filterFooter) {
16056
- filterFooter.style.setProperty("bottom", "120px");
16057
- filterFooter.style.setProperty("left", "0");
16058
- }
16059
- const filterBody = document.querySelector(".impact_drawer_filter_body.impact_drawer_filter_footer_no_buttons");
16060
- if (filterBody) {
16061
- filterBody.style.setProperty("padding-right", "40px");
16062
- }
16063
- };
16064
- patchDrawer();
16065
- const observer = new MutationObserver(patchDrawer);
16066
- observer.observe(document.body, { childList: true, subtree: true });
16067
- return () => observer.disconnect();
16068
- }, [showFilter, chatBotWidth]);
16069
- return (jsx("div", { className: partialClose ? classes.hidden : undefined, children: !showFilter ?
16070
- 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" }) })] }) :
16071
- jsx("div", { children: jsx(CoreComponentScreen, { showPageHeader: false,
16072
- // Filter dashboard props
16073
- showFilterDashboard: true, filterConfigKey: "chatbotFilterConfiguration", onApplyFilter: onFilterDashboardClick, autoApplyEnabled: false, hideNoDataFound: true, defaultOpenModel: true }) }) }));
16074
- };
16075
- const mapStateToProps = (state) => {
16076
- return {
16077
- chatbotFilterDashboardConfiguration: state.filterReducer.filterDashboardConfiguration["chatbotFilterConfiguration"],
16078
- savedFilterSelection: state.filterReducer.savedFilterSelection,
16079
- };
16080
- };
16081
- const mapDispatchToProps = (dispatch) => {
16082
- return {
16083
- setFilterConfiguration: (filterConfiguration) => dispatch(setFilterConfiguration(filterConfiguration)),
16084
- };
16085
- };
16086
- var ChatbotSaveFilterComponent$1 = connect(mapStateToProps, mapDispatchToProps)(ChatbotSaveFilterComponent);
16087
-
16088
17280
  var _mask$1, _path$5, _path2$1, _defs$1;
16089
17281
  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); }
16090
17282
  var SvgMimimizedIconLogo = function SvgMimimizedIconLogo(props) {
@@ -16740,8 +17932,72 @@ const AllocationDetailPanel = () => {
16740
17932
  return createPortal(panel, document.body);
16741
17933
  };
16742
17934
 
17935
+ /**
17936
+ * SmartBot Redux reducer.
17937
+ * State shape and behaviour match the consumer's core/reducers/smartBotReducer.js exactly.
17938
+ */
17939
+ const smartBotInitialState = {
17940
+ smartBotActive: false,
17941
+ isSmartBotRestricted: true,
17942
+ chatbotContext: {},
17943
+ thinkingContext: {
17944
+ thinkingContent: "",
17945
+ thinkingHeaderMessage: "Working for 0m:00s",
17946
+ streamStartTime: null,
17947
+ isStreamCompleted: false,
17948
+ finalElapsedSeconds: null,
17949
+ },
17950
+ heirarchyKeyValuePairs: {},
17951
+ currentAgentChatId: "",
17952
+ persistedFormValues: {},
17953
+ savedFilterSets: [],
17954
+ stepFormRestreamPayload: null,
17955
+ stepFormStreamData: null,
17956
+ minimizedStreamData: null,
17957
+ chatbotFilterOptions: [],
17958
+ };
17959
+ function smartBotReducer(state = smartBotInitialState, action) {
17960
+ switch (action.type) {
17961
+ case SET_SMART_BOT_ACTIVE:
17962
+ return { ...state, smartBotActive: action.payload };
17963
+ case SET_IS_SMART_BOT_RESTRICTED:
17964
+ return { ...state, isSmartBotRestricted: action.payload };
17965
+ case SET_CHATBOT_CONTEXT:
17966
+ return { ...state, chatbotContext: action.payload };
17967
+ case SET_THINKING_CONTEXT:
17968
+ return { ...state, thinkingContext: action.payload };
17969
+ case SET_HIERARCHY_KEY_VALUE_PAIR:
17970
+ return { ...state, heirarchyKeyValuePairs: action.payload };
17971
+ case SET_CURRENT_AGENT_CHAT_ID:
17972
+ return { ...state, currentAgentChatId: action.payload };
17973
+ case SET_PERSISTED_FORM_VALUES:
17974
+ return {
17975
+ ...state,
17976
+ persistedFormValues: {
17977
+ ...state.persistedFormValues,
17978
+ ...action.payload,
17979
+ },
17980
+ };
17981
+ case CLEAR_PERSISTED_FORM_VALUES:
17982
+ return { ...state, persistedFormValues: {} };
17983
+ case SET_SAVED_FILTER_SETS:
17984
+ return { ...state, savedFilterSets: action.payload };
17985
+ case SET_STEP_FORM_RESTREAM_PAYLOAD:
17986
+ return { ...state, stepFormRestreamPayload: action.payload };
17987
+ case SET_STEP_FORM_STREAM_DATA:
17988
+ return { ...state, stepFormStreamData: action.payload };
17989
+ case SET_MINIMIZED_STREAM_DATA:
17990
+ return { ...state, minimizedStreamData: action.payload };
17991
+ case SET_CHATBOT_FILTER_OPTIONS:
17992
+ return { ...state, chatbotFilterOptions: action.payload };
17993
+ default:
17994
+ return state;
17995
+ }
17996
+ }
17997
+
16743
17998
  const SmartBot = (props) => {
16744
17999
  const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
18000
+ const { callbacks, components, selectors } = useChatbotDeps();
16745
18001
  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();
16746
18002
  // Add state for confirmation dialogs
16747
18003
  useState(false);
@@ -16749,11 +18005,8 @@ const SmartBot = (props) => {
16749
18005
  useState(false);
16750
18006
  useState(false);
16751
18007
  const [conversation, setConversation] = useState({});
16752
- // "Upload Skill": offered only when the agent's /info says skills.upload (asked once per base URL)
16753
- const [skillUploadOn, setSkillUploadOn] = useState(false);
16754
- const [isSkillUploadOpen, setIsSkillUploadOpen] = useState(false);
16755
18008
  const { chatbotContext, currentAgentChatId, minimizedStreamData } = useSelector((state) => state.smartBotReducer);
16756
- const savedFilterDashboard = useSelector((state) => state.filterReducer?.savedFilterDashboard);
18009
+ const savedFilterDashboard = useSelector(selectors?.getSavedFilterDashboard ?? NULL_SELECTOR);
16757
18010
  // Per-mode conversation ID tracking — prevents cross-mode contamination when
16758
18011
  // switching tabs while streams are pending.
16759
18012
  useRef({});
@@ -16783,7 +18036,7 @@ const SmartBot = (props) => {
16783
18036
  useRef(0);
16784
18037
  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);
16785
18038
  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);
16786
- const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction, dispatch);
18039
+ const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction);
16787
18040
  const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
16788
18041
  setChatDataState,
16789
18042
  activeConversationId,
@@ -16929,8 +18182,7 @@ const SmartBot = (props) => {
16929
18182
  let accessDataResponse = await getModuleLevelAccessUtility({
16930
18183
  app: applicationName,
16931
18184
  module: ["Chatbot Upload"],
16932
- skipHierarchyCall: true,
16933
- })();
18185
+ });
16934
18186
  if (!isEmpty$1(accessDataResponse)) {
16935
18187
  setUtilityList([
16936
18188
  ...utilityList,
@@ -16981,8 +18233,7 @@ const SmartBot = (props) => {
16981
18233
  let accessDataResponse = await getModuleLevelAccessUtility({
16982
18234
  app: applicationName,
16983
18235
  module: ["ChatbotAgent"],
16984
- skipHierarchyCall: true,
16985
- })();
18236
+ });
16986
18237
  let showAgentIcon = await getAgentVisibilityData();
16987
18238
  let appCode = getApplicationCodeFromURL(applicationName);
16988
18239
  let hideNavbot = await getHideNavbotData(appCode);
@@ -16993,6 +18244,7 @@ const SmartBot = (props) => {
16993
18244
  let multiChatCfUrl = await getMultiChatCfUrl(appCode);
16994
18245
  setChatHistoryBaseUrl(multiChatCfUrl);
16995
18246
  const filterNavigationTab = (tabs) => hideNavbot ? tabs.filter((tab) => tab.name !== "Navigation") : tabs;
18247
+ const filterSavedFiltersTab = (tabs) => components?.FilterComponent ? tabs : tabs.filter((tab) => tab.name !== "Saved Filters");
16996
18248
  if (!isEmpty$1(accessDataResponse) &&
16997
18249
  showAgentIcon?.data?.data[0]?.attribute_value?.value) {
16998
18250
  let list = await getAgentExceptionUserList(appCode);
@@ -17206,7 +18458,7 @@ const SmartBot = (props) => {
17206
18458
  icon: jsx(SvgNavigationIcon, {}),
17207
18459
  }
17208
18460
  ];
17209
- setTabList(filterNavigationTab(tabListData));
18461
+ setTabList(filterSavedFiltersTab(filterNavigationTab(tabListData)));
17210
18462
  }
17211
18463
  else {
17212
18464
  setCurrentMode("navigation");
@@ -17311,29 +18563,6 @@ const SmartBot = (props) => {
17311
18563
  useEffect(() => {
17312
18564
  fetchCustomBotConfigurations();
17313
18565
  }, [baseUrl]);
17314
- useEffect(() => {
17315
- let live = true;
17316
- if (!baseUrl) {
17317
- setSkillUploadOn(false);
17318
- return;
17319
- }
17320
- fetchSkillUploadOn(baseUrl).then((on) => {
17321
- if (live)
17322
- setSkillUploadOn(on);
17323
- });
17324
- return () => {
17325
- live = false;
17326
- };
17327
- }, [baseUrl]);
17328
- // kept apart from utilityList: handleUploadAccess sets that list from its first value once its access
17329
- // check returns, which would drop an item added meanwhile
17330
- const skillUploadItem = {
17331
- key: "Upload Skill",
17332
- onClick: () => {
17333
- setIsSkillUploadOpen(true);
17334
- },
17335
- icon: (jsx("div", { className: classes.memoryModalIconDiv, children: jsx(SvgUploadIcon, { style: { width: 20, height: 20 } }) })),
17336
- };
17337
18566
  // Sync showModal state with props.showModal OR props.invokeBot (backward compatibility)
17338
18567
  // Host app passes showModal prop, but some integrations may use invokeBot
17339
18568
  useEffect(() => {
@@ -17991,7 +19220,7 @@ const SmartBot = (props) => {
17991
19220
  return (jsxs(Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsx(MinimizedChatWidget, { onExpand: () => {
17992
19221
  setShowModal(true);
17993
19222
  setPartialClose(false);
17994
- } })), 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 }), skillUploadOn && (jsx(SkillUploadModal, { isOpen: isSkillUploadOpen, setIsOpen: setIsSkillUploadOpen, baseUrl: baseUrl, displaySnackMessages: displaySnackMessages, onUseText: (text) => setUserInput(text) })), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat, isConversationLoading: conversationLoading, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
19223
+ } })), 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, isConversationLoading: conversationLoading, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
17995
19224
  // onSaveClick={saveCurrentChat}
17996
19225
  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) => {
17997
19226
  const convId = params?.conversation_id;
@@ -18034,7 +19263,7 @@ const SmartBot = (props) => {
18034
19263
  }
18035
19264
  }, onHistoryMenuAction: (action, conversationData) => {
18036
19265
  handleHistoryMenuAction(action, conversationData);
18037
- }, activeConversationId: activeConversationId,
19266
+ }, activeConversationId: activeConversationId, isConversationLoading: conversationLoading,
18038
19267
  // landingScreen={true}
18039
19268
  handleNewChatClick: () => {
18040
19269
  localStorage.setItem("isStreaming", "false");
@@ -18104,10 +19333,10 @@ const SmartBot = (props) => {
18104
19333
  onSendIconClick: onSendIconClick, conversation: conversation, onModuleClick: (id, name, param) => {
18105
19334
  // activeTab.current.activeTab = name.toLowerCase();
18106
19335
  handleModuleSelect(name);
18107
- }, moduleList: modules, tabList: tabList, utilityList: skillUploadOn ? [...utilityList, skillUploadItem] : utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
19336
+ }, moduleList: modules, tabList: tabList, utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
18108
19337
  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 })
18109
19338
  :
18110
- jsx(ChatbotSaveFilterComponent$1, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth }), inputText: userInput, threadList: ["Home"], hideMenuArrow: true, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
19339
+ components?.FilterComponent ? jsx(components.FilterComponent, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth, onSetFilterConfiguration: callbacks?.onSetFilterConfiguration }) : null, inputText: userInput, threadList: ["Home"], hideMenuArrow: true, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
18111
19340
  freeTextHeading: "Try adding more details :",
18112
19341
  freeTextContent: "Iris works better when you provide more context and pointed questions",
18113
19342
  }, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {
@@ -18132,5 +19361,5 @@ const SmartBot = (props) => {
18132
19361
  } })] }), jsx(AllocationDetailPanel, {})] }));
18133
19362
  };
18134
19363
 
18135
- export { SmartBot as default };
19364
+ export { ChatbotProvider, clearPersistedFormValues, SmartBot as default, setChatbotContext, setChatbotFilterOptions, setCurrentAgentChatId, setHierarchyKeyValue, setIsSmartBotRestricted, setMinimizedStreamData, setPersistedFormValues, setSavedFilterSets, setSmartBotActive, setStepFormRestreamPayload, setStepFormStreamData, setThinkingContext, smartBotInitialState, smartBotReducer, useChatbotDeps };
18136
19365
  //# sourceMappingURL=index.esm.js.map