impact-chatbot 3.0.0 → 3.1.1
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/components/skill-upload-modal/index.d.ts +2 -0
- package/dist/index.cjs.js +1188 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1189 -30
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chatbot-services.d.ts +11 -0
- package/package.json +22 -8
package/dist/index.cjs.js
CHANGED
|
@@ -41,10 +41,19 @@ require('highcharts/esm/modules/heatmap.js');
|
|
|
41
41
|
require('highcharts/esm/modules/pareto.js');
|
|
42
42
|
var makeStyles = require('@mui/styles/makeStyles');
|
|
43
43
|
var ChevronRightIcon$1 = require('@mui/icons-material/ChevronRight');
|
|
44
|
+
var DescriptionOutlinedIcon = require('@mui/icons-material/DescriptionOutlined');
|
|
45
|
+
var OpenInNewIcon = require('@mui/icons-material/OpenInNew');
|
|
44
46
|
var FormatListBulletedOutlinedIcon = require('@mui/icons-material/FormatListBulletedOutlined');
|
|
45
47
|
var PsychologyOutlinedIcon = require('@mui/icons-material/PsychologyOutlined');
|
|
46
48
|
var SaveOutlinedIcon = require('@mui/icons-material/SaveOutlined');
|
|
47
49
|
require('react-dates/lib/css/_datepicker.css');
|
|
50
|
+
var reactDom = require('react-dom');
|
|
51
|
+
var VisibilityOutlinedIcon = require('@mui/icons-material/VisibilityOutlined');
|
|
52
|
+
var OpenInFullIcon = require('@mui/icons-material/OpenInFull');
|
|
53
|
+
var CloseFullscreenIcon = require('@mui/icons-material/CloseFullscreen');
|
|
54
|
+
var CloseIcon = require('@mui/icons-material/Close');
|
|
55
|
+
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
|
56
|
+
var ArrowForwardIcon = require('@mui/icons-material/ArrowForward');
|
|
48
57
|
|
|
49
58
|
function _interopNamespaceDefault(e) {
|
|
50
59
|
var n = Object.create(null);
|
|
@@ -774,6 +783,30 @@ const uploadFile = async (payload) => {
|
|
|
774
783
|
return null;
|
|
775
784
|
}
|
|
776
785
|
};
|
|
786
|
+
/** Saves a skill for the signed-in user: its SKILL.md and the files it refers to, each keyed by its path in
|
|
787
|
+
* the skill's folder ({"SKILL.md": text, "references/x.md": text}). The agent checks it as its harness would
|
|
788
|
+
* serve it and answers {name, version, characters, files, missing_files, trigger, trigger_said, turn_on}; a
|
|
789
|
+
* skill it refuses is a 422 whose detail says why. Errors reach the caller, which shows them. */
|
|
790
|
+
const uploadSkill = async (files, baseUrl) => {
|
|
791
|
+
return axiosInstance({
|
|
792
|
+
url: `${baseUrl}/chatbot/agent/skills`,
|
|
793
|
+
method: 'POST',
|
|
794
|
+
data: { files },
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
/** Whether the agent takes skill uploads: its /info answer carries skills.upload beside the cards. Any
|
|
798
|
+
* failure, or an agent that does not say so, is false (no "Upload Skill" item). */
|
|
799
|
+
const fetchSkillUploadOn = async (baseUrl) => {
|
|
800
|
+
try {
|
|
801
|
+
const response = await fetchAgentsInfo(baseUrl);
|
|
802
|
+
const body = response?.data || {};
|
|
803
|
+
return body?.skills?.upload === true || body?.data?.skills?.upload === true;
|
|
804
|
+
}
|
|
805
|
+
catch (error) {
|
|
806
|
+
console.error('fetchSkillUploadOn error:', error);
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
};
|
|
777
810
|
const triggerRefresh = async (baseUrl) => {
|
|
778
811
|
try {
|
|
779
812
|
return httpRequest({
|
|
@@ -833,6 +866,21 @@ const getTableRecords = async (payload, baseUrl, tableName) => {
|
|
|
833
866
|
return null;
|
|
834
867
|
}
|
|
835
868
|
};
|
|
869
|
+
/** A read for a generated surface (frame protocol iui:query): the agent runs one read tool as the signed-in
|
|
870
|
+
* user and answers {rows, total}. */
|
|
871
|
+
const postUiQuery = async (payload, baseUrl) => {
|
|
872
|
+
try {
|
|
873
|
+
return httpRequest({
|
|
874
|
+
url: `${baseUrl}/chatbot/agent/ui-query`,
|
|
875
|
+
method: 'POST',
|
|
876
|
+
data: payload,
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
catch (error) {
|
|
880
|
+
console.error('postUiQuery error:', error);
|
|
881
|
+
return null;
|
|
882
|
+
}
|
|
883
|
+
};
|
|
836
884
|
const getTableRecordsByUrl = async (payload, url) => {
|
|
837
885
|
try {
|
|
838
886
|
return httpRequest({
|
|
@@ -1455,6 +1503,7 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
1455
1503
|
isDisabled: data?.data?.isDisabled,
|
|
1456
1504
|
orientation: data?.data?.orientation,
|
|
1457
1505
|
options: data?.data?.options,
|
|
1506
|
+
defaultSelected: data?.data?.defaultSelected,
|
|
1458
1507
|
paramName: data?.data?.param_name
|
|
1459
1508
|
}
|
|
1460
1509
|
};
|
|
@@ -1534,6 +1583,17 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
1534
1583
|
bodyType: "html",
|
|
1535
1584
|
bodyText: { content: data?.data?.content || "" },
|
|
1536
1585
|
};
|
|
1586
|
+
case "allocation_plan_card":
|
|
1587
|
+
return {
|
|
1588
|
+
...data,
|
|
1589
|
+
timeStamp: timeString,
|
|
1590
|
+
userType: "bot",
|
|
1591
|
+
userName: userName,
|
|
1592
|
+
headerTitle: "",
|
|
1593
|
+
noShowHeaderTitle: true,
|
|
1594
|
+
bodyType: "allocation_plan_card",
|
|
1595
|
+
bodyText: data?.data || data,
|
|
1596
|
+
};
|
|
1537
1597
|
case "image":
|
|
1538
1598
|
return {
|
|
1539
1599
|
...data,
|
|
@@ -1561,6 +1621,18 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
1561
1621
|
thinkingResponse: utilityObject?.thinkingResponse,
|
|
1562
1622
|
enableLikes: true
|
|
1563
1623
|
};
|
|
1624
|
+
case "surface_frame":
|
|
1625
|
+
// A generated UI surface drawn by the UI service's renderer page (Impact UI 5), which SurfaceFrameContent embeds
|
|
1626
|
+
return {
|
|
1627
|
+
...data,
|
|
1628
|
+
agentId: agentId,
|
|
1629
|
+
timeStamp: timeString,
|
|
1630
|
+
userType: "bot",
|
|
1631
|
+
userName: userName,
|
|
1632
|
+
headerTitle: data?.data?.surface?.title || "",
|
|
1633
|
+
bodyType: "surface_frame",
|
|
1634
|
+
bodyText: data?.data,
|
|
1635
|
+
};
|
|
1564
1636
|
default:
|
|
1565
1637
|
return null;
|
|
1566
1638
|
}
|
|
@@ -2823,6 +2895,10 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
2823
2895
|
answer_mode: data?.answerMode || "auto",
|
|
2824
2896
|
...(!isEmpty(utilityObjectData?.additionalArgs) ? utilityObjectData.additionalArgs : {}),
|
|
2825
2897
|
};
|
|
2898
|
+
if (data?.uiContext && typeof data.uiContext === "object") {
|
|
2899
|
+
// a follow-up asked from a generated surface: which surface, and its input values
|
|
2900
|
+
payload.ui_context = data.uiContext;
|
|
2901
|
+
}
|
|
2826
2902
|
// Handle @ filter mentions - user_explicit_input contains filter values
|
|
2827
2903
|
if (!isEmpty(data?.userExplicitInput)) {
|
|
2828
2904
|
payload.user_explicit_input = data?.userExplicitInput;
|
|
@@ -3283,9 +3359,16 @@ const useChatFlow = (chatDataRef, setLoader, setFlowType, setScreenName, setUser
|
|
|
3283
3359
|
else if (data.actionType === "indirect") {
|
|
3284
3360
|
setUserInput(data.displayText);
|
|
3285
3361
|
}
|
|
3286
|
-
else {
|
|
3362
|
+
else if (data.screen_name) {
|
|
3287
3363
|
fetchUserResultsFromQuery(data, true, "", activeConversationId);
|
|
3288
3364
|
}
|
|
3365
|
+
else {
|
|
3366
|
+
// No screen_name (e.g. suggested follow-up chips from navigation-v2):
|
|
3367
|
+
// treat the chip's displayText as a regular user query so it flows
|
|
3368
|
+
// through the navigation streaming endpoint instead of the
|
|
3369
|
+
// fetchRelatedQuestions screen-based endpoint.
|
|
3370
|
+
fetchUserResultsFromQuery(data, false, data.displayText, activeConversationId);
|
|
3371
|
+
}
|
|
3289
3372
|
}, [activeConversationId, baseUrl]);
|
|
3290
3373
|
const fetchUserResultsFromQuery = React.useCallback(async (refObject, fetchQuestions = false, inputValue = userInput, conversationId = activeConversationId) => {
|
|
3291
3374
|
let flowType = refObject?.flow_type ? refObject?.flow_type : currentMode;
|
|
@@ -6017,6 +6100,73 @@ const QuestionsContent = ({ bodyText, props }) => {
|
|
|
6017
6100
|
}) }));
|
|
6018
6101
|
};
|
|
6019
6102
|
|
|
6103
|
+
/**
|
|
6104
|
+
* One widget per generated surface in a stream: the agent may send a surface more than once (a placeholder
|
|
6105
|
+
* while it is composed, `status: "pending"`, version 0; then the surface, version 1; or its withdrawal), and
|
|
6106
|
+
* frame protocol 1 replaces a surface by its id (agent-ui-service-ssr docs/chat-frame-widget.md, rule 4).
|
|
6107
|
+
* No imports: the stream reader (AxiosEventSource) uses it too. Ported from core's smartBot
|
|
6108
|
+
* (insideinsight/core feat/iui-surface, e386f8f0).
|
|
6109
|
+
*/
|
|
6110
|
+
/** A surface's version; one when it gives none. */
|
|
6111
|
+
const surfaceVersion = (surface) => (Number.isFinite(surface?.version) ? surface.version : 1);
|
|
6112
|
+
const surfaceIdOf = (widget) => (widget?.type === "surface_frame" ? widget?.data?.surface?.id : undefined);
|
|
6113
|
+
/** A stream's widgets with these added: a surface_frame widget whose surface the list already holds replaces
|
|
6114
|
+
* it in place (a lower version is dropped); any other widget is added at the end. */
|
|
6115
|
+
const mergeSurfaceWidgets = (previous, incoming) => {
|
|
6116
|
+
const merged = Array.isArray(previous) ? previous.slice() : previous ? [previous] : [];
|
|
6117
|
+
for (const widget of Array.isArray(incoming) ? incoming : [incoming]) {
|
|
6118
|
+
const id = surfaceIdOf(widget);
|
|
6119
|
+
const at = id === undefined ? -1 : merged.findIndex((w) => surfaceIdOf(w) === id);
|
|
6120
|
+
if (at < 0)
|
|
6121
|
+
merged.push(widget);
|
|
6122
|
+
else if (surfaceVersion(widget.data.surface) >= surfaceVersion(merged[at].data.surface))
|
|
6123
|
+
merged[at] = widget;
|
|
6124
|
+
}
|
|
6125
|
+
return merged;
|
|
6126
|
+
};
|
|
6127
|
+
/*
|
|
6128
|
+
* Across the chat's messages (one page per surface): a surface revised in a later turn is shown, newest
|
|
6129
|
+
* version, where that turn put it; each earlier widget of it collapses to a line. Every SurfaceFrameContent
|
|
6130
|
+
* says which version it shows; a widget whose surface another widget shows in a higher version collapses.
|
|
6131
|
+
* Placeholders and withdrawn surfaces take no part. Equal versions (the same surface drawn in two places)
|
|
6132
|
+
* both show.
|
|
6133
|
+
*/
|
|
6134
|
+
const shownVersions = new Map(); // surface id -> Map(widget token -> version)
|
|
6135
|
+
const watchers = new Set();
|
|
6136
|
+
let lastToken = 0;
|
|
6137
|
+
/** A token for one widget. */
|
|
6138
|
+
const surfaceToken = () => {
|
|
6139
|
+
lastToken += 1;
|
|
6140
|
+
return lastToken;
|
|
6141
|
+
};
|
|
6142
|
+
const notify = () => watchers.forEach((watch) => watch());
|
|
6143
|
+
/** This widget shows `version` of surface `id`. */
|
|
6144
|
+
const showSurface = (id, token, version) => {
|
|
6145
|
+
if (!shownVersions.has(id))
|
|
6146
|
+
shownVersions.set(id, new Map());
|
|
6147
|
+
shownVersions.get(id).set(token, version);
|
|
6148
|
+
notify();
|
|
6149
|
+
};
|
|
6150
|
+
/** This widget no longer shows surface `id`. */
|
|
6151
|
+
const hideSurface = (id, token) => {
|
|
6152
|
+
const versions = shownVersions.get(id);
|
|
6153
|
+
if (!versions)
|
|
6154
|
+
return;
|
|
6155
|
+
versions.delete(token);
|
|
6156
|
+
if (versions.size === 0)
|
|
6157
|
+
shownVersions.delete(id);
|
|
6158
|
+
notify();
|
|
6159
|
+
};
|
|
6160
|
+
/** Whether another widget shows surface `id` in a version higher than `version`. */
|
|
6161
|
+
const newerShown = (id, version) => [...(shownVersions.get(id)?.values() ?? [])].some((v) => v > version);
|
|
6162
|
+
/** Calls `watch` whenever a widget starts or stops showing a surface; returns the unsubscribe. */
|
|
6163
|
+
const watchSurfaces = (watch) => {
|
|
6164
|
+
watchers.add(watch);
|
|
6165
|
+
return () => {
|
|
6166
|
+
watchers.delete(watch);
|
|
6167
|
+
};
|
|
6168
|
+
};
|
|
6169
|
+
|
|
6020
6170
|
// Utility: check whether a string is a likely complete JSON value
|
|
6021
6171
|
const isLikelyCompleteJson = (message) => {
|
|
6022
6172
|
try {
|
|
@@ -6224,10 +6374,8 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
6224
6374
|
let previousWidgetData = lodash.isArray(messageToStoreRef.current.appendedData)
|
|
6225
6375
|
? messageToStoreRef.current.appendedData
|
|
6226
6376
|
: [messageToStoreRef.current.appendedData];
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
...finalWidgetData,
|
|
6230
|
-
];
|
|
6377
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
6378
|
+
messageToStoreRef.current.appendedData = mergeSurfaceWidgets(previousWidgetData, finalWidgetData);
|
|
6231
6379
|
messageToStoreRef.current.sessionId = parsedData.session_id;
|
|
6232
6380
|
messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
|
|
6233
6381
|
? parsedData.chat_id
|
|
@@ -6267,10 +6415,8 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
6267
6415
|
let previousWidgetData = lodash.isArray(messageToStoreRef.current.appendedData)
|
|
6268
6416
|
? messageToStoreRef.current.appendedData
|
|
6269
6417
|
: [messageToStoreRef.current.appendedData];
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
...finalWidgetData,
|
|
6273
|
-
];
|
|
6418
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
6419
|
+
messageToStoreRef.current.appendedData = mergeSurfaceWidgets(previousWidgetData, finalWidgetData);
|
|
6274
6420
|
messageToStoreRef.current.additionalArgs = parsedData?.additional_args
|
|
6275
6421
|
? parsedData.additional_args
|
|
6276
6422
|
: {};
|
|
@@ -9177,13 +9323,36 @@ const CheckboxGroupContent = ({ bodyText, isFormDisabled = false, messageIndex }
|
|
|
9177
9323
|
const RadioContent = ({ bodyText, isFormDisabled = false, messageIndex }) => {
|
|
9178
9324
|
const formKey = `${messageIndex}_${bodyText?.paramName}`;
|
|
9179
9325
|
const classes = useStyles$b();
|
|
9180
|
-
const { label, isDisabled, orientation, options } = bodyText;
|
|
9326
|
+
const { label, isDisabled, orientation, options, defaultSelected } = bodyText;
|
|
9181
9327
|
const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
9182
9328
|
const chatbotContextRef = React.useRef(chatbotContext);
|
|
9183
9329
|
chatbotContextRef.current = chatbotContext;
|
|
9184
9330
|
const persistedFormValues = reactRedux.useSelector((state) => state.smartBotReducer.persistedFormValues);
|
|
9185
9331
|
const dispatch = reactRedux.useDispatch();
|
|
9186
|
-
const [selectedOption, setSelectedOption] = React.useState(persistedFormValues[formKey] ?? null);
|
|
9332
|
+
const [selectedOption, setSelectedOption] = React.useState(persistedFormValues[formKey] ?? defaultSelected ?? null);
|
|
9333
|
+
// When a defaultSelected value is provided and nothing was previously persisted,
|
|
9334
|
+
// seed Redux state so submit-validation and context are aware of the pre-selection.
|
|
9335
|
+
// Uses getState inside a thunk to read the latest chatbotContext at dispatch time,
|
|
9336
|
+
// avoiding stale-ref overwrites when multiple radio widgets mount in the same flush.
|
|
9337
|
+
React.useEffect(() => {
|
|
9338
|
+
if (defaultSelected && !persistedFormValues[formKey]) {
|
|
9339
|
+
dispatch((dispatchAction, getState) => {
|
|
9340
|
+
const currentContext = getState().smartBotReducer.chatbotContext;
|
|
9341
|
+
dispatchAction({
|
|
9342
|
+
type: "SET_CHATBOT_CONTEXT",
|
|
9343
|
+
payload: {
|
|
9344
|
+
...currentContext,
|
|
9345
|
+
[bodyText?.paramName]: {
|
|
9346
|
+
...currentContext?.[bodyText?.paramName],
|
|
9347
|
+
[bodyText?.paramName]: defaultSelected,
|
|
9348
|
+
updated: true,
|
|
9349
|
+
},
|
|
9350
|
+
},
|
|
9351
|
+
});
|
|
9352
|
+
});
|
|
9353
|
+
dispatch(setPersistedFormValues({ [formKey]: defaultSelected }));
|
|
9354
|
+
}
|
|
9355
|
+
}, []);
|
|
9187
9356
|
if (lodash.isEmpty(bodyText))
|
|
9188
9357
|
return null;
|
|
9189
9358
|
const handleChange = (selectedOption) => {
|
|
@@ -9261,6 +9430,183 @@ const ImageContent = ({ bodyText }) => {
|
|
|
9261
9430
|
} })), caption && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(TextRenderer, { text: caption }) }))] }));
|
|
9262
9431
|
};
|
|
9263
9432
|
|
|
9433
|
+
const SUBMIT = { buttons: [{ label: "Submit", variant: "primary" }] };
|
|
9434
|
+
/** A follow-up's limits: longer ones are ignored. */
|
|
9435
|
+
const PROMPT_TEXT_MAX = 1000;
|
|
9436
|
+
const PROMPT_CONTEXT_MAX = 16000;
|
|
9437
|
+
/** The window event the chat listens to for a follow-up asked from a surface. */
|
|
9438
|
+
const PROMPT_EVENT = "iris:prompt";
|
|
9439
|
+
/** The source a surface names for this temp table, if it names it: the only tables its page may ask pages
|
|
9440
|
+
* of, and the endpoint address the agent gave (the page's own copy of the source is not trusted for it). */
|
|
9441
|
+
const sourceOf = (surface, table) => Object.values(surface?.data || {}).map((entry) => entry?.source).find((source) => typeof source?.table === "string" && source.table === table);
|
|
9442
|
+
/** Whether the surface binds this tool: the only tools its page may ask to read again. */
|
|
9443
|
+
const bindsTool = (surface, tool) => typeof tool === "string" && tool !== "rows" && Object.values(surface?.data || {}).some((entry) => entry?.tool === tool);
|
|
9444
|
+
const baseUrl = () => sessionStorage.getItem("stepForm_baseUrl") || "";
|
|
9445
|
+
/** One page of a source, from the agent's paging endpoint (its pages hold at most 10 rows): at the address
|
|
9446
|
+
* the agent gave, as TableContent does with temp_table_url, else under the stream's base URL. `search`: a
|
|
9447
|
+
* filter Control over the kept rows (catalog 0.3), each `{field, value}` an exact match the endpoint applies. */
|
|
9448
|
+
const pageOf = async ({ source, page, pageSize, sort, search }) => {
|
|
9449
|
+
const payload = {
|
|
9450
|
+
limit: { page, page_size: pageSize },
|
|
9451
|
+
search: (Array.isArray(search) ? search : [])
|
|
9452
|
+
.filter((s) => s && typeof s.field === "string" && s.value !== undefined && s.value !== null)
|
|
9453
|
+
.slice(0, 5)
|
|
9454
|
+
.map((s) => ({ column: s.field, pattern: String(s.value), search_type: "equals" })),
|
|
9455
|
+
sort: (Array.isArray(sort) ? sort : []).map((s) => ({ column: s.field, order: s.order === "desc" ? "desc" : "asc" })),
|
|
9456
|
+
};
|
|
9457
|
+
const response = source.url
|
|
9458
|
+
? await getTableRecordsByUrl(payload, source.url)
|
|
9459
|
+
: await getTableRecords(payload, baseUrl(), source.table);
|
|
9460
|
+
const rows = response?.data?.data;
|
|
9461
|
+
const total = response?.data?.total_count;
|
|
9462
|
+
if (!Array.isArray(rows) || !Number.isFinite(total))
|
|
9463
|
+
throw new Error("no rows");
|
|
9464
|
+
return { rows, total };
|
|
9465
|
+
};
|
|
9466
|
+
/** A read tool the surface binds, run again by the agent with these arguments. */
|
|
9467
|
+
const readOf = async ({ surface, tool, args }) => {
|
|
9468
|
+
const response = await postUiQuery({ surface, tool, args: args && typeof args === "object" ? args : {} }, baseUrl());
|
|
9469
|
+
const rows = response?.data?.rows;
|
|
9470
|
+
const total = response?.data?.total;
|
|
9471
|
+
if (!Array.isArray(rows) || !Number.isFinite(total))
|
|
9472
|
+
throw new Error(response?.data?.error || "no rows");
|
|
9473
|
+
return { rows, total };
|
|
9474
|
+
};
|
|
9475
|
+
/** The page's origin, for http(s) addresses only; anything else is refused. */
|
|
9476
|
+
const frameOrigin = (src) => {
|
|
9477
|
+
try {
|
|
9478
|
+
const url = new URL(src, window.location.href);
|
|
9479
|
+
return url.protocol === "https:" || url.protocol === "http:" ? url.origin : null;
|
|
9480
|
+
}
|
|
9481
|
+
catch {
|
|
9482
|
+
return null;
|
|
9483
|
+
}
|
|
9484
|
+
};
|
|
9485
|
+
/** A follow-up within the limits, or null. */
|
|
9486
|
+
const promptOf = (data, surfaceId) => {
|
|
9487
|
+
const text = typeof data?.text === "string" ? data.text.trim() : "";
|
|
9488
|
+
const context = data?.context && typeof data.context === "object" ? { ...data.context, surface: surfaceId } : { surface: surfaceId };
|
|
9489
|
+
let size = Infinity;
|
|
9490
|
+
try {
|
|
9491
|
+
size = JSON.stringify(context).length;
|
|
9492
|
+
}
|
|
9493
|
+
catch {
|
|
9494
|
+
// a context that cannot be sent is not sent
|
|
9495
|
+
}
|
|
9496
|
+
if (!text || text.length > PROMPT_TEXT_MAX || size > PROMPT_CONTEXT_MAX)
|
|
9497
|
+
return null;
|
|
9498
|
+
return { text, uiContext: context };
|
|
9499
|
+
};
|
|
9500
|
+
const SurfaceFrameContent = ({ frame, isFormDisabled = false, messageIndex = 0 }) => {
|
|
9501
|
+
const dispatch = reactRedux.useDispatch();
|
|
9502
|
+
const chatbotContext = reactRedux.useSelector((state) => state.smartBotReducer.chatbotContext);
|
|
9503
|
+
const contextRef = React.useRef(chatbotContext);
|
|
9504
|
+
contextRef.current = chatbotContext;
|
|
9505
|
+
const iframeRef = React.useRef(null);
|
|
9506
|
+
const ready = React.useRef(false);
|
|
9507
|
+
const [height, setHeight] = React.useState(120);
|
|
9508
|
+
const [form, setForm] = React.useState({ values: {}, inputs: [], missing: [] });
|
|
9509
|
+
const formRef = React.useRef(form);
|
|
9510
|
+
formRef.current = form;
|
|
9511
|
+
const src = frame?.src;
|
|
9512
|
+
const incoming = frame?.surface;
|
|
9513
|
+
// the surface shown: a newer version of the same surface replaces it, a lower one is ignored
|
|
9514
|
+
const [surface, setSurface] = React.useState(incoming);
|
|
9515
|
+
React.useEffect(() => {
|
|
9516
|
+
if (incoming && (!surface || incoming.id !== surface.id || surfaceVersion(incoming) >= surfaceVersion(surface)))
|
|
9517
|
+
setSurface(incoming);
|
|
9518
|
+
}, [incoming]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9519
|
+
const origin = React.useMemo(() => frameOrigin(src), [src]);
|
|
9520
|
+
const ask = surface?.mode === "ask";
|
|
9521
|
+
// which version of its surface each widget shows, across the chat's messages
|
|
9522
|
+
const token = React.useRef(null);
|
|
9523
|
+
if (token.current === null)
|
|
9524
|
+
token.current = surfaceToken();
|
|
9525
|
+
const [, setShownChange] = React.useState(0);
|
|
9526
|
+
React.useEffect(() => watchSurfaces(() => setShownChange((n) => n + 1)), []);
|
|
9527
|
+
React.useEffect(() => {
|
|
9528
|
+
if (!surface?.id || surface.status === "pending" || surface.status === "withdrawn")
|
|
9529
|
+
return undefined;
|
|
9530
|
+
showSurface(surface.id, token.current, surfaceVersion(surface));
|
|
9531
|
+
return () => hideSurface(surface.id, token.current);
|
|
9532
|
+
}, [surface?.id, surface?.version, surface?.status]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9533
|
+
const send = (target, values) => target?.postMessage({ type: "iui:surface", surface, values, disabled: Boolean(isFormDisabled), query: true, ...(ask ? { submit: false } : {}) }, origin);
|
|
9534
|
+
React.useEffect(() => {
|
|
9535
|
+
if (!origin || !surface)
|
|
9536
|
+
return undefined;
|
|
9537
|
+
const onMessage = (event) => {
|
|
9538
|
+
const target = iframeRef.current?.contentWindow;
|
|
9539
|
+
if (!target || event.source !== target || event.origin !== origin)
|
|
9540
|
+
return;
|
|
9541
|
+
const data = event.data || {};
|
|
9542
|
+
// every message but iui:ready and iui:height names its surface: this widget answers for its own only
|
|
9543
|
+
const own = data.surface === undefined || data.surface === surface.id;
|
|
9544
|
+
if (data.type === "iui:ready") {
|
|
9545
|
+
ready.current = true;
|
|
9546
|
+
send(target, undefined);
|
|
9547
|
+
}
|
|
9548
|
+
else if (data.type === "iui:height" && Number.isFinite(data.height))
|
|
9549
|
+
setHeight(Math.max(40, Math.ceil(data.height)));
|
|
9550
|
+
else if (data.type === "iui:query" && own) {
|
|
9551
|
+
const reply = (body) => target.postMessage({ type: "iui:data", surface: surface.id, id: data.id, ...body }, origin);
|
|
9552
|
+
const args = data.args || {};
|
|
9553
|
+
if (data.tool === "rows") {
|
|
9554
|
+
const source = sourceOf(surface, args.source?.table);
|
|
9555
|
+
if (!source)
|
|
9556
|
+
reply({ error: "not a table of this answer" });
|
|
9557
|
+
else
|
|
9558
|
+
pageOf({ ...args, source }).then(reply, () => reply({ error: "the rows could not be loaded" }));
|
|
9559
|
+
}
|
|
9560
|
+
else if (bindsTool(surface, data.tool)) {
|
|
9561
|
+
readOf({ surface: surface.id, tool: data.tool, args }).then(reply, () => reply({ error: "the data could not be loaded" }));
|
|
9562
|
+
}
|
|
9563
|
+
else
|
|
9564
|
+
reply({ error: "not a tool of this answer" });
|
|
9565
|
+
}
|
|
9566
|
+
else if (data.type === "iui:prompt" && data.surface === surface.id) {
|
|
9567
|
+
const prompt = promptOf(data, surface.id);
|
|
9568
|
+
if (prompt)
|
|
9569
|
+
window.dispatchEvent(new CustomEvent(PROMPT_EVENT, { detail: prompt }));
|
|
9570
|
+
}
|
|
9571
|
+
else if (data.type === "iui:change" && ask && own) {
|
|
9572
|
+
const values = data.values || {};
|
|
9573
|
+
setForm({ values, inputs: Array.isArray(data.inputs) ? data.inputs : Object.keys(values), missing: Array.isArray(data.missing) ? data.missing : [] });
|
|
9574
|
+
// as this chat's own inputs record their values, for the step form's Submit (ButtonContent)
|
|
9575
|
+
const context = { ...contextRef.current };
|
|
9576
|
+
for (const [name, value] of Object.entries(values)) {
|
|
9577
|
+
const empty = value === "" || value === null || value === undefined || (Array.isArray(value) && value.length === 0);
|
|
9578
|
+
context[name] = { ...context[name], [name]: value, updated: !empty };
|
|
9579
|
+
}
|
|
9580
|
+
dispatch(setChatbotContext(context));
|
|
9581
|
+
// only what was filled in: ButtonContent sends a persisted value even when it is empty
|
|
9582
|
+
const filled = Object.entries(values).filter(([name]) => context[name].updated);
|
|
9583
|
+
dispatch(setPersistedFormValues(Object.fromEntries(filled.map(([name, value]) => [`${messageIndex}_${name}`, value]))));
|
|
9584
|
+
}
|
|
9585
|
+
// anything else: a message type this chat does not know, ignored
|
|
9586
|
+
};
|
|
9587
|
+
window.addEventListener("message", onMessage);
|
|
9588
|
+
return () => window.removeEventListener("message", onMessage);
|
|
9589
|
+
}, [origin, surface, isFormDisabled, ask, messageIndex]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9590
|
+
// a newer version of the surface goes into the page that shows it
|
|
9591
|
+
React.useEffect(() => {
|
|
9592
|
+
if (ready.current)
|
|
9593
|
+
send(iframeRef.current?.contentWindow, undefined);
|
|
9594
|
+
}, [surface]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9595
|
+
// a submitted form is posted again, disabled, with what was filled in
|
|
9596
|
+
React.useEffect(() => {
|
|
9597
|
+
if (isFormDisabled && ask)
|
|
9598
|
+
send(iframeRef.current?.contentWindow, formRef.current.values);
|
|
9599
|
+
}, [isFormDisabled]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9600
|
+
// a surface that will not come after all (its composition failed): nothing to draw
|
|
9601
|
+
if (!origin || !surface || surface.status === "withdrawn")
|
|
9602
|
+
return null;
|
|
9603
|
+
// a later message shows this surface revised: one line here, the surface there
|
|
9604
|
+
if (newerShown(surface.id, surfaceVersion(surface))) {
|
|
9605
|
+
return (jsxRuntime.jsx(material.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}` : ""}.` }));
|
|
9606
|
+
}
|
|
9607
|
+
return (jsxRuntime.jsxs(material.Box, { "data-iui-host": "surface-frame", my: 1, children: [jsxRuntime.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 ? (jsxRuntime.jsx(ButtonContent, { bodyText: SUBMIT, isFormDisabled: isFormDisabled, isStepFormSubmit: true, isFormValid: form.inputs.length > 0 && form.missing.length === 0, formParamNames: form.inputs, messageIndex: messageIndex })) : null] }));
|
|
9608
|
+
};
|
|
9609
|
+
|
|
9264
9610
|
// Key used to persist timeout state in sessionStorage (survives component remounts from tab switches)
|
|
9265
9611
|
const STEP_FORM_TIMEOUT_KEY = "__stepFormTimedOut";
|
|
9266
9612
|
/**
|
|
@@ -9690,11 +10036,17 @@ const StepFormContent = ({ formData, messageIndex = 0, isFormDisabled = false, s
|
|
|
9690
10036
|
case "radio":
|
|
9691
10037
|
return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
9692
10038
|
case "button":
|
|
10039
|
+
// A form in the renderer page has its Submit drawn by SurfaceFrameContent, which knows the page's inputs
|
|
10040
|
+
if (formData.some((item) => item?.type === "surface_frame"))
|
|
10041
|
+
return null;
|
|
9693
10042
|
return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, isStepFormSubmit: true, isFormValid: requiredFieldsFilled && checkboxGroupsValid, formParamNames: formParamNames, messageIndex: messageIndex }, key);
|
|
9694
10043
|
case "input":
|
|
9695
10044
|
return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText, isFormDisabled: formFieldsDisabled, messageIndex: messageIndex }, key);
|
|
9696
10045
|
case "image":
|
|
9697
10046
|
return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
10047
|
+
case "surface_frame":
|
|
10048
|
+
// The whole form in the renderer page; the widget draws this form's Submit (its inputs are in the page)
|
|
10049
|
+
return jsxRuntime.jsx(SurfaceFrameContent, { frame: parsedData.bodyText, isFormDisabled: isFormDisabled || isFormSubmitted || isTimedOut, messageIndex: messageIndex }, parsedData.bodyText?.surface?.id || key);
|
|
9698
10050
|
default:
|
|
9699
10051
|
return null;
|
|
9700
10052
|
}
|
|
@@ -10090,7 +10442,7 @@ const ProgressBarItem$1 = ({ question, questionSteps, isLast, classes, formData,
|
|
|
10090
10442
|
const [isExpanded, setIsExpanded] = React.useState(true);
|
|
10091
10443
|
const dotClass = status === "completed"
|
|
10092
10444
|
? "completed"
|
|
10093
|
-
: status === "in-progress"
|
|
10445
|
+
: status === "in-progress" || status === "not-started"
|
|
10094
10446
|
? "in-progress"
|
|
10095
10447
|
: status === "error"
|
|
10096
10448
|
? "error"
|
|
@@ -10211,6 +10563,479 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
|
|
|
10211
10563
|
}, children: jsxRuntime.jsx(ProgressBarItem$1, { question: "Thinking", questionSteps: [{ header: "", sub_header: "", step_status: "not-completed" }], isLast: true, classes: classes, formData: null, isFormDisabled: isFormDisabled }) }))] }));
|
|
10212
10564
|
};
|
|
10213
10565
|
|
|
10566
|
+
const useAllocationPanelStyles = styles.makeStyles((theme) => ({
|
|
10567
|
+
// AllocationPlanCard styles (inside chatbot)
|
|
10568
|
+
planCard: {
|
|
10569
|
+
border: "1.5px solid #e2e8f0",
|
|
10570
|
+
borderRadius: "14px",
|
|
10571
|
+
padding: "14px 16px",
|
|
10572
|
+
display: "flex",
|
|
10573
|
+
alignItems: "center",
|
|
10574
|
+
gap: "14px",
|
|
10575
|
+
cursor: "pointer",
|
|
10576
|
+
position: "relative",
|
|
10577
|
+
overflow: "hidden",
|
|
10578
|
+
transition: "border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease",
|
|
10579
|
+
background: "#fafbff",
|
|
10580
|
+
"&:hover": {
|
|
10581
|
+
borderColor: "#b4beff",
|
|
10582
|
+
boxShadow: "0 2px 12px rgba(66, 89, 238, 0.10)",
|
|
10583
|
+
background: "linear-gradient(135deg, #f5f7ff 0%, #eef1ff 60%, #e8ecff 100%)",
|
|
10584
|
+
},
|
|
10585
|
+
},
|
|
10586
|
+
planCardIcon: {
|
|
10587
|
+
width: "48px",
|
|
10588
|
+
height: "48px",
|
|
10589
|
+
borderRadius: "12px",
|
|
10590
|
+
background: "linear-gradient(135deg, #e8edff 0%, #dbe1ff 100%)",
|
|
10591
|
+
display: "flex",
|
|
10592
|
+
alignItems: "center",
|
|
10593
|
+
justifyContent: "center",
|
|
10594
|
+
flexShrink: 0,
|
|
10595
|
+
"& svg": {
|
|
10596
|
+
color: "#4259EE",
|
|
10597
|
+
fontSize: "22px",
|
|
10598
|
+
},
|
|
10599
|
+
},
|
|
10600
|
+
planCardContent: {
|
|
10601
|
+
flex: 1,
|
|
10602
|
+
minWidth: 0,
|
|
10603
|
+
},
|
|
10604
|
+
planCardTitle: {
|
|
10605
|
+
fontSize: "14px",
|
|
10606
|
+
fontWeight: 700,
|
|
10607
|
+
color: "#1e293b",
|
|
10608
|
+
lineHeight: 1.4,
|
|
10609
|
+
marginBottom: "4px",
|
|
10610
|
+
},
|
|
10611
|
+
planCardLinks: {
|
|
10612
|
+
display: "flex",
|
|
10613
|
+
alignItems: "center",
|
|
10614
|
+
gap: "4px",
|
|
10615
|
+
flexWrap: "wrap",
|
|
10616
|
+
fontSize: "13px",
|
|
10617
|
+
color: "#64748b",
|
|
10618
|
+
},
|
|
10619
|
+
planCardLink: {
|
|
10620
|
+
color: "#64748b",
|
|
10621
|
+
cursor: "pointer",
|
|
10622
|
+
textDecoration: "none",
|
|
10623
|
+
transition: "color 0.2s ease",
|
|
10624
|
+
"&:hover": {
|
|
10625
|
+
color: "#4259EE",
|
|
10626
|
+
},
|
|
10627
|
+
},
|
|
10628
|
+
planCardLinkSeparator: {
|
|
10629
|
+
color: "#94a3b8",
|
|
10630
|
+
margin: "0 3px",
|
|
10631
|
+
},
|
|
10632
|
+
planCardOpenIcon: {
|
|
10633
|
+
flexShrink: 0,
|
|
10634
|
+
color: "#94a3b8",
|
|
10635
|
+
fontSize: "20px !important",
|
|
10636
|
+
padding: "6px",
|
|
10637
|
+
borderRadius: "8px",
|
|
10638
|
+
border: "1px solid #e2e8f0",
|
|
10639
|
+
background: "#ffffff",
|
|
10640
|
+
transition: "border-color 0.25s ease, color 0.25s ease",
|
|
10641
|
+
"$planCard:hover &": {
|
|
10642
|
+
borderColor: "#b4beff",
|
|
10643
|
+
color: "#4259EE",
|
|
10644
|
+
},
|
|
10645
|
+
},
|
|
10646
|
+
|
|
10647
|
+
// PanelHeader styles
|
|
10648
|
+
panelHeader: {
|
|
10649
|
+
display: "flex",
|
|
10650
|
+
alignItems: "center",
|
|
10651
|
+
justifyContent: "space-between",
|
|
10652
|
+
padding: "16px",
|
|
10653
|
+
borderBottom: "1px solid #f0f0f0",
|
|
10654
|
+
flexShrink: 0,
|
|
10655
|
+
},
|
|
10656
|
+
panelHeaderLeft: {
|
|
10657
|
+
display: "flex",
|
|
10658
|
+
alignItems: "center",
|
|
10659
|
+
gap: "8px",
|
|
10660
|
+
flex: 1,
|
|
10661
|
+
minWidth: 0,
|
|
10662
|
+
},
|
|
10663
|
+
panelHeaderIcon: {
|
|
10664
|
+
color: "#666",
|
|
10665
|
+
fontSize: "20px",
|
|
10666
|
+
cursor: "pointer",
|
|
10667
|
+
},
|
|
10668
|
+
panelTitle: {
|
|
10669
|
+
fontSize: "14px",
|
|
10670
|
+
fontWeight: 600,
|
|
10671
|
+
color: "#1a1a1a",
|
|
10672
|
+
lineHeight: 1.4,
|
|
10673
|
+
overflow: "hidden",
|
|
10674
|
+
textOverflow: "ellipsis",
|
|
10675
|
+
whiteSpace: "nowrap",
|
|
10676
|
+
},
|
|
10677
|
+
panelHeaderActions: {
|
|
10678
|
+
display: "flex",
|
|
10679
|
+
alignItems: "center",
|
|
10680
|
+
gap: "6px",
|
|
10681
|
+
flexShrink: 0,
|
|
10682
|
+
},
|
|
10683
|
+
panelHeaderActionBtn: {
|
|
10684
|
+
width: "28px !important",
|
|
10685
|
+
height: "28px !important",
|
|
10686
|
+
borderRadius: "8px !important",
|
|
10687
|
+
background: "#f1f5f9 !important",
|
|
10688
|
+
color: "#475569 !important",
|
|
10689
|
+
padding: "0 !important",
|
|
10690
|
+
"&:hover": {
|
|
10691
|
+
background: "#e2e8f0 !important",
|
|
10692
|
+
color: "#1e293b !important",
|
|
10693
|
+
},
|
|
10694
|
+
},
|
|
10695
|
+
|
|
10696
|
+
// ReportSummaryCard styles
|
|
10697
|
+
reportSummaryCard: {
|
|
10698
|
+
border: "1px solid #f0c36d",
|
|
10699
|
+
borderRadius: "8px",
|
|
10700
|
+
padding: "14px",
|
|
10701
|
+
margin: "16px 0",
|
|
10702
|
+
background: "#fffdf5",
|
|
10703
|
+
},
|
|
10704
|
+
reportBadge: {
|
|
10705
|
+
display: "inline-block",
|
|
10706
|
+
fontSize: "11px",
|
|
10707
|
+
fontWeight: 500,
|
|
10708
|
+
padding: "3px 8px",
|
|
10709
|
+
borderRadius: "4px",
|
|
10710
|
+
marginBottom: "8px",
|
|
10711
|
+
border: "1px solid #f0c36d",
|
|
10712
|
+
color: "#8b6914",
|
|
10713
|
+
background: "transparent",
|
|
10714
|
+
},
|
|
10715
|
+
reportDescription: {
|
|
10716
|
+
fontSize: "12px",
|
|
10717
|
+
lineHeight: 1.6,
|
|
10718
|
+
color: "#333",
|
|
10719
|
+
marginBottom: "10px",
|
|
10720
|
+
},
|
|
10721
|
+
baselinePlanRow: {
|
|
10722
|
+
fontSize: "12px",
|
|
10723
|
+
color: "#666",
|
|
10724
|
+
display: "flex",
|
|
10725
|
+
alignItems: "center",
|
|
10726
|
+
gap: "4px",
|
|
10727
|
+
},
|
|
10728
|
+
baselinePlanLink: {
|
|
10729
|
+
color: "#2563eb",
|
|
10730
|
+
textDecoration: "underline",
|
|
10731
|
+
cursor: "pointer",
|
|
10732
|
+
wordBreak: "break-all",
|
|
10733
|
+
},
|
|
10734
|
+
|
|
10735
|
+
// PanelSection (Accordion) styles
|
|
10736
|
+
sectionAccordion: {
|
|
10737
|
+
boxShadow: "none !important",
|
|
10738
|
+
border: "none !important",
|
|
10739
|
+
borderRadius: "12px !important",
|
|
10740
|
+
marginBottom: "10px !important",
|
|
10741
|
+
background: "#f8fafc !important",
|
|
10742
|
+
"&:before": {
|
|
10743
|
+
display: "none !important",
|
|
10744
|
+
content: "none !important",
|
|
10745
|
+
background: "none !important",
|
|
10746
|
+
width: "0 !important",
|
|
10747
|
+
height: "0 !important",
|
|
10748
|
+
},
|
|
10749
|
+
"&.Mui-expanded": {
|
|
10750
|
+
margin: "0 0 10px 0 !important",
|
|
10751
|
+
background: "#ffffff !important",
|
|
10752
|
+
boxShadow: "0 1px 8px rgba(0, 0, 0, 0.06) !important",
|
|
10753
|
+
border: "1px solid #e2e8f0 !important",
|
|
10754
|
+
},
|
|
10755
|
+
},
|
|
10756
|
+
sectionSummary: {
|
|
10757
|
+
minHeight: "48px !important",
|
|
10758
|
+
padding: "0 16px !important",
|
|
10759
|
+
border: "none !important",
|
|
10760
|
+
flexDirection: "row-reverse !important",
|
|
10761
|
+
gap: "10px",
|
|
10762
|
+
"&:before": {
|
|
10763
|
+
display: "none !important",
|
|
10764
|
+
content: "none !important",
|
|
10765
|
+
background: "none !important",
|
|
10766
|
+
width: "0 !important",
|
|
10767
|
+
height: "0 !important",
|
|
10768
|
+
},
|
|
10769
|
+
"& .MuiAccordionSummary-content": {
|
|
10770
|
+
margin: "12px 0 !important",
|
|
10771
|
+
},
|
|
10772
|
+
"& .MuiAccordionSummary-expandIconWrapper": {
|
|
10773
|
+
color: "#64748b",
|
|
10774
|
+
transform: "rotate(-90deg)",
|
|
10775
|
+
padding: "0 !important",
|
|
10776
|
+
marginRight: "0 !important",
|
|
10777
|
+
"&.Mui-expanded": {
|
|
10778
|
+
transform: "rotate(0deg)",
|
|
10779
|
+
},
|
|
10780
|
+
},
|
|
10781
|
+
},
|
|
10782
|
+
sectionTitle: {
|
|
10783
|
+
fontSize: "14px",
|
|
10784
|
+
fontWeight: 600,
|
|
10785
|
+
color: "#1e293b",
|
|
10786
|
+
},
|
|
10787
|
+
sectionDetails: {
|
|
10788
|
+
padding: "0 16px 16px !important",
|
|
10789
|
+
border: "none !important",
|
|
10790
|
+
"&:before": {
|
|
10791
|
+
display: "none !important",
|
|
10792
|
+
content: "none !important",
|
|
10793
|
+
background: "none !important",
|
|
10794
|
+
width: "0 !important",
|
|
10795
|
+
height: "0 !important",
|
|
10796
|
+
},
|
|
10797
|
+
},
|
|
10798
|
+
|
|
10799
|
+
// StructuredComparison styles
|
|
10800
|
+
comparisonSubtitle: {
|
|
10801
|
+
fontSize: "12px",
|
|
10802
|
+
color: "#666",
|
|
10803
|
+
marginBottom: "12px",
|
|
10804
|
+
lineHeight: 1.5,
|
|
10805
|
+
},
|
|
10806
|
+
scenarioLabel: {
|
|
10807
|
+
fontSize: "12px",
|
|
10808
|
+
fontWeight: 500,
|
|
10809
|
+
color: "#1a1a1a",
|
|
10810
|
+
padding: "8px 12px",
|
|
10811
|
+
background: "#f8f9fa",
|
|
10812
|
+
borderRadius: "6px",
|
|
10813
|
+
marginBottom: "12px",
|
|
10814
|
+
},
|
|
10815
|
+
comparisonCard: {
|
|
10816
|
+
background: "#f8f9fa",
|
|
10817
|
+
borderRadius: "8px",
|
|
10818
|
+
padding: "12px",
|
|
10819
|
+
marginBottom: "10px",
|
|
10820
|
+
},
|
|
10821
|
+
comparisonParamRow: {
|
|
10822
|
+
display: "flex",
|
|
10823
|
+
alignItems: "center",
|
|
10824
|
+
gap: "8px",
|
|
10825
|
+
marginBottom: "10px",
|
|
10826
|
+
},
|
|
10827
|
+
comparisonParamName: {
|
|
10828
|
+
fontSize: "13px",
|
|
10829
|
+
fontWeight: 600,
|
|
10830
|
+
color: "#1a1a1a",
|
|
10831
|
+
},
|
|
10832
|
+
comparisonTag: {
|
|
10833
|
+
display: "inline-block",
|
|
10834
|
+
fontSize: "10px",
|
|
10835
|
+
fontWeight: 500,
|
|
10836
|
+
padding: "2px 6px",
|
|
10837
|
+
borderRadius: "4px",
|
|
10838
|
+
color: "#2563eb",
|
|
10839
|
+
border: "1px solid #bfdbfe",
|
|
10840
|
+
background: "#eff6ff",
|
|
10841
|
+
},
|
|
10842
|
+
comparisonValues: {
|
|
10843
|
+
display: "flex",
|
|
10844
|
+
alignItems: "center",
|
|
10845
|
+
gap: "8px",
|
|
10846
|
+
},
|
|
10847
|
+
comparisonValueBox: {
|
|
10848
|
+
flex: 1,
|
|
10849
|
+
background: theme.palette.common.white,
|
|
10850
|
+
borderRadius: "6px",
|
|
10851
|
+
padding: "8px 10px",
|
|
10852
|
+
border: "1px solid #e8e8e8",
|
|
10853
|
+
},
|
|
10854
|
+
comparisonValueLabel: {
|
|
10855
|
+
fontSize: "10px",
|
|
10856
|
+
color: "#999",
|
|
10857
|
+
marginBottom: "2px",
|
|
10858
|
+
},
|
|
10859
|
+
comparisonValueText: {
|
|
10860
|
+
fontSize: "12px",
|
|
10861
|
+
fontWeight: 600,
|
|
10862
|
+
color: "#1a1a1a",
|
|
10863
|
+
},
|
|
10864
|
+
comparisonArrow: {
|
|
10865
|
+
color: "#999",
|
|
10866
|
+
fontSize: "16px",
|
|
10867
|
+
flexShrink: 0,
|
|
10868
|
+
},
|
|
10869
|
+
|
|
10870
|
+
// Panel-specific HTML content wrapper (font size/line-height for panel context)
|
|
10871
|
+
panelHtmlContainer: {
|
|
10872
|
+
fontSize: "12px",
|
|
10873
|
+
lineHeight: 1.6,
|
|
10874
|
+
},
|
|
10875
|
+
|
|
10876
|
+
// Slide-in keyframes for panel entry
|
|
10877
|
+
"@keyframes panelSlideIn": {
|
|
10878
|
+
"0%": {
|
|
10879
|
+
transform: "translateX(100%)",
|
|
10880
|
+
opacity: 0,
|
|
10881
|
+
},
|
|
10882
|
+
"100%": {
|
|
10883
|
+
transform: "translateX(0)",
|
|
10884
|
+
opacity: 1,
|
|
10885
|
+
},
|
|
10886
|
+
},
|
|
10887
|
+
// AllocationDetailPanel container (portaled)
|
|
10888
|
+
panelContainer: {
|
|
10889
|
+
position: "fixed",
|
|
10890
|
+
top: 56,
|
|
10891
|
+
right: 0,
|
|
10892
|
+
width: "calc(50vw - 32px)",
|
|
10893
|
+
maxWidth: "520px",
|
|
10894
|
+
height: "calc(100vh - 56px)",
|
|
10895
|
+
zIndex: 99999,
|
|
10896
|
+
display: "flex",
|
|
10897
|
+
flexDirection: "column",
|
|
10898
|
+
background: "#ffffff",
|
|
10899
|
+
boxShadow: "-4px 0 16px rgba(0, 0, 0, 0.15)",
|
|
10900
|
+
borderLeft: "1px solid #e8e8e8",
|
|
10901
|
+
borderRadius: "12px 0 0 12px",
|
|
10902
|
+
overflow: "hidden",
|
|
10903
|
+
animation: "$panelSlideIn 0.3s ease forwards",
|
|
10904
|
+
transition: "width 0.3s ease, max-width 0.3s ease, border-radius 0.3s ease",
|
|
10905
|
+
},
|
|
10906
|
+
// Expanded / maximized panel — covers the chatbot area too
|
|
10907
|
+
panelExpanded: {
|
|
10908
|
+
width: "calc(100vw - 4rem)",
|
|
10909
|
+
maxWidth: "calc(100vw - 4rem)",
|
|
10910
|
+
borderRadius: "0",
|
|
10911
|
+
},
|
|
10912
|
+
panelScrollBody: {
|
|
10913
|
+
flex: 1,
|
|
10914
|
+
overflowY: "auto",
|
|
10915
|
+
padding: "0 16px 24px",
|
|
10916
|
+
},
|
|
10917
|
+
|
|
10918
|
+
// Footer
|
|
10919
|
+
panelFooter: {
|
|
10920
|
+
display: "flex",
|
|
10921
|
+
justifyContent: "flex-end",
|
|
10922
|
+
alignItems: "center",
|
|
10923
|
+
gap: "10px",
|
|
10924
|
+
padding: "12px 16px",
|
|
10925
|
+
borderTop: "1px solid #e2e8f0",
|
|
10926
|
+
background: "#ffffff",
|
|
10927
|
+
flexShrink: 0,
|
|
10928
|
+
position: "relative",
|
|
10929
|
+
},
|
|
10930
|
+
footerBtnOutlined: {
|
|
10931
|
+
display: "inline-flex",
|
|
10932
|
+
alignItems: "center",
|
|
10933
|
+
justifyContent: "center",
|
|
10934
|
+
height: "32px",
|
|
10935
|
+
padding: "0 12px",
|
|
10936
|
+
fontSize: "14px",
|
|
10937
|
+
fontWeight: 600,
|
|
10938
|
+
fontFamily: "Manrope, sans-serif",
|
|
10939
|
+
lineHeight: 1,
|
|
10940
|
+
borderRadius: "8px",
|
|
10941
|
+
border: "1px solid #d1d5db",
|
|
10942
|
+
background: "#ffffff",
|
|
10943
|
+
color: "#1e293b",
|
|
10944
|
+
cursor: "pointer",
|
|
10945
|
+
textTransform: "none",
|
|
10946
|
+
},
|
|
10947
|
+
footerBtnPrimary: {
|
|
10948
|
+
display: "inline-flex",
|
|
10949
|
+
alignItems: "center",
|
|
10950
|
+
justifyContent: "center",
|
|
10951
|
+
height: "32px",
|
|
10952
|
+
padding: "0 12px",
|
|
10953
|
+
fontSize: "14px",
|
|
10954
|
+
fontWeight: 600,
|
|
10955
|
+
fontFamily: "Manrope, sans-serif",
|
|
10956
|
+
lineHeight: 1,
|
|
10957
|
+
borderRadius: "8px",
|
|
10958
|
+
border: "1px solid #4259EE",
|
|
10959
|
+
background: "#4259EE",
|
|
10960
|
+
color: "#ffffff",
|
|
10961
|
+
cursor: "pointer",
|
|
10962
|
+
textTransform: "none",
|
|
10963
|
+
},
|
|
10964
|
+
|
|
10965
|
+
// Footer options popover
|
|
10966
|
+
optionsCard: {
|
|
10967
|
+
position: "absolute",
|
|
10968
|
+
bottom: "100%",
|
|
10969
|
+
right: 0,
|
|
10970
|
+
marginBottom: "8px",
|
|
10971
|
+
background: "#ffffff",
|
|
10972
|
+
borderRadius: "12px",
|
|
10973
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.12)",
|
|
10974
|
+
border: "1px solid #e2e8f0",
|
|
10975
|
+
padding: "8px",
|
|
10976
|
+
minWidth: "280px",
|
|
10977
|
+
zIndex: 1,
|
|
10978
|
+
},
|
|
10979
|
+
optionRow: {
|
|
10980
|
+
display: "flex",
|
|
10981
|
+
alignItems: "center",
|
|
10982
|
+
gap: "10px",
|
|
10983
|
+
padding: "10px 12px",
|
|
10984
|
+
borderRadius: "8px",
|
|
10985
|
+
cursor: "pointer",
|
|
10986
|
+
fontSize: "13px",
|
|
10987
|
+
fontWeight: 500,
|
|
10988
|
+
color: "#1e293b",
|
|
10989
|
+
background: "#f8fafc",
|
|
10990
|
+
marginBottom: "4px",
|
|
10991
|
+
border: "none",
|
|
10992
|
+
width: "100%",
|
|
10993
|
+
textAlign: "left",
|
|
10994
|
+
fontFamily: "Manrope, sans-serif",
|
|
10995
|
+
"&:hover": {
|
|
10996
|
+
background: "#eef2ff",
|
|
10997
|
+
},
|
|
10998
|
+
"&:last-child": {
|
|
10999
|
+
marginBottom: 0,
|
|
11000
|
+
},
|
|
11001
|
+
},
|
|
11002
|
+
optionIcon: {
|
|
11003
|
+
color: "#6366f1",
|
|
11004
|
+
fontSize: "16px",
|
|
11005
|
+
},
|
|
11006
|
+
}));
|
|
11007
|
+
|
|
11008
|
+
const AllocationPlanCard = ({ bodyText }) => {
|
|
11009
|
+
const classes = useAllocationPanelStyles();
|
|
11010
|
+
const title = bodyText?.title || "Allocation Plan";
|
|
11011
|
+
const links = bodyText?.links || [];
|
|
11012
|
+
const panelData = bodyText?.panel_data || null;
|
|
11013
|
+
const handleCardClick = (target) => {
|
|
11014
|
+
if (!panelData)
|
|
11015
|
+
return;
|
|
11016
|
+
const openPanel = () => {
|
|
11017
|
+
window.dispatchEvent(new CustomEvent("openAllocationDetailPanel", {
|
|
11018
|
+
detail: { panelData, activeSection: target || null },
|
|
11019
|
+
}));
|
|
11020
|
+
};
|
|
11021
|
+
// Check if the chatbot is in a collapsed/minimized state by looking for
|
|
11022
|
+
// the "Expand chatbot" button (present only when collapsed)
|
|
11023
|
+
const expandBtn = document.querySelector('button[aria-label="Expand chatbot"]');
|
|
11024
|
+
if (expandBtn) {
|
|
11025
|
+
// Maximize first, then open the panel after chatbot finishes expanding
|
|
11026
|
+
window.dispatchEvent(new CustomEvent("smartBotMaximize"));
|
|
11027
|
+
setTimeout(openPanel, 350);
|
|
11028
|
+
}
|
|
11029
|
+
else {
|
|
11030
|
+
openPanel();
|
|
11031
|
+
}
|
|
11032
|
+
};
|
|
11033
|
+
return (jsxRuntime.jsxs("div", { className: classes.planCard, onClick: () => handleCardClick(links[0]?.target), children: [jsxRuntime.jsx("div", { className: classes.planCardIcon, children: jsxRuntime.jsx(DescriptionOutlinedIcon, {}) }), jsxRuntime.jsxs("div", { className: classes.planCardContent, children: [jsxRuntime.jsx("div", { className: classes.planCardTitle, children: title }), jsxRuntime.jsx("div", { className: classes.planCardLinks, children: links.map((link, index) => (jsxRuntime.jsxs("span", { children: [index > 0 && (jsxRuntime.jsx("span", { className: classes.planCardLinkSeparator, children: "\u00B7" })), jsxRuntime.jsx("span", { className: classes.planCardLink, onClick: (e) => {
|
|
11034
|
+
e.stopPropagation();
|
|
11035
|
+
handleCardClick(link.target);
|
|
11036
|
+
}, children: link.label })] }, link.target || index))) })] }), jsxRuntime.jsx(OpenInNewIcon, { className: classes.planCardOpenIcon })] }));
|
|
11037
|
+
};
|
|
11038
|
+
|
|
10214
11039
|
const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
10215
11040
|
try {
|
|
10216
11041
|
const parsedData = parseResponse(item, item.type, "", "", true);
|
|
@@ -10247,6 +11072,10 @@ const renderWidgetItem = (item, index, isFormDisabled) => {
|
|
|
10247
11072
|
return jsxRuntime.jsx(DateRangePickerContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
10248
11073
|
case "html":
|
|
10249
11074
|
return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
11075
|
+
case "surface_frame":
|
|
11076
|
+
return jsxRuntime.jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
11077
|
+
case "allocation_plan_card":
|
|
11078
|
+
return jsxRuntime.jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
|
|
10250
11079
|
default:
|
|
10251
11080
|
return null;
|
|
10252
11081
|
}
|
|
@@ -11119,7 +11948,8 @@ const StreamedContent = ({ botData, botProps }) => {
|
|
|
11119
11948
|
const widgetItems = isArray(data.widget_data)
|
|
11120
11949
|
? data.widget_data
|
|
11121
11950
|
: [data.widget_data];
|
|
11122
|
-
|
|
11951
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
11952
|
+
setStreamingWidgetData((prev) => mergeSurfaceWidgets(prev, widgetItems));
|
|
11123
11953
|
}
|
|
11124
11954
|
else if (data.message !== "[DONE]") {
|
|
11125
11955
|
if (!thinkingDoneRef?.current && currentMode === "agent") {
|
|
@@ -12289,6 +13119,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
12289
13119
|
return jsxRuntime.jsx(TableContent, { bodyText: parsedData.bodyText }, parsedData.bodyText?.table_name || key);
|
|
12290
13120
|
case "graph":
|
|
12291
13121
|
return jsxRuntime.jsx(GraphContent, { bodyText: parsedData.bodyText }, key);
|
|
13122
|
+
case "surface_frame":
|
|
13123
|
+
return jsxRuntime.jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
12292
13124
|
case "radio":
|
|
12293
13125
|
return jsxRuntime.jsx(RadioContent, { bodyText: parsedData.bodyText, isFormDisabled: isFormDisabled }, key);
|
|
12294
13126
|
case "checkbox":
|
|
@@ -12368,7 +13200,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
12368
13200
|
}
|
|
12369
13201
|
});
|
|
12370
13202
|
if (newWidgets.length > 0) {
|
|
12371
|
-
|
|
13203
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
13204
|
+
setWidgetContent((prev) => mergeSurfaceWidgets(prev, newWidgets));
|
|
12372
13205
|
}
|
|
12373
13206
|
return;
|
|
12374
13207
|
}
|
|
@@ -12499,7 +13332,7 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
12499
13332
|
let newQuestions = [...questionsRef.current];
|
|
12500
13333
|
let newQuestionsStepsMap = lodash.cloneDeep(questionsStepsMapRef.current);
|
|
12501
13334
|
let newStepFormDataMap = lodash.cloneDeep(stepFormDataMapRef.current);
|
|
12502
|
-
|
|
13335
|
+
let newWidgets = [];
|
|
12503
13336
|
chunks.forEach((data) => {
|
|
12504
13337
|
if (data.status === "questions") {
|
|
12505
13338
|
const incomingQuestions = data.widget_data?.[0]?.questions || [];
|
|
@@ -12596,10 +13429,8 @@ const TabularContent = ({ steps: initialSteps, currentTabValue, children, questi
|
|
|
12596
13429
|
}
|
|
12597
13430
|
if (data.status === "widget") {
|
|
12598
13431
|
const widgetItems = isArray$1(data.widget_data) ? data.widget_data : [data.widget_data];
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
newWidgets.push(item);
|
|
12602
|
-
});
|
|
13432
|
+
// a surface sent again (placeholder, then the surface) replaces its widget in place
|
|
13433
|
+
newWidgets = mergeSurfaceWidgets(newWidgets, widgetItems.filter(Boolean));
|
|
12603
13434
|
}
|
|
12604
13435
|
if (data.status === "content" && data.message) {
|
|
12605
13436
|
newWidgets.push({ type: "text", response: data.message });
|
|
@@ -12726,6 +13557,10 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
12726
13557
|
return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
12727
13558
|
case "html":
|
|
12728
13559
|
return jsxRuntime.jsx(HtmlContent, { bodyText: parsedData.bodyText }, key);
|
|
13560
|
+
case "surface_frame":
|
|
13561
|
+
return jsxRuntime.jsx(SurfaceFrameContent, { frame: parsedData.bodyText }, parsedData.bodyText?.surface?.id || key);
|
|
13562
|
+
case "allocation_plan_card":
|
|
13563
|
+
return jsxRuntime.jsx(AllocationPlanCard, { bodyText: parsedData.bodyText }, key);
|
|
12729
13564
|
default:
|
|
12730
13565
|
return null;
|
|
12731
13566
|
}
|
|
@@ -12804,6 +13639,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
12804
13639
|
return jsxRuntime.jsx(TableContent, { bodyText: botData.bodyText });
|
|
12805
13640
|
case "graph":
|
|
12806
13641
|
return jsxRuntime.jsx(GraphContent, { bodyText: botData.bodyText });
|
|
13642
|
+
case "surface_frame":
|
|
13643
|
+
return jsxRuntime.jsx(SurfaceFrameContent, { frame: botData.bodyText });
|
|
12807
13644
|
case "slider":
|
|
12808
13645
|
return jsxRuntime.jsx(SliderContent, { bodyText: botData.bodyText, isFormDisabled: botData.isFormDisabled, messageIndex: botData.messageIndex });
|
|
12809
13646
|
case "select":
|
|
@@ -12826,6 +13663,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
12826
13663
|
return jsxRuntime.jsx(ImageContent, { bodyText: botData.bodyText });
|
|
12827
13664
|
case "html":
|
|
12828
13665
|
return jsxRuntime.jsx(HtmlContent, { bodyText: botData.bodyText });
|
|
13666
|
+
case "allocation_plan_card":
|
|
13667
|
+
return jsxRuntime.jsx(AllocationPlanCard, { bodyText: botData.bodyText });
|
|
12829
13668
|
case "combined":
|
|
12830
13669
|
return jsxRuntime.jsx(CombinedContent, { botData: botData, props: props });
|
|
12831
13670
|
case "dynamic":
|
|
@@ -13329,6 +14168,109 @@ function UploadModal(props) {
|
|
|
13329
14168
|
return (jsxRuntime.jsx(impactUiV3.Modal, { onClose: handleModalClose, onPrimaryButtonClick: handleFileUpload, onSecondaryButtonClick: handleModalClose, open: isUploadModalOpen, size: "small", title: "Upload Document", primaryButtonLabel: "Upload", secondaryButtonLabel: "Cancel", primaryButtonProps: { disabled: isLoading }, secondaryButtonProps: { disabled: isLoading }, children: isLoading ? (jsxRuntime.jsx(impactUiV3.Loader, { text: "Uploading file..." })) : (jsxRuntime.jsxs("div", { className: classes.uploadModalInnerSec, children: [jsxRuntime.jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileSelect, accept: ".pdf", style: { display: "none" }, disabled: isLoading }), jsxRuntime.jsx(impactUiV3.Button, { onClick: () => fileInputRef.current.click(), variant: "outlined", disabled: isLoading, children: "Select PDF File" }), selectedFile && (jsxRuntime.jsxs("p", { style: { marginTop: "10px" }, children: ["Selected File: ", selectedFile.name] }))] })) }));
|
|
13330
14169
|
}
|
|
13331
14170
|
|
|
14171
|
+
/** A skill is a folder: SKILL.md (its name and description, then its steps) and the files it refers to, such
|
|
14172
|
+
* as references/mcp-contracts.md. Picked files are read here as text, keyed by their path in that folder,
|
|
14173
|
+
* and saved for the signed-in user by the agent (POST {baseUrl}/chatbot/agent/skills). Unlike a paste into
|
|
14174
|
+
* the chat, an upload keeps the line breaks and the skill's other files. */
|
|
14175
|
+
const MAX_FILES = 50;
|
|
14176
|
+
const TEXT_EXTENSIONS = [".md", ".txt", ".json", ".yaml", ".yml", ".csv"];
|
|
14177
|
+
const isSkillFile = (path) => path === "SKILL.md" || path.endsWith("/SKILL.md");
|
|
14178
|
+
const isText = (name) => TEXT_EXTENSIONS.some((ext) => name.toLowerCase().endsWith(ext));
|
|
14179
|
+
/** What the agent answered; a 200 may be the object itself or wrapped as {data: {...}}. */
|
|
14180
|
+
const savedOf = (response) => response?.data?.data || response?.data || {};
|
|
14181
|
+
/** Why the agent did not save it: the 422's detail ("not saved: ..."), else the message or status. */
|
|
14182
|
+
const whyNot = (error) => {
|
|
14183
|
+
const body = error?.response?.data;
|
|
14184
|
+
const said = body?.detail || body?.message || body?.data?.detail;
|
|
14185
|
+
if (typeof said === "string" && said)
|
|
14186
|
+
return said;
|
|
14187
|
+
if (said)
|
|
14188
|
+
return JSON.stringify(said);
|
|
14189
|
+
return error?.response?.status ? `the agent answered ${error.response.status}` : String(error?.message || error);
|
|
14190
|
+
};
|
|
14191
|
+
function SkillUploadModal(props) {
|
|
14192
|
+
const { isOpen, setIsOpen, baseUrl, displaySnackMessages, onUseText } = props;
|
|
14193
|
+
const [picked, setPicked] = React.useState({});
|
|
14194
|
+
const [skipped, setSkipped] = React.useState(0);
|
|
14195
|
+
const [isSaving, setIsSaving] = React.useState(false);
|
|
14196
|
+
const [saved, setSaved] = React.useState(null);
|
|
14197
|
+
const [error, setError] = React.useState("");
|
|
14198
|
+
const folderRef = React.useRef(null);
|
|
14199
|
+
const filesRef = React.useRef(null);
|
|
14200
|
+
const classes = useStyles$b();
|
|
14201
|
+
const reset = () => {
|
|
14202
|
+
setPicked({});
|
|
14203
|
+
setSkipped(0);
|
|
14204
|
+
setSaved(null);
|
|
14205
|
+
setError("");
|
|
14206
|
+
};
|
|
14207
|
+
const handleClose = () => {
|
|
14208
|
+
if (isSaving)
|
|
14209
|
+
return;
|
|
14210
|
+
setIsOpen(false);
|
|
14211
|
+
reset();
|
|
14212
|
+
};
|
|
14213
|
+
const take = async (list) => {
|
|
14214
|
+
if (!list)
|
|
14215
|
+
return;
|
|
14216
|
+
const next = { ...picked };
|
|
14217
|
+
let left = 0;
|
|
14218
|
+
for (const file of Array.from(list)) {
|
|
14219
|
+
const path = file.webkitRelativePath || file.name;
|
|
14220
|
+
if (!isText(file.name)) {
|
|
14221
|
+
left += 1; // a folder may hold images or .DS_Store: only text files are a skill's
|
|
14222
|
+
continue;
|
|
14223
|
+
}
|
|
14224
|
+
if (!(path in next) && Object.keys(next).length >= MAX_FILES) {
|
|
14225
|
+
displaySnackMessages(`A skill can have at most ${MAX_FILES} files`, "error");
|
|
14226
|
+
break;
|
|
14227
|
+
}
|
|
14228
|
+
next[path] = await file.text();
|
|
14229
|
+
}
|
|
14230
|
+
setPicked(next);
|
|
14231
|
+
setSkipped(skipped + left);
|
|
14232
|
+
setSaved(null);
|
|
14233
|
+
setError("");
|
|
14234
|
+
};
|
|
14235
|
+
const paths = Object.keys(picked);
|
|
14236
|
+
const hasSkill = paths.some(isSkillFile);
|
|
14237
|
+
const handleSave = async () => {
|
|
14238
|
+
if (!hasSkill) {
|
|
14239
|
+
displaySnackMessages("Pick the skill's SKILL.md (or its folder) first", "error");
|
|
14240
|
+
return;
|
|
14241
|
+
}
|
|
14242
|
+
try {
|
|
14243
|
+
setIsSaving(true);
|
|
14244
|
+
setError("");
|
|
14245
|
+
const response = await uploadSkill(picked, baseUrl);
|
|
14246
|
+
setSaved(savedOf(response));
|
|
14247
|
+
displaySnackMessages("Skill saved", "success");
|
|
14248
|
+
}
|
|
14249
|
+
catch (err) {
|
|
14250
|
+
console.error("uploadSkill error:", err);
|
|
14251
|
+
setError(whyNot(err));
|
|
14252
|
+
}
|
|
14253
|
+
finally {
|
|
14254
|
+
setIsSaving(false);
|
|
14255
|
+
}
|
|
14256
|
+
};
|
|
14257
|
+
const use = (text) => {
|
|
14258
|
+
onUseText?.(text);
|
|
14259
|
+
setIsOpen(false);
|
|
14260
|
+
reset();
|
|
14261
|
+
};
|
|
14262
|
+
const files = saved?.files || [];
|
|
14263
|
+
const missing = saved?.missing_files || [];
|
|
14264
|
+
const runText = saved?.name ? `Run skill ${saved.name} in Preview mode` : "";
|
|
14265
|
+
return (jsxRuntime.jsx(impactUiV3.Modal, { onClose: handleClose, onPrimaryButtonClick: saved ? handleClose : handleSave, onSecondaryButtonClick: handleClose, open: isOpen, size: "small", title: "Upload Skill", primaryButtonLabel: saved ? "Done" : "Save the skill", secondaryButtonLabel: "Cancel", primaryButtonProps: { disabled: isSaving || (!saved && !hasSkill) }, secondaryButtonProps: { disabled: isSaving }, children: isSaving ? (jsxRuntime.jsx(impactUiV3.Loader, { text: "Saving the skill..." })) : saved ? (jsxRuntime.jsxs("div", { style: { padding: "16px 20px", lineHeight: 1.5 }, children: [jsxRuntime.jsxs("p", { style: { margin: "0 0 8px" }, children: ["Saved ", jsxRuntime.jsx("b", { children: saved.name }), " (version ", saved.version, typeof saved.characters === "number" ? `, ${saved.characters.toLocaleString()} characters` : "", files.length ? `, with ${files.join(", ")}` : "", ")."] }), missing.length > 0 && (jsxRuntime.jsxs("p", { style: { margin: "0 0 8px" }, children: ["It refers to ", missing.join(", "), ", which was not uploaded."] })), saved.trigger && (jsxRuntime.jsxs("p", { style: { margin: "0 0 8px" }, children: ["It has a trigger: it ", saved.trigger_said, ". It is not on yet. To turn it on, send Iris:", " ", jsxRuntime.jsx("i", { children: saved.turn_on })] })), jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginTop: "12px" }, children: [runText && (jsxRuntime.jsxs(impactUiV3.Button, { variant: "outlined", onClick: () => use(runText), children: ["Put \"", runText, "\" in the chat"] })), saved.trigger && saved.turn_on && (jsxRuntime.jsxs(impactUiV3.Button, { variant: "outlined", onClick: () => use(saved.turn_on), children: ["Put \"", saved.turn_on, "\" in the chat"] }))] })] })) : (jsxRuntime.jsxs("div", { className: classes.uploadModalInnerSec, style: { height: "auto", minHeight: "150px" }, children: [jsxRuntime.jsx("input", { type: "file", ref: folderRef, onChange: (e) => {
|
|
14266
|
+
take(e.target.files);
|
|
14267
|
+
e.target.value = "";
|
|
14268
|
+
}, style: { display: "none" }, multiple: true, ...{ webkitdirectory: "", directory: "" } }), jsxRuntime.jsx("input", { type: "file", ref: filesRef, onChange: (e) => {
|
|
14269
|
+
take(e.target.files);
|
|
14270
|
+
e.target.value = "";
|
|
14271
|
+
}, style: { display: "none" }, multiple: true, accept: TEXT_EXTENSIONS.join(",") }), jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", justifyContent: "center" }, children: [jsxRuntime.jsx(impactUiV3.Button, { variant: "outlined", onClick: () => folderRef.current?.click(), children: "Pick the skill's folder" }), jsxRuntime.jsx(impactUiV3.Button, { variant: "outlined", onClick: () => filesRef.current?.click(), children: "Pick its files" })] }), paths.length > 0 ? (jsxRuntime.jsxs("div", { style: { marginTop: "12px", width: "100%" }, children: [jsxRuntime.jsx("ul", { style: { margin: 0, paddingLeft: "18px", maxHeight: "140px", overflowY: "auto" }, children: paths.map((path) => (jsxRuntime.jsx("li", { children: path }, path))) }), !hasSkill && jsxRuntime.jsx("p", { style: { margin: "8px 0 0" }, children: "No SKILL.md picked yet." }), skipped > 0 && (jsxRuntime.jsxs("p", { style: { margin: "8px 0 0" }, children: [skipped, " file", skipped === 1 ? " was" : "s were", " left out: a skill's files are text (", TEXT_EXTENSIONS.join(" "), ")."] }))] })) : (jsxRuntime.jsx("p", { style: { marginTop: "12px", textAlign: "center" }, children: "A skill is a SKILL.md and any files it refers to. Once saved, ask Iris to run it by name, now or on a schedule." })), error && jsxRuntime.jsxs("p", { style: { marginTop: "10px", color: "#b42318" }, children: ["Not saved: ", error.replace(/^not saved:\s*/i, "")] })] })) }));
|
|
14272
|
+
}
|
|
14273
|
+
|
|
13332
14274
|
const useStyles$2 = styles.makeStyles(() => ({
|
|
13333
14275
|
input: {
|
|
13334
14276
|
width: "100%",
|
|
@@ -14423,6 +15365,7 @@ const ChatbotInput = (props) => {
|
|
|
14423
15365
|
const isTransitioningStageRef = React.useRef(false);
|
|
14424
15366
|
const shouldClearCacheRef = React.useRef(false);
|
|
14425
15367
|
const allFilterValuesRef = React.useRef([]);
|
|
15368
|
+
const initialValueOptionsRef = React.useRef([]);
|
|
14426
15369
|
const windowStartRef = React.useRef(0);
|
|
14427
15370
|
const INITIAL_DISPLAY_COUNT = 500;
|
|
14428
15371
|
const LOAD_MORE_COUNT = 100;
|
|
@@ -14967,6 +15910,7 @@ const ChatbotInput = (props) => {
|
|
|
14967
15910
|
setSelectionStage("values");
|
|
14968
15911
|
setSelectedFilter(filterConfig);
|
|
14969
15912
|
setCurrentOptions([]);
|
|
15913
|
+
initialValueOptionsRef.current = [];
|
|
14970
15914
|
setSelectedOptions([]);
|
|
14971
15915
|
setShowMentionSelect(true);
|
|
14972
15916
|
setIsSelectOpen(true);
|
|
@@ -14996,10 +15940,13 @@ const ChatbotInput = (props) => {
|
|
|
14996
15940
|
windowStartRef.current = 0;
|
|
14997
15941
|
if (allValues.length > 2000) {
|
|
14998
15942
|
allFilterValuesRef.current = allValues;
|
|
14999
|
-
|
|
15943
|
+
const initialSlice = allValues.slice(0, INITIAL_DISPLAY_COUNT);
|
|
15944
|
+
initialValueOptionsRef.current = initialSlice;
|
|
15945
|
+
setCurrentOptions(initialSlice);
|
|
15000
15946
|
}
|
|
15001
15947
|
else {
|
|
15002
15948
|
allFilterValuesRef.current = [];
|
|
15949
|
+
initialValueOptionsRef.current = allValues;
|
|
15003
15950
|
setCurrentOptions(allValues);
|
|
15004
15951
|
}
|
|
15005
15952
|
// Update dropdown position again after values are loaded (DOM might have shifted)
|
|
@@ -15752,7 +16699,7 @@ const ChatbotInput = (props) => {
|
|
|
15752
16699
|
zIndex: 10000,
|
|
15753
16700
|
}, children: selectionStage === "filter" ? (
|
|
15754
16701
|
// Stage 1: Filter selection - always use Select
|
|
15755
|
-
jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions.length > 0 ? currentOptions : [], setCurrentOptions: setCurrentOptions, initialOptions:
|
|
16702
|
+
jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions.length > 0 ? currentOptions : [], setCurrentOptions: setCurrentOptions, initialOptions: formattedFilterOptions.length > 0 ? formattedFilterOptions : [], placeholder: "Select a filter...", handleChange: handleMentionSelect, isOpen: isSelectOpen, setIsOpen: setIsSelectOpen, selectedOptions: selectedOptions, setSelectedOptions: setSelectedOptions, isCloseWhenClickOutside: false, isWithSearch: true, isMulti: false, disabled: false, isLoading: false, emptyMessage: "No filters available" })) : selectionStage === "values" && selectedFilter?.display_type &&
|
|
15756
16703
|
selectedFilter.display_type !== "dropdown" &&
|
|
15757
16704
|
selectedFilter.display_type !== "autocompleteDropdown" &&
|
|
15758
16705
|
selectedFilter.display_type !== "list" ? (
|
|
@@ -15839,7 +16786,7 @@ const ChatbotInput = (props) => {
|
|
|
15839
16786
|
cursor: "pointer"
|
|
15840
16787
|
}, children: "Cancel" })] })] })) : (
|
|
15841
16788
|
// Stage 2: Value selection with dropdown - use Select
|
|
15842
|
-
jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions.length > 0 ? currentOptions : [], setCurrentOptions: setCurrentOptions, initialOptions:
|
|
16789
|
+
jsxRuntime.jsx(impactUiV3.Select, { currentOptions: currentOptions.length > 0 ? currentOptions : [], setCurrentOptions: setCurrentOptions, initialOptions: initialValueOptionsRef.current.length > 0 ? initialValueOptionsRef.current : currentOptions, placeholder: isLoadingValues
|
|
15843
16790
|
? "Loading values..."
|
|
15844
16791
|
: "Select values...", handleChange: handleMentionSelect, isOpen: isSelectOpen, setIsOpen: setIsSelectOpen, selectedOptions: selectedOptions, setSelectedOptions: setSelectedOptions, isCloseWhenClickOutside: false, isWithSearch: true, onMenuScrollToBottom: () => {
|
|
15845
16792
|
const allValues = allFilterValuesRef.current;
|
|
@@ -16994,6 +17941,146 @@ const MinimizedChatWidget = ({ onExpand }) => {
|
|
|
16994
17941
|
return (jsxRuntime.jsxs("div", { className: classes.widgetContainer, onClick: handleExpandClick, children: [jsxRuntime.jsxs("div", { className: classes.widgetHeader, children: [jsxRuntime.jsxs("div", { className: classes.headerLeft, children: [jsxRuntime.jsx("div", { className: !isCompleted ? classes.headerIconLogoSpin : classes.headerIconLogo, children: jsxRuntime.jsx(SvgMimimizedIconLogo, {}) }), jsxRuntime.jsx("span", { className: classes.headerText, children: isCompleted ? "Action completed" : actionLabel }), !isCompleted && (jsxRuntime.jsx("div", { className: classes.warningIcon, children: jsxRuntime.jsx(SvgStepError, {}) }))] }), jsxRuntime.jsx("button", { className: classes.minimizeBtn, onClick: handleMinimizeClick, "aria-label": "Minimize", children: jsxRuntime.jsx(SvgMinimizeDashIcon, {}) })] }), jsxRuntime.jsx("div", { className: classes.widgetContent, children: jsxRuntime.jsxs("div", { className: stepStatus === "step_form" ? classes.innerContentStepForm : classes.innerContent, children: [jsxRuntime.jsxs("div", { className: classes.innerFirstRow, children: [jsxRuntime.jsx("span", { className: classes.stepHeaderText, title: stepHeader, children: stepHeader }), jsxRuntime.jsx("button", { className: classes.expandBtn, onClick: handleExpandClick, "aria-label": "Expand chatbot", children: jsxRuntime.jsx(SvgExpandFullscreenIcon, {}) })] }), stepSubHeader && (jsxRuntime.jsxs("div", { className: classes.innerSecondRow, children: [jsxRuntime.jsxs("div", { className: stepStatus === "step_form" ? classes.subHeaderPillStepForm : classes.subHeaderPill, children: [stepStatus === "step_form" ? (jsxRuntime.jsx("div", { className: classes.exclamationIcon, children: jsxRuntime.jsx(SvgExclamationIcon, {}) })) : !isCompleted && (jsxRuntime.jsx("div", { className: classes.loaderIcon, children: jsxRuntime.jsx(SvgLoadingCircle, {}) })), jsxRuntime.jsx("span", { className: classes.subHeaderText, title: stepSubHeader, children: stepSubHeader })] }), elapsedTime && (jsxRuntime.jsx("span", { className: classes.timeText, children: elapsedTime }))] }))] }) })] }));
|
|
16995
17942
|
};
|
|
16996
17943
|
|
|
17944
|
+
const PanelHeader = ({ title, actions = {}, onClose, isExpanded, onToggleExpand }) => {
|
|
17945
|
+
const classes = useAllocationPanelStyles();
|
|
17946
|
+
return (jsxRuntime.jsxs("div", { className: classes.panelHeader, children: [jsxRuntime.jsxs("div", { className: classes.panelHeaderLeft, children: [actions.preview && (jsxRuntime.jsx(VisibilityOutlinedIcon, { className: classes.panelHeaderIcon })), jsxRuntime.jsx("span", { className: classes.panelTitle, title: title, children: title })] }), jsxRuntime.jsxs("div", { className: classes.panelHeaderActions, children: [actions.expand_fullscreen && (jsxRuntime.jsx(material.IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onToggleExpand, children: isExpanded ? (jsxRuntime.jsx(CloseFullscreenIcon, { sx: { fontSize: 16 } })) : (jsxRuntime.jsx(OpenInFullIcon, { sx: { fontSize: 16 } })) })), jsxRuntime.jsx(material.IconButton, { className: classes.panelHeaderActionBtn, size: "small", onClick: onClose, children: jsxRuntime.jsx(CloseIcon, { sx: { fontSize: 16 } }) })] })] }));
|
|
17947
|
+
};
|
|
17948
|
+
|
|
17949
|
+
const ReportSummaryCard = ({ reportSummary }) => {
|
|
17950
|
+
const classes = useAllocationPanelStyles();
|
|
17951
|
+
if (!reportSummary)
|
|
17952
|
+
return null;
|
|
17953
|
+
const { badge, description, baseline_plan } = reportSummary;
|
|
17954
|
+
return (jsxRuntime.jsxs("div", { className: classes.reportSummaryCard, children: [badge && (jsxRuntime.jsx("span", { className: classes.reportBadge, children: badge.label })), description && (jsxRuntime.jsx("div", { className: classes.reportDescription, children: description })), baseline_plan && (jsxRuntime.jsxs("div", { className: classes.baselinePlanRow, children: [jsxRuntime.jsxs("span", { children: [baseline_plan.label, ":"] }), baseline_plan.link_url ? (jsxRuntime.jsx("span", { className: classes.baselinePlanLink, onClick: () => {
|
|
17955
|
+
if (baseline_plan.link_url) {
|
|
17956
|
+
window.open(baseline_plan.link_url, "_blank");
|
|
17957
|
+
}
|
|
17958
|
+
}, children: baseline_plan.value })) : (jsxRuntime.jsx("span", { children: baseline_plan.value }))] }))] }));
|
|
17959
|
+
};
|
|
17960
|
+
|
|
17961
|
+
const StructuredComparison = ({ content }) => {
|
|
17962
|
+
const classes = useAllocationPanelStyles();
|
|
17963
|
+
if (!content)
|
|
17964
|
+
return null;
|
|
17965
|
+
const { subtitle, scenario_groups = [] } = content;
|
|
17966
|
+
return (jsxRuntime.jsxs("div", { children: [subtitle && (jsxRuntime.jsx("div", { className: classes.comparisonSubtitle, children: subtitle })), scenario_groups.map((group, groupIndex) => (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { className: classes.scenarioLabel, children: group.scenario_label }), (group.comparisons || []).map((comparison, compIndex) => (jsxRuntime.jsxs("div", { className: classes.comparisonCard, children: [jsxRuntime.jsxs("div", { className: classes.comparisonParamRow, children: [jsxRuntime.jsx("span", { className: classes.comparisonParamName, children: comparison.parameter_name }), (comparison.tags || []).map((tag, tagIndex) => (jsxRuntime.jsx("span", { className: classes.comparisonTag, children: tag.label }, `tag-${tagIndex}`)))] }), jsxRuntime.jsxs("div", { className: classes.comparisonValues, children: [jsxRuntime.jsxs("div", { className: classes.comparisonValueBox, children: [jsxRuntime.jsx("div", { className: classes.comparisonValueLabel, children: comparison.baseline?.label }), jsxRuntime.jsx("div", { className: classes.comparisonValueText, children: comparison.baseline?.value })] }), jsxRuntime.jsx(ArrowForwardIcon, { className: classes.comparisonArrow }), jsxRuntime.jsxs("div", { className: classes.comparisonValueBox, children: [jsxRuntime.jsx("div", { className: classes.comparisonValueLabel, children: comparison.new_value?.label }), jsxRuntime.jsx("div", { className: classes.comparisonValueText, children: comparison.new_value?.value })] })] })] }, `comp-${groupIndex}-${compIndex}`)))] }, `group-${groupIndex}`)))] }));
|
|
17967
|
+
};
|
|
17968
|
+
|
|
17969
|
+
const PanelSection = ({ section }) => {
|
|
17970
|
+
const classes = useAllocationPanelStyles();
|
|
17971
|
+
if (!section)
|
|
17972
|
+
return null;
|
|
17973
|
+
const renderContent = () => {
|
|
17974
|
+
switch (section.content_type) {
|
|
17975
|
+
case "html":
|
|
17976
|
+
case "custom_html":
|
|
17977
|
+
return (jsxRuntime.jsx("div", { className: classes.panelHtmlContainer, children: jsxRuntime.jsx(HtmlContent, { bodyText: { content: section.content } }) }));
|
|
17978
|
+
case "structured":
|
|
17979
|
+
return jsxRuntime.jsx(StructuredComparison, { content: section.content });
|
|
17980
|
+
default:
|
|
17981
|
+
return null;
|
|
17982
|
+
}
|
|
17983
|
+
};
|
|
17984
|
+
return (jsxRuntime.jsxs(material.Accordion, { defaultExpanded: section.default_expanded, className: classes.sectionAccordion, disableGutters: true, children: [jsxRuntime.jsx(material.AccordionSummary, { expandIcon: jsxRuntime.jsx(ExpandMoreIcon, {}), className: classes.sectionSummary, children: jsxRuntime.jsx("span", { className: classes.sectionTitle, children: section.title }) }), jsxRuntime.jsx(material.AccordionDetails, { className: classes.sectionDetails, children: renderContent() })] }));
|
|
17985
|
+
};
|
|
17986
|
+
|
|
17987
|
+
const shiftChatbot = (panelEl) => {
|
|
17988
|
+
const chatbot = document.querySelector(".chatbot-component-container");
|
|
17989
|
+
if (!chatbot)
|
|
17990
|
+
return;
|
|
17991
|
+
const panelWidth = panelEl ? panelEl.offsetWidth : 0;
|
|
17992
|
+
const currentLeft = parseFloat(chatbot.style.left) || 0;
|
|
17993
|
+
chatbot.dataset.origLeft = chatbot.style.left;
|
|
17994
|
+
chatbot.style.transition = "left 0.3s ease";
|
|
17995
|
+
chatbot.style.left = (currentLeft - panelWidth) + "px";
|
|
17996
|
+
};
|
|
17997
|
+
const restoreChatbot = () => {
|
|
17998
|
+
const chatbot = document.querySelector(".chatbot-component-container");
|
|
17999
|
+
if (!chatbot)
|
|
18000
|
+
return;
|
|
18001
|
+
if (chatbot.dataset.origLeft) {
|
|
18002
|
+
chatbot.style.transition = "left 0.3s ease";
|
|
18003
|
+
chatbot.style.left = chatbot.dataset.origLeft;
|
|
18004
|
+
delete chatbot.dataset.origLeft;
|
|
18005
|
+
// Clean up transition after animation completes
|
|
18006
|
+
const onEnd = () => {
|
|
18007
|
+
chatbot.style.transition = "";
|
|
18008
|
+
chatbot.removeEventListener("transitionend", onEnd);
|
|
18009
|
+
};
|
|
18010
|
+
chatbot.addEventListener("transitionend", onEnd);
|
|
18011
|
+
}
|
|
18012
|
+
};
|
|
18013
|
+
const AllocationDetailPanel = () => {
|
|
18014
|
+
const classes = useAllocationPanelStyles();
|
|
18015
|
+
const [panelData, setPanelData] = React.useState(null);
|
|
18016
|
+
const [activeFooterAction, setActiveFooterAction] = React.useState(null);
|
|
18017
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
18018
|
+
const panelRef = React.useRef(null);
|
|
18019
|
+
const handleOpen = React.useCallback((e) => {
|
|
18020
|
+
const { panelData: data } = e.detail || {};
|
|
18021
|
+
if (data) {
|
|
18022
|
+
setPanelData(data);
|
|
18023
|
+
}
|
|
18024
|
+
}, []);
|
|
18025
|
+
const handleClose = React.useCallback(() => {
|
|
18026
|
+
restoreChatbot();
|
|
18027
|
+
setPanelData(null);
|
|
18028
|
+
setIsExpanded(false);
|
|
18029
|
+
}, []);
|
|
18030
|
+
React.useEffect(() => {
|
|
18031
|
+
window.addEventListener("openAllocationDetailPanel", handleOpen);
|
|
18032
|
+
window.addEventListener("closeAllocationDetailPanel", handleClose);
|
|
18033
|
+
return () => {
|
|
18034
|
+
window.removeEventListener("openAllocationDetailPanel", handleOpen);
|
|
18035
|
+
window.removeEventListener("closeAllocationDetailPanel", handleClose);
|
|
18036
|
+
};
|
|
18037
|
+
}, [handleOpen, handleClose]);
|
|
18038
|
+
// Shift the chatbot once the panel has rendered
|
|
18039
|
+
React.useEffect(() => {
|
|
18040
|
+
if (panelData && panelRef.current) {
|
|
18041
|
+
// Use requestAnimationFrame to ensure the panel is laid out
|
|
18042
|
+
requestAnimationFrame(() => {
|
|
18043
|
+
shiftChatbot(panelRef.current);
|
|
18044
|
+
});
|
|
18045
|
+
}
|
|
18046
|
+
}, [panelData]);
|
|
18047
|
+
// Listen for direct clicks on the impact-ui collapse button
|
|
18048
|
+
React.useEffect(() => {
|
|
18049
|
+
if (!panelData)
|
|
18050
|
+
return;
|
|
18051
|
+
const collapseBtn = document.querySelector('button[aria-label="Collapse chatbot"]');
|
|
18052
|
+
if (!collapseBtn)
|
|
18053
|
+
return;
|
|
18054
|
+
const onCollapse = () => handleClose();
|
|
18055
|
+
collapseBtn.addEventListener("click", onCollapse);
|
|
18056
|
+
return () => collapseBtn.removeEventListener("click", onCollapse);
|
|
18057
|
+
}, [panelData, handleClose]);
|
|
18058
|
+
if (!panelData)
|
|
18059
|
+
return null;
|
|
18060
|
+
const footerActions = panelData.footer_actions || [
|
|
18061
|
+
{ label: "Purge", variant: "outlined", action: "purge", options: [] },
|
|
18062
|
+
{ label: "Finalize Plan", variant: "primary", action: "finalize", options: [] },
|
|
18063
|
+
];
|
|
18064
|
+
const handleOptionClick = (option) => {
|
|
18065
|
+
setActiveFooterAction(null);
|
|
18066
|
+
window.dispatchEvent(new CustomEvent("allocationPanelAction", {
|
|
18067
|
+
detail: { value: option.value, label: option.label },
|
|
18068
|
+
}));
|
|
18069
|
+
};
|
|
18070
|
+
const handleFooterBtnClick = (btn) => {
|
|
18071
|
+
if (btn.options && btn.options.length > 0) {
|
|
18072
|
+
setActiveFooterAction(activeFooterAction === btn.action ? null : btn.action);
|
|
18073
|
+
}
|
|
18074
|
+
else {
|
|
18075
|
+
console.log("[AllocationPanel] footer action:", btn.action);
|
|
18076
|
+
}
|
|
18077
|
+
};
|
|
18078
|
+
const panel = (jsxRuntime.jsxs("div", { ref: panelRef, className: `${classes.panelContainer} ${isExpanded ? classes.panelExpanded : ""}`, "data-testid": "allocation-detail-panel", children: [jsxRuntime.jsx(PanelHeader, { title: panelData.title, actions: panelData.actions || {}, onClose: handleClose, isExpanded: isExpanded, onToggleExpand: () => setIsExpanded((prev) => !prev) }), jsxRuntime.jsxs("div", { className: classes.panelScrollBody, children: [jsxRuntime.jsx(ReportSummaryCard, { reportSummary: panelData.report_summary }), (panelData.sections || []).map((section) => (jsxRuntime.jsx(PanelSection, { section: section }, section.id)))] }), jsxRuntime.jsxs("div", { className: classes.panelFooter, children: [activeFooterAction && (jsxRuntime.jsx("div", { className: classes.optionsCard, children: footerActions
|
|
18079
|
+
.find((a) => a.action === activeFooterAction)
|
|
18080
|
+
?.options?.map((opt, idx) => (jsxRuntime.jsxs("button", { className: classes.optionRow, onClick: () => handleOptionClick(opt), children: [jsxRuntime.jsx("span", { className: classes.optionIcon, children: "\u2606" }), opt.label] }, idx))) })), footerActions.map((btn, idx) => (jsxRuntime.jsx("button", { className: btn.variant === "primary" ? classes.footerBtnPrimary : classes.footerBtnOutlined, onClick: () => handleFooterBtnClick(btn), children: btn.label }, idx)))] })] }));
|
|
18081
|
+
return reactDom.createPortal(panel, document.body);
|
|
18082
|
+
};
|
|
18083
|
+
|
|
16997
18084
|
/**
|
|
16998
18085
|
* SmartBot Redux reducer.
|
|
16999
18086
|
* State shape and behaviour match the consumer's core/reducers/smartBotReducer.js exactly.
|
|
@@ -17067,6 +18154,9 @@ const SmartBot = (props) => {
|
|
|
17067
18154
|
React.useState(false);
|
|
17068
18155
|
React.useState(false);
|
|
17069
18156
|
const [conversation, setConversation] = React.useState({});
|
|
18157
|
+
// "Upload Skill": offered only when the agent's /info says skills.upload (asked once per base URL)
|
|
18158
|
+
const [skillUploadOn, setSkillUploadOn] = React.useState(false);
|
|
18159
|
+
const [isSkillUploadOpen, setIsSkillUploadOpen] = React.useState(false);
|
|
17070
18160
|
const { chatbotContext, currentAgentChatId, minimizedStreamData } = reactRedux.useSelector((state) => state.smartBotReducer);
|
|
17071
18161
|
const savedFilterDashboard = reactRedux.useSelector(selectors?.getSavedFilterDashboard ?? NULL_SELECTOR);
|
|
17072
18162
|
// Per-mode conversation ID tracking — prevents cross-mode contamination when
|
|
@@ -17185,6 +18275,7 @@ const SmartBot = (props) => {
|
|
|
17185
18275
|
// Minimize the chat window when the user follows an in-app link from a bot response
|
|
17186
18276
|
const handleMinimizeRequest = () => {
|
|
17187
18277
|
setPartialClose(true);
|
|
18278
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
17188
18279
|
};
|
|
17189
18280
|
window.addEventListener("stepFormStreamStart", handleStepFormStreamStart);
|
|
17190
18281
|
window.addEventListener("stepFormStreamEnd", handleStepFormStreamEnd);
|
|
@@ -17624,6 +18715,29 @@ const SmartBot = (props) => {
|
|
|
17624
18715
|
React.useEffect(() => {
|
|
17625
18716
|
fetchCustomBotConfigurations();
|
|
17626
18717
|
}, [baseUrl]);
|
|
18718
|
+
React.useEffect(() => {
|
|
18719
|
+
let live = true;
|
|
18720
|
+
if (!baseUrl) {
|
|
18721
|
+
setSkillUploadOn(false);
|
|
18722
|
+
return;
|
|
18723
|
+
}
|
|
18724
|
+
fetchSkillUploadOn(baseUrl).then((on) => {
|
|
18725
|
+
if (live)
|
|
18726
|
+
setSkillUploadOn(on);
|
|
18727
|
+
});
|
|
18728
|
+
return () => {
|
|
18729
|
+
live = false;
|
|
18730
|
+
};
|
|
18731
|
+
}, [baseUrl]);
|
|
18732
|
+
// kept apart from utilityList: handleUploadAccess sets that list from its first value once its access
|
|
18733
|
+
// check returns, which would drop an item added meanwhile
|
|
18734
|
+
const skillUploadItem = {
|
|
18735
|
+
key: "Upload Skill",
|
|
18736
|
+
onClick: () => {
|
|
18737
|
+
setIsSkillUploadOpen(true);
|
|
18738
|
+
},
|
|
18739
|
+
icon: (jsxRuntime.jsx("div", { className: classes.memoryModalIconDiv, children: jsxRuntime.jsx(SvgUploadIcon, { style: { width: 20, height: 20 } }) })),
|
|
18740
|
+
};
|
|
17627
18741
|
// Sync showModal state with props.showModal OR props.invokeBot (backward compatibility)
|
|
17628
18742
|
// Host app passes showModal prop, but some integrations may use invokeBot
|
|
17629
18743
|
React.useEffect(() => {
|
|
@@ -17842,7 +18956,7 @@ const SmartBot = (props) => {
|
|
|
17842
18956
|
fetchLegacyAgentInfo(); //Disabled temporarily since this was causing issue on homepage first render
|
|
17843
18957
|
}
|
|
17844
18958
|
}, [location]);
|
|
17845
|
-
const handleSendMessage = async (userInput, userExplicitInput = {}, textWithColumnNames = "") => {
|
|
18959
|
+
const handleSendMessage = async (userInput, userExplicitInput = {}, textWithColumnNames = "", uiContext = null) => {
|
|
17846
18960
|
try {
|
|
17847
18961
|
// if (localStorage.getItem("isStreaming") === "true") {
|
|
17848
18962
|
// displaySnackMessages(
|
|
@@ -17906,6 +19020,7 @@ const SmartBot = (props) => {
|
|
|
17906
19020
|
userExplicitInput: userExplicitInput,
|
|
17907
19021
|
textWithColumnNames: textWithColumnNames,
|
|
17908
19022
|
answerMode: answerMode,
|
|
19023
|
+
...(uiContext ? { uiContext } : {}),
|
|
17909
19024
|
};
|
|
17910
19025
|
// if(!isEmpty(userInput)) {
|
|
17911
19026
|
// Clear the previous response's completed state so the incoming
|
|
@@ -17955,12 +19070,25 @@ const SmartBot = (props) => {
|
|
|
17955
19070
|
sessionStorage.removeItem("stepForm_chatId");
|
|
17956
19071
|
// dispatch(setChatbotContext({}));
|
|
17957
19072
|
setUserInput(params?.text);
|
|
17958
|
-
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames);
|
|
19073
|
+
handleSendMessage(params?.text, params?.userExplicitInput, params?.textWithColumnNames, params?.uiContext);
|
|
17959
19074
|
}
|
|
17960
19075
|
catch (error) {
|
|
17961
19076
|
console.error("onSendIconClick error", error);
|
|
17962
19077
|
}
|
|
17963
19078
|
};
|
|
19079
|
+
// A follow-up asked from a generated surface (SurfaceFrameContent's "iris:prompt"): sent as the user's next
|
|
19080
|
+
// message, with the surface's context as ui_context. Not while a turn runs or a form waits for its Submit.
|
|
19081
|
+
const surfacePromptRef = React.useRef(null);
|
|
19082
|
+
surfacePromptRef.current = (detail) => {
|
|
19083
|
+
if (!detail?.text || isStop || !lodash.isEmpty(chatbotContext))
|
|
19084
|
+
return;
|
|
19085
|
+
onSendIconClick({ text: detail.text, uiContext: detail.uiContext });
|
|
19086
|
+
};
|
|
19087
|
+
React.useEffect(() => {
|
|
19088
|
+
const onSurfacePrompt = (event) => surfacePromptRef.current?.(event.detail);
|
|
19089
|
+
window.addEventListener("iris:prompt", onSurfacePrompt);
|
|
19090
|
+
return () => window.removeEventListener("iris:prompt", onSurfacePrompt);
|
|
19091
|
+
}, []);
|
|
17964
19092
|
const onStopIconClick = (params) => {
|
|
17965
19093
|
try {
|
|
17966
19094
|
setIsStop(false);
|
|
@@ -18194,9 +19322,35 @@ const SmartBot = (props) => {
|
|
|
18194
19322
|
if (!root)
|
|
18195
19323
|
return;
|
|
18196
19324
|
const collapseBtn = root.querySelector('button[aria-label="Collapse chatbot"]');
|
|
18197
|
-
if (collapseBtn)
|
|
19325
|
+
if (collapseBtn) {
|
|
18198
19326
|
collapseBtn.click();
|
|
19327
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
19328
|
+
}
|
|
18199
19329
|
}, []);
|
|
19330
|
+
// Expand the chatbot to its full docked view by programmatically clicking
|
|
19331
|
+
// impact-ui's "Expand chatbot" button. Used when the allocation panel opens
|
|
19332
|
+
// from minimized state.
|
|
19333
|
+
const expandChatBotIfCollapsed = React.useCallback(() => {
|
|
19334
|
+
setShowModal(true);
|
|
19335
|
+
setPartialClose(false);
|
|
19336
|
+
// Use a short delay so the chatbot DOM renders before we look for the button
|
|
19337
|
+
setTimeout(() => {
|
|
19338
|
+
const root = smartBotWrapperRef.current;
|
|
19339
|
+
if (!root)
|
|
19340
|
+
return;
|
|
19341
|
+
const expandBtn = root.querySelector('button[aria-label="Expand chatbot"]');
|
|
19342
|
+
if (expandBtn) {
|
|
19343
|
+
expandBtn.click();
|
|
19344
|
+
}
|
|
19345
|
+
}, 100);
|
|
19346
|
+
}, []);
|
|
19347
|
+
// Listen for smartBotMaximize events (e.g. from allocation plan card)
|
|
19348
|
+
React.useEffect(() => {
|
|
19349
|
+
window.addEventListener("smartBotMaximize", expandChatBotIfCollapsed);
|
|
19350
|
+
return () => {
|
|
19351
|
+
window.removeEventListener("smartBotMaximize", expandChatBotIfCollapsed);
|
|
19352
|
+
};
|
|
19353
|
+
}, [expandChatBotIfCollapsed]);
|
|
18200
19354
|
// Auto-collapse to draggable mode when the user interacts outside the bot.
|
|
18201
19355
|
React.useEffect(() => {
|
|
18202
19356
|
const handleOutsideInteraction = (e) => {
|
|
@@ -18218,6 +19372,9 @@ const SmartBot = (props) => {
|
|
|
18218
19372
|
// Ignore clicks inside the expanded table modal portal
|
|
18219
19373
|
if (e.target.closest?.(".test-modal"))
|
|
18220
19374
|
return;
|
|
19375
|
+
// Ignore clicks inside the allocation detail panel
|
|
19376
|
+
if (e.target.closest?.('[data-testid="allocation-detail-panel"]'))
|
|
19377
|
+
return;
|
|
18221
19378
|
collapseChatBotIfExpanded();
|
|
18222
19379
|
};
|
|
18223
19380
|
document.addEventListener("mousedown", handleOutsideInteraction, true);
|
|
@@ -18238,7 +19395,7 @@ const SmartBot = (props) => {
|
|
|
18238
19395
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [partialClose && (minimizedStreamData?.isStreaming || minimizedStreamData?.stepStatus === "step_form") && (jsxRuntime.jsx(MinimizedChatWidget, { onExpand: () => {
|
|
18239
19396
|
setShowModal(true);
|
|
18240
19397
|
setPartialClose(false);
|
|
18241
|
-
} })), jsxRuntime.jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsxRuntime.jsx(RenameModal, { open: renameOpen, renameValue: renameValue, setRenameValue: setRenameValue, onConfirm: handleRenameConfirm, onCancel: handleRenameCancel }), jsxRuntime.jsx(DeleteConfirmModal, { open: deleteOpen, onConfirm: handleDeleteConfirm, onCancel: handleDeleteCancel }), jsxRuntime.jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(impactUiV3.ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsxRuntime.jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
|
|
19398
|
+
} })), jsxRuntime.jsxs("div", { ref: smartBotWrapperRef, className: `${classes.agentStyleOverride} ${partialClose || !(showModal || forceOpen) ? classes.hideBotStyle : ""} `, children: [jsxRuntime.jsx(RenameModal, { open: renameOpen, renameValue: renameValue, setRenameValue: setRenameValue, onConfirm: handleRenameConfirm, onCancel: handleRenameCancel }), jsxRuntime.jsx(DeleteConfirmModal, { open: deleteOpen, onConfirm: handleDeleteConfirm, onCancel: handleDeleteCancel }), jsxRuntime.jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), skillUploadOn && (jsxRuntime.jsx(SkillUploadModal, { isOpen: isSkillUploadOpen, setIsOpen: setIsSkillUploadOpen, baseUrl: baseUrl, displaySnackMessages: displaySnackMessages, onUseText: (text) => setUserInput(text) })), jsxRuntime.jsx(impactUiV3.ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: enableMultiChat, isConversationLoading: conversationLoading, customInputComponent: currentMode === "agent" && !showSavedFilters ? (jsxRuntime.jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions,
|
|
18242
19399
|
// onSaveClick={saveCurrentChat}
|
|
18243
19400
|
savedFilterSets: savedFilterSets, selectedFilterSet: selectedFilterSet, onFilterSetSelect: (filterSet) => setSelectedFilterSet(filterSet), onClearFilterSet: () => setSelectedFilterSet(null), onTriggerRefresh: triggerRefreshAction, answerMode: answerMode, setAnswerMode: setAnswerMode })) : showSavedFilters ? jsxRuntime.jsx(jsxRuntime.Fragment, {}) : null, isChatBotOpen: showModal || forceOpen, historyPanelData: historyPanelData, onHistorySearchChange: (params) => { console.log("History Search Change", params); }, onHistorySelectConversation: (params) => {
|
|
18244
19401
|
const convId = params?.conversation_id;
|
|
@@ -18344,16 +19501,17 @@ const SmartBot = (props) => {
|
|
|
18344
19501
|
dispatch(setMinimizedStreamData(null));
|
|
18345
19502
|
}
|
|
18346
19503
|
setPartialClose(true);
|
|
19504
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
18347
19505
|
}
|
|
18348
19506
|
},
|
|
18349
19507
|
// assistantChats={assistantChats}
|
|
18350
19508
|
onSendIconClick: onSendIconClick, conversation: conversation, onModuleClick: (id, name, param) => {
|
|
18351
19509
|
// activeTab.current.activeTab = name.toLowerCase();
|
|
18352
19510
|
handleModuleSelect(name);
|
|
18353
|
-
}, moduleList: modules, tabList: tabList, utilityList: utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
|
|
19511
|
+
}, moduleList: modules, tabList: tabList, utilityList: skillUploadOn ? [...utilityList, skillUploadItem] : utilityList, isAssistantThinking: false, isCustomScreen: showChatPlaceholder ? showChatPlaceholder : showSavedFilters, customScreenJsx: showChatPlaceholder ?
|
|
18354
19512
|
jsxRuntime.jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber, setAdditionalArgs: setAdditionalArgs, displayQuestions: displayQuestions, questions: questions, setActiveConversationId: setActiveConversationId, selectedFilterSet: selectedFilterSet, answerMode: answerMode })
|
|
18355
19513
|
:
|
|
18356
|
-
components?.FilterComponent ? jsxRuntime.jsx(components.FilterComponent, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth, onSetFilterConfiguration: callbacks?.onSetFilterConfiguration }) : null, inputText: userInput, threadList: ["Home"], hideMenuArrow:
|
|
19514
|
+
components?.FilterComponent ? jsxRuntime.jsx(components.FilterComponent, { savedFilterSets: savedFilterSets, partialClose: partialClose, chatBotWidth: chatBotWidth, onSetFilterConfiguration: callbacks?.onSetFilterConfiguration }) : null, inputText: userInput, threadList: ["Home"], hideMenuArrow: true, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
|
|
18357
19515
|
freeTextHeading: "Try adding more details :",
|
|
18358
19516
|
freeTextContent: "Iris works better when you provide more context and pointed questions",
|
|
18359
19517
|
}, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSavedFilters ? false : showSuggestionBanner, onCloseSuggestionBanner: () => {
|
|
@@ -18374,7 +19532,8 @@ const SmartBot = (props) => {
|
|
|
18374
19532
|
setChatBotWidth(params);
|
|
18375
19533
|
}, onMinimiseChatBot: () => {
|
|
18376
19534
|
setPartialClose(true);
|
|
18377
|
-
|
|
19535
|
+
window.dispatchEvent(new CustomEvent("closeAllocationDetailPanel"));
|
|
19536
|
+
} })] }), jsxRuntime.jsx(AllocationDetailPanel, {})] }));
|
|
18378
19537
|
};
|
|
18379
19538
|
|
|
18380
19539
|
exports.ChatbotProvider = ChatbotProvider;
|