blade-code 0.10.2 → 0.10.3

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 (106) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-8nm1hqr1.js → chunk-0n97186m.js} +2 -2
  3. package/dist/{chunk-t8q9ks7e.js → chunk-15d49qty.js} +1 -1
  4. package/dist/chunk-1cx96gx1.js +1 -0
  5. package/dist/{chunk-8mepk4tc.js → chunk-1g5qc1qx.js} +2 -2
  6. package/dist/{chunk-d9ddpapp.js → chunk-35yktzm1.js} +1 -1
  7. package/dist/chunk-3wp3h373.js +180 -0
  8. package/dist/chunk-4ncbd4k0.js +1 -0
  9. package/dist/chunk-5fxc90rb.js +1 -0
  10. package/dist/{chunk-zkbf8n6y.js → chunk-5twefby5.js} +1 -1
  11. package/dist/{chunk-sndbq5xt.js → chunk-63ysxybd.js} +1 -1
  12. package/dist/{chunk-nah0cbnp.js → chunk-6tx8k249.js} +2 -2
  13. package/dist/{chunk-k9a1vb8a.js → chunk-7089z4e1.js} +2 -2
  14. package/dist/chunk-7443b95r.js +1 -0
  15. package/dist/chunk-79s052sw.js +2 -0
  16. package/dist/{chunk-m9zpxzg2.js → chunk-7hqbwpt5.js} +2 -2
  17. package/dist/chunk-8th744ef.js +1 -0
  18. package/dist/chunk-8thp1nep.js +1 -0
  19. package/dist/{chunk-6n5xdf2r.js → chunk-948qe2pp.js} +1 -1
  20. package/dist/{chunk-mjp61rqd.js → chunk-9ffr01c3.js} +1 -1
  21. package/dist/{chunk-gafbzeyk.js → chunk-9p5f3ryf.js} +1 -1
  22. package/dist/{chunk-e2ccyhgz.js → chunk-9yytfg19.js} +1 -1
  23. package/dist/chunk-aa0ffw17.js +1 -0
  24. package/dist/{chunk-44wkjs2j.js → chunk-an96c54z.js} +2 -2
  25. package/dist/{chunk-2beq0syt.js → chunk-bexgcc2d.js} +1 -1
  26. package/dist/{chunk-5tfzehcg.js → chunk-bfw2p0x8.js} +2 -2
  27. package/dist/{chunk-bpzv054r.js → chunk-bn148dr5.js} +2 -2
  28. package/dist/{chunk-ct32ngah.js → chunk-c05t8207.js} +8 -8
  29. package/dist/chunk-c45y8tx1.js +1484 -0
  30. package/dist/chunk-ccwskwb3.js +1 -0
  31. package/dist/chunk-da1jvzbz.js +10 -0
  32. package/dist/{chunk-af49jmns.js → chunk-dqvcgwhe.js} +2 -2
  33. package/dist/{chunk-kq5my0yy.js → chunk-drrdzmaa.js} +2 -2
  34. package/dist/{chunk-px5ck9pf.js → chunk-ea7wsges.js} +2 -2
  35. package/dist/{chunk-2km4w0ky.js → chunk-eezg6pee.js} +2 -2
  36. package/dist/{chunk-vjpd3nee.js → chunk-epj56s0n.js} +1 -1
  37. package/dist/{chunk-0h81hxkw.js → chunk-fvhc1yj8.js} +1 -1
  38. package/dist/{chunk-d3236505.js → chunk-gb54hc78.js} +1 -1
  39. package/dist/{chunk-m5tjrr5c.js → chunk-grp43mdb.js} +2 -2
  40. package/dist/{chunk-fjw32ex5.js → chunk-gxmrakrk.js} +1 -1
  41. package/dist/{chunk-a7nbn5kf.js → chunk-gxzbv67r.js} +2 -2
  42. package/dist/{chunk-k89phc5j.js → chunk-jqwntnp1.js} +2 -2
  43. package/dist/{chunk-88vy9hh0.js → chunk-jza1rsan.js} +1 -1
  44. package/dist/{chunk-0h9m2fqd.js → chunk-mgwny24b.js} +1 -1
  45. package/dist/chunk-n3y9ytvg.js +3 -0
  46. package/dist/chunk-nxj1638n.js +6 -0
  47. package/dist/chunk-p5tpzh6f.js +1 -0
  48. package/dist/{chunk-gr5mzxdf.js → chunk-pnrx3spk.js} +1 -1
  49. package/dist/{chunk-jxv6r0c7.js → chunk-qda309d9.js} +2 -2
  50. package/dist/{chunk-beqaxytd.js → chunk-qm11hjd3.js} +1 -1
  51. package/dist/chunk-r4j5ca1h.js +1 -0
  52. package/dist/{chunk-tm2ckreq.js → chunk-r4pz99sy.js} +20 -20
  53. package/dist/{chunk-rkzds6k8.js → chunk-rcdynprn.js} +2 -2
  54. package/dist/{chunk-y0hwzmdn.js → chunk-s95rgkd8.js} +1 -1
  55. package/dist/chunk-t8x2qpe2.js +1 -0
  56. package/dist/{chunk-4vaywb2r.js → chunk-tq52pbde.js} +1 -1
  57. package/dist/{chunk-vvy506b3.js → chunk-v93hcxe7.js} +1 -1
  58. package/dist/chunk-vmg5n0zv.js +1 -0
  59. package/dist/{chunk-6sc78810.js → chunk-vwq9s5nj.js} +3 -3
  60. package/dist/{chunk-ws3gc024.js → chunk-wje6bck2.js} +1 -1
  61. package/dist/{chunk-qhf0knnx.js → chunk-xdbg7cn3.js} +1 -1
  62. package/dist/{chunk-th7sxjtk.js → chunk-ydtcvxsm.js} +1 -1
  63. package/dist/{chunk-wvj9h7mb.js → chunk-ygx03mdh.js} +1 -1
  64. package/dist/{chunk-6hj2dk75.js → chunk-z906d5tb.js} +2 -2
  65. package/dist/chunk-zq9r0jx3.js +1 -0
  66. package/dist/chunk-zyz82mcd.js +1 -0
  67. package/dist/web/assets/{ChatView-CnwNosSG.js → ChatView-Pqa25Vua.js} +5 -5
  68. package/dist/web/assets/{CodeBlockHighlighter-CBo_AxjZ.js → CodeBlockHighlighter-Dxt-FWJk.js} +1 -1
  69. package/dist/web/assets/{FilePreview-hNo6RCNY.js → FilePreview-Dj2yppPn.js} +2 -2
  70. package/dist/web/assets/{MarkdownRenderer-BON4fqSr.js → MarkdownRenderer-BI2xpTV2.js} +12 -12
  71. package/dist/web/assets/McpModal-COw0BcHJ.js +5 -0
  72. package/dist/web/assets/SettingsModal-h4AxN730.js +1 -0
  73. package/dist/web/assets/SkillsModal-CTZTu9xg.js +1 -0
  74. package/dist/web/assets/{TaskSwitcher-Ds8CBVtp.js → TaskSwitcher-DPXkV-qb.js} +1 -1
  75. package/dist/web/assets/{TerminalPanel-Dm4bu6ib.js → TerminalPanel-tpUxwaCh.js} +1 -1
  76. package/dist/web/assets/index-Dep3eEsS.css +1 -0
  77. package/dist/web/assets/index-bjyn3NHs.js +32 -0
  78. package/dist/web/assets/useRequest-BvqVDnKl.js +1 -0
  79. package/dist/web/assets/{vendor-icons-CsBKlDXT.js → vendor-icons-D_AkWmWB.js} +70 -60
  80. package/dist/web/assets/{vendor-radix-DXRuAJHH.js → vendor-radix-DBy9B2DN.js} +1 -1
  81. package/dist/web/index.html +4 -4
  82. package/package.json +1 -1
  83. package/dist/chunk-1wyfb6s7.js +0 -1
  84. package/dist/chunk-3vyjshqp.js +0 -1
  85. package/dist/chunk-6g21dh3n.js +0 -1
  86. package/dist/chunk-asbp4cv4.js +0 -1
  87. package/dist/chunk-bqk3wqts.js +0 -1
  88. package/dist/chunk-cjdnfyy0.js +0 -1485
  89. package/dist/chunk-d8zj7c0t.js +0 -6
  90. package/dist/chunk-jv4nkkb5.js +0 -1
  91. package/dist/chunk-m3tx1k0s.js +0 -1
  92. package/dist/chunk-m78ceafk.js +0 -1
  93. package/dist/chunk-nqq4sbmv.js +0 -1
  94. package/dist/chunk-p7ppnewt.js +0 -3
  95. package/dist/chunk-qev36qrb.js +0 -2
  96. package/dist/chunk-tckfyfsx.js +0 -1
  97. package/dist/chunk-xhpezpjq.js +0 -10
  98. package/dist/chunk-y5vq7gek.js +0 -174
  99. package/dist/chunk-ydqeg4p8.js +0 -1
  100. package/dist/chunk-yknrffcs.js +0 -1
  101. package/dist/chunk-ymmtbq2b.js +0 -1
  102. package/dist/chunk-z2yzyr9h.js +0 -1
  103. package/dist/web/assets/McpModal-Go_8v1Vu.js +0 -5
  104. package/dist/web/assets/SettingsModal-CRu1zGQf.js +0 -1
  105. package/dist/web/assets/index-BNsnHxlt.js +0 -32
  106. package/dist/web/assets/index-DVTiq-7u.css +0 -1
