@tomny-dev/uzi 0.14.0 → 0.15.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 (130) hide show
  1. package/dist/components/filter-workspace/FilterWorkspace.d.ts +40 -0
  2. package/dist/components/filter-workspace/FilterWorkspace.d.ts.map +1 -0
  3. package/dist/components/filter-workspace/FilterWorkspace.test.d.ts +2 -0
  4. package/dist/components/filter-workspace/FilterWorkspace.test.d.ts.map +1 -0
  5. package/dist/index.cjs +18 -14
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +16 -15
  9. package/dist/index57.js +21 -10
  10. package/dist/index57.js.map +1 -1
  11. package/dist/index58.cjs +30 -11
  12. package/dist/index58.cjs.map +1 -1
  13. package/dist/index58.js +101 -14
  14. package/dist/index58.js.map +1 -1
  15. package/dist/index59.cjs +104 -13
  16. package/dist/index59.cjs.map +1 -1
  17. package/dist/index59.js +10 -11
  18. package/dist/index59.js.map +1 -1
  19. package/dist/index60.cjs +11 -13
  20. package/dist/index60.cjs.map +1 -1
  21. package/dist/index60.js +13 -16
  22. package/dist/index60.js.map +1 -1
  23. package/dist/index61.cjs +13 -16
  24. package/dist/index61.cjs.map +1 -1
  25. package/dist/index61.js +10 -8
  26. package/dist/index61.js.map +1 -1
  27. package/dist/index62.cjs +11 -10
  28. package/dist/index62.cjs.map +1 -1
  29. package/dist/index62.js +15 -87
  30. package/dist/index62.js.map +1 -1
  31. package/dist/index63.cjs +15 -89
  32. package/dist/index63.cjs.map +1 -1
  33. package/dist/index63.js +9 -23
  34. package/dist/index63.js.map +1 -1
  35. package/dist/index64.cjs +12 -33
  36. package/dist/index64.cjs.map +1 -1
  37. package/dist/index64.js +89 -43
  38. package/dist/index64.js.map +1 -1
  39. package/dist/index65.cjs +88 -42
  40. package/dist/index65.cjs.map +1 -1
  41. package/dist/index65.js +23 -15
  42. package/dist/index65.js.map +1 -1
  43. package/dist/index66.cjs +33 -21
  44. package/dist/index66.cjs.map +1 -1
  45. package/dist/index66.js +44 -51
  46. package/dist/index66.js.map +1 -1
  47. package/dist/index67.cjs +43 -52
  48. package/dist/index67.cjs.map +1 -1
  49. package/dist/index67.js +14 -14
  50. package/dist/index67.js.map +1 -1
  51. package/dist/index68.cjs +19 -19
  52. package/dist/index68.cjs.map +1 -1
  53. package/dist/index68.js +49 -290
  54. package/dist/index68.js.map +1 -1
  55. package/dist/index69.cjs +51 -290
  56. package/dist/index69.cjs.map +1 -1
  57. package/dist/index69.js +15 -57
  58. package/dist/index69.js.map +1 -1
  59. package/dist/index70.cjs +20 -83
  60. package/dist/index70.cjs.map +1 -1
  61. package/dist/index70.js +276 -418
  62. package/dist/index70.js.map +1 -1
  63. package/dist/index71.cjs +275 -419
  64. package/dist/index71.cjs.map +1 -1
  65. package/dist/index71.js +56 -58
  66. package/dist/index71.js.map +1 -1
  67. package/dist/index72.cjs +82 -85
  68. package/dist/index72.cjs.map +1 -1
  69. package/dist/index72.js +420 -226
  70. package/dist/index72.js.map +1 -1
  71. package/dist/index73.cjs +421 -225
  72. package/dist/index73.cjs.map +1 -1
  73. package/dist/index73.js +58 -42
  74. package/dist/index73.js.map +1 -1
  75. package/dist/index74.cjs +85 -61
  76. package/dist/index74.cjs.map +1 -1
  77. package/dist/index74.js +236 -76
  78. package/dist/index74.js.map +1 -1
  79. package/dist/index75.cjs +235 -75
  80. package/dist/index75.cjs.map +1 -1
  81. package/dist/index75.js +42 -20
  82. package/dist/index75.js.map +1 -1
  83. package/dist/index76.cjs +60 -27
  84. package/dist/index76.cjs.map +1 -1
  85. package/dist/index76.js +73 -88
  86. package/dist/index76.js.map +1 -1
  87. package/dist/index77.cjs +73 -90
  88. package/dist/index77.cjs.map +1 -1
  89. package/dist/index77.js +17 -15
  90. package/dist/index77.js.map +1 -1
  91. package/dist/index78.cjs +22 -19
  92. package/dist/index78.cjs.map +1 -1
  93. package/dist/index78.js +85 -143
  94. package/dist/index78.js.map +1 -1
  95. package/dist/index79.cjs +87 -143
  96. package/dist/index79.cjs.map +1 -1
  97. package/dist/index79.js +19 -91
  98. package/dist/index79.js.map +1 -1
  99. package/dist/index80.cjs +27 -135
  100. package/dist/index80.cjs.map +1 -1
  101. package/dist/index80.js +140 -673
  102. package/dist/index80.js.map +1 -1
  103. package/dist/index81.cjs +140 -673
  104. package/dist/index81.cjs.map +1 -1
  105. package/dist/index81.js +91 -31
  106. package/dist/index81.js.map +1 -1
  107. package/dist/index82.cjs +135 -45
  108. package/dist/index82.cjs.map +1 -1
  109. package/dist/index82.js +667 -206
  110. package/dist/index82.js.map +1 -1
  111. package/dist/index83.cjs +667 -204
  112. package/dist/index83.cjs.map +1 -1
  113. package/dist/index83.js +31 -15
  114. package/dist/index83.js.map +1 -1
  115. package/dist/index84.cjs +45 -21
  116. package/dist/index84.cjs.map +1 -1
  117. package/dist/index84.js +224 -29
  118. package/dist/index84.js.map +1 -1
  119. package/dist/index85.cjs +224 -30
  120. package/dist/index85.cjs.map +1 -1
  121. package/dist/index85.js +19 -0
  122. package/dist/index85.js.map +1 -0
  123. package/dist/index86.cjs +25 -0
  124. package/dist/index86.cjs.map +1 -0
  125. package/dist/index86.js +36 -0
  126. package/dist/index86.js.map +1 -0
  127. package/dist/index87.cjs +37 -0
  128. package/dist/index87.cjs.map +1 -0
  129. package/dist/style.css +53 -0
  130. package/package.json +1 -1
