@samanhappy/mcphub 1.1.10 → 1.1.12

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.
Files changed (136) hide show
  1. package/README.md +4 -0
  2. package/README.zh.md +4 -0
  3. package/dist/cli/commands/keys.js +2 -2
  4. package/dist/cli/commands/keys.js.map +1 -1
  5. package/dist/clients/legacyMcpClient.js +10 -2
  6. package/dist/clients/legacyMcpClient.js.map +1 -1
  7. package/dist/controllers/bearerKeyController.js +5 -4
  8. package/dist/controllers/bearerKeyController.js.map +1 -1
  9. package/dist/controllers/configController.js +1 -1
  10. package/dist/controllers/configController.js.map +1 -1
  11. package/dist/controllers/groupController.js +19 -0
  12. package/dist/controllers/groupController.js.map +1 -1
  13. package/dist/controllers/serverController.js +5 -2
  14. package/dist/controllers/serverController.js.map +1 -1
  15. package/dist/dao/BearerKeyDao.js +34 -7
  16. package/dist/dao/BearerKeyDao.js.map +1 -1
  17. package/dist/dao/BearerKeyDaoDbImpl.js +18 -3
  18. package/dist/dao/BearerKeyDaoDbImpl.js.map +1 -1
  19. package/dist/dao/CapabilitySnapshotDao.js +38 -0
  20. package/dist/dao/CapabilitySnapshotDao.js.map +1 -0
  21. package/dist/dao/CapabilitySnapshotDaoDbImpl.js +18 -0
  22. package/dist/dao/CapabilitySnapshotDaoDbImpl.js.map +1 -0
  23. package/dist/dao/DaoFactory.js +7 -0
  24. package/dist/dao/DaoFactory.js.map +1 -1
  25. package/dist/dao/DatabaseDaoFactory.js +4 -0
  26. package/dist/dao/DatabaseDaoFactory.js.map +1 -1
  27. package/dist/dao/ServerDaoDbImpl.js +3 -0
  28. package/dist/dao/ServerDaoDbImpl.js.map +1 -1
  29. package/dist/db/entities/BearerKey.js +10 -2
  30. package/dist/db/entities/BearerKey.js.map +1 -1
  31. package/dist/db/entities/CapabilitySnapshot.js +37 -0
  32. package/dist/db/entities/CapabilitySnapshot.js.map +1 -0
  33. package/dist/db/entities/Group.js.map +1 -1
  34. package/dist/db/entities/Server.js +4 -0
  35. package/dist/db/entities/Server.js.map +1 -1
  36. package/dist/db/entities/index.js +3 -1
  37. package/dist/db/entities/index.js.map +1 -1
  38. package/dist/db/repositories/BearerKeyRepository.js +20 -3
  39. package/dist/db/repositories/BearerKeyRepository.js.map +1 -1
  40. package/dist/middlewares/auth.js +2 -2
  41. package/dist/middlewares/auth.js.map +1 -1
  42. package/dist/server.js +11 -1
  43. package/dist/server.js.map +1 -1
  44. package/dist/services/capabilitySnapshotService.js +106 -0
  45. package/dist/services/capabilitySnapshotService.js.map +1 -0
  46. package/dist/services/credentialBindingService.js +4 -0
  47. package/dist/services/credentialBindingService.js.map +1 -1
  48. package/dist/services/groupService.js +1 -0
  49. package/dist/services/groupService.js.map +1 -1
  50. package/dist/services/keepAliveService.js +52 -36
  51. package/dist/services/keepAliveService.js.map +1 -1
  52. package/dist/services/mcpOAuthProvider.js +19 -2
  53. package/dist/services/mcpOAuthProvider.js.map +1 -1
  54. package/dist/services/mcpService.js +405 -103
  55. package/dist/services/mcpService.js.map +1 -1
  56. package/dist/services/oauthClientRegistration.js +2 -1
  57. package/dist/services/oauthClientRegistration.js.map +1 -1
  58. package/dist/services/principalRuntimeService.js +27 -3
  59. package/dist/services/principalRuntimeService.js.map +1 -1
  60. package/dist/services/smartRoutingService.js +19 -5
  61. package/dist/services/smartRoutingService.js.map +1 -1
  62. package/dist/services/sseService.js +3 -3
  63. package/dist/services/sseService.js.map +1 -1
  64. package/dist/services/templateService.js +5 -0
  65. package/dist/services/templateService.js.map +1 -1
  66. package/dist/services/upstreamListRefresh.js +37 -0
  67. package/dist/services/upstreamListRefresh.js.map +1 -0
  68. package/dist/utils/bearerKeyToken.js +27 -0
  69. package/dist/utils/bearerKeyToken.js.map +1 -0
  70. package/dist/utils/groupToolNames.js +21 -0
  71. package/dist/utils/groupToolNames.js.map +1 -0
  72. package/dist/utils/mcpProtocol.js +14 -1
  73. package/dist/utils/mcpProtocol.js.map +1 -1
  74. package/dist/utils/migration.js +63 -5
  75. package/dist/utils/migration.js.map +1 -1
  76. package/dist/utils/oauthServerMetadata.js +23 -0
  77. package/dist/utils/oauthServerMetadata.js.map +1 -0
  78. package/dist/utils/parameterConversion.js +9 -2
  79. package/dist/utils/parameterConversion.js.map +1 -1
  80. package/dist/utils/serverConfigPersistence.js +11 -0
  81. package/dist/utils/serverConfigPersistence.js.map +1 -1
  82. package/dist/utils/settingsSync.js +2 -0
  83. package/dist/utils/settingsSync.js.map +1 -1
  84. package/frontend/dist/assets/{ActivityPage-DDa3yAck.js → ActivityPage-DWA-okla.js} +2 -2
  85. package/frontend/dist/assets/{ActivityPage-DDa3yAck.js.map → ActivityPage-DWA-okla.js.map} +1 -1
  86. package/frontend/dist/assets/{CopyClientConfigDialog-DPQOggV-.js → CopyClientConfigDialog-xeHg7JJj.js} +2 -2
  87. package/frontend/dist/assets/{CopyClientConfigDialog-DPQOggV-.js.map → CopyClientConfigDialog-xeHg7JJj.js.map} +1 -1
  88. package/frontend/dist/assets/{CredentialsPage-DmxY-iXb.js → CredentialsPage-D8mMIH5f.js} +2 -2
  89. package/frontend/dist/assets/{CredentialsPage-DmxY-iXb.js.map → CredentialsPage-D8mMIH5f.js.map} +1 -1
  90. package/frontend/dist/assets/{Dashboard-DCvveQBj.js → Dashboard-Diql_Btr.js} +2 -2
  91. package/frontend/dist/assets/{Dashboard-DCvveQBj.js.map → Dashboard-Diql_Btr.js.map} +1 -1
  92. package/frontend/dist/assets/{EndpointCopy-DRWz8guH.js → EndpointCopy-0d-dK6uJ.js} +2 -2
  93. package/frontend/dist/assets/{EndpointCopy-DRWz8guH.js.map → EndpointCopy-0d-dK6uJ.js.map} +1 -1
  94. package/frontend/dist/assets/GroupsPage-gZ0nnzCn.js +33 -0
  95. package/frontend/dist/assets/GroupsPage-gZ0nnzCn.js.map +1 -0
  96. package/frontend/dist/assets/{LoginPage-BVBf8nr6.js → LoginPage-BRyFcGQ5.js} +2 -2
  97. package/frontend/dist/assets/{LoginPage-BVBf8nr6.js.map → LoginPage-BRyFcGQ5.js.map} +1 -1
  98. package/frontend/dist/assets/{LogsPage-DbsmNJcA.js → LogsPage-C7erxObE.js} +2 -2
  99. package/frontend/dist/assets/{LogsPage-DbsmNJcA.js.map → LogsPage-C7erxObE.js.map} +1 -1
  100. package/frontend/dist/assets/{MarketPage-BOggDLJb.js → MarketPage-BZHQQB57.js} +2 -2
  101. package/frontend/dist/assets/{MarketPage-BOggDLJb.js.map → MarketPage-BZHQQB57.js.map} +1 -1
  102. package/frontend/dist/assets/{OAuthConsentPage-VON__2op.js → OAuthConsentPage-Czhwhcx8.js} +2 -2
  103. package/frontend/dist/assets/{OAuthConsentPage-VON__2op.js.map → OAuthConsentPage-Czhwhcx8.js.map} +1 -1
  104. package/frontend/dist/assets/{PromptsPage-BNkvIDZU.js → PromptsPage-D0yHQbns.js} +2 -2
  105. package/frontend/dist/assets/{PromptsPage-BNkvIDZU.js.map → PromptsPage-D0yHQbns.js.map} +1 -1
  106. package/frontend/dist/assets/{ResourcesPage-4WBvamN_.js → ResourcesPage-BFoqAAq0.js} +2 -2
  107. package/frontend/dist/assets/{ResourcesPage-4WBvamN_.js.map → ResourcesPage-BFoqAAq0.js.map} +1 -1
  108. package/frontend/dist/assets/{ServersPage-C7000Szj.js → ServersPage-CMG1tNig.js} +9 -9
  109. package/frontend/dist/assets/ServersPage-CMG1tNig.js.map +1 -0
  110. package/frontend/dist/assets/{SettingsPage-YX6dJjrM.js → SettingsPage-C6GAVHlw.js} +2 -2
  111. package/frontend/dist/assets/{SettingsPage-YX6dJjrM.js.map → SettingsPage-C6GAVHlw.js.map} +1 -1
  112. package/frontend/dist/assets/{StatusDot-mgJveZ2h.js → StatusDot-BniiEZ-W.js} +2 -2
  113. package/frontend/dist/assets/{StatusDot-mgJveZ2h.js.map → StatusDot-BniiEZ-W.js.map} +1 -1
  114. package/frontend/dist/assets/{ToggleGroup-DXyuwPy7.js → ToggleGroup-Df-pFUN3.js} +2 -2
  115. package/frontend/dist/assets/{ToggleGroup-DXyuwPy7.js.map → ToggleGroup-Df-pFUN3.js.map} +1 -1
  116. package/frontend/dist/assets/{UsersPage-BiUn8c0z.js → UsersPage-je7LsHJG.js} +2 -2
  117. package/frontend/dist/assets/{UsersPage-BiUn8c0z.js.map → UsersPage-je7LsHJG.js.map} +1 -1
  118. package/frontend/dist/assets/{clipboard-7MOQ-4Cg.js → clipboard-BrGjez3U.js} +2 -2
  119. package/frontend/dist/assets/{clipboard-7MOQ-4Cg.js.map → clipboard-BrGjez3U.js.map} +1 -1
  120. package/frontend/dist/assets/index-DL9uGzQF.js +3 -0
  121. package/frontend/dist/assets/{index-BKFFbupY.js.map → index-DL9uGzQF.js.map} +1 -1
  122. package/frontend/dist/assets/{index-B3hkLjCv.css → index-JDk4RjZI.css} +1 -1
  123. package/frontend/dist/assets/{resourceService-BOn21QbP.js → resourceService-8K1eUH8N.js} +2 -2
  124. package/frontend/dist/assets/{resourceService-BOn21QbP.js.map → resourceService-8K1eUH8N.js.map} +1 -1
  125. package/frontend/dist/assets/{useCostData-3iIVsNH6.js → useCostData-BuDleGRv.js} +2 -2
  126. package/frontend/dist/assets/{useCostData-3iIVsNH6.js.map → useCostData-BuDleGRv.js.map} +1 -1
  127. package/frontend/dist/assets/variableDetection-Djnw5--_.js +18 -0
  128. package/frontend/dist/assets/variableDetection-Djnw5--_.js.map +1 -0
  129. package/frontend/dist/index.html +2 -2
  130. package/package.json +1 -1
  131. package/frontend/dist/assets/GroupsPage-DtoTWqWU.js +0 -33
  132. package/frontend/dist/assets/GroupsPage-DtoTWqWU.js.map +0 -1
  133. package/frontend/dist/assets/ServersPage-C7000Szj.js.map +0 -1
  134. package/frontend/dist/assets/index-BKFFbupY.js +0 -3
  135. package/frontend/dist/assets/variableDetection-Cpa0rIrf.js +0 -18
  136. package/frontend/dist/assets/variableDetection-Cpa0rIrf.js.map +0 -1
