blade-code 0.10.7 → 0.10.9

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 (123) hide show
  1. package/dist/blade.js +3 -3
  2. package/dist/{chunk-jpy61wna.js → chunk-095x2ykj.js} +1 -1
  3. package/dist/chunk-17g172md.js +9 -0
  4. package/dist/{chunk-4hhkbyja.js → chunk-25cqav2f.js} +2 -2
  5. package/dist/chunk-27dr7bz0.js +2 -0
  6. package/dist/{chunk-vcq624qv.js → chunk-2c9ssx8y.js} +2 -2
  7. package/dist/{chunk-tc83e1b0.js → chunk-2wmnzxfz.js} +1 -1
  8. package/dist/chunk-2zwyvfbm.js +2 -0
  9. package/dist/chunk-39xzkky9.js +1 -0
  10. package/dist/chunk-3e5etzj8.js +2 -0
  11. package/dist/{chunk-m86ekqp0.js → chunk-41wym9fn.js} +2 -2
  12. package/dist/chunk-469ht1ty.js +194 -0
  13. package/dist/{chunk-p3ahf1fh.js → chunk-484ve631.js} +1 -1
  14. package/dist/chunk-4gegd63m.js +1 -0
  15. package/dist/{chunk-qqwgb9ja.js → chunk-4gkn11cb.js} +2 -2
  16. package/dist/chunk-4gptj397.js +1 -0
  17. package/dist/chunk-4v7h259s.js +2 -0
  18. package/dist/chunk-4xsqe5sn.js +2 -0
  19. package/dist/chunk-4yh4yeep.js +1 -0
  20. package/dist/chunk-5410er6c.js +1 -0
  21. package/dist/{chunk-p0j8994h.js → chunk-5ehe3xra.js} +1 -1
  22. package/dist/chunk-60764481.js +5 -0
  23. package/dist/{chunk-vafn0spm.js → chunk-686at39n.js} +1 -1
  24. package/dist/{chunk-7pkrwh10.js → chunk-6c1qjy1v.js} +1 -1
  25. package/dist/{chunk-7a200q5g.js → chunk-6rcwvrd1.js} +2 -2
  26. package/dist/{chunk-az4b6106.js → chunk-7by8mhzq.js} +1 -1
  27. package/dist/chunk-8g4n4578.js +4 -0
  28. package/dist/{chunk-1sw9z975.js → chunk-8j01ssaf.js} +1 -1
  29. package/dist/chunk-9dd2qmky.js +22 -0
  30. package/dist/chunk-afbky4f9.js +100 -0
  31. package/dist/chunk-amp9a6rq.js +2 -0
  32. package/dist/{chunk-wrbm6rch.js → chunk-b3qwhhpy.js} +2 -2
  33. package/dist/{chunk-yyvx1avz.js → chunk-bzvwcyma.js} +3 -3
  34. package/dist/{chunk-tcc3v4n2.js → chunk-c23vgww8.js} +1 -1
  35. package/dist/chunk-cgk8cft8.js +1 -0
  36. package/dist/chunk-cr7ncgsh.js +6 -0
  37. package/dist/chunk-dg6abzwy.js +1 -0
  38. package/dist/{chunk-847e0sk9.js → chunk-e0vwbx8b.js} +1 -1
  39. package/dist/chunk-e2f1kgt4.js +1 -0
  40. package/dist/chunk-f8nw8dcq.js +1481 -0
  41. package/dist/{chunk-qk2z6gag.js → chunk-gk1wq9rv.js} +2 -2
  42. package/dist/{chunk-kqpwz9b7.js → chunk-gv15jmxf.js} +2 -2
  43. package/dist/chunk-h4azdqke.js +10 -0
  44. package/dist/{chunk-43j2f1b5.js → chunk-h7szqxtg.js} +2 -2
  45. package/dist/chunk-jdy3ceqv.js +6 -0
  46. package/dist/{chunk-mt4328yf.js → chunk-jxhpwm5k.js} +2 -2
  47. package/dist/{chunk-0n04bmta.js → chunk-jzn1qtrc.js} +2 -2
  48. package/dist/chunk-k0n4prs1.js +2 -0
  49. package/dist/{chunk-tp9zk241.js → chunk-kg4xd3yf.js} +1 -1
  50. package/dist/chunk-m4b00d6v.js +1 -0
  51. package/dist/{chunk-ne7zdjrh.js → chunk-mzgwy44f.js} +1 -1
  52. package/dist/{chunk-x3780wpy.js → chunk-n2hn6tn2.js} +16 -16
  53. package/dist/chunk-n4e454dw.js +2 -0
  54. package/dist/{chunk-1v7hpr34.js → chunk-ncxavkjp.js} +1 -1
  55. package/dist/chunk-nezwz71s.js +1 -0
  56. package/dist/{chunk-rn908m3v.js → chunk-ns9emet3.js} +2 -2
  57. package/dist/chunk-p7s0rwk3.js +1 -0
  58. package/dist/{chunk-g3wgzyhx.js → chunk-p839x5dd.js} +48 -48
  59. package/dist/chunk-qtypjqb8.js +3 -0
  60. package/dist/{chunk-0xm8hn2h.js → chunk-r7mhhrp6.js} +2 -2
  61. package/dist/chunk-racbf4zb.js +1 -0
  62. package/dist/chunk-smpky1s8.js +1 -0
  63. package/dist/{chunk-w01sec4f.js → chunk-st9vr8w3.js} +2 -2
  64. package/dist/{chunk-0z7q89w7.js → chunk-tfefpqz1.js} +1 -1
  65. package/dist/{chunk-ahxc3n3g.js → chunk-vtwvwcz9.js} +2 -2
  66. package/dist/chunk-wc7dt3vm.js +1 -0
  67. package/dist/{chunk-y573s5r8.js → chunk-wr9p5hk3.js} +2 -2
  68. package/dist/chunk-xnb07jbj.js +1 -0
  69. package/dist/{chunk-qycwavck.js → chunk-y9d70cks.js} +2 -2
  70. package/dist/{chunk-3fdyzgpv.js → chunk-ybvdac8k.js} +1 -1
  71. package/dist/{chunk-e9ckf8e7.js → chunk-zns1crmz.js} +1 -1
  72. package/dist/web/assets/ChatView-BPzsdviX.js +7 -0
  73. package/dist/web/assets/{CodeBlockHighlighter-CC4e9nFc.js → CodeBlockHighlighter-7DiEw-B3.js} +1 -1
  74. package/dist/web/assets/{FilePreview-C3HEoLYS.js → FilePreview-5FjwAe93.js} +2 -2
  75. package/dist/web/assets/{MarkdownRenderer-COycrGUX.js → MarkdownRenderer-CjsMv0q1.js} +18 -18
  76. package/dist/web/assets/SettingsModal-EPwoV6vp.js +5 -0
  77. package/dist/web/assets/TaskSwitcher-BOKaxmnf.js +1 -0
  78. package/dist/web/assets/{TerminalPanel-DqQ-7CTG.js → TerminalPanel-CZJYrbjQ.js} +1 -1
  79. package/dist/web/assets/index-CU-jckjp.css +1 -0
  80. package/dist/web/assets/index-I_DKONsY.js +32 -0
  81. package/dist/web/assets/{vendor-icons-D_AkWmWB.js → vendor-icons-ICv1v-tf.js} +81 -71
  82. package/dist/web/assets/{vendor-radix-DBy9B2DN.js → vendor-radix-DXRuAJHH.js} +1 -1
  83. package/dist/web/index.html +4 -4
  84. package/package.json +3 -1
  85. package/dist/chunk-4rhssb85.js +0 -2
  86. package/dist/chunk-598egka3.js +0 -22
  87. package/dist/chunk-5ak9tw83.js +0 -100
  88. package/dist/chunk-738pkjf8.js +0 -1
  89. package/dist/chunk-7xfmzvxp.js +0 -1
  90. package/dist/chunk-867rz2ss.js +0 -1
  91. package/dist/chunk-a3e97syg.js +0 -3
  92. package/dist/chunk-akev4wsz.js +0 -2
  93. package/dist/chunk-f7854pbx.js +0 -187
  94. package/dist/chunk-fwt0kje3.js +0 -1
  95. package/dist/chunk-g1q27q6q.js +0 -2
  96. package/dist/chunk-g4snq0dx.js +0 -1
  97. package/dist/chunk-ggm04adj.js +0 -1
  98. package/dist/chunk-hpytxsge.js +0 -1
  99. package/dist/chunk-htr91q9c.js +0 -1
  100. package/dist/chunk-hwcp940f.js +0 -1
  101. package/dist/chunk-j5ysjbyr.js +0 -10
  102. package/dist/chunk-m8k1mv0j.js +0 -4
  103. package/dist/chunk-pt659n0v.js +0 -1466
  104. package/dist/chunk-q1gfeadm.js +0 -1
  105. package/dist/chunk-rk1w5pry.js +0 -2
  106. package/dist/chunk-rz2ftt6h.js +0 -5
  107. package/dist/chunk-rz9yh6e4.js +0 -6
  108. package/dist/chunk-tzh4ahry.js +0 -6
  109. package/dist/chunk-v0rn831t.js +0 -1
  110. package/dist/chunk-vynsgc2g.js +0 -1
  111. package/dist/chunk-w0ena7fe.js +0 -9
  112. package/dist/chunk-wmdgb5pz.js +0 -2
  113. package/dist/chunk-ydwjttdz.js +0 -1
  114. package/dist/chunk-z9fsh3kn.js +0 -1
  115. package/dist/chunk-zjf1z27e.js +0 -2
  116. package/dist/web/assets/ChatView-BYfHmxKJ.js +0 -7
  117. package/dist/web/assets/McpModal-CDgr9kVq.js +0 -5
  118. package/dist/web/assets/SettingsModal-CvdVIbeG.js +0 -1
  119. package/dist/web/assets/SkillsModal-lSX1ZKTu.js +0 -1
  120. package/dist/web/assets/TaskSwitcher-peKi9KvN.js +0 -1
  121. package/dist/web/assets/index-BF5HEN_f.js +0 -32
  122. package/dist/web/assets/index-BrkTYxtS.css +0 -1
  123. package/dist/web/assets/useRequest-BvqVDnKl.js +0 -1