package/dist/index81.cjs CHANGED
@@ -1,694 +1,161 @@
1
- "use client";
2
- const require_ai_chat_module = require("./index80.cjs");
1
+ const require_runtime = require("./index2.cjs");
2
+ const require_cx = require("./index4.cjs");
3
+ const require_empty_state_page_module = require("./index80.cjs");
3
4
  let react = require("react");
5
+ react = require_runtime.__toESM(react, 1);
4
6
  let react_jsx_runtime = require("react/jsx-runtime");
5
- let _assistant_ui_react = require("@assistant-ui/react");
6
- let _assistant_ui_ai_sdk = require("@assistant-ui/ai-sdk");
7
- //#region src/components/ai-chat/AIChat.tsx
8
- function isRecord(value) {
9
- return typeof value === "object" && value !== null && !Array.isArray(value);
10
- }
11
- function asString(value) {
12
- return typeof value === "string" ? value : void 0;
13
- }
14
- function safeHttpUrl(value) {
15
- const url = asString(value);
16
- return url && /^https?:\/\//i.test(url) ? url : void 0;
17
- }
18
- function AIChatMessageBubble({ role, label, children, className }) {
19
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
20
- className: [
21
- require_ai_chat_module.default.messageBubble,
22
- role === "user" ? require_ai_chat_module.default.userMessage : require_ai_chat_module.default.assistantMessage,
23
- className
24
- ].filter(Boolean).join(" "),
25
- "data-role": role,
26
- children: [label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
27
- className: require_ai_chat_module.default.messageLabel,
28
- children: label
29
- }), children]
30
- });
31
- }
32
- function DefaultMessageRenderer({ message, renderMessagePart }) {
33
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AIChatMessageBubble, {
34
- role: message.role,
35
- children: message.parts.map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: isRecord(part) ? renderMessagePart(part, index) : null }, isRecord(part) && typeof part.id === "string" ? part.id : index))
36
- });
37
- }
38
- function DefaultReasoningRenderer({ children, title = "Reasoning" }) {
39
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
40
- className: require_ai_chat_module.default.reasoning,
41
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", {
42
- className: require_ai_chat_module.default.reasoningSummary,
43
- children: title
44
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
45
- className: require_ai_chat_module.default.reasoningText,
46
- children
47
- })]
48
- });
49
- }
50
- function DefaultSourceRenderer({ sources, renderSource }) {
51
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
52
- className: require_ai_chat_module.default.sources,
53
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
54
- className: require_ai_chat_module.default.sourcesLabel,
55
- children: "Sources"
56
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: sources.map((source, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: renderSource(source, index) }, source.id)) })]
57
- });
58
- }
59
- function DefaultDataRenderer({ data, renderDataItem }) {
60
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
61
- className: require_ai_chat_module.default.data,
62
- children: data.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: renderDataItem(item, index) }, index))
7
+ //#region src/components/empty-state-page/EmptyStatePage.tsx
8
+ /** Inline SVG icon for the "no data" variant */
9
+ function NoDataIcon() {
10
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
11
+ viewBox: "0 0 48 48",
12
+ fill: "none",
13
+ className: require_empty_state_page_module.default.iconSvg,
14
+ "aria-hidden": "true",
15
+ children: [
16
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
17
+ x: "8",
18
+ y: "10",
19
+ width: "32",
20
+ height: "28",
21
+ rx: "4",
22
+ stroke: "currentColor",
23
+ strokeWidth: "2"
24
+ }),
25
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
26
+ x1: "8",
27
+ y1: "18",
28
+ x2: "40",
29
+ y2: "18",
30
+ stroke: "currentColor",
31
+ strokeWidth: "2"
32
+ }),
33
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
34
+ x1: "16",
35
+ y1: "24",
36
+ x2: "28",
37
+ y2: "24",
38
+ stroke: "currentColor",
39
+ strokeWidth: "2",
40
+ strokeLinecap: "round"
41
+ }),
42
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
43
+ x1: "16",
44
+ y1: "30",
45
+ x2: "32",
46
+ y2: "30",
47
+ stroke: "currentColor",
48
+ strokeWidth: "2",
49
+ strokeLinecap: "round"
50
+ })
51
+ ]
63
52
  });
