@nextclaw/ui 0.14.1 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/assets/{api-DPcvCLfa.js → api-BP_8IaxB.js} +7 -7
  3. package/dist/assets/channels-list-page-DEh5Jjqx.js +8 -0
  4. package/dist/assets/chat-page-BRB0N5WW.js +105 -0
  5. package/dist/assets/config-split-page-CRhlZ_pH.js +1 -0
  6. package/dist/assets/{confirm-dialog-CWh5FfK2.js → confirm-dialog-DsivFJ4r.js} +2 -2
  7. package/dist/assets/{desktop-update-config-DsRhBizi.js → desktop-update-config-B0w9p2ep.js} +1 -1
  8. package/dist/assets/{dist-DPrgcEC0.js → dist-CikkhOlq.js} +1 -1
  9. package/dist/assets/{dist-DsE4OsSS.js → dist-PVA_xL1D.js} +1 -1
  10. package/dist/assets/doc-browser-BoNJ7-tE.js +1 -0
  11. package/dist/assets/doc-browser-CdJ_d4ik.js +1 -0
  12. package/dist/assets/doc-browser-context-MTw4EvKd.js +1 -0
  13. package/dist/assets/{ellipsis-B81FStLm.js → ellipsis-y6vDtq4M.js} +1 -1
  14. package/dist/assets/{external-link-C_dmG-WJ.js → external-link-DVJIQf_G.js} +1 -1
  15. package/dist/assets/index-BiE-K8-q.css +1 -0
  16. package/dist/assets/index-D9BAE_L_.js +105 -0
  17. package/dist/assets/mcp-marketplace-page-B1SZNY5m.js +40 -0
  18. package/dist/assets/mcp-marketplace-page-Cq_Tw42T.js +1 -0
  19. package/dist/assets/middleware-CkFT3R4v.js +1 -0
  20. package/dist/assets/model-config-page-DotaTUHb.js +1 -0
  21. package/dist/assets/plus-BbZqquJe.js +1 -0
  22. package/dist/assets/provider-scoped-model-input-DsFRuWJH.js +1 -0
  23. package/dist/assets/providers-config-page-DW4tQSLN.js +1 -0
  24. package/dist/assets/{react-sZz5HSCm.js → react-VNqT5Zp7.js} +1 -1
  25. package/dist/assets/remote-B8TiUfwW.js +1 -0
  26. package/dist/assets/rotate-cw-DjHDTkCv.js +1 -0
  27. package/dist/assets/runtime-config-page-S6ErRHR8.js +1 -0
  28. package/dist/assets/{save-MzjoiHri.js → save-BOJ477H-.js} +1 -1
  29. package/dist/assets/{search-B29dE4GN.js → search-BEti5beA.js} +1 -1
  30. package/dist/assets/{search-config-page-Dl5sZzob.js → search-config-page-DGj5am03.js} +1 -1
  31. package/dist/assets/{secrets-config-page-C_l-IFCK.js → secrets-config-page--IzrIOid.js} +2 -2
  32. package/dist/assets/{select-BKmh05hd.js → select-hoj8dK4K.js} +2 -2
  33. package/dist/assets/{tag-chip-BS_7Ueom.js → tag-chip-T8-h-die.js} +1 -1
  34. package/dist/assets/use-config-CjRV2hwL.js +1 -0
  35. package/dist/assets/x-D9PXs_xP.js +1 -0
  36. package/dist/index.html +70 -19
  37. package/index.html +55 -5
  38. package/package.json +9 -9
  39. package/src/app/components/app-presenter-provider.tsx +11 -2
  40. package/src/app/components/layout/__tests__/app-layout.test.tsx +11 -2
  41. package/src/app/components/layout/__tests__/sidebar.layout.test.tsx +110 -79
  42. package/src/app/components/layout/app-layout.tsx +18 -4
  43. package/src/app/components/layout/header.tsx +3 -3
  44. package/src/app/components/layout/page-layout.tsx +2 -2
  45. package/src/app/components/layout/runtime-status-entry.tsx +7 -7
  46. package/src/app/components/layout/sidebar-items.tsx +194 -71
  47. package/src/app/components/layout/sidebar-rail.styles.ts +15 -0
  48. package/src/app/components/layout/sidebar.tsx +340 -83
  49. package/src/app/managers/viewport-layout.manager.ts +10 -0
  50. package/src/app/stores/viewport-layout.store.ts +39 -3
  51. package/src/app/styles/design-system.css +388 -26
  52. package/src/app/test/vitest-setup.ts +31 -0
  53. package/src/features/agents/components/__tests__/agents-page.test.tsx +62 -39
  54. package/src/features/agents/components/agents-page.tsx +10 -6
  55. package/src/features/chat/components/chat-sidebar-list-mode-switch.tsx +3 -3
  56. package/src/features/chat/components/conversation/__tests__/chat-conversation-header-section.test.tsx +145 -0
  57. package/src/features/chat/components/conversation/__tests__/chat-conversation-header.test.tsx +4 -2
  58. package/src/features/chat/components/conversation/__tests__/chat-conversation-panel.test.tsx +69 -762
  59. package/src/features/chat/components/conversation/__tests__/chat-conversation-workspace-section.test.tsx +132 -0
  60. package/src/features/chat/components/conversation/chat-conversation-content.tsx +22 -15
  61. package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +15 -16
  62. package/src/features/chat/components/conversation/chat-conversation-header.tsx +7 -6
  63. package/src/features/chat/components/conversation/chat-conversation-panel.tsx +19 -19
  64. package/src/features/chat/components/conversation/chat-conversation-skeleton.tsx +13 -13
  65. package/src/features/chat/components/conversation/chat-conversation-workspace-section.tsx +10 -4
  66. package/src/features/chat/components/layout/__tests__/chat-sidebar-read-state.test.tsx +52 -11
  67. package/src/features/chat/components/layout/__tests__/chat-sidebar.test.tsx +18 -16
  68. package/src/features/chat/components/layout/chat-page-shell.tsx +1 -1
  69. package/src/features/chat/components/layout/chat-sidebar-desktop-layout.tsx +247 -0
  70. package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +93 -20
  71. package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +93 -36
  72. package/src/features/chat/components/layout/chat-sidebar.tsx +60 -93
  73. package/src/features/chat/components/providers/chat-presenter.provider.tsx +0 -6
  74. package/src/features/chat/features/conversation/components/__tests__/session-conversation-area.test.tsx +225 -0
  75. package/src/features/chat/features/conversation/components/__tests__/session-conversation-input.streaming.test.tsx +199 -0
  76. package/src/features/chat/features/conversation/components/session-conversation-area.tsx +308 -0
  77. package/src/features/chat/features/conversation/components/session-conversation-input.tsx +439 -0
  78. package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +194 -0
  79. package/src/features/chat/features/conversation/hooks/use-session-conversation-input-attachments.ts +66 -0
  80. package/src/features/chat/features/{input/hooks/use-chat-input-bar-query-state.ts → conversation/hooks/use-session-conversation-input-query.ts} +51 -20
  81. package/src/features/chat/features/conversation/hooks/use-session-conversation-input-state.ts +281 -0
  82. package/src/features/chat/features/conversation/utils/session-conversation-input-toolbar.utils.ts +158 -0
  83. package/src/features/chat/features/input/hooks/__tests__/use-chat-input-surface-state.test.tsx +56 -0
  84. package/src/features/chat/features/input/hooks/use-chat-input-surface-state.ts +117 -0
  85. package/src/features/chat/features/input/input-surface-plugins/__tests__/panel-app-reference-plugin.test.ts +77 -0
  86. package/src/features/chat/features/input/input-surface-plugins/__tests__/slash-command-plugin.test.ts +108 -0
  87. package/src/features/chat/features/input/input-surface-plugins/chat-input-product-plugin-adapters.types.ts +10 -0
  88. package/src/features/chat/features/input/input-surface-plugins/input-surface-search.utils.ts +108 -0
  89. package/src/features/chat/features/input/input-surface-plugins/panel-app-reference-plugin.utils.ts +108 -0
  90. package/src/features/chat/features/input/input-surface-plugins/slash-command-plugin.utils.ts +161 -0
  91. package/src/features/chat/features/input/utils/__tests__/chat-composer-state.utils.test.ts +22 -1
  92. package/src/features/chat/features/input/utils/__tests__/chat-inline-token.utils.test.ts +26 -13
  93. package/src/features/chat/features/input/utils/__tests__/ncp-chat-input-availability.utils.test.ts +7 -28
  94. package/src/features/chat/features/input/utils/chat-composer-state.utils.ts +6 -0
  95. package/src/features/chat/features/input/utils/chat-inline-token.utils.ts +26 -51
  96. package/src/features/chat/features/input/utils/chat-input-bar.utils.ts +2 -0
  97. package/src/features/chat/features/input/utils/ncp-chat-input-availability.utils.ts +5 -6
  98. package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +47 -12
  99. package/src/features/chat/features/message/components/chat-inline-panel-app-card.tsx +7 -7
  100. package/src/features/chat/features/message/components/chat-message-list.container.tsx +99 -18
  101. package/src/features/chat/features/message/utils/__tests__/chat-message.utils.test.ts +31 -12
  102. package/src/features/chat/features/message/utils/chat-message-markdown-part.utils.ts +38 -0
  103. package/src/features/chat/features/message/utils/chat-message-part.utils.ts +1 -1
  104. package/src/features/chat/features/session/components/chat-sidebar-project-groups.tsx +7 -7
  105. package/src/features/chat/features/session/components/chat-sidebar-session-list.tsx +6 -6
  106. package/src/features/chat/features/session/components/session-context-icon.tsx +2 -2
  107. package/src/features/chat/features/session/components/session-header/__tests__/chat-session-project-badge.test.tsx +2 -2
  108. package/src/features/chat/features/session/components/session-header/chat-session-header-actions.tsx +1 -1
  109. package/src/features/chat/features/session/components/session-header/chat-session-header-menu-item.tsx +1 -1
  110. package/src/features/chat/features/session/components/session-header/chat-session-metadata-dialog.tsx +1 -1
  111. package/src/features/chat/features/session/components/session-header/chat-session-project-badge.tsx +3 -3
  112. package/src/features/chat/features/session/components/session-run-badge.tsx +1 -1
  113. package/src/features/chat/features/session/hooks/__tests__/use-chat-session-project.test.tsx +3 -30
  114. package/src/features/chat/features/session/hooks/use-chat-session-project.ts +0 -5
  115. package/src/features/chat/features/session/utils/chat-run-metadata.utils.ts +8 -0
  116. package/src/features/chat/features/session-type/components/__tests__/chat-session-type-menu.test.tsx +2 -2
  117. package/src/features/chat/features/session-type/components/__tests__/chat-session-type-option-item.test.tsx +2 -0
  118. package/src/features/chat/features/session-type/components/chat-session-type-menu.tsx +2 -2
  119. package/src/features/chat/features/session-type/components/chat-session-type-option-item.tsx +2 -2
  120. package/src/features/chat/features/session-type/hooks/use-chat-session-type-state.ts +10 -2
  121. package/src/features/chat/features/welcome/components/__tests__/chat-conversation-welcome.test.tsx +49 -31
  122. package/src/features/chat/features/welcome/components/__tests__/chat-welcome.test.tsx +2 -9
  123. package/src/features/chat/features/welcome/components/chat-conversation-welcome.tsx +21 -10
  124. package/src/features/chat/features/welcome/components/chat-welcome-agent-picker.tsx +3 -3
  125. package/src/features/chat/features/welcome/components/chat-welcome-capability-grid.tsx +4 -4
  126. package/src/features/chat/features/welcome/components/chat-welcome-project-picker.tsx +14 -19
  127. package/src/features/chat/features/welcome/components/chat-welcome-session-type-picker.tsx +5 -5
  128. package/src/features/chat/features/welcome/components/chat-welcome.tsx +6 -6
  129. package/src/features/chat/features/welcome/utils/__tests__/chat-welcome-project-options.utils.test.ts +6 -8
  130. package/src/features/chat/features/welcome/utils/chat-welcome-project-options.utils.ts +1 -16
  131. package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel-content.test.tsx +54 -0
  132. package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +44 -76
  133. package/src/features/chat/features/workspace/components/chat-session-workspace-panel-nav.tsx +5 -1
  134. package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +7 -1
  135. package/src/features/chat/features/workspace/hooks/use-chat-conversation-workspace-state.ts +40 -31
  136. package/src/features/chat/features/workspace/utils/__tests__/chat-workspace-panel-view-model.utils.test.ts +59 -1
  137. package/src/features/chat/features/workspace/utils/chat-thread-workspace-session.utils.ts +109 -0
  138. package/src/features/chat/features/workspace/utils/chat-workspace-panel-view-model.utils.ts +44 -4
  139. package/src/features/chat/index.ts +0 -1
  140. package/src/features/chat/managers/__tests__/chat-session-list.manager.test.ts +51 -99
  141. package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +135 -21
  142. package/src/features/chat/managers/chat-session-list.manager.ts +12 -43
  143. package/src/features/chat/managers/chat-thread.manager.ts +108 -34
  144. package/src/features/chat/pages/__tests__/ncp-chat-page.test.ts +48 -1
  145. package/src/features/chat/pages/__tests__/ncp-chat-page.test.tsx +72 -0
  146. package/src/features/chat/pages/ncp-chat-page.tsx +0 -122
  147. package/src/features/chat/presenters/chat.presenter.ts +2 -19
  148. package/src/features/chat/stores/__tests__/chat-thread.store.test.ts +31 -0
  149. package/src/features/chat/stores/chat-thread.store.ts +42 -26
  150. package/src/features/panel-apps/components/panel-app-list-item.tsx +8 -8
  151. package/src/features/panel-apps/components/panel-app-toolbar.tsx +4 -4
  152. package/src/features/panel-apps/components/panel-apps-list.tsx +20 -20
  153. package/src/features/panel-apps/hooks/use-panel-apps.ts +2 -1
  154. package/src/features/pwa/managers/__tests__/pwa-shell-theme.manager.test.ts +70 -6
  155. package/src/features/pwa/managers/pwa-shell-theme.manager.ts +10 -5
  156. package/src/features/service-apps/components/service-action-authorization-dialog.tsx +8 -8
  157. package/src/features/service-apps/components/service-apps-panel.tsx +24 -24
  158. package/src/features/settings/components/config/provider-advanced-settings-section.tsx +5 -5
  159. package/src/features/settings/components/config/provider-auth-section.tsx +7 -7
  160. package/src/features/settings/components/config/provider-form.tsx +10 -10
  161. package/src/features/settings/components/config/provider-models-section.tsx +16 -16
  162. package/src/features/settings/components/config/provider-pill-selector.tsx +1 -1
  163. package/src/features/settings/pages/providers-config-page.tsx +17 -17
  164. package/src/platforms/desktop/components/__tests__/desktop-app-shell.test.tsx +50 -10
  165. package/src/platforms/desktop/components/desktop-app-shell.tsx +34 -10
  166. package/src/platforms/desktop/components/desktop-window-chrome.tsx +41 -16
  167. package/src/shared/components/config-split-page.tsx +11 -11
  168. package/src/shared/components/doc-browser/doc-browser-home-page.tsx +2 -2
  169. package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +4 -4
  170. package/src/shared/components/doc-browser/doc-browser-tab-strip.tsx +4 -4
  171. package/src/shared/components/doc-browser/doc-browser.tsx +3 -3
  172. package/src/shared/components/resizable-right-panel/resizable-right-panel.tsx +1 -1
  173. package/src/shared/components/ui/actions/icon-action-button.tsx +1 -1
  174. package/src/shared/components/ui/button.tsx +4 -4
  175. package/src/shared/components/ui/card.tsx +4 -4
  176. package/src/shared/components/ui/dialog.tsx +5 -5
  177. package/src/shared/components/ui/input.tsx +1 -1
  178. package/src/shared/components/ui/label.tsx +1 -1
  179. package/src/shared/components/ui/popover.tsx +1 -1
  180. package/src/shared/components/ui/select.tsx +3 -3
  181. package/src/shared/components/ui/switch.tsx +3 -3
  182. package/src/shared/components/ui/tab-strip/__tests__/compact-tab-strip.test.tsx +24 -1
  183. package/src/shared/components/ui/tab-strip/compact-tab-strip.tsx +8 -4
  184. package/src/shared/components/ui/tabs.tsx +4 -4
  185. package/src/shared/components/ui/textarea.tsx +1 -1
  186. package/src/shared/lib/i18n/locales/en-US/chat.json +20 -2
  187. package/src/shared/lib/i18n/locales/en-US/core.json +9 -2
  188. package/src/shared/lib/i18n/locales/zh-CN/chat.json +20 -2
  189. package/src/shared/lib/i18n/locales/zh-CN/core.json +9 -2
  190. package/src/shared/lib/theme/index.ts +94 -52
  191. package/src/shared/lib/ui-document-title/__tests__/ui-document-title.test.ts +49 -0
  192. package/src/shared/lib/ui-document-title/index.ts +50 -21
  193. package/dist/assets/channels-list-page-D6jtziu4.js +0 -8
  194. package/dist/assets/chat-page-BBnNJoKG.js +0 -105
  195. package/dist/assets/config-split-page-BCJhqdK9.js +0 -1
  196. package/dist/assets/doc-browser-C8xOF_9F.js +0 -1
  197. package/dist/assets/doc-browser-DgQedeAn.js +0 -1
  198. package/dist/assets/doc-browser-context-B46tQGmO.js +0 -1
  199. package/dist/assets/index-7o1WdUbU.js +0 -103
  200. package/dist/assets/index-DQWmEWzk.css +0 -1
  201. package/dist/assets/mcp-marketplace-page-CWZN7ohK.js +0 -1
  202. package/dist/assets/mcp-marketplace-page-Dzull_4-.js +0 -40
  203. package/dist/assets/model-config-page-Cv0O3BIj.js +0 -1
  204. package/dist/assets/plus-Bnt56oqG.js +0 -1
  205. package/dist/assets/provider-scoped-model-input-Duuh7i3h.js +0 -1
  206. package/dist/assets/providers-config-page-CPDz0Lxc.js +0 -1
  207. package/dist/assets/remote-B0LMs8u7.js +0 -1
  208. package/dist/assets/rotate-cw-BfyG_KEF.js +0 -1
  209. package/dist/assets/runtime-config-page-q0fvv8ME.js +0 -1
  210. package/dist/assets/use-config-DZkBWIdL.js +0 -1
  211. package/dist/assets/x-CW2KO-Hz.js +0 -1
  212. package/src/features/chat/components/conversation/chat-conversation-alerts.tsx +0 -37
  213. package/src/features/chat/features/input/components/__tests__/chat-attachment-upload-limit.test.ts +0 -38
  214. package/src/features/chat/features/input/components/chat-input-bar.container.tsx +0 -496
  215. package/src/features/chat/features/message/utils/chat-message-inline-content.utils.ts +0 -95
  216. package/src/features/chat/managers/__tests__/chat-input.manager.test.ts +0 -448
  217. package/src/features/chat/managers/__tests__/chat-run-snapshot.manager.test.ts +0 -129
  218. package/src/features/chat/managers/__tests__/chat-run.manager.test.ts +0 -236
  219. package/src/features/chat/managers/__tests__/chat-session-preference-sync.manager.test.ts +0 -219
  220. package/src/features/chat/managers/chat-input.manager.ts +0 -430
  221. package/src/features/chat/managers/chat-run.manager.ts +0 -110
  222. package/src/features/chat/managers/chat-session-preference-sync.manager.ts +0 -142
  223. package/src/features/chat/stores/chat-input.store.ts +0 -104
  224. /package/dist/assets/{config-hints-CTqBnCDp.js → config-hints-BkYBc7z0.js} +0 -0