@@ -0,0 +1,5 @@
1
+ import{r as n,e as Qe,g as $t,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as ge,j as D,v as q,D as $e,e as Ie,w as Je,g as Ke,P as Xt,x as Zt,y as ea,S as ta,a as Le,z as It,A as Pe,E as aa,b as sa,F as na,K as ra,G as la}from"./index-I_DKONsY.js";import{_ as ie,n as se,o as ke,p as dt,q as ct,r as Kt}from"./vendor-radix-DXRuAJHH.js";import{a as Te,i as We,f as Ue,L as ne,k as oa,_ as vt,C as ft,D as ut,X as He,y as _t,a8 as ia,a3 as da,P as mt,T as ze,a9 as ca,aa as ua,u as ht,Z as Ut,O as ma,ab as xa,ac as pa,ad as fa}from"./vendor-icons-ICv1v-tf.js";var ha=function(t){return function(a,s){var l=n.useRef(!1);t(function(){return function(){l.current=!1}},[]),t(function(){if(!l.current)l.current=!0;else return a()},s)}},zt=function(t){return typeof t=="function"},Ee=function(t){var a=n.useRef(t);a.current=n.useMemo(function(){return t},[t]);var s=n.useRef(void 0);return s.current||(s.current=function(){for(var l=[],r=0;r<arguments.length;r++)l[r]=arguments[r];return a.current.apply(this,l)}),s.current};const at=ha(n.useEffect);var Ht=function(t,a){var s=a.manual,l=a.ready,r=l===void 0?!0:l,m=a.defaultParams,h=m===void 0?[]:m,g=a.refreshDeps,u=g===void 0?[]:g,i=a.refreshDepsAction,N=n.useRef(!1);return N.current=!1,at(function(){!s&&r&&(N.current=!0,t.run.apply(t,ie([],se(h),!1)))},[r]),at(function(){N.current||s||(N.current=!0,i?i():t.refresh())},ie([],se(u),!1)),{onBefore:function(){if(!r)return{stopNow:!0}}}};Ht.onInit=function(t){var a=t.ready,s=a===void 0?!0:a,l=t.manual;return{loading:!l&&s}};function xt(t,a){if(t===a)return!0;for(var s=0;s<t.length;s++)if(!Object.is(t[s],a[s]))return!1;return!0}var Gt=function(t,a){var s=n.useRef({deps:a,obj:void 0,initialized:!1}).current;return(s.initialized===!1||!xt(s.deps,a))&&(s.deps=a,s.obj=t(),s.initialized=!0),s.obj};function nt(t){var a=n.useRef(t);return a.current=t,a}var Ye=function(t){var a=nt(t);n.useEffect(function(){return function(){a.current()}},[])},Xe=new Map,ga=function(t,a,s){var l=Xe.get(t);l!=null&&l.timer&&clearTimeout(l.timer);var r=void 0;a>-1&&(r=setTimeout(function(){Xe.delete(t)},a)),Xe.set(t,ke(ke({},s),{timer:r}))},ba=function(t){return Xe.get(t)},Ze=new Map,va=function(t){return Ze.get(t)},ka=function(t,a){Ze.set(t,a),a.then(function(s){return Ze.delete(t),s}).catch(function(){Ze.delete(t)})},De={},ja=function(t,a){De[t]&&De[t].forEach(function(s){return s(a)})},rt=function(t,a){return De[t]||(De[t]=[]),De[t].push(a),function(){var l=De[t].indexOf(a);De[t].splice(l,1)}},ya=function(t,a){var s=a.cacheKey,l=a.cacheTime,r=l===void 0?5*60*1e3:l,m=a.staleTime,h=m===void 0?0:m,g=a.setCache,u=a.getCache,i=n.useRef(void 0),N=n.useRef(void 0),c=function(k,p){g?g(p):ga(k,r,p),ja(k,p.data)},b=function(k,p){return p===void 0&&(p=[]),u?u(p):ba(k)};return Gt(function(){if(s){var k=b(s);k&&Object.hasOwnProperty.call(k,"data")&&(t.state.data=k.data,t.state.params=k.params,(h===-1||Date.now()-k.time<=h)&&(t.state.loading=!1)),i.current=rt(s,function(p){t.setState({data:p})})}},[]),Ye(function(){var k;(k=i.current)===null||k===void 0||k.call(i)}),s?{onBefore:function(k){var p=b(s,k);return!p||!Object.hasOwnProperty.call(p,"data")?{}:h===-1||Date.now()-p.time<=h?{loading:!1,data:p==null?void 0:p.data,error:void 0,returnNow:!0}:{data:p==null?void 0:p.data,error:void 0}},onRequest:function(k,p){var E=va(s);return E&&E!==N.current?{servicePromise:E}:(E=k.apply(void 0,ie([],se(p),!1)),N.current=E,ka(s,E),{servicePromise:E})},onSuccess:function(k,p){var E;s&&((E=i.current)===null||E===void 0||E.call(i),c(s,{data:k,params:p,time:Date.now()}),i.current=rt(s,function(w){t.setState({data:w})}))},onMutate:function(k){var p;s&&((p=i.current)===null||p===void 0||p.call(i),c(s,{data:k,params:t.state.params,time:Date.now()}),i.current=rt(s,function(E){t.setState({data:E})}))}}:{}};function Na(t){var a=typeof t;return t!=null&&(a=="object"||a=="function")}var gt=Na,Ea=typeof Qe=="object"&&Qe&&Qe.Object===Object&&Qe,wa=Ea,Ca=wa,Sa=typeof self=="object"&&self&&self.Object===Object&&self,Aa=Ca||Sa||Function("return this")(),qt=Aa,Fa=qt,Pa=function(){return Fa.Date.now()},Ba=Pa,Ta=/\s/;function Ma(t){for(var a=t.length;a--&&Ta.test(t.charAt(a)););return a}var Ra=Ma,Oa=Ra,Da=/^\s+/;function La(t){return t&&t.slice(0,Oa(t)+1).replace(Da,"")}var $a=La,Ia=qt,Ka=Ia.Symbol,Wt=Ka,kt=Wt,Jt=Object.prototype,_a=Jt.hasOwnProperty,Ua=Jt.toString,qe=kt?kt.toStringTag:void 0;function za(t){var a=_a.call(t,qe),s=t[qe];try{t[qe]=void 0;var l=!0}catch{}var r=Ua.call(t);return l&&(a?t[qe]=s:delete t[qe]),r}var Ha=za,Ga=Object.prototype,qa=Ga.toString;function Wa(t){return qa.call(t)}var Ja=Wa,jt=Wt,Ya=Ha,Va=Ja,Qa="[object Null]",Xa="[object Undefined]",yt=jt?jt.toStringTag:void 0;function Za(t){return t==null?t===void 0?Xa:Qa:yt&&yt in Object(t)?Ya(t):Va(t)}var es=Za;function ts(t){return t!=null&&typeof t=="object"}var as=ts,ss=es,ns=as,rs="[object Symbol]";function ls(t){return typeof t=="symbol"||ns(t)&&ss(t)==rs}var os=ls,is=$a,Nt=gt,ds=os,Et=NaN,cs=/^[-+]0x[0-9a-f]+$/i,us=/^0b[01]+$/i,ms=/^0o[0-7]+$/i,xs=parseInt;function ps(t){if(typeof t=="number")return t;if(ds(t))return Et;if(Nt(t)){var a=typeof t.valueOf=="function"?t.valueOf():t;t=Nt(a)?a+"":a}if(typeof t!="string")return t===0?t:+t;t=is(t);var s=us.test(t);return s||ms.test(t)?xs(t.slice(2),s?2:8):cs.test(t)?Et:+t}var fs=ps,hs=gt,lt=Ba,wt=fs,gs="Expected a function",bs=Math.max,vs=Math.min;function ks(t,a,s){var l,r,m,h,g,u,i=0,N=!1,c=!1,b=!0;if(typeof t!="function")throw new TypeError(gs);a=wt(a)||0,hs(s)&&(N=!!s.leading,c="maxWait"in s,m=c?bs(wt(s.maxWait)||0,a):m,b="trailing"in s?!!s.trailing:b);function k(A){var F=l,R=r;return l=r=void 0,i=A,h=t.apply(R,F),h}function p(A){return i=A,g=setTimeout(B,a),N?k(A):h}function E(A){var F=A-u,R=A-i,j=a-F;return c?vs(j,m-R):j}function w(A){var F=A-u,R=A-i;return u===void 0||F>=a||F<0||c&&R>=m}function B(){var A=lt();if(w(A))return I(A);g=setTimeout(B,E(A))}function I(A){return g=void 0,b&&l?k(A):(l=r=void 0,h)}function y(){g!==void 0&&clearTimeout(g),i=0,l=u=r=g=void 0}function S(){return g===void 0?h:I(lt())}function U(){var A=lt(),F=w(A);if(l=arguments,r=this,u=A,F){if(g===void 0)return p(u);if(c)return clearTimeout(g),g=setTimeout(B,a),k(u)}return g===void 0&&(g=setTimeout(B,a)),h}return U.cancel=y,U.flush=S,U}var Yt=ks;const Vt=$t(Yt);var js=function(t,a){var s=a.debounceWait,l=a.debounceLeading,r=a.debounceTrailing,m=a.debounceMaxWait,h=n.useRef(void 0),g=n.useMemo(function(){var u={};return l!==void 0&&(u.leading=l),r!==void 0&&(u.trailing=r),m!==void 0&&(u.maxWait=m),u},[l,r,m]);return n.useEffect(function(){if(s){var u=t.runAsync.bind(t);return h.current=Vt(function(i){i()},s,g),t.runAsync=function(){for(var i=[],N=0;N<arguments.length;N++)i[N]=arguments[N];return new Promise(function(c,b){var k;(k=h.current)===null||k===void 0||k.call(h,function(){u.apply(void 0,ie([],se(i),!1)).then(c).catch(b)})})},function(){var i;(i=h.current)===null||i===void 0||i.cancel(),t.runAsync=u}}},[s,g]),s?{onCancel:function(){var u;(u=h.current)===null||u===void 0||u.cancel()}}:{}},ys=function(t,a){var s=a.loadingDelay,l=a.ready,r=n.useRef(void 0);if(!s)return{};var m=function(){r.current&&clearTimeout(r.current)};return{onBefore:function(){return m(),l!==!1&&(r.current=setTimeout(function(){t.setState({loading:!0})},s)),{loading:!1}},onFinally:function(){m()},onCancel:function(){m()}}},Ve=!!(typeof window<"u"&&window.document&&window.document.createElement);function bt(){return Ve?document.visibilityState!=="hidden":!0}var et=new Set;function Ns(t){return et.add(t),function(){et.has(t)&&et.delete(t)}}if(Ve){var Es=function(){bt()&&et.forEach(function(t){return t()})};window.addEventListener("visibilitychange",Es,!1)}var ws=function(t,a){var s=a.pollingInterval,l=a.pollingWhenHidden,r=l===void 0?!0:l,m=a.pollingErrorRetryCount,h=m===void 0?-1:m,g=n.useRef(void 0),u=n.useRef(void 0),i=n.useRef(0),N=function(){var c;g.current&&clearTimeout(g.current),(c=u.current)===null||c===void 0||c.call(u)};return at(function(){s||N()},[s]),s?{onBefore:function(){N()},onError:function(){i.current+=1},onSuccess:function(){i.current=0},onFinally:function(){h===-1||h!==-1&&i.current<=h?g.current=setTimeout(function(){!r&&!bt()?u.current=Ns(function(){t.refresh()}):t.refresh()},s):i.current=0},onCancel:function(){N()}}:{}};function Cs(t,a){var s=!1;return function(){for(var l=[],r=0;r<arguments.length;r++)l[r]=arguments[r];s||(s=!0,t.apply(void 0,ie([],se(l),!1)),setTimeout(function(){s=!1},a))}}var Ss=function(){return Ve&&typeof navigator.onLine<"u"?navigator.onLine:!0},tt=new Set;function As(t){return tt.add(t),function(){tt.has(t)&&tt.delete(t)}}if(Ve){var Ct=function(){!bt()||!Ss()||tt.forEach(function(t){return t()})};window.addEventListener("visibilitychange",Ct,!1),window.addEventListener("focus",Ct,!1)}var Fs=function(t,a){var s=a.refreshOnWindowFocus,l=a.focusTimespan,r=l===void 0?5e3:l,m=n.useRef(void 0),h=function(){var g;(g=m.current)===null||g===void 0||g.call(m)};return n.useEffect(function(){if(s){var g=Cs(t.refresh.bind(t),r);m.current=As(function(){g()})}return function(){h()}},[s,r]),Ye(function(){h()}),{}},Ps=function(t,a){var s=a.retryInterval,l=a.retryCount,r=n.useRef(void 0),m=n.useRef(0),h=n.useRef(!1);return l?{onBefore:function(){h.current||(m.current=0),h.current=!1,r.current&&clearTimeout(r.current)},onSuccess:function(){m.current=0},onError:function(){if(m.current+=1,l===-1||m.current<=l){var g=s??Math.min(1e3*Math.pow(2,m.current),3e4);r.current=setTimeout(function(){h.current=!0,t.refresh()},g)}else m.current=0},onCancel:function(){m.current=0,r.current&&clearTimeout(r.current)}}:{}},Bs=Yt,Ts=gt,Ms="Expected a function";function Rs(t,a,s){var l=!0,r=!0;if(typeof t!="function")throw new TypeError(Ms);return Ts(s)&&(l="leading"in s?!!s.leading:l,r="trailing"in s?!!s.trailing:r),Bs(t,a,{leading:l,maxWait:a,trailing:r})}var Os=Rs;const Ds=$t(Os);var Ls=function(t,a){var s=a.throttleWait,l=a.throttleLeading,r=a.throttleTrailing,m=n.useRef(void 0),h={};return l!==void 0&&(h.leading=l),r!==void 0&&(h.trailing=r),n.useEffect(function(){if(s){var g=t.runAsync.bind(t);return m.current=Ds(function(u){u()},s,h),t.runAsync=function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];return new Promise(function(N,c){var b;(b=m.current)===null||b===void 0||b.call(m,function(){g.apply(void 0,ie([],se(u),!1)).then(N).catch(c)})})},function(){var u;t.runAsync=g,(u=m.current)===null||u===void 0||u.cancel()}}},[s,l,r]),s?{onCancel:function(){var g;(g=m.current)===null||g===void 0||g.cancel()}}:{}},$s=function(t){n.useEffect(function(){var a=t==null?void 0:t();if(!(a&&typeof a=="object"&&typeof a.then=="function"))return a},[])},Is=function(){var t=se(n.useState({}),2),a=t[1];return Ee(function(){return a({})})},Ks=function(){function t(a,s,l,r){r===void 0&&(r={}),this.serviceRef=a,this.options=s,this.subscribe=l,this.initState=r,this.pluginImpls=[],this.count=0,this.state={loading:!1,params:void 0,data:void 0,error:void 0},this.state=ke(ke(ke({},this.state),{loading:!s.manual}),r)}return t.prototype.setState=function(a){a===void 0&&(a={}),this.state=ke(ke({},this.state),a),this.subscribe()},t.prototype.runPluginHandler=function(a){for(var s=[],l=1;l<arguments.length;l++)s[l-1]=arguments[l];var r=this.pluginImpls.map(function(m){var h;return(h=m[a])===null||h===void 0?void 0:h.call.apply(h,ie([m],se(s),!1))}).filter(Boolean);return Object.assign.apply(Object,ie([{}],se(r),!1))},t.prototype.runAsync=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];return dt(this,void 0,void 0,function(){var l,r,m,h,g,u,i,N,c,b,k,p,E,w,B,I,y,S,U,A,F;return ct(this,function(R){switch(R.label){case 0:if(this.count+=1,l=this.count,r=this.runPluginHandler("onBefore",a),m=r.stopNow,h=m===void 0?!1:m,g=r.returnNow,u=g===void 0?!1:g,i=Kt(r,["stopNow","returnNow"]),h)return[2,Promise.resolve(i.data)];if(this.setState(ke({loading:!0,params:a},i)),u)return[2,Promise.resolve(i.data)];(E=(p=this.options).onBefore)===null||E===void 0||E.call(p,a),R.label=1;case 1:return R.trys.push([1,3,,4]),N=this.runPluginHandler("onRequest",this.serviceRef.current,a).servicePromise,N||(N=(k=this.serviceRef).current.apply(k,ie([],se(a),!1))),[4,N];case 2:return c=R.sent(),l!==this.count?[2,new Promise(function(){})]:(this.setState({data:c,error:void 0,loading:!1}),(B=(w=this.options).onSuccess)===null||B===void 0||B.call(w,c,a),this.runPluginHandler("onSuccess",c,a),(y=(I=this.options).onFinally)===null||y===void 0||y.call(I,a,c,void 0),l===this.count&&this.runPluginHandler("onFinally",a,c,void 0),[2,c]);case 3:if(b=R.sent(),l!==this.count)return[2,new Promise(function(){})];throw this.setState({error:b,loading:!1}),(U=(S=this.options).onError)===null||U===void 0||U.call(S,b,a),this.runPluginHandler("onError",b,a),(F=(A=this.options).onFinally)===null||F===void 0||F.call(A,a,void 0,b),l===this.count&&this.runPluginHandler("onFinally",a,void 0,b),b;case 4:return[2]}})})},t.prototype.run=function(){for(var a=this,s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];this.runAsync.apply(this,ie([],se(s),!1)).catch(function(r){a.options.onError||console.error(r)})},t.prototype.cancel=function(){this.count+=1,this.setState({loading:!1}),this.runPluginHandler("onCancel")},t.prototype.refresh=function(){this.run.apply(this,ie([],se(this.state.params||[]),!1))},t.prototype.refreshAsync=function(){return this.runAsync.apply(this,ie([],se(this.state.params||[]),!1))},t.prototype.mutate=function(a){var s=zt(a)?a(this.state.data):a;this.runPluginHandler("onMutate",s),this.setState({data:s})},t}();function _s(t,a,s){a===void 0&&(a={}),s===void 0&&(s=[]);var l=a.manual,r=l===void 0?!1:l,m=a.ready,h=m===void 0?!0:m,g=Kt(a,["manual","ready"]),u=ke({manual:r,ready:h},g),i=nt(t),N=Is(),c=Gt(function(){var b=s.map(function(k){var p;return(p=k==null?void 0:k.onInit)===null||p===void 0?void 0:p.call(k,u)}).filter(Boolean);return new Ks(i,u,N,Object.assign.apply(Object,ie([{}],se(b),!1)))},[]);return c.options=u,c.pluginImpls=s.map(function(b){return b(c,u)}),$s(function(){if(!r&&h){var b=c.state.params||a.defaultParams||[];c.run.apply(c,ie([],se(b),!1))}}),Ye(function(){c.cancel()}),{loading:c.state.loading,data:c.state.data,error:c.state.error,params:c.state.params||[],cancel:Ee(c.cancel.bind(c)),refresh:Ee(c.refresh.bind(c)),refreshAsync:Ee(c.refreshAsync.bind(c)),run:Ee(c.run.bind(c)),runAsync:Ee(c.runAsync.bind(c)),mutate:Ee(c.mutate.bind(c))}}function _e(t,a,s){return _s(t,a,ie(ie([],se([]),!1),[js,ys,ws,Fs,Ls,Ht,ya,Ps],!1))}function st(t,a){if(Ve){if(!t)return a;var s;return zt(t)?s=t():"current"in t?s=t.current:s=t,s}}var Us=function(t){var a=function(s,l,r){var m=n.useRef(!1),h=n.useRef([]),g=n.useRef([]),u=n.useRef(void 0);t(function(){var i,N=Array.isArray(r)?r:[r],c=N.map(function(b){return st(b)});if(!m.current){m.current=!0,h.current=c,g.current=l,u.current=s();return}(c.length!==h.current.length||!xt(h.current,c)||!xt(g.current,l))&&((i=u.current)===null||i===void 0||i.call(u),h.current=c,g.current=l,u.current=s())}),Ye(function(){var i;(i=u.current)===null||i===void 0||i.call(u),m.current=!1})};return a},zs=Us(n.useEffect);function Hs(){var t=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,a=typeof self=="object"&&self&&self.Object===Object&&self;return t||a}Hs()||(global.Date=Date);function Gs(t,a){var s,l=nt(t),r=(s=a==null?void 0:a.wait)!==null&&s!==void 0?s:1e3,m=n.useMemo(function(){return Vt(function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];return l.current.apply(l,ie([],se(h),!1))},r,a)},[]);return Ye(function(){m.cancel()}),{run:m,cancel:m.cancel,flush:m.flush}}function qs(t,a,s){s===void 0&&(s={});var l=s.enable,r=l===void 0?!0:l,m=nt(a);zs(function(){if(r){var h=st(s.target,window);if(h!=null&&h.addEventListener){var g=function(i){return m.current(i)},u=Array.isArray(t)?t:[t];return u.forEach(function(i){h.addEventListener(i,g,{capture:s.capture,once:s.once,passive:s.passive})}),function(){u.forEach(function(i){h.removeEventListener(i,g,{capture:s.capture})})}}}},[t,s.capture,s.once,s.passive,r],s.target)}var Ws=function(t){return t===document||t===document.documentElement||t===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):t.scrollTop},St=function(t){return t.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},Js=function(t){return t.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},Ys=function(t,a){a===void 0&&(a={});var s=a.target,l=a.isNoMore,r=a.threshold,m=r===void 0?100:r,h=a.direction,g=h===void 0?"bottom":h,u=a.reloadDeps,i=u===void 0?[]:u,N=a.manual,c=a.onBefore,b=a.onSuccess,k=a.onError,p=a.onFinally,E=se(n.useState(),2),w=E[0],B=E[1],I=se(n.useState(!1),2),y=I[0],S=I[1],U=g==="top",A=n.useRef(void 0),F=n.useRef(0),R=n.useMemo(function(){return l?l(w):!1},[w]),j=_e(function(L){return dt(void 0,void 0,void 0,function(){var C;return ct(this,function(v){switch(v.label){case 0:return[4,t(L)];case 1:return C=v.sent(),[2,{currentData:C,lastData:L}]}})})},{manual:N,onFinally:function(L,C,v){S(!1),p==null||p(C==null?void 0:C.currentData,v)},onBefore:function(){return c==null?void 0:c()},onSuccess:function(L){var C,v,M;L.lastData?B(ke(ke({},L.currentData),{list:U?ie(ie([],se(L.currentData.list),!1),se((v=L.lastData.list)!==null&&v!==void 0?v:[]),!1):ie(ie([],se((M=L.lastData.list)!==null&&M!==void 0?M:[]),!1),se(L.currentData.list),!1)})):B(ke(ke({},L.currentData),{list:ie([],se((C=L.currentData.list)!==null&&C!==void 0?C:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(U){var V=st(s);if(V=V===document?document.documentElement:V,V){var pe=St(V);V.scrollTo(0,pe-F.current)}}else te()})}),b==null||b(L.currentData)},onError:function(L){return k==null?void 0:k(L)}}),O=j.loading,Q=j.error,Y=j.run,Z=j.runAsync,ee=j.cancel,J=Ee(function(){R||(S(!0),Y(w))}),X=function(L){return dt(void 0,void 0,void 0,function(){var C;return ct(this,function(v){switch(v.label){case 0:return[4,Z(L)];case 1:return C=v.sent(),[2,C.currentData]}})})},T=Ee(function(){return R?Promise.reject():(S(!0),X(w))}),K=function(){return S(!1),Y()},G=function(){return S(!1),X()},te=function(){var L=st(s);if(L){var C=L===document?document.documentElement:L,v=Ws(C),M=St(C),V=Js(C);U?(A.current!==void 0&&A.current>v&&v<=m&&J(),A.current=v,F.current=M-v):M-v<=V+m&&J()}};return qs("scroll",function(){O||y||te()},{target:s}),at(function(){Y()},ie([],se(i),!1)),{data:w,loading:!y&&O,error:Q,loadingMore:y,noMore:R,loadMore:J,loadMoreAsync:T,reload:Ee(K),reloadAsync:Ee(G),mutate:B,cancel:ee}};const At={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},Vs={connected:"mcp.status.connected",connecting:"mcp.status.connecting",reconnecting:"mcp.status.reconnecting",offline:"mcp.status.offline",error:"mcp.status.error"},Qs={disabled:"mcp.oauth.status.disabled",unavailable:"mcp.oauth.status.unavailable",unauthenticated:"mcp.oauth.status.unauthenticated",authorizing:"mcp.oauth.status.authorizing",authenticated:"mcp.oauth.status.authenticated",error:"mcp.oauth.status.error"},Xs={Official:"mcp.catalog.tag.official",Popular:"mcp.catalog.tag.popular",Community:"mcp.catalog.tag.community"},Ft=20,Zs=["debug","info","notice","warning","error","critical","alert","emergency"],Pt=(t,a)=>t.status!=="reconnecting"||!t.recovery?a(Vs[t.status]):a("mcp.status.recoveringAttempt",{attempt:t.recovery.attempt,max:t.recovery.maxAttempts}),en=async()=>q("/mcp"),tn=async t=>q(`/mcp/${encodeURIComponent(t)}/logs?limit=20`),an="mcp server @modelcontextprotocol",sn=3,Qt=t=>{var a;return((a=t.split("/").pop())==null?void 0:a.replace(/^server-/,""))||t},nn=async(t,a)=>{const s=t&&t.length>=sn?t:an,l=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(s)}&size=${Ft}&from=${a}`,r=await q(l);return{list:r.objects.map(m=>m.package),total:r.total,hasMore:a+Ft<r.total}};function rn({active:t}){const a=ge(),[s,l]=n.useState("installed"),[r,m]=n.useState(!1),[h,g]=n.useState(null),[u,i]=n.useState(""),[N,c]=n.useState(null),[b,k]=n.useState(null),[p,E]=n.useState(null),[w,B]=n.useState(null),[I,y]=n.useState(null),[S,U]=n.useState(""),[A,F]=n.useState(null),[R,j]=n.useState(!1),[O,Q]=n.useState(null),[Y,Z]=n.useState(null),[ee,J]=n.useState(""),[X,T]=n.useState(""),[K,G]=n.useState(null),[te,L]=n.useState(null),C=n.useRef(null),{run:v}=Gs(d=>{T(d)},{wait:500}),{data:M=[],loading:V,error:pe,run:Ae,runAsync:le}=_e(en,{refreshDeps:[t],ready:t,onSuccess:d=>{d.length>0&&!h&&g(d[0].id)}}),{data:he,loading:we,error:ce,runAsync:Ce}=_e(tn,{manual:!0}),{data:de,loading:re,loadingMore:f,noMore:_,error:ae,reload:oe}=Ys(async d=>{var H;const W=((H=d==null?void 0:d.list)==null?void 0:H.length)??0;return nn(X,W)},{target:C,isNoMore:d=>!(d!=null&&d.hasMore),reloadDeps:[X],manual:!t||s!=="catalog"}),{runAsync:xe,loading:fe,error:be}=_e(async d=>{await q("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,config:d})})},{manual:!0,onSuccess:()=>{le(),m(!1),L(null),G(null)},onError:()=>{G(null)}}),Fe=n.useMemo(()=>{const d=u.trim().toLowerCase();return d?M.filter(W=>[W.name,W.endpoint,W.description].some(H=>H.toLowerCase().includes(d))):M},[u,M]),P=n.useMemo(()=>Fe.find(d=>d.id===h)??Fe[0],[Fe,h]),Be=n.useMemo(()=>{if(!P)return[];const d=(P.prompts??[]).flatMap(H=>H.arguments.map(ye=>({key:`prompt:${H.name}:${ye.name}`,label:`${H.name}.${ye.name}`,reference:{type:"prompt",name:H.name},argument:ye.name}))),W=(P.resourceTemplates??[]).flatMap(H=>(H.variables??[]).map(ye=>({key:`resource:${H.uriTemplate}:${ye}`,label:`${H.uriTemplate} · ${ye}`,reference:{type:"resource",uri:H.uriTemplate},argument:ye})));return[...d,...W]},[P]),ve=Be.find(d=>d.key===I)??Be[0];n.useEffect(()=>{if(!t||!M.some(W=>W.oauthStatus==="authorizing"||W.status==="connecting"||W.status==="reconnecting"))return;const d=window.setInterval(()=>{le()},1e3);return()=>window.clearInterval(d)},[t,le,M]),n.useEffect(()=>{b&&M.some(d=>d.name===b.serverName&&(d.oauthStatus==="authenticated"||d.oauthStatus==="disabled"||d.oauthStatus==="unavailable"))&&k(null)},[b,M]),n.useEffect(()=>{!t||s!=="installed"||!P||Ce(P.name).catch(()=>{})},[t,Ce,P,s]);const Me=async(d,W)=>{E({type:d,name:W}),c(null);try{const H=d==="delete"?"":`/${d}`;await q(`/mcp/${encodeURIComponent(W)}${H}`,{method:d==="delete"?"DELETE":"POST"}),await le(),d==="delete"&&(Z(null),g(null))}catch(H){c(H instanceof Error?H.message:a(d==="connect"?"mcp.error.connectFailed":d==="disconnect"?"mcp.error.disconnectFailed":"mcp.error.deleteFailed"))}finally{E(null)}},x=async(d,W)=>{E({type:d,name:W.name}),c(null);try{if(d==="login"){const H=await q(`/mcp/${encodeURIComponent(W.name)}/oauth/login`,{method:"POST"});k({serverName:W.name,url:H.authorizationUrl})}else await q(`/mcp/${encodeURIComponent(W.name)}/oauth/logout`,{method:"POST"}),k(null);await le()}catch(H){c(H instanceof Error?H.message:a(d==="login"?"mcp.error.loginFailed":"mcp.error.logoutFailed"))}finally{E(null)}},ue=async(d,W)=>{B(W),c(null);try{await q(`/mcp/${encodeURIComponent(d.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:W})}),await le(),Ce(d.name).catch(()=>{})}catch(H){c(H instanceof Error?H.message:a("mcp.error.loggingLevelFailed"))}finally{B(null)}},Ne=async d=>{if(ve){j(!0),Q(null),F(null);try{const W=await q(`/mcp/${encodeURIComponent(d.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:ve.reference,argument:{name:ve.argument,value:S}})});F(W)}catch(W){Q(W instanceof Error?W.message:a("mcp.error.completionFailed"))}finally{j(!1)}}},je=n.useMemo(()=>new Set(M.map(d=>d.name.toLowerCase())),[M]),o=d=>{L(d)},$=d=>d.startsWith("@modelcontextprotocol/"),z=d=>$(d.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{onClick:Ae,"aria-label":a("mcp.action.refreshServers"),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:V,children:e.jsx(Te,{className:D("h-4 w-4",V&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>m(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("mcp.action.addServer")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsx(Bt,{active:s==="installed",onClick:()=>l("installed"),children:a("mcp.tab.installed",{count:M.length})}),e.jsx(Bt,{active:s==="catalog",onClick:()=>{l("catalog"),de||oe()},children:a("mcp.tab.catalog")})]}),N&&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(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:N}),e.jsx("button",{type:"button",onClick:()=>c(null),className:"underline shrink-0",children:a("mcp.action.dismiss")})]}),s==="installed"?e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:a("mcp.servers.title")}),e.jsx("input",{type:"search","aria-label":a("mcp.servers.searchAria"),value:u,onChange:d=>i(d.target.value),placeholder:a("mcp.servers.searchPlaceholder"),className:"h-8 shrink-0 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[12px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[V&&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(ne,{className:"w-4 h-4 animate-spin"}),a("mcp.servers.loading")]}),pe&&!V&&e.jsxs("div",{role:"alert",className:"flex flex-col gap-2 items-center py-6 font-mono text-xs text-center text-red-600 dark:text-red-400",children:[e.jsx("span",{children:pe.message}),e.jsx("button",{type:"button",onClick:Ae,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("mcp.action.retry")})]}),!pe&&!V&&Fe.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(u?"mcp.servers.noMatch":"mcp.servers.none")}),Fe.map(d=>e.jsxs("button",{onClick:()=>{g(d.id),Z(null),c(null),y(null),U(""),F(null),Q(null)},className:D("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",d.id===(P==null?void 0:P.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:d.name}),e.jsx("span",{className:D("text-[11px] font-mono font-semibold",At[d.status]),children:Pt(d,a)})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:d.endpoint})]},d.id))]})]}),P?e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:P.name}),e.jsx("span",{className:D("text-xs font-mono font-semibold",At[P.status]),children:Pt(P,a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:P.description}),P.error&&e.jsx("p",{className:"text-[12px] font-mono text-[#ef4444]",children:a("mcp.server.errorLabel",{error:P.error})}),P.instructions&&e.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.instructions.title")}),e.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",P.instructions.sha256]})]}),e.jsx("pre",{className:"mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:P.instructions.text??a("mcp.instructions.detailsOmittedByPolicy")}),(P.instructions.truncated||P.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:P.instructions.detailsOmitted?a("mcp.instructions.detailsOmitted"):a("mcp.instructions.truncated")})]}),P.tasks&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tasks.title")}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:P.tasks.enabled?a("mcp.tasks.summary",{count:P.tasks.maxTasksPerSession,interval:P.tasks.pollIntervalMs}):a("mcp.tasks.disabledByDefault")})]}),e.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",P.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:P.tasks.enabled?a("mcp.tasks.enabled"):a("mcp.tasks.disabled")})]}),P.oauthEnabled&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),e.jsx("span",{role:P.oauthStatus==="authorizing"?"status":void 0,className:D("text-[11px] font-mono",P.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":P.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a(Qs[P.oauthStatus])})]}),P.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void x("logout",P),disabled:p!==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:(p==null?void 0:p.type)==="logout"?a("mcp.oauth.signingOut"):a("mcp.oauth.signOut")}):P.oauthStatus==="authorizing"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(b==null?void 0:b.serverName)===P.name?e.jsx("a",{href:b.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:a("mcp.oauth.continueAuthorization")}):e.jsx("button",{type:"button",onClick:()=>void x("login",P),disabled:p!==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:a("mcp.oauth.resumeAuthorization")})]}):P.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void x("login",P),disabled:p!==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:(p==null?void 0:p.type)==="login"?a("mcp.oauth.opening"):a("mcp.oauth.authorize")})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[P.status==="connected"||P.status==="reconnecting"?e.jsx("button",{onClick:()=>void Me("disconnect",P.name),disabled:p!==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:(p==null?void 0:p.type)==="disconnect"&&p.name===P.name?a("mcp.action.disconnecting"):P.status==="reconnecting"?a("mcp.action.stopRecovery"):a("mcp.action.disconnect")}):e.jsx("button",{onClick:()=>void Me("connect",P.name),disabled:p!==null||P.oauthEnabled&&P.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:(p==null?void 0:p.type)==="connect"&&p.name===P.name?a("mcp.action.connecting"):P.oauthEnabled&&P.oauthStatus!=="authenticated"?a("mcp.action.authorizeFirst"):a("mcp.action.connect")}),e.jsx("button",{onClick:()=>Z(P.name),disabled:p!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:a("mcp.action.delete")})]}),Y===P.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("mcp.server.deleteAria",{name:P.name}),className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:a("mcp.delete.confirm")}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>Z(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a("mcp.action.cancel")}),e.jsx("button",{type:"button",onClick:()=>void Me("delete",P.name),disabled:p!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(p==null?void 0:p.type)==="delete"?a("mcp.action.deleting"):a("mcp.action.deleteServer")})]})]}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.tools.title",{count:P.tools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:P.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tools.none")}):P.tools.map(d=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:d},d))}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.completion.title")}),P.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.connectPrompt")}):P.completionSupported?Be.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.noTargets")}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{"aria-label":a("mcp.completion.targetAria"),className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:Be.map(d=>e.jsx("button",{type:"button","aria-pressed":(ve==null?void 0:ve.key)===d.key,onClick:()=>{y(d.key),F(null),Q(null)},className:D("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(ve==null?void 0:ve.key)===d.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:d.label},d.key))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text","aria-label":a("mcp.completion.partialAria"),value:S,onChange:d=>U(d.target.value),placeholder:a("mcp.completion.partialPlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[11px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsx("button",{type:"button",onClick:()=>void Ne(P),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:a(R?"mcp.completion.completing":"mcp.completion.complete")})]}),O&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:O}),A&&e.jsxs("div",{"aria-label":a("mcp.completion.suggestionsAria"),className:"rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:A.values.length>0?A.values.map(d=>e.jsx("span",{className:"rounded bg-white px-2 py-1 text-[10px] font-mono text-[#111827] dark:bg-[#0C0C0C] dark:text-[#E5E5E5]",children:d||a("mcp.completion.empty")},d)):e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF]",children:a("mcp.completion.noSuggestions")})}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",A.sha256,A.truncated?a("mcp.meta.truncatedSuffix"):""]})]})]}):e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.unsupported")}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.diagnostics.title")}),e.jsx("button",{type:"button","aria-label":a("mcp.diagnostics.refreshAria",{name:P.name}),onClick:()=>void Ce(P.name),disabled:we,className:"flex h-7 w-7 items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:text-[#71717a] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Te,{className:D("h-3.5 w-3.5",we&&"animate-spin")})})]}),e.jsx("div",{"aria-label":a("mcp.log.levelAria"),className:"flex flex-wrap gap-1",children:Zs.map(d=>{var W,H;return e.jsx("button",{type:"button",onClick:()=>void ue(P,d),disabled:P.status!=="connected"||w!==null,"aria-pressed":(((W=P.logging)==null?void 0:W.level)??"warning")===d,className:D("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((H=P.logging)==null?void 0:H.level)??"warning")===d?"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:w===d?a("mcp.log.setting"):d},d)})}),ce?e.jsx("div",{role:"alert",className:"rounded-md bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:bg-red-950/30 dark:text-red-300",children:ce.message}):he!=null&&he.entries.length?e.jsx("div",{"aria-label":a("mcp.diagnostics.logsAria",{name:P.name}),className:"flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:he.entries.map(d=>e.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(d.level)?"text-red-600 dark:text-red-400":d.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:d.level}),e.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[d.logger||P.name," · r",d.revision]})]}),e.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:d.message}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",d.dataSha256,d.truncated?a("mcp.meta.truncatedSuffix"):"",d.detailsOmitted?a("mcp.meta.detailsOmittedSuffix"):""]})]},d.revision))}):e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a(we?"mcp.log.loading":"mcp.log.none")})]}):e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a("mcp.server.selectPrompt")})})]}):e.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[e.jsx("div",{className:"flex gap-3 items-center shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(oa,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text","aria-label":a("mcp.catalog.searchAria"),value:ee,onChange:d=>{J(d.target.value),v(d.target.value)},placeholder:a("mcp.catalog.searchPlaceholder"),className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:C,className:"overflow-y-auto flex-1 min-h-0",children:[ae?e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[e.jsx(Ue,{className:"w-6 h-6 text-red-500"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:ae.message}),e.jsx("button",{type:"button",onClick:oe,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:a("mcp.catalog.retry")})]}):re&&!de?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(ne,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[de==null?void 0:de.list.map(d=>{var me,Ge;const W=je.has(Qt(d.name).toLowerCase()),H=K===d.name,ye=z(d);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:d.name}),e.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",ye==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:a(Xs[ye])})]}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] line-clamp-2",children:d.description||a("mcp.catalog.noDescription")}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsxs("span",{children:["v",d.version]}),((me=d.publisher)==null?void 0:me.username)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:a("mcp.catalog.byAuthor",{author:d.publisher.username})})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 mt-auto",children:[e.jsxs("a",{href:((Ge=d.links)==null?void 0:Ge.npm)||`https://www.npmjs.com/package/${d.name}`,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5] flex items-center gap-1",children:[e.jsx(vt,{className:"w-3 h-3"}),"npm"]}),W?e.jsxs("span",{className:"text-[11px] font-mono text-[#16A34A] dark:text-[#22C55E] flex items-center gap-1",children:[e.jsx(ft,{className:"w-3 h-3"}),a("mcp.catalog.installed")]}):e.jsxs("button",{onClick:()=>o(d),disabled:H,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(ut,{className:D("h-3 w-3",H&&"animate-pulse")}),a(H?"mcp.catalog.installing":"mcp.catalog.install")]})]})]},d.name)}),(de==null?void 0:de.list.length)===0&&e.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.noPackages")})]}),f&&e.jsx("div",{className:"flex justify-center items-center py-4",children:e.jsx(ne,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),_&&de&&de.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.noMore")})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.packagesFound",{count:(de==null?void 0:de.total)??0})}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:[a("mcp.catalog.browseGlama"),e.jsx(vt,{className:"w-3 h-3"})]})]})]})]})}),e.jsx(ln,{open:r,onOpenChange:m,onAdd:xe,saving:fe,error:(be==null?void 0:be.message)??null}),te&&e.jsx(on,{pkg:te,onClose:()=>L(null),installing:fe,error:(be==null?void 0:be.message)??null,onInstall:d=>(G(te.name),xe(d))})]})}function Bt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function ln({open:t,onOpenChange:a,onAdd:s,saving:l,error:r}){const m=ge(),[h,g]=n.useState("form"),[u,i]=n.useState(""),[N,c]=n.useState(""),[b,k]=n.useState(""),[p,E]=n.useState(null),[w,B]=n.useState(`{
2
+ "name": "my-server",
3
+ "command": "npx",
4
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
5
+ }`);n.useEffect(()=>{t&&E(null)},[t]);const I=async()=>{if(E(null),h==="json"){let y;try{y=JSON.parse(w)}catch{E(m("mcp.add.invalidJson"));return}await s(y).catch(()=>{})}else{if(!u||!N){E(m("mcp.add.nameCommandRequired"));return}await s({name:u,command:N,args:b.split(" ").filter(Boolean)}).catch(()=>{})}};return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:y=>Je("[data-mcp-add-server-trigger]",y),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:m("mcp.add.title")}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:m("mcp.add.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":m("mcp.add.closeAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(Tt,{active:h==="form",onClick:()=>g("form"),children:m("mcp.add.modeForm")}),e.jsx(Tt,{active:h==="json",onClick:()=>g("json"),children:"JSON"})]}),h==="json"?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.jsonConfig")}),e.jsx("textarea",{"aria-label":m("mcp.add.jsonConfigAria"),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:w,onChange:y=>B(y.target.value)})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.serverName")}),e.jsx("input",{"aria-label":m("mcp.add.serverName"),type:"text",value:u,onChange:y=>i(y.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.command")}),e.jsx("input",{"aria-label":m("mcp.add.commandAria"),type:"text",value:N,onChange:y=>c(y.target.value),placeholder:"npx",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.argsLabel")}),e.jsx("input",{"aria-label":m("mcp.add.argsAria"),type:"text",value:b,onChange:y=>k(y.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]"})]})]}),(p||r)&&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:p||r}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:()=>a(!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:m("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void I(),disabled:l,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:m(l?"mcp.add.adding":"mcp.add.submit")})]})]})]})})}function on({pkg:t,onClose:a,onInstall:s,installing:l,error:r}){const m=ge(),h=Qt(t.name),[g,u]=n.useState(h),[i,N]=n.useState(`-y ${t.name}`),[c,b]=n.useState(null),k=async()=>{if(b(null),!g.trim()){b(m("mcp.install.nameRequired"));return}await s({name:g.trim(),command:"npx",args:i.split(" ").filter(Boolean)}).catch(()=>{})};return e.jsx($e,{open:!0,onOpenChange:a,children:e.jsxs(Ie,{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(Ke,{className:"sr-only",children:m("mcp.install.titleWithName",{name:t.name})}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:m("mcp.install.title")}),e.jsx("button",{onClick:a,"aria-label":m("mcp.install.closeAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"rounded-md bg-white dark:bg-[#0C0C0C] p-3",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1",children:t.description||m("mcp.catalog.noDescription")})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.serverName")}),e.jsx("input",{"aria-label":m("mcp.add.serverName"),type:"text",value:g,onChange:p=>u(p.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.install.args")}),e.jsx("input",{"aria-label":m("mcp.add.argsAria"),type:"text",value:i,onChange:p=>N(p.target.value),placeholder:"-y package-name",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:m("mcp.install.commandPreview",{args:i})})]})]}),(c||r)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:c||r}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:a,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:m("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void k(),disabled:l,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:m(l?"mcp.catalog.installing":"mcp.catalog.install")})]})]})]})})}function Tt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function Se({value:t,onChange:a,options:s,placeholder:l="Select...",disabled:r=!1,className:m,"aria-label":h}){const[g,u]=n.useState(!1),[i,N]=n.useState(-1),c=n.useRef(null),b=s.find(p=>p.value===t);n.useEffect(()=>{if(g){const p=s.findIndex(E=>E.value===t);N(p>=0?p:0)}},[g,s,t]);const k=p=>{if(!r){if(!g){(p.key==="Enter"||p.key===" "||p.key==="ArrowDown")&&(p.preventDefault(),u(!0));return}switch(p.key){case"ArrowDown":p.preventDefault(),N(E=>Math.min(E+1,s.length-1));break;case"ArrowUp":p.preventDefault(),N(E=>Math.max(E-1,0));break;case"Enter":case" ":p.preventDefault(),i>=0&&i<s.length&&(a(s[i].value),u(!1));break;case"Escape":p.preventDefault(),u(!1);break}}};return n.useEffect(()=>{var E;if(!g||i<0)return;const p=(E=c.current)==null?void 0:E.children[i];p==null||p.scrollIntoView({block:"nearest"})},[i,g]),e.jsxs(Xt,{open:g,onOpenChange:u,children:[e.jsx(Zt,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":g,"aria-haspopup":"listbox","aria-label":h,disabled:r,onKeyDown:k,className:D("field flex items-center justify-between gap-2 text-left",!b&&"text-zinc-400 dark:text-zinc-500",r&&"cursor-not-allowed opacity-50",m),children:[e.jsx("span",{className:"truncate",children:b?b.label:l}),e.jsx(_t,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),e.jsx(ea,{align:"start",sideOffset:4,onKeyDown:k,className:"w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden",children:e.jsx(ta,{className:"max-h-[232px]",children:e.jsx("div",{ref:c,role:"listbox",children:s.map((p,E)=>e.jsxs("button",{type:"button",role:"option","aria-selected":p.value===t,"data-value":p.value,"data-highlighted":E===i||void 0,onClick:()=>{a(p.value),u(!1)},onMouseEnter:()=>N(E),className:D("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left font-mono text-[13px] outline-none transition-colors",E===i&&"bg-zinc-100 dark:bg-zinc-800",p.value===t&&"text-zinc-900 dark:text-zinc-50 font-medium"),children:[e.jsx(ft,{className:D("h-3.5 w-3.5 shrink-0",p.value===t?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:p.label})]},p.value))})})})]})}const dn=[{value:"cron",labelKey:"schedule.trigger.cron"},{value:"interval",labelKey:"schedule.trigger.interval"},{value:"once",labelKey:"schedule.trigger.once"}],cn=[{value:"default",labelKey:"schedule.permission.default"},{value:"autoEdit",labelKey:"schedule.permission.autoEdit"},{value:"yolo",labelKey:"schedule.permission.yolo"},{value:"plan",labelKey:"schedule.permission.plan"}],un=[{value:"worktree",labelKey:"schedule.isolation.worktree"},{value:"local",labelKey:"schedule.isolation.local"}],mn={queued:"schedule.status.queued",running:"schedule.status.running",completed:"schedule.status.completed",failed:"schedule.status.failed",cancelled:"schedule.status.cancelled",interrupted:"schedule.status.interrupted",error:"schedule.status.error"},Oe={s:1e3,m:6e4,h:36e5,d:864e5};function xn(t){const a=/^\s*(\d+)\s*([smhd])\s*$/i.exec(t);if(!a)return null;const s=Number(a[1]);if(!Number.isFinite(s)||s<=0)return null;const l=s*Oe[a[2].toLowerCase()];return l<6e4?null:l}function pn(t){return t%Oe.d===0?`${t/Oe.d}d`:t%Oe.h===0?`${t/Oe.h}h`:t%Oe.m===0?`${t/Oe.m}m`:`${Math.round(t/1e3)}s`}function ot(t){const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString()}function fn({active:t}){const a=ge(),s=Le(x=>{var ue;return(ue=x.currentSessionRef)==null?void 0:ue.projectPath}),l=Le(x=>x.selectedProjectPath),r=It(x=>x.configuredModels),m=s??l??new URLSearchParams(window.location.search).get("project")??"",h=Pe(x=>x.schedules),g=Pe(x=>x.isLoading),u=Pe(x=>x.error),i=Pe(x=>x.loadSchedules),N=Pe(x=>x.createSchedule),c=Pe(x=>x.updateSchedule),b=Pe(x=>x.deleteSchedule),k=Pe(x=>x.toggleSchedule),p=Pe(x=>x.runSchedule),[E,w]=n.useState(!1),[B,I]=n.useState("cron"),[y,S]=n.useState(""),[U,A]=n.useState(""),[F,R]=n.useState(""),[j,O]=n.useState(""),[Q,Y]=n.useState(""),[Z,ee]=n.useState(""),[J,X]=n.useState(""),[T,K]=n.useState("default"),[G,te]=n.useState("worktree"),[L,C]=n.useState(!1),[v,M]=n.useState(null),[V,pe]=n.useState(null),[Ae,le]=n.useState(null),[he,we]=n.useState(""),[ce,Ce]=n.useState(!0),[de,re]=n.useState(null),f=n.useRef(!1);n.useEffect(()=>{t&&!f.current&&(f.current=!0,i()),t||(f.current=!1)},[t,i]);const _=de??u,ae=v!==null||L,oe=()=>{w(!0),I("cron"),S(""),A(""),R(""),O(""),Y(m),ee(""),X(""),K("default"),te("worktree"),re(null)},xe=()=>{w(!1),re(null)},fe=async()=>{re(null);const x=j.trim();if(!x){re(a("schedule.error.promptRequired"));return}const ue=Q.trim();if(!ue){re(a("schedule.error.projectRequired"));return}let Ne;if(B==="cron"){const o=y.trim();if(!o){re(a("schedule.error.cronRequired"));return}Ne={kind:"cron",cron:o}}else if(B==="interval"){const o=xn(U);if(o===null){re(a("schedule.error.invalidInterval"));return}Ne={kind:"interval",intervalMs:o}}else{const o=F?new Date(F):null;if(!o||Number.isNaN(o.getTime())){re(a("schedule.error.runAtRequired"));return}Ne={kind:"once",runAt:o.toISOString()}}const je={prompt:x,projectPath:ue,trigger:Ne,permissionMode:T,isolation:G,enabled:!0};Z.trim()&&(je.title=Z.trim()),J.trim()&&(je.modelId=J.trim()),C(!0);try{await N(je),w(!1)}catch{}finally{C(!1)}},be=async x=>{re(null),M(`run:${x.id}`);try{await p(x.id)}catch{}finally{M(null)}},Fe=async x=>{re(null),M(`toggle:${x.id}`);try{await k(x.id,!x.enabled)}catch{}finally{M(null)}},P=async x=>{const ue=`delete:${x.id}`;if(V!==ue){pe(ue);return}re(null),M(ue);try{await b(x.id),pe(null)}catch{}finally{M(null)}},Be=x=>{le(x.id),we(x.prompt),Ce(x.enabled),re(null)},ve=async x=>{const ue=he.trim();if(!ue){re(a("schedule.error.promptRequired"));return}re(null),M(`edit:${x.id}`);try{await c(x.id,{prompt:ue,enabled:ce}),le(null)}catch{}finally{M(null)}},Me=x=>x.kind==="cron"?a("schedule.cadence.cron",{expr:x.cron??""}):x.kind==="interval"?a("schedule.cadence.interval",{interval:pn(x.intervalMs??0)}):a("schedule.cadence.once",{time:x.runAt?ot(x.runAt):""});return 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(ia,{className:"h-4 w-4"}),a("schedule.title"),g&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:a("schedule.description")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void i(),disabled:g||ae,"aria-label":a("schedule.reloadAria"),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(Te,{className:"h-3.5 w-3.5"}),a("schedule.refresh")]}),e.jsxs("button",{type:"button",onClick:()=>E?xe():oe(),disabled:ae,"aria-label":a("schedule.newAria"),className:"inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[11px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("schedule.new")]})]})]}),_&&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:_}),E&&e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsx("div",{role:"radiogroup","aria-label":a("schedule.trigger.kindAria"),className:"flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]",children:dn.map(x=>e.jsx("button",{type:"button",role:"radio","aria-checked":B===x.value,onClick:()=>I(x.value),className:D("flex-1 rounded px-2 py-1 text-[10px] transition-colors",B===x.value?"bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]"),children:a(x.labelKey)},x.value))}),e.jsxs("div",{className:"mt-2.5",children:[B==="cron"&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.cron")}),e.jsx("input",{value:y,onChange:x=>S(x.target.value),placeholder:a("schedule.placeholder.cron"),"aria-label":a("schedule.field.cron"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),B==="interval"&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.interval")}),e.jsx("input",{value:U,onChange:x=>A(x.target.value),placeholder:a("schedule.placeholder.interval"),"aria-label":a("schedule.field.interval"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),B==="once"&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.runAt")}),e.jsx("input",{type:"datetime-local",value:F,onChange:x=>R(x.target.value),"aria-label":a("schedule.field.runAt"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]})]}),e.jsxs("label",{className:"mt-2.5 block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.title")}),e.jsx("input",{value:Z,onChange:x=>ee(x.target.value),placeholder:a("schedule.placeholder.title"),"aria-label":a("schedule.field.title"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),e.jsxs("label",{className:"mt-2.5 block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.prompt")}),e.jsx("textarea",{value:j,onChange:x=>O(x.target.value),placeholder:a("schedule.placeholder.prompt"),"aria-label":a("schedule.field.prompt"),rows:3,className:"field mt-1 h-auto resize-y py-1.5 text-[10.5px]"})]}),e.jsxs("label",{className:"mt-2.5 block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.project")}),e.jsx("input",{value:Q,onChange:x=>Y(x.target.value),placeholder:a("schedule.placeholder.project"),"aria-label":a("schedule.field.project"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),e.jsxs("div",{className:"mt-2.5 grid gap-2 sm:grid-cols-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.model")}),e.jsx(Se,{value:J,onChange:X,placeholder:a("schedule.model.current"),"aria-label":a("schedule.field.model"),className:"field mt-1 h-8 px-2 text-[10.5px]",options:[{value:"",label:a("schedule.model.current")},...r.map(x=>({value:x.id,label:x.displayName||x.model}))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.permissionMode")}),e.jsx(Se,{value:T,onChange:x=>K(x),"aria-label":a("schedule.field.permissionMode"),className:"field mt-1 h-8 px-2 text-[10.5px]",options:cn.map(x=>({value:x.value,label:a(x.labelKey)}))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.isolation")}),e.jsx(Se,{value:G,onChange:x=>te(x),"aria-label":a("schedule.field.isolation"),className:"field mt-1 h-8 px-2 text-[10.5px]",options:un.map(x=>({value:x.value,label:a(x.labelKey)}))})]})]}),e.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:xe,disabled:L,className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-3 text-[10.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:a("schedule.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void fe(),disabled:L,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:[L?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(We,{className:"h-3.5 w-3.5"}),a("schedule.create")]})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[h.map(x=>{const ue=Ae===x.id,Ne=x.lastStatus?a(mn[x.lastStatus]):a("schedule.status.never");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 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"truncate text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:x.title||x.prompt}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:Me(x.trigger)}),e.jsx("span",{className:D("rounded px-1.5 py-0.5 text-[9px]",x.enabled?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":"bg-[#F3F4F6] text-[#9CA3AF] dark:bg-[#27272a]"),children:x.enabled?a("schedule.enabled"):a("schedule.disabled")})]}),ue?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{value:he,onChange:je=>we(je.target.value),"aria-label":a("schedule.field.prompt"),rows:3,className:"field h-auto resize-y py-1.5 text-[10.5px]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":ce,"aria-label":ce?a("schedule.disableAria",{title:x.title||x.prompt}):a("schedule.enableAria",{title:x.title||x.prompt}),onClick:()=>Ce(je=>!je),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("flex h-5 w-9 items-center rounded-full px-1 transition-colors",ce?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-3.5 w-3.5 rounded-full bg-white transition-transform",ce?"translate-x-4":"translate-x-0")})}),a(ce?"schedule.enabled":"schedule.disabled")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>le(null),disabled:ae,className:"inline-flex h-7 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:a("schedule.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void ve(x),disabled:ae,className:"inline-flex h-7 items-center gap-1 rounded-md bg-[#111827] px-2 text-[9.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]",children:[v===`edit:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(ft,{className:"h-3 w-3"}),a("schedule.save")]})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-1 line-clamp-2 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:x.prompt}),e.jsxs("p",{className:"mt-1 text-[9.5px] text-[#9CA3AF]",children:[a("schedule.nextRun"),":"," ",x.nextRunAt?ot(x.nextRunAt):a("schedule.never")," · ",a("schedule.lastRun"),":"," ",x.lastRunAt?ot(x.lastRunAt):a("schedule.never")," · ",Ne," · ",a("schedule.runCount",{count:x.runCount})]}),x.lastError&&e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:x.lastError})]})]}),!ue&&e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":x.enabled,"aria-label":x.enabled?a("schedule.disableAria",{title:x.title||x.prompt}):a("schedule.enableAria",{title:x.title||x.prompt}),disabled:ae,onClick:()=>void Fe(x),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",x.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",x.enabled?"translate-x-5":"translate-x-0")})}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":a("schedule.runNowAria",{title:x.title||x.prompt}),onClick:()=>void be(x),disabled:ae,className:"rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]",children:v===`run:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(da,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":a("schedule.editAria",{title:x.title||x.prompt}),onClick:()=>Be(x),disabled:ae,className:"rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]",children:e.jsx(mt,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":a("schedule.deleteAria",{title:x.title||x.prompt}),onClick:()=>void P(x),disabled:ae,className:D("rounded p-1 text-[9px] disabled:opacity-40",V===`delete:${x.id}`?"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:v===`delete:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):V===`delete:${x.id}`?e.jsx("span",{className:"px-0.5 text-[8.5px]",children:a("schedule.confirmDelete")}):e.jsx(ze,{className:"h-3 w-3"})})]})]})]},x.id)}),!g&&h.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:a("schedule.empty")})]})]})}const pt=t=>t?{"x-blade-directory":t}:void 0,hn=async t=>q("/skills",{headers:pt(t)}),gn=async()=>q("/skills/catalog"),Mt={Official:"skills.install.catalog.tag.official",Popular:"skills.install.catalog.tag.popular",Community:"skills.install.catalog.tag.community"};function bn({active:t}){const a=ge(),s=Le(C=>{var v,M;return((v=C.currentSessionRef)==null?void 0:v.projectPath)??C.selectedProjectPath??((M=C.taskWorkspaceInfo)==null?void 0:M.cwd)??null}),[l,r]=n.useState(null),[m,h]=n.useState(""),[g,u]=n.useState(null),[i,N]=n.useState(null),[c,b]=n.useState(null),[k,p]=n.useState(!1),[E,w]=n.useState(!1),[B,I]=n.useState("confirm"),[y,S]=n.useState(null),[U,A]=n.useState(null),{data:F=[],loading:R,error:j,run:O,runAsync:Q}=_e(()=>hn(s),{refreshDeps:[t,s],ready:t,onSuccess:C=>{C.length>0&&!l&&r(C[0].id)}}),{data:Y=[],loading:Z,error:ee,run:J}=_e(gn,{refreshDeps:[t],ready:t}),X=F.filter(C=>C.name.toLowerCase().includes(m.toLowerCase())),T=n.useMemo(()=>F.find(C=>C.id===l)??F[0],[F,l]),K=async(C,v,M)=>{N({type:C,name:v.name}),u(null);try{await q(C==="delete"?`/skills/${encodeURIComponent(v.name)}`:`/skills/${encodeURIComponent(v.name)}/toggle`,{method:C==="delete"?"DELETE":"POST",headers:{...pt(s),...C==="toggle"?{"Content-Type":"application/json"}:{}},body:C==="toggle"?JSON.stringify({enabled:M}):void 0}),await Q(),C==="delete"&&(b(null),r(null))}catch(V){u(V instanceof Error?V.message:a(C==="delete"?"skills.error.deleteFailed":"skills.error.toggleFailed"))}finally{N(null)}},G=()=>{p(!0)},te=C=>{A(C),S(null),I("confirm"),w(!0)},L=async()=>{if(U){I("installing"),S(null);try{const C=await q("/skills/install",{method:"POST",headers:{"Content-Type":"application/json",...pt(s)},body:JSON.stringify(U)});if(C.success===!1)throw new Error(C.error||a("skills.error.installFailed"));await Q(),w(!1),p(!1)}catch(C){S(C instanceof Error?C.message:a("skills.error.installFailed")),I("failed")}}};return e.jsxs(n.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col gap-4 p-4 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:a("skills.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{"data-skill-install-trigger":!0,onClick:G,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("skills.action.install")]}),e.jsx("button",{onClick:O,"aria-label":a("skills.action.refreshAria"),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:R,children:e.jsx(Te,{className:D("h-4 w-4",R&&"animate-spin")})})]})]}),g&&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(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:g}),e.jsx("button",{type:"button",onClick:()=>u(null),className:"shrink-0 underline",children:a("skills.action.dismiss")})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:a("skills.installed.title")}),e.jsx("input",{type:"search","aria-label":a("skills.installed.searchAria"),value:m,onChange:C=>h(C.target.value),placeholder:a("skills.installed.searchPlaceholder"),className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[R&&F.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(ne,{className:"h-4 w-4 animate-spin"}),a("skills.installed.loading")]}),j&&!R&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:j.message}),e.jsx("button",{type:"button",onClick:O,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("skills.action.retry")})]}),!j&&X.length===0&&!R&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(m?"skills.installed.noMatch":"skills.installed.empty")}),X.map(C=>e.jsxs("button",{onClick:()=>{r(C.id),b(null),u(null)},className:D("flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",C.id===l?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:C.name}),e.jsx("span",{className:D("text-[11px] font-mono font-semibold",C.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:C.enabled?a("skills.status.enabled"):a("skills.status.disabled")})]}),e.jsx("span",{className:"block w-full min-w-0 truncate text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:C.description||a("skills.noDescriptionShort")})]},C.id))]})]}),T?e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:T.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",T.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:T.description||a("skills.noDescription")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void K("toggle",T,!T.enabled),disabled:i!==null,className:D("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",T.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",i&&"opacity-60 cursor-not-allowed"),children:(i==null?void 0:i.type)==="toggle"&&i.name===T.name?a("skills.action.saving"):T.enabled?a("skills.action.disable"):a("skills.action.enable")}),e.jsxs("button",{onClick:()=>b(T.name),disabled:!T.removable||i!==null,title:T.removable?void 0:a("skills.uninstall.managedHint"),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ze,{className:"h-3 w-3"}),T.removable?a("skills.uninstall.action"):a("skills.uninstall.managed")]})]}),c===T.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("skills.uninstall.confirmAria",{name:T.name}),className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:a("skills.uninstall.confirmPrompt")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>b(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a("skills.action.cancel")}),e.jsx("button",{type:"button",onClick:()=>void K("delete",T),disabled:i!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(i==null?void 0:i.type)==="delete"?a("skills.uninstall.inProgress"):a("skills.uninstall.confirm")})]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.title")}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:a("skills.details.provider")}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:T.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:a("skills.details.location")}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:T.location})]})]}),T.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.capabilities")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.capabilities.map(C=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:C},C))})]}),T.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.allowedTools",{count:T.allowedTools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.allowedTools.map(C=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:C},C))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a("skills.detail.emptyState")})})]})]}),e.jsx(vn,{open:k,catalog:Y,installed:F.map(C=>C.name),catalogLoading:Z,catalogError:(ee==null?void 0:ee.message)??null,onRetryCatalog:J,onOpenChange:p,onInstall:te}),e.jsx(kn,{open:E,status:B,error:y,onCancel:()=>w(!1),onConfirm:L,onRetry:()=>I("confirm")})]})}function it({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function vn({open:t,onOpenChange:a,onInstall:s,catalog:l,installed:r,catalogLoading:m,catalogError:h,onRetryCatalog:g}){const u=ge(),[i,N]=n.useState("catalog"),[c,b]=n.useState(""),[k,p]=n.useState(null),[E,w]=n.useState(""),[B,I]=n.useState(""),y=l.filter(F=>F.name.toLowerCase().includes(c.toLowerCase())),S=()=>{if(i==="catalog"){if(!k)return;s({source:"catalog",name:k});return}if(i==="repo"){if(!E)return;s({source:"repo",url:E});return}B&&s({source:"local",path:B})},U=k?r.includes(k):!1,A=i==="catalog"&&(!k||U||m||!!h)||i==="repo"&&!E||i==="local"&&!B;return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:F=>Je("[data-skill-install-trigger]",F),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:u("skills.install.title")}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:u("skills.install.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":u("skills.install.closeAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(He,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(it,{active:i==="catalog",onClick:()=>N("catalog"),children:u("skills.install.tab.catalog")}),e.jsx(it,{active:i==="repo",onClick:()=>N("repo"),children:u("skills.install.tab.repo")}),e.jsx(it,{active:i==="local",onClick:()=>N("local"),children:u("skills.install.tab.local")})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[i==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{"aria-label":u("skills.install.catalog.searchAria"),value:c,onChange:F=>b(F.target.value),placeholder:u("skills.install.catalog.searchPlaceholder"),className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex max-h-[min(240px,30dvh)] flex-col gap-2 overflow-y-auto",children:[m&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-6 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),u("skills.install.catalog.loading")]}),h&&!m&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:g,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:u("skills.action.retry")})]}),!m&&!h&&y.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:u("skills.install.catalog.empty")}),!m&&!h&&y.map(F=>{const R=r.includes(F.name),j=k===F.name;return e.jsxs("button",{onClick:()=>p(F.name),className:D("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",j?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:F.name}),e.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded",F.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:Mt[F.tag]?u(Mt[F.tag]):F.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:F.description}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:u("skills.install.catalog.byAuthor",{author:F.author})}),R&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:u("skills.status.installed")})]},F.name)})]})]}),i==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:u("skills.install.repo.label")}),e.jsx("input",{"aria-label":u("skills.install.repo.inputAria"),value:E,onChange:F=>w(F.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:u("skills.install.repo.credentialsHint")})]}),i==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:u("skills.install.local.label")}),e.jsx("input",{"aria-label":u("skills.install.local.inputAria"),value:B,onChange:F=>I(F.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>a(!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:u("skills.action.cancel")}),e.jsx("button",{onClick:S,disabled:A,className:D("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",A?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:u("skills.action.installShort")})]})]})]})})}function kn({open:t,status:a,error:s,onCancel:l,onConfirm:r,onRetry:m}){const h=ge();return e.jsx($e,{open:t,onOpenChange:g=>!g&&l(),children:e.jsxs(Ie,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:h("skills.status.dialogTitle")}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[a==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:h("skills.status.confirm.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:h("skills.status.confirm.prompt")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:l,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:h("skills.action.cancel")}),e.jsx("button",{onClick:r,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:h("skills.action.installShort")})]})]}),a==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:h("skills.status.installing.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:h("skills.status.installing.description")}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:l,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:h("skills.action.hide")})]}),a==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:h("skills.status.failed.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:s||h("skills.status.failed.fallback")}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:h("skills.status.failed.hint")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:l,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:h("skills.action.close")}),e.jsx("button",{onClick:m,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:h("skills.action.retry")})]})]})]})]})})}const jn=[{id:"auto",name:"Auto",description:"Use the Blade default communication style",source:"built-in"},{id:"pragmatic",name:"Pragmatic",description:"Direct, factual, concise, and action-oriented",source:"built-in"},{id:"friendly",name:"Friendly",description:"Warm, collaborative, and task-focused",source:"built-in"},{id:"explanatory",name:"Explanatory",description:"Explain codebase-specific choices and tradeoffs",source:"built-in"}],yn=/^[a-z][a-z0-9._-]{0,63}$/;function Nn({open:t,onOpenChange:a,onSave:s,saveError:l}){const r=ge(),[m,h]=n.useState([]),[g,u]=n.useState([]),[i,N]=n.useState(),[c,b]=n.useState(),[k,p]=n.useState(""),[E,w]=n.useState(""),[B,I]=n.useState(""),[y,S]=n.useState(""),[U,A]=n.useState(""),[F,R]=n.useState(""),[j,O]=n.useState(!1),[Q,Y]=n.useState(!1),[Z,ee]=n.useState(!1),[J,X]=n.useState(!1),[T,K]=n.useState(null);n.useEffect(()=>{if(!t)return;let v=!0;return u([]),N(void 0),b(void 0),p(""),w(""),I(""),S(""),A(""),R(""),O(!1),K(null),Y(!0),q("/providers").then(M=>{v&&h(M)}).catch(M=>{v&&K(M instanceof Error?M.message:r("settings.models.addModal.loadProvidersError"))}).finally(()=>{v&&Y(!1)}),()=>{v=!1}},[t,r]),n.useEffect(()=>{if(!i)return;let v=!0;return u([]),b(void 0),K(null),i.factoryWireApi||i.custom?(ee(!1),()=>{v=!1}):(ee(!0),q(`/providers/${i.id}/models`).then(M=>{v&&u(M)}).catch(M=>{v&&K(M instanceof Error?M.message:r("settings.models.addModal.loadModelsError"))}).finally(()=>{v&&ee(!1)}),()=>{v=!1})},[i,r]);const G=i==null?void 0:i.factoryWireApi,te=!!(G||i!=null&&i.custom),L=te?y.trim():c==null?void 0:c.id,C=async()=>{if(!i||!L||!i.configured&&!F)return;if(G){if(!yn.test(E.trim())){K(r("settings.models.addModal.channelIdError"));return}let V;try{V=new URL(U.trim())}catch{K(r("settings.models.addModal.invalidBaseUrl"));return}if(!["http:","https:"].includes(V.protocol)){K(r("settings.models.addModal.invalidBaseUrl"));return}}X(!0);const v=G?E.trim():i.id,M=await s({provider:v,model:L,displayName:k||(te?L:(c==null?void 0:c.name)??""),apiKey:F||void 0,...G?{modelProvider:{id:v,name:B.trim()||v,baseUrl:U.trim(),wireApi:G}}:{}});X(!1),M&&a(!1)};return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:v=>Je("[data-add-model-trigger]",v),onEscapeKeyDown:v=>{v.preventDefault(),a(!1)},onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),v.stopPropagation(),a(!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(Ke,{className:"sr-only",children:r("settings.models.addModal.title")}),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:r("settings.models.addModal.title")}),e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":r("settings.models.addModal.close"),className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(He,{className:"h-4 w-4"})})]}),(T||l)&&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(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:T||l})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.provider"),e.jsx(Se,{"aria-label":r("settings.models.addModal.provider"),value:(i==null?void 0:i.id)??"",disabled:Q,onChange:v=>{N(m.find(M=>M.id===v)),p(""),w(""),I(""),S(""),A("")},placeholder:r(Q?"settings.models.addModal.loadingProviders":"settings.models.addModal.selectProvider"),options:m.map(v=>{const M=v.factoryWireApi==="openai-completions"?r("settings.models.addModal.customOpenAI"):v.factoryWireApi==="anthropic-messages"?r("settings.models.addModal.customAnthropic"):v.name;return{value:v.id,label:`${M} (${v.modelCount})${v.configured?r("settings.models.addModal.configuredSuffix"):""}`}})})]}),te?e.jsxs(e.Fragment,{children:[G&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.channelId"),e.jsx("input",{"aria-label":r("settings.models.addModal.channelId"),value:E,onChange:v=>{w(v.target.value),K(null)},placeholder:"team-gateway",autoComplete:"off",spellCheck:!1,className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:r("settings.models.addModal.channelIdHint")})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.channelName"),e.jsx("input",{"aria-label":r("settings.models.addModal.channelName"),value:B,onChange:v=>I(v.target.value),placeholder:"Team Gateway",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.baseUrl"),e.jsx("input",{"aria-label":r("settings.models.addModal.baseUrl"),value:U,onChange:v=>{A(v.target.value),K(null)},placeholder:G==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:r(G==="anthropic-messages"?"settings.models.addModal.anthropicProtocol":"settings.models.addModal.openaiProtocol")})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.modelId"),e.jsx("input",{"aria-label":r("settings.models.addModal.modelId"),value:y,onChange:v=>{S(v.target.value),K(null)},placeholder:"vendor-model-2026",className:"field"})]})]}):e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.model"),e.jsx(Se,{"aria-label":r("settings.models.addModal.model"),value:(c==null?void 0:c.id)??"",disabled:!i||Z,onChange:v=>{const M=g.find(V=>V.id===v);b(M),M&&p(M.name)},placeholder:r(Z?"settings.models.addModal.loadingModels":"settings.models.addModal.selectModel"),options:g.map(v=>({value:v.id,label:`${v.name} - ${Math.round(v.contextWindow/1e3)}K${v.reasoning?r("settings.models.addModal.reasoningSuffix"):""}${v.input.includes("image")?r("settings.models.addModal.visionSuffix"):""}`}))})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.displayName"),e.jsx("input",{value:k,onChange:v=>p(v.target.value),placeholder:(c==null?void 0:c.name)??r("settings.models.addModal.displayNamePlaceholder"),className:"field"})]}),(i==null?void 0:i.supportsApiKey)&&!i.configured&&e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.apiKey"),e.jsxs("span",{className:"relative",children:[e.jsx("input",{"aria-label":r("settings.models.addModal.apiKeyAria"),type:j?"text":"password",value:F,onChange:v=>R(v.target.value),className:"field w-full pr-10",placeholder:r("settings.models.addModal.apiKeyPlaceholder")}),e.jsx("button",{type:"button",onClick:()=>O(!j),"aria-label":r(j?"settings.models.addModal.hideApiKey":"settings.models.addModal.showApiKey"),className:"absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded",children:j?e.jsx(ca,{className:"h-4 w-4"}):e.jsx(ua,{className:"h-4 w-4"})})]})]}),i&&!i.configured&&!i.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:r("settings.models.addModal.oauthNote")}),e.jsxs("button",{type:"button",disabled:J||!i||!L||G&&(!E.trim()||!U.trim())||!i.configured&&(!i.supportsApiKey||F.trim().length===0),onClick:()=>void C(),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:[J&&e.jsx(ne,{className:"h-4 w-4 animate-spin"}),r(J?"settings.models.addModal.saving":"settings.models.addModal.saveModel")]})]})]})})}function En(t){const a=ge(),[s,l]=n.useState(""),[r,m]=n.useState(""),[h,g]=n.useState(""),[u,i]=n.useState(""),[N,c]=n.useState(!1),[b,k]=n.useState(null);n.useEffect(()=>{var w,B,I,y,S;l(((w=t.model)==null?void 0:w.displayName)??""),m(((I=(B=t.model)==null?void 0:B.overrides)==null?void 0:I.baseUrl)??""),g(((S=(y=t.model)==null?void 0:y.overrides)==null?void 0:S.streamIdleTimeout)!==void 0?String(t.model.overrides.streamIdleTimeout):""),i(""),k(null)},[t.model]);const p=async()=>{if(!t.model)return;k(null);const w=h.trim()?Number(h):void 0;if(w!==void 0&&(!Number.isFinite(w)||w<1e3)){k(a("settings.models.editModal.streamIdleTimeoutError"));return}c(!0);try{u.trim()&&await q(`/providers/${t.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:u.trim()})});const B={...t.model.overrides};r.trim()?B.baseUrl=r.trim():delete B.baseUrl,w!==void 0?B.streamIdleTimeout=w:delete B.streamIdleTimeout,await t.onSave(t.model.id,{displayName:s||void 0,overrides:Object.keys(B).length>0?B:void 0})&&t.onOpenChange(!1)}catch(B){k(B instanceof Error?B.message:a("settings.models.editModal.credentialError"))}finally{c(!1)}},E=t.model?`[data-edit-model-trigger="${t.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx($e,{open:t.open,onOpenChange:t.onOpenChange,children:e.jsxs(Ie,{onCloseAutoFocus:w=>Je(E,w),onEscapeKeyDown:w=>{w.preventDefault(),t.onOpenChange(!1)},onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),t.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(Ke,{className:"sr-only",children:a("settings.models.editModal.srTitle")}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"font-mono font-semibold",children:a("settings.models.editModal.title")}),e.jsx("button",{type:"button",onClick:()=>t.onOpenChange(!1),"aria-label":a("settings.models.editModal.close"),className:"flex justify-center items-center w-8 h-8 rounded-md",children:e.jsx(He,{className:"w-4 h-4"})})]}),(b||t.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:b||t.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.displayName"),e.jsx("input",{value:s,onChange:w=>l(w.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.replaceApiKey"),e.jsx("input",{type:"password",value:u,onChange:w=>i(w.target.value),placeholder:a("settings.models.editModal.replaceApiKeyPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.baseUrlOverride"),e.jsx("input",{value:r,onChange:w=>m(w.target.value),placeholder:a("settings.models.editModal.baseUrlPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.streamIdleTimeout"),e.jsx("input",{type:"number",min:1e3,step:1e3,value:h,onChange:w=>g(w.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void p(),disabled:N,className:"flex gap-2 justify-center items-center px-4 py-2 text-white bg-green-600 rounded-md min-h-9 disabled:opacity-60",children:[N&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),a(N?"settings.models.editModal.saving":"settings.models.editModal.save")]})]})})}function wn({provider:t,onOpenChange:a,onSave:s,saveError:l}){const r=ge(),[m,h]=n.useState(t.name),[g,u]=n.useState(t.defaultBaseUrl??""),[i,N]=n.useState(t.wireApi??"openai-completions"),[c,b]=n.useState(t.apiKeyEnv??""),[k,p]=n.useState(""),[E,w]=n.useState(null),[B,I]=n.useState(!1);n.useEffect(()=>{h(t.name),u(t.defaultBaseUrl??""),N(t.wireApi??"openai-completions"),b(t.apiKeyEnv??""),p(""),w(null)},[t]);const y=async()=>{if(!m.trim()){w(r("settings.models.editProvider.channelNameRequired"));return}try{const S=new URL(g.trim());if(!["http:","https:"].includes(S.protocol))throw new Error}catch{w(r("settings.models.editProvider.invalidBaseUrl"));return}I(!0),w(null);try{await s(t.id,{name:m.trim(),baseUrl:g.trim(),wireApi:i,apiKeyEnv:c.trim()||null,...k.trim()?{apiKey:k.trim()}:{}})&&a(!1)}finally{I(!1)}};return e.jsx($e,{open:!0,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:S=>Je(`[data-edit-provider-trigger="${t.id.replace(/"/g,'\\"')}"]`,S),onEscapeKeyDown:S=>{S.preventDefault(),a(!1)},onKeyDown:S=>{S.key==="Escape"&&(S.preventDefault(),S.stopPropagation(),a(!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(Ke,{className:"sr-only",children:r("settings.models.editProvider.title")}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-mono font-semibold",children:r("settings.models.editProvider.title")}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-zinc-400",children:t.id})]}),e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":r("settings.models.editProvider.close"),className:"flex justify-center items-center w-8 h-8 rounded-md",children:e.jsx(He,{className:"w-4 h-4"})})]}),(E||l)&&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:E||l}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.channelName"),e.jsx("input",{"aria-label":r("settings.models.editProvider.channelName"),value:m,onChange:S=>h(S.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.wireApi"),e.jsx(Se,{"aria-label":r("settings.models.editProvider.wireApi"),value:i,onChange:S=>N(S),options:[{value:"openai-completions",label:"OpenAI Chat Completions"},{value:"anthropic-messages",label:"Anthropic Messages"}]})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.baseUrl"),e.jsx("input",{"aria-label":r("settings.models.editProvider.baseUrlAria"),value:g,onChange:S=>{u(S.target.value),w(null)},className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.apiKeyEnv"),e.jsx("input",{"aria-label":r("settings.models.editProvider.apiKeyEnv"),value:c,onChange:S=>b(S.target.value),placeholder:r("settings.models.editProvider.apiKeyEnvPlaceholder"),autoComplete:"off",spellCheck:!1,className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.replaceApiKey"),e.jsx("input",{"aria-label":r("settings.models.editProvider.apiKeyAria"),type:"password",value:k,onChange:S=>p(S.target.value),placeholder:r("settings.models.editProvider.apiKeyPlaceholder"),className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void y(),disabled:B,className:"flex gap-2 justify-center items-center px-4 py-2 text-white bg-green-600 rounded-md min-h-9 disabled:opacity-60",children:[B&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),r(B?"settings.models.editProvider.saving":"settings.models.editProvider.save")]})]})})}const Cn={disabled:"settings.hooks.state.disabled",not_required:"settings.hooks.state.notRequired",untrusted:"settings.hooks.state.review",trusted:"settings.hooks.state.trusted",modified:"settings.hooks.state.modified",error:"settings.hooks.state.error"};function Sn(){const t=ge(),a=Le(T=>T.currentSessionRef),s=a==null?void 0:a.projectPath,l=a==null?void 0:a.sessionId,r=n.useMemo(()=>s??new URLSearchParams(window.location.search).get("project")??"",[s]),[m,h]=n.useState(null),[g,u]=n.useState(null),[i,N]=n.useState(""),[c,b]=n.useState(""),[k,p]=n.useState(!1),[E,w]=n.useState(null),[B,I]=n.useState(null),[y,S]=n.useState(null),U=n.useRef(0),A=n.useRef(r);A.current=r;const F=l?`${r}\0${l}`:"",R=n.useRef(F);R.current=F;const j=i===r?m:null,O=c===F?g:null,Q=n.useCallback(async()=>{const T=++U.current;if(!r){h(null),u(null),N(""),b(""),S(null);return}p(!0),S(null);try{const K=await q(`/hooks/trust?projectPath=${encodeURIComponent(r)}`);if(T!==U.current)return;const G=l?await q(`/hooks/session?projectPath=${encodeURIComponent(r)}&sessionId=${encodeURIComponent(l)}`):null;if(T!==U.current)return;h(K),u(G),N(r),b(G?F:"")}catch(K){if(T!==U.current)return;S(K instanceof Error?K.message:t("settings.hooks.loadFailed"))}finally{T===U.current&&p(!1)}},[r,l,F,t]);n.useEffect(()=>(I(null),Q(),()=>{U.current+=1}),[Q]);const Y=async T=>{if(!j)return;const K=r;w(T),S(null);try{const G=await q("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,action:T,...T==="trust"&&j.currentDigest?{expectedDigest:j.currentDigest}:{}})});A.current===K&&(h(G),N(K),I(null))}catch(G){A.current===K&&S(G instanceof Error?G.message:t("settings.hooks.updateFailed"))}finally{w(null)}},Z=async T=>{if(!l||!O)return;const K=F;w("session"),S(null);try{const G=await q("/hooks/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,sessionId:l,enabled:T})});R.current===K&&(u(G),b(K))}catch(G){R.current===K&&S(G instanceof Error?G.message:t("settings.hooks.sessionUpdateFailed"))}finally{w(null)}};if(!r)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.hooks.selectSession")});const ee=(j==null?void 0:j.state)==="trusted",J=(j==null?void 0:j.state)==="untrusted"||(j==null?void 0:j.state)==="modified",X=O!==null&&!O.enabled&&!O.paused;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:[ee?e.jsx(ht,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ut,{className:D("h-4 w-4",J?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(j?Cn[j.state]:"settings.hooks.heading")}),k&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:r}),(j==null?void 0:j.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:j.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void Q(),disabled:k||E!==null,"aria-label":t("settings.hooks.reloadAria"),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(Te,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),ee?e.jsx("button",{type:"button",onClick:()=>I("revoke"),disabled:E!==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:t("settings.hooks.revoke")}):e.jsx("button",{type:"button",onClick:()=>I("trust"),disabled:E!==null||!(j!=null&&j.currentDigest)||j.state==="error",className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:t("settings.hooks.trustDigest")})]})]}),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:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.hooks.currentSession")}),e.jsx("div",{className:"mt-0.5 text-[9.5px] text-[#9CA3AF]",children:l?O?O.paused?t("settings.hooks.session.paused"):O.enabled?t("settings.hooks.session.active"):O.configEnabled?t("settings.hooks.session.unavailable"):t("settings.hooks.session.disabled"):t("settings.hooks.session.loading"):t("settings.hooks.session.open")})]}),e.jsx("button",{type:"button",role:"switch","aria-label":O!=null&&O.paused?t("settings.hooks.session.enableAria"):O!=null&&O.enabled?t("settings.hooks.session.pauseAria"):t("settings.hooks.session.unavailableAria"),"aria-checked":(O==null?void 0:O.enabled)??!1,disabled:!O||E!==null||X,onClick:()=>void Z((O==null?void 0:O.paused)===!0),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",O!=null&&O.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",O!=null&&O.enabled?"translate-x-5":"translate-x-0")})})]}),B&&j&&e.jsxs("div",{role:"alertdialog","aria-label":t(B==="trust"?"settings.hooks.confirmTrustAria":"settings.hooks.confirmRevokeAria"),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:B==="trust"?t("settings.hooks.confirmTrust",{count:j.configuredHooks}):t("settings.hooks.confirmRevoke")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>I(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void Y(B),disabled:E!==null,className:D("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",B==="trust"?"bg-emerald-600":"bg-red-600"),children:t(E?"settings.hooks.saving":B==="trust"?"settings.hooks.trustReviewed":"settings.hooks.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((j==null?void 0:j.definitions)??[]).map((T,K)=>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:T.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:T.type}),T.name&&e.jsx("span",{className:"text-[#71717a]",children:T.name}),T.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:[T.pluginName," · ",T.pluginSource]})]}),T.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:T.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:T.target})]},`${T.event}-${T.type}-${K}`)),j&&j.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.hooks.empty")})]})]})}const Rt={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]},An=[{value:"local",labelKey:"settings.plugins.scope.local",descriptionKey:"settings.plugins.scope.localDesc"},{value:"project",labelKey:"settings.plugins.scope.project",descriptionKey:"settings.plugins.scope.projectDesc"},{value:"global",labelKey:"settings.plugins.scope.global",descriptionKey:"settings.plugins.scope.globalDesc"}],Ot={local:"settings.plugins.scope.local",project:"settings.plugins.scope.project",global:"settings.plugins.scope.global",invocation:"settings.plugins.scope.invocation",default:"settings.plugins.scope.default"};function Fn(){const t=ge(),a=Le(f=>{var _;return(_=f.currentSessionRef)==null?void 0:_.projectPath}),s=Le(f=>f.selectedProjectPath),l=n.useMemo(()=>a??s??new URLSearchParams(window.location.search).get("project")??"",[s,a]),[r,m]=n.useState([]),[h,g]=n.useState([]),[u,i]=n.useState(Rt),[N,c]=n.useState(!1),[b,k]=n.useState(""),[p,E]=n.useState(""),[w,B]=n.useState(""),[I,y]=n.useState(""),[S,U]=n.useState(!1),[A,F]=n.useState(null),[R,j]=n.useState(null),[O,Q]=n.useState(""),[Y,Z]=n.useState(""),[ee,J]=n.useState(!1),[X,T]=n.useState(null),[K,G]=n.useState("local"),te=n.useRef(0),L=n.useRef(l);L.current=l;const C=I===l?r:[],v=I===l?h:[],M=n.useCallback(async()=>{const f=++te.current;if(!l){m([]),y(""),j(null);return}U(!0),j(null);try{const[_,ae,oe]=await Promise.all([q(`/plugins?projectPath=${encodeURIComponent(l)}`),q(`/plugins/catalog?projectPath=${encodeURIComponent(l)}`),q(`/plugins/policy?projectPath=${encodeURIComponent(l)}`)]);if(f!==te.current)return;m(_),g(ae);const xe=(oe==null?void 0:oe.policy)??Rt;i(xe),c((oe==null?void 0:oe.environmentRequiresSha)??!1),k(xe.allowedGitHosts.join(", ")),E(xe.allowedMarketplaces.join(", ")),B(xe.allowedLocalRoots.join(", ")),y(l)}catch(_){if(f!==te.current)return;j(_ instanceof Error?_.message:t("settings.plugins.loadFailed"))}finally{f===te.current&&U(!1)}},[l,t]);n.useEffect(()=>(M(),()=>{te.current+=1}),[M]);const V=async(f,_)=>{const ae=l;F(f.name),j(null);try{await q(`/plugins/${encodeURIComponent(f.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:ae,enabled:_,scope:K})}),L.current===ae&&await M()}catch(oe){L.current===ae&&j(oe instanceof Error?oe.message:t("settings.plugins.updateFailed"))}finally{F(null)}},pe=f=>[...new Set(f.split(",").map(_=>_.trim()).filter(Boolean))],Ae=async()=>{await le("policy:save",()=>q("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,scope:"local",policy:{...u,allowedGitHosts:pe(b),allowedMarketplaces:pe(p),allowedLocalRoots:pe(w)}})}))},le=async(f,_,ae)=>{const oe=l;F(f),j(null);try{await _(),L.current===oe&&(ae==null||ae(),T(null),await M())}catch(xe){L.current===oe&&j(xe instanceof Error?xe.message:t("settings.plugins.actionFailed"))}finally{F(null)}},he=async()=>{const f=O.trim();!f||!ee||await le("install",()=>q("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:f,trust:!0})}),()=>{Q(""),J(!1)})},we=async f=>{const _=`update:${f.name}`;if(X!==_){T(_);return}await le(_,()=>q(`/plugins/${encodeURIComponent(f.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,trust:!0})}))},ce=async f=>{const _=`uninstall:${f.name}`;if(X!==_){T(_);return}await le(_,()=>q(`/plugins/${encodeURIComponent(f.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))},Ce=async()=>{const f=Y.trim();f&&await le("marketplace:add",()=>q("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:f})}),()=>Z(""))},de=async f=>{await le(`marketplace:refresh:${f.name}`,()=>q(`/plugins/marketplaces/${encodeURIComponent(f.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l})}))},re=async f=>{const _=`marketplace:remove:${f.name}`;if(X!==_){T(_);return}await le(_,()=>q(`/plugins/marketplaces/${encodeURIComponent(f.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))};return l?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(ma,{className:"h-4 w-4"}),t("settings.plugins.heading"),S&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:l}),e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:t("settings.plugins.changesNote")})]}),e.jsxs("button",{type:"button",onClick:()=>void M(),disabled:S||A!==null,"aria-label":t("settings.plugins.reloadAria"),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(Te,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]})]}),R&&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:R}),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(ht,{className:"h-3.5 w-3.5"}),t("settings.plugins.sourcePolicy")]}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.savePolicyAria"),onClick:()=>void Ae(),disabled:A!==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:t(A==="policy:save"?"settings.plugins.saving":"settings.plugins.saveForProject")})]}),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":t("settings.plugins.restrictAria"),"aria-checked":u.restrictToAllowedSources,onClick:()=>i(f=>({...f,restrictToAllowedSources:!f.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("h-3.5 w-6 rounded-full p-0.5",u.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:D("block h-2.5 w-2.5 rounded-full bg-white transition-transform",u.restrictToAllowedSources&&"translate-x-2.5")})}),t("settings.plugins.restrictAllowlists")]}),e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.requireShaAria"),"aria-checked":u.requireGitCommitSha,disabled:N,onClick:()=>i(f=>({...f,requireGitCommitSha:!f.requireGitCommitSha})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("h-3.5 w-6 rounded-full p-0.5",u.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:D("block h-2.5 w-2.5 rounded-full bg-white transition-transform",u.requireGitCommitSha&&"translate-x-2.5")})}),t("settings.plugins.requireSha"),N?t("settings.plugins.environmentLocked"):""]})]}),e.jsxs("div",{className:"mt-2 grid gap-1.5 sm:grid-cols-3",children:[e.jsx("input",{"aria-label":t("settings.plugins.gitHostsAria"),value:b,onChange:f=>k(f.target.value),placeholder:"github.com, *.corp.test",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.marketplacesAria"),value:p,onChange:f=>E(f.target.value),placeholder:"team-market, official",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.localRootsAria"),value:w,onChange:f=>B(f.target.value),placeholder:"/opt/approved/plugins",className:"field h-7 px-2 text-[9.5px]"})]}),u.restrictToAllowedSources&&!b.trim()&&!p.trim()&&!w.trim()&&e.jsx("p",{className:"mt-1.5 text-[9px] text-amber-700 dark:text-amber-400",children:t("settings.plugins.emptyAllowlists")})]}),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(ut,{className:"h-3.5 w-3.5"}),t("settings.plugins.installHeading")]}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{"aria-label":t("settings.plugins.sourceAria"),value:O,onChange:f=>Q(f.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:A!==null,className:"field h-8 min-w-0 flex-1 px-2 text-[10.5px]"}),e.jsxs("button",{type:"button",onClick:()=>void he(),disabled:!O.trim()||!ee||A!==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:[A==="install"?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ut,{className:"h-3.5 w-3.5"}),t("settings.plugins.install")]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":ee,onClick:()=>J(f=>!f),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:D("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",ee?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:ee?"✓":""}),t("settings.plugins.trustSource")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.plugins.activationScope")}),e.jsx("div",{className:"mt-0.5 text-[9px] text-[#9CA3AF]",children:t("settings.plugins.activationScopeHint")})]}),e.jsx("div",{role:"radiogroup","aria-label":t("settings.plugins.scopeAria"),className:"flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]",children:An.map(f=>e.jsx("button",{type:"button",role:"radio","aria-checked":K===f.value,title:t(f.descriptionKey),onClick:()=>G(f.value),className:D("rounded px-2 py-1 text-[9.5px] transition-colors",K===f.value?"bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]"),children:t(f.labelKey)},f.value))})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[C.map(f=>{var xe;const _=A===f.name,ae=[f.commands?t("settings.plugins.capability.commands",{count:f.commands}):"",f.skills?t("settings.plugins.capability.skills",{count:f.skills}):"",f.agents?t("settings.plugins.capability.agents",{count:f.agents}):"",f.hooks?t("settings.plugins.capability.hooks",{count:f.hooks}):"",f.mcpServers?t("settings.plugins.capability.mcp",{count:f.mcpServers}):""].filter(Boolean),oe=["global","project","local","invocation"].filter(fe=>{var be;return((be=f.settingLayers)==null?void 0:be[fe])!==void 0}).map(fe=>`${t(Ot[fe])} ${t(f.settingLayers[fe]?"settings.plugins.layer.on":"settings.plugins.layer.off")}`);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:f.name}),e.jsxs("span",{className:"text-[9.5px] text-[#9CA3AF]",children:["v",f.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:f.source}),e.jsx("span",{className:"rounded bg-sky-50 px-1.5 py-0.5 text-[9px] text-sky-700 dark:bg-sky-950/40 dark:text-sky-300",children:t("settings.plugins.effective",{scope:t(Ot[f.effectiveScope])})})]}),e.jsx("p",{className:"mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:f.description}),e.jsx("p",{className:"mt-1 text-[9.5px] text-[#9CA3AF]",children:ae.join(" · ")||t("settings.plugins.noResources")}),oe.length>0&&e.jsx("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:oe.join(" · ")}),f.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:[t("settings.plugins.managed"),f.marketplace?` · ${f.marketplace}`:"",f.revision?` · ${f.revision.slice(0,12)}`:""]}),!f.configurable&&e.jsx("p",{className:"mt-1 text-[9.5px] text-amber-600 dark:text-amber-400",children:t("settings.plugins.invocationScoped")}),(xe=f.compatibilityIssues)==null?void 0:xe.map(fe=>e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:fe.message},`${fe.code}:${fe.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":f.status==="error"?t("settings.plugins.unavailableAria",{name:f.name}):f.enabled?t("settings.plugins.disableAria",{name:f.name}):t("settings.plugins.enableAria",{name:f.name}),"aria-checked":f.enabled,disabled:f.status==="error"||!f.configurable||_||A!==null,onClick:()=>void V(f,!f.enabled),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",f.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",f.enabled?"translate-x-5":"translate-x-0")})}),f.managed&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.updateAria",{name:f.name}),onClick:()=>void we(f),disabled:A!==null,className:D("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",X===`update:${f.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:A===`update:${f.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):X===`update:${f.name}`?t("settings.plugins.confirmUpdate"):t("settings.plugins.update")}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.uninstallAria",{name:f.name}),onClick:()=>void ce(f),disabled:A!==null,className:D("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",X===`uninstall:${f.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:A===`uninstall:${f.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):X===`uninstall:${f.name}`?t("settings.plugins.confirmRemove"):e.jsx(ze,{className:"h-3 w-3"})})]})]})]},f.name)}),!S&&C.length===0&&!R&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.plugins.empty")})]}),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(xa,{className:"h-3.5 w-3.5"}),t("settings.plugins.marketplaces")]}),e.jsx("span",{className:"text-[9px] text-[#9CA3AF]",children:t("settings.plugins.configuredCount",{count:v.length})})]}),e.jsxs("div",{className:"flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]",children:[e.jsx("input",{"aria-label":t("settings.plugins.marketplaceSourceAria"),value:Y,onChange:f=>Z(f.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:A!==null,className:"field h-7 min-w-0 flex-1 px-2 text-[10px]"}),e.jsxs("button",{type:"button","aria-label":t("settings.plugins.addMarketplaceAria"),onClick:()=>void Ce(),disabled:!Y.trim()||A!==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:[A==="marketplace:add"?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(We,{className:"h-3 w-3"}),t("settings.plugins.add")]})]}),v.map(f=>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:[f.name,e.jsxs("span",{className:"ml-2 font-normal text-[#9CA3AF]",children:[f.sourceType," · ",f.revision.slice(0,12)]})]}),e.jsx("p",{className:"mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:f.description||t("settings.plugins.noDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.refreshMarketplaceAria",{name:f.name}),disabled:A!==null,onClick:()=>void de(f),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:A===`marketplace:refresh:${f.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(Te,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.removeMarketplaceAria",{name:f.name}),disabled:A!==null,onClick:()=>void re(f),className:D("rounded p-1 text-[#9CA3AF] disabled:opacity-40",X===`marketplace:remove:${f.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:X===`marketplace:remove:${f.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:t("settings.plugins.confirm")}):e.jsx(ze,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[f.plugins.slice(0,12).map(_=>e.jsxs("button",{type:"button",disabled:_.installed||A!==null,onClick:()=>{Q(`${_.name}@${f.name}`),J(!1)},title:_.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:[_.name,_.installed?t("settings.plugins.installedSuffix"):""]},_.name)),f.plugins.length>12&&e.jsxs("span",{className:"px-1 py-0.5 text-[8.5px] text-[#9CA3AF]",children:["+",f.plugins.length-12]})]})]},f.name)),!S&&v.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-[10px] text-[#9CA3AF]",children:t("settings.plugins.marketplaceEmpty")})]})]}):e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.plugins.selectProject")})}const Pn={not_required:"settings.trust.state.notRequired",trusted:"settings.trust.state.trusted",untrusted:"settings.trust.state.review",error:"settings.trust.state.error"};function Bn(){const t=ge(),a=Le(R=>{var j;return(j=R.currentSessionRef)==null?void 0:j.projectPath}),s=n.useMemo(()=>a??new URLSearchParams(window.location.search).get("project")??"",[a]),[l,r]=n.useState(null),[m,h]=n.useState(""),[g,u]=n.useState(!1),[i,N]=n.useState(null),[c,b]=n.useState(null),[k,p]=n.useState(null),[E,w]=n.useState(!1),B=n.useRef(0),I=n.useRef(s);I.current=s;const y=m===s?l:null,S=n.useCallback(async()=>{const R=++B.current;if(!s){r(null),h(""),p(null);return}u(!0),p(null);try{const j=await q(`/workspace-trust?projectPath=${encodeURIComponent(s)}`);if(R!==B.current)return;r(j),h(s)}catch(j){if(R!==B.current)return;p(j instanceof Error?j.message:t("settings.trust.loadFailed"))}finally{R===B.current&&u(!1)}},[s,t]);n.useEffect(()=>(b(null),w(!1),S(),()=>{B.current+=1}),[S]);const U=async R=>{if(!y)return;const j=s;N(R),p(null);try{const O=await q("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:j,action:R})});I.current===j&&(r(O),h(j),b(null),w(O.reloadRequired===!0))}catch(O){I.current===j&&p(O instanceof Error?O.message:t("settings.trust.updateFailed"))}finally{N(null)}};if(!s)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.trust.selectSession")});const A=(y==null?void 0:y.state)==="trusted",F=(y==null?void 0:y.state)==="untrusted";return e.jsxs("div",{className:"flex flex-col gap-3 min-h-0 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 gap-2 items-center",children:[A?e.jsx(ht,{className:"w-4 h-4 text-emerald-600"}):e.jsx(Ut,{className:D("h-4 w-4",F?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(y?Pn[y.state]:"settings.trust.heading")}),g&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:s}),y&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[y.decision,y.inheritedFrom?t("settings.trust.inheritedFrom",{source:y.inheritedFrom}):""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:g||i!==null,"aria-label":t("settings.trust.reloadAria"),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(Te,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),A?e.jsx("button",{type:"button",onClick:()=>b("revoke"),disabled:i!==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:t("settings.trust.revoke")}):e.jsx("button",{type:"button",onClick:()=>b("trust"),disabled:i!==null||(y==null?void 0:y.state)==="error"||!y||y.sensitiveSources===0,className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:t("settings.trust.trustWorkspace")})]})]}),(k||(y==null?void 0:y.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:k||(y==null?void 0:y.error)}),E&&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:t("settings.trust.restartNotice")}),c&&y&&e.jsxs("div",{role:"alertdialog","aria-label":t(c==="trust"?"settings.trust.trustWorkspace":"settings.trust.revokeAria"),className:"flex flex-wrap gap-3 justify-between items-center px-3 py-2 bg-amber-50 rounded-md border border-amber-300 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"?t("settings.trust.confirmTrust",{count:y.sensitiveSources}):t("settings.trust.confirmRevoke")}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>b(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void U(c),disabled:i!==null,className:D("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:t(i?"settings.trust.saving":c==="trust"?"settings.trust.trustReviewed":"settings.trust.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((y==null?void 0:y.sources)??[]).map(R=>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:R.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:R.kind})]}),R.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:R.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:R.effects.map((j,O)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:j.kind})," · ",j.name,j.target?` → ${j.target}`:""]},`${j.kind}-${j.name}-${O}`))})]},`${R.kind}-${R.path}`)),y&&y.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.trust.empty")})]})]})}const Tn={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},Mn={searchTasks:"settings.shortcuts.action.searchTasks",openCommands:"settings.shortcuts.action.openCommands",newTask:"settings.shortcuts.action.newTask",focusComposer:"settings.shortcuts.action.focusComposer",toggleSidebar:"settings.shortcuts.action.toggleSidebar"},Dt={auto:"settings.style.auto",pragmatic:"settings.style.pragmatic",friendly:"settings.style.friendly",explanatory:"settings.style.explanatory"},Lt={Global:"settings.shortcuts.scope.global",Chat:"settings.shortcuts.scope.chat",Layout:"settings.shortcuts.scope.layout"};function $n(){var Ne,je;const t=ge(),{locale:a}=aa(),{isSettingsOpen:s,settingsSection:l,toggleSettings:r,isSidebarOpen:m,setSidebarOpen:h}=sa(),{configuredModels:g,loadModels:u,isLoading:i,error:N}=It(),c=na(),[b,k]=n.useState("general"),[p,E]=n.useState(!1),[w,B]=n.useState(null),[I,y]=n.useState(null),[S,U]=n.useState(null),[A,F]=n.useState([]),[R,j]=n.useState(null),[O,Q]=n.useState(null),[Y,Z]=n.useState(null),[ee,J]=n.useState(null),[X,T]=n.useState({}),[K,G]=n.useState(null),[te,L]=n.useState(null),[C,v]=n.useState(""),[M,V]=n.useState("all"),pe=n.useRef(null),Ae=n.useRef(null),le=n.useRef(0),[he,we]=n.useState(typeof Notification>"u"?"unsupported":Notification.permission),ce=[{value:"general",label:t("settings.tab.general"),category:t("settings.category.settings")},{value:"trust",label:t("settings.tab.trust"),category:t("settings.category.settings")},{value:"models",label:t("settings.tab.models"),category:t("settings.category.settings")},{value:"shortcuts",label:t("settings.tab.shortcuts"),category:t("settings.category.settings")},{value:"mcp",label:t("settings.tab.mcp"),category:t("settings.category.integrations")},{value:"skills",label:t("settings.tab.skills"),category:t("settings.category.integrations")},{value:"plugins",label:t("settings.tab.plugins"),category:t("settings.category.integrations")},{value:"hooks",label:t("settings.tab.hooks"),category:t("settings.category.integrations")},{value:"schedules",label:t("settings.tab.schedules"),category:t("settings.category.integrations")}],de=n.useMemo(()=>ra.map(o=>({action:t(Mn[o.id]),combo:la(o),scope:o.scope})),[a]).filter(o=>{const $=o.action.toLowerCase().includes(C.toLowerCase()),z=M==="all"||o.scope.toLowerCase()===M;return $&&z}),re=g.reduce((o,$)=>{const z=$.provider||"unknown";return o[z]||(o[z]=[]),o[z].push($),o},{}),f=new Map(A.map(o=>[o.id,o]));for(const o of A)o.custom&&!re[o.id]&&(re[o.id]=[]);const _=n.useCallback(async()=>{try{F(await q("/providers")),J(null)}catch(o){J(o instanceof Error?o.message:t("settings.models.loadChannelsFailed"))}},[t]);n.useEffect(()=>{s&&(k(l),u(),_(),c.loadSettings())},[s,u,_,c.loadSettings,l]);const ae=()=>{const o=Ae.current,$=o!=null&&o.isConnected?o:document.querySelector("[data-settings-trigger]");$==null||$.focus({preventScroll:!0})},oe=()=>{r(),requestAnimationFrame(ae)};n.useLayoutEffect(()=>{if(!s)return;const o=document.activeElement instanceof HTMLElement?document.activeElement:null;o&&o!==document.body&&o!==document.documentElement&&!o.closest("[data-settings-panel]")&&(Ae.current=o);const $=requestAnimationFrame(()=>{var z;(z=pe.current)==null||z.focus({preventScroll:!0})});return()=>{cancelAnimationFrame($),requestAnimationFrame(ae)}},[s]);const xe=async o=>{G("save"),L(null);try{return await q("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:o.provider,displayName:o.displayName,model:o.model,apiKey:o.apiKey,modelProvider:o.modelProvider,overrides:o.overrides})}),await u(),await _(),!0}catch($){return L($ instanceof Error?$.message:t("settings.models.saveFailed")),!1}finally{G(null)}},fe=async()=>{typeof Notification>"u"||we(await Notification.requestPermission())},be=async o=>{G("delete"),L(null);try{await q(`/models/${o}`,{method:"DELETE"}),await u(),U(null)}catch($){L($ instanceof Error?$.message:t("settings.models.deleteFailed"))}finally{G(null)}},Fe=async(o,$)=>{G("update"),L(null);try{return await q(`/models/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),await u(),!0}catch(z){return L(z instanceof Error?z.message:t("settings.models.updateFailed")),!1}finally{G(null)}},P=async(o,$)=>{Z({providerId:o,type:"update"}),J(null);try{return await q(`/providers/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),await Promise.all([u(),_()]),!0}catch(z){return J(z instanceof Error?z.message:t("settings.models.updateChannelFailed")),!1}finally{Z(null)}},Be=async(o,$)=>{Z({providerId:o.id,type:"probe"}),J(null);try{const z=await q(`/providers/${o.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:$})});T(d=>({...d,[o.id]:z}))}catch(z){J(z instanceof Error?z.message:t("settings.models.probeFailed"))}finally{Z(null)}},ve=async o=>{Z({providerId:o.id,type:"delete"}),J(null);try{await q(`/providers/${o.id}?removeModels=true`,{method:"DELETE"}),Q(null),B(null),T($=>{const z={...$};return delete z[o.id],z}),await Promise.all([u(),_()])}catch($){J($ instanceof Error?$.message:t("settings.models.deleteChannelFailed"))}finally{Z(null)}},Me=(o,$)=>{var W,H;const z=o.key==="ArrowRight"||o.key==="ArrowDown"?1:o.key==="ArrowLeft"||o.key==="ArrowUp"?-1:0;if(z===0&&o.key!=="Home"&&o.key!=="End")return;o.preventDefault();const d=o.key==="Home"?0:o.key==="End"?ce.length-1:($+z+ce.length)%ce.length;k(ce[d].value),(H=(W=o.currentTarget.closest('[role="tablist"]'))==null?void 0:W.querySelectorAll('[role="tab"]')[d])==null||H.focus()},x=o=>{B(w===o?null:o)},ue=o=>{if(!s||o.key!=="Escape"||!(o.target instanceof Node)||!o.currentTarget.contains(o.target)||p||I||R||Date.now()-le.current<250)return;const $=o.target instanceof Element?o.target:null;if(!(o.defaultPrevented||$!=null&&$.closest('[role="dialog"]'))){if(o.preventDefault(),S){U(null);return}if(O){Q(null);return}oe()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:ue,className:"flex h-full min-h-0 bg-white dark:bg-[#09090b]",children:[e.jsxs("nav",{role:"tablist","aria-label":t("settings.nav.aria"),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:"p-4 shrink-0",children:e.jsxs("button",{ref:pe,type:"button",onClick:oe,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(pa,{className:"h-3.5 w-3.5"}),t("settings.action.back")]})}),e.jsx("div",{className:"overflow-y-auto flex-1 px-3 pb-4",children:Object.entries(ce.reduce((o,$)=>(o[$.category]||(o[$.category]=[]),o[$.category].push($),o),{})).map(([o,$])=>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:o}),$.map(z=>e.jsx("button",{onClick:()=>k(z.value),onKeyDown:d=>Me(d,ce.indexOf(z)),role:"tab",id:`settings-tab-${z.value}`,"aria-controls":`settings-panel-${z.value}`,"aria-selected":b===z.value,tabIndex:b===z.value?0:-1,className:D("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",b===z.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:z.label},z.value))]},o))})]}),e.jsx("div",{className:"flex overflow-hidden flex-col flex-1 min-h-0",children:e.jsx("div",{className:"overflow-y-auto flex-1 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=ce.find(o=>o.value===b))==null?void 0:Ne.label)??t("settings.title")}),c.isLoading&&b==="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(ne,{className:"h-3.5 w-3.5 animate-spin"}),t("settings.general.loading")]}),c.error&&b==="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(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:c.error}),e.jsx("button",{type:"button",onClick:()=>void c.loadSettings(),className:"underline shrink-0",children:t("settings.common.retry")})]}),b==="models"&&e.jsxs("div",{id:"settings-panel-models",role:"tabpanel","aria-labelledby":"settings-tab-models",className:"flex overflow-hidden flex-col flex-1 gap-6 min-h-0",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:t("settings.models.description")}),(N||te||ee)&&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(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:ee||te||N}),e.jsx("button",{type:"button",onClick:()=>{L(null),J(null),N&&u()},className:"underline shrink-0",children:t(N?"settings.common.retry":"settings.common.dismiss")})]}),S&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteModelAria",{name:S.displayName||S.model}),className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteModelPrompt",{name:S.displayName||S.model})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>U(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void be(S.id),disabled:K!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:t(K==="delete"?"settings.models.deleting":"settings.models.deleteModel")})]})]}),O&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteChannelAria",{name:O.name}),className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteChannelPrompt",{name:O.name,count:((je=re[O.id])==null?void 0:je.length)??0})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>Q(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void ve(O),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==null?void 0:Y.type)==="delete"?t("settings.models.deleting"):t("settings.models.deleteChannel")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[i&&g.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(ne,{className:"w-4 h-4 animate-spin"}),t("settings.models.loading")]}),Object.entries(re).map(([o,$])=>{const z=Tn[o]||{bg:"#71717a",label:"?"},d=f.get(o),W=w===o,H=X[o],ye=(Y==null?void 0:Y.providerId)===o&&Y.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:()=>x(o),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 gap-3 items-center min-w-0",children:[e.jsx("div",{className:"flex justify-center items-center w-8 h-8 text-xs font-bold text-white rounded shrink-0",style:{backgroundColor:z.bg},children:z.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:(d==null?void 0:d.name)??o.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[$.length===1?t("settings.models.modelCountOne",{count:$.length}):t("settings.models.modelCountMany",{count:$.length}),d!=null&&d.custom?` · ${d.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex gap-3 items-center shrink-0",children:[e.jsxs("span",{className:D("text-xs font-mono",(d==null?void 0:d.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(d==null?void 0:d.configured)===!1?t("settings.models.missingCredential"):t("settings.models.configured")]}),e.jsx(_t,{className:D("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",W&&"rotate-180")})]})]}),(d==null?void 0:d.custom)&&e.jsxs("div",{className:"flex gap-1 items-center pr-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{var me;return void Be(d,(me=$[0])==null?void 0:me.id)},disabled:Y!==null||$.length===0,"aria-label":t("settings.models.testChannelAria",{name:d.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:ye?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(fa,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":d.id,onClick:()=>{J(null),j(d)},disabled:Y!==null,"aria-label":t("settings.models.editChannelAria",{name:d.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(mt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>Q(d),disabled:Y!==null,"aria-label":t("settings.models.deleteChannelActionAria",{name:d.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(ze,{className:"h-3.5 w-3.5"})})]})]}),H&&e.jsxs("div",{role:"status",className:D("border-t px-4 py-2 font-mono text-[11px]",H.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:[H.message," · ",H.latencyMs,"ms · ",H.wireApi]}),W&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:[(d==null?void 0:d.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:d.id})," ","· ",d.defaultBaseUrl]}),$.map(me=>{var Ge;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:me.displayName||me.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[me.displayName&&`${me.model} · `,((Ge=me.overrides)==null?void 0:Ge.baseUrl)||t("settings.models.defaultEndpoint")]})]}),e.jsxs("div",{className:"flex gap-2 items-center opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx("button",{"data-edit-model-trigger":me.id,onClick:()=>{L(null),y(me)},disabled:K!==null,"aria-label":t("settings.models.editModelAria",{name:me.displayName||me.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(mt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>U(me),disabled:K!==null,"aria-label":t("settings.models.deleteModelAria",{name:me.displayName||me.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(ze,{className:"h-3.5 w-3.5"})})]})]},me.id)})]})]},o)}),!i&&!N&&Object.keys(re).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:t("settings.models.empty")})]})}),e.jsx("button",{"data-add-model-trigger":!0,onClick:()=>{L(null),E(!0)},disabled:K!==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:t("settings.models.add")})]}),b==="general"&&e.jsxs("div",{id:"settings-panel-general",role:"tabpanel","aria-labelledby":"settings-tab-general","aria-busy":c.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:t("settings.tab.general")}),e.jsxs("div",{className:"flex justify-between items-center 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:t("settings.general.responseLanguage")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.responseLanguageHint")})]}),e.jsx(Se,{"aria-label":t("settings.general.responseLanguage"),value:c.language,onChange:o=>c.updateSettings({language:o}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"en-US",label:"English (US)"},{value:"zh-CN",label:"简体中文"},{value:"zh-TW",label:"繁體中文"},{value:"ja-JP",label:"日本語"},{value:"ko-KR",label:"한국어"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"},{value:"de-DE",label:"Deutsch"},{value:"pt-BR",label:"Português (BR)"},{value:"ru-RU",label:"Русский"}]})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.general.autoSave")}),e.jsx(Re,{label:t("settings.general.autoSave"),enabled:c.autoSaveSessions,onChange:o=>c.updateSettings({autoSaveSessions:o})})]}),e.jsxs("div",{className:"flex justify-between items-center 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:t("settings.general.communicationStyle")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.communicationStyleHint")})]}),e.jsx(Se,{"aria-label":t("settings.general.communicationStyle"),value:c.communicationStyle??"auto",onChange:o=>c.updateSettings({communicationStyle:o}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:jn.map(o=>({value:o.id,label:Dt[o.id]?t(Dt[o.id]):o.name}))})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.appearance.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.theme")}),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(o=>e.jsx("button",{onClick:()=>c.updateSettings({uiTheme:o}),className:D("px-3 py-1 rounded text-[12px] font-mono transition-colors",c.uiTheme===o?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t(o==="dark"?"settings.appearance.theme.dark":o==="light"?"settings.appearance.theme.light":"settings.appearance.theme.system")},o))})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.compactSidebar")}),e.jsx(Re,{label:t("settings.appearance.compactSidebar"),enabled:!m,onChange:o=>h(!o)})]}),e.jsxs("div",{className:"flex justify-between items-center 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:t("settings.appearance.codeTheme")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.appearance.codeThemeHint")})]}),e.jsx(Se,{"aria-label":t("settings.appearance.codeTheme"),value:c.theme,onChange:o=>c.updateSettings({theme:o}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"dracula",label:"Dracula"},{value:"monokai",label:"Monokai"},{value:"nord",label:"Nord"},{value:"tokyo-night",label:"Tokyo Night"},{value:"one-dark",label:"One Dark"},{value:"catppuccin",label:"Catppuccin"},{value:"gruvbox",label:"Gruvbox"},{value:"github",label:"GitHub"},{value:"solarized-light",label:"Solarized Light"},{value:"solarized-dark",label:"Solarized Dark"},{value:"ayu-dark",label:"Ayu Dark"},{value:"rose-pine",label:"Rose Pine"},{value:"kanagawa",label:"Kanagawa"}]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.notifications.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.buildFinished")}),e.jsx(Re,{label:t("settings.notifications.buildFinished"),enabled:c.notifyBuild,onChange:o=>c.updateSettings({notifyBuild:o})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.errorsOnly")}),e.jsx(Re,{label:t("settings.notifications.errorsOnly"),enabled:c.notifyErrors,onChange:o=>c.updateSettings({notifyErrors:o})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.systemSounds")}),e.jsx(Re,{label:t("settings.notifications.systemSounds"),enabled:c.notifySounds,onChange:o=>c.updateSettings({notifySounds:o})})]}),(c.notifyBuild||c.notifyErrors)&&he!=="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:t(he==="denied"?"settings.notifications.blocked":he==="unsupported"?"settings.notifications.unavailable":"settings.notifications.enablePrompt")}),he==="default"&&e.jsx("button",{type:"button",onClick:()=>void fe(),className:"shrink-0 rounded-md bg-[#111827] px-2.5 py-1.5 text-[10px] font-mono text-white hover:bg-[#374151] dark:bg-[#E5E5E5] dark:text-[#111827]",children:t("settings.common.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:t("settings.privacy.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.privacy.telemetry")}),e.jsx(Re,{label:t("settings.privacy.telemetry"),enabled:c.privacyTelemetry,onChange:o=>c.updateSettings({privacyTelemetry:o})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.privacy.crash")}),e.jsx(Re,{label:t("settings.privacy.crash"),enabled:c.privacyCrash,onChange:o=>c.updateSettings({privacyCrash:o})})]})]})]}),b==="shortcuts"&&e.jsxs("div",{id:"settings-panel-shortcuts",role:"tabpanel","aria-labelledby":"settings-tab-shortcuts",className:"flex overflow-hidden flex-col flex-1 gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col gap-2 shrink-0 sm:flex-row sm:items-center sm:gap-3",children:[e.jsx("input",{"aria-label":t("settings.shortcuts.searchPlaceholder"),value:C,onChange:o=>v(o.target.value),placeholder:t("settings.shortcuts.searchPlaceholder"),className:"field flex-1 text-[12px]"}),e.jsx(Se,{"aria-label":t("settings.shortcuts.col.scope"),value:M,onChange:o=>V(o),className:"w-auto min-w-[120px] text-[12px]",options:[{value:"all",label:t("settings.shortcuts.scope.all")},{value:"global",label:t("settings.shortcuts.scope.global")},{value:"chat",label:t("settings.shortcuts.scope.chat")},{value:"layout",label:t("settings.shortcuts.scope.layout")}]}),e.jsx("button",{onClick:()=>{v(""),V("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:t("settings.shortcuts.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:t("settings.shortcuts.col.action")}),e.jsx("span",{children:t("settings.shortcuts.col.shortcut")}),e.jsx("span",{children:t("settings.shortcuts.col.scope")})]}),de.map((o,$)=>e.jsxs("div",{className:D("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",$%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:o.action}),e.jsx("div",{className:"flex gap-1 items-center",children:o.combo.map(z=>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:z},z))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:Lt[o.scope]?t(Lt[o.scope]):o.scope})]},`${o.action}-${o.scope}`)),de.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:t("settings.shortcuts.empty")})]})]}),b==="mcp"&&e.jsx("div",{id:"settings-panel-mcp",role:"tabpanel","aria-labelledby":"settings-tab-mcp",className:"flex-1 min-h-0",children:e.jsx(rn,{active:b==="mcp"})}),b==="skills"&&e.jsx("div",{id:"settings-panel-skills",role:"tabpanel","aria-labelledby":"settings-tab-skills",className:"flex-1 min-h-0",children:e.jsx(bn,{active:b==="skills"})}),b==="hooks"&&e.jsx("div",{id:"settings-panel-hooks",role:"tabpanel","aria-labelledby":"settings-tab-hooks",className:"flex-1 min-h-0",children:e.jsx(Sn,{})}),b==="plugins"&&e.jsx("div",{id:"settings-panel-plugins",role:"tabpanel","aria-labelledby":"settings-tab-plugins",className:"flex-1 min-h-0",children:e.jsx(Fn,{})}),b==="schedules"&&e.jsx("div",{id:"settings-panel-schedules",role:"tabpanel","aria-labelledby":"settings-tab-schedules",className:"flex-1 min-h-0",children:e.jsx(fn,{active:b==="schedules"})}),b==="trust"&&e.jsx("div",{id:"settings-panel-trust",role:"tabpanel","aria-labelledby":"settings-tab-trust",className:"flex-1 min-h-0",children:e.jsx(Bn,{})})]})})})]}),p&&e.jsx(Nn,{open:!0,onOpenChange:o=>{o||(le.current=Date.now()),E(o)},onSave:xe,saveError:te}),I&&e.jsx(En,{open:!0,onOpenChange:o=>{o||(le.current=Date.now(),y(null))},model:I,onSave:Fe,saveError:te}),R&&e.jsx(wn,{provider:R,onOpenChange:o=>{o||(le.current=Date.now(),j(null))},onSave:P,saveError:ee})]})}function Re({label:t,enabled:a,onChange:s}){return e.jsx("button",{type:"button",role:"switch","aria-label":t,"aria-checked":a,onClick:()=>s(!a),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors",a?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full transition-transform",a?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{$n as SettingsModal};
@@ -0,0 +1 @@
1
+ import{j as n,r as d}from"./vendor-react-DG5dkZ_t.js";import{j as S,H as Ce,d as G,c as R,I as Te,J as E,L as _,M as De,u as Ae,b as p,a as o,N as L,r as Ie,D as Fe,e as Le,O as Pe,g as Re,h as Ee,s as qe}from"./index-I_DKONsY.js";import{ae as ue,i as Be,F as Me,j as Ke,h as Oe,af as $e,ag as We,o as Qe,ah as He,ai as Ue,k as z,f as de,aj as ze,U as Ge,ak as _e,G as Je,al as Ve,L as P,S as Xe,R as Ye}from"./vendor-icons-ICv1v-tf.js";import"./vendor-radix-DXRuAJHH.js";function Ze(t,r){const s=r.trim().toLocaleLowerCase();return s?t.filter(i=>`${i.label} ${i.description} ${i.keywords}`.toLocaleLowerCase().includes(s)):t}function et({actions:t,selectedIndex:r,onSelect:s,onRun:i}){return t.map((c,h)=>{const k=h===r,m=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(m,{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(ue,{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 tt={running:"running active 进行中 运行中",queued:"queued waiting 排队中 等待中",interrupted:"interrupted paused 已暂停 已中断",failed:"failed error 已失败 错误",cancelled:"cancelled canceled 已取消",completed:"completed done finished 已完成 完成"};function J(t){return Te(t,De)}function nt(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 st(t,r){var i,c;const s=E(t,r);return q([J(t),_(s),s,t.projectPath,t.gitBranch,t.taskWorktreeBranch,t.taskStatus,tt[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 me(t,r,s){if(!r)return 0;const i=q(J(t)),c=q(_(E(t,s)));return i===r?500:i.startsWith(r)?400:i.includes(r)?300:c===r?250:c.startsWith(r)?200:100}function at(t,r,s,i=50){const c=q(r),h=c.split(/\s+/).filter(Boolean),k=new Set;return t.filter(m=>{if(h.length===0)return!0;const u=st(m,s);return h.every(g=>u.includes(g))}).sort((m,u)=>{const g=+!!u.pendingInteraction-+!!m.pendingInteraction;return g!==0?g:me(u,c,s)-me(m,c,s)||Ce(m,u)}).filter(m=>{const u=G(R(m));return k.has(u)?!1:(k.add(u),!0)}).slice(0,i)}const rt={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 dt(){const t=Ae(),r=p(e=>e.isTaskSwitcherOpen),s=p(e=>e.taskSwitcherMode),i=p(e=>e.setTaskSwitcherOpen),c=p(e=>e.setTaskSwitcherMode),h=p(e=>e.toggleSidebar),k=p(e=>e.isFilePreviewOpen),m=p(e=>e.setFilePreviewOpen),u=p(e=>e.openFilePreview),g=p(e=>e.toggleTerminal),b=p(e=>e.openSettings),v=o(e=>e.sessions),pe=o(e=>e.isLoading),C=o(e=>e.catalogLoadState),B=C==="loading"||C==="hydrating",M=o(e=>e.currentSessionRef),V=o(e=>e.isTemporarySession),X=o(e=>e.startTemporarySession),K=o(e=>e.unreadTaskKeys),he=o(e=>e.boundProjects),A=o(e=>{var a;return e.selectedProjectPath??((a=e.taskWorkspaceInfo)==null?void 0:a.cwd)??null}),ke=o(e=>e.selectProject),xe=o(e=>e.selectSession),fe=o(e=>e.cancelTask),ge=o(e=>e.retryTask),be=o(e=>e.cancellingTaskKeys),ve=o(e=>e.retryingTaskKeys),[w,Y]=d.useState(""),[f,j]=d.useState(0),[we,O]=d.useState(null),[Z,I]=d.useState(null),ee=d.useRef(null),te=d.useRef(null),ne=d.useMemo(()=>[{id:"new-task",label:t("commandCenter.action.newTask"),description:t("commandCenter.action.newTaskDescription"),keywords:"create compose session",icon:Be,shortcut:L("newTask"),run:()=>{X(),requestAnimationFrame(()=>Ie())}},{id:"toggle-preview",label:t("commandCenter.action.preview"),description:t("commandCenter.action.previewDescription"),keywords:"diff files logs artifact review",icon:Me,run:()=>{k?m(!1):u((!M||V)&&p.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:Ke,run:g},{id:"open-settings",label:t("commandCenter.action.settings"),description:t("commandCenter.action.settingsDescription"),keywords:"preferences general",icon:Oe,run:()=>b("general")},{id:"open-models",label:t("commandCenter.action.models"),description:t("commandCenter.action.modelsDescription"),keywords:"provider llm api configuration",icon:$e,run:()=>b("models")},{id:"open-shortcuts",label:t("commandCenter.action.shortcuts"),description:t("commandCenter.action.shortcutsDescription"),keywords:"keyboard hotkey key binding",icon:We,shortcut:L("openCommands"),run:()=>b("shortcuts")},{id:"open-skills",label:t("commandCenter.action.skills"),description:t("commandCenter.action.skillsDescription"),keywords:"capabilities workflow",icon:Qe,run:()=>b("skills")},{id:"open-mcp",label:t("commandCenter.action.mcp"),description:t("commandCenter.action.mcpDescription"),keywords:"server tools protocol integration",icon:He,run:()=>b("mcp")},{id:"toggle-sidebar",label:t("commandCenter.action.sidebar"),description:t("commandCenter.action.sidebarDescription"),keywords:"navigation layout panel projects",icon:Ue,shortcut:L("toggleSidebar"),run:h}],[M,k,V,u,b,m,X,t,h,g]),y=d.useMemo(()=>at(v,w,A),[A,w,v]),T=d.useMemo(()=>Ze(ne,w),[ne,w]),D=s==="tasks"?y.length:T.length,se=d.useMemo(()=>v.filter(e=>!!e.pendingInteraction).length,[v]),$=s==="tasks"?y[f]??null:null,W=s==="commands"?T[f]??null:null;d.useEffect(()=>{r&&(Y(""),j(0),O(null),I(null))},[s,r]),d.useEffect(()=>{j(0)},[w]),d.useEffect(()=>{var a,l;const e=(a=te.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 ae=async e=>{const a=R(e),l=G(a),x=E(e,A);O(l),he.some(N=>N.path===x)&&ke(x);try{await xe(a),i(!1)}catch(N){I(N instanceof Error?N.message:t("taskSwitcher.action.failed"))}finally{O(null)}},re=async(e,a)=>{I(null);try{const l=R(a);e==="cancel"?await fe(l):(await ge(l),i(!1))}catch(l){I(l instanceof Error?l.message:t("taskSwitcher.action.failed"))}},ie=e=>{i(!1),requestAnimationFrame(e.run)},ye=e=>{e.key==="ArrowDown"?(e.preventDefault(),j(a=>D===0?0:(a+1)%D)):e.key==="ArrowUp"?(e.preventDefault(),j(a=>D===0?0:(a-1+D)%D)):e.key==="Enter"&&$?(e.preventDefault(),ae($)):e.key==="Enter"&&W?(e.preventDefault(),ie(W)):e.key==="Escape"&&(e.preventDefault(),i(!1))};return n.jsx(Fe,{open:r,onOpenChange:i,children:n.jsxs(Le,{hideCloseButton:!0,onCloseAutoFocus:Pe,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(Re,{className:"sr-only",children:t("commandCenter.title")}),n.jsx(Ee,{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(z,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),n.jsx("input",{ref:ee,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:w,onChange:e=>Y(e.target.value),onKeyDown:ye,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=ee.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}):w?t("taskSwitcher.results",{count:y.length}):B?v.length===0?t("taskSwitcher.indexing"):t("taskSwitcher.indexingLoaded",{count:v.length}):C==="error"?t("sidebar.catalog.incomplete"):se>0?t("taskSwitcher.needsAction",{count:se}):K.length>0?t("taskSwitcher.unread",{count:K.length}):t("taskSwitcher.scope",{count:v.length})})})]}),Z&&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:Z}),n.jsxs("div",{id:"task-switcher-results",ref:te,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(et,{actions:T,selectedIndex:f,onSelect:j,onRun:ie}),s==="tasks"&&y.map((e,a)=>{const l=R(e),x=G(l),N=E(e,A),je=_(N),ce=qe(l,M),Q=a===f,Ne=we===x,Se=K.includes(x),F=J(e),oe=e.taskStatus==="running"||e.taskStatus==="queued",le=!!e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled"),H=be.includes(x),U=ve.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:()=>j(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 ae(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))]",ce?"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(de,{className:"h-3.5 w-3.5 animate-pulse text-amber-600 dark:text-amber-400"}):e.taskStatus==="running"?n.jsx(ze,{className:"h-3.5 w-3.5 animate-pulse"}):n.jsx(Ge,{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}),ce&&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")}),Se&&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(_e,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:je})]}),(e.taskWorktreeBranch||e.gitBranch)&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Je,{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(rt[e.taskStatus])}),n.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1",children:[n.jsx(Ve,{className:"h-2.5 w-2.5"}),nt(e)]})]})]}),Ne?n.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):n.jsx(ue,{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")})]}),(oe||le)&&n.jsxs("div",{className:"flex shrink-0 items-center pr-2",children:[oe&&n.jsx("button",{type:"button","aria-label":t(H?"session.action.stopping":"session.action.stop",{title:F}),disabled:H,onClick:()=>void re("cancel",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:H?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Xe,{className:"h-3.5 w-3.5"})}),le&&n.jsx("button",{type:"button","aria-label":t(U?"session.action.retrying":"session.action.retry",{title:F}),disabled:U,onClick:()=>void re("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:U?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Ye,{className:"h-3.5 w-3.5"})})]})]},x)}),s==="tasks"&&y.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(P,{className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("taskSwitcher.indexing")]}),s==="tasks"&&y.length===0&&!B&&C!=="error"&&!pe&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(z,{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"&&y.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(de,{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(z,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("commandCenter.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("commandCenter.emptyHint")})]})]}),n.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-4 py-2 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{children:["↑↓ ",t("taskSwitcher.hint.navigate")]}),n.jsxs("span",{children:["↵ ",t("taskSwitcher.hint.open")]}),n.jsxs("span",{className:"ml-auto",children:[L(s==="tasks"?"openCommands":"searchTasks")," ",t(s==="tasks"?"commandCenter.mode.commands":"commandCenter.mode.tasks")]})]})]})})}export{dt as TaskSwitcher};
@@ -1 +1 @@
1
- import{r as t,j as a}from"./vendor-react-DG5dkZ_t.js";import{D as A,o as R,L as j}from"./vendor-xterm-DuYZoU4T.js";import{u as C,b as N,R as F,j as x}from"./index-BF5HEN_f.js";import{j as M,al as S,X as T}from"./vendor-icons-D_AkWmWB.js";import"./vendor-radix-DBy9B2DN.js";const Y=({workspacePath:b})=>{const c=C(),{isTerminalOpen:l,toggleTerminal:y}=N(),[s,z]=t.useState(!1),[p,u]=t.useState(!1),g=F(),m=t.useRef(null),i=t.useRef(null),h=t.useRef(null),o=t.useRef(null),E=t.useRef(null),B=t.useCallback(()=>{var f;if(((f=o.current)==null?void 0:f.readyState)===WebSocket.OPEN)return;const r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=b?`${r}?cwd=${encodeURIComponent(b)}`:r,n=new WebSocket(e);o.current=n,n.onopen=()=>{u(!0)},n.onmessage=w=>{var d;(d=i.current)==null||d.write(w.data)},n.onclose=()=>{u(!1)},n.onerror=()=>{u(!1)}},[b]),k=t.useCallback(()=>{o.current&&(o.current.close(),o.current=null),u(!1)},[]),v=t.useCallback(r=>{var e;((e=o.current)==null?void 0:e.readyState)===WebSocket.OPEN&&o.current.send(r)},[]);return t.useEffect(()=>(E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{var r;return(r=E.current)==null?void 0:r.focus({preventScroll:!0})}),[]),t.useEffect(()=>{if(!l||!m.current||i.current)return;const r={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new A({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:r}),n=new R,f=new j;e.loadAddon(n),e.loadAddon(f),e.open(m.current),n.fit();const w=requestAnimationFrame(()=>e.focus());return e.onData(d=>{v(d)}),i.current=e,h.current=n,B(),()=>{cancelAnimationFrame(w),k(),e.dispose(),i.current=null,h.current=null}},[l,B,k,v]),t.useEffect(()=>{i.current&&(i.current.options.theme=g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[g]),t.useEffect(()=>{if(!l||s)return;const r=()=>{var n;(n=h.current)==null||n.fit()};window.addEventListener("resize",r);const e=setTimeout(r,100);return()=>{window.removeEventListener("resize",r),clearTimeout(e)}},[l,s]),l?a.jsxs("div",{role:"region","aria-label":c("terminal.title"),className:x("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",s?"h-10":"h-[min(18rem,45dvh)]"),children:[a.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),a.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:c("terminal.title")}),a.jsx("span",{role:"status","aria-label":c(p?"terminal.status.connected":"terminal.status.disconnected"),className:x("w-2 h-2 rounded-full",p?"bg-green-500":"bg-zinc-600")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>z(!s),"aria-label":c(s?"terminal.action.restore":"terminal.action.minimize"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(S,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>{k(),y()},"aria-label":c("terminal.action.close"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(T,{className:"h-4 w-4"})})]})]}),a.jsx("div",{ref:m,className:x("h-[calc(100%-40px)] p-2",s&&"hidden")})]}):null};export{Y as TerminalPanel};
1
+ import{r as t,j as a}from"./vendor-react-DG5dkZ_t.js";import{D as A,o as j,L as R}from"./vendor-xterm-DuYZoU4T.js";import{u as C,b as N,T as F,j as x}from"./index-I_DKONsY.js";import{j as M,an as S,X as T}from"./vendor-icons-ICv1v-tf.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};