@mechane-ai/elements 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ai.js CHANGED
@@ -5,62 +5,68 @@ import { c as f, d as p } from "./src-BVsyKLQ8.js";
5
5
  import { c as m, u as h } from "./src-R0kgHFPZ.js";
6
6
  import { t as g } from "./accessibility-C-aIZ1Yx.js";
7
7
  import * as _ from "@stylexjs/stylex";
8
- import { createContext as v, useContext as y, useId as b, useRef as x } from "react";
9
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
10
- import { ArrowDown as w, ArrowUp as T, File as E, GitBranch as D, Square as O } from "lucide-react";
11
- import { MessageScroller as k, useMessageScroller as A, useMessageScrollerScrollable as j } from "@shadcn/react/message-scroller";
8
+ import { createContext as v, useContext as y, useId as b, useLayoutEffect as x, useRef as S, useState as C } from "react";
9
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
10
+ import { ArrowDown as E, ArrowUp as D, File as O, GitBranch as k, Square as A } from "lucide-react";
11
+ import { MessageScroller as j, useMessageScroller as M, useMessageScrollerScrollable as N } from "@shadcn/react/message-scroller";
12
12
  // packages/ai/src/approval.tsx
13
- function M(t) {
14
- return /* @__PURE__ */ C("section", {
13
+ function P(t) {
14
+ return /* @__PURE__ */ T("section", {
15
15
  "aria-label": t.title,
16
16
  "data-request-id": t.requestId,
17
17
  className: "x78zum5 xdt5ytf x1n8ia3y xeuugli x1c8xbx5 xmkeg23 x1y0btm7 x1ey3b81 x1ok0vyi xpvm0e4 xbixft x1hz01jw xtqrqnz x1778rvt xj57cvi",
18
18
  children: [
19
- /* @__PURE__ */ S("h3", {
19
+ /* @__PURE__ */ w("h3", {
20
20
  className: "x1ghz6dp xtqrqnz x1778rvt xk4h15q xj0a0fe",
21
21
  children: t.title
22
22
  }),
23
- t.description !== void 0 && /* @__PURE__ */ S("p", {
23
+ t.description !== void 0 && /* @__PURE__ */ w("p", {
24
24
  className: "x1ghz6dp x153jb6y xj0a0fe",
25
25
  children: t.description
26
26
  }),
27
27
  t.children,
28
- t.status === "pending" ? /* @__PURE__ */ C(i, { children: [/* @__PURE__ */ S(e, {
28
+ t.status === "pending" ? /* @__PURE__ */ T(i, { children: [/* @__PURE__ */ w(e, {
29
29
  variant: "solid",
30
30
  onClick: t.onApprove,
31
31
  disabled: t.isDisabled === !0 || t.busy !== void 0,
32
32
  isPending: t.busy === "approve",
33
33
  pendingLabel: "Approving…",
34
34
  children: t.approveLabel ?? "Approve"
35
- }), /* @__PURE__ */ S(e, {
35
+ }), /* @__PURE__ */ w(e, {
36
36
  onClick: t.onDeny,
37
37
  disabled: t.isDisabled === !0 || t.busy !== void 0,
38
38
  isPending: t.busy === "deny",
39
39
  pendingLabel: "Denying…",
40
40
  children: t.denyLabel ?? "Deny"
41
- })] }) : /* @__PURE__ */ S(s, { children: t.statusLabel })
41
+ })] }) : /* @__PURE__ */ w(s, { children: t.statusLabel })
42
42
  ]
43
43
  });
44
44
  }
45
45
  // packages/ai/src/conversation.tsx
46
- var N = v(void 0);
47
- function P({ children: e, initialPosition: t = "end", shouldFollow: n = !0, viewportRef: r }) {
48
- let i = x(null), a = r ?? i;
49
- return /* @__PURE__ */ S(N.Provider, {
46
+ var F = v(void 0);
47
+ function I({ children: e, initialPosition: t = "end", shouldFollow: n = !0, viewportRef: r }) {
48
+ let i = S(null), a = r ?? i, [o] = C(t);
49
+ return x(() => {
50
+ typeof o == "object" && a.current?.scrollTo({
51
+ top: o.top,
52
+ left: o.left ?? 0,
53
+ behavior: "instant"
54
+ });
55
+ }, [o, a]), /* @__PURE__ */ w(F.Provider, {
50
56
  value: a,
51
- children: /* @__PURE__ */ S(k.Provider, {
57
+ children: /* @__PURE__ */ w(j.Provider, {
52
58
  autoScroll: n,
53
- defaultScrollPosition: t,
54
- children: /* @__PURE__ */ S(k.Root, {
59
+ defaultScrollPosition: typeof o == "object" ? "start" : o,
60
+ children: /* @__PURE__ */ w(j.Root, {
55
61
  className: "x1n2onr6 x78zum5 xdt5ytf x5yr21d x2lwn1j xeuugli xpvm0e4 xbixft x1hz01jw xtqrqnz x1778rvt xj57cvi",
56
62
  children: e
57
63
  })
58
64
  })
59
65
  });
60
66
  }
61
- function F({ label: e, children: t, scrollRestorationId: n }) {
62
- let r = y(N);
63
- return /* @__PURE__ */ S(k.Viewport, {
67
+ function L({ label: e, children: t, scrollRestorationId: n }) {
68
+ let r = y(F);
69
+ return /* @__PURE__ */ w(j.Viewport, {
64
70
  ref: r,
65
71
  "aria-label": e,
66
72
  "data-scroll-restoration-id": n,
@@ -68,8 +74,8 @@ function F({ label: e, children: t, scrollRestorationId: n }) {
68
74
  children: t
69
75
  });
70
76
  }
71
- function I({ children: e, isStreaming: t = !1 }) {
72
- return /* @__PURE__ */ S(k.Content, {
77
+ function R({ children: e, isStreaming: t = !1 }) {
78
+ return /* @__PURE__ */ w(j.Content, {
73
79
  "aria-live": "polite",
74
80
  "aria-relevant": "additions",
75
81
  "aria-busy": t,
@@ -77,50 +83,50 @@ function I({ children: e, isStreaming: t = !1 }) {
77
83
  children: e
78
84
  });
79
85
  }
80
- function L({ messageId: e, children: t }) {
81
- return /* @__PURE__ */ S(k.Item, {
86
+ function z({ messageId: e, children: t }) {
87
+ return /* @__PURE__ */ w(j.Item, {
82
88
  messageId: e,
83
89
  className: "xeuugli xj0a0fe",
84
90
  children: t
85
91
  });
86
92
  }
87
- function R({ children: e }) {
88
- return /* @__PURE__ */ S("div", {
93
+ function B({ children: e }) {
94
+ return /* @__PURE__ */ w("div", {
89
95
  className: "x9f619 x2lah0s xeuugli xh8yej3 xe10afn xvueqy4 xn9t2bk x1m92p3w",
90
96
  children: e
91
97
  });
92
98
  }
93
- function z({ label: e = "Jump to latest" }) {
94
- let { end: t } = j();
95
- return t ? /* @__PURE__ */ S("div", {
99
+ function V({ label: e = "Jump to latest" }) {
100
+ let { end: t } = N();
101
+ return t ? /* @__PURE__ */ w("div", {
96
102
  className: "x10l6tqk xwthv0x x1nrll8i xuuh30 x1tv4vx4 xeuugli",
97
- children: /* @__PURE__ */ S(B, { label: e })
103
+ children: /* @__PURE__ */ w(H, { label: e })
98
104
  }) : null;
99
105
  }
100
- function B({ label: t, onActivate: n }) {
101
- let { scrollToEnd: r } = A(), i = y(N);
102
- return /* @__PURE__ */ C(e, {
106
+ function H({ label: t, onActivate: n }) {
107
+ let { scrollToEnd: r } = M(), i = y(F);
108
+ return /* @__PURE__ */ T(e, {
103
109
  onClick: () => {
104
110
  n?.(), requestAnimationFrame(() => {
105
111
  let e = i?.current;
106
112
  e != null && (r({ behavior: "instant" }), e.focus({ preventScroll: !0 }));
107
113
  });
108
114
  },
109
- children: [/* @__PURE__ */ S(w, {
115
+ children: [/* @__PURE__ */ w(E, {
110
116
  size: 14,
111
117
  "aria-hidden": !0
112
118
  }), t]
113
119
  });
114
120
  }
115
- var V = {
116
- Root: P,
117
- Viewport: F,
118
- Content: I,
119
- Item: L,
120
- Controls: R,
121
- LatestButton: B,
122
- JumpToLatest: z
123
- }, H = {
121
+ var U = {
122
+ Root: I,
123
+ Viewport: L,
124
+ Content: R,
125
+ Item: z,
126
+ Controls: B,
127
+ LatestButton: H,
128
+ JumpToLatest: V
129
+ }, W = {
124
130
  root: {
125
131
  k1xSpc: "x78zum5",
126
132
  kXwgrk: "xdt5ytf",
@@ -146,72 +152,72 @@ var V = {
146
152
  k8WAf4: "xn9t2bk",
147
153
  $$css: !0
148
154
  }
149
- }, U = {
150
- user: H.user,
151
- assistant: H.assistant,
152
- system: H.system
153
- }, W = {
155
+ }, G = {
156
+ user: W.user,
157
+ assistant: W.assistant,
158
+ system: W.system
159
+ }, K = {
154
160
  "x-default-marker": "x-default-marker",
155
161
  $$css: !0
156
162
  };
157
- function G({ author: e, children: t, id: n, kind: r = "assistant", meta: i, avatar: a, actions: o, attachments: s }) {
158
- return /* @__PURE__ */ C("article", {
163
+ function q({ author: e, children: t, id: n, kind: r = "assistant", meta: i, avatar: a, actions: o, attachments: s }) {
164
+ return /* @__PURE__ */ T("article", {
159
165
  id: n,
160
166
  "aria-label": e,
161
- ..._.props(H.root, U[r], W),
167
+ ..._.props(W.root, G[r], K),
162
168
  children: [
163
- /* @__PURE__ */ C("header", {
169
+ /* @__PURE__ */ T("header", {
164
170
  className: "x78zum5 x6s0dn4 x1hnptsi x1a02dak xeuugli",
165
171
  children: [
166
- a !== void 0 && /* @__PURE__ */ S("span", {
172
+ a !== void 0 && /* @__PURE__ */ w("span", {
167
173
  className: "x3nfvp2 x2lah0s",
168
174
  children: a
169
175
  }),
170
- /* @__PURE__ */ S("span", {
176
+ /* @__PURE__ */ w("span", {
171
177
  className: "xk4h15q xeuugli xj0a0fe",
172
178
  children: e
173
179
  }),
174
- i !== void 0 && /* @__PURE__ */ S("div", {
180
+ i !== void 0 && /* @__PURE__ */ w("div", {
175
181
  className: "x153jb6y xy8obcc xas2l8k xeuugli xj0a0fe",
176
182
  children: i
177
183
  })
178
184
  ]
179
185
  }),
180
- /* @__PURE__ */ S("div", {
186
+ /* @__PURE__ */ w("div", {
181
187
  className: "xeuugli xj0a0fe x1ytb0s6",
182
188
  children: t
183
189
  }),
184
- s !== void 0 && /* @__PURE__ */ S("div", {
190
+ s !== void 0 && /* @__PURE__ */ w("div", {
185
191
  className: "x78zum5 x1a02dak x1qjc9v5 x1hnptsi xeuugli",
186
192
  children: s
187
193
  }),
188
- o !== void 0 && /* @__PURE__ */ S("footer", {
194
+ o !== void 0 && /* @__PURE__ */ w("footer", {
189
195
  className: "x78zum5 x1a02dak x6s0dn4 xeuugli xunmzkg x1hc1fzr x12vu8c0 xtf8l8m x1thm12b",
190
196
  children: o
191
197
  })
192
198
  ]
193
199
  });
194
200
  }
195
- function K({ name: e, description: t, href: n, actions: r }) {
196
- return /* @__PURE__ */ C("div", {
201
+ function J({ name: e, description: t, href: n, actions: r }) {
202
+ return /* @__PURE__ */ T("div", {
197
203
  className: "x78zum5 x1a02dak x6s0dn4 x1n8ia3y xeuugli x193iq5w x1mvvolr xmkeg23 x1y0btm7 x1ey3b81 x1ok0vyi xpvm0e4 x1hz01jw xtqrqnz x1778rvt xj57cvi",
198
204
  children: [
199
- /* @__PURE__ */ S(E, {
205
+ /* @__PURE__ */ w(O, {
200
206
  size: 16,
201
207
  "aria-hidden": !0,
202
208
  className: "x153jb6y x2lah0s"
203
209
  }),
204
- /* @__PURE__ */ C("div", {
210
+ /* @__PURE__ */ T("div", {
205
211
  className: "x78zum5 xdt5ytf xfko13i x1slnebi xeuugli xj0a0fe",
206
- children: [n === void 0 ? /* @__PURE__ */ S("span", { children: e }) : /* @__PURE__ */ S(l, {
212
+ children: [n === void 0 ? /* @__PURE__ */ w("span", { children: e }) : /* @__PURE__ */ w(l, {
207
213
  href: n,
208
214
  children: e
209
- }), t !== void 0 && /* @__PURE__ */ S("span", {
215
+ }), t !== void 0 && /* @__PURE__ */ w("span", {
210
216
  className: "x153jb6y xy8obcc xas2l8k xeuugli xj0a0fe",
211
217
  children: t
212
218
  })]
213
219
  }),
214
- r !== void 0 && /* @__PURE__ */ S("div", {
220
+ r !== void 0 && /* @__PURE__ */ w("div", {
215
221
  className: "x78zum5 x1a02dak x6s0dn4 x1hnptsi xeuugli",
216
222
  children: r
217
223
  })
@@ -219,103 +225,103 @@ function K({ name: e, description: t, href: n, actions: r }) {
219
225
  });
220
226
  }
221
227
  // packages/ai/src/message-action.tsx
222
- function q(e) {
228
+ function Y(e) {
223
229
  if (e.kind === "link") {
224
230
  let { kind: t, label: n, ...i } = e;
225
- return /* @__PURE__ */ S(r, {
231
+ return /* @__PURE__ */ w(r, {
226
232
  ...i,
227
233
  "aria-label": n
228
234
  });
229
235
  }
230
236
  let { kind: t, label: n, ...i } = e;
231
- return /* @__PURE__ */ S(c, {
237
+ return /* @__PURE__ */ w(c, {
232
238
  ...i,
233
239
  variant: "ghost",
234
240
  "aria-label": n
235
241
  });
236
242
  }
237
- function J(e) {
238
- return /* @__PURE__ */ C(d.Root, { children: [/* @__PURE__ */ S(d.Trigger, { render: q(e) }), /* @__PURE__ */ S(d.Portal, { children: /* @__PURE__ */ S(d.Positioner, { children: /* @__PURE__ */ S(d.Popup, { children: e.label }) }) })] });
243
+ function X(e) {
244
+ return /* @__PURE__ */ T(d.Root, { children: [/* @__PURE__ */ w(d.Trigger, { render: Y(e) }), /* @__PURE__ */ w(d.Portal, { children: /* @__PURE__ */ w(d.Positioner, { children: /* @__PURE__ */ w(d.Popup, { children: e.label }) }) })] });
239
245
  }
240
246
  // packages/ai/src/message-boundary.tsx
241
- function Y({ label: e, children: t }) {
242
- return /* @__PURE__ */ C(a.Root, {
247
+ function Z({ label: e, children: t }) {
248
+ return /* @__PURE__ */ T(a.Root, {
243
249
  className: "xeuugli x1kbiq1m xykt701 xpu655y",
244
- children: [/* @__PURE__ */ C(a.Trigger, {
250
+ children: [/* @__PURE__ */ T(a.Trigger, {
245
251
  className: "xlqzeqv x1hnptsi x153jb6y xy8obcc xas2l8k xj57cvi",
246
- children: [/* @__PURE__ */ S(D, {
252
+ children: [/* @__PURE__ */ w(k, {
247
253
  size: 14,
248
254
  "aria-hidden": !0,
249
255
  className: "x2lah0s"
250
- }), /* @__PURE__ */ S("span", {
256
+ }), /* @__PURE__ */ w("span", {
251
257
  className: "xeuugli xj0a0fe",
252
258
  children: e
253
259
  })]
254
- }), /* @__PURE__ */ S(a.Panel, {
260
+ }), /* @__PURE__ */ w(a.Panel, {
255
261
  className: "x153jb6y xy8obcc xas2l8k",
256
262
  children: t
257
263
  })]
258
264
  });
259
265
  }
260
266
  // packages/ai/src/prompt-input.tsx
261
- var X = { action: {
267
+ var Q = { action: {
262
268
  keTefX: "xvc5jky",
263
269
  $$css: !0
264
270
  } };
265
- function Z({ isCompact: e = !1 }) {
266
- return /* @__PURE__ */ S("div", {
271
+ function $({ isCompact: e = !1 }) {
272
+ return /* @__PURE__ */ w("div", {
267
273
  "aria-hidden": !0,
268
274
  inert: !0,
269
275
  className: "x78zum5 xdt5ytf x1hnptsi xeuugli xh8yej3 xe10afn xvueqy4 xbixft x1hz01jw xtqrqnz x1778rvt xj57cvi",
270
- children: /* @__PURE__ */ C("div", {
276
+ children: /* @__PURE__ */ T("div", {
271
277
  className: "x78zum5 xdt5ytf x1hnptsi xeuugli x1mvvolr xmkeg23 x1y0btm7 x1ey3b81 xy32g2j x1r7kqkb x1gd1hh4 x1u8w8hx x14xc8xn x1nvizq4 xgzwmep",
272
- children: [/* @__PURE__ */ S("div", {
278
+ children: [/* @__PURE__ */ w("div", {
273
279
  ..._.props(n.base, n.field, n.textarea, n.plainTextarea),
274
- children: /* @__PURE__ */ S(p, {
280
+ children: /* @__PURE__ */ w(p, {
275
281
  lines: e ? 1 : 2,
276
282
  width: "22ch"
277
283
  })
278
- }), /* @__PURE__ */ C("div", {
284
+ }), /* @__PURE__ */ T("div", {
279
285
  className: "x78zum5 x1a02dak x6s0dn4 x1qughib x1hnptsi",
280
- children: [/* @__PURE__ */ S("div", {
286
+ children: [/* @__PURE__ */ w("div", {
281
287
  className: "x78zum5 x1a02dak x6s0dn4 x1hnptsi xeuugli x12lumcd xy8obcc xas2l8k",
282
- children: /* @__PURE__ */ S(p, { width: "8ch" })
283
- }), /* @__PURE__ */ S(f, {
288
+ children: /* @__PURE__ */ w(p, { width: "8ch" })
289
+ }), /* @__PURE__ */ w(f, {
284
290
  isIconOnly: !0,
285
- xstyle: X.action
291
+ xstyle: Q.action
286
292
  })]
287
293
  })]
288
294
  })
289
295
  });
290
296
  }
291
- function Q({ label: e, value: t, onValueChange: n, onSubmit: r, name: i = "prompt", placeholder: a, maxLength: o, required: s = !0, isPending: l = !1, disabled: u = !1, isSubmitDisabled: f = !1, submitLabel: p = "Send message", pendingLabel: v = "Sending…", enterBehavior: y = "newline", isCompact: x = !1, description: w, error: E, controls: D, attachments: k, onStop: A, isStopPending: j = !1, stopLabel: M = "Stop response" }) {
297
+ function ee({ label: e, value: t, onValueChange: n, onSubmit: r, name: i = "prompt", placeholder: a, maxLength: o, required: s = !0, isPending: l = !1, disabled: u = !1, isSubmitDisabled: f = !1, submitLabel: p = "Send message", pendingLabel: v = "Sending…", enterBehavior: y = "newline", isCompact: x = !1, description: S, error: C, controls: E, attachments: O, onStop: k, isStopPending: j = !1, stopLabel: M = "Stop response" }) {
292
298
  let N = b(), P = u || l, F = p;
293
- A === void 0 ? l ? F = v : y === "submit" && (F = `${p} · Enter`) : F = j ? "Stopping…" : M;
299
+ k === void 0 ? l ? F = v : y === "submit" && (F = `${p} · Enter`) : F = j ? "Stopping…" : M;
294
300
  function I(e) {
295
301
  if (y !== "submit" || e.key !== "Enter" || e.repeat) return;
296
302
  let t = e.altKey || e.ctrlKey || e.metaKey;
297
- e.shiftKey || t || e.nativeEvent.isComposing || e.nativeEvent.keyCode === 229 || (e.preventDefault(), !P && !f && A === void 0 && e.currentTarget.form?.requestSubmit());
303
+ e.shiftKey || t || e.nativeEvent.isComposing || e.nativeEvent.keyCode === 229 || (e.preventDefault(), !P && !f && k === void 0 && e.currentTarget.form?.requestSubmit());
298
304
  }
299
305
  function L(e) {
300
- e.preventDefault(), !P && !f && A === void 0 && r(e);
306
+ e.preventDefault(), !P && !f && k === void 0 && r(e);
301
307
  }
302
- return /* @__PURE__ */ S("form", {
308
+ return /* @__PURE__ */ w("form", {
303
309
  onSubmit: L,
304
310
  className: "x78zum5 xdt5ytf x1hnptsi xeuugli xh8yej3 xe10afn xvueqy4 xbixft x1hz01jw xtqrqnz x1778rvt xj57cvi",
305
- children: /* @__PURE__ */ C(m.Root, {
306
- invalid: E !== void 0,
311
+ children: /* @__PURE__ */ T(m.Root, {
312
+ invalid: C !== void 0,
307
313
  children: [
308
- /* @__PURE__ */ S(m.Label, {
314
+ /* @__PURE__ */ w(m.Label, {
309
315
  ..._.props(g.hidden),
310
316
  children: e
311
317
  }),
312
- /* @__PURE__ */ C("div", {
318
+ /* @__PURE__ */ T("div", {
313
319
  ...{
314
320
  0: { className: "x78zum5 xdt5ytf x1hnptsi xeuugli x1mvvolr xmkeg23 x1y0btm7 x1ey3b81 xy32g2j x1r7kqkb x1gd1hh4 x1u8w8hx x14xc8xn x1nvizq4 xgzwmep" },
315
321
  1: { className: "x78zum5 xdt5ytf x1hnptsi xeuugli x1mvvolr xmkeg23 x1y0btm7 xy32g2j x1r7kqkb x1gd1hh4 x1u8w8hx x14xc8xn x1nvizq4 xgzwmep x1oddvo6" }
316
- }[E !== void 0 | 0],
322
+ }[C !== void 0 | 0],
317
323
  children: [
318
- /* @__PURE__ */ S(h, {
324
+ /* @__PURE__ */ w(h, {
319
325
  appearance: "plain",
320
326
  rows: x ? 1 : 2,
321
327
  isCompact: x,
@@ -328,75 +334,75 @@ function Q({ label: e, value: t, onValueChange: n, onSubmit: r, name: i = "promp
328
334
  required: s,
329
335
  disabled: u,
330
336
  readOnly: l,
331
- "aria-errormessage": E === void 0 ? void 0 : N
337
+ "aria-errormessage": C === void 0 ? void 0 : N
332
338
  }),
333
- k,
334
- /* @__PURE__ */ C("div", {
339
+ O,
340
+ /* @__PURE__ */ T("div", {
335
341
  className: "x78zum5 x1a02dak x6s0dn4 x1qughib x1hnptsi",
336
- children: [D !== void 0 && /* @__PURE__ */ S("div", {
342
+ children: [E !== void 0 && /* @__PURE__ */ w("div", {
337
343
  className: "x78zum5 x1a02dak x6s0dn4 x1hnptsi xeuugli x12lumcd",
338
- children: D
339
- }), /* @__PURE__ */ C(d.Root, { children: [/* @__PURE__ */ S(d.Trigger, { render: A === void 0 ? /* @__PURE__ */ S(c, {
340
- xstyle: X.action,
344
+ children: E
345
+ }), /* @__PURE__ */ T(d.Root, { children: [/* @__PURE__ */ w(d.Trigger, { render: k === void 0 ? /* @__PURE__ */ w(c, {
346
+ xstyle: Q.action,
341
347
  type: "submit",
342
348
  variant: "solid",
343
349
  "aria-label": l ? v : p,
344
350
  disabled: u || f,
345
351
  isPending: l,
346
- children: /* @__PURE__ */ S(T, {
352
+ children: /* @__PURE__ */ w(D, {
347
353
  size: 16,
348
354
  "aria-hidden": !0
349
355
  })
350
- }) : /* @__PURE__ */ S(c, {
351
- xstyle: X.action,
356
+ }) : /* @__PURE__ */ w(c, {
357
+ xstyle: Q.action,
352
358
  type: "button",
353
359
  "aria-label": j ? "Stopping…" : M,
354
360
  onClick: (e) => {
355
- e.preventDefault(), A();
361
+ e.preventDefault(), k();
356
362
  },
357
363
  disabled: u,
358
364
  isPending: j,
359
- children: /* @__PURE__ */ S(O, {
365
+ children: /* @__PURE__ */ w(A, {
360
366
  size: 14,
361
367
  "aria-hidden": !0
362
368
  })
363
- }) }), /* @__PURE__ */ S(d.Portal, { children: /* @__PURE__ */ S(d.Positioner, { children: /* @__PURE__ */ S(d.Popup, { children: F }) }) })] })]
369
+ }) }), /* @__PURE__ */ w(d.Portal, { children: /* @__PURE__ */ w(d.Positioner, { children: /* @__PURE__ */ w(d.Popup, { children: F }) }) })] })]
364
370
  })
365
371
  ]
366
372
  }),
367
- w !== void 0 && /* @__PURE__ */ S(m.Description, { children: w }),
368
- E !== void 0 && /* @__PURE__ */ S(m.Error, {
373
+ S !== void 0 && /* @__PURE__ */ w(m.Description, { children: S }),
374
+ C !== void 0 && /* @__PURE__ */ w(m.Error, {
369
375
  id: N,
370
376
  match: !0,
371
377
  role: "alert",
372
- children: E
378
+ children: C
373
379
  })
374
380
  ]
375
381
  })
376
382
  });
377
383
  }
378
384
  // packages/ai/src/sources.tsx
379
- function $({ sources: e, label: t = "Sources" }) {
380
- return /* @__PURE__ */ C("section", {
385
+ function te({ sources: e, label: t = "Sources" }) {
386
+ return /* @__PURE__ */ T("section", {
381
387
  "aria-label": t,
382
388
  className: "x78zum5 xdt5ytf x1hnptsi xeuugli x1hz01jw xtqrqnz x1778rvt xj57cvi xbixft",
383
389
  children: [
384
- /* @__PURE__ */ S("h3", {
390
+ /* @__PURE__ */ w("h3", {
385
391
  className: "x1ghz6dp xtqrqnz x1778rvt xk4h15q xj0a0fe",
386
392
  children: t
387
393
  }),
388
- e.length === 0 && /* @__PURE__ */ S("p", {
394
+ e.length === 0 && /* @__PURE__ */ w("p", {
389
395
  className: "x1ghz6dp x153jb6y xy8obcc xas2l8k xj0a0fe",
390
396
  children: "No sources supplied."
391
397
  }),
392
- /* @__PURE__ */ S("ol", {
398
+ /* @__PURE__ */ w("ol", {
393
399
  className: "x78zum5 xdt5ytf x1n8ia3y x1ghz6dp x1717udv x3ct3a4",
394
- children: e.map((e) => /* @__PURE__ */ C("li", {
400
+ children: e.map((e) => /* @__PURE__ */ T("li", {
395
401
  className: "x78zum5 xdt5ytf xfko13i xeuugli xj0a0fe",
396
- children: [/* @__PURE__ */ S("span", { children: /* @__PURE__ */ S(l, {
402
+ children: [/* @__PURE__ */ w("span", { children: /* @__PURE__ */ w(l, {
397
403
  href: e.href,
398
404
  children: e.title
399
- }) }), e.description !== void 0 && /* @__PURE__ */ S("p", {
405
+ }) }), e.description !== void 0 && /* @__PURE__ */ w("p", {
400
406
  className: "x1ghz6dp x153jb6y xy8obcc xas2l8k xj0a0fe",
401
407
  children: e.description
402
408
  })]
@@ -405,21 +411,21 @@ function $({ sources: e, label: t = "Sources" }) {
405
411
  ]
406
412
  });
407
413
  }
408
- function ee({ source: e, label: n }) {
409
- return /* @__PURE__ */ S("span", {
414
+ function ne({ source: e, label: n }) {
415
+ return /* @__PURE__ */ w("span", {
410
416
  className: "xt0psk2 x11njtxf xss6m8b",
411
- children: /* @__PURE__ */ C(u.Root, { children: [/* @__PURE__ */ S(u.Trigger, {
412
- render: /* @__PURE__ */ S(t, {}),
417
+ children: /* @__PURE__ */ T(u.Root, { children: [/* @__PURE__ */ w(u.Trigger, {
418
+ render: /* @__PURE__ */ w(t, {}),
413
419
  "aria-label": `Source ${n}: ${e.title}`,
414
420
  children: n
415
- }), /* @__PURE__ */ S(u.Portal, { children: /* @__PURE__ */ S(u.Positioner, {
421
+ }), /* @__PURE__ */ w(u.Portal, { children: /* @__PURE__ */ w(u.Positioner, {
416
422
  side: "top",
417
- children: /* @__PURE__ */ S(u.Popup, { children: /* @__PURE__ */ C(o, {
423
+ children: /* @__PURE__ */ w(u.Popup, { children: /* @__PURE__ */ T(o, {
418
424
  isCompact: !0,
419
425
  children: [
420
- /* @__PURE__ */ S(u.Title, { children: e.title }),
421
- e.description !== void 0 && /* @__PURE__ */ S(u.Description, { children: e.description }),
422
- /* @__PURE__ */ S(l, {
426
+ /* @__PURE__ */ w(u.Title, { children: e.title }),
427
+ e.description !== void 0 && /* @__PURE__ */ w(u.Description, { children: e.description }),
428
+ /* @__PURE__ */ w(l, {
423
429
  href: e.href,
424
430
  children: "Open source"
425
431
  })
@@ -428,4 +434,4 @@ function ee({ source: e, label: n }) {
428
434
  }) })] })
429
435
  });
430
436
  }
431
- export { M as Approval, V as Conversation, ee as InlineCitation, G as Message, J as MessageAction, K as MessageAttachment, Y as MessageBoundary, Q as PromptInput, Z as PromptInputPlaceholder, $ as Sources };
437
+ export { P as Approval, U as Conversation, ne as InlineCitation, q as Message, X as MessageAction, J as MessageAttachment, Z as MessageBoundary, ee as PromptInput, $ as PromptInputPlaceholder, te as Sources };
@@ -14,6 +14,17 @@ var h = /* @__PURE__ */ new Set(["href", "src"]), g = {
14
14
  if (h.has(n)) return t(e);
15
15
  }
16
16
  }, _ = {
17
+ root: {
18
+ k7Eaqz: "xeuugli",
19
+ kMwMTN: "xbixft",
20
+ kMv6JI: "x1hz01jw",
21
+ khiITx: "xvmahel",
22
+ kGuDYH: "xtqrqnz",
23
+ kLWn49: "x1ytb0s6",
24
+ k63SB2: "xj57cvi",
25
+ kHjlTd: "xj0a0fe",
26
+ $$css: !0
27
+ },
17
28
  block: {
18
29
  keoZOQ: "xyrmp21 x14l7nz5",
19
30
  k1K539: "x1jfksii xzboxd6",
@@ -49,14 +60,28 @@ var h = /* @__PURE__ */ new Set(["href", "src"]), g = {
49
60
  ksu8eU: "x1y0btm7",
50
61
  kVAM5u: "x1ey3b81",
51
62
  $$css: !0
63
+ },
64
+ strong: {
65
+ k63SB2: "x1b5ytql",
66
+ $$css: !0
67
+ },
68
+ muted: {
69
+ kMwMTN: "x153jb6y",
70
+ $$css: !0
52
71
  }
53
- }, v = /* @__PURE__ */ new Set(["string", "number"]);
54
- function y(e) {
55
- return v.has(typeof e);
72
+ }, v = {
73
+ default: null,
74
+ muted: _.muted
75
+ }, y = {
76
+ regular: null,
77
+ strong: _.strong
78
+ }, b = /* @__PURE__ */ new Set(["string", "number"]);
79
+ function x(e) {
80
+ return b.has(typeof e);
56
81
  }
57
- function b({ children: t, className: n }) {
82
+ function S({ children: t, className: n }) {
58
83
  let r = m(), i = typeof n == "string" ? /(?:^|\s)language-([^\s]+)/u.exec(n) : null, o = i === null ? void 0 : i[1], s = a.toArray(t);
59
- return s.every(y) ? /* @__PURE__ */ c("div", {
84
+ return s.every(x) ? /* @__PURE__ */ c("div", {
60
85
  className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6",
61
86
  children: /* @__PURE__ */ c(e, {
62
87
  code: s.join(""),
@@ -68,14 +93,14 @@ function b({ children: t, className: n }) {
68
93
  children: t
69
94
  });
70
95
  }
71
- function x({ level: e, headingLevel: t, children: n, id: r }) {
96
+ function C({ level: e, headingLevel: t, children: n, id: r }) {
72
97
  let a = `h${Math.min(e + t - 1, 6)}`, s = e === 1 ? _.title : e === 2 ? _.section : _.minor;
73
98
  return o(a, {
74
99
  id: r,
75
100
  ...i.props(_.heading, s)
76
101
  }, n);
77
102
  }
78
- var S = {
103
+ var w = {
79
104
  p: ({ children: e }) => /* @__PURE__ */ c("p", {
80
105
  className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6",
81
106
  children: e
@@ -97,7 +122,7 @@ var S = {
97
122
  className: "xyrmp21 x14l7nz5 x1jfksii xzboxd6 xrxpjvj x1umj4g3 xyumdvf x1t7ytsu x97x49r x153jb6y",
98
123
  children: e
99
124
  }),
100
- code: ({ children: e, className: t }) => /* @__PURE__ */ c(b, {
125
+ code: ({ children: e, className: t }) => /* @__PURE__ */ c(S, {
101
126
  className: t,
102
127
  children: e
103
128
  }),
@@ -157,35 +182,35 @@ var S = {
157
182
  className: "x5lhwog",
158
183
  children: e
159
184
  })
160
- }, C = /* @__PURE__ */ "p.h1.h2.h3.h4.h5.h6.ul.ol.li.blockquote.pre.code.a.img.table.thead.tbody.tr.th.td.input.hr.strong.em.del.br.sup.sub.section".split(".");
161
- function w({ children: e, isStreaming: t = !1, label: n, headingLevel: r = 1 }) {
162
- let i = {
163
- h1: (e) => /* @__PURE__ */ c(x, {
185
+ }, T = /* @__PURE__ */ "p.h1.h2.h3.h4.h5.h6.ul.ol.li.blockquote.pre.code.a.img.table.thead.tbody.tr.th.td.input.hr.strong.em.del.br.sup.sub.section".split(".");
186
+ function E({ children: e, isStreaming: t = !1, label: n, headingLevel: r = 1, tone: a = "default", weight: o = "regular" }) {
187
+ let s = {
188
+ h1: (e) => /* @__PURE__ */ c(C, {
164
189
  ...e,
165
190
  level: 1,
166
191
  headingLevel: r
167
192
  }),
168
- h2: (e) => /* @__PURE__ */ c(x, {
193
+ h2: (e) => /* @__PURE__ */ c(C, {
169
194
  ...e,
170
195
  level: 2,
171
196
  headingLevel: r
172
197
  }),
173
- h3: (e) => /* @__PURE__ */ c(x, {
198
+ h3: (e) => /* @__PURE__ */ c(C, {
174
199
  ...e,
175
200
  level: 3,
176
201
  headingLevel: r
177
202
  }),
178
- h4: (e) => /* @__PURE__ */ c(x, {
203
+ h4: (e) => /* @__PURE__ */ c(C, {
179
204
  ...e,
180
205
  level: 4,
181
206
  headingLevel: r
182
207
  }),
183
- h5: (e) => /* @__PURE__ */ c(x, {
208
+ h5: (e) => /* @__PURE__ */ c(C, {
184
209
  ...e,
185
210
  level: 5,
186
211
  headingLevel: r
187
212
  }),
188
- h6: (e) => /* @__PURE__ */ c(x, {
213
+ h6: (e) => /* @__PURE__ */ c(C, {
189
214
  ...e,
190
215
  level: 6,
191
216
  headingLevel: r
@@ -193,48 +218,48 @@ function w({ children: e, isStreaming: t = !1, label: n, headingLevel: r = 1 })
193
218
  };
194
219
  return /* @__PURE__ */ c(d, {
195
220
  ...g,
196
- className: "xeuugli xbixft x1hz01jw xvmahel xtqrqnz x1ytb0s6 xj57cvi xj0a0fe",
221
+ ...i.props(_.root, v[a], y[o]),
197
222
  "aria-label": n,
198
223
  components: {
199
- ...S,
200
- ...i
224
+ ...w,
225
+ ...s
201
226
  },
202
227
  mode: t ? "streaming" : "static",
203
228
  isAnimating: t,
204
229
  animated: !1,
205
230
  controls: !1,
206
231
  linkSafety: { enabled: !1 },
207
- allowedElements: C,
232
+ allowedElements: T,
208
233
  children: e
209
234
  }, r);
210
235
  }
211
236
  // packages/content/src/markdown/markdown-preview.tsx
212
- function T({ children: e }) {
237
+ function D({ children: e }) {
213
238
  return /* @__PURE__ */ l(s, { children: [e, " "] });
214
239
  }
215
- var E = {
216
- p: T,
217
- li: T,
218
- h1: T,
219
- h2: T,
220
- h3: T,
221
- h4: T,
222
- h5: T,
223
- h6: T,
224
- blockquote: T,
225
- pre: T,
240
+ var O = {
241
+ p: D,
242
+ li: D,
243
+ h1: D,
244
+ h2: D,
245
+ h3: D,
246
+ h4: D,
247
+ h5: D,
248
+ h6: D,
249
+ blockquote: D,
250
+ pre: D,
226
251
  code: ({ children: e }) => /* @__PURE__ */ c(s, { children: e }),
227
- th: T,
228
- td: T,
252
+ th: D,
253
+ td: D,
229
254
  br: () => /* @__PURE__ */ c(s, { children: " " }),
230
255
  img: ({ alt: e }) => /* @__PURE__ */ c(s, { children: e })
231
256
  };
232
- function D({ children: e }) {
257
+ function k({ children: e }) {
233
258
  return /* @__PURE__ */ c(u, {
234
259
  ...g,
235
260
  content: e,
236
- components: E,
237
- allowedElements: Object.keys(E),
261
+ components: O,
262
+ allowedElements: Object.keys(O),
238
263
  unwrapDisallowed: !0,
239
264
  shouldParseIncompleteMarkdown: !1,
240
265
  shouldNormalizeHtmlIndentation: !1,
@@ -242,4 +267,4 @@ function D({ children: e }) {
242
267
  index: 0
243
268
  });
244
269
  }
245
- export { w as Markdown, D as MarkdownPreview };
270
+ export { E as Markdown, k as MarkdownPreview };
package/dist/content.js CHANGED
@@ -3,38 +3,38 @@ import { t as i } from "./viewer-styles-CpHqp5Qv.js";
3
3
  import { t as a } from "./code-block-DB42-a0M.js";
4
4
  import { t as o } from "./content-link-rdxJ94P8.js";
5
5
  import * as s from "@stylexjs/stylex";
6
- import { useCallback as c, useEffect as l, useRef as u, useState as d } from "react";
7
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
8
- import { Check as m, Circle as h, CircleDashed as g, CircleHelp as _, Clock as v, X as y } from "lucide-react";
9
- import b from "strip-ansi";
6
+ import { useCallback as c, useEffect as l, useLayoutEffect as u, useRef as d, useState as f } from "react";
7
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { Check as h, Circle as g, CircleDashed as _, CircleHelp as v, Clock as y, X as b } from "lucide-react";
9
+ import x from "strip-ansi";
10
10
  // packages/content/src/json-viewer.tsx
11
- var x = { body: {
11
+ var S = { body: {
12
12
  kmVPX3: "x1mvvolr",
13
13
  kVQacm: "xysyzu8",
14
14
  kskxy: "x1phlbz0",
15
15
  kMv6JI: "xiard35",
16
16
  kGuDYH: "xy8obcc",
17
17
  $$css: !0
18
- } }, S = 500;
19
- function C({ value: e, name: t, path: n, depth: r, maxDepth: i, maxEntries: a }) {
20
- let [o, s] = d(r === 0);
18
+ } }, C = 500;
19
+ function w({ value: e, name: t, path: n, depth: r, maxDepth: i, maxEntries: a }) {
20
+ let [o, s] = f(r === 0);
21
21
  if (typeof e != "object" || !e) {
22
- let n = JSON.stringify(e), r = n.length > S;
23
- return /* @__PURE__ */ p("div", {
22
+ let n = JSON.stringify(e), r = n.length > C;
23
+ return /* @__PURE__ */ m("div", {
24
24
  className: "xeuugli x126k92a xj0a0fe",
25
25
  children: [
26
- /* @__PURE__ */ p("span", {
26
+ /* @__PURE__ */ m("span", {
27
27
  className: "x153jb6y",
28
28
  children: [t, ": "]
29
29
  }),
30
- /* @__PURE__ */ f("span", {
30
+ /* @__PURE__ */ p("span", {
31
31
  ...{
32
32
  0: { className: "xbixft" },
33
33
  1: { className: "x7ixh4y" }
34
34
  }[typeof e == "string" | 0],
35
- children: n.slice(0, S)
35
+ children: n.slice(0, C)
36
36
  }),
37
- r && /* @__PURE__ */ f("span", {
37
+ r && /* @__PURE__ */ p("span", {
38
38
  className: "x153jb6y x1hz01jw",
39
39
  children: "… (value truncated)"
40
40
  })
@@ -42,38 +42,38 @@ function C({ value: e, name: t, path: n, depth: r, maxDepth: i, maxEntries: a })
42
42
  });
43
43
  }
44
44
  let c = Object.entries(e), l = Array.isArray(e) ? `${c.length} items` : `${c.length} fields`;
45
- return r >= i ? /* @__PURE__ */ p("div", {
45
+ return r >= i ? /* @__PURE__ */ m("div", {
46
46
  className: "xeuugli x126k92a xj0a0fe",
47
- children: [/* @__PURE__ */ p("span", {
47
+ children: [/* @__PURE__ */ m("span", {
48
48
  className: "x153jb6y",
49
49
  children: [t, ": "]
50
- }), /* @__PURE__ */ p("span", {
50
+ }), /* @__PURE__ */ m("span", {
51
51
  className: "x153jb6y x1hz01jw",
52
52
  children: [l, " · depth limit"]
53
53
  })]
54
- }) : /* @__PURE__ */ p("details", {
54
+ }) : /* @__PURE__ */ m("details", {
55
55
  open: o,
56
56
  onToggle: (e) => s(e.currentTarget.open),
57
57
  className: "xeuugli x126k92a xj0a0fe",
58
- children: [/* @__PURE__ */ p("summary", {
58
+ children: [/* @__PURE__ */ m("summary", {
59
59
  className: "x9f619 x1ypdohk x16exltd x17oiadl xt970qd x1r6zayv xjbqb8w xif5pkx x1s9zmfe x19rmrnh x13qnu6 x9v5kkp x1bqaal",
60
60
  children: [
61
- /* @__PURE__ */ p("span", {
61
+ /* @__PURE__ */ m("span", {
62
62
  className: "x153jb6y",
63
63
  children: [t, ": "]
64
64
  }),
65
65
  Array.isArray(e) ? "[]" : "{}",
66
66
  " ",
67
- /* @__PURE__ */ f("span", {
67
+ /* @__PURE__ */ p("span", {
68
68
  className: "x153jb6y x1hz01jw",
69
69
  children: l
70
70
  })
71
71
  ]
72
- }), o && /* @__PURE__ */ p("div", {
72
+ }), o && /* @__PURE__ */ m("div", {
73
73
  className: "xo02m6d xpilrb4 x1t7ytsu x97x49r xa1dmyi",
74
74
  children: [c.slice(0, a).map(([e, t]) => {
75
75
  let o = `${n}/${e.replaceAll("~", "~0").replaceAll("/", "~1")}`;
76
- return /* @__PURE__ */ f(C, {
76
+ return /* @__PURE__ */ p(w, {
77
77
  name: JSON.stringify(e),
78
78
  path: o,
79
79
  value: t,
@@ -81,34 +81,34 @@ function C({ value: e, name: t, path: n, depth: r, maxDepth: i, maxEntries: a })
81
81
  maxDepth: i,
82
82
  maxEntries: a
83
83
  }, o);
84
- }), c.length > a && /* @__PURE__ */ p("div", {
84
+ }), c.length > a && /* @__PURE__ */ m("div", {
85
85
  className: "x153jb6y x1hz01jw",
86
86
  children: [c.length - a, " more entries · copy to inspect the complete value"]
87
87
  })]
88
88
  })]
89
89
  });
90
90
  }
91
- function w({ value: e, label: t, maxDepth: r = 6, maxEntries: a = 50 }) {
91
+ function T({ value: e, label: t, maxDepth: r = 6, maxEntries: a = 50 }) {
92
92
  let o = c(() => JSON.stringify(e, null, 2), [e]);
93
- return /* @__PURE__ */ p("section", {
93
+ return /* @__PURE__ */ m("section", {
94
94
  "aria-label": t,
95
95
  ...s.props(i.root),
96
- children: [/* @__PURE__ */ p("div", {
96
+ children: [/* @__PURE__ */ m("div", {
97
97
  ...s.props(i.header),
98
- children: [/* @__PURE__ */ f("span", {
98
+ children: [/* @__PURE__ */ p("span", {
99
99
  ...s.props(i.label),
100
100
  children: t
101
- }), /* @__PURE__ */ f(n, {
101
+ }), /* @__PURE__ */ p(n, {
102
102
  label: t,
103
103
  value: o,
104
104
  children: "Copy JSON"
105
105
  })]
106
- }), /* @__PURE__ */ f("div", {
106
+ }), /* @__PURE__ */ p("div", {
107
107
  role: "region",
108
108
  "aria-label": `${t} fields`,
109
109
  tabIndex: 0,
110
- ...s.props(i.scrollRegion, x.body),
111
- children: /* @__PURE__ */ f(C, {
110
+ ...s.props(i.scrollRegion, S.body),
111
+ children: /* @__PURE__ */ p(w, {
112
112
  name: "root",
113
113
  path: "",
114
114
  value: e,
@@ -120,7 +120,7 @@ function w({ value: e, label: t, maxDepth: r = 6, maxEntries: a = 50 }) {
120
120
  });
121
121
  }
122
122
  // packages/content/src/log-viewer.tsx
123
- var T = {
123
+ var E = {
124
124
  kVQacm: "xysyzu8",
125
125
  kmVPX3: "x1mvvolr",
126
126
  kogj98: "x1ghz6dp",
@@ -131,9 +131,9 @@ var T = {
131
131
  kHjlTd: "xj0a0fe",
132
132
  kKi2Bq: "xeq4nuv",
133
133
  $$css: !0
134
- }, E = {
134
+ }, D = {
135
135
  output: (e) => [
136
- T,
136
+ E,
137
137
  {
138
138
  kskxy: e == null ? e : "x1jols5v",
139
139
  $$css: !0
@@ -146,68 +146,124 @@ var T = {
146
146
  kL6WhQ: "x1qndepd",
147
147
  $$css: !0
148
148
  }
149
- }, D = 2e5;
150
- function O({ output: t, label: r, maxLines: a = 500, maxHeight: o = 320, isRunning: c = !1 }) {
151
- let m = u(null), [h, g] = d(!0), _ = b(t), v = _.slice(-2e5).split("\n"), y = v.slice(-Math.max(1, a)), x = v.length - y.length;
149
+ }, O = 2e5;
150
+ function k({ output: t, label: r, maxLines: a = 500, maxHeight: o = 320, isRunning: c = !1 }) {
151
+ let h = d(null), g = d(!1), [_, v] = f(!0), y = x(t), b = y.slice(-2e5).split("\n"), S = b.slice(-Math.max(1, a)), C = b.length - S.length;
152
152
  return l(() => {
153
- h && m.current !== null && (m.current.scrollTop = m.current.scrollHeight);
154
- }, [t, h]), /* @__PURE__ */ p("section", {
153
+ _ && h.current !== null && (h.current.scrollTop = h.current.scrollHeight);
154
+ }, [t, _]), u(() => {
155
+ !c && g.current && (g.current = !1, h.current?.focus({ preventScroll: !0 }));
156
+ }, [c]), /* @__PURE__ */ m("section", {
155
157
  "aria-label": r,
156
158
  ...s.props(i.root),
157
159
  children: [
158
- /* @__PURE__ */ p("div", {
160
+ /* @__PURE__ */ m("div", {
159
161
  ...s.props(i.header),
160
- children: [/* @__PURE__ */ p("span", {
162
+ children: [/* @__PURE__ */ m("span", {
161
163
  ...s.props(i.label),
162
164
  children: [r, c && " · running"]
163
- }), /* @__PURE__ */ p("div", {
165
+ }), /* @__PURE__ */ m("div", {
164
166
  ...s.props(i.actions),
165
- children: [/* @__PURE__ */ f(e, {
167
+ children: [c && /* @__PURE__ */ p(e, {
166
168
  variant: "ghost",
167
- onClick: () => g(!h),
168
- children: h ? "Pause following" : "Follow output"
169
- }), /* @__PURE__ */ f(n, {
169
+ onClick: () => v(!_),
170
+ onFocus: () => {
171
+ g.current = !0;
172
+ },
173
+ onBlur: () => {
174
+ g.current = !1;
175
+ },
176
+ children: _ ? "Pause following" : "Follow output"
177
+ }), /* @__PURE__ */ p(n, {
170
178
  value: t,
171
179
  label: r,
172
180
  children: "Copy"
173
181
  })]
174
182
  })]
175
183
  }),
176
- x > 0 && /* @__PURE__ */ p("div", {
177
- ...s.props(i.note, E.notice),
178
- children: [x, " earlier lines omitted from this view. Copy includes the supplied output."]
184
+ C > 0 && /* @__PURE__ */ m("div", {
185
+ ...s.props(i.note, D.notice),
186
+ children: [C, " earlier lines omitted from this view. Copy includes the supplied output."]
179
187
  }),
180
- _.length > D && /* @__PURE__ */ f("div", {
181
- ...s.props(i.note, E.notice),
188
+ y.length > O && /* @__PURE__ */ p("div", {
189
+ ...s.props(i.note, D.notice),
182
190
  children: "Preview limited to the last 200,000 characters. Copy includes the supplied output."
183
191
  }),
184
- /* @__PURE__ */ f("pre", {
185
- ref: m,
192
+ /* @__PURE__ */ p("pre", {
193
+ ref: h,
186
194
  role: "region",
187
195
  "aria-label": `${r} output`,
188
196
  tabIndex: 0,
189
197
  onScroll: (e) => {
190
198
  let t = e.currentTarget;
191
- g(t.scrollHeight - t.scrollTop - t.clientHeight < 8);
199
+ v(t.scrollHeight - t.scrollTop - t.clientHeight < 8);
192
200
  },
193
- ...s.props(i.scrollRegion, E.output(o)),
194
- children: _.length === 0 ? "No output recorded." : y.join("\n")
201
+ ...s.props(i.scrollRegion, D.output(o)),
202
+ children: y.length === 0 ? "No output recorded." : S.join("\n")
195
203
  })
196
204
  ]
197
205
  });
198
206
  }
207
+ // packages/content/src/media-viewer.tsx
208
+ var A = {
209
+ viewport: {
210
+ k1xSpc: "xrvj5dj",
211
+ kgQiWS: "x1ku5rj1",
212
+ kzqmXN: "xh8yej3",
213
+ kOBAk4: "x186iv6y",
214
+ kskxy: "xcwfpss",
215
+ k7Eaqz: "xeuugli",
216
+ kVQacm: "xb3r6kr",
217
+ kWkggS: "x1r7kqkb",
218
+ $$css: !0
219
+ },
220
+ placeholder: {
221
+ kWkggS: "x1fa40ue",
222
+ $$css: !0
223
+ }
224
+ };
225
+ function j() {
226
+ return /* @__PURE__ */ p("div", {
227
+ "aria-hidden": !0,
228
+ ...s.props(i.root, A.viewport, A.placeholder)
229
+ });
230
+ }
231
+ function M({ kind: e, src: t, label: n, widthPixels: r, heightPixels: a, onError: o }) {
232
+ return /* @__PURE__ */ p("div", {
233
+ ...s.props(i.root, A.viewport),
234
+ children: e === "image" ? /* @__PURE__ */ p("img", {
235
+ src: t,
236
+ alt: n,
237
+ width: r,
238
+ height: a,
239
+ onError: o,
240
+ className: "x1lliihq xh8yej3 x5yr21d x2lwn1j x19kjcj4"
241
+ }) : /* @__PURE__ */ p("video", {
242
+ src: t,
243
+ "aria-label": n,
244
+ width: r,
245
+ height: a,
246
+ controls: !0,
247
+ muted: !0,
248
+ playsInline: !0,
249
+ preload: "metadata",
250
+ onError: o,
251
+ className: "x1lliihq xh8yej3 x5yr21d x2lwn1j x19kjcj4"
252
+ })
253
+ });
254
+ }
199
255
  // packages/content/src/stack-trace.tsx
200
- function k({ message: e, frames: t }) {
201
- return /* @__PURE__ */ p("section", {
256
+ function N({ message: e, frames: t }) {
257
+ return /* @__PURE__ */ m("section", {
202
258
  "aria-label": "Stack trace",
203
259
  ...s.props(i.root),
204
- children: [/* @__PURE__ */ f("p", {
260
+ children: [/* @__PURE__ */ p("p", {
205
261
  className: "x1ghz6dp x1mvvolr xso031l x1q0q8m5 x1qndepd xr5kp14 xk4h15q xj0a0fe",
206
262
  children: e
207
- }), t.length === 0 ? /* @__PURE__ */ f("p", {
263
+ }), t.length === 0 ? /* @__PURE__ */ p("p", {
208
264
  className: "x1ghz6dp x1mvvolr x153jb6y",
209
265
  children: "No frames recorded."
210
- }) : /* @__PURE__ */ f("ol", {
266
+ }) : /* @__PURE__ */ p("ol", {
211
267
  className: "x1ghz6dp x1717udv x3ct3a4",
212
268
  children: t.map((e) => {
213
269
  let t = [
@@ -215,15 +271,15 @@ function k({ message: e, frames: t }) {
215
271
  e.line,
216
272
  e.column
217
273
  ].filter((e) => e !== void 0).join(":");
218
- return /* @__PURE__ */ p("li", {
274
+ return /* @__PURE__ */ m("li", {
219
275
  className: "x78zum5 xdt5ytf x1hnptsi xeuugli xj0a0fe x1mvvolr xso031l x1t1lzn6 x1q0q8m5 x1qndepd",
220
- children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f(o, {
276
+ children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p(o, {
221
277
  href: e.href,
222
278
  children: e.name
223
- }), t.length > 0 && /* @__PURE__ */ f("span", {
279
+ }), t.length > 0 && /* @__PURE__ */ p("span", {
224
280
  className: "x1lliihq x153jb6y xiard35 xy8obcc xj0a0fe",
225
281
  children: t
226
- })] }), e.code !== void 0 && /* @__PURE__ */ f(a, {
282
+ })] }), e.code !== void 0 && /* @__PURE__ */ p(a, {
227
283
  code: e.code,
228
284
  language: e.language,
229
285
  filename: e.file
@@ -234,7 +290,7 @@ function k({ message: e, frames: t }) {
234
290
  });
235
291
  }
236
292
  // packages/content/src/trace.tsx
237
- var A = {
293
+ var P = {
238
294
  pending: {
239
295
  kMwMTN: "x153jb6y",
240
296
  $$css: !0
@@ -259,78 +315,78 @@ var A = {
259
315
  kMwMTN: "x153jb6y",
260
316
  $$css: !0
261
317
  }
262
- }, j = {
263
- pending: A.pending,
264
- running: A.running,
265
- complete: A.complete,
266
- failed: A.failed,
267
- skipped: A.skipped,
268
- unknown: A.unknown
269
- }, M = {
270
- pending: v,
271
- running: h,
272
- complete: m,
273
- failed: y,
274
- skipped: g,
275
- unknown: _
318
+ }, F = {
319
+ pending: P.pending,
320
+ running: P.running,
321
+ complete: P.complete,
322
+ failed: P.failed,
323
+ skipped: P.skipped,
324
+ unknown: P.unknown
325
+ }, I = {
326
+ pending: y,
327
+ running: g,
328
+ complete: h,
329
+ failed: b,
330
+ skipped: _,
331
+ unknown: v
276
332
  };
277
- function N({ label: e, children: t }) {
278
- return /* @__PURE__ */ f("ol", {
333
+ function L({ label: e, children: t }) {
334
+ return /* @__PURE__ */ p("ol", {
279
335
  "aria-label": e,
280
336
  className: "x1ghz6dp x1717udv x3ct3a4 xeuugli x1hz01jw xtqrqnz x1778rvt xj57cvi xbixft",
281
337
  children: t
282
338
  });
283
339
  }
284
- function P({ label: e, children: t }) {
285
- return /* @__PURE__ */ f("ol", {
340
+ function R({ label: e, children: t }) {
341
+ return /* @__PURE__ */ p("ol", {
286
342
  "aria-label": e,
287
343
  className: "x1ghz6dp x1717udv x3ct3a4 xeuugli x1hz01jw xtqrqnz x1778rvt xj57cvi xbixft x3bg4vu",
288
344
  children: t
289
345
  });
290
346
  }
291
- function F({ id: e, label: n, status: i, statusLabel: a, description: o, detail: c, isSelected: l, onSelect: u, children: d }) {
292
- let m = M[i];
293
- return /* @__PURE__ */ p("li", {
347
+ function z({ id: e, label: n, status: i, statusLabel: a, description: o, detail: c, isSelected: l, onSelect: u, children: d }) {
348
+ let f = I[i];
349
+ return /* @__PURE__ */ m("li", {
294
350
  "data-item-id": e,
295
351
  className: "x1n2onr6 xrvj5dj x1qpdrs7 x8zbtdt x1wv5www xup0pd7",
296
- children: [/* @__PURE__ */ p("div", {
352
+ children: [/* @__PURE__ */ m("div", {
297
353
  "aria-hidden": !0,
298
354
  className: "x78zum5 xdt5ytf x6s0dn4 xunmzkg x1lk341d",
299
- children: [/* @__PURE__ */ f(m, {
355
+ children: [/* @__PURE__ */ p(f, {
300
356
  size: 14,
301
- ...s.props(j[i])
302
- }), /* @__PURE__ */ f("span", { className: "x1i1rx1s x1f6qilh x98rzlu x1fa40ue" })]
303
- }), /* @__PURE__ */ p("div", {
357
+ ...s.props(F[i])
358
+ }), /* @__PURE__ */ p("span", { className: "x1i1rx1s x1f6qilh x98rzlu x1fa40ue" })]
359
+ }), /* @__PURE__ */ m("div", {
304
360
  className: "x78zum5 xdt5ytf xunmzkg xeuugli",
305
361
  children: [
306
- /* @__PURE__ */ f("div", {
362
+ /* @__PURE__ */ p("div", {
307
363
  ...{
308
364
  0: { className: "xk4h15q xj0a0fe" },
309
365
  1: { className: "xk4h15q xj0a0fe xujl8zx xda060z" }
310
366
  }[l === !0 | 0],
311
- children: u === void 0 ? n : /* @__PURE__ */ f(t, {
367
+ children: u === void 0 ? n : /* @__PURE__ */ p(t, {
312
368
  "aria-pressed": l,
313
369
  onClick: () => u(e),
314
370
  children: n
315
371
  })
316
372
  }),
317
- /* @__PURE__ */ f("span", {
373
+ /* @__PURE__ */ p("span", {
318
374
  className: "xy8obcc xas2l8k x153jb6y xj0a0fe",
319
375
  children: a
320
376
  }),
321
- o !== void 0 && /* @__PURE__ */ f("p", {
377
+ o !== void 0 && /* @__PURE__ */ p("p", {
322
378
  className: "x1ghz6dp x153jb6y xj0a0fe",
323
379
  children: o
324
380
  }),
325
- c !== void 0 && /* @__PURE__ */ p(r.Root, { children: [/* @__PURE__ */ f(r.Trigger, { children: "Details" }), /* @__PURE__ */ f(r.Panel, { children: c })] }),
381
+ c !== void 0 && /* @__PURE__ */ m(r.Root, { children: [/* @__PURE__ */ p(r.Trigger, { children: "Details" }), /* @__PURE__ */ p(r.Panel, { children: c })] }),
326
382
  d
327
383
  ]
328
384
  })]
329
385
  });
330
386
  }
331
- var I = {
332
- Root: N,
333
- Item: F,
334
- Group: P
387
+ var B = {
388
+ Root: L,
389
+ Item: z,
390
+ Group: R
335
391
  };
336
- export { w as JsonViewer, O as LogViewer, k as StackTrace, I as Trace };
392
+ export { T as JsonViewer, k as LogViewer, M as MediaViewer, j as MediaViewerPlaceholder, N as StackTrace, B as Trace };
package/dist/elements.css CHANGED
@@ -684,6 +684,10 @@ html[dir=ltr],[data-sonner-toaster][dir=ltr]{--toast-icon-margin-start:-3px;--to
684
684
  animation-timing-function: var(--x5xz5r2);
685
685
  }
686
686
 
687
+ .x186iv6y {
688
+ aspect-ratio: 16 / 9;
689
+ }
690
+
687
691
  .xjbqb8w {
688
692
  background-color: #0000;
689
693
  }
@@ -1293,6 +1297,10 @@ html[dir=ltr],[data-sonner-toaster][dir=ltr]{--toast-icon-margin-start:-3px;--to
1293
1297
  margin-inline-start: var(--x1xijsos);
1294
1298
  }
1295
1299
 
1300
+ .x19kjcj4 {
1301
+ object-fit: contain;
1302
+ }
1303
+
1296
1304
  .xl1xv1r {
1297
1305
  object-fit: cover;
1298
1306
  }
@@ -2293,6 +2301,10 @@ html[dir=ltr],[data-sonner-toaster][dir=ltr]{--toast-icon-margin-start:-3px;--to
2293
2301
  max-height: 520px;
2294
2302
  }
2295
2303
 
2304
+ .xcwfpss {
2305
+ max-height: 70dvh;
2306
+ }
2307
+
2296
2308
  .xs8sm83 {
2297
2309
  max-height: calc(100dvh - 32px);
2298
2310
  }
@@ -1,7 +1,11 @@
1
1
  import type { ReactNode, RefObject } from 'react';
2
2
  export type ConversationRootProps = {
3
3
  readonly children: ReactNode;
4
- readonly initialPosition?: 'start' | 'end';
4
+ /** Captured at mount. A saved offset starts in reading mode; mount once the content is ready. */
5
+ readonly initialPosition?: 'start' | 'end' | {
6
+ readonly top: number;
7
+ readonly left?: number;
8
+ } | undefined;
5
9
  readonly shouldFollow?: boolean;
6
10
  readonly viewportRef?: RefObject<HTMLDivElement | null> | undefined;
7
11
  };
@@ -2,6 +2,8 @@ export type { JsonValue, JsonViewerProps } from './json-viewer.tsx';
2
2
  export { JsonViewer } from './json-viewer.tsx';
3
3
  export type { LogViewerProps } from './log-viewer.tsx';
4
4
  export { LogViewer } from './log-viewer.tsx';
5
+ export type { MediaViewerProps } from './media-viewer.tsx';
6
+ export { MediaViewer, MediaViewerPlaceholder } from './media-viewer.tsx';
5
7
  export type { StackFrame, StackTraceProps } from './stack-trace.tsx';
6
8
  export { StackTrace } from './stack-trace.tsx';
7
9
  export type { TraceStatus, TraceRootProps, TraceGroupProps, TraceItemProps } from './trace.tsx';
@@ -5,6 +5,8 @@ export type MarkdownProps = {
5
5
  readonly isStreaming?: boolean;
6
6
  readonly label?: string;
7
7
  readonly headingLevel?: HeadingLevel;
8
+ readonly tone?: 'default' | 'muted';
9
+ readonly weight?: 'regular' | 'strong';
8
10
  };
9
- export declare function Markdown({ children, isStreaming, label, headingLevel }: MarkdownProps): ReactNode;
11
+ export declare function Markdown({ children, isStreaming, label, headingLevel, tone, weight, }: MarkdownProps): ReactNode;
10
12
  export {};
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ export type MediaViewerProps = {
3
+ readonly kind: 'image' | 'video';
4
+ readonly src: string;
5
+ readonly label: string;
6
+ readonly widthPixels: number;
7
+ readonly heightPixels: number;
8
+ readonly onError?: () => void;
9
+ };
10
+ export declare function MediaViewerPlaceholder(): ReactNode;
11
+ export declare function MediaViewer({ kind, src, label, widthPixels, heightPixels, onError }: MediaViewerProps): ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechane-ai/elements",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Elements by Mechane — React components for applications, AI interfaces, and analytical graphics",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {