@mcpjam/inspector 0.8.2 → 0.9.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.
Files changed (180) hide show
  1. package/README.md +24 -6
  2. package/bin/start.js +82 -69
  3. package/dist/client/assets/index-C4nE74q5.css +1 -0
  4. package/dist/client/assets/index-CcfG-2LO.js +357 -0
  5. package/dist/client/assets/index-CcfG-2LO.js.map +1 -0
  6. package/dist/client/catalyst.png +0 -0
  7. package/dist/client/index.html +14 -0
  8. package/dist/main/main.cjs +1330 -0
  9. package/dist/preload/preload.js +26 -0
  10. package/dist/renderer/assets/index-CYiU4_x2.css +1 -0
  11. package/dist/renderer/assets/index-woGCpEdp.js +356 -0
  12. package/dist/renderer/catalyst.png +0 -0
  13. package/dist/renderer/demo_1.png +0 -0
  14. package/dist/renderer/demo_2.png +0 -0
  15. package/dist/renderer/demo_3.png +0 -0
  16. package/dist/renderer/file.svg +1 -0
  17. package/dist/renderer/globe.svg +1 -0
  18. package/dist/renderer/index.html +14 -0
  19. package/dist/renderer/mcp.svg +1 -0
  20. package/dist/renderer/mcp_jam.svg +12 -0
  21. package/dist/renderer/mcp_jam_dark.png +0 -0
  22. package/dist/renderer/mcp_jam_light.png +0 -0
  23. package/dist/renderer/next.svg +1 -0
  24. package/dist/renderer/vercel.svg +1 -0
  25. package/dist/renderer/window.svg +1 -0
  26. package/dist/server/index.js +1101 -0
  27. package/dist/server/index.js.map +1 -0
  28. package/package.json +32 -17
  29. package/.next/BUILD_ID +0 -1
  30. package/.next/app-build-manifest.json +0 -89
  31. package/.next/app-path-routes-manifest.json +0 -13
  32. package/.next/build-manifest.json +0 -33
  33. package/.next/cache/.previewinfo +0 -1
  34. package/.next/cache/.rscinfo +0 -1
  35. package/.next/cache/.tsbuildinfo +0 -1
  36. package/.next/cache/eslint/.cache_1pr0xfn +0 -1
  37. package/.next/cache/webpack/client-production/0.pack +0 -0
  38. package/.next/cache/webpack/client-production/index.pack +0 -0
  39. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  40. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  41. package/.next/cache/webpack/server-production/0.pack +0 -0
  42. package/.next/cache/webpack/server-production/index.pack +0 -0
  43. package/.next/diagnostics/build-diagnostics.json +0 -6
  44. package/.next/diagnostics/framework.json +0 -1
  45. package/.next/export-marker.json +0 -6
  46. package/.next/images-manifest.json +0 -57
  47. package/.next/next-minimal-server.js.nft.json +0 -1
  48. package/.next/next-server.js.nft.json +0 -1
  49. package/.next/package.json +0 -1
  50. package/.next/prerender-manifest.json +0 -41
  51. package/.next/react-loadable-manifest.json +0 -1
  52. package/.next/required-server-files.json +0 -318
  53. package/.next/routes-manifest.json +0 -65
  54. package/.next/server/app/_not-found/page.js +0 -2
  55. package/.next/server/app/_not-found/page.js.nft.json +0 -1
  56. package/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
  57. package/.next/server/app/api/mcp/chat/route.js +0 -45
  58. package/.next/server/app/api/mcp/chat/route.js.nft.json +0 -1
  59. package/.next/server/app/api/mcp/chat/route_client-reference-manifest.js +0 -1
  60. package/.next/server/app/api/mcp/connect/route.js +0 -1
  61. package/.next/server/app/api/mcp/connect/route.js.nft.json +0 -1
  62. package/.next/server/app/api/mcp/connect/route_client-reference-manifest.js +0 -1
  63. package/.next/server/app/api/mcp/prompts/get/route.js +0 -1
  64. package/.next/server/app/api/mcp/prompts/get/route.js.nft.json +0 -1
  65. package/.next/server/app/api/mcp/prompts/get/route_client-reference-manifest.js +0 -1
  66. package/.next/server/app/api/mcp/prompts/list/route.js +0 -1
  67. package/.next/server/app/api/mcp/prompts/list/route.js.nft.json +0 -1
  68. package/.next/server/app/api/mcp/prompts/list/route_client-reference-manifest.js +0 -1
  69. package/.next/server/app/api/mcp/resources/list/route.js +0 -1
  70. package/.next/server/app/api/mcp/resources/list/route.js.nft.json +0 -1
  71. package/.next/server/app/api/mcp/resources/list/route_client-reference-manifest.js +0 -1
  72. package/.next/server/app/api/mcp/resources/read/route.js +0 -1
  73. package/.next/server/app/api/mcp/resources/read/route.js.nft.json +0 -1
  74. package/.next/server/app/api/mcp/resources/read/route_client-reference-manifest.js +0 -1
  75. package/.next/server/app/api/mcp/tools/route.js +0 -21
  76. package/.next/server/app/api/mcp/tools/route.js.nft.json +0 -1
  77. package/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +0 -1
  78. package/.next/server/app/favicon.ico/route.js +0 -1
  79. package/.next/server/app/favicon.ico/route.js.nft.json +0 -1
  80. package/.next/server/app/favicon.ico.body +0 -0
  81. package/.next/server/app/favicon.ico.meta +0 -1
  82. package/.next/server/app/oauth/callback/page.js +0 -2
  83. package/.next/server/app/oauth/callback/page.js.nft.json +0 -1
  84. package/.next/server/app/oauth/callback/page_client-reference-manifest.js +0 -1
  85. package/.next/server/app/page.js +0 -16
  86. package/.next/server/app/page.js.nft.json +0 -1
  87. package/.next/server/app/page_client-reference-manifest.js +0 -1
  88. package/.next/server/app-paths-manifest.json +0 -13
  89. package/.next/server/chunks/175.js +0 -8
  90. package/.next/server/chunks/260.js +0 -82
  91. package/.next/server/chunks/546.js +0 -1
  92. package/.next/server/chunks/548.js +0 -6
  93. package/.next/server/chunks/55.js +0 -1
  94. package/.next/server/chunks/985.js +0 -22
  95. package/.next/server/functions-config-manifest.json +0 -4
  96. package/.next/server/interception-route-rewrite-manifest.js +0 -1
  97. package/.next/server/middleware-build-manifest.js +0 -1
  98. package/.next/server/middleware-manifest.json +0 -6
  99. package/.next/server/middleware-react-loadable-manifest.js +0 -1
  100. package/.next/server/next-font-manifest.js +0 -1
  101. package/.next/server/next-font-manifest.json +0 -1
  102. package/.next/server/pages/500.html +0 -1
  103. package/.next/server/pages/_app.js +0 -1
  104. package/.next/server/pages/_app.js.nft.json +0 -1
  105. package/.next/server/pages/_document.js +0 -1
  106. package/.next/server/pages/_document.js.nft.json +0 -1
  107. package/.next/server/pages/_error.js +0 -19
  108. package/.next/server/pages/_error.js.nft.json +0 -1
  109. package/.next/server/pages-manifest.json +0 -5
  110. package/.next/server/server-reference-manifest.js +0 -1
  111. package/.next/server/server-reference-manifest.json +0 -1
  112. package/.next/server/webpack-runtime.js +0 -1
  113. package/.next/static/SigynMKeJ0KJs0Nc9i0E-/_buildManifest.js +0 -1
  114. package/.next/static/SigynMKeJ0KJs0Nc9i0E-/_ssgManifest.js +0 -1
  115. package/.next/static/chunks/214-cc4c35d88f2695ed.js +0 -1
  116. package/.next/static/chunks/4bd1b696-cf72ae8a39fa05aa.js +0 -1
  117. package/.next/static/chunks/574-9365237f47ed3a68.js +0 -1
  118. package/.next/static/chunks/866-04c19dda4c52f2bf.js +0 -1
  119. package/.next/static/chunks/964-eda38e26c0391a47.js +0 -1
  120. package/.next/static/chunks/app/_not-found/page-8601c49989b0be94.js +0 -1
  121. package/.next/static/chunks/app/api/mcp/chat/route-0341498a8bf5f2da.js +0 -1
  122. package/.next/static/chunks/app/api/mcp/connect/route-0341498a8bf5f2da.js +0 -1
  123. package/.next/static/chunks/app/api/mcp/prompts/get/route-0341498a8bf5f2da.js +0 -1
  124. package/.next/static/chunks/app/api/mcp/prompts/list/route-0341498a8bf5f2da.js +0 -1
  125. package/.next/static/chunks/app/api/mcp/resources/list/route-0341498a8bf5f2da.js +0 -1
  126. package/.next/static/chunks/app/api/mcp/resources/read/route-0341498a8bf5f2da.js +0 -1
  127. package/.next/static/chunks/app/api/mcp/tools/route-0341498a8bf5f2da.js +0 -1
  128. package/.next/static/chunks/app/layout-9e8115d4bf656fa0.js +0 -1
  129. package/.next/static/chunks/app/oauth/callback/page-cf6cb1ac31175f40.js +0 -1
  130. package/.next/static/chunks/app/page-b0e3ed6257734413.js +0 -1
  131. package/.next/static/chunks/framework-7c95b8e5103c9e90.js +0 -1
  132. package/.next/static/chunks/main-app-4e9e28316818cdde.js +0 -1
  133. package/.next/static/chunks/main-bbdafee21a7bd1d6.js +0 -1
  134. package/.next/static/chunks/pages/_app-0a0020ddd67f79cf.js +0 -1
  135. package/.next/static/chunks/pages/_error-03529f2c21436739.js +0 -1
  136. package/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  137. package/.next/static/chunks/webpack-cdfccaf38062dd25.js +0 -1
  138. package/.next/static/css/1e852d83e9c1d0c6.css +0 -1
  139. package/.next/static/css/f30152c0704fba31.css +0 -1
  140. package/.next/static/css/fe751fdbe975e9ca.css +0 -1
  141. package/.next/static/media/569ce4b8f30dc480-s.p.woff2 +0 -0
  142. package/.next/static/media/747892c23ea88013-s.woff2 +0 -0
  143. package/.next/static/media/8d697b304b401681-s.woff2 +0 -0
  144. package/.next/static/media/93f479601ee12b01-s.p.woff2 +0 -0
  145. package/.next/static/media/9610d9e46709d722-s.woff2 +0 -0
  146. package/.next/static/media/ba015fad6dcf6784-s.woff2 +0 -0
  147. package/.next/trace +0 -35
  148. package/.next/types/app/api/mcp/chat/route.ts +0 -347
  149. package/.next/types/app/api/mcp/connect/route.ts +0 -347
  150. package/.next/types/app/api/mcp/prompts/get/route.ts +0 -347
  151. package/.next/types/app/api/mcp/prompts/list/route.ts +0 -347
  152. package/.next/types/app/api/mcp/resources/list/route.ts +0 -347
  153. package/.next/types/app/api/mcp/resources/read/route.ts +0 -347
  154. package/.next/types/app/api/mcp/tools/route.ts +0 -347
  155. package/.next/types/app/layout.ts +0 -84
  156. package/.next/types/app/oauth/callback/page.ts +0 -84
  157. package/.next/types/app/page.ts +0 -84
  158. package/.next/types/cache-life.d.ts +0 -141
  159. package/.next/types/package.json +0 -1
  160. package/next.config.ts +0 -7
  161. /package/{public → dist/client}/claude_logo.png +0 -0
  162. /package/{public → dist/client}/demo_1.png +0 -0
  163. /package/{public → dist/client}/demo_2.png +0 -0
  164. /package/{public → dist/client}/demo_3.png +0 -0
  165. /package/{public → dist/client}/file.svg +0 -0
  166. /package/{public → dist/client}/globe.svg +0 -0
  167. /package/{public → dist/client}/mcp.svg +0 -0
  168. /package/{public → dist/client}/mcp_jam.svg +0 -0
  169. /package/{public → dist/client}/mcp_jam_dark.png +0 -0
  170. /package/{public → dist/client}/mcp_jam_light.png +0 -0
  171. /package/{public → dist/client}/next.svg +0 -0
  172. /package/{public → dist/client}/ollama_dark.png +0 -0
  173. /package/{public → dist/client}/ollama_logo.svg +0 -0
  174. /package/{public → dist/client}/openai_logo.png +0 -0
  175. /package/{public → dist/client}/vercel.svg +0 -0
  176. /package/{public → dist/client}/window.svg +0 -0
  177. /package/{.next/static/media/claude_logo.d33b25b0.png → dist/renderer/claude_logo.png} +0 -0
  178. /package/{.next/static/media/ollama_dark.9af45ac0.png → dist/renderer/ollama_dark.png} +0 -0
  179. /package/{.next/static/media/ollama_logo.9f08a95b.svg → dist/renderer/ollama_logo.svg} +0 -0
  180. /package/{.next/static/media/openai_logo.3f83154a.png → dist/renderer/openai_logo.png} +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{911:(e,t,r)=>{"use strict";r.d(t,{PreferencesStoreProvider:()=>i,x:()=>c});var s=r(5155),a=r(2115),n=r(5521),o=r(2421);let l=(0,a.createContext)(null),i=e=>{let{children:t,themeMode:r,themePreset:n}=e,i=(0,a.useRef)(null);return null!=i.current||(i.current=(e=>(0,o.y)()(t=>{var r,s;return{themeMode:null!=(r=null==e?void 0:e.themeMode)?r:"light",themePreset:null!=(s=null==e?void 0:e.themePreset)?s:"default",setThemeMode:e=>t({themeMode:e}),setThemePreset:e=>t({themePreset:e})}}))({themeMode:r,themePreset:n})),(0,s.jsx)(l.Provider,{value:i.current,children:t})},c=e=>{let t=(0,a.useContext)(l);if(!t)throw Error("Missing PreferencesStoreProvider");return(0,n.P)(t,e)}},5973:(e,t,r)=>{Promise.resolve().then(r.bind(r,6928))},6695:(e,t,r)=>{"use strict";r.d(t,{Wu:()=>i,ZB:()=>l,Zp:()=>n,aR:()=>o});var s=r(5155);r(2115);var a=r(9434);function n(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"card",className:(0,a.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...r})}function o(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"card-header",className:(0,a.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...r})}function l(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"card-title",className:(0,a.cn)("leading-none font-semibold",t),...r})}function i(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"card-content",className:(0,a.cn)("px-6",t),...r})}},6928:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>rx});var s=r(5155),a=r(2115),n=r(6695),o=r(9708),l=r(2085),i=r(9434);let c=(0,l.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer 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",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",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",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function d(e){let{className:t,variant:r,size:a,asChild:n=!1,...l}=e,d=n?o.DX:"button";return(0,s.jsx)(d,{"data-slot":"button",className:(0,i.cn)(c({variant:r,size:a,className:t})),...l})}var u=r(4616),m=r(4213),x=r(6671),h=r(7489);function f(e){let{className:t,orientation:r="horizontal",decorative:a=!0,...n}=e;return(0,s.jsx)(h.b,{"data-slot":"separator",decorative:a,orientation:r,className:(0,i.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",t),...n})}var p=r(9613);function g(e){let{delayDuration:t=0,...r}=e;return(0,s.jsx)(p.Kq,{"data-slot":"tooltip-provider",delayDuration:t,...r})}function v(e){let{...t}=e;return(0,s.jsx)(g,{children:(0,s.jsx)(p.bL,{"data-slot":"tooltip",...t})})}function b(e){let{...t}=e;return(0,s.jsx)(p.l9,{"data-slot":"tooltip-trigger",...t})}function j(e){let{className:t,sideOffset:r=0,children:a,...n}=e;return(0,s.jsx)(p.ZL,{children:(0,s.jsxs)(p.UC,{"data-slot":"tooltip-content",sideOffset:r,className:(0,i.cn)("bg-primary text-primary-foreground 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",t),...n,children:[a,(0,s.jsx)(p.i3,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}var N=r(9449);function y(e){let{...t}=e;return(0,s.jsx)(N.bL,{"data-slot":"dropdown-menu",...t})}function w(e){let{...t}=e;return(0,s.jsx)(N.l9,{"data-slot":"dropdown-menu-trigger",...t})}function k(e){let{className:t,sideOffset:r=4,...a}=e;return(0,s.jsx)(N.ZL,{children:(0,s.jsx)(N.UC,{"data-slot":"dropdown-menu-content",sideOffset:r,className:(0,i.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",t),...a})})}function S(e){let{className:t,inset:r,variant:a="default",...n}=e;return(0,s.jsx)(N.q7,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":a,className:(0,i.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",t),...n})}var C=r(5196),A=r(1154),T=r(4416),O=r(6517),E=r(4020),z=r(3904),_=r(3717),M=r(7639),R=r(4357),P=r(7863),L=r(6474);function I(e){var t,r,o;let{server:l,onDisconnect:c,onReconnect:u,onEdit:m}=e,[h,p]=(0,a.useState)(!1),[v,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(!1),[I,U]=(0,a.useState)(null),D=void 0!==l.config.url,F=l.oauthTokens,q=null==(t=l.config.requestInit)?void 0:t.headers,J=(null==q||null==(r=q.Authorization)?void 0:r.startsWith("Bearer "))&&q.Authorization.slice(7),B=F||J||!D,H=(null==(o=l.oauthTokens)?void 0:o.expires_in)?{percentage:100,timeLeft:36e5,hours:1,minutes:0,seconds:0,isExpired:!1,isExpiringSoon:!1}:null,G=async(e,t)=>{try{await navigator.clipboard.writeText(e),U(t),setTimeout(()=>U(null),2e3)}catch(e){console.error("Failed to copy text:",e)}},V=async()=>{b(!0);try{u(l.name)}catch(t){let e=t instanceof Error?t.message:"Unknown error";x.oR.error("Failed to reconnect to ".concat(l.name,": ").concat(e))}finally{b(!1)}},Z=()=>{if(D){var e;return(null==(e=l.config.url)?void 0:e.toString())||""}return[l.config.command,...l.config.args||[]].join(" ")};return(0,s.jsx)(g,{children:(0,s.jsx)(n.Zp,{className:"border border-border/50 bg-card/50 backdrop-blur-sm hover:border-border transition-colors",children:(0,s.jsxs)("div",{className:"p-4 space-y-3 py-0",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 flex-1",children:[(0,s.jsx)("div",{className:"h-2 w-2 rounded-full flex-shrink-0 mt-1.5",style:{backgroundColor:"connected"===l.connectionStatus?"#10b981":"connecting"===l.connectionStatus?"#3b82f6":"oauth-flow"===l.connectionStatus?"#a855f7":"failed"===l.connectionStatus?"#ef4444":"#9ca3af"}}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("h3",{className:"font-medium text-sm text-foreground",children:l.name}),(0,s.jsxs)("div",{className:"flex justify-between mt-1",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:D?"HTTP/SSE":"STDIO"}),(0,s.jsxs)("div",{className:"flex items-center gap-1 -mr-3",children:[(()=>{switch(l.connectionStatus){case"connected":return(0,s.jsx)(C.A,{className:"h-3 w-3 text-green-500"});case"connecting":return(0,s.jsx)(A.A,{className:"h-3 w-3 text-blue-500 animate-spin"});case"oauth-flow":return(0,s.jsx)(A.A,{className:"h-3 w-3 text-purple-500 animate-spin"});case"failed":return(0,s.jsx)(T.A,{className:"h-3 w-3 text-red-500"});case"disconnected":return(0,s.jsx)(O.A,{className:"h-3 w-3 text-gray-500"})}})(),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:(()=>{switch(l.connectionStatus){case"connected":return"Connected";case"connecting":return"Connecting...";case"oauth-flow":return"Authorizing...";case"failed":return"Failed (".concat(l.retryCount," retries)");case"disconnected":return"Disconnected"}})()})]})]})]})]}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)(y,{children:[(0,s.jsx)(w,{asChild:!0,children:(0,s.jsx)(d,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground/50 hover:text-foreground cursor-pointer",children:(0,s.jsx)(E.A,{className:"h-3 w-3"})})}),(0,s.jsxs)(k,{align:"end",className:"w-40",children:[(0,s.jsxs)(S,{onClick:V,disabled:v||"connecting"===l.connectionStatus||"oauth-flow"===l.connectionStatus,className:"text-xs cursor-pointer",children:[v?(0,s.jsx)(A.A,{className:"h-3 w-3 mr-2 animate-spin"}):(0,s.jsx)(z.A,{className:"h-3 w-3 mr-2"}),v?"Reconnecting...":"Reconnect"]}),(0,s.jsxs)(S,{onClick:()=>m(l),className:"text-xs cursor-pointer",children:[(0,s.jsx)(_.A,{className:"h-3 w-3 mr-2"}),"Edit"]}),(0,s.jsx)(f,{}),(0,s.jsxs)(S,{className:"text-destructive text-xs cursor-pointer",onClick:()=>c(l.name),children:[(0,s.jsx)(M.A,{className:"h-3 w-3 mr-2"}),"Disconnect"]})]})]})})]}),(0,s.jsxs)("div",{className:"font-mono text-xs text-muted-foreground bg-muted/30 p-2 rounded border border-border/30 break-all relative group",children:[(0,s.jsx)("div",{className:"pr-8",children:Z()}),(0,s.jsx)("button",{onClick:()=>G(Z(),"command"),className:"absolute top-1 right-1 p-1 text-muted-foreground/50 hover:text-foreground transition-colors cursor-pointer",children:"command"===I?(0,s.jsx)(C.A,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(R.A,{className:"h-3 w-3"})})]}),"failed"===l.connectionStatus&&l.lastError&&(0,s.jsxs)("div",{className:"text-xs text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950/30 p-2 rounded border border-red-200 dark:border-red-800/30",children:[(0,s.jsx)("div",{className:"break-all",children:j?l.lastError:l.lastError.length>100?"".concat(l.lastError.substring(0,100),"..."):l.lastError}),l.lastError.length>100&&(0,s.jsx)("button",{onClick:()=>N(!j),className:"text-red-500/70 hover:text-red-500 mt-1 underline text-xs cursor-pointer",children:j?"Show less":"Show more"}),l.retryCount>0&&(0,s.jsxs)("div",{className:"text-red-500/70 mt-1",children:[l.retryCount," retry attempt",1!==l.retryCount?"s":""]})]}),B&&(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)(d,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground cursor-pointer",onClick:()=>p(!h),children:h?(0,s.jsx)(P.A,{className:"h-3 w-3"}):(0,s.jsx)(L.A,{className:"h-3 w-3"})})}),h&&B&&(0,s.jsxs)("div",{className:"space-y-3 pt-2",children:[J&&!l.oauthTokens&&(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsx)("div",{className:"space-y-3 text-xs",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground font-medium",children:"Bearer Access Token (Manual):"}),(0,s.jsxs)("div",{className:"font-mono text-foreground break-all bg-muted/30 p-2 rounded mt-1 relative group",children:[(0,s.jsx)("div",{className:"pr-8",children:J}),(0,s.jsx)("button",{onClick:()=>G(J,"manualBearerToken"),className:"absolute top-1 right-1 p-1 text-muted-foreground/50 hover:text-foreground transition-colors cursor-pointer",children:"manualBearerToken"===I?(0,s.jsx)(C.A,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(R.A,{className:"h-3 w-3"})})]})]})})}),l.oauthTokens&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"space-y-3 text-xs",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground font-medium",children:"Bearer Access Token:"}),(0,s.jsxs)("div",{className:"font-mono text-foreground break-all bg-muted/30 p-2 rounded mt-1 relative group",children:[(0,s.jsx)("div",{className:"pr-8",children:l.oauthTokens.access_token}),(0,s.jsx)("button",{onClick:()=>{var e;return G((null==(e=l.oauthTokens)?void 0:e.access_token)||"","accessToken")},className:"absolute top-1 right-1 p-1 text-muted-foreground/50 hover:text-foreground transition-colors cursor-pointer",children:"accessToken"===I?(0,s.jsx)(C.A,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(R.A,{className:"h-3 w-3"})})]})]}),l.oauthTokens.scope&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground font-medium",children:"Scopes:"}),(0,s.jsx)("div",{className:"font-mono text-foreground break-all bg-muted/30 p-2 rounded mt-1",children:l.oauthTokens.scope})]})]}),H&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-medium",children:"Token Expiry:"}),(0,s.jsx)("div",{className:"text-xs font-mono mt-1 bg-muted/30 p-2 rounded ".concat(H.isExpired?"text-red-500":H.isExpiringSoon?"text-yellow-500":"text-green-500"),children:(0,i.$B)(H.timeLeft)})]})]}),!D&&(0,s.jsxs)("div",{className:"space-y-3",children:[l.config.args&&l.config.args.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-medium",children:"Arguments:"}),(0,s.jsx)("div",{className:"space-y-1 mt-1",children:l.config.args.map((e,t)=>(0,s.jsx)("div",{className:"text-xs font-mono text-foreground bg-muted/30 p-2 rounded break-all",children:e},t))})]}),l.config.env&&Object.keys(l.config.env).length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-medium",children:"Environment:"}),(0,s.jsx)("div",{className:"space-y-1 mt-1",children:Object.entries(l.config.env).map(e=>{let[t,r]=e;return(0,s.jsxs)("div",{className:"text-xs font-mono bg-muted/30 p-2 rounded break-all",children:[(0,s.jsx)("span",{className:"text-blue-600",children:t}),"=",(0,s.jsx)("span",{className:"text-green-600",children:r})]},t)})})]})]})]})]})})})}function U(e){let{className:t,type:r,...a}=e;return(0,s.jsx)("input",{type:r,"data-slot":"input",className:(0,i.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex 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",t),...a})}var D=r(5452);function F(e){let{...t}=e;return(0,s.jsx)(D.bL,{"data-slot":"dialog",...t})}function q(e){let{...t}=e;return(0,s.jsx)(D.ZL,{"data-slot":"dialog-portal",...t})}function J(e){let{className:t,...r}=e;return(0,s.jsx)(D.hJ,{"data-slot":"dialog-overlay",className:(0,i.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",t),...r})}function B(e){let{className:t,children:r,showCloseButton:a=!0,...n}=e;return(0,s.jsxs)(q,{"data-slot":"dialog-portal",children:[(0,s.jsx)(J,{}),(0,s.jsxs)(D.UC,{"data-slot":"dialog-content",className:(0,i.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 sm:max-w-lg",t),...n,children:[r,a&&(0,s.jsxs)(D.bm,{"data-slot":"dialog-close",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",children:[(0,s.jsx)(T.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function H(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"dialog-header",className:(0,i.cn)("flex flex-col gap-2 text-center sm:text-left",t),...r})}function G(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"dialog-footer",className:(0,i.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...r})}function V(e){let{className:t,...r}=e;return(0,s.jsx)(D.hE,{"data-slot":"dialog-title",className:(0,i.cn)("text-lg leading-none font-semibold",t),...r})}function Z(e){let{className:t,...r}=e;return(0,s.jsx)(D.VY,{"data-slot":"dialog-description",className:(0,i.cn)("text-muted-foreground text-sm",t),...r})}var W=r(83);function K(e){let{...t}=e;return(0,s.jsx)(W.bL,{"data-slot":"select",...t})}function $(e){let{...t}=e;return(0,s.jsx)(W.WT,{"data-slot":"select-value",...t})}function Y(e){let{className:t,size:r="default",children:a,...n}=e;return(0,s.jsxs)(W.l9,{"data-slot":"select-trigger","data-size":r,className:(0,i.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",t),...n,children:[a,(0,s.jsx)(W.In,{asChild:!0,children:(0,s.jsx)(L.A,{className:"size-4 opacity-50"})})]})}function X(e){let{className:t,children:r,position:a="popper",...n}=e;return(0,s.jsx)(W.ZL,{children:(0,s.jsxs)(W.UC,{"data-slot":"select-content",className:(0,i.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","popper"===a&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...n,children:[(0,s.jsx)(ee,{}),(0,s.jsx)(W.LM,{className:(0,i.cn)("p-1","popper"===a&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,s.jsx)(et,{})]})})}function Q(e){let{className:t,children:r,...a}=e;return(0,s.jsxs)(W.q7,{"data-slot":"select-item",className:(0,i.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",t),...a,children:[(0,s.jsx)("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,s.jsx)(W.VF,{children:(0,s.jsx)(C.A,{className:"size-4"})})}),(0,s.jsx)(W.p4,{children:r})]})}function ee(e){let{className:t,...r}=e;return(0,s.jsx)(W.PP,{"data-slot":"select-scroll-up-button",className:(0,i.cn)("flex cursor-default items-center justify-center py-1",t),...r,children:(0,s.jsx)(P.A,{className:"size-4"})})}function et(e){let{className:t,...r}=e;return(0,s.jsx)(W.wn,{"data-slot":"select-scroll-down-button",className:(0,i.cn)("flex cursor-default items-center justify-center py-1",t),...r,children:(0,s.jsx)(L.A,{className:"size-4"})})}function er(e){let{isOpen:t,onClose:r,onConnect:n}=e,[o,l]=(0,a.useState)({name:"",type:"stdio",command:"",args:[],url:"",headers:{},env:{},useOAuth:!0,oauthScopes:["mcp:*"]}),[i,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(""),[x,h]=(0,a.useState)(""),[f,p]=(0,a.useState)("none"),[g,v]=(0,a.useState)([]),b=()=>{j(),r()},j=()=>{l({name:"",type:"stdio",command:"",args:[],url:"",headers:{},env:{},useOAuth:!0,oauthScopes:["mcp:*"]}),c(""),m(""),h(""),p("none"),v([])},N=(e,t,r)=>{let s=[...g];s[e][t]=r,v(s)};return(0,s.jsx)(F,{open:t,onOpenChange:b,children:(0,s.jsxs)(B,{className:"max-w-md sm:max-w-lg",children:[(0,s.jsx)(H,{className:"space-y-2",children:(0,s.jsx)(V,{className:"text-xl font-semibold",children:"Add MCP Server"})}),(0,s.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),o.name){let e={...o};if("stdio"===o.type&&i){let t=i.split(" ").filter(e=>e.trim()),r=t[0]||"",s=t.slice(1);e={...e,command:r,args:s};let a=g.reduce((e,t)=>{let{key:r,value:s}=t;return r&&s&&(e[r]=s),e},{});e={...e,env:a}}if("http"===o.type){if("none"===f)e={...e,useOAuth:!1};else if("bearer"===f&&x)e={...e,headers:{...e.headers,Authorization:"Bearer ".concat(x)},useOAuth:!1};else if("oauth"===f&&o.useOAuth&&u){let t=u.split(" ").filter(e=>e.trim());e={...e,oauthScopes:t}}}n(e),j(),r()}},className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Server Name"}),(0,s.jsx)(U,{value:o.name,onChange:e=>l(t=>({...t,name:e.target.value})),placeholder:"my-mcp-server",required:!0,className:"h-10"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Connection Type"}),"stdio"===o.type?(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsxs)(K,{value:o.type,onValueChange:e=>l(t=>({...t,type:e})),children:[(0,s.jsx)(Y,{className:"w-22 rounded-r-none border-r-0 text-xs border-border",children:(0,s.jsx)($,{})}),(0,s.jsxs)(X,{children:[(0,s.jsx)(Q,{value:"stdio",children:"STDIO"}),(0,s.jsx)(Q,{value:"http",children:"HTTP"})]})]}),(0,s.jsx)(U,{value:i,onChange:e=>c(e.target.value),placeholder:"npx -y @modelcontextprotocol/server-everything",required:!0,className:"flex-1 rounded-l-none text-sm border-border"})]}):(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsxs)(K,{value:o.type,onValueChange:e=>l(t=>({...t,type:e})),children:[(0,s.jsx)(Y,{className:"w-22 rounded-r-none border-r-0 text-xs border-border",children:(0,s.jsx)($,{})}),(0,s.jsxs)(X,{children:[(0,s.jsx)(Q,{value:"stdio",children:"STDIO"}),(0,s.jsx)(Q,{value:"http",children:"HTTP"})]})]}),(0,s.jsx)(U,{value:o.url,onChange:e=>l(t=>({...t,url:e.target.value})),placeholder:"http://localhost:8080/mcp",required:!0,className:"flex-1 rounded-l-none text-sm"})]})]}),"stdio"===o.type&&(0,s.jsxs)("div",{className:"space-y-4 p-4 border rounded-lg bg-muted/30 border-border/50",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Environment Variables"}),(0,s.jsx)(d,{type:"button",variant:"outline",size:"sm",onClick:()=>{v([...g,{key:"",value:""}])},className:"h-8 px-2 text-xs cursor-pointer",children:"Add Variable"})]}),g.length>0&&(0,s.jsx)("div",{className:"space-y-2",children:g.map((e,t)=>(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(U,{placeholder:"key",value:e.key,onChange:e=>N(t,"key",e.target.value),className:"h-8 text-sm"}),(0,s.jsx)(U,{placeholder:"value",value:e.value,onChange:e=>N(t,"value",e.target.value),className:"h-8 text-sm"}),(0,s.jsx)(d,{type:"button",variant:"outline",size:"sm",onClick:()=>{v(g.filter((e,r)=>r!==t))},className:"h-8 px-2 text-xs",children:"\xd7"})]},t))})]}),"http"===o.type&&(0,s.jsxs)("div",{className:"space-y-4 p-4 border rounded-lg bg-muted/30 border-border/50",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Authentication Method"}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("input",{type:"radio",id:"none",name:"authType",checked:"none"===f,onChange:()=>p("none"),className:"w-4 h-4 cursor-pointer"}),(0,s.jsx)("label",{htmlFor:"none",className:"text-sm cursor-pointer",children:"None"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("input",{type:"radio",id:"oauth",name:"authType",checked:"oauth"===f,onChange:()=>p("oauth"),className:"w-4 h-4 cursor-pointer"}),(0,s.jsx)("label",{htmlFor:"oauth",className:"text-sm cursor-pointer",children:"OAuth 2.1"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("input",{type:"radio",id:"bearer",name:"authType",checked:"bearer"===f,onChange:()=>p("bearer"),className:"w-4 h-4 cursor-pointer"}),(0,s.jsx)("label",{htmlFor:"bearer",className:"text-sm cursor-pointer",children:"Bearer Token"})]})]})]}),"oauth"===f&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"OAuth Scopes"}),(0,s.jsx)(U,{value:u,onChange:e=>m(e.target.value),placeholder:"mcp:* mcp:tools mcp:resources",className:"h-10"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Space-separated OAuth scopes. Use 'mcp:*' for full access."})]}),"bearer"===f&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Bearer Token"}),(0,s.jsx)(U,{type:"password",value:x,onChange:e=>h(e.target.value),placeholder:"Enter your bearer token",className:"h-10"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Token will be sent as Authorization: Bearer <token> header"})]})]}),(0,s.jsxs)("div",{className:"flex gap-3 pt-6 border-t",children:[(0,s.jsx)(d,{type:"submit",className:"flex-1 cursor-pointer",children:"Connect Server"}),(0,s.jsx)(d,{type:"button",variant:"outline",onClick:b,className:"flex-1 cursor-pointer",children:"Cancel"})]})]})]})})}function es(e){let{isOpen:t,onClose:r,onUpdate:n,server:o}=e,[l,i]=(0,a.useState)({name:"",type:"stdio",command:"",args:[],url:"",headers:{},env:{},useOAuth:!0,oauthScopes:["mcp:*"]}),[c,u]=(0,a.useState)(""),[m,x]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[p,g]=(0,a.useState)("none"),[v,b]=(0,a.useState)([]);(0,a.useEffect)(()=>{if(o&&t){let t=(e=>{let t=e.config;if(!("url"in t))return{name:e.name,type:"stdio",command:t.command||"",args:t.args||[],env:t.env||{}};{var r,s,a,n;let o=(null==(r=t.requestInit)?void 0:r.headers)||{},l=null!=e.oauthTokens;return{name:e.name,type:"http",url:(null==(s=t.url)?void 0:s.toString())||"",headers:o,useOAuth:l,oauthScopes:(null==(n=e.oauthTokens)||null==(a=n.scope)?void 0:a.split(" "))||["mcp:*"]}}})(o);if(i(t),"stdio"===t.type)u([t.command||"",...t.args||[]].join(" ")),b(Object.entries(t.env||{}).map(e=>{let[t,r]=e;return{key:t,value:r}}));else{let r=(t.headers||{}).Authorization,s=null==r?void 0:r.startsWith("Bearer ");if(t.useOAuth){var e;g("oauth"),x((null==(e=t.oauthScopes)?void 0:e.join(" "))||"mcp:*"),i(e=>({...e,useOAuth:!0}))}else s?(g("bearer"),f(r.slice(7)),i(e=>({...e,useOAuth:!1}))):(g("none"),i(e=>({...e,useOAuth:!1})))}}},[o,t]);let j=()=>{r()},N=(e,t,r)=>{let s=[...v];s[e][t]=r,b(s)};return(0,s.jsx)(F,{open:t,onOpenChange:j,children:(0,s.jsxs)(B,{className:"max-w-md sm:max-w-lg",children:[(0,s.jsx)(H,{className:"space-y-2",children:(0,s.jsx)(V,{className:"text-xl font-semibold",children:"Edit MCP Server"})}),(0,s.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),l.name){let e={...l};if("stdio"===l.type&&c){let t=c.split(" ").filter(e=>e.trim()),r=t[0]||"",s=t.slice(1);e={...e,command:r,args:s};let a=v.reduce((e,t)=>{let{key:r,value:s}=t;return r&&s&&(e[r]=s),e},{});e={...e,env:a}}if("http"===l.type){if("none"===p)e={...e,useOAuth:!1,headers:{}};else if("bearer"===p&&h)e={...e,headers:{...e.headers,Authorization:"Bearer ".concat(h)},useOAuth:!1};else if("oauth"===p&&m){let t=m.split(" ").filter(e=>e.trim());e={...e,useOAuth:!0,oauthScopes:t,headers:{}}}}n(o.name,e),r()}},className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Server Name"}),(0,s.jsx)(U,{value:l.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:"my-mcp-server",required:!0,className:"h-10"})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Connection Type"}),"stdio"===l.type?(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsxs)(K,{value:l.type,onValueChange:e=>i(t=>({...t,type:e})),children:[(0,s.jsx)(Y,{className:"w-22 rounded-r-none border-r-0 text-xs border-border",children:(0,s.jsx)($,{})}),(0,s.jsxs)(X,{children:[(0,s.jsx)(Q,{value:"stdio",children:"STDIO"}),(0,s.jsx)(Q,{value:"http",children:"HTTP"})]})]}),(0,s.jsx)(U,{value:c,onChange:e=>u(e.target.value),placeholder:"npx -y @modelcontextprotocol/server-everything",required:!0,className:"flex-1 rounded-l-none text-sm border-border"})]}):(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsxs)(K,{value:l.type,onValueChange:e=>i(t=>({...t,type:e})),children:[(0,s.jsx)(Y,{className:"w-22 rounded-r-none border-r-0 text-xs border-border",children:(0,s.jsx)($,{})}),(0,s.jsxs)(X,{children:[(0,s.jsx)(Q,{value:"stdio",children:"STDIO"}),(0,s.jsx)(Q,{value:"http",children:"HTTP"})]})]}),(0,s.jsx)(U,{value:l.url,onChange:e=>i(t=>({...t,url:e.target.value})),placeholder:"http://localhost:8080/mcp",required:!0,className:"flex-1 rounded-l-none text-sm"})]})]}),"stdio"===l.type&&(0,s.jsxs)("div",{className:"space-y-4 p-4 border rounded-lg bg-muted/30 border-border/50",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Environment Variables"}),(0,s.jsx)(d,{type:"button",variant:"outline",size:"sm",onClick:()=>{b([...v,{key:"",value:""}])},className:"h-8 px-2 text-xs cursor-pointer",children:"Add Variable"})]}),v.length>0&&(0,s.jsx)("div",{className:"space-y-2",children:v.map((e,t)=>(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(U,{placeholder:"key",value:e.key,onChange:e=>N(t,"key",e.target.value),className:"h-8 text-sm"}),(0,s.jsx)(U,{placeholder:"value",value:e.value,onChange:e=>N(t,"value",e.target.value),className:"h-8 text-sm"}),(0,s.jsx)(d,{type:"button",variant:"outline",size:"sm",onClick:()=>{b(v.filter((e,r)=>r!==t))},className:"h-8 px-2 text-xs",children:"�"})]},t))})]}),"http"===l.type&&(0,s.jsxs)("div",{className:"space-y-4 p-4 border rounded-lg bg-muted/30 border-border/50",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Authentication Method"}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("input",{type:"radio",id:"none",name:"authType",checked:"none"===p,onChange:()=>{g("none"),i(e=>({...e,useOAuth:!1}))},className:"w-4 h-4 cursor-pointer"}),(0,s.jsx)("label",{htmlFor:"none",className:"text-sm cursor-pointer",children:"None"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("input",{type:"radio",id:"oauth",name:"authType",checked:"oauth"===p,onChange:()=>{g("oauth"),i(e=>({...e,useOAuth:!0}))},className:"w-4 h-4 cursor-pointer"}),(0,s.jsx)("label",{htmlFor:"oauth",className:"text-sm cursor-pointer",children:"OAuth 2.1"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("input",{type:"radio",id:"bearer",name:"authType",checked:"bearer"===p,onChange:()=>{g("bearer"),i(e=>({...e,useOAuth:!1}))},className:"w-4 h-4 cursor-pointer"}),(0,s.jsx)("label",{htmlFor:"bearer",className:"text-sm cursor-pointer",children:"Bearer Token"})]})]})]}),"oauth"===p&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"OAuth Scopes"}),(0,s.jsx)(U,{value:m,onChange:e=>x(e.target.value),placeholder:"mcp:* mcp:tools mcp:resources",className:"h-10"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Space-separated OAuth scopes. Use 'mcp:*' for full access."})]}),"bearer"===p&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-foreground",children:"Bearer Token"}),(0,s.jsx)(U,{type:"password",value:h,onChange:e=>f(e.target.value),placeholder:"Enter your bearer token",className:"h-10"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Token will be sent as Authorization: Bearer <token> header"})]})]}),(0,s.jsxs)("div",{className:"flex gap-3 pt-6 border-t",children:[(0,s.jsx)(d,{type:"submit",className:"flex-1 cursor-pointer",children:"Update Server"}),(0,s.jsx)(d,{type:"button",variant:"outline",onClick:j,className:"flex-1 cursor-pointer",children:"Cancel"})]})]})]})})}let ea=a.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsxs)("svg",{ref:t,fill:"currentColor",fillRule:"evenodd",height:"1em",style:{flex:"none",lineHeight:1},viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:r,...a,children:[(0,s.jsx)("title",{children:"ModelContextProtocol"}),(0,s.jsx)("path",{d:"M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z"}),(0,s.jsx)("path",{d:"M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z"})]})});function en(e){let{connectedServerConfigs:t,onConnect:r,onDisconnect:o,onReconnect:l,onUpdate:i}=e,[c,x]=(0,a.useState)(!1),[h,f]=(0,a.useState)(!1),[p,g]=(0,a.useState)(null),[v,b]=(0,a.useState)(""),[j,N]=(0,a.useState)("all");(0,a.useEffect)(()=>{Object.keys(t).forEach(e=>{l(e)})},[]);let y=Object.entries(t).filter(e=>{let[t,r]=e,s=t.toLowerCase().includes(v.toLowerCase()),a="all"===j||"stdio"===j&&"command"in r.config||"http"===j&&"url"in r.config;return s&&a}),w=Object.keys(t).length,k=e=>{g(e),f(!0)};return(0,s.jsxs)("div",{className:"space-y-6 p-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("div",{children:(0,s.jsx)("h2",{className:"text-2xl font-bold tracking-tight",children:"MCP Servers"})}),(0,s.jsxs)(d,{onClick:()=>x(!0),className:"cursor-pointer",children:[(0,s.jsx)(u.A,{className:"h-4 w-4 mr-2"}),"Add Server"]})]}),w>0?(0,s.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:y.map(e=>{let[t,r]=e;return(0,s.jsx)(I,{server:r,onDisconnect:o,onReconnect:l,onEdit:k},t)})}):(0,s.jsx)(n.Zp,{className:"p-12 text-center",children:(0,s.jsxs)("div",{className:"mx-auto max-w-sm",children:[(0,s.jsx)(ea,{className:"mx-auto h-12 w-12 text-muted-foreground"}),(0,s.jsx)("h3",{className:"mt-4 text-lg font-semibold",children:"No servers connected"}),(0,s.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Get started by connecting to your first MCP server"}),(0,s.jsxs)(d,{onClick:()=>x(!0),className:"mt-4 cursor-pointer",children:[(0,s.jsx)(u.A,{className:"h-4 w-4 mr-2"}),"Add Your First Server"]})]})}),0===y.length&&w>0&&(0,s.jsx)(n.Zp,{className:"p-8 text-center",children:(0,s.jsxs)("div",{className:"mx-auto max-w-sm",children:[(0,s.jsx)(m.A,{className:"mx-auto h-8 w-8 text-muted-foreground"}),(0,s.jsx)("h3",{className:"mt-4 text-lg font-semibold",children:"No servers found"}),(0,s.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your search or filter criteria"})]})}),(0,s.jsx)(er,{isOpen:c,onClose:()=>x(!1),onConnect:r}),p&&(0,s.jsx)(es,{isOpen:h,onClose:()=>{f(!1),g(null)},onUpdate:i,server:p})]})}ea.displayName="MCPIcon";let eo={error:0,warn:1,info:2,debug:3,trace:4},el={error:"#ef4444",warn:"#f59e0b",info:"#3b82f6",debug:"#8b5cf6",trace:"#6b7280"};class ei{setConfig(e){this.config={...this.config,...e},this.notifyListeners()}getConfig(){return{...this.config}}addEntry(e){this.buffer.push(e),this.buffer.length>this.config.maxBufferSize&&(this.buffer=this.buffer.slice(-this.config.maxBufferSize)),this.notifyListeners()}getEntries(){return[...this.buffer]}getFilteredEntries(e,t){let r=this.buffer;if(e&&(r=r.filter(t=>t.level===e)),t){let e=t.toLowerCase();r=r.filter(t=>t.context.toLowerCase().includes(e))}return r}clearBuffer(){this.buffer=[],this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e())}shouldLog(e){return eo[e]<=eo[this.config.level]}constructor(){this.config={level:"info",enableConsole:!0,maxBufferSize:1e3},this.buffer=[],this.listeners=new Set}}let ec=new ei;function ed(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unknown",t=(0,a.useCallback)(t=>(r,s,a)=>{if(!ec.shouldLog(t))return;let n={timestamp:new Date().toISOString(),level:t,context:e,message:r,data:s,error:a};ec.addEntry(n),ec.getConfig().enableConsole&&function(e){let{timestamp:t,level:r,context:s,message:a,data:n,error:o}=e,l=new Date(t).toLocaleTimeString(),i=el[r],c=["%c[".concat(l,"] %c").concat(r.toUpperCase()," %c[").concat(s,"] %c").concat(a),"color: #6b7280;","color: ".concat(i,"; font-weight: bold;"),"color: #6b7280;","color: ".concat(i,";")];void 0!==n&&c.push("\nData:",n),o&&c.push("\nError:",o),("error"===r?console.error:"warn"===r?console.warn:"debug"===r?console.debug:console.log)(...c)}(n)},[e]);return(0,a.useMemo)(()=>({error:t("error"),warn:t("warn"),info:t("info"),debug:t("debug"),trace:t("trace"),context:e}),[t,e])}function eu(e){let{className:t,...r}=e;return(0,s.jsx)("textarea",{"data-slot":"textarea",className:(0,i.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",t),...r})}ec.setConfig({level:"info",enableConsole:!0});let em=(0,l.F)("inline-flex items-center justify-center rounded-md 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",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",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",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function ex(e){let{className:t,variant:r,asChild:a=!1,...n}=e,l=a?o.DX:"span";return(0,s.jsx)(l,{"data-slot":"badge",className:(0,i.cn)(em({variant:r}),t),...n})}var eh=r(7655);function ef(e){let{className:t,children:r,...a}=e;return(0,s.jsxs)(eh.bL,{"data-slot":"scroll-area",className:(0,i.cn)("relative",t),...a,children:[(0,s.jsx)(eh.LM,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),(0,s.jsx)(ep,{}),(0,s.jsx)(eh.OK,{})]})}function ep(e){let{className:t,orientation:r="vertical",...a}=e;return(0,s.jsx)(eh.VM,{"data-slot":"scroll-area-scrollbar",orientation:r,className:(0,i.cn)("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",t),...a,children:(0,s.jsx)(eh.lr,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var eg=r(8021),ev=r(1729);function eb(e){let{className:t,...r}=e;return(0,s.jsx)(ev.YZ,{"data-slot":"resizable-panel-group",className:(0,i.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...r})}function ej(e){let{...t}=e;return(0,s.jsx)(ev.Zk,{"data-slot":"resizable-panel",...t})}function eN(e){let{withHandle:t,className:r,...a}=e;return(0,s.jsx)(ev.TW,{"data-slot":"resizable-handle",className:(0,i.cn)("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...a,children:t&&(0,s.jsx)("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:(0,s.jsx)(eg.A,{className:"size-2.5"})})})}var ey=r(8313),ew=r(3052),ek=r(5690),eS=r(9994);r(3347);var eC=r(968);function eA(e){let{className:t,...r}=e;return(0,s.jsx)(eC.b,{"data-slot":"label",className:(0,i.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",t),...r})}var eT=r(1497);function eO(e){let{elicitationRequest:t,onResponse:r,loading:n=!1}=e,[o,l]=(0,a.useState)([]);a.useEffect(()=>{(null==t?void 0:t.schema)?i(t.schema):l([])},[t]);let i=e=>{if(!e||!e.properties)return void l([]);let t=[],r=e.required||[];Object.entries(e.properties).forEach(e=>{let[s,a]=e,n=a.enum?"enum":a.type||"string";t.push({name:s,type:n,description:a.description,required:r.includes(s),value:c(n,a.enum),enum:a.enum,minimum:a.minimum,maximum:a.maximum,pattern:a.pattern})}),l(t)},c=(e,t)=>{switch(e){case"enum":return(null==t?void 0:t[0])||"";case"string":case"number":case"integer":default:return"";case"boolean":return!1;case"array":return[];case"object":return{}}},u=(e,t)=>{l(r=>r.map(r=>r.name===e?{...r,value:t}:r))},m=async e=>{if("accept"===e){if(o.filter(e=>e.required&&(!e.value||""===e.value)).length>0)return;let t=(()=>{let e={};return o.forEach(t=>{if(""!==t.value&&null!==t.value&&void 0!==t.value){let r=t.value;if("number"===t.type||"integer"===t.type)r=Number(t.value);else if("boolean"===t.type)r=!!t.value;else if("array"===t.type||"object"===t.type)try{r=JSON.parse(t.value)}catch(e){r=t.value}e[t.name]=r}}),e})();await r(e,t)}else await r(e)};return(0,s.jsx)(F,{open:!!t,onOpenChange:()=>{},children:(0,s.jsxs)(B,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,s.jsxs)(H,{children:[(0,s.jsxs)(V,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(eT.A,{className:"h-3 w-3"}),"Elicitation Request"]}),(0,s.jsx)(Z,{className:"text-md font-bold",children:null==t?void 0:t.message})]}),(0,s.jsx)("div",{className:"space-y-6 py-4",children:o.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-2",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eA,{className:"text-sm font-medium",children:e.name}),e.required&&(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-red-500 rounded-full",title:"Required field"})]}),e.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description})]}),(0,s.jsx)(ex,{variant:"secondary",className:"text-xs",children:e.type})]}),(e=>{if("enum"===e.type){var t;return(0,s.jsxs)(K,{value:e.value,onValueChange:t=>u(e.name,t),children:[(0,s.jsx)(Y,{className:"w-full",children:(0,s.jsx)($,{placeholder:"Select an option"})}),(0,s.jsx)(X,{children:null==(t=e.enum)?void 0:t.map(e=>(0,s.jsx)(Q,{value:e,children:e},e))})]})}return"boolean"===e.type?(0,s.jsxs)("div",{className:"flex items-center space-x-3 py-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.value,onChange:t=>u(e.name,t.target.checked),className:"w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"}),(0,s.jsx)("span",{className:"text-sm",children:e.value?"Enabled":"Disabled"})]}):"array"===e.type||"object"===e.type?(0,s.jsx)(eu,{value:"string"==typeof e.value?e.value:JSON.stringify(e.value,null,2),onChange:t=>u(e.name,t.target.value),placeholder:"Enter ".concat(e.type," as JSON"),className:"font-mono text-sm h-20 resize-none"}):(0,s.jsx)(U,{type:"number"===e.type||"integer"===e.type?"number":"text",value:e.value,onChange:t=>u(e.name,t.target.value),placeholder:"Enter ".concat(e.name),className:"text-sm"})})(e)]},e.name))}),(0,s.jsxs)(G,{className:"flex gap-2",children:[(0,s.jsxs)(d,{variant:"outline",onClick:()=>m("cancel"),disabled:n,children:[(0,s.jsx)(T.A,{className:"h-4 w-4 mr-2"}),"Cancel"]}),(0,s.jsx)(d,{variant:"outline",onClick:()=>m("decline"),disabled:n,children:"Decline"}),(0,s.jsxs)(d,{onClick:()=>m("accept"),disabled:n,children:[n?(0,s.jsx)(z.A,{className:"h-4 w-4 mr-2 animate-spin"}):(0,s.jsx)(C.A,{className:"h-4 w-4 mr-2"}),"Accept"]})]})]})})}function eE(e){var t;let{serverConfig:r}=e,o=ed("ToolsTab"),[l,i]=(0,a.useState)({}),[c,u]=(0,a.useState)(""),[m,x]=(0,a.useState)([]),[h,f]=(0,a.useState)(null),[p,g]=(0,a.useState)(!1),[v,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)(""),[y,w]=(0,a.useState)(null),[k,S]=(0,a.useState)(null),[C,A]=(0,a.useState)(!1);(0,a.useEffect)(()=>(r&&T(),()=>{y&&y.close()}),[r,o]),(0,a.useEffect)(()=>{c&&l[c]&&O(l[c].inputSchema)},[c,l,o]);let T=async()=>{let e=r||null;if(!e)return void o.warn("Cannot fetch tools: no server config available");o.info("Starting tool fetch",{serverConfig:e}),y&&(y.close(),w(null)),b(!0),N(""),i({});let t=Date.now();try{var s;let r=await fetch("/api/mcp/tools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list",serverConfig:e})});if(!r.ok){let e="HTTP error! status: ".concat(r.status);throw o.error("Tools fetch HTTP error",{status:r.status}),Error(e)}let a=null==(s=r.body)?void 0:s.getReader(),n=new TextDecoder;if(!a)throw o.error("Tools fetch error: no response body"),Error("No response body");let l=0;for(;;){let{done:r,value:s}=await a.read();if(r)break;for(let r of n.decode(s).split("\n"))if(r.startsWith("data: ")){let s=r.slice(6);if("[DONE]"===s)return void b(!1);try{let r=JSON.parse(s);if("tools_list"===r.type){l=Object.keys(r.tools||{}).length,i(r.tools||{});let s=Date.now()-t;o.info("Tools fetch completed successfully",{serverConfig:e,toolCount:l,duration:s,tools:r.tools})}else if("tool_error"===r.type){o.error("Tools fetch error from server",{error:r.error}),N(r.error),b(!1);return}}catch(e){o.warn("Failed to parse SSE data",{data:s,error:e})}}}}catch(t){let e=t instanceof Error?t.message:"Unknown error";o.error("Tools fetch network error",{error:e},t instanceof Error?t:void 0),N("Network error fetching tools")}finally{b(!1)}},O=e=>{if(!e||!e.properties)return void x([]);let t=[],r=e.required||[];Object.entries(e.properties).forEach(e=>{let[s,a]=e,n=a.enum?"enum":a.type||"string";t.push({name:s,type:n,description:a.description,required:r.includes(s),value:E(n,a.enum),enum:a.enum,minimum:a.minimum,maximum:a.maximum,pattern:a.pattern})}),x(t)},E=(e,t)=>{switch(e){case"enum":return(null==t?void 0:t[0])||"";case"string":case"number":case"integer":default:return"";case"boolean":return!1;case"array":return[];case"object":return{}}},_=(e,t)=>{x(r=>r.map(r=>r.name===e?{...r,value:t}:r))},M=async()=>{if(!c)return void o.warn("Cannot execute tool: no tool selected");let e=r||null;if(!e)return void o.warn("Cannot execute tool: no server config available");g(!0),N(""),f(null);let t=Date.now();try{var s;let r=(()=>{let e={},t=0,r=0;return m.forEach(s=>{if(""!==s.value&&null!==s.value&&void 0!==s.value){let a=s.value;t++;try{"number"===s.type||"integer"===s.type?(a=Number(s.value),isNaN(a)&&(o.warn("Invalid number value for field",{fieldName:s.name,value:s.value}),r++)):"boolean"===s.type?a=!!s.value:("array"===s.type||"object"===s.type)&&(a=JSON.parse(s.value)),e[s.name]=a}catch(t){o.warn("Failed to process field value",{fieldName:s.name,type:s.type,value:s.value,error:t}),r++,e[s.name]=s.value}}}),e})();o.info("Starting tool execution",{toolName:c,parameters:r});let a=await fetch("/api/mcp/tools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"execute",serverConfig:e,toolName:c,parameters:r})});if(!a.ok){let e="HTTP error! status: ".concat(a.status);throw o.error("Tool execution HTTP error",{toolName:c,status:a.status}),Error(e)}let n=null==(s=a.body)?void 0:s.getReader(),l=new TextDecoder;if(!n)throw o.error("Tool execution error: no response body",{toolName:c}),Error("No response body");for(;;){let{done:e,value:r}=await n.read();if(e)break;for(let e of l.decode(r).split("\n"))if(e.startsWith("data: ")){let r=e.slice(6);if("[DONE]"===r)return void g(!1);try{let e=JSON.parse(r);if("tool_result"===e.type){let r=e.result,s=Date.now()-t;o.info("Tool execution completed successfully",{toolName:c,duration:s,result:r}),f(r)}else if("tool_error"===e.type){o.error("Tool execution error from server",{toolName:c,error:e.error}),N(e.error),g(!1);return}else"elicitation_request"===e.type?S({requestId:e.requestId,message:e.message,schema:e.schema,timestamp:e.timestamp}):"elicitation_complete"===e.type&&S(null)}catch(e){o.warn("Failed to parse tool execution SSE data",{toolName:c,data:r,error:e})}}}}catch(t){let e=t instanceof Error?t.message:"Unknown error";o.error("Tool execution network error",{toolName:c,error:e},t instanceof Error?t:void 0),N("Error executing tool")}finally{g(!1)}},R=async(e,t)=>{if(!k)return void o.warn("Cannot handle elicitation response: no active request");A(!0);try{let r=null;r="accept"===e?{action:"accept",content:t||{}}:{action:e};let s=await fetch("/api/mcp/tools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"respond",requestId:k.requestId,response:r})});if(!s.ok){let t="HTTP error! status: ".concat(s.status);throw o.error("Elicitation response HTTP error",{requestId:k.requestId,action:e,status:s.status}),Error(t)}S(null)}catch(r){let t=r instanceof Error?r.message:"Unknown error";o.error("Error responding to elicitation request",{requestId:k.requestId,action:e,error:t},r instanceof Error?r:void 0),N("Error responding to elicitation request")}finally{A(!1)}},P=Object.keys(l);return r?(0,s.jsxs)("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:[(0,s.jsxs)(eb,{direction:"vertical",className:"flex-1",children:[(0,s.jsx)(ej,{defaultSize:70,minSize:30,children:(0,s.jsxs)(eb,{direction:"horizontal",className:"h-full",children:[(0,s.jsx)(ej,{defaultSize:30,minSize:20,maxSize:50,children:(0,s.jsxs)("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(ey.A,{className:"h-3 w-3 text-muted-foreground"}),(0,s.jsx)("h2",{className:"text-xs font-semibold text-foreground",children:"Tools"}),(0,s.jsx)(ex,{variant:"secondary",className:"text-xs font-mono",children:P.length})]}),(0,s.jsx)(d,{onClick:T,variant:"ghost",size:"sm",disabled:v,children:(0,s.jsx)(z.A,{className:"h-3 w-3 ".concat(v?"animate-spin":""," cursor-pointer")})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"p-2",children:v?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:(0,s.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading tools..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available tools from server"})]}):0===P.length?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No tools available"})}):(0,s.jsx)("div",{className:"space-y-1",children:P.map(e=>{var t;return(0,s.jsx)("div",{className:"cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ".concat(c===e?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"),onClick:()=>{u(e)},children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 mb-1",children:(0,s.jsx)("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e})}),(null==(t=l[e])?void 0:t.description)&&(0,s.jsx)("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:l[e].description})]}),(0,s.jsx)(ew.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},e)})})})})})]})}),(0,s.jsx)(eN,{withHandle:!0}),(0,s.jsx)(ej,{defaultSize:70,minSize:50,children:(0,s.jsx)("div",{className:"h-full flex flex-col bg-background",children:c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsx)("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:c})})}),(0,s.jsx)(d,{onClick:M,disabled:p||!c,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:p?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(z.A,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),(0,s.jsx)("span",{className:"font-mono text-xs",children:k?"Waiting...":"Running"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.A,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),(0,s.jsx)("span",{className:"font-mono text-xs",children:"Execute"})]})})]}),(null==(t=l[c])?void 0:t.description)&&(0,s.jsx)("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:l[c].description})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"px-6 py-6",children:0===m.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:(0,s.jsx)(ek.A,{className:"h-4 w-4 text-muted-foreground"})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"No parameters required"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"This tool can be executed directly"})]}):(0,s.jsx)("div",{className:"space-y-8",children:m.map(e=>{var t;return(0,s.jsxs)("div",{className:"group",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("code",{className:"font-mono text-xs font-semibold text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e.name}),e.required&&(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-amber-400 dark:bg-amber-500 rounded-full",title:"Required field"})]}),e.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed max-w-md font-medium",children:e.description})]}),(0,s.jsx)(ex,{variant:"secondary",className:"text-xs font-mono font-medium",children:e.type})]}),(0,s.jsx)("div",{className:"space-y-2",children:"enum"===e.type?(0,s.jsxs)(K,{value:e.value,onValueChange:t=>_(e.name,t),children:[(0,s.jsx)(Y,{className:"w-full bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs",children:(0,s.jsx)($,{placeholder:"Select an option",className:"font-mono text-xs"})}),(0,s.jsx)(X,{children:null==(t=e.enum)?void 0:t.map(e=>(0,s.jsx)(Q,{value:e,className:"font-mono text-xs",children:e},e))})]}):"boolean"===e.type?(0,s.jsxs)("div",{className:"flex items-center space-x-3 py-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.value,onChange:t=>_(e.name,t.target.checked),className:"w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"}),(0,s.jsx)("span",{className:"text-xs text-foreground font-medium",children:e.value?"Enabled":"Disabled"})]}):"array"===e.type||"object"===e.type?(0,s.jsx)(eu,{value:"string"==typeof e.value?e.value:JSON.stringify(e.value,null,2),onChange:t=>_(e.name,t.target.value),placeholder:"Enter ".concat(e.type," as JSON"),className:"font-mono text-xs h-20 bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 resize-none"}):(0,s.jsx)(U,{type:"number"===e.type||"integer"===e.type?"number":"text",value:e.value,onChange:t=>_(e.name,t.target.value),placeholder:"Enter ".concat(e.name),className:"bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs"})})]},e.name)})})})})})]}):(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:(0,s.jsx)(ey.A,{className:"h-5 w-5 text-muted-foreground"})}),(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a tool"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a tool from the left to configure parameters"})]})})})})]})}),(0,s.jsx)(eN,{withHandle:!0}),(0,s.jsx)(ej,{defaultSize:30,minSize:15,maxSize:70,children:(0,s.jsxs)("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[(0,s.jsx)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:(0,s.jsx)("h2",{className:"text-xs font-semibold text-foreground",children:"Response"})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:j?(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:j})}):h?(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(eS.Ay,{src:h,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Execute a tool to see results here"})})})]})})]}),(0,s.jsx)(eO,{elicitationRequest:k,onResponse:R,loading:C})]}):(0,s.jsx)(n.Zp,{children:(0,s.jsx)(n.Wu,{className:"pt-6",children:(0,s.jsx)("p",{className:"text-center text-muted-foreground font-medium",children:"Please select a server to view tools"})})})}var ez=r(4395),e_=r(9890),eM=r(2657);function eR(e){var t,r,o,l;let{serverConfig:i}=e,[c,u]=(0,a.useState)({}),[m,x]=(0,a.useState)(""),[h,f]=(0,a.useState)(null),[p,g]=(0,a.useState)(!1),[v,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)("");(0,a.useEffect)(()=>{i&&y()},[i]);let y=async()=>{let e=i||null;if(e){b(!0),N(""),u({});try{let t=await fetch("/api/mcp/resources/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:e})}),r=await t.json();t.ok?u(r.resources||{}):N(r.error||"Failed to fetch resources")}catch(e){N("Network error fetching resources: ".concat(e))}finally{b(!1)}}},w=async e=>{let t=i||null;if(t){g(!0),N("");try{let r=await fetch("/api/mcp/resources/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:t,uri:e})}),s=await r.json();r.ok?f(s.content):N(s.error||"Failed to read resource")}catch(e){N("Network error reading resource: ".concat(e))}finally{g(!1)}}},k=Object.values(c).flat();return i?(0,s.jsx)("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:(0,s.jsxs)(eb,{direction:"vertical",className:"flex-1",children:[(0,s.jsx)(ej,{defaultSize:70,minSize:30,children:(0,s.jsxs)(eb,{direction:"horizontal",className:"h-full",children:[(0,s.jsx)(ej,{defaultSize:30,minSize:20,maxSize:50,children:(0,s.jsxs)("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(ez.A,{className:"h-3 w-3 text-muted-foreground"}),(0,s.jsx)("h2",{className:"text-xs font-semibold text-foreground",children:"Resources"}),(0,s.jsx)(ex,{variant:"secondary",className:"text-xs font-mono",children:k.length})]}),(0,s.jsx)(d,{onClick:y,variant:"ghost",size:"sm",disabled:v,children:(0,s.jsx)(z.A,{className:"h-3 w-3 ".concat(v?"animate-spin":""," cursor-pointer")})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"p-2",children:v?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:(0,s.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading resources..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available resources from server"})]}):0===k.length?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No resources available"})}):(0,s.jsx)("div",{className:"space-y-1",children:k.map(e=>(0,s.jsx)("div",{className:"cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ".concat(m===e.uri?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"),onClick:()=>x(e.uri),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,s.jsx)(e_.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,s.jsx)("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e.name})]}),e.description&&(0,s.jsx)("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:e.description}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1 font-mono truncate",children:e.uri}),e.mimeType&&(0,s.jsx)(ex,{variant:"outline",className:"text-xs mt-2 font-mono",children:e.mimeType})]}),(0,s.jsx)(ew.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},e.uri))})})})})]})}),(0,s.jsx)(eN,{withHandle:!0}),(0,s.jsx)(ej,{defaultSize:70,minSize:50,children:(0,s.jsx)("div",{className:"h-full flex flex-col bg-background",children:m?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsx)("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:(null==(t=k.find(e=>e.uri===m))?void 0:t.name)||m})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate max-w-md",children:m})]}),(0,s.jsx)(d,{onClick:()=>w(m),disabled:p,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:p?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(z.A,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),(0,s.jsx)("span",{className:"font-mono text-xs",children:"Reading"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eM.A,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),(0,s.jsx)("span",{className:"font-mono text-xs",children:"Read"})]})})]}),(null==(r=k.find(e=>e.uri===m))?void 0:r.description)&&(0,s.jsx)("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:null==(o=k.find(e=>e.uri===m))?void 0:o.description})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"px-6 py-6",children:h?(0,s.jsx)("div",{className:"space-y-4",children:null==h||null==(l=h.contents)?void 0:l.map((e,t)=>(0,s.jsxs)("div",{className:"group",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,s.jsx)(ex,{variant:"secondary",className:"text-xs font-mono font-medium",children:e.type}),e.mimeType&&(0,s.jsx)(ex,{variant:"outline",className:"text-xs font-mono",children:e.mimeType})]}),(0,s.jsx)("div",{className:"border border-border rounded-md overflow-hidden",children:"text"===e.type?(0,s.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap p-4 bg-background overflow-auto max-h-96",children:e.text}):(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(eS.Ay,{src:e,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"0",borderRadius:"0",border:"none"}})})})]},t))}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:(0,s.jsx)(eM.A,{className:"h-4 w-4 text-muted-foreground"})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Ready to read resource"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Click the Read button to view resource content"})]})})})})]}):(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:(0,s.jsx)(ez.A,{className:"h-5 w-5 text-muted-foreground"})}),(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a resource"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a resource from the left to preview its content"})]})})})})]})}),(0,s.jsx)(eN,{withHandle:!0}),(0,s.jsx)(ej,{defaultSize:30,minSize:15,maxSize:70,children:(0,s.jsxs)("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[(0,s.jsx)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:(0,s.jsx)("h2",{className:"text-xs font-semibold text-foreground",children:"Status"})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:j?(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:j})}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Resource operations status will appear here"})})})]})})]})}):(0,s.jsx)(n.Zp,{children:(0,s.jsx)(n.Wu,{className:"pt-6",children:(0,s.jsx)("p",{className:"text-center text-muted-foreground font-medium",children:"Please select a server to view resources"})})})}function eP(e){let{serverConfig:t}=e,[r,o]=(0,a.useState)({}),[l,i]=(0,a.useState)(""),[c,u]=(0,a.useState)(null),[m,x]=(0,a.useState)([]),[h,f]=(0,a.useState)(null),[p,g]=(0,a.useState)(!1),[v,b]=(0,a.useState)(!1),[j,N]=(0,a.useState)("");(0,a.useEffect)(()=>{t&&y()},[t]),(0,a.useEffect)(()=>{(null==c?void 0:c.arguments)?w(c.arguments):x([])},[c]);let y=async()=>{let e=t||null;if(e){b(!0),N("");try{let t=await fetch("/api/mcp/prompts/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:e})}),r=await t.json();console.log("bigData",r),t.ok?o(r.prompts||{}):N(r.error||"Failed to fetch prompts")}catch(e){N("Network error fetching prompts")}finally{b(!1)}}},w=e=>{if(!e||0===e.length)return void x([]);x(e.map(e=>({name:e.name,type:"string",description:e.description,required:e.required||!1,value:""})))},k=(e,t)=>{x(r=>r.map(r=>r.name===e?{...r,value:t}:r))},S=async()=>{if(!l)return;let e=t||null;if(e){g(!0),N("");try{let t=(()=>{let e={};return m.forEach(t=>{if(""!==t.value&&null!==t.value&&void 0!==t.value){let r=t.value;if("number"===t.type||"integer"===t.type)r=Number(t.value);else if("boolean"===t.type)r=!!t.value;else if("array"===t.type||"object"===t.type)try{r=JSON.parse(t.value)}catch(e){r=t.value}e[t.name]=r}}),e})(),r=await fetch("/api/mcp/prompts/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:e,name:l,args:t})}),s=await r.json();r.ok?f(s.content):N(s.error||"Failed to get prompt")}catch(e){N("Error getting prompt: ".concat(e))}finally{g(!1)}}},C=Object.values(r).flat().map(e=>e.name);return t?(0,s.jsx)("div",{className:"h-[calc(100vh-120px)] flex flex-col",children:(0,s.jsxs)(eb,{direction:"vertical",className:"flex-1",children:[(0,s.jsx)(ej,{defaultSize:70,minSize:30,children:(0,s.jsxs)(eb,{direction:"horizontal",className:"h-full",children:[(0,s.jsx)(ej,{defaultSize:30,minSize:20,maxSize:50,children:(0,s.jsxs)("div",{className:"h-full flex flex-col border-r border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-4 border-b border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(eT.A,{className:"h-3 w-3 text-muted-foreground"}),(0,s.jsx)("h2",{className:"text-xs font-semibold text-foreground",children:"Prompts"}),(0,s.jsx)(ex,{variant:"secondary",className:"text-xs font-mono",children:C.length})]}),(0,s.jsx)(d,{onClick:y,variant:"ghost",size:"sm",disabled:v,children:(0,s.jsx)(z.A,{className:"h-3 w-3 ".concat(v?"animate-spin":""," cursor-pointer")})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"p-2",children:v?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-8 h-8 bg-muted rounded-full flex items-center justify-center mb-3",children:(0,s.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground animate-spin cursor-pointer"})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Loading prompts..."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Fetching available prompts from server"})]}):0===C.length?(0,s.jsx)("div",{className:"text-center py-8",children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No prompts available"})}):(0,s.jsx)("div",{className:"space-y-1",children:C.map(e=>{var t,a;return(0,s.jsx)("div",{className:"cursor-pointer transition-all duration-200 hover:bg-muted/30 dark:hover:bg-muted/50 p-3 rounded-md mx-2 ".concat(l===e?"bg-muted/50 dark:bg-muted/50 shadow-sm border border-border ring-1 ring-ring/20":"hover:shadow-sm"),onClick:()=>{i(e),u(Object.values(r).flat().find(t=>t.name===e)||null)},children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 mb-1",children:(0,s.jsx)("code",{className:"font-mono text-xs font-medium text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e})}),(null==(t=Object.values(r).flat().find(t=>t.name===e))?void 0:t.description)&&(0,s.jsx)("p",{className:"text-xs mt-2 line-clamp-2 leading-relaxed text-muted-foreground",children:null==(a=Object.values(r).flat().find(t=>t.name===e))?void 0:a.description})]}),(0,s.jsx)(ew.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},e)})})})})})]})}),(0,s.jsx)(eN,{withHandle:!0}),(0,s.jsx)(ej,{defaultSize:70,minSize:50,children:(0,s.jsx)("div",{className:"h-full flex flex-col bg-background",children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border bg-background",children:[(0,s.jsx)("div",{className:"space-y-2",children:(0,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsx)("code",{className:"font-mono font-semibold text-foreground bg-muted px-2 py-1 rounded-md border border-border text-xs",children:l})})}),(0,s.jsx)(d,{onClick:S,disabled:p||!l,className:"bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm transition-all duration-200 cursor-pointer",size:"sm",children:p?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(z.A,{className:"h-3 w-3 mr-1.5 animate-spin cursor-pointer"}),(0,s.jsx)("span",{className:"font-mono text-xs",children:"Loading"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.A,{className:"h-3 w-3 mr-1.5 cursor-pointer"}),(0,s.jsx)("span",{className:"font-mono text-xs",children:"Get Prompt"})]})})]}),(null==c?void 0:c.description)&&(0,s.jsx)("div",{className:"px-6 py-4 bg-muted/50 border-b border-border",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed font-medium",children:c.description})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"px-6 py-6",children:0===m.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-muted rounded-full flex items-center justify-center mb-3",children:(0,s.jsx)(ek.A,{className:"h-4 w-4 text-muted-foreground"})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"No parameters required"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"This prompt can be retrieved directly"})]}):(0,s.jsx)("div",{className:"space-y-8",children:m.map(e=>{var t;return(0,s.jsxs)("div",{className:"group",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("code",{className:"font-mono text-xs font-semibold text-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:e.name}),e.required&&(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-amber-400 dark:bg-amber-500 rounded-full",title:"Required field"})]}),e.description&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed max-w-md font-medium",children:e.description})]}),(0,s.jsx)(ex,{variant:"secondary",className:"text-xs font-mono font-medium",children:e.type})]}),(0,s.jsx)("div",{className:"space-y-2",children:"enum"===e.type?(0,s.jsxs)(K,{value:e.value,onValueChange:t=>k(e.name,t),children:[(0,s.jsx)(Y,{className:"w-full bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs",children:(0,s.jsx)($,{placeholder:"Select an option",className:"font-mono text-xs"})}),(0,s.jsx)(X,{children:null==(t=e.enum)?void 0:t.map(e=>(0,s.jsx)(Q,{value:e,className:"font-mono text-xs",children:e},e))})]}):"boolean"===e.type?(0,s.jsxs)("div",{className:"flex items-center space-x-3 py-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.value,onChange:t=>k(e.name,t.target.checked),className:"w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"}),(0,s.jsx)("span",{className:"text-xs text-foreground font-medium",children:e.value?"Enabled":"Disabled"})]}):"array"===e.type||"object"===e.type?(0,s.jsx)(eu,{value:"string"==typeof e.value?e.value:JSON.stringify(e.value,null,2),onChange:t=>k(e.name,t.target.value),placeholder:"Enter ".concat(e.type," as JSON"),className:"font-mono text-xs h-20 bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 resize-none"}):(0,s.jsx)(U,{type:"number"===e.type||"integer"===e.type?"number":"text",value:e.value,onChange:t=>k(e.name,t.target.value),placeholder:"Enter ".concat(e.name),className:"bg-background border-border hover:border-border/80 focus:border-ring focus:ring-0 font-medium text-xs"})})]},e.name)})})})})})]}):(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 bg-muted rounded-full flex items-center justify-center mx-auto mb-3",children:(0,s.jsx)(eT.A,{className:"h-5 w-5 text-muted-foreground"})}),(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Select a prompt"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Choose a prompt from the left to view details"})]})})})})]})}),(0,s.jsx)(eN,{withHandle:!0}),(0,s.jsx)(ej,{defaultSize:30,minSize:15,maxSize:70,children:(0,s.jsxs)("div",{className:"h-full flex flex-col border-t border-border bg-background",children:[(0,s.jsx)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:(0,s.jsx)("h2",{className:"text-xs font-semibold text-foreground",children:"Prompt Content"})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:j?(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded text-destructive text-xs font-medium",children:j})}):h?(0,s.jsx)(ef,{className:"h-full",children:(0,s.jsx)("div",{className:"p-4",children:"string"==typeof h?(0,s.jsx)("pre",{className:"whitespace-pre-wrap text-xs font-mono bg-muted p-4 rounded-md border border-border",children:h}):(0,s.jsx)(eS.Ay,{src:h,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"16px",borderRadius:"8px",border:"1px solid hsl(var(--border))"}})})}):(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground font-medium",children:"Get a prompt to see its content here"})})})]})})]})}):(0,s.jsx)(n.Zp,{children:(0,s.jsx)(n.Wu,{className:"pt-6",children:(0,s.jsx)("p",{className:"text-center text-muted-foreground font-medium",children:"Please select a server to view prompts"})})})}var eL=r(1366),eI=r(2596),eU=r(9688);function eD(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,eU.QP)((0,eI.$)(t))}function eF(e){return new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}).format(e)}function eq(e,t,r){return{id:Math.random().toString(36).substr(2,9),role:e,content:t,timestamp:new Date,attachments:r,metadata:{createdAt:new Date().toISOString()}}}var eJ=function(e){return e.CLAUDE_OPUS_4_0="claude-opus-4-0",e.CLAUDE_SONNET_4_0="claude-sonnet-4-0",e.CLAUDE_3_7_SONNET_LATEST="claude-3-7-sonnet-latest",e.CLAUDE_3_5_SONNET_LATEST="claude-3-5-sonnet-latest",e.CLAUDE_3_5_HAIKU_LATEST="claude-3-5-haiku-latest",e.O3_MINI="o3-mini",e.O3="o3",e.O4_MINI="o4-mini",e.GPT_4_1="gpt-4.1",e.GPT_4_1_MINI="gpt-4.1-mini",e.GPT_4_1_NANO="gpt-4.1-nano",e.GPT_4O="gpt-4o",e.GPT_4O_MINI="gpt-4o-mini",e.GPT_4_TURBO="gpt-4-turbo",e.GPT_4="gpt-4",e.GPT_3_5_TURBO="gpt-3.5-turbo",e.O1="o1",e}({});let eB=[{id:"claude-opus-4-0",name:"Claude Opus 4",provider:"anthropic"},{id:"claude-sonnet-4-0",name:"Claude Sonnet 4",provider:"anthropic"},{id:"claude-3-7-sonnet-latest",name:"Claude Sonnet 3.7",provider:"anthropic"},{id:"claude-3-5-sonnet-latest",name:"Claude Sonnet 3.5",provider:"anthropic"},{id:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5",provider:"anthropic"},{id:"o3-mini",name:"O3 Mini",provider:"openai"},{id:"o3",name:"O3",provider:"openai"},{id:"o4-mini",name:"O4 Mini",provider:"openai"},{id:"gpt-4.1",name:"GPT-4.1",provider:"openai"},{id:"gpt-4.1-mini",name:"GPT-4.1 Mini",provider:"openai"},{id:"gpt-4.1-nano",name:"GPT-4.1 Nano",provider:"openai"},{id:"gpt-4o",name:"GPT-4o",provider:"openai"},{id:"gpt-4o-mini",name:"GPT-4o Mini",provider:"openai"},{id:"gpt-4-turbo",name:"GPT-4 Turbo",provider:"openai"},{id:"gpt-4",name:"GPT-4",provider:"openai"},{id:"gpt-3.5-turbo",name:"GPT-3.5 Turbo",provider:"openai"},{id:"o1",name:"O1",provider:"openai"}],eH="mcp-inspector-provider-tokens",eG={anthropic:"",openai:"",ollama:"local",ollamaBaseUrl:"http://localhost:11434"};function eV(){let[e,t]=(0,a.useState)(eG),[r,s]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(eH);if(e){let r=JSON.parse(e);t(r)}}catch(e){console.warn("Failed to load provider tokens from localStorage:",e)}s(!0)},[]),(0,a.useEffect)(()=>{if(r&&1)try{localStorage.setItem(eH,JSON.stringify(e))}catch(e){console.warn("Failed to save provider tokens to localStorage:",e)}},[e,r]);let n=(0,a.useCallback)((e,r)=>{t(t=>({...t,[e]:r}))},[]),o=(0,a.useCallback)(e=>{t(t=>({...t,[e]:""}))},[]),l=(0,a.useCallback)(()=>{t(eG)},[]),i=(0,a.useCallback)(t=>{var r;return!!(null==(r=e[t])?void 0:r.trim())},[e]),c=(0,a.useCallback)(t=>e[t]||"",[e]),d=(0,a.useCallback)(()=>e.ollamaBaseUrl||eG.ollamaBaseUrl,[e.ollamaBaseUrl]);return{tokens:e,setToken:n,clearToken:o,clearAllTokens:l,hasToken:i,getToken:c,getOllamaBaseUrl:d,setOllamaBaseUrl:(0,a.useCallback)(e=>{t(t=>({...t,ollamaBaseUrl:e}))},[])}}class eZ{setBaseUrl(e){this.baseUrl=e}async isOllamaRunning(){try{return(await fetch("".concat(this.baseUrl,"/api/version"),{method:"GET",signal:AbortSignal.timeout(3e3)})).ok}catch(e){return!1}}async getAvailableModels(){try{let e=await fetch("".concat(this.baseUrl,"/api/tags"),{method:"GET",signal:AbortSignal.timeout(5e3)});if(!e.ok)return[];return(await e.json()).models.map(e=>e.name)}catch(e){return console.warn("Failed to fetch Ollama models:",e),[]}}async checkModelExists(e){return(await this.getAvailableModels()).some(t=>t===e||t.startsWith("".concat(e,":")))}async getFilteredAvailableModels(e){let t=await this.getAvailableModels();return e.filter(e=>t.some(t=>t===e||t.startsWith("".concat(e,":"))))}constructor(e="http://localhost:11434"){this.baseUrl=e}}let eW=new eZ,eK=async e=>{let t=e?new eZ(e):eW;return await t.isOllamaRunning()?{isRunning:!0,availableModels:await t.getAvailableModels()}:{isRunning:!1,availableModels:[]}};var e$=r(760),eY=r(2605),eX=r(133),eQ=r(6874),e0=r.n(eQ),e1=r(8240),e2=r(5405);let e4={code:function(e){let{node:t,inline:r,className:a,children:n,...o}=e;return r?(0,s.jsx)("code",{className:"".concat(a," text-sm bg-zinc-100 dark:bg-zinc-800 py-0.5 px-1 rounded-md"),...o,children:n}):(0,s.jsx)("div",{className:"not-prose flex flex-col",children:(0,s.jsx)("div",{...o,className:"text-sm w-full overflow-x-auto dark:bg-zinc-900 p-4 border border-zinc-200 dark:border-zinc-700 rounded-xl dark:text-zinc-50 text-zinc-900 font-mono whitespace-pre-wrap break-words",children:n})})},pre:e=>{let{children:t}=e;return(0,s.jsx)(s.Fragment,{children:t})},ol:e=>{let{children:t,...r}=e;return(0,s.jsx)("ol",{className:"list-decimal list-outside ml-4",...r,children:t})},li:e=>{let{children:t,...r}=e;return(0,s.jsx)("li",{className:"py-1",...r,children:t})},ul:e=>{let{children:t,...r}=e;return(0,s.jsx)("ul",{className:"list-decimal list-outside ml-4",...r,children:t})},strong:e=>{let{children:t,...r}=e;return(0,s.jsx)("span",{className:"font-semibold",...r,children:t})},a:e=>{let{children:t,...r}=e;return(0,s.jsx)(e0(),{className:"text-blue-500 hover:underline",target:"_blank",rel:"noreferrer",...r,children:t})},h1:e=>{let{children:t,...r}=e;return(0,s.jsx)("h1",{className:"text-3xl font-semibold mt-6 mb-2",...r,children:t})},h2:e=>{let{children:t,...r}=e;return(0,s.jsx)("h2",{className:"text-2xl font-semibold mt-6 mb-2",...r,children:t})},h3:e=>{let{children:t,...r}=e;return(0,s.jsx)("h3",{className:"text-xl font-semibold mt-6 mb-2",...r,children:t})},h4:e=>{let{children:t,...r}=e;return(0,s.jsx)("h4",{className:"text-lg font-semibold mt-6 mb-2",...r,children:t})},h5:e=>{let{children:t,...r}=e;return(0,s.jsx)("h5",{className:"text-base font-semibold mt-6 mb-2",...r,children:t})},h6:e=>{let{children:t,...r}=e;return(0,s.jsx)("h6",{className:"text-sm font-semibold mt-6 mb-2",...r,children:t})}},e3=[e2.A],e5=(0,a.memo)(e=>{let{children:t}=e;return(0,s.jsx)(e1.oz,{remarkPlugins:e3,components:e4,children:t})},(e,t)=>e.children===t.children);function e6(e){let{message:t,onSave:r,onCancel:n}=e,[o,l]=(0,a.useState)(t.content),i=(0,a.useRef)(null);(0,a.useEffect)(()=>{i.current&&(i.current.focus(),i.current.select(),c())},[]);let c=()=>{i.current&&(i.current.style.height="auto",i.current.style.height="".concat(i.current.scrollHeight,"px"))},u=()=>{o.trim()!==t.content.trim()?r(o.trim()):n()};return(0,s.jsxs)("div",{className:"w-full space-y-3",children:[(0,s.jsx)(eu,{ref:i,value:o,onChange:e=>{l(e.target.value),c()},onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),u()),"Escape"===e.key&&(e.preventDefault(),n())},className:"min-h-[100px] resize-none",placeholder:"Edit your message..."}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)(d,{variant:"outline",size:"sm",onClick:n,children:"Cancel"}),(0,s.jsx)(d,{size:"sm",onClick:u,disabled:!o.trim(),children:"Save"})]})]})}var e8=r(646),e7=r(4861),e9=r(4186);function te(e){let{data:t,className:r}=e,[n,o]=(0,a.useState)(!1),l=JSON.stringify(t,null,2),c=async()=>{try{await navigator.clipboard.writeText(l),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error("Failed to copy:",e)}};return(0,s.jsxs)("div",{className:(0,i.cn)("relative group",r),children:[(0,s.jsx)("button",{onClick:c,className:"absolute top-2 right-2 p-1.5 rounded-md bg-background/80 backdrop-blur-sm border opacity-0 group-hover:opacity-100 transition-opacity hover:bg-muted",title:"Copy JSON",children:n?(0,s.jsx)(C.A,{className:"h-3 w-3 text-green-600/70 dark:text-green-400/70"}):(0,s.jsx)(R.A,{className:"h-3 w-3"})}),(0,s.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap overflow-x-auto p-3 bg-muted/20 rounded-md border",children:(0,s.jsx)("code",{dangerouslySetInnerHTML:{__html:l.replace(/"([^"]+)":/g,'<span class="text-blue-600/70 dark:text-blue-400/70">"$1"</span>:').replace(/: "([^"]*)"/g,': <span class="text-foreground">"$1"</span>').replace(/: (true|false)/g,': <span class="text-purple-600/70 dark:text-purple-400/70">$1</span>').replace(/: (null)/g,': <span class="text-muted-foreground/60">$1</span>').replace(/: (-?\d+(?:\.\d+)?)/g,': <span class="text-orange-600/70 dark:text-orange-400/70">$1</span>')}})})]})}function tt(e){let{data:t,depth:r=0}=e,[n,o]=(0,a.useState)(r<2);if("object"!=typeof t||null===t)return(0,s.jsx)("span",{className:(0,i.cn)("text-sm","string"==typeof t&&"text-foreground","number"==typeof t&&"text-orange-600/70 dark:text-orange-400/70","boolean"==typeof t&&"text-purple-600/70 dark:text-purple-400/70",null===t&&"text-muted-foreground/60"),children:"string"==typeof t?'"'.concat(t,'"'):String(t)});let l=Array.isArray(t),c=l?t.map((e,t)=>[t,e]):Object.entries(t),d=l?"[":"{",u=l?"]":"}";return 0===c.length?(0,s.jsxs)("span",{className:"text-sm text-muted-foreground",children:[d,u]}):(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsxs)("button",{onClick:()=>o(!n),className:"flex items-center gap-1 hover:bg-muted/50 rounded px-1 transition-colors",children:[n?(0,s.jsx)(L.A,{className:"h-3 w-3"}):(0,s.jsx)(ew.A,{className:"h-3 w-3"}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[d," ",!n&&"".concat(c.length," items")]})]}),n&&(0,s.jsx)("div",{className:"ml-4 border-l border-border pl-2 space-y-1",children:c.map(e=>{let[t,a]=e;return(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("span",{className:"text-blue-600/70 dark:text-blue-400/70 font-medium min-w-0 flex-shrink-0",children:[l?"[".concat(t,"]"):'"'.concat(t,'"'),":"]}),(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsx)(tt,{data:a,depth:r+1})})]},t)})}),n&&(0,s.jsx)("span",{className:"text-muted-foreground ml-4",children:u})]})}function tr(e){let{toolCall:t,toolResult:r,className:n}=e,[o,l]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1);return(0,s.jsxs)("div",{className:(0,i.cn)("border rounded-lg bg-gradient-to-br from-muted/20 to-muted/40 backdrop-blur-sm shadow-sm hover:shadow-md transition-all duration-200","completed"===t.status&&"border-green-200/50 dark:border-green-800/50","error"===t.status&&"border-red-200/50 dark:border-red-800/50","executing"===t.status&&"border-blue-200/50 dark:border-blue-800/50",n),children:[(0,s.jsxs)("button",{onClick:()=>l(!o),className:"w-full flex items-center justify-between p-4 hover:bg-muted/30 transition-all duration-200 rounded-t-lg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"p-2 rounded-md bg-background/50 border",children:(0,s.jsx)(ea,{className:"h-4 w-4 text-muted-foreground"})}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:"font-semibold text-sm",children:t.name}),(()=>{switch(t.status){case"completed":return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(e8.A,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70"}),(0,s.jsx)("div",{className:"absolute inset-0 animate-ping",children:(0,s.jsx)(e8.A,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70 opacity-20"})})]});case"error":return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(e7.A,{className:"h-4 w-4 text-red-600/70 dark:text-red-400/70"}),(0,s.jsx)("div",{className:"absolute inset-0 animate-pulse",children:(0,s.jsx)(e7.A,{className:"h-4 w-4 text-red-600/70 dark:text-red-400/70 opacity-30"})})]});case"executing":return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(e9.A,{className:"h-4 w-4 text-blue-600/70 dark:text-blue-400/70 animate-spin"}),(0,s.jsx)("div",{className:"absolute inset-0 animate-ping",children:(0,s.jsx)(e9.A,{className:"h-4 w-4 text-blue-600/70 dark:text-blue-400/70 opacity-20"})})]});default:return(0,s.jsx)(e9.A,{className:"h-4 w-4 text-muted-foreground/60"})}})()]})]}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:o?(0,s.jsx)(L.A,{className:"h-4 w-4 text-muted-foreground"}):(0,s.jsx)(ew.A,{className:"h-4 w-4 text-muted-foreground"})})]}),o&&(0,s.jsxs)("div",{className:"border-t bg-background/30 backdrop-blur-sm",children:[Object.keys(t.parameters).length>0&&(0,s.jsxs)("div",{className:"p-4 border-b border-border/50",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-blue-600/70 dark:bg-blue-400/70"}),"Parameters"]}),(0,s.jsx)("button",{onClick:()=>d(!c),className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-1 rounded bg-muted/50 hover:bg-muted",children:c?"Raw JSON":"Tree View"})]}),c?(0,s.jsx)(tt,{data:t.parameters}):(0,s.jsx)(te,{data:t.parameters})]}),r&&(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsxs)("h4",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3 flex items-center gap-2",children:[(0,s.jsx)("div",{className:(0,i.cn)("w-2 h-2 rounded-full",r.error?"bg-red-600/70 dark:bg-red-400/70":"bg-green-600/70 dark:bg-green-400/70")}),r.error?"Error":"Result"]}),(0,s.jsx)("div",{children:r.error?(0,s.jsx)("div",{className:"bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(e7.A,{className:"h-5 w-5 text-red-600/70 dark:text-red-400/70 flex-shrink-0 mt-0.5"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-foreground mb-1",children:"Tool execution failed"}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:r.error})]})]})}):(0,s.jsxs)("div",{className:"bg-green-50/30 dark:bg-green-950/20 border border-green-200/50 dark:border-green-800/50 rounded-lg overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-100/30 dark:bg-green-900/20 border-b border-green-200/50 dark:border-green-800/50",children:[(0,s.jsx)(e8.A,{className:"h-4 w-4 text-green-600/70 dark:text-green-400/70"}),(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Tool executed successfully"})]}),(0,s.jsx)("div",{className:"p-4",children:"object"==typeof r.result?(0,s.jsx)(te,{data:r.result}):(0,s.jsx)("div",{className:"text-sm text-foreground bg-muted/30 p-3 rounded border",children:String(r.result)})})]})})]})]})]})}let ts={src:"/_next/static/media/claude_logo.d33b25b0.png"},ta={src:"/_next/static/media/openai_logo.3f83154a.png"},tn={src:"/_next/static/media/ollama_logo.9f08a95b.svg"},to={src:"/_next/static/media/ollama_dark.9af45ac0.png"},tl=(e,t)=>{switch(e){case"anthropic":return ts.src;case"openai":return ta.src;case"ollama":if("dark"===t)return to.src;if("system"===t&&"undefined"!=typeof document)return document.documentElement.classList.contains("dark")?to.src:tn.src;return tn.src;default:return null}};var ti=r(911);let tc=()=>(0,s.jsxs)("div",{className:"flex items-center gap-2 py-2",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking"}),(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce"}),(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce [animation-delay:-0.2s]"}),(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce [animation-delay:-0.4s]"})]})]}),td=(0,a.memo)(e=>{let{message:t,isLoading:r=!1,onEdit:n,onRegenerate:o,onCopy:l,isReadonly:i=!1,showActions:c=!0,model:u}=e,[m,x]=(0,a.useState)("view"),[h,f]=(0,a.useState)(!1),p=(0,ti.x)(e=>e.themeMode),g=()=>{l?l(t.content):navigator.clipboard.writeText(t.content)},N=e=>{n&&n(t.id,e),x("view")},y=()=>{x("view")},w="assistant"===t.role&&r&&(!t.content||""===t.content.trim());return(0,s.jsx)(e$.N,{children:(0,s.jsxs)(eY.P.div,{"data-testid":"message-".concat(t.role),className:"w-full mx-auto max-w-4xl px-4 group/message",initial:{y:5,opacity:0},animate:{y:0,opacity:1},"data-role":t.role,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:["assistant"===t.role&&(0,s.jsxs)("div",{className:"flex gap-4 w-full",children:[(0,s.jsx)("div",{className:"size-8 flex items-center rounded-full justify-center shrink-0 bg-muted/50",children:(0,s.jsx)("img",{src:tl(u.provider,p),alt:"".concat(null==u?void 0:u.id," logo"),className:"h-4 w-4 object-contain"})}),(0,s.jsxs)("div",{className:"flex flex-col gap-4 w-full min-w-0",children:[t.attachments&&t.attachments.length>0&&(0,s.jsx)("div",{className:"flex flex-row gap-2",children:t.attachments.map(e=>(0,s.jsx)("div",{className:"px-3 py-2 bg-muted rounded-lg text-sm",children:e.name},e.id))}),t.toolCalls&&t.toolCalls.length>0&&(0,s.jsx)("div",{className:"space-y-2",children:t.toolCalls.map(e=>{var r;let a=null==(r=t.toolResults)?void 0:r.find(t=>t.toolCallId===e.id);return(0,s.jsx)(tr,{toolCall:e,toolResult:a},e.id)})}),w?(0,s.jsx)(eY.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:(0,s.jsx)(tc,{})}):"view"===m?(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{"data-testid":"message-content",className:"prose prose-sm max-w-none dark:prose-invert prose-p:leading-relaxed prose-pre:bg-muted/50 prose-pre:border prose-pre:border-border/30 flex-1 min-w-0",children:(0,s.jsx)(e5,{children:t.content.trim()})}),h&&(0,s.jsxs)("div",{className:"absolute -bottom-6 left-0 right-0 flex items-center justify-between",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground/60",children:eF(t.timestamp)}),c&&!i&&(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:(0,s.jsx)(d,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:g,children:(0,s.jsx)(R.A,{size:14})})}),(0,s.jsx)(j,{children:"Copy"})]}),o&&(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:(0,s.jsx)(d,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:()=>{o&&o(t.id)},children:(0,s.jsx)(eX.A,{size:14})})}),(0,s.jsx)(j,{children:"Regenerate"})]})]})]})]}):(0,s.jsx)("div",{className:"flex flex-row gap-2 items-start",children:(0,s.jsx)(e6,{message:t,onSave:N,onCancel:y})})]})]}),"user"===t.role&&(0,s.jsx)("div",{className:"flex justify-end w-full",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 max-w-2xl",children:[t.attachments&&t.attachments.length>0&&(0,s.jsx)("div",{className:"flex flex-row justify-end gap-2",children:t.attachments.map(e=>(0,s.jsx)("div",{className:"px-3 py-2 bg-muted rounded-lg text-sm",children:e.name},e.id))}),"view"===m?(0,s.jsxs)("div",{className:"flex items-start gap-2 justify-end",children:[c&&!i&&h&&(0,s.jsx)("div",{className:"flex items-center gap-1 mt-1",children:(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:(0,s.jsx)(d,{variant:"ghost",size:"sm",className:"px-2 h-7 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-all",onClick:g,children:(0,s.jsx)(R.A,{size:14})})}),(0,s.jsx)(j,{children:"Copy"})]})}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{"data-testid":"message-content",className:"bg-primary text-primary-foreground px-4 py-3 rounded-2xl max-w-fit",children:(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words font-medium",children:t.content.trim()})}),h&&(0,s.jsx)("div",{className:"absolute -bottom-6 right-0 text-xs text-muted-foreground/60",children:eF(t.timestamp)})]})]}):(0,s.jsx)("div",{className:"w-full",children:(0,s.jsx)(e6,{message:t,onSave:N,onCancel:y})})]})})]})})},(e,t)=>e.message.id===t.message.id&&e.message.content===t.message.content&&e.isLoading===t.isLoading&&JSON.stringify(e.message.toolCalls)===JSON.stringify(t.message.toolCalls)&&JSON.stringify(e.message.toolResults)===JSON.stringify(t.message.toolResults));var tu=r(492),tm=r(8979),tx=r(9881),th=r(8832),tf=r(6766);function tp(e){let{provider:t}=e,r=tl(t,(0,ti.x)(e=>e.themeMode));return r?(0,s.jsx)(tf.default,{src:r,width:12,height:12,alt:"".concat(t," logo"),className:"h-3 w-3 object-contain"}):(0,s.jsx)("div",{className:eD("h-3 w-3 rounded-sm",(e=>{switch(e){case"anthropic":return"text-orange-600 dark:text-orange-400";case"openai":return"text-green-600 dark:text-green-400";default:return"text-blue-600 dark:text-blue-400"}})(t))})}function tg(e){let{currentModel:t,availableModels:r,onModelChange:n,disabled:o,isLoading:l}=e,[i,c]=(0,a.useState)(!1);return(0,s.jsxs)(y,{open:i,onOpenChange:c,children:[(0,s.jsx)(w,{asChild:!0,children:(0,s.jsx)(d,{variant:"ghost",size:"sm",disabled:o||l,className:"h-8 px-2 rounded-full hover:bg-muted/80 transition-colors text-xs cursor-pointer",children:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tp,{provider:t.provider}),(0,s.jsx)("span",{className:"text-[10px] font-medium",children:t.name})]})})}),(0,s.jsx)(k,{align:"start",className:"min-w-[200px]",children:r.map(e=>(0,s.jsxs)(S,{onClick:()=>{n(e),c(!1)},className:"flex items-center gap-3 text-sm cursor-pointer",children:[(0,s.jsx)(tp,{provider:e.provider}),(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsx)("span",{className:"font-medium",children:e.name})}),e.id===t.id&&(0,s.jsx)("div",{className:"ml-auto w-2 h-2 bg-primary rounded-full"})]},e.id))})]})}function tv(e){let{value:t,onChange:r,onSubmit:n,onStop:o,disabled:l=!1,isLoading:i=!1,placeholder:c="Type your message...",className:u,showScrollToBottom:m=!1,onScrollToBottom:x,currentModel:h,availableModels:f,onModelChange:p}=e,g=(0,a.useRef)(null),N=(0,a.useRef)(null),[y,w]=(0,a.useState)([]),[k,S]=(0,a.useState)([]);console.log(h),(0,a.useEffect)(()=>{C()},[t]);let C=()=>{g.current&&(g.current.style.height="auto",g.current.style.height="".concat(Math.min(g.current.scrollHeight,120),"px"))},A=(0,a.useCallback)(()=>{!t.trim()||l||i||k.length>0||(n(t.trim(),y.length>0?y:void 0),r(""),w([]),g.current&&(g.current.style.height="auto"),setTimeout(()=>{var e;null==(e=g.current)||e.focus()},0))},[t,l,i,k.length,n,y,r]),T=(0,a.useCallback)(async e=>{let t=Array.from(e.target.files||[]);if(0!==t.length){S(t.map(e=>e.name));try{let e=await Promise.all(t.map(async e=>(await new Promise(e=>setTimeout(e,1e3)),{id:Math.random().toString(36).substr(2,9),name:e.name,url:URL.createObjectURL(e),contentType:e.type,size:e.size})));w(t=>[...t,...e])}catch(e){console.error("Error uploading files:",e)}finally{S([]),N.current&&(N.current.value="")}}},[]);return(0,s.jsxs)("div",{className:"relative w-full",children:[(0,s.jsx)(e$.N,{children:m&&(0,s.jsx)(eY.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:"absolute left-1/2 bottom-full mb-4 -translate-x-1/2 z-50",children:(0,s.jsx)(d,{size:"sm",variant:"outline",className:"rounded-full shadow-lg cursor-pointer",onClick:x,children:(0,s.jsx)(th.A,{className:"h-4 w-4"})})})}),(0,s.jsx)("input",{ref:N,type:"file",multiple:!0,className:"hidden",onChange:T,accept:"image/*,.pdf,.txt,.json,.csv"}),(y.length>0||k.length>0)&&(0,s.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[y.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-muted px-3 py-2 rounded-lg text-sm",children:[(0,s.jsx)("span",{className:"truncate max-w-[200px]",children:e.name}),(0,s.jsx)("button",{onClick:()=>{var t;return t=e.id,void w(e=>e.filter(e=>e.id!==t))},className:"text-muted-foreground hover:text-foreground cursor-pointer",children:"\xd7"})]},e.id)),k.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-muted/50 px-3 py-2 rounded-lg text-sm animate-pulse",children:[(0,s.jsx)("span",{className:"truncate max-w-[200px]",children:e}),(0,s.jsx)("div",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"})]},e))]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(eu,{ref:g,value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),A())},placeholder:c,disabled:l,className:eD("min-h-[56px] max-h-[120px] resize-none pl-16 pr-14 py-4 rounded-3xl","border-border/30 bg-background/50 focus-visible:border-border/50","focus-visible:ring-0 focus-visible:ring-offset-0","transition-all duration-200 ease-in-out overflow-y-auto","text-base placeholder:text-muted-foreground/60",u),rows:1,autoFocus:!0}),(0,s.jsx)("div",{className:"absolute bottom-3 left-4 flex items-center gap-1",children:(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:(0,s.jsx)(d,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-full hover:bg-muted/80 transition-colors cursor-pointer",onClick:()=>{var e;return null==(e=N.current)?void 0:e.click()},disabled:l||i,children:(0,s.jsx)(tu.A,{size:16})})}),(0,s.jsx)(j,{children:"Add files"})]})}),(0,s.jsx)("div",{className:"absolute bottom-3 right-4 flex items-center gap-1",children:i?(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:(0,s.jsx)(d,{type:"button",size:"sm",variant:"outline",className:"h-8 w-8 p-0 rounded-full border-border/30 hover:border-border/50 transition-colors cursor-pointer",onClick:o,children:(0,s.jsx)(tm.A,{size:16})})}),(0,s.jsx)(j,{children:"Stop generating"})]}):(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:(0,s.jsx)(d,{type:"button",size:"sm",className:eD("h-8 w-8 p-0 rounded-full transition-all duration-200 cursor-pointer",t.trim()&&!l&&0===k.length?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground cursor-not-allowed"),onClick:A,disabled:!t.trim()||l||k.length>0,children:(0,s.jsx)(tx.A,{size:16})})}),(0,s.jsx)(j,{children:"Send message"})]})})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 mt-2",children:f.length>0&&h&&(0,s.jsx)(tg,{currentModel:h,availableModels:f,onModelChange:p,disabled:l,isLoading:i})})]})}function tb(e){let{serverConfigs:t,systemPrompt:r=""}=e,n=(0,a.useRef)(null),[o,l]=(0,a.useState)(!0),{messages:i,isLoading:c,error:d,input:u,setInput:m,sendMessage:h,stopGeneration:f,regenerateMessage:p,clearChat:v,model:b,availableModels:j,setModel:N}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getToken:t,hasToken:r,tokens:s,getOllamaBaseUrl:n}=eV(),{initialMessages:o=[],serverConfigs:l,systemPrompt:i,onMessageSent:c,onMessageReceived:d,onError:u,onModelChange:m}=e,[x,h]=(0,a.useState)({messages:o,isLoading:!1,connectionStatus:"disconnected"}),[f,p]=(0,a.useState)(""),[g,v]=(0,a.useState)("idle"),[b,j]=(0,a.useState)(null),[N,y]=(0,a.useState)([]),[w,k]=(0,a.useState)(!1),S=(0,a.useRef)(null),C=(0,a.useRef)(x.messages);console.log("model",b),(0,a.useEffect)(()=>{C.current=x.messages},[x.messages]),(0,a.useEffect)(()=>{let e=async()=>{let{isRunning:e,availableModels:t}=await eK(n());k(e),y(t.map(e=>({id:e,name:e,provider:"ollama"})))};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[n]),(0,a.useEffect)(()=>{if(!b||!O.some(e=>e.id===b.id))if(w&&N.length>0)j(N[0]);else if(r("anthropic")){let e=eB.find(e=>e.id===eJ.CLAUDE_3_5_SONNET_LATEST);e&&j(e)}else if(r("openai")){let e=eB.find(e=>e.id===eJ.GPT_4O);e&&j(e)}else j(null)},[s,N,w,r,b]);let A=(0,a.useMemo)(()=>b?"ollama"===b.provider?w&&N.some(e=>e.id===b.id||e.id.startsWith("".concat(b.id,":")))?"local":"":t(b.provider):"",[b,t,w,N]),T=(0,a.useCallback)(e=>{j(e),m&&m(e)},[m]),O=(0,a.useMemo)(()=>{let e=[];for(let t of eB)"anthropic"===t.provider&&r("anthropic")?e.push(t):"openai"===t.provider&&r("openai")&&e.push(t);return w&&N.length>0&&e.push(...N),e},[w,N,r]),E=(0,a.useCallback)((e,t,r,s,a)=>{if(("text"===e.type||!e.type&&e.content)&&e.content){r.current+=e.content,h(e=>({...e,messages:e.messages.map(e=>e.id===t.id?{...e,content:r.current}:e)}));return}if(("tool_call"===e.type||!e.type&&e.toolCall)&&e.toolCall){let r=e.toolCall;s.current=[...s.current,r],h(e=>({...e,messages:e.messages.map(e=>e.id===t.id?{...e,toolCalls:[...s.current]}:e)}));return}if(("tool_result"===e.type||!e.type&&e.toolResult)&&e.toolResult){let r=e.toolResult;a.current=[...a.current,r],s.current=s.current.map(e=>e.id===r.toolCallId?{...e,status:r.error?"error":"completed"}:e),h(e=>({...e,messages:e.messages.map(e=>e.id===t.id?{...e,toolCalls:[...s.current],toolResults:[...a.current]}:e)}));return}if(("error"===e.type||!e.type&&e.error)&&e.error)throw Error(e.error)},[]),z=(0,a.useCallback)(async e=>{if(!l||!b||!A)throw Error("Missing required configuration: serverConfig, model, and apiKey are required");let t=eq("assistant","");h(e=>({...e,messages:[...e.messages,t]}));try{var r,s;let a=await fetch("/api/mcp/chat",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({serverConfigs:l,model:b,apiKey:A,systemPrompt:i,messages:C.current.concat(e),ollamaBaseUrl:n()}),signal:null==(r=S.current)?void 0:r.signal});if(!a.ok){let e,t=await a.text();try{e=JSON.parse(t)}catch(e){throw Error("Chat request failed: ".concat(a.status))}throw Error(e.error||"Chat request failed")}let o=null==(s=a.body)?void 0:s.getReader(),c=new TextDecoder,u={current:""},m={current:[]},x={current:[]},f="",p=!1;if(o)for(;!p;){let{done:e,value:r}=await o.read();if(e)break;let s=(f+=c.decode(r,{stream:!0})).split("\n");for(let e of(f=s.pop()||"",s))if(e.startsWith("data: ")){let r=e.slice(6).trim();if("[DONE]"===r){p=!0,h(e=>({...e,isLoading:!1}));break}if(r)try{let e=JSON.parse(r);E(e,t,u,m,x)}catch(e){console.warn("Failed to parse SSE data:",r,e)}}}if(u.current||m.current.length||console.warn("No content received from stream"),d){let e={...t,content:u.current};d(e)}}catch(e){throw h(e=>({...e,isLoading:!1})),e}},[l,b,A,i,d,E,n]),_=(0,a.useCallback)(async(e,t)=>{if(!e.trim()||x.isLoading)return;let r=eq("user",e,t);h(e=>({...e,messages:[...e.messages,r],isLoading:!0,error:void 0})),c&&c(r),S.current=new AbortController;try{await z(r),v("idle")}catch(t){let e=t instanceof Error?t.message:"An error occurred";h(t=>({...t,isLoading:!1,error:e})),v("error"),u&&u(e)}},[x.isLoading,c,z,u]),M=(0,a.useCallback)(()=>{S.current&&S.current.abort(),h(e=>({...e,isLoading:!1})),v("idle")},[]),R=(0,a.useCallback)(async e=>{let t=C.current,r=t.findIndex(t=>t.id===e);if(-1===r||0===r)return;let s=t[r-1];if("user"===s.role){h(e=>({...e,messages:e.messages.slice(0,r),isLoading:!0})),S.current=new AbortController;try{await z(s),v("idle")}catch(t){let e=t instanceof Error?t.message:"An error occurred";h(t=>({...t,isLoading:!1,error:e})),v("error"),u&&u(e)}}},[z,u]),P=(0,a.useCallback)(e=>{h(t=>({...t,messages:t.messages.filter(t=>t.id!==e)}))},[]),L=(0,a.useCallback)(()=>{h(e=>({...e,messages:[],error:void 0})),p("")},[]);return(0,a.useEffect)(()=>()=>{S.current&&S.current.abort()},[]),{messages:x.messages,isLoading:x.isLoading,error:x.error,connectionStatus:x.connectionStatus,status:g,input:f,setInput:p,model:b,availableModels:O,hasValidApiKey:!!A,sendMessage:_,stopGeneration:M,regenerateMessage:R,deleteMessage:P,clearChat:L,setModel:T}}({serverConfigs:t,systemPrompt:r,onError:e=>{x.oR.error(e)}});console.log("availableModels",j);let y=i.length>0;(0,a.useEffect)(()=>{o&&n.current&&(n.current.scrollTop=n.current.scrollHeight)},[i,o]);let w=e=>{navigator.clipboard.writeText(e)};return(console.log(j),y)?(0,s.jsx)(g,{children:(0,s.jsxs)("div",{className:"relative bg-background h-screen overflow-hidden",children:[(0,s.jsx)("div",{ref:n,onScroll:()=>{if(!n.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:r}=n.current;l(t-e-r<100)},className:"h-full overflow-y-auto pb-40",children:(0,s.jsx)("div",{className:"max-w-4xl mx-auto px-4 pt-8 pb-8",children:(0,s.jsxs)(e$.N,{mode:"popLayout",children:[i.map((e,t)=>(0,s.jsx)(eY.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3,delay:.05*t},className:"mb-8",children:(0,s.jsx)(td,{message:e,model:b||null,isLoading:c&&t===i.length-1,onEdit:()=>{},onRegenerate:p,onCopy:w,showActions:!0})},e.id)),c&&i.length>0&&"user"===i[i.length-1].role&&(0,s.jsx)(eY.P.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"mb-8",children:(0,s.jsxs)("div",{className:"flex gap-4 items-start",children:[(0,s.jsx)("div",{className:"w-8 h-8 flex items-center rounded-full justify-center bg-muted/50 shrink-0",children:(0,s.jsx)(eL.A,{className:"h-4 w-4 text-muted-foreground"})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking"}),(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce"}),(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce delay-100"}),(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-muted-foreground/60 rounded-full animate-bounce delay-200"})]})]})]})})]})})}),(0,s.jsx)(e$.N,{children:d&&(0,s.jsx)(eY.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},className:"absolute bottom-40 left-0 right-0 px-4 py-3 bg-destructive/5 border-t border-destructive/10 z-10",children:(0,s.jsx)("div",{className:"max-w-4xl mx-auto",children:(0,s.jsx)("p",{className:"text-sm text-destructive",children:d})})})}),(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 border-t border-border/50 bg-background/80 backdrop-blur-sm",children:(0,s.jsx)("div",{className:"max-w-4xl mx-auto p-4",children:(0,s.jsx)(tv,{value:u,onChange:m,onSubmit:h,onStop:f,disabled:0===j.length,isLoading:c,placeholder:"Send a message...",className:"border-2 shadow-sm",currentModel:b,availableModels:j,onModelChange:N,onClearChat:v,hasMessages:y})})})]})}):(0,s.jsx)("div",{className:"flex flex-col h-screen",children:(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center px-4",children:[(0,s.jsx)(eY.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"text-center space-y-6 max-w-2xl mb-8",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("h1",{className:"text-4xl font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text text-transparent",children:"Let's test out your MCP servers!"}),t&&(0,s.jsx)("div",{className:"text-sm text-muted-foreground mt-4",children:(0,s.jsxs)("p",{children:["Connected servers: ",Object.keys(t).join(", ")]})})]})}),(0,s.jsxs)(eY.P.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1},className:"w-full max-w-3xl",children:[(0,s.jsx)(tv,{value:u,onChange:m,onSubmit:h,onStop:f,disabled:0===j.length,isLoading:c,placeholder:"Send a message...",className:"border-2 shadow-lg bg-background/80 backdrop-blur-sm",currentModel:b||null,availableModels:j,onModelChange:N,onClearChat:v,hasMessages:!1}),0===j.length&&(0,s.jsx)(eY.P.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},className:"text-sm text-muted-foreground mt-3 text-center",children:"Configure API keys in Settings or start Ollama to enable chat"})]})]})})}var tj=r(381),tN=r(9803),ty=r(8749);function tw(){let{tokens:e,setToken:t,clearToken:r,hasToken:o,getOllamaBaseUrl:l,setOllamaBaseUrl:i}=eV(),[c,u]=(0,a.useState)(!1),[m,x]=(0,a.useState)(!1),h=(0,ti.x)(e=>e.themeMode),f=e=>{r(e)},p=e=>e?e.length<=8?"*".repeat(e.length):e.slice(0,4)+"*".repeat(e.length-8)+e.slice(-4):"";return(0,s.jsxs)("div",{className:"container mx-auto p-6 max-w-2xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,s.jsx)(tj.A,{className:"h-6 w-6"}),(0,s.jsx)("h1",{className:"text-2xl font-bold",children:"Settings"})]}),(0,s.jsxs)(n.Zp,{children:[(0,s.jsxs)(n.aR,{children:[(0,s.jsxs)(n.ZB,{className:"flex items-center gap-2",children:[(0,s.jsx)(tN.A,{className:"h-5 w-5"}),"API Keys"]}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure your LLM provider API keys. Keys are stored locally in your browser."})]}),(0,s.jsxs)(n.Wu,{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(eA,{htmlFor:"anthropic-key",className:"text-base font-medium",children:"Anthropic API Key"}),o("anthropic")&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(C.A,{className:"h-4 w-4 text-green-500"}),(0,s.jsx)("span",{className:"text-xs text-green-600",children:"Configured"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(U,{id:"anthropic-key",type:c?"text":"password",value:c?e.anthropic:p(e.anthropic),onChange:e=>t("anthropic",e.target.value),placeholder:"sk-ant-...",className:"pr-10"}),(0,s.jsx)(d,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>u(!c),children:c?(0,s.jsx)(ty.A,{className:"h-4 w-4"}):(0,s.jsx)(eM.A,{className:"h-4 w-4"})})]}),o("anthropic")&&(0,s.jsx)(d,{variant:"outline",size:"sm",onClick:()=>f("anthropic"),children:(0,s.jsx)(T.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",(0,s.jsx)("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:"Anthropic Console"})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(eA,{htmlFor:"openai-key",className:"text-base font-medium",children:"OpenAI API Key"}),o("openai")&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(C.A,{className:"h-4 w-4 text-green-500"}),(0,s.jsx)("span",{className:"text-xs text-green-600",children:"Configured"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(U,{id:"openai-key",type:m?"text":"password",value:m?e.openai:p(e.openai),onChange:e=>t("openai",e.target.value),placeholder:"sk-...",className:"pr-10"}),(0,s.jsx)(d,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>x(!m),children:m?(0,s.jsx)(ty.A,{className:"h-4 w-4"}):(0,s.jsx)(eM.A,{className:"h-4 w-4"})})]}),o("openai")&&(0,s.jsx)(d,{variant:"outline",size:"sm",onClick:()=>f("openai"),children:(0,s.jsx)(T.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",(0,s.jsx)("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:"OpenAI Platform"})]})]})]})]}),(0,s.jsxs)(n.Zp,{className:"mt-6",children:[(0,s.jsxs)(n.aR,{children:[(0,s.jsxs)(n.ZB,{className:"flex items-center gap-2",children:[(0,s.jsx)("img",{src:"dark"===h?"/ollama_dark.png":"/ollama_logo.svg",alt:"Ollama",className:"h-5 w-5"}),"Ollama Configuration"]}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure your local Ollama server settings."})]}),(0,s.jsx)(n.Wu,{className:"space-y-6",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(eA,{htmlFor:"ollama-url",className:"text-base font-medium",children:"Base URL"}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"Default: http://localhost:11434"})})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(U,{id:"ollama-url",type:"text",value:l(),onChange:e=>i(e.target.value),placeholder:"http://localhost:11434",className:"flex-1"}),(0,s.jsx)(d,{variant:"outline",size:"sm",onClick:()=>{i("http://localhost:11434")},children:"Reset"})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Configure the base URL for your Ollama server. This is typically"," ",(0,s.jsx)("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"http://localhost:11434"})," ","for local installations."]})]})})]})]})}var tk=r(5543),tS=r(3343),tC=r(2572);let tA=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"HH:mm:ss.SSS",r="string"==typeof e?(0,tS.H)(e):e;return(0,tC.GP)(r,t)};r(3596);var tT=r(1362);let tO={error:"bg-red-500/10 text-red-700 border-red-200 dark:text-red-400 dark:border-red-800",warn:"bg-yellow-500/10 text-yellow-700 border-yellow-200 dark:text-yellow-400 dark:border-yellow-800",info:"bg-blue-500/10 text-blue-700 border-blue-200 dark:text-blue-400 dark:border-blue-800",debug:"bg-purple-500/10 text-purple-700 border-purple-200 dark:text-purple-400 dark:border-purple-800",trace:"bg-gray-500/10 text-gray-700 border-gray-200 dark:text-gray-400 dark:border-gray-800"};function tE(e){let{level:t}=e;return(0,s.jsx)(ex,{variant:"outline",className:(0,i.cn)("font-mono",tO[t]),children:t.toUpperCase()})}function tz(e){let{entry:t,isExpanded:r,onToggleExpand:a}=e,n=void 0!==t.data||void 0!==t.error,{theme:o}=(0,tT.D)();return(0,s.jsxs)("div",{className:"border rounded-lg font-mono",children:[(0,s.jsx)("div",{className:"p-3 cursor-pointer hover:bg-muted/50 ".concat(n?"":"cursor-default"),onClick:n?a:void 0,children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[n&&(0,s.jsx)("div",{className:"mt-0.5",children:r?(0,s.jsx)(L.A,{className:"h-4 w-4 text-muted-foreground"}):(0,s.jsx)(ew.A,{className:"h-4 w-4 text-muted-foreground"})}),(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,s.jsx)("span",{className:"text-muted-foreground font-mono text-xs",children:"[".concat(tA(t.timestamp),"]")}),(0,s.jsx)(tE,{level:t.level}),(0,s.jsx)(ex,{variant:"secondary",children:t.context}),(0,s.jsx)("span",{className:"flex-1 break-words",children:t.message})]})})]})}),r&&n&&(0,s.jsxs)("div",{className:"border-t bg-muted/20 p-3 space-y-3",children:[void 0!==t.data&&(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"DATA:"}),(0,s.jsx)("div",{className:"text-xs bg-background border rounded overflow-auto max-h-60",children:(0,s.jsx)(eS.Ay,{src:t.data,dark:!0,theme:"atom",enableClipboard:!0,displaySize:!1,collapseStringsAfterLength:100,style:{fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', monospace",backgroundColor:"hsl(var(--background))",padding:"0",borderRadius:"0",border:"none"}})})]}),t.error&&(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"ERROR:"}),(0,s.jsxs)("pre",{className:"text-xs bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded p-2 overflow-auto max-h-40 text-red-700 dark:text-red-400",children:[t.error.message,t.error.stack&&"\n\n".concat(t.error.stack)]})]})]})]})}let t_=["error","warn","info","debug","trace"];function tM(){let{entries:e,getFilteredEntries:t}=function(){let[,e]=(0,a.useState)({});return(0,a.useEffect)(()=>{let t=ec.subscribe(()=>{e({})});return()=>{t()}},[]),{entries:ec.getEntries(),config:ec.getConfig(),setConfig:ec.setConfig.bind(ec),clearBuffer:ec.clearBuffer.bind(ec),getFilteredEntries:ec.getFilteredEntries.bind(ec)}}(),[r,n]=(0,a.useState)(new Set),[o,l]=(0,a.useState)("all"),[i,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),x=(0,a.useRef)(null),h=(0,a.useRef)(null),f=(0,a.useMemo)(()=>{let t="all"===o?e:e.filter(e=>e.level===o);if(!i.trim())return t;let r=i.toLowerCase();return t.filter(e=>e.message.toLowerCase().includes(r)||e.context.toLowerCase().includes(r)||e.data&&JSON.stringify(e.data).toLowerCase().includes(r))},[e,o,i]);return(0,a.useEffect)(()=>{h.current&&h.current.scrollIntoView({behavior:"smooth"})},[e.length]),(0,a.useEffect)(()=>{let e=()=>{if(x.current){let{scrollTop:e}=x.current;m(e>200)}},t=x.current;if(t)return t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)},[]),(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"border-b bg-background p-4 space-y-4 flex-shrink-0 sticky top-0 z-10",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold",children:"Tracing"}),(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsxs)(K,{value:o,onValueChange:e=>l(e),children:[(0,s.jsx)(Y,{className:"w-32",children:(0,s.jsx)($,{})}),(0,s.jsxs)(X,{children:[(0,s.jsx)(Q,{value:"all",children:"All Levels"}),t_.map(e=>(0,s.jsx)(Q,{value:e,children:(0,s.jsx)(tE,{level:e})},e))]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[(0,s.jsx)(tk.A,{className:"h-4 w-4"}),(0,s.jsx)(U,{placeholder:"Search logs...",value:i,onChange:e=>c(e.target.value),className:"h-8"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[(0,s.jsxs)("span",{children:["Total: ",e.length]}),(0,s.jsxs)("span",{children:["Filtered: ",f.length]})]})]}),(0,s.jsxs)("div",{ref:x,className:"flex-1 overflow-y-auto p-4 space-y-2 font-mono text-sm min-h-0",children:[0===f.length?(0,s.jsx)("div",{className:"text-center text-muted-foreground py-8",children:0===e.length?"No logs yet":"No logs match current filters"}):f.map((e,t)=>{let a=r.has(t);return(0,s.jsx)(tz,{entry:e,isExpanded:a,onToggleExpand:()=>(e=>{let t=new Set(r);t.has(e)?t.delete(e):t.add(e),n(t)})(t)},"".concat(e.timestamp,"-").concat(t))}),(0,s.jsx)("div",{ref:h})]}),u&&(0,s.jsxs)(d,{onClick:()=>{x.current&&x.current.scrollTo({top:0,behavior:"smooth"})},size:"sm",className:"fixed bottom-4 right-4 z-20 shadow-lg",variant:"secondary",children:[(0,s.jsx)(tx.A,{className:"h-4 w-4 mr-1"}),"Top"]})]})}var tR=r(1392),tP=r(1274),tL=r(9376),tI=r(2432);function tU(e){let{...t}=e;return(0,s.jsx)(D.bL,{"data-slot":"sheet",...t})}function tD(e){let{...t}=e;return(0,s.jsx)(D.ZL,{"data-slot":"sheet-portal",...t})}function tF(e){let{className:t,...r}=e;return(0,s.jsx)(D.hJ,{"data-slot":"sheet-overlay",className:(0,i.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",t),...r})}function tq(e){let{className:t,children:r,side:a="right",...n}=e;return(0,s.jsxs)(tD,{children:[(0,s.jsx)(tF,{}),(0,s.jsxs)(D.UC,{"data-slot":"sheet-content",className:(0,i.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===a&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===a&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===a&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===a&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",t),...n,children:[r,(0,s.jsxs)(D.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary 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",children:[(0,s.jsx)(T.A,{className:"size-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function tJ(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"sheet-header",className:(0,i.cn)("flex flex-col gap-1.5 p-4",t),...r})}function tB(e){let{className:t,...r}=e;return(0,s.jsx)(D.hE,{"data-slot":"sheet-title",className:(0,i.cn)("text-foreground font-semibold",t),...r})}function tH(e){let{className:t,...r}=e;return(0,s.jsx)(D.VY,{"data-slot":"sheet-description",className:(0,i.cn)("text-muted-foreground text-sm",t),...r})}let tG=a.createContext(null);function tV(){let e=a.useContext(tG);if(!e)throw Error("useSidebar must be used within a SidebarProvider.");return e}function tZ(e){let{defaultOpen:t=!0,open:r,onOpenChange:n,className:o,style:l,children:c,...d}=e,u=function(){let[e,t]=a.useState(void 0);return a.useEffect(()=>{let e=window.matchMedia("(max-width: ".concat(767,"px)")),r=()=>{t(window.innerWidth<768)};return e.addEventListener("change",r),t(window.innerWidth<768),()=>e.removeEventListener("change",r)},[]),!!e}(),[m,x]=a.useState(!1),[h,f]=a.useState(t),p=null!=r?r:h,v=a.useCallback(e=>{let t="function"==typeof e?e(p):e;n?n(t):f(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[n,p]),b=a.useCallback(()=>u?x(e=>!e):v(e=>!e),[u,v,x]);a.useEffect(()=>{let e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[b]);let j=p?"expanded":"collapsed",N=a.useMemo(()=>({state:j,open:p,setOpen:v,isMobile:u,openMobile:m,setOpenMobile:x,toggleSidebar:b}),[j,p,v,u,m,x,b]);return(0,s.jsx)(tG.Provider,{value:N,children:(0,s.jsx)(g,{delayDuration:0,children:(0,s.jsx)("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...l},className:(0,i.cn)("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",o),...d,children:c})})})}function tW(e){let{side:t="left",variant:r="sidebar",collapsible:a="offcanvas",className:n,children:o,...l}=e,{isMobile:c,state:d,openMobile:u,setOpenMobile:m}=tV();return"none"===a?(0,s.jsx)("div",{"data-slot":"sidebar",className:(0,i.cn)("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",n),...l,children:o}):c?(0,s.jsx)(tU,{open:u,onOpenChange:m,...l,children:(0,s.jsxs)(tq,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:t,children:[(0,s.jsxs)(tJ,{className:"sr-only",children:[(0,s.jsx)(tB,{children:"Sidebar"}),(0,s.jsx)(tH,{children:"Displays the mobile sidebar."})]}),(0,s.jsx)("div",{className:"flex h-full w-full flex-col",children:o})]})}):(0,s.jsxs)("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":d,"data-collapsible":"collapsed"===d?a:"","data-variant":r,"data-side":t,"data-slot":"sidebar",children:[(0,s.jsx)("div",{"data-slot":"sidebar-gap",className:(0,i.cn)("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===r||"inset"===r?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),(0,s.jsx)("div",{"data-slot":"sidebar-container",className:(0,i.cn)("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===r||"inset"===r?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",n),...l,children:(0,s.jsx)("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:o})})]})}function tK(e){let{className:t,onClick:r,...a}=e,{toggleSidebar:n}=tV();return(0,s.jsxs)(d,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:(0,i.cn)("size-7",t),onClick:e=>{null==r||r(e),n()},...a,children:[(0,s.jsx)(tI.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function t$(e){let{className:t,...r}=e;return(0,s.jsx)("main",{"data-slot":"sidebar-inset",className:(0,i.cn)("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",t),...r})}function tY(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:(0,i.cn)("flex flex-col gap-2 p-2",t),...r})}function tX(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:(0,i.cn)("flex flex-col gap-2 p-2",t),...r})}function tQ(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:(0,i.cn)("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...r})}function t0(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:(0,i.cn)("relative flex w-full min-w-0 flex-col p-2",t),...r})}function t1(e){let{className:t,...r}=e;return(0,s.jsx)("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:(0,i.cn)("w-full text-sm",t),...r})}function t2(e){let{className:t,...r}=e;return(0,s.jsx)("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:(0,i.cn)("flex w-full min-w-0 flex-col gap-1",t),...r})}function t4(e){let{className:t,...r}=e;return(0,s.jsx)("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:(0,i.cn)("group/menu-item relative",t),...r})}let t3=(0,l.F)("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function t5(e){let{asChild:t=!1,isActive:r=!1,variant:a="default",size:n="default",tooltip:l,className:c,...d}=e,u=t?o.DX:"button",{isMobile:m,state:x}=tV(),h=(0,s.jsx)(u,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":n,"data-active":r,className:(0,i.cn)(t3({variant:a,size:n}),c),...d});return l?("string"==typeof l&&(l={children:l}),(0,s.jsxs)(v,{children:[(0,s.jsx)(b,{asChild:!0,children:h}),(0,s.jsx)(j,{side:"right",align:"center",hidden:"collapsed"!==x||m,...l})]})):h}function t6(e){let{items:t,onItemClick:r}=e;return(0,s.jsx)(t0,{children:(0,s.jsx)(t1,{children:(0,s.jsx)(t2,{children:t.map(e=>(0,s.jsx)(t4,{children:(0,s.jsxs)(t5,{tooltip:e.title,isActive:e.isActive||!1,onClick:()=>{var t;return t=e.url,void(r&&r(t))},className:e.isActive?"[&[data-active=true]]:bg-black/5 dark:[&[data-active=true]]:bg-white/5 cursor-pointer":"cursor-pointer",children:[e.icon&&(0,s.jsx)(e.icon,{className:"h-4 w-4"}),(0,s.jsx)("span",{children:e.title})]})},e.title))})})})}let t8=[{id:"connection",items:[{title:"MCP Servers",url:"#servers",icon:ea},{title:"Playground",url:"#chat",icon:eL.A},{title:"Tracing",url:"#tracing",icon:tR.A}]},{id:"tools",items:[{title:"Tools",url:"#tools",icon:tP.A},{title:"Resources",url:"#resources",icon:ez.A},{title:"Prompts",url:"#prompts",icon:tL.A}]},{id:"settings",items:[{title:"Settings",url:"#settings",icon:tj.A}]}];function t7(e){let{onNavigate:t,activeTab:r,...n}=e,o=(0,ti.x)(e=>e.themeMode),l=e=>{t&&e.startsWith("#")&&t(e.slice(1))};return(0,s.jsxs)(tW,{collapsible:"offcanvas",...n,children:[(0,s.jsx)(tY,{children:(0,s.jsx)("div",{className:"flex items-center justify-center px-4 py-4",children:(0,s.jsx)("img",{src:"dark"===o?"/mcp_jam_dark.png":"/mcp_jam_light.png",alt:"MCP Jam",className:"h-4 w-auto"})})}),(0,s.jsx)(tQ,{children:t8.map((e,t)=>(0,s.jsxs)(a.Fragment,{children:[(0,s.jsx)(t6,{items:e.items.map(e=>({...e,isActive:e.url==="#".concat(r)})),onItemClick:l}),t<t8.length-1&&(0,s.jsx)("div",{className:"mx-4 my-2 border-t border-border/50"})]},e.id))}),(0,s.jsx)(tX,{})]})}function t9(e){let{connectedServerConfigs:t,selectedServer:r,selectedMultipleServers:n,isMultiSelectEnabled:o,onServerChange:l,onMultiServerToggle:c,onConnect:d}=e,[u,m]=(0,a.useState)(!1),x=Object.entries(t);return 0===x.length?(0,s.jsx)("div",{className:"mb-6 p-4 border rounded-lg bg-muted/30 text-center text-sm text-muted-foreground",children:"No servers connected. Add a server to get started."}):(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex flex-wrap",children:[x.map(e=>{let[t,a]=e,d=o?n.includes(t):r===t;return(0,s.jsxs)("button",{onClick:()=>o?c(t):l(t),className:(0,i.cn)("group relative flex items-center gap-3 px-4 py-3 border-r border-b border-border transition-all duration-200 cursor-pointer","hover:bg-accent hover:text-accent-foreground",d?"bg-muted text-foreground":"bg-background text-foreground"),children:[o&&(0,s.jsx)("div",{className:(0,i.cn)("w-4 h-4 rounded border-2 flex items-center justify-center transition-colors",d?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),children:d&&(0,s.jsx)(C.A,{className:"w-3 h-3"})}),(0,s.jsx)("div",{className:(0,i.cn)("w-2 h-2 rounded-full",function(e){switch(e){case"connected":return"bg-green-500 dark:bg-green-400";case"connecting":return"bg-yellow-500 dark:bg-yellow-400 animate-pulse";case"failed":return"bg-red-500 dark:bg-red-400";default:return"bg-muted-foreground"}}(a.connectionStatus)),title:function(e){switch(e){case"connected":return"Connected";case"connecting":return"Connecting...";case"failed":return"Failed";case"disconnected":return"Disconnected";default:return"Unknown"}}(a.connectionStatus)}),(0,s.jsx)("span",{className:"text-sm font-medium truncate max-w-36",children:t}),(0,s.jsx)("div",{className:"text-xs opacity-70",children:a.config.command?"STDIO":"HTTP"})]},t)}),(0,s.jsxs)("button",{onClick:()=>m(!0),className:(0,i.cn)("group relative flex items-center gap-3 px-4 py-3 border-r border-b border-border transition-all duration-200 cursor-pointer","hover:bg-accent hover:text-accent-foreground","bg-background text-muted-foreground border-dashed"),children:[o&&(0,s.jsx)("div",{className:"w-4 h-4"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Add Server"}),(0,s.jsx)("div",{className:"text-xs opacity-70",children:"+"})]})]}),(0,s.jsx)(er,{isOpen:u,onClose:()=>m(!1),onConnect:d})]})}var re=r(2098),rt=r(3509),rr=r(4477);let rs=(0,rr.createServerReference)("703879787ee8a24342cad319ddf0318da5dd194f0a",rr.callServer,void 0,rr.findSourceMapURL,"setValueToCookie");function ra(){let e=(0,ti.x)(e=>e.themeMode),t=(0,ti.x)(e=>e.setThemeMode),r=async()=>{let r="dark"===e?"light":"dark",s=document.documentElement;s.classList.add("disable-transitions"),s.classList.toggle("dark","dark"===r),requestAnimationFrame(()=>{s.classList.remove("disable-transitions")}),t(r),await rs("theme_mode",r)};return(0,s.jsx)(d,{size:"icon",onClick:r,className:"cursor-pointer",children:"dark"===e?(0,s.jsx)(re.A,{}):(0,s.jsx)(rt.A,{})})}var rn=r(6208);class ro{get redirectUrl(){return this.redirectUri}get clientMetadata(){return{client_name:"MCP Inspector - ".concat(this.serverName),client_uri:"https://github.com/modelcontextprotocol/inspector",redirect_uris:[this.redirectUri],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"client_secret_post",scope:"mcp:*"}}clientInformation(){let e=localStorage.getItem("mcp-client-".concat(this.serverName));return e?JSON.parse(e):void 0}async saveClientInformation(e){localStorage.setItem("mcp-client-".concat(this.serverName),JSON.stringify(e))}tokens(){let e=localStorage.getItem("mcp-tokens-".concat(this.serverName));return e?JSON.parse(e):void 0}async saveTokens(e){localStorage.setItem("mcp-tokens-".concat(this.serverName),JSON.stringify(e))}async redirectToAuthorization(e){console.log("Setting mcp-oauth-pending to:",this.serverName),localStorage.setItem("mcp-oauth-pending",this.serverName),window.location.href=e.toString()}async saveCodeVerifier(e){localStorage.setItem("mcp-verifier-".concat(this.serverName),e)}codeVerifier(){let e=localStorage.getItem("mcp-verifier-".concat(this.serverName));if(!e)throw Error("Code verifier not found");return e}async invalidateCredentials(e){switch(e){case"all":localStorage.removeItem("mcp-tokens-".concat(this.serverName)),localStorage.removeItem("mcp-client-".concat(this.serverName)),localStorage.removeItem("mcp-verifier-".concat(this.serverName));break;case"client":localStorage.removeItem("mcp-client-".concat(this.serverName));break;case"tokens":localStorage.removeItem("mcp-tokens-".concat(this.serverName));break;case"verifier":localStorage.removeItem("mcp-verifier-".concat(this.serverName))}}constructor(e){this.serverName=e,this.redirectUri="".concat(window.location.origin,"/oauth/callback")}}async function rl(e){try{var t;let r=new ro(e.serverName);localStorage.setItem("mcp-serverUrl-".concat(e.serverName),e.serverUrl),localStorage.setItem("mcp-oauth-pending",e.serverName);let s=await (0,rn.j2)(r,{serverUrl:e.serverUrl,scope:(null==(t=e.scopes)?void 0:t.join(" "))||"mcp:*"});if("REDIRECT"===s)return{success:!0};if("AUTHORIZED"===s){let t=r.tokens();if(t){let r=ru(e.serverUrl,t);return{success:!0,serverConfig:r}}}return{success:!1,error:"OAuth flow failed"}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown OAuth error"}}}async function ri(e){try{let t=localStorage.getItem("mcp-oauth-pending");if(!t)throw Error("No pending OAuth flow found");let r=localStorage.getItem("mcp-serverUrl-".concat(t));if(!r)throw Error("Server URL not found for OAuth callback");let s=new ro(t),a=await (0,rn.j2)(s,{serverUrl:r,authorizationCode:e,scope:"mcp:*"});if("AUTHORIZED"===a){let e=s.tokens();if(e){localStorage.removeItem("mcp-oauth-pending");let s=ru(r,e);return{success:!0,serverConfig:s,serverName:t}}}return{success:!1,error:"Token exchange failed"}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown callback error"}}}function rc(e){let t=localStorage.getItem("mcp-tokens-".concat(e));return t?JSON.parse(t):void 0}async function rd(e){try{let t=new ro(e),r=t.tokens();if(!(null==r?void 0:r.refresh_token))return{success:!1,error:"No refresh token available"};let s=localStorage.getItem("mcp-serverUrl-".concat(e));if(!s)return{success:!1,error:"Server URL not found for token refresh"};let a=await (0,rn.j2)(t,{serverUrl:s,scope:"mcp:*"});if("AUTHORIZED"===a){let e=t.tokens();if(e){let t=ru(s,e);return{success:!0,serverConfig:t}}}return{success:!1,error:"Token refresh failed"}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Unknown refresh error"}}}function ru(e,t){return{url:new URL(e),requestInit:{headers:t.access_token?{Authorization:"Bearer ".concat(t.access_token)}:{}},oauth:t}}let rm="mcp-inspector-state";function rx(){let[e,t]=(0,a.useState)("servers"),{appState:r,isLoading:n,connectedServerConfigs:o,selectedMCPConfig:l,handleConnect:i,handleDisconnect:c,handleReconnect:d,handleUpdate:u,setSelectedServer:m,toggleServerSelection:h,selectedMCPConfigsMap:f,setSelectedMultipleServersToAllServers:p}=function(){var e;let t=ed("Connections"),[r,s]=(0,a.useState)({servers:{},selectedServer:"none",selectedMultipleServers:[],isMultiSelectMode:!1}),[n,o]=(0,a.useState)(!0),[l,i]=(0,a.useState)({});(0,a.useEffect)(()=>{let e=localStorage.getItem(rm);if(e)try{let t=JSON.parse(e),r=Object.fromEntries(Object.entries(t.servers||{}).map(e=>{let[t,r]=e;return[t,{...r,connectionStatus:r.connectionStatus||"disconnected",retryCount:r.retryCount||0,lastConnectionTime:r.lastConnectionTime?new Date(r.lastConnectionTime):new Date}]}));s({servers:r,selectedServer:t.selectedServer||"none",selectedMultipleServers:t.selectedMultipleServers||[],isMultiSelectMode:t.isMultiSelectMode||!1})}catch(e){t.error("Failed to parse saved state",{error:e instanceof Error?e.message:"Unknown error"})}o(!1)},[]),(0,a.useEffect)(()=>{n||localStorage.setItem(rm,JSON.stringify(r))},[r,n]);let c=(0,a.useCallback)(()=>{s(e=>({...e,selectedMultipleServers:Object.keys(r.servers)}))},[r.servers]);(0,a.useEffect)(()=>{if(!n){let e=new URLSearchParams(window.location.search),t=e.get("code"),r=e.get("error");t?m(t):r&&x.oR.error("OAuth authorization failed: ".concat(r))}},[n]);let d=(0,a.useCallback)(e=>"stdio"===e.type?{command:e.command,args:e.args,env:e.env}:{url:new URL(e.url),requestInit:{headers:e.headers||{}}},[]),u=(0,a.useCallback)(async e=>{if(console.log("handleConnectFormData",e),"stdio"===e.type){if(!e.command||""===e.command.trim())return void x.oR.error("Command is required for STDIO connections")}else{if(!e.url||""===e.url.trim())return void x.oR.error("URL is required for HTTP connections");try{new URL(e.url)}catch(t){x.oR.error("Invalid URL format: ".concat(e.url," ").concat(t));return}}let r=d(e);s(t=>({...t,servers:{...t.servers,[e.name]:{name:e.name,config:r,lastConnectionTime:new Date,connectionStatus:"connecting",retryCount:0}},selectedServer:e.name}));try{if("http"===e.type&&e.useOAuth&&e.url){s(t=>({...t,servers:{...t.servers,[e.name]:{...t.servers[e.name],connectionStatus:"oauth-flow"}}}));let t=await rl({serverName:e.name,serverUrl:e.url,scopes:e.oauthScopes||["mcp:*"]});if(t.success)if(!t.serverConfig)return void x.oR.success("OAuth flow initiated. You will be redirected to authorize access.");else{try{let r=await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:t.serverConfig})}),a=await r.json();a.success?(s(r=>({...r,servers:{...r.servers,[e.name]:{...r.servers[e.name],config:t.serverConfig,connectionStatus:"connected",oauthTokens:rc(e.name),lastError:void 0}}})),x.oR.success("Connected successfully with OAuth!")):(s(t=>({...t,servers:{...t.servers,[e.name]:{...t.servers[e.name],connectionStatus:"failed",lastError:a.error||"OAuth connection test failed"}}})),x.oR.error("OAuth succeeded but connection failed: ".concat(a.error)))}catch(r){let t=r instanceof Error?r.message:"Unknown error";s(r=>({...r,servers:{...r.servers,[e.name]:{...r.servers[e.name],connectionStatus:"failed",lastError:t}}})),x.oR.error("OAuth succeeded but connection test threw error: ".concat(t))}return}s(r=>({...r,servers:{...r.servers,[e.name]:{...r.servers[e.name],connectionStatus:"failed",retryCount:0,lastError:t.error||"OAuth initialization failed"}}})),x.oR.error("OAuth initialization failed: ".concat(t.error));return}let a=await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:r})}),n=await a.json();n.success?(s(t=>({...t,servers:{...t.servers,[e.name]:{...t.servers[e.name],connectionStatus:"connected",lastConnectionTime:new Date,retryCount:0,lastError:void 0}}})),t.info("Connection successful",{serverName:e.name}),x.oR.success("Connected successfully!")):(s(t=>({...t,servers:{...t.servers,[e.name]:{...t.servers[e.name],connectionStatus:"failed",retryCount:0,lastError:n.error}}})),t.error("Connection failed",{serverName:e.name,error:n.error}),x.oR.error("Failed to connect to ".concat(e.name)))}catch(a){let r=a instanceof Error?a.message:"Unknown error";s(t=>({...t,servers:{...t.servers,[e.name]:{...t.servers[e.name],connectionStatus:"failed",retryCount:0,lastError:r}}})),t.error("Connection failed",{serverName:e.name,error:r}),x.oR.error("Network error: ".concat(r))}},[d]),m=(0,a.useCallback)(async e=>{window.history.replaceState({},document.title,window.location.pathname);try{let a=await ri(e);if(console.log("OAuth callback result:",a),a.success&&a.serverConfig&&a.serverName){let e=a.serverName,n=r.servers[e];n&&"oauth-flow"===n.connectionStatus?s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],config:a.serverConfig,oauthTokens:rc(e),connectionStatus:"connecting",lastError:void 0}},selectedServer:e})):s(t=>({...t,servers:{...t.servers,[e]:{name:e,config:a.serverConfig,oauthTokens:rc(e),lastConnectionTime:new Date,connectionStatus:"connecting",retryCount:0}},selectedServer:e}));try{let r=await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:a.serverConfig})}),n=await r.json();n.success?(s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],connectionStatus:"connected",lastConnectionTime:new Date,lastError:void 0}}})),t.info("OAuth connection successful",{serverName:e}),x.oR.success("OAuth connection successful! Connected to ".concat(e,"."))):(s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],connectionStatus:"failed",lastError:n.error||"Connection test failed after OAuth"}}})),t.error("OAuth connection test failed",{serverName:e,error:n.error}),x.oR.error("OAuth succeeded but connection test failed: ".concat(n.error)))}catch(a){let r=a instanceof Error?a.message:"Unknown connection error";s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],connectionStatus:"failed",lastError:r}}})),t.error("OAuth connection test error",{serverName:e,error:r}),x.oR.error("OAuth succeeded but connection test failed: ".concat(r))}}else throw Error(a.error||"OAuth callback failed")}catch(r){let e=r instanceof Error?r.message:"Unknown error";x.oR.error("Error completing OAuth flow: ".concat(e)),t.error("OAuth callback failed",{error:e})}},[r.servers,t]),h=(0,a.useCallback)(async e=>{let t=r.servers[e];return(null==t?void 0:t.oauthTokens)&&t.oauthTokens.access_token||null},[r.servers]),f=(0,a.useCallback)(async e=>{t.info("Disconnecting from server",{serverName:e}),localStorage.removeItem("mcp-tokens-".concat(e)),localStorage.removeItem("mcp-client-".concat(e)),localStorage.removeItem("mcp-verifier-".concat(e)),localStorage.removeItem("mcp-serverUrl-".concat(e)),s(t=>{let r={...t.servers};return delete r[e],{...t,servers:r,selectedServer:t.selectedServer===e?"none":t.selectedServer,selectedMultipleServers:t.selectedMultipleServers.filter(t=>t!==e)}})},[]),p=(0,a.useCallback)(async e=>{t.info("Reconnecting to server",{serverName:e});let a=r.servers[e];if(!a)throw Error("Server ".concat(e," not found"));s(t=>({...t,servers:{...t.servers,[e]:{...a,connectionStatus:"connecting"}}}));try{let r=a.config;if(a.oauthTokens){t.info("Attempting to refresh OAuth tokens",{serverName:e});let a=await rd(e);a.success&&a.serverConfig?(t.info("OAuth tokens refreshed successfully",{serverName:e}),r=a.serverConfig,s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],config:a.serverConfig,oauthTokens:rc(e)}}}))):t.warn("OAuth token refresh failed, attempting with existing tokens",{serverName:e,error:a.error})}let n=await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:r})}),o=await n.json();if(o.success)return s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],connectionStatus:"connected",lastConnectionTime:new Date,retryCount:0,lastError:void 0}}})),t.info("Reconnection successful",{serverName:e,result:o}),{success:!0};s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],connectionStatus:"failed",retryCount:t.servers[e].retryCount+1,lastError:o.error||"Connection test failed"}}})),t.error("Reconnection failed",{serverName:e,result:o}),x.oR.error("Failed to connect: ".concat(e))}catch(a){let r=a instanceof Error?a.message:"Unknown error";throw s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],connectionStatus:"failed",retryCount:t.servers[e].retryCount+1,lastError:r}}})),t.error("Reconnection failed",{serverName:e,error:r}),a}},[r.servers]);(0,a.useEffect)(()=>{Object.keys(l).forEach(e=>{let t=r.servers[e];t&&"failed"===t.connectionStatus||(clearTimeout(l[e]),i(t=>{let r={...t};return delete r[e],r}))})},[r.servers,l]),(0,a.useEffect)(()=>()=>{Object.values(l).forEach(clearTimeout)},[l]);let g=(0,a.useCallback)(e=>{s(t=>({...t,selectedServer:e}))},[]),v=(0,a.useCallback)(e=>{s(t=>({...t,selectedMCPConfigs:e}))},[]),b=(0,a.useCallback)(e=>{s(t=>({...t,isMultiSelectMode:e,selectedMultipleServers:e?[]:t.selectedMultipleServers}))},[]),j=(0,a.useCallback)(e=>{s(t=>{let r=t.selectedMultipleServers,s=r.includes(e);return{...t,selectedMultipleServers:s?r.filter(t=>t!==e):[...r,e]}})},[]),N=(0,a.useCallback)(async(e,t)=>{var a;console.log("handleUpdateFormData",t);let n=r.servers[e];if((null==n?void 0:n.oauthTokens)!=null&&t.useOAuth&&t.name===e&&"http"===t.type&&t.url===(null==(a=n.config.url)?void 0:a.toString())){let r=d(t);s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],config:r,connectionStatus:"connecting"}}}));try{let t=await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:n.config})});if((await t.json()).success){s(t=>({...t,servers:{...t.servers,[e]:{...t.servers[e],config:r,connectionStatus:"connected",lastConnectionTime:new Date,retryCount:0,lastError:void 0}}})),x.oR.success("Server configuration updated successfully!");return}console.warn("OAuth connection test failed, falling back to full reconnect")}catch(e){console.warn("OAuth connection test error, falling back to full reconnect",e)}}await f(e),await u(t),r.selectedServer===e&&t.name!==e&&g(t.name)},[r.servers,r.selectedServer,d,f,u,g]);return{appState:r,isLoading:n,connectedServerConfigs:r.servers,selectedServerEntry:r.servers[r.selectedServer],selectedMCPConfig:null==(e=r.servers[r.selectedServer])?void 0:e.config,selectedMCPConfigs:r.selectedMultipleServers.map(e=>r.servers[e]).filter(Boolean),selectedMCPConfigsMap:r.selectedMultipleServers.reduce((e,t)=>(r.servers[t]&&(e[t]=r.servers[t].config),e),{}),isMultiSelectMode:r.isMultiSelectMode,handleConnect:u,handleDisconnect:f,handleReconnect:p,handleUpdate:N,setSelectedServer:g,setSelectedMCPConfigs:v,toggleMultiSelectMode:b,toggleServerSelection:j,getValidAccessToken:h,setSelectedMultipleServersToAllServers:c}}();return n?(0,s.jsx)("div",{className:"min-h-screen bg-background flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),(0,s.jsx)("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})}):(0,s.jsxs)(tZ,{defaultOpen:!0,children:[(0,s.jsx)(t7,{onNavigate:e=>{t(e),"chat"===e&&p()},activeTab:e}),(0,s.jsxs)(t$,{className:"flex flex-col",children:[(0,s.jsx)("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear",children:(0,s.jsxs)("div",{className:"flex w-full items-center justify-between px-4 lg:px-6",children:[(0,s.jsx)("div",{className:"flex items-center gap-1 lg:gap-2",children:(0,s.jsx)(tK,{className:"-ml-1"})}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)(ra,{})})]})}),(0,s.jsxs)("div",{className:"flex-1",children:[("tools"===e||"resources"===e||"prompts"===e||"chat"===e)&&(0,s.jsx)(t9,{connectedServerConfigs:o,selectedServer:r.selectedServer,onServerChange:m,onConnect:i,isMultiSelectEnabled:"chat"===e,onMultiServerToggle:h,selectedMultipleServers:r.selectedMultipleServers}),"servers"===e&&(0,s.jsx)(en,{connectedServerConfigs:o,onConnect:i,onDisconnect:c,onReconnect:d,onUpdate:u}),"tools"===e&&(0,s.jsx)(eE,{serverConfig:l}),"resources"===e&&(0,s.jsx)(eR,{serverConfig:l}),"prompts"===e&&(0,s.jsx)(eP,{serverConfig:l}),"chat"===e&&(0,s.jsx)(tb,{serverConfigs:f}),"tracing"===e&&(0,s.jsx)(tM,{}),"settings"===e&&(0,s.jsx)(tw,{})]})]})]})}},9434:(e,t,r)=>{"use strict";r.d(t,{$B:()=>o,cn:()=>n});var s=r(2596),a=r(9688);function n(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,a.QP)((0,s.$)(t))}function o(e){if(e<=0)return"Expired";let t=Math.floor(e/864e5),r=Math.floor(e%864e5/36e5),s=Math.floor(e%36e5/6e4),a=Math.floor(e%6e4/1e3),n=[];return t>0&&n.push("".concat(t,"d")),r>0&&n.push("".concat(r,"h")),s>0&&n.push("".concat(s,"m")),(a>0||0===n.length)&&n.push("".concat(a,"s")),n.join(" ")+" remaining"}}},e=>{e.O(0,[774,214,866,574,441,964,358],()=>e(e.s=5973)),_N_E=e.O()}]);