impact-chatbot 2.3.78 → 2.3.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { cloneDeep, isEmpty as isEmpty$1, isNull, isArray as isArray$1, isObject, throttle } from 'lodash';
3
3
  import * as React from 'react';
4
- import { useCallback, useState, useEffect, useRef, createContext, useContext, useMemo } from 'react';
4
+ import { useCallback, useState, useEffect, useRef, createContext, useContext, useMemo, Fragment as Fragment$1 } from 'react';
5
5
  import { COMBINED_CROSS_DIMENSIONAL_API, BASE_API } from 'config/api';
6
6
  import axiosInstance from 'core/Utils/axios';
7
7
  import { tenantConfigApiCache } from 'core/actions/tenantConfigActions';
@@ -2179,11 +2179,17 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
2179
2179
  };
2180
2180
  };
2181
2181
 
2182
- 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) => {
2182
+ 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) => {
2183
2183
  const navSessionIdRef = useRef(navSessionId);
2184
2184
  useEffect(() => {
2185
2185
  navSessionIdRef.current = navSessionId;
2186
2186
  }, [navSessionId]);
2187
+ // Keep a fresh reference to uniqueChatId so callbacks memoized with narrow
2188
+ // deps (e.g. handleUserAction) don't send a stale/empty chat_id on follow-ups.
2189
+ const uniqueChatIdRef = useRef(uniqueChatId);
2190
+ useEffect(() => {
2191
+ uniqueChatIdRef.current = uniqueChatId;
2192
+ }, [uniqueChatId]);
2187
2193
  const { prepareDataAndSendToAgent, setAgentFlow, processResponse, } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
2188
2194
  setChatDataState,
2189
2195
  activeConversationId,
@@ -2206,9 +2212,10 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2206
2212
  thinkingHeaderMessage,
2207
2213
  setThinkingHeaderMessage,
2208
2214
  uniqueChatId,
2215
+ setUniqueChatId,
2209
2216
  fieldNumber,
2210
2217
  setFieldNumber,
2211
- setAdditionalArgs: () => { },
2218
+ setAdditionalArgs: setAdditionalArgs || (() => { }),
2212
2219
  });
2213
2220
  const getCurrentDateTimeString = () => {
2214
2221
  return moment().format(dateFormat);
@@ -2371,7 +2378,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2371
2378
  sessionId: sessionId,
2372
2379
  setSessionId: setSessionId,
2373
2380
  setInitValue: setInitValue,
2374
- uniqueChatId: uniqueChatId,
2381
+ uniqueChatId: uniqueChatIdRef.current,
2375
2382
  additionalArgs: additionalArgs,
2376
2383
  });
2377
2384
  }
@@ -3591,6 +3598,9 @@ const useStyles$a = makeStyles((theme) => ({
3591
3598
  boldText: {
3592
3599
  fontWeight: 600,
3593
3600
  },
3601
+ combinedBlockHeaderTitle: {
3602
+ marginBottom: "0.5rem",
3603
+ },
3594
3604
  botViewHeader: {
3595
3605
  color: theme.palette.textColours.botDateChipText,
3596
3606
  },
@@ -5487,7 +5497,7 @@ const useStyles$8 = makeStyles((theme) => ({
5487
5497
  }));
5488
5498
  const MAX_RETRY_COUNT_BUTTON = 1;
5489
5499
  const RETRY_COUNTDOWN_SECONDS_BUTTON = 15;
5490
- const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false, isFormValid = true }) => {
5500
+ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false, isFormValid = true, formParamNames = [], messageIndex = 0 }) => {
5491
5501
  const classes = useStyles$8();
5492
5502
  const dispatch = useDispatch();
5493
5503
  const sourceRef = useRef(null);
@@ -5513,19 +5523,56 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5513
5523
  status: "",
5514
5524
  });
5515
5525
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
5526
+ const chatbotContextRef = useRef(chatbotContext);
5527
+ chatbotContextRef.current = chatbotContext;
5528
+ const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
5529
+ const persistedFormValuesRef = useRef(persistedFormValues);
5530
+ persistedFormValuesRef.current = persistedFormValues;
5516
5531
  const thinkingContext = useSelector((state) => state.smartBotReducer.thinkingContext);
