@mcpjam/inspector 0.8.1 → 0.8.2

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 (41) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +9 -9
  3. package/.next/app-path-routes-manifest.json +2 -2
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/cache/.previewinfo +1 -1
  6. package/.next/cache/.rscinfo +1 -1
  7. package/.next/cache/.tsbuildinfo +1 -1
  8. package/.next/cache/eslint/.cache_1pr0xfn +1 -1
  9. package/.next/cache/webpack/client-production/0.pack +0 -0
  10. package/.next/cache/webpack/client-production/index.pack +0 -0
  11. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  12. package/.next/cache/webpack/server-production/0.pack +0 -0
  13. package/.next/cache/webpack/server-production/index.pack +0 -0
  14. package/.next/prerender-manifest.json +3 -3
  15. package/.next/server/app/_not-found/page.js +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/mcp/chat/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/mcp/connect/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/mcp/prompts/get/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/mcp/prompts/list/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/mcp/resources/list/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/mcp/resources/read/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/mcp/tools/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/oauth/callback/page.js +2 -2
  25. package/.next/server/app/oauth/callback/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/page.js +5 -5
  27. package/.next/server/app/page.js.nft.json +1 -1
  28. package/.next/server/app/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app-paths-manifest.json +2 -2
  30. package/.next/server/pages/500.html +1 -1
  31. package/.next/server/server-reference-manifest.js +1 -1
  32. package/.next/server/server-reference-manifest.json +1 -1
  33. package/.next/static/chunks/574-9365237f47ed3a68.js +1 -0
  34. package/.next/static/chunks/app/page-b0e3ed6257734413.js +1 -0
  35. package/.next/trace +35 -35
  36. package/README.md +5 -5
  37. package/package.json +1 -1
  38. package/.next/static/chunks/14-ae3a01e72ea53777.js +0 -1
  39. package/.next/static/chunks/app/page-fdd433623879220d.js +0 -1
  40. /package/.next/static/{Pq27RIJUfrYOGSjOrYx4E → SigynMKeJ0KJs0Nc9i0E-}/_buildManifest.js +0 -0
  41. /package/.next/static/{Pq27RIJUfrYOGSjOrYx4E → SigynMKeJ0KJs0Nc9i0E-}/_ssgManifest.js +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)}},5121:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>rd});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),E=r(6517),z=r(4020),O=r(3904),_=r(7639),M=r(4357),R=r(7863),P=r(6474);function L(e){var t,r,o;let{server:l,onDisconnect:c,onReconnect:u}=e,[m,h]=(0,a.useState)(!1),[p,v]=(0,a.useState)(!1),[b,j]=(0,a.useState)(Date.now()),[N,L]=(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;(0,a.useEffect)(()=>{let e=setInterval(()=>{j(Date.now())},1e3);return()=>clearInterval(e)},[]);let 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()=>{v(!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{v(!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)(E.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)(z.A,{className:"h-3 w-3"})})}),(0,s.jsxs)(k,{align:"end",className:"w-40",children:[(0,s.jsxs)(S,{onClick:V,disabled:p||"connecting"===l.connectionStatus||"oauth-flow"===l.connectionStatus,className:"text-xs cursor-pointer",children:[p?(0,s.jsx)(A.A,{className:"h-3 w-3 mr-2 animate-spin"}):(0,s.jsx)(O.A,{className:"h-3 w-3 mr-2"}),p?"Reconnecting...":"Reconnect"]}),(0,s.jsx)(f,{}),(0,s.jsxs)(S,{className:"text-destructive text-xs cursor-pointer",onClick:()=>c(l.name),children:[(0,s.jsx)(_.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)(M.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:N?l.lastError:l.lastError.length>100?"".concat(l.lastError.substring(0,100),"..."):l.lastError}),l.lastError.length>100&&(0,s.jsx)("button",{onClick:()=>L(!N),className:"text-red-500/70 hover:text-red-500 mt-1 underline text-xs cursor-pointer",children:N?"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:()=>h(!m),children:m?(0,s.jsx)(R.A,{className:"h-3 w-3"}):(0,s.jsx)(P.A,{className:"h-3 w-3"})})}),m&&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)(M.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)(M.A,{className:"h-3 w-3"})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-muted-foreground font-medium",children:"Client ID:"}),(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.client_id||"N/A"}),(0,s.jsx)("button",{onClick:()=>{var e;return G((null==(e=l.oauthTokens)?void 0:e.client_id)||"N/A","clientId")},className:"absolute top-1 right-1 p-1 text-muted-foreground/50 hover:text-foreground transition-colors cursor-pointer",children:"clientId"===I?(0,s.jsx)(C.A,{className:"h-3 w-3 text-green-500"}):(0,s.jsx)(M.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 I(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 U=r(5452);function D(e){let{...t}=e;return(0,s.jsx)(U.bL,{"data-slot":"dialog",...t})}function F(e){let{...t}=e;return(0,s.jsx)(U.ZL,{"data-slot":"dialog-portal",...t})}function q(e){let{className:t,...r}=e;return(0,s.jsx)(U.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 J(e){let{className:t,children:r,showCloseButton:a=!0,...n}=e;return(0,s.jsxs)(F,{"data-slot":"dialog-portal",children:[(0,s.jsx)(q,{}),(0,s.jsxs)(U.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)(U.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 B(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 H(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 G(e){let{className:t,...r}=e;return(0,s.jsx)(U.hE,{"data-slot":"dialog-title",className:(0,i.cn)("text-lg leading-none font-semibold",t),...r})}function V(e){let{className:t,...r}=e;return(0,s.jsx)(U.VY,{"data-slot":"dialog-description",className:(0,i.cn)("text-muted-foreground text-sm",t),...r})}var Z=r(83);function W(e){let{...t}=e;return(0,s.jsx)(Z.bL,{"data-slot":"select",...t})}function K(e){let{...t}=e;return(0,s.jsx)(Z.WT,{"data-slot":"select-value",...t})}function $(e){let{className:t,size:r="default",children:a,...n}=e;return(0,s.jsxs)(Z.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)(Z.In,{asChild:!0,children:(0,s.jsx)(P.A,{className:"size-4 opacity-50"})})]})}function Y(e){let{className:t,children:r,position:a="popper",...n}=e;return(0,s.jsx)(Z.ZL,{children:(0,s.jsxs)(Z.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)(Q,{}),(0,s.jsx)(Z.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)(ee,{})]})})}function X(e){let{className:t,children:r,...a}=e;return(0,s.jsxs)(Z.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)(Z.VF,{children:(0,s.jsx)(C.A,{className:"size-4"})})}),(0,s.jsx)(Z.p4,{children:r})]})}function Q(e){let{className:t,...r}=e;return(0,s.jsx)(Z.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)(R.A,{className:"size-4"})})}function ee(e){let{className:t,...r}=e;return(0,s.jsx)(Z.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)(P.A,{className:"size-4"})})}function et(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(),c(""),m(""),h(""),p("oauth"),v([]),r()},j=()=>{l({name:"",type:"stdio",command:"",args:[],url:"",headers:{},env:{},useOAuth:!0,oauthScopes:["mcp:*"]})},N=(e,t,r)=>{let s=[...g];s[e][t]=r,v(s)};return(0,s.jsx)(D,{open:t,onOpenChange:b,children:(0,s.jsxs)(J,{className:"max-w-md sm:max-w-lg",children:[(0,s.jsx)(B,{className:"space-y-2",children:(0,s.jsx)(G,{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(),c(""),m(""),h(""),p("none"),v([]),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)(I,{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)(W,{value:o.type,onValueChange:e=>l(t=>({...t,type:e})),children:[(0,s.jsx)($,{className:"w-22 rounded-r-none border-r-0 text-xs border-border",children:(0,s.jsx)(K,{})}),(0,s.jsxs)(Y,{children:[(0,s.jsx)(X,{value:"stdio",children:"STDIO"}),(0,s.jsx)(X,{value:"http",children:"HTTP"})]})]}),(0,s.jsx)(I,{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)(W,{value:o.type,onValueChange:e=>l(t=>({...t,type:e})),children:[(0,s.jsx)($,{className:"w-22 rounded-r-none border-r-0 text-xs border-border",children:(0,s.jsx)(K,{})}),(0,s.jsxs)(Y,{children:[(0,s.jsx)(X,{value:"stdio",children:"STDIO"}),(0,s.jsx)(X,{value:"http",children:"HTTP"})]})]}),(0,s.jsx)(I,{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)(I,{placeholder:"key",value:e.key,onChange:e=>N(t,"key",e.target.value),className:"h-8 text-sm"}),(0,s.jsx)(I,{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)(I,{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)(I,{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"})]})]})]})})}let er=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 es(e){let{connectedServerConfigs:t,onConnect:r,onDisconnect:o,onReconnect:l}=e,[i,c]=(0,a.useState)(!1),[x,h]=(0,a.useState)(""),[f,p]=(0,a.useState)("all");(0,a.useEffect)(()=>{Object.keys(t).forEach(e=>{l(e)})},[]);let g=Object.entries(t).filter(e=>{let[t,r]=e,s=t.toLowerCase().includes(x.toLowerCase()),a="all"===f||"stdio"===f&&"command"in r.config||"http"===f&&"url"in r.config;return s&&a}),v=Object.keys(t).length;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:()=>c(!0),className:"cursor-pointer",children:[(0,s.jsx)(u.A,{className:"h-4 w-4 mr-2"}),"Add Server"]})]}),v>0?(0,s.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:g.map(e=>{let[t,r]=e;return(0,s.jsx)(L,{server:r,onDisconnect:o,onReconnect:l},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)(er,{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:()=>c(!0),className:"mt-4 cursor-pointer",children:[(0,s.jsx)(u.A,{className:"h-4 w-4 mr-2"}),"Add Your First Server"]})]})}),0===g.length&&v>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)(et,{isOpen:i,onClose:()=>c(!1),onConnect:r})]})}er.displayName="MCPIcon";let ea={error:0,warn:1,info:2,debug:3,trace:4},en={error:"#ef4444",warn:"#f59e0b",info:"#3b82f6",debug:"#8b5cf6",trace:"#6b7280"};class eo{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 ea[e]<=ea[this.config.level]}constructor(){this.config={level:"info",enableConsole:!0,maxBufferSize:1e3},this.buffer=[],this.listeners=new Set}}let el=new eo;function ei(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unknown",t=(0,a.useCallback)(t=>(r,s,a)=>{if(!el.shouldLog(t))return;let n={timestamp:new Date().toISOString(),level:t,context:e,message:r,data:s,error:a};el.addEntry(n),el.getConfig().enableConsole&&function(e){let{timestamp:t,level:r,context:s,message:a,data:n,error:o}=e,l=new Date(t).toLocaleTimeString(),i=en[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 ec(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})}el.setConfig({level:"info",enableConsole:!0});let ed=(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 eu(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)(ed({variant:r}),t),...n})}var em=r(7655);function ex(e){let{className:t,children:r,...a}=e;return(0,s.jsxs)(em.bL,{"data-slot":"scroll-area",className:(0,i.cn)("relative",t),...a,children:[(0,s.jsx)(em.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)(eh,{}),(0,s.jsx)(em.OK,{})]})}function eh(e){let{className:t,orientation:r="vertical",...a}=e;return(0,s.jsx)(em.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)(em.lr,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var ef=r(8021),ep=r(1729);function eg(e){let{className:t,...r}=e;return(0,s.jsx)(ep.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 ev(e){let{...t}=e;return(0,s.jsx)(ep.Zk,{"data-slot":"resizable-panel",...t})}function eb(e){let{withHandle:t,className:r,...a}=e;return(0,s.jsx)(ep.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)(ef.A,{className:"size-2.5"})})})}var ej=r(8313),eN=r(3052),ey=r(5690),ew=r(9994);r(3347);var ek=r(968);function eS(e){let{className:t,...r}=e;return(0,s.jsx)(ek.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 eC=r(1497);function eA(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)(D,{open:!!t,onOpenChange:()=>{},children:(0,s.jsxs)(J,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,s.jsxs)(B,{children:[(0,s.jsxs)(G,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,s.jsx)(eC.A,{className:"h-3 w-3"}),"Elicitation Request"]}),(0,s.jsx)(V,{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)(eS,{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)(eu,{variant:"secondary",className:"text-xs",children:e.type})]}),(e=>{if("enum"===e.type){var t;return(0,s.jsxs)(W,{value:e.value,onValueChange:t=>u(e.name,t),children:[(0,s.jsx)($,{className:"w-full",children:(0,s.jsx)(K,{placeholder:"Select an option"})}),(0,s.jsx)(Y,{children:null==(t=e.enum)?void 0:t.map(e=>(0,s.jsx)(X,{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)(ec,{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)(I,{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)(H,{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)(O.A,{className:"h-4 w-4 mr-2 animate-spin"}):(0,s.jsx)(C.A,{className:"h-4 w-4 mr-2"}),"Accept"]})]})]})})}function eT(e){var t;let{serverConfig:r}=e,o=ei("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]&&E(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)}},E=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:z(n,a.enum),enum:a.enum,minimum:a.minimum,maximum:a.maximum,pattern:a.pattern})}),x(t)},z=(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)(eg,{direction:"vertical",className:"flex-1",children:[(0,s.jsx)(ev,{defaultSize:70,minSize:30,children:(0,s.jsxs)(eg,{direction:"horizontal",className:"h-full",children:[(0,s.jsx)(ev,{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)(ej.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)(eu,{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)(O.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)(ex,{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)(O.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)(eN.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},e)})})})})})]})}),(0,s.jsx)(eb,{withHandle:!0}),(0,s.jsx)(ev,{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)(O.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)(ey.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)(ex,{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)(ey.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)(eu,{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)(W,{value:e.value,onValueChange:t=>_(e.name,t),children:[(0,s.jsx)($,{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)(K,{placeholder:"Select an option",className:"font-mono text-xs"})}),(0,s.jsx)(Y,{children:null==(t=e.enum)?void 0:t.map(e=>(0,s.jsx)(X,{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)(ec,{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)(I,{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)(ej.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)(eb,{withHandle:!0}),(0,s.jsx)(ev,{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)(ex,{className:"h-full",children:(0,s.jsx)("div",{className:"p-4",children:(0,s.jsx)(ew.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)(eA,{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 eE=r(4395),ez=r(9890),eO=r(2657);function e_(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)(eg,{direction:"vertical",className:"flex-1",children:[(0,s.jsx)(ev,{defaultSize:70,minSize:30,children:(0,s.jsxs)(eg,{direction:"horizontal",className:"h-full",children:[(0,s.jsx)(ev,{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)(eE.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)(eu,{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)(O.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)(ex,{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)(O.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)(ez.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)(eu,{variant:"outline",className:"text-xs mt-2 font-mono",children:e.mimeType})]}),(0,s.jsx)(eN.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},e.uri))})})})})]})}),(0,s.jsx)(eb,{withHandle:!0}),(0,s.jsx)(ev,{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)(O.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)(eO.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)(ex,{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)(eu,{variant:"secondary",className:"text-xs font-mono font-medium",children:e.type}),e.mimeType&&(0,s.jsx)(eu,{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)(ew.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)(eO.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)(eE.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)(eb,{withHandle:!0}),(0,s.jsx)(ev,{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 eM(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)(eg,{direction:"vertical",className:"flex-1",children:[(0,s.jsx)(ev,{defaultSize:70,minSize:30,children:(0,s.jsxs)(eg,{direction:"horizontal",className:"h-full",children:[(0,s.jsx)(ev,{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)(eC.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)(eu,{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)(O.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)(ex,{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)(O.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)(eN.A,{className:"h-3 w-3 text-muted-foreground flex-shrink-0 mt-1"})]})},e)})})})})})]})}),(0,s.jsx)(eb,{withHandle:!0}),(0,s.jsx)(ev,{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)(O.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)(ey.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)(ex,{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)(ey.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)(eu,{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)(W,{value:e.value,onValueChange:t=>k(e.name,t),children:[(0,s.jsx)($,{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)(K,{placeholder:"Select an option",className:"font-mono text-xs"})}),(0,s.jsx)(Y,{children:null==(t=e.enum)?void 0:t.map(e=>(0,s.jsx)(X,{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)(ec,{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)(I,{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)(eC.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)(eb,{withHandle:!0}),(0,s.jsx)(ev,{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)(ex,{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)(ew.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 eR=r(1366),eP=r(2596),eL=r(9688);function eI(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,eL.QP)((0,eP.$)(t))}function eU(e){return new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}).format(e)}function eD(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 eF=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 eq=[{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"}],eJ="mcp-inspector-provider-tokens",eB={anthropic:"",openai:"",ollama:"local",ollamaBaseUrl:"http://localhost:11434"};function eH(){let[e,t]=(0,a.useState)(eB),[r,s]=(0,a.useState)(!1);(0,a.useEffect)(()=>{try{let e=localStorage.getItem(eJ);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(eJ,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(eB)},[]),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||eB.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 eG{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 eV=new eG,eZ=async e=>{let t=e?new eG(e):eV;return await t.isOllamaRunning()?{isRunning:!0,availableModels:await t.getAvailableModels()}:{isRunning:!1,availableModels:[]}};var eW=r(760),eK=r(2605),e$=r(133),eY=r(6874),eX=r.n(eY),eQ=r(8240),e0=r(5405);let e1={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)(eX(),{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})}},e2=[e0.A],e4=(0,a.memo)(e=>{let{children:t}=e;return(0,s.jsx)(eQ.oz,{remarkPlugins:e2,components:e1,children:t})},(e,t)=>e.children===t.children);function e3(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)(ec,{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 e5=r(646),e6=r(4861),e8=r(4186);function e7(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)(M.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 e9(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)(P.A,{className:"h-3 w-3"}):(0,s.jsx)(eN.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)(e9,{data:a,depth:r+1})})]},t)})}),n&&(0,s.jsx)("span",{className:"text-muted-foreground ml-4",children:u})]})}function te(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)(er,{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)(e5.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)(e5.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)(e6.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)(e6.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)(e8.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)(e8.A,{className:"h-4 w-4 text-blue-600/70 dark:text-blue-400/70 opacity-20"})})]});default:return(0,s.jsx)(e8.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)(P.A,{className:"h-4 w-4 text-muted-foreground"}):(0,s.jsx)(eN.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)(e9,{data:t.parameters}):(0,s.jsx)(e7,{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)(e6.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)(e5.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)(e7,{data:r.result}):(0,s.jsx)("div",{className:"text-sm text-foreground bg-muted/30 p-3 rounded border",children:String(r.result)})})]})})]})]})]})}let tt={src:"/_next/static/media/claude_logo.d33b25b0.png"},tr={src:"/_next/static/media/openai_logo.3f83154a.png"},ts={src:"/_next/static/media/ollama_logo.9f08a95b.svg"},ta={src:"/_next/static/media/ollama_dark.9af45ac0.png"},tn=(e,t)=>{switch(e){case"anthropic":return tt.src;case"openai":return tr.src;case"ollama":if("dark"===t)return ta.src;if("system"===t&&"undefined"!=typeof document)return document.documentElement.classList.contains("dark")?ta.src:ts.src;return ts.src;default:return null}};var to=r(911);let tl=()=>(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]"})]})]}),ti=(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,to.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)(eW.N,{children:(0,s.jsxs)(eK.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:tn(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)(te,{toolCall:e,toolResult:a},e.id)})}),w?(0,s.jsx)(eK.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},children:(0,s.jsx)(tl,{})}):"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)(e4,{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:eU(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)(M.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)(e$.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)(e3,{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)(M.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:eU(t.timestamp)})]})]}):(0,s.jsx)("div",{className:"w-full",children:(0,s.jsx)(e3,{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 tc=r(492),td=r(8979),tu=r(9881),tm=r(8832),tx=r(6766);function th(e){let{provider:t}=e,r=tn(t,(0,to.x)(e=>e.themeMode));return r?(0,s.jsx)(tx.default,{src:r,width:12,height:12,alt:"".concat(t," logo"),className:"h-3 w-3 object-contain"}):(0,s.jsx)("div",{className:eI("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 tf(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)(th,{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)(th,{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 tp(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)(eW.N,{children:m&&(0,s.jsx)(eK.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)(tm.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)(ec,{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:eI("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)(tc.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)(td.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:eI("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)(tu.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)(tf,{currentModel:h,availableModels:f,onModelChange:p,disabled:l,isLoading:i})})]})}function tg(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}=eH(),{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 eZ(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||!E.some(e=>e.id===b.id))if(w&&N.length>0)j(N[0]);else if(r("anthropic")){let e=eq.find(e=>e.id===eF.CLAUDE_3_5_SONNET_LATEST);e&&j(e)}else if(r("openai")){let e=eq.find(e=>e.id===eF.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]),E=(0,a.useMemo)(()=>{let e=[];for(let t of eq)"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]),z=(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)},[]),O=(0,a.useCallback)(async e=>{if(!l||!b||!A)throw Error("Missing required configuration: serverConfig, model, and apiKey are required");let t=eD("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);z(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,z,n]),_=(0,a.useCallback)(async(e,t)=>{if(!e.trim()||x.isLoading)return;let r=eD("user",e,t);h(e=>({...e,messages:[...e.messages,r],isLoading:!0,error:void 0})),c&&c(r),S.current=new AbortController;try{await O(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,O,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 O(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)}}},[O,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:E,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)(eW.N,{mode:"popLayout",children:[i.map((e,t)=>(0,s.jsx)(eK.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)(ti,{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)(eK.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)(eR.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)(eW.N,{children:d&&(0,s.jsx)(eK.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)(tp,{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)(eK.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)(eK.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)(tp,{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)(eK.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 tv=r(381),tb=r(9803),tj=r(8749);function tN(){let{tokens:e,setToken:t,clearToken:r,hasToken:o,getOllamaBaseUrl:l,setOllamaBaseUrl:i}=eH(),[c,u]=(0,a.useState)(!1),[m,x]=(0,a.useState)(!1),h=(0,to.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)(tv.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)(tb.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)(eS,{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)(I,{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)(tj.A,{className:"h-4 w-4"}):(0,s.jsx)(eO.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)(eS,{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)(I,{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)(tj.A,{className:"h-4 w-4"}):(0,s.jsx)(eO.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)(eS,{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)(I,{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 ty=r(5543),tw=r(3343),tk=r(2572);let tS=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"HH:mm:ss.SSS",r="string"==typeof e?(0,tw.H)(e):e;return(0,tk.GP)(r,t)};r(3596);var tC=r(1362);let tA={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 tT(e){let{level:t}=e;return(0,s.jsx)(eu,{variant:"outline",className:(0,i.cn)("font-mono",tA[t]),children:t.toUpperCase()})}function tE(e){let{entry:t,isExpanded:r,onToggleExpand:a}=e,n=void 0!==t.data||void 0!==t.error,{theme:o}=(0,tC.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)(P.A,{className:"h-4 w-4 text-muted-foreground"}):(0,s.jsx)(eN.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(tS(t.timestamp),"]")}),(0,s.jsx)(tT,{level:t.level}),(0,s.jsx)(eu,{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)(ew.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 tz=["error","warn","info","debug","trace"];function tO(){let{entries:e,getFilteredEntries:t}=function(){let[,e]=(0,a.useState)({});return(0,a.useEffect)(()=>{let t=el.subscribe(()=>{e({})});return()=>{t()}},[]),{entries:el.getEntries(),config:el.getConfig(),setConfig:el.setConfig.bind(el),clearBuffer:el.clearBuffer.bind(el),getFilteredEntries:el.getFilteredEntries.bind(el)}}(),[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)(W,{value:o,onValueChange:e=>l(e),children:[(0,s.jsx)($,{className:"w-32",children:(0,s.jsx)(K,{})}),(0,s.jsxs)(Y,{children:[(0,s.jsx)(X,{value:"all",children:"All Levels"}),tz.map(e=>(0,s.jsx)(X,{value:e,children:(0,s.jsx)(tT,{level:e})},e))]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[(0,s.jsx)(ty.A,{className:"h-4 w-4"}),(0,s.jsx)(I,{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)(tE,{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)(tu.A,{className:"h-4 w-4 mr-1"}),"Top"]})]})}var t_=r(1392),tM=r(1274),tR=r(9376),tP=r(2432);function tL(e){let{...t}=e;return(0,s.jsx)(U.bL,{"data-slot":"sheet",...t})}function tI(e){let{...t}=e;return(0,s.jsx)(U.ZL,{"data-slot":"sheet-portal",...t})}function tU(e){let{className:t,...r}=e;return(0,s.jsx)(U.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 tD(e){let{className:t,children:r,side:a="right",...n}=e;return(0,s.jsxs)(tI,{children:[(0,s.jsx)(tU,{}),(0,s.jsxs)(U.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)(U.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 tF(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 tq(e){let{className:t,...r}=e;return(0,s.jsx)(U.hE,{"data-slot":"sheet-title",className:(0,i.cn)("text-foreground font-semibold",t),...r})}function tJ(e){let{className:t,...r}=e;return(0,s.jsx)(U.VY,{"data-slot":"sheet-description",className:(0,i.cn)("text-muted-foreground text-sm",t),...r})}let tB=a.createContext(null);function tH(){let e=a.useContext(tB);if(!e)throw Error("useSidebar must be used within a SidebarProvider.");return e}function tG(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)(tB.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 tV(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}=tH();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)(tL,{open:u,onOpenChange:m,...l,children:(0,s.jsxs)(tD,{"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)(tF,{className:"sr-only",children:[(0,s.jsx)(tq,{children:"Sidebar"}),(0,s.jsx)(tJ,{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 tZ(e){let{className:t,onClick:r,...a}=e,{toggleSidebar:n}=tH();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)(tP.A,{}),(0,s.jsx)("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function tW(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 tK(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 t$(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 tY(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 tX(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 tQ(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 t0(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 t1(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 t2=(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 t4(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}=tH(),h=(0,s.jsx)(u,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":n,"data-active":r,className:(0,i.cn)(t2({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 t3(e){let{items:t,onItemClick:r}=e;return(0,s.jsx)(tX,{children:(0,s.jsx)(tQ,{children:(0,s.jsx)(t0,{children:t.map(e=>(0,s.jsx)(t1,{children:(0,s.jsxs)(t4,{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 t5=[{id:"connection",items:[{title:"MCP Servers",url:"#servers",icon:er},{title:"Playground",url:"#chat",icon:eR.A},{title:"Tracing",url:"#tracing",icon:t_.A}]},{id:"tools",items:[{title:"Tools",url:"#tools",icon:tM.A},{title:"Resources",url:"#resources",icon:eE.A},{title:"Prompts",url:"#prompts",icon:tR.A}]},{id:"settings",items:[{title:"Settings",url:"#settings",icon:tv.A}]}];function t6(e){let{onNavigate:t,activeTab:r,...n}=e,o=(0,to.x)(e=>e.themeMode),l=e=>{t&&e.startsWith("#")&&t(e.slice(1))};return(0,s.jsxs)(tV,{collapsible:"offcanvas",...n,children:[(0,s.jsx)(tK,{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)(tY,{children:t5.map((e,t)=>(0,s.jsxs)(a.Fragment,{children:[(0,s.jsx)(t3,{items:e.items.map(e=>({...e,isActive:e.url==="#".concat(r)})),onItemClick:l}),t<t5.length-1&&(0,s.jsx)("div",{className:"mx-4 my-2 border-t border-border/50"})]},e.id))}),(0,s.jsx)(t$,{})]})}function t8(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)(et,{isOpen:u,onClose:()=>m(!1),onConnect:d})]})}var t7=r(2098),t9=r(3509),re=r(4477);let rt=(0,re.createServerReference)("70c3204c8c80063f4f0a5b1c3fdacb444c5403a1d3",re.callServer,void 0,re.findSourceMapURL,"setValueToCookie");function rr(){let e=(0,to.x)(e=>e.themeMode),t=(0,to.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 rt("theme_mode",r)};return(0,s.jsx)(d,{size:"icon",onClick:r,className:"cursor-pointer",children:"dark"===e?(0,s.jsx)(t7.A,{}):(0,s.jsx)(t9.A,{})})}var rs=r(6208);class ra{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:"none",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 rn(e){try{var t;let r=new ra(e.serverName);localStorage.setItem("mcp-serverUrl-".concat(e.serverName),e.serverUrl),localStorage.setItem("mcp-oauth-pending",e.serverName);let s=await (0,rs.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=ri(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 ro(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 ra(t),a=await (0,rs.j2)(s,{serverUrl:r,authorizationCode:e,scope:"mcp:*"});if("AUTHORIZED"===a){let e=s.tokens();if(e){localStorage.removeItem("mcp-oauth-pending");let s=ri(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 rl(e){let t=localStorage.getItem("mcp-tokens-".concat(e));return t?JSON.parse(t):void 0}function ri(e,t){return{url:new URL(e),requestInit:{headers:t.access_token?{Authorization:"Bearer ".concat(t.access_token)}:{}},oauth:t}}let rc="mcp-inspector-state";function rd(){let[e,t]=(0,a.useState)("servers"),{appState:r,isLoading:n,connectedServerConfigs:o,selectedMCPConfig:l,handleConnect:i,handleDisconnect:c,handleReconnect:d,setSelectedServer:u,toggleServerSelection:m,selectedMCPConfigsMap:h,setSelectedMultipleServersToAllServers:f}=function(){var e;let t=ei("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(rc);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(rc,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("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 rn({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:rl(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 ro(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:rl(e),connectionStatus:"connecting",lastError:void 0}},selectedServer:e})):s(t=>({...t,servers:{...t.servers,[e]:{name:e,config:a.serverConfig,oauthTokens:rl(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 a=r.servers[e],n=await fetch("/api/mcp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverConfig:a.config})}),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]}})},[]);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,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)(tG,{defaultOpen:!0,children:[(0,s.jsx)(t6,{onNavigate:e=>{t(e),"chat"===e&&f()},activeTab:e}),(0,s.jsxs)(tW,{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)(tZ,{className:"-ml-1"})}),(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)(rr,{})})]})}),(0,s.jsxs)("div",{className:"flex-1",children:[("tools"===e||"resources"===e||"prompts"===e||"chat"===e)&&(0,s.jsx)(t8,{connectedServerConfigs:o,selectedServer:r.selectedServer,onServerChange:u,onConnect:i,isMultiSelectEnabled:"chat"===e,onMultiServerToggle:m,selectedMultipleServers:r.selectedMultipleServers}),"servers"===e&&(0,s.jsx)(es,{connectedServerConfigs:o,onConnect:i,onDisconnect:c,onReconnect:d}),"tools"===e&&(0,s.jsx)(eT,{serverConfig:l}),"resources"===e&&(0,s.jsx)(e_,{serverConfig:l}),"prompts"===e&&(0,s.jsx)(eM,{serverConfig:l}),"chat"===e&&(0,s.jsx)(tg,{serverConfigs:h}),"tracing"===e&&(0,s.jsx)(tO,{}),"settings"===e&&(0,s.jsx)(tN,{})]})]})]})}},5973:(e,t,r)=>{Promise.resolve().then(r.bind(r,5121))},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})}},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,14,441,964,358],()=>e(e.s=5973)),_N_E=e.O()}]);