blade-code 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +20 -5
  2. package/dist/blade.js +4 -4
  3. package/dist/{chunk-1v2n922p.js → chunk-0h81hxkw.js} +1 -1
  4. package/dist/chunk-11qty4fd.js +13 -0
  5. package/dist/chunk-29r7z43j.js +2 -0
  6. package/dist/chunk-2beq0syt.js +2 -0
  7. package/dist/chunk-3nx2579c.js +44 -0
  8. package/dist/chunk-44wkjs2j.js +114 -0
  9. package/dist/chunk-49sytjma.js +22 -0
  10. package/dist/chunk-4vaywb2r.js +2 -0
  11. package/dist/chunk-51wa5fct.js +25 -0
  12. package/dist/{chunk-d7y2mf7c.js → chunk-5pvxw7sd.js} +2 -2
  13. package/dist/chunk-6g21dh3n.js +1 -0
  14. package/dist/chunk-6hj2dk75.js +3 -0
  15. package/dist/chunk-6n5xdf2r.js +2 -0
  16. package/dist/chunk-793k86j6.js +1485 -0
  17. package/dist/chunk-859m18ra.js +160 -0
  18. package/dist/chunk-88vy9hh0.js +4 -0
  19. package/dist/{chunk-gdm1xzvp.js → chunk-8nm1hqr1.js} +2 -2
  20. package/dist/chunk-a7nbn5kf.js +3 -0
  21. package/dist/chunk-a8y9xbxw.js +99 -0
  22. package/dist/chunk-af49jmns.js +5 -0
  23. package/dist/chunk-asbp4cv4.js +1 -0
  24. package/dist/chunk-beqaxytd.js +2 -0
  25. package/dist/{chunk-ax7bx0j8.js → chunk-d3236505.js} +1 -1
  26. package/dist/chunk-d9ddpapp.js +18 -0
  27. package/dist/chunk-dnhb7k9g.js +4 -0
  28. package/dist/chunk-f19yx9an.js +1 -0
  29. package/dist/chunk-fjw32ex5.js +2 -0
  30. package/dist/chunk-g0jb7v73.js +1 -0
  31. package/dist/chunk-g2972yzq.js +1 -0
  32. package/dist/chunk-gafbzeyk.js +1 -0
  33. package/dist/chunk-gv8gfnz8.js +1 -0
  34. package/dist/chunk-h7kj4gvj.js +2 -0
  35. package/dist/chunk-hefv4415.js +45 -0
  36. package/dist/{chunk-rmfk5f9m.js → chunk-j457sh1b.js} +2 -2
  37. package/dist/chunk-j51fwecz.js +636 -0
  38. package/dist/chunk-jv4nkkb5.js +1 -0
  39. package/dist/{chunk-2fbwmdvg.js → chunk-jxv6r0c7.js} +2 -2
  40. package/dist/chunk-jzrqjzjm.js +174 -0
  41. package/dist/chunk-k6qwdjyy.js +25 -0
  42. package/dist/{chunk-x40fkg4z.js → chunk-km7m66vw.js} +2 -2
  43. package/dist/{chunk-aq7wf2zt.js → chunk-kq5my0yy.js} +2 -2
  44. package/dist/chunk-m3g8hz67.js +1 -0
  45. package/dist/chunk-m3tx1k0s.js +1 -0
  46. package/dist/chunk-m78ceafk.js +1 -0
  47. package/dist/{chunk-ppyg431d.js → chunk-mjp61rqd.js} +1 -1
  48. package/dist/chunk-mrpvdvn4.js +3 -0
  49. package/dist/chunk-mz1jrcgc.js +6 -0
  50. package/dist/chunk-nah0cbnp.js +2 -0
  51. package/dist/chunk-p6yed31x.js +1 -0
  52. package/dist/chunk-pms05z02.js +2 -0
  53. package/dist/chunk-px5ck9pf.js +2 -0
  54. package/dist/chunk-qev36qrb.js +2 -0
  55. package/dist/chunk-qk0akpsg.js +1 -0
  56. package/dist/chunk-rppak8ep.js +6 -0
  57. package/dist/{chunk-z0qxaky4.js → chunk-sndbq5xt.js} +1 -1
  58. package/dist/chunk-t7ej11xd.js +9 -0
  59. package/dist/chunk-t8q9ks7e.js +3 -0
  60. package/dist/{chunk-mns8e65q.js → chunk-th7sxjtk.js} +2 -2
  61. package/dist/chunk-tkd04sjm.js +1 -0
  62. package/dist/chunk-tkr4d9ej.js +1 -0
  63. package/dist/{chunk-w3me85va.js → chunk-vjpd3nee.js} +2 -2
  64. package/dist/chunk-vvy506b3.js +3 -0
  65. package/dist/chunk-w1wp1t52.js +10 -0
  66. package/dist/{chunk-bc6wbcrs.js → chunk-wvj9h7mb.js} +1 -1
  67. package/dist/{chunk-j8en7x02.js → chunk-zkbf8n6y.js} +1 -1
  68. package/dist/web/assets/ChatView-CnwNosSG.js +7 -0
  69. package/dist/web/assets/CodeBlockHighlighter-CBo_AxjZ.js +8 -0
  70. package/dist/web/assets/FilePreview-hNo6RCNY.js +8 -0
  71. package/dist/web/assets/MarkdownRenderer-BON4fqSr.js +30 -0
  72. package/dist/web/assets/McpModal-Go_8v1Vu.js +5 -0
  73. package/dist/web/assets/SettingsModal-CRu1zGQf.js +1 -0
  74. package/dist/web/assets/TaskSwitcher-Ds8CBVtp.js +1 -0
  75. package/dist/web/assets/TerminalPanel-Dm4bu6ib.js +1 -0
  76. package/dist/web/assets/index-BNsnHxlt.js +32 -0
  77. package/dist/web/assets/index-DI8ZWdWH.js +11 -0
  78. package/dist/web/assets/index-DVTiq-7u.css +1 -0
  79. package/dist/web/assets/vendor-icons-CsBKlDXT.js +381 -0
  80. package/dist/web/assets/vendor-radix-DXRuAJHH.js +45 -0
  81. package/dist/web/assets/vendor-react-DG5dkZ_t.js +49 -0
  82. package/dist/web/index.html +5 -2
  83. package/package.json +36 -34
  84. package/dist/chunk-0abtfzm6.js +0 -1
  85. package/dist/chunk-0zkhjsbv.js +0 -1
  86. package/dist/chunk-119fhp5q.js +0 -9
  87. package/dist/chunk-1rpgvk3r.js +0 -10
  88. package/dist/chunk-3qgj2y5r.js +0 -1
  89. package/dist/chunk-45bme7n9.js +0 -2
  90. package/dist/chunk-5jq01mg6.js +0 -4
  91. package/dist/chunk-5nye3k5w.js +0 -1
  92. package/dist/chunk-7pevqbfd.js +0 -2
  93. package/dist/chunk-8dqvnx7n.js +0 -2
  94. package/dist/chunk-8edsvxf3.js +0 -1
  95. package/dist/chunk-8vemqfe4.js +0 -2
  96. package/dist/chunk-8vtznxpq.js +0 -5
  97. package/dist/chunk-936ft6kq.js +0 -2
  98. package/dist/chunk-9ax02vtg.js +0 -22
  99. package/dist/chunk-9qknesxs.js +0 -6
  100. package/dist/chunk-acegy4td.js +0 -3
  101. package/dist/chunk-aewrn5xp.js +0 -1
  102. package/dist/chunk-b10vr4xj.js +0 -2
  103. package/dist/chunk-bfgm5k3e.js +0 -1566
  104. package/dist/chunk-cf3fhs7j.js +0 -1
  105. package/dist/chunk-e1586s4t.js +0 -1
  106. package/dist/chunk-enk621t7.js +0 -98
  107. package/dist/chunk-fpr6d8zc.js +0 -2
  108. package/dist/chunk-gagt42k2.js +0 -13
  109. package/dist/chunk-gm62cfjw.js +0 -1
  110. package/dist/chunk-h3bjmkvz.js +0 -1
  111. package/dist/chunk-jyr9417h.js +0 -34
  112. package/dist/chunk-mcnfbhpr.js +0 -6
  113. package/dist/chunk-mpkr3s6b.js +0 -3
  114. package/dist/chunk-n9tgxfvw.js +0 -615
  115. package/dist/chunk-qxhrzws6.js +0 -1
  116. package/dist/chunk-r6h7eja3.js +0 -151
  117. package/dist/chunk-r8pjwjt6.js +0 -1
  118. package/dist/chunk-rrg9bw8r.js +0 -25
  119. package/dist/chunk-wtxwny0p.js +0 -41
  120. package/dist/chunk-x548f12z.js +0 -2
  121. package/dist/chunk-xtfzjb72.js +0 -6
  122. package/dist/web/assets/CodeBlockHighlighter-D8_cOYpG.js +0 -1
  123. package/dist/web/assets/FilePreview-DpovIbME.js +0 -7
  124. package/dist/web/assets/MarkdownRenderer-73wC_SGk.js +0 -1
  125. package/dist/web/assets/McpModal-CIpxuyTG.js +0 -5
  126. package/dist/web/assets/SettingsModal-BBa1libe.js +0 -1
  127. package/dist/web/assets/SettingsStore-C8YBWQPS.js +0 -1
  128. package/dist/web/assets/SkillsModal-DArZ-nCX.js +0 -1
  129. package/dist/web/assets/TerminalPanel-BX7C7qiD.js +0 -1
  130. package/dist/web/assets/index-Ch0eqSLM.css +0 -1
  131. package/dist/web/assets/index-DIWzaS2_.js +0 -16
  132. package/dist/web/assets/useRequest-B4kP-cmG.js +0 -1
  133. package/dist/web/assets/vendor-icons-DBM55KTG.js +0 -251
  134. package/dist/web/assets/vendor-markdown-b9iCqZWK.js +0 -36
  135. package/dist/web/assets/vendor-monaco-w6PwaWGP.js +0 -11
  136. package/dist/web/assets/vendor-radix-DyP_DOwV.js +0 -45
  137. package/dist/web/assets/vendor-react-FPIC4Czm.js +0 -49
