blade-code 0.10.5 → 0.10.7

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 (108) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-z906d5tb.js → chunk-0n04bmta.js} +2 -2
  3. package/dist/{chunk-drrdzmaa.js → chunk-0xm8hn2h.js} +2 -2
  4. package/dist/chunk-0z7q89w7.js +2 -0
  5. package/dist/{chunk-gxmrakrk.js → chunk-1sw9z975.js} +1 -1
  6. package/dist/{chunk-948qe2pp.js → chunk-1v7hpr34.js} +1 -1
  7. package/dist/{chunk-fvhc1yj8.js → chunk-3fdyzgpv.js} +1 -1
  8. package/dist/{chunk-15d49qty.js → chunk-43j2f1b5.js} +1 -1
  9. package/dist/{chunk-njyvrtje.js → chunk-4hhkbyja.js} +2 -2
  10. package/dist/{chunk-6eragc74.js → chunk-4rhssb85.js} +2 -2
  11. package/dist/chunk-598egka3.js +22 -0
  12. package/dist/chunk-5ak9tw83.js +100 -0
  13. package/dist/chunk-738pkjf8.js +1 -0
  14. package/dist/{chunk-xv0maezy.js → chunk-7a200q5g.js} +2 -2
  15. package/dist/{chunk-5twefby5.js → chunk-7pkrwh10.js} +1 -1
  16. package/dist/chunk-7xfmzvxp.js +1 -0
  17. package/dist/{chunk-9ffr01c3.js → chunk-847e0sk9.js} +1 -1
  18. package/dist/chunk-867rz2ss.js +1 -0
  19. package/dist/chunk-a3e97syg.js +3 -0
  20. package/dist/{chunk-0n97186m.js → chunk-ahxc3n3g.js} +2 -2
  21. package/dist/{chunk-tq52pbde.js → chunk-akev4wsz.js} +1 -1
  22. package/dist/{chunk-epj56s0n.js → chunk-az4b6106.js} +1 -1
  23. package/dist/{chunk-63ysxybd.js → chunk-e9ckf8e7.js} +1 -1
  24. package/dist/chunk-f7854pbx.js +187 -0
  25. package/dist/chunk-fwt0kje3.js +1 -0
  26. package/dist/{chunk-1vx4sf1y.js → chunk-g1q27q6q.js} +2 -2
  27. package/dist/chunk-g3wgzyhx.js +160 -0
  28. package/dist/chunk-g4snq0dx.js +1 -0
  29. package/dist/chunk-ggm04adj.js +1 -0
  30. package/dist/chunk-hpytxsge.js +1 -0
  31. package/dist/chunk-htr91q9c.js +1 -0
  32. package/dist/chunk-hwcp940f.js +1 -0
  33. package/dist/chunk-j5ysjbyr.js +10 -0
  34. package/dist/{chunk-jza1rsan.js → chunk-jpy61wna.js} +1 -1
  35. package/dist/chunk-kqpwz9b7.js +8 -0
  36. package/dist/{chunk-gxzbv67r.js → chunk-m86ekqp0.js} +2 -2
  37. package/dist/{chunk-51wtvmzn.js → chunk-m8k1mv0j.js} +1 -1
  38. package/dist/{chunk-ydtcvxsm.js → chunk-mt4328yf.js} +1 -1
  39. package/dist/{chunk-35yktzm1.js → chunk-ne7zdjrh.js} +1 -1
  40. package/dist/{chunk-bexgcc2d.js → chunk-p0j8994h.js} +1 -1
  41. package/dist/{chunk-gb54hc78.js → chunk-p3ahf1fh.js} +1 -1
  42. package/dist/chunk-pt659n0v.js +1466 -0
  43. package/dist/chunk-q1gfeadm.js +1 -0
  44. package/dist/{chunk-vntzy7bc.js → chunk-qk2z6gag.js} +2 -2
  45. package/dist/{chunk-ea7wsges.js → chunk-qqwgb9ja.js} +2 -2
  46. package/dist/{chunk-am8dtvff.js → chunk-qycwavck.js} +72 -17
  47. package/dist/chunk-rk1w5pry.js +2 -0
  48. package/dist/{chunk-s645azsm.js → chunk-rn908m3v.js} +2 -2
  49. package/dist/{chunk-dqvcgwhe.js → chunk-rz2ftt6h.js} +2 -2
  50. package/dist/{chunk-19kg7yvw.js → chunk-rz9yh6e4.js} +2 -2
  51. package/dist/{chunk-qm11hjd3.js → chunk-tc83e1b0.js} +1 -1
  52. package/dist/{chunk-v93hcxe7.js → chunk-tcc3v4n2.js} +1 -1
  53. package/dist/{chunk-g6h6h8xr.js → chunk-tp9zk241.js} +1 -1
  54. package/dist/chunk-tzh4ahry.js +6 -0
  55. package/dist/chunk-v0rn831t.js +1 -0
  56. package/dist/{chunk-fz1vyc15.js → chunk-vafn0spm.js} +1 -1
  57. package/dist/{chunk-rh7v814a.js → chunk-vcq624qv.js} +2 -2
  58. package/dist/chunk-vynsgc2g.js +1 -0
  59. package/dist/{chunk-qda309d9.js → chunk-w01sec4f.js} +2 -2
  60. package/dist/chunk-w0ena7fe.js +9 -0
  61. package/dist/{chunk-6tx8k249.js → chunk-wmdgb5pz.js} +2 -2
  62. package/dist/{chunk-an96c54z.js → chunk-wrbm6rch.js} +8 -8
  63. package/dist/{chunk-sanhjqpd.js → chunk-x3780wpy.js} +2 -2
  64. package/dist/{chunk-yc53wz4r.js → chunk-y573s5r8.js} +2 -2
  65. package/dist/chunk-ydwjttdz.js +1 -0
  66. package/dist/{chunk-vpj0sv73.js → chunk-yyvx1avz.js} +3 -3
  67. package/dist/chunk-z9fsh3kn.js +1 -0
  68. package/dist/{chunk-ygx03mdh.js → chunk-zjf1z27e.js} +1 -1
  69. package/dist/web/assets/ChatView-BYfHmxKJ.js +7 -0
  70. package/dist/web/assets/{CodeBlockHighlighter-CFW6qjnA.js → CodeBlockHighlighter-CC4e9nFc.js} +1 -1
  71. package/dist/web/assets/{FilePreview-CR_XetY0.js → FilePreview-C3HEoLYS.js} +1 -1
  72. package/dist/web/assets/{MarkdownRenderer-CVrxJswQ.js → MarkdownRenderer-COycrGUX.js} +3 -3
  73. package/dist/web/assets/{McpModal-BO-85gll.js → McpModal-CDgr9kVq.js} +1 -1
  74. package/dist/web/assets/{SettingsModal-CW87OnxI.js → SettingsModal-CvdVIbeG.js} +1 -1
  75. package/dist/web/assets/{SkillsModal-Q8ZFPhys.js → SkillsModal-lSX1ZKTu.js} +1 -1
  76. package/dist/web/assets/{TaskSwitcher-BzH-0QXr.js → TaskSwitcher-peKi9KvN.js} +1 -1
  77. package/dist/web/assets/{TerminalPanel-DTqvx8yB.js → TerminalPanel-DqQ-7CTG.js} +1 -1
  78. package/dist/web/assets/index-BF5HEN_f.js +32 -0
  79. package/dist/web/assets/index-BrkTYxtS.css +1 -0
  80. package/dist/web/index.html +2 -2
  81. package/package.json +1 -1
  82. package/dist/chunk-069zpw09.js +0 -6
  83. package/dist/chunk-1m5r6mp2.js +0 -180
  84. package/dist/chunk-1q21sxhx.js +0 -1
  85. package/dist/chunk-1r6szcrj.js +0 -1
  86. package/dist/chunk-1x4fpe47.js +0 -1
  87. package/dist/chunk-2nkd1kjx.js +0 -1
  88. package/dist/chunk-417wefq7.js +0 -99
  89. package/dist/chunk-4ncbd4k0.js +0 -1
  90. package/dist/chunk-62881c2s.js +0 -1484
  91. package/dist/chunk-7443b95r.js +0 -1
  92. package/dist/chunk-79s052sw.js +0 -2
  93. package/dist/chunk-7jy60gnx.js +0 -1
  94. package/dist/chunk-c5tds5v0.js +0 -9
  95. package/dist/chunk-ccwskwb3.js +0 -1
  96. package/dist/chunk-f6mszdsd.js +0 -1
  97. package/dist/chunk-hh85pk77.js +0 -160
  98. package/dist/chunk-nz78b5c5.js +0 -10
  99. package/dist/chunk-r1764q6f.js +0 -1
  100. package/dist/chunk-r6mwyg3h.js +0 -3
  101. package/dist/chunk-rzzt21ef.js +0 -22
  102. package/dist/chunk-t8x2qpe2.js +0 -1
  103. package/dist/chunk-tjnfhm9v.js +0 -1
  104. package/dist/chunk-v0ygsjry.js +0 -1
  105. package/dist/chunk-zyz82mcd.js +0 -1
  106. package/dist/web/assets/ChatView-Y-6k-ayR.js +0 -7
  107. package/dist/web/assets/index-B7etZcne.css +0 -1
  108. package/dist/web/assets/index-ClOgGy-I.js +0 -32
