limixbot 0.3.1 → 0.3.3
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-O6Su2c-u.js → ActivityPanel-CagbdBtd.js} +1 -1
- package/dist/assets/{App-Bcey1qup.js → App-DFjF9FvF.js} +119 -119
- package/dist/assets/{AppEventEditor-BlJGPJ3Z.js → AppEventEditor-BgX3KO6T.js} +1 -1
- package/dist/assets/BotSettingsDialog-ieeszW_3.js +16 -0
- package/dist/assets/{BrowserPanel-BWcb5CXi.js → BrowserPanel-BB3qz5lN.js} +2 -2
- package/dist/assets/{BrowserProfilesManager-dKHyQotG.js → BrowserProfilesManager-CVdcfOF8.js} +1 -1
- package/dist/assets/CloudAddDialog-Bl1bRrYD.js +1 -0
- package/dist/assets/{ComputerFilesPane-wgtikCgi.js → ComputerFilesPane-piKNDkt6.js} +1 -1
- package/dist/assets/ComputerPanel-COQweEJR.js +2 -0
- package/dist/assets/{DataPanel-BlBidswi.js → DataPanel-DdHxcsUa.js} +1 -1
- package/dist/assets/{DesktopViewer-D7JeLJbi.js → DesktopViewer-BNIgo9Nm.js} +1 -1
- package/dist/assets/{FilesView-CNkEKeZB.js → FilesView-Dy1gKmcM.js} +1 -1
- package/dist/assets/{GrokMoveDialog-fyBulzXL.js → GrokMoveDialog-CUnJWZi7.js} +6 -6
- package/dist/assets/{InspectorPanel-Cut2OqiB.js → InspectorPanel-CWdxtHne.js} +2 -2
- package/dist/assets/{KeyboardShortcutsModal-DnxUB4cd.js → KeyboardShortcutsModal-6FMUgbpC.js} +1 -1
- package/dist/assets/{LiveDesktop-CnbyXW61.js → LiveDesktop-CDbI9dPy.js} +1 -1
- package/dist/assets/LocalVmWorkspace-CslSGvNI.js +1 -0
- package/dist/assets/{MacLocalControl-CpswtfCI.js → MacLocalControl-CwHtEWES.js} +1 -1
- package/dist/assets/MarkdownFilePreview-DrdGFCnN.js +1 -0
- package/dist/assets/{MenuMotion-VeZ_fZ8M.js → MenuMotion-IQitGKH4.js} +1 -1
- package/dist/assets/{NewBotDialog-rBjsSV0e.js → NewBotDialog-V2wMpLPn.js} +1 -1
- package/dist/assets/PhoneAppDialog-DmBPVDxr.js +1 -0
- package/dist/assets/{PlacesRail-C_3Mh4C8.js → PlacesRail-v1XIqiBG.js} +9 -9
- package/dist/assets/{PluginsPanel-CMsgWSNg.js → PluginsPanel-CMARnTMq.js} +2 -2
- package/dist/assets/{ProIntroduction-6ByF2_US.js → ProIntroduction--jIMb4bL.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-D4X4rHMQ.js → RemoteAgentSettingsPanel-Co34aJHb.js} +1 -1
- package/dist/assets/{RoomPanel-mg6M04wy.js → RoomPanel-ClyWQx9x.js} +2 -2
- package/dist/assets/{RoutinesPage-DomuZMUT.js → RoutinesPage-DRwSDyGu.js} +1 -1
- package/dist/assets/SettingsModal-CHa_Zc-J.js +11 -0
- package/dist/assets/{ShareTeamDialog-B_0Gr8Mq.js → ShareTeamDialog-BQ9h2Rd2.js} +1 -1
- package/dist/assets/{SignedInSites-C-eqeBxT.js → SignedInSites-B16Ruhd0.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-DpXOFOQr.js → TeamLibraryPanel-NwC4Fc9C.js} +1 -1
- package/dist/assets/TeamMapPage-DabJFxkf.js +1 -0
- package/dist/assets/{TriggersPage-D7RDjrjV.js → TriggersPage-Cn_f8AcZ.js} +1 -1
- package/dist/assets/{VisibilitySection-Bimhk6c5.js → VisibilitySection-DyGNmx9n.js} +1 -1
- package/dist/assets/{WebhookTrigger-D5c2bPJu.js → WebhookTrigger-C-9-FE3w.js} +1 -1
- package/dist/assets/WorksOnGrid-M_5NkZch.js +1 -0
- package/dist/assets/{abnfDiagram-YUKMZFIV-D7az-C1J.js → abnfDiagram-YUKMZFIV-CBzJU2O6.js} +1 -1
- package/dist/assets/{activity-W_ia4q-Y.js → activity-bd7MWK8m.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-B2IC9169.js → architectureDiagram-47P4ROYG-DVR1DP3v.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-FnweBzU4.js → blockDiagram-E7TT5TSB-BYqUHhoh.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-rxgwSaAP.js → c4Diagram-CRA5TL53-BtQERHwr.js} +1 -1
- package/dist/assets/{calendar-days-wM1DS-Cu.js → calendar-days-YMHxUvlg.js} +1 -1
- package/dist/assets/channel-D6e78p3W.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-B7yhqEe8.js → chunk-2Q5K7J3B-Cwf_xeHP.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-Sw6phnaf.js → chunk-5VM5RSS4-Doo-zxI4.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-CheglUSd.js → chunk-7TKQ45FW-CD2AgrRj.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-CswkqPkf.js → chunk-AW2ZBBNX-e5OuWeq_.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-DeN53o4S.js → chunk-FVRAUYC3-C8jo43it.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-CCZ_Udf0.js → chunk-HTAEGDNF-DLsD4agj.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-nG1rfC9P.js → chunk-JWPE2WC7-UZDUbeTy.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-Bh_TxL0e.js → chunk-KQW6MTUR-DR9SuVX3.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CLIJBS-V.js → chunk-XXDRQBXY-DwEl4815.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-B04FntQx.js → classDiagram-v2-K4WV4PDN-CQZho8e0.js} +1 -1
- package/dist/assets/{coins-81htcDNx.js → coins-DpzGN3sd.js} +1 -1
- package/dist/assets/{core-BLAzrox0.js → core-BNopzNRl.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-D9PAieWF.js → cose-bilkent-JH36ORCC-DUZ9OWzu.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-BAC2DRg5.js → cynefin-EF2NZ3EQ-DVHnJdjN.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-Cc3k_C-5.js → cynefinDiagram-3GCD6N5R-dYhbIkRt.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-CpbzxBGo.js → dagre-W4DXFKR2-DqJNpw5w.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-d22NGVzG.js → diagram-2UJZ2QOL-DKNDqAnE.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-BFTJTNpN.js → diagram-OVF4WLC6-DENMVM-d.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-CA_YgAo3.js → diagram-PFPMY2P6-CrRFeR5V.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-CCsuWndY.js → diagram-UMYRVEAY-B5w-desO.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-Bcwhmpgl.js → diagram-YEKJPTXX-C7AVX3MB.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-Bs1iIjhq.js → diagram-ZIFT7M5P-BgkTRwwr.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-CFr96fLM.js → ebnfDiagram-VR2GEFS7-yY_2KNsK.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-DSdTG_hW.js → elk-IJKZMXRS-xWtfkoqT.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-BGdMdwi1.js → erDiagram-O2IAPWRE-BMM4saPI.js} +1 -1
- package/dist/assets/{file-up-DvGMRF5I.js → file-up-Bl7ViNTL.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-DL25A20O.js → flowDiagram-OXPTDLAJ-BCRe8i6T.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-DQaNIRGv.js → ganttDiagram-R7TSEDQI-COBrcDi7.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-B6ypA1ZF.js → gitGraphDiagram-XJZIOB7I-Dc4RKydD.js} +1 -1
- package/dist/assets/{import-name-Cdh9ZlkK.js → import-name-DA_MmEsd.js} +1 -1
- package/dist/assets/{index-BaW02tJl.js → index-BXLNny-w.js} +1 -1
- package/dist/assets/index-CwYJ9TX8.js +2 -0
- package/dist/assets/{index-CxcnLo81.js → index-D6huutPz.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-8YbtI4S4.js → infoDiagram-5W2HQ5XZ-BV8RRI_4.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-DYpDWk2K.js → ishikawaDiagram-K3B6WC7H-H-XILdGm.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-BUd8Vnbq.js → journeyDiagram-COXZFDF6-ChLduKEj.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-AywqsEBB.js → kanban-definition-P3RFRI5V-FSZ9F3JH.js} +1 -1
- package/dist/assets/{mcp-servers-Bu5RuYBT.js → mcp-servers-CYvHVOYi.js} +1 -1
- package/dist/assets/{mermaid.core-B5yiNmEY.js → mermaid.core-BRsJ02Pz.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-DRALSCg6.js → mindmap-definition-LZFPQGKD-TWHzZjNT.js} +1 -1
- package/dist/assets/{minimize-CWsi9mRL.js → minimize-BYscOtPM.js} +1 -1
- package/dist/assets/{monitor-c1mf38zt.js → monitor-DFEzCfQk.js} +1 -1
- package/dist/assets/{new-bot-mp2gi3ed.js → new-bot-_oEUbcDw.js} +2 -2
- package/dist/assets/{org-library-Bi3EieNo.js → org-library-CapoiPaN.js} +1 -1
- package/dist/assets/{package-format-CaPiTXn3.js → package-format-Cn4nABBW.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-Drj_UJz5.js → pegDiagram-BGZESJAR-LQWOF7IE.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-CL7MryRt.js → pieDiagram-CAPJLFHJ-BRXp4qFw.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-BvWxqPJn.js → quadrantDiagram-GDMTTRAM-DyIdGBZo.js} +1 -1
- package/dist/assets/{rail-DApFzTxo.js → rail-Du7tlPwj.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-CGfR0UsO.js → railroadDiagram-SM67HX2B-BrL1MhW1.js} +1 -1
- package/dist/assets/{remote-desktop-panel-B4uIIoh3.js → remote-desktop-panel-DbxYe3uv.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-CJq96anP.js → requirementDiagram-X7JNWC4A-DTYjaC8j.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-BdZSA65i.js → sankeyDiagram-UM26HJRW-BR9dASO5.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B5W6udgn.js → sequenceDiagram-ZO4K6R2Y-BR1k8h2_.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CuKCNVLn.js → sizeCapture-INFHLROL-u8zOvZVi.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-C7mAgpvB.js → stateDiagram-v2-TBUQTH76-mQ64BAFv.js} +1 -1
- package/dist/assets/styles-BlayaJti.js +23 -0
- package/dist/assets/{swimlanes-N4OXWK64-D-mimAU7.js → swimlanes-N4OXWK64-CmzC3Mu0.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Coei7rJr.js +8 -0
- package/dist/assets/{team-share-wuAG66b7.js → team-share-C3w1L3WL.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-C5prnOXi.js → timeline-definition-YOQAKGHF-9aPCRsK2.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-BC-9KKSF.js → usecaseDiagram-VIAY4XPW--ngAouwr.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-LCNTQN9e.js → vennDiagram-BLWOH2XV-C3zKxuAB.js} +1 -1
- package/dist/assets/vi-uLErku_e.js +15 -0
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-CtWGEzVU.js → wardleyDiagram-YMQ3BMBF-CZWsQPSF.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-DadPRdBp.js → xychartDiagram-TAQBALBS-BTcsDP6v.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/rail.html +4 -4
- package/dist-server/index.js +426 -421
- package/dist-server/openmausbot.js +22 -22
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +22 -22
- package/dist-server/server/index.js +1 -1
- package/dist-server/server/limix-skill-folder.js +72 -0
- package/dist-server/server/routes/bot-skills.js +2 -1
- package/package.json +1 -1
- package/dist/assets/BotSettingsDialog-PiCk9us7.js +0 -16
- package/dist/assets/CloudAddDialog-D1ZSbkxV.js +0 -1
- package/dist/assets/ComputerPanel-Cyj53a7W.js +0 -2
- package/dist/assets/LocalVmWorkspace-D9xFPGF0.js +0 -1
- package/dist/assets/MarkdownFilePreview-V-y-0ksi.js +0 -1
- package/dist/assets/PhoneAppDialog-DAW1N-hM.js +0 -1
- package/dist/assets/SettingsModal-Dd9l0b2C.js +0 -11
- package/dist/assets/TeamMapPage-CIQPYaxL.js +0 -1
- package/dist/assets/WorksOnGrid-PZ-caKHg.js +0 -1
- package/dist/assets/channel-BQyC_QMX.js +0 -1
- package/dist/assets/index-oVds-_Vz.js +0 -2
- package/dist/assets/module-DCUsy2BQ.js +0 -3
- package/dist/assets/styles-C_rlkDrt.js +0 -23
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Dn31PG7h.js +0 -8
- package/dist/assets/vi-NX09tr5q.js +0 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{c as dn,t as n,r as d,j as e,X as es,
|
|
1
|
+
import{c as dn,t as n,r as d,j as e,X as es,aa as ts,a as G,f as Ye,b as Bt,au as ws,S as Ns,i as _t}from"./styles-BlayaJti.js";import{S as un,n as w,u as et,eu as As,ev as Cs,ew as Ss,ex as ht,D as Rs,ey as Es,ez as zs,l as Is,G as Sn,eA as Ts,eB as Os,cL as Bs,T as Ps,ah as Xt,br as Ms,J as en,eC as Rt,eD as ns,eE as Et,eF as ss,an as as,eG as zt,eH as Ls,eI as is,eJ as It,eK as os,eL as Us,eM as Rn,eN as $s,$ as cs,eO as Nt,eP as Fs,eQ as Ks,eR as Ds,eS as Qs,eT as Hs,eU as ct,eV as En,eW as Js,eX as zn,e7 as In,eY as _s,eZ as Vs,e_ as Gs,e$ as Vt,f0 as qs,f1 as Zs,f2 as Ws,f3 as Ys,f4 as Xs,f5 as ea,f6 as ta,f7 as na,f8 as sa,f9 as aa,fa as ia}from"./App-DFjF9FvF.js";import{L as ae,P as rs,Y as oa,a as ca,z as pn,E as ra,a0 as la,B as da}from"./PlacesRail-v1XIqiBG.js";import{u as Gt}from"./mcp-servers-CYvHVOYi.js";import{C as ls,R as tn}from"./MenuMotion-IQitGKH4.js";import{u as ua}from"./ProIntroduction--jIMb4bL.js";import"./index-CwYJ9TX8.js";import"./monitor-DFEzCfQk.js";const pa=[["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"}]],ma=dn("phone-call",pa);const ha=[["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"}]],xa=dn("radio-tower",ha);const fa=[["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"}]],qt=dn("server-cog",fa),ga=new Set(["twitter","x"]);function Tn(t,s){return t!=="managed"||!ga.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 ba=5,ya=3,Tt=4;function ka(t,s=ba,c=[]){const o=new Map;for(const g of t)for(const k of new Set(g.categories??[]))o.set(k,(o.get(k)??0)+1);const r=[...o].sort((g,k)=>k[1]-g[1]||g[0].localeCompare(k[0])).map(([g])=>g),l=c.filter(g=>r.indexOf(g)>=s),y=[...r.slice(0,Math.max(0,s-l.length)),...l];return{inline:y,more:r.filter(g=>!y.includes(g))}}function nn(t,s){return s===null||(t.categories??[]).includes(s)}function ja(t,s,c){const o=[],r=t.filter(l=>s(l.slug));r.length&&o.push({kind:"connected",cards:r});for(const l of c.slice(0,ya)){const y=t.filter(g=>!s(g.slug)&&nn(g,l));y.length&&o.push({kind:"category",category:l,cards:y.slice(0,Tt),more:y.length>Tt})}return o.push({kind:"all",cards:t.filter(l=>!s(l.slug))}),o}const va={productivity:"productivity","developer tools":"developerTools",communication:"communication",files:"files","sales and crm":"salesCrm",design:"design",marketing:"marketing",analytics:"analytics",social:"social"},wa={"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=va[t.trim().toLowerCase()];return s?n(`apps.category.${s}`):t}function On(t){const s=wa[t.label.trim().toLowerCase()];return s?n(`apps.catalog.${s}.blurb`):t.blurb}function Na({server:t,disabled:s,onSaved:c}){const[o,r]=d.useState(!1),[l,y]=d.useState(null);if(typeof t.apps!="boolean"||t.apps&&t.hasApps!==!0)return null;const g=t.apps,k=async()=>{r(!0),y(null);try{const p=await w(`/api/mcp/servers/${encodeURIComponent(t.name)}`,{method:"PATCH",body:JSON.stringify({apps:!g})});c(p.servers??[])}catch(p){y(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")})]}),o&&e.jsx(ae,{"aria-hidden":"true",size:13,className:"animate-spin text-ink-secondary"}),e.jsx(un,{checked:g,disabled:s||o,onClick:()=>{k()},"aria-label":n("mcp.apps.toggleAria",{name:t.name}),className:"disabled:opacity-40"})]})}function Bn({feature:t,enabled:s,prefix:c}){const{dispatch:o}=et(),[r,l]=d.useState(!1),[y,g]=d.useState(!1),k=async()=>{if(!r){l(!0),g(!1);try{const p=await w("/api/config",{method:"PATCH",body:JSON.stringify({features:{[t]:!s}})});o({type:"configStatus",config:p})}catch{g(!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(`${c}.title`)}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:n(`${c}.desc`)}),y&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:n("mcp.claude.error")})]}),e.jsx(un,{checked:s,"aria-label":n(`${c}.aria`),disabled:r,onClick:()=>{k()},className:"mt-0.5 shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}function Aa(){const{state:t}=et();return e.jsxs(e.Fragment,{children:[e.jsx(Bn,{feature:"claudeUserMcp",enabled:As(t.config),prefix:"mcp.claude"}),e.jsx(Bn,{feature:"claudeUserSkills",enabled:Cs(t.config),prefix:"mcp.claudeSkills"})]})}function Pn({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 sn=/^https?:\/\//i,ds=/^[A-Za-z_][A-Za-z0-9_]*=/,Ca=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+:/,Sa=new Set(["npx","uvx","bunx"]),Ra=new Set(["pnpm","yarn"]);function Ea(t,s=[]){const c=za(t).trim();if(!c)return null;try{const o=/^[{[]/.test(c)?La(c):sn.test(c)&&!/\s/.test(c)?[mn(void 0,c,void 0,[])]:Ia(c);return{ok:!0,servers:Da(o,s)}}catch(o){if(o instanceof me)return{ok:!1,error:o.key};throw o}}function za(t){return t.replace(/[“”„]/g,'"').replace(/[‘’]/g,"'").replace(/(^|\s)[–—](?=[a-z])/g,"$1--")}function us(t){const s=[];let c=[],o="",r=!1;const l=()=>{r&&c.push(o),o="",r=!1},y=()=>{l(),c.length&&s.push(c),c=[]},g=k=>t[k]===`
|
|
2
2
|
`?1:t[k]==="\r"&&t[k+1]===`
|
|
3
3
|
`?2:0;for(let k=0;k<t.length;k+=1){const p=t[k];if(p==="\\"||(p==="`"||p==="^")&&g(k+1)){const h=g(k+1);if(h){k+=h;continue}k+1<t.length&&(o+=t[k+1],r=!0,k+=1);continue}if(p==="'"){const h=t.indexOf("'",k+1);if(h<0)throw new me("mcp.paste.notRecognized");o+=t.slice(k+1,h),r=!0,k=h;continue}if(p==='"'){let h=k+1;for(;h<t.length&&t[h]!=='"';h+=1){if(t[h]==="\\"&&h+1<t.length){const A=g(h+1);if(A){h+=A;continue}if('"\\$`'.includes(t[h+1])){o+=t[h+1],h+=1;continue}}o+=t[h]}if(h>=t.length)throw new me("mcp.paste.notRecognized");r=!0,k=h;continue}if(p==="$"&&t[k+1]==="("){const h=t.indexOf(")",k+2);if(h<0)throw new me("mcp.paste.notRecognized");o+=t.slice(k,h+1),r=!0,k=h;continue}if(p==="#"&&!r){for(;k+1<t.length&&t[k+1]!==`
|
|
4
4
|
`;)k+=1;continue}if(p===`
|
|
5
5
|
`||p===";"){y();continue}if(p==="&"&&t[k+1]==="&"){y(),k+=1;continue}if(/\s/.test(p)){l();continue}o+=p,r=!0}return y(),s}function Ia(t){const s=us(t);if(!s.length)throw new me("mcp.paste.notRecognized");return s.map(c=>{const o=c[0]==="$"||c[0]===">"?c.slice(1):c;return o[0]==="claude"&&o[1]==="mcp"&&o[2]==="add"?Ta(o.slice(3)):o[0]==="claude"&&o[1]==="mcp"&&o[2]==="add-json"?Oa(o.slice(3)):Ba(o)})}function Ta(t){let s,c;const o=[],r=[],l=[];let y=[];for(let h=0;h<t.length;h+=1){const A=t[h];if(A==="--"){y=t.slice(h+1);break}const Q=/^(--[a-z][a-z-]*|-[a-zA-Z])(?:=([\s\S]*))?$/.exec(A);if(!Q){l.push(A);continue}const C=()=>Q[2]??t[++h]??"",M=(J,K)=>{for(;h+1<t.length&&J.test(t[h+1])&&!sn.test(t[h+1]);)K.push(t[++h])};switch(Q[1]){case"--transport":case"-t":s=C().toLowerCase();break;case"--header":case"-H":o.push(C()),Q[2]===void 0&&M(Ca,o);break;case"--env":case"-e":r.push(C()),Q[2]===void 0&&M(ds,r);break;case"--client-id":c=C();break;case"--scope":case"-s":case"--callback-port":C();break}}const[g,k,...p]=[...l,...y];if(!g||!k)throw new me("mcp.paste.incomplete");if(s!=="stdio"&&(s==="http"||s==="sse"||sn.test(k))){const h=mn(g,k,s==="sse"?"sse":s==="http"?"http":void 0,o.map(Ua));return c?{...h,oauthClientId:c}:h}return{transport:"stdio",name:ht(g),command:k,args:p,env:r.map(hn)}}function Oa(t){const s=[];for(let l=0;l<t.length;l+=1){const y=t[l];if(y==="--scope"||y==="-s"){l+=1;continue}y.startsWith("-")&&!y.startsWith("{")||s.push(y)}const[c,o]=s;if(!c||!o)throw new me("mcp.paste.incomplete");const r=an(c,ps(o));if(!r)throw new me("mcp.paste.notRecognized");return r}function Ba(t){let s=0;const c=[];for(;s<t.length&&ds.test(t[s]);)c.push(hn(t[s++]));const[o,...r]=t.slice(s);if(!o)throw new me("mcp.paste.notRecognized");if(o==="docker"&&r[0]==="run")return Ma(r,c);if(!Sa.has(o)&&!(Ra.has(o)&&r[0]==="dlx"))throw new me("mcp.paste.notRecognized");const l=r.find((y,g)=>!y.startsWith("-")&&!(g===0&&y==="dlx"));if(!l)throw new me("mcp.paste.incomplete");return{transport:"stdio",name:fn(l),command:o,args:r,env:c}}const Pa=new Set(["-i","-t","-it","-ti","-d","--rm","--init","--interactive","--tty","--detach","--privileged"]);function Ma(t,s){const c=[t[0]];let o;for(let r=1;r<t.length;r+=1){const l=t[r];if(o||!l.startsWith("-"))o??=l,c.push(l);else if((l==="-e"||l==="--env")&&r+1<t.length){const y=t[++r],g=y.split("=")[0];s.push(y.includes("=")?hn(y):{name:g,value:"",gap:{kind:"variable",names:[g],before:"",after:""}}),c.push(l,g)}else l.includes("=")||Pa.has(l)||r+1>=t.length?c.push(l):c.push(l,t[++r])}if(!o)throw new me("mcp.paste.incomplete");return{transport:"stdio",name:fn(o.replace(/:[^/:]*$/,"")),command:"docker",args:c,env:s}}function ps(t){try{return JSON.parse(t)}catch{throw new me("mcp.paste.badJson")}}const ut=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function La(t){const s=ps(t);if(!ut(s))throw new me("mcp.paste.notRecognized");const c=an(typeof s.name=="string"?s.name:void 0,s);if(c)return[c];const o=ut(s.mcpServers)?s.mcpServers:ut(s.servers)?s.servers:s,r=Object.entries(o).map(([l,y])=>an(l,y));if(!r.length||r.some(l=>!l))throw new me("mcp.paste.notRecognized");return r}const Mn=t=>ut(t)?Object.entries(t).filter(s=>typeof s[1]=="string"):[];function an(t,s){if(!ut(s))return null;const c=typeof s.url=="string"?s.url:typeof s.serverUrl=="string"?s.serverUrl:void 0,o=typeof s.type=="string"?s.type.toLowerCase():"";if(c!==void 0){const p=Mn(s.headers).map(([h,A])=>Ot(h,A));return mn(t,c,o==="sse"?"sse":o?"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,...y]=r.length?[s.command.trim()]:us(s.command)[0]??[s.command],g=Mn(s.env).map(([p,h])=>Ot(p,h)),k=[...y,...r];return{transport:"stdio",name:t?ht(t):fn(k.find(p=>!p.startsWith("-"))??l??""),command:l,args:k,env:g}}function mn(t,s,c,o){const r=xn(s);return{transport:"remote",name:t?ht(t):Ka(s),type:c??(/\/sse\/?(?:[?#]|$)/i.test(s)?"sse":"http"),url:s,...r?{urlGap:r}:{},headers:o}}function Ua(t){const s=t.indexOf(":");if(s<=0)throw new me("mcp.paste.badPair");return Ot(t.slice(0,s).trim(),t.slice(s+1).trim())}function hn(t){const s=t.indexOf("=");if(s<=0)throw new me("mcp.paste.badPair");return Ot(t.slice(0,s),t.slice(s+1))}function Ot(t,s){const c=xn(s);return c?{name:t,value:"",gap:c}:{name:t,value:s}}const $a=/\$\{([^}]*)\}|\$\(([^)]*)\)|\$([A-Za-z_][A-Za-z0-9_]*)/g,Fa=/<([^<>\s][^<>]{0,63})>|\b(YOUR[_-][A-Za-z0-9_-]+|your[_-][a-z0-9_-]+)\b/g;function xn(t){const s=[];for(const l of t.matchAll($a)){const y=(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:y||l[0],kind:"variable"})}for(const l of t.matchAll(Fa))s.some(y=>l.index<y.end&&l.index+l[0].length>y.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 c=[...new Set(s.map(l=>l.name))],o=s.some(l=>l.kind==="variable")?"variable":"placeholder",r=s.length===1?s[0]:null;return{kind:o,names:c,before:r?t.slice(0,r.start):"",after:r?t.slice(r.end):""}}const ms=new Set(["www","mcp","api","server","servers","app","remote","sse","gateway","co","com","org","net","ac","gov"]);function Ka(t){let s;try{s=new URL(t).hostname}catch{return""}if(/^[\d.]+$/.test(s)||s.includes(":"))return"server";const c=s.split(".").filter(Boolean);return c.length>1&&c.pop(),ht(c.filter(o=>!ms.has(o)).at(-1)??c.at(-1)??"server")}function fn(t){const s=t.replace(/(?!^)@[^/@]*$/,"").split("/"),c=s.at(-1)??t,o=c.replace(/^(?:mcp-server-|server-|mcp-)/,"").replace(/(?:-mcp-server|-mcp|-server)$/,""),r=(s.at(-2)??"").replace(/^@/,"");return ht(ms.has(o)&&r?r:o||c)||"server"}function Da(t,s){const c=new Set(s);return t.map(o=>{let r=o.name||"server";if(c.has(r))for(let l=2;c.has(r);l+=1)r=Ss(`${o.name.slice(0,29)}-${l}`);return c.add(r),r===o.name?o:{...o,name:r}})}const Qa=2e6;function Ha(t){const s=t.trim(),o=/^\d{1,3}([\s,._ '])\d{3}(?:\1\d{3})*$/.test(s)?s.replace(/\D/g,""):s;return o?!/^\d+$/.test(o)||Number(o)>Qa?{ok:!1,error:{key:"mcp.err.resultBudget"}}:{ok:!0,value:Number(o)}:{ok:!0,value:void 0}}function Ln(t){return t.resultBudget===void 0?"":String(t.resultBudget)}function Ja(t,s){const c=Ha(t);if(!c.ok)return c;const o=s();return!o.ok||c.value===void 0?o:{ok:!0,body:{...o.body,resultBudget:c.value}}}function _a({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:c=>s(c.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 Un=0;function Be(t={name:"",value:""}){return Un+=1,{id:Un,...t}}function Xe(){return{name:"",transport:"remote",command:"",args:"",env:[Be()],type:"http",url:"",headers:[Be()],oauthClientId:"",oauthClientSecret:"",oauthScopes:"",oauthForgetSecret:!1,resultBudget:""}}const $n=t=>t.length?t.map(s=>Be({name:s,value:"",saved:!0})):[Be()],Fn=t=>t.length?t.map(s=>Be({...s})):[Be()];function Va(t){return pe(t)?{...Xe(),name:t.name,type:t.type,url:t.url,headers:$n(t.headerKeys),oauthClientId:t.oauth?.clientId??"",oauthScopes:t.oauth?.scopes.join(" ")??"",resultBudget:Ln(t)}:{...Xe(),name:t.name,transport:"stdio",command:t.command,args:t.args.join(`
|
|
6
6
|
`),env:$n(t.envKeys),resultBudget:Ln(t)}}function Ga(t){return t.transport==="remote"?{...Xe(),name:t.name,type:t.type,url:t.url,...t.urlGap?{urlGap:t.urlGap}:{},headers:Fn(t.headers),oauthClientId:t.oauthClientId??""}:{...Xe(),name:t.name,transport:"stdio",command:t.command,args:t.args.join(`
|
|
7
7
|
`),env:Fn(t.env)}}function on(t){const s=t.value.trim();if(!t.gap||!s)return t.value;const{before:c,after:o}=t.gap;return c.trim()&&s.toLowerCase().startsWith(c.trim().toLowerCase())?s:`${c}${s}${o}`}const qa=/^[A-Za-z_][A-Za-z0-9_]*$/,Za=/^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/;function Kn(t,s){const c={};for(const o of t){const r=o.name.trim(),l=s==="header"?on(o).trim():on(o);if(!(!r&&!l)){if(!r)return{ok:!1,error:{key:"mcp.err.rowName"}};if(!(s==="header"?Za:qa).test(r))return{ok:!1,error:{key:s==="header"?"mcp.headers.invalidName":"mcp.env.invalidName",params:{key:r}}};if(Object.hasOwn(c,r))return{ok:!1,error:{key:s==="header"?"mcp.headers.duplicate":"mcp.env.duplicate",params:{key:r}}};if(l)c[r]=l;else if(o.saved)c[r]=!0;else return{ok:!1,error:{key:"mcp.err.missingValue",params:{name:r}}}}}return{ok:!0,values:c}}function Wa(t){return t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean)}function Ya(t,s){const c=t.clientId.trim();if(!c)return;const o=t.clientSecret.trim(),r=t.scopes.split(/[\s,]+/).filter(Boolean);return{clientId:c,...o?{clientSecret:o}:s?.clientSecretConfigured&&!t.forgetSecret?{clientSecret:!0}:{},...r.length?{scopes:r}:{}}}function Xa(t,s){const c=t.name.trim();if(t.transport==="remote"){const l=t.url.trim();if(!c||!/^https?:\/\/\S+$/i.test(l))return{ok:!1,error:{key:"mcp.err.nameAndUrl"}};if(xn(l))return{ok:!1,error:{key:"mcp.paste.urlMissing"}};const y=Kn(t.headers,"header");if(!y.ok)return y;const g=Ya({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:y.values,...g?{oauth:g}:{}}}}const o=t.command.trim();if(!c||!o)return{ok:!1,error:{key:"mcp.err.nameAndCommand"}};const r=Kn(t.env,"env");return r.ok?{ok:!0,body:{command:o,args:Wa(t.args),env:r.values}}:r}function Dn(t){if(t.transport!=="remote"||t.oauthClientId.trim())return null;const s=t.headers.filter(c=>c.name.trim());return s.length===1&&on(s[0]).trim()||null}function ei(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 Ge({kind:t,rows:s,onChange:c,valuesOf:o,placeholder:r}){const l=(p,h)=>c(s.map(A=>A.id===p?{...A,...h}:A)),y=t==="header"?":":"=",g=(p,h)=>{const A=h.clipboardData.getData("text"),Q=A.indexOf(y);Q<=0||(h.preventDefault(),l(p.id,{name:A.slice(0,Q).trim(),value:A.slice(Q+1).trim()}))},k=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:h=>l(p.id,{value:h.target.value}),className:Qn});return e.jsxs("div",{className:"space-y-2",children:[s.filter(p=>o==="gaps"?p.gap:o==="named"?p.name.trim():!0).map(p=>e.jsxs("div",{children:[o?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}),k(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:h=>l(p.id,{name:h.target.value}),onPaste:h=>g(p,h),className:`${Qn} max-w-[42%]`}),k(p),e.jsx("button",{type:"button","aria-label":n("mcp.row.remove",{name:p.name.trim()||n("mcp.row.value")}),onClick:()=>c(s.length>1?s.filter(h=>h.id!==p.id):[Be()]),className:"shrink-0 rounded-lg p-2 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(es,{size:14})})]}),p.gap&&!p.value.trim()&&e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-warning",children:ei(p.gap)})]},p.id)),!o&&e.jsxs("button",{type:"button",onClick:()=>c([...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(rs,{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 ti(t){if(t.transport==="stdio")return t.command;try{return new URL(t.url).host}catch{return t.url}}function ni({server:t,fixKeys:s=!1,taken:c,team:o,busy:r,onCancel:l,onSubmit:y}){const g=!t,[k,p]=d.useState(""),[h,A]=d.useState(()=>t?[Va(t)]:[]),[Q,C]=d.useState(null),M=s&&t!==void 0&&pe(t),[J,K]=d.useState(!g&&!M),[H,$]=d.useState(!1),[L,le]=d.useState(null),v=h.length===1?h[0]:null,_=b=>A(f=>f.length===1?[b(f[0])]:f),Z=t&&pe(t)?t.oauth:void 0,he=!!(Z?.clientSecretConfigured&&!v?.oauthForgetSecret),X=o&&g&&v!==null&&Dn(v)!==null,ee=b=>{p(b),le(null);const f=Ea(b,c);C(f&&!f.ok?f.error:null),A(S=>f?.ok?f.servers.map(Ga):J?S.length===1?S:[Xe()]:[])},ye=()=>{const b=[];for(const f of h){const S=Ja(f.resultBudget,()=>Xa(f,t));if(!S.ok){le(S.error);return}const E=X&&H?Dn(f):null;b.push({name:f.name.trim(),body:S.body,...E?{ownKey:E}:{}})}le(null),y(b)},W=!J&&h.some(b=>b.urlGap||b.headers.some(f=>f.gap)||b.env.some(f=>f.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:g?n("mcp.editorNew"):n(M?"mcp.fixKeys.title":"mcp.editorEdit",{name:t.name})}),M&&v&&!J&&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")}),v.headers.some(b=>b.name.trim())?e.jsx(Ge,{kind:"header",valuesOf:"named",placeholder:n("mcp.fixKeys.placeholder"),rows:v.headers,onChange:b=>_(f=>({...f,headers:b}))}):e.jsx(Ge,{kind:"header",rows:v.headers,onChange:b=>_(f=>({...f,headers:b}))})]}),g&&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:k,onChange:b=>ee(b.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"})]}),Q&&e.jsx("p",{role:"alert",className:"mt-2 text-[12px] leading-relaxed text-danger",children:n(Q)}),g&&k.trim()&&h.length>0&&!Q&&e.jsx("p",{role:"status",className:"mt-2 text-[12px] text-ink-secondary",children:v?n("mcp.paste.foundOne",{name:v.name,where:ti(v)}):n("mcp.paste.foundMany",{count:h.length,names:h.map(b=>b.name).join(", ")})}),W&&e.jsx("div",{className:"mt-3 space-y-3",children:h.map((b,f)=>e.jsxs("div",{className:"space-y-3",children:[h.length>1&&(b.urlGap||b.headers.some(S=>S.gap)||b.env.some(S=>S.gap))&&e.jsx("div",{className:"text-[12px] font-medium text-ink",children:b.name}),b.urlGap&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:Ce,children:n("mcp.field.url")}),e.jsx("input",{value:b.url,spellCheck:!1,onChange:S=>A(E=>E.map((U,B)=>B===f?{...U,url:S.target.value}:U)),className:Te}),e.jsx("span",{className:"mt-1 block text-[11px] text-warning",children:n("mcp.paste.urlMissing")})]}),e.jsx(Ge,{kind:"header",valuesOf:"gaps",rows:b.headers,onChange:S=>A(E=>E.map((U,B)=>B===f?{...U,headers:S}:U))}),e.jsx(Ge,{kind:"env",valuesOf:"gaps",rows:b.env,onChange:S=>A(E=>E.map((U,B)=>B===f?{...U,env:S}:U))})]},f))}),(g||M)&&h.length<=1&&e.jsxs("button",{type:"button","aria-expanded":J,onClick:()=>{K(!J),h.length||A([Xe()])},className:"mt-3 inline-flex items-center gap-1 text-[12px] font-medium text-ink-secondary hover:text-ink",children:[J?e.jsx(ts,{size:14}):e.jsx(ls,{size:14})," ",n("mcp.details")]}),J&&v&&e.jsxs("div",{className:"mt-3",children:[g&&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(b=>e.jsx("button",{type:"button",role:"radio","aria-checked":v.transport===b,onClick:()=>_(f=>({...f,transport:b})),className:G("rounded-md px-3 py-1.5 text-[12px] font-medium transition-colors",v.transport===b?"bg-card text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:n(b==="stdio"?"mcp.transport.stdio":"mcp.transport.remote")},b))}),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:!g,value:v.name,maxLength:32,placeholder:"github",className:G(Te,"disabled:opacity-60"),onChange:b=>_(f=>({...f,name:b.target.value.toLowerCase()}))})]}),v.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:!g,value:v.url,spellCheck:!1,placeholder:"https://mcp.example.com/mcp",className:Te,onChange:b=>_(f=>({...f,url:b.target.value}))}),v.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(Rs,{className:"mt-1.5 w-full",value:v.type,onChange:b=>_(f=>({...f,type:b.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:G(Ce,"mb-1.5"),children:n("mcp.field.headerRows")}),e.jsx(Ge,{kind:"header",rows:v.headers,onChange:b=>_(f=>({...f,headers:b}))}),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:Z?n("mcp.oauth.hintRedirect",{uri:Z.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:v.oauthClientId,spellCheck:!1,autoComplete:"off",className:G(Te,"font-mono text-[12px]"),onChange:b=>_(f=>({...f,oauthClientId:b.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:()=>_(b=>({...b,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:v.oauthClientSecret,autoComplete:"new-password",className:G(Te,"font-mono text-[12px]"),placeholder:he?n("mcp.oauth.secretSaved"):n("mcp.oauth.secretOptional"),onChange:b=>_(f=>({...f,oauthClientSecret:b.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:v.oauthScopes,placeholder:"offline_access api://my-app/mcp.read",spellCheck:!1,className:G(Te,"font-mono text-[12px]"),onChange:b=>_(f=>({...f,oauthScopes:b.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:!g,value:v.command,placeholder:"npx",className:Te,onChange:b=>_(f=>({...f,command:b.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:v.args,placeholder:`-y
|
|
8
|
-
@modelcontextprotocol/server-github`,rows:4,className:G(Te,"resize-y font-mono text-[12px]"),onChange:b=>_(f=>({...f,args:b.target.value}))})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("div",{className:G(Ce,"mb-1.5"),children:n("mcp.field.envRows")}),e.jsx(Ge,{kind:"env",rows:v.env,onChange:b=>_(f=>({...f,env:b}))})]})]}),e.jsx(_a,{value:v.resultBudget,onChange:b=>_(f=>({...f,resultBudget:b}))})]})]}),o&&g&&h.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(X&&H?"mcp.team.onlyMeOn":"mcp.team.everyone")}),X&&e.jsxs("label",{className:"flex items-center gap-1.5 text-ink",children:[e.jsx("input",{type:"checkbox",checked:H,onChange:b=>$(b.target.checked)})," ",n("mcp.team.onlyMe")]})]}),L&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:n(L.key,L.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||!h.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(ae,{size:13,className:"animate-spin"})," ",n(g?"mcp.add":"mcp.save")]})]})]})}const si="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",ai="https://platform.postiz.com/settings";function ii(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 pt=[{id:"whop",label:"Whop",url:"https://mcp.whop.com/mcp",icon:{image:si},description:"whop.description",notice:"whop.notice",keywords:"whop checkout memberships"},{id:"agentcard",label:"Agentcard",url:"https://mcp.agentcard.sh/mcp",icon:{glyph:Es},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:zs},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:ma},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:xa},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:oa},description:"agentphone.description",notice:"agentphone.notice",keywords:"agentphone phone number sms text call calls"}];function gn(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 pt.find(c=>{const o=new URL(c.url);return s.origin===o.origin&&(s.pathname===o.pathname||s.pathname===`${o.pathname}/`)})}function Hn(t,s){const c=new Set(s.map(r=>r.name));let o=t.id;for(let r=2;c.has(o);r++)o=`${t.id}-${r}`;return o}const hs="Authorization";function oi(t){const s=c=>c.headerKeys?.some(o=>o.toLowerCase()===hs.toLowerCase())===!0;return Object.fromEntries(pt.map(c=>[c.id,t.some(o=>gn(o)===c&&o.enabled&&("key"in c?s(o):o.auth==="signed-in"))]))}function cn(t){return t.url===void 0||!(gn(t)||t.name===Oe)}function xs(t){return t.enabled&&t.auth!=="needs-sign-in"}const fs=128;function ci(t,s=fs){return t>=s?"exceeds":t*2>=s?"crowds":"fits"}const ri=1500;async function St(t,s,c){try{return await s(`/api/mcp/servers/${encodeURIComponent(t)}/test`,{method:"POST",signal:c})}catch(o){if(c?.aborted)throw o;return{ok:!1,error:o instanceof Error?o.message:String(o),reason:"unreachable"}}}async function Jn(t,s,c,o,r="hostedMcp.testFailed"){const l=await St(t,s,c);if(l.ok)return l;const y=(l.error??"").trim();return{...l,error:n(r,{service:o,reason:y&&!/[.!?]$/.test(y)?`${y}.`:y})}}function _n(t,s){if(s.reason!=="keys"||!pe(t))return s.error??"";const c=s.status?`HTTP ${s.status}`:n("mcp.check.unauthorized");return t.headerKeys.length?n("mcp.check.keysRefused",{reason:c,names:new Intl.ListFormat(Bt(),{style:"long",type:"conjunction"}).format(t.headerKeys)}):n("mcp.check.keysNeeded",{reason:c})}function li(t){const s=Math.max(t.total??0,t.tools?.length??0);if(!s)return n("mcp.check.connectedNone");const c=s===1?n("mcp.check.connectedOne"):n("mcp.check.connectedMany",{count:s}),o=ci(s);return o==="fits"?c:`${c}. ${n(o==="exceeds"?"mcp.check.overLimit":"mcp.check.crowdsLimit",{count:s,limit:fs})}`}function Vn({embedded:t=!1,hostedCards:s,hideHosted:c=!1,refreshKey:o=0}={}){const{state:r,dispatch:l}=et(),y=a=>r.bots?.find(u=>u.id===a)?.name??a,g=r.config?.managedPolicy,k=!!(g&&!g.mcp.allowCustom),[p,h]=d.useState(null),[A,Q]=d.useState(null),[C,M]=d.useState(null),[J,K]=d.useState(null),[H,$]=d.useState(null),[L,le]=d.useState({}),[v,_]=d.useState(null),Z=d.useRef(null),he=d.useRef(null),[X,ee]=d.useState(null),[ye,W]=d.useState(""),[b,f]=d.useState(null),[S,E]=d.useState(!1),[U,B]=d.useState(!1),Y=d.useRef({}),[Pe,Me]=d.useState(null),[Le,we]=d.useState(null),[Re,Ue]=d.useState({}),ne=d.useRef(0),q=d.useRef(!0),fe=a=>pe(a)?gn(a):void 0,V=d.useMemo(()=>p&&oi(p),[p]),ke=s?.onConnections;d.useEffect(()=>{V&&ke?.(V)},[V,ke]);const $e=s?.onServers;d.useEffect(()=>{p&&$e?.(p)},[p,$e]);const oe=a=>(h(a??[]),Gt(a??[]),a??[]),je=a=>le(u=>{const x={...u};return delete x[a],x}),Ne=d.useCallback(()=>{const a=++ne.current;return M("load"),K(null),w("/api/mcp/servers").then(u=>{a===ne.current&&(h(u.servers??[]),Gt(u.servers??[]))}).catch(u=>{a===ne.current&&K(u instanceof Error?u.message:String(u))}).finally(()=>{a===ne.current&&M(null)})},[]);d.useEffect(()=>(q.current=!0,Ne(),()=>{q.current=!1,ne.current+=1}),[Ne,o]);const R=d.useRef(null);R.current=C,d.useEffect(()=>{const a=()=>{if(R.current!==null)return;const u=ne.current;w("/api/mcp/servers").then(x=>{!q.current||R.current!==null||u!==ne.current||(h(x.servers??[]),Gt(x.servers??[]))}).catch(()=>{})};return Is({onFrame:u=>{u.kind==="mcp.changed"&&a()},onMissedFrames:a})},[]);const I=()=>{Q(null),B(!1)},ce=(a,u=!1)=>{Q(a),B(u),K(null),$(null)},se=async(a,u=!1)=>{M(`test:${a}`),Me(a),ne.current+=1,je(a);let x=await St(a,w);if(x.ok)try{oe((await w(`/api/mcp/servers/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})).servers),Y.current[a]=Date.now()}catch(m){x={ok:!1,error:m instanceof Error?m.message:String(m)}}return u&&(x={...x,saved:!0}),q.current&&(le(m=>({...m,[a]:x})),M(null),Me(null)),x},ue=async a=>{M("save"),ne.current+=1,K(null),$(null);const u=[];let x=p??[];try{for(const m of a){const P=m.ownKey?{...m.body,headers:Object.fromEntries(Object.keys(m.body.headers??{}).map(N=>[N,""]))}:m.body;x=oe((await w("/api/mcp/servers",{method:"POST",body:JSON.stringify({name:m.name,...P})})).servers),m.ownKey&&(await w("/api/team/connection-scopes",{method:"PUT",body:JSON.stringify({kind:"mcp",id:m.name,scope:"person"})}),await w(`/api/team/my-connections/mcp/${encodeURIComponent(m.name)}/key`,{method:"PUT",body:JSON.stringify({value:m.ownKey,url:P.url})}),x=oe((await w(`/api/mcp/servers/${encodeURIComponent(m.name)}`,{method:"PUT",body:JSON.stringify({...P,enabled:!1})})).servers)),u.push(m.name)}}catch(m){K(m instanceof Error?m.message:String(m))}M(null),u.length&&I();for(const m of u){const P=await se(m,!0),N=x.find(te=>te.name===m);P.auth==="required"&&N&&u.length===1&&q.current&&await Ee(N)}},re=async([a])=>{const u=p?.find(x=>x.name===A);if(!(!a||!u)){M("save"),ne.current+=1,K(null),$(null);try{let x=a.body,m;if(r.config?.team&&u.scope!=="team"&&typeof x.url=="string"&&!x.oauth&&(await w("/api/team/my-connections")).mcp.some(N=>N.name===a.name)){const N=x.headers??{};if(Object.keys(N).length>1)throw new Error(n("mcp.personal.oneHeader"));const te=Object.values(N)[0];m=typeof te=="string"?te:void 0,x={...x,headers:Object.fromEntries(Object.keys(N).map(ie=>[ie,""]))}}oe((await w(`/api/mcp/servers/${encodeURIComponent(a.name)}`,{method:"PUT",body:JSON.stringify({...x,enabled:u.enabled})})).servers),m&&await w(`/api/team/my-connections/mcp/${encodeURIComponent(a.name)}/key`,{method:"PUT",body:JSON.stringify({value:m,url:x.url})}),I()}catch(x){K(x instanceof Error?x.message:String(x)),M(null);return}M(null),u.runsOn||await se(a.name,!0)}},Se=async a=>{if(a.enabled&&Date.now()-(Y.current[a.name]??0)<ri){$({key:"mcp.switchedOnByTest",params:{name:a.name}});return}M(`toggle:${a.name}`),ne.current+=1,K(null);try{oe((await w(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!a.enabled})})).servers),$({key:"mcp.toggled",params:{name:a.name},stateKey:a.enabled?"mcp.state.off":"mcp.state.on"})}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(null)}},xe=async a=>{M(`test:${a.name}`),ne.current+=1,K(null),je(a.name);const u=await St(a.name,w);le(x=>({...x,[a.name]:u})),M(null)};async function Ee(a){const u=Rt(),x=new AbortController;Z.current=x,_(a.name),ee(null),W(""),f(null),K(null),we(null),$(null),je(a.name);const m=fe(a);try{const P=async te=>{!await u.open(te)&&q.current&&!x.signal.aborted&&f(n("connectors.card.popupBlocked"))},N=await ns(a.name,{api:w,open:P,signal:x.signal,onStarted:(te,ie)=>{ee(te),he.current=ie}});if(!q.current||x.signal.aborted)return;if(N.phase==="succeeded"){ee({...N,flowId:null,authorizationUrl:null});const te=m?await Jn(a.name,w,x.signal,m.label):await St(a.name,w,x.signal);if(x.signal.aborted||!q.current||(le(De=>({...De,[a.name]:te})),!te.ok))return;const ie=await w(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!0})});if(!q.current)return;oe(ie.servers),m&&$({key:"hostedMcp.connected",params:{service:m.label}})}else N.phase!=="cancelled"&&le(te=>({...te,[a.name]:{ok:!1,error:N.message||n("mcp.auth.failed")}}))}catch(P){q.current&&!x.signal.aborted&&le(N=>({...N,[a.name]:{ok:!1,error:P instanceof Error?P.message:String(P)}}))}finally{u.cancel(),Z.current===x&&(Z.current=null,he.current=null,E(!1),_(null),ee(null),W(""),f(null),q.current&&Ne())}}const tt=async a=>{if(!p||C!==null||v!==null)return;const u=p.find(m=>fe(m)===a);if("key"in a){await nt(a,u);return}if(u){await Ee(u);return}M(`hosted:${a.id}`),ne.current+=1,K(null),we(null),$(null);let x;try{const m=Hn(a,p),P=await w("/api/mcp/servers",{method:"POST",body:JSON.stringify({name:m,type:"http",url:a.url,enabled:!1})});if(!q.current)return;if(x=oe(P.servers).find(N=>N.name===m&&fe(N)===a),!x)throw new Error(n("hostedMcp.setupFailed",{service:a.label}))}catch(m){q.current&&we({id:a.id,message:m instanceof Error?m.message:String(m)})}finally{q.current&&M(null)}x&&q.current&&await Ee(x)},nt=async(a,u)=>{const x=Re[a.id]?.trim();if(!p||!x)return;M(`hosted:${a.id}`),ne.current+=1,K(null),we(null),$(null);const m=u?.name??Hn(a,p);je(m);try{const P={type:"http",url:a.url,headers:{[hs]:`Bearer ${x}`},enabled:!1};oe((await w(u?`/api/mcp/servers/${m}`:"/api/mcp/servers",{method:u?"PUT":"POST",body:JSON.stringify(u?P:{name:m,...P})})).servers);const N=await Jn(m,w,void 0,a.label,"hostedMcp.keyTestFailed");if(!q.current||(le(te=>({...te,[m]:N.reason==="keys"?{...N,error:n("hostedMcp.keyRefused",{service:a.label})}:N})),!N.ok))return;oe((await w(`/api/mcp/servers/${m}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})).servers),Ue(te=>({...te,[a.id]:""})),$({key:"hostedMcp.connected",params:{service:a.label}})}catch(P){q.current&&we({id:a.id,message:P instanceof Error?P.message:String(P)})}finally{q.current&&M(null)}},xt=async()=>{if(!v||!X?.flowId||S)return;const a=Z.current;E(!0),f(null);try{const u=await ss(v,X.flowId,ye,w);Z.current===a&&he.current?.(u)}catch(u){Z.current===a&&f(u instanceof Error?u.message:String(u))}finally{Z.current===a&&E(!1)}},Fe=async(a,u)=>{M(`signout:${a.name}`),ne.current+=1,K(null),we(null),$(null),je(a.name);try{if(u&&"key"in u){oe((await w(`/api/mcp/servers/${a.name}`,{method:"DELETE"})).servers);return}fe(a)&&oe((await w(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!1})})).servers),oe((await w(`/api/mcp/servers/${a.name}/sign-out`,{method:"POST"})).servers)}catch(x){const m=x instanceof Error?x.message:String(x);u?we({id:u.id,message:m}):K(m)}finally{M(null)}};d.useEffect(()=>()=>Z.current?.abort(),[]);const be=async a=>{if(window.confirm(n("mcp.removeConfirm",{name:a.name}))){M(`delete:${a.name}`),ne.current+=1,K(null);try{oe((await w(`/api/mcp/servers/${a.name}`,{method:"DELETE"})).servers),je(a.name),A===a.name&&I()}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(null)}}},Ke=A&&A!=="new"?p?.find(a=>a.name===A):void 0;function ft(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:S,onChange:u=>W(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()||S,"aria-busy":S,onClick:()=>{xt()},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:[S&&e.jsx(ae,{size:14,className:"animate-spin","aria-hidden":"true"}),n(S?"mcp.auth.completing":"mcp.auth.complete")]})]})}function st(a){const u=fe(a);return v===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(ae,{size:13,className:"animate-spin"})," ",X?.phase!=="succeeded"?n("mcp.auth.waiting"):u?n("hostedMcp.loadingTools",{service:u.label}):n("mcp.auth.loadingTools")]}),X?.authorizationUrl&&Et(X.authorizationUrl)&&e.jsx("button",{type:"button",onClick:()=>{f(null),Xt(X.authorizationUrl).catch(()=>f(n("mcp.auth.openFailed")))},className:"text-accent hover:underline",children:n("mcp.auth.openAgain")}),X?.flowId&&(X.pasteBack?e.jsxs("div",{children:[e.jsx("p",{className:"leading-relaxed text-ink",children:n("mcp.auth.pasteBackHint")}),ft(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")}),ft(a)]})),b&&e.jsx("p",{role:"alert",className:"text-danger",children:b})]})}function Pt(a){const u=p?.find(ie=>fe(ie)===a),x=!!V?.[a.id],m=u&&L[u.name],P=J||(Le?.id===a.id?Le.message:null)||(m&&!m.ok?m.error:null),N=C!==null||v!==null,te=C===`hosted:${a.id}`||u!==void 0&&(v===u.name||C===`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(Pn,{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(Ye,{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&&v===u.name?e.jsx("button",{type:"button",onClick:()=>Z.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:N||p!==null&&!x&&(!!u?.managedBy||k&&!g?.mcp.allowlist.length||"key"in a&&!Re[a.id]?.trim()),onClick:()=>{p===null?Ne():x&&u?Fe(u,a):tt(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:N&&(te||C==="load")?e.jsx(ae,{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:N,autoComplete:"off",spellCheck:!1,"aria-label":n("hostedMcp.keyLabel",{service:a.label}),placeholder:n("hostedMcp.keyPlaceholder",{service:a.label}),onChange:ie=>{const De=ie.target.value;Ue(Lt=>({...Lt,[a.id]:De}))},onKeyDown:ie=>{ie.key==="Enter"&&tt(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:()=>{Xt(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(pn,{size:11,"aria-hidden":"true"})]})]}),P&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:typeof P=="string"?P:n(P.key,P.params)}),u&&st(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(ie=>!ie.hidden).map(ie=>e.jsx("button",{type:"button",onClick:()=>{l({type:"togglePlugins",open:!1}),en(l,"access",{botId:ie.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:ie.name})},ie.id))})]})]})]})}function Mt(a,u){const x=pe(a)&&a.auth==="needs-sign-in",m=L[a.name],P=m&&!m.ok&&!m.auth?n("mcp.check.failed",{reason:_n(a,m)}):null,N=x?n("mcp.auth.needsSignIn"):a.offFor?.length?n("mcp.offFor",{bots:a.offFor.map(y).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(Sn,{size:19}):e.jsx(qt,{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}),xs(a)&&e.jsx(Ye,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")})]}),e.jsx("p",{className:G("truncate text-[13px] leading-[18px]",x?"text-warning":"text-ink-secondary"),title:N,children:N})]}),v===a.name?e.jsx("button",{type:"button",onClick:()=>Z.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&&(C!==null||v!==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:[P&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:P}),st(a)]})]},a.name)}if(s){const a=s.ownServers;return e.jsxs(e.Fragment,{children:[pt.map(u=>e.jsx("div",{className:s.shown(u.id)?"contents":"hidden",children:Pt(u)},u.id)),a&&p?.filter(u=>u.enabled&&cn(u)&&a.shown(u)).map(u=>Mt(u,a.manage))]})}const ze=p?.filter(a=>!c||cn(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:C!==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(tn,{size:16,className:G(C==="load"&&"animate-spin")})}),e.jsxs("button",{type:"button",disabled:C!==null||k&&!g?.mcp.allowlist.length,title:k&&g?n("policy.managedBy",{organization:g.organizationName}):void 0,onClick:()=>ce("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(rs,{size:14})," ",n(t?"apps.mcp.add":"mcp.addServer")]})]})]}),k&&g&&e.jsx("p",{role:"status",className:"mt-3 text-[13px] leading-relaxed text-ink-secondary",children:n("policy.mcpRestricted",{organization:g.organizationName})}),(A==="new"||Ke)&&e.jsx(ni,{server:Ke,fixKeys:U,taken:(p??[]).map(a=>a.name),team:!!r.config?.team,busy:C!==null,onCancel:I,onSubmit:a=>{A==="new"?ue(a):re(a)}},`${A}${U?":keys":""}`),J&&e.jsx("div",{role:"alert",className:"mt-3 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:typeof J=="string"?J:n(J.key,J.params)}),H&&e.jsx("div",{role:"status",className:"mt-3 rounded-lg bg-success/10 px-3 py-2 text-[12px] text-success",children:n(H.key,{...H.params,...H.stateKey?{state:n(H.stateKey)}:{}})}),e.jsx(Aa,{}),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(ae,{size:14,className:"animate-spin"})," ",n("mcp.loading")]}):ze?.length===0&&!A?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(qt,{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=L[a.name],m=pe(a)?a.auth:void 0,P=pe(a)&&!a.runsOn&&(m==="needs-sign-in"||x?.auth==="required"||(!!u||!!a.oauth)&&m!=="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:G("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(Pn,{app:u}):pe(a)?e.jsx(Sn,{size:19}):e.jsx(qt,{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:G("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")}),m&&e.jsx("span",{className:G("rounded-full px-2 py-0.5 text-[11px]",m==="signed-in"?"bg-success/10 text-success":"bg-warning/10 text-warning"),children:n(m==="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:y(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(y).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:[v===a.name?e.jsxs("button",{type:"button",onClick:()=>Z.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(ae,{size:14,className:"animate-spin"})," ",n("mcp.auth.cancel")]}):P?e.jsxs("button",{type:"button",disabled:C!==null||v!==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(Ts,{size:14})," ",u?n("hostedMcp.connect",{service:u.label}):n("mcp.auth.signIn")]}):m==="signed-in"?e.jsxs("button",{type:"button",disabled:C!==null||v!==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:[C===`signout:${a.name}`?e.jsx(ae,{size:14,className:"animate-spin"}):e.jsx(ca,{size:14})," ",u?n("hostedMcp.disconnect",{service:u.label}):n("mcp.auth.signOut")]}):null,e.jsxs("button",{type:"button",disabled:C!==null||v!==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:[C===`test:${a.name}`?e.jsx(ae,{size:14,className:"animate-spin"}):e.jsx(Os,{size:14})," ",n("mcp.test")]}),e.jsx("button",{type:"button",disabled:C!==null||v!==null,onClick:()=>ce(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(Bs,{size:14})}),e.jsx("button",{type:"button",disabled:C!==null||v!==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(Ps,{size:14})}),e.jsxs("span",{className:"ml-1 flex items-center",children:[C===`toggle:${a.name}`&&e.jsx(ae,{size:13,className:"mr-1.5 animate-spin text-ink-secondary"}),e.jsx(un,{checked:a.enabled,disabled:C!==null||v!==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(N=>!N.hidden).map(N=>e.jsx("button",{type:"button",onClick:()=>{l({type:"togglePlugins",open:!1}),en(l,"access",{botId:N.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:N.name})},N.id))})]})]}),e.jsx(Na,{server:a,disabled:C!==null||v!==null,onSaved:N=>{ne.current+=1,oe(N)}}),st(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(ae,{size:13,className:"animate-spin","aria-hidden":"true"})," ",n("mcp.check.testingOff")]}),x&&v!==a.name&&e.jsx("div",{role:"status",className:G("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(Ms,{size:14,className:"mt-px shrink-0"})," ",li(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:_n(a,x)})}),x.reason==="keys"&&pe(a)||x.reason==="unreachable"||x.reason==="timeout"?e.jsx("button",{type:"button",disabled:C!==null||v!==null,onClick:()=>x.reason==="keys"?ce(a.name,!0):void se(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 qe="/api/postiz",di="postiz social media posts schedule linkedin instagram facebook tiktok threads bluesky",Zt={slug:Oe,categories:["Social"]};function mt(t){try{return new URL(t.trim()).host}catch{return t.trim()}}function rn(t,s){const c=t?.body,o=typeof c?.code=="string"?c.code:null,r=mt(s);return o==="key_rejected"?n("postiz.error.keyRejected"):o==="unreachable"?n("postiz.error.unreachable",{host:r}):o==="not_postiz"?n("postiz.error.notPostiz",{host:r}):o==="address"?n("postiz.error.address"):o==="taken"?n("postiz.taken"):typeof c?.error=="string"&&c.error?c.error:t instanceof Error?t.message:String(t)}function ui(t,s){const c=t instanceof Error?t.message:"";return/didn't accept this API key/u.test(c)||t?.name==="KeyRejected"?n("postiz.error.keyRejected"):/Couldn't reach a Postiz server/u.test(c)?n("postiz.error.unreachable",{host:mt(s)}):/didn't answer like Postiz/u.test(c)?n("postiz.error.notPostiz",{host:mt(s)}):rn(t,s)}const Ze="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",Wt="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",Gn="text-[12px] text-accent-text underline underline-offset-2",We=encodeURIComponent(Oe),pi=1500,mi=5*6e4;function hi(){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 xi({refreshKey:t=0,onConnection:s}){const{state:c,dispatch:o}=et(),[r,l]=d.useState(null),[y,g]=d.useState(!1),[k,p]=d.useState(!1),[h,A]=d.useState(null),[Q,C]=d.useState(null),[M,J]=d.useState(!1),[K,H]=d.useState(""),[$,L]=d.useState(null),[le,v]=d.useState(!1),[_,Z]=d.useState(""),[he,X]=d.useState(""),[ee,ye]=d.useState(!1),[W,b]=d.useState(null),f=d.useRef(!0),S=d.useRef(null),E=d.useCallback(async()=>{const I=(await w("/api/team/my-connections").catch(()=>null))?.mcp?.find(ce=>ce.name===Oe);return I?{connected:I.connected,how:I.how}:{connected:!1,how:null}},[]),U=d.useCallback(async(R=!1)=>{try{const I=await w(R?`${qe}/check`:qe,R?{method:"POST"}:void 0);if(!f.current)return null;if(!ii(I))throw new Error("unexpected Postiz status");return l(I),p(!1),I.team&&I.scope==="person"&&b(await E()),I}catch(I){return f.current&&(I.status===403?g(!0):p(!0)),null}},[E]);d.useEffect(()=>(f.current=!0,U().then(R=>{R?.state==="connected"&&R.scope==="team"&&U(!0)}),()=>{f.current=!1,S.current?.controller.abort(),S.current=null}),[U,t]);const B=r?.team===!0&&r.scope==="person",Y=B?W?.connected===!0:r?.state==="connected";d.useEffect(()=>{s?.(r?Y:null)},[r,Y,s]);const Pe=R=>o({type:"configStatus",config:R}),Me=async()=>{await w("/api/team/connection-scopes",{method:"PUT",body:JSON.stringify({kind:"mcp",id:Oe,scope:"person"})}),await w(`/api/mcp/servers/${We}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})},Le=async(R,I)=>{const ce=await w(`/api/team/my-connections/mcp/${We}/sign-in`,{method:"POST"}),se=Et(ce.auth.authorizationUrl);if(!se)throw new Error(n("mcp.auth.failed"));C({...ce.auth,flowId:null,pasteBack:!1}),!await I(se)&&f.current&&L(n("connectors.popupBlockedContinue"));const ue=Date.now()+mi;for(;!R.signal.aborted&&Date.now()<ue;)if(await new Promise(Se=>setTimeout(Se,pi)),(await E())?.connected)return;if(!R.signal.aborted)throw new Error(n("postiz.signInExpired"))},we=async()=>{if(h||S.current)return;const R=Rt(),I=new AbortController;S.current={controller:I},A("sign-in"),L(null),H("");const ce=async se=>{const ue=await R.open(se);return R.cancel(),ue};try{if(await w(`${qe}/sign-in`,{method:"POST"}),ee||B){ee&&!B&&await Me(),await Le(I,ce);return}const se=await ns(Oe,{api:w,signal:I.signal,open:async re=>{!await ce(re)&&f.current&&!I.signal.aborted&&L(n("connectors.popupBlockedContinue"))},onStarted:(re,Se)=>{S.current?.controller===I&&(S.current.complete=Se),f.current&&C(re)}});if(I.signal.aborted||!f.current)return;if(se.phase!=="succeeded"){se.phase!=="cancelled"&&L(se.message||n("mcp.auth.failed"));return}J(!0);const ue=await w(`/api/mcp/servers/${We}/test`,{method:"POST",signal:I.signal});if(!ue.ok){const re=(ue.error??"").trim();L(n("postiz.error.testFailed",{reason:re&&!/[.!?]$/u.test(re)?`${re}.`:re}));return}await w(`/api/mcp/servers/${We}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})}catch(se){f.current&&!I.signal.aborted&&L(rn(se,lt))}finally{R.cancel(),S.current?.controller===I&&(S.current=null),f.current&&(C(null),J(!1),A(null),await U())}},Re=async()=>{const R=S.current;if(!(!R||!Q?.flowId||!K.trim()))try{R.complete?.(await ss(Oe,Q.flowId,K,w))}catch(I){f.current&&L(I instanceof Error?I.message:String(I))}},Ue=async()=>{const R=Ls(_),I=B||ee?"":he.trim();if(!h){if(!is(R))return L(n("keys.notAKey"));A("key"),L(null);try{if(await w(`${qe}/key-check`,{method:"POST",body:JSON.stringify({key:R,...I?{address:I}:{}})}),ee||B){await w(`${qe}/sign-in`,{method:"POST"}),B||await Me();const se=(await w("/api/mcp/servers")).servers?.find(ue=>ue.name===Oe)?.url;await w(`/api/team/my-connections/mcp/${We}/key`,{method:"PUT",body:JSON.stringify({value:R,url:se})})}else{const ce=c.config?.postiz?.url??"",se=I&&mt(I)!==mt(lt)?I:"";se!==ce&&Pe(await w("/api/config",{method:"PUT",body:JSON.stringify({postiz:{url:se}})})),Pe(await zt("postiz",R,c.config?.postiz?.configured!==!0))}if(It("postiz","apps","ok"),!f.current)return;Z(""),v(!1)}catch(ce){It("postiz","apps",os(ce)),f.current&&L(ui(ce,I||lt))}finally{f.current&&(A(null),await U())}}},ne=async()=>{if(!(h||!window.confirm(n("postiz.disconnectConfirm")))){A("disconnect"),L(null);try{B?await w(`/api/team/my-connections/mcp/${We}`,{method:"DELETE"}):(r?.keySaved&&Pe(await zt("postiz","",!1)),await w(qe,{method:"DELETE"}))}catch(R){f.current&&L(rn(R,r?.address??lt))}finally{f.current&&(A(null),await U())}}},q=()=>S.current?.controller.abort();if(y)return null;const fe=h==="sign-in",V=!B&&r?.state==="needs-sign-in",ke=!B&&r?.state==="key-refused",$e=r?.state==="blocked"||r?.state==="taken",oe=r?.state==="taken"?n("postiz.taken"):r?.state==="blocked"?r.message??n("postiz.description"):Y?B?n("postiz.connectedOwn"):r?.how==="key"?n("postiz.connectedKey",{host:r.host}):n("postiz.connectedTo",{host:r?.host??""}):V?n("connectors.signedOut"):ke?n("postiz.keyRefused"):n("postiz.description"),je=(Y||V||ke)&&e.jsx(as,{placement:"below",ariaLabel:n("postiz.menu"),triggerClassName:"shrink-0",items:[{key:"disconnect",label:n("connectors.disconnect"),disabled:h!==null,onSelect:()=>{ne()}}],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:h==="disconnect"?e.jsx(ae,{size:14,className:"animate-spin"}):e.jsx(ra,{size:15,"aria-hidden":"true"})})}),Ne=r!==null&&!Y&&!$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(hi,{}),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"}),Y&&e.jsx(Ye,{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:oe,children:oe})]}),fe?e.jsx("button",{type:"button",onClick:q,className:Ze,children:n("mcp.auth.cancel")}):r===null?k?e.jsx("button",{type:"button",onClick:()=>{U()},className:Ze,children:n("connectors.action.retry")}):e.jsx("button",{type:"button",disabled:!0,className:Ze,"aria-label":n("common.checking"),children:e.jsx(ae,{size:14,className:"animate-spin"})}):Y?je:Ne&&!le?e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-label":n(V||ke?"postiz.reconnect":"postiz.connect"),disabled:h!==null,onClick:()=>ke?(v(!0),L(null)):void we(),className:Ze,children:n(V||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(ae,{size:12,className:"shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:n(M?"postiz.loadingTools":"postiz.finishInBrowser")}),Q?.authorizationUrl&&Et(Q.authorizationUrl)&&e.jsx("button",{type:"button",onClick:()=>{Xt(Q.authorizationUrl).catch(()=>L(n("mcp.auth.openFailed")))},className:Gn,children:n("mcp.auth.openAgain")})]}),Q?.flowId&&Q.pasteBack&&e.jsxs("form",{"data-postiz-paste":!0,className:"flex flex-col gap-1.5",onSubmit:R=>{R.preventDefault(),Re()},children:[e.jsx("span",{className:"leading-relaxed text-ink",children:n("mcp.auth.pasteBackHint")}),e.jsx("input",{type:"text",value:K,onChange:R=>H(R.target.value),autoComplete:"off",spellCheck:!1,"aria-label":n("mcp.auth.callbackUrl"),placeholder:"http://127.0.0.1:…/mcp-oauth/callback?…",className:Wt}),e.jsx("button",{type:"submit",disabled:!K.trim(),className:Ze,children:n("mcp.auth.complete")})]})]}),$&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:$}),Ne&&!fe&&r.team&&!B&&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:ee,onChange:R=>ye(R.target.checked)})," ",n("mcp.team.onlyMe")]}),B&&!Y&&!fe&&e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-ink-secondary",children:n("postiz.personScope")}),Ne&&!fe&&(le?e.jsxs("form",{"data-postiz-key-form":!0,className:"mt-2 flex flex-col gap-2",onSubmit:R=>{R.preventDefault(),Ue()},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,"aria-label":n("postiz.keyField"),placeholder:n("keys.postiz.placeholder"),value:_,disabled:h==="key",onChange:R=>{L(null),Z(R.target.value)},className:Wt}),!B&&!ee&&e.jsx("input",{type:"url",autoComplete:"off",spellCheck:!1,"aria-label":n("postiz.addressField"),placeholder:lt,value:he,disabled:h==="key",onChange:R=>{L(null),X(R.target.value)},className:Wt}),e.jsx("p",{className:"text-[12px] leading-relaxed text-ink-secondary",children:n(B||ee?"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:h!==null||!_.trim(),className:Ze,children:h==="key"?e.jsx(ae,{size:14,className:"animate-spin"}):n("connectors.action.connect")}),e.jsxs("a",{href:ai,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(pn,{size:11,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",onClick:()=>{v(!1),L(null)},className:"text-[12px] text-ink-secondary underline underline-offset-2 hover:text-ink",children:n("postiz.useSignIn")})]})]}):e.jsx("button",{type:"button",onClick:()=>{v(!0),L(null),X(r.selfHosted?r.address:"")},className:`mt-1.5 inline-block ${Gn}`,children:n("postiz.useKey")}))]})]})}const qn=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0,Zn=t=>typeof t=="string"&&t.length<=40&&!Number.isNaN(Date.parse(t));function fi(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const{calls:s,max:c,usedUp:o,resetsAt:r,trialEndsAt:l}=t;return!qn(s)||!qn(c)||!Zn(r)||l!==void 0&&!Zn(l)?null:{calls:Math.min(s,c),max:c,...o===!0||s>=c?{usedUp:!0}:{},resetsAt:r,...l!==void 0?{trialEndsAt:l}:{}}}function gi(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||fi(s.usage)!==null)}const bi="https://treg.to",At="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",yi="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",ki="x twitter treg tweets posts";function ji(){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 Yt=t=>new Intl.DateTimeFormat(Bt(),{day:"numeric",month:"long",timeZone:"UTC"}).format(new Date(t)),Wn=t=>t.toLocaleString(Bt());function vi(t){const s={used:Wn(t.calls),max:Wn(t.max)};return t.trialEndsAt?t.usedUp?{line:n("apps.x.usedUpTrial",{date:Yt(t.trialEndsAt)}),usedUp:!0}:{line:n("apps.x.usageTrial",s),usedUp:!1}:t.usedUp?{line:n("apps.x.usedUp",{date:Yt(t.resetsAt)}),usedUp:!0}:{line:`${n("apps.x.usage",s)} ${n("apps.x.resets",{date:Yt(t.resetsAt)})}`,usedUp:!1}}function wi({refreshKey:t=0,onConnection:s}){const{state:c,dispatch:o}=et(),[r,l]=d.useState(null),[y,g]=d.useState(!1),[k,p]=d.useState(null),[h,A]=d.useState(""),[Q,C]=d.useState(null),[M,J]=d.useState(null),[K,H]=d.useState(!1),$=d.useRef(!0),L=d.useRef(!1),le=ws(ua()?.view??null)==="connecting",v=c.config?.treg?.configured===!0,_=c.config?.xResearch?.included===!0,Z=d.useCallback(async(E=!1)=>{try{const U=await w(`/api/x/status${E?"?refresh=1":""}`);if(!$.current)return;if(!gi(U))throw new Error("unexpected X status");l(U),g(!1)}catch{$.current&&g(!0)}},[]);d.useEffect(()=>($.current=!0,Z(t>0),()=>{$.current=!1}),[Z,t,v,_]),d.useEffect(()=>{s?.(r?r.using!==null:null)},[r,s]);const he=E=>(o({type:"configStatus",config:E}),Z(!0)),X=async()=>{p("test"),J(null);try{const E=await w("/api/keys/test",{method:"POST",body:JSON.stringify({provider:"treg"})});return $.current&&J(Us(E)),Rn(E)}catch(E){return $.current&&J(E instanceof Error?E.message:String(E)),Rn(null)}finally{$.current&&p(null)}},ee=async()=>{const E=h.trim();if(!(k||!E)){if(!is(E))return C(n("keys.notAKey"));p("save"),C(null),J(null);try{if(await he(await zt("treg",E,!v)),!$.current)return;A(""),H(!1),It("treg","apps",await X())}catch(U){$.current&&C(U instanceof Error?U.message:String(U)),It("treg","apps",os(U))}finally{$.current&&p(U=>U==="save"?null:U)}}},ye=async()=>{if(!k){p("remove"),C(null),J(null);try{await he(await zt("treg","",!1)),$s("treg","apps")}catch(E){$.current&&C(E instanceof Error?E.message:String(E))}finally{$.current&&p(null)}}};d.useEffect(()=>{L.current&&(L.current=!1,ee())});const W=r?.using??null,b=r?.usage?vi(r.usage):null,f=r!==null&&W!=="own"&&(W===null||K||b?.usedUp===!0),S=r===null?n("apps.x.description"):W==="own"?n("apps.x.own"):W==="included"?n("apps.x.included"):le&&!r.unavailable?n("apps.x.connecting"):n("apps.x.addKey");return e.jsxs("div",{"data-app-tile":"x","data-x-state":r===null?"loading":W??"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(ji,{}),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")}),W!==null&&e.jsx(Ye,{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:S,children:S})]}),r===null?y?e.jsx("button",{type:"button",onClick:()=>{Z(!0)},className:At,children:n("connectors.action.retry")}):e.jsx("button",{type:"button",disabled:!0,className:At,"aria-label":n("common.checking"),children:e.jsx(ae,{size:14,className:"animate-spin"})}):W==="own"?e.jsx("button",{type:"button",disabled:k!==null,onClick:()=>{X()},className:At,children:k==="test"?e.jsx(ae,{size:14,className:"animate-spin"}):n("keys.test")}):null]}),e.jsxs("div",{className:"ps-[52px]",children:[W==="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")}),W==="included"&&b&&e.jsx("p",{"data-x-usage":!0,className:b.usedUp?"mt-1 text-[12px] leading-relaxed text-warning":"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:b.line}),W==="own"&&e.jsxs("button",{type:"button",disabled:k!==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:[k==="remove"&&e.jsx(ae,{size:12,className:"animate-spin","aria-hidden":"true"}),n("apps.x.remove")]}),W==="included"&&!f&&e.jsx("button",{type:"button",onClick:()=>{H(!0),C(null)},className:"mt-1.5 inline-block text-[12px] text-accent-text underline underline-offset-2",children:n("apps.x.useOwnKey")}),f&&e.jsxs("form",{"data-x-key-form":!0,className:"mt-2 flex flex-col gap-2",onSubmit:E=>{E.preventDefault(),ee()},children:[W===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:h,disabled:k==="save",onChange:E=>{C(null),A(E.target.value)},onPaste:()=>{L.current=!0},className:yi}),e.jsx("button",{type:"submit",disabled:k!==null||!h.trim(),className:At,children:k==="save"?e.jsx(ae,{size:14,className:"animate-spin"}):n("common.save")})]}),e.jsxs("a",{href:bi,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(pn,{size:11,"aria-hidden":"true"})]})]}),M&&e.jsx("p",{role:"status",className:"mt-1.5 text-[12px] text-ink-secondary",children:M}),Q&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:Q})]})]})}function ln(t,s,c,o){const r={...t};for(const[l,y]of Object.entries(s))(c.get(l)??0)===(o.get(l)??0)&&(r[l]=y);return r}function Ni(t,s,c,o,r=!0){const l={...t};if(!r)return ln(l,s,c,o);for(const[y,g]of Object.entries(t))s[y]||!g.connected&&!g.accounts?.length||(c.get(y)??0)===(o.get(y)??0)&&(l[y]={connected:!1,pending:!1,status:"not_connected",accounts:[]});return ln(l,s,c,o)}function Ai(t,s,c){return Object.fromEntries(Object.entries(t).filter(([o])=>(s.get(o)??0)===(c.get(o)??0)))}async function Ci(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 Yn({notice:t=!1}){const[s,c]=d.useState(!1),[o,r]=d.useState(()=>dt!==null);if(d.useEffect(()=>{let g=!0;return Ci().then(k=>{g&&c(k)}),dt?.finally(()=>{g&&r(!1)}),()=>{g=!1}},[]),!s)return null;const l=()=>{if(dt)return;r(!0),dt=Promise.resolve(window.ogb?.credentialStore?.reset()).then(()=>{},()=>{}).finally(()=>{dt=null,r(!1)})},y=e.jsx("button",{type:"button",onClick:l,disabled:o,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(cs,{size:14,className:"mt-px shrink-0"}),e.jsxs("span",{children:[n("connectors.savedKeysUnreadable"),y]})]}):y}function Ct({id:t,title:s,note:c,viewAll:o,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,c&&e.jsx("span",{className:"ms-2 text-[12px] font-normal text-ink-secondary",children:c})]}),o&&e.jsx("button",{type:"button",onClick:o.onClick,className:"shrink-0 rounded-full px-2 text-[13px] font-medium leading-5 text-ink-secondary transition-colors hover:text-ink",children:o.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 Si(t,s){const c=s.alias?`“${s.alias}” (${s.id})`:`“${s.id}”`;return n("connectors.disconnectConfirm",{identity:c,service:t})}function Ri(t,s,c){return t.filter(o=>{if(o.hidden||o.composio===!1||!s.find(y=>y.instanceId===o.modelSelection.instanceId)?.capabilities?.composioMcp)return!1;const r=o.connectorTools;if(!r||typeof r!="object"||Array.isArray(r))return!1;const l=r[c];return l===void 0?!0:!na(l)||l.tools!=="*"})}function Ei(t,s,c,o){return(!s||`${t.label} ${t.keywords} ${n(t.description)}`.toLowerCase().includes(s.toLowerCase().trim()))&&(c==="all"||c==="connected"&&o?.[t.id]!==!1)}function zi(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 Xn=48,Ii=16;function Ti(t,s,c){return Ys(t,s).filter(o=>Xs(o,c)!==null)}function Ki(){const{state:t,dispatch:s}=et(),c=window.ogb?.remoteClient?.active===!0,o=d.useRef(null),r=t.pluginsSurface,[l,y]=d.useState(null),[g,k]=d.useState("curated"),[p,h]=d.useState(null),[A,Q]=d.useState(!1),[C,M]=d.useState("unavailable"),[J,K]=d.useState(void 0),[H,$]=d.useState(()=>Nt()?.services??Fs()?.services??{}),[L,le]=d.useState(Nt()?.authoritative===!1),[v,_]=d.useState({}),[Z,he]=d.useState(null),[X,ee]=d.useState(""),[ye,W]=d.useState(null),[b,f]=d.useState(!1),[S,E]=d.useState(Nt()===null?"loading":"ready"),[U,B]=d.useState(null),[Y,Pe]=d.useState(""),[Me,Le]=d.useState("marketplace"),[we,Re]=d.useState(!1),[Ue,ne]=d.useState(null),[q,fe]=d.useState(0),[V,ke]=d.useState(null),[$e,oe]=d.useState(null),[je,Ne]=d.useState(null),[R,I]=d.useState(null),[ce,se]=d.useState([]),ue=d.useRef(new Map),re=d.useRef(new Map),Se=d.useRef(new Map),xe=d.useRef(null),Ee=d.useRef(new Set),tt=(i,j)=>{const O=Object.entries(i).filter(([z,F])=>(re.current.get(z)??0)===(j.get(z)??0)&&(F.connected&&!F.pending||/^(expired|failed)$/i.test(F.status??""))).map(([z])=>z);O.length&&_(z=>O.some(F=>z[F])?Object.fromEntries(Object.entries(z).filter(([F])=>!O.includes(F))):z)},nt=d.useCallback(i=>{if(!i.length)return Promise.resolve({});const j=new Map(i.map(z=>[z,re.current.get(z)??0])),O=new Map(i.map(z=>{const F=(Se.current.get(z)??0)+1;return Se.current.set(z,F),[z,F]}));return w(`/api/connectors?services=${i.join(",")}`).then(z=>{const F=Ai(z.services??{},Se.current,O);return $(D=>ln(D,F,re.current,j)),tt(F,j),F}).catch(()=>({}))},[]),xt=d.useCallback((i=!1)=>{const j=new Map(re.current);return f(!0),Ks(i).then(({services:O,authoritative:z,refused:F})=>(le(!z),F&&B({key:"connectors.adminOnly"}),$(D=>Ni(D,O,re.current,j,z)),tt(O,j),O)).finally(()=>f(!1))},[]),Fe=d.useCallback((i=!1)=>{const j=Nt()!==null;return j||E("loading"),B(null),xt(i).then(O=>(E("ready"),O)).catch(O=>(j||E("error"),B(O instanceof Error?O.message:String(O)),{}))},[xt]);d.useEffect(()=>()=>{xe.current?.cancel(),xe.current=null;for(const i of ue.current.values())i();ue.current.clear()},[]);const be=Ds({status:H,emailConnected:R,inventoryReady:S==="ready"&&!L});d.useEffect(()=>{S==="ready"&&ia(H,!L)},[S,L,H]),d.useEffect(()=>{let i=!0;return Fe(),w("/api/connectors/catalog").then(j=>{i&&(y(j.cards??[]),k(j.source??"curated"),h(j.pagination??null),Q(!!j.configured),M(j.mode??"unavailable"),K(j.setup))}).catch(j=>{i&&(y(O=>O??[]),B(Qs(j)?{key:"connectors.adminOnly"}:j.message))}),()=>{i=!1}},[Fe]),d.useEffect(()=>{const i=document.activeElement instanceof HTMLElement?document.activeElement:null,j=o.current,O=()=>Array.from(j?.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]).filter(D=>D.getClientRects().length>0),z=O();(z.find(D=>D.matches("input"))??z[0]??j)?.focus();const F=D=>{if(D.key==="Escape"){D.preventDefault(),s({type:"togglePlugins",open:!1});return}if(D.key!=="Tab"||!j)return;const de=O();if(de.length===0){D.preventDefault(),j.focus();return}const ve=de[0],Ae=de.at(-1);de.some(ge=>ge===document.activeElement)?D.shiftKey&&document.activeElement===ve?(D.preventDefault(),Ae.focus()):!D.shiftKey&&document.activeElement===Ae&&(D.preventDefault(),ve.focus()):(D.preventDefault(),(D.shiftKey?Ae:ve).focus())};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F),i?.focus()}},[s]);const{suggestions:Ke,picking:ft,pick:st}=Hs(l!==null&&A&&S==="ready",`${q}:${Object.keys(H).filter(i=>H[i]?.connected).sort().join()}`),Pt=async i=>{if(xe.current)return;const j=Rt();xe.current=j;try{!await j.open(i)&&xe.current===j&&B({key:"connectors.popupBlockedContinue"})}finally{j.cancel(),xe.current===j&&(xe.current=null)}},Mt=(i,j,O)=>{ue.current.get(i)?.();const z=sa(j,()=>nt([i]).then(F=>F[i]),F=>{ue.current.get(i)===z&&ue.current.delete(i),aa(i,F),F==="connected"&&O&&be.appConnected(i,l?.find(D=>D.slug===i)?.label??i)});ue.current.set(i,z)},ze=async(i,j,O)=>{if(ye||xe.current)return;const z=Rt();xe.current=z,re.current.set(i,(re.current.get(i)??0)+1),W(i),B(null),O&&Ee.current.add(i);const F=!Ee.current.has(i)&&!ct(H[i]);try{const D=Date.now();O&&await w(`/api/connectors/${i}/accounts/${encodeURIComponent(O.id)}`,{method:"DELETE"});const de={method:"POST"};j&&(de.body=JSON.stringify({alias:j}));const ve=await w(`/api/connectors/${i}/authorize`,de);if(xe.current!==z)return;const Ae=Et(typeof ve.url=="string"?ve.url:null);if(!Ae)throw new Error(n("connectors.invalidAuthorizationUrl"));_(ge=>({...ge,[i]:{url:Ae,createdAt:D}})),$(ge=>({...ge,[i]:{...ge[i],connected:ge[i]?.connected??!1,pending:!0,status:"INITIATED"}})),he(null),ee(""),Mt(i,H[i],F),!await z.open(Ae)&&xe.current===z&&B({key:"connectors.popupBlockedContinue"})}catch(D){if(xe.current!==z)return;const de=D instanceof Error?D.message:String(D);ea(de)?(he(i),ee(""),B({key:"connectors.aliasNeeded"}),nt([i])):B(ta(de)?{key:"connectors.aliasTaken"}:de)}finally{z.cancel(),xe.current===z&&(xe.current=null,W(null))}},a=(i,j)=>{W(i),w(`/api/connectors/${i}/accounts/${encodeURIComponent(j)}`,{method:"DELETE"}).then(()=>nt([i])).catch(O=>B(O.message)).finally(()=>W(null))},u=(l??[]).filter(i=>(!Tn(C,i.slug)||ct(H[i.slug]))&&En(`${i.label} ${i.slug} ${On(i)} ${(i.categories??[]).join(" ")}`,Y)),x=i=>!!(H[i]?.connected||H[i]?.accounts?.length),m=r==="mcp"?"mcp":Me==="connected"?"connected":"all",P=Y.trim().length>0,N=P&&m==="connected"?"all":m,te=new Set(pt.filter(i=>Ei(i,Y,N,Ue)).map(i=>i.id)),ie=(!Y||`email mail imap smtp mailbox ${n("email.description")}`.toLowerCase().includes(Y.toLowerCase().trim()))&&(N==="all"||N==="connected"&&R!==!1),De=(!Y||`${ki} ${n("apps.x.description")}`.toLowerCase().includes(Y.toLowerCase().trim()))&&(N==="all"||N==="connected"&&$e!==!1),Lt=(!Y||`${di} ${n("postiz.description")}`.toLowerCase().includes(Y.toLowerCase().trim()))&&(N==="all"||N==="connected"&&je!==!1),Ut=(N==="connected"?u.filter(i=>x(i.slug)):u).map((i,j)=>({card:i,index:j})).sort((i,j)=>Number(x(j.card.slug))-Number(x(i.card.slug))||i.index-j.index).map(({card:i})=>i),$t=pt.filter(i=>Ue?.[i.id]),bn=ce.filter(i=>cn(i)),yn=i=>En(`${i.name} ${pe(i)?i.url:[i.command,...i.args].join(" ")}`,Y),kn=Object.values(H).filter(ct).length+$t.length+bn.filter(xs).length+ +(R===!0)+ +($e===!0)+ +(je===!0),jn=Js(S),Qe=()=>s({type:"togglePlugins",open:!1}),gt=zi({configured:A,stale:L,setup:J,remoteClient:c}),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"})},Ft=ka([...l??[],Zt],void 0,Zt.categories),Kt=Ft.more,Dt=V!==null&&Kt.includes(V),He=m==="all"&&V!==null&&!P,vn=Lt&&(!He||nn(Zt,V)),gs=!He&&(te.size>0||ie||De)||vn||m==="connected"&&bn.some(i=>i.enabled&&yn(i)),bs=He?Ut.filter(i=>nn(i,V)):Ut,bt=m==="all"&&!P&&V===null,it=bt?ja(Ut,x,Ft.inline):[],ys=it.find(i=>i.kind==="all"),yt=bt?ys?.cards??[]:bs,Qt=bt&&!we&&yt.length>Xn,wn=Qt?yt.slice(0,Xn):yt,Nn=(l??[]).filter(i=>ct(H[i.slug])),Ht=i=>{ke(i),Le("marketplace"),r!=="apps"&&s({type:"togglePlugins",open:!0,surface:"apps"})},ks=P?n("connectors.section.results"):m==="connected"?n("connectors.section.yours"):V?rt(V):it.length>1?n("apps.section.all"):n("connectors.section.available"),Je="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:Gs(),onMouseDown:i=>i.target===i.currentTarget&&Qe(),children:[e.jsx("div",{"aria-hidden":"true",className:"glass-scrim pointer-events-none absolute inset-0"}),e.jsxs("div",{ref:o,"data-tour":"apps-panel",role:"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":m==="connected",onClick:()=>at(m==="connected"?"all":"connected"),className:G("inline-flex h-8 items-center gap-2 rounded-full ps-1.5 pe-2 text-[13px] font-medium leading-5 transition-colors",m==="connected"?"bg-raised text-ink":"text-ink-secondary hover:bg-raised/60 hover:text-ink"),children:[Nn.length>0&&e.jsx("span",{"aria-hidden":"true",className:"flex -space-x-1.5 rtl:space-x-reverse",children:Nn.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(zn,{card:i,className:"size-5 rounded-md"})},i.slug))}),e.jsx("span",{className:"whitespace-nowrap",children:kn>0?n("apps.connectedCount",{count:kn}):n("apps.filter.connected")}),e.jsx(ls,{size:14,"aria-hidden":"true",className:"shrink-0 rtl:-scale-x-100"})]}),e.jsx("button",{onClick:()=>{fe(i=>i+1),Fe(!0)},disabled:b,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(tn,{size:16,className:G(b&&"animate-spin")})}),e.jsx("button",{"data-tour":"apps-close",onClick:Qe,"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(es,{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(Ns,{size:15,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:Y,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":m==="mcp",onClick:()=>at(m==="mcp"?"all":"mcp"),className:G(Je,"h-9 border border-hairline/40 px-3.5",m==="mcp"?"bg-ink text-app":"text-ink hover:bg-raised"),children:[e.jsx(la,{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":m==="all"&&V===null,onClick:()=>{at("all"),ke(null)},className:G(Je,Jt(m==="all"&&V===null)),children:n("apps.filter.all")}),Ft.inline.map(i=>e.jsx("button",{type:"button","data-apps-category":i,"aria-pressed":m==="all"&&V===i,onClick:()=>Ht(V===i?null:i),className:G(Je,Jt(m==="all"&&V===i)),children:rt(i)},i)),Kt.length>0&&e.jsx(as,{ariaLabel:n("apps.moreCategories"),items:Kt.map(i=>({key:i,label:rt(i),active:V===i,onSelect:()=>Ht(i)})),renderTrigger:({open:i})=>e.jsxs("span",{className:G(Je,Jt(m==="all"&&Dt),i&&!Dt&&"bg-raised-hover text-ink"),children:[Dt?rt(V):n("apps.more"),e.jsx(ts,{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:[L?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(cs,{size:14,className:"mt-px shrink-0"}),e.jsxs("span",{children:[n("connectors.stale"),e.jsx(Yn,{})]})]}):e.jsx(Yn,{notice:!0}),gt&&m!=="mcp"&&e.jsxs("div",{className:G("mb-3 rounded-xl px-4 py-3 text-[13px]",gt.tone==="warning"?"bg-warning/10 text-warning":"bg-control/50 text-ink-secondary"),children:[$t.length>0?n("hostedMcp.otherAppsSetup",{services:new Intl.ListFormat(Bt(),{style:"long",type:"conjunction"}).format($t.map(i=>i.label))}):n(gt.key)," ",e.jsx("button",{className:G("font-medium underline underline-offset-2",gt.tone==="info"&&"text-ink",c&&"hidden"),onClick:()=>{Qe(),s(In("composio"))},children:n("connectors.openSettings")})]}),A&&!c&&g==="curated"&&C==="self-hosted"&&m!=="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:()=>{Qe(),s({type:"toggleAppSettings",open:!0})},children:n("connectors.updateKey")})," ",n("connectors.featuredAfter")]}),U&&e.jsx("div",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[12px] text-danger",children:typeof U=="string"?U:n(U.key)}),m!=="mcp"&&e.jsxs("div",{"data-apps-grid":!0,className:"@container flex flex-col gap-7 pt-1",children:[!it.some(i=>i.kind==="connected")&&An(),it.filter(i=>i.kind!=="all").map(i=>i.kind==="connected"?e.jsxs(d.Fragment,{children:[e.jsx(Ct,{id:"apps-section-connected",title:n("apps.section.connected"),viewAll:i.cards.length>Tt?{label:n("apps.viewAll"),onClick:()=>at("connected")}:void 0,children:i.cards.slice(0,Tt).map(j=>kt(j))}),An()]},"connected"):e.jsx(Ct,{id:`apps-section-${i.category}`,title:rt(i.category),viewAll:i.more?{label:n("apps.viewAll"),onClick:()=>Ht(i.category)}:void 0,children:i.cards.map(j=>kt(j))},i.category)),e.jsxs(Ct,{id:"apps-grid-title",title:ks,note:m==="all"&&!Y&&V===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(_t()),total:p.totalItems.toLocaleString(_t())}):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(ae,{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:G(Je,"bg-control/70 px-4 text-ink hover:bg-raised-hover"),children:n("apps.showAll",{count:yt.length.toLocaleString(_t())})})}),l!==null&&wn.length===0&&!gs&&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:N==="connected"?jn.title:n("connectors.noAppsFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:N==="connected"?jn.description:n("connectors.tryDifferentSearch")}),m==="connected"&&S==="error"&&e.jsxs("button",{type:"button",disabled:b,onClick:()=>{Fe(!0)},className:G(Je,"mt-4 bg-raised text-ink hover:bg-raised-hover disabled:opacity-50"),children:[e.jsx(tn,{size:14,className:G(b&&"animate-spin")}),n("connectors.action.retry")]})]})]}),children:[e.jsx(Vn,{hostedCards:{shown:i=>!He&&te.has(i),onConnections:ne,onServers:se,...m==="connected"?{ownServers:{shown:yn,manage:()=>at("mcp")}}:{}},refreshKey:q}),e.jsx("div",{"data-native-card":"x",className:De&&!He?"contents":"hidden",children:e.jsx(wi,{refreshKey:q,onConnection:oe})}),e.jsx("div",{"data-native-card":"email",className:ie&&!He?"contents":"hidden",children:e.jsx(_s,{refreshKey:q,onConnection:I})}),e.jsx("div",{"data-native-card":"postiz",className:vn?"contents":"hidden",children:e.jsx(xi,{refreshKey:q,onConnection:Ne})}),wn.map(i=>kt(i))]})]}),m!=="connected"&&V===null&&e.jsx("div",{className:G(m==="all"&&"mt-8 border-t border-hairline/30 pt-6",m==="mcp"&&"pt-1"),children:e.jsx(Vn,{embedded:!0,hideHosted:m==="all"})})]}),be.changing&&e.jsx(Vs,{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 An(){const i=Ke.cards.filter(O=>!x(O.slug));if(!bt||i.length===0)return null;const j=Ke.pick==="available"?{label:n(ft?"apps.suggested.picking":"apps.suggested.show"),onClick:st}:Ke.pick==="needs-key"&&!c?{label:n("apps.suggested.addKey"),onClick:()=>{Qe(),s(In("jev"))}}:void 0;return e.jsx(Ct,{id:"apps-section-suggested",title:n("apps.section.suggested"),note:Ke.pick==="picked"?n("apps.suggested.picked"):void 0,viewAll:j,children:i.map(O=>kt(O))})}function kt(i){const j=H[i.slug],O=j?.status&&/^(expired|failed)$/i.test(j.status),z=j?.pending&&!O,F=z&&!O?v[i.slug]:void 0,D=Vt(F),de=j?.accounts??[],ve=i.noAuth===!0||j?.connected===!0&&!de.length&&!z&&!O,Ae=ct(j),ge=z?void 0:qs(j),js=Z===i.slug&&!ve,_e=ye===i.slug,jt=t.config?.managedPolicy,vt=jt?.apps&&!jt.apps.allowAll&&!jt.apps.allowlist.includes(i.slug)?n("policy.managedBy",{organization:jt.organizationName}):Tn(C,i.slug)?n("connectors.selfHostOnlyReason"):null,ot=Ae||ve?Ti(t.bots,t.instances,i.slug):[],wt=n("apps.usedBy",{names:ot.map(T=>T.name).join(", ")}),Cn=vt??(z?D?n("connectors.finishSetup"):n("connectors.finishSetupOrDisconnect"):ge?n("connectors.signedOut"):O&&!de.length?n("connectors.authExpired"):On(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(zn,{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&&!z&&e.jsx(Ye,{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:wt,"aria-label":wt,role:"img",children:ot.slice(0,3).map(T=>e.jsx("span",{"data-used-by-avatar":T.id,className:"flex size-5 shrink-0 items-center justify-center overflow-hidden rounded-full bg-menu ring-2 ring-menu",children:e.jsx(da,{bot:T,size:Ii,animated:!1})},T.id))})]}),e.jsx("div",{className:"truncate text-[13px] leading-[18px] text-ink-secondary",title:Cn,children:Cn})]}),e.jsx("button",{type:"button",disabled:!A||S!=="ready"||_e||ve||!!vt,title:vt??void 0,onClick:()=>{if(z&&!O){const T=Vt(F);T?(B(null),Pt(T).catch(Ie=>B(Ie.message))):ze(i.slug)}else ge?ze(i.slug,ge.alias,ge):(he(T=>T===i.slug?null:i.slug),ee(""))},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:vt?n("connectors.selfHostOnly"):_e?e.jsx(ae,{size:14,className:"animate-spin"}):Zs(S,{busy:_e,included:ve,canContinue:!!F,pending:z,reconnect:!!ge,hasAccounts:de.length>0,failed:!!O})})]}),e.jsxs("div",{className:"ps-[52px]",children:[D&&e.jsx("a",{href:D,target:"_blank",rel:"noopener noreferrer",onClick:T=>{Vt(F)||(T.preventDefault(),ze(i.slug))},className:"mt-1.5 inline-block text-[12px] text-accent-text underline underline-offset-2",children:n("connectors.openAuthorizationPage")}),Ae&&!z&&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?wt:void 0,children:ot.length?wt: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(T=>{const Ie=/^active$/i.test(T.status),Ve=Ws(T)&&T.id!==ge?.id;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[12px] leading-5",children:[Ie?e.jsx(Ye,{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:`${T.alias?`${T.id} · `:""}${T.status.toLowerCase()}`,children:[T.alias||T.id,e.jsxs("span",{className:"text-ink-secondary",children:[" · ",T.status.toLowerCase()]})]}),Ve&&e.jsx("button",{type:"button",disabled:_e,onClick:()=>{ze(i.slug,T.alias,T)},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:T.alias||T.id,service:i.label}),children:n("connectors.action.reconnect")}),e.jsx("button",{type:"button",disabled:_e,onClick:()=>{window.confirm(Si(i.label,T))&&a(i.slug,T.id)},className:G("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",!Ve&&"ms-auto"),"aria-label":n("connectors.disconnectAria",{account:T.alias||T.id,service:i.label}),children:n("connectors.disconnect")})]},T.id)})}),(j?.connected||ve)&&(()=>{const T=Ri(t.bots,t.instances,i.slug);if(!T.length)return null;const Ie=T.slice(0,4).map((Ve,vs)=>e.jsxs("span",{children:[vs>0&&", ",e.jsx("button",{type:"button",onClick:()=>{Qe(),en(s,"access",{botId:Ve.id,page:"apps"})},className:"font-medium text-ink underline underline-offset-2 hover:text-accent-text",children:Ve.name})]},Ve.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:T.length})})," ",Ie,T.length>4&&e.jsx("span",{children:n("connectors.grants.more",{count:T.length-4})})]})})(),js&&e.jsxs("form",{className:"mt-2 flex items-center gap-2",onSubmit:T=>{T.preventDefault();const Ie=X.trim();if(!Ie){B({key:"connectors.aliasRequired"});return}ze(i.slug,Ie)},children:[e.jsx("input",{autoFocus:!0,value:X,maxLength:64,onChange:T=>ee(T.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||!X.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{Xn as APPS_PREVIEW_COUNT,Ki as PluginsPanel,zn as ServiceIcon,Ii as USED_BY_AVATAR_SIZE,Ti as botsUsingService,Ri as botsWithLimitedServiceTools,zi as connectorSetupNotice,Si as disconnectAccountConfirmation,Ei as hostedShown,Ks as preloadConnectedApps};
|
|
8
|
+
@modelcontextprotocol/server-github`,rows:4,className:G(Te,"resize-y font-mono text-[12px]"),onChange:b=>_(f=>({...f,args:b.target.value}))})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("div",{className:G(Ce,"mb-1.5"),children:n("mcp.field.envRows")}),e.jsx(Ge,{kind:"env",rows:v.env,onChange:b=>_(f=>({...f,env:b}))})]})]}),e.jsx(_a,{value:v.resultBudget,onChange:b=>_(f=>({...f,resultBudget:b}))})]})]}),o&&g&&h.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(X&&H?"mcp.team.onlyMeOn":"mcp.team.everyone")}),X&&e.jsxs("label",{className:"flex items-center gap-1.5 text-ink",children:[e.jsx("input",{type:"checkbox",checked:H,onChange:b=>$(b.target.checked)})," ",n("mcp.team.onlyMe")]})]}),L&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:n(L.key,L.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||!h.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(ae,{size:13,className:"animate-spin"})," ",n(g?"mcp.add":"mcp.save")]})]})]})}const si="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",ai="https://platform.postiz.com/settings";function ii(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 pt=[{id:"whop",label:"Whop",url:"https://mcp.whop.com/mcp",icon:{image:si},description:"whop.description",notice:"whop.notice",keywords:"whop checkout memberships"},{id:"agentcard",label:"Agentcard",url:"https://mcp.agentcard.sh/mcp",icon:{glyph:Es},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:zs},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:ma},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:xa},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:oa},description:"agentphone.description",notice:"agentphone.notice",keywords:"agentphone phone number sms text call calls"}];function gn(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 pt.find(c=>{const o=new URL(c.url);return s.origin===o.origin&&(s.pathname===o.pathname||s.pathname===`${o.pathname}/`)})}function Hn(t,s){const c=new Set(s.map(r=>r.name));let o=t.id;for(let r=2;c.has(o);r++)o=`${t.id}-${r}`;return o}const hs="Authorization";function oi(t){const s=c=>c.headerKeys?.some(o=>o.toLowerCase()===hs.toLowerCase())===!0;return Object.fromEntries(pt.map(c=>[c.id,t.some(o=>gn(o)===c&&o.enabled&&("key"in c?s(o):o.auth==="signed-in"))]))}function cn(t){return t.url===void 0||!(gn(t)||t.name===Oe)}function xs(t){return t.enabled&&t.auth!=="needs-sign-in"}const fs=128;function ci(t,s=fs){return t>=s?"exceeds":t*2>=s?"crowds":"fits"}const ri=1500;async function St(t,s,c){try{return await s(`/api/mcp/servers/${encodeURIComponent(t)}/test`,{method:"POST",signal:c})}catch(o){if(c?.aborted)throw o;return{ok:!1,error:o instanceof Error?o.message:String(o),reason:"unreachable"}}}async function Jn(t,s,c,o,r="hostedMcp.testFailed"){const l=await St(t,s,c);if(l.ok)return l;const y=(l.error??"").trim();return{...l,error:n(r,{service:o,reason:y&&!/[.!?]$/.test(y)?`${y}.`:y})}}function _n(t,s){if(s.reason!=="keys"||!pe(t))return s.error??"";const c=s.status?`HTTP ${s.status}`:n("mcp.check.unauthorized");return t.headerKeys.length?n("mcp.check.keysRefused",{reason:c,names:new Intl.ListFormat(Bt(),{style:"long",type:"conjunction"}).format(t.headerKeys)}):n("mcp.check.keysNeeded",{reason:c})}function li(t){const s=Math.max(t.total??0,t.tools?.length??0);if(!s)return n("mcp.check.connectedNone");const c=s===1?n("mcp.check.connectedOne"):n("mcp.check.connectedMany",{count:s}),o=ci(s);return o==="fits"?c:`${c}. ${n(o==="exceeds"?"mcp.check.overLimit":"mcp.check.crowdsLimit",{count:s,limit:fs})}`}function Vn({embedded:t=!1,hostedCards:s,hideHosted:c=!1,refreshKey:o=0}={}){const{state:r,dispatch:l}=et(),y=a=>r.bots?.find(u=>u.id===a)?.name??a,g=r.config?.managedPolicy,k=!!(g&&!g.mcp.allowCustom),[p,h]=d.useState(null),[A,Q]=d.useState(null),[C,M]=d.useState(null),[J,K]=d.useState(null),[H,$]=d.useState(null),[L,le]=d.useState({}),[v,_]=d.useState(null),Z=d.useRef(null),he=d.useRef(null),[X,ee]=d.useState(null),[ye,W]=d.useState(""),[b,f]=d.useState(null),[S,E]=d.useState(!1),[U,B]=d.useState(!1),Y=d.useRef({}),[Pe,Me]=d.useState(null),[Le,we]=d.useState(null),[Re,Ue]=d.useState({}),ne=d.useRef(0),q=d.useRef(!0),fe=a=>pe(a)?gn(a):void 0,V=d.useMemo(()=>p&&oi(p),[p]),ke=s?.onConnections;d.useEffect(()=>{V&&ke?.(V)},[V,ke]);const $e=s?.onServers;d.useEffect(()=>{p&&$e?.(p)},[p,$e]);const oe=a=>(h(a??[]),Gt(a??[]),a??[]),je=a=>le(u=>{const x={...u};return delete x[a],x}),Ne=d.useCallback(()=>{const a=++ne.current;return M("load"),K(null),w("/api/mcp/servers").then(u=>{a===ne.current&&(h(u.servers??[]),Gt(u.servers??[]))}).catch(u=>{a===ne.current&&K(u instanceof Error?u.message:String(u))}).finally(()=>{a===ne.current&&M(null)})},[]);d.useEffect(()=>(q.current=!0,Ne(),()=>{q.current=!1,ne.current+=1}),[Ne,o]);const R=d.useRef(null);R.current=C,d.useEffect(()=>{const a=()=>{if(R.current!==null)return;const u=ne.current;w("/api/mcp/servers").then(x=>{!q.current||R.current!==null||u!==ne.current||(h(x.servers??[]),Gt(x.servers??[]))}).catch(()=>{})};return Is({onFrame:u=>{u.kind==="mcp.changed"&&a()},onMissedFrames:a})},[]);const I=()=>{Q(null),B(!1)},ce=(a,u=!1)=>{Q(a),B(u),K(null),$(null)},se=async(a,u=!1)=>{M(`test:${a}`),Me(a),ne.current+=1,je(a);let x=await St(a,w);if(x.ok)try{oe((await w(`/api/mcp/servers/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})).servers),Y.current[a]=Date.now()}catch(m){x={ok:!1,error:m instanceof Error?m.message:String(m)}}return u&&(x={...x,saved:!0}),q.current&&(le(m=>({...m,[a]:x})),M(null),Me(null)),x},ue=async a=>{M("save"),ne.current+=1,K(null),$(null);const u=[];let x=p??[];try{for(const m of a){const P=m.ownKey?{...m.body,headers:Object.fromEntries(Object.keys(m.body.headers??{}).map(N=>[N,""]))}:m.body;x=oe((await w("/api/mcp/servers",{method:"POST",body:JSON.stringify({name:m.name,...P})})).servers),m.ownKey&&(await w("/api/team/connection-scopes",{method:"PUT",body:JSON.stringify({kind:"mcp",id:m.name,scope:"person"})}),await w(`/api/team/my-connections/mcp/${encodeURIComponent(m.name)}/key`,{method:"PUT",body:JSON.stringify({value:m.ownKey,url:P.url})}),x=oe((await w(`/api/mcp/servers/${encodeURIComponent(m.name)}`,{method:"PUT",body:JSON.stringify({...P,enabled:!1})})).servers)),u.push(m.name)}}catch(m){K(m instanceof Error?m.message:String(m))}M(null),u.length&&I();for(const m of u){const P=await se(m,!0),N=x.find(te=>te.name===m);P.auth==="required"&&N&&u.length===1&&q.current&&await Ee(N)}},re=async([a])=>{const u=p?.find(x=>x.name===A);if(!(!a||!u)){M("save"),ne.current+=1,K(null),$(null);try{let x=a.body,m;if(r.config?.team&&u.scope!=="team"&&typeof x.url=="string"&&!x.oauth&&(await w("/api/team/my-connections")).mcp.some(N=>N.name===a.name)){const N=x.headers??{};if(Object.keys(N).length>1)throw new Error(n("mcp.personal.oneHeader"));const te=Object.values(N)[0];m=typeof te=="string"?te:void 0,x={...x,headers:Object.fromEntries(Object.keys(N).map(ie=>[ie,""]))}}oe((await w(`/api/mcp/servers/${encodeURIComponent(a.name)}`,{method:"PUT",body:JSON.stringify({...x,enabled:u.enabled})})).servers),m&&await w(`/api/team/my-connections/mcp/${encodeURIComponent(a.name)}/key`,{method:"PUT",body:JSON.stringify({value:m,url:x.url})}),I()}catch(x){K(x instanceof Error?x.message:String(x)),M(null);return}M(null),u.runsOn||await se(a.name,!0)}},Se=async a=>{if(a.enabled&&Date.now()-(Y.current[a.name]??0)<ri){$({key:"mcp.switchedOnByTest",params:{name:a.name}});return}M(`toggle:${a.name}`),ne.current+=1,K(null);try{oe((await w(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!a.enabled})})).servers),$({key:"mcp.toggled",params:{name:a.name},stateKey:a.enabled?"mcp.state.off":"mcp.state.on"})}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(null)}},xe=async a=>{M(`test:${a.name}`),ne.current+=1,K(null),je(a.name);const u=await St(a.name,w);le(x=>({...x,[a.name]:u})),M(null)};async function Ee(a){const u=Rt(),x=new AbortController;Z.current=x,_(a.name),ee(null),W(""),f(null),K(null),we(null),$(null),je(a.name);const m=fe(a);try{const P=async te=>{!await u.open(te)&&q.current&&!x.signal.aborted&&f(n("connectors.card.popupBlocked"))},N=await ns(a.name,{api:w,open:P,signal:x.signal,onStarted:(te,ie)=>{ee(te),he.current=ie}});if(!q.current||x.signal.aborted)return;if(N.phase==="succeeded"){ee({...N,flowId:null,authorizationUrl:null});const te=m?await Jn(a.name,w,x.signal,m.label):await St(a.name,w,x.signal);if(x.signal.aborted||!q.current||(le(De=>({...De,[a.name]:te})),!te.ok))return;const ie=await w(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!0})});if(!q.current)return;oe(ie.servers),m&&$({key:"hostedMcp.connected",params:{service:m.label}})}else N.phase!=="cancelled"&&le(te=>({...te,[a.name]:{ok:!1,error:N.message||n("mcp.auth.failed")}}))}catch(P){q.current&&!x.signal.aborted&&le(N=>({...N,[a.name]:{ok:!1,error:P instanceof Error?P.message:String(P)}}))}finally{u.cancel(),Z.current===x&&(Z.current=null,he.current=null,E(!1),_(null),ee(null),W(""),f(null),q.current&&Ne())}}const tt=async a=>{if(!p||C!==null||v!==null)return;const u=p.find(m=>fe(m)===a);if("key"in a){await nt(a,u);return}if(u){await Ee(u);return}M(`hosted:${a.id}`),ne.current+=1,K(null),we(null),$(null);let x;try{const m=Hn(a,p),P=await w("/api/mcp/servers",{method:"POST",body:JSON.stringify({name:m,type:"http",url:a.url,enabled:!1})});if(!q.current)return;if(x=oe(P.servers).find(N=>N.name===m&&fe(N)===a),!x)throw new Error(n("hostedMcp.setupFailed",{service:a.label}))}catch(m){q.current&&we({id:a.id,message:m instanceof Error?m.message:String(m)})}finally{q.current&&M(null)}x&&q.current&&await Ee(x)},nt=async(a,u)=>{const x=Re[a.id]?.trim();if(!p||!x)return;M(`hosted:${a.id}`),ne.current+=1,K(null),we(null),$(null);const m=u?.name??Hn(a,p);je(m);try{const P={type:"http",url:a.url,headers:{[hs]:`Bearer ${x}`},enabled:!1};oe((await w(u?`/api/mcp/servers/${m}`:"/api/mcp/servers",{method:u?"PUT":"POST",body:JSON.stringify(u?P:{name:m,...P})})).servers);const N=await Jn(m,w,void 0,a.label,"hostedMcp.keyTestFailed");if(!q.current||(le(te=>({...te,[m]:N.reason==="keys"?{...N,error:n("hostedMcp.keyRefused",{service:a.label})}:N})),!N.ok))return;oe((await w(`/api/mcp/servers/${m}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})).servers),Ue(te=>({...te,[a.id]:""})),$({key:"hostedMcp.connected",params:{service:a.label}})}catch(P){q.current&&we({id:a.id,message:P instanceof Error?P.message:String(P)})}finally{q.current&&M(null)}},xt=async()=>{if(!v||!X?.flowId||S)return;const a=Z.current;E(!0),f(null);try{const u=await ss(v,X.flowId,ye,w);Z.current===a&&he.current?.(u)}catch(u){Z.current===a&&f(u instanceof Error?u.message:String(u))}finally{Z.current===a&&E(!1)}},Fe=async(a,u)=>{M(`signout:${a.name}`),ne.current+=1,K(null),we(null),$(null),je(a.name);try{if(u&&"key"in u){oe((await w(`/api/mcp/servers/${a.name}`,{method:"DELETE"})).servers);return}fe(a)&&oe((await w(`/api/mcp/servers/${a.name}`,{method:"PATCH",body:JSON.stringify({enabled:!1})})).servers),oe((await w(`/api/mcp/servers/${a.name}/sign-out`,{method:"POST"})).servers)}catch(x){const m=x instanceof Error?x.message:String(x);u?we({id:u.id,message:m}):K(m)}finally{M(null)}};d.useEffect(()=>()=>Z.current?.abort(),[]);const be=async a=>{if(window.confirm(n("mcp.removeConfirm",{name:a.name}))){M(`delete:${a.name}`),ne.current+=1,K(null);try{oe((await w(`/api/mcp/servers/${a.name}`,{method:"DELETE"})).servers),je(a.name),A===a.name&&I()}catch(u){K(u instanceof Error?u.message:String(u))}finally{M(null)}}},Ke=A&&A!=="new"?p?.find(a=>a.name===A):void 0;function ft(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:S,onChange:u=>W(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()||S,"aria-busy":S,onClick:()=>{xt()},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:[S&&e.jsx(ae,{size:14,className:"animate-spin","aria-hidden":"true"}),n(S?"mcp.auth.completing":"mcp.auth.complete")]})]})}function st(a){const u=fe(a);return v===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(ae,{size:13,className:"animate-spin"})," ",X?.phase!=="succeeded"?n("mcp.auth.waiting"):u?n("hostedMcp.loadingTools",{service:u.label}):n("mcp.auth.loadingTools")]}),X?.authorizationUrl&&Et(X.authorizationUrl)&&e.jsx("button",{type:"button",onClick:()=>{f(null),en(X.authorizationUrl).catch(()=>f(n("mcp.auth.openFailed")))},className:"text-accent hover:underline",children:n("mcp.auth.openAgain")}),X?.flowId&&(X.pasteBack?e.jsxs("div",{children:[e.jsx("p",{className:"leading-relaxed text-ink",children:n("mcp.auth.pasteBackHint")}),ft(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")}),ft(a)]})),b&&e.jsx("p",{role:"alert",className:"text-danger",children:b})]})}function Pt(a){const u=p?.find(ie=>fe(ie)===a),x=!!V?.[a.id],m=u&&L[u.name],P=J||(Le?.id===a.id?Le.message:null)||(m&&!m.ok?m.error:null),N=C!==null||v!==null,te=C===`hosted:${a.id}`||u!==void 0&&(v===u.name||C===`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(Pn,{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(Ye,{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&&v===u.name?e.jsx("button",{type:"button",onClick:()=>Z.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:N||p!==null&&!x&&(!!u?.managedBy||k&&!g?.mcp.allowlist.length||"key"in a&&!Re[a.id]?.trim()),onClick:()=>{p===null?Ne():x&&u?Fe(u,a):tt(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:N&&(te||C==="load")?e.jsx(ae,{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:N,autoComplete:"off",spellCheck:!1,"aria-label":n("hostedMcp.keyLabel",{service:a.label}),placeholder:n("hostedMcp.keyPlaceholder",{service:a.label}),onChange:ie=>{const De=ie.target.value;Ue(Lt=>({...Lt,[a.id]:De}))},onKeyDown:ie=>{ie.key==="Enter"&&tt(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:()=>{en(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(pn,{size:11,"aria-hidden":"true"})]})]}),P&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:typeof P=="string"?P:n(P.key,P.params)}),u&&st(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(ie=>!ie.hidden).map(ie=>e.jsx("button",{type:"button",onClick:()=>{l({type:"togglePlugins",open:!1}),Xt(l,"access",{botId:ie.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:ie.name})},ie.id))})]})]})]})}function Mt(a,u){const x=pe(a)&&a.auth==="needs-sign-in",m=L[a.name],P=m&&!m.ok&&!m.auth?n("mcp.check.failed",{reason:_n(a,m)}):null,N=x?n("mcp.auth.needsSignIn"):a.offFor?.length?n("mcp.offFor",{bots:a.offFor.map(y).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(Sn,{size:19}):e.jsx(qt,{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}),xs(a)&&e.jsx(Ye,{size:13,strokeWidth:2.5,className:"shrink-0 text-success","aria-label":n("apps.connected")})]}),e.jsx("p",{className:G("truncate text-[13px] leading-[18px]",x?"text-warning":"text-ink-secondary"),title:N,children:N})]}),v===a.name?e.jsx("button",{type:"button",onClick:()=>Z.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&&(C!==null||v!==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:[P&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:P}),st(a)]})]},a.name)}if(s){const a=s.ownServers;return e.jsxs(e.Fragment,{children:[pt.map(u=>e.jsx("div",{className:s.shown(u.id)?"contents":"hidden",children:Pt(u)},u.id)),a&&p?.filter(u=>u.enabled&&cn(u)&&a.shown(u)).map(u=>Mt(u,a.manage))]})}const ze=p?.filter(a=>!c||cn(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:C!==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(tn,{size:16,className:G(C==="load"&&"animate-spin")})}),e.jsxs("button",{type:"button",disabled:C!==null||k&&!g?.mcp.allowlist.length,title:k&&g?n("policy.managedBy",{organization:g.organizationName}):void 0,onClick:()=>ce("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(rs,{size:14})," ",n(t?"apps.mcp.add":"mcp.addServer")]})]})]}),k&&g&&e.jsx("p",{role:"status",className:"mt-3 text-[13px] leading-relaxed text-ink-secondary",children:n("policy.mcpRestricted",{organization:g.organizationName})}),(A==="new"||Ke)&&e.jsx(ni,{server:Ke,fixKeys:U,taken:(p??[]).map(a=>a.name),team:!!r.config?.team,busy:C!==null,onCancel:I,onSubmit:a=>{A==="new"?ue(a):re(a)}},`${A}${U?":keys":""}`),J&&e.jsx("div",{role:"alert",className:"mt-3 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:typeof J=="string"?J:n(J.key,J.params)}),H&&e.jsx("div",{role:"status",className:"mt-3 rounded-lg bg-success/10 px-3 py-2 text-[12px] text-success",children:n(H.key,{...H.params,...H.stateKey?{state:n(H.stateKey)}:{}})}),e.jsx(Aa,{}),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(ae,{size:14,className:"animate-spin"})," ",n("mcp.loading")]}):ze?.length===0&&!A?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(qt,{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=L[a.name],m=pe(a)?a.auth:void 0,P=pe(a)&&!a.runsOn&&(m==="needs-sign-in"||x?.auth==="required"||(!!u||!!a.oauth)&&m!=="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:G("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(Pn,{app:u}):pe(a)?e.jsx(Sn,{size:19}):e.jsx(qt,{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:G("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")}),m&&e.jsx("span",{className:G("rounded-full px-2 py-0.5 text-[11px]",m==="signed-in"?"bg-success/10 text-success":"bg-warning/10 text-warning"),children:n(m==="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:y(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(y).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:[v===a.name?e.jsxs("button",{type:"button",onClick:()=>Z.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(ae,{size:14,className:"animate-spin"})," ",n("mcp.auth.cancel")]}):P?e.jsxs("button",{type:"button",disabled:C!==null||v!==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(Ts,{size:14})," ",u?n("hostedMcp.connect",{service:u.label}):n("mcp.auth.signIn")]}):m==="signed-in"?e.jsxs("button",{type:"button",disabled:C!==null||v!==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:[C===`signout:${a.name}`?e.jsx(ae,{size:14,className:"animate-spin"}):e.jsx(ca,{size:14})," ",u?n("hostedMcp.disconnect",{service:u.label}):n("mcp.auth.signOut")]}):null,e.jsxs("button",{type:"button",disabled:C!==null||v!==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:[C===`test:${a.name}`?e.jsx(ae,{size:14,className:"animate-spin"}):e.jsx(Os,{size:14})," ",n("mcp.test")]}),e.jsx("button",{type:"button",disabled:C!==null||v!==null,onClick:()=>ce(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(Bs,{size:14})}),e.jsx("button",{type:"button",disabled:C!==null||v!==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(Ps,{size:14})}),e.jsxs("span",{className:"ml-1 flex items-center",children:[C===`toggle:${a.name}`&&e.jsx(ae,{size:13,className:"mr-1.5 animate-spin text-ink-secondary"}),e.jsx(un,{checked:a.enabled,disabled:C!==null||v!==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(N=>!N.hidden).map(N=>e.jsx("button",{type:"button",onClick:()=>{l({type:"togglePlugins",open:!1}),Xt(l,"access",{botId:N.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:N.name})},N.id))})]})]}),e.jsx(Na,{server:a,disabled:C!==null||v!==null,onSaved:N=>{ne.current+=1,oe(N)}}),st(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(ae,{size:13,className:"animate-spin","aria-hidden":"true"})," ",n("mcp.check.testingOff")]}),x&&v!==a.name&&e.jsx("div",{role:"status",className:G("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(Ms,{size:14,className:"mt-px shrink-0"})," ",li(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:_n(a,x)})}),x.reason==="keys"&&pe(a)||x.reason==="unreachable"||x.reason==="timeout"?e.jsx("button",{type:"button",disabled:C!==null||v!==null,onClick:()=>x.reason==="keys"?ce(a.name,!0):void se(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 qe="/api/postiz",di="postiz social media posts schedule linkedin instagram facebook tiktok threads bluesky",Zt={slug:Oe,categories:["Social"]};function mt(t){try{return new URL(t.trim()).host}catch{return t.trim()}}function rn(t,s){const c=t?.body,o=typeof c?.code=="string"?c.code:null,r=mt(s);return o==="key_rejected"?n("postiz.error.keyRejected"):o==="unreachable"?n("postiz.error.unreachable",{host:r}):o==="not_postiz"?n("postiz.error.notPostiz",{host:r}):o==="address"?n("postiz.error.address"):o==="taken"?n("postiz.taken"):typeof c?.error=="string"&&c.error?c.error:t instanceof Error?t.message:String(t)}function ui(t,s){const c=t instanceof Error?t.message:"";return/didn't accept this API key/u.test(c)||t?.name==="KeyRejected"?n("postiz.error.keyRejected"):/Couldn't reach a Postiz server/u.test(c)?n("postiz.error.unreachable",{host:mt(s)}):/didn't answer like Postiz/u.test(c)?n("postiz.error.notPostiz",{host:mt(s)}):rn(t,s)}const Ze="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",Wt="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",Gn="text-[12px] text-accent-text underline underline-offset-2",We=encodeURIComponent(Oe),pi=1500,mi=5*6e4;function hi(){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 xi({refreshKey:t=0,onConnection:s}){const{state:c,dispatch:o}=et(),[r,l]=d.useState(null),[y,g]=d.useState(!1),[k,p]=d.useState(!1),[h,A]=d.useState(null),[Q,C]=d.useState(null),[M,J]=d.useState(!1),[K,H]=d.useState(""),[$,L]=d.useState(null),[le,v]=d.useState(!1),[_,Z]=d.useState(""),[he,X]=d.useState(""),[ee,ye]=d.useState(!1),[W,b]=d.useState(null),f=d.useRef(!0),S=d.useRef(null),E=d.useCallback(async()=>{const I=(await w("/api/team/my-connections").catch(()=>null))?.mcp?.find(ce=>ce.name===Oe);return I?{connected:I.connected,how:I.how}:{connected:!1,how:null}},[]),U=d.useCallback(async(R=!1)=>{try{const I=await w(R?`${qe}/check`:qe,R?{method:"POST"}:void 0);if(!f.current)return null;if(!ii(I))throw new Error("unexpected Postiz status");return l(I),p(!1),I.team&&I.scope==="person"&&b(await E()),I}catch(I){return f.current&&(I.status===403?g(!0):p(!0)),null}},[E]);d.useEffect(()=>(f.current=!0,U().then(R=>{R?.state==="connected"&&R.scope==="team"&&U(!0)}),()=>{f.current=!1,S.current?.controller.abort(),S.current=null}),[U,t]);const B=r?.team===!0&&r.scope==="person",Y=B?W?.connected===!0:r?.state==="connected";d.useEffect(()=>{s?.(r?Y:null)},[r,Y,s]);const Pe=R=>o({type:"configStatus",config:R}),Me=async()=>{await w("/api/team/connection-scopes",{method:"PUT",body:JSON.stringify({kind:"mcp",id:Oe,scope:"person"})}),await w(`/api/mcp/servers/${We}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})},Le=async(R,I)=>{const ce=await w(`/api/team/my-connections/mcp/${We}/sign-in`,{method:"POST"}),se=Et(ce.auth.authorizationUrl);if(!se)throw new Error(n("mcp.auth.failed"));C({...ce.auth,flowId:null,pasteBack:!1}),!await I(se)&&f.current&&L(n("connectors.popupBlockedContinue"));const ue=Date.now()+mi;for(;!R.signal.aborted&&Date.now()<ue;)if(await new Promise(Se=>setTimeout(Se,pi)),(await E())?.connected)return;if(!R.signal.aborted)throw new Error(n("postiz.signInExpired"))},we=async()=>{if(h||S.current)return;const R=Rt(),I=new AbortController;S.current={controller:I},A("sign-in"),L(null),H("");const ce=async se=>{const ue=await R.open(se);return R.cancel(),ue};try{if(await w(`${qe}/sign-in`,{method:"POST"}),ee||B){ee&&!B&&await Me(),await Le(I,ce);return}const se=await ns(Oe,{api:w,signal:I.signal,open:async re=>{!await ce(re)&&f.current&&!I.signal.aborted&&L(n("connectors.popupBlockedContinue"))},onStarted:(re,Se)=>{S.current?.controller===I&&(S.current.complete=Se),f.current&&C(re)}});if(I.signal.aborted||!f.current)return;if(se.phase!=="succeeded"){se.phase!=="cancelled"&&L(se.message||n("mcp.auth.failed"));return}J(!0);const ue=await w(`/api/mcp/servers/${We}/test`,{method:"POST",signal:I.signal});if(!ue.ok){const re=(ue.error??"").trim();L(n("postiz.error.testFailed",{reason:re&&!/[.!?]$/u.test(re)?`${re}.`:re}));return}await w(`/api/mcp/servers/${We}`,{method:"PATCH",body:JSON.stringify({enabled:!0})})}catch(se){f.current&&!I.signal.aborted&&L(rn(se,lt))}finally{R.cancel(),S.current?.controller===I&&(S.current=null),f.current&&(C(null),J(!1),A(null),await U())}},Re=async()=>{const R=S.current;if(!(!R||!Q?.flowId||!K.trim()))try{R.complete?.(await ss(Oe,Q.flowId,K,w))}catch(I){f.current&&L(I instanceof Error?I.message:String(I))}},Ue=async()=>{const R=Ls(_),I=B||ee?"":he.trim();if(!h){if(!is(R))return L(n("keys.notAKey"));A("key"),L(null);try{if(await w(`${qe}/key-check`,{method:"POST",body:JSON.stringify({key:R,...I?{address:I}:{}})}),ee||B){await w(`${qe}/sign-in`,{method:"POST"}),B||await Me();const se=(await w("/api/mcp/servers")).servers?.find(ue=>ue.name===Oe)?.url;await w(`/api/team/my-connections/mcp/${We}/key`,{method:"PUT",body:JSON.stringify({value:R,url:se})})}else{const ce=c.config?.postiz?.url??"",se=I&&mt(I)!==mt(lt)?I:"";se!==ce&&Pe(await w("/api/config",{method:"PUT",body:JSON.stringify({postiz:{url:se}})})),Pe(await zt("postiz",R,c.config?.postiz?.configured!==!0))}if(It("postiz","apps","ok"),!f.current)return;Z(""),v(!1)}catch(ce){It("postiz","apps",os(ce)),f.current&&L(ui(ce,I||lt))}finally{f.current&&(A(null),await U())}}},ne=async()=>{if(!(h||!window.confirm(n("postiz.disconnectConfirm")))){A("disconnect"),L(null);try{B?await w(`/api/team/my-connections/mcp/${We}`,{method:"DELETE"}):(r?.keySaved&&Pe(await zt("postiz","",!1)),await w(qe,{method:"DELETE"}))}catch(R){f.current&&L(rn(R,r?.address??lt))}finally{f.current&&(A(null),await U())}}},q=()=>S.current?.controller.abort();if(y)return null;const fe=h==="sign-in",V=!B&&r?.state==="needs-sign-in",ke=!B&&r?.state==="key-refused",$e=r?.state==="blocked"||r?.state==="taken",oe=r?.state==="taken"?n("postiz.taken"):r?.state==="blocked"?r.message??n("postiz.description"):Y?B?n("postiz.connectedOwn"):r?.how==="key"?n("postiz.connectedKey",{host:r.host}):n("postiz.connectedTo",{host:r?.host??""}):V?n("connectors.signedOut"):ke?n("postiz.keyRefused"):n("postiz.description"),je=(Y||V||ke)&&e.jsx(as,{placement:"below",ariaLabel:n("postiz.menu"),triggerClassName:"shrink-0",items:[{key:"disconnect",label:n("connectors.disconnect"),disabled:h!==null,onSelect:()=>{ne()}}],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:h==="disconnect"?e.jsx(ae,{size:14,className:"animate-spin"}):e.jsx(ra,{size:15,"aria-hidden":"true"})})}),Ne=r!==null&&!Y&&!$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(hi,{}),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"}),Y&&e.jsx(Ye,{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:oe,children:oe})]}),fe?e.jsx("button",{type:"button",onClick:q,className:Ze,children:n("mcp.auth.cancel")}):r===null?k?e.jsx("button",{type:"button",onClick:()=>{U()},className:Ze,children:n("connectors.action.retry")}):e.jsx("button",{type:"button",disabled:!0,className:Ze,"aria-label":n("common.checking"),children:e.jsx(ae,{size:14,className:"animate-spin"})}):Y?je:Ne&&!le?e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-label":n(V||ke?"postiz.reconnect":"postiz.connect"),disabled:h!==null,onClick:()=>ke?(v(!0),L(null)):void we(),className:Ze,children:n(V||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(ae,{size:12,className:"shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{children:n(M?"postiz.loadingTools":"postiz.finishInBrowser")}),Q?.authorizationUrl&&Et(Q.authorizationUrl)&&e.jsx("button",{type:"button",onClick:()=>{en(Q.authorizationUrl).catch(()=>L(n("mcp.auth.openFailed")))},className:Gn,children:n("mcp.auth.openAgain")})]}),Q?.flowId&&Q.pasteBack&&e.jsxs("form",{"data-postiz-paste":!0,className:"flex flex-col gap-1.5",onSubmit:R=>{R.preventDefault(),Re()},children:[e.jsx("span",{className:"leading-relaxed text-ink",children:n("mcp.auth.pasteBackHint")}),e.jsx("input",{type:"text",value:K,onChange:R=>H(R.target.value),autoComplete:"off",spellCheck:!1,"aria-label":n("mcp.auth.callbackUrl"),placeholder:"http://127.0.0.1:…/mcp-oauth/callback?…",className:Wt}),e.jsx("button",{type:"submit",disabled:!K.trim(),className:Ze,children:n("mcp.auth.complete")})]})]}),$&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:$}),Ne&&!fe&&r.team&&!B&&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:ee,onChange:R=>ye(R.target.checked)})," ",n("mcp.team.onlyMe")]}),B&&!Y&&!fe&&e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-ink-secondary",children:n("postiz.personScope")}),Ne&&!fe&&(le?e.jsxs("form",{"data-postiz-key-form":!0,className:"mt-2 flex flex-col gap-2",onSubmit:R=>{R.preventDefault(),Ue()},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,"aria-label":n("postiz.keyField"),placeholder:n("keys.postiz.placeholder"),value:_,disabled:h==="key",onChange:R=>{L(null),Z(R.target.value)},className:Wt}),!B&&!ee&&e.jsx("input",{type:"url",autoComplete:"off",spellCheck:!1,"aria-label":n("postiz.addressField"),placeholder:lt,value:he,disabled:h==="key",onChange:R=>{L(null),X(R.target.value)},className:Wt}),e.jsx("p",{className:"text-[12px] leading-relaxed text-ink-secondary",children:n(B||ee?"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:h!==null||!_.trim(),className:Ze,children:h==="key"?e.jsx(ae,{size:14,className:"animate-spin"}):n("connectors.action.connect")}),e.jsxs("a",{href:ai,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(pn,{size:11,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",onClick:()=>{v(!1),L(null)},className:"text-[12px] text-ink-secondary underline underline-offset-2 hover:text-ink",children:n("postiz.useSignIn")})]})]}):e.jsx("button",{type:"button",onClick:()=>{v(!0),L(null),X(r.selfHosted?r.address:"")},className:`mt-1.5 inline-block ${Gn}`,children:n("postiz.useKey")}))]})]})}const qn=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0,Zn=t=>typeof t=="string"&&t.length<=40&&!Number.isNaN(Date.parse(t));function fi(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const{calls:s,max:c,usedUp:o,resetsAt:r,trialEndsAt:l}=t;return!qn(s)||!qn(c)||!Zn(r)||l!==void 0&&!Zn(l)?null:{calls:Math.min(s,c),max:c,...o===!0||s>=c?{usedUp:!0}:{},resetsAt:r,...l!==void 0?{trialEndsAt:l}:{}}}function gi(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||fi(s.usage)!==null)}const bi="https://treg.to",At="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",yi="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",ki="x twitter treg tweets posts";function ji(){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 Yt=t=>new Intl.DateTimeFormat(Bt(),{day:"numeric",month:"long",timeZone:"UTC"}).format(new Date(t)),Wn=t=>t.toLocaleString(Bt());function vi(t){const s={used:Wn(t.calls),max:Wn(t.max)};return t.trialEndsAt?t.usedUp?{line:n("apps.x.usedUpTrial",{date:Yt(t.trialEndsAt)}),usedUp:!0}:{line:n("apps.x.usageTrial",s),usedUp:!1}:t.usedUp?{line:n("apps.x.usedUp",{date:Yt(t.resetsAt)}),usedUp:!0}:{line:`${n("apps.x.usage",s)} ${n("apps.x.resets",{date:Yt(t.resetsAt)})}`,usedUp:!1}}function wi({refreshKey:t=0,onConnection:s}){const{state:c,dispatch:o}=et(),[r,l]=d.useState(null),[y,g]=d.useState(!1),[k,p]=d.useState(null),[h,A]=d.useState(""),[Q,C]=d.useState(null),[M,J]=d.useState(null),[K,H]=d.useState(!1),$=d.useRef(!0),L=d.useRef(!1),le=ws(ua()?.view??null)==="connecting",v=c.config?.treg?.configured===!0,_=c.config?.xResearch?.included===!0,Z=d.useCallback(async(E=!1)=>{try{const U=await w(`/api/x/status${E?"?refresh=1":""}`);if(!$.current)return;if(!gi(U))throw new Error("unexpected X status");l(U),g(!1)}catch{$.current&&g(!0)}},[]);d.useEffect(()=>($.current=!0,Z(t>0),()=>{$.current=!1}),[Z,t,v,_]),d.useEffect(()=>{s?.(r?r.using!==null:null)},[r,s]);const he=E=>(o({type:"configStatus",config:E}),Z(!0)),X=async()=>{p("test"),J(null);try{const E=await w("/api/keys/test",{method:"POST",body:JSON.stringify({provider:"treg"})});return $.current&&J(Us(E)),Rn(E)}catch(E){return $.current&&J(E instanceof Error?E.message:String(E)),Rn(null)}finally{$.current&&p(null)}},ee=async()=>{const E=h.trim();if(!(k||!E)){if(!is(E))return C(n("keys.notAKey"));p("save"),C(null),J(null);try{if(await he(await zt("treg",E,!v)),!$.current)return;A(""),H(!1),It("treg","apps",await X())}catch(U){$.current&&C(U instanceof Error?U.message:String(U)),It("treg","apps",os(U))}finally{$.current&&p(U=>U==="save"?null:U)}}},ye=async()=>{if(!k){p("remove"),C(null),J(null);try{await he(await zt("treg","",!1)),$s("treg","apps")}catch(E){$.current&&C(E instanceof Error?E.message:String(E))}finally{$.current&&p(null)}}};d.useEffect(()=>{L.current&&(L.current=!1,ee())});const W=r?.using??null,b=r?.usage?vi(r.usage):null,f=r!==null&&W!=="own"&&(W===null||K||b?.usedUp===!0),S=r===null?n("apps.x.description"):W==="own"?n("apps.x.own"):W==="included"?n("apps.x.included"):le&&!r.unavailable?n("apps.x.connecting"):n("apps.x.addKey");return e.jsxs("div",{"data-app-tile":"x","data-x-state":r===null?"loading":W??"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(ji,{}),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")}),W!==null&&e.jsx(Ye,{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:S,children:S})]}),r===null?y?e.jsx("button",{type:"button",onClick:()=>{Z(!0)},className:At,children:n("connectors.action.retry")}):e.jsx("button",{type:"button",disabled:!0,className:At,"aria-label":n("common.checking"),children:e.jsx(ae,{size:14,className:"animate-spin"})}):W==="own"?e.jsx("button",{type:"button",disabled:k!==null,onClick:()=>{X()},className:At,children:k==="test"?e.jsx(ae,{size:14,className:"animate-spin"}):n("keys.test")}):null]}),e.jsxs("div",{className:"ps-[52px]",children:[W==="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")}),W==="included"&&b&&e.jsx("p",{"data-x-usage":!0,className:b.usedUp?"mt-1 text-[12px] leading-relaxed text-warning":"mt-1 text-[12px] leading-relaxed text-ink-secondary",children:b.line}),W==="own"&&e.jsxs("button",{type:"button",disabled:k!==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:[k==="remove"&&e.jsx(ae,{size:12,className:"animate-spin","aria-hidden":"true"}),n("apps.x.remove")]}),W==="included"&&!f&&e.jsx("button",{type:"button",onClick:()=>{H(!0),C(null)},className:"mt-1.5 inline-block text-[12px] text-accent-text underline underline-offset-2",children:n("apps.x.useOwnKey")}),f&&e.jsxs("form",{"data-x-key-form":!0,className:"mt-2 flex flex-col gap-2",onSubmit:E=>{E.preventDefault(),ee()},children:[W===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:h,disabled:k==="save",onChange:E=>{C(null),A(E.target.value)},onPaste:()=>{L.current=!0},className:yi}),e.jsx("button",{type:"submit",disabled:k!==null||!h.trim(),className:At,children:k==="save"?e.jsx(ae,{size:14,className:"animate-spin"}):n("common.save")})]}),e.jsxs("a",{href:bi,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(pn,{size:11,"aria-hidden":"true"})]})]}),M&&e.jsx("p",{role:"status",className:"mt-1.5 text-[12px] text-ink-secondary",children:M}),Q&&e.jsx("p",{role:"alert",className:"mt-1.5 text-[12px] text-danger",children:Q})]})]})}function ln(t,s,c,o){const r={...t};for(const[l,y]of Object.entries(s))(c.get(l)??0)===(o.get(l)??0)&&(r[l]=y);return r}function Ni(t,s,c,o,r=!0){const l={...t};if(!r)return ln(l,s,c,o);for(const[y,g]of Object.entries(t))s[y]||!g.connected&&!g.accounts?.length||(c.get(y)??0)===(o.get(y)??0)&&(l[y]={connected:!1,pending:!1,status:"not_connected",accounts:[]});return ln(l,s,c,o)}function Ai(t,s,c){return Object.fromEntries(Object.entries(t).filter(([o])=>(s.get(o)??0)===(c.get(o)??0)))}async function Ci(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 Yn({notice:t=!1}){const[s,c]=d.useState(!1),[o,r]=d.useState(()=>dt!==null);if(d.useEffect(()=>{let g=!0;return Ci().then(k=>{g&&c(k)}),dt?.finally(()=>{g&&r(!1)}),()=>{g=!1}},[]),!s)return null;const l=()=>{if(dt)return;r(!0),dt=Promise.resolve(window.ogb?.credentialStore?.reset()).then(()=>{},()=>{}).finally(()=>{dt=null,r(!1)})},y=e.jsx("button",{type:"button",onClick:l,disabled:o,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(cs,{size:14,className:"mt-px shrink-0"}),e.jsxs("span",{children:[n("connectors.savedKeysUnreadable"),y]})]}):y}function Ct({id:t,title:s,note:c,viewAll:o,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,c&&e.jsx("span",{className:"ms-2 text-[12px] font-normal text-ink-secondary",children:c})]}),o&&e.jsx("button",{type:"button",onClick:o.onClick,className:"shrink-0 rounded-full px-2 text-[13px] font-medium leading-5 text-ink-secondary transition-colors hover:text-ink",children:o.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 Si(t,s){const c=s.alias?`“${s.alias}” (${s.id})`:`“${s.id}”`;return n("connectors.disconnectConfirm",{identity:c,service:t})}function Ri(t,s,c){return t.filter(o=>{if(o.hidden||o.composio===!1||!s.find(y=>y.instanceId===o.modelSelection.instanceId)?.capabilities?.composioMcp)return!1;const r=o.connectorTools;if(!r||typeof r!="object"||Array.isArray(r))return!1;const l=r[c];return l===void 0?!0:!na(l)||l.tools!=="*"})}function Ei(t,s,c,o){return(!s||`${t.label} ${t.keywords} ${n(t.description)}`.toLowerCase().includes(s.toLowerCase().trim()))&&(c==="all"||c==="connected"&&o?.[t.id]!==!1)}function zi(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 Xn=48,Ii=16;function Ti(t,s,c){return Ys(t,s).filter(o=>Xs(o,c)!==null)}function Ki(){const{state:t,dispatch:s}=et(),c=window.ogb?.remoteClient?.active===!0,o=d.useRef(null),r=t.pluginsSurface,[l,y]=d.useState(null),[g,k]=d.useState("curated"),[p,h]=d.useState(null),[A,Q]=d.useState(!1),[C,M]=d.useState("unavailable"),[J,K]=d.useState(void 0),[H,$]=d.useState(()=>Nt()?.services??Fs()?.services??{}),[L,le]=d.useState(Nt()?.authoritative===!1),[v,_]=d.useState({}),[Z,he]=d.useState(null),[X,ee]=d.useState(""),[ye,W]=d.useState(null),[b,f]=d.useState(!1),[S,E]=d.useState(Nt()===null?"loading":"ready"),[U,B]=d.useState(null),[Y,Pe]=d.useState(""),[Me,Le]=d.useState("marketplace"),[we,Re]=d.useState(!1),[Ue,ne]=d.useState(null),[q,fe]=d.useState(0),[V,ke]=d.useState(null),[$e,oe]=d.useState(null),[je,Ne]=d.useState(null),[R,I]=d.useState(null),[ce,se]=d.useState([]),ue=d.useRef(new Map),re=d.useRef(new Map),Se=d.useRef(new Map),xe=d.useRef(null),Ee=d.useRef(new Set),tt=(i,j)=>{const O=Object.entries(i).filter(([z,F])=>(re.current.get(z)??0)===(j.get(z)??0)&&(F.connected&&!F.pending||/^(expired|failed)$/i.test(F.status??""))).map(([z])=>z);O.length&&_(z=>O.some(F=>z[F])?Object.fromEntries(Object.entries(z).filter(([F])=>!O.includes(F))):z)},nt=d.useCallback(i=>{if(!i.length)return Promise.resolve({});const j=new Map(i.map(z=>[z,re.current.get(z)??0])),O=new Map(i.map(z=>{const F=(Se.current.get(z)??0)+1;return Se.current.set(z,F),[z,F]}));return w(`/api/connectors?services=${i.join(",")}`).then(z=>{const F=Ai(z.services??{},Se.current,O);return $(D=>ln(D,F,re.current,j)),tt(F,j),F}).catch(()=>({}))},[]),xt=d.useCallback((i=!1)=>{const j=new Map(re.current);return f(!0),Ks(i).then(({services:O,authoritative:z,refused:F})=>(le(!z),F&&B({key:"connectors.adminOnly"}),$(D=>Ni(D,O,re.current,j,z)),tt(O,j),O)).finally(()=>f(!1))},[]),Fe=d.useCallback((i=!1)=>{const j=Nt()!==null;return j||E("loading"),B(null),xt(i).then(O=>(E("ready"),O)).catch(O=>(j||E("error"),B(O instanceof Error?O.message:String(O)),{}))},[xt]);d.useEffect(()=>()=>{xe.current?.cancel(),xe.current=null;for(const i of ue.current.values())i();ue.current.clear()},[]);const be=Ds({status:H,emailConnected:R,inventoryReady:S==="ready"&&!L});d.useEffect(()=>{S==="ready"&&ia(H,!L)},[S,L,H]),d.useEffect(()=>{let i=!0;return Fe(),w("/api/connectors/catalog").then(j=>{i&&(y(j.cards??[]),k(j.source??"curated"),h(j.pagination??null),Q(!!j.configured),M(j.mode??"unavailable"),K(j.setup))}).catch(j=>{i&&(y(O=>O??[]),B(Qs(j)?{key:"connectors.adminOnly"}:j.message))}),()=>{i=!1}},[Fe]),d.useEffect(()=>{const i=document.activeElement instanceof HTMLElement?document.activeElement:null,j=o.current,O=()=>Array.from(j?.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')??[]).filter(D=>D.getClientRects().length>0),z=O();(z.find(D=>D.matches("input"))??z[0]??j)?.focus();const F=D=>{if(D.key==="Escape"){D.preventDefault(),s({type:"togglePlugins",open:!1});return}if(D.key!=="Tab"||!j)return;const de=O();if(de.length===0){D.preventDefault(),j.focus();return}const ve=de[0],Ae=de.at(-1);de.some(ge=>ge===document.activeElement)?D.shiftKey&&document.activeElement===ve?(D.preventDefault(),Ae.focus()):!D.shiftKey&&document.activeElement===Ae&&(D.preventDefault(),ve.focus()):(D.preventDefault(),(D.shiftKey?Ae:ve).focus())};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F),i?.focus()}},[s]);const{suggestions:Ke,picking:ft,pick:st}=Hs(l!==null&&A&&S==="ready",`${q}:${Object.keys(H).filter(i=>H[i]?.connected).sort().join()}`),Pt=async i=>{if(xe.current)return;const j=Rt();xe.current=j;try{!await j.open(i)&&xe.current===j&&B({key:"connectors.popupBlockedContinue"})}finally{j.cancel(),xe.current===j&&(xe.current=null)}},Mt=(i,j,O)=>{ue.current.get(i)?.();const z=sa(j,()=>nt([i]).then(F=>F[i]),F=>{ue.current.get(i)===z&&ue.current.delete(i),aa(i,F),F==="connected"&&O&&be.appConnected(i,l?.find(D=>D.slug===i)?.label??i)});ue.current.set(i,z)},ze=async(i,j,O)=>{if(ye||xe.current)return;const z=Rt();xe.current=z,re.current.set(i,(re.current.get(i)??0)+1),W(i),B(null),O&&Ee.current.add(i);const F=!Ee.current.has(i)&&!ct(H[i]);try{const D=Date.now();O&&await w(`/api/connectors/${i}/accounts/${encodeURIComponent(O.id)}`,{method:"DELETE"});const de={method:"POST"};j&&(de.body=JSON.stringify({alias:j}));const ve=await w(`/api/connectors/${i}/authorize`,de);if(xe.current!==z)return;const Ae=Et(typeof ve.url=="string"?ve.url:null);if(!Ae)throw new Error(n("connectors.invalidAuthorizationUrl"));_(ge=>({...ge,[i]:{url:Ae,createdAt:D}})),$(ge=>({...ge,[i]:{...ge[i],connected:ge[i]?.connected??!1,pending:!0,status:"INITIATED"}})),he(null),ee(""),Mt(i,H[i],F),!await z.open(Ae)&&xe.current===z&&B({key:"connectors.popupBlockedContinue"})}catch(D){if(xe.current!==z)return;const de=D instanceof Error?D.message:String(D);ea(de)?(he(i),ee(""),B({key:"connectors.aliasNeeded"}),nt([i])):B(ta(de)?{key:"connectors.aliasTaken"}:de)}finally{z.cancel(),xe.current===z&&(xe.current=null,W(null))}},a=(i,j)=>{W(i),w(`/api/connectors/${i}/accounts/${encodeURIComponent(j)}`,{method:"DELETE"}).then(()=>nt([i])).catch(O=>B(O.message)).finally(()=>W(null))},u=(l??[]).filter(i=>(!Tn(C,i.slug)||ct(H[i.slug]))&&En(`${i.label} ${i.slug} ${On(i)} ${(i.categories??[]).join(" ")}`,Y)),x=i=>!!(H[i]?.connected||H[i]?.accounts?.length),m=r==="mcp"?"mcp":Me==="connected"?"connected":"all",P=Y.trim().length>0,N=P&&m==="connected"?"all":m,te=new Set(pt.filter(i=>Ei(i,Y,N,Ue)).map(i=>i.id)),ie=(!Y||`email mail imap smtp mailbox ${n("email.description")}`.toLowerCase().includes(Y.toLowerCase().trim()))&&(N==="all"||N==="connected"&&R!==!1),De=(!Y||`${ki} ${n("apps.x.description")}`.toLowerCase().includes(Y.toLowerCase().trim()))&&(N==="all"||N==="connected"&&$e!==!1),Lt=(!Y||`${di} ${n("postiz.description")}`.toLowerCase().includes(Y.toLowerCase().trim()))&&(N==="all"||N==="connected"&&je!==!1),Ut=(N==="connected"?u.filter(i=>x(i.slug)):u).map((i,j)=>({card:i,index:j})).sort((i,j)=>Number(x(j.card.slug))-Number(x(i.card.slug))||i.index-j.index).map(({card:i})=>i),$t=pt.filter(i=>Ue?.[i.id]),bn=ce.filter(i=>cn(i)),yn=i=>En(`${i.name} ${pe(i)?i.url:[i.command,...i.args].join(" ")}`,Y),kn=Object.values(H).filter(ct).length+$t.length+bn.filter(xs).length+ +(R===!0)+ +($e===!0)+ +(je===!0),jn=Js(S),Qe=()=>s({type:"togglePlugins",open:!1}),gt=zi({configured:A,stale:L,setup:J,remoteClient:c}),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"})},Ft=ka([...l??[],Zt],void 0,Zt.categories),Kt=Ft.more,Dt=V!==null&&Kt.includes(V),He=m==="all"&&V!==null&&!P,vn=Lt&&(!He||nn(Zt,V)),gs=!He&&(te.size>0||ie||De)||vn||m==="connected"&&bn.some(i=>i.enabled&&yn(i)),bs=He?Ut.filter(i=>nn(i,V)):Ut,bt=m==="all"&&!P&&V===null,it=bt?ja(Ut,x,Ft.inline):[],ys=it.find(i=>i.kind==="all"),yt=bt?ys?.cards??[]:bs,Qt=bt&&!we&&yt.length>Xn,wn=Qt?yt.slice(0,Xn):yt,Nn=(l??[]).filter(i=>ct(H[i.slug])),Ht=i=>{ke(i),Le("marketplace"),r!=="apps"&&s({type:"togglePlugins",open:!0,surface:"apps"})},ks=P?n("connectors.section.results"):m==="connected"?n("connectors.section.yours"):V?rt(V):it.length>1?n("apps.section.all"):n("connectors.section.available"),Je="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:Gs(),onMouseDown:i=>i.target===i.currentTarget&&Qe(),children:[e.jsx("div",{"aria-hidden":"true",className:"glass-scrim pointer-events-none absolute inset-0"}),e.jsxs("div",{ref:o,"data-tour":"apps-panel",role:"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":m==="connected",onClick:()=>at(m==="connected"?"all":"connected"),className:G("inline-flex h-8 items-center gap-2 rounded-full ps-1.5 pe-2 text-[13px] font-medium leading-5 transition-colors",m==="connected"?"bg-raised text-ink":"text-ink-secondary hover:bg-raised/60 hover:text-ink"),children:[Nn.length>0&&e.jsx("span",{"aria-hidden":"true",className:"flex -space-x-1.5 rtl:space-x-reverse",children:Nn.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(zn,{card:i,className:"size-5 rounded-md"})},i.slug))}),e.jsx("span",{className:"whitespace-nowrap",children:kn>0?n("apps.connectedCount",{count:kn}):n("apps.filter.connected")}),e.jsx(ls,{size:14,"aria-hidden":"true",className:"shrink-0 rtl:-scale-x-100"})]}),e.jsx("button",{onClick:()=>{fe(i=>i+1),Fe(!0)},disabled:b,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(tn,{size:16,className:G(b&&"animate-spin")})}),e.jsx("button",{"data-tour":"apps-close",onClick:Qe,"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(es,{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(Ns,{size:15,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:Y,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":m==="mcp",onClick:()=>at(m==="mcp"?"all":"mcp"),className:G(Je,"h-9 border border-hairline/40 px-3.5",m==="mcp"?"bg-ink text-app":"text-ink hover:bg-raised"),children:[e.jsx(la,{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":m==="all"&&V===null,onClick:()=>{at("all"),ke(null)},className:G(Je,Jt(m==="all"&&V===null)),children:n("apps.filter.all")}),Ft.inline.map(i=>e.jsx("button",{type:"button","data-apps-category":i,"aria-pressed":m==="all"&&V===i,onClick:()=>Ht(V===i?null:i),className:G(Je,Jt(m==="all"&&V===i)),children:rt(i)},i)),Kt.length>0&&e.jsx(as,{ariaLabel:n("apps.moreCategories"),items:Kt.map(i=>({key:i,label:rt(i),active:V===i,onSelect:()=>Ht(i)})),renderTrigger:({open:i})=>e.jsxs("span",{className:G(Je,Jt(m==="all"&&Dt),i&&!Dt&&"bg-raised-hover text-ink"),children:[Dt?rt(V):n("apps.more"),e.jsx(ts,{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:[L?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(cs,{size:14,className:"mt-px shrink-0"}),e.jsxs("span",{children:[n("connectors.stale"),e.jsx(Yn,{})]})]}):e.jsx(Yn,{notice:!0}),gt&&m!=="mcp"&&e.jsxs("div",{className:G("mb-3 rounded-xl px-4 py-3 text-[13px]",gt.tone==="warning"?"bg-warning/10 text-warning":"bg-control/50 text-ink-secondary"),children:[$t.length>0?n("hostedMcp.otherAppsSetup",{services:new Intl.ListFormat(Bt(),{style:"long",type:"conjunction"}).format($t.map(i=>i.label))}):n(gt.key)," ",e.jsx("button",{className:G("font-medium underline underline-offset-2",gt.tone==="info"&&"text-ink",c&&"hidden"),onClick:()=>{Qe(),s(In("composio"))},children:n("connectors.openSettings")})]}),A&&!c&&g==="curated"&&C==="self-hosted"&&m!=="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:()=>{Qe(),s({type:"toggleAppSettings",open:!0})},children:n("connectors.updateKey")})," ",n("connectors.featuredAfter")]}),U&&e.jsx("div",{role:"alert",className:"mb-3 rounded-xl bg-danger/10 px-3 py-2 text-[12px] text-danger",children:typeof U=="string"?U:n(U.key)}),m!=="mcp"&&e.jsxs("div",{"data-apps-grid":!0,className:"@container flex flex-col gap-7 pt-1",children:[!it.some(i=>i.kind==="connected")&&An(),it.filter(i=>i.kind!=="all").map(i=>i.kind==="connected"?e.jsxs(d.Fragment,{children:[e.jsx(Ct,{id:"apps-section-connected",title:n("apps.section.connected"),viewAll:i.cards.length>Tt?{label:n("apps.viewAll"),onClick:()=>at("connected")}:void 0,children:i.cards.slice(0,Tt).map(j=>kt(j))}),An()]},"connected"):e.jsx(Ct,{id:`apps-section-${i.category}`,title:rt(i.category),viewAll:i.more?{label:n("apps.viewAll"),onClick:()=>Ht(i.category)}:void 0,children:i.cards.map(j=>kt(j))},i.category)),e.jsxs(Ct,{id:"apps-grid-title",title:ks,note:m==="all"&&!Y&&V===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(_t()),total:p.totalItems.toLocaleString(_t())}):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(ae,{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:G(Je,"bg-control/70 px-4 text-ink hover:bg-raised-hover"),children:n("apps.showAll",{count:yt.length.toLocaleString(_t())})})}),l!==null&&wn.length===0&&!gs&&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:N==="connected"?jn.title:n("connectors.noAppsFound")}),e.jsx("div",{className:"mt-1 text-[13px] text-ink-secondary",children:N==="connected"?jn.description:n("connectors.tryDifferentSearch")}),m==="connected"&&S==="error"&&e.jsxs("button",{type:"button",disabled:b,onClick:()=>{Fe(!0)},className:G(Je,"mt-4 bg-raised text-ink hover:bg-raised-hover disabled:opacity-50"),children:[e.jsx(tn,{size:14,className:G(b&&"animate-spin")}),n("connectors.action.retry")]})]})]}),children:[e.jsx(Vn,{hostedCards:{shown:i=>!He&&te.has(i),onConnections:ne,onServers:se,...m==="connected"?{ownServers:{shown:yn,manage:()=>at("mcp")}}:{}},refreshKey:q}),e.jsx("div",{"data-native-card":"x",className:De&&!He?"contents":"hidden",children:e.jsx(wi,{refreshKey:q,onConnection:oe})}),e.jsx("div",{"data-native-card":"email",className:ie&&!He?"contents":"hidden",children:e.jsx(_s,{refreshKey:q,onConnection:I})}),e.jsx("div",{"data-native-card":"postiz",className:vn?"contents":"hidden",children:e.jsx(xi,{refreshKey:q,onConnection:Ne})}),wn.map(i=>kt(i))]})]}),m!=="connected"&&V===null&&e.jsx("div",{className:G(m==="all"&&"mt-8 border-t border-hairline/30 pt-6",m==="mcp"&&"pt-1"),children:e.jsx(Vn,{embedded:!0,hideHosted:m==="all"})})]}),be.changing&&e.jsx(Vs,{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 An(){const i=Ke.cards.filter(O=>!x(O.slug));if(!bt||i.length===0)return null;const j=Ke.pick==="available"?{label:n(ft?"apps.suggested.picking":"apps.suggested.show"),onClick:st}:Ke.pick==="needs-key"&&!c?{label:n("apps.suggested.addKey"),onClick:()=>{Qe(),s(In("jev"))}}:void 0;return e.jsx(Ct,{id:"apps-section-suggested",title:n("apps.section.suggested"),note:Ke.pick==="picked"?n("apps.suggested.picked"):void 0,viewAll:j,children:i.map(O=>kt(O))})}function kt(i){const j=H[i.slug],O=j?.status&&/^(expired|failed)$/i.test(j.status),z=j?.pending&&!O,F=z&&!O?v[i.slug]:void 0,D=Vt(F),de=j?.accounts??[],ve=i.noAuth===!0||j?.connected===!0&&!de.length&&!z&&!O,Ae=ct(j),ge=z?void 0:qs(j),js=Z===i.slug&&!ve,_e=ye===i.slug,jt=t.config?.managedPolicy,vt=jt?.apps&&!jt.apps.allowAll&&!jt.apps.allowlist.includes(i.slug)?n("policy.managedBy",{organization:jt.organizationName}):Tn(C,i.slug)?n("connectors.selfHostOnlyReason"):null,ot=Ae||ve?Ti(t.bots,t.instances,i.slug):[],wt=n("apps.usedBy",{names:ot.map(T=>T.name).join(", ")}),Cn=vt??(z?D?n("connectors.finishSetup"):n("connectors.finishSetupOrDisconnect"):ge?n("connectors.signedOut"):O&&!de.length?n("connectors.authExpired"):On(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(zn,{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&&!z&&e.jsx(Ye,{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:wt,"aria-label":wt,role:"img",children:ot.slice(0,3).map(T=>e.jsx("span",{"data-used-by-avatar":T.id,className:"flex size-5 shrink-0 items-center justify-center overflow-hidden rounded-full bg-menu ring-2 ring-menu",children:e.jsx(da,{bot:T,size:Ii,animated:!1})},T.id))})]}),e.jsx("div",{className:"truncate text-[13px] leading-[18px] text-ink-secondary",title:Cn,children:Cn})]}),e.jsx("button",{type:"button",disabled:!A||S!=="ready"||_e||ve||!!vt,title:vt??void 0,onClick:()=>{if(z&&!O){const T=Vt(F);T?(B(null),Pt(T).catch(Ie=>B(Ie.message))):ze(i.slug)}else ge?ze(i.slug,ge.alias,ge):(he(T=>T===i.slug?null:i.slug),ee(""))},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:vt?n("connectors.selfHostOnly"):_e?e.jsx(ae,{size:14,className:"animate-spin"}):Zs(S,{busy:_e,included:ve,canContinue:!!F,pending:z,reconnect:!!ge,hasAccounts:de.length>0,failed:!!O})})]}),e.jsxs("div",{className:"ps-[52px]",children:[D&&e.jsx("a",{href:D,target:"_blank",rel:"noopener noreferrer",onClick:T=>{Vt(F)||(T.preventDefault(),ze(i.slug))},className:"mt-1.5 inline-block text-[12px] text-accent-text underline underline-offset-2",children:n("connectors.openAuthorizationPage")}),Ae&&!z&&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?wt:void 0,children:ot.length?wt: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(T=>{const Ie=/^active$/i.test(T.status),Ve=Ws(T)&&T.id!==ge?.id;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[12px] leading-5",children:[Ie?e.jsx(Ye,{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:`${T.alias?`${T.id} · `:""}${T.status.toLowerCase()}`,children:[T.alias||T.id,e.jsxs("span",{className:"text-ink-secondary",children:[" · ",T.status.toLowerCase()]})]}),Ve&&e.jsx("button",{type:"button",disabled:_e,onClick:()=>{ze(i.slug,T.alias,T)},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:T.alias||T.id,service:i.label}),children:n("connectors.action.reconnect")}),e.jsx("button",{type:"button",disabled:_e,onClick:()=>{window.confirm(Si(i.label,T))&&a(i.slug,T.id)},className:G("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",!Ve&&"ms-auto"),"aria-label":n("connectors.disconnectAria",{account:T.alias||T.id,service:i.label}),children:n("connectors.disconnect")})]},T.id)})}),(j?.connected||ve)&&(()=>{const T=Ri(t.bots,t.instances,i.slug);if(!T.length)return null;const Ie=T.slice(0,4).map((Ve,vs)=>e.jsxs("span",{children:[vs>0&&", ",e.jsx("button",{type:"button",onClick:()=>{Qe(),Xt(s,"access",{botId:Ve.id,page:"apps"})},className:"font-medium text-ink underline underline-offset-2 hover:text-accent-text",children:Ve.name})]},Ve.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:T.length})})," ",Ie,T.length>4&&e.jsx("span",{children:n("connectors.grants.more",{count:T.length-4})})]})})(),js&&e.jsxs("form",{className:"mt-2 flex items-center gap-2",onSubmit:T=>{T.preventDefault();const Ie=X.trim();if(!Ie){B({key:"connectors.aliasRequired"});return}ze(i.slug,Ie)},children:[e.jsx("input",{autoFocus:!0,value:X,maxLength:64,onChange:T=>ee(T.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||!X.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{Xn as APPS_PREVIEW_COUNT,Ki as PluginsPanel,zn as ServiceIcon,Ii as USED_BY_AVATAR_SIZE,Ti as botsUsingService,Ri as botsWithLimitedServiceTools,zi as connectorSetupNotice,Si as disconnectAccountConfirmation,Ei as hostedShown,Ks as preloadConnectedApps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c}from"./styles-
|
|
1
|
+
import{r as c}from"./styles-BlayaJti.js";import{u as i}from"./App-DFjF9FvF.js";import"./PlacesRail-v1XIqiBG.js";function l(n,o){const t=n&&!window.ogb?.remoteClient?.active?window.ogb?.cloudAccount:void 0,[u,e]=c.useState(null),f=t?.offer?JSON.stringify(o??null):null;return c.useEffect(()=>{if(f===null||!t?.offer)return;let r=!0;return t.offer().then(a=>{r&&e(a)},()=>{}),()=>{r=!1}},[t,f]),t?.offer?u:null}function s(){const n=window.ogb?.remoteClient?.active?void 0:window.ogb?.cloudAccount,[o,t]=c.useState(null);return c.useEffect(()=>{if(!n)return;let u=!0,e=!1;const f=n.onState(r=>{e=!0,u&&t(r)});return n.state().then(r=>{u&&!e&&t(r)}).catch(()=>{}),()=>{u=!1,f()}},[n]),null}function b(){const{dispatch:n}=i(),o=s();return l(o!==null,o?.account?.offer),null}function w({place:n,usage:o=null,upgrade:t}){const{dispatch:u}=i(),e=s();return l(e!==null,e?.account?.offer),null}function v(){const n=s();return l(n!==null,n?.account?.offer),null}export{w as C,b as P,l as a,v as b,s as u};
|