64
53
  }
65
- function DefaultErrorRenderer({ error, onRetry, onClear }) {
66
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
67
- className: require_ai_chat_module.default.error,
68
- role: "alert",
69
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: error.message }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
70
- className: require_ai_chat_module.default.errorActions,
71
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
72
- type: "button",
73
- onClick: onRetry,
74
- children: "Retry response"
75
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
76
- type: "button",
77
- onClick: onClear,
78
- children: "Start new chat"
79
- })]
54
+ /** Inline SVG icon for the "no connection" variant */
55
+ function NoConnectionIcon() {
56
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
57
+ viewBox: "0 0 48 48",
58
+ fill: "none",
59
+ className: require_empty_state_page_module.default.iconSvg,
60
+ "aria-hidden": "true",
61
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
62
+ cx: "24",
63
+ cy: "24",
64
+ r: "14",
65
+ stroke: "currentColor",
66
+ strokeWidth: "2"
67
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
68
+ d: "M18 18l12 12M30 18L18 30",
69
+ stroke: "currentColor",
70
+ strokeWidth: "2",
71
+ strokeLinecap: "round"
80
72
  })]
81
73
  });
82
74
  }
83
- function renderPart(part, index, components, onToolApproval, pendingApprovalId) {
84
- const type = asString(part.type) ?? "";
85
- if (type === "step-start") return null;
86
- if (type === "text") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
87
- className: require_ai_chat_module.default.textPart,
88
- children: asString(part.text) ?? ""
89
- });
90
- if (type === "reasoning") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(components?.ReasoningRenderer ?? DefaultReasoningRenderer, { children: asString(part.text) ?? "" });
91
- if (type === "source-url" || type === "source-document") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(components?.SourceRenderer ?? DefaultSourceRenderer, {
92
- sources: [{
93
- id: asString(part.sourceId) ?? asString(part.id) ?? `source-${index}`,
94
- title: asString(part.title) ?? asString(part.filename),
95
- url: safeHttpUrl(part.url)
96
- }],
97
- renderSource: (item) => item.url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
98
- href: item.url,
99
- target: "_blank",
100
- rel: "noopener noreferrer",
101
- children: item.title ?? item.url
102
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.title ?? item.id })
103
- });
104
- if (type.startsWith("data-")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(components?.DataRenderer ?? DefaultDataRenderer, {
105
- data: [part],
106
- renderDataItem: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
107
- className: require_ai_chat_module.default.structuredData,
108
- children: JSON.stringify(item.data ?? item, null, 2)
109
- })
110
- });
111
- if (type.startsWith("tool-") || type === "dynamic-tool") {
112
- const name = asString(part.toolName) ?? type.replace(/^tool-/, "");
113
- const approval = isRecord(part.approval) ? asString(part.approval.id) : void 0;
114
- const approvalId = part.state === "approval-requested" ? approval : void 0;
115
- const controlsDisabled = pendingApprovalId !== null && pendingApprovalId !== void 0;
116
- const ToolRenderer = components?.ToolRenderer;
117
- const props = {
118
- part,
119
- name,
120
- approvalId,
121
- approvalPending: controlsDisabled,
122
- ...approvalId && onToolApproval ? {
123
- onApprove: () => {
124
- if (!controlsDisabled) onToolApproval(approvalId, true);
125
- },
126
- onDeny: () => {
127
- if (!controlsDisabled) onToolApproval(approvalId, false);
128
- }
129
- } : {}
130
- };
131
- if (ToolRenderer) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolRenderer, { ...props });
132
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
133
- className: require_ai_chat_module.default.toolPart,
134
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: name }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
135
- className: require_ai_chat_module.default.structuredData,
136
- children: JSON.stringify(part.output ?? part.input ?? part, null, 2)
137
- })] }), approvalId && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
138
- className: require_ai_chat_module.default.approvalActions,
139
- "aria-label": `Approval required for ${name}`,
140
- children: props.onApprove && props.onDeny ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
141
- type: "button",
142
- disabled: controlsDisabled,
143
- onClick: props.onApprove,
144
- children: "Approve"
145
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
146
- type: "button",
147
- disabled: controlsDisabled,
148
- onClick: props.onDeny,
149
- children: "Deny"
150
- })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Approval required in application" })
151
- })]
152
- });
153
- }
154
- if (type === "file" || type === "image") {
155
- const url = safeHttpUrl(part.url);
156
- return url ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
157
- href: url,
158
- target: "_blank",
159
- rel: "noopener noreferrer",
160
- children: asString(part.filename) ?? "View attachment"
161
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Attachment" });
162
- }
163
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
164
- className: require_ai_chat_module.default.structuredData,
165
- children: JSON.stringify(part, null, 2)
166
- });
167
- }
168
- var DEFAULT_MESSAGE_LIMIT = 8;
169
- function AIChat({ api, scope, scopeLabel, fetch: requestFetch, headers, credentials, prepareSendMessagesRequest, sessionKey, messageLimit = DEFAULT_MESSAGE_LIMIT, inputPlaceholder = "Ask a question...", inputAriaLabel = "Message", inputMaxLength = 2e3, components, toolbarActions, attachments, history, sendAutomaticallyWhen, onClose, className, style }) {
170
- const [session, setSession] = (0, react.useState)(0);
171
- const transport = (0, react.useMemo)(() => new _assistant_ui_ai_sdk.AssistantChatTransport({
172
- api,
173
- ...scope ? { body: { scope } } : {},
174
- ...requestFetch ? { fetch: requestFetch } : {},
175
- ...headers ? { headers } : {},
176
- ...credentials ? { credentials } : {},
177
- ...prepareSendMessagesRequest ? { prepareSendMessagesRequest } : {}
178
- }), [
179
- api,
180
- scope,
181
- requestFetch,
182
- headers,
183
- credentials,
184
- prepareSendMessagesRequest
185
- ]);
186
- const config = (0, react.useMemo)(() => (0, _assistant_ui_react.AuiConfig)({ threads: (0, _assistant_ui_ai_sdk.AISDKChat)({
187
- transport,
188
- ...sendAutomaticallyWhen ? { sendAutomaticallyWhen } : {}
189
- }) }), [
190
- transport,
191
- session,
192
- sendAutomaticallyWhen
193
- ]);
194
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
195
- className: [require_ai_chat_module.default.container, className].filter(Boolean).join(" "),
196
- style,
75
+ /** Inline SVG icon for the "no permissions" variant */
76
+ function NoPermissionsIcon() {
77
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
78
+ viewBox: "0 0 48 48",
79
+ fill: "none",
80
+ className: require_empty_state_page_module.default.iconSvg,
81
+ "aria-hidden": "true",
197
82
  children: [
198
- scopeLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
199
- className: require_ai_chat_module.default.scope,
200
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
201
- className: require_ai_chat_module.default.scopeLabel,
202
- children: "Current scope"
203
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: scopeLabel })]
83
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
84
+ x: "12",
85
+ y: "20",
86
+ width: "24",
87
+ height: "18",
88
+ rx: "3",
89
+ stroke: "currentColor",
90
+ strokeWidth: "2"
204
91
  }),
