@epam/ai-dial-conversation-stages 1.2.0-dev.3 → 1.2.0-dev.303

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.
Files changed (40) hide show
  1. package/components/CollapsedGroup/CollapsedGroup.d.ts.map +1 -1
  2. package/components/StageItem/StageItem.d.ts +11 -3
  3. package/components/StageItem/StageItem.d.ts.map +1 -1
  4. package/components/StageList/StageList.d.ts +29 -0
  5. package/components/StageList/StageList.d.ts.map +1 -0
  6. package/components/StageMarkdownContent/StageCodeBlock.d.ts +4 -2
  7. package/components/StageMarkdownContent/StageCodeBlock.d.ts.map +1 -1
  8. package/components/StageMarkdownContent/StageMarkdownContent.d.ts +6 -0
  9. package/components/StageMarkdownContent/StageMarkdownContent.d.ts.map +1 -1
  10. package/components/StagesPanel/StagesPanel.d.ts +15 -1
  11. package/components/StagesPanel/StagesPanel.d.ts.map +1 -1
  12. package/constants/public-class-names.d.ts +9 -0
  13. package/constants/public-class-names.d.ts.map +1 -0
  14. package/constants/stage-accordion.d.ts +11 -0
  15. package/constants/stage-accordion.d.ts.map +1 -0
  16. package/hooks/useStageExpansion/useStageExpansion.d.ts +9 -0
  17. package/hooks/useStageExpansion/useStageExpansion.d.ts.map +1 -0
  18. package/index.css +2 -2
  19. package/index.d.ts +1 -0
  20. package/index.d.ts.map +1 -1
  21. package/index.js +791 -422
  22. package/models/collapsed-group.d.ts +12 -6
  23. package/models/collapsed-group.d.ts.map +1 -1
  24. package/models/stage-grouping.d.ts +6 -6
  25. package/models/stage-grouping.d.ts.map +1 -1
  26. package/models/stage-tree.d.ts +21 -0
  27. package/models/stage-tree.d.ts.map +1 -0
  28. package/models/stages-props.d.ts +15 -5
  29. package/models/stages-props.d.ts.map +1 -1
  30. package/package.json +5 -4
  31. package/utils/stage-attachments.d.ts +11 -0
  32. package/utils/stage-attachments.d.ts.map +1 -0
  33. package/utils/stage-grouping.d.ts +7 -3
  34. package/utils/stage-grouping.d.ts.map +1 -1
  35. package/utils/stage-name.d.ts +0 -6
  36. package/utils/stage-name.d.ts.map +1 -1
  37. package/utils/stage-progress.d.ts +0 -2
  38. package/utils/stage-progress.d.ts.map +1 -1
  39. package/utils/stage-tree.d.ts +14 -0
  40. package/utils/stage-tree.d.ts.map +1 -0
