@leanmcp/ui 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,67 +1,93 @@
1
1
  'use strict';
2
2
 
3
- require('reflect-metadata');
4
- var React7 = require('react');
3
+ var chunk3PV26V5F_js = require('./chunk-3PV26V5F.js');
4
+ var React25 = require('react');
5
5
  var extApps = require('@modelcontextprotocol/ext-apps');
6
+ var lucideReact = require('lucide-react');
7
+ var nextThemes = require('next-themes');
8
+ var sonner = require('sonner');
6
9
  var reactSlot = require('@radix-ui/react-slot');
10
+ var classVarianceAuthority = require('class-variance-authority');
7
11
  var clsx = require('clsx');
12
+ var tailwindMerge = require('tailwind-merge');
13
+ var DialogPrimitive = require('@radix-ui/react-dialog');
14
+ var SelectPrimitive = require('@radix-ui/react-select');
15
+ var cmdk = require('cmdk');
16
+ var PopoverPrimitive = require('@radix-ui/react-popover');
17
+ var LabelPrimitive = require('@radix-ui/react-label');
18
+ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
19
+ var SliderPrimitive = require('@radix-ui/react-slider');
20
+ var SwitchPrimitive = require('@radix-ui/react-switch');
21
+ var ProgressPrimitive = require('@radix-ui/react-progress');
22
+ var reactHookForm = require('react-hook-form');
23
+ var TabsPrimitive2 = require('@radix-ui/react-tabs');
24
+ var SeparatorPrimitive = require('@radix-ui/react-separator');
25
+ var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
26
+ var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
27
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
8
28
  var reactTable = require('@tanstack/react-table');
9
29
  var chart_js = require('chart.js');
10
30
  var reactChartjs2 = require('react-chartjs-2');
11
31
  var prismReactRenderer = require('prism-react-renderer');
32
+ var appBridge = require('@modelcontextprotocol/ext-apps/app-bridge');
12
33
 
13
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
34
+ function _interopNamespace(e) {
35
+ if (e && e.__esModule) return e;
36
+ var n = Object.create(null);
37
+ if (e) {
38
+ Object.keys(e).forEach(function (k) {
39
+ if (k !== 'default') {
40
+ var d = Object.getOwnPropertyDescriptor(e, k);
41
+ Object.defineProperty(n, k, d.get ? d : {
42
+ enumerable: true,
43
+ get: function () { return e[k]; }
44
+ });
45
+ }
46
+ });
47
+ }
48
+ n.default = e;
49
+ return Object.freeze(n);
50
+ }
14
51
 
15
- var React7__default = /*#__PURE__*/_interopDefault(React7);
52
+ var React25__namespace = /*#__PURE__*/_interopNamespace(React25);
53
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
54
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
55
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
56
+ var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
57
+ var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
58
+ var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
59
+ var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
60
+ var ProgressPrimitive__namespace = /*#__PURE__*/_interopNamespace(ProgressPrimitive);
61
+ var TabsPrimitive2__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive2);
62
+ var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
63
+ var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
64
+ var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
65
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
16
66
 
