@shapesos/clay 0.10.0 → 0.11.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.
Files changed (72) hide show
  1. package/dist/artifacts.cjs +741 -0
  2. package/dist/artifacts.cjs.map +1 -0
  3. package/dist/artifacts.d.cts +56 -0
  4. package/dist/artifacts.d.ts +56 -0
  5. package/dist/artifacts.js +23 -0
  6. package/dist/blocks.cjs +685 -53
  7. package/dist/blocks.cjs.map +1 -1
  8. package/dist/blocks.css +2 -0
  9. package/dist/blocks.d.cts +22 -10
  10. package/dist/blocks.d.ts +22 -10
  11. package/dist/blocks.js +15 -5
  12. package/dist/button.d.cts +2 -2
  13. package/dist/button.d.ts +2 -2
  14. package/dist/chat.cjs +728 -296
  15. package/dist/chat.cjs.map +1 -1
  16. package/dist/chat.d.cts +27 -10
  17. package/dist/chat.d.ts +27 -10
  18. package/dist/chat.js +7 -3
  19. package/dist/chunk-BX5TCEPR.js +436 -0
  20. package/dist/chunk-BX5TCEPR.js.map +1 -0
  21. package/dist/chunk-JGMN6W72.js +12 -0
  22. package/dist/chunk-JGMN6W72.js.map +1 -0
  23. package/dist/{chunk-27GJUWVN.js → chunk-JJUIBBBU.js} +14 -8
  24. package/dist/chunk-JJUIBBBU.js.map +1 -0
  25. package/dist/chunk-L35M3OD5.js +99 -0
  26. package/dist/chunk-L35M3OD5.js.map +1 -0
  27. package/dist/chunk-MEJESPTZ.js +1 -0
  28. package/dist/chunk-MEJESPTZ.js.map +1 -0
  29. package/dist/{chunk-R3BGPOAM.js → chunk-MXOPG747.js} +53 -45
  30. package/dist/chunk-MXOPG747.js.map +1 -0
  31. package/dist/{chunk-MLCRDVQ2.js → chunk-OBOXCBDL.js} +13 -5
  32. package/dist/chunk-OBOXCBDL.js.map +1 -0
  33. package/dist/{chunk-WS4IPADR.js → chunk-OUW6PUEB.js} +42 -110
  34. package/dist/chunk-OUW6PUEB.js.map +1 -0
  35. package/dist/icon.cjs +12 -4
  36. package/dist/icon.cjs.map +1 -1
  37. package/dist/icon.d.cts +19 -6
  38. package/dist/icon.d.ts +19 -6
  39. package/dist/icon.js +1 -1
  40. package/dist/index.cjs +794 -332
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +6 -4
  43. package/dist/index.d.ts +6 -4
  44. package/dist/index.js +50 -25
  45. package/dist/lottie.d.cts +2 -2
  46. package/dist/lottie.d.ts +2 -2
  47. package/dist/table.cjs +142 -0
  48. package/dist/table.cjs.map +1 -0
  49. package/dist/table.d.cts +44 -0
  50. package/dist/table.d.ts +44 -0
  51. package/dist/table.js +24 -0
  52. package/dist/table.js.map +1 -0
  53. package/dist/text-area.d.cts +2 -2
  54. package/dist/text-area.d.ts +2 -2
  55. package/dist/types-3Gzk7cRt.d.cts +121 -0
  56. package/dist/types-3Gzk7cRt.d.ts +121 -0
  57. package/dist/types-C9XX-Uhk.d.ts +68 -0
  58. package/dist/types-DuuRI4ll.d.cts +68 -0
  59. package/dist/utils.cjs +14 -7
  60. package/dist/utils.cjs.map +1 -1
  61. package/dist/utils.d.cts +18 -1
  62. package/dist/utils.d.ts +18 -1
  63. package/dist/utils.js +6 -4
  64. package/package.json +29 -4
  65. package/dist/chunk-27GJUWVN.js.map +0 -1
  66. package/dist/chunk-MLCRDVQ2.js.map +0 -1
  67. package/dist/chunk-OKPNST44.js +0 -1
  68. package/dist/chunk-R3BGPOAM.js.map +0 -1
  69. package/dist/chunk-WS4IPADR.js.map +0 -1
  70. package/dist/types-Q9aqd9nq.d.cts +0 -34
  71. package/dist/types-Q9aqd9nq.d.ts +0 -34
  72. /package/dist/{chunk-OKPNST44.js.map → artifacts.js.map} +0 -0
package/dist/chat.js CHANGED
@@ -2,13 +2,16 @@ import {
2
2
  ChatContext,
3
3
  ChatMessage,
4
4
  MESSAGE_ROLE,
5
+ copyMessageText,
5
6
  useChatContext,
6
7
  useCopyToClipboard
7
- } from "./chunk-WS4IPADR.js";
8
+ } from "./chunk-OUW6PUEB.js";
9
+ import "./chunk-MXOPG747.js";
8
10
  import "./chunk-NMKKU2UG.js";
9
- import "./chunk-R3BGPOAM.js";
10
- import "./chunk-MLCRDVQ2.js";
11
11
  import "./chunk-SV24ONND.js";
12
+ import "./chunk-BX5TCEPR.js";
13
+ import "./chunk-L35M3OD5.js";
14
+ import "./chunk-OBOXCBDL.js";
12
15
  import "./chunk-OLJIJYB5.js";
13
16
  import "./chunk-JF3P66JF.js";
14
17
  import "./chunk-5WRI5ZAA.js";
@@ -16,6 +19,7 @@ export {
16
19
  ChatContext,
17
20
  ChatMessage,
18
21
  MESSAGE_ROLE,
22
+ copyMessageText,
19
23
  useChatContext,
20
24
  useCopyToClipboard
21
25
  };
