blade-code 0.10.206 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-erhaedch.js → chunk-06hkf59s.js} +1 -1
- package/dist/{chunk-dnpkf5mv.js → chunk-0b83mt1c.js} +2 -2
- package/dist/{chunk-3crwyd2r.js → chunk-0wcnkxe8.js} +2 -2
- package/dist/{chunk-gz84aewr.js → chunk-1beqtjsw.js} +1 -1
- package/dist/chunk-1kxpnt9q.js +1 -0
- package/dist/{chunk-az3rehz9.js → chunk-25s0c8km.js} +399 -392
- package/dist/{chunk-v5vx6nz9.js → chunk-27bjk35b.js} +1 -1
- package/dist/{chunk-65wc1h38.js → chunk-2ftyzk83.js} +1 -1
- package/dist/chunk-2g3v9qpz.js +1 -0
- package/dist/{chunk-q6abav45.js → chunk-2vrsfb8p.js} +59 -59
- package/dist/{chunk-h6ahwwpa.js → chunk-30p7aff1.js} +1 -1
- package/dist/{chunk-ewwrss2w.js → chunk-3kszepm6.js} +1 -1
- package/dist/{chunk-28tzj187.js → chunk-3y2x6fb6.js} +1 -1
- package/dist/chunk-43gg1wdc.js +1 -0
- package/dist/{chunk-67wy9mm7.js → chunk-447ps2te.js} +2 -2
- package/dist/{chunk-9kj19a8t.js → chunk-4cdk4mds.js} +1 -1
- package/dist/{chunk-nj6kpdte.js → chunk-5034apfz.js} +2 -2
- package/dist/{chunk-28n945me.js → chunk-5bc4hwt9.js} +2 -2
- package/dist/{chunk-t0gm0pn1.js → chunk-5yyp6njq.js} +1 -1
- package/dist/chunk-72wn385d.js +1 -0
- package/dist/{chunk-n5jzmwhy.js → chunk-7eset766.js} +2 -2
- package/dist/{chunk-793wjhvz.js → chunk-7vzz3rsx.js} +5 -5
- package/dist/{chunk-h4k69z1b.js → chunk-80946c9a.js} +1 -1
- package/dist/chunk-8emp6ysb.js +1 -0
- package/dist/chunk-8evyh5t0.js +1 -0
- package/dist/chunk-8hdtssvs.js +1 -0
- package/dist/{chunk-5k8k56f2.js → chunk-8n3jythp.js} +11 -9
- package/dist/{chunk-870szc6v.js → chunk-8sth12hd.js} +1 -1
- package/dist/{chunk-1n4v80hy.js → chunk-9qxch6sy.js} +1 -1
- package/dist/{chunk-09kqfdpa.js → chunk-9ydrwcpy.js} +2 -2
- package/dist/{chunk-p8vpvx07.js → chunk-9yn01a90.js} +1 -1
- package/dist/chunk-a1tt14a2.js +2 -0
- package/dist/{chunk-tsm8rhmd.js → chunk-a731hdwa.js} +1 -1
- package/dist/{chunk-pga8gxtf.js → chunk-a74ynw4t.js} +1 -1
- package/dist/chunk-b36egepz.js +1 -0
- package/dist/{chunk-yjjxv7fn.js → chunk-dxq7462e.js} +2 -2
- package/dist/{chunk-gmpsfkgg.js → chunk-f552hzcx.js} +1 -1
- package/dist/{chunk-ebpg1srd.js → chunk-f6hc7t65.js} +2 -2
- package/dist/{chunk-vx2g1faw.js → chunk-fqxzzsgr.js} +1 -1
- package/dist/{chunk-p2y1zqsb.js → chunk-g0hhqxpg.js} +2 -2
- package/dist/{chunk-ed2hdrwe.js → chunk-gzbb747a.js} +1 -1
- package/dist/{chunk-pdna2qvv.js → chunk-h8w3ahnk.js} +2 -2
- package/dist/{chunk-sbfe9vh3.js → chunk-hmw99nm1.js} +7 -7
- package/dist/chunk-hrtf7dba.js +2 -0
- package/dist/chunk-j7dx054r.js +1 -0
- package/dist/chunk-j9ppeg6v.js +1 -0
- package/dist/chunk-jemb0vwa.js +1 -0
- package/dist/{chunk-6xzk4hsg.js → chunk-m30qwpe9.js} +1 -1
- package/dist/{chunk-v4cxk10d.js → chunk-m70cnaeg.js} +1 -1
- package/dist/{chunk-826xegd8.js → chunk-m8te4s8f.js} +2 -2
- package/dist/chunk-ms0wve9g.js +14 -0
- package/dist/{chunk-n34qsnks.js → chunk-n8qg68y2.js} +1 -1
- package/dist/{chunk-e45r1a8r.js → chunk-pm5ssr7m.js} +2 -2
- package/dist/chunk-r9m3b170.js +1 -0
- package/dist/{chunk-1j39te3t.js → chunk-rt3f4xjz.js} +1 -1
- package/dist/{chunk-9sf1t8gw.js → chunk-s1cch8tt.js} +1 -1
- package/dist/{chunk-tzvb0nd2.js → chunk-sa9fxss4.js} +1 -1
- package/dist/{chunk-e0ft3vwg.js → chunk-ta99scbr.js} +1 -1
- package/dist/chunk-tf1qz4q6.js +1 -0
- package/dist/{chunk-0ef47wgr.js → chunk-tqt5c2f5.js} +2 -2
- package/dist/{chunk-fd0a8h55.js → chunk-ts5xzefm.js} +2 -2
- package/dist/{chunk-g7tphxme.js → chunk-v17q4bsd.js} +2 -2
- package/dist/{chunk-fnmqxhv1.js → chunk-v1k6nvth.js} +1 -1
- package/dist/{chunk-hv8nt7wj.js → chunk-vbjgcn49.js} +1 -1
- package/dist/{chunk-53vh6vpt.js → chunk-wcps5gjm.js} +1 -1
- package/dist/{chunk-av799ng5.js → chunk-xcj23spc.js} +2 -2
- package/dist/chunk-xcy45yxx.js +8 -0
- package/dist/{chunk-fc1gz532.js → chunk-xseh3f4m.js} +2 -2
- package/dist/{chunk-9tpzmy8v.js → chunk-xz7dddaj.js} +1 -1
- package/dist/{chunk-xcq0cehr.js → chunk-xzva8y4e.js} +3 -3
- package/dist/chunk-y0wc0hef.js +10 -0
- package/dist/{chunk-sqk8cnej.js → chunk-yrr9mdjn.js} +2 -2
- package/dist/{chunk-50vwafn5.js → chunk-zfxcef0z.js} +1 -1
- package/dist/{chunk-asgmmaec.js → chunk-zjezws85.js} +2 -2
- package/dist/web/assets/ChatView-BA3kB_z1.js +17 -0
- package/dist/web/assets/CodeBlockHighlighter-B5kcdVCA.js +8 -0
- package/dist/web/assets/FilePreview-BQid6G2-.js +8 -0
- package/dist/web/assets/KanbanBoard-CTR7bMLa.js +1 -0
- package/dist/web/assets/MarkdownRenderer-d7DdyYdx.js +30 -0
- package/dist/web/assets/ScrollArea-D1tPWHKZ.js +1 -0
- package/dist/web/assets/SessionHistorySurface-Cv_jRoJr.js +1 -0
- package/dist/web/assets/SettingsModal-CFa2uCzI.js +5 -0
- package/dist/web/assets/Sidebar-DrRNJOgU.js +1 -0
- package/dist/web/assets/TaskSwitcher-C9AKJrl-.js +1 -0
- package/dist/web/assets/TerminalPanel-BxBGcuB9.js +1 -0
- package/dist/web/assets/archive-DNa9b1YE.js +1 -0
- package/dist/web/assets/arrow-left-BQh8jlfT.js +1 -0
- package/dist/web/assets/calendar-clock-CC7FeYTg.js +1 -0
- package/dist/web/assets/chevron-right-6ZTOJE0p.js +1 -0
- package/dist/web/assets/clock-3-P2q6i6vm.js +1 -0
- package/dist/web/assets/copy-C-KvzjCC.js +1 -0
- package/dist/web/assets/dist-DiQNoDMg.js +11 -0
- package/dist/web/assets/download-CJHn20x1.js +1 -0
- package/dist/web/assets/folder-DmyFehXD.js +1 -0
- package/dist/web/assets/index-BVEiHNFk.css +1 -0
- package/dist/web/assets/index-D-oma3Je.js +11 -0
- package/dist/web/assets/message-square-plus-CKu9bFq3.js +1 -0
- package/dist/web/assets/pause-D2FxNG-w.js +1 -0
- package/dist/web/assets/pencil-D6HI7KC8.js +1 -0
- package/dist/web/assets/play-4jKCDYR-.js +1 -0
- package/dist/web/assets/plus-C4p8E1Nk.js +1 -0
- package/dist/web/assets/preload-helper-BC9Zf9qO.js +1 -0
- package/dist/web/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/web/assets/session-events-CvFfHkFA.js +23 -0
- package/dist/web/assets/settings-fWlqCZ-U.js +1 -0
- package/dist/web/assets/team-qGS2kixH.js +1 -0
- package/dist/web/assets/teamService-DfIvlI2_.js +1 -0
- package/dist/web/assets/terminal-DZkEoiSb.js +1 -0
- package/dist/web/assets/triangle-alert-Detl9fRQ.js +1 -0
- package/dist/web/assets/vendor-radix-CHeA_3Pt.js +41 -0
- package/dist/web/assets/vendor-react-hNfZDUf2.js +9 -0
- package/dist/web/assets/vendor-xterm-CANZO_wP.js +16 -0
- package/dist/web/assets/vendor-xterm-CHOd7Rch.css +1 -0
- package/dist/web/index.html +6 -4
- package/package.json +11 -10
- package/dist/chunk-514va7ce.js +0 -2
- package/dist/chunk-6p0hkf4f.js +0 -1
- package/dist/chunk-867bpjzg.js +0 -1
- package/dist/chunk-983hqzat.js +0 -1
- package/dist/chunk-af0m5227.js +0 -1
- package/dist/chunk-dpg006xj.js +0 -1
- package/dist/chunk-gpnkxh4c.js +0 -1
- package/dist/chunk-hpge30p8.js +0 -8
- package/dist/chunk-mtvbm7xe.js +0 -1
- package/dist/chunk-mys9mmcp.js +0 -1
- package/dist/chunk-new78c3h.js +0 -1
- package/dist/chunk-nng1xbsm.js +0 -10
- package/dist/chunk-pt0y4zrg.js +0 -14
- package/dist/chunk-r4em0ha7.js +0 -1
- package/dist/chunk-rdzbd5vk.js +0 -1
- package/dist/chunk-w6zat4v4.js +0 -1
- package/dist/chunk-wsd3rn0q.js +0 -1
- package/dist/chunk-yzf2jpam.js +0 -2
- package/dist/web/assets/ChatView-lUD-61n0.js +0 -70
- package/dist/web/assets/CodeBlockHighlighter--TbfcBxW.js +0 -8
- package/dist/web/assets/FilePreview-R6OKQPf2.js +0 -55
- package/dist/web/assets/KanbanBoard-BHOKtiv5.js +0 -16
- package/dist/web/assets/MarkdownRenderer-DqxNq8pa.js +0 -30
- package/dist/web/assets/ScrollArea-Dhu0B-zB.js +0 -1
- package/dist/web/assets/SessionHistorySurface-aZvoj3ma.js +0 -6
- package/dist/web/assets/SettingsModal-C7QBnIqa.js +0 -20
- package/dist/web/assets/Sidebar-Bznnq91x.js +0 -31
- package/dist/web/assets/TaskSwitcher-DJczhDRp.js +0 -26
- package/dist/web/assets/TerminalPanel-Vk4p0V3p.js +0 -6
- package/dist/web/assets/archive-0hLYBKQf.js +0 -6
- package/dist/web/assets/arrow-left-CXb6Gqf3.js +0 -6
- package/dist/web/assets/calendar-clock-DiaFI9Jk.js +0 -6
- package/dist/web/assets/chevron-right-CcPXH37D.js +0 -6
- package/dist/web/assets/clock-3-D6VR6gJc.js +0 -6
- package/dist/web/assets/copy-C3eUAQgp.js +0 -6
- package/dist/web/assets/download-DHvS9tI3.js +0 -6
- package/dist/web/assets/external-link-BDVaEuqY.js +0 -11
- package/dist/web/assets/folder-B80Ac6rr.js +0 -11
- package/dist/web/assets/index-B5mUEr6D.js +0 -11
- package/dist/web/assets/index-VwIiNjc8.css +0 -1
- package/dist/web/assets/index-YqughEZk.js +0 -211
- package/dist/web/assets/message-square-plus-D15quyPH.js +0 -21
- package/dist/web/assets/pause-BjMlj6Bx.js +0 -6
- package/dist/web/assets/pencil-BMoJvcB7.js +0 -6
- package/dist/web/assets/play-BHh4py3p.js +0 -6
- package/dist/web/assets/plus-DeFz_gQq.js +0 -6
- package/dist/web/assets/session-events-DCHBz9We.js +0 -25
- package/dist/web/assets/settings-CI8xbId2.js +0 -6
- package/dist/web/assets/team-zZ803hH9.js +0 -6
- package/dist/web/assets/teamService-CgLBXgmv.js +0 -1
- package/dist/web/assets/terminal-1WxSJ47E.js +0 -6
- package/dist/web/assets/vendor-radix-D6QrtXqd.js +0 -45
- package/dist/web/assets/vendor-react-DofNRwfy.js +0 -49
- package/dist/web/assets/vendor-xterm-9CEnUXvW.css +0 -32
- package/dist/web/assets/vendor-xterm-DuYZoU4T.js +0 -49
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{r as n,e as Qe,g as Kt,j as e}from"./vendor-react-DofNRwfy.js";import{c as ht,u as ge,t as Me,j as R,A as Ue,L as ne,$ as ea,C as gt,a2 as q,D as $e,e as Ie,a3 as Je,g as Ke,X as He,a4 as ta,a5 as aa,o as _t,a6 as sa,a as Le,Y as Ut,a7 as Pe,T as ze,a8 as bt,P as na,w as ra,E as la,a9 as oa,aa as ia}from"./index-YqughEZk.js";import{_ as ie,j as se,k as ke,l as ct,m as ut,n as zt}from"./vendor-radix-D6QrtXqd.js";import{P as We}from"./plus-DeFz_gQq.js";import{E as jt,A as Ht}from"./external-link-BDVaEuqY.js";import{D as mt}from"./download-DHvS9tI3.js";import{S as da}from"./ScrollArea-Dhu0B-zB.js";import{C as ca}from"./calendar-clock-DiaFI9Jk.js";import{P as ua}from"./play-BHh4py3p.js";import{P as xt}from"./pencil-BMoJvcB7.js";import{A as ma,t as rt}from"./team-zZ803hH9.js";import{a0 as xa}from"./session-events-DCHBz9We.js";import{A as pa}from"./arrow-left-CXb6Gqf3.js";/**
|
|
2
|
-
* @license lucide-react v0.300.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const fa=ht("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
|
|
7
|
-
* @license lucide-react v0.300.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const ha=ht("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
12
|
-
* @license lucide-react v0.300.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const ga=ht("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2v0a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12v0a2 2 0 0 1-2-2V7",key:"jon5kx"}]]);var ba=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)}},Gt=function(t){return typeof t=="function"},Ne=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=ba(n.useEffect);var qt=function(t,a){var s=a.manual,l=a.ready,r=l===void 0?!0:l,i=a.defaultParams,f=i===void 0?[]:i,g=a.refreshDeps,h=g===void 0?[]:g,c=a.refreshDepsAction,j=n.useRef(!1);return j.current=!1,at(function(){!s&&r&&(j.current=!0,t.run.apply(t,ie([],se(f),!1)))},[r]),at(function(){j.current||s||(j.current=!0,c?c():t.refresh())},ie([],se(h),!1)),{onBefore:function(){if(!r)return{stopNow:!0}}}};qt.onInit=function(t){var a=t.ready,s=a===void 0?!0:a,l=t.manual;return{loading:!l&&s}};function pt(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 Wt=function(t,a){var s=n.useRef({deps:a,obj:void 0,initialized:!1}).current;return(s.initialized===!1||!pt(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,va=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}))},ka=function(t){return Xe.get(t)},Ze=new Map,ja=function(t){return Ze.get(t)},ya=function(t,a){Ze.set(t,a),a.then(function(s){return Ze.delete(t),s}).catch(function(){Ze.delete(t)})},De={},Ea=function(t,a){De[t]&&De[t].forEach(function(s){return s(a)})},lt=function(t,a){return De[t]||(De[t]=[]),De[t].push(a),function(){var l=De[t].indexOf(a);De[t].splice(l,1)}},Na=function(t,a){var s=a.cacheKey,l=a.cacheTime,r=l===void 0?5*60*1e3:l,i=a.staleTime,f=i===void 0?0:i,g=a.setCache,h=a.getCache,c=n.useRef(void 0),j=n.useRef(void 0),u=function(y,m){g?g(m):va(y,r,m),Ea(y,m.data)},b=function(y,m){return m===void 0&&(m=[]),h?h(m):ka(y)};return Wt(function(){if(s){var y=b(s);y&&Object.hasOwnProperty.call(y,"data")&&(t.state.data=y.data,t.state.params=y.params,(f===-1||Date.now()-y.time<=f)&&(t.state.loading=!1)),c.current=lt(s,function(m){t.setState({data:m})})}},[]),Ye(function(){var y;(y=c.current)===null||y===void 0||y.call(c)}),s?{onBefore:function(y){var m=b(s,y);return!m||!Object.hasOwnProperty.call(m,"data")?{}:f===-1||Date.now()-m.time<=f?{loading:!1,data:m==null?void 0:m.data,error:void 0,returnNow:!0}:{data:m==null?void 0:m.data,error:void 0}},onRequest:function(y,m){var A=ja(s);return A&&A!==j.current?{servicePromise:A}:(A=y.apply(void 0,ie([],se(m),!1)),j.current=A,ya(s,A),{servicePromise:A})},onSuccess:function(y,m){var A;s&&((A=c.current)===null||A===void 0||A.call(c),u(s,{data:y,params:m,time:Date.now()}),c.current=lt(s,function(C){t.setState({data:C})}))},onMutate:function(y){var m;s&&((m=c.current)===null||m===void 0||m.call(c),u(s,{data:y,params:t.state.params,time:Date.now()}),c.current=lt(s,function(A){t.setState({data:A})}))}}:{}};function wa(t){var a=typeof t;return t!=null&&(a=="object"||a=="function")}var vt=wa,Ca=typeof Qe=="object"&&Qe&&Qe.Object===Object&&Qe,Aa=Ca,Sa=Aa,Fa=typeof self=="object"&&self&&self.Object===Object&&self,Pa=Sa||Fa||Function("return this")(),Jt=Pa,Ba=Jt,Ta=function(){return Ba.Date.now()},Ma=Ta,Ra=/\s/;function Oa(t){for(var a=t.length;a--&&Ra.test(t.charAt(a)););return a}var Da=Oa,La=Da,$a=/^\s+/;function Ia(t){return t&&t.slice(0,La(t)+1).replace($a,"")}var Ka=Ia,_a=Jt,Ua=_a.Symbol,Yt=Ua,yt=Yt,Vt=Object.prototype,za=Vt.hasOwnProperty,Ha=Vt.toString,qe=yt?yt.toStringTag:void 0;function Ga(t){var a=za.call(t,qe),s=t[qe];try{t[qe]=void 0;var l=!0}catch{}var r=Ha.call(t);return l&&(a?t[qe]=s:delete t[qe]),r}var qa=Ga,Wa=Object.prototype,Ja=Wa.toString;function Ya(t){return Ja.call(t)}var Va=Ya,Et=Yt,Qa=qa,Xa=Va,Za="[object Null]",es="[object Undefined]",Nt=Et?Et.toStringTag:void 0;function ts(t){return t==null?t===void 0?es:Za:Nt&&Nt in Object(t)?Qa(t):Xa(t)}var as=ts;function ss(t){return t!=null&&typeof t=="object"}var ns=ss,rs=as,ls=ns,os="[object Symbol]";function is(t){return typeof t=="symbol"||ls(t)&&rs(t)==os}var ds=is,cs=Ka,wt=vt,us=ds,Ct=NaN,ms=/^[-+]0x[0-9a-f]+$/i,xs=/^0b[01]+$/i,ps=/^0o[0-7]+$/i,fs=parseInt;function hs(t){if(typeof t=="number")return t;if(us(t))return Ct;if(wt(t)){var a=typeof t.valueOf=="function"?t.valueOf():t;t=wt(a)?a+"":a}if(typeof t!="string")return t===0?t:+t;t=cs(t);var s=xs.test(t);return s||ps.test(t)?fs(t.slice(2),s?2:8):ms.test(t)?Ct:+t}var gs=hs,bs=vt,ot=Ma,At=gs,vs="Expected a function",ks=Math.max,js=Math.min;function ys(t,a,s){var l,r,i,f,g,h,c=0,j=!1,u=!1,b=!0;if(typeof t!="function")throw new TypeError(vs);a=At(a)||0,bs(s)&&(j=!!s.leading,u="maxWait"in s,i=u?ks(At(s.maxWait)||0,a):i,b="trailing"in s?!!s.trailing:b);function y(P){var O=l,w=r;return l=r=void 0,c=P,f=t.apply(w,O),f}function m(P){return c=P,g=setTimeout(B,a),j?y(P):f}function A(P){var O=P-h,w=P-c,k=a-O;return u?js(k,i-w):k}function C(P){var O=P-h,w=P-c;return h===void 0||O>=a||O<0||u&&w>=i}function B(){var P=ot();if(C(P))return D(P);g=setTimeout(B,A(P))}function D(P){return g=void 0,b&&l?y(P):(l=r=void 0,f)}function N(){g!==void 0&&clearTimeout(g),c=0,l=h=r=g=void 0}function S(){return g===void 0?f:D(ot())}function z(){var P=ot(),O=C(P);if(l=arguments,r=this,h=P,O){if(g===void 0)return m(h);if(u)return clearTimeout(g),g=setTimeout(B,a),y(h)}return g===void 0&&(g=setTimeout(B,a)),f}return z.cancel=N,z.flush=S,z}var Qt=ys;const Xt=Kt(Qt);var Es=function(t,a){var s=a.debounceWait,l=a.debounceLeading,r=a.debounceTrailing,i=a.debounceMaxWait,f=n.useRef(void 0),g=n.useMemo(function(){var h={};return l!==void 0&&(h.leading=l),r!==void 0&&(h.trailing=r),i!==void 0&&(h.maxWait=i),h},[l,r,i]);return n.useEffect(function(){if(s){var h=t.runAsync.bind(t);return f.current=Xt(function(c){c()},s,g),t.runAsync=function(){for(var c=[],j=0;j<arguments.length;j++)c[j]=arguments[j];return new Promise(function(u,b){var y;(y=f.current)===null||y===void 0||y.call(f,function(){h.apply(void 0,ie([],se(c),!1)).then(u).catch(b)})})},function(){var c;(c=f.current)===null||c===void 0||c.cancel(),t.runAsync=h}}},[s,g]),s?{onCancel:function(){var h;(h=f.current)===null||h===void 0||h.cancel()}}:{}},Ns=function(t,a){var s=a.loadingDelay,l=a.ready,r=n.useRef(void 0);if(!s)return{};var i=function(){r.current&&clearTimeout(r.current)};return{onBefore:function(){return i(),l!==!1&&(r.current=setTimeout(function(){t.setState({loading:!0})},s)),{loading:!1}},onFinally:function(){i()},onCancel:function(){i()}}},Ve=!!(typeof window<"u"&&window.document&&window.document.createElement);function kt(){return Ve?document.visibilityState!=="hidden":!0}var et=new Set;function ws(t){return et.add(t),function(){et.has(t)&&et.delete(t)}}if(Ve){var Cs=function(){kt()&&et.forEach(function(t){return t()})};window.addEventListener("visibilitychange",Cs,!1)}var As=function(t,a){var s=a.pollingInterval,l=a.pollingWhenHidden,r=l===void 0?!0:l,i=a.pollingErrorRetryCount,f=i===void 0?-1:i,g=n.useRef(void 0),h=n.useRef(void 0),c=n.useRef(0),j=function(){var u;g.current&&clearTimeout(g.current),(u=h.current)===null||u===void 0||u.call(h)};return at(function(){s||j()},[s]),s?{onBefore:function(){j()},onError:function(){c.current+=1},onSuccess:function(){c.current=0},onFinally:function(){f===-1||f!==-1&&c.current<=f?g.current=setTimeout(function(){!r&&!kt()?h.current=ws(function(){t.refresh()}):t.refresh()},s):c.current=0},onCancel:function(){j()}}:{}};function Ss(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 Fs=function(){return Ve&&typeof navigator.onLine<"u"?navigator.onLine:!0},tt=new Set;function Ps(t){return tt.add(t),function(){tt.has(t)&&tt.delete(t)}}if(Ve){var St=function(){!kt()||!Fs()||tt.forEach(function(t){return t()})};window.addEventListener("visibilitychange",St,!1),window.addEventListener("focus",St,!1)}var Bs=function(t,a){var s=a.refreshOnWindowFocus,l=a.focusTimespan,r=l===void 0?5e3:l,i=n.useRef(void 0),f=function(){var g;(g=i.current)===null||g===void 0||g.call(i)};return n.useEffect(function(){if(s){var g=Ss(t.refresh.bind(t),r);i.current=Ps(function(){g()})}return function(){f()}},[s,r]),Ye(function(){f()}),{}},Ts=function(t,a){var s=a.retryInterval,l=a.retryCount,r=n.useRef(void 0),i=n.useRef(0),f=n.useRef(!1);return l?{onBefore:function(){f.current||(i.current=0),f.current=!1,r.current&&clearTimeout(r.current)},onSuccess:function(){i.current=0},onError:function(){if(i.current+=1,l===-1||i.current<=l){var g=s??Math.min(1e3*Math.pow(2,i.current),3e4);r.current=setTimeout(function(){f.current=!0,t.refresh()},g)}else i.current=0},onCancel:function(){i.current=0,r.current&&clearTimeout(r.current)}}:{}},Ms=Qt,Rs=vt,Os="Expected a function";function Ds(t,a,s){var l=!0,r=!0;if(typeof t!="function")throw new TypeError(Os);return Rs(s)&&(l="leading"in s?!!s.leading:l,r="trailing"in s?!!s.trailing:r),Ms(t,a,{leading:l,maxWait:a,trailing:r})}var Ls=Ds;const $s=Kt(Ls);var Is=function(t,a){var s=a.throttleWait,l=a.throttleLeading,r=a.throttleTrailing,i=n.useRef(void 0),f={};return l!==void 0&&(f.leading=l),r!==void 0&&(f.trailing=r),n.useEffect(function(){if(s){var g=t.runAsync.bind(t);return i.current=$s(function(h){h()},s,f),t.runAsync=function(){for(var h=[],c=0;c<arguments.length;c++)h[c]=arguments[c];return new Promise(function(j,u){var b;(b=i.current)===null||b===void 0||b.call(i,function(){g.apply(void 0,ie([],se(h),!1)).then(j).catch(u)})})},function(){var h;t.runAsync=g,(h=i.current)===null||h===void 0||h.cancel()}}},[s,l,r]),s?{onCancel:function(){var g;(g=i.current)===null||g===void 0||g.cancel()}}:{}},Ks=function(t){n.useEffect(function(){var a=t==null?void 0:t();if(!(a&&typeof a=="object"&&typeof a.then=="function"))return a},[])},_s=function(){var t=se(n.useState({}),2),a=t[1];return Ne(function(){return a({})})},Us=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(i){var f;return(f=i[a])===null||f===void 0?void 0:f.call.apply(f,ie([i],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 ct(this,void 0,void 0,function(){var l,r,i,f,g,h,c,j,u,b,y,m,A,C,B,D,N,S,z,P,O;return ut(this,function(w){switch(w.label){case 0:if(this.count+=1,l=this.count,r=this.runPluginHandler("onBefore",a),i=r.stopNow,f=i===void 0?!1:i,g=r.returnNow,h=g===void 0?!1:g,c=zt(r,["stopNow","returnNow"]),f)return[2,Promise.resolve(c.data)];if(this.setState(ke({loading:!0,params:a},c)),h)return[2,Promise.resolve(c.data)];(A=(m=this.options).onBefore)===null||A===void 0||A.call(m,a),w.label=1;case 1:return w.trys.push([1,3,,4]),j=this.runPluginHandler("onRequest",this.serviceRef.current,a).servicePromise,j||(j=(y=this.serviceRef).current.apply(y,ie([],se(a),!1))),[4,j];case 2:return u=w.sent(),l!==this.count?[2,new Promise(function(){})]:(this.setState({data:u,error:void 0,loading:!1}),(B=(C=this.options).onSuccess)===null||B===void 0||B.call(C,u,a),this.runPluginHandler("onSuccess",u,a),(N=(D=this.options).onFinally)===null||N===void 0||N.call(D,a,u,void 0),l===this.count&&this.runPluginHandler("onFinally",a,u,void 0),[2,u]);case 3:if(b=w.sent(),l!==this.count)return[2,new Promise(function(){})];throw this.setState({error:b,loading:!1}),(z=(S=this.options).onError)===null||z===void 0||z.call(S,b,a),this.runPluginHandler("onError",b,a),(O=(P=this.options).onFinally)===null||O===void 0||O.call(P,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=Gt(a)?a(this.state.data):a;this.runPluginHandler("onMutate",s),this.setState({data:s})},t}();function zs(t,a,s){a===void 0&&(a={}),s===void 0&&(s=[]);var l=a.manual,r=l===void 0?!1:l,i=a.ready,f=i===void 0?!0:i,g=zt(a,["manual","ready"]),h=ke({manual:r,ready:f},g),c=nt(t),j=_s(),u=Wt(function(){var b=s.map(function(y){var m;return(m=y==null?void 0:y.onInit)===null||m===void 0?void 0:m.call(y,h)}).filter(Boolean);return new Us(c,h,j,Object.assign.apply(Object,ie([{}],se(b),!1)))},[]);return u.options=h,u.pluginImpls=s.map(function(b){return b(u,h)}),Ks(function(){if(!r&&f){var b=u.state.params||a.defaultParams||[];u.run.apply(u,ie([],se(b),!1))}}),Ye(function(){u.cancel()}),{loading:u.state.loading,data:u.state.data,error:u.state.error,params:u.state.params||[],cancel:Ne(u.cancel.bind(u)),refresh:Ne(u.refresh.bind(u)),refreshAsync:Ne(u.refreshAsync.bind(u)),run:Ne(u.run.bind(u)),runAsync:Ne(u.runAsync.bind(u)),mutate:Ne(u.mutate.bind(u))}}function _e(t,a,s){return zs(t,a,ie(ie([],se([]),!1),[Es,Ns,As,Bs,Is,qt,Na,Ts],!1))}function st(t,a){if(Ve){if(!t)return a;var s;return Gt(t)?s=t():"current"in t?s=t.current:s=t,s}}var Hs=function(t){var a=function(s,l,r){var i=n.useRef(!1),f=n.useRef([]),g=n.useRef([]),h=n.useRef(void 0);t(function(){var c,j=Array.isArray(r)?r:[r],u=j.map(function(b){return st(b)});if(!i.current){i.current=!0,f.current=u,g.current=l,h.current=s();return}(u.length!==f.current.length||!pt(f.current,u)||!pt(g.current,l))&&((c=h.current)===null||c===void 0||c.call(h),f.current=u,g.current=l,h.current=s())}),Ye(function(){var c;(c=h.current)===null||c===void 0||c.call(h),i.current=!1})};return a},Gs=Hs(n.useEffect);function qs(){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}qs()||(global.Date=Date);function Ws(t,a){var s,l=nt(t),r=(s=a==null?void 0:a.wait)!==null&&s!==void 0?s:1e3,i=n.useMemo(function(){return Xt(function(){for(var f=[],g=0;g<arguments.length;g++)f[g]=arguments[g];return l.current.apply(l,ie([],se(f),!1))},r,a)},[]);return Ye(function(){i.cancel()}),{run:i,cancel:i.cancel,flush:i.flush}}function Js(t,a,s){s===void 0&&(s={});var l=s.enable,r=l===void 0?!0:l,i=nt(a);Gs(function(){if(r){var f=st(s.target,window);if(f!=null&&f.addEventListener){var g=function(c){return i.current(c)},h=Array.isArray(t)?t:[t];return h.forEach(function(c){f.addEventListener(c,g,{capture:s.capture,once:s.once,passive:s.passive})}),function(){h.forEach(function(c){f.removeEventListener(c,g,{capture:s.capture})})}}}},[t,s.capture,s.once,s.passive,r],s.target)}var Ys=function(t){return t===document||t===document.documentElement||t===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):t.scrollTop},Ft=function(t){return t.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},Vs=function(t){return t.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},Qs=function(t,a){a===void 0&&(a={});var s=a.target,l=a.isNoMore,r=a.threshold,i=r===void 0?100:r,f=a.direction,g=f===void 0?"bottom":f,h=a.reloadDeps,c=h===void 0?[]:h,j=a.manual,u=a.onBefore,b=a.onSuccess,y=a.onError,m=a.onFinally,A=se(n.useState(),2),C=A[0],B=A[1],D=se(n.useState(!1),2),N=D[0],S=D[1],z=g==="top",P=n.useRef(void 0),O=n.useRef(0),w=n.useMemo(function(){return l?l(C):!1},[C]),k=_e(function(L){return ct(void 0,void 0,void 0,function(){var V;return ut(this,function(E){switch(E.label){case 0:return[4,t(L)];case 1:return V=E.sent(),[2,{currentData:V,lastData:L}]}})})},{manual:j,onFinally:function(L,V,E){S(!1),m==null||m(V==null?void 0:V.currentData,E)},onBefore:function(){return u==null?void 0:u()},onSuccess:function(L){var V,E,M;L.lastData?B(ke(ke({},L.currentData),{list:z?ie(ie([],se(L.currentData.list),!1),se((E=L.lastData.list)!==null&&E!==void 0?E:[]),!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((V=L.currentData.list)!==null&&V!==void 0?V:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(z){var Z=st(s);if(Z=Z===document?document.documentElement:Z,Z){var pe=Ft(Z);Z.scrollTo(0,pe-O.current)}}else Q()})}),b==null||b(L.currentData)},onError:function(L){return y==null?void 0:y(L)}}),T=k.loading,X=k.error,J=k.run,I=k.runAsync,te=k.cancel,Y=Ne(function(){w||(S(!0),J(C))}),ee=function(L){return ct(void 0,void 0,void 0,function(){var V;return ut(this,function(E){switch(E.label){case 0:return[4,I(L)];case 1:return V=E.sent(),[2,V.currentData]}})})},_=Ne(function(){return w?Promise.reject():(S(!0),ee(C))}),v=function(){return S(!1),J()},K=function(){return S(!1),ee()},Q=function(){var L=st(s);if(L){var V=L===document?document.documentElement:L,E=Ys(V),M=Ft(V),Z=Vs(V);z?(P.current!==void 0&&P.current>E&&E<=i&&Y(),P.current=E,O.current=M-E):M-E<=Z+i&&Y()}};return Js("scroll",function(){T||N||Q()},{target:s}),at(function(){J()},ie([],se(c),!1)),{data:C,loading:!N&&T,error:X,loadingMore:N,noMore:w,loadMore:Y,loadMoreAsync:_,reload:Ne(v),reloadAsync:Ne(K),mutate:B,cancel:te}};const Pt={connected:"text-[#16A34A] dark:text-[#22C55E]",connecting:"text-[#2563eb] dark:text-[#3b82f6]",reconnecting:"text-[#2563eb] dark:text-[#60a5fa]",offline:"text-[#f59e0b]",error:"text-[#ef4444]"},Xs={connected:"mcp.status.connected",connecting:"mcp.status.connecting",reconnecting:"mcp.status.reconnecting",offline:"mcp.status.offline",error:"mcp.status.error"},Zs={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"},en={Official:"mcp.catalog.tag.official",Popular:"mcp.catalog.tag.popular",Community:"mcp.catalog.tag.community"},Bt=20,tn=["debug","info","notice","warning","error","critical","alert","emergency"],Tt=(t,a)=>t.status!=="reconnecting"||!t.recovery?a(Xs[t.status]):a("mcp.status.recoveringAttempt",{attempt:t.recovery.attempt,max:t.recovery.maxAttempts}),an=async()=>q("/mcp"),sn=async t=>q(`/mcp/${encodeURIComponent(t)}/logs?limit=20`),nn="mcp server @modelcontextprotocol",rn=3,Zt=t=>{var a;return((a=t.split("/").pop())==null?void 0:a.replace(/^server-/,""))||t},ln=async(t,a)=>{const s=t&&t.length>=rn?t:nn,l=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(s)}&size=${Bt}&from=${a}`,r=await q(l);return{list:r.objects.map(i=>i.package),total:r.total,hasMore:a+Bt<r.total}};function on({active:t}){const a=ge(),[s,l]=n.useState("installed"),[r,i]=n.useState(!1),[f,g]=n.useState(null),[h,c]=n.useState(""),[j,u]=n.useState(null),[b,y]=n.useState(null),[m,A]=n.useState(null),[C,B]=n.useState(null),[D,N]=n.useState(null),[S,z]=n.useState(""),[P,O]=n.useState(null),[w,k]=n.useState(!1),[T,X]=n.useState(null),[J,I]=n.useState(null),[te,Y]=n.useState(""),[ee,_]=n.useState(""),[v,K]=n.useState(null),[Q,L]=n.useState(null),V=n.useRef(null),{run:E}=Ws(d=>{_(d)},{wait:500}),{data:M=[],loading:Z,error:pe,run:Se,runAsync:le}=_e(an,{refreshDeps:[t],ready:t,onSuccess:d=>{d.length>0&&!f&&g(d[0].id)}}),{data:he,loading:we,error:ce,runAsync:Ce}=_e(sn,{manual:!0}),{data:de,loading:re,loadingMore:p,noMore:U,error:ae,reload:oe}=Qs(async d=>{var G;const W=((G=d==null?void 0:d.list)==null?void 0:G.length)??0;return ln(ee,W)},{target:V,isNoMore:d=>!(d!=null&&d.hasMore),reloadDeps:[ee],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(),i(!1),L(null),K(null)},onError:()=>{K(null)}}),Fe=n.useMemo(()=>{const d=h.trim().toLowerCase();return d?M.filter(W=>[W.name,W.endpoint,W.description].some(G=>G.toLowerCase().includes(d))):M},[h,M]),F=n.useMemo(()=>Fe.find(d=>d.id===f)??Fe[0],[Fe,f]),Be=n.useMemo(()=>{if(!F)return[];const d=(F.prompts??[]).flatMap(G=>G.arguments.map(ye=>({key:`prompt:${G.name}:${ye.name}`,label:`${G.name}.${ye.name}`,reference:{type:"prompt",name:G.name},argument:ye.name}))),W=(F.resourceTemplates??[]).flatMap(G=>(G.variables??[]).map(ye=>({key:`resource:${G.uriTemplate}:${ye}`,label:`${G.uriTemplate} · ${ye}`,reference:{type:"resource",uri:G.uriTemplate},argument:ye})));return[...d,...W]},[F]),ve=Be.find(d=>d.key===D)??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"))&&y(null)},[b,M]),n.useEffect(()=>{!t||s!=="installed"||!F||Ce(F.name).catch(()=>{})},[t,Ce,F,s]);const Re=async(d,W)=>{A({type:d,name:W}),u(null);try{const G=d==="delete"?"":`/${d}`;await q(`/mcp/${encodeURIComponent(W)}${G}`,{method:d==="delete"?"DELETE":"POST"}),await le(),d==="delete"&&(I(null),g(null))}catch(G){u(G instanceof Error?G.message:a(d==="connect"?"mcp.error.connectFailed":d==="disconnect"?"mcp.error.disconnectFailed":"mcp.error.deleteFailed"))}finally{A(null)}},x=async(d,W)=>{A({type:d,name:W.name}),u(null);try{if(d==="login"){const G=await q(`/mcp/${encodeURIComponent(W.name)}/oauth/login`,{method:"POST"});y({serverName:W.name,url:G.authorizationUrl})}else await q(`/mcp/${encodeURIComponent(W.name)}/oauth/logout`,{method:"POST"}),y(null);await le()}catch(G){u(G instanceof Error?G.message:a(d==="login"?"mcp.error.loginFailed":"mcp.error.logoutFailed"))}finally{A(null)}},ue=async(d,W)=>{B(W),u(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(G){u(G instanceof Error?G.message:a("mcp.error.loggingLevelFailed"))}finally{B(null)}},Ee=async d=>{if(ve){k(!0),X(null),O(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}})});O(W)}catch(W){X(W instanceof Error?W.message:a("mcp.error.completionFailed"))}finally{k(!1)}}},je=n.useMemo(()=>new Set(M.map(d=>d.name.toLowerCase())),[M]),o=d=>{L(d)},$=d=>d.startsWith("@modelcontextprotocol/"),H=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:Se,"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:Z,children:e.jsx(Me,{className:R("h-4 w-4",Z&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>i(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[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(Mt,{active:s==="installed",onClick:()=>l("installed"),children:a("mcp.tab.installed",{count:M.length})}),e.jsx(Mt,{active:s==="catalog",onClick:()=>{l("catalog"),de||oe()},children:a("mcp.tab.catalog")})]}),j&&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:j}),e.jsx("button",{type:"button",onClick:()=>u(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:h,onChange:d=>c(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:[Z&&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&&!Z&&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:Se,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("mcp.action.retry")})]}),!pe&&!Z&&Fe.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(h?"mcp.servers.noMatch":"mcp.servers.none")}),Fe.map(d=>e.jsxs("button",{onClick:()=>{g(d.id),I(null),u(null),N(null),z(""),O(null),X(null)},className:R("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",d.id===(F==null?void 0:F.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:R("text-[11px] font-mono font-semibold",Pt[d.status]),children:Tt(d,a)})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:d.endpoint})]},d.id))]})]}),F?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:F.name}),e.jsx("span",{className:R("text-xs font-mono font-semibold",Pt[F.status]),children:Tt(F,a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:F.description}),F.error&&e.jsx("p",{className:"text-[12px] font-mono text-[#ef4444]",children:a("mcp.server.errorLabel",{error:F.error})}),F.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 ",F.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:F.instructions.text??a("mcp.instructions.detailsOmittedByPolicy")}),(F.instructions.truncated||F.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:F.instructions.detailsOmitted?a("mcp.instructions.detailsOmitted"):a("mcp.instructions.truncated")})]}),F.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:F.tasks.enabled?a("mcp.tasks.summary",{count:F.tasks.maxTasksPerSession,interval:F.tasks.pollIntervalMs}):a("mcp.tasks.disabledByDefault")})]}),e.jsx("span",{className:R("text-[10px] font-mono font-semibold uppercase",F.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:F.tasks.enabled?a("mcp.tasks.enabled"):a("mcp.tasks.disabled")})]}),F.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:F.oauthStatus==="authorizing"?"status":void 0,className:R("text-[11px] font-mono",F.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":F.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a(Zs[F.oauthStatus])})]}),F.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void x("logout",F),disabled:m!==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:(m==null?void 0:m.type)==="logout"?a("mcp.oauth.signingOut"):a("mcp.oauth.signOut")}):F.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)===F.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",F),disabled:m!==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")})]}):F.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void x("login",F),disabled:m!==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:(m==null?void 0:m.type)==="login"?a("mcp.oauth.opening"):a("mcp.oauth.authorize")})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[F.status==="connected"||F.status==="reconnecting"?e.jsx("button",{onClick:()=>void Re("disconnect",F.name),disabled:m!==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:(m==null?void 0:m.type)==="disconnect"&&m.name===F.name?a("mcp.action.disconnecting"):F.status==="reconnecting"?a("mcp.action.stopRecovery"):a("mcp.action.disconnect")}):e.jsx("button",{onClick:()=>void Re("connect",F.name),disabled:m!==null||F.oauthEnabled&&F.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:(m==null?void 0:m.type)==="connect"&&m.name===F.name?a("mcp.action.connecting"):F.oauthEnabled&&F.oauthStatus!=="authenticated"?a("mcp.action.authorizeFirst"):a("mcp.action.connect")}),e.jsx("button",{onClick:()=>I(F.name),disabled:m!==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")})]}),J===F.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("mcp.server.deleteAria",{name:F.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:()=>I(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 Re("delete",F.name),disabled:m!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(m==null?void 0:m.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:F.tools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:F.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tools.none")}):F.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")}),F.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.connectPrompt")}):F.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:()=>{N(d.key),O(null),X(null)},className:R("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=>z(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 Ee(F),disabled:w,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(w?"mcp.completion.completing":"mcp.completion.complete")})]}),T&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:T}),P&&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:P.values.length>0?P.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 ",P.sha256,P.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:F.name}),onClick:()=>void Ce(F.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(Me,{className:R("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:tn.map(d=>{var W,G;return e.jsx("button",{type:"button",onClick:()=>void ue(F,d),disabled:F.status!=="connected"||C!==null,"aria-pressed":(((W=F.logging)==null?void 0:W.level)??"warning")===d,className:R("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((G=F.logging)==null?void 0:G.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:C===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:F.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:R("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||F.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(ea,{className:"h-3.5 w-3.5 text-[#9CA3AF] dark:text-[#71717a]"}),e.jsx("input",{type:"text","aria-label":a("mcp.catalog.searchAria"),value:te,onChange:d=>{Y(d.target.value),E(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:V,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(Zt(d.name).toLowerCase()),G=v===d.name,ye=H(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:R("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(en[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(jt,{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(gt,{className:"w-3 h-3"}),a("mcp.catalog.installed")]}):e.jsxs("button",{onClick:()=>o(d),disabled:G,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(mt,{className:R("h-3 w-3",G&&"animate-pulse")}),a(G?"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")})]}),p&&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"})}),U&&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(jt,{className:"w-3 h-3"})]})]})]})]})}),e.jsx(dn,{open:r,onOpenChange:i,onAdd:xe,saving:fe,error:(be==null?void 0:be.message)??null}),Q&&e.jsx(cn,{pkg:Q,onClose:()=>L(null),installing:fe,error:(be==null?void 0:be.message)??null,onInstall:d=>(K(Q.name),xe(d))})]})}function Mt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:R("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 dn({open:t,onOpenChange:a,onAdd:s,saving:l,error:r}){const i=ge(),[f,g]=n.useState("form"),[h,c]=n.useState(""),[j,u]=n.useState(""),[b,y]=n.useState(""),[m,A]=n.useState(null),[C,B]=n.useState(`{
|
|
17
|
-
"name": "my-server",
|
|
18
|
-
"command": "npx",
|
|
19
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
20
|
-
}`);n.useEffect(()=>{t&&A(null)},[t]);const D=async()=>{if(A(null),f==="json"){let N;try{N=JSON.parse(C)}catch{A(i("mcp.add.invalidJson"));return}await s(N).catch(()=>{})}else{if(!h||!j){A(i("mcp.add.nameCommandRequired"));return}await s({name:h,command:j,args:b.split(" ").filter(Boolean)}).catch(()=>{})}};return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:N=>Je("[data-mcp-add-server-trigger]",N),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:i("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:i("mcp.add.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":i("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(Rt,{active:f==="form",onClick:()=>g("form"),children:i("mcp.add.modeForm")}),e.jsx(Rt,{active:f==="json",onClick:()=>g("json"),children:"JSON"})]}),f==="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:i("mcp.add.jsonConfig")}),e.jsx("textarea",{"aria-label":i("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:C,onChange:N=>B(N.target.value)})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:i("mcp.add.serverName")}),e.jsx("input",{"aria-label":i("mcp.add.serverName"),type:"text",value:h,onChange:N=>c(N.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:i("mcp.add.command")}),e.jsx("input",{"aria-label":i("mcp.add.commandAria"),type:"text",value:j,onChange:N=>u(N.target.value),placeholder:"npx",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:i("mcp.add.argsLabel")}),e.jsx("input",{"aria-label":i("mcp.add.argsAria"),type:"text",value:b,onChange:N=>y(N.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem /tmp",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]})]}),(m||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:m||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:i("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void D(),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:i(l?"mcp.add.adding":"mcp.add.submit")})]})]})]})})}function cn({pkg:t,onClose:a,onInstall:s,installing:l,error:r}){const i=ge(),f=Zt(t.name),[g,h]=n.useState(f),[c,j]=n.useState(`-y ${t.name}`),[u,b]=n.useState(null),y=async()=>{if(b(null),!g.trim()){b(i("mcp.install.nameRequired"));return}await s({name:g.trim(),command:"npx",args:c.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:i("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:i("mcp.install.title")}),e.jsx("button",{onClick:a,"aria-label":i("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||i("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:i("mcp.add.serverName")}),e.jsx("input",{"aria-label":i("mcp.add.serverName"),type:"text",value:g,onChange:m=>h(m.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:i("mcp.install.args")}),e.jsx("input",{"aria-label":i("mcp.add.argsAria"),type:"text",value:c,onChange:m=>j(m.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:i("mcp.install.commandPreview",{args:c})})]})]}),(u||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:u||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:i("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void y(),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:i(l?"mcp.catalog.installing":"mcp.catalog.install")})]})]})]})})}function Rt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:R("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 Ae({value:t,onChange:a,options:s,placeholder:l="Select...",disabled:r=!1,className:i,"aria-label":f}){const[g,h]=n.useState(!1),[c,j]=n.useState(-1),u=n.useRef(null),b=s.find(m=>m.value===t);n.useEffect(()=>{if(g){const m=s.findIndex(A=>A.value===t);j(m>=0?m:0)}},[g,s,t]);const y=m=>{if(!r){if(!g){(m.key==="Enter"||m.key===" "||m.key==="ArrowDown")&&(m.preventDefault(),h(!0));return}switch(m.key){case"ArrowDown":m.preventDefault(),j(A=>Math.min(A+1,s.length-1));break;case"ArrowUp":m.preventDefault(),j(A=>Math.max(A-1,0));break;case"Enter":case" ":m.preventDefault(),c>=0&&c<s.length&&(a(s[c].value),h(!1));break;case"Escape":m.preventDefault(),h(!1);break}}};return n.useEffect(()=>{var A;if(!g||c<0)return;const m=(A=u.current)==null?void 0:A.children[c];m==null||m.scrollIntoView({block:"nearest"})},[c,g]),e.jsxs(ta,{open:g,onOpenChange:h,children:[e.jsx(aa,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":g,"aria-haspopup":"listbox","aria-label":f,disabled:r,onKeyDown:y,className:R("field flex items-center justify-between gap-2 text-left",!b&&"text-zinc-400 dark:text-zinc-500",r&&"cursor-not-allowed opacity-50",i),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(sa,{align:"start",sideOffset:4,onKeyDown:y,className:"w-[var(--radix-popover-trigger-width)] max-h-[240px] p-1 overflow-hidden",children:e.jsx(da,{className:"max-h-[232px]",children:e.jsx("div",{ref:u,role:"listbox",children:s.map((m,A)=>e.jsxs("button",{type:"button",role:"option","aria-selected":m.value===t,"data-value":m.value,"data-highlighted":A===c||void 0,onClick:()=>{a(m.value),h(!1)},onMouseEnter:()=>j(A),className:R("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left font-mono text-[13px] outline-none transition-colors",A===c&&"bg-zinc-100 dark:bg-zinc-800",m.value===t&&"text-zinc-900 dark:text-zinc-50 font-medium"),children:[e.jsx(gt,{className:R("h-3.5 w-3.5 shrink-0",m.value===t?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:m.label})]},m.value))})})})]})}const un=[{value:"cron",labelKey:"schedule.trigger.cron"},{value:"interval",labelKey:"schedule.trigger.interval"},{value:"once",labelKey:"schedule.trigger.once"}],mn=[{value:"default",labelKey:"schedule.permission.default"},{value:"autoEdit",labelKey:"schedule.permission.autoEdit"},{value:"yolo",labelKey:"schedule.permission.yolo"},{value:"plan",labelKey:"schedule.permission.plan"}],xn=[{value:"worktree",labelKey:"schedule.isolation.worktree"},{value:"local",labelKey:"schedule.isolation.local"}],pn={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 fn(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 hn(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 it(t){const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString()}function gn({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=Ut(x=>x.configuredModels),i=s??l??new URLSearchParams(window.location.search).get("project")??"",f=Pe(x=>x.schedules),g=Pe(x=>x.isLoading),h=Pe(x=>x.error),c=Pe(x=>x.loadSchedules),j=Pe(x=>x.createSchedule),u=Pe(x=>x.updateSchedule),b=Pe(x=>x.deleteSchedule),y=Pe(x=>x.toggleSchedule),m=Pe(x=>x.runSchedule),[A,C]=n.useState(!1),[B,D]=n.useState("cron"),[N,S]=n.useState(""),[z,P]=n.useState(""),[O,w]=n.useState(""),[k,T]=n.useState(""),[X,J]=n.useState(""),[I,te]=n.useState(""),[Y,ee]=n.useState(""),[_,v]=n.useState("default"),[K,Q]=n.useState("worktree"),[L,V]=n.useState(!1),[E,M]=n.useState(null),[Z,pe]=n.useState(null),[Se,le]=n.useState(null),[he,we]=n.useState(""),[ce,Ce]=n.useState(!0),[de,re]=n.useState(null),p=n.useRef(!1);n.useEffect(()=>{t&&!p.current&&(p.current=!0,c()),t||(p.current=!1)},[t,c]);const U=de??h,ae=E!==null||L,oe=()=>{C(!0),D("cron"),S(""),P(""),w(""),T(""),J(i),te(""),ee(""),v("default"),Q("worktree"),re(null)},xe=()=>{C(!1),re(null)},fe=async()=>{re(null);const x=k.trim();if(!x){re(a("schedule.error.promptRequired"));return}const ue=X.trim();if(!ue){re(a("schedule.error.projectRequired"));return}let Ee;if(B==="cron"){const o=N.trim();if(!o){re(a("schedule.error.cronRequired"));return}Ee={kind:"cron",cron:o}}else if(B==="interval"){const o=fn(z);if(o===null){re(a("schedule.error.invalidInterval"));return}Ee={kind:"interval",intervalMs:o}}else{const o=O?new Date(O):null;if(!o||Number.isNaN(o.getTime())){re(a("schedule.error.runAtRequired"));return}Ee={kind:"once",runAt:o.toISOString()}}const je={prompt:x,projectPath:ue,trigger:Ee,permissionMode:_,isolation:K,enabled:!0};I.trim()&&(je.title=I.trim()),Y.trim()&&(je.modelId=Y.trim()),V(!0);try{await j(je),C(!1)}catch{}finally{V(!1)}},be=async x=>{re(null),M(`run:${x.id}`);try{await m(x.id)}catch{}finally{M(null)}},Fe=async x=>{re(null),M(`toggle:${x.id}`);try{await y(x.id,!x.enabled)}catch{}finally{M(null)}},F=async x=>{const ue=`delete:${x.id}`;if(Z!==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 u(x.id,{prompt:ue,enabled:ce}),le(null)}catch{}finally{M(null)}},Re=x=>x.kind==="cron"?a("schedule.cadence.cron",{expr:x.cron??""}):x.kind==="interval"?a("schedule.cadence.interval",{interval:hn(x.intervalMs??0)}):a("schedule.cadence.once",{time:x.runAt?it(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(ca,{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 c(),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(Me,{className:"h-3.5 w-3.5"}),a("schedule.refresh")]}),e.jsxs("button",{type:"button",onClick:()=>A?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")]})]})]}),U&&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:U}),A&&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:un.map(x=>e.jsx("button",{type:"button",role:"radio","aria-checked":B===x.value,onClick:()=>D(x.value),className:R("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:N,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:z,onChange:x=>P(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:O,onChange:x=>w(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:I,onChange:x=>te(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:k,onChange:x=>T(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:X,onChange:x=>J(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(Ae,{value:Y,onChange:ee,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(Ae,{value:_,onChange:x=>v(x),"aria-label":a("schedule.field.permissionMode"),className:"field mt-1 h-8 px-2 text-[10.5px]",options:mn.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(Ae,{value:K,onChange:x=>Q(x),"aria-label":a("schedule.field.isolation"),className:"field mt-1 h-8 px-2 text-[10.5px]",options:xn.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:[f.map(x=>{const ue=Se===x.id,Ee=x.lastStatus?a(pn[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:Re(x.trigger)}),e.jsx("span",{className:R("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:R("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:R("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:[E===`edit:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(gt,{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?it(x.nextRunAt):a("schedule.never")," · ",a("schedule.lastRun"),":"," ",x.lastRunAt?it(x.lastRunAt):a("schedule.never")," · ",Ee," · ",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:R("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:R("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:E===`run:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(ua,{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(xt,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":a("schedule.deleteAria",{title:x.title||x.prompt}),onClick:()=>void F(x),disabled:ae,className:R("rounded p-1 text-[9px] disabled:opacity-40",Z===`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:E===`delete:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):Z===`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&&f.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:a("schedule.empty")})]})]})}const ft=t=>t?{"x-blade-directory":t}:void 0,bn=async t=>q("/skills",{headers:ft(t)}),vn=async()=>q("/skills/catalog"),Ot={Official:"skills.install.catalog.tag.official",Popular:"skills.install.catalog.tag.popular",Community:"skills.install.catalog.tag.community"};function kn({active:t}){const a=ge(),s=Le(v=>{var K,Q;return((K=v.currentSessionRef)==null?void 0:K.projectPath)??v.selectedProjectPath??((Q=v.taskWorkspaceInfo)==null?void 0:Q.cwd)??null}),[l,r]=n.useState(null),[i,f]=n.useState(""),[g,h]=n.useState(null),[c,j]=n.useState(null),[u,b]=n.useState(null),[y,m]=n.useState(!1),[A,C]=n.useState(!1),[B,D]=n.useState("confirm"),[N,S]=n.useState(null),[z,P]=n.useState(null),{data:O=[],loading:w,error:k,run:T,runAsync:X}=_e(()=>bn(s),{refreshDeps:[t,s],ready:t,onSuccess:v=>{v.length>0&&!l&&r(v[0].id)}}),J=O.filter(v=>v.name.toLowerCase().includes(i.toLowerCase())),I=n.useMemo(()=>O.find(v=>v.id===l)??O[0],[O,l]),te=async(v,K,Q)=>{j({type:v,name:K.name}),h(null);try{await q(v==="delete"?`/skills/${encodeURIComponent(K.name)}`:`/skills/${encodeURIComponent(K.name)}/toggle`,{method:v==="delete"?"DELETE":"POST",headers:{...ft(s),...v==="toggle"?{"Content-Type":"application/json"}:{}},body:v==="toggle"?JSON.stringify({enabled:Q}):void 0}),await X(),v==="delete"&&(b(null),r(null))}catch(L){h(L instanceof Error?L.message:a(v==="delete"?"skills.error.deleteFailed":"skills.error.toggleFailed"))}finally{j(null)}},Y=()=>{m(!0)},ee=v=>{P(v),S(null),D("confirm"),C(!0)},_=async()=>{if(z){D("installing"),S(null);try{const v=await q("/skills/install",{method:"POST",headers:{"Content-Type":"application/json",...ft(s)},body:JSON.stringify(z)});if(v.success===!1)throw new Error(v.error||a("skills.error.installFailed"));await X(),C(!1),m(!1)}catch(v){S(v instanceof Error?v.message:a("skills.error.installFailed")),D("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:Y,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("skills.action.install")]}),e.jsx("button",{onClick:T,"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:w,children:e.jsx(Me,{className:R("h-4 w-4",w&&"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:()=>h(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:i,onChange:v=>f(v.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:[w&&O.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")]}),k&&!w&&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:k.message}),e.jsx("button",{type:"button",onClick:T,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("skills.action.retry")})]}),!k&&J.length===0&&!w&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(i?"skills.installed.noMatch":"skills.installed.empty")}),J.map(v=>e.jsxs("button",{onClick:()=>{r(v.id),b(null),h(null)},className:R("flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",v.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:v.name}),e.jsx("span",{className:R("text-[11px] font-mono font-semibold",v.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:v.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:v.description||a("skills.noDescriptionShort")})]},v.id))]})]}),I?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:I.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",I.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:I.description||a("skills.noDescription")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void te("toggle",I,!I.enabled),disabled:c!==null,className:R("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",I.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]",c&&"opacity-60 cursor-not-allowed"),children:(c==null?void 0:c.type)==="toggle"&&c.name===I.name?a("skills.action.saving"):I.enabled?a("skills.action.disable"):a("skills.action.enable")}),e.jsxs("button",{onClick:()=>b(I.name),disabled:!I.removable||c!==null,title:I.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"}),I.removable?a("skills.uninstall.action"):a("skills.uninstall.managed")]})]}),u===I.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("skills.uninstall.confirmAria",{name:I.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 te("delete",I),disabled:c!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(c==null?void 0:c.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:I.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:I.location})]})]}),I.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:I.capabilities.map(v=>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:v},v))})]}),I.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:I.allowedTools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:I.allowedTools.map(v=>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:v},v))})]})]}):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(jn,{open:y,active:t,installed:O.map(v=>v.name),onOpenChange:m,onInstall:ee}),e.jsx(yn,{open:A,status:B,error:N,onCancel:()=>C(!1),onConfirm:_,onRetry:()=>D("confirm")})]})}function dt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:R("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 jn({open:t,active:a,onOpenChange:s,onInstall:l,installed:r}){const i=ge(),[f,g]=n.useState("catalog"),[h,c]=n.useState(""),[j,u]=n.useState(null),[b,y]=n.useState(""),[m,A]=n.useState(""),{data:C=[],loading:B,error:D,run:N}=_e(vn,{ready:a&&t&&f==="catalog"}),S=C.filter(w=>w.name.toLowerCase().includes(h.toLowerCase())),z=()=>{if(f==="catalog"){if(!j)return;l({source:"catalog",name:j});return}if(f==="repo"){if(!b)return;l({source:"repo",url:b});return}m&&l({source:"local",path:m})},P=j?r.includes(j):!1,O=f==="catalog"&&(!j||P||B||!!D)||f==="repo"&&!b||f==="local"&&!m;return e.jsx($e,{open:t,onOpenChange:s,children:e.jsxs(Ie,{onCloseAutoFocus:w=>Je("[data-skill-install-trigger]",w),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:i("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:i("skills.install.title")}),e.jsx("button",{onClick:()=>s(!1),"aria-label":i("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(dt,{active:f==="catalog",onClick:()=>g("catalog"),children:i("skills.install.tab.catalog")}),e.jsx(dt,{active:f==="repo",onClick:()=>g("repo"),children:i("skills.install.tab.repo")}),e.jsx(dt,{active:f==="local",onClick:()=>g("local"),children:i("skills.install.tab.local")})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[f==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{"aria-label":i("skills.install.catalog.searchAria"),value:h,onChange:w=>c(w.target.value),placeholder:i("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:[B&&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"}),i("skills.install.catalog.loading")]}),D&&!B&&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:D.message}),e.jsx("button",{type:"button",onClick:N,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:i("skills.action.retry")})]}),!B&&!D&&S.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:i("skills.install.catalog.empty")}),!B&&!D&&S.map(w=>{const k=r.includes(w.name),T=j===w.name;return e.jsxs("button",{onClick:()=>u(w.name),className:R("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",T?"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:w.name}),e.jsx("span",{className:R("text-[10px] font-mono px-2 py-0.5 rounded",w.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:Ot[w.tag]?i(Ot[w.tag]):w.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:w.description}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:i("skills.install.catalog.byAuthor",{author:w.author})}),k&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:i("skills.status.installed")})]},w.name)})]})]}),f==="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:i("skills.install.repo.label")}),e.jsx("input",{"aria-label":i("skills.install.repo.inputAria"),value:b,onChange:w=>y(w.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:i("skills.install.repo.credentialsHint")})]}),f==="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:i("skills.install.local.label")}),e.jsx("input",{"aria-label":i("skills.install.local.inputAria"),value:m,onChange:w=>A(w.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:()=>s(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:i("skills.action.cancel")}),e.jsx("button",{onClick:z,disabled:O,className:R("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",O?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:i("skills.action.installShort")})]})]})]})})}function yn({open:t,status:a,error:s,onCancel:l,onConfirm:r,onRetry:i}){const f=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:f("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:f("skills.status.confirm.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:f("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:f("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:f("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:f("skills.status.installing.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:f("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:f("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:f("skills.status.failed.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:s||f("skills.status.failed.fallback")}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:f("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:f("skills.action.close")}),e.jsx("button",{onClick:i,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:f("skills.action.retry")})]})]})]})]})})}const En=[{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"}],Nn=/^[a-z][a-z0-9._-]{0,63}$/;function wn({open:t,onOpenChange:a,onSave:s,saveError:l}){const r=ge(),[i,f]=n.useState([]),[g,h]=n.useState([]),[c,j]=n.useState(),[u,b]=n.useState(),[y,m]=n.useState(""),[A,C]=n.useState(""),[B,D]=n.useState(""),[N,S]=n.useState(""),[z,P]=n.useState(""),[O,w]=n.useState(""),[k,T]=n.useState(!1),[X,J]=n.useState(!1),[I,te]=n.useState(!1),[Y,ee]=n.useState(!1),[_,v]=n.useState(null);n.useEffect(()=>{if(!t)return;let E=!0;return h([]),j(void 0),b(void 0),m(""),C(""),D(""),S(""),P(""),w(""),T(!1),v(null),J(!0),q("/providers").then(M=>{E&&f(M)}).catch(M=>{E&&v(M instanceof Error?M.message:r("settings.models.addModal.loadProvidersError"))}).finally(()=>{E&&J(!1)}),()=>{E=!1}},[t,r]),n.useEffect(()=>{if(!c)return;let E=!0;return h([]),b(void 0),v(null),c.factoryWireApi||c.custom?(te(!1),()=>{E=!1}):(te(!0),q(`/providers/${c.id}/models`).then(M=>{E&&h(M)}).catch(M=>{E&&v(M instanceof Error?M.message:r("settings.models.addModal.loadModelsError"))}).finally(()=>{E&&te(!1)}),()=>{E=!1})},[c,r]);const K=c==null?void 0:c.factoryWireApi,Q=!!(K||c!=null&&c.custom),L=Q?N.trim():u==null?void 0:u.id,V=async()=>{if(!c||!L||!c.configured&&!O)return;if(K){if(!Nn.test(A.trim())){v(r("settings.models.addModal.channelIdError"));return}let Z;try{Z=new URL(z.trim())}catch{v(r("settings.models.addModal.invalidBaseUrl"));return}if(!["http:","https:"].includes(Z.protocol)){v(r("settings.models.addModal.invalidBaseUrl"));return}}ee(!0);const E=K?A.trim():c.id,M=await s({provider:E,model:L,displayName:y||(Q?L:(u==null?void 0:u.name)??""),apiKey:O||void 0,...K?{modelProvider:{id:E,name:B.trim()||E,baseUrl:z.trim(),wireApi:K}}:{}});ee(!1),M&&a(!1)};return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:E=>Je("[data-add-model-trigger]",E),onEscapeKeyDown:E=>{E.preventDefault(),a(!1)},onKeyDown:E=>{E.key==="Escape"&&(E.preventDefault(),E.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"})})]}),(_||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:_||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(Ae,{"aria-label":r("settings.models.addModal.provider"),value:(c==null?void 0:c.id)??"",disabled:X,onChange:E=>{j(i.find(M=>M.id===E)),m(""),C(""),D(""),S(""),P("")},placeholder:r(X?"settings.models.addModal.loadingProviders":"settings.models.addModal.selectProvider"),options:i.map(E=>{const M=E.factoryWireApi==="openai-completions"?r("settings.models.addModal.customOpenAI"):E.factoryWireApi==="anthropic-messages"?r("settings.models.addModal.customAnthropic"):E.name;return{value:E.id,label:`${M} (${E.modelCount})${E.configured?r("settings.models.addModal.configuredSuffix"):""}`}})})]}),Q?e.jsxs(e.Fragment,{children:[K&&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:A,onChange:E=>{C(E.target.value),v(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:E=>D(E.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:z,onChange:E=>{P(E.target.value),v(null)},placeholder:K==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:r(K==="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:N,onChange:E=>{S(E.target.value),v(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(Ae,{"aria-label":r("settings.models.addModal.model"),value:(u==null?void 0:u.id)??"",disabled:!c||I,onChange:E=>{const M=g.find(Z=>Z.id===E);b(M),M&&m(M.name)},placeholder:r(I?"settings.models.addModal.loadingModels":"settings.models.addModal.selectModel"),options:g.map(E=>({value:E.id,label:`${E.name} - ${Math.round(E.contextWindow/1e3)}K${E.reasoning?r("settings.models.addModal.reasoningSuffix"):""}${E.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:y,onChange:E=>m(E.target.value),placeholder:(u==null?void 0:u.name)??r("settings.models.addModal.displayNamePlaceholder"),className:"field"})]}),(c==null?void 0:c.supportsApiKey)&&!c.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:k?"text":"password",value:O,onChange:E=>w(E.target.value),className:"field w-full pr-10",placeholder:r("settings.models.addModal.apiKeyPlaceholder")}),e.jsx("button",{type:"button",onClick:()=>T(!k),"aria-label":r(k?"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:k?e.jsx(fa,{className:"h-4 w-4"}):e.jsx(ha,{className:"h-4 w-4"})})]})]}),c&&!c.configured&&!c.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:r("settings.models.addModal.oauthNote")}),e.jsxs("button",{type:"button",disabled:Y||!c||!L||K&&(!A.trim()||!z.trim())||!c.configured&&(!c.supportsApiKey||O.trim().length===0),onClick:()=>void V(),className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 font-mono text-sm font-semibold text-white disabled:opacity-50",children:[Y&&e.jsx(ne,{className:"h-4 w-4 animate-spin"}),r(Y?"settings.models.addModal.saving":"settings.models.addModal.saveModel")]})]})]})})}function Cn(t){const a=ge(),[s,l]=n.useState(""),[r,i]=n.useState(""),[f,g]=n.useState(""),[h,c]=n.useState(""),[j,u]=n.useState(!1),[b,y]=n.useState(null);n.useEffect(()=>{var C,B,D,N,S;l(((C=t.model)==null?void 0:C.displayName)??""),i(((D=(B=t.model)==null?void 0:B.overrides)==null?void 0:D.baseUrl)??""),g(((S=(N=t.model)==null?void 0:N.overrides)==null?void 0:S.streamIdleTimeout)!==void 0?String(t.model.overrides.streamIdleTimeout):""),c(""),y(null)},[t.model]);const m=async()=>{if(!t.model)return;y(null);const C=f.trim()?Number(f):void 0;if(C!==void 0&&(!Number.isFinite(C)||C<1e3)){y(a("settings.models.editModal.streamIdleTimeoutError"));return}u(!0);try{h.trim()&&await q(`/providers/${t.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:h.trim()})});const B={...t.model.overrides};r.trim()?B.baseUrl=r.trim():delete B.baseUrl,C!==void 0?B.streamIdleTimeout=C: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){y(B instanceof Error?B.message:a("settings.models.editModal.credentialError"))}finally{u(!1)}},A=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:C=>Je(A,C),onEscapeKeyDown:C=>{C.preventDefault(),t.onOpenChange(!1)},onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),C.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:C=>l(C.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:h,onChange:C=>c(C.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:C=>i(C.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:f,onChange:C=>g(C.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void m(),disabled:j,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:[j&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),a(j?"settings.models.editModal.saving":"settings.models.editModal.save")]})]})})}function An({provider:t,onOpenChange:a,onSave:s,saveError:l}){const r=ge(),[i,f]=n.useState(t.name),[g,h]=n.useState(t.defaultBaseUrl??""),[c,j]=n.useState(t.wireApi??"openai-completions"),[u,b]=n.useState(t.apiKeyEnv??""),[y,m]=n.useState(""),[A,C]=n.useState(null),[B,D]=n.useState(!1);n.useEffect(()=>{f(t.name),h(t.defaultBaseUrl??""),j(t.wireApi??"openai-completions"),b(t.apiKeyEnv??""),m(""),C(null)},[t]);const N=async()=>{if(!i.trim()){C(r("settings.models.editProvider.channelNameRequired"));return}try{const S=new URL(g.trim());if(!["http:","https:"].includes(S.protocol))throw new Error}catch{C(r("settings.models.editProvider.invalidBaseUrl"));return}D(!0),C(null);try{await s(t.id,{name:i.trim(),baseUrl:g.trim(),wireApi:c,apiKeyEnv:u.trim()||null,...y.trim()?{apiKey:y.trim()}:{}})&&a(!1)}finally{D(!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"})})]}),(A||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:A||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:i,onChange:S=>f(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(Ae,{"aria-label":r("settings.models.editProvider.wireApi"),value:c,onChange:S=>j(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=>{h(S.target.value),C(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:u,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:y,onChange:S=>m(S.target.value),placeholder:r("settings.models.editProvider.apiKeyPlaceholder"),className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void N(),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 Sn={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 Fn(){const t=ge(),a=Le(_=>_.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]),[i,f]=n.useState(null),[g,h]=n.useState(null),[c,j]=n.useState(""),[u,b]=n.useState(""),[y,m]=n.useState(!1),[A,C]=n.useState(null),[B,D]=n.useState(null),[N,S]=n.useState(null),z=n.useRef(0),P=n.useRef(r);P.current=r;const O=l?`${r}\0${l}`:"",w=n.useRef(O);w.current=O;const k=c===r?i:null,T=u===O?g:null,X=n.useCallback(async()=>{const _=++z.current;if(!r){f(null),h(null),j(""),b(""),S(null);return}m(!0),S(null);try{const v=await q(`/hooks/trust?projectPath=${encodeURIComponent(r)}`);if(_!==z.current)return;const K=l?await q(`/hooks/session?projectPath=${encodeURIComponent(r)}&sessionId=${encodeURIComponent(l)}`):null;if(_!==z.current)return;f(v),h(K),j(r),b(K?O:"")}catch(v){if(_!==z.current)return;S(v instanceof Error?v.message:t("settings.hooks.loadFailed"))}finally{_===z.current&&m(!1)}},[r,l,O,t]);n.useEffect(()=>(D(null),X(),()=>{z.current+=1}),[X]);const J=async _=>{if(!k)return;const v=r;C(_),S(null);try{const K=await q("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,action:_,..._==="trust"&&k.currentDigest?{expectedDigest:k.currentDigest}:{}})});P.current===v&&(f(K),j(v),D(null))}catch(K){P.current===v&&S(K instanceof Error?K.message:t("settings.hooks.updateFailed"))}finally{C(null)}},I=async _=>{if(!l||!T)return;const v=O;C("session"),S(null);try{const K=await q("/hooks/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,sessionId:l,enabled:_})});w.current===v&&(h(K),b(v))}catch(K){w.current===v&&S(K instanceof Error?K.message:t("settings.hooks.sessionUpdateFailed"))}finally{C(null)}};if(!r)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.hooks.selectSession")});const te=(k==null?void 0:k.state)==="trusted",Y=(k==null?void 0:k.state)==="untrusted"||(k==null?void 0:k.state)==="modified",ee=T!==null&&!T.enabled&&!T.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:[te?e.jsx(bt,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ht,{className:R("h-4 w-4",Y?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(k?Sn[k.state]:"settings.hooks.heading")}),y&&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}),(k==null?void 0:k.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:k.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void X(),disabled:y||A!==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(Me,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),te?e.jsx("button",{type:"button",onClick:()=>D("revoke"),disabled:A!==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:()=>D("trust"),disabled:A!==null||!(k!=null&&k.currentDigest)||k.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")})]})]}),N&&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:N}),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?T?T.paused?t("settings.hooks.session.paused"):T.enabled?t("settings.hooks.session.active"):T.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":T!=null&&T.paused?t("settings.hooks.session.enableAria"):T!=null&&T.enabled?t("settings.hooks.session.pauseAria"):t("settings.hooks.session.unavailableAria"),"aria-checked":(T==null?void 0:T.enabled)??!1,disabled:!T||A!==null||ee,onClick:()=>void I((T==null?void 0:T.paused)===!0),className:R("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",T!=null&&T.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:R("h-4 w-4 rounded-full bg-white transition-transform",T!=null&&T.enabled?"translate-x-5":"translate-x-0")})})]}),B&&k&&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:k.configuredHooks}):t("settings.hooks.confirmRevoke")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>D(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 J(B),disabled:A!==null,className:R("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(A?"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:[((k==null?void 0:k.definitions)??[]).map((_,v)=>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:_.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:_.type}),_.name&&e.jsx("span",{className:"text-[#71717a]",children:_.name}),_.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:[_.pluginName," · ",_.pluginSource]})]}),_.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:_.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:_.target})]},`${_.event}-${_.type}-${v}`)),k&&k.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.hooks.empty")})]})]})}const Dt={restrictToAllowedSources:!1,requireGitCommitSha:!1,allowedGitHosts:[],allowedMarketplaces:[],allowedLocalRoots:[]},Pn=[{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"}],Lt={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 Bn(){const t=ge(),a=Le(p=>{var U;return(U=p.currentSessionRef)==null?void 0:U.projectPath}),s=Le(p=>p.selectedProjectPath),l=n.useMemo(()=>a??s??new URLSearchParams(window.location.search).get("project")??"",[s,a]),[r,i]=n.useState([]),[f,g]=n.useState([]),[h,c]=n.useState(Dt),[j,u]=n.useState(!1),[b,y]=n.useState(""),[m,A]=n.useState(""),[C,B]=n.useState(""),[D,N]=n.useState(""),[S,z]=n.useState(!1),[P,O]=n.useState(null),[w,k]=n.useState(null),[T,X]=n.useState(""),[J,I]=n.useState(""),[te,Y]=n.useState(!1),[ee,_]=n.useState(null),[v,K]=n.useState("local"),Q=n.useRef(0),L=n.useRef(l);L.current=l;const V=D===l?r:[],E=D===l?f:[],M=n.useCallback(async()=>{const p=++Q.current;if(!l){i([]),N(""),k(null);return}z(!0),k(null);try{const[U,ae,oe]=await Promise.all([q(`/plugins?projectPath=${encodeURIComponent(l)}`),q(`/plugins/catalog?projectPath=${encodeURIComponent(l)}`),q(`/plugins/policy?projectPath=${encodeURIComponent(l)}`)]);if(p!==Q.current)return;i(U),g(ae);const xe=(oe==null?void 0:oe.policy)??Dt;c(xe),u((oe==null?void 0:oe.environmentRequiresSha)??!1),y(xe.allowedGitHosts.join(", ")),A(xe.allowedMarketplaces.join(", ")),B(xe.allowedLocalRoots.join(", ")),N(l)}catch(U){if(p!==Q.current)return;k(U instanceof Error?U.message:t("settings.plugins.loadFailed"))}finally{p===Q.current&&z(!1)}},[l,t]);n.useEffect(()=>(M(),()=>{Q.current+=1}),[M]);const Z=async(p,U)=>{const ae=l;O(p.name),k(null);try{await q(`/plugins/${encodeURIComponent(p.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:ae,enabled:U,scope:v})}),L.current===ae&&await M()}catch(oe){L.current===ae&&k(oe instanceof Error?oe.message:t("settings.plugins.updateFailed"))}finally{O(null)}},pe=p=>[...new Set(p.split(",").map(U=>U.trim()).filter(Boolean))],Se=async()=>{await le("policy:save",()=>q("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,scope:"local",policy:{...h,allowedGitHosts:pe(b),allowedMarketplaces:pe(m),allowedLocalRoots:pe(C)}})}))},le=async(p,U,ae)=>{const oe=l;O(p),k(null);try{await U(),L.current===oe&&(ae==null||ae(),_(null),await M())}catch(xe){L.current===oe&&k(xe instanceof Error?xe.message:t("settings.plugins.actionFailed"))}finally{O(null)}},he=async()=>{const p=T.trim();!p||!te||await le("install",()=>q("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:p,trust:!0})}),()=>{X(""),Y(!1)})},we=async p=>{const U=`update:${p.name}`;if(ee!==U){_(U);return}await le(U,()=>q(`/plugins/${encodeURIComponent(p.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,trust:!0})}))},ce=async p=>{const U=`uninstall:${p.name}`;if(ee!==U){_(U);return}await le(U,()=>q(`/plugins/${encodeURIComponent(p.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))},Ce=async()=>{const p=J.trim();p&&await le("marketplace:add",()=>q("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:p})}),()=>I(""))},de=async p=>{await le(`marketplace:refresh:${p.name}`,()=>q(`/plugins/marketplaces/${encodeURIComponent(p.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l})}))},re=async p=>{const U=`marketplace:remove:${p.name}`;if(ee!==U){_(U);return}await le(U,()=>q(`/plugins/marketplaces/${encodeURIComponent(p.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(na,{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||P!==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(Me,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]})]}),w&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:w}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(bt,{className:"h-3.5 w-3.5"}),t("settings.plugins.sourcePolicy")]}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.savePolicyAria"),onClick:()=>void Se(),disabled:P!==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(P==="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":h.restrictToAllowedSources,onClick:()=>c(p=>({...p,restrictToAllowedSources:!p.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:R("h-3.5 w-6 rounded-full p-0.5",h.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:R("block h-2.5 w-2.5 rounded-full bg-white transition-transform",h.restrictToAllowedSources&&"translate-x-2.5")})}),t("settings.plugins.restrictAllowlists")]}),e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.requireShaAria"),"aria-checked":h.requireGitCommitSha,disabled:j,onClick:()=>c(p=>({...p,requireGitCommitSha:!p.requireGitCommitSha})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]",children:[e.jsx("span",{className:R("h-3.5 w-6 rounded-full p-0.5",h.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:R("block h-2.5 w-2.5 rounded-full bg-white transition-transform",h.requireGitCommitSha&&"translate-x-2.5")})}),t("settings.plugins.requireSha"),j?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:p=>y(p.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:m,onChange:p=>A(p.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:C,onChange:p=>B(p.target.value),placeholder:"/opt/approved/plugins",className:"field h-7 px-2 text-[9.5px]"})]}),h.restrictToAllowedSources&&!b.trim()&&!m.trim()&&!C.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(mt,{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:T,onChange:p=>X(p.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:P!==null,className:"field h-8 min-w-0 flex-1 px-2 text-[10.5px]"}),e.jsxs("button",{type:"button",onClick:()=>void he(),disabled:!T.trim()||!te||P!==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:[P==="install"?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(mt,{className:"h-3.5 w-3.5"}),t("settings.plugins.install")]})]}),e.jsxs("button",{type:"button",role:"checkbox","aria-checked":te,onClick:()=>Y(p=>!p),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:R("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",te?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:te?"✓":""}),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:Pn.map(p=>e.jsx("button",{type:"button",role:"radio","aria-checked":v===p.value,title:t(p.descriptionKey),onClick:()=>K(p.value),className:R("rounded px-2 py-1 text-[9.5px] transition-colors",v===p.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(p.labelKey)},p.value))})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[V.map(p=>{var xe;const U=P===p.name,ae=[p.commands?t("settings.plugins.capability.commands",{count:p.commands}):"",p.skills?t("settings.plugins.capability.skills",{count:p.skills}):"",p.agents?t("settings.plugins.capability.agents",{count:p.agents}):"",p.hooks?t("settings.plugins.capability.hooks",{count:p.hooks}):"",p.mcpServers?t("settings.plugins.capability.mcp",{count:p.mcpServers}):""].filter(Boolean),oe=["global","project","local","invocation"].filter(fe=>{var be;return((be=p.settingLayers)==null?void 0:be[fe])!==void 0}).map(fe=>`${t(Lt[fe])} ${t(p.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:p.name}),e.jsxs("span",{className:"text-[9.5px] text-[#9CA3AF]",children:["v",p.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:p.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(Lt[p.effectiveScope])})})]}),e.jsx("p",{className:"mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:p.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(" · ")}),p.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:[t("settings.plugins.managed"),p.marketplace?` · ${p.marketplace}`:"",p.revision?` · ${p.revision.slice(0,12)}`:""]}),!p.configurable&&e.jsx("p",{className:"mt-1 text-[9.5px] text-amber-600 dark:text-amber-400",children:t("settings.plugins.invocationScoped")}),(xe=p.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":p.status==="error"?t("settings.plugins.unavailableAria",{name:p.name}):p.enabled?t("settings.plugins.disableAria",{name:p.name}):t("settings.plugins.enableAria",{name:p.name}),"aria-checked":p.enabled,disabled:p.status==="error"||!p.configurable||U||P!==null,onClick:()=>void Z(p,!p.enabled),className:R("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",p.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:R("h-4 w-4 rounded-full bg-white transition-transform",p.enabled?"translate-x-5":"translate-x-0")})}),p.managed&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.updateAria",{name:p.name}),onClick:()=>void we(p),disabled:P!==null,className:R("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",ee===`update:${p.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:P===`update:${p.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):ee===`update:${p.name}`?t("settings.plugins.confirmUpdate"):t("settings.plugins.update")}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.uninstallAria",{name:p.name}),onClick:()=>void ce(p),disabled:P!==null,className:R("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",ee===`uninstall:${p.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:P===`uninstall:${p.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):ee===`uninstall:${p.name}`?t("settings.plugins.confirmRemove"):e.jsx(ze,{className:"h-3 w-3"})})]})]})]},p.name)}),!S&&V.length===0&&!w&&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(ga,{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:E.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:J,onChange:p=>I(p.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:P!==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:!J.trim()||P!==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:[P==="marketplace:add"?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(We,{className:"h-3 w-3"}),t("settings.plugins.add")]})]}),E.map(p=>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:[p.name,e.jsxs("span",{className:"ml-2 font-normal text-[#9CA3AF]",children:[p.sourceType," · ",p.revision.slice(0,12)]})]}),e.jsx("p",{className:"mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:p.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:p.name}),disabled:P!==null,onClick:()=>void de(p),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:P===`marketplace:refresh:${p.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(Me,{className:"h-3 w-3"})}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.removeMarketplaceAria",{name:p.name}),disabled:P!==null,onClick:()=>void re(p),className:R("rounded p-1 text-[#9CA3AF] disabled:opacity-40",ee===`marketplace:remove:${p.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:ee===`marketplace:remove:${p.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:[p.plugins.slice(0,12).map(U=>e.jsxs("button",{type:"button",disabled:U.installed||P!==null,onClick:()=>{X(`${U.name}@${p.name}`),Y(!1)},title:U.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:[U.name,U.installed?t("settings.plugins.installedSuffix"):""]},U.name)),p.plugins.length>12&&e.jsxs("span",{className:"px-1 py-0.5 text-[8.5px] text-[#9CA3AF]",children:["+",p.plugins.length-12]})]})]},p.name)),!S&&E.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 Tn={not_required:"settings.trust.state.notRequired",trusted:"settings.trust.state.trusted",untrusted:"settings.trust.state.review",error:"settings.trust.state.error"};function Mn(){const t=ge(),a=Le(w=>{var k;return(k=w.currentSessionRef)==null?void 0:k.projectPath}),s=n.useMemo(()=>a??new URLSearchParams(window.location.search).get("project")??"",[a]),[l,r]=n.useState(null),[i,f]=n.useState(""),[g,h]=n.useState(!1),[c,j]=n.useState(null),[u,b]=n.useState(null),[y,m]=n.useState(null),[A,C]=n.useState(!1),B=n.useRef(0),D=n.useRef(s);D.current=s;const N=i===s?l:null,S=n.useCallback(async()=>{const w=++B.current;if(!s){r(null),f(""),m(null);return}h(!0),m(null);try{const k=await q(`/workspace-trust?projectPath=${encodeURIComponent(s)}`);if(w!==B.current)return;r(k),f(s)}catch(k){if(w!==B.current)return;m(k instanceof Error?k.message:t("settings.trust.loadFailed"))}finally{w===B.current&&h(!1)}},[s,t]);n.useEffect(()=>(b(null),C(!1),S(),()=>{B.current+=1}),[S]);const z=async w=>{if(!N)return;const k=s;j(w),m(null);try{const T=await q("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:k,action:w})});D.current===k&&(r(T),f(k),b(null),C(T.reloadRequired===!0))}catch(T){D.current===k&&m(T instanceof Error?T.message:t("settings.trust.updateFailed"))}finally{j(null)}};if(!s)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.trust.selectSession")});const P=(N==null?void 0:N.state)==="trusted",O=(N==null?void 0:N.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:[P?e.jsx(bt,{className:"w-4 h-4 text-emerald-600"}):e.jsx(Ht,{className:R("h-4 w-4",O?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(N?Tn[N.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}),N&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[N.decision,N.inheritedFrom?t("settings.trust.inheritedFrom",{source:N.inheritedFrom}):""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:g||c!==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(Me,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),P?e.jsx("button",{type:"button",onClick:()=>b("revoke"),disabled:c!==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:c!==null||(N==null?void 0:N.state)==="error"||!N||N.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")})]})]}),(y||(N==null?void 0:N.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:y||(N==null?void 0:N.error)}),A&&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")}),u&&N&&e.jsxs("div",{role:"alertdialog","aria-label":t(u==="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:u==="trust"?t("settings.trust.confirmTrust",{count:N.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 z(u),disabled:c!==null,className:R("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",u==="trust"?"bg-emerald-600":"bg-red-600"),children:t(c?"settings.trust.saving":u==="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:[((N==null?void 0:N.sources)??[]).map(w=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:w.path}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:w.kind})]}),w.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:w.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:w.effects.map((k,T)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:k.kind})," · ",k.name,k.target?` → ${k.target}`:""]},`${k.kind}-${k.name}-${T}`))})]},`${w.kind}-${w.path}`)),N&&N.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.trust.empty")})]})]})}const Rn={anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}},On={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"},$t={auto:"settings.style.auto",pragmatic:"settings.style.pragmatic",friendly:"settings.style.friendly",explanatory:"settings.style.explanatory"},It={Global:"settings.shortcuts.scope.global",Chat:"settings.shortcuts.scope.chat",Layout:"settings.shortcuts.scope.layout"};function Yn(){var Ee,je;const t=ge(),{locale:a}=ra(),{isSettingsOpen:s,settingsSection:l,toggleSettings:r,isSidebarOpen:i,setSidebarOpen:f}=xa(),{configuredModels:g,loadModels:h,isLoading:c,error:j}=Ut(),u=la(),[b,y]=n.useState("general"),[m,A]=n.useState(!1),[C,B]=n.useState(null),[D,N]=n.useState(null),[S,z]=n.useState(null),[P,O]=n.useState([]),[w,k]=n.useState(null),[T,X]=n.useState(null),[J,I]=n.useState(null),[te,Y]=n.useState(null),[ee,_]=n.useState({}),[v,K]=n.useState(null),[Q,L]=n.useState(null),[V,E]=n.useState(""),[M,Z]=n.useState("all"),pe=n.useRef(null),Se=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(()=>oa.map(o=>({action:t(On[o.id]),combo:ia(o),scope:o.scope})),[a]).filter(o=>{const $=o.action.toLowerCase().includes(V.toLowerCase()),H=M==="all"||o.scope.toLowerCase()===M;return $&&H}),re=g.reduce((o,$)=>{const H=$.provider||"unknown";return o[H]||(o[H]=[]),o[H].push($),o},{}),p=new Map(P.map(o=>[o.id,o]));for(const o of P)o.custom&&!re[o.id]&&(re[o.id]=[]);const U=n.useCallback(async()=>{try{O(await q("/providers")),Y(null)}catch(o){Y(o instanceof Error?o.message:t("settings.models.loadChannelsFailed"))}},[t]);n.useEffect(()=>{s&&(y(l),h(),U(),u.loadSettings())},[s,h,U,u.loadSettings,l]);const ae=()=>{const o=Se.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]")&&(Se.current=o);const $=requestAnimationFrame(()=>{var H;(H=pe.current)==null||H.focus({preventScroll:!0})});return()=>{cancelAnimationFrame($),requestAnimationFrame(ae)}},[s]);const xe=async o=>{K("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 h(),await U(),!0}catch($){return L($ instanceof Error?$.message:t("settings.models.saveFailed")),!1}finally{K(null)}},fe=async()=>{typeof Notification>"u"||we(await Notification.requestPermission())},be=async o=>{K("delete"),L(null);try{await q(`/models/${o}`,{method:"DELETE"}),await h(),z(null)}catch($){L($ instanceof Error?$.message:t("settings.models.deleteFailed"))}finally{K(null)}},Fe=async(o,$)=>{K("update"),L(null);try{return await q(`/models/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),await h(),!0}catch(H){return L(H instanceof Error?H.message:t("settings.models.updateFailed")),!1}finally{K(null)}},F=async(o,$)=>{I({providerId:o,type:"update"}),Y(null);try{return await q(`/providers/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),await Promise.all([h(),U()]),!0}catch(H){return Y(H instanceof Error?H.message:t("settings.models.updateChannelFailed")),!1}finally{I(null)}},Be=async(o,$)=>{I({providerId:o.id,type:"probe"}),Y(null);try{const H=await q(`/providers/${o.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:$})});_(d=>({...d,[o.id]:H}))}catch(H){Y(H instanceof Error?H.message:t("settings.models.probeFailed"))}finally{I(null)}},ve=async o=>{I({providerId:o.id,type:"delete"}),Y(null);try{await q(`/providers/${o.id}?removeModels=true`,{method:"DELETE"}),X(null),B(null),_($=>{const H={...$};return delete H[o.id],H}),await Promise.all([h(),U()])}catch($){Y($ instanceof Error?$.message:t("settings.models.deleteChannelFailed"))}finally{I(null)}},Re=(o,$)=>{var W,G;const H=o.key==="ArrowRight"||o.key==="ArrowDown"?1:o.key==="ArrowLeft"||o.key==="ArrowUp"?-1:0;if(H===0&&o.key!=="Home"&&o.key!=="End")return;o.preventDefault();const d=o.key==="Home"?0:o.key==="End"?ce.length-1:($+H+ce.length)%ce.length;y(ce[d].value),(G=(W=o.currentTarget.closest('[role="tablist"]'))==null?void 0:W.querySelectorAll('[role="tab"]')[d])==null||G.focus()},x=o=>{B(C===o?null:o)},ue=o=>{if(!s||o.key!=="Escape"||!(o.target instanceof Node)||!o.currentTarget.contains(o.target)||m||D||w||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){z(null);return}if(T){X(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(H=>e.jsx("button",{onClick:()=>y(H.value),onKeyDown:d=>Re(d,ce.indexOf(H)),role:"tab",id:`settings-tab-${H.value}`,"aria-controls":`settings-panel-${H.value}`,"aria-selected":b===H.value,tabIndex:b===H.value?0:-1,className:R("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",b===H.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:H.label},H.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:((Ee=ce.find(o=>o.value===b))==null?void 0:Ee.label)??t("settings.title")}),u.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")]}),u.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:u.error}),e.jsx("button",{type:"button",onClick:()=>void u.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")}),(j||Q||te)&&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:te||Q||j}),e.jsx("button",{type:"button",onClick:()=>{L(null),Y(null),j&&h()},className:"underline shrink-0",children:t(j?"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:()=>z(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:v!==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(v==="delete"?"settings.models.deleting":"settings.models.deleteModel")})]})]}),T&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteChannelAria",{name:T.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:T.name,count:((je=re[T.id])==null?void 0:je.length)??0})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>X(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(T),disabled:J!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(J==null?void 0:J.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:[c&&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 H=Rn[o]||{bg:"#71717a",label:"?"},d=p.get(o),W=C===o,G=ee[o],ye=(J==null?void 0:J.providerId)===o&&J.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:H.bg},children:H.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:R("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:R("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:J!==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(ma,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":d.id,onClick:()=>{Y(null),k(d)},disabled:J!==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(xt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>X(d),disabled:J!==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"})})]})]}),G&&e.jsxs("div",{role:"status",className:R("border-t px-4 py-2 font-mono text-[11px]",G.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:[G.message," · ",G.latencyMs,"ms · ",G.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),N(me)},disabled:v!==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(xt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>z(me),disabled:v!==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)}),!c&&!j&&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),A(!0)},disabled:v!==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":u.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(Ae,{"aria-label":t("settings.general.responseLanguage"),value:u.language,onChange:o=>u.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(Te,{label:t("settings.general.autoSave"),enabled:u.autoSaveSessions,onChange:o=>u.updateSettings({autoSaveSessions:o})})]}),e.jsxs("div",{className:"flex justify-between items-center gap-4 py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:rt(a,"settingsTitle")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:rt(a,"settingsHint")})]}),e.jsx(Te,{label:rt(a,"settingsTitle"),enabled:u.agentTeamsEnabled,onChange:o=>u.updateSettings({agentTeamsEnabled: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(Ae,{"aria-label":t("settings.general.communicationStyle"),value:u.communicationStyle??"auto",onChange:o=>u.updateSettings({communicationStyle:o}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:En.map(o=>({value:o.id,label:$t[o.id]?t($t[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:()=>u.updateSettings({uiTheme:o}),className:R("px-3 py-1 rounded text-[12px] font-mono transition-colors",u.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(Te,{label:t("settings.appearance.compactSidebar"),enabled:!i,onChange:o=>f(!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(Ae,{"aria-label":t("settings.appearance.codeTheme"),value:u.codeTheme,onChange:o=>u.updateSettings({codeTheme: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(Te,{label:t("settings.notifications.buildFinished"),enabled:u.notifyBuild,onChange:o=>u.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(Te,{label:t("settings.notifications.errorsOnly"),enabled:u.notifyErrors,onChange:o=>u.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(Te,{label:t("settings.notifications.systemSounds"),enabled:u.notifySounds,onChange:o=>u.updateSettings({notifySounds:o})})]}),(u.notifyBuild||u.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(Te,{label:t("settings.privacy.telemetry"),enabled:u.privacyTelemetry,onChange:o=>u.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(Te,{label:t("settings.privacy.crash"),enabled:u.privacyCrash,onChange:o=>u.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:V,onChange:o=>E(o.target.value),placeholder:t("settings.shortcuts.searchPlaceholder"),className:"field flex-1 text-[12px]"}),e.jsx(Ae,{"aria-label":t("settings.shortcuts.col.scope"),value:M,onChange:o=>Z(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:()=>{E(""),Z("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:R("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(H=>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:H},H))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:It[o.scope]?t(It[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(on,{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(kn,{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(Fn,{})}),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(Bn,{})}),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(gn,{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(Mn,{})})]})})})]}),m&&e.jsx(wn,{open:!0,onOpenChange:o=>{o||(le.current=Date.now()),A(o)},onSave:xe,saveError:Q}),D&&e.jsx(Cn,{open:!0,onOpenChange:o=>{o||(le.current=Date.now(),N(null))},model:D,onSave:Fe,saveError:Q}),w&&e.jsx(An,{provider:w,onOpenChange:o=>{o||(le.current=Date.now(),k(null))},onSave:F,saveError:te})]})}function Te({label:t,enabled:a,onChange:s}){return e.jsx("button",{type:"button",role:"switch","aria-label":t,"aria-checked":a,onClick:()=>s(!a),className:R("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:R("h-4 w-4 rounded-full transition-transform",a?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{Yn as SettingsModal};
|