205
- onClose && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
206
- className: require_ai_chat_module.default.closeBtn,
207
- type: "button",
208
- onClick: onClose,
209
- "aria-label": "Close chat",
210
- children: "✕"
92
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
93
+ d: "M20 20v-6a4 4 0 018 0v6",
94
+ stroke: "currentColor",
95
+ strokeWidth: "2"
211
96
  }),
212
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_assistant_ui_react.AuiProvider, {
213
- config,
214
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_assistant_ui_react.ThreadPrimitive.Root, {
215
- className: require_ai_chat_module.default.thread,
216
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChatViewport, {
217
- messageLimit: Number.isFinite(messageLimit) ? Math.max(1, Math.floor(messageLimit)) : DEFAULT_MESSAGE_LIMIT,
218
- inputPlaceholder,
219
- inputAriaLabel,
220
- inputMaxLength,
221
- components,
222
- toolbarActions,
223
- attachmentOptions: attachments,
224
- history,
225
- onNewChat: () => setSession((previous) => previous + 1)
226
- })
227
- })
228
- }, JSON.stringify([
229
- api,
230
- scope,
231
- sessionKey,
232
- session
233
- ]))
97
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
98
+ cx: "24",
99
+ cy: "30",
100
+ r: "2",
101
+ fill: "currentColor"
102
+ })
234
103
  ]
235
104
  });
236
105
  }
