limixbot 0.3.126 → 0.3.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-DIMjrd3X.js → ActivityPanel-BFSwx00G.js} +1 -1
- package/dist/assets/{App-CS3HrcMj.js → App-UlXFr-rh.js} +119 -119
- package/dist/assets/{AppEventEditor-DhtwxBir.js → AppEventEditor-B7Io0wi4.js} +1 -1
- package/dist/assets/{BotSettingsDialog-Dgq4U3Nf.js → BotSettingsDialog-B7hW939m.js} +1 -1
- package/dist/assets/{BrowserPanel-CMnRadEp.js → BrowserPanel-2FEz8sUH.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-Dx9QOdNF.js → BrowserProfilesManager-DjtG76qN.js} +1 -1
- package/dist/assets/{CloudAddDialog-BBFnRgs1.js → CloudAddDialog-C0sa5ArG.js} +1 -1
- package/dist/assets/{ComputerFilesPane-C94SXeS_.js → ComputerFilesPane-QFeb-ewE.js} +1 -1
- package/dist/assets/{ComputerPanel-Cronfk0-.js → ComputerPanel-sKgH3B7V.js} +2 -2
- package/dist/assets/{DataPanel-DMS_tCpf.js → DataPanel-BNHLLw4V.js} +1 -1
- package/dist/assets/{GrokMoveDialog-kUhkAFi-.js → GrokMoveDialog-Ck_lC5co.js} +1 -1
- package/dist/assets/{InspectorPanel-4H1--CX1.js → InspectorPanel-BNHiBYSd.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-CLlU6zUw.js → KeyboardShortcutsModal-CAnRULUo.js} +1 -1
- package/dist/assets/{LimixResizeHandles-DfWhgf3R.js → LimixResizeHandles-RBNUxAWK.js} +1 -1
- package/dist/assets/{LiveDesktop-BTzCEDXq.js → LiveDesktop-CBwaPn-v.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-ClW4eeSV.js → LocalVmWorkspace-C6Mp51Ya.js} +1 -1
- package/dist/assets/{MacLocalControl-BIq1xfTV.js → MacLocalControl-CB1n0Rwg.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-DHM2_q-g.js → MarkdownFilePreview-CEFVN7bO.js} +1 -1
- package/dist/assets/{NewBotDialog-Dv1uDRyz.js → NewBotDialog-BZyKYErk.js} +1 -1
- package/dist/assets/{PhoneAppDialog-DOR04gUf.js → PhoneAppDialog-Xuvxu5R4.js} +1 -1
- package/dist/assets/{PlacesRail-RbEQCQDz.js → PlacesRail-HdHRCodH.js} +1 -1
- package/dist/assets/PluginsPanel-K8R5tGG1.js +8 -0
- package/dist/assets/{ProIntroduction-C6BiXYPS.js → ProIntroduction-CekjUapV.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-CA74QBHk.js → RemoteAgentSettingsPanel-mGE8ZvE7.js} +1 -1
- package/dist/assets/{RoomPanel-dDwHIpEP.js → RoomPanel-DaJwgf2-.js} +1 -1
- package/dist/assets/{RoutinesPage-BrotrkDr.js → RoutinesPage-YdlVSVTB.js} +1 -1
- package/dist/assets/{SettingsModal-BuRiDIcS.js → SettingsModal-D69DAjZz.js} +4 -4
- package/dist/assets/{ShareTeamDialog-HMNWpkYV.js → ShareTeamDialog-CQCrALiU.js} +1 -1
- package/dist/assets/{SignedInSites-Ld5qeXJU.js → SignedInSites-CaLYcDmG.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-BmpNk2AJ.js → TeamLibraryPanel-BywQZ0U2.js} +1 -1
- package/dist/assets/{TeamMapPage-CB2jk0oq.js → TeamMapPage-8N6-aXaN.js} +1 -1
- package/dist/assets/{TriggersPage-Bowp3ya_.js → TriggersPage-DcX1ruE_.js} +1 -1
- package/dist/assets/{VisibilitySection-DHAhO-7A.js → VisibilitySection-QNfma0_Q.js} +1 -1
- package/dist/assets/{WebhookTrigger-CaL1ySEI.js → WebhookTrigger-DjFrDFpT.js} +1 -1
- package/dist/assets/{WorksOnGrid-DyO7xzTr.js → WorksOnGrid-BPq4vW3n.js} +1 -1
- package/dist/assets/{core-CR3Wuk_4.js → core-B1gf3Z1c.js} +1 -1
- package/dist/assets/{import-name-D7aA4mLr.js → import-name-CU_qLPSL.js} +1 -1
- package/dist/assets/{index-B7FjK7sg.js → index-9b3nVh6T.js} +1 -1
- package/dist/assets/{index-1qHuN_Gs.js → index-CquxehuD.js} +2 -2
- package/dist/assets/{mcp-servers-B9fmEHDJ.js → mcp-servers-D9YZ99kI.js} +1 -1
- package/dist/assets/{new-bot-USwoHfYT.js → new-bot-DzOrSV2V.js} +1 -1
- package/dist/assets/{org-library-D4XB-Whq.js → org-library-DcXalbrG.js} +1 -1
- package/dist/assets/{package-format-BOH4bncG.js → package-format-KDg9nGi0.js} +1 -1
- package/dist/assets/{rail-BZIFozED.js → rail-CMXP3rkT.js} +1 -1
- package/dist/assets/{remote-desktop-panel-yZRJK5wr.js → remote-desktop-panel-ClkgPSQp.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/rail.html +2 -2
- package/dist-server/package.json +1 -1
- package/package.json +1 -1
- package/dist/assets/PluginsPanel-ChXeOAhk.js +0 -8
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{c as un,t as n,r as d,j as e,X as ns,ae as ss,a as q,d as Ze,l as xt,S as As,i as Vt}from"./styles-CbbuPFF7.js";import{S as pn,j as A,u as Xe,eG as Cs,eH as Ss,eI as Rs,eJ as ft,w as Es,eK as zs,eL as Is,l as Ts,G as Rn,eM as Os,eN as Bs,cT as Ps,T as Ms,ah as en,bt as Ls,D as tn,eO as zt,eP as as,eQ as It,eR as is,an as os,eS as Tt,eT as Us,eU as cs,eV as Ot,eW as rs,eX as $s,eY as En,eZ as Fs,Y as ls,e_ as Ct,e$ as Ks,f0 as Ds,f1 as Hs,f2 as Qs,f3 as _s,f4 as ct,f5 as zn,f6 as Js,f7 as In,eg as Tn,f8 as Vs,f9 as Gs,fa as qs,fb as Gt,fc as Ws,fd as Zs,fe as Ys,ff as Xs,fg as ea,fh as ta,fi as na,fj as sa,fk as aa,fl as ia,fm as oa}from"./App-CS3HrcMj.js";import{L as ie,P as ds,X as ca,a as ra,v as mn,E as la,_ as da,$ as ua,B as pa}from"./PlacesRail-RbEQCQDz.js";import{u as qt}from"./mcp-servers-B9fmEHDJ.js";import{C as us,R as nn}from"./MenuMotion-p_3OSw7G.js";import{u as ma}from"./ProIntroduction-C6BiXYPS.js";import"./index-1qHuN_Gs.js";import"./monitor-DInAobl-.js";const ha=[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],xa=un("phone-call",ha);const fa=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],ga=un("radio-tower",fa);const ba=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Wt=un("server-cog",ba),ya=new Set(["twitter","x"]);function On(t,s){return t!=="managed"||!ya.has(s.trim().toLowerCase())?null:"Twitter/X needs your own X Developer app and Composio auth config. Use self-hosted connected apps for now."}const ka=5,ja=3,Bt=4;function va(t,s=ka,o=[]){const c=new Map;for(const f of t)for(const y of new Set(f.categories??[]))c.set(y,(c.get(y)??0)+1);const r=[...c].sort((f,y)=>y[1]-f[1]||f[0].localeCompare(y[0])).map(([f])=>f),l=o.filter(f=>r.indexOf(f)>=s),b=[...r.slice(0,Math.max(0,s-l.length)),...l];return{inline:b,more:r.filter(f=>!b.includes(f))}}function sn(t,s){return s===null||(t.categories??[]).includes(s)}function wa(t,s,o){const c=[],r=t.filter(l=>s(l.slug));r.length&&c.push({kind:"connected",cards:r});for(const l of o.slice(0,ja)){const b=t.filter(f=>!s(f.slug)&&sn(f,l));b.length&&c.push({kind:"category",category:l,cards:b.slice(0,Bt),more:b.length>Bt})}return c.push({kind:"all",cards:t.filter(l=>!s(l.slug))}),c}const Na={productivity:"productivity","developer tools":"developerTools",communication:"communication",files:"files","sales and crm":"salesCrm",design:"design",marketing:"marketing",analytics:"analytics",social:"social"},Aa={"google calendar":"googleCalendar","google sheets":"googleSheets","google docs":"googleDocs",notion:"notion",github:"github",linear:"linear",sentry:"sentry",jira:"jira",slack:"slack",gmail:"gmail",discord:"discord","google drive":"googleDrive",posthog:"posthog","x (twitter)":"xTwitter",reddit:"reddit",zapier:"zapier",hubspot:"hubspot",salesforce:"salesforce",asana:"asana",trello:"trello",dropbox:"dropbox",airtable:"airtable",figma:"figma",stripe:"stripe"};function rt(t){const s=Na[t.trim().toLowerCase()];return s?n(`apps.category.${s}`):t}function Bn(t){const s=Aa[t.label.trim().toLowerCase()];return s?n(`apps.catalog.${s}.blurb`):t.blurb}function Ca({server:t,disabled:s,onSaved:o}){const[c,r]=d.useState(!1),[l,b]=d.useState(null);if(typeof t.apps!="boolean"||t.apps&&t.hasApps!==!0)return null;const f=t.apps,y=async()=>{r(!0),b(null);try{const p=await A(`/api/mcp/servers/${encodeURIComponent(t.name)}`,{method:"PATCH",body:JSON.stringify({apps:!f})});o(p.servers??[])}catch(p){b(p instanceof Error?p.message:String(p))}finally{r(!1)}};return e.jsxs("div",{"data-mcp-apps":t.name,className:"mt-3 flex items-center gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("mcp.apps.title")}),e.jsx("div",{role:l?"alert":void 0,className:l?"mt-0.5 text-[12px] text-danger":"mt-0.5 text-[12px] text-ink-secondary",children:l??n("mcp.apps.desc")})]}),c&&e.jsx(ie,{"aria-hidden":"true",size:13,className:"animate-spin text-ink-secondary"}),e.jsx(pn,{checked:f,disabled:s||c,onClick:()=>{y()},"aria-label":n("mcp.apps.toggleAria",{name:t.name}),className:"disabled:opacity-40"})]})}function Pn({feature:t,enabled:s,prefix:o}){const{dispatch:c}=Xe(),[r,l]=d.useState(!1),[b,f]=d.useState(!1),y=async()=>{if(!r){l(!0),f(!1);try{const p=await A("/api/config",{method:"PATCH",body:JSON.stringify({features:{[t]:!s}})});c({type:"configStatus",config:p})}catch{f(!0)}finally{l(!1)}}};return e.jsxs("div",{className:"mt-4 flex items-start justify-between gap-4 rounded-2xl border border-hairline/50 bg-card px-4 py-4 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:n(`${o}.title`)}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n(`${o}.desc`)}),b&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:n("mcp.claude.error")})]}),e.jsx(pn,{checked:s,"aria-label":n(`${o}.aria`),disabled:r,onClick:()=>{y()},className:"mt-0.5 shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}function Sa(){const{state:t}=Xe();return e.jsxs(e.Fragment,{children:[e.jsx(Pn,{feature:"claudeUserMcp",enabled:Cs(t.config),prefix:"mcp.claude"}),e.jsx(Pn,{feature:"claudeUserSkills",enabled:Ss(t.config),prefix:"mcp.claudeSkills"})]})}function Mn({app:t}){if("image"in t.icon)return e.jsx("img",{src:t.icon.image,alt:"",className:"size-10 shrink-0 rounded-xl object-contain"});const s=t.icon.glyph;return e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-xl bg-raised text-ink-secondary",children:e.jsx(s,{size:19,"aria-hidden":"true"})})}class me extends Error{key;constructor(s){super(s),this.key=s}}const an=/^https?:\/\//i,ps=/^[A-Za-z_][A-Za-z0-9_]*=/,Ra=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+:/,Ea=new Set(["npx","uvx","bunx"]),za=new Set(["pnpm","yarn"]);function Ia(t,s=[]){const o=Ta(t).trim();if(!o)return null;try{const c=/^[{[]/.test(o)?$a(o):an.test(o)&&!/\s/.test(o)?[hn(void 0,o,void 0,[])]:Oa(o);return{ok:!0,servers:Qa(c,s)}}catch(c){if(c instanceof me)return{ok:!1,error:c.key};throw c}}function Ta(t){return t.replace(/[“”„]/g,'"').replace(/[‘’]/g,"'").replace(/(^|\s)[–—](?=[a-z])/g,"$1--")}function ms(t){const s=[];let o=[],c="",r=!1;const l=()=>{r&&o.push(c),c="",r=!1},b=()=>{l(),o.length&&s.push(o),o=[]},f=y=>t[y]===`
|
|
2
|
-
`?1:t[y]==="\r"&&t[y+1]===`
|
|
3
|
-
`?2:0;for(let y=0;y<t.length;y+=1){const p=t[y];if(p==="\\"||(p==="`"||p==="^")&&f(y+1)){const m=f(y+1);if(m){y+=m;continue}y+1<t.length&&(c+=t[y+1],r=!0,y+=1);continue}if(p==="'"){const m=t.indexOf("'",y+1);if(m<0)throw new me("mcp.paste.notRecognized");c+=t.slice(y+1,m),r=!0,y=m;continue}if(p==='"'){let m=y+1;for(;m<t.length&&t[m]!=='"';m+=1){if(t[m]==="\\"&&m+1<t.length){const j=f(m+1);if(j){m+=j;continue}if('"\\$`'.includes(t[m+1])){c+=t[m+1],m+=1;continue}}c+=t[m]}if(m>=t.length)throw new me("mcp.paste.notRecognized");r=!0,y=m;continue}if(p==="$"&&t[y+1]==="("){const m=t.indexOf(")",y+2);if(m<0)throw new me("mcp.paste.notRecognized");c+=t.slice(y,m+1),r=!0,y=m;continue}if(p==="#"&&!r){for(;y+1<t.length&&t[y+1]!==`
|
|
4
|
-
`;)y+=1;continue}if(p===`
|
|
5
|
-
`||p===";"){b();continue}if(p==="&"&&t[y+1]==="&"){b(),y+=1;continue}if(/\s/.test(p)){l();continue}c+=p,r=!0}return b(),s}function Oa(t){const s=ms(t);if(!s.length)throw new me("mcp.paste.notRecognized");return s.map(o=>{const c=o[0]==="$"||o[0]===">"?o.slice(1):o;return c[0]==="claude"&&c[1]==="mcp"&&c[2]==="add"?Ba(c.slice(3)):c[0]==="claude"&&c[1]==="mcp"&&c[2]==="add-json"?Pa(c.slice(3)):Ma(c)})}function Ba(t){let s,o;const c=[],r=[],l=[];let b=[];for(let m=0;m<t.length;m+=1){const j=t[m];if(j==="--"){b=t.slice(m+1);break}const D=/^(--[a-z][a-z-]*|-[a-zA-Z])(?:=([\s\S]*))?$/.exec(j);if(!D){l.push(j);continue}const R=()=>D[2]??t[++m]??"",B=(H,F)=>{for(;m+1<t.length&&H.test(t[m+1])&&!an.test(t[m+1]);)F.push(t[++m])};switch(D[1]){case"--transport":case"-t":s=R().toLowerCase();break;case"--header":case"-H":c.push(R()),D[2]===void 0&&B(Ra,c);break;case"--env":case"-e":r.push(R()),D[2]===void 0&&B(ps,r);break;case"--client-id":o=R();break;case"--scope":case"-s":case"--callback-port":R();break}}const[f,y,...p]=[...l,...b];if(!f||!y)throw new me("mcp.paste.incomplete");if(s!=="stdio"&&(s==="http"||s==="sse"||an.test(y))){const m=hn(f,y,s==="sse"?"sse":s==="http"?"http":void 0,c.map(Fa));return o?{...m,oauthClientId:o}:m}return{transport:"stdio",name:ft(f),command:y,args:p,env:r.map(xn)}}function Pa(t){const s=[];for(let l=0;l<t.length;l+=1){const b=t[l];if(b==="--scope"||b==="-s"){l+=1;continue}b.startsWith("-")&&!b.startsWith("{")||s.push(b)}const[o,c]=s;if(!o||!c)throw new me("mcp.paste.incomplete");const r=on(o,hs(c));if(!r)throw new me("mcp.paste.notRecognized");return r}function Ma(t){let s=0;const o=[];for(;s<t.length&&ps.test(t[s]);)o.push(xn(t[s++]));const[c,...r]=t.slice(s);if(!c)throw new me("mcp.paste.notRecognized");if(c==="docker"&&r[0]==="run")return Ua(r,o);if(!Ea.has(c)&&!(za.has(c)&&r[0]==="dlx"))throw new me("mcp.paste.notRecognized");const l=r.find((b,f)=>!b.startsWith("-")&&!(f===0&&b==="dlx"));if(!l)throw new me("mcp.paste.incomplete");return{transport:"stdio",name:gn(l),command:c,args:r,env:o}}const La=new Set(["-i","-t","-it","-ti","-d","--rm","--init","--interactive","--tty","--detach","--privileged"]);function Ua(t,s){const o=[t[0]];let c;for(let r=1;r<t.length;r+=1){const l=t[r];if(c||!l.startsWith("-"))c??=l,o.push(l);else if((l==="-e"||l==="--env")&&r+1<t.length){const b=t[++r],f=b.split("=")[0];s.push(b.includes("=")?xn(b):{name:f,value:"",gap:{kind:"variable",names:[f],before:"",after:""}}),o.push(l,f)}else l.includes("=")||La.has(l)||r+1>=t.length?o.push(l):o.push(l,t[++r])}if(!c)throw new me("mcp.paste.incomplete");return{transport:"stdio",name:gn(c.replace(/:[^/:]*$/,"")),command:"docker",args:o,env:s}}function hs(t){try{return JSON.parse(t)}catch{throw new me("mcp.paste.badJson")}}const pt=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function $a(t){const s=hs(t);if(!pt(s))throw new me("mcp.paste.notRecognized");const o=on(typeof s.name=="string"?s.name:void 0,s);if(o)return[o];const c=pt(s.mcpServers)?s.mcpServers:pt(s.servers)?s.servers:s,r=Object.entries(c).map(([l,b])=>on(l,b));if(!r.length||r.some(l=>!l))throw new me("mcp.paste.notRecognized");return r}const Ln=t=>pt(t)?Object.entries(t).filter(s=>typeof s[1]=="string"):[];function on(t,s){if(!pt(s))return null;const o=typeof s.url=="string"?s.url:typeof s.serverUrl=="string"?s.serverUrl:void 0,c=typeof s.type=="string"?s.type.toLowerCase():"";if(o!==void 0){const p=Ln(s.headers).map(([m,j])=>Pt(m,j));return hn(t,o,c==="sse"?"sse":c?"http":void 0,p)}if(typeof s.command!="string"||!s.command.trim())return null;const r=Array.isArray(s.args)?s.args.filter(p=>typeof p=="string"):[],[l,...b]=r.length?[s.command.trim()]:ms(s.command)[0]??[s.command],f=Ln(s.env).map(([p,m])=>Pt(p,m)),y=[...b,...r];return{transport:"stdio",name:t?ft(t):gn(y.find(p=>!p.startsWith("-"))??l??""),command:l,args:y,env:f}}function hn(t,s,o,c){const r=fn(s);return{transport:"remote",name:t?ft(t):Ha(s),type:o??(/\/sse\/?(?:[?#]|$)/i.test(s)?"sse":"http"),url:s,...r?{urlGap:r}:{},headers:c}}function Fa(t){const s=t.indexOf(":");if(s<=0)throw new me("mcp.paste.badPair");return Pt(t.slice(0,s).trim(),t.slice(s+1).trim())}function xn(t){const s=t.indexOf("=");if(s<=0)throw new me("mcp.paste.badPair");return Pt(t.slice(0,s),t.slice(s+1))}function Pt(t,s){const o=fn(s);return o?{name:t,value:"",gap:o}:{name:t,value:s}}const Ka=/\$\{([^}]*)\}|\$\(([^)]*)\)|\$([A-Za-z_][A-Za-z0-9_]*)/g,Da=/<([^<>\s][^<>]{0,63})>|\b(YOUR[_-][A-Za-z0-9_-]+|your[_-][a-z0-9_-]+)\b/g;function fn(t){const s=[];for(const l of t.matchAll(Ka)){const b=(l[1]??l[2]??l[3]??"").replace(/^(?:env|input):/,"").replace(/:-[\s\S]*$/,"").trim();s.push({start:l.index,end:l.index+l[0].length,name:b||l[0],kind:"variable"})}for(const l of t.matchAll(Da))s.some(b=>l.index<b.end&&l.index+l[0].length>b.start)||s.push({start:l.index,end:l.index+l[0].length,name:(l[1]??l[2]??"").trim(),kind:"placeholder"});if(!s.length)return;const o=[...new Set(s.map(l=>l.name))],c=s.some(l=>l.kind==="variable")?"variable":"placeholder",r=s.length===1?s[0]:null;return{kind:c,names:o,before:r?t.slice(0,r.start):"",after:r?t.slice(r.end):""}}const xs=new Set(["www","mcp","api","server","servers","app","remote","sse","gateway","co","com","org","net","ac","gov"]);function Ha(t){let s;try{s=new URL(t).hostname}catch{return""}if(/^[\d.]+$/.test(s)||s.includes(":"))return"server";const o=s.split(".").filter(Boolean);return o.length>1&&o.pop(),ft(o.filter(c=>!xs.has(c)).at(-1)??o.at(-1)??"server")}function gn(t){const s=t.replace(/(?!^)@[^/@]*$/,"").split("/"),o=s.at(-1)??t,c=o.replace(/^(?:mcp-server-|server-|mcp-)/,"").replace(/(?:-mcp-server|-mcp|-server)$/,""),r=(s.at(-2)??"").replace(/^@/,"");return ft(xs.has(c)&&r?r:c||o)||"server"}function Qa(t,s){const o=new Set(s);return t.map(c=>{let r=c.name||"server";if(o.has(r))for(let l=2;o.has(r);l+=1)r=Rs(`${c.name.slice(0,29)}-${l}`);return o.add(r),r===c.name?c:{...c,name:r}})}const _a=2e6;function Ja(t){const s=t.trim(),c=/^\d{1,3}([\s,._ '])\d{3}(?:\1\d{3})*$/.test(s)?s.replace(/\D/g,""):s;return c?!/^\d+$/.test(c)||Number(c)>_a?{ok:!1,error:{key:"mcp.err.resultBudget"}}:{ok:!0,value:Number(c)}:{ok:!0,value:void 0}}function Un(t){return t.resultBudget===void 0?"":String(t.resultBudget)}function Va(t,s){const o=Ja(t);if(!o.ok)return o;const c=s();return!c.ok||o.value===void 0?c:{ok:!0,body:{...c.body,resultBudget:o.value}}}function Ga({value:t,onChange:s}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("mcp.field.resultBudget")}),e.jsx("input",{value:t,onChange:o=>s(o.target.value),inputMode:"numeric",placeholder:"8000",className:"mt-1.5 w-full rounded-lg border border-hairline/60 bg-raised px-3 py-2.5 text-[13px] text-ink outline-none focus:border-accent"}),e.jsx("span",{className:"mt-1.5 block text-[11px] text-ink-secondary",children:n("mcp.resultBudgetHint")})]})}function pe(t){return"url"in t}let $n=0;function Be(t={name:"",value:""}){return $n+=1,{id:$n,...t}}function Ye(){return{name:"",transport:"remote",command:"",args:"",env:[Be()],type:"http",url:"",headers:[Be()],oauthClientId:"",oauthClientSecret:"",oauthScopes:"",oauthForgetSecret:!1,resultBudget:""}}const Fn=t=>t.length?t.map(s=>Be({name:s,value:"",saved:!0})):[Be()],Kn=t=>t.length?t.map(s=>Be({...s})):[Be()];function qa(t){return pe(t)?{...Ye(),name:t.name,type:t.type,url:t.url,headers:Fn(t.headerKeys),oauthClientId:t.oauth?.clientId??"",oauthScopes:t.oauth?.scopes.join(" ")??"",resultBudget:Un(t)}:{...Ye(),name:t.name,transport:"stdio",command:t.command,args:t.args.join(`
|
|
6
|
-
`),env:Fn(t.envKeys),resultBudget:Un(t)}}function Wa(t){return t.transport==="remote"?{...Ye(),name:t.name,type:t.type,url:t.url,...t.urlGap?{urlGap:t.urlGap}:{},headers:Kn(t.headers),oauthClientId:t.oauthClientId??""}:{...Ye(),name:t.name,transport:"stdio",command:t.command,args:t.args.join(`
|
|
7
|
-
`),env:Kn(t.env)}}function cn(t){const s=t.value.trim();if(!t.gap||!s)return t.value;const{before:o,after:c}=t.gap;return o.trim()&&s.toLowerCase().startsWith(o.trim().toLowerCase())?s:`${o}${s}${c}`}const Za=/^[A-Za-z_][A-Za-z0-9_]*$/,Ya=/^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/;function Dn(t,s){const o={};for(const c of t){const r=c.name.trim(),l=s==="header"?cn(c).trim():cn(c);if(!(!r&&!l)){if(!r)return{ok:!1,error:{key:"mcp.err.rowName"}};if(!(s==="header"?Ya:Za).test(r))return{ok:!1,error:{key:s==="header"?"mcp.headers.invalidName":"mcp.env.invalidName",params:{key:r}}};if(Object.hasOwn(o,r))return{ok:!1,error:{key:s==="header"?"mcp.headers.duplicate":"mcp.env.duplicate",params:{key:r}}};if(l)o[r]=l;else if(c.saved)o[r]=!0;else return{ok:!1,error:{key:"mcp.err.missingValue",params:{name:r}}}}}return{ok:!0,values:o}}function Xa(t){return t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean)}function ei(t,s){const o=t.clientId.trim();if(!o)return;const c=t.clientSecret.trim(),r=t.scopes.split(/[\s,]+/).filter(Boolean);return{clientId:o,...c?{clientSecret:c}:s?.clientSecretConfigured&&!t.forgetSecret?{clientSecret:!0}:{},...r.length?{scopes:r}:{}}}function ti(t,s){const o=t.name.trim();if(t.transport==="remote"){const l=t.url.trim();if(!o||!/^https?:\/\/\S+$/i.test(l))return{ok:!1,error:{key:"mcp.err.nameAndUrl"}};if(fn(l))return{ok:!1,error:{key:"mcp.paste.urlMissing"}};const b=Dn(t.headers,"header");if(!b.ok)return b;const f=ei({clientId:t.oauthClientId,clientSecret:t.oauthClientSecret,scopes:t.oauthScopes,forgetSecret:t.oauthForgetSecret},s&&pe(s)?s.oauth:void 0);return{ok:!0,body:{type:t.type,url:l,headers:b.values,...f?{oauth:f}:{}}}}const c=t.command.trim();if(!o||!c)return{ok:!1,error:{key:"mcp.err.nameAndCommand"}};const r=Dn(t.env,"env");return r.ok?{ok:!0,body:{command:c,args:Xa(t.args),env:r.values}}:r}function Hn(t){if(t.transport!=="remote"||t.oauthClientId.trim())return null;const s=t.headers.filter(o=>o.name.trim());return s.length===1&&cn(s[0]).trim()||null}function ni(t){return n(t.kind==="variable"?"mcp.paste.variable":"mcp.paste.placeholder",{name:t.names.join(", ")})}const Qn="w-full min-w-0 rounded-lg border border-hairline/60 bg-raised px-3 py-2.5 font-mono text-[12px] text-ink outline-none focus:border-accent";function Ve({kind:t,rows:s,onChange:o,valuesOf:c,placeholder:r}){const l=(p,m)=>o(s.map(j=>j.id===p?{...j,...m}:j)),b=t==="header"?":":"=",f=(p,m)=>{const j=m.clipboardData.getData("text"),D=j.indexOf(b);D<=0||(m.preventDefault(),l(p.id,{name:j.slice(0,D).trim(),value:j.slice(D+1).trim()}))},y=p=>e.jsx("input",{type:"password","aria-label":p.name.trim()||n("mcp.row.value"),value:p.value,autoComplete:"new-password",spellCheck:!1,placeholder:r??(p.saved?n("mcp.oauth.secretSaved"):n("mcp.row.value")),onChange:m=>l(p.id,{value:m.target.value}),className:Qn});return e.jsxs("div",{className:"space-y-2",children:[s.filter(p=>c==="gaps"?p.gap:c==="named"?p.name.trim():!0).map(p=>e.jsxs("div",{children:[c?e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1.5 block font-mono text-[12px] font-medium text-ink-secondary",children:p.name}),y(p)]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{"aria-label":n(t==="header"?"mcp.row.headerName":"mcp.row.envName"),value:p.name,spellCheck:!1,autoComplete:"off",placeholder:t==="header"?"Authorization":"API_KEY",onChange:m=>l(p.id,{name:m.target.value}),onPaste:m=>f(p,m),className:`${Qn} max-w-[42%]`}),y(p),e.jsx("button",{type:"button","aria-label":n("mcp.row.remove",{name:p.name.trim()||n("mcp.row.value")}),onClick:()=>o(s.length>1?s.filter(m=>m.id!==p.id):[Be()]),className:"shrink-0 rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(ns,{size:14})})]}),p.gap&&!p.value.trim()&&e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-warning",children:ni(p.gap)})]},p.id)),!c&&e.jsxs("button",{type:"button",onClick:()=>o([...s,Be()]),className:"inline-flex items-center gap-1 rounded-lg px-1 py-1 text-[12px] font-medium text-accent hover:underline",children:[e.jsx(ds,{size:13})," ",n("mcp.row.add")]})]})}const Te="mt-1.5 w-full rounded-lg border border-hairline/60 bg-raised px-3 py-2.5 text-[13px] text-ink outline-none focus:border-accent",Ce="text-[12px] font-medium text-ink-secondary";function si(t){if(t.transport==="stdio")return t.command;try{return new URL(t.url).host}catch{return t.url}}function ai({server:t,fixKeys:s=!1,taken:o,team:c,busy:r,onCancel:l,onSubmit:b}){const f=!t,[y,p]=d.useState(""),[m,j]=d.useState(()=>t?[qa(t)]:[]),[D,R]=d.useState(null),B=s&&t!==void 0&&pe(t),[H,F]=d.useState(!f&&!B),[v,E]=d.useState(!1),[C,Z]=d.useState(null),w=m.length===1?m[0]:null,V=k=>j(g=>g.length===1?[k(g[0])]:g),Q=t&&pe(t)?t.oauth:void 0,he=!!(Q?.clientSecretConfigured&&!w?.oauthForgetSecret),ee=c&&f&&w!==null&&Hn(w)!==null,te=k=>{p(k),Z(null);const g=Ia(k,o);R(g&&!g.ok?g.error:null),j(z=>g?.ok?g.servers.map(Wa):H?z.length===1?z:[Ye()]:[])},ye=()=>{const k=[];for(const g of m){const z=Va(g.resultBudget,()=>ti(g,t));if(!z.ok){Z(z.error);return}const T=ee&&v?Hn(g):null;k.push({name:g.name.trim(),body:z.body,...T?{ownKey:T}:{}})}Z(null),b(k)},Y=!H&&m.some(k=>k.urlGap||k.headers.some(g=>g.gap)||k.env.some(g=>g.gap));return e.jsxs("div",{"data-mcp-editor":!0,className:"mt-4 rounded-2xl border border-hairline/60 bg-card p-4 sm:p-5",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:f?n("mcp.editorNew"):n(B?"mcp.fixKeys.title":"mcp.editorEdit",{name:t.name})}),B&&w&&!H&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[12px] leading-relaxed text-ink-secondary",children:n("mcp.fixKeys.hint")}),w.headers.some(k=>k.name.trim())?e.jsx(Ve,{kind:"header",valuesOf:"named",placeholder:n("mcp.fixKeys.placeholder"),rows:w.headers,onChange:k=>V(g=>({...g,headers:k}))}):e.jsx(Ve,{kind:"header",rows:w.headers,onChange:k=>V(g=>({...g,headers:k}))})]}),f&&e.jsxs("label",{className:"mt-3 block",children:[e.jsx("span",{className:"text-[13px] text-ink",children:n("mcp.paste.prompt")}),e.jsx("textarea",{autoFocus:!0,"aria-label":n("mcp.paste.label"),value:y,onChange:k=>te(k.target.value),spellCheck:!1,rows:3,placeholder:"https://mcp.example.com/mcp",className:"mt-2 w-full resize-y rounded-lg border border-hairline/60 bg-raised px-3 py-2.5 font-mono text-[12px] leading-relaxed text-ink outline-none focus:border-accent"})]}),D&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] leading-relaxed text-danger",children:n(D)}),f&&y.trim()&&m.length>0&&!D&&e.jsx("p",{role:"status",className:"mt-2 text-[12px] text-ink-secondary",children:w?n("mcp.paste.foundOne",{name:w.name,where:si(w)}):n("mcp.paste.foundMany",{count:m.length,names:m.map(k=>k.name).join(", ")})}),Y&&e.jsx("div",{className:"mt-3 space-y-3",children:m.map((k,g)=>e.jsxs("div",{className:"space-y-3",children:[m.length>1&&(k.urlGap||k.headers.some(z=>z.gap)||k.env.some(z=>z.gap))&&e.jsx("div",{className:"text-[12px] font-medium text-ink",children:k.name}),k.urlGap&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.field.url")}),e.jsx("input",{value:k.url,spellCheck:!1,onChange:z=>j(T=>T.map((K,U)=>U===g?{...K,url:z.target.value}:K)),className:Te}),e.jsx("span",{className:"mt-1 block text-[11px] text-warning",children:n("mcp.paste.urlMissing")})]}),e.jsx(Ve,{kind:"header",valuesOf:"gaps",rows:k.headers,onChange:z=>j(T=>T.map((K,U)=>U===g?{...K,headers:z}:K))}),e.jsx(Ve,{kind:"env",valuesOf:"gaps",rows:k.env,onChange:z=>j(T=>T.map((K,U)=>U===g?{...K,env:z}:K))})]},g))}),(f||B)&&m.length<=1&&e.jsxs("button",{type:"button","aria-expanded":H,onClick:()=>{F(!H),m.length||j([Ye()])},className:"mt-3 inline-flex items-center gap-1 text-[12px] font-medium text-ink-secondary hover:text-ink",children:[H?e.jsx(ss,{size:14}):e.jsx(us,{size:14})," ",n("mcp.details")]}),H&&w&&e.jsxs("div",{className:"mt-3",children:[f&&e.jsx("div",{className:"inline-flex rounded-lg bg-raised p-0.5",role:"radiogroup","aria-label":n("mcp.field.type"),children:["remote","stdio"].map(k=>e.jsx("button",{type:"button",role:"radio","aria-checked":w.transport===k,onClick:()=>V(g=>({...g,transport:k})),className:q("rounded-md px-3 py-1.5 text-[12px] font-medium transition-colors",w.transport===k?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:n(k==="stdio"?"mcp.transport.stdio":"mcp.transport.remote")},k))}),e.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.field.name")}),e.jsx("input",{disabled:!f,value:w.name,maxLength:32,placeholder:"github",className:q(Te,"disabled:opacity-60"),onChange:k=>V(g=>({...g,name:k.target.value.toLowerCase()}))})]}),w.transport==="remote"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.field.url")}),e.jsx("input",{autoFocus:!f,value:w.url,spellCheck:!1,placeholder:"https://mcp.example.com/mcp",className:Te,onChange:k=>V(g=>({...g,url:k.target.value}))}),w.urlGap&&e.jsx("span",{className:"mt-1 block text-[11px] text-warning",children:n("mcp.paste.urlMissing")})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.field.type")}),e.jsxs(Es,{className:"mt-1.5 w-full",value:w.type,onChange:k=>V(g=>({...g,type:k.target.value==="sse"?"sse":"http"})),children:[e.jsx("option",{value:"http",children:n("mcp.type.http")}),e.jsx("option",{value:"sse",children:n("mcp.type.sse")})]})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("div",{className:q(Ce,"mb-1.5"),children:n("mcp.field.headerRows")}),e.jsx(Ve,{kind:"header",rows:w.headers,onChange:k=>V(g=>({...g,headers:k}))}),e.jsx("span",{className:"mt-1.5 block text-[11px] text-ink-secondary",children:n("mcp.headersHint")})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink",children:n("mcp.oauth.title")}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-ink-secondary",children:Q?n("mcp.oauth.hintRedirect",{uri:Q.redirectUri}):n("mcp.oauth.hint")}),e.jsxs("div",{className:"mt-2 grid gap-4 sm:grid-cols-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.oauth.clientId")}),e.jsx("input",{value:w.oauthClientId,spellCheck:!1,autoComplete:"off",className:q(Te,"font-mono text-[12px]"),onChange:k=>V(g=>({...g,oauthClientId:k.target.value}))})]}),e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2 text-[12px] font-medium text-ink-secondary",children:[n("mcp.oauth.clientSecret"),he&&e.jsx("button",{type:"button",onClick:()=>V(k=>({...k,oauthClientSecret:"",oauthForgetSecret:!0})),className:"text-[11px] font-normal text-ink-secondary underline-offset-2 hover:text-ink hover:underline",children:n("mcp.oauth.removeSecret")})]}),e.jsx("input",{type:"password",value:w.oauthClientSecret,autoComplete:"new-password",className:q(Te,"font-mono text-[12px]"),placeholder:he?n("mcp.oauth.secretSaved"):n("mcp.oauth.secretOptional"),onChange:k=>V(g=>({...g,oauthClientSecret:k.target.value}))})]}),e.jsxs("label",{className:"block sm:col-span-2",children:[e.jsx("span",{className:Ce,children:n("mcp.oauth.scopes")}),e.jsx("input",{value:w.oauthScopes,placeholder:"offline_access api://my-app/mcp.read",spellCheck:!1,className:q(Te,"font-mono text-[12px]"),onChange:k=>V(g=>({...g,oauthScopes:k.target.value}))})]})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.field.command")}),e.jsx("input",{autoFocus:!f,value:w.command,placeholder:"npx",className:Te,onChange:k=>V(g=>({...g,command:k.target.value}))})]}),e.jsxs("label",{className:"block sm:col-span-2",children:[e.jsx("span",{className:Ce,children:n("mcp.field.args")}),e.jsx("textarea",{value:w.args,placeholder:`-y
|
|
8
|
-
@modelcontextprotocol/server-github`,rows:4,className:q(Te,"resize-y font-mono text-[12px]"),onChange:k=>V(g=>({...g,args:k.target.value}))})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("div",{className:q(Ce,"mb-1.5"),children:n("mcp.field.envRows")}),e.jsx(Ve,{kind:"env",rows:w.env,onChange:k=>V(g=>({...g,env:k}))})]})]}),e.jsx(Ga,{value:w.resultBudget,onChange:k=>V(g=>({...g,resultBudget:k}))})]})]}),c&&f&&m.length>0&&e.jsxs("div",{"data-mcp-team-scope":!0,className:"mt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-lg bg-raised/50 px-3 py-2 text-[12px]",children:[e.jsx("span",{className:"text-ink-secondary",children:n(ee&&v?"mcp.team.onlyMeOn":"mcp.team.everyone")}),ee&&e.jsxs("label",{className:"flex items-center gap-1.5 text-ink",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:k=>E(k.target.checked)})," ",n("mcp.team.onlyMe")]})]}),C&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:n(C.key,C.params)}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:l,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:n("mcp.cancel")}),e.jsxs("button",{type:"button",disabled:r||!m.length,onClick:ye,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3.5 py-2 text-[13px] font-medium text-white disabled:opacity-50",children:[r&&e.jsx(ie,{size:13,className:"animate-spin"})," ",n(f?"mcp.add":"mcp.save")]})]})]})}const ii="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaEAAAGhCAMAAAD/dvvwAAACf1BMVEX////6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6Rhb6RhYZ6Qt0AAAA1XRSTlMAFThdfpaqwNbl8P/74dKwjmxDDgsvUXWMpLjM4Oz4/OLYtpRyTRg9X4CXq8LX5vH60K5qPgVilcj+1Z0iVYi7qW4jBzVom83z/dGZWREEOny/JiisjTsBBj/EdyEPrfRpR5jk3BRjtPbBDGH5ni0CSKPvuRC+JySE1GREpgllQGCC69oZi7UuF2eQ915m6CztJc57HaUTRXDKA0IaU+dYS3axTuq9N1Leicm3w8+i0xLZvAoxMoZzcRxP9VRaFjxbDVaDKcayTFwgnOma43i6CEF6bTOoblYlAAAHlElEQVR4AezBxQECMBAAsOJwh7s73X9ExugnSQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoJFOt9cfDEfjSURmTmM2XyxX601pabvbH46n8+V6i3vmI56v9+f7q6Wp+meuHhQrZ+IogJ81ztq2dbP12qjdpLaxtm3bts267/XZuDeTzEz6e4DBnxMnTZ4yddr0GV19JI2uw2YGDQoO6QeFQvuHhUf4+J9mzZ4zqQ08MHfe/AVd+N+GLVy0GB5YsnTZ8hUr+Z8io6JjYqFAXHxC4gj6NysiIQk6JQenDGcAo1PTTGhkpU/OMOhf5LTMLEiV3S4nl/ZE5MVCi9D8gkLaU9Q+C3oUl5SW0Z7ysL6QpKJySDcKqKqugWqrVq9ZSxHr8k2otj5vQyQFlE3ZCPfMidW5FLYgHypt2lxIYVu2WlBo1bbtIyhqVmk63NmxcwudidgFRcz8dXRm2O44KFLRu4jObGgL54r37KVznZZCAWvrFjq3b54JBfYf6ErnDh5ymp/5uXRlVvVhSBZ3ZBTdKe8vPz9Hj9GVkWNjIa5ici5d842Lg0SrjhfRtZHh6yFTbK9jdG34CRNiVoWdpBRDT0GaiUMpRZfxkCZu0WlK0ekMRKSdpSxV50IhxfmplObCRchxaTplKbu8CnZlF8yiRFcWw72ri1ZSohnXIEGbwZQp8TrsuXGTcvluwa2aK5QrcnMc3Np9mnINvw0b1q+hfMuXwI1Vd6ooXcZ+uNLmLuVLvYpAro2iChFuwpE1jSrcbAsX7t2nCg8uwq+rm2dRjZsP4dQjH9WoqoRT1lEq8vgQ/JiQSGWq5qmPhbAnJhzJukJlclfjf6WdpEKzLsOB60+p0mALDqxeS4W67cb/2GlQrVQTotrepFoLsiFsYCTVOof/cjWcyk0xIWZSFVV7KpqiJReo3Hz8W8UzalB9FQLMPRSlPkUXn1OchAV5/QW1uHAVtlkvqcWr17Bv7htqEY6/SxpFTabArn5vqcnTd7Dr/V5qshl/9WEvtfkIe4qfUpu3FuwJ8VGbT/jTLh81+gw7vmyhRjmrYMf4Mmq0G7+7VEadIr8isDb7qNUT2HDPoE5Gujf3kt/eB07QK2oWhoC+G9TrdBJ+VmtQt8K6VpcgGvUIoCGSur1p9OZe8u1V+JM9k/rNqBNOkHopQFMkvdDsN0FP6YUHV4UTpN5lPKcn9lmtLkEsa2l9CeIaj8JR9OVH9u5BV7IsDKDwHjueYGzbtm172rbdYdu2bdt29/u0ouafunX3qVo3WesRzhecbSDQeCDQyHFnPggLaPlOgc4DOkOEAmov0AVAp4k+FggJdO24jKMPgfK365eUAiICkEABEQFIoICIACRQQAQBEigmEggAFBMJNP1uAFBAJNAzAKCASCAAUEAkEAAoIBIIABQQCQQAiokEAgDFRAIBgGIigQBAMZFAAKCYSCAAUEwkEAAoJhIIABQQCQQAiokEAgDFRAIBgGIigQBAMZFAAKCYSCAAUEwkEAAoJhIIABQTCQQAiokEAgDlJroHCPTMbixQ5Yn+7wgEmg4FykkkEAAoJhIIABQTCQQAiokEAgDFRAIBgGKi8oF+WSZQDFQ8UQy0S6AAKA+RQACgmEggAFBMJBAAKCYSCAAUEi0ViAAUtLaeQFyggEggAlBAVOeAxqOB8hPVPaBGN1Wl+XmBAiKByqr98pQqTyQQAyggEogAFBAJRAAKiAQiAAVEAhGAAiKBCEABkUAIoIDoPYGgQHECCSSQQAIJJJBAAgkkkEACCSSQQAIJlKGbBWIDfbpFoNK6XyAiULzVUSCJBCqfSCCJBCqH6A6Blid0Hf8XKEkkUH4igWBEAkkkEJxIIDiRQHAigeBEAsGJQqArBao6UQg062mBiicSiE8kEJ9IID6RQHwigfhEAvGJBOITsYF+OwMkERdo3p8pSSQQn0ggPpFAcCKB4EQCwYkEghMJBCcSCE4kEJxIIDiRQHSiAQKxif4RiE0kEJxIIDiRQHAigeBEApGJBOITCQQnEghOJBCEaIZA8Fr0EYhPJBCfSCA+kUB8IoHQRCUC3Vp9IIn+KVVSoMoTCcQnEohOJBCcSCA40Ut1F8gEEkgggQQSSCATSCCBBOInkEACCfSsQGygxVckEwiQQAoJBCASSKIMQBIJJFEGIIkEkkigcokEkqi2QBIJJJFAcCKB4EQCoYkEAhAJBCASCEA0oxCgeaOSkR+wbvxnsmyNeDY70A/dk2Vs632Zgeb+nCxr497K6bN+T7LsrbsxG1DfFqmAbG/jTED7mqRCspZT78rgs396Kiz7bmatgQ58mQrMft54sFY+t/+UCs66f/NJ2T637Pk5FZ/V731jWT73fPhLssrU7tDBGvssfESfSvbVm4dfrQFP/24PJ6t0a4cvLI3n05kD/0xVyd5bc7jRTXFDrn1pSapiduTosV2TLqNTr9vxEy2TAVrywsBVI6/r/NTfZ2GePvjs4eaPPvKBczun2oNjAQAAAIBB/taz2FUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJcA09LUTxlsWtoAAAAASUVORK5CYII=",Oe="postiz",lt="https://api.postiz.com",oi="https://platform.postiz.com/settings";function ci(t){if(!t||typeof t!="object")return!1;const s=t;return typeof s.state=="string"&&typeof s.address=="string"&&typeof s.host=="string"&&(s.how===null||s.how==="sign-in"||s.how==="key")}const mt=[{id:"whop",label:"Whop",url:"https://mcp.whop.com/mcp",icon:{image:ii},description:"whop.description",notice:"whop.notice",keywords:"whop checkout memberships"},{id:"agentcard",label:"Agentcard",url:"https://mcp.agentcard.sh/mcp",icon:{glyph:zs},description:"agentcard.description",notice:"agentcard.notice",keywords:"agentcard agent card opencommerce shopping payments buy virtual debit card"},{id:"agentmail",label:"AgentMail",url:"https://mcp.agentmail.to/mcp",icon:{glyph:Is},description:"agentmail.description",notice:"agentmail.notice",keywords:"agentmail email inbox mail address send reply"},{id:"vapi",label:"Vapi",url:"https://mcp.vapi.ai/mcp",key:{url:"https://dashboard.vapi.ai"},icon:{glyph:xa},description:"vapi.description",notice:"vapi.notice",keywords:"vapi phone call calls voice dial assistant"},{id:"telnyx",label:"Telnyx",url:"https://api.telnyx.com/v2/mcp",key:{url:"https://portal.telnyx.com/#/api-keys"},icon:{glyph:ga},description:"telnyx.description",notice:"telnyx.notice",keywords:"telnyx phone number numbers sms text call calls international"},{id:"agentphone",label:"AgentPhone",url:"https://mcp.agentphone.ai/mcp",icon:{glyph:ca},description:"agentphone.description",notice:"agentphone.notice",keywords:"agentphone phone number sms text call calls"}];function bn(t){if(t.type!=="http"||!t.url)return;let s;try{s=new URL(t.url)}catch{return}if(!(s.search||s.hash||s.username||s.password))return mt.find(o=>{const c=new URL(o.url);return s.origin===c.origin&&(s.pathname===c.pathname||s.pathname===`${c.pathname}/`)})}function _n(t,s){const o=new Set(s.map(r=>r.name));let c=t.id;for(let r=2;o.has(c);r++)c=`${t.id}-${r}`;return c}const fs="Authorization";function ri(t){const s=o=>o.headerKeys?.some(c=>c.toLowerCase()===fs.toLowerCase())===!0;return Object.fromEntries(mt.map(o=>[o.id,t.some(c=>bn(c)===o&&c.enabled&&("key"in o?s(c):c.auth==="signed-in"))]))}function rn(t){return t.url===void 0||!(bn(t)||t.name===Oe)}function gs(t){return t.enabled&&t.auth!=="needs-sign-in"}const bs=128;function li(t,s=bs){return t>=s?"exceeds":t*2>=s?"crowds":"fits"}const di=1500;async function Et(t,s,o){try{return await s(`/api/mcp/servers/${encodeURIComponent(t)}/test`,{method:"POST",signal:o})}catch(c){if(o?.aborted)throw c;return{ok:!1,error:c instanceof Error?c.message:String(c),reason:"unreachable"}}}async function Jn(t,s,o,c,r="hostedMcp.testFailed"){const l=await Et(t,s,o);if(l.ok)return l;const b=(l.error??"").trim();return{...l,error:n(r,{service:c,reason:b&&!/[.!?]$/.test(b)?`${b}.`:b})}}function Vn(t,s){if(s.reason!=="keys"||!pe(t))return s.error??"";const o=s.status?`HTTP ${s.status}`:n("mcp.check.unauthorized");return t.headerKeys.length?n("mcp.check.keysRefused",{reason:o,names:new Intl.ListFormat(xt(),{style:"long",type:"conjunction"}).format(t.headerKeys)}):n("mcp.check.keysNeeded",{reason:o})}function ui(t){const s=Math.max(t.total??0,t.tools?.length??0);if(!s)return n("mcp.check.connectedNone");const o=s===1?n("mcp.check.connectedOne"):n("mcp.check.connectedMany",{count:s}),c=li(s);return c==="fits"?o:`${o}. ${n(c==="exceeds"?"mcp.check.overLimit":"mcp.check.crowdsLimit",{count:s,limit:bs})}`}function Gn({embedded:t=!1,hostedCards:s,hideHosted:o=!1,refreshKey:c=0}={}){const{state:r,dispatch:l}=Xe(),b=a=>r.bots?.find(u=>u.id===a)?.name??a,f=r.config?.managedPolicy,y=!!(f&&!f.mcp.allowCustom),[p,m]=d.useState(null),[j,D]=d.useState(null),[R,B]=d.useState(null),[H,F]=d.useState(null),[v,E]=d.useState(null),[C,Z]=d.useState({}),[w,V]=d.useState(null),Q=d.useRef(null),he=d.useRef(null),[ee,te]=d.useState(null),[ye,Y]=d.useState(""),[k,g]=d.useState(null),[z,T]=d.useState(!1),[K,U]=d.useState(!1),X=d.useRef({}),[Pe,Me]=d.useState(null),[Le,we]=d.useState(null),[Re,Ue]=d.useState({}),se=d.useRef(0),W=d.useRef(!0),fe=a=>pe(a)?bn(a):void 0,G=d.useMemo(()=>p&&ri(p),[p]),ke=s?.onConnections;d.useEffect(()=>{G&&ke?.(G)},[G,ke]);const $e=s?.onServers;d.useEffect(()=>{p&&$e?.(p)},[p,$e]);const ce=a=>(m(a??[]),qt(a??[]),a??[]),je=a=>Z(u=>{const x={...u};return delete x[a],x}),Ne=d.useCallback(()=>{const a=++se.current;return B("load"),F(null),A("/api/mcp/servers").then(u=>{a===se.current&&(m(u.servers??[]),qt(u.servers??[]))}).catch(u=>{a===se.current&&F(u instanceof Error?u.message:String(u))}).finally(()=>{a===se.current&&B(null)})},[]);d.useEffect(()=>(W.current=!0,Ne(),()=>{W.current=!1,se.current+=1}),[Ne,c]);const I=d.useRef(null);I.current=R,d.useEffect(()=>{const a=()=>{if(I.current!==null)return;const u=se.current;A("/api/mcp/servers").then(x=>{!W.current||I.current!==null||u!==se.current||(m(x.servers??[]),qt(x.servers??[]))}).catch(()=>{})};return Ts({onFrame:u=>{u.kind==="mcp.changed"&&a()},onMissedFrames:a})},[]);const P=()=>{D(null),U(!1)},re=(a,u=!1)=>{D(a),U(u),F(null),E(null)},ae=async(a,u=!1)=>{B(`test:${a}`),Me(a),se.current+=1,je(a);let x=await Et(a,A);if(x.ok)try{ce((await A(`/api/mcp/servers/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})).servers),X.current[a]=Date.now()}catch(h){x={ok:!1,error:h instanceof Error?h.message:String(h)}}return u&&(x={...x,saved:!0}),W.current&&(Z(h=>({...h,[a]:x})),B(null),Me(null)),x},ue=async a=>{B("save"),se.current+=1,F(null),E(null);const u=[];let x=p??[];try{for(const h of a){const $=h.ownKey?{...h.body,headers:Object.fromEntries(Object.keys(h.body.headers??{}).map(S=>[S,""]))}:h.body;x=ce((await A("/api/mcp/servers",{method:"POST",body:JSON.stringify({name:h.name,...$})})).servers),h.ownKey&&(await A("/api/team/connection-scopes",{method:"PUT",body:JSON.stringify({kind:"mcp",id:h.name,scope:"person"})}),await A(`/api/team/my-connections/mcp/${encodeURIComponent(h.name)}/key`,{method:"PUT",body:JSON.stringify({value:h.ownKey,url:$.url})}),x=ce((await A(`/api/mcp/servers/${encodeURIComponent(h.name)}`,{method:"PUT",body:JSON.stringify({...$,enabled:!1})})).servers)),u.push(h.name)}}catch(h){F(h instanceof Error?h.message:String(h))}B(null),u.length&&P();for(const h of u){const $=await ae(h,!0),S=x.find(ne=>ne.name===h);$.auth==="required"&&S&&u.length===1&&W.current&&await Ee(S)}},le=async([a])=>{const u=p?.find(x=>x.name===j);if(!(!a||!u)){B("save"),se.current+=1,F(null),E(null);try{let x=a.body,h;if(r.config?.team&&u.scope!=="team"&&typeof x.url=="string"&&!x.oauth&&(await A("/api/team/my-connections")).mcp.some(S=>S.name===a.name)){const S=x.headers??{};if(Object.keys(S).length>1)throw new Error(n("mcp.personal.oneHeader"));const ne=Object.values(S)[0];h=typeof ne=="string"?ne:void 0,x={...x,headers:Object.fromEntries(Object.keys(S).map(oe=>[oe,""]))}}ce((await A(`/api/mcp/servers/${encodeURIComponent(a.name)}`,{method:"PUT",body:JSON.stringify({...x,enabled:u.enabled})})).servers),h&&await A(`/api/team/my-connections/mcp/${encodeURIComponent(a.name)}/key`,{method:"PUT",body:JSON.stringify({value:h,url:x.url})}),P()}catch(x){F(x instanceof Error?x.message:String(x)),B(null);return}B(null),u.runsOn||await ae(a.name,!0)}},Se=async a=>{if(a.enabled&&Date.now()-(X.current[a.name]??0)<di){E({key:"mcp.switchedOnByTest",params:{name:a.name}});return}B(`toggle:${a.name}`),se.current+=1,F(null);try{ce((await A(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!a.enabled})})).servers),E({key:"mcp.toggled",params:{name:a.name},stateKey:a.enabled?"mcp.state.off":"mcp.state.on"})}catch(u){F(u instanceof Error?u.message:String(u))}finally{B(null)}},xe=async a=>{B(`test:${a.name}`),se.current+=1,F(null),je(a.name);const u=await Et(a.name,A);Z(x=>({...x,[a.name]:u})),B(null)};async function Ee(a){const u=zt(),x=new AbortController;Q.current=x,V(a.name),te(null),Y(""),g(null),F(null),we(null),E(null),je(a.name);const h=fe(a);try{const $=async ne=>{!await u.open(ne)&&W.current&&!x.signal.aborted&&g(n("connectors.card.popupBlocked"))},S=await as(a.name,{api:A,open:$,signal:x.signal,onStarted:(ne,oe)=>{te(ne),he.current=oe}});if(!W.current||x.signal.aborted)return;if(S.phase==="succeeded"){te({...S,flowId:null,authorizationUrl:null});const ne=h?await Jn(a.name,A,x.signal,h.label):await Et(a.name,A,x.signal);if(x.signal.aborted||!W.current||(Z(De=>({...De,[a.name]:ne})),!ne.ok))return;const oe=await A(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!0})});if(!W.current)return;ce(oe.servers),h&&E({key:"hostedMcp.connected",params:{service:h.label}})}else S.phase!=="cancelled"&&Z(ne=>({...ne,[a.name]:{ok:!1,error:S.message||n("mcp.auth.failed")}}))}catch($){W.current&&!x.signal.aborted&&Z(S=>({...S,[a.name]:{ok:!1,error:$ instanceof Error?$.message:String($)}}))}finally{u.cancel(),Q.current===x&&(Q.current=null,he.current=null,T(!1),V(null),te(null),Y(""),g(null),W.current&&Ne())}}const et=async a=>{if(!p||R!==null||w!==null)return;const u=p.find(h=>fe(h)===a);if("key"in a){await tt(a,u);return}if(u){await Ee(u);return}B(`hosted:${a.id}`),se.current+=1,F(null),we(null),E(null);let x;try{const h=_n(a,p),$=await A("/api/mcp/servers",{method:"POST",body:JSON.stringify({name:h,type:"http",url:a.url,enabled:!1})});if(!W.current)return;if(x=ce($.servers).find(S=>S.name===h&&fe(S)===a),!x)throw new Error(n("hostedMcp.setupFailed",{service:a.label}))}catch(h){W.current&&we({id:a.id,message:h instanceof Error?h.message:String(h)})}finally{W.current&&B(null)}x&&W.current&&await Ee(x)},tt=async(a,u)=>{const x=Re[a.id]?.trim();if(!p||!x)return;B(`hosted:${a.id}`),se.current+=1,F(null),we(null),E(null);const h=u?.name??_n(a,p);je(h);try{const $={type:"http",url:a.url,headers:{[fs]:`Bearer ${x}`},enabled:!1};ce((await A(u?`/api/mcp/servers/${h}`:"/api/mcp/servers",{method:u?"PUT":"POST",body:JSON.stringify(u?$:{name:h,...$})})).servers);const S=await Jn(h,A,void 0,a.label,"hostedMcp.keyTestFailed");if(!W.current||(Z(ne=>({...ne,[h]:S.reason==="keys"?{...S,error:n("hostedMcp.keyRefused",{service:a.label})}:S})),!S.ok))return;ce((await A(`/api/mcp/servers/${h}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})).servers),Ue(ne=>({...ne,[a.id]:""})),E({key:"hostedMcp.connected",params:{service:a.label}})}catch($){W.current&&we({id:a.id,message:$ instanceof Error?$.message:String($)})}finally{W.current&&B(null)}},gt=async()=>{if(!w||!ee?.flowId||z)return;const a=Q.current;T(!0),g(null);try{const u=await is(w,ee.flowId,ye,A);Q.current===a&&he.current?.(u)}catch(u){Q.current===a&&g(u instanceof Error?u.message:String(u))}finally{Q.current===a&&T(!1)}},Fe=async(a,u)=>{B(`signout:${a.name}`),se.current+=1,F(null),we(null),E(null),je(a.name);try{if(u&&"key"in u){ce((await A(`/api/mcp/servers/${a.name}`,{method:"DELETE"})).servers);return}fe(a)&&ce((await A(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!1})})).servers),ce((await A(`/api/mcp/servers/${a.name}/sign-out`,{method:"POST"})).servers)}catch(x){const h=x instanceof Error?x.message:String(x);u?we({id:u.id,message:h}):F(h)}finally{B(null)}};d.useEffect(()=>()=>Q.current?.abort(),[]);const be=async a=>{if(window.confirm(n("mcp.removeConfirm",{name:a.name}))){B(`delete:${a.name}`),se.current+=1,F(null);try{ce((await A(`/api/mcp/servers/${a.name}`,{method:"DELETE"})).servers),je(a.name),j===a.name&&P()}catch(u){F(u instanceof Error?u.message:String(u))}finally{B(null)}}},Ke=j&&j!=="new"?p?.find(a=>a.name===j):void 0;function bt(a){return e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"mt-3 block",htmlFor:`mcp-callback-${a.name}`,children:n("mcp.auth.callbackUrl")}),e.jsx("input",{id:`mcp-callback-${a.name}`,type:"text",value:ye,disabled:z,onChange:u=>Y(u.target.value),autoComplete:"off",spellCheck:!1,placeholder:"http://127.0.0.1:…/mcp-oauth/callback?…",className:"mt-1 w-full rounded-lg border border-hairline bg-inset px-3 py-2 text-ink outline-none focus:border-accent"}),e.jsxs("button",{type:"button",disabled:!ye.trim()||z,"aria-busy":z,onClick:()=>{gt()},className:"mt-2 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 font-medium text-white disabled:opacity-40",children:[z&&e.jsx(ie,{size:14,className:"animate-spin","aria-hidden":"true"}),n(z?"mcp.auth.completing":"mcp.auth.complete")]})]})}function nt(a){const u=fe(a);return w===a.name&&e.jsxs("div",{className:"mt-3 space-y-3 rounded-lg bg-raised px-3 py-3 text-[12px] text-ink-secondary",children:[e.jsxs("div",{role:"status",className:"flex items-center gap-2",children:[e.jsx(ie,{size:13,className:"animate-spin"})," ",ee?.phase!=="succeeded"?n("mcp.auth.waiting"):u?n("hostedMcp.loadingTools",{service:u.label}):n("mcp.auth.loadingTools")]}),ee?.authorizationUrl&&It(ee.authorizationUrl)&&e.jsx("button",{type:"button",onClick:()=>{g(null),tn(ee.authorizationUrl).catch(()=>g(n("mcp.auth.openFailed")))},className:"text-accent hover:underline",children:n("mcp.auth.openAgain")}),ee?.flowId&&(ee.pasteBack?e.jsxs("div",{children:[e.jsx("p",{className:"leading-relaxed text-ink",children:n("mcp.auth.pasteBackHint")}),bt(a)]}):e.jsxs("details",{children:[e.jsx("summary",{className:"cursor-pointer font-medium text-ink",children:n("mcp.auth.otherComputer")}),e.jsx("p",{className:"mt-2 leading-relaxed",children:n("mcp.auth.otherComputerHint")}),bt(a)]})),k&&e.jsx("p",{role:"alert",className:"text-danger",children:k})]})}function Mt(a){const u=p?.find(oe=>fe(oe)===a),x=!!G?.[a.id],h=u&&C[u.name],$=H||(Le?.id===a.id?Le.message:null)||(h&&!h.ok?h.error:null),S=R!==null||w!==null,ne=R===`hosted:${a.id}`||u!==void 0&&(w===u.name||R===`signout:${u.name}`);return e.jsxs("div",{"data-app-tile":a.id,className:"flex min-w-0 flex-col rounded-xl px-2 py-2 transition-colors hover:bg-raised/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Mn,{app:a}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold leading-5 text-ink",children:a.label}),x&&e.jsx(Ze,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")})]}),e.jsx("p",{className:"truncate text-[13px] leading-[18px] text-ink-secondary",title:n(a.description),children:n(a.description)})]}),u&&w===u.name?e.jsx("button",{type:"button",onClick:()=>Q.current?.abort(),className:"inline-flex h-7 shrink-0 items-center rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink",children:n("mcp.auth.cancel")}):e.jsx("button",{type:"button","aria-label":n(x?"hostedMcp.disconnect":"hostedMcp.connect",{service:a.label}),disabled:S||p!==null&&!x&&(!!u?.managedBy||y&&!f?.mcp.allowlist.length||"key"in a&&!Re[a.id]?.trim()),onClick:()=>{p===null?Ne():x&&u?Fe(u,a):et(a)},className:"inline-flex h-7 min-w-[64px] shrink-0 items-center justify-center gap-2 rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink hover:bg-raised-hover disabled:opacity-40",children:S&&(ne||R==="load")?e.jsx(ie,{size:14,className:"animate-spin"}):p===null?n("connectors.action.retry"):n(x?"connectors.disconnect":"connectors.action.connect")})]}),e.jsxs("div",{className:"ps-[52px]",children:["key"in a&&!x&&p!==null&&e.jsxs("div",{className:"mt-2 flex flex-col items-start gap-2",children:[e.jsx("input",{type:"password",value:Re[a.id]??"",disabled:S,autoComplete:"off",spellCheck:!1,"aria-label":n("hostedMcp.keyLabel",{service:a.label}),placeholder:n("hostedMcp.keyPlaceholder",{service:a.label}),onChange:oe=>{const De=oe.target.value;Ue(Ut=>({...Ut,[a.id]:De}))},onKeyDown:oe=>{oe.key==="Enter"&&et(a)},className:"h-8 w-full min-w-0 rounded-lg bg-inset px-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none focus:ring-1 focus:ring-accent/50"}),e.jsxs("button",{type:"button",onClick:()=>{tn(a.key.url)},className:"inline-flex items-center gap-1 text-[12px] font-medium text-accent-text hover:underline",children:[n("hostedMcp.getKey",{service:a.label}),e.jsx(mn,{size:11,"aria-hidden":"true"})]})]}),$&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:typeof $=="string"?$:n($.key,$.params)}),u&&nt(u),e.jsxs("details",{className:"mt-1 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer",children:n("hostedMcp.access")}),e.jsx("p",{className:"mt-2 leading-relaxed",children:n(a.notice)}),e.jsx("p",{className:"mt-2 leading-relaxed",children:n("hostedMcp.accessHint")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:(r.bots??[]).filter(oe=>!oe.hidden).map(oe=>e.jsx("button",{type:"button",onClick:()=>{l({type:"togglePlugins",open:!1}),en(l,"access",{botId:oe.id,page:"mcp"})},className:"rounded-lg bg-control px-2.5 py-1.5 text-ink hover:bg-raised-hover",children:n("hostedMcp.botSettings",{name:oe.name})},oe.id))})]})]})]})}function Lt(a,u){const x=pe(a)&&a.auth==="needs-sign-in",h=C[a.name],$=h&&!h.ok&&!h.auth?n("mcp.check.failed",{reason:Vn(a,h)}):null,S=x?n("mcp.auth.needsSignIn"):a.offFor?.length?n("mcp.offFor",{bots:a.offFor.map(b).join(", ")}):pe(a)?a.url:[a.command,...a.args].join(" ");return e.jsxs("div",{"data-app-tile":a.name,"data-mcp-tile":"",className:"flex min-w-0 flex-col rounded-xl px-2 py-2 transition-colors hover:bg-raised/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[8px] bg-raised text-ink-secondary",children:pe(a)?e.jsx(Rn,{size:19}):e.jsx(Wt,{size:19})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold leading-5 text-ink",children:a.name}),gs(a)&&e.jsx(Ze,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")})]}),e.jsx("p",{className:q("truncate text-[13px] leading-[18px]",x?"text-warning":"text-ink-secondary"),title:S,children:S})]}),w===a.name?e.jsx("button",{type:"button",onClick:()=>Q.current?.abort(),className:"inline-flex h-7 shrink-0 items-center rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink",children:n("mcp.auth.cancel")}):e.jsx("button",{type:"button",disabled:x&&(R!==null||w!==null||!!a.managedBy),onClick:()=>{x?Ee(a):u()},className:"inline-flex h-7 min-w-[64px] shrink-0 items-center justify-center rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink hover:bg-raised-hover disabled:opacity-40",children:n(x?"mcp.auth.signIn":"apps.mcp.manage")})]}),e.jsxs("div",{className:"ps-[52px]",children:[$&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:$}),nt(a)]})]},a.name)}if(s){const a=s.ownServers;return e.jsxs(e.Fragment,{children:[mt.map(u=>e.jsx("div",{className:s.shown(u.id)?"contents":"hidden",children:Mt(u)},u.id)),a&&p?.filter(u=>u.enabled&&rn(u)&&a.shown(u)).map(u=>Lt(u,a.manage))]})}const ze=p?.filter(a=>!o||rn(a));return e.jsx("section",{"data-mcp-servers":!0,"aria-labelledby":"mcp-servers-title",className:t?"":"min-h-0 flex-1 overflow-y-auto px-6 pb-7 pt-5 sm:px-8",children:e.jsxs("div",{className:t?"":"mx-auto max-w-[840px]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-[1_1_280px]",children:[e.jsx("h3",{id:"mcp-servers-title",className:"text-[15px] font-semibold text-ink",children:n("mcp.title")}),e.jsx("p",{className:"mt-1 max-w-[610px] break-words text-[13px] leading-relaxed text-ink-secondary",children:n("mcp.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{Ne()},disabled:R!==null,className:"rounded-lg p-2 text-ink-secondary transition-colors hover:bg-raised hover:text-ink disabled:opacity-40","aria-label":n("mcp.refreshAria"),children:e.jsx(nn,{size:16,className:q(R==="load"&&"animate-spin")})}),e.jsxs("button",{type:"button",disabled:R!==null||y&&!f?.mcp.allowlist.length,title:y&&f?n("policy.managedBy",{organization:f.organizationName}):void 0,onClick:()=>re("new"),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[e.jsx(ds,{size:14})," ",n(t?"apps.mcp.add":"mcp.addServer")]})]})]}),y&&f&&e.jsx("p",{role:"status",className:"mt-3 text-[13px] leading-relaxed text-ink-secondary",children:n("policy.mcpRestricted",{organization:f.organizationName})}),(j==="new"||Ke)&&e.jsx(ai,{server:Ke,fixKeys:K,taken:(p??[]).map(a=>a.name),team:!!r.config?.team,busy:R!==null,onCancel:P,onSubmit:a=>{j==="new"?ue(a):le(a)}},`${j}${K?":keys":""}`),H&&e.jsx("div",{role:"alert",className:"mt-3 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:typeof H=="string"?H:n(H.key,H.params)}),v&&e.jsx("div",{role:"status",className:"mt-3 rounded-lg bg-success/10 px-3 py-2 text-[12px] text-success",children:n(v.key,{...v.params,...v.stateKey?{state:n(v.stateKey)}:{}})}),e.jsx(Sa,{}),e.jsx("div",{className:"mt-4 rounded-xl border border-hairline/50 bg-raised/35 px-4 py-3 text-[12px] leading-relaxed text-ink-secondary",children:n("mcp.trustNotice")}),p===null?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(ie,{size:14,className:"animate-spin"})," ",n("mcp.loading")]}):ze?.length===0&&!j?e.jsxs("div",{className:"mt-5 flex min-h-32 flex-col items-center justify-center rounded-2xl border border-dashed border-hairline/60 text-center",children:[e.jsx("div",{className:"flex size-11 items-center justify-center rounded-xl bg-raised text-ink-secondary",children:e.jsx(Wt,{size:21})}),e.jsx("div",{className:"mt-3 text-[14px] font-medium text-ink",children:n("mcp.empty.title")}),e.jsx("div",{className:"mt-1 max-w-sm text-[13px] text-ink-secondary",children:n("mcp.empty.desc")})]}):e.jsx("div",{className:"mt-5 space-y-3",children:ze?.map(a=>{const u=fe(a),x=C[a.name],h=pe(a)?a.auth:void 0,$=pe(a)&&!a.runsOn&&(h==="needs-sign-in"||x?.auth==="required"||(!!u||!!a.oauth)&&h!=="signed-in");return e.jsxs("div",{"data-hosted-server":u?.id,className:"rounded-2xl border border-hairline/50 bg-card px-4 py-4 sm:px-5",children:[e.jsxs("div",{"data-mcp-row":!0,className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:q("flex size-10 shrink-0 items-center justify-center rounded-xl",a.enabled?"bg-success/10 text-success":"bg-raised text-ink-secondary"),children:u?e.jsx(Mn,{app:u}):pe(a)?e.jsx(Rn,{size:19}):e.jsx(Wt,{size:19})}),e.jsxs("div",{className:"min-w-0 flex-[1_1_220px]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[14px] font-medium text-ink",children:u?u.label:a.name}),e.jsx("span",{className:q("rounded-full px-2 py-0.5 text-[11px]",a.enabled?"bg-success/10 text-success":"bg-raised text-ink-secondary"),children:n(a.enabled?"mcp.badge.on":"mcp.badge.off")}),h&&e.jsx("span",{className:q("rounded-full px-2 py-0.5 text-[11px]",h==="signed-in"?"bg-success/10 text-success":"bg-warning/10 text-warning"),children:n(h==="signed-in"?"mcp.auth.signedIn":"mcp.auth.needsSignIn")}),a.managedBy&&e.jsx("span",{className:"rounded-full bg-raised px-2 py-0.5 text-[11px] text-ink-secondary",children:n("policy.managedBy",{organization:a.managedBy})})]}),a.managedBy&&e.jsx("div",{className:"mt-1 text-[12px] text-ink-secondary",children:n("policy.mcpBlocked",{organization:a.managedBy})}),a.runsOn&&e.jsx("div",{"data-mcp-runs-on":!0,className:"mt-1 text-[12px] text-ink-secondary",children:n("mcp.runsOn",{computer:a.runsOn.label})}),a.bot&&e.jsx("div",{"data-mcp-own-bot":!0,className:"mt-1 text-[12px] text-ink-secondary",children:n("mcp.ownBot",{bot:b(a.bot)})}),a.offFor?.length?e.jsx("div",{"data-mcp-off-for":!0,className:"mt-1 text-[12px] text-ink-secondary",children:n("mcp.offFor",{bots:a.offFor.map(b).join(", ")})}):null,a.keyOff&&e.jsx("div",{"data-mcp-key-off":!0,className:"mt-1 text-[12px] text-warning",children:n("mcp.keyOff")}),e.jsx("div",{className:"mt-1 truncate font-mono text-[12px] text-ink-secondary",children:pe(a)?a.url:[a.command,...a.args].join(" ")}),pe(a)?a.headerKeys.length>0&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-ink-secondary",children:n("mcp.headersSaved",{keys:a.headerKeys.join(", ")})}):a.envKeys.length>0&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-ink-secondary",children:n("mcp.secretsSaved",{keys:a.envKeys.join(", ")})}),pe(a)&&a.oauth&&e.jsx("div",{className:"mt-1 truncate text-[11px] text-ink-secondary",children:n(a.oauth.clientSecretConfigured?"mcp.oauth.savedWithSecret":"mcp.oauth.saved",{clientId:a.oauth.clientId})})]}),e.jsxs("div",{"data-mcp-row-actions":!0,className:"ml-auto flex flex-wrap items-center justify-end gap-1",children:[w===a.name?e.jsxs("button",{type:"button",onClick:()=>Q.current?.abort(),className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(ie,{size:14,className:"animate-spin"})," ",n("mcp.auth.cancel")]}):$?e.jsxs("button",{type:"button",disabled:R!==null||w!==null||!!a.managedBy,onClick:()=>{Ee(a)},className:"flex items-center gap-1.5 rounded-lg bg-accent px-2.5 py-2 text-[12px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[e.jsx(Os,{size:14})," ",u?n("hostedMcp.connect",{service:u.label}):n("mcp.auth.signIn")]}):h==="signed-in"?e.jsxs("button",{type:"button",disabled:R!==null||w!==null,onClick:()=>{Fe(a)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:[R===`signout:${a.name}`?e.jsx(ie,{size:14,className:"animate-spin"}):e.jsx(ra,{size:14})," ",u?n("hostedMcp.disconnect",{service:u.label}):n("mcp.auth.signOut")]}):null,e.jsxs("button",{type:"button",disabled:R!==null||w!==null,onClick:()=>{xe(a)},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-2 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:[R===`test:${a.name}`?e.jsx(ie,{size:14,className:"animate-spin"}):e.jsx(Bs,{size:14})," ",n("mcp.test")]}),e.jsx("button",{type:"button",disabled:R!==null||w!==null,onClick:()=>re(a.name),className:"rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40","aria-label":n("mcp.editAria",{name:a.name}),children:e.jsx(Ps,{size:14})}),e.jsx("button",{type:"button",disabled:R!==null||w!==null,onClick:()=>{be(a)},className:"rounded-lg p-2 text-ink-secondary hover:bg-danger/10 hover:text-danger disabled:opacity-40","aria-label":n("mcp.removeAria",{name:a.name}),children:e.jsx(Ms,{size:14})}),e.jsxs("span",{className:"ml-1 flex items-center",children:[R===`toggle:${a.name}`&&e.jsx(ie,{size:13,className:"mr-1.5 animate-spin text-ink-secondary"}),e.jsx(pn,{checked:a.enabled,disabled:R!==null||w!==null,onClick:()=>{Se(a)},"aria-label":n("mcp.toggleAria",{name:a.name,state:n(a.enabled?"mcp.state.off":"mcp.state.on")}),className:"disabled:opacity-40"})]})]})]}),u&&e.jsxs("div",{className:"mt-3 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx("p",{children:n(u.notice)}),e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer font-medium text-ink",children:n("hostedMcp.access")}),e.jsx("p",{className:"mt-2",children:n("hostedMcp.accessHint")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:(r.bots??[]).filter(S=>!S.hidden).map(S=>e.jsx("button",{type:"button",onClick:()=>{l({type:"togglePlugins",open:!1}),en(l,"access",{botId:S.id,page:"mcp"})},className:"rounded-lg bg-control px-2.5 py-1.5 text-ink hover:bg-raised-hover",children:n("hostedMcp.botSettings",{name:S.name})},S.id))})]})]}),e.jsx(Ca,{server:a,disabled:R!==null||w!==null,onSaved:S=>{se.current+=1,ce(S)}}),nt(a),Pe===a.name&&!a.enabled&&!x&&e.jsxs("div",{role:"status","data-mcp-testing":!0,className:"mt-3 flex items-center gap-2 rounded-lg bg-raised px-3 py-2 text-[12px] text-ink-secondary",children:[e.jsx(ie,{size:13,className:"animate-spin","aria-hidden":"true"})," ",n("mcp.check.testingOff")]}),x&&w!==a.name&&e.jsx("div",{role:"status",className:q("mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg px-3 py-2 text-[12px]",x.ok?"bg-success/10 text-success":x.auth==="required"?"bg-warning/10 text-warning":"bg-danger/10 text-danger"),children:x.auth==="required"?n("mcp.auth.required"):x.ok?e.jsxs("span",{className:"flex items-start gap-2",children:[e.jsx(Ls,{size:14,className:"mt-px shrink-0"})," ",ui(x)]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 flex-1",children:n(a.enabled?"mcp.check.failed":x.saved?"mcp.check.savedOff":"mcp.check.failedOff",{reason:Vn(a,x)})}),x.reason==="keys"&&pe(a)||x.reason==="unreachable"||x.reason==="timeout"?e.jsx("button",{type:"button",disabled:R!==null||w!==null,onClick:()=>x.reason==="keys"?re(a.name,!0):void ae(a.name),className:"shrink-0 rounded-lg bg-card px-2.5 py-1.5 font-medium text-ink hover:bg-raised-hover disabled:opacity-40",children:n(x.reason==="keys"?"mcp.check.fixKeys":"mcp.check.tryAgain")}):null]})})]},a.name)})})]})})}const Ge="/api/postiz",pi="postiz social media posts schedule linkedin instagram facebook tiktok threads bluesky",Zt={slug:Oe,categories:["Social"]};function ht(t){try{return new URL(t.trim()).host}catch{return t.trim()}}function ln(t,s){const o=t?.body,c=typeof o?.code=="string"?o.code:null,r=ht(s);return c==="key_rejected"?n("postiz.error.keyRejected"):c==="unreachable"?n("postiz.error.unreachable",{host:r}):c==="not_postiz"?n("postiz.error.notPostiz",{host:r}):c==="address"?n("postiz.error.address"):c==="taken"?n("postiz.taken"):typeof o?.error=="string"&&o.error?o.error:t instanceof Error?t.message:String(t)}function mi(t,s){const o=t instanceof Error?t.message:"";return/didn't accept this API key/u.test(o)||t?.name==="KeyRejected"?n("postiz.error.keyRejected"):/Couldn't reach a Postiz server/u.test(o)?n("postiz.error.unreachable",{host:ht(s)}):/didn't answer like Postiz/u.test(o)?n("postiz.error.notPostiz",{host:ht(s)}):ln(t,s)}const qe="inline-flex h-7 min-w-[64px] shrink-0 items-center justify-center gap-2 rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink transition-colors hover:bg-raised-hover disabled:opacity-40",Yt="h-8 w-full min-w-0 rounded-lg bg-inset px-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none focus:ring-1 focus:ring-accent/50",qn="text-[12px] text-accent-text underline underline-offset-2",We=encodeURIComponent(Oe),hi=1500,xi=5*6e4;function fi(){return e.jsxs("svg",{viewBox:"0 0 40 40",className:"size-10 shrink-0 rounded-[8px]","aria-hidden":"true",children:[e.jsx("rect",{width:"40",height:"40",rx:"10",fill:"#612bd3"}),e.jsx("path",{d:"M14 29V11h7.2c4.1 0 6.8 2.3 6.8 5.9s-2.7 5.9-6.8 5.9h-3.1V29zm4.1-9.7h2.8c1.9 0 3-0.9 3-2.4s-1.1-2.4-3-2.4h-2.8z",fill:"#fff",fillRule:"evenodd"})]})}function gi({refreshKey:t=0,onConnection:s}){const{state:o,dispatch:c}=Xe(),[r,l]=d.useState(null),[b,f]=d.useState(!1),[y,p]=d.useState(!1),[m,j]=d.useState(null),[D,R]=d.useState(null),[B,H]=d.useState(!1),[F,v]=d.useState(""),[E,C]=d.useState(null),[Z,w]=d.useState(!1),[V,Q]=d.useState(""),[he,ee]=d.useState(""),[te,ye]=d.useState(!1),[Y,k]=d.useState(null),g=d.useRef(!0),z=d.useRef(null),T=d.useCallback(async()=>{const P=(await A("/api/team/my-connections").catch(()=>null))?.mcp?.find(re=>re.name===Oe);return P?{connected:P.connected,how:P.how}:{connected:!1,how:null}},[]),K=d.useCallback(async(I=!1)=>{try{const P=await A(I?`${Ge}/check`:Ge,I?{method:"POST"}:void 0);if(!g.current)return null;if(!ci(P))throw new Error("unexpected Postiz status");return l(P),p(!1),P.team&&P.scope==="person"&&k(await T()),P}catch(P){return g.current&&(P.status===403?f(!0):p(!0)),null}},[T]);d.useEffect(()=>(g.current=!0,K().then(I=>{I?.state==="connected"&&I.scope==="team"&&K(!0)}),()=>{g.current=!1,z.current?.controller.abort(),z.current=null}),[K,t]);const U=r?.team===!0&&r.scope==="person",X=U?Y?.connected===!0:r?.state==="connected";d.useEffect(()=>{s?.(r?X:null)},[r,X,s]);const Pe=I=>c({type:"configStatus",config:I}),Me=async()=>{await A("/api/team/connection-scopes",{method:"PUT",body:JSON.stringify({kind:"mcp",id:Oe,scope:"person"})}),await A(`/api/mcp/servers/${We}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})},Le=async(I,P)=>{const re=await A(`/api/team/my-connections/mcp/${We}/sign-in`,{method:"POST"}),ae=It(re.auth.authorizationUrl);if(!ae)throw new Error(n("mcp.auth.failed"));R({...re.auth,flowId:null,pasteBack:!1}),!await P(ae)&&g.current&&C(n("connectors.popupBlockedContinue"));const ue=Date.now()+xi;for(;!I.signal.aborted&&Date.now()<ue;)if(await new Promise(Se=>setTimeout(Se,hi)),(await T())?.connected)return;if(!I.signal.aborted)throw new Error(n("postiz.signInExpired"))},we=async()=>{if(m||z.current)return;const I=zt(),P=new AbortController;z.current={controller:P},j("sign-in"),C(null),v("");const re=async ae=>{const ue=await I.open(ae);return I.cancel(),ue};try{if(await A(`${Ge}/sign-in`,{method:"POST"}),te||U){te&&!U&&await Me(),await Le(P,re);return}const ae=await as(Oe,{api:A,signal:P.signal,open:async le=>{!await re(le)&&g.current&&!P.signal.aborted&&C(n("connectors.popupBlockedContinue"))},onStarted:(le,Se)=>{z.current?.controller===P&&(z.current.complete=Se),g.current&&R(le)}});if(P.signal.aborted||!g.current)return;if(ae.phase!=="succeeded"){ae.phase!=="cancelled"&&C(ae.message||n("mcp.auth.failed"));return}H(!0);const ue=await A(`/api/mcp/servers/${We}/test`,{method:"POST",signal:P.signal});if(!ue.ok){const le=(ue.error??"").trim();C(n("postiz.error.testFailed",{reason:le&&!/[.!?]$/u.test(le)?`${le}.`:le}));return}await A(`/api/mcp/servers/${We}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})}catch(ae){g.current&&!P.signal.aborted&&C(ln(ae,lt))}finally{I.cancel(),z.current?.controller===P&&(z.current=null),g.current&&(R(null),H(!1),j(null),await K())}},Re=async()=>{const I=z.current;if(!(!I||!D?.flowId||!F.trim()))try{I.complete?.(await is(Oe,D.flowId,F,A))}catch(P){g.current&&C(P instanceof Error?P.message:String(P))}},Ue=async()=>{const I=Us(V),P=U||te?"":he.trim();if(!m){if(!cs(I))return C(n("keys.notAKey"));j("key"),C(null);try{if(await A(`${Ge}/key-check`,{method:"POST",body:JSON.stringify({key:I,...P?{address:P}:{}})}),te||U){await A(`${Ge}/sign-in`,{method:"POST"}),U||await Me();const ae=(await A("/api/mcp/servers")).servers?.find(ue=>ue.name===Oe)?.url;await A(`/api/team/my-connections/mcp/${We}/key`,{method:"PUT",body:JSON.stringify({value:I,url:ae})})}else{const re=o.config?.postiz?.url??"",ae=P&&ht(P)!==ht(lt)?P:"";ae!==re&&Pe(await A("/api/config",{method:"PUT",body:JSON.stringify({postiz:{url:ae}})})),Pe(await Tt("postiz",I,o.config?.postiz?.configured!==!0))}if(Ot("postiz","apps","ok"),!g.current)return;Q(""),w(!1)}catch(re){Ot("postiz","apps",rs(re)),g.current&&C(mi(re,P||lt))}finally{g.current&&(j(null),await K())}}},se=async()=>{if(!(m||!window.confirm(n("postiz.disconnectConfirm")))){j("disconnect"),C(null);try{U?await A(`/api/team/my-connections/mcp/${We}`,{method:"DELETE"}):(r?.keySaved&&Pe(await Tt("postiz","",!1)),await A(Ge,{method:"DELETE"}))}catch(I){g.current&&C(ln(I,r?.address??lt))}finally{g.current&&(j(null),await K())}}},W=()=>z.current?.controller.abort();if(b)return null;const fe=m==="sign-in",G=!U&&r?.state==="needs-sign-in",ke=!U&&r?.state==="key-refused",$e=r?.state==="blocked"||r?.state==="taken",ce=r?.state==="taken"?n("postiz.taken"):r?.state==="blocked"?r.message??n("postiz.description"):X?U?n("postiz.connectedOwn"):r?.how==="key"?n("postiz.connectedKey",{host:r.host}):n("postiz.connectedTo",{host:r?.host??""}):G?n("connectors.signedOut"):ke?n("postiz.keyRefused"):n("postiz.description"),je=(X||G||ke)&&e.jsx(os,{placement:"below",ariaLabel:n("postiz.menu"),triggerClassName:"shrink-0",items:[{key:"disconnect",label:n("connectors.disconnect"),disabled:m!==null,onSelect:()=>{se()}}],renderTrigger:()=>e.jsx("span",{className:"inline-flex size-7 items-center justify-center rounded-full bg-control/80 text-ink hover:bg-raised-hover",children:m==="disconnect"?e.jsx(ie,{size:14,className:"animate-spin"}):e.jsx(la,{size:15,"aria-hidden":"true"})})}),Ne=r!==null&&!X&&!$e;return e.jsxs("div",{"data-app-tile":"postiz","data-postiz-state":r?.state??"loading",className:"flex min-w-0 flex-col rounded-xl px-2 py-2 transition-colors hover:bg-raised/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fi,{}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold leading-5 text-ink",children:"Postiz"}),X&&e.jsx(Ze,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")})]}),e.jsx("p",{className:"truncate text-[13px] leading-[18px] text-ink-secondary",title:ce,children:ce})]}),fe?e.jsx("button",{type:"button",onClick:W,className:qe,children:n("mcp.auth.cancel")}):r===null?y?e.jsx("button",{type:"button",onClick:()=>{K()},className:qe,children:n("connectors.action.retry")}):e.jsx("button",{type:"button",disabled:!0,className:qe,"aria-label":n("common.checking"),children:e.jsx(ie,{size:14,className:"animate-spin"})}):X?je:Ne&&!Z?e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-label":n(G||ke?"postiz.reconnect":"postiz.connect"),disabled:m!==null,onClick:()=>ke?(w(!0),C(null)):void we(),className:qe,children:n(G||ke?"connectors.action.reconnect":"connectors.action.connect")}),je]}):null]}),e.jsxs("div",{className:"ps-[52px]",children:[fe&&e.jsxs("div",{role:"status",className:"mt-1.5 flex flex-col gap-1.5 text-[12px] text-ink-secondary",children:[e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(ie,{size:12,className:"shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:n(B?"postiz.loadingTools":"postiz.finishInBrowser")}),D?.authorizationUrl&&It(D.authorizationUrl)&&e.jsx("button",{type:"button",onClick:()=>{tn(D.authorizationUrl).catch(()=>C(n("mcp.auth.openFailed")))},className:qn,children:n("mcp.auth.openAgain")})]}),D?.flowId&&D.pasteBack&&e.jsxs("form",{"data-postiz-paste":!0,className:"flex flex-col gap-1.5",onSubmit:I=>{I.preventDefault(),Re()},children:[e.jsx("span",{className:"leading-relaxed text-ink",children:n("mcp.auth.pasteBackHint")}),e.jsx("input",{type:"text",value:F,onChange:I=>v(I.target.value),autoComplete:"off",spellCheck:!1,"aria-label":n("mcp.auth.callbackUrl"),placeholder:"http://127.0.0.1:…/mcp-oauth/callback?…",className:Yt}),e.jsx("button",{type:"submit",disabled:!F.trim(),className:qe,children:n("mcp.auth.complete")})]})]}),E&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:E}),Ne&&!fe&&r.team&&!U&&e.jsxs("label",{"data-postiz-only-me":!0,className:"mt-1.5 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:te,onChange:I=>ye(I.target.checked)})," ",n("mcp.team.onlyMe")]}),U&&!X&&!fe&&e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-ink-secondary",children:n("postiz.personScope")}),Ne&&!fe&&(Z?e.jsxs("form",{"data-postiz-key-form":!0,className:"mt-2 flex flex-col gap-2",onSubmit:I=>{I.preventDefault(),Ue()},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,"aria-label":n("postiz.keyField"),placeholder:n("keys.postiz.placeholder"),value:V,disabled:m==="key",onChange:I=>{C(null),Q(I.target.value)},className:Yt}),!U&&!te&&e.jsx("input",{type:"url",autoComplete:"off",spellCheck:!1,"aria-label":n("postiz.addressField"),placeholder:lt,value:he,disabled:m==="key",onChange:I=>{C(null),ee(I.target.value)},className:Yt}),e.jsx("p",{className:"text-[12px] leading-relaxed text-ink-secondary",children:n(U||te?"postiz.keyHelp":"postiz.keyAndAddressHelp")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[e.jsx("button",{type:"submit",disabled:m!==null||!V.trim(),className:qe,children:m==="key"?e.jsx(ie,{size:14,className:"animate-spin"}):n("connectors.action.connect")}),e.jsxs("a",{href:oi,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[12px] font-medium text-accent-text hover:underline",children:[n("postiz.keyLink"),e.jsx(mn,{size:11,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",onClick:()=>{w(!1),C(null)},className:"text-[12px] text-ink-secondary underline underline-offset-2 hover:text-ink",children:n("postiz.useSignIn")})]})]}):e.jsx("button",{type:"button",onClick:()=>{w(!0),C(null),ee(r.selfHosted?r.address:"")},className:`mt-1.5 inline-block ${qn}`,children:n("postiz.useKey")}))]})]})}const Wn=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0,Zn=t=>typeof t=="string"&&t.length<=40&&!Number.isNaN(Date.parse(t));function bi(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const{calls:s,max:o,usedUp:c,resetsAt:r,trialEndsAt:l}=t;return!Wn(s)||!Wn(o)||!Zn(r)||l!==void 0&&!Zn(l)?null:{calls:Math.min(s,o),max:o,...c===!0||s>=o?{usedUp:!0}:{},resetsAt:r,...l!==void 0?{trialEndsAt:l}:{}}}function yi(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t;return(s.using==="own"||s.using==="included"||s.using===null)&&typeof s.ownKey=="boolean"&&typeof s.included=="boolean"&&(s.usage===void 0||bi(s.usage)!==null)}const ki="https://treg.to",St="inline-flex h-7 min-w-[64px] shrink-0 items-center justify-center gap-2 rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink transition-colors hover:bg-raised-hover disabled:opacity-40",ji="h-8 w-full min-w-0 rounded-lg bg-inset px-2.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none focus:ring-1 focus:ring-accent/50",vi="x twitter treg tweets posts";function wi(){return e.jsxs("svg",{viewBox:"0 0 40 40",className:"size-10 shrink-0 rounded-[8px]","aria-hidden":"true",children:[e.jsx("rect",{width:"40",height:"40",rx:"10",fill:"#000"}),e.jsx("path",{transform:"translate(9 9) scale(0.9167)",fill:"#fff",d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})]})}const Xt=t=>new Intl.DateTimeFormat(xt(),{day:"numeric",month:"long",timeZone:"UTC"}).format(new Date(t)),Yn=t=>t.toLocaleString(xt());function Ni(t){const s={used:Yn(t.calls),max:Yn(t.max)};return t.trialEndsAt?t.usedUp?{line:n("apps.x.usedUpTrial",{date:Xt(t.trialEndsAt)}),usedUp:!0}:{line:n("apps.x.usageTrial",s),usedUp:!1}:t.usedUp?{line:n("apps.x.usedUp",{date:Xt(t.resetsAt)}),usedUp:!0}:{line:`${n("apps.x.usage",s)} ${n("apps.x.resets",{date:Xt(t.resetsAt)})}`,usedUp:!1}}function Ai({refreshKey:t=0,onConnection:s}){const{state:o,dispatch:c}=Xe(),[r,l]=d.useState(null),[b,f]=d.useState(!1),[y,p]=d.useState(null),[m,j]=d.useState(""),[D,R]=d.useState(null),[B,H]=d.useState(null),[F,v]=d.useState(!1),E=d.useRef(!0),C=d.useRef(!1),Z=da(ma()?.view??null)==="connecting",w=o.config?.treg?.configured===!0,V=o.config?.xResearch?.included===!0,Q=d.useCallback(async(T=!1)=>{try{const K=await A(`/api/x/status${T?"?refresh=1":""}`);if(!E.current)return;if(!yi(K))throw new Error("unexpected X status");l(K),f(!1)}catch{E.current&&f(!0)}},[]);d.useEffect(()=>(E.current=!0,Q(t>0),()=>{E.current=!1}),[Q,t,w,V]),d.useEffect(()=>{s?.(r?r.using!==null:null)},[r,s]);const he=T=>(c({type:"configStatus",config:T}),Q(!0)),ee=async()=>{p("test"),H(null);try{const T=await A("/api/keys/test",{method:"POST",body:JSON.stringify({provider:"treg"})});return E.current&&H($s(T)),En(T)}catch(T){return E.current&&H(T instanceof Error?T.message:String(T)),En(null)}finally{E.current&&p(null)}},te=async()=>{const T=m.trim();if(!(y||!T)){if(!cs(T))return R(n("keys.notAKey"));p("save"),R(null),H(null);try{if(await he(await Tt("treg",T,!w)),!E.current)return;j(""),v(!1),Ot("treg","apps",await ee())}catch(K){E.current&&R(K instanceof Error?K.message:String(K)),Ot("treg","apps",rs(K))}finally{E.current&&p(K=>K==="save"?null:K)}}},ye=async()=>{if(!y){p("remove"),R(null),H(null);try{await he(await Tt("treg","",!1)),Fs("treg","apps")}catch(T){E.current&&R(T instanceof Error?T.message:String(T))}finally{E.current&&p(null)}}};d.useEffect(()=>{C.current&&(C.current=!1,te())});const Y=r?.using??null,k=r?.usage?Ni(r.usage):null,g=r!==null&&Y!=="own"&&(Y===null||F||k?.usedUp===!0),z=r===null?n("apps.x.description"):Y==="own"?n("apps.x.own"):Y==="included"?n("apps.x.included"):Z&&!r.unavailable?n("apps.x.connecting"):n("apps.x.addKey");return e.jsxs("div",{"data-app-tile":"x","data-x-state":r===null?"loading":Y??"none",className:"flex min-w-0 flex-col rounded-xl px-2 py-2 transition-colors hover:bg-raised/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wi,{}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold leading-5 text-ink",children:n("apps.x.title")}),Y!==null&&e.jsx(Ze,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")})]}),e.jsx("p",{className:"truncate text-[13px] leading-[18px] text-ink-secondary",title:z,children:z})]}),r===null?b?e.jsx("button",{type:"button",onClick:()=>{Q(!0)},className:St,children:n("connectors.action.retry")}):e.jsx("button",{type:"button",disabled:!0,className:St,"aria-label":n("common.checking"),children:e.jsx(ie,{size:14,className:"animate-spin"})}):Y==="own"?e.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{ee()},className:St,children:y==="test"?e.jsx(ie,{size:14,className:"animate-spin"}):n("keys.test")}):null]}),e.jsxs("div",{className:"ps-[52px]",children:[Y==="own"&&e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:r?.included?n("apps.x.ownFirst"):n("apps.x.ownBilled")}),Y==="included"&&k&&e.jsx("p",{"data-x-usage":!0,className:k.usedUp?"mt-1 text-[12px] leading-relaxed text-warning":"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:k.line}),Y==="own"&&e.jsxs("button",{type:"button",disabled:y!==null,onClick:()=>{ye()},className:"mt-1.5 inline-flex items-center gap-1.5 text-[12px] text-danger underline underline-offset-2 disabled:opacity-50",children:[y==="remove"&&e.jsx(ie,{size:12,className:"animate-spin","aria-hidden":"true"}),n("apps.x.remove")]}),Y==="included"&&!g&&e.jsx("button",{type:"button",onClick:()=>{v(!0),R(null)},className:"mt-1.5 inline-block text-[12px] text-accent-text underline underline-offset-2",children:n("apps.x.useOwnKey")}),g&&e.jsxs("form",{"data-x-key-form":!0,className:"mt-2 flex flex-col gap-2",onSubmit:T=>{T.preventDefault(),te()},children:[Y===null&&e.jsx("p",{className:"text-[12px] leading-relaxed text-ink-secondary",children:n("apps.x.addKeyHelp")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,"aria-label":n("keys.treg.label"),placeholder:n("keys.treg.placeholder"),value:m,disabled:y==="save",onChange:T=>{R(null),j(T.target.value)},onPaste:()=>{C.current=!0},className:ji}),e.jsx("button",{type:"submit",disabled:y!==null||!m.trim(),className:St,children:y==="save"?e.jsx(ie,{size:14,className:"animate-spin"}):n("common.save")})]}),e.jsxs("a",{href:ki,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[12px] font-medium text-accent-text hover:underline",children:[n("keys.treg.link"),e.jsx(mn,{size:11,"aria-hidden":"true"})]})]}),B&&e.jsx("p",{role:"status",className:"mt-1.5 text-[12px] text-ink-secondary",children:B}),D&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:D})]})]})}function dn(t,s,o,c){const r={...t};for(const[l,b]of Object.entries(s))(o.get(l)??0)===(c.get(l)??0)&&(r[l]=b);return r}function Ci(t,s,o,c,r=!0){const l={...t};if(!r)return dn(l,s,o,c);for(const[b,f]of Object.entries(t))s[b]||!f.connected&&!f.accounts?.length||(o.get(b)??0)===(c.get(b)??0)&&(l[b]={connected:!1,pending:!1,status:"not_connected",accounts:[]});return dn(l,s,o,c)}function Si(t,s,o){return Object.fromEntries(Object.entries(t).filter(([c])=>(s.get(c)??0)===(o.get(c)??0)))}async function Ri(t=window.ogb){if(!t?.credentialStore||t.remoteClient?.active===!0)return!1;try{return await t.credentialStore.unreadable()===!0}catch{return!1}}let dt=null;function Xn({notice:t=!1}){const[s,o]=d.useState(!1),[c,r]=d.useState(()=>dt!==null);if(d.useEffect(()=>{let f=!0;return Ri().then(y=>{f&&o(y)}),dt?.finally(()=>{f&&r(!1)}),()=>{f=!1}},[]),!s)return null;const l=()=>{if(dt)return;r(!0),dt=Promise.resolve(window.ogb?.credentialStore?.reset()).then(()=>{},()=>{}).finally(()=>{dt=null,r(!1)})},b=e.jsx("button",{type:"button",onClick:l,disabled:c,className:"ms-2 font-medium underline underline-offset-2 hover:opacity-80 disabled:opacity-60",children:n("connectors.resetSavedKeys")});return t?e.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-xl bg-warning/10 px-3 py-2 text-[13px] text-warning",children:[e.jsx(ls,{size:14,className:"mt-px shrink-0"}),e.jsxs("span",{children:[n("connectors.savedKeysUnreadable"),b]})]}):b}function Ei(t,s){return Object.hasOwn(t.bots,s.id)?t.bots[s.id]:t.teams.includes(s.section??"")}const es="/api/limix/plugins",ut="rounded-lg bg-control px-3 py-1.5 text-sm text-ink disabled:opacity-50 hover:bg-raised-hover",zi={"forbidden: this session lacks the admin scope":"Chỉ quản trị viên mới có thể quản lý kho plugin.","Could not sync the plugin catalog":"Chưa đồng bộ được kho plugin. Hãy kiểm tra kết nối và thử lại.","Plugin download or integrity check failed":"Tải gói hoặc kiểm tra tính toàn vẹn thất bại. Hãy đồng bộ kho rồi thử lại.","Refresh the catalog and review this version":"Hãy đồng bộ kho và xem lại phiên bản này.","Review the installed version first":"Hãy mở lại kho để xem phiên bản đã cài.","The saved plugin library could not be read":"Không đọc được dữ liệu kho plugin đã lưu."};function Ii(){const[t,s]=d.useState(!1),[o,c]=d.useState(),[r,l]=d.useState(!1),[b,f]=d.useState(""),[y,p]=d.useState(""),m=xt().startsWith("vi")?"vi":"en",j=(v,E)=>m==="vi"?v:E;d.useEffect(()=>{if(!t)return;const v=new AbortController;return l(!0),f(""),A(es,{signal:v.signal}).then(c).catch(E=>{v.signal.aborted||f(E.message)}).finally(()=>{v.signal.aborted||l(!1)}),()=>v.abort()},[t]);async function D(v){l(!0),f("");try{c(await A(es,{method:"POST",body:JSON.stringify(v)}))}catch(E){f(E instanceof Error?E.message:String(E))}finally{l(!1)}}const R=new Set([...o?.catalog??[],...o?.installed??[]].map(v=>v.id)),B=y.startsWith("team:"),H=y.slice(y.indexOf(":")+1),F=o?.bots.find(v=>v.id===H);return e.jsxs("section",{className:"mb-4 rounded-xl border border-line p-3",children:[e.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>s(!t),className:"font-semibold text-ink",children:[t?"▾ ":"▸ ",j("Kho Plugin","Plugin library")]}),t&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{className:ut,disabled:r,onClick:()=>{D({action:"sync"})},children:j("Đồng bộ kho","Sync catalog")}),e.jsx("a",{href:"https://github.com/leomieo/limix-plugin-hub",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",children:j("Mở kho trên GitHub","View catalog on GitHub")}),o&&e.jsxs("select",{className:ut,"aria-label":j("Phạm vi áp dụng","Applies to"),value:y,onChange:v=>p(v.target.value),children:[e.jsx("option",{value:"",children:j("Chọn bot hoặc nhóm","Choose a bot or team")}),e.jsx("optgroup",{label:j("Nhóm bot","Teams"),children:o.teams.map(v=>e.jsx("option",{value:"team:"+v,children:v},v))}),e.jsx("optgroup",{label:"Bot",children:o.bots.map(v=>e.jsx("option",{value:"bot:"+v.id,children:v.name},v.id))})]})]}),b&&e.jsx("p",{role:"alert",className:"text-danger",children:m==="vi"?zi[b]??b:b}),r&&e.jsx("p",{role:"status",children:j("Đang xử lý…","Working…")}),o&&!R.size&&e.jsx("p",{children:j("Đồng bộ kho để xem các plugin có thể tải.","Sync the catalog to see available plugins.")}),[...R].map(v=>{const E=o.catalog.find(Q=>Q.id===v),C=o.installed.find(Q=>Q.id===v),Z=E??C,w=E&&C&&E.sha256!==C.sha256,V=C&&(B?String(C.teams.includes(H)):Object.hasOwn(C.bots,H)?String(C.bots[H]):"inherit");return e.jsxs("article",{className:"space-y-2 border-t border-line pt-3",children:[e.jsxs("h3",{className:"font-medium",children:[Z.name[m]," ",e.jsxs("small",{children:["v",Z.version]})]}),e.jsx("p",{children:Z.description[m]}),e.jsxs("p",{className:"text-sm",children:[j("Quyền: thêm chỉ dẫn vào cuộc trò chuyện.","Permission: add instructions to the conversation.")," ",j("Kết nối MCP cần có","Required MCP connections")," · ",Z.requiresMcp.join(", ")||j("Không có","None")]}),!!Z.requiresMcp.length&&e.jsx("p",{className:"text-xs text-ink-secondary",children:j("Plugin hoạt động khi bot đã được cấp các kết nối trên trong lượt chat.","The workflow runs when these connections are available to the bot in this turn.")}),C&&e.jsxs("details",{children:[e.jsxs("summary",{children:[j("Xem nội dung đã cài","Inspect installed package")," · v",C.version]}),e.jsxs("p",{children:["MCP · ",C.requiresMcp.join(", ")||j("Không có","None")]}),e.jsx("pre",{className:"whitespace-pre-wrap p-2",children:C.instructions})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[E&&(!C||w)&&e.jsx("button",{disabled:r,className:ut,onClick:()=>{D({action:"install",id:v,sha256:E.sha256})},children:w?j("Cập nhật và tắt để duyệt lại","Update and disable for review"):j("Tải về","Download")}),C&&e.jsxs(e.Fragment,{children:[y&&e.jsxs("select",{"aria-label":Z.name[m],className:ut,disabled:r,value:V,onChange:Q=>{D({action:"assign",id:v,sha256:C.sha256,target:B?"team":"bot",key:H,enabled:Q.target.value==="inherit"?null:Q.target.value==="true"})},children:[!B&&e.jsxs("option",{value:"inherit",children:[j("Theo nhóm","Inherit from team")," · ",F&&C.teams.includes(F.section??"")?j("Bật","On"):j("Tắt","Off")]}),e.jsx("option",{value:"true",children:j("Bật","On")}),e.jsx("option",{value:"false",children:j("Tắt","Off")})]}),y&&!B&&F&&e.jsx("span",{className:"self-center text-xs",children:Ei(C,F)?j("Đang bật","Enabled"):j("Đang tắt","Disabled")}),e.jsx("button",{className:ut,disabled:r,onClick:()=>{D({action:"remove",id:v})},children:j("Gỡ cài đặt","Uninstall")})]})]})]},v)})]})]})}function Rt({id:t,title:s,note:o,viewAll:c,after:r,children:l}){return e.jsxs("section",{"aria-labelledby":t,"data-apps-section":t,children:[e.jsxs("div",{className:"mb-1.5 flex min-h-7 items-center justify-between gap-3 px-2",children:[e.jsxs("h3",{id:t,className:"min-w-0 truncate text-[14px] font-semibold leading-5 text-ink",children:[s,o&&e.jsx("span",{className:"ms-2 text-[12px] font-normal text-ink-secondary",children:o})]}),c&&e.jsx("button",{type:"button",onClick:c.onClick,className:"shrink-0 rounded-full px-2 text-[13px] font-medium leading-5 text-ink-secondary transition-colors hover:text-ink",children:c.label})]}),e.jsx("div",{className:"grid grid-cols-1 items-start gap-x-6 gap-y-1 @xl:grid-cols-2",children:l}),r]})}function Ti(t,s){const o=s.alias?`“${s.alias}” (${s.id})`:`“${s.id}”`;return n("connectors.disconnectConfirm",{identity:o,service:t})}function Oi(t,s,o){return t.filter(c=>{if(c.hidden||c.composio===!1||!s.find(b=>b.instanceId===c.modelSelection.instanceId)?.capabilities?.composioMcp)return!1;const r=c.connectorTools;if(!r||typeof r!="object"||Array.isArray(r))return!1;const l=r[o];return l===void 0?!0:!sa(l)||l.tools!=="*"})}function Bi(t,s,o,c){return(!s||`${t.label} ${t.keywords} ${n(t.description)}`.toLowerCase().includes(s.toLowerCase().trim()))&&(o==="all"||o==="connected"&&c?.[t.id]!==!1)}function Pi(t){return t.configured||t.stale?null:t.setup==="needs-setup"?{key:t.remoteClient?"connectors.setupNeededRemote":"connectors.setupNeeded",tone:"info"}:{key:"connectors.notConfigured",tone:"warning"}}const ts=48,Mi=16;function Li(t,s,o){return Xs(t,s).filter(c=>ea(c,o)!==null)}function Ji(){const{state:t,dispatch:s}=Xe(),o=window.ogb?.remoteClient?.active===!0,c=d.useRef(null),r=t.pluginsSurface,[l,b]=d.useState(null),[f,y]=d.useState("curated"),[p,m]=d.useState(null),[j,D]=d.useState(!1),[R,B]=d.useState("unavailable"),[H,F]=d.useState(void 0),[v,E]=d.useState(()=>Ct()?.services??Ks()?.services??{}),[C,Z]=d.useState(Ct()?.authoritative===!1),[w,V]=d.useState({}),[Q,he]=d.useState(null),[ee,te]=d.useState(""),[ye,Y]=d.useState(null),[k,g]=d.useState(!1),[z,T]=d.useState(Ct()===null?"loading":"ready"),[K,U]=d.useState(null),[X,Pe]=d.useState(""),[Me,Le]=d.useState("marketplace"),[we,Re]=d.useState(!1),[Ue,se]=d.useState(null),[W,fe]=d.useState(0),[G,ke]=d.useState(null),[$e,ce]=d.useState(null),[je,Ne]=d.useState(null),[I,P]=d.useState(null),[re,ae]=d.useState([]),ue=d.useRef(new Map),le=d.useRef(new Map),Se=d.useRef(new Map),xe=d.useRef(null),Ee=d.useRef(new Set),et=(i,N)=>{const L=Object.entries(i).filter(([O,_])=>(le.current.get(O)??0)===(N.get(O)??0)&&(_.connected&&!_.pending||/^(expired|failed)$/i.test(_.status??""))).map(([O])=>O);L.length&&V(O=>L.some(_=>O[_])?Object.fromEntries(Object.entries(O).filter(([_])=>!L.includes(_))):O)},tt=d.useCallback(i=>{if(!i.length)return Promise.resolve({});const N=new Map(i.map(O=>[O,le.current.get(O)??0])),L=new Map(i.map(O=>{const _=(Se.current.get(O)??0)+1;return Se.current.set(O,_),[O,_]}));return A(`/api/connectors?services=${i.join(",")}`).then(O=>{const _=Si(O.services??{},Se.current,L);return E(J=>dn(J,_,le.current,N)),et(_,N),_}).catch(()=>({}))},[]),gt=d.useCallback((i=!1)=>{const N=new Map(le.current);return g(!0),Ds(i).then(({services:L,authoritative:O,refused:_})=>(Z(!O),_&&U({key:"connectors.adminOnly"}),E(J=>Ci(J,L,le.current,N,O)),et(L,N),L)).finally(()=>g(!1))},[]),Fe=d.useCallback((i=!1)=>{const N=Ct()!==null;return N||T("loading"),U(null),gt(i).then(L=>(T("ready"),L)).catch(L=>(N||T("error"),U(L instanceof Error?L.message:String(L)),{}))},[gt]);d.useEffect(()=>()=>{xe.current?.cancel(),xe.current=null;for(const i of ue.current.values())i();ue.current.clear()},[]);const be=Hs({status:v,emailConnected:I,inventoryReady:z==="ready"&&!C});d.useEffect(()=>{z==="ready"&&oa(v,!C)},[z,C,v]),d.useEffect(()=>{let i=!0;return Fe(),A("/api/connectors/catalog").then(N=>{i&&(b(N.cards??[]),y(N.source??"curated"),m(N.pagination??null),D(!!N.configured),B(N.mode??"unavailable"),F(N.setup))}).catch(N=>{i&&(b(L=>L??[]),U(Qs(N)?{key:"connectors.adminOnly"}:N.message))}),()=>{i=!1}},[Fe]),d.useEffect(()=>{const i=document.activeElement instanceof HTMLElement?document.activeElement:null,N=c.current,L=()=>Array.from(N?.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]).filter(J=>J.getClientRects().length>0),O=L();(O.find(J=>J.matches("input"))??O[0]??N)?.focus();const _=J=>{if(J.key==="Escape"){J.preventDefault(),s({type:"togglePlugins",open:!1});return}if(J.key!=="Tab"||!N)return;const de=L();if(de.length===0){J.preventDefault(),N.focus();return}const ve=de[0],Ae=de.at(-1);de.some(ge=>ge===document.activeElement)?J.shiftKey&&document.activeElement===ve?(J.preventDefault(),Ae.focus()):!J.shiftKey&&document.activeElement===Ae&&(J.preventDefault(),ve.focus()):(J.preventDefault(),(J.shiftKey?Ae:ve).focus())};return window.addEventListener("keydown",_),()=>{window.removeEventListener("keydown",_),i?.focus()}},[s]);const{suggestions:Ke,picking:bt,pick:nt}=_s(l!==null&&j&&z==="ready",`${W}:${Object.keys(v).filter(i=>v[i]?.connected).sort().join()}`),Mt=async i=>{if(xe.current)return;const N=zt();xe.current=N;try{!await N.open(i)&&xe.current===N&&U({key:"connectors.popupBlockedContinue"})}finally{N.cancel(),xe.current===N&&(xe.current=null)}},Lt=(i,N,L)=>{ue.current.get(i)?.();const O=aa(N,()=>tt([i]).then(_=>_[i]),_=>{ue.current.get(i)===O&&ue.current.delete(i),ia(i,_),_==="connected"&&L&&be.appConnected(i,l?.find(J=>J.slug===i)?.label??i)});ue.current.set(i,O)},ze=async(i,N,L)=>{if(ye||xe.current)return;const O=zt();xe.current=O,le.current.set(i,(le.current.get(i)??0)+1),Y(i),U(null),L&&Ee.current.add(i);const _=!Ee.current.has(i)&&!ct(v[i]);try{const J=Date.now();L&&await A(`/api/connectors/${i}/accounts/${encodeURIComponent(L.id)}`,{method:"DELETE"});const de={method:"POST"};N&&(de.body=JSON.stringify({alias:N}));const ve=await A(`/api/connectors/${i}/authorize`,de);if(xe.current!==O)return;const Ae=It(typeof ve.url=="string"?ve.url:null);if(!Ae)throw new Error(n("connectors.invalidAuthorizationUrl"));V(ge=>({...ge,[i]:{url:Ae,createdAt:J}})),E(ge=>({...ge,[i]:{...ge[i],connected:ge[i]?.connected??!1,pending:!0,status:"INITIATED"}})),he(null),te(""),Lt(i,v[i],_),!await O.open(Ae)&&xe.current===O&&U({key:"connectors.popupBlockedContinue"})}catch(J){if(xe.current!==O)return;const de=J instanceof Error?J.message:String(J);ta(de)?(he(i),te(""),U({key:"connectors.aliasNeeded"}),tt([i])):U(na(de)?{key:"connectors.aliasTaken"}:de)}finally{O.cancel(),xe.current===O&&(xe.current=null,Y(null))}},a=(i,N)=>{Y(i),A(`/api/connectors/${i}/accounts/${encodeURIComponent(N)}`,{method:"DELETE"}).then(()=>tt([i])).catch(L=>U(L.message)).finally(()=>Y(null))},u=(l??[]).filter(i=>(!On(R,i.slug)||ct(v[i.slug]))&&zn(`${i.label} ${i.slug} ${Bn(i)} ${(i.categories??[]).join(" ")}`,X)),x=i=>!!(v[i]?.connected||v[i]?.accounts?.length),h=r==="mcp"?"mcp":Me==="connected"?"connected":"all",$=X.trim().length>0,S=$&&h==="connected"?"all":h,ne=new Set(mt.filter(i=>Bi(i,X,S,Ue)).map(i=>i.id)),oe=(!X||`email mail imap smtp mailbox ${n("email.description")}`.toLowerCase().includes(X.toLowerCase().trim()))&&(S==="all"||S==="connected"&&I!==!1),De=(!X||`${vi} ${n("apps.x.description")}`.toLowerCase().includes(X.toLowerCase().trim()))&&(S==="all"||S==="connected"&&$e!==!1),Ut=(!X||`${pi} ${n("postiz.description")}`.toLowerCase().includes(X.toLowerCase().trim()))&&(S==="all"||S==="connected"&&je!==!1),$t=(S==="connected"?u.filter(i=>x(i.slug)):u).map((i,N)=>({card:i,index:N})).sort((i,N)=>Number(x(N.card.slug))-Number(x(i.card.slug))||i.index-N.index).map(({card:i})=>i),Ft=mt.filter(i=>Ue?.[i.id]),yn=re.filter(i=>rn(i)),kn=i=>zn(`${i.name} ${pe(i)?i.url:[i.command,...i.args].join(" ")}`,X),jn=Object.values(v).filter(ct).length+Ft.length+yn.filter(gs).length+ +(I===!0)+ +($e===!0)+ +(je===!0),vn=Js(z),st=()=>s({type:"togglePlugins",open:!1}),yt=Pi({configured:j,stale:C,setup:H,remoteClient:o}),at=i=>{if(ke(null),i==="mcp"){s({type:"togglePlugins",open:!0,surface:"mcp"});return}Le(i==="connected"?"connected":"marketplace"),r!=="apps"&&s({type:"togglePlugins",open:!0,surface:"apps"})},Kt=va([...l??[],Zt],void 0,Zt.categories),Dt=Kt.more,Ht=G!==null&&Dt.includes(G),He=h==="all"&&G!==null&&!$,wn=Ut&&(!He||sn(Zt,G)),ys=!He&&(ne.size>0||oe||De)||wn||h==="connected"&&yn.some(i=>i.enabled&&kn(i)),ks=He?$t.filter(i=>sn(i,G)):$t,kt=h==="all"&&!$&&G===null,it=kt?wa($t,x,Kt.inline):[],js=it.find(i=>i.kind==="all"),jt=kt?js?.cards??[]:ks,Qt=kt&&!we&&jt.length>ts,Nn=Qt?jt.slice(0,ts):jt,An=(l??[]).filter(i=>ct(v[i.slug])),_t=i=>{ke(i),Le("marketplace"),r!=="apps"&&s({type:"togglePlugins",open:!0,surface:"apps"})},vs=$?n("connectors.section.results"):h==="connected"?n("connectors.section.yours"):G?rt(G):it.length>1?n("apps.section.all"):n("connectors.section.available"),Qe="inline-flex h-7 shrink-0 items-center justify-center gap-2 rounded-full px-3 text-[13px] font-medium leading-5 transition-colors",Jt=i=>i?"bg-ink text-app":"bg-control/70 text-ink-secondary hover:bg-raised-hover hover:text-ink";return e.jsxs("div",{className:"glass-popup-frame",style:qs(),onMouseDown:i=>i.stopPropagation(),children:[e.jsx("div",{"aria-hidden":"true",className:"glass-scrim pointer-events-none absolute inset-0"}),e.jsxs("div",{ref:c,"data-tour":"apps-panel",role:"dialog","data-look":"dialog","aria-modal":"true","aria-labelledby":"plugins-title",tabIndex:-1,className:"glass-surface glass-popup animate-pop-in relative flex max-w-[780px] flex-col overflow-hidden rounded-2xl",children:[e.jsxs("header",{className:"flex flex-col gap-4 px-5 pb-4 pt-5 sm:px-7 sm:pt-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{id:"plugins-title",className:"min-w-0 truncate text-[20px] font-semibold leading-7 tracking-[-0.01em] text-ink",children:n("apps.title")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs("button",{type:"button","data-apps-filter":"connected","aria-pressed":h==="connected",onClick:()=>at(h==="connected"?"all":"connected"),className:q("inline-flex h-8 items-center gap-2 rounded-full ps-1.5 pe-2 text-[13px] font-medium leading-5 transition-colors",h==="connected"?"bg-raised text-ink":"text-ink-secondary hover:bg-raised/60 hover:text-ink"),children:[An.length>0&&e.jsx("span",{"aria-hidden":"true",className:"flex -space-x-1.5 rtl:space-x-reverse",children:An.slice(0,4).map(i=>e.jsx("span",{className:"flex size-5 items-center justify-center overflow-hidden rounded-md bg-menu ring-2 ring-menu",children:e.jsx(In,{card:i,className:"size-5 rounded-md"})},i.slug))}),e.jsx("span",{className:"whitespace-nowrap",children:jn>0?n("apps.connectedCount",{count:jn}):n("apps.filter.connected")}),e.jsx(us,{size:14,"aria-hidden":"true",className:"shrink-0 rtl:-scale-x-100"})]}),e.jsx("button",{onClick:()=>{fe(i=>i+1),Fe(!0)},disabled:k,className:"flex size-8 items-center justify-center rounded-full text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",title:n("connectors.refreshTitle"),"aria-label":n("connectors.refreshTitle"),children:e.jsx(nn,{size:16,className:q(k&&"animate-spin")})}),e.jsx("button",{"data-tour":"apps-close",onClick:st,"aria-label":n("connectors.closeAria"),className:"flex size-8 items-center justify-center rounded-full text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(ns,{size:18})})]})]}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-5 text-ink-secondary",children:n("apps.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("label",{className:"flex h-9 min-w-0 flex-1 items-center gap-2.5 rounded-full bg-control/70 px-3.5 focus-within:ring-1 focus-within:ring-accent",children:[e.jsx(As,{size:15,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:X,onChange:i=>Pe(i.target.value),placeholder:n("connectors.searchPlaceholder"),"aria-label":n("connectors.searchPlaceholder"),className:"min-w-0 flex-1 bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("button",{type:"button","data-apps-filter":"mcp","aria-pressed":h==="mcp",onClick:()=>at(h==="mcp"?"all":"mcp"),className:q(Qe,"h-9 border border-hairline/40 px-3.5",h==="mcp"?"bg-ink text-app":"text-ink hover:bg-raised"),children:[e.jsx(ua,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"hidden sm:inline",children:n("apps.filter.mcp")}),e.jsx("span",{className:"sr-only sm:hidden",children:n("apps.filter.mcp")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":n("apps.categoriesAria"),children:[e.jsx("button",{type:"button","data-apps-filter":"all","aria-pressed":h==="all"&&G===null,onClick:()=>{at("all"),ke(null)},className:q(Qe,Jt(h==="all"&&G===null)),children:n("apps.filter.all")}),Kt.inline.map(i=>e.jsx("button",{type:"button","data-apps-category":i,"aria-pressed":h==="all"&&G===i,onClick:()=>_t(G===i?null:i),className:q(Qe,Jt(h==="all"&&G===i)),children:rt(i)},i)),Dt.length>0&&e.jsx(os,{ariaLabel:n("apps.moreCategories"),items:Dt.map(i=>({key:i,label:rt(i),active:G===i,onSelect:()=>_t(i)})),renderTrigger:({open:i})=>e.jsxs("span",{className:q(Qe,Jt(h==="all"&&Ht),i&&!Ht&&"bg-raised-hover text-ink"),children:[Ht?rt(G):n("apps.more"),e.jsx(ss,{size:14,"aria-hidden":"true"})]})})]})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-7 sm:px-7",children:[e.jsx(Ii,{}),C?e.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-xl bg-warning/10 px-3 py-2 text-[13px] text-warning",children:[e.jsx(ls,{size:14,className:"mt-px shrink-0"}),e.jsxs("span",{children:[n("connectors.stale"),e.jsx(Xn,{})]})]}):e.jsx(Xn,{notice:!0}),yt&&h!=="mcp"&&e.jsxs("div",{className:q("mb-3 rounded-xl px-4 py-3 text-[13px]",yt.tone==="warning"?"bg-warning/10 text-warning":"bg-control/50 text-ink-secondary"),children:[Ft.length>0?n("hostedMcp.otherAppsSetup",{services:new Intl.ListFormat(xt(),{style:"long",type:"conjunction"}).format(Ft.map(i=>i.label))}):n(yt.key)," ",e.jsx("button",{className:q("font-medium underline underline-offset-2",yt.tone==="info"&&"text-ink",o&&"hidden"),onClick:()=>{st(),s(Tn("composio"))},children:n("connectors.openSettings")})]}),j&&!o&&f==="curated"&&R==="self-hosted"&&h!=="mcp"&&e.jsxs("div",{className:"mb-3 text-[12px] text-ink-secondary",children:[n("connectors.featuredBefore")," ",e.jsx("button",{className:"underline underline-offset-2 hover:text-ink",onClick:()=>{st(),s({type:"toggleAppSettings",open:!0})},children:n("connectors.updateKey")})," ",n("connectors.featuredAfter")]}),K&&e.jsx("div",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[12px] text-danger",children:typeof K=="string"?K:n(K.key)}),h!=="mcp"&&e.jsxs("div",{"data-apps-grid":!0,className:"@container flex flex-col gap-7 pt-1",children:[!it.some(i=>i.kind==="connected")&&Cn(),it.filter(i=>i.kind!=="all").map(i=>i.kind==="connected"?e.jsxs(d.Fragment,{children:[e.jsx(Rt,{id:"apps-section-connected",title:n("apps.section.connected"),viewAll:i.cards.length>Bt?{label:n("apps.viewAll"),onClick:()=>at("connected")}:void 0,children:i.cards.slice(0,Bt).map(N=>vt(N))}),Cn()]},"connected"):e.jsx(Rt,{id:`apps-section-${i.category}`,title:rt(i.category),viewAll:i.more?{label:n("apps.viewAll"),onClick:()=>_t(i.category)}:void 0,children:i.cards.map(N=>vt(N))},i.category)),e.jsxs(Rt,{id:"apps-grid-title",title:vs,note:h==="all"&&!X&&G===null&&p&&(p.stalled||p.totalItems!==void 0&&p.items<p.totalItems)?`${p.totalItems!==void 0&&p.items<p.totalItems?n("connectors.marketplace.partialCount",{shown:p.items.toLocaleString(Vt()),total:p.totalItems.toLocaleString(Vt())}):n("connectors.marketplace.partialStalled")}${p.reason?` — ${n("connectors.marketplace.partialReason",{reason:p.reason})}`:""}`:void 0,viewAll:Qt?{label:n("apps.viewAll"),onClick:()=>Re(!0)}:void 0,after:e.jsxs(e.Fragment,{children:[l===null&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-24 text-[13px] text-ink-secondary",children:[e.jsx(ie,{size:14,className:"animate-spin"})," ",n("connectors.loadingCatalog")]}),Qt&&e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>Re(!0),className:q(Qe,"bg-control/70 px-4 text-ink hover:bg-raised-hover"),children:n("apps.showAll",{count:jt.length.toLocaleString(Vt())})})}),l!==null&&Nn.length===0&&!ys&&it.length<=1&&e.jsxs("div",{className:"flex min-h-40 flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:S==="connected"?vn.title:n("connectors.noAppsFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:S==="connected"?vn.description:n("connectors.tryDifferentSearch")}),h==="connected"&&z==="error"&&e.jsxs("button",{type:"button",disabled:k,onClick:()=>{Fe(!0)},className:q(Qe,"mt-4 bg-raised text-ink hover:bg-raised-hover disabled:opacity-50"),children:[e.jsx(nn,{size:14,className:q(k&&"animate-spin")}),n("connectors.action.retry")]})]})]}),children:[e.jsx(Gn,{hostedCards:{shown:i=>!He&&ne.has(i),onConnections:se,onServers:ae,...h==="connected"?{ownServers:{shown:kn,manage:()=>at("mcp")}}:{}},refreshKey:W}),e.jsx("div",{"data-native-card":"x",className:De&&!He?"contents":"hidden",children:e.jsx(Ai,{refreshKey:W,onConnection:ce})}),e.jsx("div",{"data-native-card":"email",className:oe&&!He?"contents":"hidden",children:e.jsx(Vs,{refreshKey:W,onConnection:P})}),e.jsx("div",{"data-native-card":"postiz",className:wn?"contents":"hidden",children:e.jsx(gi,{refreshKey:W,onConnection:Ne})}),Nn.map(i=>vt(i))]})]}),h!=="connected"&&G===null&&e.jsx("div",{className:q(h==="all"&&"mt-8 border-t border-hairline/30 pt-6",h==="mcp"&&"pt-1"),children:e.jsx(Gn,{embedded:!0,hideHosted:h==="all"})})]}),be.changing&&e.jsx(Gs,{app:l?.find(i=>i.slug===be.changing)?.label??be.changing,slug:be.changing,bots:be.bots,onDone:be.done,onDismiss:be.dismiss},be.changing)]})]});function Cn(){const i=Ke.cards.filter(L=>!x(L.slug));if(!kt||i.length===0)return null;const N=Ke.pick==="available"?{label:n(bt?"apps.suggested.picking":"apps.suggested.show"),onClick:nt}:Ke.pick==="needs-key"&&!o?{label:n("apps.suggested.addKey"),onClick:()=>{st(),s(Tn("jev"))}}:void 0;return e.jsx(Rt,{id:"apps-section-suggested",title:n("apps.section.suggested"),note:Ke.pick==="picked"?n("apps.suggested.picked"):void 0,viewAll:N,children:i.map(L=>vt(L))})}function vt(i){const N=v[i.slug],L=N?.status&&/^(expired|failed)$/i.test(N.status),O=N?.pending&&!L,_=O&&!L?w[i.slug]:void 0,J=Gt(_),de=N?.accounts??[],ve=i.noAuth===!0||N?.connected===!0&&!de.length&&!O&&!L,Ae=ct(N),ge=O?void 0:Ws(N),ws=Q===i.slug&&!ve,_e=ye===i.slug,wt=t.config?.managedPolicy,Nt=wt?.apps&&!wt.apps.allowAll&&!wt.apps.allowlist.includes(i.slug)?n("policy.managedBy",{organization:wt.organizationName}):On(R,i.slug)?n("connectors.selfHostOnlyReason"):null,ot=Ae||ve?Li(t.bots,t.instances,i.slug):[],At=n("apps.usedBy",{names:ot.map(M=>M.name).join(", ")}),Sn=Nt??(O?J?n("connectors.finishSetup"):n("connectors.finishSetupOrDisconnect"):ge?n("connectors.signedOut"):L&&!de.length?n("connectors.authExpired"):Bn(i));return e.jsxs("div",{"data-app-tile":i.slug,className:"flex min-w-0 flex-col rounded-xl px-2 py-2 transition-colors hover:bg-raised/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(In,{card:i,className:"size-10 shrink-0 rounded-[8px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold leading-5 text-ink",children:i.label}),Ae&&!O&&e.jsx(Ze,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")}),ot.length>0&&e.jsx("span",{className:"ms-1 flex shrink-0 -space-x-1.5 rtl:space-x-reverse",title:At,"aria-label":At,role:"img",children:ot.slice(0,3).map(M=>e.jsx("span",{"data-used-by-avatar":M.id,className:"flex size-5 shrink-0 items-center justify-center overflow-hidden rounded-full bg-menu ring-2 ring-menu",children:e.jsx(pa,{bot:M,size:Mi,animated:!1})},M.id))})]}),e.jsx("div",{className:"truncate text-[13px] leading-[18px] text-ink-secondary",title:Sn,children:Sn})]}),e.jsx("button",{type:"button",disabled:!j||z!=="ready"||_e||ve||!!Nt,title:Nt??void 0,onClick:()=>{if(O&&!L){const M=Gt(_);M?(U(null),Mt(M).catch(Ie=>U(Ie.message))):ze(i.slug)}else ge?ze(i.slug,ge.alias,ge):(he(M=>M===i.slug?null:i.slug),te(""))},className:"inline-flex h-7 min-w-[64px] shrink-0 items-center justify-center gap-2 rounded-full bg-control/80 px-3 text-[13px] font-medium leading-5 text-ink transition-colors hover:bg-raised-hover disabled:opacity-40",children:Nt?n("connectors.selfHostOnly"):_e?e.jsx(ie,{size:14,className:"animate-spin"}):Zs(z,{busy:_e,included:ve,canContinue:!!_,pending:O,reconnect:!!ge,hasAccounts:de.length>0,failed:!!L})})]}),e.jsxs("div",{className:"ps-[52px]",children:[J&&e.jsx("a",{href:J,target:"_blank",rel:"noopener noreferrer",onClick:M=>{Gt(_)||(M.preventDefault(),ze(i.slug))},className:"mt-1.5 inline-block text-[12px] text-accent-text underline underline-offset-2",children:n("connectors.openAuthorizationPage")}),Ae&&!O&&e.jsxs("div",{"data-app-bots":i.slug,className:"mt-1.5 flex min-w-0 items-center gap-2 text-[12px] leading-5 text-ink-secondary",children:[e.jsx("span",{className:"min-w-0 truncate",title:ot.length?At:void 0,children:ot.length?At:n("apps.usedByNone")}),be.canChange&&e.jsx("button",{type:"button",onClick:()=>be.change(i.slug),"aria-label":n("apps.whichBots",{app:i.label}),className:"ms-auto shrink-0 rounded-full px-2 text-[12px] font-medium leading-5 text-accent-text transition-colors hover:bg-raised-hover",children:n("apps.usedByChange")})]}),de.length>0&&e.jsx("div",{className:"mt-1.5 space-y-0.5",children:de.map(M=>{const Ie=/^active$/i.test(M.status),Je=Ys(M)&&M.id!==ge?.id;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[12px] leading-5",children:[Ie?e.jsx(Ze,{size:12,className:"shrink-0 text-success"}):e.jsx("span",{className:"size-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 truncate text-ink",title:`${M.alias?`${M.id} · `:""}${M.status.toLowerCase()}`,children:[M.alias||M.id,e.jsxs("span",{className:"text-ink-secondary",children:[" · ",M.status.toLowerCase()]})]}),Je&&e.jsx("button",{type:"button",disabled:_e,onClick:()=>{ze(i.slug,M.alias,M)},className:"ms-auto shrink-0 rounded-full px-2 text-[12px] font-medium leading-5 text-accent-text transition-colors hover:bg-raised-hover disabled:opacity-40","aria-label":n("connectors.reconnectAria",{account:M.alias||M.id,service:i.label}),children:n("connectors.action.reconnect")}),e.jsx("button",{type:"button",disabled:_e,onClick:()=>{window.confirm(Ti(i.label,M))&&a(i.slug,M.id)},className:q("shrink-0 rounded-full px-2 text-[12px] font-medium leading-5 text-ink-secondary transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40",!Je&&"ms-auto"),"aria-label":n("connectors.disconnectAria",{account:M.alias||M.id,service:i.label}),children:n("connectors.disconnect")})]},M.id)})}),(N?.connected||ve)&&(()=>{const M=Oi(t.bots,t.instances,i.slug);if(!M.length)return null;const Ie=M.slice(0,4).map((Je,Ns)=>e.jsxs("span",{children:[Ns>0&&", ",e.jsx("button",{type:"button",onClick:()=>{st(),en(s,"access",{botId:Je.id,page:"apps"})},className:"font-medium text-ink underline underline-offset-2 hover:text-accent-text",children:Je.name})]},Je.id));return e.jsxs("div",{className:"mt-1.5 text-[12px] leading-relaxed text-ink-secondary",children:[e.jsx("span",{children:n("connectors.grants.limited",{count:M.length})})," ",Ie,M.length>4&&e.jsx("span",{children:n("connectors.grants.more",{count:M.length-4})})]})})(),ws&&e.jsxs("form",{className:"mt-2 flex items-center gap-2",onSubmit:M=>{M.preventDefault();const Ie=ee.trim();if(!Ie){U({key:"connectors.aliasRequired"});return}ze(i.slug,Ie)},children:[e.jsx("input",{autoFocus:!0,value:ee,maxLength:64,onChange:M=>te(M.target.value),placeholder:n("connectors.aliasPlaceholder"),"aria-label":de.length>0?n("connectors.aliasAriaAnother",{service:i.label}):n("connectors.aliasAriaNew",{service:i.label}),className:"h-8 min-w-0 flex-1 rounded-full bg-inset px-3 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{type:"submit",disabled:_e||!ee.trim(),className:"inline-flex h-7 shrink-0 items-center rounded-full bg-accent px-3 text-[13px] font-medium leading-5 text-accent-ink disabled:opacity-40",children:n("connectors.action.continue")})]})]})]},i.slug)}}export{ts as APPS_PREVIEW_COUNT,Ji as PluginsPanel,In as ServiceIcon,Mi as USED_BY_AVATAR_SIZE,Li as botsUsingService,Oi as botsWithLimitedServiceTools,Pi as connectorSetupNotice,Ti as disconnectAccountConfirmation,Bi as hostedShown,Ds as preloadConnectedApps};
|