decocms 2.285.1 → 2.286.0

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 (381) hide show
  1. package/dist/client/assets/{AlertCircle-Ljx3VIeb.js → AlertCircle-DTmaHldD.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-B8YVT66M.js → ArrowNarrowLeft-DlPeFc4v.js} +1 -1
  3. package/dist/client/assets/{CheckCircle-BFRWTTWo.js → CheckCircle-DJ3lme5R.js} +1 -1
  4. package/dist/client/assets/{ChevronDown-BqFspEzt.js → ChevronDown-DGnjAtqs.js} +1 -1
  5. package/dist/client/assets/{ChevronRight-DCsBjQ-n.js → ChevronRight-DV9No7GF.js} +1 -1
  6. package/dist/client/assets/{ChevronUp-D7S3j_fa.js → ChevronUp-BkSgkwhO.js} +1 -1
  7. package/dist/client/assets/{Container-SHbLkl7K.js → Container-B1nHZdmn.js} +1 -1
  8. package/dist/client/assets/DotsVertical-Bp2tW8JI.js +1 -0
  9. package/dist/client/assets/{LinkExternal01-XmkIm96u.js → LinkExternal01-BBbCPDtX.js} +1 -1
  10. package/dist/client/assets/{Lock01-CXrm99F-.js → Lock01-DpPIS3K7.js} +1 -1
  11. package/dist/client/assets/{Palette-B46VjX8F.js → Palette-CI8n49a8.js} +1 -1
  12. package/dist/client/assets/{Play-9pX5w5-3.js → Play-DKFUTU3G.js} +1 -1
  13. package/dist/client/assets/{Plus-Bmk1thjl.js → Plus-oXFwCrYz.js} +1 -1
  14. package/dist/client/assets/RefreshCcw01-B10mKiE2.js +1 -0
  15. package/dist/client/assets/SearchMd-BRJBvWf4.js +1 -0
  16. package/dist/client/assets/{Settings02-C88OtRRq.js → Settings02-Dm9dFDqk.js} +1 -1
  17. package/dist/client/assets/Shield01-BZJVBd5S.js +1 -0
  18. package/dist/client/assets/{Star01-fuGmPeeu.js → Star01-_IJK5Yjt.js} +1 -1
  19. package/dist/client/assets/{Sun-ndN_CHuQ.js → Sun-QqE1VnS_.js} +1 -1
  20. package/dist/client/assets/{Tool01-DBxgF1Y_.js → Tool01-CKowkGsd.js} +1 -1
  21. package/dist/client/assets/{Trash01-BHBjIGXE.js → Trash01-C6bAXG6g.js} +1 -1
  22. package/dist/client/assets/{User01-DCiwOMBU.js → User01-C2-anwoO.js} +1 -1
  23. package/dist/client/assets/{Users03-Bgfd1KM0.js → Users03-DqYvPeZM.js} +1 -1
  24. package/dist/client/assets/{X-BWV-b86T.js → X-i9zBn6Hn.js} +1 -1
  25. package/dist/client/assets/XCircle-C1sJYG9R.js +1 -0
  26. package/dist/client/assets/XClose-BbIo6xHe.js +1 -0
  27. package/dist/client/assets/{Zap-K9sQXDlC.js → Zap-KmbRMccM.js} +1 -1
  28. package/dist/client/assets/{ZapSquare-CTcr_tRy.js → ZapSquare-DT93lGV4.js} +1 -1
  29. package/dist/client/assets/{accordion-COmeMo5z.js → accordion-BV3tm7bj.js} +1 -1
  30. package/dist/client/assets/agent-icon-CyE6nkC1.js +1 -0
  31. package/dist/client/assets/agents-list-7o6gZt-q.js +1 -0
  32. package/dist/client/assets/ai-providers-DI3UF9nU.js +1 -0
  33. package/dist/client/assets/{alert-dialog-DaP8t8su.js → alert-dialog-CicrCOay.js} +2 -2
  34. package/dist/client/assets/{auth-catchall-CerK6T4u.js → auth-catchall-Cyd7fWQv.js} +1 -1
  35. package/dist/client/assets/automation-list-row-B4Vfg4UC.js +1 -0
  36. package/dist/client/assets/automations-DRM_lJom.js +1 -0
  37. package/dist/client/assets/{avatar-gTIcZioB.js → avatar-CF1bgUpD.js} +1 -1
  38. package/dist/client/assets/{badge-DsWPcX1V.js → badge-s_TAXGUN.js} +1 -1
  39. package/dist/client/assets/{brand-context-CnnwTWNT.js → brand-context-iopLFZ2k.js} +1 -1
  40. package/dist/client/assets/{card-CPVRwbgl.js → card-CaekC2K0.js} +1 -1
  41. package/dist/client/assets/{chat-context-CZAEwDWp.js → chat-context-DP5UfIrn.js} +1 -1
  42. package/dist/client/assets/{checkbox-CPqdqI54.js → checkbox-DznLgPgR.js} +1 -1
  43. package/dist/client/assets/collection-detail-CTQuhG7N.js +1 -0
  44. package/dist/client/assets/collection-display-button-BgYKhoGQ.js +1 -0
  45. package/dist/client/assets/{collection-search-DgokupF2.js → collection-search-Bo2bOvRn.js} +1 -1
  46. package/dist/client/assets/{collection-search-lfil19IA.js → collection-search-DMqppne6.js} +1 -1
  47. package/dist/client/assets/collection-table-wrapper-KnWZIddd.js +1 -0
  48. package/dist/client/assets/{collection-tabs-BRY4wHvH.js → collection-tabs-CU6MCzSn.js} +1 -1
  49. package/dist/client/assets/{collections-lJhN2k9k.js → collections-DHmXATua.js} +1 -1
  50. package/dist/client/assets/command-D4w2xkZT.js +1 -0
  51. package/dist/client/assets/{connection-card-BrctpSfE.js → connection-card-DBz-rrLk.js} +1 -1
  52. package/dist/client/assets/connection-detail-zHqb5ZSw.js +1 -0
  53. package/dist/client/assets/{connection-form-helpers-C1FnnBdL.js → connection-form-helpers-CBEV0IXi.js} +1 -1
  54. package/dist/client/assets/connections-CHiGbl1F.js +1 -0
  55. package/dist/client/assets/{constants-D8VkIs2c.js → constants-DDHDU3PV.js} +1 -1
  56. package/dist/client/assets/{constants-D_Nupw5-.js → constants-v4RUVkEN.js} +1 -1
  57. package/dist/client/assets/{dialog-BOagZAx2.js → dialog-C4lREl-t.js} +1 -1
  58. package/dist/client/assets/{drawer-BRUzFEdi.js → drawer-BTCEaGGQ.js} +1 -1
  59. package/dist/client/assets/dropdown-menu-v2GifVOh.js +1 -0
  60. package/dist/client/assets/{dynamic-plugin-layout-ltkevohS.js → dynamic-plugin-layout-CVBBnlEt.js} +1 -1
  61. package/dist/client/assets/{empty-state-BokLRSGE.js → empty-state-BdQTFnZA.js} +1 -1
  62. package/dist/client/assets/{empty-state-DCK4Z2GX.js → empty-state-DdKZ_is7.js} +1 -1
  63. package/dist/client/assets/{extract-connection-data-V-eInhlP.js → extract-connection-data-CfXvFcGA.js} +1 -1
  64. package/dist/client/assets/{features-DIBFVG_b.js → features-fsR9zLkr.js} +1 -1
  65. package/dist/client/assets/{form-DHQjt1Tk.js → form-D7DN8UcB.js} +1 -1
  66. package/dist/client/assets/general-WQbdllPl.js +1 -0
  67. package/dist/client/assets/{github-repo-picker-CIYxcUMn.js → github-repo-picker-DZqLC6FL.js} +2 -2
  68. package/dist/client/assets/index-BCwsJqWc.css +1 -0
  69. package/dist/client/assets/{index-sYNl3b-7.js → index-C5AR7k1c.js} +1 -1
  70. package/dist/client/assets/{index-DWOvEgKr.js → index-CHKi_s_a.js} +1 -1
  71. package/dist/client/assets/{index-DvxSs9Po.js → index-D-RCnwJQ.js} +1 -1
  72. package/dist/client/assets/{index-CNolBSVE.js → index-D34n6J5J.js} +22 -22
  73. package/dist/client/assets/{index-DbNFtLRR.js → index-DBclwIf_.js} +3 -3
  74. package/dist/client/assets/{index-Di0ylaLI.js → index-DnJZfbsP.js} +3 -3
  75. package/dist/client/assets/{index-uSGXbgq4.js → index-FnxI6OGR.js} +1 -1
  76. package/dist/client/assets/{index-BWvVdWtP.js → index-e3AFJ_dX.js} +1 -1
  77. package/dist/client/assets/{index-gfedyrlZ.js → index-qXZ0t4XR.js} +16 -16
  78. package/dist/client/assets/{index-PT6VRyBL.js → index-zDq2Zqio.js} +1 -1
  79. package/dist/client/assets/{infiniteQueryObserver-B8q-YDXm.js → infiniteQueryObserver-1_M-sq16.js} +1 -1
  80. package/dist/client/assets/{input-B8j75XZ_.js → input-urtyHxks.js} +1 -1
  81. package/dist/client/assets/{integration-icon-De50Mm7k.js → integration-icon-Cdkk9YPE.js} +1 -1
  82. package/dist/client/assets/{label-KH35YAYU.js → label-Bt4h_QUk.js} +1 -1
  83. package/dist/client/assets/{layout-E2py7rYQ.js → layout-B5SDe6IW.js} +1 -1
  84. package/dist/client/assets/{login-agOBj-o2.js → login-7zFMf3C1.js} +1 -1
  85. package/dist/client/assets/members-Dy7hWkQ8.js +3 -0
  86. package/dist/client/assets/{monaco-editor-CzAT2DWn.js → monaco-editor-lveN-AoO.js} +1 -1
  87. package/dist/client/assets/{monitoring-stats-row-k0blCMgl.js → monitoring-stats-row-D3x0_phM.js} +1 -1
  88. package/dist/client/assets/{oauth-callback-ViEW-3g2.js → oauth-callback-BJALVgfT.js} +1 -1
  89. package/dist/client/assets/{oauth-callback-ai-provider-cSZy9hW7.js → oauth-callback-ai-provider-o8Hfz-wL.js} +1 -1
  90. package/dist/client/assets/{onboarding-CquRdW5q.js → onboarding-DlI3PsIA.js} +1 -1
  91. package/dist/client/assets/{org-layout-DY9vqUg9.js → org-layout-DPzm8vzJ.js} +1 -1
  92. package/dist/client/assets/{org-plugin-layout-HyePbhDN.js → org-plugin-layout-DB72TzxO.js} +1 -1
  93. package/dist/client/assets/{plugin-empty-state-tSKwN8yW.js → plugin-empty-state-BzyxU1IF.js} +1 -1
  94. package/dist/client/assets/{plugin-header-CgMEgROC.js → plugin-header-hJH6-4Nr.js} +1 -1
  95. package/dist/client/assets/{plugin-layout-B0f9qTk_.js → plugin-layout-l_MDXBYc.js} +1 -1
  96. package/dist/client/assets/{popover-BK6PL-XB.js → popover-j_PzMtdY.js} +1 -1
  97. package/dist/client/assets/{profile-C_xBhvj7.js → profile-lf_QL3Ye.js} +1 -1
  98. package/dist/client/assets/project-app-view-DuFzKNXE.js +1 -0
  99. package/dist/client/assets/registry-D3m_WKwq.js +2 -0
  100. package/dist/client/assets/{registry-layout-7nSgT8Ua.js → registry-layout-DRb_iR_v.js} +3 -3
  101. package/dist/client/assets/{required-auth-layout-D-NWWr5P.js → required-auth-layout-C2o7AZ4K.js} +1 -1
  102. package/dist/client/assets/{reset-password-C7m0cAdE.js → reset-password-DTEY3I_i.js} +1 -1
  103. package/dist/client/assets/roles-DW1_Kn6r.js +1 -0
  104. package/dist/client/assets/{scroll-area-Da2hNrch.js → scroll-area-BebfgLv6.js} +1 -1
  105. package/dist/client/assets/{search-input-BZmdDW7A.js → search-input-dmuYGYsk.js} +1 -1
  106. package/dist/client/assets/{select-JPYD20it.js → select-CePxsPeP.js} +1 -1
  107. package/dist/client/assets/{select-model-DMVU-2Gx.js → select-model-QQ7yjZl9.js} +2 -2
  108. package/dist/client/assets/settings-layout-Cd1tdTnr.js +1 -0
  109. package/dist/client/assets/{shell-layout-DkN8Q_tp.js → shell-layout-BE22YA40.js} +1 -1
  110. package/dist/client/assets/{skeleton-DPqifXUx.js → skeleton-C9NsUzIb.js} +1 -1
  111. package/dist/client/assets/{sso-BdiVJFM8.js → sso-QSGlyP2n.js} +1 -1
  112. package/dist/client/assets/{store-D9lb1Gph.js → store-BB9yi6PD.js} +1 -1
  113. package/dist/client/assets/store-registry-BSp-W72J.js +2 -0
  114. package/dist/client/assets/{switch-CVtXvreH.js → switch-VBeL01bM.js} +1 -1
  115. package/dist/client/assets/{table-C-JSrHQJ.js → table-CQMW-Toa.js} +1 -1
  116. package/dist/client/assets/{tabs-DtgWLQ6i.js → tabs-DOoLL5wa.js} +1 -1
  117. package/dist/client/assets/{task-status-DTuLfGhm.js → task-status-vvRP86lz.js} +7 -7
  118. package/dist/client/assets/{textarea-p_oNKH-r.js → textarea-Ie4QUdo5.js} +1 -1
  119. package/dist/client/assets/{toggle-group-B6-etMEh.js → toggle-group-C077Smww.js} +1 -1
  120. package/dist/client/assets/tools-list-UnPsMGhr.js +1 -0
  121. package/dist/client/assets/{types-BP7V6N8z.js → types-D4PfKOFF.js} +1 -1
  122. package/dist/client/assets/{use-ai-providers-oN1cKhaJ.js → use-ai-providers-DHuVj1kn.js} +1 -1
  123. package/dist/client/assets/{use-collections-BTXUmiDi.js → use-collections-DRlHpXQL.js} +1 -1
  124. package/dist/client/assets/{use-connection-DIvNoxL5.js → use-connection-Cif-LY0f.js} +1 -1
  125. package/dist/client/assets/{use-copy-D8L6lrfC.js → use-copy-uiSuMvtc.js} +1 -1
  126. package/dist/client/assets/{use-create-virtual-mcp-DUKkySGS.js → use-create-virtual-mcp-CBpw3zXA.js} +1 -1
  127. package/dist/client/assets/{use-decopilot-events-BRc3SX00.js → use-decopilot-events-Dpt6CcIN.js} +1 -1
  128. package/dist/client/assets/{use-delete-connection-IDpzSpRp.js → use-delete-connection-BZmW9ZAz.js} +1 -1
  129. package/dist/client/assets/{use-infinite-scroll-WKRKMI2J.js → use-infinite-scroll-CWlV3gJA.js} +1 -1
  130. package/dist/client/assets/{use-list-state-Dyh2zhb9.js → use-list-state-BJZWeXjY.js} +1 -1
  131. package/dist/client/assets/{use-mcp-tools-tZ37UBLL.js → use-mcp-tools-BYVtg7WH.js} +1 -1
  132. package/dist/client/assets/{use-members-AvAHjkiq.js → use-members-M_p47epa.js} +1 -1
  133. package/dist/client/assets/{use-mobile-Ctb5URy7.js → use-mobile-CxvYCzu9.js} +1 -1
  134. package/dist/client/assets/{use-navigate-to-agent-CLfSU3ru.js → use-navigate-to-agent-CFIKBq0L.js} +1 -1
  135. package/dist/client/assets/{use-org-sso-CmuM4ieo.js → use-org-sso-CACnH9GQ.js} +1 -1
  136. package/dist/client/assets/use-organization-roles-o4lVU0iD.js +1 -0
  137. package/dist/client/assets/{use-organization-settings-dQpmtQzl.js → use-organization-settings-BD9CIHH5.js} +1 -1
  138. package/dist/client/assets/{use-registry-connections-CP0QI7iA.js → use-registry-connections-DR_etJ2H.js} +1 -1
  139. package/dist/client/assets/{use-status-sounds-CObwI0DY.js → use-status-sounds-Ce7WandB.js} +1 -1
  140. package/dist/client/assets/{use-tasks-7rX1bsHL.js → use-tasks-Dpp1DK1f.js} +1 -1
  141. package/dist/client/assets/{use-view-mode-BkbloGkm.js → use-view-mode-CZPzVaxj.js} +1 -1
  142. package/dist/client/assets/{use-virtual-mcp-CDOk_IIy.js → use-virtual-mcp-0vHwLInn.js} +1 -1
  143. package/dist/client/assets/useInfiniteQuery-B4w-6TrV.js +1 -0
  144. package/dist/client/assets/useSuspenseInfiniteQuery-WURyRq6p.js +1 -0
  145. package/dist/client/assets/{user-lj8QRtGG.js → user-xj80BAo3.js} +1 -1
  146. package/dist/client/assets/{view-mode-toggle-BiPtlB_S.js → view-mode-toggle-D5CGwPOj.js} +1 -1
  147. package/dist/client/assets/workflow-CD_DiE5j.js +1 -0
  148. package/dist/client/assets/workflow-detail-CxWEb-ID.js +1 -0
  149. package/dist/client/index.html +2 -2
  150. package/dist/server/cli.js +2 -2
  151. package/dist/server/node_modules/figures/index.d.ts +279 -0
  152. package/dist/server/node_modules/figures/index.js +292 -0
  153. package/dist/server/node_modules/figures/license +9 -0
  154. package/dist/server/node_modules/figures/package.json +49 -0
  155. package/dist/server/node_modules/figures/readme.md +337 -0
  156. package/dist/server/node_modules/ink/build/ansi-tokenizer.d.ts +38 -0
  157. package/dist/server/node_modules/ink/build/ansi-tokenizer.js +316 -0
  158. package/dist/server/node_modules/ink/build/ansi-tokenizer.js.map +1 -0
  159. package/dist/server/node_modules/ink/build/apply-styles.js +175 -0
  160. package/dist/server/node_modules/ink/build/build-layout.js +77 -0
  161. package/dist/server/node_modules/ink/build/calculate-wrapped-text.js +53 -0
  162. package/dist/server/node_modules/ink/build/colorize.d.ts +3 -0
  163. package/dist/server/node_modules/ink/build/colorize.js +48 -0
  164. package/dist/server/node_modules/ink/build/colorize.js.map +1 -0
  165. package/dist/server/node_modules/ink/build/components/AccessibilityContext.d.ts +3 -0
  166. package/dist/server/node_modules/ink/build/components/AccessibilityContext.js +5 -0
  167. package/dist/server/node_modules/ink/build/components/AccessibilityContext.js.map +1 -0
  168. package/dist/server/node_modules/ink/build/components/App.d.ts +18 -0
  169. package/dist/server/node_modules/ink/build/components/App.js +351 -0
  170. package/dist/server/node_modules/ink/build/components/App.js.map +1 -0
  171. package/dist/server/node_modules/ink/build/components/AppContext.d.ts +15 -0
  172. package/dist/server/node_modules/ink/build/components/AppContext.js +11 -0
  173. package/dist/server/node_modules/ink/build/components/AppContext.js.map +1 -0
  174. package/dist/server/node_modules/ink/build/components/BackgroundContext.d.ts +4 -0
  175. package/dist/server/node_modules/ink/build/components/BackgroundContext.js +3 -0
  176. package/dist/server/node_modules/ink/build/components/BackgroundContext.js.map +1 -0
  177. package/dist/server/node_modules/ink/build/components/Box.d.ts +117 -0
  178. package/dist/server/node_modules/ink/build/components/Box.js +34 -0
  179. package/dist/server/node_modules/ink/build/components/Box.js.map +1 -0
  180. package/dist/server/node_modules/ink/build/components/Color.js +62 -0
  181. package/dist/server/node_modules/ink/build/components/Cursor.d.ts +83 -0
  182. package/dist/server/node_modules/ink/build/components/Cursor.js +53 -0
  183. package/dist/server/node_modules/ink/build/components/Cursor.js.map +1 -0
  184. package/dist/server/node_modules/ink/build/components/CursorContext.d.ts +11 -0
  185. package/dist/server/node_modules/ink/build/components/CursorContext.js +8 -0
  186. package/dist/server/node_modules/ink/build/components/CursorContext.js.map +1 -0
  187. package/dist/server/node_modules/ink/build/components/ErrorBoundary.d.ts +18 -0
  188. package/dist/server/node_modules/ink/build/components/ErrorBoundary.js +23 -0
  189. package/dist/server/node_modules/ink/build/components/ErrorBoundary.js.map +1 -0
  190. package/dist/server/node_modules/ink/build/components/ErrorOverview.d.ts +6 -0
  191. package/dist/server/node_modules/ink/build/components/ErrorOverview.js +84 -0
  192. package/dist/server/node_modules/ink/build/components/ErrorOverview.js.map +1 -0
  193. package/dist/server/node_modules/ink/build/components/FocusContext.d.ts +16 -0
  194. package/dist/server/node_modules/ink/build/components/FocusContext.js +17 -0
  195. package/dist/server/node_modules/ink/build/components/FocusContext.js.map +1 -0
  196. package/dist/server/node_modules/ink/build/components/Newline.d.ts +13 -0
  197. package/dist/server/node_modules/ink/build/components/Newline.js +8 -0
  198. package/dist/server/node_modules/ink/build/components/Newline.js.map +1 -0
  199. package/dist/server/node_modules/ink/build/components/Spacer.d.ts +7 -0
  200. package/dist/server/node_modules/ink/build/components/Spacer.js +11 -0
  201. package/dist/server/node_modules/ink/build/components/Spacer.js.map +1 -0
  202. package/dist/server/node_modules/ink/build/components/Static.d.ts +24 -0
  203. package/dist/server/node_modules/ink/build/components/Static.js +28 -0
  204. package/dist/server/node_modules/ink/build/components/Static.js.map +1 -0
  205. package/dist/server/node_modules/ink/build/components/StderrContext.d.ts +15 -0
  206. package/dist/server/node_modules/ink/build/components/StderrContext.js +13 -0
  207. package/dist/server/node_modules/ink/build/components/StderrContext.js.map +1 -0
  208. package/dist/server/node_modules/ink/build/components/StdinContext.d.ts +22 -0
  209. package/dist/server/node_modules/ink/build/components/StdinContext.js +19 -0
  210. package/dist/server/node_modules/ink/build/components/StdinContext.js.map +1 -0
  211. package/dist/server/node_modules/ink/build/components/StdoutContext.d.ts +15 -0
  212. package/dist/server/node_modules/ink/build/components/StdoutContext.js +13 -0
  213. package/dist/server/node_modules/ink/build/components/StdoutContext.js.map +1 -0
  214. package/dist/server/node_modules/ink/build/components/Text.d.ts +55 -0
  215. package/dist/server/node_modules/ink/build/components/Text.js +50 -0
  216. package/dist/server/node_modules/ink/build/components/Text.js.map +1 -0
  217. package/dist/server/node_modules/ink/build/components/Transform.d.ts +16 -0
  218. package/dist/server/node_modules/ink/build/components/Transform.js +15 -0
  219. package/dist/server/node_modules/ink/build/components/Transform.js.map +1 -0
  220. package/dist/server/node_modules/ink/build/cursor-helpers.d.ts +38 -0
  221. package/dist/server/node_modules/ink/build/cursor-helpers.js +56 -0
  222. package/dist/server/node_modules/ink/build/cursor-helpers.js.map +1 -0
  223. package/dist/server/node_modules/ink/build/devtools-window-polyfill.d.ts +1 -0
  224. package/dist/server/node_modules/ink/build/devtools-window-polyfill.js +65 -0
  225. package/dist/server/node_modules/ink/build/devtools-window-polyfill.js.map +1 -0
  226. package/dist/server/node_modules/ink/build/devtools.d.ts +1 -0
  227. package/dist/server/node_modules/ink/build/devtools.js +11 -0
  228. package/dist/server/node_modules/ink/build/devtools.js.map +1 -0
  229. package/dist/server/node_modules/ink/build/dom.d.ts +56 -0
  230. package/dist/server/node_modules/ink/build/dom.js +124 -0
  231. package/dist/server/node_modules/ink/build/dom.js.map +1 -0
  232. package/dist/server/node_modules/ink/build/experimental/apply-style.js +140 -0
  233. package/dist/server/node_modules/ink/build/experimental/dom.js +123 -0
  234. package/dist/server/node_modules/ink/build/experimental/output.js +91 -0
  235. package/dist/server/node_modules/ink/build/experimental/reconciler.js +141 -0
  236. package/dist/server/node_modules/ink/build/experimental/renderer.js +81 -0
  237. package/dist/server/node_modules/ink/build/get-max-width.d.ts +3 -0
  238. package/dist/server/node_modules/ink/build/get-max-width.js +10 -0
  239. package/dist/server/node_modules/ink/build/get-max-width.js.map +1 -0
  240. package/dist/server/node_modules/ink/build/hooks/use-app.d.ts +5 -0
  241. package/dist/server/node_modules/ink/build/hooks/use-app.js +8 -0
  242. package/dist/server/node_modules/ink/build/hooks/use-app.js.map +1 -0
  243. package/dist/server/node_modules/ink/build/hooks/use-cursor.d.ts +12 -0
  244. package/dist/server/node_modules/ink/build/hooks/use-cursor.js +29 -0
  245. package/dist/server/node_modules/ink/build/hooks/use-cursor.js.map +1 -0
  246. package/dist/server/node_modules/ink/build/hooks/use-focus-manager.d.ts +28 -0
  247. package/dist/server/node_modules/ink/build/hooks/use-focus-manager.js +17 -0
  248. package/dist/server/node_modules/ink/build/hooks/use-focus-manager.js.map +1 -0
  249. package/dist/server/node_modules/ink/build/hooks/use-focus.d.ts +29 -0
  250. package/dist/server/node_modules/ink/build/hooks/use-focus.js +42 -0
  251. package/dist/server/node_modules/ink/build/hooks/use-focus.js.map +1 -0
  252. package/dist/server/node_modules/ink/build/hooks/use-input.d.ts +131 -0
  253. package/dist/server/node_modules/ink/build/hooks/use-input.js +124 -0
  254. package/dist/server/node_modules/ink/build/hooks/use-input.js.map +1 -0
  255. package/dist/server/node_modules/ink/build/hooks/use-is-screen-reader-enabled.d.ts +5 -0
  256. package/dist/server/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js +11 -0
  257. package/dist/server/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
  258. package/dist/server/node_modules/ink/build/hooks/use-stderr.d.ts +5 -0
  259. package/dist/server/node_modules/ink/build/hooks/use-stderr.js +8 -0
  260. package/dist/server/node_modules/ink/build/hooks/use-stderr.js.map +1 -0
  261. package/dist/server/node_modules/ink/build/hooks/use-stdin.d.ts +5 -0
  262. package/dist/server/node_modules/ink/build/hooks/use-stdin.js +8 -0
  263. package/dist/server/node_modules/ink/build/hooks/use-stdin.js.map +1 -0
  264. package/dist/server/node_modules/ink/build/hooks/use-stdout.d.ts +5 -0
  265. package/dist/server/node_modules/ink/build/hooks/use-stdout.js +8 -0
  266. package/dist/server/node_modules/ink/build/hooks/use-stdout.js.map +1 -0
  267. package/dist/server/node_modules/ink/build/hooks/useInput.js +38 -0
  268. package/dist/server/node_modules/ink/build/index.d.ts +34 -0
  269. package/dist/server/node_modules/ink/build/index.js +20 -0
  270. package/dist/server/node_modules/ink/build/index.js.map +1 -0
  271. package/dist/server/node_modules/ink/build/ink.d.ts +90 -0
  272. package/dist/server/node_modules/ink/build/ink.js +637 -0
  273. package/dist/server/node_modules/ink/build/ink.js.map +1 -0
  274. package/dist/server/node_modules/ink/build/input-parser.d.ts +7 -0
  275. package/dist/server/node_modules/ink/build/input-parser.js +154 -0
  276. package/dist/server/node_modules/ink/build/input-parser.js.map +1 -0
  277. package/dist/server/node_modules/ink/build/instance.js +205 -0
  278. package/dist/server/node_modules/ink/build/instances.d.ts +3 -0
  279. package/dist/server/node_modules/ink/build/instances.js +8 -0
  280. package/dist/server/node_modules/ink/build/instances.js.map +1 -0
  281. package/dist/server/node_modules/ink/build/kitty-keyboard.d.ts +23 -0
  282. package/dist/server/node_modules/ink/build/kitty-keyboard.js +32 -0
  283. package/dist/server/node_modules/ink/build/kitty-keyboard.js.map +1 -0
  284. package/dist/server/node_modules/ink/build/layout.d.ts +7 -0
  285. package/dist/server/node_modules/ink/build/layout.js +33 -0
  286. package/dist/server/node_modules/ink/build/layout.js.map +1 -0
  287. package/dist/server/node_modules/ink/build/log-update.d.ts +19 -0
  288. package/dist/server/node_modules/ink/build/log-update.js +242 -0
  289. package/dist/server/node_modules/ink/build/log-update.js.map +1 -0
  290. package/dist/server/node_modules/ink/build/measure-element.d.ts +16 -0
  291. package/dist/server/node_modules/ink/build/measure-element.js +9 -0
  292. package/dist/server/node_modules/ink/build/measure-element.js.map +1 -0
  293. package/dist/server/node_modules/ink/build/measure-text.d.ts +6 -0
  294. package/dist/server/node_modules/ink/build/measure-text.js +21 -0
  295. package/dist/server/node_modules/ink/build/measure-text.js.map +1 -0
  296. package/dist/server/node_modules/ink/build/options.d.ts +52 -0
  297. package/dist/server/node_modules/ink/build/options.js +2 -0
  298. package/dist/server/node_modules/ink/build/options.js.map +1 -0
  299. package/dist/server/node_modules/ink/build/output.d.ts +35 -0
  300. package/dist/server/node_modules/ink/build/output.js +183 -0
  301. package/dist/server/node_modules/ink/build/output.js.map +1 -0
  302. package/dist/server/node_modules/ink/build/parse-keypress.d.ts +22 -0
  303. package/dist/server/node_modules/ink/build/parse-keypress.js +493 -0
  304. package/dist/server/node_modules/ink/build/parse-keypress.js.map +1 -0
  305. package/dist/server/node_modules/ink/build/reconciler.d.ts +4 -0
  306. package/dist/server/node_modules/ink/build/reconciler.js +274 -0
  307. package/dist/server/node_modules/ink/build/reconciler.js.map +1 -0
  308. package/dist/server/node_modules/ink/build/render-background.d.ts +4 -0
  309. package/dist/server/node_modules/ink/build/render-background.js +25 -0
  310. package/dist/server/node_modules/ink/build/render-background.js.map +1 -0
  311. package/dist/server/node_modules/ink/build/render-border.d.ts +4 -0
  312. package/dist/server/node_modules/ink/build/render-border.js +73 -0
  313. package/dist/server/node_modules/ink/build/render-border.js.map +1 -0
  314. package/dist/server/node_modules/ink/build/render-node-to-output.d.ts +14 -0
  315. package/dist/server/node_modules/ink/build/render-node-to-output.js +147 -0
  316. package/dist/server/node_modules/ink/build/render-node-to-output.js.map +1 -0
  317. package/dist/server/node_modules/ink/build/render-to-string.d.ts +38 -0
  318. package/dist/server/node_modules/ink/build/render-to-string.js +115 -0
  319. package/dist/server/node_modules/ink/build/render-to-string.js.map +1 -0
  320. package/dist/server/node_modules/ink/build/render.d.ts +121 -0
  321. package/dist/server/node_modules/ink/build/render.js +55 -0
  322. package/dist/server/node_modules/ink/build/render.js.map +1 -0
  323. package/dist/server/node_modules/ink/build/renderer.d.ts +8 -0
  324. package/dist/server/node_modules/ink/build/renderer.js +55 -0
  325. package/dist/server/node_modules/ink/build/renderer.js.map +1 -0
  326. package/dist/server/node_modules/ink/build/sanitize-ansi.d.ts +2 -0
  327. package/dist/server/node_modules/ink/build/sanitize-ansi.js +27 -0
  328. package/dist/server/node_modules/ink/build/sanitize-ansi.js.map +1 -0
  329. package/dist/server/node_modules/ink/build/screen-reader-update.d.ts +13 -0
  330. package/dist/server/node_modules/ink/build/screen-reader-update.js +38 -0
  331. package/dist/server/node_modules/ink/build/screen-reader-update.js.map +1 -0
  332. package/dist/server/node_modules/ink/build/squash-text-nodes.d.ts +3 -0
  333. package/dist/server/node_modules/ink/build/squash-text-nodes.js +36 -0
  334. package/dist/server/node_modules/ink/build/squash-text-nodes.js.map +1 -0
  335. package/dist/server/node_modules/ink/build/styles.d.ts +240 -0
  336. package/dist/server/node_modules/ink/build/styles.js +232 -0
  337. package/dist/server/node_modules/ink/build/styles.js.map +1 -0
  338. package/dist/server/node_modules/ink/build/utils.d.ts +2 -0
  339. package/dist/server/node_modules/ink/build/utils.js +4 -0
  340. package/dist/server/node_modules/ink/build/utils.js.map +1 -0
  341. package/dist/server/node_modules/ink/build/wrap-text.d.ts +3 -0
  342. package/dist/server/node_modules/ink/build/wrap-text.js +31 -0
  343. package/dist/server/node_modules/ink/build/wrap-text.js.map +1 -0
  344. package/dist/server/node_modules/ink/build/write-synchronized.d.ts +4 -0
  345. package/dist/server/node_modules/ink/build/write-synchronized.js +7 -0
  346. package/dist/server/node_modules/ink/build/write-synchronized.js.map +1 -0
  347. package/dist/server/node_modules/ink/license +10 -0
  348. package/dist/server/node_modules/ink/package.json +201 -0
  349. package/dist/server/node_modules/ink/readme.md +2636 -0
  350. package/dist/server/node_modules/onetime/index.d.ts +64 -0
  351. package/dist/server/node_modules/onetime/index.js +44 -0
  352. package/dist/server/node_modules/onetime/license +9 -0
  353. package/dist/server/node_modules/onetime/package.json +43 -0
  354. package/dist/server/node_modules/onetime/readme.md +94 -0
  355. package/dist/server/server.js +1 -1
  356. package/package.json +1 -1
  357. package/dist/client/assets/SearchMd-VdXbz8fL.js +0 -1
  358. package/dist/client/assets/XCircle-BiHPX6_R.js +0 -1
  359. package/dist/client/assets/agent-icon-DCE-D-qC.js +0 -1
  360. package/dist/client/assets/agents-list-8_yOp3iD.js +0 -1
  361. package/dist/client/assets/ai-providers-DxQNSEJT.js +0 -1
  362. package/dist/client/assets/automation-list-row-BWjwKsQ5.js +0 -1
  363. package/dist/client/assets/automations-D6LOd0hH.js +0 -1
  364. package/dist/client/assets/collection-detail-BTibo6D3.js +0 -1
  365. package/dist/client/assets/collection-display-button-CfjJ9SIP.js +0 -1
  366. package/dist/client/assets/collection-table-wrapper-B4l_6tOy.js +0 -1
  367. package/dist/client/assets/command-BPSv-8-5.js +0 -1
  368. package/dist/client/assets/connection-detail-DgKIsKao.js +0 -1
  369. package/dist/client/assets/connections-rM_I7gvv.js +0 -1
  370. package/dist/client/assets/dropdown-menu-DO26Q0bD.js +0 -1
  371. package/dist/client/assets/general-VnUbEBHT.js +0 -1
  372. package/dist/client/assets/index-DeSgX7LP.css +0 -1
  373. package/dist/client/assets/members-6PieW-Nu.js +0 -3
  374. package/dist/client/assets/project-app-view-EMrqjiux.js +0 -1
  375. package/dist/client/assets/registry-CYL2cMC0.js +0 -2
  376. package/dist/client/assets/settings-layout-hwviWS6Q.js +0 -1
  377. package/dist/client/assets/store-registry-DAeO63_G.js +0 -2
  378. package/dist/client/assets/tools-list-C0RCBhOc.js +0 -1
  379. package/dist/client/assets/useInfiniteQuery-Ci00Hw-m.js +0 -1
  380. package/dist/client/assets/workflow-BrBlpNSn.js +0 -1
  381. package/dist/client/assets/workflow-detail-NqGVn5hy.js +0 -1
@@ -1,4 +1,4 @@
1
- import{e as Y,s as ie,n as Ie,o as ke,a as je,z as V,r as I,j as t,B as G,l as Le,c as Z,a0 as Fs,a1 as Bs}from"./index-CNolBSVE.js";import{i as Qs}from"./ArrowNarrowLeft-B8YVT66M.js";import{i as qe}from"./CheckCircle-BFRWTTWo.js";import{n as Vs}from"./Container-SHbLkl7K.js";import{a as Gs}from"./Settings02-C88OtRRq.js";import{c as Jt,n as Ks,g as ds,b as Zt,h as Mt,a as Ys,j as us,i as Hs,e as Ws,d as Js,f as St,t as Zs,l as Xs}from"./XCircle-BiHPX6_R.js";import{S as ce,u as oe,d as er}from"./constants-D8VkIs2c.js";import{u as ms}from"./useInfiniteQuery-Ci00Hw-m.js";import{B as F}from"./badge-DsWPcX1V.js";import{I as ae}from"./input-B8j75XZ_.js";import{d as dt,D as Ce,c as ut,e as mt,j as Xt,k as es,i as tr}from"./dropdown-menu-DO26Q0bD.js";import{c as Et,d as Dt,a as Fe,e as ue,b as At,T as me}from"./table-C-JSrHQJ.js";import{T as sr,a as ts}from"./toggle-group-B6-etMEh.js";import{u as rr}from"./use-view-mode-BkbloGkm.js";import{c as $t,e as nr,i as ir,a as lr,s as xs,b as ar,d as or}from"./SearchMd-VdXbz8fL.js";import{a as xt,D as ht,e as pt,b as ft,c as gt,d as jt}from"./dialog-BOagZAx2.js";import{i as Ke}from"./AlertCircle-Ljx3VIeb.js";import{c as Ye,b as He,d as We,A as Je,g as Ze,e as Xe,a as et,f as tt}from"./alert-dialog-DaP8t8su.js";import{C as ne}from"./card-CPVRwbgl.js";import{s as st}from"./Trash01-BHBjIGXE.js";import{L as X}from"./label-KH35YAYU.js";import{a as cr,c as dr,d as ur,S as mr,b as Rt}from"./select-JPYD20it.js";import{S as Oe}from"./switch-CVtXvreH.js";import{T as vt}from"./textarea-p_oNKH-r.js";import{i as xr}from"./X-BWV-b86T.js";import{t as hr,i as Tt}from"./ChevronDown-BqFspEzt.js";import{n as pr}from"./ChevronUp-D7S3j_fa.js";import{C as ss}from"./checkbox-CPqdqI54.js";import{n as fr}from"./LinkExternal01-XmkIm96u.js";import{u as It}from"./use-copy-D8L6lrfC.js";import{s as gr}from"./Plus-Bmk1thjl.js";import{a as jr,b as vr,c as br}from"./use-mobile-Ctb5URy7.js";import{i as yr}from"./Play-9pX5w5-3.js";import"./infiniteQueryObserver-B8q-YDXm.js";import"./ChevronRight-DCsBjQ-n.js";const $e="private-registry",Nr=`
1
+ import{e as Y,s as ie,n as Ie,o as ke,a as je,z as V,r as I,j as t,B as G,l as Le,c as Z,a0 as Fs,a1 as Bs}from"./index-D34n6J5J.js";import{i as Qs}from"./ArrowNarrowLeft-DlPeFc4v.js";import{i as qe}from"./CheckCircle-DJ3lme5R.js";import{n as Vs}from"./Container-B1nHZdmn.js";import{a as Gs}from"./Settings02-Dm9dFDqk.js";import{c as Jt,n as Ks,g as ds,b as Zt,a as Ys,h as us,i as Hs,e as Ws,d as Js,f as St,t as Zs,j as Xs}from"./XCircle-C1sJYG9R.js";import{S as ce,u as oe,d as er}from"./constants-DDHDU3PV.js";import{u as ms}from"./useInfiniteQuery-B4w-6TrV.js";import{B as F}from"./badge-s_TAXGUN.js";import{I as ae}from"./input-urtyHxks.js";import{d as dt,D as Ce,c as ut,e as mt,j as Xt,k as es,i as tr}from"./dropdown-menu-v2GifVOh.js";import{c as Mt,d as Et,a as Fe,e as ue,b as Dt,T as me}from"./table-CQMW-Toa.js";import{T as sr,a as ts}from"./toggle-group-C077Smww.js";import{u as rr}from"./use-view-mode-CZPzVaxj.js";import{i as At}from"./DotsVertical-Bp2tW8JI.js";import{i as nr,a as ir}from"./SearchMd-BRJBvWf4.js";import{a as xt,D as ht,e as pt,b as ft,c as gt,d as jt}from"./dialog-C4lREl-t.js";import{i as Ke}from"./AlertCircle-DTmaHldD.js";import{c as Ye,b as He,d as We,A as Je,g as Ze,e as Xe,a as et,f as tt}from"./alert-dialog-CicrCOay.js";import{C as ne}from"./card-CaekC2K0.js";import{s as st}from"./Trash01-C6bAXG6g.js";import{L as X}from"./label-Bt4h_QUk.js";import{a as lr,c as ar,d as or,S as cr,b as Rt}from"./select-CePxsPeP.js";import{S as Oe}from"./switch-VBeL01bM.js";import{T as vt}from"./textarea-Ie4QUdo5.js";import{a as $t,c as dr,i as ur,s as xs,b as mr}from"./RefreshCcw01-B10mKiE2.js";import{i as xr}from"./X-i9zBn6Hn.js";import{t as hr,i as Tt}from"./ChevronDown-DGnjAtqs.js";import{n as pr}from"./ChevronUp-BkSgkwhO.js";import{C as ss}from"./checkbox-DznLgPgR.js";import{n as fr}from"./LinkExternal01-BBbCPDtX.js";import{u as It}from"./use-copy-uiSuMvtc.js";import{s as gr}from"./Plus-oXFwCrYz.js";import{a as jr,b as vr,c as br}from"./use-mobile-CxvYCzu9.js";import{i as yr}from"./Play-DKFUTU3G.js";import"./infiniteQueryObserver-1_M-sq16.js";import"./ChevronRight-DV9No7GF.js";const $e="private-registry",Nr=`
2
2
  You are an MCP tool tester running automated integration checks.
3
3
 
4
4
  Goal:
@@ -22,6 +22,6 @@ At the end, provide a concise summary of:
22
22
  - If some tool needs user-specific context (email/account/tenant), explicitly output a "CONTEXT_REQUIRED" note with what is needed.
23
23
  `.trim(),Q={all:["private-registry"],items:()=>[...Q.all,"items"],itemsList:(s,e,r,n)=>[...Q.items(),"list",{search:s,tags:e,categories:r,limit:n}],item:s=>[...Q.items(),"item",s],filters:()=>[...Q.all,"filters"],registryConfig:()=>[...Q.all,"registry-config"],registryConfigByPlugin:(s,e)=>[...Q.registryConfig(),s,e],publishRequests:()=>[...Q.all,"publish-requests"],publishRequestsByOrg:s=>[...Q.publishRequests(),"org",s],publishRequestsList:(s,e,r)=>[...Q.publishRequests(),"list",{status:s??"all",sortBy:e??"created_at",sortDirection:r??"desc"}],publishRequestsListByOrg:(s,e,r,n)=>[...Q.publishRequestsByOrg(s),"list",{status:e??"all",sortBy:r??"created_at",sortDirection:n??"desc"}],publishRequestsCount:()=>[...Q.publishRequests(),"count"],publishRequestsCountByOrg:s=>[...Q.publishRequestsByOrg(s),"count"],publishApiKeys:()=>[...Q.all,"publish-api-keys"],monitor:()=>[...Q.all,"monitor"],monitorRuns:()=>[...Q.monitor(),"runs"],monitorRunsList:s=>[...Q.monitorRuns(),"list",{status:s??"all"}],monitorRun:s=>[...Q.monitorRuns(),"run",s??"none"],monitorResults:()=>[...Q.monitor(),"results"],monitorResultsList:(s,e)=>[...Q.monitorResults(),"list",{runId:s??"none",status:e??"all"}],monitorConnections:()=>[...Q.monitor(),"connections"],monitorConnectionAuthProbe:s=>[...Q.monitorConnections(),"auth-probe",s]};async function _e(s,e,r){const n=await s.callTool({name:e,arguments:r});if(!n||typeof n!="object")throw new Error(`Invalid tool response for ${e}`);if(n.isError){const o=n.content?.find(i=>i.type==="text")?.text??`Tool ${e} returned an error`;throw new Error(o)}return n.structuredContent??n}function wr(){const s=Y.c(9),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async d=>_e(o,"REGISTRY_MONITOR_RUN_START",{config:d}),s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async()=>{await Promise.all([e.invalidateQueries({queryKey:Q.monitorRuns()}),e.invalidateQueries({queryKey:Q.monitorResults()})])},s[4]=e,s[5]=a):a=s[5];let l;return s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8],je(l)}function _r(){const s=Y.c(9),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async d=>_e(o,"REGISTRY_MONITOR_RUN_CANCEL",{runId:d}),s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async(d,u)=>{await Promise.all([e.invalidateQueries({queryKey:Q.monitorRuns()}),e.invalidateQueries({queryKey:Q.monitorRun(u)})])},s[4]=e,s[5]=a):a=s[5];let l;return s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8],je(l)}function yt(s){const e=Y.c(10),{org:r}=ie();let n;e[0]!==r.id?(n={connectionId:ce,orgId:r.id},e[0]=r.id,e[1]=n):n=e[1];const o=oe(n);let i;e[2]!==s?(i=Q.monitorRunsList(s),e[2]=s,e[3]=i):i=e[3];let a;e[4]!==o||e[5]!==s?(a=async()=>_e(o,"REGISTRY_MONITOR_RUN_LIST",{status:s,limit:100}),e[4]=o,e[5]=s,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==a?(l={queryKey:i,queryFn:a,staleTime:5e3},e[7]=i,e[8]=a,e[9]=l):l=e[9],Ie(l)}function Ot(s){const e=Y.c(11),{org:r}=ie();let n;e[0]!==r.id?(n={connectionId:ce,orgId:r.id},e[0]=r.id,e[1]=n):n=e[1];const o=oe(n);let i;e[2]!==s?(i=Q.monitorRun(s),e[2]=s,e[3]=i):i=e[3];let a;e[4]!==o||e[5]!==s?(a=async()=>_e(o,"REGISTRY_MONITOR_RUN_GET",{runId:s}),e[4]=o,e[5]=s,e[6]=a):a=e[6];const l=!!s;let d;return e[7]!==i||e[8]!==a||e[9]!==l?(d={queryKey:i,queryFn:a,enabled:l,refetchInterval:Cr},e[7]=i,e[8]=a,e[9]=l,e[10]=d):d=e[10],Ie(d)}function Cr(s){return s.state.data?.run?.status==="running"?5e3:!1}function rt(s,e,r){const n=Y.c(14),{org:o}=ie();let i;n[0]!==o.id?(i={connectionId:ce,orgId:o.id},n[0]=o.id,n[1]=i):i=n[1];const a=oe(i);let l;n[2]!==s||n[3]!==e?(l=Q.monitorResultsList(s,e),n[2]=s,n[3]=e,n[4]=l):l=n[4];let d;n[5]!==a||n[6]!==s||n[7]!==e?(d=async()=>_e(a,"REGISTRY_MONITOR_RESULT_LIST",{runId:s,status:e,limit:200,offset:0}),n[5]=a,n[6]=s,n[7]=e,n[8]=d):d=n[8];const u=!!s,m=r==="running"?2500:!1;let h;return n[9]!==l||n[10]!==d||n[11]!==u||n[12]!==m?(h={queryKey:l,queryFn:d,enabled:u,staleTime:5e3,refetchInterval:m},n[9]=l,n[10]=d,n[11]=u,n[12]=m,n[13]=h):h=n[13],Ie(h)}function hs(){const s=Y.c(5),{org:e}=ie();let r;s[0]!==e.id?(r={connectionId:ce,orgId:e.id},s[0]=e.id,s[1]=r):r=s[1];const n=oe(r);let o;s[2]===Symbol.for("react.memo_cache_sentinel")?(o=Q.monitorConnections(),s[2]=o):o=s[2];let i;return s[3]!==n?(i={queryKey:o,queryFn:async()=>_e(n,"REGISTRY_MONITOR_CONNECTION_LIST",{}),staleTime:1e4},s[3]=n,s[4]=i):i=s[4],Ie(i)}function kr(){const s=Y.c(9),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async()=>_e(o,"REGISTRY_MONITOR_CONNECTION_SYNC",{}),s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async()=>{await e.invalidateQueries({queryKey:Q.monitorConnections()})},s[4]=e,s[5]=a):a=s[5];let l;return s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8],je(l)}function Sr(){const s=Y.c(9),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async d=>{const{connectionId:u,authStatus:m}=d;return _e(o,"REGISTRY_MONITOR_CONNECTION_UPDATE_AUTH",{connectionId:u,authStatus:m})},s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async()=>{await e.invalidateQueries({queryKey:Q.monitorConnections()})},s[4]=e,s[5]=a):a=s[5];let l;return s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8],je(l)}const rs={monitorMode:"health_check",onFailure:"none",schedule:"manual",cronExpression:"",scheduleEventId:"",perMcpTimeoutMs:3e4,perToolTimeoutMs:1e4,maxAgentSteps:15,testPublicOnly:!1,testPrivateOnly:!1,includePendingRequests:!1,agentContext:""};function ps(){const s=Y.c(33),{org:e,project:r}=ie();let n;s[0]!==e.id?(n={connectionId:ce,orgId:e.id},s[0]=e.id,s[1]=n):n=s[1];const o=oe(n),i=ke();let a;s[2]!==r.id?(a=Q.registryConfigByPlugin(r.id??"",$e),s[2]=r.id,s[3]=a):a=s[3];let l;s[4]!==o||s[5]!==r.id?(l=async()=>_e(o,"VIRTUAL_MCP_PLUGIN_CONFIG_GET",{virtualMcpId:r.id,pluginId:$e}),s[4]=o,s[5]=r.id,s[6]=l):l=s[6];const d=!!r.id;let u;s[7]!==a||s[8]!==l||s[9]!==d?(u={queryKey:a,queryFn:l,enabled:d},s[7]=a,s[8]=l,s[9]=d,s[10]=u):u=s[10];const m=Ie(u),h=m.data?.config?.settings,x=h&&typeof h=="object"?h.testConfig:void 0,c=typeof(h?h.monitorMode??h.testMode:void 0)=="string";let f;s[11]!==x?(f=x??{},s[11]=x,s[12]=f):f=s[12];let j;s[13]!==c||s[14]!==h||s[15]!==x?(j=c&&!x?h:{},s[13]=c,s[14]=h,s[15]=x,s[16]=j):j=s[16];let C;s[17]!==f||s[18]!==j?(C={...rs,...f,...j},s[17]=f,s[18]=j,s[19]=C):C=s[19];const _=C;let y;s[20]!==o||s[21]!==r.id?(y=async k=>{const N=(await _e(o,"VIRTUAL_MCP_PLUGIN_CONFIG_GET",{virtualMcpId:r.id,pluginId:$e}))?.config?.settings??{};return _e(o,"VIRTUAL_MCP_PLUGIN_CONFIG_UPDATE",{virtualMcpId:r.id,pluginId:$e,settings:{...N,testConfig:{...rs,...N.testConfig??{},...k}}})},s[20]=o,s[21]=r.id,s[22]=y):y=s[22];let g;s[23]!==r.id||s[24]!==i?(g=async()=>{await i.invalidateQueries({queryKey:Q.registryConfigByPlugin(r.id??"",$e)})},s[23]=r.id,s[24]=i,s[25]=g):g=s[25];let P;s[26]!==y||s[27]!==g?(P={mutationFn:y,onSuccess:g},s[26]=y,s[27]=g,s[28]=P):P=s[28];const R=je(P);let w;return s[29]!==m.isLoading||s[30]!==R||s[31]!==_?(w={settings:_,isLoading:m.isLoading,saveMutation:R},s[29]=m.isLoading,s[30]=R,s[31]=_,s[32]=w):w=s[32],w}function Rr(){const s=Y.c(9),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async d=>_e(o,"REGISTRY_MONITOR_SCHEDULE_SET",d),s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async()=>{await e.invalidateQueries({queryKey:Q.registryConfig()})},s[4]=e,s[5]=a):a=s[5];let l;return s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8],je(l)}function Tr(){const s=Y.c(9),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async d=>_e(o,"REGISTRY_MONITOR_SCHEDULE_CANCEL",{scheduleEventId:d}),s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async()=>{await e.invalidateQueries({queryKey:Q.registryConfig()})},s[4]=e,s[5]=a):a=s[5];let l;return s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8],je(l)}function Ir(){const s=Y.c(3),e=yt("completed"),r=e.data?.items?.[0]?.id,n=e.data?.items?.[0]?.status,o=rt(r,"failed",n),i=o.data?.items?.length??0,a=e.isLoading||o.isLoading;let l;return s[0]!==i||s[1]!==a?(l={brokenCount:i,isLoading:a},s[0]=i,s[1]=a,s[2]=l):l=s[2],l}const fs=24;function Pr(s){return s.trim()}async function ve(s,e,r){const n=await s.callTool({name:e,arguments:r});if(!n||typeof n!="object")throw new Error(`Invalid tool response for ${e}`);if(n.isError){const o=n.content?.find(i=>i.type==="text")?.text??`Tool ${e} returned an error`;throw new Error(o)}return n.structuredContent??n}function gs(s){const e=Y.c(19),{org:r}=ie();let n;e[0]!==r.id?(n={connectionId:ce,orgId:r.id},e[0]=r.id,e[1]=n):n=e[1];const o=oe(n);let i,a,l,d;e[2]!==s.categories||e[3]!==s.limit||e[4]!==s.search||e[5]!==s.tags?(a=Pr(s.search),i=s.limit??fs,d=ms,l=Q.itemsList(a,s.tags,s.categories,i),e[2]=s.categories,e[3]=s.limit,e[4]=s.search,e[5]=s.tags,e[6]=i,e[7]=a,e[8]=l,e[9]=d):(i=e[6],a=e[7],l=e[8],d=e[9]);let u;e[10]!==o||e[11]!==i||e[12]!==s.categories||e[13]!==s.tags||e[14]!==a?(u=async h=>{const{pageParam:x}=h,p=a.length>0?{operator:"or",conditions:[{field:["title"],operator:"contains",value:a},{field:["description"],operator:"contains",value:a},{field:["id"],operator:"contains",value:a},{field:["server","name"],operator:"contains",value:a}]}:void 0;return ve(o,"REGISTRY_ITEM_LIST",{cursor:x,limit:i,tags:s.tags.length?s.tags:void 0,categories:s.categories.length?s.categories:void 0,where:p})},e[10]=o,e[11]=i,e[12]=s.categories,e[13]=s.tags,e[14]=a,e[15]=u):u=e[15];let m;return e[16]!==l||e[17]!==u?(m={queryKey:l,queryFn:u,initialPageParam:void 0,getNextPageParam:Mr,staleTime:3e4},e[16]=l,e[17]=u,e[18]=m):m=e[18],d(m)}function Mr(s){return s.nextCursor}function Er(){const s=Y.c(8),{org:e}=ie();let r;s[0]!==e.id?(r={connectionId:ce,orgId:e.id},s[0]=e.id,s[1]=r):r=s[1];const n=oe(r);let o;s[2]===Symbol.for("react.memo_cache_sentinel")?(o=Q.filters(),s[2]=o):o=s[2];let i;s[3]!==n?(i=async()=>ve(n,"REGISTRY_ITEM_FILTERS",{}),s[3]=n,s[4]=i):i=s[4];let a;s[5]===Symbol.for("react.memo_cache_sentinel")?(a={tags:[],categories:[]},s[5]=a):a=s[5];let l;return s[6]!==i?(l={queryKey:o,queryFn:i,placeholderData:a,staleTime:6e4},s[6]=i,s[7]=l):l=s[7],Ie(l)}function zt(){const s=Y.c(29),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==e?(i=async()=>{await Promise.all([e.invalidateQueries({queryKey:Q.items()}),e.invalidateQueries({queryKey:Q.filters()})])},s[2]=e,s[3]=i):i=s[3];const a=i;let l;s[4]!==o?(l=async g=>(await ve(o,"REGISTRY_ITEM_CREATE",{data:g})).item,s[4]=o,s[5]=l):l=s[5];let d;s[6]!==a||s[7]!==l?(d={mutationFn:l,onSuccess:a},s[6]=a,s[7]=l,s[8]=d):d=s[8];const u=je(d);let m;s[9]!==o?(m=async g=>{const{id:P,data:R}=g;return(await ve(o,"REGISTRY_ITEM_UPDATE",{id:P,data:R})).item},s[9]=o,s[10]=m):m=s[10];let h;s[11]!==a||s[12]!==m?(h={mutationFn:m,onSuccess:a},s[11]=a,s[12]=m,s[13]=h):h=s[13];const x=je(h);let p;s[14]!==o?(p=async g=>(await ve(o,"REGISTRY_ITEM_DELETE",{id:g})).item,s[14]=o,s[15]=p):p=s[15];let c;s[16]!==a||s[17]!==p?(c={mutationFn:p,onSuccess:a},s[16]=a,s[17]=p,s[18]=c):c=s[18];const f=je(c);let j;s[19]!==o?(j=async g=>ve(o,"REGISTRY_ITEM_BULK_CREATE",{items:g}),s[19]=o,s[20]=j):j=s[20];let C;s[21]!==a||s[22]!==j?(C={mutationFn:j,onSuccess:a},s[21]=a,s[22]=j,s[23]=C):C=s[23];const _=je(C);let y;return s[24]!==_||s[25]!==u||s[26]!==f||s[27]!==x?(y={createMutation:u,updateMutation:x,deleteMutation:f,bulkCreateMutation:_},s[24]=_,s[25]=u,s[26]=f,s[27]=x,s[28]=y):y=s[28],y}function js(s){const e=Y.c(26),{org:r}=ie();let n;e[0]!==r.id?(n={connectionId:ce,orgId:r.id},e[0]=r.id,e[1]=n):n=e[1];const o=oe(n),i=ke(),a=er.SELF(r.id),l=Ie({queryKey:Q.registryConfigByPlugin(a,s),queryFn:async()=>ve(o,"VIRTUAL_MCP_PLUGIN_CONFIG_GET",{virtualMcpId:a,pluginId:s}),staleTime:6e4}),d=Q.registryConfigByPlugin(a,s);let u;e[2]!==o||e[3]!==s||e[4]!==a?(u=async N=>{const v=(await ve(o,"VIRTUAL_MCP_PLUGIN_CONFIG_GET",{virtualMcpId:a,pluginId:s}))?.config?.settings??{};return ve(o,"VIRTUAL_MCP_PLUGIN_CONFIG_UPDATE",{virtualMcpId:a,pluginId:s,settings:{...v,...N}})},e[2]=o,e[3]=s,e[4]=a,e[5]=u):u=e[5];let m;e[6]!==i||e[7]!==d?(m=async()=>{await i.invalidateQueries({queryKey:d})},e[6]=i,e[7]=d,e[8]=m):m=e[8];let h;e[9]!==u||e[10]!==m?(h={mutationFn:u,onSuccess:m,onError:Dr},e[9]=u,e[10]=m,e[11]=h):h=e[11];const x=je(h);let p;e[12]!==x?(p=N=>{x.mutate(N)},e[12]=x,e[13]=p):p=e[13];const c=p,f=l.data?.config?.settings?.registryName??"Private Registry",j=l.data?.config?.settings?.registryIcon??"",C=l.data?.config?.settings?.acceptPublishRequests??!1,_=l.data?.config?.settings?.requireApiToken??!1,y=l.data?.config?.settings?.storePrivateOnly??!1,g=l.data?.config?.settings?.rateLimitEnabled??!0,R=l.data?.config?.settings?.rateLimitWindow==="minute"?"minute":"hour",w=l.data?.config?.settings?.rateLimitMax,k=typeof w=="number"&&w>=1?Math.floor(w):100;let T;return e[14]!==C||e[15]!==x.isPending||e[16]!==l.isLoading||e[17]!==g||e[18]!==k||e[19]!==R||e[20]!==j||e[21]!==f||e[22]!==_||e[23]!==y||e[24]!==c?(T={registryName:f,registryIcon:j,acceptPublishRequests:C,requireApiToken:_,storePrivateOnly:y,rateLimitEnabled:g,rateLimitWindow:R,rateLimitMax:k,isLoadingConfig:l.isLoading,isSaving:x.isPending,updateConfig:c},e[14]=C,e[15]=x.isPending,e[16]=l.isLoading,e[17]=g,e[18]=k,e[19]=R,e[20]=j,e[21]=f,e[22]=_,e[23]=y,e[24]=c,e[25]=T):T=e[25],T}function Dr(s){V.error(s instanceof Error?s.message:"Failed to save registry settings")}function Ar(s){const e=Y.c(15),{org:r}=ie();let n;e[0]!==r.id?(n={connectionId:ce,orgId:r.id},e[0]=r.id,e[1]=n):n=e[1];const o=oe(n);let i;e[2]!==r.id||e[3]!==s.sortBy||e[4]!==s.sortDirection||e[5]!==s.status?(i=Q.publishRequestsListByOrg(r.id,s.status,s.sortBy,s.sortDirection),e[2]=r.id,e[3]=s.sortBy,e[4]=s.sortDirection,e[5]=s.status,e[6]=i):i=e[6];let a;e[7]!==o||e[8]!==s.sortBy||e[9]!==s.sortDirection||e[10]!==s.status?(a=async d=>{const{pageParam:u}=d;return ve(o,"REGISTRY_PUBLISH_REQUEST_LIST",{status:s.status,sortBy:s.sortBy,sortDirection:s.sortDirection,limit:fs,offset:u})},e[7]=o,e[8]=s.sortBy,e[9]=s.sortDirection,e[10]=s.status,e[11]=a):a=e[11];let l;return e[12]!==i||e[13]!==a?(l={queryKey:i,queryFn:a,initialPageParam:0,getNextPageParam:$r,staleTime:3e4,refetchOnMount:!0},e[12]=i,e[13]=a,e[14]=l):l=e[14],ms(l)}function $r(s,e){const r=e.reduce(Or,0);return r<s.totalCount?r:void 0}function Or(s,e){return s+e.items.length}function zr(){const s=Y.c(9),{org:e}=ie();let r;s[0]!==e.id?(r={connectionId:ce,orgId:e.id},s[0]=e.id,s[1]=r):r=s[1];const n=oe(r);let o;s[2]!==e.id?(o=Q.publishRequestsCountByOrg(e.id),s[2]=e.id,s[3]=o):o=s[3];let i;s[4]!==n?(i=async()=>ve(n,"REGISTRY_PUBLISH_REQUEST_COUNT",{}),s[4]=n,s[5]=i):i=s[5];let a;return s[6]!==o||s[7]!==i?(a={queryKey:o,queryFn:i,staleTime:3e4},s[6]=o,s[7]=i,s[8]=a):a=s[8],Ie(a)}function Ur(){const s=Y.c(17),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==e?(i=async()=>{await Promise.all([e.invalidateQueries({queryKey:Q.publishRequests()})])},s[2]=e,s[3]=i):i=s[3];const a=i;let l;s[4]!==o?(l=async c=>ve(o,"REGISTRY_PUBLISH_REQUEST_REVIEW",c),s[4]=o,s[5]=l):l=s[5];let d;s[6]!==a||s[7]!==l?(d={mutationFn:l,onSuccess:a},s[6]=a,s[7]=l,s[8]=d):d=s[8];const u=je(d);let m;s[9]!==o?(m=async c=>ve(o,"REGISTRY_PUBLISH_REQUEST_DELETE",{id:c}),s[9]=o,s[10]=m):m=s[10];let h;s[11]!==a||s[12]!==m?(h={mutationFn:m,onSuccess:a},s[11]=a,s[12]=m,s[13]=h):h=s[13];const x=je(h);let p;return s[14]!==x||s[15]!==u?(p={reviewMutation:u,deleteMutation:x},s[14]=x,s[15]=u,s[16]=p):p=s[16],p}function Lr(){const s=Y.c(5),{org:e}=ie();let r;s[0]!==e.id?(r={connectionId:ce,orgId:e.id},s[0]=e.id,s[1]=r):r=s[1];const n=oe(r);let o;s[2]===Symbol.for("react.memo_cache_sentinel")?(o=Q.publishApiKeys(),s[2]=o):o=s[2];let i;return s[3]!==n?(i={queryKey:o,queryFn:async()=>ve(n,"REGISTRY_PUBLISH_API_KEY_LIST",{}),staleTime:3e4},s[3]=n,s[4]=i):i=s[4],Ie(i)}function qr(){const s=Y.c(19),e=ke(),{org:r}=ie();let n;s[0]!==r.id?(n={connectionId:ce,orgId:r.id},s[0]=r.id,s[1]=n):n=s[1];const o=oe(n);let i;s[2]!==o?(i=async c=>ve(o,"REGISTRY_PUBLISH_API_KEY_GENERATE",{name:c}),s[2]=o,s[3]=i):i=s[3];let a;s[4]!==e?(a=async()=>{await e.invalidateQueries({queryKey:Q.publishApiKeys()})},s[4]=e,s[5]=a):a=s[5];let l;s[6]!==i||s[7]!==a?(l={mutationFn:i,onSuccess:a},s[6]=i,s[7]=a,s[8]=l):l=s[8];const d=je(l);let u;s[9]!==o?(u=async c=>ve(o,"REGISTRY_PUBLISH_API_KEY_REVOKE",{keyId:c}),s[9]=o,s[10]=u):u=s[10];let m;s[11]!==e?(m=async()=>{await e.invalidateQueries({queryKey:Q.publishApiKeys()})},s[11]=e,s[12]=m):m=s[12];let h;s[13]!==u||s[14]!==m?(h={mutationFn:u,onSuccess:m},s[13]=u,s[14]=m,s[15]=h):h=s[15];const x=je(h);let p;return s[16]!==d||s[17]!==x?(p={generateMutation:d,revokeMutation:x},s[16]=d,s[17]=x,s[18]=p):p=s[18],p}function ns(s){return s?s.split(/[;|]/).map(e=>e.trim()).filter(Boolean):[]}function is(s){const e=[];let r="",n=!1;for(let o=0;o<s.length;o+=1){const i=s[o],a=s[o+1];if(i==='"'){n&&a==='"'?(r+='"',o+=1):n=!n;continue}if(i===","&&!n){e.push(r.trim()),r="";continue}r+=i}return e.push(r.trim()),e}const Fr=["id","title"],Br=["id","title","description","remote_url","remote_type","tags","categories","is_public"];function Qr(s){const e=s.split(/\r?\n/).map(u=>u.trim()).filter(Boolean);if(e.length<2)return{items:[],warnings:[{line:0,message:"CSV must have a header row and at least one data row"}],skipped:0};const r=is(e[0]??""),n=new Map,o=[];r.forEach((u,m)=>{const h=u.toLowerCase().trim();h&&n.set(h,m)});for(const u of Fr)n.has(u)||o.push({line:1,message:`Missing required column: "${u}"`});for(const u of r){const m=u.toLowerCase().trim();m&&!Br.includes(m)&&o.push({line:1,message:`Unknown column "${u}" will be ignored`})}if(!n.has("id")||!n.has("title"))return{items:[],warnings:o,skipped:0};const i=(u,m)=>{const h=n.get(m);return typeof h=="number"?u[h]??"":""},a=[],l=new Set;let d=0;for(let u=1;u<e.length;u+=1){const m=is(e[u]??""),h=i(m,"id").trim(),x=i(m,"title").trim();if(!h){o.push({line:u+1,message:"Missing id — row skipped"}),d+=1;continue}if(!x){o.push({line:u+1,message:`Missing title for id="${h}" — row skipped`}),d+=1;continue}if(l.has(h)){o.push({line:u+1,message:`Duplicate id="${h}" — row skipped`}),d+=1;continue}l.add(h);const p=i(m,"description").trim(),c=i(m,"remote_url").trim(),j=i(m,"remote_type").trim().toLowerCase()==="sse"?"sse":"http",C=ns(i(m,"tags")),_=ns(i(m,"categories")),y=i(m,"is_public").trim().toLowerCase(),g=y==="true"||y==="1"||y==="yes";a.push({id:h,title:x,description:p||null,is_public:g,_meta:{"mcp.mesh":{...C.length>0?{tags:C}:{},..._.length>0?{categories:_}:{}}},server:{name:h,title:x,description:p||void 0,remotes:c?[{type:j,url:c}]:[]}})}return{items:a,warnings:o,skipped:d}}const Vr=`id,title,description,remote_url,remote_type,tags,categories,is_public
24
24
  my-mcp-server,My MCP Server,A useful MCP server,https://example.com/mcp,http,ai|tools,productivity,true
25
- another-server,Another Server,Another useful server,https://example2.com/mcp,http,data|analytics,data-processing,false`;function Gr(){const s=new Blob([Vr],{type:"text/csv;charset=utf-8"}),e=URL.createObjectURL(s),r=document.createElement("a");r.href=e,r.download="registry-import-template.csv",r.click(),URL.revokeObjectURL(e)}function Kr(s){const e=Y.c(63),{open:r,onOpenChange:n,isImporting:o,onImport:i}=s,a=o===void 0?!1:o,[l,d]=I.useState(null),[u,m]=I.useState(null),[h,x]=I.useState(null),p=I.useRef(null);let c;e[0]!==n?(c=H=>{n(H),H||(d(null),m(null),x(null),p.current&&(p.current.value=""))},e[0]=n,e[1]=c):c=e[1];const f=c;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=async H=>{if(!H)return;x(H.name),m(null);const xe=await H.text();d(Qr(xe))},e[2]=j):j=e[2];const C=j;let _;e[3]!==i||e[4]!==l?(_=async()=>{if(!l?.items.length)return;const H=await i(l.items);m(H)},e[3]=i,e[4]=l,e[5]=_):_=e[5];const y=_;let g;e[6]!==l?.items?(g=l?.items??[],e[6]=l?.items,e[7]=g):g=e[7];const P=g;let R;e[8]!==l?.warnings?(R=l?.warnings??[],e[8]=l?.warnings,e[9]=R):R=e[9];const w=R;let k;e[10]!==w?(k=w.some(Jr),e[10]=w,e[11]=k):k=e[11];const T=k,N=u!==null;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsxs(xt,{children:[t.jsx(ht,{children:"Import MCP Servers from CSV"}),t.jsx(pt,{children:"Upload a CSV file to bulk-import MCP servers into the registry."})]}),e[12]=E):E=e[12];let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=()=>p.current?.click(),e[13]=v):v=e[13];let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(Jt,{size:14}),e[14]=D):D=e[14];const O=h?"Change file":"Choose CSV file";let M;e[15]!==a||e[16]!==O?(M=t.jsxs(G,{variant:"outline",size:"sm",className:"gap-1.5",onClick:v,disabled:a,children:[D,O]}),e[15]=a,e[16]=O,e[17]=M):M=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("input",{ref:p,type:"file",accept:".csv,text/csv",className:"hidden",onChange:H=>C(H.target.files?.[0]??null)}),e[18]=A):A=e[18];let $;e[19]!==h?($=h&&t.jsx("span",{className:"text-sm text-muted-foreground truncate",children:h}),e[19]=h,e[20]=$):$=e[20];let z;e[21]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("div",{className:"flex-1"}),e[21]=z):z=e[21];let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground",onClick:Gr,children:[t.jsx(Ks,{size:14}),"Download template"]}),e[22]=L):L=e[22];let b;e[23]!==M||e[24]!==$?(b=t.jsxs("div",{className:"flex items-center gap-3",children:[M,A,$,z,L]}),e[23]=M,e[24]=$,e[25]=b):b=e[25];let U;e[26]!==w?(U=w.length>0&&t.jsx("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 dark:border-yellow-900 dark:bg-yellow-950/30 p-3 grid gap-1",children:w.map(Wr)}),e[26]=w,e[27]=U):U=e[27];let K;e[28]!==P||e[29]!==l?(K=P.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:"Preview"}),t.jsxs(F,{variant:"secondary",children:[P.length," items"]}),l?.skipped?t.jsxs(F,{variant:"outline",className:"text-yellow-600",children:[l.skipped," skipped"]}):null]}),t.jsx("div",{className:"border rounded-lg overflow-hidden",children:t.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:t.jsxs(Et,{children:[t.jsx(Dt,{children:t.jsxs(Fe,{children:[t.jsx(ue,{className:"w-[140px]",children:"ID"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Remote URL"}),t.jsx(ue,{className:"w-[80px] text-center",children:"Public"}),t.jsx(ue,{children:"Tags"})]})}),t.jsx(At,{children:P.map(Hr)})]})})})]}),e[28]=P,e[29]=l,e[30]=K):K=e[30];let te;e[31]!==u?(te=u&&t.jsxs("div",{className:"rounded-lg border p-3 grid gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[t.jsx(qe,{size:16,className:"text-emerald-600"}),"Imported ",u.created," item(s) successfully"]}),u.errors.length>0&&t.jsx("div",{className:"grid gap-1 mt-1",children:u.errors.map(Yr)})]}),e[31]=u,e[32]=te):te=e[32];let ee;e[33]!==N||e[34]!==l?(ee=!l&&!N&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx(Jt,{size:32,className:"text-muted-foreground/40 mb-3"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a CSV file or download the template to get started."}),t.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Required columns: ",t.jsx("code",{children:"id"}),", ",t.jsx("code",{children:"title"}),". Optional:"," ",t.jsx("code",{children:"description"}),", ",t.jsx("code",{children:"remote_url"}),","," ",t.jsx("code",{children:"remote_type"}),", ",t.jsx("code",{children:"tags"}),","," ",t.jsx("code",{children:"categories"}),", ",t.jsx("code",{children:"is_public"}),"."]}),t.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Use ",t.jsx("code",{children:"|"})," or ",t.jsx("code",{children:";"})," to separate multiple tags/categories within a cell."]})]}),e[33]=N,e[34]=l,e[35]=ee):ee=e[35];let se;e[36]!==b||e[37]!==U||e[38]!==K||e[39]!==te||e[40]!==ee?(se=t.jsxs("div",{className:"flex-1 overflow-y-auto grid gap-4 pr-1",children:[b,U,K,te,ee]}),e[36]=b,e[37]=U,e[38]=K,e[39]=te,e[40]=ee,e[41]=se):se=e[41];let re;e[42]!==f?(re=()=>f(!1),e[42]=f,e[43]=re):re=e[43];const pe=N?"Done":"Cancel";let fe;e[44]!==re||e[45]!==pe?(fe=t.jsx(G,{variant:"outline",onClick:re,children:pe}),e[44]=re,e[45]=pe,e[46]=fe):fe=e[46];let ge;e[47]!==y||e[48]!==T||e[49]!==N||e[50]!==a||e[51]!==P.length?(ge=!N&&t.jsx(G,{onClick:y,disabled:a||P.length===0||T,children:a?"Importing...":`Import ${P.length} item(s)`}),e[47]=y,e[48]=T,e[49]=N,e[50]=a,e[51]=P.length,e[52]=ge):ge=e[52];let be;e[53]!==fe||e[54]!==ge?(be=t.jsxs(ft,{className:"gap-2 sm:gap-0",children:[fe,ge]}),e[53]=fe,e[54]=ge,e[55]=be):be=e[55];let S;e[56]!==se||e[57]!==be?(S=t.jsxs(gt,{className:"sm:max-w-3xl max-h-[85vh] flex flex-col",children:[E,se,be]}),e[56]=se,e[57]=be,e[58]=S):S=e[58];let W;return e[59]!==f||e[60]!==r||e[61]!==S?(W=t.jsx(jt,{open:r,onOpenChange:f,children:S}),e[59]=f,e[60]=r,e[61]=S,e[62]=W):W=e[62],W}function Yr(s){return t.jsxs("p",{className:"text-xs text-destructive flex items-start gap-1.5",children:[t.jsx(Ke,{size:12,className:"shrink-0 mt-0.5"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:s.id}),": ",s.error]})]},s.id)}function Hr(s){return t.jsxs(Fe,{children:[t.jsx(me,{className:"font-mono text-xs",children:s.id}),t.jsx(me,{className:"text-sm",children:s.title}),t.jsx(me,{className:"text-xs text-muted-foreground max-w-[200px] truncate",children:s.server.remotes?.[0]?.url??t.jsx("span",{className:"italic",children:"none"})}),t.jsx(me,{className:"text-center",children:s.is_public?t.jsx(F,{variant:"secondary",className:"text-[10px] bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400",children:"Yes"}):t.jsx("span",{className:"text-xs text-muted-foreground",children:"No"})}),t.jsx(me,{className:"text-xs text-muted-foreground",children:(s._meta?.["mcp.mesh"]?.tags??[]).join(", ")||"-"})]},s.id)}function Wr(s,e){return t.jsxs("p",{className:"text-xs text-yellow-700 dark:text-yellow-400 flex items-start gap-1.5",children:[t.jsx(Ke,{size:12,className:"shrink-0 mt-0.5"}),t.jsxs("span",{children:[s.line>0&&t.jsxs("span",{className:"font-mono text-[10px] mr-1",children:["Line ",s.line,":"]}),s.message]})]},`${s.line}-${e}`)}function Jr(s){return s.message.startsWith("Missing required column:")}function Zr(s){const e=Y.c(19),{open:r,onOpenChange:n,title:o,isDeleting:i,onConfirm:a}=s,l=i===void 0?!1:i;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ye,{children:"Delete registry item?"}),e[0]=d):d=e[0];let u;e[1]!==o?(u=t.jsxs(He,{children:[d,t.jsxs(We,{children:["This action cannot be undone. Item ",t.jsx("strong",{children:o})," will be permanently removed from this private registry."]})]}),e[1]=o,e[2]=u):u=e[2];let m;e[3]!==l?(m=t.jsx(Je,{disabled:l,children:"Cancel"}),e[3]=l,e[4]=m):m=e[4];const h=l?"Deleting...":"Delete";let x;e[5]!==l||e[6]!==a||e[7]!==h?(x=t.jsx(Ze,{disabled:l,onClick:a,children:h}),e[5]=l,e[6]=a,e[7]=h,e[8]=x):x=e[8];let p;e[9]!==m||e[10]!==x?(p=t.jsxs(Xe,{children:[m,x]}),e[9]=m,e[10]=x,e[11]=p):p=e[11];let c;e[12]!==u||e[13]!==p?(c=t.jsxs(et,{children:[u,p]}),e[12]=u,e[13]=p,e[14]=c):c=e[14];let f;return e[15]!==n||e[16]!==r||e[17]!==c?(f=t.jsx(tt,{open:r,onOpenChange:n,children:c}),e[15]=n,e[16]=r,e[17]=c,e[18]=f):f=e[18],f}function Xr(s){const[e]=s.id.split("/");return e??"provider"}function en(s){return s._meta?.["mcp.mesh"]?.tags??[]}function tn(s){return s._meta?.["mcp.mesh"]?.categories??[]}function sn(s){return s.server?.icons?.[0]?.src??null}function rn(s){const e=Y.c(77),{item:r,onEdit:n,onDelete:o,onToggleVerified:i,onToggleOfficial:a}=s;let l;e[0]!==r?(l=sn(r),e[0]=r,e[1]=l):l=e[1];const d=l,u=r._meta?.["mcp.mesh"]?.verified===!0,m=r._meta?.["mcp.mesh"]?.official===!0;let h;e[2]!==r?(h=[...en(r),...tn(r)],e[2]=r,e[3]=h):h=e[3];const x=h;let p;e[4]!==x?(p=x.slice(0,3),e[4]=x,e[5]=p):p=e[5];const c=p,f=Math.max(0,x.length-c.length);let j;e[6]!==d||e[7]!==r.title?(j=t.jsx("div",{className:"size-10 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0 flex items-center justify-center",children:d?t.jsx("img",{src:d,alt:r.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:r.title.charAt(0).toUpperCase()})}),e[6]=d,e[7]=r.title,e[8]=j):j=e[8];let C;e[9]!==r.title?(C=t.jsx("p",{className:"font-medium truncate",children:r.title}),e[9]=r.title,e[10]=C):C=e[10];let _;e[11]!==r?(_=Xr(r),e[11]=r,e[12]=_):_=e[12];let y;e[13]!==_?(y=t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:_}),e[13]=_,e[14]=y):y=e[14];let g;e[15]!==r.is_public?(g=r.is_public?t.jsxs(F,{variant:"default",className:"gap-1",children:[t.jsx(ds,{size:10}),"Public"]}):t.jsx(F,{variant:"secondary",children:"Private"}),e[15]=r.is_public,e[16]=g):g=e[16];let P;e[17]!==m?(P=m&&t.jsxs(F,{variant:"outline",className:"gap-1 text-primary",children:[t.jsx(Zt,{size:10}),"Official"]}),e[17]=m,e[18]=P):P=e[18];let R;e[19]!==m||e[20]!==u?(R=!m&&u&&t.jsxs(F,{variant:"outline",className:"gap-1 text-success",children:[t.jsx(Zt,{size:10}),"Verified"]}),e[19]=m,e[20]=u,e[21]=R):R=e[21];let w;e[22]!==R||e[23]!==y||e[24]!==g||e[25]!==P?(w=t.jsxs("div",{className:"flex items-center gap-2",children:[y,g,P,R]}),e[22]=R,e[23]=y,e[24]=g,e[25]=P,e[26]=w):w=e[26];let k;e[27]!==w||e[28]!==C?(k=t.jsxs("div",{className:"min-w-0 flex-1",children:[C,w]}),e[27]=w,e[28]=C,e[29]=k):k=e[29];let T;e[30]!==k||e[31]!==j?(T=t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[j,k]}),e[30]=k,e[31]=j,e[32]=T):T=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(dt,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:t.jsx(Mt,{size:18})})}),e[33]=N):N=e[33];let E;e[34]!==r||e[35]!==n?(E=t.jsx(Ce,{onClick:()=>n(r),children:"Edit"}),e[34]=r,e[35]=n,e[36]=E):E=e[36];let v;e[37]!==r||e[38]!==i?(v=()=>i(r),e[37]=r,e[38]=i,e[39]=v):v=e[39];const D=u?"Unmark as Verified":"Mark as Verified";let O;e[40]!==v||e[41]!==D?(O=t.jsx(Ce,{onClick:v,children:D}),e[40]=v,e[41]=D,e[42]=O):O=e[42];let M;e[43]!==r||e[44]!==a?(M=()=>a(r),e[43]=r,e[44]=a,e[45]=M):M=e[45];const A=m?"Unmark as Official":"Mark as Official";let $;e[46]!==M||e[47]!==A?($=t.jsx(Ce,{onClick:M,children:A}),e[46]=M,e[47]=A,e[48]=$):$=e[48];let z;e[49]!==r||e[50]!==o?(z=()=>o(r),e[49]=r,e[50]=o,e[51]=z):z=e[51];let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(st,{size:14}),e[52]=L):L=e[52];let b;e[53]!==z?(b=t.jsxs(Ce,{variant:"destructive",onClick:z,children:[L,"Delete"]}),e[53]=z,e[54]=b):b=e[54];let U;e[55]!==E||e[56]!==O||e[57]!==$||e[58]!==b?(U=t.jsxs(ut,{children:[N,t.jsxs(mt,{align:"end",children:[E,O,$,b]})]}),e[55]=E,e[56]=O,e[57]=$,e[58]=b,e[59]=U):U=e[59];let K;e[60]!==T||e[61]!==U?(K=t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[T,U]}),e[60]=T,e[61]=U,e[62]=K):K=e[62];const te=r._meta?.["mcp.mesh"]?.short_description||r.description||r.server.description||"No description provided.";let ee;e[63]!==te?(ee=t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 min-h-10",children:te}),e[63]=te,e[64]=ee):ee=e[64];let se;e[65]!==r.id||e[66]!==c?(se=c.map(ge=>t.jsx(F,{variant:"secondary",children:ge},`${r.id}-badge-${ge}`)),e[65]=r.id,e[66]=c,e[67]=se):se=e[67];let re;e[68]!==f?(re=f>0&&t.jsxs(F,{variant:"outline",children:["+",f]}),e[68]=f,e[69]=re):re=e[69];let pe;e[70]!==se||e[71]!==re?(pe=t.jsxs("div",{className:"flex flex-wrap gap-1",children:[se,re]}),e[70]=se,e[71]=re,e[72]=pe):pe=e[72];let fe;return e[73]!==K||e[74]!==ee||e[75]!==pe?(fe=t.jsxs(ne,{className:"p-4 gap-4 transition-colors hover:bg-muted/50",children:[K,ee,pe]}),e[73]=K,e[74]=ee,e[75]=pe,e[76]=fe):fe=e[76],fe}function vs(s){const e=Y.c(28),{value:r,onChange:n,onBlur:o,onFileUpload:i,error:a,isUploading:l}=s,d=l===void 0?!1:l,[u,m]=I.useState(!1),[h,x]=I.useState(!1),p=I.useRef(null);let c;e[0]!==d?(c=v=>{v.preventDefault(),d||m(!0)},e[0]=d,e[1]=c):c=e[1];const f=c;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=v=>{v.preventDefault(),m(!1)},e[2]=j):j=e[2];const C=j;let _;e[3]!==d||e[4]!==i?(_=async v=>{if(v.preventDefault(),m(!1),d)return;const D=v.dataTransfer.files[0];D&&await i(D)},e[3]=d,e[4]=i,e[5]=_):_=e[5];const y=_;let g;e[6]!==d||e[7]!==i?(g=async v=>{const D=v.target.files?.[0];D&&!d&&await i(D),v.target.value=""},e[6]=d,e[7]=i,e[8]=g):g=e[8];const P=g,R=r.length>0;let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(X,{children:"Image"}),e[9]=w):w=e[9];let k;e[10]!==f||e[11]!==y||e[12]!==R||e[13]!==u||e[14]!==d||e[15]!==o||e[16]!==n||e[17]!==h||e[18]!==r?(k=R?t.jsx("div",{className:"relative group min-h-[180px] rounded-xl border border-border overflow-hidden bg-muted/10",children:t.jsxs("div",{className:"flex items-center gap-3 p-3 h-full",children:[t.jsx("div",{className:"size-20 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0",children:t.jsx("img",{src:r,alt:"Preview",className:"w-full h-full object-cover"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",onClick:()=>p.current?.click(),disabled:d,children:[t.jsx($t,{className:"size-3"}),"Change"]}),t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-destructive hover:text-destructive",onClick:()=>{n(""),x(!1)},disabled:d,children:[t.jsx(st,{className:"size-3"}),"Remove"]})]})]})]})}):d?t.jsxs("div",{className:"relative min-h-[180px] rounded-xl border border-border bg-muted/10 flex flex-col items-center justify-center gap-3",children:[t.jsx(Le,{className:"size-8 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading image..."})]}):t.jsxs("div",{className:Z("relative min-h-[180px] rounded-xl border-2 border-dashed transition-colors cursor-pointer flex flex-col",u?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/40 hover:bg-muted/30"),onDragOver:f,onDragLeave:C,onDrop:y,onClick:()=>p.current?.click(),children:[t.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-6 px-4 flex-1",children:[t.jsx("div",{className:Z("size-10 rounded-lg flex items-center justify-center transition-colors",u?"bg-primary/10 text-primary":"bg-muted/50 text-muted-foreground"),children:t.jsx(nr,{size:20})}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:u?"Drop image here":"Click or drag to upload"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"PNG, JPG, SVG up to 2MB"})]})]}),h?t.jsx("div",{className:"border-t border-border px-3 py-2",onClick:nn,children:t.jsx(ae,{placeholder:"https://example.com/logo.png",value:r,className:"text-xs h-8",onChange:v=>n(v.target.value),onBlur:o})}):t.jsx("div",{className:"border-t border-border px-4 py-2",children:t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-full justify-center",onClick:v=>{v.stopPropagation(),x(!0)},children:[t.jsx(Ys,{className:"size-3"}),"Or paste an image URL"]})})]}),e[10]=f,e[11]=y,e[12]=R,e[13]=u,e[14]=d,e[15]=o,e[16]=n,e[17]=h,e[18]=r,e[19]=k):k=e[19];let T;e[20]!==P?(T=t.jsx("input",{ref:p,type:"file",accept:"image/*",className:"hidden",onChange:P}),e[20]=P,e[21]=T):T=e[21];let N;e[22]!==a?(N=a&&t.jsx("p",{className:"text-xs text-destructive",children:a}),e[22]=a,e[23]=N):N=e[23];let E;return e[24]!==k||e[25]!==T||e[26]!==N?(E=t.jsxs("div",{className:"grid gap-1.5",children:[w,k,T,N]}),e[24]=k,e[25]=T,e[26]=N,e[27]=E):E=e[27],E}function nn(s){return s.stopPropagation()}function bs(){const[s,e]=I.useState("idle"),[r,n]=I.useState(null),{org:o}=ie(),i=oe({connectionId:ce,orgId:o.id});return{discover:async(d,u)=>{if(!d)return null;e("loading"),n(null);try{const m=await i.callTool({name:"REGISTRY_DISCOVER_TOOLS",arguments:{url:d,type:u==="sse"?"sse":"http"}}),h=m.structuredContent??m;if(m.isError){const x=m.content?.find(p=>p.type==="text")?.text??"Tool returned an error";return n(x),e("error"),null}return h.error?ln(h.error)?(n(h.error),e("auth_required"),null):(n(h.error),e("error"),null):!h.tools||h.tools.length===0?(n("No tools found on this MCP server."),e("error"),null):(e("success"),h.tools)}catch(m){const h=m instanceof Error?m.message:String(m);return n(h||"Could not discover tools."),e("error"),null}},discoverStatus:s,discoverError:r,resetDiscover:()=>{e("idle"),n(null)}}}function ln(s){const e=s.toLowerCase();return e.includes("authentication")||e.includes("unauthorized")||e.includes("credentials")}function an(s){const e=Y.c(54),{tools:r,onChange:n,remoteUrl:o,remoteType:i,externalDiscoverStatus:a,externalDiscoverError:l}=s,[d,u]=I.useState(r.length>0),{discover:m,discoverStatus:h,discoverError:x,resetDiscover:p}=bs(),c=a??h,f=l??x;let j;e[0]!==m||e[1]!==n||e[2]!==i||e[3]!==o?(j=async()=>{if(!o)return;const L=await m(o,i??"http");L&&(n(L),u(!0))},e[0]=m,e[1]=n,e[2]=i,e[3]=o,e[4]=j):j=e[4];const C=j;let _;e[5]!==n||e[6]!==p?(_=()=>{n([]),p()},e[5]=n,e[6]=p,e[7]=_):_=e[7];const y=_;let g;e[8]!==d?(g=()=>u(!d),e[8]=d,e[9]=g):g=e[9];let P,R;e[10]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(us,{size:14,className:"text-muted-foreground"}),R=t.jsx("span",{children:"Tools"}),e[10]=P,e[11]=R):(P=e[10],R=e[11]);let w;e[12]!==r.length?(w=r.length>0&&t.jsx(F,{variant:"secondary",className:"text-xs px-1.5 py-0",children:r.length}),e[12]=r.length,e[13]=w):w=e[13];let k;e[14]!==d?(k=d?t.jsx(pr,{size:14,className:"text-muted-foreground"}):t.jsx(hr,{size:14,className:"text-muted-foreground"}),e[14]=d,e[15]=k):k=e[15];let T;e[16]!==g||e[17]!==w||e[18]!==k?(T=t.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm font-medium cursor-pointer",onClick:g,children:[P,R,w,k]}),e[16]=g,e[17]=w,e[18]=k,e[19]=T):T=e[19];let N;e[20]!==y||e[21]!==r.length?(N=r.length>0&&t.jsxs(G,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs gap-1.5 text-muted-foreground",onClick:y,children:[t.jsx(st,{size:12}),"Clear"]}),e[20]=y,e[21]=r.length,e[22]=N):N=e[22];let E;e[23]!==c||e[24]!==C||e[25]!==o||e[26]!==r.length?(E=o&&t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 border-green-500/30 text-green-600 dark:text-green-400 shadow-[0_0_8px_rgba(34,197,94,0.3)] hover:shadow-[0_0_14px_rgba(34,197,94,0.5)] hover:border-green-500/50 transition-all",onClick:C,disabled:c==="loading",children:[c==="loading"?t.jsx(Le,{size:12,className:"animate-spin"}):t.jsx($t,{size:12}),c==="loading"?"Discovering...":r.length>0?"Refresh":"Auto-discover"]}),e[23]=c,e[24]=C,e[25]=o,e[26]=r.length,e[27]=E):E=e[27];let v;e[28]!==E||e[29]!==N?(v=t.jsxs("div",{className:"flex items-center gap-2",children:[N,E]}),e[28]=E,e[29]=N,e[30]=v):v=e[30];let D;e[31]!==v||e[32]!==T?(D=t.jsxs("div",{className:"flex items-center justify-between",children:[T,v]}),e[31]=v,e[32]=T,e[33]=D):D=e[33];let O;e[34]!==c||e[35]!==r.length?(O=c==="success"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-950/30 rounded-lg px-3 py-2",children:[t.jsx(qe,{size:14,className:"shrink-0"}),t.jsxs("span",{children:["Discovered ",r.length," tool",r.length!==1?"s":""," ","successfully."]})]}),e[34]=c,e[35]=r.length,e[36]=O):O=e[36];let M;e[37]!==f||e[38]!==c?(M=c==="error"&&f&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 rounded-lg px-3 py-2",children:[t.jsx(Ke,{size:14,className:"shrink-0"}),t.jsx("span",{children:f})]}),e[37]=f,e[38]=c,e[39]=M):M=e[39];let A;e[40]!==d||e[41]!==r?(A=d&&r.length>0&&t.jsx("div",{className:"rounded-xl border border-border divide-y divide-border overflow-hidden max-h-48 overflow-y-auto",children:r.map(on)}),e[40]=d,e[41]=r,e[42]=A):A=e[42];let $;e[43]!==c||e[44]!==d||e[45]!==o||e[46]!==r.length?($=d&&r.length===0&&c==="idle"&&t.jsx("p",{className:"text-xs text-muted-foreground px-1",children:o?'Click "Auto-discover" to load tools from the MCP server.':"Add a Remote URL first, then tools can be auto-discovered."}),e[43]=c,e[44]=d,e[45]=o,e[46]=r.length,e[47]=$):$=e[47];let z;return e[48]!==D||e[49]!==O||e[50]!==M||e[51]!==A||e[52]!==$?(z=t.jsxs("div",{className:"space-y-3",children:[D,O,M,A,$]}),e[48]=D,e[49]=O,e[50]=M,e[51]=A,e[52]=$,e[53]=z):z=e[53],z}function on(s){return t.jsx("div",{className:"flex items-center gap-3 px-3 py-2",children:t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-mono truncate",children:s.name}),s.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description})]})},s.name)}function ys(s){const{org:e}=ie(),[r,n]=I.useState(!1),i=typeof window<"u"&&window.location.hostname==="localhost"?`${e.id}_dev-assets`:null,a=oe({connectionId:i??"noop",orgId:e.id});return{uploadImage:async(d,u)=>{if(!i)return V.error("Image upload requires an object-storage connection. Configure one in plugin settings."),null;if(!d.type.startsWith("image/"))return V.error("Only image files are supported"),null;if(d.size>5*1024*1024)return V.error("Image size must be less than 5MB"),null;n(!0);try{const m=await a.callTool({name:"PUT_PRESIGNED_URL",arguments:{key:u,contentType:d.type}}),h=m.structuredContent?.url||m.url;if(!h)throw new Error("Failed to get presigned URL");const x=await fetch(h,{method:"PUT",body:d,headers:{"Content-Type":d.type}});if(!x.ok)throw new Error(`Upload failed: ${x.statusText}`);const p=await a.callTool({name:"GET_PRESIGNED_URL",arguments:{key:u,expiresIn:31536e3}}),c=p.structuredContent?.url||p.url;if(!c)throw new Error("Failed to get public URL");return c}catch(m){return console.error("Image upload failed:",m),V.error(m instanceof Error?m.message:"Failed to upload image. Please try again."),null}finally{n(!1)}},isUploading:r}}const cn=new Set(["http","sse","stdio"]),dn=/^[a-z0-9]+(?:[/-][a-z0-9._-]+)*$/,un=["internal","automation","support","sales","ops","ai"],mn=["productivity","communication","customer-support","development","data","operations"],xn=["Essentials","Details","Advanced"],hn="h-7 text-xs border-green-500/30 text-green-600 dark:text-green-400 shadow-[0_0_8px_rgba(34,197,94,0.3)] hover:shadow-[0_0_14px_rgba(34,197,94,0.5)] hover:border-green-500/50 transition-all";function ls(s){return s.replace(/^https?:\/\//i,"").trim()}function Ge(s){const e=s.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function ze(s){return s.trim().toLowerCase()}function bt(s){return Array.from(new Set(s.map(ze).filter(e=>e.length>0)))}function Ae(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function pn(s){const e=Y.c(4),{current:r}=s;let n;e[0]!==r?(n=xn.map((i,a)=>{const l=a+1,d=l===r,u=l<r;return t.jsxs("div",{className:"flex items-center gap-1.5",children:[a>0&&t.jsx("div",{className:Z("w-4 h-px",u?"bg-primary":"bg-border")}),t.jsxs("div",{className:Z("flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs transition-colors",d?"bg-primary/10 text-primary font-medium":u?"text-primary":"text-muted-foreground"),children:[t.jsx("span",{className:Z("size-5 rounded-full inline-flex items-center justify-center text-[10px] font-semibold shrink-0",d?"bg-primary text-primary-foreground":u?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"),children:l}),t.jsx("span",{className:"hidden sm:inline",children:i})]})]},i)}),e[0]=r,e[1]=n):n=e[1];let o;return e[2]!==n?(o=t.jsx("div",{className:"flex items-center gap-1.5",children:n}),e[2]=n,e[3]=o):o=e[3],o}function fn(s){const e=Y.c(28),{id:r,label:n,values:o,availableOptions:i,placeholder:a,onChange:l}=s,[d,u]=I.useState(""),[m,h]=I.useState(!1);let x,p,c,f,j;if(e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==n||e[5]!==l||e[6]!==a||e[7]!==o){const y=bt(i),g=bt(o),P=new Set(g),R=ze(d),w=y.filter(M=>!P.has(M)).filter(M=>R?M.includes(R):!0).slice(0,8),k=M=>{const A=ze(M);!A||P.has(A)||l([...g,A])},T=M=>{l(g.filter(A=>A!==M))},N=()=>{const M=d.split(/[,\n;]/).map(ze).filter(Boolean);if(M.length===0)return;const A=[...g];for(const $ of M)A.includes($)||A.push($);l(A),u("")},E=R;f="grid gap-2",e[13]!==r||e[14]!==n?(j=t.jsx(X,{htmlFor:r,children:n}),e[13]=r,e[14]=n,e[15]=j):j=e[15],x="relative";let v;e[16]!==r?(v=()=>{const M=document.getElementById(r);M instanceof HTMLInputElement&&M.focus()},e[16]=r,e[17]=v):v=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=()=>h(!0),e[18]=D):D=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=M=>u(M.target.value),e[19]=O):O=e[19],p=t.jsx("div",{className:"min-h-9 w-full rounded-xl border border-input bg-background px-2.5 py-1.5 text-sm focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",onClick:v,children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[g.map(M=>t.jsxs(F,{variant:"secondary",className:"gap-1",children:[M,t.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),T(M)},children:t.jsx(xr,{size:12})})]},`${r}-${M}`)),t.jsx("input",{id:r,className:"flex-1 min-w-[120px] bg-transparent outline-none border-none text-sm",placeholder:g.length?"":a,value:d,onFocus:D,onBlur:()=>{h(!1),N()},onChange:O,onKeyDown:M=>{if(M.key==="Enter"||M.key===","){M.preventDefault(),N();return}M.key==="Backspace"&&!d&&g.length&&T(g[g.length-1]??"")}})]})}),c=m&&t.jsx("div",{className:"absolute z-50 mt-1 w-full rounded-xl border border-border bg-background shadow-lg max-h-56 overflow-y-auto",children:w.length>0?w.map(M=>t.jsx("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:jn,onClick:()=>{k(M),u("")},children:M},`${r}-suggestion-${M}`)):E?t.jsxs("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:gn,onClick:()=>{k(E),u("")},children:['Create "',E,'"']}):t.jsx("div",{className:"px-2.5 py-1.5 text-sm text-muted-foreground",children:"Type to search or create."})}),e[0]=i,e[1]=r,e[2]=d,e[3]=m,e[4]=n,e[5]=l,e[6]=a,e[7]=o,e[8]=x,e[9]=p,e[10]=c,e[11]=f,e[12]=j}else x=e[8],p=e[9],c=e[10],f=e[11],j=e[12];let C;e[20]!==x||e[21]!==p||e[22]!==c?(C=t.jsxs("div",{className:x,children:[p,c]}),e[20]=x,e[21]=p,e[22]=c,e[23]=C):C=e[23];let _;return e[24]!==f||e[25]!==j||e[26]!==C?(_=t.jsxs("div",{className:f,children:[j,C]}),e[24]=f,e[25]=j,e[26]=C,e[27]=_):_=e[27],_}function gn(s){return s.preventDefault()}function jn(s){return s.preventDefault()}function vn({id:s,value:e,availableOptions:r,onChange:n}){const[o,i]=I.useState(e),[a,l]=I.useState(!1),d=I.useRef(e);d.current!==e&&(d.current=e,i(e));const u=bt([...mn,...r,e]).filter(Boolean),m=ze(o),h=u.filter(p=>m?p.includes(m):!0).slice(0,8),x=p=>{const c=ze(p);n(c),i(c),l(!1)};return t.jsxs("div",{className:"grid gap-2",children:[t.jsx(X,{htmlFor:s,children:"Category"}),t.jsxs("div",{className:"relative",children:[t.jsx(ae,{id:s,className:"h-9 text-sm",placeholder:"Select or create category",value:o,onFocus:()=>{i(e),l(!0)},onBlur:()=>{x(o)},onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),x(o))}}),e&&t.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground hover:text-foreground",onMouseDown:p=>p.preventDefault(),onClick:()=>{n(""),i("")},children:"clear"}),a&&t.jsx("div",{className:"absolute z-50 mt-1 w-full rounded-xl border border-border bg-background shadow-lg max-h-56 overflow-y-auto",children:h.length>0?h.map(p=>t.jsx("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:c=>c.preventDefault(),onClick:()=>x(p),children:p},`${s}-${p}`)):m?t.jsxs("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:p=>p.preventDefault(),onClick:()=>x(m),children:['Create "',m,'"']}):t.jsx("div",{className:"px-2.5 py-1.5 text-sm text-muted-foreground",children:"Type to search or create."})})]})]})}function bn({open:s,onOpenChange:e,item:r,draft:n,availableTags:o=[],availableCategories:i=[],isSubmitting:a=!1,onSubmit:l}){const{org:d}=ie(),{uploadImage:u,isUploading:m}=ys(),{discover:h,discoverStatus:x,discoverError:p,resetDiscover:c}=bs(),f=!!r,j=n?._meta?.["mcp.mesh"],C=r?.title??n?.title??"",_=r?.id?.split("/")[0]??n?.id?.split("/")[0]??"",y=r?.description??n?.description??"",g=r?._meta?.["mcp.mesh"]?.short_description??j?.short_description??"",P=r?._meta?.["mcp.mesh"]?.owner??j?.owner??"",R=r?.server?.repository?.url??n?.server?.repository?.url??"",w=r?._meta?.["mcp.mesh"]?.readme??j?.readme??"",k=r?._meta?.["mcp.mesh"]?.readme_url??j?.readme_url??"",T=ls(r?.server?.remotes?.[0]?.url??n?.server?.remotes?.[0]?.url??""),N=r?.server?.remotes?.[0]?.type??n?.server?.remotes?.[0]?.type??"http",E=r?._meta?.["mcp.mesh"]?.tags??j?.tags??[],v=r?._meta?.["mcp.mesh"]?.categories?.[0]??j?.categories?.[0]??"",D=r?.server?.icons?.[0]?.src??n?.server?.icons?.[0]?.src??"",O=r?._meta?.["mcp.mesh"]?.tools??j?.tools??[],M=r?.is_public??n?.is_public??!1,A=r?._meta?.["mcp.mesh"]?.verified??j?.verified??!1,$=r?._meta?.["mcp.mesh"]?.official??j?.official??!1,[z,L]=I.useState(1),[b,U]=I.useState(C),[K,te]=I.useState(_),[ee,se]=I.useState(y),[re,pe]=I.useState(g),[fe,ge]=I.useState(P),[be,S]=I.useState(R),[W,H]=I.useState(w),[xe,ye]=I.useState(k),[de,nt]=I.useState(w?"content":"link"),[Me,q]=I.useState(T),[le,it]=I.useState(N),[Ue,Ut]=I.useState(E),[Nt,Lt]=I.useState(v),[Be,wt]=I.useState(D),[we,lt]=I.useState(O),[qt,Ft]=I.useState(M),[Bt,Qt]=I.useState(A),[Vt,Gt]=I.useState($),[he,Qe]=I.useState({}),Kt=()=>{L(1),U(C),te(_),se(y),pe(g),ge(P),S(R),H(w),ye(k),nt(w?"content":"link"),q(T),it(N),Ut(E),Lt(v),wt(D),lt(O),Ft(M),Qt(A),Gt($),Qe({}),c(),at.current="",Pe.current&&(clearTimeout(Pe.current),Pe.current=null)},ks=async B=>{if(!B)return;const J=f?r?.id:`${K}/${b}`.toLowerCase(),Ne=Ae(J||"temp"),Se=B.name.split(".").pop()||"png",Re=`registry/${d.id}/${Ne}/icon.${Se}`,De=await u(B,Re);De?(wt(De),Qe(Te=>({...Te,imageUrl:void 0}))):Qe(Te=>({...Te,imageUrl:"Failed to upload image. Please try again."}))},Pe=I.useRef(null),at=I.useRef(""),_t=I.useRef(le);_t.current=le;const Yt=B=>{!B&&Pe.current&&(clearTimeout(Pe.current),Pe.current=null),e(B),B||Kt()},Ss=async()=>{const B=Ge(Me);if(!B)return;at.current=B;const J=await h(B,_t.current);J&&lt(J)},Rs=B=>{Pe.current&&clearTimeout(Pe.current);const J=Ge(B);!J||J===at.current||B.includes(".")&&(Pe.current=setTimeout(async()=>{at.current=J;const Ne=await h(J,_t.current);Ne&&lt(Ne)},800))},Ht=B=>{const J={};if(B===1){const Ne=Ae(K),Se=Ae(b),Re=`${Ne}/${Se}`;b.trim()||(J.title="Name is required."),f||(Ne?Se?dn.test(Re)||(J.provider="Use lowercase letters/numbers and separators '/' or '-'."):J.title="Name must contain valid characters.":J.provider="Provider is required.");const De=Ge(Me),Te=le.trim().toLowerCase();if(Te!=="stdio"&&De)try{const Ve=new URL(De);["http:","https:"].includes(Ve.protocol)||(J.remoteUrl="Remote URL must be http(s).")}catch{J.remoteUrl="Remote URL is invalid."}if(Te&&!cn.has(Te)&&(J.remoteType="Remote type must be: http, sse or stdio."),Be.trim()&&!Be.trim().startsWith("data:image/"))try{const Ct=new URL(Be.trim());["http:","https:"].includes(Ct.protocol)||(J.imageUrl="Image URL must be http(s).")}catch{J.imageUrl="Image URL is invalid."}}if(B===2&&(ee.length>1500&&(J.description="Description must be 1500 characters or less."),re.trim().length>160&&(J.shortDescription="Short description must be 160 characters or less.")),B===3){const Ne=xe.trim();if(Ne)try{const Re=new URL(Ne);["http:","https:"].includes(Re.protocol)||(J.readmeUrl="README URL must be http(s).")}catch{J.readmeUrl="README URL is invalid."}W.trim().length>5e4&&(J.readme="README must be 50 000 characters or less.");const Se=be.trim();if(Se)try{const Re=new URL(Se);["http:","https:"].includes(Re.protocol)||(J.repositoryUrl="Repository URL must be http(s).")}catch{J.repositoryUrl="Repository URL is invalid."}}return Qe(J),Object.values(J).every(Ne=>Ne===void 0)},Ts=()=>{Ht(z)&&z<3&&L(z+1)},Is=()=>{z>1&&L(z-1)},Ps=async()=>{if(!Ht(3))return;const B=b.trim(),J=Ae(K),Ne=Ae(B),Se=`${J}/${Ne}`,Re=Ge(Me),De=le.trim().toLowerCase(),Te=Be.trim(),Ve=be.trim(),Ct=re.trim(),As=W.trim(),$s=xe.trim(),Os=bt(Ue),zs=Nt?[ze(Nt)]:[],Us=r?r.server?.name??r.id:"",Ls=(f?Us:Se).trim(),kt=ee.trim(),qs=fe.trim(),Wt={title:B,description:kt.length>0?kt:null,is_public:qt,_meta:{"mcp.mesh":{verified:Bt,official:Vt,tags:Os,categories:zs,short_description:Ct||null,owner:qs||null,readme:As||null,readme_url:$s||null,...we.length>0?{tools:we}:{}}},server:{name:Ls,title:B,description:kt||void 0,icons:Te?[{src:Te}]:[],repository:Ve?{url:Ve}:void 0,remotes:Re?[{type:De||"http",url:Re}]:[]}};if(f&&r){await l({id:r.id,data:Wt}),e(!1);return}await l({id:Se,...Wt}),e(!1),Kt()},Ms=t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"row-span-2 grid gap-3 content-start",children:[t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-provider",children:"Provider"}),t.jsx(ae,{id:"registry-item-provider",className:"h-9 text-sm",placeholder:"acme",value:K,onChange:B=>te(B.target.value),disabled:f}),!f&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Item ID:"," ",t.jsx("span",{className:"font-mono",children:`${Ae(K)||"provider"}/${Ae(b)||"name"}`})]}),he.provider&&t.jsx("p",{className:"text-xs text-destructive",children:he.provider})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-title",children:"Name"}),t.jsx(ae,{id:"registry-item-title",className:"h-9 text-sm",placeholder:"Internal MCP",value:b,onChange:B=>U(B.target.value)}),he.title&&t.jsx("p",{className:"text-xs text-destructive",children:he.title})]})]}),t.jsx("div",{className:"row-span-2 content-start",children:t.jsx(vs,{value:Be,onChange:B=>{wt(B),Qe(J=>({...J,imageUrl:void 0}))},onFileUpload:ks,error:he.imageUrl,isUploading:m})}),t.jsxs("div",{className:"col-span-2 grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-remote-url",children:"Remote URL"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex-1 flex items-center rounded-xl border border-input px-3",children:[t.jsx("span",{className:"text-xs font-semibold text-muted-foreground mr-1",children:"https://"}),t.jsx("input",{id:"registry-remote-url",className:"flex-1 h-9 bg-transparent outline-none text-sm",placeholder:"example.com/mcp",value:Me,onChange:B=>{const J=ls(B.target.value);q(J),Rs(J)}})]}),t.jsxs(cr,{value:le,onValueChange:it,children:[t.jsx(dr,{id:"registry-remote-type",className:"w-[90px] h-9 shrink-0",children:t.jsx(ur,{placeholder:"Type"})}),t.jsxs(mr,{children:[t.jsx(Rt,{value:"http",children:"http"}),t.jsx(Rt,{value:"sse",children:"sse"}),t.jsx(Rt,{value:"stdio",children:"stdio"})]})]})]}),he.remoteUrl&&t.jsx("p",{className:"text-xs text-destructive",children:he.remoteUrl}),he.remoteType&&t.jsx("p",{className:"text-xs text-destructive",children:he.remoteType})]}),Me.trim()&&t.jsxs("div",{className:"col-span-2 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:Z(hn,"gap-1.5"),onClick:Ss,disabled:x==="loading",children:[x==="loading"?t.jsx(Le,{size:12,className:"animate-spin"}):t.jsx($t,{size:12}),x==="loading"?"Discovering tools...":we.length>0?"Re-discover tools":"Discover tools from URL"]}),we.length>0&&x!=="loading"&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:[we.length," tool",we.length!==1?"s":""," loaded"]})]}),x==="success"&&we.length>0&&t.jsxs("div",{className:"rounded-lg border border-green-500/20 bg-green-50 dark:bg-green-950/20 px-3 py-2 space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-green-600 dark:text-green-400",children:[t.jsx(qe,{size:14,className:"shrink-0"}),t.jsxs("span",{className:"font-medium",children:[we.length," tool",we.length!==1?"s":""," discovered"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[we.slice(0,8).map(B=>t.jsx(F,{variant:"secondary",className:"text-[10px] px-1.5 py-0 font-mono",children:B.name},B.name)),we.length>8&&t.jsxs("span",{className:"text-[10px] text-muted-foreground self-center",children:["+",we.length-8," more"]})]}),t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"These tools will enrich AI-generated descriptions, tags and categories in the next step."})]}),x==="auth_required"&&p&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-950/20 border border-amber-500/20 rounded-lg px-3 py-2",children:[t.jsx(Ke,{size:14,className:"shrink-0"}),t.jsx("span",{children:"This server requires authentication. The connection is valid but tools cannot be listed without credentials."})]}),x==="error"&&p&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 rounded-lg px-3 py-2",children:[t.jsx(Ke,{size:14,className:"shrink-0"}),t.jsx("span",{children:p})]})]})]}),Es=t.jsxs("div",{className:"grid gap-3",children:[t.jsxs("div",{className:"grid gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(X,{htmlFor:"registry-item-short-description",children:"Short Description"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[re.length,"/160"]})]}),t.jsx(ae,{id:"registry-item-short-description",className:"h-9 text-sm",placeholder:"Short summary for the store card",value:re,maxLength:160,onChange:B=>pe(B.target.value)}),he.shortDescription&&t.jsx("p",{className:"text-xs text-destructive",children:he.shortDescription})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(X,{htmlFor:"registry-item-description",children:"Description"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[ee.length,"/1500"]})]}),t.jsx(vt,{id:"registry-item-description",className:"text-sm max-h-28 overflow-y-auto resize-none",placeholder:"Brief description of this MCP server",rows:2,value:ee,onChange:B=>se(B.target.value)}),he.description&&t.jsx("p",{className:"text-xs text-destructive",children:he.description})]}),t.jsx("div",{className:"border-t border-border"}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx("div",{className:"grid content-start gap-2",children:t.jsx(vn,{id:"registry-category",value:Nt,availableOptions:i,onChange:Lt})}),t.jsx("div",{className:"grid content-start gap-2",children:t.jsx(fn,{id:"registry-tags",label:"Tags",values:Ue,availableOptions:[...un,...o],placeholder:"Type and press Enter or comma",onChange:Ut})})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-4 py-3",children:[t.jsxs("div",{className:"grid gap-0.5",children:[t.jsx(X,{htmlFor:"registry-is-public",className:"text-sm",children:"Public"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this MCP visible in the public store URL."})]}),t.jsx(Oe,{id:"registry-is-public",checked:qt,onCheckedChange:Ft})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-4 py-3",children:[t.jsxs("div",{className:"grid gap-0.5",children:[t.jsx(X,{htmlFor:"registry-is-verified",className:"text-sm",children:"Verified"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Curated and approved by deco."})]}),t.jsx(Oe,{id:"registry-is-verified",checked:Bt,onCheckedChange:Qt})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-4 py-3",children:[t.jsxs("div",{className:"grid gap-0.5",children:[t.jsx(X,{htmlFor:"registry-is-official",className:"text-sm",children:"Official"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Made and hosted by the service provider."})]}),t.jsx(Oe,{id:"registry-is-official",checked:Vt,onCheckedChange:Gt})]})]}),Ds=t.jsxs("div",{className:"grid gap-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-owner",children:"Owner (optional)"}),t.jsx(ae,{id:"registry-item-owner",className:"h-9 text-sm",placeholder:"Team, company, or responsible person",value:fe,onChange:B=>ge(B.target.value)})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-repository-url",children:"Repository URL (optional)"}),t.jsx(ae,{id:"registry-item-repository-url",className:"h-9 text-sm",placeholder:"https://github.com/org/repo",value:be,onChange:B=>S(B.target.value)}),he.repositoryUrl&&t.jsx("p",{className:"text-xs text-destructive",children:he.repositoryUrl})]})]}),t.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(X,{children:"README"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[W.length,"/50000"]})]}),t.jsx("div",{className:"inline-flex rounded-lg border border-border p-0.5",children:["link","content"].map(B=>t.jsx("button",{type:"button",className:Z("px-2.5 py-1 text-xs rounded-md",de===B?"bg-primary text-primary-foreground":"text-muted-foreground"),onClick:()=>nt(B),children:B==="link"?"Link":"Content"},B))}),de==="link"&&t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(ae,{className:"h-9 text-sm",placeholder:"https://raw.githubusercontent.com/org/repo/main/README.md",value:xe,onChange:B=>ye(B.target.value)}),he.readmeUrl&&t.jsx("p",{className:"text-xs text-destructive",children:he.readmeUrl})]}),de==="content"&&t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(vt,{className:"text-sm max-h-48 overflow-y-auto resize-none",placeholder:`# README
25
+ another-server,Another Server,Another useful server,https://example2.com/mcp,http,data|analytics,data-processing,false`;function Gr(){const s=new Blob([Vr],{type:"text/csv;charset=utf-8"}),e=URL.createObjectURL(s),r=document.createElement("a");r.href=e,r.download="registry-import-template.csv",r.click(),URL.revokeObjectURL(e)}function Kr(s){const e=Y.c(63),{open:r,onOpenChange:n,isImporting:o,onImport:i}=s,a=o===void 0?!1:o,[l,d]=I.useState(null),[u,m]=I.useState(null),[h,x]=I.useState(null),p=I.useRef(null);let c;e[0]!==n?(c=H=>{n(H),H||(d(null),m(null),x(null),p.current&&(p.current.value=""))},e[0]=n,e[1]=c):c=e[1];const f=c;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=async H=>{if(!H)return;x(H.name),m(null);const xe=await H.text();d(Qr(xe))},e[2]=j):j=e[2];const C=j;let _;e[3]!==i||e[4]!==l?(_=async()=>{if(!l?.items.length)return;const H=await i(l.items);m(H)},e[3]=i,e[4]=l,e[5]=_):_=e[5];const y=_;let g;e[6]!==l?.items?(g=l?.items??[],e[6]=l?.items,e[7]=g):g=e[7];const P=g;let R;e[8]!==l?.warnings?(R=l?.warnings??[],e[8]=l?.warnings,e[9]=R):R=e[9];const w=R;let k;e[10]!==w?(k=w.some(Jr),e[10]=w,e[11]=k):k=e[11];const T=k,N=u!==null;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsxs(xt,{children:[t.jsx(ht,{children:"Import MCP Servers from CSV"}),t.jsx(pt,{children:"Upload a CSV file to bulk-import MCP servers into the registry."})]}),e[12]=E):E=e[12];let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=()=>p.current?.click(),e[13]=v):v=e[13];let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(Jt,{size:14}),e[14]=D):D=e[14];const O=h?"Change file":"Choose CSV file";let M;e[15]!==a||e[16]!==O?(M=t.jsxs(G,{variant:"outline",size:"sm",className:"gap-1.5",onClick:v,disabled:a,children:[D,O]}),e[15]=a,e[16]=O,e[17]=M):M=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("input",{ref:p,type:"file",accept:".csv,text/csv",className:"hidden",onChange:H=>C(H.target.files?.[0]??null)}),e[18]=A):A=e[18];let $;e[19]!==h?($=h&&t.jsx("span",{className:"text-sm text-muted-foreground truncate",children:h}),e[19]=h,e[20]=$):$=e[20];let z;e[21]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("div",{className:"flex-1"}),e[21]=z):z=e[21];let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1.5 text-xs text-muted-foreground",onClick:Gr,children:[t.jsx(Ks,{size:14}),"Download template"]}),e[22]=L):L=e[22];let b;e[23]!==M||e[24]!==$?(b=t.jsxs("div",{className:"flex items-center gap-3",children:[M,A,$,z,L]}),e[23]=M,e[24]=$,e[25]=b):b=e[25];let U;e[26]!==w?(U=w.length>0&&t.jsx("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 dark:border-yellow-900 dark:bg-yellow-950/30 p-3 grid gap-1",children:w.map(Wr)}),e[26]=w,e[27]=U):U=e[27];let K;e[28]!==P||e[29]!==l?(K=P.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:"Preview"}),t.jsxs(F,{variant:"secondary",children:[P.length," items"]}),l?.skipped?t.jsxs(F,{variant:"outline",className:"text-yellow-600",children:[l.skipped," skipped"]}):null]}),t.jsx("div",{className:"border rounded-lg overflow-hidden",children:t.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:t.jsxs(Mt,{children:[t.jsx(Et,{children:t.jsxs(Fe,{children:[t.jsx(ue,{className:"w-[140px]",children:"ID"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"Remote URL"}),t.jsx(ue,{className:"w-[80px] text-center",children:"Public"}),t.jsx(ue,{children:"Tags"})]})}),t.jsx(Dt,{children:P.map(Hr)})]})})})]}),e[28]=P,e[29]=l,e[30]=K):K=e[30];let te;e[31]!==u?(te=u&&t.jsxs("div",{className:"rounded-lg border p-3 grid gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[t.jsx(qe,{size:16,className:"text-emerald-600"}),"Imported ",u.created," item(s) successfully"]}),u.errors.length>0&&t.jsx("div",{className:"grid gap-1 mt-1",children:u.errors.map(Yr)})]}),e[31]=u,e[32]=te):te=e[32];let ee;e[33]!==N||e[34]!==l?(ee=!l&&!N&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsx(Jt,{size:32,className:"text-muted-foreground/40 mb-3"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a CSV file or download the template to get started."}),t.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Required columns: ",t.jsx("code",{children:"id"}),", ",t.jsx("code",{children:"title"}),". Optional:"," ",t.jsx("code",{children:"description"}),", ",t.jsx("code",{children:"remote_url"}),","," ",t.jsx("code",{children:"remote_type"}),", ",t.jsx("code",{children:"tags"}),","," ",t.jsx("code",{children:"categories"}),", ",t.jsx("code",{children:"is_public"}),"."]}),t.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-1",children:["Use ",t.jsx("code",{children:"|"})," or ",t.jsx("code",{children:";"})," to separate multiple tags/categories within a cell."]})]}),e[33]=N,e[34]=l,e[35]=ee):ee=e[35];let se;e[36]!==b||e[37]!==U||e[38]!==K||e[39]!==te||e[40]!==ee?(se=t.jsxs("div",{className:"flex-1 overflow-y-auto grid gap-4 pr-1",children:[b,U,K,te,ee]}),e[36]=b,e[37]=U,e[38]=K,e[39]=te,e[40]=ee,e[41]=se):se=e[41];let re;e[42]!==f?(re=()=>f(!1),e[42]=f,e[43]=re):re=e[43];const pe=N?"Done":"Cancel";let fe;e[44]!==re||e[45]!==pe?(fe=t.jsx(G,{variant:"outline",onClick:re,children:pe}),e[44]=re,e[45]=pe,e[46]=fe):fe=e[46];let ge;e[47]!==y||e[48]!==T||e[49]!==N||e[50]!==a||e[51]!==P.length?(ge=!N&&t.jsx(G,{onClick:y,disabled:a||P.length===0||T,children:a?"Importing...":`Import ${P.length} item(s)`}),e[47]=y,e[48]=T,e[49]=N,e[50]=a,e[51]=P.length,e[52]=ge):ge=e[52];let be;e[53]!==fe||e[54]!==ge?(be=t.jsxs(ft,{className:"gap-2 sm:gap-0",children:[fe,ge]}),e[53]=fe,e[54]=ge,e[55]=be):be=e[55];let S;e[56]!==se||e[57]!==be?(S=t.jsxs(gt,{className:"sm:max-w-3xl max-h-[85vh] flex flex-col",children:[E,se,be]}),e[56]=se,e[57]=be,e[58]=S):S=e[58];let W;return e[59]!==f||e[60]!==r||e[61]!==S?(W=t.jsx(jt,{open:r,onOpenChange:f,children:S}),e[59]=f,e[60]=r,e[61]=S,e[62]=W):W=e[62],W}function Yr(s){return t.jsxs("p",{className:"text-xs text-destructive flex items-start gap-1.5",children:[t.jsx(Ke,{size:12,className:"shrink-0 mt-0.5"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-mono",children:s.id}),": ",s.error]})]},s.id)}function Hr(s){return t.jsxs(Fe,{children:[t.jsx(me,{className:"font-mono text-xs",children:s.id}),t.jsx(me,{className:"text-sm",children:s.title}),t.jsx(me,{className:"text-xs text-muted-foreground max-w-[200px] truncate",children:s.server.remotes?.[0]?.url??t.jsx("span",{className:"italic",children:"none"})}),t.jsx(me,{className:"text-center",children:s.is_public?t.jsx(F,{variant:"secondary",className:"text-[10px] bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400",children:"Yes"}):t.jsx("span",{className:"text-xs text-muted-foreground",children:"No"})}),t.jsx(me,{className:"text-xs text-muted-foreground",children:(s._meta?.["mcp.mesh"]?.tags??[]).join(", ")||"-"})]},s.id)}function Wr(s,e){return t.jsxs("p",{className:"text-xs text-yellow-700 dark:text-yellow-400 flex items-start gap-1.5",children:[t.jsx(Ke,{size:12,className:"shrink-0 mt-0.5"}),t.jsxs("span",{children:[s.line>0&&t.jsxs("span",{className:"font-mono text-[10px] mr-1",children:["Line ",s.line,":"]}),s.message]})]},`${s.line}-${e}`)}function Jr(s){return s.message.startsWith("Missing required column:")}function Zr(s){const e=Y.c(19),{open:r,onOpenChange:n,title:o,isDeleting:i,onConfirm:a}=s,l=i===void 0?!1:i;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ye,{children:"Delete registry item?"}),e[0]=d):d=e[0];let u;e[1]!==o?(u=t.jsxs(He,{children:[d,t.jsxs(We,{children:["This action cannot be undone. Item ",t.jsx("strong",{children:o})," will be permanently removed from this private registry."]})]}),e[1]=o,e[2]=u):u=e[2];let m;e[3]!==l?(m=t.jsx(Je,{disabled:l,children:"Cancel"}),e[3]=l,e[4]=m):m=e[4];const h=l?"Deleting...":"Delete";let x;e[5]!==l||e[6]!==a||e[7]!==h?(x=t.jsx(Ze,{disabled:l,onClick:a,children:h}),e[5]=l,e[6]=a,e[7]=h,e[8]=x):x=e[8];let p;e[9]!==m||e[10]!==x?(p=t.jsxs(Xe,{children:[m,x]}),e[9]=m,e[10]=x,e[11]=p):p=e[11];let c;e[12]!==u||e[13]!==p?(c=t.jsxs(et,{children:[u,p]}),e[12]=u,e[13]=p,e[14]=c):c=e[14];let f;return e[15]!==n||e[16]!==r||e[17]!==c?(f=t.jsx(tt,{open:r,onOpenChange:n,children:c}),e[15]=n,e[16]=r,e[17]=c,e[18]=f):f=e[18],f}function Xr(s){const[e]=s.id.split("/");return e??"provider"}function en(s){return s._meta?.["mcp.mesh"]?.tags??[]}function tn(s){return s._meta?.["mcp.mesh"]?.categories??[]}function sn(s){return s.server?.icons?.[0]?.src??null}function rn(s){const e=Y.c(77),{item:r,onEdit:n,onDelete:o,onToggleVerified:i,onToggleOfficial:a}=s;let l;e[0]!==r?(l=sn(r),e[0]=r,e[1]=l):l=e[1];const d=l,u=r._meta?.["mcp.mesh"]?.verified===!0,m=r._meta?.["mcp.mesh"]?.official===!0;let h;e[2]!==r?(h=[...en(r),...tn(r)],e[2]=r,e[3]=h):h=e[3];const x=h;let p;e[4]!==x?(p=x.slice(0,3),e[4]=x,e[5]=p):p=e[5];const c=p,f=Math.max(0,x.length-c.length);let j;e[6]!==d||e[7]!==r.title?(j=t.jsx("div",{className:"size-10 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0 flex items-center justify-center",children:d?t.jsx("img",{src:d,alt:r.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:r.title.charAt(0).toUpperCase()})}),e[6]=d,e[7]=r.title,e[8]=j):j=e[8];let C;e[9]!==r.title?(C=t.jsx("p",{className:"font-medium truncate",children:r.title}),e[9]=r.title,e[10]=C):C=e[10];let _;e[11]!==r?(_=Xr(r),e[11]=r,e[12]=_):_=e[12];let y;e[13]!==_?(y=t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:_}),e[13]=_,e[14]=y):y=e[14];let g;e[15]!==r.is_public?(g=r.is_public?t.jsxs(F,{variant:"default",className:"gap-1",children:[t.jsx(ds,{size:10}),"Public"]}):t.jsx(F,{variant:"secondary",children:"Private"}),e[15]=r.is_public,e[16]=g):g=e[16];let P;e[17]!==m?(P=m&&t.jsxs(F,{variant:"outline",className:"gap-1 text-primary",children:[t.jsx(Zt,{size:10}),"Official"]}),e[17]=m,e[18]=P):P=e[18];let R;e[19]!==m||e[20]!==u?(R=!m&&u&&t.jsxs(F,{variant:"outline",className:"gap-1 text-success",children:[t.jsx(Zt,{size:10}),"Verified"]}),e[19]=m,e[20]=u,e[21]=R):R=e[21];let w;e[22]!==R||e[23]!==y||e[24]!==g||e[25]!==P?(w=t.jsxs("div",{className:"flex items-center gap-2",children:[y,g,P,R]}),e[22]=R,e[23]=y,e[24]=g,e[25]=P,e[26]=w):w=e[26];let k;e[27]!==w||e[28]!==C?(k=t.jsxs("div",{className:"min-w-0 flex-1",children:[C,w]}),e[27]=w,e[28]=C,e[29]=k):k=e[29];let T;e[30]!==k||e[31]!==j?(T=t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[j,k]}),e[30]=k,e[31]=j,e[32]=T):T=e[32];let N;e[33]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(dt,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:t.jsx(At,{size:18})})}),e[33]=N):N=e[33];let E;e[34]!==r||e[35]!==n?(E=t.jsx(Ce,{onClick:()=>n(r),children:"Edit"}),e[34]=r,e[35]=n,e[36]=E):E=e[36];let v;e[37]!==r||e[38]!==i?(v=()=>i(r),e[37]=r,e[38]=i,e[39]=v):v=e[39];const D=u?"Unmark as Verified":"Mark as Verified";let O;e[40]!==v||e[41]!==D?(O=t.jsx(Ce,{onClick:v,children:D}),e[40]=v,e[41]=D,e[42]=O):O=e[42];let M;e[43]!==r||e[44]!==a?(M=()=>a(r),e[43]=r,e[44]=a,e[45]=M):M=e[45];const A=m?"Unmark as Official":"Mark as Official";let $;e[46]!==M||e[47]!==A?($=t.jsx(Ce,{onClick:M,children:A}),e[46]=M,e[47]=A,e[48]=$):$=e[48];let z;e[49]!==r||e[50]!==o?(z=()=>o(r),e[49]=r,e[50]=o,e[51]=z):z=e[51];let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(st,{size:14}),e[52]=L):L=e[52];let b;e[53]!==z?(b=t.jsxs(Ce,{variant:"destructive",onClick:z,children:[L,"Delete"]}),e[53]=z,e[54]=b):b=e[54];let U;e[55]!==E||e[56]!==O||e[57]!==$||e[58]!==b?(U=t.jsxs(ut,{children:[N,t.jsxs(mt,{align:"end",children:[E,O,$,b]})]}),e[55]=E,e[56]=O,e[57]=$,e[58]=b,e[59]=U):U=e[59];let K;e[60]!==T||e[61]!==U?(K=t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[T,U]}),e[60]=T,e[61]=U,e[62]=K):K=e[62];const te=r._meta?.["mcp.mesh"]?.short_description||r.description||r.server.description||"No description provided.";let ee;e[63]!==te?(ee=t.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 min-h-10",children:te}),e[63]=te,e[64]=ee):ee=e[64];let se;e[65]!==r.id||e[66]!==c?(se=c.map(ge=>t.jsx(F,{variant:"secondary",children:ge},`${r.id}-badge-${ge}`)),e[65]=r.id,e[66]=c,e[67]=se):se=e[67];let re;e[68]!==f?(re=f>0&&t.jsxs(F,{variant:"outline",children:["+",f]}),e[68]=f,e[69]=re):re=e[69];let pe;e[70]!==se||e[71]!==re?(pe=t.jsxs("div",{className:"flex flex-wrap gap-1",children:[se,re]}),e[70]=se,e[71]=re,e[72]=pe):pe=e[72];let fe;return e[73]!==K||e[74]!==ee||e[75]!==pe?(fe=t.jsxs(ne,{className:"p-4 gap-4 transition-colors hover:bg-muted/50",children:[K,ee,pe]}),e[73]=K,e[74]=ee,e[75]=pe,e[76]=fe):fe=e[76],fe}function vs(s){const e=Y.c(28),{value:r,onChange:n,onBlur:o,onFileUpload:i,error:a,isUploading:l}=s,d=l===void 0?!1:l,[u,m]=I.useState(!1),[h,x]=I.useState(!1),p=I.useRef(null);let c;e[0]!==d?(c=v=>{v.preventDefault(),d||m(!0)},e[0]=d,e[1]=c):c=e[1];const f=c;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=v=>{v.preventDefault(),m(!1)},e[2]=j):j=e[2];const C=j;let _;e[3]!==d||e[4]!==i?(_=async v=>{if(v.preventDefault(),m(!1),d)return;const D=v.dataTransfer.files[0];D&&await i(D)},e[3]=d,e[4]=i,e[5]=_):_=e[5];const y=_;let g;e[6]!==d||e[7]!==i?(g=async v=>{const D=v.target.files?.[0];D&&!d&&await i(D),v.target.value=""},e[6]=d,e[7]=i,e[8]=g):g=e[8];const P=g,R=r.length>0;let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(X,{children:"Image"}),e[9]=w):w=e[9];let k;e[10]!==f||e[11]!==y||e[12]!==R||e[13]!==u||e[14]!==d||e[15]!==o||e[16]!==n||e[17]!==h||e[18]!==r?(k=R?t.jsx("div",{className:"relative group min-h-[180px] rounded-xl border border-border overflow-hidden bg-muted/10",children:t.jsxs("div",{className:"flex items-center gap-3 p-3 h-full",children:[t.jsx("div",{className:"size-20 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0",children:t.jsx("img",{src:r,alt:"Preview",className:"w-full h-full object-cover"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",onClick:()=>p.current?.click(),disabled:d,children:[t.jsx($t,{className:"size-3"}),"Change"]}),t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 text-destructive hover:text-destructive",onClick:()=>{n(""),x(!1)},disabled:d,children:[t.jsx(st,{className:"size-3"}),"Remove"]})]})]})]})}):d?t.jsxs("div",{className:"relative min-h-[180px] rounded-xl border border-border bg-muted/10 flex flex-col items-center justify-center gap-3",children:[t.jsx(Le,{className:"size-8 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading image..."})]}):t.jsxs("div",{className:Z("relative min-h-[180px] rounded-xl border-2 border-dashed transition-colors cursor-pointer flex flex-col",u?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/40 hover:bg-muted/30"),onDragOver:f,onDragLeave:C,onDrop:y,onClick:()=>p.current?.click(),children:[t.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-6 px-4 flex-1",children:[t.jsx("div",{className:Z("size-10 rounded-lg flex items-center justify-center transition-colors",u?"bg-primary/10 text-primary":"bg-muted/50 text-muted-foreground"),children:t.jsx(dr,{size:20})}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:u?"Drop image here":"Click or drag to upload"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"PNG, JPG, SVG up to 2MB"})]})]}),h?t.jsx("div",{className:"border-t border-border px-3 py-2",onClick:nn,children:t.jsx(ae,{placeholder:"https://example.com/logo.png",value:r,className:"text-xs h-8",onChange:v=>n(v.target.value),onBlur:o})}):t.jsx("div",{className:"border-t border-border px-4 py-2",children:t.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-full justify-center",onClick:v=>{v.stopPropagation(),x(!0)},children:[t.jsx(Ys,{className:"size-3"}),"Or paste an image URL"]})})]}),e[10]=f,e[11]=y,e[12]=R,e[13]=u,e[14]=d,e[15]=o,e[16]=n,e[17]=h,e[18]=r,e[19]=k):k=e[19];let T;e[20]!==P?(T=t.jsx("input",{ref:p,type:"file",accept:"image/*",className:"hidden",onChange:P}),e[20]=P,e[21]=T):T=e[21];let N;e[22]!==a?(N=a&&t.jsx("p",{className:"text-xs text-destructive",children:a}),e[22]=a,e[23]=N):N=e[23];let E;return e[24]!==k||e[25]!==T||e[26]!==N?(E=t.jsxs("div",{className:"grid gap-1.5",children:[w,k,T,N]}),e[24]=k,e[25]=T,e[26]=N,e[27]=E):E=e[27],E}function nn(s){return s.stopPropagation()}function bs(){const[s,e]=I.useState("idle"),[r,n]=I.useState(null),{org:o}=ie(),i=oe({connectionId:ce,orgId:o.id});return{discover:async(d,u)=>{if(!d)return null;e("loading"),n(null);try{const m=await i.callTool({name:"REGISTRY_DISCOVER_TOOLS",arguments:{url:d,type:u==="sse"?"sse":"http"}}),h=m.structuredContent??m;if(m.isError){const x=m.content?.find(p=>p.type==="text")?.text??"Tool returned an error";return n(x),e("error"),null}return h.error?ln(h.error)?(n(h.error),e("auth_required"),null):(n(h.error),e("error"),null):!h.tools||h.tools.length===0?(n("No tools found on this MCP server."),e("error"),null):(e("success"),h.tools)}catch(m){const h=m instanceof Error?m.message:String(m);return n(h||"Could not discover tools."),e("error"),null}},discoverStatus:s,discoverError:r,resetDiscover:()=>{e("idle"),n(null)}}}function ln(s){const e=s.toLowerCase();return e.includes("authentication")||e.includes("unauthorized")||e.includes("credentials")}function an(s){const e=Y.c(54),{tools:r,onChange:n,remoteUrl:o,remoteType:i,externalDiscoverStatus:a,externalDiscoverError:l}=s,[d,u]=I.useState(r.length>0),{discover:m,discoverStatus:h,discoverError:x,resetDiscover:p}=bs(),c=a??h,f=l??x;let j;e[0]!==m||e[1]!==n||e[2]!==i||e[3]!==o?(j=async()=>{if(!o)return;const L=await m(o,i??"http");L&&(n(L),u(!0))},e[0]=m,e[1]=n,e[2]=i,e[3]=o,e[4]=j):j=e[4];const C=j;let _;e[5]!==n||e[6]!==p?(_=()=>{n([]),p()},e[5]=n,e[6]=p,e[7]=_):_=e[7];const y=_;let g;e[8]!==d?(g=()=>u(!d),e[8]=d,e[9]=g):g=e[9];let P,R;e[10]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(us,{size:14,className:"text-muted-foreground"}),R=t.jsx("span",{children:"Tools"}),e[10]=P,e[11]=R):(P=e[10],R=e[11]);let w;e[12]!==r.length?(w=r.length>0&&t.jsx(F,{variant:"secondary",className:"text-xs px-1.5 py-0",children:r.length}),e[12]=r.length,e[13]=w):w=e[13];let k;e[14]!==d?(k=d?t.jsx(pr,{size:14,className:"text-muted-foreground"}):t.jsx(hr,{size:14,className:"text-muted-foreground"}),e[14]=d,e[15]=k):k=e[15];let T;e[16]!==g||e[17]!==w||e[18]!==k?(T=t.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm font-medium cursor-pointer",onClick:g,children:[P,R,w,k]}),e[16]=g,e[17]=w,e[18]=k,e[19]=T):T=e[19];let N;e[20]!==y||e[21]!==r.length?(N=r.length>0&&t.jsxs(G,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs gap-1.5 text-muted-foreground",onClick:y,children:[t.jsx(st,{size:12}),"Clear"]}),e[20]=y,e[21]=r.length,e[22]=N):N=e[22];let E;e[23]!==c||e[24]!==C||e[25]!==o||e[26]!==r.length?(E=o&&t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 border-green-500/30 text-green-600 dark:text-green-400 shadow-[0_0_8px_rgba(34,197,94,0.3)] hover:shadow-[0_0_14px_rgba(34,197,94,0.5)] hover:border-green-500/50 transition-all",onClick:C,disabled:c==="loading",children:[c==="loading"?t.jsx(Le,{size:12,className:"animate-spin"}):t.jsx($t,{size:12}),c==="loading"?"Discovering...":r.length>0?"Refresh":"Auto-discover"]}),e[23]=c,e[24]=C,e[25]=o,e[26]=r.length,e[27]=E):E=e[27];let v;e[28]!==E||e[29]!==N?(v=t.jsxs("div",{className:"flex items-center gap-2",children:[N,E]}),e[28]=E,e[29]=N,e[30]=v):v=e[30];let D;e[31]!==v||e[32]!==T?(D=t.jsxs("div",{className:"flex items-center justify-between",children:[T,v]}),e[31]=v,e[32]=T,e[33]=D):D=e[33];let O;e[34]!==c||e[35]!==r.length?(O=c==="success"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-950/30 rounded-lg px-3 py-2",children:[t.jsx(qe,{size:14,className:"shrink-0"}),t.jsxs("span",{children:["Discovered ",r.length," tool",r.length!==1?"s":""," ","successfully."]})]}),e[34]=c,e[35]=r.length,e[36]=O):O=e[36];let M;e[37]!==f||e[38]!==c?(M=c==="error"&&f&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 rounded-lg px-3 py-2",children:[t.jsx(Ke,{size:14,className:"shrink-0"}),t.jsx("span",{children:f})]}),e[37]=f,e[38]=c,e[39]=M):M=e[39];let A;e[40]!==d||e[41]!==r?(A=d&&r.length>0&&t.jsx("div",{className:"rounded-xl border border-border divide-y divide-border overflow-hidden max-h-48 overflow-y-auto",children:r.map(on)}),e[40]=d,e[41]=r,e[42]=A):A=e[42];let $;e[43]!==c||e[44]!==d||e[45]!==o||e[46]!==r.length?($=d&&r.length===0&&c==="idle"&&t.jsx("p",{className:"text-xs text-muted-foreground px-1",children:o?'Click "Auto-discover" to load tools from the MCP server.':"Add a Remote URL first, then tools can be auto-discovered."}),e[43]=c,e[44]=d,e[45]=o,e[46]=r.length,e[47]=$):$=e[47];let z;return e[48]!==D||e[49]!==O||e[50]!==M||e[51]!==A||e[52]!==$?(z=t.jsxs("div",{className:"space-y-3",children:[D,O,M,A,$]}),e[48]=D,e[49]=O,e[50]=M,e[51]=A,e[52]=$,e[53]=z):z=e[53],z}function on(s){return t.jsx("div",{className:"flex items-center gap-3 px-3 py-2",children:t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-mono truncate",children:s.name}),s.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description})]})},s.name)}function ys(s){const{org:e}=ie(),[r,n]=I.useState(!1),i=typeof window<"u"&&window.location.hostname==="localhost"?`${e.id}_dev-assets`:null,a=oe({connectionId:i??"noop",orgId:e.id});return{uploadImage:async(d,u)=>{if(!i)return V.error("Image upload requires an object-storage connection. Configure one in plugin settings."),null;if(!d.type.startsWith("image/"))return V.error("Only image files are supported"),null;if(d.size>5*1024*1024)return V.error("Image size must be less than 5MB"),null;n(!0);try{const m=await a.callTool({name:"PUT_PRESIGNED_URL",arguments:{key:u,contentType:d.type}}),h=m.structuredContent?.url||m.url;if(!h)throw new Error("Failed to get presigned URL");const x=await fetch(h,{method:"PUT",body:d,headers:{"Content-Type":d.type}});if(!x.ok)throw new Error(`Upload failed: ${x.statusText}`);const p=await a.callTool({name:"GET_PRESIGNED_URL",arguments:{key:u,expiresIn:31536e3}}),c=p.structuredContent?.url||p.url;if(!c)throw new Error("Failed to get public URL");return c}catch(m){return console.error("Image upload failed:",m),V.error(m instanceof Error?m.message:"Failed to upload image. Please try again."),null}finally{n(!1)}},isUploading:r}}const cn=new Set(["http","sse","stdio"]),dn=/^[a-z0-9]+(?:[/-][a-z0-9._-]+)*$/,un=["internal","automation","support","sales","ops","ai"],mn=["productivity","communication","customer-support","development","data","operations"],xn=["Essentials","Details","Advanced"],hn="h-7 text-xs border-green-500/30 text-green-600 dark:text-green-400 shadow-[0_0_8px_rgba(34,197,94,0.3)] hover:shadow-[0_0_14px_rgba(34,197,94,0.5)] hover:border-green-500/50 transition-all";function ls(s){return s.replace(/^https?:\/\//i,"").trim()}function Ge(s){const e=s.trim();return e?/^https?:\/\//i.test(e)?e:`https://${e}`:""}function ze(s){return s.trim().toLowerCase()}function bt(s){return Array.from(new Set(s.map(ze).filter(e=>e.length>0)))}function Ae(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function pn(s){const e=Y.c(4),{current:r}=s;let n;e[0]!==r?(n=xn.map((i,a)=>{const l=a+1,d=l===r,u=l<r;return t.jsxs("div",{className:"flex items-center gap-1.5",children:[a>0&&t.jsx("div",{className:Z("w-4 h-px",u?"bg-primary":"bg-border")}),t.jsxs("div",{className:Z("flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs transition-colors",d?"bg-primary/10 text-primary font-medium":u?"text-primary":"text-muted-foreground"),children:[t.jsx("span",{className:Z("size-5 rounded-full inline-flex items-center justify-center text-[10px] font-semibold shrink-0",d?"bg-primary text-primary-foreground":u?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"),children:l}),t.jsx("span",{className:"hidden sm:inline",children:i})]})]},i)}),e[0]=r,e[1]=n):n=e[1];let o;return e[2]!==n?(o=t.jsx("div",{className:"flex items-center gap-1.5",children:n}),e[2]=n,e[3]=o):o=e[3],o}function fn(s){const e=Y.c(28),{id:r,label:n,values:o,availableOptions:i,placeholder:a,onChange:l}=s,[d,u]=I.useState(""),[m,h]=I.useState(!1);let x,p,c,f,j;if(e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==n||e[5]!==l||e[6]!==a||e[7]!==o){const y=bt(i),g=bt(o),P=new Set(g),R=ze(d),w=y.filter(M=>!P.has(M)).filter(M=>R?M.includes(R):!0).slice(0,8),k=M=>{const A=ze(M);!A||P.has(A)||l([...g,A])},T=M=>{l(g.filter(A=>A!==M))},N=()=>{const M=d.split(/[,\n;]/).map(ze).filter(Boolean);if(M.length===0)return;const A=[...g];for(const $ of M)A.includes($)||A.push($);l(A),u("")},E=R;f="grid gap-2",e[13]!==r||e[14]!==n?(j=t.jsx(X,{htmlFor:r,children:n}),e[13]=r,e[14]=n,e[15]=j):j=e[15],x="relative";let v;e[16]!==r?(v=()=>{const M=document.getElementById(r);M instanceof HTMLInputElement&&M.focus()},e[16]=r,e[17]=v):v=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=()=>h(!0),e[18]=D):D=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=M=>u(M.target.value),e[19]=O):O=e[19],p=t.jsx("div",{className:"min-h-9 w-full rounded-xl border border-input bg-background px-2.5 py-1.5 text-sm focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",onClick:v,children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[g.map(M=>t.jsxs(F,{variant:"secondary",className:"gap-1",children:[M,t.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),T(M)},children:t.jsx(xr,{size:12})})]},`${r}-${M}`)),t.jsx("input",{id:r,className:"flex-1 min-w-[120px] bg-transparent outline-none border-none text-sm",placeholder:g.length?"":a,value:d,onFocus:D,onBlur:()=>{h(!1),N()},onChange:O,onKeyDown:M=>{if(M.key==="Enter"||M.key===","){M.preventDefault(),N();return}M.key==="Backspace"&&!d&&g.length&&T(g[g.length-1]??"")}})]})}),c=m&&t.jsx("div",{className:"absolute z-50 mt-1 w-full rounded-xl border border-border bg-background shadow-lg max-h-56 overflow-y-auto",children:w.length>0?w.map(M=>t.jsx("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:jn,onClick:()=>{k(M),u("")},children:M},`${r}-suggestion-${M}`)):E?t.jsxs("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:gn,onClick:()=>{k(E),u("")},children:['Create "',E,'"']}):t.jsx("div",{className:"px-2.5 py-1.5 text-sm text-muted-foreground",children:"Type to search or create."})}),e[0]=i,e[1]=r,e[2]=d,e[3]=m,e[4]=n,e[5]=l,e[6]=a,e[7]=o,e[8]=x,e[9]=p,e[10]=c,e[11]=f,e[12]=j}else x=e[8],p=e[9],c=e[10],f=e[11],j=e[12];let C;e[20]!==x||e[21]!==p||e[22]!==c?(C=t.jsxs("div",{className:x,children:[p,c]}),e[20]=x,e[21]=p,e[22]=c,e[23]=C):C=e[23];let _;return e[24]!==f||e[25]!==j||e[26]!==C?(_=t.jsxs("div",{className:f,children:[j,C]}),e[24]=f,e[25]=j,e[26]=C,e[27]=_):_=e[27],_}function gn(s){return s.preventDefault()}function jn(s){return s.preventDefault()}function vn({id:s,value:e,availableOptions:r,onChange:n}){const[o,i]=I.useState(e),[a,l]=I.useState(!1),d=I.useRef(e);d.current!==e&&(d.current=e,i(e));const u=bt([...mn,...r,e]).filter(Boolean),m=ze(o),h=u.filter(p=>m?p.includes(m):!0).slice(0,8),x=p=>{const c=ze(p);n(c),i(c),l(!1)};return t.jsxs("div",{className:"grid gap-2",children:[t.jsx(X,{htmlFor:s,children:"Category"}),t.jsxs("div",{className:"relative",children:[t.jsx(ae,{id:s,className:"h-9 text-sm",placeholder:"Select or create category",value:o,onFocus:()=>{i(e),l(!0)},onBlur:()=>{x(o)},onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),x(o))}}),e&&t.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground hover:text-foreground",onMouseDown:p=>p.preventDefault(),onClick:()=>{n(""),i("")},children:"clear"}),a&&t.jsx("div",{className:"absolute z-50 mt-1 w-full rounded-xl border border-border bg-background shadow-lg max-h-56 overflow-y-auto",children:h.length>0?h.map(p=>t.jsx("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:c=>c.preventDefault(),onClick:()=>x(p),children:p},`${s}-${p}`)):m?t.jsxs("button",{type:"button",className:"w-full text-left px-2.5 py-1.5 text-sm hover:bg-muted",onMouseDown:p=>p.preventDefault(),onClick:()=>x(m),children:['Create "',m,'"']}):t.jsx("div",{className:"px-2.5 py-1.5 text-sm text-muted-foreground",children:"Type to search or create."})})]})]})}function bn({open:s,onOpenChange:e,item:r,draft:n,availableTags:o=[],availableCategories:i=[],isSubmitting:a=!1,onSubmit:l}){const{org:d}=ie(),{uploadImage:u,isUploading:m}=ys(),{discover:h,discoverStatus:x,discoverError:p,resetDiscover:c}=bs(),f=!!r,j=n?._meta?.["mcp.mesh"],C=r?.title??n?.title??"",_=r?.id?.split("/")[0]??n?.id?.split("/")[0]??"",y=r?.description??n?.description??"",g=r?._meta?.["mcp.mesh"]?.short_description??j?.short_description??"",P=r?._meta?.["mcp.mesh"]?.owner??j?.owner??"",R=r?.server?.repository?.url??n?.server?.repository?.url??"",w=r?._meta?.["mcp.mesh"]?.readme??j?.readme??"",k=r?._meta?.["mcp.mesh"]?.readme_url??j?.readme_url??"",T=ls(r?.server?.remotes?.[0]?.url??n?.server?.remotes?.[0]?.url??""),N=r?.server?.remotes?.[0]?.type??n?.server?.remotes?.[0]?.type??"http",E=r?._meta?.["mcp.mesh"]?.tags??j?.tags??[],v=r?._meta?.["mcp.mesh"]?.categories?.[0]??j?.categories?.[0]??"",D=r?.server?.icons?.[0]?.src??n?.server?.icons?.[0]?.src??"",O=r?._meta?.["mcp.mesh"]?.tools??j?.tools??[],M=r?.is_public??n?.is_public??!1,A=r?._meta?.["mcp.mesh"]?.verified??j?.verified??!1,$=r?._meta?.["mcp.mesh"]?.official??j?.official??!1,[z,L]=I.useState(1),[b,U]=I.useState(C),[K,te]=I.useState(_),[ee,se]=I.useState(y),[re,pe]=I.useState(g),[fe,ge]=I.useState(P),[be,S]=I.useState(R),[W,H]=I.useState(w),[xe,ye]=I.useState(k),[de,nt]=I.useState(w?"content":"link"),[Me,q]=I.useState(T),[le,it]=I.useState(N),[Ue,Ut]=I.useState(E),[Nt,Lt]=I.useState(v),[Be,wt]=I.useState(D),[we,lt]=I.useState(O),[qt,Ft]=I.useState(M),[Bt,Qt]=I.useState(A),[Vt,Gt]=I.useState($),[he,Qe]=I.useState({}),Kt=()=>{L(1),U(C),te(_),se(y),pe(g),ge(P),S(R),H(w),ye(k),nt(w?"content":"link"),q(T),it(N),Ut(E),Lt(v),wt(D),lt(O),Ft(M),Qt(A),Gt($),Qe({}),c(),at.current="",Pe.current&&(clearTimeout(Pe.current),Pe.current=null)},ks=async B=>{if(!B)return;const J=f?r?.id:`${K}/${b}`.toLowerCase(),Ne=Ae(J||"temp"),Se=B.name.split(".").pop()||"png",Re=`registry/${d.id}/${Ne}/icon.${Se}`,De=await u(B,Re);De?(wt(De),Qe(Te=>({...Te,imageUrl:void 0}))):Qe(Te=>({...Te,imageUrl:"Failed to upload image. Please try again."}))},Pe=I.useRef(null),at=I.useRef(""),_t=I.useRef(le);_t.current=le;const Yt=B=>{!B&&Pe.current&&(clearTimeout(Pe.current),Pe.current=null),e(B),B||Kt()},Ss=async()=>{const B=Ge(Me);if(!B)return;at.current=B;const J=await h(B,_t.current);J&&lt(J)},Rs=B=>{Pe.current&&clearTimeout(Pe.current);const J=Ge(B);!J||J===at.current||B.includes(".")&&(Pe.current=setTimeout(async()=>{at.current=J;const Ne=await h(J,_t.current);Ne&&lt(Ne)},800))},Ht=B=>{const J={};if(B===1){const Ne=Ae(K),Se=Ae(b),Re=`${Ne}/${Se}`;b.trim()||(J.title="Name is required."),f||(Ne?Se?dn.test(Re)||(J.provider="Use lowercase letters/numbers and separators '/' or '-'."):J.title="Name must contain valid characters.":J.provider="Provider is required.");const De=Ge(Me),Te=le.trim().toLowerCase();if(Te!=="stdio"&&De)try{const Ve=new URL(De);["http:","https:"].includes(Ve.protocol)||(J.remoteUrl="Remote URL must be http(s).")}catch{J.remoteUrl="Remote URL is invalid."}if(Te&&!cn.has(Te)&&(J.remoteType="Remote type must be: http, sse or stdio."),Be.trim()&&!Be.trim().startsWith("data:image/"))try{const Ct=new URL(Be.trim());["http:","https:"].includes(Ct.protocol)||(J.imageUrl="Image URL must be http(s).")}catch{J.imageUrl="Image URL is invalid."}}if(B===2&&(ee.length>1500&&(J.description="Description must be 1500 characters or less."),re.trim().length>160&&(J.shortDescription="Short description must be 160 characters or less.")),B===3){const Ne=xe.trim();if(Ne)try{const Re=new URL(Ne);["http:","https:"].includes(Re.protocol)||(J.readmeUrl="README URL must be http(s).")}catch{J.readmeUrl="README URL is invalid."}W.trim().length>5e4&&(J.readme="README must be 50 000 characters or less.");const Se=be.trim();if(Se)try{const Re=new URL(Se);["http:","https:"].includes(Re.protocol)||(J.repositoryUrl="Repository URL must be http(s).")}catch{J.repositoryUrl="Repository URL is invalid."}}return Qe(J),Object.values(J).every(Ne=>Ne===void 0)},Ts=()=>{Ht(z)&&z<3&&L(z+1)},Is=()=>{z>1&&L(z-1)},Ps=async()=>{if(!Ht(3))return;const B=b.trim(),J=Ae(K),Ne=Ae(B),Se=`${J}/${Ne}`,Re=Ge(Me),De=le.trim().toLowerCase(),Te=Be.trim(),Ve=be.trim(),Ct=re.trim(),As=W.trim(),$s=xe.trim(),Os=bt(Ue),zs=Nt?[ze(Nt)]:[],Us=r?r.server?.name??r.id:"",Ls=(f?Us:Se).trim(),kt=ee.trim(),qs=fe.trim(),Wt={title:B,description:kt.length>0?kt:null,is_public:qt,_meta:{"mcp.mesh":{verified:Bt,official:Vt,tags:Os,categories:zs,short_description:Ct||null,owner:qs||null,readme:As||null,readme_url:$s||null,...we.length>0?{tools:we}:{}}},server:{name:Ls,title:B,description:kt||void 0,icons:Te?[{src:Te}]:[],repository:Ve?{url:Ve}:void 0,remotes:Re?[{type:De||"http",url:Re}]:[]}};if(f&&r){await l({id:r.id,data:Wt}),e(!1);return}await l({id:Se,...Wt}),e(!1),Kt()},Ms=t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"row-span-2 grid gap-3 content-start",children:[t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-provider",children:"Provider"}),t.jsx(ae,{id:"registry-item-provider",className:"h-9 text-sm",placeholder:"acme",value:K,onChange:B=>te(B.target.value),disabled:f}),!f&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Item ID:"," ",t.jsx("span",{className:"font-mono",children:`${Ae(K)||"provider"}/${Ae(b)||"name"}`})]}),he.provider&&t.jsx("p",{className:"text-xs text-destructive",children:he.provider})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-title",children:"Name"}),t.jsx(ae,{id:"registry-item-title",className:"h-9 text-sm",placeholder:"Internal MCP",value:b,onChange:B=>U(B.target.value)}),he.title&&t.jsx("p",{className:"text-xs text-destructive",children:he.title})]})]}),t.jsx("div",{className:"row-span-2 content-start",children:t.jsx(vs,{value:Be,onChange:B=>{wt(B),Qe(J=>({...J,imageUrl:void 0}))},onFileUpload:ks,error:he.imageUrl,isUploading:m})}),t.jsxs("div",{className:"col-span-2 grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-remote-url",children:"Remote URL"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex-1 flex items-center rounded-xl border border-input px-3",children:[t.jsx("span",{className:"text-xs font-semibold text-muted-foreground mr-1",children:"https://"}),t.jsx("input",{id:"registry-remote-url",className:"flex-1 h-9 bg-transparent outline-none text-sm",placeholder:"example.com/mcp",value:Me,onChange:B=>{const J=ls(B.target.value);q(J),Rs(J)}})]}),t.jsxs(lr,{value:le,onValueChange:it,children:[t.jsx(ar,{id:"registry-remote-type",className:"w-[90px] h-9 shrink-0",children:t.jsx(or,{placeholder:"Type"})}),t.jsxs(cr,{children:[t.jsx(Rt,{value:"http",children:"http"}),t.jsx(Rt,{value:"sse",children:"sse"}),t.jsx(Rt,{value:"stdio",children:"stdio"})]})]})]}),he.remoteUrl&&t.jsx("p",{className:"text-xs text-destructive",children:he.remoteUrl}),he.remoteType&&t.jsx("p",{className:"text-xs text-destructive",children:he.remoteType})]}),Me.trim()&&t.jsxs("div",{className:"col-span-2 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(G,{type:"button",variant:"outline",size:"sm",className:Z(hn,"gap-1.5"),onClick:Ss,disabled:x==="loading",children:[x==="loading"?t.jsx(Le,{size:12,className:"animate-spin"}):t.jsx($t,{size:12}),x==="loading"?"Discovering tools...":we.length>0?"Re-discover tools":"Discover tools from URL"]}),we.length>0&&x!=="loading"&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:[we.length," tool",we.length!==1?"s":""," loaded"]})]}),x==="success"&&we.length>0&&t.jsxs("div",{className:"rounded-lg border border-green-500/20 bg-green-50 dark:bg-green-950/20 px-3 py-2 space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-green-600 dark:text-green-400",children:[t.jsx(qe,{size:14,className:"shrink-0"}),t.jsxs("span",{className:"font-medium",children:[we.length," tool",we.length!==1?"s":""," discovered"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[we.slice(0,8).map(B=>t.jsx(F,{variant:"secondary",className:"text-[10px] px-1.5 py-0 font-mono",children:B.name},B.name)),we.length>8&&t.jsxs("span",{className:"text-[10px] text-muted-foreground self-center",children:["+",we.length-8," more"]})]}),t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"These tools will enrich AI-generated descriptions, tags and categories in the next step."})]}),x==="auth_required"&&p&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-950/20 border border-amber-500/20 rounded-lg px-3 py-2",children:[t.jsx(Ke,{size:14,className:"shrink-0"}),t.jsx("span",{children:"This server requires authentication. The connection is valid but tools cannot be listed without credentials."})]}),x==="error"&&p&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 rounded-lg px-3 py-2",children:[t.jsx(Ke,{size:14,className:"shrink-0"}),t.jsx("span",{children:p})]})]})]}),Es=t.jsxs("div",{className:"grid gap-3",children:[t.jsxs("div",{className:"grid gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(X,{htmlFor:"registry-item-short-description",children:"Short Description"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[re.length,"/160"]})]}),t.jsx(ae,{id:"registry-item-short-description",className:"h-9 text-sm",placeholder:"Short summary for the store card",value:re,maxLength:160,onChange:B=>pe(B.target.value)}),he.shortDescription&&t.jsx("p",{className:"text-xs text-destructive",children:he.shortDescription})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(X,{htmlFor:"registry-item-description",children:"Description"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[ee.length,"/1500"]})]}),t.jsx(vt,{id:"registry-item-description",className:"text-sm max-h-28 overflow-y-auto resize-none",placeholder:"Brief description of this MCP server",rows:2,value:ee,onChange:B=>se(B.target.value)}),he.description&&t.jsx("p",{className:"text-xs text-destructive",children:he.description})]}),t.jsx("div",{className:"border-t border-border"}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx("div",{className:"grid content-start gap-2",children:t.jsx(vn,{id:"registry-category",value:Nt,availableOptions:i,onChange:Lt})}),t.jsx("div",{className:"grid content-start gap-2",children:t.jsx(fn,{id:"registry-tags",label:"Tags",values:Ue,availableOptions:[...un,...o],placeholder:"Type and press Enter or comma",onChange:Ut})})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-4 py-3",children:[t.jsxs("div",{className:"grid gap-0.5",children:[t.jsx(X,{htmlFor:"registry-is-public",className:"text-sm",children:"Public"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this MCP visible in the public store URL."})]}),t.jsx(Oe,{id:"registry-is-public",checked:qt,onCheckedChange:Ft})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-4 py-3",children:[t.jsxs("div",{className:"grid gap-0.5",children:[t.jsx(X,{htmlFor:"registry-is-verified",className:"text-sm",children:"Verified"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Curated and approved by deco."})]}),t.jsx(Oe,{id:"registry-is-verified",checked:Bt,onCheckedChange:Qt})]}),t.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-4 py-3",children:[t.jsxs("div",{className:"grid gap-0.5",children:[t.jsx(X,{htmlFor:"registry-is-official",className:"text-sm",children:"Official"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Made and hosted by the service provider."})]}),t.jsx(Oe,{id:"registry-is-official",checked:Vt,onCheckedChange:Gt})]})]}),Ds=t.jsxs("div",{className:"grid gap-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-owner",children:"Owner (optional)"}),t.jsx(ae,{id:"registry-item-owner",className:"h-9 text-sm",placeholder:"Team, company, or responsible person",value:fe,onChange:B=>ge(B.target.value)})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"registry-item-repository-url",children:"Repository URL (optional)"}),t.jsx(ae,{id:"registry-item-repository-url",className:"h-9 text-sm",placeholder:"https://github.com/org/repo",value:be,onChange:B=>S(B.target.value)}),he.repositoryUrl&&t.jsx("p",{className:"text-xs text-destructive",children:he.repositoryUrl})]})]}),t.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(X,{children:"README"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[W.length,"/50000"]})]}),t.jsx("div",{className:"inline-flex rounded-lg border border-border p-0.5",children:["link","content"].map(B=>t.jsx("button",{type:"button",className:Z("px-2.5 py-1 text-xs rounded-md",de===B?"bg-primary text-primary-foreground":"text-muted-foreground"),onClick:()=>nt(B),children:B==="link"?"Link":"Content"},B))}),de==="link"&&t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(ae,{className:"h-9 text-sm",placeholder:"https://raw.githubusercontent.com/org/repo/main/README.md",value:xe,onChange:B=>ye(B.target.value)}),he.readmeUrl&&t.jsx("p",{className:"text-xs text-destructive",children:he.readmeUrl})]}),de==="content"&&t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(vt,{className:"text-sm max-h-48 overflow-y-auto resize-none",placeholder:`# README
26
26
 
27
- Describe your MCP here...`,rows:6,value:W,onChange:B=>H(B.target.value)}),he.readme&&t.jsx("p",{className:"text-xs text-destructive",children:he.readme})]})]}),t.jsx(an,{tools:we,onChange:lt,remoteUrl:Ge(Me)||void 0,remoteType:le,externalDiscoverStatus:x,externalDiscoverError:p})]});return t.jsx(jt,{open:s,onOpenChange:Yt,children:t.jsxs(gt,{className:"sm:max-w-[820px] max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs(xt,{className:"space-y-3",children:[t.jsx(ht,{children:f?"Edit MCP Server":"Add MCP Server"}),t.jsx(pn,{current:z}),t.jsxs(pt,{children:[z===1&&"Set up the identity, connection and discover available tools.",z===2&&"Add descriptions, categories and tags to help discovery.",z===3&&"Configure optional metadata, README and tools."]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto pr-1 py-2",children:[z===1&&Ms,z===2&&Es,z===3&&Ds]}),t.jsxs(ft,{className:"flex items-center justify-between gap-2 sm:justify-between",children:[t.jsx("div",{children:z>1&&t.jsxs(G,{variant:"ghost",size:"sm",onClick:Is,children:[t.jsx(ir,{size:14}),"Back"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>Yt(!1),disabled:a,children:"Cancel"}),z<3?t.jsxs(G,{size:"sm",onClick:Ts,children:["Next",t.jsx(Hs,{size:14})]}):t.jsx(G,{size:"sm",onClick:Ps,disabled:a,children:a?"Saving...":f?"Save changes":"Create"})]})]})]})})}function as(s,e){return s.includes(e)?s.filter(r=>r!==e):[...s,e]}function yn(s){return s._meta?.["mcp.mesh"]?.tags??[]}function Nn(s){return s._meta?.["mcp.mesh"]?.categories??[]}function wn(s){return s.server?.remotes?.[0]?.url??"-"}function _n(){const[e,r]=I.useState(""),n=I.useDeferredValue(e),[o,i]=I.useState([]),[a,l]=I.useState([]),[d,u]=I.useState(!1),[m,h]=I.useState(!1),[x,p]=I.useState(null),[c,f]=I.useState(null),[j,C]=rr("private-registry-list","cards"),_=I.useRef(null),y=gs({search:n,tags:o,categories:a}),g=Er(),{createMutation:P,updateMutation:R,deleteMutation:w,bulkCreateMutation:k}=zt(),T=y.data?.pages.flatMap(b=>b.items??[]).filter(Boolean)??[],N=y.data?.pages[0]?.totalCount??T.length,E=o.length>0||a.length>0||n.length>0,v=g.data,D=Array.isArray(v?.tags)?v.tags:[],O=Array.isArray(v?.categories)?v.categories:[],M=b=>{_.current&&(_.current.disconnect(),_.current=null),!(!b||!y.hasNextPage||y.isFetchingNextPage)&&(_.current=new IntersectionObserver(U=>{U[0]?.isIntersecting&&y.hasNextPage&&!y.isFetchingNextPage&&y.fetchNextPage()},{rootMargin:"240px 0px"}),_.current.observe(b))},A=async b=>{try{"data"in b?(await R.mutateAsync(b),V.success("Registry item updated")):(await P.mutateAsync(b),V.success("Registry item created"))}catch(U){throw V.error(U instanceof Error?U.message:"Failed to save item"),U}},$=async b=>{const U=b._meta?.["mcp.mesh"]?.verified===!0;try{await R.mutateAsync({id:b.id,data:{_meta:{...b._meta,"mcp.mesh":{...b._meta?.["mcp.mesh"],verified:!U}}}}),V.success(U?"Removed verified status":"Marked as verified")}catch(K){V.error(K instanceof Error?K.message:"Failed to update item")}},z=async b=>{const U=b._meta?.["mcp.mesh"]?.official===!0;try{await R.mutateAsync({id:b.id,data:{_meta:{...b._meta,"mcp.mesh":{...b._meta?.["mcp.mesh"],official:!U}}}}),V.success(U?"Removed official status":"Marked as official")}catch(K){V.error(K instanceof Error?K.message:"Failed to update item")}},L=async()=>{if(c)try{await w.mutateAsync(c.id),V.success("Registry item deleted"),f(null)}catch(b){V.error(b instanceof Error?b.message:"Failed to delete item")}};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"shrink-0 border-b border-border",children:[t.jsxs("div",{className:"h-12 px-4 md:px-6 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"text-sm font-medium",children:"Items"}),t.jsx(F,{variant:"secondary",className:"text-xs",children:N})]}),t.jsxs("div",{className:"flex items-center gap-2 self-stretch",children:[t.jsxs(ut,{children:[t.jsx(dt,{asChild:!0,children:t.jsxs(G,{variant:"outline",size:"sm",className:Z("h-8","gap-1.5"),children:[t.jsx(Ws,{size:14}),"Filters"]})}),t.jsxs(mt,{align:"end",className:"w-[260px]",children:[t.jsx(Xt,{children:"Tags"}),D.length>0?D.map(b=>t.jsxs(es,{checked:o.includes(b.value),onCheckedChange:()=>i(U=>as(U,b.value)),children:[b.value," (",b.count,")"]},b.value)):t.jsx(Ce,{disabled:!0,children:"No tags available"}),t.jsx(tr,{}),t.jsx(Xt,{children:"Categories"}),O.length>0?O.map(b=>t.jsxs(es,{checked:a.includes(b.value),onCheckedChange:()=>l(U=>as(U,b.value)),children:[b.value," (",b.count,")"]},b.value)):t.jsx(Ce,{disabled:!0,children:"No categories available"})]})]}),t.jsxs(sr,{type:"single",value:j,onValueChange:b=>{(b==="cards"||b==="table")&&C(b)},variant:"outline",className:"h-8",children:[t.jsx(ts,{value:"cards","aria-label":"Cards view",className:"h-8",children:"Cards"}),t.jsx(ts,{value:"table","aria-label":"Table view",className:"h-8",children:"Table"})]}),t.jsx(G,{variant:"outline",size:"sm",className:"h-8",onClick:()=>h(!0),children:"Import CSV"}),t.jsx(G,{size:"sm",className:"h-8",onClick:()=>u(!0),children:"Add MCP Servers"})]})]}),t.jsx("div",{className:"border-t border-border h-12 px-4 md:px-6 flex items-center",children:t.jsxs("label",{className:"flex items-center gap-2.5 h-12 w-full cursor-text",children:[t.jsx(lr,{size:16,className:"text-muted-foreground shrink-0"}),t.jsx(ae,{value:e,onChange:b=>r(b.target.value),placeholder:"Search by id, title, description, or server name",className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),E&&t.jsxs("div",{className:"border-t border-border px-4 md:px-6 py-2 flex flex-wrap items-center gap-2",children:[o.map(b=>t.jsxs(F,{variant:"default",children:["#",b]},`selected-tag-${b}`)),a.map(b=>t.jsx(F,{variant:"outline",children:b},`selected-category-${b}`)),e.trim()&&t.jsxs(F,{variant:"secondary",className:"max-w-[280px] truncate",children:["Search: ",e]}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 ml-auto",onClick:()=>{r(""),i([]),l([])},children:"Clear filters"})]})]}),t.jsxs("div",{className:"flex-1 overflow-auto px-4 md:px-6 py-4",children:[T.length===0?t.jsx("div",{className:"min-h-[320px] rounded-xl border border-dashed border-border flex flex-col items-center justify-center gap-3 p-6 text-center",children:y.isLoading?t.jsxs(t.Fragment,{children:[t.jsx(Le,{className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading items..."})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-medium",children:E?"No items found":"No MCPs in your registry"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:E?"Try removing filters or changing your search to find matching MCPs.":"Add your first MCP item to start building your private registry catalog."}),!E&&t.jsx(G,{size:"lg",onClick:()=>u(!0),children:"Add MCP Servers"})]})}):j==="cards"?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:T.map(b=>t.jsx(rn,{item:b,onEdit:p,onDelete:f,onToggleVerified:$,onToggleOfficial:z},b.id))}),y.hasNextPage&&t.jsx("div",{ref:M,className:"h-2"})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"border rounded-lg overflow-auto",children:t.jsxs(Et,{children:[t.jsx(Dt,{children:t.jsxs(Fe,{children:[t.jsx(ue,{className:"w-[56px]",children:"Icon"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"ID"}),t.jsx(ue,{children:"Tags"}),t.jsx(ue,{children:"Categories"}),t.jsx(ue,{children:"Remote URL"}),t.jsx(ue,{children:"Visibility"}),t.jsx(ue,{className:"text-right w-[68px]",children:"Actions"})]})}),t.jsx(At,{children:T.map(b=>t.jsxs(Fe,{children:[t.jsx(me,{children:t.jsx("div",{className:"size-8 rounded-md border border-border bg-muted/20 overflow-hidden flex items-center justify-center",children:b.server?.icons?.[0]?.src?t.jsx("img",{src:b.server.icons[0].src,alt:b.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground",children:b.title.charAt(0).toUpperCase()})})}),t.jsx(me,{children:b.title}),t.jsx(me,{className:"font-mono",children:b.id}),t.jsx(me,{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:yn(b).slice(0,3).map(U=>t.jsx(F,{variant:"outline",children:U},`${b.id}-tag-${U}`))})}),t.jsx(me,{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:Nn(b).slice(0,3).map(U=>t.jsx(F,{variant:"outline",children:U},`${b.id}-category-${U}`))})}),t.jsx(me,{children:wn(b)}),t.jsx(me,{children:b.is_public?t.jsxs(F,{variant:"default",className:"gap-1",children:[t.jsx(ds,{size:10}),"Public"]}):t.jsx(F,{variant:"secondary",children:"Private"})}),t.jsx(me,{className:"text-right",children:t.jsxs(ut,{children:[t.jsx(dt,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:t.jsx(Mt,{size:18})})}),t.jsxs(mt,{align:"end",children:[t.jsx(Ce,{onClick:()=>p(b),children:"Edit"}),t.jsx(Ce,{variant:"destructive",onClick:()=>f(b),children:"Delete"})]})]})})]},b.id))})]})}),y.hasNextPage&&t.jsx("div",{ref:M,className:"h-2"})]}),y.isFetchingNextPage&&t.jsxs("div",{className:"py-4 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Le,{className:"size-4 animate-spin"}),"Loading more items..."]})]}),t.jsx(bn,{open:d||!!x,onOpenChange:b=>{b||(u(!1),p(null))},item:x,availableTags:D.map(b=>b.value),availableCategories:O.map(b=>b.value),isSubmitting:P.isPending||R.isPending,onSubmit:A},x?.id??"create"),t.jsx(Kr,{open:m,onOpenChange:h,isImporting:k.isPending,onImport:async b=>{try{const U=await k.mutateAsync(b);return V.success(`Imported ${U.created} item(s)`),U}catch(U){throw V.error(U instanceof Error?U.message:"Failed to import CSV"),U}}}),t.jsx(Zr,{open:!!c,onOpenChange:b=>{b||f(null)},title:c?.title??c?.id??"",isDeleting:w.isPending,onConfirm:L})]})}function Cn(s,e,r=!1){const n=I.useRef(null),o=I.useRef(s),i=I.useRef(e),a=I.useRef(r);return o.current=s,i.current=e,a.current=r,d=>{n.current&&n.current.disconnect(),n.current=new IntersectionObserver(u=>{u[0]?.isIntersecting&&i.current&&!a.current&&o.current()}),d&&n.current.observe(d)}}const kn=[{value:"pending",label:"Pending"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"}];function os(s){const e=new Date(s);return Number.isNaN(e.getTime())?s:e.toLocaleDateString()}function cs(s){return{id:s.requested_id??s.server?.name,title:s.title,description:s.description??"",_meta:s._meta,server:s.server,is_public:!1}}function Pt(s){const e=s.server?.icons?.[0]?.src;return typeof e=="string"&&e.length>0?e:null}function ot(s){const e=s._meta?.["mcp.mesh"];return{hasReadmeContent:!!e?.readme?.trim(),hasReadmeLink:!!e?.readme_url?.trim(),readmeContent:e?.readme?.trim()??"",readmeUrl:e?.readme_url?.trim()??""}}function Sn(){const[s,e]=I.useState("pending"),[r,n]=I.useState("created_at"),[o,i]=I.useState("asc"),[a,l]=I.useState(new Set),[d,u]=I.useState(!1),[m,h]=I.useState("private"),[x,p]=I.useState(!1),[c,f]=I.useState(null),[j,C]=I.useState(null),[_,y]=I.useState(null),[g,P]=I.useState(null),[R,w]=I.useState(""),k=Ar({status:s,sortBy:r,sortDirection:o}),{reviewMutation:T,deleteMutation:N}=Ur(),{createMutation:E}=zt(),v=k.data?.pages.flatMap(S=>S.items)??[],D=k.data?.pages[0]?.totalCount??0,O=k.isFetchingNextPage,M=!!k.hasNextPage,A=Cn(()=>{k.isFetchingNextPage||k.fetchNextPage()},M,O),$=new Set(v.filter(S=>S.status==="pending").map(S=>S.id)),z=v.filter(S=>$.has(S.id)),L=a.size,b=z.filter(S=>a.has(S.id)),U=v.filter(S=>a.has(S.id)).length,K=z.length>0&&z.every(S=>a.has(S.id)),te=()=>l(new Set),ee=(S,W)=>{l(H=>{const xe=new Set(H);return W?xe.add(S):xe.delete(S),xe})},se=S=>{l(W=>{const H=new Set(W);return H.has(S)?H.delete(S):H.add(S),H})},re=()=>{l(S=>{const W=new Set(S);for(const H of z)W.add(H.id);return W})},pe=async()=>{const S=j;if(S){C(null),f(S.id);try{await T.mutateAsync({id:S.id,status:"approved",reviewerNotes:void 0});const W=cs(S);await E.mutateAsync({id:W.id,title:W.title,description:W.description,_meta:W._meta,server:W.server,is_public:W.is_public}),V.success("Request approved and added to registry")}catch(W){const H=W instanceof Error?W.message:"Failed to approve request";H.includes("UNIQUE constraint")||H.includes("already exists")?V.error("An item with this ID already exists in the registry. Delete or rename it first."):V.error(H)}finally{f(null)}}},fe=async()=>{if(_)try{await T.mutateAsync({id:_.id,status:"rejected",reviewerNotes:R.trim()||void 0}),V.success("Request rejected"),y(null),w("")}catch(S){V.error(S instanceof Error?S.message:"Failed to reject request")}},ge=async S=>{try{await N.mutateAsync(S.id),V.success("Request deleted")}catch(W){V.error(W instanceof Error?W.message:"Failed to delete request")}},be=async()=>{if(b.length===0||x)return;p(!0),u(!1);let S=0;const W=new Set;for(const xe of b)try{await T.mutateAsync({id:xe.id,status:"approved",reviewerNotes:void 0});const ye=cs(xe);await E.mutateAsync({id:ye.id,title:ye.title,description:ye.description,_meta:ye._meta,server:ye.server,is_public:m==="public"}),S++}catch{W.add(xe.id)}const H=W.size;S>0&&H===0?V.success(`${S} request${S>1?"s":""} approved as ${m}.`):S>0&&H>0?V.warning(`Approved ${S}. Failed ${H}. Failed items remain selected for retry.`):V.error("Bulk approve failed. Selected items were kept for retry."),l(W),p(!1)};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"shrink-0 border-b border-border",children:t.jsxs("div",{className:"h-12 px-4 md:px-6 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"text-sm font-medium",children:"Requests to Publish"}),t.jsx(F,{variant:"secondary",className:"text-xs",children:D})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"inline-flex rounded-lg border border-border p-0.5",children:kn.map(S=>t.jsx("button",{type:"button",className:Z("px-2.5 py-1 text-xs rounded-md transition-colors",s===S.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>e(S.value),onClickCapture:()=>te(),children:S.label},S.value))}),t.jsxs("select",{className:"h-7 rounded-md border border-input bg-background px-2 text-xs",value:`${r}:${o}`,onChange:S=>{const[W,H]=S.target.value.split(":");n(W),i(H)},children:[t.jsx("option",{value:"created_at:asc",children:"Created at (oldest first)"}),t.jsx("option",{value:"created_at:desc",children:"Created at (newest first)"}),t.jsx("option",{value:"title:asc",children:"Alphabetical (A-Z)"}),t.jsx("option",{value:"title:desc",children:"Alphabetical (Z-A)"})]})]})]})}),t.jsxs("div",{className:"flex-1 overflow-auto px-4 md:px-6 py-4",children:[k.isLoading?t.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading requests..."}):k.isError?t.jsxs("div",{className:"p-8 text-center rounded-lg border border-border",children:[t.jsx("p",{className:"text-sm text-destructive",children:"Failed to load publish requests."}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:k.error instanceof Error?k.error.message:"Unknown error"})]}):v.length===0?t.jsx("div",{className:"p-8 text-center rounded-lg border border-border",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:s==="pending"?"No pending publish requests.":s==="approved"?"No approved publish requests.":"No rejected publish requests."})}):t.jsxs(Et,{children:[t.jsx(Dt,{children:t.jsxs(Fe,{children:[s==="pending"&&t.jsx(ue,{className:"w-10",children:t.jsx(ss,{checked:K&&z.length>0,onCheckedChange:S=>{S?re():te()}})}),t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Requester"}),t.jsx(ue,{children:"Tags"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Date"}),t.jsx(ue,{className:"text-right",children:"Actions"})]})}),t.jsx(At,{children:v.map(S=>{const W=Pt(S),H=S._meta?.["mcp.mesh"]?.tags??[],xe=$.has(S.id),ye=a.has(S.id);return t.jsxs(Fe,{className:Z(xe&&"cursor-pointer",ye&&"bg-accent/20"),onClick:()=>{xe&&se(S.id)},children:[s==="pending"&&t.jsx(me,{children:t.jsx(ss,{checked:ye,onCheckedChange:de=>ee(S.id,de===!0),onClick:de=>de.stopPropagation()})}),t.jsx(me,{children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("div",{className:"size-7 rounded-md border border-border bg-muted/30 overflow-hidden shrink-0 flex items-center justify-center",children:W?t.jsx("img",{src:W,alt:S.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground",children:S.title.slice(0,1).toUpperCase()})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:S.title}),S.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:S.description})]})]})}),t.jsx(me,{children:t.jsx("span",{className:"text-sm text-muted-foreground truncate",children:S.requester_name||S.requester_email||"-"})}),t.jsx(me,{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:H.slice(0,3).map(de=>t.jsx(F,{variant:"secondary",className:"text-[10px]",children:de},`${S.id}-tag-${de}`))})}),t.jsx(me,{children:t.jsx(F,{variant:"secondary",className:"capitalize text-[11px]",children:S.status})}),t.jsx(me,{children:t.jsx("span",{className:"text-sm text-muted-foreground",children:os(S.created_at)})}),t.jsx(me,{className:"text-right",children:t.jsxs("div",{className:"flex items-center justify-end gap-1",children:[t.jsxs(G,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),P(S)},children:[t.jsx(xs,{size:13}),"View"]}),xe?t.jsxs(t.Fragment,{children:[t.jsxs(G,{size:"sm",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),C(S)},disabled:c!==null||x||ye,children:[t.jsx(qe,{size:13}),c===S.id?"Approving...":ye?"Selected":"Approve"]}),t.jsxs(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),y(S),w("")},disabled:T.isPending,children:[t.jsx(Js,{size:13}),"Reject"]})]}):t.jsxs(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),ge(S)},disabled:N.isPending,children:[t.jsx(st,{size:13}),"Delete"]})]})})]},S.id)})})]}),v.length>0&&M?t.jsx("div",{ref:A,className:"h-1 w-full"}):null,O&&v.length>0?t.jsx("div",{className:"pt-3 text-xs text-muted-foreground",children:"Loading more requests..."}):null]}),L>0?t.jsx("div",{className:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2",children:t.jsxs("div",{className:"rounded-xl border border-border bg-background/95 shadow-lg backdrop-blur px-3 py-2 flex items-center gap-2",children:[t.jsxs("div",{className:"text-xs text-muted-foreground pr-1",children:[L," selected"]}),t.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:re,disabled:K,children:"Select all"}),t.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:te,children:"Clear selection"}),t.jsxs(G,{size:"sm",className:"h-7 text-xs px-2",onClick:()=>u(!0),disabled:x,children:[t.jsx(qe,{size:13}),"Approve selected"]})]})}):null,t.jsx(jt,{open:!!g,onOpenChange:S=>{S||P(null)},children:t.jsxs(gt,{className:"sm:max-w-[720px] max-h-[85vh] overflow-hidden flex flex-col",children:[t.jsxs(xt,{children:[t.jsx(ht,{children:g?.title??"Request details"}),t.jsx(pt,{children:"Review all metadata sent by the requester before approving."})]}),g&&t.jsxs("div",{className:"flex-1 overflow-y-auto pr-1 space-y-4",children:[t.jsxs("div",{className:"rounded-lg border border-border bg-muted/20 p-3 flex items-center gap-3",children:[t.jsx("div",{className:"size-16 rounded-lg border border-border bg-muted/30 overflow-hidden shrink-0 flex items-center justify-center",children:Pt(g)?t.jsx("img",{src:Pt(g)||"",alt:g.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-lg font-semibold text-muted-foreground",children:g.title.slice(0,1).toUpperCase()})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:g.title}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:g.server?.name||g.id})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Status"}),t.jsx("span",{className:"capitalize",children:g.status})]}),t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Submitted"}),t.jsx("span",{children:os(g.created_at)})]}),t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Requester"}),t.jsx("span",{children:g.requester_name||"-"})]}),t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Email"}),t.jsx("span",{children:g.requester_email||"-"})]})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Remote URL"}),t.jsx("code",{className:"text-xs rounded-md border border-border bg-muted/30 px-2.5 py-2 break-all",children:g.server?.remotes?.[0]?.url??"-"})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Description"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:g.description||"No description provided."})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Tags"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:(g._meta?.["mcp.mesh"]?.tags??[]).length?(g._meta?.["mcp.mesh"]?.tags??[]).map(S=>t.jsx(F,{variant:"secondary",children:S},`${g.id}-detail-tag-${S}`)):t.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Categories"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:(g._meta?.["mcp.mesh"]?.categories??[]).length?(g._meta?.["mcp.mesh"]?.categories??[]).map(S=>t.jsx(F,{variant:"secondary",children:S},`${g.id}-detail-category-${S}`)):t.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"README"}),ot(g).hasReadmeContent?t.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap max-h-40 overflow-y-auto rounded-md border border-border bg-muted/20 px-2.5 py-2",children:ot(g).readmeContent}):ot(g).hasReadmeLink?t.jsxs("a",{href:ot(g).readmeUrl,target:"_blank",rel:"noreferrer",className:"text-sm inline-flex items-center gap-1.5 text-primary hover:underline",children:["Open README link",t.jsx(fr,{size:14})]}):t.jsx("span",{className:"text-sm text-muted-foreground",children:"No README provided."})]})]}),t.jsx(ft,{children:t.jsx(G,{variant:"outline",onClick:()=>P(null),children:"Close"})})]})}),t.jsx(tt,{open:!!j,onOpenChange:S=>{S||C(null)},children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Approve publish request?"}),t.jsxs(We,{children:["This will add"," ",t.jsx("span",{className:"font-medium text-foreground",children:j?.title})," ","to your private registry. The requester will be notified of the approval."]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{children:"Cancel"}),t.jsx(Ze,{onClick:pe,children:"Approve"})]})]})}),t.jsx(tt,{open:d,onOpenChange:u,children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Approve selected requests?"}),t.jsxs(We,{children:["This will approve ",b.length," request",b.length>1?"s":""," and create all resulting apps with the same visibility setting."]})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"bulk-visibility",children:"Visibility for all selected"}),t.jsxs("select",{id:"bulk-visibility",className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:m,onChange:S=>h(S.target.value),children:[t.jsx("option",{value:"private",children:"Private"}),t.jsx("option",{value:"public",children:"Public"})]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{disabled:x,children:"Cancel"}),t.jsx(Ze,{onClick:be,disabled:x||U===0,children:x?"Approving...":"Approve selected"})]})]})}),t.jsx(jt,{open:!!_,onOpenChange:S=>{S||(y(null),w(""))},children:t.jsxs(gt,{children:[t.jsxs(xt,{children:[t.jsx(ht,{children:"Reject publish request?"}),t.jsx(pt,{children:"This request will move to rejected status. You can leave optional notes for context."})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"reject-notes",children:"Reviewer notes (optional)"}),t.jsx(vt,{id:"reject-notes",rows:4,value:R,onChange:S=>w(S.target.value),placeholder:"Reason for rejection..."})]}),t.jsxs(ft,{children:[t.jsx(G,{variant:"outline",onClick:()=>{y(null),w("")},children:"Cancel"}),t.jsx(G,{onClick:fe,disabled:T.isPending,children:T.isPending?"Rejecting...":"Reject"})]})]})})]})}function Rn({revealedKey:s,onRevealedKeyChange:e}){const{org:r}=ie(),{uploadImage:n,isUploading:o}=ys(),{registryName:i,registryIcon:a,acceptPublishRequests:l,requireApiToken:d,storePrivateOnly:u,rateLimitEnabled:m,rateLimitWindow:h,rateLimitMax:x,isSaving:p,updateConfig:c}=js($e),[f,j]=I.useState(i),[C,_]=I.useState(i);i!==C&&(_(i),j(i));const[y,g]=I.useState(a),[P,R]=I.useState(a);a!==P&&(R(a),g(a));const[w,k]=I.useState(String(x)),[T,N]=I.useState(x);x!==T&&(N(x),k(String(x)));const E=Lr(),{generateMutation:v,revokeMutation:D}=qr(),[O,M]=I.useState(""),[A,$]=I.useState(!1),[z,L]=I.useState(null),{handleCopy:b,copied:U}=It(),{handleCopy:K,copied:te}=It(),{handleCopy:ee,copied:se}=It(),re=gs({search:"",tags:[],categories:[],limit:50}),pe=`${window.location.origin}/org/${r.slug}/registry/mcp`,ge=(re.data?.pages.flatMap(q=>q.items??[])??[]).filter(q=>q.is_public).length,be=`${window.location.origin}/org/${r.slug}/registry/publish-request`,S=s?.slice(0,12)??null,W=!!(S&&(E.data?.items??[]).some(q=>q.prefix===S)),H=p||o,xe=()=>{const q=f.trim();!q||q===i||c({registryName:q})},ye=()=>{const q=Number.parseInt(w,10),le=Number.isFinite(q)&&q>=1?q:100;k(String(le)),le!==x&&c({rateLimitMax:le})},de=async q=>{if(!q)return;const le=q.name.split(".").pop()||"png",it=`registry/${r.id}/identity/icon.${le}`,Ue=await n(q,it);Ue?(g(Ue),c({registryIcon:Ue})):V.error("Failed to upload icon. Please try again.")},nt=async()=>{const q=O.trim();if(q)try{const le=await v.mutateAsync(q);le?.key&&(e(le.key),$(!1),M(""),V.success("API key generated. Copy it now — it won't be shown again!"))}catch(le){V.error(le instanceof Error?le.message:"Failed to generate API key")}},Me=async q=>{try{await D.mutateAsync(q),e(null),L(null),V.success("API key revoked")}catch(le){V.error(le instanceof Error?le.message:"Failed to revoke API key")}};return t.jsxs("div",{className:"h-full overflow-auto px-4 md:px-6 py-4",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-4 items-start xl:grid-cols-2",children:[t.jsx("div",{className:"grid gap-4 min-w-0 content-start",children:t.jsxs(ne,{className:"min-w-0 p-4 grid gap-4 content-start",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Registry Identity"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the name and icon shown in the store selector."})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"identity-name",children:"Name"}),t.jsx(ae,{id:"identity-name",value:f,onChange:q=>j(q.target.value),onBlur:xe,disabled:H,placeholder:"Private Registry"})]}),t.jsx(vs,{value:y,onChange:g,onBlur:()=>{const q=y.trim();q!==a&&c({registryIcon:q})},onFileUpload:de,isUploading:o})]})}),t.jsxs("div",{className:"grid gap-4 min-w-0 content-start",children:[t.jsxs(ne,{className:"min-w-0 p-4 grid gap-3 content-start",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Public Registry"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Public URL to consume this registry as an MCP."})]}),t.jsxs(F,{variant:"secondary",children:[ge," ",ge===1?"public item":"public items"]})]}),t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2 flex items-center gap-2 min-w-0",children:[t.jsx("code",{className:"text-xs font-mono break-all leading-5 min-w-0 flex-1 select-all",children:pe}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:()=>b(pe),children:U?t.jsx(Tt,{size:14}):t.jsx(St,{size:14})})]})]}),t.jsxs(ne,{className:"min-w-0 p-4 grid gap-3 content-start",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Store Visibility"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose what appears when users browse this registry in Store."})]}),t.jsx(Oe,{id:"store-private-only",checked:u,onCheckedChange:q=>c({storePrivateOnly:q}),disabled:H})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enabled: show only private apps. Disabled: show public and private apps together."})]}),t.jsxs(ne,{className:"min-w-0 p-4 grid gap-3 content-start",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Publish Requests"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Allow external users to submit MCP servers for review."})]}),t.jsx(Oe,{id:"accept-publish-requests",checked:l,onCheckedChange:q=>c({acceptPublishRequests:q}),disabled:H})]}),t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2 flex items-center gap-2 min-w-0",children:[t.jsx("code",{className:"text-xs font-mono break-all leading-5 min-w-0 flex-1 select-all",children:be}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:()=>K(be),children:te?t.jsx(Tt,{size:14}):t.jsx(St,{size:14})})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border",children:[t.jsxs("div",{children:[t.jsx(X,{className:"text-sm font-medium",children:"Require API Token"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Requests without a valid token will be rejected."})]}),t.jsx(Oe,{id:"require-api-token",checked:d,onCheckedChange:q=>c({requireApiToken:q}),disabled:H})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border",children:[t.jsxs("div",{children:[t.jsx(X,{className:"text-sm font-medium",children:"Rate Limit"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit publish requests per organization by time window."})]}),t.jsx(Oe,{id:"publish-rate-limit",checked:m,onCheckedChange:q=>c({rateLimitEnabled:q}),disabled:H})]}),m&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(X,{htmlFor:"rate-limit-max",className:"text-sm font-medium",children:"Max requests"}),t.jsx(ae,{id:"rate-limit-max",inputMode:"numeric",min:1,type:"number",value:w,onChange:q=>k(q.target.value),onBlur:ye,disabled:H,placeholder:"100"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(X,{htmlFor:"rate-limit-window",className:"text-sm font-medium",children:"Window"}),t.jsxs("select",{id:"rate-limit-window",className:"h-9 rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",value:h,onChange:q=>c({rateLimitWindow:q.target.value}),disabled:H,children:[t.jsx("option",{value:"minute",children:"Per minute"}),t.jsx("option",{value:"hour",children:"Per hour"})]})]})]}),l&&d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-border",children:[t.jsx(ar,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium",children:"API Keys"})]}),s&&!W&&t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 grid gap-1.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"New key (refreshing list...)"}),t.jsx(ae,{readOnly:!0,value:s,className:"h-8 text-xs font-mono bg-background"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxs("div",{className:"grid gap-1.5 flex-1",children:[t.jsx(X,{htmlFor:"api-key-name",className:"text-xs",children:"Key name"}),t.jsx(ae,{id:"api-key-name",value:O,onChange:q=>M(q.target.value),placeholder:"e.g. CI/CD Pipeline",className:"h-8 text-sm"})]}),t.jsxs(G,{variant:"outline",size:"sm",className:"h-8 gap-1.5",disabled:!O.trim()||v.isPending,onClick:nt,children:[v.isPending?t.jsx(Le,{size:14,className:"animate-spin"}):t.jsx(gr,{size:14}),"Generate"]})]}),(E.data?.items?.length??0)>0&&t.jsx("div",{className:"grid gap-2",children:E.data?.items?.map(q=>t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2",children:[t.jsxs("div",{className:"grid gap-1 min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium truncate leading-none",children:q.name}),S===q.prefix?t.jsx(ae,{readOnly:!0,value:A?s??"":"••••••••••••••••••••••••••••••••••••••••••••••••••••",className:"h-8 text-xs font-mono bg-muted/20"}):t.jsx(ae,{readOnly:!0,value:`${q.prefix}••••••••`,className:"h-8 text-xs font-mono bg-muted/20 text-muted-foreground"})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[S===q.prefix&&t.jsxs(t.Fragment,{children:[t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>$(le=>!le),children:A?t.jsx(or,{size:14}):t.jsx(xs,{size:14})}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:!s,onClick:()=>s&&ee(s),children:se?t.jsx(Tt,{size:14}):t.jsx(St,{size:14})})]}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",disabled:D.isPending,onClick:()=>L({id:q.id,name:q.name}),children:t.jsx(st,{size:14})})]})]},q.id))})]})]})]})]}),t.jsx(tt,{open:!!z,onOpenChange:q=>{!q&&!D.isPending&&L(null)},children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Revoke API key?"}),t.jsxs(We,{children:["This action cannot be undone. The key",z?` "${z.name}"`:""," will stop working immediately."]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{disabled:D.isPending,children:"Cancel"}),t.jsx(Ze,{disabled:!z||D.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>z&&Me(z.id),children:D.isPending?"Revoking...":"Revoke key"})]})]})})]})}function Tn(s){const e=Y.c(5),{results:r}=s;if(r.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ne,{className:"p-4 text-sm text-muted-foreground text-center",children:"No broken MCPs in this run. All healthy! ✓"}),e[0]=i):i=e[0],i}let n;e[1]!==r?(n=r.map(In),e[1]=r,e[2]=n):n=e[2];let o;return e[3]!==n?(o=t.jsx("div",{className:"space-y-2",children:n}),e[3]=n,e[4]=o):o=e[4],o}function In(s){return t.jsx(Pn,{result:s},s.id)}function Pn(s){const e=Y.c(49),{result:r}=s,[n,o]=I.useState(!1);let i;if(e[0]!==n||e[1]!==r.action_taken||e[2]!==r.connection_ok||e[3]!==r.duration_ms||e[4]!==r.error_message||e[5]!==r.id||e[6]!==r.item_title||e[7]!==r.status||e[8]!==r.tool_results||e[9]!==r.tools_listed){const a=r.tool_results.filter(Dn);let l;e[11]!==n?(l=()=>o(!n),e[11]=n,e[12]=l):l=e[12];let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"text-red-500 text-sm mt-0.5",children:"✗"}),e[13]=d):d=e[13];let u;e[14]!==r.item_title?(u=t.jsx("h4",{className:"text-sm font-medium truncate",children:r.item_title}),e[14]=r.item_title,e[15]=u):u=e[15];let m;e[16]!==r.status?(m=r.status.replace("_"," "),e[16]=r.status,e[17]=m):m=e[17];let h;e[18]!==m?(h=t.jsx(F,{variant:"destructive",className:"capitalize text-[10px] shrink-0",children:m}),e[18]=m,e[19]=h):h=e[19];let x;e[20]!==u||e[21]!==h?(x=t.jsxs("div",{className:"flex items-center gap-2",children:[u,h]}),e[20]=u,e[21]=h,e[22]=x):x=e[22];const p=r.connection_ok?"✓":"✗";let c;e[23]!==p?(c=t.jsxs("span",{children:["conn: ",p]}),e[23]=p,e[24]=c):c=e[24];const f=r.tools_listed?"✓":"✗";let j;e[25]!==f?(j=t.jsxs("span",{children:["tools listed: ",f]}),e[25]=f,e[26]=j):j=e[26];let C;e[27]!==r.duration_ms?(C=t.jsxs("span",{children:[r.duration_ms,"ms"]}),e[27]=r.duration_ms,e[28]=C):C=e[28];const _=a.length>0&&t.jsxs("span",{className:"text-red-600",children:[a.length," tool",a.length>1?"s":""," ","failed"]});let y;e[29]!==r.action_taken?(y=r.action_taken!=="none"&&t.jsx(F,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:r.action_taken.replace(/_/g," ")}),e[29]=r.action_taken,e[30]=y):y=e[30];let g;e[31]!==j||e[32]!==C||e[33]!==_||e[34]!==y||e[35]!==c?(g=t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground flex-wrap",children:[c,j,C,_,y]}),e[31]=j,e[32]=C,e[33]=_,e[34]=y,e[35]=c,e[36]=g):g=e[36];let P;e[37]!==r.error_message?(P=r.error_message&&t.jsx("p",{className:"text-xs text-red-600 line-clamp-2",children:r.error_message}),e[37]=r.error_message,e[38]=P):P=e[38];let R;e[39]!==g||e[40]!==P||e[41]!==x?(R=t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[x,g,P]}),e[39]=g,e[40]=P,e[41]=x,e[42]=R):R=e[42];const w=n?"▲":"▼";let k;e[43]!==w?(k=t.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 mt-1",children:w}),e[43]=w,e[44]=k):k=e[44];let T;e[45]!==R||e[46]!==k||e[47]!==l?(T=t.jsxs("button",{type:"button",className:"w-full text-left p-3 flex items-start gap-3 hover:bg-muted/30 transition-colors",onClick:l,children:[d,R,k]}),e[45]=R,e[46]=k,e[47]=l,e[48]=T):T=e[48],i=t.jsxs(ne,{className:"overflow-hidden",children:[T,n&&t.jsxs("div",{className:"border-t border-border p-3 space-y-2 bg-muted/10",children:[r.error_message&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Full Error"}),t.jsx("pre",{className:"text-[11px] bg-red-500/5 border border-red-500/10 rounded px-2.5 py-1.5 whitespace-pre-wrap break-all text-red-700",children:r.error_message})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Connection"}),t.jsx("p",{className:Z("text-xs font-medium",r.connection_ok?"text-emerald-600":"text-red-600"),children:r.connection_ok?"OK":"Failed"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tools Listed"}),t.jsx("p",{className:Z("text-xs font-medium",r.tools_listed?"text-emerald-600":"text-red-600"),children:r.tools_listed?"Yes":"No"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Duration"}),t.jsxs("p",{className:"text-xs font-medium",children:[r.duration_ms,"ms"]})]})]}),a.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-red-600",children:["Failed Tools (",a.length,")"]}),a.map(N=>t.jsxs("div",{className:"rounded border border-red-500/10 bg-red-500/5 px-2.5 py-1.5 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono font-medium text-red-700",children:N.toolName}),t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[N.durationMs,"ms"]})]}),N.error&&t.jsx("pre",{className:"text-[11px] whitespace-pre-wrap break-all text-red-600",children:N.error})]},`${r.id}-${N.toolName}`))]}),r.tool_results.length>0&&r.tool_results.some(En)&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Passing Tools"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:r.tool_results.filter(Mn).map(N=>t.jsxs(F,{variant:"secondary",className:"text-[10px]",children:["✓ ",N.toolName]},`${r.id}-${N.toolName}-pass`))})]})]})]}),e[0]=n,e[1]=r.action_taken,e[2]=r.connection_ok,e[3]=r.duration_ms,e[4]=r.error_message,e[5]=r.id,e[6]=r.item_title,e[7]=r.status,e[8]=r.tool_results,e[9]=r.tools_listed,e[10]=i}else i=e[10];return i}function Mn(s){return s.success}function En(s){return s.success}function Dn(s){return!s.success}const An=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}];function $n(s){const r=s.trim().split(/\s+/);if(r.length!==5)return{frequency:"custom",minute:0,hour:9,weekDay:1,dayOfMonth:1};const[n,o,i,a,l]=r,d=Number(n),u=Number(o),m=Number(i),h=Number(l);return Number.isInteger(d)&&Number.isInteger(u)&&d>=0&&d<=59&&u>=0&&u<=23?i==="*"&&l==="*"?{frequency:"daily",minute:d,hour:u,weekDay:1,dayOfMonth:1}:i==="*/14"&&l==="*"?{frequency:"biweekly",minute:d,hour:u,weekDay:1,dayOfMonth:1}:i==="*"&&Number.isInteger(h)&&h>=0&&h<=6?{frequency:"weekly",minute:d,hour:u,weekDay:h,dayOfMonth:1}:l==="*"&&Number.isInteger(m)&&m>=1&&m<=31?{frequency:"monthly",minute:d,hour:u,weekDay:1,dayOfMonth:m}:{frequency:"custom",minute:d,hour:u,weekDay:1,dayOfMonth:1}:{frequency:"custom",minute:0,hour:9,weekDay:1,dayOfMonth:1}}function On(s,e){return`${String(s).padStart(2,"0")}:${String(e).padStart(2,"0")}`}function ct(s){return s.frequency==="daily"?`${s.minute} ${s.hour} * * *`:s.frequency==="weekly"?`${s.minute} ${s.hour} * * ${s.weekDay}`:s.frequency==="biweekly"?`${s.minute} ${s.hour} */14 * *`:s.frequency==="monthly"?`${s.minute} ${s.hour} ${s.dayOfMonth} * *`:s.currentValue}function zn(s){const e=Y.c(60),{value:r,onChange:n,disabled:o}=s,i=o===void 0?!1:o;let a;e[0]!==r?(a=$n(r),e[0]=r,e[1]=a):a=e[1];const l=a,d=l.frequency==="custom";let u;e[2]!==n||e[3]!==l.dayOfMonth||e[4]!==l.hour||e[5]!==l.minute||e[6]!==l.weekDay||e[7]!==r?(u=A=>{if(A==="custom"){n(r);return}n(ct({frequency:A,hour:l.hour,minute:l.minute,weekDay:l.weekDay,dayOfMonth:l.dayOfMonth,currentValue:r}))},e[2]=n,e[3]=l.dayOfMonth,e[4]=l.hour,e[5]=l.minute,e[6]=l.weekDay,e[7]=r,e[8]=u):u=e[8];const m=u;let h;e[9]!==n||e[10]!==l.dayOfMonth||e[11]!==l.frequency||e[12]!==l.weekDay||e[13]!==r?(h=A=>{const[$,z]=A.split(":"),L=Number($),b=Number(z);!Number.isInteger(L)||!Number.isInteger(b)||n(ct({frequency:l.frequency,hour:L,minute:b,weekDay:l.weekDay,dayOfMonth:l.dayOfMonth,currentValue:r}))},e[9]=n,e[10]=l.dayOfMonth,e[11]=l.frequency,e[12]=l.weekDay,e[13]=r,e[14]=h):h=e[14];const x=h;let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(X,{children:"Frequency"}),e[15]=p):p=e[15];let c;e[16]!==m?(c=A=>m(A.target.value),e[16]=m,e[17]=c):c=e[17];let f,j,C,_,y;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx("option",{value:"daily",children:"Daily"}),_=t.jsx("option",{value:"weekly",children:"Weekly"}),y=t.jsx("option",{value:"biweekly",children:"Every 2 weeks"}),f=t.jsx("option",{value:"monthly",children:"Monthly"}),j=t.jsx("option",{value:"custom",children:"Custom (raw cron)"}),e[18]=f,e[19]=j,e[20]=C,e[21]=_,e[22]=y):(f=e[18],j=e[19],C=e[20],_=e[21],y=e[22]);let g;e[23]!==i||e[24]!==l.frequency||e[25]!==c?(g=t.jsxs("label",{className:"space-y-1",children:[p,t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:l.frequency,onChange:c,disabled:i,children:[C,_,y,f,j]})]}),e[23]=i,e[24]=l.frequency,e[25]=c,e[26]=g):g=e[26];let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(X,{children:"Time"}),e[27]=P):P=e[27];let R;e[28]!==l.hour||e[29]!==l.minute?(R=On(l.hour,l.minute),e[28]=l.hour,e[29]=l.minute,e[30]=R):R=e[30];let w;e[31]!==x?(w=A=>x(A.target.value),e[31]=x,e[32]=w):w=e[32];const k=i||d;let T;e[33]!==R||e[34]!==w||e[35]!==k?(T=t.jsxs("label",{className:"space-y-1",children:[P,t.jsx(ae,{type:"time",value:R,onChange:w,disabled:k})]}),e[33]=R,e[34]=w,e[35]=k,e[36]=T):T=e[36];let N;e[37]!==i||e[38]!==n||e[39]!==l.dayOfMonth||e[40]!==l.frequency||e[41]!==l.hour||e[42]!==l.minute||e[43]!==l.weekDay||e[44]!==r?(N=l.frequency==="weekly"?t.jsxs("label",{className:"space-y-1",children:[t.jsx(X,{children:"Day of week"}),t.jsx("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:l.weekDay,onChange:A=>n(ct({frequency:"weekly",hour:l.hour,minute:l.minute,weekDay:Number(A.target.value),dayOfMonth:l.dayOfMonth,currentValue:r})),disabled:i,children:An.map(Un)})]}):l.frequency==="monthly"?t.jsxs("label",{className:"space-y-1",children:[t.jsx(X,{children:"Day of month"}),t.jsx(ae,{type:"number",min:1,max:31,value:l.dayOfMonth,onChange:A=>{const $=Number(A.target.value);!Number.isInteger($)||$<1||$>31||n(ct({frequency:"monthly",hour:l.hour,minute:l.minute,weekDay:l.weekDay,dayOfMonth:$,currentValue:r}))},disabled:i})]}):t.jsxs("div",{className:"space-y-1",children:[t.jsx(X,{children:"Schedule notes"}),t.jsx("div",{className:"h-9 rounded-md border border-input bg-muted/20 px-3 text-xs text-muted-foreground flex items-center",children:l.frequency==="biweekly"?"Biweekly uses an every-14-days cron approximation.":l.frequency==="custom"?"Edit raw cron directly below.":"Runs in your server timezone."})]}),e[37]=i,e[38]=n,e[39]=l.dayOfMonth,e[40]=l.frequency,e[41]=l.hour,e[42]=l.minute,e[43]=l.weekDay,e[44]=r,e[45]=N):N=e[45];let E;e[46]!==g||e[47]!==T||e[48]!==N?(E=t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[g,T,N]}),e[46]=g,e[47]=T,e[48]=N,e[49]=E):E=e[49];let v;e[50]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(X,{children:"Raw cron expression"}),e[50]=v):v=e[50];let D;e[51]!==n?(D=A=>n(A.target.value),e[51]=n,e[52]=D):D=e[52];let O;e[53]!==i||e[54]!==D||e[55]!==r?(O=t.jsxs("label",{className:"space-y-1 block",children:[v,t.jsx(ae,{value:r,onChange:D,disabled:i,placeholder:"*/15 * * * *"})]}),e[53]=i,e[54]=D,e[55]=r,e[56]=O):O=e[56];let M;return e[57]!==E||e[58]!==O?(M=t.jsxs("div",{className:"space-y-2",children:[E,O]}),e[57]=E,e[58]=O,e[59]=M):M=e[59],M}function Un(s){return t.jsx("option",{value:s.value,children:s.label},s.value)}function Ln(s,e){return s.onFailure!==e.onFailure||s.perMcpTimeoutMs!==e.perMcpTimeoutMs||s.perToolTimeoutMs!==e.perToolTimeoutMs||s.maxAgentSteps!==e.maxAgentSteps||s.testPublicOnly!==e.testPublicOnly||s.testPrivateOnly!==e.testPrivateOnly||s.includePendingRequests!==e.includePendingRequests||(s.agentContext??"")!==(e.agentContext??"")||s.schedule!==e.schedule||s.cronExpression!==e.cronExpression}function qn(){const{settings:s,saveMutation:e}=ps(),r=Rr(),n=Tr(),o=I.useRef(s),[i,a]=I.useState(s),[l,d]=I.useState(!1),[u,m]=I.useState(!1);o.current!==s&&(o.current=s,a(s));const h=Ln(i,s),x=c=>{d(!1),a(f=>({...f,...c}))},p=async()=>{const c=i.cronExpression?.trim()??"";let f=s.scheduleEventId??"";if(i.schedule==="cron"&&c.length>0){const C=c!==(s.cronExpression??"");C&&f&&await n.mutateAsync(f),(C||!f)&&(f=(await r.mutateAsync({cronExpression:c,config:i})).scheduleEventId)}else f&&(await n.mutateAsync(f),f="");const j={...i,cronExpression:c,scheduleEventId:f,agentContext:(i.agentContext??"").trim()};await e.mutateAsync(j),a(j),d(!0),setTimeout(()=>d(!1),3e3)};return t.jsxs(ne,{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"QA Configuration"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure how the MCP QA agent validates registry entries."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[h&&t.jsx(F,{className:"bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:"Unsaved changes"}),l&&t.jsx(F,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:"✓ Saved"}),t.jsx(G,{size:"sm",onClick:p,disabled:e.isPending||r.isPending||n.isPending||!h,children:e.isPending||r.isPending||n.isPending?"Saving...":"Save settings"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"On failure",hint:"Automatic action to apply when an MCP fails tests in a run."}),t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:i.onFailure,onChange:c=>x({onFailure:c.target.value}),children:[t.jsx("option",{value:"none",children:"Do nothing"}),t.jsx("option",{value:"unlisted",children:"Unlist from store (keep in registry)"}),t.jsx("option",{value:"remove_public",children:"Remove from public store"}),t.jsx("option",{value:"remove_private",children:"Remove from private registry"}),t.jsx("option",{value:"remove_all",children:"Remove from all (public + private)"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Test scope",hint:"Choose whether tests should run for public items, private items, or both."}),t.jsxs("div",{className:"flex items-center gap-4 rounded-md border border-input px-3 py-2",children:[t.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:i.testPublicOnly,onChange:c=>x({testPublicOnly:c.target.checked,testPrivateOnly:c.target.checked?!1:i.testPrivateOnly})}),"Public only"]}),t.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:i.testPrivateOnly,onChange:c=>x({testPrivateOnly:c.target.checked,testPublicOnly:c.target.checked?!1:i.testPublicOnly})}),"Private only"]})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Publish requests",hint:"Include pending publish requests in QA runs to validate them before publishing to the store."}),t.jsx("div",{className:"flex items-center gap-4 rounded-md border border-input px-3 py-2",children:t.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:i.includePendingRequests,onChange:c=>x({includePendingRequests:c.target.checked})}),"Include pending requests in tests"]})})]}),t.jsxs("div",{className:"space-y-1 md:col-span-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(Ee,{label:"Additional test context (prompt)",hint:"Extra runtime context passed to the agent, such as valid emails, tenant IDs, or known test entities."}),t.jsxs(G,{size:"sm",variant:"outline",className:"h-7",onClick:()=>m(c=>!c),children:[u?"Hide":"View"," default system prompt"]})]}),t.jsx(vt,{value:i.agentContext??"",onChange:c=>x({agentContext:c.target.value}),placeholder:'Example: Use "my-user@company.com" as a valid email for Google Drive share/create_permission tests.',rows:3}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Use this field for real data required by some tools (valid email, fixed IDs, test environment details, etc)."}),u&&t.jsx("pre",{className:"text-[11px] bg-muted/50 border border-border rounded px-3 py-2 whitespace-pre-wrap max-h-64 overflow-auto",children:Nr})]}),t.jsxs("div",{className:"space-y-1 md:col-span-2",children:[t.jsx(Ee,{label:"Schedule",hint:"Set automatic test runs. Manual mode runs only when you click Start QA run."}),t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:i.schedule??"manual",onChange:c=>x({schedule:c.target.value}),children:[t.jsx("option",{value:"manual",children:"Manual only"}),t.jsx("option",{value:"cron",children:"Cron schedule"})]}),(i.schedule??"manual")==="cron"&&t.jsx(zn,{value:i.cronExpression??"",onChange:c=>x({cronExpression:c})})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Per MCP timeout (ms)",hint:"Max total time allowed to validate one MCP."}),t.jsx(ae,{type:"number",value:i.perMcpTimeoutMs,onChange:c=>x({perMcpTimeoutMs:Number(c.target.value)})})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Per tool timeout (ms)",hint:"Max time allowed for each individual tool call."}),t.jsx(ae,{type:"number",value:i.perToolTimeoutMs,onChange:c=>x({perToolTimeoutMs:Number(c.target.value)})})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Max agent steps",hint:"Maximum number of reasoning/tool steps in Agentic mode."}),t.jsx(ae,{type:"number",value:i.maxAgentSteps,onChange:c=>x({maxAgentSteps:Number(c.target.value)}),min:1,max:30})]})]})]})}function Ee(s){const e=Y.c(13),{label:r,hint:n}=s;let o;e[0]!==r?(o=t.jsx(X,{children:r}),e[0]=r,e[1]=o):o=e[1];const i=`About ${r}`;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Zs,{size:14}),e[2]=a):a=e[2];let l;e[3]!==i?(l=t.jsx(jr,{asChild:!0,children:t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors","aria-label":i,children:a})}),e[3]=i,e[4]=l):l=e[4];let d;e[5]!==n?(d=t.jsx(vr,{side:"top",className:"max-w-72",children:n}),e[5]=n,e[6]=d):d=e[6];let u;e[7]!==l||e[8]!==d?(u=t.jsxs(br,{children:[l,d]}),e[7]=l,e[8]=d,e[9]=u):u=e[9];let m;return e[10]!==o||e[11]!==u?(m=t.jsxs("div",{className:"flex items-center gap-1.5",children:[o,u]}),e[10]=o,e[11]=u,e[12]=m):m=e[12],m}function Fn(s){switch(s){case"authenticated":return"bg-emerald-500/10 text-emerald-600 border-emerald-500/20";case"needs_auth":return"bg-amber-500/10 text-amber-600 border-amber-500/20";default:return"bg-zinc-500/10 text-zinc-500 border-zinc-500/20"}}function Bn(s){switch(s){case"authenticated":return"Authenticated";case"needs_auth":return"Needs Auth";default:return"Not checked"}}function Qn({entry:s,onAuthChanged:e,failedToolsCount:r,failedResultCount:n}){const[o,i]=I.useState(!1),[a,l]=I.useState(""),[d,u]=I.useState(!1),m=Sr(),{updateMutation:h}=zt(),x=s.mapping.connection_id,p=s.mapping.auth_status,c=s.item?.title??s.mapping.item_id,f=s.item?.server?.icons?.[0]?.src??null,j=s.item?.is_public??!1,C=s.item?.is_unlisted??!1,_=s.source==="request",y=Ie({queryKey:Q.monitorConnectionAuthProbe(x),queryFn:async()=>Fs({url:`/mcp/${x}`,token:null}),staleTime:1e4,retry:1,refetchOnWindowFocus:!1}),g=y.data,P=y.isLoading,R=g?.supportsOAuth??!1,w=g?.hasOAuthToken??!1,k=g?.isServerError??!1,T=g?.isAuthenticated??!1,N=P?"checking":k?"server_error":R?T?w?"oauth_connected":"connected":"oauth_available":T?"connected":"token_required",E=()=>{m.mutate({connectionId:x,authStatus:"authenticated"},{onSuccess:()=>e()})},v=async()=>{i(!0);try{const z=(await y.refetch()).data;if(!z){V.error(`Could not reach "${c}". The remote MCP may be down.`);return}if(z.isAuthenticated){V.success(`"${c}" is reachable. You can re-authenticate if needed.`);return}if(z.isServerError){V.error(`Server error for "${c}". The remote MCP may be down.`);return}if(!z.supportsOAuth){V.warning(`"${c}" does not support OAuth. Use the Token field to paste an API key.`);return}V.info(`Opening authentication window for "${c}"...`);const L=await Bs({connectionId:x,clientName:`MCP Test - ${c}`,timeout:18e4,scope:"offline_access"});if(L.error){V.error(`OAuth failed for "${c}": ${L.error}`);return}L.tokenInfo?(await fetch(`/api/connections/${x}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.tokenInfo.accessToken,refreshToken:L.tokenInfo.refreshToken,expiresIn:L.tokenInfo.expiresIn,scope:L.tokenInfo.scope,clientId:L.tokenInfo.clientId,clientSecret:L.tokenInfo.clientSecret,tokenEndpoint:L.tokenInfo.tokenEndpoint})})).ok||L.token&&await D(L.token):L.token&&await D(L.token),V.success(`"${c}" authenticated!`),E(),await y.refetch()}catch($){console.error("[MonitorConnectionsPanel] Auth error:",$),V.error(`Error: ${$ instanceof Error?$.message:String($)}`)}finally{i(!1)}},D=async $=>{if(!(await fetch("/mcp/self",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:x,data:{connection_token:$}}}})})).ok)throw new Error("Failed to save token")},O=async()=>{if(!a.trim()){V.error("Token cannot be empty.");return}i(!0);try{await D(a),V.success(`Token saved for "${c}"!`),u(!1),l(""),E(),await y.refetch()}catch($){V.error(`Error saving token: ${$ instanceof Error?$.message:String($)}`)}finally{i(!1)}},M=p==="authenticated"&&!w&&!d&&a.length===0,A=async $=>{if(_){V.info("Visibility controls are available only for store items.");return}if(!s.item){V.error("Registry item not found for this connection.");return}try{await h.mutateAsync({id:s.item.id,data:$}),V.success("Visibility updated"),e()}catch(z){V.error(z instanceof Error?z.message:"Failed to update visibility")}};return t.jsxs(ne,{className:"p-3 space-y-3 h-full",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:"size-10 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0 flex items-center justify-center",children:f?t.jsx("img",{src:f,alt:c,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:c.charAt(0).toUpperCase()})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:c}),t.jsx("p",{className:"text-xs text-muted-foreground break-all",children:s.remoteUrl??"-"}),t.jsxs("div",{className:"mt-1 flex items-center gap-1.5 flex-wrap",children:[t.jsx(F,{variant:"outline",className:Z("text-[10px]",Fn(p)),children:Bn(p)}),t.jsx(F,{variant:j?"default":"secondary",className:"text-[10px]",children:j?"Public":"Not public"}),t.jsx(F,{variant:"outline",className:"text-[10px]",children:_?"Request":"Store"}),t.jsxs(F,{variant:"outline",className:Z("text-[10px]",N==="server_error"?"border-destructive/40 text-destructive":N==="oauth_connected"?"border-emerald-500/30 text-emerald-600":N==="oauth_available"?"border-sky-500/30 text-sky-600":N==="token_required"?"border-amber-500/30 text-amber-600":"text-muted-foreground"),children:[N==="checking"&&"Checking auth...",N==="server_error"&&"Server error",N==="oauth_connected"&&"OAuth connected",N==="oauth_available"&&"OAuth available",N==="token_required"&&"Token/manual auth",N==="connected"&&"Connected"]}),C&&t.jsx(F,{variant:"outline",className:"text-[10px]",children:"Hidden in private"}),(n>0||r>0)&&t.jsxs(F,{variant:"destructive",className:"text-[10px]",children:[n," failed MCP / ",r," failed tools"]})]})]})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.jsxs(ut,{children:[t.jsx(dt,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:t.jsx(Mt,{size:16})})}),t.jsx(mt,{align:"end",children:_?t.jsx(Ce,{disabled:!0,children:"Request item (no store visibility controls)"}):t.jsxs(t.Fragment,{children:[t.jsx(Ce,{onClick:()=>A({is_public:!1}),children:"Hide from public store"}),t.jsx(Ce,{onClick:()=>A({is_unlisted:!0}),children:"Hide from private store"}),t.jsx(Ce,{onClick:()=>A({is_public:!0,is_unlisted:!1}),children:"Show in both stores"})]})})]})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 flex-wrap",children:[R&&t.jsx(G,{size:"sm",onClick:v,disabled:o,children:o?"...":w?"Re-auth OAuth":"OAuth"}),t.jsx(G,{size:"sm",variant:"outline",onClick:()=>y.refetch(),disabled:o||P,children:P?"Checking...":"Re-check"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Token/API key (for MCPs that require manual auth)"}),M?t.jsxs("div",{className:"relative group",children:[t.jsx("div",{className:"h-8 px-3 flex items-center rounded-md border border-border bg-muted/50 text-muted-foreground font-mono text-xs",children:"••••••••••••••••"}),t.jsx("button",{type:"button",onClick:()=>u(!0),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted",title:"Replace token",children:"Edit"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ae,{type:"password",placeholder:"Paste API token / key...",value:a,onChange:$=>l($.target.value),className:"h-8 text-xs flex-1",onKeyDown:$=>{$.key==="Enter"&&O()}}),t.jsx(G,{size:"sm",className:"h-8 text-xs",onClick:O,disabled:o||!a.trim(),children:"Save"}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:()=>{u(!1),l("")},children:"✕"})]})]})]})}function Vn(){const s=Y.c(55),e=hs(),n=yt("completed").data?.items?.[0],o=rt(n?.id,void 0,n?.status),i=kr(),[a,l]=I.useState("all");let d,u,m,h,x,p;if(s[0]!==e||s[1]!==o.data?.items||s[2]!==a||s[3]!==i){const j=e.data?.items??[];let C;s[10]!==o.data?.items?(C=(o.data?.items??[]).reduce(Yn,{}),s[10]=o.data?.items,s[11]=C):C=s[11];const _=C;let y;s[12]!==a?(y=se=>a==="all"?!0:se.source===a,s[12]=a,s[13]=y):y=s[13];const g=j.filter(y);d=ne,x="p-4 space-y-3";let P,R,w,k;s[14]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("h3",{className:"text-sm font-semibold",children:"QA Connections"}),w=t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"We auto-detect auth type. Use OAuth when available, or always paste a Token/API key for manual auth MCPs."}),k=t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Listing tools alone does not imply authenticated status."}),P=t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Cards show MCP icon, auth status, and latest failed test counters."}),s[14]=P,s[15]=R,s[16]=w,s[17]=k):(P=s[14],R=s[15],w=s[16],k=s[17]);const T=a==="all"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground";let N;s[18]!==T?(N=Z("px-2.5 py-1 text-xs rounded-md transition-colors",T),s[18]=T,s[19]=N):N=s[19];let E;s[20]===Symbol.for("react.memo_cache_sentinel")?(E=()=>l("all"),s[20]=E):E=s[20];let v;s[21]!==N?(v=t.jsx("button",{type:"button",className:N,onClick:E,children:"All"}),s[21]=N,s[22]=v):v=s[22];const D=a==="store"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground";let O;s[23]!==D?(O=Z("px-2.5 py-1 text-xs rounded-md transition-colors",D),s[23]=D,s[24]=O):O=s[24];let M;s[25]===Symbol.for("react.memo_cache_sentinel")?(M=()=>l("store"),s[25]=M):M=s[25];let A;s[26]!==O?(A=t.jsx("button",{type:"button",className:O,onClick:M,children:"Store"}),s[26]=O,s[27]=A):A=s[27];const $=a==="request"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground";let z;s[28]!==$?(z=Z("px-2.5 py-1 text-xs rounded-md transition-colors",$),s[28]=$,s[29]=z):z=s[29];let L;s[30]===Symbol.for("react.memo_cache_sentinel")?(L=()=>l("request"),s[30]=L):L=s[30];let b;s[31]!==z?(b=t.jsx("button",{type:"button",className:z,onClick:L,children:"Requests"}),s[31]=z,s[32]=b):b=s[32];let U;s[33]!==v||s[34]!==A||s[35]!==b?(U=t.jsxs("div",{children:[R,w,k,P,t.jsxs("div",{className:"mt-2 inline-flex rounded-lg border border-border p-0.5",children:[v,A,b]})]}),s[33]=v,s[34]=A,s[35]=b,s[36]=U):U=s[36];let K;s[37]!==i?(K=()=>{i.mutate(void 0,{onSuccess:Kn,onError:Gn})},s[37]=i,s[38]=K):K=s[38];const te=i.isPending?"Syncing...":"Sync";let ee;s[39]!==i.isPending||s[40]!==K||s[41]!==te?(ee=t.jsx(G,{size:"sm",variant:"outline",onClick:K,disabled:i.isPending,children:te}),s[39]=i.isPending,s[40]=K,s[41]=te,s[42]=ee):ee=s[42],s[43]!==U||s[44]!==ee?(p=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[U,ee]}),s[43]=U,s[44]=ee,s[45]=p):p=s[45],u="space-y-2",m=g.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:'No QA connections for this filter. Click "Sync" to create mappings from store items and pending requests.'}),h=g.length>0&&t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:g.map(se=>{const re=_[se.mapping.item_id]??{failedTools:0,failedResults:0};return t.jsx(Qn,{entry:se,onAuthChanged:()=>e.refetch(),failedToolsCount:re.failedTools,failedResultCount:re.failedResults},se.mapping.id)})}),s[0]=e,s[1]=o.data?.items,s[2]=a,s[3]=i,s[4]=d,s[5]=u,s[6]=m,s[7]=h,s[8]=x,s[9]=p}else d=s[4],u=s[5],m=s[6],h=s[7],x=s[8],p=s[9];let c;s[46]!==u||s[47]!==m||s[48]!==h?(c=t.jsxs("div",{className:u,children:[m,h]}),s[46]=u,s[47]=m,s[48]=h,s[49]=c):c=s[49];let f;return s[50]!==d||s[51]!==x||s[52]!==p||s[53]!==c?(f=t.jsxs(d,{className:x,children:[p,c]}),s[50]=d,s[51]=x,s[52]=p,s[53]=c,s[54]=f):f=s[54],f}function Gn(s){return V.error(`Sync failed: ${s.message}`)}function Kn(){return V.success("Connections synced (store + pending requests)")}function Yn(s,e){const r=s[e.item_id]??{failedTools:0,failedResults:0},n=e.tool_results.filter(Hn).length;return r.failedTools=r.failedTools+n,(e.status==="failed"||e.status==="error")&&(r.failedResults=r.failedResults+1),s[e.item_id]=r,s}function Hn(s){return!s.success}function Ns(s){switch(s){case"running":return"bg-blue-500/10 text-blue-600 border-blue-500/20";case"completed":return"bg-emerald-500/10 text-emerald-600 border-emerald-500/20";case"failed":return"bg-red-500/10 text-red-600 border-red-500/20";case"cancelled":return"bg-zinc-500/10 text-zinc-500 border-zinc-500/20";case"pending":return"bg-amber-500/10 text-amber-600 border-amber-500/20";default:return""}}function ws(s,e){if(!s)return null;const r=e?new Date(e).getTime():Date.now(),n=new Date(s).getTime(),o=r-n;return o<1e3?`${o}ms`:o<6e4?`${(o/1e3).toFixed(1)}s`:`${Math.floor(o/6e4)}m ${Math.round(o%6e4/1e3)}s`}function _s(s){const e=new Map;for(const r of s)e.has(r.toolName)&&e.delete(r.toolName),e.set(r.toolName,r);return Array.from(e.values())}function Wn(s){return s.total_items?Math.min(100,Math.round(s.tested_items/s.total_items*100)):0}function Jn(s){if(!s)return null;const e=s.match(/Not executed tools \((\d+)\/(\d+)\):/i);if(!e)return null;const r=Number(e[2]);return Number.isFinite(r)&&r>=0?r:null}function Zn(s){const e=Y.c(57),{result:r,index:n,icon:o}=s,[i,a]=I.useState(!1);let l;if(e[0]!==i||e[1]!==o||e[2]!==n||e[3]!==r.action_taken||e[4]!==r.agent_summary||e[5]!==r.connection_ok||e[6]!==r.duration_ms||e[7]!==r.error_message||e[8]!==r.id||e[9]!==r.item_title||e[10]!==r.status||e[11]!==r.tool_results||e[12]!==r.tools_listed){const d=_s(r.tool_results),u=d.every(si),m=d.filter(ti),h=m.filter(ei).length,x=m.filter(Xn).length,p=m.length>0,c=m.length;let f;e[14]!==r.agent_summary?(f=Jn(r.agent_summary),e[14]=r.agent_summary,e[15]=f):f=e[15];const j=f,C=Math.max(d.length,j??0),_=C>0?`${c}/${C} tools tested`:"0 tools";let y;e[16]!==i?(y=()=>a(!i),e[16]=i,e[17]=y):y=e[17];const g=n+1;let P;e[18]!==g?(P=t.jsx("span",{className:"text-muted-foreground w-5 text-right shrink-0",children:g}),e[18]=g,e[19]=P):P=e[19];let R;e[20]!==o||e[21]!==r.item_title?(R=t.jsx("div",{className:"size-5 rounded border border-border bg-muted/20 overflow-hidden shrink-0 flex items-center justify-center",children:o?t.jsx("img",{src:o,alt:r.item_title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-[9px] font-semibold text-muted-foreground",children:r.item_title.charAt(0).toUpperCase()})}),e[20]=o,e[21]=r.item_title,e[22]=R):R=e[22];const w=r.status==="passed"?"text-emerald-600":r.status==="needs_auth"?"text-amber-600":"text-red-600";let k;e[23]!==w?(k=Z("shrink-0",w),e[23]=w,e[24]=k):k=e[24];const T=r.status==="passed"?"✓":r.status==="needs_auth"?"🔑":"✗";let N;e[25]!==k||e[26]!==T?(N=t.jsx("span",{className:k,children:T}),e[25]=k,e[26]=T,e[27]=N):N=e[27];let E;e[28]!==r.item_title?(E=t.jsx("span",{className:"font-medium truncate flex-1 min-w-0",children:r.item_title}),e[28]=r.item_title,e[29]=E):E=e[29];let v;e[30]!==r.duration_ms?(v=t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[r.duration_ms,"ms"]}),e[30]=r.duration_ms,e[31]=v):v=e[31];const D=r.status==="passed"?"text-emerald-600 border-emerald-500/20":r.status==="needs_auth"?"text-amber-600 border-amber-500/20":"text-red-600 border-red-500/20";let O;e[32]!==D?(O=Z("text-[9px] capitalize shrink-0",D),e[32]=D,e[33]=O):O=e[33];let M;e[34]!==r.status?(M=r.status.replace("_"," "),e[34]=r.status,e[35]=M):M=e[35];let A;e[36]!==O||e[37]!==M?(A=t.jsx(F,{variant:"outline",className:O,children:M}),e[36]=O,e[37]=M,e[38]=A):A=e[38];let $;e[39]!==r.connection_ok?($=r.connection_ok?t.jsx("span",{className:"text-[10px] text-emerald-600 shrink-0",children:"conn✓"}):t.jsx("span",{className:"text-[10px] text-red-600 shrink-0",children:"conn✗"}),e[39]=r.connection_ok,e[40]=$):$=e[40];const z=r.tools_listed&&t.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:p?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-emerald-600",children:[h,"✓"]})," ",t.jsxs("span",{className:Z(x>0?"text-red-600":""),children:[x,"✗"]})]}):u&&d.length>0?t.jsxs("span",{children:[d.length," tools found"]}):"no tools"});let L;e[41]!==_?(L=t.jsx(F,{variant:"outline",className:"text-[9px] shrink-0",children:_}),e[41]=_,e[42]=L):L=e[42];const b=i?"▲":"▼";let U;e[43]!==b?(U=t.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:b}),e[43]=b,e[44]=U):U=e[44];let K;e[45]!==N||e[46]!==E||e[47]!==v||e[48]!==A||e[49]!==$||e[50]!==z||e[51]!==L||e[52]!==U||e[53]!==y||e[54]!==P||e[55]!==R?(K=t.jsxs("button",{type:"button",className:"w-full text-left flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors",onClick:y,children:[P,R,N,E,v,A,$,z,L,U]}),e[45]=N,e[46]=E,e[47]=v,e[48]=A,e[49]=$,e[50]=z,e[51]=L,e[52]=U,e[53]=y,e[54]=P,e[55]=R,e[56]=K):K=e[56],l=t.jsxs("div",{className:"rounded border border-border overflow-hidden",children:[K,i&&t.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-2 bg-muted/10",children:[r.error_message&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Error"}),t.jsx("pre",{className:"text-[11px] bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 whitespace-pre-wrap break-all text-red-700 max-h-20 overflow-auto",children:r.error_message})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:[t.jsxs("span",{children:["Connection:"," ",t.jsx("span",{className:Z(r.connection_ok?"text-emerald-600":"text-red-600"),children:r.connection_ok?"OK":"Failed"})]}),t.jsxs("span",{children:["Tools listed:"," ",t.jsx("span",{className:Z(r.tools_listed?"text-emerald-600":"text-red-600"),children:r.tools_listed?"Yes":"No"})]}),r.action_taken!=="none"&&t.jsxs(F,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:["action: ",r.action_taken]})]}),p?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tools tested: ",h," passed, ",x," failed"]}),t.jsx("div",{className:"space-y-0.5",children:m.map((te,ee)=>t.jsx(ri,{tool:te},`${r.id}-${te.toolName}-${ee}`))})]}):u&&d.length>0?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tools discovered (",d.length,") - not individually tested (health-check mode)"]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:d.map((te,ee)=>t.jsx(F,{variant:"outline",className:"text-[10px] font-mono",children:te.toolName},`${r.id}-${te.toolName}-${ee}`))})]}):r.tools_listed?t.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No tools found on this server."}):null,r.agent_summary&&t.jsx("p",{className:"text-[11px] bg-muted/50 rounded px-2 py-1.5",children:r.agent_summary})]})]}),e[0]=i,e[1]=o,e[2]=n,e[3]=r.action_taken,e[4]=r.agent_summary,e[5]=r.connection_ok,e[6]=r.duration_ms,e[7]=r.error_message,e[8]=r.id,e[9]=r.item_title,e[10]=r.status,e[11]=r.tool_results,e[12]=r.tools_listed,e[13]=l}else l=e[13];return l}function Xn(s){return!s.success}function ei(s){return s.success}function ti(s){return s.outputPreview!=="health_check: not called"}function si(s){return s.outputPreview==="health_check: not called"}function ri(s){const e=Y.c(30),{tool:r}=s,[n,o]=I.useState(!1);let i;e[0]!==n?(i=()=>o(!n),e[0]=n,e[1]=i):i=e[1];const a=r.success?"text-emerald-600":"text-red-600";let l;e[2]!==a?(l=Z("font-bold",a),e[2]=a,e[3]=l):l=e[3];const d=r.success?"✓":"✗";let u;e[4]!==l||e[5]!==d?(u=t.jsx("span",{className:l,children:d}),e[4]=l,e[5]=d,e[6]=u):u=e[6];let m;e[7]!==r.toolName?(m=t.jsx("span",{className:"font-mono truncate flex-1",children:r.toolName}),e[7]=r.toolName,e[8]=m):m=e[8];let h;e[9]!==r.durationMs?(h=t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[r.durationMs,"ms"]}),e[9]=r.durationMs,e[10]=h):h=e[10];let x;e[11]!==r.error?(x=r.error&&t.jsx("span",{className:"text-red-500 truncate max-w-28",title:r.error,children:r.error}),e[11]=r.error,e[12]=x):x=e[12];const p=n?"▲":"▼";let c;e[13]!==p?(c=t.jsx("span",{className:"text-muted-foreground",children:p}),e[13]=p,e[14]=c):c=e[14];let f;e[15]!==i||e[16]!==c||e[17]!==u||e[18]!==m||e[19]!==h||e[20]!==x?(f=t.jsxs("button",{type:"button",className:"w-full text-left flex items-center gap-2 px-2 py-1 text-[11px] hover:bg-muted/30 transition-colors",onClick:i,children:[u,m,h,x,c]}),e[15]=i,e[16]=c,e[17]=u,e[18]=m,e[19]=h,e[20]=x,e[21]=f):f=e[21];let j;e[22]!==n||e[23]!==r.error||e[24]!==r.input||e[25]!==r.outputPreview?(j=n&&t.jsxs("div",{className:"border-t border-border px-2 py-1.5 space-y-1 bg-muted/10 text-[11px]",children:[r.error&&t.jsx("pre",{className:"bg-red-500/5 border border-red-500/10 rounded px-2 py-1 whitespace-pre-wrap break-all text-red-700 max-h-20 overflow-auto",children:r.error}),r.input&&Object.keys(r.input).length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Input"}),t.jsx("pre",{className:"bg-muted/50 rounded px-2 py-1 whitespace-pre-wrap break-all max-h-16 overflow-auto",children:JSON.stringify(r.input,null,2)})]}),r.outputPreview&&t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Output"}),t.jsx("pre",{className:"bg-muted/50 rounded px-2 py-1 whitespace-pre-wrap break-all max-h-16 overflow-auto",children:r.outputPreview})]})]}),e[22]=n,e[23]=r.error,e[24]=r.input,e[25]=r.outputPreview,e[26]=j):j=e[26];let C;return e[27]!==f||e[28]!==j?(C=t.jsxs("div",{className:"rounded border border-border overflow-hidden",children:[f,j]}),e[27]=f,e[28]=j,e[29]=C):C=e[29],C}function ni({activeRunId:s,onRunChange:e}){const{settings:r}=ps(),[n,o]=I.useState(null),[i,a]=I.useState(!1),l=I.useRef(0),d=I.useRef(null),u=wr(),m=_r(),h=Ot(s),x=yt(),p=hs(),c=h.data?.run??null,f=c?.status,j=c?.config_snapshot?.monitorMode??c?.config_snapshot?.testMode,C=rt(s,void 0,f),_=(x.data?.items??[]).find(v=>v.status==="running"),y=x.data?.items?.[0]?.id;!s&&y&&d.current!==y&&(d.current=y,queueMicrotask(()=>{e(y)}));const g=async()=>{const v=Date.now();if(v-l.current<1e3)return;l.current=v;const D=n??r.monitorMode,O=await u.mutateAsync({...r,monitorMode:D});e(O.run.id)},P=async()=>{if(_&&_.id!==s&&_.status==="running"){a(!0);return}await g()},R=async()=>{s&&await m.mutateAsync(s)},w=c?.status==="running",k=c?ws(c.started_at,c.finished_at):null,T=C.data?.items??[],N=(p.data?.items??[]).reduce((v,D)=>(v[D.mapping.item_id]=D.item?.server?.icons?.[0]?.src??null,v),{}),E=n??r.monitorMode;return t.jsxs("div",{className:"space-y-4 min-w-0",children:[t.jsxs("div",{className:"space-y-4 min-w-0",children:[t.jsxs(ne,{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Current QA Run"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a full QA validation run and track results in real time."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.id!==s&&t.jsxs(F,{variant:"outline",className:"text-[10px]",children:["Run in progress: ",_.id.slice(0,8)]}),t.jsxs(G,{size:"sm",onClick:P,disabled:u.isPending||w,className:"gap-1.5",children:[t.jsx(yr,{size:14}),u.isPending?"Starting...":_&&_.id!==s?"Start another run":"Start QA run"]}),t.jsxs(G,{size:"sm",variant:"outline",onClick:R,disabled:!s||!w,className:"gap-1.5",children:[t.jsx(Xs,{size:14}),"Cancel"]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsxs("label",{className:"space-y-1",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"QA mode"}),t.jsxs("select",{className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm",value:E,onChange:v=>o(v.target.value),disabled:w,children:[t.jsx("option",{value:"health_check",children:"Health check"}),t.jsx("option",{value:"tool_call",children:"Tool call"}),t.jsx("option",{value:"full_agent",children:"Agentic (LLM model)"})]})]}),t.jsxs("label",{className:"space-y-1",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"QA run history (pick a previous run)"}),t.jsxs("select",{className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm",value:s??"",onChange:v=>e(v.target.value||void 0),children:[t.jsx("option",{value:"",children:"Auto-select latest run"}),(x.data?.items??[]).map(v=>t.jsxs("option",{value:v.id,children:[new Date(v.created_at).toLocaleString()," -"," ",v.status]},v.id))]})]})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground rounded-md bg-muted/30 px-2.5 py-2",children:E==="health_check"?"Checks connectivity and tool listing only — no tool calls are made.":E==="tool_call"?"Calls each tool with empty inputs to verify it responds without errors.":"Uses an LLM model to execute chained tool calls and validate outputs."}),c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsx(F,{className:Z("capitalize",Ns(c.status),c.status==="running"?"animate-pulse":""),children:c.status}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[c.tested_items,"/",c.total_items," tested"]}),k&&t.jsx("span",{className:"text-xs text-muted-foreground",children:k}),w&&c.current_item_id&&t.jsxs("span",{className:"text-xs text-muted-foreground truncate max-w-64",children:["QA on:"," ",t.jsx("span",{className:"font-mono",children:c.current_item_id})]})]}),t.jsx("div",{className:"h-2.5 rounded-full bg-muted overflow-hidden",children:t.jsx("div",{className:Z("h-full transition-all duration-500",c.failed_items>0?"bg-orange-500":"bg-emerald-500",w?"animate-pulse":""),style:{width:`${Wn(c)}%`}})}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-emerald-600",children:"Passed"}),t.jsx("p",{className:"text-lg font-bold text-emerald-600",children:c.passed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-red-600",children:"Failed"}),t.jsx("p",{className:"text-lg font-bold text-red-600",children:c.failed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Skipped"}),t.jsx("p",{className:"text-lg font-bold",children:c.skipped_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Total"}),t.jsx("p",{className:"text-lg font-bold",children:c.total_items})]})]})]}):t.jsx("p",{className:"text-xs text-muted-foreground",children:"No run selected yet. Start a new run to begin."})]}),t.jsxs(ne,{className:"p-4 space-y-2 min-h-[360px]",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsxs("h3",{className:"text-sm font-semibold",children:["QA results log (",T.length,")"]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Live per-MCP test output for the selected run."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[w&&t.jsx(F,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20 animate-pulse",children:"run in progress"}),c&&t.jsxs(F,{variant:"outline",className:"text-[10px]",children:["progress: ",c.tested_items," of ",c.total_items," MCPs"]}),j&&t.jsxs(F,{variant:"outline",className:"text-[10px]",children:["mode: ",j.replace("_"," ")]})]})]}),T.length===0?t.jsx("div",{className:"h-[280px] rounded border border-dashed border-border flex items-center justify-center text-xs text-muted-foreground",children:"No results yet. Start a run to see live logs here."}):t.jsx("div",{ref:v=>{v&&w&&v.scrollHeight-v.scrollTop-v.clientHeight<120&&requestAnimationFrame(()=>{v.scrollTop=v.scrollHeight})},className:"space-y-1 max-h-[60vh] overflow-auto pr-1",children:T.map((v,D)=>t.jsx(Zn,{result:v,index:D,icon:N[v.item_id]},v.id))})]})]}),t.jsx(tt,{open:i,onOpenChange:a,children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Start another test run?"}),t.jsxs(We,{children:["There is already a run in progress",_?` (${_.id})`:"",". Starting another run may increase database load and slow down both executions."]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{children:"Cancel"}),t.jsx(Ze,{onClick:()=>{a(!1),g()},children:"Start anyway"})]})]})})]})}function Cs(s){switch(s){case"passed":return"bg-emerald-500/10 text-emerald-600 border-emerald-500/20";case"failed":return"bg-red-500/10 text-red-600 border-red-500/20";case"error":return"bg-orange-500/10 text-orange-600 border-orange-500/20";case"needs_auth":return"bg-amber-500/10 text-amber-600 border-amber-500/20";case"skipped":return"bg-zinc-500/10 text-zinc-500 border-zinc-500/20";default:return""}}function ii(s){switch(s){case"passed":return"✓";case"failed":return"✗";case"error":return"⚠";case"needs_auth":return"🔑";case"skipped":return"⏭";default:return"?"}}function li(s){const e=Y.c(27),{tool:r}=s,[n,o]=I.useState(!1);let i;e[0]!==n?(i=()=>o(!n),e[0]=n,e[1]=i):i=e[1];const a=r.success?"text-emerald-600":"text-red-600";let l;e[2]!==a?(l=Z("text-xs font-bold",a),e[2]=a,e[3]=l):l=e[3];const d=r.success?"✓":"✗";let u;e[4]!==l||e[5]!==d?(u=t.jsx("span",{className:l,children:d}),e[4]=l,e[5]=d,e[6]=u):u=e[6];let m;e[7]!==r.toolName?(m=t.jsx("span",{className:"text-xs font-mono truncate flex-1",children:r.toolName}),e[7]=r.toolName,e[8]=m):m=e[8];let h;e[9]!==r.durationMs?(h=t.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[r.durationMs,"ms"]}),e[9]=r.durationMs,e[10]=h):h=e[10];const x=n?"▲":"▼";let p;e[11]!==x?(p=t.jsx("span",{className:"text-[10px] text-muted-foreground",children:x}),e[11]=x,e[12]=p):p=e[12];let c;e[13]!==i||e[14]!==u||e[15]!==m||e[16]!==h||e[17]!==p?(c=t.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",onClick:i,children:[u,m,h,p]}),e[13]=i,e[14]=u,e[15]=m,e[16]=h,e[17]=p,e[18]=c):c=e[18];let f;e[19]!==n||e[20]!==r.error||e[21]!==r.input||e[22]!==r.outputPreview?(f=n&&t.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5 bg-muted/20",children:[r.error&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Error"}),t.jsx("pre",{className:"text-[11px] bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 whitespace-pre-wrap break-all text-red-700",children:r.error})]}),r.input&&Object.keys(r.input).length>0&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Input"}),t.jsx("pre",{className:"text-[11px] bg-muted/50 rounded px-2 py-1.5 whitespace-pre-wrap break-all max-h-24 overflow-auto",children:JSON.stringify(r.input,null,2)})]}),r.outputPreview&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Output preview"}),t.jsx("pre",{className:"text-[11px] bg-muted/50 rounded px-2 py-1.5 whitespace-pre-wrap break-all max-h-24 overflow-auto",children:r.outputPreview})]}),!r.error&&!r.outputPreview&&(!r.input||Object.keys(r.input).length===0)&&t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"No additional details."})]}),e[19]=n,e[20]=r.error,e[21]=r.input,e[22]=r.outputPreview,e[23]=f):f=e[23];let j;return e[24]!==c||e[25]!==f?(j=t.jsxs("div",{className:"rounded border border-border",children:[c,f]}),e[24]=c,e[25]=f,e[26]=j):j=e[26],j}function ai(s){const e=Y.c(52),{result:r}=s,[n,o]=I.useState(r.status!=="passed");let i;if(e[0]!==n||e[1]!==r.action_taken||e[2]!==r.agent_summary||e[3]!==r.connection_ok||e[4]!==r.duration_ms||e[5]!==r.error_message||e[6]!==r.id||e[7]!==r.item_title||e[8]!==r.status||e[9]!==r.tool_results||e[10]!==r.tools_listed){const a=_s(r.tool_results),l=a.every(ui),d=a.filter(di),u=d.filter(ci).length,m=d.filter(oi).length,h=d.length>0;let x;e[12]!==n?(x=()=>o(!n),e[12]=n,e[13]=x):x=e[13];let p;e[14]!==r.status?(p=ii(r.status),e[14]=r.status,e[15]=p):p=e[15];let c;e[16]!==p?(c=t.jsx("span",{className:"text-base shrink-0",children:p}),e[16]=p,e[17]=c):c=e[17];let f;e[18]!==r.item_title?(f=t.jsx("p",{className:"text-sm font-medium truncate",children:r.item_title}),e[18]=r.item_title,e[19]=f):f=e[19];let j;e[20]!==r.duration_ms?(j=t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[r.duration_ms,"ms"]}),e[20]=r.duration_ms,e[21]=j):j=e[21];const C=r.connection_ok?"✓":"✗";let _;e[22]!==C?(_=t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["conn: ",C]}),e[22]=C,e[23]=_):_=e[23];const y=r.tools_listed?"✓":"✗";let g;e[24]!==y?(g=t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["tools listed: ",y]}),e[24]=y,e[25]=g):g=e[25];const P=a.length>0&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:h?t.jsxs(t.Fragment,{children:["tools: ",u,"✓ ",m,"✗"]}):t.jsxs(t.Fragment,{children:[a.length," tools found"]})});let R;e[26]!==r.action_taken?(R=r.action_taken!=="none"&&t.jsxs(F,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:["action: ",r.action_taken]}),e[26]=r.action_taken,e[27]=R):R=e[27];let w;e[28]!==g||e[29]!==P||e[30]!==R||e[31]!==j||e[32]!==_?(w=t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[j,_,g,P,R]}),e[28]=g,e[29]=P,e[30]=R,e[31]=j,e[32]=_,e[33]=w):w=e[33];let k;e[34]!==w||e[35]!==f?(k=t.jsxs("div",{className:"min-w-0 flex-1",children:[f,w]}),e[34]=w,e[35]=f,e[36]=k):k=e[36];let T;e[37]!==r.status?(T=Z("capitalize shrink-0",Cs(r.status)),e[37]=r.status,e[38]=T):T=e[38];let N;e[39]!==r.status?(N=r.status.replace("_"," "),e[39]=r.status,e[40]=N):N=e[40];let E;e[41]!==T||e[42]!==N?(E=t.jsx(F,{className:T,children:N}),e[41]=T,e[42]=N,e[43]=E):E=e[43];const v=n?"▲":"▼";let D;e[44]!==v?(D=t.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:v}),e[44]=v,e[45]=D):D=e[45];let O;e[46]!==k||e[47]!==E||e[48]!==D||e[49]!==x||e[50]!==c?(O=t.jsxs("button",{type:"button",className:"w-full text-left px-4 py-3 flex items-center gap-3 hover:bg-muted/30 transition-colors",onClick:x,children:[c,k,E,D]}),e[46]=k,e[47]=E,e[48]=D,e[49]=x,e[50]=c,e[51]=O):O=e[51],i=t.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[O,n&&t.jsxs("div",{className:"border-t border-border px-4 py-3 space-y-2 bg-muted/10",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Connection"}),t.jsx("p",{className:Z("text-xs font-medium",r.connection_ok?"text-emerald-600":"text-red-600"),children:r.connection_ok?"Connected":"Failed"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tools Listed"}),t.jsx("p",{className:Z("text-xs font-medium",r.tools_listed?"text-emerald-600":"text-red-600"),children:r.tools_listed?`Yes (${a.length})`:"No"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Duration"}),t.jsxs("p",{className:"text-xs font-medium",children:[r.duration_ms,"ms"]})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Action Taken"}),t.jsx("p",{className:"text-xs font-medium capitalize",children:r.action_taken.replace(/_/g," ")})]})]}),r.error_message&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Error Message"}),t.jsx("pre",{className:"text-xs bg-red-500/5 border border-red-500/10 rounded px-3 py-2 whitespace-pre-wrap break-all text-red-700",children:r.error_message})]}),h?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tool Results (",u," passed, ",m," failed)"]}),t.jsx("div",{className:"space-y-1",children:d.map((M,A)=>t.jsx(li,{tool:M},`${r.id}-${M.toolName}-${A}`))})]}):l&&a.length>0?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tools discovered (",a.length,") — not individually tested (health-check mode)"]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:a.map((M,A)=>t.jsx(F,{variant:"outline",className:"text-[10px] font-mono",children:M.toolName},`${r.id}-${M.toolName}-${A}`))})]}):null,r.agent_summary&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Agent Summary"}),t.jsx("p",{className:"text-xs bg-muted/50 rounded px-3 py-2",children:r.agent_summary})]})]})]}),e[0]=n,e[1]=r.action_taken,e[2]=r.agent_summary,e[3]=r.connection_ok,e[4]=r.duration_ms,e[5]=r.error_message,e[6]=r.id,e[7]=r.item_title,e[8]=r.status,e[9]=r.tool_results,e[10]=r.tools_listed,e[11]=i}else i=e[11];return i}function oi(s){return!s.success}function ci(s){return s.success}function di(s){return s.outputPreview!=="health_check: not called"}function ui(s){return s.outputPreview==="health_check: not called"}function mi(s){const e=Y.c(4),{value:r,onChange:n}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[{value:"all",label:"All"},{value:"passed",label:"Passed"},{value:"failed",label:"Failed"},{value:"error",label:"Error"},{value:"needs_auth",label:"Needs Auth"},{value:"skipped",label:"Skipped"}],e[0]=o):o=e[0];const i=o;let a;return e[1]!==n||e[2]!==r?(a=t.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:i.map(l=>t.jsx("button",{type:"button",className:Z("text-[11px] px-2 py-0.5 rounded-full border transition-colors",r===l.value?"bg-primary text-primary-foreground border-primary":"bg-muted/30 border-border hover:bg-muted/50"),onClick:()=>n(l.value),children:l.label},l.value))}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function xi(s){const e=Y.c(46),{runId:r}=s,[n,o]=I.useState("all"),i=Ot(r),a=i.data?.run,l=rt(r,void 0,a?.status);let d;e[0]!==l.data?.items?(d=l.data?.items??[],e[0]=l.data?.items,e[1]=d):d=e[1];const u=d;let m;e[2]!==u||e[3]!==n?(m=n==="all"?u:u.filter(v=>v.status===n),e[2]=u,e[3]=n,e[4]=m):m=e[4];const h=m;if(!r){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(ne,{className:"p-6 text-center space-y-2",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a run to inspect details."})}),e[5]=v):v=e[5],v}let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("h3",{className:"text-sm font-semibold",children:"Run Detail"}),e[6]=x):x=e[6];let p;e[7]!==r?(p=t.jsxs("div",{children:[x,t.jsx("p",{className:"text-[10px] text-muted-foreground font-mono",children:r})]}),e[7]=r,e[8]=p):p=e[8];let c;e[9]!==a?(c=a&&t.jsx(F,{className:Z("capitalize",Cs(a.status)),children:a.status}),e[9]=a,e[10]=c):c=e[10];let f;e[11]!==l||e[12]!==i?(f=t.jsx(G,{size:"sm",variant:"outline",onClick:()=>{i.refetch(),l.refetch()},children:"Refresh"}),e[11]=l,e[12]=i,e[13]=f):f=e[13];let j;e[14]!==c||e[15]!==f?(j=t.jsxs("div",{className:"flex items-center gap-2",children:[c,f]}),e[14]=c,e[15]=f,e[16]=j):j=e[16];let C;e[17]!==p||e[18]!==j?(C=t.jsx(ne,{className:"p-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p,j]})}),e[17]=p,e[18]=j,e[19]=C):C=e[19];let _;e[20]!==a?(_=a&&t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2 text-xs",children:[t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Total"}),t.jsx("p",{className:"text-lg font-bold",children:a.total_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tested"}),t.jsx("p",{className:"text-lg font-bold",children:a.tested_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-emerald-600",children:"Passed"}),t.jsx("p",{className:"text-lg font-bold text-emerald-600",children:a.passed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-red-600",children:"Failed"}),t.jsx("p",{className:"text-lg font-bold text-red-600",children:a.failed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Skipped"}),t.jsx("p",{className:"text-lg font-bold",children:a.skipped_items})]})]}),e[20]=a,e[21]=_):_=e[21];let y;e[22]!==a?(y=a&&(a.started_at||a.finished_at)&&t.jsxs(ne,{className:"p-3 flex items-center gap-4 text-xs text-muted-foreground flex-wrap",children:[a.started_at&&t.jsxs("span",{children:["Started: ",new Date(a.started_at).toLocaleString()]}),a.finished_at&&t.jsxs("span",{children:["Finished: ",new Date(a.finished_at).toLocaleString()]}),a.started_at&&a.finished_at&&t.jsxs("span",{className:"font-medium text-foreground",children:["Duration:"," ",((new Date(a.finished_at).getTime()-new Date(a.started_at).getTime())/1e3).toFixed(1),"s"]})]}),e[22]=a,e[23]=y):y=e[23];let g;e[24]!==n?(g=t.jsx(mi,{value:n,onChange:o}),e[24]=n,e[25]=g):g=e[25];const P=h.length!==1?"s":"";let R;e[26]!==h.length||e[27]!==P?(R=t.jsxs("span",{className:"text-xs text-muted-foreground",children:[h.length," result",P]}),e[26]=h.length,e[27]=P,e[28]=R):R=e[28];let w;e[29]!==g||e[30]!==R?(w=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,R]}),e[29]=g,e[30]=R,e[31]=w):w=e[31];let k;e[32]!==u||e[33]!==h.length?(k=h.length===0&&t.jsx(ne,{className:"p-4 text-sm text-muted-foreground text-center",children:u.length===0?"No test results yet.":"No results match the current filter."}),e[32]=u,e[33]=h.length,e[34]=k):k=e[34];let T;e[35]!==h?(T=h.map(hi),e[35]=h,e[36]=T):T=e[36];let N;e[37]!==k||e[38]!==T?(N=t.jsxs("div",{className:"space-y-2",children:[k,T]}),e[37]=k,e[38]=T,e[39]=N):N=e[39];let E;return e[40]!==y||e[41]!==w||e[42]!==N||e[43]!==C||e[44]!==_?(E=t.jsxs("div",{className:"space-y-3",children:[C,_,y,w,N]}),e[40]=y,e[41]=w,e[42]=N,e[43]=C,e[44]=_,e[45]=E):E=e[45],E}function hi(s){return t.jsx(ai,{result:s},s.id)}function pi(s){return s.tested_items?`${Math.round(s.passed_items/s.tested_items*100)}%`:"-"}function fi(s){const e=Y.c(20),{selectedRunId:r,onSelectRun:n}=s,o=yt();let i;e[0]!==o.data?.items?(i=o.data?.items??[],e[0]=o.data?.items,e[1]=i):i=e[1];const a=i;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"QA run history"}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Browse previous QA executions and reopen their logs."})]}),e[2]=l):l=e[2];let d;e[3]!==o?(d=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,t.jsx(G,{size:"sm",variant:"outline",onClick:()=>o.refetch(),children:"Refresh"})]}),e[3]=o,e[4]=d):d=e[4];let u;e[5]!==a.length?(u=a.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No runs yet. Start QA from the Dashboard tab."}),e[5]=a.length,e[6]=u):u=e[6];let m;if(e[7]!==n||e[8]!==a||e[9]!==r){let p;e[11]!==n||e[12]!==r?(p=c=>{const f=ws(c.started_at,c.finished_at),j=pi(c),C=r===c.id;return t.jsxs("button",{type:"button",onClick:()=>n(c.id),className:Z("w-full text-left rounded-lg border p-3 transition-colors",C?"border-primary bg-primary/5":"border-border hover:bg-muted/30"),children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(c.created_at).toLocaleString()})}),t.jsx(F,{className:Z("capitalize",Ns(c.status)),children:c.status})]}),t.jsxs("div",{className:"mt-2 flex items-center gap-3 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground",children:[c.tested_items,"/",c.total_items," tested"]}),t.jsxs("span",{className:"text-emerald-600 font-medium",children:[c.passed_items," passed"]}),c.failed_items>0&&t.jsxs("span",{className:"text-red-600 font-medium",children:[c.failed_items," failed"]}),c.skipped_items>0&&t.jsxs("span",{className:"text-muted-foreground",children:[c.skipped_items," skipped"]}),t.jsxs("span",{className:"text-muted-foreground",children:["pass rate: ",j]}),f&&t.jsx("span",{className:"text-muted-foreground",children:f})]}),c.config_snapshot&&t.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[t.jsx(F,{variant:"outline",className:"text-[9px]",children:(c.config_snapshot.monitorMode??c.config_snapshot.testMode??"health_check").replace("_"," ")}),c.config_snapshot.onFailure!=="none"&&t.jsxs(F,{variant:"outline",className:"text-[9px] text-red-600",children:["on fail:"," ",c.config_snapshot.onFailure.replace(/_/g," ")]})]})]},c.id)},e[11]=n,e[12]=r,e[13]=p):p=e[13],m=a.map(p),e[7]=n,e[8]=a,e[9]=r,e[10]=m}else m=e[10];let h;e[14]!==u||e[15]!==m?(h=t.jsxs("div",{className:"space-y-2 max-h-[520px] overflow-auto",children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let x;return e[17]!==d||e[18]!==h?(x=t.jsx(ne,{className:"p-4",children:t.jsxs("div",{className:"space-y-3",children:[d,h]})}),e[17]=d,e[18]=h,e[19]=x):x=e[19],x}function gi(){const s=Y.c(20),[e,r]=I.useState(void 0),[n,o]=I.useState("tests"),a=Ot(e).data?.run?.status,l=rt(e,void 0,a);let d;s[0]!==l.data?.items?(d=l.data?.items??[],s[0]=l.data?.items,s[1]=d):d=s[1];let u;s[2]!==d?(u=d.filter(ji),s[2]=d,s[3]=u):u=s[3];const m=u;let h;s[4]===Symbol.for("react.memo_cache_sentinel")?(h=[{id:"tests",label:"Tests"},{id:"configuration",label:"Configuration"},{id:"connections",label:"Connections"}],s[4]=h):h=s[4];let x;s[5]!==n?(x=t.jsx("nav",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar",children:h.map(C=>{const _=n===C.id;return t.jsx("button",{type:"button",className:Z("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex gap-1.5 items-center whitespace-nowrap",_?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),onClick:()=>o(C.id),children:t.jsx("span",{children:C.label})},C.id)})}),s[5]=n,s[6]=x):x=s[6];let p;s[7]!==e||s[8]!==n||s[9]!==m?(p=n==="tests"&&t.jsxs("div",{className:"space-y-6",children:[t.jsx(ni,{activeRunId:e,onRunChange:r}),t.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-4 items-start",children:[t.jsxs("div",{className:"xl:col-span-8 space-y-6 min-w-0",children:[e&&t.jsx(xi,{runId:e}),t.jsx(fi,{selectedRunId:e,onSelectRun:r})]}),t.jsxs("div",{className:"xl:col-span-4 space-y-2 min-w-0",children:[t.jsxs("h3",{className:"text-sm font-semibold",children:["Broken MCPs"," ",m.length>0&&t.jsx(F,{variant:"destructive",className:"text-[10px] ml-1",children:m.length})]}),t.jsx(Tn,{results:m})]})]})]}),s[7]=e,s[8]=n,s[9]=m,s[10]=p):p=s[10];let c;s[11]!==n?(c=n==="configuration"&&t.jsx(qn,{}),s[11]=n,s[12]=c):c=s[12];let f;s[13]!==n?(f=n==="connections"&&t.jsx(Vn,{}),s[13]=n,s[14]=f):f=s[14];let j;return s[15]!==x||s[16]!==p||s[17]!==c||s[18]!==f?(j=t.jsxs("div",{className:"h-full overflow-auto px-4 md:px-6 py-4 space-y-6",children:[x,p,c,f]}),s[15]=x,s[16]=p,s[17]=c,s[18]=f,s[19]=j):j=s[19],j}function ji(s){return s.status==="failed"||s.status==="error"}function vi(s){const e=Y.c(9),{activeTab:r,onChange:n,items:o}=s;let i;if(e[0]!==r||e[1]!==o||e[2]!==n){let l;e[4]!==r||e[5]!==n?(l=d=>{const u=r===d.tab,m=d.icon;return t.jsxs("button",{type:"button",className:Z("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex gap-1.5 items-center whitespace-nowrap",u?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),onClick:()=>n(d.tab),children:[t.jsx(m,{size:14}),t.jsx("span",{children:d.label}),typeof d.count=="number"&&d.count>0&&t.jsx("span",{className:"min-w-4 h-4 px-1 inline-flex items-center justify-center rounded-full bg-primary/15 text-[10px] font-semibold",children:d.count})]},d.id)},e[4]=r,e[5]=n,e[6]=l):l=e[6],i=o.map(l),e[0]=r,e[1]=o,e[2]=n,e[3]=i}else i=e[3];let a;return e[7]!==i?(a=t.jsx("nav",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar",children:i}),e[7]=i,e[8]=a):a=e[8],a}function tl(s){const e=Y.c(47),{onBack:r}=s,[n,o]=I.useState("items"),[i,a]=I.useState(null),{registryName:l,registryIcon:d,acceptPublishRequests:u}=js($e),m=zr(),h=Ir();!u&&n==="requests"&&o("items");const x=m.data?.pending??0,p=h.brokenCount>0?h.brokenCount:void 0;let c;e[0]!==p?(c={id:"items",label:"Items",icon:Vs,tab:"items",count:p},e[0]=p,e[1]=c):c=e[1];let f;e[2]!==u||e[3]!==x?(f=u?[{id:"requests",label:"Requests",icon:qe,tab:"requests",count:x}]:[],e[2]=u,e[3]=x,e[4]=f):f=e[4];let j,C;e[5]===Symbol.for("react.memo_cache_sentinel")?(j={id:"qa",label:"QA",icon:us,tab:"qa"},C={id:"settings",label:"Settings",icon:Gs,tab:"settings"},e[5]=j,e[6]=C):(j=e[5],C=e[6]);let _;e[7]!==c||e[8]!==f?(_=[c,...f,j,C],e[7]=c,e[8]=f,e[9]=_):_=e[9];const y=_;let g;e[10]!==r?(g=r&&t.jsx("button",{type:"button",className:"shrink-0 p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors cursor-pointer",onClick:r,children:t.jsx(Qs,{size:16})}),e[10]=r,e[11]=g):g=e[11];let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=()=>o("settings"),e[12]=P):P=e[12];let R;e[13]!==d||e[14]!==l?(R=t.jsx("div",{className:"size-7 rounded-lg border border-border overflow-hidden bg-muted/20 flex items-center justify-center shrink-0",children:d?t.jsx("img",{src:d,alt:l,className:"h-full w-full object-cover"}):t.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground",children:l.slice(0,1).toUpperCase()})}),e[13]=d,e[14]=l,e[15]=R):R=e[15];let w;e[16]!==l?(w=t.jsx("span",{className:"text-sm font-medium truncate max-w-[220px]",children:l}),e[16]=l,e[17]=w):w=e[17];let k;e[18]!==w||e[19]!==R?(k=t.jsxs("button",{type:"button",className:"min-w-0 flex items-center gap-2 hover:opacity-90 transition-opacity cursor-pointer",onClick:P,children:[R,w]}),e[18]=w,e[19]=R,e[20]=k):k=e[20];let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("div",{className:"h-6 w-px bg-border shrink-0"}),e[21]=T):T=e[21];let N;e[22]!==n||e[23]!==y?(N=t.jsx(vi,{activeTab:n,onChange:o,items:y}),e[22]=n,e[23]=y,e[24]=N):N=e[24];let E;e[25]!==k||e[26]!==N||e[27]!==g?(E=t.jsx("header",{className:"shrink-0 w-full border-b border-border h-12 overflow-x-auto flex items-center justify-between gap-3 px-4 min-w-max",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[g,k,T,N]})}),e[25]=k,e[26]=N,e[27]=g,e[28]=E):E=e[28];let v;e[29]!==n?(v=n==="items"&&t.jsx(_n,{}),e[29]=n,e[30]=v):v=e[30];let D;e[31]!==u||e[32]!==n?(D=n==="requests"&&u&&t.jsx(Sn,{}),e[31]=u,e[32]=n,e[33]=D):D=e[33];let O;e[34]!==n?(O=n==="qa"&&t.jsx(gi,{}),e[34]=n,e[35]=O):O=e[35];let M;e[36]!==n||e[37]!==i?(M=n==="settings"&&t.jsx(Rn,{revealedKey:i,onRevealedKeyChange:a}),e[36]=n,e[37]=i,e[38]=M):M=e[38];let A;e[39]!==v||e[40]!==D||e[41]!==O||e[42]!==M?(A=t.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[v,D,O,M]}),e[39]=v,e[40]=D,e[41]=O,e[42]=M,e[43]=A):A=e[43];let $;return e[44]!==E||e[45]!==A?($=t.jsxs("div",{className:"h-full flex flex-col bg-background overflow-hidden",children:[E,A]}),e[44]=E,e[45]=A,e[46]=$):$=e[46],$}export{tl as default};
27
+ Describe your MCP here...`,rows:6,value:W,onChange:B=>H(B.target.value)}),he.readme&&t.jsx("p",{className:"text-xs text-destructive",children:he.readme})]})]}),t.jsx(an,{tools:we,onChange:lt,remoteUrl:Ge(Me)||void 0,remoteType:le,externalDiscoverStatus:x,externalDiscoverError:p})]});return t.jsx(jt,{open:s,onOpenChange:Yt,children:t.jsxs(gt,{className:"sm:max-w-[820px] max-h-[90vh] overflow-hidden flex flex-col",children:[t.jsxs(xt,{className:"space-y-3",children:[t.jsx(ht,{children:f?"Edit MCP Server":"Add MCP Server"}),t.jsx(pn,{current:z}),t.jsxs(pt,{children:[z===1&&"Set up the identity, connection and discover available tools.",z===2&&"Add descriptions, categories and tags to help discovery.",z===3&&"Configure optional metadata, README and tools."]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto pr-1 py-2",children:[z===1&&Ms,z===2&&Es,z===3&&Ds]}),t.jsxs(ft,{className:"flex items-center justify-between gap-2 sm:justify-between",children:[t.jsx("div",{children:z>1&&t.jsxs(G,{variant:"ghost",size:"sm",onClick:Is,children:[t.jsx(ur,{size:14}),"Back"]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(G,{variant:"outline",size:"sm",onClick:()=>Yt(!1),disabled:a,children:"Cancel"}),z<3?t.jsxs(G,{size:"sm",onClick:Ts,children:["Next",t.jsx(Hs,{size:14})]}):t.jsx(G,{size:"sm",onClick:Ps,disabled:a,children:a?"Saving...":f?"Save changes":"Create"})]})]})]})})}function as(s,e){return s.includes(e)?s.filter(r=>r!==e):[...s,e]}function yn(s){return s._meta?.["mcp.mesh"]?.tags??[]}function Nn(s){return s._meta?.["mcp.mesh"]?.categories??[]}function wn(s){return s.server?.remotes?.[0]?.url??"-"}function _n(){const[e,r]=I.useState(""),n=I.useDeferredValue(e),[o,i]=I.useState([]),[a,l]=I.useState([]),[d,u]=I.useState(!1),[m,h]=I.useState(!1),[x,p]=I.useState(null),[c,f]=I.useState(null),[j,C]=rr("private-registry-list","cards"),_=I.useRef(null),y=gs({search:n,tags:o,categories:a}),g=Er(),{createMutation:P,updateMutation:R,deleteMutation:w,bulkCreateMutation:k}=zt(),T=y.data?.pages.flatMap(b=>b.items??[]).filter(Boolean)??[],N=y.data?.pages[0]?.totalCount??T.length,E=o.length>0||a.length>0||n.length>0,v=g.data,D=Array.isArray(v?.tags)?v.tags:[],O=Array.isArray(v?.categories)?v.categories:[],M=b=>{_.current&&(_.current.disconnect(),_.current=null),!(!b||!y.hasNextPage||y.isFetchingNextPage)&&(_.current=new IntersectionObserver(U=>{U[0]?.isIntersecting&&y.hasNextPage&&!y.isFetchingNextPage&&y.fetchNextPage()},{rootMargin:"240px 0px"}),_.current.observe(b))},A=async b=>{try{"data"in b?(await R.mutateAsync(b),V.success("Registry item updated")):(await P.mutateAsync(b),V.success("Registry item created"))}catch(U){throw V.error(U instanceof Error?U.message:"Failed to save item"),U}},$=async b=>{const U=b._meta?.["mcp.mesh"]?.verified===!0;try{await R.mutateAsync({id:b.id,data:{_meta:{...b._meta,"mcp.mesh":{...b._meta?.["mcp.mesh"],verified:!U}}}}),V.success(U?"Removed verified status":"Marked as verified")}catch(K){V.error(K instanceof Error?K.message:"Failed to update item")}},z=async b=>{const U=b._meta?.["mcp.mesh"]?.official===!0;try{await R.mutateAsync({id:b.id,data:{_meta:{...b._meta,"mcp.mesh":{...b._meta?.["mcp.mesh"],official:!U}}}}),V.success(U?"Removed official status":"Marked as official")}catch(K){V.error(K instanceof Error?K.message:"Failed to update item")}},L=async()=>{if(c)try{await w.mutateAsync(c.id),V.success("Registry item deleted"),f(null)}catch(b){V.error(b instanceof Error?b.message:"Failed to delete item")}};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"shrink-0 border-b border-border",children:[t.jsxs("div",{className:"h-12 px-4 md:px-6 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"text-sm font-medium",children:"Items"}),t.jsx(F,{variant:"secondary",className:"text-xs",children:N})]}),t.jsxs("div",{className:"flex items-center gap-2 self-stretch",children:[t.jsxs(ut,{children:[t.jsx(dt,{asChild:!0,children:t.jsxs(G,{variant:"outline",size:"sm",className:Z("h-8","gap-1.5"),children:[t.jsx(Ws,{size:14}),"Filters"]})}),t.jsxs(mt,{align:"end",className:"w-[260px]",children:[t.jsx(Xt,{children:"Tags"}),D.length>0?D.map(b=>t.jsxs(es,{checked:o.includes(b.value),onCheckedChange:()=>i(U=>as(U,b.value)),children:[b.value," (",b.count,")"]},b.value)):t.jsx(Ce,{disabled:!0,children:"No tags available"}),t.jsx(tr,{}),t.jsx(Xt,{children:"Categories"}),O.length>0?O.map(b=>t.jsxs(es,{checked:a.includes(b.value),onCheckedChange:()=>l(U=>as(U,b.value)),children:[b.value," (",b.count,")"]},b.value)):t.jsx(Ce,{disabled:!0,children:"No categories available"})]})]}),t.jsxs(sr,{type:"single",value:j,onValueChange:b=>{(b==="cards"||b==="table")&&C(b)},variant:"outline",className:"h-8",children:[t.jsx(ts,{value:"cards","aria-label":"Cards view",className:"h-8",children:"Cards"}),t.jsx(ts,{value:"table","aria-label":"Table view",className:"h-8",children:"Table"})]}),t.jsx(G,{variant:"outline",size:"sm",className:"h-8",onClick:()=>h(!0),children:"Import CSV"}),t.jsx(G,{size:"sm",className:"h-8",onClick:()=>u(!0),children:"Add MCP Servers"})]})]}),t.jsx("div",{className:"border-t border-border h-12 px-4 md:px-6 flex items-center",children:t.jsxs("label",{className:"flex items-center gap-2.5 h-12 w-full cursor-text",children:[t.jsx(nr,{size:16,className:"text-muted-foreground shrink-0"}),t.jsx(ae,{value:e,onChange:b=>r(b.target.value),placeholder:"Search by id, title, description, or server name",className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),E&&t.jsxs("div",{className:"border-t border-border px-4 md:px-6 py-2 flex flex-wrap items-center gap-2",children:[o.map(b=>t.jsxs(F,{variant:"default",children:["#",b]},`selected-tag-${b}`)),a.map(b=>t.jsx(F,{variant:"outline",children:b},`selected-category-${b}`)),e.trim()&&t.jsxs(F,{variant:"secondary",className:"max-w-[280px] truncate",children:["Search: ",e]}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-7 ml-auto",onClick:()=>{r(""),i([]),l([])},children:"Clear filters"})]})]}),t.jsxs("div",{className:"flex-1 overflow-auto px-4 md:px-6 py-4",children:[T.length===0?t.jsx("div",{className:"min-h-[320px] rounded-xl border border-dashed border-border flex flex-col items-center justify-center gap-3 p-6 text-center",children:y.isLoading?t.jsxs(t.Fragment,{children:[t.jsx(Le,{className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading items..."})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-base font-medium",children:E?"No items found":"No MCPs in your registry"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:E?"Try removing filters or changing your search to find matching MCPs.":"Add your first MCP item to start building your private registry catalog."}),!E&&t.jsx(G,{size:"lg",onClick:()=>u(!0),children:"Add MCP Servers"})]})}):j==="cards"?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:T.map(b=>t.jsx(rn,{item:b,onEdit:p,onDelete:f,onToggleVerified:$,onToggleOfficial:z},b.id))}),y.hasNextPage&&t.jsx("div",{ref:M,className:"h-2"})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"border rounded-lg overflow-auto",children:t.jsxs(Mt,{children:[t.jsx(Et,{children:t.jsxs(Fe,{children:[t.jsx(ue,{className:"w-[56px]",children:"Icon"}),t.jsx(ue,{children:"Title"}),t.jsx(ue,{children:"ID"}),t.jsx(ue,{children:"Tags"}),t.jsx(ue,{children:"Categories"}),t.jsx(ue,{children:"Remote URL"}),t.jsx(ue,{children:"Visibility"}),t.jsx(ue,{className:"text-right w-[68px]",children:"Actions"})]})}),t.jsx(Dt,{children:T.map(b=>t.jsxs(Fe,{children:[t.jsx(me,{children:t.jsx("div",{className:"size-8 rounded-md border border-border bg-muted/20 overflow-hidden flex items-center justify-center",children:b.server?.icons?.[0]?.src?t.jsx("img",{src:b.server.icons[0].src,alt:b.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground",children:b.title.charAt(0).toUpperCase()})})}),t.jsx(me,{children:b.title}),t.jsx(me,{className:"font-mono",children:b.id}),t.jsx(me,{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:yn(b).slice(0,3).map(U=>t.jsx(F,{variant:"outline",children:U},`${b.id}-tag-${U}`))})}),t.jsx(me,{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:Nn(b).slice(0,3).map(U=>t.jsx(F,{variant:"outline",children:U},`${b.id}-category-${U}`))})}),t.jsx(me,{children:wn(b)}),t.jsx(me,{children:b.is_public?t.jsxs(F,{variant:"default",className:"gap-1",children:[t.jsx(ds,{size:10}),"Public"]}):t.jsx(F,{variant:"secondary",children:"Private"})}),t.jsx(me,{className:"text-right",children:t.jsxs(ut,{children:[t.jsx(dt,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:t.jsx(At,{size:18})})}),t.jsxs(mt,{align:"end",children:[t.jsx(Ce,{onClick:()=>p(b),children:"Edit"}),t.jsx(Ce,{variant:"destructive",onClick:()=>f(b),children:"Delete"})]})]})})]},b.id))})]})}),y.hasNextPage&&t.jsx("div",{ref:M,className:"h-2"})]}),y.isFetchingNextPage&&t.jsxs("div",{className:"py-4 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Le,{className:"size-4 animate-spin"}),"Loading more items..."]})]}),t.jsx(bn,{open:d||!!x,onOpenChange:b=>{b||(u(!1),p(null))},item:x,availableTags:D.map(b=>b.value),availableCategories:O.map(b=>b.value),isSubmitting:P.isPending||R.isPending,onSubmit:A},x?.id??"create"),t.jsx(Kr,{open:m,onOpenChange:h,isImporting:k.isPending,onImport:async b=>{try{const U=await k.mutateAsync(b);return V.success(`Imported ${U.created} item(s)`),U}catch(U){throw V.error(U instanceof Error?U.message:"Failed to import CSV"),U}}}),t.jsx(Zr,{open:!!c,onOpenChange:b=>{b||f(null)},title:c?.title??c?.id??"",isDeleting:w.isPending,onConfirm:L})]})}function Cn(s,e,r=!1){const n=I.useRef(null),o=I.useRef(s),i=I.useRef(e),a=I.useRef(r);return o.current=s,i.current=e,a.current=r,d=>{n.current&&n.current.disconnect(),n.current=new IntersectionObserver(u=>{u[0]?.isIntersecting&&i.current&&!a.current&&o.current()}),d&&n.current.observe(d)}}const kn=[{value:"pending",label:"Pending"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"}];function os(s){const e=new Date(s);return Number.isNaN(e.getTime())?s:e.toLocaleDateString()}function cs(s){return{id:s.requested_id??s.server?.name,title:s.title,description:s.description??"",_meta:s._meta,server:s.server,is_public:!1}}function Pt(s){const e=s.server?.icons?.[0]?.src;return typeof e=="string"&&e.length>0?e:null}function ot(s){const e=s._meta?.["mcp.mesh"];return{hasReadmeContent:!!e?.readme?.trim(),hasReadmeLink:!!e?.readme_url?.trim(),readmeContent:e?.readme?.trim()??"",readmeUrl:e?.readme_url?.trim()??""}}function Sn(){const[s,e]=I.useState("pending"),[r,n]=I.useState("created_at"),[o,i]=I.useState("asc"),[a,l]=I.useState(new Set),[d,u]=I.useState(!1),[m,h]=I.useState("private"),[x,p]=I.useState(!1),[c,f]=I.useState(null),[j,C]=I.useState(null),[_,y]=I.useState(null),[g,P]=I.useState(null),[R,w]=I.useState(""),k=Ar({status:s,sortBy:r,sortDirection:o}),{reviewMutation:T,deleteMutation:N}=Ur(),{createMutation:E}=zt(),v=k.data?.pages.flatMap(S=>S.items)??[],D=k.data?.pages[0]?.totalCount??0,O=k.isFetchingNextPage,M=!!k.hasNextPage,A=Cn(()=>{k.isFetchingNextPage||k.fetchNextPage()},M,O),$=new Set(v.filter(S=>S.status==="pending").map(S=>S.id)),z=v.filter(S=>$.has(S.id)),L=a.size,b=z.filter(S=>a.has(S.id)),U=v.filter(S=>a.has(S.id)).length,K=z.length>0&&z.every(S=>a.has(S.id)),te=()=>l(new Set),ee=(S,W)=>{l(H=>{const xe=new Set(H);return W?xe.add(S):xe.delete(S),xe})},se=S=>{l(W=>{const H=new Set(W);return H.has(S)?H.delete(S):H.add(S),H})},re=()=>{l(S=>{const W=new Set(S);for(const H of z)W.add(H.id);return W})},pe=async()=>{const S=j;if(S){C(null),f(S.id);try{await T.mutateAsync({id:S.id,status:"approved",reviewerNotes:void 0});const W=cs(S);await E.mutateAsync({id:W.id,title:W.title,description:W.description,_meta:W._meta,server:W.server,is_public:W.is_public}),V.success("Request approved and added to registry")}catch(W){const H=W instanceof Error?W.message:"Failed to approve request";H.includes("UNIQUE constraint")||H.includes("already exists")?V.error("An item with this ID already exists in the registry. Delete or rename it first."):V.error(H)}finally{f(null)}}},fe=async()=>{if(_)try{await T.mutateAsync({id:_.id,status:"rejected",reviewerNotes:R.trim()||void 0}),V.success("Request rejected"),y(null),w("")}catch(S){V.error(S instanceof Error?S.message:"Failed to reject request")}},ge=async S=>{try{await N.mutateAsync(S.id),V.success("Request deleted")}catch(W){V.error(W instanceof Error?W.message:"Failed to delete request")}},be=async()=>{if(b.length===0||x)return;p(!0),u(!1);let S=0;const W=new Set;for(const xe of b)try{await T.mutateAsync({id:xe.id,status:"approved",reviewerNotes:void 0});const ye=cs(xe);await E.mutateAsync({id:ye.id,title:ye.title,description:ye.description,_meta:ye._meta,server:ye.server,is_public:m==="public"}),S++}catch{W.add(xe.id)}const H=W.size;S>0&&H===0?V.success(`${S} request${S>1?"s":""} approved as ${m}.`):S>0&&H>0?V.warning(`Approved ${S}. Failed ${H}. Failed items remain selected for retry.`):V.error("Bulk approve failed. Selected items were kept for retry."),l(W),p(!1)};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"shrink-0 border-b border-border",children:t.jsxs("div",{className:"h-12 px-4 md:px-6 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("h2",{className:"text-sm font-medium",children:"Requests to Publish"}),t.jsx(F,{variant:"secondary",className:"text-xs",children:D})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"inline-flex rounded-lg border border-border p-0.5",children:kn.map(S=>t.jsx("button",{type:"button",className:Z("px-2.5 py-1 text-xs rounded-md transition-colors",s===S.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>e(S.value),onClickCapture:()=>te(),children:S.label},S.value))}),t.jsxs("select",{className:"h-7 rounded-md border border-input bg-background px-2 text-xs",value:`${r}:${o}`,onChange:S=>{const[W,H]=S.target.value.split(":");n(W),i(H)},children:[t.jsx("option",{value:"created_at:asc",children:"Created at (oldest first)"}),t.jsx("option",{value:"created_at:desc",children:"Created at (newest first)"}),t.jsx("option",{value:"title:asc",children:"Alphabetical (A-Z)"}),t.jsx("option",{value:"title:desc",children:"Alphabetical (Z-A)"})]})]})]})}),t.jsxs("div",{className:"flex-1 overflow-auto px-4 md:px-6 py-4",children:[k.isLoading?t.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading requests..."}):k.isError?t.jsxs("div",{className:"p-8 text-center rounded-lg border border-border",children:[t.jsx("p",{className:"text-sm text-destructive",children:"Failed to load publish requests."}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:k.error instanceof Error?k.error.message:"Unknown error"})]}):v.length===0?t.jsx("div",{className:"p-8 text-center rounded-lg border border-border",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:s==="pending"?"No pending publish requests.":s==="approved"?"No approved publish requests.":"No rejected publish requests."})}):t.jsxs(Mt,{children:[t.jsx(Et,{children:t.jsxs(Fe,{children:[s==="pending"&&t.jsx(ue,{className:"w-10",children:t.jsx(ss,{checked:K&&z.length>0,onCheckedChange:S=>{S?re():te()}})}),t.jsx(ue,{children:"Name"}),t.jsx(ue,{children:"Requester"}),t.jsx(ue,{children:"Tags"}),t.jsx(ue,{children:"Status"}),t.jsx(ue,{children:"Date"}),t.jsx(ue,{className:"text-right",children:"Actions"})]})}),t.jsx(Dt,{children:v.map(S=>{const W=Pt(S),H=S._meta?.["mcp.mesh"]?.tags??[],xe=$.has(S.id),ye=a.has(S.id);return t.jsxs(Fe,{className:Z(xe&&"cursor-pointer",ye&&"bg-accent/20"),onClick:()=>{xe&&se(S.id)},children:[s==="pending"&&t.jsx(me,{children:t.jsx(ss,{checked:ye,onCheckedChange:de=>ee(S.id,de===!0),onClick:de=>de.stopPropagation()})}),t.jsx(me,{children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("div",{className:"size-7 rounded-md border border-border bg-muted/30 overflow-hidden shrink-0 flex items-center justify-center",children:W?t.jsx("img",{src:W,alt:S.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground",children:S.title.slice(0,1).toUpperCase()})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:S.title}),S.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:S.description})]})]})}),t.jsx(me,{children:t.jsx("span",{className:"text-sm text-muted-foreground truncate",children:S.requester_name||S.requester_email||"-"})}),t.jsx(me,{children:t.jsx("div",{className:"flex flex-wrap gap-1",children:H.slice(0,3).map(de=>t.jsx(F,{variant:"secondary",className:"text-[10px]",children:de},`${S.id}-tag-${de}`))})}),t.jsx(me,{children:t.jsx(F,{variant:"secondary",className:"capitalize text-[11px]",children:S.status})}),t.jsx(me,{children:t.jsx("span",{className:"text-sm text-muted-foreground",children:os(S.created_at)})}),t.jsx(me,{className:"text-right",children:t.jsxs("div",{className:"flex items-center justify-end gap-1",children:[t.jsxs(G,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),P(S)},children:[t.jsx(xs,{size:13}),"View"]}),xe?t.jsxs(t.Fragment,{children:[t.jsxs(G,{size:"sm",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),C(S)},disabled:c!==null||x||ye,children:[t.jsx(qe,{size:13}),c===S.id?"Approving...":ye?"Selected":"Approve"]}),t.jsxs(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),y(S),w("")},disabled:T.isPending,children:[t.jsx(Js,{size:13}),"Reject"]})]}):t.jsxs(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:de=>{de.stopPropagation(),ge(S)},disabled:N.isPending,children:[t.jsx(st,{size:13}),"Delete"]})]})})]},S.id)})})]}),v.length>0&&M?t.jsx("div",{ref:A,className:"h-1 w-full"}):null,O&&v.length>0?t.jsx("div",{className:"pt-3 text-xs text-muted-foreground",children:"Loading more requests..."}):null]}),L>0?t.jsx("div",{className:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2",children:t.jsxs("div",{className:"rounded-xl border border-border bg-background/95 shadow-lg backdrop-blur px-3 py-2 flex items-center gap-2",children:[t.jsxs("div",{className:"text-xs text-muted-foreground pr-1",children:[L," selected"]}),t.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:re,disabled:K,children:"Select all"}),t.jsx(G,{size:"sm",variant:"outline",className:"h-7 text-xs px-2",onClick:te,children:"Clear selection"}),t.jsxs(G,{size:"sm",className:"h-7 text-xs px-2",onClick:()=>u(!0),disabled:x,children:[t.jsx(qe,{size:13}),"Approve selected"]})]})}):null,t.jsx(jt,{open:!!g,onOpenChange:S=>{S||P(null)},children:t.jsxs(gt,{className:"sm:max-w-[720px] max-h-[85vh] overflow-hidden flex flex-col",children:[t.jsxs(xt,{children:[t.jsx(ht,{children:g?.title??"Request details"}),t.jsx(pt,{children:"Review all metadata sent by the requester before approving."})]}),g&&t.jsxs("div",{className:"flex-1 overflow-y-auto pr-1 space-y-4",children:[t.jsxs("div",{className:"rounded-lg border border-border bg-muted/20 p-3 flex items-center gap-3",children:[t.jsx("div",{className:"size-16 rounded-lg border border-border bg-muted/30 overflow-hidden shrink-0 flex items-center justify-center",children:Pt(g)?t.jsx("img",{src:Pt(g)||"",alt:g.title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-lg font-semibold text-muted-foreground",children:g.title.slice(0,1).toUpperCase()})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:g.title}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:g.server?.name||g.id})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Status"}),t.jsx("span",{className:"capitalize",children:g.status})]}),t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Submitted"}),t.jsx("span",{children:os(g.created_at)})]}),t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Requester"}),t.jsx("span",{children:g.requester_name||"-"})]}),t.jsxs("div",{className:"grid gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Email"}),t.jsx("span",{children:g.requester_email||"-"})]})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Remote URL"}),t.jsx("code",{className:"text-xs rounded-md border border-border bg-muted/30 px-2.5 py-2 break-all",children:g.server?.remotes?.[0]?.url??"-"})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Description"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:g.description||"No description provided."})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Tags"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:(g._meta?.["mcp.mesh"]?.tags??[]).length?(g._meta?.["mcp.mesh"]?.tags??[]).map(S=>t.jsx(F,{variant:"secondary",children:S},`${g.id}-detail-tag-${S}`)):t.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"Categories"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:(g._meta?.["mcp.mesh"]?.categories??[]).length?(g._meta?.["mcp.mesh"]?.categories??[]).map(S=>t.jsx(F,{variant:"secondary",children:S},`${g.id}-detail-category-${S}`)):t.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{children:"README"}),ot(g).hasReadmeContent?t.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap max-h-40 overflow-y-auto rounded-md border border-border bg-muted/20 px-2.5 py-2",children:ot(g).readmeContent}):ot(g).hasReadmeLink?t.jsxs("a",{href:ot(g).readmeUrl,target:"_blank",rel:"noreferrer",className:"text-sm inline-flex items-center gap-1.5 text-primary hover:underline",children:["Open README link",t.jsx(fr,{size:14})]}):t.jsx("span",{className:"text-sm text-muted-foreground",children:"No README provided."})]})]}),t.jsx(ft,{children:t.jsx(G,{variant:"outline",onClick:()=>P(null),children:"Close"})})]})}),t.jsx(tt,{open:!!j,onOpenChange:S=>{S||C(null)},children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Approve publish request?"}),t.jsxs(We,{children:["This will add"," ",t.jsx("span",{className:"font-medium text-foreground",children:j?.title})," ","to your private registry. The requester will be notified of the approval."]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{children:"Cancel"}),t.jsx(Ze,{onClick:pe,children:"Approve"})]})]})}),t.jsx(tt,{open:d,onOpenChange:u,children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Approve selected requests?"}),t.jsxs(We,{children:["This will approve ",b.length," request",b.length>1?"s":""," and create all resulting apps with the same visibility setting."]})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"bulk-visibility",children:"Visibility for all selected"}),t.jsxs("select",{id:"bulk-visibility",className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:m,onChange:S=>h(S.target.value),children:[t.jsx("option",{value:"private",children:"Private"}),t.jsx("option",{value:"public",children:"Public"})]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{disabled:x,children:"Cancel"}),t.jsx(Ze,{onClick:be,disabled:x||U===0,children:x?"Approving...":"Approve selected"})]})]})}),t.jsx(jt,{open:!!_,onOpenChange:S=>{S||(y(null),w(""))},children:t.jsxs(gt,{children:[t.jsxs(xt,{children:[t.jsx(ht,{children:"Reject publish request?"}),t.jsx(pt,{children:"This request will move to rejected status. You can leave optional notes for context."})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"reject-notes",children:"Reviewer notes (optional)"}),t.jsx(vt,{id:"reject-notes",rows:4,value:R,onChange:S=>w(S.target.value),placeholder:"Reason for rejection..."})]}),t.jsxs(ft,{children:[t.jsx(G,{variant:"outline",onClick:()=>{y(null),w("")},children:"Cancel"}),t.jsx(G,{onClick:fe,disabled:T.isPending,children:T.isPending?"Rejecting...":"Reject"})]})]})})]})}function Rn({revealedKey:s,onRevealedKeyChange:e}){const{org:r}=ie(),{uploadImage:n,isUploading:o}=ys(),{registryName:i,registryIcon:a,acceptPublishRequests:l,requireApiToken:d,storePrivateOnly:u,rateLimitEnabled:m,rateLimitWindow:h,rateLimitMax:x,isSaving:p,updateConfig:c}=js($e),[f,j]=I.useState(i),[C,_]=I.useState(i);i!==C&&(_(i),j(i));const[y,g]=I.useState(a),[P,R]=I.useState(a);a!==P&&(R(a),g(a));const[w,k]=I.useState(String(x)),[T,N]=I.useState(x);x!==T&&(N(x),k(String(x)));const E=Lr(),{generateMutation:v,revokeMutation:D}=qr(),[O,M]=I.useState(""),[A,$]=I.useState(!1),[z,L]=I.useState(null),{handleCopy:b,copied:U}=It(),{handleCopy:K,copied:te}=It(),{handleCopy:ee,copied:se}=It(),re=gs({search:"",tags:[],categories:[],limit:50}),pe=`${window.location.origin}/org/${r.slug}/registry/mcp`,ge=(re.data?.pages.flatMap(q=>q.items??[])??[]).filter(q=>q.is_public).length,be=`${window.location.origin}/org/${r.slug}/registry/publish-request`,S=s?.slice(0,12)??null,W=!!(S&&(E.data?.items??[]).some(q=>q.prefix===S)),H=p||o,xe=()=>{const q=f.trim();!q||q===i||c({registryName:q})},ye=()=>{const q=Number.parseInt(w,10),le=Number.isFinite(q)&&q>=1?q:100;k(String(le)),le!==x&&c({rateLimitMax:le})},de=async q=>{if(!q)return;const le=q.name.split(".").pop()||"png",it=`registry/${r.id}/identity/icon.${le}`,Ue=await n(q,it);Ue?(g(Ue),c({registryIcon:Ue})):V.error("Failed to upload icon. Please try again.")},nt=async()=>{const q=O.trim();if(q)try{const le=await v.mutateAsync(q);le?.key&&(e(le.key),$(!1),M(""),V.success("API key generated. Copy it now — it won't be shown again!"))}catch(le){V.error(le instanceof Error?le.message:"Failed to generate API key")}},Me=async q=>{try{await D.mutateAsync(q),e(null),L(null),V.success("API key revoked")}catch(le){V.error(le instanceof Error?le.message:"Failed to revoke API key")}};return t.jsxs("div",{className:"h-full overflow-auto px-4 md:px-6 py-4",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-4 items-start xl:grid-cols-2",children:[t.jsx("div",{className:"grid gap-4 min-w-0 content-start",children:t.jsxs(ne,{className:"min-w-0 p-4 grid gap-4 content-start",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Registry Identity"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the name and icon shown in the store selector."})]}),t.jsxs("div",{className:"grid gap-1.5",children:[t.jsx(X,{htmlFor:"identity-name",children:"Name"}),t.jsx(ae,{id:"identity-name",value:f,onChange:q=>j(q.target.value),onBlur:xe,disabled:H,placeholder:"Private Registry"})]}),t.jsx(vs,{value:y,onChange:g,onBlur:()=>{const q=y.trim();q!==a&&c({registryIcon:q})},onFileUpload:de,isUploading:o})]})}),t.jsxs("div",{className:"grid gap-4 min-w-0 content-start",children:[t.jsxs(ne,{className:"min-w-0 p-4 grid gap-3 content-start",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Public Registry"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Public URL to consume this registry as an MCP."})]}),t.jsxs(F,{variant:"secondary",children:[ge," ",ge===1?"public item":"public items"]})]}),t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2 flex items-center gap-2 min-w-0",children:[t.jsx("code",{className:"text-xs font-mono break-all leading-5 min-w-0 flex-1 select-all",children:pe}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:()=>b(pe),children:U?t.jsx(Tt,{size:14}):t.jsx(St,{size:14})})]})]}),t.jsxs(ne,{className:"min-w-0 p-4 grid gap-3 content-start",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Store Visibility"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose what appears when users browse this registry in Store."})]}),t.jsx(Oe,{id:"store-private-only",checked:u,onCheckedChange:q=>c({storePrivateOnly:q}),disabled:H})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enabled: show only private apps. Disabled: show public and private apps together."})]}),t.jsxs(ne,{className:"min-w-0 p-4 grid gap-3 content-start",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold",children:"Publish Requests"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Allow external users to submit MCP servers for review."})]}),t.jsx(Oe,{id:"accept-publish-requests",checked:l,onCheckedChange:q=>c({acceptPublishRequests:q}),disabled:H})]}),t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2 flex items-center gap-2 min-w-0",children:[t.jsx("code",{className:"text-xs font-mono break-all leading-5 min-w-0 flex-1 select-all",children:be}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:()=>K(be),children:te?t.jsx(Tt,{size:14}):t.jsx(St,{size:14})})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border",children:[t.jsxs("div",{children:[t.jsx(X,{className:"text-sm font-medium",children:"Require API Token"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Requests without a valid token will be rejected."})]}),t.jsx(Oe,{id:"require-api-token",checked:d,onCheckedChange:q=>c({requireApiToken:q}),disabled:H})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border",children:[t.jsxs("div",{children:[t.jsx(X,{className:"text-sm font-medium",children:"Rate Limit"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit publish requests per organization by time window."})]}),t.jsx(Oe,{id:"publish-rate-limit",checked:m,onCheckedChange:q=>c({rateLimitEnabled:q}),disabled:H})]}),m&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(X,{htmlFor:"rate-limit-max",className:"text-sm font-medium",children:"Max requests"}),t.jsx(ae,{id:"rate-limit-max",inputMode:"numeric",min:1,type:"number",value:w,onChange:q=>k(q.target.value),onBlur:ye,disabled:H,placeholder:"100"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(X,{htmlFor:"rate-limit-window",className:"text-sm font-medium",children:"Window"}),t.jsxs("select",{id:"rate-limit-window",className:"h-9 rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",value:h,onChange:q=>c({rateLimitWindow:q.target.value}),disabled:H,children:[t.jsx("option",{value:"minute",children:"Per minute"}),t.jsx("option",{value:"hour",children:"Per hour"})]})]})]}),l&&d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-border",children:[t.jsx(ir,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium",children:"API Keys"})]}),s&&!W&&t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 grid gap-1.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"New key (refreshing list...)"}),t.jsx(ae,{readOnly:!0,value:s,className:"h-8 text-xs font-mono bg-background"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxs("div",{className:"grid gap-1.5 flex-1",children:[t.jsx(X,{htmlFor:"api-key-name",className:"text-xs",children:"Key name"}),t.jsx(ae,{id:"api-key-name",value:O,onChange:q=>M(q.target.value),placeholder:"e.g. CI/CD Pipeline",className:"h-8 text-sm"})]}),t.jsxs(G,{variant:"outline",size:"sm",className:"h-8 gap-1.5",disabled:!O.trim()||v.isPending,onClick:nt,children:[v.isPending?t.jsx(Le,{size:14,className:"animate-spin"}):t.jsx(gr,{size:14}),"Generate"]})]}),(E.data?.items?.length??0)>0&&t.jsx("div",{className:"grid gap-2",children:E.data?.items?.map(q=>t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2",children:[t.jsxs("div",{className:"grid gap-1 min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium truncate leading-none",children:q.name}),S===q.prefix?t.jsx(ae,{readOnly:!0,value:A?s??"":"••••••••••••••••••••••••••••••••••••••••••••••••••••",className:"h-8 text-xs font-mono bg-muted/20"}):t.jsx(ae,{readOnly:!0,value:`${q.prefix}••••••••`,className:"h-8 text-xs font-mono bg-muted/20 text-muted-foreground"})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[S===q.prefix&&t.jsxs(t.Fragment,{children:[t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>$(le=>!le),children:A?t.jsx(mr,{size:14}):t.jsx(xs,{size:14})}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:!s,onClick:()=>s&&ee(s),children:se?t.jsx(Tt,{size:14}):t.jsx(St,{size:14})})]}),t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",disabled:D.isPending,onClick:()=>L({id:q.id,name:q.name}),children:t.jsx(st,{size:14})})]})]},q.id))})]})]})]})]}),t.jsx(tt,{open:!!z,onOpenChange:q=>{!q&&!D.isPending&&L(null)},children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Revoke API key?"}),t.jsxs(We,{children:["This action cannot be undone. The key",z?` "${z.name}"`:""," will stop working immediately."]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{disabled:D.isPending,children:"Cancel"}),t.jsx(Ze,{disabled:!z||D.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>z&&Me(z.id),children:D.isPending?"Revoking...":"Revoke key"})]})]})})]})}function Tn(s){const e=Y.c(5),{results:r}=s;if(r.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ne,{className:"p-4 text-sm text-muted-foreground text-center",children:"No broken MCPs in this run. All healthy! ✓"}),e[0]=i):i=e[0],i}let n;e[1]!==r?(n=r.map(In),e[1]=r,e[2]=n):n=e[2];let o;return e[3]!==n?(o=t.jsx("div",{className:"space-y-2",children:n}),e[3]=n,e[4]=o):o=e[4],o}function In(s){return t.jsx(Pn,{result:s},s.id)}function Pn(s){const e=Y.c(49),{result:r}=s,[n,o]=I.useState(!1);let i;if(e[0]!==n||e[1]!==r.action_taken||e[2]!==r.connection_ok||e[3]!==r.duration_ms||e[4]!==r.error_message||e[5]!==r.id||e[6]!==r.item_title||e[7]!==r.status||e[8]!==r.tool_results||e[9]!==r.tools_listed){const a=r.tool_results.filter(Dn);let l;e[11]!==n?(l=()=>o(!n),e[11]=n,e[12]=l):l=e[12];let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"text-red-500 text-sm mt-0.5",children:"✗"}),e[13]=d):d=e[13];let u;e[14]!==r.item_title?(u=t.jsx("h4",{className:"text-sm font-medium truncate",children:r.item_title}),e[14]=r.item_title,e[15]=u):u=e[15];let m;e[16]!==r.status?(m=r.status.replace("_"," "),e[16]=r.status,e[17]=m):m=e[17];let h;e[18]!==m?(h=t.jsx(F,{variant:"destructive",className:"capitalize text-[10px] shrink-0",children:m}),e[18]=m,e[19]=h):h=e[19];let x;e[20]!==u||e[21]!==h?(x=t.jsxs("div",{className:"flex items-center gap-2",children:[u,h]}),e[20]=u,e[21]=h,e[22]=x):x=e[22];const p=r.connection_ok?"✓":"✗";let c;e[23]!==p?(c=t.jsxs("span",{children:["conn: ",p]}),e[23]=p,e[24]=c):c=e[24];const f=r.tools_listed?"✓":"✗";let j;e[25]!==f?(j=t.jsxs("span",{children:["tools listed: ",f]}),e[25]=f,e[26]=j):j=e[26];let C;e[27]!==r.duration_ms?(C=t.jsxs("span",{children:[r.duration_ms,"ms"]}),e[27]=r.duration_ms,e[28]=C):C=e[28];const _=a.length>0&&t.jsxs("span",{className:"text-red-600",children:[a.length," tool",a.length>1?"s":""," ","failed"]});let y;e[29]!==r.action_taken?(y=r.action_taken!=="none"&&t.jsx(F,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:r.action_taken.replace(/_/g," ")}),e[29]=r.action_taken,e[30]=y):y=e[30];let g;e[31]!==j||e[32]!==C||e[33]!==_||e[34]!==y||e[35]!==c?(g=t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground flex-wrap",children:[c,j,C,_,y]}),e[31]=j,e[32]=C,e[33]=_,e[34]=y,e[35]=c,e[36]=g):g=e[36];let P;e[37]!==r.error_message?(P=r.error_message&&t.jsx("p",{className:"text-xs text-red-600 line-clamp-2",children:r.error_message}),e[37]=r.error_message,e[38]=P):P=e[38];let R;e[39]!==g||e[40]!==P||e[41]!==x?(R=t.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[x,g,P]}),e[39]=g,e[40]=P,e[41]=x,e[42]=R):R=e[42];const w=n?"▲":"▼";let k;e[43]!==w?(k=t.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 mt-1",children:w}),e[43]=w,e[44]=k):k=e[44];let T;e[45]!==R||e[46]!==k||e[47]!==l?(T=t.jsxs("button",{type:"button",className:"w-full text-left p-3 flex items-start gap-3 hover:bg-muted/30 transition-colors",onClick:l,children:[d,R,k]}),e[45]=R,e[46]=k,e[47]=l,e[48]=T):T=e[48],i=t.jsxs(ne,{className:"overflow-hidden",children:[T,n&&t.jsxs("div",{className:"border-t border-border p-3 space-y-2 bg-muted/10",children:[r.error_message&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Full Error"}),t.jsx("pre",{className:"text-[11px] bg-red-500/5 border border-red-500/10 rounded px-2.5 py-1.5 whitespace-pre-wrap break-all text-red-700",children:r.error_message})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Connection"}),t.jsx("p",{className:Z("text-xs font-medium",r.connection_ok?"text-emerald-600":"text-red-600"),children:r.connection_ok?"OK":"Failed"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tools Listed"}),t.jsx("p",{className:Z("text-xs font-medium",r.tools_listed?"text-emerald-600":"text-red-600"),children:r.tools_listed?"Yes":"No"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Duration"}),t.jsxs("p",{className:"text-xs font-medium",children:[r.duration_ms,"ms"]})]})]}),a.length>0&&t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-red-600",children:["Failed Tools (",a.length,")"]}),a.map(N=>t.jsxs("div",{className:"rounded border border-red-500/10 bg-red-500/5 px-2.5 py-1.5 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono font-medium text-red-700",children:N.toolName}),t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[N.durationMs,"ms"]})]}),N.error&&t.jsx("pre",{className:"text-[11px] whitespace-pre-wrap break-all text-red-600",children:N.error})]},`${r.id}-${N.toolName}`))]}),r.tool_results.length>0&&r.tool_results.some(En)&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Passing Tools"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:r.tool_results.filter(Mn).map(N=>t.jsxs(F,{variant:"secondary",className:"text-[10px]",children:["✓ ",N.toolName]},`${r.id}-${N.toolName}-pass`))})]})]})]}),e[0]=n,e[1]=r.action_taken,e[2]=r.connection_ok,e[3]=r.duration_ms,e[4]=r.error_message,e[5]=r.id,e[6]=r.item_title,e[7]=r.status,e[8]=r.tool_results,e[9]=r.tools_listed,e[10]=i}else i=e[10];return i}function Mn(s){return s.success}function En(s){return s.success}function Dn(s){return!s.success}const An=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}];function $n(s){const r=s.trim().split(/\s+/);if(r.length!==5)return{frequency:"custom",minute:0,hour:9,weekDay:1,dayOfMonth:1};const[n,o,i,a,l]=r,d=Number(n),u=Number(o),m=Number(i),h=Number(l);return Number.isInteger(d)&&Number.isInteger(u)&&d>=0&&d<=59&&u>=0&&u<=23?i==="*"&&l==="*"?{frequency:"daily",minute:d,hour:u,weekDay:1,dayOfMonth:1}:i==="*/14"&&l==="*"?{frequency:"biweekly",minute:d,hour:u,weekDay:1,dayOfMonth:1}:i==="*"&&Number.isInteger(h)&&h>=0&&h<=6?{frequency:"weekly",minute:d,hour:u,weekDay:h,dayOfMonth:1}:l==="*"&&Number.isInteger(m)&&m>=1&&m<=31?{frequency:"monthly",minute:d,hour:u,weekDay:1,dayOfMonth:m}:{frequency:"custom",minute:d,hour:u,weekDay:1,dayOfMonth:1}:{frequency:"custom",minute:0,hour:9,weekDay:1,dayOfMonth:1}}function On(s,e){return`${String(s).padStart(2,"0")}:${String(e).padStart(2,"0")}`}function ct(s){return s.frequency==="daily"?`${s.minute} ${s.hour} * * *`:s.frequency==="weekly"?`${s.minute} ${s.hour} * * ${s.weekDay}`:s.frequency==="biweekly"?`${s.minute} ${s.hour} */14 * *`:s.frequency==="monthly"?`${s.minute} ${s.hour} ${s.dayOfMonth} * *`:s.currentValue}function zn(s){const e=Y.c(60),{value:r,onChange:n,disabled:o}=s,i=o===void 0?!1:o;let a;e[0]!==r?(a=$n(r),e[0]=r,e[1]=a):a=e[1];const l=a,d=l.frequency==="custom";let u;e[2]!==n||e[3]!==l.dayOfMonth||e[4]!==l.hour||e[5]!==l.minute||e[6]!==l.weekDay||e[7]!==r?(u=A=>{if(A==="custom"){n(r);return}n(ct({frequency:A,hour:l.hour,minute:l.minute,weekDay:l.weekDay,dayOfMonth:l.dayOfMonth,currentValue:r}))},e[2]=n,e[3]=l.dayOfMonth,e[4]=l.hour,e[5]=l.minute,e[6]=l.weekDay,e[7]=r,e[8]=u):u=e[8];const m=u;let h;e[9]!==n||e[10]!==l.dayOfMonth||e[11]!==l.frequency||e[12]!==l.weekDay||e[13]!==r?(h=A=>{const[$,z]=A.split(":"),L=Number($),b=Number(z);!Number.isInteger(L)||!Number.isInteger(b)||n(ct({frequency:l.frequency,hour:L,minute:b,weekDay:l.weekDay,dayOfMonth:l.dayOfMonth,currentValue:r}))},e[9]=n,e[10]=l.dayOfMonth,e[11]=l.frequency,e[12]=l.weekDay,e[13]=r,e[14]=h):h=e[14];const x=h;let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(X,{children:"Frequency"}),e[15]=p):p=e[15];let c;e[16]!==m?(c=A=>m(A.target.value),e[16]=m,e[17]=c):c=e[17];let f,j,C,_,y;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx("option",{value:"daily",children:"Daily"}),_=t.jsx("option",{value:"weekly",children:"Weekly"}),y=t.jsx("option",{value:"biweekly",children:"Every 2 weeks"}),f=t.jsx("option",{value:"monthly",children:"Monthly"}),j=t.jsx("option",{value:"custom",children:"Custom (raw cron)"}),e[18]=f,e[19]=j,e[20]=C,e[21]=_,e[22]=y):(f=e[18],j=e[19],C=e[20],_=e[21],y=e[22]);let g;e[23]!==i||e[24]!==l.frequency||e[25]!==c?(g=t.jsxs("label",{className:"space-y-1",children:[p,t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:l.frequency,onChange:c,disabled:i,children:[C,_,y,f,j]})]}),e[23]=i,e[24]=l.frequency,e[25]=c,e[26]=g):g=e[26];let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(X,{children:"Time"}),e[27]=P):P=e[27];let R;e[28]!==l.hour||e[29]!==l.minute?(R=On(l.hour,l.minute),e[28]=l.hour,e[29]=l.minute,e[30]=R):R=e[30];let w;e[31]!==x?(w=A=>x(A.target.value),e[31]=x,e[32]=w):w=e[32];const k=i||d;let T;e[33]!==R||e[34]!==w||e[35]!==k?(T=t.jsxs("label",{className:"space-y-1",children:[P,t.jsx(ae,{type:"time",value:R,onChange:w,disabled:k})]}),e[33]=R,e[34]=w,e[35]=k,e[36]=T):T=e[36];let N;e[37]!==i||e[38]!==n||e[39]!==l.dayOfMonth||e[40]!==l.frequency||e[41]!==l.hour||e[42]!==l.minute||e[43]!==l.weekDay||e[44]!==r?(N=l.frequency==="weekly"?t.jsxs("label",{className:"space-y-1",children:[t.jsx(X,{children:"Day of week"}),t.jsx("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:l.weekDay,onChange:A=>n(ct({frequency:"weekly",hour:l.hour,minute:l.minute,weekDay:Number(A.target.value),dayOfMonth:l.dayOfMonth,currentValue:r})),disabled:i,children:An.map(Un)})]}):l.frequency==="monthly"?t.jsxs("label",{className:"space-y-1",children:[t.jsx(X,{children:"Day of month"}),t.jsx(ae,{type:"number",min:1,max:31,value:l.dayOfMonth,onChange:A=>{const $=Number(A.target.value);!Number.isInteger($)||$<1||$>31||n(ct({frequency:"monthly",hour:l.hour,minute:l.minute,weekDay:l.weekDay,dayOfMonth:$,currentValue:r}))},disabled:i})]}):t.jsxs("div",{className:"space-y-1",children:[t.jsx(X,{children:"Schedule notes"}),t.jsx("div",{className:"h-9 rounded-md border border-input bg-muted/20 px-3 text-xs text-muted-foreground flex items-center",children:l.frequency==="biweekly"?"Biweekly uses an every-14-days cron approximation.":l.frequency==="custom"?"Edit raw cron directly below.":"Runs in your server timezone."})]}),e[37]=i,e[38]=n,e[39]=l.dayOfMonth,e[40]=l.frequency,e[41]=l.hour,e[42]=l.minute,e[43]=l.weekDay,e[44]=r,e[45]=N):N=e[45];let E;e[46]!==g||e[47]!==T||e[48]!==N?(E=t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[g,T,N]}),e[46]=g,e[47]=T,e[48]=N,e[49]=E):E=e[49];let v;e[50]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(X,{children:"Raw cron expression"}),e[50]=v):v=e[50];let D;e[51]!==n?(D=A=>n(A.target.value),e[51]=n,e[52]=D):D=e[52];let O;e[53]!==i||e[54]!==D||e[55]!==r?(O=t.jsxs("label",{className:"space-y-1 block",children:[v,t.jsx(ae,{value:r,onChange:D,disabled:i,placeholder:"*/15 * * * *"})]}),e[53]=i,e[54]=D,e[55]=r,e[56]=O):O=e[56];let M;return e[57]!==E||e[58]!==O?(M=t.jsxs("div",{className:"space-y-2",children:[E,O]}),e[57]=E,e[58]=O,e[59]=M):M=e[59],M}function Un(s){return t.jsx("option",{value:s.value,children:s.label},s.value)}function Ln(s,e){return s.onFailure!==e.onFailure||s.perMcpTimeoutMs!==e.perMcpTimeoutMs||s.perToolTimeoutMs!==e.perToolTimeoutMs||s.maxAgentSteps!==e.maxAgentSteps||s.testPublicOnly!==e.testPublicOnly||s.testPrivateOnly!==e.testPrivateOnly||s.includePendingRequests!==e.includePendingRequests||(s.agentContext??"")!==(e.agentContext??"")||s.schedule!==e.schedule||s.cronExpression!==e.cronExpression}function qn(){const{settings:s,saveMutation:e}=ps(),r=Rr(),n=Tr(),o=I.useRef(s),[i,a]=I.useState(s),[l,d]=I.useState(!1),[u,m]=I.useState(!1);o.current!==s&&(o.current=s,a(s));const h=Ln(i,s),x=c=>{d(!1),a(f=>({...f,...c}))},p=async()=>{const c=i.cronExpression?.trim()??"";let f=s.scheduleEventId??"";if(i.schedule==="cron"&&c.length>0){const C=c!==(s.cronExpression??"");C&&f&&await n.mutateAsync(f),(C||!f)&&(f=(await r.mutateAsync({cronExpression:c,config:i})).scheduleEventId)}else f&&(await n.mutateAsync(f),f="");const j={...i,cronExpression:c,scheduleEventId:f,agentContext:(i.agentContext??"").trim()};await e.mutateAsync(j),a(j),d(!0),setTimeout(()=>d(!1),3e3)};return t.jsxs(ne,{className:"p-4 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"QA Configuration"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure how the MCP QA agent validates registry entries."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[h&&t.jsx(F,{className:"bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:"Unsaved changes"}),l&&t.jsx(F,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:"✓ Saved"}),t.jsx(G,{size:"sm",onClick:p,disabled:e.isPending||r.isPending||n.isPending||!h,children:e.isPending||r.isPending||n.isPending?"Saving...":"Save settings"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"On failure",hint:"Automatic action to apply when an MCP fails tests in a run."}),t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:i.onFailure,onChange:c=>x({onFailure:c.target.value}),children:[t.jsx("option",{value:"none",children:"Do nothing"}),t.jsx("option",{value:"unlisted",children:"Unlist from store (keep in registry)"}),t.jsx("option",{value:"remove_public",children:"Remove from public store"}),t.jsx("option",{value:"remove_private",children:"Remove from private registry"}),t.jsx("option",{value:"remove_all",children:"Remove from all (public + private)"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Test scope",hint:"Choose whether tests should run for public items, private items, or both."}),t.jsxs("div",{className:"flex items-center gap-4 rounded-md border border-input px-3 py-2",children:[t.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:i.testPublicOnly,onChange:c=>x({testPublicOnly:c.target.checked,testPrivateOnly:c.target.checked?!1:i.testPrivateOnly})}),"Public only"]}),t.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:i.testPrivateOnly,onChange:c=>x({testPrivateOnly:c.target.checked,testPublicOnly:c.target.checked?!1:i.testPublicOnly})}),"Private only"]})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Publish requests",hint:"Include pending publish requests in QA runs to validate them before publishing to the store."}),t.jsx("div",{className:"flex items-center gap-4 rounded-md border border-input px-3 py-2",children:t.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:i.includePendingRequests,onChange:c=>x({includePendingRequests:c.target.checked})}),"Include pending requests in tests"]})})]}),t.jsxs("div",{className:"space-y-1 md:col-span-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(Ee,{label:"Additional test context (prompt)",hint:"Extra runtime context passed to the agent, such as valid emails, tenant IDs, or known test entities."}),t.jsxs(G,{size:"sm",variant:"outline",className:"h-7",onClick:()=>m(c=>!c),children:[u?"Hide":"View"," default system prompt"]})]}),t.jsx(vt,{value:i.agentContext??"",onChange:c=>x({agentContext:c.target.value}),placeholder:'Example: Use "my-user@company.com" as a valid email for Google Drive share/create_permission tests.',rows:3}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Use this field for real data required by some tools (valid email, fixed IDs, test environment details, etc)."}),u&&t.jsx("pre",{className:"text-[11px] bg-muted/50 border border-border rounded px-3 py-2 whitespace-pre-wrap max-h-64 overflow-auto",children:Nr})]}),t.jsxs("div",{className:"space-y-1 md:col-span-2",children:[t.jsx(Ee,{label:"Schedule",hint:"Set automatic test runs. Manual mode runs only when you click Start QA run."}),t.jsxs("select",{className:"h-9 rounded-md border border-input bg-background px-3 text-sm",value:i.schedule??"manual",onChange:c=>x({schedule:c.target.value}),children:[t.jsx("option",{value:"manual",children:"Manual only"}),t.jsx("option",{value:"cron",children:"Cron schedule"})]}),(i.schedule??"manual")==="cron"&&t.jsx(zn,{value:i.cronExpression??"",onChange:c=>x({cronExpression:c})})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Per MCP timeout (ms)",hint:"Max total time allowed to validate one MCP."}),t.jsx(ae,{type:"number",value:i.perMcpTimeoutMs,onChange:c=>x({perMcpTimeoutMs:Number(c.target.value)})})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Per tool timeout (ms)",hint:"Max time allowed for each individual tool call."}),t.jsx(ae,{type:"number",value:i.perToolTimeoutMs,onChange:c=>x({perToolTimeoutMs:Number(c.target.value)})})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ee,{label:"Max agent steps",hint:"Maximum number of reasoning/tool steps in Agentic mode."}),t.jsx(ae,{type:"number",value:i.maxAgentSteps,onChange:c=>x({maxAgentSteps:Number(c.target.value)}),min:1,max:30})]})]})]})}function Ee(s){const e=Y.c(13),{label:r,hint:n}=s;let o;e[0]!==r?(o=t.jsx(X,{children:r}),e[0]=r,e[1]=o):o=e[1];const i=`About ${r}`;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Zs,{size:14}),e[2]=a):a=e[2];let l;e[3]!==i?(l=t.jsx(jr,{asChild:!0,children:t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground transition-colors","aria-label":i,children:a})}),e[3]=i,e[4]=l):l=e[4];let d;e[5]!==n?(d=t.jsx(vr,{side:"top",className:"max-w-72",children:n}),e[5]=n,e[6]=d):d=e[6];let u;e[7]!==l||e[8]!==d?(u=t.jsxs(br,{children:[l,d]}),e[7]=l,e[8]=d,e[9]=u):u=e[9];let m;return e[10]!==o||e[11]!==u?(m=t.jsxs("div",{className:"flex items-center gap-1.5",children:[o,u]}),e[10]=o,e[11]=u,e[12]=m):m=e[12],m}function Fn(s){switch(s){case"authenticated":return"bg-emerald-500/10 text-emerald-600 border-emerald-500/20";case"needs_auth":return"bg-amber-500/10 text-amber-600 border-amber-500/20";default:return"bg-zinc-500/10 text-zinc-500 border-zinc-500/20"}}function Bn(s){switch(s){case"authenticated":return"Authenticated";case"needs_auth":return"Needs Auth";default:return"Not checked"}}function Qn({entry:s,onAuthChanged:e,failedToolsCount:r,failedResultCount:n}){const[o,i]=I.useState(!1),[a,l]=I.useState(""),[d,u]=I.useState(!1),m=Sr(),{updateMutation:h}=zt(),x=s.mapping.connection_id,p=s.mapping.auth_status,c=s.item?.title??s.mapping.item_id,f=s.item?.server?.icons?.[0]?.src??null,j=s.item?.is_public??!1,C=s.item?.is_unlisted??!1,_=s.source==="request",y=Ie({queryKey:Q.monitorConnectionAuthProbe(x),queryFn:async()=>Fs({url:`/mcp/${x}`,token:null}),staleTime:1e4,retry:1,refetchOnWindowFocus:!1}),g=y.data,P=y.isLoading,R=g?.supportsOAuth??!1,w=g?.hasOAuthToken??!1,k=g?.isServerError??!1,T=g?.isAuthenticated??!1,N=P?"checking":k?"server_error":R?T?w?"oauth_connected":"connected":"oauth_available":T?"connected":"token_required",E=()=>{m.mutate({connectionId:x,authStatus:"authenticated"},{onSuccess:()=>e()})},v=async()=>{i(!0);try{const z=(await y.refetch()).data;if(!z){V.error(`Could not reach "${c}". The remote MCP may be down.`);return}if(z.isAuthenticated){V.success(`"${c}" is reachable. You can re-authenticate if needed.`);return}if(z.isServerError){V.error(`Server error for "${c}". The remote MCP may be down.`);return}if(!z.supportsOAuth){V.warning(`"${c}" does not support OAuth. Use the Token field to paste an API key.`);return}V.info(`Opening authentication window for "${c}"...`);const L=await Bs({connectionId:x,clientName:`MCP Test - ${c}`,timeout:18e4,scope:"offline_access"});if(L.error){V.error(`OAuth failed for "${c}": ${L.error}`);return}L.tokenInfo?(await fetch(`/api/connections/${x}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.tokenInfo.accessToken,refreshToken:L.tokenInfo.refreshToken,expiresIn:L.tokenInfo.expiresIn,scope:L.tokenInfo.scope,clientId:L.tokenInfo.clientId,clientSecret:L.tokenInfo.clientSecret,tokenEndpoint:L.tokenInfo.tokenEndpoint})})).ok||L.token&&await D(L.token):L.token&&await D(L.token),V.success(`"${c}" authenticated!`),E(),await y.refetch()}catch($){console.error("[MonitorConnectionsPanel] Auth error:",$),V.error(`Error: ${$ instanceof Error?$.message:String($)}`)}finally{i(!1)}},D=async $=>{if(!(await fetch("/mcp/self",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:"COLLECTION_CONNECTIONS_UPDATE",arguments:{id:x,data:{connection_token:$}}}})})).ok)throw new Error("Failed to save token")},O=async()=>{if(!a.trim()){V.error("Token cannot be empty.");return}i(!0);try{await D(a),V.success(`Token saved for "${c}"!`),u(!1),l(""),E(),await y.refetch()}catch($){V.error(`Error saving token: ${$ instanceof Error?$.message:String($)}`)}finally{i(!1)}},M=p==="authenticated"&&!w&&!d&&a.length===0,A=async $=>{if(_){V.info("Visibility controls are available only for store items.");return}if(!s.item){V.error("Registry item not found for this connection.");return}try{await h.mutateAsync({id:s.item.id,data:$}),V.success("Visibility updated"),e()}catch(z){V.error(z instanceof Error?z.message:"Failed to update visibility")}};return t.jsxs(ne,{className:"p-3 space-y-3 h-full",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:"size-10 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0 flex items-center justify-center",children:f?t.jsx("img",{src:f,alt:c,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:c.charAt(0).toUpperCase()})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:c}),t.jsx("p",{className:"text-xs text-muted-foreground break-all",children:s.remoteUrl??"-"}),t.jsxs("div",{className:"mt-1 flex items-center gap-1.5 flex-wrap",children:[t.jsx(F,{variant:"outline",className:Z("text-[10px]",Fn(p)),children:Bn(p)}),t.jsx(F,{variant:j?"default":"secondary",className:"text-[10px]",children:j?"Public":"Not public"}),t.jsx(F,{variant:"outline",className:"text-[10px]",children:_?"Request":"Store"}),t.jsxs(F,{variant:"outline",className:Z("text-[10px]",N==="server_error"?"border-destructive/40 text-destructive":N==="oauth_connected"?"border-emerald-500/30 text-emerald-600":N==="oauth_available"?"border-sky-500/30 text-sky-600":N==="token_required"?"border-amber-500/30 text-amber-600":"text-muted-foreground"),children:[N==="checking"&&"Checking auth...",N==="server_error"&&"Server error",N==="oauth_connected"&&"OAuth connected",N==="oauth_available"&&"OAuth available",N==="token_required"&&"Token/manual auth",N==="connected"&&"Connected"]}),C&&t.jsx(F,{variant:"outline",className:"text-[10px]",children:"Hidden in private"}),(n>0||r>0)&&t.jsxs(F,{variant:"destructive",className:"text-[10px]",children:[n," failed MCP / ",r," failed tools"]})]})]})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.jsxs(ut,{children:[t.jsx(dt,{asChild:!0,children:t.jsx(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:t.jsx(At,{size:16})})}),t.jsx(mt,{align:"end",children:_?t.jsx(Ce,{disabled:!0,children:"Request item (no store visibility controls)"}):t.jsxs(t.Fragment,{children:[t.jsx(Ce,{onClick:()=>A({is_public:!1}),children:"Hide from public store"}),t.jsx(Ce,{onClick:()=>A({is_unlisted:!0}),children:"Hide from private store"}),t.jsx(Ce,{onClick:()=>A({is_public:!0,is_unlisted:!1}),children:"Show in both stores"})]})})]})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 flex-wrap",children:[R&&t.jsx(G,{size:"sm",onClick:v,disabled:o,children:o?"...":w?"Re-auth OAuth":"OAuth"}),t.jsx(G,{size:"sm",variant:"outline",onClick:()=>y.refetch(),disabled:o||P,children:P?"Checking...":"Re-check"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Token/API key (for MCPs that require manual auth)"}),M?t.jsxs("div",{className:"relative group",children:[t.jsx("div",{className:"h-8 px-3 flex items-center rounded-md border border-border bg-muted/50 text-muted-foreground font-mono text-xs",children:"••••••••••••••••"}),t.jsx("button",{type:"button",onClick:()=>u(!0),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted",title:"Replace token",children:"Edit"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ae,{type:"password",placeholder:"Paste API token / key...",value:a,onChange:$=>l($.target.value),className:"h-8 text-xs flex-1",onKeyDown:$=>{$.key==="Enter"&&O()}}),t.jsx(G,{size:"sm",className:"h-8 text-xs",onClick:O,disabled:o||!a.trim(),children:"Save"}),t.jsx(G,{size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:()=>{u(!1),l("")},children:"✕"})]})]})]})}function Vn(){const s=Y.c(55),e=hs(),n=yt("completed").data?.items?.[0],o=rt(n?.id,void 0,n?.status),i=kr(),[a,l]=I.useState("all");let d,u,m,h,x,p;if(s[0]!==e||s[1]!==o.data?.items||s[2]!==a||s[3]!==i){const j=e.data?.items??[];let C;s[10]!==o.data?.items?(C=(o.data?.items??[]).reduce(Yn,{}),s[10]=o.data?.items,s[11]=C):C=s[11];const _=C;let y;s[12]!==a?(y=se=>a==="all"?!0:se.source===a,s[12]=a,s[13]=y):y=s[13];const g=j.filter(y);d=ne,x="p-4 space-y-3";let P,R,w,k;s[14]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("h3",{className:"text-sm font-semibold",children:"QA Connections"}),w=t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"We auto-detect auth type. Use OAuth when available, or always paste a Token/API key for manual auth MCPs."}),k=t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Listing tools alone does not imply authenticated status."}),P=t.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Cards show MCP icon, auth status, and latest failed test counters."}),s[14]=P,s[15]=R,s[16]=w,s[17]=k):(P=s[14],R=s[15],w=s[16],k=s[17]);const T=a==="all"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground";let N;s[18]!==T?(N=Z("px-2.5 py-1 text-xs rounded-md transition-colors",T),s[18]=T,s[19]=N):N=s[19];let E;s[20]===Symbol.for("react.memo_cache_sentinel")?(E=()=>l("all"),s[20]=E):E=s[20];let v;s[21]!==N?(v=t.jsx("button",{type:"button",className:N,onClick:E,children:"All"}),s[21]=N,s[22]=v):v=s[22];const D=a==="store"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground";let O;s[23]!==D?(O=Z("px-2.5 py-1 text-xs rounded-md transition-colors",D),s[23]=D,s[24]=O):O=s[24];let M;s[25]===Symbol.for("react.memo_cache_sentinel")?(M=()=>l("store"),s[25]=M):M=s[25];let A;s[26]!==O?(A=t.jsx("button",{type:"button",className:O,onClick:M,children:"Store"}),s[26]=O,s[27]=A):A=s[27];const $=a==="request"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground";let z;s[28]!==$?(z=Z("px-2.5 py-1 text-xs rounded-md transition-colors",$),s[28]=$,s[29]=z):z=s[29];let L;s[30]===Symbol.for("react.memo_cache_sentinel")?(L=()=>l("request"),s[30]=L):L=s[30];let b;s[31]!==z?(b=t.jsx("button",{type:"button",className:z,onClick:L,children:"Requests"}),s[31]=z,s[32]=b):b=s[32];let U;s[33]!==v||s[34]!==A||s[35]!==b?(U=t.jsxs("div",{children:[R,w,k,P,t.jsxs("div",{className:"mt-2 inline-flex rounded-lg border border-border p-0.5",children:[v,A,b]})]}),s[33]=v,s[34]=A,s[35]=b,s[36]=U):U=s[36];let K;s[37]!==i?(K=()=>{i.mutate(void 0,{onSuccess:Kn,onError:Gn})},s[37]=i,s[38]=K):K=s[38];const te=i.isPending?"Syncing...":"Sync";let ee;s[39]!==i.isPending||s[40]!==K||s[41]!==te?(ee=t.jsx(G,{size:"sm",variant:"outline",onClick:K,disabled:i.isPending,children:te}),s[39]=i.isPending,s[40]=K,s[41]=te,s[42]=ee):ee=s[42],s[43]!==U||s[44]!==ee?(p=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[U,ee]}),s[43]=U,s[44]=ee,s[45]=p):p=s[45],u="space-y-2",m=g.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:'No QA connections for this filter. Click "Sync" to create mappings from store items and pending requests.'}),h=g.length>0&&t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:g.map(se=>{const re=_[se.mapping.item_id]??{failedTools:0,failedResults:0};return t.jsx(Qn,{entry:se,onAuthChanged:()=>e.refetch(),failedToolsCount:re.failedTools,failedResultCount:re.failedResults},se.mapping.id)})}),s[0]=e,s[1]=o.data?.items,s[2]=a,s[3]=i,s[4]=d,s[5]=u,s[6]=m,s[7]=h,s[8]=x,s[9]=p}else d=s[4],u=s[5],m=s[6],h=s[7],x=s[8],p=s[9];let c;s[46]!==u||s[47]!==m||s[48]!==h?(c=t.jsxs("div",{className:u,children:[m,h]}),s[46]=u,s[47]=m,s[48]=h,s[49]=c):c=s[49];let f;return s[50]!==d||s[51]!==x||s[52]!==p||s[53]!==c?(f=t.jsxs(d,{className:x,children:[p,c]}),s[50]=d,s[51]=x,s[52]=p,s[53]=c,s[54]=f):f=s[54],f}function Gn(s){return V.error(`Sync failed: ${s.message}`)}function Kn(){return V.success("Connections synced (store + pending requests)")}function Yn(s,e){const r=s[e.item_id]??{failedTools:0,failedResults:0},n=e.tool_results.filter(Hn).length;return r.failedTools=r.failedTools+n,(e.status==="failed"||e.status==="error")&&(r.failedResults=r.failedResults+1),s[e.item_id]=r,s}function Hn(s){return!s.success}function Ns(s){switch(s){case"running":return"bg-blue-500/10 text-blue-600 border-blue-500/20";case"completed":return"bg-emerald-500/10 text-emerald-600 border-emerald-500/20";case"failed":return"bg-red-500/10 text-red-600 border-red-500/20";case"cancelled":return"bg-zinc-500/10 text-zinc-500 border-zinc-500/20";case"pending":return"bg-amber-500/10 text-amber-600 border-amber-500/20";default:return""}}function ws(s,e){if(!s)return null;const r=e?new Date(e).getTime():Date.now(),n=new Date(s).getTime(),o=r-n;return o<1e3?`${o}ms`:o<6e4?`${(o/1e3).toFixed(1)}s`:`${Math.floor(o/6e4)}m ${Math.round(o%6e4/1e3)}s`}function _s(s){const e=new Map;for(const r of s)e.has(r.toolName)&&e.delete(r.toolName),e.set(r.toolName,r);return Array.from(e.values())}function Wn(s){return s.total_items?Math.min(100,Math.round(s.tested_items/s.total_items*100)):0}function Jn(s){if(!s)return null;const e=s.match(/Not executed tools \((\d+)\/(\d+)\):/i);if(!e)return null;const r=Number(e[2]);return Number.isFinite(r)&&r>=0?r:null}function Zn(s){const e=Y.c(57),{result:r,index:n,icon:o}=s,[i,a]=I.useState(!1);let l;if(e[0]!==i||e[1]!==o||e[2]!==n||e[3]!==r.action_taken||e[4]!==r.agent_summary||e[5]!==r.connection_ok||e[6]!==r.duration_ms||e[7]!==r.error_message||e[8]!==r.id||e[9]!==r.item_title||e[10]!==r.status||e[11]!==r.tool_results||e[12]!==r.tools_listed){const d=_s(r.tool_results),u=d.every(si),m=d.filter(ti),h=m.filter(ei).length,x=m.filter(Xn).length,p=m.length>0,c=m.length;let f;e[14]!==r.agent_summary?(f=Jn(r.agent_summary),e[14]=r.agent_summary,e[15]=f):f=e[15];const j=f,C=Math.max(d.length,j??0),_=C>0?`${c}/${C} tools tested`:"0 tools";let y;e[16]!==i?(y=()=>a(!i),e[16]=i,e[17]=y):y=e[17];const g=n+1;let P;e[18]!==g?(P=t.jsx("span",{className:"text-muted-foreground w-5 text-right shrink-0",children:g}),e[18]=g,e[19]=P):P=e[19];let R;e[20]!==o||e[21]!==r.item_title?(R=t.jsx("div",{className:"size-5 rounded border border-border bg-muted/20 overflow-hidden shrink-0 flex items-center justify-center",children:o?t.jsx("img",{src:o,alt:r.item_title,className:"h-full w-full object-cover",loading:"lazy"}):t.jsx("span",{className:"text-[9px] font-semibold text-muted-foreground",children:r.item_title.charAt(0).toUpperCase()})}),e[20]=o,e[21]=r.item_title,e[22]=R):R=e[22];const w=r.status==="passed"?"text-emerald-600":r.status==="needs_auth"?"text-amber-600":"text-red-600";let k;e[23]!==w?(k=Z("shrink-0",w),e[23]=w,e[24]=k):k=e[24];const T=r.status==="passed"?"✓":r.status==="needs_auth"?"🔑":"✗";let N;e[25]!==k||e[26]!==T?(N=t.jsx("span",{className:k,children:T}),e[25]=k,e[26]=T,e[27]=N):N=e[27];let E;e[28]!==r.item_title?(E=t.jsx("span",{className:"font-medium truncate flex-1 min-w-0",children:r.item_title}),e[28]=r.item_title,e[29]=E):E=e[29];let v;e[30]!==r.duration_ms?(v=t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[r.duration_ms,"ms"]}),e[30]=r.duration_ms,e[31]=v):v=e[31];const D=r.status==="passed"?"text-emerald-600 border-emerald-500/20":r.status==="needs_auth"?"text-amber-600 border-amber-500/20":"text-red-600 border-red-500/20";let O;e[32]!==D?(O=Z("text-[9px] capitalize shrink-0",D),e[32]=D,e[33]=O):O=e[33];let M;e[34]!==r.status?(M=r.status.replace("_"," "),e[34]=r.status,e[35]=M):M=e[35];let A;e[36]!==O||e[37]!==M?(A=t.jsx(F,{variant:"outline",className:O,children:M}),e[36]=O,e[37]=M,e[38]=A):A=e[38];let $;e[39]!==r.connection_ok?($=r.connection_ok?t.jsx("span",{className:"text-[10px] text-emerald-600 shrink-0",children:"conn✓"}):t.jsx("span",{className:"text-[10px] text-red-600 shrink-0",children:"conn✗"}),e[39]=r.connection_ok,e[40]=$):$=e[40];const z=r.tools_listed&&t.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:p?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-emerald-600",children:[h,"✓"]})," ",t.jsxs("span",{className:Z(x>0?"text-red-600":""),children:[x,"✗"]})]}):u&&d.length>0?t.jsxs("span",{children:[d.length," tools found"]}):"no tools"});let L;e[41]!==_?(L=t.jsx(F,{variant:"outline",className:"text-[9px] shrink-0",children:_}),e[41]=_,e[42]=L):L=e[42];const b=i?"▲":"▼";let U;e[43]!==b?(U=t.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:b}),e[43]=b,e[44]=U):U=e[44];let K;e[45]!==N||e[46]!==E||e[47]!==v||e[48]!==A||e[49]!==$||e[50]!==z||e[51]!==L||e[52]!==U||e[53]!==y||e[54]!==P||e[55]!==R?(K=t.jsxs("button",{type:"button",className:"w-full text-left flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors",onClick:y,children:[P,R,N,E,v,A,$,z,L,U]}),e[45]=N,e[46]=E,e[47]=v,e[48]=A,e[49]=$,e[50]=z,e[51]=L,e[52]=U,e[53]=y,e[54]=P,e[55]=R,e[56]=K):K=e[56],l=t.jsxs("div",{className:"rounded border border-border overflow-hidden",children:[K,i&&t.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-2 bg-muted/10",children:[r.error_message&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Error"}),t.jsx("pre",{className:"text-[11px] bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 whitespace-pre-wrap break-all text-red-700 max-h-20 overflow-auto",children:r.error_message})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[10px] flex-wrap",children:[t.jsxs("span",{children:["Connection:"," ",t.jsx("span",{className:Z(r.connection_ok?"text-emerald-600":"text-red-600"),children:r.connection_ok?"OK":"Failed"})]}),t.jsxs("span",{children:["Tools listed:"," ",t.jsx("span",{className:Z(r.tools_listed?"text-emerald-600":"text-red-600"),children:r.tools_listed?"Yes":"No"})]}),r.action_taken!=="none"&&t.jsxs(F,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:["action: ",r.action_taken]})]}),p?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tools tested: ",h," passed, ",x," failed"]}),t.jsx("div",{className:"space-y-0.5",children:m.map((te,ee)=>t.jsx(ri,{tool:te},`${r.id}-${te.toolName}-${ee}`))})]}):u&&d.length>0?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tools discovered (",d.length,") - not individually tested (health-check mode)"]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:d.map((te,ee)=>t.jsx(F,{variant:"outline",className:"text-[10px] font-mono",children:te.toolName},`${r.id}-${te.toolName}-${ee}`))})]}):r.tools_listed?t.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No tools found on this server."}):null,r.agent_summary&&t.jsx("p",{className:"text-[11px] bg-muted/50 rounded px-2 py-1.5",children:r.agent_summary})]})]}),e[0]=i,e[1]=o,e[2]=n,e[3]=r.action_taken,e[4]=r.agent_summary,e[5]=r.connection_ok,e[6]=r.duration_ms,e[7]=r.error_message,e[8]=r.id,e[9]=r.item_title,e[10]=r.status,e[11]=r.tool_results,e[12]=r.tools_listed,e[13]=l}else l=e[13];return l}function Xn(s){return!s.success}function ei(s){return s.success}function ti(s){return s.outputPreview!=="health_check: not called"}function si(s){return s.outputPreview==="health_check: not called"}function ri(s){const e=Y.c(30),{tool:r}=s,[n,o]=I.useState(!1);let i;e[0]!==n?(i=()=>o(!n),e[0]=n,e[1]=i):i=e[1];const a=r.success?"text-emerald-600":"text-red-600";let l;e[2]!==a?(l=Z("font-bold",a),e[2]=a,e[3]=l):l=e[3];const d=r.success?"✓":"✗";let u;e[4]!==l||e[5]!==d?(u=t.jsx("span",{className:l,children:d}),e[4]=l,e[5]=d,e[6]=u):u=e[6];let m;e[7]!==r.toolName?(m=t.jsx("span",{className:"font-mono truncate flex-1",children:r.toolName}),e[7]=r.toolName,e[8]=m):m=e[8];let h;e[9]!==r.durationMs?(h=t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[r.durationMs,"ms"]}),e[9]=r.durationMs,e[10]=h):h=e[10];let x;e[11]!==r.error?(x=r.error&&t.jsx("span",{className:"text-red-500 truncate max-w-28",title:r.error,children:r.error}),e[11]=r.error,e[12]=x):x=e[12];const p=n?"▲":"▼";let c;e[13]!==p?(c=t.jsx("span",{className:"text-muted-foreground",children:p}),e[13]=p,e[14]=c):c=e[14];let f;e[15]!==i||e[16]!==c||e[17]!==u||e[18]!==m||e[19]!==h||e[20]!==x?(f=t.jsxs("button",{type:"button",className:"w-full text-left flex items-center gap-2 px-2 py-1 text-[11px] hover:bg-muted/30 transition-colors",onClick:i,children:[u,m,h,x,c]}),e[15]=i,e[16]=c,e[17]=u,e[18]=m,e[19]=h,e[20]=x,e[21]=f):f=e[21];let j;e[22]!==n||e[23]!==r.error||e[24]!==r.input||e[25]!==r.outputPreview?(j=n&&t.jsxs("div",{className:"border-t border-border px-2 py-1.5 space-y-1 bg-muted/10 text-[11px]",children:[r.error&&t.jsx("pre",{className:"bg-red-500/5 border border-red-500/10 rounded px-2 py-1 whitespace-pre-wrap break-all text-red-700 max-h-20 overflow-auto",children:r.error}),r.input&&Object.keys(r.input).length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Input"}),t.jsx("pre",{className:"bg-muted/50 rounded px-2 py-1 whitespace-pre-wrap break-all max-h-16 overflow-auto",children:JSON.stringify(r.input,null,2)})]}),r.outputPreview&&t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Output"}),t.jsx("pre",{className:"bg-muted/50 rounded px-2 py-1 whitespace-pre-wrap break-all max-h-16 overflow-auto",children:r.outputPreview})]})]}),e[22]=n,e[23]=r.error,e[24]=r.input,e[25]=r.outputPreview,e[26]=j):j=e[26];let C;return e[27]!==f||e[28]!==j?(C=t.jsxs("div",{className:"rounded border border-border overflow-hidden",children:[f,j]}),e[27]=f,e[28]=j,e[29]=C):C=e[29],C}function ni({activeRunId:s,onRunChange:e}){const{settings:r}=ps(),[n,o]=I.useState(null),[i,a]=I.useState(!1),l=I.useRef(0),d=I.useRef(null),u=wr(),m=_r(),h=Ot(s),x=yt(),p=hs(),c=h.data?.run??null,f=c?.status,j=c?.config_snapshot?.monitorMode??c?.config_snapshot?.testMode,C=rt(s,void 0,f),_=(x.data?.items??[]).find(v=>v.status==="running"),y=x.data?.items?.[0]?.id;!s&&y&&d.current!==y&&(d.current=y,queueMicrotask(()=>{e(y)}));const g=async()=>{const v=Date.now();if(v-l.current<1e3)return;l.current=v;const D=n??r.monitorMode,O=await u.mutateAsync({...r,monitorMode:D});e(O.run.id)},P=async()=>{if(_&&_.id!==s&&_.status==="running"){a(!0);return}await g()},R=async()=>{s&&await m.mutateAsync(s)},w=c?.status==="running",k=c?ws(c.started_at,c.finished_at):null,T=C.data?.items??[],N=(p.data?.items??[]).reduce((v,D)=>(v[D.mapping.item_id]=D.item?.server?.icons?.[0]?.src??null,v),{}),E=n??r.monitorMode;return t.jsxs("div",{className:"space-y-4 min-w-0",children:[t.jsxs("div",{className:"space-y-4 min-w-0",children:[t.jsxs(ne,{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Current QA Run"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a full QA validation run and track results in real time."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[_&&_.id!==s&&t.jsxs(F,{variant:"outline",className:"text-[10px]",children:["Run in progress: ",_.id.slice(0,8)]}),t.jsxs(G,{size:"sm",onClick:P,disabled:u.isPending||w,className:"gap-1.5",children:[t.jsx(yr,{size:14}),u.isPending?"Starting...":_&&_.id!==s?"Start another run":"Start QA run"]}),t.jsxs(G,{size:"sm",variant:"outline",onClick:R,disabled:!s||!w,className:"gap-1.5",children:[t.jsx(Xs,{size:14}),"Cancel"]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsxs("label",{className:"space-y-1",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"QA mode"}),t.jsxs("select",{className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm",value:E,onChange:v=>o(v.target.value),disabled:w,children:[t.jsx("option",{value:"health_check",children:"Health check"}),t.jsx("option",{value:"tool_call",children:"Tool call"}),t.jsx("option",{value:"full_agent",children:"Agentic (LLM model)"})]})]}),t.jsxs("label",{className:"space-y-1",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"QA run history (pick a previous run)"}),t.jsxs("select",{className:"h-9 w-full rounded-md border border-input bg-background px-3 text-sm",value:s??"",onChange:v=>e(v.target.value||void 0),children:[t.jsx("option",{value:"",children:"Auto-select latest run"}),(x.data?.items??[]).map(v=>t.jsxs("option",{value:v.id,children:[new Date(v.created_at).toLocaleString()," -"," ",v.status]},v.id))]})]})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground rounded-md bg-muted/30 px-2.5 py-2",children:E==="health_check"?"Checks connectivity and tool listing only — no tool calls are made.":E==="tool_call"?"Calls each tool with empty inputs to verify it responds without errors.":"Uses an LLM model to execute chained tool calls and validate outputs."}),c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsx(F,{className:Z("capitalize",Ns(c.status),c.status==="running"?"animate-pulse":""),children:c.status}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[c.tested_items,"/",c.total_items," tested"]}),k&&t.jsx("span",{className:"text-xs text-muted-foreground",children:k}),w&&c.current_item_id&&t.jsxs("span",{className:"text-xs text-muted-foreground truncate max-w-64",children:["QA on:"," ",t.jsx("span",{className:"font-mono",children:c.current_item_id})]})]}),t.jsx("div",{className:"h-2.5 rounded-full bg-muted overflow-hidden",children:t.jsx("div",{className:Z("h-full transition-all duration-500",c.failed_items>0?"bg-orange-500":"bg-emerald-500",w?"animate-pulse":""),style:{width:`${Wn(c)}%`}})}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-emerald-600",children:"Passed"}),t.jsx("p",{className:"text-lg font-bold text-emerald-600",children:c.passed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-red-600",children:"Failed"}),t.jsx("p",{className:"text-lg font-bold text-red-600",children:c.failed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Skipped"}),t.jsx("p",{className:"text-lg font-bold",children:c.skipped_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Total"}),t.jsx("p",{className:"text-lg font-bold",children:c.total_items})]})]})]}):t.jsx("p",{className:"text-xs text-muted-foreground",children:"No run selected yet. Start a new run to begin."})]}),t.jsxs(ne,{className:"p-4 space-y-2 min-h-[360px]",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{children:[t.jsxs("h3",{className:"text-sm font-semibold",children:["QA results log (",T.length,")"]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Live per-MCP test output for the selected run."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[w&&t.jsx(F,{className:"bg-blue-500/10 text-blue-600 border-blue-500/20 animate-pulse",children:"run in progress"}),c&&t.jsxs(F,{variant:"outline",className:"text-[10px]",children:["progress: ",c.tested_items," of ",c.total_items," MCPs"]}),j&&t.jsxs(F,{variant:"outline",className:"text-[10px]",children:["mode: ",j.replace("_"," ")]})]})]}),T.length===0?t.jsx("div",{className:"h-[280px] rounded border border-dashed border-border flex items-center justify-center text-xs text-muted-foreground",children:"No results yet. Start a run to see live logs here."}):t.jsx("div",{ref:v=>{v&&w&&v.scrollHeight-v.scrollTop-v.clientHeight<120&&requestAnimationFrame(()=>{v.scrollTop=v.scrollHeight})},className:"space-y-1 max-h-[60vh] overflow-auto pr-1",children:T.map((v,D)=>t.jsx(Zn,{result:v,index:D,icon:N[v.item_id]},v.id))})]})]}),t.jsx(tt,{open:i,onOpenChange:a,children:t.jsxs(et,{children:[t.jsxs(He,{children:[t.jsx(Ye,{children:"Start another test run?"}),t.jsxs(We,{children:["There is already a run in progress",_?` (${_.id})`:"",". Starting another run may increase database load and slow down both executions."]})]}),t.jsxs(Xe,{children:[t.jsx(Je,{children:"Cancel"}),t.jsx(Ze,{onClick:()=>{a(!1),g()},children:"Start anyway"})]})]})})]})}function Cs(s){switch(s){case"passed":return"bg-emerald-500/10 text-emerald-600 border-emerald-500/20";case"failed":return"bg-red-500/10 text-red-600 border-red-500/20";case"error":return"bg-orange-500/10 text-orange-600 border-orange-500/20";case"needs_auth":return"bg-amber-500/10 text-amber-600 border-amber-500/20";case"skipped":return"bg-zinc-500/10 text-zinc-500 border-zinc-500/20";default:return""}}function ii(s){switch(s){case"passed":return"✓";case"failed":return"✗";case"error":return"⚠";case"needs_auth":return"🔑";case"skipped":return"⏭";default:return"?"}}function li(s){const e=Y.c(27),{tool:r}=s,[n,o]=I.useState(!1);let i;e[0]!==n?(i=()=>o(!n),e[0]=n,e[1]=i):i=e[1];const a=r.success?"text-emerald-600":"text-red-600";let l;e[2]!==a?(l=Z("text-xs font-bold",a),e[2]=a,e[3]=l):l=e[3];const d=r.success?"✓":"✗";let u;e[4]!==l||e[5]!==d?(u=t.jsx("span",{className:l,children:d}),e[4]=l,e[5]=d,e[6]=u):u=e[6];let m;e[7]!==r.toolName?(m=t.jsx("span",{className:"text-xs font-mono truncate flex-1",children:r.toolName}),e[7]=r.toolName,e[8]=m):m=e[8];let h;e[9]!==r.durationMs?(h=t.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[r.durationMs,"ms"]}),e[9]=r.durationMs,e[10]=h):h=e[10];const x=n?"▲":"▼";let p;e[11]!==x?(p=t.jsx("span",{className:"text-[10px] text-muted-foreground",children:x}),e[11]=x,e[12]=p):p=e[12];let c;e[13]!==i||e[14]!==u||e[15]!==m||e[16]!==h||e[17]!==p?(c=t.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 flex items-center gap-2 hover:bg-muted/30 transition-colors",onClick:i,children:[u,m,h,p]}),e[13]=i,e[14]=u,e[15]=m,e[16]=h,e[17]=p,e[18]=c):c=e[18];let f;e[19]!==n||e[20]!==r.error||e[21]!==r.input||e[22]!==r.outputPreview?(f=n&&t.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5 bg-muted/20",children:[r.error&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Error"}),t.jsx("pre",{className:"text-[11px] bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 whitespace-pre-wrap break-all text-red-700",children:r.error})]}),r.input&&Object.keys(r.input).length>0&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Input"}),t.jsx("pre",{className:"text-[11px] bg-muted/50 rounded px-2 py-1.5 whitespace-pre-wrap break-all max-h-24 overflow-auto",children:JSON.stringify(r.input,null,2)})]}),r.outputPreview&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Output preview"}),t.jsx("pre",{className:"text-[11px] bg-muted/50 rounded px-2 py-1.5 whitespace-pre-wrap break-all max-h-24 overflow-auto",children:r.outputPreview})]}),!r.error&&!r.outputPreview&&(!r.input||Object.keys(r.input).length===0)&&t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"No additional details."})]}),e[19]=n,e[20]=r.error,e[21]=r.input,e[22]=r.outputPreview,e[23]=f):f=e[23];let j;return e[24]!==c||e[25]!==f?(j=t.jsxs("div",{className:"rounded border border-border",children:[c,f]}),e[24]=c,e[25]=f,e[26]=j):j=e[26],j}function ai(s){const e=Y.c(52),{result:r}=s,[n,o]=I.useState(r.status!=="passed");let i;if(e[0]!==n||e[1]!==r.action_taken||e[2]!==r.agent_summary||e[3]!==r.connection_ok||e[4]!==r.duration_ms||e[5]!==r.error_message||e[6]!==r.id||e[7]!==r.item_title||e[8]!==r.status||e[9]!==r.tool_results||e[10]!==r.tools_listed){const a=_s(r.tool_results),l=a.every(ui),d=a.filter(di),u=d.filter(ci).length,m=d.filter(oi).length,h=d.length>0;let x;e[12]!==n?(x=()=>o(!n),e[12]=n,e[13]=x):x=e[13];let p;e[14]!==r.status?(p=ii(r.status),e[14]=r.status,e[15]=p):p=e[15];let c;e[16]!==p?(c=t.jsx("span",{className:"text-base shrink-0",children:p}),e[16]=p,e[17]=c):c=e[17];let f;e[18]!==r.item_title?(f=t.jsx("p",{className:"text-sm font-medium truncate",children:r.item_title}),e[18]=r.item_title,e[19]=f):f=e[19];let j;e[20]!==r.duration_ms?(j=t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[r.duration_ms,"ms"]}),e[20]=r.duration_ms,e[21]=j):j=e[21];const C=r.connection_ok?"✓":"✗";let _;e[22]!==C?(_=t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["conn: ",C]}),e[22]=C,e[23]=_):_=e[23];const y=r.tools_listed?"✓":"✗";let g;e[24]!==y?(g=t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["tools listed: ",y]}),e[24]=y,e[25]=g):g=e[25];const P=a.length>0&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:h?t.jsxs(t.Fragment,{children:["tools: ",u,"✓ ",m,"✗"]}):t.jsxs(t.Fragment,{children:[a.length," tools found"]})});let R;e[26]!==r.action_taken?(R=r.action_taken!=="none"&&t.jsxs(F,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:["action: ",r.action_taken]}),e[26]=r.action_taken,e[27]=R):R=e[27];let w;e[28]!==g||e[29]!==P||e[30]!==R||e[31]!==j||e[32]!==_?(w=t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[j,_,g,P,R]}),e[28]=g,e[29]=P,e[30]=R,e[31]=j,e[32]=_,e[33]=w):w=e[33];let k;e[34]!==w||e[35]!==f?(k=t.jsxs("div",{className:"min-w-0 flex-1",children:[f,w]}),e[34]=w,e[35]=f,e[36]=k):k=e[36];let T;e[37]!==r.status?(T=Z("capitalize shrink-0",Cs(r.status)),e[37]=r.status,e[38]=T):T=e[38];let N;e[39]!==r.status?(N=r.status.replace("_"," "),e[39]=r.status,e[40]=N):N=e[40];let E;e[41]!==T||e[42]!==N?(E=t.jsx(F,{className:T,children:N}),e[41]=T,e[42]=N,e[43]=E):E=e[43];const v=n?"▲":"▼";let D;e[44]!==v?(D=t.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:v}),e[44]=v,e[45]=D):D=e[45];let O;e[46]!==k||e[47]!==E||e[48]!==D||e[49]!==x||e[50]!==c?(O=t.jsxs("button",{type:"button",className:"w-full text-left px-4 py-3 flex items-center gap-3 hover:bg-muted/30 transition-colors",onClick:x,children:[c,k,E,D]}),e[46]=k,e[47]=E,e[48]=D,e[49]=x,e[50]=c,e[51]=O):O=e[51],i=t.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[O,n&&t.jsxs("div",{className:"border-t border-border px-4 py-3 space-y-2 bg-muted/10",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Connection"}),t.jsx("p",{className:Z("text-xs font-medium",r.connection_ok?"text-emerald-600":"text-red-600"),children:r.connection_ok?"Connected":"Failed"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tools Listed"}),t.jsx("p",{className:Z("text-xs font-medium",r.tools_listed?"text-emerald-600":"text-red-600"),children:r.tools_listed?`Yes (${a.length})`:"No"})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Duration"}),t.jsxs("p",{className:"text-xs font-medium",children:[r.duration_ms,"ms"]})]}),t.jsxs("div",{className:"rounded border border-border px-2 py-1.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Action Taken"}),t.jsx("p",{className:"text-xs font-medium capitalize",children:r.action_taken.replace(/_/g," ")})]})]}),r.error_message&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-[10px] font-semibold text-red-600",children:"Error Message"}),t.jsx("pre",{className:"text-xs bg-red-500/5 border border-red-500/10 rounded px-3 py-2 whitespace-pre-wrap break-all text-red-700",children:r.error_message})]}),h?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tool Results (",u," passed, ",m," failed)"]}),t.jsx("div",{className:"space-y-1",children:d.map((M,A)=>t.jsx(li,{tool:M},`${r.id}-${M.toolName}-${A}`))})]}):l&&a.length>0?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-muted-foreground",children:["Tools discovered (",a.length,") — not individually tested (health-check mode)"]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:a.map((M,A)=>t.jsx(F,{variant:"outline",className:"text-[10px] font-mono",children:M.toolName},`${r.id}-${M.toolName}-${A}`))})]}):null,r.agent_summary&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground",children:"Agent Summary"}),t.jsx("p",{className:"text-xs bg-muted/50 rounded px-3 py-2",children:r.agent_summary})]})]})]}),e[0]=n,e[1]=r.action_taken,e[2]=r.agent_summary,e[3]=r.connection_ok,e[4]=r.duration_ms,e[5]=r.error_message,e[6]=r.id,e[7]=r.item_title,e[8]=r.status,e[9]=r.tool_results,e[10]=r.tools_listed,e[11]=i}else i=e[11];return i}function oi(s){return!s.success}function ci(s){return s.success}function di(s){return s.outputPreview!=="health_check: not called"}function ui(s){return s.outputPreview==="health_check: not called"}function mi(s){const e=Y.c(4),{value:r,onChange:n}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[{value:"all",label:"All"},{value:"passed",label:"Passed"},{value:"failed",label:"Failed"},{value:"error",label:"Error"},{value:"needs_auth",label:"Needs Auth"},{value:"skipped",label:"Skipped"}],e[0]=o):o=e[0];const i=o;let a;return e[1]!==n||e[2]!==r?(a=t.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:i.map(l=>t.jsx("button",{type:"button",className:Z("text-[11px] px-2 py-0.5 rounded-full border transition-colors",r===l.value?"bg-primary text-primary-foreground border-primary":"bg-muted/30 border-border hover:bg-muted/50"),onClick:()=>n(l.value),children:l.label},l.value))}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function xi(s){const e=Y.c(46),{runId:r}=s,[n,o]=I.useState("all"),i=Ot(r),a=i.data?.run,l=rt(r,void 0,a?.status);let d;e[0]!==l.data?.items?(d=l.data?.items??[],e[0]=l.data?.items,e[1]=d):d=e[1];const u=d;let m;e[2]!==u||e[3]!==n?(m=n==="all"?u:u.filter(v=>v.status===n),e[2]=u,e[3]=n,e[4]=m):m=e[4];const h=m;if(!r){let v;return e[5]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(ne,{className:"p-6 text-center space-y-2",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a run to inspect details."})}),e[5]=v):v=e[5],v}let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("h3",{className:"text-sm font-semibold",children:"Run Detail"}),e[6]=x):x=e[6];let p;e[7]!==r?(p=t.jsxs("div",{children:[x,t.jsx("p",{className:"text-[10px] text-muted-foreground font-mono",children:r})]}),e[7]=r,e[8]=p):p=e[8];let c;e[9]!==a?(c=a&&t.jsx(F,{className:Z("capitalize",Cs(a.status)),children:a.status}),e[9]=a,e[10]=c):c=e[10];let f;e[11]!==l||e[12]!==i?(f=t.jsx(G,{size:"sm",variant:"outline",onClick:()=>{i.refetch(),l.refetch()},children:"Refresh"}),e[11]=l,e[12]=i,e[13]=f):f=e[13];let j;e[14]!==c||e[15]!==f?(j=t.jsxs("div",{className:"flex items-center gap-2",children:[c,f]}),e[14]=c,e[15]=f,e[16]=j):j=e[16];let C;e[17]!==p||e[18]!==j?(C=t.jsx(ne,{className:"p-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p,j]})}),e[17]=p,e[18]=j,e[19]=C):C=e[19];let _;e[20]!==a?(_=a&&t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2 text-xs",children:[t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Total"}),t.jsx("p",{className:"text-lg font-bold",children:a.total_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Tested"}),t.jsx("p",{className:"text-lg font-bold",children:a.tested_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-emerald-600",children:"Passed"}),t.jsx("p",{className:"text-lg font-bold text-emerald-600",children:a.passed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-red-600",children:"Failed"}),t.jsx("p",{className:"text-lg font-bold text-red-600",children:a.failed_items})]}),t.jsxs(ne,{className:"p-2.5 space-y-0.5",children:[t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Skipped"}),t.jsx("p",{className:"text-lg font-bold",children:a.skipped_items})]})]}),e[20]=a,e[21]=_):_=e[21];let y;e[22]!==a?(y=a&&(a.started_at||a.finished_at)&&t.jsxs(ne,{className:"p-3 flex items-center gap-4 text-xs text-muted-foreground flex-wrap",children:[a.started_at&&t.jsxs("span",{children:["Started: ",new Date(a.started_at).toLocaleString()]}),a.finished_at&&t.jsxs("span",{children:["Finished: ",new Date(a.finished_at).toLocaleString()]}),a.started_at&&a.finished_at&&t.jsxs("span",{className:"font-medium text-foreground",children:["Duration:"," ",((new Date(a.finished_at).getTime()-new Date(a.started_at).getTime())/1e3).toFixed(1),"s"]})]}),e[22]=a,e[23]=y):y=e[23];let g;e[24]!==n?(g=t.jsx(mi,{value:n,onChange:o}),e[24]=n,e[25]=g):g=e[25];const P=h.length!==1?"s":"";let R;e[26]!==h.length||e[27]!==P?(R=t.jsxs("span",{className:"text-xs text-muted-foreground",children:[h.length," result",P]}),e[26]=h.length,e[27]=P,e[28]=R):R=e[28];let w;e[29]!==g||e[30]!==R?(w=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,R]}),e[29]=g,e[30]=R,e[31]=w):w=e[31];let k;e[32]!==u||e[33]!==h.length?(k=h.length===0&&t.jsx(ne,{className:"p-4 text-sm text-muted-foreground text-center",children:u.length===0?"No test results yet.":"No results match the current filter."}),e[32]=u,e[33]=h.length,e[34]=k):k=e[34];let T;e[35]!==h?(T=h.map(hi),e[35]=h,e[36]=T):T=e[36];let N;e[37]!==k||e[38]!==T?(N=t.jsxs("div",{className:"space-y-2",children:[k,T]}),e[37]=k,e[38]=T,e[39]=N):N=e[39];let E;return e[40]!==y||e[41]!==w||e[42]!==N||e[43]!==C||e[44]!==_?(E=t.jsxs("div",{className:"space-y-3",children:[C,_,y,w,N]}),e[40]=y,e[41]=w,e[42]=N,e[43]=C,e[44]=_,e[45]=E):E=e[45],E}function hi(s){return t.jsx(ai,{result:s},s.id)}function pi(s){return s.tested_items?`${Math.round(s.passed_items/s.tested_items*100)}%`:"-"}function fi(s){const e=Y.c(20),{selectedRunId:r,onSelectRun:n}=s,o=yt();let i;e[0]!==o.data?.items?(i=o.data?.items??[],e[0]=o.data?.items,e[1]=i):i=e[1];const a=i;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"QA run history"}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Browse previous QA executions and reopen their logs."})]}),e[2]=l):l=e[2];let d;e[3]!==o?(d=t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,t.jsx(G,{size:"sm",variant:"outline",onClick:()=>o.refetch(),children:"Refresh"})]}),e[3]=o,e[4]=d):d=e[4];let u;e[5]!==a.length?(u=a.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No runs yet. Start QA from the Dashboard tab."}),e[5]=a.length,e[6]=u):u=e[6];let m;if(e[7]!==n||e[8]!==a||e[9]!==r){let p;e[11]!==n||e[12]!==r?(p=c=>{const f=ws(c.started_at,c.finished_at),j=pi(c),C=r===c.id;return t.jsxs("button",{type:"button",onClick:()=>n(c.id),className:Z("w-full text-left rounded-lg border p-3 transition-colors",C?"border-primary bg-primary/5":"border-border hover:bg-muted/30"),children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(c.created_at).toLocaleString()})}),t.jsx(F,{className:Z("capitalize",Ns(c.status)),children:c.status})]}),t.jsxs("div",{className:"mt-2 flex items-center gap-3 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground",children:[c.tested_items,"/",c.total_items," tested"]}),t.jsxs("span",{className:"text-emerald-600 font-medium",children:[c.passed_items," passed"]}),c.failed_items>0&&t.jsxs("span",{className:"text-red-600 font-medium",children:[c.failed_items," failed"]}),c.skipped_items>0&&t.jsxs("span",{className:"text-muted-foreground",children:[c.skipped_items," skipped"]}),t.jsxs("span",{className:"text-muted-foreground",children:["pass rate: ",j]}),f&&t.jsx("span",{className:"text-muted-foreground",children:f})]}),c.config_snapshot&&t.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[t.jsx(F,{variant:"outline",className:"text-[9px]",children:(c.config_snapshot.monitorMode??c.config_snapshot.testMode??"health_check").replace("_"," ")}),c.config_snapshot.onFailure!=="none"&&t.jsxs(F,{variant:"outline",className:"text-[9px] text-red-600",children:["on fail:"," ",c.config_snapshot.onFailure.replace(/_/g," ")]})]})]},c.id)},e[11]=n,e[12]=r,e[13]=p):p=e[13],m=a.map(p),e[7]=n,e[8]=a,e[9]=r,e[10]=m}else m=e[10];let h;e[14]!==u||e[15]!==m?(h=t.jsxs("div",{className:"space-y-2 max-h-[520px] overflow-auto",children:[u,m]}),e[14]=u,e[15]=m,e[16]=h):h=e[16];let x;return e[17]!==d||e[18]!==h?(x=t.jsx(ne,{className:"p-4",children:t.jsxs("div",{className:"space-y-3",children:[d,h]})}),e[17]=d,e[18]=h,e[19]=x):x=e[19],x}function gi(){const s=Y.c(20),[e,r]=I.useState(void 0),[n,o]=I.useState("tests"),a=Ot(e).data?.run?.status,l=rt(e,void 0,a);let d;s[0]!==l.data?.items?(d=l.data?.items??[],s[0]=l.data?.items,s[1]=d):d=s[1];let u;s[2]!==d?(u=d.filter(ji),s[2]=d,s[3]=u):u=s[3];const m=u;let h;s[4]===Symbol.for("react.memo_cache_sentinel")?(h=[{id:"tests",label:"Tests"},{id:"configuration",label:"Configuration"},{id:"connections",label:"Connections"}],s[4]=h):h=s[4];let x;s[5]!==n?(x=t.jsx("nav",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar",children:h.map(C=>{const _=n===C.id;return t.jsx("button",{type:"button",className:Z("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex gap-1.5 items-center whitespace-nowrap",_?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),onClick:()=>o(C.id),children:t.jsx("span",{children:C.label})},C.id)})}),s[5]=n,s[6]=x):x=s[6];let p;s[7]!==e||s[8]!==n||s[9]!==m?(p=n==="tests"&&t.jsxs("div",{className:"space-y-6",children:[t.jsx(ni,{activeRunId:e,onRunChange:r}),t.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-4 items-start",children:[t.jsxs("div",{className:"xl:col-span-8 space-y-6 min-w-0",children:[e&&t.jsx(xi,{runId:e}),t.jsx(fi,{selectedRunId:e,onSelectRun:r})]}),t.jsxs("div",{className:"xl:col-span-4 space-y-2 min-w-0",children:[t.jsxs("h3",{className:"text-sm font-semibold",children:["Broken MCPs"," ",m.length>0&&t.jsx(F,{variant:"destructive",className:"text-[10px] ml-1",children:m.length})]}),t.jsx(Tn,{results:m})]})]})]}),s[7]=e,s[8]=n,s[9]=m,s[10]=p):p=s[10];let c;s[11]!==n?(c=n==="configuration"&&t.jsx(qn,{}),s[11]=n,s[12]=c):c=s[12];let f;s[13]!==n?(f=n==="connections"&&t.jsx(Vn,{}),s[13]=n,s[14]=f):f=s[14];let j;return s[15]!==x||s[16]!==p||s[17]!==c||s[18]!==f?(j=t.jsxs("div",{className:"h-full overflow-auto px-4 md:px-6 py-4 space-y-6",children:[x,p,c,f]}),s[15]=x,s[16]=p,s[17]=c,s[18]=f,s[19]=j):j=s[19],j}function ji(s){return s.status==="failed"||s.status==="error"}function vi(s){const e=Y.c(9),{activeTab:r,onChange:n,items:o}=s;let i;if(e[0]!==r||e[1]!==o||e[2]!==n){let l;e[4]!==r||e[5]!==n?(l=d=>{const u=r===d.tab,m=d.icon;return t.jsxs("button",{type:"button",className:Z("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex gap-1.5 items-center whitespace-nowrap",u?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),onClick:()=>n(d.tab),children:[t.jsx(m,{size:14}),t.jsx("span",{children:d.label}),typeof d.count=="number"&&d.count>0&&t.jsx("span",{className:"min-w-4 h-4 px-1 inline-flex items-center justify-center rounded-full bg-primary/15 text-[10px] font-semibold",children:d.count})]},d.id)},e[4]=r,e[5]=n,e[6]=l):l=e[6],i=o.map(l),e[0]=r,e[1]=o,e[2]=n,e[3]=i}else i=e[3];let a;return e[7]!==i?(a=t.jsx("nav",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar",children:i}),e[7]=i,e[8]=a):a=e[8],a}function rl(s){const e=Y.c(47),{onBack:r}=s,[n,o]=I.useState("items"),[i,a]=I.useState(null),{registryName:l,registryIcon:d,acceptPublishRequests:u}=js($e),m=zr(),h=Ir();!u&&n==="requests"&&o("items");const x=m.data?.pending??0,p=h.brokenCount>0?h.brokenCount:void 0;let c;e[0]!==p?(c={id:"items",label:"Items",icon:Vs,tab:"items",count:p},e[0]=p,e[1]=c):c=e[1];let f;e[2]!==u||e[3]!==x?(f=u?[{id:"requests",label:"Requests",icon:qe,tab:"requests",count:x}]:[],e[2]=u,e[3]=x,e[4]=f):f=e[4];let j,C;e[5]===Symbol.for("react.memo_cache_sentinel")?(j={id:"qa",label:"QA",icon:us,tab:"qa"},C={id:"settings",label:"Settings",icon:Gs,tab:"settings"},e[5]=j,e[6]=C):(j=e[5],C=e[6]);let _;e[7]!==c||e[8]!==f?(_=[c,...f,j,C],e[7]=c,e[8]=f,e[9]=_):_=e[9];const y=_;let g;e[10]!==r?(g=r&&t.jsx("button",{type:"button",className:"shrink-0 p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors cursor-pointer",onClick:r,children:t.jsx(Qs,{size:16})}),e[10]=r,e[11]=g):g=e[11];let P;e[12]===Symbol.for("react.memo_cache_sentinel")?(P=()=>o("settings"),e[12]=P):P=e[12];let R;e[13]!==d||e[14]!==l?(R=t.jsx("div",{className:"size-7 rounded-lg border border-border overflow-hidden bg-muted/20 flex items-center justify-center shrink-0",children:d?t.jsx("img",{src:d,alt:l,className:"h-full w-full object-cover"}):t.jsx("span",{className:"text-[10px] font-semibold text-muted-foreground",children:l.slice(0,1).toUpperCase()})}),e[13]=d,e[14]=l,e[15]=R):R=e[15];let w;e[16]!==l?(w=t.jsx("span",{className:"text-sm font-medium truncate max-w-[220px]",children:l}),e[16]=l,e[17]=w):w=e[17];let k;e[18]!==w||e[19]!==R?(k=t.jsxs("button",{type:"button",className:"min-w-0 flex items-center gap-2 hover:opacity-90 transition-opacity cursor-pointer",onClick:P,children:[R,w]}),e[18]=w,e[19]=R,e[20]=k):k=e[20];let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("div",{className:"h-6 w-px bg-border shrink-0"}),e[21]=T):T=e[21];let N;e[22]!==n||e[23]!==y?(N=t.jsx(vi,{activeTab:n,onChange:o,items:y}),e[22]=n,e[23]=y,e[24]=N):N=e[24];let E;e[25]!==k||e[26]!==N||e[27]!==g?(E=t.jsx("header",{className:"shrink-0 w-full border-b border-border h-12 overflow-x-auto flex items-center justify-between gap-3 px-4 min-w-max",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[g,k,T,N]})}),e[25]=k,e[26]=N,e[27]=g,e[28]=E):E=e[28];let v;e[29]!==n?(v=n==="items"&&t.jsx(_n,{}),e[29]=n,e[30]=v):v=e[30];let D;e[31]!==u||e[32]!==n?(D=n==="requests"&&u&&t.jsx(Sn,{}),e[31]=u,e[32]=n,e[33]=D):D=e[33];let O;e[34]!==n?(O=n==="qa"&&t.jsx(gi,{}),e[34]=n,e[35]=O):O=e[35];let M;e[36]!==n||e[37]!==i?(M=n==="settings"&&t.jsx(Rn,{revealedKey:i,onRevealedKeyChange:a}),e[36]=n,e[37]=i,e[38]=M):M=e[38];let A;e[39]!==v||e[40]!==D||e[41]!==O||e[42]!==M?(A=t.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[v,D,O,M]}),e[39]=v,e[40]=D,e[41]=O,e[42]=M,e[43]=A):A=e[43];let $;return e[44]!==E||e[45]!==A?($=t.jsxs("div",{className:"h-full flex flex-col bg-background overflow-hidden",children:[E,A]}),e[44]=E,e[45]=A,e[46]=$):$=e[46],$}export{rl as default};