@epam/ai-dial-conversation-stages 1.2.0-dev.21 → 1.2.0-dev.213

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