@timbal-ai/timbal-react 0.8.2 → 1.1.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/CHANGELOG.md +49 -0
- package/README.md +100 -6
- package/dist/app.cjs +2538 -1262
- package/dist/app.d.cts +11 -6
- package/dist/app.d.ts +11 -6
- package/dist/app.esm.js +43 -6
- package/dist/{button-ClSgD6OF.d.cts → button-BoyX5pM_.d.cts} +1 -1
- package/dist/{button-ClSgD6OF.d.ts → button-BoyX5pM_.d.ts} +1 -1
- package/dist/{chart-artifact-Bl67kre7.d.ts → chart-artifact-BZp7nmaf.d.ts} +430 -14
- package/dist/{chart-artifact-BzcvblDe.d.cts → chart-artifact-CX-rh9nq.d.cts} +430 -14
- package/dist/{chat-Bed4FQSl.d.cts → chat-DCms8pJ_.d.cts} +31 -4
- package/dist/{chat-Bed4FQSl.d.ts → chat-DCms8pJ_.d.ts} +31 -4
- package/dist/chat.cjs +1111 -776
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-QVAUCVQA.esm.js → chunk-4AKJ6FKE.esm.js} +277 -4
- package/dist/chunk-6HWMJNZT.esm.js +3439 -0
- package/dist/{chunk-VWHHKAHN.esm.js → chunk-FRZOEYBO.esm.js} +4 -4
- package/dist/chunk-JEAUF54A.esm.js +52 -0
- package/dist/{chunk-OISVICYF.esm.js → chunk-P3KDAYX6.esm.js} +1 -1
- package/dist/{chunk-6YVKCVEP.esm.js → chunk-TK2AGIME.esm.js} +1106 -298
- package/dist/{chunk-CFU3YDTV.esm.js → chunk-XCM3V6RK.esm.js} +5 -5
- package/dist/{chunk-5ZKLPWVN.esm.js → chunk-YXZ22OJN.esm.js} +849 -667
- package/dist/index.cjs +6070 -1605
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.esm.js +427 -11
- package/dist/pill-segmented-tabs-Ba5q0feL.d.cts +500 -0
- package/dist/pill-segmented-tabs-Ba5q0feL.d.ts +500 -0
- package/dist/studio.cjs +1333 -998
- package/dist/studio.d.cts +2 -2
- package/dist/studio.d.ts +2 -2
- package/dist/studio.esm.js +5 -5
- package/dist/styles.css +220 -0
- package/dist/ui.cjs +3592 -89
- package/dist/ui.d.cts +72 -96
- package/dist/ui.d.ts +72 -96
- package/dist/ui.esm.js +400 -6
- package/dist/{welcome-COOb05a5.d.cts → welcome-CRqOPKMp.d.cts} +1 -1
- package/dist/{welcome-DE08m9ca.d.ts → welcome-DlHUa3OL.d.ts} +1 -1
- package/package.json +9 -3
- package/dist/chunk-P4SN7M67.esm.js +0 -435
|
@@ -3,6 +3,11 @@ import {
|
|
|
3
3
|
AvatarFallback,
|
|
4
4
|
AvatarImage,
|
|
5
5
|
Button,
|
|
6
|
+
ChartContainer,
|
|
7
|
+
ChartLegend,
|
|
8
|
+
ChartLegendContent,
|
|
9
|
+
ChartTooltip,
|
|
10
|
+
ChartTooltipContent,
|
|
6
11
|
Dialog,
|
|
7
12
|
DialogContent,
|
|
8
13
|
DialogTitle,
|
|
@@ -18,7 +23,7 @@ import {
|
|
|
18
23
|
TooltipProvider,
|
|
19
24
|
TooltipTrigger,
|
|
20
25
|
cn
|
|
21
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4AKJ6FKE.esm.js";
|
|
22
27
|
|
|
23
28
|
// src/chat/tooltip-icon-button.tsx
|
|
24
29
|
import { forwardRef } from "react";
|
|
@@ -203,25 +208,17 @@ var ComposerAddAttachment = () => {
|
|
|
203
208
|
};
|
|
204
209
|
|
|
205
210
|
// src/charts/line-area-chart.tsx
|
|
206
|
-
import {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const w = entries[0]?.contentRect.width;
|
|
218
|
-
if (w && w > 0) setWidth(w);
|
|
219
|
-
});
|
|
220
|
-
ro.observe(el);
|
|
221
|
-
return () => ro.disconnect();
|
|
222
|
-
}, []);
|
|
223
|
-
return { ref, width };
|
|
224
|
-
}
|
|
211
|
+
import {
|
|
212
|
+
Area,
|
|
213
|
+
AreaChart,
|
|
214
|
+
Bar,
|
|
215
|
+
BarChart,
|
|
216
|
+
CartesianGrid,
|
|
217
|
+
Line,
|
|
218
|
+
LineChart,
|
|
219
|
+
XAxis,
|
|
220
|
+
YAxis
|
|
221
|
+
} from "recharts";
|
|
225
222
|
|
|
226
223
|
// src/charts/geometry.ts
|
|
227
224
|
function toNum(value) {
|
|
@@ -293,27 +290,6 @@ function monotoneTangents(points) {
|
|
|
293
290
|
}
|
|
294
291
|
return tangents;
|
|
295
292
|
}
|
|
296
|
-
function niceTicks(min, max, count = 4) {
|
|
297
|
-
if (!Number.isFinite(min) || !Number.isFinite(max) || max === min) {
|
|
298
|
-
return [min || 0];
|
|
299
|
-
}
|
|
300
|
-
const step = niceStep((max - min) / count);
|
|
301
|
-
const start = Math.floor(min / step) * step;
|
|
302
|
-
const out = [];
|
|
303
|
-
for (let v = start; v <= max + step / 2; v += step) {
|
|
304
|
-
out.push(round(v));
|
|
305
|
-
}
|
|
306
|
-
return out;
|
|
307
|
-
}
|
|
308
|
-
function niceStep(raw) {
|
|
309
|
-
const exp = Math.floor(Math.log10(Math.abs(raw) || 1));
|
|
310
|
-
const base = Math.pow(10, exp);
|
|
311
|
-
const norm = raw / base;
|
|
312
|
-
let nice = 1;
|
|
313
|
-
if (norm >= 5) nice = 5;
|
|
314
|
-
else if (norm >= 2) nice = 2;
|
|
315
|
-
return nice * base;
|
|
316
|
-
}
|
|
317
293
|
function round(v) {
|
|
318
294
|
return Math.round(v * 1e6) / 1e6;
|
|
319
295
|
}
|
|
@@ -327,17 +303,15 @@ function formatCompact(value, unit) {
|
|
|
327
303
|
}
|
|
328
304
|
|
|
329
305
|
// src/charts/line-area-chart.tsx
|
|
330
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
306
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
331
307
|
var CHART_PALETTE = [
|
|
332
|
-
"var(--
|
|
333
|
-
"#10b981",
|
|
334
|
-
"#f59e0b",
|
|
335
|
-
"#
|
|
336
|
-
"#
|
|
337
|
-
"#
|
|
308
|
+
"var(--chart-1, #6366f1)",
|
|
309
|
+
"var(--chart-2, #10b981)",
|
|
310
|
+
"var(--chart-3, #f59e0b)",
|
|
311
|
+
"var(--chart-4, #a855f7)",
|
|
312
|
+
"var(--chart-5, #ef4444)",
|
|
313
|
+
"var(--chart-6, #06b6d4)"
|
|
338
314
|
];
|
|
339
|
-
var PAD_DEFAULT = { top: 12, right: 16, bottom: 26, left: 44 };
|
|
340
|
-
var PAD_FLUSH = { top: 20, right: 0, bottom: 8, left: 0 };
|
|
341
315
|
var LineAreaChart = ({
|
|
342
316
|
data = [],
|
|
343
317
|
xKey: xKeyProp,
|
|
@@ -346,308 +320,222 @@ var LineAreaChart = ({
|
|
|
346
320
|
height = 240,
|
|
347
321
|
unit,
|
|
348
322
|
yMax,
|
|
323
|
+
curve = "monotone",
|
|
324
|
+
stacked = false,
|
|
325
|
+
dots = false,
|
|
326
|
+
orientation = "vertical",
|
|
327
|
+
barRadius = 4,
|
|
328
|
+
gridLines,
|
|
349
329
|
layout = "default",
|
|
350
330
|
showGrid = true,
|
|
351
331
|
showXAxis: showXAxisProp,
|
|
352
332
|
showYAxis: showYAxisProp,
|
|
353
333
|
showLegend: showLegendProp,
|
|
354
334
|
showTooltip = true,
|
|
335
|
+
tooltipIndicator = "dot",
|
|
355
336
|
formatValue,
|
|
356
337
|
formatX,
|
|
357
338
|
className,
|
|
358
339
|
ariaLabel = "Chart"
|
|
359
340
|
}) => {
|
|
360
|
-
const uid = useId();
|
|
361
|
-
const { ref, width } = useChartWidth();
|
|
362
|
-
const [active, setActive] = useState3(null);
|
|
363
|
-
const [grown, setGrown] = useState3(false);
|
|
364
341
|
const xKey = xKeyProp ?? inferXKey(data);
|
|
365
|
-
const series =
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
const showLegend = showLegendProp ?? (layout !== "flush" && series.length > 1);
|
|
373
|
-
useEffect3(() => {
|
|
374
|
-
const t = requestAnimationFrame(() => setGrown(true));
|
|
375
|
-
return () => cancelAnimationFrame(t);
|
|
376
|
-
}, []);
|
|
377
|
-
const innerW = Math.max(0, width - pad.left - pad.right);
|
|
378
|
-
const innerH = Math.max(0, height - pad.top - pad.bottom);
|
|
379
|
-
const { minV, maxV } = useMemo(() => {
|
|
380
|
-
let lo = 0;
|
|
381
|
-
let hi = yMax ?? 0;
|
|
382
|
-
for (const s of series) {
|
|
383
|
-
for (const d of data) {
|
|
384
|
-
const v = toNum(d[s.dataKey]);
|
|
385
|
-
if (v > hi && yMax == null) hi = v;
|
|
386
|
-
if (v < lo) lo = v;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
if (hi === lo) hi = lo + 1;
|
|
390
|
-
return { minV: lo, maxV: yMax != null ? yMax : hi * 1.08 };
|
|
391
|
-
}, [series, data, yMax]);
|
|
392
|
-
const ticks = useMemo(() => niceTicks(minV, maxV, 4), [minV, maxV]);
|
|
342
|
+
const series = resolveSeries(seriesProp, data, xKey);
|
|
343
|
+
const flush = layout === "flush";
|
|
344
|
+
const horizontal = orientation === "horizontal" && variant === "bar";
|
|
345
|
+
const showXAxis = showXAxisProp ?? !flush;
|
|
346
|
+
const showYAxis = showYAxisProp ?? !flush;
|
|
347
|
+
const showLegend = showLegendProp ?? (!flush && series.length > 1);
|
|
348
|
+
const grid = gridLines ?? (horizontal ? "vertical" : "horizontal");
|
|
393
349
|
if (data.length === 0 || series.length === 0) {
|
|
394
|
-
return /* @__PURE__ */ jsx3(ChartEmpty, { className, height });
|
|
395
|
-
}
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
350
|
+
return /* @__PURE__ */ jsx3(ChartEmpty, { className, height, ariaLabel });
|
|
351
|
+
}
|
|
352
|
+
const config = {};
|
|
353
|
+
series.forEach((s, i) => {
|
|
354
|
+
config[s.dataKey] = {
|
|
355
|
+
label: s.label ?? s.dataKey,
|
|
356
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
const valueFmt = (v) => formatValue ? formatValue(toNum(v)) : formatCompact(toNum(v), unit);
|
|
360
|
+
const xFmt = (v, i) => formatX ? formatX(v, i) : String(v ?? "");
|
|
361
|
+
const margin = flush ? { top: 8, right: 4, bottom: 0, left: 0 } : { top: 8, right: 12, bottom: 0, left: 0 };
|
|
362
|
+
const showVGrid = showGrid && (grid === "vertical" || grid === "both");
|
|
363
|
+
const showHGrid = showGrid && (grid === "horizontal" || grid === "both");
|
|
364
|
+
const tooltipEl = showTooltip ? /* @__PURE__ */ jsx3(
|
|
365
|
+
ChartTooltip,
|
|
366
|
+
{
|
|
367
|
+
cursor: variant === "bar",
|
|
368
|
+
content: /* @__PURE__ */ jsx3(ChartTooltipContent, { indicator: tooltipIndicator })
|
|
369
|
+
}
|
|
370
|
+
) : null;
|
|
371
|
+
const legendEl = showLegend ? /* @__PURE__ */ jsx3(ChartLegend, { content: /* @__PURE__ */ jsx3(ChartLegendContent, {}) }) : null;
|
|
372
|
+
const gridEl = showGrid && grid !== "none" ? /* @__PURE__ */ jsx3(CartesianGrid, { vertical: showVGrid, horizontal: showHGrid, strokeDasharray: "4 4" }) : null;
|
|
373
|
+
const yDomain = yMax != null ? [0, yMax] : void 0;
|
|
374
|
+
if (variant === "bar") {
|
|
375
|
+
const bars = series.map((s) => /* @__PURE__ */ jsx3(
|
|
376
|
+
Bar,
|
|
413
377
|
{
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
"
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
textAnchor: i === 0 ? "start" : i === xCount - 1 ? "end" : "middle",
|
|
498
|
-
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
499
|
-
children: fmtX(i)
|
|
500
|
-
},
|
|
501
|
-
i
|
|
502
|
-
)),
|
|
503
|
-
/* @__PURE__ */ jsx3("g", { clipPath: `url(#${uid}-grow)`, children: variant === "bar" ? renderBars({ data, series, xCount, xPos, yScale, baseY, innerW, uid }) : series.map((s, si) => {
|
|
504
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
505
|
-
const pts = data.map((d, i) => ({
|
|
506
|
-
x: xPos(i),
|
|
507
|
-
y: yScale(toNum(d[s.dataKey]))
|
|
508
|
-
}));
|
|
509
|
-
return /* @__PURE__ */ jsxs3("g", { children: [
|
|
510
|
-
variant === "area" && /* @__PURE__ */ jsx3("path", { d: monotoneAreaPath(pts, baseY), fill: `url(#${uid}-fill-${si})` }),
|
|
511
|
-
/* @__PURE__ */ jsx3(
|
|
512
|
-
"path",
|
|
513
|
-
{
|
|
514
|
-
d: monotoneLinePath(pts),
|
|
515
|
-
fill: "none",
|
|
516
|
-
stroke: color,
|
|
517
|
-
strokeWidth: 2,
|
|
518
|
-
strokeLinecap: "round",
|
|
519
|
-
strokeLinejoin: "round"
|
|
520
|
-
}
|
|
521
|
-
)
|
|
522
|
-
] }, s.dataKey);
|
|
523
|
-
}) }),
|
|
524
|
-
showTooltip && active != null && variant !== "bar" && /* @__PURE__ */ jsxs3("g", { pointerEvents: "none", children: [
|
|
525
|
-
/* @__PURE__ */ jsx3(
|
|
526
|
-
"line",
|
|
527
|
-
{
|
|
528
|
-
x1: xPos(active),
|
|
529
|
-
x2: xPos(active),
|
|
530
|
-
y1: pad.top,
|
|
531
|
-
y2: pad.top + innerH,
|
|
532
|
-
stroke: "currentColor",
|
|
533
|
-
strokeOpacity: 0.25,
|
|
534
|
-
className: "text-foreground"
|
|
535
|
-
}
|
|
536
|
-
),
|
|
537
|
-
series.map((s, si) => {
|
|
538
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
539
|
-
return /* @__PURE__ */ jsx3(
|
|
540
|
-
"circle",
|
|
541
|
-
{
|
|
542
|
-
cx: xPos(active),
|
|
543
|
-
cy: yScale(toNum(data[active]?.[s.dataKey])),
|
|
544
|
-
r: 4,
|
|
545
|
-
fill: color,
|
|
546
|
-
stroke: "var(--background, #fff)",
|
|
547
|
-
strokeWidth: 2
|
|
548
|
-
},
|
|
549
|
-
s.dataKey
|
|
550
|
-
);
|
|
551
|
-
})
|
|
552
|
-
] }),
|
|
553
|
-
showTooltip && /* @__PURE__ */ jsx3(
|
|
554
|
-
"rect",
|
|
555
|
-
{
|
|
556
|
-
x: pad.left,
|
|
557
|
-
y: pad.top,
|
|
558
|
-
width: innerW,
|
|
559
|
-
height: innerH,
|
|
560
|
-
fill: "transparent",
|
|
561
|
-
style: { cursor: "crosshair" },
|
|
562
|
-
onMouseMove: onMove,
|
|
563
|
-
onMouseLeave: () => setActive(null)
|
|
564
|
-
}
|
|
565
|
-
)
|
|
566
|
-
]
|
|
378
|
+
dataKey: s.dataKey,
|
|
379
|
+
fill: `var(--color-${s.dataKey})`,
|
|
380
|
+
radius: barCornerRadius(barRadius, horizontal, stacked),
|
|
381
|
+
stackId: stacked ? "stack" : void 0,
|
|
382
|
+
isAnimationActive: true
|
|
383
|
+
},
|
|
384
|
+
s.dataKey
|
|
385
|
+
));
|
|
386
|
+
if (horizontal) {
|
|
387
|
+
return /* @__PURE__ */ jsx3(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ jsxs3(BarChart, { accessibilityLayer: true, data, layout: "vertical", margin, children: [
|
|
388
|
+
gridEl,
|
|
389
|
+
/* @__PURE__ */ jsx3(
|
|
390
|
+
XAxis,
|
|
391
|
+
{
|
|
392
|
+
type: "number",
|
|
393
|
+
hide: !showXAxis,
|
|
394
|
+
tickLine: false,
|
|
395
|
+
axisLine: false,
|
|
396
|
+
tickMargin: 8,
|
|
397
|
+
tickFormatter: (v) => valueFmt(v),
|
|
398
|
+
domain: yDomain
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
/* @__PURE__ */ jsx3(
|
|
402
|
+
YAxis,
|
|
403
|
+
{
|
|
404
|
+
type: "category",
|
|
405
|
+
dataKey: xKey,
|
|
406
|
+
hide: !showYAxis,
|
|
407
|
+
tickLine: false,
|
|
408
|
+
axisLine: false,
|
|
409
|
+
tickMargin: 8,
|
|
410
|
+
width: showYAxis ? void 0 : 0,
|
|
411
|
+
tickFormatter: (v, i) => xFmt(v, i)
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
tooltipEl,
|
|
415
|
+
legendEl,
|
|
416
|
+
bars
|
|
417
|
+
] }) });
|
|
418
|
+
}
|
|
419
|
+
return /* @__PURE__ */ jsx3(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ jsxs3(BarChart, { accessibilityLayer: true, data, margin, children: [
|
|
420
|
+
gridEl,
|
|
421
|
+
/* @__PURE__ */ jsx3(
|
|
422
|
+
XAxis,
|
|
423
|
+
{
|
|
424
|
+
dataKey: xKey,
|
|
425
|
+
hide: !showXAxis,
|
|
426
|
+
tickLine: false,
|
|
427
|
+
axisLine: false,
|
|
428
|
+
tickMargin: 8,
|
|
429
|
+
minTickGap: 16,
|
|
430
|
+
tickFormatter: (v, i) => xFmt(v, i)
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ jsx3(
|
|
434
|
+
YAxis,
|
|
435
|
+
{
|
|
436
|
+
hide: !showYAxis,
|
|
437
|
+
tickLine: false,
|
|
438
|
+
axisLine: false,
|
|
439
|
+
tickMargin: 8,
|
|
440
|
+
width: showYAxis ? 44 : 0,
|
|
441
|
+
tickFormatter: (v) => valueFmt(v),
|
|
442
|
+
domain: yDomain
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
tooltipEl,
|
|
446
|
+
legendEl,
|
|
447
|
+
bars
|
|
448
|
+
] }) });
|
|
449
|
+
}
|
|
450
|
+
const axes = /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
451
|
+
/* @__PURE__ */ jsx3(
|
|
452
|
+
XAxis,
|
|
453
|
+
{
|
|
454
|
+
dataKey: xKey,
|
|
455
|
+
hide: !showXAxis,
|
|
456
|
+
tickLine: false,
|
|
457
|
+
axisLine: false,
|
|
458
|
+
tickMargin: 8,
|
|
459
|
+
minTickGap: 24,
|
|
460
|
+
tickFormatter: (v, i) => xFmt(v, i)
|
|
567
461
|
}
|
|
568
462
|
),
|
|
569
|
-
|
|
570
|
-
|
|
463
|
+
/* @__PURE__ */ jsx3(
|
|
464
|
+
YAxis,
|
|
571
465
|
{
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}))
|
|
466
|
+
hide: !showYAxis,
|
|
467
|
+
tickLine: false,
|
|
468
|
+
axisLine: false,
|
|
469
|
+
tickMargin: 8,
|
|
470
|
+
width: showYAxis ? 44 : 0,
|
|
471
|
+
tickFormatter: (v) => valueFmt(v),
|
|
472
|
+
domain: yDomain
|
|
580
473
|
}
|
|
581
|
-
)
|
|
582
|
-
showLegend ? /* @__PURE__ */ jsx3(ChartLegend, { series }) : null
|
|
474
|
+
)
|
|
583
475
|
] });
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
return /* @__PURE__ */ jsx3(
|
|
597
|
-
"rect",
|
|
476
|
+
if (variant === "area") {
|
|
477
|
+
return /* @__PURE__ */ jsx3(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ jsxs3(AreaChart, { accessibilityLayer: true, data, margin, children: [
|
|
478
|
+
/* @__PURE__ */ jsx3("defs", { children: series.map((s) => /* @__PURE__ */ jsxs3("linearGradient", { id: `fill-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
479
|
+
/* @__PURE__ */ jsx3("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
|
|
480
|
+
/* @__PURE__ */ jsx3("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.04 })
|
|
481
|
+
] }, s.dataKey)) }),
|
|
482
|
+
gridEl,
|
|
483
|
+
axes,
|
|
484
|
+
tooltipEl,
|
|
485
|
+
legendEl,
|
|
486
|
+
series.map((s) => /* @__PURE__ */ jsx3(
|
|
487
|
+
Area,
|
|
598
488
|
{
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
fill:
|
|
489
|
+
dataKey: s.dataKey,
|
|
490
|
+
type: curve,
|
|
491
|
+
stackId: stacked ? "stack" : void 0,
|
|
492
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
493
|
+
strokeWidth: 2,
|
|
494
|
+
fill: `url(#fill-${s.dataKey})`,
|
|
495
|
+
dot: dots === true ? { r: 3 } : false,
|
|
496
|
+
activeDot: { r: 4 },
|
|
497
|
+
isAnimationActive: true
|
|
605
498
|
},
|
|
606
|
-
|
|
607
|
-
)
|
|
608
|
-
})
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
499
|
+
s.dataKey
|
|
500
|
+
))
|
|
501
|
+
] }) });
|
|
502
|
+
}
|
|
503
|
+
return /* @__PURE__ */ jsx3(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ jsxs3(LineChart, { accessibilityLayer: true, data, margin, children: [
|
|
504
|
+
gridEl,
|
|
505
|
+
axes,
|
|
506
|
+
tooltipEl,
|
|
507
|
+
legendEl,
|
|
508
|
+
series.map((s) => /* @__PURE__ */ jsx3(
|
|
509
|
+
Line,
|
|
510
|
+
{
|
|
511
|
+
dataKey: s.dataKey,
|
|
512
|
+
type: curve,
|
|
513
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
514
|
+
strokeWidth: 2,
|
|
515
|
+
dot: dots === true ? { r: 3 } : false,
|
|
516
|
+
activeDot: { r: 4 },
|
|
517
|
+
isAnimationActive: true
|
|
620
518
|
},
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
/* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
625
|
-
/* @__PURE__ */ jsx3(
|
|
626
|
-
"span",
|
|
627
|
-
{
|
|
628
|
-
className: "inline-block size-2 rounded-full",
|
|
629
|
-
style: { background: r.color }
|
|
630
|
-
}
|
|
631
|
-
),
|
|
632
|
-
r.label
|
|
633
|
-
] }),
|
|
634
|
-
/* @__PURE__ */ jsx3("span", { className: "text-xs font-medium tabular-nums text-foreground", children: r.value })
|
|
635
|
-
] }, r.label)) })
|
|
636
|
-
]
|
|
637
|
-
}
|
|
638
|
-
);
|
|
519
|
+
s.dataKey
|
|
520
|
+
))
|
|
521
|
+
] }) });
|
|
639
522
|
};
|
|
640
|
-
var
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
523
|
+
var ChartShell = ({ config, height, className, ariaLabel, children }) => /* @__PURE__ */ jsx3(
|
|
524
|
+
ChartContainer,
|
|
525
|
+
{
|
|
526
|
+
config,
|
|
527
|
+
role: "img",
|
|
528
|
+
"aria-label": ariaLabel,
|
|
529
|
+
className: cn("aspect-auto w-full", className),
|
|
530
|
+
style: { height },
|
|
531
|
+
children
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
var ChartEmpty = ({
|
|
535
|
+
className,
|
|
536
|
+
height,
|
|
537
|
+
ariaLabel
|
|
538
|
+
}) => /* @__PURE__ */ jsx3(
|
|
651
539
|
"div",
|
|
652
540
|
{
|
|
653
541
|
className: cn(
|
|
@@ -655,9 +543,15 @@ var ChartEmpty = ({ className, height }) => /* @__PURE__ */ jsx3(
|
|
|
655
543
|
className
|
|
656
544
|
),
|
|
657
545
|
style: { height },
|
|
546
|
+
role: "img",
|
|
547
|
+
"aria-label": ariaLabel,
|
|
658
548
|
children: "No data yet"
|
|
659
549
|
}
|
|
660
550
|
);
|
|
551
|
+
function barCornerRadius(r, horizontal, stacked) {
|
|
552
|
+
if (stacked) return r;
|
|
553
|
+
return horizontal ? [0, r, r, 0] : [r, r, 0, 0];
|
|
554
|
+
}
|
|
661
555
|
function inferXKey(data) {
|
|
662
556
|
if (data.length === 0) return "x";
|
|
663
557
|
for (const k of Object.keys(data[0])) {
|
|
@@ -672,21 +566,316 @@ function resolveSeries(seriesProp, data, xKey) {
|
|
|
672
566
|
if (data.length === 0) return [];
|
|
673
567
|
return Object.keys(data[0]).filter((k) => k !== xKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
674
568
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
569
|
+
|
|
570
|
+
// src/charts/pie-chart.tsx
|
|
571
|
+
import { Cell, Label, Pie, PieChart as RePieChart } from "recharts";
|
|
572
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
573
|
+
var PieChart = ({
|
|
574
|
+
data,
|
|
575
|
+
nameKey: nameKeyProp,
|
|
576
|
+
dataKey = "value",
|
|
577
|
+
innerRadius = 0,
|
|
578
|
+
colors,
|
|
579
|
+
height = 260,
|
|
580
|
+
showLegend = true,
|
|
581
|
+
showLabels = false,
|
|
582
|
+
showTooltip = true,
|
|
583
|
+
tooltipIndicator = "dot",
|
|
584
|
+
centerValue,
|
|
585
|
+
centerLabel,
|
|
586
|
+
className,
|
|
587
|
+
ariaLabel = "Pie chart"
|
|
588
|
+
}) => {
|
|
589
|
+
const nameKey = nameKeyProp ?? inferNameKey(data, dataKey);
|
|
590
|
+
const palette = colors ?? CHART_PALETTE;
|
|
591
|
+
if (data.length === 0) {
|
|
592
|
+
return /* @__PURE__ */ jsx4(PieEmpty, { className, height, ariaLabel });
|
|
593
|
+
}
|
|
594
|
+
const slices = data.map((d, i) => ({
|
|
595
|
+
name: String(d[nameKey] ?? i),
|
|
596
|
+
value: toNum(d[dataKey]),
|
|
597
|
+
fill: palette[i % palette.length]
|
|
598
|
+
}));
|
|
599
|
+
const config = {};
|
|
600
|
+
for (const s of slices) config[s.name] = { label: s.name };
|
|
601
|
+
const innerPct = innerRadius > 0 ? `${Math.round(innerRadius * 75)}%` : 0;
|
|
602
|
+
const hasCenter = innerRadius > 0 && (centerValue != null || centerLabel != null);
|
|
603
|
+
return /* @__PURE__ */ jsx4(
|
|
604
|
+
ChartContainer,
|
|
605
|
+
{
|
|
606
|
+
config,
|
|
607
|
+
role: "img",
|
|
608
|
+
"aria-label": ariaLabel,
|
|
609
|
+
className: cn("aspect-auto w-full", className),
|
|
610
|
+
style: { height },
|
|
611
|
+
children: /* @__PURE__ */ jsxs4(RePieChart, { children: [
|
|
612
|
+
showTooltip && /* @__PURE__ */ jsx4(
|
|
613
|
+
ChartTooltip,
|
|
614
|
+
{
|
|
615
|
+
content: /* @__PURE__ */ jsx4(ChartTooltipContent, { nameKey: "name", indicator: tooltipIndicator, hideLabel: true })
|
|
616
|
+
}
|
|
617
|
+
),
|
|
618
|
+
/* @__PURE__ */ jsxs4(
|
|
619
|
+
Pie,
|
|
620
|
+
{
|
|
621
|
+
data: slices,
|
|
622
|
+
dataKey: "value",
|
|
623
|
+
nameKey: "name",
|
|
624
|
+
innerRadius: innerPct,
|
|
625
|
+
outerRadius: "75%",
|
|
626
|
+
paddingAngle: innerRadius > 0 ? 2 : 0,
|
|
627
|
+
strokeWidth: 2,
|
|
628
|
+
label: showLabels,
|
|
629
|
+
isAnimationActive: true,
|
|
630
|
+
children: [
|
|
631
|
+
slices.map((s) => /* @__PURE__ */ jsx4(Cell, { fill: s.fill }, s.name)),
|
|
632
|
+
hasCenter && /* @__PURE__ */ jsx4(
|
|
633
|
+
Label,
|
|
634
|
+
{
|
|
635
|
+
content: ({ viewBox }) => {
|
|
636
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
637
|
+
const { cx, cy } = viewBox;
|
|
638
|
+
return /* @__PURE__ */ jsxs4("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "middle", children: [
|
|
639
|
+
centerValue != null && /* @__PURE__ */ jsx4("tspan", { x: cx, y: cy - 2, className: "fill-foreground text-2xl tabular-nums", children: centerValue }),
|
|
640
|
+
centerLabel != null && /* @__PURE__ */ jsx4("tspan", { x: cx, y: cy + 18, className: "fill-muted-foreground text-[11px]", children: centerLabel })
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
)
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
showLegend && /* @__PURE__ */ jsx4(ChartLegend, { content: /* @__PURE__ */ jsx4(ChartLegendContent, { nameKey: "name" }) })
|
|
649
|
+
] })
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
};
|
|
653
|
+
var PieEmpty = ({
|
|
654
|
+
className,
|
|
655
|
+
height,
|
|
656
|
+
ariaLabel
|
|
657
|
+
}) => /* @__PURE__ */ jsx4(
|
|
658
|
+
"div",
|
|
659
|
+
{
|
|
660
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
661
|
+
style: { height },
|
|
662
|
+
role: "img",
|
|
663
|
+
"aria-label": ariaLabel,
|
|
664
|
+
children: "No data yet"
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
function inferNameKey(data, dataKey) {
|
|
668
|
+
if (data.length === 0) return "name";
|
|
669
|
+
for (const k of Object.keys(data[0])) {
|
|
670
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
671
|
+
}
|
|
672
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/charts/radial-chart.tsx
|
|
676
|
+
import {
|
|
677
|
+
Cell as Cell2,
|
|
678
|
+
Label as Label2,
|
|
679
|
+
PolarAngleAxis,
|
|
680
|
+
PolarRadiusAxis,
|
|
681
|
+
RadialBar,
|
|
682
|
+
RadialBarChart
|
|
683
|
+
} from "recharts";
|
|
684
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
685
|
+
var RadialChart = ({
|
|
686
|
+
data,
|
|
687
|
+
nameKey: nameKeyProp,
|
|
688
|
+
dataKey = "value",
|
|
689
|
+
maxValue,
|
|
690
|
+
colors,
|
|
691
|
+
height = 260,
|
|
692
|
+
ringWidth = 16,
|
|
693
|
+
ringGap = 4,
|
|
694
|
+
showLegend = true,
|
|
695
|
+
centerValue,
|
|
696
|
+
centerLabel,
|
|
697
|
+
className,
|
|
698
|
+
ariaLabel = "Radial chart"
|
|
699
|
+
}) => {
|
|
700
|
+
const nameKey = nameKeyProp ?? inferNameKey2(data, dataKey);
|
|
701
|
+
const palette = colors ?? CHART_PALETTE;
|
|
702
|
+
if (data.length === 0) {
|
|
703
|
+
return /* @__PURE__ */ jsx5(RadialEmpty, { className, height, ariaLabel });
|
|
704
|
+
}
|
|
705
|
+
const rows = data.map((d, i) => ({
|
|
706
|
+
name: String(d[nameKey] ?? i),
|
|
707
|
+
value: toNum(d[dataKey]),
|
|
708
|
+
fill: palette[i % palette.length]
|
|
709
|
+
}));
|
|
710
|
+
const max = maxValue ?? Math.max(...rows.map((r) => r.value), 1);
|
|
711
|
+
const config = {};
|
|
712
|
+
for (const r of rows) config[r.name] = { label: r.name };
|
|
713
|
+
const hasCenter = centerValue != null || centerLabel != null;
|
|
714
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("flex w-full flex-col items-center gap-3", className), children: [
|
|
715
|
+
/* @__PURE__ */ jsx5(
|
|
716
|
+
ChartContainer,
|
|
717
|
+
{
|
|
718
|
+
config,
|
|
719
|
+
role: "img",
|
|
720
|
+
"aria-label": ariaLabel,
|
|
721
|
+
className: "aspect-auto w-full",
|
|
722
|
+
style: { height: height - (showLegend ? 32 : 0) },
|
|
723
|
+
children: /* @__PURE__ */ jsxs5(
|
|
724
|
+
RadialBarChart,
|
|
725
|
+
{
|
|
726
|
+
data: rows,
|
|
727
|
+
startAngle: 90,
|
|
728
|
+
endAngle: -270,
|
|
729
|
+
innerRadius: "30%",
|
|
730
|
+
outerRadius: "100%",
|
|
731
|
+
barSize: ringWidth,
|
|
732
|
+
barGap: ringGap,
|
|
733
|
+
children: [
|
|
734
|
+
/* @__PURE__ */ jsx5(PolarAngleAxis, { type: "number", domain: [0, max], tick: false, axisLine: false }),
|
|
735
|
+
/* @__PURE__ */ jsx5(ChartTooltip, { content: /* @__PURE__ */ jsx5(ChartTooltipContent, { nameKey: "name", hideLabel: true }) }),
|
|
736
|
+
/* @__PURE__ */ jsx5(RadialBar, { dataKey: "value", background: true, cornerRadius: ringWidth / 2, isAnimationActive: true, children: rows.map((r) => /* @__PURE__ */ jsx5(Cell2, { fill: r.fill }, r.name)) }),
|
|
737
|
+
hasCenter && /* @__PURE__ */ jsx5(PolarRadiusAxis, { tick: false, tickLine: false, axisLine: false, children: /* @__PURE__ */ jsx5(
|
|
738
|
+
Label2,
|
|
739
|
+
{
|
|
740
|
+
content: ({ viewBox }) => {
|
|
741
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
742
|
+
const { cx, cy } = viewBox;
|
|
743
|
+
return /* @__PURE__ */ jsxs5("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "middle", children: [
|
|
744
|
+
centerValue != null && /* @__PURE__ */ jsx5("tspan", { x: cx, y: cy - 2, className: "fill-foreground text-2xl tabular-nums", children: centerValue }),
|
|
745
|
+
centerLabel != null && /* @__PURE__ */ jsx5("tspan", { x: cx, y: cy + 18, className: "fill-muted-foreground text-[11px]", children: centerLabel })
|
|
746
|
+
] });
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
) })
|
|
750
|
+
]
|
|
751
|
+
}
|
|
752
|
+
)
|
|
753
|
+
}
|
|
754
|
+
),
|
|
755
|
+
showLegend && /* @__PURE__ */ jsx5("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: rows.map((r) => /* @__PURE__ */ jsxs5("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
756
|
+
/* @__PURE__ */ jsx5("span", { className: "inline-block size-2.5 rounded-[3px]", style: { background: r.fill } }),
|
|
757
|
+
r.name
|
|
758
|
+
] }, r.name)) })
|
|
759
|
+
] });
|
|
760
|
+
};
|
|
761
|
+
var RadialEmpty = ({
|
|
762
|
+
className,
|
|
763
|
+
height,
|
|
764
|
+
ariaLabel
|
|
765
|
+
}) => /* @__PURE__ */ jsx5(
|
|
766
|
+
"div",
|
|
767
|
+
{
|
|
768
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
769
|
+
style: { height },
|
|
770
|
+
role: "img",
|
|
771
|
+
"aria-label": ariaLabel,
|
|
772
|
+
children: "No data yet"
|
|
773
|
+
}
|
|
774
|
+
);
|
|
775
|
+
function inferNameKey2(data, dataKey) {
|
|
776
|
+
if (data.length === 0) return "name";
|
|
777
|
+
for (const k of Object.keys(data[0])) {
|
|
778
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
779
|
+
}
|
|
780
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/charts/radar-chart.tsx
|
|
784
|
+
import {
|
|
785
|
+
PolarAngleAxis as PolarAngleAxis2,
|
|
786
|
+
PolarGrid,
|
|
787
|
+
Radar,
|
|
788
|
+
RadarChart as ReRadarChart
|
|
789
|
+
} from "recharts";
|
|
790
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
791
|
+
var RadarChart = ({
|
|
792
|
+
data,
|
|
793
|
+
nameKey: nameKeyProp,
|
|
794
|
+
series: seriesProp,
|
|
795
|
+
maxValue,
|
|
796
|
+
height = 280,
|
|
797
|
+
showLegend = true,
|
|
798
|
+
fill = true,
|
|
799
|
+
className,
|
|
800
|
+
ariaLabel = "Radar chart"
|
|
801
|
+
}) => {
|
|
802
|
+
const nameKey = nameKeyProp ?? inferNameKey3(data);
|
|
803
|
+
const series = resolveSeries2(seriesProp, data, nameKey);
|
|
804
|
+
if (data.length < 3 || series.length === 0) {
|
|
805
|
+
return /* @__PURE__ */ jsx6(
|
|
806
|
+
"div",
|
|
807
|
+
{
|
|
808
|
+
className: cn("flex items-center justify-center text-xs text-muted-foreground", className),
|
|
809
|
+
style: { height },
|
|
810
|
+
role: "img",
|
|
811
|
+
"aria-label": ariaLabel,
|
|
812
|
+
children: "Radar needs at least 3 axes"
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
const config = {};
|
|
817
|
+
series.forEach((s, i) => {
|
|
818
|
+
config[s.dataKey] = {
|
|
819
|
+
label: s.label ?? s.dataKey,
|
|
820
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
821
|
+
};
|
|
822
|
+
});
|
|
823
|
+
return /* @__PURE__ */ jsx6(
|
|
824
|
+
ChartContainer,
|
|
825
|
+
{
|
|
826
|
+
config,
|
|
827
|
+
role: "img",
|
|
828
|
+
"aria-label": ariaLabel,
|
|
829
|
+
className: cn("mx-auto aspect-square", className),
|
|
830
|
+
style: { height },
|
|
831
|
+
children: /* @__PURE__ */ jsxs6(ReRadarChart, { data, outerRadius: "70%", children: [
|
|
832
|
+
/* @__PURE__ */ jsx6(ChartTooltip, { content: /* @__PURE__ */ jsx6(ChartTooltipContent, { indicator: "line" }) }),
|
|
833
|
+
/* @__PURE__ */ jsx6(PolarGrid, {}),
|
|
834
|
+
/* @__PURE__ */ jsx6(
|
|
835
|
+
PolarAngleAxis2,
|
|
836
|
+
{
|
|
837
|
+
dataKey: nameKey,
|
|
838
|
+
tick: { fontSize: 10, fill: "var(--color-muted-foreground)" }
|
|
839
|
+
}
|
|
840
|
+
),
|
|
841
|
+
series.map((s) => /* @__PURE__ */ jsx6(
|
|
842
|
+
Radar,
|
|
843
|
+
{
|
|
844
|
+
dataKey: s.dataKey,
|
|
845
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
846
|
+
fill: `var(--color-${s.dataKey})`,
|
|
847
|
+
fillOpacity: fill ? 0.18 : 0,
|
|
848
|
+
strokeWidth: 2,
|
|
849
|
+
dot: { r: 2.5, fillOpacity: 1 },
|
|
850
|
+
isAnimationActive: true
|
|
851
|
+
},
|
|
852
|
+
s.dataKey
|
|
853
|
+
)),
|
|
854
|
+
showLegend && series.length > 1 && /* @__PURE__ */ jsx6(ChartLegend, { content: /* @__PURE__ */ jsx6(ChartLegendContent, {}) })
|
|
855
|
+
] })
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
};
|
|
859
|
+
function inferNameKey3(data) {
|
|
860
|
+
if (data.length === 0) return "name";
|
|
861
|
+
for (const k of Object.keys(data[0])) {
|
|
862
|
+
if (typeof data[0][k] !== "number") return k;
|
|
863
|
+
}
|
|
864
|
+
return Object.keys(data[0])[0] ?? "name";
|
|
865
|
+
}
|
|
866
|
+
function resolveSeries2(seriesProp, data, nameKey) {
|
|
867
|
+
if (seriesProp && seriesProp.length > 0) {
|
|
868
|
+
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
869
|
+
}
|
|
870
|
+
if (data.length === 0) return [];
|
|
871
|
+
return Object.keys(data[0]).filter((k) => k !== nameKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
683
872
|
}
|
|
684
873
|
|
|
685
874
|
// src/artifacts/artifact-card.tsx
|
|
686
|
-
import { jsx as
|
|
875
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
687
876
|
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
688
877
|
const hasHeader = Boolean(title || toolbar);
|
|
689
|
-
return /* @__PURE__ */
|
|
878
|
+
return /* @__PURE__ */ jsxs7(
|
|
690
879
|
"div",
|
|
691
880
|
{
|
|
692
881
|
className: cn(
|
|
@@ -695,30 +884,30 @@ var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }
|
|
|
695
884
|
),
|
|
696
885
|
"data-artifact-kind": kind,
|
|
697
886
|
children: [
|
|
698
|
-
hasHeader && /* @__PURE__ */
|
|
699
|
-
title && /* @__PURE__ */
|
|
700
|
-
!title && /* @__PURE__ */
|
|
887
|
+
hasHeader && /* @__PURE__ */ jsxs7("div", { className: "aui-artifact-header flex items-center gap-2 border-b border-border/40 bg-muted/30 px-3 py-1.5", children: [
|
|
888
|
+
title && /* @__PURE__ */ jsx7("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
889
|
+
!title && /* @__PURE__ */ jsx7("span", { className: "flex-1" }),
|
|
701
890
|
toolbar
|
|
702
891
|
] }),
|
|
703
|
-
/* @__PURE__ */
|
|
892
|
+
/* @__PURE__ */ jsx7("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
704
893
|
]
|
|
705
894
|
}
|
|
706
895
|
);
|
|
707
896
|
};
|
|
708
897
|
|
|
709
898
|
// src/artifacts/chart-artifact.tsx
|
|
710
|
-
import { useMemo
|
|
711
|
-
import { jsx as
|
|
899
|
+
import { useMemo } from "react";
|
|
900
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
712
901
|
var ChartArtifactView = ({
|
|
713
902
|
artifact,
|
|
714
903
|
embedded = false,
|
|
715
904
|
height = 300
|
|
716
905
|
}) => {
|
|
717
|
-
const plot = /* @__PURE__ */
|
|
906
|
+
const plot = /* @__PURE__ */ jsx8(ChartArtifactPlot, { artifact, height });
|
|
718
907
|
if (embedded) {
|
|
719
|
-
return /* @__PURE__ */
|
|
908
|
+
return /* @__PURE__ */ jsx8("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
720
909
|
}
|
|
721
|
-
return /* @__PURE__ */
|
|
910
|
+
return /* @__PURE__ */ jsx8(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ jsx8("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
722
911
|
};
|
|
723
912
|
function ChartArtifactPlot({
|
|
724
913
|
artifact,
|
|
@@ -726,14 +915,58 @@ function ChartArtifactPlot({
|
|
|
726
915
|
}) {
|
|
727
916
|
const { chartType = "bar", data = [] } = artifact;
|
|
728
917
|
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
729
|
-
const series =
|
|
918
|
+
const series = useMemo(() => {
|
|
919
|
+
if (artifact.series && artifact.series.length > 0) {
|
|
920
|
+
return artifact.series.map((s) => ({
|
|
921
|
+
dataKey: s.dataKey,
|
|
922
|
+
label: s.label,
|
|
923
|
+
color: s.color
|
|
924
|
+
}));
|
|
925
|
+
}
|
|
730
926
|
const keys = Array.isArray(artifact.dataKey) ? artifact.dataKey : typeof artifact.dataKey === "string" ? [artifact.dataKey] : inferDataKeys(data, xKey);
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
927
|
+
const colors = artifact.colors;
|
|
928
|
+
return keys.map((dataKey, i) => ({
|
|
929
|
+
dataKey,
|
|
930
|
+
color: colors?.[i]
|
|
931
|
+
}));
|
|
932
|
+
}, [artifact.series, artifact.dataKey, artifact.colors, data, xKey]);
|
|
933
|
+
const aria = typeof artifact.title === "string" ? artifact.title : "Chart";
|
|
934
|
+
if (chartType === "pie" || chartType === "donut") {
|
|
935
|
+
const total = data.reduce((sum, d) => sum + toNum(d[series[0]?.dataKey ?? "value"]), 0);
|
|
936
|
+
return /* @__PURE__ */ jsx8("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ jsx8(
|
|
937
|
+
PieChart,
|
|
938
|
+
{
|
|
939
|
+
data,
|
|
940
|
+
nameKey: xKey,
|
|
941
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
942
|
+
innerRadius: chartType === "donut" ? 0.6 : 0,
|
|
943
|
+
colors: artifact.colors,
|
|
944
|
+
height,
|
|
945
|
+
unit: artifact.unit,
|
|
946
|
+
centerValue: chartType === "donut" ? formatCompact(total, artifact.unit) : void 0,
|
|
947
|
+
centerLabel: chartType === "donut" ? "Total" : void 0,
|
|
948
|
+
ariaLabel: aria
|
|
949
|
+
}
|
|
950
|
+
) });
|
|
951
|
+
}
|
|
952
|
+
if (chartType === "radial") {
|
|
953
|
+
return /* @__PURE__ */ jsx8("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ jsx8(
|
|
954
|
+
RadialChart,
|
|
955
|
+
{
|
|
956
|
+
data,
|
|
957
|
+
nameKey: xKey,
|
|
958
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
959
|
+
colors: artifact.colors,
|
|
960
|
+
height,
|
|
961
|
+
ariaLabel: aria
|
|
962
|
+
}
|
|
963
|
+
) });
|
|
735
964
|
}
|
|
736
|
-
|
|
965
|
+
if (chartType === "radar") {
|
|
966
|
+
return /* @__PURE__ */ jsx8("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ jsx8(RadarChart, { data, nameKey: xKey, series, height, ariaLabel: aria }) });
|
|
967
|
+
}
|
|
968
|
+
const horizontal = chartType === "horizontalBar";
|
|
969
|
+
return /* @__PURE__ */ jsx8(
|
|
737
970
|
LineAreaChart,
|
|
738
971
|
{
|
|
739
972
|
data,
|
|
@@ -742,71 +975,19 @@ function ChartArtifactPlot({
|
|
|
742
975
|
layout: "flush",
|
|
743
976
|
height,
|
|
744
977
|
variant: chartType === "line" ? "line" : chartType === "area" ? "area" : "bar",
|
|
978
|
+
orientation: horizontal ? "horizontal" : "vertical",
|
|
979
|
+
stacked: artifact.stacked,
|
|
980
|
+
curve: artifact.curve,
|
|
981
|
+
dots: artifact.dots,
|
|
982
|
+
tooltipIndicator: artifact.tooltipIndicator,
|
|
983
|
+
showXAxis: true,
|
|
984
|
+
showYAxis: horizontal,
|
|
985
|
+
showLegend: artifact.legend ?? series.length > 1,
|
|
745
986
|
unit: artifact.unit,
|
|
746
|
-
ariaLabel:
|
|
987
|
+
ariaLabel: aria
|
|
747
988
|
}
|
|
748
989
|
);
|
|
749
990
|
}
|
|
750
|
-
var PIE_W = 320;
|
|
751
|
-
var PIE_H = 220;
|
|
752
|
-
var PieChart = ({ data, xKey, dataKey }) => {
|
|
753
|
-
if (data.length === 0) {
|
|
754
|
-
return /* @__PURE__ */ jsx5("div", { className: "flex h-32 items-center justify-center text-xs text-muted-foreground", children: "No data" });
|
|
755
|
-
}
|
|
756
|
-
const cx = PIE_W / 2;
|
|
757
|
-
const cy = PIE_H / 2;
|
|
758
|
-
const r = Math.min(PIE_W, PIE_H) / 2 - 16;
|
|
759
|
-
const total = data.reduce((sum, d) => sum + toNum(d[dataKey]), 0) || 1;
|
|
760
|
-
let acc = 0;
|
|
761
|
-
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center gap-3", children: [
|
|
762
|
-
/* @__PURE__ */ jsx5(
|
|
763
|
-
"svg",
|
|
764
|
-
{
|
|
765
|
-
viewBox: `0 0 ${PIE_W} ${PIE_H}`,
|
|
766
|
-
className: "w-full max-w-[20rem]",
|
|
767
|
-
role: "img",
|
|
768
|
-
"aria-label": "Pie chart",
|
|
769
|
-
children: data.map((d, i) => {
|
|
770
|
-
const value = toNum(d[dataKey]);
|
|
771
|
-
const start = acc / total * Math.PI * 2;
|
|
772
|
-
acc += value;
|
|
773
|
-
const end = acc / total * Math.PI * 2;
|
|
774
|
-
return /* @__PURE__ */ jsx5(
|
|
775
|
-
PieSlice,
|
|
776
|
-
{
|
|
777
|
-
cx,
|
|
778
|
-
cy,
|
|
779
|
-
r,
|
|
780
|
-
start,
|
|
781
|
-
end,
|
|
782
|
-
color: CHART_PALETTE[i % CHART_PALETTE.length]
|
|
783
|
-
},
|
|
784
|
-
i
|
|
785
|
-
);
|
|
786
|
-
})
|
|
787
|
-
}
|
|
788
|
-
),
|
|
789
|
-
/* @__PURE__ */ jsx5("div", { className: "flex flex-wrap items-center justify-center gap-x-3 gap-y-1 text-xs text-muted-foreground", children: data.map((d, i) => /* @__PURE__ */ jsxs5("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
790
|
-
/* @__PURE__ */ jsx5(
|
|
791
|
-
"span",
|
|
792
|
-
{
|
|
793
|
-
className: "inline-block size-2 rounded-sm",
|
|
794
|
-
style: { background: CHART_PALETTE[i % CHART_PALETTE.length] }
|
|
795
|
-
}
|
|
796
|
-
),
|
|
797
|
-
String(d[xKey] ?? i)
|
|
798
|
-
] }, i)) })
|
|
799
|
-
] });
|
|
800
|
-
};
|
|
801
|
-
var PieSlice = ({ cx, cy, r, start, end, color }) => {
|
|
802
|
-
const x1 = cx + Math.sin(start) * r;
|
|
803
|
-
const y1 = cy - Math.cos(start) * r;
|
|
804
|
-
const x2 = cx + Math.sin(end) * r;
|
|
805
|
-
const y2 = cy - Math.cos(end) * r;
|
|
806
|
-
const large = end - start > Math.PI ? 1 : 0;
|
|
807
|
-
const path = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
808
|
-
return /* @__PURE__ */ jsx5("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1.5 });
|
|
809
|
-
};
|
|
810
991
|
function inferXKey2(data) {
|
|
811
992
|
if (data.length === 0) return "x";
|
|
812
993
|
for (const k of Object.keys(data[0])) {
|
|
@@ -822,7 +1003,7 @@ function inferDataKeys(data, xKey) {
|
|
|
822
1003
|
}
|
|
823
1004
|
|
|
824
1005
|
// src/artifacts/question-artifact.tsx
|
|
825
|
-
import { useCallback, useState as
|
|
1006
|
+
import { useCallback, useState as useState2 } from "react";
|
|
826
1007
|
import { useThreadRuntime } from "@assistant-ui/react";
|
|
827
1008
|
import { CheckIcon } from "lucide-react";
|
|
828
1009
|
|
|
@@ -938,12 +1119,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
938
1119
|
);
|
|
939
1120
|
|
|
940
1121
|
// src/artifacts/question-artifact.tsx
|
|
941
|
-
import { jsx as
|
|
1122
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
942
1123
|
function optionKey(option, index) {
|
|
943
1124
|
const id = option.id?.trim();
|
|
944
1125
|
return id ? id : `__option-${index}`;
|
|
945
1126
|
}
|
|
946
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */
|
|
1127
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ jsx9(
|
|
947
1128
|
"span",
|
|
948
1129
|
{
|
|
949
1130
|
className: cn(
|
|
@@ -951,15 +1132,15 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ jsx6(
|
|
|
951
1132
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
952
1133
|
),
|
|
953
1134
|
"aria-hidden": true,
|
|
954
|
-
children: selected ? /* @__PURE__ */
|
|
1135
|
+
children: selected ? /* @__PURE__ */ jsx9(CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
955
1136
|
}
|
|
956
1137
|
);
|
|
957
1138
|
var QuestionArtifactView = ({
|
|
958
1139
|
artifact
|
|
959
1140
|
}) => {
|
|
960
1141
|
const runtime = useThreadRuntime();
|
|
961
|
-
const [selected, setSelected] =
|
|
962
|
-
const [submittedIds, setSubmittedIds] =
|
|
1142
|
+
const [selected, setSelected] = useState2([]);
|
|
1143
|
+
const [submittedIds, setSubmittedIds] = useState2(null);
|
|
963
1144
|
const isMulti = artifact.multi === true;
|
|
964
1145
|
const isDisabled = submittedIds !== null;
|
|
965
1146
|
const send = useCallback(
|
|
@@ -990,12 +1171,12 @@ var QuestionArtifactView = ({
|
|
|
990
1171
|
const onConfirm = useCallback(() => {
|
|
991
1172
|
send(selected);
|
|
992
1173
|
}, [selected, send]);
|
|
993
|
-
return /* @__PURE__ */
|
|
994
|
-
artifact.prompt ? /* @__PURE__ */
|
|
995
|
-
/* @__PURE__ */
|
|
1174
|
+
return /* @__PURE__ */ jsx9("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ jsxs8("div", { className: "px-2.5 py-2", children: [
|
|
1175
|
+
artifact.prompt ? /* @__PURE__ */ jsx9("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
1176
|
+
/* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
996
1177
|
const key = optionKey(option, index);
|
|
997
1178
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
998
|
-
return /* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ jsxs8(
|
|
999
1180
|
"button",
|
|
1000
1181
|
{
|
|
1001
1182
|
type: "button",
|
|
@@ -1007,17 +1188,17 @@ var QuestionArtifactView = ({
|
|
|
1007
1188
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
1008
1189
|
),
|
|
1009
1190
|
children: [
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
option.description ? /* @__PURE__ */
|
|
1191
|
+
/* @__PURE__ */ jsx9(OptionRadio, { selected: isSelected }),
|
|
1192
|
+
/* @__PURE__ */ jsxs8("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
1193
|
+
/* @__PURE__ */ jsx9("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
1194
|
+
option.description ? /* @__PURE__ */ jsx9("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
1014
1195
|
] })
|
|
1015
1196
|
]
|
|
1016
1197
|
},
|
|
1017
1198
|
key
|
|
1018
1199
|
);
|
|
1019
1200
|
}) }),
|
|
1020
|
-
isMulti && !submittedIds ? /* @__PURE__ */
|
|
1201
|
+
isMulti && !submittedIds ? /* @__PURE__ */ jsx9("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ jsx9(
|
|
1021
1202
|
TimbalV2Button,
|
|
1022
1203
|
{
|
|
1023
1204
|
type: "button",
|
|
@@ -1032,12 +1213,12 @@ var QuestionArtifactView = ({
|
|
|
1032
1213
|
};
|
|
1033
1214
|
|
|
1034
1215
|
// src/artifacts/html-artifact.tsx
|
|
1035
|
-
import { jsx as
|
|
1216
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1036
1217
|
var HtmlArtifactView = ({ artifact }) => {
|
|
1037
1218
|
const sandboxed = artifact.sandboxed !== false;
|
|
1038
1219
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
1039
1220
|
const height = artifact.height ?? "320px";
|
|
1040
|
-
return /* @__PURE__ */
|
|
1221
|
+
return /* @__PURE__ */ jsx10(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ jsx10(
|
|
1041
1222
|
"iframe",
|
|
1042
1223
|
{
|
|
1043
1224
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -1050,7 +1231,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
1050
1231
|
};
|
|
1051
1232
|
|
|
1052
1233
|
// src/artifacts/json-artifact.tsx
|
|
1053
|
-
import { jsx as
|
|
1234
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1054
1235
|
var JsonArtifactView = ({
|
|
1055
1236
|
artifact
|
|
1056
1237
|
}) => {
|
|
@@ -1062,16 +1243,16 @@ var JsonArtifactView = ({
|
|
|
1062
1243
|
} catch {
|
|
1063
1244
|
body = String(data);
|
|
1064
1245
|
}
|
|
1065
|
-
return /* @__PURE__ */
|
|
1246
|
+
return /* @__PURE__ */ jsx11(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ jsx11("pre", { className: "aui-artifact-json m-0 max-h-[420px] overflow-auto p-3 font-mono text-[12px] leading-relaxed text-foreground/85", children: body }) });
|
|
1066
1247
|
};
|
|
1067
1248
|
|
|
1068
1249
|
// src/artifacts/table-artifact.tsx
|
|
1069
|
-
import { jsx as
|
|
1250
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1070
1251
|
var TableArtifactView = ({ artifact }) => {
|
|
1071
1252
|
const rows = artifact.rows ?? [];
|
|
1072
1253
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
1073
|
-
return /* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1254
|
+
return /* @__PURE__ */ jsx12(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ jsx12("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ jsxs9("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
1255
|
+
/* @__PURE__ */ jsx12("thead", { children: /* @__PURE__ */ jsx12("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ jsx12(
|
|
1075
1256
|
"th",
|
|
1076
1257
|
{
|
|
1077
1258
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -1079,11 +1260,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
1079
1260
|
},
|
|
1080
1261
|
col.key
|
|
1081
1262
|
)) }) }),
|
|
1082
|
-
/* @__PURE__ */
|
|
1263
|
+
/* @__PURE__ */ jsx12("tbody", { children: rows.map((row, i) => /* @__PURE__ */ jsx12(
|
|
1083
1264
|
"tr",
|
|
1084
1265
|
{
|
|
1085
1266
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
1086
|
-
children: columns.map((col) => /* @__PURE__ */
|
|
1267
|
+
children: columns.map((col) => /* @__PURE__ */ jsx12(
|
|
1087
1268
|
"td",
|
|
1088
1269
|
{
|
|
1089
1270
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -1170,11 +1351,11 @@ import {
|
|
|
1170
1351
|
createContext,
|
|
1171
1352
|
useContext
|
|
1172
1353
|
} from "react";
|
|
1173
|
-
import { jsx as
|
|
1354
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1174
1355
|
var UiStateContext = createContext({});
|
|
1175
1356
|
var UiDispatchContext = createContext(() => {
|
|
1176
1357
|
});
|
|
1177
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */
|
|
1358
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ jsx13(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ jsx13(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
1178
1359
|
function useUiState() {
|
|
1179
1360
|
return useContext(UiStateContext);
|
|
1180
1361
|
}
|
|
@@ -1184,12 +1365,12 @@ function useUiDispatch() {
|
|
|
1184
1365
|
var UiEventContext = createContext(
|
|
1185
1366
|
null
|
|
1186
1367
|
);
|
|
1187
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */
|
|
1368
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ jsx13(UiEventContext.Provider, { value: onEvent, children });
|
|
1188
1369
|
function useUiEventEmitter() {
|
|
1189
1370
|
return useContext(UiEventContext);
|
|
1190
1371
|
}
|
|
1191
1372
|
var UiCustomNodeRegistryContext = createContext({});
|
|
1192
|
-
var UiCustomNodeRegistryProvider = ({ renderers, children }) => /* @__PURE__ */
|
|
1373
|
+
var UiCustomNodeRegistryProvider = ({ renderers, children }) => /* @__PURE__ */ jsx13(UiCustomNodeRegistryContext.Provider, { value: renderers, children });
|
|
1193
1374
|
function useUiCustomNodeRegistry() {
|
|
1194
1375
|
return useContext(UiCustomNodeRegistryContext);
|
|
1195
1376
|
}
|
|
@@ -1198,29 +1379,29 @@ function useUiCustomNodeRegistry() {
|
|
|
1198
1379
|
import { useCallback as useCallback2 } from "react";
|
|
1199
1380
|
import { motion } from "motion/react";
|
|
1200
1381
|
import { useThreadRuntime as useThreadRuntime2 } from "@assistant-ui/react";
|
|
1201
|
-
import { jsx as
|
|
1382
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1202
1383
|
var UiNodeView = ({ node }) => {
|
|
1203
1384
|
switch (node.kind) {
|
|
1204
1385
|
case "box":
|
|
1205
|
-
return /* @__PURE__ */
|
|
1386
|
+
return /* @__PURE__ */ jsx14(BoxNode, { node });
|
|
1206
1387
|
case "text":
|
|
1207
|
-
return /* @__PURE__ */
|
|
1388
|
+
return /* @__PURE__ */ jsx14(TextNode, { node });
|
|
1208
1389
|
case "heading":
|
|
1209
|
-
return /* @__PURE__ */
|
|
1390
|
+
return /* @__PURE__ */ jsx14(HeadingNode, { node });
|
|
1210
1391
|
case "badge":
|
|
1211
|
-
return /* @__PURE__ */
|
|
1392
|
+
return /* @__PURE__ */ jsx14(BadgeNode, { node });
|
|
1212
1393
|
case "button":
|
|
1213
|
-
return /* @__PURE__ */
|
|
1394
|
+
return /* @__PURE__ */ jsx14(ButtonNode, { node });
|
|
1214
1395
|
case "toggle":
|
|
1215
|
-
return /* @__PURE__ */
|
|
1396
|
+
return /* @__PURE__ */ jsx14(ToggleNode, { node });
|
|
1216
1397
|
case "slider":
|
|
1217
|
-
return /* @__PURE__ */
|
|
1398
|
+
return /* @__PURE__ */ jsx14(SliderNode, { node });
|
|
1218
1399
|
case "tooltip":
|
|
1219
|
-
return /* @__PURE__ */
|
|
1400
|
+
return /* @__PURE__ */ jsx14(TooltipNode, { node });
|
|
1220
1401
|
case "draggable":
|
|
1221
|
-
return /* @__PURE__ */
|
|
1402
|
+
return /* @__PURE__ */ jsx14(DraggableNode, { node });
|
|
1222
1403
|
case "custom":
|
|
1223
|
-
return /* @__PURE__ */
|
|
1404
|
+
return /* @__PURE__ */ jsx14(CustomNode, { node });
|
|
1224
1405
|
default:
|
|
1225
1406
|
return null;
|
|
1226
1407
|
}
|
|
@@ -1280,7 +1461,7 @@ var JUSTIFY_CLS = {
|
|
|
1280
1461
|
};
|
|
1281
1462
|
var BoxNode = ({ node }) => {
|
|
1282
1463
|
const dir = node.direction ?? "col";
|
|
1283
|
-
return /* @__PURE__ */
|
|
1464
|
+
return /* @__PURE__ */ jsx14(
|
|
1284
1465
|
"div",
|
|
1285
1466
|
{
|
|
1286
1467
|
className: cn(
|
|
@@ -1295,7 +1476,7 @@ var BoxNode = ({ node }) => {
|
|
|
1295
1476
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
1296
1477
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
1297
1478
|
},
|
|
1298
|
-
children: node.children?.map((child, i) => /* @__PURE__ */
|
|
1479
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ jsx14(UiNodeView, { node: child }, child.id ?? i))
|
|
1299
1480
|
}
|
|
1300
1481
|
);
|
|
1301
1482
|
};
|
|
@@ -1314,7 +1495,7 @@ var TEXT_WEIGHT = {
|
|
|
1314
1495
|
var TextNode = ({ node }) => {
|
|
1315
1496
|
const state = useUiState();
|
|
1316
1497
|
const value = resolveBindable(node.value, state);
|
|
1317
|
-
return /* @__PURE__ */
|
|
1498
|
+
return /* @__PURE__ */ jsx14(
|
|
1318
1499
|
"span",
|
|
1319
1500
|
{
|
|
1320
1501
|
className: cn(
|
|
@@ -1345,13 +1526,13 @@ var HeadingNode = ({ node }) => {
|
|
|
1345
1526
|
);
|
|
1346
1527
|
switch (level) {
|
|
1347
1528
|
case 1:
|
|
1348
|
-
return /* @__PURE__ */
|
|
1529
|
+
return /* @__PURE__ */ jsx14("h1", { className: cls, children: value });
|
|
1349
1530
|
case 2:
|
|
1350
|
-
return /* @__PURE__ */
|
|
1531
|
+
return /* @__PURE__ */ jsx14("h2", { className: cls, children: value });
|
|
1351
1532
|
case 3:
|
|
1352
|
-
return /* @__PURE__ */
|
|
1533
|
+
return /* @__PURE__ */ jsx14("h3", { className: cls, children: value });
|
|
1353
1534
|
case 4:
|
|
1354
|
-
return /* @__PURE__ */
|
|
1535
|
+
return /* @__PURE__ */ jsx14("h4", { className: cls, children: value });
|
|
1355
1536
|
}
|
|
1356
1537
|
};
|
|
1357
1538
|
var BADGE_TONE = {
|
|
@@ -1364,7 +1545,7 @@ var BADGE_TONE = {
|
|
|
1364
1545
|
var BadgeNode = ({ node }) => {
|
|
1365
1546
|
const state = useUiState();
|
|
1366
1547
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
1367
|
-
return /* @__PURE__ */
|
|
1548
|
+
return /* @__PURE__ */ jsx14(
|
|
1368
1549
|
"span",
|
|
1369
1550
|
{
|
|
1370
1551
|
className: cn(
|
|
@@ -1381,7 +1562,7 @@ var ButtonNode = ({ node }) => {
|
|
|
1381
1562
|
const run = useActionRunner();
|
|
1382
1563
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
1383
1564
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
1384
|
-
return /* @__PURE__ */
|
|
1565
|
+
return /* @__PURE__ */ jsx14(
|
|
1385
1566
|
Button,
|
|
1386
1567
|
{
|
|
1387
1568
|
variant: node.variant ?? "default",
|
|
@@ -1403,7 +1584,7 @@ var ToggleNode = ({ node }) => {
|
|
|
1403
1584
|
dispatch({ type: "toggle", path: node.binding });
|
|
1404
1585
|
run(node.onChange);
|
|
1405
1586
|
};
|
|
1406
|
-
return /* @__PURE__ */
|
|
1587
|
+
return /* @__PURE__ */ jsxs10(
|
|
1407
1588
|
"label",
|
|
1408
1589
|
{
|
|
1409
1590
|
className: cn(
|
|
@@ -1411,7 +1592,7 @@ var ToggleNode = ({ node }) => {
|
|
|
1411
1592
|
node.className
|
|
1412
1593
|
),
|
|
1413
1594
|
children: [
|
|
1414
|
-
/* @__PURE__ */
|
|
1595
|
+
/* @__PURE__ */ jsx14(
|
|
1415
1596
|
"button",
|
|
1416
1597
|
{
|
|
1417
1598
|
type: "button",
|
|
@@ -1422,7 +1603,7 @@ var ToggleNode = ({ node }) => {
|
|
|
1422
1603
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
1423
1604
|
value ? "border-foreground/15 bg-gradient-to-b from-primary-fill-from to-primary-fill-to shadow-card" : cn(TIMBAL_V2_SWITCH_TRACK_OFF, "hover:from-secondary-fill-hover-from hover:to-secondary-fill-hover-to")
|
|
1424
1605
|
),
|
|
1425
|
-
children: /* @__PURE__ */
|
|
1606
|
+
children: /* @__PURE__ */ jsx14(
|
|
1426
1607
|
"span",
|
|
1427
1608
|
{
|
|
1428
1609
|
className: cn(
|
|
@@ -1435,7 +1616,7 @@ var ToggleNode = ({ node }) => {
|
|
|
1435
1616
|
)
|
|
1436
1617
|
}
|
|
1437
1618
|
),
|
|
1438
|
-
label && /* @__PURE__ */
|
|
1619
|
+
label && /* @__PURE__ */ jsx14("span", { className: "text-foreground/85", children: label })
|
|
1439
1620
|
]
|
|
1440
1621
|
}
|
|
1441
1622
|
);
|
|
@@ -1455,12 +1636,12 @@ var SliderNode = ({ node }) => {
|
|
|
1455
1636
|
const next = Number(e.target.value);
|
|
1456
1637
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
1457
1638
|
};
|
|
1458
|
-
return /* @__PURE__ */
|
|
1459
|
-
(label || showValue) && /* @__PURE__ */
|
|
1460
|
-
label && /* @__PURE__ */
|
|
1461
|
-
showValue && /* @__PURE__ */
|
|
1639
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
1640
|
+
(label || showValue) && /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
1641
|
+
label && /* @__PURE__ */ jsx14("span", { children: label }),
|
|
1642
|
+
showValue && /* @__PURE__ */ jsx14("span", { className: "font-mono", children: value })
|
|
1462
1643
|
] }),
|
|
1463
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ jsx14(
|
|
1464
1645
|
"input",
|
|
1465
1646
|
{
|
|
1466
1647
|
type: "range",
|
|
@@ -1482,9 +1663,9 @@ var SliderNode = ({ node }) => {
|
|
|
1482
1663
|
var TooltipNode = ({ node }) => {
|
|
1483
1664
|
const state = useUiState();
|
|
1484
1665
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
1485
|
-
return /* @__PURE__ */
|
|
1486
|
-
/* @__PURE__ */
|
|
1487
|
-
/* @__PURE__ */
|
|
1666
|
+
return /* @__PURE__ */ jsx14(TooltipProvider, { children: /* @__PURE__ */ jsxs10(Tooltip, { children: [
|
|
1667
|
+
/* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ jsx14(UiNodeView, { node: node.child }) }) }),
|
|
1668
|
+
/* @__PURE__ */ jsx14(TooltipContent, { side: node.side ?? "top", children: content })
|
|
1488
1669
|
] }) });
|
|
1489
1670
|
};
|
|
1490
1671
|
var DraggableNode = ({ node }) => {
|
|
@@ -1492,7 +1673,7 @@ var DraggableNode = ({ node }) => {
|
|
|
1492
1673
|
const snapBack = node.snapBack ?? true;
|
|
1493
1674
|
const axis = node.axis ?? "both";
|
|
1494
1675
|
const dragProp = axis === "both" ? true : axis;
|
|
1495
|
-
return /* @__PURE__ */
|
|
1676
|
+
return /* @__PURE__ */ jsx14(
|
|
1496
1677
|
motion.div,
|
|
1497
1678
|
{
|
|
1498
1679
|
drag: dragProp,
|
|
@@ -1504,7 +1685,7 @@ var DraggableNode = ({ node }) => {
|
|
|
1504
1685
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
1505
1686
|
node.className
|
|
1506
1687
|
),
|
|
1507
|
-
children: /* @__PURE__ */
|
|
1688
|
+
children: /* @__PURE__ */ jsx14(UiNodeView, { node: node.child })
|
|
1508
1689
|
}
|
|
1509
1690
|
);
|
|
1510
1691
|
};
|
|
@@ -1514,8 +1695,8 @@ var CustomNode = ({ node }) => {
|
|
|
1514
1695
|
const Renderer = registry[node.name];
|
|
1515
1696
|
if (!Renderer) return null;
|
|
1516
1697
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
1517
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */
|
|
1518
|
-
return /* @__PURE__ */
|
|
1698
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ jsx14(UiNodeView, { node: child }, child.id ?? i));
|
|
1699
|
+
return /* @__PURE__ */ jsx14(Renderer, { props: resolvedProps, children });
|
|
1519
1700
|
};
|
|
1520
1701
|
function resolveProps(props, state) {
|
|
1521
1702
|
const out = {};
|
|
@@ -1527,18 +1708,18 @@ function resolveProps(props, state) {
|
|
|
1527
1708
|
|
|
1528
1709
|
// src/artifacts/ui/ui-artifact.tsx
|
|
1529
1710
|
import { useReducer } from "react";
|
|
1530
|
-
import { jsx as
|
|
1711
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1531
1712
|
var UiArtifactView = ({ artifact }) => {
|
|
1532
1713
|
const [state, dispatch] = useReducer(
|
|
1533
1714
|
uiStateReducer,
|
|
1534
1715
|
artifact.initialState ?? {}
|
|
1535
1716
|
);
|
|
1536
|
-
return /* @__PURE__ */
|
|
1717
|
+
return /* @__PURE__ */ jsx15(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ jsx15(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ jsx15("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ jsx15(UiNodeView, { node: artifact.root }) }) }) });
|
|
1537
1718
|
};
|
|
1538
1719
|
|
|
1539
1720
|
// src/artifacts/registry.tsx
|
|
1540
|
-
import { createContext as createContext2, useContext as useContext2, useMemo as
|
|
1541
|
-
import { jsx as
|
|
1721
|
+
import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
1722
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1542
1723
|
var defaultArtifactRenderers = {
|
|
1543
1724
|
chart: ChartArtifactView,
|
|
1544
1725
|
question: QuestionArtifactView,
|
|
@@ -1551,12 +1732,12 @@ var ArtifactRegistryContext = createContext2(
|
|
|
1551
1732
|
defaultArtifactRenderers
|
|
1552
1733
|
);
|
|
1553
1734
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
1554
|
-
const merged =
|
|
1735
|
+
const merged = useMemo2(() => {
|
|
1555
1736
|
if (!renderers) return defaultArtifactRenderers;
|
|
1556
1737
|
if (override) return renderers;
|
|
1557
1738
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
1558
1739
|
}, [renderers, override]);
|
|
1559
|
-
return /* @__PURE__ */
|
|
1740
|
+
return /* @__PURE__ */ jsx16(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
1560
1741
|
};
|
|
1561
1742
|
function useArtifactRegistry() {
|
|
1562
1743
|
return useContext2(ArtifactRegistryContext);
|
|
@@ -1565,7 +1746,7 @@ var ArtifactView = ({ artifact }) => {
|
|
|
1565
1746
|
const registry = useArtifactRegistry();
|
|
1566
1747
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
1567
1748
|
if (!Renderer) return null;
|
|
1568
|
-
return /* @__PURE__ */
|
|
1749
|
+
return /* @__PURE__ */ jsx16(Renderer, { artifact });
|
|
1569
1750
|
};
|
|
1570
1751
|
|
|
1571
1752
|
// src/artifacts/types.ts
|
|
@@ -1677,11 +1858,11 @@ import {
|
|
|
1677
1858
|
import remarkGfm from "remark-gfm";
|
|
1678
1859
|
import remarkMath from "remark-math";
|
|
1679
1860
|
import rehypeKatex from "rehype-katex";
|
|
1680
|
-
import { memo, useState as
|
|
1861
|
+
import { memo, useState as useState4 } from "react";
|
|
1681
1862
|
import { CheckIcon as CheckIcon2, CopyIcon } from "lucide-react";
|
|
1682
1863
|
|
|
1683
1864
|
// src/chat/syntax-highlighter.tsx
|
|
1684
|
-
import { useEffect as
|
|
1865
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1685
1866
|
import { createHighlighterCore } from "shiki/core";
|
|
1686
1867
|
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
1687
1868
|
import langJavascript from "shiki/langs/javascript.mjs";
|
|
@@ -1703,7 +1884,7 @@ import langC from "shiki/langs/c.mjs";
|
|
|
1703
1884
|
import langCpp from "shiki/langs/cpp.mjs";
|
|
1704
1885
|
import themeVitesseDark from "shiki/themes/vitesse-dark.mjs";
|
|
1705
1886
|
import themeVitesseLight from "shiki/themes/vitesse-light.mjs";
|
|
1706
|
-
import { jsx as
|
|
1887
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1707
1888
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
1708
1889
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
1709
1890
|
var highlighterPromise = null;
|
|
@@ -1741,8 +1922,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
1741
1922
|
language,
|
|
1742
1923
|
code
|
|
1743
1924
|
}) => {
|
|
1744
|
-
const [html, setHtml] =
|
|
1745
|
-
|
|
1925
|
+
const [html, setHtml] = useState3(null);
|
|
1926
|
+
useEffect2(() => {
|
|
1746
1927
|
let cancelled = false;
|
|
1747
1928
|
(async () => {
|
|
1748
1929
|
try {
|
|
@@ -1772,13 +1953,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
1772
1953
|
try {
|
|
1773
1954
|
const parsed = JSON.parse(code);
|
|
1774
1955
|
if (isArtifact(parsed)) {
|
|
1775
|
-
return /* @__PURE__ */
|
|
1956
|
+
return /* @__PURE__ */ jsx17(ArtifactView, { artifact: parsed });
|
|
1776
1957
|
}
|
|
1777
1958
|
} catch {
|
|
1778
1959
|
}
|
|
1779
1960
|
}
|
|
1780
1961
|
if (html) {
|
|
1781
|
-
return /* @__PURE__ */
|
|
1962
|
+
return /* @__PURE__ */ jsx17(
|
|
1782
1963
|
"div",
|
|
1783
1964
|
{
|
|
1784
1965
|
className: "shiki-wrapper [&>pre]:!m-0 [&>pre]:!rounded-t-none [&>pre]:!rounded-b-lg [&>pre]:!border [&>pre]:!border-t-0 [&>pre]:!border-border/50 [&>pre]:!p-3 [&>pre]:!text-xs [&>pre]:!leading-relaxed [&>pre]:overflow-x-auto",
|
|
@@ -1786,14 +1967,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
1786
1967
|
}
|
|
1787
1968
|
);
|
|
1788
1969
|
}
|
|
1789
|
-
return /* @__PURE__ */
|
|
1970
|
+
return /* @__PURE__ */ jsx17(Pre, { children: /* @__PURE__ */ jsx17(Code2, { children: code }) });
|
|
1790
1971
|
};
|
|
1791
1972
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
1792
1973
|
|
|
1793
1974
|
// src/chat/markdown-text.tsx
|
|
1794
|
-
import { jsx as
|
|
1975
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1795
1976
|
var MarkdownTextImpl = () => {
|
|
1796
|
-
return /* @__PURE__ */
|
|
1977
|
+
return /* @__PURE__ */ jsx18(
|
|
1797
1978
|
MarkdownTextPrimitive,
|
|
1798
1979
|
{
|
|
1799
1980
|
remarkPlugins: [remarkGfm, remarkMath],
|
|
@@ -1814,20 +1995,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
1814
1995
|
if (!code || isCopied) return;
|
|
1815
1996
|
copyToClipboard(code);
|
|
1816
1997
|
};
|
|
1817
|
-
return /* @__PURE__ */
|
|
1818
|
-
/* @__PURE__ */
|
|
1819
|
-
/* @__PURE__ */
|
|
1998
|
+
return /* @__PURE__ */ jsxs11("div", { className: "aui-code-header flex items-center justify-between rounded-t-lg border border-b-0 border-border/50 bg-code-header-bg px-4 py-2", children: [
|
|
1999
|
+
/* @__PURE__ */ jsxs11("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
2000
|
+
/* @__PURE__ */ jsx18("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
1820
2001
|
language
|
|
1821
2002
|
] }),
|
|
1822
|
-
/* @__PURE__ */
|
|
2003
|
+
/* @__PURE__ */ jsxs11(
|
|
1823
2004
|
TooltipIconButton,
|
|
1824
2005
|
{
|
|
1825
2006
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
1826
2007
|
onClick: onCopy,
|
|
1827
2008
|
className: "transition-colors hover:text-foreground",
|
|
1828
2009
|
children: [
|
|
1829
|
-
!isCopied && /* @__PURE__ */
|
|
1830
|
-
isCopied && /* @__PURE__ */
|
|
2010
|
+
!isCopied && /* @__PURE__ */ jsx18(CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
2011
|
+
isCopied && /* @__PURE__ */ jsx18(CheckIcon2, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
1831
2012
|
]
|
|
1832
2013
|
}
|
|
1833
2014
|
)
|
|
@@ -1836,7 +2017,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
1836
2017
|
var useCopyToClipboard = ({
|
|
1837
2018
|
copiedDuration = 3e3
|
|
1838
2019
|
} = {}) => {
|
|
1839
|
-
const [isCopied, setIsCopied] =
|
|
2020
|
+
const [isCopied, setIsCopied] = useState4(false);
|
|
1840
2021
|
const copyToClipboard = (value) => {
|
|
1841
2022
|
if (!value) return;
|
|
1842
2023
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -1847,7 +2028,7 @@ var useCopyToClipboard = ({
|
|
|
1847
2028
|
return { isCopied, copyToClipboard };
|
|
1848
2029
|
};
|
|
1849
2030
|
var defaultComponents = memoizeMarkdownComponents({
|
|
1850
|
-
h1: ({ className, ...props }) => /* @__PURE__ */
|
|
2031
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1851
2032
|
"h1",
|
|
1852
2033
|
{
|
|
1853
2034
|
className: cn(
|
|
@@ -1857,7 +2038,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1857
2038
|
...props
|
|
1858
2039
|
}
|
|
1859
2040
|
),
|
|
1860
|
-
h2: ({ className, ...props }) => /* @__PURE__ */
|
|
2041
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1861
2042
|
"h2",
|
|
1862
2043
|
{
|
|
1863
2044
|
className: cn(
|
|
@@ -1867,7 +2048,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1867
2048
|
...props
|
|
1868
2049
|
}
|
|
1869
2050
|
),
|
|
1870
|
-
h3: ({ className, ...props }) => /* @__PURE__ */
|
|
2051
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1871
2052
|
"h3",
|
|
1872
2053
|
{
|
|
1873
2054
|
className: cn(
|
|
@@ -1877,7 +2058,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1877
2058
|
...props
|
|
1878
2059
|
}
|
|
1879
2060
|
),
|
|
1880
|
-
h4: ({ className, ...props }) => /* @__PURE__ */
|
|
2061
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1881
2062
|
"h4",
|
|
1882
2063
|
{
|
|
1883
2064
|
className: cn(
|
|
@@ -1887,7 +2068,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1887
2068
|
...props
|
|
1888
2069
|
}
|
|
1889
2070
|
),
|
|
1890
|
-
h5: ({ className, ...props }) => /* @__PURE__ */
|
|
2071
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1891
2072
|
"h5",
|
|
1892
2073
|
{
|
|
1893
2074
|
className: cn(
|
|
@@ -1897,7 +2078,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1897
2078
|
...props
|
|
1898
2079
|
}
|
|
1899
2080
|
),
|
|
1900
|
-
h6: ({ className, ...props }) => /* @__PURE__ */
|
|
2081
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1901
2082
|
"h6",
|
|
1902
2083
|
{
|
|
1903
2084
|
className: cn(
|
|
@@ -1907,7 +2088,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1907
2088
|
...props
|
|
1908
2089
|
}
|
|
1909
2090
|
),
|
|
1910
|
-
p: ({ className, ...props }) => /* @__PURE__ */
|
|
2091
|
+
p: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1911
2092
|
"p",
|
|
1912
2093
|
{
|
|
1913
2094
|
className: cn(
|
|
@@ -1917,7 +2098,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1917
2098
|
...props
|
|
1918
2099
|
}
|
|
1919
2100
|
),
|
|
1920
|
-
a: ({ className, ...props }) => /* @__PURE__ */
|
|
2101
|
+
a: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1921
2102
|
"a",
|
|
1922
2103
|
{
|
|
1923
2104
|
className: cn(
|
|
@@ -1929,7 +2110,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1929
2110
|
...props
|
|
1930
2111
|
}
|
|
1931
2112
|
),
|
|
1932
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */
|
|
2113
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1933
2114
|
"blockquote",
|
|
1934
2115
|
{
|
|
1935
2116
|
className: cn(
|
|
@@ -1939,7 +2120,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1939
2120
|
...props
|
|
1940
2121
|
}
|
|
1941
2122
|
),
|
|
1942
|
-
ul: ({ className, ...props }) => /* @__PURE__ */
|
|
2123
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1943
2124
|
"ul",
|
|
1944
2125
|
{
|
|
1945
2126
|
className: cn(
|
|
@@ -1949,7 +2130,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1949
2130
|
...props
|
|
1950
2131
|
}
|
|
1951
2132
|
),
|
|
1952
|
-
ol: ({ className, ...props }) => /* @__PURE__ */
|
|
2133
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1953
2134
|
"ol",
|
|
1954
2135
|
{
|
|
1955
2136
|
className: cn(
|
|
@@ -1959,7 +2140,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1959
2140
|
...props
|
|
1960
2141
|
}
|
|
1961
2142
|
),
|
|
1962
|
-
hr: ({ className, ...props }) => /* @__PURE__ */
|
|
2143
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1963
2144
|
"hr",
|
|
1964
2145
|
{
|
|
1965
2146
|
className: cn(
|
|
@@ -1969,14 +2150,14 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1969
2150
|
...props
|
|
1970
2151
|
}
|
|
1971
2152
|
),
|
|
1972
|
-
table: ({ className, ...props }) => /* @__PURE__ */
|
|
2153
|
+
table: ({ className, ...props }) => /* @__PURE__ */ jsx18("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ jsx18(
|
|
1973
2154
|
"table",
|
|
1974
2155
|
{
|
|
1975
2156
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
1976
2157
|
...props
|
|
1977
2158
|
}
|
|
1978
2159
|
) }),
|
|
1979
|
-
th: ({ className, ...props }) => /* @__PURE__ */
|
|
2160
|
+
th: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1980
2161
|
"th",
|
|
1981
2162
|
{
|
|
1982
2163
|
className: cn(
|
|
@@ -1986,7 +2167,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1986
2167
|
...props
|
|
1987
2168
|
}
|
|
1988
2169
|
),
|
|
1989
|
-
td: ({ className, ...props }) => /* @__PURE__ */
|
|
2170
|
+
td: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
1990
2171
|
"td",
|
|
1991
2172
|
{
|
|
1992
2173
|
className: cn(
|
|
@@ -1996,7 +2177,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
1996
2177
|
...props
|
|
1997
2178
|
}
|
|
1998
2179
|
),
|
|
1999
|
-
tr: ({ className, ...props }) => /* @__PURE__ */
|
|
2180
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
2000
2181
|
"tr",
|
|
2001
2182
|
{
|
|
2002
2183
|
className: cn(
|
|
@@ -2006,8 +2187,8 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
2006
2187
|
...props
|
|
2007
2188
|
}
|
|
2008
2189
|
),
|
|
2009
|
-
li: ({ className, ...props }) => /* @__PURE__ */
|
|
2010
|
-
sup: ({ className, ...props }) => /* @__PURE__ */
|
|
2190
|
+
li: ({ className, ...props }) => /* @__PURE__ */ jsx18("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
2191
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
2011
2192
|
"sup",
|
|
2012
2193
|
{
|
|
2013
2194
|
className: cn(
|
|
@@ -2017,7 +2198,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
2017
2198
|
...props
|
|
2018
2199
|
}
|
|
2019
2200
|
),
|
|
2020
|
-
pre: ({ className, ...props }) => /* @__PURE__ */
|
|
2201
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ jsx18(
|
|
2021
2202
|
"pre",
|
|
2022
2203
|
{
|
|
2023
2204
|
className: cn(
|
|
@@ -2029,7 +2210,7 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
2029
2210
|
),
|
|
2030
2211
|
code: function Code({ className, ...props }) {
|
|
2031
2212
|
const isCodeBlock = useIsMarkdownCodeBlock();
|
|
2032
|
-
return /* @__PURE__ */
|
|
2213
|
+
return /* @__PURE__ */ jsx18(
|
|
2033
2214
|
"code",
|
|
2034
2215
|
{
|
|
2035
2216
|
className: cn(
|
|
@@ -2040,8 +2221,8 @@ var defaultComponents = memoizeMarkdownComponents({
|
|
|
2040
2221
|
}
|
|
2041
2222
|
);
|
|
2042
2223
|
},
|
|
2043
|
-
strong: ({ className, ...props }) => /* @__PURE__ */
|
|
2044
|
-
em: ({ className, ...props }) => /* @__PURE__ */
|
|
2224
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ jsx18("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
2225
|
+
em: ({ className, ...props }) => /* @__PURE__ */ jsx18("em", { className: cn("italic", className), ...props }),
|
|
2045
2226
|
CodeHeader
|
|
2046
2227
|
});
|
|
2047
2228
|
|
|
@@ -2237,10 +2418,10 @@ import {
|
|
|
2237
2418
|
createContext as createContext4,
|
|
2238
2419
|
useCallback as useCallback3,
|
|
2239
2420
|
useContext as useContext4,
|
|
2240
|
-
useEffect as
|
|
2241
|
-
useMemo as
|
|
2242
|
-
useRef
|
|
2243
|
-
useState as
|
|
2421
|
+
useEffect as useEffect3,
|
|
2422
|
+
useMemo as useMemo3,
|
|
2423
|
+
useRef,
|
|
2424
|
+
useState as useState5
|
|
2244
2425
|
} from "react";
|
|
2245
2426
|
import {
|
|
2246
2427
|
useExternalStoreRuntime,
|
|
@@ -2594,20 +2775,20 @@ function buildPromptBody({
|
|
|
2594
2775
|
|
|
2595
2776
|
// src/runtime/attachments-context.tsx
|
|
2596
2777
|
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
2597
|
-
import { jsx as
|
|
2778
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
2598
2779
|
var TimbalAttachmentsEnabledContext = createContext3(false);
|
|
2599
2780
|
function TimbalAttachmentsEnabledProvider({
|
|
2600
2781
|
enabled,
|
|
2601
2782
|
children
|
|
2602
2783
|
}) {
|
|
2603
|
-
return /* @__PURE__ */
|
|
2784
|
+
return /* @__PURE__ */ jsx19(TimbalAttachmentsEnabledContext.Provider, { value: enabled, children });
|
|
2604
2785
|
}
|
|
2605
2786
|
function useTimbalAttachmentsEnabled() {
|
|
2606
2787
|
return useContext3(TimbalAttachmentsEnabledContext);
|
|
2607
2788
|
}
|
|
2608
2789
|
|
|
2609
2790
|
// src/runtime/provider.tsx
|
|
2610
|
-
import { jsx as
|
|
2791
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2611
2792
|
function projectAttachment(attachment) {
|
|
2612
2793
|
const filename = attachment.name ?? "attachment";
|
|
2613
2794
|
const mimeType = attachment.contentType ?? "application/octet-stream";
|
|
@@ -2672,19 +2853,19 @@ function useTimbalStream({
|
|
|
2672
2853
|
fetch: fetchFn,
|
|
2673
2854
|
debug = false
|
|
2674
2855
|
}) {
|
|
2675
|
-
const [messages, setMessages] =
|
|
2676
|
-
const [isRunning, setIsRunning] =
|
|
2677
|
-
const abortRef =
|
|
2678
|
-
const messagesRef =
|
|
2679
|
-
const fetchFnRef =
|
|
2680
|
-
|
|
2856
|
+
const [messages, setMessages] = useState5([]);
|
|
2857
|
+
const [isRunning, setIsRunning] = useState5(false);
|
|
2858
|
+
const abortRef = useRef(null);
|
|
2859
|
+
const messagesRef = useRef([]);
|
|
2860
|
+
const fetchFnRef = useRef(fetchFn ?? authFetch);
|
|
2861
|
+
useEffect3(() => {
|
|
2681
2862
|
fetchFnRef.current = fetchFn ?? authFetch;
|
|
2682
2863
|
}, [fetchFn]);
|
|
2683
|
-
const debugRef =
|
|
2684
|
-
|
|
2864
|
+
const debugRef = useRef(debug);
|
|
2865
|
+
useEffect3(() => {
|
|
2685
2866
|
debugRef.current = debug;
|
|
2686
2867
|
}, [debug]);
|
|
2687
|
-
|
|
2868
|
+
useEffect3(() => {
|
|
2688
2869
|
messagesRef.current = messages;
|
|
2689
2870
|
}, [messages]);
|
|
2690
2871
|
const streamAssistantResponse = useCallback3(
|
|
@@ -2833,7 +3014,7 @@ function useTimbalStream({
|
|
|
2833
3014
|
abortRef.current?.abort();
|
|
2834
3015
|
setMessages([]);
|
|
2835
3016
|
}, []);
|
|
2836
|
-
return
|
|
3017
|
+
return useMemo3(
|
|
2837
3018
|
() => ({ messages, isRunning, send, reload, cancel, clear }),
|
|
2838
3019
|
[messages, isRunning, send, reload, cancel, clear]
|
|
2839
3020
|
);
|
|
@@ -2870,7 +3051,7 @@ function TimbalRuntimeProvider({
|
|
|
2870
3051
|
fetch: fetchFn,
|
|
2871
3052
|
debug
|
|
2872
3053
|
});
|
|
2873
|
-
const attachmentAdapter =
|
|
3054
|
+
const attachmentAdapter = useMemo3(
|
|
2874
3055
|
() => resolveAttachmentAdapter(attachments, {
|
|
2875
3056
|
baseUrl,
|
|
2876
3057
|
fetch: fetchFn,
|
|
@@ -2913,7 +3094,7 @@ function TimbalRuntimeProvider({
|
|
|
2913
3094
|
onCancel,
|
|
2914
3095
|
...attachmentAdapter ? { adapters: { attachments: attachmentAdapter } } : {}
|
|
2915
3096
|
});
|
|
2916
|
-
return /* @__PURE__ */
|
|
3097
|
+
return /* @__PURE__ */ jsx20(TimbalStreamContext.Provider, { value: stream, children: /* @__PURE__ */ jsx20(TimbalAttachmentsEnabledProvider, { enabled: attachmentAdapter !== void 0, children: /* @__PURE__ */ jsx20(AssistantRuntimeProvider, { runtime, children }) }) });
|
|
2917
3098
|
}
|
|
2918
3099
|
function findParentIdFromAuiParent(messages, auiParentId) {
|
|
2919
3100
|
const idx = messages.findIndex((m) => m.id === auiParentId);
|
|
@@ -2922,7 +3103,7 @@ function findParentIdFromAuiParent(messages, auiParentId) {
|
|
|
2922
3103
|
}
|
|
2923
3104
|
|
|
2924
3105
|
// src/chat/tool-fallback.tsx
|
|
2925
|
-
import { memo as memo2, useMemo as
|
|
3106
|
+
import { memo as memo2, useMemo as useMemo4, useState as useState6 } from "react";
|
|
2926
3107
|
import { ChevronRightIcon } from "lucide-react";
|
|
2927
3108
|
import {
|
|
2928
3109
|
useAuiState as useAuiState2
|
|
@@ -2930,7 +3111,7 @@ import {
|
|
|
2930
3111
|
|
|
2931
3112
|
// src/chat/motion.tsx
|
|
2932
3113
|
import { AnimatePresence, motion as motion2, useReducedMotion } from "motion/react";
|
|
2933
|
-
import { jsx as
|
|
3114
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
2934
3115
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
2935
3116
|
var TOOL_ENTER_MS = 0.78;
|
|
2936
3117
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -2958,7 +3139,7 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
2958
3139
|
function ToolMotion({ children, className, motionKey }) {
|
|
2959
3140
|
const reduced = useReducedMotion() ?? false;
|
|
2960
3141
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
2961
|
-
return /* @__PURE__ */
|
|
3142
|
+
return /* @__PURE__ */ jsx21(
|
|
2962
3143
|
motion2.div,
|
|
2963
3144
|
{
|
|
2964
3145
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
@@ -2981,7 +3162,7 @@ function ToolPresence({
|
|
|
2981
3162
|
const reduced = useReducedMotion() ?? false;
|
|
2982
3163
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
2983
3164
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
2984
|
-
return /* @__PURE__ */
|
|
3165
|
+
return /* @__PURE__ */ jsx21(AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ jsx21(
|
|
2985
3166
|
motion2.div,
|
|
2986
3167
|
{
|
|
2987
3168
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
@@ -3003,7 +3184,7 @@ function ToolBodyPresence({
|
|
|
3003
3184
|
className
|
|
3004
3185
|
}) {
|
|
3005
3186
|
const reduced = useReducedMotion() ?? false;
|
|
3006
|
-
return /* @__PURE__ */
|
|
3187
|
+
return /* @__PURE__ */ jsx21(
|
|
3007
3188
|
"div",
|
|
3008
3189
|
{
|
|
3009
3190
|
className: cn(
|
|
@@ -3011,7 +3192,7 @@ function ToolBodyPresence({
|
|
|
3011
3192
|
open ? reduced ? "duration-200 ease-out" : "duration-[340ms] ease-[cubic-bezier(0.16,1,0.3,1)]" : reduced ? "duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]" : "duration-200 ease-[cubic-bezier(0.4,0,0.2,1)]"
|
|
3012
3193
|
),
|
|
3013
3194
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3014
|
-
children: /* @__PURE__ */
|
|
3195
|
+
children: /* @__PURE__ */ jsx21("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx21(
|
|
3015
3196
|
"div",
|
|
3016
3197
|
{
|
|
3017
3198
|
className: cn(
|
|
@@ -3027,7 +3208,7 @@ function ToolBodyPresence({
|
|
|
3027
3208
|
}
|
|
3028
3209
|
|
|
3029
3210
|
// src/chat/tool-fallback.tsx
|
|
3030
|
-
import { jsx as
|
|
3211
|
+
import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3031
3212
|
function detectRunning({
|
|
3032
3213
|
status,
|
|
3033
3214
|
result,
|
|
@@ -3059,8 +3240,8 @@ function formatToolResult(result) {
|
|
|
3059
3240
|
return String(result);
|
|
3060
3241
|
}
|
|
3061
3242
|
}
|
|
3062
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */
|
|
3063
|
-
action ? shimmer ? /* @__PURE__ */
|
|
3243
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ jsxs12("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
3244
|
+
action ? shimmer ? /* @__PURE__ */ jsx22(
|
|
3064
3245
|
Shimmer,
|
|
3065
3246
|
{
|
|
3066
3247
|
as: "span",
|
|
@@ -3069,10 +3250,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3069
3250
|
spread: 2.5,
|
|
3070
3251
|
children: action
|
|
3071
3252
|
}
|
|
3072
|
-
) : /* @__PURE__ */
|
|
3073
|
-
detail ? /* @__PURE__ */
|
|
3253
|
+
) : /* @__PURE__ */ jsx22("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
3254
|
+
detail ? /* @__PURE__ */ jsx22("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3074
3255
|
] });
|
|
3075
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */
|
|
3256
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ jsx22(
|
|
3076
3257
|
ChevronRightIcon,
|
|
3077
3258
|
{
|
|
3078
3259
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3080,9 +3261,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ jsx19(
|
|
|
3080
3261
|
}
|
|
3081
3262
|
);
|
|
3082
3263
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3083
|
-
const [open, setOpen] =
|
|
3264
|
+
const [open, setOpen] = useState6(false);
|
|
3084
3265
|
const detail = formatToolLabel(toolName);
|
|
3085
|
-
const formattedArgs =
|
|
3266
|
+
const formattedArgs = useMemo4(() => {
|
|
3086
3267
|
if (!argsText || argsText === "{}") return null;
|
|
3087
3268
|
try {
|
|
3088
3269
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3090,17 +3271,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3090
3271
|
return argsText;
|
|
3091
3272
|
}
|
|
3092
3273
|
}, [argsText]);
|
|
3093
|
-
const formattedResult =
|
|
3274
|
+
const formattedResult = useMemo4(() => {
|
|
3094
3275
|
if (result === void 0 || result === null) return null;
|
|
3095
3276
|
return formatToolResult(result);
|
|
3096
3277
|
}, [result]);
|
|
3097
3278
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3098
3279
|
const action = isError ? "Failed" : "Used";
|
|
3099
3280
|
if (!hasBody) {
|
|
3100
|
-
return /* @__PURE__ */
|
|
3281
|
+
return /* @__PURE__ */ jsx22("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ jsx22(TimelineActionLabel, { action, detail }) });
|
|
3101
3282
|
}
|
|
3102
|
-
return /* @__PURE__ */
|
|
3103
|
-
/* @__PURE__ */
|
|
3283
|
+
return /* @__PURE__ */ jsxs12("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
3284
|
+
/* @__PURE__ */ jsx22(
|
|
3104
3285
|
"button",
|
|
3105
3286
|
{
|
|
3106
3287
|
type: "button",
|
|
@@ -3108,7 +3289,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3108
3289
|
"aria-expanded": open,
|
|
3109
3290
|
"aria-label": `${action} ${detail}`,
|
|
3110
3291
|
className: studioTimelineRowButtonClass,
|
|
3111
|
-
children: /* @__PURE__ */
|
|
3292
|
+
children: /* @__PURE__ */ jsxs12(
|
|
3112
3293
|
"span",
|
|
3113
3294
|
{
|
|
3114
3295
|
className: cn(
|
|
@@ -3117,37 +3298,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3117
3298
|
"text-foreground"
|
|
3118
3299
|
),
|
|
3119
3300
|
children: [
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
/* @__PURE__ */
|
|
3301
|
+
/* @__PURE__ */ jsx22(TimelineActionLabel, { action, detail }),
|
|
3302
|
+
/* @__PURE__ */ jsx22(TimelineHoverChevron, { expanded: open })
|
|
3122
3303
|
]
|
|
3123
3304
|
}
|
|
3124
3305
|
)
|
|
3125
3306
|
}
|
|
3126
3307
|
),
|
|
3127
|
-
/* @__PURE__ */
|
|
3308
|
+
/* @__PURE__ */ jsxs12(
|
|
3128
3309
|
ToolBodyPresence,
|
|
3129
3310
|
{
|
|
3130
3311
|
open,
|
|
3131
3312
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3132
3313
|
children: [
|
|
3133
|
-
formattedArgs ? /* @__PURE__ */
|
|
3314
|
+
formattedArgs ? /* @__PURE__ */ jsx22(
|
|
3134
3315
|
"div",
|
|
3135
3316
|
{
|
|
3136
3317
|
className: cn(
|
|
3137
3318
|
studioComposerIoWellClass,
|
|
3138
3319
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3139
3320
|
),
|
|
3140
|
-
children: /* @__PURE__ */
|
|
3321
|
+
children: /* @__PURE__ */ jsx22("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3141
3322
|
}
|
|
3142
3323
|
) : null,
|
|
3143
|
-
formattedResult ? /* @__PURE__ */
|
|
3324
|
+
formattedResult ? /* @__PURE__ */ jsx22(
|
|
3144
3325
|
"div",
|
|
3145
3326
|
{
|
|
3146
3327
|
className: cn(
|
|
3147
3328
|
studioComposerIoWellClass,
|
|
3148
3329
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3149
3330
|
),
|
|
3150
|
-
children: /* @__PURE__ */
|
|
3331
|
+
children: /* @__PURE__ */ jsx22("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3151
3332
|
}
|
|
3152
3333
|
) : null
|
|
3153
3334
|
]
|
|
@@ -3164,20 +3345,20 @@ var ToolFallbackImpl = ({
|
|
|
3164
3345
|
const isRunning = useToolRunning({ status, result });
|
|
3165
3346
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3166
3347
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3167
|
-
return /* @__PURE__ */
|
|
3348
|
+
return /* @__PURE__ */ jsx22(
|
|
3168
3349
|
ToolPresence,
|
|
3169
3350
|
{
|
|
3170
3351
|
presenceKey,
|
|
3171
3352
|
variant: isRunning ? "executing" : "settled",
|
|
3172
3353
|
className: "py-0.5",
|
|
3173
|
-
children: isRunning ? /* @__PURE__ */
|
|
3354
|
+
children: isRunning ? /* @__PURE__ */ jsx22("div", { className: "aui-tool-running", children: /* @__PURE__ */ jsx22(
|
|
3174
3355
|
TimelineActionLabel,
|
|
3175
3356
|
{
|
|
3176
3357
|
action: "Using",
|
|
3177
3358
|
detail: formatToolLabel(toolName),
|
|
3178
3359
|
shimmer: true
|
|
3179
3360
|
}
|
|
3180
|
-
) }) : /* @__PURE__ */
|
|
3361
|
+
) }) : /* @__PURE__ */ jsx22(
|
|
3181
3362
|
ToolPanel,
|
|
3182
3363
|
{
|
|
3183
3364
|
toolName,
|
|
@@ -3195,7 +3376,7 @@ var ToolFallback = memo2(
|
|
|
3195
3376
|
ToolFallback.displayName = "ToolFallback";
|
|
3196
3377
|
|
|
3197
3378
|
// src/artifacts/tool-artifact.tsx
|
|
3198
|
-
import { jsx as
|
|
3379
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3199
3380
|
var ToolArtifactFallback = (props) => {
|
|
3200
3381
|
const registry = useArtifactRegistry();
|
|
3201
3382
|
const isRunning = useToolRunning({
|
|
@@ -3207,18 +3388,18 @@ var ToolArtifactFallback = (props) => {
|
|
|
3207
3388
|
if (artifact) {
|
|
3208
3389
|
const Renderer = registry[artifact.type];
|
|
3209
3390
|
if (Renderer) {
|
|
3210
|
-
return /* @__PURE__ */
|
|
3391
|
+
return /* @__PURE__ */ jsx23(
|
|
3211
3392
|
ToolMotion,
|
|
3212
3393
|
{
|
|
3213
3394
|
motionKey: `artifact-${artifact.type}`,
|
|
3214
3395
|
className: "aui-tool-artifact",
|
|
3215
|
-
children: /* @__PURE__ */
|
|
3396
|
+
children: /* @__PURE__ */ jsx23(Renderer, { artifact })
|
|
3216
3397
|
}
|
|
3217
3398
|
);
|
|
3218
3399
|
}
|
|
3219
3400
|
}
|
|
3220
3401
|
}
|
|
3221
|
-
return /* @__PURE__ */
|
|
3402
|
+
return /* @__PURE__ */ jsx23(ToolFallback, { ...props });
|
|
3222
3403
|
};
|
|
3223
3404
|
|
|
3224
3405
|
// src/chat/composer.tsx
|
|
@@ -3228,7 +3409,7 @@ import {
|
|
|
3228
3409
|
useComposerRuntime
|
|
3229
3410
|
} from "@assistant-ui/react";
|
|
3230
3411
|
import { ArrowUpIcon, SquareIcon } from "lucide-react";
|
|
3231
|
-
import { Fragment, jsx as
|
|
3412
|
+
import { Fragment as Fragment2, jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3232
3413
|
var Composer = ({
|
|
3233
3414
|
placeholder = "Send a message...",
|
|
3234
3415
|
showAttachments,
|
|
@@ -3239,10 +3420,10 @@ var Composer = ({
|
|
|
3239
3420
|
}) => {
|
|
3240
3421
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
3241
3422
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
3242
|
-
const shell = /* @__PURE__ */
|
|
3243
|
-
attachUi && /* @__PURE__ */
|
|
3244
|
-
/* @__PURE__ */
|
|
3245
|
-
/* @__PURE__ */
|
|
3423
|
+
const shell = /* @__PURE__ */ jsxs13(Fragment2, { children: [
|
|
3424
|
+
attachUi && /* @__PURE__ */ jsx24(ComposerAttachments, {}),
|
|
3425
|
+
/* @__PURE__ */ jsx24(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
3426
|
+
/* @__PURE__ */ jsx24(
|
|
3246
3427
|
ComposerToolbar,
|
|
3247
3428
|
{
|
|
3248
3429
|
showAttachments: attachUi,
|
|
@@ -3251,14 +3432,14 @@ var Composer = ({
|
|
|
3251
3432
|
}
|
|
3252
3433
|
)
|
|
3253
3434
|
] });
|
|
3254
|
-
return /* @__PURE__ */
|
|
3435
|
+
return /* @__PURE__ */ jsx24(
|
|
3255
3436
|
ComposerPrimitive2.Root,
|
|
3256
3437
|
{
|
|
3257
3438
|
className: cn(
|
|
3258
3439
|
"aui-composer-root relative flex w-full flex-col",
|
|
3259
3440
|
className
|
|
3260
3441
|
),
|
|
3261
|
-
children: attachUi ? /* @__PURE__ */
|
|
3442
|
+
children: attachUi ? /* @__PURE__ */ jsx24(
|
|
3262
3443
|
ComposerPrimitive2.AttachmentDropzone,
|
|
3263
3444
|
{
|
|
3264
3445
|
className: cn(
|
|
@@ -3267,7 +3448,7 @@ var Composer = ({
|
|
|
3267
3448
|
),
|
|
3268
3449
|
children: shell
|
|
3269
3450
|
}
|
|
3270
|
-
) : /* @__PURE__ */
|
|
3451
|
+
) : /* @__PURE__ */ jsx24("div", { className: studioComposeInputShellClass, children: shell })
|
|
3271
3452
|
}
|
|
3272
3453
|
);
|
|
3273
3454
|
};
|
|
@@ -3287,7 +3468,7 @@ var ComposerInput = ({
|
|
|
3287
3468
|
el.style.height = "auto";
|
|
3288
3469
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
3289
3470
|
};
|
|
3290
|
-
return /* @__PURE__ */
|
|
3471
|
+
return /* @__PURE__ */ jsx24(
|
|
3291
3472
|
ComposerPrimitive2.Input,
|
|
3292
3473
|
{
|
|
3293
3474
|
placeholder,
|
|
@@ -3301,17 +3482,17 @@ var ComposerInput = ({
|
|
|
3301
3482
|
);
|
|
3302
3483
|
};
|
|
3303
3484
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
3304
|
-
return /* @__PURE__ */
|
|
3305
|
-
/* @__PURE__ */
|
|
3306
|
-
showAttachments && /* @__PURE__ */
|
|
3485
|
+
return /* @__PURE__ */ jsxs13("div", { className: "aui-composer-action-wrapper relative z-[1] flex items-center justify-between gap-1 bg-composer-bg px-2.5 pb-2.5", children: [
|
|
3486
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
|
|
3487
|
+
showAttachments && /* @__PURE__ */ jsx24(ComposerAddAttachment, {}),
|
|
3307
3488
|
toolbar
|
|
3308
3489
|
] }),
|
|
3309
|
-
/* @__PURE__ */
|
|
3490
|
+
/* @__PURE__ */ jsx24(ComposerSendOrCancel, { sendTooltip })
|
|
3310
3491
|
] });
|
|
3311
3492
|
};
|
|
3312
3493
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
3313
|
-
return /* @__PURE__ */
|
|
3314
|
-
/* @__PURE__ */
|
|
3494
|
+
return /* @__PURE__ */ jsxs13(Fragment2, { children: [
|
|
3495
|
+
/* @__PURE__ */ jsx24(AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ jsx24(ComposerPrimitive2.Send, { asChild: true, children: /* @__PURE__ */ jsx24(
|
|
3315
3496
|
TooltipIconButton,
|
|
3316
3497
|
{
|
|
3317
3498
|
tooltip: sendTooltip,
|
|
@@ -3319,17 +3500,17 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3319
3500
|
type: "submit",
|
|
3320
3501
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
3321
3502
|
"aria-label": "Send message",
|
|
3322
|
-
children: /* @__PURE__ */
|
|
3503
|
+
children: /* @__PURE__ */ jsx24(ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
3323
3504
|
}
|
|
3324
3505
|
) }) }),
|
|
3325
|
-
/* @__PURE__ */
|
|
3506
|
+
/* @__PURE__ */ jsx24(AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ jsx24(ComposerPrimitive2.Cancel, { asChild: true, children: /* @__PURE__ */ jsx24(
|
|
3326
3507
|
TooltipIconButton,
|
|
3327
3508
|
{
|
|
3328
3509
|
tooltip: "Stop generating",
|
|
3329
3510
|
variant: "primary",
|
|
3330
3511
|
className: "aui-composer-cancel shrink-0",
|
|
3331
3512
|
"aria-label": "Stop generating",
|
|
3332
|
-
children: /* @__PURE__ */
|
|
3513
|
+
children: /* @__PURE__ */ jsx24(SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
3333
3514
|
}
|
|
3334
3515
|
) }) })
|
|
3335
3516
|
] });
|
|
@@ -3337,20 +3518,20 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3337
3518
|
|
|
3338
3519
|
// src/chat/suggestions.tsx
|
|
3339
3520
|
import {
|
|
3340
|
-
useEffect as
|
|
3341
|
-
useMemo as
|
|
3342
|
-
useState as
|
|
3521
|
+
useEffect as useEffect4,
|
|
3522
|
+
useMemo as useMemo5,
|
|
3523
|
+
useState as useState7
|
|
3343
3524
|
} from "react";
|
|
3344
3525
|
import { useThreadRuntime as useThreadRuntime3 } from "@assistant-ui/react";
|
|
3345
3526
|
import { ArrowUpIcon as ArrowUpIcon2 } from "lucide-react";
|
|
3346
|
-
import { jsx as
|
|
3527
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3347
3528
|
var Suggestions = ({
|
|
3348
3529
|
suggestions,
|
|
3349
3530
|
className
|
|
3350
3531
|
}) => {
|
|
3351
3532
|
const items = useResolvedSuggestions(suggestions);
|
|
3352
3533
|
if (!items || items.length === 0) return null;
|
|
3353
|
-
return /* @__PURE__ */
|
|
3534
|
+
return /* @__PURE__ */ jsx25(
|
|
3354
3535
|
"div",
|
|
3355
3536
|
{
|
|
3356
3537
|
className: cn(
|
|
@@ -3359,7 +3540,7 @@ var Suggestions = ({
|
|
|
3359
3540
|
),
|
|
3360
3541
|
role: "list",
|
|
3361
3542
|
"aria-label": "Suggested prompts",
|
|
3362
|
-
children: items.map((suggestion, i) => /* @__PURE__ */
|
|
3543
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ jsx25(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
3363
3544
|
}
|
|
3364
3545
|
);
|
|
3365
3546
|
};
|
|
@@ -3369,7 +3550,7 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3369
3550
|
const text = suggestion.prompt ?? suggestion.title;
|
|
3370
3551
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
3371
3552
|
};
|
|
3372
|
-
return /* @__PURE__ */
|
|
3553
|
+
return /* @__PURE__ */ jsxs14(
|
|
3373
3554
|
"button",
|
|
3374
3555
|
{
|
|
3375
3556
|
type: "button",
|
|
@@ -3377,20 +3558,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3377
3558
|
onClick,
|
|
3378
3559
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
3379
3560
|
children: [
|
|
3380
|
-
/* @__PURE__ */
|
|
3381
|
-
/* @__PURE__ */
|
|
3382
|
-
/* @__PURE__ */
|
|
3383
|
-
suggestion.description && /* @__PURE__ */
|
|
3561
|
+
/* @__PURE__ */ jsx25("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ jsx25(ArrowUpIcon2, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
3562
|
+
/* @__PURE__ */ jsxs14("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
3563
|
+
/* @__PURE__ */ jsx25("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
3564
|
+
suggestion.description && /* @__PURE__ */ jsx25("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
3384
3565
|
] })
|
|
3385
3566
|
]
|
|
3386
3567
|
}
|
|
3387
3568
|
);
|
|
3388
3569
|
};
|
|
3389
3570
|
function useResolvedSuggestions(source) {
|
|
3390
|
-
const [resolved, setResolved] =
|
|
3571
|
+
const [resolved, setResolved] = useState7(
|
|
3391
3572
|
() => Array.isArray(source) ? source : void 0
|
|
3392
3573
|
);
|
|
3393
|
-
|
|
3574
|
+
useEffect4(() => {
|
|
3394
3575
|
if (!source) {
|
|
3395
3576
|
setResolved(void 0);
|
|
3396
3577
|
return;
|
|
@@ -3409,11 +3590,11 @@ function useResolvedSuggestions(source) {
|
|
|
3409
3590
|
cancelled = true;
|
|
3410
3591
|
};
|
|
3411
3592
|
}, [source]);
|
|
3412
|
-
return
|
|
3593
|
+
return useMemo5(() => resolved, [resolved]);
|
|
3413
3594
|
}
|
|
3414
3595
|
|
|
3415
3596
|
// src/chat/thread.tsx
|
|
3416
|
-
import { useEffect as
|
|
3597
|
+
import { useEffect as useEffect5 } from "react";
|
|
3417
3598
|
import {
|
|
3418
3599
|
ActionBarMorePrimitive,
|
|
3419
3600
|
ActionBarPrimitive,
|
|
@@ -3514,7 +3695,7 @@ function useThreadVariant() {
|
|
|
3514
3695
|
}
|
|
3515
3696
|
|
|
3516
3697
|
// src/chat/thread.tsx
|
|
3517
|
-
import { jsx as
|
|
3698
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3518
3699
|
var Thread = ({
|
|
3519
3700
|
className,
|
|
3520
3701
|
variant = "default",
|
|
@@ -3537,16 +3718,16 @@ var Thread = ({
|
|
|
3537
3718
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
3538
3719
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
3539
3720
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
3540
|
-
|
|
3721
|
+
useEffect5(() => {
|
|
3541
3722
|
scheduleThemeSanityCheck();
|
|
3542
3723
|
}, []);
|
|
3543
|
-
return /* @__PURE__ */
|
|
3724
|
+
return /* @__PURE__ */ jsx26(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ jsx26(
|
|
3544
3725
|
ArtifactRegistryProvider,
|
|
3545
3726
|
{
|
|
3546
3727
|
renderers: artifacts?.renderers,
|
|
3547
3728
|
override: artifacts?.override,
|
|
3548
|
-
children: /* @__PURE__ */
|
|
3549
|
-
}), children: /* @__PURE__ */
|
|
3729
|
+
children: /* @__PURE__ */ jsx26(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
3730
|
+
}), children: /* @__PURE__ */ jsx26(
|
|
3550
3731
|
ThreadPrimitive.Root,
|
|
3551
3732
|
{
|
|
3552
3733
|
className: cn(
|
|
@@ -3556,7 +3737,7 @@ var Thread = ({
|
|
|
3556
3737
|
),
|
|
3557
3738
|
style: { ["--thread-max-width"]: maxWidth },
|
|
3558
3739
|
"data-thread-variant": variant,
|
|
3559
|
-
children: /* @__PURE__ */
|
|
3740
|
+
children: /* @__PURE__ */ jsxs15(
|
|
3560
3741
|
ThreadPrimitive.Viewport,
|
|
3561
3742
|
{
|
|
3562
3743
|
turnAnchor: "bottom",
|
|
@@ -3565,7 +3746,7 @@ var Thread = ({
|
|
|
3565
3746
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
3566
3747
|
),
|
|
3567
3748
|
children: [
|
|
3568
|
-
/* @__PURE__ */
|
|
3749
|
+
/* @__PURE__ */ jsx26(
|
|
3569
3750
|
WelcomeSlot,
|
|
3570
3751
|
{
|
|
3571
3752
|
config: welcome,
|
|
@@ -3574,7 +3755,7 @@ var Thread = ({
|
|
|
3574
3755
|
Suggestions: SuggestionsSlot
|
|
3575
3756
|
}
|
|
3576
3757
|
),
|
|
3577
|
-
/* @__PURE__ */
|
|
3758
|
+
/* @__PURE__ */ jsx26(
|
|
3578
3759
|
ThreadPrimitive.Messages,
|
|
3579
3760
|
{
|
|
3580
3761
|
components: {
|
|
@@ -3584,14 +3765,14 @@ var Thread = ({
|
|
|
3584
3765
|
}
|
|
3585
3766
|
}
|
|
3586
3767
|
),
|
|
3587
|
-
/* @__PURE__ */
|
|
3768
|
+
/* @__PURE__ */ jsx26(
|
|
3588
3769
|
ThreadPrimitive.ViewportFooter,
|
|
3589
3770
|
{
|
|
3590
3771
|
className: cn(
|
|
3591
3772
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
3592
3773
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
3593
3774
|
),
|
|
3594
|
-
children: /* @__PURE__ */
|
|
3775
|
+
children: /* @__PURE__ */ jsxs15(
|
|
3595
3776
|
"div",
|
|
3596
3777
|
{
|
|
3597
3778
|
className: cn(
|
|
@@ -3599,8 +3780,8 @@ var Thread = ({
|
|
|
3599
3780
|
isPanel ? "gap-2" : "gap-4"
|
|
3600
3781
|
),
|
|
3601
3782
|
children: [
|
|
3602
|
-
/* @__PURE__ */
|
|
3603
|
-
/* @__PURE__ */
|
|
3783
|
+
/* @__PURE__ */ jsx26(ScrollToBottomSlot, {}),
|
|
3784
|
+
/* @__PURE__ */ jsx26(ComposerSlot, { placeholder })
|
|
3604
3785
|
]
|
|
3605
3786
|
}
|
|
3606
3787
|
)
|
|
@@ -3615,13 +3796,13 @@ var Thread = ({
|
|
|
3615
3796
|
) });
|
|
3616
3797
|
};
|
|
3617
3798
|
var ThreadScrollToBottom = () => {
|
|
3618
|
-
return /* @__PURE__ */
|
|
3799
|
+
return /* @__PURE__ */ jsx26(ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx26(
|
|
3619
3800
|
TooltipIconButton,
|
|
3620
3801
|
{
|
|
3621
3802
|
tooltip: "Scroll to bottom",
|
|
3622
3803
|
variant: "secondary",
|
|
3623
3804
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
3624
|
-
children: /* @__PURE__ */
|
|
3805
|
+
children: /* @__PURE__ */ jsx26(ArrowDownIcon, { className: "size-4" })
|
|
3625
3806
|
}
|
|
3626
3807
|
) });
|
|
3627
3808
|
};
|
|
@@ -3660,8 +3841,8 @@ var ThreadWelcome = ({
|
|
|
3660
3841
|
if (!isEmpty) return null;
|
|
3661
3842
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
3662
3843
|
const defaultSubheading = isPanel ? "The assistant can use dashboard context from your app." : "Send a message to start a conversation.";
|
|
3663
|
-
return /* @__PURE__ */
|
|
3664
|
-
/* @__PURE__ */
|
|
3844
|
+
return /* @__PURE__ */ jsxs15("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
3845
|
+
/* @__PURE__ */ jsx26("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxs15(
|
|
3665
3846
|
motion3.div,
|
|
3666
3847
|
{
|
|
3667
3848
|
className: cn(
|
|
@@ -3672,8 +3853,8 @@ var ThreadWelcome = ({
|
|
|
3672
3853
|
initial: "initial",
|
|
3673
3854
|
animate: "animate",
|
|
3674
3855
|
children: [
|
|
3675
|
-
config?.icon && /* @__PURE__ */
|
|
3676
|
-
/* @__PURE__ */
|
|
3856
|
+
config?.icon && /* @__PURE__ */ jsx26(motion3.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
3857
|
+
/* @__PURE__ */ jsx26(
|
|
3677
3858
|
motion3.h1,
|
|
3678
3859
|
{
|
|
3679
3860
|
variants: welcomeItem,
|
|
@@ -3684,7 +3865,7 @@ var ThreadWelcome = ({
|
|
|
3684
3865
|
children: config?.heading ?? defaultHeading
|
|
3685
3866
|
}
|
|
3686
3867
|
),
|
|
3687
|
-
/* @__PURE__ */
|
|
3868
|
+
/* @__PURE__ */ jsx26(
|
|
3688
3869
|
motion3.p,
|
|
3689
3870
|
{
|
|
3690
3871
|
variants: welcomeItem,
|
|
@@ -3695,15 +3876,15 @@ var ThreadWelcome = ({
|
|
|
3695
3876
|
]
|
|
3696
3877
|
}
|
|
3697
3878
|
) }),
|
|
3698
|
-
showWelcomeSuggestions && suggestions ? /* @__PURE__ */
|
|
3879
|
+
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ jsx26("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ jsx26(SuggestionsSlot, { suggestions }) }) : null
|
|
3699
3880
|
] });
|
|
3700
3881
|
};
|
|
3701
3882
|
var MessageError = () => {
|
|
3702
|
-
return /* @__PURE__ */
|
|
3883
|
+
return /* @__PURE__ */ jsx26(MessagePrimitive2.Error, { children: /* @__PURE__ */ jsx26(ErrorPrimitive.Root, { className: "aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm", children: /* @__PURE__ */ jsx26(ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
3703
3884
|
};
|
|
3704
3885
|
var AssistantMessage = () => {
|
|
3705
3886
|
const isPanel = useThreadVariant() === "panel";
|
|
3706
|
-
return /* @__PURE__ */
|
|
3887
|
+
return /* @__PURE__ */ jsxs15(
|
|
3707
3888
|
MessagePrimitive2.Root,
|
|
3708
3889
|
{
|
|
3709
3890
|
className: cn(
|
|
@@ -3712,7 +3893,7 @@ var AssistantMessage = () => {
|
|
|
3712
3893
|
),
|
|
3713
3894
|
"data-role": "assistant",
|
|
3714
3895
|
children: [
|
|
3715
|
-
/* @__PURE__ */
|
|
3896
|
+
/* @__PURE__ */ jsxs15(
|
|
3716
3897
|
"div",
|
|
3717
3898
|
{
|
|
3718
3899
|
className: cn(
|
|
@@ -3720,7 +3901,7 @@ var AssistantMessage = () => {
|
|
|
3720
3901
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
3721
3902
|
),
|
|
3722
3903
|
children: [
|
|
3723
|
-
/* @__PURE__ */
|
|
3904
|
+
/* @__PURE__ */ jsx26(
|
|
3724
3905
|
MessagePrimitive2.Parts,
|
|
3725
3906
|
{
|
|
3726
3907
|
components: {
|
|
@@ -3731,11 +3912,11 @@ var AssistantMessage = () => {
|
|
|
3731
3912
|
}
|
|
3732
3913
|
}
|
|
3733
3914
|
),
|
|
3734
|
-
/* @__PURE__ */
|
|
3915
|
+
/* @__PURE__ */ jsx26(MessageError, {})
|
|
3735
3916
|
]
|
|
3736
3917
|
}
|
|
3737
3918
|
),
|
|
3738
|
-
/* @__PURE__ */
|
|
3919
|
+
/* @__PURE__ */ jsx26("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ jsx26(AssistantActionBar, {}) })
|
|
3739
3920
|
]
|
|
3740
3921
|
}
|
|
3741
3922
|
);
|
|
@@ -3748,36 +3929,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
3748
3929
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
3749
3930
|
);
|
|
3750
3931
|
var AssistantActionBar = () => {
|
|
3751
|
-
return /* @__PURE__ */
|
|
3932
|
+
return /* @__PURE__ */ jsxs15(
|
|
3752
3933
|
ActionBarPrimitive.Root,
|
|
3753
3934
|
{
|
|
3754
3935
|
hideWhenRunning: true,
|
|
3755
3936
|
autohide: "never",
|
|
3756
3937
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
3757
3938
|
children: [
|
|
3758
|
-
/* @__PURE__ */
|
|
3939
|
+
/* @__PURE__ */ jsx26(ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ jsxs15(
|
|
3759
3940
|
TooltipIconButton,
|
|
3760
3941
|
{
|
|
3761
3942
|
tooltip: "Copy",
|
|
3762
3943
|
variant: "ghost",
|
|
3763
3944
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3764
3945
|
children: [
|
|
3765
|
-
/* @__PURE__ */
|
|
3766
|
-
/* @__PURE__ */
|
|
3946
|
+
/* @__PURE__ */ jsx26(AuiIf2, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ jsx26(CheckIcon3, { className: "size-3" }) }),
|
|
3947
|
+
/* @__PURE__ */ jsx26(AuiIf2, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ jsx26(CopyIcon2, { className: "size-3" }) })
|
|
3767
3948
|
]
|
|
3768
3949
|
}
|
|
3769
3950
|
) }),
|
|
3770
|
-
/* @__PURE__ */
|
|
3951
|
+
/* @__PURE__ */ jsx26(ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ jsx26(
|
|
3771
3952
|
TooltipIconButton,
|
|
3772
3953
|
{
|
|
3773
3954
|
tooltip: "Regenerate",
|
|
3774
3955
|
variant: "ghost",
|
|
3775
3956
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3776
|
-
children: /* @__PURE__ */
|
|
3957
|
+
children: /* @__PURE__ */ jsx26(RefreshCwIcon, { className: "size-3" })
|
|
3777
3958
|
}
|
|
3778
3959
|
) }),
|
|
3779
|
-
/* @__PURE__ */
|
|
3780
|
-
/* @__PURE__ */
|
|
3960
|
+
/* @__PURE__ */ jsxs15(ActionBarMorePrimitive.Root, { children: [
|
|
3961
|
+
/* @__PURE__ */ jsx26(ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ jsx26(
|
|
3781
3962
|
TooltipIconButton,
|
|
3782
3963
|
{
|
|
3783
3964
|
tooltip: "More",
|
|
@@ -3786,17 +3967,17 @@ var AssistantActionBar = () => {
|
|
|
3786
3967
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
3787
3968
|
"data-[state=open]:text-muted-foreground/80"
|
|
3788
3969
|
),
|
|
3789
|
-
children: /* @__PURE__ */
|
|
3970
|
+
children: /* @__PURE__ */ jsx26(MoreHorizontalIcon, { className: "size-3" })
|
|
3790
3971
|
}
|
|
3791
3972
|
) }),
|
|
3792
|
-
/* @__PURE__ */
|
|
3973
|
+
/* @__PURE__ */ jsx26(
|
|
3793
3974
|
ActionBarMorePrimitive.Content,
|
|
3794
3975
|
{
|
|
3795
3976
|
side: "bottom",
|
|
3796
3977
|
align: "start",
|
|
3797
3978
|
className: "aui-action-bar-more-content z-50 min-w-36 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-card-elevated",
|
|
3798
|
-
children: /* @__PURE__ */
|
|
3799
|
-
/* @__PURE__ */
|
|
3979
|
+
children: /* @__PURE__ */ jsx26(ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ jsxs15(ActionBarMorePrimitive.Item, { className: "aui-action-bar-more-item flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none hover:bg-muted focus:bg-muted", children: [
|
|
3980
|
+
/* @__PURE__ */ jsx26(DownloadIcon, { className: "size-4 shrink-0" }),
|
|
3800
3981
|
"Export as Markdown"
|
|
3801
3982
|
] }) })
|
|
3802
3983
|
}
|
|
@@ -3807,11 +3988,11 @@ var AssistantActionBar = () => {
|
|
|
3807
3988
|
);
|
|
3808
3989
|
};
|
|
3809
3990
|
var UserMessageText = () => {
|
|
3810
|
-
return /* @__PURE__ */
|
|
3991
|
+
return /* @__PURE__ */ jsx26("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ jsx26(MessagePartPrimitive.Text, { smooth: false }) });
|
|
3811
3992
|
};
|
|
3812
3993
|
var UserMessage = () => {
|
|
3813
3994
|
const isPanel = useThreadVariant() === "panel";
|
|
3814
|
-
return /* @__PURE__ */
|
|
3995
|
+
return /* @__PURE__ */ jsxs15(
|
|
3815
3996
|
MessagePrimitive2.Root,
|
|
3816
3997
|
{
|
|
3817
3998
|
className: cn(
|
|
@@ -3820,8 +4001,8 @@ var UserMessage = () => {
|
|
|
3820
4001
|
),
|
|
3821
4002
|
"data-role": "user",
|
|
3822
4003
|
children: [
|
|
3823
|
-
/* @__PURE__ */
|
|
3824
|
-
/* @__PURE__ */
|
|
4004
|
+
/* @__PURE__ */ jsx26(UserMessageAttachments, {}),
|
|
4005
|
+
/* @__PURE__ */ jsxs15(
|
|
3825
4006
|
motion3.div,
|
|
3826
4007
|
{
|
|
3827
4008
|
className: cn(
|
|
@@ -3832,8 +4013,8 @@ var UserMessage = () => {
|
|
|
3832
4013
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
3833
4014
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
3834
4015
|
children: [
|
|
3835
|
-
/* @__PURE__ */
|
|
3836
|
-
/* @__PURE__ */
|
|
4016
|
+
/* @__PURE__ */ jsx26(MessagePrimitive2.Parts, { components: { Text: UserMessageText } }),
|
|
4017
|
+
/* @__PURE__ */ jsx26("div", { className: "aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2", children: /* @__PURE__ */ jsx26(UserActionBar, {}) })
|
|
3837
4018
|
]
|
|
3838
4019
|
}
|
|
3839
4020
|
)
|
|
@@ -3842,42 +4023,42 @@ var UserMessage = () => {
|
|
|
3842
4023
|
);
|
|
3843
4024
|
};
|
|
3844
4025
|
var UserActionBar = () => {
|
|
3845
|
-
return /* @__PURE__ */
|
|
4026
|
+
return /* @__PURE__ */ jsx26(
|
|
3846
4027
|
ActionBarPrimitive.Root,
|
|
3847
4028
|
{
|
|
3848
4029
|
hideWhenRunning: true,
|
|
3849
4030
|
autohide: "always",
|
|
3850
4031
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
3851
|
-
children: /* @__PURE__ */
|
|
4032
|
+
children: /* @__PURE__ */ jsx26(ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ jsx26(
|
|
3852
4033
|
TooltipIconButton,
|
|
3853
4034
|
{
|
|
3854
4035
|
tooltip: "Edit",
|
|
3855
4036
|
variant: "ghost",
|
|
3856
4037
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3857
|
-
children: /* @__PURE__ */
|
|
4038
|
+
children: /* @__PURE__ */ jsx26(PencilIcon, { className: "size-3" })
|
|
3858
4039
|
}
|
|
3859
4040
|
) })
|
|
3860
4041
|
}
|
|
3861
4042
|
);
|
|
3862
4043
|
};
|
|
3863
4044
|
var EditComposer = () => {
|
|
3864
|
-
return /* @__PURE__ */
|
|
3865
|
-
/* @__PURE__ */
|
|
4045
|
+
return /* @__PURE__ */ jsx26(MessagePrimitive2.Root, { className: "aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-max-width) flex-col px-2 py-3", children: /* @__PURE__ */ jsxs15(ComposerPrimitive3.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
4046
|
+
/* @__PURE__ */ jsx26(
|
|
3866
4047
|
ComposerPrimitive3.Input,
|
|
3867
4048
|
{
|
|
3868
4049
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
3869
4050
|
autoFocus: true
|
|
3870
4051
|
}
|
|
3871
4052
|
),
|
|
3872
|
-
/* @__PURE__ */
|
|
3873
|
-
/* @__PURE__ */
|
|
3874
|
-
/* @__PURE__ */
|
|
4053
|
+
/* @__PURE__ */ jsxs15("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
4054
|
+
/* @__PURE__ */ jsx26(ComposerPrimitive3.Cancel, { asChild: true, children: /* @__PURE__ */ jsx26(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
4055
|
+
/* @__PURE__ */ jsx26(ComposerPrimitive3.Send, { asChild: true, children: /* @__PURE__ */ jsx26(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
3875
4056
|
] })
|
|
3876
4057
|
] }) });
|
|
3877
4058
|
};
|
|
3878
4059
|
|
|
3879
4060
|
// src/chat/chat.tsx
|
|
3880
|
-
import { jsx as
|
|
4061
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
3881
4062
|
function TimbalChat({
|
|
3882
4063
|
workforceId,
|
|
3883
4064
|
baseUrl,
|
|
@@ -3888,7 +4069,7 @@ function TimbalChat({
|
|
|
3888
4069
|
debug,
|
|
3889
4070
|
...threadProps
|
|
3890
4071
|
}) {
|
|
3891
|
-
return /* @__PURE__ */
|
|
4072
|
+
return /* @__PURE__ */ jsx27(
|
|
3892
4073
|
TimbalRuntimeProvider,
|
|
3893
4074
|
{
|
|
3894
4075
|
workforceId,
|
|
@@ -3898,7 +4079,7 @@ function TimbalChat({
|
|
|
3898
4079
|
attachmentsUploadUrl,
|
|
3899
4080
|
attachmentsAccept,
|
|
3900
4081
|
debug,
|
|
3901
|
-
children: /* @__PURE__ */
|
|
4082
|
+
children: /* @__PURE__ */ jsx27(Thread, { ...threadProps })
|
|
3902
4083
|
}
|
|
3903
4084
|
);
|
|
3904
4085
|
}
|
|
@@ -3907,8 +4088,6 @@ export {
|
|
|
3907
4088
|
studioTopbarPillHeightClass,
|
|
3908
4089
|
studioTopbarIconPillClass,
|
|
3909
4090
|
studioPlaygroundGradientClass,
|
|
3910
|
-
studioSecondaryChromeClass,
|
|
3911
|
-
studioSearchChromeClass,
|
|
3912
4091
|
studioIntegrationCardClass,
|
|
3913
4092
|
studioSidebarPanelClass,
|
|
3914
4093
|
studioSidebarNavItemClass,
|
|
@@ -3926,6 +4105,9 @@ export {
|
|
|
3926
4105
|
monotoneAreaPath,
|
|
3927
4106
|
CHART_PALETTE,
|
|
3928
4107
|
LineAreaChart,
|
|
4108
|
+
PieChart,
|
|
4109
|
+
RadialChart,
|
|
4110
|
+
RadarChart,
|
|
3929
4111
|
ArtifactCard,
|
|
3930
4112
|
ChartArtifactView,
|
|
3931
4113
|
QuestionArtifactView,
|