@timbal-ai/timbal-react 0.6.0 → 0.7.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 +37 -0
- package/README.md +24 -5
- package/dist/app.cjs +2282 -738
- package/dist/app.d.cts +4 -1
- package/dist/app.d.ts +4 -1
- package/dist/app.esm.js +58 -5
- package/dist/button-CIKzUrJI.d.cts +18 -0
- package/dist/button-CIKzUrJI.d.ts +18 -0
- package/dist/chart-artifact-BFDz8Tf9.d.ts +756 -0
- package/dist/chart-artifact-bWUa-iSG.d.cts +756 -0
- package/dist/chat.cjs +872 -562
- package/dist/chat.d.cts +2 -2
- package/dist/chat.d.ts +2 -2
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-4TCJQSIX.esm.js → chunk-2XZ3S4OP.esm.js} +14 -3
- package/dist/chunk-533MK5EA.esm.js +2294 -0
- package/dist/{chunk-OVHR7J3J.esm.js → chunk-7O5VY3TP.esm.js} +38 -11
- package/dist/{chunk-WLTW56MC.esm.js → chunk-N3PYVTY5.esm.js} +2 -2
- package/dist/{chunk-IYENDIRY.esm.js → chunk-TDIJHV4I.esm.js} +1 -1
- package/dist/{chunk-YJQLLFKP.esm.js → chunk-TLUF2RUL.esm.js} +813 -507
- package/dist/{chunk-OFHLFNJH.esm.js → chunk-Z27GBSOT.esm.js} +3 -1
- package/dist/index.cjs +2587 -1016
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.esm.js +57 -7
- package/dist/{layout-CQWngNQ7.d.ts → layout-BTJyU8wd.d.ts} +1 -1
- package/dist/{layout-B9VayJhZ.d.cts → layout-C2G-FcER.d.cts} +1 -1
- package/dist/studio.cjs +1127 -788
- package/dist/studio.d.cts +1 -1
- package/dist/studio.d.ts +1 -1
- package/dist/studio.esm.js +6 -6
- package/dist/{timbal-v2-button-F4-z7m33.d.ts → timbal-v2-button-CNfdwGq4.d.cts} +1 -1
- package/dist/{timbal-v2-button-F4-z7m33.d.cts → timbal-v2-button-CNfdwGq4.d.ts} +1 -1
- package/dist/ui.cjs +12 -3
- package/dist/ui.d.cts +5 -16
- package/dist/ui.d.ts +5 -16
- package/dist/ui.esm.js +2 -2
- package/dist/{welcome-BOizSp5h.d.ts → welcome-BBmB3tl7.d.ts} +4 -3
- package/dist/{welcome--80i_O0p.d.cts → welcome-C89Mgdaw.d.cts} +4 -3
- package/package.json +2 -1
- package/vite/local-dev.mjs +91 -5
- package/dist/chart-artifact-C71dk4xI.d.ts +0 -329
- package/dist/chart-artifact-CPEpOmtV.d.cts +0 -329
- package/dist/chunk-M4V6Q6XO.esm.js +0 -1082
package/dist/studio.cjs
CHANGED
|
@@ -898,10 +898,10 @@ function findParentIdFromAuiParent(messages, auiParentId) {
|
|
|
898
898
|
}
|
|
899
899
|
|
|
900
900
|
// src/chat/thread.tsx
|
|
901
|
-
var
|
|
902
|
-
var
|
|
901
|
+
var import_react29 = require("react");
|
|
902
|
+
var import_react30 = require("@assistant-ui/react");
|
|
903
903
|
var import_lucide_react8 = require("lucide-react");
|
|
904
|
-
var
|
|
904
|
+
var import_react31 = require("motion/react");
|
|
905
905
|
|
|
906
906
|
// src/chat/attachment.tsx
|
|
907
907
|
var import_react5 = require("react");
|
|
@@ -1066,6 +1066,10 @@ var TIMBAL_V2_SWITCH_THUMB = cn(
|
|
|
1066
1066
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1067
1067
|
"border border-border/80 shadow-sm"
|
|
1068
1068
|
);
|
|
1069
|
+
var TIMBAL_V2_ELEVATED_SURFACE = cn(
|
|
1070
|
+
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1071
|
+
"border border-border shadow-card"
|
|
1072
|
+
);
|
|
1069
1073
|
var TIMBAL_V2_SECONDARY_CHROME = [
|
|
1070
1074
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1071
1075
|
"border border-border shadow-card",
|
|
@@ -1073,6 +1077,11 @@ var TIMBAL_V2_SECONDARY_CHROME = [
|
|
|
1073
1077
|
"hover:from-secondary-fill-hover-from hover:to-secondary-fill-hover-to",
|
|
1074
1078
|
"active:from-secondary-fill-active-from active:to-secondary-fill-active-to"
|
|
1075
1079
|
].join(" ");
|
|
1080
|
+
var TIMBAL_V2_LOGO_TILE = cn(
|
|
1081
|
+
"bg-gradient-to-b from-white to-neutral-100",
|
|
1082
|
+
"border border-neutral-200",
|
|
1083
|
+
"shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.08)]"
|
|
1084
|
+
);
|
|
1076
1085
|
|
|
1077
1086
|
// src/ui/dialog.tsx
|
|
1078
1087
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -1254,7 +1263,7 @@ var TimbalV2Button = React.forwardRef(function TimbalV2Button2({
|
|
|
1254
1263
|
isIconOnly = false,
|
|
1255
1264
|
isLoading = false,
|
|
1256
1265
|
fullWidth = false,
|
|
1257
|
-
shape = "pill",
|
|
1266
|
+
shape: _shape = "pill",
|
|
1258
1267
|
asChild = false,
|
|
1259
1268
|
className,
|
|
1260
1269
|
disabled,
|
|
@@ -1264,7 +1273,7 @@ var TimbalV2Button = React.forwardRef(function TimbalV2Button2({
|
|
|
1264
1273
|
}, ref) {
|
|
1265
1274
|
const isDisabled = disabled || isLoading;
|
|
1266
1275
|
const sizeClass = isIconOnly ? TIMBAL_V2_SIZE_ICON[size] : TIMBAL_V2_SIZE_HEIGHT[size];
|
|
1267
|
-
const radiusClass =
|
|
1276
|
+
const radiusClass = "rounded-full";
|
|
1268
1277
|
const sharedRootClass = cn(
|
|
1269
1278
|
"relative box-border inline-flex items-center justify-center gap-2 whitespace-nowrap border-0 text-sm font-normal shadow-none transition duration-200 ease-in-out",
|
|
1270
1279
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
@@ -1513,293 +1522,625 @@ var import_react_markdown = require("@assistant-ui/react-markdown");
|
|
|
1513
1522
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1514
1523
|
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1515
1524
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1516
|
-
var
|
|
1525
|
+
var import_react19 = require("react");
|
|
1517
1526
|
var import_lucide_react4 = require("lucide-react");
|
|
1518
1527
|
|
|
1519
1528
|
// src/chat/syntax-highlighter.tsx
|
|
1520
|
-
var
|
|
1529
|
+
var import_react18 = require("react");
|
|
1521
1530
|
var import_core = require("shiki/core");
|
|
1522
1531
|
var import_javascript = require("shiki/engine/javascript");
|
|
1523
1532
|
|
|
1524
1533
|
// src/artifacts/registry.tsx
|
|
1525
|
-
var
|
|
1534
|
+
var import_react17 = require("react");
|
|
1526
1535
|
|
|
1527
1536
|
// src/artifacts/chart-artifact.tsx
|
|
1537
|
+
var import_react9 = require("react");
|
|
1538
|
+
|
|
1539
|
+
// src/charts/line-area-chart.tsx
|
|
1540
|
+
var import_react8 = require("react");
|
|
1541
|
+
|
|
1542
|
+
// src/charts/use-chart-width.ts
|
|
1528
1543
|
var import_react7 = require("react");
|
|
1544
|
+
function useChartWidth(initial = 640) {
|
|
1545
|
+
const ref = (0, import_react7.useRef)(null);
|
|
1546
|
+
const [width, setWidth] = (0, import_react7.useState)(initial);
|
|
1547
|
+
(0, import_react7.useEffect)(() => {
|
|
1548
|
+
const el = ref.current;
|
|
1549
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
1550
|
+
const ro = new ResizeObserver((entries) => {
|
|
1551
|
+
const w = entries[0]?.contentRect.width;
|
|
1552
|
+
if (w && w > 0) setWidth(w);
|
|
1553
|
+
});
|
|
1554
|
+
ro.observe(el);
|
|
1555
|
+
return () => ro.disconnect();
|
|
1556
|
+
}, []);
|
|
1557
|
+
return { ref, width };
|
|
1558
|
+
}
|
|
1529
1559
|
|
|
1530
|
-
// src/
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1560
|
+
// src/charts/geometry.ts
|
|
1561
|
+
function toNum(value) {
|
|
1562
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1563
|
+
return Number.isFinite(n) ? n : 0;
|
|
1564
|
+
}
|
|
1565
|
+
function monotoneLinePath(points) {
|
|
1566
|
+
const n = points.length;
|
|
1567
|
+
if (n === 0) return "";
|
|
1568
|
+
if (n === 1) return `M ${points[0].x},${points[0].y}`;
|
|
1569
|
+
if (n === 2) {
|
|
1570
|
+
return `M ${points[0].x},${points[0].y} L ${points[1].x},${points[1].y}`;
|
|
1571
|
+
}
|
|
1572
|
+
const tangents = monotoneTangents(points);
|
|
1573
|
+
let d = `M ${points[0].x},${points[0].y}`;
|
|
1574
|
+
for (let i = 0; i < n - 1; i++) {
|
|
1575
|
+
const p0 = points[i];
|
|
1576
|
+
const p1 = points[i + 1];
|
|
1577
|
+
const dx = (p1.x - p0.x) / 3;
|
|
1578
|
+
const c1x = p0.x + dx;
|
|
1579
|
+
const c1y = p0.y + dx * tangents[i];
|
|
1580
|
+
const c2x = p1.x - dx;
|
|
1581
|
+
const c2y = p1.y - dx * tangents[i + 1];
|
|
1582
|
+
d += ` C ${c1x},${c1y} ${c2x},${c2y} ${p1.x},${p1.y}`;
|
|
1583
|
+
}
|
|
1584
|
+
return d;
|
|
1585
|
+
}
|
|
1586
|
+
function monotoneAreaPath(points, baseY) {
|
|
1587
|
+
if (points.length === 0) return "";
|
|
1588
|
+
const line = monotoneLinePath(points);
|
|
1589
|
+
const last = points[points.length - 1];
|
|
1590
|
+
const first = points[0];
|
|
1591
|
+
return `${line} L ${last.x},${baseY} L ${first.x},${baseY} Z`;
|
|
1592
|
+
}
|
|
1593
|
+
function monotoneTangents(points) {
|
|
1594
|
+
const n = points.length;
|
|
1595
|
+
const slopes = new Array(n - 1);
|
|
1596
|
+
for (let i = 0; i < n - 1; i++) {
|
|
1597
|
+
const dx = points[i + 1].x - points[i].x || 1;
|
|
1598
|
+
slopes[i] = (points[i + 1].y - points[i].y) / dx;
|
|
1599
|
+
}
|
|
1600
|
+
const tangents = new Array(n);
|
|
1601
|
+
tangents[0] = slopes[0];
|
|
1602
|
+
tangents[n - 1] = slopes[n - 2];
|
|
1603
|
+
for (let i = 1; i < n - 1; i++) {
|
|
1604
|
+
const s0 = slopes[i - 1];
|
|
1605
|
+
const s1 = slopes[i];
|
|
1606
|
+
if (s0 * s1 <= 0) {
|
|
1607
|
+
tangents[i] = 0;
|
|
1608
|
+
} else {
|
|
1609
|
+
tangents[i] = (s0 + s1) / 2;
|
|
1550
1610
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1611
|
+
}
|
|
1612
|
+
for (let i = 0; i < n - 1; i++) {
|
|
1613
|
+
const s = slopes[i];
|
|
1614
|
+
if (s === 0) {
|
|
1615
|
+
tangents[i] = 0;
|
|
1616
|
+
tangents[i + 1] = 0;
|
|
1617
|
+
continue;
|
|
1618
|
+
}
|
|
1619
|
+
const a = tangents[i] / s;
|
|
1620
|
+
const b = tangents[i + 1] / s;
|
|
1621
|
+
const h = Math.hypot(a, b);
|
|
1622
|
+
if (h > 3) {
|
|
1623
|
+
const t = 3 / h;
|
|
1624
|
+
tangents[i] = t * a * s;
|
|
1625
|
+
tangents[i + 1] = t * b * s;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
return tangents;
|
|
1629
|
+
}
|
|
1630
|
+
function niceTicks(min, max, count = 4) {
|
|
1631
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || max === min) {
|
|
1632
|
+
return [min || 0];
|
|
1633
|
+
}
|
|
1634
|
+
const step = niceStep((max - min) / count);
|
|
1635
|
+
const start = Math.floor(min / step) * step;
|
|
1636
|
+
const out = [];
|
|
1637
|
+
for (let v = start; v <= max + step / 2; v += step) {
|
|
1638
|
+
out.push(round(v));
|
|
1639
|
+
}
|
|
1640
|
+
return out;
|
|
1641
|
+
}
|
|
1642
|
+
function niceStep(raw) {
|
|
1643
|
+
const exp = Math.floor(Math.log10(Math.abs(raw) || 1));
|
|
1644
|
+
const base = Math.pow(10, exp);
|
|
1645
|
+
const norm = raw / base;
|
|
1646
|
+
let nice = 1;
|
|
1647
|
+
if (norm >= 5) nice = 5;
|
|
1648
|
+
else if (norm >= 2) nice = 2;
|
|
1649
|
+
return nice * base;
|
|
1650
|
+
}
|
|
1651
|
+
function round(v) {
|
|
1652
|
+
return Math.round(v * 1e6) / 1e6;
|
|
1653
|
+
}
|
|
1654
|
+
function formatCompact(value, unit) {
|
|
1655
|
+
const abs = Math.abs(value);
|
|
1656
|
+
let s;
|
|
1657
|
+
if (abs >= 1e6) s = `${round(value / 1e6)}M`;
|
|
1658
|
+
else if (abs >= 1e3) s = `${round(value / 1e3)}k`;
|
|
1659
|
+
else s = String(round(value));
|
|
1660
|
+
return unit ? `${s}${unit}` : s;
|
|
1661
|
+
}
|
|
1553
1662
|
|
|
1554
|
-
// src/
|
|
1555
|
-
var
|
|
1556
|
-
var
|
|
1557
|
-
artifact
|
|
1558
|
-
}) => {
|
|
1559
|
-
const { type: _t, chartType = "bar", data = [] } = artifact;
|
|
1560
|
-
const xKey = artifact.xKey ?? inferXKey(data);
|
|
1561
|
-
const dataKeys = (0, import_react7.useMemo)(() => {
|
|
1562
|
-
if (Array.isArray(artifact.dataKey)) return artifact.dataKey;
|
|
1563
|
-
if (typeof artifact.dataKey === "string") return [artifact.dataKey];
|
|
1564
|
-
return inferDataKeys(data, xKey);
|
|
1565
|
-
}, [artifact.dataKey, data, xKey]);
|
|
1566
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "aui-artifact-chart p-3", children: [
|
|
1567
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1568
|
-
ChartSvg,
|
|
1569
|
-
{
|
|
1570
|
-
chartType,
|
|
1571
|
-
data,
|
|
1572
|
-
xKey,
|
|
1573
|
-
dataKeys,
|
|
1574
|
-
unit: artifact.unit
|
|
1575
|
-
}
|
|
1576
|
-
),
|
|
1577
|
-
dataKeys.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Legend, { dataKeys })
|
|
1578
|
-
] }) });
|
|
1579
|
-
};
|
|
1580
|
-
var COLORS = [
|
|
1663
|
+
// src/charts/line-area-chart.tsx
|
|
1664
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1665
|
+
var CHART_PALETTE = [
|
|
1581
1666
|
"var(--primary, #6366f1)",
|
|
1582
|
-
"#
|
|
1667
|
+
"#10b981",
|
|
1583
1668
|
"#f59e0b",
|
|
1584
|
-
"#ef4444",
|
|
1585
1669
|
"#06b6d4",
|
|
1586
|
-
"#a855f7"
|
|
1670
|
+
"#a855f7",
|
|
1671
|
+
"#ef4444"
|
|
1587
1672
|
];
|
|
1588
|
-
var
|
|
1589
|
-
var
|
|
1590
|
-
var
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1673
|
+
var PAD_DEFAULT = { top: 12, right: 16, bottom: 26, left: 44 };
|
|
1674
|
+
var PAD_FLUSH = { top: 20, right: 0, bottom: 8, left: 0 };
|
|
1675
|
+
var LineAreaChart = ({
|
|
1676
|
+
data = [],
|
|
1677
|
+
xKey: xKeyProp,
|
|
1678
|
+
series: seriesProp,
|
|
1679
|
+
variant = "area",
|
|
1680
|
+
height = 240,
|
|
1681
|
+
unit,
|
|
1682
|
+
yMax,
|
|
1683
|
+
layout = "default",
|
|
1684
|
+
showGrid = true,
|
|
1685
|
+
showXAxis: showXAxisProp,
|
|
1686
|
+
showYAxis: showYAxisProp,
|
|
1687
|
+
showLegend: showLegendProp,
|
|
1688
|
+
showTooltip = true,
|
|
1689
|
+
formatValue,
|
|
1690
|
+
formatX,
|
|
1691
|
+
className,
|
|
1692
|
+
ariaLabel = "Chart"
|
|
1693
|
+
}) => {
|
|
1694
|
+
const uid = (0, import_react8.useId)();
|
|
1695
|
+
const { ref, width } = useChartWidth();
|
|
1696
|
+
const [active, setActive] = (0, import_react8.useState)(null);
|
|
1697
|
+
const [grown, setGrown] = (0, import_react8.useState)(false);
|
|
1698
|
+
const xKey = xKeyProp ?? inferXKey(data);
|
|
1699
|
+
const series = (0, import_react8.useMemo)(
|
|
1700
|
+
() => resolveSeries(seriesProp, data, xKey),
|
|
1701
|
+
[seriesProp, data, xKey]
|
|
1702
|
+
);
|
|
1703
|
+
const pad = layout === "flush" ? PAD_FLUSH : PAD_DEFAULT;
|
|
1704
|
+
const showXAxis = showXAxisProp ?? layout !== "flush";
|
|
1705
|
+
const showYAxis = showYAxisProp ?? layout !== "flush";
|
|
1706
|
+
const showLegend = showLegendProp ?? (layout !== "flush" && series.length > 1);
|
|
1707
|
+
(0, import_react8.useEffect)(() => {
|
|
1708
|
+
const t = requestAnimationFrame(() => setGrown(true));
|
|
1709
|
+
return () => cancelAnimationFrame(t);
|
|
1710
|
+
}, []);
|
|
1711
|
+
const innerW = Math.max(0, width - pad.left - pad.right);
|
|
1712
|
+
const innerH = Math.max(0, height - pad.top - pad.bottom);
|
|
1713
|
+
const { minV, maxV } = (0, import_react8.useMemo)(() => {
|
|
1714
|
+
let lo = 0;
|
|
1715
|
+
let hi = yMax ?? 0;
|
|
1716
|
+
for (const s of series) {
|
|
1717
|
+
for (const d of data) {
|
|
1718
|
+
const v = toNum(d[s.dataKey]);
|
|
1719
|
+
if (v > hi && yMax == null) hi = v;
|
|
1720
|
+
if (v < lo) lo = v;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
if (hi === lo) hi = lo + 1;
|
|
1724
|
+
return { minV: lo, maxV: yMax != null ? yMax : hi * 1.08 };
|
|
1725
|
+
}, [series, data, yMax]);
|
|
1726
|
+
const ticks = (0, import_react8.useMemo)(() => niceTicks(minV, maxV, 4), [minV, maxV]);
|
|
1727
|
+
if (data.length === 0 || series.length === 0) {
|
|
1728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartEmpty, { className, height });
|
|
1597
1729
|
}
|
|
1598
|
-
const
|
|
1599
|
-
const innerH = H - PAD.top - PAD.bottom;
|
|
1600
|
-
const all = dataKeys.flatMap((k) => data.map((d) => toNum(d[k])));
|
|
1601
|
-
const maxV = Math.max(0, ...all);
|
|
1602
|
-
const minV = Math.min(0, ...all);
|
|
1603
|
-
const range = maxV - minV || 1;
|
|
1604
|
-
const yScale = (v) => PAD.top + innerH - (v - minV) / range * innerH;
|
|
1730
|
+
const yScale = (v) => pad.top + innerH - (v - minV) / (maxV - minV || 1) * innerH;
|
|
1605
1731
|
const xCount = data.length;
|
|
1606
1732
|
const xStep = xCount > 1 ? innerW / (xCount - 1) : innerW;
|
|
1607
|
-
const xPos = (i) =>
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1733
|
+
const xPos = (i) => variant === "bar" ? pad.left + innerW * (i + 0.5) / xCount : pad.left + i * xStep;
|
|
1734
|
+
const baseY = yScale(Math.max(0, minV));
|
|
1735
|
+
const fmtV = (v) => formatValue ? formatValue(v) : formatCompact(v, unit);
|
|
1736
|
+
const fmtX = (i) => formatX ? formatX(data[i]?.[xKey], i) : String(data[i]?.[xKey] ?? i);
|
|
1737
|
+
const onMove = (event) => {
|
|
1738
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1739
|
+
const px2 = event.clientX - rect.left - pad.left;
|
|
1740
|
+
const i = Math.round(px2 / (xStep || 1));
|
|
1741
|
+
setActive(Math.max(0, Math.min(xCount - 1, i)));
|
|
1742
|
+
};
|
|
1743
|
+
const labelIdx = pickXLabels(xCount, innerW);
|
|
1744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref, className: cn("relative w-full", className), style: { height }, children: [
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1746
|
+
"svg",
|
|
1747
|
+
{
|
|
1748
|
+
width,
|
|
1749
|
+
height,
|
|
1750
|
+
role: "img",
|
|
1751
|
+
"aria-label": ariaLabel,
|
|
1752
|
+
className: "block overflow-visible",
|
|
1753
|
+
children: [
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("defs", { children: [
|
|
1755
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("clipPath", { id: `${uid}-grow`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1756
|
+
"rect",
|
|
1757
|
+
{
|
|
1758
|
+
x: pad.left,
|
|
1759
|
+
y: 0,
|
|
1760
|
+
height,
|
|
1761
|
+
width: grown ? innerW : 0,
|
|
1762
|
+
style: { transition: "width 900ms cubic-bezier(0.22,1,0.36,1)" }
|
|
1763
|
+
}
|
|
1764
|
+
) }),
|
|
1765
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("linearGradient", { id: `${uid}-gridfade`, x1: "0%", x2: "100%", y1: "0", y2: "0", children: [
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "0%", stopColor: "white", stopOpacity: 0 }),
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "8%", stopColor: "white", stopOpacity: 1 }),
|
|
1768
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "92%", stopColor: "white", stopOpacity: 1 }),
|
|
1769
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "100%", stopColor: "white", stopOpacity: 0 })
|
|
1770
|
+
] }),
|
|
1771
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("mask", { id: `${uid}-gridmask`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1772
|
+
"rect",
|
|
1773
|
+
{
|
|
1774
|
+
x: pad.left,
|
|
1775
|
+
y: pad.top,
|
|
1776
|
+
width: innerW,
|
|
1777
|
+
height: innerH,
|
|
1778
|
+
fill: `url(#${uid}-gridfade)`
|
|
1779
|
+
}
|
|
1780
|
+
) }),
|
|
1781
|
+
series.map((s, i) => {
|
|
1782
|
+
const color = s.color ?? CHART_PALETTE[i % CHART_PALETTE.length];
|
|
1783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1784
|
+
"linearGradient",
|
|
1785
|
+
{
|
|
1786
|
+
id: `${uid}-fill-${i}`,
|
|
1787
|
+
x1: "0",
|
|
1788
|
+
x2: "0",
|
|
1789
|
+
y1: "0",
|
|
1790
|
+
y2: "1",
|
|
1791
|
+
children: [
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "0%", style: { stopColor: color, stopOpacity: 0.28 } }),
|
|
1793
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "100%", style: { stopColor: color, stopOpacity: 0 } })
|
|
1794
|
+
]
|
|
1795
|
+
},
|
|
1796
|
+
s.dataKey
|
|
1797
|
+
);
|
|
1798
|
+
})
|
|
1799
|
+
] }),
|
|
1800
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { mask: `url(#${uid}-gridmask)`, children: ticks.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1619
1801
|
"line",
|
|
1620
1802
|
{
|
|
1621
|
-
x1:
|
|
1622
|
-
x2:
|
|
1803
|
+
x1: pad.left,
|
|
1804
|
+
x2: width - pad.right,
|
|
1623
1805
|
y1: yScale(t),
|
|
1624
1806
|
y2: yScale(t),
|
|
1625
1807
|
stroke: "currentColor",
|
|
1626
|
-
strokeOpacity: 0.
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1808
|
+
strokeOpacity: 0.14,
|
|
1809
|
+
strokeDasharray: "4 4",
|
|
1810
|
+
className: "text-muted-foreground"
|
|
1811
|
+
},
|
|
1812
|
+
i
|
|
1813
|
+
)) }),
|
|
1814
|
+
showYAxis && ticks.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1630
1815
|
"text",
|
|
1631
1816
|
{
|
|
1632
|
-
x:
|
|
1817
|
+
x: pad.left - 8,
|
|
1633
1818
|
y: yScale(t),
|
|
1634
1819
|
textAnchor: "end",
|
|
1635
1820
|
dominantBaseline: "middle",
|
|
1636
|
-
className: "fill-muted-foreground text-[10px]",
|
|
1637
|
-
children:
|
|
1821
|
+
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
1822
|
+
children: fmtV(t)
|
|
1823
|
+
},
|
|
1824
|
+
i
|
|
1825
|
+
)),
|
|
1826
|
+
showXAxis && labelIdx.map((i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1827
|
+
"text",
|
|
1828
|
+
{
|
|
1829
|
+
x: xPos(i),
|
|
1830
|
+
y: height - pad.bottom + 16,
|
|
1831
|
+
textAnchor: i === 0 ? "start" : i === xCount - 1 ? "end" : "middle",
|
|
1832
|
+
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
1833
|
+
children: fmtX(i)
|
|
1834
|
+
},
|
|
1835
|
+
i
|
|
1836
|
+
)),
|
|
1837
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { clipPath: `url(#${uid}-grow)`, children: variant === "bar" ? renderBars({ data, series, xCount, xPos, yScale, baseY, innerW, uid }) : series.map((s, si) => {
|
|
1838
|
+
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1839
|
+
const pts = data.map((d, i) => ({
|
|
1840
|
+
x: xPos(i),
|
|
1841
|
+
y: yScale(toNum(d[s.dataKey]))
|
|
1842
|
+
}));
|
|
1843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { children: [
|
|
1844
|
+
variant === "area" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: monotoneAreaPath(pts, baseY), fill: `url(#${uid}-fill-${si})` }),
|
|
1845
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1846
|
+
"path",
|
|
1847
|
+
{
|
|
1848
|
+
d: monotoneLinePath(pts),
|
|
1849
|
+
fill: "none",
|
|
1850
|
+
stroke: color,
|
|
1851
|
+
strokeWidth: 2,
|
|
1852
|
+
strokeLinecap: "round",
|
|
1853
|
+
strokeLinejoin: "round"
|
|
1854
|
+
}
|
|
1855
|
+
)
|
|
1856
|
+
] }, s.dataKey);
|
|
1857
|
+
}) }),
|
|
1858
|
+
showTooltip && active != null && variant !== "bar" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { pointerEvents: "none", children: [
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1860
|
+
"line",
|
|
1861
|
+
{
|
|
1862
|
+
x1: xPos(active),
|
|
1863
|
+
x2: xPos(active),
|
|
1864
|
+
y1: pad.top,
|
|
1865
|
+
y2: pad.top + innerH,
|
|
1866
|
+
stroke: "currentColor",
|
|
1867
|
+
strokeOpacity: 0.25,
|
|
1868
|
+
className: "text-foreground"
|
|
1869
|
+
}
|
|
1870
|
+
),
|
|
1871
|
+
series.map((s, si) => {
|
|
1872
|
+
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1874
|
+
"circle",
|
|
1875
|
+
{
|
|
1876
|
+
cx: xPos(active),
|
|
1877
|
+
cy: yScale(toNum(data[active]?.[s.dataKey])),
|
|
1878
|
+
r: 4,
|
|
1879
|
+
fill: color,
|
|
1880
|
+
stroke: "var(--background, #fff)",
|
|
1881
|
+
strokeWidth: 2
|
|
1882
|
+
},
|
|
1883
|
+
s.dataKey
|
|
1884
|
+
);
|
|
1885
|
+
})
|
|
1886
|
+
] }),
|
|
1887
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1888
|
+
"rect",
|
|
1889
|
+
{
|
|
1890
|
+
x: pad.left,
|
|
1891
|
+
y: pad.top,
|
|
1892
|
+
width: innerW,
|
|
1893
|
+
height: innerH,
|
|
1894
|
+
fill: "transparent",
|
|
1895
|
+
style: { cursor: "crosshair" },
|
|
1896
|
+
onMouseMove: onMove,
|
|
1897
|
+
onMouseLeave: () => setActive(null)
|
|
1638
1898
|
}
|
|
1639
1899
|
)
|
|
1640
|
-
]
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
xPos,
|
|
1659
|
-
yScale,
|
|
1660
|
-
color: COLORS[ki % COLORS.length]
|
|
1661
|
-
},
|
|
1662
|
-
k
|
|
1663
|
-
)),
|
|
1664
|
-
chartType === "area" && dataKeys.map((k, ki) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1665
|
-
Area,
|
|
1666
|
-
{
|
|
1667
|
-
data,
|
|
1668
|
-
dataKey: k,
|
|
1669
|
-
xPos,
|
|
1670
|
-
yScale,
|
|
1671
|
-
baseY: yScale(Math.max(0, minV)),
|
|
1672
|
-
color: COLORS[ki % COLORS.length]
|
|
1673
|
-
},
|
|
1674
|
-
k
|
|
1675
|
-
))
|
|
1676
|
-
]
|
|
1677
|
-
}
|
|
1678
|
-
);
|
|
1900
|
+
]
|
|
1901
|
+
}
|
|
1902
|
+
),
|
|
1903
|
+
showTooltip && active != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1904
|
+
ChartTooltip,
|
|
1905
|
+
{
|
|
1906
|
+
x: xPos(active),
|
|
1907
|
+
width,
|
|
1908
|
+
title: fmtX(active),
|
|
1909
|
+
rows: series.map((s, si) => ({
|
|
1910
|
+
color: s.color ?? CHART_PALETTE[si % CHART_PALETTE.length],
|
|
1911
|
+
label: s.label ?? s.dataKey,
|
|
1912
|
+
value: fmtV(toNum(data[active]?.[s.dataKey]))
|
|
1913
|
+
}))
|
|
1914
|
+
}
|
|
1915
|
+
),
|
|
1916
|
+
showLegend ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartLegend, { series }) : null
|
|
1917
|
+
] });
|
|
1679
1918
|
};
|
|
1680
1919
|
function renderBars(args) {
|
|
1681
|
-
const { data,
|
|
1682
|
-
const groupWidth = innerW / xCount * 0.
|
|
1683
|
-
const barWidth = groupWidth /
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
const
|
|
1688
|
-
const
|
|
1689
|
-
const x = xPos(i) - groupWidth / 2 + ki * barWidth;
|
|
1920
|
+
const { data, series, xCount, xPos, yScale, baseY, innerW } = args;
|
|
1921
|
+
const groupWidth = innerW / xCount * 0.66;
|
|
1922
|
+
const barWidth = groupWidth / series.length;
|
|
1923
|
+
return series.flatMap(
|
|
1924
|
+
(s, si) => data.map((d, i) => {
|
|
1925
|
+
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1926
|
+
const y = yScale(toNum(d[s.dataKey]));
|
|
1927
|
+
const x = xPos(i) - groupWidth / 2 + si * barWidth;
|
|
1690
1928
|
const top = Math.min(y, baseY);
|
|
1691
|
-
const
|
|
1692
|
-
return /* @__PURE__ */ (0,
|
|
1929
|
+
const h = Math.max(1, Math.abs(y - baseY));
|
|
1930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1693
1931
|
"rect",
|
|
1694
1932
|
{
|
|
1695
1933
|
x,
|
|
1696
1934
|
y: top,
|
|
1697
1935
|
width: Math.max(1, barWidth - 2),
|
|
1698
|
-
height:
|
|
1699
|
-
rx:
|
|
1700
|
-
fill:
|
|
1936
|
+
height: h,
|
|
1937
|
+
rx: 3,
|
|
1938
|
+
fill: color
|
|
1701
1939
|
},
|
|
1702
|
-
`${
|
|
1940
|
+
`${s.dataKey}-${i}`
|
|
1703
1941
|
);
|
|
1704
1942
|
})
|
|
1705
1943
|
);
|
|
1706
1944
|
}
|
|
1707
|
-
var
|
|
1708
|
-
const
|
|
1709
|
-
return /* @__PURE__ */ (0,
|
|
1710
|
-
"
|
|
1945
|
+
var ChartTooltip = ({ x, width, title, rows }) => {
|
|
1946
|
+
const flip = x > width - 160;
|
|
1947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1948
|
+
"div",
|
|
1711
1949
|
{
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1950
|
+
className: "pointer-events-none absolute top-2 z-10 min-w-[8rem] rounded-lg border border-border bg-popover/95 px-2.5 py-2 text-popover-foreground shadow-card-elevated backdrop-blur-sm",
|
|
1951
|
+
style: {
|
|
1952
|
+
left: flip ? void 0 : Math.min(x + 12, width - 8),
|
|
1953
|
+
right: flip ? Math.max(width - x + 12, 8) : void 0
|
|
1954
|
+
},
|
|
1955
|
+
children: [
|
|
1956
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mb-1.5 text-[11px] text-muted-foreground", children: title }),
|
|
1957
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
1959
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1960
|
+
"span",
|
|
1961
|
+
{
|
|
1962
|
+
className: "inline-block size-2 rounded-full",
|
|
1963
|
+
style: { background: r.color }
|
|
1964
|
+
}
|
|
1965
|
+
),
|
|
1966
|
+
r.label
|
|
1967
|
+
] }),
|
|
1968
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium tabular-nums text-foreground", children: r.value })
|
|
1969
|
+
] }, r.label)) })
|
|
1970
|
+
]
|
|
1718
1971
|
}
|
|
1719
1972
|
);
|
|
1720
1973
|
};
|
|
1721
|
-
var
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1974
|
+
var ChartLegend = ({ series }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 pl-10 text-xs text-muted-foreground", children: series.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
1975
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1976
|
+
"span",
|
|
1977
|
+
{
|
|
1978
|
+
className: "inline-block size-2 rounded-sm",
|
|
1979
|
+
style: { background: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length] }
|
|
1980
|
+
}
|
|
1981
|
+
),
|
|
1982
|
+
s.label ?? s.dataKey
|
|
1983
|
+
] }, s.dataKey)) });
|
|
1984
|
+
var ChartEmpty = ({ className, height }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1985
|
+
"div",
|
|
1986
|
+
{
|
|
1987
|
+
className: cn(
|
|
1988
|
+
"flex w-full items-center justify-center text-xs text-muted-foreground",
|
|
1989
|
+
className
|
|
1990
|
+
),
|
|
1991
|
+
style: { height },
|
|
1992
|
+
children: "No data yet"
|
|
1993
|
+
}
|
|
1994
|
+
);
|
|
1995
|
+
function inferXKey(data) {
|
|
1996
|
+
if (data.length === 0) return "x";
|
|
1997
|
+
for (const k of Object.keys(data[0])) {
|
|
1998
|
+
if (typeof data[0][k] !== "number") return k;
|
|
1999
|
+
}
|
|
2000
|
+
return Object.keys(data[0])[0] ?? "x";
|
|
2001
|
+
}
|
|
2002
|
+
function resolveSeries(seriesProp, data, xKey) {
|
|
2003
|
+
if (seriesProp && seriesProp.length > 0) {
|
|
2004
|
+
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
2005
|
+
}
|
|
2006
|
+
if (data.length === 0) return [];
|
|
2007
|
+
return Object.keys(data[0]).filter((k) => k !== xKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2008
|
+
}
|
|
2009
|
+
function pickXLabels(count, innerW) {
|
|
2010
|
+
if (count <= 1) return [0];
|
|
2011
|
+
const maxLabels = Math.max(2, Math.min(count, Math.floor(innerW / 64) + 1));
|
|
2012
|
+
if (maxLabels >= count) return Array.from({ length: count }, (_, i) => i);
|
|
2013
|
+
const out = /* @__PURE__ */ new Set([0, count - 1]);
|
|
2014
|
+
const step = (count - 1) / (maxLabels - 1);
|
|
2015
|
+
for (let i = 1; i < maxLabels - 1; i++) out.add(Math.round(i * step));
|
|
2016
|
+
return [...out].sort((a, b) => a - b);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
// src/artifacts/artifact-card.tsx
|
|
2020
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2021
|
+
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
2022
|
+
const hasHeader = Boolean(title || toolbar);
|
|
2023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2024
|
+
"div",
|
|
2025
|
+
{
|
|
2026
|
+
className: cn(
|
|
2027
|
+
"aui-artifact-root my-3 overflow-hidden rounded-xl border border-border/60 bg-background shadow-sm",
|
|
2028
|
+
className
|
|
2029
|
+
),
|
|
2030
|
+
"data-artifact-kind": kind,
|
|
2031
|
+
children: [
|
|
2032
|
+
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "aui-artifact-header flex items-center gap-2 border-b border-border/40 bg-muted/30 px-3 py-1.5", children: [
|
|
2033
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
2034
|
+
!title && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "flex-1" }),
|
|
2035
|
+
toolbar
|
|
2036
|
+
] }),
|
|
2037
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
2038
|
+
]
|
|
2039
|
+
}
|
|
2040
|
+
);
|
|
1729
2041
|
};
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
2042
|
+
|
|
2043
|
+
// src/artifacts/chart-artifact.tsx
|
|
2044
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2045
|
+
var ChartArtifactView = ({
|
|
2046
|
+
artifact,
|
|
2047
|
+
embedded = false,
|
|
2048
|
+
height = 300
|
|
2049
|
+
}) => {
|
|
2050
|
+
const plot = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChartArtifactPlot, { artifact, height });
|
|
2051
|
+
if (embedded) {
|
|
2052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
2053
|
+
}
|
|
2054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
2055
|
+
};
|
|
2056
|
+
function ChartArtifactPlot({
|
|
2057
|
+
artifact,
|
|
2058
|
+
height
|
|
2059
|
+
}) {
|
|
2060
|
+
const { chartType = "bar", data = [] } = artifact;
|
|
2061
|
+
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
2062
|
+
const series = (0, import_react9.useMemo)(() => {
|
|
2063
|
+
const keys = Array.isArray(artifact.dataKey) ? artifact.dataKey : typeof artifact.dataKey === "string" ? [artifact.dataKey] : inferDataKeys(data, xKey);
|
|
2064
|
+
return keys.map((dataKey) => ({ dataKey }));
|
|
2065
|
+
}, [artifact.dataKey, data, xKey]);
|
|
2066
|
+
if (chartType === "pie") {
|
|
2067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PieChart, { data, xKey, dataKey: series[0]?.dataKey ?? "value" }) });
|
|
2068
|
+
}
|
|
2069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2070
|
+
LineAreaChart,
|
|
1738
2071
|
{
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
const end = acc / total * Math.PI * 2;
|
|
1748
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1749
|
-
PieSlice,
|
|
1750
|
-
{
|
|
1751
|
-
cx,
|
|
1752
|
-
cy,
|
|
1753
|
-
r,
|
|
1754
|
-
start,
|
|
1755
|
-
end,
|
|
1756
|
-
color: COLORS[i % COLORS.length],
|
|
1757
|
-
label: String(d[xKey] ?? i)
|
|
1758
|
-
},
|
|
1759
|
-
i
|
|
1760
|
-
);
|
|
1761
|
-
})
|
|
2072
|
+
data,
|
|
2073
|
+
xKey,
|
|
2074
|
+
series,
|
|
2075
|
+
layout: "flush",
|
|
2076
|
+
height,
|
|
2077
|
+
variant: chartType === "line" ? "line" : chartType === "area" ? "area" : "bar",
|
|
2078
|
+
unit: artifact.unit,
|
|
2079
|
+
ariaLabel: typeof artifact.title === "string" ? artifact.title : "Chart"
|
|
1762
2080
|
}
|
|
1763
2081
|
);
|
|
2082
|
+
}
|
|
2083
|
+
var PIE_W = 320;
|
|
2084
|
+
var PIE_H = 220;
|
|
2085
|
+
var PieChart = ({ data, xKey, dataKey }) => {
|
|
2086
|
+
if (data.length === 0) {
|
|
2087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex h-32 items-center justify-center text-xs text-muted-foreground", children: "No data" });
|
|
2088
|
+
}
|
|
2089
|
+
const cx = PIE_W / 2;
|
|
2090
|
+
const cy = PIE_H / 2;
|
|
2091
|
+
const r = Math.min(PIE_W, PIE_H) / 2 - 16;
|
|
2092
|
+
const total = data.reduce((sum, d) => sum + toNum(d[dataKey]), 0) || 1;
|
|
2093
|
+
let acc = 0;
|
|
2094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
2095
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2096
|
+
"svg",
|
|
2097
|
+
{
|
|
2098
|
+
viewBox: `0 0 ${PIE_W} ${PIE_H}`,
|
|
2099
|
+
className: "w-full max-w-[20rem]",
|
|
2100
|
+
role: "img",
|
|
2101
|
+
"aria-label": "Pie chart",
|
|
2102
|
+
children: data.map((d, i) => {
|
|
2103
|
+
const value = toNum(d[dataKey]);
|
|
2104
|
+
const start = acc / total * Math.PI * 2;
|
|
2105
|
+
acc += value;
|
|
2106
|
+
const end = acc / total * Math.PI * 2;
|
|
2107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2108
|
+
PieSlice,
|
|
2109
|
+
{
|
|
2110
|
+
cx,
|
|
2111
|
+
cy,
|
|
2112
|
+
r,
|
|
2113
|
+
start,
|
|
2114
|
+
end,
|
|
2115
|
+
color: CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2116
|
+
},
|
|
2117
|
+
i
|
|
2118
|
+
);
|
|
2119
|
+
})
|
|
2120
|
+
}
|
|
2121
|
+
),
|
|
2122
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("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__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2123
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2124
|
+
"span",
|
|
2125
|
+
{
|
|
2126
|
+
className: "inline-block size-2 rounded-sm",
|
|
2127
|
+
style: { background: CHART_PALETTE[i % CHART_PALETTE.length] }
|
|
2128
|
+
}
|
|
2129
|
+
),
|
|
2130
|
+
String(d[xKey] ?? i)
|
|
2131
|
+
] }, i)) })
|
|
2132
|
+
] });
|
|
1764
2133
|
};
|
|
1765
|
-
var PieSlice = ({ cx, cy, r, start, end, color
|
|
2134
|
+
var PieSlice = ({ cx, cy, r, start, end, color }) => {
|
|
1766
2135
|
const x1 = cx + Math.sin(start) * r;
|
|
1767
2136
|
const y1 = cy - Math.cos(start) * r;
|
|
1768
2137
|
const x2 = cx + Math.sin(end) * r;
|
|
1769
2138
|
const y2 = cy - Math.cos(end) * r;
|
|
1770
2139
|
const large = end - start > Math.PI ? 1 : 0;
|
|
1771
2140
|
const path = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
1772
|
-
|
|
1773
|
-
const lx = cx + Math.sin(mid) * (r * 0.65);
|
|
1774
|
-
const ly = cy - Math.cos(mid) * (r * 0.65);
|
|
1775
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { children: [
|
|
1776
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1 }),
|
|
1777
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1778
|
-
"text",
|
|
1779
|
-
{
|
|
1780
|
-
x: lx,
|
|
1781
|
-
y: ly,
|
|
1782
|
-
textAnchor: "middle",
|
|
1783
|
-
dominantBaseline: "middle",
|
|
1784
|
-
className: "fill-white text-[10px] font-semibold",
|
|
1785
|
-
children: label
|
|
1786
|
-
}
|
|
1787
|
-
)
|
|
1788
|
-
] });
|
|
2141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1.5 });
|
|
1789
2142
|
};
|
|
1790
|
-
|
|
1791
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1792
|
-
"span",
|
|
1793
|
-
{
|
|
1794
|
-
className: "inline-block size-2 rounded-sm",
|
|
1795
|
-
style: { background: COLORS[i % COLORS.length] },
|
|
1796
|
-
"aria-hidden": true
|
|
1797
|
-
}
|
|
1798
|
-
),
|
|
1799
|
-
k
|
|
1800
|
-
] }, k)) });
|
|
1801
|
-
var EmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "aui-artifact-chart-empty flex h-32 items-center justify-center text-xs text-muted-foreground", children: "No data" });
|
|
1802
|
-
function inferXKey(data) {
|
|
2143
|
+
function inferXKey2(data) {
|
|
1803
2144
|
if (data.length === 0) return "x";
|
|
1804
2145
|
for (const k of Object.keys(data[0])) {
|
|
1805
2146
|
if (typeof data[0][k] !== "number") return k;
|
|
@@ -1812,41 +2153,10 @@ function inferDataKeys(data, xKey) {
|
|
|
1812
2153
|
(k) => k !== xKey && typeof data[0][k] === "number"
|
|
1813
2154
|
);
|
|
1814
2155
|
}
|
|
1815
|
-
function toNum(value) {
|
|
1816
|
-
const n = typeof value === "number" ? value : Number(value);
|
|
1817
|
-
return Number.isFinite(n) ? n : 0;
|
|
1818
|
-
}
|
|
1819
|
-
function niceTicks(min, max, count = 4) {
|
|
1820
|
-
if (max === min) return [min];
|
|
1821
|
-
const range = max - min;
|
|
1822
|
-
const step = niceStep(range / count);
|
|
1823
|
-
const start = Math.floor(min / step) * step;
|
|
1824
|
-
const out = [];
|
|
1825
|
-
for (let v = start; v <= max + step / 2; v += step) {
|
|
1826
|
-
out.push(round(v));
|
|
1827
|
-
}
|
|
1828
|
-
return out;
|
|
1829
|
-
}
|
|
1830
|
-
function niceStep(raw) {
|
|
1831
|
-
const exp = Math.floor(Math.log10(Math.abs(raw))) || 0;
|
|
1832
|
-
const base = Math.pow(10, exp);
|
|
1833
|
-
const norm = raw / base;
|
|
1834
|
-
let nice = 1;
|
|
1835
|
-
if (norm >= 5) nice = 5;
|
|
1836
|
-
else if (norm >= 2) nice = 2;
|
|
1837
|
-
return nice * base;
|
|
1838
|
-
}
|
|
1839
|
-
function round(v) {
|
|
1840
|
-
return Math.round(v * 1e6) / 1e6;
|
|
1841
|
-
}
|
|
1842
|
-
function formatTick(v, unit) {
|
|
1843
|
-
const s = Math.abs(v) >= 1e3 ? `${(v / 1e3).toFixed(1)}k` : String(round(v));
|
|
1844
|
-
return unit ? `${s}${unit}` : s;
|
|
1845
|
-
}
|
|
1846
2156
|
|
|
1847
2157
|
// src/artifacts/question-artifact.tsx
|
|
1848
|
-
var
|
|
1849
|
-
var
|
|
2158
|
+
var import_react10 = require("react");
|
|
2159
|
+
var import_react11 = require("@assistant-ui/react");
|
|
1850
2160
|
var import_lucide_react3 = require("lucide-react");
|
|
1851
2161
|
|
|
1852
2162
|
// src/design/classes.ts
|
|
@@ -1961,12 +2271,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
1961
2271
|
);
|
|
1962
2272
|
|
|
1963
2273
|
// src/artifacts/question-artifact.tsx
|
|
1964
|
-
var
|
|
2274
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1965
2275
|
function optionKey(option, index) {
|
|
1966
2276
|
const id = option.id?.trim();
|
|
1967
2277
|
return id ? id : `__option-${index}`;
|
|
1968
2278
|
}
|
|
1969
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0,
|
|
2279
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1970
2280
|
"span",
|
|
1971
2281
|
{
|
|
1972
2282
|
className: cn(
|
|
@@ -1974,18 +2284,18 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx
|
|
|
1974
2284
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
1975
2285
|
),
|
|
1976
2286
|
"aria-hidden": true,
|
|
1977
|
-
children: selected ? /* @__PURE__ */ (0,
|
|
2287
|
+
children: selected ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
1978
2288
|
}
|
|
1979
2289
|
);
|
|
1980
2290
|
var QuestionArtifactView = ({
|
|
1981
2291
|
artifact
|
|
1982
2292
|
}) => {
|
|
1983
|
-
const runtime = (0,
|
|
1984
|
-
const [selected, setSelected] = (0,
|
|
1985
|
-
const [submittedIds, setSubmittedIds] = (0,
|
|
2293
|
+
const runtime = (0, import_react11.useThreadRuntime)();
|
|
2294
|
+
const [selected, setSelected] = (0, import_react10.useState)([]);
|
|
2295
|
+
const [submittedIds, setSubmittedIds] = (0, import_react10.useState)(null);
|
|
1986
2296
|
const isMulti = artifact.multi === true;
|
|
1987
2297
|
const isDisabled = submittedIds !== null;
|
|
1988
|
-
const send = (0,
|
|
2298
|
+
const send = (0, import_react10.useCallback)(
|
|
1989
2299
|
(keys) => {
|
|
1990
2300
|
if (keys.length === 0) return;
|
|
1991
2301
|
const labels = artifact.options.map((option, index) => ({ option, key: optionKey(option, index) })).filter(({ key }) => keys.includes(key)).map(({ option }) => option.label);
|
|
@@ -1997,7 +2307,7 @@ var QuestionArtifactView = ({
|
|
|
1997
2307
|
},
|
|
1998
2308
|
[artifact.options, runtime]
|
|
1999
2309
|
);
|
|
2000
|
-
const onPick = (0,
|
|
2310
|
+
const onPick = (0, import_react10.useCallback)(
|
|
2001
2311
|
(key) => {
|
|
2002
2312
|
if (isDisabled) return;
|
|
2003
2313
|
if (!isMulti) {
|
|
@@ -2010,15 +2320,15 @@ var QuestionArtifactView = ({
|
|
|
2010
2320
|
},
|
|
2011
2321
|
[isDisabled, isMulti, send]
|
|
2012
2322
|
);
|
|
2013
|
-
const onConfirm = (0,
|
|
2323
|
+
const onConfirm = (0, import_react10.useCallback)(() => {
|
|
2014
2324
|
send(selected);
|
|
2015
2325
|
}, [selected, send]);
|
|
2016
|
-
return /* @__PURE__ */ (0,
|
|
2017
|
-
artifact.prompt ? /* @__PURE__ */ (0,
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "px-2.5 py-2", children: [
|
|
2327
|
+
artifact.prompt ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
2328
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
2019
2329
|
const key = optionKey(option, index);
|
|
2020
2330
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
2021
|
-
return /* @__PURE__ */ (0,
|
|
2331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2022
2332
|
"button",
|
|
2023
2333
|
{
|
|
2024
2334
|
type: "button",
|
|
@@ -2030,17 +2340,17 @@ var QuestionArtifactView = ({
|
|
|
2030
2340
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
2031
2341
|
),
|
|
2032
2342
|
children: [
|
|
2033
|
-
/* @__PURE__ */ (0,
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
2035
|
-
/* @__PURE__ */ (0,
|
|
2036
|
-
option.description ? /* @__PURE__ */ (0,
|
|
2343
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OptionRadio, { selected: isSelected }),
|
|
2344
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
2345
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
2346
|
+
option.description ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
2037
2347
|
] })
|
|
2038
2348
|
]
|
|
2039
2349
|
},
|
|
2040
2350
|
key
|
|
2041
2351
|
);
|
|
2042
2352
|
}) }),
|
|
2043
|
-
isMulti && !submittedIds ? /* @__PURE__ */ (0,
|
|
2353
|
+
isMulti && !submittedIds ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2044
2354
|
TimbalV2Button,
|
|
2045
2355
|
{
|
|
2046
2356
|
type: "button",
|
|
@@ -2055,12 +2365,12 @@ var QuestionArtifactView = ({
|
|
|
2055
2365
|
};
|
|
2056
2366
|
|
|
2057
2367
|
// src/artifacts/html-artifact.tsx
|
|
2058
|
-
var
|
|
2368
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2059
2369
|
var HtmlArtifactView = ({ artifact }) => {
|
|
2060
2370
|
const sandboxed = artifact.sandboxed !== false;
|
|
2061
2371
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
2062
2372
|
const height = artifact.height ?? "320px";
|
|
2063
|
-
return /* @__PURE__ */ (0,
|
|
2373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2064
2374
|
"iframe",
|
|
2065
2375
|
{
|
|
2066
2376
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -2073,7 +2383,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
2073
2383
|
};
|
|
2074
2384
|
|
|
2075
2385
|
// src/artifacts/json-artifact.tsx
|
|
2076
|
-
var
|
|
2386
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2077
2387
|
var JsonArtifactView = ({
|
|
2078
2388
|
artifact
|
|
2079
2389
|
}) => {
|
|
@@ -2085,16 +2395,16 @@ var JsonArtifactView = ({
|
|
|
2085
2395
|
} catch {
|
|
2086
2396
|
body = String(data);
|
|
2087
2397
|
}
|
|
2088
|
-
return /* @__PURE__ */ (0,
|
|
2398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("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 }) });
|
|
2089
2399
|
};
|
|
2090
2400
|
|
|
2091
2401
|
// src/artifacts/table-artifact.tsx
|
|
2092
|
-
var
|
|
2402
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2093
2403
|
var TableArtifactView = ({ artifact }) => {
|
|
2094
2404
|
const rows = artifact.rows ?? [];
|
|
2095
2405
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
2096
|
-
return /* @__PURE__ */ (0,
|
|
2097
|
-
/* @__PURE__ */ (0,
|
|
2406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
2407
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2098
2408
|
"th",
|
|
2099
2409
|
{
|
|
2100
2410
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -2102,11 +2412,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
2102
2412
|
},
|
|
2103
2413
|
col.key
|
|
2104
2414
|
)) }) }),
|
|
2105
|
-
/* @__PURE__ */ (0,
|
|
2415
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tbody", { children: rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2106
2416
|
"tr",
|
|
2107
2417
|
{
|
|
2108
2418
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
2109
|
-
children: columns.map((col) => /* @__PURE__ */ (0,
|
|
2419
|
+
children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2110
2420
|
"td",
|
|
2111
2421
|
{
|
|
2112
2422
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -2139,7 +2449,7 @@ function formatCell(value) {
|
|
|
2139
2449
|
}
|
|
2140
2450
|
|
|
2141
2451
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2142
|
-
var
|
|
2452
|
+
var import_react16 = require("react");
|
|
2143
2453
|
|
|
2144
2454
|
// src/artifacts/ui/types.ts
|
|
2145
2455
|
function isUiBinding(value) {
|
|
@@ -2192,38 +2502,38 @@ function resolveBindable(value, state) {
|
|
|
2192
2502
|
}
|
|
2193
2503
|
|
|
2194
2504
|
// src/artifacts/ui/registry.tsx
|
|
2195
|
-
var
|
|
2196
|
-
var
|
|
2197
|
-
var UiStateContext = (0,
|
|
2198
|
-
var UiDispatchContext = (0,
|
|
2505
|
+
var import_react12 = require("react");
|
|
2506
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2507
|
+
var UiStateContext = (0, import_react12.createContext)({});
|
|
2508
|
+
var UiDispatchContext = (0, import_react12.createContext)(() => {
|
|
2199
2509
|
});
|
|
2200
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0,
|
|
2510
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
2201
2511
|
function useUiState() {
|
|
2202
|
-
return (0,
|
|
2512
|
+
return (0, import_react12.useContext)(UiStateContext);
|
|
2203
2513
|
}
|
|
2204
2514
|
function useUiDispatch() {
|
|
2205
|
-
return (0,
|
|
2515
|
+
return (0, import_react12.useContext)(UiDispatchContext);
|
|
2206
2516
|
}
|
|
2207
|
-
var UiEventContext = (0,
|
|
2517
|
+
var UiEventContext = (0, import_react12.createContext)(
|
|
2208
2518
|
null
|
|
2209
2519
|
);
|
|
2210
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0,
|
|
2520
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UiEventContext.Provider, { value: onEvent, children });
|
|
2211
2521
|
function useUiEventEmitter() {
|
|
2212
|
-
return (0,
|
|
2522
|
+
return (0, import_react12.useContext)(UiEventContext);
|
|
2213
2523
|
}
|
|
2214
|
-
var UiCustomNodeRegistryContext = (0,
|
|
2524
|
+
var UiCustomNodeRegistryContext = (0, import_react12.createContext)({});
|
|
2215
2525
|
function useUiCustomNodeRegistry() {
|
|
2216
|
-
return (0,
|
|
2526
|
+
return (0, import_react12.useContext)(UiCustomNodeRegistryContext);
|
|
2217
2527
|
}
|
|
2218
2528
|
|
|
2219
2529
|
// src/artifacts/ui/nodes.tsx
|
|
2220
|
-
var
|
|
2221
|
-
var
|
|
2222
|
-
var
|
|
2530
|
+
var import_react13 = require("react");
|
|
2531
|
+
var import_react14 = require("motion/react");
|
|
2532
|
+
var import_react15 = require("@assistant-ui/react");
|
|
2223
2533
|
|
|
2224
2534
|
// src/ui/button.tsx
|
|
2225
2535
|
var import_class_variance_authority = require("class-variance-authority");
|
|
2226
|
-
var
|
|
2536
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2227
2537
|
var LEGACY_SIZE_TO_V2 = {
|
|
2228
2538
|
default: "md",
|
|
2229
2539
|
xs: "xs",
|
|
@@ -2273,7 +2583,7 @@ function Button({
|
|
|
2273
2583
|
const v2Variant = TIMBAL_V2_FROM_LEGACY_BUTTON[variant ?? "default"];
|
|
2274
2584
|
const v2Size = LEGACY_SIZE_TO_V2[size ?? "default"];
|
|
2275
2585
|
const isIconOnly = typeof size === "string" && size.startsWith("icon");
|
|
2276
|
-
return /* @__PURE__ */ (0,
|
|
2586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2277
2587
|
TimbalV2Button,
|
|
2278
2588
|
{
|
|
2279
2589
|
"data-slot": "button",
|
|
@@ -2281,7 +2591,7 @@ function Button({
|
|
|
2281
2591
|
"data-size": size,
|
|
2282
2592
|
variant: v2Variant,
|
|
2283
2593
|
size: v2Size,
|
|
2284
|
-
shape: "
|
|
2594
|
+
shape: "pill",
|
|
2285
2595
|
isIconOnly,
|
|
2286
2596
|
asChild,
|
|
2287
2597
|
className: cn(buttonVariants({ variant, size, className })),
|
|
@@ -2291,29 +2601,29 @@ function Button({
|
|
|
2291
2601
|
}
|
|
2292
2602
|
|
|
2293
2603
|
// src/artifacts/ui/nodes.tsx
|
|
2294
|
-
var
|
|
2604
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2295
2605
|
var UiNodeView = ({ node }) => {
|
|
2296
2606
|
switch (node.kind) {
|
|
2297
2607
|
case "box":
|
|
2298
|
-
return /* @__PURE__ */ (0,
|
|
2608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BoxNode, { node });
|
|
2299
2609
|
case "text":
|
|
2300
|
-
return /* @__PURE__ */ (0,
|
|
2610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextNode, { node });
|
|
2301
2611
|
case "heading":
|
|
2302
|
-
return /* @__PURE__ */ (0,
|
|
2612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(HeadingNode, { node });
|
|
2303
2613
|
case "badge":
|
|
2304
|
-
return /* @__PURE__ */ (0,
|
|
2614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BadgeNode, { node });
|
|
2305
2615
|
case "button":
|
|
2306
|
-
return /* @__PURE__ */ (0,
|
|
2616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ButtonNode, { node });
|
|
2307
2617
|
case "toggle":
|
|
2308
|
-
return /* @__PURE__ */ (0,
|
|
2618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToggleNode, { node });
|
|
2309
2619
|
case "slider":
|
|
2310
|
-
return /* @__PURE__ */ (0,
|
|
2620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SliderNode, { node });
|
|
2311
2621
|
case "tooltip":
|
|
2312
|
-
return /* @__PURE__ */ (0,
|
|
2622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipNode, { node });
|
|
2313
2623
|
case "draggable":
|
|
2314
|
-
return /* @__PURE__ */ (0,
|
|
2624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DraggableNode, { node });
|
|
2315
2625
|
case "custom":
|
|
2316
|
-
return /* @__PURE__ */ (0,
|
|
2626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CustomNode, { node });
|
|
2317
2627
|
default:
|
|
2318
2628
|
return null;
|
|
2319
2629
|
}
|
|
@@ -2321,9 +2631,9 @@ var UiNodeView = ({ node }) => {
|
|
|
2321
2631
|
function useActionRunner() {
|
|
2322
2632
|
const state = useUiState();
|
|
2323
2633
|
const dispatch = useUiDispatch();
|
|
2324
|
-
const runtime = (0,
|
|
2634
|
+
const runtime = (0, import_react15.useThreadRuntime)();
|
|
2325
2635
|
const emit = useUiEventEmitter();
|
|
2326
|
-
return (0,
|
|
2636
|
+
return (0, import_react13.useCallback)(
|
|
2327
2637
|
(actions) => {
|
|
2328
2638
|
if (!actions) return;
|
|
2329
2639
|
const list = Array.isArray(actions) ? actions : [actions];
|
|
@@ -2373,7 +2683,7 @@ var JUSTIFY_CLS = {
|
|
|
2373
2683
|
};
|
|
2374
2684
|
var BoxNode = ({ node }) => {
|
|
2375
2685
|
const dir = node.direction ?? "col";
|
|
2376
|
-
return /* @__PURE__ */ (0,
|
|
2686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2377
2687
|
"div",
|
|
2378
2688
|
{
|
|
2379
2689
|
className: cn(
|
|
@@ -2388,7 +2698,7 @@ var BoxNode = ({ node }) => {
|
|
|
2388
2698
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
2389
2699
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
2390
2700
|
},
|
|
2391
|
-
children: node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2701
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: child }, child.id ?? i))
|
|
2392
2702
|
}
|
|
2393
2703
|
);
|
|
2394
2704
|
};
|
|
@@ -2407,7 +2717,7 @@ var TEXT_WEIGHT = {
|
|
|
2407
2717
|
var TextNode = ({ node }) => {
|
|
2408
2718
|
const state = useUiState();
|
|
2409
2719
|
const value = resolveBindable(node.value, state);
|
|
2410
|
-
return /* @__PURE__ */ (0,
|
|
2720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2411
2721
|
"span",
|
|
2412
2722
|
{
|
|
2413
2723
|
className: cn(
|
|
@@ -2438,13 +2748,13 @@ var HeadingNode = ({ node }) => {
|
|
|
2438
2748
|
);
|
|
2439
2749
|
switch (level) {
|
|
2440
2750
|
case 1:
|
|
2441
|
-
return /* @__PURE__ */ (0,
|
|
2751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h1", { className: cls, children: value });
|
|
2442
2752
|
case 2:
|
|
2443
|
-
return /* @__PURE__ */ (0,
|
|
2753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h2", { className: cls, children: value });
|
|
2444
2754
|
case 3:
|
|
2445
|
-
return /* @__PURE__ */ (0,
|
|
2755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h3", { className: cls, children: value });
|
|
2446
2756
|
case 4:
|
|
2447
|
-
return /* @__PURE__ */ (0,
|
|
2757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { className: cls, children: value });
|
|
2448
2758
|
}
|
|
2449
2759
|
};
|
|
2450
2760
|
var BADGE_TONE = {
|
|
@@ -2457,7 +2767,7 @@ var BADGE_TONE = {
|
|
|
2457
2767
|
var BadgeNode = ({ node }) => {
|
|
2458
2768
|
const state = useUiState();
|
|
2459
2769
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
2460
|
-
return /* @__PURE__ */ (0,
|
|
2770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2461
2771
|
"span",
|
|
2462
2772
|
{
|
|
2463
2773
|
className: cn(
|
|
@@ -2474,7 +2784,7 @@ var ButtonNode = ({ node }) => {
|
|
|
2474
2784
|
const run = useActionRunner();
|
|
2475
2785
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
2476
2786
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
2477
|
-
return /* @__PURE__ */ (0,
|
|
2787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2478
2788
|
Button,
|
|
2479
2789
|
{
|
|
2480
2790
|
variant: node.variant ?? "default",
|
|
@@ -2496,7 +2806,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2496
2806
|
dispatch({ type: "toggle", path: node.binding });
|
|
2497
2807
|
run(node.onChange);
|
|
2498
2808
|
};
|
|
2499
|
-
return /* @__PURE__ */ (0,
|
|
2809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2500
2810
|
"label",
|
|
2501
2811
|
{
|
|
2502
2812
|
className: cn(
|
|
@@ -2504,7 +2814,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2504
2814
|
node.className
|
|
2505
2815
|
),
|
|
2506
2816
|
children: [
|
|
2507
|
-
/* @__PURE__ */ (0,
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2508
2818
|
"button",
|
|
2509
2819
|
{
|
|
2510
2820
|
type: "button",
|
|
@@ -2515,7 +2825,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2515
2825
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
2516
2826
|
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")
|
|
2517
2827
|
),
|
|
2518
|
-
children: /* @__PURE__ */ (0,
|
|
2828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2519
2829
|
"span",
|
|
2520
2830
|
{
|
|
2521
2831
|
className: cn(
|
|
@@ -2528,7 +2838,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2528
2838
|
)
|
|
2529
2839
|
}
|
|
2530
2840
|
),
|
|
2531
|
-
label && /* @__PURE__ */ (0,
|
|
2841
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-foreground/85", children: label })
|
|
2532
2842
|
]
|
|
2533
2843
|
}
|
|
2534
2844
|
);
|
|
@@ -2548,12 +2858,12 @@ var SliderNode = ({ node }) => {
|
|
|
2548
2858
|
const next = Number(e.target.value);
|
|
2549
2859
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
2550
2860
|
};
|
|
2551
|
-
return /* @__PURE__ */ (0,
|
|
2552
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
2553
|
-
label && /* @__PURE__ */ (0,
|
|
2554
|
-
showValue && /* @__PURE__ */ (0,
|
|
2861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
2862
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
2863
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: label }),
|
|
2864
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "font-mono", children: value })
|
|
2555
2865
|
] }),
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2866
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2557
2867
|
"input",
|
|
2558
2868
|
{
|
|
2559
2869
|
type: "range",
|
|
@@ -2575,9 +2885,9 @@ var SliderNode = ({ node }) => {
|
|
|
2575
2885
|
var TooltipNode = ({ node }) => {
|
|
2576
2886
|
const state = useUiState();
|
|
2577
2887
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
2578
|
-
return /* @__PURE__ */ (0,
|
|
2579
|
-
/* @__PURE__ */ (0,
|
|
2580
|
-
/* @__PURE__ */ (0,
|
|
2888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Tooltip, { children: [
|
|
2889
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: node.child }) }) }),
|
|
2890
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipContent, { side: node.side ?? "top", children: content })
|
|
2581
2891
|
] }) });
|
|
2582
2892
|
};
|
|
2583
2893
|
var DraggableNode = ({ node }) => {
|
|
@@ -2585,8 +2895,8 @@ var DraggableNode = ({ node }) => {
|
|
|
2585
2895
|
const snapBack = node.snapBack ?? true;
|
|
2586
2896
|
const axis = node.axis ?? "both";
|
|
2587
2897
|
const dragProp = axis === "both" ? true : axis;
|
|
2588
|
-
return /* @__PURE__ */ (0,
|
|
2589
|
-
|
|
2898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2899
|
+
import_react14.motion.div,
|
|
2590
2900
|
{
|
|
2591
2901
|
drag: dragProp,
|
|
2592
2902
|
dragMomentum: false,
|
|
@@ -2597,7 +2907,7 @@ var DraggableNode = ({ node }) => {
|
|
|
2597
2907
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
2598
2908
|
node.className
|
|
2599
2909
|
),
|
|
2600
|
-
children: /* @__PURE__ */ (0,
|
|
2910
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: node.child })
|
|
2601
2911
|
}
|
|
2602
2912
|
);
|
|
2603
2913
|
};
|
|
@@ -2607,8 +2917,8 @@ var CustomNode = ({ node }) => {
|
|
|
2607
2917
|
const Renderer = registry[node.name];
|
|
2608
2918
|
if (!Renderer) return null;
|
|
2609
2919
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
2610
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2611
|
-
return /* @__PURE__ */ (0,
|
|
2920
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: child }, child.id ?? i));
|
|
2921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Renderer, { props: resolvedProps, children });
|
|
2612
2922
|
};
|
|
2613
2923
|
function resolveProps(props, state) {
|
|
2614
2924
|
const out = {};
|
|
@@ -2619,17 +2929,17 @@ function resolveProps(props, state) {
|
|
|
2619
2929
|
}
|
|
2620
2930
|
|
|
2621
2931
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2622
|
-
var
|
|
2932
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2623
2933
|
var UiArtifactView = ({ artifact }) => {
|
|
2624
|
-
const [state, dispatch] = (0,
|
|
2934
|
+
const [state, dispatch] = (0, import_react16.useReducer)(
|
|
2625
2935
|
uiStateReducer,
|
|
2626
2936
|
artifact.initialState ?? {}
|
|
2627
2937
|
);
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(UiNodeView, { node: artifact.root }) }) }) });
|
|
2629
2939
|
};
|
|
2630
2940
|
|
|
2631
2941
|
// src/artifacts/registry.tsx
|
|
2632
|
-
var
|
|
2942
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2633
2943
|
var defaultArtifactRenderers = {
|
|
2634
2944
|
chart: ChartArtifactView,
|
|
2635
2945
|
question: QuestionArtifactView,
|
|
@@ -2638,25 +2948,25 @@ var defaultArtifactRenderers = {
|
|
|
2638
2948
|
table: TableArtifactView,
|
|
2639
2949
|
ui: UiArtifactView
|
|
2640
2950
|
};
|
|
2641
|
-
var ArtifactRegistryContext = (0,
|
|
2951
|
+
var ArtifactRegistryContext = (0, import_react17.createContext)(
|
|
2642
2952
|
defaultArtifactRenderers
|
|
2643
2953
|
);
|
|
2644
2954
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
2645
|
-
const merged = (0,
|
|
2955
|
+
const merged = (0, import_react17.useMemo)(() => {
|
|
2646
2956
|
if (!renderers) return defaultArtifactRenderers;
|
|
2647
2957
|
if (override) return renderers;
|
|
2648
2958
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
2649
2959
|
}, [renderers, override]);
|
|
2650
|
-
return /* @__PURE__ */ (0,
|
|
2960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
2651
2961
|
};
|
|
2652
2962
|
function useArtifactRegistry() {
|
|
2653
|
-
return (0,
|
|
2963
|
+
return (0, import_react17.useContext)(ArtifactRegistryContext);
|
|
2654
2964
|
}
|
|
2655
2965
|
var ArtifactView = ({ artifact }) => {
|
|
2656
2966
|
const registry = useArtifactRegistry();
|
|
2657
2967
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
2658
2968
|
if (!Renderer) return null;
|
|
2659
|
-
return /* @__PURE__ */ (0,
|
|
2969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Renderer, { artifact });
|
|
2660
2970
|
};
|
|
2661
2971
|
|
|
2662
2972
|
// src/artifacts/parse.ts
|
|
@@ -2732,7 +3042,7 @@ var import_c = __toESM(require("shiki/langs/c.mjs"), 1);
|
|
|
2732
3042
|
var import_cpp = __toESM(require("shiki/langs/cpp.mjs"), 1);
|
|
2733
3043
|
var import_vitesse_dark = __toESM(require("shiki/themes/vitesse-dark.mjs"), 1);
|
|
2734
3044
|
var import_vitesse_light = __toESM(require("shiki/themes/vitesse-light.mjs"), 1);
|
|
2735
|
-
var
|
|
3045
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2736
3046
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
2737
3047
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
2738
3048
|
var highlighterPromise = null;
|
|
@@ -2770,8 +3080,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
2770
3080
|
language,
|
|
2771
3081
|
code
|
|
2772
3082
|
}) => {
|
|
2773
|
-
const [html, setHtml] = (0,
|
|
2774
|
-
(0,
|
|
3083
|
+
const [html, setHtml] = (0, import_react18.useState)(null);
|
|
3084
|
+
(0, import_react18.useEffect)(() => {
|
|
2775
3085
|
let cancelled = false;
|
|
2776
3086
|
(async () => {
|
|
2777
3087
|
try {
|
|
@@ -2801,13 +3111,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
2801
3111
|
try {
|
|
2802
3112
|
const parsed = JSON.parse(code);
|
|
2803
3113
|
if (isArtifact(parsed)) {
|
|
2804
|
-
return /* @__PURE__ */ (0,
|
|
3114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArtifactView, { artifact: parsed });
|
|
2805
3115
|
}
|
|
2806
3116
|
} catch {
|
|
2807
3117
|
}
|
|
2808
3118
|
}
|
|
2809
3119
|
if (html) {
|
|
2810
|
-
return /* @__PURE__ */ (0,
|
|
3120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2811
3121
|
"div",
|
|
2812
3122
|
{
|
|
2813
3123
|
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",
|
|
@@ -2815,14 +3125,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
2815
3125
|
}
|
|
2816
3126
|
);
|
|
2817
3127
|
}
|
|
2818
|
-
return /* @__PURE__ */ (0,
|
|
3128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Pre, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Code2, { children: code }) });
|
|
2819
3129
|
};
|
|
2820
3130
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
2821
3131
|
|
|
2822
3132
|
// src/chat/markdown-text.tsx
|
|
2823
|
-
var
|
|
3133
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2824
3134
|
var MarkdownTextImpl = () => {
|
|
2825
|
-
return /* @__PURE__ */ (0,
|
|
3135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2826
3136
|
import_react_markdown.MarkdownTextPrimitive,
|
|
2827
3137
|
{
|
|
2828
3138
|
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
@@ -2835,7 +3145,7 @@ var MarkdownTextImpl = () => {
|
|
|
2835
3145
|
}
|
|
2836
3146
|
);
|
|
2837
3147
|
};
|
|
2838
|
-
var MarkdownText = (0,
|
|
3148
|
+
var MarkdownText = (0, import_react19.memo)(MarkdownTextImpl);
|
|
2839
3149
|
var CodeHeader = ({ language, code }) => {
|
|
2840
3150
|
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
2841
3151
|
if (isArtifactFenceLanguage(language)) return null;
|
|
@@ -2843,20 +3153,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
2843
3153
|
if (!code || isCopied) return;
|
|
2844
3154
|
copyToClipboard(code);
|
|
2845
3155
|
};
|
|
2846
|
-
return /* @__PURE__ */ (0,
|
|
2847
|
-
/* @__PURE__ */ (0,
|
|
2848
|
-
/* @__PURE__ */ (0,
|
|
3156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("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: [
|
|
3157
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
3158
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
2849
3159
|
language
|
|
2850
3160
|
] }),
|
|
2851
|
-
/* @__PURE__ */ (0,
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2852
3162
|
TooltipIconButton,
|
|
2853
3163
|
{
|
|
2854
3164
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
2855
3165
|
onClick: onCopy,
|
|
2856
3166
|
className: "transition-colors hover:text-foreground",
|
|
2857
3167
|
children: [
|
|
2858
|
-
!isCopied && /* @__PURE__ */ (0,
|
|
2859
|
-
isCopied && /* @__PURE__ */ (0,
|
|
3168
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react4.CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
3169
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react4.CheckIcon, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
2860
3170
|
]
|
|
2861
3171
|
}
|
|
2862
3172
|
)
|
|
@@ -2865,7 +3175,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
2865
3175
|
var useCopyToClipboard = ({
|
|
2866
3176
|
copiedDuration = 3e3
|
|
2867
3177
|
} = {}) => {
|
|
2868
|
-
const [isCopied, setIsCopied] = (0,
|
|
3178
|
+
const [isCopied, setIsCopied] = (0, import_react19.useState)(false);
|
|
2869
3179
|
const copyToClipboard = (value) => {
|
|
2870
3180
|
if (!value) return;
|
|
2871
3181
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -2876,7 +3186,7 @@ var useCopyToClipboard = ({
|
|
|
2876
3186
|
return { isCopied, copyToClipboard };
|
|
2877
3187
|
};
|
|
2878
3188
|
var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownComponents)({
|
|
2879
|
-
h1: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3189
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2880
3190
|
"h1",
|
|
2881
3191
|
{
|
|
2882
3192
|
className: cn(
|
|
@@ -2886,7 +3196,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2886
3196
|
...props
|
|
2887
3197
|
}
|
|
2888
3198
|
),
|
|
2889
|
-
h2: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3199
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2890
3200
|
"h2",
|
|
2891
3201
|
{
|
|
2892
3202
|
className: cn(
|
|
@@ -2896,7 +3206,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2896
3206
|
...props
|
|
2897
3207
|
}
|
|
2898
3208
|
),
|
|
2899
|
-
h3: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3209
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2900
3210
|
"h3",
|
|
2901
3211
|
{
|
|
2902
3212
|
className: cn(
|
|
@@ -2906,7 +3216,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2906
3216
|
...props
|
|
2907
3217
|
}
|
|
2908
3218
|
),
|
|
2909
|
-
h4: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3219
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2910
3220
|
"h4",
|
|
2911
3221
|
{
|
|
2912
3222
|
className: cn(
|
|
@@ -2916,7 +3226,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2916
3226
|
...props
|
|
2917
3227
|
}
|
|
2918
3228
|
),
|
|
2919
|
-
h5: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3229
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2920
3230
|
"h5",
|
|
2921
3231
|
{
|
|
2922
3232
|
className: cn(
|
|
@@ -2926,7 +3236,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2926
3236
|
...props
|
|
2927
3237
|
}
|
|
2928
3238
|
),
|
|
2929
|
-
h6: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3239
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2930
3240
|
"h6",
|
|
2931
3241
|
{
|
|
2932
3242
|
className: cn(
|
|
@@ -2936,7 +3246,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2936
3246
|
...props
|
|
2937
3247
|
}
|
|
2938
3248
|
),
|
|
2939
|
-
p: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3249
|
+
p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2940
3250
|
"p",
|
|
2941
3251
|
{
|
|
2942
3252
|
className: cn(
|
|
@@ -2946,7 +3256,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2946
3256
|
...props
|
|
2947
3257
|
}
|
|
2948
3258
|
),
|
|
2949
|
-
a: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3259
|
+
a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2950
3260
|
"a",
|
|
2951
3261
|
{
|
|
2952
3262
|
className: cn(
|
|
@@ -2958,7 +3268,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2958
3268
|
...props
|
|
2959
3269
|
}
|
|
2960
3270
|
),
|
|
2961
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3271
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2962
3272
|
"blockquote",
|
|
2963
3273
|
{
|
|
2964
3274
|
className: cn(
|
|
@@ -2968,7 +3278,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2968
3278
|
...props
|
|
2969
3279
|
}
|
|
2970
3280
|
),
|
|
2971
|
-
ul: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3281
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2972
3282
|
"ul",
|
|
2973
3283
|
{
|
|
2974
3284
|
className: cn(
|
|
@@ -2978,7 +3288,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2978
3288
|
...props
|
|
2979
3289
|
}
|
|
2980
3290
|
),
|
|
2981
|
-
ol: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3291
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2982
3292
|
"ol",
|
|
2983
3293
|
{
|
|
2984
3294
|
className: cn(
|
|
@@ -2988,7 +3298,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2988
3298
|
...props
|
|
2989
3299
|
}
|
|
2990
3300
|
),
|
|
2991
|
-
hr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3301
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2992
3302
|
"hr",
|
|
2993
3303
|
{
|
|
2994
3304
|
className: cn(
|
|
@@ -2998,14 +3308,14 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2998
3308
|
...props
|
|
2999
3309
|
}
|
|
3000
3310
|
),
|
|
3001
|
-
table: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3311
|
+
table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3002
3312
|
"table",
|
|
3003
3313
|
{
|
|
3004
3314
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
3005
3315
|
...props
|
|
3006
3316
|
}
|
|
3007
3317
|
) }),
|
|
3008
|
-
th: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3318
|
+
th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3009
3319
|
"th",
|
|
3010
3320
|
{
|
|
3011
3321
|
className: cn(
|
|
@@ -3015,7 +3325,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3015
3325
|
...props
|
|
3016
3326
|
}
|
|
3017
3327
|
),
|
|
3018
|
-
td: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3328
|
+
td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3019
3329
|
"td",
|
|
3020
3330
|
{
|
|
3021
3331
|
className: cn(
|
|
@@ -3025,7 +3335,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3025
3335
|
...props
|
|
3026
3336
|
}
|
|
3027
3337
|
),
|
|
3028
|
-
tr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3338
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3029
3339
|
"tr",
|
|
3030
3340
|
{
|
|
3031
3341
|
className: cn(
|
|
@@ -3035,8 +3345,8 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3035
3345
|
...props
|
|
3036
3346
|
}
|
|
3037
3347
|
),
|
|
3038
|
-
li: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3039
|
-
sup: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3348
|
+
li: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
3349
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3040
3350
|
"sup",
|
|
3041
3351
|
{
|
|
3042
3352
|
className: cn(
|
|
@@ -3046,7 +3356,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3046
3356
|
...props
|
|
3047
3357
|
}
|
|
3048
3358
|
),
|
|
3049
|
-
pre: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3359
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3050
3360
|
"pre",
|
|
3051
3361
|
{
|
|
3052
3362
|
className: cn(
|
|
@@ -3058,7 +3368,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3058
3368
|
),
|
|
3059
3369
|
code: function Code({ className, ...props }) {
|
|
3060
3370
|
const isCodeBlock = (0, import_react_markdown.useIsMarkdownCodeBlock)();
|
|
3061
|
-
return /* @__PURE__ */ (0,
|
|
3371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3062
3372
|
"code",
|
|
3063
3373
|
{
|
|
3064
3374
|
className: cn(
|
|
@@ -3069,20 +3379,20 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3069
3379
|
}
|
|
3070
3380
|
);
|
|
3071
3381
|
},
|
|
3072
|
-
strong: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3073
|
-
em: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3382
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
3383
|
+
em: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("em", { className: cn("italic", className), ...props }),
|
|
3074
3384
|
CodeHeader
|
|
3075
3385
|
});
|
|
3076
3386
|
|
|
3077
3387
|
// src/chat/tool-fallback.tsx
|
|
3078
|
-
var
|
|
3388
|
+
var import_react23 = require("react");
|
|
3079
3389
|
var import_lucide_react5 = require("lucide-react");
|
|
3080
|
-
var
|
|
3390
|
+
var import_react24 = require("@assistant-ui/react");
|
|
3081
3391
|
|
|
3082
3392
|
// src/ui/shimmer.tsx
|
|
3083
|
-
var
|
|
3084
|
-
var
|
|
3085
|
-
var
|
|
3393
|
+
var import_react20 = require("motion/react");
|
|
3394
|
+
var import_react21 = require("react");
|
|
3395
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3086
3396
|
var ShimmerComponent = ({
|
|
3087
3397
|
children,
|
|
3088
3398
|
as: Component = "p",
|
|
@@ -3090,14 +3400,14 @@ var ShimmerComponent = ({
|
|
|
3090
3400
|
duration = 2,
|
|
3091
3401
|
spread = 2
|
|
3092
3402
|
}) => {
|
|
3093
|
-
const MotionComponent =
|
|
3403
|
+
const MotionComponent = import_react20.motion.create(
|
|
3094
3404
|
Component
|
|
3095
3405
|
);
|
|
3096
|
-
const dynamicSpread = (0,
|
|
3406
|
+
const dynamicSpread = (0, import_react21.useMemo)(
|
|
3097
3407
|
() => (children?.length ?? 0) * spread,
|
|
3098
3408
|
[children, spread]
|
|
3099
3409
|
);
|
|
3100
|
-
return /* @__PURE__ */ (0,
|
|
3410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3101
3411
|
MotionComponent,
|
|
3102
3412
|
{
|
|
3103
3413
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -3120,11 +3430,11 @@ var ShimmerComponent = ({
|
|
|
3120
3430
|
}
|
|
3121
3431
|
);
|
|
3122
3432
|
};
|
|
3123
|
-
var Shimmer = (0,
|
|
3433
|
+
var Shimmer = (0, import_react21.memo)(ShimmerComponent);
|
|
3124
3434
|
|
|
3125
3435
|
// src/chat/motion.tsx
|
|
3126
|
-
var
|
|
3127
|
-
var
|
|
3436
|
+
var import_react22 = require("motion/react");
|
|
3437
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3128
3438
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
3129
3439
|
var TOOL_ENTER_MS = 0.78;
|
|
3130
3440
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -3150,10 +3460,10 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
3150
3460
|
return entering ? { opacity: 0, y: 14, filter: "blur(10px)" } : { opacity: 1, y: 0, filter: "blur(0px)" };
|
|
3151
3461
|
}
|
|
3152
3462
|
function ToolMotion({ children, className, motionKey }) {
|
|
3153
|
-
const reduced = (0,
|
|
3463
|
+
const reduced = (0, import_react22.useReducedMotion)() ?? false;
|
|
3154
3464
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3155
|
-
return /* @__PURE__ */ (0,
|
|
3156
|
-
|
|
3465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3466
|
+
import_react22.motion.div,
|
|
3157
3467
|
{
|
|
3158
3468
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
3159
3469
|
initial: toolMotionState(reduced, true, "settled"),
|
|
@@ -3172,11 +3482,11 @@ function ToolPresence({
|
|
|
3172
3482
|
className,
|
|
3173
3483
|
variant = "settled"
|
|
3174
3484
|
}) {
|
|
3175
|
-
const reduced = (0,
|
|
3485
|
+
const reduced = (0, import_react22.useReducedMotion)() ?? false;
|
|
3176
3486
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3177
3487
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
3178
|
-
return /* @__PURE__ */ (0,
|
|
3179
|
-
|
|
3488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react22.AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3489
|
+
import_react22.motion.div,
|
|
3180
3490
|
{
|
|
3181
3491
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
3182
3492
|
initial: toolMotionState(reduced, true, variant),
|
|
@@ -3196,8 +3506,8 @@ function ToolBodyPresence({
|
|
|
3196
3506
|
children,
|
|
3197
3507
|
className
|
|
3198
3508
|
}) {
|
|
3199
|
-
const reduced = (0,
|
|
3200
|
-
return /* @__PURE__ */ (0,
|
|
3509
|
+
const reduced = (0, import_react22.useReducedMotion)() ?? false;
|
|
3510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3201
3511
|
"div",
|
|
3202
3512
|
{
|
|
3203
3513
|
className: cn(
|
|
@@ -3205,7 +3515,7 @@ function ToolBodyPresence({
|
|
|
3205
3515
|
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)]"
|
|
3206
3516
|
),
|
|
3207
3517
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3208
|
-
children: /* @__PURE__ */ (0,
|
|
3518
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3209
3519
|
"div",
|
|
3210
3520
|
{
|
|
3211
3521
|
className: cn(
|
|
@@ -3221,7 +3531,7 @@ function ToolBodyPresence({
|
|
|
3221
3531
|
}
|
|
3222
3532
|
|
|
3223
3533
|
// src/chat/tool-fallback.tsx
|
|
3224
|
-
var
|
|
3534
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3225
3535
|
function detectRunning({
|
|
3226
3536
|
status,
|
|
3227
3537
|
result,
|
|
@@ -3235,7 +3545,7 @@ function detectRunning({
|
|
|
3235
3545
|
}
|
|
3236
3546
|
function useToolRunning(props) {
|
|
3237
3547
|
const { isRunning: streamRunning } = useTimbalRuntime();
|
|
3238
|
-
const partStatus = (0,
|
|
3548
|
+
const partStatus = (0, import_react24.useAuiState)((s) => s.part.status);
|
|
3239
3549
|
return detectRunning({
|
|
3240
3550
|
status: partStatus ?? props.status,
|
|
3241
3551
|
result: props.result,
|
|
@@ -3253,8 +3563,8 @@ function formatToolResult(result) {
|
|
|
3253
3563
|
return String(result);
|
|
3254
3564
|
}
|
|
3255
3565
|
}
|
|
3256
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0,
|
|
3257
|
-
action ? shimmer ? /* @__PURE__ */ (0,
|
|
3566
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
3567
|
+
action ? shimmer ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3258
3568
|
Shimmer,
|
|
3259
3569
|
{
|
|
3260
3570
|
as: "span",
|
|
@@ -3263,10 +3573,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3263
3573
|
spread: 2.5,
|
|
3264
3574
|
children: action
|
|
3265
3575
|
}
|
|
3266
|
-
) : /* @__PURE__ */ (0,
|
|
3267
|
-
detail ? /* @__PURE__ */ (0,
|
|
3576
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
3577
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3268
3578
|
] });
|
|
3269
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0,
|
|
3579
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3270
3580
|
import_lucide_react5.ChevronRightIcon,
|
|
3271
3581
|
{
|
|
3272
3582
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3274,9 +3584,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runt
|
|
|
3274
3584
|
}
|
|
3275
3585
|
);
|
|
3276
3586
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3277
|
-
const [open, setOpen] = (0,
|
|
3587
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
3278
3588
|
const detail = formatToolLabel(toolName);
|
|
3279
|
-
const formattedArgs = (0,
|
|
3589
|
+
const formattedArgs = (0, import_react23.useMemo)(() => {
|
|
3280
3590
|
if (!argsText || argsText === "{}") return null;
|
|
3281
3591
|
try {
|
|
3282
3592
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3284,17 +3594,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3284
3594
|
return argsText;
|
|
3285
3595
|
}
|
|
3286
3596
|
}, [argsText]);
|
|
3287
|
-
const formattedResult = (0,
|
|
3597
|
+
const formattedResult = (0, import_react23.useMemo)(() => {
|
|
3288
3598
|
if (result === void 0 || result === null) return null;
|
|
3289
3599
|
return formatToolResult(result);
|
|
3290
3600
|
}, [result]);
|
|
3291
3601
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3292
3602
|
const action = isError ? "Failed" : "Used";
|
|
3293
3603
|
if (!hasBody) {
|
|
3294
|
-
return /* @__PURE__ */ (0,
|
|
3604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimelineActionLabel, { action, detail }) });
|
|
3295
3605
|
}
|
|
3296
|
-
return /* @__PURE__ */ (0,
|
|
3297
|
-
/* @__PURE__ */ (0,
|
|
3606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
3607
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3298
3608
|
"button",
|
|
3299
3609
|
{
|
|
3300
3610
|
type: "button",
|
|
@@ -3302,7 +3612,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3302
3612
|
"aria-expanded": open,
|
|
3303
3613
|
"aria-label": `${action} ${detail}`,
|
|
3304
3614
|
className: studioTimelineRowButtonClass,
|
|
3305
|
-
children: /* @__PURE__ */ (0,
|
|
3615
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3306
3616
|
"span",
|
|
3307
3617
|
{
|
|
3308
3618
|
className: cn(
|
|
@@ -3311,37 +3621,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3311
3621
|
"text-foreground"
|
|
3312
3622
|
),
|
|
3313
3623
|
children: [
|
|
3314
|
-
/* @__PURE__ */ (0,
|
|
3315
|
-
/* @__PURE__ */ (0,
|
|
3624
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimelineActionLabel, { action, detail }),
|
|
3625
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimelineHoverChevron, { expanded: open })
|
|
3316
3626
|
]
|
|
3317
3627
|
}
|
|
3318
3628
|
)
|
|
3319
3629
|
}
|
|
3320
3630
|
),
|
|
3321
|
-
/* @__PURE__ */ (0,
|
|
3631
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3322
3632
|
ToolBodyPresence,
|
|
3323
3633
|
{
|
|
3324
3634
|
open,
|
|
3325
3635
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3326
3636
|
children: [
|
|
3327
|
-
formattedArgs ? /* @__PURE__ */ (0,
|
|
3637
|
+
formattedArgs ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3328
3638
|
"div",
|
|
3329
3639
|
{
|
|
3330
3640
|
className: cn(
|
|
3331
3641
|
studioComposerIoWellClass,
|
|
3332
3642
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3333
3643
|
),
|
|
3334
|
-
children: /* @__PURE__ */ (0,
|
|
3644
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3335
3645
|
}
|
|
3336
3646
|
) : null,
|
|
3337
|
-
formattedResult ? /* @__PURE__ */ (0,
|
|
3647
|
+
formattedResult ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3338
3648
|
"div",
|
|
3339
3649
|
{
|
|
3340
3650
|
className: cn(
|
|
3341
3651
|
studioComposerIoWellClass,
|
|
3342
3652
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3343
3653
|
),
|
|
3344
|
-
children: /* @__PURE__ */ (0,
|
|
3654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3345
3655
|
}
|
|
3346
3656
|
) : null
|
|
3347
3657
|
]
|
|
@@ -3358,20 +3668,20 @@ var ToolFallbackImpl = ({
|
|
|
3358
3668
|
const isRunning = useToolRunning({ status, result });
|
|
3359
3669
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3360
3670
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3361
|
-
return /* @__PURE__ */ (0,
|
|
3671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3362
3672
|
ToolPresence,
|
|
3363
3673
|
{
|
|
3364
3674
|
presenceKey,
|
|
3365
3675
|
variant: isRunning ? "executing" : "settled",
|
|
3366
3676
|
className: "py-0.5",
|
|
3367
|
-
children: isRunning ? /* @__PURE__ */ (0,
|
|
3677
|
+
children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "aui-tool-running", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3368
3678
|
TimelineActionLabel,
|
|
3369
3679
|
{
|
|
3370
3680
|
action: "Using",
|
|
3371
3681
|
detail: formatToolLabel(toolName),
|
|
3372
3682
|
shimmer: true
|
|
3373
3683
|
}
|
|
3374
|
-
) }) : /* @__PURE__ */ (0,
|
|
3684
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3375
3685
|
ToolPanel,
|
|
3376
3686
|
{
|
|
3377
3687
|
toolName,
|
|
@@ -3383,13 +3693,13 @@ var ToolFallbackImpl = ({
|
|
|
3383
3693
|
}
|
|
3384
3694
|
);
|
|
3385
3695
|
};
|
|
3386
|
-
var ToolFallback = (0,
|
|
3696
|
+
var ToolFallback = (0, import_react23.memo)(
|
|
3387
3697
|
ToolFallbackImpl
|
|
3388
3698
|
);
|
|
3389
3699
|
ToolFallback.displayName = "ToolFallback";
|
|
3390
3700
|
|
|
3391
3701
|
// src/artifacts/tool-artifact.tsx
|
|
3392
|
-
var
|
|
3702
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3393
3703
|
var ToolArtifactFallback = (props) => {
|
|
3394
3704
|
const registry = useArtifactRegistry();
|
|
3395
3705
|
const isRunning = useToolRunning({
|
|
@@ -3401,24 +3711,24 @@ var ToolArtifactFallback = (props) => {
|
|
|
3401
3711
|
if (artifact) {
|
|
3402
3712
|
const Renderer = registry[artifact.type];
|
|
3403
3713
|
if (Renderer) {
|
|
3404
|
-
return /* @__PURE__ */ (0,
|
|
3714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3405
3715
|
ToolMotion,
|
|
3406
3716
|
{
|
|
3407
3717
|
motionKey: `artifact-${artifact.type}`,
|
|
3408
3718
|
className: "aui-tool-artifact",
|
|
3409
|
-
children: /* @__PURE__ */ (0,
|
|
3719
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Renderer, { artifact })
|
|
3410
3720
|
}
|
|
3411
3721
|
);
|
|
3412
3722
|
}
|
|
3413
3723
|
}
|
|
3414
3724
|
}
|
|
3415
|
-
return /* @__PURE__ */ (0,
|
|
3725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ToolFallback, { ...props });
|
|
3416
3726
|
};
|
|
3417
3727
|
|
|
3418
3728
|
// src/chat/composer.tsx
|
|
3419
|
-
var
|
|
3729
|
+
var import_react25 = require("@assistant-ui/react");
|
|
3420
3730
|
var import_lucide_react6 = require("lucide-react");
|
|
3421
|
-
var
|
|
3731
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3422
3732
|
var Composer = ({
|
|
3423
3733
|
placeholder = "Send a message...",
|
|
3424
3734
|
showAttachments,
|
|
@@ -3429,10 +3739,10 @@ var Composer = ({
|
|
|
3429
3739
|
}) => {
|
|
3430
3740
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
3431
3741
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
3432
|
-
const shell = /* @__PURE__ */ (0,
|
|
3433
|
-
attachUi && /* @__PURE__ */ (0,
|
|
3434
|
-
/* @__PURE__ */ (0,
|
|
3435
|
-
/* @__PURE__ */ (0,
|
|
3742
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
3743
|
+
attachUi && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerAttachments, {}),
|
|
3744
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
3745
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3436
3746
|
ComposerToolbar,
|
|
3437
3747
|
{
|
|
3438
3748
|
showAttachments: attachUi,
|
|
@@ -3441,15 +3751,15 @@ var Composer = ({
|
|
|
3441
3751
|
}
|
|
3442
3752
|
)
|
|
3443
3753
|
] });
|
|
3444
|
-
return /* @__PURE__ */ (0,
|
|
3445
|
-
|
|
3754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3755
|
+
import_react25.ComposerPrimitive.Root,
|
|
3446
3756
|
{
|
|
3447
3757
|
className: cn(
|
|
3448
3758
|
"aui-composer-root relative flex w-full flex-col",
|
|
3449
3759
|
className
|
|
3450
3760
|
),
|
|
3451
|
-
children: attachUi ? /* @__PURE__ */ (0,
|
|
3452
|
-
|
|
3761
|
+
children: attachUi ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3762
|
+
import_react25.ComposerPrimitive.AttachmentDropzone,
|
|
3453
3763
|
{
|
|
3454
3764
|
className: cn(
|
|
3455
3765
|
studioComposeInputShellClass,
|
|
@@ -3457,7 +3767,7 @@ var Composer = ({
|
|
|
3457
3767
|
),
|
|
3458
3768
|
children: shell
|
|
3459
3769
|
}
|
|
3460
|
-
) : /* @__PURE__ */ (0,
|
|
3770
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: studioComposeInputShellClass, children: shell })
|
|
3461
3771
|
}
|
|
3462
3772
|
);
|
|
3463
3773
|
};
|
|
@@ -3465,7 +3775,7 @@ var ComposerInput = ({
|
|
|
3465
3775
|
placeholder,
|
|
3466
3776
|
autoFocus
|
|
3467
3777
|
}) => {
|
|
3468
|
-
const composer = (0,
|
|
3778
|
+
const composer = (0, import_react25.useComposerRuntime)();
|
|
3469
3779
|
const onKeyDown = (e) => {
|
|
3470
3780
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
3471
3781
|
e.preventDefault();
|
|
@@ -3477,8 +3787,8 @@ var ComposerInput = ({
|
|
|
3477
3787
|
el.style.height = "auto";
|
|
3478
3788
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
3479
3789
|
};
|
|
3480
|
-
return /* @__PURE__ */ (0,
|
|
3481
|
-
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3791
|
+
import_react25.ComposerPrimitive.Input,
|
|
3482
3792
|
{
|
|
3483
3793
|
placeholder,
|
|
3484
3794
|
className: "aui-composer-input max-h-60 min-h-14 w-full resize-none bg-composer-bg px-3 pt-3 pb-1 text-sm outline-none placeholder:text-muted-foreground/70 focus-visible:ring-0",
|
|
@@ -3491,17 +3801,17 @@ var ComposerInput = ({
|
|
|
3491
3801
|
);
|
|
3492
3802
|
};
|
|
3493
3803
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
3494
|
-
return /* @__PURE__ */ (0,
|
|
3495
|
-
/* @__PURE__ */ (0,
|
|
3496
|
-
showAttachments && /* @__PURE__ */ (0,
|
|
3804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("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: [
|
|
3805
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3806
|
+
showAttachments && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerAddAttachment, {}),
|
|
3497
3807
|
toolbar
|
|
3498
3808
|
] }),
|
|
3499
|
-
/* @__PURE__ */ (0,
|
|
3809
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerSendOrCancel, { sendTooltip })
|
|
3500
3810
|
] });
|
|
3501
3811
|
};
|
|
3502
3812
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
3503
|
-
return /* @__PURE__ */ (0,
|
|
3504
|
-
/* @__PURE__ */ (0,
|
|
3813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3505
3815
|
TooltipIconButton,
|
|
3506
3816
|
{
|
|
3507
3817
|
tooltip: sendTooltip,
|
|
@@ -3509,34 +3819,34 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3509
3819
|
type: "submit",
|
|
3510
3820
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
3511
3821
|
"aria-label": "Send message",
|
|
3512
|
-
children: /* @__PURE__ */ (0,
|
|
3822
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react6.ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
3513
3823
|
}
|
|
3514
3824
|
) }) }),
|
|
3515
|
-
/* @__PURE__ */ (0,
|
|
3825
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3516
3826
|
TooltipIconButton,
|
|
3517
3827
|
{
|
|
3518
3828
|
tooltip: "Stop generating",
|
|
3519
3829
|
variant: "primary",
|
|
3520
3830
|
className: "aui-composer-cancel shrink-0",
|
|
3521
3831
|
"aria-label": "Stop generating",
|
|
3522
|
-
children: /* @__PURE__ */ (0,
|
|
3832
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react6.SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
3523
3833
|
}
|
|
3524
3834
|
) }) })
|
|
3525
3835
|
] });
|
|
3526
3836
|
};
|
|
3527
3837
|
|
|
3528
3838
|
// src/chat/suggestions.tsx
|
|
3529
|
-
var
|
|
3530
|
-
var
|
|
3839
|
+
var import_react26 = require("react");
|
|
3840
|
+
var import_react27 = require("@assistant-ui/react");
|
|
3531
3841
|
var import_lucide_react7 = require("lucide-react");
|
|
3532
|
-
var
|
|
3842
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3533
3843
|
var Suggestions = ({
|
|
3534
3844
|
suggestions,
|
|
3535
3845
|
className
|
|
3536
3846
|
}) => {
|
|
3537
3847
|
const items = useResolvedSuggestions(suggestions);
|
|
3538
3848
|
if (!items || items.length === 0) return null;
|
|
3539
|
-
return /* @__PURE__ */ (0,
|
|
3849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3540
3850
|
"div",
|
|
3541
3851
|
{
|
|
3542
3852
|
className: cn(
|
|
@@ -3545,17 +3855,17 @@ var Suggestions = ({
|
|
|
3545
3855
|
),
|
|
3546
3856
|
role: "list",
|
|
3547
3857
|
"aria-label": "Suggested prompts",
|
|
3548
|
-
children: items.map((suggestion, i) => /* @__PURE__ */ (0,
|
|
3858
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
3549
3859
|
}
|
|
3550
3860
|
);
|
|
3551
3861
|
};
|
|
3552
3862
|
var SuggestionRow = ({ suggestion }) => {
|
|
3553
|
-
const runtime = (0,
|
|
3863
|
+
const runtime = (0, import_react27.useThreadRuntime)();
|
|
3554
3864
|
const onClick = () => {
|
|
3555
3865
|
const text = suggestion.prompt ?? suggestion.title;
|
|
3556
3866
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
3557
3867
|
};
|
|
3558
|
-
return /* @__PURE__ */ (0,
|
|
3868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3559
3869
|
"button",
|
|
3560
3870
|
{
|
|
3561
3871
|
type: "button",
|
|
@@ -3563,20 +3873,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3563
3873
|
onClick,
|
|
3564
3874
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
3565
3875
|
children: [
|
|
3566
|
-
/* @__PURE__ */ (0,
|
|
3567
|
-
/* @__PURE__ */ (0,
|
|
3568
|
-
/* @__PURE__ */ (0,
|
|
3569
|
-
suggestion.description && /* @__PURE__ */ (0,
|
|
3876
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
3878
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
3879
|
+
suggestion.description && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
3570
3880
|
] })
|
|
3571
3881
|
]
|
|
3572
3882
|
}
|
|
3573
3883
|
);
|
|
3574
3884
|
};
|
|
3575
3885
|
function useResolvedSuggestions(source) {
|
|
3576
|
-
const [resolved, setResolved] = (0,
|
|
3886
|
+
const [resolved, setResolved] = (0, import_react26.useState)(
|
|
3577
3887
|
() => Array.isArray(source) ? source : void 0
|
|
3578
3888
|
);
|
|
3579
|
-
(0,
|
|
3889
|
+
(0, import_react26.useEffect)(() => {
|
|
3580
3890
|
if (!source) {
|
|
3581
3891
|
setResolved(void 0);
|
|
3582
3892
|
return;
|
|
@@ -3595,7 +3905,7 @@ function useResolvedSuggestions(source) {
|
|
|
3595
3905
|
cancelled = true;
|
|
3596
3906
|
};
|
|
3597
3907
|
}, [source]);
|
|
3598
|
-
return (0,
|
|
3908
|
+
return (0, import_react26.useMemo)(() => resolved, [resolved]);
|
|
3599
3909
|
}
|
|
3600
3910
|
|
|
3601
3911
|
// src/design/theme-sanity.ts
|
|
@@ -3668,15 +3978,15 @@ function scheduleThemeSanityCheck() {
|
|
|
3668
3978
|
}
|
|
3669
3979
|
|
|
3670
3980
|
// src/chat/thread-variant.tsx
|
|
3671
|
-
var
|
|
3672
|
-
var ThreadVariantContext = (0,
|
|
3981
|
+
var import_react28 = require("react");
|
|
3982
|
+
var ThreadVariantContext = (0, import_react28.createContext)("default");
|
|
3673
3983
|
var ThreadVariantProvider = ThreadVariantContext.Provider;
|
|
3674
3984
|
function useThreadVariant() {
|
|
3675
|
-
return (0,
|
|
3985
|
+
return (0, import_react28.useContext)(ThreadVariantContext);
|
|
3676
3986
|
}
|
|
3677
3987
|
|
|
3678
3988
|
// src/chat/thread.tsx
|
|
3679
|
-
var
|
|
3989
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3680
3990
|
var Thread = ({
|
|
3681
3991
|
className,
|
|
3682
3992
|
variant = "default",
|
|
@@ -3698,17 +4008,17 @@ var Thread = ({
|
|
|
3698
4008
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
3699
4009
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
3700
4010
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
3701
|
-
(0,
|
|
4011
|
+
(0, import_react29.useEffect)(() => {
|
|
3702
4012
|
scheduleThemeSanityCheck();
|
|
3703
4013
|
}, []);
|
|
3704
|
-
return /* @__PURE__ */ (0,
|
|
4014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3705
4015
|
ArtifactRegistryProvider,
|
|
3706
4016
|
{
|
|
3707
4017
|
renderers: artifacts?.renderers,
|
|
3708
4018
|
override: artifacts?.override,
|
|
3709
|
-
children: /* @__PURE__ */ (0,
|
|
3710
|
-
}), children: /* @__PURE__ */ (0,
|
|
3711
|
-
|
|
4019
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
4020
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4021
|
+
import_react30.ThreadPrimitive.Root,
|
|
3712
4022
|
{
|
|
3713
4023
|
className: cn(
|
|
3714
4024
|
"aui-root aui-thread-root @container flex h-full flex-col bg-transparent",
|
|
@@ -3717,8 +4027,8 @@ var Thread = ({
|
|
|
3717
4027
|
),
|
|
3718
4028
|
style: { ["--thread-max-width"]: maxWidth },
|
|
3719
4029
|
"data-thread-variant": variant,
|
|
3720
|
-
children: /* @__PURE__ */ (0,
|
|
3721
|
-
|
|
4030
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4031
|
+
import_react30.ThreadPrimitive.Viewport,
|
|
3722
4032
|
{
|
|
3723
4033
|
turnAnchor: "bottom",
|
|
3724
4034
|
className: cn(
|
|
@@ -3726,7 +4036,7 @@ var Thread = ({
|
|
|
3726
4036
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
3727
4037
|
),
|
|
3728
4038
|
children: [
|
|
3729
|
-
/* @__PURE__ */ (0,
|
|
4039
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3730
4040
|
WelcomeSlot,
|
|
3731
4041
|
{
|
|
3732
4042
|
config: welcome,
|
|
@@ -3734,8 +4044,8 @@ var Thread = ({
|
|
|
3734
4044
|
Suggestions: SuggestionsSlot
|
|
3735
4045
|
}
|
|
3736
4046
|
),
|
|
3737
|
-
/* @__PURE__ */ (0,
|
|
3738
|
-
|
|
4047
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4048
|
+
import_react30.ThreadPrimitive.Messages,
|
|
3739
4049
|
{
|
|
3740
4050
|
components: {
|
|
3741
4051
|
UserMessage: UserMessageSlot,
|
|
@@ -3744,14 +4054,14 @@ var Thread = ({
|
|
|
3744
4054
|
}
|
|
3745
4055
|
}
|
|
3746
4056
|
),
|
|
3747
|
-
/* @__PURE__ */ (0,
|
|
3748
|
-
|
|
4057
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4058
|
+
import_react30.ThreadPrimitive.ViewportFooter,
|
|
3749
4059
|
{
|
|
3750
4060
|
className: cn(
|
|
3751
4061
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
3752
4062
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
3753
4063
|
),
|
|
3754
|
-
children: /* @__PURE__ */ (0,
|
|
4064
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3755
4065
|
"div",
|
|
3756
4066
|
{
|
|
3757
4067
|
className: cn(
|
|
@@ -3759,8 +4069,8 @@ var Thread = ({
|
|
|
3759
4069
|
isPanel ? "gap-2" : "gap-4"
|
|
3760
4070
|
),
|
|
3761
4071
|
children: [
|
|
3762
|
-
/* @__PURE__ */ (0,
|
|
3763
|
-
/* @__PURE__ */ (0,
|
|
4072
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ScrollToBottomSlot, {}),
|
|
4073
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ComposerSlot, { placeholder })
|
|
3764
4074
|
]
|
|
3765
4075
|
}
|
|
3766
4076
|
)
|
|
@@ -3775,13 +4085,13 @@ var Thread = ({
|
|
|
3775
4085
|
) });
|
|
3776
4086
|
};
|
|
3777
4087
|
var ThreadScrollToBottom = () => {
|
|
3778
|
-
return /* @__PURE__ */ (0,
|
|
4088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3779
4089
|
TooltipIconButton,
|
|
3780
4090
|
{
|
|
3781
4091
|
tooltip: "Scroll to bottom",
|
|
3782
4092
|
variant: "secondary",
|
|
3783
4093
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
3784
|
-
children: /* @__PURE__ */ (0,
|
|
4094
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.ArrowDownIcon, { className: "size-4" })
|
|
3785
4095
|
}
|
|
3786
4096
|
) });
|
|
3787
4097
|
};
|
|
@@ -3813,14 +4123,14 @@ var ThreadWelcome = ({
|
|
|
3813
4123
|
suggestions,
|
|
3814
4124
|
Suggestions: SuggestionsSlot = Suggestions
|
|
3815
4125
|
}) => {
|
|
3816
|
-
const isEmpty = (0,
|
|
4126
|
+
const isEmpty = (0, import_react30.useThread)((s) => s.messages.length === 0);
|
|
3817
4127
|
const isPanel = useThreadVariant() === "panel";
|
|
3818
4128
|
if (!isEmpty) return null;
|
|
3819
4129
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
3820
4130
|
const defaultSubheading = isPanel ? "The assistant can use dashboard context from your app." : "Send a message to start a conversation.";
|
|
3821
|
-
return /* @__PURE__ */ (0,
|
|
3822
|
-
/* @__PURE__ */ (0,
|
|
3823
|
-
|
|
4131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
4132
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4133
|
+
import_react31.motion.div,
|
|
3824
4134
|
{
|
|
3825
4135
|
className: cn(
|
|
3826
4136
|
"aui-thread-welcome-message flex flex-col items-center justify-center text-center",
|
|
@@ -3830,9 +4140,9 @@ var ThreadWelcome = ({
|
|
|
3830
4140
|
initial: "initial",
|
|
3831
4141
|
animate: "animate",
|
|
3832
4142
|
children: [
|
|
3833
|
-
config?.icon && /* @__PURE__ */ (0,
|
|
3834
|
-
/* @__PURE__ */ (0,
|
|
3835
|
-
|
|
4143
|
+
config?.icon && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react31.motion.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
4144
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4145
|
+
import_react31.motion.h1,
|
|
3836
4146
|
{
|
|
3837
4147
|
variants: welcomeItem,
|
|
3838
4148
|
className: cn(
|
|
@@ -3842,8 +4152,8 @@ var ThreadWelcome = ({
|
|
|
3842
4152
|
children: config?.heading ?? defaultHeading
|
|
3843
4153
|
}
|
|
3844
4154
|
),
|
|
3845
|
-
/* @__PURE__ */ (0,
|
|
3846
|
-
|
|
4155
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4156
|
+
import_react31.motion.p,
|
|
3847
4157
|
{
|
|
3848
4158
|
variants: welcomeItem,
|
|
3849
4159
|
className: "aui-thread-welcome-message-inner mt-1.5 text-muted-foreground text-sm",
|
|
@@ -3853,16 +4163,16 @@ var ThreadWelcome = ({
|
|
|
3853
4163
|
]
|
|
3854
4164
|
}
|
|
3855
4165
|
) }),
|
|
3856
|
-
suggestions && !isPanel ? /* @__PURE__ */ (0,
|
|
4166
|
+
suggestions && !isPanel ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SuggestionsSlot, { suggestions }) }) : null
|
|
3857
4167
|
] });
|
|
3858
4168
|
};
|
|
3859
4169
|
var MessageError = () => {
|
|
3860
|
-
return /* @__PURE__ */ (0,
|
|
4170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePrimitive.Error, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.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__ */ (0, import_jsx_runtime29.jsx)(import_react30.ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
3861
4171
|
};
|
|
3862
4172
|
var AssistantMessage = () => {
|
|
3863
4173
|
const isPanel = useThreadVariant() === "panel";
|
|
3864
|
-
return /* @__PURE__ */ (0,
|
|
3865
|
-
|
|
4174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4175
|
+
import_react30.MessagePrimitive.Root,
|
|
3866
4176
|
{
|
|
3867
4177
|
className: cn(
|
|
3868
4178
|
"aui-assistant-message-root fade-in slide-in-from-bottom-1 relative mx-auto w-full max-w-(--thread-max-width) animate-in duration-150",
|
|
@@ -3870,7 +4180,7 @@ var AssistantMessage = () => {
|
|
|
3870
4180
|
),
|
|
3871
4181
|
"data-role": "assistant",
|
|
3872
4182
|
children: [
|
|
3873
|
-
/* @__PURE__ */ (0,
|
|
4183
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3874
4184
|
"div",
|
|
3875
4185
|
{
|
|
3876
4186
|
className: cn(
|
|
@@ -3878,8 +4188,8 @@ var AssistantMessage = () => {
|
|
|
3878
4188
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
3879
4189
|
),
|
|
3880
4190
|
children: [
|
|
3881
|
-
/* @__PURE__ */ (0,
|
|
3882
|
-
|
|
4191
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4192
|
+
import_react30.MessagePrimitive.Parts,
|
|
3883
4193
|
{
|
|
3884
4194
|
components: {
|
|
3885
4195
|
Text: MarkdownText,
|
|
@@ -3889,11 +4199,11 @@ var AssistantMessage = () => {
|
|
|
3889
4199
|
}
|
|
3890
4200
|
}
|
|
3891
4201
|
),
|
|
3892
|
-
/* @__PURE__ */ (0,
|
|
4202
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(MessageError, {})
|
|
3893
4203
|
]
|
|
3894
4204
|
}
|
|
3895
4205
|
),
|
|
3896
|
-
/* @__PURE__ */ (0,
|
|
4206
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(AssistantActionBar, {}) })
|
|
3897
4207
|
]
|
|
3898
4208
|
}
|
|
3899
4209
|
);
|
|
@@ -3906,36 +4216,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
3906
4216
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
3907
4217
|
);
|
|
3908
4218
|
var AssistantActionBar = () => {
|
|
3909
|
-
return /* @__PURE__ */ (0,
|
|
3910
|
-
|
|
4219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4220
|
+
import_react30.ActionBarPrimitive.Root,
|
|
3911
4221
|
{
|
|
3912
4222
|
hideWhenRunning: true,
|
|
3913
4223
|
autohide: "never",
|
|
3914
4224
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
3915
4225
|
children: [
|
|
3916
|
-
/* @__PURE__ */ (0,
|
|
4226
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3917
4227
|
TooltipIconButton,
|
|
3918
4228
|
{
|
|
3919
4229
|
tooltip: "Copy",
|
|
3920
4230
|
variant: "ghost",
|
|
3921
4231
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3922
4232
|
children: [
|
|
3923
|
-
/* @__PURE__ */ (0,
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
4233
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.CheckIcon, { className: "size-3" }) }),
|
|
4234
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.CopyIcon, { className: "size-3" }) })
|
|
3925
4235
|
]
|
|
3926
4236
|
}
|
|
3927
4237
|
) }),
|
|
3928
|
-
/* @__PURE__ */ (0,
|
|
4238
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3929
4239
|
TooltipIconButton,
|
|
3930
4240
|
{
|
|
3931
4241
|
tooltip: "Regenerate",
|
|
3932
4242
|
variant: "ghost",
|
|
3933
4243
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3934
|
-
children: /* @__PURE__ */ (0,
|
|
4244
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.RefreshCwIcon, { className: "size-3" })
|
|
3935
4245
|
}
|
|
3936
4246
|
) }),
|
|
3937
|
-
/* @__PURE__ */ (0,
|
|
3938
|
-
/* @__PURE__ */ (0,
|
|
4247
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_react30.ActionBarMorePrimitive.Root, { children: [
|
|
4248
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3939
4249
|
TooltipIconButton,
|
|
3940
4250
|
{
|
|
3941
4251
|
tooltip: "More",
|
|
@@ -3944,17 +4254,17 @@ var AssistantActionBar = () => {
|
|
|
3944
4254
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
3945
4255
|
"data-[state=open]:text-muted-foreground/80"
|
|
3946
4256
|
),
|
|
3947
|
-
children: /* @__PURE__ */ (0,
|
|
4257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.MoreHorizontalIcon, { className: "size-3" })
|
|
3948
4258
|
}
|
|
3949
4259
|
) }),
|
|
3950
|
-
/* @__PURE__ */ (0,
|
|
3951
|
-
|
|
4260
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4261
|
+
import_react30.ActionBarMorePrimitive.Content,
|
|
3952
4262
|
{
|
|
3953
4263
|
side: "bottom",
|
|
3954
4264
|
align: "start",
|
|
3955
4265
|
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",
|
|
3956
|
-
children: /* @__PURE__ */ (0,
|
|
3957
|
-
/* @__PURE__ */ (0,
|
|
4266
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_react30.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: [
|
|
4267
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.DownloadIcon, { className: "size-4 shrink-0" }),
|
|
3958
4268
|
"Export as Markdown"
|
|
3959
4269
|
] }) })
|
|
3960
4270
|
}
|
|
@@ -3965,12 +4275,12 @@ var AssistantActionBar = () => {
|
|
|
3965
4275
|
);
|
|
3966
4276
|
};
|
|
3967
4277
|
var UserMessageText = () => {
|
|
3968
|
-
return /* @__PURE__ */ (0,
|
|
4278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePartPrimitive.Text, { smooth: false }) });
|
|
3969
4279
|
};
|
|
3970
4280
|
var UserMessage = () => {
|
|
3971
4281
|
const isPanel = useThreadVariant() === "panel";
|
|
3972
|
-
return /* @__PURE__ */ (0,
|
|
3973
|
-
|
|
4282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4283
|
+
import_react30.MessagePrimitive.Root,
|
|
3974
4284
|
{
|
|
3975
4285
|
className: cn(
|
|
3976
4286
|
"aui-user-message-root mx-auto flex w-full max-w-(--thread-max-width) flex-col items-end gap-2",
|
|
@@ -3978,9 +4288,9 @@ var UserMessage = () => {
|
|
|
3978
4288
|
),
|
|
3979
4289
|
"data-role": "user",
|
|
3980
4290
|
children: [
|
|
3981
|
-
/* @__PURE__ */ (0,
|
|
3982
|
-
/* @__PURE__ */ (0,
|
|
3983
|
-
|
|
4291
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(UserMessageAttachments, {}),
|
|
4292
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4293
|
+
import_react31.motion.div,
|
|
3984
4294
|
{
|
|
3985
4295
|
className: cn(
|
|
3986
4296
|
"aui-user-message-content relative inline-block max-w-[85%] rounded-2xl bg-bubble-user text-bubble-user-foreground",
|
|
@@ -3990,8 +4300,8 @@ var UserMessage = () => {
|
|
|
3990
4300
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
3991
4301
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
3992
4302
|
children: [
|
|
3993
|
-
/* @__PURE__ */ (0,
|
|
3994
|
-
/* @__PURE__ */ (0,
|
|
4303
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePrimitive.Parts, { components: { Text: UserMessageText } }),
|
|
4304
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(UserActionBar, {}) })
|
|
3995
4305
|
]
|
|
3996
4306
|
}
|
|
3997
4307
|
)
|
|
@@ -4000,42 +4310,42 @@ var UserMessage = () => {
|
|
|
4000
4310
|
);
|
|
4001
4311
|
};
|
|
4002
4312
|
var UserActionBar = () => {
|
|
4003
|
-
return /* @__PURE__ */ (0,
|
|
4004
|
-
|
|
4313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4314
|
+
import_react30.ActionBarPrimitive.Root,
|
|
4005
4315
|
{
|
|
4006
4316
|
hideWhenRunning: true,
|
|
4007
4317
|
autohide: "always",
|
|
4008
4318
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
4009
|
-
children: /* @__PURE__ */ (0,
|
|
4319
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4010
4320
|
TooltipIconButton,
|
|
4011
4321
|
{
|
|
4012
4322
|
tooltip: "Edit",
|
|
4013
4323
|
variant: "ghost",
|
|
4014
4324
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4015
|
-
children: /* @__PURE__ */ (0,
|
|
4325
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.PencilIcon, { className: "size-3" })
|
|
4016
4326
|
}
|
|
4017
4327
|
) })
|
|
4018
4328
|
}
|
|
4019
4329
|
);
|
|
4020
4330
|
};
|
|
4021
4331
|
var EditComposer = () => {
|
|
4022
|
-
return /* @__PURE__ */ (0,
|
|
4023
|
-
/* @__PURE__ */ (0,
|
|
4024
|
-
|
|
4332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePrimitive.Root, { className: "aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-max-width) flex-col px-2 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_react30.ComposerPrimitive.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
4333
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4334
|
+
import_react30.ComposerPrimitive.Input,
|
|
4025
4335
|
{
|
|
4026
4336
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
4027
4337
|
autoFocus: true
|
|
4028
4338
|
}
|
|
4029
4339
|
),
|
|
4030
|
-
/* @__PURE__ */ (0,
|
|
4031
|
-
/* @__PURE__ */ (0,
|
|
4032
|
-
/* @__PURE__ */ (0,
|
|
4340
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
4341
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
4342
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
4033
4343
|
] })
|
|
4034
4344
|
] }) });
|
|
4035
4345
|
};
|
|
4036
4346
|
|
|
4037
4347
|
// src/chat/chat.tsx
|
|
4038
|
-
var
|
|
4348
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4039
4349
|
function TimbalChat({
|
|
4040
4350
|
workforceId,
|
|
4041
4351
|
baseUrl,
|
|
@@ -4046,7 +4356,7 @@ function TimbalChat({
|
|
|
4046
4356
|
debug,
|
|
4047
4357
|
...threadProps
|
|
4048
4358
|
}) {
|
|
4049
|
-
return /* @__PURE__ */ (0,
|
|
4359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4050
4360
|
TimbalRuntimeProvider,
|
|
4051
4361
|
{
|
|
4052
4362
|
workforceId,
|
|
@@ -4056,14 +4366,14 @@ function TimbalChat({
|
|
|
4056
4366
|
attachmentsUploadUrl,
|
|
4057
4367
|
attachmentsAccept,
|
|
4058
4368
|
debug,
|
|
4059
|
-
children: /* @__PURE__ */ (0,
|
|
4369
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Thread, { ...threadProps })
|
|
4060
4370
|
}
|
|
4061
4371
|
);
|
|
4062
4372
|
}
|
|
4063
4373
|
|
|
4064
4374
|
// src/chat/workforce-selector.tsx
|
|
4065
4375
|
var import_lucide_react9 = require("lucide-react");
|
|
4066
|
-
var
|
|
4376
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
4067
4377
|
var WorkforceSelector = ({
|
|
4068
4378
|
workforces,
|
|
4069
4379
|
value,
|
|
@@ -4074,7 +4384,7 @@ var WorkforceSelector = ({
|
|
|
4074
4384
|
}) => {
|
|
4075
4385
|
if (workforces.length === 0) return null;
|
|
4076
4386
|
if (hideWhenSingle && workforces.length === 1) return null;
|
|
4077
|
-
return /* @__PURE__ */ (0,
|
|
4387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
4078
4388
|
"div",
|
|
4079
4389
|
{
|
|
4080
4390
|
className: cn(
|
|
@@ -4085,7 +4395,7 @@ var WorkforceSelector = ({
|
|
|
4085
4395
|
className
|
|
4086
4396
|
),
|
|
4087
4397
|
children: [
|
|
4088
|
-
/* @__PURE__ */ (0,
|
|
4398
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
4089
4399
|
"select",
|
|
4090
4400
|
{
|
|
4091
4401
|
className: "aui-workforce-selector-input h-full cursor-pointer appearance-none rounded-full border-none bg-transparent pr-8 pl-3.5 text-sm font-medium text-foreground outline-none focus:outline-none",
|
|
@@ -4093,15 +4403,15 @@ var WorkforceSelector = ({
|
|
|
4093
4403
|
onChange: (e) => onChange(e.target.value),
|
|
4094
4404
|
"aria-label": placeholder,
|
|
4095
4405
|
children: [
|
|
4096
|
-
!value && /* @__PURE__ */ (0,
|
|
4406
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: "", children: placeholder }),
|
|
4097
4407
|
workforces.map((w) => {
|
|
4098
4408
|
const id = idOf(w);
|
|
4099
|
-
return /* @__PURE__ */ (0,
|
|
4409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: id, children: w.name ?? id }, id);
|
|
4100
4410
|
})
|
|
4101
4411
|
]
|
|
4102
4412
|
}
|
|
4103
4413
|
),
|
|
4104
|
-
/* @__PURE__ */ (0,
|
|
4414
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4105
4415
|
import_lucide_react9.ChevronDownIcon,
|
|
4106
4416
|
{
|
|
4107
4417
|
className: "aui-workforce-selector-icon pointer-events-none absolute right-3 size-3.5 text-muted-foreground/70",
|
|
@@ -4117,22 +4427,22 @@ function idOf(item) {
|
|
|
4117
4427
|
}
|
|
4118
4428
|
|
|
4119
4429
|
// src/hooks/use-workforces.ts
|
|
4120
|
-
var
|
|
4430
|
+
var import_react32 = require("react");
|
|
4121
4431
|
function useWorkforces(options = {}) {
|
|
4122
4432
|
const { baseUrl = "/api", fetch: fetchFn, pickInitial, enabled = true } = options;
|
|
4123
|
-
const [workforces, setWorkforces] = (0,
|
|
4124
|
-
const [selectedId, setSelectedId] = (0,
|
|
4125
|
-
const [isLoading, setIsLoading] = (0,
|
|
4126
|
-
const [error, setError] = (0,
|
|
4127
|
-
const fetchFnRef = (0,
|
|
4128
|
-
(0,
|
|
4433
|
+
const [workforces, setWorkforces] = (0, import_react32.useState)([]);
|
|
4434
|
+
const [selectedId, setSelectedId] = (0, import_react32.useState)("");
|
|
4435
|
+
const [isLoading, setIsLoading] = (0, import_react32.useState)(enabled);
|
|
4436
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
4437
|
+
const fetchFnRef = (0, import_react32.useRef)(fetchFn ?? authFetch);
|
|
4438
|
+
(0, import_react32.useEffect)(() => {
|
|
4129
4439
|
fetchFnRef.current = fetchFn ?? authFetch;
|
|
4130
4440
|
}, [fetchFn]);
|
|
4131
|
-
const pickInitialRef = (0,
|
|
4132
|
-
(0,
|
|
4441
|
+
const pickInitialRef = (0, import_react32.useRef)(pickInitial);
|
|
4442
|
+
(0, import_react32.useEffect)(() => {
|
|
4133
4443
|
pickInitialRef.current = pickInitial;
|
|
4134
4444
|
}, [pickInitial]);
|
|
4135
|
-
const load = (0,
|
|
4445
|
+
const load = (0, import_react32.useMemo)(() => {
|
|
4136
4446
|
return async () => {
|
|
4137
4447
|
if (!enabled) {
|
|
4138
4448
|
setIsLoading(false);
|
|
@@ -4157,10 +4467,10 @@ function useWorkforces(options = {}) {
|
|
|
4157
4467
|
}
|
|
4158
4468
|
};
|
|
4159
4469
|
}, [baseUrl, enabled]);
|
|
4160
|
-
(0,
|
|
4470
|
+
(0, import_react32.useEffect)(() => {
|
|
4161
4471
|
load();
|
|
4162
4472
|
}, [load]);
|
|
4163
|
-
const selected = (0,
|
|
4473
|
+
const selected = (0, import_react32.useMemo)(
|
|
4164
4474
|
() => workforces.find((w) => idOf2(w) === selectedId),
|
|
4165
4475
|
[workforces, selectedId]
|
|
4166
4476
|
);
|
|
@@ -4212,7 +4522,9 @@ var studioChromeShellStyle = {
|
|
|
4212
4522
|
"--studio-inset-left-collapsed": SIDEBAR_INSET_COLLAPSED
|
|
4213
4523
|
};
|
|
4214
4524
|
var STORAGE_KEYS = {
|
|
4215
|
-
sidebarCollapsed: "timbal-studio-sidebar-collapsed"
|
|
4525
|
+
sidebarCollapsed: "timbal-studio-sidebar-collapsed",
|
|
4526
|
+
/** Used by `ModeToggle` in uncontrolled mode (`localStorage`). */
|
|
4527
|
+
theme: "timbal-theme"
|
|
4216
4528
|
};
|
|
4217
4529
|
var DOM_IDS = {
|
|
4218
4530
|
sidebarRuntimeAnchor: "timbal-studio-sidebar-runtime-anchor",
|
|
@@ -4220,7 +4532,7 @@ var DOM_IDS = {
|
|
|
4220
4532
|
};
|
|
4221
4533
|
|
|
4222
4534
|
// src/studio/shell/chat-shell.tsx
|
|
4223
|
-
var
|
|
4535
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
4224
4536
|
var TimbalChatShell = ({
|
|
4225
4537
|
workforceId,
|
|
4226
4538
|
brand,
|
|
@@ -4238,7 +4550,7 @@ var TimbalChatShell = ({
|
|
|
4238
4550
|
});
|
|
4239
4551
|
const effectiveId = workforceId ?? selectedId;
|
|
4240
4552
|
const showSelector = !hideWorkforceSelector && !workforceId && workforces.length > 0;
|
|
4241
|
-
return /* @__PURE__ */ (0,
|
|
4553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
4242
4554
|
"div",
|
|
4243
4555
|
{
|
|
4244
4556
|
className: cn(
|
|
@@ -4247,7 +4559,7 @@ var TimbalChatShell = ({
|
|
|
4247
4559
|
),
|
|
4248
4560
|
style: studioChromeShellStyle,
|
|
4249
4561
|
children: [
|
|
4250
|
-
/* @__PURE__ */ (0,
|
|
4562
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4251
4563
|
"div",
|
|
4252
4564
|
{
|
|
4253
4565
|
className: cn(
|
|
@@ -4257,7 +4569,7 @@ var TimbalChatShell = ({
|
|
|
4257
4569
|
"aria-hidden": true
|
|
4258
4570
|
}
|
|
4259
4571
|
),
|
|
4260
|
-
/* @__PURE__ */ (0,
|
|
4572
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
4261
4573
|
"header",
|
|
4262
4574
|
{
|
|
4263
4575
|
className: cn(
|
|
@@ -4266,9 +4578,9 @@ var TimbalChatShell = ({
|
|
|
4266
4578
|
),
|
|
4267
4579
|
style: { minHeight: "var(--studio-topbar-height)" },
|
|
4268
4580
|
children: [
|
|
4269
|
-
/* @__PURE__ */ (0,
|
|
4581
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
4270
4582
|
brand,
|
|
4271
|
-
showSelector && /* @__PURE__ */ (0,
|
|
4583
|
+
showSelector && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4272
4584
|
WorkforceSelector,
|
|
4273
4585
|
{
|
|
4274
4586
|
workforces,
|
|
@@ -4277,11 +4589,11 @@ var TimbalChatShell = ({
|
|
|
4277
4589
|
}
|
|
4278
4590
|
)
|
|
4279
4591
|
] }),
|
|
4280
|
-
/* @__PURE__ */ (0,
|
|
4592
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex shrink-0 items-center gap-1", children: headerActions })
|
|
4281
4593
|
]
|
|
4282
4594
|
}
|
|
4283
4595
|
),
|
|
4284
|
-
/* @__PURE__ */ (0,
|
|
4596
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4285
4597
|
TimbalChat,
|
|
4286
4598
|
{
|
|
4287
4599
|
workforceId: effectiveId,
|
|
@@ -4298,9 +4610,9 @@ var TimbalChatShell = ({
|
|
|
4298
4610
|
};
|
|
4299
4611
|
|
|
4300
4612
|
// src/studio/shell/studio-shell.tsx
|
|
4301
|
-
var
|
|
4613
|
+
var import_react47 = require("react");
|
|
4302
4614
|
var import_lucide_react13 = require("lucide-react");
|
|
4303
|
-
var
|
|
4615
|
+
var import_react48 = require("motion/react");
|
|
4304
4616
|
|
|
4305
4617
|
// src/design/sidebar-motion.ts
|
|
4306
4618
|
var STUDIO_SIDEBAR_EASE_ENTER = [0, 0, 0.2, 1];
|
|
@@ -4371,16 +4683,16 @@ function studioSidebarBackdropTransition(reduced) {
|
|
|
4371
4683
|
}
|
|
4372
4684
|
|
|
4373
4685
|
// src/hooks/use-sidebar-collapse-phase.ts
|
|
4374
|
-
var
|
|
4686
|
+
var import_react33 = require("react");
|
|
4375
4687
|
var WIDTH_OVERLAP_FRAC = 0.7;
|
|
4376
4688
|
function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
4377
|
-
const [widthCollapsed, setWidthCollapsed] = (0,
|
|
4378
|
-
const [entriesVisible, setEntriesVisible] = (0,
|
|
4379
|
-
const collapsedTarget = (0,
|
|
4380
|
-
const isFirstRender = (0,
|
|
4381
|
-
const widthTimerRef = (0,
|
|
4382
|
-
const revealTimerRef = (0,
|
|
4383
|
-
(0,
|
|
4689
|
+
const [widthCollapsed, setWidthCollapsed] = (0, import_react33.useState)(collapsed);
|
|
4690
|
+
const [entriesVisible, setEntriesVisible] = (0, import_react33.useState)(true);
|
|
4691
|
+
const collapsedTarget = (0, import_react33.useRef)(collapsed);
|
|
4692
|
+
const isFirstRender = (0, import_react33.useRef)(true);
|
|
4693
|
+
const widthTimerRef = (0, import_react33.useRef)(null);
|
|
4694
|
+
const revealTimerRef = (0, import_react33.useRef)(null);
|
|
4695
|
+
(0, import_react33.useEffect)(() => {
|
|
4384
4696
|
collapsedTarget.current = collapsed;
|
|
4385
4697
|
}, [collapsed]);
|
|
4386
4698
|
const clearWidthTimer = () => {
|
|
@@ -4395,7 +4707,7 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4395
4707
|
revealTimerRef.current = null;
|
|
4396
4708
|
}
|
|
4397
4709
|
};
|
|
4398
|
-
const applyWidthTarget = (0,
|
|
4710
|
+
const applyWidthTarget = (0, import_react33.useCallback)(() => {
|
|
4399
4711
|
const willExpand = !collapsedTarget.current;
|
|
4400
4712
|
setWidthCollapsed(collapsedTarget.current);
|
|
4401
4713
|
clearRevealTimer();
|
|
@@ -4406,7 +4718,7 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4406
4718
|
);
|
|
4407
4719
|
}
|
|
4408
4720
|
}, [reducedMotion]);
|
|
4409
|
-
(0,
|
|
4721
|
+
(0, import_react33.useEffect)(() => {
|
|
4410
4722
|
clearWidthTimer();
|
|
4411
4723
|
clearRevealTimer();
|
|
4412
4724
|
if (reducedMotion) {
|
|
@@ -4430,10 +4742,10 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4430
4742
|
clearRevealTimer();
|
|
4431
4743
|
};
|
|
4432
4744
|
}, [collapsed, reducedMotion, applyWidthTarget]);
|
|
4433
|
-
const onEntriesBlurOutComplete = (0,
|
|
4745
|
+
const onEntriesBlurOutComplete = (0, import_react33.useCallback)(() => {
|
|
4434
4746
|
applyWidthTarget();
|
|
4435
4747
|
}, [applyWidthTarget]);
|
|
4436
|
-
const onPanelWidthComplete = (0,
|
|
4748
|
+
const onPanelWidthComplete = (0, import_react33.useCallback)(() => {
|
|
4437
4749
|
clearRevealTimer();
|
|
4438
4750
|
setEntriesVisible(true);
|
|
4439
4751
|
}, []);
|
|
@@ -4448,15 +4760,15 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4448
4760
|
}
|
|
4449
4761
|
|
|
4450
4762
|
// src/studio/sidebar/sidebar-backdrop.tsx
|
|
4451
|
-
var
|
|
4452
|
-
var
|
|
4763
|
+
var import_react34 = require("motion/react");
|
|
4764
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4453
4765
|
var StudioSidebarBackdrop = ({
|
|
4454
4766
|
open,
|
|
4455
4767
|
onClose
|
|
4456
4768
|
}) => {
|
|
4457
|
-
const reducedMotion = (0,
|
|
4458
|
-
return /* @__PURE__ */ (0,
|
|
4459
|
-
|
|
4769
|
+
const reducedMotion = (0, import_react34.useReducedMotion)();
|
|
4770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react34.AnimatePresence, { children: open ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4771
|
+
import_react34.motion.button,
|
|
4460
4772
|
{
|
|
4461
4773
|
type: "button",
|
|
4462
4774
|
className: "fixed inset-0 z-40 bg-foreground/30 backdrop-blur-[2px] md:hidden",
|
|
@@ -4471,36 +4783,36 @@ var StudioSidebarBackdrop = ({
|
|
|
4471
4783
|
};
|
|
4472
4784
|
|
|
4473
4785
|
// src/studio/sidebar/sidebar-context.tsx
|
|
4474
|
-
var
|
|
4475
|
-
var StudioSidebarContext = (0,
|
|
4786
|
+
var import_react35 = require("react");
|
|
4787
|
+
var StudioSidebarContext = (0, import_react35.createContext)({
|
|
4476
4788
|
collapsed: false,
|
|
4477
4789
|
isMobile: false,
|
|
4478
4790
|
isCollapsedRail: false,
|
|
4479
4791
|
iconOnlyLayout: false
|
|
4480
4792
|
});
|
|
4481
4793
|
function useStudioSidebarLayout() {
|
|
4482
|
-
return (0,
|
|
4794
|
+
return (0, import_react35.useContext)(StudioSidebarContext);
|
|
4483
4795
|
}
|
|
4484
4796
|
|
|
4485
4797
|
// src/studio/sidebar/sidebar.tsx
|
|
4486
|
-
var
|
|
4487
|
-
var
|
|
4798
|
+
var import_react41 = require("react");
|
|
4799
|
+
var import_react42 = require("motion/react");
|
|
4488
4800
|
|
|
4489
4801
|
// src/studio/sidebar/sidebar-entries.tsx
|
|
4490
|
-
var
|
|
4491
|
-
var
|
|
4802
|
+
var import_react36 = require("motion/react");
|
|
4803
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4492
4804
|
var StudioSidebarEntries = ({
|
|
4493
4805
|
visible,
|
|
4494
4806
|
onBlurOutComplete,
|
|
4495
4807
|
children,
|
|
4496
4808
|
className
|
|
4497
4809
|
}) => {
|
|
4498
|
-
const reducedMotion = (0,
|
|
4810
|
+
const reducedMotion = (0, import_react36.useReducedMotion)();
|
|
4499
4811
|
if (reducedMotion) {
|
|
4500
|
-
return visible ? /* @__PURE__ */ (0,
|
|
4812
|
+
return visible ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn("flex min-h-0 flex-1 flex-col", className), children }) : null;
|
|
4501
4813
|
}
|
|
4502
|
-
return /* @__PURE__ */ (0,
|
|
4503
|
-
|
|
4814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4815
|
+
import_react36.motion.div,
|
|
4504
4816
|
{
|
|
4505
4817
|
className: cn("flex min-h-0 flex-1 flex-col", className),
|
|
4506
4818
|
initial: false,
|
|
@@ -4523,11 +4835,11 @@ var StudioSidebarEntries = ({
|
|
|
4523
4835
|
var import_lucide_react10 = require("lucide-react");
|
|
4524
4836
|
|
|
4525
4837
|
// src/auth/provider.tsx
|
|
4526
|
-
var
|
|
4527
|
-
var
|
|
4528
|
-
var SessionContext = (0,
|
|
4838
|
+
var import_react37 = require("react");
|
|
4839
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4840
|
+
var SessionContext = (0, import_react37.createContext)(void 0);
|
|
4529
4841
|
var useOptionalSession = () => {
|
|
4530
|
-
const context = (0,
|
|
4842
|
+
const context = (0, import_react37.useContext)(SessionContext);
|
|
4531
4843
|
return context ?? null;
|
|
4532
4844
|
};
|
|
4533
4845
|
|
|
@@ -4554,35 +4866,35 @@ function studioSidebarNavItemClasses(iconOnly, isActive) {
|
|
|
4554
4866
|
}
|
|
4555
4867
|
|
|
4556
4868
|
// src/studio/sidebar/sidebar-entry-motion.tsx
|
|
4557
|
-
var
|
|
4558
|
-
var
|
|
4869
|
+
var import_react38 = require("motion/react");
|
|
4870
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4559
4871
|
var StudioSidebarEntryMotion = ({
|
|
4560
4872
|
children,
|
|
4561
4873
|
className
|
|
4562
4874
|
}) => {
|
|
4563
|
-
const reducedMotion = (0,
|
|
4875
|
+
const reducedMotion = (0, import_react38.useReducedMotion)();
|
|
4564
4876
|
if (reducedMotion) {
|
|
4565
|
-
return /* @__PURE__ */ (0,
|
|
4877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className, children });
|
|
4566
4878
|
}
|
|
4567
|
-
return /* @__PURE__ */ (0,
|
|
4879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react38.motion.div, { variants: studioSidebarEntryItemVariants, className: cn(className), children });
|
|
4568
4880
|
};
|
|
4569
4881
|
|
|
4570
4882
|
// src/studio/sidebar/sidebar-tooltip.tsx
|
|
4571
|
-
var
|
|
4883
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4572
4884
|
var StudioSidebarTooltip = ({
|
|
4573
4885
|
label,
|
|
4574
4886
|
enabled,
|
|
4575
4887
|
children
|
|
4576
4888
|
}) => {
|
|
4577
|
-
if (!enabled) return /* @__PURE__ */ (0,
|
|
4578
|
-
return /* @__PURE__ */ (0,
|
|
4579
|
-
/* @__PURE__ */ (0,
|
|
4580
|
-
/* @__PURE__ */ (0,
|
|
4889
|
+
if (!enabled) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
|
4890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Tooltip, { children: [
|
|
4891
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipTrigger, { asChild: true, children }),
|
|
4892
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipContent, { side: "right", className: "text-xs", children: label })
|
|
4581
4893
|
] });
|
|
4582
4894
|
};
|
|
4583
4895
|
|
|
4584
4896
|
// src/studio/sidebar/sidebar-footer.tsx
|
|
4585
|
-
var
|
|
4897
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4586
4898
|
function userInitials(name, email) {
|
|
4587
4899
|
const fromName = name.trim().split(/\s+/).map((part) => part.charAt(0)).join("").slice(0, 2).toUpperCase();
|
|
4588
4900
|
if (fromName) return fromName;
|
|
@@ -4600,32 +4912,32 @@ var StudioSidebarFooter = ({
|
|
|
4600
4912
|
session?.logout();
|
|
4601
4913
|
onSignOut?.();
|
|
4602
4914
|
};
|
|
4603
|
-
return /* @__PURE__ */ (0,
|
|
4915
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StudioSidebarEntryMotion, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4604
4916
|
"footer",
|
|
4605
4917
|
{
|
|
4606
4918
|
className: cn(
|
|
4607
4919
|
"mt-auto w-full shrink-0 py-2.5",
|
|
4608
4920
|
iconOnlyLayout ? studioSidebarCollapsedRailInsetClass : "px-2.5"
|
|
4609
4921
|
),
|
|
4610
|
-
children: user ? /* @__PURE__ */ (0,
|
|
4611
|
-
iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
4612
|
-
user.user_photo_url ? /* @__PURE__ */ (0,
|
|
4613
|
-
/* @__PURE__ */ (0,
|
|
4614
|
-
] }) }) : /* @__PURE__ */ (0,
|
|
4615
|
-
/* @__PURE__ */ (0,
|
|
4616
|
-
user.user_photo_url ? /* @__PURE__ */ (0,
|
|
4617
|
-
/* @__PURE__ */ (0,
|
|
4922
|
+
children: user ? /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
4923
|
+
iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: studioSidebarCollapsedRailChipRowClass, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Avatar, { size: "sm", className: "size-8", children: [
|
|
4924
|
+
user.user_photo_url ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarImage, { src: user.user_photo_url, alt: user.user_name }) : null,
|
|
4925
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarFallback, { className: "text-[10px]", children: userInitials(user.user_name, user.user_email) })
|
|
4926
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex min-w-0 items-center gap-2.5", children: [
|
|
4927
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Avatar, { size: "sm", children: [
|
|
4928
|
+
user.user_photo_url ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarImage, { src: user.user_photo_url, alt: user.user_name }) : null,
|
|
4929
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarFallback, { children: userInitials(user.user_name, user.user_email) })
|
|
4618
4930
|
] }),
|
|
4619
|
-
/* @__PURE__ */ (0,
|
|
4620
|
-
/* @__PURE__ */ (0,
|
|
4621
|
-
/* @__PURE__ */ (0,
|
|
4931
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
4932
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "truncate text-sm font-medium text-foreground", children: user.user_name }),
|
|
4933
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "truncate text-xs text-muted-foreground", children: user.user_email })
|
|
4622
4934
|
] })
|
|
4623
4935
|
] }),
|
|
4624
|
-
/* @__PURE__ */ (0,
|
|
4936
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4625
4937
|
"div",
|
|
4626
4938
|
{
|
|
4627
4939
|
className: iconOnlyLayout ? studioSidebarCollapsedRailChipRowClass : void 0,
|
|
4628
|
-
children: /* @__PURE__ */ (0,
|
|
4940
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StudioSidebarTooltip, { label: "Sign out", enabled: showTooltips, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4629
4941
|
"button",
|
|
4630
4942
|
{
|
|
4631
4943
|
type: "button",
|
|
@@ -4636,28 +4948,28 @@ var StudioSidebarFooter = ({
|
|
|
4636
4948
|
),
|
|
4637
4949
|
"aria-label": "Sign out",
|
|
4638
4950
|
children: [
|
|
4639
|
-
/* @__PURE__ */ (0,
|
|
4951
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react10.LogOut, { className: "size-3.5 shrink-0" }),
|
|
4640
4952
|
!iconOnlyLayout ? "Sign out" : null
|
|
4641
4953
|
]
|
|
4642
4954
|
}
|
|
4643
4955
|
) })
|
|
4644
4956
|
}
|
|
4645
4957
|
)
|
|
4646
|
-
] }) : !iconOnlyLayout && emptyCaption ? /* @__PURE__ */ (0,
|
|
4958
|
+
] }) : !iconOnlyLayout && emptyCaption ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: emptyCaption }) : null
|
|
4647
4959
|
}
|
|
4648
4960
|
) });
|
|
4649
4961
|
};
|
|
4650
4962
|
|
|
4651
4963
|
// src/studio/sidebar/sidebar-header.tsx
|
|
4652
4964
|
var import_lucide_react11 = require("lucide-react");
|
|
4653
|
-
var
|
|
4965
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4654
4966
|
var sidebarHeaderClass = "flex h-12 shrink-0 items-center px-2";
|
|
4655
4967
|
var toggleButtonClass = cn(
|
|
4656
4968
|
"flex shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors",
|
|
4657
4969
|
"hover:bg-muted hover:text-foreground",
|
|
4658
4970
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/15"
|
|
4659
4971
|
);
|
|
4660
|
-
var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__PURE__ */ (0,
|
|
4972
|
+
var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4661
4973
|
"button",
|
|
4662
4974
|
{
|
|
4663
4975
|
type: "button",
|
|
@@ -4671,7 +4983,7 @@ var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__
|
|
|
4671
4983
|
var CollapsedBrandToggle = ({
|
|
4672
4984
|
onExpand,
|
|
4673
4985
|
brand
|
|
4674
|
-
}) => /* @__PURE__ */ (0,
|
|
4986
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: studioSidebarCollapsedRailChipRowClass, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(StudioSidebarTooltip, { label: "Expand sidebar", enabled: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
4675
4987
|
"button",
|
|
4676
4988
|
{
|
|
4677
4989
|
type: "button",
|
|
@@ -4683,7 +4995,7 @@ var CollapsedBrandToggle = ({
|
|
|
4683
4995
|
"group relative inline-flex size-8 items-center justify-center overflow-hidden rounded-lg"
|
|
4684
4996
|
),
|
|
4685
4997
|
children: [
|
|
4686
|
-
/* @__PURE__ */ (0,
|
|
4998
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4687
4999
|
"span",
|
|
4688
5000
|
{
|
|
4689
5001
|
"aria-hidden": true,
|
|
@@ -4695,7 +5007,7 @@ var CollapsedBrandToggle = ({
|
|
|
4695
5007
|
children: brand
|
|
4696
5008
|
}
|
|
4697
5009
|
),
|
|
4698
|
-
/* @__PURE__ */ (0,
|
|
5010
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4699
5011
|
import_lucide_react11.ChevronRight,
|
|
4700
5012
|
{
|
|
4701
5013
|
"aria-hidden": true,
|
|
@@ -4717,40 +5029,40 @@ var StudioSidebarHeader = ({
|
|
|
4717
5029
|
brand
|
|
4718
5030
|
}) => {
|
|
4719
5031
|
if (isMobile) {
|
|
4720
|
-
return /* @__PURE__ */ (0,
|
|
5032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("header", { className: cn(sidebarHeaderClass, "justify-between gap-2 pr-2"), children: [
|
|
4721
5033
|
brand,
|
|
4722
|
-
/* @__PURE__ */ (0,
|
|
5034
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4723
5035
|
SidebarToggleButton,
|
|
4724
5036
|
{
|
|
4725
5037
|
ariaLabel: "Close menu",
|
|
4726
5038
|
expanded: mobileOpen,
|
|
4727
5039
|
onClick: onToggle,
|
|
4728
|
-
children: /* @__PURE__ */ (0,
|
|
5040
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react11.X, { className: "size-3.5" })
|
|
4729
5041
|
}
|
|
4730
5042
|
)
|
|
4731
5043
|
] });
|
|
4732
5044
|
}
|
|
4733
5045
|
if (isCollapsedRail) {
|
|
4734
|
-
return /* @__PURE__ */ (0,
|
|
5046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4735
5047
|
"header",
|
|
4736
5048
|
{
|
|
4737
5049
|
className: cn(
|
|
4738
5050
|
"flex h-12 shrink-0 items-center",
|
|
4739
5051
|
studioSidebarCollapsedRailInsetClass
|
|
4740
5052
|
),
|
|
4741
|
-
children: /* @__PURE__ */ (0,
|
|
5053
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CollapsedBrandToggle, { onExpand: onToggle, brand })
|
|
4742
5054
|
}
|
|
4743
5055
|
);
|
|
4744
5056
|
}
|
|
4745
|
-
return /* @__PURE__ */ (0,
|
|
5057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("header", { className: cn(sidebarHeaderClass, "justify-between gap-1 pr-2"), children: [
|
|
4746
5058
|
brand,
|
|
4747
|
-
/* @__PURE__ */ (0,
|
|
5059
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4748
5060
|
SidebarToggleButton,
|
|
4749
5061
|
{
|
|
4750
5062
|
ariaLabel: "Collapse sidebar",
|
|
4751
5063
|
expanded: true,
|
|
4752
5064
|
onClick: onToggle,
|
|
4753
|
-
children: /* @__PURE__ */ (0,
|
|
5065
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react11.ChevronLeft, { className: "size-4" })
|
|
4754
5066
|
}
|
|
4755
5067
|
)
|
|
4756
5068
|
] });
|
|
@@ -4769,7 +5081,7 @@ function workforceItemInitial(w) {
|
|
|
4769
5081
|
}
|
|
4770
5082
|
|
|
4771
5083
|
// src/studio/sidebar/sidebar-nav.tsx
|
|
4772
|
-
var
|
|
5084
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4773
5085
|
var StudioSidebarNav = ({
|
|
4774
5086
|
workforces,
|
|
4775
5087
|
selectedId,
|
|
@@ -4778,7 +5090,7 @@ var StudioSidebarNav = ({
|
|
|
4778
5090
|
showTooltips
|
|
4779
5091
|
}) => {
|
|
4780
5092
|
if (workforces.length === 0) return null;
|
|
4781
|
-
return /* @__PURE__ */ (0,
|
|
5093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4782
5094
|
"nav",
|
|
4783
5095
|
{
|
|
4784
5096
|
className: cn(
|
|
@@ -4790,11 +5102,11 @@ var StudioSidebarNav = ({
|
|
|
4790
5102
|
const id = workforceItemId(w);
|
|
4791
5103
|
const isActive = id === selectedId;
|
|
4792
5104
|
const label = workforceItemLabel(w);
|
|
4793
|
-
return /* @__PURE__ */ (0,
|
|
5105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4794
5106
|
StudioSidebarEntryMotion,
|
|
4795
5107
|
{
|
|
4796
5108
|
className: iconOnlyLayout ? studioSidebarCollapsedRailChipRowClass : void 0,
|
|
4797
|
-
children: /* @__PURE__ */ (0,
|
|
5109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(StudioSidebarTooltip, { label, enabled: showTooltips, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4798
5110
|
"button",
|
|
4799
5111
|
{
|
|
4800
5112
|
type: "button",
|
|
@@ -4805,7 +5117,7 @@ var StudioSidebarNav = ({
|
|
|
4805
5117
|
studioSidebarNavItemClasses(iconOnlyLayout, isActive),
|
|
4806
5118
|
iconOnlyLayout && "inline-flex"
|
|
4807
5119
|
),
|
|
4808
|
-
children: iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5120
|
+
children: iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-xs font-semibold leading-none", children: workforceItemInitial(w) }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "min-w-0 truncate", children: label })
|
|
4809
5121
|
}
|
|
4810
5122
|
) })
|
|
4811
5123
|
},
|
|
@@ -4818,7 +5130,7 @@ var StudioSidebarNav = ({
|
|
|
4818
5130
|
|
|
4819
5131
|
// src/studio/sidebar/timbal-mark.tsx
|
|
4820
5132
|
var import_shaders_react = require("@paper-design/shaders-react");
|
|
4821
|
-
var
|
|
5133
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4822
5134
|
var DEFAULT_SIZE = 64;
|
|
4823
5135
|
var TRANSPARENT_BACK = "#00000000";
|
|
4824
5136
|
var TIMBAL_SYMBOL_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAH6ElEQVR4Aeyci7EcNRBFFxIBIgEygUiASCATyASIBOa4rFrZntmPPq1W93218o5nZyTd26dbmnX5fX3TjxyY4IDAmmCqurzdBJYomOKAwJpiqzoVWGJgigMCa4qt6lRgZWHAWKfAMjY8y3ACK0ukjXUKLGPDswwnsLJE2linwDI2PMtwAitLpI11Cixjw+/DxT4SWLHju0ydwHrP+p/euzzE1T8cKr492lsvgfWaXZj733Hp90fL9Pr1EPvn0QTWYcLoF8bS6Pdf/kjQAAnNv7RqVcW6do4q9ffxMe/HW5oXy323boF1zkvzEnDe3RZnS5X6fcRsBdbdRY6oTl1LAJ1s2NDdXaVq3QLr7kapUph8Pxv/iESiDVUqsG63sgQ0b1Rve/6QQEOrVG1DdrCGbFRrQzc5Zh9FlSKppkw5M1gYi8FTjHXaaalSJNTUKWYEC3P5spP3qeY667zsIadVqVpvNrCoUrTag+jHgIRm0z2ka7AGRpzqNG2jOnCeo7uiSi3RnQEszCVjydzRgfPaH1rRbFqlajMig0WVWmpubbThMRvzJVWq1hgVrFKlgKvWG/2YRHLxpBsNrOVLwCJySSBXT7qRwHKxBCwAiypFWzD09ZARwCpVysUScG318E+oUsv3Uleq3gPrqpd1512bO9GWsockqSYO0971zmBR/mnt6ve7k0RC87KvEV61bEewMNftEvCq8Q3XlSqF/obbbW/ZDSz2UWSs2yVgQvjQimb3VarWvgtYZCnm8uRXzz/6MXq3rM47gLXVEjCI9FKlqNCDurTtxjNYxdytloAB4aM6r65S3TK8grXtEtAZEZZ7Wmc362/3BlapUtsuAY0hDVGlau2ewApnbm30g+OyhySpHly210dewKL80/Zyr2+2JBKaQ+4hV4OFudtvVBv4KlUK/Q23+79lJVjso8jYUEvAk5CjFc0hq1StfQVYZCnm8uRXzyX6MXqbq/Nu5liDFX4JOAGgVCkq9MnHMU9ZgVXMDb8EfIYJ1TlNlaq1W4BFlcpoLss9rfY7zfFMsFSl0mD0pdBZYKXaqFa2so+iSpFU1el8hzPAwlgMzuQmeyl0k1ARdf/zrqiRYGGuq/+C9K4Zb11/v5g9JFCh/342+dEosDCWlslOljs0Z3vSfSnGvWCRpRmf+KhSGXW/BBUX9YCFuWQsmUtfGdo3h0g0q0odRjx6tYAFSFnNZXNOlX7kqT47HGgB67jtJnNv+nnkQCtYj/rUZ3LgFggsRdOTAwLLUzQCzUVgBQqmJykCy1M0As1FYAUKpicpAstTNALNRWAFCqYnKTPB8qRTczF2QGAZG55lOIGVJdLGOgWWseFZhhNYWSJtrFNgGRueZTiBlSXSM3We9C2wTkzRqX4HBFa/h+rhxAGBdWKKTvU7ILD6PVQPJw4IrBNTdKrfAYHV76F6OHFAYJ2Ysv+p9QoE1voYhJyBwAoZ1vWiBNb6GIScgcAKGdb1ogTW+hiEnIHAChnW9aIElk0M0o0isNKF3EawwLLxOd0oAitdyN8W/Ndxx9LfmnyMH/aFuX+EVXct7Lfjox+P9vZLFeu5ZcXcf59fGuYKKhRA8Xtmm0QJrGvbqFJd5l537foTKvN3xwzRf7y1vdKC9cSuUqW6zH0yhsePSaSfR0xMYH3qYvcS8Gl32/yNBPrqmC3vx1v/S2DdPRyyBNy72+aIKkUbOuEWsPg970MnsbizUqWGLAGLtbwzPNWpey91NWALWFd97Xh+qrmODSl7SJJqyjQzg0X5p00x1mmnJBKam79GeFVXRrAwd9oS8KrxC64rVQr904f3A9Z0qR8GYB9Fxk5bAj6M4usPtKJ5epWqZWcBiyzFXJ78av3Rj9G7pDpnAMt0CXBCaqlSVOglU4oMVjHXdAlYEsVPB6U6L6lS9TSigkWVWm5ubbTRMcs9zWi462GigaUqdR1r008igbVso2oasS8HYx9FlSKpvvx00ZkHYC2aUduwGIvBbXfveRd7KXSTUO4U7A4W5g79V3l3ETqfEHtIoEL/+RWLz+4MFsbSFltoOjzLHZrdP+nuCBZZmvGJjyVvG927gVWWADLXtFQsHAytVKmt9pC7gEWVwlz3S8BgANG9TZWqte8AVqlSmFzPPfoxiUSbrnPGAJ7BKkuAqtSMyE/u0ytYW21UB8aIfRRViqQa2K19Vx7BwlgMtndj3Ygs8+gmodbNYuDInsDCXH3ZOTC4K7vyAhbZSlvphfXYLHdoDrmHXA0WVWrLx+lOCnnSDa17JViYS8aSuZ1x2uZ2tKL5cZXaRs71RFeARZVKYe5ntrMxD12lar3WYJUqBVz1PKIfk0ipnnStwEqzBHyWISRQxifdmwVYqZaACiyqFK06ledwJlilSqVaAg50qFJp9lKH3tPXLLCymlv2kCTVqeFZTs4Ai/JPC+ThUykkEprDf43w1ImPF4wEC3MzLgGlSqH/o616GwUW+ygyNtMSgFY0q0qd5FEvWGQp5vLkd9J92FPozVidXw5oD1hZlwASiQr9sskZL2wBK+sSgO6UX3a2JEYrWCyBLePtfA/L387zN517C1imE7wYTKedOyCwnAdo1+kJrF0j53zeAst5gHadnsDaNXLO5y2wnAdo1+kJrF0j53zew8ByrlPTM3ZAYBkbnmU4gZUl0sY6BZax4VmGE1hZIm2sU2AZG55lOIGVJdLDdL7W0f8AAAD//x3VUCQAAAAGSURBVAMArsj7LTb9pqMAAAAASUVORK5CYII=";
|
|
@@ -4827,14 +5139,14 @@ function TimbalMark({
|
|
|
4827
5139
|
size = DEFAULT_SIZE,
|
|
4828
5140
|
src = TIMBAL_SYMBOL_DATA_URI
|
|
4829
5141
|
}) {
|
|
4830
|
-
return /* @__PURE__ */ (0,
|
|
5142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4831
5143
|
"div",
|
|
4832
5144
|
{
|
|
4833
5145
|
className: cn("relative shrink-0 bg-transparent", className),
|
|
4834
5146
|
style: { width: size, height: size },
|
|
4835
5147
|
role: "img",
|
|
4836
5148
|
"aria-label": "Timbal",
|
|
4837
|
-
children: /* @__PURE__ */ (0,
|
|
5149
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4838
5150
|
import_shaders_react.LiquidMetal,
|
|
4839
5151
|
{
|
|
4840
5152
|
width: size,
|
|
@@ -4866,14 +5178,14 @@ function TimbalMark({
|
|
|
4866
5178
|
}
|
|
4867
5179
|
|
|
4868
5180
|
// src/studio/sidebar/shell-inset-bridge-context.tsx
|
|
4869
|
-
var
|
|
5181
|
+
var import_react40 = require("react");
|
|
4870
5182
|
|
|
4871
5183
|
// src/layout/shell-inset-context.tsx
|
|
4872
|
-
var
|
|
4873
|
-
var ShellInsetContext = (0,
|
|
5184
|
+
var import_react39 = require("react");
|
|
5185
|
+
var ShellInsetContext = (0, import_react39.createContext)(null);
|
|
4874
5186
|
var ShellInsetProvider = ShellInsetContext.Provider;
|
|
4875
5187
|
function useShellInsetReporter() {
|
|
4876
|
-
return (0,
|
|
5188
|
+
return (0, import_react39.useContext)(ShellInsetContext);
|
|
4877
5189
|
}
|
|
4878
5190
|
|
|
4879
5191
|
// src/studio/sidebar/shell-inset-bridge-context.tsx
|
|
@@ -4882,7 +5194,7 @@ var StudioSidebarShellInsetBridge = ({
|
|
|
4882
5194
|
}) => {
|
|
4883
5195
|
const reportInset = useShellInsetReporter();
|
|
4884
5196
|
const { isMobile, isCollapsedRail } = useStudioSidebarLayout();
|
|
4885
|
-
(0,
|
|
5197
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
4886
5198
|
const insetPx = isMobile ? 0 : isCollapsedRail ? SIDEBAR_INSET_PX_COLLAPSED : SIDEBAR_INSET_PX_EXPANDED;
|
|
4887
5199
|
reportInset?.(insetPx);
|
|
4888
5200
|
onInsetChange?.(insetPx);
|
|
@@ -4891,7 +5203,7 @@ var StudioSidebarShellInsetBridge = ({
|
|
|
4891
5203
|
};
|
|
4892
5204
|
|
|
4893
5205
|
// src/studio/sidebar/sidebar.tsx
|
|
4894
|
-
var
|
|
5206
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4895
5207
|
var DEFAULT_BREAKPOINT_PX = 768;
|
|
4896
5208
|
function readPersistedCollapsed(key) {
|
|
4897
5209
|
if (!key || typeof window === "undefined") return false;
|
|
@@ -4924,7 +5236,7 @@ var StudioSidebarPanel = ({
|
|
|
4924
5236
|
brand,
|
|
4925
5237
|
emptyCaption = null
|
|
4926
5238
|
}) => {
|
|
4927
|
-
const reducedMotion = (0,
|
|
5239
|
+
const reducedMotion = (0, import_react42.useReducedMotion)();
|
|
4928
5240
|
const isCollapsedRail = widthCollapsed && !isMobile;
|
|
4929
5241
|
const iconOnlyLayout = studioSidebarIconOnlyLayout(isMobile, isCollapsedRail);
|
|
4930
5242
|
const isDrawerOpen = isMobile && mobileOpen;
|
|
@@ -4941,9 +5253,9 @@ var StudioSidebarPanel = ({
|
|
|
4941
5253
|
onCollapsedChange(!collapsed);
|
|
4942
5254
|
};
|
|
4943
5255
|
const panelWidthPx = isMobile ? SIDEBAR_MOBILE_PX : widthCollapsed ? SIDEBAR_WIDTH_COLLAPSED_PX : SIDEBAR_WIDTH_PX;
|
|
4944
|
-
const brandNode = brand ?? /* @__PURE__ */ (0,
|
|
4945
|
-
const panel = /* @__PURE__ */ (0,
|
|
4946
|
-
|
|
5256
|
+
const brandNode = brand ?? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TimbalMark, { size: 32 });
|
|
5257
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
5258
|
+
import_react42.motion.div,
|
|
4947
5259
|
{
|
|
4948
5260
|
"data-sidebar-collapsed": isCollapsedRail ? "" : void 0,
|
|
4949
5261
|
className: cn(
|
|
@@ -4957,7 +5269,7 @@ var StudioSidebarPanel = ({
|
|
|
4957
5269
|
style: { willChange: entriesVisible ? void 0 : "width" },
|
|
4958
5270
|
onAnimationComplete: isMobile || entriesVisible ? void 0 : () => onPanelWidthComplete(),
|
|
4959
5271
|
children: [
|
|
4960
|
-
/* @__PURE__ */ (0,
|
|
5272
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4961
5273
|
StudioSidebarHeader,
|
|
4962
5274
|
{
|
|
4963
5275
|
isCollapsedRail,
|
|
@@ -4967,13 +5279,13 @@ var StudioSidebarPanel = ({
|
|
|
4967
5279
|
brand: brandNode
|
|
4968
5280
|
}
|
|
4969
5281
|
),
|
|
4970
|
-
/* @__PURE__ */ (0,
|
|
5282
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
4971
5283
|
StudioSidebarEntries,
|
|
4972
5284
|
{
|
|
4973
5285
|
visible: entriesVisible,
|
|
4974
5286
|
onBlurOutComplete: onEntriesBlurOutComplete,
|
|
4975
5287
|
children: [
|
|
4976
|
-
/* @__PURE__ */ (0,
|
|
5288
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4977
5289
|
"div",
|
|
4978
5290
|
{
|
|
4979
5291
|
id: DOM_IDS.sidebarRuntimeAnchor,
|
|
@@ -4983,7 +5295,7 @@ var StudioSidebarPanel = ({
|
|
|
4983
5295
|
)
|
|
4984
5296
|
}
|
|
4985
5297
|
),
|
|
4986
|
-
/* @__PURE__ */ (0,
|
|
5298
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4987
5299
|
StudioSidebarNav,
|
|
4988
5300
|
{
|
|
4989
5301
|
workforces,
|
|
@@ -4993,8 +5305,8 @@ var StudioSidebarPanel = ({
|
|
|
4993
5305
|
showTooltips: isCollapsedRail
|
|
4994
5306
|
}
|
|
4995
5307
|
),
|
|
4996
|
-
workforces.length === 0 ? /* @__PURE__ */ (0,
|
|
4997
|
-
/* @__PURE__ */ (0,
|
|
5308
|
+
workforces.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "min-h-0 flex-1" }) : null,
|
|
5309
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4998
5310
|
StudioSidebarFooter,
|
|
4999
5311
|
{
|
|
5000
5312
|
iconOnlyLayout,
|
|
@@ -5010,8 +5322,8 @@ var StudioSidebarPanel = ({
|
|
|
5010
5322
|
}
|
|
5011
5323
|
);
|
|
5012
5324
|
if (isMobile) {
|
|
5013
|
-
return /* @__PURE__ */ (0,
|
|
5014
|
-
|
|
5325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5326
|
+
import_react42.motion.aside,
|
|
5015
5327
|
{
|
|
5016
5328
|
className: "fixed inset-y-0 left-0 z-[60] flex",
|
|
5017
5329
|
"aria-label": "Studio navigation",
|
|
@@ -5026,7 +5338,7 @@ var StudioSidebarPanel = ({
|
|
|
5026
5338
|
}
|
|
5027
5339
|
);
|
|
5028
5340
|
}
|
|
5029
|
-
return /* @__PURE__ */ (0,
|
|
5341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5030
5342
|
"aside",
|
|
5031
5343
|
{
|
|
5032
5344
|
className: "absolute inset-y-0 left-0 z-[60] flex py-[var(--studio-sidebar-gap)] pl-[var(--studio-sidebar-gap)]",
|
|
@@ -5048,51 +5360,51 @@ var StudioSidebar = ({
|
|
|
5048
5360
|
onMobileOpenChange: onMobileOpenChangeProp,
|
|
5049
5361
|
onInsetChange
|
|
5050
5362
|
}) => {
|
|
5051
|
-
const reducedMotion = (0,
|
|
5363
|
+
const reducedMotion = (0, import_react42.useReducedMotion)();
|
|
5052
5364
|
const fetched = useWorkforces({ enabled: workforcesProp === void 0 });
|
|
5053
5365
|
const workforces = workforcesProp ?? fetched.workforces;
|
|
5054
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
5366
|
+
const [internalSelected, setInternalSelected] = (0, import_react41.useState)(
|
|
5055
5367
|
selectedIdProp ?? ""
|
|
5056
5368
|
);
|
|
5057
|
-
(0,
|
|
5369
|
+
(0, import_react41.useEffect)(() => {
|
|
5058
5370
|
if (selectedIdProp !== void 0) return;
|
|
5059
5371
|
if (internalSelected) return;
|
|
5060
5372
|
const first = workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name;
|
|
5061
5373
|
if (first) setInternalSelected(first);
|
|
5062
5374
|
}, [workforces, selectedIdProp, internalSelected]);
|
|
5063
5375
|
const selectedId = selectedIdProp ?? internalSelected ?? workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name ?? "";
|
|
5064
|
-
const handleSelect = (0,
|
|
5376
|
+
const handleSelect = (0, import_react41.useCallback)(
|
|
5065
5377
|
(id) => {
|
|
5066
5378
|
if (selectedIdProp === void 0) setInternalSelected(id);
|
|
5067
5379
|
onSelect?.(id);
|
|
5068
5380
|
},
|
|
5069
5381
|
[selectedIdProp, onSelect]
|
|
5070
5382
|
);
|
|
5071
|
-
const [collapsed, setCollapsed] = (0,
|
|
5383
|
+
const [collapsed, setCollapsed] = (0, import_react41.useState)(() => {
|
|
5072
5384
|
const persisted = readPersistedCollapsed(persistKey);
|
|
5073
5385
|
return persisted || defaultCollapsed;
|
|
5074
5386
|
});
|
|
5075
|
-
const handleCollapsedChange = (0,
|
|
5387
|
+
const handleCollapsedChange = (0, import_react41.useCallback)(
|
|
5076
5388
|
(next) => {
|
|
5077
5389
|
setCollapsed(next);
|
|
5078
5390
|
writePersistedCollapsed(persistKey, next);
|
|
5079
5391
|
},
|
|
5080
5392
|
[persistKey]
|
|
5081
5393
|
);
|
|
5082
|
-
const [isMobile, setIsMobile] = (0,
|
|
5394
|
+
const [isMobile, setIsMobile] = (0, import_react41.useState)(() => {
|
|
5083
5395
|
if (typeof window === "undefined") return false;
|
|
5084
5396
|
return window.innerWidth < mobileBreakpointPx;
|
|
5085
5397
|
});
|
|
5086
|
-
(0,
|
|
5398
|
+
(0, import_react41.useEffect)(() => {
|
|
5087
5399
|
if (typeof window === "undefined") return;
|
|
5088
5400
|
const onResize = () => setIsMobile(window.innerWidth < mobileBreakpointPx);
|
|
5089
5401
|
onResize();
|
|
5090
5402
|
window.addEventListener("resize", onResize);
|
|
5091
5403
|
return () => window.removeEventListener("resize", onResize);
|
|
5092
5404
|
}, [mobileBreakpointPx]);
|
|
5093
|
-
const [internalMobileOpen, setInternalMobileOpen] = (0,
|
|
5405
|
+
const [internalMobileOpen, setInternalMobileOpen] = (0, import_react41.useState)(false);
|
|
5094
5406
|
const mobileOpen = mobileOpenProp ?? internalMobileOpen;
|
|
5095
|
-
const setMobileOpen = (0,
|
|
5407
|
+
const setMobileOpen = (0, import_react41.useCallback)(
|
|
5096
5408
|
(next) => {
|
|
5097
5409
|
if (mobileOpenProp === void 0) setInternalMobileOpen(next);
|
|
5098
5410
|
onMobileOpenChangeProp?.(next);
|
|
@@ -5109,7 +5421,7 @@ var StudioSidebar = ({
|
|
|
5109
5421
|
const entriesVisible = isMobile || phaseEntriesVisible;
|
|
5110
5422
|
const isCollapsedRail = widthCollapsed && !isMobile;
|
|
5111
5423
|
const iconOnlyLayout = studioSidebarIconOnlyLayout(isMobile, isCollapsedRail);
|
|
5112
|
-
const contextValue = (0,
|
|
5424
|
+
const contextValue = (0, import_react41.useMemo)(
|
|
5113
5425
|
() => ({
|
|
5114
5426
|
collapsed: effectiveCollapsed,
|
|
5115
5427
|
isMobile,
|
|
@@ -5118,9 +5430,9 @@ var StudioSidebar = ({
|
|
|
5118
5430
|
}),
|
|
5119
5431
|
[effectiveCollapsed, isMobile, isCollapsedRail, iconOnlyLayout]
|
|
5120
5432
|
);
|
|
5121
|
-
return /* @__PURE__ */ (0,
|
|
5122
|
-
/* @__PURE__ */ (0,
|
|
5123
|
-
/* @__PURE__ */ (0,
|
|
5433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(StudioSidebarContext.Provider, { value: contextValue, children: [
|
|
5434
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StudioSidebarShellInsetBridge, { onInsetChange }),
|
|
5435
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5124
5436
|
StudioSidebarPanel,
|
|
5125
5437
|
{
|
|
5126
5438
|
workforces,
|
|
@@ -5143,26 +5455,26 @@ var StudioSidebar = ({
|
|
|
5143
5455
|
};
|
|
5144
5456
|
|
|
5145
5457
|
// src/studio/sidebar/sidebar-runtime-portal.tsx
|
|
5146
|
-
var
|
|
5458
|
+
var import_react43 = require("react");
|
|
5147
5459
|
var import_react_dom = require("react-dom");
|
|
5148
5460
|
var import_lucide_react12 = require("lucide-react");
|
|
5149
|
-
var
|
|
5150
|
-
var
|
|
5461
|
+
var import_react44 = require("@assistant-ui/react");
|
|
5462
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
5151
5463
|
var StudioSidebarRuntimePortal = ({
|
|
5152
5464
|
label = "New chat"
|
|
5153
5465
|
}) => {
|
|
5154
5466
|
const { iconOnlyLayout } = useStudioSidebarLayout();
|
|
5155
|
-
const hasMessages = (0,
|
|
5467
|
+
const hasMessages = (0, import_react44.useThread)((s) => s.messages.length > 0);
|
|
5156
5468
|
const { clear } = useTimbalRuntime();
|
|
5157
|
-
const [anchor, setAnchor] = (0,
|
|
5158
|
-
const startNewChat = (0,
|
|
5469
|
+
const [anchor, setAnchor] = (0, import_react43.useState)(null);
|
|
5470
|
+
const startNewChat = (0, import_react43.useCallback)(() => {
|
|
5159
5471
|
clear();
|
|
5160
5472
|
}, [clear]);
|
|
5161
|
-
(0,
|
|
5473
|
+
(0, import_react43.useLayoutEffect)(() => {
|
|
5162
5474
|
setAnchor(document.getElementById(DOM_IDS.sidebarRuntimeAnchor));
|
|
5163
5475
|
}, []);
|
|
5164
5476
|
if (!anchor || !hasMessages) return null;
|
|
5165
|
-
const button = /* @__PURE__ */ (0,
|
|
5477
|
+
const button = /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
5166
5478
|
"button",
|
|
5167
5479
|
{
|
|
5168
5480
|
type: "button",
|
|
@@ -5170,24 +5482,24 @@ var StudioSidebarRuntimePortal = ({
|
|
|
5170
5482
|
"aria-label": label,
|
|
5171
5483
|
className: studioSidebarNavItemClasses(iconOnlyLayout, false),
|
|
5172
5484
|
children: [
|
|
5173
|
-
/* @__PURE__ */ (0,
|
|
5174
|
-
!iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5485
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_lucide_react12.MessageSquarePlus, { className: "size-3.5 shrink-0" }),
|
|
5486
|
+
!iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "min-w-0 truncate", children: label }) : null
|
|
5175
5487
|
]
|
|
5176
5488
|
}
|
|
5177
5489
|
);
|
|
5178
5490
|
return (0, import_react_dom.createPortal)(
|
|
5179
|
-
iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5180
|
-
/* @__PURE__ */ (0,
|
|
5181
|
-
/* @__PURE__ */ (0,
|
|
5491
|
+
iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Tooltip, { children: [
|
|
5492
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TooltipTrigger, { asChild: true, children: button }),
|
|
5493
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TooltipContent, { side: "right", className: "text-xs", children: label })
|
|
5182
5494
|
] }) : button,
|
|
5183
5495
|
anchor
|
|
5184
5496
|
);
|
|
5185
5497
|
};
|
|
5186
5498
|
|
|
5187
5499
|
// src/studio/sidebar/welcome.tsx
|
|
5188
|
-
var
|
|
5189
|
-
var
|
|
5190
|
-
var
|
|
5500
|
+
var import_react45 = require("motion/react");
|
|
5501
|
+
var import_react46 = require("@assistant-ui/react");
|
|
5502
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
5191
5503
|
var welcomeStagger2 = {
|
|
5192
5504
|
initial: {},
|
|
5193
5505
|
animate: {
|
|
@@ -5212,34 +5524,34 @@ var welcomeIcon2 = {
|
|
|
5212
5524
|
}
|
|
5213
5525
|
};
|
|
5214
5526
|
var StudioWelcome = ({ config, icon }) => {
|
|
5215
|
-
const isEmpty = (0,
|
|
5527
|
+
const isEmpty = (0, import_react46.useThread)((s) => s.messages.length === 0);
|
|
5216
5528
|
if (!isEmpty) return null;
|
|
5217
|
-
const iconNode = icon ?? /* @__PURE__ */ (0,
|
|
5529
|
+
const iconNode = icon ?? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
5218
5530
|
TimbalMark,
|
|
5219
5531
|
{
|
|
5220
5532
|
size: 112,
|
|
5221
5533
|
className: "max-md:scale-[0.58] max-md:origin-center"
|
|
5222
5534
|
}
|
|
5223
5535
|
);
|
|
5224
|
-
return /* @__PURE__ */ (0,
|
|
5225
|
-
|
|
5536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
5537
|
+
import_react45.motion.div,
|
|
5226
5538
|
{
|
|
5227
5539
|
className: "aui-thread-welcome-message flex flex-col items-center justify-center px-2 text-center sm:px-4",
|
|
5228
5540
|
variants: welcomeStagger2,
|
|
5229
5541
|
initial: "initial",
|
|
5230
5542
|
animate: "animate",
|
|
5231
5543
|
children: [
|
|
5232
|
-
/* @__PURE__ */ (0,
|
|
5233
|
-
/* @__PURE__ */ (0,
|
|
5234
|
-
|
|
5544
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react45.motion.div, { variants: welcomeIcon2, className: "mb-4 md:mb-5", children: iconNode }),
|
|
5545
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
5546
|
+
import_react45.motion.h1,
|
|
5235
5547
|
{
|
|
5236
5548
|
variants: welcomeItem2,
|
|
5237
5549
|
className: "aui-thread-welcome-message-inner text-xl font-semibold sm:text-2xl",
|
|
5238
5550
|
children: config?.heading ?? "How can I help you today?"
|
|
5239
5551
|
}
|
|
5240
5552
|
),
|
|
5241
|
-
/* @__PURE__ */ (0,
|
|
5242
|
-
|
|
5553
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
5554
|
+
import_react45.motion.p,
|
|
5243
5555
|
{
|
|
5244
5556
|
variants: welcomeItem2,
|
|
5245
5557
|
className: "aui-thread-welcome-message-inner mt-2 text-muted-foreground",
|
|
@@ -5252,8 +5564,8 @@ var StudioWelcome = ({ config, icon }) => {
|
|
|
5252
5564
|
};
|
|
5253
5565
|
|
|
5254
5566
|
// src/studio/shell/studio-shell.tsx
|
|
5255
|
-
var
|
|
5256
|
-
var
|
|
5567
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
5568
|
+
var import_react49 = require("react");
|
|
5257
5569
|
var DEFAULT_BREAKPOINT_PX2 = 768;
|
|
5258
5570
|
function readPersistedCollapsed2(key) {
|
|
5259
5571
|
if (!key || typeof window === "undefined") return false;
|
|
@@ -5273,9 +5585,9 @@ function writePersistedCollapsed2(key, collapsed) {
|
|
|
5273
5585
|
function makeComposerWithPortal(BaseComposer) {
|
|
5274
5586
|
const Resolved = BaseComposer ?? Composer;
|
|
5275
5587
|
return function StudioComposerWithSidebar(props) {
|
|
5276
|
-
return /* @__PURE__ */ (0,
|
|
5277
|
-
/* @__PURE__ */ (0,
|
|
5278
|
-
/* @__PURE__ */ (0,
|
|
5588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
5589
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(StudioSidebarRuntimePortal, {}),
|
|
5590
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Resolved, { ...props })
|
|
5279
5591
|
] });
|
|
5280
5592
|
};
|
|
5281
5593
|
}
|
|
@@ -5295,7 +5607,7 @@ var TimbalStudioShell = ({
|
|
|
5295
5607
|
components,
|
|
5296
5608
|
...chatProps
|
|
5297
5609
|
}) => {
|
|
5298
|
-
const reducedMotion = (0,
|
|
5610
|
+
const reducedMotion = (0, import_react48.useReducedMotion)();
|
|
5299
5611
|
const shouldFetchWorkforces = !workforceId && workforcesProp === void 0;
|
|
5300
5612
|
const fetched = useWorkforces({
|
|
5301
5613
|
enabled: shouldFetchWorkforces,
|
|
@@ -5303,36 +5615,36 @@ var TimbalStudioShell = ({
|
|
|
5303
5615
|
baseUrl: workforcesBaseUrl
|
|
5304
5616
|
});
|
|
5305
5617
|
const workforces = workforcesProp ?? fetched.workforces;
|
|
5306
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
5618
|
+
const [internalSelected, setInternalSelected] = (0, import_react47.useState)(
|
|
5307
5619
|
workforceId ?? ""
|
|
5308
5620
|
);
|
|
5309
|
-
(0,
|
|
5621
|
+
(0, import_react47.useEffect)(() => {
|
|
5310
5622
|
if (workforceId) return;
|
|
5311
5623
|
if (internalSelected) return;
|
|
5312
5624
|
const first = workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name;
|
|
5313
5625
|
if (first) setInternalSelected(first);
|
|
5314
5626
|
}, [workforces, workforceId, internalSelected]);
|
|
5315
5627
|
const activeWorkforceId = workforceId ?? internalSelected ?? fetched.selectedId ?? "";
|
|
5316
|
-
const [collapsed, setCollapsed] = (0,
|
|
5628
|
+
const [collapsed, setCollapsed] = (0, import_react47.useState)(() => {
|
|
5317
5629
|
const persisted = readPersistedCollapsed2(persistKey);
|
|
5318
5630
|
return persisted || defaultCollapsed;
|
|
5319
5631
|
});
|
|
5320
|
-
const [isMobile, setIsMobile] = (0,
|
|
5632
|
+
const [isMobile, setIsMobile] = (0, import_react47.useState)(() => {
|
|
5321
5633
|
if (typeof window === "undefined") return false;
|
|
5322
5634
|
return window.innerWidth < mobileBreakpointPx;
|
|
5323
5635
|
});
|
|
5324
|
-
const [mobileSidebarOpen, setMobileSidebarOpen] = (0,
|
|
5325
|
-
(0,
|
|
5636
|
+
const [mobileSidebarOpen, setMobileSidebarOpen] = (0, import_react47.useState)(false);
|
|
5637
|
+
(0, import_react47.useEffect)(() => {
|
|
5326
5638
|
if (typeof window === "undefined") return;
|
|
5327
5639
|
const onResize = () => setIsMobile(window.innerWidth < mobileBreakpointPx);
|
|
5328
5640
|
onResize();
|
|
5329
5641
|
window.addEventListener("resize", onResize);
|
|
5330
5642
|
return () => window.removeEventListener("resize", onResize);
|
|
5331
5643
|
}, [mobileBreakpointPx]);
|
|
5332
|
-
(0,
|
|
5644
|
+
(0, import_react47.useEffect)(() => {
|
|
5333
5645
|
if (!isMobile) setMobileSidebarOpen(false);
|
|
5334
5646
|
}, [isMobile]);
|
|
5335
|
-
(0,
|
|
5647
|
+
(0, import_react47.useEffect)(() => {
|
|
5336
5648
|
if (!mobileSidebarOpen) return;
|
|
5337
5649
|
const onKeyDown = (e) => {
|
|
5338
5650
|
if (e.key === "Escape") setMobileSidebarOpen(false);
|
|
@@ -5356,21 +5668,21 @@ var TimbalStudioShell = ({
|
|
|
5356
5668
|
layoutDirection
|
|
5357
5669
|
);
|
|
5358
5670
|
const desktopInsetPx = widthCollapsed ? SIDEBAR_INSET_PX_COLLAPSED : SIDEBAR_INSET_PX_EXPANDED;
|
|
5359
|
-
const onCollapsedChange = (0,
|
|
5671
|
+
const onCollapsedChange = (0, import_react47.useCallback)(
|
|
5360
5672
|
(next) => {
|
|
5361
5673
|
setCollapsed(next);
|
|
5362
5674
|
writePersistedCollapsed2(persistKey, next);
|
|
5363
5675
|
},
|
|
5364
5676
|
[persistKey]
|
|
5365
5677
|
);
|
|
5366
|
-
const handleSelectWorkforce = (0,
|
|
5678
|
+
const handleSelectWorkforce = (0, import_react47.useCallback)(
|
|
5367
5679
|
(id) => {
|
|
5368
5680
|
if (!workforceId) setInternalSelected(id);
|
|
5369
5681
|
if (isMobile) setMobileSidebarOpen(false);
|
|
5370
5682
|
},
|
|
5371
5683
|
[workforceId, isMobile]
|
|
5372
5684
|
);
|
|
5373
|
-
const sidebarContext = (0,
|
|
5685
|
+
const sidebarContext = (0, import_react47.useMemo)(
|
|
5374
5686
|
() => ({
|
|
5375
5687
|
collapsed: effectiveCollapsed,
|
|
5376
5688
|
isMobile,
|
|
@@ -5379,12 +5691,12 @@ var TimbalStudioShell = ({
|
|
|
5379
5691
|
}),
|
|
5380
5692
|
[effectiveCollapsed, isMobile, isCollapsedRail, iconOnlyLayout]
|
|
5381
5693
|
);
|
|
5382
|
-
const resolvedComponents = (0,
|
|
5694
|
+
const resolvedComponents = (0, import_react47.useMemo)(() => {
|
|
5383
5695
|
const next = { Welcome: StudioWelcome, ...components };
|
|
5384
5696
|
next.Composer = makeComposerWithPortal(components?.Composer);
|
|
5385
5697
|
return next;
|
|
5386
5698
|
}, [components]);
|
|
5387
|
-
return /* @__PURE__ */ (0,
|
|
5699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(StudioSidebarContext.Provider, { value: sidebarContext, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5388
5700
|
"div",
|
|
5389
5701
|
{
|
|
5390
5702
|
className: cn(
|
|
@@ -5393,14 +5705,14 @@ var TimbalStudioShell = ({
|
|
|
5393
5705
|
),
|
|
5394
5706
|
style: studioChromeShellStyle,
|
|
5395
5707
|
children: [
|
|
5396
|
-
/* @__PURE__ */ (0,
|
|
5708
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5397
5709
|
"div",
|
|
5398
5710
|
{
|
|
5399
5711
|
className: "pointer-events-none absolute inset-0 z-0 bg-background",
|
|
5400
5712
|
"aria-hidden": true
|
|
5401
5713
|
}
|
|
5402
5714
|
),
|
|
5403
|
-
/* @__PURE__ */ (0,
|
|
5715
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5404
5716
|
"div",
|
|
5405
5717
|
{
|
|
5406
5718
|
className: cn(
|
|
@@ -5410,14 +5722,14 @@ var TimbalStudioShell = ({
|
|
|
5410
5722
|
"aria-hidden": true
|
|
5411
5723
|
}
|
|
5412
5724
|
),
|
|
5413
|
-
/* @__PURE__ */ (0,
|
|
5725
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5414
5726
|
StudioSidebarBackdrop,
|
|
5415
5727
|
{
|
|
5416
5728
|
open: isMobile && mobileSidebarOpen,
|
|
5417
5729
|
onClose: () => setMobileSidebarOpen(false)
|
|
5418
5730
|
}
|
|
5419
5731
|
),
|
|
5420
|
-
/* @__PURE__ */ (0,
|
|
5732
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5421
5733
|
StudioSidebarPanel,
|
|
5422
5734
|
{
|
|
5423
5735
|
workforces,
|
|
@@ -5436,8 +5748,8 @@ var TimbalStudioShell = ({
|
|
|
5436
5748
|
emptyCaption: sidebarEmptyCaption
|
|
5437
5749
|
}
|
|
5438
5750
|
),
|
|
5439
|
-
/* @__PURE__ */ (0,
|
|
5440
|
-
|
|
5751
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5752
|
+
import_react48.motion.header,
|
|
5441
5753
|
{
|
|
5442
5754
|
className: cn(
|
|
5443
5755
|
"absolute top-0 right-0 z-40 flex items-start justify-between gap-2",
|
|
@@ -5448,7 +5760,7 @@ var TimbalStudioShell = ({
|
|
|
5448
5760
|
animate: { left: isMobile ? 0 : desktopInsetPx },
|
|
5449
5761
|
transition: layoutTransition,
|
|
5450
5762
|
children: [
|
|
5451
|
-
/* @__PURE__ */ (0,
|
|
5763
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5452
5764
|
"div",
|
|
5453
5765
|
{
|
|
5454
5766
|
className: cn(
|
|
@@ -5456,7 +5768,7 @@ var TimbalStudioShell = ({
|
|
|
5456
5768
|
studioTopbarPillHeightClass
|
|
5457
5769
|
),
|
|
5458
5770
|
children: [
|
|
5459
|
-
isMobile && !mobileSidebarOpen ? /* @__PURE__ */ (0,
|
|
5771
|
+
isMobile && !mobileSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5460
5772
|
TimbalV2Button,
|
|
5461
5773
|
{
|
|
5462
5774
|
variant: "secondary",
|
|
@@ -5466,19 +5778,19 @@ var TimbalStudioShell = ({
|
|
|
5466
5778
|
onClick: () => setMobileSidebarOpen(true),
|
|
5467
5779
|
"aria-label": "Open menu",
|
|
5468
5780
|
"aria-expanded": false,
|
|
5469
|
-
children: /* @__PURE__ */ (0,
|
|
5781
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react13.Menu, { className: "size-4" })
|
|
5470
5782
|
}
|
|
5471
5783
|
) : null,
|
|
5472
5784
|
headerStart
|
|
5473
5785
|
]
|
|
5474
5786
|
}
|
|
5475
5787
|
),
|
|
5476
|
-
headerActions ? /* @__PURE__ */ (0,
|
|
5788
|
+
headerActions ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex shrink-0 items-center gap-1", children: headerActions }) : null
|
|
5477
5789
|
]
|
|
5478
5790
|
}
|
|
5479
5791
|
),
|
|
5480
|
-
/* @__PURE__ */ (0,
|
|
5481
|
-
|
|
5792
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5793
|
+
import_react48.motion.main,
|
|
5482
5794
|
{
|
|
5483
5795
|
className: cn(
|
|
5484
5796
|
"relative z-10 flex h-full min-w-0 flex-col",
|
|
@@ -5488,7 +5800,7 @@ var TimbalStudioShell = ({
|
|
|
5488
5800
|
initial: false,
|
|
5489
5801
|
animate: { paddingLeft: isMobile ? 12 : desktopInsetPx },
|
|
5490
5802
|
transition: layoutTransition,
|
|
5491
|
-
children: activeWorkforceId ? /* @__PURE__ */ (0,
|
|
5803
|
+
children: activeWorkforceId ? /* @__PURE__ */ (0, import_react49.createElement)(
|
|
5492
5804
|
TimbalChat,
|
|
5493
5805
|
{
|
|
5494
5806
|
...chatProps,
|
|
@@ -5507,9 +5819,29 @@ var TimbalStudioShell = ({
|
|
|
5507
5819
|
};
|
|
5508
5820
|
|
|
5509
5821
|
// src/studio/sidebar/mode-toggle.tsx
|
|
5510
|
-
var
|
|
5822
|
+
var import_react50 = require("react");
|
|
5511
5823
|
var import_lucide_react14 = require("lucide-react");
|
|
5512
|
-
var
|
|
5824
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
5825
|
+
function readStoredTheme() {
|
|
5826
|
+
if (typeof window === "undefined") return null;
|
|
5827
|
+
try {
|
|
5828
|
+
const value = window.localStorage.getItem(STORAGE_KEYS.theme);
|
|
5829
|
+
return value === "dark" || value === "light" ? value : null;
|
|
5830
|
+
} catch {
|
|
5831
|
+
return null;
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
function writeStoredTheme(theme) {
|
|
5835
|
+
if (typeof window === "undefined") return;
|
|
5836
|
+
try {
|
|
5837
|
+
window.localStorage.setItem(STORAGE_KEYS.theme, theme);
|
|
5838
|
+
} catch {
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
function applyDarkClass(isDark) {
|
|
5842
|
+
if (typeof document === "undefined") return;
|
|
5843
|
+
document.documentElement.classList.toggle("dark", isDark);
|
|
5844
|
+
}
|
|
5513
5845
|
var ModeToggle = ({
|
|
5514
5846
|
theme,
|
|
5515
5847
|
setTheme,
|
|
@@ -5517,24 +5849,31 @@ var ModeToggle = ({
|
|
|
5517
5849
|
label = "Toggle theme"
|
|
5518
5850
|
}) => {
|
|
5519
5851
|
const isControlled = theme !== void 0;
|
|
5520
|
-
const [internalIsDark, setInternalIsDark] = (0,
|
|
5521
|
-
(0,
|
|
5852
|
+
const [internalIsDark, setInternalIsDark] = (0, import_react50.useState)(false);
|
|
5853
|
+
(0, import_react50.useLayoutEffect)(() => {
|
|
5522
5854
|
if (isControlled) return;
|
|
5523
|
-
|
|
5855
|
+
const stored = readStoredTheme();
|
|
5856
|
+
if (stored) {
|
|
5857
|
+
const isDark2 = stored === "dark";
|
|
5858
|
+
applyDarkClass(isDark2);
|
|
5859
|
+
setInternalIsDark(isDark2);
|
|
5860
|
+
return;
|
|
5861
|
+
}
|
|
5524
5862
|
setInternalIsDark(document.documentElement.classList.contains("dark"));
|
|
5525
5863
|
}, [isControlled]);
|
|
5526
5864
|
const isDark = isControlled ? theme === "dark" : internalIsDark;
|
|
5527
|
-
const onClick = (0,
|
|
5865
|
+
const onClick = (0, import_react50.useCallback)(() => {
|
|
5528
5866
|
const next = isDark ? "light" : "dark";
|
|
5529
5867
|
if (setTheme) {
|
|
5530
5868
|
setTheme(next);
|
|
5531
5869
|
return;
|
|
5532
5870
|
}
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5871
|
+
const isDarkNext = next === "dark";
|
|
5872
|
+
applyDarkClass(isDarkNext);
|
|
5873
|
+
writeStoredTheme(isDarkNext ? "dark" : "light");
|
|
5874
|
+
setInternalIsDark(isDarkNext);
|
|
5536
5875
|
}, [isDark, setTheme]);
|
|
5537
|
-
return /* @__PURE__ */ (0,
|
|
5876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
5538
5877
|
TimbalV2Button,
|
|
5539
5878
|
{
|
|
5540
5879
|
variant: "secondary",
|
|
@@ -5550,20 +5889,20 @@ var ModeToggle = ({
|
|
|
5550
5889
|
"aria-label": label,
|
|
5551
5890
|
title: label,
|
|
5552
5891
|
children: [
|
|
5553
|
-
/* @__PURE__ */ (0,
|
|
5554
|
-
/* @__PURE__ */ (0,
|
|
5555
|
-
/* @__PURE__ */ (0,
|
|
5892
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react14.Sun, { className: "size-3.5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" }),
|
|
5893
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react14.Moon, { className: "absolute size-3.5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" }),
|
|
5894
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "sr-only", children: label })
|
|
5556
5895
|
]
|
|
5557
5896
|
}
|
|
5558
5897
|
);
|
|
5559
5898
|
};
|
|
5560
5899
|
|
|
5561
5900
|
// src/studio/mode-switch.tsx
|
|
5562
|
-
var
|
|
5901
|
+
var import_react53 = require("react");
|
|
5563
5902
|
|
|
5564
5903
|
// src/ui/pill-segmented-tabs.tsx
|
|
5565
|
-
var
|
|
5566
|
-
var
|
|
5904
|
+
var import_react51 = require("react");
|
|
5905
|
+
var import_react52 = require("motion/react");
|
|
5567
5906
|
|
|
5568
5907
|
// src/design/pill-segmented-classes.ts
|
|
5569
5908
|
var pillSegmentedTrackBase = "inline-flex w-fit max-w-max shrink-0 self-start items-center rounded-full";
|
|
@@ -5596,7 +5935,7 @@ var pillSegmentedActiveIndicatorClass = cn(
|
|
|
5596
5935
|
);
|
|
5597
5936
|
|
|
5598
5937
|
// src/ui/pill-segmented-tabs.tsx
|
|
5599
|
-
var
|
|
5938
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5600
5939
|
var PillTab = ({
|
|
5601
5940
|
tabKey,
|
|
5602
5941
|
label,
|
|
@@ -5607,10 +5946,10 @@ var PillTab = ({
|
|
|
5607
5946
|
segmentClassName,
|
|
5608
5947
|
animateIndicator
|
|
5609
5948
|
}) => {
|
|
5610
|
-
const handlePress = (0,
|
|
5949
|
+
const handlePress = (0, import_react51.useCallback)(() => {
|
|
5611
5950
|
if (!disabled) onSelect(tabKey);
|
|
5612
5951
|
}, [disabled, onSelect, tabKey]);
|
|
5613
|
-
return /* @__PURE__ */ (0,
|
|
5952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
5614
5953
|
"button",
|
|
5615
5954
|
{
|
|
5616
5955
|
type: "button",
|
|
@@ -5623,15 +5962,15 @@ var PillTab = ({
|
|
|
5623
5962
|
!disabled && (isActive ? "text-foreground" : "text-muted-foreground hover:text-foreground")
|
|
5624
5963
|
),
|
|
5625
5964
|
children: [
|
|
5626
|
-
isActive && animateIndicator ? /* @__PURE__ */ (0,
|
|
5627
|
-
|
|
5965
|
+
isActive && animateIndicator ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5966
|
+
import_react52.motion.div,
|
|
5628
5967
|
{
|
|
5629
5968
|
layoutId,
|
|
5630
5969
|
className: pillSegmentedActiveIndicatorClass,
|
|
5631
5970
|
transition: { type: "spring", duration: 0.3, bounce: 0.15 }
|
|
5632
5971
|
}
|
|
5633
|
-
) : isActive ? /* @__PURE__ */ (0,
|
|
5634
|
-
/* @__PURE__ */ (0,
|
|
5972
|
+
) : isActive ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: pillSegmentedActiveIndicatorClass, "aria-hidden": true }) : null,
|
|
5973
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "relative z-10 whitespace-nowrap", children: label })
|
|
5635
5974
|
]
|
|
5636
5975
|
}
|
|
5637
5976
|
);
|
|
@@ -5645,13 +5984,13 @@ var PillSegmentedTabs = ({
|
|
|
5645
5984
|
layoutId: layoutIdProp,
|
|
5646
5985
|
"aria-label": ariaLabel
|
|
5647
5986
|
}) => {
|
|
5648
|
-
const reactId = (0,
|
|
5987
|
+
const reactId = (0, import_react51.useId)();
|
|
5649
5988
|
const layoutId = layoutIdProp ?? `pill-segmented-${reactId.replace(/:/g, "")}`;
|
|
5650
|
-
const reducedMotion = (0,
|
|
5989
|
+
const reducedMotion = (0, import_react52.useReducedMotion)();
|
|
5651
5990
|
const isFlush = trackVariant === "flush";
|
|
5652
5991
|
const trackClass = isFlush ? pillSegmentedTrackFlushClass : pillSegmentedTrackClass;
|
|
5653
5992
|
const segmentClassName = isFlush ? pillSegmentedFlushSegmentClass : pillSegmentedSegmentClass;
|
|
5654
|
-
return /* @__PURE__ */ (0,
|
|
5993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { role: "group", "aria-label": ariaLabel, className: cn(trackClass, className), children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5655
5994
|
PillTab,
|
|
5656
5995
|
{
|
|
5657
5996
|
tabKey: tab.key,
|
|
@@ -5666,15 +6005,15 @@ var PillSegmentedTabs = ({
|
|
|
5666
6005
|
tab.key
|
|
5667
6006
|
)) });
|
|
5668
6007
|
};
|
|
5669
|
-
var MemoPillSegmentedTabs = (0,
|
|
6008
|
+
var MemoPillSegmentedTabs = (0, import_react51.memo)(PillSegmentedTabs);
|
|
5670
6009
|
|
|
5671
6010
|
// src/studio/mode-switch.tsx
|
|
5672
|
-
var
|
|
6011
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5673
6012
|
var STUDIO_NAV_MODE = {
|
|
5674
6013
|
BUILD: "build",
|
|
5675
6014
|
OPERATE: "operate"
|
|
5676
6015
|
};
|
|
5677
|
-
var StudioModeSwitch = (0,
|
|
6016
|
+
var StudioModeSwitch = (0, import_react53.memo)(
|
|
5678
6017
|
function StudioModeSwitch2({
|
|
5679
6018
|
value,
|
|
5680
6019
|
onChange,
|
|
@@ -5683,14 +6022,14 @@ var StudioModeSwitch = (0, import_react51.memo)(
|
|
|
5683
6022
|
manageLabel = "Manage",
|
|
5684
6023
|
"aria-label": ariaLabel = "Studio mode"
|
|
5685
6024
|
}) {
|
|
5686
|
-
const tabs = (0,
|
|
6025
|
+
const tabs = (0, import_react53.useMemo)(
|
|
5687
6026
|
() => [
|
|
5688
6027
|
{ key: STUDIO_NAV_MODE.BUILD, label: buildLabel },
|
|
5689
6028
|
{ key: STUDIO_NAV_MODE.OPERATE, label: manageLabel }
|
|
5690
6029
|
],
|
|
5691
6030
|
[buildLabel, manageLabel]
|
|
5692
6031
|
);
|
|
5693
|
-
const handleChange = (0,
|
|
6032
|
+
const handleChange = (0, import_react53.useCallback)(
|
|
5694
6033
|
(key) => {
|
|
5695
6034
|
if (key === STUDIO_NAV_MODE.BUILD || key === STUDIO_NAV_MODE.OPERATE) {
|
|
5696
6035
|
onChange(key);
|
|
@@ -5698,14 +6037,14 @@ var StudioModeSwitch = (0, import_react51.memo)(
|
|
|
5698
6037
|
},
|
|
5699
6038
|
[onChange]
|
|
5700
6039
|
);
|
|
5701
|
-
return /* @__PURE__ */ (0,
|
|
6040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5702
6041
|
"div",
|
|
5703
6042
|
{
|
|
5704
6043
|
"data-tour": "studio-mode-switch",
|
|
5705
6044
|
"data-studio-chrome-align": "mode-switch",
|
|
5706
6045
|
id: "studio-chrome-mode-switch",
|
|
5707
6046
|
className,
|
|
5708
|
-
children: /* @__PURE__ */ (0,
|
|
6047
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5709
6048
|
PillSegmentedTabs,
|
|
5710
6049
|
{
|
|
5711
6050
|
value,
|