impact-chatbot 2.3.102 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/allocation-detail-panel/AllocationDetailPanel.d.ts +2 -0
- package/dist/components/allocation-detail-panel/AllocationPlanCard.d.ts +4 -0
- package/dist/components/allocation-detail-panel/components/PanelHeader.d.ts +8 -0
- package/dist/components/allocation-detail-panel/components/PanelSection.d.ts +4 -0
- package/dist/components/allocation-detail-panel/components/ReportSummaryCard.d.ts +4 -0
- package/dist/components/allocation-detail-panel/components/StructuredComparison.d.ts +4 -0
- package/dist/components/allocation-detail-panel/styles.d.ts +1 -0
- package/dist/components/message-template/components/message-content/SurfaceFrameContent.d.ts +37 -0
- package/dist/components/message-template/components/message-content/surfaceWidgets.d.ts +22 -0
- package/dist/index.cjs.js +989 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +990 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chatbot-services.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -23,7 +23,7 @@ import { setSelectedFilters, setFilterConfiguration, getFilterUserConfiguration
|
|
|
23
23
|
import { setThinkingContext, setChatbotContext, setStepFormStreamData, setMinimizedStreamData, setPersistedFormValues, setCurrentAgentChatId, clearPersistedFormValues, setHierarchyKeyValue, setChatbotFilterOptions, setSavedFilterSets } from 'core/actions/smartBotActions';
|
|
24
24
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
25
25
|
import styled from 'styled-components';
|
|
26
|
-
import { CircularProgress, Typography, Grid } from '@mui/material';
|
|
26
|
+
import { CircularProgress, Typography, Grid, Box, IconButton, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
|
|
27
27
|
import { fetchBaseUrl, pxToRem as pxToRem$1, replaceSpecialCharacter as replaceSpecialCharacter$1, fetchLegacyAgentScreen } from 'core/Utils/functions/utils';
|
|
28
28
|
import { Button, Modal, Slider, Select, DatePicker, DateRangePicker, Checkbox, RadioButtonGroup, Input, Tabs, Loader, Prompt, Tooltip, ChatBotComponent } from 'impact-ui-v3';
|
|
29
29
|
import isArray$2 from 'lodash/isArray';
|
|
@@ -35,6 +35,8 @@ import agGridColumnFormatter from 'core/Utils/agGridV36/columnFormatter';
|
|
|
35
35
|
import CoreChart from 'core/Utils/core-charts';
|
|
36
36
|
import makeStyles$1 from '@mui/styles/makeStyles';
|
|
37
37
|
import ChevronRightIcon$1 from '@mui/icons-material/ChevronRight';
|
|
38
|
+
import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined';
|
|
39
|
+
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
|
38
40
|
import FormatListBulletedOutlinedIcon from '@mui/icons-material/FormatListBulletedOutlined';
|
|
39
41
|
import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined';
|
|
40
42
|
import colours$1 from 'core/Styles/colours';
|
|
@@ -43,6 +45,13 @@ import RangePicker from 'core/commonComponents/dateRangePicker';
|
|
|
43
45
|
import NoFilterSetSavedIcon from 'core/coreAssets/chatbot/noFilterSetSaved.svg';
|
|
44
46
|
import CoreComponentScreen from 'core/commonComponents/coreComponentScreen';
|
|
45
47
|
import { fetchFilterFieldValues, formattedFilterConfiguration } from 'core/commonComponents/coreComponentScreen/utils';
|
|
48
|
+
import { createPortal } from 'react-dom';
|
|
49
|
+
import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
|
|
50
|
+
import OpenInFullIcon from '@mui/icons-material/OpenInFull';
|
|
51
|
+
import CloseFullscreenIcon from '@mui/icons-material/CloseFullscreen';
|
|
52
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
53
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
54
|
+
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
|
|
46
55
|
import { getApplicationCodeFromURL } from 'core/Utils/utils';
|
|
47
56
|
|
|
48
57
|
/**
|
|
@@ -285,6 +294,21 @@ const getTableRecords = async (payload, baseUrl, tableName) => {
|
|
|
285
294
|
return null;
|
|
286
295
|
}
|
|
287
296
|
};
|
|
297
|
+
/** A read for a generated surface (frame protocol iui:query): the agent runs one read tool as the signed-in
|
|
298
|
+
* user and answers {rows, total}. */
|
|
299
|
+
const postUiQuery = async (payload, baseUrl) => {
|
|
300
|
+
try {
|
|
301
|
+
return axiosInstance({
|
|
302
|
+
url: `${baseUrl}/chatbot/agent/ui-query`,
|
|
303
|
+
method: 'POST',
|
|
304
|
+
data: payload,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
console.error('postUiQuery error:', error);
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
288
312
|
const getTableRecordsByUrl = async (payload, url) => {
|
|
289
313
|
try {
|
|
290
314
|
return axiosInstance({
|
|
@@ -841,6 +865,17 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
841
865
|
bodyType: "html",
|
|
842
866
|
bodyText: { content: data?.data?.content || "" },
|
|
843
867
|
};
|
|
868
|
+
case "allocation_plan_card":
|
|
869
|
+
return {
|
|
870
|
+
...data,
|
|
871
|
+
timeStamp: timeString,
|
|
872
|
+
userType: "bot",
|
|
873
|
+
userName: userName,
|
|
874
|
+
headerTitle: "",
|
|
875
|
+
noShowHeaderTitle: true,
|
|
876
|
+
bodyType: "allocation_plan_card",
|
|
877
|
+
bodyText: data?.data || data,
|
|
878
|
+
};
|
|
844
879
|
case "image":
|
|
845
880
|
return {
|
|
846
881
|
...data,
|
|
@@ -868,6 +903,18 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
868
903
|
thinkingResponse: utilityObject?.thinkingResponse,
|
|
869
904
|
enableLikes: true
|
|
870
905
|
};
|
|
906
|
+
case "surface_frame":
|
|
907
|
+
// A generated UI surface drawn by the UI service's renderer page (Impact UI 5), which SurfaceFrameContent embeds
|
|
908
|
+
return {
|
|
909
|
+
...data,
|
|
910
|
+
agentId: agentId,
|
|
911
|
+
timeStamp: timeString,
|
|
912
|
+
userType: "bot",
|
|
913
|
+
userName: userName,
|
|
914
|
+
headerTitle: data?.data?.surface?.title || "",
|
|
915
|
+
bodyType: "surface_frame",
|
|
916
|
+
bodyText: data?.data,
|
|
917
|
+
};
|
|
871
918
|
default:
|
|
872
919
|
return null;
|
|
873
920
|
}
|
|
@@ -2399,6 +2446,10 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
2399
2446
|
answer_mode: data?.answerMode || "auto",
|
|
2400
2447
|
...(!isEmpty(utilityObjectData?.additionalArgs) ? utilityObjectData.additionalArgs : {}),
|
|
2401
2448
|
};
|
|
2449
|
+
if (data?.uiContext && typeof data.uiContext === "object") {
|
|
2450
|
+
// a follow-up asked from a generated surface: which surface, and its input values
|
|
2451
|
+
payload.ui_context = data.uiContext;
|
|
2452
|
+
}
|
|
2402
2453
|
// Handle @ filter mentions - user_explicit_input contains filter values
|
|
2403
2454
|
if (!isEmpty(data?.userExplicitInput)) {
|
|
2404
2455
|
payload.user_explicit_input = data?.userExplicitInput;
|
|
@@ -5546,6 +5597,73 @@ const QuestionsContent = ({ bodyText, props }) => {
|
|
|
5546
5597
|
}) }));
|
|
5547
5598
|
};
|
|
5548
5599
|
|
|
5600
|
+
/**
|
|
5601
|
+
* One widget per generated surface in a stream: the agent may send a surface more than once (a placeholder
|
|
5602
|
+
* while it is composed, `status: "pending"`, version 0; then the surface, version 1; or its withdrawal), and
|
|
5603
|
+
* frame protocol 1 replaces a surface by its id (agent-ui-service-ssr docs/chat-frame-widget.md, rule 4).
|
|
5604
|
+
* No imports: the stream reader (AxiosEventSource) uses it too. Ported from core's smartBot
|
|
5605
|
+
* (insideinsight/core feat/iui-surface, e386f8f0).
|
|
5606
|
+
*/
|
|
5607
|
+
/** A surface's version; one when it gives none. */
|
|
5608
|
+
const surfaceVersion = (surface) => (Number.isFinite(surface?.version) ? surface.version : 1);
|
|
5609
|
+
const surfaceIdOf = (widget) => (widget?.type === "surface_frame" ? widget?.data?.surface?.id : undefined);
|
|
5610
|
+
/** A stream's widgets with these added: a surface_frame widget whose surface the list already holds replaces
|
|
5611
|
+
* it in place (a lower version is dropped); any other widget is added at the end. */
|
|
5612
|
+
const mergeSurfaceWidgets = (previous, incoming) => {
|
|
5613
|
+
const merged = Array.isArray(previous) ? previous.slice() : previous ? [previous] : [];
|
|
5614
|
+
for (const widget of Array.isArray(incoming) ? incoming : [incoming]) {
|
|
5615
|
+
const id = surfaceIdOf(widget);
|
|
5616
|
+
const at = id === undefined ? -1 : merged.findIndex((w) => surfaceIdOf(w) === id);
|
|
5617
|
+
if (at < 0)
|
|
5618
|
+
merged.push(widget);
|
|
5619
|
+
else if (surfaceVersion(widget.data.surface) >= surfaceVersion(merged[at].data.surface))
|
|
5620
|
+
merged[at] = widget;
|
|
5621
|
+
}
|
|
5622
|
+
return merged;
|
|
5623
|
+
};
|
|
5624
|
+
/*
|
|
5625
|
+
* Across the chat's messages (one page per surface): a surface revised in a later turn is shown, newest
|
|
5626
|
+
* version, where that turn put it; each earlier widget of it collapses to a line. Every SurfaceFrameContent
|
|
5627
|
+
* says which version it shows; a widget whose surface another widget shows in a higher version collapses.
|
|
5628
|
+
* Placeholders and withdrawn surfaces take no part. Equal versions (the same surface drawn in two places)
|
|
5629
|
+
* both show.
|
|
5630
|
+
*/
|
|
5631
|
+
const shownVersions = new Map(); // surface id -> Map(widget token -> version)
|
|
5632
|
+
const watchers = new Set();
|
|
5633
|
+
let lastToken = 0;
|
|
5634
|
+
/** A token for one widget. */
|
|
5635
|
+
const surfaceToken = () => {
|
|
5636
|
+
lastToken += 1;
|
|
5637
|
+
return lastToken;
|
|
5638
|
+
};
|
|
5639
|
+
const notify = () => watchers.forEach((watch) => watch());
|
|
5640
|
+
/** This widget shows `version` of surface `id`. */
|
|
5641
|
+
const showSurface = (id, token, version) => {
|
|
5642
|
+
if (!shownVersions.has(id))
|
|
5643
|
+
shownVersions.set(id, new Map());
|
|
5644
|
+
shownVersions.get(id).set(token, version);
|
|
5645
|
+
notify();
|
|
5646
|
+
};
|
|
5647
|
+
/** This widget no longer shows surface `id`. */
|
|
5648
|
+
const hideSurface = (id, token) => {
|
|
5649
|
+
const versions = shownVersions.get(id);
|
|
5650
|
+
if (!versions)
|
|
5651
|
+
return;
|
|
5652
|
+
versions.delete(token);
|
|
5653
|
+
if (versions.size === 0)
|
|
5654
|
+
shownVersions.delete(id);
|
|
5655
|
+
notify();
|
|
5656
|
+
};
|
|
5657
|
+
/** Whether another widget shows surface `id` in a version higher than `version`. */
|
|
5658
|
+
const newerShown = (id, version) => [...(shownVersions.get(id)?.values() ?? [])].some((v) => v > version);
|
|
5659
|
+
/** Calls `watch` whenever a widget starts or stops showing a surface; returns the unsubscribe. */
|
|
5660
|
+
const watchSurfaces = (watch) => {
|
|
5661
|
+
watchers.add(watch);
|
|
5662
|
+
return () => {
|
|
5663
|
+
watchers.delete(watch);
|
|
5664
|
+
};
|
|
5665
|
+
};
|
|
5666
|
+
|
|
5549
5667
|
// Utility: check whether a string is a likely complete JSON value
|
|
5550
5668
|
const isLikelyCompleteJson = (message) => {
|
|
5551
5669
|
try {
|
|
@@ -5753,10 +5871,8 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5753
5871
|
let previousWidgetData = isArray$1(messageToStoreRef.current.appendedData)
|
|
5754
5872
|
? messageToStoreRef.current.appendedData
|
|
5755
5873
|
: [messageToStoreRef.current.appendedData];
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
...finalWidgetData,
|
|
5759
|
-
];
|
|
5874
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
5875
|
+
messageToStoreRef.current.appendedData = mergeSurfaceWidgets(previousWidgetData, finalWidgetData);
|
|
5760
5876
|
messageToStoreRef.current.sessionId = parsedData.session_id;
|
|
5761
5877
|
messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
|
|
5762
5878
|
? parsedData.chat_id
|
|
@@ -5796,10 +5912,8 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5796
5912
|
let previousWidgetData = isArray$1(messageToStoreRef.current.appendedData)
|
|
5797
5913
|
? messageToStoreRef.current.appendedData
|
|
5798
5914
|
: [messageToStoreRef.current.appendedData];
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
...finalWidgetData,
|
|
5802
|
-
];
|
|
5915
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
5916
|
+
messageToStoreRef.current.appendedData = mergeSurfaceWidgets(previousWidgetData, finalWidgetData);
|
|
5803
5917
|
messageToStoreRef.current.additionalArgs = parsedData?.additional_args
|
|
5804
5918
|
? parsedData.additional_args
|
|
5805
5919
|
: {};
|
|
@@ -7990,6 +8104,183 @@ const ImageContent = ({ bodyText }) => {
|
|
|
7990
8104
|
} })), caption && (jsx("div", { children: jsx(TextRenderer, { text: caption }) }))] }));
|
|
7991
8105
|
};
|
|
7992
8106
|
|
|
8107
|
+
const SUBMIT = { buttons: [{ label: "Submit", variant: "primary" }] };
|
|
8108
|
+
/** A follow-up's limits: longer ones are ignored. */
|
|
8109
|
+
const PROMPT_TEXT_MAX = 1000;
|
|
8110
|
+
const PROMPT_CONTEXT_MAX = 16000;
|
|
8111
|
+
/** The window event the chat listens to for a follow-up asked from a surface. */
|
|
8112
|
+
const PROMPT_EVENT = "iris:prompt";
|
|
8113
|
+
/** The source a surface names for this temp table, if it names it: the only tables its page may ask pages
|
|
8114
|
+
* of, and the endpoint address the agent gave (the page's own copy of the source is not trusted for it). */
|
|
8115
|
+
const sourceOf = (surface, table) => Object.values(surface?.data || {}).map((entry) => entry?.source).find((source) => typeof source?.table === "string" && source.table === table);
|
|
8116
|
+
/** Whether the surface binds this tool: the only tools its page may ask to read again. */
|
|
8117
|
+
const bindsTool = (surface, tool) => typeof tool === "string" && tool !== "rows" && Object.values(surface?.data || {}).some((entry) => entry?.tool === tool);
|
|
8118
|
+
const baseUrl = () => sessionStorage.getItem("stepForm_baseUrl") || "";
|
|
8119
|
+
/** One page of a source, from the agent's paging endpoint (its pages hold at most 10 rows): at the address
|
|
8120
|
+
* the agent gave, as TableContent does with temp_table_url, else under the stream's base URL. `search`: a
|
|
8121
|
+
* filter Control over the kept rows (catalog 0.3), each `{field, value}` an exact match the endpoint applies. */
|
|
8122
|
+
const pageOf = async ({ source, page, pageSize, sort, search }) => {
|
|
8123
|
+
const payload = {
|
|
8124
|
+
limit: { page, page_size: pageSize },
|
|
8125
|
+
search: (Array.isArray(search) ? search : [])
|
|
8126
|
+
.filter((s) => s && typeof s.field === "string" && s.value !== undefined && s.value !== null)
|
|
8127
|
+
.slice(0, 5)
|
|
8128
|
+
.map((s) => ({ column: s.field, pattern: String(s.value), search_type: "equals" })),
|
|
8129
|
+
sort: (Array.isArray(sort) ? sort : []).map((s) => ({ column: s.field, order: s.order === "desc" ? "desc" : "asc" })),
|
|
8130
|
+
};
|
|
8131
|
+
const response = source.url
|
|
8132
|
+
? await getTableRecordsByUrl(payload, source.url)
|
|
8133
|
+
: await getTableRecords(payload, baseUrl(), source.table);
|
|
8134
|
+
const rows = response?.data?.data;
|
|
8135
|
+
const total = response?.data?.total_count;
|
|
8136
|
+
if (!Array.isArray(rows) || !Number.isFinite(total))
|
|
8137
|
+
throw new Error("no rows");
|
|
8138
|
+
return { rows, total };
|
|
8139
|
+
};
|
|
8140
|
+
/** A read tool the surface binds, run again by the agent with these arguments. */
|
|
8141
|
+
const readOf = async ({ surface, tool, args }) => {
|
|
8142
|
+
const response = await postUiQuery({ surface, tool, args: args && typeof args === "object" ? args : {} }, baseUrl());
|
|
8143
|
+
const rows = response?.data?.rows;
|
|
8144
|
+
const total = response?.data?.total;
|
|
8145
|
+
if (!Array.isArray(rows) || !Number.isFinite(total))
|
|
8146
|
+
throw new Error(response?.data?.error || "no rows");
|
|
8147
|
+
return { rows, total };
|
|
8148
|
+
};
|
|
8149
|
+
/** The page's origin, for http(s) addresses only; anything else is refused. */
|
|
8150
|
+
const frameOrigin = (src) => {
|
|
8151
|
+
try {
|
|
8152
|
+
const url = new URL(src, window.location.href);
|
|
8153
|
+
return url.protocol === "https:" || url.protocol === "http:" ? url.origin : null;
|
|
8154
|
+
}
|
|
8155
|
+
catch {
|
|
8156
|
+
return null;
|
|
8157
|
+
}
|
|
8158
|
+
};
|
|
8159
|
+
/** A follow-up within the limits, or null. */
|
|
8160
|
+
const promptOf = (data, surfaceId) => {
|
|
8161
|
+
const text = typeof data?.text === "string" ? data.text.trim() : "";
|
|
8162
|
+
const context = data?.context && typeof data.context === "object" ? { ...data.context, surface: surfaceId } : { surface: surfaceId };
|
|
8163
|
+
let size = Infinity;
|
|
8164
|
+
try {
|
|
8165
|
+
size = JSON.stringify(context).length;
|
|
8166
|
+
}
|
|
8167
|
+
catch {
|
|
8168
|
+
// a context that cannot be sent is not sent
|
|
8169
|
+
}
|
|
8170
|
+
if (!text || text.length > PROMPT_TEXT_MAX || size > PROMPT_CONTEXT_MAX)
|
|
8171
|
+
return null;
|
|
8172
|
+
return { text, uiContext: context };
|
|
8173
|
+
};
|
|
8174
|
+
const SurfaceFrameContent = ({ frame, isFormDisabled = false, messageIndex = 0 }) => {
|
|
8175
|
+
const dispatch = useDispatch();
|
|
8176
|
+
const chatbotContext = useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
8177
|
+
const contextRef = useRef(chatbotContext);
|
|
8178
|
+
contextRef.current = chatbotContext;
|
|
8179
|
+
const iframeRef = useRef(null);
|
|
8180
|
+
const ready = useRef(false);
|
|
8181
|
+
const [height, setHeight] = useState(120);
|
|
8182
|
+
const [form, setForm] = useState({ values: {}, inputs: [], missing: [] });
|
|
8183
|
+
const formRef = useRef(form);
|
|
8184
|
+
formRef.current = form;
|
|
8185
|
+
const src = frame?.src;
|
|
8186
|
+
const incoming = frame?.surface;
|
|
8187
|
+
// the surface shown: a newer version of the same surface replaces it, a lower one is ignored
|
|
8188
|
+
const [surface, setSurface] = useState(incoming);
|
|
8189
|
+
useEffect(() => {
|
|
8190
|
+
if (incoming && (!surface || incoming.id !== surface.id || surfaceVersion(incoming) >= surfaceVersion(surface)))
|
|
8191
|
+
setSurface(incoming);
|
|
8192
|
+
}, [incoming]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8193
|
+
const origin = useMemo(() => frameOrigin(src), [src]);
|
|
8194
|
+
const ask = surface?.mode === "ask";
|
|
8195
|
+
// which version of its surface each widget shows, across the chat's messages
|
|
8196
|
+
const token = useRef(null);
|
|
8197
|
+
if (token.current === null)
|
|
8198
|
+
token.current = surfaceToken();
|
|
8199
|
+
const [, setShownChange] = useState(0);
|
|
8200
|
+
useEffect(() => watchSurfaces(() => setShownChange((n) => n + 1)), []);
|
|
8201
|
+
useEffect(() => {
|
|
8202
|
+
if (!surface?.id || surface.status === "pending" || surface.status === "withdrawn")
|
|
8203
|
+
return undefined;
|
|
8204
|
+
showSurface(surface.id, token.current, surfaceVersion(surface));
|
|
8205
|
+
return () => hideSurface(surface.id, token.current);
|
|
8206
|
+
}, [surface?.id, surface?.version, surface?.status]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8207
|
+
const send = (target, values) => target?.postMessage({ type: "iui:surface", surface, values, disabled: Boolean(isFormDisabled), query: true, ...(ask ? { submit: false } : {}) }, origin);
|
|
8208
|
+
useEffect(() => {
|
|
8209
|
+
if (!origin || !surface)
|
|
8210
|
+
return undefined;
|
|
8211
|
+
const onMessage = (event) => {
|
|
8212
|
+
const target = iframeRef.current?.contentWindow;
|
|
8213
|
+
if (!target || event.source !== target || event.origin !== origin)
|
|
8214
|
+
return;
|
|
8215
|
+
const data = event.data || {};
|
|
8216
|
+
// every message but iui:ready and iui:height names its surface: this widget answers for its own only
|
|
8217
|
+
const own = data.surface === undefined || data.surface === surface.id;
|
|
8218
|
+
if (data.type === "iui:ready") {
|
|
8219
|
+
ready.current = true;
|
|
8220
|
+
send(target, undefined);
|
|
8221
|
+
}
|
|
8222
|
+
else if (data.type === "iui:height" && Number.isFinite(data.height))
|
|
8223
|
+
setHeight(Math.max(40, Math.ceil(data.height)));
|
|
8224
|
+
else if (data.type === "iui:query" && own) {
|
|
8225
|
+
const reply = (body) => target.postMessage({ type: "iui:data", surface: surface.id, id: data.id, ...body }, origin);
|
|
8226
|
+
const args = data.args || {};
|
|
8227
|
+
if (data.tool === "rows") {
|
|
8228
|
+
const source = sourceOf(surface, args.source?.table);
|
|
8229
|
+
if (!source)
|
|
8230
|
+
reply({ error: "not a table of this answer" });
|
|
8231
|
+
else
|
|
8232
|
+
pageOf({ ...args, source }).then(reply, () => reply({ error: "the rows could not be loaded" }));
|
|
8233
|
+
}
|
|
8234
|
+
else if (bindsTool(surface, data.tool)) {
|
|
8235
|
+
readOf({ surface: surface.id, tool: data.tool, args }).then(reply, () => reply({ error: "the data could not be loaded" }));
|
|
8236
|
+
}
|
|
8237
|
+
else
|
|
8238
|
+
reply({ error: "not a tool of this answer" });
|
|
8239
|
+
}
|
|
8240
|
+
else if (data.type === "iui:prompt" && data.surface === surface.id) {
|
|
8241
|
+
const prompt = promptOf(data, surface.id);
|
|
8242
|
+
if (prompt)
|
|
8243
|
+
window.dispatchEvent(new CustomEvent(PROMPT_EVENT, { detail: prompt }));
|
|
8244
|
+
}
|
|
8245
|
+
else if (data.type === "iui:change" && ask && own) {
|
|
8246
|
+
const values = data.values || {};
|
|
8247
|
+
setForm({ values, inputs: Array.isArray(data.inputs) ? data.inputs : Object.keys(values), missing: Array.isArray(data.missing) ? data.missing : [] });
|
|
8248
|
+
// as this chat's own inputs record their values, for the step form's Submit (ButtonContent)
|
|
8249
|
+
const context = { ...contextRef.current };
|
|
8250
|
+
for (const [name, value] of Object.entries(values)) {
|
|
8251
|
+
const empty = value === "" || value === null || value === undefined || (Array.isArray(value) && value.length === 0);
|
|
8252
|
+
context[name] = { ...context[name], [name]: value, updated: !empty };
|
|
8253
|
+
}
|
|
8254
|
+
dispatch(setChatbotContext(context));
|
|
8255
|
+
// only what was filled in: ButtonContent sends a persisted value even when it is empty
|
|
8256
|
+
const filled = Object.entries(values).filter(([name]) => context[name].updated);
|
|
8257
|
+
dispatch(setPersistedFormValues(Object.fromEntries(filled.map(([name, value]) => [`${messageIndex}_${name}`, value]))));
|
|
8258
|
+
}
|
|
8259
|
+
// anything else: a message type this chat does not know, ignored
|
|
8260
|
+
};
|
|
8261
|
+
window.addEventListener("message", onMessage);
|
|
8262
|
+
return () => window.removeEventListener("message", onMessage);
|
|
8263
|
+
}, [origin, surface, isFormDisabled, ask, messageIndex]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8264
|
+
// a newer version of the surface goes into the page that shows it
|
|
8265
|
+
useEffect(() => {
|
|
8266
|
+
if (ready.current)
|
|
8267
|
+
send(iframeRef.current?.contentWindow, undefined);
|
|
8268
|
+
}, [surface]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8269
|
+
// a submitted form is posted again, disabled, with what was filled in
|
|
8270
|
+
useEffect(() => {
|
|
8271
|
+
if (isFormDisabled && ask)
|
|
8272
|
+
send(iframeRef.current?.contentWindow, formRef.current.values);
|
|
8273
|
+
}, [isFormDisabled]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
8274
|
+
// a surface that will not come after all (its composition failed): nothing to draw
|
|
8275
|
+
if (!origin || !surface || surface.status === "withdrawn")
|
|
8276
|
+
return null;
|
|
8277
|
+
// a later message shows this surface revised: one line here, the surface there
|
|
8278
|
+
if (newerShown(surface.id, surfaceVersion(surface))) {
|
|
8279
|
+
return (jsx(Box, { "data-iui-host": "surface-frame", "data-iui-superseded": surface.id, my: 1, sx: { fontSize: 13, color: "text.secondary" }, children: `Revised below${surface.title ? `: ${surface.title}` : ""}.` }));
|
|
8280
|
+
}
|
|
8281
|
+
return (jsxs(Box, { "data-iui-host": "surface-frame", my: 1, children: [jsx("iframe", { ref: iframeRef, src: src, title: surface.title || "Generated answer", sandbox: "allow-scripts allow-same-origin", referrerPolicy: "no-referrer", style: { width: "100%", height, border: 0, display: "block" } }), ask ? (jsx(ButtonContent, { bodyText: SUBMIT, isFormDisabled: isFormDisabled, isStepFormSubmit: true, isFormValid: form.inputs.length > 0 && form.missing.length === 0, formParamNames: form.inputs, messageIndex: messageIndex })) : null] }));
|
|
8282
|
+
};
|
|
8283
|
+
|
|
7993
8284
|
// Key used to persist timeout state in sessionStorage (survives component remounts from tab switches)
|
|
7994
8285
|
const STEP_FORM_TIMEOUT_KEY = "__stepFormTimedOut";
|
|
7995
8286
|
/**
|
|
@@ -8417,11 +8708,17 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
8417
8708
|
case "radio":
|
|
8418
8709
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
8419
8710
|
case "button":
|
|
8711
|
+
// A form in the renderer page has its Submit drawn by SurfaceFrameContent, which knows the page's inputs
|
|
8712
|
+
if (formData.some((item) => item?.type === "surface_frame"))
|
|
8713
|
+
return null;
|
|
8420
8714
|
return jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled && checkboxGroupsValid, formParamNames: formParamNames, messageIndex: messageIndex }, key);
|
|
8421
8715
|
case "input":
|
|
8422
8716
|
return jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
8423
8717
|
case "image":
|
|
8424
8718
|
return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
8719
|
+
case "surface_frame":
|
|
8720
|
+
// The whole form in the renderer page; the widget draws this form's Submit (its inputs are in the page)
|
|
8721
|
+
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, messageIndex: messageIndex }, parsedData.bodyText?.surface?.id || key);
|
|
8425
8722
|
default:
|
|
8426
8723
|
return null;
|
|
8427
8724
|
}
|
|
@@ -8938,6 +9235,479 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
|
|
|
8938
9235
|
}, children: jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
|
|
8939
9236
|
};
|
|
8940
9237
|
|
|
9238
|
+
const useAllocationPanelStyles = makeStyles((theme) => ({
|
|
9239
|
+
// AllocationPlanCard styles (inside chatbot)
|
|
9240
|
+
planCard: {
|
|
9241
|
+
border: "1.5px solid #e2e8f0",
|
|
9242
|
+
borderRadius: "14px",
|
|
9243
|
+
padding: "14px 16px",
|
|
9244
|
+
display: "flex",
|
|
9245
|
+
alignItems: "center",
|
|
9246
|
+
gap: "14px",
|
|
9247
|
+
cursor: "pointer",
|
|
9248
|
+
position: "relative",
|
|
9249
|
+
overflow: "hidden",
|
|
9250
|
+
transition: "border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease",
|
|
9251
|
+
background: "#fafbff",
|
|
9252
|
+
"&:hover": {
|
|
9253
|
+
borderColor: "#b4beff",
|
|
9254
|
+
boxShadow: "0 2px 12px rgba(66, 89, 238, 0.10)",
|
|
9255
|
+
background: "linear-gradient(135deg, #f5f7ff 0%, #eef1ff 60%, #e8ecff 100%)",
|
|
9256
|
+
},
|
|
9257
|
+
},
|
|
9258
|
+
planCardIcon: {
|
|
9259
|
+
width: "48px",
|
|
9260
|
+
height: "48px",
|
|
9261
|
+
borderRadius: "12px",
|
|
9262
|
+
background: "linear-gradient(135deg, #e8edff 0%, #dbe1ff 100%)",
|
|
9263
|
+
display: "flex",
|
|
9264
|
+
alignItems: "center",
|
|
9265
|
+
justifyContent: "center",
|
|
9266
|
+
flexShrink: 0,
|
|
9267
|
+
"& svg": {
|
|
9268
|
+
color: "#4259EE",
|
|
9269
|
+
fontSize: "22px",
|
|
9270
|
+
},
|
|
9271
|
+
},
|
|
9272
|
+
planCardContent: {
|
|
9273
|
+
flex: 1,
|
|
9274
|
+
minWidth: 0,
|
|
9275
|
+
},
|
|
9276
|
+
planCardTitle: {
|
|
9277
|
+
fontSize: "14px",
|
|
9278
|
+
fontWeight: 700,
|
|
9279
|
+
color: "#1e293b",
|
|
9280
|
+
lineHeight: 1.4,
|
|
9281
|
+
marginBottom: "4px",
|
|
9282
|
+
},
|
|
9283
|
+
planCardLinks: {
|
|
9284
|
+
display: "flex",
|
|
9285
|
+
alignItems: "center",
|
|
9286
|
+
gap: "4px",
|
|
9287
|
+
flexWrap: "wrap",
|
|
9288
|
+
fontSize: "13px",
|
|
9289
|
+
color: "#64748b",
|
|
9290
|
+
},
|
|
9291
|
+
planCardLink: {
|
|
9292
|
+
color: "#64748b",
|
|
9293
|
+
cursor: "pointer",
|
|
9294
|
+
textDecoration: "none",
|
|
9295
|
+
transition: "color 0.2s ease",
|
|
9296
|
+
"&:hover": {
|
|
9297
|
+
color: "#4259EE",
|
|
9298
|
+
},
|
|
9299
|
+
},
|
|
9300
|
+
planCardLinkSeparator: {
|
|
9301
|
+
color: "#94a3b8",
|
|
9302
|
+
margin: "0 3px",
|
|
9303
|
+
},
|
|
9304
|
+
planCardOpenIcon: {
|
|
9305
|
+
flexShrink: 0,
|
|
9306
|
+
color: "#94a3b8",
|
|
9307
|
+
fontSize: "20px !important",
|
|
9308
|
+
padding: "6px",
|
|
9309
|
+
borderRadius: "8px",
|
|
9310
|
+
border: "1px solid #e2e8f0",
|
|
9311
|
+
background: "#ffffff",
|
|
9312
|
+
transition: "border-color 0.25s ease, color 0.25s ease",
|
|
9313
|
+
"$planCard:hover &": {
|
|
9314
|
+
borderColor: "#b4beff",
|
|
9315
|
+
color: "#4259EE",
|
|
9316
|
+
},
|
|
9317
|
+
},
|
|
9318
|
+
|
|
9319
|
+
// PanelHeader styles
|
|
9320
|
+
panelHeader: {
|
|
9321
|
+
display: "flex",
|
|
9322
|
+
alignItems: "center",
|
|
9323
|
+
justifyContent: "space-between",
|
|
9324
|
+
padding: "16px",
|
|
9325
|
+
borderBottom: "1px solid #f0f0f0",
|
|
9326
|
+
flexShrink: 0,
|
|
9327
|
+
},
|
|
9328
|
+
panelHeaderLeft: {
|
|
9329
|
+
display: "flex",
|
|
9330
|
+
alignItems: "center",
|
|
9331
|
+
gap: "8px",
|
|
9332
|
+
flex: 1,
|
|
9333
|
+
minWidth: 0,
|
|
9334
|
+
},
|
|
9335
|
+
panelHeaderIcon: {
|
|
9336
|
+
color: "#666",
|
|
9337
|
+
fontSize: "20px",
|
|
9338
|
+
cursor: "pointer",
|
|
9339
|
+
},
|
|
9340
|
+
panelTitle: {
|
|
9341
|
+
fontSize: "14px",
|
|
9342
|
+
fontWeight: 600,
|
|
9343
|
+
color: "#1a1a1a",
|
|
9344
|
+
lineHeight: 1.4,
|
|
9345
|
+
overflow: "hidden",
|
|
9346
|
+
textOverflow: "ellipsis",
|
|
9347
|
+
whiteSpace: "nowrap",
|
|
9348
|
+
},
|
|
9349
|
+
panelHeaderActions: {
|
|
9350
|
+
display: "flex",
|
|
9351
|
+
alignItems: "center",
|
|
9352
|
+
gap: "6px",
|
|
9353
|
+
flexShrink: 0,
|
|
9354
|
+
},
|
|
9355
|
+
panelHeaderActionBtn: {
|
|
9356
|
+
width: "28px !important",
|
|
9357
|
+
height: "28px !important",
|
|
9358
|
+
borderRadius: "8px !important",
|
|
9359
|
+
background: "#f1f5f9 !important",
|
|
9360
|
+
color: "#475569 !important",
|
|
9361
|
+
padding: "0 !important",
|
|
9362
|
+
"&:hover": {
|
|
9363
|
+
background: "#e2e8f0 !important",
|
|
9364
|
+
color: "#1e293b !important",
|
|
9365
|
+
},
|
|
9366
|
+
},
|
|
9367
|
+
|
|
9368
|
+
// ReportSummaryCard styles
|
|
9369
|
+
reportSummaryCard: {
|
|
9370
|
+
border: "1px solid #f0c36d",
|
|
9371
|
+
borderRadius: "8px",
|
|
9372
|
+
padding: "14px",
|
|
9373
|
+
margin: "16px 0",
|
|
9374
|
+
background: "#fffdf5",
|
|
9375
|
+
},
|
|
9376
|
+
reportBadge: {
|
|
9377
|
+
display: "inline-block",
|
|
9378
|
+
fontSize: "11px",
|
|
9379
|
+
fontWeight: 500,
|
|
9380
|
+
padding: "3px 8px",
|
|
9381
|
+
borderRadius: "4px",
|
|
9382
|
+
marginBottom: "8px",
|
|
9383
|
+
border: "1px solid #f0c36d",
|
|
9384
|
+
color: "#8b6914",
|
|
9385
|
+
background: "transparent",
|
|
9386
|
+
},
|
|
9387
|
+
reportDescription: {
|
|
9388
|
+
fontSize: "12px",
|
|
9389
|
+
lineHeight: 1.6,
|
|
9390
|
+
color: "#333",
|
|
9391
|
+
marginBottom: "10px",
|
|
9392
|
+
},
|
|
9393
|
+
baselinePlanRow: {
|
|
9394
|
+
fontSize: "12px",
|
|
9395
|
+
color: "#666",
|
|
9396
|
+
display: "flex",
|
|
9397
|
+
alignItems: "center",
|
|
9398
|
+
gap: "4px",
|
|
9399
|
+
},
|
|
9400
|
+
baselinePlanLink: {
|
|
9401
|
+
color: "#2563eb",
|
|
9402
|
+
textDecoration: "underline",
|
|
9403
|
+
cursor: "pointer",
|
|
9404
|
+
wordBreak: "break-all",
|
|
9405
|
+
},
|
|
9406
|
+
|
|
9407
|
+
// PanelSection (Accordion) styles
|
|
9408
|
+
sectionAccordion: {
|
|
9409
|
+
boxShadow: "none !important",
|
|
9410
|
+
border: "none !important",
|
|
9411
|
+
borderRadius: "12px !important",
|
|
9412
|
+
marginBottom: "10px !important",
|
|
9413
|
+
background: "#f8fafc !important",
|
|
9414
|
+
"&:before": {
|
|
9415
|
+
display: "none !important",
|
|
9416
|
+
content: "none !important",
|
|
9417
|
+
background: "none !important",
|
|
9418
|
+
width: "0 !important",
|
|
9419
|
+
height: "0 !important",
|
|
9420
|
+
},
|
|
9421
|
+
"&.Mui-expanded": {
|
|
9422
|
+
margin: "0 0 10px 0 !important",
|
|
9423
|
+
background: "#ffffff !important",
|
|
9424
|
+
boxShadow: "0 1px 8px rgba(0, 0, 0, 0.06) !important",
|
|
9425
|
+
border: "1px solid #e2e8f0 !important",
|
|
9426
|
+
},
|
|
9427
|
+
},
|
|
9428
|
+
sectionSummary: {
|
|
9429
|
+
minHeight: "48px !important",
|
|
9430
|
+
padding: "0 16px !important",
|
|
9431
|
+
border: "none !important",
|
|
9432
|
+
flexDirection: "row-reverse !important",
|
|
9433
|
+
gap: "10px",
|
|
9434
|
+
"&:before": {
|
|
9435
|
+
display: "none !important",
|
|
9436
|
+
content: "none !important",
|
|
9437
|
+
background: "none !important",
|
|
9438
|
+
width: "0 !important",
|
|
9439
|
+
height: "0 !important",
|
|
9440
|
+
},
|
|
9441
|
+
"& .MuiAccordionSummary-content": {
|
|
9442
|
+
margin: "12px 0 !important",
|
|
9443
|
+
},
|
|
9444
|
+
"& .MuiAccordionSummary-expandIconWrapper": {
|
|
9445
|
+
color: "#64748b",
|
|
9446
|
+
transform: "rotate(-90deg)",
|
|
9447
|
+
padding: "0 !important",
|
|
9448
|
+
marginRight: "0 !important",
|
|
9449
|
+
"&.Mui-expanded": {
|
|
9450
|
+
transform: "rotate(0deg)",
|
|
9451
|
+
},
|
|
9452
|
+
},
|
|
9453
|
+
},
|
|
9454
|
+
sectionTitle: {
|
|
9455
|
+
fontSize: "14px",
|
|
9456
|
+
fontWeight: 600,
|
|
9457
|
+
color: "#1e293b",
|
|
9458
|
+
},
|
|
9459
|
+
sectionDetails: {
|
|
9460
|
+
padding: "0 16px 16px !important",
|
|
9461
|
+
border: "none !important",
|
|
9462
|
+
"&:before": {
|
|
9463
|
+
display: "none !important",
|
|
9464
|
+
content: "none !important",
|
|
9465
|
+
background: "none !important",
|
|
9466
|
+
width: "0 !important",
|
|
9467
|
+
height: "0 !important",
|
|
9468
|
+
},
|
|
9469
|
+
},
|
|
9470
|
+
|
|
9471
|
+
// StructuredComparison styles
|
|
9472
|
+
comparisonSubtitle: {
|
|
9473
|
+
fontSize: "12px",
|
|
9474
|
+
color: "#666",
|
|
9475
|
+
marginBottom: "12px",
|
|
9476
|
+
lineHeight: 1.5,
|
|
9477
|
+
},
|
|
9478
|
+
scenarioLabel: {
|
|
9479
|
+
fontSize: "12px",
|
|
9480
|
+
fontWeight: 500,
|
|
9481
|
+
color: "#1a1a1a",
|
|
9482
|
+
padding: "8px 12px",
|
|
9483
|
+
background: "#f8f9fa",
|
|
9484
|
+
borderRadius: "6px",
|
|
9485
|
+
marginBottom: "12px",
|
|
9486
|
+
},
|
|
9487
|
+
comparisonCard: {
|
|
9488
|
+
background: "#f8f9fa",
|
|
9489
|
+
borderRadius: "8px",
|
|
9490
|
+
padding: "12px",
|
|
9491
|
+
marginBottom: "10px",
|
|
9492
|
+
},
|
|
9493
|
+
comparisonParamRow: {
|
|
9494
|
+
display: "flex",
|
|
9495
|
+
alignItems: "center",
|
|
9496
|
+
gap: "8px",
|
|
9497
|
+
marginBottom: "10px",
|
|
9498
|
+
},
|
|
9499
|
+
comparisonParamName: {
|
|
9500
|
+
fontSize: "13px",
|
|
9501
|
+
fontWeight: 600,
|
|
9502
|
+
color: "#1a1a1a",
|
|
9503
|
+
},
|
|
9504
|
+
comparisonTag: {
|
|
9505
|
+
display: "inline-block",
|
|
9506
|
+
fontSize: "10px",
|
|
9507
|
+
fontWeight: 500,
|
|
9508
|
+
padding: "2px 6px",
|
|
9509
|
+
borderRadius: "4px",
|
|
9510
|
+
color: "#2563eb",
|
|
9511
|
+
border: "1px solid #bfdbfe",
|
|
9512
|
+
background: "#eff6ff",
|
|
9513
|
+
},
|
|
9514
|
+
comparisonValues: {
|
|
9515
|
+
display: "flex",
|
|
9516
|
+
alignItems: "center",
|
|
9517
|
+
gap: "8px",
|
|
9518
|
+
},
|
|
9519
|
+
comparisonValueBox: {
|
|
9520
|
+
flex: 1,
|
|
9521
|
+
background: theme.palette.common.white,
|
|
9522
|
+
borderRadius: "6px",
|
|
9523
|
+
padding: "8px 10px",
|
|
9524
|
+
border: "1px solid #e8e8e8",
|
|
9525
|
+
},
|
|
9526
|
+
comparisonValueLabel: {
|
|
9527
|
+
fontSize: "10px",
|
|
9528
|
+
color: "#999",
|
|
9529
|
+
marginBottom: "2px",
|
|
9530
|
+
},
|
|
9531
|
+
comparisonValueText: {
|
|
9532
|
+
fontSize: "12px",
|
|
9533
|
+
fontWeight: 600,
|
|
9534
|
+
color: "#1a1a1a",
|
|
9535
|
+
},
|
|
9536
|
+
comparisonArrow: {
|
|
9537
|
+
color: "#999",
|
|
9538
|
+
fontSize: "16px",
|
|
9539
|
+
flexShrink: 0,
|
|
9540
|
+
},
|
|
9541
|
+
|
|
9542
|
+
// Panel-specific HTML content wrapper (font size/line-height for panel context)
|
|
9543
|
+
panelHtmlContainer: {
|
|
9544
|
+
fontSize: "12px",
|
|
9545
|
+
lineHeight: 1.6,
|
|
9546
|
+
},
|
|
9547
|
+
|
|
9548
|
+
// Slide-in keyframes for panel entry
|
|
9549
|
+
"@keyframes panelSlideIn": {
|
|
9550
|
+
"0%": {
|
|
9551
|
+
transform: "translateX(100%)",
|
|
9552
|
+
opacity: 0,
|
|
9553
|
+
},
|
|
9554
|
+
"100%": {
|
|
9555
|
+
transform: "translateX(0)",
|
|
9556
|
+
opacity: 1,
|
|
9557
|
+
},
|
|
9558
|
+
},
|
|
9559
|
+
// AllocationDetailPanel container (portaled)
|
|
9560
|
+
panelContainer: {
|
|
9561
|
+
position: "fixed",
|
|
9562
|
+
top: 56,
|
|
9563
|
+
right: 0,
|
|
9564
|
+
width: "calc(50vw - 32px)",
|
|
9565
|
+
maxWidth: "520px",
|
|
9566
|
+
height: "calc(100vh - 56px)",
|
|
9567
|
+
zIndex: 99999,
|
|
9568
|
+
display: "flex",
|
|
9569
|
+
flexDirection: "column",
|
|
9570
|
+
background: "#ffffff",
|
|
9571
|
+
boxShadow: "-4px 0 16px rgba(0, 0, 0, 0.15)",
|
|
9572
|
+
borderLeft: "1px solid #e8e8e8",
|
|
9573
|
+
borderRadius: "12px 0 0 12px",
|
|
9574
|
+
overflow: "hidden",
|
|
9575
|
+
animation: "$panelSlideIn 0.3s ease forwards",
|
|
9576
|
+
transition: "width 0.3s ease, max-width 0.3s ease, border-radius 0.3s ease",
|
|
9577
|
+
},
|
|
9578
|
+
// Expanded / maximized panel — covers the chatbot area too
|
|
9579
|
+
panelExpanded: {
|
|
9580
|
+
width: "calc(100vw - 4rem)",
|
|
9581
|
+
maxWidth: "calc(100vw - 4rem)",
|
|
9582
|
+
borderRadius: "0",
|
|
9583
|
+
},
|
|
9584
|
+
panelScrollBody: {
|
|
9585
|
+
flex: 1,
|
|
9586
|
+
overflowY: "auto",
|
|
9587
|
+
padding: "0 16px 24px",
|
|
9588
|
+
},
|
|
9589
|
+
|
|
9590
|
+
// Footer
|
|
9591
|
+
panelFooter: {
|
|
9592
|
+
display: "flex",
|
|
9593
|
+
justifyContent: "flex-end",
|
|
9594
|
+
alignItems: "center",
|
|
9595
|
+
gap: "10px",
|
|
9596
|
+
padding: "12px 16px",
|
|
9597
|
+
borderTop: "1px solid #e2e8f0",
|
|
9598
|
+
background: "#ffffff",
|
|
9599
|
+
flexShrink: 0,
|
|
9600
|
+
position: "relative",
|
|
9601
|
+
},
|
|
9602
|
+
footerBtnOutlined: {
|
|
9603
|
+
display: "inline-flex",
|
|
9604
|
+
alignItems: "center",
|
|
9605
|
+
justifyContent: "center",
|
|
9606
|
+
height: "32px",
|
|
9607
|
+
padding: "0 12px",
|
|
9608
|
+
fontSize: "14px",
|
|
9609
|
+
fontWeight: 600,
|
|
9610
|
+
fontFamily: "Manrope, sans-serif",
|
|
9611
|
+
lineHeight: 1,
|
|
9612
|
+
borderRadius: "8px",
|
|
9613
|
+
border: "1px solid #d1d5db",
|
|
9614
|
+
background: "#ffffff",
|
|
9615
|
+
color: "#1e293b",
|
|
9616
|
+
cursor: "pointer",
|
|
9617
|
+
textTransform: "none",
|
|
9618
|
+
},
|
|
9619
|
+
footerBtnPrimary: {
|
|
9620
|
+
display: "inline-flex",
|
|
9621
|
+
alignItems: "center",
|
|
9622
|
+
justifyContent: "center",
|
|
9623
|
+
height: "32px",
|
|
9624
|
+
padding: "0 12px",
|
|
9625
|
+
fontSize: "14px",
|
|
9626
|
+
fontWeight: 600,
|
|
9627
|
+
fontFamily: "Manrope, sans-serif",
|
|
9628
|
+
lineHeight: 1,
|
|
9629
|
+
borderRadius: "8px",
|
|
9630
|
+
border: "1px solid #4259EE",
|
|
9631
|
+
background: "#4259EE",
|
|
9632
|
+
color: "#ffffff",
|
|
9633
|
+
cursor: "pointer",
|
|
9634
|
+
textTransform: "none",
|
|
9635
|
+
},
|
|
9636
|
+
|
|
9637
|
+
// Footer options popover
|
|
9638
|
+
optionsCard: {
|
|
9639
|
+
position: "absolute",
|
|
9640
|
+
bottom: "100%",
|
|
9641
|
+
right: 0,
|
|
9642
|
+
marginBottom: "8px",
|
|
9643
|
+
background: "#ffffff",
|
|
9644
|
+
borderRadius: "12px",
|
|
9645
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.12)",
|
|
9646
|
+
border: "1px solid #e2e8f0",
|
|
9647
|
+
padding: "8px",
|
|
9648
|
+
minWidth: "280px",
|
|
9649
|
+
zIndex: 1,
|
|
9650
|
+
},
|
|
9651
|
+
optionRow: {
|
|
9652
|
+
display: "flex",
|
|
9653
|
+
alignItems: "center",
|
|
9654
|
+
gap: "10px",
|
|
9655
|
+
padding: "10px 12px",
|
|
9656
|
+
borderRadius: "8px",
|
|
9657
|
+
cursor: "pointer",
|
|
9658
|
+
fontSize: "13px",
|
|
9659
|
+
fontWeight: 500,
|
|
9660
|
+
color: "#1e293b",
|
|
9661
|
+
background: "#f8fafc",
|
|
9662
|
+
marginBottom: "4px",
|
|
9663
|
+
border: "none",
|
|
9664
|
+
width: "100%",
|
|
9665
|
+
textAlign: "left",
|
|
9666
|
+
fontFamily: "Manrope, sans-serif",
|
|
9667
|
+
"&:hover": {
|
|
9668
|
+
background: "#eef2ff",
|
|
9669
|
+
},
|
|
9670
|
+
"&:last-child": {
|
|
9671
|
+
marginBottom: 0,
|
|
9672
|
+
},
|
|
9673
|
+
},
|
|
9674
|
+
optionIcon: {
|
|
9675
|
+
color: "#6366f1",
|
|
9676
|
+
fontSize: "16px",
|
|
9677
|
+
},
|
|
9678
|
+
}));
|
|
9679
|
+
|
|
9680
|
+
const AllocationPlanCard = ({ bodyText }) => {
|
|
9681
|
+
const classes = useAllocationPanelStyles();
|
|
9682
|
+
const title = bodyText?.title || "Allocation Plan";
|
|
9683
|
+
const links = bodyText?.links || [];
|
|
9684
|
+
const panelData = bodyText?.panel_data || null;
|
|
9685
|
+
const handleCardClick = (target) => {
|
|
9686
|
+
if (!panelData)
|
|
9687
|
+
return;
|
|
9688
|
+
const openPanel = () => {
|
|
9689
|
+
window.dispatchEvent(new CustomEvent("openAllocationDetailPanel", {
|
|
9690
|
+
detail: { panelData, activeSection: target || null },
|
|
9691
|
+
}));
|
|
9692
|
+
};
|
|
9693
|
+
// Check if the chatbot is in a collapsed/minimized state by looking for
|
|
9694
|
+
// the "Expand chatbot" button (present only when collapsed)
|
|
9695
|
+
const expandBtn = document.querySelector('button[aria-label="Expand chatbot"]');
|
|
9696
|
+
if (expandBtn) {
|
|
9697
|
+
// Maximize first, then open the panel after chatbot finishes expanding
|
|
9698
|
+
window.dispatchEvent(new CustomEvent("smartBotMaximize"));
|
|
9699
|
+
setTimeout(openPanel, 350);
|
|
9700
|
+
}
|
|
9701
|
+
else {
|
|
9702
|
+
openPanel();
|
|
9703
|
+
}
|
|
9704
|
+
};
|
|
9705
|
+
return (jsxs("div", { className: classes.planCard, onClick: () => handleCardClick(links[0]?.target), children: [jsx("div", { className: classes.planCardIcon, children: jsx(DescriptionOutlinedIcon, {}) }), jsxs("div", { className: classes.planCardContent, children: [jsx("div", { className: classes.planCardTitle, children: title }), jsx("div", { className: classes.planCardLinks, children: links.map((link, index) => (jsxs("span", { children: [index > 0 && (jsx("span", { className: classes.planCardLinkSeparator, children: "\u00B7" })), jsx("span", { className: classes.planCardLink, onClick: (e) => {
|
|
9706
|
+
e.stopPropagation();
|
|
9707
|
+
handleCardClick(link.target);
|
|
9708
|
+
}, children: link.label })] }, link.target || index))) })] }), jsx(OpenInNewIcon, { className: classes.planCardOpenIcon })] }));
|
|
9709
|
+
};
|
|
9710
|
+
|
|
8941
9711
|
const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
8942
9712
|
try {
|
|
8943
9713
|
const parsedData = parseResponse(item, item.type, "", "", true);
|
|
@@ -8974,6 +9744,10 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
|
8974
9744
|
return jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
8975
9745
|
case "html":
|
|
8976
9746
|
return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
9747
|
+
case "surface_frame":
|
|
9748
|
+
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
9749
|
+
case "allocation_plan_card":
|
|
9750
|
+
return jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
|
|
8977
9751
|
default:
|
|
8978
9752
|
return null;
|
|
8979
9753
|
}
|
|
@@ -9845,7 +10619,8 @@ const StreamedContent = ({ botData, botProps }) => {
|
|
|
9845
10619
|
const widgetItems = isArray(data.widget_data)
|
|
9846
10620
|
? data.widget_data
|
|
9847
10621
|
: [data.widget_data];
|
|
9848
|
-
|
|
10622
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
10623
|
+
setStreamingWidgetData((prev) => mergeSurfaceWidgets(prev, widgetItems));
|
|
9849
10624
|
}
|
|
9850
10625
|
else if (data.message !== "[DONE]") {
|
|
9851
10626
|
if (!thinkingDoneRef?.current && currentMode === "agent") {
|
|
@@ -11015,6 +11790,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
11015
11790
|
return jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
11016
11791
|
case "graph":
|
|
11017
11792
|
return jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
11793
|
+
case "surface_frame":
|
|
11794
|
+
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
11018
11795
|
case "radio":
|
|
11019
11796
|
return jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
11020
11797
|
case "checkbox":
|
|
@@ -11094,7 +11871,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
11094
11871
|
}
|
|
11095
11872
|
});
|
|
11096
11873
|
if (newWidgets.length > 0) {
|
|
11097
|
-
|
|
11874
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
11875
|
+
setWidgetContent((prev) => mergeSurfaceWidgets(prev, newWidgets));
|
|
11098
11876
|
}
|
|
11099
11877
|
return;
|
|
11100
11878
|
}
|
|
@@ -11225,7 +12003,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
11225
12003
|
let newQuestions = [...questionsRef.current];
|
|
11226
12004
|
let newQuestionsStepsMap = cloneDeep(questionsStepsMapRef.current);
|
|
11227
12005
|
let newStepFormDataMap = cloneDeep(stepFormDataMapRef.current);
|
|
11228
|
-
|
|
12006
|
+
let newWidgets = [];
|
|
11229
12007
|
chunks.forEach((data) => {
|
|
11230
12008
|
if (data.status === "questions") {
|
|
11231
12009
|
const incomingQuestions = data.widget_data?.[0]?.questions || [];
|
|
@@ -11322,10 +12100,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
11322
12100
|
}
|
|
11323
12101
|
if (data.status === "widget") {
|
|
11324
12102
|
const widgetItems = isArray$2(data.widget_data) ? data.widget_data : [data.widget_data];
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
newWidgets.push(item);
|
|
11328
|
-
});
|
|
12103
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
12104
|
+
newWidgets = mergeSurfaceWidgets(newWidgets, widgetItems.filter(Boolean));
|
|
11329
12105
|
}
|
|
11330
12106
|
if (data.status === "content" && data.message) {
|
|
11331
12107
|
newWidgets.push({ type: "text", response: data.message });
|
|
@@ -11452,6 +12228,10 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
11452
12228
|
return jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
11453
12229
|
case "html":
|
|
11454
12230
|
return jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
12231
|
+
case "surface_frame":
|
|
12232
|
+
return jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
12233
|
+
case "allocation_plan_card":
|
|
12234
|
+
return jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
|
|
11455
12235
|
default:
|
|
11456
12236
|
return null;
|
|
11457
12237
|
}
|
|
@@ -11530,6 +12310,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
11530
12310
|
return jsx(TableContent, { bodyText: botData.bodyText });
|
|
11531
12311
|
case "graph":
|
|
11532
12312
|
return jsx(GraphContent, { bodyText: botData.bodyText });
|
|
12313
|
+
case "surface_frame":
|
|
12314
|
+
return jsx(SurfaceFrameContent, { frame: botData.bodyText });
|
|
11533
12315
|
case "slider":
|
|
11534
12316
|
return jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
11535
12317
|
case "select":
|
|
@@ -11552,6 +12334,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
11552
12334
|
return jsx(ImageContent, { bodyText: botData.bodyText });
|
|
11553
12335
|
case "html":
|
|
11554
12336
|
return jsx(HtmlContent, { bodyText: botData.bodyText });
|
|
12337
|
+
case "allocation_plan_card":
|
|
12338
|
+
return jsx(AllocationPlanCard, { bodyText: botData.bodyText });
|
|
11555
12339
|
case "combined":
|
|
11556
12340
|
return jsx(CombinedContent, { botData: botData, props: props });
|
|
11557
12341
|
case "dynamic":
|
|
@@ -15684,6 +16468,146 @@ const MinimizedChatWidget = ({ onExpand }) => {
|
|
|
15684
16468
|
return (jsxs("div", { className: classes.widgetContainer, onClick: handleExpandClick, children: [jsxs("div", { className: classes.widgetHeader, children: [jsxs("div", { className: classes.headerLeft, children: [jsx("div", { className: !isCompleted ? classes.headerIconLogoSpin : classes.headerIconLogo, children: jsx(SvgMimimizedIconLogo, {}) }), jsx("span", { className: classes.headerText, children: isCompleted ? "Action completed" : actionLabel }), !isCompleted && (jsx("div", { className: classes.warningIcon, children: jsx(SvgStepError, {}) }))] }), jsx("button", { className: classes.minimizeBtn, onClick: handleMinimizeClick, "aria-label": "Minimize", children: jsx(SvgMinimizeDashIcon, {}) })] }), jsx("div", { className: classes.widgetContent, children: jsxs("div", { className: stepStatus === "step_form" ? classes.innerContentStepForm : classes.innerContent, children: [jsxs("div", { className: classes.innerFirstRow, children: [jsx("span", { className: classes.stepHeaderText, title: stepHeader, children: stepHeader }), jsx("button", { className: classes.expandBtn, onClick: handleExpandClick, "aria-label": "Expand chatbot", children: jsx(SvgExpandFullscreenIcon, {}) })] }), stepSubHeader && (jsxs("div", { className: classes.innerSecondRow, children: [jsxs("div", { className: stepStatus === "step_form" ? classes.subHeaderPillStepForm : classes.subHeaderPill, children: [stepStatus === "step_form" ? (jsx("div", { className: classes.exclamationIcon, children: jsx(SvgExclamationIcon, {}) })) : !isCompleted && (jsx("div", { className: classes.loaderIcon, children: jsx(SvgLoadingCircle, {}) })), jsx("span", { className: classes.subHeaderText, title: stepSubHeader, children: stepSubHeader })] }), elapsedTime && (jsx("span", { className: classes.timeText, children: elapsedTime }))] }))] }) })] }));
|
|
15685
16469
|
};
|
|
15686
16470
|
|
|
16471
|
+
const PanelHeader = ({ title, actions = {}, onClose, isExpanded, onToggleExpand }) => {
|
|
16472
|
+
const classes = useAllocationPanelStyles();
|
|
16473
|
+
return (jsxs("div", { className: classes.panelHeader, children: [jsxs("div", { className: classes.panelHeaderLeft, children: [actions.preview && (jsx(VisibilityOutlinedIcon, { className: classes.panelHeaderIcon })), jsx("span", { className: classes.panelTitle, title: title, children: title })] }), jsxs("div", { className: classes.panelHeaderActions, children: [actions.expand_fullscreen && (jsx(IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onToggleExpand, children: isExpanded ? (jsx(CloseFullscreenIcon, { sx: { fontSize: 16 } })) : (jsx(OpenInFullIcon, { sx: { fontSize: 16 } })) })), jsx(IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onClose, children: jsx(CloseIcon, { sx: { fontSize: 16 } }) })] })] }));
|
|
16474
|
+
};
|
|
16475
|
+
|
|
16476
|
+
const ReportSummaryCard = ({ reportSummary }) => {
|
|
16477
|
+
const classes = useAllocationPanelStyles();
|
|
16478
|
+
if (!reportSummary)
|
|
16479
|
+
return null;
|
|
16480
|
+
const { badge, description, baseline_plan } = reportSummary;
|
|
16481
|
+
return (jsxs("div", { className: classes.reportSummaryCard, children: [badge && (jsx("span", { className: classes.reportBadge, children: badge.label })), description && (jsx("div", { className: classes.reportDescription, children: description })), baseline_plan && (jsxs("div", { className: classes.baselinePlanRow, children: [jsxs("span", { children: [baseline_plan.label, ":"] }), baseline_plan.link_url ? (jsx("span", { className: classes.baselinePlanLink, onClick: () => {
|
|
16482
|
+
if (baseline_plan.link_url) {
|
|
16483
|
+
window.open(baseline_plan.link_url, "_blank");
|
|
16484
|
+
}
|
|
16485
|
+
}, children: baseline_plan.value })) : (jsx("span", { children: baseline_plan.value }))] }))] }));
|
|
16486
|
+
};
|
|
16487
|
+
|
|
16488
|
+
const StructuredComparison = ({ content }) => {
|
|
16489
|
+
const classes = useAllocationPanelStyles();
|
|
16490
|
+
if (!content)
|
|
16491
|
+
return null;
|
|
16492
|
+
const { subtitle, scenario_groups = [] } = content;
|
|
16493
|
+
return (jsxs("div", { children: [subtitle && (jsx("div", { className: classes.comparisonSubtitle, children: subtitle })), scenario_groups.map((group, groupIndex) => (jsxs("div", { children: [jsx("div", { className: classes.scenarioLabel, children: group.scenario_label }), (group.comparisons || []).map((comparison, compIndex) => (jsxs("div", { className: classes.comparisonCard, children: [jsxs("div", { className: classes.comparisonParamRow, children: [jsx("span", { className: classes.comparisonParamName, children: comparison.parameter_name }), (comparison.tags || []).map((tag, tagIndex) => (jsx("span", { className: classes.comparisonTag, children: tag.label }, `tag-${tagIndex}`)))] }), jsxs("div", { className: classes.comparisonValues, children: [jsxs("div", { className: classes.comparisonValueBox, children: [jsx("div", { className: classes.comparisonValueLabel, children: comparison.baseline?.label }), jsx("div", { className: classes.comparisonValueText, children: comparison.baseline?.value })] }), jsx(ArrowForwardIcon, { className: classes.comparisonArrow }), jsxs("div", { className: classes.comparisonValueBox, children: [jsx("div", { className: classes.comparisonValueLabel, children: comparison.new_value?.label }), jsx("div", { className: classes.comparisonValueText, children: comparison.new_value?.value })] })] })] }, `comp-${groupIndex}-${compIndex}`)))] }, `group-${groupIndex}`)))] }));
|
|
16494
|
+
};
|
|
16495
|
+
|
|
16496
|
+
const PanelSection = ({ section }) => {
|
|
16497
|
+
const classes = useAllocationPanelStyles();
|
|
16498
|
+
if (!section)
|
|
16499
|
+
return null;
|
|
16500
|
+
const renderContent = () => {
|
|
16501
|
+
switch (section.content_type) {
|
|
16502
|
+
case "html":
|
|
16503
|
+
case "custom_html":
|
|
16504
|
+
return (jsx("div", { className: classes.panelHtmlContainer, children: jsx(HtmlContent, { bodyText: { content: section.content } }) }));
|
|
16505
|
+
case "structured":
|
|
16506
|
+
return jsx(StructuredComparison, { content: section.content });
|
|
16507
|
+
default:
|
|
16508
|
+
return null;
|
|
16509
|
+
}
|
|
16510
|
+
};
|
|
16511
|
+
return (jsxs(Accordion, { defaultExpanded: section.default_expanded, className: classes.sectionAccordion, disableGutters: true, children: [jsx(AccordionSummary, { expandIcon: jsx(ExpandMoreIcon, {}), className: classes.sectionSummary, children: jsx("span", { className: classes.sectionTitle, children: section.title }) }), jsx(AccordionDetails, { className: classes.sectionDetails, children: renderContent() })] }));
|
|
16512
|
+
};
|
|
16513
|
+
|
|
16514
|
+
const shiftChatbot = (panelEl) => {
|
|
16515
|
+
const chatbot = document.querySelector(".chatbot-component-container");
|
|
16516
|
+
if (!chatbot)
|
|
16517
|
+
return;
|
|
16518
|
+
const panelWidth = panelEl ? panelEl.offsetWidth : 0;
|
|
16519
|
+
const currentLeft = parseFloat(chatbot.style.left) || 0;
|
|
16520
|
+
chatbot.dataset.origLeft = chatbot.style.left;
|
|
16521
|
+
chatbot.style.transition = "left 0.3s ease";
|
|
16522
|
+
chatbot.style.left = (currentLeft - panelWidth) + "px";
|
|
16523
|
+
};
|
|
16524
|
+
const restoreChatbot = () => {
|
|
16525
|
+
const chatbot = document.querySelector(".chatbot-component-container");
|
|
16526
|
+
if (!chatbot)
|
|
16527
|
+
return;
|
|
16528
|
+
if (chatbot.dataset.origLeft) {
|
|
16529
|
+
chatbot.style.transition = "left 0.3s ease";
|
|
16530
|
+
chatbot.style.left = chatbot.dataset.origLeft;
|
|
16531
|
+
delete chatbot.dataset.origLeft;
|
|
16532
|
+
// Clean up transition after animation completes
|
|
16533
|
+
const onEnd = () => {
|
|
16534
|
+
chatbot.style.transition = "";
|
|
16535
|
+
chatbot.removeEventListener("transitionend", onEnd);
|
|
16536
|
+
};
|
|
16537
|
+
chatbot.addEventListener("transitionend", onEnd);
|
|
16538
|
+
}
|
|
16539
|
+
};
|
|
16540
|
+
const AllocationDetailPanel = () => {
|
|
16541
|
+
const classes = useAllocationPanelStyles();
|
|
16542
|
+
const [panelData, setPanelData] = useState(null);
|
|
16543
|
+
const [activeFooterAction, setActiveFooterAction] = useState(null);
|
|
16544
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
16545
|
+
const panelRef = useRef(null);
|
|
16546
|
+
const handleOpen = useCallback((e) => {
|
|
16547
|
+
const { panelData: data } = e.detail || {};
|
|
16548
|
+
if (data) {
|
|
16549
|
+
setPanelData(data);
|
|
16550
|
+
}
|
|
16551
|
+
}, []);
|
|
16552
|
+
const handleClose = useCallback(() => {
|
|
16553
|
+
restoreChatbot();
|
|
16554
|
+
setPanelData(null);
|
|
16555
|
+
setIsExpanded(false);
|
|
16556
|
+
}, []);
|
|
16557
|
+
useEffect(() => {
|
|
16558
|
+
window.addEventListener("openAllocationDetailPanel", handleOpen);
|
|
16559
|
+
window.addEventListener("closeAllocationDetailPanel", handleClose);
|
|
16560
|
+
return () => {
|
|
16561
|
+
window.removeEventListener("openAllocationDetailPanel", handleOpen);
|
|
16562
|
+
window.removeEventListener("closeAllocationDetailPanel", handleClose);
|
|
16563
|
+
};
|
|
16564
|
+
}, [handleOpen, handleClose]);
|
|
16565
|
+
// Shift the chatbot once the panel has rendered
|
|
16566
|
+
useEffect(() => {
|
|
16567
|
+
if (panelData && panelRef.current) {
|
|
16568
|
+
// Use requestAnimationFrame to ensure the panel is laid out
|
|
16569
|
+
requestAnimationFrame(() => {
|
|
16570
|
+
shiftChatbot(panelRef.current);
|
|
16571
|
+
});
|
|
16572
|
+
}
|
|
16573
|
+
}, [panelData]);
|
|
16574
|
+
// Listen for direct clicks on the impact-ui collapse button
|
|
16575
|
+
useEffect(() => {
|
|
16576
|
+
if (!panelData)
|
|
16577
|
+
return;
|
|
16578
|
+
const collapseBtn = document.querySelector('button[aria-label="Collapse chatbot"]');
|
|
16579
|
+
if (!collapseBtn)
|
|
16580
|
+
return;
|
|
16581
|
+
const onCollapse = () => handleClose();
|
|
16582
|
+
collapseBtn.addEventListener("click", onCollapse);
|
|
16583
|
+
return () => collapseBtn.removeEventListener("click", onCollapse);
|
|
16584
|
+
}, [panelData, handleClose]);
|
|
16585
|
+
if (!panelData)
|
|
16586
|
+
return null;
|
|
16587
|
+
const footerActions = panelData.footer_actions || [
|
|
16588
|
+
{ label: "Purge", variant: "outlined", action: "purge", options: [] },
|
|
16589
|
+
{ label: "Finalize Plan", variant: "primary", action: "finalize", options: [] },
|
|
16590
|
+
];
|
|
16591
|
+
const handleOptionClick = (option) => {
|
|
16592
|
+
setActiveFooterAction(null);
|
|
16593
|
+
window.dispatchEvent(new CustomEvent("allocationPanelAction", {
|
|
16594
|
+
detail: { value: option.value, label: option.label },
|
|
16595
|
+
}));
|
|
16596
|
+
};
|
|
16597
|
+
const handleFooterBtnClick = (btn) => {
|
|
16598
|
+
if (btn.options && btn.options.length > 0) {
|
|
16599
|
+
setActiveFooterAction(activeFooterAction === btn.action ? null : btn.action);
|
|
16600
|
+
}
|
|
16601
|
+
else {
|
|
16602
|
+
console.log("[AllocationPanel] footer action:", btn.action);
|
|
16603
|
+
}
|
|
16604
|
+
};
|
|
16605
|
+
const panel = (jsxs("div", { ref: panelRef, className: `${classes.panelContainer} ${isExpanded ? classes.panelExpanded : ""}`, "data-testid": "allocation-detail-panel", children: [jsx(PanelHeader, { title: panelData.title, actions: panelData.actions || {}, onClose: handleClose, isExpanded: isExpanded, onToggleExpand: () => setIsExpanded((prev) => !prev) }), jsxs("div", { className: classes.panelScrollBody, children: [jsx(ReportSummaryCard, { reportSummary: panelData.report_summary }), (panelData.sections || []).map((section) => (jsx(PanelSection, { section: section }, section.id)))] }), jsxs("div", { className: classes.panelFooter, children: [activeFooterAction && (jsx("div", { className: classes.optionsCard, children: footerActions
|
|
16606
|
+
.find((a) => a.action === activeFooterAction)
|
|
16607
|
+
?.options?.map((opt, idx) => (jsxs("button", { className: classes.optionRow, onClick: () => handleOptionClick(opt), children: [jsx("span", { className: classes.optionIcon, children: "\u2606" }), opt.label] }, idx))) })), footerActions.map((btn, idx) => (jsx("button", { className: btn.variant === "primary" ? classes.footerBtnPrimary : classes.footerBtnOutlined, onClick: () => handleFooterBtnClick(btn), children: btn.label }, idx)))] })] }));
|
|
16608
|
+
return createPortal(panel, document.body);
|
|
16609
|
+
};
|
|
16610
|
+
|
|
15687
16611
|
const SmartBot = (props) => {
|
|
15688
16612
|
const { userName, partialClose, setPartialClose, forceOpen, customBaseUrl = "", displayQuestions, questions = [] } = props;
|
|
15689
16613
|
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();
|
|
@@ -15811,6 +16735,7 @@ const SmartBot = (props) => {
|
|
|
15811
16735
|
// Minimize the chat window when the user follows an in-app link from a bot response
|
|
15812
16736
|
const handleMinimizeRequest = () => {
|
|
15813
16737
|
setPartialClose(true);
|
|
16738
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
15814
16739
|
};
|
|
15815
16740
|
window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
|
|
15816
16741
|
window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
|
|
@@ -16469,7 +17394,7 @@ const SmartBot = (props) => {
|
|
|
16469
17394
|
fetchLegacyAgentInfo(); //Disabled temporarily since this was causing issue on homepage first render
|
|
16470
17395
|
}
|
|
16471
17396
|
}, [location]);
|
|
16472
|
-
const handleSendMessage = async (userInput, userExplicitInput = {}, textWithColumnNames = "") => {
|
|
17397
|
+
const handleSendMessage = async (userInput, userExplicitInput = {}, textWithColumnNames = "", uiContext = null) => {
|
|
16473
17398
|
try {
|
|
16474
17399
|
// if (localStorage.getItem("isStreaming") === "true") {
|
|
16475
17400
|
// displaySnackMessages(
|
|
@@ -16533,6 +17458,7 @@ const SmartBot = (props) => {
|
|
|
16533
17458
|
userExplicitInput: userExplicitInput,
|
|
16534
17459
|
textWithColumnNames: textWithColumnNames,
|
|
16535
17460
|
answerMode: answerMode,
|
|
17461
|
+
...(uiContext ? { uiContext } : {}),
|
|
16536
17462
|
};
|
|
16537
17463
|
// if(!isEmpty(userInput)) {
|
|
16538
17464
|
// Clear the previous response's completed state so the incoming
|
|
@@ -16582,12 +17508,25 @@ const SmartBot = (props) => {
|
|
|
16582
17508
|
sessionStorage.removeItem("stepForm_chatId");
|
|
16583
17509
|
// dispatch(setChatbotContext({}));
|
|
16584
17510
|
setUserInput(params?.text);
|
|
16585
|
-
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames);
|
|
17511
|
+
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames, params?.uiContext);
|
|
16586
17512
|
}
|
|
16587
17513
|
catch (error) {
|
|
16588
17514
|
console.error("onSendIconClick error", error);
|
|
16589
17515
|
}
|
|
16590
17516
|
};
|
|
17517
|
+
// A follow-up asked from a generated surface (SurfaceFrameContent's "iris:prompt"): sent as the user's next
|
|
17518
|
+
// message, with the surface's context as ui_context. Not while a turn runs or a form waits for its Submit.
|
|
17519
|
+
const surfacePromptRef = useRef(null);
|
|
17520
|
+
surfacePromptRef.current = (detail) => {
|
|
17521
|
+
if (!detail?.text || isStop || !isEmpty$1(chatbotContext))
|
|
17522
|
+
return;
|
|
17523
|
+
onSendIconClick({ text: detail.text, uiContext: detail.uiContext });
|
|
17524
|
+
};
|
|
17525
|
+
useEffect(() => {
|
|
17526
|
+
const onSurfacePrompt = (event) => surfacePromptRef.current?.(event.detail);
|
|
17527
|
+
window.addEventListener("iris:prompt", onSurfacePrompt);
|
|
17528
|
+
return () => window.removeEventListener("iris:prompt", onSurfacePrompt);
|
|
17529
|
+
}, []);
|
|
16591
17530
|
const onStopIconClick = (params) => {
|
|
16592
17531
|
try {
|
|
16593
17532
|
setIsStop(false);
|
|
@@ -16821,9 +17760,35 @@ const SmartBot = (props) => {
|
|
|
16821
17760
|
if (!root)
|
|
16822
17761
|
return;
|
|
16823
17762
|
const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
|
|
16824
|
-
if (collapseBtn)
|
|
17763
|
+
if (collapseBtn) {
|
|
16825
17764
|
collapseBtn.click();
|
|
17765
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
17766
|
+
}
|
|
16826
17767
|
}, []);
|
|
17768
|
+
// Expand the chatbot to its full docked view by programmatically clicking
|
|
17769
|
+
// impact-ui's "Expand chatbot" button. Used when the allocation panel opens
|
|
17770
|
+
// from minimized state.
|
|
17771
|
+
const expandChatBotIfCollapsed = useCallback(() => {
|
|
17772
|
+
setShowModal(true);
|
|
17773
|
+
setPartialClose(false);
|
|
17774
|
+
// Use a short delay so the chatbot DOM renders before we look for the button
|
|
17775
|
+
setTimeout(() => {
|
|
17776
|
+
const root = smartBotWrapperRef.current;
|
|
17777
|
+
if (!root)
|
|
17778
|
+
return;
|
|
17779
|
+
const expandBtn = root.querySelector('button[aria-label="Expand chatbot"]');
|
|
17780
|
+
if (expandBtn) {
|
|
17781
|
+
expandBtn.click();
|
|
17782
|
+
}
|
|
17783
|
+
}, 100);
|
|
17784
|
+
}, []);
|
|
17785
|
+
// Listen for smartBotMaximize events (e.g. from allocation plan card)
|
|
17786
|
+
useEffect(() => {
|
|
17787
|
+
window.addEventListener("smartBotMaximize", expandChatBotIfCollapsed);
|
|
17788
|
+
return () => {
|
|
17789
|
+
window.removeEventListener("smartBotMaximize", expandChatBotIfCollapsed);
|
|
17790
|
+
};
|
|
17791
|
+
}, [expandChatBotIfCollapsed]);
|
|
16827
17792
|
// Auto-collapse to draggable mode when the user interacts outside the bot.
|
|
16828
17793
|
useEffect(() => {
|
|
16829
17794
|
const handleOutsideInteraction = (e) => {
|
|
@@ -16845,6 +17810,9 @@ const SmartBot = (props) => {
|
|
|
16845
17810
|
// Ignore clicks inside the expanded table modal portal
|
|
16846
17811
|
if (e.target.closest?.(".test-modal"))
|
|
16847
17812
|
return;
|
|
17813
|
+
// Ignore clicks inside the allocation detail panel
|
|
17814
|
+
if (e.target.closest?.('[data-testid="allocation-detail-panel"]'))
|
|
17815
|
+
return;
|
|
16848
17816
|
collapseChatBotIfExpanded();
|
|
16849
17817
|
};
|
|
16850
17818
|
document.addEventListener("mousedown", handleOutsideInteraction, true);
|
|
@@ -16971,6 +17939,7 @@ const SmartBot = (props) => {
|
|
|
16971
17939
|
dispatch(setMinimizedStreamData(null));
|
|
16972
17940
|
}
|
|
16973
17941
|
setPartialClose(true);
|
|
17942
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
16974
17943
|
}
|
|
16975
17944
|
},
|
|
16976
17945
|
// assistantChats={assistantChats}
|
|
@@ -17001,7 +17970,8 @@ const SmartBot = (props) => {
|
|
|
17001
17970
|
setChatBotWidth(params);
|
|
17002
17971
|
}, onMinimiseChatBot: () => {
|
|
17003
17972
|
setPartialClose(true);
|
|
17004
|
-
|
|
17973
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
17974
|
+
} })] }), jsx(AllocationDetailPanel, {})] }));
|
|
17005
17975
|
};
|
|
17006
17976
|
|
|
17007
17977
|
export { SmartBot as default };
|