17
- var __defProp = Object.defineProperty;
18
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
- var UI_APP_COMPONENT_KEY = "ui:app:component";
20
- var UI_APP_URI_KEY = "ui:app:uri";
21
- var UI_APP_OPTIONS_KEY = "ui:app:options";
22
- function UIApp(options) {
23
- return (target, propertyKey, descriptor) => {
24
- const methodName = String(propertyKey);
25
- const className = target.constructor.name.toLowerCase().replace("service", "");
26
- const uri = options.uri ?? `ui://${className}/${methodName}`;
27
- Reflect.defineMetadata(UI_APP_COMPONENT_KEY, options.component, descriptor.value);
28
- Reflect.defineMetadata(UI_APP_URI_KEY, uri, descriptor.value);
29
- Reflect.defineMetadata(UI_APP_OPTIONS_KEY, options, descriptor.value);
30
- const existingMeta = Reflect.getMetadata("tool:meta", descriptor.value) || {};
31
- Reflect.defineMetadata("tool:meta", {
32
- ...existingMeta,
33
- "ui/resourceUri": uri
34
- }, descriptor.value);
35
- return descriptor;
36
- };
37
- }
38
- __name(UIApp, "UIApp");
39
- function getUIAppMetadata(target) {
40
- const component = Reflect.getMetadata(UI_APP_COMPONENT_KEY, target);
41
- if (!component) return void 0;
42
- return {
43
- component,
44
- uri: Reflect.getMetadata(UI_APP_URI_KEY, target),
45
- ...Reflect.getMetadata(UI_APP_OPTIONS_KEY, target)
46
- };
47
- }
48
- __name(getUIAppMetadata, "getUIAppMetadata");
49
- function getUIAppUri(target) {
50
- return Reflect.getMetadata(UI_APP_URI_KEY, target);
51
- }
52
- __name(getUIAppUri, "getUIAppUri");
53
- var McpAppContext = /* @__PURE__ */ React7.createContext(null);
67
+ var McpAppContext = /* @__PURE__ */ React25.createContext(null);
54
68
  function AppProvider({ appInfo, capabilities = {}, options = {
55
69
  autoResize: true
56
- }, children }) {
57
- const [app, setApp] = React7.useState(null);
58
- const [isConnected, setIsConnected] = React7.useState(false);
59
- const [error, setError] = React7.useState(null);
60
- const [hostContext, setHostContext] = React7.useState({});
61
- const [toolInput, setToolInput] = React7.useState(null);
62
- const [toolInputPartial, setToolInputPartial] = React7.useState(null);
63
- const [toolResult, setToolResult] = React7.useState(null);
64
- React7.useEffect(() => {
70
+ }, onTeardown, children }) {
71
+ const [app, setApp] = React25.useState(null);
72
+ const [isConnected, setIsConnected] = React25.useState(false);
73
+ const [error, setError] = React25.useState(null);
74
+ const [hostContext, setHostContext] = React25.useState({});
75
+ const [toolInput, setToolInput] = React25.useState(null);
76
+ const [toolInputPartial, setToolInputPartial] = React25.useState(null);
77
+ const [toolResult, setToolResult] = React25.useState(null);
78
+ const [toolCancelled, setToolCancelled] = React25.useState({
79
+ cancelled: false
80
+ });
81
+ const stylesApplied = React25.useRef(false);
82
+ const applyHostStyles = React25.useCallback((context) => {
83
+ if (context.theme) {
84
+ extApps.applyDocumentTheme(context.theme);
85
+ }
86
+ if (context.styles?.variables) {
87
+ extApps.applyHostStyleVariables(context.styles.variables);
88
+ }
89
+ }, []);
90
+ React25.useEffect(() => {
65
91
  let mounted = true;
66
92
  let appInstance = null;
67
93
  async function connect() {
@@ -71,6 +97,9 @@ function AppProvider({ appInfo, capabilities = {}, options = {
71
97
  appInstance.ontoolinput = (params) => {
72
98
  if (mounted) {
73
99
  setToolInput(params.arguments);
100
+ setToolCancelled({
101
+ cancelled: false
102
+ });
74
103
  }
75
104
  };
76
105
  appInstance.ontoolinputpartial = (params) => {
@@ -83,19 +112,42 @@ function AppProvider({ appInfo, capabilities = {}, options = {
83
112
  setToolResult(params);
84
113
  }
85
114
  };
115
+ appInstance.ontoolcancelled = (params) => {
116
+ if (mounted) {
117
+ setToolCancelled({
118
+ cancelled: true,
119
+ reason: params.reason
120
+ });
121
+ }
122
+ };
86
123
  appInstance.onhostcontextchanged = (params) => {
87
124
  if (mounted) {
88
125
  setHostContext((prev) => ({
89
126
  ...prev,
90
127
  ...params
91
128
  }));
129
+ applyHostStyles(params);
92
130
  }
93
131
  };
132
+ if (onTeardown) {
133
+ appInstance.onteardown = async () => {
134
+ await onTeardown();
135
+ return {};
136
+ };
137
+ }
94
138
  await appInstance.connect(transport);
95
139
  if (mounted) {
96
140
  setApp(appInstance);
97
141
  setIsConnected(true);
98
142
  setError(null);
143
+ const initialContext = appInstance.getHostContext();
144
+ if (initialContext) {
145
+ setHostContext(initialContext);
146
+ if (!stylesApplied.current) {
147
+ applyHostStyles(initialContext);
148
+ stylesApplied.current = true;
149
+ }
150
+ }
99
151
  }
100
152
  } catch (err) {
101
153
  if (mounted) {
@@ -104,7 +156,7 @@ function AppProvider({ appInfo, capabilities = {}, options = {
104
156
  }
105
157
  }
106
158
  }
107
- __name(connect, "connect");
159
+ chunk3PV26V5F_js.__name(connect, "connect");
108
160
  connect();
109
161
  return () => {
110
162
  mounted = false;
@@ -114,12 +166,17 @@ function AppProvider({ appInfo, capabilities = {}, options = {
114
166
  };
115
167
  }, [
116
168
  appInfo.name,
117
- appInfo.version
169
+ appInfo.version,
170
+ applyHostStyles,
171
+ onTeardown
118
172
  ]);
119
- const callTool = React7.useCallback(async (name, args = {}) => {
173
+ const callTool = React25.useCallback(async (name, args = {}) => {
120
174
  if (!app) {
121
175
  throw new Error("Not connected to host");
122
176
  }
177
+ setToolCancelled({
178
+ cancelled: false
179
+ });
123
180
  const result = await app.callServerTool({
124
181
  name,
125
182
  arguments: args
@@ -129,7 +186,7 @@ function AppProvider({ appInfo, capabilities = {}, options = {
129
186
  }, [
130
187
  app
131
188
  ]);
132
- const sendMessage = React7.useCallback(async (text) => {
189
+ const sendMessage = React25.useCallback(async (text) => {
133
190
  if (!app) {
134
191
  console.warn("[AppProvider] Not connected - cannot send message");
135
192
  return;
@@ -146,7 +203,7 @@ function AppProvider({ appInfo, capabilities = {}, options = {
146
203
  }, [
147
204
  app
148
205
  ]);
149
- const sendLog = React7.useCallback(async (level, data) => {
206
+ const sendLog = React25.useCallback(async (level, data) => {
150
207
  if (!app) {
151
208
  console.log(`[MCP App] ${level}:`, data);
152
209
  return;
@@ -158,17 +215,29 @@ function AppProvider({ appInfo, capabilities = {}, options = {
158
215
  }, [
159
216
  app
160
217
  ]);
161
- const openLink = React7.useCallback(async (url) => {
218
+ const openLink = React25.useCallback(async (url) => {
162
219
  if (!app) {
163
220
  window.open(url, "_blank", "noopener,noreferrer");
164
221
  return;
165
222
  }
166
- await app.sendOpenLink({
223
+ await app.openLink({
167
224
  url
168
225
  });
169
226
  }, [
170
227
  app
171
228
  ]);
229
+ const requestDisplayMode = React25.useCallback(async (mode) => {
230
+ if (!app) {
231
+ console.warn("[AppProvider] Not connected - cannot request display mode");
232
+ return "inline";
233
+ }
234
+ const result = await app.requestDisplayMode({
235
+ mode
236
+ });
237
+ return result.mode;
238
+ }, [
239
+ app
240
+ ]);
172
241
  const value = {
173
242
  app,
174
243
  isConnected,
@@ -177,20 +246,22 @@ function AppProvider({ appInfo, capabilities = {}, options = {
177
246
  toolInput,
178
247
  toolInputPartial,
179
248
  toolResult,
249
+ toolCancelled,
180
250
  callTool,
181
251
  sendMessage,
182
252
  sendLog,
183
- openLink
253
+ openLink,
254
+ requestDisplayMode
184
255
  };
185
256
  const theme = hostContext.theme ?? "light";
186
- return /* @__PURE__ */ React7__default.default.createElement(McpAppContext.Provider, {
257
+ return /* @__PURE__ */ React25__namespace.default.createElement(McpAppContext.Provider, {
187
258
  value
188
- }, /* @__PURE__ */ React7__default.default.createElement("div", {
259
+ }, /* @__PURE__ */ React25__namespace.default.createElement("div", {
189
260
  className: "lui-root",
190
261
  "data-theme": theme
191
262
  }, children));
192
263
  }
193
- __name(AppProvider, "AppProvider");
264
+ chunk3PV26V5F_js.__name(AppProvider, "AppProvider");
194
265
  var ssrDefaultContext = {
195
266
  app: null,
196
267
  isConnected: false,
@@ -199,336 +270,2630 @@ var ssrDefaultContext = {
199
270
  toolInput: null,
200
271
  toolInputPartial: null,
201
272
  toolResult: null,
202
- callTool: /* @__PURE__ */ __name(async () => {
273
+ toolCancelled: {
274
+ cancelled: false
275
+ },
276
+ callTool: /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
203
277
  throw new Error("callTool not available during SSR");
204
278
  }, "callTool"),
205
- sendMessage: /* @__PURE__ */ __name(async () => {
279
+ sendMessage: /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
206
280
  console.warn("sendMessage not available during SSR");
207
281
  }, "sendMessage"),
208
- sendLog: /* @__PURE__ */ __name(async () => {
282
+ sendLog: /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
209
283
  console.warn("sendLog not available during SSR");
210
284
  }, "sendLog"),
211
- openLink: /* @__PURE__ */ __name(async () => {
285
+ openLink: /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
212
286
  console.warn("openLink not available during SSR");
213
- }, "openLink")
287
+ }, "openLink"),
288
+ requestDisplayMode: /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
289
+ console.warn("requestDisplayMode not available during SSR");
290
+ return "inline";
291
+ }, "requestDisplayMode")
214
292
  };
215
293
  function useMcpApp() {
216
- const context = React7.useContext(McpAppContext);
294
+ const context = React25.useContext(McpAppContext);
217
295
  if (!context) {
218
296
  return ssrDefaultContext;
219
297
  }
220
298
  return context;
221
299
  }
222
- __name(useMcpApp, "useMcpApp");
223
- function useTool(toolName) {
300
+ chunk3PV26V5F_js.__name(useMcpApp, "useMcpApp");
301
+ var DEFAULT_CONTEXT = {
302
+ resultDisplay: {
303
+ display: "none"
304
+ },
305
+ showLoading: true
306
+ };
307
+ var ToolContext = /* @__PURE__ */ React25.createContext(DEFAULT_CONTEXT);
308
+ function ToolProvider({ defaults = {}, children }) {
309
+ const parentContext = React25.useContext(ToolContext);
310
+ const value = React25.useMemo(() => ({
311
+ resultDisplay: defaults.resultDisplay ?? parentContext.resultDisplay,
312
+ onError: defaults.onError ?? parentContext.onError,
313
+ showLoading: defaults.showLoading ?? parentContext.showLoading
314
+ }), [
315
+ defaults,
316
+ parentContext
317
+ ]);
318
+ return /* @__PURE__ */ React25__namespace.createElement(ToolContext.Provider, {
319
+ value
320
+ }, children);
321
+ }
322
+ chunk3PV26V5F_js.__name(ToolProvider, "ToolProvider");
323
+ function useToolContext() {
324
+ return React25.useContext(ToolContext);
325
+ }
326
+ chunk3PV26V5F_js.__name(useToolContext, "useToolContext");
327
+ var Toaster = /* @__PURE__ */ chunk3PV26V5F_js.__name(({ ...props }) => {
328
+ const { theme = "system" } = nextThemes.useTheme();
329
+ return /* @__PURE__ */ React25__namespace.default.createElement(sonner.Toaster, {
330
+ theme,
331
+ className: "toaster group",
332
+ icons: {
333
+ success: /* @__PURE__ */ React25__namespace.default.createElement(lucideReact.CircleCheckIcon, {
334
+ className: "size-4"
335
+ }),
336
+ info: /* @__PURE__ */ React25__namespace.default.createElement(lucideReact.InfoIcon, {
337
+ className: "size-4"
338
+ }),
339
+ warning: /* @__PURE__ */ React25__namespace.default.createElement(lucideReact.TriangleAlertIcon, {
340
+ className: "size-4"
341
+ }),
342
+ error: /* @__PURE__ */ React25__namespace.default.createElement(lucideReact.OctagonXIcon, {
343
+ className: "size-4"
344
+ }),
345
+ loading: /* @__PURE__ */ React25__namespace.default.createElement(lucideReact.Loader2Icon, {
346
+ className: "size-4 animate-spin"
347
+ })
348
+ },
349
+ style: {
350
+ "--normal-bg": "var(--popover)",
351
+ "--normal-text": "var(--popover-foreground)",
352
+ "--normal-border": "var(--border)",
353
+ "--border-radius": "var(--radius)"
354
+ },
355
+ ...props
356
+ });
357
+ }, "Toaster");
358
+ function cn(...inputs) {
359
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
360
+ }
361
+ chunk3PV26V5F_js.__name(cn, "cn");
362
+
363
+ // src/components/ui/button.tsx
364
+ var buttonVariants = classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
365
+ variants: {
366
+ variant: {
367
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
368
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
369
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
370
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
371
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
372
+ link: "text-primary underline-offset-4 hover:underline"
373
+ },
374
+ size: {
375
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
376
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
377
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
378
+ icon: "size-9",
379
+ "icon-sm": "size-8",
380
+ "icon-lg": "size-10"
381
+ }
382
+ },
383
+ defaultVariants: {
384
+ variant: "default",
385
+ size: "default"
386
+ }
387
+ });
388
+ function Button({ className, variant = "default", size = "default", asChild = false, ...props }) {
389
+ const Comp = asChild ? reactSlot.Slot : "button";
390
+ return /* @__PURE__ */ React25__namespace.createElement(Comp, {
391
+ "data-slot": "button",
392
+ "data-variant": variant,
393
+ "data-size": size,
394
+ className: cn(buttonVariants({
395
+ variant,
396
+ size,
397
+ className
398
+ })),
399
+ ...props
400
+ });
401
+ }
402
+ chunk3PV26V5F_js.__name(Button, "Button");
403
+ function Dialog({ ...props }) {
404
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Root, {
405
+ "data-slot": "dialog",
406
+ ...props
407
+ });
408
+ }
409
+ chunk3PV26V5F_js.__name(Dialog, "Dialog");
410
+ function DialogTrigger({ ...props }) {
411
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Trigger, {
412
+ "data-slot": "dialog-trigger",
413
+ ...props
414
+ });
415
+ }
416
+ chunk3PV26V5F_js.__name(DialogTrigger, "DialogTrigger");
417
+ function DialogPortal({ ...props }) {
418
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Portal, {
419
+ "data-slot": "dialog-portal",
420
+ ...props
421
+ });
422
+ }
423
+ chunk3PV26V5F_js.__name(DialogPortal, "DialogPortal");
424
+ function DialogClose({ ...props }) {
425
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Close, {
426
+ "data-slot": "dialog-close",
427
+ ...props
428
+ });
429
+ }
430
+ chunk3PV26V5F_js.__name(DialogClose, "DialogClose");
431
+ function DialogOverlay({ className, ...props }) {
432
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Overlay, {
433
+ "data-slot": "dialog-overlay",
434
+ className: cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", className),
435
+ ...props
436
+ });
437
+ }
438
+ chunk3PV26V5F_js.__name(DialogOverlay, "DialogOverlay");
439
+ function DialogContent({ className, children, showCloseButton = true, ...props }) {
440
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPortal, {
441
+ "data-slot": "dialog-portal"
442
+ }, /* @__PURE__ */ React25__namespace.createElement(DialogOverlay, null), /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Content, {
443
+ "data-slot": "dialog-content",
444
+ className: cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg", className),
445
+ ...props
446
+ }, children, showCloseButton && /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Close, {
447
+ "data-slot": "dialog-close",
448
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
449
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.XIcon, null), /* @__PURE__ */ React25__namespace.createElement("span", {
450
+ className: "sr-only"
451
+ }, "Close"))));
452
+ }
453
+ chunk3PV26V5F_js.__name(DialogContent, "DialogContent");
454
+ function DialogHeader({ className, ...props }) {
455
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
456
+ "data-slot": "dialog-header",
457
+ className: cn("flex flex-col gap-2 text-center sm:text-left", className),
458
+ ...props
459
+ });
460
+ }
461
+ chunk3PV26V5F_js.__name(DialogHeader, "DialogHeader");
462
+ function DialogFooter({ className, ...props }) {
463
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
464
+ "data-slot": "dialog-footer",
465
+ className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
466
+ ...props
467
+ });
468
+ }
469
+ chunk3PV26V5F_js.__name(DialogFooter, "DialogFooter");
470
+ function DialogTitle({ className, ...props }) {
471
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Title, {
472
+ "data-slot": "dialog-title",
473
+ className: cn("text-lg leading-none font-semibold", className),
474
+ ...props
475
+ });
476
+ }
477
+ chunk3PV26V5F_js.__name(DialogTitle, "DialogTitle");
478
+ function DialogDescription({ className, ...props }) {
479
+ return /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Description, {
480
+ "data-slot": "dialog-description",
481
+ className: cn("text-muted-foreground text-sm", className),
482
+ ...props
483
+ });
484
+ }
485
+ chunk3PV26V5F_js.__name(DialogDescription, "DialogDescription");
486
+ function extractResultData(result) {
487
+ if ("structuredContent" in result && result.structuredContent) {
488
+ return result.structuredContent;
489
+ }
490
+ if (result.content && result.content.length > 0) {
491
+ const textContent = result.content.filter((c) => c.type === "text").map((c) => c.text).join("");
492
+ if (textContent) {
493
+ try {
494
+ return JSON.parse(textContent);
495
+ } catch {
496
+ return textContent;
497
+ }
498
+ }
499
+ }
500
+ return result;
501
+ }
502
+ chunk3PV26V5F_js.__name(extractResultData, "extractResultData");
503
+ function useTool(toolName, options = {}) {
224
504
  const { callTool } = useMcpApp();
225
- const [loading, setLoading] = React7.useState(false);
226
- const [result, setResult] = React7.useState(null);
227
- const [error, setError] = React7.useState(null);
228
- const call = React7.useCallback(async (args = {}) => {
229
- setLoading(true);
505
+ const [state, setState] = React25.useState("idle");
506
+ const [result, setResult] = React25.useState(null);
507
+ const [error, setError] = React25.useState(null);
508
+ const abortControllerRef = React25.useRef(null);
509
+ const lastArgsRef = React25.useRef(void 0);
510
+ const retryCountRef = React25.useRef(0);
511
+ const { defaultArgs, transform, retry, onStart, onSuccess, onError, onComplete } = options;
512
+ const retryConfig = typeof retry === "number" ? {
513
+ count: retry,
514
+ delay: 1e3
515
+ } : retry ?? {
516
+ count: 0,
517
+ delay: 1e3
518
+ };
519
+ const executeCall = React25.useCallback(async (args) => {
520
+ const mergedArgs = {
521
+ ...defaultArgs,
522
+ ...args
523
+ };
524
+ lastArgsRef.current = mergedArgs;
525
+ abortControllerRef.current = new AbortController();
526
+ setState("loading");
230
527
  setError(null);
528
+ onStart?.();
231
529
  try {
232
- const response = await callTool(toolName, args);
233
- const data = response?.structuredContent ?? response;
530
+ const response = await callTool(toolName, mergedArgs);
531
+ if (abortControllerRef.current?.signal.aborted) {
532
+ throw new Error("Tool call aborted");
533
+ }
534
+ let data;
535
+ if (transform) {
536
+ data = transform(response);
537
+ } else {
538
+ data = extractResultData(response);
539
+ }
540
+ setState("success");
234
541
  setResult(data);
542
+ retryCountRef.current = 0;
543
+ onSuccess?.(data);
544
+ onComplete?.();
235
545
  return data;
236
546
  } catch (err) {
237
547
  const error2 = err instanceof Error ? err : new Error(String(err));
548
+ if (retryCountRef.current < retryConfig.count) {
549
+ retryCountRef.current++;
550
+ await new Promise((resolve) => setTimeout(resolve, retryConfig.delay));
551
+ return executeCall(args);
552
+ }
553
+ setState("error");
238
554
  setError(error2);
555
+ retryCountRef.current = 0;
556
+ onError?.(error2);
557
+ onComplete?.();
239
558
  throw error2;
240
- } finally {
241
- setLoading(false);
242
559
  }
243
560
  }, [
244
561
  callTool,
245
- toolName
562
+ toolName,
563
+ defaultArgs,
564
+ transform,
565
+ retryConfig,
566
+ onStart,
567
+ onSuccess,
568
+ onError,
569
+ onComplete
570
+ ]);
571
+ const call = React25.useCallback(async (args) => {
572
+ retryCountRef.current = 0;
573
+ return executeCall(args);
574
+ }, [
575
+ executeCall
576
+ ]);
577
+ const mutate = React25.useCallback(async (args) => {
578
+ return call(args);
579
+ }, [
580
+ call
246
581
  ]);
247
- const reset = React7.useCallback(() => {
582
+ const reset = React25.useCallback(() => {
583
+ setState("idle");
248
584
  setResult(null);
249
585
  setError(null);
586
+ retryCountRef.current = 0;
587
+ abortControllerRef.current?.abort();
588
+ }, []);
589
+ const retryCall = React25.useCallback(async () => {
590
+ if (lastArgsRef.current === void 0 && !defaultArgs) {
591
+ return null;
592
+ }
593
+ retryCountRef.current = 0;
594
+ return executeCall(lastArgsRef.current);
595
+ }, [
596
+ executeCall,
597
+ defaultArgs
598
+ ]);
599
+ const abort = React25.useCallback(() => {
600
+ abortControllerRef.current?.abort();
601
+ setState("idle");
250
602
  }, []);
251
603
  return {
252
604
  call,
605
+ mutate,
606
+ state,
607
+ loading: state === "loading",
608
+ result,
609
+ error,
610
+ reset,
611
+ retry: retryCall,
612
+ abort
613
+ };
614
+ }
615
+ chunk3PV26V5F_js.__name(useTool, "useTool");
616
+ function ToolButton({ tool, args = {}, resultDisplay = "none", renderResult, resultDuration = 3e3, successMessage, errorMessage, onToolStart, onToolSuccess, onToolError, onToolComplete, loadingText, loadingIcon, disableWhileLoading = true, confirm, children, className, variant = "default", size = "default", disabled, asChild = false, ...props }) {
617
+ const toolConfig = typeof tool === "string" ? {
618
+ name: tool
619
+ } : tool;
620
+ const mergedArgs = {
621
+ ...toolConfig.args,
622
+ ...args
623
+ };
624
+ const { call, state, loading, result, error, reset } = useTool(toolConfig.name, {
625
+ defaultArgs: mergedArgs,
626
+ transform: toolConfig.transform,
627
+ onStart: onToolStart,
628
+ onSuccess: onToolSuccess,
629
+ onError: onToolError,
630
+ onComplete: onToolComplete
631
+ });
632
+ const [showConfirm, setShowConfirm] = React25.useState(false);
633
+ const [showResult, setShowResult] = React25.useState(false);
634
+ const buttonState = {
253
635
  loading,
636
+ state,
254
637
  result,
255
638
  error,
256
- reset
639
+ hasResult: result !== null || error !== null
640
+ };
641
+ const executeCall = React25.useCallback(async () => {
642
+ try {
643
+ const res = await call();
644
+ if (resultDisplay === "toast") {
645
+ const message = typeof successMessage === "function" ? successMessage(res) : successMessage ?? "Success";
646
+ sonner.toast.success(message);
647
+ } else if (resultDisplay === "inline") {
648
+ setShowResult(true);
649
+ setTimeout(() => setShowResult(false), resultDuration);
650
+ }
651
+ } catch (err) {
652
+ if (resultDisplay === "toast") {
653
+ const message = typeof errorMessage === "function" ? errorMessage(err instanceof Error ? err : new Error(String(err))) : errorMessage ?? (err instanceof Error ? err.message : "An error occurred");
654
+ sonner.toast.error(message);
655
+ } else if (resultDisplay === "inline") {
656
+ setShowResult(true);
657
+ setTimeout(() => setShowResult(false), resultDuration);
658
+ }
659
+ }
660
+ }, [
661
+ call,
662
+ resultDisplay,
663
+ successMessage,
664
+ errorMessage,
665
+ resultDuration
666
+ ]);
667
+ const handleClick = React25.useCallback(() => {
668
+ if (confirm) {
669
+ setShowConfirm(true);
670
+ } else {
671
+ executeCall();
672
+ }
673
+ }, [
674
+ confirm,
675
+ executeCall
676
+ ]);
677
+ const handleConfirm = React25.useCallback(() => {
678
+ setShowConfirm(false);
679
+ executeCall();
680
+ }, [
681
+ executeCall
682
+ ]);
683
+ const confirmConfig = typeof confirm === "object" ? confirm : {
684
+ title: "Confirm Action",
685
+ description: "Are you sure you want to proceed?",
686
+ confirmText: "Confirm",
687
+ cancelText: "Cancel"
257
688
  };
689
+ const renderChildren = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
690
+ if (typeof children === "function") {
691
+ return children(buttonState);
692
+ }
693
+ if (loading) {
694
+ return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, loadingIcon ?? /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
695
+ className: "animate-spin"
696
+ }), loadingText && /* @__PURE__ */ React25__namespace.createElement("span", null, loadingText), !loadingText && children);
697
+ }
698
+ if (showResult && resultDisplay === "inline") {
699
+ if (error) {
700
+ return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.X, {
701
+ className: "text-destructive"
702
+ }), /* @__PURE__ */ React25__namespace.createElement("span", null, error.message));
703
+ }
704
+ if (renderResult) {
705
+ return renderResult(result);
706
+ }
707
+ return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Check, {
708
+ className: "text-success"
709
+ }), /* @__PURE__ */ React25__namespace.createElement("span", null, "Done"));
710
+ }
711
+ return children;
712
+ }, "renderChildren");
713
+ return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, /* @__PURE__ */ React25__namespace.createElement(Button, {
714
+ type: "button",
715
+ variant,
716
+ size,
717
+ className: cn(className),
718
+ disabled: disabled || disableWhileLoading && loading,
719
+ onClick: handleClick,
720
+ asChild,
721
+ ...props
722
+ }, renderChildren()), confirm && /* @__PURE__ */ React25__namespace.createElement(Dialog, {
723
+ open: showConfirm,
724
+ onOpenChange: setShowConfirm
725
+ }, /* @__PURE__ */ React25__namespace.createElement(DialogContent, null, /* @__PURE__ */ React25__namespace.createElement(DialogHeader, null, /* @__PURE__ */ React25__namespace.createElement(DialogTitle, null, confirmConfig.title), confirmConfig.description && /* @__PURE__ */ React25__namespace.createElement(DialogDescription, null, confirmConfig.description)), /* @__PURE__ */ React25__namespace.createElement(DialogFooter, null, /* @__PURE__ */ React25__namespace.createElement(Button, {
726
+ variant: "outline",
727
+ onClick: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => setShowConfirm(false), "onClick")
728
+ }, confirmConfig.cancelText ?? "Cancel"), /* @__PURE__ */ React25__namespace.createElement(Button, {
729
+ variant: confirmConfig.confirmVariant ?? (variant === "destructive" ? "destructive" : "default"),
730
+ onClick: handleConfirm
731
+ }, confirmConfig.confirmText ?? "Confirm")))));
732
+ }
733
+ chunk3PV26V5F_js.__name(ToolButton, "ToolButton");
734
+ function Select({ ...props }) {
735
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Root, {
736
+ "data-slot": "select",
737
+ ...props
738
+ });
739
+ }
740
+ chunk3PV26V5F_js.__name(Select, "Select");
741
+ function SelectGroup({ ...props }) {
742
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Group, {
743
+ "data-slot": "select-group",
744
+ ...props
745
+ });
746
+ }
747
+ chunk3PV26V5F_js.__name(SelectGroup, "SelectGroup");
748
+ function SelectValue({ ...props }) {
749
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Value, {
750
+ "data-slot": "select-value",
751
+ ...props
752
+ });
753
+ }
754
+ chunk3PV26V5F_js.__name(SelectValue, "SelectValue");
755
+ function SelectTrigger({ className, size = "default", children, ...props }) {
756
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Trigger, {
757
+ "data-slot": "select-trigger",
758
+ "data-size": size,
759
+ className: cn("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
760
+ ...props
761
+ }, children, /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Icon, {
762
+ asChild: true
763
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronDownIcon, {
764
+ className: "size-4 opacity-50"
765
+ })));
766
+ }
767
+ chunk3PV26V5F_js.__name(SelectTrigger, "SelectTrigger");
768
+ function SelectContent({ className, children, position = "item-aligned", align = "center", ...props }) {
769
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Content, {
770
+ "data-slot": "select-content",
771
+ className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
772
+ position,
773
+ align,
774
+ ...props
775
+ }, /* @__PURE__ */ React25__namespace.createElement(SelectScrollUpButton, null), /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Viewport, {
776
+ className: cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1")
777
+ }, children), /* @__PURE__ */ React25__namespace.createElement(SelectScrollDownButton, null)));
778
+ }
779
+ chunk3PV26V5F_js.__name(SelectContent, "SelectContent");
780
+ function SelectLabel({ className, ...props }) {
781
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Label, {
782
+ "data-slot": "select-label",
783
+ className: cn("text-muted-foreground px-2 py-1.5 text-xs", className),
784
+ ...props
785
+ });
786
+ }
787
+ chunk3PV26V5F_js.__name(SelectLabel, "SelectLabel");
788
+ function SelectItem({ className, children, ...props }) {
789
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Item, {
790
+ "data-slot": "select-item",
791
+ className: cn("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
792
+ ...props
793
+ }, /* @__PURE__ */ React25__namespace.createElement("span", {
794
+ "data-slot": "select-item-indicator",
795
+ className: "absolute right-2 flex size-3.5 items-center justify-center"
796
+ }, /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.CheckIcon, {
797
+ className: "size-4"
798
+ }))), /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ItemText, null, children));
799
+ }
800
+ chunk3PV26V5F_js.__name(SelectItem, "SelectItem");
801
+ function SelectSeparator({ className, ...props }) {
802
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Separator, {
803
+ "data-slot": "select-separator",
804
+ className: cn("bg-border pointer-events-none -mx-1 my-1 h-px", className),
805
+ ...props
806
+ });
807
+ }
808
+ chunk3PV26V5F_js.__name(SelectSeparator, "SelectSeparator");
809
+ function SelectScrollUpButton({ className, ...props }) {
810
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ScrollUpButton, {
811
+ "data-slot": "select-scroll-up-button",
812
+ className: cn("flex cursor-default items-center justify-center py-1", className),
813
+ ...props
814
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronUpIcon, {
815
+ className: "size-4"
816
+ }));
817
+ }
818
+ chunk3PV26V5F_js.__name(SelectScrollUpButton, "SelectScrollUpButton");
819
+ function SelectScrollDownButton({ className, ...props }) {
820
+ return /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ScrollDownButton, {
821
+ "data-slot": "select-scroll-down-button",
822
+ className: cn("flex cursor-default items-center justify-center py-1", className),
823
+ ...props
824
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronDownIcon, {
825
+ className: "size-4"
826
+ }));
827
+ }
828
+ chunk3PV26V5F_js.__name(SelectScrollDownButton, "SelectScrollDownButton");
829
+ function ToolSelect({ onSelectTool, argName = "value", additionalArgs = {}, optionsTool, optionsArgs = {}, transformOptions, options: staticOptions = [], placeholder = "Select an option", loadingPlaceholder = "Loading...", emptyMessage = "No options available", value: controlledValue, defaultValue, onValueChange, onOptionsLoaded, onSelectionSuccess, onSelectionError, showSuccessToast = false, successMessage, className, disabled = false }) {
830
+ const [fetchedOptions, setFetchedOptions] = React25.useState([]);
831
+ const [internalValue, setInternalValue] = React25.useState(defaultValue ?? "");
832
+ const optionsToolConfig = optionsTool ? typeof optionsTool === "string" ? {
833
+ name: optionsTool
834
+ } : optionsTool : null;
835
+ const selectToolConfig = onSelectTool ? typeof onSelectTool === "string" ? {
836
+ name: onSelectTool
837
+ } : onSelectTool : null;
838
+ const optionsHook = useTool(optionsToolConfig?.name ?? "", {
839
+ defaultArgs: {
840
+ ...optionsToolConfig?.args,
841
+ ...optionsArgs
842
+ }
843
+ });
844
+ const selectHook = useTool(selectToolConfig?.name ?? "", {
845
+ onSuccess: /* @__PURE__ */ chunk3PV26V5F_js.__name((result) => {
846
+ onSelectionSuccess?.(result);
847
+ if (showSuccessToast) {
848
+ const message = typeof successMessage === "function" ? successMessage(result) : successMessage ?? "Selection saved";
849
+ sonner.toast.success(message);
850
+ }
851
+ }, "onSuccess"),
852
+ onError: onSelectionError
853
+ });
854
+ React25.useEffect(() => {
855
+ if (optionsToolConfig) {
856
+ optionsHook.call().then((result) => {
857
+ const options = transformOptions ? transformOptions(result) : result;
858
+ setFetchedOptions(options);
859
+ onOptionsLoaded?.(options);
860
+ }).catch(() => {
861
+ });
862
+ }
863
+ }, [
864
+ optionsToolConfig?.name
865
+ ]);
866
+ const allOptions = [
867
+ ...staticOptions,
868
+ ...fetchedOptions
869
+ ];
870
+ const value = controlledValue ?? internalValue;
871
+ const handleValueChange = React25.useCallback((newValue) => {
872
+ setInternalValue(newValue);
873
+ onValueChange?.(newValue);
874
+ if (selectToolConfig) {
875
+ selectHook.call({
876
+ [argName]: newValue,
877
+ ...additionalArgs
878
+ });
879
+ }
880
+ }, [
881
+ onValueChange,
882
+ selectToolConfig,
883
+ argName,
884
+ additionalArgs,
885
+ selectHook
886
+ ]);
887
+ const isLoading = optionsHook.loading || selectHook.loading;
888
+ const hasError = optionsHook.error || selectHook.error;
889
+ return /* @__PURE__ */ React25__namespace.createElement(Select, {
890
+ value,
891
+ onValueChange: handleValueChange,
892
+ disabled: disabled || isLoading
893
+ }, /* @__PURE__ */ React25__namespace.createElement(SelectTrigger, {
894
+ className: cn("w-full", className)
895
+ }, isLoading ? /* @__PURE__ */ React25__namespace.createElement("div", {
896
+ className: "flex items-center gap-2"
897
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
898
+ className: "h-4 w-4 animate-spin"
899
+ }), /* @__PURE__ */ React25__namespace.createElement("span", {
900
+ className: "text-muted-foreground"
901
+ }, optionsHook.loading ? loadingPlaceholder : "Saving...")) : /* @__PURE__ */ React25__namespace.createElement(SelectValue, {
902
+ placeholder
903
+ })), /* @__PURE__ */ React25__namespace.createElement(SelectContent, null, allOptions.length === 0 ? /* @__PURE__ */ React25__namespace.createElement("div", {
904
+ className: "py-6 text-center text-sm text-muted-foreground"
905
+ }, hasError ? "Error loading options" : emptyMessage) : allOptions.map((option) => /* @__PURE__ */ React25__namespace.createElement(SelectItem, {
906
+ key: option.value,
907
+ value: option.value,
908
+ disabled: option.disabled
909
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
910
+ className: "flex items-center gap-2"
911
+ }, option.icon, /* @__PURE__ */ React25__namespace.createElement("div", null, /* @__PURE__ */ React25__namespace.createElement("div", null, option.label), option.description && /* @__PURE__ */ React25__namespace.createElement("div", {
912
+ className: "text-xs text-muted-foreground"
913
+ }, option.description)))))));
914
+ }
915
+ chunk3PV26V5F_js.__name(ToolSelect, "ToolSelect");
916
+ function Input({ className, type, ...props }) {
917
+ return /* @__PURE__ */ React25__namespace.createElement("input", {
918
+ type,
919
+ "data-slot": "input",
920
+ className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", className),
921
+ ...props
922
+ });
923
+ }
924
+ chunk3PV26V5F_js.__name(Input, "Input");
925
+ function Command({ className, ...props }) {
926
+ return /* @__PURE__ */ React25__namespace.createElement(cmdk.Command, {
927
+ "data-slot": "command",
928
+ className: cn("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md", className),
929
+ ...props
930
+ });
931
+ }
932
+ chunk3PV26V5F_js.__name(Command, "Command");
933
+ function CommandDialog({ title = "Command Palette", description = "Search for a command to run...", children, className, showCloseButton = true, ...props }) {
934
+ return /* @__PURE__ */ React25__namespace.createElement(Dialog, props, /* @__PURE__ */ React25__namespace.createElement(DialogHeader, {
935
+ className: "sr-only"
936
+ }, /* @__PURE__ */ React25__namespace.createElement(DialogTitle, null, title), /* @__PURE__ */ React25__namespace.createElement(DialogDescription, null, description)), /* @__PURE__ */ React25__namespace.createElement(DialogContent, {
937
+ className: cn("overflow-hidden p-0", className),
938
+ showCloseButton
939
+ }, /* @__PURE__ */ React25__namespace.createElement(Command, {
940
+ className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"
941
+ }, children)));
942
+ }
943
+ chunk3PV26V5F_js.__name(CommandDialog, "CommandDialog");
944
+ function CommandInput({ className, ...props }) {
945
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
946
+ "data-slot": "command-input-wrapper",
947
+ className: "flex h-9 items-center gap-2 border-b px-3"
948
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.SearchIcon, {
949
+ className: "size-4 shrink-0 opacity-50"
950
+ }), /* @__PURE__ */ React25__namespace.createElement(cmdk.Command.Input, {
951
+ "data-slot": "command-input",
952
+ className: cn("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50", className),
953
+ ...props
954
+ }));
955
+ }
956
+ chunk3PV26V5F_js.__name(CommandInput, "CommandInput");
957
+ function CommandList({ className, ...props }) {
958
+ return /* @__PURE__ */ React25__namespace.createElement(cmdk.Command.List, {
959
+ "data-slot": "command-list",
960
+ className: cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className),
961
+ ...props
962
+ });
963
+ }
964
+ chunk3PV26V5F_js.__name(CommandList, "CommandList");
965
+ function CommandEmpty({ ...props }) {
966
+ return /* @__PURE__ */ React25__namespace.createElement(cmdk.Command.Empty, {
967
+ "data-slot": "command-empty",
968
+ className: "py-6 text-center text-sm",
969
+ ...props
970
+ });
971
+ }
972
+ chunk3PV26V5F_js.__name(CommandEmpty, "CommandEmpty");
973
+ function CommandGroup({ className, ...props }) {
974
+ return /* @__PURE__ */ React25__namespace.createElement(cmdk.Command.Group, {
975
+ "data-slot": "command-group",
976
+ className: cn("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium", className),
977
+ ...props
978
+ });
979
+ }
980
+ chunk3PV26V5F_js.__name(CommandGroup, "CommandGroup");
981
+ function CommandSeparator({ className, ...props }) {
982
+ return /* @__PURE__ */ React25__namespace.createElement(cmdk.Command.Separator, {
983
+ "data-slot": "command-separator",
984
+ className: cn("bg-border -mx-1 h-px", className),
985
+ ...props
986
+ });
987
+ }
988
+ chunk3PV26V5F_js.__name(CommandSeparator, "CommandSeparator");
989
+ function CommandItem({ className, ...props }) {
990
+ return /* @__PURE__ */ React25__namespace.createElement(cmdk.Command.Item, {
991
+ "data-slot": "command-item",
992
+ className: cn("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
993
+ ...props
994
+ });
995
+ }
996
+ chunk3PV26V5F_js.__name(CommandItem, "CommandItem");
997
+ function CommandShortcut({ className, ...props }) {
998
+ return /* @__PURE__ */ React25__namespace.createElement("span", {
999
+ "data-slot": "command-shortcut",
1000
+ className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className),
1001
+ ...props
1002
+ });
1003
+ }
1004
+ chunk3PV26V5F_js.__name(CommandShortcut, "CommandShortcut");
1005
+ function Popover({ ...props }) {
1006
+ return /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Root, {
1007
+ "data-slot": "popover",
1008
+ ...props
1009
+ });
1010
+ }
1011
+ chunk3PV26V5F_js.__name(Popover, "Popover");
1012
+ function PopoverTrigger({ ...props }) {
1013
+ return /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Trigger, {
1014
+ "data-slot": "popover-trigger",
1015
+ ...props
1016
+ });
1017
+ }
1018
+ chunk3PV26V5F_js.__name(PopoverTrigger, "PopoverTrigger");
1019
+ function PopoverContent({ className, align = "center", sideOffset = 4, ...props }) {
1020
+ return /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Content, {
1021
+ "data-slot": "popover-content",
1022
+ align,
1023
+ sideOffset,
1024
+ className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden", className),
1025
+ ...props
1026
+ }));
1027
+ }
1028
+ chunk3PV26V5F_js.__name(PopoverContent, "PopoverContent");
1029
+ function PopoverAnchor({ ...props }) {
1030
+ return /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Anchor, {
1031
+ "data-slot": "popover-anchor",
1032
+ ...props
1033
+ });
1034
+ }
1035
+ chunk3PV26V5F_js.__name(PopoverAnchor, "PopoverAnchor");
1036
+
1037
+ // src/mcp/ToolInput.tsx
1038
+ function ToolInput({ searchTool, debounce = 300, minChars = 1, argName = "query", additionalArgs = {}, autocomplete = false, transformSuggestions, onSuggestionSelect, emptyMessage = "No results found", value: controlledValue, onChange, onSearchResults, onSearchError, showSearchIcon = true, showClearButton = true, showLoadingIndicator = true, className, placeholder = "Search...", disabled, ...props }) {
1039
+ const [internalValue, setInternalValue] = React25.useState("");
1040
+ const [suggestions, setSuggestions] = React25.useState([]);
1041
+ const [isOpen, setIsOpen] = React25.useState(false);
1042
+ const debounceRef = React25.useRef(null);
1043
+ const inputRef = React25.useRef(null);
1044
+ const toolConfig = searchTool ? typeof searchTool === "string" ? {
1045
+ name: searchTool
1046
+ } : searchTool : null;
1047
+ const { call, loading, error, reset } = useTool(toolConfig?.name ?? "", {
1048
+ defaultArgs: {
1049
+ ...toolConfig?.args,
1050
+ ...additionalArgs
1051
+ },
1052
+ onSuccess: /* @__PURE__ */ chunk3PV26V5F_js.__name((result) => {
1053
+ onSearchResults?.(result);
1054
+ if (autocomplete && transformSuggestions) {
1055
+ const suggestions2 = transformSuggestions(result);
1056
+ setSuggestions(suggestions2);
1057
+ if (suggestions2.length > 0) {
1058
+ setIsOpen(true);
1059
+ }
1060
+ }
1061
+ }, "onSuccess"),
1062
+ onError: onSearchError
1063
+ });
1064
+ const value = controlledValue ?? internalValue;
1065
+ const handleChange = React25.useCallback((e) => {
1066
+ const newValue = e.target.value;
1067
+ setInternalValue(newValue);
1068
+ onChange?.(newValue);
1069
+ if (debounceRef.current) {
1070
+ clearTimeout(debounceRef.current);
1071
+ }
1072
+ if (newValue.length < minChars) {
1073
+ setSuggestions([]);
1074
+ setIsOpen(false);
1075
+ return;
1076
+ }
1077
+ if (toolConfig) {
1078
+ debounceRef.current = setTimeout(() => {
1079
+ call({
1080
+ [argName]: newValue
1081
+ });
1082
+ }, debounce);
1083
+ }
1084
+ }, [
1085
+ onChange,
1086
+ minChars,
1087
+ toolConfig,
1088
+ argName,
1089
+ debounce,
1090
+ call
1091
+ ]);
1092
+ const handleClear = React25.useCallback(() => {
1093
+ setInternalValue("");
1094
+ onChange?.("");
1095
+ setSuggestions([]);
1096
+ setIsOpen(false);
1097
+ reset();
1098
+ inputRef.current?.focus();
1099
+ }, [
1100
+ onChange,
1101
+ reset
1102
+ ]);
1103
+ const handleSelect = React25.useCallback((suggestion) => {
1104
+ setInternalValue(suggestion.label);
1105
+ onChange?.(suggestion.label);
1106
+ setIsOpen(false);
1107
+ onSuggestionSelect?.(suggestion);
1108
+ }, [
1109
+ onChange,
1110
+ onSuggestionSelect
1111
+ ]);
1112
+ React25.useEffect(() => {
1113
+ return () => {
1114
+ if (debounceRef.current) {
1115
+ clearTimeout(debounceRef.current);
1116
+ }
1117
+ };
1118
+ }, []);
1119
+ const inputElement = /* @__PURE__ */ React25__namespace.createElement("div", {
1120
+ className: cn("relative", className)
1121
+ }, showSearchIcon && /* @__PURE__ */ React25__namespace.createElement(lucideReact.Search, {
1122
+ className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
1123
+ }), /* @__PURE__ */ React25__namespace.createElement(Input, {
1124
+ ref: inputRef,
1125
+ value,
1126
+ onChange: handleChange,
1127
+ placeholder,
1128
+ disabled,
1129
+ className: cn(showSearchIcon && "pl-9", (showClearButton || showLoadingIndicator) && "pr-9"),
1130
+ ...props
1131
+ }), /* @__PURE__ */ React25__namespace.createElement("div", {
1132
+ className: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1"
1133
+ }, showLoadingIndicator && loading && /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
1134
+ className: "h-4 w-4 animate-spin text-muted-foreground"
1135
+ }), showClearButton && value && !loading && /* @__PURE__ */ React25__namespace.createElement("button", {
1136
+ type: "button",
1137
+ onClick: handleClear,
1138
+ className: "h-4 w-4 text-muted-foreground hover:text-foreground transition-colors"
1139
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.X, {
1140
+ className: "h-4 w-4"
1141
+ }))));
1142
+ if (!autocomplete) {
1143
+ return inputElement;
1144
+ }
1145
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, {
1146
+ open: isOpen,
1147
+ onOpenChange: setIsOpen
1148
+ }, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, {
1149
+ asChild: true
1150
+ }, inputElement), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, {
1151
+ className: "p-0 w-[var(--radix-popover-trigger-width)]",
1152
+ align: "start",
1153
+ onOpenAutoFocus: /* @__PURE__ */ chunk3PV26V5F_js.__name((e) => e.preventDefault(), "onOpenAutoFocus")
1154
+ }, /* @__PURE__ */ React25__namespace.createElement(Command, null, /* @__PURE__ */ React25__namespace.createElement(CommandList, null, /* @__PURE__ */ React25__namespace.createElement(CommandEmpty, null, emptyMessage), /* @__PURE__ */ React25__namespace.createElement(CommandGroup, null, suggestions.map((suggestion) => /* @__PURE__ */ React25__namespace.createElement(CommandItem, {
1155
+ key: suggestion.value,
1156
+ value: suggestion.value,
1157
+ onSelect: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => handleSelect(suggestion), "onSelect")
1158
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
1159
+ className: "flex items-center gap-2"
1160
+ }, suggestion.icon, /* @__PURE__ */ React25__namespace.createElement("div", null, /* @__PURE__ */ React25__namespace.createElement("div", null, suggestion.label), suggestion.description && /* @__PURE__ */ React25__namespace.createElement("div", {
1161
+ className: "text-xs text-muted-foreground"
1162
+ }, suggestion.description))))))))));
1163
+ }
1164
+ chunk3PV26V5F_js.__name(ToolInput, "ToolInput");
1165
+ function Label2({ className, ...props }) {
1166
+ return /* @__PURE__ */ React25__namespace.createElement(LabelPrimitive__namespace.Root, {
1167
+ "data-slot": "label",
1168
+ className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
1169
+ ...props
1170
+ });
1171
+ }
1172
+ chunk3PV26V5F_js.__name(Label2, "Label");
1173
+ function Textarea({ className, ...props }) {
1174
+ return /* @__PURE__ */ React25__namespace.createElement("textarea", {
1175
+ "data-slot": "textarea",
1176
+ className: cn("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className),
1177
+ ...props
1178
+ });
1179
+ }
1180
+ chunk3PV26V5F_js.__name(Textarea, "Textarea");
1181
+ function Checkbox({ className, ...props }) {
1182
+ return /* @__PURE__ */ React25__namespace.createElement(CheckboxPrimitive__namespace.Root, {
1183
+ "data-slot": "checkbox",
1184
+ className: cn("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
1185
+ ...props
1186
+ }, /* @__PURE__ */ React25__namespace.createElement(CheckboxPrimitive__namespace.Indicator, {
1187
+ "data-slot": "checkbox-indicator",
1188
+ className: "grid place-content-center text-current transition-none"
1189
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.CheckIcon, {
1190
+ className: "size-3.5"
1191
+ })));
1192
+ }
1193
+ chunk3PV26V5F_js.__name(Checkbox, "Checkbox");
1194
+ function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }) {
1195
+ const _values = React25__namespace.useMemo(() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [
1196
+ min,
1197
+ max
1198
+ ], [
1199
+ value,
1200
+ defaultValue,
1201
+ min,
1202
+ max
1203
+ ]);
1204
+ return /* @__PURE__ */ React25__namespace.createElement(SliderPrimitive__namespace.Root, {
1205
+ "data-slot": "slider",
1206
+ defaultValue,
1207
+ value,
1208
+ min,
1209
+ max,
1210
+ className: cn("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col", className),
1211
+ ...props
1212
+ }, /* @__PURE__ */ React25__namespace.createElement(SliderPrimitive__namespace.Track, {
1213
+ "data-slot": "slider-track",
1214
+ className: cn("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5")
1215
+ }, /* @__PURE__ */ React25__namespace.createElement(SliderPrimitive__namespace.Range, {
1216
+ "data-slot": "slider-range",
1217
+ className: cn("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
1218
+ })), Array.from({
1219
+ length: _values.length
1220
+ }, (_, index) => /* @__PURE__ */ React25__namespace.createElement(SliderPrimitive__namespace.Thumb, {
1221
+ "data-slot": "slider-thumb",
1222
+ key: index,
1223
+ className: "border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
1224
+ })));
1225
+ }
1226
+ chunk3PV26V5F_js.__name(Slider, "Slider");
1227
+ function Switch({ className, ...props }) {
1228
+ return /* @__PURE__ */ React25__namespace.createElement(SwitchPrimitive__namespace.Root, {
1229
+ "data-slot": "switch",
1230
+ className: cn("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", className),
1231
+ ...props
1232
+ }, /* @__PURE__ */ React25__namespace.createElement(SwitchPrimitive__namespace.Thumb, {
1233
+ "data-slot": "switch-thumb",
1234
+ className: cn("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")
1235
+ }));
1236
+ }
1237
+ chunk3PV26V5F_js.__name(Switch, "Switch");
1238
+ var alertVariants = classVarianceAuthority.cva("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", {
1239
+ variants: {
1240
+ variant: {
1241
+ default: "bg-card text-card-foreground",
1242
+ destructive: "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"
1243
+ }
1244
+ },
1245
+ defaultVariants: {
1246
+ variant: "default"
1247
+ }
1248
+ });
1249
+ function Alert({ className, variant, ...props }) {
1250
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1251
+ "data-slot": "alert",
1252
+ role: "alert",
1253
+ className: cn(alertVariants({
1254
+ variant
1255
+ }), className),
1256
+ ...props
1257
+ });
1258
+ }
1259
+ chunk3PV26V5F_js.__name(Alert, "Alert");
1260
+ function AlertTitle({ className, ...props }) {
1261
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1262
+ "data-slot": "alert-title",
1263
+ className: cn("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight", className),
1264
+ ...props
1265
+ });
1266
+ }
1267
+ chunk3PV26V5F_js.__name(AlertTitle, "AlertTitle");
1268
+ function AlertDescription({ className, ...props }) {
1269
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1270
+ "data-slot": "alert-description",
1271
+ className: cn("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed", className),
1272
+ ...props
1273
+ });
1274
+ }
1275
+ chunk3PV26V5F_js.__name(AlertDescription, "AlertDescription");
1276
+ function ToolForm({ toolName, fields: manualFields, autoSchema = false, submitText = "Submit", loadingText, onSuccess, onError, showResult = false, showSuccessToast = false, successMessage, resetOnSuccess = false, className, layout = "vertical" }) {
1277
+ const { app, isConnected } = useMcpApp();
1278
+ const { call, loading, result, error, reset } = useTool(toolName, {
1279
+ onSuccess: /* @__PURE__ */ chunk3PV26V5F_js.__name((result2) => {
1280
+ onSuccess?.(result2);
1281
+ if (showSuccessToast) {
1282
+ const message = typeof successMessage === "function" ? successMessage(result2) : successMessage ?? "Form submitted successfully";
1283
+ sonner.toast.success(message);
1284
+ }
1285
+ if (resetOnSuccess) {
1286
+ resetForm();
1287
+ }
1288
+ }, "onSuccess"),
1289
+ onError
1290
+ });
1291
+ const [fields, setFields] = React25.useState(manualFields ?? []);
1292
+ const [schemaLoading, setSchemaLoading] = React25.useState(autoSchema);
1293
+ const [formData, setFormData] = React25.useState({});
1294
+ const initializeFormData = /* @__PURE__ */ chunk3PV26V5F_js.__name((fields2) => {
1295
+ const initial = {};
1296
+ fields2.forEach((field) => {
1297
+ if (field.defaultValue !== void 0) {
1298
+ initial[field.name] = field.defaultValue;
1299
+ } else if (field.type === "checkbox" || field.type === "switch") {
1300
+ initial[field.name] = false;
1301
+ } else if (field.type === "number" || field.type === "slider") {
1302
+ initial[field.name] = field.min ?? 0;
1303
+ } else {
1304
+ initial[field.name] = "";
1305
+ }
1306
+ });
1307
+ setFormData(initial);
1308
+ }, "initializeFormData");
1309
+ const resetForm = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
1310
+ initializeFormData(fields);
1311
+ reset();
1312
+ }, "resetForm");
1313
+ React25.useEffect(() => {
1314
+ if (autoSchema && app && isConnected) {
1315
+ setSchemaLoading(true);
1316
+ const fetchSchema = /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
1317
+ try {
1318
+ console.warn("[ToolForm] Auto-schema not fully implemented, use manual fields");
1319
+ if (manualFields) {
1320
+ setFields(manualFields);
1321
+ initializeFormData(manualFields);
1322
+ }
1323
+ } catch (err) {
1324
+ console.error("[ToolForm] Failed to fetch schema:", err);
1325
+ } finally {
1326
+ setSchemaLoading(false);
1327
+ }
1328
+ }, "fetchSchema");
1329
+ fetchSchema();
1330
+ } else if (manualFields) {
1331
+ setFields(manualFields);
1332
+ initializeFormData(manualFields);
1333
+ }
1334
+ }, [
1335
+ autoSchema,
1336
+ app,
1337
+ isConnected,
1338
+ manualFields,
1339
+ toolName
1340
+ ]);
1341
+ const handleSubmit = /* @__PURE__ */ chunk3PV26V5F_js.__name(async (e) => {
1342
+ e.preventDefault();
1343
+ const args = {};
1344
+ fields.forEach((field) => {
1345
+ let value = formData[field.name];
1346
+ if (field.type === "number" || field.type === "slider") {
1347
+ value = Number(value);
1348
+ }
1349
+ args[field.name] = value;
1350
+ });
1351
+ await call(args);
1352
+ }, "handleSubmit");
1353
+ const handleChange = /* @__PURE__ */ chunk3PV26V5F_js.__name((name, value) => {
1354
+ setFormData((prev) => ({
1355
+ ...prev,
1356
+ [name]: value
1357
+ }));
1358
+ }, "handleChange");
1359
+ const renderField = /* @__PURE__ */ chunk3PV26V5F_js.__name((field) => {
1360
+ const value = formData[field.name];
1361
+ switch (field.type) {
1362
+ case "textarea":
1363
+ return /* @__PURE__ */ React25__namespace.createElement(Textarea, {
1364
+ id: field.name,
1365
+ placeholder: field.placeholder,
1366
+ value: value ?? "",
1367
+ onChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((e) => handleChange(field.name, e.target.value), "onChange"),
1368
+ disabled: field.disabled || loading,
1369
+ required: field.required
1370
+ });
1371
+ case "select":
1372
+ return /* @__PURE__ */ React25__namespace.createElement(Select, {
1373
+ value: value ?? "",
1374
+ onValueChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((v) => handleChange(field.name, v), "onValueChange"),
1375
+ disabled: field.disabled || loading
1376
+ }, /* @__PURE__ */ React25__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React25__namespace.createElement(SelectValue, {
1377
+ placeholder: field.placeholder ?? "Select..."
1378
+ })), /* @__PURE__ */ React25__namespace.createElement(SelectContent, null, field.options?.map((option) => /* @__PURE__ */ React25__namespace.createElement(SelectItem, {
1379
+ key: option.value,
1380
+ value: option.value
1381
+ }, option.label))));
1382
+ case "checkbox":
1383
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1384
+ className: "flex items-center space-x-2"
1385
+ }, /* @__PURE__ */ React25__namespace.createElement(Checkbox, {
1386
+ id: field.name,
1387
+ checked: value ?? false,
1388
+ onCheckedChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((checked) => handleChange(field.name, checked), "onCheckedChange"),
1389
+ disabled: field.disabled || loading
1390
+ }), /* @__PURE__ */ React25__namespace.createElement("label", {
1391
+ htmlFor: field.name,
1392
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
1393
+ }, field.label));
1394
+ case "switch":
1395
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1396
+ className: "flex items-center space-x-2"
1397
+ }, /* @__PURE__ */ React25__namespace.createElement(Switch, {
1398
+ id: field.name,
1399
+ checked: value ?? false,
1400
+ onCheckedChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((checked) => handleChange(field.name, checked), "onCheckedChange"),
1401
+ disabled: field.disabled || loading
1402
+ }), /* @__PURE__ */ React25__namespace.createElement(Label2, {
1403
+ htmlFor: field.name
1404
+ }, field.label));
1405
+ case "slider":
1406
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1407
+ className: "space-y-2"
1408
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
1409
+ className: "flex justify-between text-sm"
1410
+ }, /* @__PURE__ */ React25__namespace.createElement("span", null, field.min ?? 0), /* @__PURE__ */ React25__namespace.createElement("span", null, value ?? field.min ?? 0), /* @__PURE__ */ React25__namespace.createElement("span", null, field.max ?? 100)), /* @__PURE__ */ React25__namespace.createElement(Slider, {
1411
+ value: [
1412
+ value ?? field.min ?? 0
1413
+ ],
1414
+ onValueChange: /* @__PURE__ */ chunk3PV26V5F_js.__name(([v]) => handleChange(field.name, v), "onValueChange"),
1415
+ min: field.min ?? 0,
1416
+ max: field.max ?? 100,
1417
+ step: field.step ?? 1,
1418
+ disabled: field.disabled || loading
1419
+ }));
1420
+ case "number":
1421
+ return /* @__PURE__ */ React25__namespace.createElement(Input, {
1422
+ id: field.name,
1423
+ type: "number",
1424
+ placeholder: field.placeholder,
1425
+ value: value ?? "",
1426
+ onChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((e) => handleChange(field.name, e.target.value), "onChange"),
1427
+ min: field.min,
1428
+ max: field.max,
1429
+ step: field.step,
1430
+ disabled: field.disabled || loading,
1431
+ required: field.required
1432
+ });
1433
+ default:
1434
+ return /* @__PURE__ */ React25__namespace.createElement(Input, {
1435
+ id: field.name,
1436
+ type: field.type ?? "text",
1437
+ placeholder: field.placeholder,
1438
+ value: value ?? "",
1439
+ onChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((e) => handleChange(field.name, e.target.value), "onChange"),
1440
+ disabled: field.disabled || loading,
1441
+ required: field.required
1442
+ });
1443
+ }
1444
+ }, "renderField");
1445
+ if (schemaLoading) {
1446
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1447
+ className: "flex items-center justify-center p-8"
1448
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
1449
+ className: "h-6 w-6 animate-spin text-muted-foreground"
1450
+ }));
1451
+ }
1452
+ return /* @__PURE__ */ React25__namespace.createElement("form", {
1453
+ className: cn("space-y-4", className),
1454
+ onSubmit: handleSubmit
1455
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
1456
+ className: cn("space-y-4", layout === "horizontal" && "grid grid-cols-2 gap-4")
1457
+ }, fields.map((field) => /* @__PURE__ */ React25__namespace.createElement("div", {
1458
+ key: field.name,
1459
+ className: "space-y-2"
1460
+ }, field.type !== "checkbox" && field.type !== "switch" && /* @__PURE__ */ React25__namespace.createElement(Label2, {
1461
+ htmlFor: field.name
1462
+ }, field.label, field.required && /* @__PURE__ */ React25__namespace.createElement("span", {
1463
+ className: "text-destructive ml-1"
1464
+ }, "*")), renderField(field), field.description && /* @__PURE__ */ React25__namespace.createElement("p", {
1465
+ className: "text-sm text-muted-foreground"
1466
+ }, field.description)))), /* @__PURE__ */ React25__namespace.createElement("div", {
1467
+ className: "flex items-center gap-2"
1468
+ }, /* @__PURE__ */ React25__namespace.createElement(Button, {
1469
+ type: "submit",
1470
+ disabled: loading
1471
+ }, loading ? /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
1472
+ className: "h-4 w-4 animate-spin mr-2"
1473
+ }), loadingText ?? "Submitting...") : submitText)), error && /* @__PURE__ */ React25__namespace.createElement(Alert, {
1474
+ variant: "destructive"
1475
+ }, /* @__PURE__ */ React25__namespace.createElement(AlertDescription, null, error.message)), showResult && result !== null && /* @__PURE__ */ React25__namespace.createElement("div", {
1476
+ className: "rounded-md bg-muted p-4"
1477
+ }, /* @__PURE__ */ React25__namespace.createElement("pre", {
1478
+ className: "text-sm overflow-auto"
1479
+ }, JSON.stringify(result, null, 2))));
1480
+ }
1481
+ chunk3PV26V5F_js.__name(ToolForm, "ToolForm");
1482
+ function useResource(uri, options = {}) {
1483
+ const { app, isConnected } = useMcpApp();
1484
+ const { refreshInterval, subscribe = false, transform, skip = false } = options;
1485
+ const [data, setData] = React25.useState(null);
1486
+ const [loading, setLoading] = React25.useState(!skip);
1487
+ const [error, setError] = React25.useState(null);
1488
+ const [lastUpdated, setLastUpdated] = React25.useState(null);
1489
+ const intervalRef = React25.useRef(null);
1490
+ const mountedRef = React25.useRef(true);
1491
+ const fetchResource = React25.useCallback(async () => {
1492
+ if (!app || !isConnected) {
1493
+ throw new Error("Not connected to MCP host");
1494
+ }
1495
+ setLoading(true);
1496
+ setError(null);
1497
+ try {
1498
+ const result = await app.readResource?.({
1499
+ uri
1500
+ });
1501
+ if (!result) {
1502
+ throw new Error("readResource not supported by host");
1503
+ }
1504
+ let resourceData;
1505
+ if (result.contents && result.contents.length > 0) {
1506
+ const content = result.contents[0];
1507
+ if (content.text) {
1508
+ try {
1509
+ resourceData = JSON.parse(content.text);
1510
+ } catch {
1511
+ resourceData = content.text;
1512
+ }
1513
+ } else if (content.blob) {
1514
+ resourceData = content.blob;
1515
+ } else {
1516
+ resourceData = content;
1517
+ }
1518
+ } else {
1519
+ resourceData = result;
1520
+ }
1521
+ if (transform) {
1522
+ resourceData = transform(resourceData);
1523
+ }
1524
+ if (mountedRef.current) {
1525
+ setData(resourceData);
1526
+ setLastUpdated(/* @__PURE__ */ new Date());
1527
+ setLoading(false);
1528
+ }
1529
+ return resourceData;
1530
+ } catch (err) {
1531
+ const error2 = err instanceof Error ? err : new Error(String(err));
1532
+ if (mountedRef.current) {
1533
+ setError(error2);
1534
+ setLoading(false);
1535
+ }
1536
+ throw error2;
1537
+ }
1538
+ }, [
1539
+ app,
1540
+ isConnected,
1541
+ uri,
1542
+ transform
1543
+ ]);
1544
+ const refresh = React25.useCallback(async () => {
1545
+ return fetchResource();
1546
+ }, [
1547
+ fetchResource
1548
+ ]);
1549
+ React25.useEffect(() => {
1550
+ mountedRef.current = true;
1551
+ if (!skip && isConnected) {
1552
+ fetchResource().catch(() => {
1553
+ });
1554
+ }
1555
+ return () => {
1556
+ mountedRef.current = false;
1557
+ };
1558
+ }, [
1559
+ uri,
1560
+ isConnected,
1561
+ skip,
1562
+ fetchResource
1563
+ ]);
1564
+ React25.useEffect(() => {
1565
+ if (refreshInterval && refreshInterval > 0 && isConnected && !skip) {
1566
+ intervalRef.current = setInterval(() => {
1567
+ fetchResource().catch(() => {
1568
+ });
1569
+ }, refreshInterval);
1570
+ }
1571
+ return () => {
1572
+ if (intervalRef.current) {
1573
+ clearInterval(intervalRef.current);
1574
+ intervalRef.current = null;
1575
+ }
1576
+ };
1577
+ }, [
1578
+ refreshInterval,
1579
+ isConnected,
1580
+ skip,
1581
+ fetchResource
1582
+ ]);
1583
+ React25.useEffect(() => {
1584
+ if (subscribe) {
1585
+ console.warn("[useResource] Subscription support not yet implemented");
1586
+ }
1587
+ }, [
1588
+ subscribe
1589
+ ]);
1590
+ return {
1591
+ data,
1592
+ loading,
1593
+ error,
1594
+ refresh,
1595
+ lastUpdated
1596
+ };
1597
+ }
1598
+ chunk3PV26V5F_js.__name(useResource, "useResource");
1599
+ function Skeleton({ className, ...props }) {
1600
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
1601
+ "data-slot": "skeleton",
1602
+ className: cn("bg-accent animate-pulse rounded-md", className),
1603
+ ...props
1604
+ });
1605
+ }
1606
+ chunk3PV26V5F_js.__name(Skeleton, "Skeleton");
1607
+
1608
+ // src/mcp/ResourceView.tsx
1609
+ function DefaultLoading() {
1610
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1611
+ className: "flex flex-col gap-3 p-4"
1612
+ }, /* @__PURE__ */ React25__namespace.createElement(Skeleton, {
1613
+ className: "h-4 w-3/4"
1614
+ }), /* @__PURE__ */ React25__namespace.createElement(Skeleton, {
1615
+ className: "h-4 w-1/2"
1616
+ }), /* @__PURE__ */ React25__namespace.createElement(Skeleton, {
1617
+ className: "h-20 w-full"
1618
+ }));
1619
+ }
1620
+ chunk3PV26V5F_js.__name(DefaultLoading, "DefaultLoading");
1621
+ function DefaultError({ error, onRetry }) {
1622
+ return /* @__PURE__ */ React25__namespace.createElement(Alert, {
1623
+ variant: "destructive"
1624
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlertCircle, {
1625
+ className: "h-4 w-4"
1626
+ }), /* @__PURE__ */ React25__namespace.createElement(AlertTitle, null, "Error loading resource"), /* @__PURE__ */ React25__namespace.createElement(AlertDescription, {
1627
+ className: "flex flex-col gap-2"
1628
+ }, /* @__PURE__ */ React25__namespace.createElement("span", null, error.message), /* @__PURE__ */ React25__namespace.createElement(Button, {
1629
+ variant: "outline",
1630
+ size: "sm",
1631
+ onClick: onRetry,
1632
+ className: "w-fit"
1633
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.RefreshCw, {
1634
+ className: "h-4 w-4 mr-2"
1635
+ }), "Retry")));
1636
+ }
1637
+ chunk3PV26V5F_js.__name(DefaultError, "DefaultError");
1638
+ function ResourceView({ uri, refreshInterval, subscribe, transform, loading: loadingContent, error: errorContent, children, className, skip = false }) {
1639
+ const { data, loading, error, refresh, lastUpdated } = useResource(uri, {
1640
+ refreshInterval,
1641
+ subscribe,
1642
+ transform,
1643
+ skip
1644
+ });
1645
+ const meta = {
1646
+ uri,
1647
+ refresh,
1648
+ lastUpdated,
1649
+ isRefreshing: loading && data !== null
1650
+ };
1651
+ if (loading && data === null) {
1652
+ if (loadingContent) {
1653
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1654
+ className
1655
+ }, loadingContent);
1656
+ }
1657
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1658
+ className: cn("flex items-center justify-center p-8", className)
1659
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
1660
+ className: "h-8 w-8 animate-spin text-muted-foreground"
1661
+ }));
1662
+ }
1663
+ if (error && data === null) {
1664
+ if (errorContent) {
1665
+ if (typeof errorContent === "function") {
1666
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1667
+ className
1668
+ }, errorContent(error, refresh));
1669
+ }
1670
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1671
+ className
1672
+ }, errorContent);
1673
+ }
1674
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1675
+ className
1676
+ }, /* @__PURE__ */ React25__namespace.createElement(DefaultError, {
1677
+ error,
1678
+ onRetry: refresh
1679
+ }));
1680
+ }
1681
+ if (data !== null) {
1682
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1683
+ className
1684
+ }, children(data, meta));
1685
+ }
1686
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1687
+ className
1688
+ }, loadingContent ?? /* @__PURE__ */ React25__namespace.createElement(DefaultLoading, null));
1689
+ }
1690
+ chunk3PV26V5F_js.__name(ResourceView, "ResourceView");
1691
+ function useToolStream(options = {}) {
1692
+ const { toolInputPartial, toolInput, toolResult } = useMcpApp();
1693
+ const { onPartial, onComplete } = options;
1694
+ const [partial, setPartial] = React25.useState(null);
1695
+ const [complete, setComplete] = React25.useState(null);
1696
+ const [isStreaming, setIsStreaming] = React25.useState(false);
1697
+ const [isComplete, setIsComplete] = React25.useState(false);
1698
+ React25.useEffect(() => {
1699
+ if (toolInputPartial) {
1700
+ setPartial(toolInputPartial);
1701
+ setIsStreaming(true);
1702
+ setIsComplete(false);
1703
+ onPartial?.(toolInputPartial);
1704
+ }
1705
+ }, [
1706
+ toolInputPartial,
1707
+ onPartial
1708
+ ]);
1709
+ React25.useEffect(() => {
1710
+ if (toolInput) {
1711
+ setComplete(toolInput);
1712
+ setIsStreaming(false);
1713
+ setIsComplete(true);
1714
+ onComplete?.(toolInput);
1715
+ }
1716
+ }, [
1717
+ toolInput,
1718
+ onComplete
1719
+ ]);
1720
+ React25.useEffect(() => {
1721
+ if (toolResult && !toolResult.isError) {
1722
+ setIsStreaming(false);
1723
+ setIsComplete(true);
1724
+ }
1725
+ }, [
1726
+ toolResult
1727
+ ]);
1728
+ return {
1729
+ partial,
1730
+ complete,
1731
+ isStreaming,
1732
+ isComplete
1733
+ };
1734
+ }
1735
+ chunk3PV26V5F_js.__name(useToolStream, "useToolStream");
1736
+ function Progress({ className, value, ...props }) {
1737
+ return /* @__PURE__ */ React25__namespace.createElement(ProgressPrimitive__namespace.Root, {
1738
+ "data-slot": "progress",
1739
+ className: cn("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full", className),
1740
+ ...props
1741
+ }, /* @__PURE__ */ React25__namespace.createElement(ProgressPrimitive__namespace.Indicator, {
1742
+ "data-slot": "progress-indicator",
1743
+ className: "bg-primary h-full w-full flex-1 transition-all",
1744
+ style: {
1745
+ transform: `translateX(-${100 - (value || 0)}%)`
1746
+ }
1747
+ }));
1748
+ }
1749
+ chunk3PV26V5F_js.__name(Progress, "Progress");
1750
+
1751
+ // src/mcp/StreamingContent.tsx
1752
+ function StreamingContent({ fallback, showProgress = false, progress: externalProgress, onPartial, onComplete, children, className, streamingStyle = "opacity" }) {
1753
+ const { partial, complete, isStreaming, isComplete } = useToolStream({
1754
+ onPartial,
1755
+ onComplete
1756
+ });
1757
+ const data = complete ?? partial;
1758
+ if (!data) {
1759
+ if (fallback) {
1760
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1761
+ className
1762
+ }, fallback);
1763
+ }
1764
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1765
+ className: cn("flex items-center justify-center p-8", className)
1766
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
1767
+ className: "h-6 w-6 animate-spin text-muted-foreground"
1768
+ }));
1769
+ }
1770
+ const streamingClasses = cn(streamingStyle === "opacity" && isStreaming && "opacity-70", streamingStyle === "blur" && isStreaming && "blur-[1px]");
1771
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1772
+ className: cn("relative", className)
1773
+ }, showProgress && isStreaming && /* @__PURE__ */ React25__namespace.createElement("div", {
1774
+ className: "absolute top-0 left-0 right-0 z-10"
1775
+ }, externalProgress !== void 0 ? /* @__PURE__ */ React25__namespace.createElement(Progress, {
1776
+ value: externalProgress,
1777
+ className: "h-1"
1778
+ }) : /* @__PURE__ */ React25__namespace.createElement("div", {
1779
+ className: "h-1 bg-primary/20 overflow-hidden"
1780
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
1781
+ className: "h-full w-1/3 bg-primary animate-[shimmer_1s_infinite]"
1782
+ }))), isStreaming && /* @__PURE__ */ React25__namespace.createElement("div", {
1783
+ className: "absolute top-2 right-2 z-10"
1784
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
1785
+ className: "flex items-center gap-1 px-2 py-1 rounded-full bg-muted text-muted-foreground text-xs"
1786
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
1787
+ className: "h-3 w-3 animate-spin"
1788
+ }), /* @__PURE__ */ React25__namespace.createElement("span", null, "Streaming..."))), /* @__PURE__ */ React25__namespace.createElement("div", {
1789
+ className: cn("transition-all duration-200", streamingClasses)
1790
+ }, children(data, isComplete)));
1791
+ }
1792
+ chunk3PV26V5F_js.__name(StreamingContent, "StreamingContent");
1793
+ function Table({ className, ...props }) {
1794
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1795
+ "data-slot": "table-container",
1796
+ className: "relative w-full overflow-x-auto"
1797
+ }, /* @__PURE__ */ React25__namespace.createElement("table", {
1798
+ "data-slot": "table",
1799
+ className: cn("w-full caption-bottom text-sm", className),
1800
+ ...props
1801
+ }));
1802
+ }
1803
+ chunk3PV26V5F_js.__name(Table, "Table");
1804
+ function TableHeader({ className, ...props }) {
1805
+ return /* @__PURE__ */ React25__namespace.createElement("thead", {
1806
+ "data-slot": "table-header",
1807
+ className: cn("[&_tr]:border-b", className),
1808
+ ...props
1809
+ });
1810
+ }
1811
+ chunk3PV26V5F_js.__name(TableHeader, "TableHeader");
1812
+ function TableBody({ className, ...props }) {
1813
+ return /* @__PURE__ */ React25__namespace.createElement("tbody", {
1814
+ "data-slot": "table-body",
1815
+ className: cn("[&_tr:last-child]:border-0", className),
1816
+ ...props
1817
+ });
1818
+ }
1819
+ chunk3PV26V5F_js.__name(TableBody, "TableBody");
1820
+ function TableFooter({ className, ...props }) {
1821
+ return /* @__PURE__ */ React25__namespace.createElement("tfoot", {
1822
+ "data-slot": "table-footer",
1823
+ className: cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
1824
+ ...props
1825
+ });
1826
+ }
1827
+ chunk3PV26V5F_js.__name(TableFooter, "TableFooter");
1828
+ function TableRow({ className, ...props }) {
1829
+ return /* @__PURE__ */ React25__namespace.createElement("tr", {
1830
+ "data-slot": "table-row",
1831
+ className: cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
1832
+ ...props
1833
+ });
1834
+ }
1835
+ chunk3PV26V5F_js.__name(TableRow, "TableRow");
1836
+ function TableHead({ className, ...props }) {
1837
+ return /* @__PURE__ */ React25__namespace.createElement("th", {
1838
+ "data-slot": "table-head",
1839
+ className: cn("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
1840
+ ...props
1841
+ });
1842
+ }
1843
+ chunk3PV26V5F_js.__name(TableHead, "TableHead");
1844
+ function TableCell({ className, ...props }) {
1845
+ return /* @__PURE__ */ React25__namespace.createElement("td", {
1846
+ "data-slot": "table-cell",
1847
+ className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className),
1848
+ ...props
1849
+ });
1850
+ }
1851
+ chunk3PV26V5F_js.__name(TableCell, "TableCell");
1852
+ function TableCaption({ className, ...props }) {
1853
+ return /* @__PURE__ */ React25__namespace.createElement("caption", {
1854
+ "data-slot": "table-caption",
1855
+ className: cn("text-muted-foreground mt-4 text-sm", className),
1856
+ ...props
1857
+ });
1858
+ }
1859
+ chunk3PV26V5F_js.__name(TableCaption, "TableCaption");
1860
+ function getNestedValue(obj, path) {
1861
+ return path.split(".").reduce((current, key) => {
1862
+ if (current && typeof current === "object" && key in current) {
1863
+ return current[key];
1864
+ }
1865
+ return void 0;
1866
+ }, obj);
1867
+ }
1868
+ chunk3PV26V5F_js.__name(getNestedValue, "getNestedValue");
1869
+ function ToolDataGrid({ dataTool, columns, transformData, rowActions = [], pagination = true, pageSizes = [
1870
+ 10,
1871
+ 25,
1872
+ 50,
1873
+ 100
1874
+ ], defaultPageSize = 10, defaultSort, refreshInterval, showRefresh = true, onDataLoaded, onError, onRowClick, getRowKey, emptyContent, loadingContent, className }) {
1875
+ const toolConfig = typeof dataTool === "string" ? {
1876
+ name: dataTool
1877
+ } : dataTool;
1878
+ const [data, setData] = React25.useState({
1879
+ rows: [],
1880
+ total: 0
1881
+ });
1882
+ const [paginationState, setPaginationState] = React25.useState({
1883
+ page: 1,
1884
+ pageSize: defaultPageSize
1885
+ });
1886
+ const [sortState, setSortState] = React25.useState(defaultSort ?? {
1887
+ column: null,
1888
+ direction: "asc"
1889
+ });
1890
+ const { call, loading, error } = useTool(toolConfig.name, {
1891
+ defaultArgs: toolConfig.args,
1892
+ onSuccess: /* @__PURE__ */ chunk3PV26V5F_js.__name((result) => {
1893
+ const gridData = transformData ? transformData(result) : result;
1894
+ setData(gridData);
1895
+ onDataLoaded?.(gridData);
1896
+ }, "onSuccess"),
1897
+ onError
1898
+ });
1899
+ const fetchData = React25.useCallback(() => {
1900
+ const args = {};
1901
+ if (pagination) {
1902
+ args.page = paginationState.page;
1903
+ args.pageSize = paginationState.pageSize;
1904
+ args.offset = (paginationState.page - 1) * paginationState.pageSize;
1905
+ args.limit = paginationState.pageSize;
1906
+ }
1907
+ if (sortState.column) {
1908
+ args.sortBy = sortState.column;
1909
+ args.sortDirection = sortState.direction;
1910
+ args.sort = `${sortState.column}:${sortState.direction}`;
1911
+ }
1912
+ call(args);
1913
+ }, [
1914
+ call,
1915
+ pagination,
1916
+ paginationState,
1917
+ sortState
1918
+ ]);
1919
+ const initialFetchDone = React25__namespace.useRef(false);
1920
+ const prevStateRef = React25__namespace.useRef({
1921
+ pagination: paginationState,
1922
+ sort: sortState
1923
+ });
1924
+ React25.useEffect(() => {
1925
+ if (!initialFetchDone.current) {
1926
+ initialFetchDone.current = true;
1927
+ fetchData();
1928
+ return;
1929
+ }
1930
+ const prevState = prevStateRef.current;
1931
+ const stateChanged = prevState.pagination.page !== paginationState.page || prevState.pagination.pageSize !== paginationState.pageSize || prevState.sort.column !== sortState.column || prevState.sort.direction !== sortState.direction;
1932
+ if (stateChanged) {
1933
+ prevStateRef.current = {
1934
+ pagination: paginationState,
1935
+ sort: sortState
1936
+ };
1937
+ fetchData();
1938
+ }
1939
+ }, [
1940
+ fetchData,
1941
+ paginationState,
1942
+ sortState
1943
+ ]);
1944
+ React25.useEffect(() => {
1945
+ if (refreshInterval && refreshInterval > 0) {
1946
+ const interval = setInterval(fetchData, refreshInterval);
1947
+ return () => clearInterval(interval);
1948
+ }
1949
+ }, [
1950
+ refreshInterval,
1951
+ fetchData
1952
+ ]);
1953
+ const handleSort = React25.useCallback((column) => {
1954
+ setSortState((prev) => ({
1955
+ column,
1956
+ direction: prev.column === column && prev.direction === "asc" ? "desc" : "asc"
1957
+ }));
1958
+ }, []);
1959
+ const handlePageChange = React25.useCallback((page) => {
1960
+ setPaginationState((prev) => ({
1961
+ ...prev,
1962
+ page
1963
+ }));
1964
+ }, []);
1965
+ const handlePageSizeChange = React25.useCallback((pageSize) => {
1966
+ setPaginationState({
1967
+ page: 1,
1968
+ pageSize: parseInt(pageSize, 10)
1969
+ });
1970
+ }, []);
1971
+ const totalPages = Math.ceil(data.total / paginationState.pageSize);
1972
+ const canPreviousPage = paginationState.page > 1;
1973
+ const canNextPage = paginationState.page < totalPages;
1974
+ const getSortIcon = /* @__PURE__ */ chunk3PV26V5F_js.__name((column) => {
1975
+ if (sortState.column !== column) {
1976
+ return /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowUpDown, {
1977
+ className: "h-4 w-4"
1978
+ });
1979
+ }
1980
+ return sortState.direction === "asc" ? /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowUp, {
1981
+ className: "h-4 w-4"
1982
+ }) : /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowDown, {
1983
+ className: "h-4 w-4"
1984
+ });
1985
+ }, "getSortIcon");
1986
+ const renderLoading = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
1987
+ if (loadingContent) return loadingContent;
1988
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
1989
+ className: "space-y-2"
1990
+ }, Array.from({
1991
+ length: 5
1992
+ }).map((_, i) => /* @__PURE__ */ React25__namespace.createElement(Skeleton, {
1993
+ key: i,
1994
+ className: "h-12 w-full"
1995
+ })));
1996
+ }, "renderLoading");
1997
+ const renderEmpty = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
1998
+ if (emptyContent) return emptyContent;
1999
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2000
+ className: "flex flex-col items-center justify-center py-12 text-muted-foreground"
2001
+ }, /* @__PURE__ */ React25__namespace.createElement("p", {
2002
+ className: "text-lg"
2003
+ }, "No data found"), /* @__PURE__ */ React25__namespace.createElement(Button, {
2004
+ variant: "ghost",
2005
+ size: "sm",
2006
+ onClick: fetchData,
2007
+ className: "mt-2"
2008
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.RefreshCw, {
2009
+ className: "h-4 w-4 mr-2"
2010
+ }), "Refresh"));
2011
+ }, "renderEmpty");
2012
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2013
+ className: cn("space-y-4", className)
2014
+ }, showRefresh && /* @__PURE__ */ React25__namespace.createElement("div", {
2015
+ className: "flex items-center justify-end gap-2"
2016
+ }, /* @__PURE__ */ React25__namespace.createElement(Button, {
2017
+ variant: "outline",
2018
+ size: "sm",
2019
+ onClick: fetchData,
2020
+ disabled: loading
2021
+ }, loading ? /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
2022
+ className: "h-4 w-4 animate-spin"
2023
+ }) : /* @__PURE__ */ React25__namespace.createElement(lucideReact.RefreshCw, {
2024
+ className: "h-4 w-4"
2025
+ }), /* @__PURE__ */ React25__namespace.createElement("span", {
2026
+ className: "ml-2"
2027
+ }, "Refresh"))), /* @__PURE__ */ React25__namespace.createElement("div", {
2028
+ className: "rounded-md border"
2029
+ }, loading && data.rows.length === 0 ? /* @__PURE__ */ React25__namespace.createElement("div", {
2030
+ className: "p-4"
2031
+ }, renderLoading()) : data.rows.length === 0 ? renderEmpty() : /* @__PURE__ */ React25__namespace.createElement(Table, null, /* @__PURE__ */ React25__namespace.createElement(TableHeader, null, /* @__PURE__ */ React25__namespace.createElement(TableRow, null, columns.map((column) => /* @__PURE__ */ React25__namespace.createElement(TableHead, {
2032
+ key: column.key,
2033
+ style: {
2034
+ width: column.width
2035
+ },
2036
+ className: cn(column.align === "center" && "text-center", column.align === "right" && "text-right", column.hideMobile && "hidden md:table-cell")
2037
+ }, column.sortable ? /* @__PURE__ */ React25__namespace.createElement(Button, {
2038
+ variant: "ghost",
2039
+ size: "sm",
2040
+ onClick: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => handleSort(column.key), "onClick"),
2041
+ className: "-ml-3"
2042
+ }, column.header, getSortIcon(column.key)) : column.header)), rowActions.length > 0 && /* @__PURE__ */ React25__namespace.createElement(TableHead, {
2043
+ className: "w-[100px]"
2044
+ }, "Actions"))), /* @__PURE__ */ React25__namespace.createElement(TableBody, null, data.rows.map((row, index) => {
2045
+ const key = getRowKey?.(row, index) ?? String(index);
2046
+ return /* @__PURE__ */ React25__namespace.createElement(TableRow, {
2047
+ key,
2048
+ onClick: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => onRowClick?.(row, index), "onClick"),
2049
+ className: onRowClick ? "cursor-pointer" : void 0
2050
+ }, columns.map((column) => {
2051
+ const value = getNestedValue(row, column.key);
2052
+ return /* @__PURE__ */ React25__namespace.createElement(TableCell, {
2053
+ key: column.key,
2054
+ className: cn(column.align === "center" && "text-center", column.align === "right" && "text-right", column.hideMobile && "hidden md:table-cell")
2055
+ }, column.render ? column.render(value, row, index) : String(value ?? ""));
2056
+ }), rowActions.length > 0 && /* @__PURE__ */ React25__namespace.createElement(TableCell, null, /* @__PURE__ */ React25__namespace.createElement("div", {
2057
+ className: "flex items-center gap-1"
2058
+ }, rowActions.filter((action) => !action.hidden?.(row)).map((action, actionIndex) => /* @__PURE__ */ React25__namespace.createElement(RowActionButton, {
2059
+ key: actionIndex,
2060
+ action,
2061
+ row,
2062
+ onRefresh: fetchData
2063
+ })))));
2064
+ })))), pagination && data.total > 0 && /* @__PURE__ */ React25__namespace.createElement("div", {
2065
+ className: "flex items-center justify-between"
2066
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
2067
+ className: "text-sm text-muted-foreground"
2068
+ }, "Showing ", (paginationState.page - 1) * paginationState.pageSize + 1, " to", " ", Math.min(paginationState.page * paginationState.pageSize, data.total), " of", " ", data.total, " results"), /* @__PURE__ */ React25__namespace.createElement("div", {
2069
+ className: "flex items-center gap-4"
2070
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
2071
+ className: "flex items-center gap-2"
2072
+ }, /* @__PURE__ */ React25__namespace.createElement("span", {
2073
+ className: "text-sm text-muted-foreground"
2074
+ }, "Rows per page"), /* @__PURE__ */ React25__namespace.createElement(Select, {
2075
+ value: String(paginationState.pageSize),
2076
+ onValueChange: handlePageSizeChange
2077
+ }, /* @__PURE__ */ React25__namespace.createElement(SelectTrigger, {
2078
+ className: "w-[70px]"
2079
+ }, /* @__PURE__ */ React25__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React25__namespace.createElement(SelectContent, null, pageSizes.map((size) => /* @__PURE__ */ React25__namespace.createElement(SelectItem, {
2080
+ key: size,
2081
+ value: String(size)
2082
+ }, size))))), /* @__PURE__ */ React25__namespace.createElement("div", {
2083
+ className: "flex items-center gap-2"
2084
+ }, /* @__PURE__ */ React25__namespace.createElement(Button, {
2085
+ variant: "outline",
2086
+ size: "sm",
2087
+ onClick: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => handlePageChange(paginationState.page - 1), "onClick"),
2088
+ disabled: !canPreviousPage || loading
2089
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronLeft, {
2090
+ className: "h-4 w-4"
2091
+ })), /* @__PURE__ */ React25__namespace.createElement("span", {
2092
+ className: "text-sm"
2093
+ }, "Page ", paginationState.page, " of ", totalPages), /* @__PURE__ */ React25__namespace.createElement(Button, {
2094
+ variant: "outline",
2095
+ size: "sm",
2096
+ onClick: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => handlePageChange(paginationState.page + 1), "onClick"),
2097
+ disabled: !canNextPage || loading
2098
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronRight, {
2099
+ className: "h-4 w-4"
2100
+ }))))));
2101
+ }
2102
+ chunk3PV26V5F_js.__name(ToolDataGrid, "ToolDataGrid");
2103
+ function RowActionButton({ action, row, onRefresh }) {
2104
+ const toolConfig = typeof action.tool === "string" ? {
2105
+ name: action.tool
2106
+ } : action.tool;
2107
+ const args = action.getArgs?.(row) ?? {
2108
+ id: row.id
2109
+ };
2110
+ const { call, loading } = useTool(toolConfig.name, {
2111
+ onSuccess: /* @__PURE__ */ chunk3PV26V5F_js.__name((result) => {
2112
+ action.onSuccess?.(result, row);
2113
+ sonner.toast.success("Action completed");
2114
+ onRefresh();
2115
+ }, "onSuccess"),
2116
+ onError: /* @__PURE__ */ chunk3PV26V5F_js.__name((error) => {
2117
+ sonner.toast.error(error.message);
2118
+ }, "onError")
2119
+ });
2120
+ const handleClick = React25.useCallback((e) => {
2121
+ e.stopPropagation();
2122
+ call(args);
2123
+ }, [
2124
+ call,
2125
+ args
2126
+ ]);
2127
+ return /* @__PURE__ */ React25__namespace.createElement(Button, {
2128
+ variant: action.variant ?? "ghost",
2129
+ size: "sm",
2130
+ onClick: handleClick,
2131
+ disabled: loading
2132
+ }, loading ? /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
2133
+ className: "h-3 w-3 animate-spin"
2134
+ }) : /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, action.icon, /* @__PURE__ */ React25__namespace.createElement("span", {
2135
+ className: action.icon ? "ml-1" : ""
2136
+ }, action.label)));
2137
+ }
2138
+ chunk3PV26V5F_js.__name(RowActionButton, "RowActionButton");
2139
+ var Button2 = /* @__PURE__ */ React25.forwardRef(({ className, variant = "primary", size = "md", loading = false, disabled, asChild = false, leftIcon, rightIcon, children, ...props }, ref) => {
2140
+ const Comp = asChild ? reactSlot.Slot : "button";
2141
+ return /* @__PURE__ */ React25__namespace.default.createElement(Comp, {
2142
+ ref,
2143
+ className: clsx.clsx("lui-button", `lui-button--${variant}`, `lui-button--${size}`, loading && "lui-button--loading", className),
2144
+ disabled: disabled || loading,
2145
+ ...props
2146
+ }, loading && /* @__PURE__ */ React25__namespace.default.createElement("span", {
2147
+ className: "lui-button__spinner",
2148
+ "aria-hidden": "true"
2149
+ }, /* @__PURE__ */ React25__namespace.default.createElement("svg", {
2150
+ viewBox: "0 0 24 24",
2151
+ fill: "none",
2152
+ className: "lui-spinner-icon"
2153
+ }, /* @__PURE__ */ React25__namespace.default.createElement("circle", {
2154
+ cx: "12",
2155
+ cy: "12",
2156
+ r: "10",
2157
+ stroke: "currentColor",
2158
+ strokeWidth: "3",
2159
+ strokeLinecap: "round",
2160
+ strokeDasharray: "32",
2161
+ strokeDashoffset: "12"
2162
+ }))), leftIcon && !loading && /* @__PURE__ */ React25__namespace.default.createElement("span", {
2163
+ className: "lui-button__icon"
2164
+ }, leftIcon), /* @__PURE__ */ React25__namespace.default.createElement("span", {
2165
+ className: "lui-button__content"
2166
+ }, children), rightIcon && /* @__PURE__ */ React25__namespace.default.createElement("span", {
2167
+ className: "lui-button__icon"
2168
+ }, rightIcon));
2169
+ });
2170
+ Button2.displayName = "Button";
2171
+
2172
+ // src/mcp/ActionButton.tsx
2173
+ function ActionButton({ toolName, toolArgs = {}, onToolSuccess, onToolError, showResult = false, renderResult, children, ...buttonProps }) {
2174
+ const { call, loading, result, error } = useTool(toolName);
2175
+ const [hasResult, setHasResult] = React25.useState(false);
2176
+ const handleClick = /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
2177
+ try {
2178
+ const res = await call(toolArgs);
2179
+ setHasResult(true);
2180
+ onToolSuccess?.(res);
2181
+ } catch (err) {
2182
+ onToolError?.(err instanceof Error ? err : new Error(String(err)));
2183
+ }
2184
+ }, "handleClick");
2185
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
2186
+ className: "lui-action-button-wrapper"
2187
+ }, /* @__PURE__ */ React25__namespace.default.createElement(Button2, {
2188
+ ...buttonProps,
2189
+ loading,
2190
+ onClick: handleClick
2191
+ }, children), showResult && hasResult && result !== null && /* @__PURE__ */ React25__namespace.default.createElement("div", {
2192
+ className: "lui-action-button-result"
2193
+ }, renderResult ? renderResult(result) : /* @__PURE__ */ React25__namespace.default.createElement("pre", null, JSON.stringify(result, null, 2))), error && /* @__PURE__ */ React25__namespace.default.createElement("div", {
2194
+ className: "lui-action-button-error"
2195
+ }, error.message));
2196
+ }
2197
+ chunk3PV26V5F_js.__name(ActionButton, "ActionButton");
2198
+ function DefaultLoading2() {
2199
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2200
+ className: "flex items-center justify-center p-8"
2201
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2, {
2202
+ className: "h-6 w-6 animate-spin text-muted-foreground"
2203
+ }));
2204
+ }
2205
+ chunk3PV26V5F_js.__name(DefaultLoading2, "DefaultLoading");
2206
+ function DefaultDisconnected() {
2207
+ return /* @__PURE__ */ React25__namespace.createElement(Alert, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.WifiOff, {
2208
+ className: "h-4 w-4"
2209
+ }), /* @__PURE__ */ React25__namespace.createElement(AlertDescription, null, "Waiting for connection to MCP host..."));
2210
+ }
2211
+ chunk3PV26V5F_js.__name(DefaultDisconnected, "DefaultDisconnected");
2212
+ function DefaultError2({ error }) {
2213
+ return /* @__PURE__ */ React25__namespace.createElement(Alert, {
2214
+ variant: "destructive"
2215
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlertCircle, {
2216
+ className: "h-4 w-4"
2217
+ }), /* @__PURE__ */ React25__namespace.createElement(AlertDescription, null, "Connection error: ", error.message));
2218
+ }
2219
+ chunk3PV26V5F_js.__name(DefaultError2, "DefaultError");
2220
+ function RequireConnection({ loading: loadingContent, error: errorContent, disconnected: disconnectedContent, children, className }) {
2221
+ const { isConnected, error, app } = useMcpApp();
2222
+ if (!app && !error && !isConnected) {
2223
+ if (loadingContent) {
2224
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2225
+ className
2226
+ }, loadingContent);
2227
+ }
2228
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2229
+ className
2230
+ }, /* @__PURE__ */ React25__namespace.createElement(DefaultLoading2, null));
2231
+ }
2232
+ if (error) {
2233
+ if (errorContent) {
2234
+ if (typeof errorContent === "function") {
2235
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2236
+ className
2237
+ }, errorContent(error));
2238
+ }
2239
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2240
+ className
2241
+ }, errorContent);
2242
+ }
2243
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2244
+ className
2245
+ }, /* @__PURE__ */ React25__namespace.createElement(DefaultError2, {
2246
+ error
2247
+ }));
2248
+ }
2249
+ if (!isConnected) {
2250
+ if (disconnectedContent) {
2251
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2252
+ className
2253
+ }, disconnectedContent);
2254
+ }
2255
+ if (loadingContent) {
2256
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2257
+ className
2258
+ }, loadingContent);
2259
+ }
2260
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2261
+ className
2262
+ }, /* @__PURE__ */ React25__namespace.createElement(DefaultDisconnected, null));
2263
+ }
2264
+ return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, children);
2265
+ }
2266
+ chunk3PV26V5F_js.__name(RequireConnection, "RequireConnection");
2267
+ function DefaultFallback({ error, onRetry }) {
2268
+ return /* @__PURE__ */ React25__namespace.createElement(Alert, {
2269
+ variant: "destructive"
2270
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlertCircle, {
2271
+ className: "h-4 w-4"
2272
+ }), /* @__PURE__ */ React25__namespace.createElement(AlertTitle, null, "Something went wrong"), /* @__PURE__ */ React25__namespace.createElement(AlertDescription, {
2273
+ className: "flex flex-col gap-3"
2274
+ }, /* @__PURE__ */ React25__namespace.createElement("p", {
2275
+ className: "text-sm"
2276
+ }, error.message), /* @__PURE__ */ React25__namespace.createElement(Button, {
2277
+ variant: "outline",
2278
+ size: "sm",
2279
+ onClick: onRetry,
2280
+ className: "w-fit"
2281
+ }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.RefreshCw, {
2282
+ className: "h-4 w-4 mr-2"
2283
+ }), "Try Again")));
2284
+ }
2285
+ chunk3PV26V5F_js.__name(DefaultFallback, "DefaultFallback");
2286
+ var ToolErrorBoundary = class extends React25.Component {
2287
+ static {
2288
+ chunk3PV26V5F_js.__name(this, "ToolErrorBoundary");
2289
+ }
2290
+ constructor(props) {
2291
+ super(props);
2292
+ this.state = {
2293
+ hasError: false,
2294
+ error: null
2295
+ };
2296
+ }
2297
+ static getDerivedStateFromError(error) {
2298
+ return {
2299
+ hasError: true,
2300
+ error
2301
+ };
2302
+ }
2303
+ componentDidCatch(error, errorInfo) {
2304
+ this.props.onError?.(error, errorInfo);
2305
+ }
2306
+ componentDidUpdate(prevProps) {
2307
+ if (this.state.hasError && this.props.resetKeys && prevProps.resetKeys && this.props.resetKeys.some((key, index) => key !== prevProps.resetKeys?.[index])) {
2308
+ this.reset();
2309
+ }
2310
+ }
2311
+ reset = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
2312
+ this.setState({
2313
+ hasError: false,
2314
+ error: null
2315
+ });
2316
+ }, "reset");
2317
+ render() {
2318
+ const { hasError, error } = this.state;
2319
+ const { fallback, children } = this.props;
2320
+ if (hasError && error) {
2321
+ if (fallback) {
2322
+ if (typeof fallback === "function") {
2323
+ return fallback(error, this.reset);
2324
+ }
2325
+ return fallback;
2326
+ }
2327
+ return /* @__PURE__ */ React25__namespace.createElement(DefaultFallback, {
2328
+ error,
2329
+ onRetry: this.reset
2330
+ });
2331
+ }
2332
+ return children;
2333
+ }
2334
+ };
2335
+ function useMessage() {
2336
+ const { sendMessage: appSendMessage, isConnected } = useMcpApp();
2337
+ const [sending, setSending] = React25.useState(false);
2338
+ const [error, setError] = React25.useState(null);
2339
+ const send = React25.useCallback(async (text) => {
2340
+ if (!isConnected) {
2341
+ console.warn("[useMessage] Not connected to host");
2342
+ return;
2343
+ }
2344
+ setSending(true);
2345
+ setError(null);
2346
+ try {
2347
+ await appSendMessage(text);
2348
+ } catch (err) {
2349
+ const error2 = err instanceof Error ? err : new Error(String(err));
2350
+ setError(error2);
2351
+ throw error2;
2352
+ } finally {
2353
+ setSending(false);
2354
+ }
2355
+ }, [
2356
+ appSendMessage,
2357
+ isConnected
2358
+ ]);
2359
+ const sendContent = React25.useCallback(async (content) => {
2360
+ if (!isConnected) {
2361
+ console.warn("[useMessage] Not connected to host");
2362
+ return;
2363
+ }
2364
+ setSending(true);
2365
+ setError(null);
2366
+ try {
2367
+ const textContent = content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
2368
+ await appSendMessage(textContent);
2369
+ } catch (err) {
2370
+ const error2 = err instanceof Error ? err : new Error(String(err));
2371
+ setError(error2);
2372
+ throw error2;
2373
+ } finally {
2374
+ setSending(false);
2375
+ }
2376
+ }, [
2377
+ appSendMessage,
2378
+ isConnected
2379
+ ]);
2380
+ const requestTool = React25.useCallback(async (toolName, args) => {
2381
+ let message = `Please call the "${toolName}" tool`;
2382
+ if (args && Object.keys(args).length > 0) {
2383
+ message += ` with arguments: ${JSON.stringify(args)}`;
2384
+ }
2385
+ await send(message);
2386
+ }, [
2387
+ send
2388
+ ]);
2389
+ return {
2390
+ send,
2391
+ sendContent,
2392
+ requestTool,
2393
+ sending,
2394
+ error
2395
+ };
2396
+ }
2397
+ chunk3PV26V5F_js.__name(useMessage, "useMessage");
2398
+
2399
+ // src/mcp/useHostContext.ts
2400
+ function useHostContext() {
2401
+ const { hostContext } = useMcpApp();
2402
+ return {
2403
+ theme: hostContext.theme ?? "light",
2404
+ displayMode: hostContext.displayMode ?? "inline",
2405
+ availableDisplayModes: hostContext.availableDisplayModes ?? [],
2406
+ viewport: hostContext.viewport ?? null,
2407
+ locale: hostContext.locale ?? null,
2408
+ timeZone: hostContext.timeZone ?? null,
2409
+ platform: hostContext.platform ?? null,
2410
+ userAgent: hostContext.userAgent ?? null,
2411
+ deviceCapabilities: hostContext.deviceCapabilities ?? null,
2412
+ safeAreaInsets: hostContext.safeAreaInsets ?? null,
2413
+ styles: hostContext.styles ?? null,
2414
+ rawContext: hostContext
2415
+ };
2416
+ }
2417
+ chunk3PV26V5F_js.__name(useHostContext, "useHostContext");
2418
+
2419
+ // src/mcp/useToolResult.ts
2420
+ function useToolResult() {
2421
+ const { toolResult } = useMcpApp();
2422
+ let result = null;
2423
+ let textContent = null;
2424
+ if (toolResult) {
2425
+ if ("structuredContent" in toolResult && toolResult.structuredContent) {
2426
+ result = toolResult.structuredContent;
2427
+ }
2428
+ if (!result && toolResult.content) {
2429
+ const textItem = toolResult.content.find((c) => c.type === "text");
2430
+ if (textItem) {
2431
+ textContent = textItem.text;
2432
+ try {
2433
+ result = JSON.parse(textItem.text);
2434
+ } catch {
2435
+ }
2436
+ }
2437
+ }
2438
+ }
2439
+ return {
2440
+ result,
2441
+ rawResult: toolResult,
2442
+ hasResult: toolResult !== null,
2443
+ textContent
2444
+ };
2445
+ }
2446
+ chunk3PV26V5F_js.__name(useToolResult, "useToolResult");
2447
+
2448
+ // src/mcp/useToolInput.ts
2449
+ function useToolInput() {
2450
+ const { toolInput } = useMcpApp();
2451
+ return {
2452
+ input: toolInput,
2453
+ hasInput: toolInput !== null
2454
+ };
2455
+ }
2456
+ chunk3PV26V5F_js.__name(useToolInput, "useToolInput");
2457
+
2458
+ // src/mcp/useToolInputPartial.ts
2459
+ function useToolInputPartial() {
2460
+ const { toolInputPartial } = useMcpApp();
2461
+ return {
2462
+ partialArgs: toolInputPartial,
2463
+ isStreaming: toolInputPartial !== null
2464
+ };
2465
+ }
2466
+ chunk3PV26V5F_js.__name(useToolInputPartial, "useToolInputPartial");
2467
+ function useToolSubscription(toolName, options = {}) {
2468
+ const { interval = 1e4, enabled = true, args = {} } = options;
2469
+ const toolHook = useTool(toolName);
2470
+ const intervalRef = React25.useRef(null);
2471
+ const [isPolling, setIsPolling] = React25.useState(false);
2472
+ const stop = React25.useCallback(() => {
2473
+ if (intervalRef.current) {
2474
+ clearInterval(intervalRef.current);
2475
+ intervalRef.current = null;
2476
+ }
2477
+ setIsPolling(false);
2478
+ }, []);
2479
+ const start = React25.useCallback(() => {
2480
+ stop();
2481
+ setIsPolling(true);
2482
+ toolHook.call(args).catch(() => {
2483
+ });
2484
+ intervalRef.current = setInterval(() => {
2485
+ toolHook.call(args).catch(() => {
2486
+ });
2487
+ }, interval);
2488
+ }, [
2489
+ toolHook.call,
2490
+ args,
2491
+ interval,
2492
+ stop
2493
+ ]);
2494
+ const refresh = React25.useCallback(async () => {
2495
+ return toolHook.call(args);
2496
+ }, [
2497
+ toolHook.call,
2498
+ args
2499
+ ]);
2500
+ React25.useEffect(() => {
2501
+ if (enabled) {
2502
+ start();
2503
+ }
2504
+ return () => stop();
2505
+ }, [
2506
+ enabled,
2507
+ start,
2508
+ stop
2509
+ ]);
2510
+ return {
2511
+ result: toolHook.result,
2512
+ loading: toolHook.loading,
2513
+ error: toolHook.error,
2514
+ start,
2515
+ stop,
2516
+ isPolling,
2517
+ refresh
2518
+ };
2519
+ }
2520
+ chunk3PV26V5F_js.__name(useToolSubscription, "useToolSubscription");
2521
+
2522
+ // src/types/mcp-types.ts
2523
+ function normalizeToolBinding(tool) {
2524
+ if (typeof tool === "string") {
2525
+ return {
2526
+ name: tool
2527
+ };
2528
+ }
2529
+ return tool;
2530
+ }
2531
+ chunk3PV26V5F_js.__name(normalizeToolBinding, "normalizeToolBinding");
2532
+ var DEFAULT_RESULT_CONFIG = {
2533
+ display: "none",
2534
+ autoDismiss: 5e3
2535
+ };
2536
+ var INITIAL_TOOL_STATE = {
2537
+ state: "idle",
2538
+ loading: false,
2539
+ result: null,
2540
+ error: null,
2541
+ hasResult: false
2542
+ };
2543
+ function CardTitle({ className, ...props }) {
2544
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2545
+ "data-slot": "card-title",
2546
+ className: cn("leading-none font-semibold", className),
2547
+ ...props
2548
+ });
2549
+ }
2550
+ chunk3PV26V5F_js.__name(CardTitle, "CardTitle");
2551
+ function CardDescription({ className, ...props }) {
2552
+ return /* @__PURE__ */ React25__namespace.createElement("div", {
2553
+ "data-slot": "card-description",
2554
+ className: cn("text-muted-foreground text-sm", className),
2555
+ ...props
2556
+ });
2557
+ }
2558
+ chunk3PV26V5F_js.__name(CardDescription, "CardDescription");
2559
+ var Form = reactHookForm.FormProvider;
2560
+ var FormFieldContext = /* @__PURE__ */ React25__namespace.createContext({});
2561
+ var FormField = /* @__PURE__ */ chunk3PV26V5F_js.__name(({ ...props }) => {
2562
+ return /* @__PURE__ */ React25__namespace.createElement(FormFieldContext.Provider, {
2563
+ value: {
2564
+ name: props.name
2565
+ }
2566
+ }, /* @__PURE__ */ React25__namespace.createElement(reactHookForm.Controller, props));
2567
+ }, "FormField");
2568
+ var useFormField = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
2569
+ const fieldContext = React25__namespace.useContext(FormFieldContext);
2570
+ const itemContext = React25__namespace.useContext(FormItemContext);
2571
+ const { getFieldState } = reactHookForm.useFormContext();
2572
+ const formState = reactHookForm.useFormState({
2573
+ name: fieldContext.name
2574
+ });
2575
+ const fieldState = getFieldState(fieldContext.name, formState);
2576
+ if (!fieldContext) {
2577
+ throw new Error("useFormField should be used within <FormField>");
2578
+ }
2579
+ const { id } = itemContext;
2580
+ return {
2581
+ id,
2582
+ name: fieldContext.name,
2583
+ formItemId: `${id}-form-item`,
2584
+ formDescriptionId: `${id}-form-item-description`,
2585
+ formMessageId: `${id}-form-item-message`,
2586
+ ...fieldState
2587
+ };
2588
+ }, "useFormField");
2589
+ var FormItemContext = /* @__PURE__ */ React25__namespace.createContext({});
2590
+ function FormItem({ className, ...props }) {
2591
+ const id = React25__namespace.useId();
2592
+ return /* @__PURE__ */ React25__namespace.createElement(FormItemContext.Provider, {
2593
+ value: {
2594
+ id
2595
+ }
2596
+ }, /* @__PURE__ */ React25__namespace.createElement("div", {
2597
+ "data-slot": "form-item",
2598
+ className: cn("grid gap-2", className),
2599
+ ...props
2600
+ }));
2601
+ }
2602
+ chunk3PV26V5F_js.__name(FormItem, "FormItem");
2603
+ function FormLabel({ className, ...props }) {
2604
+ const { error, formItemId } = useFormField();
2605
+ return /* @__PURE__ */ React25__namespace.createElement(Label2, {
2606
+ "data-slot": "form-label",
2607
+ "data-error": !!error,
2608
+ className: cn("data-[error=true]:text-destructive", className),
2609
+ htmlFor: formItemId,
2610
+ ...props
2611
+ });
2612
+ }
2613
+ chunk3PV26V5F_js.__name(FormLabel, "FormLabel");
2614
+ function FormControl({ ...props }) {
2615
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
2616
+ return /* @__PURE__ */ React25__namespace.createElement(reactSlot.Slot, {
2617
+ "data-slot": "form-control",
2618
+ id: formItemId,
2619
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
2620
+ "aria-invalid": !!error,
2621
+ ...props
2622
+ });
2623
+ }
2624
+ chunk3PV26V5F_js.__name(FormControl, "FormControl");
2625
+ function FormDescription({ className, ...props }) {
2626
+ const { formDescriptionId } = useFormField();
2627
+ return /* @__PURE__ */ React25__namespace.createElement("p", {
2628
+ "data-slot": "form-description",
2629
+ id: formDescriptionId,
2630
+ className: cn("text-muted-foreground text-sm", className),
2631
+ ...props
2632
+ });
2633
+ }
2634
+ chunk3PV26V5F_js.__name(FormDescription, "FormDescription");
2635
+ function FormMessage({ className, ...props }) {
2636
+ const { error, formMessageId } = useFormField();
2637
+ const body = error ? String(error?.message ?? "") : props.children;
2638
+ if (!body) {
2639
+ return null;
2640
+ }
2641
+ return /* @__PURE__ */ React25__namespace.createElement("p", {
2642
+ "data-slot": "form-message",
2643
+ id: formMessageId,
2644
+ className: cn("text-destructive text-sm", className),
2645
+ ...props
2646
+ }, body);
2647
+ }
2648
+ chunk3PV26V5F_js.__name(FormMessage, "FormMessage");
2649
+ var badgeVariants = classVarianceAuthority.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", {
2650
+ variants: {
2651
+ variant: {
2652
+ default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
2653
+ secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
2654
+ destructive: "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
2655
+ outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"
2656
+ }
2657
+ },
2658
+ defaultVariants: {
2659
+ variant: "default"
2660
+ }
2661
+ });
2662
+ function Badge({ className, variant, asChild = false, ...props }) {
2663
+ const Comp = asChild ? reactSlot.Slot : "span";
2664
+ return /* @__PURE__ */ React25__namespace.createElement(Comp, {
2665
+ "data-slot": "badge",
2666
+ className: cn(badgeVariants({
2667
+ variant
2668
+ }), className),
2669
+ ...props
2670
+ });
2671
+ }
2672
+ chunk3PV26V5F_js.__name(Badge, "Badge");
2673
+ function TabsList({ className, ...props }) {
2674
+ return /* @__PURE__ */ React25__namespace.createElement(TabsPrimitive2__namespace.List, {
2675
+ "data-slot": "tabs-list",
2676
+ className: cn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]", className),
2677
+ ...props
2678
+ });
2679
+ }
2680
+ chunk3PV26V5F_js.__name(TabsList, "TabsList");
2681
+ function TabsTrigger({ className, ...props }) {
2682
+ return /* @__PURE__ */ React25__namespace.createElement(TabsPrimitive2__namespace.Trigger, {
2683
+ "data-slot": "tabs-trigger",
2684
+ className: cn("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
2685
+ ...props
2686
+ });
2687
+ }
2688
+ chunk3PV26V5F_js.__name(TabsTrigger, "TabsTrigger");
2689
+ function TabsContent({ className, ...props }) {
2690
+ return /* @__PURE__ */ React25__namespace.createElement(TabsPrimitive2__namespace.Content, {
2691
+ "data-slot": "tabs-content",
2692
+ className: cn("flex-1 outline-none", className),
2693
+ ...props
2694
+ });
2695
+ }
2696
+ chunk3PV26V5F_js.__name(TabsContent, "TabsContent");
2697
+ function Separator2({ className, orientation = "horizontal", decorative = true, ...props }) {
2698
+ return /* @__PURE__ */ React25__namespace.createElement(SeparatorPrimitive__namespace.Root, {
2699
+ "data-slot": "separator",
2700
+ decorative,
2701
+ orientation,
2702
+ className: cn("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px", className),
2703
+ ...props
2704
+ });
2705
+ }
2706
+ chunk3PV26V5F_js.__name(Separator2, "Separator");
2707
+ function ScrollArea({ className, children, ...props }) {
2708
+ return /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Root, {
2709
+ "data-slot": "scroll-area",
2710
+ className: cn("relative", className),
2711
+ ...props
2712
+ }, /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Viewport, {
2713
+ "data-slot": "scroll-area-viewport",
2714
+ className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
2715
+ }, children), /* @__PURE__ */ React25__namespace.createElement(ScrollBar, null), /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Corner, null));
2716
+ }
2717
+ chunk3PV26V5F_js.__name(ScrollArea, "ScrollArea");
2718
+ function ScrollBar({ className, orientation = "vertical", ...props }) {
2719
+ return /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaScrollbar, {
2720
+ "data-slot": "scroll-area-scrollbar",
2721
+ orientation,
2722
+ className: cn("flex touch-none p-px transition-colors select-none", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent", className),
2723
+ ...props
2724
+ }, /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaThumb, {
2725
+ "data-slot": "scroll-area-thumb",
2726
+ className: "bg-border relative flex-1 rounded-full"
2727
+ }));
2728
+ }
2729
+ chunk3PV26V5F_js.__name(ScrollBar, "ScrollBar");
2730
+ function DropdownMenu({ ...props }) {
2731
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Root, {
2732
+ "data-slot": "dropdown-menu",
2733
+ ...props
2734
+ });
2735
+ }
2736
+ chunk3PV26V5F_js.__name(DropdownMenu, "DropdownMenu");
2737
+ function DropdownMenuPortal({ ...props }) {
2738
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Portal, {
2739
+ "data-slot": "dropdown-menu-portal",
2740
+ ...props
2741
+ });
258
2742
  }