@@ -0,0 +1,436 @@
1
+ import {
2
+ Table,
3
+ TableBody,
4
+ TableCell,
5
+ TableHead,
6
+ TableHeader,
7
+ TableRow,
8
+ cn,
9
+ useScrollShadow
10
+ } from "./chunk-L35M3OD5.js";
11
+ import {
12
+ IconButton
13
+ } from "./chunk-OBOXCBDL.js";
14
+
15
+ // src/components/artifacts/types.ts
16
+ var artifactTypes = {
17
+ TABLE: "TABLE"
18
+ };
19
+
20
+ // node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
21
+ import { forwardRef, createElement } from "react";
22
+
23
+ // node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
24
+ var defaultAttributes = {
25
+ outline: {
26
+ xmlns: "http://www.w3.org/2000/svg",
27
+ width: 24,
28
+ height: 24,
29
+ viewBox: "0 0 24 24",
30
+ fill: "none",
31
+ stroke: "currentColor",
32
+ strokeWidth: 2,
33
+ strokeLinecap: "round",
34
+ strokeLinejoin: "round"
35
+ },
36
+ filled: {
37
+ xmlns: "http://www.w3.org/2000/svg",
38
+ width: 24,
39
+ height: 24,
40
+ viewBox: "0 0 24 24",
41
+ fill: "currentColor",
42
+ stroke: "none"
43
+ }
44
+ };
45
+
46
+ // node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
47
+ var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
48
+ const Component = forwardRef(
49
+ ({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement(
50
+ "svg",
51
+ {
52
+ ref,
53
+ ...defaultAttributes[type],
54
+ width: size,
55
+ height: size,
56
+ className: [`tabler-icon`, `tabler-icon-${iconName}`, className].join(" "),
57
+ ...type === "filled" ? {
58
+ fill: color
59
+ } : {
60
+ strokeWidth: stroke,
61
+ stroke: color
62
+ },
63
+ ...rest
64
+ },
65
+ [
66
+ title && createElement("title", { key: "svg-title" }, title),
67
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
68
+ ...Array.isArray(children) ? children : [children]
69
+ ]
70
+ )
71
+ );
72
+ Component.displayName = `${iconNamePascal}`;
73
+ return Component;
74
+ };
75
+
76
+ // node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.mjs
77
+ var __iconNode = [["path", { "d": "M5 12l5 5l10 -10", "key": "svg-0" }]];
78
+ var IconCheck = createReactComponent("outline", "check", "Check", __iconNode);
79
+
80
+ // node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.mjs
81
+ var __iconNode2 = [["path", { "d": "M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666", "key": "svg-0" }], ["path", { "d": "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1", "key": "svg-1" }]];
82
+ var IconCopy = createReactComponent("outline", "copy", "Copy", __iconNode2);
83
+
84
+ // node_modules/@tabler/icons-react/dist/esm/icons/IconDownload.mjs
85
+ var __iconNode3 = [["path", { "d": "M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2", "key": "svg-0" }], ["path", { "d": "M7 11l5 5l5 -5", "key": "svg-1" }], ["path", { "d": "M12 4l0 12", "key": "svg-2" }]];
86
+ var IconDownload = createReactComponent("outline", "download", "Download", __iconNode3);
87
+
88
+ // node_modules/@tabler/icons-react/dist/esm/icons/IconThumbDown.mjs
89
+ var __iconNode4 = [["path", { "d": "M7 13v-8a1 1 0 0 0 -1 -1h-2a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h3a4 4 0 0 1 4 4v1a2 2 0 0 0 4 0v-5h3a2 2 0 0 0 2 -2l-1 -5a2 3 0 0 0 -2 -2h-7a3 3 0 0 0 -3 3", "key": "svg-0" }]];
90
+ var IconThumbDown = createReactComponent("outline", "thumb-down", "ThumbDown", __iconNode4);
91
+
92
+ // node_modules/@tabler/icons-react/dist/esm/icons/IconThumbUp.mjs
93
+ var __iconNode5 = [["path", { "d": "M7 11v8a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1h3a4 4 0 0 0 4 -4v-1a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1 -2 2h-7a3 3 0 0 1 -3 -3", "key": "svg-0" }]];
94
+ var IconThumbUp = createReactComponent("outline", "thumb-up", "ThumbUp", __iconNode5);
95
+
96
+ // src/components/ui/tooltip.tsx
97
+ import * as React from "react";
98
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
99
+ import { jsx } from "react/jsx-runtime";
100
+ var TooltipProvider = TooltipPrimitive.Provider;
101
+ var Tooltip = TooltipPrimitive.Root;
102
+ var TooltipTrigger = TooltipPrimitive.Trigger;
103
+ var TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
104
+ TooltipPrimitive.Content,
105
+ {
106
+ ref,
107
+ sideOffset,
108
+ className: cn(
109
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
110
+ className
111
+ ),
112
+ ...props
113
+ }
114
+ ));
115
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
116
+
117
+ // src/components/artifacts/artifact-download-button/artifact-download-button.tsx
118
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
119
+ function ArtifactDownloadButton({ href }) {
120
+ if (!isSafeDownloadUrl(href)) return null;
121
+ return /* @__PURE__ */ jsx2(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
122
+ /* @__PURE__ */ jsx2(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx2(
123
+ IconButton,
124
+ {
125
+ as: "a",
126
+ href,
127
+ download: true,
128
+ rel: "noopener noreferrer",
129
+ icon: IconDownload,
130
+ size: "small",
131
+ "aria-label": "Download artifact"
132
+ }
133
+ ) }),
134
+ /* @__PURE__ */ jsx2(TooltipContent, { children: "Download" })
135
+ ] }) });
136
+ }
137
+ function isSafeDownloadUrl(url) {
138
+ try {
139
+ const parsed = new URL(url);
140
+ return parsed.protocol === "https:" || parsed.protocol === "http:";
141
+ } catch {
142
+ return false;
143
+ }
144
+ }
145
+
146
+ // src/components/artifacts/table-artifact/table-artifact.tsx
147
+ import { useEffect as useEffect2 } from "react";
148
+
149
+ // src/components/ai-elements/artifact.tsx
150
+ import { jsx as jsx3 } from "react/jsx-runtime";
151
+ var Artifact = ({ className, ...props }) => /* @__PURE__ */ jsx3(
152
+ "div",
153
+ {
154
+ className: cn("flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm", className),
155
+ ...props
156
+ }
157
+ );
158
+ var ArtifactHeader = ({ className, ...props }) => /* @__PURE__ */ jsx3("div", { className: cn("flex items-center justify-between border-b bg-muted/50 px-4 py-3", className), ...props });
159
+ var ArtifactTitle = ({ className, ...props }) => /* @__PURE__ */ jsx3("p", { className: cn("font-medium text-foreground text-sm", className), ...props });
160
+ var ArtifactActions = ({ className, ...props }) => /* @__PURE__ */ jsx3("div", { className: cn("flex items-center gap-1", className), ...props });
161
+ var ArtifactContent = ({ className, ...props }) => /* @__PURE__ */ jsx3("div", { className: cn("flex-1 overflow-auto p-4", className), ...props });
162
+
163
+ // src/components/artifacts/table-artifact/table-artifact-styles.ts
164
+ import { createElement as createElement2 } from "react";
165
+ function StatusMessage({ $tone, children }) {
166
+ return createElement2(
167
+ "div",
168
+ {
169
+ className: `py-6 px-2 text-center text-sm font-medium leading-5 ${$tone === "error" ? "text-red-600" : "text-brown-70"}`
170
+ },
171
+ children
172
+ );
173
+ }
174
+
175
+ // src/components/artifacts/table-artifact/table-artifact-content.constants.ts
176
+ var TABLE_STATUS = {
177
+ LOADING: "loading",
178
+ READY: "ready",
179
+ ERROR: "error",
180
+ UNAVAILABLE: "unavailable"
181
+ };
182
+
183
+ // src/components/artifacts/table-artifact/table-artifact-content.utils.ts
184
+ function formatCell(row, column) {
185
+ return row[column.key] ?? "";
186
+ }
187
+ var HEAD_CLASS = "h-auto py-2 px-4 text-xs font-medium text-foreground whitespace-nowrap text-left";
188
+ var CELL_CLASS = "p-4 text-sm font-normal text-foreground align-top min-w-[150px] text-left";
189
+ var ROW_CLASSES = "border-b-brown-30 bg-background/70 hover:bg-secondary";
190
+ var DATA_ROW_CLASSES = `${ROW_CLASSES} animate-in fade-in duration-300`;
191
+ var SCROLL_SHADOW = "0 1px 2px rgb(0 0 0 / 0.01), 0 6px 12px -2px rgb(0 0 0 / 0.03)";
192
+
193
+ // src/components/artifacts/table-artifact/table-artifact-content.tsx
194
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
195
+ function TableArtifactContent({
196
+ columns,
197
+ data,
198
+ knownRowCount,
199
+ maxShimmerRows,
200
+ maxBodyHeight,
201
+ unavailableMessage
202
+ }) {
203
+ if (data.status === TABLE_STATUS.ERROR) {
204
+ return /* @__PURE__ */ jsx4(StatusMessage, { $tone: "error", children: "Couldn't load table data." });
205
+ }
206
+ if (data.status === TABLE_STATUS.UNAVAILABLE) {
207
+ return /* @__PURE__ */ jsx4(StatusMessage, { $tone: "info", children: unavailableMessage });
208
+ }
209
+ if (data.status === TABLE_STATUS.LOADING) {
210
+ if (typeof knownRowCount === "number" && knownRowCount > 0) {
211
+ const shimmerCount = Math.min(knownRowCount, maxShimmerRows);
212
+ return /* @__PURE__ */ jsx4(ArtifactTable, { columns, maxBodyHeight, children: renderShimmerRows(columns, shimmerCount) });
213
+ }
214
+ return /* @__PURE__ */ jsx4(StatusMessage, { $tone: "info", children: "Loading table\u2026" });
215
+ }
216
+ return /* @__PURE__ */ jsx4(ArtifactTable, { columns, maxBodyHeight, children: data.rows.length === 0 ? renderEmptyRow(columns.length) : renderDataRows(columns, data.rows) });
217
+ }
218
+ function ArtifactTable({ columns, maxBodyHeight, children }) {
219
+ const { targetRef, isScrolled } = useScrollShadow();
220
+ return /* @__PURE__ */ jsx4("div", { ref: targetRef, className: "overscroll-none", style: { maxHeight: maxBodyHeight, overflowY: "auto" }, children: /* @__PURE__ */ jsxs2(Table, { containerClassName: "overflow-visible", children: [
221
+ /* @__PURE__ */ jsx4(
222
+ TableHeader,
223
+ {
224
+ "data-scrolled": isScrolled ? "true" : void 0,
225
+ className: "sticky top-0 z-10 bg-background/70 backdrop-blur-lg transition-shadow",
226
+ style: isScrolled ? { boxShadow: SCROLL_SHADOW } : void 0,
227
+ children: /* @__PURE__ */ jsx4(TableRow, { className: "hover:bg-transparent", children: columns.map((column) => /* @__PURE__ */ jsx4(TableHead, { scope: "col", className: HEAD_CLASS, children: column.label }, column.key)) })
228
+ }
229
+ ),
230
+ /* @__PURE__ */ jsx4(TableBody, { children })
231
+ ] }) });
232
+ }
233
+ function renderShimmerRows(columns, count) {
234
+ return Array.from({ length: count }).map((_, index) => /* @__PURE__ */ jsx4(TableRow, { className: ROW_CLASSES, "aria-hidden": "true", children: columns.map((column) => /* @__PURE__ */ jsx4(TableCell, { className: CELL_CLASS, children: /* @__PURE__ */ jsx4("span", { className: "block h-3 w-3/4 animate-pulse rounded bg-muted-foreground/20" }) }, column.key)) }, `shimmer-${index}`));
235
+ }
236
+ function renderDataRows(columns, rows) {
237
+ return rows.map((row, index) => /* @__PURE__ */ jsx4(TableRow, { className: DATA_ROW_CLASSES, children: columns.map((column) => /* @__PURE__ */ jsx4(TableCell, { className: CELL_CLASS, children: formatCell(row, column) }, column.key)) }, index));
238
+ }
239
+ function renderEmptyRow(colSpan) {
240
+ return /* @__PURE__ */ jsx4(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx4(TableCell, { colSpan, className: "py-6 text-center text-sm text-muted-foreground", children: "No rows to display." }) });
241
+ }
242
+
243
+ // src/components/artifacts/table-artifact/use-table-artifact-data.ts
244
+ import { useEffect, useMemo, useState } from "react";
245
+
246
+ // src/components/artifacts/table-artifact/parse-csv.ts
247
+ import Papa from "papaparse";
248
+ function parseCsv(text, columns) {
249
+ const result = Papa.parse(text, {
250
+ header: true,
251
+ skipEmptyLines: true,
252
+ dynamicTyping: false
253
+ });
254
+ const csvHeaders = new Set(result.meta?.fields ?? []);
255
+ const presentColumns = columns.filter((col) => csvHeaders.has(col.key));
256
+ return result.data.map((rawRow) => {
257
+ const row = {};
258
+ for (const column of presentColumns) {
259
+ const value = rawRow[column.key];
260
+ row[column.key] = value === void 0 || value === "" ? null : value;
261
+ }
262
+ return row;
263
+ });
264
+ }
265
+
266
+ // src/components/artifacts/table-artifact/use-table-artifact-data.ts
267
+ var LOADING = { status: "loading", rows: null, error: null };
268
+ var UNAVAILABLE = { status: "unavailable", rows: null, error: null };
269
+ var INITIAL_INTERNAL = { cacheKey: null, data: LOADING };
270
+ function columnsFingerprint(columns) {
271
+ return columns.map((c) => `${c.key}:${c.type ?? "string"}`).join("|");
272
+ }
273
+ function useTableArtifactData(presignedUrl, columns) {
274
+ const colsKey = useMemo(() => columnsFingerprint(columns), [columns]);
275
+ const cacheKey = presignedUrl ? `${presignedUrl}::${colsKey}` : null;
276
+ const [state, setState] = useState(INITIAL_INTERNAL);
277
+ useEffect(() => {
278
+ if (!presignedUrl) return;
279
+ const controller = new AbortController();
280
+ fetch(presignedUrl, {
281
+ signal: controller.signal,
282
+ headers: { Accept: "text/csv" },
283
+ // Presigned URLs are cross-origin S3 in production and don't need credentials. Explicit
284
+ // omit so a same-origin URL (compromised payload, local dev) can't accidentally receive
285
+ // session cookies or auth headers.
286
+ credentials: "omit"
287
+ }).then(async (response) => {
288
+ if (!response.ok) throw new Error(`Failed to load table data (${response.status})`);
289
+ return response.text();
290
+ }).then((text) => {
291
+ if (controller.signal.aborted) return;
292
+ try {
293
+ const rows = parseCsv(text, columns);
294
+ setState({ cacheKey: `${presignedUrl}::${colsKey}`, data: { status: "ready", rows, error: null } });
295
+ } catch (parseError) {
296
+ console.error("[TableArtifact] CSV parse failed", parseError);
297
+ const err = parseError instanceof Error ? parseError : new Error(String(parseError));
298
+ setState({ cacheKey: `${presignedUrl}::${colsKey}`, data: { status: "error", rows: null, error: err } });
299
+ }
300
+ }).catch((error) => {
301
+ if (controller.signal.aborted) return;
302
+ console.error("[TableArtifact] Fetch failed", error);
303
+ const err = error instanceof Error ? error : new Error(String(error));
304
+ setState({ cacheKey: `${presignedUrl}::${colsKey}`, data: { status: "error", rows: null, error: err } });
305
+ });
306
+ return () => {
307
+ controller.abort();
308
+ };
309
+ }, [presignedUrl, colsKey]);
310
+ if (!presignedUrl) return UNAVAILABLE;
311
+ if (state.cacheKey !== cacheKey) return LOADING;
312
+ return state.data;
313
+ }
314
+
315
+ // src/components/artifacts/table-artifact/validate.ts
316
+ function isValidTableConfig(config) {
317
+ if (!config || typeof config !== "object") return false;
318
+ const candidate = config;
319
+ if (!Array.isArray(candidate.columns)) return false;
320
+ if (candidate.columns.length === 0) return false;
321
+ return candidate.columns.every(isValidTableColumn);
322
+ }
323
+ function isValidTableColumn(column) {
324
+ if (!column || typeof column !== "object") return false;
325
+ const candidate = column;
326
+ if (typeof candidate.key !== "string" || candidate.key.length === 0) return false;
327
+ if (typeof candidate.label !== "string") return false;
328
+ return true;
329
+ }
330
+
331
+ // src/components/artifacts/table-artifact/table-artifact.tsx
332
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
333
+ var TITLE_CLASSES = "text-sm font-semibold text-foreground";
334
+ var TABLE_MAX_BODY_HEIGHT = 480;
335
+ var MAX_SHIMMER_ROWS = 10;
336
+ var MSG_UNAVAILABLE = "Table data is unavailable.";
337
+ function TableArtifact({ artifact }) {
338
+ const validConfig = isValidTableConfig(artifact.config);
339
+ const validColumns = validConfig ? artifact.config.columns : null;
340
+ useEffect2(() => {
341
+ if (validConfig) return;
342
+ console.warn("[clay] TableArtifact: malformed `config` \u2014 skipping render.");
343
+ }, [validConfig]);
344
+ const data = useTableArtifactData(
345
+ validConfig ? artifact.protectedAsset?.presignedUrl ?? null : null,
346
+ validColumns ?? []
347
+ );
348
+ const presignedUrl = artifact.protectedAsset?.presignedUrl ?? null;
349
+ if (!validConfig || !validColumns) {
350
+ return /* @__PURE__ */ jsxs3(Artifact, { className: "shadow-none w-full rounded-2xl bg-background/70", children: [
351
+ /* @__PURE__ */ jsxs3(ArtifactHeader, { className: "bg-background/70", children: [
352
+ artifact.title ? /* @__PURE__ */ jsx5(ArtifactTitle, { className: TITLE_CLASSES, children: artifact.title }) : /* @__PURE__ */ jsx5("span", {}),
353
+ presignedUrl ? /* @__PURE__ */ jsx5(ArtifactActions, { children: /* @__PURE__ */ jsx5(ArtifactDownloadButton, { href: presignedUrl }) }) : null
354
+ ] }),
355
+ /* @__PURE__ */ jsx5(ArtifactContent, { className: "p-0 overflow-auto", style: { maxHeight: TABLE_MAX_BODY_HEIGHT }, children: /* @__PURE__ */ jsx5(StatusMessage, { $tone: "info", children: MSG_UNAVAILABLE }) })
356
+ ] });
357
+ }
358
+ return (
359
+ // The table body owns its own scroll container (`ArtifactTable` inside `TableArtifactContent`).
360
+ // Disable the outer overflow container so only one scroll context exists — this prevents
361
+ // double-scroll nesting and lets `useScrollShadow` find the correct scroll ancestor.
362
+ /* @__PURE__ */ jsxs3(Artifact, { className: "shadow-none w-full rounded-2xl bg-background/70", children: [
363
+ /* @__PURE__ */ jsxs3(ArtifactHeader, { className: "bg-background/70", children: [
364
+ artifact.title ? /* @__PURE__ */ jsx5(ArtifactTitle, { className: TITLE_CLASSES, children: artifact.title }) : /* @__PURE__ */ jsx5("span", {}),
365
+ /* @__PURE__ */ jsx5(ArtifactActions, { children: /* @__PURE__ */ jsx5(ArtifactDownloadButton, { href: presignedUrl ?? "" }) })
366
+ ] }),
367
+ /* @__PURE__ */ jsx5(ArtifactContent, { className: "p-0 overflow-visible", style: { maxHeight: "none" }, children: /* @__PURE__ */ jsx5(
368
+ TableArtifactContent,
369
+ {
370
+ columns: validColumns,
371
+ data,
372
+ knownRowCount: artifact.config.stats?.rowCount,
373
+ maxShimmerRows: MAX_SHIMMER_ROWS,
374
+ maxBodyHeight: TABLE_MAX_BODY_HEIGHT,
375
+ unavailableMessage: MSG_UNAVAILABLE
376
+ }
377
+ ) })
378
+ ] })
379
+ );
380
+ }
381
+
382
+ // src/components/artifacts/table-artifact/to-clipboard-text.ts
383
+ function tableArtifactToClipboardText(artifact) {
384
+ const trimmedTitle = artifact.title?.trim();
385
+ return trimmedTitle || "Table";
386
+ }
387
+
388
+ // src/components/artifacts/artifact-services/table-artifact-service.ts
389
+ var TableArtifactService = {
390
+ type: artifactTypes.TABLE,
391
+ Component: TableArtifact,
392
+ toClipboardText: tableArtifactToClipboardText
393
+ };
394
+
395
+ // src/components/artifacts/artifact-services/index.ts
396
+ var ArtifactServices = {
397
+ [artifactTypes.TABLE]: TableArtifactService
398
+ };
399
+ function artifactToClipboardText(artifact) {
400
+ const entry = ArtifactServices[artifact.type];
401
+ if (!entry) {
402
+ return `[Artifact: ${artifact.title ?? artifact.type}]`;
403
+ }
404
+ return entry.toClipboardText(artifact);
405
+ }
406
+
407
+ export {
408
+ artifactTypes,
409
+ IconCheck,
410
+ IconCopy,
411
+ IconThumbDown,
412
+ IconThumbUp,
413
+ ArtifactDownloadButton,
414
+ isSafeDownloadUrl,
415
+ TableArtifact,
416
+ ArtifactServices,
417
+ artifactToClipboardText
418
+ };
419
+ /*! Bundled license information:
420
+
421
+ @tabler/icons-react/dist/esm/defaultAttributes.mjs:
422
+ @tabler/icons-react/dist/esm/createReactComponent.mjs:
423
+ @tabler/icons-react/dist/esm/icons/IconCheck.mjs:
424
+ @tabler/icons-react/dist/esm/icons/IconCopy.mjs:
425
+ @tabler/icons-react/dist/esm/icons/IconDownload.mjs:
426
+ @tabler/icons-react/dist/esm/icons/IconThumbDown.mjs:
427
+ @tabler/icons-react/dist/esm/icons/IconThumbUp.mjs:
428
+ @tabler/icons-react/dist/esm/tabler-icons-react.mjs:
429
+ (**
430
+ * @license @tabler/icons-react v3.37.1 - MIT
431
+ *
432
+ * This source code is licensed under the MIT license.
433
+ * See the LICENSE file in the root directory of this source tree.
434
+ *)
435
+ */
436
+ //# sourceMappingURL=chunk-BX5TCEPR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/artifacts/types.ts","../node_modules/@tabler/icons-react/src/defaultAttributes.ts","../node_modules/@tabler/icons-react/src/createReactComponent.ts","../node_modules/@tabler/icons-react/src/icons/IconCheck.ts","../node_modules/@tabler/icons-react/src/icons/IconCopy.ts","../node_modules/@tabler/icons-react/src/icons/IconDownload.ts","../node_modules/@tabler/icons-react/src/icons/IconThumbDown.ts","../node_modules/@tabler/icons-react/src/icons/IconThumbUp.ts","../src/components/ui/tooltip.tsx","../src/components/artifacts/artifact-download-button/artifact-download-button.tsx","../src/components/artifacts/table-artifact/table-artifact.tsx","../src/components/ai-elements/artifact.tsx","../src/components/artifacts/table-artifact/table-artifact-styles.ts","../src/components/artifacts/table-artifact/table-artifact-content.constants.ts","../src/components/artifacts/table-artifact/table-artifact-content.utils.ts","../src/components/artifacts/table-artifact/table-artifact-content.tsx","../src/components/artifacts/table-artifact/use-table-artifact-data.ts","../src/components/artifacts/table-artifact/parse-csv.ts","../src/components/artifacts/table-artifact/validate.ts","../src/components/artifacts/table-artifact/to-clipboard-text.ts","../src/components/artifacts/artifact-services/table-artifact-service.ts","../src/components/artifacts/artifact-services/index.ts"],"sourcesContent":["/**\n * Artifact-domain types — wire-protocol shapes shared between artifact components, block-services, and\n * consumers. The block layer (`@/components/blocks`) imports these to define\n * `ArtifactRefBlockRecord`; the artifact components consume them directly.\n *\n * Mirrored from the agent / io-server contract — see the `chat-typed-content-blocks-and-artifacts`\n * plan, §6.4 (table contract).\n */\n\nimport type { ComponentType } from \"react\";\n\n/**\n * Artifact-type discriminator constants. Uppercase to match the server-side `artifactTypes`\n * constant — io-server stores `artifact.type === \"TABLE\"` (aligned with the GraphQL enum).\n */\nexport const artifactTypes = {\n TABLE: \"TABLE\",\n} as const;\n\n/** Discriminator for artifact types. Additive — new types extend this union. */\nexport type ArtifactType = (typeof artifactTypes)[keyof typeof artifactTypes];\n\n/**\n * A single column descriptor for a `TableArtifact`. Carries the ORDER and LABEL for the\n * rendered table — `key` selects a column from the CSV header; `label` overrides the rendered\n * header text. The CSV is always the source of truth for the data shape; clay never coerces,\n * reformats, or interprets cell values.\n */\nexport interface TableColumn {\n /** Matches a header in the CSV. Required. Used to project + order the CSV's columns. */\n key: string;\n /** Human-readable header text. Required. */\n label: string;\n /**\n * Accepted in the wire payload but not consulted by the renderer — every cell is rendered as\n * the raw CSV string (or empty for null). Format conversion is a server concern; if a column\n * needs to be \"Yes/No\" instead of \"true/false\", the server should emit it that way in the CSV.\n * Kept in the interface so callers that pass `type` (e.g. io-client) don't get a type error.\n */\n type?: \"string\" | \"number\" | \"date\" | \"boolean\";\n /**\n * Accepted in the wire payload but not consulted by the renderer — every column is left-aligned\n * by design. Kept in the interface for forward-compat; restore per-column alignment by editing\n * `table-artifact-content.tsx` if a future use case justifies it.\n */\n align?: \"left\" | \"center\" | \"right\";\n}\n\n/**\n * Optional stats embedded in `TableConfig` so clients can pre-render UI before fetching the\n * actual data payload (e.g. N loading shimmers sized to the eventual row count).\n *\n * Backward-compat: optional everywhere — older artifacts persisted before this field shipped\n * still validate. The renderer falls back to a single status-message line when `stats` is absent.\n */\nexport interface TableStats {\n /** Total number of rows in the materialised CSV. Lets the loading branch render shimmers. */\n rowCount: number;\n}\n\n/** Rendering config for a table artifact, stored at `artifact.config` (JSONB on the server). */\nexport interface TableConfig {\n /** Column descriptors in render order. */\n columns: TableColumn[];\n /** Optional metadata describing the underlying data — used for loading-state UI. */\n stats?: TableStats;\n}\n\n/**\n * A row inside a table artifact's parsed CSV. Every cell is the raw string from the CSV (or\n * `null` for the empty string). The renderer never coerces or interprets — type-aware formatting\n * is a server concern (the CSV's contents are what the user sees).\n */\nexport type TableRow = Record<string, string | null>;\n\n/** Common shape every artifact record carries. Discriminated by `type`. */\ninterface ArtifactBase<TType extends ArtifactType, TConfig> {\n /** Artifact-type discriminator. */\n type: TType;\n /** Human-readable label. Nullable when the artifact has no title. */\n title: string | null;\n /** Rendering config — shape varies per artifact type. */\n config: TConfig;\n /** Protected-asset metadata pointing to the underlying data payload. Null while the asset is unavailable. */\n protectedAsset: {\n /** Time-limited URL the renderer fetches the artifact's data from. */\n presignedUrl: string;\n } | null;\n}\n\n/** Concrete table artifact record. Future artifact types extend `ArtifactRecord` here. */\nexport type TableArtifactRecord = ArtifactBase<typeof artifactTypes.TABLE, TableConfig>;\n\n/**\n * Discriminated union of all supported artifacts. Single-member today; extension pattern:\n *\n * export type ArtifactRecord = TableArtifactRecord | ChartArtifactRecord;\n *\n * Every consumer that narrows on `artifact.type` must add the new branch here AND in the\n * `ArtifactServices` map (single source of truth for the type→component mapping). Older clay\n * versions that don't know about a new type silently render nothing — see `ArtifactRefBlock` guard.\n */\nexport type ArtifactRecord = TableArtifactRecord;\n\n/** Props every concrete artifact component receives from the dispatcher. */\nexport interface ArtifactServiceProps<TArtifact extends ArtifactRecord = ArtifactRecord> {\n /** The artifact metadata (config + presigned URL). */\n artifact: TArtifact;\n}\n\n/** Per-artifact-type service — registry entry that pairs a discriminator with its concrete component. */\nexport interface ArtifactService<TArtifact extends ArtifactRecord = ArtifactRecord> {\n /** Discriminator value this service handles. */\n type: ArtifactType;\n /** React component that renders an artifact of this type — composes ai-elements primitives\n * (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`, `ArtifactContent`) directly. */\n Component: ComponentType<ArtifactServiceProps<TArtifact>>;\n /**\n * Returns a plain-text / markdown string suitable for clipboard copy.\n *\n * Called by `ArtifactRefBlockService.toClipboardText` when the user copies a message that\n * contains this artifact. Must be pure and synchronous.\n *\n * Implementation notes per type:\n * - `table`: returns the artifact title as plain text (see `TableArtifactService`).\n * - Future types implement their own representation in a co-located `*-service.ts` file.\n */\n toClipboardText: (artifact: TArtifact) => string;\n}\n","export default {\n outline: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: 24,\n height: 24,\n viewBox: '0 0 24 24',\n fill: 'none',\n stroke: 'currentColor',\n strokeWidth: 2,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n },\n filled: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: 24,\n height: 24,\n viewBox: '0 0 24 24',\n fill: 'currentColor',\n stroke: 'none',\n },\n};\n","import { forwardRef, createElement } from 'react';\nimport defaultAttributes from './defaultAttributes';\nimport type { IconNode, IconProps, Icon } from './types';\n\nconst createReactComponent = (\n type: 'outline' | 'filled',\n iconName: string,\n iconNamePascal: string,\n iconNode: IconNode,\n) => {\n const Component = forwardRef<SVGSVGElement, IconProps>(\n (\n { color = 'currentColor', size = 24, stroke = 2, title, className, children, ...rest }: IconProps,\n ref,\n ) =>\n createElement(\n 'svg',\n {\n ref,\n ...defaultAttributes[type],\n width: size,\n height: size,\n className: [`tabler-icon`, `tabler-icon-${iconName}`, className].join(' '),\n ...(type === 'filled'\n ? {\n fill: color,\n }\n : {\n strokeWidth: stroke,\n stroke: color,\n }),\n ...rest,\n },\n [\n title && createElement('title', { key: 'svg-title' }, title),\n ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),\n ...(Array.isArray(children) ? children : [children]),\n ],\n ),\n );\n\n Component.displayName = `${iconNamePascal}`;\n\n return Component;\n};\n\nexport default createReactComponent;\n","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M5 12l5 5l10 -10\",\"key\":\"svg-0\"}]]\n\nconst IconCheck = createReactComponent('outline', 'check', 'Check', __iconNode);\n\nexport default IconCheck;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666\",\"key\":\"svg-0\"}],[\"path\",{\"d\":\"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1\",\"key\":\"svg-1\"}]]\n\nconst IconCopy = createReactComponent('outline', 'copy', 'Copy', __iconNode);\n\nexport default IconCopy;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2\",\"key\":\"svg-0\"}],[\"path\",{\"d\":\"M7 11l5 5l5 -5\",\"key\":\"svg-1\"}],[\"path\",{\"d\":\"M12 4l0 12\",\"key\":\"svg-2\"}]]\n\nconst IconDownload = createReactComponent('outline', 'download', 'Download', __iconNode);\n\nexport default IconDownload;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M7 13v-8a1 1 0 0 0 -1 -1h-2a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h3a4 4 0 0 1 4 4v1a2 2 0 0 0 4 0v-5h3a2 2 0 0 0 2 -2l-1 -5a2 3 0 0 0 -2 -2h-7a3 3 0 0 0 -3 3\",\"key\":\"svg-0\"}]]\n\nconst IconThumbDown = createReactComponent('outline', 'thumb-down', 'ThumbDown', __iconNode);\n\nexport default IconThumbDown;","import createReactComponent from '../createReactComponent';\nimport { IconNode } from '../types';\n\nexport const __iconNode: IconNode = [[\"path\",{\"d\":\"M7 11v8a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1h3a4 4 0 0 0 4 -4v-1a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1 -2 2h-7a3 3 0 0 1 -3 -3\",\"key\":\"svg-0\"}]]\n\nconst IconThumbUp = createReactComponent('outline', 'thumb-up', 'ThumbUp', __iconNode);\n\nexport default IconThumbUp;","import * as React from \"react\";\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst TooltipProvider = TooltipPrimitive.Provider;\n\nconst Tooltip = TooltipPrimitive.Root;\n\nconst TooltipTrigger = TooltipPrimitive.Trigger;\n\nconst TooltipContent = React.forwardRef<\n React.ElementRef<typeof TooltipPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>\n>(({ className, sideOffset = 4, ...props }, ref) => (\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]\",\n className\n )}\n {...props}\n />\n));\nTooltipContent.displayName = TooltipPrimitive.Content.displayName;\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n","import { IconDownload } from \"@tabler/icons-react\";\nimport type { ReactNode } from \"react\";\n\nimport { IconButton } from \"@/components/icon-button/icon-button\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from \"@/components/ui/tooltip\";\n\n/** Props for `ArtifactDownloadButton`. */\nexport interface ArtifactDownloadButtonProps {\n /**\n * URL to download the artifact's underlying bytes. The button is an `<a href download>` so the\n * browser uses whatever filename the server supplies via `Content-Disposition`. No client-side\n * filename invention.\n *\n * Renders nothing when the URL is not a safe `http(s):` scheme — guards against `javascript:` or\n * `data:` URIs smuggled into `presignedUrl`.\n */\n href: string;\n}\n\n/**\n * Reusable download button for artifact headers. Anchor-based so the browser handles the download\n * natively (respects `Content-Disposition`, falls back to URL basename). `rel=\"noopener noreferrer\"`\n * defends against `window.opener` leakage if the browser opens the URL instead of downloading.\n *\n * Drop this inside `<ArtifactActions>` in any per-type artifact orchestrator.\n */\nexport function ArtifactDownloadButton({ href }: ArtifactDownloadButtonProps): ReactNode {\n if (!isSafeDownloadUrl(href)) return null;\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <IconButton\n as=\"a\"\n href={href}\n download\n rel=\"noopener noreferrer\"\n icon={IconDownload}\n size=\"small\"\n aria-label=\"Download artifact\"\n />\n </TooltipTrigger>\n <TooltipContent>Download</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n\n/**\n * Returns `true` only for `http:` and `https:` URLs. Rejects `javascript:`, `data:`, and any\n * other scheme that could execute code on click.\n */\nexport function isSafeDownloadUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"https:\" || parsed.protocol === \"http:\";\n } catch {\n return false;\n }\n}\n","import { useEffect, type ReactNode } from \"react\";\n\nimport {\n Artifact,\n ArtifactActions,\n ArtifactContent,\n ArtifactHeader,\n ArtifactTitle,\n} from \"@/components/ai-elements/artifact\";\nimport { ArtifactDownloadButton } from \"@/components/artifacts/artifact-download-button/artifact-download-button\";\nimport type { ArtifactServiceProps } from \"@/components/artifacts/types\";\nimport type { TableArtifactRecord } from \"@/components/artifacts/types\";\nimport { TableArtifactContent } from \"./table-artifact-content\";\nimport { StatusMessage } from \"./table-artifact-styles\";\nimport { useTableArtifactData } from \"./use-table-artifact-data\";\nimport { isValidTableConfig } from \"./validate\";\n\nconst TITLE_CLASSES = \"text-sm font-semibold text-foreground\";\n\n/**\n * Cap the body at ~10 rows × 48px (~480px). Long lists scroll inside the artifact so they\n * don't stretch the chat surface. Each artifact type declares its own sensible cap.\n */\nconst TABLE_MAX_BODY_HEIGHT = 480;\n\n/**\n * Cap on shimmer rows during loading. Approximates the visible viewport (`TABLE_MAX_BODY_HEIGHT`\n * ÷ 48px per row) so we don't render hundreds of placeholder DOM nodes for very large tables.\n */\nconst MAX_SHIMMER_ROWS = 10;\n\n/** User-facing copy for permanent server-side absence of the artifact's data (no presigned URL or malformed config). */\nconst MSG_UNAVAILABLE = \"Table data is unavailable.\";\n\n/**\n * Orchestrator for the `table`-typed artifact.\n *\n * Composes the ai-elements chrome primitives (`Artifact`, `ArtifactHeader`, `ArtifactTitle`,\n * `ArtifactActions`, `ArtifactContent`) directly around the table body (`TableArtifactContent`).\n * Download is handled via `ArtifactDownloadButton` — a shared utility component that applies the\n * safe-URL guard and renders nothing for non-http(s) schemes.\n */\nexport function TableArtifact({ artifact }: ArtifactServiceProps<TableArtifactRecord>): ReactNode {\n const validConfig = isValidTableConfig(artifact.config);\n const validColumns = validConfig ? artifact.config.columns : null;\n\n useEffect(() => {\n if (validConfig) return;\n console.warn(\"[clay] TableArtifact: malformed `config` — skipping render.\");\n }, [validConfig]);\n\n // Hook is always called (Rules of Hooks). Pass null URL when config is invalid so the hook\n // short-circuits at its `if (!presignedUrl) return UNAVAILABLE` path — no network fetch fires\n // for an artifact whose config shape can't be rendered.\n const data = useTableArtifactData(\n validConfig ? artifact.protectedAsset?.presignedUrl ?? null : null,\n validColumns ?? []\n );\n\n const presignedUrl = artifact.protectedAsset?.presignedUrl ?? null;\n\n if (!validConfig || !validColumns) {\n return (\n <Artifact className=\"shadow-none w-full rounded-2xl bg-background/70\">\n <ArtifactHeader className=\"bg-background/70\">\n {artifact.title ? <ArtifactTitle className={TITLE_CLASSES}>{artifact.title}</ArtifactTitle> : <span />}\n {presignedUrl ? (\n <ArtifactActions>\n <ArtifactDownloadButton href={presignedUrl} />\n </ArtifactActions>\n ) : null}\n </ArtifactHeader>\n <ArtifactContent className=\"p-0 overflow-auto\" style={{ maxHeight: TABLE_MAX_BODY_HEIGHT }}>\n <StatusMessage $tone=\"info\">{MSG_UNAVAILABLE}</StatusMessage>\n </ArtifactContent>\n </Artifact>\n );\n }\n\n return (\n // The table body owns its own scroll container (`ArtifactTable` inside `TableArtifactContent`).\n // Disable the outer overflow container so only one scroll context exists — this prevents\n // double-scroll nesting and lets `useScrollShadow` find the correct scroll ancestor.\n <Artifact className=\"shadow-none w-full rounded-2xl bg-background/70\">\n <ArtifactHeader className=\"bg-background/70\">\n {artifact.title ? <ArtifactTitle className={TITLE_CLASSES}>{artifact.title}</ArtifactTitle> : <span />}\n <ArtifactActions>\n <ArtifactDownloadButton href={presignedUrl ?? \"\"} />\n </ArtifactActions>\n </ArtifactHeader>\n <ArtifactContent className=\"p-0 overflow-visible\" style={{ maxHeight: \"none\" }}>\n <TableArtifactContent\n columns={validColumns}\n data={data}\n knownRowCount={artifact.config.stats?.rowCount}\n maxShimmerRows={MAX_SHIMMER_ROWS}\n maxBodyHeight={TABLE_MAX_BODY_HEIGHT}\n unavailableMessage={MSG_UNAVAILABLE}\n />\n </ArtifactContent>\n </Artifact>\n );\n}\n","import type { HTMLAttributes } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\n/* ------------------------------------------------------------------------------------------------\n * Originally vendored from `@vercel/ai-elements`'s `artifact` registry entry — see\n * https://elements.ai-sdk.dev/api/registry/artifact.json. Slimmed to the chrome primitives clay\n * actually composes (`Artifact`, `ArtifactHeader`, `ArtifactTitle`, `ArtifactActions`,\n * `ArtifactContent`). The original entry also shipped `ArtifactClose`, `ArtifactDescription`, and\n * `ArtifactAction` — all dependent on the shadcn `Button` primitive, none of which clay consumes.\n * Action buttons inside the artifact header use clay's `IconButton` (see `TableArtifact`'s\n * `ExportCsvButton`) instead of a generic shadcn Button, so the design system stays single-sourced.\n *\n * If a future ai-elements re-scaffold needs one of the dropped primitives back, re-add only the\n * piece consumers need and route its inner button through clay's `Button` / `IconButton` rather\n * than re-introducing the shadcn Button file.\n * ------------------------------------------------------------------------------------------------ */\n\nexport type ArtifactProps = HTMLAttributes<HTMLDivElement>;\n\nexport const Artifact = ({ className, ...props }: ArtifactProps) => (\n <div\n className={cn(\"flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm\", className)}\n {...props}\n />\n);\n\nexport type ArtifactHeaderProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ArtifactHeader = ({ className, ...props }: ArtifactHeaderProps) => (\n <div className={cn(\"flex items-center justify-between border-b bg-muted/50 px-4 py-3\", className)} {...props} />\n);\n\nexport type ArtifactTitleProps = HTMLAttributes<HTMLParagraphElement>;\n\nexport const ArtifactTitle = ({ className, ...props }: ArtifactTitleProps) => (\n <p className={cn(\"font-medium text-foreground text-sm\", className)} {...props} />\n);\n\nexport type ArtifactActionsProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ArtifactActions = ({ className, ...props }: ArtifactActionsProps) => (\n <div className={cn(\"flex items-center gap-1\", className)} {...props} />\n);\n\nexport type ArtifactContentProps = HTMLAttributes<HTMLDivElement>;\n\nexport const ArtifactContent = ({ className, ...props }: ArtifactContentProps) => (\n <div className={cn(\"flex-1 overflow-auto p-4\", className)} {...props} />\n);\n","import type { ReactNode } from \"react\";\n\nimport { createElement } from \"react\";\n\ninterface StatusMessageProps {\n /** Visual tone: \"error\" renders red copy, \"info\" renders muted brown copy. */\n $tone?: \"info\" | \"error\";\n children: ReactNode;\n}\n\n/**\n * Centred status copy rendered inside the artifact when there is no table to show\n * (loading without a known row count, error, or unavailable).\n * Uses Tailwind so it stays consistent with the rest of the artifact renderer.\n */\nexport function StatusMessage({ $tone, children }: StatusMessageProps): ReactNode {\n return createElement(\n \"div\",\n {\n className: `py-6 px-2 text-center text-sm font-medium leading-5 ${\n $tone === \"error\" ? \"text-red-600\" : \"text-brown-70\"\n }`,\n },\n children\n );\n}\n","/**\n * Discriminant constants for `TableArtifactDataState.status`.\n *\n * Use these instead of inline string literals so a typo is a compile-time error rather than a\n * silent wrong-branch at runtime.\n */\nexport const TABLE_STATUS = {\n LOADING: \"loading\",\n READY: \"ready\",\n ERROR: \"error\",\n UNAVAILABLE: \"unavailable\",\n} as const;\n","import type { TableColumn, TableRow as TableRowData } from \"@/components/artifacts/types\";\n\n/**\n * Returns a cell's rendered string. The CSV is the source of truth — clay never coerces or\n * reformats values. `null` / missing keys render as the empty cell. The value comes out as it\n * went in (whatever the server wrote into the CSV).\n */\nexport function formatCell(row: TableRowData, column: TableColumn): string {\n return row[column.key] ?? \"\";\n}\n\n/**\n * Header + body cell class strings. Alignment is uniformly left in chat-embedded artifact tables\n * by design (mixing right-aligned numerics with left-aligned text reads inconsistently); the\n * wire-type `column.align` is preserved for forward-compat but ignored at render time. See\n * `TableColumn.align` doc in `@/components/artifacts/types`.\n */\nexport const HEAD_CLASS = \"h-auto py-2 px-4 text-xs font-medium text-foreground whitespace-nowrap text-left\";\nexport const CELL_CLASS = \"p-4 text-sm font-normal text-foreground align-top min-w-[150px] text-left\";\n\n/**\n * Row tint matches the artifact card's frosted-glass scheme. The custom `border-b-brown-30`\n * overrides shadcn's row-default border (which inherits `--color-border` = brown-40) with the\n * lighter brown-30. Hover lifts to `bg-secondary` (opaque brown-20) for strong feedback against\n * the translucent base.\n */\nexport const ROW_CLASSES = \"border-b-brown-30 bg-background/70 hover:bg-secondary\";\n\n/**\n * Mount-time fade-in for data rows so the shimmer-to-data transition feels smooth (300ms ease-in\n * over `opacity: 0 → 1`). Shimmer rows keep `ROW_CLASSES` (no animate-in) so they remain in their\n * loading stillness while the pulse animation runs. `animate-in fade-in duration-300` is provided\n * by `tw-animate-css`.\n */\nexport const DATA_ROW_CLASSES = `${ROW_CLASSES} animate-in fade-in duration-300`;\n\n/** Layered drop-shadow for the scroll-lift effect on the sticky header. */\nexport const SCROLL_SHADOW = \"0 1px 2px rgb(0 0 0 / 0.01), 0 6px 12px -2px rgb(0 0 0 / 0.03)\";\n","import { type ReactNode } from \"react\";\n\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, useScrollShadow } from \"@/components/table\";\nimport type { TableColumn, TableRow as TableRowData } from \"@/components/artifacts/types\";\nimport { StatusMessage } from \"./table-artifact-styles\";\nimport type { ArtifactTableProps, TableArtifactContentProps } from \"./table-artifact-content.types\";\nimport { TABLE_STATUS } from \"./table-artifact-content.constants\";\nimport {\n CELL_CLASS,\n DATA_ROW_CLASSES,\n formatCell,\n HEAD_CLASS,\n ROW_CLASSES,\n SCROLL_SHADOW,\n} from \"./table-artifact-content.utils\";\n\n/**\n * Bridges artifact data-states → shadcn's compound `Table` primitives.\n *\n * The four states render differently:\n *\n * - **loading w/ knownRowCount** → renders a sticky-header table with N shimmer rows so the\n * layout doesn't jump.\n * - **loading w/o knownRowCount** → renders the inline \"Loading table…\" status message.\n * - **error / unavailable** → renders an inline status message.\n * - **ready** → renders the full table with data rows and the scroll-lift\n * shadow on the sticky header.\n *\n * The shadcn primitives are composed directly here — no `Table` wrapper component sits in between.\n * Each row variant (header, data, shimmer, empty) is a small inline component below.\n */\nexport function TableArtifactContent({\n columns,\n data,\n knownRowCount,\n maxShimmerRows,\n maxBodyHeight,\n unavailableMessage,\n}: TableArtifactContentProps): ReactNode {\n if (data.status === TABLE_STATUS.ERROR) {\n // No retry hook today — copy intentionally drops the \"Please try again.\" that has nowhere\n // to land. Wire an `onRetry` callback into `ArtifactService` to re-mint a fresh\n // presigned URL before re-introducing the retry framing.\n return <StatusMessage $tone=\"error\">Couldn't load table data.</StatusMessage>;\n }\n if (data.status === TABLE_STATUS.UNAVAILABLE) {\n return <StatusMessage $tone=\"info\">{unavailableMessage}</StatusMessage>;\n }\n if (data.status === TABLE_STATUS.LOADING) {\n if (typeof knownRowCount === \"number\" && knownRowCount > 0) {\n const shimmerCount = Math.min(knownRowCount, maxShimmerRows);\n return (\n <ArtifactTable columns={columns} maxBodyHeight={maxBodyHeight}>\n {renderShimmerRows(columns, shimmerCount)}\n </ArtifactTable>\n );\n }\n return <StatusMessage $tone=\"info\">Loading table…</StatusMessage>;\n }\n // data.status === TABLE_STATUS.READY\n return (\n <ArtifactTable columns={columns} maxBodyHeight={maxBodyHeight}>\n {data.rows.length === 0 ? renderEmptyRow(columns.length) : renderDataRows(columns, data.rows)}\n </ArtifactTable>\n );\n}\n\n/**\n * Compound-table chrome shared between the loading-shimmer branch and the data/empty branch:\n * scroll container, sticky header, and the body slot. Caller passes the body rows.\n */\nfunction ArtifactTable({ columns, maxBodyHeight, children }: ArtifactTableProps): ReactNode {\n const { targetRef, isScrolled } = useScrollShadow();\n return (\n <div ref={targetRef} className=\"overscroll-none\" style={{ maxHeight: maxBodyHeight, overflowY: \"auto\" }}>\n <Table containerClassName=\"overflow-visible\">\n <TableHeader\n data-scrolled={isScrolled ? \"true\" : undefined}\n className=\"sticky top-0 z-10 bg-background/70 backdrop-blur-lg transition-shadow\"\n style={isScrolled ? { boxShadow: SCROLL_SHADOW } : undefined}\n >\n <TableRow className=\"hover:bg-transparent\">\n {columns.map((column) => (\n <TableHead key={column.key} scope=\"col\" className={HEAD_CLASS}>\n {column.label}\n </TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody>{children}</TableBody>\n </Table>\n </div>\n );\n}\n\nfunction renderShimmerRows(columns: TableColumn[], count: number): ReactNode {\n return Array.from({ length: count }).map((_, index) => (\n <TableRow key={`shimmer-${index}`} className={ROW_CLASSES} aria-hidden=\"true\">\n {columns.map((column) => (\n <TableCell key={column.key} className={CELL_CLASS}>\n <span className=\"block h-3 w-3/4 animate-pulse rounded bg-muted-foreground/20\" />\n </TableCell>\n ))}\n </TableRow>\n ));\n}\n\nfunction renderDataRows(columns: TableColumn[], rows: TableRowData[]): ReactNode {\n // `key={index}` is safe today because `rows` is a static fetch result — no sort, filter, or\n // streaming insertion. The moment row order can change (e.g. client-side sort feature), this\n // must switch to a stable per-row identity or React will reconcile incorrectly (inputs lose\n // focus, animations glitch). The data hook will need to surface a row-id at that point.\n return rows.map((row, index) => (\n <TableRow key={index} className={DATA_ROW_CLASSES}>\n {columns.map((column) => (\n <TableCell key={column.key} className={CELL_CLASS}>\n {formatCell(row, column)}\n </TableCell>\n ))}\n </TableRow>\n ));\n}\n\nfunction renderEmptyRow(colSpan: number): ReactNode {\n return (\n <TableRow className=\"hover:bg-transparent\">\n <TableCell colSpan={colSpan} className=\"py-6 text-center text-sm text-muted-foreground\">\n No rows to display.\n </TableCell>\n </TableRow>\n );\n}\n","import { useEffect, useMemo, useState } from \"react\";\n\nimport type { TableColumn, TableRow } from \"@/components/artifacts/types\";\nimport { parseCsv } from \"./parse-csv\";\n\n/**\n * Discriminator for the result returned by `useTableArtifactData`.\n *\n * - `loading` — fetch is in flight (or about to be).\n * - `ready` — payload fetched and parsed successfully.\n * - `error` — fetch or parse failed at runtime; user can retry.\n * - `unavailable` — the artifact has no presigned URL at all (permanent server-side state). Distinct\n * from `error` so the renderer can surface \"data is unavailable\" instead of a misleading \"try again\".\n */\nexport type TableArtifactDataState =\n | { status: \"loading\"; rows: null; error: null }\n | { status: \"ready\"; rows: TableRow[]; error: null }\n | { status: \"error\"; rows: null; error: Error }\n | { status: \"unavailable\"; rows: null; error: null };\n\nconst LOADING: TableArtifactDataState = { status: \"loading\", rows: null, error: null };\nconst UNAVAILABLE: TableArtifactDataState = { status: \"unavailable\", rows: null, error: null };\n\ninterface InternalState {\n /** The cache key the current `data` was fetched for; used to ignore stale data when inputs change. */\n cacheKey: string | null;\n /** The fetch result for `cacheKey`. */\n data: TableArtifactDataState;\n}\n\nconst INITIAL_INTERNAL: InternalState = { cacheKey: null, data: LOADING };\n\n/**\n * Builds a stable fingerprint string for a columns array so the effect only re-runs when the\n * column definitions actually change, not just when the array reference is replaced.\n */\nfunction columnsFingerprint(columns: TableColumn[]): string {\n return columns.map((c) => `${c.key}:${c.type ?? \"string\"}`).join(\"|\");\n}\n\n/**\n * Fetches a table artifact's data payload from a presigned URL and parses it as CSV.\n *\n * The server writes `text/csv` to the presigned URL (io-server PR #2096). This hook fetches with\n * `Accept: text/csv`, reads the body as text, and delegates to `parseCsv` for RFC 4180 parsing\n * and per-column type coercion (CSV strings → typed values per `column.type`).\n *\n * Returns `loading` while the request is in flight, `unavailable` synchronously when no URL is\n * supplied, `ready` on success, or `error` on a runtime failure (HTTP non-2xx, network, or parse\n * error). Parse errors are surfaced as `error` state — they are never thrown.\n *\n * In-flight requests are cancelled via `AbortController` when the URL or columns change, or the\n * consumer unmounts, so abandoned table loads don't keep consuming bandwidth.\n *\n * @param presignedUrl S3 presigned URL for the artifact's CSV file, or `null`/`undefined` when absent.\n * @param columns Column definitions from `TableConfig.columns` — used for per-cell type coercion.\n */\nexport function useTableArtifactData(\n presignedUrl: string | null | undefined,\n columns: TableColumn[]\n): TableArtifactDataState {\n // Stable fingerprint so the effect doesn't re-fire on referentially-new but content-equal column arrays.\n const colsKey = useMemo(() => columnsFingerprint(columns), [columns]);\n\n const cacheKey = presignedUrl ? `${presignedUrl}::${colsKey}` : null;\n\n const [state, setState] = useState<InternalState>(INITIAL_INTERNAL);\n\n useEffect(() => {\n if (!presignedUrl) return;\n\n const controller = new AbortController();\n\n fetch(presignedUrl, {\n signal: controller.signal,\n headers: { Accept: \"text/csv\" },\n // Presigned URLs are cross-origin S3 in production and don't need credentials. Explicit\n // omit so a same-origin URL (compromised payload, local dev) can't accidentally receive\n // session cookies or auth headers.\n credentials: \"omit\",\n })\n .then(async (response) => {\n if (!response.ok) throw new Error(`Failed to load table data (${response.status})`);\n return response.text();\n })\n .then((text) => {\n if (controller.signal.aborted) return;\n try {\n const rows = parseCsv(text, columns);\n setState({ cacheKey: `${presignedUrl}::${colsKey}`, data: { status: \"ready\", rows, error: null } });\n } catch (parseError: unknown) {\n console.error(\"[TableArtifact] CSV parse failed\", parseError);\n const err = parseError instanceof Error ? parseError : new Error(String(parseError));\n setState({ cacheKey: `${presignedUrl}::${colsKey}`, data: { status: \"error\", rows: null, error: err } });\n }\n })\n .catch((error: unknown) => {\n // Per the Fetch spec, `signal.aborted` is set before the promise rejects on abort, so this\n // guard catches every abort case driven by our `controller.abort()` cleanup.\n if (controller.signal.aborted) return;\n console.error(\"[TableArtifact] Fetch failed\", error);\n const err = error instanceof Error ? error : new Error(String(error));\n setState({ cacheKey: `${presignedUrl}::${colsKey}`, data: { status: \"error\", rows: null, error: err } });\n });\n\n return () => {\n controller.abort();\n };\n // `columns` is intentionally omitted from the dep array: `colsKey` is its stable fingerprint\n // (covers every observable change), and `columns` is validated config from a static payload\n // that cannot mutate between effect invocation and fetch resolution. If `columns` ever becomes\n // dynamic (e.g. a future column-reorder UI), this assumption breaks and the suppression must\n // be removed in favour of including `columns` directly.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [presignedUrl, colsKey]);\n\n if (!presignedUrl) return UNAVAILABLE;\n // While the in-flight URL/columns change, cached data belongs to a stale key — return loading until\n // the new fetch resolves. Avoids a synchronous setState() in the effect body (lint forbids that).\n if (state.cacheKey !== cacheKey) return LOADING;\n return state.data;\n}\n","import Papa from \"papaparse\";\n\nimport type { TableColumn, TableRow } from \"@/components/artifacts/types\";\n\n/**\n * Parses a CSV text payload fetched from a presigned URL into `TableRow[]`.\n *\n * Uses `Papa.parse` with `header: true` (first row is the header) and `skipEmptyLines: true`.\n * Every cell arrives as a string — the renderer NEVER coerces values to JS numbers / booleans /\n * dates. Format conversion is a server concern: if a column needs to be `\"Yes/No\"` or\n * `\"$1,234\"`, the server emits it that way in the CSV.\n *\n * Column projection rules:\n * - CSV header columns NOT in `columns[].key` are silently dropped.\n * - `columns[].key` values missing from the CSV header are silently omitted from row output —\n * client-side reconciliation warnings would let the client second-guess the server's contract.\n * Trust the CSV.\n *\n * Empty cells (`\"\"`) are returned as `null` so the renderer can distinguish \"missing value\"\n * from \"empty string\" downstream.\n *\n * @param text Raw CSV text (may start with a UTF-8 BOM which Papa strips automatically).\n * @param columns Column definitions from `TableConfig.columns`.\n * @returns Rows in source order, projected to the configured columns.\n */\nexport function parseCsv(text: string, columns: TableColumn[]): TableRow[] {\n const result = Papa.parse<Record<string, string>>(text, {\n header: true,\n skipEmptyLines: true,\n dynamicTyping: false,\n });\n\n const csvHeaders = new Set(result.meta?.fields ?? []);\n const presentColumns = columns.filter((col) => csvHeaders.has(col.key));\n\n return result.data.map((rawRow) => {\n const row: TableRow = {};\n for (const column of presentColumns) {\n const value = rawRow[column.key];\n row[column.key] = value === undefined || value === \"\" ? null : value;\n }\n return row;\n });\n}\n","import type { TableColumn, TableConfig } from \"@/components/artifacts/types\";\n\n/**\n * Returns true iff `config` carries the minimum-viable shape for rendering: a non-empty array\n * of columns where each has a non-empty `key` and a string `label`.\n *\n * Anything else is trusted to the server. The deprecated `type` / `align` wire fields are NOT\n * validated — clay doesn't act on them, so rejecting unknown values would punish servers\n * shipping fields clay was about to ignore anyway.\n */\nexport function isValidTableConfig(config: unknown): config is TableConfig {\n if (!config || typeof config !== \"object\") return false;\n const candidate = config as { columns?: unknown };\n if (!Array.isArray(candidate.columns)) return false;\n if (candidate.columns.length === 0) return false;\n return candidate.columns.every(isValidTableColumn);\n}\n\n/** Minimum-viable column shape: non-empty string `key` + string `label`. */\nfunction isValidTableColumn(column: unknown): column is TableColumn {\n if (!column || typeof column !== \"object\") return false;\n const candidate = column as Record<string, unknown>;\n if (typeof candidate.key !== \"string\" || candidate.key.length === 0) return false;\n if (typeof candidate.label !== \"string\") return false;\n return true;\n}\n","import type { TableArtifactRecord } from \"@/components/artifacts/types\";\n\n/**\n * Produces a plain-text clipboard representation of a table artifact.\n *\n * Returns the artifact title as plain text so that pasting into non-markdown-aware targets\n * (plain-text editors, terminal, spreadsheets) does not expose raw markdown syntax. This\n * matches the contract of `TextBlockService.toClipboardText`, which also strips markdown —\n * `useCopyToClipboard` writes the aggregated string verbatim, so every block type must\n * independently normalise to plain text.\n *\n * The presigned URL is intentionally omitted from the clipboard value: presigned URLs expire\n * quickly (typically 15 min–1 h) and are not useful when pasted as bare text. The Download\n * button in the artifact chrome is the canonical way to obtain the file.\n */\nexport function tableArtifactToClipboardText(artifact: TableArtifactRecord): string {\n const trimmedTitle = artifact.title?.trim();\n return trimmedTitle || \"Table\";\n}\n","import type { ArtifactService, TableArtifactRecord } from \"../types\";\nimport { artifactTypes } from \"../types\";\nimport { TableArtifact } from \"../table-artifact/table-artifact\";\nimport { tableArtifactToClipboardText } from \"../table-artifact/to-clipboard-text\";\n\nexport const TableArtifactService: ArtifactService<TableArtifactRecord> = {\n type: artifactTypes.TABLE,\n Component: TableArtifact,\n toClipboardText: tableArtifactToClipboardText,\n};\n","import type { ArtifactRecord, ArtifactService, ArtifactType } from \"../types\";\nimport { artifactTypes } from \"../types\";\nimport { TableArtifactService } from \"./table-artifact-service\";\n\n// `ArtifactService<TSpecific>` is invariant on `TSpecific` via React's `ComponentType`\n// (props are contravariant). Each service overlaps structurally with the base `ArtifactService`\n// enough for a direct `as ArtifactService` cast. The registry dispatches only by runtime\n// discriminator — `ArtifactServices[artifact.type]` always resolves to the matching concrete service.\n/**\n * Map of artifact services keyed by `artifact.type`.\n *\n * Adding a new artifact type = create a `*-service.ts` file (mirroring `block-services/`), then\n * add one entry here. The block-level dispatcher (`ArtifactRefBlock`) consumes this map to\n * render the concrete component; `artifactToClipboardText` consumes it for the clipboard contract.\n */\nexport const ArtifactServices: Record<ArtifactType, ArtifactService> = {\n [artifactTypes.TABLE]: TableArtifactService as ArtifactService,\n};\n\n/**\n * Returns a clipboard-friendly string for an artifact, delegating to the registered service's\n * `toClipboardText`. Falls back to `[Artifact: <title>]` when the artifact type has no registered\n * service (unknown type) so copy never silently produces an empty string.\n */\nexport function artifactToClipboardText(artifact: ArtifactRecord): string {\n const entry = ArtifactServices[artifact.type];\n if (!entry) {\n return `[Artifact: ${artifact.title ?? artifact.type}]`;\n }\n return entry.toClipboardText(artifact);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AACT;A;;;;;ACjBA,IAAA,oBAAe;EACb,SAAS;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;IACR,aAAa;IACb,eAAe;IACf,gBAAgB;EAAA;EAElB,QAAQ;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,QAAQ;EAAA;AAEZ;;;AChBA,IAAM,uBAAuB,CAC3B,MACA,UACA,gBACA,aACG;AACH,QAAM,YAAY;IAChB,CACE,EAAE,QAAQ,gBAAgB,OAAO,IAAI,SAAS,GAAG,OAAO,WAAW,UAAU,GAAG,KAAA,GAChF,QAEA;MACE;MACA;QACE;QACA,GAAG,kBAAkB,IAAI;QACzB,OAAO;QACP,QAAQ;QACR,WAAW,CAAC,eAAe,eAAe,QAAQ,IAAI,SAAS,EAAE,KAAK,GAAG;QACzE,GAAI,SAAS,WACT;UACE,MAAM;QAAA,IAER;UACE,aAAa;UACb,QAAQ;QAAA;QAEd,GAAG;MAAA;MAEL;QACE,SAAS,cAAc,SAAS,EAAE,KAAK,YAAA,GAAe,KAAK;QAC3D,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,cAAc,KAAK,KAAK,CAAC;QAC3D,GAAI,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ;MAAA;IACpD;EACF;AAGJ,YAAU,cAAc,GAAG,cAAc;AAEzC,SAAO;AACT;;;ACzCO,IAAM,aAAuB,CAAC,CAAC,QAAO,EAAC,KAAI,oBAAmB,OAAM,QAA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conNode","jsx","useEffect","jsx","createElement","jsx","jsxs","jsx","jsxs","useEffect"]}
@@ -0,0 +1,12 @@
1
+ // src/components/blocks/block-context/block-context.tsx
2
+ import { createContext, useContext } from "react";
3
+ var BlockContext = createContext(null);
4
+ function useBlockContext() {
5
+ return useContext(BlockContext) ?? {};
6
+ }
7
+
8
+ export {
9
+ BlockContext,
10
+ useBlockContext
11
+ };
12
+ //# sourceMappingURL=chunk-JGMN6W72.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/blocks/block-context/block-context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\n/** Renderer-level concerns provided to descendants of any `Block`-rendering tree. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- placeholder to preserve API while the surface area is scoped down\nexport interface BlockContextValue {}\n\nexport const BlockContext = createContext<BlockContextValue | null>(null);\n\n/** Returns the ambient block-rendering context. Returns an empty object outside a `<BlockContext.Provider>`. */\nexport function useBlockContext(): BlockContextValue {\n return useContext(BlockContext) ?? {};\n}\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkB;AAMnC,IAAM,eAAe,cAAwC,IAAI;AAGjE,SAAS,kBAAqC;AACnD,SAAO,WAAW,YAAY,KAAK,CAAC;AACtC;","names":[]}
@@ -55,21 +55,27 @@ function parseMarkdownTable(markdown, tableIndex = 0) {
55
55
  return null;
56
56
  }