237
- function ChatViewport({ messageLimit, inputPlaceholder, inputAriaLabel, inputMaxLength, components, toolbarActions, attachmentOptions, history, onNewChat }) {
238
- const chat = (0, _assistant_ui_ai_sdk.useAISDKChat)();
239
- const [draft, setDraft] = (0, react.useState)("");
240
- const [selectedFiles, setSelectedFiles] = (0, react.useState)([]);
241
- const [attachmentError, setAttachmentError] = (0, react.useState)(null);
242
- const [attachmentPreviews, setAttachmentPreviews] = (0, react.useState)([]);
243
- const [hydrated, setHydrated] = (0, react.useState)(!history);
244
- const expectedRestoredId = (0, react.useRef)(null);
245
- const saveQueue = (0, react.useRef)(Promise.resolve());
246
- const [approvalBusy, setApprovalBusy] = (0, react.useState)(false);
247
- (0, react.useEffect)(() => {
248
- const urls = selectedFiles.map((file) => file.type.startsWith("image/") && typeof URL.createObjectURL === "function" ? URL.createObjectURL(file) : "");
249
- setAttachmentPreviews(urls);
250
- return () => urls.forEach((url) => {
251
- if (url && typeof URL.revokeObjectURL === "function") URL.revokeObjectURL(url);
252
- });
253
- }, [selectedFiles]);
254
- const messages = chat?.messages ?? [];
255
- const status = chat?.status ?? "ready";
256
- const isBusy = status === "submitted" || status === "streaming";
257
- const historyFull = messages.filter((message) => message.role === "user").length >= messageLimit;
258
- const reportHistoryError = (operation, error) => {
259
- if (history?.onError) history.onError(operation, error);
260
- else console.warn(`[Uzi AIChat] History ${operation} failed`);
261
- };
262
- (0, react.useEffect)(() => {
263
- if (!history) return;
264
- let active = true;
265
- Promise.resolve().then(() => history.load()).then((restored) => {
266
- if (!active) return;
267
- if (Array.isArray(restored)) {
268
- const valid = restored.filter((message) => typeof message?.id === "string" && (message.role === "user" || message.role === "assistant") && Array.isArray(message.parts));
269
- expectedRestoredId.current = valid.length ? valid[0].id : null;
270
- if (valid.length) chat?.setMessages(valid);
271
- }
272
- setHydrated(true);
273
- }).catch((error) => {
274
- if (active) {
275
- reportHistoryError("load", error);
276
- setHydrated(true);
277
- }
278
- });
279
- return () => {
280
- active = false;
281
- };
282
- }, [chat?.setMessages, history]);
283
- (0, react.useEffect)(() => {
284
- if (!history || !hydrated || isBusy) return;
285
- const snapshot = messages.filter((message) => message.role === "user" || message.role === "assistant").map((message) => ({
286
- id: message.id,
287
- role: message.role,
288
- parts: message.parts,
289
- ...isRecord(message.metadata) ? { metadata: message.metadata } : {}
290
- }));
291
- if (expectedRestoredId.current) {
292
- if (!snapshot.some((message) => message.id === expectedRestoredId.current)) return;
293
- expectedRestoredId.current = null;
294
- }
295
- saveQueue.current = saveQueue.current.then(() => history.save(snapshot), () => history.save(snapshot)).then(() => {}, (error) => {
296
- reportHistoryError("save", error);
297
- });
298
- }, [
299
- history,
300
- hydrated,
301
- isBusy,
302
- messages
303
- ]);
304
- const handleSelectedFiles = (files) => {
305
- if (!attachmentOptions) return;
306
- const selected = Array.from(files);
307
- if (selected.length + selectedFiles.length > (attachmentOptions.maxFiles ?? 3)) {
308
- setAttachmentError("Too many attachments.");
309
- return;
310
- }
311
- if (selected.some((file) => file.size > (attachmentOptions.maxBytesPerFile ?? 5 * 1024 * 1024))) {
312
- setAttachmentError("An attachment exceeds the size limit.");
313
- return;
314
- }
315
- const allowedTypes = attachmentOptions.accept.split(",").map((item) => item.trim());
316
- if (selected.some((file) => !allowedTypes.some((allow) => allow === file.type || allow.endsWith("/*") && file.type.startsWith(allow.slice(0, -1))))) {
317
- setAttachmentError("Unsupported attachment type.");
318
- return;
319
- }
320
- setAttachmentError(null);
321
- setSelectedFiles((existing) => [...existing, ...selected]);
322
- };
323
- const handleSubmit = () => {
324
- const text = draft.trim();
325
- if (!chat || !text && selectedFiles.length === 0 || isBusy || historyFull || chat.error || !hydrated || approvalBusy) return;
326
- const files = selectedFiles.length ? new DataTransfer() : null;
327
- selectedFiles.forEach((file) => files?.items.add(file));
328
- const previousDraft = draft;
329
- const previousFiles = selectedFiles;
330
- setDraft("");
331
- setSelectedFiles([]);
332
- setAttachmentError(null);
333
- Promise.resolve(chat.sendMessage({
334
- text,
335
- ...files ? { files: files.files } : {}
336
- })).catch(() => {
337
- setDraft((current) => current || previousDraft);
338
- setSelectedFiles((current) => current.length ? current : previousFiles);
339
- });
340
- };
341
- const handleNewChat = () => {
342
- (async () => {
343
- await chat?.stop();
344
- if (history) try {
345
- await saveQueue.current;
346
- await history.clear();
347
- } catch (error) {
348
- reportHistoryError("clear", error);
349
- return;
350
- }
351
- onNewChat();
352
- })();
353
- };
354
- const handleRetry = () => {
355
- if (!chat || isBusy) return;
356
- chat.clearError();
357
- chat.regenerate();
358
- };
359
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AIChatView, {
360
- messages: messages.filter((message) => message.role === "user" || message.role === "assistant").map((message) => ({
361
- id: message.id,
362
- role: message.role,
363
- parts: message.parts,
364
- ...isRecord(message.metadata) ? { metadata: message.metadata } : {}
365
- })),
366
- status,
367
- error: chat?.error,
368
- draft,
369
- onDraftChange: setDraft,
370
- onSend: handleSubmit,
371
- onStop: () => {
372
- chat?.stop();
373
- },
374
- onRetry: handleRetry,
375
- onNewChat: handleNewChat,
376
- toolbarActions,
377
- messageLimit,
378
- attachments: selectedFiles.map((file, index) => ({
379
- name: file.name,
380
- size: file.size,
381
- ...attachmentPreviews[index] ? { previewUrl: attachmentPreviews[index] } : {}
382
- })),
383
- onSelectAttachments: attachmentOptions ? handleSelectedFiles : void 0,
384
- onRemoveAttachment: attachmentOptions ? (index) => setSelectedFiles((files) => files.filter((_, i) => i !== index)) : void 0,
385
- attachmentAccept: attachmentOptions?.accept,
386
- attachmentError,
387
- onToolApproval: chat ? async (id, approved) => {
388
- if (approvalBusy) return;
389
- setApprovalBusy(true);
390
- try {
391
- await chat.addToolApprovalResponse({
392
- id,
393
- approved,
394
- ...!approved ? { reason: "User denied approval" } : {}
395
- });
396
- } finally {
397
- setApprovalBusy(false);
398
- }
399
- } : void 0,
400
- inputPlaceholder,
401
- inputAriaLabel,
402
- inputMaxLength,
403
- components
404
- });
405
- }
106
+ var variantMap = {
107
+ noData: {
108
+ icon: NoDataIcon,
109
+ title: "No data yet",
110
+ description: "When you add data, it will appear here."
111
+ },
112
+ noConnection: {
113
+ icon: NoConnectionIcon,
114
+ title: "No connection",
115
+ description: "Check your network settings and try again."
116
+ },
117
+ noPermissions: {
118
+ icon: NoPermissionsIcon,
119
+ title: "Access denied",
120
+ description: "You don't have permission to view this content."
121
+ }
122
+ };
406
123
  /**
407
- * Controlled chat presentation for apps with their own AI SDK/assistant-ui
408
- * runtime. It does not create providers, transports or chat state. Callbacks
409
- * are the only way messages/actions leave the view.
124
+ * EmptyStatePage — a Card-based page template with variant icons, title, description, and actions.
125
+ *
126
+ * Layout:
127
+ * Card → Icon → Title → Description → Actions
410
128
  */
