@samanhappy/mcphub 1.1.7 → 1.1.9

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 (140) hide show
  1. package/dist/clients/openapi.js +2 -1
  2. package/dist/clients/openapi.js.map +1 -1
  3. package/dist/controllers/authController.js +27 -1
  4. package/dist/controllers/authController.js.map +1 -1
  5. package/dist/controllers/configController.js +4 -1
  6. package/dist/controllers/configController.js.map +1 -1
  7. package/dist/controllers/oauthServerController.js +12 -14
  8. package/dist/controllers/oauthServerController.js.map +1 -1
  9. package/dist/controllers/promptController.js +2 -2
  10. package/dist/controllers/promptController.js.map +1 -1
  11. package/dist/controllers/serverController.js +201 -12
  12. package/dist/controllers/serverController.js.map +1 -1
  13. package/dist/dao/OAuthTokenDaoDbImpl.js +2 -0
  14. package/dist/dao/OAuthTokenDaoDbImpl.js.map +1 -1
  15. package/dist/dao/ServerDao.js.map +1 -1
  16. package/dist/dao/ServerDaoDbImpl.js.map +1 -1
  17. package/dist/db/entities/OAuthToken.js +4 -0
  18. package/dist/db/entities/OAuthToken.js.map +1 -1
  19. package/dist/db/entities/Server.js.map +1 -1
  20. package/dist/middlewares/auth.js +7 -25
  21. package/dist/middlewares/auth.js.map +1 -1
  22. package/dist/middlewares/userContext.js +6 -34
  23. package/dist/middlewares/userContext.js.map +1 -1
  24. package/dist/models/OAuth.js +14 -93
  25. package/dist/models/OAuth.js.map +1 -1
  26. package/dist/routes/index.js +3 -1
  27. package/dist/routes/index.js.map +1 -1
  28. package/dist/services/betterAuthConfig.js +1 -0
  29. package/dist/services/betterAuthConfig.js.map +1 -1
  30. package/dist/services/contextCostService.js +3 -1
  31. package/dist/services/contextCostService.js.map +1 -1
  32. package/dist/services/credentialBindingService.js +8 -3
  33. package/dist/services/credentialBindingService.js.map +1 -1
  34. package/dist/services/elicitationService.js +93 -0
  35. package/dist/services/elicitationService.js.map +1 -0
  36. package/dist/services/mcpService.js +167 -95
  37. package/dist/services/mcpService.js.map +1 -1
  38. package/dist/services/oauthServerService.js +15 -1
  39. package/dist/services/oauthServerService.js.map +1 -1
  40. package/dist/services/openApiGeneratorService.js +3 -1
  41. package/dist/services/openApiGeneratorService.js.map +1 -1
  42. package/dist/services/personalOAuthService.js +70 -8
  43. package/dist/services/personalOAuthService.js.map +1 -1
  44. package/dist/services/registrationService.js +28 -0
  45. package/dist/services/registrationService.js.map +1 -0
  46. package/dist/services/serverConfigPresenter.js +6 -1
  47. package/dist/services/serverConfigPresenter.js.map +1 -1
  48. package/dist/services/smartRoutingService.js +7 -6
  49. package/dist/services/smartRoutingService.js.map +1 -1
  50. package/dist/services/sseService.js +1 -2
  51. package/dist/services/sseService.js.map +1 -1
  52. package/dist/services/templateService.js +5 -4
  53. package/dist/services/templateService.js.map +1 -1
  54. package/dist/services/userService.js +22 -4
  55. package/dist/services/userService.js.map +1 -1
  56. package/dist/utils/credentialTemplate.js +76 -6
  57. package/dist/utils/credentialTemplate.js.map +1 -1
  58. package/dist/utils/migration.js +1 -0
  59. package/dist/utils/migration.js.map +1 -1
  60. package/dist/utils/namePattern.js +28 -0
  61. package/dist/utils/namePattern.js.map +1 -0
  62. package/dist/utils/oauthBearer.js +4 -2
  63. package/dist/utils/oauthBearer.js.map +1 -1
  64. package/dist/utils/passthroughHeaders.js +17 -0
  65. package/dist/utils/passthroughHeaders.js.map +1 -0
  66. package/dist/utils/rateLimit.js +1 -1
  67. package/dist/utils/rateLimit.js.map +1 -1
  68. package/dist/utils/serverConfigPersistence.js +1 -3
  69. package/dist/utils/serverConfigPersistence.js.map +1 -1
  70. package/dist/utils/serverConfigValidation.js +2 -1
  71. package/dist/utils/serverConfigValidation.js.map +1 -1
  72. package/dist/utils/settingsSync.js +5 -1
  73. package/dist/utils/settingsSync.js.map +1 -1
  74. package/dist/utils/toolConfig.js +93 -0
  75. package/dist/utils/toolConfig.js.map +1 -0
  76. package/dist/utils/upstreamError.js +9 -2
  77. package/dist/utils/upstreamError.js.map +1 -1
  78. package/dist/utils/userSession.js +29 -0
  79. package/dist/utils/userSession.js.map +1 -0
  80. package/frontend/dist/assets/{ActivityPage-BEpHoGLB.js → ActivityPage-CFRX20v4.js} +2 -2
  81. package/frontend/dist/assets/{ActivityPage-BEpHoGLB.js.map → ActivityPage-CFRX20v4.js.map} +1 -1
  82. package/frontend/dist/assets/{CopyClientConfigDialog-B4RDMLQ7.js → CopyClientConfigDialog-CDEiSInj.js} +2 -2
  83. package/frontend/dist/assets/{CopyClientConfigDialog-B4RDMLQ7.js.map → CopyClientConfigDialog-CDEiSInj.js.map} +1 -1
  84. package/frontend/dist/assets/CredentialsPage-BCLHY_fN.js +2 -0
  85. package/frontend/dist/assets/CredentialsPage-BCLHY_fN.js.map +1 -0
  86. package/frontend/dist/assets/{Dashboard-Bp8ZGDp5.js → Dashboard-B3Y6nAFL.js} +2 -2
  87. package/frontend/dist/assets/{Dashboard-Bp8ZGDp5.js.map → Dashboard-B3Y6nAFL.js.map} +1 -1
  88. package/frontend/dist/assets/{EndpointCopy-CH7rfwDL.js → EndpointCopy-BMxT99Ne.js} +2 -2
  89. package/frontend/dist/assets/{EndpointCopy-CH7rfwDL.js.map → EndpointCopy-BMxT99Ne.js.map} +1 -1
  90. package/frontend/dist/assets/GroupsPage-5iCk1LKT.js +33 -0
  91. package/frontend/dist/assets/GroupsPage-5iCk1LKT.js.map +1 -0
  92. package/frontend/dist/assets/LoginPage-BjYzY6RH.js +2 -0
  93. package/frontend/dist/assets/LoginPage-BjYzY6RH.js.map +1 -0
  94. package/frontend/dist/assets/{LogsPage-B4RyT3TS.js → LogsPage-CGcFNKJn.js} +2 -2
  95. package/frontend/dist/assets/{LogsPage-B4RyT3TS.js.map → LogsPage-CGcFNKJn.js.map} +1 -1
  96. package/frontend/dist/assets/{MarketPage-DV7Bs6bj.js → MarketPage-B7JPqFw3.js} +2 -2
  97. package/frontend/dist/assets/{MarketPage-DV7Bs6bj.js.map → MarketPage-B7JPqFw3.js.map} +1 -1
  98. package/frontend/dist/assets/{OAuthConsentPage-DdxMIqDO.js → OAuthConsentPage-BYi_kgNj.js} +2 -2
  99. package/frontend/dist/assets/{OAuthConsentPage-DdxMIqDO.js.map → OAuthConsentPage-BYi_kgNj.js.map} +1 -1
  100. package/frontend/dist/assets/{PromptsPage-61Uj8gCp.js → PromptsPage-x6X5trLX.js} +2 -2
  101. package/frontend/dist/assets/{PromptsPage-61Uj8gCp.js.map → PromptsPage-x6X5trLX.js.map} +1 -1
  102. package/frontend/dist/assets/{ResourcesPage-BSgOwVld.js → ResourcesPage-BJZCPBs8.js} +2 -2
  103. package/frontend/dist/assets/{ResourcesPage-BSgOwVld.js.map → ResourcesPage-BJZCPBs8.js.map} +1 -1
  104. package/frontend/dist/assets/ServersPage-CsyGLden.js +39 -0
  105. package/frontend/dist/assets/ServersPage-CsyGLden.js.map +1 -0
  106. package/frontend/dist/assets/{SettingsPage-C8zYH_jq.js → SettingsPage-C53DI0Sz.js} +6 -6
  107. package/frontend/dist/assets/SettingsPage-C53DI0Sz.js.map +1 -0
  108. package/frontend/dist/assets/{StatusDot-R86yLB-f.js → StatusDot-BDJd3Iix.js} +2 -2
  109. package/frontend/dist/assets/{StatusDot-R86yLB-f.js.map → StatusDot-BDJd3Iix.js.map} +1 -1
  110. package/frontend/dist/assets/{ToggleGroup-DN1ttokb.js → ToggleGroup-BbmRhILg.js} +2 -2
  111. package/frontend/dist/assets/{ToggleGroup-DN1ttokb.js.map → ToggleGroup-BbmRhILg.js.map} +1 -1
  112. package/frontend/dist/assets/{UsersPage-BCMjm9JG.js → UsersPage-NUG6vF8C.js} +2 -2
  113. package/frontend/dist/assets/{UsersPage-BCMjm9JG.js.map → UsersPage-NUG6vF8C.js.map} +1 -1
  114. package/frontend/dist/assets/{clipboard-DjzVWhkB.js → clipboard-7BggsilD.js} +2 -2
  115. package/frontend/dist/assets/{clipboard-DjzVWhkB.js.map → clipboard-7BggsilD.js.map} +1 -1
  116. package/frontend/dist/assets/index-B_IITM9e.js +3 -0
  117. package/frontend/dist/assets/index-B_IITM9e.js.map +1 -0
  118. package/frontend/dist/assets/index-CnqLKewL.css +1 -0
  119. package/frontend/dist/assets/{resourceService-DRZl8_Vm.js → resourceService-B674Fopr.js} +2 -2
  120. package/frontend/dist/assets/{resourceService-DRZl8_Vm.js.map → resourceService-B674Fopr.js.map} +1 -1
  121. package/frontend/dist/assets/{useCostData-DVLGVcuy.js → useCostData-8Z1HjAL5.js} +2 -2
  122. package/frontend/dist/assets/{useCostData-DVLGVcuy.js.map → useCostData-8Z1HjAL5.js.map} +1 -1
  123. package/frontend/dist/assets/variableDetection-C0nP3Jj2.js +18 -0
  124. package/frontend/dist/assets/variableDetection-C0nP3Jj2.js.map +1 -0
  125. package/frontend/dist/index.html +2 -2
  126. package/package.json +2 -2
  127. package/frontend/dist/assets/CredentialsPage-46Z8Qv7O.js +0 -2
  128. package/frontend/dist/assets/CredentialsPage-46Z8Qv7O.js.map +0 -1
  129. package/frontend/dist/assets/GroupsPage-DTjOja6T.js +0 -33
  130. package/frontend/dist/assets/GroupsPage-DTjOja6T.js.map +0 -1
  131. package/frontend/dist/assets/LoginPage-o6ibb_j3.js +0 -2
  132. package/frontend/dist/assets/LoginPage-o6ibb_j3.js.map +0 -1
  133. package/frontend/dist/assets/ServersPage-DYumMhzV.js +0 -39
  134. package/frontend/dist/assets/ServersPage-DYumMhzV.js.map +0 -1
  135. package/frontend/dist/assets/SettingsPage-C8zYH_jq.js.map +0 -1
  136. package/frontend/dist/assets/index--NhF_yyy.css +0 -1
  137. package/frontend/dist/assets/index-P_O2kAcB.js +0 -3
  138. package/frontend/dist/assets/index-P_O2kAcB.js.map +0 -1
  139. package/frontend/dist/assets/variableDetection-DiE4h0o7.js +0 -16
  140. package/frontend/dist/assets/variableDetection-DiE4h0o7.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoginPage-o6ibb_j3.js","sources":["../../src/components/ui/DefaultPasswordWarningModal.tsx","../../src/pages/LoginPage.tsx"],"sourcesContent":["import React from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useNavigate } from 'react-router-dom';\n\ninterface DefaultPasswordWarningModalProps {\n isOpen: boolean;\n onClose: () => void;\n}\n\nconst DefaultPasswordWarningModal: React.FC<DefaultPasswordWarningModalProps> = ({\n isOpen,\n onClose,\n}) => {\n const { t } = useTranslation();\n const navigate = useNavigate();\n\n if (!isOpen) return null;\n\n const handleGoToSettings = () => {\n onClose();\n navigate('/settings');\n // Auto-scroll to password section after a small delay to ensure page is loaded\n setTimeout(() => {\n const passwordSection = document.querySelector('[data-section=\"password\"]');\n if (passwordSection) {\n passwordSection.scrollIntoView({ behavior: 'smooth', block: 'start' });\n // If the section is collapsed, expand it\n const clickTarget = passwordSection.querySelector('[role=\"button\"]');\n if (clickTarget && !passwordSection.querySelector('.mt-4')) {\n (clickTarget as HTMLElement).click();\n }\n }\n }, 100);\n };\n\n const handleBackdropClick = (e: React.MouseEvent) => {\n if (e.target === e.currentTarget) {\n onClose();\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n onClose();\n }\n };\n\n return (\n <div\n className=\"fixed inset-0 bg-black/50 z-[100] flex items-center justify-center p-4\"\n onClick={handleBackdropClick}\n onKeyDown={handleKeyDown}\n tabIndex={-1}\n >\n <div\n className=\"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full transform transition-all duration-200 ease-out\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=\"password-warning-title\"\n aria-describedby=\"password-warning-message\"\n >\n <div className=\"p-6\">\n <div className=\"flex items-start space-x-3\">\n <div className=\"flex-shrink-0\">\n <svg\n className=\"w-6 h-6 text-yellow-600 dark:text-yellow-400\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z\"\n />\n </svg>\n </div>\n <div className=\"flex-1\">\n <h3\n id=\"password-warning-title\"\n className=\"text-lg font-medium text-gray-900 dark:text-white mb-2\"\n >\n {t('auth.defaultPasswordWarning')}\n </h3>\n <p\n id=\"password-warning-message\"\n className=\"text-gray-600 dark:text-gray-300 leading-relaxed\"\n >\n {t('auth.defaultPasswordMessage')}\n </p>\n </div>\n </div>\n\n <div className=\"flex justify-end space-x-3 mt-6\">\n <button\n onClick={onClose}\n className=\"hub-btn\"\n >\n {t('common.cancel')}\n </button>\n <button\n onClick={handleGoToSettings}\n className=\"hub-btn primary\"\n autoFocus\n >\n {t('auth.goToSettings')}\n </button>\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default DefaultPasswordWarningModal;\n","import React, { useState, useMemo, useCallback, useEffect } from 'react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport { useTranslation } from 'react-i18next';\nimport { BookOpen, AlertCircle } from 'lucide-react';\nimport { useAuth } from '../contexts/AuthContext';\nimport { getToken } from '../services/authService';\nimport { getPublicConfig } from '../services/configService';\nimport { createBetterAuthClient, startOidcLogin } from '../services/betterAuthClient';\nimport { getBasePath } from '../utils/runtime';\nimport ThemeSwitch from '@/components/ui/ThemeSwitch';\nimport LanguageSwitch from '@/components/ui/LanguageSwitch';\nimport GitHubIcon from '@/components/icons/GitHubIcon';\nimport DefaultPasswordWarningModal from '@/components/ui/DefaultPasswordWarningModal';\n\ntype SocialProvider = 'google' | 'github' | 'oidc';\n\nconst sanitizeReturnUrl = (value: string | null): string | null => {\n if (!value) return null;\n try {\n const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';\n const url = new URL(value, origin);\n if (url.origin !== origin) return null;\n const relativePath = `${url.pathname}${url.search}${url.hash}`;\n return relativePath || '/';\n } catch {\n if (value.startsWith('/') && !value.startsWith('//')) return value;\n return null;\n }\n};\n\nconst LoginPage: React.FC = () => {\n const { t } = useTranslation();\n const [username, setUsername] = useState('');\n const [password, setPassword] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [loading, setLoading] = useState(false);\n const [socialLoading, setSocialLoading] = useState<SocialProvider | null>(null);\n const [socialError, setSocialError] = useState<string | null>(null);\n const [betterAuthBasePath, setBetterAuthBasePath] = useState<string | undefined>(undefined);\n // Set from the public config: only SSO sign-in is offered\n const [passwordLoginDisabled, setPasswordLoginDisabled] = useState(false);\n const [socialProviders, setSocialProviders] = useState({\n google: false,\n github: false,\n oidc: false,\n });\n const [oidcProviderId, setOidcProviderId] = useState<string>('oidc');\n const [showDefaultPasswordWarning, setShowDefaultPasswordWarning] = useState(false);\n const { login, auth } = useAuth();\n const location = useLocation();\n const navigate = useNavigate();\n const returnUrl = useMemo(() => {\n const params = new URLSearchParams(location.search);\n return sanitizeReturnUrl(params.get('returnUrl'));\n }, [location.search]);\n\n const isServerUnavailableError = useCallback((message?: string) => {\n if (!message) return false;\n const normalized = message.toLowerCase();\n return (\n normalized.includes('failed to fetch') ||\n normalized.includes('networkerror') ||\n normalized.includes('network error') ||\n normalized.includes('connection refused') ||\n normalized.includes('unable to connect') ||\n normalized.includes('fetch error') ||\n normalized.includes('econnrefused') ||\n normalized.includes('http 500') ||\n normalized.includes('internal server error') ||\n normalized.includes('proxy error')\n );\n }, []);\n\n const buildRedirectTarget = useCallback(() => {\n if (!returnUrl) return '/';\n if (!returnUrl.startsWith('/oauth/authorize')) return returnUrl;\n const token = getToken();\n if (!token) return returnUrl;\n try {\n const origin = window.location.origin;\n const url = new URL(returnUrl, origin);\n url.searchParams.set('token', token);\n return `${url.pathname}${url.search}${url.hash}`;\n } catch {\n const separator = returnUrl.includes('?') ? '&' : '?';\n return `${returnUrl}${separator}token=${encodeURIComponent(token)}`;\n }\n }, [returnUrl]);\n\n const redirectAfterLogin = useCallback(() => {\n if (returnUrl) {\n window.location.assign(buildRedirectTarget());\n } else {\n navigate('/');\n }\n }, [buildRedirectTarget, navigate, returnUrl]);\n\n useEffect(() => {\n if (!auth.loading && auth.isAuthenticated) redirectAfterLogin();\n }, [auth.isAuthenticated, auth.loading, redirectAfterLogin]);\n\n useEffect(() => {\n const params = new URLSearchParams(location.search);\n const errorCode = params.get('error');\n if (errorCode) {\n const i18nKey = `auth.error.${errorCode}`;\n const translated = t(i18nKey);\n setSocialError(translated !== i18nKey ? translated : t('auth.socialLoginFailed'));\n }\n }, [location.search, t]);\n\n useEffect(() => {\n const loadAuthProviders = async () => {\n const publicConfig = await getPublicConfig();\n const betterAuth = publicConfig.betterAuth;\n if (!betterAuth?.enabled) {\n setSocialProviders({ google: false, github: false, oidc: false });\n return;\n }\n setBetterAuthBasePath(betterAuth.basePath);\n setPasswordLoginDisabled(betterAuth.disablePasswordLogin === true);\n setOidcProviderId(betterAuth.providers?.oidc?.providerId || 'oidc');\n setSocialProviders({\n google: betterAuth.providers?.google?.enabled === true,\n github: betterAuth.providers?.github?.enabled === true,\n oidc: betterAuth.providers?.oidc?.enabled === true,\n });\n };\n loadAuthProviders();\n }, []);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setError(null);\n setSocialError(null);\n setLoading(true);\n try {\n if (!username || !password) {\n setError(t('auth.emptyFields'));\n setLoading(false);\n return;\n }\n const result = await login(username, password);\n if (result.success) {\n if (result.isUsingDefaultPassword) setShowDefaultPasswordWarning(true);\n else redirectAfterLogin();\n } else {\n const message = result.message;\n setError(isServerUnavailableError(message) ? t('auth.serverUnavailable') : t('auth.loginFailed'));\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : undefined;\n setError(isServerUnavailableError(message) ? t('auth.serverUnavailable') : t('auth.loginError'));\n } finally {\n setLoading(false);\n }\n };\n\n const handleSocialLogin = async (provider: SocialProvider) => {\n setSocialError(null);\n setSocialLoading(provider);\n try {\n if (provider === 'oidc') {\n await startOidcLogin({\n providerId: oidcProviderId,\n callbackURL: returnUrl || '/',\n errorCallbackURL: `${getBasePath()}/login`,\n basePathOverride: betterAuthBasePath,\n });\n return;\n }\n\n const client = createBetterAuthClient(betterAuthBasePath);\n await client.signIn.social({\n provider,\n callbackURL: returnUrl || '/',\n errorCallbackURL: `${getBasePath()}/login`,\n });\n } catch (err) {\n console.error('Social login error:', err);\n setSocialError(t('auth.socialLoginFailed'));\n setSocialLoading(null);\n }\n };\n\n const handleCloseWarning = () => {\n setShowDefaultPasswordWarning(false);\n redirectAfterLogin();\n };\n\n return (\n <div\n className=\"relative min-h-screen w-full overflow-hidden\"\n style={{ background: 'var(--hub-bg)', color: 'var(--hub-ink)' }}\n >\n {/* Top-right controls */}\n <div className=\"absolute top-3 right-4 z-20 flex items-center gap-1\">\n <a\n href=\"https://github.com/samanhappy/mcphub\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hub-icon-btn\"\n aria-label=\"GitHub Repository\"\n >\n <GitHubIcon className=\"h-4 w-4\" />\n </a>\n <a\n href=\"https://docs.mcphub.app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hub-icon-btn\"\n aria-label=\"Documentation\"\n >\n <BookOpen className=\"h-4 w-4\" />\n </a>\n <ThemeSwitch />\n <LanguageSwitch />\n </div>\n\n {/* Subtle grid pattern (kept low-key, hair-line) */}\n <div className=\"pointer-events-none absolute inset-0 -z-10\">\n <svg\n className=\"h-full w-full\"\n style={{ opacity: 0.5 }}\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <defs>\n <pattern id=\"grid\" width=\"32\" height=\"32\" patternUnits=\"userSpaceOnUse\">\n <path\n d=\"M 32 0 L 0 0 0 32\"\n fill=\"none\"\n stroke=\"var(--hub-line-2)\"\n strokeWidth=\"0.5\"\n />\n </pattern>\n </defs>\n <rect width=\"100%\" height=\"100%\" fill=\"url(#grid)\" />\n </svg>\n </div>\n\n <div className=\"relative mx-auto flex min-h-screen w-full max-w-md items-center justify-center px-6\">\n <div className=\"w-full space-y-8\">\n {/* Brand */}\n <div className=\"flex flex-col items-center gap-3\">\n <div\n className=\"relative grid place-items-center\"\n style={{\n width: 44,\n height: 44,\n borderRadius: 10,\n background: 'var(--hub-ink)',\n color: 'var(--hub-bg)',\n }}\n >\n <span className=\"hub-mono font-semibold\" style={{ fontSize: 18 }}>\n M\n </span>\n <span\n className=\"absolute\"\n style={{\n right: -2,\n bottom: -2,\n width: 8,\n height: 8,\n borderRadius: 50,\n background: 'var(--hub-ok)',\n boxShadow: '0 0 0 3px var(--hub-bg)',\n }}\n />\n </div>\n <div className=\"text-center\">\n <h1\n style={{\n fontSize: 20,\n fontWeight: 600,\n letterSpacing: '-0.02em',\n color: 'var(--hub-ink)',\n }}\n >\n {t('app.title')}\n </h1>\n <p className=\"hub-sub\" style={{ marginTop: 4 }}>\n {t('auth.slogan')}\n </p>\n </div>\n </div>\n\n {/* Login card */}\n <div\n className=\"hub-card\"\n style={{\n padding: '22px 22px 20px',\n boxShadow: '0 1px 2px rgba(0,0,0,0.02)',\n }}\n >\n {!passwordLoginDisabled && (\n <form className=\"space-y-3\" onSubmit={handleSubmit}>\n <div>\n <label\n htmlFor=\"username\"\n className=\"hub-sect block\"\n style={{ marginBottom: 6 }}\n >\n {t('auth.username')}\n </label>\n <input\n id=\"username\"\n name=\"username\"\n type=\"text\"\n autoComplete=\"username\"\n required\n className=\"hub-input\"\n placeholder={t('auth.username')}\n value={username}\n onChange={(e) => setUsername(e.target.value)}\n />\n </div>\n <div>\n <label\n htmlFor=\"password\"\n className=\"hub-sect block\"\n style={{ marginBottom: 6 }}\n >\n {t('auth.password')}\n </label>\n <input\n id=\"password\"\n name=\"password\"\n type=\"password\"\n autoComplete=\"current-password\"\n required\n className=\"hub-input\"\n placeholder={t('auth.password')}\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n />\n </div>\n\n {error && (\n <div\n className=\"flex items-center gap-2\"\n style={{\n padding: '8px 10px',\n borderRadius: 7,\n border: '1px solid oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n fontSize: 12.5,\n }}\n >\n <AlertCircle size={13} className=\"flex-shrink-0\" />\n <span>{error}</span>\n </div>\n )}\n\n <button\n type=\"submit\"\n disabled={loading}\n className=\"hub-btn primary w-full justify-center\"\n style={{ height: 34 }}\n >\n {loading ? t('auth.loggingIn') : t('auth.login')}\n </button>\n </form>\n )}\n\n {(socialProviders.google || socialProviders.github || socialProviders.oidc) && (\n <div className={passwordLoginDisabled ? 'space-y-3' : 'mt-5 space-y-3'}>\n {!passwordLoginDisabled && (\n <div className=\"flex items-center gap-3\">\n <div className=\"h-px flex-1\" style={{ background: 'var(--hub-line)' }} />\n <span\n className=\"hub-sect\"\n style={{ textTransform: 'uppercase', letterSpacing: '0.08em' }}\n >\n {t('auth.orContinue')}\n </span>\n <div className=\"h-px flex-1\" style={{ background: 'var(--hub-line)' }} />\n </div>\n )}\n\n {socialError && (\n <div\n className=\"flex items-center gap-2\"\n style={{\n padding: '8px 10px',\n borderRadius: 7,\n border: '1px solid oklch(0.85 0.1 25)',\n background: 'oklch(0.97 0.03 25)',\n color: 'oklch(0.4 0.18 25)',\n fontSize: 12.5,\n }}\n >\n <AlertCircle size={13} className=\"flex-shrink-0\" />\n <span>{socialError}</span>\n </div>\n )}\n\n <div className=\"space-y-2\">\n {socialProviders.google && (\n <button\n type=\"button\"\n onClick={() => handleSocialLogin('google')}\n disabled={socialLoading !== null}\n className=\"hub-btn w-full justify-center\"\n style={{ height: 34 }}\n >\n {socialLoading === 'google'\n ? t('auth.loggingIn')\n : t('auth.loginWithGoogle')}\n </button>\n )}\n {socialProviders.github && (\n <button\n type=\"button\"\n onClick={() => handleSocialLogin('github')}\n disabled={socialLoading !== null}\n className=\"hub-btn w-full justify-center\"\n style={{\n height: 34,\n background: 'var(--hub-ink)',\n color: 'var(--hub-bg)',\n borderColor: 'var(--hub-ink)',\n }}\n >\n <GitHubIcon className=\"h-3.5 w-3.5\" />\n {socialLoading === 'github'\n ? t('auth.loggingIn')\n : t('auth.loginWithGithub')}\n </button>\n )}\n {socialProviders.oidc && (\n <button\n type=\"button\"\n onClick={() => handleSocialLogin('oidc')}\n disabled={socialLoading !== null}\n className=\"hub-btn w-full justify-center\"\n style={{ height: 34 }}\n >\n {socialLoading === 'oidc'\n ? t('auth.loggingIn')\n : t('auth.loginWithOIDC')}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n\n <p\n className=\"text-center hub-mono\"\n style={{ fontSize: 11, color: 'var(--hub-ink-3)' }}\n >\n v{import.meta.env.PACKAGE_VERSION}\n </p>\n </div>\n </div>\n\n <DefaultPasswordWarningModal\n isOpen={showDefaultPasswordWarning}\n onClose={handleCloseWarning}\n />\n </div>\n );\n};\n\nexport default LoginPage;\n"],"names":["DefaultPasswordWarningModal","isOpen","onClose","t","useTranslation","navigate","useNavigate","handleGoToSettings","passwordSection","clickTarget","handleBackdropClick","e","handleKeyDown","jsx","jsxs","sanitizeReturnUrl","value","origin","url","LoginPage","username","setUsername","useState","password","setPassword","error","setError","loading","setLoading","socialLoading","setSocialLoading","socialError","setSocialError","betterAuthBasePath","setBetterAuthBasePath","passwordLoginDisabled","setPasswordLoginDisabled","socialProviders","setSocialProviders","oidcProviderId","setOidcProviderId","showDefaultPasswordWarning","setShowDefaultPasswordWarning","login","auth","useAuth","location","useLocation","returnUrl","useMemo","params","isServerUnavailableError","useCallback","message","normalized","buildRedirectTarget","token","getToken","separator","redirectAfterLogin","useEffect","errorCode","i18nKey","translated","betterAuth","getPublicConfig","_b","_a","_d","_c","_f","_e","_h","_g","handleSubmit","result","err","handleSocialLogin","provider","startOidcLogin","getBasePath","createBetterAuthClient","handleCloseWarning","GitHubIcon","BookOpen","ThemeSwitch","LanguageSwitch","AlertCircle"],"mappings":"mRASA,MAAMA,GAA0E,CAAC,CAC/E,OAAAC,EACA,QAAAC,CACF,IAAM,CACJ,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAA,EACRC,EAAWC,EAAA,EAEjB,GAAI,CAACL,EAAQ,OAAO,KAEpB,MAAMM,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KAAC,MAAA,CAAI,UAAU,YACZ,SAAA,CAAAuB,EAAgB,QACfxB,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAAS,IAAMgE,EAAkB,QAAQ,EACzC,SAAUhD,IAAkB,KAC5B,UAAU,gCACV,MAAO,CAAE,OAAQ,EAAA,EAEhB,SACG1B,MADe,SACb,iBACA,sBADgB,CACM,CAAA,EAG/BkC,EAAgB,QACfvB,EAAAA,KAAC,SAAA,CACC,KAAK,SACL,QAAS,IAAM+D,EAAkB,QAAQ,EACzC,SAAUhD,IAAkB,KAC5B,UAAU,gCACV,MAAO,CACL,OAAQ,GACR,WAAY,iBACZ,MAAO,gBACP,YAAa,gBAAA,EAGf,SAAA,CAAAhB,EAAAA,IAACsE,EAAA,CAAW,UAAU,cAAc,EAEhChF,EADH0B,IAAkB,SACb,iBACA,sBADgB,CACM,CAAA,CAAA,EAG/BQ,EAAgB,MACfxB,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAAS,IAAMgE,EAAkB,MAAM,EACvC,SAAUhD,IAAkB,KAC5B,UAAU,gCACV,MAAO,CAAE,OAAQ,EAAA,EAEhB,SACG1B,MADe,OACb,iBACA,oBADgB,CACI,CAAA,CAC5B,EAEJ,CAAA,EACF,CAAA,CAAA,CAAA,EAIJW,EAAAA,KAAC,IAAA,CACC,UAAU,uBACV,MAAO,CAAE,SAAU,GAAI,MAAO,kBAAA,EAC/B,SAAA,CAAA,IACG,OAAA,CAAgB,CAAA,CACpB,CAAA,CACF,CAAA,CACF,EAEAD,EAAAA,IAACb,GAAA,CACC,OAAQyC,EACR,QAASyC,CAAA,CAAA,CACX,CAAA,CAAA,CAGN"}
@@ -1,39 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./resourceService-DRZl8_Vm.js","./index-P_O2kAcB.js","./framework-vendor-CQFm9vKd.js","./i18n-vendor-DVmjrzgW.js","./icons-vendor-CkcU1LMA.js","./index--NhF_yyy.css"])))=>i.map(i=>d[i]);
2
- import{r as c,j as e,L as Js,d as Ls}from"./framework-vendor-CQFm9vKd.js";import{j as Ne,f as ps,h as Te,k as le,i as we,u as Ws,_ as ve,l as qs,m as Ks}from"./index-P_O2kAcB.js";import{u as re}from"./i18n-vendor-DVmjrzgW.js";import{n as ke,o as hs,p as xs,l as Ce,q as Hs,C as fe,r as be,s as $e,t as bs,u as fs,m as Se,W as Gs,g as Xs,F as Ys,X as De,R as me,v as Zs,w as Qs,x as et,y as st,L as tt,T as rt,P as nt,z as at,D as ot,G as it}from"./icons-vendor-CkcU1LMA.js";import{f as ce}from"./contextCost-CilWqGWT.js";import{S as lt}from"./StatusDot-R86yLB-f.js";import{u as Ee,c as as}from"./clipboard-DjzVWhkB.js";import{S as Pe}from"./ToggleGroup-DN1ttokb.js";import{g as ct,C as dt,t as ut}from"./CopyClientConfigDialog-B4RDMLQ7.js";import{D as mt}from"./DeleteDialog-BaCsEkJA.js";import{C as ze}from"./ConfirmDialog-BYdfb115.js";import{c as pt,S as ht,a as gs,d as xt}from"./variableDetection-DiE4h0o7.js";import{P as bt}from"./Pagination-BRqqU5Ct.js";import{u as ft,a as gt}from"./useCostData-DVLGVcuy.js";function yt({serverName:s,enabled:n=!0}){const{t}=re(),{showToast:r}=Ne(),[b,u]=c.useState(!1),[a,j]=c.useState(),[h,E]=c.useState(!1),d=`/servers/${encodeURIComponent(s)}/oauth/personal`;c.useEffect(()=>{let v=!0;const w=()=>{ps(d).then(D=>{var A,O;v&&D.success&&(u(!!((A=D.data)!=null&&A.connected)),j((O=D.data)==null?void 0:O.authorizationUrl))}).catch(()=>{})};return w(),window.addEventListener("focus",w),()=>{v=!1,window.removeEventListener("focus",w)}},[d]);const g=async v=>{var D,A,O;const w=v?null:window.open("about:blank","_blank");w&&(w.opener=null),E(!0);try{const I=v?await Te(d):await le(d,{});if(!I.success)throw new Error(I.message||t("server.oauth.personalError"));u(!!((D=I.data)!=null&&D.connected)),j((A=I.data)==null?void 0:A.authorizationUrl),(O=I.data)!=null&&O.authorizationUrl&&w?w.location.replace(I.data.authorizationUrl):w==null||w.close()}catch(I){w==null||w.close(),r(I instanceof Error?I.message:t("server.oauth.personalError"),"error")}finally{E(!1)}},o=t(n?b?"status.online":"status.oauthRequired":"server.disable"),p="hub-btn whitespace-nowrap",_="block w-full px-2.5 py-1.5 text-[13px] rounded-md hover:bg-[var(--hub-surface-hover)] text-left whitespace-nowrap";return e.jsx("div",{className:"relative",onClick:v=>v.stopPropagation(),children:b?e.jsxs("details",{children:[e.jsxs("summary",{className:`${p} cursor-pointer list-none`,children:[o,e.jsx(ke,{size:12})]}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-20 hub-card p-1",children:[e.jsx("button",{className:_,disabled:h||!n,onClick:()=>void g(!1),children:t("server.oauth.personalReconnect")}),e.jsx("button",{className:_,disabled:h,onClick:()=>void g(!0),children:t("server.oauth.personalDisconnect")})]})]}):a&&n?e.jsx("a",{className:p,title:t("status.clickToAuthorize"),href:a,target:"_blank",rel:"noopener noreferrer",children:o}):e.jsx("button",{className:p,disabled:h||!n,title:t("server.oauth.personalConnect"),onClick:()=>void g(!1),children:o})})}const ys=async(s,n)=>{try{const t=n?`/tools/${encodeURIComponent(n)}/${encodeURIComponent(s.toolName)}`:"/tools/call",r=await le(t,s.arguments,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return r.success===!1?{success:!1,error:r.message||"Tool call failed"}:{success:!0,content:(r==null?void 0:r.content)||[]}}catch(t){return console.error("Error calling tool",{toolName:s.toolName,server:n,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},jt=async(s,n,t)=>{try{const r=await le(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(n)}/toggle`,{enabled:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error toggling tool",{serverName:s,toolName:n,enabled:t,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},js=async(s,n,t)=>{try{const r=await we(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(n)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error updating tool description",{serverName:s,toolName:n,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},vs=async(s,n)=>{var t;try{const r=await Te(`/servers/${encodeURIComponent(s)}/tools/${encodeURIComponent(n)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message,description:(t=r.data)==null?void 0:t.description}}catch(r){return console.error("Error resetting tool description",{serverName:s,toolName:n,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},vt=Object.freeze(Object.defineProperty({__proto__:null,callTool:ys,resetToolDescription:vs,toggleTool:jt,updateToolDescription:js},Symbol.toStringTag,{value:"Module"})),Ns=({schema:s,onSubmit:n,onCancel:t,loading:r=!1,storageKey:b,title:u})=>{const{t:a}=re(),[j,h]=c.useState({}),[E,d]=c.useState({}),[g,o]=c.useState(!1),[p,_]=c.useState(""),[v,w]=c.useState(""),D=c.useMemo(()=>(x=>{const C=l=>{if(typeof l=="object"&&l!==null){const f=l;return{type:f.type||"string",description:f.description,enum:f.enum,default:f.default,properties:f.properties?Object.fromEntries(Object.entries(f.properties).map(([m,k])=>[m,C(k)])):void 0,required:f.required,items:f.items?C(f.items):void 0}}return{type:"string"}};return{type:x.type,properties:x.properties?Object.fromEntries(Object.entries(x.properties).map(([l,f])=>[l,C(f)])):void 0,required:x.required}})(s),[s]);c.useEffect(()=>{const y=(C,l="")=>{const f={};return C.type==="object"&&C.properties&&Object.entries(C.properties).forEach(([m,k])=>{const $=l?`${l}.${m}`:m;k.default!==void 0?f[m]=k.default:k.type==="string"?f[m]="":k.type==="number"||k.type==="integer"?f[m]=0:k.type==="boolean"?f[m]=!1:k.type==="array"?f[m]=[]:k.type==="object"&&(k.properties?f[m]=y(k,$):f[m]={})}),f};let x=y(D);if(b)try{const C=localStorage.getItem(b);if(C){const l=JSON.parse(C);x={...x,...l}}}catch(C){console.warn("Failed to load saved form data:",C)}h(x)},[D,b]),c.useEffect(()=>{g&&Object.keys(j).length>0&&(_(JSON.stringify(j,null,2)),w(""))},[g,j]);const A=y=>{_(y),w("");try{const x=JSON.parse(y);if(h(x),b)try{localStorage.setItem(b,JSON.stringify(x))}catch(C){console.warn("Failed to save form data to localStorage:",C)}}catch{w(a("tool.invalidJsonFormat"))}},O=()=>{_(JSON.stringify(j,null,2)),w(""),o(!0)},I=()=>{if(p.trim())try{const y=JSON.parse(p);h(y),w(""),o(!1)}catch{w(a("tool.fixJsonBeforeSwitching"));return}else o(!1)},M=(y,x)=>{h(C=>{const l={...C},f=y.split(".");let m=l;for(let $=0;$<f.length-1;$++){const R=f[$];if(R==="__proto__"||R==="constructor"||R==="prototype")return C;m[R]||(m[R]={}),m=m[R]}const k=f[f.length-1];if(!k||k==="__proto__"||k==="constructor"||k==="prototype")return C;if(m[k]=x,b)try{localStorage.setItem(b,JSON.stringify(l))}catch($){console.warn("Failed to save form data to localStorage:",$)}return l}),E[y]&&d(C=>{const l={...C};return delete l[y],l})},L=()=>{const y={},x=(C,l,f="")=>{C.type==="object"&&C.properties&&Object.entries(C.properties).forEach(([m,k])=>{var W;const $=f?`${f}.${m}`:m,R=l==null?void 0:l[m];if((W=C.required)!=null&&W.includes(m)&&(R==null||R===""||Array.isArray(R)&&R.length===0)){y[$]=`${m} is required`;return}R!=null&&R!==""&&(k.type==="string"&&typeof R!="string"?y[$]=`${m} must be a string`:k.type==="number"&&typeof R!="number"?y[$]=`${m} must be a number`:k.type==="integer"&&(!Number.isInteger(R)||typeof R!="number")?y[$]=`${m} must be an integer`:k.type==="boolean"&&typeof R!="boolean"?y[$]=`${m} must be a boolean`:k.type==="array"&&Array.isArray(R)?k.items&&R.forEach((Y,G)=>{var Q;((Q=k.items)==null?void 0:Q.type)==="object"&&k.items.properties&&x(k.items,Y,`${$}.${G}`)}):k.type==="object"&&typeof R=="object"&&x(k,R,$))})};return x(D,j),d(y),Object.keys(y).length===0},z=y=>{y.preventDefault(),L()&&n(j)},U=(y,x)=>x.split(".").reduce((C,l)=>C==null?void 0:C[l],y),q=(y,x,C,l)=>{const f=C==null?void 0:C[y];return x.type==="string"?x.enum?e.jsxs("select",{value:f||"",onChange:m=>l(m.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:a("tool.selectOption")}),x.enum.map((m,k)=>e.jsx("option",{value:m,children:m},k))]}):e.jsx("input",{type:"text",value:f||"",onChange:m=>l(m.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:x.description||a("tool.enterKey",{key:y})}):x.type==="number"||x.type==="integer"?e.jsx("input",{type:"number",step:x.type==="integer"?"1":"any",value:f??"",onChange:m=>{const k=m.target.value===""?"":x.type==="integer"?parseInt(m.target.value):parseFloat(m.target.value);l(k)},className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input"}):x.type==="boolean"?e.jsx("input",{type:"checkbox",checked:f||!1,onChange:m=>l(m.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}):e.jsx("input",{type:"text",value:f||"",onChange:m=>l(m.target.value),className:"w-full border rounded-md px-2 py-1 text-sm border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500 form-input",placeholder:x.description||a("tool.enterKey",{key:y})})},ee=(y,x,C="")=>{var k,$,R,W,Y,G,Q,N,B,te,ne,T,K,J;const l=C?`${C}.${y}`:y,f=U(j,l),m=E[l];if(x.type==="array"){const F=U(j,l)||[];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?($=(k=U(D,C))==null?void 0:k.required)==null?void 0:$.includes(y):(R=D.required)==null?void 0:R.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-3 bg-gray-50 dark:bg-gray-800",children:[F.map((H,ae)=>{var ge,ye,je;return e.jsxs("div",{className:"mb-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600",children:a("tool.item",{index:ae+1})}),e.jsx("button",{type:"button",onClick:()=>{const Z=[...F];Z.splice(ae,1),M(l,Z)},className:"text-status-red hover:text-red-700 text-sm",children:a("common.remove")})]}),((ge=x.items)==null?void 0:ge.type)==="string"&&x.items.enum?e.jsxs("select",{value:H||"",onChange:Z=>{const oe=[...F];oe[ae]=Z.target.value,M(l,oe)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:a("tool.selectOption")}),x.items.enum.map((Z,oe)=>e.jsx("option",{value:Z,children:Z},oe))]}):((ye=x.items)==null?void 0:ye.type)==="object"&&x.items.properties?e.jsx("div",{className:"space-y-3",children:Object.entries(x.items.properties).map(([Z,oe])=>{var ie,X;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-600 mb-1",children:[Z,((X=(ie=x.items)==null?void 0:ie.required)==null?void 0:X.includes(Z))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),q(Z,oe,H,he=>{const xe=[...F];xe[ae]={...xe[ae],[Z]:he},M(l,xe)})]},Z)})}):e.jsx("input",{type:"text",value:H||"",onChange:Z=>{const oe=[...F];oe[ae]=Z.target.value,M(l,oe)},className:"w-full border rounded-md px-3 py-2 border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:a("tool.enterValue",{type:((je=x.items)==null?void 0:je.type)||"value"})})]},ae)}),e.jsx("button",{type:"button",onClick:()=>{var ae;const H=((ae=x.items)==null?void 0:ae.type)==="object"?{}:"";M(l,[...F,H])},className:"w-full mt-2 px-3 py-2 text-sm text-blue-600 border border-blue-300 rounded-md hover:bg-blue-50",children:a("tool.addItem",{key:y})})]}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l)}return x.type==="object"?x.properties?e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?(Y=(W=U(D,C))==null?void 0:W.required)==null?void 0:Y.includes(y):(G=D.required)==null?void 0:G.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-md p-4 bg-gray-50 dark:bg-gray-800",children:Object.entries(x.properties).map(([F,H])=>ee(F,H,l))}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?(N=(Q=U(D,C))==null?void 0:Q.required)==null?void 0:N.includes(y):(B=D.required)==null?void 0:B.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(JSON object)"})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsx("textarea",{value:typeof f=="object"?JSON.stringify(f,null,2):f||"{}",onChange:F=>{try{const H=JSON.parse(F.target.value);M(l,H)}catch{M(l,F.target.value)}},placeholder:`{
3
- "key": "value"
4
- }`,className:`w-full border rounded-md px-3 py-2 font-mono text-sm ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,rows:4}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):x.type==="string"?x.enum?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?!1:(te=D.required)==null?void 0:te.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsxs("select",{value:f||"",onChange:F=>M(l,F.target.value),className:`w-full border rounded-md px-3 py-2 ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[e.jsx("option",{value:"",children:a("tool.selectOption")}),x.enum.map((F,H)=>e.jsx("option",{value:F,children:F},H))]}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?!1:(ne=D.required)==null?void 0:ne.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsx("input",{type:"text",value:f||"",onChange:F=>M(l,F.target.value),className:`w-full border rounded-md px-3 py-2 ${m?"border-red":"border-gray-200"} focus:outline-none form-input`}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):x.type==="number"||x.type==="integer"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?!1:(T=D.required)==null?void 0:T.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsx("input",{type:"number",step:x.type==="integer"?"1":"any",value:f??"",onChange:F=>{const H=F.target.value===""?"":x.type==="integer"?parseInt(F.target.value):parseFloat(F.target.value);M(l,H)},className:`w-full border rounded-md px-3 py-2 form-input ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):x.type==="boolean"?e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:f||!1,onChange:F=>M(l,F.target.checked),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),e.jsxs("label",{className:"ml-2 block text-sm text-gray-700",children:[y,(C?!1:(K=D.required)==null?void 0:K.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"})]})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:x.description}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l):e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[y,(C?!1:(J=D.required)==null?void 0:J.includes(y))&&e.jsx("span",{className:"text-status-red ml-1",children:"*"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-1",children:["(",x.type,")"]})]}),x.description&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:x.description}),e.jsx("input",{type:"text",value:f||"",onChange:F=>M(l,F.target.value),placeholder:a("tool.enterValue",{type:x.type}),className:`w-full border rounded-md px-3 py-2 ${m?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500 form-input`}),m&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:m})]},l)};return D.properties?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center pb-3",children:[e.jsx("h6",{className:"text-md font-medium text-gray-900",children:u}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{type:"button",onClick:I,className:`hub-btn sm ${g?"":"primary"}`,children:a("tool.formMode")}),e.jsx("button",{type:"button",onClick:O,className:`hub-btn sm ${g?"primary":""}`,children:a("tool.jsonMode")})]})]}),g?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:a("tool.jsonConfiguration")}),e.jsx("textarea",{value:p,onChange:y=>A(y.target.value),placeholder:`{
5
- "key": "value"
6
- }`,className:`w-full h-64 border rounded-md px-3 py-2 font-mono text-sm resize-y form-input ${v?"border-red-500":"border-gray-300"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),v&&e.jsx("p",{className:"text-status-red text-xs mt-1",children:v})]}),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:a("tool.cancel")}),e.jsx("button",{onClick:()=>{try{const y=JSON.parse(p);n(y)}catch{w(a("tool.invalidJsonFormat"))}},disabled:r||!!v,className:"hub-btn sm primary",children:a(r?"tool.running":"tool.runTool")})]})]}):e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[Object.entries(D.properties||{}).map(([y,x])=>ee(y,x)),e.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn sm",children:a("tool.cancel")}),e.jsx("button",{type:"submit",disabled:r,className:"hub-btn sm primary",children:a(r?"tool.running":"tool.runTool")})]})]})]}):e.jsxs("div",{className:"p-4 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-gray-600",children:a("tool.noParameters")}),e.jsxs("div",{className:"flex justify-end space-x-2 mt-4",children:[e.jsx("button",{type:"button",onClick:t,className:"hub-btn",children:a("tool.cancel")}),e.jsx("button",{onClick:()=>n({}),disabled:r,className:"hub-btn primary",children:a(r?"tool.running":"tool.runTool")})]})]})},Nt=({result:s,onClose:n})=>{const{t}=re(),r=s.content,b=d=>d?d.startsWith("image/")?d:`image/${d}`:"image/png",u=d=>{if(!d)return[];if(Array.isArray(d))return d.flatMap(p=>u(p));if(typeof d!="object")return[];const g=[];d.type==="image"&&d.data&&g.push({data:String(d.data),mimeType:b(d.mimeType||d.mime_type)});const o=d.image_base64||d.imageBase64||d.image_data||d.imageData||d.base64;return o&&g.push({data:String(o),mimeType:b(d.image_mimeType||d.image_mime_type||d.mimeType||d.mime_type)}),d.image&&typeof d.image=="object"&&g.push(...u(d.image)),Array.isArray(d.images)&&g.push(...u(d.images)),Array.isArray(d.content)&&g.push(...u(d.content)),g},a=d=>{const g=[];try{const _=JSON.parse(d);if(g.push(...u(_)),g.length>0)return g}catch{}const o=/data:image\/(png|jpe?g|gif|webp);base64,([A-Za-z0-9+/=]+)/g;let p;for(;(p=o.exec(d))!==null;){const _=`image/${p[1]==="jpg"?"jpeg":p[1]}`;g.push({data:p[2],mimeType:_})}return g},j=d=>{try{const g=JSON.parse(d),o=p=>{if(Array.isArray(p))return p.map(o);if(p&&typeof p=="object"){const _={};for(const[v,w]of Object.entries(p))typeof w=="string"&&v.toLowerCase().includes("base64")?_[v]="[base64 omitted]":_[v]=o(w);return _}return p};return JSON.stringify(o(g),null,2)}catch{return d.replace(/data:image\/(png|jpe?g|gif|webp);base64,[A-Za-z0-9+/=]+/g,"[image data omitted]")}},h=d=>Array.isArray(d)?d.map((g,o)=>e.jsx("div",{className:"mb-3 last:mb-0",children:E(g)},o)):E(d),E=d=>{if(typeof d=="string"){const g=a(d),o=j(d);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[g.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:g.map((p,_)=>e.jsx("img",{src:`data:${p.mimeType||"image/png"};base64,${p.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},_))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:o})]})}if(typeof d=="object"&&d!==null){if(d.type==="text"&&d.text){const g=a(d.text),o=j(d.text);return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[g.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:g.map((p,_)=>e.jsx("img",{src:`data:${p.mimeType||"image/png"};base64,${p.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"},_))}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:o})]})}if(d.type==="image"&&d.data)return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("img",{src:`data:${d.mimeType||"image/png"};base64,${d.data}`,alt:t("tool.toolResult"),className:"max-w-full h-auto rounded-md"})});try{const g=typeof d=="string"?JSON.parse(d):d;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("tool.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(g,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(d)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(hs,{size:20,className:"text-status-green"}):e.jsx(xs,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("tool.execution")," ",s.success?t("tool.successful"):t("tool.failed")]})})]}),e.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.content&&s.content.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.result")}),h(s.content)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("tool.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(Ce,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:t("tool.error")})]}),r&&r.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("tool.errorDetails")}),h(r)]}):e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-300 dark:border-red-700/60 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 dark:text-red-300 whitespace-pre-wrap",children:s.error||s.message||t("tool.unknownError")})})]})})]})},pe=({title:s,onClick:n,disabled:t=!1,loading:r=!1})=>e.jsx("button",{type:"button",className:"ml-2 p-1 text-amber-600 hover:text-amber-700 cursor-pointer transition-colors disabled:opacity-60 disabled:cursor-not-allowed",onClick:n,disabled:t,title:s,"aria-label":s,children:e.jsx(Hs,{size:14,className:r?"animate-spin":""})});function wt(s){return s==null?!0:typeof s=="string"?s.trim()==="":Array.isArray(s)?s.length===0:typeof s=="object"?Object.keys(s).length===0:!1}const kt=({tool:s,server:n,readOnly:t=!1,onToggle:r,onDescriptionUpdate:b,cost:u})=>{const{t:a}=re(),{showToast:j}=Ne(),{nameSeparator:h}=Ee(),[E,d]=c.useState(!1),[g,o]=c.useState(!1),[p,_]=c.useState(!1),[v,w]=c.useState(null),[D,A]=c.useState(!1),[O,I]=c.useState(!1),[M,L]=c.useState(s.description||""),z=c.useRef(null),U=c.useRef(null),[q,ee]=c.useState(0),[y,x]=c.useState(!1);c.useEffect(()=>{D&&z.current&&(z.current.focus(),q>0&&(z.current.style.width=`${q+20}px`))},[D,q]),c.useEffect(()=>{!D&&U.current&&ee(U.current.offsetWidth)},[D,M]),c.useEffect(()=>{L(s.description||"")},[s.description]);const C=s.name.replace(n+h,""),l=ct(s,a("tool.noDescription")),f=l.hasDescriptionOverride?a("tool.defaultDescriptionTooltip",{description:l.defaultDescription}):void 0,m=c.useCallback(()=>`mcphub_tool_form_${n?`${n}_`:""}${s.name}`,[s.name,n]),k=c.useCallback(()=>{localStorage.removeItem(m())},[m]),$=T=>{!t&&r&&r(s.name,T)},R=()=>{t||A(!0)},W=async()=>{if(!t)try{const T=await js(n,s.name,M);T.success?(A(!1),b&&b(s.name,M)):(L(s.description||""),console.error("Failed to update tool description:",T.error))}catch(T){console.error("Error updating tool description:",T),L(s.description||""),A(!1)}},Y=T=>{L(T.target.value)},G=async()=>{if(!t){I(!0);try{const T=await vs(n,s.name);if(T.success){const K=T.description||"";L(K),A(!1),b==null||b(s.name,K,{restored:!0})}else j(T.error||a("tool.restoreDefaultFailed"),"error")}catch(T){console.error("Error resetting tool description:",T),j(a("tool.restoreDefaultFailed"),"error")}finally{I(!1)}}},Q=T=>{T.key==="Enter"?W():T.key==="Escape"&&(L(s.description||""),A(!1))},N=async T=>{T.stopPropagation();try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s.name),x(!0),j(a("common.copySuccess"),"success"),setTimeout(()=>x(!1),2e3);else{const K=document.createElement("textarea");K.value=s.name,K.style.position="fixed",K.style.left="-9999px",document.body.appendChild(K),K.focus(),K.select();try{document.execCommand("copy"),x(!0),j(a("common.copySuccess"),"success"),setTimeout(()=>x(!1),2e3)}catch(J){j(a("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",J)}document.body.removeChild(K)}}catch(K){j(a("common.copyFailed"),"error"),console.error("Copy to clipboard failed:",K)}},B=async T=>{_(!0);try{T=Object.fromEntries(Object.entries(T).filter(([J,F])=>!wt(F)));const K=await ys({toolName:s.name,arguments:T},n);w(K)}catch(K){w({success:!1,error:K instanceof Error?K.message:"Unknown error occurred"})}finally{_(!1)}},te=()=>{o(!1),k(),w(null)},ne=()=>{w(null)};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:T=>{T.stopPropagation(),d(!E)},children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:C}),e.jsx("button",{className:"hub-icon-btn sm",onClick:N,title:a("common.copy"),children:y?e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}}):e.jsx(be,{size:12})}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:D?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:z,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:M,onChange:Y,onKeyDown:Q,onClick:T=>T.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:T=>{T.stopPropagation(),W()},disabled:O,children:e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(pe,{title:a("tool.restoreDefault"),onClick:T=>{T.stopPropagation(),G()},disabled:O,loading:O})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:U,title:f,children:l.currentDescription}),l.hasDescriptionOverride&&e.jsx("span",{className:"inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium",style:{color:"var(--hub-accent)",borderColor:"var(--hub-line)",background:"var(--hub-bg-2)"},title:f,children:a("tool.descriptionModifiedBadge")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:T=>{T.stopPropagation(),R()},children:e.jsx($e,{size:12})}),e.jsx(pe,{title:a("tool.restoreDefault"),onClick:T=>{T.stopPropagation(),G()},disabled:O,loading:O})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[u!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:a("cost.estimate"),children:["Σ ",ce(u)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:T=>T.stopPropagation(),children:e.jsx(Pe,{checked:s.enabled??!0,onCheckedChange:$,disabled:p||t,size:"card","aria-label":`${a(s.enabled??!0?"server.disable":"server.enable")} ${C}`})}),e.jsxs("button",{onClick:T=>{T.stopPropagation(),d(!0),o(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:p||!s.enabled,children:[p?e.jsx(bs,{size:12,className:"animate-spin"}):e.jsx(fs,{size:12}),e.jsx("span",{children:a(p?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:E?e.jsx(ke,{size:14}):e.jsx(Se,{size:14})})]})]}),E&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[l.hasDescriptionOverride&&l.defaultDescription&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px dashed var(--hub-line)",fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsx("span",{className:"hub-sect",style:{marginRight:6},children:a("tool.defaultDescriptionLabel")}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:l.defaultDescription})]}),!g&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px solid var(--hub-line)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:6},children:a("tool.inputSchema")}),e.jsx("pre",{className:"hub-mono overflow-auto",style:{fontSize:11.5,color:"var(--hub-ink-2)",margin:0},children:JSON.stringify(s.inputSchema,null,2)})]}),g&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(Ns,{schema:s.inputSchema||{type:"object"},onSubmit:B,onCancel:te,loading:p,storageKey:m(),title:a("tool.runToolWithName",{name:C})}),v&&e.jsx("div",{style:{marginTop:12},children:e.jsx(Nt,{result:v,onClose:ne})})]})]})]})},Ct=async(s,n)=>{try{const t=n?`/prompts/call/${n}`:"/prompts/call",r=await le(t,{promptName:s.promptName,arguments:s.arguments});return r.success?{success:!0,data:r.data}:{success:!1,error:r.message||"Prompt call failed"}}catch(t){return console.error("Error calling prompt",{promptName:s.promptName,server:n,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},ws=async(s,n)=>{try{const t=await le(`/mcp/${encodeURIComponent(n||"")}/prompts/${encodeURIComponent(s.promptName)}`,{name:s.promptName,arguments:s.arguments});if(!t.success)throw new Error(`Failed to get prompt: ${t.message||"Unknown error"}`);return{success:!0,data:t.data}}catch(t){return console.error("Error getting prompt",{promptName:s.promptName,server:n,error:t}),{success:!1,error:t instanceof Error?t.message:"Unknown error occurred"}}},St=async(s,n,t)=>{try{const r=await le(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(n)}/toggle`,{enabled:t});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error toggling prompt",{serverName:s,promptName:n,enabled:t,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},ks=async(s,n,t)=>{try{const r=await we(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(n)}/description`,{description:t},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message}}catch(r){return console.error("Error updating prompt description",{serverName:s,promptName:n,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Cs=async(s,n)=>{var t;try{const r=await Te(`/servers/${encodeURIComponent(s)}/prompts/${encodeURIComponent(n)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:r.success,error:r.success?void 0:r.message,description:(t=r.data)==null?void 0:t.description}}catch(r){return console.error("Error resetting prompt description",{serverName:s,promptName:n,error:r}),{success:!1,error:r instanceof Error?r.message:"Unknown error occurred"}}},Et=Object.freeze(Object.defineProperty({__proto__:null,callPrompt:Ct,getPrompt:ws,resetPromptDescription:Cs,togglePrompt:St,updatePromptDescription:ks},Symbol.toStringTag,{value:"Module"})),os=({result:s,onClose:n})=>{const{t}=re(),r=b=>{if(typeof b=="string")return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:b})});if(typeof b=="object"&&b!==null){if(b.description||b.messages)return e.jsxs("div",{className:"space-y-4",children:[b.description&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.description")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("p",{className:"text-sm text-gray-800",children:b.description})})]}),b.messages&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:t("prompt.messages")}),e.jsx("div",{className:"space-y-3",children:b.messages.map((u,a)=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"flex items-center mb-2",children:e.jsxs("span",{className:"inline-block w-16 text-xs font-medium text-gray-500",children:[u.role,":"]})}),typeof u.content=="string"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:u.content}):typeof u.content=="object"&&u.content.type==="text"?e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:u.content.text}):e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(u.content,null,2)})]},a))})]})]});try{const u=typeof b=="string"?JSON.parse(b):b;return e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:t("prompt.jsonResponse")}),e.jsx("pre",{className:"text-sm text-gray-800 overflow-auto",children:JSON.stringify(u,null,2)})]})}catch{return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(b)})})}}return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-800 font-mono",children:String(b)})})};return e.jsxs("div",{className:"border border-gray-300 rounded-lg bg-white dark:bg-gray-800 shadow-sm",children:[e.jsx("div",{className:"border-b border-gray-300 px-4 py-3 bg-gray-50 dark:bg-gray-800 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[s.success?e.jsx(hs,{size:20,className:"text-status-green"}):e.jsx(xs,{size:20,className:"text-status-red"}),e.jsx("div",{children:e.jsxs("h4",{className:"text-sm font-medium text-gray-900",children:[t("prompt.execution")," ",s.success?t("prompt.successful"):t("prompt.failed")]})})]}),e.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 text-sm",children:"✕"})]})}),e.jsx("div",{className:"p-4",children:s.success?e.jsx("div",{children:s.data?e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-600 mb-3",children:t("prompt.result")}),r(s.data)]}):e.jsx("div",{className:"text-sm text-gray-500 italic",children:t("prompt.noContent")})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(Ce,{size:16,className:"text-red-500"}),e.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:t("prompt.error")})]}),e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-300 dark:border-red-700/60 rounded-md p-3",children:e.jsx("pre",{className:"text-sm text-red-800 dark:text-red-300 whitespace-pre-wrap",children:s.error||s.message||t("prompt.unknownError")})})]})})]})},Pt=({prompt:s,server:n,readOnly:t=!1,onToggle:r,onDescriptionUpdate:b,cost:u})=>{const{t:a}=re(),{showToast:j}=Ne(),{nameSeparator:h}=Ee(),[E,d]=c.useState(!1),[g,o]=c.useState(!1),[p,_]=c.useState(!1),[v,w]=c.useState(null),[D,A]=c.useState(!1),[O,I]=c.useState(!1),[M,L]=c.useState(s.description||""),z=c.useRef(null),U=c.useRef(null),[q,ee]=c.useState(0);c.useEffect(()=>{D&&z.current&&(z.current.focus(),q>0&&(z.current.style.width=`${q+20}px`))},[D,q]),c.useEffect(()=>{!D&&U.current&&ee(U.current.offsetWidth)},[D,M]),c.useEffect(()=>{L(s.description||"")},[s.description]);const y=c.useCallback(()=>`mcphub_prompt_form_${n?`${n}_`:""}${s.name}`,[s.name,n]),x=c.useCallback(()=>{localStorage.removeItem(y())},[y]),C=N=>{!t&&r&&r(s.name,N)},l=()=>{t||A(!0)},f=async()=>{if(!t){A(!1);try{const N=await ks(n,s.name,M);N.success?b&&b(s.name,M):(j(N.error||a("prompt.descriptionUpdateFailed"),"error"),L(s.description||""))}catch(N){console.error("Error updating prompt description:",N),j(a("prompt.descriptionUpdateFailed"),"error"),L(s.description||"")}}},m=async()=>{if(!t){I(!0);try{const N=await Cs(n,s.name);if(N.success){const B=N.description||"";L(B),A(!1),b==null||b(s.name,B,{restored:!0})}else j(N.error||a("prompt.restoreDefaultFailed"),"error")}catch(N){console.error("Error resetting prompt description:",N),j(a("prompt.restoreDefaultFailed"),"error")}finally{I(!1)}}},k=N=>{L(N.target.value)},$=N=>{N.key==="Enter"?f():N.key==="Escape"&&(L(s.description||""),A(!1))},R=async N=>{_(!0);try{const B=await ws({promptName:s.name,arguments:N},n);console.log("GetPrompt result:",B),w({success:B.success,data:B.data,error:B.error})}catch(B){w({success:!1,error:B instanceof Error?B.message:"Unknown error occurred"})}finally{_(!1)}},W=()=>{o(!1),x(),w(null)},Y=()=>{w(null)},G=s.name.replace(n+h,""),Q=()=>{if(!s.arguments||s.arguments.length===0)return{type:"object",properties:{},required:[]};const N={},B=[];return s.arguments.forEach(te=>{N[te.name]={type:"string",description:te.description||""},te.required&&B.push(te.name)}),{type:"object",properties:N,required:B}};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>d(!E),children:[e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium",style:{fontSize:13,color:"var(--hub-ink)"},children:G}),s.title&&e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.title}),e.jsx("span",{className:"flex items-center gap-1",style:{fontSize:12,color:"var(--hub-ink-3)"},children:D?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:z,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:q>0?`${q+20}px`:160,minWidth:80},value:M,onChange:k,onKeyDown:$,onClick:N=>N.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:N=>{N.stopPropagation(),f()},disabled:O,children:e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(pe,{title:a("prompt.restoreDefault"),onClick:N=>{N.stopPropagation(),m()},disabled:O,loading:O})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:U,children:M||a("tool.noDescription")}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:N=>{N.stopPropagation(),l()},children:e.jsx($e,{size:12})}),e.jsx(pe,{title:a("prompt.restoreDefault"),onClick:N=>{N.stopPropagation(),m()},disabled:O,loading:O})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[u!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:a("cost.estimate"),children:["Σ ",ce(u)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:N=>N.stopPropagation(),children:s.enabled!==void 0&&e.jsx(Pe,{checked:s.enabled,onCheckedChange:C,disabled:p||t,size:"card","aria-label":`${a(s.enabled?"server.disable":"server.enable")} ${G}`})}),e.jsxs("button",{onClick:N=>{N.stopPropagation(),d(!0),o(!0)},className:"hub-btn sm",style:{color:"var(--hub-accent)"},disabled:p||!s.enabled,children:[p?e.jsx(bs,{size:12,className:"animate-spin"}):e.jsx(fs,{size:12}),e.jsx("span",{children:a(p?"tool.running":"tool.run")})]}),e.jsx("button",{className:"hub-icon-btn sm",children:E?e.jsx(ke,{size:14}):e.jsx(Se,{size:14})})]})]}),E&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:10},children:[g&&e.jsxs("div",{style:{border:"1px solid var(--hub-line)",borderRadius:8,padding:14},children:[e.jsx(Ns,{schema:Q(),onSubmit:R,onCancel:W,loading:p,storageKey:y(),title:a("prompt.runPromptWithName",{name:G})}),v&&e.jsx("div",{style:{marginTop:12},children:e.jsx(os,{result:v,onClose:Y})})]}),!g&&s.arguments&&s.arguments.length>0&&e.jsxs("div",{style:{background:"var(--hub-bg-2)",borderRadius:7,padding:"8px 12px",border:"1px solid var(--hub-line)"},children:[e.jsx("div",{className:"hub-sect",style:{marginBottom:6},children:a("tool.parameters")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.arguments.map((N,B)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"hub-mono",style:{fontSize:12.5,color:"var(--hub-ink)"},children:N.name}),N.required&&e.jsx("span",{style:{color:"var(--hub-err)",fontSize:12},children:"*"})]}),N.description&&e.jsx("p",{style:{fontSize:12,color:"var(--hub-ink-3)",margin:"2px 0 0"},children:N.description})]}),N.title&&e.jsx("span",{style:{fontSize:11,color:"var(--hub-ink-3)"},children:N.title})]},B))})]}),!g&&v&&e.jsx("div",{children:e.jsx(os,{result:v,onClose:Y})})]})]})},Dt=({resource:s,readOnly:n=!1,onToggle:t,onDescriptionUpdate:r,cost:b})=>{const{t:u}=re(),[a,j]=c.useState(!1),[h,E]=c.useState(!1),[d,g]=c.useState(!1),[o,p]=c.useState(s.description||""),_=c.useRef(null),v=c.useRef(null),[w,D]=c.useState(0);c.useEffect(()=>{h&&_.current&&(_.current.focus(),w>0&&(_.current.style.width=`${w+20}px`))},[h,w]),c.useEffect(()=>{!h&&v.current&&D(v.current.offsetWidth)},[h,o]),c.useEffect(()=>{p(s.description||"")},[s.description]);const A=s.name||s.uri,O=z=>{!n&&t&&t(s.uri,z)},I=async()=>{n||(E(!1),r&&await r(s.uri,o))},M=async()=>{if(!n){g(!0);try{await(r==null?void 0:r(s.uri,"",{restored:!0})),E(!1)}finally{g(!1)}}},L=z=>{z.key==="Enter"?I():z.key==="Escape"&&(p(s.description||""),E(!1))};return e.jsxs("div",{className:"hub-card overflow-hidden",style:{marginBottom:8},children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 px-3 py-2.5 cursor-pointer hover:bg-[var(--hub-surface-hover)] transition-colors",onClick:()=>j(!a),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"hub-mono font-medium truncate",style:{fontSize:13,color:"var(--hub-ink)"},children:A}),e.jsx("span",{className:"hub-mono truncate",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:s.uri})]}),e.jsx("span",{className:"flex items-center gap-1 mt-0.5",style:{fontSize:12,color:"var(--hub-ink-3)"},children:h?e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:_,type:"text",className:"hub-input",style:{height:26,fontSize:12,width:w>0?`${w+20}px`:160,minWidth:80},value:o,onChange:z=>p(z.target.value),onKeyDown:L,onClick:z=>z.stopPropagation()}),e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),I()},disabled:d,children:e.jsx(fe,{size:12,style:{color:"var(--hub-ok)"}})}),e.jsx(pe,{title:u("builtinResources.restoreDefault"),onClick:z=>{z.stopPropagation(),M()},disabled:d,loading:d})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:v,children:o||u("tool.noDescription")}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"hub-icon-btn sm",onClick:z=>{z.stopPropagation(),E(!0)},children:e.jsx($e,{size:12})}),e.jsx(pe,{title:u("builtinResources.restoreDefault"),onClick:z=>{z.stopPropagation(),M()},disabled:d,loading:d})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[b!=null&&e.jsxs("span",{className:"hub-mono flex-shrink-0",style:{fontSize:11,color:"var(--hub-ink-3)"},title:u("cost.estimate"),children:["Σ ",ce(b)]}),e.jsx("div",{className:"flex h-[26px] items-center",onClick:z=>z.stopPropagation(),children:e.jsx(Pe,{checked:s.enabled!==!1,onCheckedChange:O,disabled:n,size:"card","aria-label":`${u(s.enabled!==!1?"server.disable":"server.enable")} ${A}`})}),e.jsx("button",{className:"hub-icon-btn sm",children:a?e.jsx(ke,{size:14}):e.jsx(Se,{size:14})})]})]}),a&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",padding:"8px 12px"},children:[e.jsxs("span",{className:"hub-sect",children:[u("builtinResources.mimeType"),":"]})," ",e.jsx("span",{style:{fontSize:12,color:"var(--hub-ink-2)"},children:s.mimeType||"text/plain"})]})]})},zt={private:{shortKey:"server.visibilityPrivateShort",shortFallback:"Private",longKey:"server.visibilityPrivate",longFallback:"Private — only the owner and admins",className:"bg-[var(--hub-bg-2)] text-[var(--hub-ink-2)] border-[var(--hub-line-2)]"},group:{shortKey:"server.visibilityGroupShort",shortFallback:"Shared",longKey:"server.visibilityGroup",longFallback:"Shared — selected users only",className:"bg-[oklch(0.97_0.02_85)] text-[oklch(0.45_0.07_85)] border-[oklch(0.88_0.04_85)]"},public:{shortKey:"server.visibilityPublicShort",shortFallback:"Public",longKey:"server.visibilityPublic",longFallback:"Public — every authenticated user",className:"bg-[oklch(0.97_0.03_145)] text-[oklch(0.42_0.12_145)] border-[oklch(0.88_0.04_145)]"}},Ie=s=>s==="public"||s==="group"?s:"private",Tt=(s,n)=>{const t=Ie(n),r=zt[t];return{value:t,shortLabel:s(r.shortKey,{defaultValue:r.shortFallback}),longLabel:s(r.longKey,{defaultValue:r.longFallback}),className:r.className}},$t=(s,n)=>{const t=Ie(n),r=[{value:"private",label:s("server.visibilityPrivateShort",{defaultValue:"Private"}),disabled:!1}];return t==="group"&&r.push({value:"group",label:s("server.visibilityGroupShort",{defaultValue:"Shared"}),disabled:!0}),r.push({value:"public",label:s("server.visibilityPublicShort",{defaultValue:"Public"}),disabled:!1}),r},is=({isLoading:s,children:n,className:t,overlayStyle:r,spinnerSize:b=12})=>e.jsxs("div",{className:t?`relative flex items-center ${t}`:"relative flex items-center","aria-busy":s,children:[e.jsx("div",{className:"flex w-full items-center justify-center",style:{visibility:s?"hidden":"visible",pointerEvents:s?"none":"auto"},children:n}),s&&e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",style:{background:"var(--hub-surface)",border:"1px solid var(--hub-line-2)",borderRadius:8,...r},children:e.jsx(me,{size:b,className:"animate-spin",style:{color:"var(--hub-ink-3)"}})})]}),ls=({icon:s})=>e.jsx("span",{className:"hub-server-capability-icon","aria-hidden":"true",children:e.jsx(s,{size:11.5,strokeWidth:1.9,className:"block"})}),cs=(s,n)=>n?n==="stdio"?s("server.typeStdio")||"stdio":n==="sse"?s("server.typeSse")||"sse":n==="streamable-http"?s("server.typeStreamableHttp")||"http":n==="openapi"?s("server.typeOpenapi")||"openapi":n:null,It="text/html;profile=mcp-app",ds=s=>s?!!(s.ui||s["ui/resourceUri"]):!1,Rt=s=>{var n,t;return!!((n=s.tools)!=null&&n.some(r=>ds(r._meta))||(t=s.resources)!=null&&t.some(r=>{var b;return((b=r.uri)==null?void 0:b.startsWith("ui://"))||r.mimeType===It||ds(r._meta)}))},Ft=({server:s,cost:n,onRemove:t,onEdit:r,onDuplicate:b,isDuplicating:u=!1,onToggle:a,onVisibilityChange:j,onRefresh:h,onReload:E,onReinstall:d,onOAuthDisconnect:g})=>{var Me,Ue,Ve,Be,Je,Le,We,qe,Ke,He,Ge,Xe,Ye,Ze,Qe,es,ss,ts,rs,ns;const{t:o}=re(),{showToast:p}=Ne(),{exportMCPSettings:_,installConfig:v}=Ee(),{auth:w}=Ws(),D=((Me=v==null?void 0:v.baseUrl)==null?void 0:Me.replace(/\/+$/,""))||"",[A,O]=c.useState(!1),[I,M]=c.useState(null),[L,z]=c.useState(!1),[U,q]=c.useState(!1),[ee,y]=c.useState(!1),[x,C]=c.useState(null),[l,f]=c.useState(!1),[m,k]=c.useState(!1),[$,R]=c.useState(!1),[W,Y]=c.useState(!1),[G,Q]=c.useState(!1),[N,B]=c.useState(!1),[te,ne]=c.useState(!1),[T,K]=c.useState(!1),J=c.useRef(null),F=c.useRef(null);c.useEffect(()=>{const i=P=>{J.current&&!J.current.contains(P.target)&&B(!1),F.current&&!F.current.contains(P.target)&&ne(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const H=((Ue=s.tools)==null?void 0:Ue.length)||0,ae=((Ve=s.tools)==null?void 0:Ve.filter(i=>i.enabled!==!1).length)||0,ge=((Be=s.prompts)==null?void 0:Be.length)||0,ye=((Je=s.prompts)==null?void 0:Je.filter(i=>i.enabled!==!1).length)||0,je=((Le=s.resources)==null?void 0:Le.length)||0,Z=((We=s.resources)==null?void 0:We.filter(i=>i.enabled!==!1).length)||0,oe=Rt(s),ie=s.enabled!==!1,X=pt(s,w.user),he=((qe=s.config)==null?void 0:qe.command)==="npx"||((Ke=s.config)==null?void 0:Ke.command)==="uvx",xe=!!(((Ge=(He=s.config)==null?void 0:He.oauth)==null?void 0:Ge.identityMode)!=="personal"&&((Xe=s.oauth)!=null&&Xe.connected)&&g),Ss=async i=>{if(!(!X||l||!a)){f(!0);try{await a(s,i)}finally{f(!1)}}},Es=async i=>{if(i.stopPropagation(),B(!1),!(!X||$||!E)){R(!0);try{await E(s)?p(o("server.reloadSuccess")||"Server reloaded successfully","success"):p(o("server.reloadError",{serverName:s.name})||"Failed to reload","error")}finally{R(!1)}}},Ps=async()=>{if(B(!1),!(!X||W||!d)){Y(!0);try{await d(s)?p(o("server.reinstallSuccess")||"Server reinstall initiated","success"):p(o("server.reinstallError",{serverName:s.name})||"Failed to reinstall","error")}finally{Y(!1)}}},Ds=async()=>{if(B(!1),!(!X||G||!g)){Q(!0);try{await g(s)?p(o("server.disconnectOAuthSuccess")||"Server OAuth disconnected","success"):p(o("server.disconnectOAuthError",{serverName:s.name})||"Failed to disconnect OAuth","error")}finally{Q(!1)}}},zs=async i=>{var S;if(i.stopPropagation(),!X||m||!j)return;const P=i.target.value;if(P!==Ie(s.visibility??((S=s.config)==null?void 0:S.visibility))){k(!0);try{await j(s,P)}finally{k(!1)}}},Ts=async i=>{if(i.stopPropagation(),!s.error)return;await as(s.error)?(K(!0),p(o("common.copySuccess")||"Copied","success"),setTimeout(()=>K(!1),1500)):p(o("common.copyFailed")||"Copy failed","error")},$s=async i=>{var P,S;if(i.stopPropagation(),B(!1),!!X)try{const V=await _(s.name),se=(S=(P=V==null?void 0:V.data)==null?void 0:P.mcpServers)==null?void 0:S[s.name];if(!V||!V.success||!se){p((V==null?void 0:V.message)||o("common.copyFailed")||"Copy failed","error");return}C(ut(s.name,se))}catch(V){console.error("Error copying server configuration:",V),p(o("common.copyFailed")||"Copy failed","error")}},Is=i=>{var P;if(i.stopPropagation(),(P=s.oauth)!=null&&P.authorizationUrl){const se=window.screen.width/2-300,de=window.screen.height/2-700/2;window.open(s.oauth.authorizationUrl,"OAuth Authorization",`width=600,height=700,left=${se},top=${de}`),p(o("status.oauthWindowOpened"),"info"),s.oauth.clientIdConfigured&&p(o("status.oauthClientIdHint"),"warning")}},Rs=async(i,P)=>{try{const{toggleTool:S}=await ve(async()=>{const{toggleTool:se}=await Promise.resolve().then(()=>vt);return{toggleTool:se}},void 0,import.meta.url),V=await S(s.name,i,P);V.success?(p(o(P?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),h==null||h()):p(V.error||o("tool.toggleFailed"),"error")}catch(S){console.error(S),p(o("tool.toggleFailed"),"error")}},Fs=async(i,P)=>{try{const{togglePrompt:S}=await ve(async()=>{const{togglePrompt:se}=await Promise.resolve().then(()=>Et);return{togglePrompt:se}},void 0,import.meta.url),V=await S(s.name,i,P);V.success?(p(o(P?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),h==null||h()):p(V.error||o("tool.toggleFailed"),"error")}catch(S){console.error(S),p(o("tool.toggleFailed"),"error")}},Os=async(i,P)=>{try{const{toggleResource:S}=await ve(async()=>{const{toggleResource:se}=await import("./resourceService-DRZl8_Vm.js");return{toggleResource:se}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),V=await S(s.name,i,P);V.success?(p(o(P?"tool.enableSuccess":"tool.disableSuccess",{name:i}),"success"),h==null||h()):p(V.error||o("tool.toggleFailed"),"error")}catch(S){console.error(S),p(o("tool.toggleFailed"),"error")}},_s=(i,P,S)=>{p(S!=null&&S.restored?o("tool.restoreDefaultSuccess"):o("tool.descriptionUpdateSuccess"),"success"),h==null||h()},As=(i,P,S)=>{p(S!=null&&S.restored?o("prompt.restoreDefaultSuccess"):o("prompt.descriptionUpdateSuccess"),"success"),h==null||h()},Ms=async(i,P,S)=>{try{const{updateResourceDescription:V,resetResourceDescription:se}=await ve(async()=>{const{updateResourceDescription:Vs,resetResourceDescription:Bs}=await import("./resourceService-DRZl8_Vm.js");return{updateResourceDescription:Vs,resetResourceDescription:Bs}},__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),de=S!=null&&S.restored?await se(s.name,i):await V(s.name,i,P);de.success?(p(S!=null&&S.restored?o("builtinResources.restoreDefaultSuccess"):o("builtinResources.descriptionUpdateSuccess"),"success"),h==null||h()):p(de.error||(S!=null&&S.restored?o("builtinResources.restoreDefaultFailed"):o("builtinResources.descriptionUpdateFailed")),"error")}catch(V){console.error(V),p(S!=null&&S.restored?o("builtinResources.restoreDefaultFailed"):o("builtinResources.descriptionUpdateFailed"),"error")}};(()=>{var S;const i=s.config;if(!i)return"";if(i.url)return i.url;const P=[];return i.command&&P.push(i.command),(S=i.args)!=null&&S.length&&P.push(...i.args),P.join(" ")})();const Re=`${D}/mcp/${s.name}`,Fe=`${D}/api/${s.name}`,Oe=async i=>{const P=await as(i);p(P?o("common.copySuccess")||"Copied":o("common.copyFailed")||"Failed",P?"success":"error")},_e=(i,P)=>o(i,P),ue=Tt(_e,s.visibility??((Ye=s.config)==null?void 0:Ye.visibility)),Us=$t(_e,ue.value),Ae=[{key:"tools",icon:Gs,total:H,enabled:ae,label:o("server.tools")},{key:"prompts",icon:Xs,total:ge,enabled:ye,label:o("server.prompts")},{key:"resources",icon:Ys,total:je,enabled:Z,label:o("nav.resources")}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hub-card overflow-visible",style:{marginBottom:10},children:[e.jsxs("div",{className:"hub-server-card-row cursor-pointer px-4 py-3 transition-colors hover:bg-[var(--hub-surface-hover)]",onClick:()=>O(!A),children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(Se,{size:12,style:{color:"var(--hub-ink-3)",transform:A?"rotate(90deg)":"none",transition:"transform 0.15s",flexShrink:0}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"hub-mono truncate",style:{fontSize:13.5,color:ie?"var(--hub-ink)":"var(--hub-ink-3)"},children:s.name}),he&&s.packageVersion&&e.jsxs("span",{className:"hub-tag flex-shrink-0",title:o("server.packageVersion"),style:{fontSize:11},children:["v",s.packageVersion]}),he&&s.updateAvailable&&s.latestVersion&&e.jsxs("span",{className:"hub-tag flex-shrink-0",title:o("server.updateAvailable"),style:{fontSize:11,color:"var(--hub-warn)"},children:["↑ ",s.latestVersion]}),oe&&e.jsx("span",{className:"hub-tag accent flex-shrink-0",title:o("server.mcpApp"),children:"App"}),s.error&&e.jsxs("div",{className:"relative",ref:F,children:[e.jsx("button",{onClick:i=>{i.stopPropagation(),ne(P=>!P)},className:"text-[var(--hub-err)] hover:opacity-80","aria-label":o("server.viewErrorDetails"),children:e.jsx(Ce,{size:14})}),te&&e.jsxs("div",{className:"absolute z-20 mt-1.5 hub-card",style:{left:0,top:"100%",width:460,maxHeight:320,overflow:"hidden",boxShadow:"0 8px 24px rgba(0,0,0,0.08)"},onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid var(--hub-line-2)"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--hub-err)"},children:o("server.errorDetails")}),e.jsx("button",{onClick:Ts,className:"hub-icon-btn sm",title:o("common.copy"),children:T?e.jsx(fe,{size:12,className:"text-[var(--hub-ok)]"}):e.jsx(be,{size:12})})]}),e.jsx("button",{onClick:()=>ne(!1),className:"hub-icon-btn sm","aria-label":o("app.closeButton"),children:e.jsx(De,{size:12})})]}),e.jsx("div",{className:"p-3 overflow-auto hub-mono",style:{maxHeight:260,fontSize:12},children:e.jsx("pre",{className:"whitespace-pre-wrap break-words m-0",style:{color:"var(--hub-ink-2)"},children:s.error})})]})]})]}),!!((Qe=(Ze=s.config)==null?void 0:Ze.credentialTemplate)!=null&&Qe.length)&&e.jsxs(Js,{className:"hub-tag text-xs",to:`/credentials?server=${encodeURIComponent(s.name)}`,onClick:i=>i.stopPropagation(),children:[o("credentials.personalBadge")," · ",o("credentials.manage")]}),((es=s.config)==null?void 0:es.description)&&e.jsx("div",{className:"text-[11.5px] truncate",style:{color:"var(--hub-ink-3)",marginTop:1},title:s.config.description,children:s.config.description})]})]}),e.jsx("div",{className:"hub-server-card-status-cell min-w-0",children:((ts=(ss=s.config)==null?void 0:ss.oauth)==null?void 0:ts.identityMode)==="personal"?e.jsx(yt,{serverName:s.name,enabled:ie}):e.jsx(lt,{status:s.status,enabled:s.enabled,startOnDemand:((rs=s.config)==null?void 0:rs.startOnDemand)===!0,onAuthClick:Is,className:"hub-server-card-status"})}),e.jsx("div",{className:"hub-server-card-transport-cell min-w-0",children:(ns=s.config)!=null&&ns.type?e.jsx("span",{className:"hub-tag hub-server-card-transport-tag",title:cs(o,s.config.type)??void 0,children:cs(o,s.config.type)}):e.jsx("span",{style:{color:"var(--hub-ink-3)",fontSize:12},children:"—"})}),e.jsx("div",{className:"hub-server-card-visibility min-w-0",onClick:i=>i.stopPropagation(),children:X&&j?e.jsx(is,{isLoading:m,className:"w-full",overlayStyle:{borderRadius:6},children:e.jsx("select",{value:ue.value,onChange:zs,disabled:m,className:"hub-server-card-select w-full rounded-md border px-2 py-1 text-[11.5px] bg-[var(--hub-surface)] text-[var(--hub-ink)]",style:{borderColor:"var(--hub-line-2)"},"aria-label":o("server.visibility","Visibility"),title:ue.longLabel,children:Us.map(i=>e.jsx("option",{value:i.value,disabled:i.disabled,children:i.label},i.value))})}):e.jsx("span",{className:`hub-server-card-visibility-badge inline-flex items-center rounded-md border px-2 py-0.5 text-[11.5px] ${ue.className}`,title:ue.longLabel,children:ue.shortLabel})}),Ae.map(({key:i,icon:P,total:S,enabled:V,label:se})=>{const de=S===0;return e.jsxs("span",{className:`hub-server-capability-stat hub-mono hub-num ${de?"is-empty":""}`,title:`${se}: ${V}/${S}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:e.jsx(ls,{icon:P})}),e.jsx("span",{className:"hub-server-capability-value",children:de?"0":`${V}/${S}`})]},i)}),n&&n.connected?e.jsxs("span",{className:"hub-server-capability-stat hub-mono hub-num",title:`${o("cost.exposed")} ${n.exposed} / ${o("cost.gross")} ${n.gross} · ${o("cost.estimate")}`,children:[e.jsx("span",{className:"text-[var(--hub-ink-3)]",children:"Σ"}),e.jsxs("span",{className:"hub-server-capability-value",children:[ce(n.exposed),"/",ce(n.gross)]})]}):n?e.jsx("span",{className:"hub-server-capability-stat hub-mono is-empty",title:o("cost.notConnected"),children:e.jsx("span",{className:"hub-server-capability-value",children:"—"})}):null,e.jsx("div",{className:"flex items-center justify-center",onClick:i=>i.stopPropagation(),children:e.jsx(is,{isLoading:l,className:"h-[18px] w-[30px]",overlayStyle:{borderRadius:999,background:"var(--hub-bg-2)"},spinnerSize:10,children:e.jsx(Pe,{checked:ie,onCheckedChange:Ss,disabled:l||!X,size:"compact","aria-label":`${o(ie?"server.disable":"server.enable")} ${s.name}`})})}),e.jsxs("div",{className:"relative",ref:J,children:[X&&e.jsx("button",{className:"hub-icon-btn",onClick:i=>{i.stopPropagation(),B(P=>!P)},"aria-label":"More","aria-busy":u,children:u?e.jsx(me,{size:14,className:"animate-spin"}):e.jsx(Zs,{size:14})}),X&&N&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 hub-card",style:{minWidth:160,padding:4},onClick:i=>i.stopPropagation(),children:[e.jsxs("button",{onClick:i=>{i.stopPropagation(),B(!1),r(s)},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",style:{color:"var(--hub-ink)"},children:[e.jsx(Qs,{size:13})," ",o("server.edit")]}),b&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),B(!1),!u&&b(s)},disabled:u,"aria-busy":u,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 disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[u?e.jsx(me,{size:13,className:"animate-spin"}):e.jsx(et,{size:13})," ",o("server.duplicate")]}),e.jsxs("button",{onClick:$s,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",style:{color:"var(--hub-ink)"},children:[e.jsx(be,{size:13})," ",o("server.copy")]}),E&&e.jsxs("button",{onClick:Es,disabled:$||l||!ie,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 disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[e.jsx(me,{size:13})," ",o("server.reload")]}),d&&he&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),B(!1),!(!X||W||!ie)&&q(!0)},disabled:W||l||!ie,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 disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[e.jsx(st,{size:13})," ",o("server.reinstall")]}),xe&&e.jsxs("button",{onClick:i=>{i.stopPropagation(),B(!1),!(!X||G)&&y(!0)},disabled:G,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 disabled:opacity-50 disabled:cursor-not-allowed",style:{color:"var(--hub-ink)"},children:[e.jsx(tt,{size:13})," ",o("server.disconnectOAuth")]}),e.jsx("div",{style:{height:1,background:"var(--hub-line-2)",margin:"4px 0"}}),e.jsxs("button",{onClick:i=>{i.stopPropagation(),B(!1),z(!0)},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",style:{color:"var(--hub-err)"},children:[e.jsx(rt,{size:13})," ",o("server.delete")]})]})]})]}),A&&e.jsxs("div",{style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)",padding:"14px 16px 16px 38px"},children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 flex-wrap",children:[Ae.map(i=>{const P=I===i.key,S=i.icon;return e.jsxs("button",{onClick:()=>M(P?null:i.key),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] transition-colors hover:bg-[var(--hub-surface-hover)]",style:{background:P?"var(--hub-surface)":"transparent",border:"1px solid "+(P?"var(--hub-line)":"transparent"),color:P?"var(--hub-ink)":"var(--hub-ink-2)"},children:[e.jsx(ls,{icon:S}),e.jsx("span",{children:i.label}),e.jsx("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:i.total===0?"0":`${i.enabled}/${i.total}`})]},i.key)}),n&&n.connected&&e.jsxs("button",{onClick:()=>M(I==="cost"?null:"cost"),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] transition-colors hover:bg-[var(--hub-surface-hover)]",style:{background:I==="cost"?"var(--hub-surface)":"transparent",border:"1px solid "+(I==="cost"?"var(--hub-line)":"transparent"),color:I==="cost"?"var(--hub-ink)":"var(--hub-ink-2)"},title:o("cost.estimate"),children:[e.jsx("span",{style:{color:"var(--hub-ink-3)"},children:"Σ"}),e.jsx("span",{children:o("cost.totalFootprint")}),e.jsxs("span",{className:"hub-mono hub-num",style:{color:"var(--hub-ink-3)",fontSize:11},children:[ce(n.exposed),"/",ce(n.gross)]})]}),e.jsxs("div",{className:"ml-auto max-w-full flex-shrink-0 flex items-center justify-end gap-1.5 flex-wrap",children:[e.jsxs("div",{className:"hub-endpoint",style:{height:26},children:[e.jsx("div",{className:"hub-endpoint-label",children:"/mcp/"}),e.jsx("div",{className:"hub-endpoint-url",title:Re,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:i=>{i.stopPropagation(),Oe(Re)},title:o("common.copyUrl"),children:e.jsx(be,{size:12})})]}),e.jsxs("div",{className:"hub-endpoint",style:{height:26},children:[e.jsx("div",{className:"hub-endpoint-label",children:"/api/"}),e.jsx("div",{className:"hub-endpoint-url",title:Fe,style:{maxWidth:200},children:s.name}),e.jsx("button",{type:"button",className:"hub-endpoint-copy",onClick:i=>{i.stopPropagation(),Oe(Fe)},title:o("common.copyOpenApiUrl"),children:e.jsx(be,{size:12})})]})]})]}),I==="cost"&&(n==null?void 0:n.connected)&&e.jsx("div",{className:"mt-2 space-y-1",children:[...n.items].sort((i,P)=>P.cost-i.cost).map(i=>e.jsxs("div",{className:"flex items-center justify-between hub-mono",style:{fontSize:11.5,color:i.enabled?"var(--hub-ink-2)":"var(--hub-ink-3)"},children:[e.jsx("span",{className:"truncate",children:i.name}),e.jsx("span",{className:"hub-num flex-shrink-0",children:ce(i.cost)})]},`${i.kind}:${i.name}`))}),I==="tools"&&s.tools&&e.jsx("div",{className:"space-y-3 mt-2",children:s.tools.map((i,P)=>{var S;return e.jsx(kt,{server:s.name,tool:i,readOnly:!X,onToggle:Rs,onDescriptionUpdate:_s,cost:(S=n==null?void 0:n.items.find(V=>V.kind==="tool"&&V.name===i.name))==null?void 0:S.cost},P)})}),I==="prompts"&&s.prompts&&e.jsx("div",{className:"space-y-3 mt-2",children:s.prompts.map((i,P)=>{var S;return e.jsx(Pt,{server:s.name,prompt:i,readOnly:!X,onToggle:Fs,onDescriptionUpdate:As,cost:(S=n==null?void 0:n.items.find(V=>V.kind==="prompt"&&V.name===i.name))==null?void 0:S.cost},P)})}),I==="resources"&&s.resources&&e.jsx("div",{className:"mt-2",children:s.resources.length===0?e.jsx("div",{className:"text-sm",style:{color:"var(--hub-ink-3)"},children:o("builtinResources.noResources")}):e.jsx("div",{className:"space-y-3",children:s.resources.map((i,P)=>{var S;return e.jsx(Dt,{resource:i,readOnly:!X,onToggle:Os,onDescriptionUpdate:Ms,cost:(S=n==null?void 0:n.items.find(V=>V.kind==="resource"&&V.name===i.uri))==null?void 0:S.cost},`${i.uri}-${P}`)})})})]})]}),e.jsx(dt,{isOpen:x!==null,target:x,onClose:()=>C(null)}),e.jsx(mt,{isOpen:L,onClose:()=>z(!1),onConfirm:()=>{t(s.name),z(!1)},serverName:s.name}),e.jsx(ze,{isOpen:U,onClose:()=>q(!1),onConfirm:()=>{q(!1),Ps()},title:o("server.reinstall"),message:o("server.reinstallConfirm")||"This will clear the package cache and re-download dependencies. The server will restart.",confirmText:o("server.reinstall"),variant:"warning"}),e.jsx(ze,{isOpen:ee,onClose:()=>y(!1),onConfirm:()=>{y(!1),Ds()},title:o("server.disconnectOAuth"),message:o("server.disconnectOAuthConfirm")||"This will revoke stored OAuth credentials where supported and require authorization again.",confirmText:o("server.disconnectOAuth"),variant:"warning"})]})},us="-copy",Ot=s=>{const n=Math.max(ht-us.length,0);return`${s.slice(0,n)}${us}`},_t=s=>{const{oauth:n,...t}=s.config??{},{accessToken:r,refreshToken:b,pendingAuthorization:u,...a}=n??{};return{name:Ot(s.name),status:"disconnected",config:{...t,...Object.keys(a).length>0?{oauth:a}:{}}}},At=(s,n)=>{if(s)return Object.fromEntries(Object.entries(s).map(([t,r])=>[n(t),r]))},Mt=(s,n,t={})=>{const r=n.config;if(!r)return s;const b=t.nameSeparator||"-",u=new Set((n.tools??[]).map(g=>g.name)),a=g=>`${s.name}${g.slice(n.name.length)}`,j=`${n.name}${b}`,h=r.tools?Object.fromEntries(Object.entries(r.tools).flatMap(([g,o])=>u.has(g)?[[a(g),o]]:g.startsWith(j)&&u.has(`${j}${g}`)?[[g,o]]:g.startsWith(j)?[]:[[g,o]])):void 0,E=At(r.prompts,g=>g.startsWith(j)?a(g):g),d={};return h&&Object.keys(h).length>0&&(d.tools=h),E&&Object.keys(E).length>0&&(d.prompts=E),r.resources&&Object.keys(r.resources).length>0&&(d.resources=r.resources),{...s,config:{...s.config,...d}}},ms=(s,n)=>s===n?"commit":"stale",Ut=({onAdd:s,duplicateSource:n=null,onDuplicateCancel:t})=>{const{t:r}=re(),{nameSeparator:b}=Ee(),[u,a]=c.useState(!1),[j,h]=c.useState(null),[E,d]=c.useState(!1),[g,o]=c.useState(null),[p,_]=c.useState([]),v=c.useMemo(()=>n?_t(n):null,[n]),w=u||n!==null,D=()=>{h(null),d(!1),o(null)},A=()=>{a(!1),D(),n&&(t==null||t())},O=()=>{if(w){A();return}a(!0),D()},I=async()=>{g&&(await M(g),d(!1),o(null))},M=async z=>{try{h(null);const U=await le("/servers",z);if(!U.success){U&&U.message?h(U.message):h(r("server.addError"));return}A(),s()}catch(U){console.error("Error adding server:",U),navigator.onLine?U instanceof TypeError&&(U.message.includes("NetworkError")||U.message.includes("Failed to fetch"))?h(r("errors.serverConnection")):h(r("errors.serverAdd")):h(r("errors.network"))}},L=async z=>{try{const U=n?Mt(z,n,{nameSeparator:b}):z,q=xt(U);q.length>0?(_(q),o(U),d(!0)):await M(U)}catch(U){console.error("Error processing server submission:",U),h(r("errors.serverAdd"))}};return e.jsxs("div",{children:[e.jsxs("button",{onClick:O,className:"hub-btn primary",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),r("server.add")]}),w&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(gs,{onSubmit:L,onCancel:A,initialData:v,mode:"create",shareCandidatesFrom:n==null?void 0:n.name,modalTitle:n?r("server.duplicateTitle",{serverName:n.name}):r("server.addServer"),formError:j},(n==null?void 0:n.name)??"add")}),E&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card p-6 w-full max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:r("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:r("server.variablesDetected")}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-700/60 rounded p-3 mb-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-300",children:[r("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700 dark:text-yellow-300",children:p.map((z,U)=>e.jsxs("li",{className:"font-mono",children:["$",`{${z}}`]},U))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:r("server.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{d(!1),o(null)},className:"hub-btn",children:r("common.cancel")}),e.jsx("button",{onClick:I,className:"hub-btn primary",children:r("server.confirmAndAdd")})]})]})})]})},Vt=({server:s,onEdit:n,onCancel:t})=>{const{t:r}=re(),[b,u]=c.useState(null),a=async j=>{try{u(null);const h=encodeURIComponent(s.name),E=j.name&&j.name!==s.name,d={config:j.config,...E?{newName:j.name}:{}},g=await we(`/servers/${h}`,d);if(!g.success){g&&g.message?u(g.message):u(r("server.updateError",{serverName:s.name}));return}n()}catch(h){console.error("Error updating server:",h),navigator.onLine?h instanceof TypeError&&(h.message.includes("NetworkError")||h.message.includes("Failed to fetch"))?u(r("errors.serverConnection")):u(r("errors.serverUpdate",{serverName:s.name})):u(r("errors.network"))}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(gs,{onSubmit:a,onCancel:t,initialData:s,modalTitle:r("server.editTitle",{serverName:s.name}),formError:b},s.name)})},Bt=({onSuccess:s,onCancel:n})=>{const{t}=re(),[r,b]=c.useState(!1),[u,a]=c.useState(!1),[j,h]=c.useState(null),[E,d]=c.useState(null),[g,o]=c.useState(!1),[p,_]=c.useState(null),[v,w]=c.useState(""),[D,A]=c.useState(!1),[O,I]=c.useState(""),M=l=>{l.preventDefault(),b(!0)},L=l=>{l.preventDefault(),b(!1)},z=l=>{l.preventDefault(),b(!1);const f=l.dataTransfer.files;if(f.length>0){const m=f[0];m.name.endsWith(".mcpb")?(d(m),h(null)):h(t("mcpb.invalidFileType"))}},U=l=>{const f=l.target.files;if(f&&f.length>0){const m=f[0];m.name.endsWith(".mcpb")?(d(m),h(null)):h(t("mcpb.invalidFileType"))}},q=async()=>{if(!E){h(t("mcpb.noFileSelected"));return}a(!0),h(null);try{const l=new FormData;l.append("mcpbFile",E);const f=await qs(Ks("/mcpb/upload"),{method:"POST",body:l}),m=await f.json();if(!f.ok)throw new Error(m.message||`HTTP error! Status: ${f.status}`);if(m.success&&m.data)_(m.data.manifest),w(m.data.extractDir),o(!0);else throw new Error(m.message||t("mcpb.uploadFailed"))}catch(l){console.error("MCPB upload error:",l),h(l instanceof Error?l.message:t("mcpb.uploadFailed"))}finally{a(!1)}},ee=async(l,f=!1)=>{var m;a(!0),h(null);try{const k=C(p,v,l);if(!f){const R=await ps("/servers");if(R.success&&((m=R.data)==null?void 0:m.find(Y=>Y.name===l))){I(l),A(!0),a(!1);return}}let $;if(f?$=await we(`/servers/${encodeURIComponent(l)}`,{name:l,config:k}):$=await le("/servers",{name:l,config:k}),$.success)s(k);else throw new Error($.message||t("mcpb.installFailed"))}catch(k){console.error("MCPB install error:",k),h(k instanceof Error?k.message:t("mcpb.installFailed")),a(!1)}},y=()=>{A(!1),O&&ee(O,!0)},x=()=>{A(!1),I(""),a(!1)},C=(l,f,m)=>{var R;const k=((R=l.server)==null?void 0:R.mcp_config)||{},$={type:"stdio",command:k.command||"node",args:(k.args||[]).map(W=>W.replace("${__dirname}",f))};return k.env&&Object.keys(k.env).length>0&&($.env={...k.env},Object.keys($.env).forEach(W=>{typeof $.env[W]=="string"&&($.env[W]=$.env[W].replace("${__dirname}",f))})),$};return g&&p?e.jsxs(e.Fragment,{children:[e.jsx(ze,{isOpen:D,onClose:x,onConfirm:y,title:t("mcpb.serverExistsTitle"),message:t("mcpb.serverExistsConfirm",{serverName:O}),confirmText:t("mcpb.override"),cancelText:t("common.cancel"),variant:"warning"}),e.jsx("div",{className:`fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 ${D?"opacity-50 pointer-events-none":""}`,children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6 w-full max-w-3xl max-h-screen 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:t("mcpb.installServer")}),e.jsx("button",{onClick:n,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-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-2",children:t("mcpb.extensionInfo")}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.name"),":"]})," ",p.display_name||p.name]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.version"),":"]})," ",p.version]}),e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.description"),":"]})," ",p.description]}),p.author&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.author"),":"]})," ",p.author.name]}),p.tools&&p.tools.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("mcpb.tools"),":"]}),e.jsx("ul",{className:"list-disc list-inside ml-4",children:p.tools.map((l,f)=>e.jsxs("li",{children:[l.name," - ",l.description]},f))})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:t("mcpb.serverName")}),e.jsx("input",{type:"text",id:"serverName",defaultValue:p.name,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 form-input",placeholder:t("mcpb.serverNamePlaceholder")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:n,disabled:u,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:()=>{const l=document.getElementById("serverName"),f=(l==null?void 0:l.value.trim())||p.name;ee(f)},disabled:u,className:"hub-btn primary",children:u?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"})]}),t("mcpb.installing")]}):t("mcpb.install")})]})]})]})})]}):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-lg",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:t("mcpb.uploadTitle")}),e.jsx("button",{onClick:n,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:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${r?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":E?"border-gray-500 ":"border-gray-300 hover:border-gray-400"}`,onDragOver:M,onDragLeave:L,onDrop:z,children:[E?e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-green-200",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-sm text-gray-900 font-medium",children:E.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(E.size/1024/1024).toFixed(2)," MB"]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-900",children:t("mcpb.dropFileHere")}),e.jsx("p",{className:"text-xs text-gray-500",children:t("mcpb.orClickToSelect")})]})]}),e.jsx("input",{type:"file",accept:".mcpb",onChange:U,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e.jsxs("div",{className:"mt-6 flex justify-end space-x-4",children:[e.jsx("button",{onClick:n,disabled:u,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:q,disabled:!E||u,className:"hub-btn primary flex items-center",children:u?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"})]}),t("mcpb.uploading")]}):t("mcpb.upload")})]})]})})},Jt=["sse","streamable-http"],Lt=new Set(["type","url","command","args","env","headers","options","openapi","oauth","enabled","visibility","keepAliveInterval","enableKeepAlive","perSessionClient","tools","prompts","passthroughHeaders","proxy"]),Wt=s=>{const n=[],t=[];for(const[r,b]of Object.entries(s.mcpServers)){const u=b??{},a={},j=Object.keys(u).filter(h=>!Lt.has(h));if(j.length>0){t.push({name:r,message:`unknown field(s) "${j.join('", "')}" — not part of the mcphub server schema. For OAuth, use an "oauth" object (e.g. {"scopes":["email"]}).`});continue}if(u.type==="sse"||u.type==="streamable-http"){if(a.type=u.type,a.url=u.url,u.headers&&(a.headers=u.headers),u.oauth&&(a.oauth=u.oauth),!u.url){t.push({name:r,message:`"${u.type}" servers require a "url" field.`});continue}}else if(u.type==="openapi")a.type="openapi",a.openapi=u.openapi;else if(u.type===void 0||u.type==="stdio"){if(u.url&&!u.command){t.push({name:r,message:`has a "url" but type "${u.type??"stdio"}". Use "streamable-http" or "sse" for remote servers.`});continue}if(a.type="stdio",a.command=u.command,a.args=u.args||[],u.env&&(a.env=u.env),u.options&&(a.options=u.options),!u.command){t.push({name:r,message:'stdio servers require a "command" field.'});continue}}else{const h=Jt.includes(String(u.type))?"":' Did you mean "streamable-http"? Supported types: stdio, sse, streamable-http, openapi.';t.push({name:r,message:`unsupported type "${u.type}".${h}`});continue}n.push({name:r,config:a})}return{servers:n,issues:t}},qt=({onSuccess:s,onCancel:n})=>{const{t}=re(),[r,b]=c.useState(""),[u,a]=c.useState(null),[j,h]=c.useState(!1),[E,d]=c.useState(null),g=`{
7
- "mcpServers": {
8
- "stdio-server-example": {
9
- "command": "npx",
10
- "args": ["-y", "mcp-server-example"]
11
- },
12
- "sse-server-example": {
13
- "type": "sse",
14
- "url": "http://localhost:3000"
15
- },
16
- "http-server-example": {
17
- "type": "streamable-http",
18
- "url": "http://localhost:3001",
19
- "headers": {
20
- "Content-Type": "application/json",
21
- "Authorization": "Bearer your-token"
22
- }
23
- },
24
- "openapi-server-example": {
25
- "type": "openapi",
26
- "openapi": {
27
- "url": "https://petstore.swagger.io/v2/swagger.json"
28
- }
29
- }
30
- }
31
- }
32
-
33
- Supports: STDIO, SSE, HTTP (streamable-http), OpenAPI
34
- All servers will be imported in a single efficient batch operation.`,o=v=>{try{const w=JSON.parse(v.trim());return!w.mcpServers||typeof w.mcpServers!="object"?(a(t("jsonImport.invalidFormat")),null):w}catch{return a(t("jsonImport.parseError")),null}},p=()=>{a(null);const v=o(r);if(!v)return;const{servers:w,issues:D}=Wt(v);if(D.length>0){const A=D.map(O=>`${O.name}: ${O.message}`).join(`
35
- `);if(a(t("jsonImport.validationErrors")+`
36
- `+A),w.length===0)return}d(w)},_=async()=>{if(E){h(!0),a(null);try{const v=await le("/servers/batch",{servers:E});if(v.success&&v.data){const{successCount:w,failureCount:D,results:A}=v.data;if(D>0){const O=A.filter(I=>!I.success).map(I=>`${I.name}: ${I.message||t("jsonImport.addFailed")}`);a(t("jsonImport.partialSuccess",{count:w,total:E.length})+`
37
- `+O.join(`
38
- `))}w>0&&s()}else a(v.message||t("jsonImport.importFailed"))}catch(v){console.error("Import error:",v),a(t("jsonImport.importFailed"))}finally{h(!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:t("jsonImport.title")}),e.jsx("button",{onClick:n,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),u&&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:u})}),E?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:t("jsonImport.previewTitle")}),e.jsx("div",{className:"space-y-3",children:E.map((v,w)=>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:v.name}),e.jsxs("div",{className:"mt-2 space-y-1 text-sm text-gray-600",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.type"),":"]})," ",v.config.type||"stdio"]}),v.config.command&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.command"),":"]})," ",v.config.command]}),v.config.args&&v.config.args.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.arguments"),":"]})," ",v.config.args.join(" ")]}),v.config.url&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.url"),":"]})," ",v.config.url]}),v.config.env&&Object.keys(v.config.env).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.envVars"),":"]})," ",Object.keys(v.config.env).join(", ")]}),v.config.headers&&Object.keys(v.config.headers).length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t("server.headers"),":"]})," ",Object.keys(v.config.headers).join(", ")]})]})]})})},w))})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:()=>d(null),disabled:j,className:"hub-btn",children:t("common.back")}),e.jsx("button",{onClick:_,disabled:j,className:"hub-btn primary",children:j?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"})]}),t("jsonImport.importing")]}):t("jsonImport.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:t("jsonImport.inputLabel")}),e.jsx("textarea",{value:r,onChange:v=>b(v.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:g}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:t("jsonImport.inputHelp")})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx("button",{onClick:n,className:"hub-btn",children:t("common.cancel")}),e.jsx("button",{onClick:p,disabled:!r.trim(),className:"hub-btn primary",children:t("jsonImport.preview")})]})]})]})})},Kt=s=>({all:s.length,online:s.filter(n=>n.status==="connected").length,issues:s.filter(n=>n.status!=="connected"&&n.enabled!==!1).length,disabled:s.filter(n=>n.enabled===!1).length}),Ht=(s,n,t="")=>{const r=t.trim().toLowerCase();return s.filter(b=>{var a,j;return n==="online"&&b.status!=="connected"||n==="issues"&&(b.status==="connected"||b.enabled===!1)||n==="disabled"&&b.enabled!==!1?!1:r?(b.name+" "+(((a=b.config)==null?void 0:a.description)||"")+" "+(((j=b.tools)==null?void 0:j.map(h=>h.name).join(" "))||"")).toLowerCase().includes(r):!0})},Gt=(s,n,t,r,b)=>{const u=Ht(s,n,t),a=u.length,j=Math.max(1,Math.ceil(a/b)),h=Math.min(Math.max(1,r),j),E=(h-1)*b;return{servers:u.slice(E,E+b),pagination:{page:h,limit:b,total:a,totalPages:j,hasNextPage:h<j,hasPrevPage:h>1}}},dr=()=>{const{t:s}=re(),n=Ls(),{servers:t,allServers:r,error:b,setError:u,isLoading:a,currentPage:j,serversPerPage:h,setCurrentPage:E,setServersPerPage:d,handleServerAdd:g,handleServerEdit:o,handleServerRemove:p,handleServerToggle:_,handleServerVisibilityChange:v,handleServerReload:w,handleServerReinstall:D,handleServerOAuthDisconnect:A,triggerRefresh:O}=ft({refreshOnMount:!0}),{serverCosts:I,refetch:M}=gt();c.useEffect(()=>{M()},[t,M]);const[L,z]=c.useState(null),[U,q]=c.useState(null),[ee,y]=c.useState(null),[x,C]=c.useState(!1),[l,f]=c.useState(!1),[m,k]=c.useState(!1),[$,R]=c.useState("all"),[W,Y]=c.useState(""),G=c.useMemo(()=>Kt(r),[r]),{servers:Q,pagination:N}=c.useMemo(()=>Gt(r,$,W,j,h),[r,$,W,j,h]);c.useEffect(()=>{N.page!==j&&E(N.page)},[N.page,j,E]);const B=c.useRef(0),te=async J=>{const F=++B.current,H=await o(J);F===B.current&&H&&z(H)},ne=c.useRef(0),T=async J=>{if(ee===J.name)return;const F=++ne.current;y(J.name);try{const H=await o(J);if(ms(F,ne.current)==="stale")return;H&&q(H)}finally{ms(F,ne.current)==="commit"&&y(null)}},K=async()=>{C(!0);try{O(),await new Promise(J=>setTimeout(J,400))}finally{C(!1)}};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:s("pages.servers.title")}),e.jsxs("p",{className:"hub-sub",children:[e.jsx("span",{className:"hub-num",children:G.all})," ",s("nav.servers").toLowerCase()," ·"," ",e.jsx("span",{className:"hub-num",children:G.online})," ",s("status.online")," ·"," ",e.jsx("span",{className:"hub-num",children:G.issues})," ",s("common.inactive")||"issues"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"hub-btn",onClick:()=>n("/market"),children:[e.jsx(nt,{size:13})," ",s("nav.market")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>k(!0),children:[e.jsx(at,{size:13})," ",s("jsonImport.button")]}),e.jsxs("button",{className:"hub-btn",onClick:()=>f(!0),children:[e.jsx(ot,{size:13})," ",s("mcpb.upload")]}),e.jsxs("button",{className:"hub-btn",onClick:K,disabled:x,"aria-label":s("common.refresh"),children:[e.jsx(me,{size:13,className:x?"animate-spin":""}),s("common.refresh")]}),e.jsx(Ut,{onAdd:g,duplicateSource:U,onDuplicateCancel:()=>q(null)})]})]}),b&&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(Ce,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:b})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>u(null),"aria-label":s("app.closeButton"),children:e.jsx(De,{size:13})})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4 flex-wrap",children:[e.jsx("div",{className:"hub-card flex items-center",style:{padding:2,borderRadius:7,background:"var(--hub-surface)"},children:[["all",s("common.all")||"All",G.all],["online",s("status.online"),G.online],["issues",s("common.inactive")||"Issues",G.issues],["disabled",s("pages.dashboard.disabledServers")||"Disabled",G.disabled]].map(([J,F,H])=>e.jsxs("button",{onClick:()=>R(J),className:"inline-flex items-center gap-1.5 px-3 text-[12px]",style:{height:24,borderRadius:5,background:$===J?"var(--hub-bg-2)":"transparent",color:$===J?"var(--hub-ink)":"var(--hub-ink-3)",border:"1px solid "+($===J?"var(--hub-line)":"transparent")},children:[F,e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:H})]},J))}),e.jsxs("div",{className:"hub-card flex items-center gap-2 px-2.5 flex-1",style:{height:30,background:"var(--hub-surface)",maxWidth:360},children:[e.jsx(it,{size:13,style:{color:"var(--hub-ink-3)"}}),e.jsx("input",{value:W,onChange:J=>Y(J.target.value),className:"flex-1 bg-transparent outline-none text-[13px]",style:{color:"var(--hub-ink)"},placeholder:s("market.searchPlaceholder")||"Search…"}),W&&e.jsx("button",{onClick:()=>Y(""),className:"hub-icon-btn sm",children:e.jsx(De,{size:11})})]}),e.jsxs("div",{className:"ml-auto hub-mono text-[12px]",style:{color:"var(--hub-ink-3)"},children:[N.total,"/",r.length]})]}),a&&t.length===0?e.jsx("div",{className:"hub-card p-6 flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(me,{size:20,className:"animate-spin",style:{color:"var(--hub-ink-3)"}}),e.jsx("p",{style:{color:"var(--hub-ink-3)"},children:s("app.loading")})]})}):Q.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:e.jsx("p",{children:t.length===0?s("app.noServers"):s("market.noServers")})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:Q.map(J=>e.jsx(Ft,{server:J,cost:I.find(F=>F.name===J.name),onRemove:p,onEdit:te,onDuplicate:T,isDuplicating:ee===J.name,onToggle:_,onVisibilityChange:v,onRefresh:O,onReload:w,onReinstall:D,onOAuthDisconnect:A},J.name))}),e.jsxs("div",{className:"flex items-center mt-4 text-[12px]",style:{color:"var(--hub-ink-3)"},children:[e.jsx("div",{className:"flex-[2]",children:s("common.showing",{start:(N.page-1)*N.limit+1,end:Math.min(N.page*N.limit,N.total),total:N.total})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:N.totalPages>1&&e.jsx(bt,{currentPage:N.page,totalPages:N.totalPages,onPageChange:E,disabled:a})}),e.jsxs("div",{className:"flex-[2] flex items-center justify-end gap-2",children:[e.jsxs("label",{htmlFor:"perPage",children:[s("common.itemsPerPage"),":"]}),e.jsxs("select",{id:"perPage",value:h,onChange:J=>d(Number(J.target.value)),disabled:a,className:"hub-input",style:{height:26,width:70,padding:"0 6px",fontSize:12},children:[e.jsx("option",{value:5,children:"5"}),e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"})]})]})]})]}),L&&e.jsx(Vt,{server:L,onEdit:()=>{z(null),O()},onCancel:()=>z(null)}),l&&e.jsx(Bt,{onSuccess:()=>{f(!1),O()},onCancel:()=>f(!1)}),m&&e.jsx(qt,{onSuccess:()=>{k(!1),O()},onCancel:()=>k(!1)})]})};export{dr as default};
39
- //# sourceMappingURL=ServersPage-DYumMhzV.js.map