@@ -0,0 +1,33 @@
1
+ import{r as g,j as e,R as M}from"./framework-vendor-CQFm9vKd.js";import{n as Z,f as fe,d as ee,u as ve,j as je,k as se}from"./index-DL9uGzQF.js";import{u as te,a as re}from"./useCostData-BuDleGRv.js";import{u as G}from"./i18n-vendor-DVmjrzgW.js";import{u as me,c as ye}from"./clipboard-BrGjez3U.js";import{f as H,p as Ne}from"./contextCost-CilWqGWT.js";import{g as ke,A as Se,C as we}from"./CopyClientConfigDialog-xeHg7JJj.js";import{W as Ce,g as Ae,F as Te,H as Ee,C as De,r as Q,J as oe,z as Ie,w as Fe,T as ze,n as Pe,D as ce,N as Re,P as de,l as Le,X as Ue}from"./icons-vendor-CkcU1LMA.js";import{D as $e}from"./DeleteDialog-BaCsEkJA.js";const Oe=["read","create","update","delete","other"],Ge=a=>{var s,l,h;if(((s=a.annotations)==null?void 0:s.readOnlyHint)===!0)return"read";const m=a.value.toLowerCase();return/^(delete|remove)[_-]/.test(m)?"delete":((l=a.annotations)==null?void 0:l.destructiveHint)===!0?"other":/^(create|add)[_-]/.test(m)?"create":/^(update|set)[_-]/.test(m)?"update":((h=a.annotations)==null?void 0:h.readOnlyHint)!==!1&&/^(get|list|read|search)[_-]/.test(m)?"read":"other"},We=(a,m,s)=>{const l=m.trim().toLowerCase();return a.filter(h=>{var i,p;return(h.value.toLowerCase().includes(l)||((i=h.description)==null?void 0:i.toLowerCase().includes(l)))&&(s==="all"||((p=h.annotations)==null?void 0:p[s])===!0)})},Me=(a,m,s,l)=>{if(s.length===0||a==="all"&&l==="select")return a;const h=new Set(a==="all"?m:a);for(const i of s)l==="deselect"||l==="invert"&&h.has(i)?h.delete(i):h.add(i);return[...h]},He=({items:a,selection:m,tools:s,label:l,onChange:h,children:i})=>{const{t:p}=G(),[E,I]=g.useState(""),[N,A]=g.useState("all"),[x,w]=g.useState(!1),j=We(a,E,N),T=new Set(m==="all"?a.map(t=>t.value):m),d=(t,o)=>h(Me(m,a.map(c=>c.value),t.map(c=>c.value),o)),b=s&&x?Oe.map(t=>({risk:t,items:j.filter(o=>Ge(o)===t)})):[{risk:null,items:j}],f="text-xs text-blue-600 hover:text-blue-800 disabled:opacity-40 disabled:cursor-not-allowed";return e.jsxs("section",{"aria-label":l,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{type:"search","aria-label":p("groups.bulkSearchLabel",{capability:l}),placeholder:p("groups.bulkSearch"),value:E,onChange:t=>I(t.target.value),className:"min-w-0 flex-1 basis-48 rounded border border-gray-300 bg-white dark:bg-gray-800 px-2 py-1 text-sm"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{"aria-label":p("groups.annotationFilter"),value:N,onChange:t=>A(t.target.value),className:"max-w-full rounded border border-gray-300 bg-white dark:bg-gray-800 px-2 py-1 text-sm",children:[e.jsx("option",{value:"all",children:p("groups.allAnnotations")}),["readOnlyHint","destructiveHint","idempotentHint"].map(t=>e.jsx("option",{value:t,children:p(`groups.${t}`)},t))]}),e.jsx("button",{type:"button","aria-pressed":x,onClick:()=>w(!x),className:f,children:p(x?"groups.flatList":"groups.riskGroups")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mb-2",children:[e.jsx("span",{className:"text-xs text-gray-500",role:"status",children:p("groups.visibleCount",{count:j.length,total:a.length})}),["select","deselect","invert"].map(t=>e.jsx("button",{type:"button",disabled:!j.length,onClick:()=>d(j,t),className:f,children:p(`groups.${t}Visible`)},t))]}),s&&x&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:p("groups.riskHint")}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 max-h-96 overflow-y-auto",children:[j.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:p("groups.noMatchingItems")}),b.filter(t=>t.items.length>0).map(t=>{const o=t.items.filter(c=>T.has(c.value)).length;return e.jsxs(M.Fragment,{children:[t.risk&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-gray-200 py-1",children:[e.jsxs("span",{className:"text-xs font-medium",children:[p(`groups.risk_${t.risk}`)," (",o,"/",t.items.length,")"]}),e.jsx("button",{type:"button",className:f,onClick:()=>d(t.items,o===t.items.length?"deselect":"select"),children:p(o===t.items.length?"groups.selectNone":"groups.selectAll")})]}),t.items.map(c=>e.jsx(M.Fragment,{children:i(c)},c.value))]},t.risk??"flat")})]})]})},_e={tools:[],prompts:[],resources:[]},ue={tools:"all",prompts:"all",resources:"all"},pe=({servers:a,value:m,onChange:s,className:l,serverCosts:h=[]})=>{const{t:i}=G(),p=M.useId(),{nameSeparator:E,smartRoutingConfig:I}=me(),[N,A]=g.useState(new Set),x=M.useMemo(()=>m.map(r=>typeof r=="string"?{name:r,...ue}:{...r,tools:r.tools||"all",prompts:r.prompts||"all",resources:r.resources||"all"}),[m]),w=M.useMemo(()=>a.filter(r=>r.enabled!==!1),[a]);M.useEffect(()=>{const r=new Set(x.map(n=>n.name)),u=new Set(w.map(n=>n.name));A(n=>{const S=new Set;return n.forEach(v=>{(r.has(v)||u.has(v))&&S.add(v)}),S})},[x,w]);const j=r=>{if(x.findIndex(n=>n.name===r)>=0){const n=x.filter(S=>S.name!==r);s(n)}else{const n=[...x,{name:r,...ue}];s(n)}},T=r=>{A(u=>{const n=new Set(u);return n.has(r)?n.delete(r):n.add(r),n})},d=r=>["tools","prompts","resources"].some(u=>{const n=r[u];return n==="all"||Array.isArray(n)&&n.length>0}),b=(r,u,n,S=!1)=>{const v=x.find(k=>k.name===r),F={...v?{...v}:{name:r,..._e},[u]:n};if(u==="tools"&&Array.isArray(n)&&F.pinnedTools&&(F.pinnedTools=F.pinnedTools.filter(k=>n.includes(k)),F.pinnedTools.length===0&&delete F.pinnedTools),!d(F)){const k=x.filter(y=>y.name!==r);s(k),S||A(y=>{const $=new Set(y);return $.delete(r),$});return}if(v){s(x.map(k=>k.name===r?F:k));return}s([...x,F])},f=(r,u)=>{const n=x.find(v=>v.name===r);if(!n)return;const S={...n};u?S.alias=u:delete S.alias,s(x.map(v=>v.name===r?S:v))},t=(r,u)=>{const n=x.find(P=>P.name===r);if(!n)return;const S=n.pinnedTools??[],v={...n,pinnedTools:S.includes(u)?S.filter(P=>P!==u):[...S,u]};v.pinnedTools.length===0&&delete v.pinnedTools,s(x.map(P=>P.name===r?v:P))},o=(r,u)=>{const n=`${r}${E}`;return u.startsWith(n)?u.slice(n.length):u},c=(r,u)=>u==="tools"?(r.tools||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.name,value:o(r.name,n.name),description:n.description,annotations:n.annotations,defaultDescription:n.defaultDescription,hasDescriptionOverride:n.hasDescriptionOverride})):u==="prompts"?(r.prompts||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.name,value:o(r.name,n.name),description:n.description})):(r.resources||[]).filter(n=>n.enabled!==!1).map(n=>({key:n.uri,value:n.uri,description:n.description})),C=M.useMemo(()=>{const r=new Map;return h.forEach(u=>{const n=new Map;u.items.forEach(S=>n.set(S.name,S.cost)),r.set(u.name,n)}),r},[h]),z=r=>C.get(r)??new Map,O=(r,u)=>{const n=z(r.name);return c(r,u).filter(S=>J(r.name,u,S.value)).reduce((S,v)=>S+(n.get(v.key)??0),0)},_=r=>["tools","prompts","resources"].reduce((u,n)=>u+O(r,n),0),X=(r,u,n)=>{const S=w.find(k=>k.name===r);if(!S)return;const v=c(S,u).map(k=>k.value),P=x.find(k=>k.name===r);if(!P){b(r,u,[n]);return}const F=P[u];if(F==="all"){const k=v.filter(y=>y!==n);b(r,u,k);return}if(Array.isArray(F)){if(F.includes(n)){b(r,u,F.filter(y=>y!==n));return}const k=[...F,n];b(r,u,k.length===v.length?"all":k);return}b(r,u,[n])},W=r=>{const u=x.find(n=>n.name===r);return!!(u&&d(u))},K=r=>{const u=x.find(n=>n.name===r);return u?["tools","prompts","resources"].some(n=>{const S=u[n];return Array.isArray(S)&&S.length>0}):!1},J=(r,u,n)=>{const S=x.find(P=>P.name===r);if(!S)return!1;const v=S[u];return v==="all"?!0:Array.isArray(v)?v.includes(n):!1},B=(r,u)=>{const n=x.find(P=>P.name===r.name);if(!n)return 0;const S=c(r,u),v=n[u];if(v==="all")return S.length;if(Array.isArray(v)){const P=new Set(S.map(F=>F.value));return v.filter(F=>P.has(F)).length}return 0},D=[{key:"tools",titleKey:"groups.toolSelection",countKey:"groups.toolsSelected",allKey:"groups.allTools"},{key:"prompts",titleKey:"groups.promptSelection",countKey:"groups.promptsSelected",allKey:"groups.allPrompts"},{key:"resources",titleKey:"groups.resourceSelection",countKey:"groups.resourcesSelected",allKey:"groups.allResources"}],R=r=>D.map(({key:u})=>({key:u,count:B(r,u)})).filter(u=>u.count>0);return e.jsxs("div",{className:Z("space-y-4",l),children:[e.jsx("div",{className:"space-y-3",children:w.map(r=>{const u=W(r.name),n=K(r.name),S=N.has(r.name),v=x.find(y=>y.name===r.name),P=R(r),F=D.filter(({key:y})=>c(r,y).length>0),k=z(r.name);return e.jsxs("div",{className:"border border-[var(--hub-line)] rounded-lg bg-[var(--hub-surface)] hover:border-[var(--hub-ink-3)] hover:bg-[var(--hub-surface-hover)] transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer rounded-lg transition-colors",onClick:()=>T(r.name),children:[e.jsxs("div",{className:"flex items-center space-x-3",onClick:y=>{y.stopPropagation(),j(r.name)},children:[e.jsx("input",{type:"checkbox",checked:u||n,onChange:()=>j(r.name),className:"w-4 h-4 text-blue-600 accent-[var(--hub-accent)] rounded focus:ring-blue-500"}),e.jsx("span",{className:"font-medium text-[var(--hub-ink)] cursor-pointer select-none",children:r.name})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[_(r)>0&&e.jsxs("span",{className:"text-sm text-[var(--hub-ink-3)] hub-mono",title:i("cost.estimate"),children:["Σ ",H(_(r))]}),P.map(({key:y,count:$})=>e.jsxs("span",{className:"text-sm text-green-600 flex items-center gap-1",children:[y==="tools"?e.jsx(Ce,{size:14}):y==="prompts"?e.jsx(Ae,{size:14}):e.jsx(Te,{size:14})," ",$]},y)),F.length>0&&e.jsx("button",{type:"button",className:"p-1 text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)] transition-colors",children:e.jsx("svg",{className:Z("w-5 h-5 transition-transform",S&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),S&&F.length>0&&e.jsx("div",{className:"border-t border-[var(--hub-line)] bg-[var(--hub-bg-2)] p-3",children:e.jsxs("div",{className:"space-y-4",children:[v&&e.jsxs("div",{className:"space-y-1",onClick:y=>y.stopPropagation(),children:[e.jsx("label",{htmlFor:`${p}-${r.name}`,className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:i("groups.alias")}),e.jsx("input",{type:"text",id:`${p}-${r.name}`,value:v.alias||"",placeholder:r.name,onChange:y=>f(r.name,y.target.value),className:"hub-input"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-[var(--hub-ink-2)]",children:[e.jsx("input",{type:"checkbox",checked:v.preserveToolNames===!0,onChange:y=>s(x.map($=>$.name===r.name?{...$,preserveToolNames:y.target.checked}:$))}),i("groups.preserveToolNames")]}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)]",children:i("groups.preserveToolNamesHint")})]}),F.map(({key:y,titleKey:$,countKey:be,allKey:ge})=>{const V=c(r,y),ae=B(r,y),Y=(v==null?void 0:v[y])==="all"||ae===V.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:i($)}),e.jsxs("div",{className:"flex items-center gap-3",children:[v&&e.jsx("span",{className:"text-xs text-green-600",children:Y?`(${i(ge)} ${V.length}/${V.length})`:`(${i(be)} ${ae}/${V.length})`}),v&&O(r,y)>0&&e.jsxs("span",{className:"text-xs text-[var(--hub-ink-3)] hub-mono",title:i("cost.estimate"),children:["Σ ",H(O(r,y))]}),e.jsx("button",{type:"button",onClick:()=>{b(r.name,y,Y?[]:"all",!0)},className:"text-sm text-blue-600 hover:text-blue-800 transition-colors",children:i(Y?"groups.selectNone":"groups.selectAll")})]})]}),e.jsx(He,{items:V,selection:(v==null?void 0:v[y])??[],tools:y==="tools",label:i($),onChange:L=>b(r.name,y,L,!0),children:L=>{var ie;const ne=J(r.name,y,L.value),q=!!((ie=v==null?void 0:v.pinnedTools)!=null&&ie.includes(L.value)),U=y==="tools"?ke({description:L.description,defaultDescription:L.defaultDescription,hasDescriptionOverride:L.hasDescriptionOverride},i("tool.noDescription")):null,le=U!=null&&U.hasDescriptionOverride?i("tool.defaultDescriptionTooltip",{description:U.defaultDescription}):L.description;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:ne,onChange:()=>X(r.name,y,L.value),className:"w-3 h-3 text-blue-600 accent-[var(--hub-accent)] rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-[var(--hub-ink-2)] break-all whitespace-nowrap flex-shrink-0",children:L.value}),(L.description||(U==null?void 0:U.hasDescriptionOverride))&&e.jsxs("span",{className:"min-w-0 flex items-center gap-1 text-[var(--hub-ink-3)] text-xs truncate",children:[e.jsx("span",{className:"truncate",title:le||void 0,children:U?U.currentDescription:L.description}),(U==null?void 0:U.hasDescriptionOverride)&&e.jsx("span",{className:"inline-flex flex-shrink-0 items-center rounded-full border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300",title:le||void 0,children:i("tool.descriptionModifiedBadge")})]}),k.get(L.key)!=null&&e.jsxs("span",{className:"text-xs text-[var(--hub-ink-3)] hub-mono whitespace-nowrap ml-auto flex-shrink-0",title:i("cost.estimate"),children:["Σ ",H(k.get(L.key))]})]}),y==="tools"&&ne&&(I.enabled||q)&&e.jsx("button",{type:"button",onClick:()=>t(r.name,L.value),title:i(q?"groups.unpinTool":"groups.pinTool"),"aria-label":i("groups.pinToolLabel"),"aria-pressed":q,className:Z("flex-shrink-0 transition-colors",q?"text-blue-600":"text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)]"),children:e.jsx(Ee,{size:12,fill:q?"currentColor":"none"})})]},L.key)}})]},y)})]})})]},r.name)})}),w.length===0&&e.jsx("p",{className:"text-[var(--hub-ink-3)] text-sm",children:i("groups.noServerOptions")})]})};function xe({groupId:a,value:m,onChange:s}){const{t:l}=G(),[h,i]=g.useState([]),[p,E]=g.useState(""),[I,N]=g.useState(!1),[A,x]=g.useState(!1),[w,j]=g.useState(!1);g.useEffect(()=>{if(!a||m.visibility!=="group")return;let c=!1;return N(!0),x(!1),fe(`/groups/${encodeURIComponent(a)}/share-candidates`).then(C=>{c||(C.success&&Array.isArray(C.data)?i(C.data):x(!0))}).catch(()=>{c||x(!0)}).finally(()=>{c||N(!1)}),()=>{c=!0}},[a,m.visibility]);const T=m.sharedWithUsers||[],d=[...new Set([...h,...T])].sort().filter(c=>c.toLowerCase().includes(p.toLowerCase())),b=new Set(T),f=d.length>0&&d.every(c=>b.has(c)),t=d.length===0||d.every(c=>!b.has(c)),o=c=>{const C=new Set(T);C.has(c)?C.delete(c):C.add(c),s({sharedWithUsers:Array.from(C)})};return e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-[var(--hub-bg-2)] hover:bg-[var(--hub-surface-hover)] p-3 rounded border border-[var(--hub-line)]",onClick:()=>j(!w),children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)]",children:l("server.sectionAdvanced","Advanced Options")}),e.jsx("span",{className:"text-[var(--hub-ink-3)] text-sm",children:w?"▼":"▶"})]}),w&&e.jsxs("div",{className:"border border-[var(--hub-line)] rounded-b p-4 bg-[var(--hub-surface)] border-t-0",children:[e.jsx("label",{htmlFor:"group-visibility",className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:l("server.visibility")}),e.jsxs("select",{id:"group-visibility",className:"hub-input",value:m.visibility||"",onChange:c=>s({visibility:c.target.value}),children:[!m.visibility&&e.jsx("option",{value:"",disabled:!0,children:l("groups.legacyVisibility")}),e.jsx("option",{value:"private",children:l("server.visibilityPrivate")}),e.jsx("option",{value:"group",children:l("server.visibilityGroup")}),e.jsx("option",{value:"public",children:l("server.visibilityPublic")})]}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:l("groups.visibilityDescription")}),!m.visibility&&e.jsx("p",{className:"text-sm text-amber-600",children:l("groups.legacyVisibilityHint")}),m.visibility==="group"&&e.jsxs("div",{className:"mt-4 rounded border border-[var(--hub-line)] p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:l("server.shareWithUsers")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1 mb-3",children:l("server.shareWithUsersDescription")}),a?e.jsxs(e.Fragment,{children:[I&&e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l("server.shareCandidatesLoading")}),A&&e.jsx("p",{role:"alert",className:"text-sm text-red-600 dark:text-red-400",children:l("server.shareCandidatesError")}),!I&&!A&&d.length===0&&e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l(p?"server.noMatchingShareUsers":"server.noShareCandidates")}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:"group-share-search",className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:l("server.shareUserSearchLabel")}),e.jsx("input",{id:"group-share-search",type:"search",value:p,onChange:c=>E(c.target.value),placeholder:l("server.shareUserSearchPlaceholder"),className:"hub-input text-sm"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:[...new Set([...T,...d])]}),disabled:f,className:"hub-btn text-sm",children:l("server.selectAllShareUsers")}),e.jsx("button",{type:"button",onClick:()=>s({sharedWithUsers:T.filter(c=>!d.includes(c))}),disabled:t,className:"hub-btn text-sm",children:l("server.deselectAllShareUsers")})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:d.map(c=>e.jsxs("label",{className:"flex items-center gap-2 rounded border border-[var(--hub-line)] px-3 py-2 text-sm text-[var(--hub-ink-2)]",children:[e.jsx("input",{type:"checkbox",checked:b.has(c),onChange:()=>o(c)}),e.jsx("span",{children:c})]},c))})]})]}):e.jsx("p",{className:"text-sm text-[var(--hub-ink-3)]",children:l("groups.shareAfterCreate")})]})]})]})}const Be=({onAdd:a,onCancel:m})=>{const{t:s}=G(),{createGroup:l}=ee(),{allServers:h}=te(),{serverCosts:i}=re(),[p,E]=g.useState([]),[I,N]=g.useState(null),[A,x]=g.useState(!1),[w,j]=g.useState({visibility:"private",sharedWithUsers:[],name:"",description:"",instructions:"",servers:[]});g.useEffect(()=>{E(h.filter(b=>b.enabled!==!1))},[h]);const T=b=>{const{name:f,value:t}=b.target;j(o=>({...o,[f]:t}))},d=async b=>{b.preventDefault(),x(!0),N(null);try{if(!w.name.trim()){N(s("groups.nameRequired")),x(!1);return}const f=await l(w.name,w.description,w.servers,{visibility:w.visibility,sharedWithUsers:w.sharedWithUsers,instructions:w.instructions});if(!f||!f.success){N((f==null?void 0:f.message)||s("groups.createError")),x(!1);return}a()}catch(f){N(f instanceof Error?f.message:String(f)),x(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card shadow-lg max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--hub-ink)] mb-4",children:s("groups.addNew")}),I&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-[var(--hub-line)]",children:I})]}),e.jsxs("form",{onSubmit:d,className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"name",children:[s("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:w.name,onChange:T,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:s("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"instructions",children:s("groups.instructions")}),e.jsx("textarea",{id:"instructions",name:"instructions",value:w.instructions,onChange:T,rows:3,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:s("groups.instructionsPlaceholder")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:s("groups.instructionsHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",children:s("groups.configureCapabilities")}),e.jsx(pe,{servers:p,value:w.servers,onChange:b=>j(f=>({...f,servers:b})),className:"border border-[var(--hub-line)] rounded-lg p-4 bg-[var(--hub-bg-2)]",serverCosts:i})]}),e.jsx(xe,{value:w,onChange:b=>j(f=>({...f,...b}))})]})}),e.jsxs("div",{className:"flex justify-end space-x-2 p-5 pt-3 border-t border-[var(--hub-line-2)] flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:m,className:"hub-btn",disabled:A,children:s("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:A,children:s(A?"common.submitting":"common.create")})]})]})]})})},Ve=({group:a,onEdit:m,onCancel:s})=>{const{t:l}=G(),{updateGroup:h}=ee(),{allServers:i}=te(),{serverCosts:p}=re(),[E,I]=g.useState([]),[N,A]=g.useState(null),[x,w]=g.useState(!1),[j,T]=g.useState({visibility:a.visibility,sharedWithUsers:a.sharedWithUsers||[],name:a.name,description:a.description||"",instructions:a.instructions||"",servers:a.servers||[]});g.useEffect(()=>{I(i.filter(f=>f.enabled!==!1))},[i]);const d=f=>{const{name:t,value:o}=f.target;T(c=>({...c,[t]:o}))},b=async f=>{f.preventDefault(),w(!0),A(null);try{if(!j.name.trim()){A(l("groups.nameRequired")),w(!1);return}const t=await h(a.id,{visibility:j.visibility,sharedWithUsers:j.sharedWithUsers,name:j.name,description:j.description,instructions:j.instructions,servers:j.servers});if(!t||!t.success){A((t==null?void 0:t.message)||l("groups.updateError")),w(!1);return}m()}catch(t){A(t instanceof Error?t.message:String(t)),w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card shadow-lg max-w-3xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"p-6 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--hub-ink)] mb-4",children:l("groups.edit")}),N&&e.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded-md border border-[var(--hub-line)]",children:N})]}),e.jsxs("form",{onSubmit:b,className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"name",children:[l("groups.name")," *"]}),e.jsx("input",{type:"text",id:"name",name:"name",value:j.name,onChange:d,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:l("groups.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",htmlFor:"instructions",children:l("groups.instructions")}),e.jsx("textarea",{id:"instructions",name:"instructions",value:j.instructions,onChange:d,rows:3,className:"w-full border border-[var(--hub-line)] bg-[var(--hub-surface)] rounded-md px-3 py-2 text-[var(--hub-ink)] placeholder:text-[var(--hub-ink-3)] focus:outline-none focus:border-[var(--hub-ink-2)]",placeholder:l("groups.instructionsPlaceholder")}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:l("groups.instructionsHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[var(--hub-ink-2)] text-sm font-bold mb-2",children:l("groups.configureCapabilities")}),e.jsx(pe,{servers:E,value:j.servers,onChange:f=>T(t=>({...t,servers:f})),className:"border border-[var(--hub-line)] rounded-lg p-4 bg-[var(--hub-bg-2)]",serverCosts:p})]}),e.jsx(xe,{groupId:a.id,value:j,onChange:f=>T(t=>({...t,...f}))})]})}),e.jsxs("div",{className:"flex justify-end space-x-2 p-5 pt-3 border-t border-[var(--hub-line-2)] flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:s,className:"hub-btn",disabled:x,children:l("common.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",disabled:x,children:l(x?"common.submitting":"common.save")})]})]})]})})},qe=a=>a.map(m=>typeof m=="string"?m:m.name),he=(a,m)=>{const s=a.servers.find(l=>typeof l=="string"?l===m:l.name===m);return s?typeof s=="string"?{name:s,tools:"all",prompts:"all",resources:"all"}:s:{name:m,tools:"all",prompts:"all",resources:"all"}},Ke=(a,m)=>{var l;return((l=he(a,m).alias)==null?void 0:l.trim())||m},Je=({group:a,servers:m,onEdit:s,onDelete:l,cost:h})=>{var B;const{t:i}=G(),{auth:p}=ve(),E=!!p.user&&(p.user.isAdmin||p.user.username===a.owner),{showToast:I}=je(),{installConfig:N,nameSeparator:A}=me(),x=((B=N==null?void 0:N.baseUrl)==null?void 0:B.replace(/\/+$/,""))||"",[w,j]=g.useState(!1),[T,d]=g.useState(null),[b,f]=g.useState(!1),[t,o]=g.useState(!1),c=g.useRef(null);g.useEffect(()=>{const D=R=>{c.current&&!c.current.contains(R.target)&&o(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const C=async D=>{await ye(D)?(f(!0),o(!1),I(i("common.copySuccess")||"Copied","success"),setTimeout(()=>f(!1),1500)):I(i("common.copyFailed")||"Copy failed","error")},z=`${x}/mcp/${a.name}`,O=`${x}/mcp/${encodeURIComponent(a.name)}`,_=`${x}/api/${a.name}`,X=qe(a.servers),W=m.filter(D=>X.includes(D.name)),K=D=>{const R=he(a,D.name),r=`${D.name}${A}`,u=D.tools||[],n=D.prompts||[],S=D.resources||[],v=Array.isArray(R.tools)?u.filter(k=>{if(k.enabled===!1)return!1;const y=k.name.startsWith(r)?k.name.slice(r.length):k.name;return R.tools.includes(y)}).length:u.filter(k=>k.enabled!==!1).length,P=Array.isArray(R.prompts)?n.filter(k=>{if(k.enabled===!1)return!1;const y=k.name.startsWith(r)?k.name.slice(r.length):k.name;return R.prompts.includes(y)}).length:n.filter(k=>k.enabled!==!1).length,F=Array.isArray(R.resources)?S.filter(k=>k.enabled!==!1&&R.resources.includes(k.uri)).length:S.filter(k=>k.enabled!==!1).length;return{visibleTools:v,totalTools:u.length,visiblePrompts:P,totalPrompts:n.length,visibleResources:F,totalResources:S.length}},J=W.reduce((D,R)=>D+K(R).visibleTools,0);return e.jsxs("div",{className:"hub-card flex h-full flex-col overflow-visible",children:[e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",style:{borderBottom:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:15,fontWeight:600,letterSpacing:"-0.015em"},children:a.name}),e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)",padding:"0 6px",border:"1px solid var(--hub-line)",borderRadius:4,height:18,display:"inline-flex",alignItems:"center"},title:a.id,children:a.id})]}),e.jsx("div",{className:"mt-1 text-xs text-[var(--hub-ink-3)]",children:a.visibility?i(`server.visibility${a.visibility==="group"?"Group":a.visibility==="public"?"Public":"Private"}`):i("groups.legacyVisibility")}),a.description&&e.jsx("div",{style:{fontSize:12.5,color:"var(--hub-ink-3)",marginTop:2},children:a.description})]}),e.jsxs("div",{className:"flex items-center gap-1",ref:c,children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>o(D=>!D),className:"hub-icon-btn sm",title:i("common.copy"),children:b?e.jsx(De,{size:13,className:"text-[var(--hub-ok)]"}):e.jsx(Q,{size:13})}),t&&e.jsxs("div",{className:"absolute top-full right-0 mt-1 z-20 hub-card",style:{minWidth:160,padding:4},children:[e.jsxs("button",{onClick:()=>C(a.id),className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",children:[e.jsx(Q,{size:12})," ",i("common.copyId")]}),e.jsxs("button",{onClick:()=>C(z),className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",children:[e.jsx(oe,{size:12})," ",i("common.copyUrl")]}),e.jsxs("button",{onClick:()=>C(_),className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",children:[e.jsx(oe,{size:12})," ",i("common.copyOpenApiUrl")]}),e.jsxs("button",{onClick:()=>{o(!1),d({name:a.name,url:O,headers:{Authorization:`Bearer ${Se}`}})},className:"flex items-center gap-2 w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left",children:[e.jsx(Ie,{size:12})," ",i("clientConfig.menuItem")]})]})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>s(a),className:"hub-icon-btn sm",title:i("groups.edit"),children:e.jsx(Fe,{size:13})}),e.jsx("button",{onClick:()=>j(!0),className:"hub-icon-btn sm",title:i("groups.delete"),style:{color:"var(--hub-ink-3)"},children:e.jsx(ze,{size:13})})]})]})]}),e.jsxs("div",{className:"grid flex-1 items-center gap-3 px-4 py-3",style:{gridTemplateColumns:"1fr 80px 1fr",minHeight:180},children:[e.jsx("div",{className:"flex flex-col gap-1.5",children:W.length===0?e.jsx("div",{style:{fontSize:12,color:"var(--hub-ink-3)"},children:i("groups.noServers")}):W.map(D=>{const R=K(D);return e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-md",style:{background:"var(--hub-bg-2)",border:"1px solid var(--hub-line-2)"},children:[e.jsx("span",{className:"inline-block flex-shrink-0",style:{width:6,height:6,borderRadius:50,background:D.status==="connected"?"var(--hub-ok)":D.status==="connecting"?"var(--hub-warn)":"var(--hub-err)"}}),e.jsx("span",{className:"hub-mono truncate flex-1",style:{fontSize:12.5},children:e.jsx("span",{title:D.name,children:Ke(a,D.name)})}),e.jsxs("span",{className:"hub-mono hub-num flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},children:[R.visibleTools,"/",R.totalTools," tools"]})]},D.name)})}),e.jsxs("svg",{width:"80",height:"80",viewBox:"0 0 80 80",className:"self-center",children:[W.length===0?e.jsx("path",{d:"M0,40 C30,40 50,40 80,40",stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"}):W.map((D,R)=>{const r=12+60/Math.max(W.length,1)*(R+.5);return e.jsx("path",{d:`M0,${r} C 30,${r} 50,40 80,40`,stroke:"var(--hub-line)",strokeWidth:"1",fill:"none",strokeDasharray:"3 3"},R)}),e.jsx("circle",{cx:"80",cy:"40",r:"4",fill:"var(--hub-ink)"})]}),e.jsxs("div",{className:"px-3 py-2.5 rounded-md",style:{border:"1px solid var(--hub-line)",background:"var(--hub-bg-2)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:4},children:"endpoint"}),e.jsxs("div",{className:"hub-mono break-all",style:{fontSize:12,color:"var(--hub-ink-2)",lineHeight:1.4},children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"/mcp/"}),e.jsx("b",{style:{color:"var(--hub-ink)",fontWeight:600},children:a.name})]}),e.jsxs("div",{className:"hub-mono break-all",style:{fontSize:12,color:"var(--hub-ink-2)",lineHeight:1.4},children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"/api/"}),e.jsx("b",{style:{color:"var(--hub-ink)",fontWeight:600},children:a.name})]}),e.jsxs("div",{className:"flex gap-1.5 mt-2",children:[e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>C(z),title:i("common.copyUrl"),children:[e.jsx(Q,{size:11})," MCP"]}),e.jsxs("button",{className:"hub-btn sm flex-1 justify-center",onClick:()=>C(_),title:i("common.copyOpenApiUrl"),children:[e.jsx(Q,{size:11})," OpenAPI"]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center px-4 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",fontSize:12,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{children:[e.jsxs("div",{className:"hub-mono",children:[e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:W.length})," ",i("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{style:{color:"var(--hub-ink-2)"},children:J})," ",i("server.tools").toLowerCase()]}),h&&e.jsxs("div",{className:"hub-mono mt-1",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsxs("div",{title:i("cost.estimate"),children:[i("cost.totalFootprint"),": ",H(h.direct.exposed),"/",H(h.direct.gross)]}),h.smartRouting&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[i("cost.smartRouting"),": ",H(h.smartRouting.base)," (",i("cost.saved",{percent:Ne(h.direct.exposed,h.smartRouting.base)}),")"]}),e.jsxs("div",{title:i("cost.smartRoutingPdHint"),children:[i("cost.smartRoutingPd"),":"," ",H(h.smartRouting.progressiveDisclosure)]})]}),h.connectedCount<h.totalCount&&e.jsx("div",{children:i("cost.connectedOf",{connected:h.connectedCount,total:h.totalCount})})]})]}),E&&e.jsxs("button",{className:"hub-btn ghost sm",style:{color:"var(--hub-ink-3)"},onClick:()=>s(a),children:[i("groups.configureTools")||i("groups.edit"),e.jsx(Pe,{size:11,style:{transform:"rotate(-90deg)"}})]})]}),e.jsx(we,{isOpen:T!==null,target:T,onClose:()=>d(null)}),e.jsx($e,{isOpen:w,onClose:()=>j(!1),onConfirm:()=>{l(a.id),j(!1)},serverName:a.name,isGroup:!0})]})},Qe=({onSuccess:a,onCancel:m})=>{const{t:s}=G(),[l,h]=g.useState(""),[i,p]=g.useState(null),[E,I]=g.useState(!1),[N,A]=g.useState(null),x=`{
2
+ "groups": [
3
+ {
4
+ "name": "AI Assistants",
5
+ "servers": ["openai-server", "anthropic-server"]
6
+ },
7
+ {
8
+ "name": "Development Tools",
9
+ "servers": [
10
+ {
11
+ "name": "github-server",
12
+ "tools": ["create_issue", "list_repos"],
13
+ "prompts": ["triage_prompt"],
14
+ "resources": ["resource://docs/repo-guide"]
15
+ },
16
+ {
17
+ "name": "gitlab-server",
18
+ "tools": "all",
19
+ "prompts": "all",
20
+ "resources": "all"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+
27
+ Supports:
28
+ - Simple server list: ["server1", "server2"]
29
+ - Advanced server config: [{"name": "server1", "tools": ["tool1"], "prompts": ["prompt1"], "resources": ["resource://docs/guide"]}]
30
+ - All groups will be imported in a single efficient batch operation.`,w=t=>{try{const o=JSON.parse(t.trim());if(!o.groups||!Array.isArray(o.groups))return p(s("groupImport.invalidFormat")),null;for(const c of o.groups)if(!c.name||typeof c.name!="string")return p(s("groupImport.missingName")),null;return o}catch{return p(s("groupImport.parseError")),null}},j=()=>{p(null);const t=w(l);t&&A(t.groups)},T=async()=>{if(N){I(!0),p(null);try{const t=await se("/groups/batch",{groups:N});if(t.success){const{successCount:o,failureCount:c,results:C}=t;if(c>0){const z=C.filter(O=>!O.success).map(O=>`${O.name}: ${O.message||s("groupImport.addFailed")}`);p(s("groupImport.partialSuccess",{count:o,total:N.length})+`
31
+ `+z.join(`
32
+ `))}o>0&&a()}else p(t.message||s("groupImport.importFailed"))}catch(t){console.error("Import error:",t),p(s("groupImport.importFailed"))}finally{I(!1)}}},d=t=>e.jsx("span",{className:"text-gray-500 ml-2",children:s(`groups.${t}`)}),b=(t,o)=>{if(!o||o==="all")return null;const c=Array.isArray(o)?o.join(", "):o;return e.jsx("span",{className:"text-gray-500 ml-2",children:s(`groups.${t}`,{items:c})})},f=t=>!t||t.length===0?e.jsx("span",{className:"text-gray-500",children:s("groups.noServers")}):e.jsx("div",{className:"space-y-1",children:t.map((o,c)=>typeof o=="string"?e.jsxs("div",{className:"text-sm",children:["• ",o]},c):e.jsxs("div",{className:"text-sm",children:["• ",o.name,o.tools&&o.tools!=="all"&&e.jsxs("span",{className:"text-gray-500 ml-2",children:["(",Array.isArray(o.tools)?o.tools.join(", "):o.tools,")"]}),o.tools==="all"&&d("previewAllTools"),b("previewPrompts",o.prompts),o.prompts==="all"&&d("previewAllPrompts"),b("previewResources",o.resources),o.resources==="all"&&d("previewAllResources")]},c))});return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:s("groupImport.title")}),e.jsx("button",{onClick:m,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),i&&e.jsx("div",{className:"mb-4 bg-red-50 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 whitespace-pre-wrap",children:i})}),N?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-3",children:s("groupImport.previewTitle")}),e.jsx("div",{className:"space-y-3",children:N.map((t,o)=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:t.description}),e.jsxs("div",{className:"mt-2 text-sm text-gray-600",children:[e.jsxs("strong",{children:[s("groups.servers"),":"]}),e.jsx("div",{className:"mt-1",children:f(t.servers)})]})]})})},o))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>A(null),disabled:E,className:"hub-btn",children:s("common.back")}),e.jsx("button",{onClick:T,disabled:E,className:"hub-btn primary",children:E?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),s("groupImport.importing")]}):s("groupImport.import")})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:s("groupImport.inputLabel")}),e.jsx("textarea",{value:l,onChange:t=>h(t.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:x}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:s("groupImport.inputHelp")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:m,className:"hub-btn",children:s("common.cancel")}),e.jsx("button",{onClick:j,disabled:!l.trim(),className:"hub-btn primary",children:s("groupImport.preview")})]})]})]})})},Xe=({groups:a,onCancel:m})=>{const{t:s}=G(),[l,h]=g.useState(""),[i,p]=g.useState(""),[E,I]=g.useState([]),[N,A]=g.useState(!1),[x,w]=g.useState(!1),[j,T]=g.useState(null),d=t=>{I(o=>o.includes(t)?o.filter(c=>c!==t):[...o,t])},b=()=>{E.length===a.length?I([]):I(a.map(t=>t.id))},f=async()=>{if(!l.trim()){T(s("template.nameRequired"));return}w(!0),T(null);try{const t=await se("/templates/export",{name:l.trim(),description:i.trim()||void 0,groupIds:E.length>0?E:void 0,includeDisabledServers:N});if(t.success&&t.data){const o=t.data,c=new Blob([JSON.stringify(o,null,2)],{type:"application/json"}),C=URL.createObjectURL(c),z=document.createElement("a");z.href=C,z.download=`${o.name.replace(/[^a-zA-Z0-9-_]/g,"_")}.mcphub-template.json`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(C),m()}else T(t.message||s("template.exportFailed"))}catch(t){console.error("Export error:",t),T(s("template.exportFailed"))}finally{w(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:s("template.exportTitle")}),e.jsx("button",{onClick:m,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),j&&e.jsx("div",{className:"mb-4 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 dark:text-red-300",children:j})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[s("template.name")," *"]}),e.jsx("input",{type:"text",value:l,onChange:t=>h(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:s("template.namePlaceholder")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s("template.description")}),e.jsx("input",{type:"text",value:i,onChange:t=>p(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:s("template.descriptionPlaceholder")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("template.selectGroups")}),e.jsx("button",{onClick:b,className:"text-sm text-blue-600 hover:text-blue-800 dark:text-blue-300",children:E.length===a.length?s("template.deselectAll"):s("template.selectAll")})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:s("template.selectGroupsHelp")}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md max-h-48 overflow-y-auto",children:a.map(t=>e.jsxs("label",{className:"flex items-center px-3 py-2 hover:bg-gray-50 dark:bg-gray-800 dark:hover:bg-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:E.includes(t.id),onChange:()=>d(t.id),className:"mr-3 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.name}),t.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:t.description})]})]},t.id))})]}),e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:N,onChange:t=>A(t.target.checked),className:"h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:s("template.includeDisabled")})]})]}),e.jsx("div",{className:"mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-700/60 rounded-md",children:e.jsx("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:s("template.exportNote")})}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[e.jsx("button",{onClick:m,className:"hub-btn",children:s("common.cancel")}),e.jsx("button",{onClick:f,disabled:x||!l.trim(),className:"hub-btn primary",children:s(x?"template.exporting":"template.export")})]})]})})},Ye=({onSuccess:a,onCancel:m})=>{const{t:s}=G(),[l,h]=g.useState(null),[i,p]=g.useState(null),[E,I]=g.useState(!1),[N,A]=g.useState(null),x=g.useRef(null),w=d=>{var t;p(null),h(null),A(null);const b=(t=d.target.files)==null?void 0:t[0];if(!b)return;const f=new FileReader;f.onload=o=>{var c;try{const C=JSON.parse((c=o.target)==null?void 0:c.result);if(!C.version||!C.name||!C.servers||!C.groups){p(s("template.invalidFormat"));return}h(C)}catch{p(s("template.parseError"))}},f.readAsText(b)},j=d=>{if(p(null),h(null),A(null),!!d.trim())try{const b=JSON.parse(d.trim());if(!b.version||!b.name||!b.servers||!b.groups){p(s("template.invalidFormat"));return}h(b)}catch{p(s("template.parseError"))}},T=async()=>{if(l){I(!0),p(null);try{const d=await se("/templates/import",l);d.data?(A(d.data),d.data.success&&a()):p(d.message||s("template.importFailed"))}catch(d){console.error("Import error:",d),p(s("template.importFailed"))}finally{I(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:s("template.importTitle")}),e.jsx("button",{onClick:m,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),i&&e.jsx("div",{className:"mb-4 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 p-4 rounded",children:e.jsx("p",{className:"text-red-700 dark:text-red-300",children:i})}),N&&e.jsxs("div",{className:`mb-4 p-4 rounded border-l-4 ${N.success?"bg-green-50 dark:bg-green-900/20 border-green-500":"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-500"}`,children:[e.jsx("p",{className:N.success?"text-green-700 dark:text-green-300":"text-yellow-700 dark:text-yellow-300",children:s("template.importResult",{serversCreated:N.serversCreated,serversSkipped:N.serversSkipped,groupsCreated:N.groupsCreated,groupsSkipped:N.groupsSkipped})}),N.requiredEnvVars.length>0&&e.jsxs("div",{className:"mt-2 p-2 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-700/60 rounded",children:[e.jsx("p",{className:"text-sm font-medium text-orange-800 dark:text-orange-300",children:s("template.envVarsNeeded")}),e.jsx("ul",{className:"mt-1 text-sm text-orange-700 dark:text-orange-300",children:N.requiredEnvVars.map(d=>e.jsx("li",{className:"font-mono",children:d},d))})]})]}),l?e.jsxs("div",{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("h3",{className:"font-medium text-gray-900",children:l.name}),l.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:l.description}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[s("template.version"),": ",l.version," | ",s("template.createdAt"),":"," ",new Date(l.createdAt).toLocaleDateString()]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:[s("template.servers")," (",Object.keys(l.servers).length,")"]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md divide-y divide-gray-200 dark:divide-gray-700 max-h-40 overflow-y-auto",children:Object.entries(l.servers).map(([d,b])=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:d}),e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:b.type||"stdio"})]},d))})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:[s("template.groups")," (",l.groups.length,")"]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md divide-y divide-gray-200 dark:divide-gray-700 max-h-40 overflow-y-auto",children:l.groups.map((d,b)=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:d.name}),d.description&&e.jsx("span",{className:"text-xs text-gray-500 ml-2",children:d.description}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[d.servers.length," ",s("template.serversInGroup")]})]},b))})]}),l.requiredEnvVars.length>0&&e.jsxs("div",{className:"p-3 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-700/60 rounded-md",children:[e.jsx("h4",{className:"text-sm font-medium text-orange-800 dark:text-orange-300",children:s("template.envVarsNeeded")}),e.jsx("ul",{className:"mt-1 text-sm text-orange-700 dark:text-orange-300 font-mono",children:l.requiredEnvVars.map(d=>e.jsx("li",{children:d},d))})]})]}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[e.jsx("button",{onClick:()=>{h(null),A(null),x.current&&(x.current.value="")},className:"hub-btn",children:s("common.back")}),e.jsx("button",{onClick:T,disabled:E,className:"hub-btn primary",children:s(E?"template.importing":"template.import")})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:s("template.uploadFile")})}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx("input",{ref:x,type:"file",accept:".json",onChange:w,className:"block text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100"})})]}),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"bg-white dark:bg-gray-800 px-2 text-gray-500",children:s("template.or")})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:s("template.pasteJson")}),e.jsx("textarea",{className:"w-full h-64 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:s("template.pastePlaceholder"),onChange:d=>j(d.target.value)})]}),e.jsx("div",{className:"flex justify-end space-x-4",children:e.jsx("button",{onClick:m,className:"hub-btn",children:s("common.cancel")})})]})]})})},os=()=>{const{t:a}=G(),{groups:m,loading:s,error:l,setError:h,deleteGroup:i,triggerRefresh:p}=ee(),{allServers:E}=te({refreshOnMount:!0}),{groupCosts:I,refetch:N}=re();g.useEffect(()=>{N()},[m,E,N]);const[A,x]=g.useState(null),[w,j]=g.useState(!1),[T,d]=g.useState(!1),[b,f]=g.useState(!1),[t,o]=g.useState(!1),c=async C=>{const z=await i(C);(!z||!z.success)&&h((z==null?void 0:z.message)||a("groups.deleteError"))};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:a("pages.groups.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:m.length})," ",a("nav.groups").toLowerCase()]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>d(!0),children:[e.jsx(ce,{size:13})," ",a("groupImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>f(!0),children:[e.jsx(Re,{size:13})," ",a("template.exportButton")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>o(!0),children:[e.jsx(ce,{size:13})," ",a("template.importButton")]}),e.jsxs("button",{className:"hub-btn primary",onClick:()=>j(!0),children:[e.jsx(de,{size:13})," ",a("groups.add")]})]})]}),l&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Le,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:l})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>h(null),children:e.jsx(Ue,{size:13})})]}),s?e.jsx("div",{className:"hub-card p-6 text-center",style:{color:"var(--hub-ink-3)"},children:a("app.loading")}):m.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:a("groups.noGroups")}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3.5",children:[m.map(C=>e.jsx(Je,{group:C,servers:E,onEdit:x,onDelete:c,cost:I.find(z=>z.id===C.id)},C.id)),e.jsx("button",{onClick:()=>j(!0),className:"flex items-center justify-center text-[var(--hub-ink-3)] hover:text-[var(--hub-ink-2)] transition-colors",style:{border:"1px dashed var(--hub-line)",borderRadius:10,minHeight:200,background:"transparent",cursor:"pointer"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"grid place-items-center mx-auto mb-2",style:{width:36,height:36,borderRadius:10,border:"1px solid var(--hub-line)"},children:e.jsx(de,{size:16})}),e.jsx("div",{style:{fontSize:13,fontWeight:500,color:"var(--hub-ink-2)"},children:a("groups.add")}),e.jsx("div",{style:{fontSize:12,marginTop:2},children:a("groups.addNew")})]})})]}),w&&e.jsx(Be,{onAdd:()=>{j(!1),p()},onCancel:()=>j(!1)}),T&&e.jsx(Qe,{onSuccess:()=>{d(!1),p()},onCancel:()=>d(!1)}),A&&e.jsx(Ve,{group:A,onEdit:()=>{x(null),p()},onCancel:()=>x(null)}),b&&e.jsx(Xe,{groups:m,onCancel:()=>f(!1)}),t&&e.jsx(Ye,{onSuccess:()=>{o(!1),p()},onCancel:()=>o(!1)})]})};export{os as default};
33
+ //# sourceMappingURL=GroupsPage-gZ0nnzCn.js.map