hmcp-web 0.2.3 → 0.2.5

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.
@@ -1,5 +1,5 @@
1
- import{$ as e,A as t,At as n,B as r,Ct as i,E as a,G as o,H as s,It as c,J as l,M as u,N as d,Nt as f,O as p,Ot as m,Pt as h,Tt as g,U as _,V as v,Y as y,Z as b,_t as x,a as S,b as C,bt as w,et as T,ht as E,i as D,jt as O,k,kt as A,n as j,o as ee,q as M,r as N,rt as P,s as F,t as I,tt as te,vt as ne,w as re,x as ie,xt as ae,y as oe,yt as L}from"./kit-BHB_ha4i.js";import{$ as se,A as ce,B as le,Bt as ue,C as de,D as fe,E as pe,F as R,Ft as z,G as me,H as he,I as ge,J as _e,Jt as ve,K as ye,Kt as B,L as be,Lt as V,M as xe,Mn as H,N as Se,Nt as U,O as Ce,P as we,Q as Te,Qt as Ee,R as De,Rt as Oe,S as ke,T as Ae,U as je,Ut as W,V as Me,Vt as G,W as Ne,Wt as Pe,X as Fe,Y as Ie,Yt as Le,Zt as Re,b as ze,bn as Be,cn as K,ct as Ve,dn as He,en as Ue,et as q,fn as J,j as We,k as Ge,ln as Y,m as Ke,nn as qe,nt as Je,on as Ye,q as Xe,rn as X,rt as Ze,s as Qe,sn as $e,tn as et,tt,x as nt,z as rt,zt as it}from"./index-Cm4wG2zz.js";import{A as at,B as ot,C as st,D as ct,E as lt,F as ut,G as dt,H as ft,I as pt,K as mt,L as ht,M as gt,O as _t,R as vt,S as yt,T as bt,U as xt,V as St,W as Ct,b as wt,d as Tt,f as Et,j as Dt,k as Ot,w as kt,x as At,y as jt,z as Mt}from"./connect-app-words-CT8Fytzv.js";var Z=c(),Q=A(),Nt=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function Pt(e){let t=Nt();return t.name=e.name,t.transport=e.transport,t.onInjection=e.on_injection??``,e.transport===`stdio`?(t.command=e.command,t.args=e.args??[],t.env=Ze(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=Ze(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function Ft(e){let t=e.onInjection?{on_injection:e.onInjection}:{};return e.transport===`stdio`?{name:e.name.trim(),transport:`stdio`,...t,command:e.command.trim(),...e.args.length?{args:e.args}:{},...e.env.length?{env:Je(e.env)}:{},...e.passEnv.length?{pass_env:e.passEnv}:{},...e.cwd.trim()?{cwd:e.cwd.trim()}:{}}:{name:e.name.trim(),transport:`http`,...t,url:e.url.trim(),...e.headers.length?{headers:Je(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function It(e,t=[]){if(!/^[a-z0-9_]+$/.test(e.name.trim()))return`Give the server a name of lower-case letters, digits and underscores.`;if(t.includes(e.name.trim()))return`Another connected server is already called “${e.name.trim()}”.`;if(e.transport===`stdio`&&!e.command.trim())return`Say which program starts the server.`;if(e.transport===`http`)try{new URL(e.url.trim())}catch{return`Enter the server's full web address, starting with https://.`}return null}function Lt({value:e,onChange:n,nameLocked:r,secret:i,literalWarning:o}){let c=(t,r)=>n({...e,[t]:r}),l=([e,t])=>!!t&&t!==i&&!qe(t)&&!Re(e),f=e.transport===`stdio`?e.env.some(l):e.headers.some(l);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(a,{label:`Name`,technical:`name`,help:r?`A server's name can't be changed. Remove it and add it again under a new name.`:`Lower-case letters, digits and underscores. Its tools are shown to your AI app as name__tool.`,children:(0,Q.jsx)(u,{value:e.name,onChange:e=>c(`name`,e),mono:!0,disabled:r,placeholder:`files`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Where it runs`}),(0,Q.jsx)(p,{label:`Where it runs`,value:e.transport,onChange:e=>c(`transport`,e),options:[{value:`stdio`,label:`Runs on this computer`},{value:`http`,label:`Remote server`}]})]}),e.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Program to start`,technical:`command`,help:`The program the toolbox runs to start this server, such as npx or a full path.`,children:(0,Q.jsx)(u,{value:e.command,onChange:e=>c(`command`,e),mono:!0,placeholder:`npx`})}),(0,Q.jsx)(a,{label:`What to pass the program`,technical:`args`,optional:!0,help:`One item at a time. Press Enter after each.`,children:(0,Q.jsx)(t,{value:e.args,onChange:e=>c(`args`,e),placeholder:`-y, @modelcontextprotocol/server-filesystem`})}),(0,Q.jsx)(a,{label:`Values it is given`,technical:`env`,optional:!0,help:`Settings the server reads when it starts, such as an access key.`,children:(0,Q.jsx)(se,{value:e.env,onChange:e=>c(`env`,e),keyLabel:`Name of value`,valueLabel:`Value`,addLabel:`Add a value`,secret:i,valueType:`password`,keyPlaceholder:`API_KEY`})}),(0,Q.jsx)(a,{label:`Values passed on from the toolbox`,technical:`pass_env`,optional:!0,help:`Names of values the toolbox already has, given to this server as they are. Nothing else is passed on.`,children:(0,Q.jsx)(t,{value:e.passEnv,onChange:e=>c(`passEnv`,e),placeholder:`GITHUB_TOKEN`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Web address`,technical:`url`,children:(0,Q.jsx)(u,{value:e.url,onChange:e=>c(`url`,e),type:`url`,mono:!0,placeholder:`https://mcp.example.com/mcp`})}),(0,Q.jsx)(a,{label:`Headers sent with every request`,technical:`headers`,optional:!0,help:`Such as an access key the server expects.`,children:(0,Q.jsx)(se,{value:e.headers,onChange:e=>c(`headers`,e),keyLabel:`Header name`,valueLabel:`Header value`,addLabel:`Add a header`,secret:i,valueType:`password`,keyPlaceholder:`authorization`})})]}),o&&f&&(0,Q.jsx)(s,{tone:`warn`,title:`These values are saved in the toolbox's settings file as typed`,children:`A value whose name says it is a key (a TOKEN, KEY, SECRET or PASSWORD) goes into your locked keys instead. If another one is a password or key, give it a name like that, or anyone who can read the file can read it.`}),(0,Q.jsxs)(Te,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?z[e.onInjection].explain:`Uses the toolbox-wide setting.`,children:(0,Q.jsx)(k,{value:e.onInjection,onChange:e=>c(`onInjection`,e),options:[{value:``,label:`Same as the toolbox`},{value:`strip`,label:z.strip.label},{value:`deny`,label:z.deny.label},{value:`annotate`,label:z.annotate.label}]})}),e.transport===`stdio`?(0,Q.jsx)(a,{label:`Folder it starts in`,technical:`cwd`,optional:!0,children:(0,Q.jsx)(u,{value:e.cwd,onChange:e=>c(`cwd`,e),mono:!0,placeholder:`/Users/me/project`})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{checked:e.passthrough,onChange:e=>c(`passthrough`,e),label:`Send each caller's own sign-in`,description:`Instead of one shared key, the toolbox passes on the key each AI app connects with. This sends that key to this server.`}),e.passthrough&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Header it goes in`,technical:`credential_passthrough.header`,children:(0,Q.jsx)(u,{value:e.passthroughHeader,onChange:e=>c(`passthroughHeader`,e),mono:!0})}),(0,Q.jsx)(d,{checked:e.passthroughRequired,onChange:e=>c(`passthroughRequired`,e),label:`Refuse calls without a sign-in`,description:`Otherwise a caller with no key of its own falls back to the headers above.`})]})]})]})]})}function Rt({compact:e,tab:t,onTab:r,onCatalog:i,onDraft:a}){let[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1),d=e&&!c;if((0,Z.useEffect)(()=>{if(d)return;let e=!0;return n.settings().then(t=>e&&s(t.registry.enabled)).catch(()=>e&&s(!0)),()=>{e=!1}},[d]),d){let e=e=>{u(!0),r(e)};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(zt,{compact:!0,onPick:i}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Other ways:`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`registry`),children:`search the public list`}),` · `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`paste`),children:`paste instructions from a README`})]})]})}let f=[{id:`popular`,label:`Popular`},...o===!1?[]:[{id:`registry`,label:`Search the public list`}],{id:`paste`,label:`Paste instructions`},{id:`advanced`,label:`Advanced`}],p=t===`registry`&&o===!1?`popular`:t;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(M,{items:f,value:p,onChange:r,label:`Where to find the server`}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:y(p),"aria-labelledby":l(p),children:p===`popular`?(0,Q.jsx)(zt,{onPick:i}):p===`registry`?(0,Q.jsx)(Ht,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(Ut,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(Wt,{onDraft:a})})]})}function zt({onPick:e,compact:t}){let i=F(()=>n.catalog(),[]),[a,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(!1),p=i.data?.entries??[],h=a?rt(p,a,l):[...rt(p,a,l)].sort((e,t)=>Number(t.id===Bt)-Number(e.id===Bt)),g=[...new Set(p.map(e=>e.category))],v=t&&!d&&!a?6:1/0,y=h.slice(0,v);return i.error&&!i.data?(0,Q.jsx)(s,{tone:`danger`,title:`The list of servers could not be loaded`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:B(i.error)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search: files, GitHub, notes…`,"aria-label":`Search servers`,className:`field pl-10`})]}),!t&&g.length>1&&(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Kind of server`,className:`flex flex-wrap gap-1.5`,children:[`all`,...g].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:L(`h-8 rounded-full border-[1.5px] px-3.5 text-[13px] font-semibold transition-colors`,l===e?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:e===`all`?`All`:de[e]},e))})]}),i.data?h.length===0?(0,Q.jsxs)(_,{icon:`search`,title:`Nothing matches`,compact:!0,children:[`Try another word. You can also search the public list, or paste the server's setup instructions, using the `,t?`links below`:`tabs above`,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sr-only`,role:`status`,children:[r(h.length,`server`),` found`]}),(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:y.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Vt,{entry:t,onPick:()=>e(t)})},t.id))}),y.length<h.length&&(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),children:[`Show all `,h.length]})})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))})]})}var Bt=`filesystem`;function Vt({entry:t,onPick:n}){let r=De(t.requires);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-full w-full min-w-0 flex-col items-start gap-2 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15.5px] font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-muted`,children:[`by `,t.publisher.name]})]}),t.id===Bt?(0,Q.jsx)(e,{tone:`ok`,icon:`check`,children:`Good first choice`}):t.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.summary}),(r.setup.length>0||r.needs.length>0)&&(0,Q.jsxs)(`span`,{className:`mt-auto flex flex-wrap gap-1.5 pt-1`,children:[r.setup.length>0&&(0,Q.jsx)(`span`,{title:`Needs ${r.setup.map(e=>Ae[e]??e).join(` and `)}. The next screen walks you through it.`,children:(0,Q.jsx)(e,{icon:`wrench`,children:`Needs a little setup`})}),r.needs.map(t=>(0,Q.jsx)(e,{children:t},t))]})]})}function Ht({onCatalogId:t,onDraft:i}){let[a,c]=(0,Z.useState)(``),l=w(a.trim(),300),[u,d]=(0,Z.useState)(null),[p,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,T]=(0,Z.useState)(null),D=F(()=>n.catalog(),[]),O=l?rt(D.data?.entries??[],l).slice(0,3):[];(0,Z.useEffect)(()=>{if(!l){d(null),h([]),_(null),b(!1);return}let e=!0;return b(!0),n.registrySearch(l).then(t=>{e&&(d(t),h(t.hits),_(null))}).catch(t=>{e&&(t instanceof f&&(t.status===404||t.code===`registry-off`)?_(`Searching the public list is switched off in Settings & help.`):_(B(t)))}).finally(()=>e&&b(!1)),()=>{e=!1}},[l,x]),(0,Z.useEffect)(()=>{if(!u?.loading)return;let e=setTimeout(()=>S(e=>e+1),2e3);return()=>clearTimeout(e)},[u]);let k=()=>{u?.nextCursor&&(b(!0),n.registrySearch(l,u.nextCursor).then(e=>{d(e),h(t=>[...t,...e.hits])}).catch(e=>_(B(e))).finally(()=>b(!1)))},A=e=>{e.catalogId?(T(e.name),n.catalog().then(n=>t(e.catalogId,n.entries.find(t=>t.id===e.catalogId)??null)).catch(e=>_(B(e))).finally(()=>T(null))):e.draft&&i(e.draft,{})};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`A public directory of servers that anyone can publish to. Only the words you type are sent to it to find matches. Nobody has checked these servers, so look at who made one before you add it.`}),(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search the public list`,"aria-label":`Search the public list`,className:`field pl-10`}),y&&(0,Q.jsx)(`span`,{className:`absolute right-3.5 text-soft`,children:(0,Q.jsx)(ne,{})})]}),(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] text-soft`,children:u?.loading?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ne,{size:14}),` Getting the list…`]}):u&&l?`${r(u.total+O.length,`server`)}${u.updatedAt?` · list updated ${v(u.updatedAt)}`:``}`:null}),u?.problem&&(0,Q.jsx)(s,{tone:`warn`,children:u.problem}),g&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:()=>S(e=>e+1),children:`Try again`}),children:g}),l?!u&&!g?(0,Q.jsx)(o,{lines:4,height:18}):(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[O.map(n=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id,n),className:`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:n.name}),(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:n.summary}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`by `,n.publisher.name]})]})},`catalog-${n.id}`)),p.filter(e=>!e.catalogId||!O.some(t=>t.id===e.catalogId)).map(t=>{let n=!!t.catalogId||!!t.draft;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>A(t),"aria-describedby":n?void 0:`why-${t.name}`,className:L(`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] p-4 text-left transition-colors`,n?`border-line hover:border-[var(--soft)] hover:bg-faint/50`:`cursor-not-allowed border-line bg-sunken/40 opacity-70`),children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:t.title??t.name}),C===t.name&&(0,Q.jsx)(ne,{}),t.catalogId?(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`}):n?(0,Q.jsx)(e,{tone:`warn`,children:`From the public list — not checked by us`}):(0,Q.jsx)(e,{children:`Can't be added`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.description}),t.caution&&(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,className:`mt-0.5 shrink-0`}),t.caution]}),(0,Q.jsxs)(`code`,{className:`mono text-[11.5px] text-soft`,children:[t.name,` · `,t.version]}),!n&&(0,Q.jsx)(`span`,{id:`why-${t.name}`,className:`text-[12.5px] text-soft`,children:t.unsupported??`It can't be started from the public list's description.`})]})},t.name)})]}):(0,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:`Type the name of a server or a service, such as “weather” or “slack”, to search the public list.`}),u?.nextCursor&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:k,loading:y,children:`Show more`})})]})}function Ut({onDraft:e,onAdvanced:t}){let[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-paste`,className:`text-[13px] font-semibold`,children:`Paste the setup instructions`}),(0,Q.jsx)(`textarea`,{id:`add-paste`,rows:8,value:i,onChange:e=>{a(e.target.value),u(null)},"aria-describedby":`add-paste-help`,placeholder:`{
1
+ import{$ as e,A as t,At as n,B as r,Ct as i,E as a,G as o,H as s,It as c,J as l,M as u,N as d,Nt as f,O as p,Ot as m,Pt as h,Tt as g,U as _,V as v,Y as y,Z as b,_t as x,a as S,b as C,bt as w,et as T,ht as E,i as D,jt as O,k,kt as A,n as j,o as ee,q as M,r as N,rt as P,s as F,t as I,tt as te,vt as ne,w as re,x as ie,xt as ae,y as oe,yt as L}from"./kit-BHB_ha4i.js";import{$ as se,A as ce,B as le,Bt as ue,C as de,D as fe,E as pe,F as R,Ft as z,G as me,H as he,I as ge,J as _e,Jt as ve,K as ye,Kt as B,L as be,Lt as V,M as xe,Mn as H,N as Se,Nt as U,O as Ce,P as we,Q as Te,Qt as Ee,R as De,Rt as Oe,S as ke,T as Ae,U as je,Ut as W,V as Me,Vt as G,W as Ne,Wt as Pe,X as Fe,Y as Ie,Yt as Le,Zt as Re,b as ze,bn as Be,cn as K,ct as Ve,dn as He,en as Ue,et as q,fn as J,j as We,k as Ge,ln as Y,m as Ke,nn as qe,nt as Je,on as Ye,q as Xe,rn as X,rt as Ze,s as Qe,sn as $e,tn as et,tt,x as nt,z as rt,zt as it}from"./index-2otwle61.js";import{A as at,B as ot,C as st,D as ct,E as lt,G as ut,H as dt,I as ft,J as pt,K as mt,L as ht,M as gt,N as _t,O as vt,R as yt,S as bt,T as xt,U as St,V as Ct,W as wt,b as Tt,d as Et,f as Dt,j as Ot,k as kt,q as At,w as jt,x as Mt,y as Nt,z as Pt}from"./connect-app-words-B_5RQcK_.js";var Z=c(),Q=A(),Ft=()=>({name:``,transport:`stdio`,command:``,args:[],env:[],passEnv:[],cwd:``,url:``,headers:[],passthrough:!1,passthroughHeader:`authorization`,passthroughRequired:!1,onInjection:``});function It(e){let t=Ft();return t.name=e.name,t.transport=e.transport,t.onInjection=e.on_injection??``,e.transport===`stdio`?(t.command=e.command,t.args=e.args??[],t.env=Ze(e.env),t.passEnv=e.pass_env??[],t.cwd=e.cwd??``):(t.url=e.url,t.headers=Ze(e.headers),t.passthrough=!!e.credential_passthrough?.enabled,t.passthroughHeader=e.credential_passthrough?.header??`authorization`,t.passthroughRequired=!!e.credential_passthrough?.required),t}function Lt(e){let t=e.onInjection?{on_injection:e.onInjection}:{};return e.transport===`stdio`?{name:e.name.trim(),transport:`stdio`,...t,command:e.command.trim(),...e.args.length?{args:e.args}:{},...e.env.length?{env:Je(e.env)}:{},...e.passEnv.length?{pass_env:e.passEnv}:{},...e.cwd.trim()?{cwd:e.cwd.trim()}:{}}:{name:e.name.trim(),transport:`http`,...t,url:e.url.trim(),...e.headers.length?{headers:Je(e.headers)}:{},...e.passthrough?{credential_passthrough:{enabled:!0,header:e.passthroughHeader.trim()||`authorization`,required:e.passthroughRequired}}:{}}}function Rt(e,t=[]){if(!/^[a-z0-9_]+$/.test(e.name.trim()))return`Give the server a name of lower-case letters, digits and underscores.`;if(t.includes(e.name.trim()))return`Another connected server is already called “${e.name.trim()}”.`;if(e.transport===`stdio`&&!e.command.trim())return`Say which program starts the server.`;if(e.transport===`http`)try{new URL(e.url.trim())}catch{return`Enter the server's full web address, starting with https://.`}return null}function zt({value:e,onChange:n,nameLocked:r,secret:i,literalWarning:o}){let c=(t,r)=>n({...e,[t]:r}),l=([e,t])=>!!t&&t!==i&&!qe(t)&&!Re(e),f=e.transport===`stdio`?e.env.some(l):e.headers.some(l);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(a,{label:`Name`,technical:`name`,help:r?`A server's name can't be changed. Remove it and add it again under a new name.`:`Lower-case letters, digits and underscores. Its tools are shown to your AI app as name__tool.`,children:(0,Q.jsx)(u,{value:e.name,onChange:e=>c(`name`,e),mono:!0,disabled:r,placeholder:`files`})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Where it runs`}),(0,Q.jsx)(p,{label:`Where it runs`,value:e.transport,onChange:e=>c(`transport`,e),options:[{value:`stdio`,label:`Runs on this computer`},{value:`http`,label:`Remote server`}]})]}),e.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Program to start`,technical:`command`,help:`The program the toolbox runs to start this server, such as npx or a full path.`,children:(0,Q.jsx)(u,{value:e.command,onChange:e=>c(`command`,e),mono:!0,placeholder:`npx`})}),(0,Q.jsx)(a,{label:`What to pass the program`,technical:`args`,optional:!0,help:`One item at a time. Press Enter after each.`,children:(0,Q.jsx)(t,{value:e.args,onChange:e=>c(`args`,e),placeholder:`-y, @modelcontextprotocol/server-filesystem`})}),(0,Q.jsx)(a,{label:`Values it is given`,technical:`env`,optional:!0,help:`Settings the server reads when it starts, such as an access key.`,children:(0,Q.jsx)(se,{value:e.env,onChange:e=>c(`env`,e),keyLabel:`Name of value`,valueLabel:`Value`,addLabel:`Add a value`,secret:i,valueType:`password`,keyPlaceholder:`API_KEY`})}),(0,Q.jsx)(a,{label:`Values passed on from the toolbox`,technical:`pass_env`,optional:!0,help:`Names of values the toolbox already has, given to this server as they are. Nothing else is passed on.`,children:(0,Q.jsx)(t,{value:e.passEnv,onChange:e=>c(`passEnv`,e),placeholder:`GITHUB_TOKEN`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Web address`,technical:`url`,children:(0,Q.jsx)(u,{value:e.url,onChange:e=>c(`url`,e),type:`url`,mono:!0,placeholder:`https://mcp.example.com/mcp`})}),(0,Q.jsx)(a,{label:`Headers sent with every request`,technical:`headers`,optional:!0,help:`Such as an access key the server expects.`,children:(0,Q.jsx)(se,{value:e.headers,onChange:e=>c(`headers`,e),keyLabel:`Header name`,valueLabel:`Header value`,addLabel:`Add a header`,secret:i,valueType:`password`,keyPlaceholder:`authorization`})})]}),o&&f&&(0,Q.jsx)(s,{tone:`warn`,title:`These values are saved in the toolbox's settings file as typed`,children:`A value whose name says it is a key (a TOKEN, KEY, SECRET or PASSWORD) goes into your locked keys instead. If another one is a password or key, give it a name like that, or anyone who can read the file can read it.`}),(0,Q.jsxs)(Te,{title:`More options`,children:[(0,Q.jsx)(a,{label:`Hidden instructions in its tool descriptions`,technical:`on_injection`,help:e.onInjection?z[e.onInjection].explain:`Uses the toolbox-wide setting.`,children:(0,Q.jsx)(k,{value:e.onInjection,onChange:e=>c(`onInjection`,e),options:[{value:``,label:`Same as the toolbox`},{value:`strip`,label:z.strip.label},{value:`deny`,label:z.deny.label},{value:`annotate`,label:z.annotate.label}]})}),e.transport===`stdio`?(0,Q.jsx)(a,{label:`Folder it starts in`,technical:`cwd`,optional:!0,children:(0,Q.jsx)(u,{value:e.cwd,onChange:e=>c(`cwd`,e),mono:!0,placeholder:`/Users/me/project`})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{checked:e.passthrough,onChange:e=>c(`passthrough`,e),label:`Send each caller's own sign-in`,description:`Instead of one shared key, the toolbox passes on the key each AI app connects with. This sends that key to this server.`}),e.passthrough&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(a,{label:`Header it goes in`,technical:`credential_passthrough.header`,children:(0,Q.jsx)(u,{value:e.passthroughHeader,onChange:e=>c(`passthroughHeader`,e),mono:!0})}),(0,Q.jsx)(d,{checked:e.passthroughRequired,onChange:e=>c(`passthroughRequired`,e),label:`Refuse calls without a sign-in`,description:`Otherwise a caller with no key of its own falls back to the headers above.`})]})]})]})]})}function Bt({compact:e,tab:t,onTab:r,onCatalog:i,onDraft:a}){let[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(!1),d=e&&!c;if((0,Z.useEffect)(()=>{if(d)return;let e=!0;return n.settings().then(t=>e&&s(t.registry.enabled)).catch(()=>e&&s(!0)),()=>{e=!1}},[d]),d){let e=e=>{u(!0),r(e)};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(Vt,{compact:!0,onPick:i}),(0,Q.jsxs)(`p`,{className:`text-[13px] text-soft`,children:[`Other ways:`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`registry`),children:`search the public list`}),` · `,(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-muted underline hover:text-ink`,onClick:()=>e(`paste`),children:`paste instructions from a README`})]})]})}let f=[{id:`popular`,label:`Popular`},...o===!1?[]:[{id:`registry`,label:`Search the public list`}],{id:`paste`,label:`Paste instructions`},{id:`advanced`,label:`Advanced`}],p=t===`registry`&&o===!1?`popular`:t;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(M,{items:f,value:p,onChange:r,label:`Where to find the server`}),(0,Q.jsx)(`div`,{role:`tabpanel`,id:y(p),"aria-labelledby":l(p),children:p===`popular`?(0,Q.jsx)(Vt,{onPick:i}):p===`registry`?(0,Q.jsx)(Wt,{onCatalogId:(e,t)=>t&&i(t),onDraft:a}):p===`paste`?(0,Q.jsx)(Gt,{onDraft:a,onAdvanced:()=>r(`advanced`)}):(0,Q.jsx)(Kt,{onDraft:a})})]})}function Vt({onPick:e,compact:t}){let i=F(()=>n.catalog(),[]),[a,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(`all`),[d,f]=(0,Z.useState)(!1),p=i.data?.entries??[],h=a?rt(p,a,l):[...rt(p,a,l)].sort((e,t)=>Number(t.id===Ht)-Number(e.id===Ht)),g=[...new Set(p.map(e=>e.category))],v=t&&!d&&!a?6:1/0,y=h.slice(0,v);return i.error&&!i.data?(0,Q.jsx)(s,{tone:`danger`,title:`The list of servers could not be loaded`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:i.reload,children:`Try again`}),children:B(i.error)}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search: files, GitHub, notes…`,"aria-label":`Search servers`,className:`field pl-10`})]}),!t&&g.length>1&&(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Kind of server`,className:`flex flex-wrap gap-1.5`,children:[`all`,...g].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":l===e,onClick:()=>u(e),className:L(`h-8 rounded-full border-[1.5px] px-3.5 text-[13px] font-semibold transition-colors`,l===e?`border-primary bg-primary text-white`:`border-line text-muted hover:border-[var(--soft)] hover:text-ink`),children:e===`all`?`All`:de[e]},e))})]}),i.data?h.length===0?(0,Q.jsxs)(_,{icon:`search`,title:`Nothing matches`,compact:!0,children:[`Try another word. You can also search the public list, or paste the server's setup instructions, using the `,t?`links below`:`tabs above`,`.`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sr-only`,role:`status`,children:[r(h.length,`server`),` found`]}),(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:y.map(t=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Ut,{entry:t,onPick:()=>e(t)})},t.id))}),y.length<h.length&&(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),children:[`Show all `,h.length]})})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))})]})}var Ht=`filesystem`;function Ut({entry:t,onPick:n}){let r=De(t.requires);return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-full w-full min-w-0 flex-col items-start gap-2 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15.5px] font-semibold`,children:t.name}),(0,Q.jsxs)(`span`,{className:`block text-[12.5px] text-muted`,children:[`by `,t.publisher.name]})]}),t.id===Ht?(0,Q.jsx)(e,{tone:`ok`,icon:`check`,children:`Good first choice`}):t.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.summary}),(r.setup.length>0||r.needs.length>0)&&(0,Q.jsxs)(`span`,{className:`mt-auto flex flex-wrap gap-1.5 pt-1`,children:[r.setup.length>0&&(0,Q.jsx)(`span`,{title:`Needs ${r.setup.map(e=>Ae[e]??e).join(` and `)}. The next screen walks you through it.`,children:(0,Q.jsx)(e,{icon:`wrench`,children:`Needs a little setup`})}),r.needs.map(t=>(0,Q.jsx)(e,{children:t},t))]})]})}function Wt({onCatalogId:t,onDraft:i}){let[a,c]=(0,Z.useState)(``),l=w(a.trim(),300),[u,d]=(0,Z.useState)(null),[p,h]=(0,Z.useState)([]),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,T]=(0,Z.useState)(null),D=F(()=>n.catalog(),[]),O=l?rt(D.data?.entries??[],l).slice(0,3):[];(0,Z.useEffect)(()=>{if(!l){d(null),h([]),_(null),b(!1);return}let e=!0;return b(!0),n.registrySearch(l).then(t=>{e&&(d(t),h(t.hits),_(null))}).catch(t=>{e&&(t instanceof f&&(t.status===404||t.code===`registry-off`)?_(`Searching the public list is switched off in Settings & help.`):_(B(t)))}).finally(()=>e&&b(!1)),()=>{e=!1}},[l,x]),(0,Z.useEffect)(()=>{if(!u?.loading)return;let e=setTimeout(()=>S(e=>e+1),2e3);return()=>clearTimeout(e)},[u]);let k=()=>{u?.nextCursor&&(b(!0),n.registrySearch(l,u.nextCursor).then(e=>{d(e),h(t=>[...t,...e.hits])}).catch(e=>_(B(e))).finally(()=>b(!1)))},A=e=>{e.catalogId?(T(e.name),n.catalog().then(n=>t(e.catalogId,n.entries.find(t=>t.id===e.catalogId)??null)).catch(e=>_(B(e))).finally(()=>T(null))):e.draft&&i(e.draft,{})};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`A public directory of servers that anyone can publish to. Only the words you type are sent to it to find matches. Nobody has checked these servers, so look at who made one before you add it.`}),(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(m,{name:`search`,size:17,className:`pointer-events-none absolute left-3.5 text-soft`}),(0,Q.jsx)(`input`,{type:`search`,value:a,onChange:e=>c(e.target.value),placeholder:`Search the public list`,"aria-label":`Search the public list`,className:`field pl-10`}),y&&(0,Q.jsx)(`span`,{className:`absolute right-3.5 text-soft`,children:(0,Q.jsx)(ne,{})})]}),(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] text-soft`,children:u?.loading?(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ne,{size:14}),` Getting the list…`]}):u&&l?`${r(u.total+O.length,`server`)}${u.updatedAt?` · list updated ${v(u.updatedAt)}`:``}`:null}),u?.problem&&(0,Q.jsx)(s,{tone:`warn`,children:u.problem}),g&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:()=>S(e=>e+1),children:`Try again`}),children:g}),l?!u&&!g?(0,Q.jsx)(o,{lines:4,height:18}):(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2`,children:[O.map(n=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id,n),className:`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] border-line p-4 text-left transition-colors hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:n.name}),(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:n.summary}),(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`by `,n.publisher.name]})]})},`catalog-${n.id}`)),p.filter(e=>!e.catalogId||!O.some(t=>t.id===e.catalogId)).map(t=>{let n=!!t.catalogId||!!t.draft;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,onClick:()=>A(t),"aria-describedby":n?void 0:`why-${t.name}`,className:L(`flex w-full min-w-0 flex-col items-start gap-1 rounded-[18px] border-[1.5px] p-4 text-left transition-colors`,n?`border-line hover:border-[var(--soft)] hover:bg-faint/50`:`cursor-not-allowed border-line bg-sunken/40 opacity-70`),children:[(0,Q.jsxs)(`span`,{className:`flex w-full flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[15px] font-semibold`,children:t.title??t.name}),C===t.name&&(0,Q.jsx)(ne,{}),t.catalogId?(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Checked by us`}):n?(0,Q.jsx)(e,{tone:`warn`,children:`From the public list — not checked by us`}):(0,Q.jsx)(e,{children:`Can't be added`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:t.description}),t.caution&&(0,Q.jsxs)(`span`,{className:`flex items-start gap-1.5 text-[12.5px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,className:`mt-0.5 shrink-0`}),t.caution]}),(0,Q.jsxs)(`code`,{className:`mono text-[11.5px] text-soft`,children:[t.name,` · `,t.version]}),!n&&(0,Q.jsx)(`span`,{id:`why-${t.name}`,className:`text-[12.5px] text-soft`,children:t.unsupported??`It can't be started from the public list's description.`})]})},t.name)})]}):(0,Q.jsx)(`p`,{className:`rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:`Type the name of a server or a service, such as “weather” or “slack”, to search the public list.`}),u?.nextCursor&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:k,loading:y,children:`Show more`})})]})}function Gt({onDraft:e,onAdvanced:t}){let[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-paste`,className:`text-[13px] font-semibold`,children:`Paste the setup instructions`}),(0,Q.jsx)(`textarea`,{id:`add-paste`,rows:8,value:i,onChange:e=>{a(e.target.value),u(null)},"aria-describedby":`add-paste-help`,placeholder:`{
2
2
  "mcpServers": {
3
3
  "weather": { "command": "npx", "args": ["-y", "weather-mcp"] }
4
4
  }
5
- }`,className:`field resize-y font-mono text-[13px]`}),(0,Q.jsx)(`p`,{id:`add-paste-help`,className:`text-[12.5px] text-soft`,children:`Copy the part of the server's instructions page (often called its README) that shows how to add it: a block of settings, a one-line command, or just its web address. Nothing is saved yet, and any keys in it go into your locked keys, never into a settings file.`})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{variant:`primary`,icon:`search`,onClick:()=>{c(!0),f(null),n.paste(i).then(u).catch(e=>f(B(e))).finally(()=>c(!1))},loading:o,disabled:!i.trim(),children:`Read it`})}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),l&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-3`,children:[l.servers.length===0?(0,Q.jsx)(s,{tone:`warn`,title:`No server could be added from that`,children:l.warnings.length>0&&!/didn't look like setup instructions/.test(l.warnings.join(` `))?(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):(0,Q.jsxs)(Q.Fragment,{children:[`We couldn't find a server in that. Paste the line that starts with `,(0,Q.jsx)(`code`,{className:`mono`,children:`npx`}),`, `,(0,Q.jsx)(`code`,{className:`mono`,children:`uvx`}),` or`,` `,(0,Q.jsx)(`code`,{className:`mono`,children:`docker`}),`, the block that contains `,(0,Q.jsx)(`code`,{className:`mono`,children:`mcpServers`}),`, or the server's web address. You can also add it by hand under`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-semibold underline`,onClick:t,children:`Advanced`}),`.`]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`Found `,r(l.servers.length,`server`),l.recognisedAs&&(0,Q.jsxs)(`span`,{className:`font-normal text-soft`,children:[` · read as `,l.recognisedAs]})]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.servers.map((t,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>e(t.draft,t.values),className:`flex w-full items-center gap-3 rounded-[18px] border-[1.5px] border-line p-4 text-left hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(m,{name:t.draft.launch.transport===`http`?`external`:`server`,size:18})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:t.draft.displayName}),(0,Q.jsx)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:t.draft.launch.transport===`http`?`Remote server · ${t.draft.launch.url}`:`Runs on this computer · ${[t.draft.launch.command,...t.draft.launch.args??[]].join(` `)}`}),t.draft.warnings.map(e=>(0,Q.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:e},e))]}),(0,Q.jsx)(m,{name:`chevron-right`,size:18,className:`shrink-0 text-soft`})]})},`${t.draft.name}-${n}`))})]}),l.servers.length>0&&l.warnings.length>0&&(0,Q.jsx)(s,{tone:`info`,title:`Note`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})})]})]})}function Wt({onDraft:e}){let[t,n]=(0,Z.useState)(Nt()),[r,i]=(0,Z.useState)(!1),a=It(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`For a server you know how to start. Values whose names look like keys (TOKEN, KEY, SECRET, PASSWORD) go into your locked keys rather than the toolbox's settings file.`}),(0,Q.jsx)(Lt,{value:t,onChange:n}),r&&a&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:a}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(E,{variant:`primary`,iconRight:`arrow-right`,onClick:()=>{if(i(!0),a)return;let n=we(Ft(t));e(n.draft,n.values)},children:`Continue`})})]})}function Gt({transport:e}){let[t,n]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,Q.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Q.jsx)(ne,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:he(t,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`Nothing is saved yet. `,t>2&&(0,Q.jsxs)(`span`,{className:`tnum`,children:[`(`,t,` s)`]})]})]})]})}var Kt=[`run`,`ask`,`blocked`],qt={run:`Your AI can use these without asking.`,ask:`Once protection is on, each use waits until you say yes.`,blocked:`Once protection is on, your AI can't use these.`};function Jt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=xe(e),a=Ie(e),o=Kt.filter(e=>i[e].length>0);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 rounded-[18px] bg-ok-tint p-4`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-surface text-ok`,children:(0,Q.jsx)(m,{name:`check`,size:20,strokeWidth:2.2})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:r?`${t} started`:`${t} works`}),(0,Q.jsxs)(`span`,{className:`block text-[13.5px] text-muted`,children:[je(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(tt,{sub:n?`What happens when your AI uses each tool once protection is on. Right now your toolbox only watches, so everything runs and is written down. You can change any of this later on the Tools page.`:n===!1?`What happens when your AI uses each tool. Protection is on. You can change any of this later on the Tools page.`:`What happens when your AI uses each tool once protection is on. You can change any of this later on the Tools page.`,children:`What your AI can do`}),(0,Q.jsx)(`div`,{className:L(`grid gap-3`,o.length===2?`md:grid-cols-2`:o.length>=3?`lg:grid-cols-3 md:grid-cols-2`:``),children:o.map(e=>(0,Q.jsx)(Yt,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(tt,{children:a.lines.length>0?`Please check`:`Note`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.lines.map((e,t)=>(0,Q.jsxs)(`li`,{className:L(`flex gap-2 rounded-2xl p-3`,e.tone===`warn`?`bg-warn-tint`:`border border-line`),children:[(0,Q.jsx)(m,{name:e.text.startsWith(`Won't be offered`)?`eye-off`:`warning`,size:17,className:L(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[e.tool&&(0,Q.jsx)(`code`,{className:`mono mr-1 font-semibold`,children:e.tool}),e.text,e.technical&&(0,Q.jsxs)(`details`,{className:`mt-1`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[12.5px] text-soft select-none`,children:`Details`}),(0,Q.jsx)(`p`,{className:`mono mt-1 text-[12px] break-words text-soft`,children:e.technical})]})]})]},t)),a.quiet&&(0,Q.jsx)(`li`,{className:`rounded-2xl border border-line p-3 text-muted`,children:(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer select-none`,children:[a.quiet.text,` `,(0,Q.jsx)(`span`,{className:`text-soft underline`,children:`Details`})]}),(0,Q.jsx)(`ul`,{className:`mt-2 flex max-h-64 flex-col gap-1 overflow-auto text-[12px] text-soft`,children:a.quiet.details.map((e,t)=>(0,Q.jsxs)(`li`,{className:`mono break-words`,children:[e.tool&&(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e.tool,`: `]}),e.text]},t))})]})})]})]})]})}function Yt({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=Ce[e];return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(T,{decision:o}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.length})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 mb-2 text-[12.5px] text-soft`,children:qt[e]}),(0,Q.jsx)(`ul`,{className:L(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":te[o].label,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Q.jsx)(b,{effect:e.effect}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`block text-[13px] [overflow-wrap:anywhere]`,title:e.description?`${e.name}: ${e.description}`:e.name,children:e.title??Qe(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:P[e.effect]?.label}),e.packRule&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11.5px] text-muted`,title:`Decided by a ready-made rule for this server`,children:`Ready-made rule`})]},e.name))}),!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>i(!0),children:[`Show all `,t.length]}),(0,Q.jsxs)(`details`,{className:`mt-2 text-[12px] text-soft`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Q.jsxs)(`p`,{className:`mt-1`,children:[`The server's own names:`,` `,t.map((e,t)=>(0,Q.jsxs)(`span`,{children:[t>0&&`, `,(0,Q.jsx)(`code`,{className:`mono break-normal`,children:ee(e.name)})]},e.name))]})]})]})}var Xt=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function Zt({draft:t,entry:n,values:r,onValues:i,problems:a,tried:o,onVariant:c,name:l,onName:u,signedIn:f,onSignedIn:p,doctor:h,doctorBusy:g,onRecheck:_,focus:v}){let[y,b]=(0,Z.useState)({}),x=(e,t)=>i({...r,[e]:t}),S=t.source.kind===`catalog`?t.source.variant:null,C=n?.variants??[],w=R(t.requires,h),T=Ne(t),E=t.launch.transport===`http`?We(t.launch.url,r):``,D=Me(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(Xt(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let O=e=>a[e.id]??(o||y[e.id]?ye(e,r[e.id]):null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[20px] font-medium tracking-[-0.02em]`,children:t.displayName}),n?.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`}),t.source.kind===`registry`&&(0,Q.jsx)(e,{tone:`warn`,icon:`warning`,children:`From the public list — not checked by us`}),t.source.kind===`paste`&&(0,Q.jsx)(e,{children:`From what you pasted`}),t.requires.map(t=>(0,Q.jsxs)(e,{children:[`Needs `,Ae[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(N,{text:n?.description??n?.summary??``})})]}),t.warnings.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Before you go on`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})}),D&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl bg-warn-tint px-4 py-3`,children:[(0,Q.jsx)(d,{checked:r.__local_ok===!0,onChange:e=>x(`__local_ok`,e),label:`This is on my own computer or network`,description:D===`loopback`?`This server's address is on this computer. Testing it lets the toolbox reach that address, just for the test. Only tick this if you started that program yourself.`:`This server's address is on your own network (a router or another computer). Testing it lets the toolbox reach that address, just for the test. Only tick this if you know what is there.`}),a.__local_ok&&r.__local_ok!==!0&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),`Tick this first, or choose another server.`]})]}),(0,Q.jsx)(nt,{missing:w,platform:h?.platform,onRecheck:_,checking:g}),C.length>1&&S&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:`How to run it`}),(0,Q.jsx)(Fe,{label:`How to run it`,value:S,onChange:c,options:C.map(e=>({value:e.id,title:e.label,body:(0,Q.jsxs)(Q.Fragment,{children:[e.summary??(e.launch.transport===`http`?`Runs on the service's own computers. Nothing to install.`:`Runs on this computer.`),(e.requires??[]).length>0&&(0,Q.jsxs)(`span`,{className:`mt-1 block`,children:[`Needs `,(e.requires??[]).map(e=>Ae[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:L(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(j,{steps:t.guide,className:`md:self-start`}),(0,Q.jsxs)(`section`,{"aria-label":`Settings for this server`,className:`flex min-w-0 flex-col gap-5`,children:[T&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Sign in`}),(0,Q.jsx)(ze,{serverUrl:E,secretName:le(l||t.name),name:t.displayName,signedIn:f,onSignedIn:p,startNonce:v?.kind===`sign-in`?v.nonce:void 0})]}),t.fields.map(e=>(0,Q.jsx)(Qt,{field:e,value:r[e.id],storedAs:typeof r[`__saved.${e.id}`]==`string`?r[`__saved.${e.id}`]:void 0,onChange:t=>x(e.id,t),onBlur:()=>b(t=>({...t,[e.id]:!0})),error:O(e),openFolder:v?.kind===`folder`&&(!v.field||v.field===e.id)?v.nonce:void 0},e.id)),t.fields.length===0&&!T&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:[(0,Q.jsx)(m,{name:`check`,size:17,className:`text-ok`}),` Nothing to fill in. Test it to see what it can do.`]}),(0,Q.jsxs)(Te,{title:`More options`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-server-name`,className:`text-[13px] font-semibold`,children:`Name in your toolbox`}),(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:`name`})]}),(0,Q.jsx)(`input`,{id:`add-server-name`,className:`field font-mono text-[13px]`,value:l,onChange:e=>u(e.target.value),"aria-describedby":`add-server-name-help`,"aria-invalid":!!ge(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:L(`text-[12.5px]`,ge(l)?`font-medium text-bad`:`text-soft`),children:ge(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)($t,{draft:t})]})]})]}),w.length===0&&t.requires.length>0&&h&&(0,Q.jsx)(`p`,{className:`sr-only`,role:`status`,children:`This computer has everything this server needs.`})]})}function Qt({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=Xt(e.id),c=`${s}-help`,l=`${s}-err`,u=[e.help&&!i?c:null,i?l:null].filter(Boolean).join(` `)||void 0;if(e.kind===`toggle`)return(0,Q.jsx)(d,{checked:t===!0,onChange:n,label:e.label,description:e.help});let f=typeof t==`string`?t:``,p=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],h=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsxs)(`label`,{htmlFor:s,className:`text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&e.kind!==`choice`&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:`optional`})]}),e.technical&&(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:e.technical})]}),g;return g=e.kind===`secret`?(0,Q.jsx)(D,{id:s,value:f,onChange:n,storedAs:o,placeholder:e.placeholder,"aria-describedby":u,invalid:!!i}):e.kind===`folder`||e.kind===`folders`?(0,Q.jsx)(I,{id:s,value:p,multiple:e.kind===`folders`,onChange:t=>{n(e.kind===`folders`?t:t[0]??``),r()},openNonce:a,"aria-describedby":u}):e.kind===`choice`?(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`select`,{id:s,value:f,onChange:e=>n(e.target.value),onBlur:r,"aria-describedby":u,"aria-invalid":!!i||void 0,className:`field appearance-none pr-9`,children:(e.choices??[]).map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Q.jsx)(m,{name:`chevron`,size:16,className:`pointer-events-none absolute right-3 text-soft`})]}):(0,Q.jsx)(`input`,{id:s,type:e.kind===`url`?`url`:`text`,value:f,onChange:e=>n(e.target.value),onBlur:r,placeholder:e.placeholder??(e.kind===`url`?`https://`:void 0),spellCheck:!1,"aria-describedby":u,"aria-invalid":!!i||void 0,className:L(`field`,e.kind===`url`&&`font-mono text-[13px]`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.kind===`folder`||e.kind===`folders`?(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`font-normal text-soft`,children:`optional`})]}):h,g,e.help&&!i&&(0,Q.jsx)(`p`,{id:c,className:`text-[12.5px] text-soft`,children:(0,Q.jsx)(N,{text:e.help})}),i&&(0,Q.jsxs)(`p`,{id:l,role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),i]})]})}function $t({draft:e}){let t=e.launch,n=e=>typeof e==`string`?e:`${e.prefix??``}<locked key: ${e.field}>`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px]`,children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:`What it runs`}),t.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:[t.command,...t.args??[]].join(` `)}),Object.entries(t.env??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`=`,n(t)]},e))]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:t.url}),Object.entries(t.headers??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`: `,n(t)]},e))]})]})}var $={saved:null},en=new Set([`brave-search`]);function tn(){$.saved=null}function nn(e){let{gatewayId:t,onDone:r,onCancel:i,initialCatalogId:a,compact:c,fixUpstream:l}=e,[u,d]=(0,Z.useState)(`popular`),[p,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(a??null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(``),[D,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[ee,M]=(0,Z.useState)({}),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),[te,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(!1),[oe,L]=(0,Z.useState)(!1),[se,ue]=(0,Z.useState)(null),[de,R]=(0,Z.useState)(null),[z,he]=(0,Z.useState)($.saved),[ve,ye]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){ye(!0);return}let e=!0;return h.protection(t).then(t=>e&&ye(t.enforcement!==`enforce`)).catch(()=>e&&ye(null)),()=>{e=!1}},[t]);let[V,xe]=(0,Z.useState)(null),H=e=>{$.saved=e,he(e)},U=(0,Z.useRef)(null),Ce=z?`done`:N&&N.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{U.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),xe(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(pe)));S({...Se(e,n),...r}),T(e.name),k(!1),j(!1),M({}),P(null),ue(null),e.requires.length&&!te&&je()},Te=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(B(e))).finally(()=>v(null))},[De,Oe]=(0,Z.useState)(!1),Ae=async(e,t,r)=>{Oe(!0),b(null);try{let i=(await n.catalog()).entries,a=Ge(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Xe(o,e,r),c=a.entry):{draft:o,values:s}=ce(e,r),we(o,c,s),xe(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)I({kind:`folder`,field:u([`folder`,`folders`]),nonce:l});else if(t===`replace-key`){let e=u([`secret`]);e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${pe}${e}`))),I(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&I({kind:`sign-in`,nonce:l})}catch(e){b(B(e))}finally{Oe(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&Ae(l.upstream,l.action,l.path)},[l?.upstream.name,l?.action]),(0,Z.useEffect)(()=>{a&&!$.saved&&n.catalog().then(e=>{let t=e.entries.find(e=>e.id===a);t?Te(t):v(null)}).catch(e=>{b(B(e)),v(null)})},[a]);let je=()=>{ae(!0),n.doctor().then(re).catch(()=>void 0).finally(()=>ae(!1))},W=p?.draft??null,G=W?Ne(W):!1,Pe=le(w||W?.name||`server`),Fe=()=>{if(!W)return;j(!0),ue(null);let e=me(W,x);if(Object.keys(e).length||ge(w)){let t=W.fields.find(t=>e[t.id]);t&&I({kind:`field`,field:t.id,nonce:Date.now()}),P({kind:`error`,text:ge(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else G&&!D?P({kind:`error`,text:`Sign in with ${W.displayName} first.`}):Me(W,x)&&x.__local_ok!==!0?P({kind:`error`,text:`This server's address is on your own computer or network. Tick “This is on my own computer or network” first, or choose another server.`}):(P({kind:`running`}),M({}),n.testServer({...t?{gatewayId:t}:{},draft:W,values:G?{...x,[fe]:Pe}:x,...w.trim()===W.name?{}:{name:w.trim()},...V?{replacing:V}:{}}).then(e=>{if(Object.keys(e.problems).length){M(e.problems);let t=W.fields.find(t=>e.problems[t.id]);t&&I({kind:`field`,field:t.id,nonce:Date.now()}),P({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else P({kind:`done`,res:e})}).catch(e=>P({kind:`error`,text:B(e)})))},Ie=e=>{if(!W)return;let t=Date.now(),n=e=>W.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return Fe();case`install-runtime`:case`start-runtime`:return je();case`show-details`:return;case`choose-folder`:{P(null);let e=n([`folder`,`folders`]);if(!e&&W.launch.transport===`stdio`&&p){let e=N?.kind===`done`?N.res.outcome.problem?.detail?.path:void 0,n=ce({name:w||W.name,transport:`stdio`,command:W.launch.command,args:W.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...W,launch:{...W.launch,args:n.draft.launch.args??[]},fields:[...W.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),I({kind:`folder`,field:`folders`,nonce:t})}return I(null)}return I({kind:`folder`,field:e,nonce:t})}case`replace-key`:{P(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${pe}${e}`))),I(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Ne(W)&&p&&g({...p,draft:_e(W)}),P(null),k(!1),I({kind:`sign-in`,nonce:t});case`check-address`:{P(null);let e=n([`url`,`text`]);return I(e?{kind:`field`,field:e,nonce:t}:null)}}},[Le,Re]=(0,Z.useState)(null),ze=async(e,t,n)=>{if(!z)return;Re(null);let{upstreamName:r}=z.result;if(p){H(null),xe(r),T(r),Ie(e);return}let i=t;if(!i)try{i=(await Be(z.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Re(B(e));return}i?(H(null),await Ae(i,e,n)):Re(`The server "${r}" isn't in your toolbox any more.`)},K=(0,Z.useRef)(!1),He=async e=>{if(N?.kind!==`done`||K.current)return;K.current=!0,L(!0),ue(null);let r;if(t)try{let[e,n]=await Promise.all([Be(t),h.protection(t)]);r={gateway:e.digest,policy:n.policyWrite.digest}}catch{r=void 0}try{if(!e){let e=await n.install(t??`main`,{probeId:N.res.probeId,...r?{expected:r}:{},preview:!0});if(e.preview&&(e.loosens??[]).length>0){R(e.loosens);return}}let i=await n.install(t??`main`,{probeId:N.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});R(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;H({result:i,name:W?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?R(et(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(R(null),ue({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(R(null),ue({text:Ee(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:B(e)}))}finally{K.current=!1,L(!1)}};(0,Z.useEffect)(()=>{if(!z||z.settled)return;let e=Date.now(),t=z.result.gatewayId,r=!0,i=()=>n.live(t).then(t=>{if(!r)return;let{live:n,settled:i}=be(t,z.result.upstreamName,z.result.apply,Date.now()-e,e);H({...z,live:n,settled:i})}).catch(()=>r&&(z.result.apply===`needs-restart`||Date.now()-e>=15e3)&&H({...z,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[z?.result.upstreamName,z?.settled]);let Ue=()=>{$.saved=null,i?.()},q=()=>{let e=z?.result;$.saved=null,e&&r(e)};if(z)return(0,Q.jsx)(rn,{saved:z,heading:U,onFinish:q,onRewatch:()=>H({...z,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void ze(e,t,n),reopenError:Le});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:c?`Pick a server to add`:`Find the server you want`}),y&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:y}),_&&a||De?(0,Q.jsx)(o,{lines:5}):(0,Q.jsxs)(`div`,{className:`relative`,children:[_&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center rounded-[18px] bg-surface/70`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,Q.jsx)(ne,{}),` Opening…`]})}),(0,Q.jsx)(Rt,{compact:c,tab:u,onTab:d,onCatalog:e=>Te(e),onDraft:(e,t)=>we(e,null,t)})]}),i&&(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`ghost`,onClick:Ue,children:`Cancel`})})]});let J=p.draft,We=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>N?P(null):(g(null),O({kind:`picker`})),disabled:N?.kind===`running`||oe,children:N&&N.kind!==`error`?`Change its settings`:`Choose another server`}),Y=N?.kind===`done`&&!N.res.outcome.ok?N.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,Ke=J.source.kind===`catalog`&&J.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(J.launch.url)?p.entry?.name??J.displayName:void 0,qe={firstSignIn:G?!D:N?.kind===`done`&&!!N.res.signInAvailable,...Ke?{desktopApp:Ke.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:J.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||J.launch.transport===`stdio`};return Ce===`test`&&N?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,J.displayName]}),N.kind===`running`?(0,Q.jsx)(Gt,{transport:J.launch.transport}):N.kind===`done`&&N.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Jt,{outcome:N.res.outcome,name:J.displayName,watching:ve,keyUnchecked:J.fields.some(e=>e.kind===`secret`)&&!(J.source.kind===`catalog`&&en.has(J.source.id))}),N.res.egressHosts.length>0&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 text-[13px] text-soft`,children:[(0,Q.jsx)(m,{name:`shield`,size:16,className:`mt-0.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Saving lets the toolbox reach `,(0,Q.jsx)(`span`,{className:`mono`,children:N.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):N.kind===`done`?(0,Q.jsx)(ke,{problem:Y,onFix:Ie,context:qe,extra:(0,Q.jsxs)(Q.Fragment,{children:[N.res.signInAvailable&&!G&&N.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>Ie(`sign-in`),children:`Sign in instead`}),Ve(Y,qe).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:Fe,children:`Try again`})]})}):null,se&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:se.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:Fe,children:`Test it again`}):void 0,children:se.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[We,N.kind===`done`&&N.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void He(),loading:oe,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!de,title:`Save ${J.displayName}?`,confirmLabel:`Save and turn on`,consequences:de??[],busy:oe,error:se?.text??null,onCancel:()=>R(null),onConfirm:()=>void He(!0),children:`Adding this server lets your AI apps do more than before. Here is exactly what changes. Nothing is saved until you press Save and turn on.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,J.displayName]}),(0,Q.jsx)(Zt,{draft:J,entry:p.entry,values:x,onValues:e=>{S(e),M({})},problems:ee,tried:A,onVariant:e=>p.entry&&Te(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:k,doctor:te,doctorBusy:ie,onRecheck:je,focus:F}),N?.kind===`error`&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[13.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,strokeWidth:2}),` `,N.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[We,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:Fe,disabled:!!_,children:`Test it`})]})]})}function rn({saved:e,heading:t,onFinish:n,onRewatch:r,onReopen:a,reopenError:o}){let{result:c,live:l,settled:u,name:d}=e,f=g(),p=!u,[h,_]=(0,Z.useState)(null),v=l.kind===`problem`||l.kind===`needs-sign-in`;(0,Z.useEffect)(()=>{if(!v||h)return;let e=!0;return Be(c.gatewayId).then(t=>e&&t.broken===null&&_(t.config.upstreams.find(e=>e.name===c.upstreamName)??null)).catch(()=>void 0),()=>{e=!1}},[v,c.gatewayId,c.upstreamName]);let y,b=null,x=`check`;l.kind===`live`?(y=`Live — ${l.tools} ${l.tools===1?`tool`:`tools`} ready`,b=`${d} is on. Your AI app can use it now, no restart needed.`):c.apply===`not-running`?(y=`${d} is saved`,b=`It turns on when your AI app opens your toolbox. If you haven't connected an app yet, that's the next step.`):c.apply===`needs-restart`||l.kind===`needs-restart`?(y=`${d} is saved. Restart your AI app once`,b=(l.kind===`needs-restart`?l.why:void 0)??`The running toolbox couldn't take this change while running. Quit your AI app and open it again.`,x=`clock`):l.kind===`needs-sign-in`?(y=`Saved, but it needs you to sign in`,b=`Press Sign in again below. It turns on as soon as you're signed in.`,x=`warning`):l.kind===`problem`?(y=`Saved, but it isn't working yet`,x=`warning`):p?(y=`Turning on ${d}…`,x=`clock`):(y=`${d} is saved`,b=`It's still starting. You can see how it's doing on the Connections page.`,x=`clock`);let C=l.kind===`problem`?{name:c.upstreamName,state:`failed`,problem:l.problem,since:``,attempts:0,tool_count:0}:l.kind===`needs-sign-in`?{name:c.upstreamName,state:`needs-sign-in`,since:``,attempts:0,tool_count:0}:null,w=e=>{$.saved=null,ae(i(f,e,{server:c.gatewayId}))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-3 py-6 text-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:L(`grid h-12 w-12 place-items-center rounded-full`,x===`check`?`bg-ok-tint text-ok`:x===`warning`?`bg-warn-tint text-warn`:`bg-sunken text-muted`),children:(0,Q.jsx)(m,{name:x,size:22,strokeWidth:2})}),(0,Q.jsx)(`h2`,{ref:t,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:y}),(0,Q.jsx)(`div`,{className:`max-w-[46ch] text-[14px] text-muted`,children:p&&l.kind===`waiting`?(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:(0,Q.jsx)(S,{state:`connecting`,label:`Starting`})}):b})]}),C&&(0,Q.jsx)(Ke,{gatewayId:c.gatewayId,upstream:h??{name:c.upstreamName,transport:`stdio`,command:``},state:C,onEdit:e=>a(e,h,l.kind===`problem`?l.problem.detail?.path:void 0),onFixed:r,onAllowAddress:()=>w(`/protection`)}),o&&(0,Q.jsxs)(s,{tone:`danger`,role:`alert`,title:`The setup screen couldn't be opened again`,children:[o,` You can change this server on the Connections page instead.`]}),(c.summary.length>0||c.created)&&(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13.5px]`,children:[c.created&&(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` Your toolbox is ready. Connect your AI app to it next.`]}),c.summary.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` `,e]},e))]}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`primary`,icon:`check`,onClick:n,children:`Done`})})]})}var an={};function on({scope:t,projectDir:n}){let r=F(()=>H.clients(n),[n]),i=r.data?.clients.find(e=>e.scope===t)??null,[a,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(an[t]??null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=e=>{an[t]=e??void 0,_(e)};if(!i)return r.error?(0,Q.jsx)(s,{tone:`danger`,children:B(r.error)}):(0,Q.jsx)(o,{lines:3});if(!i.attachedTo)return null;let w=V(t),T=i.servers??[],D=e=>T.find(t=>t.source===`extension`&&t.extensionId===e),O=a??new Set(ve(T)),k=T.filter(e=>e.importable&&!(e.source===`extension`&&e.inToolbox)),A=k.filter(e=>O.has(Y(e))),j=(e,t)=>{let n=new Set(O);t?n.add(Y(e)):n.delete(Y(e)),c(n)},ee=e=>{u(!0),f(null),H.importServers({scope:t,names:A.filter(e=>e.source===`config`).map(e=>e.name),extensions:A.filter(e=>e.source===`extension`).map(e=>e.extensionId),...i.projectScoped&&r.data?.projectDir?{projectDir:r.data.projectDir}:{},acknowledged:e}).then(e=>{h(null),c(null),S(e),r.reload()}).catch(t=>{t.detail?.needs===`loosens`&&!e?h(et(t)):(h(null),f(B(t)))}).finally(()=>u(!1))},M=v&&(0,Q.jsxs)(s,{tone:`warn`,title:`Give these servers back to ${w}?`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>y(!1),disabled:l,children:`Keep them in the toolbox`}),(0,Q.jsx)(E,{size:`sm`,variant:`danger`,onClick:()=>{u(!0),f(null),H.undoImport(t,i.projectScoped?r.data?.projectDir:void 0).then(e=>{y(!1),S(null),x(e),r.reload()}).catch(e=>f(B(e))).finally(()=>u(!1))},loading:l,children:`Give them back`})]}),children:[`They are taken out of your toolbox and put back in `,w,`'s own settings, the way they were. Keys saved for them are removed if nothing else uses them.`]});if(g){let t=g.extensionsToSwitchOff.map(e=>({...e,enabled:D(e.id)?.enabled??e.enabled}));return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers brought in`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-2 rounded-[18px] bg-ok-tint p-5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[16px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:19,className:`text-ok`,strokeWidth:2.2}),Le(w,g.imported.length+g.takenOut.length)]}),t.some(e=>e.enabled)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:He(t.filter(e=>e.enabled).map(e=>e.name))}),g.imported.length+g.takenOut.length>0&&(0,Q.jsxs)(`ul`,{className:`space-y-1 text-[14px]`,children:[g.imported.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` `,`— as “`,e.upstream,`”, `,e.tools===1?`1 tool`:`${e.tools} tools`,e.keysLocked.length>0?`; ${e.keysLocked.join(`, `)} kept in your locked keys`:``]})]},`i-${e.name}`)),g.takenOut.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — your toolbox already had it; `,w,`'s own copy was taken out`]})]},`t-${e.name}`))]}),g.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:K(X(g.restartHint))})]}),g.failures.length>0&&(0,Q.jsxs)(s,{tone:`warn`,title:`${g.failures.length===1?`This one stayed`:`These stayed`} in ${w}`,children:[g.failures.length===1?`It`:`They`,` didn't connect when tested, so nothing about `,g.failures.length===1?`it`:`them`,` was changed.`,(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:g.failures.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,`:`]}),` `,K(X(e.message))]},e.name))})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Switch these off in Claude`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[14px] font-medium`,children:t.name}),t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})]}),t.enabled&&(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:J(t.name)})]},t.id))}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`refresh`,loading:r.loading,onClick:r.reload,children:`Check again`})})]}),g.otherApps.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[g.otherApps.join(` and `),` `,g.otherApps.length===1?`uses`:`use`,` this toolbox too, so `,g.otherApps.length===1?`it gets`:`they get`,` these servers as well.`]}),g.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(g.warning))}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),M,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo`}),(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>S(null),children:`Done`})]})]})}return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers ${w} runs itself`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Bring its servers into your toolbox`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13.5px] text-muted`,children:T.length>0?`${w} runs these servers itself, so your toolbox doesn't check what they do. Each one you choose is tested first; the ones that connect run through your toolbox instead and are taken out of ${w}'s own settings. A backup is kept, so you can undo it.`:`${w} has no servers of its own to bring in.`})]}),b&&(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:`Given back to ${w}`,children:[b.restored.length>0?`${b.restored.join(`, `)} ${b.restored.length===1?`is`:`are`} back in ${w}'s own settings. `:``,b.extensions.length>0?`Switch ${b.extensions.map(e=>e.name).join(` and `)} back on in Claude, under Settings, then Extensions, if you want Claude to run ${b.extensions.length===1?`it`:`them`} itself. `:``,K(X(b.restartHint))]}),T.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:Ye(w)}),T.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:T.map(e=>(0,Q.jsx)(`li`,{className:`rounded-[14px] border border-line p-3`,children:(0,Q.jsx)(sn,{server:e,app:w,checked:O.has(Y(e)),onChange:t=>j(e,t)})},Y(e)))}),t===`claude-desktop`&&(0,Q.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Connectors added on claude.ai live in your Claude account, not on this computer, so they can't be listed here.`}),(i.imported?.length??0)>0&&!b&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-muted`,children:[`Brought in earlier: `,i.imported.map(e=>e.name).join(`, `),`.`]}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),M,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0&&(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,disabled:A.length===0||l&&!p,loading:l&&!p,onClick:()=>ee(!1),children:l&&!p?`Testing each one…`:ue(A.length)}),i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo bringing them in`})]}),(0,Q.jsx)(C,{open:p!==null,onCancel:()=>h(null),onConfirm:()=>ee(!0),title:`Let your toolbox reach these servers?`,consequences:p??[],confirmLabel:`Bring them in`,cancelLabel:`Don't bring them in`,busy:l,children:`At least one of these servers runs on this computer or your local network, which your toolbox only reaches once its allowed addresses are widened.`})]})}function sn({server:t,app:n,checked:r,onChange:i}){let a=(0,Q.jsxs)(`span`,{className:`ml-2 inline-flex flex-wrap gap-1.5 align-middle`,children:[t.source===`extension`&&(0,Q.jsx)(e,{children:`Extension`}),t.inToolbox&&t.source===`config`&&(0,Q.jsx)(e,{tone:`warn`,children:`In both`}),t.inToolbox&&t.source===`extension`&&(t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})),!t.importable&&(0,Q.jsx)(e,{children:`Can't be brought in`})]}),o=t.importable?t.inToolbox&&t.source===`config`?`Your toolbox already has it (as “${t.inToolbox}”), and ${n} still runs its own copy. Tick it to take ${n}'s copy out.`:t.inToolbox?t.enabled?`Your toolbox already has it. ${J(t.name)}`:`Your toolbox has it, and it is switched off in Claude.`:[t.source===`extension`?`A Claude extension. It isn't changed here; you switch it off in Claude afterwards.`:null,t.keysLocked.length>0?`${t.keysLocked.join(`, `)} ${t.keysLocked.length===1?`goes`:`go`} into your locked keys.`:null,t.needsLocalHttp?`It runs on this computer or your local network, so you'll be asked to confirm.`:null,t.upstreamName&&t.upstreamName!==t.name?`In your toolbox it will be called “${t.upstreamName}”.`:null].filter(Boolean).join(` `):K(X(t.reason??`It can't be brought in.`));return!t.importable||t.inToolbox&&t.source===`extension`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px]`,children:[(0,Q.jsxs)(`span`,{className:t.importable?`font-medium`:`font-medium text-soft`,children:[t.name,a]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:o})]}):(0,Q.jsx)(re,{checked:r,onChange:i,label:(0,Q.jsxs)(`span`,{className:`font-medium`,children:[t.name,a]}),description:o||void 0})}function cn({client:e,projectDir:t}){let[n,r]=(0,Z.useState)(!1);if(!e.attachedTo)return null;let i=V(e.scope);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`plus`,onClick:()=>r(!0),children:`Bring in servers`}),(0,Q.jsx)(ie,{open:n,onClose:()=>r(!1),title:`Bring ${i}'s servers into your toolbox`,width:640,footer:(0,Q.jsx)(E,{onClick:()=>r(!1),children:`Close`}),children:(0,Q.jsx)(on,{scope:e.scope,...t?{projectDir:t}:{}})})]})}function ln({title:e,children:t}){return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:e}),t]})}function un({go:e,icon:t,variant:n,newTab:r,children:i}){return e.href===void 0?(0,Q.jsx)(E,{size:`sm`,variant:n,icon:t,onClick:e.onClick,children:i}):(0,Q.jsx)(x,{href:e.href,size:`sm`,variant:n,icon:t,external:r,children:i})}function dn(e){let t=(0,Z.useRef)(!1),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null);return{busy:n,error:i,run:n=>{t.current||(t.current=!0,r(n.id),a(null),H.undoApp(n.id).then(t=>e(t,n)).catch(e=>a({app:n.id,text:B(e)})).finally(()=>{t.current=!1,r(null)}))}}}function fn({app:e,undone:t,onAnother:n}){let r=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>r.current?.focus(),[]),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{ref:r,tabIndex:-1,className:`outline-none`,children:(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:Ct(e.label,t.disconnected),children:[xt(t),` `,t.note&&K(X(t.note)),` `,K(X(t.restartHint))]})}),(t.removed.length>0||t.keptInToolbox.length>0||t.guardRemoved)&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px] text-muted`,children:[t.removed.length>0&&(0,Q.jsx)(`p`,{children:pt(t.removed)}),t.keptInToolbox.length>0&&(0,Q.jsx)(`p`,{children:bt(t.keptInToolbox)}),t.guardRemoved&&(0,Q.jsx)(`p`,{children:`Claude Code's own actions are no longer recorded.`})]}),t.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(t.warning))}),n&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`arrow-left`,onClick:n,children:`Back to the apps`})})]})}function pn(e){let{result:t}=e;return t.status===`needs-server`?(0,Q.jsx)(mn,{...e,result:t}):(0,Q.jsx)(gn,{...e,result:t})}function mn({app:e,result:t,addServer:n,newTab:r,onAnother:i}){let a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>a.current?.focus(),[]);let o=t.left.length>0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`status`,children:[(0,Q.jsx)(`div`,{ref:a,tabIndex:-1,className:`outline-none`,children:(0,Q.jsx)(s,{tone:`info`,title:Ot(e.label,o),actions:(0,Q.jsx)(un,{go:n,icon:`plus`,variant:`primary`,newTab:r,children:`Add a server`}),children:_t(e.label,o)})}),o&&(0,Q.jsx)(ln,{title:`Why ${e.label}'s servers stay where they are`,children:(0,Q.jsx)(hn,{left:t.left})}),i&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`arrow-left`,onClick:i,children:`Back to the apps`})})]})}function hn({left:e}){return(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[14px]`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`minus`,size:16,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — `,K(X(e.why))]})]})]},e.name))})}function gn({app:t,result:n,toolsHref:r,protect:i,newTab:a,extensionOn:o,onCheckAgain:c,onUndone:l,onAnother:u}){let d=F(()=>h.protection(n.toolbox.id),[n.toolbox.id]),f=dn(e=>l(e)),[p,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(null);(0,Z.useEffect)(()=>_.current?.focus(),[]);let v=f.error?.text??null,y=n.left.some(e=>e.kind===`needs-ok`),b=n.extensionsToSwitchOff.map(e=>({...e,enabled:o?.(e.id)??e.enabled})),S=mt(d.data?.enforcement);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{ref:_,tabIndex:-1,role:`status`,className:`flex flex-col gap-1 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),ht(n,t.label)]}),(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`→ `,K(X(n.restartHint))]})]}),(0,Q.jsxs)(ln,{title:ct(n,t.label),children:[n.imported.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-wrap gap-1.5`,"aria-label":`Servers that moved`,children:n.imported.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-full bg-sunken px-2.5 py-0.5 text-[13px]`,children:[e.name,` `,(0,Q.jsxs)(`span`,{className:`text-soft`,children:[`· `,st(e.tools,`tool`)]})]},e.upstream))}),(0,Q.jsx)(x,{href:r,size:`sm`,iconRight:`arrow-right`,external:a,children:`See tools`})]}),n.takenOut.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:St(t.label,n.takenOut.map(e=>e.name))})]}),n.left.length>0&&(0,Q.jsxs)(ln,{title:lt(t.label),children:[(0,Q.jsx)(hn,{left:n.left}),y&&!p&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,icon:`eye`,onClick:()=>g(!0),children:`Review`})}),y&&p&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`Some servers need your OK before they can move`}),(0,Q.jsx)(on,{scope:t.scope})]})]}),n.allowedHosts.length>0&&(0,Q.jsxs)(ln,{title:`Web addresses your toolbox may now reach`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`The servers you moved live at these addresses, so your toolbox was allowed to connect to them.`}),(0,Q.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Web addresses your toolbox may now reach`,children:n.allowedHosts.map(e=>(0,Q.jsx)(`li`,{className:`mono rounded-full bg-sunken px-2.5 py-0.5 text-[12.5px]`,children:e},e))})]}),b.some(e=>e.enabled)&&(0,Q.jsxs)(ln,{title:Mt(b.filter(e=>e.enabled).length),children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:b.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[14px] font-medium`,children:[ot(t.name),t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})]}),t.enabled&&(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:J(t.name)})]},t.id))}),c&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:c,children:`Check again`})})]}),n.notRecorded.length>0&&(0,Q.jsx)(ln,{title:`Not recorded`,children:(0,Q.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-[13.5px] text-muted`,children:n.notRecorded.map(e=>(0,Q.jsx)(`li`,{children:K(e)},e))})}),(n.guard||S||n.otherApps.length>0)&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px] text-muted`,children:[n.guard&&(0,Q.jsx)(`p`,{children:`Claude Code's own actions (reading and editing files, running commands, opening web pages) are recorded too.`}),S&&(0,Q.jsx)(`p`,{children:S}),n.otherApps.length>0&&(0,Q.jsx)(`p`,{children:at(n.otherApps)})]}),n.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(n.warning))}),v&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:v}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Q.jsx)(un,{go:i,icon:`shield-check`,variant:`primary`,newTab:a,children:`Protect me`}),n.undoable&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:f.busy===t.id,onClick:()=>f.run(t),children:ft(t.label)}),u&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:u,children:`Connect another app`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(q,{children:n.configPath})]}),(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(q,{children:n.backupPath})]})]})]})}function _n(e,t){return t||(e.toolbox?.needsConfirm?e.toolbox:null)}function vn(e,t){let n=_n(e,t.asked);return{...e.id===`claude-code`?{guard:t.guard}:{},...n&&t.confirmed===n.id?{toolbox:n.id}:{}}}function yn(e,t,n){if(!e.installed||e.error||yt(e.connection))return!1;let r=_n(e,n);return!r||t===r.id}function bn(e){return e.kind===`result`&&e.result.status===`connected`?{app:e.app,result:e.result}:null}var xn={kept:null};function Sn(e){xn.kept=bn(e)}function Cn(){xn.kept=null}function wn({toolsHref:e,protect:t,addServer:n,newTab:r,keep:i,onConnected:a,onNeedsServer:c,onUndone:l}){let u=F(()=>H.apps(),[]),[d,p]=(0,Z.useState)(null),m=(0,Z.useRef)(!1),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)({}),[S,C]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(()=>i&&xn.kept?{kind:`result`,...xn.kept}:null),D=(e,t)=>{i&&Sn(t),T(e)},O=(0,Z.useRef)(null),k=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{w===null&&k.current&&(k.current=!1,O.current?.focus())},[w]);let A=(e,t)=>{D({kind:`undone`,app:t,undone:e},{kind:`undone`}),l?.(e,t),u.reload()},j=dn((e,t)=>A(e,u.data?.apps.find(e=>e.id===t.id)??{id:t.id,label:t.id})),ee=e=>{m.current||(m.current=!0,p(e.id),g(t=>({...t,[e.id]:``})),H.connectApp(e.id,vn(e,{guard:_,confirmed:y[e.id],asked:S[e.id]})).then(t=>{D({kind:`result`,app:e,result:t},{kind:`result`,app:e,result:t}),t.status===`connected`?a?.(t,e):c?.(e),u.reload()}).catch(t=>{let n=t instanceof f?t.detail:void 0;t instanceof f&&t.status===409&&n?.needs===`toolbox`&&(C(t=>({...t,[e.id]:n.toolbox})),b(t=>({...t,[e.id]:void 0})),u.reload()),g(n=>({...n,[e.id]:B(t)}))}).finally(()=>{m.current=!1,p(null)}))},M=()=>{k.current=!0,D(null,{kind:`back`})};if(w?.kind===`undone`)return(0,Q.jsx)(fn,{app:w.app,undone:w.undone,onAnother:M});if(w){let i=u.data?.apps.find(e=>e.id===w.app.id),a=w.result;return(0,Q.jsx)(pn,{app:w.app,result:a,toolsHref:a.status===`connected`?e(a.toolbox.id,w.app.id):``,protect:a.status===`connected`?t(a.toolbox.id):n,addServer:n,newTab:r,extensionOn:e=>i?.servers.find(t=>t.source===`extension`&&t.extensionId===e)?.enabled,onCheckAgain:u.reload,onUndone:e=>A(e,w.app),onAnother:M})}if(u.error&&!u.data)return(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:u.reload,children:`Check again`}),children:B(u.error)});if(!u.data)return(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,"aria-busy":`true`,"aria-label":`Looking for your AI apps`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))});let N=u.data.apps.filter(e=>e.installed),P=u.data.apps.filter(e=>!e.installed),I=d?u.data.apps.find(e=>e.id===d)?.label??null:null;return(0,Q.jsxs)(`div`,{ref:O,tabIndex:-1,className:`flex flex-col gap-4 outline-none`,children:[N.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:Et}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:Tt}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[U.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:u.loading,onClick:u.reload,children:`Check again`})]})]}):(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,"aria-label":`Your AI apps`,children:N.map(e=>(0,Q.jsx)(Tn,{app:e,busy:d,busyLabel:I,error:h[e.id]||(j.error?.app===e.id?j.error.text:null),guard:_,onGuard:v,confirmed:y[e.id],onConfirm:t=>b(n=>({...n,[e.id]:t})),asked:S[e.id],onConnect:()=>ee(e),undoing:j.busy===e.id,onUndo:()=>j.run(e)},e.id))}),P.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-muted`,children:[`Not on this computer`,`:`]}),` `,P.map(e=>e.label).join(` · `)]}),u.data.cloud.length>0&&(0,Q.jsxs)(`section`,{"aria-labelledby":`cloud-apps-h`,className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4`,children:[(0,Q.jsx)(`h3`,{id:`cloud-apps-h`,className:`text-[14px] font-semibold`,children:`Can't be connected from here`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[13px] text-muted`,children:u.data.cloud.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-ink`,children:[e.label,`:`]}),` `,e.note]},e.label))})]})]})}function Tn({app:t,busy:n,busyLabel:r,error:i,guard:a,onGuard:o,confirmed:s,onConfirm:c,asked:l,onConnect:u,undoing:d,onUndo:f}){let{moving:p,staying:h}=gt(t),g=_n(t,l),_=yt(t.connection),v=yn(t,s,l),y=!!n&&n!==t.id;return(0,Q.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-2.5 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold`,children:t.label}),t.connected&&(0,Q.jsx)(e,{tone:`ok`,children:`Connected`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:Dt(t)}),p.length>0&&(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`Moves: `,p.map(e=>e.name).join(`, `)]}),h.length>0&&(0,Q.jsxs)(`details`,{className:`text-[13px]`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-muted select-none`,children:[`Why `,h.length===1?`1 stays`:`${h.length} stay`]}),(0,Q.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:h.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Q.jsxs)(`span`,{className:`text-muted`,children:[`— `,vt(e)]})]},`${e.scope}:${e.source}:${e.name}`))})]}),t.running&&(0,Q.jsxs)(`p`,{className:`flex gap-2 text-[13px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,className:`mt-0.5 shrink-0`}),ut(t.label)]}),t.error&&(0,Q.jsx)(`p`,{className:`text-[13px] text-bad`,children:K(X(t.error))}),_&&(0,Q.jsx)(`p`,{className:`text-[13px] text-muted`,children:_}),t.id===`claude-code`&&!_&&(0,Q.jsx)(re,{checked:a,onChange:o,label:`Also record what Claude Code does by itself (reading and editing files, running commands)`,description:kt(g&&g.id!==t.toolbox?.id?{mode:null}:t.toolbox)}),g&&!_&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-2xl bg-sunken/60 p-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted`,children:wt(t.label,g)}),(0,Q.jsx)(re,{checked:s===g.id,onChange:e=>c(e?g.id:void 0),label:jt(g.label)})]}),i&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:i}),y&&r&&(0,Q.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:dt(r)}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:n===t.id,disabled:!v||y,onClick:u,children:At(t.label,t.connected)}),t.connected&&t.undoable&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:d,disabled:!!n,onClick:f,children:ft(t.label)})]})]})}var En=null;function Dn({client:e,projectDir:t,onClose:n,onDone:r}){let i=oe(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(En),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(En=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{En=null,n(),r()},_=Oe(e.scope),v=()=>{l(!0),d(null),H.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{En=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(B(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(ie,{open:!0,onClose:g,title:`Connection undone`,description:`Restart ${_} so it uses its own server list again.`,width:580,footer:(0,Q.jsx)(E,{variant:`primary`,onClick:g,children:`Close`}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsx)(`p`,{children:e.fileRestored===`bytes`?`Your toolbox was taken out of ${_}, and its settings file is back exactly as it was before.`:e.fileRestored===`removed`?`Your toolbox was taken out of ${_}. Its settings file didn't exist before, so it was removed again.`:`Your toolbox was taken out of ${_}.`}),f.restored.length>0?(0,Q.jsx)(On,{title:`Servers given back to ${_}`,items:f.restored}):(0,Q.jsxs)(`p`,{className:`text-soft`,children:[_,`'s own servers were never moved, so they keep working as before.`]}),e.copyLeft&&(0,Q.jsxs)(s,{tone:`warn`,title:`A copy of the old settings is kept`,children:[_,`'s settings file changed since it was connected, so a copy of it as it was is kept at `,(0,Q.jsx)(q,{children:e.copyLeft}),`. It holds the old values, including any keys that were written in it. Delete it once you no longer need it.`]}),e.keysKept&&e.keysKept.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Its keys stay in your locked keys (`,e.keysKept.join(`, `),`). Remove them under Settings & help, Locked keys, if nothing else uses them.`]}),f.importedNote&&(0,Q.jsx)(`p`,{className:`text-soft`,children:K(X(f.importedNote))}),e.stillUsedBy&&e.stillUsedBy.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Your toolbox was kept, because `,e.stillUsedBy.join(` and `),` still `,e.stillUsedBy.length===1?`uses`:`use`,` it.`]}),f.deleted.length>0&&(0,Q.jsx)(On,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(On,{title:`Files kept`,items:f.leftInPlace,paths:!0}),f.refusedToDelete.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Some files were not deleted`,children:(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:f.refusedToDelete.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(q,{children:e.path}),` `,K(X(e.why))]},e.path))})}),f.registryRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The toolbox was also removed from this console.`}),f.clientAllowRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The “Don't ask me twice” setting was removed from Claude Code.`}),f.clientAllowError&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(f.warning))})]})})}return(0,Q.jsx)(ie,{open:!0,onClose:n,tone:`danger`,dismissable:!c,title:`Undo the connection for ${e.label}?`,description:`${_} goes back to reaching its servers directly, without your toolbox checking each call.`,width:580,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{variant:`secondary`,onClick:n,disabled:c,children:`Keep it connected`}),(0,Q.jsx)(E,{variant:`danger`,onClick:v,loading:c,children:`Undo connection`})]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsxs)(`ul`,{className:`space-y-2 text-muted`,children:[(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`refresh`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`The app's original server list is put back from the backup made when it was connected.`]}),(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[`The file changed is `,(0,Q.jsx)(q,{children:e.path})]})]})]}),(0,Q.jsx)(re,{checked:a,onChange:o,label:`Also delete the toolbox's files`,description:`Its settings file and protection settings. Your rules and choices in them are lost. Leave this off to keep them for later. They are kept anyway while another app still uses the toolbox.`}),u&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:u})]})})}function On({title:e,items:t,empty:n,paths:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:e}),t.length===0?(0,Q.jsx)(`p`,{className:`text-soft`,children:n}):(0,Q.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.map(e=>(0,Q.jsx)(`li`,{children:r?(0,Q.jsx)(q,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var kn={done:null};function An({gatewayId:t,onDone:r,compact:i,scope:a}){let c=F(()=>H.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(kn.done&&(!a||kn.done.scope===a)?kn.done:null),g=e=>{kn.done=e,h(e)},[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{p&&b.current&&(b.current=!1,y.current?.focus())},[p]);let S=c.data?.clients??[],C=(a?S.filter(e=>e.scope===a):S).filter(e=>!i||e.installed!==!1||e.exists).sort((e,t)=>jn(e)-jn(t)),w=e=>{u(e.scope),f(null),n.attach({gatewayId:t,scope:e.scope,...e.projectScoped&&c.data?.projectDir?{projectDir:c.data.projectDir}:{}}).then(t=>{let n=V(e.scope);b.current=!0,g({...t,appLabel:n,scope:e.scope}),r({...t,appLabel:n,scope:e.scope}),c.reload()}).catch(t=>f({scope:e.scope,text:B(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null,t=e?.servers?$e(e.servers).length:0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{ref:y,tabIndex:-1,role:`status`,className:`flex flex-col gap-3 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),p.alreadyConnected?`${p.appLabel} was already connected`:`Restart ${p.appLabel} once`]}),(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:p.alreadyConnected?`Nothing needed changing.${t>0?` Its own servers still run directly; bring them in below.`:``}`:`${p.appLabel} reads its list of servers when it opens, so it needs one restart to find your toolbox. After that, servers you add show up by themselves.`}),p.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:K(X(p.restartHint))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(q,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(q,{children:p.backupPath})]})]}),e?.attachedTo&&(0,Q.jsx)(on,{scope:e.scope,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v({...e,canRevert:!0}),children:`Undo`}),!a&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:()=>g(null),children:`Connect another app`})]}),(0,Q.jsx)(Dn,{client:_,projectDir:c.data?.projectDir,onClose:()=>v(null),onDone:()=>{g(null),c.reload()}})]})}return c.error&&!c.data?(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:c.reload,children:`Check again`}),children:B(c.error)}):c.data?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!a&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app you talk to. One click adds your toolbox to it; nothing else in the app changes.`}),C.length===0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`No AI app was found on this computer.`}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`Install one of these, open it once, then come back here and press Check again.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[U.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:c.loading,onClick:c.reload,children:`Check again`})]})]}),(0,Q.jsx)(`ul`,{className:L(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=G(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:L(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] border-line p-4`,!n&&!r&&`bg-sunken/40`),children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:L(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:Ue(t,c.data?.projectDir)}),r?(0,Q.jsx)(e,{tone:`ok`,children:`Connected`}):!n&&(0,Q.jsx)(e,{children:t.error?`Can't be read`:`Not found`})]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:t.error?K(X(t.error)):r?W(t.servers,Pe(t)):n?it(t.servers?.length??t.serverCount):`This app isn't on this computer.`}),d?.scope===t.scope&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:d.text}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[n&&!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:l===t.scope,disabled:!!l&&l!==t.scope,onClick:()=>w(t),children:[`Connect `,V(t.scope)]}),r&&(0,Q.jsx)(cn,{client:t,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),t.canRevert&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v(t),children:`Undo connection`})]})]},t.scope)})}),(0,Q.jsx)(Dn,{client:_,projectDir:c.data.projectDir,onClose:()=>v(null),onDone:c.reload})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:2})},e))})}var jn=e=>e.error?3:e.alreadyAdopted?1:G(e)?0:4;export{cn as a,Lt as c,Nt as d,Ft as f,Cn as i,Pt as l,Dn as n,nn as o,wn as r,tn as s,An as t,It as u};
5
+ }`,className:`field resize-y font-mono text-[13px]`}),(0,Q.jsx)(`p`,{id:`add-paste-help`,className:`text-[12.5px] text-soft`,children:`Copy the part of the server's instructions page (often called its README) that shows how to add it: a block of settings, a one-line command, or just its web address. Nothing is saved yet, and any keys in it go into your locked keys, never into a settings file.`})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{variant:`primary`,icon:`search`,onClick:()=>{c(!0),f(null),n.paste(i).then(u).catch(e=>f(B(e))).finally(()=>c(!1))},loading:o,disabled:!i.trim(),children:`Read it`})}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),l&&(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-3`,children:[l.servers.length===0?(0,Q.jsx)(s,{tone:`warn`,title:`No server could be added from that`,children:l.warnings.length>0&&!/didn't look like setup instructions/.test(l.warnings.join(` `))?(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))}):(0,Q.jsxs)(Q.Fragment,{children:[`We couldn't find a server in that. Paste the line that starts with `,(0,Q.jsx)(`code`,{className:`mono`,children:`npx`}),`, `,(0,Q.jsx)(`code`,{className:`mono`,children:`uvx`}),` or`,` `,(0,Q.jsx)(`code`,{className:`mono`,children:`docker`}),`, the block that contains `,(0,Q.jsx)(`code`,{className:`mono`,children:`mcpServers`}),`, or the server's web address. You can also add it by hand under`,` `,(0,Q.jsx)(`button`,{type:`button`,className:`font-semibold underline`,onClick:t,children:`Advanced`}),`.`]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`Found `,r(l.servers.length,`server`),l.recognisedAs&&(0,Q.jsxs)(`span`,{className:`font-normal text-soft`,children:[` · read as `,l.recognisedAs]})]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.servers.map((t,n)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>e(t.draft,t.values),className:`flex w-full items-center gap-3 rounded-[18px] border-[1.5px] border-line p-4 text-left hover:border-[var(--soft)] hover:bg-faint/50`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-sunken text-muted`,children:(0,Q.jsx)(m,{name:t.draft.launch.transport===`http`?`external`:`server`,size:18})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:t.draft.displayName}),(0,Q.jsx)(`span`,{className:`block truncate text-[12.5px] text-soft`,children:t.draft.launch.transport===`http`?`Remote server · ${t.draft.launch.url}`:`Runs on this computer · ${[t.draft.launch.command,...t.draft.launch.args??[]].join(` `)}`}),t.draft.warnings.map(e=>(0,Q.jsx)(`span`,{className:`mt-1 block text-[12.5px] text-warn`,children:e},e))]}),(0,Q.jsx)(m,{name:`chevron-right`,size:18,className:`shrink-0 text-soft`})]})},`${t.draft.name}-${n}`))})]}),l.servers.length>0&&l.warnings.length>0&&(0,Q.jsx)(s,{tone:`info`,title:`Note`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:l.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})})]})]})}function Kt({onDraft:e}){let[t,n]=(0,Z.useState)(Ft()),[r,i]=(0,Z.useState)(!1),a=Rt(t);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`For a server you know how to start. Values whose names look like keys (TOKEN, KEY, SECRET, PASSWORD) go into your locked keys rather than the toolbox's settings file.`}),(0,Q.jsx)(zt,{value:t,onChange:n}),r&&a&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:a}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(E,{variant:`primary`,iconRight:`arrow-right`,onClick:()=>{if(i(!0),a)return;let n=we(Lt(t));e(n.draft,n.values)},children:`Continue`})})]})}function qt({transport:e}){let[t,n]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,Q.jsx)(`span`,{className:`grid h-14 w-14 place-items-center rounded-full bg-ok-tint text-ok`,children:(0,Q.jsx)(ne,{size:26})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-medium`,children:he(t,e)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-[13.5px] text-soft`,children:[`Nothing is saved yet. `,t>2&&(0,Q.jsxs)(`span`,{className:`tnum`,children:[`(`,t,` s)`]})]})]})]})}var Jt=[`run`,`ask`,`blocked`],Yt={run:`Your AI can use these without asking.`,ask:`Once protection is on, each use waits until you say yes.`,blocked:`Once protection is on, your AI can't use these.`};function Xt({outcome:e,name:t,watching:n,keyUnchecked:r}){let i=xe(e),a=Ie(e),o=Jt.filter(e=>i[e].length>0);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 rounded-[18px] bg-ok-tint p-4`,children:[(0,Q.jsx)(`span`,{className:`grid h-10 w-10 shrink-0 place-items-center rounded-full bg-surface text-ok`,children:(0,Q.jsx)(m,{name:`check`,size:20,strokeWidth:2.2})}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-semibold`,children:r?`${t} started`:`${t} works`}),(0,Q.jsxs)(`span`,{className:`block text-[13.5px] text-muted`,children:[je(e),r&&` Your key is checked the first time your AI uses it.`]})]})]}),i.offered>0&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(tt,{sub:n?`What happens when your AI uses each tool once protection is on. Right now your toolbox only watches, so everything runs and is written down. You can change any of this later on the Tools page.`:n===!1?`What happens when your AI uses each tool. Protection is on. You can change any of this later on the Tools page.`:`What happens when your AI uses each tool once protection is on. You can change any of this later on the Tools page.`,children:`What your AI can do`}),(0,Q.jsx)(`div`,{className:L(`grid gap-3`,o.length===2?`md:grid-cols-2`:o.length>=3?`lg:grid-cols-3 md:grid-cols-2`:``),children:o.map(e=>(0,Q.jsx)(Zt,{verdict:e,tools:i[e],wide:o.length===1},e))})]}),(a.lines.length>0||a.quiet)&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(tt,{children:a.lines.length>0?`Please check`:`Note`}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 text-[13.5px]`,children:[a.lines.map((e,t)=>(0,Q.jsxs)(`li`,{className:L(`flex gap-2 rounded-2xl p-3`,e.tone===`warn`?`bg-warn-tint`:`border border-line`),children:[(0,Q.jsx)(m,{name:e.text.startsWith(`Won't be offered`)?`eye-off`:`warning`,size:17,className:L(`mt-0.5 shrink-0`,e.tone===`warn`?`text-warn`:`text-soft`)}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[e.tool&&(0,Q.jsx)(`code`,{className:`mono mr-1 font-semibold`,children:e.tool}),e.text,e.technical&&(0,Q.jsxs)(`details`,{className:`mt-1`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-[12.5px] text-soft select-none`,children:`Details`}),(0,Q.jsx)(`p`,{className:`mono mt-1 text-[12px] break-words text-soft`,children:e.technical})]})]})]},t)),a.quiet&&(0,Q.jsx)(`li`,{className:`rounded-2xl border border-line p-3 text-muted`,children:(0,Q.jsxs)(`details`,{children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer select-none`,children:[a.quiet.text,` `,(0,Q.jsx)(`span`,{className:`text-soft underline`,children:`Details`})]}),(0,Q.jsx)(`ul`,{className:`mt-2 flex max-h-64 flex-col gap-1 overflow-auto text-[12px] text-soft`,children:a.quiet.details.map((e,t)=>(0,Q.jsxs)(`li`,{className:`mono break-words`,children:[e.tool&&(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e.tool,`: `]}),e.text]},t))})]})})]})]})]})}function Zt({verdict:e,tools:t,wide:n}){let[r,i]=(0,Z.useState)(t.length<=8),a=r?t:t.slice(0,8),o=Ce[e];return(0,Q.jsxs)(`div`,{className:`rounded-[18px] border border-line p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(T,{decision:o}),(0,Q.jsx)(`span`,{className:`tnum text-[13px] text-soft`,children:t.length})]}),(0,Q.jsx)(`p`,{className:`mt-1.5 mb-2 text-[12.5px] text-soft`,children:Yt[e]}),(0,Q.jsx)(`ul`,{className:L(`grid`,n&&`sm:grid-cols-2 sm:gap-x-6`),"aria-label":te[o].label,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 border-b border-faint py-1.5 last:border-b-0`,children:[(0,Q.jsx)(b,{effect:e.effect}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`block text-[13px] [overflow-wrap:anywhere]`,title:e.description?`${e.name}: ${e.description}`:e.name,children:e.title??Qe(e.name).label})}),(0,Q.jsx)(`span`,{className:`sr-only`,children:P[e.effect]?.label}),e.packRule&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11.5px] text-muted`,title:`Decided by a ready-made rule for this server`,children:`Ready-made rule`})]},e.name))}),!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`ghost`,className:`mt-1`,onClick:()=>i(!0),children:[`Show all `,t.length]}),(0,Q.jsxs)(`details`,{className:`mt-2 text-[12px] text-soft`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Q.jsxs)(`p`,{className:`mt-1`,children:[`The server's own names:`,` `,t.map((e,t)=>(0,Q.jsxs)(`span`,{children:[t>0&&`, `,(0,Q.jsx)(`code`,{className:`mono break-normal`,children:ee(e.name)})]},e.name))]})]})]})}var Qt=e=>`add-field-${e.replace(/[^\w-]/g,`_`)}`;function $t({draft:t,entry:n,values:r,onValues:i,problems:a,tried:o,onVariant:c,name:l,onName:u,signedIn:f,onSignedIn:p,doctor:h,doctorBusy:g,onRecheck:_,focus:v}){let[y,b]=(0,Z.useState)({}),x=(e,t)=>i({...r,[e]:t}),S=t.source.kind===`catalog`?t.source.variant:null,C=n?.variants??[],w=R(t.requires,h),T=Ne(t),E=t.launch.transport===`http`?We(t.launch.url,r):``,D=Me(t,r);(0,Z.useEffect)(()=>{if(!v||v.kind!==`field`||!v.field)return;let e=document.getElementById(Qt(v.field));e?.focus(),e?.scrollIntoView({block:`center`,behavior:`smooth`})},[v?.nonce]);let O=e=>a[e.id]??(o||y[e.id]?ye(e,r[e.id]):null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-[20px] font-medium tracking-[-0.02em]`,children:t.displayName}),n?.publisher.official&&(0,Q.jsx)(e,{tone:`ok`,icon:`shield-check`,children:`Official`}),t.source.kind===`registry`&&(0,Q.jsx)(e,{tone:`warn`,icon:`warning`,children:`From the public list — not checked by us`}),t.source.kind===`paste`&&(0,Q.jsx)(e,{children:`From what you pasted`}),t.requires.map(t=>(0,Q.jsxs)(e,{children:[`Needs `,Ae[t]??t]},t))]}),(n?.description??n?.summary)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:(0,Q.jsx)(N,{text:n?.description??n?.summary??``})})]}),t.warnings.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Before you go on`,children:(0,Q.jsx)(`ul`,{className:`mt-1 list-disc space-y-1 pl-5`,children:t.warnings.map(e=>(0,Q.jsx)(`li`,{children:e},e))})}),D&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl bg-warn-tint px-4 py-3`,children:[(0,Q.jsx)(d,{checked:r.__local_ok===!0,onChange:e=>x(`__local_ok`,e),label:`This is on my own computer or network`,description:D===`loopback`?`This server's address is on this computer. Testing it lets the toolbox reach that address, just for the test. Only tick this if you started that program yourself.`:`This server's address is on your own network (a router or another computer). Testing it lets the toolbox reach that address, just for the test. Only tick this if you know what is there.`}),a.__local_ok&&r.__local_ok!==!0&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),`Tick this first, or choose another server.`]})]}),(0,Q.jsx)(nt,{missing:w,platform:h?.platform,onRecheck:_,checking:g}),C.length>1&&S&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[13.5px] font-semibold`,children:`How to run it`}),(0,Q.jsx)(Fe,{label:`How to run it`,value:S,onChange:c,options:C.map(e=>({value:e.id,title:e.label,body:(0,Q.jsxs)(Q.Fragment,{children:[e.summary??(e.launch.transport===`http`?`Runs on the service's own computers. Nothing to install.`:`Runs on this computer.`),(e.requires??[]).length>0&&(0,Q.jsxs)(`span`,{className:`mt-1 block`,children:[`Needs `,(e.requires??[]).map(e=>Ae[e]).join(` and `),`.`]})]})}))})]}),(0,Q.jsxs)(`div`,{className:L(`grid gap-6`,t.guide.length>0&&`md:grid-cols-2`),children:[t.guide.length>0&&(0,Q.jsx)(j,{steps:t.guide,className:`md:self-start`}),(0,Q.jsxs)(`section`,{"aria-label":`Settings for this server`,className:`flex min-w-0 flex-col gap-5`,children:[T&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] font-semibold`,children:`Sign in`}),(0,Q.jsx)(ze,{serverUrl:E,secretName:le(l||t.name),name:t.displayName,signedIn:f,onSignedIn:p,startNonce:v?.kind===`sign-in`?v.nonce:void 0})]}),t.fields.map(e=>(0,Q.jsx)(en,{field:e,value:r[e.id],storedAs:typeof r[`__saved.${e.id}`]==`string`?r[`__saved.${e.id}`]:void 0,onChange:t=>x(e.id,t),onBlur:()=>b(t=>({...t,[e.id]:!0})),error:O(e),openFolder:v?.kind===`folder`&&(!v.field||v.field===e.id)?v.nonce:void 0},e.id)),t.fields.length===0&&!T&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 rounded-2xl bg-sunken/60 px-4 py-3 text-[13.5px] text-muted`,children:[(0,Q.jsx)(m,{name:`check`,size:17,className:`text-ok`}),` Nothing to fill in. Test it to see what it can do.`]}),(0,Q.jsxs)(Te,{title:`More options`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`add-server-name`,className:`text-[13px] font-semibold`,children:`Name in your toolbox`}),(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:`name`})]}),(0,Q.jsx)(`input`,{id:`add-server-name`,className:`field font-mono text-[13px]`,value:l,onChange:e=>u(e.target.value),"aria-describedby":`add-server-name-help`,"aria-invalid":!!ge(l)||void 0}),(0,Q.jsx)(`p`,{id:`add-server-name-help`,className:L(`text-[12.5px]`,ge(l)?`font-medium text-bad`:`text-soft`),children:ge(l)??`Your AI app sees its tools as ${l||`name`}__tool.`})]}),(0,Q.jsx)(tn,{draft:t})]})]})]}),w.length===0&&t.requires.length>0&&h&&(0,Q.jsx)(`p`,{className:`sr-only`,role:`status`,children:`This computer has everything this server needs.`})]})}function en({field:e,value:t,onChange:n,onBlur:r,error:i,openFolder:a,storedAs:o}){let s=Qt(e.id),c=`${s}-help`,l=`${s}-err`,u=[e.help&&!i?c:null,i?l:null].filter(Boolean).join(` `)||void 0;if(e.kind===`toggle`)return(0,Q.jsx)(d,{checked:t===!0,onChange:n,label:e.label,description:e.help});let f=typeof t==`string`?t:``,p=Array.isArray(t)?t:typeof t==`string`&&t?[t]:[],h=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsxs)(`label`,{htmlFor:s,className:`text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&e.kind!==`choice`&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:`optional`})]}),e.technical&&(0,Q.jsx)(`code`,{className:`mono text-[11.5px] text-muted`,"aria-hidden":!0,children:e.technical})]}),g;return g=e.kind===`secret`?(0,Q.jsx)(D,{id:s,value:f,onChange:n,storedAs:o,placeholder:e.placeholder,"aria-describedby":u,invalid:!!i}):e.kind===`folder`||e.kind===`folders`?(0,Q.jsx)(I,{id:s,value:p,multiple:e.kind===`folders`,onChange:t=>{n(e.kind===`folders`?t:t[0]??``),r()},openNonce:a,"aria-describedby":u}):e.kind===`choice`?(0,Q.jsxs)(`span`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`select`,{id:s,value:f,onChange:e=>n(e.target.value),onBlur:r,"aria-describedby":u,"aria-invalid":!!i||void 0,className:`field appearance-none pr-9`,children:(e.choices??[]).map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,Q.jsx)(m,{name:`chevron`,size:16,className:`pointer-events-none absolute right-3 text-soft`})]}):(0,Q.jsx)(`input`,{id:s,type:e.kind===`url`?`url`:`text`,value:f,onChange:e=>n(e.target.value),onBlur:r,placeholder:e.placeholder??(e.kind===`url`?`https://`:void 0),spellCheck:!1,"aria-describedby":u,"aria-invalid":!!i||void 0,className:L(`field`,e.kind===`url`&&`font-mono text-[13px]`)}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.kind===`folder`||e.kind===`folders`?(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 text-[13px] font-semibold text-ink`,children:[e.label,!e.required&&!/\boptional\b/i.test(e.label)&&(0,Q.jsx)(`span`,{className:`font-normal text-soft`,children:`optional`})]}):h,g,e.help&&!i&&(0,Q.jsx)(`p`,{id:c,className:`text-[12.5px] text-soft`,children:(0,Q.jsx)(N,{text:e.help})}),i&&(0,Q.jsxs)(`p`,{id:l,role:`alert`,className:`flex items-center gap-1.5 text-[12.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:14,strokeWidth:2}),i]})]})}function tn({draft:e}){let t=e.launch,n=e=>typeof e==`string`?e:`${e.prefix??``}<locked key: ${e.field}>`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px]`,children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:`What it runs`}),t.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:[t.command,...t.args??[]].join(` `)}),Object.entries(t.env??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`=`,n(t)]},e))]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{className:`mono rounded-xl bg-sunken px-3 py-2 break-all`,children:t.url}),Object.entries(t.headers??{}).map(([e,t])=>(0,Q.jsxs)(`code`,{className:`mono text-soft break-all`,children:[e,`: `,n(t)]},e))]})]})}var $={saved:null},nn=new Set([`brave-search`]);function rn(){$.saved=null}function an(e){let{gatewayId:t,onDone:r,onCancel:i,initialCatalogId:a,compact:c,fixUpstream:l}=e,[u,d]=(0,Z.useState)(`popular`),[p,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(a??null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(``),[D,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[ee,M]=(0,Z.useState)({}),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(null),[te,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(!1),[oe,L]=(0,Z.useState)(!1),[se,ue]=(0,Z.useState)(null),[de,R]=(0,Z.useState)(null),[z,he]=(0,Z.useState)($.saved),[ve,ye]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!t){ye(!0);return}let e=!0;return h.protection(t).then(t=>e&&ye(t.enforcement!==`enforce`)).catch(()=>e&&ye(null)),()=>{e=!1}},[t]);let[V,xe]=(0,Z.useState)(null),H=e=>{$.saved=e,he(e)},U=(0,Z.useRef)(null),Ce=z?`done`:N&&N.kind!==`error`?`test`:p?`setup`:`choose`;(0,Z.useEffect)(()=>{U.current?.focus()},[Ce]);let we=(e,t,n={})=>{g({draft:e,entry:t}),xe(null);let r=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith(pe)));S({...Se(e,n),...r}),T(e.name),k(!1),j(!1),M({}),P(null),ue(null),e.requires.length&&!te&&je()},Te=(e,t,r)=>{v(e.id),b(null),n.catalogDraft(e.id,t).then(t=>we(t.draft,e,r)).catch(e=>b(B(e))).finally(()=>v(null))},[De,Oe]=(0,Z.useState)(!1),Ae=async(e,t,r)=>{Oe(!0),b(null);try{let i=(await n.catalog()).entries,a=Ge(e,i),o,s,c=null;a?(o=(await n.catalogDraft(a.entry.id,a.variant)).draft,s=Xe(o,e,r),c=a.entry):{draft:o,values:s}=ce(e,r),we(o,c,s),xe(e.name),T(e.name);let l=Date.now(),u=e=>o.fields.find(t=>e.includes(t.kind))?.id;if(t===`choose-folder`)I({kind:`folder`,field:u([`folder`,`folders`]),nonce:l});else if(t===`replace-key`){let e=u([`secret`]);e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${pe}${e}`))),I(e?{kind:`field`,field:e,nonce:l}:null)}else t===`sign-in`&&I({kind:`sign-in`,nonce:l})}catch(e){b(B(e))}finally{Oe(!1)}};(0,Z.useEffect)(()=>{l&&!$.saved&&Ae(l.upstream,l.action,l.path)},[l?.upstream.name,l?.action]),(0,Z.useEffect)(()=>{a&&!$.saved&&n.catalog().then(e=>{let t=e.entries.find(e=>e.id===a);t?Te(t):v(null)}).catch(e=>{b(B(e)),v(null)})},[a]);let je=()=>{ae(!0),n.doctor().then(re).catch(()=>void 0).finally(()=>ae(!1))},W=p?.draft??null,G=W?Ne(W):!1,Pe=le(w||W?.name||`server`),Fe=()=>{if(!W)return;j(!0),ue(null);let e=me(W,x);if(Object.keys(e).length||ge(w)){let t=W.fields.find(t=>e[t.id]);t&&I({kind:`field`,field:t.id,nonce:Date.now()}),P({kind:`error`,text:ge(w)?`The name under More options needs fixing.`:`Some settings need fixing first. They are marked above.`})}else G&&!D?P({kind:`error`,text:`Sign in with ${W.displayName} first.`}):Me(W,x)&&x.__local_ok!==!0?P({kind:`error`,text:`This server's address is on your own computer or network. Tick “This is on my own computer or network” first, or choose another server.`}):(P({kind:`running`}),M({}),n.testServer({...t?{gatewayId:t}:{},draft:W,values:G?{...x,[fe]:Pe}:x,...w.trim()===W.name?{}:{name:w.trim()},...V?{replacing:V}:{}}).then(e=>{if(Object.keys(e.problems).length){M(e.problems);let t=W.fields.find(t=>e.problems[t.id]);t&&I({kind:`field`,field:t.id,nonce:Date.now()}),P({kind:`error`,text:`Some settings need fixing first. They are marked above.`})}else P({kind:`done`,res:e})}).catch(e=>P({kind:`error`,text:B(e)})))},Ie=e=>{if(!W)return;let t=Date.now(),n=e=>W.fields.find(t=>e.includes(t.kind))?.id;switch(e){case`retry`:case`allow-address`:return Fe();case`install-runtime`:case`start-runtime`:return je();case`show-details`:return;case`choose-folder`:{P(null);let e=n([`folder`,`folders`]);if(!e&&W.launch.transport===`stdio`&&p){let e=N?.kind===`done`?N.res.outcome.problem?.detail?.path:void 0,n=ce({name:w||W.name,transport:`stdio`,command:W.launch.command,args:W.launch.args??[]},e);if(n.draft.fields.some(e=>e.kind===`folders`)){let e={...W,launch:{...W.launch,args:n.draft.launch.args??[]},fields:[...W.fields,...n.draft.fields]};return g({...p,draft:e}),S(e=>({...e,folders:n.values.folders??[]})),I({kind:`folder`,field:`folders`,nonce:t})}return I(null)}return I({kind:`folder`,field:e,nonce:t})}case`replace-key`:{P(null);let e=n([`secret`]);return e&&S(t=>Object.fromEntries(Object.entries({...t,[e]:``}).filter(([t])=>t!==`${pe}${e}`))),I(e?{kind:`field`,field:e,nonce:t}:null)}case`sign-in`:return!Ne(W)&&p&&g({...p,draft:_e(W)}),P(null),k(!1),I({kind:`sign-in`,nonce:t});case`check-address`:{P(null);let e=n([`url`,`text`]);return I(e?{kind:`field`,field:e,nonce:t}:null)}}},[Le,Re]=(0,Z.useState)(null),ze=async(e,t,n)=>{if(!z)return;Re(null);let{upstreamName:r}=z.result;if(p){H(null),xe(r),T(r),Ie(e);return}let i=t;if(!i)try{i=(await Be(z.result.gatewayId)).config?.upstreams.find(e=>e.name===r)??null}catch(e){Re(B(e));return}i?(H(null),await Ae(i,e,n)):Re(`The server "${r}" isn't in your toolbox any more.`)},K=(0,Z.useRef)(!1),He=async e=>{if(N?.kind!==`done`||K.current)return;K.current=!0,L(!0),ue(null);let r;if(t)try{let[e,n]=await Promise.all([Be(t),h.protection(t)]);r={gateway:e.digest,policy:n.policyWrite.digest}}catch{r=void 0}try{if(!e){let e=await n.install(t??`main`,{probeId:N.res.probeId,...r?{expected:r}:{},preview:!0});if(e.preview&&(e.loosens??[]).length>0){R(e.loosens);return}}let i=await n.install(t??`main`,{probeId:N.res.probeId,...r?{expected:r}:{},...e?{acknowledged:{loosens:!0}}:{}});R(null);let a=i.apply===`live`||i.apply===`pending`||i.apply===`needs-restart`;H({result:i,name:W?.displayName??i.upstreamName,live:{kind:`waiting`},settled:!a})}catch(e){e instanceof f&&e.needsLoosenAck?R(et(e)):e instanceof f&&(e.status===410||/probe/i.test(e.code))?(R(null),ue({text:`The test result is too old to save. Test it again, then save.`,retest:!0})):(R(null),ue({text:Ee(e)?`The toolbox's settings changed while you were here. Save again to use the latest.`:B(e)}))}finally{K.current=!1,L(!1)}};(0,Z.useEffect)(()=>{if(!z||z.settled)return;let e=Date.now(),t=z.result.gatewayId,r=!0,i=()=>n.live(t).then(t=>{if(!r)return;let{live:n,settled:i}=be(t,z.result.upstreamName,z.result.apply,Date.now()-e,e);H({...z,live:n,settled:i})}).catch(()=>r&&(z.result.apply===`needs-restart`||Date.now()-e>=15e3)&&H({...z,settled:!0})),a=setInterval(i,1e3);return i(),()=>{r=!1,clearInterval(a)}},[z?.result.upstreamName,z?.settled]);let Ue=()=>{$.saved=null,i?.()},q=()=>{let e=z?.result;$.saved=null,e&&r(e)};if(z)return(0,Q.jsx)(on,{saved:z,heading:U,onFinish:q,onRewatch:()=>H({...z,live:{kind:`waiting`},settled:!1}),onReopen:(e,t,n)=>void ze(e,t,n),reopenError:Le});if(!p)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:c?`Pick a server to add`:`Find the server you want`}),y&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:y}),_&&a||De?(0,Q.jsx)(o,{lines:5}):(0,Q.jsxs)(`div`,{className:`relative`,children:[_&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center rounded-[18px] bg-surface/70`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,Q.jsx)(ne,{}),` Opening…`]})}),(0,Q.jsx)(Bt,{compact:c,tab:u,onTab:d,onCatalog:e=>Te(e),onDraft:(e,t)=>we(e,null,t)})]}),i&&(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`ghost`,onClick:Ue,children:`Cancel`})})]});let J=p.draft,We=(0,Q.jsx)(E,{variant:`ghost`,icon:`arrow-left`,onClick:()=>N?P(null):(g(null),O({kind:`picker`})),disabled:N?.kind===`running`||oe,children:N&&N.kind!==`error`?`Change its settings`:`Choose another server`}),Y=N?.kind===`done`&&!N.res.outcome.ok?N.res.outcome.problem??{code:`unknown`,message:`It did not start, and gave no reason.`}:null,Ke=J.source.kind===`catalog`&&J.launch.transport===`http`&&/^https?:\/\/(127\.|localhost|\[::1\])/i.test(J.launch.url)?p.entry?.name??J.displayName:void 0,qe={firstSignIn:G?!D:N?.kind===`done`&&!!N.res.signInAvailable,...Ke?{desktopApp:Ke.replace(/\s*\(desktop app\)\s*$/i,``)}:{},hasFolderField:J.fields.some(e=>e.kind===`folder`||e.kind===`folders`)||J.launch.transport===`stdio`};return Ce===`test`&&N?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:[`Test `,J.displayName]}),N.kind===`running`?(0,Q.jsx)(qt,{transport:J.launch.transport}):N.kind===`done`&&N.res.outcome.ok?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xt,{outcome:N.res.outcome,name:J.displayName,watching:ve,keyUnchecked:J.fields.some(e=>e.kind===`secret`)&&!(J.source.kind===`catalog`&&nn.has(J.source.id))}),N.res.egressHosts.length>0&&(0,Q.jsxs)(`p`,{className:`flex items-start gap-2 text-[13px] text-soft`,children:[(0,Q.jsx)(m,{name:`shield`,size:16,className:`mt-0.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Saving lets the toolbox reach `,(0,Q.jsx)(`span`,{className:`mono`,children:N.res.egressHosts.join(`, `)}),`. You'll be asked to confirm.`]})]})]}):N.kind===`done`?(0,Q.jsx)(ke,{problem:Y,onFix:Ie,context:qe,extra:(0,Q.jsxs)(Q.Fragment,{children:[N.res.signInAvailable&&!G&&N.res.outcome.problem?.code!==`needs-sign-in`&&(0,Q.jsx)(E,{size:`sm`,icon:`key`,onClick:()=>Ie(`sign-in`),children:`Sign in instead`}),Ve(Y,qe).fix?.action!==`retry`&&(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:Fe,children:`Try again`})]})}):null,se&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,title:`It wasn't saved`,actions:se.retest?(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:Fe,children:`Test it again`}):void 0,children:se.text}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[We,N.kind===`done`&&N.res.outcome.ok&&(0,Q.jsx)(E,{variant:`primary`,icon:`power`,onClick:()=>void He(),loading:oe,children:`Save and turn on`})]}),(0,Q.jsx)(C,{open:!!de,title:`Save ${J.displayName}?`,confirmLabel:`Save and turn on`,consequences:de??[],busy:oe,error:se?.text??null,onCancel:()=>R(null),onConfirm:()=>void He(!0),children:`Adding this server lets your AI apps do more than before. Here is exactly what changes. Nothing is saved until you press Save and turn on.`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`h2`,{ref:U,tabIndex:-1,className:`sr-only outline-none`,children:[`Set up `,J.displayName]}),(0,Q.jsx)($t,{draft:J,entry:p.entry,values:x,onValues:e=>{S(e),M({})},problems:ee,tried:A,onVariant:e=>p.entry&&Te(p.entry,e,x),name:w,onName:T,signedIn:D,onSignedIn:k,doctor:te,doctorBusy:ie,onRecheck:je,focus:F}),N?.kind===`error`&&(0,Q.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-1.5 text-[13.5px] font-medium text-bad`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,strokeWidth:2}),` `,N.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-faint pt-5`,children:[We,(0,Q.jsx)(E,{variant:`primary`,icon:`play`,onClick:Fe,disabled:!!_,children:`Test it`})]})]})}function on({saved:e,heading:t,onFinish:n,onRewatch:r,onReopen:a,reopenError:o}){let{result:c,live:l,settled:u,name:d}=e,f=g(),p=!u,[h,_]=(0,Z.useState)(null),v=l.kind===`problem`||l.kind===`needs-sign-in`;(0,Z.useEffect)(()=>{if(!v||h)return;let e=!0;return Be(c.gatewayId).then(t=>e&&t.broken===null&&_(t.config.upstreams.find(e=>e.name===c.upstreamName)??null)).catch(()=>void 0),()=>{e=!1}},[v,c.gatewayId,c.upstreamName]);let y,b=null,x=`check`;l.kind===`live`?(y=`Live — ${l.tools} ${l.tools===1?`tool`:`tools`} ready`,b=`${d} is on. Your AI app can use it now, no restart needed.`):c.apply===`not-running`?(y=`${d} is saved`,b=`It turns on when your AI app opens your toolbox. If you haven't connected an app yet, that's the next step.`):c.apply===`needs-restart`||l.kind===`needs-restart`?(y=`${d} is saved. Restart your AI app once`,b=(l.kind===`needs-restart`?l.why:void 0)??`The running toolbox couldn't take this change while running. Quit your AI app and open it again.`,x=`clock`):l.kind===`needs-sign-in`?(y=`Saved, but it needs you to sign in`,b=`Press Sign in again below. It turns on as soon as you're signed in.`,x=`warning`):l.kind===`problem`?(y=`Saved, but it isn't working yet`,x=`warning`):p?(y=`Turning on ${d}…`,x=`clock`):(y=`${d} is saved`,b=`It's still starting. You can see how it's doing on the Connections page.`,x=`clock`);let C=l.kind===`problem`?{name:c.upstreamName,state:`failed`,problem:l.problem,since:``,attempts:0,tool_count:0}:l.kind===`needs-sign-in`?{name:c.upstreamName,state:`needs-sign-in`,since:``,attempts:0,tool_count:0}:null,w=e=>{$.saved=null,ae(i(f,e,{server:c.gatewayId}))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex flex-col items-center gap-3 py-6 text-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:L(`grid h-12 w-12 place-items-center rounded-full`,x===`check`?`bg-ok-tint text-ok`:x===`warning`?`bg-warn-tint text-warn`:`bg-sunken text-muted`),children:(0,Q.jsx)(m,{name:x,size:22,strokeWidth:2})}),(0,Q.jsx)(`h2`,{ref:t,tabIndex:-1,className:`text-[17px] font-semibold outline-none`,children:y}),(0,Q.jsx)(`div`,{className:`max-w-[46ch] text-[14px] text-muted`,children:p&&l.kind===`waiting`?(0,Q.jsx)(`span`,{className:`inline-flex items-center gap-2`,children:(0,Q.jsx)(S,{state:`connecting`,label:`Starting`})}):b})]}),C&&(0,Q.jsx)(Ke,{gatewayId:c.gatewayId,upstream:h??{name:c.upstreamName,transport:`stdio`,command:``},state:C,onEdit:e=>a(e,h,l.kind===`problem`?l.problem.detail?.path:void 0),onFixed:r,onAllowAddress:()=>w(`/protection`)}),o&&(0,Q.jsxs)(s,{tone:`danger`,role:`alert`,title:`The setup screen couldn't be opened again`,children:[o,` You can change this server on the Connections page instead.`]}),(c.summary.length>0||c.created)&&(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4 text-[13.5px]`,children:[c.created&&(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` Your toolbox is ready. Connect your AI app to it next.`]}),c.summary.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`check`,size:16,className:`mt-0.5 shrink-0 text-ok`}),` `,e]},e))]}),(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-faint pt-5`,children:(0,Q.jsx)(E,{variant:`primary`,icon:`check`,onClick:n,children:`Done`})})]})}var sn={};function cn({scope:t,projectDir:n}){let r=F(()=>H.clients(n),[n]),i=r.data?.clients.find(e=>e.scope===t)??null,[a,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(sn[t]??null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S=e=>{sn[t]=e??void 0,_(e)};if(!i)return r.error?(0,Q.jsx)(s,{tone:`danger`,children:B(r.error)}):(0,Q.jsx)(o,{lines:3});if(!i.attachedTo)return null;let w=V(t),T=i.servers??[],D=e=>T.find(t=>t.source===`extension`&&t.extensionId===e),O=a??new Set(ve(T)),k=T.filter(e=>e.importable&&!(e.source===`extension`&&e.inToolbox)),A=k.filter(e=>O.has(Y(e))),j=(e,t)=>{let n=new Set(O);t?n.add(Y(e)):n.delete(Y(e)),c(n)},ee=e=>{u(!0),f(null),H.importServers({scope:t,names:A.filter(e=>e.source===`config`).map(e=>e.name),extensions:A.filter(e=>e.source===`extension`).map(e=>e.extensionId),...i.projectScoped&&r.data?.projectDir?{projectDir:r.data.projectDir}:{},acknowledged:e}).then(e=>{h(null),c(null),S(e),r.reload()}).catch(t=>{t.detail?.needs===`loosens`&&!e?h(et(t)):(h(null),f(B(t)))}).finally(()=>u(!1))},M=v&&(0,Q.jsxs)(s,{tone:`warn`,title:`Give these servers back to ${w}?`,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,onClick:()=>y(!1),disabled:l,children:`Keep them in the toolbox`}),(0,Q.jsx)(E,{size:`sm`,variant:`danger`,onClick:()=>{u(!0),f(null),H.undoImport(t,i.projectScoped?r.data?.projectDir:void 0).then(e=>{y(!1),S(null),x(e),r.reload()}).catch(e=>f(B(e))).finally(()=>u(!1))},loading:l,children:`Give them back`})]}),children:[`They are taken out of your toolbox and put back in `,w,`'s own settings, the way they were. Keys saved for them are removed if nothing else uses them.`]});if(g){let t=g.extensionsToSwitchOff.map(e=>({...e,enabled:D(e.id)?.enabled??e.enabled}));return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers brought in`,children:[(0,Q.jsxs)(`div`,{role:`status`,className:`flex flex-col gap-2 rounded-[18px] bg-ok-tint p-5`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[16px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:19,className:`text-ok`,strokeWidth:2.2}),Le(w,g.imported.length+g.takenOut.length)]}),t.some(e=>e.enabled)&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:He(t.filter(e=>e.enabled).map(e=>e.name))}),g.imported.length+g.takenOut.length>0&&(0,Q.jsxs)(`ul`,{className:`space-y-1 text-[14px]`,children:[g.imported.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` `,`— as “`,e.upstream,`”, `,e.tools===1?`1 tool`:`${e.tools} tools`,e.keysLocked.length>0?`; ${e.keysLocked.join(`, `)} kept in your locked keys`:``]})]},`i-${e.name}`)),g.takenOut.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — your toolbox already had it; `,w,`'s own copy was taken out`]})]},`t-${e.name}`))]}),g.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:K(X(g.restartHint))})]}),g.failures.length>0&&(0,Q.jsxs)(s,{tone:`warn`,title:`${g.failures.length===1?`This one stayed`:`These stayed`} in ${w}`,children:[g.failures.length===1?`It`:`They`,` didn't connect when tested, so nothing about `,g.failures.length===1?`it`:`them`,` was changed.`,(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:g.failures.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,`:`]}),` `,K(X(e.message))]},e.name))})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Switch these off in Claude`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[14px] font-medium`,children:t.name}),t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})]}),t.enabled&&(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:J(t.name)})]},t.id))}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`refresh`,loading:r.loading,onClick:r.reload,children:`Check again`})})]}),g.otherApps.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[g.otherApps.join(` and `),` `,g.otherApps.length===1?`uses`:`use`,` this toolbox too, so `,g.otherApps.length===1?`it gets`:`they get`,` these servers as well.`]}),g.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(g.warning))}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),M,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo`}),(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,onClick:()=>S(null),children:`Done`})]})]})}return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,"aria-label":`Servers ${w} runs itself`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[15px] font-semibold`,children:`Bring its servers into your toolbox`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[13.5px] text-muted`,children:T.length>0?`${w} runs these servers itself, so your toolbox doesn't check what they do. Each one you choose is tested first; the ones that connect run through your toolbox instead and are taken out of ${w}'s own settings. A backup is kept, so you can undo it.`:`${w} has no servers of its own to bring in.`})]}),b&&(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:`Given back to ${w}`,children:[b.restored.length>0?`${b.restored.join(`, `)} ${b.restored.length===1?`is`:`are`} back in ${w}'s own settings. `:``,b.extensions.length>0?`Switch ${b.extensions.map(e=>e.name).join(` and `)} back on in Claude, under Settings, then Extensions, if you want Claude to run ${b.extensions.length===1?`it`:`them`} itself. `:``,K(X(b.restartHint))]}),T.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-soft`,children:Ye(w)}),T.length>0&&(0,Q.jsx)(`ul`,{className:`flex flex-col gap-3`,children:T.map(e=>(0,Q.jsx)(`li`,{className:`rounded-[14px] border border-line p-3`,children:(0,Q.jsx)(ln,{server:e,app:w,checked:O.has(Y(e)),onChange:t=>j(e,t)})},Y(e)))}),t===`claude-desktop`&&(0,Q.jsx)(`p`,{className:`text-[13px] text-soft`,children:`Connectors added on claude.ai live in your Claude account, not on this computer, so they can't be listed here.`}),(i.imported?.length??0)>0&&!b&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-muted`,children:[`Brought in earlier: `,i.imported.map(e=>e.name).join(`, `),`.`]}),d&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:d}),M,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k.length>0&&(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,disabled:A.length===0||l&&!p,loading:l&&!p,onClick:()=>ee(!1),children:l&&!p?`Testing each one…`:ue(A.length)}),i.canUndoImport&&!v&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>y(!0),children:`Undo bringing them in`})]}),(0,Q.jsx)(C,{open:p!==null,onCancel:()=>h(null),onConfirm:()=>ee(!0),title:`Let your toolbox reach these servers?`,consequences:p??[],confirmLabel:`Bring them in`,cancelLabel:`Don't bring them in`,busy:l,children:`At least one of these servers runs on this computer or your local network, which your toolbox only reaches once its allowed addresses are widened.`})]})}function ln({server:t,app:n,checked:r,onChange:i}){let a=(0,Q.jsxs)(`span`,{className:`ml-2 inline-flex flex-wrap gap-1.5 align-middle`,children:[t.source===`extension`&&(0,Q.jsx)(e,{children:`Extension`}),t.inToolbox&&t.source===`config`&&(0,Q.jsx)(e,{tone:`warn`,children:`In both`}),t.inToolbox&&t.source===`extension`&&(t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})),!t.importable&&(0,Q.jsx)(e,{children:`Can't be brought in`})]}),o=t.importable?t.inToolbox&&t.source===`config`?`Your toolbox already has it (as “${t.inToolbox}”), and ${n} still runs its own copy. Tick it to take ${n}'s copy out.`:t.inToolbox?t.enabled?`Your toolbox already has it. ${J(t.name)}`:`Your toolbox has it, and it is switched off in Claude.`:[t.source===`extension`?`A Claude extension. It isn't changed here; you switch it off in Claude afterwards.`:null,t.keysLocked.length>0?`${t.keysLocked.join(`, `)} ${t.keysLocked.length===1?`goes`:`go`} into your locked keys.`:null,t.needsLocalHttp?`It runs on this computer or your local network, so you'll be asked to confirm.`:null,t.upstreamName&&t.upstreamName!==t.name?`In your toolbox it will be called “${t.upstreamName}”.`:null].filter(Boolean).join(` `):K(X(t.reason??`It can't be brought in.`));return!t.importable||t.inToolbox&&t.source===`extension`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px]`,children:[(0,Q.jsxs)(`span`,{className:t.importable?`font-medium`:`font-medium text-soft`,children:[t.name,a]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:o})]}):(0,Q.jsx)(re,{checked:r,onChange:i,label:(0,Q.jsxs)(`span`,{className:`font-medium`,children:[t.name,a]}),description:o||void 0})}function un({client:e,projectDir:t}){let[n,r]=(0,Z.useState)(!1);if(!e.attachedTo)return null;let i=V(e.scope);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:`sm`,variant:`secondary`,icon:`plus`,onClick:()=>r(!0),children:`Bring in servers`}),(0,Q.jsx)(ie,{open:n,onClose:()=>r(!1),title:`Bring ${i}'s servers into your toolbox`,width:640,footer:(0,Q.jsx)(E,{onClick:()=>r(!1),children:`Close`}),children:(0,Q.jsx)(cn,{scope:e.scope,...t?{projectDir:t}:{}})})]})}function dn({title:e,children:t}){return(0,Q.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-[15px] font-semibold`,children:e}),t]})}function fn({go:e,icon:t,variant:n,newTab:r,children:i}){return e.href===void 0?(0,Q.jsx)(E,{size:`sm`,variant:n,icon:t,onClick:e.onClick,children:i}):(0,Q.jsx)(x,{href:e.href,size:`sm`,variant:n,icon:t,external:r,children:i})}function pn(e){let t=(0,Z.useRef)(!1),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null);return{busy:n,error:i,run:n=>{t.current||(t.current=!0,r(n.id),a(null),H.undoApp(n.id).then(t=>e(t,n)).catch(e=>a({app:n.id,text:B(e)})).finally(()=>{t.current=!1,r(null)}))}}}function mn({app:e,undone:t,onAnother:n}){let r=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>r.current?.focus(),[]),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{ref:r,tabIndex:-1,className:`outline-none`,children:(0,Q.jsxs)(s,{tone:`ok`,role:`status`,title:mt(e.label,t.disconnected),children:[ut(t),` `,t.note&&K(X(t.note)),` `,K(X(t.restartHint))]})}),(t.removed.length>0||t.keptInToolbox.length>0||t.guardRemoved)&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px] text-muted`,children:[t.removed.length>0&&(0,Q.jsx)(`p`,{children:yt(t.removed)}),t.keptInToolbox.length>0&&(0,Q.jsx)(`p`,{children:xt(t.keptInToolbox)}),t.guardRemoved&&(0,Q.jsx)(`p`,{children:`Claude Code's own actions are no longer recorded.`})]}),t.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(t.warning))}),n&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`arrow-left`,onClick:n,children:`Back to the apps`})})]})}function hn(e){let{result:t}=e;return t.status===`needs-server`?(0,Q.jsx)(gn,{...e,result:t}):(0,Q.jsx)(vn,{...e,result:t})}function gn({app:e,result:t,addServer:n,newTab:r,onAnother:i}){let a=(0,Z.useRef)(null);(0,Z.useEffect)(()=>a.current?.focus(),[]);let o=t.left.length>0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`status`,children:[(0,Q.jsx)(`div`,{ref:a,tabIndex:-1,className:`outline-none`,children:(0,Q.jsx)(s,{tone:`info`,title:kt(e.label,o),actions:(0,Q.jsx)(fn,{go:n,icon:`plus`,variant:`primary`,newTab:r,children:`Add a server`}),children:vt(e.label,o)})}),o&&(0,Q.jsx)(dn,{title:`Why ${e.label}'s servers stay where they are`,children:(0,Q.jsx)(_n,{left:t.left})}),i&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`arrow-left`,onClick:i,children:`Back to the apps`})})]})}function _n({left:e}){return(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[14px]`,children:e.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`minus`,size:16,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-muted`,children:[` — `,K(X(e.why))]})]})]},e.name))})}function vn({app:t,result:n,toolsHref:r,protect:i,newTab:a,extensionOn:o,onCheckAgain:c,onUndone:l,onAnother:u}){let d=F(()=>h.protection(n.toolbox.id),[n.toolbox.id]),f=pn(e=>l(e)),[p,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(null);(0,Z.useEffect)(()=>_.current?.focus(),[]);let v=f.error?.text??null,y=n.left.some(e=>e.kind===`needs-ok`),b=n.extensionsToSwitchOff.map(e=>({...e,enabled:o?.(e.id)??e.enabled})),S=pt(d.data?.enforcement);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{ref:_,tabIndex:-1,role:`status`,className:`flex flex-col gap-1 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),Pt(n,t.label)]}),n.refreshed&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:ht(t.label,n.refreshed)}),(0,Q.jsxs)(`p`,{className:`text-[14px] font-medium`,children:[`→ `,K(X(n.restartHint))]})]}),(0,Q.jsxs)(dn,{title:ct(n,t.label),children:[n.imported.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-wrap gap-1.5`,"aria-label":`Servers that moved`,children:n.imported.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-full bg-sunken px-2.5 py-0.5 text-[13px]`,children:[e.name,` `,(0,Q.jsxs)(`span`,{className:`text-soft`,children:[`· `,st(e.tools,`tool`)]})]},e.upstream))}),(0,Q.jsx)(x,{href:r,size:`sm`,iconRight:`arrow-right`,external:a,children:`See tools`})]}),n.takenOut.length>0&&(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:St(t.label,n.takenOut.map(e=>e.name))})]}),n.left.length>0&&(0,Q.jsxs)(dn,{title:lt(t.label),children:[(0,Q.jsx)(_n,{left:n.left}),y&&!p&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,icon:`eye`,onClick:()=>g(!0),children:`Review`})}),y&&p&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`Some servers need your OK before they can move`}),(0,Q.jsx)(cn,{scope:t.scope})]})]}),n.allowedHosts.length>0&&(0,Q.jsxs)(dn,{title:`Web addresses your toolbox may now reach`,children:[(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`The servers you moved live at these addresses, so your toolbox was allowed to connect to them.`}),(0,Q.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,"aria-label":`Web addresses your toolbox may now reach`,children:n.allowedHosts.map(e=>(0,Q.jsx)(`li`,{className:`mono rounded-full bg-sunken px-2.5 py-0.5 text-[12.5px]`,children:e},e))})]}),b.some(e=>e.enabled)&&(0,Q.jsxs)(dn,{title:Ct(b.filter(e=>e.enabled).length),children:[(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:b.map(t=>(0,Q.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[14px] font-medium`,children:[dt(t.name),t.enabled?(0,Q.jsx)(e,{tone:`warn`,children:`Still on`}):(0,Q.jsx)(e,{tone:`ok`,children:`Switched off`})]}),t.enabled&&(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:J(t.name)})]},t.id))}),c&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:c,children:`Check again`})})]}),n.notRecorded.length>0&&(0,Q.jsx)(dn,{title:`Not recorded`,children:(0,Q.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-[13.5px] text-muted`,children:n.notRecorded.map(e=>(0,Q.jsx)(`li`,{children:K(e)},e))})}),(n.guard||S||n.otherApps.length>0)&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[14px] text-muted`,children:[n.guard&&(0,Q.jsx)(`p`,{children:`Claude Code's own actions (reading and editing files, running commands, opening web pages) are recorded too.`}),S&&(0,Q.jsx)(`p`,{children:S}),n.otherApps.length>0&&(0,Q.jsx)(`p`,{children:at(n.otherApps)})]}),n.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(n.warning))}),v&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13.5px] font-medium text-bad`,children:v}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-faint pt-4`,children:[(0,Q.jsx)(fn,{go:i,icon:`shield-check`,variant:`primary`,newTab:a,children:`Protect me`}),n.undoable&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:f.busy===t.id,onClick:()=>f.run(t),children:wt(t.label)}),u&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:u,children:`Connect another app`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(q,{children:n.configPath})]}),(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(q,{children:n.backupPath})]})]})]})}function yn(e,t){return t||(e.toolbox?.needsConfirm?e.toolbox:null)}function bn(e,t){let n=yn(e,t.asked);return{...e.id===`claude-code`?{guard:t.guard}:{},...n&&t.confirmed===n.id?{toolbox:n.id}:{}}}function xn(e,t,n){if(!e.installed||e.error||bt(e.connection))return!1;let r=yn(e,n);return!r||t===r.id}function Sn(e){return e.kind===`result`&&e.result.status===`connected`?{app:e.app,result:e.result}:null}var Cn={kept:null};function wn(e){Cn.kept=Sn(e)}function Tn(){Cn.kept=null}function En({toolsHref:e,protect:t,addServer:n,newTab:r,keep:i,onConnected:a,onNeedsServer:c,onUndone:l}){let u=F(()=>H.apps(),[]),[d,p]=(0,Z.useState)(null),m=(0,Z.useRef)(!1),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)({}),[S,C]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(()=>i&&Cn.kept?{kind:`result`,...Cn.kept}:null),D=(e,t)=>{i&&wn(t),T(e)},O=(0,Z.useRef)(null),k=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{w===null&&k.current&&(k.current=!1,O.current?.focus())},[w]);let A=(e,t)=>{D({kind:`undone`,app:t,undone:e},{kind:`undone`}),l?.(e,t),u.reload()},j=pn((e,t)=>A(e,u.data?.apps.find(e=>e.id===t.id)??{id:t.id,label:t.id})),ee=e=>{m.current||(m.current=!0,p(e.id),g(t=>({...t,[e.id]:``})),H.connectApp(e.id,bn(e,{guard:_,confirmed:y[e.id],asked:S[e.id]})).then(t=>{D({kind:`result`,app:e,result:t},{kind:`result`,app:e,result:t}),t.status===`connected`?a?.(t,e):c?.(e),u.reload()}).catch(t=>{let n=t instanceof f?t.detail:void 0;t instanceof f&&t.status===409&&n?.needs===`toolbox`&&(C(t=>({...t,[e.id]:n.toolbox})),b(t=>({...t,[e.id]:void 0})),u.reload()),g(n=>({...n,[e.id]:B(t)}))}).finally(()=>{m.current=!1,p(null)}))},M=()=>{k.current=!0,D(null,{kind:`back`})};if(w?.kind===`undone`)return(0,Q.jsx)(mn,{app:w.app,undone:w.undone,onAnother:M});if(w){let i=u.data?.apps.find(e=>e.id===w.app.id),a=w.result;return(0,Q.jsx)(hn,{app:w.app,result:a,toolsHref:a.status===`connected`?e(a.toolbox.id,w.app.id):``,protect:a.status===`connected`?t(a.toolbox.id):n,addServer:n,newTab:r,extensionOn:e=>i?.servers.find(t=>t.source===`extension`&&t.extensionId===e)?.enabled,onCheckAgain:u.reload,onUndone:e=>A(e,w.app),onAnother:M})}if(u.error&&!u.data)return(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:u.reload,children:`Check again`}),children:B(u.error)});if(!u.data)return(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,"aria-busy":`true`,"aria-label":`Looking for your AI apps`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:3})},e))});let N=u.data.apps.filter(e=>e.installed),P=u.data.apps.filter(e=>!e.installed),I=d?u.data.apps.find(e=>e.id===d)?.label??null:null;return(0,Q.jsxs)(`div`,{ref:O,tabIndex:-1,className:`flex flex-col gap-4 outline-none`,children:[N.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:Dt}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:Et}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[U.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:u.loading,onClick:u.reload,children:`Check again`})]})]}):(0,Q.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,"aria-label":`Your AI apps`,children:N.map(e=>(0,Q.jsx)(Dn,{app:e,busy:d,busyLabel:I,error:h[e.id]||(j.error?.app===e.id?j.error.text:null),guard:_,onGuard:v,confirmed:y[e.id],onConfirm:t=>b(n=>({...n,[e.id]:t})),asked:S[e.id],onConnect:()=>ee(e),undoing:j.busy===e.id,onUndo:()=>j.run(e)},e.id))}),P.length>0&&(0,Q.jsxs)(`p`,{className:`text-[13.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-muted`,children:[`Not on this computer`,`:`]}),` `,P.map(e=>e.label).join(` · `)]}),u.data.cloud.length>0&&(0,Q.jsxs)(`section`,{"aria-labelledby":`cloud-apps-h`,className:`flex flex-col gap-2 rounded-[18px] bg-sunken/60 p-4`,children:[(0,Q.jsx)(`h3`,{id:`cloud-apps-h`,className:`text-[14px] font-semibold`,children:`Can't be connected from here`}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-[13px] text-muted`,children:u.data.cloud.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-ink`,children:[e.label,`:`]}),` `,e.note]},e.label))})]})]})}function Dn({app:t,busy:n,busyLabel:r,error:i,guard:a,onGuard:o,confirmed:s,onConfirm:c,asked:l,onConnect:u,undoing:d,onUndo:f}){let{moving:p,staying:h}=_t(t),g=yn(t,l),_=bt(t.connection),v=xn(t,s,l),y=!!n&&n!==t.id;return(0,Q.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-2.5 rounded-[18px] border-[1.5px] border-line p-4`,children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold`,children:t.label}),t.connected&&(0,Q.jsx)(e,{tone:`ok`,children:`Connected`})]}),(0,Q.jsx)(`span`,{className:`text-[13.5px] text-muted`,children:gt(t)}),p.length>0&&(0,Q.jsxs)(`span`,{className:`text-[12.5px] text-soft`,children:[`Moves: `,p.map(e=>e.name).join(`, `)]}),h.length>0&&(0,Q.jsxs)(`details`,{className:`text-[13px]`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-muted select-none`,children:[`Why `,h.length===1?`1 stays`:`${h.length} stay`]}),(0,Q.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:h.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,Q.jsxs)(`span`,{className:`text-muted`,children:[`— `,ot(e)]})]},`${e.scope}:${e.source}:${e.name}`))})]}),t.running&&(0,Q.jsxs)(`p`,{className:`flex gap-2 text-[13px] font-medium text-warn`,children:[(0,Q.jsx)(m,{name:`warning`,size:16,className:`mt-0.5 shrink-0`}),ft(t.label)]}),t.connected&&t.outdated&&(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-warn`,children:Ot(t.label,t.outdated)}),t.error&&(0,Q.jsx)(`p`,{className:`text-[13px] text-bad`,children:K(X(t.error))}),_&&(0,Q.jsx)(`p`,{className:`text-[13px] text-muted`,children:_}),t.id===`claude-code`&&!_&&(0,Q.jsx)(re,{checked:a,onChange:o,label:`Also record what Claude Code does by itself (reading and editing files, running commands)`,description:jt(g&&g.id!==t.toolbox?.id?{mode:null}:t.toolbox)}),g&&!_&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-2xl bg-sunken/60 p-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted`,children:Tt(t.label,g)}),(0,Q.jsx)(re,{checked:s===g.id,onChange:e=>c(e?g.id:void 0),label:Nt(g.label)})]}),i&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:i}),y&&r&&(0,Q.jsx)(`p`,{className:`text-[12.5px] text-soft`,children:At(r)}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:n===t.id,disabled:!v||y,onClick:u,children:Mt(t.label,t.connected,!!t.outdated)}),t.connected&&t.undoable&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,loading:d,disabled:!!n,onClick:f,children:wt(t.label)})]})]})}var On=null;function kn({client:e,projectDir:t,onClose:n,onDone:r}){let i=oe(),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(On),h=(0,Z.useRef)(!0);if((0,Z.useEffect)(()=>{h.current?h.current=!1:e&&(On=null,o(!1),d(null),p(null))},[e]),!e)return null;let g=()=>{On=null,n(),r()},_=Oe(e.scope),v=()=>{l(!0),d(null),H.revert(e.scope,a,e.projectScoped?t:void 0).then(t=>{On=t,p(t),i.show(`ok`,`${e.label} no longer uses your toolbox.`)}).catch(e=>d(B(e))).finally(()=>l(!1))};if(f){let e=f;return(0,Q.jsx)(ie,{open:!0,onClose:g,title:`Connection undone`,description:`Restart ${_} so it uses its own server list again.`,width:580,footer:(0,Q.jsx)(E,{variant:`primary`,onClick:g,children:`Close`}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsx)(`p`,{children:e.fileRestored===`bytes`?`Your toolbox was taken out of ${_}, and its settings file is back exactly as it was before.`:e.fileRestored===`removed`?`Your toolbox was taken out of ${_}. Its settings file didn't exist before, so it was removed again.`:`Your toolbox was taken out of ${_}.`}),f.restored.length>0?(0,Q.jsx)(An,{title:`Servers given back to ${_}`,items:f.restored}):(0,Q.jsxs)(`p`,{className:`text-soft`,children:[_,`'s own servers were never moved, so they keep working as before.`]}),e.copyLeft&&(0,Q.jsxs)(s,{tone:`warn`,title:`A copy of the old settings is kept`,children:[_,`'s settings file changed since it was connected, so a copy of it as it was is kept at `,(0,Q.jsx)(q,{children:e.copyLeft}),`. It holds the old values, including any keys that were written in it. Delete it once you no longer need it.`]}),e.keysKept&&e.keysKept.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Its keys stay in your locked keys (`,e.keysKept.join(`, `),`). Remove them under Settings & help, Locked keys, if nothing else uses them.`]}),f.importedNote&&(0,Q.jsx)(`p`,{className:`text-soft`,children:K(X(f.importedNote))}),e.stillUsedBy&&e.stillUsedBy.length>0&&(0,Q.jsxs)(`p`,{className:`text-soft`,children:[`Your toolbox was kept, because `,e.stillUsedBy.join(` and `),` still `,e.stillUsedBy.length===1?`uses`:`use`,` it.`]}),f.deleted.length>0&&(0,Q.jsx)(An,{title:`Files deleted`,items:f.deleted,paths:!0}),f.leftInPlace.length>0&&(0,Q.jsx)(An,{title:`Files kept`,items:f.leftInPlace,paths:!0}),f.refusedToDelete.length>0&&(0,Q.jsx)(s,{tone:`warn`,title:`Some files were not deleted`,children:(0,Q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:f.refusedToDelete.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(q,{children:e.path}),` `,K(X(e.why))]},e.path))})}),f.registryRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The toolbox was also removed from this console.`}),f.clientAllowRemoved&&(0,Q.jsx)(`p`,{className:`text-soft`,children:`The “Don't ask me twice” setting was removed from Claude Code.`}),f.clientAllowError&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(f.clientAllowError))}),f.warning&&(0,Q.jsx)(s,{tone:`warn`,children:K(X(f.warning))})]})})}return(0,Q.jsx)(ie,{open:!0,onClose:n,tone:`danger`,dismissable:!c,title:`Undo the connection for ${e.label}?`,description:`${_} goes back to reaching its servers directly, without your toolbox checking each call.`,width:580,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{variant:`secondary`,onClick:n,disabled:c,children:`Keep it connected`}),(0,Q.jsx)(E,{variant:`danger`,onClick:v,loading:c,children:`Undo connection`})]}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-[14px]`,children:[(0,Q.jsxs)(`ul`,{className:`space-y-2 text-muted`,children:[(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`refresh`,size:17,className:`mt-0.5 shrink-0 text-soft`}),`The app's original server list is put back from the backup made when it was connected.`]}),(0,Q.jsxs)(`li`,{className:`flex gap-2`,children:[(0,Q.jsx)(m,{name:`file`,size:17,className:`mt-0.5 shrink-0 text-soft`}),(0,Q.jsxs)(`span`,{children:[`The file changed is `,(0,Q.jsx)(q,{children:e.path})]})]})]}),(0,Q.jsx)(re,{checked:a,onChange:o,label:`Also delete the toolbox's files`,description:`Its settings file and protection settings. Your rules and choices in them are lost. Leave this off to keep them for later. They are kept anyway while another app still uses the toolbox.`}),u&&(0,Q.jsx)(s,{tone:`danger`,role:`alert`,children:u})]})})}function An({title:e,items:t,empty:n,paths:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold`,children:e}),t.length===0?(0,Q.jsx)(`p`,{className:`text-soft`,children:n}):(0,Q.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.map(e=>(0,Q.jsx)(`li`,{children:r?(0,Q.jsx)(q,{children:e}):(0,Q.jsx)(`code`,{className:`mono text-[13px]`,children:e})},e))})]})}var jn={done:null};function Mn({gatewayId:t,onDone:r,compact:i,scope:a}){let c=F(()=>H.clients(),[]),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(jn.done&&(!a||jn.done.scope===a)?jn.done:null),g=e=>{jn.done=e,h(e)},[_,v]=(0,Z.useState)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{p&&b.current&&(b.current=!1,y.current?.focus())},[p]);let S=c.data?.clients??[],C=(a?S.filter(e=>e.scope===a):S).filter(e=>!i||e.installed!==!1||e.exists).sort((e,t)=>Nn(e)-Nn(t)),w=e=>{u(e.scope),f(null),n.attach({gatewayId:t,scope:e.scope,...e.projectScoped&&c.data?.projectDir?{projectDir:c.data.projectDir}:{}}).then(t=>{let n=V(e.scope);b.current=!0,g({...t,appLabel:n,scope:e.scope}),r({...t,appLabel:n,scope:e.scope}),c.reload()}).catch(t=>f({scope:e.scope,text:B(t)})).finally(()=>u(null))};if(p){let e=S.find(e=>e.scope===p.scope)??null,t=e?.servers?$e(e.servers).length:0;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{ref:y,tabIndex:-1,role:`status`,className:`flex flex-col gap-3 rounded-[18px] bg-ok-tint p-5 outline-none focus-visible:outline-2 focus-visible:outline-[var(--focus)]`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2.5 text-[17px] font-medium`,children:[(0,Q.jsx)(m,{name:`check`,size:20,className:`text-ok`,strokeWidth:2.2}),p.refreshed?`Updated ${p.appLabel}`:p.alreadyConnected?`${p.appLabel} was already connected`:`Restart ${p.appLabel} once`]}),(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:p.refreshed?ht(p.appLabel,p.refreshed):p.alreadyConnected?`${p.leftAsIs?`${K(X(p.leftAsIs))} `:``}Nothing needed changing.${t>0?` Its own servers still run directly; bring them in below.`:``}`:`${p.appLabel} reads its list of servers when it opens, so it needs one restart to find your toolbox. After that, servers you add show up by themselves.`}),p.restartHint&&(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:K(X(p.restartHint))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 text-[12.5px] text-soft`,children:[(0,Q.jsxs)(`span`,{children:[`Changed: `,(0,Q.jsx)(q,{children:p.configPath})]}),p.backupPath&&(0,Q.jsxs)(`span`,{children:[`Backup of how it was: `,(0,Q.jsx)(q,{children:p.backupPath})]})]}),e?.attachedTo&&(0,Q.jsx)(cn,{scope:e.scope,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v({...e,canRevert:!0}),children:`Undo`}),!a&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`plug`,onClick:()=>g(null),children:`Connect another app`})]}),(0,Q.jsx)(kn,{client:_,projectDir:c.data?.projectDir,onClose:()=>v(null),onDone:()=>{g(null),c.reload()}})]})}return c.error&&!c.data?(0,Q.jsx)(s,{tone:`danger`,title:`Your apps could not be checked`,actions:(0,Q.jsx)(E,{size:`sm`,icon:`refresh`,onClick:c.reload,children:`Check again`}),children:B(c.error)}):c.data?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!a&&(0,Q.jsx)(`p`,{className:`text-[14px] text-muted`,children:`Pick the app you talk to. One click adds your toolbox to it; nothing else in the app changes.`}),C.length===0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-[18px] border border-line p-4`,children:[(0,Q.jsx)(`p`,{className:`text-[14px] font-medium`,children:`No AI app was found on this computer.`}),(0,Q.jsx)(`p`,{className:`text-[13.5px] text-muted`,children:`Install one of these, open it once, then come back here and press Check again.`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[U.map(e=>(0,Q.jsxs)(x,{href:e.url,external:!0,size:`sm`,iconRight:`external`,children:[`Get `,e.label]},e.url)),(0,Q.jsx)(E,{size:`sm`,variant:`primary`,icon:`refresh`,loading:c.loading,onClick:c.reload,children:`Check again`})]})]}),(0,Q.jsx)(`ul`,{className:L(`grid gap-3`,!a&&`sm:grid-cols-2`),children:C.map(t=>{let n=G(t),r=t.alreadyAdopted;return(0,Q.jsxs)(`li`,{className:L(`flex min-w-0 flex-col gap-2 rounded-[18px] border-[1.5px] border-line p-4`,!n&&!r&&`bg-sunken/40`),children:[(0,Q.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:L(`min-w-0 flex-1 text-[15px] font-semibold`,!n&&!r&&`text-soft`),children:Ue(t,c.data?.projectDir)}),r?(0,Q.jsx)(e,{tone:`ok`,children:`Connected`}):!n&&(0,Q.jsx)(e,{children:t.error?`Can't be read`:`Not found`})]}),(0,Q.jsx)(`span`,{className:`text-[13px] text-soft`,children:t.error?K(X(t.error)):r?W(t.servers,Pe(t)):n?it(t.servers?.length??t.serverCount):`This app isn't on this computer.`}),d?.scope===t.scope&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-[13px] font-medium text-bad`,children:d.text}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-wrap gap-2 pt-1`,children:[n&&!r&&(0,Q.jsxs)(E,{size:`sm`,variant:`primary`,icon:`plug`,loading:l===t.scope,disabled:!!l&&l!==t.scope,onClick:()=>w(t),children:[`Connect `,V(t.scope)]}),r&&(0,Q.jsx)(un,{client:t,...c.data?.projectDir?{projectDir:c.data.projectDir}:{}}),t.canRevert&&(0,Q.jsx)(E,{size:`sm`,variant:`ghost`,icon:`refresh`,onClick:()=>v(t),children:`Undo connection`})]})]},t.scope)})}),(0,Q.jsx)(kn,{client:_,projectDir:c.data.projectDir,onClose:()=>v(null),onDone:c.reload})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[0,1].map(e=>(0,Q.jsx)(`div`,{className:`rounded-[18px] border border-line p-4`,children:(0,Q.jsx)(o,{lines:2})},e))})}var Nn=e=>e.error?3:e.alreadyAdopted?1:G(e)?0:4;export{un as a,zt as c,Ft as d,Lt as f,Tn as i,It as l,kn as n,an as o,En as r,rn as s,Mn as t,Rt as u};