@timbal-ai/timbal-react 1.1.0 → 1.3.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 +28 -1
- package/LICENSE +201 -0
- package/README.md +20 -11
- package/dist/app.cjs +1675 -1218
- package/dist/app.d.cts +22 -6
- package/dist/app.d.ts +22 -6
- package/dist/app.esm.js +26 -8
- package/dist/{chart-artifact-BZp7nmaf.d.ts → chart-artifact-Q5QgMtbj.d.ts} +107 -28
- package/dist/{chart-artifact-CX-rh9nq.d.cts → chart-artifact-WDEW9dHT.d.cts} +107 -28
- package/dist/{chat-DCms8pJ_.d.cts → chat-ClmzWzCX.d.cts} +2 -0
- package/dist/{chat-DCms8pJ_.d.ts → chat-ClmzWzCX.d.ts} +2 -0
- package/dist/chat.cjs +868 -511
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-YXZ22OJN.esm.js → chunk-GQBYZRD7.esm.js} +670 -402
- package/dist/{chunk-XCM3V6RK.esm.js → chunk-OFWC4MIY.esm.js} +2 -2
- package/dist/{chunk-6HWMJNZT.esm.js → chunk-OH23AX2V.esm.js} +757 -56
- package/dist/{chunk-4AKJ6FKE.esm.js → chunk-QU7ET55D.esm.js} +120 -23
- package/dist/{chunk-FRZOEYBO.esm.js → chunk-THBA27QY.esm.js} +4 -4
- package/dist/{chunk-JEAUF54A.esm.js → chunk-UCGVL7ZY.esm.js} +1 -1
- package/dist/{chunk-P3KDAYX6.esm.js → chunk-VXMM2HX7.esm.js} +1 -1
- package/dist/{chunk-TK2AGIME.esm.js → chunk-YCXN67SD.esm.js} +565 -480
- package/dist/{pill-segmented-tabs-Ba5q0feL.d.cts → circular-progress-Ci8L-Hfa.d.cts} +230 -6
- package/dist/{pill-segmented-tabs-Ba5q0feL.d.ts → circular-progress-Ci8L-Hfa.d.ts} +230 -6
- package/dist/index.cjs +2850 -1689
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.js +41 -11
- package/dist/studio.cjs +1089 -732
- package/dist/studio.d.cts +2 -2
- package/dist/studio.d.ts +2 -2
- package/dist/studio.esm.js +5 -5
- package/dist/styles.css +14 -16
- package/dist/ui.cjs +880 -71
- package/dist/ui.d.cts +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.esm.js +28 -4
- package/dist/{welcome-CRqOPKMp.d.cts → welcome-BFGRoNfK.d.cts} +1 -1
- package/dist/{welcome-DlHUa3OL.d.ts → welcome-DXqsGTwH.d.ts} +1 -1
- package/package.json +1 -1
- package/vite/local-dev.d.ts +5 -1
- package/vite/local-dev.mjs +17 -13
package/dist/chat.cjs
CHANGED
|
@@ -910,10 +910,10 @@ function findParentIdFromAuiParent(messages, auiParentId) {
|
|
|
910
910
|
}
|
|
911
911
|
|
|
912
912
|
// src/chat/thread.tsx
|
|
913
|
-
var
|
|
914
|
-
var
|
|
913
|
+
var import_react30 = require("react");
|
|
914
|
+
var import_react31 = require("@assistant-ui/react");
|
|
915
915
|
var import_lucide_react8 = require("lucide-react");
|
|
916
|
-
var
|
|
916
|
+
var import_react32 = require("motion/react");
|
|
917
917
|
|
|
918
918
|
// src/chat/attachment.tsx
|
|
919
919
|
var import_react5 = require("react");
|
|
@@ -1070,6 +1070,33 @@ var TIMBAL_V2_SHADOW = {
|
|
|
1070
1070
|
ghost: "",
|
|
1071
1071
|
link: ""
|
|
1072
1072
|
};
|
|
1073
|
+
var TIMBAL_V2_PRIMARY_SURFACE = cn(
|
|
1074
|
+
TIMBAL_V2_PRIMARY_GRADIENT,
|
|
1075
|
+
TIMBAL_V2_SHADOW.primary,
|
|
1076
|
+
TIMBAL_V2_BORDER.primary
|
|
1077
|
+
);
|
|
1078
|
+
var TIMBAL_V2_PRIMARY_PILL_ROOT = cn(
|
|
1079
|
+
"relative box-border inline-flex items-center justify-center overflow-hidden rounded-full border-0 bg-transparent p-0 font-normal shadow-none transition duration-200 ease-in-out",
|
|
1080
|
+
TIMBAL_V2_SHADOW.primary,
|
|
1081
|
+
TIMBAL_V2_BORDER.primary
|
|
1082
|
+
);
|
|
1083
|
+
var TIMBAL_V2_PRIMARY_PILL_FILL_LAYER = cn(
|
|
1084
|
+
"pointer-events-none absolute inset-0 transition duration-200 ease-in-out",
|
|
1085
|
+
"bg-gradient-to-b from-primary-fill-from to-primary-fill-to",
|
|
1086
|
+
"group-hover/avatar:from-primary-fill-hover-from group-hover/avatar:to-primary-fill-hover-to",
|
|
1087
|
+
"group-active/avatar:from-primary-fill-active-from group-active/avatar:to-primary-fill-active-to"
|
|
1088
|
+
);
|
|
1089
|
+
var TIMBAL_V2_SECONDARY_PILL_ROOT = cn(
|
|
1090
|
+
"relative box-border inline-flex items-center justify-center overflow-hidden rounded-full bg-transparent p-0 font-normal shadow-none transition duration-200 ease-in-out",
|
|
1091
|
+
TIMBAL_V2_SHADOW.secondary,
|
|
1092
|
+
TIMBAL_V2_BORDER.secondary
|
|
1093
|
+
);
|
|
1094
|
+
var TIMBAL_V2_SECONDARY_PILL_FILL_LAYER = cn(
|
|
1095
|
+
"pointer-events-none absolute inset-0 transition duration-200 ease-in-out",
|
|
1096
|
+
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1097
|
+
"group-hover/avatar:from-secondary-fill-hover-from group-hover/avatar:to-secondary-fill-hover-to",
|
|
1098
|
+
"group-active/avatar:from-secondary-fill-active-from group-active/avatar:to-secondary-fill-active-to"
|
|
1099
|
+
);
|
|
1073
1100
|
var TIMBAL_V2_SWITCH_TRACK_OFF = cn(
|
|
1074
1101
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1075
1102
|
"border border-border shadow-card"
|
|
@@ -1179,25 +1206,71 @@ function DialogTitle({
|
|
|
1179
1206
|
}
|
|
1180
1207
|
|
|
1181
1208
|
// src/ui/avatar.tsx
|
|
1209
|
+
var React = __toESM(require("react"), 1);
|
|
1182
1210
|
var import_radix_ui3 = require("radix-ui");
|
|
1183
1211
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1212
|
+
var AVATAR_PRIMARY_FALLBACK_CLASS = cn(
|
|
1213
|
+
TIMBAL_V2_SECONDARY_PILL_ROOT,
|
|
1214
|
+
TIMBAL_V2_LABEL.secondary,
|
|
1215
|
+
"font-medium"
|
|
1216
|
+
);
|
|
1217
|
+
var AVATAR_SECONDARY_FILL_STYLE = {
|
|
1218
|
+
backgroundImage: "linear-gradient(to bottom, var(--elevated-from), var(--elevated-to))"
|
|
1219
|
+
};
|
|
1220
|
+
var AvatarChromeContext = React.createContext(
|
|
1221
|
+
null
|
|
1222
|
+
);
|
|
1223
|
+
function useAvatarChrome() {
|
|
1224
|
+
return React.useContext(AvatarChromeContext);
|
|
1225
|
+
}
|
|
1226
|
+
function isBrandedVariant(variant) {
|
|
1227
|
+
return variant === "secondary" || variant === "primary" || variant === "chart";
|
|
1228
|
+
}
|
|
1229
|
+
var AVATAR_SIZE_CLASS = {
|
|
1230
|
+
default: "size-8",
|
|
1231
|
+
sm: "size-6",
|
|
1232
|
+
lg: "size-10"
|
|
1233
|
+
};
|
|
1184
1234
|
function Avatar({
|
|
1185
1235
|
className,
|
|
1186
1236
|
size = "default",
|
|
1237
|
+
variant: rootVariant,
|
|
1238
|
+
children,
|
|
1187
1239
|
...props
|
|
1188
1240
|
}) {
|
|
1189
|
-
|
|
1241
|
+
const [chrome, setChrome] = React.useState(rootVariant ?? "muted");
|
|
1242
|
+
React.useLayoutEffect(() => {
|
|
1243
|
+
if (rootVariant !== void 0) {
|
|
1244
|
+
setChrome(rootVariant);
|
|
1245
|
+
}
|
|
1246
|
+
}, [rootVariant]);
|
|
1247
|
+
const branded = isBrandedVariant(chrome);
|
|
1248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AvatarChromeContext.Provider, { value: { chrome, setChrome }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1190
1249
|
import_radix_ui3.Avatar.Root,
|
|
1191
1250
|
{
|
|
1192
1251
|
"data-slot": "avatar",
|
|
1193
1252
|
"data-size": size,
|
|
1253
|
+
"data-variant": branded ? "secondary" : chrome,
|
|
1194
1254
|
className: cn(
|
|
1195
|
-
"group/avatar relative
|
|
1255
|
+
"group/avatar relative shrink-0 select-none",
|
|
1256
|
+
AVATAR_SIZE_CLASS[size],
|
|
1257
|
+
branded ? TIMBAL_V2_SECONDARY_PILL_ROOT : "flex overflow-hidden rounded-full",
|
|
1196
1258
|
className
|
|
1197
1259
|
),
|
|
1198
|
-
...props
|
|
1260
|
+
...props,
|
|
1261
|
+
children: [
|
|
1262
|
+
branded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1263
|
+
"span",
|
|
1264
|
+
{
|
|
1265
|
+
"aria-hidden": true,
|
|
1266
|
+
className: TIMBAL_V2_SECONDARY_PILL_FILL_LAYER,
|
|
1267
|
+
style: AVATAR_SECONDARY_FILL_STYLE
|
|
1268
|
+
}
|
|
1269
|
+
) : null,
|
|
1270
|
+
children
|
|
1271
|
+
]
|
|
1199
1272
|
}
|
|
1200
|
-
);
|
|
1273
|
+
) });
|
|
1201
1274
|
}
|
|
1202
1275
|
function AvatarImage({
|
|
1203
1276
|
className,
|
|
@@ -1207,24 +1280,44 @@ function AvatarImage({
|
|
|
1207
1280
|
import_radix_ui3.Avatar.Image,
|
|
1208
1281
|
{
|
|
1209
1282
|
"data-slot": "avatar-image",
|
|
1210
|
-
className: cn(
|
|
1283
|
+
className: cn(
|
|
1284
|
+
"relative z-10 aspect-square size-full rounded-full object-cover",
|
|
1285
|
+
className
|
|
1286
|
+
),
|
|
1211
1287
|
...props
|
|
1212
1288
|
}
|
|
1213
1289
|
);
|
|
1214
1290
|
}
|
|
1215
1291
|
function AvatarFallback({
|
|
1216
1292
|
className,
|
|
1293
|
+
variant = "muted",
|
|
1294
|
+
seed: _seed,
|
|
1295
|
+
children,
|
|
1296
|
+
style,
|
|
1217
1297
|
...props
|
|
1218
1298
|
}) {
|
|
1299
|
+
const chromeCtx = useAvatarChrome();
|
|
1300
|
+
React.useLayoutEffect(() => {
|
|
1301
|
+
chromeCtx?.setChrome(variant);
|
|
1302
|
+
}, [chromeCtx, variant]);
|
|
1303
|
+
const branded = isBrandedVariant(variant);
|
|
1219
1304
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1220
1305
|
import_radix_ui3.Avatar.Fallback,
|
|
1221
1306
|
{
|
|
1222
1307
|
"data-slot": "avatar-fallback",
|
|
1308
|
+
"data-variant": branded ? "secondary" : variant,
|
|
1223
1309
|
className: cn(
|
|
1224
|
-
"
|
|
1310
|
+
"relative z-10 flex size-full items-center justify-center rounded-full",
|
|
1311
|
+
branded ? cn(
|
|
1312
|
+
"bg-transparent font-medium",
|
|
1313
|
+
TIMBAL_V2_LABEL.secondary,
|
|
1314
|
+
"text-sm group-data-[size=sm]/avatar:text-xs"
|
|
1315
|
+
) : "bg-muted font-normal text-muted-foreground text-sm group-data-[size=sm]/avatar:text-xs",
|
|
1225
1316
|
className
|
|
1226
1317
|
),
|
|
1227
|
-
|
|
1318
|
+
style,
|
|
1319
|
+
...props,
|
|
1320
|
+
children
|
|
1228
1321
|
}
|
|
1229
1322
|
);
|
|
1230
1323
|
}
|
|
@@ -1233,7 +1326,7 @@ function AvatarFallback({
|
|
|
1233
1326
|
var import_react4 = require("react");
|
|
1234
1327
|
|
|
1235
1328
|
// src/ui/timbal-v2-button.tsx
|
|
1236
|
-
var
|
|
1329
|
+
var React2 = __toESM(require("react"), 1);
|
|
1237
1330
|
var import_radix_ui4 = require("radix-ui");
|
|
1238
1331
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1239
1332
|
var TIMBAL_V2_FILL_AS_CHILD = {
|
|
@@ -1269,7 +1362,7 @@ var TIMBAL_V2_LABEL_AS_CHILD = {
|
|
|
1269
1362
|
...TIMBAL_V2_LABEL,
|
|
1270
1363
|
link: "text-foreground underline decoration-foreground/25 underline-offset-2 hover:decoration-foreground/45"
|
|
1271
1364
|
};
|
|
1272
|
-
var TimbalV2Button =
|
|
1365
|
+
var TimbalV2Button = React2.forwardRef(function TimbalV2Button2({
|
|
1273
1366
|
variant = "secondary",
|
|
1274
1367
|
size = "sm",
|
|
1275
1368
|
isIconOnly = false,
|
|
@@ -1534,31 +1627,32 @@ var import_react_markdown = require("@assistant-ui/react-markdown");
|
|
|
1534
1627
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1535
1628
|
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1536
1629
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1537
|
-
var
|
|
1630
|
+
var import_react20 = require("react");
|
|
1538
1631
|
var import_lucide_react4 = require("lucide-react");
|
|
1539
1632
|
|
|
1540
1633
|
// src/chat/syntax-highlighter.tsx
|
|
1541
|
-
var
|
|
1634
|
+
var import_react19 = require("react");
|
|
1542
1635
|
var import_core = require("shiki/core");
|
|
1543
1636
|
var import_javascript = require("shiki/engine/javascript");
|
|
1544
1637
|
|
|
1545
1638
|
// src/artifacts/registry.tsx
|
|
1546
|
-
var
|
|
1639
|
+
var import_react18 = require("react");
|
|
1547
1640
|
|
|
1548
1641
|
// src/artifacts/chart-artifact.tsx
|
|
1549
|
-
var
|
|
1642
|
+
var import_react10 = require("react");
|
|
1550
1643
|
|
|
1551
1644
|
// src/charts/line-area-chart.tsx
|
|
1645
|
+
var import_react7 = require("react");
|
|
1552
1646
|
var import_recharts = require("recharts");
|
|
1553
1647
|
|
|
1554
1648
|
// src/ui/chart.tsx
|
|
1555
|
-
var
|
|
1649
|
+
var React3 = __toESM(require("react"), 1);
|
|
1556
1650
|
var RechartsPrimitive = __toESM(require("recharts"), 1);
|
|
1557
1651
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1558
1652
|
var THEMES = { light: "", dark: ".dark" };
|
|
1559
|
-
var ChartContext =
|
|
1653
|
+
var ChartContext = React3.createContext(null);
|
|
1560
1654
|
function useChart() {
|
|
1561
|
-
const context =
|
|
1655
|
+
const context = React3.useContext(ChartContext);
|
|
1562
1656
|
if (!context) {
|
|
1563
1657
|
throw new Error("useChart must be used within a <ChartContainer />");
|
|
1564
1658
|
}
|
|
@@ -1571,7 +1665,7 @@ function ChartContainer({
|
|
|
1571
1665
|
config,
|
|
1572
1666
|
...props
|
|
1573
1667
|
}) {
|
|
1574
|
-
const uniqueId =
|
|
1668
|
+
const uniqueId = React3.useId();
|
|
1575
1669
|
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
1576
1670
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1577
1671
|
"div",
|
|
@@ -1632,7 +1726,7 @@ function ChartTooltipContent({
|
|
|
1632
1726
|
labelKey
|
|
1633
1727
|
}) {
|
|
1634
1728
|
const { config } = useChart();
|
|
1635
|
-
const tooltipLabel =
|
|
1729
|
+
const tooltipLabel = React3.useMemo(() => {
|
|
1636
1730
|
if (hideLabel || !payload?.length) {
|
|
1637
1731
|
return null;
|
|
1638
1732
|
}
|
|
@@ -1743,7 +1837,7 @@ function ChartLegendContent({
|
|
|
1743
1837
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1744
1838
|
"div",
|
|
1745
1839
|
{
|
|
1746
|
-
className: "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3",
|
|
1840
|
+
className: "[&>svg]:text-muted-foreground flex min-w-0 max-w-[8rem] items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3",
|
|
1747
1841
|
children: [
|
|
1748
1842
|
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1749
1843
|
"div",
|
|
@@ -1752,7 +1846,7 @@ function ChartLegendContent({
|
|
|
1752
1846
|
style: { backgroundColor: item.color }
|
|
1753
1847
|
}
|
|
1754
1848
|
),
|
|
1755
|
-
itemConfig?.label
|
|
1849
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "min-w-0 truncate", children: itemConfig?.label ?? (item.value != null ? String(item.value) : null) })
|
|
1756
1850
|
]
|
|
1757
1851
|
},
|
|
1758
1852
|
`${item.value ?? index}`
|
|
@@ -1775,6 +1869,83 @@ function getPayloadConfigFromPayload(config, payload, key) {
|
|
|
1775
1869
|
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
1776
1870
|
}
|
|
1777
1871
|
|
|
1872
|
+
// src/charts/chart-gradient-utils.ts
|
|
1873
|
+
function barGradientId(scopeId, dataKey) {
|
|
1874
|
+
return `bar-${scopeId}-${sanitizeId(dataKey)}`;
|
|
1875
|
+
}
|
|
1876
|
+
function pieGradientId(scopeId, key) {
|
|
1877
|
+
return `pie-${scopeId}-${sanitizeId(key)}`;
|
|
1878
|
+
}
|
|
1879
|
+
function sanitizeId(key) {
|
|
1880
|
+
return key.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1881
|
+
}
|
|
1882
|
+
function truncateLabel(text, maxChars = 14) {
|
|
1883
|
+
const s = String(text ?? "");
|
|
1884
|
+
if (s.length <= maxChars) return s;
|
|
1885
|
+
if (maxChars <= 1) return "\u2026";
|
|
1886
|
+
return `${s.slice(0, maxChars - 1)}\u2026`;
|
|
1887
|
+
}
|
|
1888
|
+
function estimateYAxisWidth(labels, { min = 48, max = 112, charWidth = 6.5 } = {}) {
|
|
1889
|
+
if (labels.length === 0) return min;
|
|
1890
|
+
const longest = labels.reduce((a, b) => a.length >= b.length ? a : b, "");
|
|
1891
|
+
return Math.min(max, Math.max(min, Math.ceil(longest.length * charWidth) + 12));
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// src/charts/chart-axis-tick.tsx
|
|
1895
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1896
|
+
var ChartAxisTick = ({
|
|
1897
|
+
x = 0,
|
|
1898
|
+
y = 0,
|
|
1899
|
+
payload,
|
|
1900
|
+
textAnchor = "end",
|
|
1901
|
+
maxChars = 14,
|
|
1902
|
+
clipTicks = true
|
|
1903
|
+
}) => {
|
|
1904
|
+
const raw = String(payload?.value ?? "");
|
|
1905
|
+
const label = clipTicks ? truncateLabel(raw, maxChars) : raw;
|
|
1906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { transform: `translate(${x},${y})`, children: [
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("title", { children: raw }),
|
|
1908
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1909
|
+
"text",
|
|
1910
|
+
{
|
|
1911
|
+
textAnchor,
|
|
1912
|
+
fill: "currentColor",
|
|
1913
|
+
className: "fill-muted-foreground",
|
|
1914
|
+
dominantBaseline: "middle",
|
|
1915
|
+
children: label
|
|
1916
|
+
}
|
|
1917
|
+
)
|
|
1918
|
+
] });
|
|
1919
|
+
};
|
|
1920
|
+
|
|
1921
|
+
// src/charts/chart-gradients.tsx
|
|
1922
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1923
|
+
var BarGradientDefs = ({
|
|
1924
|
+
scopeId,
|
|
1925
|
+
dataKeys,
|
|
1926
|
+
horizontal
|
|
1927
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: dataKeys.map((dataKey) => {
|
|
1928
|
+
const id = barGradientId(scopeId, dataKey);
|
|
1929
|
+
const color = `var(--color-${dataKey})`;
|
|
1930
|
+
if (horizontal) {
|
|
1931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "0", children: [
|
|
1932
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1933
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.55 })
|
|
1934
|
+
] }, dataKey);
|
|
1935
|
+
}
|
|
1936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
1937
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1938
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.55 })
|
|
1939
|
+
] }, dataKey);
|
|
1940
|
+
}) });
|
|
1941
|
+
var PieGradientDefs = ({ scopeId, slices }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: slices.map(({ key, color }) => {
|
|
1942
|
+
const id = pieGradientId(scopeId, key);
|
|
1943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "1", children: [
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.65 })
|
|
1946
|
+
] }, key);
|
|
1947
|
+
}) });
|
|
1948
|
+
|
|
1778
1949
|
// src/charts/geometry.ts
|
|
1779
1950
|
function toNum(value) {
|
|
1780
1951
|
const n = typeof value === "number" ? value : Number(value);
|
|
@@ -1792,15 +1963,52 @@ function formatCompact(value, unit) {
|
|
|
1792
1963
|
return unit ? `${s}${unit}` : s;
|
|
1793
1964
|
}
|
|
1794
1965
|
|
|
1966
|
+
// src/charts/line-area-chart-utils.ts
|
|
1967
|
+
function resolveChartMargin(options) {
|
|
1968
|
+
const { flush, showXAxis, showYAxis } = options;
|
|
1969
|
+
if (!flush) {
|
|
1970
|
+
return { top: 8, right: 12, bottom: 0, left: 0 };
|
|
1971
|
+
}
|
|
1972
|
+
const anyAxis = showXAxis || showYAxis;
|
|
1973
|
+
if (!anyAxis) {
|
|
1974
|
+
return { top: 8, right: 12, bottom: 8, left: 12 };
|
|
1975
|
+
}
|
|
1976
|
+
return {
|
|
1977
|
+
top: 8,
|
|
1978
|
+
right: 12,
|
|
1979
|
+
bottom: showXAxis ? 24 : 8,
|
|
1980
|
+
left: showYAxis ? 8 : 12
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
function flushBarCategoryGap(flush, showCategoryAxis) {
|
|
1984
|
+
return flush && showCategoryAxis ? "0%" : void 0;
|
|
1985
|
+
}
|
|
1986
|
+
function flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis) {
|
|
1987
|
+
return flush && (variant === "line" || variant === "area") && showXAxis && !showYAxis;
|
|
1988
|
+
}
|
|
1989
|
+
function resolveTooltipCategory(label, payload, xKey, data, formatX) {
|
|
1990
|
+
const row = payload?.[0]?.payload;
|
|
1991
|
+
if (row && xKey in row) {
|
|
1992
|
+
const idx = data.indexOf(row);
|
|
1993
|
+
return formatX(row[xKey], idx >= 0 ? idx : 0);
|
|
1994
|
+
}
|
|
1995
|
+
if (label != null && label !== "") {
|
|
1996
|
+
const idx = typeof label === "number" ? label : data.findIndex((r) => r[xKey] === label || String(r[xKey]) === String(label));
|
|
1997
|
+
return formatX(label, idx >= 0 ? idx : 0);
|
|
1998
|
+
}
|
|
1999
|
+
return "";
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1795
2002
|
// src/charts/line-area-chart.tsx
|
|
1796
|
-
var
|
|
2003
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2004
|
+
var INDEX_X_KEY = "__index";
|
|
1797
2005
|
var CHART_PALETTE = [
|
|
1798
|
-
"var(--chart-1, #
|
|
1799
|
-
"var(--chart-2, #
|
|
1800
|
-
"var(--chart-3, #
|
|
1801
|
-
"var(--chart-4, #
|
|
1802
|
-
"var(--chart-5, #
|
|
1803
|
-
"var(--chart-6, #
|
|
2006
|
+
"var(--chart-1, #4f46e5)",
|
|
2007
|
+
"var(--chart-2, #3b82f6)",
|
|
2008
|
+
"var(--chart-3, #0ea5e9)",
|
|
2009
|
+
"var(--chart-4, #6366f1)",
|
|
2010
|
+
"var(--chart-5, #60a5fa)",
|
|
2011
|
+
"var(--chart-6, #2563eb)"
|
|
1804
2012
|
];
|
|
1805
2013
|
var LineAreaChart = ({
|
|
1806
2014
|
data = [],
|
|
@@ -1825,9 +2033,11 @@ var LineAreaChart = ({
|
|
|
1825
2033
|
tooltipIndicator = "dot",
|
|
1826
2034
|
formatValue,
|
|
1827
2035
|
formatX,
|
|
2036
|
+
clipTicks = true,
|
|
1828
2037
|
className,
|
|
1829
2038
|
ariaLabel = "Chart"
|
|
1830
2039
|
}) => {
|
|
2040
|
+
const gradientScopeId = (0, import_react7.useId)().replace(/:/g, "");
|
|
1831
2041
|
const xKey = xKeyProp ?? inferXKey(data);
|
|
1832
2042
|
const series = resolveSeries(seriesProp, data, xKey);
|
|
1833
2043
|
const flush = layout === "flush";
|
|
@@ -1837,7 +2047,7 @@ var LineAreaChart = ({
|
|
|
1837
2047
|
const showLegend = showLegendProp ?? (!flush && series.length > 1);
|
|
1838
2048
|
const grid = gridLines ?? (horizontal ? "vertical" : "horizontal");
|
|
1839
2049
|
if (data.length === 0 || series.length === 0) {
|
|
1840
|
-
return /* @__PURE__ */ (0,
|
|
2050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartEmpty, { className, height, ariaLabel });
|
|
1841
2051
|
}
|
|
1842
2052
|
const config = {};
|
|
1843
2053
|
series.forEach((s, i) => {
|
|
@@ -1848,25 +2058,52 @@ var LineAreaChart = ({
|
|
|
1848
2058
|
});
|
|
1849
2059
|
const valueFmt = (v) => formatValue ? formatValue(toNum(v)) : formatCompact(toNum(v), unit);
|
|
1850
2060
|
const xFmt = (v, i) => formatX ? formatX(v, i) : String(v ?? "");
|
|
1851
|
-
const margin =
|
|
2061
|
+
const margin = resolveChartMargin({ flush, showXAxis, showYAxis });
|
|
2062
|
+
const flushCategoryXAxisProps = flush && showXAxis && flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis) ? { scale: "point", padding: "no-gap", interval: 0 } : flush && showXAxis && variant === "bar" ? { interval: 0 } : {};
|
|
2063
|
+
const useIndexX = flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis);
|
|
2064
|
+
const chartData = useIndexX ? data.map((row, i) => ({ ...row, [INDEX_X_KEY]: i })) : data;
|
|
2065
|
+
const chartXKey = useIndexX ? INDEX_X_KEY : xKey;
|
|
2066
|
+
const categoryTick = (textAnchor) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartAxisTick, { textAnchor, clipTicks });
|
|
1852
2067
|
const showVGrid = showGrid && (grid === "vertical" || grid === "both");
|
|
1853
2068
|
const showHGrid = showGrid && (grid === "horizontal" || grid === "both");
|
|
1854
|
-
const tooltipEl = showTooltip ? /* @__PURE__ */ (0,
|
|
2069
|
+
const tooltipEl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1855
2070
|
ChartTooltip,
|
|
1856
2071
|
{
|
|
1857
2072
|
cursor: variant === "bar",
|
|
1858
|
-
content: /* @__PURE__ */ (0,
|
|
2073
|
+
content: ({ active, payload, label }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2074
|
+
ChartTooltipContent,
|
|
2075
|
+
{
|
|
2076
|
+
active,
|
|
2077
|
+
payload,
|
|
2078
|
+
label,
|
|
2079
|
+
indicator: tooltipIndicator,
|
|
2080
|
+
labelFormatter: (_value, items) => {
|
|
2081
|
+
const category = resolveTooltipCategory(label, items, xKey, data, xFmt);
|
|
2082
|
+
return category || null;
|
|
2083
|
+
},
|
|
2084
|
+
formatter: (value, name, item) => {
|
|
2085
|
+
const key = String(item.dataKey ?? name ?? "value");
|
|
2086
|
+
const seriesLabel = config[key]?.label ?? name;
|
|
2087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-1 items-center justify-between leading-none", children: [
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-muted-foreground", children: seriesLabel }),
|
|
2089
|
+
value != null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-foreground font-mono font-medium tabular-nums", children: valueFmt(value) }) : null
|
|
2090
|
+
] });
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
)
|
|
1859
2094
|
}
|
|
1860
2095
|
) : null;
|
|
1861
|
-
const legendEl = showLegend ? /* @__PURE__ */ (0,
|
|
1862
|
-
const gridEl = showGrid && grid !== "none" ? /* @__PURE__ */ (0,
|
|
2096
|
+
const legendEl = showLegend ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegendContent, {}) }) : null;
|
|
2097
|
+
const gridEl = showGrid && grid !== "none" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.CartesianGrid, { vertical: showVGrid, horizontal: showHGrid, strokeDasharray: "4 4" }) : null;
|
|
1863
2098
|
const yDomain = yMax != null ? [0, yMax] : void 0;
|
|
1864
2099
|
if (variant === "bar") {
|
|
1865
|
-
const
|
|
2100
|
+
const dataKeys = series.map((s) => s.dataKey);
|
|
2101
|
+
const barDefs = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BarGradientDefs, { scopeId: gradientScopeId, dataKeys, horizontal });
|
|
2102
|
+
const bars = series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1866
2103
|
import_recharts.Bar,
|
|
1867
2104
|
{
|
|
1868
2105
|
dataKey: s.dataKey,
|
|
1869
|
-
fill: `
|
|
2106
|
+
fill: `url(#${barGradientId(gradientScopeId, s.dataKey)})`,
|
|
1870
2107
|
radius: barCornerRadius(barRadius, horizontal, stacked),
|
|
1871
2108
|
stackId: stacked ? "stack" : void 0,
|
|
1872
2109
|
isAnimationActive: true
|
|
@@ -1874,149 +2111,212 @@ var LineAreaChart = ({
|
|
|
1874
2111
|
s.dataKey
|
|
1875
2112
|
));
|
|
1876
2113
|
if (horizontal) {
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
hide: !showXAxis,
|
|
1884
|
-
tickLine: false,
|
|
1885
|
-
axisLine: false,
|
|
1886
|
-
tickMargin: 8,
|
|
1887
|
-
tickFormatter: (v) => valueFmt(v),
|
|
1888
|
-
domain: yDomain
|
|
1889
|
-
}
|
|
1890
|
-
),
|
|
1891
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1892
|
-
import_recharts.YAxis,
|
|
1893
|
-
{
|
|
1894
|
-
type: "category",
|
|
1895
|
-
dataKey: xKey,
|
|
1896
|
-
hide: !showYAxis,
|
|
1897
|
-
tickLine: false,
|
|
1898
|
-
axisLine: false,
|
|
1899
|
-
tickMargin: 8,
|
|
1900
|
-
width: showYAxis ? void 0 : 0,
|
|
1901
|
-
tickFormatter: (v, i) => xFmt(v, i)
|
|
1902
|
-
}
|
|
1903
|
-
),
|
|
1904
|
-
tooltipEl,
|
|
1905
|
-
legendEl,
|
|
1906
|
-
bars
|
|
1907
|
-
] }) });
|
|
1908
|
-
}
|
|
1909
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_recharts.BarChart, { accessibilityLayer: true, data, margin, children: [
|
|
1910
|
-
gridEl,
|
|
1911
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1912
|
-
import_recharts.XAxis,
|
|
1913
|
-
{
|
|
1914
|
-
dataKey: xKey,
|
|
1915
|
-
hide: !showXAxis,
|
|
1916
|
-
tickLine: false,
|
|
1917
|
-
axisLine: false,
|
|
1918
|
-
tickMargin: 8,
|
|
1919
|
-
minTickGap: 16,
|
|
1920
|
-
tickFormatter: (v, i) => xFmt(v, i)
|
|
1921
|
-
}
|
|
1922
|
-
),
|
|
1923
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1924
|
-
import_recharts.YAxis,
|
|
2114
|
+
const categoryLabels = data.map((row, i) => xFmt(row[xKey], i));
|
|
2115
|
+
const yAxisWidth = showYAxis ? estimateYAxisWidth(
|
|
2116
|
+
clipTicks ? categoryLabels.map((l) => l.slice(0, 14)) : categoryLabels
|
|
2117
|
+
) : 0;
|
|
2118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2119
|
+
import_recharts.BarChart,
|
|
1925
2120
|
{
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
2121
|
+
accessibilityLayer: true,
|
|
2122
|
+
data,
|
|
2123
|
+
layout: "vertical",
|
|
2124
|
+
margin,
|
|
2125
|
+
barCategoryGap: flushBarCategoryGap(flush, showYAxis),
|
|
2126
|
+
children: [
|
|
2127
|
+
barDefs,
|
|
2128
|
+
gridEl,
|
|
2129
|
+
showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2130
|
+
import_recharts.XAxis,
|
|
2131
|
+
{
|
|
2132
|
+
type: "number",
|
|
2133
|
+
tickLine: false,
|
|
2134
|
+
axisLine: false,
|
|
2135
|
+
tickMargin: 8,
|
|
2136
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2137
|
+
domain: yDomain
|
|
2138
|
+
}
|
|
2139
|
+
) : null,
|
|
2140
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2141
|
+
import_recharts.YAxis,
|
|
2142
|
+
{
|
|
2143
|
+
type: "category",
|
|
2144
|
+
dataKey: xKey,
|
|
2145
|
+
tickLine: false,
|
|
2146
|
+
axisLine: false,
|
|
2147
|
+
tickMargin: 8,
|
|
2148
|
+
width: yAxisWidth,
|
|
2149
|
+
minTickGap: 16,
|
|
2150
|
+
tick: categoryTick("end")
|
|
2151
|
+
}
|
|
2152
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.YAxis, { type: "category", dataKey: xKey, hide: true, width: 0 }),
|
|
2153
|
+
tooltipEl,
|
|
2154
|
+
legendEl,
|
|
2155
|
+
bars
|
|
2156
|
+
]
|
|
1933
2157
|
}
|
|
1934
|
-
)
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2158
|
+
) });
|
|
2159
|
+
}
|
|
2160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2161
|
+
import_recharts.BarChart,
|
|
2162
|
+
{
|
|
2163
|
+
accessibilityLayer: true,
|
|
2164
|
+
data,
|
|
2165
|
+
margin,
|
|
2166
|
+
barCategoryGap: flushBarCategoryGap(flush, showXAxis),
|
|
2167
|
+
children: [
|
|
2168
|
+
barDefs,
|
|
2169
|
+
gridEl,
|
|
2170
|
+
showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2171
|
+
import_recharts.XAxis,
|
|
2172
|
+
{
|
|
2173
|
+
dataKey: xKey,
|
|
2174
|
+
tickLine: false,
|
|
2175
|
+
axisLine: false,
|
|
2176
|
+
tickMargin: 8,
|
|
2177
|
+
minTickGap: 16,
|
|
2178
|
+
tick: categoryTick("middle"),
|
|
2179
|
+
...flushCategoryXAxisProps
|
|
2180
|
+
}
|
|
2181
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.XAxis, { dataKey: xKey, hide: true }),
|
|
2182
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2183
|
+
import_recharts.YAxis,
|
|
2184
|
+
{
|
|
2185
|
+
tickLine: false,
|
|
2186
|
+
axisLine: false,
|
|
2187
|
+
tickMargin: 8,
|
|
2188
|
+
width: 44,
|
|
2189
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2190
|
+
domain: yDomain
|
|
2191
|
+
}
|
|
2192
|
+
) : null,
|
|
2193
|
+
tooltipEl,
|
|
2194
|
+
legendEl,
|
|
2195
|
+
bars
|
|
2196
|
+
]
|
|
2197
|
+
}
|
|
2198
|
+
) });
|
|
1939
2199
|
}
|
|
1940
|
-
const
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
2200
|
+
const lineAreaAxes = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2201
|
+
showXAxis && useIndexX ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2202
|
+
import_recharts.XAxis,
|
|
2203
|
+
{
|
|
2204
|
+
type: "number",
|
|
2205
|
+
dataKey: INDEX_X_KEY,
|
|
2206
|
+
domain: [0, Math.max(0, chartData.length - 1)],
|
|
2207
|
+
allowDecimals: false,
|
|
2208
|
+
ticks: chartData.map((_, i) => i),
|
|
2209
|
+
tickLine: false,
|
|
2210
|
+
axisLine: false,
|
|
2211
|
+
tickMargin: 8,
|
|
2212
|
+
tickFormatter: (i) => {
|
|
2213
|
+
const row = chartData[Number(i)];
|
|
2214
|
+
return row ? xFmt(row[xKey], Number(i)) : "";
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
) : showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1942
2218
|
import_recharts.XAxis,
|
|
1943
2219
|
{
|
|
1944
2220
|
dataKey: xKey,
|
|
1945
|
-
hide: !showXAxis,
|
|
1946
2221
|
tickLine: false,
|
|
1947
2222
|
axisLine: false,
|
|
1948
2223
|
tickMargin: 8,
|
|
1949
|
-
minTickGap: 24,
|
|
1950
|
-
tickFormatter: (v, i) => xFmt(v, i)
|
|
2224
|
+
minTickGap: flush ? 8 : 24,
|
|
2225
|
+
tickFormatter: (v, i) => xFmt(v, i),
|
|
2226
|
+
...flushCategoryXAxisProps
|
|
1951
2227
|
}
|
|
1952
|
-
),
|
|
1953
|
-
/* @__PURE__ */ (0,
|
|
2228
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.XAxis, { dataKey: chartXKey, hide: true }),
|
|
2229
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1954
2230
|
import_recharts.YAxis,
|
|
1955
2231
|
{
|
|
1956
|
-
hide: !showYAxis,
|
|
1957
2232
|
tickLine: false,
|
|
1958
2233
|
axisLine: false,
|
|
1959
2234
|
tickMargin: 8,
|
|
1960
|
-
width:
|
|
2235
|
+
width: 44,
|
|
1961
2236
|
tickFormatter: (v) => valueFmt(v),
|
|
1962
2237
|
domain: yDomain
|
|
1963
2238
|
}
|
|
1964
|
-
)
|
|
2239
|
+
) : null
|
|
1965
2240
|
] });
|
|
2241
|
+
const chartA11y = flush ? {} : { accessibilityLayer: true };
|
|
1966
2242
|
if (variant === "area") {
|
|
1967
|
-
return /* @__PURE__ */ (0,
|
|
1968
|
-
|
|
1969
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
|
|
1970
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.04 })
|
|
1971
|
-
] }, s.dataKey)) }),
|
|
1972
|
-
gridEl,
|
|
1973
|
-
axes,
|
|
1974
|
-
tooltipEl,
|
|
1975
|
-
legendEl,
|
|
1976
|
-
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1977
|
-
import_recharts.Area,
|
|
1978
|
-
{
|
|
1979
|
-
dataKey: s.dataKey,
|
|
1980
|
-
type: curve,
|
|
1981
|
-
stackId: stacked ? "stack" : void 0,
|
|
1982
|
-
stroke: `var(--color-${s.dataKey})`,
|
|
1983
|
-
strokeWidth: 2,
|
|
1984
|
-
fill: `url(#fill-${s.dataKey})`,
|
|
1985
|
-
dot: dots === true ? { r: 3 } : false,
|
|
1986
|
-
activeDot: { r: 4 },
|
|
1987
|
-
isAnimationActive: true
|
|
1988
|
-
},
|
|
1989
|
-
s.dataKey
|
|
1990
|
-
))
|
|
1991
|
-
] }) });
|
|
1992
|
-
}
|
|
1993
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_recharts.LineChart, { accessibilityLayer: true, data, margin, children: [
|
|
1994
|
-
gridEl,
|
|
1995
|
-
axes,
|
|
1996
|
-
tooltipEl,
|
|
1997
|
-
legendEl,
|
|
1998
|
-
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1999
|
-
import_recharts.Line,
|
|
2243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2244
|
+
ChartShell,
|
|
2000
2245
|
{
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2246
|
+
config,
|
|
2247
|
+
height,
|
|
2248
|
+
className,
|
|
2249
|
+
ariaLabel,
|
|
2250
|
+
flush,
|
|
2251
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts.AreaChart, { ...chartA11y, data: chartData, margin, children: [
|
|
2252
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("linearGradient", { id: `fill-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2253
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
|
|
2254
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.04 })
|
|
2255
|
+
] }, s.dataKey)) }),
|
|
2256
|
+
gridEl,
|
|
2257
|
+
lineAreaAxes,
|
|
2258
|
+
tooltipEl,
|
|
2259
|
+
legendEl,
|
|
2260
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2261
|
+
import_recharts.Area,
|
|
2262
|
+
{
|
|
2263
|
+
dataKey: s.dataKey,
|
|
2264
|
+
type: curve,
|
|
2265
|
+
stackId: stacked ? "stack" : void 0,
|
|
2266
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2267
|
+
strokeWidth: 2,
|
|
2268
|
+
fill: `url(#fill-${s.dataKey})`,
|
|
2269
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2270
|
+
activeDot: { r: 4 },
|
|
2271
|
+
isAnimationActive: true
|
|
2272
|
+
},
|
|
2273
|
+
s.dataKey
|
|
2274
|
+
))
|
|
2275
|
+
] })
|
|
2276
|
+
}
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2280
|
+
ChartShell,
|
|
2281
|
+
{
|
|
2282
|
+
config,
|
|
2283
|
+
height,
|
|
2284
|
+
className,
|
|
2285
|
+
ariaLabel,
|
|
2286
|
+
flush,
|
|
2287
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts.LineChart, { ...chartA11y, data: chartData, margin, children: [
|
|
2288
|
+
gridEl,
|
|
2289
|
+
lineAreaAxes,
|
|
2290
|
+
tooltipEl,
|
|
2291
|
+
legendEl,
|
|
2292
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2293
|
+
import_recharts.Line,
|
|
2294
|
+
{
|
|
2295
|
+
dataKey: s.dataKey,
|
|
2296
|
+
type: curve,
|
|
2297
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2298
|
+
strokeWidth: 2,
|
|
2299
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2300
|
+
activeDot: { r: 4 },
|
|
2301
|
+
isAnimationActive: true
|
|
2302
|
+
},
|
|
2303
|
+
s.dataKey
|
|
2304
|
+
))
|
|
2305
|
+
] })
|
|
2306
|
+
}
|
|
2307
|
+
);
|
|
2012
2308
|
};
|
|
2013
|
-
var ChartShell = ({ config, height, className, ariaLabel, children }) => /* @__PURE__ */ (0,
|
|
2309
|
+
var ChartShell = ({ config, height, className, ariaLabel, flush = false, children }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2014
2310
|
ChartContainer,
|
|
2015
2311
|
{
|
|
2016
2312
|
config,
|
|
2017
2313
|
role: "img",
|
|
2018
2314
|
"aria-label": ariaLabel,
|
|
2019
|
-
className: cn(
|
|
2315
|
+
className: cn(
|
|
2316
|
+
"aspect-auto w-full",
|
|
2317
|
+
flush && "justify-start [&_.recharts-responsive-container]:!mx-0 [&_.recharts-responsive-container]:w-full",
|
|
2318
|
+
className
|
|
2319
|
+
),
|
|
2020
2320
|
style: { height },
|
|
2021
2321
|
children
|
|
2022
2322
|
}
|
|
@@ -2025,7 +2325,7 @@ var ChartEmpty = ({
|
|
|
2025
2325
|
className,
|
|
2026
2326
|
height,
|
|
2027
2327
|
ariaLabel
|
|
2028
|
-
}) => /* @__PURE__ */ (0,
|
|
2328
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2029
2329
|
"div",
|
|
2030
2330
|
{
|
|
2031
2331
|
className: cn(
|
|
@@ -2058,8 +2358,35 @@ function resolveSeries(seriesProp, data, xKey) {
|
|
|
2058
2358
|
}
|
|
2059
2359
|
|
|
2060
2360
|
// src/charts/pie-chart.tsx
|
|
2361
|
+
var import_react8 = require("react");
|
|
2061
2362
|
var import_recharts2 = require("recharts");
|
|
2062
|
-
|
|
2363
|
+
|
|
2364
|
+
// src/charts/chart-center-label.tsx
|
|
2365
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2366
|
+
var CENTER_BOX_W = 96;
|
|
2367
|
+
var CENTER_BOX_H = 52;
|
|
2368
|
+
var ChartCenterLabel = ({ cx, cy, value, label }) => {
|
|
2369
|
+
const hasValue = value != null && value !== "";
|
|
2370
|
+
const hasLabel = label != null && label !== "";
|
|
2371
|
+
if (!hasValue && !hasLabel) return null;
|
|
2372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2373
|
+
"foreignObject",
|
|
2374
|
+
{
|
|
2375
|
+
x: cx - CENTER_BOX_W / 2,
|
|
2376
|
+
y: cy - CENTER_BOX_H / 2,
|
|
2377
|
+
width: CENTER_BOX_W,
|
|
2378
|
+
height: CENTER_BOX_H,
|
|
2379
|
+
className: "overflow-visible",
|
|
2380
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "pointer-events-none flex h-full flex-col items-center justify-center gap-0.5 text-center", children: [
|
|
2381
|
+
hasValue ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-2xl font-normal leading-none tabular-nums text-foreground", children: value }) : null,
|
|
2382
|
+
hasLabel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-[11px] leading-none text-muted-foreground", children: label }) : null
|
|
2383
|
+
] })
|
|
2384
|
+
}
|
|
2385
|
+
);
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
// src/charts/pie-chart.tsx
|
|
2389
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2063
2390
|
var PieChart = ({
|
|
2064
2391
|
data,
|
|
2065
2392
|
nameKey: nameKeyProp,
|
|
@@ -2076,10 +2403,11 @@ var PieChart = ({
|
|
|
2076
2403
|
className,
|
|
2077
2404
|
ariaLabel = "Pie chart"
|
|
2078
2405
|
}) => {
|
|
2406
|
+
const gradientScopeId = (0, import_react8.useId)().replace(/:/g, "");
|
|
2079
2407
|
const nameKey = nameKeyProp ?? inferNameKey(data, dataKey);
|
|
2080
2408
|
const palette = colors ?? CHART_PALETTE;
|
|
2081
2409
|
if (data.length === 0) {
|
|
2082
|
-
return /* @__PURE__ */ (0,
|
|
2410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PieEmpty, { className, height, ariaLabel });
|
|
2083
2411
|
}
|
|
2084
2412
|
const slices = data.map((d, i) => ({
|
|
2085
2413
|
name: String(d[nameKey] ?? i),
|
|
@@ -2090,7 +2418,7 @@ var PieChart = ({
|
|
|
2090
2418
|
for (const s of slices) config[s.name] = { label: s.name };
|
|
2091
2419
|
const innerPct = innerRadius > 0 ? `${Math.round(innerRadius * 75)}%` : 0;
|
|
2092
2420
|
const hasCenter = innerRadius > 0 && (centerValue != null || centerLabel != null);
|
|
2093
|
-
return /* @__PURE__ */ (0,
|
|
2421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2094
2422
|
ChartContainer,
|
|
2095
2423
|
{
|
|
2096
2424
|
config,
|
|
@@ -2098,14 +2426,21 @@ var PieChart = ({
|
|
|
2098
2426
|
"aria-label": ariaLabel,
|
|
2099
2427
|
className: cn("aspect-auto w-full", className),
|
|
2100
2428
|
style: { height },
|
|
2101
|
-
children: /* @__PURE__ */ (0,
|
|
2102
|
-
|
|
2429
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_recharts2.PieChart, { children: [
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2431
|
+
PieGradientDefs,
|
|
2432
|
+
{
|
|
2433
|
+
scopeId: gradientScopeId,
|
|
2434
|
+
slices: slices.map((s) => ({ key: s.name, color: s.fill }))
|
|
2435
|
+
}
|
|
2436
|
+
),
|
|
2437
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2103
2438
|
ChartTooltip,
|
|
2104
2439
|
{
|
|
2105
|
-
content: /* @__PURE__ */ (0,
|
|
2440
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartTooltipContent, { nameKey: "name", indicator: tooltipIndicator, hideLabel: true })
|
|
2106
2441
|
}
|
|
2107
2442
|
),
|
|
2108
|
-
/* @__PURE__ */ (0,
|
|
2443
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2109
2444
|
import_recharts2.Pie,
|
|
2110
2445
|
{
|
|
2111
2446
|
data: slices,
|
|
@@ -2118,24 +2453,30 @@ var PieChart = ({
|
|
|
2118
2453
|
label: showLabels,
|
|
2119
2454
|
isAnimationActive: true,
|
|
2120
2455
|
children: [
|
|
2121
|
-
slices.map((s) => /* @__PURE__ */ (0,
|
|
2122
|
-
hasCenter && /* @__PURE__ */ (0,
|
|
2456
|
+
slices.map((s) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts2.Cell, { fill: `url(#${pieGradientId(gradientScopeId, s.name)})` }, s.name)),
|
|
2457
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2123
2458
|
import_recharts2.Label,
|
|
2124
2459
|
{
|
|
2460
|
+
position: "center",
|
|
2125
2461
|
content: ({ viewBox }) => {
|
|
2126
2462
|
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2127
2463
|
const { cx, cy } = viewBox;
|
|
2128
|
-
return /* @__PURE__ */ (0,
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2465
|
+
ChartCenterLabel,
|
|
2466
|
+
{
|
|
2467
|
+
cx,
|
|
2468
|
+
cy,
|
|
2469
|
+
value: centerValue,
|
|
2470
|
+
label: centerLabel
|
|
2471
|
+
}
|
|
2472
|
+
);
|
|
2132
2473
|
}
|
|
2133
2474
|
}
|
|
2134
2475
|
)
|
|
2135
2476
|
]
|
|
2136
2477
|
}
|
|
2137
2478
|
),
|
|
2138
|
-
showLegend && /* @__PURE__ */ (0,
|
|
2479
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartLegendContent, { nameKey: "name" }) })
|
|
2139
2480
|
] })
|
|
2140
2481
|
}
|
|
2141
2482
|
);
|
|
@@ -2144,7 +2485,7 @@ var PieEmpty = ({
|
|
|
2144
2485
|
className,
|
|
2145
2486
|
height,
|
|
2146
2487
|
ariaLabel
|
|
2147
|
-
}) => /* @__PURE__ */ (0,
|
|
2488
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2148
2489
|
"div",
|
|
2149
2490
|
{
|
|
2150
2491
|
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
@@ -2163,8 +2504,9 @@ function inferNameKey(data, dataKey) {
|
|
|
2163
2504
|
}
|
|
2164
2505
|
|
|
2165
2506
|
// src/charts/radial-chart.tsx
|
|
2507
|
+
var import_react9 = require("react");
|
|
2166
2508
|
var import_recharts3 = require("recharts");
|
|
2167
|
-
var
|
|
2509
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2168
2510
|
var RadialChart = ({
|
|
2169
2511
|
data,
|
|
2170
2512
|
nameKey: nameKeyProp,
|
|
@@ -2180,10 +2522,11 @@ var RadialChart = ({
|
|
|
2180
2522
|
className,
|
|
2181
2523
|
ariaLabel = "Radial chart"
|
|
2182
2524
|
}) => {
|
|
2525
|
+
const gradientScopeId = (0, import_react9.useId)().replace(/:/g, "");
|
|
2183
2526
|
const nameKey = nameKeyProp ?? inferNameKey2(data, dataKey);
|
|
2184
2527
|
const palette = colors ?? CHART_PALETTE;
|
|
2185
2528
|
if (data.length === 0) {
|
|
2186
|
-
return /* @__PURE__ */ (0,
|
|
2529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RadialEmpty, { className, height, ariaLabel });
|
|
2187
2530
|
}
|
|
2188
2531
|
const rows = data.map((d, i) => ({
|
|
2189
2532
|
name: String(d[nameKey] ?? i),
|
|
@@ -2194,8 +2537,8 @@ var RadialChart = ({
|
|
|
2194
2537
|
const config = {};
|
|
2195
2538
|
for (const r of rows) config[r.name] = { label: r.name };
|
|
2196
2539
|
const hasCenter = centerValue != null || centerLabel != null;
|
|
2197
|
-
return /* @__PURE__ */ (0,
|
|
2198
|
-
/* @__PURE__ */ (0,
|
|
2540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("flex w-full flex-col items-center gap-3", className), children: [
|
|
2541
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2199
2542
|
ChartContainer,
|
|
2200
2543
|
{
|
|
2201
2544
|
config,
|
|
@@ -2203,7 +2546,7 @@ var RadialChart = ({
|
|
|
2203
2546
|
"aria-label": ariaLabel,
|
|
2204
2547
|
className: "aspect-auto w-full",
|
|
2205
2548
|
style: { height: height - (showLegend ? 32 : 0) },
|
|
2206
|
-
children: /* @__PURE__ */ (0,
|
|
2549
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2207
2550
|
import_recharts3.RadialBarChart,
|
|
2208
2551
|
{
|
|
2209
2552
|
data: rows,
|
|
@@ -2214,19 +2557,32 @@ var RadialChart = ({
|
|
|
2214
2557
|
barSize: ringWidth,
|
|
2215
2558
|
barGap: ringGap,
|
|
2216
2559
|
children: [
|
|
2217
|
-
/* @__PURE__ */ (0,
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2561
|
+
PieGradientDefs,
|
|
2562
|
+
{
|
|
2563
|
+
scopeId: gradientScopeId,
|
|
2564
|
+
slices: rows.map((r) => ({ key: r.name, color: r.fill }))
|
|
2565
|
+
}
|
|
2566
|
+
),
|
|
2567
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.PolarAngleAxis, { type: "number", domain: [0, max], tick: false, axisLine: false }),
|
|
2568
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartTooltipContent, { nameKey: "name", hideLabel: true }) }),
|
|
2569
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.RadialBar, { dataKey: "value", background: true, cornerRadius: ringWidth / 2, isAnimationActive: true, children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.Cell, { fill: `url(#${pieGradientId(gradientScopeId, r.name)})` }, r.name)) }),
|
|
2570
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.PolarRadiusAxis, { tick: false, tickLine: false, axisLine: false, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2221
2571
|
import_recharts3.Label,
|
|
2222
2572
|
{
|
|
2573
|
+
position: "center",
|
|
2223
2574
|
content: ({ viewBox }) => {
|
|
2224
2575
|
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2225
2576
|
const { cx, cy } = viewBox;
|
|
2226
|
-
return /* @__PURE__ */ (0,
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2578
|
+
ChartCenterLabel,
|
|
2579
|
+
{
|
|
2580
|
+
cx,
|
|
2581
|
+
cy,
|
|
2582
|
+
value: centerValue,
|
|
2583
|
+
label: centerLabel
|
|
2584
|
+
}
|
|
2585
|
+
);
|
|
2230
2586
|
}
|
|
2231
2587
|
}
|
|
2232
2588
|
) })
|
|
@@ -2235,8 +2591,8 @@ var RadialChart = ({
|
|
|
2235
2591
|
)
|
|
2236
2592
|
}
|
|
2237
2593
|
),
|
|
2238
|
-
showLegend && /* @__PURE__ */ (0,
|
|
2239
|
-
/* @__PURE__ */ (0,
|
|
2594
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2595
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "inline-block size-2.5 rounded-[3px]", style: { background: r.fill } }),
|
|
2240
2596
|
r.name
|
|
2241
2597
|
] }, r.name)) })
|
|
2242
2598
|
] });
|
|
@@ -2245,7 +2601,7 @@ var RadialEmpty = ({
|
|
|
2245
2601
|
className,
|
|
2246
2602
|
height,
|
|
2247
2603
|
ariaLabel
|
|
2248
|
-
}) => /* @__PURE__ */ (0,
|
|
2604
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2249
2605
|
"div",
|
|
2250
2606
|
{
|
|
2251
2607
|
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
@@ -2265,7 +2621,7 @@ function inferNameKey2(data, dataKey) {
|
|
|
2265
2621
|
|
|
2266
2622
|
// src/charts/radar-chart.tsx
|
|
2267
2623
|
var import_recharts4 = require("recharts");
|
|
2268
|
-
var
|
|
2624
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2269
2625
|
var RadarChart = ({
|
|
2270
2626
|
data,
|
|
2271
2627
|
nameKey: nameKeyProp,
|
|
@@ -2280,7 +2636,7 @@ var RadarChart = ({
|
|
|
2280
2636
|
const nameKey = nameKeyProp ?? inferNameKey3(data);
|
|
2281
2637
|
const series = resolveSeries2(seriesProp, data, nameKey);
|
|
2282
2638
|
if (data.length < 3 || series.length === 0) {
|
|
2283
|
-
return /* @__PURE__ */ (0,
|
|
2639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2284
2640
|
"div",
|
|
2285
2641
|
{
|
|
2286
2642
|
className: cn("flex items-center justify-center text-xs text-muted-foreground", className),
|
|
@@ -2298,7 +2654,7 @@ var RadarChart = ({
|
|
|
2298
2654
|
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2299
2655
|
};
|
|
2300
2656
|
});
|
|
2301
|
-
return /* @__PURE__ */ (0,
|
|
2657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2302
2658
|
ChartContainer,
|
|
2303
2659
|
{
|
|
2304
2660
|
config,
|
|
@@ -2306,17 +2662,17 @@ var RadarChart = ({
|
|
|
2306
2662
|
"aria-label": ariaLabel,
|
|
2307
2663
|
className: cn("mx-auto aspect-square", className),
|
|
2308
2664
|
style: { height },
|
|
2309
|
-
children: /* @__PURE__ */ (0,
|
|
2310
|
-
/* @__PURE__ */ (0,
|
|
2311
|
-
/* @__PURE__ */ (0,
|
|
2312
|
-
/* @__PURE__ */ (0,
|
|
2665
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_recharts4.RadarChart, { data, outerRadius: "70%", children: [
|
|
2666
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltipContent, { indicator: "line" }) }),
|
|
2667
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_recharts4.PolarGrid, {}),
|
|
2668
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2313
2669
|
import_recharts4.PolarAngleAxis,
|
|
2314
2670
|
{
|
|
2315
2671
|
dataKey: nameKey,
|
|
2316
2672
|
tick: { fontSize: 10, fill: "var(--color-muted-foreground)" }
|
|
2317
2673
|
}
|
|
2318
2674
|
),
|
|
2319
|
-
series.map((s) => /* @__PURE__ */ (0,
|
|
2675
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2320
2676
|
import_recharts4.Radar,
|
|
2321
2677
|
{
|
|
2322
2678
|
dataKey: s.dataKey,
|
|
@@ -2329,7 +2685,7 @@ var RadarChart = ({
|
|
|
2329
2685
|
},
|
|
2330
2686
|
s.dataKey
|
|
2331
2687
|
)),
|
|
2332
|
-
showLegend && series.length > 1 && /* @__PURE__ */ (0,
|
|
2688
|
+
showLegend && series.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartLegendContent, {}) })
|
|
2333
2689
|
] })
|
|
2334
2690
|
}
|
|
2335
2691
|
);
|
|
@@ -2350,10 +2706,10 @@ function resolveSeries2(seriesProp, data, nameKey) {
|
|
|
2350
2706
|
}
|
|
2351
2707
|
|
|
2352
2708
|
// src/artifacts/artifact-card.tsx
|
|
2353
|
-
var
|
|
2709
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2354
2710
|
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
2355
2711
|
const hasHeader = Boolean(title || toolbar);
|
|
2356
|
-
return /* @__PURE__ */ (0,
|
|
2712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2357
2713
|
"div",
|
|
2358
2714
|
{
|
|
2359
2715
|
className: cn(
|
|
@@ -2362,29 +2718,29 @@ var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }
|
|
|
2362
2718
|
),
|
|
2363
2719
|
"data-artifact-kind": kind,
|
|
2364
2720
|
children: [
|
|
2365
|
-
hasHeader && /* @__PURE__ */ (0,
|
|
2366
|
-
title && /* @__PURE__ */ (0,
|
|
2367
|
-
!title && /* @__PURE__ */ (0,
|
|
2721
|
+
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime17.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: [
|
|
2722
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
2723
|
+
!title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "flex-1" }),
|
|
2368
2724
|
toolbar
|
|
2369
2725
|
] }),
|
|
2370
|
-
/* @__PURE__ */ (0,
|
|
2726
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
2371
2727
|
]
|
|
2372
2728
|
}
|
|
2373
2729
|
);
|
|
2374
2730
|
};
|
|
2375
2731
|
|
|
2376
2732
|
// src/artifacts/chart-artifact.tsx
|
|
2377
|
-
var
|
|
2733
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2378
2734
|
var ChartArtifactView = ({
|
|
2379
2735
|
artifact,
|
|
2380
2736
|
embedded = false,
|
|
2381
2737
|
height = 300
|
|
2382
2738
|
}) => {
|
|
2383
|
-
const plot = /* @__PURE__ */ (0,
|
|
2739
|
+
const plot = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartArtifactPlot, { artifact, height });
|
|
2384
2740
|
if (embedded) {
|
|
2385
|
-
return /* @__PURE__ */ (0,
|
|
2741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
2386
2742
|
}
|
|
2387
|
-
return /* @__PURE__ */ (0,
|
|
2743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
2388
2744
|
};
|
|
2389
2745
|
function ChartArtifactPlot({
|
|
2390
2746
|
artifact,
|
|
@@ -2392,7 +2748,7 @@ function ChartArtifactPlot({
|
|
|
2392
2748
|
}) {
|
|
2393
2749
|
const { chartType = "bar", data = [] } = artifact;
|
|
2394
2750
|
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
2395
|
-
const series = (0,
|
|
2751
|
+
const series = (0, import_react10.useMemo)(() => {
|
|
2396
2752
|
if (artifact.series && artifact.series.length > 0) {
|
|
2397
2753
|
return artifact.series.map((s) => ({
|
|
2398
2754
|
dataKey: s.dataKey,
|
|
@@ -2410,7 +2766,7 @@ function ChartArtifactPlot({
|
|
|
2410
2766
|
const aria = typeof artifact.title === "string" ? artifact.title : "Chart";
|
|
2411
2767
|
if (chartType === "pie" || chartType === "donut") {
|
|
2412
2768
|
const total = data.reduce((sum, d) => sum + toNum(d[series[0]?.dataKey ?? "value"]), 0);
|
|
2413
|
-
return /* @__PURE__ */ (0,
|
|
2769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2414
2770
|
PieChart,
|
|
2415
2771
|
{
|
|
2416
2772
|
data,
|
|
@@ -2427,7 +2783,7 @@ function ChartArtifactPlot({
|
|
|
2427
2783
|
) });
|
|
2428
2784
|
}
|
|
2429
2785
|
if (chartType === "radial") {
|
|
2430
|
-
return /* @__PURE__ */ (0,
|
|
2786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2431
2787
|
RadialChart,
|
|
2432
2788
|
{
|
|
2433
2789
|
data,
|
|
@@ -2440,10 +2796,11 @@ function ChartArtifactPlot({
|
|
|
2440
2796
|
) });
|
|
2441
2797
|
}
|
|
2442
2798
|
if (chartType === "radar") {
|
|
2443
|
-
return /* @__PURE__ */ (0,
|
|
2799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadarChart, { data, nameKey: xKey, series, height, ariaLabel: aria }) });
|
|
2444
2800
|
}
|
|
2445
2801
|
const horizontal = chartType === "horizontalBar";
|
|
2446
|
-
|
|
2802
|
+
const showAxes = artifact.showAxes === true;
|
|
2803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2447
2804
|
LineAreaChart,
|
|
2448
2805
|
{
|
|
2449
2806
|
data,
|
|
@@ -2457,8 +2814,8 @@ function ChartArtifactPlot({
|
|
|
2457
2814
|
curve: artifact.curve,
|
|
2458
2815
|
dots: artifact.dots,
|
|
2459
2816
|
tooltipIndicator: artifact.tooltipIndicator,
|
|
2460
|
-
showXAxis:
|
|
2461
|
-
showYAxis: horizontal,
|
|
2817
|
+
showXAxis: showAxes,
|
|
2818
|
+
showYAxis: showAxes && horizontal,
|
|
2462
2819
|
showLegend: artifact.legend ?? series.length > 1,
|
|
2463
2820
|
unit: artifact.unit,
|
|
2464
2821
|
ariaLabel: aria
|
|
@@ -2480,8 +2837,8 @@ function inferDataKeys(data, xKey) {
|
|
|
2480
2837
|
}
|
|
2481
2838
|
|
|
2482
2839
|
// src/artifacts/question-artifact.tsx
|
|
2483
|
-
var
|
|
2484
|
-
var
|
|
2840
|
+
var import_react11 = require("react");
|
|
2841
|
+
var import_react12 = require("@assistant-ui/react");
|
|
2485
2842
|
var import_lucide_react3 = require("lucide-react");
|
|
2486
2843
|
|
|
2487
2844
|
// src/design/classes.ts
|
|
@@ -2590,12 +2947,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
2590
2947
|
);
|
|
2591
2948
|
|
|
2592
2949
|
// src/artifacts/question-artifact.tsx
|
|
2593
|
-
var
|
|
2950
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2594
2951
|
function optionKey(option, index) {
|
|
2595
2952
|
const id = option.id?.trim();
|
|
2596
2953
|
return id ? id : `__option-${index}`;
|
|
2597
2954
|
}
|
|
2598
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0,
|
|
2955
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2599
2956
|
"span",
|
|
2600
2957
|
{
|
|
2601
2958
|
className: cn(
|
|
@@ -2603,18 +2960,18 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx
|
|
|
2603
2960
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
2604
2961
|
),
|
|
2605
2962
|
"aria-hidden": true,
|
|
2606
|
-
children: selected ? /* @__PURE__ */ (0,
|
|
2963
|
+
children: selected ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react3.CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
2607
2964
|
}
|
|
2608
2965
|
);
|
|
2609
2966
|
var QuestionArtifactView = ({
|
|
2610
2967
|
artifact
|
|
2611
2968
|
}) => {
|
|
2612
|
-
const runtime = (0,
|
|
2613
|
-
const [selected, setSelected] = (0,
|
|
2614
|
-
const [submittedIds, setSubmittedIds] = (0,
|
|
2969
|
+
const runtime = (0, import_react12.useThreadRuntime)();
|
|
2970
|
+
const [selected, setSelected] = (0, import_react11.useState)([]);
|
|
2971
|
+
const [submittedIds, setSubmittedIds] = (0, import_react11.useState)(null);
|
|
2615
2972
|
const isMulti = artifact.multi === true;
|
|
2616
2973
|
const isDisabled = submittedIds !== null;
|
|
2617
|
-
const send = (0,
|
|
2974
|
+
const send = (0, import_react11.useCallback)(
|
|
2618
2975
|
(keys) => {
|
|
2619
2976
|
if (keys.length === 0) return;
|
|
2620
2977
|
const labels = artifact.options.map((option, index) => ({ option, key: optionKey(option, index) })).filter(({ key }) => keys.includes(key)).map(({ option }) => option.label);
|
|
@@ -2626,7 +2983,7 @@ var QuestionArtifactView = ({
|
|
|
2626
2983
|
},
|
|
2627
2984
|
[artifact.options, runtime]
|
|
2628
2985
|
);
|
|
2629
|
-
const onPick = (0,
|
|
2986
|
+
const onPick = (0, import_react11.useCallback)(
|
|
2630
2987
|
(key) => {
|
|
2631
2988
|
if (isDisabled) return;
|
|
2632
2989
|
if (!isMulti) {
|
|
@@ -2639,15 +2996,15 @@ var QuestionArtifactView = ({
|
|
|
2639
2996
|
},
|
|
2640
2997
|
[isDisabled, isMulti, send]
|
|
2641
2998
|
);
|
|
2642
|
-
const onConfirm = (0,
|
|
2999
|
+
const onConfirm = (0, import_react11.useCallback)(() => {
|
|
2643
3000
|
send(selected);
|
|
2644
3001
|
}, [selected, send]);
|
|
2645
|
-
return /* @__PURE__ */ (0,
|
|
2646
|
-
artifact.prompt ? /* @__PURE__ */ (0,
|
|
2647
|
-
/* @__PURE__ */ (0,
|
|
3002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "px-2.5 py-2", children: [
|
|
3003
|
+
artifact.prompt ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
2648
3005
|
const key = optionKey(option, index);
|
|
2649
3006
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
2650
|
-
return /* @__PURE__ */ (0,
|
|
3007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2651
3008
|
"button",
|
|
2652
3009
|
{
|
|
2653
3010
|
type: "button",
|
|
@@ -2659,17 +3016,17 @@ var QuestionArtifactView = ({
|
|
|
2659
3016
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
2660
3017
|
),
|
|
2661
3018
|
children: [
|
|
2662
|
-
/* @__PURE__ */ (0,
|
|
2663
|
-
/* @__PURE__ */ (0,
|
|
2664
|
-
/* @__PURE__ */ (0,
|
|
2665
|
-
option.description ? /* @__PURE__ */ (0,
|
|
3019
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionRadio, { selected: isSelected }),
|
|
3020
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
3021
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
3022
|
+
option.description ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
2666
3023
|
] })
|
|
2667
3024
|
]
|
|
2668
3025
|
},
|
|
2669
3026
|
key
|
|
2670
3027
|
);
|
|
2671
3028
|
}) }),
|
|
2672
|
-
isMulti && !submittedIds ? /* @__PURE__ */ (0,
|
|
3029
|
+
isMulti && !submittedIds ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2673
3030
|
TimbalV2Button,
|
|
2674
3031
|
{
|
|
2675
3032
|
type: "button",
|
|
@@ -2684,12 +3041,12 @@ var QuestionArtifactView = ({
|
|
|
2684
3041
|
};
|
|
2685
3042
|
|
|
2686
3043
|
// src/artifacts/html-artifact.tsx
|
|
2687
|
-
var
|
|
3044
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2688
3045
|
var HtmlArtifactView = ({ artifact }) => {
|
|
2689
3046
|
const sandboxed = artifact.sandboxed !== false;
|
|
2690
3047
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
2691
3048
|
const height = artifact.height ?? "320px";
|
|
2692
|
-
return /* @__PURE__ */ (0,
|
|
3049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2693
3050
|
"iframe",
|
|
2694
3051
|
{
|
|
2695
3052
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -2702,7 +3059,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
2702
3059
|
};
|
|
2703
3060
|
|
|
2704
3061
|
// src/artifacts/json-artifact.tsx
|
|
2705
|
-
var
|
|
3062
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2706
3063
|
var JsonArtifactView = ({
|
|
2707
3064
|
artifact
|
|
2708
3065
|
}) => {
|
|
@@ -2714,16 +3071,16 @@ var JsonArtifactView = ({
|
|
|
2714
3071
|
} catch {
|
|
2715
3072
|
body = String(data);
|
|
2716
3073
|
}
|
|
2717
|
-
return /* @__PURE__ */ (0,
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ (0, import_jsx_runtime21.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 }) });
|
|
2718
3075
|
};
|
|
2719
3076
|
|
|
2720
3077
|
// src/artifacts/table-artifact.tsx
|
|
2721
|
-
var
|
|
3078
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2722
3079
|
var TableArtifactView = ({ artifact }) => {
|
|
2723
3080
|
const rows = artifact.rows ?? [];
|
|
2724
3081
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
2725
|
-
return /* @__PURE__ */ (0,
|
|
2726
|
-
/* @__PURE__ */ (0,
|
|
3082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
3083
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2727
3084
|
"th",
|
|
2728
3085
|
{
|
|
2729
3086
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -2731,11 +3088,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
2731
3088
|
},
|
|
2732
3089
|
col.key
|
|
2733
3090
|
)) }) }),
|
|
2734
|
-
/* @__PURE__ */ (0,
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tbody", { children: rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2735
3092
|
"tr",
|
|
2736
3093
|
{
|
|
2737
3094
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
2738
|
-
children: columns.map((col) => /* @__PURE__ */ (0,
|
|
3095
|
+
children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2739
3096
|
"td",
|
|
2740
3097
|
{
|
|
2741
3098
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -2768,7 +3125,7 @@ function formatCell(value) {
|
|
|
2768
3125
|
}
|
|
2769
3126
|
|
|
2770
3127
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2771
|
-
var
|
|
3128
|
+
var import_react17 = require("react");
|
|
2772
3129
|
|
|
2773
3130
|
// src/artifacts/ui/types.ts
|
|
2774
3131
|
function isUiBinding(value) {
|
|
@@ -2821,38 +3178,38 @@ function resolveBindable(value, state) {
|
|
|
2821
3178
|
}
|
|
2822
3179
|
|
|
2823
3180
|
// src/artifacts/ui/registry.tsx
|
|
2824
|
-
var
|
|
2825
|
-
var
|
|
2826
|
-
var UiStateContext = (0,
|
|
2827
|
-
var UiDispatchContext = (0,
|
|
3181
|
+
var import_react13 = require("react");
|
|
3182
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3183
|
+
var UiStateContext = (0, import_react13.createContext)({});
|
|
3184
|
+
var UiDispatchContext = (0, import_react13.createContext)(() => {
|
|
2828
3185
|
});
|
|
2829
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0,
|
|
3186
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
2830
3187
|
function useUiState() {
|
|
2831
|
-
return (0,
|
|
3188
|
+
return (0, import_react13.useContext)(UiStateContext);
|
|
2832
3189
|
}
|
|
2833
3190
|
function useUiDispatch() {
|
|
2834
|
-
return (0,
|
|
3191
|
+
return (0, import_react13.useContext)(UiDispatchContext);
|
|
2835
3192
|
}
|
|
2836
|
-
var UiEventContext = (0,
|
|
3193
|
+
var UiEventContext = (0, import_react13.createContext)(
|
|
2837
3194
|
null
|
|
2838
3195
|
);
|
|
2839
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0,
|
|
3196
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiEventContext.Provider, { value: onEvent, children });
|
|
2840
3197
|
function useUiEventEmitter() {
|
|
2841
|
-
return (0,
|
|
3198
|
+
return (0, import_react13.useContext)(UiEventContext);
|
|
2842
3199
|
}
|
|
2843
|
-
var UiCustomNodeRegistryContext = (0,
|
|
3200
|
+
var UiCustomNodeRegistryContext = (0, import_react13.createContext)({});
|
|
2844
3201
|
function useUiCustomNodeRegistry() {
|
|
2845
|
-
return (0,
|
|
3202
|
+
return (0, import_react13.useContext)(UiCustomNodeRegistryContext);
|
|
2846
3203
|
}
|
|
2847
3204
|
|
|
2848
3205
|
// src/artifacts/ui/nodes.tsx
|
|
2849
|
-
var
|
|
2850
|
-
var
|
|
2851
|
-
var
|
|
3206
|
+
var import_react14 = require("react");
|
|
3207
|
+
var import_react15 = require("motion/react");
|
|
3208
|
+
var import_react16 = require("@assistant-ui/react");
|
|
2852
3209
|
|
|
2853
3210
|
// src/ui/button.tsx
|
|
2854
3211
|
var import_class_variance_authority = require("class-variance-authority");
|
|
2855
|
-
var
|
|
3212
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2856
3213
|
var LEGACY_SIZE_TO_V2 = {
|
|
2857
3214
|
default: "md",
|
|
2858
3215
|
xs: "xs",
|
|
@@ -2902,7 +3259,7 @@ function Button({
|
|
|
2902
3259
|
const v2Variant = TIMBAL_V2_FROM_LEGACY_BUTTON[variant ?? "default"];
|
|
2903
3260
|
const v2Size = LEGACY_SIZE_TO_V2[size ?? "default"];
|
|
2904
3261
|
const isIconOnly = typeof size === "string" && size.startsWith("icon");
|
|
2905
|
-
return /* @__PURE__ */ (0,
|
|
3262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2906
3263
|
TimbalV2Button,
|
|
2907
3264
|
{
|
|
2908
3265
|
"data-slot": "button",
|
|
@@ -2920,29 +3277,29 @@ function Button({
|
|
|
2920
3277
|
}
|
|
2921
3278
|
|
|
2922
3279
|
// src/artifacts/ui/nodes.tsx
|
|
2923
|
-
var
|
|
3280
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2924
3281
|
var UiNodeView = ({ node }) => {
|
|
2925
3282
|
switch (node.kind) {
|
|
2926
3283
|
case "box":
|
|
2927
|
-
return /* @__PURE__ */ (0,
|
|
3284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BoxNode, { node });
|
|
2928
3285
|
case "text":
|
|
2929
|
-
return /* @__PURE__ */ (0,
|
|
3286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TextNode, { node });
|
|
2930
3287
|
case "heading":
|
|
2931
|
-
return /* @__PURE__ */ (0,
|
|
3288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(HeadingNode, { node });
|
|
2932
3289
|
case "badge":
|
|
2933
|
-
return /* @__PURE__ */ (0,
|
|
3290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BadgeNode, { node });
|
|
2934
3291
|
case "button":
|
|
2935
|
-
return /* @__PURE__ */ (0,
|
|
3292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ButtonNode, { node });
|
|
2936
3293
|
case "toggle":
|
|
2937
|
-
return /* @__PURE__ */ (0,
|
|
3294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToggleNode, { node });
|
|
2938
3295
|
case "slider":
|
|
2939
|
-
return /* @__PURE__ */ (0,
|
|
3296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SliderNode, { node });
|
|
2940
3297
|
case "tooltip":
|
|
2941
|
-
return /* @__PURE__ */ (0,
|
|
3298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipNode, { node });
|
|
2942
3299
|
case "draggable":
|
|
2943
|
-
return /* @__PURE__ */ (0,
|
|
3300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DraggableNode, { node });
|
|
2944
3301
|
case "custom":
|
|
2945
|
-
return /* @__PURE__ */ (0,
|
|
3302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CustomNode, { node });
|
|
2946
3303
|
default:
|
|
2947
3304
|
return null;
|
|
2948
3305
|
}
|
|
@@ -2950,9 +3307,9 @@ var UiNodeView = ({ node }) => {
|
|
|
2950
3307
|
function useActionRunner() {
|
|
2951
3308
|
const state = useUiState();
|
|
2952
3309
|
const dispatch = useUiDispatch();
|
|
2953
|
-
const runtime = (0,
|
|
3310
|
+
const runtime = (0, import_react16.useThreadRuntime)();
|
|
2954
3311
|
const emit = useUiEventEmitter();
|
|
2955
|
-
return (0,
|
|
3312
|
+
return (0, import_react14.useCallback)(
|
|
2956
3313
|
(actions) => {
|
|
2957
3314
|
if (!actions) return;
|
|
2958
3315
|
const list = Array.isArray(actions) ? actions : [actions];
|
|
@@ -3002,7 +3359,7 @@ var JUSTIFY_CLS = {
|
|
|
3002
3359
|
};
|
|
3003
3360
|
var BoxNode = ({ node }) => {
|
|
3004
3361
|
const dir = node.direction ?? "col";
|
|
3005
|
-
return /* @__PURE__ */ (0,
|
|
3362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3006
3363
|
"div",
|
|
3007
3364
|
{
|
|
3008
3365
|
className: cn(
|
|
@@ -3017,7 +3374,7 @@ var BoxNode = ({ node }) => {
|
|
|
3017
3374
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
3018
3375
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
3019
3376
|
},
|
|
3020
|
-
children: node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
3377
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: child }, child.id ?? i))
|
|
3021
3378
|
}
|
|
3022
3379
|
);
|
|
3023
3380
|
};
|
|
@@ -3036,7 +3393,7 @@ var TEXT_WEIGHT = {
|
|
|
3036
3393
|
var TextNode = ({ node }) => {
|
|
3037
3394
|
const state = useUiState();
|
|
3038
3395
|
const value = resolveBindable(node.value, state);
|
|
3039
|
-
return /* @__PURE__ */ (0,
|
|
3396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3040
3397
|
"span",
|
|
3041
3398
|
{
|
|
3042
3399
|
className: cn(
|
|
@@ -3067,13 +3424,13 @@ var HeadingNode = ({ node }) => {
|
|
|
3067
3424
|
);
|
|
3068
3425
|
switch (level) {
|
|
3069
3426
|
case 1:
|
|
3070
|
-
return /* @__PURE__ */ (0,
|
|
3427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h1", { className: cls, children: value });
|
|
3071
3428
|
case 2:
|
|
3072
|
-
return /* @__PURE__ */ (0,
|
|
3429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { className: cls, children: value });
|
|
3073
3430
|
case 3:
|
|
3074
|
-
return /* @__PURE__ */ (0,
|
|
3431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { className: cls, children: value });
|
|
3075
3432
|
case 4:
|
|
3076
|
-
return /* @__PURE__ */ (0,
|
|
3433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: cls, children: value });
|
|
3077
3434
|
}
|
|
3078
3435
|
};
|
|
3079
3436
|
var BADGE_TONE = {
|
|
@@ -3086,7 +3443,7 @@ var BADGE_TONE = {
|
|
|
3086
3443
|
var BadgeNode = ({ node }) => {
|
|
3087
3444
|
const state = useUiState();
|
|
3088
3445
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
3089
|
-
return /* @__PURE__ */ (0,
|
|
3446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3090
3447
|
"span",
|
|
3091
3448
|
{
|
|
3092
3449
|
className: cn(
|
|
@@ -3103,7 +3460,7 @@ var ButtonNode = ({ node }) => {
|
|
|
3103
3460
|
const run = useActionRunner();
|
|
3104
3461
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
3105
3462
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
3106
|
-
return /* @__PURE__ */ (0,
|
|
3463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3107
3464
|
Button,
|
|
3108
3465
|
{
|
|
3109
3466
|
variant: node.variant ?? "default",
|
|
@@ -3125,7 +3482,7 @@ var ToggleNode = ({ node }) => {
|
|
|
3125
3482
|
dispatch({ type: "toggle", path: node.binding });
|
|
3126
3483
|
run(node.onChange);
|
|
3127
3484
|
};
|
|
3128
|
-
return /* @__PURE__ */ (0,
|
|
3485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3129
3486
|
"label",
|
|
3130
3487
|
{
|
|
3131
3488
|
className: cn(
|
|
@@ -3133,7 +3490,7 @@ var ToggleNode = ({ node }) => {
|
|
|
3133
3490
|
node.className
|
|
3134
3491
|
),
|
|
3135
3492
|
children: [
|
|
3136
|
-
/* @__PURE__ */ (0,
|
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3137
3494
|
"button",
|
|
3138
3495
|
{
|
|
3139
3496
|
type: "button",
|
|
@@ -3144,7 +3501,7 @@ var ToggleNode = ({ node }) => {
|
|
|
3144
3501
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
3145
3502
|
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")
|
|
3146
3503
|
),
|
|
3147
|
-
children: /* @__PURE__ */ (0,
|
|
3504
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3148
3505
|
"span",
|
|
3149
3506
|
{
|
|
3150
3507
|
className: cn(
|
|
@@ -3157,7 +3514,7 @@ var ToggleNode = ({ node }) => {
|
|
|
3157
3514
|
)
|
|
3158
3515
|
}
|
|
3159
3516
|
),
|
|
3160
|
-
label && /* @__PURE__ */ (0,
|
|
3517
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-foreground/85", children: label })
|
|
3161
3518
|
]
|
|
3162
3519
|
}
|
|
3163
3520
|
);
|
|
@@ -3177,12 +3534,12 @@ var SliderNode = ({ node }) => {
|
|
|
3177
3534
|
const next = Number(e.target.value);
|
|
3178
3535
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
3179
3536
|
};
|
|
3180
|
-
return /* @__PURE__ */ (0,
|
|
3181
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
3182
|
-
label && /* @__PURE__ */ (0,
|
|
3183
|
-
showValue && /* @__PURE__ */ (0,
|
|
3537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
3538
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
3539
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: label }),
|
|
3540
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: value })
|
|
3184
3541
|
] }),
|
|
3185
|
-
/* @__PURE__ */ (0,
|
|
3542
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3186
3543
|
"input",
|
|
3187
3544
|
{
|
|
3188
3545
|
type: "range",
|
|
@@ -3204,9 +3561,9 @@ var SliderNode = ({ node }) => {
|
|
|
3204
3561
|
var TooltipNode = ({ node }) => {
|
|
3205
3562
|
const state = useUiState();
|
|
3206
3563
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
3207
|
-
return /* @__PURE__ */ (0,
|
|
3208
|
-
/* @__PURE__ */ (0,
|
|
3209
|
-
/* @__PURE__ */ (0,
|
|
3564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Tooltip, { children: [
|
|
3565
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: node.child }) }) }),
|
|
3566
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { side: node.side ?? "top", children: content })
|
|
3210
3567
|
] }) });
|
|
3211
3568
|
};
|
|
3212
3569
|
var DraggableNode = ({ node }) => {
|
|
@@ -3214,8 +3571,8 @@ var DraggableNode = ({ node }) => {
|
|
|
3214
3571
|
const snapBack = node.snapBack ?? true;
|
|
3215
3572
|
const axis = node.axis ?? "both";
|
|
3216
3573
|
const dragProp = axis === "both" ? true : axis;
|
|
3217
|
-
return /* @__PURE__ */ (0,
|
|
3218
|
-
|
|
3574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3575
|
+
import_react15.motion.div,
|
|
3219
3576
|
{
|
|
3220
3577
|
drag: dragProp,
|
|
3221
3578
|
dragMomentum: false,
|
|
@@ -3226,7 +3583,7 @@ var DraggableNode = ({ node }) => {
|
|
|
3226
3583
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
3227
3584
|
node.className
|
|
3228
3585
|
),
|
|
3229
|
-
children: /* @__PURE__ */ (0,
|
|
3586
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: node.child })
|
|
3230
3587
|
}
|
|
3231
3588
|
);
|
|
3232
3589
|
};
|
|
@@ -3236,8 +3593,8 @@ var CustomNode = ({ node }) => {
|
|
|
3236
3593
|
const Renderer = registry[node.name];
|
|
3237
3594
|
if (!Renderer) return null;
|
|
3238
3595
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
3239
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
3240
|
-
return /* @__PURE__ */ (0,
|
|
3596
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: child }, child.id ?? i));
|
|
3597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Renderer, { props: resolvedProps, children });
|
|
3241
3598
|
};
|
|
3242
3599
|
function resolveProps(props, state) {
|
|
3243
3600
|
const out = {};
|
|
@@ -3248,17 +3605,17 @@ function resolveProps(props, state) {
|
|
|
3248
3605
|
}
|
|
3249
3606
|
|
|
3250
3607
|
// src/artifacts/ui/ui-artifact.tsx
|
|
3251
|
-
var
|
|
3608
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3252
3609
|
var UiArtifactView = ({ artifact }) => {
|
|
3253
|
-
const [state, dispatch] = (0,
|
|
3610
|
+
const [state, dispatch] = (0, import_react17.useReducer)(
|
|
3254
3611
|
uiStateReducer,
|
|
3255
3612
|
artifact.initialState ?? {}
|
|
3256
3613
|
);
|
|
3257
|
-
return /* @__PURE__ */ (0,
|
|
3614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UiNodeView, { node: artifact.root }) }) }) });
|
|
3258
3615
|
};
|
|
3259
3616
|
|
|
3260
3617
|
// src/artifacts/registry.tsx
|
|
3261
|
-
var
|
|
3618
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3262
3619
|
var defaultArtifactRenderers = {
|
|
3263
3620
|
chart: ChartArtifactView,
|
|
3264
3621
|
question: QuestionArtifactView,
|
|
@@ -3267,25 +3624,25 @@ var defaultArtifactRenderers = {
|
|
|
3267
3624
|
table: TableArtifactView,
|
|
3268
3625
|
ui: UiArtifactView
|
|
3269
3626
|
};
|
|
3270
|
-
var ArtifactRegistryContext = (0,
|
|
3627
|
+
var ArtifactRegistryContext = (0, import_react18.createContext)(
|
|
3271
3628
|
defaultArtifactRenderers
|
|
3272
3629
|
);
|
|
3273
3630
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
3274
|
-
const merged = (0,
|
|
3631
|
+
const merged = (0, import_react18.useMemo)(() => {
|
|
3275
3632
|
if (!renderers) return defaultArtifactRenderers;
|
|
3276
3633
|
if (override) return renderers;
|
|
3277
3634
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
3278
3635
|
}, [renderers, override]);
|
|
3279
|
-
return /* @__PURE__ */ (0,
|
|
3636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
3280
3637
|
};
|
|
3281
3638
|
function useArtifactRegistry() {
|
|
3282
|
-
return (0,
|
|
3639
|
+
return (0, import_react18.useContext)(ArtifactRegistryContext);
|
|
3283
3640
|
}
|
|
3284
3641
|
var ArtifactView = ({ artifact }) => {
|
|
3285
3642
|
const registry = useArtifactRegistry();
|
|
3286
3643
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
3287
3644
|
if (!Renderer) return null;
|
|
3288
|
-
return /* @__PURE__ */ (0,
|
|
3645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Renderer, { artifact });
|
|
3289
3646
|
};
|
|
3290
3647
|
|
|
3291
3648
|
// src/artifacts/parse.ts
|
|
@@ -3361,7 +3718,7 @@ var import_c = __toESM(require("shiki/langs/c.mjs"), 1);
|
|
|
3361
3718
|
var import_cpp = __toESM(require("shiki/langs/cpp.mjs"), 1);
|
|
3362
3719
|
var import_vitesse_dark = __toESM(require("shiki/themes/vitesse-dark.mjs"), 1);
|
|
3363
3720
|
var import_vitesse_light = __toESM(require("shiki/themes/vitesse-light.mjs"), 1);
|
|
3364
|
-
var
|
|
3721
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3365
3722
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
3366
3723
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
3367
3724
|
var highlighterPromise = null;
|
|
@@ -3399,8 +3756,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3399
3756
|
language,
|
|
3400
3757
|
code
|
|
3401
3758
|
}) => {
|
|
3402
|
-
const [html, setHtml] = (0,
|
|
3403
|
-
(0,
|
|
3759
|
+
const [html, setHtml] = (0, import_react19.useState)(null);
|
|
3760
|
+
(0, import_react19.useEffect)(() => {
|
|
3404
3761
|
let cancelled = false;
|
|
3405
3762
|
(async () => {
|
|
3406
3763
|
try {
|
|
@@ -3430,13 +3787,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3430
3787
|
try {
|
|
3431
3788
|
const parsed = JSON.parse(code);
|
|
3432
3789
|
if (isArtifact(parsed)) {
|
|
3433
|
-
return /* @__PURE__ */ (0,
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ArtifactView, { artifact: parsed });
|
|
3434
3791
|
}
|
|
3435
3792
|
} catch {
|
|
3436
3793
|
}
|
|
3437
3794
|
}
|
|
3438
3795
|
if (html) {
|
|
3439
|
-
return /* @__PURE__ */ (0,
|
|
3796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3440
3797
|
"div",
|
|
3441
3798
|
{
|
|
3442
3799
|
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",
|
|
@@ -3444,14 +3801,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3444
3801
|
}
|
|
3445
3802
|
);
|
|
3446
3803
|
}
|
|
3447
|
-
return /* @__PURE__ */ (0,
|
|
3804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Pre, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Code2, { children: code }) });
|
|
3448
3805
|
};
|
|
3449
3806
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
3450
3807
|
|
|
3451
3808
|
// src/chat/markdown-text.tsx
|
|
3452
|
-
var
|
|
3809
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3453
3810
|
var MarkdownTextImpl = () => {
|
|
3454
|
-
return /* @__PURE__ */ (0,
|
|
3811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3455
3812
|
import_react_markdown.MarkdownTextPrimitive,
|
|
3456
3813
|
{
|
|
3457
3814
|
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
@@ -3464,7 +3821,7 @@ var MarkdownTextImpl = () => {
|
|
|
3464
3821
|
}
|
|
3465
3822
|
);
|
|
3466
3823
|
};
|
|
3467
|
-
var MarkdownText = (0,
|
|
3824
|
+
var MarkdownText = (0, import_react20.memo)(MarkdownTextImpl);
|
|
3468
3825
|
var CodeHeader = ({ language, code }) => {
|
|
3469
3826
|
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
3470
3827
|
if (isArtifactFenceLanguage(language)) return null;
|
|
@@ -3472,20 +3829,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3472
3829
|
if (!code || isCopied) return;
|
|
3473
3830
|
copyToClipboard(code);
|
|
3474
3831
|
};
|
|
3475
|
-
return /* @__PURE__ */ (0,
|
|
3476
|
-
/* @__PURE__ */ (0,
|
|
3477
|
-
/* @__PURE__ */ (0,
|
|
3832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.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: [
|
|
3833
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
3834
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
3478
3835
|
language
|
|
3479
3836
|
] }),
|
|
3480
|
-
/* @__PURE__ */ (0,
|
|
3837
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3481
3838
|
TooltipIconButton,
|
|
3482
3839
|
{
|
|
3483
3840
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
3484
3841
|
onClick: onCopy,
|
|
3485
3842
|
className: "transition-colors hover:text-foreground",
|
|
3486
3843
|
children: [
|
|
3487
|
-
!isCopied && /* @__PURE__ */ (0,
|
|
3488
|
-
isCopied && /* @__PURE__ */ (0,
|
|
3844
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react4.CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
3845
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react4.CheckIcon, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
3489
3846
|
]
|
|
3490
3847
|
}
|
|
3491
3848
|
)
|
|
@@ -3494,7 +3851,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3494
3851
|
var useCopyToClipboard = ({
|
|
3495
3852
|
copiedDuration = 3e3
|
|
3496
3853
|
} = {}) => {
|
|
3497
|
-
const [isCopied, setIsCopied] = (0,
|
|
3854
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
3498
3855
|
const copyToClipboard = (value) => {
|
|
3499
3856
|
if (!value) return;
|
|
3500
3857
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -3505,7 +3862,7 @@ var useCopyToClipboard = ({
|
|
|
3505
3862
|
return { isCopied, copyToClipboard };
|
|
3506
3863
|
};
|
|
3507
3864
|
var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownComponents)({
|
|
3508
|
-
h1: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3865
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3509
3866
|
"h1",
|
|
3510
3867
|
{
|
|
3511
3868
|
className: cn(
|
|
@@ -3515,7 +3872,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3515
3872
|
...props
|
|
3516
3873
|
}
|
|
3517
3874
|
),
|
|
3518
|
-
h2: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3875
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3519
3876
|
"h2",
|
|
3520
3877
|
{
|
|
3521
3878
|
className: cn(
|
|
@@ -3525,7 +3882,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3525
3882
|
...props
|
|
3526
3883
|
}
|
|
3527
3884
|
),
|
|
3528
|
-
h3: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3885
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3529
3886
|
"h3",
|
|
3530
3887
|
{
|
|
3531
3888
|
className: cn(
|
|
@@ -3535,7 +3892,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3535
3892
|
...props
|
|
3536
3893
|
}
|
|
3537
3894
|
),
|
|
3538
|
-
h4: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3895
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3539
3896
|
"h4",
|
|
3540
3897
|
{
|
|
3541
3898
|
className: cn(
|
|
@@ -3545,7 +3902,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3545
3902
|
...props
|
|
3546
3903
|
}
|
|
3547
3904
|
),
|
|
3548
|
-
h5: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3905
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3549
3906
|
"h5",
|
|
3550
3907
|
{
|
|
3551
3908
|
className: cn(
|
|
@@ -3555,7 +3912,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3555
3912
|
...props
|
|
3556
3913
|
}
|
|
3557
3914
|
),
|
|
3558
|
-
h6: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3915
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3559
3916
|
"h6",
|
|
3560
3917
|
{
|
|
3561
3918
|
className: cn(
|
|
@@ -3565,7 +3922,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3565
3922
|
...props
|
|
3566
3923
|
}
|
|
3567
3924
|
),
|
|
3568
|
-
p: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3925
|
+
p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3569
3926
|
"p",
|
|
3570
3927
|
{
|
|
3571
3928
|
className: cn(
|
|
@@ -3575,7 +3932,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3575
3932
|
...props
|
|
3576
3933
|
}
|
|
3577
3934
|
),
|
|
3578
|
-
a: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3935
|
+
a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3579
3936
|
"a",
|
|
3580
3937
|
{
|
|
3581
3938
|
className: cn(
|
|
@@ -3587,7 +3944,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3587
3944
|
...props
|
|
3588
3945
|
}
|
|
3589
3946
|
),
|
|
3590
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3947
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3591
3948
|
"blockquote",
|
|
3592
3949
|
{
|
|
3593
3950
|
className: cn(
|
|
@@ -3597,7 +3954,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3597
3954
|
...props
|
|
3598
3955
|
}
|
|
3599
3956
|
),
|
|
3600
|
-
ul: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3957
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3601
3958
|
"ul",
|
|
3602
3959
|
{
|
|
3603
3960
|
className: cn(
|
|
@@ -3607,7 +3964,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3607
3964
|
...props
|
|
3608
3965
|
}
|
|
3609
3966
|
),
|
|
3610
|
-
ol: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3967
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3611
3968
|
"ol",
|
|
3612
3969
|
{
|
|
3613
3970
|
className: cn(
|
|
@@ -3617,7 +3974,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3617
3974
|
...props
|
|
3618
3975
|
}
|
|
3619
3976
|
),
|
|
3620
|
-
hr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3977
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3621
3978
|
"hr",
|
|
3622
3979
|
{
|
|
3623
3980
|
className: cn(
|
|
@@ -3627,14 +3984,14 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3627
3984
|
...props
|
|
3628
3985
|
}
|
|
3629
3986
|
),
|
|
3630
|
-
table: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3987
|
+
table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3631
3988
|
"table",
|
|
3632
3989
|
{
|
|
3633
3990
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
3634
3991
|
...props
|
|
3635
3992
|
}
|
|
3636
3993
|
) }),
|
|
3637
|
-
th: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3994
|
+
th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3638
3995
|
"th",
|
|
3639
3996
|
{
|
|
3640
3997
|
className: cn(
|
|
@@ -3644,7 +4001,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3644
4001
|
...props
|
|
3645
4002
|
}
|
|
3646
4003
|
),
|
|
3647
|
-
td: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4004
|
+
td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3648
4005
|
"td",
|
|
3649
4006
|
{
|
|
3650
4007
|
className: cn(
|
|
@@ -3654,7 +4011,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3654
4011
|
...props
|
|
3655
4012
|
}
|
|
3656
4013
|
),
|
|
3657
|
-
tr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4014
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3658
4015
|
"tr",
|
|
3659
4016
|
{
|
|
3660
4017
|
className: cn(
|
|
@@ -3664,8 +4021,8 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3664
4021
|
...props
|
|
3665
4022
|
}
|
|
3666
4023
|
),
|
|
3667
|
-
li: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3668
|
-
sup: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4024
|
+
li: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
4025
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3669
4026
|
"sup",
|
|
3670
4027
|
{
|
|
3671
4028
|
className: cn(
|
|
@@ -3675,7 +4032,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3675
4032
|
...props
|
|
3676
4033
|
}
|
|
3677
4034
|
),
|
|
3678
|
-
pre: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4035
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3679
4036
|
"pre",
|
|
3680
4037
|
{
|
|
3681
4038
|
className: cn(
|
|
@@ -3687,7 +4044,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3687
4044
|
),
|
|
3688
4045
|
code: function Code({ className, ...props }) {
|
|
3689
4046
|
const isCodeBlock = (0, import_react_markdown.useIsMarkdownCodeBlock)();
|
|
3690
|
-
return /* @__PURE__ */ (0,
|
|
4047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3691
4048
|
"code",
|
|
3692
4049
|
{
|
|
3693
4050
|
className: cn(
|
|
@@ -3698,20 +4055,20 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3698
4055
|
}
|
|
3699
4056
|
);
|
|
3700
4057
|
},
|
|
3701
|
-
strong: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3702
|
-
em: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4058
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
4059
|
+
em: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("em", { className: cn("italic", className), ...props }),
|
|
3703
4060
|
CodeHeader
|
|
3704
4061
|
});
|
|
3705
4062
|
|
|
3706
4063
|
// src/chat/tool-fallback.tsx
|
|
3707
|
-
var
|
|
4064
|
+
var import_react24 = require("react");
|
|
3708
4065
|
var import_lucide_react5 = require("lucide-react");
|
|
3709
|
-
var
|
|
4066
|
+
var import_react25 = require("@assistant-ui/react");
|
|
3710
4067
|
|
|
3711
4068
|
// src/ui/shimmer.tsx
|
|
3712
|
-
var
|
|
3713
|
-
var
|
|
3714
|
-
var
|
|
4069
|
+
var import_react21 = require("motion/react");
|
|
4070
|
+
var import_react22 = require("react");
|
|
4071
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3715
4072
|
var ShimmerComponent = ({
|
|
3716
4073
|
children,
|
|
3717
4074
|
as: Component = "p",
|
|
@@ -3719,14 +4076,14 @@ var ShimmerComponent = ({
|
|
|
3719
4076
|
duration = 2,
|
|
3720
4077
|
spread = 2
|
|
3721
4078
|
}) => {
|
|
3722
|
-
const MotionComponent =
|
|
4079
|
+
const MotionComponent = import_react21.motion.create(
|
|
3723
4080
|
Component
|
|
3724
4081
|
);
|
|
3725
|
-
const dynamicSpread = (0,
|
|
4082
|
+
const dynamicSpread = (0, import_react22.useMemo)(
|
|
3726
4083
|
() => (children?.length ?? 0) * spread,
|
|
3727
4084
|
[children, spread]
|
|
3728
4085
|
);
|
|
3729
|
-
return /* @__PURE__ */ (0,
|
|
4086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3730
4087
|
MotionComponent,
|
|
3731
4088
|
{
|
|
3732
4089
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -3749,11 +4106,11 @@ var ShimmerComponent = ({
|
|
|
3749
4106
|
}
|
|
3750
4107
|
);
|
|
3751
4108
|
};
|
|
3752
|
-
var Shimmer = (0,
|
|
4109
|
+
var Shimmer = (0, import_react22.memo)(ShimmerComponent);
|
|
3753
4110
|
|
|
3754
4111
|
// src/chat/motion.tsx
|
|
3755
|
-
var
|
|
3756
|
-
var
|
|
4112
|
+
var import_react23 = require("motion/react");
|
|
4113
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3757
4114
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
3758
4115
|
var TOOL_ENTER_MS = 0.78;
|
|
3759
4116
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -3779,10 +4136,10 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
3779
4136
|
return entering ? { opacity: 0, y: 14, filter: "blur(10px)" } : { opacity: 1, y: 0, filter: "blur(0px)" };
|
|
3780
4137
|
}
|
|
3781
4138
|
function ToolMotion({ children, className, motionKey }) {
|
|
3782
|
-
const reduced = (0,
|
|
4139
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
3783
4140
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3784
|
-
return /* @__PURE__ */ (0,
|
|
3785
|
-
|
|
4141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4142
|
+
import_react23.motion.div,
|
|
3786
4143
|
{
|
|
3787
4144
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
3788
4145
|
initial: toolMotionState(reduced, true, "settled"),
|
|
@@ -3801,11 +4158,11 @@ function ToolPresence({
|
|
|
3801
4158
|
className,
|
|
3802
4159
|
variant = "settled"
|
|
3803
4160
|
}) {
|
|
3804
|
-
const reduced = (0,
|
|
4161
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
3805
4162
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3806
4163
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
3807
|
-
return /* @__PURE__ */ (0,
|
|
3808
|
-
|
|
4164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4165
|
+
import_react23.motion.div,
|
|
3809
4166
|
{
|
|
3810
4167
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
3811
4168
|
initial: toolMotionState(reduced, true, variant),
|
|
@@ -3825,8 +4182,8 @@ function ToolBodyPresence({
|
|
|
3825
4182
|
children,
|
|
3826
4183
|
className
|
|
3827
4184
|
}) {
|
|
3828
|
-
const reduced = (0,
|
|
3829
|
-
return /* @__PURE__ */ (0,
|
|
4185
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
4186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3830
4187
|
"div",
|
|
3831
4188
|
{
|
|
3832
4189
|
className: cn(
|
|
@@ -3834,7 +4191,7 @@ function ToolBodyPresence({
|
|
|
3834
4191
|
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)]"
|
|
3835
4192
|
),
|
|
3836
4193
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3837
|
-
children: /* @__PURE__ */ (0,
|
|
4194
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3838
4195
|
"div",
|
|
3839
4196
|
{
|
|
3840
4197
|
className: cn(
|
|
@@ -3850,7 +4207,7 @@ function ToolBodyPresence({
|
|
|
3850
4207
|
}
|
|
3851
4208
|
|
|
3852
4209
|
// src/chat/tool-fallback.tsx
|
|
3853
|
-
var
|
|
4210
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3854
4211
|
function detectRunning({
|
|
3855
4212
|
status,
|
|
3856
4213
|
result,
|
|
@@ -3864,7 +4221,7 @@ function detectRunning({
|
|
|
3864
4221
|
}
|
|
3865
4222
|
function useToolRunning(props) {
|
|
3866
4223
|
const { isRunning: streamRunning } = useTimbalRuntime();
|
|
3867
|
-
const partStatus = (0,
|
|
4224
|
+
const partStatus = (0, import_react25.useAuiState)((s) => s.part.status);
|
|
3868
4225
|
return detectRunning({
|
|
3869
4226
|
status: partStatus ?? props.status,
|
|
3870
4227
|
result: props.result,
|
|
@@ -3882,8 +4239,8 @@ function formatToolResult(result) {
|
|
|
3882
4239
|
return String(result);
|
|
3883
4240
|
}
|
|
3884
4241
|
}
|
|
3885
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0,
|
|
3886
|
-
action ? shimmer ? /* @__PURE__ */ (0,
|
|
4242
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
4243
|
+
action ? shimmer ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3887
4244
|
Shimmer,
|
|
3888
4245
|
{
|
|
3889
4246
|
as: "span",
|
|
@@ -3892,10 +4249,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3892
4249
|
spread: 2.5,
|
|
3893
4250
|
children: action
|
|
3894
4251
|
}
|
|
3895
|
-
) : /* @__PURE__ */ (0,
|
|
3896
|
-
detail ? /* @__PURE__ */ (0,
|
|
4252
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
4253
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3897
4254
|
] });
|
|
3898
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0,
|
|
4255
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3899
4256
|
import_lucide_react5.ChevronRightIcon,
|
|
3900
4257
|
{
|
|
3901
4258
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3903,9 +4260,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runt
|
|
|
3903
4260
|
}
|
|
3904
4261
|
);
|
|
3905
4262
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3906
|
-
const [open, setOpen] = (0,
|
|
4263
|
+
const [open, setOpen] = (0, import_react24.useState)(false);
|
|
3907
4264
|
const detail = formatToolLabel(toolName);
|
|
3908
|
-
const formattedArgs = (0,
|
|
4265
|
+
const formattedArgs = (0, import_react24.useMemo)(() => {
|
|
3909
4266
|
if (!argsText || argsText === "{}") return null;
|
|
3910
4267
|
try {
|
|
3911
4268
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3913,17 +4270,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3913
4270
|
return argsText;
|
|
3914
4271
|
}
|
|
3915
4272
|
}, [argsText]);
|
|
3916
|
-
const formattedResult = (0,
|
|
4273
|
+
const formattedResult = (0, import_react24.useMemo)(() => {
|
|
3917
4274
|
if (result === void 0 || result === null) return null;
|
|
3918
4275
|
return formatToolResult(result);
|
|
3919
4276
|
}, [result]);
|
|
3920
4277
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3921
4278
|
const action = isError ? "Failed" : "Used";
|
|
3922
4279
|
if (!hasBody) {
|
|
3923
|
-
return /* @__PURE__ */ (0,
|
|
4280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineActionLabel, { action, detail }) });
|
|
3924
4281
|
}
|
|
3925
|
-
return /* @__PURE__ */ (0,
|
|
3926
|
-
/* @__PURE__ */ (0,
|
|
4282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
4283
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3927
4284
|
"button",
|
|
3928
4285
|
{
|
|
3929
4286
|
type: "button",
|
|
@@ -3931,7 +4288,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3931
4288
|
"aria-expanded": open,
|
|
3932
4289
|
"aria-label": `${action} ${detail}`,
|
|
3933
4290
|
className: studioTimelineRowButtonClass,
|
|
3934
|
-
children: /* @__PURE__ */ (0,
|
|
4291
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3935
4292
|
"span",
|
|
3936
4293
|
{
|
|
3937
4294
|
className: cn(
|
|
@@ -3940,37 +4297,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3940
4297
|
"text-foreground"
|
|
3941
4298
|
),
|
|
3942
4299
|
children: [
|
|
3943
|
-
/* @__PURE__ */ (0,
|
|
3944
|
-
/* @__PURE__ */ (0,
|
|
4300
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineActionLabel, { action, detail }),
|
|
4301
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineHoverChevron, { expanded: open })
|
|
3945
4302
|
]
|
|
3946
4303
|
}
|
|
3947
4304
|
)
|
|
3948
4305
|
}
|
|
3949
4306
|
),
|
|
3950
|
-
/* @__PURE__ */ (0,
|
|
4307
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3951
4308
|
ToolBodyPresence,
|
|
3952
4309
|
{
|
|
3953
4310
|
open,
|
|
3954
4311
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3955
4312
|
children: [
|
|
3956
|
-
formattedArgs ? /* @__PURE__ */ (0,
|
|
4313
|
+
formattedArgs ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3957
4314
|
"div",
|
|
3958
4315
|
{
|
|
3959
4316
|
className: cn(
|
|
3960
4317
|
studioComposerIoWellClass,
|
|
3961
4318
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3962
4319
|
),
|
|
3963
|
-
children: /* @__PURE__ */ (0,
|
|
4320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3964
4321
|
}
|
|
3965
4322
|
) : null,
|
|
3966
|
-
formattedResult ? /* @__PURE__ */ (0,
|
|
4323
|
+
formattedResult ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3967
4324
|
"div",
|
|
3968
4325
|
{
|
|
3969
4326
|
className: cn(
|
|
3970
4327
|
studioComposerIoWellClass,
|
|
3971
4328
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3972
4329
|
),
|
|
3973
|
-
children: /* @__PURE__ */ (0,
|
|
4330
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3974
4331
|
}
|
|
3975
4332
|
) : null
|
|
3976
4333
|
]
|
|
@@ -3987,20 +4344,20 @@ var ToolFallbackImpl = ({
|
|
|
3987
4344
|
const isRunning = useToolRunning({ status, result });
|
|
3988
4345
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3989
4346
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3990
|
-
return /* @__PURE__ */ (0,
|
|
4347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3991
4348
|
ToolPresence,
|
|
3992
4349
|
{
|
|
3993
4350
|
presenceKey,
|
|
3994
4351
|
variant: isRunning ? "executing" : "settled",
|
|
3995
4352
|
className: "py-0.5",
|
|
3996
|
-
children: isRunning ? /* @__PURE__ */ (0,
|
|
4353
|
+
children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "aui-tool-running", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3997
4354
|
TimelineActionLabel,
|
|
3998
4355
|
{
|
|
3999
4356
|
action: "Using",
|
|
4000
4357
|
detail: formatToolLabel(toolName),
|
|
4001
4358
|
shimmer: true
|
|
4002
4359
|
}
|
|
4003
|
-
) }) : /* @__PURE__ */ (0,
|
|
4360
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4004
4361
|
ToolPanel,
|
|
4005
4362
|
{
|
|
4006
4363
|
toolName,
|
|
@@ -4012,13 +4369,13 @@ var ToolFallbackImpl = ({
|
|
|
4012
4369
|
}
|
|
4013
4370
|
);
|
|
4014
4371
|
};
|
|
4015
|
-
var ToolFallback = (0,
|
|
4372
|
+
var ToolFallback = (0, import_react24.memo)(
|
|
4016
4373
|
ToolFallbackImpl
|
|
4017
4374
|
);
|
|
4018
4375
|
ToolFallback.displayName = "ToolFallback";
|
|
4019
4376
|
|
|
4020
4377
|
// src/artifacts/tool-artifact.tsx
|
|
4021
|
-
var
|
|
4378
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4022
4379
|
var ToolArtifactFallback = (props) => {
|
|
4023
4380
|
const registry = useArtifactRegistry();
|
|
4024
4381
|
const isRunning = useToolRunning({
|
|
@@ -4030,24 +4387,24 @@ var ToolArtifactFallback = (props) => {
|
|
|
4030
4387
|
if (artifact) {
|
|
4031
4388
|
const Renderer = registry[artifact.type];
|
|
4032
4389
|
if (Renderer) {
|
|
4033
|
-
return /* @__PURE__ */ (0,
|
|
4390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4034
4391
|
ToolMotion,
|
|
4035
4392
|
{
|
|
4036
4393
|
motionKey: `artifact-${artifact.type}`,
|
|
4037
4394
|
className: "aui-tool-artifact",
|
|
4038
|
-
children: /* @__PURE__ */ (0,
|
|
4395
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Renderer, { artifact })
|
|
4039
4396
|
}
|
|
4040
4397
|
);
|
|
4041
4398
|
}
|
|
4042
4399
|
}
|
|
4043
4400
|
}
|
|
4044
|
-
return /* @__PURE__ */ (0,
|
|
4401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ToolFallback, { ...props });
|
|
4045
4402
|
};
|
|
4046
4403
|
|
|
4047
4404
|
// src/chat/composer.tsx
|
|
4048
|
-
var
|
|
4405
|
+
var import_react26 = require("@assistant-ui/react");
|
|
4049
4406
|
var import_lucide_react6 = require("lucide-react");
|
|
4050
|
-
var
|
|
4407
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4051
4408
|
var Composer = ({
|
|
4052
4409
|
placeholder = "Send a message...",
|
|
4053
4410
|
showAttachments,
|
|
@@ -4058,10 +4415,10 @@ var Composer = ({
|
|
|
4058
4415
|
}) => {
|
|
4059
4416
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
4060
4417
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
4061
|
-
const shell = /* @__PURE__ */ (0,
|
|
4062
|
-
attachUi && /* @__PURE__ */ (0,
|
|
4063
|
-
/* @__PURE__ */ (0,
|
|
4064
|
-
/* @__PURE__ */ (0,
|
|
4418
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
4419
|
+
attachUi && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerAttachments, {}),
|
|
4420
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
4421
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4065
4422
|
ComposerToolbar,
|
|
4066
4423
|
{
|
|
4067
4424
|
showAttachments: attachUi,
|
|
@@ -4070,15 +4427,15 @@ var Composer = ({
|
|
|
4070
4427
|
}
|
|
4071
4428
|
)
|
|
4072
4429
|
] });
|
|
4073
|
-
return /* @__PURE__ */ (0,
|
|
4074
|
-
|
|
4430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4431
|
+
import_react26.ComposerPrimitive.Root,
|
|
4075
4432
|
{
|
|
4076
4433
|
className: cn(
|
|
4077
4434
|
"aui-composer-root relative flex w-full flex-col",
|
|
4078
4435
|
className
|
|
4079
4436
|
),
|
|
4080
|
-
children: attachUi ? /* @__PURE__ */ (0,
|
|
4081
|
-
|
|
4437
|
+
children: attachUi ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4438
|
+
import_react26.ComposerPrimitive.AttachmentDropzone,
|
|
4082
4439
|
{
|
|
4083
4440
|
className: cn(
|
|
4084
4441
|
studioComposeInputShellClass,
|
|
@@ -4086,7 +4443,7 @@ var Composer = ({
|
|
|
4086
4443
|
),
|
|
4087
4444
|
children: shell
|
|
4088
4445
|
}
|
|
4089
|
-
) : /* @__PURE__ */ (0,
|
|
4446
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: studioComposeInputShellClass, children: shell })
|
|
4090
4447
|
}
|
|
4091
4448
|
);
|
|
4092
4449
|
};
|
|
@@ -4094,7 +4451,7 @@ var ComposerInput = ({
|
|
|
4094
4451
|
placeholder,
|
|
4095
4452
|
autoFocus
|
|
4096
4453
|
}) => {
|
|
4097
|
-
const composer = (0,
|
|
4454
|
+
const composer = (0, import_react26.useComposerRuntime)();
|
|
4098
4455
|
const onKeyDown = (e) => {
|
|
4099
4456
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
4100
4457
|
e.preventDefault();
|
|
@@ -4106,8 +4463,8 @@ var ComposerInput = ({
|
|
|
4106
4463
|
el.style.height = "auto";
|
|
4107
4464
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
4108
4465
|
};
|
|
4109
|
-
return /* @__PURE__ */ (0,
|
|
4110
|
-
|
|
4466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4467
|
+
import_react26.ComposerPrimitive.Input,
|
|
4111
4468
|
{
|
|
4112
4469
|
placeholder,
|
|
4113
4470
|
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",
|
|
@@ -4120,17 +4477,17 @@ var ComposerInput = ({
|
|
|
4120
4477
|
);
|
|
4121
4478
|
};
|
|
4122
4479
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
4123
|
-
return /* @__PURE__ */ (0,
|
|
4124
|
-
/* @__PURE__ */ (0,
|
|
4125
|
-
showAttachments && /* @__PURE__ */ (0,
|
|
4480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.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: [
|
|
4481
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4482
|
+
showAttachments && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerAddAttachment, {}),
|
|
4126
4483
|
toolbar
|
|
4127
4484
|
] }),
|
|
4128
|
-
/* @__PURE__ */ (0,
|
|
4485
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerSendOrCancel, { sendTooltip })
|
|
4129
4486
|
] });
|
|
4130
4487
|
};
|
|
4131
4488
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
4132
|
-
return /* @__PURE__ */ (0,
|
|
4133
|
-
/* @__PURE__ */ (0,
|
|
4489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
4490
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4134
4491
|
TooltipIconButton,
|
|
4135
4492
|
{
|
|
4136
4493
|
tooltip: sendTooltip,
|
|
@@ -4138,34 +4495,34 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
4138
4495
|
type: "submit",
|
|
4139
4496
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
4140
4497
|
"aria-label": "Send message",
|
|
4141
|
-
children: /* @__PURE__ */ (0,
|
|
4498
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react6.ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
4142
4499
|
}
|
|
4143
4500
|
) }) }),
|
|
4144
|
-
/* @__PURE__ */ (0,
|
|
4501
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4145
4502
|
TooltipIconButton,
|
|
4146
4503
|
{
|
|
4147
4504
|
tooltip: "Stop generating",
|
|
4148
4505
|
variant: "primary",
|
|
4149
4506
|
className: "aui-composer-cancel shrink-0",
|
|
4150
4507
|
"aria-label": "Stop generating",
|
|
4151
|
-
children: /* @__PURE__ */ (0,
|
|
4508
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react6.SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
4152
4509
|
}
|
|
4153
4510
|
) }) })
|
|
4154
4511
|
] });
|
|
4155
4512
|
};
|
|
4156
4513
|
|
|
4157
4514
|
// src/chat/suggestions.tsx
|
|
4158
|
-
var
|
|
4159
|
-
var
|
|
4515
|
+
var import_react27 = require("react");
|
|
4516
|
+
var import_react28 = require("@assistant-ui/react");
|
|
4160
4517
|
var import_lucide_react7 = require("lucide-react");
|
|
4161
|
-
var
|
|
4518
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4162
4519
|
var Suggestions = ({
|
|
4163
4520
|
suggestions,
|
|
4164
4521
|
className
|
|
4165
4522
|
}) => {
|
|
4166
4523
|
const items = useResolvedSuggestions(suggestions);
|
|
4167
4524
|
if (!items || items.length === 0) return null;
|
|
4168
|
-
return /* @__PURE__ */ (0,
|
|
4525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4169
4526
|
"div",
|
|
4170
4527
|
{
|
|
4171
4528
|
className: cn(
|
|
@@ -4174,17 +4531,17 @@ var Suggestions = ({
|
|
|
4174
4531
|
),
|
|
4175
4532
|
role: "list",
|
|
4176
4533
|
"aria-label": "Suggested prompts",
|
|
4177
|
-
children: items.map((suggestion, i) => /* @__PURE__ */ (0,
|
|
4534
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
4178
4535
|
}
|
|
4179
4536
|
);
|
|
4180
4537
|
};
|
|
4181
4538
|
var SuggestionRow = ({ suggestion }) => {
|
|
4182
|
-
const runtime = (0,
|
|
4539
|
+
const runtime = (0, import_react28.useThreadRuntime)();
|
|
4183
4540
|
const onClick = () => {
|
|
4184
4541
|
const text = suggestion.prompt ?? suggestion.title;
|
|
4185
4542
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
4186
4543
|
};
|
|
4187
|
-
return /* @__PURE__ */ (0,
|
|
4544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
4188
4545
|
"button",
|
|
4189
4546
|
{
|
|
4190
4547
|
type: "button",
|
|
@@ -4192,20 +4549,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
4192
4549
|
onClick,
|
|
4193
4550
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
4194
4551
|
children: [
|
|
4195
|
-
/* @__PURE__ */ (0,
|
|
4196
|
-
/* @__PURE__ */ (0,
|
|
4197
|
-
/* @__PURE__ */ (0,
|
|
4198
|
-
suggestion.description && /* @__PURE__ */ (0,
|
|
4552
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
4553
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
4554
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
4555
|
+
suggestion.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
4199
4556
|
] })
|
|
4200
4557
|
]
|
|
4201
4558
|
}
|
|
4202
4559
|
);
|
|
4203
4560
|
};
|
|
4204
4561
|
function useResolvedSuggestions(source) {
|
|
4205
|
-
const [resolved, setResolved] = (0,
|
|
4562
|
+
const [resolved, setResolved] = (0, import_react27.useState)(
|
|
4206
4563
|
() => Array.isArray(source) ? source : void 0
|
|
4207
4564
|
);
|
|
4208
|
-
(0,
|
|
4565
|
+
(0, import_react27.useEffect)(() => {
|
|
4209
4566
|
if (!source) {
|
|
4210
4567
|
setResolved(void 0);
|
|
4211
4568
|
return;
|
|
@@ -4224,7 +4581,7 @@ function useResolvedSuggestions(source) {
|
|
|
4224
4581
|
cancelled = true;
|
|
4225
4582
|
};
|
|
4226
4583
|
}, [source]);
|
|
4227
|
-
return (0,
|
|
4584
|
+
return (0, import_react27.useMemo)(() => resolved, [resolved]);
|
|
4228
4585
|
}
|
|
4229
4586
|
|
|
4230
4587
|
// src/design/theme-sanity.ts
|
|
@@ -4297,15 +4654,15 @@ function scheduleThemeSanityCheck() {
|
|
|
4297
4654
|
}
|
|
4298
4655
|
|
|
4299
4656
|
// src/chat/thread-variant.tsx
|
|
4300
|
-
var
|
|
4301
|
-
var ThreadVariantContext = (0,
|
|
4657
|
+
var import_react29 = require("react");
|
|
4658
|
+
var ThreadVariantContext = (0, import_react29.createContext)("default");
|
|
4302
4659
|
var ThreadVariantProvider = ThreadVariantContext.Provider;
|
|
4303
4660
|
function useThreadVariant() {
|
|
4304
|
-
return (0,
|
|
4661
|
+
return (0, import_react29.useContext)(ThreadVariantContext);
|
|
4305
4662
|
}
|
|
4306
4663
|
|
|
4307
4664
|
// src/chat/thread.tsx
|
|
4308
|
-
var
|
|
4665
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4309
4666
|
var Thread = ({
|
|
4310
4667
|
className,
|
|
4311
4668
|
variant = "default",
|
|
@@ -4328,17 +4685,17 @@ var Thread = ({
|
|
|
4328
4685
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
4329
4686
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
4330
4687
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
4331
|
-
(0,
|
|
4688
|
+
(0, import_react30.useEffect)(() => {
|
|
4332
4689
|
scheduleThemeSanityCheck();
|
|
4333
4690
|
}, []);
|
|
4334
|
-
return /* @__PURE__ */ (0,
|
|
4691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4335
4692
|
ArtifactRegistryProvider,
|
|
4336
4693
|
{
|
|
4337
4694
|
renderers: artifacts?.renderers,
|
|
4338
4695
|
override: artifacts?.override,
|
|
4339
|
-
children: /* @__PURE__ */ (0,
|
|
4340
|
-
}), children: /* @__PURE__ */ (0,
|
|
4341
|
-
|
|
4696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
4697
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4698
|
+
import_react31.ThreadPrimitive.Root,
|
|
4342
4699
|
{
|
|
4343
4700
|
className: cn(
|
|
4344
4701
|
"aui-root aui-thread-root @container flex h-full flex-col bg-transparent",
|
|
@@ -4347,8 +4704,8 @@ var Thread = ({
|
|
|
4347
4704
|
),
|
|
4348
4705
|
style: { ["--thread-max-width"]: maxWidth },
|
|
4349
4706
|
"data-thread-variant": variant,
|
|
4350
|
-
children: /* @__PURE__ */ (0,
|
|
4351
|
-
|
|
4707
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4708
|
+
import_react31.ThreadPrimitive.Viewport,
|
|
4352
4709
|
{
|
|
4353
4710
|
turnAnchor: "bottom",
|
|
4354
4711
|
className: cn(
|
|
@@ -4356,7 +4713,7 @@ var Thread = ({
|
|
|
4356
4713
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
4357
4714
|
),
|
|
4358
4715
|
children: [
|
|
4359
|
-
/* @__PURE__ */ (0,
|
|
4716
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4360
4717
|
WelcomeSlot,
|
|
4361
4718
|
{
|
|
4362
4719
|
config: welcome,
|
|
@@ -4365,8 +4722,8 @@ var Thread = ({
|
|
|
4365
4722
|
Suggestions: SuggestionsSlot
|
|
4366
4723
|
}
|
|
4367
4724
|
),
|
|
4368
|
-
/* @__PURE__ */ (0,
|
|
4369
|
-
|
|
4725
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4726
|
+
import_react31.ThreadPrimitive.Messages,
|
|
4370
4727
|
{
|
|
4371
4728
|
components: {
|
|
4372
4729
|
UserMessage: UserMessageSlot,
|
|
@@ -4375,14 +4732,14 @@ var Thread = ({
|
|
|
4375
4732
|
}
|
|
4376
4733
|
}
|
|
4377
4734
|
),
|
|
4378
|
-
/* @__PURE__ */ (0,
|
|
4379
|
-
|
|
4735
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4736
|
+
import_react31.ThreadPrimitive.ViewportFooter,
|
|
4380
4737
|
{
|
|
4381
4738
|
className: cn(
|
|
4382
4739
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
4383
4740
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
4384
4741
|
),
|
|
4385
|
-
children: /* @__PURE__ */ (0,
|
|
4742
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4386
4743
|
"div",
|
|
4387
4744
|
{
|
|
4388
4745
|
className: cn(
|
|
@@ -4390,8 +4747,8 @@ var Thread = ({
|
|
|
4390
4747
|
isPanel ? "gap-2" : "gap-4"
|
|
4391
4748
|
),
|
|
4392
4749
|
children: [
|
|
4393
|
-
/* @__PURE__ */ (0,
|
|
4394
|
-
/* @__PURE__ */ (0,
|
|
4750
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ScrollToBottomSlot, {}),
|
|
4751
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ComposerSlot, { placeholder })
|
|
4395
4752
|
]
|
|
4396
4753
|
}
|
|
4397
4754
|
)
|
|
@@ -4406,13 +4763,13 @@ var Thread = ({
|
|
|
4406
4763
|
) });
|
|
4407
4764
|
};
|
|
4408
4765
|
var ThreadScrollToBottom = () => {
|
|
4409
|
-
return /* @__PURE__ */ (0,
|
|
4766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4410
4767
|
TooltipIconButton,
|
|
4411
4768
|
{
|
|
4412
4769
|
tooltip: "Scroll to bottom",
|
|
4413
4770
|
variant: "secondary",
|
|
4414
4771
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
4415
|
-
children: /* @__PURE__ */ (0,
|
|
4772
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.ArrowDownIcon, { className: "size-4" })
|
|
4416
4773
|
}
|
|
4417
4774
|
) });
|
|
4418
4775
|
};
|
|
@@ -4445,15 +4802,15 @@ var ThreadWelcome = ({
|
|
|
4445
4802
|
showWelcomeSuggestions: showWelcomeSuggestionsProp,
|
|
4446
4803
|
Suggestions: SuggestionsSlot = Suggestions
|
|
4447
4804
|
}) => {
|
|
4448
|
-
const isEmpty = (0,
|
|
4805
|
+
const isEmpty = (0, import_react31.useThread)((s) => s.messages.length === 0);
|
|
4449
4806
|
const isPanel = useThreadVariant() === "panel";
|
|
4450
4807
|
const showWelcomeSuggestions = showWelcomeSuggestionsProp ?? !isPanel;
|
|
4451
4808
|
if (!isEmpty) return null;
|
|
4452
4809
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
4453
4810
|
const defaultSubheading = isPanel ? "The assistant can use dashboard context from your app." : "Send a message to start a conversation.";
|
|
4454
|
-
return /* @__PURE__ */ (0,
|
|
4455
|
-
/* @__PURE__ */ (0,
|
|
4456
|
-
|
|
4811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
4812
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4813
|
+
import_react32.motion.div,
|
|
4457
4814
|
{
|
|
4458
4815
|
className: cn(
|
|
4459
4816
|
"aui-thread-welcome-message flex flex-col items-center justify-center text-center",
|
|
@@ -4463,9 +4820,9 @@ var ThreadWelcome = ({
|
|
|
4463
4820
|
initial: "initial",
|
|
4464
4821
|
animate: "animate",
|
|
4465
4822
|
children: [
|
|
4466
|
-
config?.icon && /* @__PURE__ */ (0,
|
|
4467
|
-
/* @__PURE__ */ (0,
|
|
4468
|
-
|
|
4823
|
+
config?.icon && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react32.motion.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
4824
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4825
|
+
import_react32.motion.h1,
|
|
4469
4826
|
{
|
|
4470
4827
|
variants: welcomeItem,
|
|
4471
4828
|
className: cn(
|
|
@@ -4475,8 +4832,8 @@ var ThreadWelcome = ({
|
|
|
4475
4832
|
children: config?.heading ?? defaultHeading
|
|
4476
4833
|
}
|
|
4477
4834
|
),
|
|
4478
|
-
/* @__PURE__ */ (0,
|
|
4479
|
-
|
|
4835
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4836
|
+
import_react32.motion.p,
|
|
4480
4837
|
{
|
|
4481
4838
|
variants: welcomeItem,
|
|
4482
4839
|
className: "aui-thread-welcome-message-inner mt-1.5 text-muted-foreground text-sm",
|
|
@@ -4486,16 +4843,16 @@ var ThreadWelcome = ({
|
|
|
4486
4843
|
]
|
|
4487
4844
|
}
|
|
4488
4845
|
) }),
|
|
4489
|
-
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0,
|
|
4846
|
+
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SuggestionsSlot, { suggestions }) }) : null
|
|
4490
4847
|
] });
|
|
4491
4848
|
};
|
|
4492
4849
|
var MessageError = () => {
|
|
4493
|
-
return /* @__PURE__ */ (0,
|
|
4850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Error, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.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_runtime36.jsx)(import_react31.ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
4494
4851
|
};
|
|
4495
4852
|
var AssistantMessage = () => {
|
|
4496
4853
|
const isPanel = useThreadVariant() === "panel";
|
|
4497
|
-
return /* @__PURE__ */ (0,
|
|
4498
|
-
|
|
4854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4855
|
+
import_react31.MessagePrimitive.Root,
|
|
4499
4856
|
{
|
|
4500
4857
|
className: cn(
|
|
4501
4858
|
"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",
|
|
@@ -4503,7 +4860,7 @@ var AssistantMessage = () => {
|
|
|
4503
4860
|
),
|
|
4504
4861
|
"data-role": "assistant",
|
|
4505
4862
|
children: [
|
|
4506
|
-
/* @__PURE__ */ (0,
|
|
4863
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4507
4864
|
"div",
|
|
4508
4865
|
{
|
|
4509
4866
|
className: cn(
|
|
@@ -4511,8 +4868,8 @@ var AssistantMessage = () => {
|
|
|
4511
4868
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
4512
4869
|
),
|
|
4513
4870
|
children: [
|
|
4514
|
-
/* @__PURE__ */ (0,
|
|
4515
|
-
|
|
4871
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4872
|
+
import_react31.MessagePrimitive.Parts,
|
|
4516
4873
|
{
|
|
4517
4874
|
components: {
|
|
4518
4875
|
Text: MarkdownText,
|
|
@@ -4522,11 +4879,11 @@ var AssistantMessage = () => {
|
|
|
4522
4879
|
}
|
|
4523
4880
|
}
|
|
4524
4881
|
),
|
|
4525
|
-
/* @__PURE__ */ (0,
|
|
4882
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(MessageError, {})
|
|
4526
4883
|
]
|
|
4527
4884
|
}
|
|
4528
4885
|
),
|
|
4529
|
-
/* @__PURE__ */ (0,
|
|
4886
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(AssistantActionBar, {}) })
|
|
4530
4887
|
]
|
|
4531
4888
|
}
|
|
4532
4889
|
);
|
|
@@ -4539,36 +4896,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
4539
4896
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
4540
4897
|
);
|
|
4541
4898
|
var AssistantActionBar = () => {
|
|
4542
|
-
return /* @__PURE__ */ (0,
|
|
4543
|
-
|
|
4899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4900
|
+
import_react31.ActionBarPrimitive.Root,
|
|
4544
4901
|
{
|
|
4545
4902
|
hideWhenRunning: true,
|
|
4546
4903
|
autohide: "never",
|
|
4547
4904
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
4548
4905
|
children: [
|
|
4549
|
-
/* @__PURE__ */ (0,
|
|
4906
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4550
4907
|
TooltipIconButton,
|
|
4551
4908
|
{
|
|
4552
4909
|
tooltip: "Copy",
|
|
4553
4910
|
variant: "ghost",
|
|
4554
4911
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4555
4912
|
children: [
|
|
4556
|
-
/* @__PURE__ */ (0,
|
|
4557
|
-
/* @__PURE__ */ (0,
|
|
4913
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.CheckIcon, { className: "size-3" }) }),
|
|
4914
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.CopyIcon, { className: "size-3" }) })
|
|
4558
4915
|
]
|
|
4559
4916
|
}
|
|
4560
4917
|
) }),
|
|
4561
|
-
/* @__PURE__ */ (0,
|
|
4918
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4562
4919
|
TooltipIconButton,
|
|
4563
4920
|
{
|
|
4564
4921
|
tooltip: "Regenerate",
|
|
4565
4922
|
variant: "ghost",
|
|
4566
4923
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4567
|
-
children: /* @__PURE__ */ (0,
|
|
4924
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.RefreshCwIcon, { className: "size-3" })
|
|
4568
4925
|
}
|
|
4569
4926
|
) }),
|
|
4570
|
-
/* @__PURE__ */ (0,
|
|
4571
|
-
/* @__PURE__ */ (0,
|
|
4927
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ActionBarMorePrimitive.Root, { children: [
|
|
4928
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4572
4929
|
TooltipIconButton,
|
|
4573
4930
|
{
|
|
4574
4931
|
tooltip: "More",
|
|
@@ -4577,17 +4934,17 @@ var AssistantActionBar = () => {
|
|
|
4577
4934
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
4578
4935
|
"data-[state=open]:text-muted-foreground/80"
|
|
4579
4936
|
),
|
|
4580
|
-
children: /* @__PURE__ */ (0,
|
|
4937
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.MoreHorizontalIcon, { className: "size-3" })
|
|
4581
4938
|
}
|
|
4582
4939
|
) }),
|
|
4583
|
-
/* @__PURE__ */ (0,
|
|
4584
|
-
|
|
4940
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4941
|
+
import_react31.ActionBarMorePrimitive.Content,
|
|
4585
4942
|
{
|
|
4586
4943
|
side: "bottom",
|
|
4587
4944
|
align: "start",
|
|
4588
4945
|
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",
|
|
4589
|
-
children: /* @__PURE__ */ (0,
|
|
4590
|
-
/* @__PURE__ */ (0,
|
|
4946
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.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: [
|
|
4947
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.DownloadIcon, { className: "size-4 shrink-0" }),
|
|
4591
4948
|
"Export as Markdown"
|
|
4592
4949
|
] }) })
|
|
4593
4950
|
}
|
|
@@ -4598,12 +4955,12 @@ var AssistantActionBar = () => {
|
|
|
4598
4955
|
);
|
|
4599
4956
|
};
|
|
4600
4957
|
var UserMessageText = () => {
|
|
4601
|
-
return /* @__PURE__ */ (0,
|
|
4958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePartPrimitive.Text, { smooth: false }) });
|
|
4602
4959
|
};
|
|
4603
4960
|
var UserMessage = () => {
|
|
4604
4961
|
const isPanel = useThreadVariant() === "panel";
|
|
4605
|
-
return /* @__PURE__ */ (0,
|
|
4606
|
-
|
|
4962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4963
|
+
import_react31.MessagePrimitive.Root,
|
|
4607
4964
|
{
|
|
4608
4965
|
className: cn(
|
|
4609
4966
|
"aui-user-message-root mx-auto flex w-full max-w-(--thread-max-width) flex-col items-end gap-2",
|
|
@@ -4611,9 +4968,9 @@ var UserMessage = () => {
|
|
|
4611
4968
|
),
|
|
4612
4969
|
"data-role": "user",
|
|
4613
4970
|
children: [
|
|
4614
|
-
/* @__PURE__ */ (0,
|
|
4615
|
-
/* @__PURE__ */ (0,
|
|
4616
|
-
|
|
4971
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UserMessageAttachments, {}),
|
|
4972
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4973
|
+
import_react32.motion.div,
|
|
4617
4974
|
{
|
|
4618
4975
|
className: cn(
|
|
4619
4976
|
"aui-user-message-content relative inline-block max-w-[85%] rounded-2xl bg-bubble-user text-bubble-user-foreground",
|
|
@@ -4623,8 +4980,8 @@ var UserMessage = () => {
|
|
|
4623
4980
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
4624
4981
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
4625
4982
|
children: [
|
|
4626
|
-
/* @__PURE__ */ (0,
|
|
4627
|
-
/* @__PURE__ */ (0,
|
|
4983
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Parts, { components: { Text: UserMessageText } }),
|
|
4984
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.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_runtime36.jsx)(UserActionBar, {}) })
|
|
4628
4985
|
]
|
|
4629
4986
|
}
|
|
4630
4987
|
)
|
|
@@ -4633,42 +4990,42 @@ var UserMessage = () => {
|
|
|
4633
4990
|
);
|
|
4634
4991
|
};
|
|
4635
4992
|
var UserActionBar = () => {
|
|
4636
|
-
return /* @__PURE__ */ (0,
|
|
4637
|
-
|
|
4993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4994
|
+
import_react31.ActionBarPrimitive.Root,
|
|
4638
4995
|
{
|
|
4639
4996
|
hideWhenRunning: true,
|
|
4640
4997
|
autohide: "always",
|
|
4641
4998
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
4642
|
-
children: /* @__PURE__ */ (0,
|
|
4999
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4643
5000
|
TooltipIconButton,
|
|
4644
5001
|
{
|
|
4645
5002
|
tooltip: "Edit",
|
|
4646
5003
|
variant: "ghost",
|
|
4647
5004
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4648
|
-
children: /* @__PURE__ */ (0,
|
|
5005
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.PencilIcon, { className: "size-3" })
|
|
4649
5006
|
}
|
|
4650
5007
|
) })
|
|
4651
5008
|
}
|
|
4652
5009
|
);
|
|
4653
5010
|
};
|
|
4654
5011
|
var EditComposer = () => {
|
|
4655
|
-
return /* @__PURE__ */ (0,
|
|
4656
|
-
/* @__PURE__ */ (0,
|
|
4657
|
-
|
|
5012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.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_runtime36.jsxs)(import_react31.ComposerPrimitive.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
5013
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5014
|
+
import_react31.ComposerPrimitive.Input,
|
|
4658
5015
|
{
|
|
4659
5016
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
4660
5017
|
autoFocus: true
|
|
4661
5018
|
}
|
|
4662
5019
|
),
|
|
4663
|
-
/* @__PURE__ */ (0,
|
|
4664
|
-
/* @__PURE__ */ (0,
|
|
4665
|
-
/* @__PURE__ */ (0,
|
|
5020
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
5021
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
5022
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
4666
5023
|
] })
|
|
4667
5024
|
] }) });
|
|
4668
5025
|
};
|
|
4669
5026
|
|
|
4670
5027
|
// src/chat/chat.tsx
|
|
4671
|
-
var
|
|
5028
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4672
5029
|
function TimbalChat({
|
|
4673
5030
|
workforceId,
|
|
4674
5031
|
baseUrl,
|
|
@@ -4679,7 +5036,7 @@ function TimbalChat({
|
|
|
4679
5036
|
debug,
|
|
4680
5037
|
...threadProps
|
|
4681
5038
|
}) {
|
|
4682
|
-
return /* @__PURE__ */ (0,
|
|
5039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
4683
5040
|
TimbalRuntimeProvider,
|
|
4684
5041
|
{
|
|
4685
5042
|
workforceId,
|
|
@@ -4689,7 +5046,7 @@ function TimbalChat({
|
|
|
4689
5046
|
attachmentsUploadUrl,
|
|
4690
5047
|
attachmentsAccept,
|
|
4691
5048
|
debug,
|
|
4692
|
-
children: /* @__PURE__ */ (0,
|
|
5049
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Thread, { ...threadProps })
|
|
4693
5050
|
}
|
|
4694
5051
|
);
|
|
4695
5052
|
}
|
|
@@ -4718,7 +5075,7 @@ var overlayListPanelClass = cn(
|
|
|
4718
5075
|
);
|
|
4719
5076
|
|
|
4720
5077
|
// src/chat/workforce-selector.tsx
|
|
4721
|
-
var
|
|
5078
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4722
5079
|
var WorkforceSelector = ({
|
|
4723
5080
|
workforces,
|
|
4724
5081
|
value,
|
|
@@ -4729,7 +5086,7 @@ var WorkforceSelector = ({
|
|
|
4729
5086
|
}) => {
|
|
4730
5087
|
if (workforces.length === 0) return null;
|
|
4731
5088
|
if (hideWhenSingle && workforces.length === 1) return null;
|
|
4732
|
-
return /* @__PURE__ */ (0,
|
|
5089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4733
5090
|
"div",
|
|
4734
5091
|
{
|
|
4735
5092
|
className: cn(
|
|
@@ -4740,7 +5097,7 @@ var WorkforceSelector = ({
|
|
|
4740
5097
|
className
|
|
4741
5098
|
),
|
|
4742
5099
|
children: [
|
|
4743
|
-
/* @__PURE__ */ (0,
|
|
5100
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4744
5101
|
"select",
|
|
4745
5102
|
{
|
|
4746
5103
|
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",
|
|
@@ -4748,15 +5105,15 @@ var WorkforceSelector = ({
|
|
|
4748
5105
|
onChange: (e) => onChange(e.target.value),
|
|
4749
5106
|
"aria-label": placeholder,
|
|
4750
5107
|
children: [
|
|
4751
|
-
!value && /* @__PURE__ */ (0,
|
|
5108
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("option", { value: "", children: placeholder }),
|
|
4752
5109
|
workforces.map((w) => {
|
|
4753
5110
|
const id = idOf(w);
|
|
4754
|
-
return /* @__PURE__ */ (0,
|
|
5111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("option", { value: id, children: w.name ?? id }, id);
|
|
4755
5112
|
})
|
|
4756
5113
|
]
|
|
4757
5114
|
}
|
|
4758
5115
|
),
|
|
4759
|
-
/* @__PURE__ */ (0,
|
|
5116
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4760
5117
|
import_lucide_react9.ChevronDownIcon,
|
|
4761
5118
|
{
|
|
4762
5119
|
className: "aui-workforce-selector-icon pointer-events-none absolute right-3 size-3.5 text-muted-foreground/70",
|