@@ -0,0 +1,5 @@
1
+ import{r as l,e as ue,g as lt,j as t}from"./vendor-react-DG5dkZ_t.js";import{_ as w,n as N,o as _,p as Fe,q as Te,r as ct}from"./vendor-radix-DXRuAJHH.js";import{b as At,D as Pe,e as Me,A as Ft,g as Oe,j as D,v as G,w as Tt}from"./index-BNsnHxlt.js";import{a as Je,i as Rt,X as Be,f as qe,L as fe,k as Pt,U as Ve,C as Mt,D as Ot}from"./vendor-icons-CsBKlDXT.js";var Bt=function(e){return function(n,r){var o=l.useRef(!1);e(function(){return function(){o.current=!1}},[]),e(function(){if(!o.current)o.current=!0;else return n()},r)}},dt=function(e){return typeof e=="function"},W=function(e){var n=l.useRef(e);n.current=l.useMemo(function(){return e},[e]);var r=l.useRef(void 0);return r.current||(r.current=function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];return n.current.apply(this,o)}),r.current};const be=Bt(l.useEffect);var ut=function(e,n){var r=n.manual,o=n.ready,s=o===void 0?!0:o,i=n.defaultParams,c=i===void 0?[]:i,u=n.refreshDeps,x=u===void 0?[]:u,p=n.refreshDepsAction,b=l.useRef(!1);return b.current=!1,be(function(){!r&&s&&(b.current=!0,e.run.apply(e,w([],N(c),!1)))},[s]),be(function(){b.current||r||(b.current=!0,p?p():e.refresh())},w([],N(x),!1)),{onBefore:function(){if(!s)return{stopNow:!0}}}};ut.onInit=function(e){var n=e.ready,r=n===void 0?!0:n,o=e.manual;return{loading:!o&&r}};function Re(e,n){if(e===n)return!0;for(var r=0;r<e.length;r++)if(!Object.is(e[r],n[r]))return!1;return!0}var ft=function(e,n){var r=l.useRef({deps:n,obj:void 0,initialized:!1}).current;return(r.initialized===!1||!Re(r.deps,n))&&(r.deps=n,r.obj=e(),r.initialized=!0),r.obj};function Ee(e){var n=l.useRef(e);return n.current=e,n}var se=function(e){var n=Ee(e);l.useEffect(function(){return function(){n.current()}},[])},me=new Map,Dt=function(e,n,r){var o=me.get(e);o!=null&&o.timer&&clearTimeout(o.timer);var s=void 0;n>-1&&(s=setTimeout(function(){me.delete(e)},n)),me.set(e,_(_({},r),{timer:s}))},$t=function(e){return me.get(e)},xe=new Map,Lt=function(e){return xe.get(e)},_t=function(e,n){xe.set(e,n),n.then(function(r){return xe.delete(e),r}).catch(function(){xe.delete(e)})},J={},It=function(e,n){J[e]&&J[e].forEach(function(r){return r(n)})},Se=function(e,n){return J[e]||(J[e]=[]),J[e].push(n),function(){var o=J[e].indexOf(n);J[e].splice(o,1)}},Ht=function(e,n){var r=n.cacheKey,o=n.cacheTime,s=o===void 0?5*60*1e3:o,i=n.staleTime,c=i===void 0?0:i,u=n.setCache,x=n.getCache,p=l.useRef(void 0),b=l.useRef(void 0),d=function(h,f){u?u(f):Dt(h,s,f),It(h,f.data)},v=function(h,f){return f===void 0&&(f=[]),x?x(f):$t(h)};return ft(function(){if(r){var h=v(r);h&&Object.hasOwnProperty.call(h,"data")&&(e.state.data=h.data,e.state.params=h.params,(c===-1||Date.now()-h.time<=c)&&(e.state.loading=!1)),p.current=Se(r,function(f){e.setState({data:f})})}},[]),se(function(){var h;(h=p.current)===null||h===void 0||h.call(p)}),r?{onBefore:function(h){var f=v(r,h);return!f||!Object.hasOwnProperty.call(f,"data")?{}:c===-1||Date.now()-f.time<=c?{loading:!1,data:f==null?void 0:f.data,error:void 0,returnNow:!0}:{data:f==null?void 0:f.data,error:void 0}},onRequest:function(h,f){var y=Lt(r);return y&&y!==b.current?{servicePromise:y}:(y=h.apply(void 0,w([],N(f),!1)),b.current=y,_t(r,y),{servicePromise:y})},onSuccess:function(h,f){var y;r&&((y=p.current)===null||y===void 0||y.call(p),d(r,{data:h,params:f,time:Date.now()}),p.current=Se(r,function(T){e.setState({data:T})}))},onMutate:function(h){var f;r&&((f=p.current)===null||f===void 0||f.call(p),d(r,{data:h,params:e.state.params,time:Date.now()}),p.current=Se(r,function(y){e.setState({data:y})}))}}:{}};function Wt(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}var De=Wt,Ut=typeof ue=="object"&&ue&&ue.Object===Object&&ue,zt=Ut,Gt=zt,Jt=typeof self=="object"&&self&&self.Object===Object&&self,qt=Gt||Jt||Function("return this")(),mt=qt,Vt=mt,Xt=function(){return Vt.Date.now()},Yt=Xt,Kt=/\s/;function Qt(e){for(var n=e.length;n--&&Kt.test(e.charAt(n)););return n}var Zt=Qt,en=Zt,tn=/^\s+/;function nn(e){return e&&e.slice(0,en(e)+1).replace(tn,"")}var rn=nn,an=mt,on=an.Symbol,xt=on,Xe=xt,pt=Object.prototype,sn=pt.hasOwnProperty,ln=pt.toString,oe=Xe?Xe.toStringTag:void 0;function cn(e){var n=sn.call(e,oe),r=e[oe];try{e[oe]=void 0;var o=!0}catch{}var s=ln.call(e);return o&&(n?e[oe]=r:delete e[oe]),s}var dn=cn,un=Object.prototype,fn=un.toString;function mn(e){return fn.call(e)}var xn=mn,Ye=xt,pn=dn,hn=xn,vn="[object Null]",bn="[object Undefined]",Ke=Ye?Ye.toStringTag:void 0;function gn(e){return e==null?e===void 0?bn:vn:Ke&&Ke in Object(e)?pn(e):hn(e)}var En=gn;function jn(e){return e!=null&&typeof e=="object"}var yn=jn,kn=En,Nn=yn,Cn="[object Symbol]";function wn(e){return typeof e=="symbol"||Nn(e)&&kn(e)==Cn}var Sn=wn,An=rn,Qe=De,Fn=Sn,Ze=NaN,Tn=/^[-+]0x[0-9a-f]+$/i,Rn=/^0b[01]+$/i,Pn=/^0o[0-7]+$/i,Mn=parseInt;function On(e){if(typeof e=="number")return e;if(Fn(e))return Ze;if(Qe(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=Qe(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=An(e);var r=Rn.test(e);return r||Pn.test(e)?Mn(e.slice(2),r?2:8):Tn.test(e)?Ze:+e}var Bn=On,Dn=De,Ae=Yt,et=Bn,$n="Expected a function",Ln=Math.max,_n=Math.min;function In(e,n,r){var o,s,i,c,u,x,p=0,b=!1,d=!1,v=!0;if(typeof e!="function")throw new TypeError($n);n=et(n)||0,Dn(r)&&(b=!!r.leading,d="maxWait"in r,i=d?Ln(et(r.maxWait)||0,n):i,v="trailing"in r?!!r.trailing:v);function h(E){var S=o,R=s;return o=s=void 0,p=E,c=e.apply(R,S),c}function f(E){return p=E,u=setTimeout(M,n),b?h(E):c}function y(E){var S=E-x,R=E-p,H=n-S;return d?_n(H,i-R):H}function T(E){var S=E-x,R=E-p;return x===void 0||S>=n||S<0||d&&R>=i}function M(){var E=Ae();if(T(E))return C(E);u=setTimeout(M,y(E))}function C(E){return u=void 0,v&&o?h(E):(o=s=void 0,c)}function I(){u!==void 0&&clearTimeout(u),p=0,o=x=s=u=void 0}function $(){return u===void 0?c:C(Ae())}function O(){var E=Ae(),S=T(E);if(o=arguments,s=this,x=E,S){if(u===void 0)return f(x);if(d)return clearTimeout(u),u=setTimeout(M,n),h(x)}return u===void 0&&(u=setTimeout(M,n)),c}return O.cancel=I,O.flush=$,O}var ht=In;const vt=lt(ht);var Hn=function(e,n){var r=n.debounceWait,o=n.debounceLeading,s=n.debounceTrailing,i=n.debounceMaxWait,c=l.useRef(void 0),u=l.useMemo(function(){var x={};return o!==void 0&&(x.leading=o),s!==void 0&&(x.trailing=s),i!==void 0&&(x.maxWait=i),x},[o,s,i]);return l.useEffect(function(){if(r){var x=e.runAsync.bind(e);return c.current=vt(function(p){p()},r,u),e.runAsync=function(){for(var p=[],b=0;b<arguments.length;b++)p[b]=arguments[b];return new Promise(function(d,v){var h;(h=c.current)===null||h===void 0||h.call(c,function(){x.apply(void 0,w([],N(p),!1)).then(d).catch(v)})})},function(){var p;(p=c.current)===null||p===void 0||p.cancel(),e.runAsync=x}}},[r,u]),r?{onCancel:function(){var x;(x=c.current)===null||x===void 0||x.cancel()}}:{}},Wn=function(e,n){var r=n.loadingDelay,o=n.ready,s=l.useRef(void 0);if(!r)return{};var i=function(){s.current&&clearTimeout(s.current)};return{onBefore:function(){return i(),o!==!1&&(s.current=setTimeout(function(){e.setState({loading:!0})},r)),{loading:!1}},onFinally:function(){i()},onCancel:function(){i()}}},ie=!!(typeof window<"u"&&window.document&&window.document.createElement);function $e(){return ie?document.visibilityState!=="hidden":!0}var pe=new Set;function Un(e){return pe.add(e),function(){pe.has(e)&&pe.delete(e)}}if(ie){var zn=function(){$e()&&pe.forEach(function(e){return e()})};window.addEventListener("visibilitychange",zn,!1)}var Gn=function(e,n){var r=n.pollingInterval,o=n.pollingWhenHidden,s=o===void 0?!0:o,i=n.pollingErrorRetryCount,c=i===void 0?-1:i,u=l.useRef(void 0),x=l.useRef(void 0),p=l.useRef(0),b=function(){var d;u.current&&clearTimeout(u.current),(d=x.current)===null||d===void 0||d.call(x)};return be(function(){r||b()},[r]),r?{onBefore:function(){b()},onError:function(){p.current+=1},onSuccess:function(){p.current=0},onFinally:function(){c===-1||c!==-1&&p.current<=c?u.current=setTimeout(function(){!s&&!$e()?x.current=Un(function(){e.refresh()}):e.refresh()},r):p.current=0},onCancel:function(){b()}}:{}};function Jn(e,n){var r=!1;return function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];r||(r=!0,e.apply(void 0,w([],N(o),!1)),setTimeout(function(){r=!1},n))}}var qn=function(){return ie&&typeof navigator.onLine<"u"?navigator.onLine:!0},he=new Set;function Vn(e){return he.add(e),function(){he.has(e)&&he.delete(e)}}if(ie){var tt=function(){!$e()||!qn()||he.forEach(function(e){return e()})};window.addEventListener("visibilitychange",tt,!1),window.addEventListener("focus",tt,!1)}var Xn=function(e,n){var r=n.refreshOnWindowFocus,o=n.focusTimespan,s=o===void 0?5e3:o,i=l.useRef(void 0),c=function(){var u;(u=i.current)===null||u===void 0||u.call(i)};return l.useEffect(function(){if(r){var u=Jn(e.refresh.bind(e),s);i.current=Vn(function(){u()})}return function(){c()}},[r,s]),se(function(){c()}),{}},Yn=function(e,n){var r=n.retryInterval,o=n.retryCount,s=l.useRef(void 0),i=l.useRef(0),c=l.useRef(!1);return o?{onBefore:function(){c.current||(i.current=0),c.current=!1,s.current&&clearTimeout(s.current)},onSuccess:function(){i.current=0},onError:function(){if(i.current+=1,o===-1||i.current<=o){var u=r??Math.min(1e3*Math.pow(2,i.current),3e4);s.current=setTimeout(function(){c.current=!0,e.refresh()},u)}else i.current=0},onCancel:function(){i.current=0,s.current&&clearTimeout(s.current)}}:{}},Kn=ht,Qn=De,Zn="Expected a function";function er(e,n,r){var o=!0,s=!0;if(typeof e!="function")throw new TypeError(Zn);return Qn(r)&&(o="leading"in r?!!r.leading:o,s="trailing"in r?!!r.trailing:s),Kn(e,n,{leading:o,maxWait:n,trailing:s})}var tr=er;const nr=lt(tr);var rr=function(e,n){var r=n.throttleWait,o=n.throttleLeading,s=n.throttleTrailing,i=l.useRef(void 0),c={};return o!==void 0&&(c.leading=o),s!==void 0&&(c.trailing=s),l.useEffect(function(){if(r){var u=e.runAsync.bind(e);return i.current=nr(function(x){x()},r,c),e.runAsync=function(){for(var x=[],p=0;p<arguments.length;p++)x[p]=arguments[p];return new Promise(function(b,d){var v;(v=i.current)===null||v===void 0||v.call(i,function(){u.apply(void 0,w([],N(x),!1)).then(b).catch(d)})})},function(){var x;e.runAsync=u,(x=i.current)===null||x===void 0||x.cancel()}}},[r,o,s]),r?{onCancel:function(){var u;(u=i.current)===null||u===void 0||u.cancel()}}:{}},ar=function(e){l.useEffect(function(){var n=e==null?void 0:e();if(!(n&&typeof n=="object"&&typeof n.then=="function"))return n},[])},or=function(){var e=N(l.useState({}),2),n=e[1];return W(function(){return n({})})},sr=function(){function e(n,r,o,s){s===void 0&&(s={}),this.serviceRef=n,this.options=r,this.subscribe=o,this.initState=s,this.pluginImpls=[],this.count=0,this.state={loading:!1,params:void 0,data:void 0,error:void 0},this.state=_(_(_({},this.state),{loading:!r.manual}),s)}return e.prototype.setState=function(n){n===void 0&&(n={}),this.state=_(_({},this.state),n),this.subscribe()},e.prototype.runPluginHandler=function(n){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var s=this.pluginImpls.map(function(i){var c;return(c=i[n])===null||c===void 0?void 0:c.call.apply(c,w([i],N(r),!1))}).filter(Boolean);return Object.assign.apply(Object,w([{}],N(s),!1))},e.prototype.runAsync=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return Fe(this,void 0,void 0,function(){var o,s,i,c,u,x,p,b,d,v,h,f,y,T,M,C,I,$,O,E,S;return Te(this,function(R){switch(R.label){case 0:if(this.count+=1,o=this.count,s=this.runPluginHandler("onBefore",n),i=s.stopNow,c=i===void 0?!1:i,u=s.returnNow,x=u===void 0?!1:u,p=ct(s,["stopNow","returnNow"]),c)return[2,Promise.resolve(p.data)];if(this.setState(_({loading:!0,params:n},p)),x)return[2,Promise.resolve(p.data)];(y=(f=this.options).onBefore)===null||y===void 0||y.call(f,n),R.label=1;case 1:return R.trys.push([1,3,,4]),b=this.runPluginHandler("onRequest",this.serviceRef.current,n).servicePromise,b||(b=(h=this.serviceRef).current.apply(h,w([],N(n),!1))),[4,b];case 2:return d=R.sent(),o!==this.count?[2,new Promise(function(){})]:(this.setState({data:d,error:void 0,loading:!1}),(M=(T=this.options).onSuccess)===null||M===void 0||M.call(T,d,n),this.runPluginHandler("onSuccess",d,n),(I=(C=this.options).onFinally)===null||I===void 0||I.call(C,n,d,void 0),o===this.count&&this.runPluginHandler("onFinally",n,d,void 0),[2,d]);case 3:if(v=R.sent(),o!==this.count)return[2,new Promise(function(){})];throw this.setState({error:v,loading:!1}),(O=($=this.options).onError)===null||O===void 0||O.call($,v,n),this.runPluginHandler("onError",v,n),(S=(E=this.options).onFinally)===null||S===void 0||S.call(E,n,void 0,v),o===this.count&&this.runPluginHandler("onFinally",n,void 0,v),v;case 4:return[2]}})})},e.prototype.run=function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];this.runAsync.apply(this,w([],N(r),!1)).catch(function(s){n.options.onError||console.error(s)})},e.prototype.cancel=function(){this.count+=1,this.setState({loading:!1}),this.runPluginHandler("onCancel")},e.prototype.refresh=function(){this.run.apply(this,w([],N(this.state.params||[]),!1))},e.prototype.refreshAsync=function(){return this.runAsync.apply(this,w([],N(this.state.params||[]),!1))},e.prototype.mutate=function(n){var r=dt(n)?n(this.state.data):n;this.runPluginHandler("onMutate",r),this.setState({data:r})},e}();function ir(e,n,r){n===void 0&&(n={}),r===void 0&&(r=[]);var o=n.manual,s=o===void 0?!1:o,i=n.ready,c=i===void 0?!0:i,u=ct(n,["manual","ready"]),x=_({manual:s,ready:c},u),p=Ee(e),b=or(),d=ft(function(){var v=r.map(function(h){var f;return(f=h==null?void 0:h.onInit)===null||f===void 0?void 0:f.call(h,x)}).filter(Boolean);return new sr(p,x,b,Object.assign.apply(Object,w([{}],N(v),!1)))},[]);return d.options=x,d.pluginImpls=r.map(function(v){return v(d,x)}),ar(function(){if(!s&&c){var v=d.state.params||n.defaultParams||[];d.run.apply(d,w([],N(v),!1))}}),se(function(){d.cancel()}),{loading:d.state.loading,data:d.state.data,error:d.state.error,params:d.state.params||[],cancel:W(d.cancel.bind(d)),refresh:W(d.refresh.bind(d)),refreshAsync:W(d.refreshAsync.bind(d)),run:W(d.run.bind(d)),runAsync:W(d.runAsync.bind(d)),mutate:W(d.mutate.bind(d))}}function ve(e,n,r){return ir(e,n,w(w([],N([]),!1),[Hn,Wn,Gn,Xn,rr,ut,Ht,Yn],!1))}function ge(e,n){if(ie){if(!e)return n;var r;return dt(e)?r=e():"current"in e?r=e.current:r=e,r}}var lr=function(e){var n=function(r,o,s){var i=l.useRef(!1),c=l.useRef([]),u=l.useRef([]),x=l.useRef(void 0);e(function(){var p,b=Array.isArray(s)?s:[s],d=b.map(function(v){return ge(v)});if(!i.current){i.current=!0,c.current=d,u.current=o,x.current=r();return}(d.length!==c.current.length||!Re(c.current,d)||!Re(u.current,o))&&((p=x.current)===null||p===void 0||p.call(x),c.current=d,u.current=o,x.current=r())}),se(function(){var p;(p=x.current)===null||p===void 0||p.call(x),i.current=!1})};return n},cr=lr(l.useEffect);function dr(){var e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,n=typeof self=="object"&&self&&self.Object===Object&&self;return e||n}dr()||(global.Date=Date);function ur(e,n){var r,o=Ee(e),s=(r=n==null?void 0:n.wait)!==null&&r!==void 0?r:1e3,i=l.useMemo(function(){return vt(function(){for(var c=[],u=0;u<arguments.length;u++)c[u]=arguments[u];return o.current.apply(o,w([],N(c),!1))},s,n)},[]);return se(function(){i.cancel()}),{run:i,cancel:i.cancel,flush:i.flush}}function fr(e,n,r){r===void 0&&(r={});var o=r.enable,s=o===void 0?!0:o,i=Ee(n);cr(function(){if(s){var c=ge(r.target,window);if(c!=null&&c.addEventListener){var u=function(p){return i.current(p)},x=Array.isArray(e)?e:[e];return x.forEach(function(p){c.addEventListener(p,u,{capture:r.capture,once:r.once,passive:r.passive})}),function(){x.forEach(function(p){c.removeEventListener(p,u,{capture:r.capture})})}}}},[e,r.capture,r.once,r.passive,s],r.target)}var mr=function(e){return e===document||e===document.documentElement||e===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):e.scrollTop},nt=function(e){return e.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},xr=function(e){return e.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},pr=function(e,n){n===void 0&&(n={});var r=n.target,o=n.isNoMore,s=n.threshold,i=s===void 0?100:s,c=n.direction,u=c===void 0?"bottom":c,x=n.reloadDeps,p=x===void 0?[]:x,b=n.manual,d=n.onBefore,v=n.onSuccess,h=n.onError,f=n.onFinally,y=N(l.useState(),2),T=y[0],M=y[1],C=N(l.useState(!1),2),I=C[0],$=C[1],O=u==="top",E=l.useRef(void 0),S=l.useRef(0),R=l.useMemo(function(){return o?o(T):!1},[T]),H=ve(function(k){return Fe(void 0,void 0,void 0,function(){var A;return Te(this,function(F){switch(F.label){case 0:return[4,e(k)];case 1:return A=F.sent(),[2,{currentData:A,lastData:k}]}})})},{manual:b,onFinally:function(k,A,F){$(!1),f==null||f(A==null?void 0:A.currentData,F)},onBefore:function(){return d==null?void 0:d()},onSuccess:function(k){var A,F,P;k.lastData?M(_(_({},k.currentData),{list:O?w(w([],N(k.currentData.list),!1),N((F=k.lastData.list)!==null&&F!==void 0?F:[]),!1):w(w([],N((P=k.lastData.list)!==null&&P!==void 0?P:[]),!1),N(k.currentData.list),!1)})):M(_(_({},k.currentData),{list:w([],N((A=k.currentData.list)!==null&&A!==void 0?A:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(O){var B=ge(r);if(B=B===document?document.documentElement:B,B){var re=nt(B);B.scrollTo(0,re-S.current)}}else X()})}),v==null||v(k.currentData)},onError:function(k){return h==null?void 0:h(k)}}),Q=H.loading,q=H.error,Z=H.run,V=H.runAsync,je=H.cancel,ee=W(function(){R||($(!0),Z(T))}),te=function(k){return Fe(void 0,void 0,void 0,function(){var A;return Te(this,function(F){switch(F.label){case 0:return[4,V(k)];case 1:return A=F.sent(),[2,A.currentData]}})})},ye=W(function(){return R?Promise.reject():($(!0),te(T))}),ke=function(){return $(!1),Z()},ne=function(){return $(!1),te()},X=function(){var k=ge(r);if(k){var A=k===document?document.documentElement:k,F=mr(A),P=nt(A),B=xr(A);O?(E.current!==void 0&&E.current>F&&F<=i&&ee(),E.current=F,S.current=P-F):P-F<=B+i&&ee()}};return fr("scroll",function(){Q||I||X()},{target:r}),be(function(){Z()},w([],N(p),!1)),{data:T,loading:!I&&Q,error:q,loadingMore:I,noMore:R,loadMore:ee,loadMoreAsync:ye,reload:W(ke),reloadAsync:W(ne),mutate:M,cancel:je}};const rt={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},hr={connected:"Connected",connecting:"Connecting...",reconnecting:"Recovering...",offline:"Offline",error:"Error"},vr={disabled:"Not configured",unavailable:"Unavailable in this runtime",unauthenticated:"Authorization required",authorizing:"Waiting for authorization...",authenticated:"Authorized",error:"Authorization failed"},at=20,br=["debug","info","notice","warning","error","critical","alert","emergency"],ot=e=>e.status!=="reconnecting"||!e.recovery?hr[e.status]:`Recovering ${e.recovery.attempt}/${e.recovery.maxAttempts}`,gr=async()=>G("/mcp"),Er=async e=>G(`/mcp/${encodeURIComponent(e)}/logs?limit=20`),jr="mcp server @modelcontextprotocol",yr=3,bt=e=>{var n;return((n=e.split("/").pop())==null?void 0:n.replace(/^server-/,""))||e},kr=async(e,n)=>{const r=e&&e.length>=yr?e:jr,o=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(r)}&size=${at}&from=${n}`,s=await G(o);return{list:s.objects.map(i=>i.package),total:s.total,hasMore:n+at<s.total}};function Tr(){const{isMcpOpen:e,toggleMcp:n}=At(),[r,o]=l.useState("installed"),[s,i]=l.useState(!1),[c,u]=l.useState(null),[x,p]=l.useState(""),[b,d]=l.useState(null),[v,h]=l.useState(null),[f,y]=l.useState(null),[T,M]=l.useState(null),[C,I]=l.useState(null),[$,O]=l.useState(""),[E,S]=l.useState(null),[R,H]=l.useState(!1),[Q,q]=l.useState(null),[Z,V]=l.useState(null),[je,ee]=l.useState(""),[te,ye]=l.useState(""),[ke,ne]=l.useState(null),[X,k]=l.useState(null),A=l.useRef(null),{run:F}=ur(a=>{ye(a)},{wait:500}),{data:P=[],loading:B,error:re,run:Le,runAsync:Y}=ve(gr,{refreshDeps:[e],ready:e,onSuccess:a=>{a.length>0&&!c&&u(a[0].id)}}),{data:le,loading:Ne,error:_e,runAsync:ce}=ve(Er,{manual:!0}),{data:L,loading:gt,loadingMore:Et,noMore:jt,error:Ie,reload:He}=pr(async a=>{var g;const j=((g=a==null?void 0:a.list)==null?void 0:g.length)??0;return kr(te,j)},{target:A,isNoMore:a=>!(a!=null&&a.hasMore),reloadDeps:[te],manual:!e||r!=="catalog"}),{runAsync:We,loading:Ue,error:K}=ve(async a=>{await G("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a.name,config:a})})},{manual:!0,onSuccess:()=>{Y(),i(!1),k(null),ne(null)},onError:()=>{ne(null)}}),ae=l.useMemo(()=>{const a=x.trim().toLowerCase();return a?P.filter(j=>[j.name,j.endpoint,j.description].some(g=>g.toLowerCase().includes(a))):P},[x,P]),m=l.useMemo(()=>ae.find(a=>a.id===c)??ae[0],[ae,c]),de=l.useMemo(()=>{if(!m)return[];const a=(m.prompts??[]).flatMap(g=>g.arguments.map(U=>({key:`prompt:${g.name}:${U.name}`,label:`${g.name}.${U.name}`,reference:{type:"prompt",name:g.name},argument:U.name}))),j=(m.resourceTemplates??[]).flatMap(g=>(g.variables??[]).map(U=>({key:`resource:${g.uriTemplate}:${U}`,label:`${g.uriTemplate} · ${U}`,reference:{type:"resource",uri:g.uriTemplate},argument:U})));return[...a,...j]},[m]),z=de.find(a=>a.key===C)??de[0];l.useEffect(()=>{if(!e||!P.some(j=>j.oauthStatus==="authorizing"||j.status==="connecting"||j.status==="reconnecting"))return;const a=window.setInterval(()=>{Y()},1e3);return()=>window.clearInterval(a)},[e,Y,P]),l.useEffect(()=>{v&&P.some(a=>a.name===v.serverName&&(a.oauthStatus==="authenticated"||a.oauthStatus==="disabled"||a.oauthStatus==="unavailable"))&&h(null)},[v,P]),l.useEffect(()=>{!e||r!=="installed"||!m||ce(m.name).catch(()=>{})},[e,ce,m,r]);const Ce=async(a,j)=>{y({type:a,name:j}),d(null);try{const g=a==="delete"?"":`/${a}`;await G(`/mcp/${encodeURIComponent(j)}${g}`,{method:a==="delete"?"DELETE":"POST"}),await Y(),a==="delete"&&(V(null),u(null))}catch(g){d(g instanceof Error?g.message:`Failed to ${a} server`)}finally{y(null)}},we=async(a,j)=>{y({type:a,name:j.name}),d(null);try{if(a==="login"){const g=await G(`/mcp/${encodeURIComponent(j.name)}/oauth/login`,{method:"POST"});h({serverName:j.name,url:g.authorizationUrl})}else await G(`/mcp/${encodeURIComponent(j.name)}/oauth/logout`,{method:"POST"}),h(null);await Y()}catch(g){d(g instanceof Error?g.message:`Failed to ${a} MCP OAuth`)}finally{y(null)}},yt=async(a,j)=>{M(j),d(null);try{await G(`/mcp/${encodeURIComponent(a.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:j})}),await Y(),ce(a.name).catch(()=>{})}catch(g){d(g instanceof Error?g.message:"Failed to set MCP logging level")}finally{M(null)}},kt=async a=>{if(z){H(!0),q(null),S(null);try{const j=await G(`/mcp/${encodeURIComponent(a.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:z.reference,argument:{name:z.argument,value:$}})});S(j)}catch(j){q(j instanceof Error?j.message:"MCP completion failed")}finally{H(!1)}}},Nt=l.useMemo(()=>new Set(P.map(a=>a.name.toLowerCase())),[P]),Ct=a=>{k(a)},wt=a=>a.startsWith("@modelcontextprotocol/"),St=a=>wt(a.name)?"Official":"Community";return t.jsxs(t.Fragment,{children:[t.jsx(Pe,{open:e,onOpenChange:n,children:t.jsxs(Me,{onCloseAutoFocus:Ft,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:[t.jsx(Oe,{className:"sr-only",children:"MCP"}),t.jsx("div",{className:"flex flex-1 min-h-0",children:t.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[t.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[t.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("button",{onClick:Le,"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:B,children:t.jsx(Je,{className:D("h-4 w-4",B&&"animate-spin")})}),t.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>i(!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:[t.jsx(Rt,{className:"h-3.5 w-3.5"}),"Add server"]}),t.jsx("button",{onClick:n,"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:t.jsx(Be,{className:"w-4 h-4"})})]})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[t.jsxs(st,{active:r==="installed",onClick:()=>o("installed"),children:["Installed (",P.length,")"]}),t.jsx(st,{active:r==="catalog",onClick:()=>{o("catalog"),L||He()},children:"Catalog"})]}),b&&t.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:[t.jsx(qe,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsx("span",{className:"flex-1 min-w-0",children:b}),t.jsx("button",{type:"button",onClick:()=>d(null),className:"underline shrink-0",children:"Dismiss"})]}),r==="installed"?t.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[t.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[t.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Servers"}),t.jsx("input",{type:"search","aria-label":"Search installed MCP servers",value:x,onChange:a=>p(a.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]"}),t.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[B&&P.length===0&&t.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[t.jsx(fe,{className:"w-4 h-4 animate-spin"}),"Loading servers..."]}),re&&!B&&t.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:[t.jsx("span",{children:re.message}),t.jsx("button",{type:"button",onClick:Le,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:"Retry"})]}),!re&&!B&&ae.length===0&&t.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:x?"No servers match your search":"No MCP servers configured"}),ae.map(a=>t.jsxs("button",{onClick:()=>{u(a.id),V(null),d(null),I(null),O(""),S(null),q(null)},className:D("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",a.id===(m==null?void 0:m.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a.name}),t.jsx("span",{className:D("text-[11px] font-mono font-semibold",rt[a.status]),children:ot(a)})]}),t.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:a.endpoint})]},a.id))]})]}),m?t.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[t.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[t.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:m.name}),t.jsx("span",{className:D("text-xs font-mono font-semibold",rt[m.status]),children:ot(m)})]}),t.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:m.description}),m.error&&t.jsxs("p",{className:"text-[12px] font-mono text-[#ef4444]",children:["Error: ",m.error]}),m.instructions&&t.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Server instructions"}),t.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",m.instructions.sha256]})]}),t.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:m.instructions.text??"[details omitted by runtime policy]"}),(m.instructions.truncated||m.instructions.detailsOmitted)&&t.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:m.instructions.detailsOmitted?"Details omitted":"Truncated to the safe display budget"})]}),m.tasks&&t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[t.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"Experimental MCP Tasks"}),t.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m.tasks.enabled?`${m.tasks.maxTasksPerSession} per Session · ${m.tasks.pollIntervalMs}ms poll`:"Disabled by default"})]}),t.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",m.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:m.tasks.enabled?"Enabled":"Disabled"})]}),m.oauthEnabled&&t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[t.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),t.jsx("span",{role:m.oauthStatus==="authorizing"?"status":void 0,className:D("text-[11px] font-mono",m.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":m.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:vr[m.oauthStatus]})]}),m.oauthStatus==="authenticated"?t.jsx("button",{type:"button",onClick:()=>void we("logout",m),disabled:f!==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:(f==null?void 0:f.type)==="logout"?"Signing out...":"Sign out"}):m.oauthStatus==="authorizing"?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(fe,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(v==null?void 0:v.serverName)===m.name?t.jsx("a",{href:v.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"}):t.jsx("button",{type:"button",onClick:()=>void we("login",m),disabled:f!==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"})]}):m.oauthStatus==="unavailable"?null:t.jsx("button",{type:"button",onClick:()=>void we("login",m),disabled:f!==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:(f==null?void 0:f.type)==="login"?"Opening...":"Authorize"})]}),t.jsxs("div",{className:"flex gap-2 items-center",children:[m.status==="connected"||m.status==="reconnecting"?t.jsx("button",{onClick:()=>void Ce("disconnect",m.name),disabled:f!==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:(f==null?void 0:f.type)==="disconnect"&&f.name===m.name?"Disconnecting...":m.status==="reconnecting"?"Stop recovery":"Disconnect"}):t.jsx("button",{onClick:()=>void Ce("connect",m.name),disabled:f!==null||m.oauthEnabled&&m.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:(f==null?void 0:f.type)==="connect"&&f.name===m.name?"Connecting...":m.oauthEnabled&&m.oauthStatus!=="authenticated"?"Authorize first":"Connect"}),t.jsx("button",{onClick:()=>V(m.name),disabled:f!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:"Delete"})]}),Z===m.name&&t.jsxs("div",{role:"alertdialog","aria-label":`Delete ${m.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:[t.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:"Remove this server and its saved configuration?"}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("button",{type:"button",onClick:()=>V(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void Ce("delete",m.name),disabled:f!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(f==null?void 0:f.type)==="delete"?"Deleting...":"Delete server"})]})]}),t.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Tools (",m.tools.length,")"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:m.tools.length===0?t.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No tools available"}):m.tools.map(a=>t.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:a},a))}),t.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Argument completion"}),m.status!=="connected"?t.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Connect the server to request suggestions"}):m.completionSupported?de.length===0?t.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No completable prompt arguments or template variables"}):t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{"aria-label":"MCP completion target",className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:de.map(a=>t.jsx("button",{type:"button","aria-pressed":(z==null?void 0:z.key)===a.key,onClick:()=>{I(a.key),S(null),q(null)},className:D("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(z==null?void 0:z.key)===a.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:a.label},a.key))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text","aria-label":"MCP completion partial value",value:$,onChange:a=>O(a.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]"}),t.jsx("button",{type:"button",onClick:()=>void kt(m),disabled:R,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:R?"Completing...":"Complete"})]}),Q&&t.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:Q}),E&&t.jsxs("div",{"aria-label":"MCP completion suggestions",className:"rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:[t.jsx("div",{className:"flex flex-wrap gap-1",children:E.values.length>0?E.values.map(a=>t.jsx("span",{className:"rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]",children:a||"[empty]"},a)):t.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF]",children:"No suggestions"})}),t.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",E.sha256,E.truncated?" · truncated":""]})]})]}):t.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"Server does not advertise MCP completions"}),t.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Diagnostics"}),t.jsx("button",{type:"button","aria-label":`Refresh ${m.name} MCP logs`,onClick:()=>void ce(m.name),disabled:Ne,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:t.jsx(Je,{className:D("h-3.5 w-3.5",Ne&&"animate-spin")})})]}),t.jsx("div",{"aria-label":"MCP logging level",className:"flex flex-wrap gap-1",children:br.map(a=>{var j,g;return t.jsx("button",{type:"button",onClick:()=>void yt(m,a),disabled:m.status!=="connected"||T!==null,"aria-pressed":(((j=m.logging)==null?void 0:j.level)??"warning")===a,className:D("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((g=m.logging)==null?void 0:g.level)??"warning")===a?"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:T===a?"Setting...":a},a)})}),_e?t.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:_e.message}):le!=null&&le.entries.length?t.jsx("div",{"aria-label":`${m.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:le.entries.map(a=>t.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(a.level)?"text-red-600 dark:text-red-400":a.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:a.level}),t.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[a.logger||m.name," · r",a.revision]})]}),t.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:a.message}),t.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",a.dataSha256,a.truncated?" · truncated":"",a.detailsOmitted?" · details omitted":""]})]},a.revision))}):t.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:Ne?"Loading logs...":"No logs captured"})]}):t.jsx("div",{className:"flex flex-1 justify-center items-center",children:t.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a server to view details"})})]}):t.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[t.jsx("div",{className:"flex gap-3 items-center shrink-0",children:t.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[t.jsx(Pt,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),t.jsx("input",{type:"text","aria-label":"Search MCP server catalog",value:je,onChange:a=>{ee(a.target.value),F(a.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"})]})}),t.jsxs("div",{ref:A,className:"overflow-y-auto flex-1 min-h-0",children:[Ie?t.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[t.jsx(qe,{className:"w-6 h-6 text-red-500"}),t.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:Ie.message}),t.jsx("button",{type:"button",onClick:He,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:"Retry catalog"})]}):gt&&!L?t.jsx("div",{className:"flex justify-center items-center py-12",children:t.jsx(fe,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):t.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[L==null?void 0:L.list.map(a=>{var ze,Ge;const j=Nt.has(bt(a.name).toLowerCase()),g=ke===a.name,U=St(a);return t.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[t.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[t.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:a.name}),t.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",U==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:U})]}),t.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:a.description||"No description"}),t.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[t.jsxs("span",{children:["v",a.version]}),((ze=a.publisher)==null?void 0:ze.username)&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"•"}),t.jsxs("span",{children:["by ",a.publisher.username]})]})]}),t.jsxs("div",{className:"flex justify-between items-center pt-2 mt-auto",children:[t.jsxs("a",{href:((Ge=a.links)==null?void 0:Ge.npm)||`https://www.npmjs.com/package/${a.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:[t.jsx(Ve,{className:"w-3 h-3"}),"npm"]}),j?t.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[t.jsx(Mt,{className:"w-3 h-3"}),"Installed"]}):t.jsxs("button",{onClick:()=>Ct(a),disabled:g,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:[t.jsx(Ot,{className:D("h-3 w-3",g&&"animate-pulse")}),g?"Installing...":"Install"]})]})]},a.name)}),(L==null?void 0:L.list.length)===0&&t.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No packages found"})]}),Et&&t.jsx("div",{className:"flex justify-center items-center py-4",children:t.jsx(fe,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),jt&&L&&L.list.length>0&&t.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"No more packages"})]}),t.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[t.jsxs("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[(L==null?void 0:L.total)??0," packages found"]}),t.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",t.jsx(Ve,{className:"w-3 h-3"})]})]})]})]})})]})}),t.jsx(Nr,{open:s,onOpenChange:i,onAdd:We,saving:Ue,error:(K==null?void 0:K.message)??null}),X&&t.jsx(Cr,{pkg:X,onClose:()=>k(null),installing:Ue,error:(K==null?void 0:K.message)??null,onInstall:a=>(ne(X.name),We(a))})]})}function st({active:e,children:n,onClick:r}){return t.jsx("button",{onClick:r,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",e?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:n})}function Nr({open:e,onOpenChange:n,onAdd:r,saving:o,error:s}){const[i,c]=l.useState("form"),[u,x]=l.useState(""),[p,b]=l.useState(""),[d,v]=l.useState(""),[h,f]=l.useState(null),[y,T]=l.useState(`{
2
+ "name": "my-server",
3
+ "command": "npx",
4
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
5
+ }`);l.useEffect(()=>{e&&f(null)},[e]);const M=async()=>{if(f(null),i==="json"){let C;try{C=JSON.parse(y)}catch{f("Enter valid JSON with a server name and transport.");return}await r(C).catch(()=>{})}else{if(!u||!p){f("Name and command are required.");return}await r({name:u,command:p,args:d.split(" ").filter(Boolean)}).catch(()=>{})}};return t.jsx(Pe,{open:e,onOpenChange:n,children:t.jsxs(Me,{onCloseAutoFocus:C=>Tt("[data-mcp-add-server-trigger]",C),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:[t.jsx(Oe,{className:"sr-only",children:"Add MCP Server"}),t.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Add MCP Server"}),t.jsx("button",{onClick:()=>n(!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:t.jsx(Be,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[t.jsx(it,{active:i==="form",onClick:()=>c("form"),children:"Form"}),t.jsx(it,{active:i==="json",onClick:()=>c("json"),children:"JSON"})]}),i==="json"?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"JSON config"}),t.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:y,onChange:C=>T(C.target.value)})]}):t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Server name"}),t.jsx("input",{"aria-label":"Server name",type:"text",value:u,onChange:C=>x(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]"})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Command"}),t.jsx("input",{"aria-label":"Server command",type:"text",value:p,onChange:C=>b(C.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]"})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Arguments (space separated)"}),t.jsx("input",{"aria-label":"Server arguments",type:"text",value:d,onChange:C=>v(C.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]"})]})]}),(h||s)&&t.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:h||s}),t.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[t.jsx("button",{onClick:()=>n(!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"}),t.jsx("button",{onClick:()=>void M(),disabled:o,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:o?"Adding...":"Add Server"})]})]})]})})}function Cr({pkg:e,onClose:n,onInstall:r,installing:o,error:s}){const i=bt(e.name),[c,u]=l.useState(i),[x,p]=l.useState(`-y ${e.name}`),[b,d]=l.useState(null),v=async()=>{if(d(null),!c.trim()){d("Server name is required.");return}await r({name:c.trim(),command:"npx",args:x.split(" ").filter(Boolean)}).catch(()=>{})};return t.jsx(Pe,{open:!0,onOpenChange:n,children:t.jsxs(Me,{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:[t.jsxs(Oe,{className:"sr-only",children:["Install ",e.name]}),t.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install MCP Server"}),t.jsx("button",{onClick:n,"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:t.jsx(Be,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"rounded-md bg-white dark:bg-[#0C0C0C] p-3",children:[t.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:e.name}),t.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1",children:e.description||"No description"})]}),t.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Server name"}),t.jsx("input",{"aria-label":"Server name",type:"text",value:c,onChange:h=>u(h.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]"})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Arguments"}),t.jsx("input",{"aria-label":"Server arguments",type:"text",value:x,onChange:h=>p(h.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]"}),t.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["Command: npx ",x]})]})]}),(b||s)&&t.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:b||s}),t.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[t.jsx("button",{onClick:n,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"}),t.jsx("button",{onClick:()=>void v(),disabled:o,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:o?"Installing...":"Install"})]})]})]})})}function it({active:e,children:n,onClick:r}){return t.jsx("button",{onClick:r,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",e?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:n})}export{Tr as McpModal};
@@ -0,0 +1 @@
1
+ import{r as s,j as e}from"./vendor-react-DG5dkZ_t.js";import{v as C,D as be,e as fe,w as ge,g as je,a as ce,j as T,b as pe,x as Oe,y as Ke,K as qe,z as ze}from"./index-BNsnHxlt.js";import{X as ve,f as he,a4 as Ge,a5 as He,L as J,a6 as ye,O as Ae,a as xe,B as _e,D as Se,T as me,a7 as Je,i as We,a8 as Ye,u as Qe,a9 as Ve,P as Ce}from"./vendor-icons-CsBKlDXT.js";import"./vendor-radix-DXRuAJHH.js";const Xe=/^[a-z][a-z0-9._-]{0,63}$/;function Ze({open:o,onOpenChange:x,onSave:g,saveError:D}){const[U,M]=s.useState([]),[S,E]=s.useState([]),[l,p]=s.useState(),[c,k]=s.useState(),[B,w]=s.useState(""),[F,m]=s.useState(""),[r,A]=s.useState(""),[d,h]=s.useState(""),[_,i]=s.useState(""),[N,y]=s.useState(""),[f,I]=s.useState(!1),[O,W]=s.useState(!1),[Z,$]=s.useState(!1),[ee,H]=s.useState(!1),[Y,R]=s.useState(null);s.useEffect(()=>{if(!o)return;let n=!0;return E([]),p(void 0),k(void 0),w(""),m(""),A(""),h(""),i(""),y(""),I(!1),R(null),W(!0),C("/providers").then(P=>{n&&M(P)}).catch(P=>{n&&R(P instanceof Error?P.message:"Failed to load providers")}).finally(()=>{n&&W(!1)}),()=>{n=!1}},[o]),s.useEffect(()=>{if(!l)return;let n=!0;return E([]),k(void 0),R(null),l.factoryWireApi||l.custom?($(!1),()=>{n=!1}):($(!0),C(`/providers/${l.id}/models`).then(P=>{n&&E(P)}).catch(P=>{n&&R(P instanceof Error?P.message:"Failed to load models")}).finally(()=>{n&&$(!1)}),()=>{n=!1})},[l]);const L=l==null?void 0:l.factoryWireApi,z=!!(L||l!=null&&l.custom),Q=z?d.trim():c==null?void 0:c.id,V=async()=>{if(!l||!Q||!l.configured&&!N)return;if(L){if(!Xe.test(F.trim())){R('Channel ID must start with a lowercase letter and contain only lowercase letters, numbers, ".", "_" or "-"');return}let te;try{te=new URL(_.trim())}catch{R("Base URL must be an absolute HTTP(S) URL");return}if(!["http:","https:"].includes(te.protocol)){R("Base URL must be an absolute HTTP(S) URL");return}}H(!0);const n=L?F.trim():l.id,P=await g({provider:n,model:Q,displayName:B||(z?Q:(c==null?void 0:c.name)??""),apiKey:N||void 0,...L?{modelProvider:{id:n,name:r.trim()||n,baseUrl:_.trim(),wireApi:L}}:{}});H(!1),P&&x(!1)};return e.jsx(be,{open:o,onOpenChange:x,children:e.jsxs(fe,{onCloseAutoFocus:n=>ge("[data-add-model-trigger]",n),onEscapeKeyDown:n=>{n.preventDefault(),x(!1)},onKeyDown:n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),x(!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(je,{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:()=>x(!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||D)&&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||D})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Provider",e.jsxs("select",{"aria-label":"Provider",value:(l==null?void 0:l.id)??"",disabled:O,onChange:n=>{p(U.find(P=>P.id===n.target.value)),w(""),m(""),A(""),h(""),i("")},className:"field",children:[e.jsx("option",{value:"",children:O?"Loading providers...":"Select provider"}),U.map(n=>e.jsxs("option",{value:n.id,children:[n.name," (",n.modelCount,")",n.configured?" - configured":""]},n.id))]})]}),z?e.jsxs(e.Fragment,{children:[L&&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:F,onChange:n=>{m(n.target.value),R(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:r,onChange:n=>A(n.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:n=>{i(n.target.value),R(null)},placeholder:L==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:L==="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:d,onChange:n=>{h(n.target.value),R(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.jsxs("select",{"aria-label":"Model",value:(c==null?void 0:c.id)??"",disabled:!l||Z,onChange:n=>{const P=S.find(te=>te.id===n.target.value);k(P),P&&w(P.name)},className:"field",children:[e.jsx("option",{value:"",children:Z?"Loading models...":"Select model"}),S.map(n=>e.jsxs("option",{value:n.id,children:[n.name," - ",Math.round(n.contextWindow/1e3),"K",n.reasoning?" - reasoning":"",n.input.includes("image")?" - vision":""]},n.id))]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:["Display name",e.jsx("input",{value:B,onChange:n=>w(n.target.value),placeholder:(c==null?void 0:c.name)??"Optional alias",className:"field"})]}),(l==null?void 0:l.supportsApiKey)&&!l.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:f?"text":"password",value:N,onChange:n=>y(n.target.value),className:"field w-full pr-10",placeholder:"Stored separately in auth.json"}),e.jsx("button",{type:"button",onClick:()=>I(!f),"aria-label":f?"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:f?e.jsx(Ge,{className:"h-4 w-4"}):e.jsx(He,{className:"h-4 w-4"})})]})]}),l&&!l.configured&&!l.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||!l||!Q||L&&(!F.trim()||!_.trim())||!l.configured&&(!l.supportsApiKey||N.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 et(o){const[x,g]=s.useState(""),[D,U]=s.useState(""),[M,S]=s.useState(""),[E,l]=s.useState(""),[p,c]=s.useState(!1),[k,B]=s.useState(null);s.useEffect(()=>{var m,r,A,d,h;g(((m=o.model)==null?void 0:m.displayName)??""),U(((A=(r=o.model)==null?void 0:r.overrides)==null?void 0:A.baseUrl)??""),S(((h=(d=o.model)==null?void 0:d.overrides)==null?void 0:h.streamIdleTimeout)!==void 0?String(o.model.overrides.streamIdleTimeout):""),l(""),B(null)},[o.model]);const w=async()=>{if(!o.model)return;B(null);const m=M.trim()?Number(M):void 0;if(m!==void 0&&(!Number.isFinite(m)||m<1e3)){B("Stream idle timeout must be at least 1000ms");return}c(!0);try{E.trim()&&await C(`/providers/${o.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:E.trim()})});const r={...o.model.overrides};D.trim()?r.baseUrl=D.trim():delete r.baseUrl,m!==void 0?r.streamIdleTimeout=m:delete r.streamIdleTimeout,await o.onSave(o.model.id,{displayName:x||void 0,overrides:Object.keys(r).length>0?r:void 0})&&o.onOpenChange(!1)}catch(r){B(r instanceof Error?r.message:"Failed to update provider credential")}finally{c(!1)}},F=o.model?`[data-edit-model-trigger="${o.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx(be,{open:o.open,onOpenChange:o.onOpenChange,children:e.jsxs(fe,{onCloseAutoFocus:m=>ge(F,m),onEscapeKeyDown:m=>{m.preventDefault(),o.onOpenChange(!1)},onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),o.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(je,{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:()=>o.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"})})]}),(k||o.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:k||o.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Display name",e.jsx("input",{value:x,onChange:m=>g(m.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:E,onChange:m=>l(m.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:D,onChange:m=>U(m.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:M,onChange:m=>S(m.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void w(),disabled:p,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:[p&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),p?"Saving...":"Save"]})]})})}function tt({provider:o,onOpenChange:x,onSave:g,saveError:D}){const[U,M]=s.useState(o.name),[S,E]=s.useState(o.defaultBaseUrl??""),[l,p]=s.useState(o.wireApi??"openai-completions"),[c,k]=s.useState(o.apiKeyEnv??""),[B,w]=s.useState(""),[F,m]=s.useState(null),[r,A]=s.useState(!1);s.useEffect(()=>{M(o.name),E(o.defaultBaseUrl??""),p(o.wireApi??"openai-completions"),k(o.apiKeyEnv??""),w(""),m(null)},[o]);const d=async()=>{if(!U.trim()){m("Channel name is required");return}try{const h=new URL(S.trim());if(!["http:","https:"].includes(h.protocol))throw new Error}catch{m("Base URL must be an absolute HTTP(S) URL");return}A(!0),m(null);try{await g(o.id,{name:U.trim(),baseUrl:S.trim(),wireApi:l,apiKeyEnv:c.trim()||null,...B.trim()?{apiKey:B.trim()}:{}})&&x(!1)}finally{A(!1)}};return e.jsx(be,{open:!0,onOpenChange:x,children:e.jsxs(fe,{onCloseAutoFocus:h=>ge(`[data-edit-provider-trigger="${o.id.replace(/"/g,'\\"')}"]`,h),onEscapeKeyDown:h=>{h.preventDefault(),x(!1)},onKeyDown:h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),x(!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(je,{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:o.id})]}),e.jsx("button",{type:"button",onClick:()=>x(!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"})})]}),(F||D)&&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:F||D}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Channel name",e.jsx("input",{"aria-label":"Channel name",value:U,onChange:h=>M(h.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:["Wire API",e.jsxs("select",{"aria-label":"Wire API",value:l,onChange:h=>p(h.target.value),className:"field",children:[e.jsx("option",{value:"openai-completions",children:"OpenAI Chat Completions"}),e.jsx("option",{value:"anthropic-messages",children:"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:S,onChange:h=>{E(h.target.value),m(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:h=>k(h.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:B,onChange:h=>w(h.target.value),placeholder:"Leave empty to keep current credential",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void d(),disabled:r,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:[r&&e.jsx(J,{className:"h-4 w-4 animate-spin"}),r?"Saving...":"Save channel"]})]})})}const at={disabled:"Hooks disabled",not_required:"No external hooks",untrusted:"Review required",trusted:"Trusted",modified:"Changed since approval",error:"Trust store error"};function st(){const o=ce(i=>{var N;return(N=i.currentSessionRef)==null?void 0:N.projectPath}),x=s.useMemo(()=>o??new URLSearchParams(window.location.search).get("project")??"",[o]),[g,D]=s.useState(null),[U,M]=s.useState(""),[S,E]=s.useState(!1),[l,p]=s.useState(null),[c,k]=s.useState(null),[B,w]=s.useState(null),F=s.useRef(0),m=s.useRef(x);m.current=x;const r=U===x?g:null,A=s.useCallback(async()=>{const i=++F.current;if(!x){D(null),M(""),w(null);return}E(!0),w(null);try{const N=await C(`/hooks/trust?projectPath=${encodeURIComponent(x)}`);if(i!==F.current)return;D(N),M(x)}catch(N){if(i!==F.current)return;w(N instanceof Error?N.message:"Failed to load hook trust")}finally{i===F.current&&E(!1)}},[x]);s.useEffect(()=>(k(null),A(),()=>{F.current+=1}),[A]);const d=async i=>{if(!r)return;const N=x;p(i),w(null);try{const y=await C("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:x,action:i,...i==="trust"&&r.currentDigest?{expectedDigest:r.currentDigest}:{}})});m.current===N&&(D(y),M(N),k(null))}catch(y){m.current===N&&w(y instanceof Error?y.message:"Failed to update hook trust")}finally{p(null)}};if(!x)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project session to review its hooks."});const h=(r==null?void 0:r.state)==="trusted",_=(r==null?void 0:r.state)==="untrusted"||(r==null?void 0:r.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:[h?e.jsx(ye,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ae,{className:T("h-4 w-4",_?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:r?at[r.state]:"Hook trust"}),S&&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:x}),(r==null?void 0:r.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:r.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void A(),disabled:S||l!==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(xe,{className:"h-3.5 w-3.5"}),"Reload"]}),h?e.jsx("button",{type:"button",onClick:()=>k("revoke"),disabled:l!==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:()=>k("trust"),disabled:l!==null||!(r!=null&&r.currentDigest)||r.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"})]})]}),B&&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:B}),c&&r&&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 ${r.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:()=>k(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void d(c),disabled:l!==null,className:T("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:l?"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:[((r==null?void 0:r.definitions)??[]).map((i,N)=>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:i.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:i.type}),i.name&&e.jsx("span",{className:"text-[#71717a]",children:i.name}),i.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:[i.pluginName," · ",i.pluginSource]})]}),i.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:i.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:i.target})]},`${i.event}-${i.type}-${N}`)),r&&r.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 rt={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]};function nt(){const o=ce(a=>{var j;return(j=a.currentSessionRef)==null?void 0:j.projectPath}),x=ce(a=>a.selectedProjectPath),g=s.useMemo(()=>o??x??new URLSearchParams(window.location.search).get("project")??"",[x,o]),[D,U]=s.useState([]),[M,S]=s.useState([]),[E,l]=s.useState(rt),[p,c]=s.useState(!1),[k,B]=s.useState(""),[w,F]=s.useState(""),[m,r]=s.useState(""),[A,d]=s.useState(""),[h,_]=s.useState(!1),[i,N]=s.useState(null),[y,f]=s.useState(null),[I,O]=s.useState(""),[W,Z]=s.useState(""),[$,ee]=s.useState(!1),[H,Y]=s.useState(null),R=s.useRef(0),L=s.useRef(g);L.current=g;const z=A===g?D:[],Q=A===g?M:[],V=s.useCallback(async()=>{const a=++R.current;if(!g){U([]),d(""),f(null);return}_(!0),f(null);try{const[j,K,q]=await Promise.all([C(`/plugins?projectPath=${encodeURIComponent(g)}`),C(`/plugins/catalog?projectPath=${encodeURIComponent(g)}`),C(`/plugins/policy?projectPath=${encodeURIComponent(g)}`)]);if(a!==R.current)return;U(j),S(K),l(q.policy),c(q.environmentRequiresSha),B(q.policy.allowedGitHosts.join(", ")),F(q.policy.allowedMarketplaces.join(", ")),r(q.policy.allowedLocalRoots.join(", ")),d(g)}catch(j){if(a!==R.current)return;f(j instanceof Error?j.message:"Failed to load plugins")}finally{a===R.current&&_(!1)}},[g]);s.useEffect(()=>(V(),()=>{R.current+=1}),[V]);const n=async(a,j)=>{const K=g;N(a.name),f(null);try{await C(`/plugins/${encodeURIComponent(a.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:K,enabled:j,scope:"local"})}),L.current===K&&await V()}catch(q){L.current===K&&f(q instanceof Error?q.message:"Failed to update plugin")}finally{N(null)}},P=a=>[...new Set(a.split(",").map(j=>j.trim()).filter(Boolean))],te=async()=>{await X("policy:save",()=>C("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,scope:"local",policy:{...E,allowedGitHosts:P(k),allowedMarketplaces:P(w),allowedLocalRoots:P(m)}})}))},X=async(a,j,K)=>{const q=g;N(a),f(null);try{await j(),L.current===q&&(K==null||K(),Y(null),await V())}catch(se){L.current===q&&f(se instanceof Error?se.message:"Plugin action failed")}finally{N(null)}},le=async()=>{const a=I.trim();!a||!$||await X("install",()=>C("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,source:a,trust:!0})}),()=>{O(""),ee(!1)})},oe=async a=>{const j=`update:${a.name}`;if(H!==j){Y(j);return}await X(j,()=>C(`/plugins/${encodeURIComponent(a.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,trust:!0})}))},ue=async a=>{const j=`uninstall:${a.name}`;if(H!==j){Y(j);return}await X(j,()=>C(`/plugins/${encodeURIComponent(a.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,confirm:!0})}))},ae=async()=>{const a=W.trim();a&&await X("marketplace:add",()=>C("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,source:a})}),()=>Z(""))},ke=async a=>{await X(`marketplace:refresh:${a.name}`,()=>C(`/plugins/marketplaces/${encodeURIComponent(a.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g})}))},ie=async a=>{const j=`marketplace:remove:${a.name}`;if(H!==j){Y(j);return}await X(j,()=>C(`/plugins/marketplaces/${encodeURIComponent(a.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:g,confirm:!0})}))};return g?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(_e,{className:"h-4 w-4"}),"Workspace plugins",h&&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:g}),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:h||i!==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(xe,{className:"h-3.5 w-3.5"}),"Reload"]})]}),y&&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:y}),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(ye,{className:"h-3.5 w-3.5"}),"Source policy"]}),e.jsx("button",{type:"button","aria-label":"Save plugin source policy",onClick:()=>void te(),disabled:i!==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:i==="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":E.restrictToAllowedSources,onClick:()=>l(a=>({...a,restrictToAllowedSources:!a.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:T("h-3.5 w-6 rounded-full p-0.5",E.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:T("block h-2.5 w-2.5 rounded-full bg-white transition-transform",E.restrictToAllowedSources&&"translate-x-2.5")})}),"Restrict to allowlists"]}),e.jsxs("button",{type:"button",role:"switch","aria-label":"Require full Git commit SHA","aria-checked":E.requireGitCommitSha,disabled:p,onClick:()=>l(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:T("h-3.5 w-6 rounded-full p-0.5",E.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:T("block h-2.5 w-2.5 rounded-full bg-white transition-transform",E.requireGitCommitSha&&"translate-x-2.5")})}),"Require full Git SHA",p?" · 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:k,onChange:a=>B(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:w,onChange:a=>F(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:m,onChange:a=>r(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]"})]}),E.restrictToAllowedSources&&!k.trim()&&!w.trim()&&!m.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(Se,{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:I,onChange:a=>O(a.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:i!==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 le(),disabled:!I.trim()||!$||i!==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:[i==="install"?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Se,{className:"h-3.5 w-3.5"}),"Install"]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":$,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:T("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",$?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:$?"✓":""}),"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:[z.map(a=>{var q;const j=i===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"}),(q=a.compatibilityIssues)==null?void 0:q.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||j||i!==null,onClick:()=>void n(a,!a.enabled),className:T("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:T("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 oe(a),disabled:i!==null,className:T("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",H===`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:i===`update:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):H===`update:${a.name}`?"Confirm update":"Update"}),e.jsx("button",{type:"button","aria-label":`Uninstall ${a.name}`,onClick:()=>void ue(a),disabled:i!==null,className:T("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",H===`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:i===`uninstall:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):H===`uninstall:${a.name}`?"Confirm remove":e.jsx(me,{className:"h-3 w-3"})})]})]})]},a.name)}),!h&&z.length===0&&!y&&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(Je,{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:i!==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()||i!==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:[i==="marketplace:add"?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(We,{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:i!==null,onClick:()=>void ke(a),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:i===`marketplace:refresh:${a.name}`?e.jsx(J,{className:"h-3 w-3 animate-spin"}):e.jsx(xe,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":`Remove marketplace ${a.name}`,disabled:i!==null,onClick:()=>void ie(a),className:T("rounded p-1 text-[#9CA3AF] disabled:opacity-40",H===`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:H===`marketplace:remove:${a.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:"Confirm"}):e.jsx(me,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[a.plugins.slice(0,12).map(j=>e.jsxs("button",{type:"button",disabled:j.installed||i!==null,onClick:()=>{O(`${j.name}@${a.name}`),ee(!1)},title:j.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:[j.name,j.installed?" · installed":""]},j.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)),!h&&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 lt={not_required:"No trust required",trusted:"Workspace trusted",untrusted:"Review required",error:"Trust store error"};function ot(){const o=ce(y=>{var f;return(f=y.currentSessionRef)==null?void 0:f.projectPath}),x=s.useMemo(()=>o??new URLSearchParams(window.location.search).get("project")??"",[o]),[g,D]=s.useState(null),[U,M]=s.useState(""),[S,E]=s.useState(!1),[l,p]=s.useState(null),[c,k]=s.useState(null),[B,w]=s.useState(null),[F,m]=s.useState(!1),r=s.useRef(0),A=s.useRef(x);A.current=x;const d=U===x?g:null,h=s.useCallback(async()=>{const y=++r.current;if(!x){D(null),M(""),w(null);return}E(!0),w(null);try{const f=await C(`/workspace-trust?projectPath=${encodeURIComponent(x)}`);if(y!==r.current)return;D(f),M(x)}catch(f){if(y!==r.current)return;w(f instanceof Error?f.message:"Failed to load workspace trust")}finally{y===r.current&&E(!1)}},[x]);s.useEffect(()=>(k(null),m(!1),h(),()=>{r.current+=1}),[h]);const _=async y=>{if(!d)return;const f=x;p(y),w(null);try{const I=await C("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:f,action:y})});A.current===f&&(D(I),M(f),k(null),m(I.reloadRequired===!0))}catch(I){A.current===f&&w(I instanceof Error?I.message:"Failed to update workspace trust")}finally{p(null)}};if(!x)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:"Select a project session to review folder trust."});const i=(d==null?void 0:d.state)==="trusted",N=(d==null?void 0:d.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:[i?e.jsx(ye,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ae,{className:T("h-4 w-4",N?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:d?lt[d.state]:"Workspace trust"}),S&&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:x}),d&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[d.decision,d.inheritedFrom?` · inherited from ${d.inheritedFrom}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void h(),disabled:S||l!==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(xe,{className:"h-3.5 w-3.5"}),"Reload"]}),i?e.jsx("button",{type:"button",onClick:()=>k("revoke"),disabled:l!==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:()=>k("trust"),disabled:l!==null||(d==null?void 0:d.state)==="error"||!d||d.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"})]})]}),(B||(d==null?void 0:d.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:B||(d==null?void 0:d.error)}),F&&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&&d&&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 ${d.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:()=>k(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:l!==null,className:T("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:l?"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:[((d==null?void 0:d.sources)??[]).map(y=>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:y.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:y.kind})]}),y.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:y.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:y.effects.map((f,I)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:f.kind})," · ",f.name,f.target?` → ${f.target}`:""]},`${f.kind}-${f.name}-${I}`))})]},`${y.kind}-${y.path}`)),d&&d.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 dt={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},it={searchTasks:"Search tasks",openCommands:"Open command center",newTask:"New task",focusComposer:"Focus composer",toggleSidebar:"Toggle sidebar"};function pt(){var Ne,Ee;const{isSettingsOpen:o,settingsSection:x,toggleSettings:g,isSidebarOpen:D,setSidebarOpen:U}=pe(),{configuredModels:M,loadModels:S,isLoading:E,error:l}=Oe(),p=Ke(),[c,k]=s.useState("general"),[B,w]=s.useState(!1),[F,m]=s.useState(null),[r,A]=s.useState(null),[d,h]=s.useState(null),[_,i]=s.useState([]),[N,y]=s.useState(null),[f,I]=s.useState(null),[O,W]=s.useState(null),[Z,$]=s.useState(null),[ee,H]=s.useState({}),[Y,R]=s.useState(null),[L,z]=s.useState(null),[Q,V]=s.useState(""),[n,P]=s.useState("all"),te=s.useRef(null),X=s.useRef(null),le=s.useRef(0),[oe,ue]=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"}],ie=s.useMemo(()=>qe.map(t=>({action:it[t.id],combo:ze(t),scope:t.scope})),[]).filter(t=>{const u=t.action.toLowerCase().includes(Q.toLowerCase()),b=n==="all"||t.scope.toLowerCase()===n;return u&&b}),a=M.reduce((t,u)=>{const b=u.provider||"unknown";return t[b]||(t[b]=[]),t[b].push(u),t},{}),j=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{i(await C("/providers")),$(null)}catch(t){$(t instanceof Error?t.message:"Failed to load provider channels")}},[]);s.useEffect(()=>{o&&(k(x),S(),K(),p.loadSettings())},[o,S,K,p.loadSettings,x]);const q=()=>{const t=X.current,u=t!=null&&t.isConnected?t:document.querySelector("[data-settings-trigger]");u==null||u.focus({preventScroll:!0})},se=()=>{g(),requestAnimationFrame(q)};s.useLayoutEffect(()=>{if(!o)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 u=requestAnimationFrame(()=>{var b;(b=te.current)==null||b.focus({preventScroll:!0})});return()=>{cancelAnimationFrame(u),requestAnimationFrame(q)}},[o]);const Pe=async t=>{R("save"),z(null);try{return await C("/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 S(),await K(),!0}catch(u){return z(u instanceof Error?u.message:"Failed to save model"),!1}finally{R(null)}},Be=async()=>{typeof Notification>"u"||ue(await Notification.requestPermission())},Fe=async t=>{R("delete"),z(null);try{await C(`/models/${t}`,{method:"DELETE"}),await S(),h(null)}catch(u){z(u instanceof Error?u.message:"Failed to delete model")}finally{R(null)}},Re=async(t,u)=>{R("update"),z(null);try{return await C(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),await S(),!0}catch(b){return z(b instanceof Error?b.message:"Failed to update model"),!1}finally{R(null)}},Te=async(t,u)=>{W({providerId:t,type:"update"}),$(null);try{return await C(`/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),await Promise.all([S(),K()]),!0}catch(b){return $(b instanceof Error?b.message:"Failed to update provider channel"),!1}finally{W(null)}},De=async(t,u)=>{W({providerId:t.id,type:"probe"}),$(null);try{const b=await C(`/providers/${t.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:u})});H(v=>({...v,[t.id]:b}))}catch(b){$(b instanceof Error?b.message:"Provider probe failed")}finally{W(null)}},Me=async t=>{W({providerId:t.id,type:"delete"}),$(null);try{await C(`/providers/${t.id}?removeModels=true`,{method:"DELETE"}),I(null),m(null),H(u=>{const b={...u};return delete b[t.id],b}),await Promise.all([S(),K()])}catch(u){$(u instanceof Error?u.message:"Failed to delete provider channel")}finally{W(null)}},$e=(t,u)=>{var de,re;const b=t.key==="ArrowRight"||t.key==="ArrowDown"?1:t.key==="ArrowLeft"||t.key==="ArrowUp"?-1:0;if(b===0&&t.key!=="Home"&&t.key!=="End")return;t.preventDefault();const v=t.key==="Home"?0:t.key==="End"?ae.length-1:(u+b+ae.length)%ae.length;k(ae[v].value),(re=(de=t.currentTarget.parentElement)==null?void 0:de.querySelectorAll('[role="tab"]')[v])==null||re.focus()},Le=t=>{m(F===t?null:t)},Ie=t=>{if(!o||t.key!=="Escape"||!(t.target instanceof Node)||!t.currentTarget.contains(t.target)||B||r||N||Date.now()-le.current<250)return;const u=t.target instanceof Element?t.target:null;if(!(t.defaultPrevented||u!=null&&u.closest('[role="dialog"]'))){if(t.preventDefault(),d){h(null);return}if(f){I(null);return}se()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:Ie,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(Ye,{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,u)=>(t[u.category]||(t[u.category]=[]),t[u.category].push(u),t),{})).map(([t,u])=>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}),u.map(b=>e.jsx("button",{onClick:()=>k(b.value),onKeyDown:v=>$e(v,ae.indexOf(b)),role:"tab",id:`settings-tab-${b.value}`,"aria-controls":`settings-panel-${b.value}`,"aria-selected":c===b.value,tabIndex:c===b.value?0:-1,className:T("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",c===b.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:b.label},b.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:((Ne=ae.find(t=>t.value===c))==null?void 0:Ne.label)??"Settings"}),p.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..."]}),p.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:p.error}),e.jsx("button",{type:"button",onClick:()=>void p.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."}),(l||L||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||L||l}),e.jsx("button",{type:"button",onClick:()=>{z(null),$(null),l&&S()},className:"shrink-0 underline",children:l?"Retry":"Dismiss"})]}),d&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete ${d.displayName||d.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 ",d.displayName||d.model," and its saved configuration?"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>h(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(d.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"})]})]}),f&&e.jsxs("div",{role:"alertdialog","aria-label":`Delete channel ${f.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 ",f.name,", its credential, and"," ",((Ee=a[f.id])==null?void 0:Ee.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:()=>I(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 Me(f),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:[E&&M.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,u])=>{const b=dt[t]||{bg:"#71717a",label:"?"},v=j.get(t),de=F===t,re=ee[t],Ue=(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:()=>Le(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:b.bg},children:b.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:(v==null?void 0:v.name)??t.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[u.length," model",u.length!==1?"s":"",v!=null&&v.custom?` · ${v.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsxs("span",{className:T("text-xs font-mono",(v==null?void 0:v.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(v==null?void 0:v.configured)===!1?"Missing credential":"Configured"]}),e.jsx(Qe,{className:T("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",de&&"rotate-180")})]})]}),(v==null?void 0:v.custom)&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pr-3",children:[e.jsx("button",{type:"button",onClick:()=>{var G;return void De(v,(G=u[0])==null?void 0:G.id)},disabled:O!==null||u.length===0,"aria-label":`Test ${v.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:Ue?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ve,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":v.id,onClick:()=>{$(null),y(v)},disabled:O!==null,"aria-label":`Edit channel ${v.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(Ce,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>I(v),disabled:O!==null,"aria-label":`Delete channel ${v.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(me,{className:"h-3.5 w-3.5"})})]})]}),re&&e.jsxs("div",{role:"status",className:T("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:[(v==null?void 0:v.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:v.id})," ","· ",v.defaultBaseUrl]}),u.map(G=>{var we;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:G.displayName||G.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[G.displayName&&`${G.model} · `,((we=G.overrides)==null?void 0:we.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":G.id,onClick:()=>{z(null),A(G)},disabled:Y!==null,"aria-label":`Edit ${G.displayName||G.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(Ce,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>h(G),disabled:Y!==null,"aria-label":`Delete ${G.displayName||G.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(me,{className:"h-3.5 w-3.5"})})]})]},G.id)})]})]},t)}),!E&&!l&&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:()=>{z(null),w(!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":p.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.jsxs("select",{"aria-label":"Response language",value:p.language,onChange:t=>p.updateSettings({language:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"en-US",children:"English (US)"}),e.jsx("option",{value:"zh-CN",children:"简体中文"}),e.jsx("option",{value:"zh-TW",children:"繁體中文"}),e.jsx("option",{value:"ja-JP",children:"日本語"}),e.jsx("option",{value:"ko-KR",children:"한국어"}),e.jsx("option",{value:"es-ES",children:"Español"}),e.jsx("option",{value:"fr-FR",children:"Français"}),e.jsx("option",{value:"de-DE",children:"Deutsch"}),e.jsx("option",{value:"pt-BR",children:"Português (BR)"}),e.jsx("option",{value:"ru-RU",children:"Русский"})]})]}),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(ne,{label:"Auto-save sessions",enabled:p.autoSaveSessions,onChange:t=>p.updateSettings({autoSaveSessions:t})})]})]}),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:()=>p.updateSettings({uiTheme:t}),className:T("px-3 py-1 rounded text-[12px] font-mono transition-colors",p.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(ne,{label:"Compact sidebar",enabled:!D,onChange:t=>U(!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.jsxs("select",{"aria-label":"Code theme",value:p.theme,onChange:t=>p.updateSettings({theme:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"dracula",children:"Dracula"}),e.jsx("option",{value:"monokai",children:"Monokai"}),e.jsx("option",{value:"nord",children:"Nord"}),e.jsx("option",{value:"tokyo-night",children:"Tokyo Night"}),e.jsx("option",{value:"one-dark",children:"One Dark"}),e.jsx("option",{value:"catppuccin",children:"Catppuccin"}),e.jsx("option",{value:"gruvbox",children:"Gruvbox"}),e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"solarized-light",children:"Solarized Light"}),e.jsx("option",{value:"solarized-dark",children:"Solarized Dark"}),e.jsx("option",{value:"ayu-dark",children:"Ayu Dark"}),e.jsx("option",{value:"rose-pine",children:"Rose Pine"}),e.jsx("option",{value:"kanagawa",children:"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(ne,{label:"Build finished notifications",enabled:p.notifyBuild,onChange:t=>p.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(ne,{label:"Error notifications",enabled:p.notifyErrors,onChange:t=>p.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(ne,{label:"System sounds",enabled:p.notifySounds,onChange:t=>p.updateSettings({notifySounds:t})})]}),(p.notifyBuild||p.notifyErrors)&&oe!=="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:oe==="denied"?"Browser notifications are blocked":oe==="unsupported"?"Browser notifications are unavailable":"Enable alerts while this tab is in the background"}),oe==="default"&&e.jsx("button",{type:"button",onClick:()=>void Be(),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(ne,{label:"Telemetry",enabled:p.privacyTelemetry,onChange:t=>p.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(ne,{label:"Crash reports",enabled:p.privacyCrash,onChange:t=>p.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:"flex-1 h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono"}),e.jsxs("select",{"aria-label":"Shortcut scope",value:n,onChange:t=>P(t.target.value),className:"h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:[e.jsx("option",{value:"all",children:"All scopes"}),e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"layout",children:"Layout"})]}),e.jsx("button",{onClick:()=>{V(""),P("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"})]}),ie.map((t,u)=>e.jsxs("div",{className:T("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",u%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(b=>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:b},b))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),ie.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:()=>{g(),pe.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:()=>{g(),pe.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(st,{})}),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(nt,{})}),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(ot,{})})]})})})]}),B&&e.jsx(Ze,{open:!0,onOpenChange:t=>{t||(le.current=Date.now()),w(t)},onSave:Pe,saveError:L}),r&&e.jsx(et,{open:!0,onOpenChange:t=>{t||(le.current=Date.now(),A(null))},model:r,onSave:Re,saveError:L}),N&&e.jsx(tt,{provider:N,onOpenChange:t=>{t||(le.current=Date.now(),y(null))},onSave:Te,saveError:Z})]})}function ne({label:o,enabled:x,onChange:g}){return e.jsx("button",{type:"button",role:"switch","aria-label":o,"aria-checked":x,onClick:()=>g(!x),className:T("flex h-6 w-11 items-center rounded-full px-1 transition-colors",x?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:T("h-4 w-4 rounded-full transition-transform",x?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{pt as SettingsModal};
@@ -0,0 +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};
@@ -0,0 +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};