@@ -0,0 +1,5 @@
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,F as nt,g as ge,j as w,x as L,y as rt}from"./index-bjyn3NHs.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 W()})}),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()},W=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||W()},{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),[W,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:G}=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:()=>{G(),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(()=>{G()},1e3);return()=>window.clearInterval(t)},[n,G,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 G(),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 G()}catch(l){g(l instanceof Error?l.message:`Failed to ${t} MCP OAuth`)}finally{F(null)}},We=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 G(),ne(t.name).catch(()=>{})}catch(l){g(l instanceof Error?l.message:"Failed to set MCP logging level")}finally{O(null)}},Ge=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 Ge(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 We(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}),W&&e.jsx(wt,{pkg:W,onClose:()=>m(null),installing:ye,error:(V==null?void 0:V.message)??null,onInstall:t=>(X(W.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
+ "name": "my-server",
3
+ "command": "npx",
4
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
5
+ }`);r.useEffect(()=>{n&&d(null)},[n]);const O=async()=>{if(d(null),x==="json"){let N;try{N=JSON.parse(F)}catch{d("Enter valid JSON with a server name and transport.");return}await o(N).catch(()=>{})}else{if(!p||!b){d("Name and command are required.");return}await o({name:p,command:b,args:g.split(" ").filter(Boolean)}).catch(()=>{})}};return e.jsx(he,{open:n,onOpenChange:s,children:e.jsxs(be,{onCloseAutoFocus:N=>rt("[data-mcp-add-server-trigger]",N),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ge,{className:"sr-only",children:"Add MCP Server"}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Add MCP Server"}),e.jsx("button",{onClick:()=>s(!1),"aria-label":"Close add MCP server",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",children:[e.jsx(_e,{active:x==="form",onClick:()=>c("form"),children:"Form"}),e.jsx(_e,{active:x==="json",onClick:()=>c("json"),children:"JSON"})]}),x==="json"?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"JSON config"}),e.jsx("textarea",{"aria-label":"JSON configuration",className:"min-h-[140px] rounded-md bg-white dark:bg-[#0C0C0C] text-[#111827] dark:text-[#E5E5E5] font-mono text-[12px] p-3 border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]",value:F,onChange:N=>M(N.target.value)})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Server name"}),e.jsx("input",{"aria-label":"Server name",type:"text",value:p,onChange:N=>h(N.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Command"}),e.jsx("input",{"aria-label":"Server command",type:"text",value:b,onChange:N=>S(N.target.value),placeholder:"npx",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Arguments (space separated)"}),e.jsx("input",{"aria-label":"Server arguments",type:"text",value:g,onChange:N=>j(N.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem /tmp",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]})]}),(C||f)&&e.jsx("div",{role:"alert",className:"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:C||f}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:()=>s(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:()=>void O(),disabled:u,className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60",children:u?"Adding...":"Add Server"})]})]})]})})}function wt({pkg:n,onClose:s,onInstall:o,installing:u,error:f}){const x=Ue(n.name),[c,p]=r.useState(x),[h,b]=r.useState(`-y ${n.name}`),[S,g]=r.useState(null),j=async()=>{if(g(null),!c.trim()){g("Server name is required.");return}await o({name:c.trim(),command:"npx",args:h.split(" ").filter(Boolean)}).catch(()=>{})};return e.jsx(he,{open:!0,onOpenChange:s,children:e.jsxs(be,{className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsxs(ge,{className:"sr-only",children:["Install ",n.name]}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install MCP Server"}),e.jsx("button",{onClick:s,"aria-label":"Close MCP installation",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:"rounded-md bg-white dark:bg-[#0C0C0C] p-3",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:n.name}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1",children:n.description||"No description"})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Server name"}),e.jsx("input",{"aria-label":"Server name",type:"text",value:c,onChange:C=>p(C.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Arguments"}),e.jsx("input",{"aria-label":"Server arguments",type:"text",value:h,onChange:C=>b(C.target.value),placeholder:"-y package-name",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["Command: npx ",h]})]})]}),(S||f)&&e.jsx("div",{role:"alert",className:"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:S||f}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:s,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:()=>void j(),disabled:u,className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60",children:u?"Installing...":"Install"})]})]})]})})}function _e({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})}export{Dt as McpModal};
@@ -0,0 +1 @@
1
+ import{r as s,j as e}from"./vendor-react-DG5dkZ_t.js";import{P as ze,v as qe,j as B,w as He,S as Ge,x as P,D as fe,e as ge,y as je,g as ye,a as xe,b as be,z as _e,A as Je,K as We,E as Ye}from"./index-bjyn3NHs.js";import{y as Pe,C as Qe,X as ve,f as he,a7 as Ve,a8 as Xe,L as J,u as ke,Y as Be,a as me,N as Ze,D as Ce,T as ue,a9 as et,i as tt,aa as at,ab as st,P as Ae}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";const rt=[{id:"auto",name:"Auto",description:"Use the Blade default communication style",source:"built-in"},{id:"pragmatic",name:"Pragmatic",description:"Direct, factual, concise, and action-oriented",source:"built-in"},{id:"friendly",name:"Friendly",description:"Warm, collaborative, and task-focused",source:"built-in"},{id:"explanatory",name:"Explanatory",description:"Explain codebase-specific choices and tradeoffs",source:"built-in"}];function ne({value:n,onChange:m,options:h,placeholder:R="Select...",disabled:M=!1,className:T,"aria-label":C}){const[y,r]=s.useState(!1),[i,c]=s.useState(-1),N=s.useRef(null),A=h.find(p=>p.value===n);s.useEffect(()=>{if(y){const p=h.findIndex(o=>o.value===n);c(p>=0?p:0)}},[y,h,n]);const E=p=>{if(!M){if(!y){(p.key==="Enter"||p.key===" "||p.key==="ArrowDown")&&(p.preventDefault(),r(!0));return}switch(p.key){case"ArrowDown":p.preventDefault(),c(o=>Math.min(o+1,h.length-1));break;case"ArrowUp":p.preventDefault(),c(o=>Math.max(o-1,0));break;case"Enter":case" ":p.preventDefault(),i>=0&&i<h.length&&(m(h[i].value),r(!1));break;case"Escape":p.preventDefault(),r(!1);break}}};return s.useEffect(()=>{var o;if(!y||i<0)return;const p=(o=N.current)==null?void 0:o.children[i];p==null||p.scrollIntoView({block:"nearest"})},[i,y]),e.jsxs(ze,{open:y,onOpenChange:r,children:[e.jsx(qe,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":y,"aria-haspopup":"listbox","aria-label":C,disabled:M,onKeyDown:E,className:B("field flex items-center justify-between gap-2 text-left",!A&&"text-zinc-400 dark:text-zinc-500",M&&"cursor-not-allowed opacity-50",T),children:[e.jsx("span",{className:"truncate",children:A?A.label:R}),e.jsx(Pe,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),e.jsx(He,{align:"start",sideOffset:4,onKeyDown:E,className:"w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden",children:e.jsx(Ge,{className:"max-h-[232px]",children:e.jsx("div",{ref:N,role:"listbox",children:h.map((p,o)=>e.jsxs("button",{type:"button",role:"option","aria-selected":p.value===n,"data-value":p.value,"data-highlighted":o===i||void 0,onClick:()=>{m(p.value),r(!1)},onMouseEnter:()=>c(o),className:B("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left font-mono text-[13px] outline-none transition-colors",o===i&&"bg-zinc-100 dark:bg-zinc-800",p.value===n&&"text-zinc-900 dark:text-zinc-50 font-medium"),children:[e.jsx(Qe,{className:B("h-3.5 w-3.5 shrink-0",p.value===n?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:p.label})]},p.value))})})})]})}const lt=/^[a-z][a-z0-9._-]{0,63}$/;function nt({open:n,onOpenChange:m,onSave:h,saveError:R}){const[M,T]=s.useState([]),[C,y]=s.useState([]),[r,i]=s.useState(),[c,N]=s.useState(),[A,E]=s.useState(""),[p,o]=s.useState(""),[l,D]=s.useState(""),[x,f]=s.useState(""),[_,u]=s.useState(""),[S,w]=s.useState(""),[j,U]=s.useState(!1),[O,W]=s.useState(!1),[Z,L]=s.useState(!1),[ee,G]=s.useState(!1),[Y,$]=s.useState(null);s.useEffect(()=>{if(!n)return;let d=!0;return y([]),i(void 0),N(void 0),E(""),o(""),D(""),f(""),u(""),w(""),U(!1),$(null),W(!0),P("/providers").then(F=>{d&&T(F)}).catch(F=>{d&&$(F instanceof Error?F.message:"Failed to load providers")}).finally(()=>{d&&W(!1)}),()=>{d=!1}},[n]),s.useEffect(()=>{if(!r)return;let d=!0;return y([]),N(void 0),$(null),r.factoryWireApi||r.custom?(L(!1),()=>{d=!1}):(L(!0),P(`/providers/${r.id}/models`).then(F=>{d&&y(F)}).catch(F=>{d&&$(F instanceof Error?F.message:"Failed to load models")}).finally(()=>{d&&L(!1)}),()=>{d=!1})},[r]);const I=r==null?void 0:r.factoryWireApi,q=!!(I||r!=null&&r.custom),Q=q?x.trim():c==null?void 0:c.id,V=async()=>{if(!r||!Q||!r.configured&&!S)return;if(I){if(!lt.test(p.trim())){$('Channel ID must start with a lowercase letter and contain only lowercase letters, numbers, ".", "_" or "-"');return}let te;try{te=new URL(_.trim())}catch{$("Base URL must be an absolute HTTP(S) URL");return}if(!["http:","https:"].includes(te.protocol)){$("Base URL must be an absolute HTTP(S) URL");return}}G(!0);const d=I?p.trim():r.id,F=await h({provider:d,model:Q,displayName:A||(q?Q:(c==null?void 0:c.name)??""),apiKey:S||void 0,...I?{modelProvider:{id:d,name:l.trim()||d,baseUrl:_.trim(),wireApi:I}}:{}});G(!1),F&&m(!1)};return e.jsx(fe,{open:n,onOpenChange:m,children:e.jsxs(ge,{onCloseAutoFocus:d=>je("[data-add-model-trigger]",d),onEscapeKeyDown:d=>{d.preventDefault(),m(!1)},onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),m(!1))},className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ye,{className:"sr-only",children:"Add Model"}),e.jsxs("div",{className:"flex flex-col gap-5 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono text-base font-semibold",children:"Add Model"}),e.jsx("button",{type:"button",onClick:()=>m(!1),"aria-label":"Close add model",className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(ve,{className:"h-4 w-4"})})]}),(Y||R)&&e.jsxs("div",{role:"alert",className:"flex 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(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Y||R})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Provider",e.jsx(ne,{"aria-label":"Provider",value:(r==null?void 0:r.id)??"",disabled:O,onChange:d=>{i(M.find(F=>F.id===d)),E(""),o(""),D(""),f(""),u("")},placeholder:O?"Loading providers...":"Select provider",options:M.map(d=>({value:d.id,label:`${d.name} (${d.modelCount})${d.configured?" - configured":""}`}))})]}),q?e.jsxs(e.Fragment,{children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Channel ID",e.jsx("input",{"aria-label":"Channel ID",value:p,onChange:d=>{o(d.target.value),$(null)},placeholder:"team-gateway",autoComplete:"off",spellCheck:!1,className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:"Stable config and credential identifier."})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Channel name",e.jsx("input",{"aria-label":"Channel name",value:l,onChange:d=>D(d.target.value),placeholder:"Team Gateway",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Base URL",e.jsx("input",{"aria-label":"Base URL",value:_,onChange:d=>{u(d.target.value),$(null)},placeholder:I==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:I==="anthropic-messages"?"Uses the Anthropic Messages protocol.":"Uses the OpenAI Chat Completions protocol."})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Model ID",e.jsx("input",{"aria-label":"Model ID",value:x,onChange:d=>{f(d.target.value),$(null)},placeholder:"vendor-model-2026",className:"field"})]})]}):e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Model",e.jsx(ne,{"aria-label":"Model",value:(c==null?void 0:c.id)??"",disabled:!r||Z,onChange:d=>{const F=C.find(te=>te.id===d);N(F),F&&E(F.name)},placeholder:Z?"Loading models...":"Select model",options:C.map(d=>({value:d.id,label:`${d.name} - ${Math.round(d.contextWindow/1e3)}K${d.reasoning?" - reasoning":""}${d.input.includes("image")?" - vision":""}`}))})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Display name",e.jsx("input",{value:A,onChange:d=>E(d.target.value),placeholder:(c==null?void 0:c.name)??"Optional alias",className:"field"})]}),(r==null?void 0:r.supportsApiKey)&&!r.configured&&e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["API Key",e.jsxs("span",{className:"relative",children:[e.jsx("input",{"aria-label":"API key",type:j?"text":"password",value:S,onChange:d=>w(d.target.value),className:"field w-full pr-10",placeholder:"Stored separately in auth.json"}),e.jsx("button",{type:"button",onClick:()=>U(!j),"aria-label":j?"Hide API key":"Show API key",className:"absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded",children:j?e.jsx(Ve,{className:"h-4 w-4"}):e.jsx(Xe,{className:"h-4 w-4"})})]})]}),r&&!r.configured&&!r.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:"This provider requires OAuth or ambient credentials. Configure it externally before selecting the model."}),e.jsxs("button",{type:"button",disabled:ee||!r||!Q||I&&(!p.trim()||!_.trim())||!r.configured&&(!r.supportsApiKey||S.trim().length===0),onClick:()=>void V(),className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 font-mono text-sm font-semibold text-white disabled:opacity-50",children:[ee&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),ee?"Saving...":"Save Model"]})]})]})})}function ot(n){const[m,h]=s.useState(""),[R,M]=s.useState(""),[T,C]=s.useState(""),[y,r]=s.useState(""),[i,c]=s.useState(!1),[N,A]=s.useState(null);s.useEffect(()=>{var o,l,D,x,f;h(((o=n.model)==null?void 0:o.displayName)??""),M(((D=(l=n.model)==null?void 0:l.overrides)==null?void 0:D.baseUrl)??""),C(((f=(x=n.model)==null?void 0:x.overrides)==null?void 0:f.streamIdleTimeout)!==void 0?String(n.model.overrides.streamIdleTimeout):""),r(""),A(null)},[n.model]);const E=async()=>{if(!n.model)return;A(null);const o=T.trim()?Number(T):void 0;if(o!==void 0&&(!Number.isFinite(o)||o<1e3)){A("Stream idle timeout must be at least 1000ms");return}c(!0);try{y.trim()&&await P(`/providers/${n.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:y.trim()})});const l={...n.model.overrides};R.trim()?l.baseUrl=R.trim():delete l.baseUrl,o!==void 0?l.streamIdleTimeout=o:delete l.streamIdleTimeout,await n.onSave(n.model.id,{displayName:m||void 0,overrides:Object.keys(l).length>0?l:void 0})&&n.onOpenChange(!1)}catch(l){A(l instanceof Error?l.message:"Failed to update provider credential")}finally{c(!1)}},p=n.model?`[data-edit-model-trigger="${n.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx(fe,{open:n.open,onOpenChange:n.onOpenChange,children:e.jsxs(ge,{onCloseAutoFocus:o=>je(p,o),onEscapeKeyDown:o=>{o.preventDefault(),n.onOpenChange(!1)},onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),n.onOpenChange(!1))},className:"gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ye,{className:"sr-only",children:"Edit Model"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono font-semibold",children:"Edit Model Overrides"}),e.jsx("button",{type:"button",onClick:()=>n.onOpenChange(!1),"aria-label":"Close edit model",className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(ve,{className:"h-4 w-4"})})]}),(N||n.saveError)&&e.jsx("div",{role:"alert",className:"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:N||n.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Display name",e.jsx("input",{value:m,onChange:o=>h(o.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Replace provider API key",e.jsx("input",{type:"password",value:y,onChange:o=>r(o.target.value),placeholder:"Leave empty to keep current credential",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Base URL override",e.jsx("input",{value:R,onChange:o=>M(o.target.value),placeholder:"Leave empty to use default endpoint",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Stream idle timeout (ms)",e.jsx("input",{type:"number",min:1e3,step:1e3,value:T,onChange:o=>C(o.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void E(),disabled:i,className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 text-white disabled:opacity-60",children:[i&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),i?"Saving...":"Save"]})]})})}function it({provider:n,onOpenChange:m,onSave:h,saveError:R}){const[M,T]=s.useState(n.name),[C,y]=s.useState(n.defaultBaseUrl??""),[r,i]=s.useState(n.wireApi??"openai-completions"),[c,N]=s.useState(n.apiKeyEnv??""),[A,E]=s.useState(""),[p,o]=s.useState(null),[l,D]=s.useState(!1);s.useEffect(()=>{T(n.name),y(n.defaultBaseUrl??""),i(n.wireApi??"openai-completions"),N(n.apiKeyEnv??""),E(""),o(null)},[n]);const x=async()=>{if(!M.trim()){o("Channel name is required");return}try{const f=new URL(C.trim());if(!["http:","https:"].includes(f.protocol))throw new Error}catch{o("Base URL must be an absolute HTTP(S) URL");return}D(!0),o(null);try{await h(n.id,{name:M.trim(),baseUrl:C.trim(),wireApi:r,apiKeyEnv:c.trim()||null,...A.trim()?{apiKey:A.trim()}:{}})&&m(!1)}finally{D(!1)}};return e.jsx(fe,{open:!0,onOpenChange:m,children:e.jsxs(ge,{onCloseAutoFocus:f=>je(`[data-edit-provider-trigger="${n.id.replace(/"/g,'\\"')}"]`,f),onEscapeKeyDown:f=>{f.preventDefault(),m(!1)},onKeyDown:f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),m(!1))},className:"gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(ye,{className:"sr-only",children:"Edit Provider Channel"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-mono font-semibold",children:"Edit Provider Channel"}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-zinc-400",children:n.id})]}),e.jsx("button",{type:"button",onClick:()=>m(!1),"aria-label":"Close edit provider",className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(ve,{className:"h-4 w-4"})})]}),(p||R)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:p||R}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Channel name",e.jsx("input",{"aria-label":"Channel name",value:M,onChange:f=>T(f.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Wire API",e.jsx(ne,{"aria-label":"Wire API",value:r,onChange:f=>i(f),options:[{value:"openai-completions",label:"OpenAI Chat Completions"},{value:"anthropic-messages",label:"Anthropic Messages"}]})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Base URL",e.jsx("input",{"aria-label":"Provider Base URL",value:C,onChange:f=>{y(f.target.value),o(null)},className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["API key environment variable",e.jsx("input",{"aria-label":"API key environment variable",value:c,onChange:f=>N(f.target.value),placeholder:"Optional, for example TEAM_GATEWAY_API_KEY",autoComplete:"off",spellCheck:!1,className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Replace API key",e.jsx("input",{"aria-label":"Provider API key",type:"password",value:A,onChange:f=>E(f.target.value),placeholder:"Leave empty to keep current credential",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void x(),disabled:l,className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 text-white disabled:opacity-60",children:[l&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),l?"Saving...":"Save channel"]})]})})}const dt={disabled:"Hooks disabled",not_required:"No external hooks",untrusted:"Review required",trusted:"Trusted",modified:"Changed since approval",error:"Trust store error"};function ct(){const n=xe(u=>{var S;return(S=u.currentSessionRef)==null?void 0:S.projectPath}),m=s.useMemo(()=>n??new URLSearchParams(window.location.search).get("project")??"",[n]),[h,R]=s.useState(null),[M,T]=s.useState(""),[C,y]=s.useState(!1),[r,i]=s.useState(null),[c,N]=s.useState(null),[A,E]=s.useState(null),p=s.useRef(0),o=s.useRef(m);o.current=m;const l=M===m?h:null,D=s.useCallback(async()=>{const u=++p.current;if(!m){R(null),T(""),E(null);return}y(!0),E(null);try{const S=await P(`/hooks/trust?projectPath=${encodeURIComponent(m)}`);if(u!==p.current)return;R(S),T(m)}catch(S){if(u!==p.current)return;E(S instanceof Error?S.message:"Failed to load hook trust")}finally{u===p.current&&y(!1)}},[m]);s.useEffect(()=>(N(null),D(),()=>{p.current+=1}),[D]);const x=async u=>{if(!l)return;const S=m;i(u),E(null);try{const w=await P("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:m,action:u,...u==="trust"&&l.currentDigest?{expectedDigest:l.currentDigest}:{}})});o.current===S&&(R(w),T(S),N(null))}catch(w){o.current===S&&E(w instanceof Error?w.message:"Failed to update hook trust")}finally{i(null)}};if(!m)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project session to review its hooks."});const f=(l==null?void 0:l.state)==="trusted",_=(l==null?void 0:l.state)==="untrusted"||(l==null?void 0:l.state)==="modified";return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f?e.jsx(ke,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Be,{className:B("h-4 w-4",_?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:l?dt[l.state]:"Hook trust"}),C&&e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:m}),(l==null?void 0:l.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:l.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void D(),disabled:C||r!==null,"aria-label":"Reload hook trust",className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Reload"]}),f?e.jsx("button",{type:"button",onClick:()=>N("revoke"),disabled:r!==null,className:"h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400",children:"Revoke"}):e.jsx("button",{type:"button",onClick:()=>N("trust"),disabled:r!==null||!(l!=null&&l.currentDigest)||l.state==="error",className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:"Trust digest"})]})]}),A&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:A}),c&&l&&e.jsxs("div",{role:"alertdialog","aria-label":c==="trust"?"Trust project hooks":"Revoke project hook trust",className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-900/70 dark:bg-amber-950/30",children:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:c==="trust"?`Run these ${l.configuredHooks} hooks with your user permissions until their configuration changes?`:"Stop all configured hooks for this project until explicitly trusted again?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>N(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void x(c),disabled:r!==null,className:B("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:r?"Saving...":c==="trust"?"Trust reviewed hooks":"Revoke trust"})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((l==null?void 0:l.definitions)??[]).map((u,S)=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:u.event}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:u.type}),u.name&&e.jsx("span",{className:"text-[#71717a]",children:u.name}),u.pluginName&&e.jsxs("span",{className:"rounded bg-violet-100 px-1.5 py-0.5 text-[9px] text-violet-700 dark:bg-violet-950/50 dark:text-violet-300",children:[u.pluginName," · ",u.pluginSource]})]}),u.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:u.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:u.target})]},`${u.event}-${u.type}-${S}`)),l&&l.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:"No configured command, HTTP, or prompt hooks."})]})]})}const xt={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]};function mt(){const n=xe(a=>{var v;return(v=a.currentSessionRef)==null?void 0:v.projectPath}),m=xe(a=>a.selectedProjectPath),h=s.useMemo(()=>n??m??new URLSearchParams(window.location.search).get("project")??"",[m,n]),[R,M]=s.useState([]),[T,C]=s.useState([]),[y,r]=s.useState(xt),[i,c]=s.useState(!1),[N,A]=s.useState(""),[E,p]=s.useState(""),[o,l]=s.useState(""),[D,x]=s.useState(""),[f,_]=s.useState(!1),[u,S]=s.useState(null),[w,j]=s.useState(null),[U,O]=s.useState(""),[W,Z]=s.useState(""),[L,ee]=s.useState(!1),[G,Y]=s.useState(null),$=s.useRef(0),I=s.useRef(h);I.current=h;const q=D===h?R:[],Q=D===h?T:[],V=s.useCallback(async()=>{const a=++$.current;if(!h){M([]),x(""),j(null);return}_(!0),j(null);try{const[v,K,z]=await Promise.all([P(`/plugins?projectPath=${encodeURIComponent(h)}`),P(`/plugins/catalog?projectPath=${encodeURIComponent(h)}`),P(`/plugins/policy?projectPath=${encodeURIComponent(h)}`)]);if(a!==$.current)return;M(v),C(K),r(z.policy),c(z.environmentRequiresSha),A(z.policy.allowedGitHosts.join(", ")),p(z.policy.allowedMarketplaces.join(", ")),l(z.policy.allowedLocalRoots.join(", ")),x(h)}catch(v){if(a!==$.current)return;j(v instanceof Error?v.message:"Failed to load plugins")}finally{a===$.current&&_(!1)}},[h]);s.useEffect(()=>(V(),()=>{$.current+=1}),[V]);const d=async(a,v)=>{const K=h;S(a.name),j(null);try{await P(`/plugins/${encodeURIComponent(a.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:K,enabled:v,scope:"local"})}),I.current===K&&await V()}catch(z){I.current===K&&j(z instanceof Error?z.message:"Failed to update plugin")}finally{S(null)}},F=a=>[...new Set(a.split(",").map(v=>v.trim()).filter(Boolean))],te=async()=>{await X("policy:save",()=>P("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h,scope:"local",policy:{...y,allowedGitHosts:F(N),allowedMarketplaces:F(E),allowedLocalRoots:F(o)}})}))},X=async(a,v,K)=>{const z=h;S(a),j(null);try{await v(),I.current===z&&(K==null||K(),Y(null),await V())}catch(se){I.current===z&&j(se instanceof Error?se.message:"Plugin action failed")}finally{S(null)}},oe=async()=>{const a=U.trim();!a||!L||await X("install",()=>P("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h,source:a,trust:!0})}),()=>{O(""),ee(!1)})},ie=async a=>{const v=`update:${a.name}`;if(G!==v){Y(v);return}await X(v,()=>P(`/plugins/${encodeURIComponent(a.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h,trust:!0})}))},pe=async a=>{const v=`uninstall:${a.name}`;if(G!==v){Y(v);return}await X(v,()=>P(`/plugins/${encodeURIComponent(a.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h,confirm:!0})}))},ae=async()=>{const a=W.trim();a&&await X("marketplace:add",()=>P("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h,source:a})}),()=>Z(""))},Ne=async a=>{await X(`marketplace:refresh:${a.name}`,()=>P(`/plugins/marketplaces/${encodeURIComponent(a.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h})}))},ce=async a=>{const v=`marketplace:remove:${a.name}`;if(G!==v){Y(v);return}await X(v,()=>P(`/plugins/marketplaces/${encodeURIComponent(a.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:h,confirm:!0})}))};return h?e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(Ze,{className:"h-4 w-4"}),"Workspace plugins",f&&e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:h}),e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:"Changes apply to future sessions and persist in local project settings."})]}),e.jsxs("button",{type:"button",onClick:()=>void V(),disabled:f||u!==null,"aria-label":"Reload plugins",className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Reload"]})]}),w&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:w}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"Source policy"]}),e.jsx("button",{type:"button","aria-label":"Save plugin source policy",onClick:()=>void te(),disabled:u!==null,className:"rounded-md border border-[#D1D5DB] px-2 py-1 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:u==="policy:save"?"Saving…":"Save for project"})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-2",children:[e.jsxs("button",{type:"button",role:"switch","aria-label":"Restrict plugin sources","aria-checked":y.restrictToAllowedSources,onClick:()=>r(a=>({...a,restrictToAllowedSources:!a.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:B("h-3.5 w-6 rounded-full p-0.5",y.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:B("block h-2.5 w-2.5 rounded-full bg-white transition-transform",y.restrictToAllowedSources&&"translate-x-2.5")})}),"Restrict to allowlists"]}),e.jsxs("button",{type:"button",role:"switch","aria-label":"Require full Git commit SHA","aria-checked":y.requireGitCommitSha,disabled:i,onClick:()=>r(a=>({...a,requireGitCommitSha:!a.requireGitCommitSha})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]",children:[e.jsx("span",{className:B("h-3.5 w-6 rounded-full p-0.5",y.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:B("block h-2.5 w-2.5 rounded-full bg-white transition-transform",y.requireGitCommitSha&&"translate-x-2.5")})}),"Require full Git SHA",i?" · environment locked":""]})]}),e.jsxs("div",{className:"mt-2 grid gap-1.5 sm:grid-cols-3",children:[e.jsx("input",{"aria-label":"Allowed plugin Git hosts",value:N,onChange:a=>A(a.target.value),placeholder:"github.com, *.corp.test",className:"h-7 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[9.5px] text-[#111827] outline-none dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsx("input",{"aria-label":"Allowed plugin Marketplaces",value:E,onChange:a=>p(a.target.value),placeholder:"team-market, official",className:"h-7 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[9.5px] text-[#111827] outline-none dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsx("input",{"aria-label":"Allowed local plugin roots",value:o,onChange:a=>l(a.target.value),placeholder:"/opt/approved/plugins",className:"h-7 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[9.5px] text-[#111827] outline-none dark:border-[#3f3f46] dark:text-[#E5E5E5]"})]}),y.restrictToAllowedSources&&!N.trim()&&!E.trim()&&!o.trim()&&e.jsx("p",{className:"mt-1.5 text-[9px] text-amber-700 dark:text-amber-400",children:"Empty allowlists deny every plugin source."})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Install trusted plugin"]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{"aria-label":"Plugin source",value:U,onChange:a=>O(a.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:u!==null,className:"h-8 min-w-0 flex-1 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[10.5px] text-[#111827] outline-none focus:border-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsxs("button",{type:"button",onClick:()=>void oe(),disabled:!U.trim()||!L||u!==null,className:"inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[10.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]",children:[u==="install"?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Install"]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":L,onClick:()=>ee(a=>!a),className:"mt-2 flex items-center gap-2 text-left text-[9.5px] text-amber-700 dark:text-amber-400",children:[e.jsx("span",{className:B("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",L?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:L?"✓":""}),"I trust this source to activate Hooks, MCP servers, skills, and commands."]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[q.map(a=>{var z;const v=u===a.name,K=[a.commands?`${a.commands} commands`:"",a.skills?`${a.skills} skills`:"",a.agents?`${a.agents} agents`:"",a.hooks?`${a.hooks} hooks`:"",a.mcpServers?`${a.mcpServers} MCP`:""].filter(Boolean);return e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[#E5E7EB] px-3 py-2.5 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsxs("span",{className:"text-[9.5px] text-[#9CA3AF]",children:["v",a.version]}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:a.source})]}),e.jsx("p",{className:"mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a.description}),e.jsx("p",{className:"mt-1 text-[9.5px] text-[#9CA3AF]",children:K.join(" · ")||"No declared resources"}),a.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:["managed",a.marketplace?` · ${a.marketplace}`:"",a.revision?` · ${a.revision.slice(0,12)}`:""]}),!a.configurable&&e.jsx("p",{className:"mt-1 text-[9.5px] text-amber-600 dark:text-amber-400",children:"Invocation-scoped via --plugin-dir"}),(z=a.compatibilityIssues)==null?void 0:z.map(se=>e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:se.message},`${se.code}:${se.message}`))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("button",{type:"button",role:"switch","aria-label":a.status==="error"?`Unavailable ${a.name}`:`${a.enabled?"Disable":"Enable"} ${a.name}`,"aria-checked":a.enabled,disabled:a.status==="error"||!a.configurable||v||u!==null,onClick:()=>void d(a,!a.enabled),className:B("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",a.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:B("h-4 w-4 rounded-full bg-white transition-transform",a.enabled?"translate-x-5":"translate-x-0")})}),a.managed&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":`Update ${a.name}`,onClick:()=>void ie(a),disabled:u!==null,className:B("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",G===`update:${a.name}`?"bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-300":"text-[#6B7280] hover:bg-[#F3F4F6] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]"),children:u===`update:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):G===`update:${a.name}`?"Confirm update":"Update"}),e.jsx("button",{type:"button","aria-label":`Uninstall ${a.name}`,onClick:()=>void pe(a),disabled:u!==null,className:B("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",G===`uninstall:${a.name}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"text-[#9CA3AF] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:u===`uninstall:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):G===`uninstall:${a.name}`?"Confirm remove":e.jsx(ue,{className:"h-3 w-3"})})]})]})]},a.name)}),!f&&q.length===0&&!w&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:"No plugins discovered for this project."})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(et,{className:"h-3.5 w-3.5"}),"Marketplaces"]}),e.jsxs("span",{className:"text-[9px] text-[#9CA3AF]",children:[Q.length," configured"]})]}),e.jsxs("div",{className:"flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]",children:[e.jsx("input",{"aria-label":"Marketplace source",value:W,onChange:a=>Z(a.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:u!==null,className:"h-7 min-w-0 flex-1 rounded-md border border-[#D1D5DB] bg-transparent px-2 text-[10px] text-[#111827] outline-none focus:border-[#6B7280] dark:border-[#3f3f46] dark:text-[#E5E5E5]"}),e.jsxs("button",{type:"button","aria-label":"Add marketplace",onClick:()=>void ae(),disabled:!W.trim()||u!==null,className:"inline-flex h-7 items-center gap-1 rounded-md border border-[#D1D5DB] px-2 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[u==="marketplace:add"?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(tt,{className:"h-3 w-3"}),"Add"]})]}),Q.map(a=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[a.name,e.jsxs("span",{className:"ml-2 font-normal text-[#9CA3AF]",children:[a.sourceType," · ",a.revision.slice(0,12)]})]}),e.jsx("p",{className:"mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a.description||"No description"})]}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx("button",{type:"button","aria-label":`Refresh marketplace ${a.name}`,disabled:u!==null,onClick:()=>void Ne(a),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:u===`marketplace:refresh:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(me,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Remove marketplace ${a.name}`,disabled:u!==null,onClick:()=>void ce(a),className:B("rounded p-1 text-[#9CA3AF] disabled:opacity-40",G===`marketplace:remove:${a.name}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:G===`marketplace:remove:${a.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:"Confirm"}):e.jsx(ue,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[a.plugins.slice(0,12).map(v=>e.jsxs("button",{type:"button",disabled:v.installed||u!==null,onClick:()=>{O(`${v.name}@${a.name}`),ee(!1)},title:v.description,className:"rounded bg-[#F3F4F6] px-1.5 py-0.5 text-[8.5px] text-[#6B7280] disabled:opacity-40 dark:bg-[#27272a] dark:text-[#a1a1aa]",children:[v.name,v.installed?" · installed":""]},v.name)),a.plugins.length>12&&e.jsxs("span",{className:"px-1 py-0.5 text-[8.5px] text-[#9CA3AF]",children:["+",a.plugins.length-12]})]})]},a.name)),!f&&Q.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-[10px] text-[#9CA3AF]",children:"Add a Marketplace to discover installable plugins."})]})]}):e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project to manage its plugins."})}const ut={not_required:"No trust required",trusted:"Workspace trusted",untrusted:"Review required",error:"Trust store error"};function pt(){const n=xe(w=>{var j;return(j=w.currentSessionRef)==null?void 0:j.projectPath}),m=s.useMemo(()=>n??new URLSearchParams(window.location.search).get("project")??"",[n]),[h,R]=s.useState(null),[M,T]=s.useState(""),[C,y]=s.useState(!1),[r,i]=s.useState(null),[c,N]=s.useState(null),[A,E]=s.useState(null),[p,o]=s.useState(!1),l=s.useRef(0),D=s.useRef(m);D.current=m;const x=M===m?h:null,f=s.useCallback(async()=>{const w=++l.current;if(!m){R(null),T(""),E(null);return}y(!0),E(null);try{const j=await P(`/workspace-trust?projectPath=${encodeURIComponent(m)}`);if(w!==l.current)return;R(j),T(m)}catch(j){if(w!==l.current)return;E(j instanceof Error?j.message:"Failed to load workspace trust")}finally{w===l.current&&y(!1)}},[m]);s.useEffect(()=>(N(null),o(!1),f(),()=>{l.current+=1}),[f]);const _=async w=>{if(!x)return;const j=m;i(w),E(null);try{const U=await P("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:j,action:w})});D.current===j&&(R(U),T(j),N(null),o(U.reloadRequired===!0))}catch(U){D.current===j&&E(U instanceof Error?U.message:"Failed to update workspace trust")}finally{i(null)}};if(!m)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project session to review folder trust."});const u=(x==null?void 0:x.state)==="trusted",S=(x==null?void 0:x.state)==="untrusted";return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u?e.jsx(ke,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Be,{className:B("h-4 w-4",S?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:x?ut[x.state]:"Workspace trust"}),C&&e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:m}),x&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[x.decision,x.inheritedFrom?` · inherited from ${x.inheritedFrom}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void f(),disabled:C||r!==null,"aria-label":"Reload workspace trust",className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Reload"]}),u?e.jsx("button",{type:"button",onClick:()=>N("revoke"),disabled:r!==null,className:"h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400",children:"Revoke"}):e.jsx("button",{type:"button",onClick:()=>N("trust"),disabled:r!==null||(x==null?void 0:x.state)==="error"||!x||x.sensitiveSources===0,className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:"Trust workspace"})]})]}),(A||(x==null?void 0:x.error))&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:A||(x==null?void 0:x.error)}),p&&e.jsx("div",{role:"status",className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-[11px] text-blue-700 dark:border-blue-900/60 dark:bg-blue-950/30 dark:text-blue-300",children:"Restart Blade to reload project models, MCP, LSP, permissions, and plugins."}),c&&x&&e.jsxs("div",{role:"alertdialog","aria-label":c==="trust"?"Trust workspace":"Revoke workspace trust",className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-900/70 dark:bg-amber-950/30",children:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:c==="trust"?`Allow ${x.sensitiveSources} project source(s) to configure models, MCP, LSP, permissions, environment, instructions, commands, skills, agents, or plugins?`:"Block project-controlled executable configuration after restart?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>N(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void _(c),disabled:r!==null,className:B("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:r?"Saving...":c==="trust"?"Trust reviewed workspace":"Revoke trust"})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((x==null?void 0:x.sources)??[]).map(w=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:w.path}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:w.kind})]}),w.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:w.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:w.effects.map((j,U)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:j.kind})," · ",j.name,j.target?` → ${j.target}`:""]},`${j.kind}-${j.name}-${U}`))})]},`${w.kind}-${w.path}`)),x&&x.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:"No project-controlled executable configuration was found."})]})]})}const bt={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},ht={searchTasks:"Search tasks",openCommands:"Open command center",newTask:"New task",focusComposer:"Focus composer",toggleSidebar:"Toggle sidebar"};function vt(){var Ee,we;const{isSettingsOpen:n,settingsSection:m,toggleSettings:h,isSidebarOpen:R,setSidebarOpen:M}=be(),{configuredModels:T,loadModels:C,isLoading:y,error:r}=_e(),i=Je(),[c,N]=s.useState("general"),[A,E]=s.useState(!1),[p,o]=s.useState(null),[l,D]=s.useState(null),[x,f]=s.useState(null),[_,u]=s.useState([]),[S,w]=s.useState(null),[j,U]=s.useState(null),[O,W]=s.useState(null),[Z,L]=s.useState(null),[ee,G]=s.useState({}),[Y,$]=s.useState(null),[I,q]=s.useState(null),[Q,V]=s.useState(""),[d,F]=s.useState("all"),te=s.useRef(null),X=s.useRef(null),oe=s.useRef(0),[ie,pe]=s.useState(typeof Notification>"u"?"unsupported":Notification.permission),ae=[{value:"general",label:"General",category:"Settings"},{value:"trust",label:"Security",category:"Settings"},{value:"models",label:"Models",category:"Settings"},{value:"shortcuts",label:"Shortcuts",category:"Settings"},{value:"mcp",label:"MCP",category:"Integrations"},{value:"skills",label:"Skills",category:"Integrations"},{value:"plugins",label:"Plugins",category:"Integrations"},{value:"hooks",label:"Hooks",category:"Integrations"}],ce=s.useMemo(()=>We.map(t=>({action:ht[t.id],combo:Ye(t),scope:t.scope})),[]).filter(t=>{const b=t.action.toLowerCase().includes(Q.toLowerCase()),g=d==="all"||t.scope.toLowerCase()===d;return b&&g}),a=T.reduce((t,b)=>{const g=b.provider||"unknown";return t[g]||(t[g]=[]),t[g].push(b),t},{}),v=new Map(_.map(t=>[t.id,t]));for(const t of _)t.custom&&!a[t.id]&&(a[t.id]=[]);const K=s.useCallback(async()=>{try{u(await P("/providers")),L(null)}catch(t){L(t instanceof Error?t.message:"Failed to load provider channels")}},[]);s.useEffect(()=>{n&&(N(m),C(),K(),i.loadSettings())},[n,C,K,i.loadSettings,m]);const z=()=>{const t=X.current,b=t!=null&&t.isConnected?t:document.querySelector("[data-settings-trigger]");b==null||b.focus({preventScroll:!0})},se=()=>{h(),requestAnimationFrame(z)};s.useLayoutEffect(()=>{if(!n)return;const t=document.activeElement instanceof HTMLElement?document.activeElement:null;t&&t!==document.body&&t!==document.documentElement&&!t.closest("[data-settings-panel]")&&(X.current=t);const b=requestAnimationFrame(()=>{var g;(g=te.current)==null||g.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(b),requestAnimationFrame(z)}},[n]);const De=async t=>{$("save"),q(null);try{return await P("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,displayName:t.displayName,model:t.model,apiKey:t.apiKey,modelProvider:t.modelProvider,overrides:t.overrides})}),await C(),await K(),!0}catch(b){return q(b instanceof Error?b.message:"Failed to save model"),!1}finally{$(null)}},Fe=async()=>{typeof Notification>"u"||pe(await Notification.requestPermission())},Re=async t=>{$("delete"),q(null);try{await P(`/models/${t}`,{method:"DELETE"}),await C(),f(null)}catch(b){q(b instanceof Error?b.message:"Failed to delete model")}finally{$(null)}},Te=async(t,b)=>{$("update"),q(null);try{return await P(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),await C(),!0}catch(g){return q(g instanceof Error?g.message:"Failed to update model"),!1}finally{$(null)}},$e=async(t,b)=>{W({providerId:t,type:"update"}),L(null);try{return await P(`/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),await Promise.all([C(),K()]),!0}catch(g){return L(g instanceof Error?g.message:"Failed to update provider channel"),!1}finally{W(null)}},Me=async(t,b)=>{W({providerId:t.id,type:"probe"}),L(null);try{const g=await P(`/providers/${t.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:b})});G(k=>({...k,[t.id]:g}))}catch(g){L(g instanceof Error?g.message:"Provider probe failed")}finally{W(null)}},Le=async t=>{W({providerId:t.id,type:"delete"}),L(null);try{await P(`/providers/${t.id}?removeModels=true`,{method:"DELETE"}),U(null),o(null),G(b=>{const g={...b};return delete g[t.id],g}),await Promise.all([C(),K()])}catch(b){L(b instanceof Error?b.message:"Failed to delete provider channel")}finally{W(null)}},Ie=(t,b)=>{var de,re;const g=t.key==="ArrowRight"||t.key==="ArrowDown"?1:t.key==="ArrowLeft"||t.key==="ArrowUp"?-1:0;if(g===0&&t.key!=="Home"&&t.key!=="End")return;t.preventDefault();const k=t.key==="Home"?0:t.key==="End"?ae.length-1:(b+g+ae.length)%ae.length;N(ae[k].value),(re=(de=t.currentTarget.parentElement)==null?void 0:de.querySelectorAll('[role="tab"]')[k])==null||re.focus()},Ue=t=>{o(p===t?null:t)},Oe=t=>{if(!n||t.key!=="Escape"||!(t.target instanceof Node)||!t.currentTarget.contains(t.target)||A||l||S||Date.now()-oe.current<250)return;const b=t.target instanceof Element?t.target:null;if(!(t.defaultPrevented||b!=null&&b.closest('[role="dialog"]'))){if(t.preventDefault(),x){f(null);return}if(j){U(null);return}se()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:Oe,className:"flex h-full min-h-0 bg-white dark:bg-[#09090b]",children:[e.jsxs("nav",{role:"tablist","aria-label":"Settings sections",className:"flex h-full w-[220px] shrink-0 flex-col border-r border-[#E5E7EB] bg-[#F9FAFB] dark:border-zinc-800 dark:bg-[#111113]",children:[e.jsx("div",{className:"shrink-0 p-4",children:e.jsxs("button",{ref:te,type:"button",onClick:se,className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[12px] font-mono text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:[e.jsx(at,{className:"h-3.5 w-3.5"}),"Back"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-3 pb-4",children:Object.entries(ae.reduce((t,b)=>(t[b.category]||(t[b.category]=[]),t[b.category].push(b),t),{})).map(([t,b])=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-[#9CA3AF] dark:text-[#71717a]",children:t}),b.map(g=>e.jsx("button",{onClick:()=>N(g.value),onKeyDown:k=>Ie(k,ae.indexOf(g)),role:"tab",id:`settings-tab-${g.value}`,"aria-controls":`settings-panel-${g.value}`,"aria-selected":c===g.value,tabIndex:c===g.value?0:-1,className:B("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",c===g.value?"bg-[#E5E7EB] font-medium text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] hover:bg-[#E5E7EB]/60 hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]/50 dark:hover:text-[#E5E5E5]"),children:g.label},g.value))]},t))})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-y-auto p-6 sm:p-10",children:e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-xl font-semibold text-[#111827] dark:text-[#E5E5E5]",children:((Ee=ae.find(t=>t.value===c))==null?void 0:Ee.label)??"Settings"}),i.isLoading&&c==="general"&&e.jsxs("div",{role:"status",className:"flex shrink-0 items-center gap-2 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}),"Loading settings..."]}),i.error&&c==="general"&&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(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:i.error}),e.jsx("button",{type:"button",onClick:()=>void i.loadSettings(),className:"shrink-0 underline",children:"Retry"})]}),c==="models"&&e.jsxs("div",{id:"settings-panel-models",role:"tabpanel","aria-labelledby":"settings-tab-models",className:"flex flex-col gap-6 flex-1 min-h-0 overflow-hidden",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:"Configure API keys and model settings for different providers."}),(r||I||Z)&&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(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:Z||I||r}),e.jsx("button",{type:"button",onClick:()=>{q(null),L(null),r&&C()},className:"shrink-0 underline",children:r?"Retry":"Dismiss"})]}),x&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete ${x.displayName||x.model}`,className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsxs("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:["Delete ",x.displayName||x.model," and its saved configuration?"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(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 Re(x.id),disabled:Y!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:Y==="delete"?"Deleting...":"Delete model"})]})]}),j&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete channel ${j.name}`,className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsxs("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:["Delete channel ",j.name,", its credential, and"," ",((we=a[j.id])==null?void 0:we.length)??0," configured model(s)? Fallback references will also be removed."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>U(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 Le(j),disabled:O!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(O==null?void 0:O.type)==="delete"?"Deleting...":"Delete channel"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[y&&T.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(J,{className:"h-4 w-4 animate-spin"}),"Loading models..."]}),Object.entries(a).map(([t,b])=>{const g=bt[t]||{bg:"#71717a",label:"?"},k=v.get(t),de=p===t,re=ee[t],Ke=(O==null?void 0:O.providerId)===t&&O.type==="probe";return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("button",{onClick:()=>Ue(t),className:"flex min-w-0 flex-1 items-center justify-between p-4 text-left transition-colors hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded text-xs font-bold text-white",style:{backgroundColor:g.bg},children:g.label}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"truncate text-sm font-semibold font-mono text-[#111827] dark:text-[#E5E5E5]",children:(k==null?void 0:k.name)??t.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[b.length," model",b.length!==1?"s":"",k!=null&&k.custom?` · ${k.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsxs("span",{className:B("text-xs font-mono",(k==null?void 0:k.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(k==null?void 0:k.configured)===!1?"Missing credential":"Configured"]}),e.jsx(Pe,{className:B("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",de&&"rotate-180")})]})]}),(k==null?void 0:k.custom)&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pr-3",children:[e.jsx("button",{type:"button",onClick:()=>{var H;return void Me(k,(H=b[0])==null?void 0:H.id)},disabled:O!==null||b.length===0,"aria-label":`Test ${k.name}`,className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:Ke?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(st,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":k.id,onClick:()=>{L(null),w(k)},disabled:O!==null,"aria-label":`Edit channel ${k.name}`,className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Ae,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>U(k),disabled:O!==null,"aria-label":`Delete channel ${k.name}`,className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-red-500 disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-red-400",children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]})]}),re&&e.jsxs("div",{role:"status",className:B("border-t px-4 py-2 font-mono text-[11px]",re.ok?"border-green-200 bg-green-50 text-green-700 dark:border-green-900/60 dark:bg-green-950/20 dark:text-green-300":"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-300"),children:[re.message," · ",re.latencyMs,"ms · ",re.wireApi]}),de&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:[(k==null?void 0:k.custom)&&e.jsxs("div",{className:"border-b border-[#E5E7EB] px-4 py-2 font-mono text-[11px] text-[#71717a] dark:border-zinc-800",children:[e.jsx("span",{className:"font-semibold",children:k.id})," ","· ",k.defaultBaseUrl]}),b.map(H=>{var Se;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:H.displayName||H.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[H.displayName&&`${H.model} · `,((Se=H.overrides)==null?void 0:Se.baseUrl)||"default endpoint"]})]}),e.jsxs("div",{className:"flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx("button",{"data-edit-model-trigger":H.id,onClick:()=>{q(null),D(H)},disabled:Y!==null,"aria-label":`Edit ${H.displayName||H.model}`,className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(Ae,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>f(H),disabled:Y!==null,"aria-label":`Delete ${H.displayName||H.model}`,className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(ue,{className:"h-3.5 w-3.5"})})]})]},H.id)})]})]},t)}),!y&&!r&&Object.keys(a).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No models configured yet"})]})}),e.jsx("button",{"data-add-model-trigger":!0,onClick:()=>{q(null),E(!0)},disabled:Y!==null,className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:"+ Add New Model"})]}),c==="general"&&e.jsxs("div",{id:"settings-panel-general",role:"tabpanel","aria-labelledby":"settings-tab-general","aria-busy":i.isLoading,className:"flex flex-col gap-6 overflow-x-hidden overflow-y-auto pr-2 [&>div>div.flex]:flex-wrap [&>div>div.flex]:gap-2 [&_select]:max-w-full",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"General"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Response Language"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"AI will respond in this language"})]}),e.jsx(ne,{"aria-label":"Response language",value:i.language,onChange:t=>i.updateSettings({language:t}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"en-US",label:"English (US)"},{value:"zh-CN",label:"简体中文"},{value:"zh-TW",label:"繁體中文"},{value:"ja-JP",label:"日本語"},{value:"ko-KR",label:"한국어"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"},{value:"de-DE",label:"Deutsch"},{value:"pt-BR",label:"Português (BR)"},{value:"ru-RU",label:"Русский"}]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Auto-save sessions"}),e.jsx(le,{label:"Auto-save sessions",enabled:i.autoSaveSessions,onChange:t=>i.updateSettings({autoSaveSessions:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Communication Style"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"How the agent phrases its replies across every session"})]}),e.jsx(ne,{"aria-label":"Communication style",value:i.communicationStyle??"auto",onChange:t=>i.updateSettings({communicationStyle:t}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:rt.map(t=>({value:t.id,label:t.name}))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Theme Preference"}),e.jsx("div",{className:"flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1",children:["dark","light","system"].map(t=>e.jsx("button",{onClick:()=>i.updateSettings({uiTheme:t}),className:B("px-3 py-1 rounded text-[12px] font-mono transition-colors",i.uiTheme===t?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t==="dark"?"Dark":t==="light"?"Light":"System"},t))})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Compact sidebar"}),e.jsx(le,{label:"Compact sidebar",enabled:!R,onChange:t=>M(!t)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Code theme"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"Syntax highlighting colors"})]}),e.jsx(ne,{"aria-label":"Code theme",value:i.theme,onChange:t=>i.updateSettings({theme:t}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"dracula",label:"Dracula"},{value:"monokai",label:"Monokai"},{value:"nord",label:"Nord"},{value:"tokyo-night",label:"Tokyo Night"},{value:"one-dark",label:"One Dark"},{value:"catppuccin",label:"Catppuccin"},{value:"gruvbox",label:"Gruvbox"},{value:"github",label:"GitHub"},{value:"solarized-light",label:"Solarized Light"},{value:"solarized-dark",label:"Solarized Dark"},{value:"ayu-dark",label:"Ayu Dark"},{value:"rose-pine",label:"Rose Pine"},{value:"kanagawa",label:"Kanagawa"}]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Notifications"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Build finished"}),e.jsx(le,{label:"Build finished notifications",enabled:i.notifyBuild,onChange:t=>i.updateSettings({notifyBuild:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Errors only"}),e.jsx(le,{label:"Error notifications",enabled:i.notifyErrors,onChange:t=>i.updateSettings({notifyErrors:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"System sounds"}),e.jsx(le,{label:"System sounds",enabled:i.notifySounds,onChange:t=>i.updateSettings({notifySounds:t})})]}),(i.notifyBuild||i.notifyErrors)&&ie!=="granted"&&e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] px-3 py-2 dark:border-[#27272a] dark:bg-[#18181b]",children:[e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:ie==="denied"?"Browser notifications are blocked":ie==="unsupported"?"Browser notifications are unavailable":"Enable alerts while this tab is in the background"}),ie==="default"&&e.jsx("button",{type:"button",onClick:()=>void Fe(),className:"shrink-0 rounded-md bg-[#111827] px-2.5 py-1.5 text-[10px] font-mono text-white hover:bg-[#374151] dark:bg-[#E5E5E5] dark:text-[#111827]",children:"Enable"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Privacy"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Telemetry"}),e.jsx(le,{label:"Telemetry",enabled:i.privacyTelemetry,onChange:t=>i.updateSettings({privacyTelemetry:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Crash reports"}),e.jsx(le,{label:"Crash reports",enabled:i.privacyCrash,onChange:t=>i.updateSettings({privacyCrash:t})})]})]})]}),c==="shortcuts"&&e.jsxs("div",{id:"settings-panel-shortcuts",role:"tabpanel","aria-labelledby":"settings-tab-shortcuts",className:"flex flex-col gap-4 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-3",children:[e.jsx("input",{"aria-label":"Search shortcut actions",value:Q,onChange:t=>V(t.target.value),placeholder:"Search actions...",className:"field flex-1 text-[12px]"}),e.jsx(ne,{"aria-label":"Shortcut scope",value:d,onChange:t=>F(t),className:"w-auto min-w-[120px] text-[12px]",options:[{value:"all",label:"All scopes"},{value:"global",label:"Global"},{value:"chat",label:"Chat"},{value:"layout",label:"Layout"}]}),e.jsx("button",{onClick:()=>{V(""),F("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:"Reset"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:"Action"}),e.jsx("span",{children:"Shortcut"}),e.jsx("span",{children:"Scope"})]}),ce.map((t,b)=>e.jsxs("div",{className:B("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",b%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:t.action}),e.jsx("div",{className:"flex items-center gap-1",children:t.combo.map(g=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:g},g))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),ce.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:"No shortcuts found."})]})]}),c==="mcp"&&e.jsxs("div",{id:"settings-panel-mcp",role:"tabpanel","aria-labelledby":"settings-tab-mcp",className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("p",{children:"MCP server configuration is available via the MCP panel."}),e.jsx("button",{type:"button",onClick:()=>{be.getState().toggleMcp()},className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-[#E5E7EB] px-3 text-[12px] font-medium text-[#111827] transition-colors hover:bg-[#F3F4F6] dark:border-zinc-700 dark:text-[#E5E5E5] dark:hover:bg-[#27272a]",children:"Open MCP Panel"})]}),c==="skills"&&e.jsxs("div",{id:"settings-panel-skills",role:"tabpanel","aria-labelledby":"settings-tab-skills",className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("p",{children:"Skills configuration is available via the Skills panel."}),e.jsx("button",{type:"button",onClick:()=>{be.getState().toggleSkills()},className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-[#E5E7EB] px-3 text-[12px] font-medium text-[#111827] transition-colors hover:bg-[#F3F4F6] dark:border-zinc-700 dark:text-[#E5E5E5] dark:hover:bg-[#27272a]",children:"Open Skills Panel"})]}),c==="hooks"&&e.jsx("div",{id:"settings-panel-hooks",role:"tabpanel","aria-labelledby":"settings-tab-hooks",className:"min-h-0 flex-1",children:e.jsx(ct,{})}),c==="plugins"&&e.jsx("div",{id:"settings-panel-plugins",role:"tabpanel","aria-labelledby":"settings-tab-plugins",className:"min-h-0 flex-1",children:e.jsx(mt,{})}),c==="trust"&&e.jsx("div",{id:"settings-panel-trust",role:"tabpanel","aria-labelledby":"settings-tab-trust",className:"min-h-0 flex-1",children:e.jsx(pt,{})})]})})})]}),A&&e.jsx(nt,{open:!0,onOpenChange:t=>{t||(oe.current=Date.now()),E(t)},onSave:De,saveError:I}),l&&e.jsx(ot,{open:!0,onOpenChange:t=>{t||(oe.current=Date.now(),D(null))},model:l,onSave:Te,saveError:I}),S&&e.jsx(it,{provider:S,onOpenChange:t=>{t||(oe.current=Date.now(),w(null))},onSave:$e,saveError:Z})]})}function le({label:n,enabled:m,onChange:h}){return e.jsx("button",{type:"button",role:"switch","aria-label":n,"aria-checked":m,onClick:()=>h(!m),className:B("flex h-6 w-11 items-center rounded-full px-1 transition-colors",m?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:B("h-4 w-4 rounded-full transition-transform",m?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{vt as SettingsModal};
@@ -0,0 +1 @@
1
+ import{r as l,j as e}from"./vendor-react-DG5dkZ_t.js";import{e as G}from"./useRequest-BvqVDnKl.js";import{b as ee,a as te,D as U,e as P,F as se,g as M,j as g,x as F,y as ae}from"./index-bjyn3NHs.js";import{i as le,a as ne,X as Q,f as oe,L as W,T as re}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";const O=n=>n?{"x-blade-directory":n}:void 0,de=async n=>F("/skills",{headers:O(n)}),ie=async()=>F("/skills/catalog");function ue(){const{isSkillsOpen:n,toggleSkills:d}=ee(),i=te(t=>{var j,y;return((j=t.currentSessionRef)==null?void 0:j.projectPath)??t.selectedProjectPath??((y=t.taskWorkspaceInfo)==null?void 0:y.cwd)??null}),[x,f]=l.useState(null),[c,h]=l.useState(""),[w,o]=l.useState(null),[r,N]=l.useState(null),[A,m]=l.useState(null),[S,p]=l.useState(!1),[B,b]=l.useState(!1),[I,k]=l.useState("confirm"),[D,v]=l.useState(null),[C,a]=l.useState(null),{data:u=[],loading:E,error:R,run:q,runAsync:$}=G(()=>de(i),{refreshDeps:[n,i],ready:n,onSuccess:t=>{t.length>0&&!x&&f(t[0].id)}}),{data:X=[],loading:K,error:T,run:V}=G(ie,{refreshDeps:[n],ready:n}),z=u.filter(t=>t.name.toLowerCase().includes(c.toLowerCase())),s=l.useMemo(()=>u.find(t=>t.id===x)??u[0],[u,x]),H=async(t,j,y)=>{N({type:t,name:j.name}),o(null);try{await F(t==="delete"?`/skills/${encodeURIComponent(j.name)}`:`/skills/${encodeURIComponent(j.name)}/toggle`,{method:t==="delete"?"DELETE":"POST",headers:{...O(i),...t==="toggle"?{"Content-Type":"application/json"}:{}},body:t==="toggle"?JSON.stringify({enabled:y}):void 0}),await $(),t==="delete"&&(m(null),f(null))}catch(J){o(J instanceof Error?J.message:`Failed to ${t} skill`)}finally{N(null)}},Y=()=>{p(!0)},Z=t=>{a(t),v(null),k("confirm"),b(!0)},_=async()=>{if(C){k("installing"),v(null);try{const t=await F("/skills/install",{method:"POST",headers:{"Content-Type":"application/json",...O(i)},body:JSON.stringify(C)});if(t.success===!1)throw new Error(t.error||"Failed to install skill");await $(),b(!1),p(!1)}catch(t){v(t instanceof Error?t.message:"Failed to install skill"),k("failed")}}};return e.jsxs(l.Fragment,{children:[e.jsx(U,{open:n,onOpenChange:d,children:e.jsxs(P,{onCloseAutoFocus:se,className:"flex h-[min(620px,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-[820px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(M,{className:"sr-only",children:"Skills"}),e.jsx("div",{className:"flex h-full min-h-0 min-w-0",children:e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 p-4 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{"data-skill-install-trigger":!0,onClick:Y,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(le,{className:"h-3.5 w-3.5"}),"Install skill"]}),e.jsx("button",{onClick:q,"aria-label":"Refresh skills",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:E,children:e.jsx(ne,{className:g("h-4 w-4",E&&"animate-spin")})}),e.jsx("button",{onClick:d,"aria-label":"Close skills",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(Q,{className:"h-4 w-4"})})]})]}),w&&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(oe,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:w}),e.jsx("button",{type:"button",onClick:()=>o(null),className:"shrink-0 underline",children:"Dismiss"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden 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("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Installed"}),e.jsx("input",{type:"search","aria-label":"Search installed skills",value:c,onChange:t=>h(t.target.value),placeholder:"Search skills...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[E&&u.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(W,{className:"h-4 w-4 animate-spin"}),"Loading skills..."]}),R&&!E&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:R.message}),e.jsx("button",{type:"button",onClick:q,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!R&&z.length===0&&!E&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:c?"No skills match your search":"No skills installed"}),z.map(t=>e.jsxs("button",{onClick:()=>{f(t.id),m(null),o(null)},className:g("flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",t.id===x?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:g("text-[11px] font-mono font-semibold",t.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:t.enabled?"Enabled":"Disabled"})]}),e.jsx("span",{className:"block w-full min-w-0 truncate text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:t.description||"No description"})]},t.id))]})]}),s?e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:s.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",s.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:s.description||"No description available"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void H("toggle",s,!s.enabled),disabled:r!==null,className:g("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",s.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",r&&"opacity-60 cursor-not-allowed"),children:(r==null?void 0:r.type)==="toggle"&&r.name===s.name?"Saving...":s.enabled?"Disable":"Enable"}),e.jsxs("button",{onClick:()=>m(s.name),disabled:!s.removable||r!==null,title:s.removable?void 0:"Only Blade user skills can be uninstalled",className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(re,{className:"h-3 w-3"}),s.removable?"Uninstall":"Managed"]})]}),A===s.name&&e.jsxs("div",{role:"alertdialog","aria-label":`Uninstall ${s.name}`,className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 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 skill from ~/.blade/skills?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>m(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 H("delete",s),disabled:r!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(r==null?void 0:r.type)==="delete"?"Uninstalling...":"Uninstall skill"})]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Provider"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:s.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Location"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:s.location})]})]}),s.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.capabilities.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))})]}),s.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Allowed Tools (",s.allowedTools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.allowedTools.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("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a skill to view details"})})]})]})})]})}),e.jsx(xe,{open:S,catalog:X,installed:u.map(t=>t.name),catalogLoading:K,catalogError:(T==null?void 0:T.message)??null,onRetryCatalog:V,onOpenChange:p,onInstall:Z}),e.jsx(ce,{open:B,status:I,error:D,onCancel:()=>b(!1),onConfirm:_,onRetry:()=>k("confirm")})]})}function L({active:n,children:d,onClick:i}){return e.jsx("button",{onClick:i,className:g("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:d})}function xe({open:n,onOpenChange:d,onInstall:i,catalog:x,installed:f,catalogLoading:c,catalogError:h,onRetryCatalog:w}){const[o,r]=l.useState("catalog"),[N,A]=l.useState(""),[m,S]=l.useState(null),[p,B]=l.useState(""),[b,I]=l.useState(""),k=x.filter(a=>a.name.toLowerCase().includes(N.toLowerCase())),D=()=>{if(o==="catalog"){if(!m)return;i({source:"catalog",name:m});return}if(o==="repo"){if(!p)return;i({source:"repo",url:p});return}b&&i({source:"local",path:b})},v=m?f.includes(m):!1,C=o==="catalog"&&(!m||v||c||!!h)||o==="repo"&&!p||o==="local"&&!b;return e.jsx(U,{open:n,onOpenChange:d,children:e.jsxs(P,{onCloseAutoFocus:a=>ae("[data-skill-install-trigger]",a),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(M,{className:"sr-only",children:"Install Skill"}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install Skill"}),e.jsx("button",{onClick:()=>d(!1),"aria-label":"Close skill installation",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(Q,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(L,{active:o==="catalog",onClick:()=>r("catalog"),children:"Catalog"}),e.jsx(L,{active:o==="repo",onClick:()=>r("repo"),children:"Repo"}),e.jsx(L,{active:o==="local",onClick:()=>r("local"),children:"Local"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[o==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{"aria-label":"Search skill catalog",value:N,onChange:a=>A(a.target.value),placeholder:"Search catalog...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex max-h-[min(240px,30dvh)] flex-col gap-2 overflow-y-auto",children:[c&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-6 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(W,{className:"h-4 w-4 animate-spin"}),"Loading catalog..."]}),h&&!c&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:w,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!c&&!h&&k.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills found"}),!c&&!h&&k.map(a=>{const u=f.includes(a.name),E=m===a.name;return e.jsxs("button",{onClick:()=>S(a.name),className:g("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",E?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),e.jsx("span",{className:g("text-[10px] font-mono px-2 py-0.5 rounded",a.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:a.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:a.description}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["by ",a.author]}),u&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:"Installed"})]},a.name)})]})]}),o==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"GitHub URL"}),e.jsx("input",{"aria-label":"Skill repository URL",value:p,onChange:a=>B(a.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Uses Git credentials available to the Blade process"})]}),o==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Local path"}),e.jsx("input",{"aria-label":"Local skill path",value:b,onChange:a=>I(a.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>d(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:D,disabled:C,className:g("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",C?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:"Install"})]})]})]})})}function ce({open:n,status:d,error:i,onCancel:x,onConfirm:f,onRetry:c}){return e.jsx(U,{open:n,onOpenChange:h=>!h&&x(),children:e.jsxs(P,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(M,{className:"sr-only",children:"Install Status"}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[d==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Confirm Install"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Install selected skill?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:x,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:f,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Install"})]})]}),d==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Installing"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Downloading and verifying…"}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:x,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Hide"})]}),d==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Install Failed"}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:i||"Installation failed."}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Check access and try again."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:x,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Close"}),e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Retry"})]})]})]})]})})}export{ue as SkillsModal};
@@ -1 +1 @@
1
- import{j as n,r as d}from"./vendor-react-DG5dkZ_t.js";import{j as S,E as De,d as U,c as L,F as Ae,G as E,H as J,I as Ie,u as Fe,b as m,a as o,J as P,r as Pe,D as Re,e as Le,A as Ee,g as qe,h as Be,s as Me}from"./index-BNsnHxlt.js";import{aa as he,i as Ke,F as Oe,j as $e,h as We,ab as Qe,ac as He,o as ze,ad as Ge,ae as Ue,k as G,f as ue,af as Je,J as _e,ag as Ve,G as Xe,ah as Ye,L as R,S as Ze,R as et}from"./vendor-icons-CsBKlDXT.js";import"./vendor-radix-DXRuAJHH.js";function tt(t,r){const s=r.trim().toLocaleLowerCase();return s?t.filter(i=>`${i.label} ${i.description} ${i.keywords}`.toLocaleLowerCase().includes(s)):t}function nt({actions:t,selectedIndex:r,onSelect:s,onRun:i}){return t.map((c,h)=>{const k=h===r,u=c.icon;return n.jsx("div",{id:`command-center-result-${h}`,"data-task-result-index":h,role:"option","aria-selected":k,onMouseEnter:()=>s(h),className:S("group flex min-h-[58px] w-full items-center rounded-lg border border-transparent text-left transition-colors",k?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:n.jsxs("button",{type:"button",onClick:()=>i(c),className:"flex min-h-[58px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-accent))]",children:n.jsx(u,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:c.label}),n.jsx("span",{className:"mt-0.5 block truncate text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:c.description})]}),c.shortcut&&n.jsx("span",{className:"shrink-0 rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:c.shortcut}),n.jsx(he,{className:S("h-3.5 w-3.5 shrink-0 transition-all",k?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]})},c.id)})}const st={running:"running active 进行中 运行中",queued:"queued waiting 排队中 等待中",interrupted:"interrupted paused 已暂停 已中断",failed:"failed error 已失败 错误",cancelled:"cancelled canceled 已取消",completed:"completed done finished 已完成 完成"};function _(t){return Ae(t,Ie)}function at(t){const r=t.lastMessageTime||t.firstMessageTime;if(!r)return"";const s=new Date(r);return Number.isNaN(s.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}function q(t){return t.normalize("NFKC").toLocaleLowerCase().trim()}function rt(t,r){var i,c;const s=E(t,r);return q([_(t),J(s),s,t.projectPath,t.gitBranch,t.taskWorktreeBranch,t.taskStatus,st[t.taskStatus],((i=t.pendingInteraction)==null?void 0:i.type)==="question"?"needs answer question attention 等待回答 需要回答":((c=t.pendingInteraction)==null?void 0:c.type)==="elicitation"?"mcp input elicitation attention MCP 输入 等待输入":t.pendingInteraction?"needs approval permission attention 等待审批 需要授权":"",t.sessionId].filter(Boolean).join(" "))}function pe(t,r,s){if(!r)return 0;const i=q(_(t)),c=q(J(E(t,s)));return i===r?500:i.startsWith(r)?400:i.includes(r)?300:c===r?250:c.startsWith(r)?200:100}function it(t,r,s,i=50){const c=q(r),h=c.split(/\s+/).filter(Boolean),k=new Set;return t.filter(u=>{if(h.length===0)return!0;const p=rt(u,s);return h.every(g=>p.includes(g))}).sort((u,p)=>{const g=+!!p.pendingInteraction-+!!u.pendingInteraction;return g!==0?g:pe(p,c,s)-pe(u,c,s)||De(u,p)}).filter(u=>{const p=U(L(u));return k.has(p)?!1:(k.add(p),!0)}).slice(0,i)}const ct={running:"sidebar.group.running",queued:"sidebar.group.queued",interrupted:"sidebar.group.interrupted",failed:"sidebar.group.failed",cancelled:"sidebar.group.cancelled",completed:"sidebar.group.done"};function ut(){const t=Fe(),r=m(e=>e.isTaskSwitcherOpen),s=m(e=>e.taskSwitcherMode),i=m(e=>e.setTaskSwitcherOpen),c=m(e=>e.setTaskSwitcherMode),h=m(e=>e.toggleSidebar),k=m(e=>e.isFilePreviewOpen),u=m(e=>e.setFilePreviewOpen),p=m(e=>e.openFilePreview),g=m(e=>e.toggleTerminal),N=m(e=>e.openSettings),V=m(e=>e.toggleMcp),X=m(e=>e.toggleSkills),b=o(e=>e.sessions),ke=o(e=>e.isLoading),C=o(e=>e.catalogLoadState),B=C==="loading"||C==="hydrating",M=o(e=>e.currentSessionRef),Y=o(e=>e.isTemporarySession),Z=o(e=>e.startTemporarySession),K=o(e=>e.unreadTaskKeys),xe=o(e=>e.boundProjects),A=o(e=>{var a;return e.selectedProjectPath??((a=e.taskWorkspaceInfo)==null?void 0:a.cwd)??null}),fe=o(e=>e.selectProject),ge=o(e=>e.selectSession),be=o(e=>e.cancelTask),ve=o(e=>e.retryTask),we=o(e=>e.cancellingTaskKeys),ye=o(e=>e.retryingTaskKeys),[v,ee]=d.useState(""),[f,y]=d.useState(0),[je,O]=d.useState(null),[te,I]=d.useState(null),ne=d.useRef(null),se=d.useRef(null),ae=d.useMemo(()=>[{id:"new-task",label:t("commandCenter.action.newTask"),description:t("commandCenter.action.newTaskDescription"),keywords:"create compose session",icon:Ke,shortcut:P("newTask"),run:()=>{Z(),requestAnimationFrame(()=>Pe())}},{id:"toggle-preview",label:t("commandCenter.action.preview"),description:t("commandCenter.action.previewDescription"),keywords:"diff files logs artifact review",icon:Oe,run:()=>{k?u(!1):p((!M||Y)&&m.getState().previewRequestId===0?{tab:"files"}:void 0)}},{id:"toggle-terminal",label:t("commandCenter.action.terminal"),description:t("commandCenter.action.terminalDescription"),keywords:"shell console command line",icon:$e,run:g},{id:"open-settings",label:t("commandCenter.action.settings"),description:t("commandCenter.action.settingsDescription"),keywords:"preferences general",icon:We,run:()=>N("general")},{id:"open-models",label:t("commandCenter.action.models"),description:t("commandCenter.action.modelsDescription"),keywords:"provider llm api configuration",icon:Qe,run:()=>N("models")},{id:"open-shortcuts",label:t("commandCenter.action.shortcuts"),description:t("commandCenter.action.shortcutsDescription"),keywords:"keyboard hotkey key binding",icon:He,shortcut:P("openCommands"),run:()=>N("shortcuts")},{id:"open-skills",label:t("commandCenter.action.skills"),description:t("commandCenter.action.skillsDescription"),keywords:"capabilities workflow",icon:ze,run:X},{id:"open-mcp",label:t("commandCenter.action.mcp"),description:t("commandCenter.action.mcpDescription"),keywords:"server tools protocol integration",icon:Ge,run:V},{id:"toggle-sidebar",label:t("commandCenter.action.sidebar"),description:t("commandCenter.action.sidebarDescription"),keywords:"navigation layout panel projects",icon:Ue,shortcut:P("toggleSidebar"),run:h}],[M,k,Y,p,N,u,Z,t,V,h,X,g]),w=d.useMemo(()=>it(b,v,A),[A,v,b]),T=d.useMemo(()=>tt(ae,v),[ae,v]),D=s==="tasks"?w.length:T.length,re=d.useMemo(()=>b.filter(e=>!!e.pendingInteraction).length,[b]),$=s==="tasks"?w[f]??null:null,W=s==="commands"?T[f]??null:null;d.useEffect(()=>{r&&(ee(""),y(0),O(null),I(null))},[s,r]),d.useEffect(()=>{y(0)},[v]),d.useEffect(()=>{var a,l;const e=(a=se.current)==null?void 0:a.querySelector(`[data-task-result-index="${f}"]`);(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})},[f]);const ie=async e=>{const a=L(e),l=U(a),x=E(e,A);O(l),xe.some(j=>j.path===x)&&fe(x);try{await ge(a),i(!1)}catch(j){I(j instanceof Error?j.message:t("taskSwitcher.action.failed"))}finally{O(null)}},ce=async(e,a)=>{I(null);try{const l=L(a);e==="cancel"?await be(l):(await ve(l),i(!1))}catch(l){I(l instanceof Error?l.message:t("taskSwitcher.action.failed"))}},oe=e=>{i(!1),requestAnimationFrame(e.run)},Se=e=>{e.key==="ArrowDown"?(e.preventDefault(),y(a=>D===0?0:(a+1)%D)):e.key==="ArrowUp"?(e.preventDefault(),y(a=>D===0?0:(a-1+D)%D)):e.key==="Enter"&&$?(e.preventDefault(),ie($)):e.key==="Enter"&&W?(e.preventDefault(),oe(W)):e.key==="Escape"&&(e.preventDefault(),i(!1))};return n.jsx(Re,{open:r,onOpenChange:i,children:n.jsxs(Le,{hideCloseButton:!0,onCloseAutoFocus:Ee,className:"top-3 w-[min(680px,calc(100vw-32px))] max-w-none translate-y-0 gap-0 overflow-hidden rounded-xl border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-canvas))] p-0 shadow-2xl sm:top-[18%]",children:[n.jsx(qe,{className:"sr-only",children:t("commandCenter.title")}),n.jsx(Be,{className:"sr-only",children:t("commandCenter.description")}),n.jsxs("div",{className:"flex h-14 items-center gap-3 border-b border-[hsl(var(--deck-hairline))] px-4",children:[n.jsx(G,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),n.jsx("input",{ref:ne,autoFocus:!0,role:"combobox","aria-expanded":"true","aria-controls":"task-switcher-results","aria-activedescendant":$?`task-switcher-result-${f}`:W?`command-center-result-${f}`:void 0,"aria-label":t(s==="tasks"?"taskSwitcher.searchAria":"commandCenter.searchAria"),placeholder:t(s==="tasks"?"taskSwitcher.placeholder":"commandCenter.placeholder"),value:v,onChange:e=>ee(e.target.value),onKeyDown:Se,className:"h-full min-w-0 flex-1 bg-transparent font-mono text-[14px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),n.jsx("span",{className:"rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:"ESC"})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 pb-2 pt-3",children:[n.jsx("div",{role:"tablist","aria-label":t("commandCenter.modeAria"),className:"flex items-center gap-0.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0.5",children:["tasks","commands"].map(e=>n.jsx("button",{type:"button",role:"tab","aria-selected":s===e,onClick:()=>{c(e),requestAnimationFrame(()=>{var a;return(a=ne.current)==null?void 0:a.focus()})},className:S("rounded-[5px] px-2.5 py-1 font-mono text-[9.5px] uppercase tracking-[0.1em] transition-colors",s===e?"bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] shadow-sm":"text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:t(e==="tasks"?"commandCenter.mode.tasks":"commandCenter.mode.commands")},e))}),n.jsx("span",{children:n.jsx("span",{className:"font-mono text-[9.5px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]",children:s==="commands"?t("commandCenter.actions",{count:T.length}):v?t("taskSwitcher.results",{count:w.length}):B?b.length===0?t("taskSwitcher.indexing"):t("taskSwitcher.indexingLoaded",{count:b.length}):C==="error"?t("sidebar.catalog.incomplete"):re>0?t("taskSwitcher.needsAction",{count:re}):K.length>0?t("taskSwitcher.unread",{count:K.length}):t("taskSwitcher.scope",{count:b.length})})})]}),te&&n.jsx("div",{role:"alert",className:"mx-4 mb-2 rounded-md border border-red-300/70 bg-red-50 px-3 py-2 font-mono text-[10.5px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:te}),n.jsxs("div",{id:"task-switcher-results",ref:se,role:"listbox","aria-label":t(s==="tasks"?"taskSwitcher.resultsAria":"commandCenter.resultsAria"),className:"max-h-[min(460px,60vh)] overflow-y-auto px-2 pb-2",children:[s==="commands"&&n.jsx(nt,{actions:T,selectedIndex:f,onSelect:y,onRun:oe}),s==="tasks"&&w.map((e,a)=>{const l=L(e),x=U(l),j=E(e,A),Ne=J(j),le=Me(l,M),Q=a===f,Ce=je===x,Te=K.includes(x),F=_(e),de=e.taskStatus==="running"||e.taskStatus==="queued",me=!!e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled"),H=we.includes(x),z=ye.includes(x);return n.jsxs("div",{id:`task-switcher-result-${a}`,"data-task-result-index":a,"data-session-ref":x,role:"option","aria-selected":Q,onMouseEnter:()=>y(a),className:S("group flex min-h-[68px] w-full items-center rounded-lg border border-transparent text-left transition-colors",Q?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:[n.jsxs("button",{type:"button",onClick:()=>void ie(e),"aria-label":t("session.action.select",{title:F}),className:"flex min-h-[68px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:S("flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-[hsl(var(--deck-canvas))]",le?"border-[hsl(var(--deck-accent)/0.5)] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))]"),children:e.pendingInteraction?n.jsx(ue,{className:"h-3.5 w-3.5 animate-pulse text-amber-600 dark:text-amber-400"}):e.taskStatus==="running"?n.jsx(Je,{className:"h-3.5 w-3.5 animate-pulse"}):n.jsx(_e,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:F}),le&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.current")}),Te&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.new")}),e.pendingInteraction&&n.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-amber-800 dark:bg-amber-950/60 dark:text-amber-300",children:t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission")}),e.taskRetriedFrom&&n.jsx("span",{title:`${t("session.retriedFrom")} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] text-[hsl(var(--deck-accent))]",children:t("session.retryShort")})]}),n.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Ve,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:Ne})]}),(e.taskWorktreeBranch||e.gitBranch)&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Xe,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:e.taskWorktreeBranch||e.gitBranch})]}),n.jsx("span",{className:"shrink-0",children:e.taskStatus==="queued"&&e.taskQueuePosition!==void 0&&e.taskQueueDepth!==void 0?t("session.queued",{position:e.taskQueuePosition,depth:e.taskQueueDepth}):e.pendingInteraction?t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission"):t(ct[e.taskStatus])}),n.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1",children:[n.jsx(Ye,{className:"h-2.5 w-2.5"}),at(e)]})]})]}),Ce?n.jsx(R,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):n.jsx(he,{className:S("h-3.5 w-3.5 shrink-0 transition-all",Q?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]}),(de||me)&&n.jsxs("div",{className:"flex shrink-0 items-center pr-2",children:[de&&n.jsx("button",{type:"button","aria-label":t(H?"session.action.stopping":"session.action.stop",{title:F}),disabled:H,onClick:()=>void ce("cancel",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:H?n.jsx(R,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Ze,{className:"h-3.5 w-3.5"})}),me&&n.jsx("button",{type:"button","aria-label":t(z?"session.action.retrying":"session.action.retry",{title:F}),disabled:z,onClick:()=>void ce("retry",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60",children:z?n.jsx(R,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(et,{className:"h-3.5 w-3.5"})})]})]},x)}),s==="tasks"&&w.length===0&&B&&n.jsxs("div",{className:"flex min-h-36 items-center justify-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsx(R,{className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("taskSwitcher.indexing")]}),s==="tasks"&&w.length===0&&!B&&C!=="error"&&!ke&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(G,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("taskSwitcher.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("taskSwitcher.emptyHint")})]}),s==="tasks"&&w.length===0&&C==="error"&&n.jsxs("div",{role:"alert",className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(ue,{className:"mb-3 h-5 w-5 text-amber-500"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("sidebar.catalog.incomplete")})]}),s==="commands"&&T.length===0&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(G,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("commandCenter.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("commandCenter.emptyHint")})]})]}),n.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-4 py-2 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{children:["↑↓ ",t("taskSwitcher.hint.navigate")]}),n.jsxs("span",{children:["↵ ",t("taskSwitcher.hint.open")]}),n.jsxs("span",{className:"ml-auto",children:[P(s==="tasks"?"openCommands":"searchTasks")," ",t(s==="tasks"?"commandCenter.mode.commands":"commandCenter.mode.tasks")]})]})]})})}export{ut as TaskSwitcher};
1
+ import{j as n,r as d}from"./vendor-react-DG5dkZ_t.js";import{j as S,G as De,d as U,c as R,H as Ae,I as E,J as _,L as Ie,u as Fe,b as m,a as o,M as L,r as Le,D as Pe,e as Re,F as Ee,g as Me,h as qe,s as Be}from"./index-bjyn3NHs.js";import{ac as he,i as Ke,F as Oe,j as $e,h as Qe,ad as We,ae as He,o as ze,af as Ge,ag as Ue,k as G,f as ue,ah as _e,Q as Je,ai as Ve,G as Xe,aj as Ye,L as P,S as Ze,R as et}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";function tt(t,r){const s=r.trim().toLocaleLowerCase();return s?t.filter(i=>`${i.label} ${i.description} ${i.keywords}`.toLocaleLowerCase().includes(s)):t}function nt({actions:t,selectedIndex:r,onSelect:s,onRun:i}){return t.map((c,h)=>{const k=h===r,u=c.icon;return n.jsx("div",{id:`command-center-result-${h}`,"data-task-result-index":h,role:"option","aria-selected":k,onMouseEnter:()=>s(h),className:S("group flex min-h-[58px] w-full items-center rounded-lg border border-transparent text-left transition-colors",k?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:n.jsxs("button",{type:"button",onClick:()=>i(c),className:"flex min-h-[58px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-accent))]",children:n.jsx(u,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:c.label}),n.jsx("span",{className:"mt-0.5 block truncate text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:c.description})]}),c.shortcut&&n.jsx("span",{className:"shrink-0 rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:c.shortcut}),n.jsx(he,{className:S("h-3.5 w-3.5 shrink-0 transition-all",k?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]})},c.id)})}const st={running:"running active 进行中 运行中",queued:"queued waiting 排队中 等待中",interrupted:"interrupted paused 已暂停 已中断",failed:"failed error 已失败 错误",cancelled:"cancelled canceled 已取消",completed:"completed done finished 已完成 完成"};function J(t){return Ae(t,Ie)}function at(t){const r=t.lastMessageTime||t.firstMessageTime;if(!r)return"";const s=new Date(r);return Number.isNaN(s.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}function M(t){return t.normalize("NFKC").toLocaleLowerCase().trim()}function rt(t,r){var i,c;const s=E(t,r);return M([J(t),_(s),s,t.projectPath,t.gitBranch,t.taskWorktreeBranch,t.taskStatus,st[t.taskStatus],((i=t.pendingInteraction)==null?void 0:i.type)==="question"?"needs answer question attention 等待回答 需要回答":((c=t.pendingInteraction)==null?void 0:c.type)==="elicitation"?"mcp input elicitation attention MCP 输入 等待输入":t.pendingInteraction?"needs approval permission attention 等待审批 需要授权":"",t.sessionId].filter(Boolean).join(" "))}function pe(t,r,s){if(!r)return 0;const i=M(J(t)),c=M(_(E(t,s)));return i===r?500:i.startsWith(r)?400:i.includes(r)?300:c===r?250:c.startsWith(r)?200:100}function it(t,r,s,i=50){const c=M(r),h=c.split(/\s+/).filter(Boolean),k=new Set;return t.filter(u=>{if(h.length===0)return!0;const p=rt(u,s);return h.every(g=>p.includes(g))}).sort((u,p)=>{const g=+!!p.pendingInteraction-+!!u.pendingInteraction;return g!==0?g:pe(p,c,s)-pe(u,c,s)||De(u,p)}).filter(u=>{const p=U(R(u));return k.has(p)?!1:(k.add(p),!0)}).slice(0,i)}const ct={running:"sidebar.group.running",queued:"sidebar.group.queued",interrupted:"sidebar.group.interrupted",failed:"sidebar.group.failed",cancelled:"sidebar.group.cancelled",completed:"sidebar.group.done"};function ut(){const t=Fe(),r=m(e=>e.isTaskSwitcherOpen),s=m(e=>e.taskSwitcherMode),i=m(e=>e.setTaskSwitcherOpen),c=m(e=>e.setTaskSwitcherMode),h=m(e=>e.toggleSidebar),k=m(e=>e.isFilePreviewOpen),u=m(e=>e.setFilePreviewOpen),p=m(e=>e.openFilePreview),g=m(e=>e.toggleTerminal),N=m(e=>e.openSettings),V=m(e=>e.toggleMcp),X=m(e=>e.toggleSkills),b=o(e=>e.sessions),ke=o(e=>e.isLoading),C=o(e=>e.catalogLoadState),q=C==="loading"||C==="hydrating",B=o(e=>e.currentSessionRef),Y=o(e=>e.isTemporarySession),Z=o(e=>e.startTemporarySession),K=o(e=>e.unreadTaskKeys),xe=o(e=>e.boundProjects),A=o(e=>{var a;return e.selectedProjectPath??((a=e.taskWorkspaceInfo)==null?void 0:a.cwd)??null}),fe=o(e=>e.selectProject),ge=o(e=>e.selectSession),be=o(e=>e.cancelTask),ve=o(e=>e.retryTask),we=o(e=>e.cancellingTaskKeys),ye=o(e=>e.retryingTaskKeys),[v,ee]=d.useState(""),[f,y]=d.useState(0),[je,O]=d.useState(null),[te,I]=d.useState(null),ne=d.useRef(null),se=d.useRef(null),ae=d.useMemo(()=>[{id:"new-task",label:t("commandCenter.action.newTask"),description:t("commandCenter.action.newTaskDescription"),keywords:"create compose session",icon:Ke,shortcut:L("newTask"),run:()=>{Z(),requestAnimationFrame(()=>Le())}},{id:"toggle-preview",label:t("commandCenter.action.preview"),description:t("commandCenter.action.previewDescription"),keywords:"diff files logs artifact review",icon:Oe,run:()=>{k?u(!1):p((!B||Y)&&m.getState().previewRequestId===0?{tab:"files"}:void 0)}},{id:"toggle-terminal",label:t("commandCenter.action.terminal"),description:t("commandCenter.action.terminalDescription"),keywords:"shell console command line",icon:$e,run:g},{id:"open-settings",label:t("commandCenter.action.settings"),description:t("commandCenter.action.settingsDescription"),keywords:"preferences general",icon:Qe,run:()=>N("general")},{id:"open-models",label:t("commandCenter.action.models"),description:t("commandCenter.action.modelsDescription"),keywords:"provider llm api configuration",icon:We,run:()=>N("models")},{id:"open-shortcuts",label:t("commandCenter.action.shortcuts"),description:t("commandCenter.action.shortcutsDescription"),keywords:"keyboard hotkey key binding",icon:He,shortcut:L("openCommands"),run:()=>N("shortcuts")},{id:"open-skills",label:t("commandCenter.action.skills"),description:t("commandCenter.action.skillsDescription"),keywords:"capabilities workflow",icon:ze,run:X},{id:"open-mcp",label:t("commandCenter.action.mcp"),description:t("commandCenter.action.mcpDescription"),keywords:"server tools protocol integration",icon:Ge,run:V},{id:"toggle-sidebar",label:t("commandCenter.action.sidebar"),description:t("commandCenter.action.sidebarDescription"),keywords:"navigation layout panel projects",icon:Ue,shortcut:L("toggleSidebar"),run:h}],[B,k,Y,p,N,u,Z,t,V,h,X,g]),w=d.useMemo(()=>it(b,v,A),[A,v,b]),T=d.useMemo(()=>tt(ae,v),[ae,v]),D=s==="tasks"?w.length:T.length,re=d.useMemo(()=>b.filter(e=>!!e.pendingInteraction).length,[b]),$=s==="tasks"?w[f]??null:null,Q=s==="commands"?T[f]??null:null;d.useEffect(()=>{r&&(ee(""),y(0),O(null),I(null))},[s,r]),d.useEffect(()=>{y(0)},[v]),d.useEffect(()=>{var a,l;const e=(a=se.current)==null?void 0:a.querySelector(`[data-task-result-index="${f}"]`);(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})},[f]);const ie=async e=>{const a=R(e),l=U(a),x=E(e,A);O(l),xe.some(j=>j.path===x)&&fe(x);try{await ge(a),i(!1)}catch(j){I(j instanceof Error?j.message:t("taskSwitcher.action.failed"))}finally{O(null)}},ce=async(e,a)=>{I(null);try{const l=R(a);e==="cancel"?await be(l):(await ve(l),i(!1))}catch(l){I(l instanceof Error?l.message:t("taskSwitcher.action.failed"))}},oe=e=>{i(!1),requestAnimationFrame(e.run)},Se=e=>{e.key==="ArrowDown"?(e.preventDefault(),y(a=>D===0?0:(a+1)%D)):e.key==="ArrowUp"?(e.preventDefault(),y(a=>D===0?0:(a-1+D)%D)):e.key==="Enter"&&$?(e.preventDefault(),ie($)):e.key==="Enter"&&Q?(e.preventDefault(),oe(Q)):e.key==="Escape"&&(e.preventDefault(),i(!1))};return n.jsx(Pe,{open:r,onOpenChange:i,children:n.jsxs(Re,{hideCloseButton:!0,onCloseAutoFocus:Ee,className:"top-3 w-[min(680px,calc(100vw-32px))] max-w-none translate-y-0 gap-0 overflow-hidden rounded-xl border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-canvas))] p-0 shadow-2xl sm:top-[18%]",children:[n.jsx(Me,{className:"sr-only",children:t("commandCenter.title")}),n.jsx(qe,{className:"sr-only",children:t("commandCenter.description")}),n.jsxs("div",{className:"flex h-14 items-center gap-3 border-b border-[hsl(var(--deck-hairline))] px-4",children:[n.jsx(G,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),n.jsx("input",{ref:ne,autoFocus:!0,role:"combobox","aria-expanded":"true","aria-controls":"task-switcher-results","aria-activedescendant":$?`task-switcher-result-${f}`:Q?`command-center-result-${f}`:void 0,"aria-label":t(s==="tasks"?"taskSwitcher.searchAria":"commandCenter.searchAria"),placeholder:t(s==="tasks"?"taskSwitcher.placeholder":"commandCenter.placeholder"),value:v,onChange:e=>ee(e.target.value),onKeyDown:Se,className:"h-full min-w-0 flex-1 bg-transparent font-mono text-[14px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),n.jsx("span",{className:"rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:"ESC"})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 pb-2 pt-3",children:[n.jsx("div",{role:"tablist","aria-label":t("commandCenter.modeAria"),className:"flex items-center gap-0.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0.5",children:["tasks","commands"].map(e=>n.jsx("button",{type:"button",role:"tab","aria-selected":s===e,onClick:()=>{c(e),requestAnimationFrame(()=>{var a;return(a=ne.current)==null?void 0:a.focus()})},className:S("rounded-[5px] px-2.5 py-1 font-mono text-[9.5px] uppercase tracking-[0.1em] transition-colors",s===e?"bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] shadow-sm":"text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:t(e==="tasks"?"commandCenter.mode.tasks":"commandCenter.mode.commands")},e))}),n.jsx("span",{children:n.jsx("span",{className:"font-mono text-[9.5px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]",children:s==="commands"?t("commandCenter.actions",{count:T.length}):v?t("taskSwitcher.results",{count:w.length}):q?b.length===0?t("taskSwitcher.indexing"):t("taskSwitcher.indexingLoaded",{count:b.length}):C==="error"?t("sidebar.catalog.incomplete"):re>0?t("taskSwitcher.needsAction",{count:re}):K.length>0?t("taskSwitcher.unread",{count:K.length}):t("taskSwitcher.scope",{count:b.length})})})]}),te&&n.jsx("div",{role:"alert",className:"mx-4 mb-2 rounded-md border border-red-300/70 bg-red-50 px-3 py-2 font-mono text-[10.5px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:te}),n.jsxs("div",{id:"task-switcher-results",ref:se,role:"listbox","aria-label":t(s==="tasks"?"taskSwitcher.resultsAria":"commandCenter.resultsAria"),className:"max-h-[min(460px,60vh)] overflow-y-auto px-2 pb-2",children:[s==="commands"&&n.jsx(nt,{actions:T,selectedIndex:f,onSelect:y,onRun:oe}),s==="tasks"&&w.map((e,a)=>{const l=R(e),x=U(l),j=E(e,A),Ne=_(j),le=Be(l,B),W=a===f,Ce=je===x,Te=K.includes(x),F=J(e),de=e.taskStatus==="running"||e.taskStatus==="queued",me=!!e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled"),H=we.includes(x),z=ye.includes(x);return n.jsxs("div",{id:`task-switcher-result-${a}`,"data-task-result-index":a,"data-session-ref":x,role:"option","aria-selected":W,onMouseEnter:()=>y(a),className:S("group flex min-h-[68px] w-full items-center rounded-lg border border-transparent text-left transition-colors",W?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:[n.jsxs("button",{type:"button",onClick:()=>void ie(e),"aria-label":t("session.action.select",{title:F}),className:"flex min-h-[68px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:S("flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-[hsl(var(--deck-canvas))]",le?"border-[hsl(var(--deck-accent)/0.5)] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))]"),children:e.pendingInteraction?n.jsx(ue,{className:"h-3.5 w-3.5 animate-pulse text-amber-600 dark:text-amber-400"}):e.taskStatus==="running"?n.jsx(_e,{className:"h-3.5 w-3.5 animate-pulse"}):n.jsx(Je,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:F}),le&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.current")}),Te&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.new")}),e.pendingInteraction&&n.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-amber-800 dark:bg-amber-950/60 dark:text-amber-300",children:t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission")}),e.taskRetriedFrom&&n.jsx("span",{title:`${t("session.retriedFrom")} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] text-[hsl(var(--deck-accent))]",children:t("session.retryShort")})]}),n.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Ve,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:Ne})]}),(e.taskWorktreeBranch||e.gitBranch)&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Xe,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:e.taskWorktreeBranch||e.gitBranch})]}),n.jsx("span",{className:"shrink-0",children:e.taskStatus==="queued"&&e.taskQueuePosition!==void 0&&e.taskQueueDepth!==void 0?t("session.queued",{position:e.taskQueuePosition,depth:e.taskQueueDepth}):e.pendingInteraction?t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission"):t(ct[e.taskStatus])}),n.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1",children:[n.jsx(Ye,{className:"h-2.5 w-2.5"}),at(e)]})]})]}),Ce?n.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):n.jsx(he,{className:S("h-3.5 w-3.5 shrink-0 transition-all",W?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]}),(de||me)&&n.jsxs("div",{className:"flex shrink-0 items-center pr-2",children:[de&&n.jsx("button",{type:"button","aria-label":t(H?"session.action.stopping":"session.action.stop",{title:F}),disabled:H,onClick:()=>void ce("cancel",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:H?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Ze,{className:"h-3.5 w-3.5"})}),me&&n.jsx("button",{type:"button","aria-label":t(z?"session.action.retrying":"session.action.retry",{title:F}),disabled:z,onClick:()=>void ce("retry",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60",children:z?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(et,{className:"h-3.5 w-3.5"})})]})]},x)}),s==="tasks"&&w.length===0&&q&&n.jsxs("div",{className:"flex min-h-36 items-center justify-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsx(P,{className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("taskSwitcher.indexing")]}),s==="tasks"&&w.length===0&&!q&&C!=="error"&&!ke&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(G,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("taskSwitcher.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("taskSwitcher.emptyHint")})]}),s==="tasks"&&w.length===0&&C==="error"&&n.jsxs("div",{role:"alert",className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(ue,{className:"mb-3 h-5 w-5 text-amber-500"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("sidebar.catalog.incomplete")})]}),s==="commands"&&T.length===0&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(G,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("commandCenter.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("commandCenter.emptyHint")})]})]}),n.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-4 py-2 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{children:["↑↓ ",t("taskSwitcher.hint.navigate")]}),n.jsxs("span",{children:["↵ ",t("taskSwitcher.hint.open")]}),n.jsxs("span",{className:"ml-auto",children:[L(s==="tasks"?"openCommands":"searchTasks")," ",t(s==="tasks"?"commandCenter.mode.commands":"commandCenter.mode.tasks")]})]})]})})}export{ut as TaskSwitcher};
@@ -1 +1 @@
1
- import{r as t,j as a}from"./vendor-react-DG5dkZ_t.js";import{D as A,o as j,L as R}from"./vendor-xterm-DuYZoU4T.js";import{u as C,b as N,N as F,j as x}from"./index-BNsnHxlt.js";import{j as M,aj as S,X as T}from"./vendor-icons-CsBKlDXT.js";import"./vendor-radix-DXRuAJHH.js";const Y=({workspacePath:b})=>{const c=C(),{isTerminalOpen:l,toggleTerminal:y}=N(),[s,z]=t.useState(!1),[p,u]=t.useState(!1),g=F(),m=t.useRef(null),i=t.useRef(null),h=t.useRef(null),o=t.useRef(null),E=t.useRef(null),B=t.useCallback(()=>{var f;if(((f=o.current)==null?void 0:f.readyState)===WebSocket.OPEN)return;const r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=b?`${r}?cwd=${encodeURIComponent(b)}`:r,n=new WebSocket(e);o.current=n,n.onopen=()=>{u(!0)},n.onmessage=w=>{var d;(d=i.current)==null||d.write(w.data)},n.onclose=()=>{u(!1)},n.onerror=()=>{u(!1)}},[b]),k=t.useCallback(()=>{o.current&&(o.current.close(),o.current=null),u(!1)},[]),v=t.useCallback(r=>{var e;((e=o.current)==null?void 0:e.readyState)===WebSocket.OPEN&&o.current.send(r)},[]);return t.useEffect(()=>(E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{var r;return(r=E.current)==null?void 0:r.focus({preventScroll:!0})}),[]),t.useEffect(()=>{if(!l||!m.current||i.current)return;const r={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new A({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:r}),n=new j,f=new R;e.loadAddon(n),e.loadAddon(f),e.open(m.current),n.fit();const w=requestAnimationFrame(()=>e.focus());return e.onData(d=>{v(d)}),i.current=e,h.current=n,B(),()=>{cancelAnimationFrame(w),k(),e.dispose(),i.current=null,h.current=null}},[l,B,k,v]),t.useEffect(()=>{i.current&&(i.current.options.theme=g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[g]),t.useEffect(()=>{if(!l||s)return;const r=()=>{var n;(n=h.current)==null||n.fit()};window.addEventListener("resize",r);const e=setTimeout(r,100);return()=>{window.removeEventListener("resize",r),clearTimeout(e)}},[l,s]),l?a.jsxs("div",{role:"region","aria-label":c("terminal.title"),className:x("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",s?"h-10":"h-[min(18rem,45dvh)]"),children:[a.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),a.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:c("terminal.title")}),a.jsx("span",{role:"status","aria-label":c(p?"terminal.status.connected":"terminal.status.disconnected"),className:x("w-2 h-2 rounded-full",p?"bg-green-500":"bg-zinc-600")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>z(!s),"aria-label":c(s?"terminal.action.restore":"terminal.action.minimize"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(S,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>{k(),y()},"aria-label":c("terminal.action.close"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(T,{className:"h-4 w-4"})})]})]}),a.jsx("div",{ref:m,className:x("h-[calc(100%-40px)] p-2",s&&"hidden")})]}):null};export{Y as TerminalPanel};
1
+ import{r as t,j as a}from"./vendor-react-DG5dkZ_t.js";import{D as A,o as j,L as R}from"./vendor-xterm-DuYZoU4T.js";import{u as C,b as N,Q as F,j as x}from"./index-bjyn3NHs.js";import{j as M,al as S,X as T}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";const Y=({workspacePath:b})=>{const c=C(),{isTerminalOpen:l,toggleTerminal:y}=N(),[s,z]=t.useState(!1),[p,u]=t.useState(!1),g=F(),m=t.useRef(null),i=t.useRef(null),h=t.useRef(null),o=t.useRef(null),E=t.useRef(null),B=t.useCallback(()=>{var f;if(((f=o.current)==null?void 0:f.readyState)===WebSocket.OPEN)return;const r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=b?`${r}?cwd=${encodeURIComponent(b)}`:r,n=new WebSocket(e);o.current=n,n.onopen=()=>{u(!0)},n.onmessage=w=>{var d;(d=i.current)==null||d.write(w.data)},n.onclose=()=>{u(!1)},n.onerror=()=>{u(!1)}},[b]),k=t.useCallback(()=>{o.current&&(o.current.close(),o.current=null),u(!1)},[]),v=t.useCallback(r=>{var e;((e=o.current)==null?void 0:e.readyState)===WebSocket.OPEN&&o.current.send(r)},[]);return t.useEffect(()=>(E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{var r;return(r=E.current)==null?void 0:r.focus({preventScroll:!0})}),[]),t.useEffect(()=>{if(!l||!m.current||i.current)return;const r={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new A({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:r}),n=new j,f=new R;e.loadAddon(n),e.loadAddon(f),e.open(m.current),n.fit();const w=requestAnimationFrame(()=>e.focus());return e.onData(d=>{v(d)}),i.current=e,h.current=n,B(),()=>{cancelAnimationFrame(w),k(),e.dispose(),i.current=null,h.current=null}},[l,B,k,v]),t.useEffect(()=>{i.current&&(i.current.options.theme=g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[g]),t.useEffect(()=>{if(!l||s)return;const r=()=>{var n;(n=h.current)==null||n.fit()};window.addEventListener("resize",r);const e=setTimeout(r,100);return()=>{window.removeEventListener("resize",r),clearTimeout(e)}},[l,s]),l?a.jsxs("div",{role:"region","aria-label":c("terminal.title"),className:x("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",s?"h-10":"h-[min(18rem,45dvh)]"),children:[a.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),a.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:c("terminal.title")}),a.jsx("span",{role:"status","aria-label":c(p?"terminal.status.connected":"terminal.status.disconnected"),className:x("w-2 h-2 rounded-full",p?"bg-green-500":"bg-zinc-600")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>z(!s),"aria-label":c(s?"terminal.action.restore":"terminal.action.minimize"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(S,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>{k(),y()},"aria-label":c("terminal.action.close"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(T,{className:"h-4 w-4"})})]})]}),a.jsx("div",{ref:m,className:x("h-[calc(100%-40px)] p-2",s&&"hidden")})]}):null};export{Y as TerminalPanel};