@epam/ai-dial-conversation-stages 1.2.0-dev.28 → 1.2.0-dev.284

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