57
57
 
58
- // src/utils/convert-table-to-csv.ts
59
- function escapeField(field) {
60
- if (field.includes(",") || field.includes('"') || field.includes("\n") || field.includes("\r")) {
61
- return `"${field.replace(/"/g, '""')}"`;
58
+ // src/utils/escape-csv-field.ts
59
+ var FORMULA_TRIGGERS = /* @__PURE__ */ new Set(["=", "+", "@", " ", "\r"]);
60
+ function escapeCsvField(field) {
61
+ const needsNeutralise = field.length > 0 && FORMULA_TRIGGERS.has(field[0]);
62
+ const safeField = needsNeutralise ? ` ${field}` : field;
63
+ if (needsNeutralise || safeField.includes(",") || safeField.includes('"') || safeField.includes("\n") || safeField.includes("\r")) {
64
+ return `"${safeField.replace(/"/g, '""')}"`;
62
65
  }
63
- return field;
66
+ return safeField;
64
67
  }
68
+
69
+ // src/utils/convert-table-to-csv.ts
65
70
  function convertTableToCSV(table) {
66
- const headerRow = table.columns.map(escapeField).join(",");
67
- const dataRows = table.rows.map((row) => row.map(escapeField).join(","));
71
+ const headerRow = table.columns.map(escapeCsvField).join(",");
72
+ const dataRows = table.rows.map((row) => row.map(escapeCsvField).join(","));
68
73
  return [headerRow, ...dataRows].join("\r\n");
69
74
  }
70
75
 
71
76
  export {
72
77
  parseMarkdownTable,
78
+ escapeCsvField,
73
79
  convertTableToCSV
74
80
  };
75
- //# sourceMappingURL=chunk-27GJUWVN.js.map
81
+ //# sourceMappingURL=chunk-JJUIBBBU.js.map