411
- function AIChatView({ messages, status = "ready", error, draft = "", onDraftChange, onSend, onStop, onRetry, onNewChat, messageLimit, inputPlaceholder = "Ask a question...", inputAriaLabel = "Message", inputMaxLength = 2e3, components, attachments, onSelectAttachments, onRemoveAttachment, attachmentAccept, attachmentError, onToolApproval, toolbarActions, header, composerLeading, composerTrailing, composer, emptyState, className, style }) {
412
- const viewportRef = (0, react.useRef)(null);
413
- const pinnedToBottom = (0, react.useRef)(true);
414
- const fileInputRef = (0, react.useRef)(null);
415
- const approvalRef = (0, react.useRef)(null);
416
- const [pendingApprovalId, setPendingApprovalId] = (0, react.useState)(null);
417
- const [approvalError, setApprovalError] = (0, react.useState)(null);
418
- const respondToApproval = async (id, approved) => {
419
- if (!onToolApproval || approvalRef.current) return;
420
- approvalRef.current = id;
421
- setPendingApprovalId(id);
422
- setApprovalError(null);
423
- try {
424
- await onToolApproval(id, approved);
425
- } catch {
426
- setApprovalError("Could not submit approval. Please try again.");
427
- } finally {
428
- approvalRef.current = null;
429
- setPendingApprovalId(null);
430
- }
431
- };
432
- const isBusy = status === "submitted" || status === "streaming";
433
- const limit = messageLimit != null && Number.isFinite(messageLimit) ? Math.max(1, Math.floor(messageLimit)) : null;
434
- const historyFull = limit !== null && messages.filter((message) => message.role === "user").length >= limit;
435
- const MessageRenderer = components?.MessageRenderer ?? DefaultMessageRenderer;
436
- const ErrorRenderer = components?.ErrorRenderer ?? DefaultErrorRenderer;
437
- (0, react.useEffect)(() => {
438
- const viewport = viewportRef.current;
439
- if (viewport && pinnedToBottom.current) viewport.scrollTop = viewport.scrollHeight;
440
- });
441
- const handleKeyDown = (event) => {
442
- if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
443
- event.preventDefault();
444
- if (!isBusy && !historyFull && !error && (draft.trim() || (attachments?.length ?? 0) > 0)) onSend?.();
445
- }
446
- };
447
- const handleFormSubmit = (event) => {
448
- event.preventDefault();
449
- if (!isBusy && !historyFull && !error && (draft.trim() || (attachments?.length ?? 0) > 0)) onSend?.();
450
- };
451
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
452
- className: [require_ai_chat_module.default.thread, className].filter(Boolean).join(" "),
453
- style,
454
- children: [
455
- header,
456
- (messages.length > 0 || toolbarActions) && (onNewChat || toolbarActions) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
457
- className: require_ai_chat_module.default.chatToolbar,
458
- role: "toolbar",
459
- "aria-label": "Conversation actions",
460
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
461
- className: require_ai_chat_module.default.chatToolbarExtras,
462
- children: toolbarActions
463
- }), onNewChat && messages.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
464
- type: "button",
465
- className: require_ai_chat_module.default.newChatButton,
466
- onClick: onNewChat,
467
- "aria-label": "New chat",
468
- title: "New chat",
469
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
470
- "aria-hidden": "true",
471
- width: "18",
472
- height: "18",
473
- viewBox: "0 0 24 24",
474
- fill: "none",
475
- stroke: "currentColor",
476
- strokeWidth: "1.8",
477
- strokeLinecap: "round",
478
- strokeLinejoin: "round",
479
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 5H6a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-6" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
480
- d: "m15 5 4 4M13 11l7-7a2.12 2.12 0 0 1 3 3l-7 7-4 1 1-4Z",
481
- transform: "translate(-2 -2)"
482
- })]
483
- })
484
- })]
485
- }),
486
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
487
- ref: viewportRef,
488
- className: require_ai_chat_module.default.viewport,
489
- onScroll: (event) => {
490
- const viewport = event.currentTarget;
491
- pinnedToBottom.current = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight < 80;
492
- },
493
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
494
- className: require_ai_chat_module.default.messageList,
495
- role: "log",
496
- "aria-label": "Chat history",
497
- "aria-live": "polite",
498
- children: [
499
- messages.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
500
- className: require_ai_chat_module.default.emptyState,
501
- children: emptyState ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "Start a conversation" })
502
- }),
503
- messages.map((message) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MessageRenderer, {
504
- message,
505
- renderMessagePart: (part, index) => renderPart(part, index, components, onToolApproval ? respondToApproval : void 0, pendingApprovalId),
506
- onToolApproval: onToolApproval ? respondToApproval : void 0
507
- }, message.id)),
508
- isBusy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
509
- className: require_ai_chat_module.default.status,
510
- children: "Thinking..."
511
- })
512
- ]
129
+ function EmptyStatePage({ variant = "noData", title, description, primaryAction, secondaryAction, icon, className }) {
130
+ const { icon: VariantIcon, title: defaultTitle, description: defaultDescription } = variantMap[variant];
131
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
132
+ className: require_cx.cx(require_empty_state_page_module.default.wrapper, className),
133
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
134
+ className: require_empty_state_page_module.default.card,
135
+ children: [
136
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
137
+ className: require_empty_state_page_module.default.iconArea,
138
+ children: icon ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VariantIcon, {})
139
+ }),
140
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
141
+ className: require_empty_state_page_module.default.content,
142
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
143
+ className: require_empty_state_page_module.default.title,
144
+ children: title ?? defaultTitle
145
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
146
+ className: require_empty_state_page_module.default.description,
147
+ children: description ?? defaultDescription
148
+ })]
149
+ }),
150
+ (primaryAction || secondaryAction) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
151
+ className: require_empty_state_page_module.default.actions,
152
+ children: [primaryAction, secondaryAction]
513
153
  })
