blade-code 0.10.155 → 0.10.158
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-mp1kckbw.js → chunk-1329rzdd.js} +1 -1
- package/dist/{chunk-8wdnzcxy.js → chunk-25z7w7jb.js} +1 -1
- package/dist/{chunk-8rpshvhq.js → chunk-26109k8r.js} +1 -1
- package/dist/{chunk-cv4h5c96.js → chunk-42y6ks44.js} +1 -1
- package/dist/{chunk-yj3t8dd0.js → chunk-479y73j2.js} +1 -1
- package/dist/{chunk-j470cdhj.js → chunk-4gsjcz7t.js} +1 -1
- package/dist/chunk-5kb1dh44.js +1 -0
- package/dist/{chunk-mqcmd414.js → chunk-6htg4eyc.js} +1 -1
- package/dist/{chunk-jcx2j7e0.js → chunk-6zzet05f.js} +1 -1
- package/dist/{chunk-qank9aj0.js → chunk-7h3405ty.js} +1 -1
- package/dist/{chunk-x83b8ttr.js → chunk-7z31ajj4.js} +1 -1
- package/dist/{chunk-k678bgw3.js → chunk-95z104ay.js} +2 -2
- package/dist/chunk-9hmjg0k7.js +1 -0
- package/dist/{chunk-27x9485f.js → chunk-a9fjtdsh.js} +1 -1
- package/dist/{chunk-2sphbc7z.js → chunk-bgc4wts7.js} +2 -2
- package/dist/{chunk-ad392pqj.js → chunk-ccsgzyth.js} +1 -1
- package/dist/{chunk-3cyed1mn.js → chunk-ehdsj506.js} +3 -3
- package/dist/{chunk-14s52tht.js → chunk-ej0a0s1t.js} +1 -1
- package/dist/{chunk-phq6ejfh.js → chunk-f6wx6sf2.js} +1 -1
- package/dist/{chunk-kg0mjdr8.js → chunk-fp7ssc21.js} +1 -1
- package/dist/{chunk-gjbtr074.js → chunk-gnjsdr40.js} +1 -1
- package/dist/{chunk-559adewt.js → chunk-hamdqef9.js} +1 -1
- package/dist/{chunk-pxc61k03.js → chunk-jcq3tk8c.js} +1 -1
- package/dist/{chunk-zvzdbv7a.js → chunk-jdmm68kd.js} +1 -1
- package/dist/{chunk-xsd1pj8s.js → chunk-jxxvc3b0.js} +1 -1
- package/dist/{chunk-hv1bda16.js → chunk-kxz7j4a3.js} +1 -1
- package/dist/{chunk-4d0esqac.js → chunk-mm5rqxam.js} +1 -1
- package/dist/{chunk-zz14c6h3.js → chunk-p5k6x3be.js} +1 -1
- package/dist/{chunk-5vdg6z0a.js → chunk-pnfeyw0g.js} +1 -1
- package/dist/{chunk-273kk0cn.js → chunk-pz0d6ne3.js} +1 -1
- package/dist/{chunk-42gkes5k.js → chunk-tfebp09g.js} +1 -1
- package/dist/{chunk-ja6d4r04.js → chunk-thveee78.js} +1 -1
- package/dist/{chunk-nvyxejt7.js → chunk-v7b7dx9j.js} +1 -1
- package/dist/{chunk-ffmrt66h.js → chunk-vg6m8ybn.js} +1 -1
- package/dist/{chunk-f06aknxh.js → chunk-vq1myd58.js} +1 -1
- package/dist/{chunk-9fw3kwk5.js → chunk-vs8ywzme.js} +1 -1
- package/dist/{chunk-q1rnvn85.js → chunk-vz13c7fr.js} +45 -45
- package/dist/{chunk-h0ka760f.js → chunk-xh3bm0p0.js} +1 -1
- package/dist/{chunk-b93y9nd6.js → chunk-xxd3vx1j.js} +1 -1
- package/dist/{chunk-bs99tz6h.js → chunk-y1t2tvmq.js} +1 -1
- package/dist/web/assets/{ChatView-DhjLZ2OR.js → ChatView-D9Rgy4Xd.js} +17 -17
- package/dist/web/assets/{CodeBlockHighlighter-CYGqk6nC.js → CodeBlockHighlighter-D2xmVZ64.js} +1 -1
- package/dist/web/assets/{FilePreview-Cti4_C5N.js → FilePreview-DNvYgNjf.js} +1 -1
- package/dist/web/assets/{KanbanBoard-Ct16zVW3.js → KanbanBoard-DHsb2qNL.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-RfULWJEE.js → MarkdownRenderer-DaQIOCqh.js} +3 -3
- package/dist/web/assets/{ScrollArea-DzblNpCd.js → ScrollArea-CMTG2oYB.js} +1 -1
- package/dist/web/assets/{SessionHistorySurface-D3-0PA12.js → SessionHistorySurface-B5W8o5Ac.js} +1 -1
- package/dist/web/assets/SettingsModal-CoIGqfB8.js +20 -0
- package/dist/web/assets/{Sidebar-DgTGp3BO.js → Sidebar-Bp-rTtWG.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-BVau39Em.js → TaskSwitcher-BHlCaj6w.js} +1 -1
- package/dist/web/assets/{TerminalPanel-N2fFhXPj.js → TerminalPanel-1SkToIB-.js} +1 -1
- package/dist/web/assets/{archive-DYlK7NlT.js → archive-VQ-zwIBp.js} +1 -1
- package/dist/web/assets/{arrow-left-DaRjPuTX.js → arrow-left-CNl5Vg6X.js} +1 -1
- package/dist/web/assets/{calendar-clock-UTpg6J58.js → calendar-clock-B_VagIW-.js} +1 -1
- package/dist/web/assets/{chevron-right-DW6hcYoH.js → chevron-right-rbUP1NBz.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-D0BwYbw9.js → chevrons-up-down-DSWrXgFD.js} +1 -1
- package/dist/web/assets/{clock-3-DTmdPhfW.js → clock-3-B7G3JFdh.js} +1 -1
- package/dist/web/assets/{copy-3oxA5Cc-.js → copy-BSAC3Lqd.js} +1 -1
- package/dist/web/assets/{download-D1w7sCBV.js → download-Da_UuSK6.js} +1 -1
- package/dist/web/assets/{external-link-BHWE2Q9K.js → external-link-RaJbv6zJ.js} +1 -1
- package/dist/web/assets/{folder-y0Ib4FZ2.js → folder-BDc_dntN.js} +1 -1
- package/dist/web/assets/{index-D4bsP__r.js → index-Cqil5mhT.js} +4 -4
- package/dist/web/assets/{pause-dr9-0ZX_.js → pause-DcqIkSCj.js} +1 -1
- package/dist/web/assets/{pencil-BtXBcDA8.js → pencil-CuEcqcGd.js} +1 -1
- package/dist/web/assets/{play-CGxptupd.js → play-D-6oneXl.js} +1 -1
- package/dist/web/assets/{plus-DUJ7l4H3.js → plus-BszxRz9B.js} +1 -1
- package/dist/web/assets/{session-events-CGQa6VXb.js → session-events-Dwyp0AVI.js} +16 -14
- package/dist/web/assets/{settings-DFt3q7ma.js → settings-C2nXcRY-.js} +1 -1
- package/dist/web/assets/{team-C6IcokCI.js → team-CWZp-rb4.js} +1 -1
- package/dist/web/assets/{teamService-T8g5BXdN.js → teamService-Dyi2wFpb.js} +1 -1
- package/dist/web/assets/{terminal-DLip4ER9.js → terminal-ZQmTPaBq.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-2yqar0hx.js +0 -1
- package/dist/chunk-42mh48fg.js +0 -1
- package/dist/web/assets/SettingsModal-j0PEfToT.js +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a6 as e,T as t,a7 as r,p as m}from"./session-events-Dwyp0AVI.js";import{Z as s}from"./index-Cqil5mhT.js";import"./vendor-react-DofNRwfy.js";import"./vendor-radix-D6QrtXqd.js";const p=e(t.Object({id:t.String(),name:t.String(),subagentType:t.String(),description:t.String(),agentId:t.Optional(t.String()),status:r(["leader","running","completed","failed","cancelled","unknown"]),result:t.Optional(t.Unknown()),stats:t.Optional(t.Unknown()),worktreePath:t.Optional(t.String())})),d=e(t.Object({id:t.String(),subject:t.String(),description:t.String(),status:r(["pending","blocked","running","completed"]),owner:t.Optional(t.String()),priority:r(["high","medium","low"]),dependsOn:t.Array(t.String()),blocks:t.Array(t.String()),result:t.Optional(t.String()),createdAt:t.String(),startedAt:t.Optional(t.String()),completedAt:t.Optional(t.String())})),o=e(t.Object({name:t.String(),description:t.Optional(t.String()),status:r(["idle","running","completed","failed","deleted"]),leadAgentId:t.String(),leadSessionId:t.Optional(t.String()),workspaceRoot:t.Optional(t.String()),peerMessagingEnabled:t.Boolean(),createdAt:t.Number(),updatedAt:t.Number(),deletedAt:t.Optional(t.Number()),members:t.Array(p),tasks:t.Array(d)}));e(t.Object({sessionId:t.String({minLength:1}),projectPath:t.String({minLength:1}),name:t.String({minLength:1}),description:t.Optional(t.String()),leadAgentType:t.Optional(t.String()),peerMessagingEnabled:t.Optional(t.Boolean()),members:t.Array(t.Object({name:t.String({minLength:1}),subagentType:t.String({minLength:1}),description:t.Optional(t.String()),prompt:t.String({minLength:10,maxLength:32*1024})}),{maxItems:32}),tasks:t.Optional(t.Array(t.Object({subject:t.String({minLength:1}),description:t.String({minLength:1}),dependsOn:t.Optional(t.Array(t.String())),assignedTo:t.Optional(t.String()),priority:t.Optional(r(["high","medium","low"]))}),{maxItems:256}))}));e(t.Object({sessionId:t.String({minLength:1}),projectPath:t.String({minLength:1}),to:t.String({minLength:1}),message:t.String({minLength:1,maxLength:32*1024})}));e(t.Object({sessionId:t.String({minLength:1}),projectPath:t.String({minLength:1}),memberId:t.String({minLength:1})}));const S=t.Array(o),u={list:async n=>{const i=new URLSearchParams({sessionId:n.sessionId,projectPath:n.projectPath});return m(S,await s(`/teams?${i.toString()}`))},sendMessage:async(n,i,a,g)=>{await s(`/teams/${encodeURIComponent(i)}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId,projectPath:n.projectPath,to:a,message:g})})},delete:async(n,i)=>{const a=new URLSearchParams({sessionId:n.sessionId,projectPath:n.projectPath});return o.parse(await s(`/teams/${encodeURIComponent(i)}?${a.toString()}`,{method:"DELETE"}))}};export{u as teamService};
|
package/dist/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>BladeCode</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-Cqil5mhT.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-DofNRwfy.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-radix-D6QrtXqd.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-RGoMvYl5.css">
|
package/package.json
CHANGED
package/dist/chunk-2yqar0hx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as a,l as b,m as c,n as d,o as e}from"./chunk-14s52tht.js";import"./chunk-h0ka760f.js";import"./chunk-sdapqhj0.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
|
package/dist/chunk-42mh48fg.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{qf as a,rf as b}from"./chunk-559adewt.js";import"./chunk-h0ka760f.js";import"./chunk-sdapqhj0.js";export{a as globalOptions,b as cliConfig};
|
|
@@ -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,p as Me,j as D,A as Ue,L as ne,U as ea,C as gt,Z as q,D as $e,e as Ie,$ as Je,g as Ke,X as He,a0 as ta,a1 as aa,n as _t,a2 as sa,a as Le,O as Ut,a3 as Pe,T as ze,a4 as bt,P as na,r as ra,x as la,a5 as oa,a6 as ia}from"./index-D4bsP__r.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-DUJ7l4H3.js";import{E as jt,A as Ht}from"./external-link-BHWE2Q9K.js";import{D as mt}from"./download-D1w7sCBV.js";import{S as da}from"./ScrollArea-DzblNpCd.js";import{C as ca}from"./calendar-clock-UTpg6J58.js";import{P as ua}from"./play-CGxptupd.js";import{P as xt}from"./pencil-BtXBcDA8.js";import{A as ma,t as rt}from"./team-C6IcokCI.js";import{_ as xa}from"./session-events-CGQa6VXb.js";import{A as pa}from"./arrow-left-DaRjPuTX.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"},Ee=function(t){var a=n.useRef(t);a.current=n.useMemo(function(){return t},[t]);var s=n.useRef(void 0);return s.current||(s.current=function(){for(var l=[],r=0;r<arguments.length;r++)l[r]=arguments[r];return a.current.apply(this,l)}),s.current};const at=ba(n.useEffect);var qt=function(t,a){var s=a.manual,l=a.ready,r=l===void 0?!0:l,m=a.defaultParams,h=m===void 0?[]:m,g=a.refreshDeps,u=g===void 0?[]:g,i=a.refreshDepsAction,N=n.useRef(!1);return N.current=!1,at(function(){!s&&r&&(N.current=!0,t.run.apply(t,ie([],se(h),!1)))},[r]),at(function(){N.current||s||(N.current=!0,i?i():t.refresh())},ie([],se(u),!1)),{onBefore:function(){if(!r)return{stopNow:!0}}}};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={},Na=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)}},Ea=function(t,a){var s=a.cacheKey,l=a.cacheTime,r=l===void 0?5*60*1e3:l,m=a.staleTime,h=m===void 0?0:m,g=a.setCache,u=a.getCache,i=n.useRef(void 0),N=n.useRef(void 0),c=function(k,p){g?g(p):va(k,r,p),Na(k,p.data)},b=function(k,p){return p===void 0&&(p=[]),u?u(p):ka(k)};return Wt(function(){if(s){var k=b(s);k&&Object.hasOwnProperty.call(k,"data")&&(t.state.data=k.data,t.state.params=k.params,(h===-1||Date.now()-k.time<=h)&&(t.state.loading=!1)),i.current=lt(s,function(p){t.setState({data:p})})}},[]),Ye(function(){var k;(k=i.current)===null||k===void 0||k.call(i)}),s?{onBefore:function(k){var p=b(s,k);return!p||!Object.hasOwnProperty.call(p,"data")?{}:h===-1||Date.now()-p.time<=h?{loading:!1,data:p==null?void 0:p.data,error:void 0,returnNow:!0}:{data:p==null?void 0:p.data,error:void 0}},onRequest:function(k,p){var E=ja(s);return E&&E!==N.current?{servicePromise:E}:(E=k.apply(void 0,ie([],se(p),!1)),N.current=E,ya(s,E),{servicePromise:E})},onSuccess:function(k,p){var E;s&&((E=i.current)===null||E===void 0||E.call(i),c(s,{data:k,params:p,time:Date.now()}),i.current=lt(s,function(w){t.setState({data:w})}))},onMutate:function(k){var p;s&&((p=i.current)===null||p===void 0||p.call(i),c(s,{data:k,params:t.state.params,time:Date.now()}),i.current=lt(s,function(E){t.setState({data:E})}))}}:{}};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,Nt=Yt,Qa=qa,Xa=Va,Za="[object Null]",es="[object Undefined]",Et=Nt?Nt.toStringTag:void 0;function ts(t){return t==null?t===void 0?es:Za:Et&&Et 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,m,h,g,u,i=0,N=!1,c=!1,b=!0;if(typeof t!="function")throw new TypeError(vs);a=At(a)||0,bs(s)&&(N=!!s.leading,c="maxWait"in s,m=c?ks(At(s.maxWait)||0,a):m,b="trailing"in s?!!s.trailing:b);function k(S){var F=l,R=r;return l=r=void 0,i=S,h=t.apply(R,F),h}function p(S){return i=S,g=setTimeout(B,a),N?k(S):h}function E(S){var F=S-u,R=S-i,j=a-F;return c?js(j,m-R):j}function w(S){var F=S-u,R=S-i;return u===void 0||F>=a||F<0||c&&R>=m}function B(){var S=ot();if(w(S))return I(S);g=setTimeout(B,E(S))}function I(S){return g=void 0,b&&l?k(S):(l=r=void 0,h)}function y(){g!==void 0&&clearTimeout(g),i=0,l=u=r=g=void 0}function A(){return g===void 0?h:I(ot())}function U(){var S=ot(),F=w(S);if(l=arguments,r=this,u=S,F){if(g===void 0)return p(u);if(c)return clearTimeout(g),g=setTimeout(B,a),k(u)}return g===void 0&&(g=setTimeout(B,a)),h}return U.cancel=y,U.flush=A,U}var Qt=ys;const Xt=Kt(Qt);var Ns=function(t,a){var s=a.debounceWait,l=a.debounceLeading,r=a.debounceTrailing,m=a.debounceMaxWait,h=n.useRef(void 0),g=n.useMemo(function(){var u={};return l!==void 0&&(u.leading=l),r!==void 0&&(u.trailing=r),m!==void 0&&(u.maxWait=m),u},[l,r,m]);return n.useEffect(function(){if(s){var u=t.runAsync.bind(t);return h.current=Xt(function(i){i()},s,g),t.runAsync=function(){for(var i=[],N=0;N<arguments.length;N++)i[N]=arguments[N];return new Promise(function(c,b){var k;(k=h.current)===null||k===void 0||k.call(h,function(){u.apply(void 0,ie([],se(i),!1)).then(c).catch(b)})})},function(){var i;(i=h.current)===null||i===void 0||i.cancel(),t.runAsync=u}}},[s,g]),s?{onCancel:function(){var u;(u=h.current)===null||u===void 0||u.cancel()}}:{}},Es=function(t,a){var s=a.loadingDelay,l=a.ready,r=n.useRef(void 0);if(!s)return{};var m=function(){r.current&&clearTimeout(r.current)};return{onBefore:function(){return m(),l!==!1&&(r.current=setTimeout(function(){t.setState({loading:!0})},s)),{loading:!1}},onFinally:function(){m()},onCancel:function(){m()}}},Ve=!!(typeof window<"u"&&window.document&&window.document.createElement);function 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,m=a.pollingErrorRetryCount,h=m===void 0?-1:m,g=n.useRef(void 0),u=n.useRef(void 0),i=n.useRef(0),N=function(){var c;g.current&&clearTimeout(g.current),(c=u.current)===null||c===void 0||c.call(u)};return at(function(){s||N()},[s]),s?{onBefore:function(){N()},onError:function(){i.current+=1},onSuccess:function(){i.current=0},onFinally:function(){h===-1||h!==-1&&i.current<=h?g.current=setTimeout(function(){!r&&!kt()?u.current=ws(function(){t.refresh()}):t.refresh()},s):i.current=0},onCancel:function(){N()}}:{}};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,m=n.useRef(void 0),h=function(){var g;(g=m.current)===null||g===void 0||g.call(m)};return n.useEffect(function(){if(s){var g=Ss(t.refresh.bind(t),r);m.current=Ps(function(){g()})}return function(){h()}},[s,r]),Ye(function(){h()}),{}},Ts=function(t,a){var s=a.retryInterval,l=a.retryCount,r=n.useRef(void 0),m=n.useRef(0),h=n.useRef(!1);return l?{onBefore:function(){h.current||(m.current=0),h.current=!1,r.current&&clearTimeout(r.current)},onSuccess:function(){m.current=0},onError:function(){if(m.current+=1,l===-1||m.current<=l){var g=s??Math.min(1e3*Math.pow(2,m.current),3e4);r.current=setTimeout(function(){h.current=!0,t.refresh()},g)}else m.current=0},onCancel:function(){m.current=0,r.current&&clearTimeout(r.current)}}:{}},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,m=n.useRef(void 0),h={};return l!==void 0&&(h.leading=l),r!==void 0&&(h.trailing=r),n.useEffect(function(){if(s){var g=t.runAsync.bind(t);return m.current=$s(function(u){u()},s,h),t.runAsync=function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];return new Promise(function(N,c){var b;(b=m.current)===null||b===void 0||b.call(m,function(){g.apply(void 0,ie([],se(u),!1)).then(N).catch(c)})})},function(){var u;t.runAsync=g,(u=m.current)===null||u===void 0||u.cancel()}}},[s,l,r]),s?{onCancel:function(){var g;(g=m.current)===null||g===void 0||g.cancel()}}:{}},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 Ee(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(m){var h;return(h=m[a])===null||h===void 0?void 0:h.call.apply(h,ie([m],se(s),!1))}).filter(Boolean);return Object.assign.apply(Object,ie([{}],se(r),!1))},t.prototype.runAsync=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];return ct(this,void 0,void 0,function(){var l,r,m,h,g,u,i,N,c,b,k,p,E,w,B,I,y,A,U,S,F;return ut(this,function(R){switch(R.label){case 0:if(this.count+=1,l=this.count,r=this.runPluginHandler("onBefore",a),m=r.stopNow,h=m===void 0?!1:m,g=r.returnNow,u=g===void 0?!1:g,i=zt(r,["stopNow","returnNow"]),h)return[2,Promise.resolve(i.data)];if(this.setState(ke({loading:!0,params:a},i)),u)return[2,Promise.resolve(i.data)];(E=(p=this.options).onBefore)===null||E===void 0||E.call(p,a),R.label=1;case 1:return R.trys.push([1,3,,4]),N=this.runPluginHandler("onRequest",this.serviceRef.current,a).servicePromise,N||(N=(k=this.serviceRef).current.apply(k,ie([],se(a),!1))),[4,N];case 2:return c=R.sent(),l!==this.count?[2,new Promise(function(){})]:(this.setState({data:c,error:void 0,loading:!1}),(B=(w=this.options).onSuccess)===null||B===void 0||B.call(w,c,a),this.runPluginHandler("onSuccess",c,a),(y=(I=this.options).onFinally)===null||y===void 0||y.call(I,a,c,void 0),l===this.count&&this.runPluginHandler("onFinally",a,c,void 0),[2,c]);case 3:if(b=R.sent(),l!==this.count)return[2,new Promise(function(){})];throw this.setState({error:b,loading:!1}),(U=(A=this.options).onError)===null||U===void 0||U.call(A,b,a),this.runPluginHandler("onError",b,a),(F=(S=this.options).onFinally)===null||F===void 0||F.call(S,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,m=a.ready,h=m===void 0?!0:m,g=zt(a,["manual","ready"]),u=ke({manual:r,ready:h},g),i=nt(t),N=_s(),c=Wt(function(){var b=s.map(function(k){var p;return(p=k==null?void 0:k.onInit)===null||p===void 0?void 0:p.call(k,u)}).filter(Boolean);return new Us(i,u,N,Object.assign.apply(Object,ie([{}],se(b),!1)))},[]);return c.options=u,c.pluginImpls=s.map(function(b){return b(c,u)}),Ks(function(){if(!r&&h){var b=c.state.params||a.defaultParams||[];c.run.apply(c,ie([],se(b),!1))}}),Ye(function(){c.cancel()}),{loading:c.state.loading,data:c.state.data,error:c.state.error,params:c.state.params||[],cancel:Ee(c.cancel.bind(c)),refresh:Ee(c.refresh.bind(c)),refreshAsync:Ee(c.refreshAsync.bind(c)),run:Ee(c.run.bind(c)),runAsync:Ee(c.runAsync.bind(c)),mutate:Ee(c.mutate.bind(c))}}function _e(t,a,s){return zs(t,a,ie(ie([],se([]),!1),[Ns,Es,As,Bs,Is,qt,Ea,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 m=n.useRef(!1),h=n.useRef([]),g=n.useRef([]),u=n.useRef(void 0);t(function(){var i,N=Array.isArray(r)?r:[r],c=N.map(function(b){return st(b)});if(!m.current){m.current=!0,h.current=c,g.current=l,u.current=s();return}(c.length!==h.current.length||!pt(h.current,c)||!pt(g.current,l))&&((i=u.current)===null||i===void 0||i.call(u),h.current=c,g.current=l,u.current=s())}),Ye(function(){var i;(i=u.current)===null||i===void 0||i.call(u),m.current=!1})};return a},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,m=n.useMemo(function(){return Xt(function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];return l.current.apply(l,ie([],se(h),!1))},r,a)},[]);return Ye(function(){m.cancel()}),{run:m,cancel:m.cancel,flush:m.flush}}function Js(t,a,s){s===void 0&&(s={});var l=s.enable,r=l===void 0?!0:l,m=nt(a);Gs(function(){if(r){var h=st(s.target,window);if(h!=null&&h.addEventListener){var g=function(i){return m.current(i)},u=Array.isArray(t)?t:[t];return u.forEach(function(i){h.addEventListener(i,g,{capture:s.capture,once:s.once,passive:s.passive})}),function(){u.forEach(function(i){h.removeEventListener(i,g,{capture:s.capture})})}}}},[t,s.capture,s.once,s.passive,r],s.target)}var 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,m=r===void 0?100:r,h=a.direction,g=h===void 0?"bottom":h,u=a.reloadDeps,i=u===void 0?[]:u,N=a.manual,c=a.onBefore,b=a.onSuccess,k=a.onError,p=a.onFinally,E=se(n.useState(),2),w=E[0],B=E[1],I=se(n.useState(!1),2),y=I[0],A=I[1],U=g==="top",S=n.useRef(void 0),F=n.useRef(0),R=n.useMemo(function(){return l?l(w):!1},[w]),j=_e(function(L){return ct(void 0,void 0,void 0,function(){var C;return ut(this,function(v){switch(v.label){case 0:return[4,t(L)];case 1:return C=v.sent(),[2,{currentData:C,lastData:L}]}})})},{manual:N,onFinally:function(L,C,v){A(!1),p==null||p(C==null?void 0:C.currentData,v)},onBefore:function(){return c==null?void 0:c()},onSuccess:function(L){var C,v,M;L.lastData?B(ke(ke({},L.currentData),{list:U?ie(ie([],se(L.currentData.list),!1),se((v=L.lastData.list)!==null&&v!==void 0?v:[]),!1):ie(ie([],se((M=L.lastData.list)!==null&&M!==void 0?M:[]),!1),se(L.currentData.list),!1)})):B(ke(ke({},L.currentData),{list:ie([],se((C=L.currentData.list)!==null&&C!==void 0?C:[]),!1)})),setTimeout(function(){requestAnimationFrame(function(){if(U){var V=st(s);if(V=V===document?document.documentElement:V,V){var pe=Ft(V);V.scrollTo(0,pe-F.current)}}else te()})}),b==null||b(L.currentData)},onError:function(L){return k==null?void 0:k(L)}}),O=j.loading,Q=j.error,Y=j.run,Z=j.runAsync,ee=j.cancel,J=Ee(function(){R||(A(!0),Y(w))}),X=function(L){return ct(void 0,void 0,void 0,function(){var C;return ut(this,function(v){switch(v.label){case 0:return[4,Z(L)];case 1:return C=v.sent(),[2,C.currentData]}})})},T=Ee(function(){return R?Promise.reject():(A(!0),X(w))}),K=function(){return A(!1),Y()},G=function(){return A(!1),X()},te=function(){var L=st(s);if(L){var C=L===document?document.documentElement:L,v=Ys(C),M=Ft(C),V=Vs(C);U?(S.current!==void 0&&S.current>v&&v<=m&&J(),S.current=v,F.current=M-v):M-v<=V+m&&J()}};return Js("scroll",function(){O||y||te()},{target:s}),at(function(){Y()},ie([],se(i),!1)),{data:w,loading:!y&&O,error:Q,loadingMore:y,noMore:R,loadMore:J,loadMoreAsync:T,reload:Ee(K),reloadAsync:Ee(G),mutate:B,cancel:ee}};const 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(m=>m.package),total:r.total,hasMore:a+Bt<r.total}};function on({active:t}){const a=ge(),[s,l]=n.useState("installed"),[r,m]=n.useState(!1),[h,g]=n.useState(null),[u,i]=n.useState(""),[N,c]=n.useState(null),[b,k]=n.useState(null),[p,E]=n.useState(null),[w,B]=n.useState(null),[I,y]=n.useState(null),[A,U]=n.useState(""),[S,F]=n.useState(null),[R,j]=n.useState(!1),[O,Q]=n.useState(null),[Y,Z]=n.useState(null),[ee,J]=n.useState(""),[X,T]=n.useState(""),[K,G]=n.useState(null),[te,L]=n.useState(null),C=n.useRef(null),{run:v}=Ws(d=>{T(d)},{wait:500}),{data:M=[],loading:V,error:pe,run:Se,runAsync:le}=_e(an,{refreshDeps:[t],ready:t,onSuccess:d=>{d.length>0&&!h&&g(d[0].id)}}),{data:he,loading:we,error:ce,runAsync:Ce}=_e(sn,{manual:!0}),{data:de,loading:re,loadingMore:f,noMore:_,error:ae,reload:oe}=Qs(async d=>{var H;const W=((H=d==null?void 0:d.list)==null?void 0:H.length)??0;return ln(X,W)},{target:C,isNoMore:d=>!(d!=null&&d.hasMore),reloadDeps:[X],manual:!t||s!=="catalog"}),{runAsync:xe,loading:fe,error:be}=_e(async d=>{await q("/mcp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,config:d})})},{manual:!0,onSuccess:()=>{le(),m(!1),L(null),G(null)},onError:()=>{G(null)}}),Fe=n.useMemo(()=>{const d=u.trim().toLowerCase();return d?M.filter(W=>[W.name,W.endpoint,W.description].some(H=>H.toLowerCase().includes(d))):M},[u,M]),P=n.useMemo(()=>Fe.find(d=>d.id===h)??Fe[0],[Fe,h]),Be=n.useMemo(()=>{if(!P)return[];const d=(P.prompts??[]).flatMap(H=>H.arguments.map(ye=>({key:`prompt:${H.name}:${ye.name}`,label:`${H.name}.${ye.name}`,reference:{type:"prompt",name:H.name},argument:ye.name}))),W=(P.resourceTemplates??[]).flatMap(H=>(H.variables??[]).map(ye=>({key:`resource:${H.uriTemplate}:${ye}`,label:`${H.uriTemplate} · ${ye}`,reference:{type:"resource",uri:H.uriTemplate},argument:ye})));return[...d,...W]},[P]),ve=Be.find(d=>d.key===I)??Be[0];n.useEffect(()=>{if(!t||!M.some(W=>W.oauthStatus==="authorizing"||W.status==="connecting"||W.status==="reconnecting"))return;const d=window.setInterval(()=>{le()},1e3);return()=>window.clearInterval(d)},[t,le,M]),n.useEffect(()=>{b&&M.some(d=>d.name===b.serverName&&(d.oauthStatus==="authenticated"||d.oauthStatus==="disabled"||d.oauthStatus==="unavailable"))&&k(null)},[b,M]),n.useEffect(()=>{!t||s!=="installed"||!P||Ce(P.name).catch(()=>{})},[t,Ce,P,s]);const Re=async(d,W)=>{E({type:d,name:W}),c(null);try{const H=d==="delete"?"":`/${d}`;await q(`/mcp/${encodeURIComponent(W)}${H}`,{method:d==="delete"?"DELETE":"POST"}),await le(),d==="delete"&&(Z(null),g(null))}catch(H){c(H instanceof Error?H.message:a(d==="connect"?"mcp.error.connectFailed":d==="disconnect"?"mcp.error.disconnectFailed":"mcp.error.deleteFailed"))}finally{E(null)}},x=async(d,W)=>{E({type:d,name:W.name}),c(null);try{if(d==="login"){const H=await q(`/mcp/${encodeURIComponent(W.name)}/oauth/login`,{method:"POST"});k({serverName:W.name,url:H.authorizationUrl})}else await q(`/mcp/${encodeURIComponent(W.name)}/oauth/logout`,{method:"POST"}),k(null);await le()}catch(H){c(H instanceof Error?H.message:a(d==="login"?"mcp.error.loginFailed":"mcp.error.logoutFailed"))}finally{E(null)}},ue=async(d,W)=>{B(W),c(null);try{await q(`/mcp/${encodeURIComponent(d.name)}/logging-level`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:W})}),await le(),Ce(d.name).catch(()=>{})}catch(H){c(H instanceof Error?H.message:a("mcp.error.loggingLevelFailed"))}finally{B(null)}},Ne=async d=>{if(ve){j(!0),Q(null),F(null);try{const W=await q(`/mcp/${encodeURIComponent(d.name)}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:ve.reference,argument:{name:ve.argument,value:A}})});F(W)}catch(W){Q(W instanceof Error?W.message:a("mcp.error.completionFailed"))}finally{j(!1)}}},je=n.useMemo(()=>new Set(M.map(d=>d.name.toLowerCase())),[M]),o=d=>{L(d)},$=d=>d.startsWith("@modelcontextprotocol/"),z=d=>$(d.name)?"Official":"Community";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-4 p-4 min-h-0 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"MCP"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{onClick: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:V,children:e.jsx(Me,{className:D("h-4 w-4",V&&"animate-spin")})}),e.jsxs("button",{"data-mcp-add-server-trigger":!0,onClick:()=>m(!0),className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("mcp.action.addServer")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit shrink-0",children:[e.jsx(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")})]}),N&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:N}),e.jsx("button",{type:"button",onClick:()=>c(null),className:"underline shrink-0",children:a("mcp.action.dismiss")})]}),s==="installed"?e.jsxs("div",{className:"flex overflow-hidden flex-col flex-1 gap-3 min-h-0 sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:a("mcp.servers.title")}),e.jsx("input",{type:"search","aria-label":a("mcp.servers.searchAria"),value:u,onChange:d=>i(d.target.value),placeholder:a("mcp.servers.searchPlaceholder"),className:"h-8 shrink-0 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[12px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-2 pr-1 min-h-0",children:[V&&M.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"w-4 h-4 animate-spin"}),a("mcp.servers.loading")]}),pe&&!V&&e.jsxs("div",{role:"alert",className:"flex flex-col gap-2 items-center py-6 font-mono text-xs text-center text-red-600 dark:text-red-400",children:[e.jsx("span",{children:pe.message}),e.jsx("button",{type:"button",onClick: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&&!V&&Fe.length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(u?"mcp.servers.noMatch":"mcp.servers.none")}),Fe.map(d=>e.jsxs("button",{onClick:()=>{g(d.id),Z(null),c(null),y(null),U(""),F(null),Q(null)},className:D("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors shrink-0",d.id===(P==null?void 0:P.id)?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:d.name}),e.jsx("span",{className:D("text-[11px] font-mono font-semibold",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))]})]}),P?e.jsxs("div",{className:"flex overflow-y-auto flex-col flex-1 gap-3 pr-2 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center shrink-0",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:P.name}),e.jsx("span",{className:D("text-xs font-mono font-semibold",Pt[P.status]),children:Tt(P,a)})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:P.description}),P.error&&e.jsx("p",{className:"text-[12px] font-mono text-[#ef4444]",children:a("mcp.server.errorLabel",{error:P.error})}),P.instructions&&e.jsxs("div",{className:"rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.instructions.title")}),e.jsxs("span",{className:"truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",P.instructions.sha256]})]}),e.jsx("pre",{className:"mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:P.instructions.text??a("mcp.instructions.detailsOmittedByPolicy")}),(P.instructions.truncated||P.instructions.detailsOmitted)&&e.jsx("span",{className:"mt-1 block text-[9px] font-mono text-amber-600 dark:text-amber-400",children:P.instructions.detailsOmitted?a("mcp.instructions.detailsOmitted"):a("mcp.instructions.truncated")})]}),P.tasks&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tasks.title")}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:P.tasks.enabled?a("mcp.tasks.summary",{count:P.tasks.maxTasksPerSession,interval:P.tasks.pollIntervalMs}):a("mcp.tasks.disabledByDefault")})]}),e.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",P.tasks.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#9CA3AF] dark:text-[#71717a]"),children:P.tasks.enabled?a("mcp.tasks.enabled"):a("mcp.tasks.disabled")})]}),P.oauthEnabled&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-[#F3F4F6] px-3 py-2 dark:bg-[#18181b]",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-[#9CA3AF] dark:text-[#71717a]",children:"OAuth"}),e.jsx("span",{role:P.oauthStatus==="authorizing"?"status":void 0,className:D("text-[11px] font-mono",P.oauthStatus==="authenticated"?"text-[#16A34A] dark:text-[#22C55E]":P.oauthStatus==="error"?"text-[#ef4444]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a(Zs[P.oauthStatus])})]}),P.oauthStatus==="authenticated"?e.jsx("button",{type:"button",onClick:()=>void x("logout",P),disabled:p!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:(p==null?void 0:p.type)==="logout"?a("mcp.oauth.signingOut"):a("mcp.oauth.signOut")}):P.oauthStatus==="authorizing"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin text-[#2563eb]","aria-hidden":"true"}),(b==null?void 0:b.serverName)===P.name?e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-7 items-center rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white dark:bg-[#3b82f6]",children:a("mcp.oauth.continueAuthorization")}):e.jsx("button",{type:"button",onClick:()=>void x("login",P),disabled:p!==null,className:"h-7 rounded-md border border-[#D1D5DB] px-2.5 text-[11px] font-mono text-[#374151] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#d4d4d8]",children:a("mcp.oauth.resumeAuthorization")})]}):P.oauthStatus==="unavailable"?null:e.jsx("button",{type:"button",onClick:()=>void x("login",P),disabled:p!==null,className:"h-7 rounded-md bg-[#2563eb] px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:(p==null?void 0:p.type)==="login"?a("mcp.oauth.opening"):a("mcp.oauth.authorize")})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[P.status==="connected"||P.status==="reconnecting"?e.jsx("button",{onClick:()=>void Re("disconnect",P.name),disabled:p!==null,className:"h-7 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:(p==null?void 0:p.type)==="disconnect"&&p.name===P.name?a("mcp.action.disconnecting"):P.status==="reconnecting"?a("mcp.action.stopRecovery"):a("mcp.action.disconnect")}):e.jsx("button",{onClick:()=>void Re("connect",P.name),disabled:p!==null||P.oauthEnabled&&P.oauthStatus!=="authenticated",className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:(p==null?void 0:p.type)==="connect"&&p.name===P.name?a("mcp.action.connecting"):P.oauthEnabled&&P.oauthStatus!=="authenticated"?a("mcp.action.authorizeFirst"):a("mcp.action.connect")}),e.jsx("button",{onClick:()=>Z(P.name),disabled:p!==null,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold",children:a("mcp.action.delete")})]}),Y===P.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("mcp.server.deleteAria",{name:P.name}),className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:a("mcp.delete.confirm")}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>Z(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a("mcp.action.cancel")}),e.jsx("button",{type:"button",onClick:()=>void Re("delete",P.name),disabled:p!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(p==null?void 0:p.type)==="delete"?a("mcp.action.deleting"):a("mcp.action.deleteServer")})]})]}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.tools.title",{count:P.tools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:P.tools.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.tools.none")}):P.tools.map(d=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:d},d))}),e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.completion.title")}),P.status!=="connected"?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.connectPrompt")}):P.completionSupported?Be.length===0?e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.noTargets")}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{"aria-label":a("mcp.completion.targetAria"),className:"flex max-h-20 flex-wrap gap-1 overflow-y-auto",children:Be.map(d=>e.jsx("button",{type:"button","aria-pressed":(ve==null?void 0:ve.key)===d.key,onClick:()=>{y(d.key),F(null),Q(null)},className:D("max-w-full truncate rounded px-2 py-1 text-[10px] font-mono",(ve==null?void 0:ve.key)===d.key?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] dark:bg-[#18181b] dark:text-[#a1a1aa]"),children:d.label},d.key))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text","aria-label":a("mcp.completion.partialAria"),value:A,onChange:d=>U(d.target.value),placeholder:a("mcp.completion.partialPlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-transparent bg-[#F3F4F6] px-3 text-[11px] font-mono text-[#111827] outline-none placeholder:text-[#9CA3AF] focus:border-[#D1D5DB] dark:bg-[#18181b] dark:text-[#E5E5E5] dark:placeholder:text-[#71717a] dark:focus:border-[#3f3f46]"}),e.jsx("button",{type:"button",onClick:()=>void Ne(P),disabled:R,className:"h-8 shrink-0 rounded-md bg-[#2563eb] px-3 text-[11px] font-mono font-semibold text-white disabled:opacity-50 dark:bg-[#3b82f6]",children:a(R?"mcp.completion.completing":"mcp.completion.complete")})]}),O&&e.jsx("span",{role:"alert",className:"text-[11px] font-mono text-red-600 dark:text-red-400",children:O}),S&&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:S.values.length>0?S.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 ",S.sha256,S.truncated?a("mcp.meta.truncatedSuffix"):""]})]})]}):e.jsx("span",{className:"text-[12px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.completion.unsupported")}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("mcp.diagnostics.title")}),e.jsx("button",{type:"button","aria-label":a("mcp.diagnostics.refreshAria",{name:P.name}),onClick:()=>void Ce(P.name),disabled:we,className:"flex h-7 w-7 items-center justify-center rounded-md text-[#9CA3AF] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:text-[#71717a] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(Me,{className:D("h-3.5 w-3.5",we&&"animate-spin")})})]}),e.jsx("div",{"aria-label":a("mcp.log.levelAria"),className:"flex flex-wrap gap-1",children:tn.map(d=>{var W,H;return e.jsx("button",{type:"button",onClick:()=>void ue(P,d),disabled:P.status!=="connected"||w!==null,"aria-pressed":(((W=P.logging)==null?void 0:W.level)??"warning")===d,className:D("rounded px-2 py-1 text-[10px] font-mono transition-colors disabled:opacity-40",(((H=P.logging)==null?void 0:H.level)??"warning")===d?"bg-[#111827] text-white dark:bg-[#E5E5E5] dark:text-[#111827]":"bg-[#F3F4F6] text-[#6B7280] hover:text-[#111827] dark:bg-[#18181b] dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5]"),children:w===d?a("mcp.log.setting"):d},d)})}),ce?e.jsx("div",{role:"alert",className:"rounded-md bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:bg-red-950/30 dark:text-red-300",children:ce.message}):he!=null&&he.entries.length?e.jsx("div",{"aria-label":a("mcp.diagnostics.logsAria",{name:P.name}),className:"flex max-h-52 flex-col gap-1.5 overflow-y-auto rounded-md bg-[#F3F4F6] p-2 dark:bg-[#18181b]",children:he.entries.map(d=>e.jsxs("div",{className:"rounded bg-white px-2.5 py-2 dark:bg-[#0C0C0C]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:D("text-[10px] font-mono font-semibold uppercase",["error","critical","alert","emergency"].includes(d.level)?"text-red-600 dark:text-red-400":d.level==="warning"?"text-amber-600 dark:text-amber-400":"text-[#2563eb] dark:text-[#60a5fa]"),children:d.level}),e.jsxs("span",{className:"truncate text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[d.logger||P.name," · r",d.revision]})]}),e.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] font-mono text-[#374151] dark:text-[#d4d4d8]",children:d.message}),e.jsxs("span",{className:"mt-1 block truncate text-[9px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["sha256 ",d.dataSha256,d.truncated?a("mcp.meta.truncatedSuffix"):"",d.detailsOmitted?a("mcp.meta.detailsOmittedSuffix"):""]})]},d.revision))}):e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a(we?"mcp.log.loading":"mcp.log.none")})]}):e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a("mcp.server.selectPrompt")})})]}):e.jsxs("div",{className:"flex flex-col flex-1 gap-4 min-h-0",children:[e.jsx("div",{className:"flex gap-3 items-center shrink-0",children:e.jsxs("div",{className:"flex-1 h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] flex items-center px-3 gap-2",children:[e.jsx(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:ee,onChange:d=>{J(d.target.value),v(d.target.value)},placeholder:a("mcp.catalog.searchPlaceholder"),className:"flex-1 bg-transparent text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none"})]})}),e.jsxs("div",{ref:C,className:"overflow-y-auto flex-1 min-h-0",children:[ae?e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 items-center py-12 font-mono text-center",children:[e.jsx(Ue,{className:"w-6 h-6 text-red-500"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:ae.message}),e.jsx("button",{type:"button",onClick:oe,className:"rounded-md border border-[#E5E7EB] px-3 py-1.5 text-[11px] text-[#6B7280] dark:border-[#27272a] dark:text-[#a1a1aa]",children:a("mcp.catalog.retry")})]}):re&&!de?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx(ne,{className:"h-6 w-6 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 gap-3 pb-4 sm:grid-cols-2",children:[de==null?void 0:de.list.map(d=>{var me,Ge;const W=je.has(Zt(d.name).toLowerCase()),H=K===d.name,ye=z(d);return e.jsxs("div",{className:"rounded-lg bg-white dark:bg-[#0C0C0C] p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2 justify-between items-center",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] truncate",children:d.name}),e.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded shrink-0",ye==="Official"?"bg-[#16A34A]/20 dark:bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:a(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:H,className:"h-6 px-2 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-[10px] font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a] disabled:opacity-50",children:[e.jsx(mt,{className:D("h-3 w-3",H&&"animate-pulse")}),a(H?"mcp.catalog.installing":"mcp.catalog.install")]})]})]},d.name)}),(de==null?void 0:de.list.length)===0&&e.jsx("div",{className:"col-span-full py-12 text-center text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.noPackages")})]}),f&&e.jsx("div",{className:"flex justify-center items-center py-4",children:e.jsx(ne,{className:"h-5 w-5 text-[#9CA3AF] dark:text-[#71717a] animate-spin"})}),_&&de&&de.list.length>0&&e.jsx("div",{className:"text-center py-4 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.noMore")})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-[#E5E7EB] dark:border-[#1f2937] shrink-0",children:[e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:a("mcp.catalog.packagesFound",{count:(de==null?void 0:de.total)??0})}),e.jsxs("a",{href:"https://glama.ai/mcp/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[11px] font-mono text-[#3b82f6] hover:underline flex items-center gap-1",children:[a("mcp.catalog.browseGlama"),e.jsx(jt,{className:"w-3 h-3"})]})]})]})]})}),e.jsx(dn,{open:r,onOpenChange:m,onAdd:xe,saving:fe,error:(be==null?void 0:be.message)??null}),te&&e.jsx(cn,{pkg:te,onClose:()=>L(null),installing:fe,error:(be==null?void 0:be.message)??null,onInstall:d=>(G(te.name),xe(d))})]})}function Mt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function dn({open:t,onOpenChange:a,onAdd:s,saving:l,error:r}){const m=ge(),[h,g]=n.useState("form"),[u,i]=n.useState(""),[N,c]=n.useState(""),[b,k]=n.useState(""),[p,E]=n.useState(null),[w,B]=n.useState(`{
|
|
17
|
-
"name": "my-server",
|
|
18
|
-
"command": "npx",
|
|
19
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
20
|
-
}`);n.useEffect(()=>{t&&E(null)},[t]);const I=async()=>{if(E(null),h==="json"){let y;try{y=JSON.parse(w)}catch{E(m("mcp.add.invalidJson"));return}await s(y).catch(()=>{})}else{if(!u||!N){E(m("mcp.add.nameCommandRequired"));return}await s({name:u,command:N,args:b.split(" ").filter(Boolean)}).catch(()=>{})}};return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:y=>Je("[data-mcp-add-server-trigger]",y),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:m("mcp.add.title")}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:m("mcp.add.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":m("mcp.add.closeAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(Rt,{active:h==="form",onClick:()=>g("form"),children:m("mcp.add.modeForm")}),e.jsx(Rt,{active:h==="json",onClick:()=>g("json"),children:"JSON"})]}),h==="json"?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.jsonConfig")}),e.jsx("textarea",{"aria-label":m("mcp.add.jsonConfigAria"),className:"min-h-[140px] rounded-md bg-white dark:bg-[#0C0C0C] text-[#111827] dark:text-[#E5E5E5] font-mono text-[12px] p-3 border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]",value:w,onChange:y=>B(y.target.value)})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.serverName")}),e.jsx("input",{"aria-label":m("mcp.add.serverName"),type:"text",value:u,onChange:y=>i(y.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.command")}),e.jsx("input",{"aria-label":m("mcp.add.commandAria"),type:"text",value:N,onChange:y=>c(y.target.value),placeholder:"npx",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.argsLabel")}),e.jsx("input",{"aria-label":m("mcp.add.argsAria"),type:"text",value:b,onChange:y=>k(y.target.value),placeholder:"-y @modelcontextprotocol/server-filesystem /tmp",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]})]}),(p||r)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:p||r}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:()=>a(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:m("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void I(),disabled:l,className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60",children:m(l?"mcp.add.adding":"mcp.add.submit")})]})]})]})})}function cn({pkg:t,onClose:a,onInstall:s,installing:l,error:r}){const m=ge(),h=Zt(t.name),[g,u]=n.useState(h),[i,N]=n.useState(`-y ${t.name}`),[c,b]=n.useState(null),k=async()=>{if(b(null),!g.trim()){b(m("mcp.install.nameRequired"));return}await s({name:g.trim(),command:"npx",args:i.split(" ").filter(Boolean)}).catch(()=>{})};return e.jsx($e,{open:!0,onOpenChange:a,children:e.jsxs(Ie,{className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:m("mcp.install.titleWithName",{name:t.name})}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:m("mcp.install.title")}),e.jsx("button",{onClick:a,"aria-label":m("mcp.install.closeAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"rounded-md bg-white dark:bg-[#0C0C0C] p-3",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] mt-1",children:t.description||m("mcp.catalog.noDescription")})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.add.serverName")}),e.jsx("input",{"aria-label":m("mcp.add.serverName"),type:"text",value:g,onChange:p=>u(p.target.value),placeholder:"my-server",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:m("mcp.install.args")}),e.jsx("input",{"aria-label":m("mcp.add.argsAria"),type:"text",value:i,onChange:p=>N(p.target.value),placeholder:"-y package-name",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] font-mono text-[#111827] dark:text-[#E5E5E5] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:border-[#27272a]"}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:m("mcp.install.commandPreview",{args:i})})]})]}),(c||r)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:c||r}),e.jsxs("div",{className:"flex gap-2 justify-end items-center pt-2",children:[e.jsx("button",{onClick:a,className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:m("mcp.action.cancel")}),e.jsx("button",{onClick:()=>void k(),disabled:l,className:"h-7 px-3 rounded-md bg-[#16A34A] dark:bg-[#22C55E] text-white dark:text-[#0C0C0C] text-[11px] font-mono font-semibold disabled:opacity-60",children:m(l?"mcp.catalog.installing":"mcp.catalog.install")})]})]})]})})}function Rt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function Ae({value:t,onChange:a,options:s,placeholder:l="Select...",disabled:r=!1,className:m,"aria-label":h}){const[g,u]=n.useState(!1),[i,N]=n.useState(-1),c=n.useRef(null),b=s.find(p=>p.value===t);n.useEffect(()=>{if(g){const p=s.findIndex(E=>E.value===t);N(p>=0?p:0)}},[g,s,t]);const k=p=>{if(!r){if(!g){(p.key==="Enter"||p.key===" "||p.key==="ArrowDown")&&(p.preventDefault(),u(!0));return}switch(p.key){case"ArrowDown":p.preventDefault(),N(E=>Math.min(E+1,s.length-1));break;case"ArrowUp":p.preventDefault(),N(E=>Math.max(E-1,0));break;case"Enter":case" ":p.preventDefault(),i>=0&&i<s.length&&(a(s[i].value),u(!1));break;case"Escape":p.preventDefault(),u(!1);break}}};return n.useEffect(()=>{var E;if(!g||i<0)return;const p=(E=c.current)==null?void 0:E.children[i];p==null||p.scrollIntoView({block:"nearest"})},[i,g]),e.jsxs(ta,{open:g,onOpenChange:u,children:[e.jsx(aa,{asChild:!0,children:e.jsxs("button",{type:"button",role:"combobox","aria-expanded":g,"aria-haspopup":"listbox","aria-label":h,disabled:r,onKeyDown:k,className:D("field flex items-center justify-between gap-2 text-left",!b&&"text-zinc-400 dark:text-zinc-500",r&&"cursor-not-allowed opacity-50",m),children:[e.jsx("span",{className:"truncate",children:b?b.label:l}),e.jsx(_t,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),e.jsx(sa,{align:"start",sideOffset:4,onKeyDown:k,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:c,role:"listbox",children:s.map((p,E)=>e.jsxs("button",{type:"button",role:"option","aria-selected":p.value===t,"data-value":p.value,"data-highlighted":E===i||void 0,onClick:()=>{a(p.value),u(!1)},onMouseEnter:()=>N(E),className:D("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left font-mono text-[13px] outline-none transition-colors",E===i&&"bg-zinc-100 dark:bg-zinc-800",p.value===t&&"text-zinc-900 dark:text-zinc-50 font-medium"),children:[e.jsx(gt,{className:D("h-3.5 w-3.5 shrink-0",p.value===t?"opacity-100":"opacity-0")}),e.jsx("span",{className:"truncate",children:p.label})]},p.value))})})})]})}const 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),m=s??l??new URLSearchParams(window.location.search).get("project")??"",h=Pe(x=>x.schedules),g=Pe(x=>x.isLoading),u=Pe(x=>x.error),i=Pe(x=>x.loadSchedules),N=Pe(x=>x.createSchedule),c=Pe(x=>x.updateSchedule),b=Pe(x=>x.deleteSchedule),k=Pe(x=>x.toggleSchedule),p=Pe(x=>x.runSchedule),[E,w]=n.useState(!1),[B,I]=n.useState("cron"),[y,A]=n.useState(""),[U,S]=n.useState(""),[F,R]=n.useState(""),[j,O]=n.useState(""),[Q,Y]=n.useState(""),[Z,ee]=n.useState(""),[J,X]=n.useState(""),[T,K]=n.useState("default"),[G,te]=n.useState("worktree"),[L,C]=n.useState(!1),[v,M]=n.useState(null),[V,pe]=n.useState(null),[Se,le]=n.useState(null),[he,we]=n.useState(""),[ce,Ce]=n.useState(!0),[de,re]=n.useState(null),f=n.useRef(!1);n.useEffect(()=>{t&&!f.current&&(f.current=!0,i()),t||(f.current=!1)},[t,i]);const _=de??u,ae=v!==null||L,oe=()=>{w(!0),I("cron"),A(""),S(""),R(""),O(""),Y(m),ee(""),X(""),K("default"),te("worktree"),re(null)},xe=()=>{w(!1),re(null)},fe=async()=>{re(null);const x=j.trim();if(!x){re(a("schedule.error.promptRequired"));return}const ue=Q.trim();if(!ue){re(a("schedule.error.projectRequired"));return}let Ne;if(B==="cron"){const o=y.trim();if(!o){re(a("schedule.error.cronRequired"));return}Ne={kind:"cron",cron:o}}else if(B==="interval"){const o=fn(U);if(o===null){re(a("schedule.error.invalidInterval"));return}Ne={kind:"interval",intervalMs:o}}else{const o=F?new Date(F):null;if(!o||Number.isNaN(o.getTime())){re(a("schedule.error.runAtRequired"));return}Ne={kind:"once",runAt:o.toISOString()}}const je={prompt:x,projectPath:ue,trigger:Ne,permissionMode:T,isolation:G,enabled:!0};Z.trim()&&(je.title=Z.trim()),J.trim()&&(je.modelId=J.trim()),C(!0);try{await N(je),w(!1)}catch{}finally{C(!1)}},be=async x=>{re(null),M(`run:${x.id}`);try{await p(x.id)}catch{}finally{M(null)}},Fe=async x=>{re(null),M(`toggle:${x.id}`);try{await k(x.id,!x.enabled)}catch{}finally{M(null)}},P=async x=>{const ue=`delete:${x.id}`;if(V!==ue){pe(ue);return}re(null),M(ue);try{await b(x.id),pe(null)}catch{}finally{M(null)}},Be=x=>{le(x.id),we(x.prompt),Ce(x.enabled),re(null)},ve=async x=>{const ue=he.trim();if(!ue){re(a("schedule.error.promptRequired"));return}re(null),M(`edit:${x.id}`);try{await c(x.id,{prompt:ue,enabled:ce}),le(null)}catch{}finally{M(null)}},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 i(),disabled:g||ae,"aria-label":a("schedule.reloadAria"),className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),a("schedule.refresh")]}),e.jsxs("button",{type:"button",onClick:()=>E?xe():oe(),disabled:ae,"aria-label":a("schedule.newAria"),className:"inline-flex h-8 items-center gap-1 rounded-md bg-[#111827] px-3 text-[11px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("schedule.new")]})]})]}),_&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:_}),E&&e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsx("div",{role:"radiogroup","aria-label":a("schedule.trigger.kindAria"),className:"flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]",children:un.map(x=>e.jsx("button",{type:"button",role:"radio","aria-checked":B===x.value,onClick:()=>I(x.value),className:D("flex-1 rounded px-2 py-1 text-[10px] transition-colors",B===x.value?"bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]"),children:a(x.labelKey)},x.value))}),e.jsxs("div",{className:"mt-2.5",children:[B==="cron"&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.cron")}),e.jsx("input",{value:y,onChange:x=>A(x.target.value),placeholder:a("schedule.placeholder.cron"),"aria-label":a("schedule.field.cron"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),B==="interval"&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.interval")}),e.jsx("input",{value:U,onChange:x=>S(x.target.value),placeholder:a("schedule.placeholder.interval"),"aria-label":a("schedule.field.interval"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),B==="once"&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.runAt")}),e.jsx("input",{type:"datetime-local",value:F,onChange:x=>R(x.target.value),"aria-label":a("schedule.field.runAt"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]})]}),e.jsxs("label",{className:"mt-2.5 block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.title")}),e.jsx("input",{value:Z,onChange:x=>ee(x.target.value),placeholder:a("schedule.placeholder.title"),"aria-label":a("schedule.field.title"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),e.jsxs("label",{className:"mt-2.5 block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.prompt")}),e.jsx("textarea",{value:j,onChange:x=>O(x.target.value),placeholder:a("schedule.placeholder.prompt"),"aria-label":a("schedule.field.prompt"),rows:3,className:"field mt-1 h-auto resize-y py-1.5 text-[10.5px]"})]}),e.jsxs("label",{className:"mt-2.5 block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.project")}),e.jsx("input",{value:Q,onChange:x=>Y(x.target.value),placeholder:a("schedule.placeholder.project"),"aria-label":a("schedule.field.project"),className:"field mt-1 h-8 px-2 text-[10.5px]"})]}),e.jsxs("div",{className:"mt-2.5 grid gap-2 sm:grid-cols-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.model")}),e.jsx(Ae,{value:J,onChange:X,placeholder:a("schedule.model.current"),"aria-label":a("schedule.field.model"),className:"field mt-1 h-8 px-2 text-[10.5px]",options:[{value:"",label:a("schedule.model.current")},...r.map(x=>({value:x.id,label:x.displayName||x.model}))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:a("schedule.field.permissionMode")}),e.jsx(Ae,{value:T,onChange:x=>K(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:G,onChange:x=>te(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:[h.map(x=>{const ue=Se===x.id,Ne=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:D("rounded px-1.5 py-0.5 text-[9px]",x.enabled?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":"bg-[#F3F4F6] text-[#9CA3AF] dark:bg-[#27272a]"),children:x.enabled?a("schedule.enabled"):a("schedule.disabled")})]}),ue?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{value:he,onChange:je=>we(je.target.value),"aria-label":a("schedule.field.prompt"),rows:3,className:"field h-auto resize-y py-1.5 text-[10.5px]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":ce,"aria-label":ce?a("schedule.disableAria",{title:x.title||x.prompt}):a("schedule.enableAria",{title:x.title||x.prompt}),onClick:()=>Ce(je=>!je),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("flex h-5 w-9 items-center rounded-full px-1 transition-colors",ce?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-3.5 w-3.5 rounded-full bg-white transition-transform",ce?"translate-x-4":"translate-x-0")})}),a(ce?"schedule.enabled":"schedule.disabled")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>le(null),disabled:ae,className:"inline-flex h-7 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[9.5px] text-[#6B7280] disabled:opacity-40 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:a("schedule.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void ve(x),disabled:ae,className:"inline-flex h-7 items-center gap-1 rounded-md bg-[#111827] px-2 text-[9.5px] text-white disabled:opacity-40 dark:bg-[#E5E5E5] dark:text-[#18181b]",children:[v===`edit:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(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")," · ",Ne," · ",a("schedule.runCount",{count:x.runCount})]}),x.lastError&&e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:x.lastError})]})]}),!ue&&e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":x.enabled,"aria-label":x.enabled?a("schedule.disableAria",{title:x.title||x.prompt}):a("schedule.enableAria",{title:x.title||x.prompt}),disabled:ae,onClick:()=>void Fe(x),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",x.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",x.enabled?"translate-x-5":"translate-x-0")})}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":a("schedule.runNowAria",{title:x.title||x.prompt}),onClick:()=>void be(x),disabled:ae,className:"rounded p-1 text-[#6B7280] hover:bg-[#F3F4F6] disabled:opacity-40 dark:text-[#a1a1aa] dark:hover:bg-[#27272a]",children:v===`run:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(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 P(x),disabled:ae,className:D("rounded p-1 text-[9px] disabled:opacity-40",V===`delete:${x.id}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"text-[#9CA3AF] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:v===`delete:${x.id}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):V===`delete:${x.id}`?e.jsx("span",{className:"px-0.5 text-[8.5px]",children:a("schedule.confirmDelete")}):e.jsx(ze,{className:"h-3 w-3"})})]})]})]},x.id)}),!g&&h.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:a("schedule.empty")})]})]})}const 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(C=>{var v,M;return((v=C.currentSessionRef)==null?void 0:v.projectPath)??C.selectedProjectPath??((M=C.taskWorkspaceInfo)==null?void 0:M.cwd)??null}),[l,r]=n.useState(null),[m,h]=n.useState(""),[g,u]=n.useState(null),[i,N]=n.useState(null),[c,b]=n.useState(null),[k,p]=n.useState(!1),[E,w]=n.useState(!1),[B,I]=n.useState("confirm"),[y,A]=n.useState(null),[U,S]=n.useState(null),{data:F=[],loading:R,error:j,run:O,runAsync:Q}=_e(()=>bn(s),{refreshDeps:[t,s],ready:t,onSuccess:C=>{C.length>0&&!l&&r(C[0].id)}}),{data:Y=[],loading:Z,error:ee,run:J}=_e(vn,{refreshDeps:[t],ready:t}),X=F.filter(C=>C.name.toLowerCase().includes(m.toLowerCase())),T=n.useMemo(()=>F.find(C=>C.id===l)??F[0],[F,l]),K=async(C,v,M)=>{N({type:C,name:v.name}),u(null);try{await q(C==="delete"?`/skills/${encodeURIComponent(v.name)}`:`/skills/${encodeURIComponent(v.name)}/toggle`,{method:C==="delete"?"DELETE":"POST",headers:{...ft(s),...C==="toggle"?{"Content-Type":"application/json"}:{}},body:C==="toggle"?JSON.stringify({enabled:M}):void 0}),await Q(),C==="delete"&&(b(null),r(null))}catch(V){u(V instanceof Error?V.message:a(C==="delete"?"skills.error.deleteFailed":"skills.error.toggleFailed"))}finally{N(null)}},G=()=>{p(!0)},te=C=>{S(C),A(null),I("confirm"),w(!0)},L=async()=>{if(U){I("installing"),A(null);try{const C=await q("/skills/install",{method:"POST",headers:{"Content-Type":"application/json",...ft(s)},body:JSON.stringify(U)});if(C.success===!1)throw new Error(C.error||a("skills.error.installFailed"));await Q(),w(!1),p(!1)}catch(C){A(C instanceof Error?C.message:a("skills.error.installFailed")),I("failed")}}};return e.jsxs(n.Fragment,{children:[e.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col gap-4 p-4 sm:gap-5 sm:p-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:a("skills.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{"data-skill-install-trigger":!0,onClick:G,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),a("skills.action.install")]}),e.jsx("button",{onClick:O,"aria-label":a("skills.action.refreshAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:R,children:e.jsx(Me,{className:D("h-4 w-4",R&&"animate-spin")})})]})]}),g&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:g}),e.jsx("button",{type:"button",onClick:()=>u(null),className:"shrink-0 underline",children:a("skills.action.dismiss")})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden sm:flex-row sm:gap-5",children:[e.jsxs("div",{className:"flex h-[180px] w-full shrink-0 flex-col gap-3 overflow-hidden sm:h-auto sm:w-[220px]",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:a("skills.installed.title")}),e.jsx("input",{type:"search","aria-label":a("skills.installed.searchAria"),value:m,onChange:C=>h(C.target.value),placeholder:a("skills.installed.searchPlaceholder"),className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[R&&F.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),a("skills.installed.loading")]}),j&&!R&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:j.message}),e.jsx("button",{type:"button",onClick:O,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:a("skills.action.retry")})]}),!j&&X.length===0&&!R&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a(m?"skills.installed.noMatch":"skills.installed.empty")}),X.map(C=>e.jsxs("button",{onClick:()=>{r(C.id),b(null),u(null)},className:D("flex w-full min-w-0 flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors",C.id===l?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:C.name}),e.jsx("span",{className:D("text-[11px] font-mono font-semibold",C.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:C.enabled?a("skills.status.enabled"):a("skills.status.disabled")})]}),e.jsx("span",{className:"block w-full min-w-0 truncate text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:C.description||a("skills.noDescriptionShort")})]},C.id))]})]}),T?e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:T.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",T.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:T.description||a("skills.noDescription")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void K("toggle",T,!T.enabled),disabled:i!==null,className:D("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",T.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",i&&"opacity-60 cursor-not-allowed"),children:(i==null?void 0:i.type)==="toggle"&&i.name===T.name?a("skills.action.saving"):T.enabled?a("skills.action.disable"):a("skills.action.enable")}),e.jsxs("button",{onClick:()=>b(T.name),disabled:!T.removable||i!==null,title:T.removable?void 0:a("skills.uninstall.managedHint"),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ze,{className:"h-3 w-3"}),T.removable?a("skills.uninstall.action"):a("skills.uninstall.managed")]})]}),c===T.name&&e.jsxs("div",{role:"alertdialog","aria-label":a("skills.uninstall.confirmAria",{name:T.name}),className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:a("skills.uninstall.confirmPrompt")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>b(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:a("skills.action.cancel")}),e.jsx("button",{type:"button",onClick:()=>void K("delete",T),disabled:i!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(i==null?void 0:i.type)==="delete"?a("skills.uninstall.inProgress"):a("skills.uninstall.confirm")})]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.title")}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:a("skills.details.provider")}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:T.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:a("skills.details.location")}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:T.location})]})]}),T.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.capabilities")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.capabilities.map(C=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:C},C))})]}),T.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:a("skills.details.allowedTools",{count:T.allowedTools.length})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.allowedTools.map(C=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:C},C))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:a("skills.detail.emptyState")})})]})]}),e.jsx(jn,{open:k,catalog:Y,installed:F.map(C=>C.name),catalogLoading:Z,catalogError:(ee==null?void 0:ee.message)??null,onRetryCatalog:J,onOpenChange:p,onInstall:te}),e.jsx(yn,{open:E,status:B,error:y,onCancel:()=>w(!1),onConfirm:L,onRetry:()=>I("confirm")})]})}function dt({active:t,children:a,onClick:s}){return e.jsx("button",{onClick:s,className:D("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",t?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:a})}function jn({open:t,onOpenChange:a,onInstall:s,catalog:l,installed:r,catalogLoading:m,catalogError:h,onRetryCatalog:g}){const u=ge(),[i,N]=n.useState("catalog"),[c,b]=n.useState(""),[k,p]=n.useState(null),[E,w]=n.useState(""),[B,I]=n.useState(""),y=l.filter(F=>F.name.toLowerCase().includes(c.toLowerCase())),A=()=>{if(i==="catalog"){if(!k)return;s({source:"catalog",name:k});return}if(i==="repo"){if(!E)return;s({source:"repo",url:E});return}B&&s({source:"local",path:B})},U=k?r.includes(k):!1,S=i==="catalog"&&(!k||U||m||!!h)||i==="repo"&&!E||i==="local"&&!B;return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:F=>Je("[data-skill-install-trigger]",F),className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[540px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:u("skills.install.title")}),e.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:u("skills.install.title")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":u("skills.install.closeAria"),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(He,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(dt,{active:i==="catalog",onClick:()=>N("catalog"),children:u("skills.install.tab.catalog")}),e.jsx(dt,{active:i==="repo",onClick:()=>N("repo"),children:u("skills.install.tab.repo")}),e.jsx(dt,{active:i==="local",onClick:()=>N("local"),children:u("skills.install.tab.local")})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[i==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{"aria-label":u("skills.install.catalog.searchAria"),value:c,onChange:F=>b(F.target.value),placeholder:u("skills.install.catalog.searchPlaceholder"),className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex max-h-[min(240px,30dvh)] flex-col gap-2 overflow-y-auto",children:[m&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-6 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),u("skills.install.catalog.loading")]}),h&&!m&&e.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-2 py-6 text-center text-xs font-mono text-red-600 dark:text-red-400",children:[e.jsx("span",{children:h}),e.jsx("button",{type:"button",onClick:g,className:"rounded-md border border-red-200 px-2.5 py-1 text-[11px] dark:border-red-900",children:u("skills.action.retry")})]}),!m&&!h&&y.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:u("skills.install.catalog.empty")}),!m&&!h&&y.map(F=>{const R=r.includes(F.name),j=k===F.name;return e.jsxs("button",{onClick:()=>p(F.name),className:D("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",j?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:F.name}),e.jsx("span",{className:D("text-[10px] font-mono px-2 py-0.5 rounded",F.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:Ot[F.tag]?u(Ot[F.tag]):F.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:F.description}),e.jsx("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:u("skills.install.catalog.byAuthor",{author:F.author})}),R&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:u("skills.status.installed")})]},F.name)})]})]}),i==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:u("skills.install.repo.label")}),e.jsx("input",{"aria-label":u("skills.install.repo.inputAria"),value:E,onChange:F=>w(F.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:u("skills.install.repo.credentialsHint")})]}),i==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:u("skills.install.local.label")}),e.jsx("input",{"aria-label":u("skills.install.local.inputAria"),value:B,onChange:F=>I(F.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>a(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:u("skills.action.cancel")}),e.jsx("button",{onClick:A,disabled:S,className:D("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",S?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:u("skills.action.installShort")})]})]})]})})}function yn({open:t,status:a,error:s,onCancel:l,onConfirm:r,onRetry:m}){const h=ge();return e.jsx($e,{open:t,onOpenChange:g=>!g&&l(),children:e.jsxs(Ie,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:h("skills.status.dialogTitle")}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[a==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:h("skills.status.confirm.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:h("skills.status.confirm.prompt")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:l,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:h("skills.action.cancel")}),e.jsx("button",{onClick:r,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:h("skills.action.installShort")})]})]}),a==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:h("skills.status.installing.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:h("skills.status.installing.description")}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:l,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:h("skills.action.hide")})]}),a==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:h("skills.status.failed.title")}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:s||h("skills.status.failed.fallback")}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:h("skills.status.failed.hint")}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:l,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:h("skills.action.close")}),e.jsx("button",{onClick:m,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:h("skills.action.retry")})]})]})]})]})})}const Nn=[{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"}],En=/^[a-z][a-z0-9._-]{0,63}$/;function wn({open:t,onOpenChange:a,onSave:s,saveError:l}){const r=ge(),[m,h]=n.useState([]),[g,u]=n.useState([]),[i,N]=n.useState(),[c,b]=n.useState(),[k,p]=n.useState(""),[E,w]=n.useState(""),[B,I]=n.useState(""),[y,A]=n.useState(""),[U,S]=n.useState(""),[F,R]=n.useState(""),[j,O]=n.useState(!1),[Q,Y]=n.useState(!1),[Z,ee]=n.useState(!1),[J,X]=n.useState(!1),[T,K]=n.useState(null);n.useEffect(()=>{if(!t)return;let v=!0;return u([]),N(void 0),b(void 0),p(""),w(""),I(""),A(""),S(""),R(""),O(!1),K(null),Y(!0),q("/providers").then(M=>{v&&h(M)}).catch(M=>{v&&K(M instanceof Error?M.message:r("settings.models.addModal.loadProvidersError"))}).finally(()=>{v&&Y(!1)}),()=>{v=!1}},[t,r]),n.useEffect(()=>{if(!i)return;let v=!0;return u([]),b(void 0),K(null),i.factoryWireApi||i.custom?(ee(!1),()=>{v=!1}):(ee(!0),q(`/providers/${i.id}/models`).then(M=>{v&&u(M)}).catch(M=>{v&&K(M instanceof Error?M.message:r("settings.models.addModal.loadModelsError"))}).finally(()=>{v&&ee(!1)}),()=>{v=!1})},[i,r]);const G=i==null?void 0:i.factoryWireApi,te=!!(G||i!=null&&i.custom),L=te?y.trim():c==null?void 0:c.id,C=async()=>{if(!i||!L||!i.configured&&!F)return;if(G){if(!En.test(E.trim())){K(r("settings.models.addModal.channelIdError"));return}let V;try{V=new URL(U.trim())}catch{K(r("settings.models.addModal.invalidBaseUrl"));return}if(!["http:","https:"].includes(V.protocol)){K(r("settings.models.addModal.invalidBaseUrl"));return}}X(!0);const v=G?E.trim():i.id,M=await s({provider:v,model:L,displayName:k||(te?L:(c==null?void 0:c.name)??""),apiKey:F||void 0,...G?{modelProvider:{id:v,name:B.trim()||v,baseUrl:U.trim(),wireApi:G}}:{}});X(!1),M&&a(!1)};return e.jsx($e,{open:t,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:v=>Je("[data-add-model-trigger]",v),onEscapeKeyDown:v=>{v.preventDefault(),a(!1)},onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),v.stopPropagation(),a(!1))},className:"gap-0 overflow-y-auto rounded-xl border border-[#E5E7EB] bg-white p-0 dark:border-zinc-800 dark:bg-[#09090b] sm:max-w-[480px]","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:r("settings.models.addModal.title")}),e.jsxs("div",{className:"flex flex-col gap-5 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-mono text-base font-semibold",children:r("settings.models.addModal.title")}),e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":r("settings.models.addModal.close"),className:"flex h-8 w-8 items-center justify-center rounded-md",children:e.jsx(He,{className:"h-4 w-4"})})]}),(T||l)&&e.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:T||l})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.provider"),e.jsx(Ae,{"aria-label":r("settings.models.addModal.provider"),value:(i==null?void 0:i.id)??"",disabled:Q,onChange:v=>{N(m.find(M=>M.id===v)),p(""),w(""),I(""),A(""),S("")},placeholder:r(Q?"settings.models.addModal.loadingProviders":"settings.models.addModal.selectProvider"),options:m.map(v=>{const M=v.factoryWireApi==="openai-completions"?r("settings.models.addModal.customOpenAI"):v.factoryWireApi==="anthropic-messages"?r("settings.models.addModal.customAnthropic"):v.name;return{value:v.id,label:`${M} (${v.modelCount})${v.configured?r("settings.models.addModal.configuredSuffix"):""}`}})})]}),te?e.jsxs(e.Fragment,{children:[G&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.channelId"),e.jsx("input",{"aria-label":r("settings.models.addModal.channelId"),value:E,onChange:v=>{w(v.target.value),K(null)},placeholder:"team-gateway",autoComplete:"off",spellCheck:!1,className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:r("settings.models.addModal.channelIdHint")})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.channelName"),e.jsx("input",{"aria-label":r("settings.models.addModal.channelName"),value:B,onChange:v=>I(v.target.value),placeholder:"Team Gateway",className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.baseUrl"),e.jsx("input",{"aria-label":r("settings.models.addModal.baseUrl"),value:U,onChange:v=>{S(v.target.value),K(null)},placeholder:G==="anthropic-messages"?"https://gateway.example.com":"https://gateway.example.com/v1",className:"field"}),e.jsx("span",{className:"text-[11px] text-zinc-400",children:r(G==="anthropic-messages"?"settings.models.addModal.anthropicProtocol":"settings.models.addModal.openaiProtocol")})]})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.modelId"),e.jsx("input",{"aria-label":r("settings.models.addModal.modelId"),value:y,onChange:v=>{A(v.target.value),K(null)},placeholder:"vendor-model-2026",className:"field"})]})]}):e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.model"),e.jsx(Ae,{"aria-label":r("settings.models.addModal.model"),value:(c==null?void 0:c.id)??"",disabled:!i||Z,onChange:v=>{const M=g.find(V=>V.id===v);b(M),M&&p(M.name)},placeholder:r(Z?"settings.models.addModal.loadingModels":"settings.models.addModal.selectModel"),options:g.map(v=>({value:v.id,label:`${v.name} - ${Math.round(v.contextWindow/1e3)}K${v.reasoning?r("settings.models.addModal.reasoningSuffix"):""}${v.input.includes("image")?r("settings.models.addModal.visionSuffix"):""}`}))})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.displayName"),e.jsx("input",{value:k,onChange:v=>p(v.target.value),placeholder:(c==null?void 0:c.name)??r("settings.models.addModal.displayNamePlaceholder"),className:"field"})]}),(i==null?void 0:i.supportsApiKey)&&!i.configured&&e.jsxs("label",{className:"flex flex-col gap-2 text-[13px] font-mono text-zinc-500",children:[r("settings.models.addModal.apiKey"),e.jsxs("span",{className:"relative",children:[e.jsx("input",{"aria-label":r("settings.models.addModal.apiKeyAria"),type:j?"text":"password",value:F,onChange:v=>R(v.target.value),className:"field w-full pr-10",placeholder:r("settings.models.addModal.apiKeyPlaceholder")}),e.jsx("button",{type:"button",onClick:()=>O(!j),"aria-label":r(j?"settings.models.addModal.hideApiKey":"settings.models.addModal.showApiKey"),className:"absolute right-2 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded",children:j?e.jsx(fa,{className:"h-4 w-4"}):e.jsx(ha,{className:"h-4 w-4"})})]})]}),i&&!i.configured&&!i.supportsApiKey&&e.jsx("p",{className:"font-mono text-sm text-amber-600",children:r("settings.models.addModal.oauthNote")}),e.jsxs("button",{type:"button",disabled:J||!i||!L||G&&(!E.trim()||!U.trim())||!i.configured&&(!i.supportsApiKey||F.trim().length===0),onClick:()=>void C(),className:"flex min-h-9 items-center justify-center gap-2 rounded-md bg-green-600 px-4 py-2 font-mono text-sm font-semibold text-white disabled:opacity-50",children:[J&&e.jsx(ne,{className:"h-4 w-4 animate-spin"}),r(J?"settings.models.addModal.saving":"settings.models.addModal.saveModel")]})]})]})})}function Cn(t){const a=ge(),[s,l]=n.useState(""),[r,m]=n.useState(""),[h,g]=n.useState(""),[u,i]=n.useState(""),[N,c]=n.useState(!1),[b,k]=n.useState(null);n.useEffect(()=>{var w,B,I,y,A;l(((w=t.model)==null?void 0:w.displayName)??""),m(((I=(B=t.model)==null?void 0:B.overrides)==null?void 0:I.baseUrl)??""),g(((A=(y=t.model)==null?void 0:y.overrides)==null?void 0:A.streamIdleTimeout)!==void 0?String(t.model.overrides.streamIdleTimeout):""),i(""),k(null)},[t.model]);const p=async()=>{if(!t.model)return;k(null);const w=h.trim()?Number(h):void 0;if(w!==void 0&&(!Number.isFinite(w)||w<1e3)){k(a("settings.models.editModal.streamIdleTimeoutError"));return}c(!0);try{u.trim()&&await q(`/providers/${t.model.provider}/credential`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:u.trim()})});const B={...t.model.overrides};r.trim()?B.baseUrl=r.trim():delete B.baseUrl,w!==void 0?B.streamIdleTimeout=w:delete B.streamIdleTimeout,await t.onSave(t.model.id,{displayName:s||void 0,overrides:Object.keys(B).length>0?B:void 0})&&t.onOpenChange(!1)}catch(B){k(B instanceof Error?B.message:a("settings.models.editModal.credentialError"))}finally{c(!1)}},E=t.model?`[data-edit-model-trigger="${t.model.id.replace(/"/g,'\\"')}"]`:"[data-edit-model-trigger]";return e.jsx($e,{open:t.open,onOpenChange:t.onOpenChange,children:e.jsxs(Ie,{onCloseAutoFocus:w=>Je(E,w),onEscapeKeyDown:w=>{w.preventDefault(),t.onOpenChange(!1)},onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),t.onOpenChange(!1))},className:"gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:a("settings.models.editModal.srTitle")}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"font-mono font-semibold",children:a("settings.models.editModal.title")}),e.jsx("button",{type:"button",onClick:()=>t.onOpenChange(!1),"aria-label":a("settings.models.editModal.close"),className:"flex justify-center items-center w-8 h-8 rounded-md",children:e.jsx(He,{className:"w-4 h-4"})})]}),(b||t.saveError)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:b||t.saveError}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.displayName"),e.jsx("input",{value:s,onChange:w=>l(w.target.value),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.replaceApiKey"),e.jsx("input",{type:"password",value:u,onChange:w=>i(w.target.value),placeholder:a("settings.models.editModal.replaceApiKeyPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.baseUrlOverride"),e.jsx("input",{value:r,onChange:w=>m(w.target.value),placeholder:a("settings.models.editModal.baseUrlPlaceholder"),className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[a("settings.models.editModal.streamIdleTimeout"),e.jsx("input",{type:"number",min:1e3,step:1e3,value:h,onChange:w=>g(w.target.value),placeholder:"300000",className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void p(),disabled:N,className:"flex gap-2 justify-center items-center px-4 py-2 text-white bg-green-600 rounded-md min-h-9 disabled:opacity-60",children:[N&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),a(N?"settings.models.editModal.saving":"settings.models.editModal.save")]})]})})}function An({provider:t,onOpenChange:a,onSave:s,saveError:l}){const r=ge(),[m,h]=n.useState(t.name),[g,u]=n.useState(t.defaultBaseUrl??""),[i,N]=n.useState(t.wireApi??"openai-completions"),[c,b]=n.useState(t.apiKeyEnv??""),[k,p]=n.useState(""),[E,w]=n.useState(null),[B,I]=n.useState(!1);n.useEffect(()=>{h(t.name),u(t.defaultBaseUrl??""),N(t.wireApi??"openai-completions"),b(t.apiKeyEnv??""),p(""),w(null)},[t]);const y=async()=>{if(!m.trim()){w(r("settings.models.editProvider.channelNameRequired"));return}try{const A=new URL(g.trim());if(!["http:","https:"].includes(A.protocol))throw new Error}catch{w(r("settings.models.editProvider.invalidBaseUrl"));return}I(!0),w(null);try{await s(t.id,{name:m.trim(),baseUrl:g.trim(),wireApi:i,apiKeyEnv:c.trim()||null,...k.trim()?{apiKey:k.trim()}:{}})&&a(!1)}finally{I(!1)}};return e.jsx($e,{open:!0,onOpenChange:a,children:e.jsxs(Ie,{onCloseAutoFocus:A=>Je(`[data-edit-provider-trigger="${t.id.replace(/"/g,'\\"')}"]`,A),onEscapeKeyDown:A=>{A.preventDefault(),a(!1)},onKeyDown:A=>{A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),a(!1))},className:"gap-4 overflow-y-auto bg-white p-4 dark:bg-[#09090b] sm:max-w-[480px] sm:p-6","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(Ke,{className:"sr-only",children:r("settings.models.editProvider.title")}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-mono font-semibold",children:r("settings.models.editProvider.title")}),e.jsx("p",{className:"mt-1 font-mono text-[11px] text-zinc-400",children:t.id})]}),e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":r("settings.models.editProvider.close"),className:"flex justify-center items-center w-8 h-8 rounded-md",children:e.jsx(He,{className:"w-4 h-4"})})]}),(E||l)&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:E||l}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.channelName"),e.jsx("input",{"aria-label":r("settings.models.editProvider.channelName"),value:m,onChange:A=>h(A.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:i,onChange:A=>N(A),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:A=>{u(A.target.value),w(null)},className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.apiKeyEnv"),e.jsx("input",{"aria-label":r("settings.models.editProvider.apiKeyEnv"),value:c,onChange:A=>b(A.target.value),placeholder:r("settings.models.editProvider.apiKeyEnvPlaceholder"),autoComplete:"off",spellCheck:!1,className:"field"})]}),e.jsxs("label",{className:"flex flex-col gap-2 font-mono text-sm",children:[r("settings.models.editProvider.replaceApiKey"),e.jsx("input",{"aria-label":r("settings.models.editProvider.apiKeyAria"),type:"password",value:k,onChange:A=>p(A.target.value),placeholder:r("settings.models.editProvider.apiKeyPlaceholder"),className:"field"})]}),e.jsxs("button",{type:"button",onClick:()=>void y(),disabled:B,className:"flex gap-2 justify-center items-center px-4 py-2 text-white bg-green-600 rounded-md min-h-9 disabled:opacity-60",children:[B&&e.jsx(ne,{className:"w-4 h-4 animate-spin"}),r(B?"settings.models.editProvider.saving":"settings.models.editProvider.save")]})]})})}const 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(T=>T.currentSessionRef),s=a==null?void 0:a.projectPath,l=a==null?void 0:a.sessionId,r=n.useMemo(()=>s??new URLSearchParams(window.location.search).get("project")??"",[s]),[m,h]=n.useState(null),[g,u]=n.useState(null),[i,N]=n.useState(""),[c,b]=n.useState(""),[k,p]=n.useState(!1),[E,w]=n.useState(null),[B,I]=n.useState(null),[y,A]=n.useState(null),U=n.useRef(0),S=n.useRef(r);S.current=r;const F=l?`${r}\0${l}`:"",R=n.useRef(F);R.current=F;const j=i===r?m:null,O=c===F?g:null,Q=n.useCallback(async()=>{const T=++U.current;if(!r){h(null),u(null),N(""),b(""),A(null);return}p(!0),A(null);try{const K=await q(`/hooks/trust?projectPath=${encodeURIComponent(r)}`);if(T!==U.current)return;const G=l?await q(`/hooks/session?projectPath=${encodeURIComponent(r)}&sessionId=${encodeURIComponent(l)}`):null;if(T!==U.current)return;h(K),u(G),N(r),b(G?F:"")}catch(K){if(T!==U.current)return;A(K instanceof Error?K.message:t("settings.hooks.loadFailed"))}finally{T===U.current&&p(!1)}},[r,l,F,t]);n.useEffect(()=>(I(null),Q(),()=>{U.current+=1}),[Q]);const Y=async T=>{if(!j)return;const K=r;w(T),A(null);try{const G=await q("/hooks/trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,action:T,...T==="trust"&&j.currentDigest?{expectedDigest:j.currentDigest}:{}})});S.current===K&&(h(G),N(K),I(null))}catch(G){S.current===K&&A(G instanceof Error?G.message:t("settings.hooks.updateFailed"))}finally{w(null)}},Z=async T=>{if(!l||!O)return;const K=F;w("session"),A(null);try{const G=await q("/hooks/session",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:r,sessionId:l,enabled:T})});R.current===K&&(u(G),b(K))}catch(G){R.current===K&&A(G instanceof Error?G.message:t("settings.hooks.sessionUpdateFailed"))}finally{w(null)}};if(!r)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.hooks.selectSession")});const ee=(j==null?void 0:j.state)==="trusted",J=(j==null?void 0:j.state)==="untrusted"||(j==null?void 0:j.state)==="modified",X=O!==null&&!O.enabled&&!O.paused;return e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ee?e.jsx(bt,{className:"h-4 w-4 text-emerald-600"}):e.jsx(Ht,{className:D("h-4 w-4",J?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(j?Sn[j.state]:"settings.hooks.heading")}),k&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:r}),(j==null?void 0:j.currentDigest)&&e.jsx("p",{className:"mt-1 text-[10px] text-[#9CA3AF]",children:j.currentDigest})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void Q(),disabled:k||E!==null,"aria-label":t("settings.hooks.reloadAria"),className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),ee?e.jsx("button",{type:"button",onClick:()=>I("revoke"),disabled:E!==null,className:"h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400",children:t("settings.hooks.revoke")}):e.jsx("button",{type:"button",onClick:()=>I("trust"),disabled:E!==null||!(j!=null&&j.currentDigest)||j.state==="error",className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:t("settings.hooks.trustDigest")})]})]}),y&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:y}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.hooks.currentSession")}),e.jsx("div",{className:"mt-0.5 text-[9.5px] text-[#9CA3AF]",children:l?O?O.paused?t("settings.hooks.session.paused"):O.enabled?t("settings.hooks.session.active"):O.configEnabled?t("settings.hooks.session.unavailable"):t("settings.hooks.session.disabled"):t("settings.hooks.session.loading"):t("settings.hooks.session.open")})]}),e.jsx("button",{type:"button",role:"switch","aria-label":O!=null&&O.paused?t("settings.hooks.session.enableAria"):O!=null&&O.enabled?t("settings.hooks.session.pauseAria"):t("settings.hooks.session.unavailableAria"),"aria-checked":(O==null?void 0:O.enabled)??!1,disabled:!O||E!==null||X,onClick:()=>void Z((O==null?void 0:O.paused)===!0),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",O!=null&&O.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",O!=null&&O.enabled?"translate-x-5":"translate-x-0")})})]}),B&&j&&e.jsxs("div",{role:"alertdialog","aria-label":t(B==="trust"?"settings.hooks.confirmTrustAria":"settings.hooks.confirmRevokeAria"),className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-900/70 dark:bg-amber-950/30",children:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:B==="trust"?t("settings.hooks.confirmTrust",{count:j.configuredHooks}):t("settings.hooks.confirmRevoke")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>I(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void Y(B),disabled:E!==null,className:D("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",B==="trust"?"bg-emerald-600":"bg-red-600"),children:t(E?"settings.hooks.saving":B==="trust"?"settings.hooks.trustReviewed":"settings.hooks.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((j==null?void 0:j.definitions)??[]).map((T,K)=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:T.event}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:T.type}),T.name&&e.jsx("span",{className:"text-[#71717a]",children:T.name}),T.pluginName&&e.jsxs("span",{className:"rounded bg-violet-100 px-1.5 py-0.5 text-[9px] text-violet-700 dark:bg-violet-950/50 dark:text-violet-300",children:[T.pluginName," · ",T.pluginSource]})]}),T.matcher&&e.jsx("div",{className:"mt-1 break-all text-[9.5px] text-[#9CA3AF]",children:T.matcher}),e.jsx("pre",{className:"mt-1.5 whitespace-pre-wrap break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:T.target})]},`${T.event}-${T.type}-${K}`)),j&&j.definitions.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.hooks.empty")})]})]})}const 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(f=>{var _;return(_=f.currentSessionRef)==null?void 0:_.projectPath}),s=Le(f=>f.selectedProjectPath),l=n.useMemo(()=>a??s??new URLSearchParams(window.location.search).get("project")??"",[s,a]),[r,m]=n.useState([]),[h,g]=n.useState([]),[u,i]=n.useState(Dt),[N,c]=n.useState(!1),[b,k]=n.useState(""),[p,E]=n.useState(""),[w,B]=n.useState(""),[I,y]=n.useState(""),[A,U]=n.useState(!1),[S,F]=n.useState(null),[R,j]=n.useState(null),[O,Q]=n.useState(""),[Y,Z]=n.useState(""),[ee,J]=n.useState(!1),[X,T]=n.useState(null),[K,G]=n.useState("local"),te=n.useRef(0),L=n.useRef(l);L.current=l;const C=I===l?r:[],v=I===l?h:[],M=n.useCallback(async()=>{const f=++te.current;if(!l){m([]),y(""),j(null);return}U(!0),j(null);try{const[_,ae,oe]=await Promise.all([q(`/plugins?projectPath=${encodeURIComponent(l)}`),q(`/plugins/catalog?projectPath=${encodeURIComponent(l)}`),q(`/plugins/policy?projectPath=${encodeURIComponent(l)}`)]);if(f!==te.current)return;m(_),g(ae);const xe=(oe==null?void 0:oe.policy)??Dt;i(xe),c((oe==null?void 0:oe.environmentRequiresSha)??!1),k(xe.allowedGitHosts.join(", ")),E(xe.allowedMarketplaces.join(", ")),B(xe.allowedLocalRoots.join(", ")),y(l)}catch(_){if(f!==te.current)return;j(_ instanceof Error?_.message:t("settings.plugins.loadFailed"))}finally{f===te.current&&U(!1)}},[l,t]);n.useEffect(()=>(M(),()=>{te.current+=1}),[M]);const V=async(f,_)=>{const ae=l;F(f.name),j(null);try{await q(`/plugins/${encodeURIComponent(f.name)}/state`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:ae,enabled:_,scope:K})}),L.current===ae&&await M()}catch(oe){L.current===ae&&j(oe instanceof Error?oe.message:t("settings.plugins.updateFailed"))}finally{F(null)}},pe=f=>[...new Set(f.split(",").map(_=>_.trim()).filter(Boolean))],Se=async()=>{await le("policy:save",()=>q("/plugins/policy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,scope:"local",policy:{...u,allowedGitHosts:pe(b),allowedMarketplaces:pe(p),allowedLocalRoots:pe(w)}})}))},le=async(f,_,ae)=>{const oe=l;F(f),j(null);try{await _(),L.current===oe&&(ae==null||ae(),T(null),await M())}catch(xe){L.current===oe&&j(xe instanceof Error?xe.message:t("settings.plugins.actionFailed"))}finally{F(null)}},he=async()=>{const f=O.trim();!f||!ee||await le("install",()=>q("/plugins/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:f,trust:!0})}),()=>{Q(""),J(!1)})},we=async f=>{const _=`update:${f.name}`;if(X!==_){T(_);return}await le(_,()=>q(`/plugins/${encodeURIComponent(f.name)}/update`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,trust:!0})}))},ce=async f=>{const _=`uninstall:${f.name}`;if(X!==_){T(_);return}await le(_,()=>q(`/plugins/${encodeURIComponent(f.name)}/uninstall`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))},Ce=async()=>{const f=Y.trim();f&&await le("marketplace:add",()=>q("/plugins/marketplaces",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,source:f})}),()=>Z(""))},de=async f=>{await le(`marketplace:refresh:${f.name}`,()=>q(`/plugins/marketplaces/${encodeURIComponent(f.name)}/refresh`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l})}))},re=async f=>{const _=`marketplace:remove:${f.name}`;if(X!==_){T(_);return}await le(_,()=>q(`/plugins/marketplaces/${encodeURIComponent(f.name)}/remove`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:l,confirm:!0})}))};return l?e.jsxs("div",{className:"flex min-h-0 flex-col gap-3 font-mono",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(na,{className:"h-4 w-4"}),t("settings.plugins.heading"),A&&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:A||S!==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")]})]}),R&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:R}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(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:S!==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(S==="policy:save"?"settings.plugins.saving":"settings.plugins.saveForProject")})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-2",children:[e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.restrictAria"),"aria-checked":u.restrictToAllowedSources,onClick:()=>i(f=>({...f,restrictToAllowedSources:!f.restrictToAllowedSources})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("h-3.5 w-6 rounded-full p-0.5",u.restrictToAllowedSources?"bg-amber-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:D("block h-2.5 w-2.5 rounded-full bg-white transition-transform",u.restrictToAllowedSources&&"translate-x-2.5")})}),t("settings.plugins.restrictAllowlists")]}),e.jsxs("button",{type:"button",role:"switch","aria-label":t("settings.plugins.requireShaAria"),"aria-checked":u.requireGitCommitSha,disabled:N,onClick:()=>i(f=>({...f,requireGitCommitSha:!f.requireGitCommitSha})),className:"flex items-center gap-2 text-[9.5px] text-[#6B7280] disabled:opacity-50 dark:text-[#a1a1aa]",children:[e.jsx("span",{className:D("h-3.5 w-6 rounded-full p-0.5",u.requireGitCommitSha?"bg-emerald-500":"bg-[#D1D5DB] dark:bg-[#3f3f46]"),children:e.jsx("span",{className:D("block h-2.5 w-2.5 rounded-full bg-white transition-transform",u.requireGitCommitSha&&"translate-x-2.5")})}),t("settings.plugins.requireSha"),N?t("settings.plugins.environmentLocked"):""]})]}),e.jsxs("div",{className:"mt-2 grid gap-1.5 sm:grid-cols-3",children:[e.jsx("input",{"aria-label":t("settings.plugins.gitHostsAria"),value:b,onChange:f=>k(f.target.value),placeholder:"github.com, *.corp.test",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.marketplacesAria"),value:p,onChange:f=>E(f.target.value),placeholder:"team-market, official",className:"field h-7 px-2 text-[9.5px]"}),e.jsx("input",{"aria-label":t("settings.plugins.localRootsAria"),value:w,onChange:f=>B(f.target.value),placeholder:"/opt/approved/plugins",className:"field h-7 px-2 text-[9.5px]"})]}),u.restrictToAllowedSources&&!b.trim()&&!p.trim()&&!w.trim()&&e.jsx("p",{className:"mt-1.5 text-[9px] text-amber-700 dark:text-amber-400",children:t("settings.plugins.emptyAllowlists")})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] p-3 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(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:O,onChange:f=>Q(f.target.value),placeholder:"plugin@marketplace, owner/repo, or ./path",disabled:S!==null,className:"field h-8 min-w-0 flex-1 px-2 text-[10.5px]"}),e.jsxs("button",{type:"button",onClick:()=>void he(),disabled:!O.trim()||!ee||S!==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:[S==="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":ee,onClick:()=>J(f=>!f),className:"mt-2 flex items-center gap-2 text-left text-[9.5px] text-amber-700 dark:text-amber-400",children:[e.jsx("span",{className:D("flex h-3.5 w-3.5 items-center justify-center rounded-sm border",ee?"border-amber-600 bg-amber-600 text-white":"border-[#D1D5DB] dark:border-[#52525b]"),children:ee?"✓":""}),t("settings.plugins.trustSource")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t("settings.plugins.activationScope")}),e.jsx("div",{className:"mt-0.5 text-[9px] text-[#9CA3AF]",children:t("settings.plugins.activationScopeHint")})]}),e.jsx("div",{role:"radiogroup","aria-label":t("settings.plugins.scopeAria"),className:"flex rounded-md bg-[#F3F4F6] p-0.5 dark:bg-[#18181b]",children:Pn.map(f=>e.jsx("button",{type:"button",role:"radio","aria-checked":K===f.value,title:t(f.descriptionKey),onClick:()=>G(f.value),className:D("rounded px-2 py-1 text-[9.5px] transition-colors",K===f.value?"bg-white font-semibold text-[#111827] shadow-sm dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#71717a] hover:text-[#374151] dark:hover:text-[#d4d4d8]"),children:t(f.labelKey)},f.value))})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[C.map(f=>{var xe;const _=S===f.name,ae=[f.commands?t("settings.plugins.capability.commands",{count:f.commands}):"",f.skills?t("settings.plugins.capability.skills",{count:f.skills}):"",f.agents?t("settings.plugins.capability.agents",{count:f.agents}):"",f.hooks?t("settings.plugins.capability.hooks",{count:f.hooks}):"",f.mcpServers?t("settings.plugins.capability.mcp",{count:f.mcpServers}):""].filter(Boolean),oe=["global","project","local","invocation"].filter(fe=>{var be;return((be=f.settingLayers)==null?void 0:be[fe])!==void 0}).map(fe=>`${t(Lt[fe])} ${t(f.settingLayers[fe]?"settings.plugins.layer.on":"settings.plugins.layer.off")}`);return e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[#E5E7EB] px-3 py-2.5 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:f.name}),e.jsxs("span",{className:"text-[9.5px] text-[#9CA3AF]",children:["v",f.version]}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:f.source}),e.jsx("span",{className:"rounded bg-sky-50 px-1.5 py-0.5 text-[9px] text-sky-700 dark:bg-sky-950/40 dark:text-sky-300",children:t("settings.plugins.effective",{scope:t(Lt[f.effectiveScope])})})]}),e.jsx("p",{className:"mt-1 text-[10.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:f.description}),e.jsx("p",{className:"mt-1 text-[9.5px] text-[#9CA3AF]",children:ae.join(" · ")||t("settings.plugins.noResources")}),oe.length>0&&e.jsx("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:oe.join(" · ")}),f.managed&&e.jsxs("p",{className:"mt-1 text-[9px] text-[#9CA3AF]",children:[t("settings.plugins.managed"),f.marketplace?` · ${f.marketplace}`:"",f.revision?` · ${f.revision.slice(0,12)}`:""]}),!f.configurable&&e.jsx("p",{className:"mt-1 text-[9.5px] text-amber-600 dark:text-amber-400",children:t("settings.plugins.invocationScoped")}),(xe=f.compatibilityIssues)==null?void 0:xe.map(fe=>e.jsx("p",{className:"mt-1 text-[9.5px] text-red-600 dark:text-red-400",children:fe.message},`${fe.code}:${fe.message}`))]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("button",{type:"button",role:"switch","aria-label":f.status==="error"?t("settings.plugins.unavailableAria",{name:f.name}):f.enabled?t("settings.plugins.disableAria",{name:f.name}):t("settings.plugins.enableAria",{name:f.name}),"aria-checked":f.enabled,disabled:f.status==="error"||!f.configurable||_||S!==null,onClick:()=>void V(f,!f.enabled),className:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors disabled:opacity-40",f.enabled?"bg-emerald-500":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full bg-white transition-transform",f.enabled?"translate-x-5":"translate-x-0")})}),f.managed&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.updateAria",{name:f.name}),onClick:()=>void we(f),disabled:S!==null,className:D("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",X===`update:${f.name}`?"bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-300":"text-[#6B7280] hover:bg-[#F3F4F6] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]"),children:S===`update:${f.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):X===`update:${f.name}`?t("settings.plugins.confirmUpdate"):t("settings.plugins.update")}),e.jsx("button",{type:"button","aria-label":t("settings.plugins.uninstallAria",{name:f.name}),onClick:()=>void ce(f),disabled:S!==null,className:D("rounded px-1.5 py-1 text-[9px] disabled:opacity-40",X===`uninstall:${f.name}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"text-[#9CA3AF] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:S===`uninstall:${f.name}`?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):X===`uninstall:${f.name}`?t("settings.plugins.confirmRemove"):e.jsx(ze,{className:"h-3 w-3"})})]})]})]},f.name)}),!A&&C.length===0&&!R&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.plugins.empty")})]}),e.jsxs("div",{className:"rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[#E5E7EB] px-3 py-2 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[e.jsx(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:v.length})})]}),e.jsxs("div",{className:"flex gap-2 border-b border-[#E5E7EB] p-2 dark:border-[#27272a]",children:[e.jsx("input",{"aria-label":t("settings.plugins.marketplaceSourceAria"),value:Y,onChange:f=>Z(f.target.value),placeholder:"owner/repo, HTTPS Git URL, or ./path",disabled:S!==null,className:"field h-7 min-w-0 flex-1 px-2 text-[10px]"}),e.jsxs("button",{type:"button","aria-label":t("settings.plugins.addMarketplaceAria"),onClick:()=>void Ce(),disabled:!Y.trim()||S!==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:[S==="marketplace:add"?e.jsx(ne,{className:"h-3 w-3 animate-spin"}):e.jsx(We,{className:"h-3 w-3"}),t("settings.plugins.add")]})]}),v.map(f=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[10.5px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:[f.name,e.jsxs("span",{className:"ml-2 font-normal text-[#9CA3AF]",children:[f.sourceType," · ",f.revision.slice(0,12)]})]}),e.jsx("p",{className:"mt-0.5 text-[9.5px] text-[#6B7280] dark:text-[#a1a1aa]",children:f.description||t("settings.plugins.noDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx("button",{type:"button","aria-label":t("settings.plugins.refreshMarketplaceAria",{name:f.name}),disabled:S!==null,onClick:()=>void de(f),className:"rounded p-1 text-[#9CA3AF] hover:bg-[#F3F4F6] disabled:opacity-40 dark:hover:bg-[#27272a]",children:S===`marketplace:refresh:${f.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:f.name}),disabled:S!==null,onClick:()=>void re(f),className:D("rounded p-1 text-[#9CA3AF] disabled:opacity-40",X===`marketplace:remove:${f.name}`?"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300":"hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-950/30"),children:X===`marketplace:remove:${f.name}`?e.jsx("span",{className:"px-1 text-[8.5px]",children:t("settings.plugins.confirm")}):e.jsx(ze,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-1",children:[f.plugins.slice(0,12).map(_=>e.jsxs("button",{type:"button",disabled:_.installed||S!==null,onClick:()=>{Q(`${_.name}@${f.name}`),J(!1)},title:_.description,className:"rounded bg-[#F3F4F6] px-1.5 py-0.5 text-[8.5px] text-[#6B7280] disabled:opacity-40 dark:bg-[#27272a] dark:text-[#a1a1aa]",children:[_.name,_.installed?t("settings.plugins.installedSuffix"):""]},_.name)),f.plugins.length>12&&e.jsxs("span",{className:"px-1 py-0.5 text-[8.5px] text-[#9CA3AF]",children:["+",f.plugins.length-12]})]})]},f.name)),!A&&v.length===0&&e.jsx("div",{className:"px-3 py-4 text-center text-[10px] text-[#9CA3AF]",children:t("settings.plugins.marketplaceEmpty")})]})]}):e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.plugins.selectProject")})}const 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(R=>{var j;return(j=R.currentSessionRef)==null?void 0:j.projectPath}),s=n.useMemo(()=>a??new URLSearchParams(window.location.search).get("project")??"",[a]),[l,r]=n.useState(null),[m,h]=n.useState(""),[g,u]=n.useState(!1),[i,N]=n.useState(null),[c,b]=n.useState(null),[k,p]=n.useState(null),[E,w]=n.useState(!1),B=n.useRef(0),I=n.useRef(s);I.current=s;const y=m===s?l:null,A=n.useCallback(async()=>{const R=++B.current;if(!s){r(null),h(""),p(null);return}u(!0),p(null);try{const j=await q(`/workspace-trust?projectPath=${encodeURIComponent(s)}`);if(R!==B.current)return;r(j),h(s)}catch(j){if(R!==B.current)return;p(j instanceof Error?j.message:t("settings.trust.loadFailed"))}finally{R===B.current&&u(!1)}},[s,t]);n.useEffect(()=>(b(null),w(!1),A(),()=>{B.current+=1}),[A]);const U=async R=>{if(!y)return;const j=s;N(R),p(null);try{const O=await q("/workspace-trust",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({projectPath:j,action:R})});I.current===j&&(r(O),h(j),b(null),w(O.reloadRequired===!0))}catch(O){I.current===j&&p(O instanceof Error?O.message:t("settings.trust.updateFailed"))}finally{N(null)}};if(!s)return e.jsx("div",{className:"font-mono text-[12px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.trust.selectSession")});const S=(y==null?void 0:y.state)==="trusted",F=(y==null?void 0:y.state)==="untrusted";return e.jsxs("div",{className:"flex flex-col gap-3 min-h-0 font-mono",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] p-3 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[S?e.jsx(bt,{className:"w-4 h-4 text-emerald-600"}):e.jsx(Ht,{className:D("h-4 w-4",F?"text-amber-600":"text-[#71717a]")}),e.jsx("span",{className:"text-[13px] font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t(y?Tn[y.state]:"settings.trust.heading")}),g&&e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"})]}),e.jsx("p",{className:"mt-1 break-all text-[10.5px] text-[#71717a]",children:s}),y&&e.jsxs("p",{className:"mt-1 break-all text-[10px] text-[#9CA3AF]",children:[y.decision,y.inheritedFrom?t("settings.trust.inheritedFrom",{source:y.inheritedFrom}):""]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>void A(),disabled:g||i!==null,"aria-label":t("settings.trust.reloadAria"),className:"inline-flex h-8 items-center gap-1 rounded-md border border-[#E5E7EB] px-2 text-[11px] text-[#6B7280] disabled:opacity-50 dark:border-[#3f3f46] dark:text-[#a1a1aa]",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),t("settings.common.reload")]}),S?e.jsx("button",{type:"button",onClick:()=>b("revoke"),disabled:i!==null,className:"h-8 rounded-md border border-red-200 px-2.5 text-[11px] text-red-600 disabled:opacity-50 dark:border-red-900 dark:text-red-400",children:t("settings.trust.revoke")}):e.jsx("button",{type:"button",onClick:()=>b("trust"),disabled:i!==null||(y==null?void 0:y.state)==="error"||!y||y.sensitiveSources===0,className:"h-8 rounded-md bg-emerald-600 px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",children:t("settings.trust.trustWorkspace")})]})]}),(k||(y==null?void 0:y.error))&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:k||(y==null?void 0:y.error)}),E&&e.jsx("div",{role:"status",className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-[11px] text-blue-700 dark:border-blue-900/60 dark:bg-blue-950/30 dark:text-blue-300",children:t("settings.trust.restartNotice")}),c&&y&&e.jsxs("div",{role:"alertdialog","aria-label":t(c==="trust"?"settings.trust.trustWorkspace":"settings.trust.revokeAria"),className:"flex flex-wrap gap-3 justify-between items-center px-3 py-2 bg-amber-50 rounded-md border border-amber-300 dark:border-amber-900/70 dark:bg-amber-950/30",children:[e.jsx("span",{className:"max-w-[620px] text-[11px] text-amber-900 dark:text-amber-200",children:c==="trust"?t("settings.trust.confirmTrust",{count:y.sensitiveSources}):t("settings.trust.confirmRevoke")}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>b(null),className:"h-7 rounded px-2 text-[11px] text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void U(c),disabled:i!==null,className:D("h-7 rounded px-2.5 text-[11px] font-semibold text-white disabled:opacity-50",c==="trust"?"bg-emerald-600":"bg-red-600"),children:t(i?"settings.trust.saving":c==="trust"?"settings.trust.trustReviewed":"settings.trust.revokeTrust")})]})]}),e.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-[#E5E7EB] dark:border-[#27272a]",children:[((y==null?void 0:y.sources)??[]).map(R=>e.jsxs("div",{className:"border-b border-[#E5E7EB] px-3 py-2 last:border-b-0 dark:border-[#27272a]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"font-semibold text-[#111827] dark:text-[#E5E5E5]",children:R.path}),e.jsx("span",{className:"rounded bg-[#E5E7EB] px-1.5 py-0.5 text-[9px] uppercase text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",children:R.kind})]}),R.warning&&e.jsx("p",{className:"mt-1 text-[10px] text-amber-700 dark:text-amber-300",children:R.warning}),e.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:R.effects.map((j,O)=>e.jsxs("div",{className:"break-all text-[10.5px] text-[#374151] dark:text-[#d4d4d8]",children:[e.jsx("span",{className:"text-[#9CA3AF]",children:j.kind})," · ",j.name,j.target?` → ${j.target}`:""]},`${j.kind}-${j.name}-${O}`))})]},`${R.kind}-${R.path}`)),y&&y.sources.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-[#9CA3AF]",children:t("settings.trust.empty")})]})]})}const 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 Ne,je;const t=ge(),{locale:a}=ra(),{isSettingsOpen:s,settingsSection:l,toggleSettings:r,isSidebarOpen:m,setSidebarOpen:h}=xa(),{configuredModels:g,loadModels:u,isLoading:i,error:N}=Ut(),c=la(),[b,k]=n.useState("general"),[p,E]=n.useState(!1),[w,B]=n.useState(null),[I,y]=n.useState(null),[A,U]=n.useState(null),[S,F]=n.useState([]),[R,j]=n.useState(null),[O,Q]=n.useState(null),[Y,Z]=n.useState(null),[ee,J]=n.useState(null),[X,T]=n.useState({}),[K,G]=n.useState(null),[te,L]=n.useState(null),[C,v]=n.useState(""),[M,V]=n.useState("all"),pe=n.useRef(null),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(C.toLowerCase()),z=M==="all"||o.scope.toLowerCase()===M;return $&&z}),re=g.reduce((o,$)=>{const z=$.provider||"unknown";return o[z]||(o[z]=[]),o[z].push($),o},{}),f=new Map(S.map(o=>[o.id,o]));for(const o of S)o.custom&&!re[o.id]&&(re[o.id]=[]);const _=n.useCallback(async()=>{try{F(await q("/providers")),J(null)}catch(o){J(o instanceof Error?o.message:t("settings.models.loadChannelsFailed"))}},[t]);n.useEffect(()=>{s&&(k(l),u(),_(),c.loadSettings())},[s,u,_,c.loadSettings,l]);const ae=()=>{const o=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 z;(z=pe.current)==null||z.focus({preventScroll:!0})});return()=>{cancelAnimationFrame($),requestAnimationFrame(ae)}},[s]);const xe=async o=>{G("save"),L(null);try{return await q("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:o.provider,displayName:o.displayName,model:o.model,apiKey:o.apiKey,modelProvider:o.modelProvider,overrides:o.overrides})}),await u(),await _(),!0}catch($){return L($ instanceof Error?$.message:t("settings.models.saveFailed")),!1}finally{G(null)}},fe=async()=>{typeof Notification>"u"||we(await Notification.requestPermission())},be=async o=>{G("delete"),L(null);try{await q(`/models/${o}`,{method:"DELETE"}),await u(),U(null)}catch($){L($ instanceof Error?$.message:t("settings.models.deleteFailed"))}finally{G(null)}},Fe=async(o,$)=>{G("update"),L(null);try{return await q(`/models/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),await u(),!0}catch(z){return L(z instanceof Error?z.message:t("settings.models.updateFailed")),!1}finally{G(null)}},P=async(o,$)=>{Z({providerId:o,type:"update"}),J(null);try{return await q(`/providers/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),await Promise.all([u(),_()]),!0}catch(z){return J(z instanceof Error?z.message:t("settings.models.updateChannelFailed")),!1}finally{Z(null)}},Be=async(o,$)=>{Z({providerId:o.id,type:"probe"}),J(null);try{const z=await q(`/providers/${o.id}/probe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modelId:$})});T(d=>({...d,[o.id]:z}))}catch(z){J(z instanceof Error?z.message:t("settings.models.probeFailed"))}finally{Z(null)}},ve=async o=>{Z({providerId:o.id,type:"delete"}),J(null);try{await q(`/providers/${o.id}?removeModels=true`,{method:"DELETE"}),Q(null),B(null),T($=>{const z={...$};return delete z[o.id],z}),await Promise.all([u(),_()])}catch($){J($ instanceof Error?$.message:t("settings.models.deleteChannelFailed"))}finally{Z(null)}},Re=(o,$)=>{var W,H;const z=o.key==="ArrowRight"||o.key==="ArrowDown"?1:o.key==="ArrowLeft"||o.key==="ArrowUp"?-1:0;if(z===0&&o.key!=="Home"&&o.key!=="End")return;o.preventDefault();const d=o.key==="Home"?0:o.key==="End"?ce.length-1:($+z+ce.length)%ce.length;k(ce[d].value),(H=(W=o.currentTarget.closest('[role="tablist"]'))==null?void 0:W.querySelectorAll('[role="tab"]')[d])==null||H.focus()},x=o=>{B(w===o?null:o)},ue=o=>{if(!s||o.key!=="Escape"||!(o.target instanceof Node)||!o.currentTarget.contains(o.target)||p||I||R||Date.now()-le.current<250)return;const $=o.target instanceof Element?o.target:null;if(!(o.defaultPrevented||$!=null&&$.closest('[role="dialog"]'))){if(o.preventDefault(),A){U(null);return}if(O){Q(null);return}oe()}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-settings-panel":!0,onKeyDown:ue,className:"flex h-full min-h-0 bg-white dark:bg-[#09090b]",children:[e.jsxs("nav",{role:"tablist","aria-label":t("settings.nav.aria"),className:"flex h-full w-[220px] shrink-0 flex-col border-r border-[#E5E7EB] bg-[#F9FAFB] dark:border-zinc-800 dark:bg-[#111113]",children:[e.jsx("div",{className:"p-4 shrink-0",children:e.jsxs("button",{ref:pe,type:"button",onClick:oe,className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[12px] font-mono text-[#6B7280] transition-colors hover:bg-[#E5E7EB] hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:[e.jsx(pa,{className:"h-3.5 w-3.5"}),t("settings.action.back")]})}),e.jsx("div",{className:"overflow-y-auto flex-1 px-3 pb-4",children:Object.entries(ce.reduce((o,$)=>(o[$.category]||(o[$.category]=[]),o[$.category].push($),o),{})).map(([o,$])=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-[#9CA3AF] dark:text-[#71717a]",children:o}),$.map(z=>e.jsx("button",{onClick:()=>k(z.value),onKeyDown:d=>Re(d,ce.indexOf(z)),role:"tab",id:`settings-tab-${z.value}`,"aria-controls":`settings-panel-${z.value}`,"aria-selected":b===z.value,tabIndex:b===z.value?0:-1,className:D("w-full rounded-md px-3 py-1.5 text-left text-[13px] transition-colors",b===z.value?"bg-[#E5E7EB] font-medium text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] hover:bg-[#E5E7EB]/60 hover:text-[#111827] dark:text-[#a1a1aa] dark:hover:bg-[#27272a]/50 dark:hover:text-[#E5E5E5]"),children:z.label},z.value))]},o))})]}),e.jsx("div",{className:"flex overflow-hidden flex-col flex-1 min-h-0",children:e.jsx("div",{className:"overflow-y-auto flex-1 p-6 sm:p-10",children:e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-xl font-semibold text-[#111827] dark:text-[#E5E5E5]",children:((Ne=ce.find(o=>o.value===b))==null?void 0:Ne.label)??t("settings.title")}),c.isLoading&&b==="general"&&e.jsxs("div",{role:"status",className:"flex shrink-0 items-center gap-2 text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}),t("settings.general.loading")]}),c.error&&b==="general"&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:c.error}),e.jsx("button",{type:"button",onClick:()=>void c.loadSettings(),className:"underline shrink-0",children:t("settings.common.retry")})]}),b==="models"&&e.jsxs("div",{id:"settings-panel-models",role:"tabpanel","aria-labelledby":"settings-tab-models",className:"flex overflow-hidden flex-col flex-1 gap-6 min-h-0",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:t("settings.models.description")}),(N||te||ee)&&e.jsxs("div",{role:"alert",className:"flex shrink-0 items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] font-mono text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0",children:ee||te||N}),e.jsx("button",{type:"button",onClick:()=>{L(null),J(null),N&&u()},className:"underline shrink-0",children:t(N?"settings.common.retry":"settings.common.dismiss")})]}),A&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteModelAria",{name:A.displayName||A.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:A.displayName||A.model})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>U(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void be(A.id),disabled:K!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:t(K==="delete"?"settings.models.deleting":"settings.models.deleteModel")})]})]}),O&&e.jsxs("div",{role:"alertdialog","aria-label":t("settings.models.deleteChannelAria",{name:O.name}),className:"flex flex-wrap gap-2 justify-between items-center px-3 py-2 bg-red-50 rounded-md border border-red-200 dark:border-red-900/60 dark:bg-red-950/30",children:[e.jsx("span",{className:"text-[11px] font-mono text-red-700 dark:text-red-300",children:t("settings.models.deleteChannelPrompt",{name:O.name,count:((je=re[O.id])==null?void 0:je.length)??0})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("button",{type:"button",onClick:()=>Q(null),className:"h-7 rounded-md px-2.5 text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t("settings.common.cancel")}),e.jsx("button",{type:"button",onClick:()=>void ve(O),disabled:Y!==null,className:"h-7 rounded-md bg-red-600 px-2.5 text-[11px] font-mono font-semibold text-white disabled:opacity-60",children:(Y==null?void 0:Y.type)==="delete"?t("settings.models.deleting"):t("settings.models.deleteChannel")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[i&&g.length===0&&e.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[e.jsx(ne,{className:"w-4 h-4 animate-spin"}),t("settings.models.loading")]}),Object.entries(re).map(([o,$])=>{const z=Rn[o]||{bg:"#71717a",label:"?"},d=f.get(o),W=w===o,H=X[o],ye=(Y==null?void 0:Y.providerId)===o&&Y.type==="probe";return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("button",{onClick:()=>x(o),className:"flex min-w-0 flex-1 items-center justify-between p-4 text-left transition-colors hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23]",children:[e.jsxs("div",{className:"flex gap-3 items-center min-w-0",children:[e.jsx("div",{className:"flex justify-center items-center w-8 h-8 text-xs font-bold text-white rounded shrink-0",style:{backgroundColor:z.bg},children:z.label}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"truncate text-sm font-semibold font-mono text-[#111827] dark:text-[#E5E5E5]",children:(d==null?void 0:d.name)??o.replace(/-/g," ")}),e.jsxs("span",{className:"truncate text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:[$.length===1?t("settings.models.modelCountOne",{count:$.length}):t("settings.models.modelCountMany",{count:$.length}),d!=null&&d.custom?` · ${d.wireApi}`:""]})]})]}),e.jsxs("div",{className:"flex gap-3 items-center shrink-0",children:[e.jsxs("span",{className:D("text-xs font-mono",(d==null?void 0:d.configured)===!1?"text-amber-600":"text-[#16A34A]"),children:["●"," ",(d==null?void 0:d.configured)===!1?t("settings.models.missingCredential"):t("settings.models.configured")]}),e.jsx(_t,{className:D("h-4 w-4 text-[#9CA3AF] transition-transform dark:text-[#71717a]",W&&"rotate-180")})]})]}),(d==null?void 0:d.custom)&&e.jsxs("div",{className:"flex gap-1 items-center pr-3 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{var me;return void Be(d,(me=$[0])==null?void 0:me.id)},disabled:Y!==null||$.length===0,"aria-label":t("settings.models.testChannelAria",{name:d.name}),className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:ye?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ma,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button","data-edit-provider-trigger":d.id,onClick:()=>{J(null),j(d)},disabled:Y!==null,"aria-label":t("settings.models.editChannelAria",{name:d.name}),className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-[#111827] disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-[#E5E5E5]",children:e.jsx(xt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>Q(d),disabled:Y!==null,"aria-label":t("settings.models.deleteChannelActionAria",{name:d.name}),className:"rounded p-1.5 text-[#71717a] hover:bg-[#E5E7EB] hover:text-red-500 disabled:opacity-50 dark:hover:bg-[#27272a] dark:hover:text-red-400",children:e.jsx(ze,{className:"h-3.5 w-3.5"})})]})]}),H&&e.jsxs("div",{role:"status",className:D("border-t px-4 py-2 font-mono text-[11px]",H.ok?"border-green-200 bg-green-50 text-green-700 dark:border-green-900/60 dark:bg-green-950/20 dark:text-green-300":"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-300"),children:[H.message," · ",H.latencyMs,"ms · ",H.wireApi]}),W&&e.jsxs("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:[(d==null?void 0:d.custom)&&e.jsxs("div",{className:"border-b border-[#E5E7EB] px-4 py-2 font-mono text-[11px] text-[#71717a] dark:border-zinc-800",children:[e.jsx("span",{className:"font-semibold",children:d.id})," ","· ",d.defaultBaseUrl]}),$.map(me=>{var Ge;return e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:me.displayName||me.model}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:[me.displayName&&`${me.model} · `,((Ge=me.overrides)==null?void 0:Ge.baseUrl)||t("settings.models.defaultEndpoint")]})]}),e.jsxs("div",{className:"flex gap-2 items-center opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx("button",{"data-edit-model-trigger":me.id,onClick:()=>{L(null),y(me)},disabled:K!==null,"aria-label":t("settings.models.editModelAria",{name:me.displayName||me.model}),className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(xt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>U(me),disabled:K!==null,"aria-label":t("settings.models.deleteModelAria",{name:me.displayName||me.model}),className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(ze,{className:"h-3.5 w-3.5"})})]})]},me.id)})]})]},o)}),!i&&!N&&Object.keys(re).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:t("settings.models.empty")})]})}),e.jsx("button",{"data-add-model-trigger":!0,onClick:()=>{L(null),E(!0)},disabled:K!==null,className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:t("settings.models.add")})]}),b==="general"&&e.jsxs("div",{id:"settings-panel-general",role:"tabpanel","aria-labelledby":"settings-tab-general","aria-busy":c.isLoading,className:"flex flex-col gap-6 overflow-x-hidden overflow-y-auto pr-2 [&>div>div.flex]:flex-wrap [&>div>div.flex]:gap-2 [&_select]:max-w-full",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.tab.general")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.general.responseLanguage")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.general.responseLanguageHint")})]}),e.jsx(Ae,{"aria-label":t("settings.general.responseLanguage"),value:c.language,onChange:o=>c.updateSettings({language:o}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:[{value:"en-US",label:"English (US)"},{value:"zh-CN",label:"简体中文"},{value:"zh-TW",label:"繁體中文"},{value:"ja-JP",label:"日本語"},{value:"ko-KR",label:"한국어"},{value:"es-ES",label:"Español"},{value:"fr-FR",label:"Français"},{value:"de-DE",label:"Deutsch"},{value:"pt-BR",label:"Português (BR)"},{value:"ru-RU",label:"Русский"}]})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.general.autoSave")}),e.jsx(Te,{label:t("settings.general.autoSave"),enabled:c.autoSaveSessions,onChange:o=>c.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:c.agentTeamsEnabled,onChange:o=>c.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:c.communicationStyle??"auto",onChange:o=>c.updateSettings({communicationStyle:o}),className:"h-8 w-auto min-w-[140px] text-[12px]",options:Nn.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:()=>c.updateSettings({uiTheme:o}),className:D("px-3 py-1 rounded text-[12px] font-mono transition-colors",c.uiTheme===o?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t(o==="dark"?"settings.appearance.theme.dark":o==="light"?"settings.appearance.theme.light":"settings.appearance.theme.system")},o))})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.compactSidebar")}),e.jsx(Te,{label:t("settings.appearance.compactSidebar"),enabled:!m,onChange:o=>h(!o)})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.appearance.codeTheme")}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:t("settings.appearance.codeThemeHint")})]}),e.jsx(Ae,{"aria-label":t("settings.appearance.codeTheme"),value:c.codeTheme,onChange:o=>c.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:c.notifyBuild,onChange:o=>c.updateSettings({notifyBuild:o})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.errorsOnly")}),e.jsx(Te,{label:t("settings.notifications.errorsOnly"),enabled:c.notifyErrors,onChange:o=>c.updateSettings({notifyErrors:o})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.notifications.systemSounds")}),e.jsx(Te,{label:t("settings.notifications.systemSounds"),enabled:c.notifySounds,onChange:o=>c.updateSettings({notifySounds:o})})]}),(c.notifyBuild||c.notifyErrors)&&he!=="granted"&&e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-md border border-[#E5E7EB] bg-[#F9FAFB] px-3 py-2 dark:border-[#27272a] dark:bg-[#18181b]",children:[e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:t(he==="denied"?"settings.notifications.blocked":he==="unsupported"?"settings.notifications.unavailable":"settings.notifications.enablePrompt")}),he==="default"&&e.jsx("button",{type:"button",onClick:()=>void fe(),className:"shrink-0 rounded-md bg-[#111827] px-2.5 py-1.5 text-[10px] font-mono text-white hover:bg-[#374151] dark:bg-[#E5E5E5] dark:text-[#111827]",children:t("settings.common.enable")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:t("settings.privacy.heading")}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.privacy.telemetry")}),e.jsx(Te,{label:t("settings.privacy.telemetry"),enabled:c.privacyTelemetry,onChange:o=>c.updateSettings({privacyTelemetry:o})})]}),e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:t("settings.privacy.crash")}),e.jsx(Te,{label:t("settings.privacy.crash"),enabled:c.privacyCrash,onChange:o=>c.updateSettings({privacyCrash:o})})]})]})]}),b==="shortcuts"&&e.jsxs("div",{id:"settings-panel-shortcuts",role:"tabpanel","aria-labelledby":"settings-tab-shortcuts",className:"flex overflow-hidden flex-col flex-1 gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col gap-2 shrink-0 sm:flex-row sm:items-center sm:gap-3",children:[e.jsx("input",{"aria-label":t("settings.shortcuts.searchPlaceholder"),value:C,onChange:o=>v(o.target.value),placeholder:t("settings.shortcuts.searchPlaceholder"),className:"field flex-1 text-[12px]"}),e.jsx(Ae,{"aria-label":t("settings.shortcuts.col.scope"),value:M,onChange:o=>V(o),className:"w-auto min-w-[120px] text-[12px]",options:[{value:"all",label:t("settings.shortcuts.scope.all")},{value:"global",label:t("settings.shortcuts.scope.global")},{value:"chat",label:t("settings.shortcuts.scope.chat")},{value:"layout",label:t("settings.shortcuts.scope.layout")}]}),e.jsx("button",{onClick:()=>{v(""),V("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:t("settings.shortcuts.reset")})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:t("settings.shortcuts.col.action")}),e.jsx("span",{children:t("settings.shortcuts.col.shortcut")}),e.jsx("span",{children:t("settings.shortcuts.col.scope")})]}),de.map((o,$)=>e.jsxs("div",{className:D("grid min-w-[520px] grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",$%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:o.action}),e.jsx("div",{className:"flex gap-1 items-center",children:o.combo.map(z=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:z},z))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children: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,{})})]})})})]}),p&&e.jsx(wn,{open:!0,onOpenChange:o=>{o||(le.current=Date.now()),E(o)},onSave:xe,saveError:te}),I&&e.jsx(Cn,{open:!0,onOpenChange:o=>{o||(le.current=Date.now(),y(null))},model:I,onSave:Fe,saveError:te}),R&&e.jsx(An,{provider:R,onOpenChange:o=>{o||(le.current=Date.now(),j(null))},onSave:P,saveError:ee})]})}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:D("flex h-6 w-11 items-center rounded-full px-1 transition-colors",a?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:D("h-4 w-4 rounded-full transition-transform",a?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{Yn as SettingsModal};
|