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.
@@ -8,10 +8,12 @@ export declare const stepFormStreamControl: {
8
8
  initValue: boolean;
9
9
  uniqueChatId: string;
10
10
  };
11
- declare const ButtonContent: ({ bodyText, isFormDisabled, isStepFormSubmit, isFormValid }: {
11
+ declare const ButtonContent: ({ bodyText, isFormDisabled, isStepFormSubmit, isFormValid, formParamNames, messageIndex }: {
12
12
  bodyText: any;
13
13
  isFormDisabled?: boolean;
14
14
  isStepFormSubmit?: boolean;
15
15
  isFormValid?: boolean;
16
+ formParamNames?: any[];
17
+ messageIndex?: number;
16
18
  }) => import("react/jsx-runtime").JSX.Element;
17
19
  export default ButtonContent;
@@ -1,4 +1,4 @@
1
- export declare const useChatFlow: (chatDataRef: any, setLoader: any, setFlowType: any, setScreenName: any, setUserInput: any, setQuestionIndex: any, setCurrentAppLink: any, flowType: any, screenName: any, questionIndex: any, userInput: any, dateFormat: any, currentMode: any, activeConversationId: any, setIsModuleChanged: any, chatBodyRef: any, filterReducerState: any, dispatch: any, navigate: any, setShowChatPlaceholder: any, baseUrl: any, setChatDataState: any, setCurrentSessionId: any, customChatConfig: any, chatDataInfoRef: any, chatbotContext: any, setInitValue: any, setSessionId: any, thinkingContent: any, setThinkingContent: any, isThinking: any, setIsThinking: any, chatId: any, setChatId: any, isStop: any, setIsStop: any, functionsRef: any, functionsState: any, setFunctionsState: any, thinkingHeaderMessage: any, setThinkingHeaderMessage: any, uniqueChatId: any, initValue: any, sessionId: any, fieldNumber: any, setFieldNumber: any, additionalArgs: any, setActiveConversationId: any, navSessionId: any, setNavSessionId: any) => {
1
+ export declare const useChatFlow: (chatDataRef: any, setLoader: any, setFlowType: any, setScreenName: any, setUserInput: any, setQuestionIndex: any, setCurrentAppLink: any, flowType: any, screenName: any, questionIndex: any, userInput: any, dateFormat: any, currentMode: any, activeConversationId: any, setIsModuleChanged: any, chatBodyRef: any, filterReducerState: any, dispatch: any, navigate: any, setShowChatPlaceholder: any, baseUrl: any, setChatDataState: any, setCurrentSessionId: any, customChatConfig: any, chatDataInfoRef: any, chatbotContext: any, setInitValue: any, setSessionId: any, thinkingContent: any, setThinkingContent: any, isThinking: any, setIsThinking: any, chatId: any, setChatId: any, isStop: any, setIsStop: any, functionsRef: any, functionsState: any, setFunctionsState: any, thinkingHeaderMessage: any, setThinkingHeaderMessage: any, uniqueChatId: any, initValue: any, sessionId: any, fieldNumber: any, setFieldNumber: any, additionalArgs: any, setActiveConversationId: any, navSessionId: any, setNavSessionId: any, setUniqueChatId: any, setAdditionalArgs: any) => {
2
2
  setUserFlow: (data: any) => Promise<void>;
3
3
  setUserScreenAndFlow: (data: any) => void;
4
4
  fetchUserResultsFromQuery: (refObject: any, fetchQuestions?: boolean, inputValue?: any, conversationId?: any) => Promise<void>;
package/dist/index.cjs.js CHANGED
@@ -2201,11 +2201,17 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
2201
2201
  };
2202
2202
  };
2203
2203
 
2204
- 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) => {
2204
+ 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) => {
2205
2205
  const navSessionIdRef = React.useRef(navSessionId);
2206
2206
  React.useEffect(() => {
2207
2207
  navSessionIdRef.current = navSessionId;
2208
2208
  }, [navSessionId]);
2209
+ // Keep a fresh reference to uniqueChatId so callbacks memoized with narrow
2210
+ // deps (e.g. handleUserAction) don't send a stale/empty chat_id on follow-ups.
2211
+ const uniqueChatIdRef = React.useRef(uniqueChatId);
2212
+ React.useEffect(() => {
2213
+ uniqueChatIdRef.current = uniqueChatId;
2214
+ }, [uniqueChatId]);
2209
2215
  const { prepareDataAndSendToAgent, setAgentFlow, processResponse, } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {
2210
2216
  setChatDataState,
2211
2217
  activeConversationId,
@@ -2228,9 +2234,10 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2228
2234
  thinkingHeaderMessage,
2229
2235
  setThinkingHeaderMessage,
2230
2236
  uniqueChatId,
2237
+ setUniqueChatId,
2231
2238
  fieldNumber,
2232
2239
  setFieldNumber,
2233
- setAdditionalArgs: () => { },
2240
+ setAdditionalArgs: setAdditionalArgs || (() => { }),
2234
2241
  });
2235
2242
  const getCurrentDateTimeString = () => {
2236
2243
  return moment().format(dateFormat);
@@ -2393,7 +2400,7 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
2393
2400
  sessionId: sessionId,
2394
2401
  setSessionId: setSessionId,
2395
2402
  setInitValue: setInitValue,
2396
- uniqueChatId: uniqueChatId,
2403
+ uniqueChatId: uniqueChatIdRef.current,
2397
2404
  additionalArgs: additionalArgs,
2398
2405
  });