@@ -1,4 +1,4 @@
1
- import{r,j as e}from"./vendor-react-DG5dkZ_t.js";import{_ as $,n as P,o as Se,p as Fe,q as se}from"./vendor-radix-DBy9B2DN.js";import{i as Ze,a as Xe,d as Me,u as $e,b as ze,c as et,e as de,f as oe,g as tt}from"./useRequest-BvqVDnKl.js";import{b as at,D as he,e as be,G as nt,g as ge,j as w,x as L,y as rt}from"./index-ClOgGy-I.js";import{a as Be,i as st,X as ve,f as De,L as le,k as ot,Z as Te,C as lt,D as dt}from"./vendor-icons-D_AkWmWB.js";function ie(n,s){if(Ze){if(!n)return s;var o;return Xe(n)?o=n():"current"in n?o=n.current:o=n,o}}var it=function(n){var s=function(o,u,f){var x=r.useRef(!1),c=r.useRef([]),p=r.useRef([]),h=r.useRef(void 0);n(function(){var b,S=Array.isArray(f)?f:[f],g=S.map(function(j){return ie(j)});if(!x.current){x.current=!0,c.current=g,p.current=u,h.current=o();return}(g.length!==c.current.length||!Me(c.current,g)||!Me(p.current,u))&&((b=h.current)===null||b===void 0||b.call(h),c.current=g,p.current=u,h.current=o())}),$e(function(){var b;(b=h.current)===null||b===void 0||b.call(h),x.current=!1})};return s},ct=it(r.useEffect);function xt(){var n=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,s=typeof self=="object"&&self&&self.Object===Object&&self;return n||s}xt()||(global.Date=Date);function mt(n,s){var o,u=ze(n),f=(o=s==null?void 0:s.wait)!==null&&o!==void 0?o:1e3,x=r.useMemo(function(){return et(function(){for(var c=[],p=0;p<arguments.length;p++)c[p]=arguments[p];return u.current.apply(u,$([],P(c),!1))},f,s)},[]);return $e(function(){x.cancel()}),{run:x,cancel:x.cancel,flush:x.flush}}function ut(n,s,o){o===void 0&&(o={});var u=o.enable,f=u===void 0?!0:u,x=ze(s);ct(function(){if(f){var c=ie(o.target,window);if(c!=null&&c.addEventListener){var p=function(b){return x.current(b)},h=Array.isArray(n)?n:[n];return h.forEach(function(b){c.addEventListener(b,p,{capture:o.capture,once:o.once,passive:o.passive})}),function(){h.forEach(function(b){c.removeEventListener(b,p,{capture:o.capture})})}}}},[n,o.capture,o.once,o.passive,f],o.target)}var ft=function(n){return n===document||n===document.documentElement||n===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):n.scrollTop},Pe=function(n){return n.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},pt=function(n){return n.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},ht=function(n,s){s===void 0&&(s={});var o=s.target,u=s.isNoMore,f=s.threshold,x=f===void 0?100:f,c=s.direction,p=c===void 0?"bottom":c,h=s.reloadDeps,b=h===void 0?[]:h,S=s.manual,g=s.onBefore,j=s.onSuccess,C=s.onError,d=s.onFinally,F=P(r.useState(),2),M=F[0],O=F[1],N=P(r.useState(!1),2),z=N[0],R=N[1],U=p==="top",D=r.useRef(void 0),_=r.useRef(0),H=r.useMemo(function(){return u?u(M):!1},[M]),I=de(function(m){return Se(void 0,void 0,void 0,function(){var v;return Fe(this,function(k){switch(k.label){case 0:return[4,n(m)];case 1:return v=k.sent(),[2,{currentData:v,lastData:m}]}})})},{manual:S,onFinally:function(m,v,k){R(!1),d==null||d(v==null?void 0:v.currentData,k)},onBefore:function(){return g==null?void 0:g()},onSuccess:function(m){var v,k,E;m.lastData?O(se(se({},m.currentData),{list:U?$($([],P(m.currentData.list),!1),P((k=m.lastData.list)!==null&&k!==void 0?k:[]),!1):$($([],P((E=m.lastData.list)!==null&&E!==void 0?E:[]),!1),P(m.currentData.list),!1)})):O(se(se({},m.currentData),{list:$([],P((v=m.currentData.list)!==null&&v!==void 0?v:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(U){var y=ie(o);if(y=y===document?document.documentElement:y,y){var ee=Pe(y);y.scrollTo(0,ee-_.current)}}else G()})}),j==null||j(m.currentData)},onError:function(m){return C==null?void 0:C(m)}}),Y=I.loading,J=I.error,K=I.run,q=I.runAsync,ce=I.cancel,Q=oe(function(){H||(R(!0),K(M))}),Z=function(m){return Se(void 0,void 0,void 0,function(){var v;return Fe(this,function(k){switch(k.label){case 0:return[4,q(m)];case 1:return v=k.sent(),[2,v.currentData]}})})},xe=oe(function(){return H?Promise.reject():(R(!0),Z(M))}),me=function(){return R(!1),K()},X=function(){return R(!1),Z()},G=function(){var m=ie(o);if(m){var v=m===document?document.documentElement:m,k=ft(v),E=Pe(v),y=pt(v);U?(D.current!==void 0&&D.current>k&&k<=x&&Q(),D.current=k,_.current=E-k):E-k<=y+x&&Q()}};return ut("scroll",function(){Y||z||G()},{target:o}),tt(function(){K()},$([],P(b),!1)),{data:M,loading:!z&&Y,error:J,loadingMore:z,noMore:H,loadMore:Q,loadMoreAsync:xe,reload:oe(me),reloadAsync:oe(X),mutate:O,cancel:ce}};const Le={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},bt={connected:"Connected",connecting:"Connecting...",reconnecting:"Recovering...",offline:"Offline",error:"Error"},gt={disabled:"Not configured",unavailable:"Unavailable in this runtime",unauthenticated:"Authorization required",authorizing:"Waiting for authorization...",authenticated:"Authorized",error:"Authorization failed"},Oe=20,vt=["debug","info","notice","warning","error","critical","alert","emergency"],Re=n=>n.status!=="reconnecting"||!n.recovery?bt[n.status]:`Recovering ${n.recovery.attempt}/${n.recovery.maxAttempts}`,kt=async()=>L("/mcp"),Et=async n=>L(`/mcp/${encodeURIComponent(n)}/logs?limit=20`),jt="mcp server @modelcontextprotocol",Nt=3,Ue=n=>{var s;return((s=n.split("/").pop())==null?void 0:s.replace(/^server-/,""))||n},Ct=async(n,s)=>{const o=n&&n.length>=Nt?n:jt,u=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(o)}&size=${Oe}&from=${s}`,f=await L(u);return{list:f.objects.map(x=>x.package),total:f.total,hasMore:s+Oe<f.total}};function Dt(){const{isMcpOpen:n,toggleMcp:s}=at(),[o,u]=r.useState("installed"),[f,x]=r.useState(!1),[c,p]=r.useState(null),[h,b]=r.useState(""),[S,g]=r.useState(null),[j,C]=r.useState(null),[d,F]=r.useState(null),[M,O]=r.useState(null),[N,z]=r.useState(null),[R,U]=r.useState(""),[D,_]=r.useState(null),[H,I]=r.useState(!1),[Y,J]=r.useState(null),[K,q]=r.useState(null),[ce,Q]=r.useState(""),[Z,xe]=r.useState(""),[me,X]=r.useState(null),[G,m]=r.useState(null),v=r.useRef(null),{run:k}=mt(t=>{xe(t)},{wait:500}),{data:E=[],loading:y,error:ee,run:ke,runAsync:W}=de(kt,{refreshDeps:[n],ready:n,onSuccess:t=>{t.length>0&&!c&&p(t[0].id)}}),{data:ae,loading:ue,error:Ee,runAsync:ne}=de(Et,{manual:!0}),{data:A,loading:He,loadingMore:Je,noMore:qe,error:je,reload:Ne}=ht(async t=>{var l;const i=((l=t==null?void 0:t.list)==null?void 0:l.length)??0;return Ct(Z,i)},{target:v,isNoMore:t=>!(t!=null&&t.hasMore),reloadDeps:[Z],manual:!n||o!=="catalog"}),{runAsync:Ce,loading:ye,error:V}=de(async t=>{await L("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,config:t})})},{manual:!0,onSuccess:()=>{W(),x(!1),m(null),X(null)},onError:()=>{X(null)}}),te=r.useMemo(()=>{const t=h.trim().toLowerCase();return t?E.filter(i=>[i.name,i.endpoint,i.description].some(l=>l.toLowerCase().includes(t))):E},[h,E]),a=r.useMemo(()=>te.find(t=>t.id===c)??te[0],[te,c]),re=r.useMemo(()=>{if(!a)return[];const t=(a.prompts??[]).flatMap(l=>l.arguments.map(B=>({key:`prompt:${l.name}:${B.name}`,label:`${l.name}.${B.name}`,reference:{type:"prompt",name:l.name},argument:B.name}))),i=(a.resourceTemplates??[]).flatMap(l=>(l.variables??[]).map(B=>({key:`resource:${l.uriTemplate}:${B}`,label:`${l.uriTemplate} · ${B}`,reference:{type:"resource",uri:l.uriTemplate},argument:B})));return[...t,...i]},[a]),T=re.find(t=>t.key===N)??re[0];r.useEffect(()=>{if(!n||!E.some(i=>i.oauthStatus==="authorizing"||i.status==="connecting"||i.status==="reconnecting"))return;const t=window.setInterval(()=>{W()},1e3);return()=>window.clearInterval(t)},[n,W,E]),r.useEffect(()=>{j&&E.some(t=>t.name===j.serverName&&(t.oauthStatus==="authenticated"||t.oauthStatus==="disabled"||t.oauthStatus==="unavailable"))&&C(null)},[j,E]),r.useEffect(()=>{!n||o!=="installed"||!a||ne(a.name).catch(()=>{})},[n,ne,a,o]);const fe=async(t,i)=>{F({type:t,name:i}),g(null);try{const l=t==="delete"?"":`/${t}`;await L(`/mcp/${encodeURIComponent(i)}${l}`,{method:t==="delete"?"DELETE":"POST"}),await W(),t==="delete"&&(q(null),p(null))}catch(l){g(l instanceof Error?l.message:`Failed to ${t} server`)}finally{F(null)}},pe=async(t,i)=>{F({type:t,name:i.name}),g(null);try{if(t==="login"){const l=await L(`/mcp/${encodeURIComponent(i.name)}/oauth/login`,{method:"POST"});C({serverName:i.name,url:l.authorizationUrl})}else await L(`/mcp/${encodeURIComponent(i.name)}/oauth/logout`,{method:"POST"}),C(null);await W()}catch(l){g(l instanceof Error?l.message:`Failed to ${t} MCP OAuth`)}finally{F(null)}},Ge=async(t,i)=>{O(i),g(null);try{await L(`/mcp/${encodeURIComponent(t.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:i})}),await W(),ne(t.name).catch(()=>{})}catch(l){g(l instanceof Error?l.message:"Failed to set MCP logging level")}finally{O(null)}},We=async t=>{if(T){I(!0),J(null),_(null);try{const i=await L(`/mcp/${encodeURIComponent(t.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:T.reference,argument:{name:T.argument,value:R}})});_(i)}catch(i){J(i instanceof Error?i.message:"MCP completion failed")}finally{I(!1)}}},Ve=r.useMemo(()=>new Set(E.map(t=>t.name.toLowerCase())),[E]),Ye=t=>{m(t)},Ke=t=>t.startsWith("@modelcontextprotocol/"),Qe=t=>Ke(t.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx(he,{open:n,onOpenChange:s,children:e.jsxs(be,{onCloseAutoFocus:nt,className:"flex h-[min(680px,calc(100dvh-24px))] flex-col gap-0 overflow-hidden rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[900px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ge,{className:"sr-only",children:"MCP"}),e.jsx("div",{className:"flex flex-1 min-h-0",children:e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{onClick:ke,"aria-label":"Refresh MCP servers",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:y,children:e.jsx(Be,{className:w("h-4 w-4",y&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>x(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),"Add server"]}),e.jsx("button",{onClick:s,"aria-label":"Close MCP",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ve,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsxs(Ie,{active:o==="installed",onClick:()=>u("installed"),children:["Installed (",E.length,")"]}),e.jsx(Ie,{active:o==="catalog",onClick:()=>{u("catalog"),A||Ne()},children:"Catalog"})]}),S&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(De,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:S}),e.jsx("button",{type:"button",onClick:()=>g(null),className:"underline shrink-0",children:"Dismiss"})]}),o==="installed"?e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Servers"}),e.jsx("input",{type:"search","aria-label":"Search installed MCP servers",value:h,onChange:t=>b(t.target.value),placeholder:"Search servers...",className:"h-8 shrink-0 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[12px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[y&&E.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(le,{className:"w-4 h-4 animate-spin"}),"Loading servers..."]}),ee&&!y&&e.jsxs("div",{role:"alert",className:"flex flex-col gap-2 items-center py-6 font-mono text-xs text-center text-red-600 dark:text-red-400",children:[e.jsx("span",{children:ee.message}),e.jsx("button",{type:"button",onClick:ke,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!ee&&!y&&te.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:h?"No servers match your search":"No MCP servers configured"}),te.map(t=>e.jsxs("button",{onClick:()=>{p(t.id),q(null),g(null),z(null),U(""),_(null),J(null)},className:w("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",t.id===(a==null?void 0:a.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:w("text-[11px] font-mono font-semibold",Le[t.status]),children:Re(t)})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.endpoint})]},t.id))]})]}),a?e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsx("span",{className:w("text-xs font-mono font-semibold",Le[a.status]),children:Re(a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:a.description}),a.error&&e.jsxs("p",{className:"text-[12px] font-mono text-[#ef4444]",children:["Error: ",a.error]}),a.instructions&&e.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Server instructions"}),e.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",a.instructions.sha256]})]}),e.jsx("pre",{className:"mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:a.instructions.text??"[details omitted by runtime policy]"}),(a.instructions.truncated||a.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:a.instructions.detailsOmitted?"Details omitted":"Truncated to the safe display budget"})]}),a.tasks&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Experimental MCP Tasks"}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a.tasks.enabled?`${a.tasks.maxTasksPerSession} per Session · ${a.tasks.pollIntervalMs}ms poll`:"Disabled by default"})]}),e.jsx("span",{className:w("text-[10px] font-mono font-semibold uppercase",a.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:a.tasks.enabled?"Enabled":"Disabled"})]}),a.oauthEnabled&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),e.jsx("span",{role:a.oauthStatus==="authorizing"?"status":void 0,className:w("text-[11px] font-mono",a.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":a.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:gt[a.oauthStatus]})]}),a.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void pe("logout",a),disabled:d!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:(d==null?void 0:d.type)==="logout"?"Signing out...":"Sign out"}):a.oauthStatus==="authorizing"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(j==null?void 0:j.serverName)===a.name?e.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white dark:bg-[#3b82f6]",children:"Continue authorization"}):e.jsx("button",{type:"button",onClick:()=>void pe("login",a),disabled:d!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:"Resume authorization"})]}):a.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void pe("login",a),disabled:d!==null,className:"h-7 rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:(d==null?void 0:d.type)==="login"?"Opening...":"Authorize"})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[a.status==="connected"||a.status==="reconnecting"?e.jsx("button",{onClick:()=>void fe("disconnect",a.name),disabled:d!==null,className:"h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:(d==null?void 0:d.type)==="disconnect"&&d.name===a.name?"Disconnecting...":a.status==="reconnecting"?"Stop recovery":"Disconnect"}):e.jsx("button",{onClick:()=>void fe("connect",a.name),disabled:d!==null||a.oauthEnabled&&a.oauthStatus!=="authenticated",className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:(d==null?void 0:d.type)==="connect"&&d.name===a.name?"Connecting...":a.oauthEnabled&&a.oauthStatus!=="authenticated"?"Authorize first":"Connect"}),e.jsx("button",{onClick:()=>q(a.name),disabled:d!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:"Delete"})]}),K===a.name&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete ${a.name}`,className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:"Remove this server and its saved configuration?"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>q(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void fe("delete",a.name),disabled:d!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(d==null?void 0:d.type)==="delete"?"Deleting...":"Delete server"})]})]}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Tools (",a.tools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No tools available"}):a.tools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Argument completion"}),a.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Connect the server to request suggestions"}):a.completionSupported?re.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No completable prompt arguments or template variables"}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{"aria-label":"MCP completion target",className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:re.map(t=>e.jsx("button",{type:"button","aria-pressed":(T==null?void 0:T.key)===t.key,onClick:()=>{z(t.key),_(null),J(null)},className:w("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(T==null?void 0:T.key)===t.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:t.label},t.key))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text","aria-label":"MCP completion partial value",value:R,onChange:t=>U(t.target.value),placeholder:"Partial value",className:"h-8 min-w-0 flex-1 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[11px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsx("button",{type:"button",onClick:()=>void We(a),disabled:H,className:"h-8 shrink-0 rounded-md bg-[#2563eb] px-3 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:H?"Completing...":"Complete"})]}),Y&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:Y}),D&&e.jsxs("div",{"aria-label":"MCP completion suggestions",className:"rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:D.values.length>0?D.values.map(t=>e.jsx("span",{className:"rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]",children:t||"[empty]"},t)):e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF]",children:"No suggestions"})}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",D.sha256,D.truncated?" · truncated":""]})]})]}):e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Server does not advertise MCP completions"}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Diagnostics"}),e.jsx("button",{type:"button","aria-label":`Refresh ${a.name} MCP logs`,onClick:()=>void ne(a.name),disabled:ue,className:"flex h-7 w-7 items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:text-[#71717a] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Be,{className:w("h-3.5 w-3.5",ue&&"animate-spin")})})]}),e.jsx("div",{"aria-label":"MCP logging level",className:"flex flex-wrap gap-1",children:vt.map(t=>{var i,l;return e.jsx("button",{type:"button",onClick:()=>void Ge(a,t),disabled:a.status!=="connected"||M!==null,"aria-pressed":(((i=a.logging)==null?void 0:i.level)??"warning")===t,className:w("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((l=a.logging)==null?void 0:l.level)??"warning")===t?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] hover:text-[#111827] dark:bg-[#18181b] dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5]"),children:M===t?"Setting...":t},t)})}),Ee?e.jsx("div",{role:"alert",className:"rounded-md bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:bg-red-950/30 dark:text-red-300",children:Ee.message}):ae!=null&&ae.entries.length?e.jsx("div",{"aria-label":`${a.name} MCP logs`,className:"flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:ae.entries.map(t=>e.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:w("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(t.level)?"text-red-600 dark:text-red-400":t.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:t.level}),e.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[t.logger||a.name," · r",t.revision]})]}),e.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:t.message}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",t.dataSha256,t.truncated?" · truncated":"",t.detailsOmitted?" · details omitted":""]})]},t.revision))}):e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:ue?"Loading logs...":"No logs captured"})]}):e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a server to view details"})})]}):e.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[e.jsx("div",{className:"flex gap-3 items-center shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(ot,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text","aria-label":"Search MCP server catalog",value:ce,onChange:t=>{Q(t.target.value),k(t.target.value)},placeholder:"Search MCP servers on npm (min 3 chars)...",className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:v,className:"overflow-y-auto flex-1 min-h-0",children:[je?e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[e.jsx(De,{className:"w-6 h-6 text-red-500"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:je.message}),e.jsx("button",{type:"button",onClick:Ne,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:"Retry catalog"})]}):He&&!A?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(le,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[A==null?void 0:A.list.map(t=>{var we,Ae;const i=Ve.has(Ue(t.name).toLowerCase()),l=me===t.name,B=Qe(t);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name}),e.jsx("span",{className:w("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",B==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:B})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:t.description||"No description"}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",t.version]}),((we=t.publisher)==null?void 0:we.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["by ",t.publisher.username]})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 mt-auto",children:[e.jsxs("a",{href:((Ae=t.links)==null?void 0:Ae.npm)||`https://www.npmjs.com/package/${t.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1",children:[e.jsx(Te,{className:"w-3 h-3"}),"npm"]}),i?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(lt,{className:"w-3 h-3"}),"Installed"]}):e.jsxs("button",{onClick:()=>Ye(t),disabled:l,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(dt,{className:w("h-3 w-3",l&&"animate-pulse")}),l?"Installing...":"Install"]})]})]},t.name)}),(A==null?void 0:A.list.length)===0&&e.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No packages found"})]}),Je&&e.jsx("div",{className:"flex justify-center items-center py-4",children:e.jsx(le,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),qe&&A&&A.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No more packages"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[(A==null?void 0:A.total)??0," packages found"]}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:["Browse more on Glama",e.jsx(Te,{className:"w-3 h-3"})]})]})]})]})})]})}),e.jsx(yt,{open:f,onOpenChange:x,onAdd:Ce,saving:ye,error:(V==null?void 0:V.message)??null}),G&&e.jsx(wt,{pkg:G,onClose:()=>m(null),installing:ye,error:(V==null?void 0:V.message)??null,onInstall:t=>(X(G.name),Ce(t))})]})}function Ie({active:n,children:s,onClick:o}){return e.jsx("button",{onClick:o,className:w("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",n?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:s})}function yt({open:n,onOpenChange:s,onAdd:o,saving:u,error:f}){const[x,c]=r.useState("form"),[p,h]=r.useState(""),[b,S]=r.useState(""),[g,j]=r.useState(""),[C,d]=r.useState(null),[F,M]=r.useState(`{
1
+ import{r,j as e}from"./vendor-react-DG5dkZ_t.js";import{_ as $,n as P,o as Se,p as Fe,q as se}from"./vendor-radix-DBy9B2DN.js";import{i as Ze,a as Xe,d as Me,u as $e,b as ze,c as et,e as de,f as oe,g as tt}from"./useRequest-BvqVDnKl.js";import{b as at,D as he,e as be,G as nt,g as ge,j as w,x as L,y as rt}from"./index-BF5HEN_f.js";import{a as Be,i as st,X as ve,f as De,L as le,k as ot,Z as Te,C as lt,D as dt}from"./vendor-icons-D_AkWmWB.js";function ie(n,s){if(Ze){if(!n)return s;var o;return Xe(n)?o=n():"current"in n?o=n.current:o=n,o}}var it=function(n){var s=function(o,u,f){var x=r.useRef(!1),c=r.useRef([]),p=r.useRef([]),h=r.useRef(void 0);n(function(){var b,S=Array.isArray(f)?f:[f],g=S.map(function(j){return ie(j)});if(!x.current){x.current=!0,c.current=g,p.current=u,h.current=o();return}(g.length!==c.current.length||!Me(c.current,g)||!Me(p.current,u))&&((b=h.current)===null||b===void 0||b.call(h),c.current=g,p.current=u,h.current=o())}),$e(function(){var b;(b=h.current)===null||b===void 0||b.call(h),x.current=!1})};return s},ct=it(r.useEffect);function xt(){var n=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,s=typeof self=="object"&&self&&self.Object===Object&&self;return n||s}xt()||(global.Date=Date);function mt(n,s){var o,u=ze(n),f=(o=s==null?void 0:s.wait)!==null&&o!==void 0?o:1e3,x=r.useMemo(function(){return et(function(){for(var c=[],p=0;p<arguments.length;p++)c[p]=arguments[p];return u.current.apply(u,$([],P(c),!1))},f,s)},[]);return $e(function(){x.cancel()}),{run:x,cancel:x.cancel,flush:x.flush}}function ut(n,s,o){o===void 0&&(o={});var u=o.enable,f=u===void 0?!0:u,x=ze(s);ct(function(){if(f){var c=ie(o.target,window);if(c!=null&&c.addEventListener){var p=function(b){return x.current(b)},h=Array.isArray(n)?n:[n];return h.forEach(function(b){c.addEventListener(b,p,{capture:o.capture,once:o.once,passive:o.passive})}),function(){h.forEach(function(b){c.removeEventListener(b,p,{capture:o.capture})})}}}},[n,o.capture,o.once,o.passive,f],o.target)}var ft=function(n){return n===document||n===document.documentElement||n===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):n.scrollTop},Pe=function(n){return n.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},pt=function(n){return n.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},ht=function(n,s){s===void 0&&(s={});var o=s.target,u=s.isNoMore,f=s.threshold,x=f===void 0?100:f,c=s.direction,p=c===void 0?"bottom":c,h=s.reloadDeps,b=h===void 0?[]:h,S=s.manual,g=s.onBefore,j=s.onSuccess,C=s.onError,d=s.onFinally,F=P(r.useState(),2),M=F[0],O=F[1],N=P(r.useState(!1),2),z=N[0],R=N[1],U=p==="top",D=r.useRef(void 0),_=r.useRef(0),H=r.useMemo(function(){return u?u(M):!1},[M]),I=de(function(m){return Se(void 0,void 0,void 0,function(){var v;return Fe(this,function(k){switch(k.label){case 0:return[4,n(m)];case 1:return v=k.sent(),[2,{currentData:v,lastData:m}]}})})},{manual:S,onFinally:function(m,v,k){R(!1),d==null||d(v==null?void 0:v.currentData,k)},onBefore:function(){return g==null?void 0:g()},onSuccess:function(m){var v,k,E;m.lastData?O(se(se({},m.currentData),{list:U?$($([],P(m.currentData.list),!1),P((k=m.lastData.list)!==null&&k!==void 0?k:[]),!1):$($([],P((E=m.lastData.list)!==null&&E!==void 0?E:[]),!1),P(m.currentData.list),!1)})):O(se(se({},m.currentData),{list:$([],P((v=m.currentData.list)!==null&&v!==void 0?v:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(U){var y=ie(o);if(y=y===document?document.documentElement:y,y){var ee=Pe(y);y.scrollTo(0,ee-_.current)}}else G()})}),j==null||j(m.currentData)},onError:function(m){return C==null?void 0:C(m)}}),Y=I.loading,J=I.error,K=I.run,q=I.runAsync,ce=I.cancel,Q=oe(function(){H||(R(!0),K(M))}),Z=function(m){return Se(void 0,void 0,void 0,function(){var v;return Fe(this,function(k){switch(k.label){case 0:return[4,q(m)];case 1:return v=k.sent(),[2,v.currentData]}})})},xe=oe(function(){return H?Promise.reject():(R(!0),Z(M))}),me=function(){return R(!1),K()},X=function(){return R(!1),Z()},G=function(){var m=ie(o);if(m){var v=m===document?document.documentElement:m,k=ft(v),E=Pe(v),y=pt(v);U?(D.current!==void 0&&D.current>k&&k<=x&&Q(),D.current=k,_.current=E-k):E-k<=y+x&&Q()}};return ut("scroll",function(){Y||z||G()},{target:o}),tt(function(){K()},$([],P(b),!1)),{data:M,loading:!z&&Y,error:J,loadingMore:z,noMore:H,loadMore:Q,loadMoreAsync:xe,reload:oe(me),reloadAsync:oe(X),mutate:O,cancel:ce}};const Le={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},bt={connected:"Connected",connecting:"Connecting...",reconnecting:"Recovering...",offline:"Offline",error:"Error"},gt={disabled:"Not configured",unavailable:"Unavailable in this runtime",unauthenticated:"Authorization required",authorizing:"Waiting for authorization...",authenticated:"Authorized",error:"Authorization failed"},Oe=20,vt=["debug","info","notice","warning","error","critical","alert","emergency"],Re=n=>n.status!=="reconnecting"||!n.recovery?bt[n.status]:`Recovering ${n.recovery.attempt}/${n.recovery.maxAttempts}`,kt=async()=>L("/mcp"),Et=async n=>L(`/mcp/${encodeURIComponent(n)}/logs?limit=20`),jt="mcp server @modelcontextprotocol",Nt=3,Ue=n=>{var s;return((s=n.split("/").pop())==null?void 0:s.replace(/^server-/,""))||n},Ct=async(n,s)=>{const o=n&&n.length>=Nt?n:jt,u=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(o)}&size=${Oe}&from=${s}`,f=await L(u);return{list:f.objects.map(x=>x.package),total:f.total,hasMore:s+Oe<f.total}};function Dt(){const{isMcpOpen:n,toggleMcp:s}=at(),[o,u]=r.useState("installed"),[f,x]=r.useState(!1),[c,p]=r.useState(null),[h,b]=r.useState(""),[S,g]=r.useState(null),[j,C]=r.useState(null),[d,F]=r.useState(null),[M,O]=r.useState(null),[N,z]=r.useState(null),[R,U]=r.useState(""),[D,_]=r.useState(null),[H,I]=r.useState(!1),[Y,J]=r.useState(null),[K,q]=r.useState(null),[ce,Q]=r.useState(""),[Z,xe]=r.useState(""),[me,X]=r.useState(null),[G,m]=r.useState(null),v=r.useRef(null),{run:k}=mt(t=>{xe(t)},{wait:500}),{data:E=[],loading:y,error:ee,run:ke,runAsync:W}=de(kt,{refreshDeps:[n],ready:n,onSuccess:t=>{t.length>0&&!c&&p(t[0].id)}}),{data:ae,loading:ue,error:Ee,runAsync:ne}=de(Et,{manual:!0}),{data:A,loading:He,loadingMore:Je,noMore:qe,error:je,reload:Ne}=ht(async t=>{var l;const i=((l=t==null?void 0:t.list)==null?void 0:l.length)??0;return Ct(Z,i)},{target:v,isNoMore:t=>!(t!=null&&t.hasMore),reloadDeps:[Z],manual:!n||o!=="catalog"}),{runAsync:Ce,loading:ye,error:V}=de(async t=>{await L("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,config:t})})},{manual:!0,onSuccess:()=>{W(),x(!1),m(null),X(null)},onError:()=>{X(null)}}),te=r.useMemo(()=>{const t=h.trim().toLowerCase();return t?E.filter(i=>[i.name,i.endpoint,i.description].some(l=>l.toLowerCase().includes(t))):E},[h,E]),a=r.useMemo(()=>te.find(t=>t.id===c)??te[0],[te,c]),re=r.useMemo(()=>{if(!a)return[];const t=(a.prompts??[]).flatMap(l=>l.arguments.map(B=>({key:`prompt:${l.name}:${B.name}`,label:`${l.name}.${B.name}`,reference:{type:"prompt",name:l.name},argument:B.name}))),i=(a.resourceTemplates??[]).flatMap(l=>(l.variables??[]).map(B=>({key:`resource:${l.uriTemplate}:${B}`,label:`${l.uriTemplate} · ${B}`,reference:{type:"resource",uri:l.uriTemplate},argument:B})));return[...t,...i]},[a]),T=re.find(t=>t.key===N)??re[0];r.useEffect(()=>{if(!n||!E.some(i=>i.oauthStatus==="authorizing"||i.status==="connecting"||i.status==="reconnecting"))return;const t=window.setInterval(()=>{W()},1e3);return()=>window.clearInterval(t)},[n,W,E]),r.useEffect(()=>{j&&E.some(t=>t.name===j.serverName&&(t.oauthStatus==="authenticated"||t.oauthStatus==="disabled"||t.oauthStatus==="unavailable"))&&C(null)},[j,E]),r.useEffect(()=>{!n||o!=="installed"||!a||ne(a.name).catch(()=>{})},[n,ne,a,o]);const fe=async(t,i)=>{F({type:t,name:i}),g(null);try{const l=t==="delete"?"":`/${t}`;await L(`/mcp/${encodeURIComponent(i)}${l}`,{method:t==="delete"?"DELETE":"POST"}),await W(),t==="delete"&&(q(null),p(null))}catch(l){g(l instanceof Error?l.message:`Failed to ${t} server`)}finally{F(null)}},pe=async(t,i)=>{F({type:t,name:i.name}),g(null);try{if(t==="login"){const l=await L(`/mcp/${encodeURIComponent(i.name)}/oauth/login`,{method:"POST"});C({serverName:i.name,url:l.authorizationUrl})}else await L(`/mcp/${encodeURIComponent(i.name)}/oauth/logout`,{method:"POST"}),C(null);await W()}catch(l){g(l instanceof Error?l.message:`Failed to ${t} MCP OAuth`)}finally{F(null)}},Ge=async(t,i)=>{O(i),g(null);try{await L(`/mcp/${encodeURIComponent(t.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:i})}),await W(),ne(t.name).catch(()=>{})}catch(l){g(l instanceof Error?l.message:"Failed to set MCP logging level")}finally{O(null)}},We=async t=>{if(T){I(!0),J(null),_(null);try{const i=await L(`/mcp/${encodeURIComponent(t.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:T.reference,argument:{name:T.argument,value:R}})});_(i)}catch(i){J(i instanceof Error?i.message:"MCP completion failed")}finally{I(!1)}}},Ve=r.useMemo(()=>new Set(E.map(t=>t.name.toLowerCase())),[E]),Ye=t=>{m(t)},Ke=t=>t.startsWith("@modelcontextprotocol/"),Qe=t=>Ke(t.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx(he,{open:n,onOpenChange:s,children:e.jsxs(be,{onCloseAutoFocus:nt,className:"flex h-[min(680px,calc(100dvh-24px))] flex-col gap-0 overflow-hidden rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[900px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ge,{className:"sr-only",children:"MCP"}),e.jsx("div",{className:"flex flex-1 min-h-0",children:e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{onClick:ke,"aria-label":"Refresh MCP servers",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:y,children:e.jsx(Be,{className:w("h-4 w-4",y&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>x(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),"Add server"]}),e.jsx("button",{onClick:s,"aria-label":"Close MCP",className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(ve,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsxs(Ie,{active:o==="installed",onClick:()=>u("installed"),children:["Installed (",E.length,")"]}),e.jsx(Ie,{active:o==="catalog",onClick:()=>{u("catalog"),A||Ne()},children:"Catalog"})]}),S&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(De,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:S}),e.jsx("button",{type:"button",onClick:()=>g(null),className:"underline shrink-0",children:"Dismiss"})]}),o==="installed"?e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Servers"}),e.jsx("input",{type:"search","aria-label":"Search installed MCP servers",value:h,onChange:t=>b(t.target.value),placeholder:"Search servers...",className:"h-8 shrink-0 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[12px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[y&&E.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(le,{className:"w-4 h-4 animate-spin"}),"Loading servers..."]}),ee&&!y&&e.jsxs("div",{role:"alert",className:"flex flex-col gap-2 items-center py-6 font-mono text-xs text-center text-red-600 dark:text-red-400",children:[e.jsx("span",{children:ee.message}),e.jsx("button",{type:"button",onClick:ke,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!ee&&!y&&te.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:h?"No servers match your search":"No MCP servers configured"}),te.map(t=>e.jsxs("button",{onClick:()=>{p(t.id),q(null),g(null),z(null),U(""),_(null),J(null)},className:w("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",t.id===(a==null?void 0:a.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:w("text-[11px] font-mono font-semibold",Le[t.status]),children:Re(t)})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.endpoint})]},t.id))]})]}),a?e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsx("span",{className:w("text-xs font-mono font-semibold",Le[a.status]),children:Re(a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:a.description}),a.error&&e.jsxs("p",{className:"text-[12px] font-mono text-[#ef4444]",children:["Error: ",a.error]}),a.instructions&&e.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Server instructions"}),e.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",a.instructions.sha256]})]}),e.jsx("pre",{className:"mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:a.instructions.text??"[details omitted by runtime policy]"}),(a.instructions.truncated||a.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:a.instructions.detailsOmitted?"Details omitted":"Truncated to the safe display budget"})]}),a.tasks&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Experimental MCP Tasks"}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a.tasks.enabled?`${a.tasks.maxTasksPerSession} per Session · ${a.tasks.pollIntervalMs}ms poll`:"Disabled by default"})]}),e.jsx("span",{className:w("text-[10px] font-mono font-semibold uppercase",a.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:a.tasks.enabled?"Enabled":"Disabled"})]}),a.oauthEnabled&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),e.jsx("span",{role:a.oauthStatus==="authorizing"?"status":void 0,className:w("text-[11px] font-mono",a.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":a.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:gt[a.oauthStatus]})]}),a.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void pe("logout",a),disabled:d!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:(d==null?void 0:d.type)==="logout"?"Signing out...":"Sign out"}):a.oauthStatus==="authorizing"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(j==null?void 0:j.serverName)===a.name?e.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white dark:bg-[#3b82f6]",children:"Continue authorization"}):e.jsx("button",{type:"button",onClick:()=>void pe("login",a),disabled:d!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:"Resume authorization"})]}):a.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void pe("login",a),disabled:d!==null,className:"h-7 rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:(d==null?void 0:d.type)==="login"?"Opening...":"Authorize"})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[a.status==="connected"||a.status==="reconnecting"?e.jsx("button",{onClick:()=>void fe("disconnect",a.name),disabled:d!==null,className:"h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:(d==null?void 0:d.type)==="disconnect"&&d.name===a.name?"Disconnecting...":a.status==="reconnecting"?"Stop recovery":"Disconnect"}):e.jsx("button",{onClick:()=>void fe("connect",a.name),disabled:d!==null||a.oauthEnabled&&a.oauthStatus!=="authenticated",className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:(d==null?void 0:d.type)==="connect"&&d.name===a.name?"Connecting...":a.oauthEnabled&&a.oauthStatus!=="authenticated"?"Authorize first":"Connect"}),e.jsx("button",{onClick:()=>q(a.name),disabled:d!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:"Delete"})]}),K===a.name&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete ${a.name}`,className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:"Remove this server and its saved configuration?"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>q(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void fe("delete",a.name),disabled:d!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(d==null?void 0:d.type)==="delete"?"Deleting...":"Delete server"})]})]}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Tools (",a.tools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No tools available"}):a.tools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Argument completion"}),a.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Connect the server to request suggestions"}):a.completionSupported?re.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No completable prompt arguments or template variables"}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{"aria-label":"MCP completion target",className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:re.map(t=>e.jsx("button",{type:"button","aria-pressed":(T==null?void 0:T.key)===t.key,onClick:()=>{z(t.key),_(null),J(null)},className:w("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(T==null?void 0:T.key)===t.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:t.label},t.key))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text","aria-label":"MCP completion partial value",value:R,onChange:t=>U(t.target.value),placeholder:"Partial value",className:"h-8 min-w-0 flex-1 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[11px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsx("button",{type:"button",onClick:()=>void We(a),disabled:H,className:"h-8 shrink-0 rounded-md bg-[#2563eb] px-3 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:H?"Completing...":"Complete"})]}),Y&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:Y}),D&&e.jsxs("div",{"aria-label":"MCP completion suggestions",className:"rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:D.values.length>0?D.values.map(t=>e.jsx("span",{className:"rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]",children:t||"[empty]"},t)):e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF]",children:"No suggestions"})}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",D.sha256,D.truncated?" · truncated":""]})]})]}):e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Server does not advertise MCP completions"}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Diagnostics"}),e.jsx("button",{type:"button","aria-label":`Refresh ${a.name} MCP logs`,onClick:()=>void ne(a.name),disabled:ue,className:"flex h-7 w-7 items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:text-[#71717a] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Be,{className:w("h-3.5 w-3.5",ue&&"animate-spin")})})]}),e.jsx("div",{"aria-label":"MCP logging level",className:"flex flex-wrap gap-1",children:vt.map(t=>{var i,l;return e.jsx("button",{type:"button",onClick:()=>void Ge(a,t),disabled:a.status!=="connected"||M!==null,"aria-pressed":(((i=a.logging)==null?void 0:i.level)??"warning")===t,className:w("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((l=a.logging)==null?void 0:l.level)??"warning")===t?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] hover:text-[#111827] dark:bg-[#18181b] dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5]"),children:M===t?"Setting...":t},t)})}),Ee?e.jsx("div",{role:"alert",className:"rounded-md bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:bg-red-950/30 dark:text-red-300",children:Ee.message}):ae!=null&&ae.entries.length?e.jsx("div",{"aria-label":`${a.name} MCP logs`,className:"flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:ae.entries.map(t=>e.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:w("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(t.level)?"text-red-600 dark:text-red-400":t.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:t.level}),e.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[t.logger||a.name," · r",t.revision]})]}),e.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:t.message}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",t.dataSha256,t.truncated?" · truncated":"",t.detailsOmitted?" · details omitted":""]})]},t.revision))}):e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:ue?"Loading logs...":"No logs captured"})]}):e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a server to view details"})})]}):e.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[e.jsx("div",{className:"flex gap-3 items-center shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(ot,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text","aria-label":"Search MCP server catalog",value:ce,onChange:t=>{Q(t.target.value),k(t.target.value)},placeholder:"Search MCP servers on npm (min 3 chars)...",className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:v,className:"overflow-y-auto flex-1 min-h-0",children:[je?e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[e.jsx(De,{className:"w-6 h-6 text-red-500"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:je.message}),e.jsx("button",{type:"button",onClick:Ne,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:"Retry catalog"})]}):He&&!A?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(le,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[A==null?void 0:A.list.map(t=>{var we,Ae;const i=Ve.has(Ue(t.name).toLowerCase()),l=me===t.name,B=Qe(t);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:t.name}),e.jsx("span",{className:w("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",B==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:B})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:t.description||"No description"}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",t.version]}),((we=t.publisher)==null?void 0:we.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["by ",t.publisher.username]})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 mt-auto",children:[e.jsxs("a",{href:((Ae=t.links)==null?void 0:Ae.npm)||`https://www.npmjs.com/package/${t.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1",children:[e.jsx(Te,{className:"w-3 h-3"}),"npm"]}),i?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(lt,{className:"w-3 h-3"}),"Installed"]}):e.jsxs("button",{onClick:()=>Ye(t),disabled:l,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(dt,{className:w("h-3 w-3",l&&"animate-pulse")}),l?"Installing...":"Install"]})]})]},t.name)}),(A==null?void 0:A.list.length)===0&&e.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No packages found"})]}),Je&&e.jsx("div",{className:"flex justify-center items-center py-4",children:e.jsx(le,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),qe&&A&&A.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No more packages"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsxs("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[(A==null?void 0:A.total)??0," packages found"]}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:["Browse more on Glama",e.jsx(Te,{className:"w-3 h-3"})]})]})]})]})})]})}),e.jsx(yt,{open:f,onOpenChange:x,onAdd:Ce,saving:ye,error:(V==null?void 0:V.message)??null}),G&&e.jsx(wt,{pkg:G,onClose:()=>m(null),installing:ye,error:(V==null?void 0:V.message)??null,onInstall:t=>(X(G.name),Ce(t))})]})}function Ie({active:n,children:s,onClick:o}){return e.jsx("button",{onClick:o,className:w("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",n?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:s})}function yt({open:n,onOpenChange:s,onAdd:o,saving:u,error:f}){const[x,c]=r.useState("form"),[p,h]=r.useState(""),[b,S]=r.useState(""),[g,j]=r.useState(""),[C,d]=r.useState(null),[F,M]=r.useState(`{
2
2
  "name": "my-server",
3
3
  "command": "npx",
4
4
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]