@mgamadeus/ddd-agents 0.8.0 → 0.8.2
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/chat.js +9 -9
- package/dist/chunks/{ConversationMarkdown-BsCjyhj4.js → ConversationMarkdown-Cg80bH6c.js} +3 -3
- package/dist/chunks/{ConversationMarkdown-BsCjyhj4.js.map → ConversationMarkdown-Cg80bH6c.js.map} +1 -1
- package/dist/chunks/{ConversationMessageInputComposerWidgets-CE8LpyXY.js → ConversationMessageInputComposerWidgets-DPflWZ5o.js} +5 -5
- package/dist/chunks/{ConversationMessageInputComposerWidgets-CE8LpyXY.js.map → ConversationMessageInputComposerWidgets-DPflWZ5o.js.map} +1 -1
- package/dist/chunks/{VoiceBarsIcon-BIcURsBF.js → VoiceBarsIcon-99m5pR-4.js} +3 -3
- package/dist/chunks/{VoiceBarsIcon-BIcURsBF.js.map → VoiceBarsIcon-99m5pR-4.js.map} +1 -1
- package/dist/chunks/{WebSearchResultsConversationWidget-DXhfSikV.js → WebSearchResultsConversationWidget-W7O1fBB0.js} +1825 -1314
- package/dist/chunks/WebSearchResultsConversationWidget-W7O1fBB0.js.map +1 -0
- package/dist/chunks/{canvas-reducers-D-YxAR4B.js → canvas-reducers-DDg9T7t8.js} +2 -2
- package/dist/chunks/{canvas-reducers-D-YxAR4B.js.map → canvas-reducers-DDg9T7t8.js.map} +1 -1
- package/dist/chunks/{canvas-title-slot-context-D6UXrkdJ.js → canvas-title-slot-context-vg_UPT-V.js} +2 -2
- package/dist/chunks/{canvas-title-slot-context-D6UXrkdJ.js.map → canvas-title-slot-context-vg_UPT-V.js.map} +1 -1
- package/dist/chunks/{canvasBodies-CQEBkIVw.js → canvasBodies-8jRybJVU.js} +18 -4
- package/dist/chunks/canvasBodies-8jRybJVU.js.map +1 -0
- package/dist/chunks/{canvasStorage-BbEI3h-8.js → canvasStorage-DaM9851h.js} +2 -2
- package/dist/chunks/{canvasStorage-BbEI3h-8.js.map → canvasStorage-DaM9851h.js.map} +1 -1
- package/dist/chunks/{widget-name-resolver-B9k-s_cF.js → widget-name-resolver-In5UWRB3.js} +63 -42
- package/dist/chunks/widget-name-resolver-In5UWRB3.js.map +1 -0
- package/dist/client-testing.js +4 -4
- package/dist/files/i18n-keys.json +124 -3
- package/dist/files/renderer/widget-tree/composed-node-schema.json +2 -0
- package/dist/image-render.js +7 -7
- package/dist/index.js +9 -8
- package/dist/kit.js +2 -2
- package/dist/preview.js +5 -5
- package/dist/renderer.js +54 -54
- package/dist/renderer.js.map +1 -1
- package/dist/styles.css +625 -305
- package/dist/types/entries/index.d.ts +1 -0
- package/dist/types/entries/widgets.d.ts +6 -0
- package/dist/types/renderer/canvas/canvas-behaviours.d.ts +1 -1
- package/dist/types/widgets/AttachedFilesConversationWidget/AttachedFilesConversationWidget.d.ts +6 -0
- package/dist/types/widgets/AttachedFilesConversationWidget/AttachedFilesStrip.d.ts +22 -0
- package/dist/types/widgets/AttachedFilesConversationWidget/attached-files.d.ts +24 -0
- package/dist/types/widgets/ImageGalleryConversationWidget/ImageGallery.d.ts +16 -0
- package/dist/types/widgets/ImageGalleryConversationWidget/ImageGalleryCanvasBody.d.ts +6 -0
- package/dist/types/widgets/ImageGalleryConversationWidget/ImageGalleryConversationWidget.d.ts +11 -0
- package/dist/types/widgets/ImageGalleryConversationWidget/shared/image-gallery-canvas.d.ts +3 -0
- package/dist/types/widgets/ImageGalleryConversationWidget/shared/image-gallery-payload.d.ts +42 -0
- package/dist/types/widgets/_shared/file-preview-source.d.ts +33 -0
- package/dist/voice.js +1 -1
- package/dist/widgets.js +78 -62
- package/package.json +1 -1
- package/public-api.json +25 -1
- package/dist/chunks/WebSearchResultsConversationWidget-DXhfSikV.js.map +0 -1
- package/dist/chunks/canvasBodies-CQEBkIVw.js.map +0 -1
- package/dist/chunks/widget-name-resolver-B9k-s_cF.js.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Y as getWidgetSelfHydrationKeyFieldName, aa as useAgentsStateSelector, a9 as useAgentsStateDispatch, ae as WidgetHydrationSlice, n as Skeleton, F as classNames, o as SkeletonText, x as WidgetText, H as HeroRow, g as HeroValue, s as Text, B as Button, I as Icon, J as escapePlainTextForText,
|
|
4
|
-
import { createContext, useContext, useMemo, useEffect, useId, useRef, useCallback, useState,
|
|
3
|
+
import { Y as getWidgetSelfHydrationKeyFieldName, aa as useAgentsStateSelector, a9 as useAgentsStateDispatch, ae as WidgetHydrationSlice, n as Skeleton, F as classNames, o as SkeletonText, x as WidgetText, H as HeroRow, g as HeroValue, s as Text, B as Button, I as Icon, J as escapePlainTextForText, a1 as translateText, a8 as useAgentsOwnerSettings, l as RangeSlider, V as getSandboxLegacyAliases, O as getFurtherCanvasBehaviours, a6 as useAgentsLinkNavigation, r as StatusChip, v as Tooltip, N as getAgentsEnvironment, z as buildUnnamedAgentSpaceLabel, E as buildWidgetOfAnotherAgentSpaceExplanation, h as InteractiveSurface, j as Markdown, A as AgentsLink, u as TextInput, t as TextArea, a2 as useAgentsActiveAgentSpaceKey, C as Checkbox, y as appendAnotherAgentSpaceToOwnerText, b as ConversationSearchResultsList } from "./link-navigation-BUcy5qWW.js";
|
|
4
|
+
import { createContext, useContext, useMemo, useEffect, useId, useRef, useCallback, useState, useSyncExternalStore, useLayoutEffect } from "react";
|
|
5
5
|
import { t as textKey } from "./text-key-DnoZ4lAk.js";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
6
7
|
import { visit } from "unist-util-visit";
|
|
7
8
|
const ConversationWidgetRenderContext = createContext("conversation");
|
|
8
9
|
const useIsEmailWidgetRender = () => useContext(ConversationWidgetRenderContext) === "email";
|
|
@@ -106,8 +107,8 @@ const useReportWidgetRenderStatus = (status, code, detail) => {
|
|
|
106
107
|
};
|
|
107
108
|
const useWidgetRenderReporter = () => useContext(WidgetRenderReportContext);
|
|
108
109
|
const useWidgetMemory = (key) => {
|
|
109
|
-
return useAgentsStateSelector((
|
|
110
|
-
return
|
|
110
|
+
return useAgentsStateSelector((state2) => {
|
|
111
|
+
return state2.AIExtensionsWidgetHydration?.widgets[key];
|
|
111
112
|
});
|
|
112
113
|
};
|
|
113
114
|
const registry = /* @__PURE__ */ new Map();
|
|
@@ -342,7 +343,7 @@ const surface = "agents_surface_tMwX2D";
|
|
|
342
343
|
const elevated = "agents_elevated_-BbIdM";
|
|
343
344
|
const flat = "agents_flat_namOKd";
|
|
344
345
|
const compact = "agents_compact_yOnFdX";
|
|
345
|
-
const styles$
|
|
346
|
+
const styles$r = {
|
|
346
347
|
surface,
|
|
347
348
|
elevated,
|
|
348
349
|
flat,
|
|
@@ -355,7 +356,7 @@ const WidgetSurface = (props) => {
|
|
|
355
356
|
{
|
|
356
357
|
"data-surface-level": level,
|
|
357
358
|
"data-testid": testId2,
|
|
358
|
-
className: classNames(styles$
|
|
359
|
+
className: classNames(styles$r.surface, styles$r[level], compact2 && styles$r.compact, className),
|
|
359
360
|
children
|
|
360
361
|
}
|
|
361
362
|
);
|
|
@@ -366,7 +367,7 @@ const unitRow = "agents_unitRow_85Fm3Y";
|
|
|
366
367
|
const valueBlock = "agents_valueBlock_6ElGqo";
|
|
367
368
|
const textBlock = "agents_textBlock_WoVPQc";
|
|
368
369
|
const textValue = "agents_textValue_oHvUdR";
|
|
369
|
-
const styles$
|
|
370
|
+
const styles$q = {
|
|
370
371
|
kpi,
|
|
371
372
|
labelRow,
|
|
372
373
|
unitRow,
|
|
@@ -377,21 +378,21 @@ const styles$o = {
|
|
|
377
378
|
const WidgetKpiValue = (props) => {
|
|
378
379
|
const { label: label2, value, unit, delta, loading = false, valuePresentation = "hero", accent, meter, testId: testId2 } = props;
|
|
379
380
|
const labelText = /* @__PURE__ */ jsx(WidgetText, { variant: "caption", tone: "light", translate: false, testId: testId2 && `${testId2}-label`, children: label2 });
|
|
380
|
-
return /* @__PURE__ */ jsxs("div", { className: styles$
|
|
381
|
-
accent ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
381
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$q.kpi, children: [
|
|
382
|
+
accent ? /* @__PURE__ */ jsxs("div", { className: styles$q.labelRow, children: [
|
|
382
383
|
labelText,
|
|
383
384
|
accent
|
|
384
385
|
] }) : labelText,
|
|
385
386
|
/* @__PURE__ */ jsx(
|
|
386
387
|
"div",
|
|
387
388
|
{
|
|
388
|
-
className: classNames(styles$
|
|
389
|
+
className: classNames(styles$q.valueBlock, valuePresentation === "text" && styles$q.textBlock),
|
|
389
390
|
"data-testid": testId2 && `${testId2}-value-block`,
|
|
390
|
-
children: loading ? /* @__PURE__ */ jsx(SkeletonText, { width: "3em", height: 48 }) : valuePresentation === "text" ? /* @__PURE__ */ jsx(WidgetText, { variant: "title", translate: false, className: styles$
|
|
391
|
+
children: loading ? /* @__PURE__ */ jsx(SkeletonText, { width: "3em", height: 48 }) : valuePresentation === "text" ? /* @__PURE__ */ jsx(WidgetText, { variant: "title", translate: false, className: styles$q.textValue, children: value }) : /* @__PURE__ */ jsx(HeroRow, { children: /* @__PURE__ */ jsx(HeroValue, { children: value }) })
|
|
391
392
|
}
|
|
392
393
|
),
|
|
393
394
|
meter && !loading ? meter : null,
|
|
394
|
-
(unit || delta) && !loading ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
395
|
+
(unit || delta) && !loading ? /* @__PURE__ */ jsxs("div", { className: styles$q.unitRow, children: [
|
|
395
396
|
unit ? /* @__PURE__ */ jsx(WidgetText, { variant: "caption", tone: "light", translate: false, testId: testId2 && `${testId2}-unit`, children: unit }) : null,
|
|
396
397
|
delta
|
|
397
398
|
] }) : null
|
|
@@ -402,7 +403,7 @@ const withoutLeading = "agents_withoutLeading_7XTCP7";
|
|
|
402
403
|
const clickable = "agents_clickable_-T4Zgc";
|
|
403
404
|
const text$2 = "agents_text_fJd93m";
|
|
404
405
|
const trailing = "agents_trailing_FOCyQL";
|
|
405
|
-
const styles$
|
|
406
|
+
const styles$p = {
|
|
406
407
|
row: row$4,
|
|
407
408
|
withoutLeading,
|
|
408
409
|
clickable,
|
|
@@ -412,18 +413,18 @@ const styles$n = {
|
|
|
412
413
|
const WidgetListRow = (props) => {
|
|
413
414
|
const { title: title2, meta: meta2, leading, trailing: trailing2, onClick, className, testId: testId2 } = props;
|
|
414
415
|
const rowClassName = classNames(
|
|
415
|
-
styles$
|
|
416
|
-
leading === void 0 && styles$
|
|
417
|
-
onClick && styles$
|
|
416
|
+
styles$p.row,
|
|
417
|
+
leading === void 0 && styles$p.withoutLeading,
|
|
418
|
+
onClick && styles$p.clickable,
|
|
418
419
|
className
|
|
419
420
|
);
|
|
420
421
|
const content2 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
421
422
|
leading,
|
|
422
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
423
|
+
/* @__PURE__ */ jsxs("span", { className: styles$p.text, children: [
|
|
423
424
|
/* @__PURE__ */ jsx(Text, { role: "body", weight: "bold", translate: false, children: title2 }),
|
|
424
425
|
meta2 ? /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", translate: false, children: meta2 }) : null
|
|
425
426
|
] }),
|
|
426
|
-
trailing2 ? /* @__PURE__ */ jsx("span", { className: styles$
|
|
427
|
+
trailing2 ? /* @__PURE__ */ jsx("span", { className: styles$p.trailing, children: trailing2 }) : /* @__PURE__ */ jsx("span", {})
|
|
427
428
|
] });
|
|
428
429
|
if (onClick) {
|
|
429
430
|
return /* @__PURE__ */ jsx("button", { type: "button", className: rowClassName, onClick, "data-testid": testId2, children: content2 });
|
|
@@ -433,7 +434,7 @@ const WidgetListRow = (props) => {
|
|
|
433
434
|
const rows$1 = "agents_rows_ZeurFw";
|
|
434
435
|
const row$3 = "agents_row_2esTMM";
|
|
435
436
|
const rowText = "agents_rowText_TlYKqo";
|
|
436
|
-
const styles$
|
|
437
|
+
const styles$o = {
|
|
437
438
|
rows: rows$1,
|
|
438
439
|
row: row$3,
|
|
439
440
|
rowText
|
|
@@ -442,9 +443,9 @@ const WidgetSurfaceSkeleton = (props) => {
|
|
|
442
443
|
const { title: title2, rowCount = 3, level = "elevated", testId: testId2 } = props;
|
|
443
444
|
return /* @__PURE__ */ jsxs(WidgetSurface, { level, testId: testId2, children: [
|
|
444
445
|
typeof title2 === "string" || typeof title2 === "number" ? /* @__PURE__ */ jsx(Text, { role: "intro", weight: "bold", translate: false, children: title2 }) : title2 ?? null,
|
|
445
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
446
|
+
/* @__PURE__ */ jsx("div", { className: styles$o.rows, "aria-busy": "true", children: Array.from({ length: rowCount }, (unused, rowIndex) => /* @__PURE__ */ jsxs("div", { className: styles$o.row, children: [
|
|
446
447
|
/* @__PURE__ */ jsx(SkeletonCircle, { size: 32 }),
|
|
447
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
448
|
+
/* @__PURE__ */ jsxs("span", { className: styles$o.rowText, children: [
|
|
448
449
|
/* @__PURE__ */ jsx(SkeletonLine, { width: "60%", height: 12 }),
|
|
449
450
|
/* @__PURE__ */ jsx(SkeletonLine, { width: "35%", height: 10 })
|
|
450
451
|
] })
|
|
@@ -502,7 +503,7 @@ const ConversationWidgetActions = (props) => {
|
|
|
502
503
|
};
|
|
503
504
|
const ConversationWidgetButton = (props) => /* @__PURE__ */ jsx(ConversationWidgetActions, { children: /* @__PURE__ */ jsx(Button, { ...props }) });
|
|
504
505
|
const pill$2 = "agents_pill_-vfSSk";
|
|
505
|
-
const styles$
|
|
506
|
+
const styles$n = {
|
|
506
507
|
pill: pill$2
|
|
507
508
|
};
|
|
508
509
|
const DonePill = (props) => {
|
|
@@ -511,7 +512,7 @@ const DonePill = (props) => {
|
|
|
511
512
|
useEffect(() => {
|
|
512
513
|
if (document.activeElement === document.body) ref.current?.focus();
|
|
513
514
|
}, []);
|
|
514
|
-
return /* @__PURE__ */ jsxs("div", { ref, tabIndex: -1, className: styles$
|
|
515
|
+
return /* @__PURE__ */ jsxs("div", { ref, tabIndex: -1, className: styles$n.pill, "data-testid": testId2, children: [
|
|
515
516
|
status === "success" && /* @__PURE__ */ jsx(Icon, { pixelSize: 14, color: "var(--agents-success-500)", name: "check" }),
|
|
516
517
|
/* @__PURE__ */ jsx(Text, { role: "help", weight: "medium", color: "var(--agents-fg-light)", translate, children })
|
|
517
518
|
] });
|
|
@@ -520,6 +521,138 @@ const ModelText = (props) => {
|
|
|
520
521
|
const { children, ...textProps } = props;
|
|
521
522
|
return /* @__PURE__ */ jsx(Text, { ...textProps, translate: false, children: escapePlainTextForText(children) });
|
|
522
523
|
};
|
|
524
|
+
const ATTACHED_FILES_WIDGET_TYPE = "AttachedFiles";
|
|
525
|
+
const ATTACHED_FILES_MAX = 12;
|
|
526
|
+
const FILE_REFERENCE_PATTERN$1 = /^[a-z][a-z0-9-]{0,31}\/[A-Za-z0-9_-]{1,128}$/;
|
|
527
|
+
const readAttachedFiles = (fields) => {
|
|
528
|
+
const rawFiles = fields && typeof fields === "object" ? fields.files : void 0;
|
|
529
|
+
if (!Array.isArray(rawFiles)) return [];
|
|
530
|
+
const attachedFiles = [];
|
|
531
|
+
for (const rawFile of rawFiles) {
|
|
532
|
+
if (attachedFiles.length >= ATTACHED_FILES_MAX || !rawFile || typeof rawFile !== "object") continue;
|
|
533
|
+
const { reference, name: name2, isImage } = rawFile;
|
|
534
|
+
if (typeof reference !== "string" || !FILE_REFERENCE_PATTERN$1.test(reference)) continue;
|
|
535
|
+
attachedFiles.push({
|
|
536
|
+
reference,
|
|
537
|
+
name: typeof name2 === "string" && name2.trim() !== "" ? name2.trim() : reference,
|
|
538
|
+
isImage: isImage === true
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return attachedFiles;
|
|
542
|
+
};
|
|
543
|
+
const parseAttachedFilesPayload = (raw) => {
|
|
544
|
+
try {
|
|
545
|
+
return readAttachedFiles(JSON.parse(raw));
|
|
546
|
+
} catch {
|
|
547
|
+
return [];
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
const buildAttachedFilesComposerWidget = (attachedFiles, composerWidgetId = ATTACHED_FILES_WIDGET_TYPE) => ({
|
|
551
|
+
composerWidgetId,
|
|
552
|
+
widgetName: ATTACHED_FILES_WIDGET_TYPE,
|
|
553
|
+
fields: { files: attachedFiles.slice(0, ATTACHED_FILES_MAX).map((file) => ({ ...file })) }
|
|
554
|
+
});
|
|
555
|
+
const FILE_PREVIEW_SOURCE_MISSING = "FILE_PREVIEW_SOURCE_MISSING";
|
|
556
|
+
let registeredFilePreviewSource = null;
|
|
557
|
+
const registerFilePreviewSource = (source) => {
|
|
558
|
+
registeredFilePreviewSource = source;
|
|
559
|
+
};
|
|
560
|
+
const readFilePreviewSource = () => registeredFilePreviewSource;
|
|
561
|
+
const unregisterFilePreviewSource = () => {
|
|
562
|
+
registeredFilePreviewSource = null;
|
|
563
|
+
};
|
|
564
|
+
const useFilePictureUrl = (reference, variant) => {
|
|
565
|
+
const [state2, setState] = useState({ url: null, status: "loading" });
|
|
566
|
+
useEffect(() => {
|
|
567
|
+
if (reference === null) return void 0;
|
|
568
|
+
const source = readFilePreviewSource();
|
|
569
|
+
if (source === null) {
|
|
570
|
+
setState({ url: null, status: "notConnected" });
|
|
571
|
+
return void 0;
|
|
572
|
+
}
|
|
573
|
+
const abortController = new AbortController();
|
|
574
|
+
setState({ url: null, status: "loading" });
|
|
575
|
+
source.readPictureUrl(reference, variant, abortController.signal).then((url) => {
|
|
576
|
+
if (!abortController.signal.aborted) setState({ url, status: "loaded" });
|
|
577
|
+
}).catch(() => {
|
|
578
|
+
if (!abortController.signal.aborted) setState({ url: null, status: "failed" });
|
|
579
|
+
});
|
|
580
|
+
return () => abortController.abort();
|
|
581
|
+
}, [reference, variant]);
|
|
582
|
+
return reference === null ? { url: null, status: "failed" } : state2;
|
|
583
|
+
};
|
|
584
|
+
const strip = "agents_strip_xPbaz3";
|
|
585
|
+
const stripInComposer = "agents_stripInComposer_n-sG-t";
|
|
586
|
+
const chip$1 = "agents_chip_GNvylF";
|
|
587
|
+
const thumb = "agents_thumb_EuT8G7";
|
|
588
|
+
const name$1 = "agents_name_jW67cw";
|
|
589
|
+
const state = "agents_state_Xvk8tD";
|
|
590
|
+
const remove = "agents_remove_jo2t7F";
|
|
591
|
+
const styles$m = {
|
|
592
|
+
strip,
|
|
593
|
+
stripInComposer,
|
|
594
|
+
chip: chip$1,
|
|
595
|
+
thumb,
|
|
596
|
+
name: name$1,
|
|
597
|
+
state,
|
|
598
|
+
remove
|
|
599
|
+
};
|
|
600
|
+
const AttachedFileThumb = ({ file }) => {
|
|
601
|
+
const picture2 = useFilePictureUrl(file.isImage ? file.reference : null, "THUMBNAIL");
|
|
602
|
+
return /* @__PURE__ */ jsx("span", { className: styles$m.thumb, "aria-hidden": true, children: file.isImage && picture2.url !== null ? /* @__PURE__ */ jsx("img", { src: picture2.url, alt: "" }) : /* @__PURE__ */ jsx(Icon, { name: file.isImage ? "image" : "document", pixelSize: 18 }) });
|
|
603
|
+
};
|
|
604
|
+
const AttachedFilesStrip = ({
|
|
605
|
+
files,
|
|
606
|
+
uploads = [],
|
|
607
|
+
onRemove,
|
|
608
|
+
onDismissUpload,
|
|
609
|
+
inComposer = false,
|
|
610
|
+
testId: testId2 = "attached-files-widget"
|
|
611
|
+
}) => {
|
|
612
|
+
if (files.length === 0 && uploads.length === 0) return null;
|
|
613
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames(styles$m.strip, inComposer && styles$m.stripInComposer), "data-testid": testId2, children: [
|
|
614
|
+
files.map((file) => /* @__PURE__ */ jsxs("div", { className: styles$m.chip, title: file.reference, "data-testid": `${testId2}-file`, children: [
|
|
615
|
+
/* @__PURE__ */ jsx(AttachedFileThumb, { file }),
|
|
616
|
+
/* @__PURE__ */ jsx(Text, { role: "help", translate: false, ellipsis: true, className: styles$m.name, children: file.name }),
|
|
617
|
+
onRemove && /* @__PURE__ */ jsx(
|
|
618
|
+
"button",
|
|
619
|
+
{
|
|
620
|
+
type: "button",
|
|
621
|
+
className: styles$m.remove,
|
|
622
|
+
"aria-label": translateText("Remove %name%", { name: file.name }),
|
|
623
|
+
onClick: () => onRemove(file.reference),
|
|
624
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "close", pixelSize: 10 })
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
] }, file.reference)),
|
|
628
|
+
uploads.map((upload) => /* @__PURE__ */ jsxs("div", { className: styles$m.chip, "data-testid": `${testId2}-upload`, children: [
|
|
629
|
+
/* @__PURE__ */ jsx("span", { className: styles$m.thumb, "aria-hidden": true, children: /* @__PURE__ */ jsx(Icon, { name: upload.state === "uploading" ? "clock" : "exclamation", pixelSize: 18 }) }),
|
|
630
|
+
/* @__PURE__ */ jsxs("span", { className: styles$m.state, children: [
|
|
631
|
+
/* @__PURE__ */ jsx(Text, { role: "help", translate: false, ellipsis: true, children: upload.name }),
|
|
632
|
+
upload.state === "uploading" ? /* @__PURE__ */ jsx(Text, { role: "caption", children: "Uploading…" }) : /* @__PURE__ */ jsx(Text, { role: "caption", translate: false, ellipsis: true, children: upload.state.failed })
|
|
633
|
+
] }),
|
|
634
|
+
upload.state !== "uploading" && onDismissUpload && /* @__PURE__ */ jsx(
|
|
635
|
+
"button",
|
|
636
|
+
{
|
|
637
|
+
type: "button",
|
|
638
|
+
className: styles$m.remove,
|
|
639
|
+
"aria-label": translateText("Remove %name%", { name: upload.name }),
|
|
640
|
+
onClick: () => onDismissUpload(upload.key),
|
|
641
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "close", pixelSize: 10 })
|
|
642
|
+
}
|
|
643
|
+
)
|
|
644
|
+
] }, upload.key))
|
|
645
|
+
] });
|
|
646
|
+
};
|
|
647
|
+
const AttachedFilesConversationWidget = ({ payload }) => {
|
|
648
|
+
const files = useMemo(() => parseAttachedFilesPayload(payload), [payload]);
|
|
649
|
+
useReportWidgetRenderStatus(
|
|
650
|
+
files.length === 0 ? "empty" : "mounted",
|
|
651
|
+
files.length === 0 ? "NO_DATA" : void 0,
|
|
652
|
+
files.length === 0 ? "The AttachedFiles widget names no file reference." : void 0
|
|
653
|
+
);
|
|
654
|
+
return /* @__PURE__ */ jsx(AttachedFilesStrip, { files });
|
|
655
|
+
};
|
|
523
656
|
const IANA_TIME_ZONE_WITH_AREA_SHAPE = /^[A-Za-z][A-Za-z0-9_+-]*(\/[A-Za-z0-9_+-]+)+$/;
|
|
524
657
|
const IANA_TIME_ZONES_WITHOUT_AREA = /* @__PURE__ */ new Set([
|
|
525
658
|
"UTC",
|
|
@@ -787,7 +920,7 @@ const hourHand = "agents_hourHand_NawHe6";
|
|
|
787
920
|
const minuteHand = "agents_minuteHand_WbdO1W";
|
|
788
921
|
const secondHand = "agents_secondHand_TycNnA";
|
|
789
922
|
const dialHub = "agents_dialHub_JfCse6";
|
|
790
|
-
const styles$
|
|
923
|
+
const styles$l = {
|
|
791
924
|
root: root$2,
|
|
792
925
|
rows,
|
|
793
926
|
row: row$2,
|
|
@@ -814,12 +947,12 @@ const TICK_INDICES = Array.from({ length: 12 }, (unused, tickIndex) => tickIndex
|
|
|
814
947
|
const AnalogClockFace = (props) => {
|
|
815
948
|
const { wallClock, accessibleLabel } = props;
|
|
816
949
|
const handAngles = readHandAngles(wallClock);
|
|
817
|
-
return /* @__PURE__ */ jsxs("svg", { className: styles$
|
|
818
|
-
/* @__PURE__ */ jsx("circle", { className: styles$
|
|
950
|
+
return /* @__PURE__ */ jsxs("svg", { className: styles$l.dial, viewBox: "0 0 100 100", role: "img", "aria-label": accessibleLabel, children: [
|
|
951
|
+
/* @__PURE__ */ jsx("circle", { className: styles$l.dialFace, cx: CENTER, cy: CENTER, r: 48 }),
|
|
819
952
|
TICK_INDICES.map((tickIndex) => /* @__PURE__ */ jsx(
|
|
820
953
|
"line",
|
|
821
954
|
{
|
|
822
|
-
className: tickIndex % 3 === 0 ? styles$
|
|
955
|
+
className: tickIndex % 3 === 0 ? styles$l.dialQuarterTick : styles$l.dialTick,
|
|
823
956
|
x1: CENTER,
|
|
824
957
|
y1: tickIndex % 3 === 0 ? 7 : 9,
|
|
825
958
|
x2: CENTER,
|
|
@@ -831,7 +964,7 @@ const AnalogClockFace = (props) => {
|
|
|
831
964
|
/* @__PURE__ */ jsx(
|
|
832
965
|
"line",
|
|
833
966
|
{
|
|
834
|
-
className: styles$
|
|
967
|
+
className: styles$l.hourHand,
|
|
835
968
|
x1: CENTER,
|
|
836
969
|
y1: CENTER + 6,
|
|
837
970
|
x2: CENTER,
|
|
@@ -842,7 +975,7 @@ const AnalogClockFace = (props) => {
|
|
|
842
975
|
/* @__PURE__ */ jsx(
|
|
843
976
|
"line",
|
|
844
977
|
{
|
|
845
|
-
className: styles$
|
|
978
|
+
className: styles$l.minuteHand,
|
|
846
979
|
x1: CENTER,
|
|
847
980
|
y1: CENTER + 7,
|
|
848
981
|
x2: CENTER,
|
|
@@ -853,7 +986,7 @@ const AnalogClockFace = (props) => {
|
|
|
853
986
|
/* @__PURE__ */ jsx(
|
|
854
987
|
"line",
|
|
855
988
|
{
|
|
856
|
-
className: styles$
|
|
989
|
+
className: styles$l.secondHand,
|
|
857
990
|
"data-testid": "clock-second-hand",
|
|
858
991
|
x1: CENTER,
|
|
859
992
|
y1: CENTER + 10,
|
|
@@ -862,19 +995,19 @@ const AnalogClockFace = (props) => {
|
|
|
862
995
|
transform: `rotate(${handAngles.second} ${CENTER} ${CENTER})`
|
|
863
996
|
}
|
|
864
997
|
),
|
|
865
|
-
/* @__PURE__ */ jsx("circle", { className: styles$
|
|
998
|
+
/* @__PURE__ */ jsx("circle", { className: styles$l.dialHub, cx: CENTER, cy: CENTER, r: 2.5 })
|
|
866
999
|
] });
|
|
867
1000
|
};
|
|
868
1001
|
const SUN_RAY_ANGLES = [0, 45, 90, 135, 180, 225, 270, 315];
|
|
869
1002
|
const DayNightGlyph = (props) => {
|
|
870
1003
|
const { isDaytime: isDaytime2 } = props;
|
|
871
1004
|
if (isDaytime2) {
|
|
872
|
-
return /* @__PURE__ */ jsxs("svg", { className: styles$
|
|
873
|
-
/* @__PURE__ */ jsx("circle", { className: styles$
|
|
1005
|
+
return /* @__PURE__ */ jsxs("svg", { className: styles$l.dayNightGlyph, viewBox: "0 0 16 16", "aria-hidden": "true", "data-testid": "clock-sun", children: [
|
|
1006
|
+
/* @__PURE__ */ jsx("circle", { className: styles$l.sunDisc, cx: 8, cy: 8, r: 3.2 }),
|
|
874
1007
|
SUN_RAY_ANGLES.map((rayAngle) => /* @__PURE__ */ jsx(
|
|
875
1008
|
"line",
|
|
876
1009
|
{
|
|
877
|
-
className: styles$
|
|
1010
|
+
className: styles$l.sunRay,
|
|
878
1011
|
x1: 8,
|
|
879
1012
|
y1: 1.5,
|
|
880
1013
|
x2: 8,
|
|
@@ -885,7 +1018,7 @@ const DayNightGlyph = (props) => {
|
|
|
885
1018
|
))
|
|
886
1019
|
] });
|
|
887
1020
|
}
|
|
888
|
-
return /* @__PURE__ */ jsx("svg", { className: styles$
|
|
1021
|
+
return /* @__PURE__ */ jsx("svg", { className: styles$l.dayNightGlyph, viewBox: "0 0 16 16", "aria-hidden": "true", "data-testid": "clock-moon", children: /* @__PURE__ */ jsx("path", { className: styles$l.moon, d: "M10.8 2.2a6 6 0 1 0 3 9.6 5 5 0 0 1-3-9.6z" }) });
|
|
889
1022
|
};
|
|
890
1023
|
const RELATIVE_DAY_KEYS = {
|
|
891
1024
|
today: textKey("Today, %hourDifference% h"),
|
|
@@ -903,9 +1036,9 @@ const ClockRow = (props) => {
|
|
|
903
1036
|
const isDaytimeThere = isDaytime(wallClock);
|
|
904
1037
|
const dateLine = [formatZonedDate(now, clock.timeZone, dateLocale), formatUtcOffset(wallClock.utcOffsetMinutes)].filter((linePart) => linePart !== "").join(" · ");
|
|
905
1038
|
const digitalTime2 = dayPeriod ? `${time} ${dayPeriod}` : time;
|
|
906
|
-
return /* @__PURE__ */ jsxs("div", { className: styles$
|
|
907
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
908
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
1039
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$l.row, "data-testid": "clock-row", "data-time-zone": clock.timeZone, children: [
|
|
1040
|
+
/* @__PURE__ */ jsxs("div", { className: styles$l.readout, children: [
|
|
1041
|
+
/* @__PURE__ */ jsxs("span", { className: styles$l.digitalTime, "data-testid": "clock-digital-time", children: [
|
|
909
1042
|
/* @__PURE__ */ jsx(HeroValue, { children: time }),
|
|
910
1043
|
dayPeriod ? /* @__PURE__ */ jsx(Text, { role: "intro", weight: "bold", translate: false, children: dayPeriod }) : null
|
|
911
1044
|
] }),
|
|
@@ -915,7 +1048,7 @@ const ClockRow = (props) => {
|
|
|
915
1048
|
role: "body",
|
|
916
1049
|
weight: "bold",
|
|
917
1050
|
translate: false,
|
|
918
|
-
className: styles$
|
|
1051
|
+
className: styles$l.wrappingText,
|
|
919
1052
|
testId: `${testId2}-place`,
|
|
920
1053
|
children: escapePlainTextForText(placeLine)
|
|
921
1054
|
}
|
|
@@ -930,7 +1063,7 @@ const ClockRow = (props) => {
|
|
|
930
1063
|
children: RELATIVE_DAY_KEYS[readRelativeDay(wallClock, ownerWallClock)]
|
|
931
1064
|
}
|
|
932
1065
|
),
|
|
933
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
1066
|
+
/* @__PURE__ */ jsxs("span", { className: styles$l.metaLine, children: [
|
|
934
1067
|
/* @__PURE__ */ jsx(
|
|
935
1068
|
Text,
|
|
936
1069
|
{
|
|
@@ -941,7 +1074,7 @@ const ClockRow = (props) => {
|
|
|
941
1074
|
children: dateLine
|
|
942
1075
|
}
|
|
943
1076
|
),
|
|
944
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
1077
|
+
/* @__PURE__ */ jsxs("span", { className: styles$l.dayNight, children: [
|
|
945
1078
|
/* @__PURE__ */ jsx(DayNightGlyph, { isDaytime: isDaytimeThere }),
|
|
946
1079
|
/* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", children: isDaytimeThere ? "Day" : "Night" })
|
|
947
1080
|
] })
|
|
@@ -962,19 +1095,19 @@ const ClockWidget = (props) => {
|
|
|
962
1095
|
captureMoment,
|
|
963
1096
|
testId: testId2 = "clock-widget"
|
|
964
1097
|
} = props;
|
|
965
|
-
return /* @__PURE__ */ jsxs(WidgetSurface, { className: styles$
|
|
1098
|
+
return /* @__PURE__ */ jsxs(WidgetSurface, { className: styles$l.root, testId: testId2, children: [
|
|
966
1099
|
title2 ? /* @__PURE__ */ jsx(
|
|
967
1100
|
Text,
|
|
968
1101
|
{
|
|
969
1102
|
role: "intro",
|
|
970
1103
|
weight: "bold",
|
|
971
1104
|
translate: false,
|
|
972
|
-
className: styles$
|
|
1105
|
+
className: styles$l.wrappingText,
|
|
973
1106
|
testId: `${testId2}-title`,
|
|
974
1107
|
children: escapePlainTextForText(title2)
|
|
975
1108
|
}
|
|
976
1109
|
) : null,
|
|
977
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
1110
|
+
/* @__PURE__ */ jsx("div", { className: styles$l.rows, "data-testid": `${testId2}-rows`, children: clocks.map((clock, clockIndex) => /* @__PURE__ */ jsx(
|
|
978
1111
|
ClockRow,
|
|
979
1112
|
{
|
|
980
1113
|
testId: `${testId2}-row-${clock.timeZone}`,
|
|
@@ -1000,7 +1133,7 @@ const ClockWidget = (props) => {
|
|
|
1000
1133
|
] });
|
|
1001
1134
|
};
|
|
1002
1135
|
const notice$2 = "agents_notice_2XMkZe";
|
|
1003
|
-
const styles$
|
|
1136
|
+
const styles$k = {
|
|
1004
1137
|
notice: notice$2
|
|
1005
1138
|
};
|
|
1006
1139
|
const resolveClocks = (payloadClocks) => {
|
|
@@ -1046,7 +1179,7 @@ const ClockConversationWidget = (props) => {
|
|
|
1046
1179
|
{
|
|
1047
1180
|
role: "help",
|
|
1048
1181
|
color: "var(--agents-fg-light)",
|
|
1049
|
-
className: styles$
|
|
1182
|
+
className: styles$k.notice,
|
|
1050
1183
|
testId: `${testId2}-empty`,
|
|
1051
1184
|
children: "No time zone to show."
|
|
1052
1185
|
}
|
|
@@ -1058,7 +1191,7 @@ const ClockConversationWidget = (props) => {
|
|
|
1058
1191
|
{
|
|
1059
1192
|
role: "help",
|
|
1060
1193
|
color: "var(--agents-fg-light)",
|
|
1061
|
-
className: styles$
|
|
1194
|
+
className: styles$k.notice,
|
|
1062
1195
|
testId: `${testId2}-error`,
|
|
1063
1196
|
children: "The time zones of this clock are unknown."
|
|
1064
1197
|
}
|
|
@@ -1200,7 +1333,7 @@ const pillRow = "agents_pillRow_rL6o6f";
|
|
|
1200
1333
|
const pill$1 = "agents_pill_AOGKJY";
|
|
1201
1334
|
const pillSelected = "agents_pillSelected_7e-VPg";
|
|
1202
1335
|
const footer$2 = "agents_footer_Oxf5Dg";
|
|
1203
|
-
const styles$
|
|
1336
|
+
const styles$j = {
|
|
1204
1337
|
widget: widget$2,
|
|
1205
1338
|
header: header$3,
|
|
1206
1339
|
wrappingText: wrappingText$1,
|
|
@@ -1236,14 +1369,14 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1236
1369
|
const lastStepIndex = steps.length - 1;
|
|
1237
1370
|
const showsStepButtons = !isStatic && steps.length > 1 && steps.length <= MAX_LABELLED_STEPS;
|
|
1238
1371
|
const footerLine = valuesReading.carriesBlockNumbers ? definition.computedLine : definition.illustrationLine;
|
|
1239
|
-
return /* @__PURE__ */ jsxs(WidgetSurface, { className: styles$
|
|
1240
|
-
/* @__PURE__ */ jsxs("header", { className: styles$
|
|
1372
|
+
return /* @__PURE__ */ jsxs(WidgetSurface, { className: styles$j.widget, testId: testId2, children: [
|
|
1373
|
+
/* @__PURE__ */ jsxs("header", { className: styles$j.header, children: [
|
|
1241
1374
|
modelTitle ? /* @__PURE__ */ jsx(
|
|
1242
1375
|
ModelText,
|
|
1243
1376
|
{
|
|
1244
1377
|
role: "intro",
|
|
1245
1378
|
weight: "bold",
|
|
1246
|
-
className: styles$
|
|
1379
|
+
className: styles$j.wrappingText,
|
|
1247
1380
|
testId: `${testId2}-title`,
|
|
1248
1381
|
children: modelTitle
|
|
1249
1382
|
}
|
|
@@ -1253,7 +1386,7 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1253
1386
|
text: definition.defaultTitle,
|
|
1254
1387
|
role: "intro",
|
|
1255
1388
|
weight: "bold",
|
|
1256
|
-
className: styles$
|
|
1389
|
+
className: styles$j.wrappingText,
|
|
1257
1390
|
testId: `${testId2}-title`
|
|
1258
1391
|
}
|
|
1259
1392
|
),
|
|
@@ -1263,11 +1396,11 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1263
1396
|
text: definition.subtitle,
|
|
1264
1397
|
role: "help",
|
|
1265
1398
|
color: "var(--agents-fg-light)",
|
|
1266
|
-
className: styles$
|
|
1399
|
+
className: styles$j.wrappingText
|
|
1267
1400
|
}
|
|
1268
1401
|
)
|
|
1269
1402
|
] }),
|
|
1270
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
1403
|
+
/* @__PURE__ */ jsx("div", { className: styles$j.scene, "data-testid": "concept-explainer-scene", children: /* @__PURE__ */ jsx(
|
|
1271
1404
|
Visual,
|
|
1272
1405
|
{
|
|
1273
1406
|
values: valuesReading.values,
|
|
@@ -1278,14 +1411,14 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1278
1411
|
languageCode
|
|
1279
1412
|
}
|
|
1280
1413
|
) }),
|
|
1281
|
-
currentStep ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
1414
|
+
currentStep ? /* @__PURE__ */ jsxs("div", { className: styles$j.caption, "aria-live": "polite", "data-testid": "concept-explainer-caption", children: [
|
|
1282
1415
|
/* @__PURE__ */ jsx(
|
|
1283
1416
|
ConceptExplainerTextView,
|
|
1284
1417
|
{
|
|
1285
1418
|
text: currentStep.caption,
|
|
1286
1419
|
role: "body",
|
|
1287
1420
|
weight: "bold",
|
|
1288
|
-
className: styles$
|
|
1421
|
+
className: styles$j.wrappingText
|
|
1289
1422
|
}
|
|
1290
1423
|
),
|
|
1291
1424
|
/* @__PURE__ */ jsx(
|
|
@@ -1294,11 +1427,11 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1294
1427
|
text: currentStep.description,
|
|
1295
1428
|
role: "help",
|
|
1296
1429
|
color: "var(--agents-fg-light)",
|
|
1297
|
-
className: styles$
|
|
1430
|
+
className: styles$j.wrappingText
|
|
1298
1431
|
}
|
|
1299
1432
|
)
|
|
1300
1433
|
] }) : null,
|
|
1301
|
-
!isStatic && variants.length > 1 && definition.variantLabel ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
1434
|
+
!isStatic && variants.length > 1 && definition.variantLabel ? /* @__PURE__ */ jsxs("div", { className: styles$j.controlBlock, children: [
|
|
1302
1435
|
/* @__PURE__ */ jsx(
|
|
1303
1436
|
ConceptExplainerTextView,
|
|
1304
1437
|
{
|
|
@@ -1307,21 +1440,21 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1307
1440
|
color: "var(--agents-fg-light)"
|
|
1308
1441
|
}
|
|
1309
1442
|
),
|
|
1310
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
1443
|
+
/* @__PURE__ */ jsx("div", { className: styles$j.pillRow, role: "group", children: variants.map((variant) => /* @__PURE__ */ jsx(
|
|
1311
1444
|
"button",
|
|
1312
1445
|
{
|
|
1313
1446
|
type: "button",
|
|
1314
1447
|
"data-testid": `concept-explainer-variant-${variant.id}`,
|
|
1315
1448
|
"aria-pressed": variant.id === variantId,
|
|
1316
|
-
className: classNames(styles$
|
|
1449
|
+
className: classNames(styles$j.pill, variant.id === variantId && styles$j.pillSelected),
|
|
1317
1450
|
onClick: () => onVariantIdChange(variant.id),
|
|
1318
1451
|
children: /* @__PURE__ */ jsx(ConceptExplainerTextView, { text: variant.label, role: "help" })
|
|
1319
1452
|
},
|
|
1320
1453
|
variant.id
|
|
1321
1454
|
)) })
|
|
1322
1455
|
] }) : null,
|
|
1323
|
-
!isStatic && steps.length > 1 && currentStep ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
1324
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
1456
|
+
!isStatic && steps.length > 1 && currentStep ? /* @__PURE__ */ jsxs("div", { className: styles$j.controlBlock, children: [
|
|
1457
|
+
/* @__PURE__ */ jsxs("div", { className: styles$j.sliderRow, children: [
|
|
1325
1458
|
/* @__PURE__ */ jsx(ConceptExplainerTextView, { text: definition.controlLabel, role: "help" }),
|
|
1326
1459
|
/* @__PURE__ */ jsx(
|
|
1327
1460
|
ConceptExplainerTextView,
|
|
@@ -1329,12 +1462,12 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1329
1462
|
text: currentStep.label,
|
|
1330
1463
|
role: "help",
|
|
1331
1464
|
weight: "medium",
|
|
1332
|
-
className: styles$
|
|
1465
|
+
className: styles$j.sliderValue,
|
|
1333
1466
|
testId: `${testId2}-current-step`
|
|
1334
1467
|
}
|
|
1335
1468
|
)
|
|
1336
1469
|
] }),
|
|
1337
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
1470
|
+
/* @__PURE__ */ jsx("div", { className: styles$j.sliderTrack, "data-testid": "concept-explainer-slider", children: /* @__PURE__ */ jsx(
|
|
1338
1471
|
RangeSlider,
|
|
1339
1472
|
{
|
|
1340
1473
|
value: stepIndex,
|
|
@@ -1346,27 +1479,27 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1346
1479
|
}
|
|
1347
1480
|
}
|
|
1348
1481
|
) }),
|
|
1349
|
-
showsStepButtons ? /* @__PURE__ */ jsx("div", { className: styles$
|
|
1482
|
+
showsStepButtons ? /* @__PURE__ */ jsx("div", { className: styles$j.pillRow, role: "group", children: steps.map((step, index) => /* @__PURE__ */ jsx(
|
|
1350
1483
|
"button",
|
|
1351
1484
|
{
|
|
1352
1485
|
type: "button",
|
|
1353
1486
|
"data-testid": `concept-explainer-step-${step.id}`,
|
|
1354
1487
|
"aria-pressed": index === stepIndex,
|
|
1355
|
-
className: classNames(styles$
|
|
1488
|
+
className: classNames(styles$j.pill, index === stepIndex && styles$j.pillSelected),
|
|
1356
1489
|
onClick: () => onStepIndexChange(index),
|
|
1357
1490
|
children: /* @__PURE__ */ jsx(ConceptExplainerTextView, { text: step.label, role: "help" })
|
|
1358
1491
|
},
|
|
1359
1492
|
step.id
|
|
1360
1493
|
)) }) : null
|
|
1361
1494
|
] }) : null,
|
|
1362
|
-
/* @__PURE__ */ jsxs("footer", { className: styles$
|
|
1495
|
+
/* @__PURE__ */ jsxs("footer", { className: styles$j.footer, children: [
|
|
1363
1496
|
definition.sourceLine ? /* @__PURE__ */ jsx(
|
|
1364
1497
|
ConceptExplainerTextView,
|
|
1365
1498
|
{
|
|
1366
1499
|
text: definition.sourceLine,
|
|
1367
1500
|
role: "caption",
|
|
1368
1501
|
color: "var(--agents-fg-lightest)",
|
|
1369
|
-
className: styles$
|
|
1502
|
+
className: styles$j.wrappingText
|
|
1370
1503
|
}
|
|
1371
1504
|
) : null,
|
|
1372
1505
|
footerLine ? /* @__PURE__ */ jsx(
|
|
@@ -1375,7 +1508,7 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1375
1508
|
text: footerLine,
|
|
1376
1509
|
role: "caption",
|
|
1377
1510
|
color: "var(--agents-fg-lightest)",
|
|
1378
|
-
className: styles$
|
|
1511
|
+
className: styles$j.wrappingText,
|
|
1379
1512
|
testId: "concept-explainer-data-line"
|
|
1380
1513
|
}
|
|
1381
1514
|
) : null
|
|
@@ -1383,7 +1516,7 @@ const ConceptExplainerWidget = (props) => {
|
|
|
1383
1516
|
] });
|
|
1384
1517
|
};
|
|
1385
1518
|
const notice$1 = "agents_notice_Q0qNKx";
|
|
1386
|
-
const styles$
|
|
1519
|
+
const styles$i = {
|
|
1387
1520
|
notice: notice$1
|
|
1388
1521
|
};
|
|
1389
1522
|
const MAX_QUOTED_TYPE_ID_LENGTH = 40;
|
|
@@ -1457,7 +1590,7 @@ const ConceptExplainerConversationWidget = (props) => {
|
|
|
1457
1590
|
{
|
|
1458
1591
|
role: "help",
|
|
1459
1592
|
color: "var(--agents-fg-light)",
|
|
1460
|
-
className: styles$
|
|
1593
|
+
className: styles$i.notice,
|
|
1461
1594
|
testId: `${testId2}-empty`,
|
|
1462
1595
|
children: "No explanation to show."
|
|
1463
1596
|
}
|
|
@@ -1469,7 +1602,7 @@ const ConceptExplainerConversationWidget = (props) => {
|
|
|
1469
1602
|
{
|
|
1470
1603
|
role: "help",
|
|
1471
1604
|
color: "var(--agents-fg-light)",
|
|
1472
|
-
className: styles$
|
|
1605
|
+
className: styles$i.notice,
|
|
1473
1606
|
testId: `${testId2}-error`,
|
|
1474
1607
|
children: "This explanation is not available."
|
|
1475
1608
|
}
|
|
@@ -1575,7 +1708,7 @@ const readCurrencySymbol = (currencyCode, locale) => {
|
|
|
1575
1708
|
const readCurrencyFlag = (currencyCode) => {
|
|
1576
1709
|
const countryCode = currencyCode === "EUR" ? "EU" : currencyCode.slice(0, 2);
|
|
1577
1710
|
if (!/^[A-Z]{2}$/.test(countryCode)) return "";
|
|
1578
|
-
return String.fromCodePoint(...[...countryCode].map((
|
|
1711
|
+
return String.fromCodePoint(...[...countryCode].map((letter2) => 127462 + letter2.charCodeAt(0) - 65));
|
|
1579
1712
|
};
|
|
1580
1713
|
const formatCurrencyAmount = (amount2, currencyCode, locale) => {
|
|
1581
1714
|
try {
|
|
@@ -1634,16 +1767,16 @@ const parseTypedAmount = (typedText, locale = "en") => {
|
|
|
1634
1767
|
const currency = "agents_currency_CR9unA";
|
|
1635
1768
|
const flag = "agents_flag_6dGtG2";
|
|
1636
1769
|
const text$1 = "agents_text_Cec7cq";
|
|
1637
|
-
const styles$
|
|
1770
|
+
const styles$h = {
|
|
1638
1771
|
currency,
|
|
1639
1772
|
flag,
|
|
1640
1773
|
text: text$1
|
|
1641
1774
|
};
|
|
1642
1775
|
const CurrencyLabel = (props) => {
|
|
1643
1776
|
const { currencyCode, locale, nameId, testId: testId2 } = props;
|
|
1644
|
-
return /* @__PURE__ */ jsxs("div", { className: styles$
|
|
1645
|
-
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles$
|
|
1646
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
1777
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$h.currency, "data-testid": testId2, children: [
|
|
1778
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles$h.flag, children: readCurrencyFlag(currencyCode) }),
|
|
1779
|
+
/* @__PURE__ */ jsxs("div", { className: styles$h.text, children: [
|
|
1647
1780
|
/* @__PURE__ */ jsx(Text, { role: "help", weight: "bold", translate: false, children: currencyCode }),
|
|
1648
1781
|
/* @__PURE__ */ jsx("span", { id: nameId, children: /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", ellipsis: true, translate: false, children: readCurrencyName(currencyCode, locale) }) })
|
|
1649
1782
|
] })
|
|
@@ -1662,7 +1795,7 @@ const heroRow = "agents_heroRow_XRyMo-";
|
|
|
1662
1795
|
const divider = "agents_divider_tSMuNB";
|
|
1663
1796
|
const swap = "agents_swap_mI6Ugc";
|
|
1664
1797
|
const footer$1 = "agents_footer_2UNCNT";
|
|
1665
|
-
const styles$
|
|
1798
|
+
const styles$g = {
|
|
1666
1799
|
widget: widget$1,
|
|
1667
1800
|
title,
|
|
1668
1801
|
row: row$1,
|
|
@@ -1693,10 +1826,10 @@ const CurrencyConverterWidget = (props) => {
|
|
|
1693
1826
|
const toSymbol = readCurrencySymbol(toCurrency, locale);
|
|
1694
1827
|
const rateDateText = conversion.rateDate ? formatRateDate(conversion.rateDate, locale) : void 0;
|
|
1695
1828
|
const fieldWidth = { width: `${Math.max(typedAmount.length, 1) + 0.5}ch` };
|
|
1696
|
-
return /* @__PURE__ */ jsxs("section", { className: styles$
|
|
1697
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
1829
|
+
return /* @__PURE__ */ jsxs("section", { className: styles$g.widget, "data-testid": testId2, children: [
|
|
1830
|
+
/* @__PURE__ */ jsx("div", { className: styles$g.title, children: /* @__PURE__ */ jsx(Text, { role: "intro", weight: "bold", testId: `${testId2}-title`, children: "Currency converter" }) }),
|
|
1698
1831
|
/* @__PURE__ */ jsxs(WidgetSurface, { children: [
|
|
1699
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
1832
|
+
/* @__PURE__ */ jsxs("div", { className: styles$g.row, children: [
|
|
1700
1833
|
/* @__PURE__ */ jsx(
|
|
1701
1834
|
CurrencyLabel,
|
|
1702
1835
|
{
|
|
@@ -1706,19 +1839,19 @@ const CurrencyConverterWidget = (props) => {
|
|
|
1706
1839
|
testId: `${testId2}-from-currency`
|
|
1707
1840
|
}
|
|
1708
1841
|
),
|
|
1709
|
-
isStatic ? /* @__PURE__ */ jsxs("div", { className: styles$
|
|
1842
|
+
isStatic ? /* @__PURE__ */ jsxs("div", { className: styles$g.amount, children: [
|
|
1710
1843
|
/* @__PURE__ */ jsx(Text, { role: "title", translate: false, testId: `${testId2}-amount-static`, children: amount2 === void 0 ? "–" : formatCurrencyAmount(amount2, fromCurrency, locale) }),
|
|
1711
1844
|
/* @__PURE__ */ jsx(Text, { role: "intro", color: "var(--agents-fg-light)", translate: false, children: fromSymbol })
|
|
1712
1845
|
] }) : /* @__PURE__ */ jsxs(
|
|
1713
1846
|
"div",
|
|
1714
1847
|
{
|
|
1715
|
-
className: classNames(styles$
|
|
1848
|
+
className: classNames(styles$g.amount, styles$g.field, isInvalid && styles$g.fieldInvalid),
|
|
1716
1849
|
"data-testid": "currency-converter-amount",
|
|
1717
1850
|
children: [
|
|
1718
1851
|
/* @__PURE__ */ jsx(
|
|
1719
1852
|
"input",
|
|
1720
1853
|
{
|
|
1721
|
-
className: styles$
|
|
1854
|
+
className: styles$g.input,
|
|
1722
1855
|
"data-testid": `${testId2}-input-amount`,
|
|
1723
1856
|
type: "text",
|
|
1724
1857
|
inputMode: "decimal",
|
|
@@ -1736,25 +1869,25 @@ const CurrencyConverterWidget = (props) => {
|
|
|
1736
1869
|
}
|
|
1737
1870
|
)
|
|
1738
1871
|
] }),
|
|
1739
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
1872
|
+
/* @__PURE__ */ jsx("div", { className: styles$g.divider, children: isStatic ? null : /* @__PURE__ */ jsx(
|
|
1740
1873
|
"button",
|
|
1741
1874
|
{
|
|
1742
1875
|
type: "button",
|
|
1743
|
-
className: styles$
|
|
1876
|
+
className: styles$g.swap,
|
|
1744
1877
|
"aria-label": translateText("Swap currencies"),
|
|
1745
1878
|
"data-testid": "currency-converter-swap",
|
|
1746
1879
|
onClick: () => setIsSwapped((wasSwapped) => !wasSwapped),
|
|
1747
1880
|
children: /* @__PURE__ */ jsx(Icon, { name: "sorting" })
|
|
1748
1881
|
}
|
|
1749
1882
|
) }),
|
|
1750
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
1883
|
+
/* @__PURE__ */ jsxs("div", { className: styles$g.row, children: [
|
|
1751
1884
|
/* @__PURE__ */ jsx(CurrencyLabel, { currencyCode: toCurrency, locale, testId: `${testId2}-to-currency` }),
|
|
1752
|
-
/* @__PURE__ */ jsxs("div", { className: classNames(styles$
|
|
1753
|
-
/* @__PURE__ */ jsx("span", { className: styles$
|
|
1885
|
+
/* @__PURE__ */ jsxs("div", { className: classNames(styles$g.amount, styles$g.result), "data-testid": "currency-converter-result", children: [
|
|
1886
|
+
/* @__PURE__ */ jsx("span", { className: styles$g.heroSlot, children: /* @__PURE__ */ jsx("span", { className: styles$g.heroRow, "data-hero-row": "", children: /* @__PURE__ */ jsx(HeroValue, { children: convertedAmount === void 0 ? "–" : formatCurrencyAmount(convertedAmount, toCurrency, locale) }) }) }),
|
|
1754
1887
|
/* @__PURE__ */ jsx(Text, { role: "intro", color: "var(--agents-fg-light)", translate: false, children: toSymbol })
|
|
1755
1888
|
] })
|
|
1756
1889
|
] }),
|
|
1757
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
1890
|
+
/* @__PURE__ */ jsxs("div", { className: styles$g.footer, children: [
|
|
1758
1891
|
/* @__PURE__ */ jsx(
|
|
1759
1892
|
Text,
|
|
1760
1893
|
{
|
|
@@ -2027,7 +2160,7 @@ const frameArea = "agents_frameArea_oTAxfc";
|
|
|
2027
2160
|
const frameBox = "agents_frameBox_SO1EpU";
|
|
2028
2161
|
const frame$1 = "agents_frame_uN2yj-";
|
|
2029
2162
|
const loadingCover = "agents_loadingCover_G8fy2S";
|
|
2030
|
-
const styles$
|
|
2163
|
+
const styles$f = {
|
|
2031
2164
|
frameArea,
|
|
2032
2165
|
frameBox,
|
|
2033
2166
|
frame: frame$1,
|
|
@@ -2150,13 +2283,13 @@ const CustomVisualizationFrame = (props) => {
|
|
|
2150
2283
|
if (failure2?.frameRemoved) {
|
|
2151
2284
|
return /* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-light)", testId: `${testId2}-closed`, children: "The visualization stopped working and was closed." });
|
|
2152
2285
|
}
|
|
2153
|
-
return /* @__PURE__ */ jsxs("div", { ref: themeScopeRef, className: styles$
|
|
2154
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
2286
|
+
return /* @__PURE__ */ jsxs("div", { ref: themeScopeRef, className: styles$f.frameArea, children: [
|
|
2287
|
+
/* @__PURE__ */ jsxs("div", { className: styles$f.frameBox, "data-frame-phase": phase, "data-testid": `${testId2}-frame-box`, children: [
|
|
2155
2288
|
/* @__PURE__ */ jsx(
|
|
2156
2289
|
"iframe",
|
|
2157
2290
|
{
|
|
2158
2291
|
ref: iframeRef,
|
|
2159
|
-
className: styles$
|
|
2292
|
+
className: styles$f.frame,
|
|
2160
2293
|
"data-testid": `${testId2}-frame`,
|
|
2161
2294
|
style: { height: frameHeight },
|
|
2162
2295
|
src: frameUrl,
|
|
@@ -2167,7 +2300,7 @@ const CustomVisualizationFrame = (props) => {
|
|
|
2167
2300
|
onLoad: () => setIsFrameLoaded(true)
|
|
2168
2301
|
}
|
|
2169
2302
|
),
|
|
2170
|
-
phase === "loading" ? /* @__PURE__ */ jsx("span", { className: styles$
|
|
2303
|
+
phase === "loading" ? /* @__PURE__ */ jsx("span", { className: styles$f.loadingCover, "aria-busy": "true", "data-testid": `${testId2}-skeleton`, children: /* @__PURE__ */ jsx(SkeletonLine, { height: frameHeight, radius: 12 }) }) : null
|
|
2171
2304
|
] }),
|
|
2172
2305
|
phase === "failed" ? /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", testId: `${testId2}-error`, children: "Part of this visualization could not run." }) : null
|
|
2173
2306
|
] });
|
|
@@ -2177,7 +2310,7 @@ const content = "agents_content_lKDfwn";
|
|
|
2177
2310
|
const header$2 = "agents_header_G4HmWs";
|
|
2178
2311
|
const staticPreviewTile = "agents_staticPreviewTile_p0CkBm";
|
|
2179
2312
|
const staticPreviewIcon = "agents_staticPreviewIcon_YIgGKQ";
|
|
2180
|
-
const styles$
|
|
2313
|
+
const styles$e = {
|
|
2181
2314
|
widget,
|
|
2182
2315
|
content,
|
|
2183
2316
|
header: header$2,
|
|
@@ -2187,14 +2320,14 @@ const styles$d = {
|
|
|
2187
2320
|
const CustomVisualizationHeader = (props) => {
|
|
2188
2321
|
const { title: title2, description, testId: testId2 } = props;
|
|
2189
2322
|
if (title2 === "" && description === "") return null;
|
|
2190
|
-
return /* @__PURE__ */ jsxs("div", { className: styles$
|
|
2323
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$e.header, children: [
|
|
2191
2324
|
title2 !== "" ? /* @__PURE__ */ jsx(ModelText, { role: "intro", weight: "bold", testId: `${testId2}-title`, children: title2 }) : null,
|
|
2192
2325
|
description !== "" ? /* @__PURE__ */ jsx(ModelText, { role: "caption", color: "var(--agents-fg-light)", testId: `${testId2}-description`, children: description }) : null
|
|
2193
2326
|
] });
|
|
2194
2327
|
};
|
|
2195
2328
|
const CustomVisualizationSurface = (props) => {
|
|
2196
2329
|
const { children, testId: testId2 } = props;
|
|
2197
|
-
return /* @__PURE__ */ jsx(WidgetSurface, { className: styles$
|
|
2330
|
+
return /* @__PURE__ */ jsx(WidgetSurface, { className: styles$e.widget, testId: testId2, children: /* @__PURE__ */ jsx("div", { className: styles$e.content, children }) });
|
|
2198
2331
|
};
|
|
2199
2332
|
const CustomVisualizationWidget = (props) => {
|
|
2200
2333
|
const { payload, testId: testId2 = "custom-visualization-widget" } = props;
|
|
@@ -2207,8 +2340,8 @@ const CustomVisualizationStaticPreview = (props) => {
|
|
|
2207
2340
|
const { title: title2, description, testId: testId2 = "custom-visualization-widget" } = props;
|
|
2208
2341
|
return /* @__PURE__ */ jsxs(CustomVisualizationSurface, { testId: testId2, children: [
|
|
2209
2342
|
/* @__PURE__ */ jsx(CustomVisualizationHeader, { title: title2, description, testId: testId2 }),
|
|
2210
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
2211
|
-
/* @__PURE__ */ jsx(Icon, { className: styles$
|
|
2343
|
+
/* @__PURE__ */ jsxs("div", { className: styles$e.staticPreviewTile, "data-testid": `${testId2}-static-preview`, children: [
|
|
2344
|
+
/* @__PURE__ */ jsx(Icon, { className: styles$e.staticPreviewIcon, name: "barChart" }),
|
|
2212
2345
|
/* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-light)", children: "Interactive visualization — open the conversation to use it." })
|
|
2213
2346
|
] })
|
|
2214
2347
|
] });
|
|
@@ -2270,7 +2403,9 @@ const packageCanvasBehaviours = {
|
|
|
2270
2403
|
// One entity's detail, opened from a ComposedView row (`openEntity`) — a click, never a live delivery.
|
|
2271
2404
|
entityDetail: { lifetime: "turn", layout: "split", widthPercent: 40, narrowViewport: "none", fullBleed: false },
|
|
2272
2405
|
// A ComposedView `Map` node, full screen — the widest split a turn canvas takes, the map flush.
|
|
2273
|
-
mapFullScreen: { lifetime: "turn", layout: "split", widthPercent: 65, narrowViewport: "none", fullBleed: true }
|
|
2406
|
+
mapFullScreen: { lifetime: "turn", layout: "split", widthPercent: 65, narrowViewport: "none", fullBleed: true },
|
|
2407
|
+
// An ImageGallery of many pictures (or `display: "canvas"`): the gallery beside the chat (a phone keeps the card).
|
|
2408
|
+
imageGallery: { lifetime: "turn", layout: "split", narrowViewport: "none", fullBleed: false }
|
|
2274
2409
|
};
|
|
2275
2410
|
const hasOwnCanvasBehaviour = (behaviours, canvasId) => Object.prototype.hasOwnProperty.call(behaviours, canvasId);
|
|
2276
2411
|
const isPackageCanvasId = (canvasId) => hasOwnCanvasBehaviour(packageCanvasBehaviours, canvasId);
|
|
@@ -2482,7 +2617,7 @@ const registerDriveFilesHydrator = () => {
|
|
|
2482
2617
|
};
|
|
2483
2618
|
const stack = "agents_stack_-DCHyS";
|
|
2484
2619
|
const list = "agents_list_vjc4ux";
|
|
2485
|
-
const tile = "agents_tile_LbYH0z";
|
|
2620
|
+
const tile$1 = "agents_tile_LbYH0z";
|
|
2486
2621
|
const tileThumbnail = "agents_tileThumbnail_t8qagr";
|
|
2487
2622
|
const tileFolder = "agents_tileFolder_9GSzCJ";
|
|
2488
2623
|
const tilePdf = "agents_tilePdf_MvAe2u";
|
|
@@ -2496,11 +2631,11 @@ const tileArchive = "agents_tileArchive_zPZ4gE";
|
|
|
2496
2631
|
const meta$1 = "agents_meta_-i6woG";
|
|
2497
2632
|
const facts = "agents_facts_6Ki6Tj";
|
|
2498
2633
|
const failure = "agents_failure_sEhw7-";
|
|
2499
|
-
const actions$
|
|
2500
|
-
const styles$
|
|
2634
|
+
const actions$2 = "agents_actions_8Fqa9-";
|
|
2635
|
+
const styles$d = {
|
|
2501
2636
|
stack,
|
|
2502
2637
|
list,
|
|
2503
|
-
tile,
|
|
2638
|
+
tile: tile$1,
|
|
2504
2639
|
tileThumbnail,
|
|
2505
2640
|
tileFolder,
|
|
2506
2641
|
tilePdf,
|
|
@@ -2514,20 +2649,20 @@ const styles$c = {
|
|
|
2514
2649
|
meta: meta$1,
|
|
2515
2650
|
facts,
|
|
2516
2651
|
failure,
|
|
2517
|
-
actions: actions$
|
|
2652
|
+
actions: actions$2
|
|
2518
2653
|
};
|
|
2519
2654
|
const TEST_ID = "drive-files-widget";
|
|
2520
2655
|
const DriveFilesHeadline = ({ request }) => request.title !== null ? /* @__PURE__ */ jsx(Text, { role: "intro", weight: "bold", translate: false, testId: `${TEST_ID}-title`, children: escapePlainTextForText(request.title) }) : /* @__PURE__ */ jsx(Text, { role: "intro", weight: "bold", replacements: { count: request.references.length }, testId: `${TEST_ID}-title`, children: request.references.length === 1 ? "1 file from the drive" : "%count% files from the drive" });
|
|
2521
2656
|
const FAMILY_TILE_CLASS = {
|
|
2522
|
-
PDF: styles$
|
|
2523
|
-
SPREADSHEET: styles$
|
|
2524
|
-
DOCUMENT: styles$
|
|
2525
|
-
PRESENTATION: styles$
|
|
2526
|
-
TEXT: styles$
|
|
2527
|
-
IMAGE: styles$
|
|
2528
|
-
VECTOR: styles$
|
|
2529
|
-
VIDEO: styles$
|
|
2530
|
-
ARCHIVE: styles$
|
|
2657
|
+
PDF: styles$d.tilePdf,
|
|
2658
|
+
SPREADSHEET: styles$d.tileSpreadsheet,
|
|
2659
|
+
DOCUMENT: styles$d.tileDocument,
|
|
2660
|
+
PRESENTATION: styles$d.tilePresentation,
|
|
2661
|
+
TEXT: styles$d.tileText,
|
|
2662
|
+
IMAGE: styles$d.tileImage,
|
|
2663
|
+
VECTOR: styles$d.tileImage,
|
|
2664
|
+
VIDEO: styles$d.tileVideo,
|
|
2665
|
+
ARCHIVE: styles$d.tileArchive
|
|
2531
2666
|
};
|
|
2532
2667
|
const FolderGlyph = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "20", height: "20", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx(
|
|
2533
2668
|
"path",
|
|
@@ -2541,13 +2676,13 @@ const DriveFileTile = ({ card: card2 }) => {
|
|
|
2541
2676
|
const thumbnailUrl = card2.thumbnailUrl ?? null;
|
|
2542
2677
|
const source = thumbnailUrl && failedSource !== thumbnailUrl ? thumbnailUrl : null;
|
|
2543
2678
|
if (card2.isFolder) {
|
|
2544
|
-
return /* @__PURE__ */ jsx("span", { className: `${styles$
|
|
2679
|
+
return /* @__PURE__ */ jsx("span", { className: `${styles$d.tile} ${styles$d.tileFolder}`, "data-testid": `${TEST_ID}-folder-tile`, children: /* @__PURE__ */ jsx(FolderGlyph, {}) });
|
|
2545
2680
|
}
|
|
2546
2681
|
if (source) {
|
|
2547
|
-
return /* @__PURE__ */ jsx("span", { className: `${styles$
|
|
2682
|
+
return /* @__PURE__ */ jsx("span", { className: `${styles$d.tile} ${styles$d.tileThumbnail}`, children: /* @__PURE__ */ jsx("img", { src: source, alt: "", loading: "lazy", draggable: false, onError: () => setFailedSource(source) }) });
|
|
2548
2683
|
}
|
|
2549
2684
|
const typeLabel = driveFileTypeLabelOf(card2) ?? "";
|
|
2550
|
-
return /* @__PURE__ */ jsx("span", { className: `${styles$
|
|
2685
|
+
return /* @__PURE__ */ jsx("span", { className: `${styles$d.tile} ${FAMILY_TILE_CLASS[driveFileFamilyOf(card2)]}`, "aria-hidden": "true", children: typeLabel.slice(0, 4) });
|
|
2551
2686
|
};
|
|
2552
2687
|
const startDownload = (url, fileName) => {
|
|
2553
2688
|
const anchor2 = document.createElement("a");
|
|
@@ -2632,12 +2767,12 @@ const DriveFileCardRow = ({ card: card2, openCard, source, store, messageId, onC
|
|
|
2632
2767
|
setBusy(false);
|
|
2633
2768
|
}
|
|
2634
2769
|
};
|
|
2635
|
-
const meta2 = /* @__PURE__ */ jsxs("span", { className: styles$
|
|
2636
|
-
facts2 !== "" ? /* @__PURE__ */ jsx("span", { className: styles$
|
|
2770
|
+
const meta2 = /* @__PURE__ */ jsxs("span", { className: styles$d.meta, children: [
|
|
2771
|
+
facts2 !== "" ? /* @__PURE__ */ jsx("span", { className: styles$d.facts, children: facts2 }) : null,
|
|
2637
2772
|
card2.state ? /* @__PURE__ */ jsx(StatusChip, { tone: "warning", compact: true, translate: false, children: escapePlainTextForText(card2.state) }) : null,
|
|
2638
|
-
failure2 !== null ? /* @__PURE__ */ jsx("span", { role: "alert", className: styles$
|
|
2773
|
+
failure2 !== null ? /* @__PURE__ */ jsx("span", { role: "alert", className: styles$d.failure, children: failure2 }) : null
|
|
2639
2774
|
] });
|
|
2640
|
-
const actions2 = /* @__PURE__ */ jsxs("span", { className: styles$
|
|
2775
|
+
const actions2 = /* @__PURE__ */ jsxs("span", { className: styles$d.actions, children: [
|
|
2641
2776
|
canvasTarget !== null ? /* @__PURE__ */ jsx(Tooltip, { text: "Open %name%", replacements: { name: name2 }, children: /* @__PURE__ */ jsx(
|
|
2642
2777
|
Button,
|
|
2643
2778
|
{
|
|
@@ -2708,14 +2843,14 @@ const HydratedDriveFiles = ({ request, justDelivered, messageId }) => {
|
|
|
2708
2843
|
notConnected ? "No drive is connected to this frontend; the DriveFiles card cannot read its files." : hydration.isError ? "The DriveFiles card could not read its files." : hasData && cards.length === 0 ? "The DriveFiles card shows no file: none of its references is readable for the viewer." : void 0
|
|
2709
2844
|
);
|
|
2710
2845
|
if (notConnected) {
|
|
2711
|
-
return /* @__PURE__ */ jsx(WidgetSurface, { testId: TEST_ID, children: /* @__PURE__ */ jsxs("div", { className: styles$
|
|
2846
|
+
return /* @__PURE__ */ jsx(WidgetSurface, { testId: TEST_ID, children: /* @__PURE__ */ jsxs("div", { className: styles$d.stack, children: [
|
|
2712
2847
|
/* @__PURE__ */ jsx(DriveFilesHeadline, { request }),
|
|
2713
2848
|
/* @__PURE__ */ jsx(Text, { role: "body", weight: "bold", children: "The drive is not connected yet" }),
|
|
2714
2849
|
/* @__PURE__ */ jsx(Text, { role: "help", children: "These files show here once the drive is part of this app." })
|
|
2715
2850
|
] }) });
|
|
2716
2851
|
}
|
|
2717
2852
|
if (hydration.isError) {
|
|
2718
|
-
return /* @__PURE__ */ jsx(WidgetSurface, { testId: TEST_ID, children: /* @__PURE__ */ jsxs("div", { className: styles$
|
|
2853
|
+
return /* @__PURE__ */ jsx(WidgetSurface, { testId: TEST_ID, children: /* @__PURE__ */ jsxs("div", { className: styles$d.stack, children: [
|
|
2719
2854
|
/* @__PURE__ */ jsx(DriveFilesHeadline, { request }),
|
|
2720
2855
|
/* @__PURE__ */ jsx(Text, { role: "body", children: "The files could not be loaded." }),
|
|
2721
2856
|
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Button, { variant: "default", size: "small", onClick: () => hydration.refetch(), testId: `${TEST_ID}-retry`, children: "Try again" }) })
|
|
@@ -2731,12 +2866,12 @@ const HydratedDriveFiles = ({ request, justDelivered, messageId }) => {
|
|
|
2731
2866
|
}
|
|
2732
2867
|
);
|
|
2733
2868
|
}
|
|
2734
|
-
return /* @__PURE__ */ jsx(WidgetSurface, { testId: TEST_ID, children: /* @__PURE__ */ jsxs("div", { className: styles$
|
|
2869
|
+
return /* @__PURE__ */ jsx(WidgetSurface, { testId: TEST_ID, children: /* @__PURE__ */ jsxs("div", { className: styles$d.stack, children: [
|
|
2735
2870
|
/* @__PURE__ */ jsx(DriveFilesHeadline, { request }),
|
|
2736
2871
|
cards.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2737
2872
|
/* @__PURE__ */ jsx(Text, { role: "body", weight: "bold", children: "No file to show" }),
|
|
2738
2873
|
/* @__PURE__ */ jsx(Text, { role: "help", children: "These files were removed, or you may not open them." })
|
|
2739
|
-
] }) : /* @__PURE__ */ jsx("div", { role: "list", className: styles$
|
|
2874
|
+
] }) : /* @__PURE__ */ jsx("div", { role: "list", className: styles$d.list, children: cards.map((card2) => /* @__PURE__ */ jsx(
|
|
2740
2875
|
DriveFileCardRow,
|
|
2741
2876
|
{
|
|
2742
2877
|
card: card2,
|
|
@@ -2790,7 +2925,7 @@ const iconTile = "agents_iconTile_8LLt9b";
|
|
|
2790
2925
|
const text = "agents_text_IBPWXe";
|
|
2791
2926
|
const caption = "agents_caption_Rqoy-c";
|
|
2792
2927
|
const label = "agents_label_rk7rVc";
|
|
2793
|
-
const styles$
|
|
2928
|
+
const styles$c = {
|
|
2794
2929
|
card: card$1,
|
|
2795
2930
|
iconTile,
|
|
2796
2931
|
text,
|
|
@@ -2799,13 +2934,13 @@ const styles$b = {
|
|
|
2799
2934
|
};
|
|
2800
2935
|
const EntityMentionWidgetBody = (props) => {
|
|
2801
2936
|
const { mention, testId: testId2 = "entity-mention-chip" } = props;
|
|
2802
|
-
return /* @__PURE__ */ jsxs("div", { className: styles$
|
|
2803
|
-
/* @__PURE__ */ jsx("span", { className: styles$
|
|
2804
|
-
/* @__PURE__ */ jsxs("span", { className: styles$
|
|
2937
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$c.card, "data-testid": testId2, children: [
|
|
2938
|
+
/* @__PURE__ */ jsx("span", { className: styles$c.iconTile, "data-testid": `${testId2}-icon`, children: /* @__PURE__ */ jsx(Icon, { color: "var(--agents-fg-cta)", pixelSize: 16, name: entityTypeIcon(mention.entityType) }) }),
|
|
2939
|
+
/* @__PURE__ */ jsxs("span", { className: styles$c.text, children: [
|
|
2805
2940
|
/* @__PURE__ */ jsx(
|
|
2806
2941
|
Text,
|
|
2807
2942
|
{
|
|
2808
|
-
className: styles$
|
|
2943
|
+
className: styles$c.caption,
|
|
2809
2944
|
role: "caption",
|
|
2810
2945
|
color: "var(--agents-fg-lightest)",
|
|
2811
2946
|
textWrap: "nowrap",
|
|
@@ -2816,7 +2951,7 @@ const EntityMentionWidgetBody = (props) => {
|
|
|
2816
2951
|
mention.label !== null ? /* @__PURE__ */ jsx(
|
|
2817
2952
|
ModelText,
|
|
2818
2953
|
{
|
|
2819
|
-
className: styles$
|
|
2954
|
+
className: styles$c.label,
|
|
2820
2955
|
role: "help",
|
|
2821
2956
|
weight: "bold",
|
|
2822
2957
|
textWrap: "nowrap",
|
|
@@ -2826,7 +2961,7 @@ const EntityMentionWidgetBody = (props) => {
|
|
|
2826
2961
|
) : /* @__PURE__ */ jsx(
|
|
2827
2962
|
Text,
|
|
2828
2963
|
{
|
|
2829
|
-
className: styles$
|
|
2964
|
+
className: styles$c.label,
|
|
2830
2965
|
role: "help",
|
|
2831
2966
|
weight: "bold",
|
|
2832
2967
|
textWrap: "nowrap",
|
|
@@ -2898,7 +3033,7 @@ const toEntityMentionWireFields = (mention) => {
|
|
|
2898
3033
|
};
|
|
2899
3034
|
const entityMentionKey = (mention) => `${mention.entityType}:${mention.entityId}`;
|
|
2900
3035
|
const row = "agents_row_wARikn";
|
|
2901
|
-
const styles$
|
|
3036
|
+
const styles$b = {
|
|
2902
3037
|
row
|
|
2903
3038
|
};
|
|
2904
3039
|
const EntityMentionConversationWidget = (props) => {
|
|
@@ -2910,610 +3045,1241 @@ const EntityMentionConversationWidget = (props) => {
|
|
|
2910
3045
|
mention === null ? "the EntityMention names no entity (entityType + entityId)" : void 0
|
|
2911
3046
|
);
|
|
2912
3047
|
if (mention === null) return null;
|
|
2913
|
-
return /* @__PURE__ */ jsx("div", { className: styles$
|
|
2914
|
-
};
|
|
2915
|
-
const MAX_DRAFT_BODY_LENGTH = 2e4;
|
|
2916
|
-
const MAX_TITLE_LENGTH = 160;
|
|
2917
|
-
const MAX_RECIPIENT_LENGTH = 320;
|
|
2918
|
-
const MAX_SUBJECT_LENGTH = 240;
|
|
2919
|
-
const KIND_KEYS = ["kind", "variant", "draftType", "draft_type", "category"];
|
|
2920
|
-
const TITLE_KEYS = ["title", "heading", "name"];
|
|
2921
|
-
const RECIPIENT_KEYS = ["recipient", "recipients", "to", "addressee", "recipientEmail", "email"];
|
|
2922
|
-
const SUBJECT_KEYS = ["subject", "subjectLine", "subject_line"];
|
|
2923
|
-
const BODY_KEYS = ["body", "content", "text", "markdown", "message", "draft"];
|
|
2924
|
-
const NO_RECIPIENT_WORDS = /* @__PURE__ */ new Set(["not specified", "unspecified", "unknown", "n/a", "none", "-", "tbd"]);
|
|
2925
|
-
const KIND_ALIASES = {
|
|
2926
|
-
email: "email",
|
|
2927
|
-
"e-mail": "email",
|
|
2928
|
-
mail: "email",
|
|
2929
|
-
letter: "letter",
|
|
2930
|
-
brief: "letter",
|
|
2931
|
-
post: "post",
|
|
2932
|
-
socialpost: "post",
|
|
2933
|
-
social: "post",
|
|
2934
|
-
reply: "reply",
|
|
2935
|
-
response: "reply",
|
|
2936
|
-
answer: "reply",
|
|
2937
|
-
message: "message",
|
|
2938
|
-
sms: "message",
|
|
2939
|
-
chat: "message",
|
|
2940
|
-
dm: "message",
|
|
2941
|
-
other: "other",
|
|
2942
|
-
draft: "other",
|
|
2943
|
-
memo: "other"
|
|
2944
|
-
};
|
|
2945
|
-
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2946
|
-
const readCappedString = (value, maxLength) => {
|
|
2947
|
-
if (typeof value !== "string") return void 0;
|
|
2948
|
-
const trimmedValue = value.trim();
|
|
2949
|
-
return trimmedValue === "" ? void 0 : trimmedValue.slice(0, maxLength);
|
|
3048
|
+
return /* @__PURE__ */ jsx("div", { className: styles$b.row, "data-testid": "entity-mention-message", children: /* @__PURE__ */ jsx(EntityMentionWidgetBody, { mention }) });
|
|
2950
3049
|
};
|
|
2951
|
-
const
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
3050
|
+
const AGENT_SPACE_NAME_WIDGET_TYPE = "__agent-space-name";
|
|
3051
|
+
registerWidgetHydrator(AGENT_SPACE_NAME_WIDGET_TYPE, {
|
|
3052
|
+
deriveKey: (type, payload) => `${type}:${payload.agentSpaceKey}`,
|
|
3053
|
+
hydrator: async (input2, { signal }) => {
|
|
3054
|
+
const name2 = await getAgentsEnvironment().readAgentSpaceName?.(input2.agentSpaceKey, signal);
|
|
3055
|
+
if (signal.aborted) throw new DOMException("Aborted", "AbortError");
|
|
3056
|
+
return { name: name2 };
|
|
3057
|
+
},
|
|
3058
|
+
refetchOnNewInstance: false
|
|
3059
|
+
});
|
|
3060
|
+
const anchor = "agents_anchor_IaXKav";
|
|
3061
|
+
const inFlowAnchor = "agents_inFlowAnchor_6lEqDc";
|
|
3062
|
+
const root$1 = "agents_root_jna8Qc";
|
|
3063
|
+
const name = "agents_name_DW-l72";
|
|
3064
|
+
const styles$a = {
|
|
3065
|
+
anchor,
|
|
3066
|
+
inFlowAnchor,
|
|
3067
|
+
root: root$1,
|
|
3068
|
+
name
|
|
2957
3069
|
};
|
|
2958
|
-
const
|
|
2959
|
-
const
|
|
2960
|
-
|
|
2961
|
-
|
|
3070
|
+
const ConversationWidgetAgentSpaceHeader = (props) => {
|
|
3071
|
+
const { agentSpaceKey, inFlow = false } = props;
|
|
3072
|
+
const { data } = useWidgetHydration(AGENT_SPACE_NAME_WIDGET_TYPE, {
|
|
3073
|
+
agentSpaceKey
|
|
3074
|
+
});
|
|
3075
|
+
const label2 = data?.name ?? buildUnnamedAgentSpaceLabel(agentSpaceKey);
|
|
3076
|
+
const explanation = buildWidgetOfAnotherAgentSpaceExplanation(label2);
|
|
3077
|
+
const noteLabel = translateText("Showing data for %label%", { label: label2 });
|
|
3078
|
+
return /* @__PURE__ */ jsx("div", { className: inFlow ? styles$a.inFlowAnchor : styles$a.anchor, children: /* @__PURE__ */ jsx(Tooltip, { text: explanation, placement: "top", dark: true, wrapsChild: true, children: /* @__PURE__ */ jsx("span", { className: styles$a.root, role: "note", "aria-label": noteLabel, tabIndex: 0, children: /* @__PURE__ */ jsx("span", { className: styles$a.name, children: label2 }) }) }) });
|
|
2962
3079
|
};
|
|
2963
|
-
const
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3080
|
+
const CANVAS_VIABLE_MIN_WIDTH = 850;
|
|
3081
|
+
const isViewportViable = () => typeof window === "undefined" || window.innerWidth >= CANVAS_VIABLE_MIN_WIDTH;
|
|
3082
|
+
class ElementWidthCanvasViability {
|
|
3083
|
+
constructor(minWidth = CANVAS_VIABLE_MIN_WIDTH) {
|
|
3084
|
+
this.minWidth = minWidth;
|
|
3085
|
+
this.elementWidth = null;
|
|
3086
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
3087
|
+
this.resizeObserver = null;
|
|
3088
|
+
this.observedElement = null;
|
|
3089
|
+
this.isViable = () => this.elementWidth !== null && this.elementWidth > 0 ? this.elementWidth >= this.minWidth : isViewportViable();
|
|
3090
|
+
this.subscribe = (listener) => {
|
|
3091
|
+
this.listeners.add(listener);
|
|
3092
|
+
return () => {
|
|
3093
|
+
this.listeners.delete(listener);
|
|
3094
|
+
};
|
|
3095
|
+
};
|
|
3096
|
+
this.observe = (element) => {
|
|
3097
|
+
if (element === this.observedElement) return;
|
|
3098
|
+
this.resizeObserver?.disconnect();
|
|
3099
|
+
this.resizeObserver = null;
|
|
3100
|
+
this.observedElement = element;
|
|
3101
|
+
if (element === null) {
|
|
3102
|
+
this.receiveWidth(null);
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
this.receiveWidth(element.getBoundingClientRect().width);
|
|
3106
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
3107
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3108
|
+
const entry = entries[entries.length - 1];
|
|
3109
|
+
if (entry) this.receiveWidth(entry.contentRect.width);
|
|
3110
|
+
});
|
|
3111
|
+
this.resizeObserver.observe(element);
|
|
3112
|
+
};
|
|
3113
|
+
this.receiveViewportResize = () => {
|
|
3114
|
+
this.notifyWhenFlipped();
|
|
3115
|
+
};
|
|
3116
|
+
this.viable = this.isViable();
|
|
2971
3117
|
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
for (const key of BODY_KEYS) {
|
|
2976
|
-
const rawValue = record[key];
|
|
2977
|
-
const bodyValue = isRecord$1(rawValue) ? rawValue.text ?? rawValue.markdown ?? rawValue.body : rawValue;
|
|
2978
|
-
if (typeof bodyValue === "string" && bodyValue.trim() !== "") {
|
|
2979
|
-
return bodyValue.replace(/^\s*\n/, "").trimEnd().slice(0, MAX_DRAFT_BODY_LENGTH);
|
|
2980
|
-
}
|
|
3118
|
+
receiveWidth(width) {
|
|
3119
|
+
this.elementWidth = width;
|
|
3120
|
+
this.notifyWhenFlipped();
|
|
2981
3121
|
}
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
try {
|
|
2988
|
-
parsedPayload = JSON.parse(payload ?? "");
|
|
2989
|
-
} catch {
|
|
2990
|
-
return { isValidPayload: false, body: "", isBodyUnreadable: false };
|
|
3122
|
+
notifyWhenFlipped() {
|
|
3123
|
+
const viable = this.isViable();
|
|
3124
|
+
if (viable === this.viable) return;
|
|
3125
|
+
this.viable = viable;
|
|
3126
|
+
for (const listener of [...this.listeners]) listener();
|
|
2991
3127
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
const
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3128
|
+
}
|
|
3129
|
+
const CanvasViabilityContext = createContext(null);
|
|
3130
|
+
const readCanvasViable = (source) => source ? source.isViable() : isViewportViable();
|
|
3131
|
+
const subscribeToNothing = () => () => void 0;
|
|
3132
|
+
const useCanvasViable = () => {
|
|
3133
|
+
const source = useContext(CanvasViabilityContext);
|
|
3134
|
+
const sourceViable = useSyncExternalStore(
|
|
3135
|
+
source ? source.subscribe : subscribeToNothing,
|
|
3136
|
+
source ? source.isViable : isViewportViable,
|
|
3137
|
+
source ? source.isViable : isViewportViable
|
|
3138
|
+
);
|
|
3139
|
+
const [viewportViable, setViewportViable] = useState(isViewportViable);
|
|
3140
|
+
useEffect(() => {
|
|
3141
|
+
const onResize = () => {
|
|
3142
|
+
if (source instanceof ElementWidthCanvasViability) source.receiveViewportResize();
|
|
3143
|
+
setViewportViable((previous) => {
|
|
3144
|
+
const next = isViewportViable();
|
|
3145
|
+
return next === previous ? previous : next;
|
|
3146
|
+
});
|
|
3147
|
+
};
|
|
3148
|
+
window.addEventListener("resize", onResize);
|
|
3149
|
+
onResize();
|
|
3150
|
+
return () => window.removeEventListener("resize", onResize);
|
|
3151
|
+
}, [source]);
|
|
3152
|
+
return source ? sourceViable : viewportViable;
|
|
3007
3153
|
};
|
|
3008
|
-
const
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
const
|
|
3016
|
-
const
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
const withListMarker = withoutQuote.replace(/^(\s*)[*+]\s+/, "$1- ");
|
|
3021
|
-
const withoutHardBreak = withListMarker.replace(/(\s{2,}|\\)$/, "");
|
|
3022
|
-
return removeEmphasis(replaceLinks(withoutHardBreak));
|
|
3023
|
-
};
|
|
3024
|
-
const convertDraftMarkdownToPlainText = (markdown) => markdown.replace(/\r\n?/g, "\n").split("\n").map(convertLine).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
3025
|
-
const MAX_MAIL_LINK_LENGTH = 1900;
|
|
3026
|
-
const EMAIL_ADDRESS_PATTERN = /^[^\s@<>()[\]"',;:\\]+@[^\s@<>()[\]"',;:\\]+\.[^\s@<>()[\]"',;:\\.]{2,}$/;
|
|
3027
|
-
const readEmailAddresses = (recipient) => (recipient ?? "").split(/[,;]/).map((recipientPart) => {
|
|
3028
|
-
const bracketedAddress = /<([^<>]+)>/.exec(recipientPart);
|
|
3029
|
-
return (bracketedAddress ? bracketedAddress[1] : recipientPart).trim().replace(/^mailto:/i, "");
|
|
3030
|
-
}).filter((address) => EMAIL_ADDRESS_PATTERN.test(address));
|
|
3031
|
-
const encodeMailHeaderValue = (value) => encodeURIComponent(value.replace(/\r?\n/g, "\r\n"));
|
|
3032
|
-
const buildMailHref = (addressPart, queryParts) => {
|
|
3033
|
-
const query = queryParts.filter((queryPart) => queryPart !== void 0).join("&");
|
|
3034
|
-
return `mailto:${addressPart}${query === "" ? "" : `?${query}`}`;
|
|
3035
|
-
};
|
|
3036
|
-
const buildDraftMailLink = (recipient, subject, plainTextBody) => {
|
|
3037
|
-
const addressPart = readEmailAddresses(recipient).map((address) => encodeURIComponent(address).replace(/%40/g, "@")).join(",");
|
|
3038
|
-
const subjectPart = subject ? `subject=${encodeMailHeaderValue(subject)}` : void 0;
|
|
3039
|
-
const bodyPart = plainTextBody !== "" ? `body=${encodeMailHeaderValue(plainTextBody)}` : void 0;
|
|
3040
|
-
const hrefWithBody = buildMailHref(addressPart, [subjectPart, bodyPart]);
|
|
3041
|
-
if (hrefWithBody.length <= MAX_MAIL_LINK_LENGTH || bodyPart === void 0) {
|
|
3042
|
-
return { href: hrefWithBody, includesBody: bodyPart !== void 0 };
|
|
3043
|
-
}
|
|
3044
|
-
return { href: buildMailHref(addressPart, [subjectPart]), includesBody: false };
|
|
3045
|
-
};
|
|
3046
|
-
const remarkDraftLineBreaks = () => (tree) => {
|
|
3047
|
-
visit(tree, "text", (node, index, parent) => {
|
|
3048
|
-
if (!parent?.children || index === void 0 || typeof node.value !== "string" || !node.value.includes("\n")) {
|
|
3049
|
-
return;
|
|
3050
|
-
}
|
|
3051
|
-
const lineNodes = [];
|
|
3052
|
-
node.value.split("\n").forEach((line, lineIndex) => {
|
|
3053
|
-
if (lineIndex > 0) lineNodes.push({ type: "break" });
|
|
3054
|
-
if (line !== "") lineNodes.push({ type: "text", value: line });
|
|
3055
|
-
});
|
|
3056
|
-
parent.children.splice(index, 1, ...lineNodes);
|
|
3057
|
-
return index + lineNodes.length;
|
|
3058
|
-
});
|
|
3059
|
-
};
|
|
3060
|
-
const root$1 = "agents_root_ZXdBmq";
|
|
3061
|
-
const titleBlock = "agents_titleBlock_wE5qKF";
|
|
3062
|
-
const card = "agents_card_gsMEzB";
|
|
3063
|
-
const actions = "agents_actions_nrMgyL";
|
|
3064
|
-
const wrappingText = "agents_wrappingText_XaePR6";
|
|
3065
|
-
const header$1 = "agents_header_0ASqLt";
|
|
3066
|
-
const headerLine = "agents_headerLine_k3j-5m";
|
|
3067
|
-
const emptyValue = "agents_emptyValue_gTCHJD";
|
|
3068
|
-
const editFields = "agents_editFields_dxl8RQ";
|
|
3069
|
-
const body$1 = "agents_body_Xj5IjL";
|
|
3070
|
-
const bodyHeading = "agents_bodyHeading_7U1DWS";
|
|
3071
|
-
const bodyLink = "agents_bodyLink_ZW0-Si";
|
|
3072
|
-
const notes = "agents_notes_fh4FWY";
|
|
3073
|
-
const meta = "agents_meta_yrPynX";
|
|
3154
|
+
const cardSurface = "agents_cardSurface_E22fRs";
|
|
3155
|
+
const leadingIconBadge = "agents_leadingIconBadge_CUGLsX";
|
|
3156
|
+
const openAffordance = "agents_openAffordance_2cG57Y";
|
|
3157
|
+
const openIcon = "agents_openIcon_H-1FgN";
|
|
3158
|
+
const richOpenIcon = "agents_richOpenIcon_T3LYOK";
|
|
3159
|
+
const cardButton = "agents_cardButton_UYBiR-";
|
|
3160
|
+
const body$1 = "agents_body_TW-9Nf";
|
|
3161
|
+
const cardOfAnotherBusiness = "agents_cardOfAnotherBusiness_AJijSp";
|
|
3162
|
+
const richCardSurface = "agents_richCardSurface_Tp7fVx";
|
|
3163
|
+
const richCardButton = "agents_richCardButton_Xql1T3";
|
|
3164
|
+
const thumbnail = "agents_thumbnail_9eN6G1";
|
|
3165
|
+
const mobile = "agents_mobile_Jmo-Gy";
|
|
3074
3166
|
const styles$9 = {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
headerLine,
|
|
3082
|
-
emptyValue,
|
|
3083
|
-
editFields,
|
|
3167
|
+
cardSurface,
|
|
3168
|
+
leadingIconBadge,
|
|
3169
|
+
openAffordance,
|
|
3170
|
+
openIcon,
|
|
3171
|
+
richOpenIcon,
|
|
3172
|
+
cardButton,
|
|
3084
3173
|
body: body$1,
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
const readHastText = (node) => {
|
|
3091
|
-
if (!node) return "";
|
|
3092
|
-
if (node.type === "text") return node.value ?? "";
|
|
3093
|
-
return (node.children ?? []).map(readHastText).join("");
|
|
3094
|
-
};
|
|
3095
|
-
const renderHeading = (props) => /* @__PURE__ */ jsx(
|
|
3096
|
-
Text,
|
|
3097
|
-
{
|
|
3098
|
-
role: "body",
|
|
3099
|
-
weight: "bold",
|
|
3100
|
-
translate: false,
|
|
3101
|
-
display: "block",
|
|
3102
|
-
className: styles$9.bodyHeading,
|
|
3103
|
-
headingLevel: 4,
|
|
3104
|
-
children: escapePlainTextForText(readHastText(props.node))
|
|
3105
|
-
}
|
|
3106
|
-
);
|
|
3107
|
-
const SAFE_DRAFT_MARKDOWN_COMPONENTS = {
|
|
3108
|
-
img: () => null,
|
|
3109
|
-
h1: renderHeading,
|
|
3110
|
-
h2: renderHeading,
|
|
3111
|
-
h3: renderHeading,
|
|
3112
|
-
h4: renderHeading,
|
|
3113
|
-
h5: renderHeading,
|
|
3114
|
-
h6: renderHeading,
|
|
3115
|
-
a: (props) => {
|
|
3116
|
-
const safeUrl = readSafeHttpUrl(props.href);
|
|
3117
|
-
if (safeUrl === null) return /* @__PURE__ */ jsx("span", { children: props.children });
|
|
3118
|
-
return /* @__PURE__ */ jsx(AgentsLink, { className: styles$9.bodyLink, href: safeUrl, children: props.children });
|
|
3119
|
-
}
|
|
3174
|
+
cardOfAnotherBusiness,
|
|
3175
|
+
richCardSurface,
|
|
3176
|
+
richCardButton,
|
|
3177
|
+
thumbnail,
|
|
3178
|
+
mobile
|
|
3120
3179
|
};
|
|
3121
|
-
const
|
|
3122
|
-
const
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3180
|
+
const DEFAULT_ICON = "maximize";
|
|
3181
|
+
const CanvasLauncherWidget = ({
|
|
3182
|
+
title: title2,
|
|
3183
|
+
titleReplacements,
|
|
3184
|
+
translateTitle = true,
|
|
3185
|
+
subtitle,
|
|
3186
|
+
subtitleReplacements,
|
|
3187
|
+
translateSubtitle = true,
|
|
3188
|
+
icon,
|
|
3189
|
+
leading,
|
|
3190
|
+
thumbnail: thumbnail2,
|
|
3191
|
+
justDelivered = false,
|
|
3192
|
+
canvas,
|
|
3193
|
+
anotherAgentSpaceKey,
|
|
3194
|
+
preview,
|
|
3195
|
+
testId: testId2
|
|
3196
|
+
}) => {
|
|
3197
|
+
const { openCanvas, canvas: openCanvasState } = useConversationWidgetContext();
|
|
3198
|
+
const canvasViable = useCanvasViable();
|
|
3199
|
+
const openedRef = useRef(false);
|
|
3200
|
+
const capture = useWidgetImageRender();
|
|
3201
|
+
const isEmailRender = useIsEmailWidgetRender();
|
|
3202
|
+
useEffect(() => {
|
|
3203
|
+
if (isEmailRender || capture !== null || openedRef.current || !canvas || !justDelivered) return;
|
|
3204
|
+
openedRef.current = true;
|
|
3205
|
+
openCanvas({ ...canvas, origin: "deliveredInMessage", justDelivered: true });
|
|
3206
|
+
}, [justDelivered, canvas?.instanceId]);
|
|
3207
|
+
const open = () => {
|
|
3208
|
+
if (canvas) openCanvas({ ...canvas, origin: "widgetClick", justDelivered: false });
|
|
3209
|
+
};
|
|
3210
|
+
const isThisCanvasOpen = canvas !== void 0 && openCanvasState !== null && sameCanvasIdentity(openCanvasState, canvas);
|
|
3211
|
+
const subtitleText = subtitle ? /* @__PURE__ */ jsx(
|
|
3212
|
+
Text,
|
|
3126
3213
|
{
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3214
|
+
role: "caption",
|
|
3215
|
+
color: "var(--agents-fg-light)",
|
|
3216
|
+
ellipsis: true,
|
|
3217
|
+
translate: translateSubtitle,
|
|
3218
|
+
replacements: subtitleReplacements,
|
|
3219
|
+
children: subtitle
|
|
3131
3220
|
}
|
|
3132
|
-
)
|
|
3133
|
-
};
|
|
3134
|
-
const
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
post: textKey("Post draft"),
|
|
3138
|
-
reply: textKey("Reply draft"),
|
|
3139
|
-
message: textKey("Message draft"),
|
|
3140
|
-
other: textKey("Text draft"),
|
|
3141
|
-
unknown: textKey("Text draft")
|
|
3142
|
-
};
|
|
3143
|
-
const WritingDraftWidget = (props) => {
|
|
3144
|
-
const {
|
|
3145
|
-
kind,
|
|
3146
|
-
title: title2,
|
|
3147
|
-
values,
|
|
3148
|
-
showsAddressFields,
|
|
3149
|
-
isEditing,
|
|
3150
|
-
isEdited,
|
|
3151
|
-
characterCount,
|
|
3152
|
-
isCopied,
|
|
3153
|
-
canOpenInMail,
|
|
3154
|
-
mailLinkOmitsBody,
|
|
3155
|
-
onChangeField,
|
|
3156
|
-
onStartEditing,
|
|
3157
|
-
onFinishEditing,
|
|
3158
|
-
onReset,
|
|
3159
|
-
onCopy,
|
|
3160
|
-
onOpenInMail
|
|
3161
|
-
} = props;
|
|
3162
|
-
const headingId = useId();
|
|
3163
|
-
const kindLabel = WRITING_DRAFT_KIND_LABELS[kind ?? "unknown"];
|
|
3164
|
-
const headline = title2 !== void 0 && title2 !== values.subject ? title2 : void 0;
|
|
3165
|
-
const showsRecipientRow = showsAddressFields || values.recipient !== "";
|
|
3166
|
-
const showsSubjectRow = showsAddressFields || values.subject !== "";
|
|
3167
|
-
const showsNotes = isEditing || isEdited || mailLinkOmitsBody;
|
|
3168
|
-
const renderHeaderLine = (label2, value, emptyLabel, testId2) => /* @__PURE__ */ jsxs("div", { className: styles$9.headerLine, "data-testid": testId2, children: [
|
|
3169
|
-
/* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-light)", children: label2 }),
|
|
3170
|
-
value !== "" ? /* @__PURE__ */ jsx(ModelText, { role: "help", weight: "medium", className: styles$9.wrappingText, children: value }) : /* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-lightest)", className: styles$9.emptyValue, children: emptyLabel })
|
|
3171
|
-
] });
|
|
3172
|
-
const renderPill = (label2, icon, onClick, testId2, isPrimary = false) => /* @__PURE__ */ jsx(
|
|
3173
|
-
ConversationWidgetButton,
|
|
3221
|
+
) : null;
|
|
3222
|
+
const openCanvasTestId = testId2 ? `${testId2}-open-canvas` : void 0;
|
|
3223
|
+
const cardTestId = anotherAgentSpaceKey === void 0 ? testId2 : void 0;
|
|
3224
|
+
const renderCard = (cardContent, isRich = false, surfaceTestId) => /* @__PURE__ */ jsx(
|
|
3225
|
+
InteractiveSurface,
|
|
3174
3226
|
{
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
testId: testId2,
|
|
3181
|
-
children: label2
|
|
3182
|
-
}
|
|
3183
|
-
);
|
|
3184
|
-
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: styles$9.root, "data-testid": "writing-draft-widget", children: [
|
|
3185
|
-
/* @__PURE__ */ jsxs("div", { className: styles$9.titleBlock, id: headingId, children: [
|
|
3186
|
-
/* @__PURE__ */ jsx(
|
|
3187
|
-
Text,
|
|
3227
|
+
hoverable: true,
|
|
3228
|
+
className: classNames(styles$9.cardSurface, isRich && styles$9.richCardSurface),
|
|
3229
|
+
testId: surfaceTestId,
|
|
3230
|
+
children: /* @__PURE__ */ jsx(
|
|
3231
|
+
"button",
|
|
3188
3232
|
{
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3233
|
+
type: "button",
|
|
3234
|
+
className: classNames(styles$9.cardButton, isRich && styles$9.richCardButton),
|
|
3235
|
+
onClick: open,
|
|
3236
|
+
"data-testid": openCanvasTestId,
|
|
3237
|
+
children: cardContent
|
|
3193
3238
|
}
|
|
3194
|
-
)
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3239
|
+
)
|
|
3240
|
+
}
|
|
3241
|
+
);
|
|
3242
|
+
const openAffordance2 = /* @__PURE__ */ jsx("span", { className: styles$9.openAffordance, children: /* @__PURE__ */ jsx(Icon, { className: styles$9.openIcon, name: "arrowRight" }) });
|
|
3243
|
+
const card2 = thumbnail2 ? renderCard(
|
|
3244
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3245
|
+
/* @__PURE__ */ jsx("span", { className: styles$9.thumbnail, children: thumbnail2 }),
|
|
3246
|
+
/* @__PURE__ */ jsxs("div", { className: styles$9.body, children: [
|
|
3247
|
+
/* @__PURE__ */ jsx(
|
|
3248
|
+
Text,
|
|
3201
3249
|
{
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3250
|
+
role: "body",
|
|
3251
|
+
weight: "bold",
|
|
3252
|
+
ellipsis: true,
|
|
3253
|
+
translate: translateTitle,
|
|
3254
|
+
replacements: titleReplacements,
|
|
3255
|
+
children: title2
|
|
3206
3256
|
}
|
|
3207
|
-
)
|
|
3208
|
-
|
|
3209
|
-
TextInput,
|
|
3210
|
-
{
|
|
3211
|
-
testId: "writing-draft-subject-input",
|
|
3212
|
-
value: values.subject,
|
|
3213
|
-
label: "Subject",
|
|
3214
|
-
onChange: (text2) => onChangeField("subject", text2)
|
|
3215
|
-
}
|
|
3216
|
-
) : null,
|
|
3217
|
-
/* @__PURE__ */ jsx(
|
|
3218
|
-
TextArea,
|
|
3219
|
-
{
|
|
3220
|
-
testId: "writing-draft-body-input",
|
|
3221
|
-
value: values.body,
|
|
3222
|
-
label: "Text of the draft",
|
|
3223
|
-
minRows: 6,
|
|
3224
|
-
rows: 6,
|
|
3225
|
-
showsCounter: false,
|
|
3226
|
-
autoFocus: true,
|
|
3227
|
-
onChange: (text2) => onChangeField("body", text2)
|
|
3228
|
-
}
|
|
3229
|
-
)
|
|
3230
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3231
|
-
showsRecipientRow || showsSubjectRow ? /* @__PURE__ */ jsxs("div", { className: styles$9.header, children: [
|
|
3232
|
-
showsRecipientRow ? renderHeaderLine(textKey("To"), values.recipient, textKey("No recipient yet"), "writing-draft-recipient") : null,
|
|
3233
|
-
showsSubjectRow ? renderHeaderLine(textKey("Subject"), values.subject, textKey("No subject yet"), "writing-draft-subject") : null
|
|
3234
|
-
] }) : null,
|
|
3235
|
-
values.body.trim() !== "" ? /* @__PURE__ */ jsx(WritingDraftBody, { markdown: values.body }) : /* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-light)", className: styles$9.wrappingText, children: "The text of this draft is empty." })
|
|
3257
|
+
),
|
|
3258
|
+
subtitleText
|
|
3236
3259
|
] }),
|
|
3237
|
-
/* @__PURE__ */ jsx(
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3260
|
+
/* @__PURE__ */ jsx(Icon, { className: styles$9.richOpenIcon, name: "arrowRight" })
|
|
3261
|
+
] }),
|
|
3262
|
+
true,
|
|
3263
|
+
cardTestId
|
|
3264
|
+
) : renderCard(
|
|
3265
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3266
|
+
/* @__PURE__ */ jsx("span", { className: styles$9.leadingIconBadge, children: leading ?? /* @__PURE__ */ jsx(Icon, { name: icon ?? DEFAULT_ICON }) }),
|
|
3267
|
+
/* @__PURE__ */ jsxs("div", { className: styles$9.body, children: [
|
|
3268
|
+
/* @__PURE__ */ jsx(
|
|
3244
3269
|
Text,
|
|
3245
3270
|
{
|
|
3246
|
-
role: "
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
children:
|
|
3271
|
+
role: "help",
|
|
3272
|
+
weight: "bold",
|
|
3273
|
+
ellipsis: true,
|
|
3274
|
+
translate: translateTitle,
|
|
3275
|
+
replacements: titleReplacements,
|
|
3276
|
+
children: title2
|
|
3252
3277
|
}
|
|
3253
|
-
)
|
|
3254
|
-
|
|
3278
|
+
),
|
|
3279
|
+
subtitleText
|
|
3280
|
+
] }),
|
|
3281
|
+
openAffordance2
|
|
3255
3282
|
] }),
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3283
|
+
false,
|
|
3284
|
+
cardTestId
|
|
3285
|
+
);
|
|
3286
|
+
if (isEmailRender || capture !== null) {
|
|
3287
|
+
if (!preview) throw new Error("WIDGET_REQUIRES_STATIC_PREVIEW");
|
|
3288
|
+
return /* @__PURE__ */ jsx(Fragment, { children: preview });
|
|
3289
|
+
}
|
|
3290
|
+
if (!canvasViable && preview) {
|
|
3291
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$9.mobile, children: [
|
|
3292
|
+
isThisCanvasOpen ? null : preview,
|
|
3293
|
+
renderCard(
|
|
3294
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3295
|
+
/* @__PURE__ */ jsx("span", { className: styles$9.leadingIconBadge, children: /* @__PURE__ */ jsx(Icon, { name: "maximize" }) }),
|
|
3296
|
+
/* @__PURE__ */ jsx("div", { className: styles$9.body, children: /* @__PURE__ */ jsx(Text, { role: "help", weight: "bold", ellipsis: true, children: "Open in canvas" }) }),
|
|
3297
|
+
openAffordance2
|
|
3298
|
+
] })
|
|
3299
|
+
)
|
|
3300
|
+
] });
|
|
3301
|
+
}
|
|
3302
|
+
if (anotherAgentSpaceKey === void 0) return card2;
|
|
3303
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$9.cardOfAnotherBusiness, "data-testid": testId2, children: [
|
|
3304
|
+
/* @__PURE__ */ jsx(ConversationWidgetAgentSpaceHeader, { agentSpaceKey: anotherAgentSpaceKey, inFlow: true }),
|
|
3305
|
+
card2
|
|
3265
3306
|
] });
|
|
3266
3307
|
};
|
|
3267
|
-
const
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
const
|
|
3283
|
-
const
|
|
3284
|
-
|
|
3285
|
-
const
|
|
3286
|
-
|
|
3287
|
-
useEffect(() => {
|
|
3288
|
-
if (!isCopied) return;
|
|
3289
|
-
const confirmationTimer = setTimeout(() => setIsCopied(false), COPIED_CONFIRMATION_MS);
|
|
3290
|
-
return () => clearTimeout(confirmationTimer);
|
|
3291
|
-
}, [isCopied]);
|
|
3292
|
-
const plainTextBody = useMemo(() => convertDraftMarkdownToPlainText(values.body), [values.body]);
|
|
3293
|
-
const isEmailDraft = writingDraftPayload.kind === "email";
|
|
3294
|
-
const draftMailLink = useMemo(
|
|
3295
|
-
() => isEmailDraft ? buildDraftMailLink(values.recipient, values.subject, plainTextBody) : void 0,
|
|
3296
|
-
[isEmailDraft, values.recipient, values.subject, plainTextBody]
|
|
3297
|
-
);
|
|
3298
|
-
const changeField = (field2, value) => setValues((previousValues) => ({ ...previousValues, [field2]: value }));
|
|
3299
|
-
const copyDraft = () => {
|
|
3300
|
-
void navigator.clipboard?.writeText(plainTextBody).then(() => setIsCopied(true)).catch(() => void 0);
|
|
3301
|
-
};
|
|
3302
|
-
const resetDraft = () => {
|
|
3303
|
-
setValues(originalValues);
|
|
3304
|
-
setIsEditing(false);
|
|
3305
|
-
};
|
|
3308
|
+
const CanvasWidgetSwitch = ({
|
|
3309
|
+
display,
|
|
3310
|
+
exceedsInlineLimit = false,
|
|
3311
|
+
title: title2,
|
|
3312
|
+
titleReplacements,
|
|
3313
|
+
subtitle,
|
|
3314
|
+
subtitleReplacements,
|
|
3315
|
+
translateSubtitle,
|
|
3316
|
+
icon,
|
|
3317
|
+
justDelivered = false,
|
|
3318
|
+
canvas,
|
|
3319
|
+
anotherAgentSpaceKey,
|
|
3320
|
+
renderInline,
|
|
3321
|
+
testId: testId2
|
|
3322
|
+
}) => {
|
|
3323
|
+
const capture = useWidgetImageRender();
|
|
3324
|
+
const isEmailRender = useIsEmailWidgetRender();
|
|
3325
|
+
if (isEmailRender || capture !== null) return /* @__PURE__ */ jsx(Fragment, { children: renderInline({ isWidgetPreview: false }) });
|
|
3326
|
+
const isCanvasWidget = display === "canvas" || display !== "inline" && exceedsInlineLimit;
|
|
3327
|
+
if (!isCanvasWidget) return /* @__PURE__ */ jsx(Fragment, { children: renderInline({ isWidgetPreview: false }) });
|
|
3306
3328
|
return /* @__PURE__ */ jsx(
|
|
3307
|
-
|
|
3329
|
+
CanvasLauncherWidget,
|
|
3308
3330
|
{
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
onStartEditing: () => setIsEditing(true),
|
|
3321
|
-
onFinishEditing: () => setIsEditing(false),
|
|
3322
|
-
onReset: resetDraft,
|
|
3323
|
-
onCopy: copyDraft,
|
|
3324
|
-
onOpenInMail: () => draftMailLink && openMailLink(draftMailLink.href)
|
|
3331
|
+
title: title2,
|
|
3332
|
+
titleReplacements,
|
|
3333
|
+
subtitle,
|
|
3334
|
+
subtitleReplacements,
|
|
3335
|
+
translateSubtitle,
|
|
3336
|
+
icon,
|
|
3337
|
+
justDelivered,
|
|
3338
|
+
canvas,
|
|
3339
|
+
anotherAgentSpaceKey,
|
|
3340
|
+
preview: renderInline({ isWidgetPreview: true }),
|
|
3341
|
+
testId: testId2
|
|
3325
3342
|
}
|
|
3326
3343
|
);
|
|
3327
3344
|
};
|
|
3328
|
-
const
|
|
3329
|
-
const
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
!writingDraftPayload.isValidPayload ? "The WritingDraft payload is not a JSON object." : writingDraftPayload.isBodyUnreadable ? "The WritingDraft `body` is not a text; write the draft as one Markdown string." : hasBody ? void 0 : "The WritingDraft widget carries no text (`body`)."
|
|
3337
|
-
);
|
|
3338
|
-
if (isUnreadable) {
|
|
3339
|
-
return /* @__PURE__ */ jsx(
|
|
3340
|
-
Text,
|
|
3341
|
-
{
|
|
3342
|
-
role: "help",
|
|
3343
|
-
color: "var(--agents-fg-light)",
|
|
3344
|
-
className: styles$8.notice,
|
|
3345
|
-
testId: "writing-draft-widget-error",
|
|
3346
|
-
children: "This draft could not be shown."
|
|
3347
|
-
}
|
|
3348
|
-
);
|
|
3349
|
-
}
|
|
3350
|
-
if (!hasBody) {
|
|
3351
|
-
return /* @__PURE__ */ jsx(
|
|
3352
|
-
Text,
|
|
3353
|
-
{
|
|
3354
|
-
role: "help",
|
|
3355
|
-
color: "var(--agents-fg-light)",
|
|
3356
|
-
className: styles$8.notice,
|
|
3357
|
-
testId: "writing-draft-widget-empty",
|
|
3358
|
-
children: "This draft has no text yet."
|
|
3359
|
-
}
|
|
3360
|
-
);
|
|
3361
|
-
}
|
|
3362
|
-
return /* @__PURE__ */ jsx(WritingDraftEditor, { writingDraftPayload }, payload);
|
|
3363
|
-
};
|
|
3364
|
-
const suggestedActions = "agents_suggestedActions_vxfGKR";
|
|
3365
|
-
const styles$7 = {
|
|
3366
|
-
suggestedActions
|
|
3345
|
+
const canvasForMessageWidget = (canvasId, messageId, payload) => {
|
|
3346
|
+
const numericMessageId = messageId === void 0 ? Number.NaN : Number(messageId);
|
|
3347
|
+
if (!Number.isFinite(numericMessageId)) return void 0;
|
|
3348
|
+
return {
|
|
3349
|
+
canvasId,
|
|
3350
|
+
instanceId: canvasInstanceIdForMessagePayload(canvasId, numericMessageId, payload),
|
|
3351
|
+
anchor: messageAnchor(numericMessageId)
|
|
3352
|
+
};
|
|
3367
3353
|
};
|
|
3368
|
-
|
|
3354
|
+
const IMAGE_GALLERY_WIDGET_TYPE = "ImageGallery";
|
|
3355
|
+
const IMAGE_GALLERY_MAX_FILES = 12;
|
|
3356
|
+
const IMAGE_GALLERY_LETTERS = "ABCDEFGHIJKL";
|
|
3357
|
+
const FILE_REFERENCE_PATTERN = /^[a-z][a-z0-9-]{0,31}\/[A-Za-z0-9_-]{1,128}$/;
|
|
3358
|
+
const GALLERY_NAME_PATTERN = /^[A-Za-z0-9_.:-]{1,80}$/;
|
|
3359
|
+
const readText = (value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
3360
|
+
const parseImageGalleryPayload = (raw) => {
|
|
3369
3361
|
let parsed;
|
|
3370
3362
|
try {
|
|
3371
|
-
parsed = JSON.parse(
|
|
3363
|
+
parsed = JSON.parse(raw);
|
|
3372
3364
|
} catch {
|
|
3373
|
-
console.warn("[SuggestedActions] Failed to parse options JSON:", options2);
|
|
3374
3365
|
return null;
|
|
3375
3366
|
}
|
|
3376
|
-
if (!
|
|
3377
|
-
|
|
3378
|
-
)
|
|
3379
|
-
|
|
3380
|
-
|
|
3367
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
3368
|
+
const fields = parsed;
|
|
3369
|
+
const rawFiles = Array.isArray(fields.files) ? fields.files : [];
|
|
3370
|
+
const files = [];
|
|
3371
|
+
const seenReferences = /* @__PURE__ */ new Set();
|
|
3372
|
+
for (const rawFile of rawFiles) {
|
|
3373
|
+
if (files.length >= IMAGE_GALLERY_MAX_FILES) break;
|
|
3374
|
+
const fileFields = rawFile && typeof rawFile === "object" ? rawFile : null;
|
|
3375
|
+
const reference = typeof rawFile === "string" ? rawFile.trim() : readText(fileFields?.reference);
|
|
3376
|
+
if (reference === void 0 || !FILE_REFERENCE_PATTERN.test(reference) || seenReferences.has(reference)) continue;
|
|
3377
|
+
seenReferences.add(reference);
|
|
3378
|
+
files.push({
|
|
3379
|
+
reference,
|
|
3380
|
+
letter: IMAGE_GALLERY_LETTERS[files.length],
|
|
3381
|
+
label: readText(fileFields?.label),
|
|
3382
|
+
caption: readText(fileFields?.caption)
|
|
3383
|
+
});
|
|
3381
3384
|
}
|
|
3382
|
-
return
|
|
3383
|
-
|
|
3384
|
-
const
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
return { status: "mounted" };
|
|
3385
|
+
if (files.length === 0) return null;
|
|
3386
|
+
const selection = fields.selection === "one" || fields.selection === "many" ? fields.selection : "none";
|
|
3387
|
+
const display = fields.display === "inline" || fields.display === "canvas" ? fields.display : void 0;
|
|
3388
|
+
const name2 = readText(fields.name);
|
|
3389
|
+
return {
|
|
3390
|
+
title: readText(fields.title),
|
|
3391
|
+
name: name2 !== void 0 && GALLERY_NAME_PATTERN.test(name2) ? name2 : void 0,
|
|
3392
|
+
selection,
|
|
3393
|
+
display,
|
|
3394
|
+
files
|
|
3395
|
+
};
|
|
3394
3396
|
};
|
|
3395
|
-
const
|
|
3396
|
-
const
|
|
3397
|
-
const
|
|
3398
|
-
const
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3397
|
+
const buildImageGallerySentencePrefix = (name2) => name2 ? `${IMAGE_GALLERY_WIDGET_TYPE} ${name2}` : IMAGE_GALLERY_WIDGET_TYPE;
|
|
3398
|
+
const buildImageGalleryPickSentence = (name2, pickedFiles) => {
|
|
3399
|
+
const parts = [...pickedFiles].sort((first, second) => first.letter.localeCompare(second.letter)).map((file) => `${file.letter} (${file.reference})`);
|
|
3400
|
+
const picked = parts.length === 1 ? parts[0] : `${parts.length} pictures: ${parts.join(", ")}`;
|
|
3401
|
+
return `${buildImageGallerySentencePrefix(name2)}: the operator picked ${picked}`;
|
|
3402
|
+
};
|
|
3403
|
+
const buildImageGalleryDeclineSentence = (name2) => `${buildImageGallerySentencePrefix(name2)}: the operator declined all pictures`;
|
|
3404
|
+
const gallery = "agents_gallery_lJwj7T";
|
|
3405
|
+
const galleryCanvas = "agents_galleryCanvas_6l4eHF";
|
|
3406
|
+
const grid = "agents_grid_Z956iQ";
|
|
3407
|
+
const gridTwo = "agents_gridTwo_z2nzad";
|
|
3408
|
+
const gridInline = "agents_gridInline_Be-B2w";
|
|
3409
|
+
const gridCanvas = "agents_gridCanvas_Z6ydmS";
|
|
3410
|
+
const tile = "agents_tile_8mGCxl";
|
|
3411
|
+
const tileSelected = "agents_tileSelected_fhbEAy";
|
|
3412
|
+
const picture = "agents_picture_bfTidS";
|
|
3413
|
+
const pictureState = "agents_pictureState_SgILeJ";
|
|
3414
|
+
const pictureLoading = "agents_pictureLoading_8r88ho";
|
|
3415
|
+
const letter = "agents_letter_vbfShD";
|
|
3416
|
+
const texts = "agents_texts_RN6-ST";
|
|
3417
|
+
const pick$2 = "agents_pick_oR7k01";
|
|
3418
|
+
const pickSelected = "agents_pickSelected_B7VJfA";
|
|
3419
|
+
const actions$1 = "agents_actions_C6XnH0";
|
|
3420
|
+
const lightbox = "agents_lightbox_x8Css9";
|
|
3421
|
+
const lightboxFrame = "agents_lightboxFrame_LIU7dG";
|
|
3422
|
+
const lightboxState = "agents_lightboxState_Z6bJ1i";
|
|
3423
|
+
const lightboxBar = "agents_lightboxBar_AKL0Ny";
|
|
3424
|
+
const lightboxLetter = "agents_lightboxLetter_XC08f2";
|
|
3425
|
+
const lightboxButton = "agents_lightboxButton_6T4AtB";
|
|
3426
|
+
const lightboxClose = "agents_lightboxClose_2mJEw5";
|
|
3427
|
+
const lightboxPrevious = "agents_lightboxPrevious_tndmQn";
|
|
3428
|
+
const lightboxNext = "agents_lightboxNext_k9uvHj";
|
|
3429
|
+
const styles$8 = {
|
|
3430
|
+
gallery,
|
|
3431
|
+
galleryCanvas,
|
|
3432
|
+
grid,
|
|
3433
|
+
gridTwo,
|
|
3434
|
+
gridInline,
|
|
3435
|
+
gridCanvas,
|
|
3436
|
+
tile,
|
|
3437
|
+
tileSelected,
|
|
3438
|
+
picture,
|
|
3439
|
+
pictureState,
|
|
3440
|
+
pictureLoading,
|
|
3441
|
+
letter,
|
|
3442
|
+
texts,
|
|
3443
|
+
pick: pick$2,
|
|
3444
|
+
pickSelected,
|
|
3445
|
+
actions: actions$1,
|
|
3446
|
+
lightbox,
|
|
3447
|
+
lightboxFrame,
|
|
3448
|
+
lightboxState,
|
|
3449
|
+
lightboxBar,
|
|
3450
|
+
lightboxLetter,
|
|
3451
|
+
lightboxButton,
|
|
3452
|
+
lightboxClose,
|
|
3453
|
+
lightboxPrevious,
|
|
3454
|
+
lightboxNext
|
|
3455
|
+
};
|
|
3456
|
+
const ImageGalleryTile = ({
|
|
3457
|
+
file,
|
|
3458
|
+
isSelectable,
|
|
3459
|
+
isSelected,
|
|
3460
|
+
isDisabled,
|
|
3461
|
+
onToggle,
|
|
3462
|
+
onEnlarge,
|
|
3463
|
+
testId: testId2
|
|
3464
|
+
}) => {
|
|
3465
|
+
const picture2 = useFilePictureUrl(file.reference, "THUMBNAIL");
|
|
3466
|
+
const enlargeLabel = translateText("Enlarge picture %letter%", { letter: file.letter });
|
|
3467
|
+
return /* @__PURE__ */ jsxs(
|
|
3468
|
+
"div",
|
|
3469
|
+
{
|
|
3470
|
+
className: classNames(styles$8.tile, isSelected && styles$8.tileSelected),
|
|
3471
|
+
"data-testid": `${testId2}-tile-${file.letter}`,
|
|
3472
|
+
"data-selected": isSelected ? "true" : void 0,
|
|
3473
|
+
children: [
|
|
3474
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: styles$8.picture, onClick: onEnlarge, "aria-label": enlargeLabel, title: file.reference, children: [
|
|
3475
|
+
picture2.url !== null ? /* @__PURE__ */ jsx("img", { src: picture2.url, alt: file.label ?? file.reference, loading: "lazy" }) : /* @__PURE__ */ jsx("span", { className: styles$8.pictureState, children: picture2.status === "loading" ? /* @__PURE__ */ jsx("span", { className: styles$8.pictureLoading }) : /* @__PURE__ */ jsx(Text, { role: "caption", textAlign: "center", children: picture2.status === "notConnected" ? "Pictures are not connected here" : "Picture could not be loaded" }) }),
|
|
3476
|
+
/* @__PURE__ */ jsx("span", { className: styles$8.letter, "aria-hidden": true, children: file.letter })
|
|
3477
|
+
] }),
|
|
3478
|
+
(file.label || file.caption) && /* @__PURE__ */ jsxs("div", { className: styles$8.texts, children: [
|
|
3479
|
+
file.label && /* @__PURE__ */ jsx(Text, { role: "help", weight: "medium", translate: false, ellipsis: true, children: file.label }),
|
|
3480
|
+
file.caption && /* @__PURE__ */ jsx(Text, { role: "caption", translate: false, ellipsis: true, children: file.caption })
|
|
3481
|
+
] }),
|
|
3482
|
+
isSelectable && /* @__PURE__ */ jsxs(
|
|
3483
|
+
"button",
|
|
3484
|
+
{
|
|
3485
|
+
type: "button",
|
|
3486
|
+
className: classNames(styles$8.pick, isSelected && styles$8.pickSelected),
|
|
3487
|
+
onClick: onToggle,
|
|
3488
|
+
disabled: isDisabled,
|
|
3489
|
+
"aria-pressed": isSelected,
|
|
3490
|
+
"data-testid": `${testId2}-pick-${file.letter}`,
|
|
3491
|
+
children: [
|
|
3492
|
+
isSelected && /* @__PURE__ */ jsx(Icon, { name: "check", pixelSize: 14 }),
|
|
3493
|
+
/* @__PURE__ */ jsx(Text, { role: "help", translate: false, children: file.letter })
|
|
3494
|
+
]
|
|
3495
|
+
}
|
|
3496
|
+
)
|
|
3497
|
+
]
|
|
3498
|
+
}
|
|
3499
|
+
);
|
|
3418
3500
|
};
|
|
3419
|
-
const
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3501
|
+
const ImageGalleryLightbox = ({
|
|
3502
|
+
files,
|
|
3503
|
+
position,
|
|
3504
|
+
onPosition,
|
|
3505
|
+
onClose,
|
|
3506
|
+
testId: testId2
|
|
3507
|
+
}) => {
|
|
3508
|
+
const file = files[position];
|
|
3509
|
+
const picture2 = useFilePictureUrl(file.reference, "PREVIEW");
|
|
3510
|
+
const dialogRef = useRef(null);
|
|
3511
|
+
const closeLabel = translateText("Close");
|
|
3512
|
+
const previousLabel = translateText("Previous picture");
|
|
3513
|
+
const nextLabel = translateText("Next picture");
|
|
3514
|
+
useEffect(() => {
|
|
3515
|
+
dialogRef.current?.focus();
|
|
3516
|
+
}, []);
|
|
3517
|
+
const onKeyDown = (event) => {
|
|
3518
|
+
if (event.key === "Escape") onClose();
|
|
3519
|
+
if (event.key === "ArrowLeft" && position > 0) onPosition(position - 1);
|
|
3520
|
+
if (event.key === "ArrowRight" && position < files.length - 1) onPosition(position + 1);
|
|
3521
|
+
};
|
|
3522
|
+
return createPortal(
|
|
3523
|
+
/* @__PURE__ */ jsxs(
|
|
3524
|
+
"div",
|
|
3525
|
+
{
|
|
3526
|
+
ref: dialogRef,
|
|
3527
|
+
className: styles$8.lightbox,
|
|
3528
|
+
role: "dialog",
|
|
3529
|
+
"aria-modal": "true",
|
|
3530
|
+
"aria-label": file.label ?? file.reference,
|
|
3531
|
+
tabIndex: -1,
|
|
3532
|
+
onKeyDown,
|
|
3533
|
+
onClick: onClose,
|
|
3534
|
+
"data-testid": `${testId2}-lightbox`,
|
|
3535
|
+
children: [
|
|
3536
|
+
/* @__PURE__ */ jsxs("div", { className: styles$8.lightboxFrame, onClick: (event) => event.stopPropagation(), children: [
|
|
3537
|
+
picture2.url !== null ? /* @__PURE__ */ jsx("img", { src: picture2.url, alt: file.label ?? file.reference }) : /* @__PURE__ */ jsx("span", { className: styles$8.lightboxState, children: picture2.status === "loading" ? /* @__PURE__ */ jsx("span", { className: styles$8.pictureLoading }) : /* @__PURE__ */ jsx(Text, { role: "body", color: "#fff", children: "Picture could not be loaded" }) }),
|
|
3538
|
+
/* @__PURE__ */ jsxs("div", { className: styles$8.lightboxBar, children: [
|
|
3539
|
+
/* @__PURE__ */ jsx("span", { className: styles$8.lightboxLetter, children: file.letter }),
|
|
3540
|
+
/* @__PURE__ */ jsx(Text, { role: "help", color: "#fff", translate: false, ellipsis: true, children: [file.label, file.caption].filter(Boolean).join(" · ") || file.reference })
|
|
3541
|
+
] })
|
|
3542
|
+
] }),
|
|
3543
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: classNames(styles$8.lightboxButton, styles$8.lightboxClose), "aria-label": closeLabel, onClick: onClose, children: /* @__PURE__ */ jsx(Icon, { name: "close", pixelSize: 20, color: "#fff" }) }),
|
|
3544
|
+
position > 0 && /* @__PURE__ */ jsx(
|
|
3545
|
+
"button",
|
|
3546
|
+
{
|
|
3547
|
+
type: "button",
|
|
3548
|
+
className: classNames(styles$8.lightboxButton, styles$8.lightboxPrevious),
|
|
3549
|
+
"aria-label": previousLabel,
|
|
3550
|
+
onClick: (event) => {
|
|
3551
|
+
event.stopPropagation();
|
|
3552
|
+
onPosition(position - 1);
|
|
3553
|
+
},
|
|
3554
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "arrowLeft", pixelSize: 20, color: "#fff" })
|
|
3555
|
+
}
|
|
3556
|
+
),
|
|
3557
|
+
position < files.length - 1 && /* @__PURE__ */ jsx(
|
|
3558
|
+
"button",
|
|
3559
|
+
{
|
|
3560
|
+
type: "button",
|
|
3561
|
+
className: classNames(styles$8.lightboxButton, styles$8.lightboxNext),
|
|
3562
|
+
"aria-label": nextLabel,
|
|
3563
|
+
onClick: (event) => {
|
|
3564
|
+
event.stopPropagation();
|
|
3565
|
+
onPosition(position + 1);
|
|
3566
|
+
},
|
|
3567
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "arrowRight", pixelSize: 20, color: "#fff" })
|
|
3568
|
+
}
|
|
3569
|
+
)
|
|
3570
|
+
]
|
|
3571
|
+
}
|
|
3572
|
+
),
|
|
3573
|
+
document.body
|
|
3574
|
+
);
|
|
3424
3575
|
};
|
|
3425
|
-
const
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
const
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3576
|
+
const ImageGallery = ({ gallery: gallery2, interactive, surface: surface2, testId: testId2 }) => {
|
|
3577
|
+
const { injectSignal } = useConversationWidgetContext();
|
|
3578
|
+
const [selectedLetters, setSelectedLetters] = useState([]);
|
|
3579
|
+
const [lightboxPosition, setLightboxPosition] = useState(null);
|
|
3580
|
+
const [sentAnswer, setSentAnswer] = useState(null);
|
|
3581
|
+
const [pending, setPending] = useState(false);
|
|
3582
|
+
const pendingRef = useRef(false);
|
|
3583
|
+
const isSelectable = gallery2.selection !== "none";
|
|
3584
|
+
const isLocked = sentAnswer !== null;
|
|
3585
|
+
const isDisabled = !interactive || isLocked || pending;
|
|
3586
|
+
const selectedFiles = useMemo(
|
|
3587
|
+
() => gallery2.files.filter((file) => selectedLetters.includes(file.letter)),
|
|
3588
|
+
[gallery2.files, selectedLetters]
|
|
3589
|
+
);
|
|
3590
|
+
const toggle = useCallback(
|
|
3591
|
+
(letter2) => {
|
|
3592
|
+
setSelectedLetters((current) => {
|
|
3593
|
+
if (gallery2.selection === "one") return current.includes(letter2) ? [] : [letter2];
|
|
3594
|
+
return current.includes(letter2) ? current.filter((selected) => selected !== letter2) : [...current, letter2];
|
|
3595
|
+
});
|
|
3596
|
+
},
|
|
3597
|
+
[gallery2.selection]
|
|
3598
|
+
);
|
|
3599
|
+
const send = async (sentence, answer) => {
|
|
3600
|
+
if (isDisabled || pendingRef.current) return;
|
|
3601
|
+
pendingRef.current = true;
|
|
3602
|
+
setPending(true);
|
|
3603
|
+
try {
|
|
3604
|
+
const result2 = await injectSignal(sentence);
|
|
3605
|
+
if (result2 !== false) setSentAnswer(answer);
|
|
3606
|
+
} catch {
|
|
3607
|
+
} finally {
|
|
3608
|
+
pendingRef.current = false;
|
|
3609
|
+
setPending(false);
|
|
3610
|
+
}
|
|
3611
|
+
};
|
|
3612
|
+
const columnsClass = surface2 === "canvas" ? styles$8.gridCanvas : gallery2.files.length <= 2 ? styles$8.gridTwo : styles$8.gridInline;
|
|
3613
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames(styles$8.gallery, surface2 === "canvas" && styles$8.galleryCanvas), "data-testid": testId2, children: [
|
|
3614
|
+
gallery2.title && /* @__PURE__ */ jsx(Text, { role: surface2 === "canvas" ? "title" : "body", weight: "medium", translate: false, testId: `${testId2}-title`, children: gallery2.title }),
|
|
3615
|
+
/* @__PURE__ */ jsx("div", { className: classNames(styles$8.grid, columnsClass), role: "list", children: gallery2.files.map((file, position) => /* @__PURE__ */ jsx("div", { role: "listitem", children: /* @__PURE__ */ jsx(
|
|
3616
|
+
ImageGalleryTile,
|
|
3617
|
+
{
|
|
3618
|
+
file,
|
|
3619
|
+
isSelectable: isSelectable && !isLocked,
|
|
3620
|
+
isSelected: (sentAnswer?.letters ?? selectedLetters).includes(file.letter),
|
|
3621
|
+
isDisabled,
|
|
3622
|
+
onToggle: () => toggle(file.letter),
|
|
3623
|
+
onEnlarge: () => setLightboxPosition(position),
|
|
3624
|
+
testId: testId2
|
|
3625
|
+
}
|
|
3626
|
+
) }, file.reference)) }),
|
|
3627
|
+
/* @__PURE__ */ jsx("div", { "aria-live": "polite", children: sentAnswer !== null ? /* @__PURE__ */ jsx(
|
|
3628
|
+
DonePill,
|
|
3629
|
+
{
|
|
3630
|
+
status: sentAnswer.kind === "picked" ? "success" : "neutral",
|
|
3631
|
+
translate: false,
|
|
3632
|
+
testId: `${testId2}-done`,
|
|
3633
|
+
children: sentAnswer.kind === "picked" ? sentAnswer.letters.join(", ") : "—"
|
|
3634
|
+
}
|
|
3635
|
+
) : isSelectable && /* @__PURE__ */ jsxs("div", { className: styles$8.actions, children: [
|
|
3636
|
+
/* @__PURE__ */ jsx(
|
|
3637
|
+
Button,
|
|
3638
|
+
{
|
|
3639
|
+
variant: "muted",
|
|
3640
|
+
size: "small",
|
|
3641
|
+
disabled: isDisabled,
|
|
3642
|
+
onClick: () => send(buildImageGalleryDeclineSentence(gallery2.name), { kind: "declined", letters: [] }),
|
|
3643
|
+
testId: `${testId2}-decline`,
|
|
3644
|
+
children: "None of these"
|
|
3645
|
+
}
|
|
3646
|
+
),
|
|
3647
|
+
/* @__PURE__ */ jsx(
|
|
3648
|
+
Button,
|
|
3649
|
+
{
|
|
3650
|
+
size: "small",
|
|
3651
|
+
disabled: isDisabled || selectedFiles.length === 0,
|
|
3652
|
+
isLoading: pending,
|
|
3653
|
+
onClick: () => send(buildImageGalleryPickSentence(gallery2.name, selectedFiles), {
|
|
3654
|
+
kind: "picked",
|
|
3655
|
+
letters: selectedFiles.map((file) => file.letter)
|
|
3656
|
+
}),
|
|
3657
|
+
replacements: { count: selectedFiles.length, letter: selectedFiles[0]?.letter ?? "" },
|
|
3658
|
+
testId: `${testId2}-confirm`,
|
|
3659
|
+
children: gallery2.selection === "many" && selectedFiles.length > 1 ? textKey("Use %count% pictures") : selectedFiles.length === 1 ? textKey("Use picture %letter%") : textKey("Pick a picture")
|
|
3660
|
+
}
|
|
3661
|
+
)
|
|
3662
|
+
] }) }),
|
|
3663
|
+
lightboxPosition !== null && /* @__PURE__ */ jsx(
|
|
3664
|
+
ImageGalleryLightbox,
|
|
3665
|
+
{
|
|
3666
|
+
files: gallery2.files,
|
|
3667
|
+
position: lightboxPosition,
|
|
3668
|
+
onPosition: setLightboxPosition,
|
|
3669
|
+
onClose: () => setLightboxPosition(null),
|
|
3670
|
+
testId: testId2
|
|
3671
|
+
}
|
|
3672
|
+
)
|
|
3673
|
+
] });
|
|
3434
3674
|
};
|
|
3435
|
-
const
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3675
|
+
const IMAGE_GALLERY_CANVAS_ID = "imageGallery";
|
|
3676
|
+
const testId$3 = "image-gallery-widget";
|
|
3677
|
+
const IMAGE_GALLERY_INLINE_LIMIT = 6;
|
|
3678
|
+
const ImageGalleryConversationWidget = (props) => {
|
|
3679
|
+
const { payload, interactive = false, justDelivered = false, messageId } = props;
|
|
3680
|
+
const { messages } = useConversationWidgetContext();
|
|
3681
|
+
const gallery2 = useMemo(() => parseImageGalleryPayload(payload), [payload]);
|
|
3682
|
+
const canvas = canvasForMessageWidget(IMAGE_GALLERY_CANVAS_ID, messageId, payload);
|
|
3683
|
+
const isStale = useMemo(() => {
|
|
3684
|
+
if (!messages || messageId === void 0) return false;
|
|
3685
|
+
const hostIndex = messages.findIndex((message) => String(message.id) === String(messageId));
|
|
3686
|
+
if (hostIndex === -1) return false;
|
|
3687
|
+
return messages.slice(hostIndex + 1).some((message) => message.role === "USER");
|
|
3688
|
+
}, [messages, messageId]);
|
|
3689
|
+
useReportWidgetRenderStatus(
|
|
3690
|
+
gallery2 === null ? "failed" : "mounted",
|
|
3691
|
+
gallery2 === null ? "INVALID_PROP" : void 0,
|
|
3692
|
+
gallery2 === null ? "The ImageGallery carries no file reference (<source>/<id>); the widget was dropped." : void 0
|
|
3693
|
+
);
|
|
3694
|
+
if (gallery2 === null) return null;
|
|
3695
|
+
return /* @__PURE__ */ jsx(
|
|
3696
|
+
CanvasWidgetSwitch,
|
|
3697
|
+
{
|
|
3698
|
+
display: gallery2.display,
|
|
3699
|
+
exceedsInlineLimit: gallery2.files.length > IMAGE_GALLERY_INLINE_LIMIT,
|
|
3700
|
+
title: gallery2.title ?? textKey("Pictures"),
|
|
3701
|
+
subtitle: gallery2.files.length === 1 ? textKey("1 picture") : textKey("%count% pictures"),
|
|
3702
|
+
subtitleReplacements: { count: gallery2.files.length },
|
|
3703
|
+
icon: "image",
|
|
3704
|
+
justDelivered,
|
|
3705
|
+
canvas,
|
|
3706
|
+
testId: testId$3,
|
|
3707
|
+
renderInline: () => /* @__PURE__ */ jsx(ImageGallery, { gallery: gallery2, interactive: interactive && !isStale, surface: "inline", testId: testId$3 })
|
|
3708
|
+
}
|
|
3709
|
+
);
|
|
3442
3710
|
};
|
|
3443
|
-
const
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3711
|
+
const MAX_DRAFT_BODY_LENGTH = 2e4;
|
|
3712
|
+
const MAX_TITLE_LENGTH = 160;
|
|
3713
|
+
const MAX_RECIPIENT_LENGTH = 320;
|
|
3714
|
+
const MAX_SUBJECT_LENGTH = 240;
|
|
3715
|
+
const KIND_KEYS = ["kind", "variant", "draftType", "draft_type", "category"];
|
|
3716
|
+
const TITLE_KEYS = ["title", "heading", "name"];
|
|
3717
|
+
const RECIPIENT_KEYS = ["recipient", "recipients", "to", "addressee", "recipientEmail", "email"];
|
|
3718
|
+
const SUBJECT_KEYS = ["subject", "subjectLine", "subject_line"];
|
|
3719
|
+
const BODY_KEYS = ["body", "content", "text", "markdown", "message", "draft"];
|
|
3720
|
+
const NO_RECIPIENT_WORDS = /* @__PURE__ */ new Set(["not specified", "unspecified", "unknown", "n/a", "none", "-", "tbd"]);
|
|
3721
|
+
const KIND_ALIASES = {
|
|
3722
|
+
email: "email",
|
|
3723
|
+
"e-mail": "email",
|
|
3724
|
+
mail: "email",
|
|
3725
|
+
letter: "letter",
|
|
3726
|
+
brief: "letter",
|
|
3727
|
+
post: "post",
|
|
3728
|
+
socialpost: "post",
|
|
3729
|
+
social: "post",
|
|
3730
|
+
reply: "reply",
|
|
3731
|
+
response: "reply",
|
|
3732
|
+
answer: "reply",
|
|
3733
|
+
message: "message",
|
|
3734
|
+
sms: "message",
|
|
3735
|
+
chat: "message",
|
|
3736
|
+
dm: "message",
|
|
3737
|
+
other: "other",
|
|
3738
|
+
draft: "other",
|
|
3739
|
+
memo: "other"
|
|
3462
3740
|
};
|
|
3463
|
-
const
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
const label2 = data?.name ?? buildUnnamedAgentSpaceLabel(agentSpaceKey);
|
|
3469
|
-
const explanation = buildWidgetOfAnotherAgentSpaceExplanation(label2);
|
|
3470
|
-
const noteLabel = translateText("Showing data for %label%", { label: label2 });
|
|
3471
|
-
return /* @__PURE__ */ jsx("div", { className: inFlow ? styles$6.inFlowAnchor : styles$6.anchor, children: /* @__PURE__ */ jsx(Tooltip, { text: explanation, placement: "top", dark: true, wrapsChild: true, children: /* @__PURE__ */ jsx("span", { className: styles$6.root, role: "note", "aria-label": noteLabel, tabIndex: 0, children: /* @__PURE__ */ jsx("span", { className: styles$6.name, children: label2 }) }) }) });
|
|
3741
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3742
|
+
const readCappedString = (value, maxLength) => {
|
|
3743
|
+
if (typeof value !== "string") return void 0;
|
|
3744
|
+
const trimmedValue = value.trim();
|
|
3745
|
+
return trimmedValue === "" ? void 0 : trimmedValue.slice(0, maxLength);
|
|
3472
3746
|
};
|
|
3473
|
-
const
|
|
3474
|
-
const
|
|
3475
|
-
|
|
3747
|
+
const readFirstString = (record, keys, maxLength) => {
|
|
3748
|
+
for (const key of keys) {
|
|
3749
|
+
const stringValue = readCappedString(record[key], maxLength);
|
|
3750
|
+
if (stringValue !== void 0) return stringValue;
|
|
3751
|
+
}
|
|
3752
|
+
return void 0;
|
|
3476
3753
|
};
|
|
3477
|
-
const
|
|
3478
|
-
const
|
|
3479
|
-
|
|
3754
|
+
const readKind = (record) => {
|
|
3755
|
+
const kindWord = readFirstString(record, KIND_KEYS, 40);
|
|
3756
|
+
if (kindWord === void 0) return void 0;
|
|
3757
|
+
return KIND_ALIASES[kindWord.toLowerCase().replace(/[\s_]/g, "")] ?? "other";
|
|
3480
3758
|
};
|
|
3481
|
-
const
|
|
3482
|
-
const
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3759
|
+
const readRecipient = (record) => {
|
|
3760
|
+
for (const key of RECIPIENT_KEYS) {
|
|
3761
|
+
const rawValue = record[key];
|
|
3762
|
+
const recipient = Array.isArray(rawValue) ? readCappedString(
|
|
3763
|
+
rawValue.filter((entry) => typeof entry === "string").join(", "),
|
|
3764
|
+
MAX_RECIPIENT_LENGTH
|
|
3765
|
+
) : readCappedString(rawValue, MAX_RECIPIENT_LENGTH);
|
|
3766
|
+
if (recipient !== void 0) return NO_RECIPIENT_WORDS.has(recipient.toLowerCase()) ? void 0 : recipient;
|
|
3767
|
+
}
|
|
3768
|
+
return void 0;
|
|
3487
3769
|
};
|
|
3488
|
-
const
|
|
3489
|
-
const
|
|
3490
|
-
const
|
|
3491
|
-
const
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
const footer = "agents_footer_HVn5KW";
|
|
3498
|
-
const styles$4 = {
|
|
3499
|
-
wrap: wrap$1,
|
|
3500
|
-
heading,
|
|
3501
|
-
options,
|
|
3502
|
-
option,
|
|
3503
|
-
optionSelected,
|
|
3504
|
-
optionControl,
|
|
3505
|
-
optionBody,
|
|
3506
|
-
optionLabel,
|
|
3507
|
-
optionLabelSelected,
|
|
3508
|
-
footer
|
|
3770
|
+
const readBody = (record) => {
|
|
3771
|
+
for (const key of BODY_KEYS) {
|
|
3772
|
+
const rawValue = record[key];
|
|
3773
|
+
const bodyValue = isRecord$1(rawValue) ? rawValue.text ?? rawValue.markdown ?? rawValue.body : rawValue;
|
|
3774
|
+
if (typeof bodyValue === "string" && bodyValue.trim() !== "") {
|
|
3775
|
+
return bodyValue.replace(/^\s*\n/, "").trimEnd().slice(0, MAX_DRAFT_BODY_LENGTH);
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
return "";
|
|
3509
3779
|
};
|
|
3510
|
-
const
|
|
3780
|
+
const hasUnreadableBodyField = (record) => BODY_KEYS.some((key) => record[key] !== void 0 && record[key] !== null && typeof record[key] !== "string");
|
|
3781
|
+
const parseWritingDraftPayload = (payload) => {
|
|
3782
|
+
let parsedPayload;
|
|
3511
3783
|
try {
|
|
3512
|
-
|
|
3513
|
-
if (!parsed || !Array.isArray(parsed.options)) return null;
|
|
3514
|
-
return parsed;
|
|
3784
|
+
parsedPayload = JSON.parse(payload ?? "");
|
|
3515
3785
|
} catch {
|
|
3516
|
-
return
|
|
3786
|
+
return { isValidPayload: false, body: "", isBodyUnreadable: false };
|
|
3787
|
+
}
|
|
3788
|
+
if (!isRecord$1(parsedPayload)) return { isValidPayload: false, body: "", isBodyUnreadable: false };
|
|
3789
|
+
const kind = readKind(parsedPayload);
|
|
3790
|
+
const title2 = readFirstString(parsedPayload, TITLE_KEYS, MAX_TITLE_LENGTH);
|
|
3791
|
+
const recipient = readRecipient(parsedPayload);
|
|
3792
|
+
const subject = readFirstString(parsedPayload, SUBJECT_KEYS, MAX_SUBJECT_LENGTH);
|
|
3793
|
+
const body2 = readBody(parsedPayload);
|
|
3794
|
+
return {
|
|
3795
|
+
isValidPayload: true,
|
|
3796
|
+
body: body2,
|
|
3797
|
+
isBodyUnreadable: body2 === "" && hasUnreadableBodyField(parsedPayload),
|
|
3798
|
+
...kind ? { kind } : {},
|
|
3799
|
+
...title2 ? { title: title2 } : {},
|
|
3800
|
+
...recipient ? { recipient } : {},
|
|
3801
|
+
...subject ? { subject } : {}
|
|
3802
|
+
};
|
|
3803
|
+
};
|
|
3804
|
+
const replaceLinks = (line) => line.replace(/!?\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g, (_match, label2, url) => {
|
|
3805
|
+
const trimmedLabel = label2.trim();
|
|
3806
|
+
if (trimmedLabel === "" || trimmedLabel === url || `mailto:${trimmedLabel}` === url) {
|
|
3807
|
+
return url.replace(/^mailto:/i, "");
|
|
3808
|
+
}
|
|
3809
|
+
return `${trimmedLabel} (${url.replace(/^mailto:/i, "")})`;
|
|
3810
|
+
});
|
|
3811
|
+
const removeEmphasis = (line) => line.replace(/(\*\*|__)(?=\S)(.+?)(?<=\S)\1/g, "$2").replace(/(^|[^*\w])\*(?=\S)([^*]+?)(?<=\S)\*(?!\*)/g, "$1$2").replace(/(^|[^_\w])_(?=\S)([^_]+?)(?<=\S)_(?![_\w])/g, "$1$2").replace(/~~(?=\S)(.+?)(?<=\S)~~/g, "$1").replace(/`([^`]+)`/g, "$1");
|
|
3812
|
+
const convertLine = (line) => {
|
|
3813
|
+
if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) return "";
|
|
3814
|
+
const withoutHeading = line.replace(/^\s{0,3}#{1,6}\s+/, "").replace(/\s+#+\s*$/, "");
|
|
3815
|
+
const withoutQuote = withoutHeading.replace(/^\s{0,3}>\s?/, "");
|
|
3816
|
+
const withListMarker = withoutQuote.replace(/^(\s*)[*+]\s+/, "$1- ");
|
|
3817
|
+
const withoutHardBreak = withListMarker.replace(/(\s{2,}|\\)$/, "");
|
|
3818
|
+
return removeEmphasis(replaceLinks(withoutHardBreak));
|
|
3819
|
+
};
|
|
3820
|
+
const convertDraftMarkdownToPlainText = (markdown) => markdown.replace(/\r\n?/g, "\n").split("\n").map(convertLine).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
3821
|
+
const MAX_MAIL_LINK_LENGTH = 1900;
|
|
3822
|
+
const EMAIL_ADDRESS_PATTERN = /^[^\s@<>()[\]"',;:\\]+@[^\s@<>()[\]"',;:\\]+\.[^\s@<>()[\]"',;:\\.]{2,}$/;
|
|
3823
|
+
const readEmailAddresses = (recipient) => (recipient ?? "").split(/[,;]/).map((recipientPart) => {
|
|
3824
|
+
const bracketedAddress = /<([^<>]+)>/.exec(recipientPart);
|
|
3825
|
+
return (bracketedAddress ? bracketedAddress[1] : recipientPart).trim().replace(/^mailto:/i, "");
|
|
3826
|
+
}).filter((address) => EMAIL_ADDRESS_PATTERN.test(address));
|
|
3827
|
+
const encodeMailHeaderValue = (value) => encodeURIComponent(value.replace(/\r?\n/g, "\r\n"));
|
|
3828
|
+
const buildMailHref = (addressPart, queryParts) => {
|
|
3829
|
+
const query = queryParts.filter((queryPart) => queryPart !== void 0).join("&");
|
|
3830
|
+
return `mailto:${addressPart}${query === "" ? "" : `?${query}`}`;
|
|
3831
|
+
};
|
|
3832
|
+
const buildDraftMailLink = (recipient, subject, plainTextBody) => {
|
|
3833
|
+
const addressPart = readEmailAddresses(recipient).map((address) => encodeURIComponent(address).replace(/%40/g, "@")).join(",");
|
|
3834
|
+
const subjectPart = subject ? `subject=${encodeMailHeaderValue(subject)}` : void 0;
|
|
3835
|
+
const bodyPart = plainTextBody !== "" ? `body=${encodeMailHeaderValue(plainTextBody)}` : void 0;
|
|
3836
|
+
const hrefWithBody = buildMailHref(addressPart, [subjectPart, bodyPart]);
|
|
3837
|
+
if (hrefWithBody.length <= MAX_MAIL_LINK_LENGTH || bodyPart === void 0) {
|
|
3838
|
+
return { href: hrefWithBody, includesBody: bodyPart !== void 0 };
|
|
3839
|
+
}
|
|
3840
|
+
return { href: buildMailHref(addressPart, [subjectPart]), includesBody: false };
|
|
3841
|
+
};
|
|
3842
|
+
const remarkDraftLineBreaks = () => (tree) => {
|
|
3843
|
+
visit(tree, "text", (node, index, parent) => {
|
|
3844
|
+
if (!parent?.children || index === void 0 || typeof node.value !== "string" || !node.value.includes("\n")) {
|
|
3845
|
+
return;
|
|
3846
|
+
}
|
|
3847
|
+
const lineNodes = [];
|
|
3848
|
+
node.value.split("\n").forEach((line, lineIndex) => {
|
|
3849
|
+
if (lineIndex > 0) lineNodes.push({ type: "break" });
|
|
3850
|
+
if (line !== "") lineNodes.push({ type: "text", value: line });
|
|
3851
|
+
});
|
|
3852
|
+
parent.children.splice(index, 1, ...lineNodes);
|
|
3853
|
+
return index + lineNodes.length;
|
|
3854
|
+
});
|
|
3855
|
+
};
|
|
3856
|
+
const root = "agents_root_ZXdBmq";
|
|
3857
|
+
const titleBlock = "agents_titleBlock_wE5qKF";
|
|
3858
|
+
const card = "agents_card_gsMEzB";
|
|
3859
|
+
const actions = "agents_actions_nrMgyL";
|
|
3860
|
+
const wrappingText = "agents_wrappingText_XaePR6";
|
|
3861
|
+
const header$1 = "agents_header_0ASqLt";
|
|
3862
|
+
const headerLine = "agents_headerLine_k3j-5m";
|
|
3863
|
+
const emptyValue = "agents_emptyValue_gTCHJD";
|
|
3864
|
+
const editFields = "agents_editFields_dxl8RQ";
|
|
3865
|
+
const body = "agents_body_Xj5IjL";
|
|
3866
|
+
const bodyHeading = "agents_bodyHeading_7U1DWS";
|
|
3867
|
+
const bodyLink = "agents_bodyLink_ZW0-Si";
|
|
3868
|
+
const notes = "agents_notes_fh4FWY";
|
|
3869
|
+
const meta = "agents_meta_yrPynX";
|
|
3870
|
+
const styles$7 = {
|
|
3871
|
+
root,
|
|
3872
|
+
titleBlock,
|
|
3873
|
+
card,
|
|
3874
|
+
actions,
|
|
3875
|
+
wrappingText,
|
|
3876
|
+
header: header$1,
|
|
3877
|
+
headerLine,
|
|
3878
|
+
emptyValue,
|
|
3879
|
+
editFields,
|
|
3880
|
+
body,
|
|
3881
|
+
bodyHeading,
|
|
3882
|
+
bodyLink,
|
|
3883
|
+
notes,
|
|
3884
|
+
meta
|
|
3885
|
+
};
|
|
3886
|
+
const readHastText = (node) => {
|
|
3887
|
+
if (!node) return "";
|
|
3888
|
+
if (node.type === "text") return node.value ?? "";
|
|
3889
|
+
return (node.children ?? []).map(readHastText).join("");
|
|
3890
|
+
};
|
|
3891
|
+
const renderHeading = (props) => /* @__PURE__ */ jsx(
|
|
3892
|
+
Text,
|
|
3893
|
+
{
|
|
3894
|
+
role: "body",
|
|
3895
|
+
weight: "bold",
|
|
3896
|
+
translate: false,
|
|
3897
|
+
display: "block",
|
|
3898
|
+
className: styles$7.bodyHeading,
|
|
3899
|
+
headingLevel: 4,
|
|
3900
|
+
children: escapePlainTextForText(readHastText(props.node))
|
|
3901
|
+
}
|
|
3902
|
+
);
|
|
3903
|
+
const SAFE_DRAFT_MARKDOWN_COMPONENTS = {
|
|
3904
|
+
img: () => null,
|
|
3905
|
+
h1: renderHeading,
|
|
3906
|
+
h2: renderHeading,
|
|
3907
|
+
h3: renderHeading,
|
|
3908
|
+
h4: renderHeading,
|
|
3909
|
+
h5: renderHeading,
|
|
3910
|
+
h6: renderHeading,
|
|
3911
|
+
a: (props) => {
|
|
3912
|
+
const safeUrl = readSafeHttpUrl(props.href);
|
|
3913
|
+
if (safeUrl === null) return /* @__PURE__ */ jsx("span", { children: props.children });
|
|
3914
|
+
return /* @__PURE__ */ jsx(AgentsLink, { className: styles$7.bodyLink, href: safeUrl, children: props.children });
|
|
3915
|
+
}
|
|
3916
|
+
};
|
|
3917
|
+
const DRAFT_REMARK_PLUGINS = [remarkDraftLineBreaks];
|
|
3918
|
+
const WritingDraftBody = (props) => {
|
|
3919
|
+
const { markdown } = props;
|
|
3920
|
+
return /* @__PURE__ */ jsx("div", { className: styles$7.body, "data-testid": "writing-draft-body", children: /* @__PURE__ */ jsx(
|
|
3921
|
+
Markdown,
|
|
3922
|
+
{
|
|
3923
|
+
markdown,
|
|
3924
|
+
translate: false,
|
|
3925
|
+
components: SAFE_DRAFT_MARKDOWN_COMPONENTS,
|
|
3926
|
+
remarkPlugins: DRAFT_REMARK_PLUGINS
|
|
3927
|
+
}
|
|
3928
|
+
) });
|
|
3929
|
+
};
|
|
3930
|
+
const WRITING_DRAFT_KIND_LABELS = {
|
|
3931
|
+
email: textKey("E-mail draft"),
|
|
3932
|
+
letter: textKey("Letter draft"),
|
|
3933
|
+
post: textKey("Post draft"),
|
|
3934
|
+
reply: textKey("Reply draft"),
|
|
3935
|
+
message: textKey("Message draft"),
|
|
3936
|
+
other: textKey("Text draft"),
|
|
3937
|
+
unknown: textKey("Text draft")
|
|
3938
|
+
};
|
|
3939
|
+
const WritingDraftWidget = (props) => {
|
|
3940
|
+
const {
|
|
3941
|
+
kind,
|
|
3942
|
+
title: title2,
|
|
3943
|
+
values,
|
|
3944
|
+
showsAddressFields,
|
|
3945
|
+
isEditing,
|
|
3946
|
+
isEdited,
|
|
3947
|
+
characterCount,
|
|
3948
|
+
isCopied,
|
|
3949
|
+
canOpenInMail,
|
|
3950
|
+
mailLinkOmitsBody,
|
|
3951
|
+
onChangeField,
|
|
3952
|
+
onStartEditing,
|
|
3953
|
+
onFinishEditing,
|
|
3954
|
+
onReset,
|
|
3955
|
+
onCopy,
|
|
3956
|
+
onOpenInMail
|
|
3957
|
+
} = props;
|
|
3958
|
+
const headingId = useId();
|
|
3959
|
+
const kindLabel = WRITING_DRAFT_KIND_LABELS[kind ?? "unknown"];
|
|
3960
|
+
const headline = title2 !== void 0 && title2 !== values.subject ? title2 : void 0;
|
|
3961
|
+
const showsRecipientRow = showsAddressFields || values.recipient !== "";
|
|
3962
|
+
const showsSubjectRow = showsAddressFields || values.subject !== "";
|
|
3963
|
+
const showsNotes = isEditing || isEdited || mailLinkOmitsBody;
|
|
3964
|
+
const renderHeaderLine = (label2, value, emptyLabel, testId2) => /* @__PURE__ */ jsxs("div", { className: styles$7.headerLine, "data-testid": testId2, children: [
|
|
3965
|
+
/* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-light)", children: label2 }),
|
|
3966
|
+
value !== "" ? /* @__PURE__ */ jsx(ModelText, { role: "help", weight: "medium", className: styles$7.wrappingText, children: value }) : /* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-lightest)", className: styles$7.emptyValue, children: emptyLabel })
|
|
3967
|
+
] });
|
|
3968
|
+
const renderPill = (label2, icon, onClick, testId2, isPrimary = false) => /* @__PURE__ */ jsx(
|
|
3969
|
+
ConversationWidgetButton,
|
|
3970
|
+
{
|
|
3971
|
+
variant: isPrimary ? "primary" : "muted",
|
|
3972
|
+
size: "small",
|
|
3973
|
+
rounded: true,
|
|
3974
|
+
icon,
|
|
3975
|
+
onClick,
|
|
3976
|
+
testId: testId2,
|
|
3977
|
+
children: label2
|
|
3978
|
+
}
|
|
3979
|
+
);
|
|
3980
|
+
return /* @__PURE__ */ jsxs("section", { "aria-labelledby": headingId, className: styles$7.root, "data-testid": "writing-draft-widget", children: [
|
|
3981
|
+
/* @__PURE__ */ jsxs("div", { className: styles$7.titleBlock, id: headingId, children: [
|
|
3982
|
+
/* @__PURE__ */ jsx(
|
|
3983
|
+
Text,
|
|
3984
|
+
{
|
|
3985
|
+
role: "intro",
|
|
3986
|
+
weight: "bold",
|
|
3987
|
+
testId: headline ? "writing-draft-widget-kind" : "writing-draft-widget-title",
|
|
3988
|
+
children: kindLabel
|
|
3989
|
+
}
|
|
3990
|
+
),
|
|
3991
|
+
headline ? /* @__PURE__ */ jsx(ModelText, { role: "help", color: "var(--agents-fg-light)", className: styles$7.wrappingText, testId: "writing-draft-widget-title", children: headline }) : null
|
|
3992
|
+
] }),
|
|
3993
|
+
/* @__PURE__ */ jsxs(WidgetSurface, { className: styles$7.card, testId: "writing-draft-widget", children: [
|
|
3994
|
+
isEditing ? /* @__PURE__ */ jsxs("div", { className: styles$7.editFields, children: [
|
|
3995
|
+
showsRecipientRow ? /* @__PURE__ */ jsx(
|
|
3996
|
+
TextInput,
|
|
3997
|
+
{
|
|
3998
|
+
testId: "writing-draft-recipient-input",
|
|
3999
|
+
value: values.recipient,
|
|
4000
|
+
label: "Recipient",
|
|
4001
|
+
onChange: (text2) => onChangeField("recipient", text2)
|
|
4002
|
+
}
|
|
4003
|
+
) : null,
|
|
4004
|
+
showsSubjectRow ? /* @__PURE__ */ jsx(
|
|
4005
|
+
TextInput,
|
|
4006
|
+
{
|
|
4007
|
+
testId: "writing-draft-subject-input",
|
|
4008
|
+
value: values.subject,
|
|
4009
|
+
label: "Subject",
|
|
4010
|
+
onChange: (text2) => onChangeField("subject", text2)
|
|
4011
|
+
}
|
|
4012
|
+
) : null,
|
|
4013
|
+
/* @__PURE__ */ jsx(
|
|
4014
|
+
TextArea,
|
|
4015
|
+
{
|
|
4016
|
+
testId: "writing-draft-body-input",
|
|
4017
|
+
value: values.body,
|
|
4018
|
+
label: "Text of the draft",
|
|
4019
|
+
minRows: 6,
|
|
4020
|
+
rows: 6,
|
|
4021
|
+
showsCounter: false,
|
|
4022
|
+
autoFocus: true,
|
|
4023
|
+
onChange: (text2) => onChangeField("body", text2)
|
|
4024
|
+
}
|
|
4025
|
+
)
|
|
4026
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4027
|
+
showsRecipientRow || showsSubjectRow ? /* @__PURE__ */ jsxs("div", { className: styles$7.header, children: [
|
|
4028
|
+
showsRecipientRow ? renderHeaderLine(textKey("To"), values.recipient, textKey("No recipient yet"), "writing-draft-recipient") : null,
|
|
4029
|
+
showsSubjectRow ? renderHeaderLine(textKey("Subject"), values.subject, textKey("No subject yet"), "writing-draft-subject") : null
|
|
4030
|
+
] }) : null,
|
|
4031
|
+
values.body.trim() !== "" ? /* @__PURE__ */ jsx(WritingDraftBody, { markdown: values.body }) : /* @__PURE__ */ jsx(Text, { role: "help", color: "var(--agents-fg-light)", className: styles$7.wrappingText, children: "The text of this draft is empty." })
|
|
4032
|
+
] }),
|
|
4033
|
+
/* @__PURE__ */ jsx(ConversationWidgetActions, { children: showsNotes ? /* @__PURE__ */ jsxs("div", { className: styles$7.notes, children: [
|
|
4034
|
+
isEditing || isEdited ? /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", className: styles$7.wrappingText, children: "Your changes stay on this screen — the assistant does not see them." }) : null,
|
|
4035
|
+
mailLinkOmitsBody ? /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", className: styles$7.wrappingText, children: "The text is too long for a mail link: copy it and paste it into the e-mail." }) : null
|
|
4036
|
+
] }) : null }),
|
|
4037
|
+
isEdited || characterCount !== void 0 ? /* @__PURE__ */ jsxs("div", { className: styles$7.meta, children: [
|
|
4038
|
+
isEdited ? /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", testId: "writing-draft-edited", children: "Edited by you" }) : null,
|
|
4039
|
+
characterCount !== void 0 ? /* @__PURE__ */ jsx(
|
|
4040
|
+
Text,
|
|
4041
|
+
{
|
|
4042
|
+
role: "caption",
|
|
4043
|
+
color: "var(--agents-fg-light)",
|
|
4044
|
+
replacements: { count: characterCount },
|
|
4045
|
+
context: characterCount === 1 ? "one" : "other",
|
|
4046
|
+
testId: "writing-draft-character-count",
|
|
4047
|
+
children: "%count% character"
|
|
4048
|
+
}
|
|
4049
|
+
) : null
|
|
4050
|
+
] }) : null
|
|
4051
|
+
] }),
|
|
4052
|
+
/* @__PURE__ */ jsx(ConversationWidgetActions, { children: /* @__PURE__ */ jsx("div", { className: styles$7.actions, children: isEditing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4053
|
+
renderPill(textKey("Done"), "check", onFinishEditing, "writing-draft-done", true),
|
|
4054
|
+
isEdited ? renderPill(textKey("Discard changes"), "refresh", onReset, "writing-draft-reset") : null
|
|
4055
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4056
|
+
renderPill(isCopied ? textKey("Copied") : textKey("Copy"), isCopied ? "check" : "duplicate", onCopy, "writing-draft-copy"),
|
|
4057
|
+
renderPill(textKey("Edit"), "edit", onStartEditing, "writing-draft-edit"),
|
|
4058
|
+
canOpenInMail ? renderPill(textKey("Open in mail"), "mail", onOpenInMail, "writing-draft-open-in-mail") : null,
|
|
4059
|
+
isEdited ? renderPill(textKey("Discard changes"), "refresh", onReset, "writing-draft-reset") : null
|
|
4060
|
+
] }) }) })
|
|
4061
|
+
] });
|
|
4062
|
+
};
|
|
4063
|
+
const notice = "agents_notice_rNGvXf";
|
|
4064
|
+
const styles$6 = {
|
|
4065
|
+
notice
|
|
4066
|
+
};
|
|
4067
|
+
const COPIED_CONFIRMATION_MS = 2e3;
|
|
4068
|
+
const readDraftValues = (writingDraftPayload) => ({
|
|
4069
|
+
recipient: writingDraftPayload.recipient ?? "",
|
|
4070
|
+
subject: writingDraftPayload.subject ?? "",
|
|
4071
|
+
body: writingDraftPayload.body
|
|
4072
|
+
});
|
|
4073
|
+
const areDraftValuesEqual = (firstValues, secondValues) => firstValues.recipient === secondValues.recipient && firstValues.subject === secondValues.subject && firstValues.body === secondValues.body;
|
|
4074
|
+
const openMailLink = (href) => {
|
|
4075
|
+
window.location.assign(href);
|
|
4076
|
+
};
|
|
4077
|
+
const WritingDraftEditor = (props) => {
|
|
4078
|
+
const { writingDraftPayload } = props;
|
|
4079
|
+
const originalValues = useMemo(() => readDraftValues(writingDraftPayload), [writingDraftPayload]);
|
|
4080
|
+
const [values, setValues] = useState(originalValues);
|
|
4081
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
4082
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
4083
|
+
useEffect(() => {
|
|
4084
|
+
if (!isCopied) return;
|
|
4085
|
+
const confirmationTimer = setTimeout(() => setIsCopied(false), COPIED_CONFIRMATION_MS);
|
|
4086
|
+
return () => clearTimeout(confirmationTimer);
|
|
4087
|
+
}, [isCopied]);
|
|
4088
|
+
const plainTextBody = useMemo(() => convertDraftMarkdownToPlainText(values.body), [values.body]);
|
|
4089
|
+
const isEmailDraft = writingDraftPayload.kind === "email";
|
|
4090
|
+
const draftMailLink = useMemo(
|
|
4091
|
+
() => isEmailDraft ? buildDraftMailLink(values.recipient, values.subject, plainTextBody) : void 0,
|
|
4092
|
+
[isEmailDraft, values.recipient, values.subject, plainTextBody]
|
|
4093
|
+
);
|
|
4094
|
+
const changeField = (field2, value) => setValues((previousValues) => ({ ...previousValues, [field2]: value }));
|
|
4095
|
+
const copyDraft = () => {
|
|
4096
|
+
void navigator.clipboard?.writeText(plainTextBody).then(() => setIsCopied(true)).catch(() => void 0);
|
|
4097
|
+
};
|
|
4098
|
+
const resetDraft = () => {
|
|
4099
|
+
setValues(originalValues);
|
|
4100
|
+
setIsEditing(false);
|
|
4101
|
+
};
|
|
4102
|
+
return /* @__PURE__ */ jsx(
|
|
4103
|
+
WritingDraftWidget,
|
|
4104
|
+
{
|
|
4105
|
+
kind: writingDraftPayload.kind,
|
|
4106
|
+
title: writingDraftPayload.title,
|
|
4107
|
+
values,
|
|
4108
|
+
showsAddressFields: isEmailDraft || writingDraftPayload.kind === "letter",
|
|
4109
|
+
isEditing,
|
|
4110
|
+
isEdited: !areDraftValuesEqual(values, originalValues),
|
|
4111
|
+
characterCount: writingDraftPayload.kind === "post" ? plainTextBody.length : void 0,
|
|
4112
|
+
isCopied,
|
|
4113
|
+
canOpenInMail: draftMailLink !== void 0,
|
|
4114
|
+
mailLinkOmitsBody: draftMailLink !== void 0 && plainTextBody !== "" && !draftMailLink.includesBody,
|
|
4115
|
+
onChangeField: changeField,
|
|
4116
|
+
onStartEditing: () => setIsEditing(true),
|
|
4117
|
+
onFinishEditing: () => setIsEditing(false),
|
|
4118
|
+
onReset: resetDraft,
|
|
4119
|
+
onCopy: copyDraft,
|
|
4120
|
+
onOpenInMail: () => draftMailLink && openMailLink(draftMailLink.href)
|
|
4121
|
+
}
|
|
4122
|
+
);
|
|
4123
|
+
};
|
|
4124
|
+
const WritingDraftConversationWidget = (props) => {
|
|
4125
|
+
const { payload } = props;
|
|
4126
|
+
const writingDraftPayload = useMemo(() => parseWritingDraftPayload(payload), [payload]);
|
|
4127
|
+
const hasBody = writingDraftPayload.body.trim() !== "";
|
|
4128
|
+
const isUnreadable = !writingDraftPayload.isValidPayload || writingDraftPayload.isBodyUnreadable;
|
|
4129
|
+
useReportWidgetRenderStatus(
|
|
4130
|
+
isUnreadable ? "failed" : hasBody ? "mounted" : "empty",
|
|
4131
|
+
isUnreadable ? "INVALID_PROP" : hasBody ? void 0 : "NO_DATA",
|
|
4132
|
+
!writingDraftPayload.isValidPayload ? "The WritingDraft payload is not a JSON object." : writingDraftPayload.isBodyUnreadable ? "The WritingDraft `body` is not a text; write the draft as one Markdown string." : hasBody ? void 0 : "The WritingDraft widget carries no text (`body`)."
|
|
4133
|
+
);
|
|
4134
|
+
if (isUnreadable) {
|
|
4135
|
+
return /* @__PURE__ */ jsx(
|
|
4136
|
+
Text,
|
|
4137
|
+
{
|
|
4138
|
+
role: "help",
|
|
4139
|
+
color: "var(--agents-fg-light)",
|
|
4140
|
+
className: styles$6.notice,
|
|
4141
|
+
testId: "writing-draft-widget-error",
|
|
4142
|
+
children: "This draft could not be shown."
|
|
4143
|
+
}
|
|
4144
|
+
);
|
|
4145
|
+
}
|
|
4146
|
+
if (!hasBody) {
|
|
4147
|
+
return /* @__PURE__ */ jsx(
|
|
4148
|
+
Text,
|
|
4149
|
+
{
|
|
4150
|
+
role: "help",
|
|
4151
|
+
color: "var(--agents-fg-light)",
|
|
4152
|
+
className: styles$6.notice,
|
|
4153
|
+
testId: "writing-draft-widget-empty",
|
|
4154
|
+
children: "This draft has no text yet."
|
|
4155
|
+
}
|
|
4156
|
+
);
|
|
4157
|
+
}
|
|
4158
|
+
return /* @__PURE__ */ jsx(WritingDraftEditor, { writingDraftPayload }, payload);
|
|
4159
|
+
};
|
|
4160
|
+
const suggestedActions = "agents_suggestedActions_vxfGKR";
|
|
4161
|
+
const styles$5 = {
|
|
4162
|
+
suggestedActions
|
|
4163
|
+
};
|
|
4164
|
+
function parseOptions(options2) {
|
|
4165
|
+
let parsed;
|
|
4166
|
+
try {
|
|
4167
|
+
parsed = JSON.parse(options2);
|
|
4168
|
+
} catch {
|
|
4169
|
+
console.warn("[SuggestedActions] Failed to parse options JSON:", options2);
|
|
4170
|
+
return null;
|
|
4171
|
+
}
|
|
4172
|
+
if (!Array.isArray(parsed) || !parsed.every(
|
|
4173
|
+
(item) => typeof item === "object" && item !== null && typeof item.displayText === "string" && typeof item.userAction === "string"
|
|
4174
|
+
)) {
|
|
4175
|
+
console.warn("[SuggestedActions] Options must be an array of { displayText, userAction }:", parsed);
|
|
4176
|
+
return null;
|
|
4177
|
+
}
|
|
4178
|
+
return parsed;
|
|
4179
|
+
}
|
|
4180
|
+
const readSuggestedActionsRenderReport = (parsedOptions) => {
|
|
4181
|
+
if (parsedOptions === null)
|
|
4182
|
+
return {
|
|
4183
|
+
status: "failed",
|
|
4184
|
+
code: "INVALID_PROP",
|
|
4185
|
+
detail: "The SuggestedActions options must be a JSON array of { displayText, userAction }."
|
|
4186
|
+
};
|
|
4187
|
+
if (parsedOptions.length === 0)
|
|
4188
|
+
return { status: "empty", code: "NO_DATA", detail: "The SuggestedActions options list is empty." };
|
|
4189
|
+
return { status: "mounted" };
|
|
4190
|
+
};
|
|
4191
|
+
const testId$2 = "suggested-actions-widget";
|
|
4192
|
+
const SuggestedActions = ({ options: options2, interactive = false }) => {
|
|
4193
|
+
const { sendMessageToChat } = useConversationWidgetContext();
|
|
4194
|
+
const isEmailRender = useIsEmailWidgetRender();
|
|
4195
|
+
const parsedOptions = parseOptions(options2);
|
|
4196
|
+
const renderReport = readSuggestedActionsRenderReport(parsedOptions);
|
|
4197
|
+
useReportWidgetRenderStatus(renderReport.status, renderReport.code, renderReport.detail);
|
|
4198
|
+
if (!parsedOptions) {
|
|
4199
|
+
return null;
|
|
4200
|
+
}
|
|
4201
|
+
return /* @__PURE__ */ jsx("div", { className: styles$5.suggestedActions, "data-testid": testId$2, children: parsedOptions.map(
|
|
4202
|
+
(option2, index) => isEmailRender ? /* @__PURE__ */ jsx(Text, { translate: false, testId: `${testId$2}-option-${option2.userAction}`, children: option2.displayText }, index) : /* @__PURE__ */ jsx(
|
|
4203
|
+
Button,
|
|
4204
|
+
{
|
|
4205
|
+
variant: "muted",
|
|
4206
|
+
disabled: !interactive,
|
|
4207
|
+
onClick: () => sendMessageToChat(option2.userAction),
|
|
4208
|
+
testId: `${testId$2}-option-${option2.userAction}`,
|
|
4209
|
+
children: option2.displayText
|
|
4210
|
+
},
|
|
4211
|
+
index
|
|
4212
|
+
)
|
|
4213
|
+
) });
|
|
4214
|
+
};
|
|
4215
|
+
const toPositiveInteger = (rawValue) => {
|
|
4216
|
+
if (rawValue === void 0 || rawValue === null || rawValue === "") return void 0;
|
|
4217
|
+
const numericValue = typeof rawValue === "number" ? rawValue : Number(rawValue);
|
|
4218
|
+
if (!Number.isFinite(numericValue) || !Number.isInteger(numericValue) || numericValue <= 0) return void 0;
|
|
4219
|
+
return numericValue;
|
|
4220
|
+
};
|
|
4221
|
+
const parseAgentSpaceKeyAttribute = (agentSpaceKeyAttribute) => {
|
|
4222
|
+
if (agentSpaceKeyAttribute === void 0 || agentSpaceKeyAttribute === null || agentSpaceKeyAttribute === "") {
|
|
4223
|
+
return void 0;
|
|
4224
|
+
}
|
|
4225
|
+
const agentSpaceKey = toPositiveInteger(agentSpaceKeyAttribute);
|
|
4226
|
+
if (agentSpaceKey === void 0) {
|
|
4227
|
+
console.warn(`[agent-space] invalid agent space key on a widget block: ${String(agentSpaceKeyAttribute)}`);
|
|
4228
|
+
}
|
|
4229
|
+
return agentSpaceKey;
|
|
4230
|
+
};
|
|
4231
|
+
const useResolvedConversationWidgetAgentSpaceKey = (agentSpaceKeyAttribute) => {
|
|
4232
|
+
const activeAgentSpaceKey = toPositiveInteger(useAgentsActiveAgentSpaceKey());
|
|
4233
|
+
const namedAgentSpaceKey = parseAgentSpaceKeyAttribute(agentSpaceKeyAttribute);
|
|
4234
|
+
if (namedAgentSpaceKey === void 0 || namedAgentSpaceKey === activeAgentSpaceKey) {
|
|
4235
|
+
return { anotherAgentSpaceKey: void 0, activeAgentSpaceKey, isAnotherAgentSpace: false };
|
|
4236
|
+
}
|
|
4237
|
+
return { anotherAgentSpaceKey: namedAgentSpaceKey, activeAgentSpaceKey, isAnotherAgentSpace: true };
|
|
4238
|
+
};
|
|
4239
|
+
const wide = "agents_wide_xXPJmV";
|
|
4240
|
+
const layout = {
|
|
4241
|
+
wide
|
|
4242
|
+
};
|
|
4243
|
+
const frame = "agents_frame_Yrq5nt";
|
|
4244
|
+
const styles$4 = {
|
|
4245
|
+
frame
|
|
4246
|
+
};
|
|
4247
|
+
const ConversationWidgetAgentSpaceFrame = (props) => {
|
|
4248
|
+
const { anotherAgentSpaceKey, wide: wide2 = false, className, children } = props;
|
|
4249
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames(styles$4.frame, wide2 && layout.wide, className), children: [
|
|
4250
|
+
anotherAgentSpaceKey !== void 0 && /* @__PURE__ */ jsx(ConversationWidgetAgentSpaceHeader, { agentSpaceKey: anotherAgentSpaceKey }),
|
|
4251
|
+
children
|
|
4252
|
+
] });
|
|
4253
|
+
};
|
|
4254
|
+
const wrap$1 = "agents_wrap_erX0TL";
|
|
4255
|
+
const heading = "agents_heading_emSuXb";
|
|
4256
|
+
const options = "agents_options_vv0KNw";
|
|
4257
|
+
const option = "agents_option_7K-k7-";
|
|
4258
|
+
const optionSelected = "agents_optionSelected_w90OVm";
|
|
4259
|
+
const optionControl = "agents_optionControl_kx-eCD";
|
|
4260
|
+
const optionBody = "agents_optionBody_-IWQoq";
|
|
4261
|
+
const optionLabel = "agents_optionLabel_p4dbah";
|
|
4262
|
+
const optionLabelSelected = "agents_optionLabelSelected_kS62Dg";
|
|
4263
|
+
const footer = "agents_footer_HVn5KW";
|
|
4264
|
+
const styles$3 = {
|
|
4265
|
+
wrap: wrap$1,
|
|
4266
|
+
heading,
|
|
4267
|
+
options,
|
|
4268
|
+
option,
|
|
4269
|
+
optionSelected,
|
|
4270
|
+
optionControl,
|
|
4271
|
+
optionBody,
|
|
4272
|
+
optionLabel,
|
|
4273
|
+
optionLabelSelected,
|
|
4274
|
+
footer
|
|
4275
|
+
};
|
|
4276
|
+
const parseMultiChoicePayload = (raw) => {
|
|
4277
|
+
try {
|
|
4278
|
+
const parsed = JSON.parse(raw);
|
|
4279
|
+
if (!parsed || !Array.isArray(parsed.options)) return null;
|
|
4280
|
+
return parsed;
|
|
4281
|
+
} catch {
|
|
4282
|
+
return null;
|
|
3517
4283
|
}
|
|
3518
4284
|
};
|
|
3519
4285
|
const toConfirmLabelKey = (template) => template.replace(/\{count\}/g, "%count%");
|
|
@@ -3568,8 +4334,8 @@ const MultiChoiceConversationWidget = (props) => {
|
|
|
3568
4334
|
isAnotherAgentSpace && anotherAgentSpaceKey !== void 0 ? appendAnotherAgentSpaceToOwnerText(action, anotherAgentSpaceKey) : action
|
|
3569
4335
|
);
|
|
3570
4336
|
};
|
|
3571
|
-
return /* @__PURE__ */ jsx(ConversationWidgetAgentSpaceFrame, { anotherAgentSpaceKey: isAnotherAgentSpace ? anotherAgentSpaceKey : void 0, children: /* @__PURE__ */ jsxs("div", { className: styles$
|
|
3572
|
-
(title2 || subtitle) && /* @__PURE__ */ jsxs("div", { className: styles$
|
|
4337
|
+
return /* @__PURE__ */ jsx(ConversationWidgetAgentSpaceFrame, { anotherAgentSpaceKey: isAnotherAgentSpace ? anotherAgentSpaceKey : void 0, children: /* @__PURE__ */ jsxs("div", { className: styles$3.wrap, "data-testid": testId$1, children: [
|
|
4338
|
+
(title2 || subtitle) && /* @__PURE__ */ jsxs("div", { className: styles$3.heading, "data-testid": `${testId$1}-heading`, children: [
|
|
3573
4339
|
title2 ? /* @__PURE__ */ jsx(
|
|
3574
4340
|
Text,
|
|
3575
4341
|
{
|
|
@@ -3591,17 +4357,17 @@ const MultiChoiceConversationWidget = (props) => {
|
|
|
3591
4357
|
}
|
|
3592
4358
|
) : null
|
|
3593
4359
|
] }),
|
|
3594
|
-
/* @__PURE__ */ jsx("div", { className: styles$
|
|
4360
|
+
/* @__PURE__ */ jsx("div", { className: styles$3.options, "data-testid": `${testId$1}-options`, children: options2.map((option2) => {
|
|
3595
4361
|
const isSelected = selected.has(option2.value);
|
|
3596
4362
|
return /* @__PURE__ */ jsx(
|
|
3597
4363
|
InteractiveSurface,
|
|
3598
4364
|
{
|
|
3599
4365
|
hoverable: true,
|
|
3600
|
-
className: classNames(styles$
|
|
4366
|
+
className: classNames(styles$3.option, isSelected ? styles$3.optionSelected : void 0),
|
|
3601
4367
|
children: /* @__PURE__ */ jsxs(
|
|
3602
4368
|
"div",
|
|
3603
4369
|
{
|
|
3604
|
-
className: styles$
|
|
4370
|
+
className: styles$3.optionControl,
|
|
3605
4371
|
"data-testid": `${testId$1}-option-${option2.value}`,
|
|
3606
4372
|
onClick: isEmailRender ? void 0 : () => toggle(option2.value),
|
|
3607
4373
|
role: isEmailRender ? void 0 : "checkbox",
|
|
@@ -3614,13 +4380,13 @@ const MultiChoiceConversationWidget = (props) => {
|
|
|
3614
4380
|
}
|
|
3615
4381
|
},
|
|
3616
4382
|
children: [
|
|
3617
|
-
/* @__PURE__ */ jsxs("div", { className: styles$
|
|
4383
|
+
/* @__PURE__ */ jsxs("div", { className: styles$3.optionBody, children: [
|
|
3618
4384
|
/* @__PURE__ */ jsx(
|
|
3619
4385
|
Text,
|
|
3620
4386
|
{
|
|
3621
4387
|
role: "body",
|
|
3622
4388
|
weight: "bold",
|
|
3623
|
-
className: isSelected ? styles$
|
|
4389
|
+
className: isSelected ? styles$3.optionLabelSelected : styles$3.optionLabel,
|
|
3624
4390
|
translate: false,
|
|
3625
4391
|
children: escapePlainTextForText(option2.label)
|
|
3626
4392
|
}
|
|
@@ -3628,519 +4394,245 @@ const MultiChoiceConversationWidget = (props) => {
|
|
|
3628
4394
|
option2.sublabel ? /* @__PURE__ */ jsx(Text, { role: "caption", color: "var(--agents-fg-light)", translate: false, children: escapePlainTextForText(option2.sublabel) }) : null
|
|
3629
4395
|
] }),
|
|
3630
4396
|
!isEmailRender && /* @__PURE__ */ jsx(
|
|
3631
|
-
Checkbox,
|
|
3632
|
-
{
|
|
3633
|
-
checked: isSelected,
|
|
3634
|
-
disabled: confirmed,
|
|
3635
|
-
onChange: () => toggle(option2.value),
|
|
3636
|
-
testId: `${testId$1}-option-${option2.value}-checkbox`
|
|
3637
|
-
}
|
|
3638
|
-
)
|
|
3639
|
-
]
|
|
3640
|
-
}
|
|
3641
|
-
)
|
|
3642
|
-
},
|
|
3643
|
-
option2.value
|
|
3644
|
-
);
|
|
3645
|
-
}) }),
|
|
3646
|
-
!isEmailRender && /* @__PURE__ */ jsxs("div", { className: styles$
|
|
3647
|
-
/* @__PURE__ */ jsx(
|
|
3648
|
-
Button,
|
|
3649
|
-
{
|
|
3650
|
-
variant: "muted",
|
|
3651
|
-
onClick: handleSelectAll,
|
|
3652
|
-
disabled: confirmed,
|
|
3653
|
-
testId: `${testId$1}-select-all`,
|
|
3654
|
-
children: allSelected ? "Clear all" : selectAllLabel
|
|
3655
|
-
}
|
|
3656
|
-
),
|
|
3657
|
-
/* @__PURE__ */ jsx(
|
|
3658
|
-
Button,
|
|
3659
|
-
{
|
|
3660
|
-
size: "extraLarge",
|
|
3661
|
-
variant: "shimmer",
|
|
3662
|
-
onClick: handleConfirm,
|
|
3663
|
-
disabled: confirmed || selected.size === 0,
|
|
3664
|
-
translate: false,
|
|
3665
|
-
testId: `${testId$1}-confirm`,
|
|
3666
|
-
// Nothing picked yet: "Confirm 0 selection" read as a defect — the disabled button says what it does.
|
|
3667
|
-
children: selected.size === 0 && data.confirmLabelTemplate === void 0 ? translateText("Confirm selection") : translateText(
|
|
3668
|
-
confirmLabelKey,
|
|
3669
|
-
{ count: selected.size },
|
|
3670
|
-
selected.size === 1 ? "one" : "other"
|
|
3671
|
-
)
|
|
3672
|
-
}
|
|
3673
|
-
)
|
|
3674
|
-
] })
|
|
3675
|
-
] }) });
|
|
3676
|
-
};
|
|
3677
|
-
const useStackWhenWrapped = (items) => {
|
|
3678
|
-
const [row2, setRow] = useState(null);
|
|
3679
|
-
useLayoutEffect(() => {
|
|
3680
|
-
if (!row2) return;
|
|
3681
|
-
let width = -1;
|
|
3682
|
-
const measure = () => {
|
|
3683
|
-
if (row2.clientWidth === width) return;
|
|
3684
|
-
width = row2.clientWidth;
|
|
3685
|
-
delete row2.dataset.stacked;
|
|
3686
|
-
const buttons = Array.from(row2.children);
|
|
3687
|
-
if (buttons.some((button) => button.offsetTop !== buttons[0].offsetTop)) row2.dataset.stacked = "";
|
|
3688
|
-
};
|
|
3689
|
-
measure();
|
|
3690
|
-
const observer = new ResizeObserver(measure);
|
|
3691
|
-
observer.observe(row2);
|
|
3692
|
-
return () => observer.disconnect();
|
|
3693
|
-
}, [row2, items]);
|
|
3694
|
-
return setRow;
|
|
3695
|
-
};
|
|
3696
|
-
const QUICK_REPLIES_MIN_OPTIONS = 2;
|
|
3697
|
-
const QUICK_REPLIES_MAX_OPTIONS = 5;
|
|
3698
|
-
const QUICK_REPLIES_MAX_DISPLAY_LENGTH = 60;
|
|
3699
|
-
const parseQuickRepliesPayload = (raw) => {
|
|
3700
|
-
let parsed;
|
|
3701
|
-
try {
|
|
3702
|
-
parsed = JSON.parse(raw);
|
|
3703
|
-
} catch {
|
|
3704
|
-
return null;
|
|
3705
|
-
}
|
|
3706
|
-
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.options)) {
|
|
3707
|
-
return null;
|
|
3708
|
-
}
|
|
3709
|
-
const rawOptions = parsed.options;
|
|
3710
|
-
if (!rawOptions.every((option2) => typeof option2 === "string")) return null;
|
|
3711
|
-
const trimmedOptions = rawOptions.map((option2) => option2.trim());
|
|
3712
|
-
if (trimmedOptions.some((option2) => option2.length === 0)) return null;
|
|
3713
|
-
if (trimmedOptions.length < QUICK_REPLIES_MIN_OPTIONS || trimmedOptions.length > QUICK_REPLIES_MAX_OPTIONS) {
|
|
3714
|
-
return null;
|
|
3715
|
-
}
|
|
3716
|
-
const seenCaseInsensitive = /* @__PURE__ */ new Set();
|
|
3717
|
-
for (const option2 of trimmedOptions) {
|
|
3718
|
-
const key = option2.toLowerCase();
|
|
3719
|
-
if (seenCaseInsensitive.has(key)) return null;
|
|
3720
|
-
seenCaseInsensitive.add(key);
|
|
3721
|
-
}
|
|
3722
|
-
return { options: trimmedOptions };
|
|
3723
|
-
};
|
|
3724
|
-
const truncateQuickReplyLabel = (option2) => option2.length > QUICK_REPLIES_MAX_DISPLAY_LENGTH ? `${option2.slice(0, QUICK_REPLIES_MAX_DISPLAY_LENGTH - 1)}…` : option2;
|
|
3725
|
-
const wrap = "agents_wrap_oKRGZs";
|
|
3726
|
-
const pill = "agents_pill_-9LUkm";
|
|
3727
|
-
const pillChosen = "agents_pillChosen_os6Ke3";
|
|
3728
|
-
const pillLabel = "agents_pillLabel_mhrrx9";
|
|
3729
|
-
const styles$3 = {
|
|
3730
|
-
wrap,
|
|
3731
|
-
pill,
|
|
3732
|
-
pillChosen,
|
|
3733
|
-
pillLabel
|
|
3734
|
-
};
|
|
3735
|
-
const testId = "quick-replies-widget";
|
|
3736
|
-
const PLACEHOLDER_MARKER_PATTERN = /\[\s*(?:\.\.\.|…)\s*]|_{3,}|\.\.\.|…/;
|
|
3737
|
-
const isQuickReplyPlaceholderOption = (option2) => {
|
|
3738
|
-
const trimmed = option2.trim();
|
|
3739
|
-
return PLACEHOLDER_MARKER_PATTERN.test(trimmed) || trimmed.endsWith(":");
|
|
3740
|
-
};
|
|
3741
|
-
const stripQuickReplyPlaceholderMarker = (option2) => {
|
|
3742
|
-
const stripped = option2.trim().replace(new RegExp(PLACEHOLDER_MARKER_PATTERN.source, "g"), "").trimEnd();
|
|
3743
|
-
return `${stripped} `;
|
|
3744
|
-
};
|
|
3745
|
-
const QuickRepliesConversationWidget = (props) => {
|
|
3746
|
-
const { payload, interactive = false, messageId } = props;
|
|
3747
|
-
const { sendMessageToChat, prefillComposer, messages } = useConversationWidgetContext();
|
|
3748
|
-
const isEmailRender = useIsEmailWidgetRender();
|
|
3749
|
-
const { anotherAgentSpaceKey, isAnotherAgentSpace } = useResolvedConversationWidgetAgentSpaceKey(
|
|
3750
|
-
readWidgetAgentSpaceKeyAttribute(props)
|
|
3751
|
-
);
|
|
3752
|
-
const data = useMemo(() => parseQuickRepliesPayload(payload), [payload]);
|
|
3753
|
-
const rowRef = useStackWhenWrapped(data?.options);
|
|
3754
|
-
const [chosenOption, setChosenOption] = useState(null);
|
|
3755
|
-
const [locked, setLocked] = useState(false);
|
|
3756
|
-
const [pending, setPending] = useState(false);
|
|
3757
|
-
const pendingRef = useRef(false);
|
|
3758
|
-
const isStale = useMemo(() => {
|
|
3759
|
-
if (!messages || messageId === void 0) return false;
|
|
3760
|
-
const hostIndex = messages.findIndex((message) => String(message.id) === String(messageId));
|
|
3761
|
-
if (hostIndex === -1) return false;
|
|
3762
|
-
return messages.slice(hostIndex + 1).some((message) => message.role === "USER");
|
|
3763
|
-
}, [messages, messageId]);
|
|
3764
|
-
const isUnreadable = data === null;
|
|
3765
|
-
useReportWidgetRenderStatus(
|
|
3766
|
-
isUnreadable ? "failed" : "mounted",
|
|
3767
|
-
isUnreadable ? "INVALID_PROP" : void 0,
|
|
3768
|
-
isUnreadable ? "The QuickReplies options must be 2 to 5 distinct non-empty strings; the widget was dropped." : void 0
|
|
3769
|
-
);
|
|
3770
|
-
if (!data) return null;
|
|
3771
|
-
const inert = !interactive || isStale;
|
|
3772
|
-
const disabled = inert || locked || pending;
|
|
3773
|
-
const handleClick = async (option2) => {
|
|
3774
|
-
if (disabled || pendingRef.current) return;
|
|
3775
|
-
if (isQuickReplyPlaceholderOption(option2)) {
|
|
3776
|
-
prefillComposer(stripQuickReplyPlaceholderMarker(option2));
|
|
3777
|
-
return;
|
|
3778
|
-
}
|
|
3779
|
-
pendingRef.current = true;
|
|
3780
|
-
setPending(true);
|
|
3781
|
-
setChosenOption(option2);
|
|
3782
|
-
try {
|
|
3783
|
-
const outgoing = isAnotherAgentSpace && anotherAgentSpaceKey !== void 0 ? appendAnotherAgentSpaceToOwnerText(option2, anotherAgentSpaceKey) : option2;
|
|
3784
|
-
const result2 = await sendMessageToChat(outgoing);
|
|
3785
|
-
if (result2 === false) {
|
|
3786
|
-
setChosenOption(null);
|
|
3787
|
-
} else {
|
|
3788
|
-
setLocked(true);
|
|
3789
|
-
}
|
|
3790
|
-
} catch {
|
|
3791
|
-
setChosenOption(null);
|
|
3792
|
-
} finally {
|
|
3793
|
-
pendingRef.current = false;
|
|
3794
|
-
setPending(false);
|
|
3795
|
-
}
|
|
3796
|
-
};
|
|
3797
|
-
return /* @__PURE__ */ jsx(ConversationWidgetAgentSpaceFrame, { anotherAgentSpaceKey: isAnotherAgentSpace ? anotherAgentSpaceKey : void 0, children: /* @__PURE__ */ jsx("div", { "aria-live": "polite", "data-testid": testId, children: locked && chosenOption !== null ? /* @__PURE__ */ jsx(DonePill, { translate: false, testId: `${testId}-done`, children: truncateQuickReplyLabel(chosenOption) }) : /* @__PURE__ */ jsx("div", { ref: rowRef, className: styles$3.wrap, role: "group", "data-testid": `${testId}-options`, children: data.options.map((option2) => {
|
|
3798
|
-
if (isEmailRender)
|
|
3799
|
-
return /* @__PURE__ */ jsx(Text, { role: "help", translate: false, testId: `${testId}-option-${option2}`, children: option2 }, option2);
|
|
3800
|
-
const isChosen = chosenOption === option2;
|
|
3801
|
-
return /* @__PURE__ */ jsx(
|
|
3802
|
-
"button",
|
|
3803
|
-
{
|
|
3804
|
-
type: "button",
|
|
3805
|
-
className: classNames(styles$3.pill, isChosen && styles$3.pillChosen),
|
|
3806
|
-
disabled,
|
|
3807
|
-
onClick: () => handleClick(option2),
|
|
3808
|
-
"data-testid": `${testId}-option-${option2}`,
|
|
3809
|
-
children: /* @__PURE__ */ jsx(Text, { role: "help", translate: false, className: styles$3.pillLabel, children: truncateQuickReplyLabel(option2) })
|
|
3810
|
-
},
|
|
3811
|
-
option2
|
|
3812
|
-
);
|
|
3813
|
-
}) }) }) });
|
|
4397
|
+
Checkbox,
|
|
4398
|
+
{
|
|
4399
|
+
checked: isSelected,
|
|
4400
|
+
disabled: confirmed,
|
|
4401
|
+
onChange: () => toggle(option2.value),
|
|
4402
|
+
testId: `${testId$1}-option-${option2.value}-checkbox`
|
|
4403
|
+
}
|
|
4404
|
+
)
|
|
4405
|
+
]
|
|
4406
|
+
}
|
|
4407
|
+
)
|
|
4408
|
+
},
|
|
4409
|
+
option2.value
|
|
4410
|
+
);
|
|
4411
|
+
}) }),
|
|
4412
|
+
!isEmailRender && /* @__PURE__ */ jsxs("div", { className: styles$3.footer, children: [
|
|
4413
|
+
/* @__PURE__ */ jsx(
|
|
4414
|
+
Button,
|
|
4415
|
+
{
|
|
4416
|
+
variant: "muted",
|
|
4417
|
+
onClick: handleSelectAll,
|
|
4418
|
+
disabled: confirmed,
|
|
4419
|
+
testId: `${testId$1}-select-all`,
|
|
4420
|
+
children: allSelected ? "Clear all" : selectAllLabel
|
|
4421
|
+
}
|
|
4422
|
+
),
|
|
4423
|
+
/* @__PURE__ */ jsx(
|
|
4424
|
+
Button,
|
|
4425
|
+
{
|
|
4426
|
+
size: "extraLarge",
|
|
4427
|
+
variant: "shimmer",
|
|
4428
|
+
onClick: handleConfirm,
|
|
4429
|
+
disabled: confirmed || selected.size === 0,
|
|
4430
|
+
translate: false,
|
|
4431
|
+
testId: `${testId$1}-confirm`,
|
|
4432
|
+
// Nothing picked yet: "Confirm 0 selection" read as a defect — the disabled button says what it does.
|
|
4433
|
+
children: selected.size === 0 && data.confirmLabelTemplate === void 0 ? translateText("Confirm selection") : translateText(
|
|
4434
|
+
confirmLabelKey,
|
|
4435
|
+
{ count: selected.size },
|
|
4436
|
+
selected.size === 1 ? "one" : "other"
|
|
4437
|
+
)
|
|
4438
|
+
}
|
|
4439
|
+
)
|
|
4440
|
+
] })
|
|
4441
|
+
] }) });
|
|
3814
4442
|
};
|
|
3815
|
-
const
|
|
3816
|
-
const
|
|
4443
|
+
const useStackWhenWrapped = (items) => {
|
|
4444
|
+
const [row2, setRow] = useState(null);
|
|
4445
|
+
useLayoutEffect(() => {
|
|
4446
|
+
if (!row2) return;
|
|
4447
|
+
let width = -1;
|
|
4448
|
+
const measure = () => {
|
|
4449
|
+
if (row2.clientWidth === width) return;
|
|
4450
|
+
width = row2.clientWidth;
|
|
4451
|
+
delete row2.dataset.stacked;
|
|
4452
|
+
const buttons = Array.from(row2.children);
|
|
4453
|
+
if (buttons.some((button) => button.offsetTop !== buttons[0].offsetTop)) row2.dataset.stacked = "";
|
|
4454
|
+
};
|
|
4455
|
+
measure();
|
|
4456
|
+
const observer = new ResizeObserver(measure);
|
|
4457
|
+
observer.observe(row2);
|
|
4458
|
+
return () => observer.disconnect();
|
|
4459
|
+
}, [row2, items]);
|
|
4460
|
+
return setRow;
|
|
4461
|
+
};
|
|
4462
|
+
const QUICK_REPLIES_MIN_OPTIONS = 2;
|
|
4463
|
+
const QUICK_REPLIES_MAX_OPTIONS = 5;
|
|
4464
|
+
const QUICK_REPLIES_MAX_DISPLAY_LENGTH = 60;
|
|
4465
|
+
const parseQuickRepliesPayload = (raw) => {
|
|
4466
|
+
let parsed;
|
|
3817
4467
|
try {
|
|
3818
|
-
|
|
3819
|
-
return isRecord(parsed) ? parsed : null;
|
|
4468
|
+
parsed = JSON.parse(raw);
|
|
3820
4469
|
} catch {
|
|
3821
4470
|
return null;
|
|
3822
4471
|
}
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
const lastSegment = key.split(".").pop() ?? key;
|
|
3826
|
-
return lastSegment.toLowerCase().replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
3827
|
-
};
|
|
3828
|
-
const resolveLabel = (payload) => {
|
|
3829
|
-
if (payload.name === "Navigate" && isRecord(payload.input)) {
|
|
3830
|
-
const destination = payload.input.destination;
|
|
3831
|
-
if (typeof destination === "string" && destination.length > 0) {
|
|
3832
|
-
return humanizeNavKey(destination);
|
|
3833
|
-
}
|
|
3834
|
-
}
|
|
3835
|
-
const toolName = typeof payload.name === "string" ? payload.name : "Tool";
|
|
3836
|
-
return toolName;
|
|
3837
|
-
};
|
|
3838
|
-
const ToolTraceConversationWidget = (props) => {
|
|
3839
|
-
const { payload } = props;
|
|
3840
|
-
const label2 = useMemo(() => {
|
|
3841
|
-
const parsed = parsePayload(payload);
|
|
3842
|
-
if (!parsed) return null;
|
|
3843
|
-
return resolveLabel(parsed);
|
|
3844
|
-
}, [payload]);
|
|
3845
|
-
useReportWidgetRenderStatus(
|
|
3846
|
-
label2 ? "mounted" : "failed",
|
|
3847
|
-
label2 ? void 0 : "INVALID_PROP",
|
|
3848
|
-
label2 ? void 0 : "The ToolTrace payload is not a JSON object."
|
|
3849
|
-
);
|
|
3850
|
-
if (!label2) return null;
|
|
3851
|
-
return /* @__PURE__ */ jsxs(
|
|
3852
|
-
"span",
|
|
3853
|
-
{
|
|
3854
|
-
"data-testid": "tool-trace-widget",
|
|
3855
|
-
style: {
|
|
3856
|
-
display: "inline-flex",
|
|
3857
|
-
alignItems: "center",
|
|
3858
|
-
gap: "4px",
|
|
3859
|
-
fontSize: "12px",
|
|
3860
|
-
color: "var(--agents-text-subtle, #8a8a8a)",
|
|
3861
|
-
fontStyle: "italic"
|
|
3862
|
-
},
|
|
3863
|
-
children: [
|
|
3864
|
-
/* @__PURE__ */ jsx(Icon, { name: "arrowRight" }),
|
|
3865
|
-
/* @__PURE__ */ jsx(Text, { replacements: { label: label2 }, testId: "tool-trace-widget-label", children: "Opened %label%" })
|
|
3866
|
-
]
|
|
3867
|
-
}
|
|
3868
|
-
);
|
|
3869
|
-
};
|
|
3870
|
-
const CANVAS_VIABLE_MIN_WIDTH = 850;
|
|
3871
|
-
const isViewportViable = () => typeof window === "undefined" || window.innerWidth >= CANVAS_VIABLE_MIN_WIDTH;
|
|
3872
|
-
class ElementWidthCanvasViability {
|
|
3873
|
-
constructor(minWidth = CANVAS_VIABLE_MIN_WIDTH) {
|
|
3874
|
-
this.minWidth = minWidth;
|
|
3875
|
-
this.elementWidth = null;
|
|
3876
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
3877
|
-
this.resizeObserver = null;
|
|
3878
|
-
this.observedElement = null;
|
|
3879
|
-
this.isViable = () => this.elementWidth !== null && this.elementWidth > 0 ? this.elementWidth >= this.minWidth : isViewportViable();
|
|
3880
|
-
this.subscribe = (listener) => {
|
|
3881
|
-
this.listeners.add(listener);
|
|
3882
|
-
return () => {
|
|
3883
|
-
this.listeners.delete(listener);
|
|
3884
|
-
};
|
|
3885
|
-
};
|
|
3886
|
-
this.observe = (element) => {
|
|
3887
|
-
if (element === this.observedElement) return;
|
|
3888
|
-
this.resizeObserver?.disconnect();
|
|
3889
|
-
this.resizeObserver = null;
|
|
3890
|
-
this.observedElement = element;
|
|
3891
|
-
if (element === null) {
|
|
3892
|
-
this.receiveWidth(null);
|
|
3893
|
-
return;
|
|
3894
|
-
}
|
|
3895
|
-
this.receiveWidth(element.getBoundingClientRect().width);
|
|
3896
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
3897
|
-
this.resizeObserver = new ResizeObserver((entries) => {
|
|
3898
|
-
const entry = entries[entries.length - 1];
|
|
3899
|
-
if (entry) this.receiveWidth(entry.contentRect.width);
|
|
3900
|
-
});
|
|
3901
|
-
this.resizeObserver.observe(element);
|
|
3902
|
-
};
|
|
3903
|
-
this.receiveViewportResize = () => {
|
|
3904
|
-
this.notifyWhenFlipped();
|
|
3905
|
-
};
|
|
3906
|
-
this.viable = this.isViable();
|
|
4472
|
+
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.options)) {
|
|
4473
|
+
return null;
|
|
3907
4474
|
}
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
4475
|
+
const rawOptions = parsed.options;
|
|
4476
|
+
if (!rawOptions.every((option2) => typeof option2 === "string")) return null;
|
|
4477
|
+
const trimmedOptions = rawOptions.map((option2) => option2.trim());
|
|
4478
|
+
if (trimmedOptions.some((option2) => option2.length === 0)) return null;
|
|
4479
|
+
if (trimmedOptions.length < QUICK_REPLIES_MIN_OPTIONS || trimmedOptions.length > QUICK_REPLIES_MAX_OPTIONS) {
|
|
4480
|
+
return null;
|
|
3911
4481
|
}
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
4482
|
+
const seenCaseInsensitive = /* @__PURE__ */ new Set();
|
|
4483
|
+
for (const option2 of trimmedOptions) {
|
|
4484
|
+
const key = option2.toLowerCase();
|
|
4485
|
+
if (seenCaseInsensitive.has(key)) return null;
|
|
4486
|
+
seenCaseInsensitive.add(key);
|
|
3917
4487
|
}
|
|
3918
|
-
}
|
|
3919
|
-
const CanvasViabilityContext = createContext(null);
|
|
3920
|
-
const readCanvasViable = (source) => source ? source.isViable() : isViewportViable();
|
|
3921
|
-
const subscribeToNothing = () => () => void 0;
|
|
3922
|
-
const useCanvasViable = () => {
|
|
3923
|
-
const source = useContext(CanvasViabilityContext);
|
|
3924
|
-
const sourceViable = useSyncExternalStore(
|
|
3925
|
-
source ? source.subscribe : subscribeToNothing,
|
|
3926
|
-
source ? source.isViable : isViewportViable,
|
|
3927
|
-
source ? source.isViable : isViewportViable
|
|
3928
|
-
);
|
|
3929
|
-
const [viewportViable, setViewportViable] = useState(isViewportViable);
|
|
3930
|
-
useEffect(() => {
|
|
3931
|
-
const onResize = () => {
|
|
3932
|
-
if (source instanceof ElementWidthCanvasViability) source.receiveViewportResize();
|
|
3933
|
-
setViewportViable((previous) => {
|
|
3934
|
-
const next = isViewportViable();
|
|
3935
|
-
return next === previous ? previous : next;
|
|
3936
|
-
});
|
|
3937
|
-
};
|
|
3938
|
-
window.addEventListener("resize", onResize);
|
|
3939
|
-
onResize();
|
|
3940
|
-
return () => window.removeEventListener("resize", onResize);
|
|
3941
|
-
}, [source]);
|
|
3942
|
-
return source ? sourceViable : viewportViable;
|
|
4488
|
+
return { options: trimmedOptions };
|
|
3943
4489
|
};
|
|
3944
|
-
const
|
|
3945
|
-
const
|
|
3946
|
-
const
|
|
3947
|
-
const
|
|
3948
|
-
const
|
|
3949
|
-
const cardButton = "agents_cardButton_UYBiR-";
|
|
3950
|
-
const body = "agents_body_TW-9Nf";
|
|
3951
|
-
const cardOfAnotherBusiness = "agents_cardOfAnotherBusiness_AJijSp";
|
|
3952
|
-
const richCardSurface = "agents_richCardSurface_Tp7fVx";
|
|
3953
|
-
const richCardButton = "agents_richCardButton_Xql1T3";
|
|
3954
|
-
const thumbnail = "agents_thumbnail_9eN6G1";
|
|
3955
|
-
const mobile = "agents_mobile_Jmo-Gy";
|
|
4490
|
+
const truncateQuickReplyLabel = (option2) => option2.length > QUICK_REPLIES_MAX_DISPLAY_LENGTH ? `${option2.slice(0, QUICK_REPLIES_MAX_DISPLAY_LENGTH - 1)}…` : option2;
|
|
4491
|
+
const wrap = "agents_wrap_oKRGZs";
|
|
4492
|
+
const pill = "agents_pill_-9LUkm";
|
|
4493
|
+
const pillChosen = "agents_pillChosen_os6Ke3";
|
|
4494
|
+
const pillLabel = "agents_pillLabel_mhrrx9";
|
|
3956
4495
|
const styles$2 = {
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
subtitle,
|
|
3976
|
-
subtitleReplacements,
|
|
3977
|
-
translateSubtitle = true,
|
|
3978
|
-
icon,
|
|
3979
|
-
leading,
|
|
3980
|
-
thumbnail: thumbnail2,
|
|
3981
|
-
justDelivered = false,
|
|
3982
|
-
canvas,
|
|
3983
|
-
anotherAgentSpaceKey,
|
|
3984
|
-
preview,
|
|
3985
|
-
testId: testId2
|
|
3986
|
-
}) => {
|
|
3987
|
-
const { openCanvas, canvas: openCanvasState } = useConversationWidgetContext();
|
|
3988
|
-
const canvasViable = useCanvasViable();
|
|
3989
|
-
const openedRef = useRef(false);
|
|
3990
|
-
const capture = useWidgetImageRender();
|
|
4496
|
+
wrap,
|
|
4497
|
+
pill,
|
|
4498
|
+
pillChosen,
|
|
4499
|
+
pillLabel
|
|
4500
|
+
};
|
|
4501
|
+
const testId = "quick-replies-widget";
|
|
4502
|
+
const PLACEHOLDER_MARKER_PATTERN = /\[\s*(?:\.\.\.|…)\s*]|_{3,}|\.\.\.|…/;
|
|
4503
|
+
const isQuickReplyPlaceholderOption = (option2) => {
|
|
4504
|
+
const trimmed = option2.trim();
|
|
4505
|
+
return PLACEHOLDER_MARKER_PATTERN.test(trimmed) || trimmed.endsWith(":");
|
|
4506
|
+
};
|
|
4507
|
+
const stripQuickReplyPlaceholderMarker = (option2) => {
|
|
4508
|
+
const stripped = option2.trim().replace(new RegExp(PLACEHOLDER_MARKER_PATTERN.source, "g"), "").trimEnd();
|
|
4509
|
+
return `${stripped} `;
|
|
4510
|
+
};
|
|
4511
|
+
const QuickRepliesConversationWidget = (props) => {
|
|
4512
|
+
const { payload, interactive = false, messageId } = props;
|
|
4513
|
+
const { sendMessageToChat, prefillComposer, messages } = useConversationWidgetContext();
|
|
3991
4514
|
const isEmailRender = useIsEmailWidgetRender();
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
openedRef.current = true;
|
|
3995
|
-
openCanvas({ ...canvas, origin: "deliveredInMessage", justDelivered: true });
|
|
3996
|
-
}, [justDelivered, canvas?.instanceId]);
|
|
3997
|
-
const open = () => {
|
|
3998
|
-
if (canvas) openCanvas({ ...canvas, origin: "widgetClick", justDelivered: false });
|
|
3999
|
-
};
|
|
4000
|
-
const isThisCanvasOpen = canvas !== void 0 && openCanvasState !== null && sameCanvasIdentity(openCanvasState, canvas);
|
|
4001
|
-
const subtitleText = subtitle ? /* @__PURE__ */ jsx(
|
|
4002
|
-
Text,
|
|
4003
|
-
{
|
|
4004
|
-
role: "caption",
|
|
4005
|
-
color: "var(--agents-fg-light)",
|
|
4006
|
-
ellipsis: true,
|
|
4007
|
-
translate: translateSubtitle,
|
|
4008
|
-
replacements: subtitleReplacements,
|
|
4009
|
-
children: subtitle
|
|
4010
|
-
}
|
|
4011
|
-
) : null;
|
|
4012
|
-
const openCanvasTestId = testId2 ? `${testId2}-open-canvas` : void 0;
|
|
4013
|
-
const cardTestId = anotherAgentSpaceKey === void 0 ? testId2 : void 0;
|
|
4014
|
-
const renderCard = (cardContent, isRich = false, surfaceTestId) => /* @__PURE__ */ jsx(
|
|
4015
|
-
InteractiveSurface,
|
|
4016
|
-
{
|
|
4017
|
-
hoverable: true,
|
|
4018
|
-
className: classNames(styles$2.cardSurface, isRich && styles$2.richCardSurface),
|
|
4019
|
-
testId: surfaceTestId,
|
|
4020
|
-
children: /* @__PURE__ */ jsx(
|
|
4021
|
-
"button",
|
|
4022
|
-
{
|
|
4023
|
-
type: "button",
|
|
4024
|
-
className: classNames(styles$2.cardButton, isRich && styles$2.richCardButton),
|
|
4025
|
-
onClick: open,
|
|
4026
|
-
"data-testid": openCanvasTestId,
|
|
4027
|
-
children: cardContent
|
|
4028
|
-
}
|
|
4029
|
-
)
|
|
4030
|
-
}
|
|
4515
|
+
const { anotherAgentSpaceKey, isAnotherAgentSpace } = useResolvedConversationWidgetAgentSpaceKey(
|
|
4516
|
+
readWidgetAgentSpaceKeyAttribute(props)
|
|
4031
4517
|
);
|
|
4032
|
-
const
|
|
4033
|
-
const
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
] }),
|
|
4050
|
-
/* @__PURE__ */ jsx(Icon, { className: styles$2.richOpenIcon, name: "arrowRight" })
|
|
4051
|
-
] }),
|
|
4052
|
-
true,
|
|
4053
|
-
cardTestId
|
|
4054
|
-
) : renderCard(
|
|
4055
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4056
|
-
/* @__PURE__ */ jsx("span", { className: styles$2.leadingIconBadge, children: leading ?? /* @__PURE__ */ jsx(Icon, { name: icon ?? DEFAULT_ICON }) }),
|
|
4057
|
-
/* @__PURE__ */ jsxs("div", { className: styles$2.body, children: [
|
|
4058
|
-
/* @__PURE__ */ jsx(
|
|
4059
|
-
Text,
|
|
4060
|
-
{
|
|
4061
|
-
role: "help",
|
|
4062
|
-
weight: "bold",
|
|
4063
|
-
ellipsis: true,
|
|
4064
|
-
translate: translateTitle,
|
|
4065
|
-
replacements: titleReplacements,
|
|
4066
|
-
children: title2
|
|
4067
|
-
}
|
|
4068
|
-
),
|
|
4069
|
-
subtitleText
|
|
4070
|
-
] }),
|
|
4071
|
-
openAffordance2
|
|
4072
|
-
] }),
|
|
4073
|
-
false,
|
|
4074
|
-
cardTestId
|
|
4518
|
+
const data = useMemo(() => parseQuickRepliesPayload(payload), [payload]);
|
|
4519
|
+
const rowRef = useStackWhenWrapped(data?.options);
|
|
4520
|
+
const [chosenOption, setChosenOption] = useState(null);
|
|
4521
|
+
const [locked, setLocked] = useState(false);
|
|
4522
|
+
const [pending, setPending] = useState(false);
|
|
4523
|
+
const pendingRef = useRef(false);
|
|
4524
|
+
const isStale = useMemo(() => {
|
|
4525
|
+
if (!messages || messageId === void 0) return false;
|
|
4526
|
+
const hostIndex = messages.findIndex((message) => String(message.id) === String(messageId));
|
|
4527
|
+
if (hostIndex === -1) return false;
|
|
4528
|
+
return messages.slice(hostIndex + 1).some((message) => message.role === "USER");
|
|
4529
|
+
}, [messages, messageId]);
|
|
4530
|
+
const isUnreadable = data === null;
|
|
4531
|
+
useReportWidgetRenderStatus(
|
|
4532
|
+
isUnreadable ? "failed" : "mounted",
|
|
4533
|
+
isUnreadable ? "INVALID_PROP" : void 0,
|
|
4534
|
+
isUnreadable ? "The QuickReplies options must be 2 to 5 distinct non-empty strings; the widget was dropped." : void 0
|
|
4075
4535
|
);
|
|
4076
|
-
if (
|
|
4077
|
-
|
|
4078
|
-
|
|
4536
|
+
if (!data) return null;
|
|
4537
|
+
const inert = !interactive || isStale;
|
|
4538
|
+
const disabled = inert || locked || pending;
|
|
4539
|
+
const handleClick = async (option2) => {
|
|
4540
|
+
if (disabled || pendingRef.current) return;
|
|
4541
|
+
if (isQuickReplyPlaceholderOption(option2)) {
|
|
4542
|
+
prefillComposer(stripQuickReplyPlaceholderMarker(option2));
|
|
4543
|
+
return;
|
|
4544
|
+
}
|
|
4545
|
+
pendingRef.current = true;
|
|
4546
|
+
setPending(true);
|
|
4547
|
+
setChosenOption(option2);
|
|
4548
|
+
try {
|
|
4549
|
+
const outgoing = isAnotherAgentSpace && anotherAgentSpaceKey !== void 0 ? appendAnotherAgentSpaceToOwnerText(option2, anotherAgentSpaceKey) : option2;
|
|
4550
|
+
const result2 = await sendMessageToChat(outgoing);
|
|
4551
|
+
if (result2 === false) {
|
|
4552
|
+
setChosenOption(null);
|
|
4553
|
+
} else {
|
|
4554
|
+
setLocked(true);
|
|
4555
|
+
}
|
|
4556
|
+
} catch {
|
|
4557
|
+
setChosenOption(null);
|
|
4558
|
+
} finally {
|
|
4559
|
+
pendingRef.current = false;
|
|
4560
|
+
setPending(false);
|
|
4561
|
+
}
|
|
4562
|
+
};
|
|
4563
|
+
return /* @__PURE__ */ jsx(ConversationWidgetAgentSpaceFrame, { anotherAgentSpaceKey: isAnotherAgentSpace ? anotherAgentSpaceKey : void 0, children: /* @__PURE__ */ jsx("div", { "aria-live": "polite", "data-testid": testId, children: locked && chosenOption !== null ? /* @__PURE__ */ jsx(DonePill, { translate: false, testId: `${testId}-done`, children: truncateQuickReplyLabel(chosenOption) }) : /* @__PURE__ */ jsx("div", { ref: rowRef, className: styles$2.wrap, role: "group", "data-testid": `${testId}-options`, children: data.options.map((option2) => {
|
|
4564
|
+
if (isEmailRender)
|
|
4565
|
+
return /* @__PURE__ */ jsx(Text, { role: "help", translate: false, testId: `${testId}-option-${option2}`, children: option2 }, option2);
|
|
4566
|
+
const isChosen = chosenOption === option2;
|
|
4567
|
+
return /* @__PURE__ */ jsx(
|
|
4568
|
+
"button",
|
|
4569
|
+
{
|
|
4570
|
+
type: "button",
|
|
4571
|
+
className: classNames(styles$2.pill, isChosen && styles$2.pillChosen),
|
|
4572
|
+
disabled,
|
|
4573
|
+
onClick: () => handleClick(option2),
|
|
4574
|
+
"data-testid": `${testId}-option-${option2}`,
|
|
4575
|
+
children: /* @__PURE__ */ jsx(Text, { role: "help", translate: false, className: styles$2.pillLabel, children: truncateQuickReplyLabel(option2) })
|
|
4576
|
+
},
|
|
4577
|
+
option2
|
|
4578
|
+
);
|
|
4579
|
+
}) }) }) });
|
|
4580
|
+
};
|
|
4581
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4582
|
+
const parsePayload = (raw) => {
|
|
4583
|
+
try {
|
|
4584
|
+
const parsed = JSON.parse(raw);
|
|
4585
|
+
return isRecord(parsed) ? parsed : null;
|
|
4586
|
+
} catch {
|
|
4587
|
+
return null;
|
|
4079
4588
|
}
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
)
|
|
4090
|
-
|
|
4589
|
+
};
|
|
4590
|
+
const humanizeNavKey = (key) => {
|
|
4591
|
+
const lastSegment = key.split(".").pop() ?? key;
|
|
4592
|
+
return lastSegment.toLowerCase().replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
4593
|
+
};
|
|
4594
|
+
const resolveLabel = (payload) => {
|
|
4595
|
+
if (payload.name === "Navigate" && isRecord(payload.input)) {
|
|
4596
|
+
const destination = payload.input.destination;
|
|
4597
|
+
if (typeof destination === "string" && destination.length > 0) {
|
|
4598
|
+
return humanizeNavKey(destination);
|
|
4599
|
+
}
|
|
4091
4600
|
}
|
|
4092
|
-
|
|
4093
|
-
return
|
|
4094
|
-
/* @__PURE__ */ jsx(ConversationWidgetAgentSpaceHeader, { agentSpaceKey: anotherAgentSpaceKey, inFlow: true }),
|
|
4095
|
-
card2
|
|
4096
|
-
] });
|
|
4601
|
+
const toolName = typeof payload.name === "string" ? payload.name : "Tool";
|
|
4602
|
+
return toolName;
|
|
4097
4603
|
};
|
|
4098
|
-
const
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
const capture = useWidgetImageRender();
|
|
4114
|
-
const isEmailRender = useIsEmailWidgetRender();
|
|
4115
|
-
if (isEmailRender || capture !== null) return /* @__PURE__ */ jsx(Fragment, { children: renderInline({ isWidgetPreview: false }) });
|
|
4116
|
-
const isCanvasWidget = display === "canvas" || display !== "inline" && exceedsInlineLimit;
|
|
4117
|
-
if (!isCanvasWidget) return /* @__PURE__ */ jsx(Fragment, { children: renderInline({ isWidgetPreview: false }) });
|
|
4118
|
-
return /* @__PURE__ */ jsx(
|
|
4119
|
-
CanvasLauncherWidget,
|
|
4604
|
+
const ToolTraceConversationWidget = (props) => {
|
|
4605
|
+
const { payload } = props;
|
|
4606
|
+
const label2 = useMemo(() => {
|
|
4607
|
+
const parsed = parsePayload(payload);
|
|
4608
|
+
if (!parsed) return null;
|
|
4609
|
+
return resolveLabel(parsed);
|
|
4610
|
+
}, [payload]);
|
|
4611
|
+
useReportWidgetRenderStatus(
|
|
4612
|
+
label2 ? "mounted" : "failed",
|
|
4613
|
+
label2 ? void 0 : "INVALID_PROP",
|
|
4614
|
+
label2 ? void 0 : "The ToolTrace payload is not a JSON object."
|
|
4615
|
+
);
|
|
4616
|
+
if (!label2) return null;
|
|
4617
|
+
return /* @__PURE__ */ jsxs(
|
|
4618
|
+
"span",
|
|
4120
4619
|
{
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4620
|
+
"data-testid": "tool-trace-widget",
|
|
4621
|
+
style: {
|
|
4622
|
+
display: "inline-flex",
|
|
4623
|
+
alignItems: "center",
|
|
4624
|
+
gap: "4px",
|
|
4625
|
+
fontSize: "12px",
|
|
4626
|
+
color: "var(--agents-text-subtle, #8a8a8a)",
|
|
4627
|
+
fontStyle: "italic"
|
|
4628
|
+
},
|
|
4629
|
+
children: [
|
|
4630
|
+
/* @__PURE__ */ jsx(Icon, { name: "arrowRight" }),
|
|
4631
|
+
/* @__PURE__ */ jsx(Text, { replacements: { label: label2 }, testId: "tool-trace-widget-label", children: "Opened %label%" })
|
|
4632
|
+
]
|
|
4132
4633
|
}
|
|
4133
4634
|
);
|
|
4134
4635
|
};
|
|
4135
|
-
const canvasForMessageWidget = (canvasId, messageId, payload) => {
|
|
4136
|
-
const numericMessageId = messageId === void 0 ? Number.NaN : Number(messageId);
|
|
4137
|
-
if (!Number.isFinite(numericMessageId)) return void 0;
|
|
4138
|
-
return {
|
|
4139
|
-
canvasId,
|
|
4140
|
-
instanceId: canvasInstanceIdForMessagePayload(canvasId, numericMessageId, payload),
|
|
4141
|
-
anchor: messageAnchor(numericMessageId)
|
|
4142
|
-
};
|
|
4143
|
-
};
|
|
4144
4636
|
const parseJsonString = (value) => {
|
|
4145
4637
|
try {
|
|
4146
4638
|
return JSON.parse(value);
|
|
@@ -4621,148 +5113,167 @@ const WebSearchResultsConversationWidget = (props) => {
|
|
|
4621
5113
|
);
|
|
4622
5114
|
};
|
|
4623
5115
|
export {
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
5116
|
+
sameCanvasAnchor as $,
|
|
5117
|
+
buildWidgetAgentSpaceKeyProps as A,
|
|
5118
|
+
canvasInstanceIdForActiveAgentSpace as B,
|
|
4627
5119
|
CANVAS_BOXED_INSET_PX as C,
|
|
4628
5120
|
DEFAULT_CANVAS_WIDTH_PERCENT as D,
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
5121
|
+
canvasInstanceIdForAgentSpace as E,
|
|
5122
|
+
canvasInstanceIdForEntity as F,
|
|
5123
|
+
canvasInstanceIdForMessage as G,
|
|
5124
|
+
canvasInstanceIdForMessagePayload as H,
|
|
5125
|
+
canvasInstanceIdForReference as I,
|
|
5126
|
+
canvasKindOpenerWidgetNamesOf as J,
|
|
5127
|
+
canvasWidthPercentOf as K,
|
|
4636
5128
|
LEGACY_CARD_CLICK_ORIGIN as L,
|
|
4637
5129
|
ModelText as M,
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
5130
|
+
defaultConversationWidgetCallbacks as N,
|
|
5131
|
+
entityIdOfInstanceId as O,
|
|
5132
|
+
getDeclaredCanvasIds as P,
|
|
5133
|
+
hasWidgetHydrator as Q,
|
|
4642
5134
|
ReadOnlyConversationWidgetProvider as R,
|
|
4643
5135
|
StandaloneConversationWidgetProvider as S,
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
5136
|
+
isCanvasAnchorLoaded as T,
|
|
5137
|
+
isCanvasReference as U,
|
|
5138
|
+
messageAnchor as V,
|
|
4647
5139
|
WidgetRenderReportContext as W,
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
5140
|
+
packageCanvasBehaviours as X,
|
|
5141
|
+
pageAnchor as Y,
|
|
5142
|
+
readWidgetAgentSpaceKeyAttribute as Z,
|
|
5143
|
+
referenceOfCanvasInstanceId as _,
|
|
4652
5144
|
isPackageCanvasId as a,
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
5145
|
+
nodeIdOfReference as a$,
|
|
5146
|
+
shortStringHash as a0,
|
|
5147
|
+
useConversationWidgetContext as a1,
|
|
5148
|
+
useIsEmailWidgetRender as a2,
|
|
5149
|
+
useReportWidgetRenderStatus as a3,
|
|
5150
|
+
useWidgetHydration as a4,
|
|
5151
|
+
useWidgetMemory as a5,
|
|
5152
|
+
useWidgetRenderReporter as a6,
|
|
5153
|
+
WidgetImageReadinessContext as a7,
|
|
5154
|
+
WidgetImageRenderContext as a8,
|
|
5155
|
+
WidgetImageLiveHydrationContext as a9,
|
|
5156
|
+
IMAGE_GALLERY_WIDGET_TYPE as aA,
|
|
5157
|
+
ImageGalleryConversationWidget as aB,
|
|
5158
|
+
MultiChoiceConversationWidget as aC,
|
|
5159
|
+
QuickRepliesConversationWidget as aD,
|
|
5160
|
+
SkeletonCircle as aE,
|
|
5161
|
+
SkeletonLine as aF,
|
|
5162
|
+
SkeletonPill as aG,
|
|
5163
|
+
SkeletonWidgetLabel as aH,
|
|
5164
|
+
SuggestedActions as aI,
|
|
5165
|
+
ToolTraceConversationWidget as aJ,
|
|
5166
|
+
WebSearchResultsConversationWidget as aK,
|
|
5167
|
+
WidgetKpiValue as aL,
|
|
5168
|
+
WidgetListRow as aM,
|
|
5169
|
+
WidgetSurface as aN,
|
|
5170
|
+
WidgetSurfaceSkeleton as aO,
|
|
5171
|
+
WritingDraftConversationWidget as aP,
|
|
5172
|
+
buildAttachedFilesComposerWidget as aQ,
|
|
5173
|
+
buildImageGalleryDeclineSentence as aR,
|
|
5174
|
+
buildImageGalleryPickSentence as aS,
|
|
5175
|
+
canvasForMessageWidget as aT,
|
|
5176
|
+
driveFileCanvasTargetOf as aU,
|
|
5177
|
+
driveFileCardToOpen as aV,
|
|
5178
|
+
driveFileFamilyOf as aW,
|
|
5179
|
+
driveFileTypeLabelOf as aX,
|
|
5180
|
+
formatConceptExplainerNumber as aY,
|
|
5181
|
+
formatDriveFileSize as aZ,
|
|
5182
|
+
isDriveFileCardExpired as a_,
|
|
5183
|
+
readFrozenHydration as aa,
|
|
5184
|
+
useWidgetImageLiveHydration as ab,
|
|
5185
|
+
useWidgetImageRender as ac,
|
|
5186
|
+
ATTACHED_FILES_MAX as ad,
|
|
5187
|
+
ATTACHED_FILES_WIDGET_TYPE as ae,
|
|
5188
|
+
AttachedFilesConversationWidget as af,
|
|
5189
|
+
AttachedFilesStrip as ag,
|
|
5190
|
+
CANVAS_VIABLE_MIN_WIDTH as ah,
|
|
5191
|
+
CUSTOM_VISUALIZATION_SANDBOX_CONFIG as ai,
|
|
5192
|
+
CanvasLauncherWidget as aj,
|
|
5193
|
+
CanvasViabilityContext as ak,
|
|
5194
|
+
CanvasWidgetSwitch as al,
|
|
5195
|
+
ClockConversationWidget as am,
|
|
5196
|
+
ConceptExplainerConversationWidget as an,
|
|
5197
|
+
ConversationSearchResultsConversationWidget as ao,
|
|
5198
|
+
CurrencyConverterConversationWidget as ap,
|
|
5199
|
+
CustomVisualizationConversationWidget as aq,
|
|
5200
|
+
DRIVE_FILES_MAX_FILES as ar,
|
|
5201
|
+
DRIVE_FILES_WIDGET_TYPE as as,
|
|
5202
|
+
DRIVE_FILE_CARDS_SOURCE_MISSING as at,
|
|
5203
|
+
DonePill as au,
|
|
5204
|
+
DriveFilesConversationWidget as av,
|
|
5205
|
+
ElementWidthCanvasViability as aw,
|
|
5206
|
+
EntityMentionConversationWidget as ax,
|
|
5207
|
+
FILE_PREVIEW_SOURCE_MISSING as ay,
|
|
5208
|
+
IMAGE_GALLERY_MAX_FILES as az,
|
|
4717
5209
|
registerConceptExplainerTypes as b,
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
5210
|
+
normalizeSearchHitExcerpt as b0,
|
|
5211
|
+
parseDriveFilesPayload as b1,
|
|
5212
|
+
parseImageGalleryPayload as b2,
|
|
5213
|
+
pickAllowed as b3,
|
|
5214
|
+
pickAllowedValue as b4,
|
|
5215
|
+
pickReviewExternalId as b5,
|
|
5216
|
+
pickSafeAlias as b6,
|
|
5217
|
+
pickSafeAliases as b7,
|
|
5218
|
+
pickText as b8,
|
|
5219
|
+
readAttachedFiles as b9,
|
|
5220
|
+
readAllowedValue as bA,
|
|
5221
|
+
useReportTextNodeRenderState as bB,
|
|
5222
|
+
readTextNodeRenderState as bC,
|
|
5223
|
+
buildFaviconUrl as bD,
|
|
5224
|
+
readSiteHostname as bE,
|
|
5225
|
+
readSafeHttpUrl as bF,
|
|
5226
|
+
registerDriveFilesHydrator as bG,
|
|
5227
|
+
IMAGE_GALLERY_CANVAS_ID as bH,
|
|
5228
|
+
readCanvasViable as ba,
|
|
5229
|
+
readConceptExplainerNumber as bb,
|
|
5230
|
+
readConceptExplainerValue as bc,
|
|
5231
|
+
readDriveFileCanvasOpener as bd,
|
|
5232
|
+
readDriveFileCardsSource as be,
|
|
5233
|
+
readFilePreviewSource as bf,
|
|
5234
|
+
resolveCustomVisualizationFrameUrl as bg,
|
|
5235
|
+
safeDriveFileOpenLink as bh,
|
|
5236
|
+
unregisterDriveFileCanvasOpener as bi,
|
|
5237
|
+
unregisterDriveFileCardsSource as bj,
|
|
5238
|
+
unregisterFilePreviewSource as bk,
|
|
5239
|
+
useCanvasViable as bl,
|
|
5240
|
+
useFilePictureUrl as bm,
|
|
5241
|
+
parseConversationSearchResultsPayload as bn,
|
|
5242
|
+
WebSearchAnswer as bo,
|
|
5243
|
+
WebSearchSourcesList as bp,
|
|
5244
|
+
parseWebSearchResultsPayload as bq,
|
|
5245
|
+
ENTITY_MENTION_WIDGET_NAME as br,
|
|
5246
|
+
buildEntityMentionFields as bs,
|
|
5247
|
+
normalizeEntityMentionFields as bt,
|
|
5248
|
+
entityMentionKey as bu,
|
|
5249
|
+
MAX_ENTITY_MENTIONS_PER_MESSAGE as bv,
|
|
5250
|
+
toEntityMentionWireFields as bw,
|
|
5251
|
+
ConversationWidgetButton as bx,
|
|
5252
|
+
ImageGallery as by,
|
|
5253
|
+
readTextNodeContent as bz,
|
|
4743
5254
|
registerDriveFileCanvasOpener as c,
|
|
4744
5255
|
declareCanvasKind as d,
|
|
4745
5256
|
registerDriveFileCardsSource as e,
|
|
4746
5257
|
forgetCanvasKind as f,
|
|
4747
|
-
|
|
4748
|
-
|
|
5258
|
+
registerFilePreviewSource as g,
|
|
5259
|
+
registerWidgetHydrator as h,
|
|
4749
5260
|
isCanvasId as i,
|
|
4750
|
-
|
|
4751
|
-
|
|
5261
|
+
canvasBehaviourOf as j,
|
|
5262
|
+
getWidgetHydrator as k,
|
|
4752
5263
|
listWidgetHydratorTypes as l,
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
5264
|
+
abandonWidgetHydrationReads as m,
|
|
5265
|
+
useResolvedConversationWidgetAgentSpaceKey as n,
|
|
5266
|
+
CANVAS_FILLS_SCREEN_WIDTH_PERCENT as o,
|
|
4756
5267
|
payloadHashOfInstanceId as p,
|
|
4757
|
-
|
|
5268
|
+
CANVAS_MIN_WIDTH_PX as q,
|
|
4758
5269
|
readConceptExplainerTypeDefinitions as r,
|
|
4759
5270
|
sameCanvasIdentity as s,
|
|
4760
|
-
|
|
5271
|
+
CHAT_COLUMN_MIN_WIDTH_PX as t,
|
|
4761
5272
|
unregisterWidgetHydrator as u,
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
5273
|
+
ConversationWidgetActions as v,
|
|
5274
|
+
ConversationWidgetAgentSpaceFrame as w,
|
|
5275
|
+
ConversationWidgetAgentSpaceHeader as x,
|
|
5276
|
+
ConversationWidgetContext as y,
|
|
5277
|
+
ConversationWidgetRenderContext as z
|
|
4767
5278
|
};
|
|
4768
|
-
//# sourceMappingURL=WebSearchResultsConversationWidget-
|
|
5279
|
+
//# sourceMappingURL=WebSearchResultsConversationWidget-W7O1fBB0.js.map
|