259
- __name(useTool, "useTool");
260
-
261
- // src/mcp/useToolResult.ts
262
- function useToolResult() {
263
- const { toolResult } = useMcpApp();
264
- let result = null;
265
- let textContent = null;
266
- if (toolResult) {
267
- if ("structuredContent" in toolResult && toolResult.structuredContent) {
268
- result = toolResult.structuredContent;
269
- }
270
- if (!result && toolResult.content) {
271
- const textItem = toolResult.content.find((c) => c.type === "text");
272
- if (textItem) {
273
- textContent = textItem.text;
274
- try {
275
- result = JSON.parse(textItem.text);
276
- } catch {
277
- }
278
- }
279
- }
280
- }
281
- return {
282
- result,
283
- rawResult: toolResult,
284
- hasResult: toolResult !== null,
285
- textContent
286
- };
2743
+ chunk3PV26V5F_js.__name(DropdownMenuPortal, "DropdownMenuPortal");
2744
+ function DropdownMenuTrigger({ ...props }) {
2745
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Trigger, {
2746
+ "data-slot": "dropdown-menu-trigger",
2747
+ ...props
2748
+ });
287
2749
  }
288
- __name(useToolResult, "useToolResult");
289
-
290
- // src/mcp/useToolInput.ts
291
- function useToolInput() {
292
- const { toolInput } = useMcpApp();
293
- return {
294
- input: toolInput,
295
- hasInput: toolInput !== null
296
- };
2750
+ chunk3PV26V5F_js.__name(DropdownMenuTrigger, "DropdownMenuTrigger");
2751
+ function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
2752
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Content, {
2753
+ "data-slot": "dropdown-menu-content",
2754
+ sideOffset,
2755
+ className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md", className),
2756
+ ...props
2757
+ }));
297
2758
  }