@@ -0,0 +1,40 @@
1
+ import{h as e,p as t,r as n,u as r,v as i}from"./react-VNqT5Zp7.js";import{Bt as a,C as o,D as s,E as c,Gt as l,Jt as u,Kt as d,O as f,Rt as p,T as m,Vt as h,_t as g,an as _,cn as v,in as y,on as b,qt as x,sn as S,w as ee}from"./api-BP_8IaxB.js";import{c as C}from"./dist-PVA_xL1D.js";import{a as w,i as T,n as E,r as D,t as O}from"./select-hoj8dK4K.js";import{a as k,i as A,n as j,o as M,r as N,s as P}from"./confirm-dialog-DsivFJ4r.js";import{n as te}from"./doc-browser-context-MTw4EvKd.js";import{D as F,L as ne,_t as re,b as ie,lt as ae,ot as I}from"./index-D9BAE_L_.js";import{t as L}from"./tag-chip-T8-h-die.js";var oe=class extends v{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:S()})}getOptimisticResult(e){return e.behavior=S(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:_(t,n.data),hasPreviousPage:b(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function R(e,t){return u(e,oe,t)}var se=C(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]),ce=C(`PackageSearch`,[[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}],[`circle`,{cx:`18.5`,cy:`15.5`,r:`2.5`,key:`b5zd12`}],[`path`,{d:`M20.27 17.27 22 19`,key:`1l4muz`}]]);function z(e){if(!e||e.pages.length===0)return;let t=e.pages.flatMap(e=>e.items);return{...e.pages[e.pages.length-1],items:t,pages:e.pages,loadedItems:t.length,loadedPages:e.pages.length}}var B=t();function V({scope:e,isRefreshing:t,searchText:r,searchPlaceholder:i,sort:a,onSearchTextChange:o,onSortChange:s}){return(0,B.jsx)(`div`,{className:`mb-4`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,B.jsx)(ce,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,B.jsx)(`input`,{value:r,onChange:e=>o(e.target.value),placeholder:i,className:`h-9 w-full rounded-xl border border-gray-200/80 pl-9 pr-9 text-sm focus:outline-none focus:ring-1 focus:ring-primary/40`}),t&&(0,B.jsx)(re,{className:`absolute right-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 animate-spin text-primary`,"aria-label":n(`marketplaceRefreshingResults`)})]}),e===`all`&&(0,B.jsxs)(O,{value:a,onValueChange:e=>s(e),children:[(0,B.jsx)(T,{className:`h-9 w-[150px] shrink-0 rounded-lg`,children:(0,B.jsx)(w,{})}),(0,B.jsxs)(E,{children:[(0,B.jsx)(D,{value:`relevance`,children:n(`marketplaceSortRelevance`)}),(0,B.jsx)(D,{value:`updated`,children:n(`marketplaceSortUpdated`)})]})]})]})})}function H({count:e}){return(0,B.jsx)(B.Fragment,{children:Array.from({length:e},(e,t)=>(0,B.jsx)(`article`,{className:`h-full rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-1 gap-2.5`,children:[(0,B.jsx)(F,{className:`h-9 w-9 shrink-0 rounded-lg`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,B.jsx)(F,{className:`h-4 w-32 max-w-[70%]`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(F,{className:`h-3 w-12`}),(0,B.jsx)(F,{className:`h-3 w-24`})]}),(0,B.jsx)(F,{className:`h-3 w-full`}),(0,B.jsxs)(`div`,{className:`flex gap-1.5 pt-0.5`,children:[(0,B.jsx)(F,{className:`h-5 w-14 rounded-md`}),(0,B.jsx)(F,{className:`h-5 w-16 rounded-md`}),(0,B.jsx)(F,{className:`h-5 w-12 rounded-md`})]})]})]}),(0,B.jsx)(F,{className:`h-7 w-16 shrink-0 rounded-md`})]})},`marketplace-skeleton-${t}`))})}function U({hasMore:e,loading:t,sentinelRef:r}){return!e&&!t?null:(0,B.jsxs)(`div`,{className:`py-4`,children:[e&&(0,B.jsx)(`div`,{ref:r,className:`h-1 w-full`,"aria-hidden":`true`}),t&&(0,B.jsx)(`div`,{"data-testid":`marketplace-loading-more`,className:`pt-3 text-center text-xs text-gray-500`,children:n(`loading`)})]})}function W(e){let t=e.trim().toLowerCase().replace(/_/g,`-`),n=[t,t.split(`-`)[0],`en`];return Array.from(new Set(n.filter(Boolean)))}function G(e){return e.trim().toLowerCase().replace(/_/g,`-`)}function K(e,t,n){if(e){let t=Object.entries(e).map(([e,t])=>({locale:G(e),text:typeof t==`string`?t.trim():``})).filter(e=>e.text.length>0);if(t.length>0){let e=new Map(t.map(e=>[e.locale,e.text]));for(let t of n){let n=G(t),r=e.get(n);if(r)return r}for(let e of n){let n=G(e).split(`-`)[0];if(!n)continue;let r=t.find(e=>e.locale===n||e.locale.startsWith(`${n}-`));if(r)return r.text}return t[0]?.text??``}}return t?.trim()??``}function le(e,t){if(!e)return``;for(let n of t)if(G(n).split(`-`)[0]===`zh`&&e.descriptionZh?.trim())return e.descriptionZh.trim();return e.description?.trim()?e.description.trim():e.descriptionZh?.trim()?e.descriptionZh.trim():``}var q=i(e(),1),ue=160;function J({disabled:e,onLoadMore:t,thresholdPx:n=ue,watchValue:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(t),s=(0,q.useRef)(!1);return(0,q.useEffect)(()=>{o.current=t},[t]),(0,q.useEffect)(()=>{e&&(s.current=!1)},[e]),(0,q.useEffect)(()=>{let t=i.current,r=a.current;if(e||!t||!r)return;let c=()=>{s.current||e||(s.current=!0,Promise.resolve(o.current()).finally(()=>{s.current=!1}))},l=()=>{r.getBoundingClientRect().top-t.getBoundingClientRect().bottom<=n&&c()};if(typeof IntersectionObserver==`function`){let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:t,rootMargin:`0px 0px ${n}px 0px`});return e.observe(r),l(),()=>{e.disconnect()}}return t.addEventListener(`scroll`,l,{passive:!0}),l(),()=>{t.removeEventListener(`scroll`,l)}},[e,n,r]),{containerRef:i,sentinelRef:a}}function Y(e){return(e??``).trim().toLowerCase()}function de(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=Y(r);!e||t.has(e)||t.set(e,n)}}return t}function fe(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=Y(e);if(!n)continue;let r=t.get(n);if(r)return r}}function X(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function Z(e,t,n,r,i){let a=`<!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>${X(e)}</title>
7
+ <style>
8
+ body { margin: 0; background: #f8fafc; color: #0f172a; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
9
+ .wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 40px; }
10
+ .hero { border: 1px solid #dbeafe; border-radius: 16px; background: linear-gradient(180deg, #eff6ff, #ffffff); padding: 20px; }
11
+ .hero h1 { margin: 0; font-size: 26px; }
12
+ .grid { display: grid; grid-template-columns: 280px 1fr; gap: 14px; margin-top: 16px; }
13
+ .card { border: 1px solid #e2e8f0; background: #fff; border-radius: 14px; overflow: hidden; }
14
+ .card h2 { margin: 0; padding: 12px 14px; font-size: 13px; font-weight: 700; color: #1d4ed8; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
15
+ .body { padding: 12px 14px; }
16
+ pre { margin: 0; white-space: pre-wrap; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
17
+ a { color: #2563eb; text-decoration: none; }
18
+ @media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <main class="wrap">
23
+ <section class="hero">
24
+ <h1>${X(e)}</h1>
25
+ ${i?`<p>${X(i)}</p>`:``}
26
+ ${r?`<p><a href="${X(r)}" target="_blank" rel="noopener noreferrer">${X(r)}</a></p>`:``}
27
+ </section>
28
+ <section class="grid">
29
+ <article class="card">
30
+ <h2>Metadata</h2>
31
+ <div class="body"><pre>${X(t)}</pre></div>
32
+ </article>
33
+ <article class="card">
34
+ <h2>Content</h2>
35
+ <div class="body"><pre>${X(n)}</pre></div>
36
+ </article>
37
+ </section>
38
+ </main>
39
+ </body>
40
+ </html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(a)}`}function pe(e,t,r){return K(t?.summaryI18n,t?.summary,e)||le(r,e)||n(`marketplaceInstalledLocalSummary`)}function me(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}function Q(e){let{item:t,record:r,localeFallbacks:i,onOpen:a,onInstall:o,onToggle:s,onDoctor:c,onRemove:l}=e,u=r,d=t?.name??r?.label??r?.id??`MCP`,f=pe(i,t,r),p=me(t,r),m=u?u.enabled===!1?n(`marketplaceDisable`):n(`statusReady`):null;return(0,B.jsx)(`article`,{onClick:a,className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:d}),(0,B.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:p}),(0,B.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:f}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(t?.tags??[]).map(e=>(0,B.jsx)(L,{children:e},e)),m?(0,B.jsx)(L,{tone:`success`,children:m}):null]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!u&&t&&o?(0,B.jsx)(h,{type:`button`,size:`sm`,variant:`primary`,className:`rounded-xl`,onClick:e=>{e.stopPropagation(),o()},children:n(`marketplaceInstall`)}):null,u?(0,B.jsxs)(B.Fragment,{children:[s?(0,B.jsx)(h,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-gray-200 text-gray-700`,onClick:e=>{e.stopPropagation(),s()},children:u.enabled===!1?n(`marketplaceEnable`):n(`marketplaceDisable`)}):null,c?(0,B.jsx)(h,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-blue-200 text-blue-700 hover:border-blue-300 hover:bg-blue-50 hover:text-blue-700`,onClick:e=>{e.stopPropagation(),c()},children:n(`marketplaceMcpDoctor`)}):null,l?(0,B.jsx)(h,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-rose-200 text-rose-600 hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600`,onClick:e=>{e.stopPropagation(),l()},children:n(`marketplaceMcpRemove`)}):null]}):null]})]})})}function he(e){let{item:t,open:n,pending:r,onOpenChange:i,onSubmit:a}=e;return(0,B.jsx)(j,{open:n,onOpenChange:i,children:t?(0,B.jsx)(ge,{item:t,pending:r,onOpenChange:i,onSubmit:a},`${t.slug}:${n?`open`:`closed`}`):null})}function ge(e){let{item:t,pending:r,onOpenChange:i,onSubmit:o}=e,s=t.install,[c,l]=(0,q.useState)(s?.defaultName??``),[u,d]=(0,q.useState)(!0),[f,p]=(0,q.useState)(Object.fromEntries((s?.inputs??[]).map(e=>[e.id,e.defaultValue??``])));return(0,B.jsxs)(N,{children:[(0,B.jsxs)(M,{children:[(0,B.jsx)(P,{children:n(`marketplaceMcpInstallDialogTitle`)}),(0,B.jsx)(A,{children:t.name})]}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:n(`marketplaceMcpServerName`)}),(0,B.jsx)(a,{value:c,onChange:e=>l(e.target.value),placeholder:s?.defaultName??`mcp-server`})]}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:n(`marketplaceMcpAllAgents`)}),(0,B.jsx)(`div`,{className:`text-xs text-gray-500`,children:n(`marketplaceMcpAllAgentsDescription`)})]}),(0,B.jsx)(g,{checked:u,onCheckedChange:d})]}),(s?.inputs??[]).map(e=>(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description?(0,B.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,B.jsx)(a,{type:e.secret?`password`:`text`,value:f[e.id]??``,onChange:t=>p(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,B.jsxs)(k,{children:[(0,B.jsx)(h,{variant:`outline`,onClick:()=>i(!1),disabled:r,children:n(`cancel`)}),(0,B.jsx)(h,{onClick:()=>void o({name:c,allAgents:u,inputs:f}),disabled:r||!c.trim(),children:n(r?`marketplaceInstalling`:`marketplaceInstall`)})]})]})}function _e(e){let{result:t,targetName:r,open:i,pending:a,onOpenChange:o}=e;return(0,B.jsx)(j,{open:i,onOpenChange:o,children:(0,B.jsxs)(N,{children:[(0,B.jsxs)(M,{children:[(0,B.jsx)(P,{children:n(`marketplaceMcpDoctorTitle`)}),(0,B.jsx)(A,{children:r??`-`})]}),a?(0,B.jsx)(`div`,{className:`text-sm text-gray-500`,children:n(`loading`)}):null,!a&&t?(0,B.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,B.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorAccessible`),`:`,` `,t.accessible?n(`statusReady`):n(`marketplaceOperationFailed`)]}),(0,B.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTransport`),`:`,` `,t.transport.toUpperCase()]}),(0,B.jsxs)(`div`,{children:[n(`marketplaceMcpDoctorTools`),`: `,t.toolCount]}),t.error?(0,B.jsx)(I,{tone:`danger`,description:t.error,className:`rounded-lg`}):null]}):null]})})}function ve(e){let t=R({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>c({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,q.useMemo)(()=>z(t.data),[t.data]);return{...t,data:n}}function ye(){return x({queryKey:[`marketplace-mcp-installed`],queryFn:()=>m(),staleTime:1e4})}function be(){let e=y();return d({mutationFn:s,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),l.success(t.message||n(`marketplaceInstallSuccessMcp`))},onError:e=>{l.error(e.message||n(`marketplaceInstallFailed`))}})}function xe(){let e=y();return d({mutationFn:f,onSuccess:t=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),l.success(t.message||n(`marketplaceMcpManageSuccess`))},onError:e=>{l.error(e.message||n(`marketplaceOperationFailed`))}})}var $=12;function Se(){let[e,t]=(0,q.useState)(`catalog`),[i,a]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(`relevance`),[f,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(null),{language:y}=ie(),b=te(),{confirm:x,ConfirmDialog:S}=ne(),C=(0,q.useMemo)(()=>W(y),[y]);(0,q.useEffect)(()=>{let e=window.setTimeout(()=>{c(i.trim())},250);return()=>window.clearTimeout(e)},[i]);let w=ve({q:s||void 0,sort:l,pageSize:$}),T=ye(),{containerRef:E,sentinelRef:D}=J({disabled:e!==`catalog`||w.isError||!w.hasNextPage||w.isFetchingNextPage,onLoadMore:()=>w.fetchNextPage(),watchValue:`${e}:${s}:${l}:${w.data?.loadedItems??0}:${w.data?.loadedPages??0}`});(0,q.useEffect)(()=>{let e=E.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[E,s,e,l]);let O=be(),k=xe(),A=d({mutationFn:o,onSuccess:(e,t)=>{g(t),v(e)}}),j=(0,q.useMemo)(()=>de(T.data?.records??[]),[T.data?.records]),M=(0,q.useMemo)(()=>(T.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return s?t.includes(s.toLowerCase()):!0}),[T.data?.records,s]),N=async(e,t)=>{let r=e?.name??t?.label??t?.id??`MCP`,i={title:r,kind:`content`,dedupeKey:e?`marketplace:mcp:${e.slug}`:`marketplace:mcp:${t?.id??t?.spec??r}`},a=pe(C,e,t);if(!e){let e=Z(r,JSON.stringify(t??{},null,2),n(`marketplaceInstalledLocalSummary`),t?.docsUrl,a);b.open(e,i);return}try{let t=await ee(e.slug),n=Z(r,t.metadataRaw||JSON.stringify(e,null,2),t.bodyRaw||t.raw,t.sourceUrl,a);b.open(n,i)}catch(e){let t=Z(r,JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),a,void 0,a);b.open(t,i)}},P=async e=>{f&&(await O.mutateAsync({spec:f.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),m(null))},F=async(e,t)=>{let r=t.id||t.spec;r&&(e===`remove`&&!await x({title:`${n(`marketplaceMcpRemoveTitle`)} ${r}?`,description:n(`marketplaceMcpRemoveDescription`),confirmLabel:n(`marketplaceMcpRemove`),variant:`destructive`})||await k.mutateAsync({action:e,id:r,spec:t.spec}))},re=[{id:`catalog`,label:n(`marketplaceMcpTabCatalog`),icon:ae},{id:`installed`,label:n(`marketplaceMcpTabInstalled`),icon:se,count:T.data?.total??0}];return(0,B.jsxs)(p,{className:`flex h-full min-h-0 flex-col pb-0 px-0`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-6 w-full max-w-[1400px] h-full min-h-0 mx-auto`,children:[(0,B.jsxs)(`div`,{className:`relative overflow-hidden rounded-[32px] bg-gradient-to-br from-[#0F172A] via-[#1E1B4B] to-[#312E81] px-10 py-14 text-white shadow-xl isolate`,children:[(0,B.jsx)(`div`,{className:`absolute top-0 right-0 -m-32 opacity-30 pointer-events-none mix-blend-screen scale-150 transform-gpu`,children:(0,B.jsx)(`div`,{className:`w-[500px] h-[500px] rounded-full bg-gradient-to-tl from-fuchsia-500/40 via-purple-500/30 to-indigo-500/20 blur-[80px]`})}),(0,B.jsx)(`div`,{className:`absolute bottom-0 left-0 -m-32 opacity-20 pointer-events-none mix-blend-screen transform-gpu`,children:(0,B.jsx)(`div`,{className:`w-[400px] h-[400px] rounded-full bg-gradient-to-tr from-blue-500/40 to-cyan-500/20 blur-[80px]`})}),(0,B.jsxs)(`div`,{className:`relative z-10 flex flex-col gap-3`,children:[(0,B.jsx)(`h1`,{className:`text-[38px] font-extrabold tracking-[-0.02em] leading-tight drop-shadow-sm text-transparent bg-clip-text bg-gradient-to-r from-white via-white to-white/70`,children:n(`marketplaceMcpPageTitle`)}),(0,B.jsx)(`p`,{className:`text-[17px] font-medium text-purple-100/70 max-w-2xl leading-relaxed tracking-wide`,children:n(`marketplaceMcpPageDescription`)})]})]}),(0,B.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4 mt-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-gray-100/60 backdrop-blur-sm rounded-2xl w-fit border border-gray-200/50 shadow-inner`,children:re.map(n=>{let i=e===n.id,a=n.icon;return(0,B.jsxs)(`button`,{onClick:()=>t(n.id),className:r(`relative flex items-center gap-2 px-5 py-2.5 rounded-xl font-semibold text-[14px] transition-all duration-300`,i?`text-gray-900 bg-white shadow-[0_2px_10px_rgb(0,0,0,0.06)]`:`text-gray-500 hover:text-gray-700 hover:bg-gray-200/40`),children:[(0,B.jsx)(a,{className:r(`w-4 h-4`,i?`text-primary`:`text-gray-400`)}),n.label,n.id===`installed`&&typeof n.count==`number`&&(0,B.jsx)(`span`,{className:r(`ml-1 flex items-center justify-center h-5 px-1.5 min-w-5 rounded-full text-[11px] font-bold transition-colors`,i?`bg-primary/10 text-primary`:`bg-gray-200 text-gray-500`),children:n.count})]},n.id)})}),(0,B.jsx)(`div`,{className:`flex-1 w-full md:max-w-md`,children:(0,B.jsx)(V,{scope:e===`catalog`?`all`:`installed`,searchText:i,isRefreshing:!1,searchPlaceholder:n(`marketplaceMcpSearchPlaceholder`),sort:l,onSearchTextChange:a,onSortChange:u})})]}),(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col mt-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-1`,children:(0,B.jsxs)(`h3`,{className:`text-[18px] font-bold tracking-tight text-gray-900 flex items-center gap-2`,children:[n(e===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`),(0,B.jsx)(`span`,{className:`flex items-center justify-center h-6 px-2 rounded-lg bg-gray-100 text-[12px] font-semibold text-gray-500`,children:e===`catalog`?w.data?.total??0:T.data?.total??0})]})}),(0,B.jsxs)(`div`,{ref:E,className:`min-h-0 flex-1 overflow-y-auto pr-3 pb-8 -mx-1 px-1 custom-scrollbar`,"aria-busy":w.isLoading||w.isFetchingNextPage,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-1 gap-[22px] md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 items-stretch`,children:[e===`catalog`&&w.isLoading&&(0,B.jsx)(H,{count:$}),e===`catalog`&&!w.isLoading&&(w.data?.items??[]).map(e=>{let t=fe(e,j);return(0,B.jsx)(Q,{item:e,record:t,localeFallbacks:C,onOpen:()=>void N(e,t),onInstall:()=>m(e),onToggle:t?()=>void F(t.enabled===!1?`enable`:`disable`,t):void 0,onDoctor:t?()=>{g(t.id??null),v(null),A.mutateAsync(t.id??``)}:void 0,onRemove:t?()=>void F(`remove`,t):void 0},e.id)}),e===`installed`&&M.map(e=>(0,B.jsx)(Q,{record:e,localeFallbacks:C,onOpen:()=>void N(void 0,e),onToggle:()=>void F(e.enabled===!1?`enable`:`disable`,e),onDoctor:()=>{g(e.id??null),v(null),A.mutateAsync(e.id??``)},onRemove:()=>void F(`remove`,e)},e.id??e.spec))]}),e===`catalog`&&w.isError&&(0,B.jsx)(I,{tone:`danger`,title:n(`marketplaceMcpSectionCatalog`),description:w.error.message}),e===`installed`&&T.isError&&(0,B.jsx)(I,{tone:`danger`,title:n(`marketplaceMcpSectionInstalled`),description:T.error.message}),e===`catalog`&&!w.isLoading&&!w.isError&&(w.data?.items?.length??0)===0&&(0,B.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,B.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoMcp`)})}),e===`installed`&&!T.isError&&M.length===0&&(0,B.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,B.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:n(`marketplaceNoInstalledMcp`)})}),e===`catalog`&&!w.isError&&(0,B.jsx)(U,{hasMore:!!w.hasNextPage,loading:w.isFetchingNextPage,sentinelRef:D})]})]})]}),(0,B.jsx)(he,{item:f,open:!!f,pending:O.isPending,onOpenChange:e=>!e&&m(null),onSubmit:P}),(0,B.jsx)(_e,{open:!!h,targetName:h,result:_,pending:A.isPending,onOpenChange:e=>!e&&g(null)}),(0,B.jsx)(S,{})]})}export{V as a,z as c,K as i,R as l,J as n,U as o,W as r,H as s,Se as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./mcp-marketplace-page-B1SZNY5m.js";export{e as McpMarketplacePage};
@@ -0,0 +1 @@
1
+ function e(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var t=e=>n=>{try{let r=e(n);return r instanceof Promise?r:{then(e){return t(e)(r)},catch(e){return this}}}catch(e){return{then(e){return this},catch(n){return t(n)(e)}}}},n=(n,r)=>(i,a,o)=>{let s={storage:e(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...r},c=!1,l=0,u=new Set,d=new Set,f=s.storage;if(!f)return n((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),i(...e)},a,o);let p=()=>{let e=s.partialize({...a()});return f.setItem(s.name,{state:e,version:s.version})},m=o.setState;o.setState=(e,t)=>(m(e,t),p());let h=n((...e)=>(i(...e),p()),a,o);o.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++l;c=!1,u.forEach(e=>e(a()??h));let n=s.onRehydrateStorage?.call(s,a()??h)||void 0;return t(f.getItem.bind(f))(s.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==s.version){if(s.migrate){let t=s.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==l)return;let[n,r]=t;if(g=s.merge(r,a()??h),i(g,!0),n)return p()}).then(()=>{e===l&&(n?.(g,void 0),g=a(),c=!0,d.forEach(e=>e(g)))}).catch(t=>{e===l&&n?.(void 0,t)})};return o.persist={setOptions:e=>{s={...s,...e},e.storage&&(f=e.storage)},clearStorage:()=>{f?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>_(),hasHydrated:()=>c,onHydrate:e=>(u.add(e),()=>{u.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},s.skipHydration||_(),g||h};export{n,e as t};
@@ -0,0 +1 @@
1
+ import{h as e,p as t,r as n,v as r}from"./react-VNqT5Zp7.js";import{Bt as i,Lt as a,Mt as o,Rt as s,Vt as c,zt as l}from"./api-BP_8IaxB.js";import{t as u}from"./provider-scoped-model-input-DsFRuWJH.js";import{s as d}from"./doc-browser-context-MTw4EvKd.js";import{D as f,Dt as p,_t as m,lt as h,p as g,xt as _}from"./index-D9BAE_L_.js";import{l as v,m as y,r as b,t as x,u as S}from"./use-config-CjRV2hwL.js";import{t as C}from"./config-hints-BkYBc7z0.js";var w=r(e(),1),T=t(),E=`provider/model`;function D(e){let{initialModel:t,initialWorkspace:r,isPending:a,modelHelpText:o,modelLabel:s,modelPlaceholder:f,onSubmit:g,providerCatalog:v,workspaceLabel:y,workspacePlaceholder:b}=e,[x,S]=(0,w.useState)(t),[C,E]=(0,w.useState)(r);return(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g({model:x,workspace:C})},className:`space-y-8`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(h,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:n(`defaultModel`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(l,{htmlFor:`model`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:s}),(0,T.jsx)(u,{id:`model`,value:x,onChange:S,providerCatalog:v,modelPlaceholder:f}),(0,T.jsx)(`p`,{className:`text-xs text-gray-400`,children:o}),(0,T.jsxs)(`a`,{href:`${d}/guide/model-selection`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,T.jsx)(p,{className:`h-3.5 w-3.5`}),n(`channelsGuideTitle`)]})]})]}),(0,T.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-white p-8 shadow-card`,children:[(0,T.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,T.jsx)(_,{className:`h-5 w-5`})}),(0,T.jsx)(`h3`,{className:`text-lg font-bold text-gray-900`,children:n(`workspace`)})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(l,{htmlFor:`workspace`,className:`text-xs font-semibold uppercase tracking-wider text-gray-500`,children:y}),(0,T.jsx)(i,{id:`workspace`,value:C,onChange:e=>E(e.target.value),placeholder:b,className:`rounded-xl`})]})]})]}),(0,T.jsx)(`div`,{className:`flex justify-end pt-4`,children:(0,T.jsx)(c,{type:`submit`,disabled:a,size:`lg`,children:a?(0,T.jsx)(m,{className:`h-5 w-5 animate-spin`}):n(`saveChanges`)})})]})}function O(){let{data:e,isLoading:t}=x(),{data:r}=S(),{data:i}=v(),{data:c}=b(),l=y(),u=c?.uiHints,d=C(`agents.defaults.model`,u),p=C(`agents.defaults.workspace`,u),m=(0,w.useMemo)(()=>g({providersView:r,templatesView:i,config:e,onlyConfigured:!0}),[e,r,i]),h=n(`modelIdentifierHelp`)||d?.help||``,_=(e?.agents?.defaults?.model||``).trim(),O=e?.agents?.defaults?.workspace||``;return t?(0,T.jsxs)(`div`,{className:`max-w-2xl space-y-6`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(f,{className:`h-8 w-32`}),(0,T.jsx)(f,{className:`h-4 w-48`})]}),(0,T.jsxs)(o,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsxs)(`div`,{className:`mb-6 flex items-center gap-4`,children:[(0,T.jsx)(f,{className:`h-12 w-12 rounded-xl`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(f,{className:`h-5 w-24`}),(0,T.jsx)(f,{className:`h-3 w-32`})]})]}),(0,T.jsx)(f,{className:`mb-2 h-4 w-20`}),(0,T.jsx)(f,{className:`h-10 w-full rounded-xl`})]}),(0,T.jsxs)(o,{className:`rounded-2xl border-gray-200 p-6`,children:[(0,T.jsx)(f,{className:`mb-2 h-5 w-24`}),(0,T.jsx)(f,{className:`h-10 w-full rounded-xl`})]})]}):(0,T.jsxs)(s,{children:[(0,T.jsx)(a,{title:n(`modelPageTitle`),description:n(`modelPageDescription`)}),(0,T.jsx)(D,{initialModel:_,initialWorkspace:O,isPending:l.isPending,modelHelpText:h,modelLabel:d?.label??`Model Name`,modelPlaceholder:d?.placeholder??E,onSubmit:({model:e,workspace:t})=>l.mutate({model:e,workspace:t}),providerCatalog:m,workspaceLabel:p?.label??`Default Path`,workspacePlaceholder:p?.placeholder??`/path/to/workspace`},`${_}::${O}`)]})}export{O as ModelConfigPage};
@@ -0,0 +1 @@
1
+ import{c as e}from"./dist-PVA_xL1D.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{h as e,p as t,r as n,u as r,v as i}from"./react-VNqT5Zp7.js";import{Bt as a}from"./api-BP_8IaxB.js";import{c as o}from"./dist-PVA_xL1D.js";import{a as s,i as c,n as l,r as u,t as d,w as f}from"./select-hoj8dK4K.js";import{H as p,K as m,U as h,W as g,h as _,m as v,y}from"./index-D9BAE_L_.js";var b=o(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),x=i(e(),1),S=t(),C=m(`15rem`);function w(e){let t=new Set;for(let n of e){let e=n.trim();e.length>0&&t.add(e)}return[...t]}function T({id:e,value:t,onChange:n,options:i,disabled:o=!1,placeholder:s,className:c,inputClassName:l,emptyText:u,createText:d,toggleLabel:m,maxItems:_=1/0,onEnter:v}){let[y,T]=(0,x.useState)(!1);(0,x.useEffect)(()=>{o&&y&&T(!1)},[o,y]);let E=(0,x.useMemo)(()=>w(i),[i]),D=t.trim().toLowerCase(),O=(0,x.useMemo)(()=>{let e=E.map((e,t)=>({option:e,index:t}));D.length>0&&e.sort((e,t)=>{let n=e.option.toLowerCase(),r=t.option.toLowerCase(),i=n===D?0:n.startsWith(D)?1:n.includes(D)?2:3,a=r===D?0:r.startsWith(D)?1:r.includes(D)?2:3;return i===a?e.index-t.index:i-a});let t=e.map(e=>e.option);return Number.isFinite(_)?t.slice(0,Math.max(1,_)):t},[E,D,_]),k=t.trim().length>0&&E.some(e=>e===t.trim()),A=()=>T(!1);return(0,S.jsxs)(p,{open:y&&!o,onOpenChange:e=>T(!o&&e),children:[(0,S.jsx)(h,{asChild:!0,children:(0,S.jsxs)(`div`,{className:r(`relative`,c),children:[(0,S.jsx)(a,{id:e,value:t,disabled:o,onFocus:()=>{o||T(!0)},onChange:e=>{n(e.target.value),!y&&!o&&T(!0)},onKeyDown:e=>{e.key===`Enter`&&(v&&(e.preventDefault(),v()),A())},placeholder:s,className:r(`pr-10`,l)}),(0,S.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e=>!e),disabled:o,className:r(`absolute inset-y-0 right-0 inline-flex w-10 items-center justify-center`,o?`cursor-not-allowed text-gray-300`:`text-gray-400 hover:text-gray-600`),"aria-label":m,children:(0,S.jsx)(b,{className:`h-4 w-4`})})]})}),(0,S.jsx)(g,{align:`start`,className:`flex w-[var(--radix-popover-trigger-width)] min-w-[12rem] flex-col overflow-hidden rounded-xl border border-gray-200 p-0 shadow-lg`,onOpenAutoFocus:e=>e.preventDefault(),style:{maxHeight:C},children:(0,S.jsxs)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto py-1`,children:[!k&&t.trim().length>0&&(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(t.trim()),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:`h-4 w-4 text-transparent`}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:d.replace(`{value}`,t.trim())})]}),O.map(e=>(0,S.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n(e),A()},className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm hover:bg-gray-50`,children:[(0,S.jsx)(f,{className:r(`h-4 w-4`,e===t.trim()?`text-primary`:`text-transparent`)}),(0,S.jsx)(`span`,{className:`truncate text-gray-700`,children:e})]},e)),O.length===0&&t.trim().length===0&&(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-gray-500`,children:u})]})})]})}var E=`provider/model`;function D(e){let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function O({id:e,value:t,onChange:r,providerCatalog:i,disabled:o=!1,providerPlaceholder:f,modelPlaceholder:p,className:m}){let[h,g]=(0,x.useState)(``),[b,C]=(0,x.useState)(``),w=i.length>0,O=p??E,k=(0,x.useMemo)(()=>new Map(i.map(e=>[e.name,e])),[i]),A=k.get(h),j=(0,x.useMemo)(()=>A?.aliases??[],[A]),M=(0,x.useMemo)(()=>D(A?.models??[]),[A]);return(0,x.useEffect)(()=>{let e=t.trim();if(!w){g(``),C(e);return}if(!e){C(``),g(e=>k.has(e)?e:``);return}let n=_(e,i)??``,r=k.get(n)?.aliases??[];g(n),C(n?y(e,r):e)},[w,i,k,t]),w?(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,S.jsx)(`div`,{className:`sm:w-[38%] sm:min-w-[170px]`,children:(0,S.jsxs)(d,{value:h,onValueChange:e=>{let t=D(k.get(e)?.models??[])[0]??``;if(g(e),C(t),!t){r(``);return}r(v(k.get(e)?.prefix??e,t))},disabled:o,children:[(0,S.jsx)(c,{className:`h-10 w-full rounded-xl`,children:(0,S.jsx)(s,{placeholder:f??n(`providersSelectPlaceholder`)})}),(0,S.jsx)(l,{children:i.map(e=>(0,S.jsx)(u,{value:e.name,children:e.displayName},e.name))})]})}),(0,S.jsx)(`span`,{className:`hidden h-10 items-center justify-center leading-none text-lg font-semibold text-gray-300 sm:inline-flex`,children:`/`}),(0,S.jsx)(T,{id:e,value:b,onChange:e=>{if(!A){let t=e.trim();C(t),r(t);return}let t=y(e,j);C(t),r(t?v(A.prefix,t):``)},options:M,disabled:o||!h,placeholder:O,className:`sm:flex-1`,inputClassName:`h-10 rounded-xl`,emptyText:n(`modelPickerNoOptions`),createText:n(`modelPickerUseCustom`),toggleLabel:n(`modelPickerToggleOptions`)},h)]}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]}):(0,S.jsxs)(`div`,{className:m,children:[(0,S.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 px-4 py-3`,children:[(0,S.jsx)(`p`,{className:`text-sm font-semibold text-amber-950`,children:n(`providersEmptyTitle`)}),(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-amber-900`,children:n(`providersEmptyDescription`)})]}),(0,S.jsx)(a,{id:e,value:t,disabled:o,onChange:e=>r(e.target.value),placeholder:O,className:`mt-3 h-10 rounded-xl`}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500`,children:n(`modelInputCustomHint`)})]})}export{O as t};
@@ -0,0 +1 @@
1
+ import{a as e,h as t,p as n,r,u as i,v as a}from"./react-VNqT5Zp7.js";import{Bt as o,Gt as s,Lt as c,Rt as l,Vt as u,_t as d,in as f,zt as p}from"./api-BP_8IaxB.js";import{c as m}from"./dist-PVA_xL1D.js";import{C as h,a as g,i as _,n as v,r as y,t as b}from"./select-hoj8dK4K.js";import{t as x}from"./confirm-dialog-DsivFJ4r.js";import{t as S}from"./search-BEti5beA.js";import{t as C}from"./ellipsis-y6vDtq4M.js";import{t as w}from"./plus-BbZqquJe.js";import{t as T}from"./x-D9PXs_xP.js";import{G as E,H as D,R as O,St as k,W as A,_ as j,at as M,d as N,f as P,g as F,q as I,st as L,v as R,vt as z}from"./index-D9BAE_L_.js";import{a as ee,c as B,d as V,f as te,h as ne,i as re,l as ie,r as ae,s as H,u as oe}from"./use-config-CjRV2hwL.js";import{t as U}from"./config-hints-BkYBc7z0.js";import{a as W,c as G,i as K,n as se,o as q,r as ce,s as J}from"./config-split-page-CRhlZ_pH.js";var le=m(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),ue=m(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),de=m(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Y=a(t(),1),X=n();function fe({isSet:e,className:t,value:n,onChange:r,placeholder:a,...s}){let[c,l]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof n==`string`&&n.length>0;return(0,X.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,X.jsx)(`div`,{onClick:()=>f(!0),className:i(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,X.jsx)(o,{type:c?`text`:`password`,className:i(`pr-12`,t),value:n,onChange:r,onBlur:()=>{p||f(!1)},placeholder:a,autoFocus:d,...s}),(0,X.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,X.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,X.jsx)(ue,{className:`h-4 w-4`}):(0,X.jsx)(k,{className:`h-4 w-4`})})})]})}function pe({value:e,onChange:t,className:n}){let a=e?Object.entries(e):[],s=(e,n,r)=>{let i=[...a];i[e]=[n,r],t(Object.fromEntries(i))},c=()=>{t({...e,"":``})},l=e=>{let n=a.filter((t,n)=>n!==e);t(Object.fromEntries(n))};return(0,X.jsxs)(`div`,{className:i(`space-y-2`,n),children:[a.map(([e,t],n)=>(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(o,{type:`text`,value:e,onChange:e=>s(n,e.target.value,t),placeholder:r(`headerName`),className:`flex-1`}),(0,X.jsx)(o,{type:`text`,value:t,onChange:t=>s(n,e,t.target.value),placeholder:r(`headerValue`),className:`flex-1`}),(0,X.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(n),children:(0,X.jsx)(L,{className:`h-4 w-4 text-red-500`})})]},n)),(0,X.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,X.jsx)(w,{className:`h-4 w-4 mr-2`}),r(`add`)]})]})}function me(e){let{value:t,onChange:n,options:r}=e;return(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-primary-foreground shadow-sm`:`border-border bg-card text-muted-foreground hover:border-primary/40 hover:bg-accent/70 hover:text-accent-foreground`}`,children:e.label},e.value)})})}function he(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,X.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(de,{className:`h-3.5 w-3.5`}),r(`providerAdvancedSettings`)]}),(0,X.jsx)(h,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,X.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,X.jsx)(me,{value:o,onChange:e=>s(e),options:l}):(0,X.jsxs)(b,{value:o,onValueChange:e=>s(e),children:[(0,X.jsx)(_,{className:`rounded-xl`,children:(0,X.jsx)(g,{})}),(0,X.jsx)(v,{children:l.map(e=>(0,X.jsx)(y,{value:e.value,children:e.label},e.value))})]})]}):null,(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{className:`text-sm font-medium text-foreground`,children:u}),(0,X.jsx)(pe,{value:d,onChange:f}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerExtraHeadersHelpShort`)})]})]}):null]})}function ge(e){let{providerAuth:t,providerAuthNote:n,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:s,resolvedAuthMethodId:c,onAuthMethodChange:l,onStartProviderAuth:d,onImportProviderAuthFromCli:f,startPending:m,importPending:h,authSessionId:x,authStatusMessage:S}=e;return t?.kind===`device_code`?(0,X.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,X.jsx)(p,{className:`text-sm font-medium text-foreground`,children:t.displayName||r(`providerAuthSectionTitle`)}),n?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}):null,a>1?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{className:`text-xs font-medium text-foreground`,children:r(`providerAuthMethodLabel`)}),s?(0,X.jsx)(me,{value:c,onChange:l,options:i}):(0,X.jsxs)(b,{value:c,onValueChange:l,children:[(0,X.jsx)(_,{className:`h-8 rounded-lg`,children:(0,X.jsx)(g,{placeholder:r(`providerAuthMethodPlaceholder`)})}),(0,X.jsx)(v,{children:i.map(e=>(0,X.jsx)(y,{value:e.value,children:e.label},e.value))})]}),o?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o}):null]}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:d,disabled:m||!!x,children:r(m?`providerAuthStarting`:x?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),t.supportsCliImport?(0,X.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:f,disabled:h,children:r(h?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,x?(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[r(`providerAuthSessionLabel`),`: `,x.slice(0,8),`…`]}):null]}),S?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:S}):null]}):null}var _e={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function Z(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function ve(e,t){let n=Z(e),r=Z(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Q(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function ye(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function $(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=ye(n,t))}return n.trim()}function be(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function xe(e,t){return Q(t)}function Se(e,t){return Q(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ce(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e={},a=j(i.thinking?.supported);if(a.length>0){let t=R(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function we(e,t,n){return{...F(e,n),...F(t,n)}}function Te(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!be([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Ee(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!ve(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!be(e.models,e.currentEditableModels)||!Te(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function De(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=Z(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),ve(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),be(e.models,e.currentEditableModels)||(t.models=Se(e.models,e.providerName??``)),Te(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ce(e.modelConfig,e.models)),t}function Oe(e){let t=$(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={apiBase:e.apiBase.trim(),extraHeaders:Z(e.extraHeaders),model:t||null};return e.apiKey.trim().length>0&&(n.apiKey=e.apiKey.trim()),e.supportsWireApi&&(n.wireApi=e.wireApi),n}function ke(e){return r(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Ae(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function je(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Me(e,t,n){let r=$(t,n);return r?r.includes(`/`)?{models:e,draft:t,errorKey:`providerModelInvalidProviderPrefix`}:e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ne(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function Pe(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):P.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Fe(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ie(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function Le(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Ae({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:je({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Re(e,t){let n=!!e?.supportsWireApi||t,i=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:r(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:je({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:i.length}),supportsWireApi:n,wireApiSelectOptions:i}}function ze(e){let{providerName:t,providersView:n,templatesView:i,schema:a,language:o}=e,s=t?n?.providers[t]:null,c=i?.providerTemplates.find(e=>e.providerType===s?.providerType),l=s??_e,u=a?.uiHints,d=!!s?.isCustom,f=t?U(`providers.${t}.apiKey`,u):void 0,p=t?U(`providers.${t}.apiBase`,u):void 0,m=t?U(`providers.${t}.extraHeaders`,u):void 0,h=t?U(`providers.${t}.wireApi`,u):void 0,g=c?.displayName||s?.displayName||t||``,_=(l.displayName||``).trim()||g,v=l.enabled!==!1,y=Q([c?.modelPrefix||c?.providerType||``,t||``]),b=c?.defaultApiBase||``,x=l.apiBase||b,S=Z(l.extraHeaders||null),C=l.wireApi||c?.defaultWireApi||`auto`,w=xe(Q((c?.defaultModels??[]).map(e=>$(e,y))),Q((l.models??[]).map(e=>$(e,y)))),T=Ce(we(c?.modelConfig,l.modelConfig,y),w),E=c?.apiBaseHelp?.[o]||c?.apiBaseHelp?.en||p?.help||r(`providerApiBaseHelp`),D=Le({providerName:t,providerSpec:c,language:o}),O=Re(c,d);return{apiBaseHelpText:E,apiBaseHint:p,apiKeyHint:f,currentApiBase:x,currentEditableModels:w,currentEnabled:v,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:g,effectiveDisplayName:_,extraHeadersHint:m,...D,providerConfig:s,providerModelAliases:y,resolvedProviderConfig:l,wireApiHint:h,...O}}function Be(e){let{models:t,modelConfig:n,modelDraft:i,showModelInput:a,onModelDraftChange:s,onShowModelInputChange:c,onAddModel:l,onRemoveModel:f,onToggleModelThinkingLevel:m,onSetModelThinkingDefault:h,onSetModelVision:x,thinkingLevels:S,formatThinkingLevelLabel:C}=e;return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(p,{className:`text-sm font-medium text-foreground`,children:r(`providerModelsTitle`)}),a?null:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,X.jsx)(w,{className:`h-3 w-3`}),r(`providerAddModel`)]})]}),a?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(o,{value:i,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),s(``))},placeholder:r(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,X.jsx)(u,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:r(`add`)}),(0,X.jsx)(u,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),s(``)},children:(0,X.jsx)(T,{className:`h-4 w-4`})})]}):null,t.length===0?(0,X.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border bg-muted/60 px-4 py-6 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`providerModelsEmptyShort`)}),a?null:(0,X.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:r(`providerAddFirstModel`)})]}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{let t=n[e],i=t?.thinking,a=i?.supported??[],o=i?.default??null,s=t?.vision===!0;return(0,X.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-card px-3 py-1.5`,children:[(0,X.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,X.jsxs)(D,{children:[(0,X.jsx)(E,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-accent hover:text-accent-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`providerModelThinkingTitle`),title:r(`providerModelThinkingTitle`),children:(0,X.jsx)(de,{className:`h-3 w-3`})})}),(0,X.jsxs)(A,{className:`w-80 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/60 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelVisionTitle`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelVisionHint`)})]}),(0,X.jsx)(d,{checked:s,onCheckedChange:t=>x(e,t)})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:r(`providerModelThinkingTitle`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingHint`)})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:S.map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${a.includes(t)?`border-primary bg-primary text-white`:`border-border bg-card text-muted-foreground hover:border-primary/40 hover:bg-accent/70 hover:text-accent-foreground`}`,children:C(t)},t))}),(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(p,{className:`text-xs font-medium text-foreground`,children:r(`providerModelThinkingDefault`)}),(0,X.jsxs)(b,{value:o??`__none__`,onValueChange:t=>h(e,t===`__none__`?null:t),disabled:a.length===0,children:[(0,X.jsx)(_,{className:`h-8 rounded-lg text-xs`,children:(0,X.jsx)(g,{})}),(0,X.jsxs)(v,{children:[(0,X.jsx)(y,{value:`__none__`,children:r(`providerModelThinkingDefaultNone`)}),a.map(e=>(0,X.jsx)(y,{value:e,children:C(e)},e))]})]}),a.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-accent hover:text-accent-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":r(`remove`),children:(0,X.jsx)(T,{className:`h-3 w-3`})})]},e)})})]})}function Ve({apiKeySet:e,className:t,enabled:n}){return n?(0,X.jsx)(M,{status:e?`ready`:`setup`,label:r(e?`statusReady`:`statusSetup`),className:t}):(0,X.jsx)(M,{status:`inactive`,label:r(`disabled`),className:t})}function He(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:i}=e,a=f(),o=V(),c=B(),l=H(),[u,d]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},[]),y=(0,Y.useCallback)((e,n)=>{v(),_.current=window.setTimeout(()=>{(async()=>{if(t)try{let i=await c.mutateAsync({provider:t,data:{sessionId:e}});if(i.status===`pending`){g(r(`providerAuthWaitingBrowser`)),y(e,i.nextPollMs??n);return}if(i.status===`authorized`){m(null),v(),g(r(`providerAuthCompleted`)),s.success(r(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}m(null),v(),g(i.message||`Authorization ${i.status}.`),s.error(i.message||`Authorization ${i.status}.`)}catch(e){m(null),v();let t=e instanceof Error?e.message:String(e);g(t),s.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[v,c,t,a]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),g(``);let e=await o.mutateAsync({provider:t,data:i?{methodId:i}:{}});if(!e.sessionId||!e.verificationUri)throw Error(r(`providerAuthStartFailed`));m(e.sessionId),g(`${r(`providerAuthOpenPrompt`)}${e.userCode}${r(`providerAuthOpenPromptSuffix`)}`),await I.openExternalUrl(e.verificationUri),y(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);m(null),v(),g(t),s.error(`${r(`providerAuthStartFailed`)}: ${t}`)}},[v,n?.kind,t,i,y,o]),x=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),v(),m(null);let e=await l.mutateAsync({provider:t});g(`${r(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),s.success(r(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);g(t),s.error(`${r(`providerAuthImportFailed`)}: ${t}`)}},[v,l,n?.kind,t,a]);return(0,Y.useEffect)(()=>{v()},[v,t]),(0,Y.useEffect)(()=>()=>v(),[v]),{authSessionId:u===t?p:null,authStatusMessage:u===t?h:``,importAuthFromCli:x,importPending:l.isPending,startAuth:b,startPending:o.isPending}}function Ue({providerName:t,onProviderDeleted:n}){let{data:i}=oe(),{data:a}=ie(),{data:o}=ae(),c=ne(),l=ee(),u=te(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(`auto`),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)({}),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(``),N=e(),P=(0,Y.useMemo)(()=>ze({providerName:t,providersView:i,templatesView:a,schema:o,language:N}),[N,t,i,o,a]),{currentApiBase:F,currentEditableModels:I,currentHeaders:L,currentModelConfig:R,currentWireApi:z,defaultApiBase:B,effectiveDisplayName:V,providerAuth:re,providerAuthMethods:H,providerConfig:U,providerModelAliases:W,resolvedProviderConfig:G,preferredAuthMethodId:K,supportsWireApi:q}=P,ce=T.trim()||V||t||r(`providersSelectPlaceholder`),J=(0,Y.useMemo)(()=>{if(!H.length)return``;let e=j.trim();return e&&H.some(t=>t.id===e)?e:K||H[0]?.id||``},[j,K,H]),{authSessionId:le,authStatusMessage:ue,importAuthFromCli:de,importPending:fe,startAuth:pe,startPending:me}=He({providerName:t,providerAuth:re,resolvedAuthMethodId:J});(0,Y.useEffect)(()=>{if(!t){f(``),m(``),g(null),v(`auto`),b([]),S({}),w(``),E(``),M(``);return}f(``),m(F),g(G.extraHeaders||null),v(z),b(I),S(R),w(``),E(V),M(K)},[t,F,G.extraHeaders,z,I,R,V,K]),(0,Y.useEffect)(()=>S(e=>Ce(e,y)),[y]);let he=(0,Y.useMemo)(()=>Ee({providerName:t,apiKey:d,apiBase:p,currentApiBase:F,extraHeaders:h,currentHeaders:L,supportsWireApi:q,wireApi:_,currentWireApi:z,models:y,currentEditableModels:I,modelConfig:x,currentModelConfig:R,providerDisplayName:T,effectiveDisplayName:V}),[t,d,p,F,h,L,q,_,z,y,I,x,R,T,V]);return!t||!U?(0,X.jsx)(se,{children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:r(`providersSelectTitle`)}),(0,X.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:r(`providersSelectDescription`)})]})}):(0,X.jsx)(We,{context:P,language:N,providerTitle:ce,providerDisplayName:T,apiKey:d,apiBase:p,extraHeaders:h,wireApi:_,models:y,modelConfig:x,modelDraft:C,showAdvanced:D,showModelInput:k,resolvedAuthMethodId:J,authSessionId:le,authStatusMessage:ue,hasChanges:he,isDeletePending:l.isPending,isUpdatePending:c.isPending,isTestPending:u.isPending,startPending:me,importPending:fe,onProviderDisplayNameChange:E,onApiKeyChange:f,onApiBaseChange:m,onAuthMethodChange:M,onStartProviderAuth:pe,onImportProviderAuthFromCli:de,onModelDraftChange:w,onShowModelInputChange:A,onAddModel:()=>{let e=Me(y,C,W);if(e.errorKey){s.error(r(`providerModelInvalidProviderPrefix`));return}b(e.models),w(e.draft)},onRemoveModel:e=>{let t=Ne(y,x,e);b(t.models),S(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{S(n=>Pe(n,e,t))},onSetModelThinkingDefault:(e,t)=>{S(n=>Fe(n,e,t))},onSetModelVision:(e,t)=>{S(n=>Ie(n,e,t))},onShowAdvancedChange:O,onWireApiChange:v,onExtraHeadersChange:g,onDeleteProvider:async()=>{if(t&&window.confirm(r(`providerDeleteConfirm`)))try{await l.mutateAsync({provider:t}),n?.(t)}catch{}},onSubmit:e=>{e.preventDefault(),t&&c.mutate({provider:t,data:De({providerName:t,apiKey:d,apiBase:p,currentApiBase:F,defaultApiBase:B,extraHeaders:h,currentHeaders:L,supportsWireApi:q,wireApi:_,currentWireApi:z,models:y,currentEditableModels:I,modelConfig:x,currentModelConfig:R,providerDisplayName:T,effectiveDisplayName:V})})},onTestConnection:async()=>{if(t)try{let e=await u.mutateAsync({provider:t,data:Oe({apiKey:d,apiBase:p,extraHeaders:h,supportsWireApi:q,wireApi:_,models:y,providerModelAliases:W})});if(e.success){s.success(`${r(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let n=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&n.push(`model=${e.model}`),s.error(`${r(`providerTestConnectionFailed`)}: ${e.message} | ${n.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);s.error(`${r(`providerTestConnectionFailed`)}: ${t}`)}}})}function We(e){let{context:t,language:n,providerTitle:i,providerDisplayName:a,apiKey:s,apiBase:c,extraHeaders:l,wireApi:d,models:f,modelConfig:m,modelDraft:h,showAdvanced:g,showModelInput:_,resolvedAuthMethodId:v,authSessionId:y,authStatusMessage:b,hasChanges:x,isDeletePending:S,isUpdatePending:C,isTestPending:w,startPending:T,importPending:E,onProviderDisplayNameChange:D,onApiKeyChange:O,onApiBaseChange:k,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,onModelDraftChange:N,onShowModelInputChange:F,onAddModel:I,onRemoveModel:R,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:ee,onSetModelVision:B,onShowAdvancedChange:V,onWireApiChange:te,onExtraHeadersChange:ne,onDeleteProvider:re,onSubmit:ie,onTestConnection:ae}=e,H=t.providerAuthMethods.find(e=>e.id===v);return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{className:`px-6 py-4`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:i}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:re,disabled:S,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:r(`providerDelete`),children:(0,X.jsx)(L,{className:`h-4 w-4`})}),(0,X.jsx)(Ve,{enabled:t.currentEnabled,apiKeySet:t.resolvedProviderConfig.apiKeySet})]})]})}),(0,X.jsxs)(`form`,{onSubmit:ie,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(q,{className:`space-y-5 px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:r(`providerDisplayName`)}),(0,X.jsx)(o,{id:`providerDisplayName`,type:`text`,value:a,onChange:e=>D(e.target.value),placeholder:t.defaultDisplayName||r(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`providerDisplayNameHelpShort`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:t.apiKeyHint?.label??r(`apiKey`)}),(0,X.jsx)(fe,{id:`apiKey`,value:s,isSet:t.resolvedProviderConfig.apiKeySet,onChange:e=>O(e.target.value),placeholder:t.apiKeyHint?.placeholder??r(`enterApiKey`),className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`leaveBlankToKeepUnchanged`)})]}),(0,X.jsx)(ge,{providerAuth:t.providerAuth,providerAuthNote:t.providerAuth?.note?.[n]||t.providerAuth?.note?.en||t.providerAuth?.displayName||``,providerAuthMethodOptions:t.providerAuthMethodOptions,providerAuthMethodsCount:t.providerAuthMethods.length,selectedAuthMethodHint:H?.hint?.[n]||H?.hint?.en||``,shouldUseAuthMethodPills:t.shouldUseAuthMethodPills,resolvedAuthMethodId:v,onAuthMethodChange:A,onStartProviderAuth:j,onImportProviderAuthFromCli:M,startPending:T,importPending:E,authSessionId:y,authStatusMessage:b}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(p,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:t.apiBaseHint?.label??r(`apiBase`)}),(0,X.jsx)(o,{id:`apiBase`,type:`text`,value:c,onChange:e=>k(e.target.value),placeholder:t.defaultApiBase||t.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.apiBaseHelpText})]}),(0,X.jsx)(Be,{models:f,modelConfig:m,modelDraft:h,showModelInput:_,onModelDraftChange:N,onShowModelInputChange:F,onAddModel:I,onRemoveModel:R,onToggleModelThinkingLevel:z,onSetModelThinkingDefault:ee,onSetModelVision:B,thinkingLevels:P,formatThinkingLevelLabel:ke}),(0,X.jsx)(he,{showAdvanced:g,onShowAdvancedChange:V,supportsWireApi:t.supportsWireApi,wireApiLabel:t.wireApiHint?.label??r(`wireApi`),wireApi:d,onWireApiChange:te,shouldUseWireApiPills:t.shouldUseWireApiPills,wireApiSelectOptions:t.wireApiSelectOptions,extraHeadersLabel:t.extraHeadersHint?.label??r(`extraHeaders`),extraHeaders:l,onExtraHeadersChange:ne})]}),(0,X.jsxs)(J,{className:`flex items-center justify-between px-6 py-4`,children:[(0,X.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:ae,disabled:w,children:[(0,X.jsx)(le,{className:`mr-1.5 h-4 w-4`}),r(w?`providerTestingConnection`:`providerTestConnection`)]}),(0,X.jsx)(u,{type:`submit`,disabled:C||!x,children:r(C?`saving`:x?`save`:`unchanged`)})]})]})]})}function Ge(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function Ke(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function qe(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function Je(){let{isMobile:e}=N(),{data:t}=oe(),{data:n}=ie(),a=re(),s=ee(),f=ne(),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)([]),[T,k]=(0,Y.useState)(``),j=(0,Y.useMemo)(()=>Ke(Object.values(t?.providers??{}),y),[t?.providers,y]),P=(0,Y.useMemo)(()=>n?.providerTemplates??[],[n?.providerTemplates]),F=(0,Y.useMemo)(()=>qe(P),[P]),I=(0,Y.useMemo)(()=>new Map(P.map(e=>[e.providerType,e])),[P]),R=(0,Y.useMemo)(()=>{let e=T.trim().toLowerCase();return j.filter(t=>{if(!e)return!0;let n=t.providerType?I.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[j,T,I]),B=(0,Y.useMemo)(()=>p&&R.some(e=>e.providerId===p)?p:e?null:R[0]?.providerId??null,[R,e,p]);return!t||!n?(0,X.jsx)(`div`,{className:`p-8`,children:r(`providersLoading`)}):(0,X.jsxs)(l,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,X.jsx)(c,{title:r(`providersPageTitle`),description:r(`providersPageDescription`)}),(0,X.jsxs)(K,{className:`xl:min-h-0`,mobileView:e?B?`detail`:`list`:void 0,onMobileBack:()=>m(null),mobileListLabel:r(`providersPageTitle`),children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,X.jsxs)(D,{open:_,onOpenChange:v,children:[(0,X.jsx)(E,{asChild:!0,children:(0,X.jsxs)(u,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:a.isPending,children:[(0,X.jsx)(w,{className:`mr-2 h-4 w-4`}),a.isPending?r(`saving`):r(`providerAdd`)]})}),(0,X.jsxs)(A,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,X.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:r(`providerTemplatePickerTitle`)}),(0,X.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border bg-card px-3 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/70`,onClick:async()=>{try{let e=await a.mutateAsync({data:{providerType:null}});k(``),m(e.providerId),b(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),v(!1)}catch{}},children:[(0,X.jsx)(O,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border bg-background`}),(0,X.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:r(`providerAddCustom`)})]}),F.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border bg-card px-3 py-2 text-left transition-colors hover:border-primary/40 hover:bg-accent/70`,onClick:async()=>{try{let t=await a.mutateAsync({data:{providerType:e.providerType}});k(``),m(t.providerId),b(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),v(!1)}catch{}},children:[(0,X.jsx)(O,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,X.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,X.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,X.jsx)(o,{value:T,onChange:e=>k(e.target.value),placeholder:r(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,X.jsxs)(q,{className:`space-y-2 p-3`,children:[R.map(e=>{let t=e.providerType?I.get(e.providerType):null,n=e.enabled!==!1,a=!!(n&&e.apiKeySet),o=e.displayName?.trim()||t?.displayName||e.providerId,s=Ge(e.apiBase||t?.defaultApiBase||``)||r(`providersDefaultDescription`);return(0,X.jsx)(`div`,{onClick:()=>m(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m(e.providerId))},role:`button`,tabIndex:0,className:i(`w-full rounded-xl border p-2.5 text-left transition-all`,B===e.providerId?`border-primary/35 bg-primary-50/45 text-foreground shadow-sm`:`border-border bg-card text-muted-foreground hover:border-primary/35 hover:bg-accent/70 hover:text-accent-foreground`),children:(0,X.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,X.jsx)(O,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:i(`h-10 w-10 rounded-lg border`,a?`border-primary/35 bg-background`:`border-border bg-background`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,X.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:o}),(0,X.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,X.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[s,` · `,e.models?.length??0]})]})]}),(0,X.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5`,children:[(0,X.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,X.jsx)(d,{checked:n,disabled:f.isPending,title:r(n?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{f.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,X.jsxs)(D,{children:[(0,X.jsx)(E,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-accent hover:text-accent-foreground`,onClick:e=>e.stopPropagation(),title:r(`more`),children:(0,X.jsx)(C,{className:`h-4 w-4`})})}),(0,X.jsx)(A,{className:`w-40 p-1`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-sm text-red-600 hover:bg-red-50`,onClick:()=>g(e.providerId),children:[(0,X.jsx)(L,{className:`h-4 w-4`}),r(`providerDelete`)]})})]})]}),(0,X.jsx)(M,{status:n?a?`ready`:`setup`:`inactive`,label:r(n?a?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),R.length===0?(0,X.jsx)(ce,{icon:z,title:r(`providersNoMatch`)}):null]})]}),(0,X.jsx)(Ue,{providerName:B??void 0,onProviderDeleted:e=>{b(t=>t.filter(t=>t!==e)),e===B&&m(null)}})]}),(0,X.jsx)(x,{open:!!h,onOpenChange:e=>{e||g(null)},title:r(`providerDelete`),description:h??void 0,confirmLabel:r(`delete`),variant:`destructive`,onCancel:()=>g(null),onConfirm:()=>{h&&s.mutateAsync({provider:h}).then(()=>{b(e=>e.filter(e=>e!==h)),h===B&&m(null),g(null)})}})]})}export{Je as ProvidersConfigPage};