package/index.js CHANGED
@@ -1,498 +1,867 @@
1
- import { MarkdownRenderer as e, StageStatus as t, buildCssVars as n, copyToClipboard as r, mergeClasses as i } from "@epam/ai-dial-chat-shared";
2
- import { DIAL_ICON_SIZE as a, DIAL_KIT_ICON_STROKE as o, ElementSize as s, EllipsisTooltip as c, GhostIconButton as l, LinkButton as u, Spinner as d } from "@epam/ai-dial-ui-kit";
3
- import { IconAlertCircle as f, IconCheck as p, IconChevronDown as m, IconChevronRight as h, IconCopy as g } from "@tabler/icons-react";
4
- import { memo as _, useCallback as v, useEffect as y, useRef as b, useState as x } from "react";
5
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
6
- //#region src/utils/stage-name.ts
7
- var T = /[([][^()[\]]*[)\]]/g, E = /(\d+(?:\.\d+)?)\s*s\b/, D = /\bStart:\s*(\d{1,2}):([0-5]\d):([0-5]\d(?:\.\d+)?)\b/i, O = (e) => {
1
+ import { AttachmentErrorReason as e, AttachmentType as t, MIME_TYPE_EXT_MAP as n, MarkdownCodeBlock as r, MarkdownRenderer as i, RequestStatus as a, StageStatus as o, buildCssVars as s, mergeClasses as c, messageAttachmentsToDisplayAttachments as l, normalizeMimeType as u } from "@epam/ai-dial-chat-shared";
2
+ import { Accordion as d, DIAL_ICON_SIZE as f, DIAL_KIT_ICON_STROKE as p, ElementSize as m, EllipsisTooltip as h, Highlight as g, Skeleton as _, SkeletonVariant as v, Spinner as y, StaticIconButton as b } from "@epam/ai-dial-ui-kit";
3
+ import { IconAlertCircle as x, IconCheck as S, IconClipboard as C, IconDownload as w, IconExternalLink as T, IconFile as E, IconFileTypeBmp as D, IconFileTypeCss as O, IconFileTypeCsv as k, IconFileTypeDoc as A, IconFileTypeDocx as j, IconFileTypeHtml as M, IconFileTypeJpg as N, IconFileTypeJs as P, IconFileTypeJsx as F, IconFileTypePdf as I, IconFileTypePhp as L, IconFileTypePng as R, IconFileTypePpt as z, IconFileTypeRs as ee, IconFileTypeSql as te, IconFileTypeSvg as ne, IconFileTypeTs as re, IconFileTypeTsx as ie, IconFileTypeTxt as B, IconFileTypeVue as ae, IconFileTypeXls as V, IconFileTypeXml as oe, IconFileTypeZip as H, IconMusic as se, IconPhoto as U, IconReload as ce, IconTerminal2 as le, IconVideo as ue, IconX as de } from "@tabler/icons-react";
4
+ import { memo as fe, useCallback as W, useEffect as G, useId as pe, useMemo as K, useRef as me, useState as q } from "react";
5
+ import { Fragment as he, jsx as J, jsxs as Y } from "react/jsx-runtime";
6
+ //#region src/constants/public-class-names.ts
7
+ var ge = {
8
+ panel: "dial-conversation-stages-panel",
9
+ group: "dial-conversation-stages-group",
10
+ groupToggle: "dial-conversation-stages-group-toggle"
11
+ }, _e = () => {
12
+ let [e, t] = q(() => /* @__PURE__ */ new Set()), n = W((e, n) => {
13
+ t((t) => {
14
+ if (t.has(e) === n) return t;
15
+ let r = new Set(t);
16
+ return n ? r.add(e) : r.delete(e), r;
17
+ });
18
+ }, []), r = W(() => {
19
+ t((e) => e.size ? /* @__PURE__ */ new Set() : e);
20
+ }, []);
21
+ return K(() => ({
22
+ isExpanded: (t) => e.has(t),
23
+ onToggle: n,
24
+ reset: r
25
+ }), [
26
+ e,
27
+ n,
28
+ r
29
+ ]);
30
+ }, ve = /[([][^()[\]]*[)\]]/g, ye = /(\d+(?:\.\d+)?)\s*s\b/, be = (e) => {
8
31
  let t = e.trimEnd();
9
32
  return t.endsWith(":") ? t.slice(0, -1) : t;
10
- }, k = 1440 * 60, A = k / 2, j = (e) => {
11
- let t = D.exec(e);
12
- if (!t) return;
13
- let n = Number(t[1]);
14
- if (!(n > 23)) return n * 60 * 60 + Number(t[2]) * 60 + Number(t[3]);
15
- }, M = (e) => {
16
- T.lastIndex = 0;
33
+ }, xe = (e) => {
34
+ ve.lastIndex = 0;
17
35
  let t;
18
- for (; t = T.exec(e);) {
19
- let e = t[0].slice(1, -1), n = E.exec(e);
36
+ for (; t = ve.exec(e);) {
37
+ let e = t[0].slice(1, -1), n = ye.exec(e);
20
38
  if (n) return {
21
39
  durationLabel: `${n[1]}s`,
22
40
  groupIndex: t.index,
23
- groupLength: t[0].length,
24
- startTimeSeconds: j(e)
41
+ groupLength: t[0].length
25
42
  };
26
43
  }
27
- }, N = (e) => {
28
- let t = e ?? "", n = M(t);
44
+ }, Se = (e) => {
45
+ let t = e ?? "", n = xe(t);
29
46
  return {
30
- name: O(n ? t.slice(0, n.groupIndex) + t.slice(n.groupIndex + n.groupLength) : t).trim().replace(/ {2,}/g, " "),
47
+ name: be(n ? t.slice(0, n.groupIndex) + t.slice(n.groupIndex + n.groupLength) : t).trim().replace(/ {2,}/g, " "),
31
48
  durationLabel: n?.durationLabel
32
49
  };
33
- }, P = (e) => e.length > 0 && !/\s/.test(e) && e.includes("_"), F = (e) => e >= 60 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${e.toFixed(1)}s`, I = (e) => {
34
- if (!e) return;
35
- let t = /^(\d+(?:\.\d+)?)s$/.exec(e);
36
- return t ? parseFloat(t[1]) : void 0;
37
- }, L = (e) => {
38
- let t = e.flatMap((e) => {
39
- let t = M(e ?? ""), n = I(t?.durationLabel);
40
- return n == null ? [] : [{
41
- durationSeconds: n,
42
- startTimeSeconds: t?.startTimeSeconds
43
- }];
44
- });
45
- if (t.length === 0) return 0;
46
- if (t.some(({ startTimeSeconds: e }) => e == null)) return t.reduce((e, { durationSeconds: t }) => e + t, 0);
47
- let n = 0, r, i = t.flatMap(({ durationSeconds: e, startTimeSeconds: t }) => {
48
- if (t == null) return [];
49
- let i = t + n;
50
- return r != null && r - i > A && (n += k, i += k), r = i, {
51
- start: i,
52
- end: i + e
53
- };
54
- }).sort((e, t) => e.start - t.start), a = 0, o = i[0].start, s = i[0].end;
55
- for (let e of i.slice(1)) e.start <= s ? s = Math.max(s, e.end) : (a += s - o, o = e.start, s = e.end);
56
- return a + s - o;
57
- }, R = (e) => [...e].reverse().find((e) => e.status == null), z = (e, t) => e.findIndex((e) => e.index === t.index) + 1, B = (e) => {
50
+ }, Ce = (e) => e.length > 0 && !/\s/.test(e) && e.includes("_"), we = (e) => [...e].reverse().find((e) => e.status == null), Te = (e, t) => {
51
+ let n = e.parent_stage_index;
52
+ if (!(n == null || !Number.isInteger(n) || n < 0 || n >= e.index)) return t.get(n);
53
+ }, Ee = (e) => {
54
+ let t = e.map((e) => ({
55
+ stage: e,
56
+ children: []
57
+ })), n = /* @__PURE__ */ new Map();
58
+ for (let e of t) n.has(e.stage.index) || n.set(e.stage.index, e);
59
+ let r = [];
60
+ for (let e of t) {
61
+ let t = Te(e.stage, n);
62
+ t ? t.children.push(e) : r.push(e);
63
+ }
64
+ return r;
65
+ }, De = (e) => `stage:${e}`, Oe = (e) => `group:${e}`, ke = "min-w-0 overflow-visible py-0", Ae = "min-w-0 justify-start gap-2 rounded-lg px-2 py-1.5 text-start mobile:min-h-11", je = (e) => {
58
66
  let t = [], n = 0;
59
67
  for (; n < e.length;) {
60
- let r = e[n], i = N(r.name).name, a = n + 1;
61
- for (; a < e.length && N(e[a].name).name === i;) a += 1;
68
+ let r = e[n], i = Se(r.stage.name).name, a = n + 1;
69
+ for (; a < e.length && Se(e[a].stage.name).name === i;) a += 1;
62
70
  let o = e.slice(n, a);
63
71
  o.length > 1 ? t.push({
64
- key: r.index,
72
+ key: r.stage.index,
65
73
  name: i,
66
74
  attempts: o
67
75
  }) : t.push({
68
- key: r.index,
69
- stage: r
76
+ key: r.stage.index,
77
+ node: r
70
78
  }), n = a;
71
79
  }
72
80
  return t;
73
- }, V = {
74
- panel: "_panel_vd48n_1",
75
- row: "_row_vd48n_5",
76
- collapseButton: "_collapseButton_vd48n_9",
77
- stageName: "_stageName_vd48n_13",
78
- stageNameFailed: "_stageNameFailed_vd48n_17",
79
- monoName: "_monoName_vd48n_21",
80
- tag: "_tag_vd48n_25",
81
- count: "_count_vd48n_29",
82
- duration: "_duration_vd48n_34",
83
- iconSecondary: "_iconSecondary_vd48n_39",
84
- iconCompleted: "_iconCompleted_vd48n_44",
85
- iconError: "_iconError_vd48n_48",
86
- stageContent: "_stageContent_vd48n_52",
87
- codeBlock: "_codeBlock_vd48n_56",
88
- codeInline: "_codeInline_vd48n_62",
89
- blockquote: "_blockquote_vd48n_68",
90
- tableCell: "_tableCell_vd48n_73"
91
- }, H = ({ status: e, isLive: n, runningLabel: r = "Running", failedLabel: i = "Failed" }) => e === t.Failed ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(f, {
92
- size: a.MD,
93
- className: V.iconError,
81
+ }, X = {
82
+ panel: "_panel_w65is_2",
83
+ row: "_row_w65is_6",
84
+ collapseButton: "_collapseButton_w65is_10",
85
+ stageHeader: "_stageHeader_w65is_19",
86
+ stageRegion: "_stageRegion_w65is_28",
87
+ stageName: "_stageName_w65is_32",
88
+ stageNameFailed: "_stageNameFailed_w65is_36",
89
+ monoName: "_monoName_w65is_40",
90
+ tag: "_tag_w65is_44",
91
+ count: "_count_w65is_48",
92
+ duration: "_duration_w65is_53",
93
+ iconSecondary: "_iconSecondary_w65is_58",
94
+ iconCompleted: "_iconCompleted_w65is_63",
95
+ iconError: "_iconError_w65is_67",
96
+ stageContent: "_stageContent_w65is_71",
97
+ codeBlock: "_codeBlock_w65is_75",
98
+ codeInline: "_codeInline_w65is_84",
99
+ blockquote: "_blockquote_w65is_91",
100
+ tableCell: "_tableCell_w65is_96"
101
+ }, Me = ({ status: e, isLive: t, runningLabel: n = "Running", failedLabel: r = "Failed" }) => e === o.Failed ? /* @__PURE__ */ Y(he, { children: [/* @__PURE__ */ J(x, {
102
+ size: f.MD,
103
+ className: X.iconError,
94
104
  "aria-hidden": !0,
95
- stroke: o
96
- }), /* @__PURE__ */ C("span", {
105
+ stroke: p
106
+ }), /* @__PURE__ */ J("span", {
97
107
  className: "sr-only",
98
- children: i
99
- })] }) : e === t.Completed ? /* @__PURE__ */ C(p, {
100
- size: a.SM,
101
- className: V.iconCompleted,
108
+ children: r
109
+ })] }) : e === o.Completed ? /* @__PURE__ */ J(S, {
110
+ size: f.SM,
111
+ className: X.iconCompleted,
102
112
  "aria-hidden": !0,
103
- stroke: o
104
- }) : n ? /* @__PURE__ */ C(d, {
113
+ stroke: p
114
+ }) : t ? /* @__PURE__ */ J(y, {
105
115
  size: 16,
106
- ariaLabel: r
107
- }) : null, U = ({ children: e, codeClassName: t, blockClassName: n = "dial-code-text", copyAriaLabel: c }) => {
108
- let [u, d] = x(!1), f = b(null);
109
- y(() => () => {
110
- f.current != null && clearTimeout(f.current);
111
- }, []);
112
- let m = v(() => {
113
- r(typeof e == "string" ? e : String(e ?? "")), f.current && clearTimeout(f.current), d(!0), f.current = setTimeout(() => d(!1), 2e3);
114
- }, [e]);
115
- return /* @__PURE__ */ w("pre", {
116
- className: i("relative max-h-[300px] overflow-auto rounded border p-3", n, V.codeBlock),
117
- children: [/* @__PURE__ */ C(l, {
118
- size: s.Small,
119
- icon: C(u ? p : g, {
120
- size: a.SM,
121
- className: V.iconSecondary,
122
- stroke: o
123
- }),
124
- "aria-label": c,
125
- onClick: m,
126
- className: "absolute end-2 top-2"
127
- }), /* @__PURE__ */ C("code", {
128
- className: t,
129
- children: e
116
+ ariaLabel: n
117
+ }) : null, Ne = (e) => {
118
+ if (e == null) return "";
119
+ let t = e.lastIndexOf(".");
120
+ return t > 0 ? e.slice(0, t) : e;
121
+ }, Pe = (e) => {
122
+ if (!e) return E;
123
+ let t = u(e);
124
+ if (t.startsWith("image/")) switch (t) {
125
+ case "image/jpeg": return N;
126
+ case "image/png": return R;
127
+ case "image/svg+xml": return ne;
128
+ case "image/bmp": return D;
129
+ default: return U;
130
+ }
131
+ if (t.startsWith("video/")) return ue;
132
+ if (t.startsWith("audio/")) return se;
133
+ switch (t) {
134
+ case "application/pdf": return I;
135
+ case "application/msword": return A;
136
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return j;
137
+ case "application/vnd.ms-powerpoint": return z;
138
+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation": return z;
139
+ case "application/vnd.ms-excel": return V;
140
+ case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": return V;
141
+ case "application/zip":
142
+ case "application/vnd.rar":
143
+ case "application/x-7z-compressed":
144
+ case "application/gzip":
145
+ case "application/x-tar": return H;
146
+ case "text/csv": return k;
147
+ case "text/plain": return B;
148
+ case "text/html":
149
+ case "application/xhtml+xml": return M;
150
+ case "application/xml": return oe;
151
+ case "application/sql": return te;
152
+ case "text/javascript": return P;
153
+ case "text/jsx": return F;
154
+ case "text/typescript": return re;
155
+ case "text/tsx": return ie;
156
+ case "text/css": return O;
157
+ case "text/x-php": return L;
158
+ case "text/x-rustsrc": return ee;
159
+ case "text/x-vue": return ae;
160
+ default: return E;
161
+ }
162
+ }, Fe = (e) => {
163
+ let { type: n, contentType: r } = e;
164
+ return n === t.Prompt ? le : n === t.Pasted ? C : n === t.Image ? U : Pe(r ?? "");
165
+ }, Ie = (e) => {
166
+ let t = u(e), r = n[t];
167
+ if (r) return r;
168
+ let i = t.split("/")[1];
169
+ if (i && !i.startsWith("vnd.") && !i.includes("+")) return i;
170
+ }, Le = (e, n) => {
171
+ let { type: r, name: i, contentType: a } = e;
172
+ if (r === t.Prompt) return n.promptLabel ?? "Prompt";
173
+ if (r === t.Pasted) return n.pastedLabel ?? "Pasted";
174
+ if (r === t.Image) return n.imageLabel ?? "Image";
175
+ if (a) {
176
+ let e = Ie(a);
177
+ if (e) return `.${e}`;
178
+ }
179
+ if (i == null) return "";
180
+ let o = i.lastIndexOf(".");
181
+ return o > 0 && o < i.length - 1 ? `.${i.slice(o + 1).toLowerCase()}` : i;
182
+ }, Re = (e, n = {}) => {
183
+ let { type: r, status: i, previewUrl: o, url: s } = e, c = i === a.Loading, l = i === a.Error, u = r === t.Image && !!(o ?? s) && !l, d = r === t.Link && !l;
184
+ return {
185
+ isLoading: c,
186
+ isError: l,
187
+ isImage: u,
188
+ isLink: d,
189
+ BottomIcon: d ? null : Fe(e),
190
+ typeLabel: d ? null : Le(e, n)
191
+ };
192
+ }, ze = "flex size-[84px] items-center justify-center rounded-xl border", Z = {
193
+ tray: "dial-ai-attachment-tray",
194
+ trayItem: "dial-ai-attachment-tray-item",
195
+ tile: "dial-ai-attachment-tile",
196
+ tileSelected: "dial-ai-attachment-tile-selected",
197
+ tileName: "dial-ai-attachment-tile-name",
198
+ tileType: "dial-ai-attachment-tile-type",
199
+ tileAction: "dial-ai-attachment-tile-action"
200
+ }, Q = {
201
+ tile: "_tile_1tdbq_12",
202
+ hovered: "_hovered_1tdbq_18",
203
+ selected: "_selected_1tdbq_28",
204
+ tileError: "_tileError_1tdbq_33",
205
+ nameText: "_nameText_1tdbq_38",
206
+ typeText: "_typeText_1tdbq_42",
207
+ retryIcon: "_retryIcon_1tdbq_46",
208
+ track: "_track_1tdbq_50",
209
+ actionButton: "_actionButton_1tdbq_56",
210
+ imageActionButton: "_imageActionButton_1tdbq_60"
211
+ }, Be = ({ ariaLabel: e, errorTitle: t, errorDescId: n, onClick: r, id: i, icon: a, className: o }) => /* @__PURE__ */ J(b, {
212
+ icon: a,
213
+ size: m.Small,
214
+ className: c("opacity-0 focus-visible:opacity-100 group-focus-within/attachment-tile:opacity-100 group-hover/attachment-tile:opacity-100", Q.actionButton, o, Z.tileAction),
215
+ "aria-label": e,
216
+ "aria-describedby": t ? n : void 0,
217
+ onClick: (e) => {
218
+ e.stopPropagation(), r(i);
219
+ }
220
+ }), Ve = ({ ...e }) => /* @__PURE__ */ J(Be, {
221
+ icon: /* @__PURE__ */ J(ce, {
222
+ size: f.SM,
223
+ "aria-hidden": !0,
224
+ stroke: p
225
+ }),
226
+ className: Q.retryIcon,
227
+ ...e
228
+ }), He = ({ ...e }) => /* @__PURE__ */ J(Be, {
229
+ icon: /* @__PURE__ */ J(w, {
230
+ size: f.SM,
231
+ "aria-hidden": !0,
232
+ stroke: p
233
+ }),
234
+ ...e
235
+ }), Ue = ({ ...e }) => /* @__PURE__ */ J(Be, {
236
+ icon: /* @__PURE__ */ J(T, {
237
+ size: f.SM,
238
+ "aria-hidden": !0,
239
+ stroke: p
240
+ }),
241
+ ...e
242
+ }), We = ({ ...e }) => /* @__PURE__ */ J(Be, {
243
+ icon: /* @__PURE__ */ J(de, {
244
+ size: f.SM,
245
+ "aria-hidden": !0,
246
+ stroke: p
247
+ }),
248
+ ...e
249
+ }), Ge = {
250
+ [e.Network]: "Upload failed · network error",
251
+ [e.UnsupportedType]: "Upload failed · unsupported file type",
252
+ [e.FileTooLarge]: "Upload failed · file too large"
253
+ }, Ke = ({ attachment: t, searchQuery: n = "", onClick: r, onRetry: i, labels: o, styles: s, onDownload: l, isPasted: u, isLink: d, cssVars: f, onExpand: p, isExpandable: m, onRemove: h, isSelected: _ }) => {
254
+ let { clickLabel: v = "Download attachment", expandLabel: b = "Expand pasted text", downloadLabel: x = "Download attachment", retryLabel: S = "Retry upload", removeLabel: C = "Remove attachment", openInNewTabLabel: w = "Open in new tab", sizeLabel: T, uploadingLabel: E = "Uploading", errorReasonLabels: D, genericErrorLabel: O = "Upload failed" } = o ?? {}, { typography: k, className: A } = s ?? {}, { id: j, name: M, status: N, errorReason: P } = t, F = N === a.Loading, I = N === a.Error, L = pe(), R = I ? P && (D?.[P] ?? Ge[P]) || O : "", { BottomIcon: z, typeLabel: ee } = Re(t), te = !I && !F && l && !d, ne = I && !!i && P !== e.UnsupportedType && P !== e.FileTooLarge, re = Number(!!te) + Number(!!ne) + Number(!!d) + Number(!!h), ie = re > 1 ? "pe-11" : re === 1 ? "pe-5" : void 0, B = !!m && p !== void 0, ae = B || r !== void 0, V = () => {
255
+ B ? p(j) : r?.(j);
256
+ }, oe = (e) => {
257
+ e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), V());
258
+ }, H = K(() => u ? M : Ne(M), [u, M]), se = W(() => {
259
+ window.open(t.referenceUrl, "_blank", "noopener,noreferrer");
260
+ }, [t]), U = c(ze, "group/attachment-tile relative flex-col justify-between items-start gap-1 overflow-hidden p-1.5", Q.tile, !I && Q.hovered, _ && Q.selected, I && Q.tileError, Z.tile, _ && Z.tileSelected), ce = /* @__PURE__ */ J("div", {
261
+ title: H,
262
+ className: c(k?.nameClassName ?? "dial-caption-text", "line-clamp-2 w-full min-w-0 break-words", Q.nameText, !I && ie, Z.tileName),
263
+ children: n ? /* @__PURE__ */ J(g, {
264
+ text: H,
265
+ query: n,
266
+ maxLines: 2
267
+ }) : H
268
+ }), le = z && /* @__PURE__ */ Y("div", {
269
+ className: c("flex w-full items-center gap-1", I && ie, Z.tileType),
270
+ children: [/* @__PURE__ */ J(z, {
271
+ size: 16,
272
+ className: Q.typeText,
273
+ "aria-hidden": !0
274
+ }), /* @__PURE__ */ J("span", {
275
+ className: c(k?.metaClassName ?? "dial-caption-text", "min-w-0 flex-1 truncate", Q.typeText),
276
+ children: T ? `${ee} · ${T}` : ee
130
277
  })]
278
+ }), ue = ae ? {
279
+ role: "button",
280
+ tabIndex: 0,
281
+ "aria-label": B ? b : v,
282
+ onClick: V,
283
+ onKeyDown: oe
284
+ } : {}, de = /* @__PURE__ */ Y(he, { children: [
285
+ ce,
286
+ le,
287
+ F && /* @__PURE__ */ J("div", {
288
+ role: "progressbar",
289
+ "aria-label": E,
290
+ className: c("absolute start-[-1px] top-[-1px] flex size-full items-center justify-center rounded", Q.track),
291
+ children: /* @__PURE__ */ J(y, { size: 32 })
292
+ }),
293
+ /* @__PURE__ */ Y("div", {
294
+ className: "absolute end-1 top-1 flex gap-1",
295
+ children: [
296
+ te && /* @__PURE__ */ J(He, {
297
+ ariaLabel: x,
298
+ errorTitle: R,
299
+ errorDescId: L,
300
+ onClick: l,
301
+ id: j
302
+ }),
303
+ ne && /* @__PURE__ */ J(Ve, {
304
+ ariaLabel: S,
305
+ errorTitle: R,
306
+ errorDescId: L,
307
+ onClick: i,
308
+ id: j
309
+ }),
310
+ d && /* @__PURE__ */ J(Ue, {
311
+ ariaLabel: w,
312
+ errorTitle: R,
313
+ errorDescId: L,
314
+ onClick: se
315
+ }),
316
+ h && /* @__PURE__ */ J(We, {
317
+ ariaLabel: C,
318
+ errorTitle: R,
319
+ errorDescId: L,
320
+ onClick: h,
321
+ id: j
322
+ })
323
+ ]
324
+ }),
325
+ I && /* @__PURE__ */ J("span", {
326
+ id: L,
327
+ role: "status",
328
+ "aria-live": "polite",
329
+ className: "sr-only",
330
+ children: R
331
+ })
332
+ ] });
333
+ return /* @__PURE__ */ J("div", {
334
+ style: f,
335
+ className: c("inline-flex", A),
336
+ children: /* @__PURE__ */ J("div", {
337
+ ...ue,
338
+ "aria-busy": F,
339
+ style: f,
340
+ className: c(U, ae && "cursor-pointer", "focus-within:outline focus-within:outline-1 focus-within:outline-offset-1"),
341
+ children: de
342
+ })
343
+ });
344
+ }, qe = /* @__PURE__ */ function(e) {
345
+ return e.Idle = "idle", e.Loading = "loading", e.Loaded = "loaded", e.Error = "error", e;
346
+ }({}), Je = ({ enabled: e, src: t }) => {
347
+ let n = me(null), [r, i] = q("idle");
348
+ return G(() => {
349
+ i(e && t ? "loading" : "idle");
350
+ }, [e, t]), G(() => {
351
+ let r = n.current;
352
+ if (!r || !e || !t) return;
353
+ let a = () => i("loaded"), o = () => i("error");
354
+ return r.addEventListener("load", a), r.addEventListener("error", o), r.complete && i(r.naturalWidth > 0 ? "loaded" : "error"), () => {
355
+ r.removeEventListener("load", a), r.removeEventListener("error", o);
356
+ };
357
+ }, [e, t]), {
358
+ imageRef: n,
359
+ imageLoadStatus: r
360
+ };
361
+ }, Ye = ({ attachment: e, onExpand: n, onClick: r, labels: i, onRemove: a, cssVars: o, onDownload: s, styles: l, isSelected: u }) => {
362
+ let { clickLabel: d = "Open attachment", expandLabel: m = "Expand pasted text", removeLabel: h = "Remove attachment", downloadLabel: g = "Download attachment" } = i ?? {}, { className: y } = l ?? {}, { id: b, name: x } = e, S = e.previewUrl ?? e.url, C = e.type === t.Pasted && n !== void 0, { isLoading: w, isError: T, isImage: E } = K(() => Re(e), [e]), D = r !== void 0 && !C && !w && !T, O = C || D, { imageRef: k, imageLoadStatus: A } = Je({
363
+ enabled: E,
364
+ src: S
365
+ }), j = () => {
366
+ C && n ? n(b) : D && r && r(b);
367
+ }, M = O ? {
368
+ role: "button",
369
+ tabIndex: 0,
370
+ "aria-label": C ? m : d,
371
+ onClick: j,
372
+ onKeyDown: (e) => {
373
+ e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), j());
374
+ }
375
+ } : {};
376
+ return /* @__PURE__ */ J("div", {
377
+ className: c(ze, "group/attachment-tile", O && "cursor-pointer", Q.tile, u && Q.selected, y, Z.tile, u && Z.tileSelected),
378
+ ...M,
379
+ style: o,
380
+ children: /* @__PURE__ */ Y("div", {
381
+ className: "relative h-full w-full overflow-hidden",
382
+ children: [
383
+ /* @__PURE__ */ Y("div", {
384
+ className: "absolute end-1 top-1 z-10 flex gap-1",
385
+ children: [a && /* @__PURE__ */ J(We, {
386
+ ariaLabel: h,
387
+ onClick: a,
388
+ id: b,
389
+ className: Q.imageActionButton
390
+ }), s && /* @__PURE__ */ J(He, {
391
+ ariaLabel: g,
392
+ onClick: s,
393
+ id: b,
394
+ className: Q.imageActionButton
395
+ })]
396
+ }),
397
+ A !== qe.Loaded && /* @__PURE__ */ J(_, {
398
+ variant: v.Rectangular,
399
+ width: "100%",
400
+ height: "100%",
401
+ active: A === qe.Loading,
402
+ overlay: /* @__PURE__ */ J(U, {
403
+ size: f.LG,
404
+ className: Q.typeText,
405
+ "aria-hidden": !0,
406
+ stroke: p
407
+ }),
408
+ className: "absolute inset-0 rounded-xl"
409
+ }),
410
+ /* @__PURE__ */ J("img", {
411
+ ref: k,
412
+ src: S,
413
+ alt: x,
414
+ loading: "lazy",
415
+ decoding: "async",
416
+ className: c("h-full w-full rounded-xl object-cover transition-opacity duration-200", A === qe.Loaded ? "opacity-100" : "opacity-0")
417
+ })
418
+ ]
419
+ })
420
+ });
421
+ }, Xe = ({ attachment: e, searchQuery: n = "", onRemove: r, onRetry: i, onExpand: a, onClick: o, onDownload: c, labels: l, styles: u, isSelected: d }) => {
422
+ let { colors: f } = u ?? {}, p = e.type === t.Pasted, m = p && a !== void 0, h = s({
423
+ "--ai-tile-bg": f?.background,
424
+ "--ai-tile-border": f?.border,
425
+ "--ai-tile-bg-hover": f?.backgroundHover,
426
+ "--ai-tile-border-hover": f?.borderHover,
427
+ "--ai-tile-bg-selected": f?.backgroundSelected,
428
+ "--ai-tile-border-selected": f?.borderSelected,
429
+ "--ai-tile-focus-outline": f?.focusOutline,
430
+ "--ai-tile-bg-error": f?.backgroundError,
431
+ "--ai-tile-border-error": f?.borderError,
432
+ "--ai-tile-error-text": f?.errorText,
433
+ "--ai-tile-name-text": f?.nameText,
434
+ "--ai-tile-type-text": f?.typeText,
435
+ "--ai-tile-hover-icon-bg": f?.hoverIconBackground,
436
+ "--ai-tile-hover-icon-color": f?.hoverIconColor,
437
+ "--ai-tile-progress-track": f?.trackBackground
438
+ }), { isImage: g, isLink: _ } = K(() => Re(e), [e]);
439
+ return g ? /* @__PURE__ */ J(Ye, {
440
+ attachment: e,
441
+ labels: l,
442
+ onClick: o,
443
+ onExpand: a,
444
+ styles: u,
445
+ onRemove: r,
446
+ cssVars: h,
447
+ onDownload: c,
448
+ isSelected: d
449
+ }) : /* @__PURE__ */ J(Ke, {
450
+ attachment: e,
451
+ searchQuery: n,
452
+ onClick: o,
453
+ onRetry: i,
454
+ onRemove: r,
455
+ onDownload: c,
456
+ isLink: _,
457
+ isPasted: p,
458
+ styles: u,
459
+ labels: l,
460
+ onExpand: a,
461
+ cssVars: h,
462
+ isExpandable: m,
463
+ isSelected: d
131
464
  });
132
- }, W = _(({ content: t, typography: n, copyAriaLabel: r = "Copy" }) => {
133
- let a = "mb-1.5 last:mb-0", o = i(n?.headingClassName ?? "dial-small-semi-text", V.stageContent, a);
134
- return /* @__PURE__ */ C(e, {
135
- content: t,
465
+ }, Ze = (e) => {
466
+ let t = l(e);
467
+ if (!e?.length) return t;
468
+ let n = /* @__PURE__ */ new Map();
469
+ for (let t of e) {
470
+ let e = t.url ?? t.data ?? t.title;
471
+ n.has(e) || n.set(e, t.type);
472
+ }
473
+ return t.map((e) => {
474
+ let t = n.get(e.id);
475
+ return t ? {
476
+ ...e,
477
+ contentType: t
478
+ } : e;
479
+ });
480
+ }, Qe = ({ children: e, codeClassName: t, blockClassName: n = "dial-code-text", copyAriaLabel: i, copiedLabel: a }) => /* @__PURE__ */ J(r, {
481
+ language: t?.replace(/^language-/, "") ?? "",
482
+ value: typeof e == "string" ? e : String(e ?? ""),
483
+ codeClassName: n,
484
+ containerClassName: c(X.codeBlock, n),
485
+ copyLabel: i,
486
+ copiedLabel: a,
487
+ hideDownload: !0
488
+ }), $e = fe(({ content: e, typography: t, copyAriaLabel: n = "Copy", copiedLabel: r, tableScrollRegionAriaLabel: a, mathScrollRegionAriaLabel: o }) => {
489
+ let s = "mb-1.5 last:mb-0", l = c(t?.headingClassName ?? "dial-small-semi-text", X.stageContent, s);
490
+ return /* @__PURE__ */ J(i, {
491
+ content: e,
492
+ tableScrollRegionAriaLabel: a,
493
+ mathScrollRegionAriaLabel: o,
136
494
  classNames: {
137
- h1: o,
138
- h2: o,
139
- h3: o,
140
- h4: o,
141
- h5: o,
142
- h6: o,
143
- p: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent, "mb-1.5"),
144
- ul: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent, a),
145
- ol: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent, a),
146
- strong: i(n?.strongClassName ?? n?.contentClassName ?? "dial-tiny-text", V.stageContent),
147
- codeInline: V.codeInline,
148
- blockquote: i(n?.contentClassName ?? "dial-tiny-text", V.blockquote, a),
149
- link: i(n?.contentClassName ?? "dial-tiny-text", V.stageContent),
150
- tableCell: i(n?.contentClassName ?? "dial-tiny-text", V.tableCell)
495
+ h1: l,
496
+ h2: l,
497
+ h3: l,
498
+ h4: l,
499
+ h5: l,
500
+ h6: l,
501
+ p: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent, "mb-1.5"),
502
+ ul: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent, s),
503
+ ol: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent, s),
504
+ strong: c(t?.strongClassName ?? t?.contentClassName ?? "dial-tiny-text", X.stageContent),
505
+ codeInline: X.codeInline,
506
+ blockquote: c(t?.contentClassName ?? "dial-tiny-text", X.blockquote, s),
507
+ link: c(t?.contentClassName ?? "dial-tiny-text", X.stageContent),
508
+ tableCell: c(t?.contentClassName ?? "dial-tiny-text", X.tableCell)
151
509
  },
152
- components: { code: ({ children: e, className: t }) => t?.includes("language-") ? /* @__PURE__ */ C(U, {
153
- codeClassName: t,
154
- blockClassName: n?.codeBlockClassName,
155
- copyAriaLabel: r,
510
+ components: { code: ({ children: e, className: i }) => i?.includes("language-") ? /* @__PURE__ */ J(Qe, {
511
+ codeClassName: i,
512
+ blockClassName: t?.codeBlockClassName,
513
+ copyAriaLabel: n,
514
+ copiedLabel: r,
156
515
  children: e
157
- }) : /* @__PURE__ */ C("code", {
158
- className: i("inline-block px-1.5 py-1", n?.codeClassName ?? "dial-code-text rounded-md", V.codeInline),
516
+ }) : /* @__PURE__ */ J("code", {
517
+ className: c("px-1 py-0.5", t?.codeClassName ?? "dial-tiny-text rounded-md", X.codeInline),
159
518
  children: e
160
519
  }) }
161
520
  });
162
- }), G = ({ stage: e, isLive: n, typography: r, labels: s, nameOverride: l }) => {
163
- let [u, d] = x(!1), { copyAriaLabel: f = "Copy stage content", runningAriaLabel: p, failedAriaLabel: g } = s ?? {}, { name: _, durationLabel: v } = N(e.name), y = l ?? _, b = !l && P(_), T = e.status === t.Failed, E = !!e.content, D = /* @__PURE__ */ w(S, { children: [
164
- /* @__PURE__ */ C("span", {
521
+ }), et = ({ attachments: e, clickLabel: t, onAttachmentClick: n }) => {
522
+ let r = W((t) => {
523
+ let r = e.find((e) => e.id === t);
524
+ r && n?.(r);
525
+ }, [e, n]);
526
+ return /* @__PURE__ */ J("div", {
527
+ role: "list",
528
+ className: "flex flex-wrap gap-3",
529
+ children: e.map((e) => /* @__PURE__ */ J("div", {
530
+ role: "listitem",
531
+ children: /* @__PURE__ */ J(Xe, {
532
+ attachment: e,
533
+ onClick: n && r,
534
+ labels: { clickLabel: t }
535
+ })
536
+ }, e.id))
537
+ });
538
+ }, tt = ({ stage: e, isLive: t, typography: n, labels: r, nameOverride: i, onAttachmentClick: a, childList: s, isExpanded: l, onToggle: u }) => {
539
+ let [f, p] = q(!1), m = l ?? f, g = W((e) => {
540
+ l === void 0 && p(e), u?.(e);
541
+ }, [l, u]), { copyAriaLabel: _ = "Copy stage content", codeBlockCopiedLabel: v, tableScrollRegionAriaLabel: y, mathScrollRegionAriaLabel: b, runningAriaLabel: x, failedAriaLabel: S, attachmentClickLabel: C = "Preview search result" } = r ?? {}, w = K(() => Ze(e.attachments), [e.attachments]), { name: T, durationLabel: E } = Se(e.name), D = i ?? T, O = !i && Ce(T), k = e.status === o.Failed, A = !!e.content || !!e.attachments?.length, j = A || s != null, M = /* @__PURE__ */ Y(he, { children: [
542
+ /* @__PURE__ */ J("span", {
165
543
  className: "flex flex-none items-center",
166
- children: /* @__PURE__ */ C(H, {
544
+ children: /* @__PURE__ */ J(Me, {
167
545
  status: e.status,
168
- isLive: n,
169
- runningLabel: p,
170
- failedLabel: g
546
+ isLive: t,
547
+ runningLabel: x,
548
+ failedLabel: S
171
549
  })
172
550
  }),
173
- /* @__PURE__ */ C("span", {
174
- className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", V.stageName, T && V.stageNameFailed, b && V.monoName),
175
- children: /* @__PURE__ */ C(c, { text: y || e.status || "" })
551
+ /* @__PURE__ */ J("span", {
552
+ className: c("min-w-0 max-w-[22rem] truncate", n?.fontClassName ?? "dial-small-text", X.stageName, k && X.stageNameFailed, O && X.monoName),
553
+ children: /* @__PURE__ */ J(h, { text: D || e.status || "" })
176
554
  }),
177
- e.tag && /* @__PURE__ */ C("span", {
178
- className: i("flex-none", r?.tagClassName ?? "dial-tiny-lead-text", V.tag),
555
+ e.tag && /* @__PURE__ */ J("span", {
556
+ className: c("flex-none", n?.tagClassName ?? "dial-tiny-lead-text", X.tag),
179
557
  children: e.tag
180
558
  }),
181
- v && /* @__PURE__ */ C("span", {
182
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", V.duration),
183
- children: v
184
- }),
185
- E && /* @__PURE__ */ C("span", {
186
- className: i("flex-none", V.iconSecondary),
187
- children: u ? /* @__PURE__ */ C(m, {
188
- size: a.SM,
189
- "aria-hidden": !0,
190
- stroke: o
191
- }) : /* @__PURE__ */ C(h, {
192
- size: a.SM,
193
- className: "rtl:scale-x-[-1]",
194
- "aria-hidden": !0,
195
- stroke: o
196
- })
559
+ E && /* @__PURE__ */ J("span", {
560
+ className: c("flex-none", n?.countFontClassName ?? "dial-tiny-text", X.duration),
561
+ children: E
197
562
  })
198
- ] }), O = i("flex w-full items-center gap-2 px-2 py-1.5", V.row);
199
- return E ? /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("div", {
200
- className: O,
201
- children: /* @__PURE__ */ C("button", {
202
- type: "button",
203
- onClick: () => d((e) => !e),
204
- "aria-expanded": u,
205
- className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-start",
206
- children: D
207
- })
208
- }), /* @__PURE__ */ C("div", {
209
- className: i("grid overflow-hidden transition-[grid-template-rows] duration-[250ms] ease-in-out", u ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
210
- children: /* @__PURE__ */ C("div", {
211
- className: "overflow-hidden",
212
- children: /* @__PURE__ */ C("div", {
213
- className: "mt-2 flex flex-col gap-3 py-1 ps-8",
214
- children: e.content && /* @__PURE__ */ C("div", {
215
- className: "max-h-[300px] overflow-y-auto",
216
- children: /* @__PURE__ */ C(W, {
217
- content: e.content,
218
- typography: r,
219
- copyAriaLabel: f
220
- })
563
+ ] });
564
+ return j ? /* @__PURE__ */ Y(d, {
565
+ expanded: m,
566
+ onToggle: g,
567
+ title: /* @__PURE__ */ J("span", {
568
+ className: "flex min-w-0 items-center gap-2",
569
+ children: M
570
+ }),
571
+ className: ke,
572
+ headerClassName: c(Ae, X.row, X.stageHeader),
573
+ contentClassName: c("-mt-1 flex min-w-0 flex-col gap-3 px-0 py-1", X.stageRegion),
574
+ children: [m && A && /* @__PURE__ */ Y("div", {
575
+ className: "flex min-w-0 flex-col gap-3 ps-8",
576
+ children: [e.content && /* @__PURE__ */ J("div", {
577
+ className: "max-h-[300px] min-w-0 overflow-y-auto",
578
+ children: /* @__PURE__ */ J($e, {
579
+ content: e.content,
580
+ typography: n,
581
+ copyAriaLabel: _,
582
+ copiedLabel: v,
583
+ tableScrollRegionAriaLabel: y,
584
+ mathScrollRegionAriaLabel: b
221
585
  })
222
- })
223
- })
224
- })] }) : /* @__PURE__ */ C("div", {
225
- className: O,
226
- children: D
586
+ }), w.length > 0 && /* @__PURE__ */ J(et, {
587
+ attachments: w,
588
+ clickLabel: C,
589
+ onAttachmentClick: a
590
+ })]
591
+ }), m && s]
592
+ }) : /* @__PURE__ */ J("div", {
593
+ className: c("flex w-full items-center gap-2 px-2 py-1.5", X.row),
594
+ children: M
227
595
  });
228
- }, K = ({ row: e, isLive: n, typography: r, labels: s }) => {
229
- let { runningAriaLabel: l, failedAriaLabel: u, attemptLabel: d = (e) => `Attempt ${e}` } = s ?? {}, [f, p] = x(!1), g = e.attempts?.some((e) => e.status == null) ?? !1, _ = e.attempts?.some((e) => e.status === t.Failed), v = g ? null : _ ? t.Failed : t.Completed, y = L((e.attempts || []).map((e) => e.name)), b = y > 0 ? F(y) : void 0;
230
- return /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ w("button", {
231
- type: "button",
232
- onClick: () => p((e) => !e),
233
- "aria-expanded": f,
234
- className: i("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start", V.collapseButton, V.row),
235
- children: [
236
- /* @__PURE__ */ C("span", {
237
- className: "flex flex-none items-center",
238
- children: /* @__PURE__ */ C(H, {
239
- status: v,
240
- isLive: n,
241
- runningLabel: l,
242
- failedLabel: u
243
- })
244
- }),
245
- /* @__PURE__ */ C("span", {
246
- className: i("min-w-0 max-w-[22rem] truncate", r?.fontClassName ?? "dial-small-text", V.stageName, _ && V.stageNameFailed),
247
- children: /* @__PURE__ */ C(c, { text: e.name })
248
- }),
249
- /* @__PURE__ */ w("span", {
250
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", V.count),
251
- children: ["×", e.attempts?.length ?? 0]
252
- }),
253
- b && /* @__PURE__ */ C("span", {
254
- className: i("flex-none", r?.countFontClassName ?? "dial-tiny-text", V.duration),
255
- children: b
256
- }),
257
- /* @__PURE__ */ C("span", {
258
- className: i("flex-none", V.iconSecondary),
259
- children: f ? /* @__PURE__ */ C(m, {
260
- size: a.SM,
261
- "aria-hidden": !0,
262
- stroke: o
263
- }) : /* @__PURE__ */ C(h, {
264
- size: a.SM,
265
- className: "rtl:scale-x-[-1]",
266
- "aria-hidden": !0,
267
- stroke: o
268
- })
269
- })
270
- ]
271
- }), /* @__PURE__ */ C("div", {
272
- className: i("grid overflow-hidden transition-[grid-template-rows] duration-[250ms] ease-in-out", f ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
273
- children: /* @__PURE__ */ C("div", {
274
- className: "overflow-hidden",
275
- children: /* @__PURE__ */ C("ul", {
276
- role: "list",
277
- className: "mt-1 flex flex-col gap-0.5 ps-6",
278
- children: e.attempts?.map((e, t) => /* @__PURE__ */ C("li", {
279
- role: "listitem",
280
- children: /* @__PURE__ */ C(G, {
281
- stage: e,
282
- nameOverride: d(t + 1),
283
- isLive: n && e.status == null,
284
- typography: r,
285
- labels: s
596
+ }, nt = (e) => e <= 3 ? "ps-4" : "ps-0", rt = (e) => e <= 3 ? "ps-6" : "ps-0", it = ({ node: e, depth: t, nameOverride: n, isStreaming: r, expansion: i, typography: a, labels: o, onAttachmentClick: s }) => {
597
+ let c = De(e.stage.index), l = t + 1;
598
+ return /* @__PURE__ */ J(tt, {
599
+ stage: e.stage,
600
+ nameOverride: n,
601
+ isLive: r && e.stage.status == null,
602
+ typography: a,
603
+ labels: o,
604
+ onAttachmentClick: s,
605
+ isExpanded: i.isExpanded(c),
606
+ onToggle: (e) => i.onToggle(c, e),
607
+ childList: e.children.length > 0 ? /* @__PURE__ */ J(ot, {
608
+ nodes: e.children,
609
+ depth: l,
610
+ className: nt(l),
611
+ isStreaming: r,
612
+ expansion: i,
613
+ typography: a,
614
+ labels: o,
615
+ onAttachmentClick: s
616
+ }) : void 0
617
+ });
618
+ }, at = ({ row: e, depth: t, isStreaming: n, expansion: r, typography: i, labels: a, onAttachmentClick: s }) => {
619
+ let { runningAriaLabel: l, failedAriaLabel: u, attemptLabel: f = (e) => `Attempt ${e}` } = a ?? {}, p = e.attempts ?? [], m = p.some((e) => e.stage.status == null), g = p.some((e) => e.stage.status === o.Failed), _ = o.Completed;
620
+ m ? _ = null : g && (_ = o.Failed);
621
+ let v = Oe(e.key), y = r.isExpanded(v), b = t + 1;
622
+ return /* @__PURE__ */ J(d, {
623
+ title: /* @__PURE__ */ Y("span", {
624
+ className: "flex min-w-0 items-center gap-2",
625
+ children: [
626
+ /* @__PURE__ */ J("span", {
627
+ className: "flex flex-none items-center",
628
+ children: /* @__PURE__ */ J(Me, {
629
+ status: _,
630
+ isLive: n && m,
631
+ runningLabel: l,
632
+ failedLabel: u
286
633
  })
287
- }, e.index))
288
- })
289
- })
290
- })] });
291
- }, q = ({ stages: e, isStreaming: t, className: r, styles: a, labels: o }) => {
292
- let { colors: s, typography: c } = a ?? {}, l = n({
293
- "--cs-text": s?.text,
294
- "--cs-row-hover": s?.rowHoverColor,
295
- "--cs-button-bg": s?.collapsedButtonBg,
296
- "--cs-stage-text": s?.stageTextColor,
297
- "--cs-failed-text": s?.failedColor,
298
- "--cs-tag-text": s?.tagTextColor,
299
- "--cs-count-text": s?.countTextColor,
300
- "--cs-duration-text": s?.durationTextColor,
301
- "--cs-icon-secondary": s?.iconSecondaryColor,
302
- "--cs-icon-completed": s?.iconCompletedColor,
303
- "--cs-icon-error": s?.iconErrorColor,
304
- "--cs-code-bg": s?.codeBg,
305
- "--cs-code-border": s?.codeBorderColor,
306
- "--cs-code-text": s?.codeTextColor,
307
- "--cs-border": s?.borderColor
308
- }), u = B(e);
309
- return /* @__PURE__ */ C("div", {
310
- style: l,
311
- className: i("w-full", V.panel, r),
312
- children: /* @__PURE__ */ C("ul", {
313
- role: "list",
314
- className: "flex w-full flex-col gap-0.5 ps-5",
315
- children: u.map((e) => e.stage ? /* @__PURE__ */ C("li", {
316
- role: "listitem",
317
- children: /* @__PURE__ */ C(G, {
318
- stage: e.stage,
319
- isLive: t && e.stage.status == null,
320
- typography: c,
321
- labels: o
634
+ }),
635
+ /* @__PURE__ */ J("span", {
636
+ className: c("min-w-0 max-w-[22rem] truncate", i?.fontClassName ?? "dial-small-text", X.stageName, g && X.stageNameFailed),
637
+ children: /* @__PURE__ */ J(h, { text: e.name })
638
+ }),
639
+ /* @__PURE__ */ Y("span", {
640
+ className: c("flex-none", i?.countFontClassName ?? "dial-tiny-text", X.count),
641
+ children: ["×", p.length]
322
642
  })
323
- }, e.key) : /* @__PURE__ */ C("li", {
643
+ ]
644
+ }),
645
+ expanded: y,
646
+ onToggle: (e) => r.onToggle(v, e),
647
+ className: ke,
648
+ headerClassName: c(Ae, X.collapseButton, X.row, X.stageHeader),
649
+ contentClassName: c("-mt-2 min-w-0 px-0", rt(b), X.stageRegion),
650
+ children: /* @__PURE__ */ J("ul", {
651
+ role: "list",
652
+ className: "flex min-w-0 flex-col gap-0.5",
653
+ children: y && p.map((e, t) => /* @__PURE__ */ J("li", {
324
654
  role: "listitem",
325
- children: /* @__PURE__ */ C(K, {
326
- row: e,
327
- isLive: t && (e.attempts?.some((e) => e.status == null) ?? !1),
328
- typography: c,
329
- labels: o
655
+ className: "min-w-0",
656
+ children: /* @__PURE__ */ J(it, {
657
+ node: e,
658
+ depth: b,
659
+ nameOverride: f(t + 1),
660
+ isStreaming: n,
661
+ expansion: r,
662
+ typography: i,
663
+ labels: a,
664
+ onAttachmentClick: s
330
665
  })
331
- }, e.key))
666
+ }, e.stage.index))
332
667
  })
333
668
  });
334
- }, J = {
335
- toggleButton: "_toggleButton_1sa5v_1",
336
- executedLabel: "_executedLabel_1sa5v_13",
337
- stepsCount: "_stepsCount_1sa5v_17",
338
- doneIcon: "_doneIcon_1sa5v_22",
339
- failedText: "_failedText_1sa5v_26",
340
- liveName: "_liveName_1sa5v_30"
341
- }, Y = ({ stages: e, isStreaming: r, labels: s, className: l, styles: f }) => {
342
- let { executedLabel: g = "Executed", stepsLabel: _ = () => "steps", failedCountLabel: v = (e) => `${e} failed`, runningStepLabel: S = (e, t) => `Step ${e} of ${t}`, runningAriaLabel: T = "Running", copyAriaLabel: E, failedAriaLabel: D, attemptLabel: O } = s ?? {}, [k, A] = x(r), j = b(r);
343
- y(() => {
344
- j.current && !r && A(!1), j.current = r;
345
- }, [r]);
346
- let { colors: M, panel: P } = f ?? {}, I = f?.typography ?? { fontClassName: "dial-small-text" }, B = n({
669
+ }, ot = ({ nodes: e, depth: t, className: n, ...r }) => /* @__PURE__ */ J("ul", {
670
+ role: "list",
671
+ className: c("flex min-w-0 flex-col gap-0.5", n),
672
+ children: je(e).map((e) => /* @__PURE__ */ J("li", {
673
+ role: "listitem",
674
+ className: "min-w-0",
675
+ children: e.node ? /* @__PURE__ */ J(it, {
676
+ node: e.node,
677
+ depth: t,
678
+ ...r
679
+ }) : /* @__PURE__ */ J(at, {
680
+ row: e,
681
+ depth: t,
682
+ ...r
683
+ })
684
+ }, e.key))
685
+ }), st = ({ stages: e, isStreaming: t, className: n, styles: r, labels: i, onAttachmentClick: a, expansion: o }) => {
686
+ let { colors: l, typography: u } = r ?? {}, d = s({
687
+ "--cs-text": l?.text,
688
+ "--cs-row-hover": l?.rowHoverColor,
689
+ "--cs-button-bg": l?.collapsedButtonBg,
690
+ "--cs-stage-text": l?.stageTextColor,
691
+ "--cs-failed-text": l?.failedColor,
692
+ "--cs-tag-text": l?.tagTextColor,
693
+ "--cs-count-text": l?.countTextColor,
694
+ "--cs-duration-text": l?.durationTextColor,
695
+ "--cs-icon-secondary": l?.iconSecondaryColor,
696
+ "--cs-icon-completed": l?.iconCompletedColor,
697
+ "--cs-icon-error": l?.iconErrorColor,
698
+ "--cs-code-bg": l?.codeBg,
699
+ "--cs-code-border": l?.codeBorderColor,
700
+ "--cs-code-text": l?.codeTextColor,
701
+ "--cs-border": l?.borderColor
702
+ }), f = K(() => Ee(e), [e]);
703
+ return /* @__PURE__ */ J("div", {
704
+ style: d,
705
+ className: c("w-full min-w-0", X.panel, n, ge.panel),
706
+ children: /* @__PURE__ */ J(ot, {
707
+ nodes: f,
708
+ depth: 0,
709
+ className: "w-full ps-5",
710
+ isStreaming: t,
711
+ expansion: o,
712
+ typography: u,
713
+ labels: i,
714
+ onAttachmentClick: a
715
+ })
716
+ });
717
+ }, ct = (e) => {
718
+ let t = _e();
719
+ return /* @__PURE__ */ J(st, {
720
+ ...e,
721
+ expansion: t
722
+ });
723
+ }, $ = {
724
+ toggleButton: "_toggleButton_16fae_7",
725
+ groupRegion: "_groupRegion_16fae_28",
726
+ executedLabel: "_executedLabel_16fae_32",
727
+ doneIcon: "_doneIcon_16fae_36",
728
+ failedText: "_failedText_16fae_40",
729
+ liveName: "_liveName_16fae_44"
730
+ }, lt = ({ stages: e, isStreaming: t, labels: n, className: r, styles: i, onAttachmentClick: a }) => {
731
+ let { executedLabel: l = "Executed", stepsLabel: u = () => "steps", failedCountLabel: m = (e) => `${e} failed`, runningAriaLabel: g = "Running", copyAriaLabel: _, codeBlockCopiedLabel: v, tableScrollRegionAriaLabel: b, mathScrollRegionAriaLabel: x, failedAriaLabel: C, attemptLabel: w, attachmentClickLabel: T } = n ?? {}, [E, D] = q(t), O = _e(), { reset: k } = O, A = e.length > 1;
732
+ G(() => {
733
+ A && !E && k();
734
+ }, [
735
+ A,
736
+ E,
737
+ k
738
+ ]);
739
+ let j = me(t);
740
+ G(() => {
741
+ j.current && !t && D(!1), j.current = t;
742
+ }, [t]);
743
+ let { colors: M, panel: N } = i ?? {}, P = i?.typography ?? { fontClassName: "dial-small-text" }, F = s({
347
744
  "--cs-cg-label": M?.labelColor,
348
745
  "--cs-cg-label-hover": M?.labelHoverColor,
349
- "--cs-cg-steps-count": M?.stepsCountColor,
350
746
  "--cs-cg-done": M?.doneColor,
351
747
  "--cs-cg-failed": M?.failedColor,
352
- "--cs-text": P?.text,
353
- "--cs-row-hover": P?.rowHoverColor,
354
- "--cs-button-bg": P?.collapsedButtonBg,
355
- "--cs-stage-text": P?.stageTextColor,
356
- "--cs-failed-text": P?.failedColor,
357
- "--cs-tag-text": P?.tagTextColor,
358
- "--cs-count-text": P?.countTextColor,
359
- "--cs-duration-text": P?.durationTextColor,
360
- "--cs-icon-secondary": P?.iconSecondaryColor,
361
- "--cs-icon-completed": P?.iconCompletedColor,
362
- "--cs-icon-error": P?.iconErrorColor,
363
- "--cs-code-bg": P?.codeBg,
364
- "--cs-code-border": P?.codeBorderColor,
365
- "--cs-code-text": P?.codeTextColor,
366
- "--cs-border": P?.borderColor
748
+ "--cs-text": N?.text,
749
+ "--cs-row-hover": N?.rowHoverColor,
750
+ "--cs-button-bg": N?.collapsedButtonBg,
751
+ "--cs-stage-text": N?.stageTextColor,
752
+ "--cs-failed-text": N?.failedColor,
753
+ "--cs-tag-text": N?.tagTextColor,
754
+ "--cs-count-text": N?.countTextColor,
755
+ "--cs-duration-text": N?.durationTextColor,
756
+ "--cs-icon-secondary": N?.iconSecondaryColor,
757
+ "--cs-icon-completed": N?.iconCompletedColor,
758
+ "--cs-icon-error": N?.iconErrorColor,
759
+ "--cs-code-bg": N?.codeBg,
760
+ "--cs-code-border": N?.codeBorderColor,
761
+ "--cs-code-text": N?.codeTextColor,
762
+ "--cs-border": N?.borderColor
367
763
  });
368
764
  if (e.length === 0) return null;
369
- let V = {
370
- copyAriaLabel: E,
371
- runningAriaLabel: T,
372
- failedAriaLabel: D,
373
- attemptLabel: O
765
+ let I = {
766
+ copyAriaLabel: _,
767
+ codeBlockCopiedLabel: v,
768
+ tableScrollRegionAriaLabel: b,
769
+ mathScrollRegionAriaLabel: x,
770
+ runningAriaLabel: g,
771
+ failedAriaLabel: C,
772
+ attemptLabel: w,
773
+ attachmentClickLabel: T
374
774
  };
375
- if (e.length === 1) return /* @__PURE__ */ C(q, {
775
+ if (e.length === 1) return /* @__PURE__ */ J(st, {
376
776
  stages: e,
377
- isStreaming: r,
378
- className: l,
777
+ isStreaming: t,
778
+ expansion: O,
779
+ className: r,
379
780
  styles: {
380
- colors: P,
381
- typography: f?.typography
781
+ colors: N,
782
+ typography: i?.typography
382
783
  },
383
- labels: V
784
+ labels: I,
785
+ onAttachmentClick: a
384
786
  });
385
- let H = e.some((e) => e.status === t.Failed), U = L(e.map((e) => e.name)), W = U > 0 ? F(U) : void 0, G = r ? R(e) : void 0, K;
386
- if (r) {
387
- let t = G ? z(e, G) : e.length, n = G ? N(G.name).name : "";
388
- K = /* @__PURE__ */ w("span", {
787
+ let L = e.some((e) => e.status === o.Failed), R;
788
+ if (t) {
789
+ let t = Se((we(e) ?? e[e.length - 1]).name).name;
790
+ R = /* @__PURE__ */ Y("span", {
389
791
  role: "status",
390
792
  "aria-live": "polite",
391
793
  className: "flex min-w-0 items-center gap-2",
392
- children: [
393
- /* @__PURE__ */ C("span", {
394
- className: "flex flex-none items-center",
395
- children: /* @__PURE__ */ C(d, {
396
- size: 14,
397
- ariaLabel: T
398
- })
399
- }),
400
- /* @__PURE__ */ C("span", {
401
- className: i("flex-none whitespace-nowrap", I.fontClassName, J.liveName),
402
- children: S(t, e.length)
403
- }),
404
- n && /* @__PURE__ */ C("span", {
405
- className: i("min-w-0 max-w-[22rem] truncate", I.fontClassName, J.executedLabel),
406
- children: /* @__PURE__ */ C(c, { text: n })
794
+ children: [/* @__PURE__ */ J("span", {
795
+ className: "flex flex-none items-center",
796
+ children: /* @__PURE__ */ J(y, {
797
+ size: 14,
798
+ ariaLabel: g
407
799
  })
408
- ]
800
+ }), t && /* @__PURE__ */ J("span", {
801
+ className: c("min-w-0 max-w-[22rem] truncate", P.fontClassName, $.liveName),
802
+ children: /* @__PURE__ */ J(h, { text: t })
803
+ })]
409
804
  });
410
- } else if (H) {
411
- let n = e.filter((e) => e.status === t.Failed).length;
412
- K = /* @__PURE__ */ w("span", {
805
+ } else if (L) {
806
+ let t = e.filter((e) => e.status === o.Failed).length;
807
+ R = /* @__PURE__ */ Y("span", {
413
808
  className: "inline-flex items-center gap-1",
414
- children: [
415
- /* @__PURE__ */ w("span", {
416
- className: i(I.fontClassName, J.executedLabel),
417
- children: [
418
- g,
419
- " ",
420
- e.length,
421
- " ",
422
- _(e.length)
423
- ]
424
- }),
425
- /* @__PURE__ */ C("span", {
426
- className: i(I.fontClassName, J.failedText),
427
- children: v(n)
428
- }),
429
- W && /* @__PURE__ */ C("span", {
430
- className: i(I.fontClassName, J.stepsCount),
431
- children: W
432
- })
433
- ]
434
- });
435
- } else K = /* @__PURE__ */ w("span", {
436
- className: "inline-flex items-center gap-1",
437
- children: [
438
- /* @__PURE__ */ C(p, {
439
- size: a.SM,
440
- className: J.doneIcon,
441
- "aria-hidden": !0,
442
- stroke: o
443
- }),
444
- /* @__PURE__ */ w("span", {
445
- className: i(I.fontClassName, J.executedLabel),
809
+ children: [/* @__PURE__ */ Y("span", {
810
+ className: c(P.fontClassName, $.executedLabel),
446
811
  children: [
447
- g,
812
+ l,
448
813
  " ",
449
814
  e.length,
450
815
  " ",
451
- _(e.length)
816
+ u(e.length)
452
817
  ]
453
- }),
454
- W && /* @__PURE__ */ C("span", {
455
- className: i(I.fontClassName, J.stepsCount),
456
- children: W
457
- })
458
- ]
818
+ }), /* @__PURE__ */ J("span", {
819
+ className: c(P.fontClassName, $.failedText),
820
+ children: m(t)
821
+ })]
822
+ });
823
+ } else R = /* @__PURE__ */ Y("span", {
824
+ className: "inline-flex items-center gap-1",
825
+ children: [/* @__PURE__ */ J(S, {
826
+ size: f.SM,
827
+ className: $.doneIcon,
828
+ "aria-hidden": !0,
829
+ stroke: p
830
+ }), /* @__PURE__ */ Y("span", {
831
+ className: c(P.fontClassName, $.executedLabel),
832
+ children: [
833
+ l,
834
+ " ",
835
+ e.length,
836
+ " ",
837
+ u(e.length)
838
+ ]
839
+ })]
459
840
  });
460
- return /* @__PURE__ */ w("div", {
461
- style: B,
462
- className: i("flex w-full flex-col gap-1", l),
463
- children: [/* @__PURE__ */ C(u, {
464
- className: J.toggleButton,
465
- textClassName: "min-w-0",
466
- onClick: () => A((e) => !e),
467
- "aria-expanded": k,
468
- iconAfter: k ? /* @__PURE__ */ C(m, {
469
- size: 12,
470
- "aria-hidden": !0,
471
- stroke: o
472
- }) : /* @__PURE__ */ C(h, {
473
- size: 12,
474
- className: "rtl:scale-x-[-1]",
475
- "aria-hidden": !0,
476
- stroke: o
477
- }),
478
- label: K
479
- }), /* @__PURE__ */ C("div", {
480
- className: i("grid transition-[grid-template-rows] duration-300 ease-in-out", k ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
481
- children: /* @__PURE__ */ C("div", {
482
- className: "overflow-hidden",
483
- children: /* @__PURE__ */ C(q, {
484
- stages: e,
485
- isStreaming: r,
486
- styles: {
487
- colors: P,
488
- typography: f?.typography
489
- },
490
- labels: V,
491
- className: "pt-1"
492
- })
841
+ return /* @__PURE__ */ J("div", {
842
+ style: F,
843
+ className: c("flex w-full flex-col gap-1", r, ge.group),
844
+ children: /* @__PURE__ */ J(d, {
845
+ title: R,
846
+ expanded: E,
847
+ onToggle: D,
848
+ className: "overflow-visible py-0",
849
+ headerClassName: c("justify-start gap-1 rounded-none px-0", $.toggleButton, ge.groupToggle),
850
+ contentClassName: c("-mt-2 px-0", $.groupRegion),
851
+ children: E && /* @__PURE__ */ J(st, {
852
+ stages: e,
853
+ isStreaming: t,
854
+ expansion: O,
855
+ styles: {
856
+ colors: N,
857
+ typography: i?.typography
858
+ },
859
+ labels: I,
860
+ className: "pt-1",
861
+ onAttachmentClick: a
493
862
  })
494
- })]
863
+ })
495
864
  });
496
865
  };
497
866
  //#endregion
498
- export { Y as CollapsedGroup, q as StagesPanel };
867
+ export { ge as CONVERSATION_STAGES_CLASS, lt as CollapsedGroup, ct as StagesPanel };