298
- __name(useToolInput, "useToolInput");
299
-
300
- // src/mcp/useToolInputPartial.ts
301
- function useToolInputPartial() {
302
- const { toolInputPartial } = useMcpApp();
303
- return {
304
- partialArgs: toolInputPartial,
305
- isStreaming: toolInputPartial !== null
306
- };
2759
+ chunk3PV26V5F_js.__name(DropdownMenuContent, "DropdownMenuContent");
2760
+ function DropdownMenuGroup({ ...props }) {
2761
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Group, {
2762
+ "data-slot": "dropdown-menu-group",
2763
+ ...props
2764
+ });
307
2765
  }
308
- __name(useToolInputPartial, "useToolInputPartial");
309
-
310
- // src/mcp/useHostContext.ts
311
- function useHostContext() {
312
- const { hostContext } = useMcpApp();
313
- return {
314
- theme: hostContext.theme ?? "light",
315
- displayMode: hostContext.displayMode ?? "inline",
316
- viewport: hostContext.viewport ?? null,
317
- locale: hostContext.locale ?? null,
318
- timeZone: hostContext.timeZone ?? null,
319
- platform: hostContext.platform ?? null,
320
- rawContext: hostContext
321
- };
2766
+ chunk3PV26V5F_js.__name(DropdownMenuGroup, "DropdownMenuGroup");
2767
+ function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
2768
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Item, {
2769
+ "data-slot": "dropdown-menu-item",
2770
+ "data-inset": inset,
2771
+ "data-variant": variant,
2772
+ className: cn("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
2773
+ ...props
2774
+ });
322
2775
  }