514
- }),
515
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
516
- className: require_ai_chat_module.default.footer,
517
- children: [
518
- approvalError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
519
- role: "alert",
520
- className: require_ai_chat_module.default.attachmentError,
521
- children: approvalError
522
- }),
523
- attachmentError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
524
- role: "alert",
525
- className: require_ai_chat_module.default.attachmentError,
526
- children: attachmentError
527
- }),
528
- error && (onRetry && onNewChat ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorRenderer, {
529
- error,
530
- onRetry,
531
- onClear: onNewChat
532
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
533
- className: require_ai_chat_module.default.error,
534
- role: "alert",
535
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: error.message }), (onRetry || onNewChat) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
536
- className: require_ai_chat_module.default.errorActions,
537
- children: [onRetry && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
538
- type: "button",
539
- onClick: onRetry,
540
- children: "Retry response"
541
- }), onNewChat && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
542
- type: "button",
543
- onClick: onNewChat,
544
- children: "Start new chat"
545
- })]
546
- })]
547
- })),
548
- historyFull && !error && !isBusy && onNewChat && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
549
- className: require_ai_chat_module.default.historyLimit,
550
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
551
- "This chat has reached its ",
552
- limit,
553
- "-question limit."
554
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
555
- type: "button",
556
- onClick: onNewChat,
557
- children: "Start new chat"
558
- })]
559
- }),
560
- (!historyFull || isBusy) && !error && (composer !== void 0 ? composer : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
561
- className: require_ai_chat_module.default.composerForm,
562
- onSubmit: handleFormSubmit,
563
- children: [
564
- composerLeading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
565
- className: require_ai_chat_module.default.composerExtras,
566
- children: composerLeading
567
- }),
568
- onSelectAttachments && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
569
- className: require_ai_chat_module.default.composerExtras,
570
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
571
- ref: fileInputRef,
572
- className: require_ai_chat_module.default.visuallyHidden,
573
- type: "file",
574
- "aria-label": "Add attachments",
575
- accept: attachmentAccept,
576
- multiple: true,
577
- disabled: isBusy,
578
- onChange: (event) => {
579
- if (event.target.files) onSelectAttachments(event.target.files);
580
- event.target.value = "";
581
- }
582
- }), attachments && attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
583
- className: require_ai_chat_module.default.attachmentList,
584
- children: attachments.map((attachment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { children: [attachment.previewUrl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
585
- className: require_ai_chat_module.default.attachmentThumbnail,
586
- src: attachment.previewUrl,
587
- alt: attachment.name
588
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
589
- className: require_ai_chat_module.default.attachmentFilename,
590
- children: attachment.name
591
- }), onRemoveAttachment && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
592
- type: "button",
593
- onClick: () => onRemoveAttachment(index),
594
- "aria-label": `Remove ${attachment.name}`,
595
- title: `Remove ${attachment.name}`,
596
- children: "×"
597
- })] }, index))
598
- })]
599
- }),
600
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
601
- className: require_ai_chat_module.default.composerSurface,
602
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
603
- className: require_ai_chat_module.default.composerRow,
604
- children: [
605
- onSelectAttachments && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
606
- type: "button",
607
- className: require_ai_chat_module.default.composerIconButton,
608
- "aria-label": "Attach file",
609
- title: "Attach file",
610
- disabled: isBusy,
611
- onClick: () => fileInputRef.current?.click(),
612
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
613
- width: "20",
614
- height: "20",
615
- viewBox: "0 0 24 24",
616
- fill: "none",
617
- stroke: "currentColor",
618
- strokeWidth: "1.8",
619
- strokeLinecap: "round",
620
- strokeLinejoin: "round",
621
- "aria-hidden": "true",
622
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m21 11-8.5 8.5a6 6 0 0 1-8.5-8.5l9-9a4 4 0 0 1 5.7 5.7l-9 9a2 2 0 0 1-2.8-2.8l8.5-8.5" })
623
- })
624
- }),
625
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
626
- className: require_ai_chat_module.default.input,
627
- "aria-label": inputAriaLabel,
628
- rows: 1,
629
- value: draft,
630
- onChange: (event) => onDraftChange?.(event.target.value),
631
- onKeyDown: handleKeyDown,
632
- placeholder: inputPlaceholder,
633
- maxLength: inputMaxLength,
634
- disabled: isBusy || !onSend || !onDraftChange,
635
- readOnly: !onDraftChange
636
- }),
637
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
638
- className: require_ai_chat_module.default.composerActions,
639
- children: [composerTrailing, isBusy ? onStop && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
640
- type: "button",
641
- className: require_ai_chat_module.default.composerIconButton,
642
- onClick: onStop,
643
- "aria-label": "Stop response",
644
- title: "Stop response",
645
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
646
- width: "18",
647
- height: "18",
648
- viewBox: "0 0 24 24",
649
- fill: "currentColor",
650
- "aria-hidden": "true",
651
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
652
- x: "5",
653
- y: "5",
654
- width: "14",
655
- height: "14",
656
- rx: "2"
657
- })
658
- })
659
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
660
- type: "submit",
661
- className: require_ai_chat_module.default.sendButton,
662
- "aria-label": "Send message",
663
- title: "Send message",
664
- disabled: !onSend || !draft.trim() && !attachments?.length,
665
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
666
- width: "20",
667
- height: "20",
668
- viewBox: "0 0 24 24",
669
- fill: "none",
670
- stroke: "currentColor",
671
- strokeWidth: "2",
672
- strokeLinecap: "round",
673
- strokeLinejoin: "round",
674
- "aria-hidden": "true",
675
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 19V5m-7 7 7-7 7 7" })
676
- })
677
- })]
678
- })
679
- ]
680
- })
681
- })
682
- ]
683
- }))
684
- ]
685
- })
686
- ]
154
+ ]
155
+ })
687
156
  });
688
157
  }
689
158
  //#endregion
690
- exports.AIChat = AIChat;
691
- exports.AIChatMessageBubble = AIChatMessageBubble;
692
- exports.AIChatView = AIChatView;
159
+ exports.EmptyStatePage = EmptyStatePage;
693
160
 
694
161
  //# sourceMappingURL=index81.cjs.map