2399
2406
  }
@@ -3613,6 +3620,9 @@ const useStyles$a = styles.makeStyles((theme) => ({
3613
3620
  boldText: {
3614
3621
  fontWeight: 600,
3615
3622
  },
3623
+ combinedBlockHeaderTitle: {
3624
+ marginBottom: "0.5rem",
3625
+ },
3616
3626
  botViewHeader: {
3617
3627
  color: theme.palette.textColours.botDateChipText,
3618
3628
  },
@@ -5509,7 +5519,7 @@ const useStyles$8 = styles.makeStyles((theme) => ({
5509
5519
  }));
5510
5520
  const MAX_RETRY_COUNT_BUTTON = 1;
5511
5521
  const RETRY_COUNTDOWN_SECONDS_BUTTON = 15;
5512
- const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false, isFormValid = true }) => {
5522
+ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = false, isFormValid = true, formParamNames = [], messageIndex = 0 }) => {
5513
5523
  const classes = useStyles$8();
5514
5524
  const dispatch = reactRedux.useDispatch();
5515
5525
  const sourceRef = React.useRef(null);
@@ -5535,19 +5545,56 @@ const ButtonContent = ({ bodyText, isFormDisabled = false, isStepFormSubmit = fa
5535
5545
  status: "",
5536
5546
  });
5537
5547
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
5548
+ const chatbotContextRef = React.useRef(chatbotContext);
5549
+ chatbotContextRef.current = chatbotContext;
5550
+ const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
5551
+ const persistedFormValuesRef = React.useRef(persistedFormValues);
5552
+ persistedFormValuesRef.current = persistedFormValues;
5538
5553
  const thinkingContext = reactRedux.useSelector((state) => state.smartBotReducer.thinkingContext);
5539
5554
  const handleButtonClick = (button) => {
5540
5555
  if (isStepFormSubmit) {
5541
- // Build the user_input from chatbotContext
5556
+ // Read the latest chatbotContext from ref to avoid stale closures
5557
+ const currentContext = chatbotContextRef.current;
5558
+ const currentPersisted = persistedFormValuesRef.current;
5559
+ // Build the user_input ONLY from formParamNames (current form's fields)
5542
5560
  const userInput = {};
5543
- for (const key in chatbotContext) {
5544
- if (key.startsWith('__'))
5545
- continue;
5546
- if (chatbotContext[key]?.updated) {
5547
- let value = chatbotContext[key][key];
5548
- userInput[key] = isArray$1(value)
5549
- ? value
5550
- : typeof value === 'number' ? value : String(value);
5561
+ if (formParamNames.length > 0) {
5562
+ formParamNames.forEach((paramName) => {
5563
+ // Primary source: chatbotContext (set by handleChange in form components)
5564
+ if (currentContext[paramName]?.updated) {
5565
+ let value = currentContext[paramName][paramName];
5566
+ userInput[paramName] = isArray$1(value)
5567
+ ? value
5568
+ : typeof value === 'number' ? value : String(value);
5569
+ }
5570
+ else {
5571
+ // Fallback: persistedFormValues (covers edge case where chatbotContext
5572
+ // was cleared but the form still has a valid selection displayed)
5573
+ const persistedKey = `${messageIndex}_${paramName}`;
5574
+ const persistedValue = currentPersisted[persistedKey];
5575
+ if (persistedValue !== undefined && persistedValue !== null) {
5576
+ // For select components, persistedFormValues stores option objects
5577
+ if (isArray$1(persistedValue)) {
5578
+ userInput[paramName] = persistedValue.map((opt) => opt.value !== undefined ? opt.value : opt);
5579
+ }
5580
+ else {
5581
+ userInput[paramName] = typeof persistedValue === 'number' ? persistedValue : String(persistedValue);
5582
+ }
5583
+ }
5584
+ }
5585
+ });
5586
+ }
5587
+ else {
5588
+ // Legacy fallback: no formParamNames provided, iterate chatbotContext
5589
+ for (const key in currentContext) {
5590
+ if (key.startsWith('__'))
5591
+ continue;
5592
+ if (currentContext[key]?.updated) {
5593
+ let value = currentContext[key][key];
5594
+ userInput[key] = isArray$1(value)
5595
+ ? value
5596
+ : typeof value === 'number' ? value : String(value);
5597
+ }
5551
5598
  }
5552
5599
  }
5553
5600
  dispatch(smartBotActions.setChatbotContext({}));
@@ -5885,6 +5932,8 @@ const TableContent = ({ bodyText }) => {
5885
5932
  const [isModalOpen, setIsModalOpen] = React.useState(false);
5886
5933
  const [downloadUrl, setDownloadUrl] = React.useState("");
5887
5934
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
5935
+ const chatbotContextRef = React.useRef(chatbotContext);
5936
+ chatbotContextRef.current = chatbotContext;
5888
5937
  const dispatch = reactRedux.useDispatch();
5889
5938
  React.useEffect(() => {
5890
5939
  let formattedColumns = getFormattedTableConfig(table_config);
@@ -5930,9 +5979,10 @@ const TableContent = ({ bodyText }) => {
5930
5979
  const onSelectionChanged = (event) => {
5931
5980
  try {
5932
5981
  const selectedList = event.api.getSelectedRows();
5982
+ const latestContext = chatbotContextRef.current;
5933
5983
  dispatch(smartBotActions.setChatbotContext({
5934
- ...chatbotContext,
5935
- tables: { ...chatbotContext?.tables, [table_name]: selectedList },
5984
+ ...latestContext,
5985
+ tables: { ...latestContext?.tables, [table_name]: selectedList },
5936
5986
  }));
5937
5987
  }
5938
5988
  catch (error) {
@@ -6803,6 +6853,8 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6803
6853
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
6804
6854
  const { header, headerOrentiation, inputPosition, label, max, min, required, disabled, } = bodyText;
6805
6855
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6856
+ const chatbotContextRef = React.useRef(chatbotContext);
6857
+ chatbotContextRef.current = chatbotContext;
6806
6858
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
6807
6859
  const dispatch = reactRedux.useDispatch();
6808
6860
  const [sliderValue, setSliderValue] = React.useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : 0);
@@ -6810,16 +6862,18 @@ const SliderContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6810
6862
  return null;
6811
6863
  const handleChange = (value) => {
6812
6864
  try {
6813
- setSliderValue(value?.target?.value);
6865
+ const newValue = value?.target?.value;
6866
+ setSliderValue(newValue);
6867
+ const latestContext = chatbotContextRef.current;
6814
6868
  dispatch(smartBotActions.setChatbotContext({
6815
- ...chatbotContext,
6869
+ ...latestContext,
6816
6870
  [bodyText?.paramName]: {
6817
- ...chatbotContext?.[bodyText?.paramName],
6818
- [bodyText?.paramName]: value?.target?.value,
6871
+ ...latestContext?.[bodyText?.paramName],
6872
+ [bodyText?.paramName]: newValue,
6819
6873
  updated: true,
6820
6874
  },
6821
6875
  }));
6822
- dispatch(smartBotActions.setPersistedFormValues({ [formKey]: value?.target?.value }));
6876
+ dispatch(smartBotActions.setPersistedFormValues({ [formKey]: newValue }));
6823
6877
  }
6824
6878
  catch (error) {
6825
6879
  console.error("Error in slider handleChange", error);
@@ -6855,6 +6909,8 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6855
6909
  const searchTermRef = React.useRef("");
6856
6910
  const selectAllCountRef = React.useRef(persistedFormValues?.[selectAllKey] || 0);
6857
6911
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
6912
+ const chatbotContextRef = React.useRef(chatbotContext);
6913
+ chatbotContextRef.current = chatbotContext;
6858
6914
  const heirarchyKeyValuePairs = reactRedux.useSelector((state) => state.smartBotReducer.heirarchyKeyValuePairs);
6859
6915
  const dispatch = reactRedux.useDispatch();
6860
6916
  // Cross-filter cascading context (optional — graceful fallback when not wrapped)
@@ -6872,10 +6928,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6872
6928
  else {
6873
6929
  value = selectedOptions.value;
6874
6930
  }
6931
+ const latestContext = chatbotContextRef.current;
6875
6932
  const updatedContext = {
6876
- ...chatbotContext,
6933
+ ...latestContext,
6877
6934
  [bodyText?.paramName]: {
6878
- ...chatbotContext?.[bodyText?.paramName],
6935
+ ...latestContext?.[bodyText?.paramName],
6879
6936
  [bodyText?.paramName]: value,
6880
6937
  updated: true,
6881
6938
  },
@@ -6925,10 +6982,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6925
6982
  setCurrentSelectedOptions([]);
6926
6983
  setIsAllSelected(false);
6927
6984
  // Also clear from chatbotContext and persistedFormValues
6985
+ const ctx = chatbotContextRef.current;
6928
6986
  dispatch(smartBotActions.setChatbotContext({
6929
- ...chatbotContext,
6987
+ ...ctx,
6930
6988
  [bodyText?.paramName]: {
6931
- ...chatbotContext?.[bodyText?.paramName],
6989
+ ...ctx?.[bodyText?.paramName],
6932
6990
  [bodyText?.paramName]: [],
6933
6991
  updated: true,
6934
6992
  },
@@ -6986,10 +7044,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
6986
7044
  isRequired: isRequired, isDisabled: isDisabled || isFormDisabled, isClearable: !(isDisabled || isFormDisabled), onClearAll: () => {
6987
7045
  setCurrentSelectedOptions([]);
6988
7046
  setIsAllSelected(false);
7047
+ const ctx1 = chatbotContextRef.current;
6989
7048
  dispatch(smartBotActions.setChatbotContext({
6990
- ...chatbotContext,
7049
+ ...ctx1,
6991
7050
  [bodyText?.paramName]: {
6992
- ...chatbotContext?.[bodyText?.paramName],
7051
+ ...ctx1?.[bodyText?.paramName],
6993
7052
  [bodyText?.paramName]: [],
6994
7053
  updated: true,
6995
7054
  },
@@ -7068,10 +7127,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7068
7127
  selectAllCountRef.current = allOptionsRef.current.length;
7069
7128
  }
7070
7129
  setIsAllSelected(true);
7130
+ const ctx2 = chatbotContextRef.current;
7071
7131
  dispatch(smartBotActions.setChatbotContext({
7072
- ...chatbotContext,
7132
+ ...ctx2,
7073
7133
  [bodyText?.paramName]: {
7074
- ...chatbotContext?.[bodyText?.paramName],
7134
+ ...ctx2?.[bodyText?.paramName],
7075
7135
  [bodyText?.paramName]: valuesToDispatch,
7076
7136
  updated: true,
7077
7137
  },
@@ -7089,10 +7149,11 @@ const SelectContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7089
7149
  else {
7090
7150
  setCurrentSelectedOptions([]);
7091
7151
  setIsAllSelected(false);
7152
+ const ctx3 = chatbotContextRef.current;
7092
7153
  dispatch(smartBotActions.setChatbotContext({
7093
- ...chatbotContext,
7154
+ ...ctx3,
7094
7155
  [bodyText?.paramName]: {
7095
- ...chatbotContext?.[bodyText?.paramName],
7156
+ ...ctx3?.[bodyText?.paramName],
7096
7157
  [bodyText?.paramName]: [],
7097
7158
  updated: true,
7098
7159
  },
@@ -7114,6 +7175,8 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
7114
7175
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7115
7176
  const { displayFormat, label, isRequired, labelOrientation, placeholder, minDate, maxDate, isDisabled, minStartDate, } = bodyText;
7116
7177
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7178
+ const chatbotContextRef = React.useRef(chatbotContext);
7179
+ chatbotContextRef.current = chatbotContext;
7117
7180
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7118
7181
  const dispatch = reactRedux.useDispatch();
7119
7182
  const [selectedDate, setSelectedDate] = React.useState(persistedFormValues[formKey] || null);
@@ -7122,10 +7185,11 @@ const DatePickerContent = ({ bodyText, isFormDisabled = false, messageIndex }) =
7122
7185
  const handleDateChange = (date) => {
7123
7186
  try {
7124
7187
  setSelectedDate(date);
7188
+ const latestContext = chatbotContextRef.current;
7125
7189
  dispatch(smartBotActions.setChatbotContext({
7126
- ...chatbotContext,
7190
+ ...latestContext,
7127
7191
  [bodyText?.paramName]: {
7128
- ...chatbotContext?.[bodyText?.paramName],
7192
+ ...latestContext?.[bodyText?.paramName],
7129
7193
  [bodyText?.paramName]: moment(date).format(displayFormat),
7130
7194
  updated: true,
7131
7195
  },
@@ -7153,6 +7217,8 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
7153
7217
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7154
7218
  const { displayFormat, label, isRequired, labelOrientation, minDate, maxDate, isDisabled, showMonthYearSelect, minStartDate, } = bodyText;
7155
7219
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7220
+ const chatbotContextRef = React.useRef(chatbotContext);
7221
+ chatbotContextRef.current = chatbotContext;
7156
7222
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7157
7223
  const dispatch = reactRedux.useDispatch();
7158
7224
  const [startDate, setStartDate] = React.useState(persistedFormValues[formKey]?.startDate || null);
@@ -7163,10 +7229,11 @@ const DateRangePickerContent = ({ bodyText, isFormDisabled = false, messageIndex
7163
7229
  try {
7164
7230
  setStartDate(start);
7165
7231
  setEndDate(end);
7232
+ const latestContext = chatbotContextRef.current;
7166
7233
  dispatch(smartBotActions.setChatbotContext({
7167
- ...chatbotContext,
7234
+ ...latestContext,
7168
7235
  [bodyText?.paramName]: {
7169
- ...chatbotContext?.[bodyText?.paramName],
7236
+ ...latestContext?.[bodyText?.paramName],
7170
7237
  [bodyText?.paramName]: {
7171
7238
  startDate: start ? moment(start).format(displayFormat) : null,
7172
7239
  endDate: end ? moment(end).format(displayFormat) : null,
@@ -7201,6 +7268,8 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
7201
7268
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7202
7269
  const { label, checked: checkedValue, required, disabled, } = bodyText;
7203
7270
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7271
+ const chatbotContextRef = React.useRef(chatbotContext);
7272
+ chatbotContextRef.current = chatbotContext;
7204
7273
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7205
7274
  const dispatch = reactRedux.useDispatch();
7206
7275
  const [checked, setChecked] = React.useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : checkedValue);
@@ -7209,15 +7278,11 @@ const CheckboxContent = ({ bodyText, isFormDisabled = false, messageIndex }) =>
7209
7278
  const handleChange = (isChecked) => {
7210
7279
  try {
7211
7280
  setChecked(isChecked?.currentTarget?.checked);
7212
- // chatbotContext.checkbox = {
7213
- // ...chatbotContext?.checkbox,
7214
- // [bodyText?.paramName]: isChecked?.currentTarget?.checked,
7215
- // updated: true
7216
- // };
7281
+ const latestContext = chatbotContextRef.current;
7217
7282
  dispatch(smartBotActions.setChatbotContext({
7218
- ...chatbotContext,
7283
+ ...latestContext,
7219
7284
  [bodyText?.paramName]: {
7220
- ...chatbotContext?.[bodyText?.paramName],
7285
+ ...latestContext?.[bodyText?.paramName],
7221
7286
  [bodyText?.paramName]: isChecked?.currentTarget?.checked,
7222
7287
  updated: true,
7223
7288
  },
@@ -7236,6 +7301,8 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7236
7301
  const classes = useStyles$a();
7237
7302
  const { label, isDisabled, orientation, options } = bodyText;
7238
7303
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7304
+ const chatbotContextRef = React.useRef(chatbotContext);
7305
+ chatbotContextRef.current = chatbotContext;
7239
7306
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7240
7307
  const dispatch = reactRedux.useDispatch();
7241
7308
  const [selectedOption, setSelectedOption] = React.useState(persistedFormValues[formKey] ?? null);
@@ -7250,10 +7317,11 @@ const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7250
7317
  // [bodyText?.paramName]: value,
7251
7318
  // updated: true,
7252
7319
  // };
7320
+ const latestContext = chatbotContextRef.current;
7253
7321
  dispatch(smartBotActions.setChatbotContext({
7254
- ...chatbotContext,
7322
+ ...latestContext,
7255
7323
  [bodyText?.paramName]: {
7256
- ...chatbotContext?.[bodyText?.paramName],
7324
+ ...latestContext?.[bodyText?.paramName],
7257
7325
  [bodyText?.paramName]: value,
7258
7326
  updated: true,
7259
7327
  },
@@ -7271,6 +7339,8 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7271
7339
  const formKey = `${messageIndex}_${bodyText?.paramName}`;
7272
7340
  const { label, placeholder, isRequired, isDisabled, inputType, labelOrientation, defaultValue, maxLength, minLength, } = bodyText;
7273
7341
  const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
7342
+ const chatbotContextRef = React.useRef(chatbotContext);
7343
+ chatbotContextRef.current = chatbotContext;
7274
7344
  const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
7275
7345
  const dispatch = reactRedux.useDispatch();
7276
7346
  const [value, setValue] = React.useState(persistedFormValues[formKey] !== undefined ? persistedFormValues[formKey] : (defaultValue || ""));
@@ -7280,10 +7350,11 @@ const InputContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
7280
7350
  try {
7281
7351
  const newValue = event?.target?.value || event?.currentTarget?.value || "";
7282
7352
  setValue(newValue);
7353
+ const latestContext = chatbotContextRef.current;
7283
7354
  dispatch(smartBotActions.setChatbotContext({
7284
- ...chatbotContext,
7355
+ ...latestContext,
7285
7356
  [bodyText?.paramName]: {
7286
- ...chatbotContext?.[bodyText?.paramName],
7357
+ ...latestContext?.[bodyText?.paramName],
7287
7358
  [bodyText?.paramName]: replaceSpecialCharToCharCode(newValue),
7288
7359
  updated: true,
7289
7360
  type: inputType,
@@ -7579,6 +7650,15 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7579
7650
  });
7580
7651
  return selections;
7581
7652
  }, [crossFilterConfigs, chatbotContext, persistedFormValues, messageIndex]);
7653
+ // Extract the param names of the current form's fields so ButtonContent
7654
+ // can restrict user_input to only these keys (avoids leaking stale context).
7655
+ const formParamNames = React.useMemo(() => {
7656
+ if (!formData || !Array.isArray(formData))
7657
+ return [];
7658
+ return formData
7659
+ .filter((item) => item?.type !== "button" && item?.data?.param_name)
7660
+ .map((item) => item.data.param_name);
7661
+ }, [formData]);
7582
7662
  if (!formData || !Array.isArray(formData) || formData.length === 0) {
7583
7663
  return null;
7584
7664
  }
@@ -7606,7 +7686,7 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
7606
7686
  case "radio":
7607
7687
  return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7608
7688
  case "button":
7609
- return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled }, key);
7689
+ return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled, formParamNames: formParamNames, messageIndex: messageIndex }, key);
7610
7690
  case "input":
7611
7691
  return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
7612
7692
  case "image":
@@ -10575,10 +10655,18 @@ const resetActiveTabularInstance = () => {
10575
10655
  };
10576
10656
 
10577
10657
  const CombinedContent = ({ botData, props }) => {
10658
+ const classes = useStyles$a();
10578
10659
  const isFormDisabled = botData?.isFormDisabled || false;
10579
10660
  const isTabEnabled = botData?.utilityData?.isTabEnabled;
10580
10661
  // Get the array of content items from bodyText
10581
10662
  const contentItems = Array.isArray(botData.bodyText) ? botData.bodyText : [];
10663
+ // Renders the optional block-level header title above a content item
10664
+ const renderHeaderTitle = (parsedData) => {
10665
+ const showHeaderTitle = !parsedData?.noShowHeaderTitle && Boolean(parsedData?.headerTitle?.length);
10666
+ if (!showHeaderTitle)
10667
+ return null;
10668
+ return (jsxRuntime.jsx("div", { className: `${classes.chatbotText} ${classes.boldText} ${classes.combinedBlockHeaderTitle}`, children: parsedData.headerTitle }));
10669
+ };
10582
10670
  // Function to render individual content based on its type
10583
10671
  const renderIndividualContent = (parsedData, index) => {
10584
10672
  const key = `combined-content-${index}`;
@@ -10631,8 +10719,8 @@ const CombinedContent = ({ botData, props }) => {
10631
10719
  if (!parsedData) {
10632
10720
  return null;
10633
10721
  }
10634
- // Render the parsed content
10635
- return renderIndividualContent(parsedData, index);
10722
+ // Render the parsed content, preceded by the block's header title when present
10723
+ return (jsxRuntime.jsxs(React.Fragment, { children: [renderHeaderTitle(parsedData), renderIndividualContent(parsedData, index)] }, `combined-block-${index}`));
10636
10724
  }
10637
10725
  catch (error) {
10638
10726
  console.error(`Error parsing combined content item at index ${index}:`, error);
@@ -14843,7 +14931,7 @@ const SmartBot = (props) => {
14843
14931
  const [chatBotWidth, setChatBotWidth] = React.useState(null);
14844
14932
  const [tabList, setTabList] = React.useState([]);
14845
14933
  React.useRef(0);
14846
- 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);
14934
+ 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);
14847
14935
  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);
14848
14936
  const { refreshAndUpdateUserManual, configureBotActions, displaySnackMessages, } = useBotConfiguration(setRefreshLoader, setEnableRefreshAction, dispatch);
14849
14937
  const { prepareDataAndSendToAgent, processResponse } = useAgentFlow(dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, baseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, {