323
- __name(useHostContext, "useHostContext");
324
- var Button = /* @__PURE__ */ React7.forwardRef(({ className, variant = "primary", size = "md", loading = false, disabled, asChild = false, leftIcon, rightIcon, children, ...props }, ref) => {
325
- const Comp = asChild ? reactSlot.Slot : "button";
326
- return /* @__PURE__ */ React7__default.default.createElement(Comp, {
327
- ref,
328
- className: clsx.clsx("lui-button", `lui-button--${variant}`, `lui-button--${size}`, loading && "lui-button--loading", className),
329
- disabled: disabled || loading,
2776
+ chunk3PV26V5F_js.__name(DropdownMenuItem, "DropdownMenuItem");
2777
+ function DropdownMenuCheckboxItem({ className, children, checked, ...props }) {
2778
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.CheckboxItem, {
2779
+ "data-slot": "dropdown-menu-checkbox-item",
2780
+ className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
2781
+ checked,
330
2782
  ...props
331
- }, loading && /* @__PURE__ */ React7__default.default.createElement("span", {
332
- className: "lui-button__spinner",
333
- "aria-hidden": "true"
334
- }, /* @__PURE__ */ React7__default.default.createElement("svg", {
335
- viewBox: "0 0 24 24",
336
- fill: "none",
337
- className: "lui-spinner-icon"
338
- }, /* @__PURE__ */ React7__default.default.createElement("circle", {
339
- cx: "12",
340
- cy: "12",
341
- r: "10",
342
- stroke: "currentColor",
343
- strokeWidth: "3",
344
- strokeLinecap: "round",
345
- strokeDasharray: "32",
346
- strokeDashoffset: "12"
347
- }))), leftIcon && !loading && /* @__PURE__ */ React7__default.default.createElement("span", {
348
- className: "lui-button__icon"
349
- }, leftIcon), /* @__PURE__ */ React7__default.default.createElement("span", {
350
- className: "lui-button__content"
351
- }, children), rightIcon && /* @__PURE__ */ React7__default.default.createElement("span", {
352
- className: "lui-button__icon"
353
- }, rightIcon));
354
- });
355
- Button.displayName = "Button";
356
-
357
- // src/mcp/ActionButton.tsx
358
- function ActionButton({ toolName, toolArgs = {}, onToolSuccess, onToolError, showResult = false, renderResult, children, ...buttonProps }) {
359
- const { call, loading, result, error } = useTool(toolName);
360
- const [hasResult, setHasResult] = React7.useState(false);
361
- const handleClick = /* @__PURE__ */ __name(async () => {
362
- try {
363
- const res = await call(toolArgs);
364
- setHasResult(true);
365
- onToolSuccess?.(res);
366
- } catch (err) {
367
- onToolError?.(err instanceof Error ? err : new Error(String(err)));
368
- }
369
- }, "handleClick");
370
- return /* @__PURE__ */ React7__default.default.createElement("div", {
371
- className: "lui-action-button-wrapper"
372
- }, /* @__PURE__ */ React7__default.default.createElement(Button, {
373
- ...buttonProps,
374
- loading,
375
- onClick: handleClick
376
- }, children), showResult && hasResult && result !== null && /* @__PURE__ */ React7__default.default.createElement("div", {
377
- className: "lui-action-button-result"
378
- }, renderResult ? renderResult(result) : /* @__PURE__ */ React7__default.default.createElement("pre", null, JSON.stringify(result, null, 2))), error && /* @__PURE__ */ React7__default.default.createElement("div", {
379
- className: "lui-action-button-error"
380
- }, error.message));
2783
+ }, /* @__PURE__ */ React25__namespace.createElement("span", {
2784
+ className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"
2785
+ }, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.CheckIcon, {
2786
+ className: "size-4"
2787
+ }))), children);
381
2788
  }
382
- __name(ActionButton, "ActionButton");
383
- var Input = /* @__PURE__ */ React7.forwardRef(({ className, label, helperText, error, size = "md", leftElement, rightElement, fullWidth = false, id, ...props }, ref) => {
384
- const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
385
- const hasError = Boolean(error);
386
- return /* @__PURE__ */ React7__default.default.createElement("div", {
387
- className: clsx.clsx("lui-input-wrapper", fullWidth && "lui-input-wrapper--full-width", className)
388
- }, label && /* @__PURE__ */ React7__default.default.createElement("label", {
389
- htmlFor: inputId,
390
- className: "lui-input-label"
391
- }, label), /* @__PURE__ */ React7__default.default.createElement("div", {
392
- className: clsx.clsx("lui-input-container", `lui-input-container--${size}`, hasError && "lui-input-container--error", leftElement && "lui-input-container--has-left", rightElement && "lui-input-container--has-right")
393
- }, leftElement && /* @__PURE__ */ React7__default.default.createElement("span", {
394
- className: "lui-input-element lui-input-element--left"
395
- }, leftElement), /* @__PURE__ */ React7__default.default.createElement("input", {
396
- ref,
397
- id: inputId,
398
- className: "lui-input",
399
- "aria-invalid": hasError,
400
- "aria-describedby": error ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
2789
+ chunk3PV26V5F_js.__name(DropdownMenuCheckboxItem, "DropdownMenuCheckboxItem");
2790
+ function DropdownMenuRadioGroup({ ...props }) {
2791
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.RadioGroup, {
2792
+ "data-slot": "dropdown-menu-radio-group",
401
2793
  ...props
402
- }), rightElement && /* @__PURE__ */ React7__default.default.createElement("span", {
403
- className: "lui-input-element lui-input-element--right"
404
- }, rightElement)), (error || helperText) && /* @__PURE__ */ React7__default.default.createElement("p", {
405
- id: error ? `${inputId}-error` : `${inputId}-helper`,
406
- className: clsx.clsx("lui-input-message", error && "lui-input-message--error")
407
- }, error || helperText));
408
- });
409
- Input.displayName = "Input";
410
- function ToolForm({ toolName, fields, submitText = "Submit", onSuccess, onError, showResult = false, className }) {
411
- const { call, loading, result, error } = useTool(toolName);
412
- const [formData, setFormData] = React7.useState(() => {
413
- const initial = {};
414
- fields.forEach((field) => {
415
- if (field.defaultValue !== void 0) {
416
- initial[field.name] = field.defaultValue;
417
- }
418
- });
419
- return initial;
420
2794
  });
421
- const handleSubmit = /* @__PURE__ */ __name(async (e) => {
422
- e.preventDefault();
423
- const args = {};
424
- fields.forEach((field) => {
425
- const value = formData[field.name];
426
- if (field.type === "number" && value !== void 0) {
427
- args[field.name] = Number(value);
428
- } else {
429
- args[field.name] = value;
430
- }
431
- });
432
- try {
433
- const res = await call(args);
434
- onSuccess?.(res);
435
- } catch (err) {
436
- onError?.(err instanceof Error ? err : new Error(String(err)));
437
- }
438
- }, "handleSubmit");
439
- const handleChange = /* @__PURE__ */ __name((name, value) => {
440
- setFormData((prev) => ({
441
- ...prev,
442
- [name]: value
443
- }));
444
- }, "handleChange");
445
- return /* @__PURE__ */ React7__default.default.createElement("form", {
446
- className: clsx.clsx("lui-tool-form", className),
447
- onSubmit: handleSubmit
448
- }, /* @__PURE__ */ React7__default.default.createElement("div", {
449
- className: "lui-tool-form-fields"
450
- }, fields.map((field) => /* @__PURE__ */ React7__default.default.createElement("div", {
451
- key: field.name,
452
- className: "lui-tool-form-field"
453
- }, field.type === "textarea" ? /* @__PURE__ */ React7__default.default.createElement("div", {
454
- className: "lui-input-wrapper lui-input-wrapper--full-width"
455
- }, /* @__PURE__ */ React7__default.default.createElement("label", {
456
- className: "lui-input-label"
457
- }, field.label), /* @__PURE__ */ React7__default.default.createElement("textarea", {
458
- className: "lui-tool-form-textarea",
459
- name: field.name,
460
- placeholder: field.placeholder,
461
- required: field.required,
462
- value: formData[field.name] ?? "",
463
- onChange: /* @__PURE__ */ __name((e) => handleChange(field.name, e.target.value), "onChange")
464
- }), field.helperText && /* @__PURE__ */ React7__default.default.createElement("p", {
465
- className: "lui-input-message"
466
- }, field.helperText)) : /* @__PURE__ */ React7__default.default.createElement(Input, {
467
- fullWidth: true,
468
- label: field.label,
469
- type: field.type ?? "text",
470
- name: field.name,
471
- placeholder: field.placeholder,
472
- required: field.required,
473
- helperText: field.helperText,
474
- value: formData[field.name] ?? "",
475
- onChange: /* @__PURE__ */ __name((e) => handleChange(field.name, e.target.value), "onChange")
476
- })))), /* @__PURE__ */ React7__default.default.createElement("div", {
477
- className: "lui-tool-form-actions"
478
- }, /* @__PURE__ */ React7__default.default.createElement(Button, {
479
- type: "submit",
480
- loading
481
- }, submitText)), error && /* @__PURE__ */ React7__default.default.createElement("div", {
482
- className: "lui-tool-form-error"
483
- }, error.message), showResult && result !== null && /* @__PURE__ */ React7__default.default.createElement("div", {
484
- className: "lui-tool-form-result"
485
- }, /* @__PURE__ */ React7__default.default.createElement("pre", null, JSON.stringify(result, null, 2))));
486
- }
487
- __name(ToolForm, "ToolForm");
488
- var Card = /* @__PURE__ */ React7.forwardRef(({ className, variant = "default", padding = "md", interactive = false, children, ...props }, ref) => {
489
- return /* @__PURE__ */ React7__default.default.createElement("div", {
490
- ref,
491
- className: clsx.clsx("lui-card", `lui-card--${variant}`, `lui-card--padding-${padding}`, interactive && "lui-card--interactive", className),
2795
+ }
2796
+ chunk3PV26V5F_js.__name(DropdownMenuRadioGroup, "DropdownMenuRadioGroup");
2797
+ function DropdownMenuRadioItem({ className, children, ...props }) {
2798
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.RadioItem, {
2799
+ "data-slot": "dropdown-menu-radio-item",
2800
+ className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
492
2801
  ...props
493
- }, children);
494
- });
495
- Card.displayName = "Card";
496
- var CardHeader = /* @__PURE__ */ React7.forwardRef(({ className, title, description, action, children, ...props }, ref) => {
497
- return /* @__PURE__ */ React7__default.default.createElement("div", {
498
- ref,
499
- className: clsx.clsx("lui-card-header", className),
2802
+ }, /* @__PURE__ */ React25__namespace.createElement("span", {
2803
+ className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center"
2804
+ }, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.CircleIcon, {
2805
+ className: "size-2 fill-current"
2806
+ }))), children);
2807
+ }
2808
+ chunk3PV26V5F_js.__name(DropdownMenuRadioItem, "DropdownMenuRadioItem");
2809
+ function DropdownMenuLabel({ className, inset, ...props }) {
2810
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Label, {
2811
+ "data-slot": "dropdown-menu-label",
2812
+ "data-inset": inset,
2813
+ className: cn("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", className),
500
2814
  ...props
501
- }, (title || description) && /* @__PURE__ */ React7__default.default.createElement("div", {
502
- className: "lui-card-header__text"
503
- }, title && /* @__PURE__ */ React7__default.default.createElement("h3", {
504
- className: "lui-card-header__title"
505
- }, title), description && /* @__PURE__ */ React7__default.default.createElement("p", {
506
- className: "lui-card-header__description"
507
- }, description)), action && /* @__PURE__ */ React7__default.default.createElement("div", {
508
- className: "lui-card-header__action"
509
- }, action), children);
510
- });
511
- CardHeader.displayName = "CardHeader";
512
- var CardContent = /* @__PURE__ */ React7.forwardRef(({ className, children, ...props }, ref) => {
513
- return /* @__PURE__ */ React7__default.default.createElement("div", {
514
- ref,
515
- className: clsx.clsx("lui-card-content", className),
2815
+ });
2816
+ }
2817
+ chunk3PV26V5F_js.__name(DropdownMenuLabel, "DropdownMenuLabel");
2818
+ function DropdownMenuSeparator({ className, ...props }) {
2819
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Separator, {
2820
+ "data-slot": "dropdown-menu-separator",
2821
+ className: cn("bg-border -mx-1 my-1 h-px", className),
516
2822
  ...props
517
- }, children);
518
- });
519
- CardContent.displayName = "CardContent";
520
- var CardFooter = /* @__PURE__ */ React7.forwardRef(({ className, children, ...props }, ref) => {
521
- return /* @__PURE__ */ React7__default.default.createElement("div", {
522
- ref,
523
- className: clsx.clsx("lui-card-footer", className),
2823
+ });
2824
+ }
2825
+ chunk3PV26V5F_js.__name(DropdownMenuSeparator, "DropdownMenuSeparator");
2826
+ function DropdownMenuShortcut({ className, ...props }) {
2827
+ return /* @__PURE__ */ React25__namespace.createElement("span", {
2828
+ "data-slot": "dropdown-menu-shortcut",
2829
+ className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className),
524
2830
  ...props
525
- }, children);
526
- });
527
- CardFooter.displayName = "CardFooter";
2831
+ });
2832
+ }
2833
+ chunk3PV26V5F_js.__name(DropdownMenuShortcut, "DropdownMenuShortcut");
2834
+ function DropdownMenuSub({ ...props }) {
2835
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Sub, {
2836
+ "data-slot": "dropdown-menu-sub",
2837
+ ...props
2838
+ });
2839
+ }
2840
+ chunk3PV26V5F_js.__name(DropdownMenuSub, "DropdownMenuSub");
2841
+ function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
2842
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.SubTrigger, {
2843
+ "data-slot": "dropdown-menu-sub-trigger",
2844
+ "data-inset": inset,
2845
+ className: cn("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
2846
+ ...props
2847
+ }, children, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronRightIcon, {
2848
+ className: "ml-auto size-4"
2849
+ }));
2850
+ }
2851
+ chunk3PV26V5F_js.__name(DropdownMenuSubTrigger, "DropdownMenuSubTrigger");
2852
+ function DropdownMenuSubContent({ className, ...props }) {
2853
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.SubContent, {
2854
+ "data-slot": "dropdown-menu-sub-content",
2855
+ className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg", className),
2856
+ ...props
2857
+ });
2858
+ }
2859
+ chunk3PV26V5F_js.__name(DropdownMenuSubContent, "DropdownMenuSubContent");
2860
+ function TooltipProvider({ delayDuration = 0, ...props }) {
2861
+ return /* @__PURE__ */ React25__namespace.createElement(TooltipPrimitive__namespace.Provider, {
2862
+ "data-slot": "tooltip-provider",
2863
+ delayDuration,
2864
+ ...props
2865
+ });
2866
+ }
2867
+ chunk3PV26V5F_js.__name(TooltipProvider, "TooltipProvider");
2868
+ function Tooltip({ ...props }) {
2869
+ return /* @__PURE__ */ React25__namespace.createElement(TooltipProvider, null, /* @__PURE__ */ React25__namespace.createElement(TooltipPrimitive__namespace.Root, {
2870
+ "data-slot": "tooltip",
2871
+ ...props
2872
+ }));
2873
+ }
2874
+ chunk3PV26V5F_js.__name(Tooltip, "Tooltip");
2875
+ function TooltipTrigger({ ...props }) {
2876
+ return /* @__PURE__ */ React25__namespace.createElement(TooltipPrimitive__namespace.Trigger, {
2877
+ "data-slot": "tooltip-trigger",
2878
+ ...props
2879
+ });
2880
+ }
2881
+ chunk3PV26V5F_js.__name(TooltipTrigger, "TooltipTrigger");
2882
+ function TooltipContent({ className, sideOffset = 0, children, ...props }) {
2883
+ return /* @__PURE__ */ React25__namespace.createElement(TooltipPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(TooltipPrimitive__namespace.Content, {
2884
+ "data-slot": "tooltip-content",
2885
+ sideOffset,
2886
+ className: cn("bg-foreground text-background 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance", className),
2887
+ ...props
2888
+ }, children, /* @__PURE__ */ React25__namespace.createElement(TooltipPrimitive__namespace.Arrow, {
2889
+ className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"
2890
+ })));
2891
+ }
2892
+ chunk3PV26V5F_js.__name(TooltipContent, "TooltipContent");
528
2893
  function DataGrid({ data, columns, searchable = false, searchPlaceholder = "Search...", onRowClick, loading = false, emptyMessage = "No data", className }) {
529
- const [sorting, setSorting] = React7.useState([]);
530
- const [globalFilter, setGlobalFilter] = React7.useState("");
531
- const tableColumns = React7.useMemo(() => columns.map((col) => ({
2894
+ const [sorting, setSorting] = React25.useState([]);
2895
+ const [globalFilter, setGlobalFilter] = React25.useState("");
2896
+ const tableColumns = React25.useMemo(() => columns.map((col) => ({
532
2897
  id: String(col.key),
533
2898
  accessorKey: col.key,
534
2899
  header: col.header,
@@ -551,49 +2916,49 @@ function DataGrid({ data, columns, searchable = false, searchPlaceholder = "Sear
551
2916
  getSortedRowModel: reactTable.getSortedRowModel(),
552
2917
  getFilteredRowModel: reactTable.getFilteredRowModel()
553
2918
  });
554
- return /* @__PURE__ */ React7__default.default.createElement("div", {
2919
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
555
2920
  className: clsx.clsx("lui-datagrid", className)
556
- }, searchable && /* @__PURE__ */ React7__default.default.createElement("div", {
2921
+ }, searchable && /* @__PURE__ */ React25__namespace.default.createElement("div", {
557
2922
  className: "lui-datagrid-search"
558
- }, /* @__PURE__ */ React7__default.default.createElement("input", {
2923
+ }, /* @__PURE__ */ React25__namespace.default.createElement("input", {
559
2924
  type: "text",
560
2925
  value: globalFilter,
561
- onChange: /* @__PURE__ */ __name((e) => setGlobalFilter(e.target.value), "onChange"),
2926
+ onChange: /* @__PURE__ */ chunk3PV26V5F_js.__name((e) => setGlobalFilter(e.target.value), "onChange"),
562
2927
  placeholder: searchPlaceholder,
563
2928
  className: "lui-datagrid-search-input"
564
- })), /* @__PURE__ */ React7__default.default.createElement("div", {
2929
+ })), /* @__PURE__ */ React25__namespace.default.createElement("div", {
565
2930
  className: "lui-datagrid-container"
566
- }, /* @__PURE__ */ React7__default.default.createElement("table", {
2931
+ }, /* @__PURE__ */ React25__namespace.default.createElement("table", {
567
2932
  className: "lui-datagrid-table"
568
- }, /* @__PURE__ */ React7__default.default.createElement("thead", null, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ React7__default.default.createElement("tr", {
2933
+ }, /* @__PURE__ */ React25__namespace.default.createElement("thead", null, table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ React25__namespace.default.createElement("tr", {
569
2934
  key: headerGroup.id
570
- }, headerGroup.headers.map((header) => /* @__PURE__ */ React7__default.default.createElement("th", {
2935
+ }, headerGroup.headers.map((header) => /* @__PURE__ */ React25__namespace.default.createElement("th", {
571
2936
  key: header.id,
572
2937
  className: clsx.clsx("lui-datagrid-th", header.column.getCanSort() && "lui-datagrid-th--sortable"),
573
2938
  onClick: header.column.getToggleSortingHandler(),
574
2939
  style: {
575
2940
  width: header.column.getSize()
576
2941
  }
577
- }, /* @__PURE__ */ React7__default.default.createElement("div", {
2942
+ }, /* @__PURE__ */ React25__namespace.default.createElement("div", {
578
2943
  className: "lui-datagrid-th-content"
579
- }, reactTable.flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted() && /* @__PURE__ */ React7__default.default.createElement("span", {
2944
+ }, reactTable.flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted() && /* @__PURE__ */ React25__namespace.default.createElement("span", {
580
2945
  className: "lui-datagrid-sort-icon"
581
- }, header.column.getIsSorted() === "asc" ? "\u2191" : "\u2193"))))))), /* @__PURE__ */ React7__default.default.createElement("tbody", null, loading ? /* @__PURE__ */ React7__default.default.createElement("tr", null, /* @__PURE__ */ React7__default.default.createElement("td", {
2946
+ }, header.column.getIsSorted() === "asc" ? "\u2191" : "\u2193"))))))), /* @__PURE__ */ React25__namespace.default.createElement("tbody", null, loading ? /* @__PURE__ */ React25__namespace.default.createElement("tr", null, /* @__PURE__ */ React25__namespace.default.createElement("td", {
582
2947
  colSpan: columns.length,
583
2948
  className: "lui-datagrid-loading"
584
- }, "Loading...")) : table.getRowModel().rows.length === 0 ? /* @__PURE__ */ React7__default.default.createElement("tr", null, /* @__PURE__ */ React7__default.default.createElement("td", {
2949
+ }, "Loading...")) : table.getRowModel().rows.length === 0 ? /* @__PURE__ */ React25__namespace.default.createElement("tr", null, /* @__PURE__ */ React25__namespace.default.createElement("td", {
585
2950
  colSpan: columns.length,
586
2951
  className: "lui-datagrid-empty"
587
- }, emptyMessage)) : table.getRowModel().rows.map((row) => /* @__PURE__ */ React7__default.default.createElement("tr", {
2952
+ }, emptyMessage)) : table.getRowModel().rows.map((row) => /* @__PURE__ */ React25__namespace.default.createElement("tr", {
588
2953
  key: row.id,
589
2954
  className: clsx.clsx("lui-datagrid-row", onRowClick && "lui-datagrid-row--clickable"),
590
- onClick: /* @__PURE__ */ __name(() => onRowClick?.(row.original), "onClick")
591
- }, row.getVisibleCells().map((cell) => /* @__PURE__ */ React7__default.default.createElement("td", {
2955
+ onClick: /* @__PURE__ */ chunk3PV26V5F_js.__name(() => onRowClick?.(row.original), "onClick")
2956
+ }, row.getVisibleCells().map((cell) => /* @__PURE__ */ React25__namespace.default.createElement("td", {
592
2957
  key: cell.id,
593
2958
  className: "lui-datagrid-td"
594
2959
  }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())))))))));
595
2960
  }
596
- __name(DataGrid, "DataGrid");
2961
+ chunk3PV26V5F_js.__name(DataGrid, "DataGrid");
597
2962
  chart_js.Chart.register(chart_js.CategoryScale, chart_js.LinearScale, chart_js.PointElement, chart_js.LineElement, chart_js.BarElement, chart_js.ArcElement, chart_js.Title, chart_js.Tooltip, chart_js.Legend);
598
2963
  function Chart({ type, data, options, height = 300, width = "100%", className }) {
599
2964
  const defaultOptions = {
@@ -647,143 +3012,419 @@ function Chart({ type, data, options, height = 300, width = "100%", className })
647
3012
  ...options?.plugins
648
3013
  }
649
3014
  };
650
- return /* @__PURE__ */ React7__default.default.createElement("div", {
3015
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
651
3016
  className: clsx.clsx("lui-chart", className),
652
3017
  style: {
653
3018
  height,
654
3019
  width
655
3020
  }
656
- }, /* @__PURE__ */ React7__default.default.createElement(reactChartjs2.Chart, {
3021
+ }, /* @__PURE__ */ React25__namespace.default.createElement(reactChartjs2.Chart, {
657
3022
  type,
658
3023
  data,
659
3024
  options: mergedOptions
660
3025
  }));
661
3026
  }
662
- __name(Chart, "Chart");
3027
+ chunk3PV26V5F_js.__name(Chart, "Chart");
663
3028
  function AppShell({ header, sidebar, footer, sidebarPosition = "left", sidebarWidth = 240, autoResize = true, padding = "md", className, children, ...props }) {
664
- const containerRef = React7.useRef(null);
665
- React7.useEffect(() => {
3029
+ const containerRef = React25.useRef(null);
3030
+ const { app } = useMcpApp();
3031
+ React25.useEffect(() => {
666
3032
  if (!autoResize || !containerRef.current) return;
667
- const resizeObserver = new ResizeObserver((entries) => {
668
- for (const entry of entries) {
669
- const { height } = entry.contentRect;
670
- window.parent.postMessage({
671
- type: "resize",
672
- height: Math.ceil(height)
673
- }, "*");
674
- }
675
- });
3033
+ if (!app) return;
3034
+ let lastWidth = 0;
3035
+ let lastHeight = 0;
3036
+ let scheduled = false;
3037
+ const sendSizeChanged = /* @__PURE__ */ chunk3PV26V5F_js.__name(() => {
3038
+ if (scheduled) return;
3039
+ scheduled = true;
3040
+ requestAnimationFrame(() => {
3041
+ scheduled = false;
3042
+ if (!containerRef.current) return;
3043
+ const rect = containerRef.current.getBoundingClientRect();
3044
+ const width = Math.ceil(rect.width);
3045
+ const height = Math.ceil(rect.height);
3046
+ if (width !== lastWidth || height !== lastHeight) {
3047
+ lastWidth = width;
3048
+ lastHeight = height;
3049
+ app.sendSizeChanged({
3050
+ width,
3051
+ height
3052
+ });
3053
+ }
3054
+ });
3055
+ }, "sendSizeChanged");
3056
+ const resizeObserver = new ResizeObserver(sendSizeChanged);
676
3057
  resizeObserver.observe(containerRef.current);
3058
+ sendSizeChanged();
677
3059
  return () => {
678
3060
  resizeObserver.disconnect();
679
3061
  };
680
3062
  }, [
681
- autoResize
3063
+ autoResize,
3064
+ app
682
3065
  ]);
683
3066
  const sidebarStyle = {
684
3067
  width: typeof sidebarWidth === "number" ? `${sidebarWidth}px` : sidebarWidth,
685
3068
  flexShrink: 0
686
3069
  };
687
- return /* @__PURE__ */ React7__default.default.createElement("div", {
3070
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
688
3071
  ref: containerRef,
689
3072
  className: clsx.clsx("lui-app-shell", `lui-app-shell--padding-${padding}`, className),
690
3073
  ...props
691
- }, header && /* @__PURE__ */ React7__default.default.createElement("header", {
3074
+ }, header && /* @__PURE__ */ React25__namespace.default.createElement("header", {
692
3075
  className: "lui-app-shell-header"
693
- }, header), /* @__PURE__ */ React7__default.default.createElement("div", {
3076
+ }, header), /* @__PURE__ */ React25__namespace.default.createElement("div", {
694
3077
  className: "lui-app-shell-body"
695
- }, sidebar && sidebarPosition === "left" && /* @__PURE__ */ React7__default.default.createElement("aside", {
3078
+ }, sidebar && sidebarPosition === "left" && /* @__PURE__ */ React25__namespace.default.createElement("aside", {
696
3079
  className: "lui-app-shell-sidebar",
697
3080
  style: sidebarStyle
698
- }, sidebar), /* @__PURE__ */ React7__default.default.createElement("main", {
3081
+ }, sidebar), /* @__PURE__ */ React25__namespace.default.createElement("main", {
699
3082
  className: "lui-app-shell-main"
700
- }, children), sidebar && sidebarPosition === "right" && /* @__PURE__ */ React7__default.default.createElement("aside", {
3083
+ }, children), sidebar && sidebarPosition === "right" && /* @__PURE__ */ React25__namespace.default.createElement("aside", {
701
3084
  className: "lui-app-shell-sidebar",
702
3085
  style: sidebarStyle
703
- }, sidebar)), footer && /* @__PURE__ */ React7__default.default.createElement("footer", {
3086
+ }, sidebar)), footer && /* @__PURE__ */ React25__namespace.default.createElement("footer", {
704
3087
  className: "lui-app-shell-footer"
705
3088
  }, footer));
706
3089
  }
707
- __name(AppShell, "AppShell");
3090
+ chunk3PV26V5F_js.__name(AppShell, "AppShell");
3091
+ function Tabs2({ tabs, defaultValue, value, onValueChange, children, className }) {
3092
+ const defaultTab = defaultValue || tabs[0]?.value;
3093
+ return /* @__PURE__ */ React25__namespace.default.createElement(TabsPrimitive2__namespace.Root, {
3094
+ className: clsx.clsx("lui-tabs", className),
3095
+ defaultValue: defaultTab,
3096
+ value,
3097
+ onValueChange
3098
+ }, /* @__PURE__ */ React25__namespace.default.createElement(TabsPrimitive2__namespace.List, {
3099
+ className: "lui-tabs-list"
3100
+ }, tabs.map((tab) => /* @__PURE__ */ React25__namespace.default.createElement(TabsPrimitive2__namespace.Trigger, {
3101
+ key: tab.value,
3102
+ value: tab.value,
3103
+ disabled: tab.disabled,
3104
+ className: "lui-tabs-trigger"
3105
+ }, tab.label))), children);
3106
+ }
3107
+ chunk3PV26V5F_js.__name(Tabs2, "Tabs");
3108
+ function TabContent({ value, children, className }) {
3109
+ return /* @__PURE__ */ React25__namespace.default.createElement(TabsPrimitive2__namespace.Content, {
3110
+ value,
3111
+ className: clsx.clsx("lui-tabs-content", className)
3112
+ }, children);
3113
+ }
3114
+ chunk3PV26V5F_js.__name(TabContent, "TabContent");
3115
+ function Modal({ open, defaultOpen, onOpenChange, title, description, children, className, trigger }) {
3116
+ return /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Root, {
3117
+ open,
3118
+ defaultOpen,
3119
+ onOpenChange
3120
+ }, trigger && /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Trigger, {
3121
+ asChild: true
3122
+ }, trigger), /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Overlay, {
3123
+ className: "lui-modal-overlay"
3124
+ }), /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Content, {
3125
+ className: clsx.clsx("lui-modal-content", className)
3126
+ }, title && /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Title, {
3127
+ className: "lui-modal-title"
3128
+ }, title), description && /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Description, {
3129
+ className: "lui-modal-description"
3130
+ }, description), children, /* @__PURE__ */ React25__namespace.default.createElement(DialogPrimitive__namespace.Close, {
3131
+ className: "lui-modal-close",
3132
+ "aria-label": "Close"
3133
+ }, /* @__PURE__ */ React25__namespace.default.createElement(CloseIcon, null)))));
3134
+ }
3135
+ chunk3PV26V5F_js.__name(Modal, "Modal");
3136
+ function CloseIcon() {
3137
+ return /* @__PURE__ */ React25__namespace.default.createElement("svg", {
3138
+ width: "14",
3139
+ height: "14",
3140
+ viewBox: "0 0 14 14",
3141
+ fill: "none"
3142
+ }, /* @__PURE__ */ React25__namespace.default.createElement("path", {
3143
+ d: "M3.5 3.5L10.5 10.5M10.5 3.5L3.5 10.5",
3144
+ stroke: "currentColor",
3145
+ strokeWidth: "1.5",
3146
+ strokeLinecap: "round"
3147
+ }));
3148
+ }
3149
+ chunk3PV26V5F_js.__name(CloseIcon, "CloseIcon");
708
3150
  function CodeBlock({ code, language = "text", showLineNumbers = false, copyable = true, className }) {
709
- const [copied, setCopied] = React7__default.default.useState(false);
710
- const handleCopy = /* @__PURE__ */ __name(async () => {
3151
+ const [copied, setCopied] = React25__namespace.default.useState(false);
3152
+ const handleCopy = /* @__PURE__ */ chunk3PV26V5F_js.__name(async () => {
711
3153
  await navigator.clipboard.writeText(code);
712
3154
  setCopied(true);
713
3155
  setTimeout(() => setCopied(false), 2e3);
714
3156
  }, "handleCopy");
715
- return /* @__PURE__ */ React7__default.default.createElement("div", {
3157
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
716
3158
  className: clsx.clsx("lui-code-block", className)
717
- }, copyable && /* @__PURE__ */ React7__default.default.createElement("button", {
3159
+ }, copyable && /* @__PURE__ */ React25__namespace.default.createElement("button", {
718
3160
  type: "button",
719
3161
  className: "lui-code-block-copy",
720
3162
  onClick: handleCopy,
721
3163
  "aria-label": copied ? "Copied!" : "Copy code"
722
- }, copied ? /* @__PURE__ */ React7__default.default.createElement("svg", {
3164
+ }, copied ? /* @__PURE__ */ React25__namespace.default.createElement("svg", {
723
3165
  viewBox: "0 0 24 24",
724
3166
  fill: "none",
725
3167
  stroke: "currentColor",
726
3168
  strokeWidth: "2"
727
- }, /* @__PURE__ */ React7__default.default.createElement("polyline", {
3169
+ }, /* @__PURE__ */ React25__namespace.default.createElement("polyline", {
728
3170
  points: "20,6 9,17 4,12"
729
- })) : /* @__PURE__ */ React7__default.default.createElement("svg", {
3171
+ })) : /* @__PURE__ */ React25__namespace.default.createElement("svg", {
730
3172
  viewBox: "0 0 24 24",
731
3173
  fill: "none",
732
3174
  stroke: "currentColor",
733
3175
  strokeWidth: "2"
734
- }, /* @__PURE__ */ React7__default.default.createElement("rect", {
3176
+ }, /* @__PURE__ */ React25__namespace.default.createElement("rect", {
735
3177
  x: "9",
736
3178
  y: "9",
737
3179
  width: "13",
738
3180
  height: "13",
739
3181
  rx: "2",
740
3182
  ry: "2"
741
- }), /* @__PURE__ */ React7__default.default.createElement("path", {
3183
+ }), /* @__PURE__ */ React25__namespace.default.createElement("path", {
742
3184
  d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
743
- }))), /* @__PURE__ */ React7__default.default.createElement(prismReactRenderer.Highlight, {
3185
+ }))), /* @__PURE__ */ React25__namespace.default.createElement(prismReactRenderer.Highlight, {
744
3186
  theme: prismReactRenderer.themes.nightOwl,
745
3187
  code: code.trim(),
746
3188
  language
747
- }, ({ className: hlClassName, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React7__default.default.createElement("pre", {
3189
+ }, ({ className: hlClassName, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React25__namespace.default.createElement("pre", {
748
3190
  className: clsx.clsx("lui-code-block-pre", hlClassName),
749
3191
  style
750
- }, tokens.map((line, i) => /* @__PURE__ */ React7__default.default.createElement("div", {
3192
+ }, tokens.map((line, i) => /* @__PURE__ */ React25__namespace.default.createElement("div", {
751
3193
  key: i,
752
3194
  ...getLineProps({
753
3195
  line
754
3196
  })
755
- }, showLineNumbers && /* @__PURE__ */ React7__default.default.createElement("span", {
3197
+ }, showLineNumbers && /* @__PURE__ */ React25__namespace.default.createElement("span", {
756
3198
  className: "lui-code-block-line-number"
757
- }, i + 1), line.map((token, key) => /* @__PURE__ */ React7__default.default.createElement("span", {
3199
+ }, i + 1), line.map((token, key) => /* @__PURE__ */ React25__namespace.default.createElement("span", {
758
3200
  key,
759
3201
  ...getTokenProps({
760
3202
  token
761
3203
  })
762
3204
  })))))));
763
3205
  }
764
- __name(CodeBlock, "CodeBlock");
3206
+ chunk3PV26V5F_js.__name(CodeBlock, "CodeBlock");
3207
+ var Card2 = /* @__PURE__ */ React25.forwardRef(({ className, variant = "default", padding = "md", interactive = false, children, ...props }, ref) => {
3208
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
3209
+ ref,
3210
+ className: clsx.clsx("lui-card", `lui-card--${variant}`, `lui-card--padding-${padding}`, interactive && "lui-card--interactive", className),
3211
+ ...props
3212
+ }, children);
3213
+ });
3214
+ Card2.displayName = "Card";
3215
+ var CardHeader2 = /* @__PURE__ */ React25.forwardRef(({ className, title, description, action, children, ...props }, ref) => {
3216
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
3217
+ ref,
3218
+ className: clsx.clsx("lui-card-header", className),
3219
+ ...props
3220
+ }, (title || description) && /* @__PURE__ */ React25__namespace.default.createElement("div", {
3221
+ className: "lui-card-header__text"
3222
+ }, title && /* @__PURE__ */ React25__namespace.default.createElement("h3", {
3223
+ className: "lui-card-header__title"
3224
+ }, title), description && /* @__PURE__ */ React25__namespace.default.createElement("p", {
3225
+ className: "lui-card-header__description"
3226
+ }, description)), action && /* @__PURE__ */ React25__namespace.default.createElement("div", {
3227
+ className: "lui-card-header__action"
3228
+ }, action), children);
3229
+ });
3230
+ CardHeader2.displayName = "CardHeader";
3231
+ var CardContent2 = /* @__PURE__ */ React25.forwardRef(({ className, children, ...props }, ref) => {
3232
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
3233
+ ref,
3234
+ className: clsx.clsx("lui-card-content", className),
3235
+ ...props
3236
+ }, children);
3237
+ });
3238
+ CardContent2.displayName = "CardContent";
3239
+ var CardFooter2 = /* @__PURE__ */ React25.forwardRef(({ className, children, ...props }, ref) => {
3240
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
3241
+ ref,
3242
+ className: clsx.clsx("lui-card-footer", className),
3243
+ ...props
3244
+ }, children);
3245
+ });
3246
+ CardFooter2.displayName = "CardFooter";
3247
+ var Input2 = /* @__PURE__ */ React25.forwardRef(({ className, label, helperText, error, size = "md", leftElement, rightElement, fullWidth = false, id, ...props }, ref) => {
3248
+ const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
3249
+ const hasError = Boolean(error);
3250
+ return /* @__PURE__ */ React25__namespace.default.createElement("div", {
3251
+ className: clsx.clsx("lui-input-wrapper", fullWidth && "lui-input-wrapper--full-width", className)
3252
+ }, label && /* @__PURE__ */ React25__namespace.default.createElement("label", {
3253
+ htmlFor: inputId,
3254
+ className: "lui-input-label"
3255
+ }, label), /* @__PURE__ */ React25__namespace.default.createElement("div", {
3256
+ className: clsx.clsx("lui-input-container", `lui-input-container--${size}`, hasError && "lui-input-container--error", leftElement && "lui-input-container--has-left", rightElement && "lui-input-container--has-right")
3257
+ }, leftElement && /* @__PURE__ */ React25__namespace.default.createElement("span", {
3258
+ className: "lui-input-element lui-input-element--left"
3259
+ }, leftElement), /* @__PURE__ */ React25__namespace.default.createElement("input", {
3260
+ ref,
3261
+ id: inputId,
3262
+ className: "lui-input",
3263
+ "aria-invalid": hasError,
3264
+ "aria-describedby": error ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
3265
+ ...props
3266
+ }), rightElement && /* @__PURE__ */ React25__namespace.default.createElement("span", {
3267
+ className: "lui-input-element lui-input-element--right"
3268
+ }, rightElement)), (error || helperText) && /* @__PURE__ */ React25__namespace.default.createElement("p", {
3269
+ id: error ? `${inputId}-error` : `${inputId}-helper`,
3270
+ className: clsx.clsx("lui-input-message", error && "lui-input-message--error")
3271
+ }, error || helperText));
3272
+ });
3273
+ Input2.displayName = "Input";
765
3274
 
3275
+ Object.defineProperty(exports, "UIApp", {
3276
+ enumerable: true,
3277
+ get: function () { return chunk3PV26V5F_js.UIApp; }
3278
+ });
3279
+ Object.defineProperty(exports, "getUIAppMetadata", {
3280
+ enumerable: true,
3281
+ get: function () { return chunk3PV26V5F_js.getUIAppMetadata; }
3282
+ });
3283
+ Object.defineProperty(exports, "getUIAppUri", {
3284
+ enumerable: true,
3285
+ get: function () { return chunk3PV26V5F_js.getUIAppUri; }
3286
+ });
3287
+ Object.defineProperty(exports, "App", {
3288
+ enumerable: true,
3289
+ get: function () { return extApps.App; }
3290
+ });
3291
+ Object.defineProperty(exports, "PostMessageTransport", {
3292
+ enumerable: true,
3293
+ get: function () { return extApps.PostMessageTransport; }
3294
+ });
3295
+ Object.defineProperty(exports, "AppBridge", {
3296
+ enumerable: true,
3297
+ get: function () { return appBridge.AppBridge; }
3298
+ });
766
3299
  exports.ActionButton = ActionButton;
3300
+ exports.Alert = Alert;
3301
+ exports.AlertDescription = AlertDescription;
3302
+ exports.AlertTitle = AlertTitle;
767
3303
  exports.AppProvider = AppProvider;
768
3304
  exports.AppShell = AppShell;
769
- exports.Button = Button;
770
- exports.Card = Card;
771
- exports.CardContent = CardContent;
772
- exports.CardFooter = CardFooter;
773
- exports.CardHeader = CardHeader;
3305
+ exports.Badge = Badge;
3306
+ exports.Button = Button2;
3307
+ exports.Card = Card2;
3308
+ exports.CardContent = CardContent2;
3309
+ exports.CardDescription = CardDescription;
3310
+ exports.CardFooter = CardFooter2;
3311
+ exports.CardHeader = CardHeader2;
3312
+ exports.CardTitle = CardTitle;
774
3313
  exports.Chart = Chart;
3314
+ exports.Checkbox = Checkbox;
775
3315
  exports.CodeBlock = CodeBlock;
3316
+ exports.Command = Command;
3317
+ exports.CommandDialog = CommandDialog;
3318
+ exports.CommandEmpty = CommandEmpty;
3319
+ exports.CommandGroup = CommandGroup;
3320
+ exports.CommandInput = CommandInput;
3321
+ exports.CommandItem = CommandItem;
3322
+ exports.CommandList = CommandList;
3323
+ exports.CommandSeparator = CommandSeparator;
3324
+ exports.CommandShortcut = CommandShortcut;
3325
+ exports.DEFAULT_RESULT_CONFIG = DEFAULT_RESULT_CONFIG;
776
3326
  exports.DataGrid = DataGrid;
777
- exports.Input = Input;
3327
+ exports.Dialog = Dialog;
3328
+ exports.DialogClose = DialogClose;
3329
+ exports.DialogContent = DialogContent;
3330
+ exports.DialogDescription = DialogDescription;
3331
+ exports.DialogFooter = DialogFooter;
3332
+ exports.DialogHeader = DialogHeader;
3333
+ exports.DialogOverlay = DialogOverlay;
3334
+ exports.DialogPortal = DialogPortal;
3335
+ exports.DialogTitle = DialogTitle;
3336
+ exports.DialogTrigger = DialogTrigger;
3337
+ exports.DropdownMenu = DropdownMenu;
3338
+ exports.DropdownMenuCheckboxItem = DropdownMenuCheckboxItem;
3339
+ exports.DropdownMenuContent = DropdownMenuContent;
3340
+ exports.DropdownMenuGroup = DropdownMenuGroup;
3341
+ exports.DropdownMenuItem = DropdownMenuItem;
3342
+ exports.DropdownMenuLabel = DropdownMenuLabel;
3343
+ exports.DropdownMenuPortal = DropdownMenuPortal;
3344
+ exports.DropdownMenuRadioGroup = DropdownMenuRadioGroup;
3345
+ exports.DropdownMenuRadioItem = DropdownMenuRadioItem;
3346
+ exports.DropdownMenuSeparator = DropdownMenuSeparator;
3347
+ exports.DropdownMenuShortcut = DropdownMenuShortcut;
3348
+ exports.DropdownMenuSub = DropdownMenuSub;
3349
+ exports.DropdownMenuSubContent = DropdownMenuSubContent;
3350
+ exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
3351
+ exports.DropdownMenuTrigger = DropdownMenuTrigger;
3352
+ exports.Form = Form;
3353
+ exports.FormControl = FormControl;
3354
+ exports.FormDescription = FormDescription;
3355
+ exports.FormField = FormField;
3356
+ exports.FormItem = FormItem;
3357
+ exports.FormLabel = FormLabel;
3358
+ exports.FormMessage = FormMessage;
3359
+ exports.INITIAL_TOOL_STATE = INITIAL_TOOL_STATE;
3360
+ exports.Input = Input2;
3361
+ exports.Label = Label2;
3362
+ exports.Modal = Modal;
3363
+ exports.Popover = Popover;
3364
+ exports.PopoverAnchor = PopoverAnchor;
3365
+ exports.PopoverContent = PopoverContent;
3366
+ exports.PopoverTrigger = PopoverTrigger;
3367
+ exports.Progress = Progress;
3368
+ exports.RequireConnection = RequireConnection;
3369
+ exports.ResourceView = ResourceView;
3370
+ exports.ScrollArea = ScrollArea;
3371
+ exports.ScrollBar = ScrollBar;
3372
+ exports.Select = Select;
3373
+ exports.SelectContent = SelectContent;
3374
+ exports.SelectGroup = SelectGroup;
3375
+ exports.SelectItem = SelectItem;
3376
+ exports.SelectLabel = SelectLabel;
3377
+ exports.SelectScrollDownButton = SelectScrollDownButton;
3378
+ exports.SelectScrollUpButton = SelectScrollUpButton;
3379
+ exports.SelectSeparator = SelectSeparator;
3380
+ exports.SelectTrigger = SelectTrigger;
3381
+ exports.SelectValue = SelectValue;
3382
+ exports.Separator = Separator2;
3383
+ exports.Skeleton = Skeleton;
3384
+ exports.Slider = Slider;
3385
+ exports.StreamingContent = StreamingContent;
3386
+ exports.Switch = Switch;
3387
+ exports.TabContent = TabContent;
3388
+ exports.Table = Table;
3389
+ exports.TableBody = TableBody;
3390
+ exports.TableCaption = TableCaption;
3391
+ exports.TableCell = TableCell;
3392
+ exports.TableFooter = TableFooter;
3393
+ exports.TableHead = TableHead;
3394
+ exports.TableHeader = TableHeader;
3395
+ exports.TableRow = TableRow;
3396
+ exports.Tabs = Tabs2;
3397
+ exports.TabsContent = TabsContent;
3398
+ exports.TabsList = TabsList;
3399
+ exports.TabsTrigger = TabsTrigger;
3400
+ exports.Textarea = Textarea;
3401
+ exports.Toaster = Toaster;
3402
+ exports.ToolButton = ToolButton;
3403
+ exports.ToolDataGrid = ToolDataGrid;
3404
+ exports.ToolErrorBoundary = ToolErrorBoundary;
778
3405
  exports.ToolForm = ToolForm;
779
- exports.UIApp = UIApp;
780
- exports.getUIAppMetadata = getUIAppMetadata;
781
- exports.getUIAppUri = getUIAppUri;
3406
+ exports.ToolInput = ToolInput;
3407
+ exports.ToolProvider = ToolProvider;
3408
+ exports.ToolSelect = ToolSelect;
3409
+ exports.Tooltip = Tooltip;
3410
+ exports.TooltipContent = TooltipContent;
3411
+ exports.TooltipProvider = TooltipProvider;
3412
+ exports.TooltipTrigger = TooltipTrigger;
3413
+ exports.badgeVariants = badgeVariants;
3414
+ exports.buttonVariants = buttonVariants;
3415
+ exports.cn = cn;
3416
+ exports.normalizeToolBinding = normalizeToolBinding;
3417
+ exports.useFormField = useFormField;
782
3418
  exports.useHostContext = useHostContext;
783
3419
  exports.useMcpApp = useMcpApp;
3420
+ exports.useMessage = useMessage;
3421
+ exports.useResource = useResource;
784
3422
  exports.useTool = useTool;
3423
+ exports.useToolContext = useToolContext;
785
3424
  exports.useToolInput = useToolInput;
786
3425
  exports.useToolInputPartial = useToolInputPartial;
787
3426
  exports.useToolResult = useToolResult;
3427
+ exports.useToolStream = useToolStream;
3428
+ exports.useToolSubscription = useToolSubscription;
788
3429
  //# sourceMappingURL=index.js.map
789
3430
  //# sourceMappingURL=index.js.map