5517
5532
  const handleButtonClick = (button) => {
5518
5533
  if (isStepFormSubmit) {
5519
- // Build the user_input from chatbotContext
5534
+ // Read the latest chatbotContext from ref to avoid stale closures
5535
+ const currentContext = chatbotContextRef.current;
5536
+ const currentPersisted = persistedFormValuesRef.current;
5537
+ // Build the user_input ONLY from formParamNames (current form's fields)
5520
5538
  const userInput = {};
5521
- for (const key in chatbotContext) {
5522
- if (key.startsWith('__'))
5523
- continue;
5524
- if (chatbotContext[key]?.updated) {
5525
- let value = chatbotContext[key][key];
5526
- userInput[key] = isArray$2(value)
5527
- ? value
5528
- : typeof value === 'number' ? value : String(value);
5539
+ if (formParamNames.length > 0) {
5540
+ formParamNames.forEach((paramName) => {
5541
+ // Primary source: chatbotContext (set by handleChange in form components)
5542
+ if (currentContext[paramName]?.updated) {
5543
+ let value = currentContext[paramName][paramName];
5544
+ userInput[paramName] = isArray$2(value)
5545
+ ? value
5546
+ : typeof value === 'number' ? value : String(value);
5547
+ }
5548
+ else {
5549
+ // Fallback: persistedFormValues (covers edge case where chatbotContext
5550
+ // was cleared but the form still has a valid selection displayed)
5551
+ const persistedKey = `${messageIndex}_${paramName}`;
5552
+ const persistedValue = currentPersisted[persistedKey];
5553
+ if (persistedValue !== undefined && persistedValue !== null) {
5554
+ // For select components, persistedFormValues stores option objects
5555
+ if (isArray$2(persistedValue)) {
5556
+ userInput[paramName] = persistedValue.map((opt) => opt.value !== undefined ? opt.value : opt);
5557
+ }
5558
+ else {
5559
+ userInput[paramName] = typeof persistedValue === 'number' ? persistedValue : String(persistedValue);
5560
+ }
5561
+ }
5562
+ }
5563
+ });
5564
+ }
5565
+ else {
5566
+ // Legacy fallback: no formParamNames provided, iterate chatbotContext
5567
+ for (const key in currentContext) {
5568
+ if (key.startsWith('__'))
5569
+ continue;
5570
+ if (currentContext[key]?.updated) {
5571
+ let value = currentContext[key][key];
5572
+ userInput[key] = isArray$2(value)
5573
+ ? value
5574
+ : typeof value === 'number' ? value : String(value);
5575
+ }
5529
5576
  }
5530
5577
  }
5531
5578
  dispatch(setChatbotContext({}));
@@ -5863,6 +5910,8 @@ const TableContent = ({ bodyText }) => {
5863
5910
  const [isModalOpen, setIsModalOpen] = useState(false);
5864
5911
  const [downloadUrl, setDownloadUrl] = useState("");
5865
5912
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
5913
+ const chatbotContextRef = useRef(chatbotContext);
5914
+ chatbotContextRef.current = chatbotContext;
5866
5915
  const dispatch = useDispatch();
5867
5916
  useEffect(() => {
5868
5917
  let formattedColumns = getFormattedTableConfig(table_config);
@@ -5908,9 +5957,10 @@ const TableContent = ({ bodyText }) => {
5908
5957
  const onSelectionChanged = (event) => {
5909
5958
  try {
5910
5959
  const selectedList = event.api.getSelectedRows();
5960
+ const latestContext = chatbotContextRef.current;
5911
5961
  dispatch(setChatbotContext({
5912
- ...chatbotContext,
5913
- tables: { ...chatbotContext?.tables, [table_name]: selectedList },
5962
+ ...latestContext,
5963
+ tables: { ...latestContext?.tables, [table_name]: selectedList },
5914
5964
  }));
5915
5965
  }
5916
5966
  catch (error) {
@@ -6781,6 +6831,8 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6781
6831
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
6782
6832
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6783
6833
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6834
+ const chatbotContextRef = useRef(chatbotContext);
6835
+ chatbotContextRef.current = chatbotContext;
6784
6836
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
6785
6837
  const dispatch = useDispatch();
6786
6838
  const [sliderValue, setSliderValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : 0);
@@ -6788,16 +6840,18 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6788
6840
  return null;
6789
6841
  const handleChange = (value) => {
6790
6842
  try {
6791
- setSliderValue(value?.target?.value);
6843
+ const newValue = value?.target?.value;
6844
+ setSliderValue(newValue);
6845
+ const latestContext = chatbotContextRef.current;
6792
6846
  dispatch(setChatbotContext({
6793
- ...chatbotContext,
6847
+ ...latestContext,
6794
6848
  [bodyText?.paramName]: {
6795
- ...chatbotContext?.[bodyText?.paramName],
6796
- [bodyText?.paramName]: value?.target?.value,
6849
+ ...latestContext?.[bodyText?.paramName],
6850
+ [bodyText?.paramName]: newValue,
6797
6851
  updated: true,
6798
6852
  },
6799
6853
  }));
6800
- dispatch(setPersistedFormValues({ [formKey]: value?.target?.value }));
6854
+ dispatch(setPersistedFormValues({ [formKey]: newValue }));
6801
6855
  }
6802
6856
  catch (error) {
6803
6857
  console.error("Error in slider handleChange", error);
@@ -6833,6 +6887,8 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6833
6887
  const searchTermRef = useRef("");
6834
6888
  const selectAllCountRef = useRef(persistedFormValues?.[selectAllKey] || 0);
6835
6889
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
6890
+ const chatbotContextRef = useRef(chatbotContext);
6891
+ chatbotContextRef.current = chatbotContext;
6836
6892
  const heirarchyKeyValuePairs = useSelector((state) => state.smartBotReducer.heirarchyKeyValuePairs);
6837
6893
  const dispatch = useDispatch();
6838
6894
  // Cross-filter cascading context (optional — graceful fallback when not wrapped)
@@ -6850,10 +6906,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6850
6906
  else {
6851
6907
  value = selectedOptions.value;
6852
6908
  }
6909
+ const latestContext = chatbotContextRef.current;
6853
6910
  const updatedContext = {
6854
- ...chatbotContext,
6911
+ ...latestContext,
6855
6912
  [bodyText?.paramName]: {
6856
- ...chatbotContext?.[bodyText?.paramName],
6913
+ ...latestContext?.[bodyText?.paramName],
6857
6914
  [bodyText?.paramName]: value,
6858
6915
  updated: true,
6859
6916
  },
@@ -6903,10 +6960,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6903
6960
  setCurrentSelectedOptions([]);
6904
6961
  setIsAllSelected(false);
6905
6962
  // Also clear from chatbotContext and persistedFormValues
6963
+ const ctx = chatbotContextRef.current;
6906
6964
  dispatch(setChatbotContext({
6907
- ...chatbotContext,
6965
+ ...ctx,
6908
6966
  [bodyText?.paramName]: {
6909
- ...chatbotContext?.[bodyText?.paramName],
6967
+ ...ctx?.[bodyText?.paramName],
6910
6968
  [bodyText?.paramName]: [],
6911
6969
  updated: true,
6912
6970
  },
@@ -6964,10 +7022,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6964
7022
  isRequired: isRequired, isDisabled: isDisabled || isFormDisabled, isClearable: !(isDisabled || isFormDisabled), onClearAll: () => {
6965
7023
  setCurrentSelectedOptions([]);
6966
7024
  setIsAllSelected(false);
7025
+ const ctx1 = chatbotContextRef.current;
6967
7026
  dispatch(setChatbotContext({
6968
- ...chatbotContext,
7027
+ ...ctx1,
6969
7028
  [bodyText?.paramName]: {
6970
- ...chatbotContext?.[bodyText?.paramName],
7029
+ ...ctx1?.[bodyText?.paramName],
6971
7030
  [bodyText?.paramName]: [],
6972
7031
  updated: true,
6973
7032
  },
@@ -7046,10 +7105,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7046
7105
  selectAllCountRef.current = allOptionsRef.current.length;
7047
7106
  }
7048
7107
  setIsAllSelected(true);
7108
+ const ctx2 = chatbotContextRef.current;
7049
7109
  dispatch(setChatbotContext({
7050
- ...chatbotContext,
7110
+ ...ctx2,
7051
7111
  [bodyText?.paramName]: {
7052
- ...chatbotContext?.[bodyText?.paramName],
7112
+ ...ctx2?.[bodyText?.paramName],
7053
7113
  [bodyText?.paramName]: valuesToDispatch,
7054
7114
  updated: true,
7055
7115
  },
@@ -7067,10 +7127,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7067
7127
  else {
7068
7128
  setCurrentSelectedOptions([]);
7069
7129
  setIsAllSelected(false);
7130
+ const ctx3 = chatbotContextRef.current;
7070
7131
  dispatch(setChatbotContext({
7071
- ...chatbotContext,
7132
+ ...ctx3,
7072
7133
  [bodyText?.paramName]: {
7073
- ...chatbotContext?.[bodyText?.paramName],
7134
+ ...ctx3?.[bodyText?.paramName],
7074
7135
  [bodyText?.paramName]: [],
7075
7136
  updated: true,
7076
7137
  },
@@ -7092,6 +7153,8 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
7092
7153
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7093
7154
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, minStartDate, } = bodyText;
7094
7155
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
7156
+ const chatbotContextRef = useRef(chatbotContext);
7157
+ chatbotContextRef.current = chatbotContext;
7095
7158
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7096
7159
  const dispatch = useDispatch();
7097
7160
  const [selectedDate, setSelectedDate] = useState(persistedFormValues[formKey] || null);
@@ -7100,10 +7163,11 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
7100
7163
  const handleDateChange = (date) => {
7101
7164
  try {
7102
7165
  setSelectedDate(date);
7166
+ const latestContext = chatbotContextRef.current;
7103
7167
  dispatch(setChatbotContext({
7104
- ...chatbotContext,
7168
+ ...latestContext,
7105
7169
  [bodyText?.paramName]: {
7106
- ...chatbotContext?.[bodyText?.paramName],
7170
+ ...latestContext?.[bodyText?.paramName],
7107
7171
  [bodyText?.paramName]: moment(date).format(displayFormat),
7108
7172
  updated: true,
7109
7173
  },
@@ -7131,6 +7195,8 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
7131
7195
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7132
7196
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, minStartDate, } = bodyText;
7133
7197
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
7198
+ const chatbotContextRef = useRef(chatbotContext);
7199
+ chatbotContextRef.current = chatbotContext;
7134
7200
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7135
7201
  const dispatch = useDispatch();
7136
7202
  const [startDate, setStartDate] = useState(persistedFormValues[formKey]?.startDate || null);
@@ -7141,10 +7207,11 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
7141
7207
  try {
7142
7208
  setStartDate(start);
7143
7209
  setEndDate(end);
7210
+ const latestContext = chatbotContextRef.current;
7144
7211
  dispatch(setChatbotContext({
7145
- ...chatbotContext,
7212
+ ...latestContext,
7146
7213
  [bodyText?.paramName]: {
7147
- ...chatbotContext?.[bodyText?.paramName],
7214
+ ...latestContext?.[bodyText?.paramName],
7148
7215
  [bodyText?.paramName]: {
7149
7216
  startDate: start ? moment(start).format(displayFormat) : null,
7150
7217
  endDate: end ? moment(end).format(displayFormat) : null,
@@ -7179,6 +7246,8 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
7179
7246
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7180
7247
  const { label, checked: checkedValue, required, disabled, } = bodyText;
7181
7248
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
7249
+ const chatbotContextRef = useRef(chatbotContext);
7250
+ chatbotContextRef.current = chatbotContext;
7182
7251
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7183
7252
  const dispatch = useDispatch();
7184
7253
  const [checked, setChecked] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : checkedValue);
@@ -7187,15 +7256,11 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
7187
7256
  const handleChange = (isChecked) => {
7188
7257
  try {
7189
7258
  setChecked(isChecked?.currentTarget?.checked);
7190
- // chatbotContext.checkbox = {
7191
- // ...chatbotContext?.checkbox,
7192
- // [bodyText?.paramName]: isChecked?.currentTarget?.checked,
7193
- // updated: true
7194
- // };
7259
+ const latestContext = chatbotContextRef.current;
7195
7260
  dispatch(setChatbotContext({
7196
- ...chatbotContext,
7261
+ ...latestContext,
7197
7262
  [bodyText?.paramName]: {
7198
- ...chatbotContext?.[bodyText?.paramName],
7263
+ ...latestContext?.[bodyText?.paramName],
7199
7264
  [bodyText?.paramName]: isChecked?.currentTarget?.checked,
7200
7265
  updated: true,
7201
7266
  },
@@ -7214,6 +7279,8 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7214
7279
  const classes = useStyles$a();
7215
7280
  const { label, isDisabled, orientation, options } = bodyText;
7216
7281
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
7282
+ const chatbotContextRef = useRef(chatbotContext);
7283
+ chatbotContextRef.current = chatbotContext;
7217
7284
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7218
7285
  const dispatch = useDispatch();
7219
7286
  const [selectedOption, setSelectedOption] = useState(persistedFormValues[formKey] ?? null);
@@ -7228,10 +7295,11 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7228
7295
  // [bodyText?.paramName]: value,
7229
7296
  // updated: true,
7230
7297
  // };
7298
+ const latestContext = chatbotContextRef.current;
7231
7299
  dispatch(setChatbotContext({
7232
- ...chatbotContext,
7300
+ ...latestContext,
7233
7301
  [bodyText?.paramName]: {
7234
- ...chatbotContext?.[bodyText?.paramName],
7302
+ ...latestContext?.[bodyText?.paramName],
7235
7303
  [bodyText?.paramName]: value,
7236
7304
  updated: true,
7237
7305
  },
@@ -7249,6 +7317,8 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7249
7317
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7250
7318
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
7251
7319
  const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
7320
+ const chatbotContextRef = useRef(chatbotContext);
7321
+ chatbotContextRef.current = chatbotContext;
7252
7322
  const persistedFormValues = useSelector((state) => state.smartBotReducer.persistedFormValues);
7253
7323
  const dispatch = useDispatch();
7254
7324
  const [value, setValue] = useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : (defaultValue || ""));
@@ -7258,10 +7328,11 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7258
7328
  try {
7259
7329
  const newValue = event?.target?.value || event?.currentTarget?.value || "";
7260
7330
  setValue(newValue);
7331
+ const latestContext = chatbotContextRef.current;
7261
7332
  dispatch(setChatbotContext({
7262
- ...chatbotContext,
7333
+ ...latestContext,
7263
7334
  [bodyText?.paramName]: {
7264
- ...chatbotContext?.[bodyText?.paramName],
7335
+ ...latestContext?.[bodyText?.paramName],
7265
7336
  [bodyText?.paramName]: replaceSpecialCharToCharCode(newValue),
7266
7337
  updated: true,
7267
7338
  type: inputType,
@@ -7557,6 +7628,15 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7557
7628
  });
7558
7629
  return selections;
7559
7630
  }, [crossFilterConfigs, chatbotContext, persistedFormValues, messageIndex]);
7631
+ // Extract the param names of the current form's fields so ButtonContent
7632
+ // can restrict user_input to only these keys (avoids leaking stale context).
7633
+ const formParamNames = useMemo(() => {
7634
+ if (!formData || !Array.isArray(formData))
7635
+ return [];
7636
+ return formData
7637
+ .filter((item) => item?.type !== "button" && item?.data?.param_name)
7638
+ .map((item) => item.data.param_name);
7639
+ }, [formData]);
7560
7640
  if (!formData || !Array.isArray(formData) || formData.length === 0) {
7561
7641
  return null;
7562
7642
  }
@@ -7584,7 +7664,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7584
7664
  case "radio":
7585
7665
  return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7586
7666
  case "button":
7587
- return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled }, key);
7667
+ return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled, formParamNames: formParamNames, messageIndex: messageIndex }, key);
7588
7668
  case "input":
7589
7669
  return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7590
7670
  case "image":
@@ -10553,10 +10633,18 @@ const resetActiveTabularInstance = () => {
10553
10633
  };
10554
10634
 
10555
10635
  const CombinedContent = ({ botData, props }) => {
10636
+ const classes = useStyles$a();
10556
10637
  const isFormDisabled = botData?.isFormDisabled || false;
10557
10638
  const isTabEnabled = botData?.utilityData?.isTabEnabled;
10558
10639
  // Get the array of content items from bodyText
10559
10640
  const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
10641
+ // Renders the optional block-level header title above a content item
10642
+ const renderHeaderTitle = (parsedData) => {
10643
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle && Boolean(parsedData?.headerTitle?.length);
10644
+ if (!showHeaderTitle)
10645
+ return null;
10646
+ return (jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }));
10647
+ };
10560
10648
  // Function to render individual content based on its type
10561
10649
  const renderIndividualContent = (parsedData, index) => {
10562
10650
  const key = `combined-content-${index}`;
@@ -10609,8 +10697,8 @@ const CombinedContent = ({ botData, props }) => {
10609
10697
  if (!parsedData) {
10610
10698
  return null;
10611
10699
  }
10612
- // Render the parsed content
10613
- return renderIndividualContent(parsedData, index);
10700
+ // Render the parsed content, preceded by the block's header title when present
10701
+ return (jsxs(Fragment$1, { children: [renderHeaderTitle(parsedData), renderIndividualContent(parsedData, index)] }, `combined-block-${index}`));
10614
10702
  }
10615
10703
  catch (error) {
10616
10704
  console.error(`Error parsing combined content item at index ${index}:`, error);
@@ -14821,7 +14909,7 @@ const SmartBot = (props) => {
14821
14909
  const [chatBotWidth, setChatBotWidth] = useState(null);
14822
14910
  const [tabList, setTabList] = useState([]);
14823
14911
  useRef(0);
14824
- 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);
14912
+ 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);
14825
14913
  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);
14826
14914
  const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction, dispatch);
14827
14915
  const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {