@leanmcp/ui 0.1.0 → 0.2.1

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