@xopcai/xopc 0.0.388 → 0.0.390

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 (644) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +6 -1
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +6 -1
  3. package/dist/browser-ext/dist/assets/{page-context-BeworyNB.js → page-context-A5RCibM_.js} +1 -1
  4. package/dist/browser-ext/dist/background.js +1 -1
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +98 -53
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/feishu/src/adapters/cli-login.js +3 -3
  9. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  10. package/dist/extensions/telegram/src/inbound-processor.js +2 -2
  11. package/dist/extensions/telegram/src/outbound-sender.js +1 -1
  12. package/dist/extensions/telegram/src/plugin.js +7 -5
  13. package/dist/extensions/telegram/xopc.extension.json +1 -1
  14. package/dist/extensions/weixin/src/api/api.js +2 -2
  15. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  16. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  17. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  18. package/dist/gateway/static/root/assets/{activity-store-CB2X4Gmu.js → activity-store-DGMAYkw8.js} +1 -1
  19. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-44LqtGte.js → agent-avatar-dicebear-B4AsZzJR.js} +1 -1
  20. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-9NUY1sO3.js +1 -0
  21. package/dist/gateway/static/root/assets/agent-plugin-dialog-CNc6ntzP.js +1 -0
  22. package/dist/gateway/static/root/assets/agents-QNY9Vkrf.js +77 -0
  23. package/dist/gateway/static/root/assets/{agents-admin-api-BkULgC6Q.js → agents-admin-api-DxdaiFWn.js} +1 -1
  24. package/dist/gateway/static/root/assets/app-management-settings-panel-DHRfLkYD.js +1 -0
  25. package/dist/gateway/static/root/assets/{appearance-settings-CYofu-su.js → appearance-settings-DtKSapgb.js} +1 -1
  26. package/dist/gateway/static/root/assets/{apps-page-CHjWvDjk.js → apps-page-B9kuRt_z.js} +1 -1
  27. package/dist/gateway/static/root/assets/{archive-plugin-De0ND0oA.js → archive-plugin-AgySTXp_.js} +1 -1
  28. package/dist/gateway/static/root/assets/{automations-page-BIF0skon.js → automations-page-D1o7ZtUW.js} +1 -1
  29. package/dist/gateway/static/root/assets/automations-workspace-BJenz0P1.js +6 -0
  30. package/dist/gateway/static/root/assets/{binary-plugins-Do535ZGW.js → binary-plugins-A1AXOsO6.js} +1 -1
  31. package/dist/gateway/static/root/assets/{block-editor-C_RD603p.js → block-editor-DUNLkLKF.js} +3 -3
  32. package/dist/gateway/static/root/assets/{browser-automation-inputs-B9M1RYTm.js → browser-automation-inputs-BvUC6OiW.js} +1 -1
  33. package/dist/gateway/static/root/assets/browser-automations-page-Dq2LlVMh.js +3 -0
  34. package/dist/gateway/static/root/assets/browser-settings-page-BOZ-1g51.js +3 -0
  35. package/dist/gateway/static/root/assets/{capabilities-CW389yo6.js → capabilities-BkCutK0V.js} +1 -1
  36. package/dist/gateway/static/root/assets/{capabilities-BX1rCiVm.js → capabilities-D61uSJPy.js} +1 -1
  37. package/dist/gateway/static/root/assets/capabilities-page-BDP6gzlv.js +2 -0
  38. package/dist/gateway/static/root/assets/capabilities-settings-panel-D6PL3Mfl.js +8 -0
  39. package/dist/gateway/static/root/assets/{capability-header-actions-Chuhscdb.js → capability-header-actions-D9uGs4Pw.js} +1 -1
  40. package/dist/gateway/static/root/assets/channels-xb7n8rwF.js +1 -0
  41. package/dist/gateway/static/root/assets/chat-terminal-dock-Dgn09YDs.js +36 -0
  42. package/dist/gateway/static/root/assets/{computer-settings-page-Af00Kjc0.js → computer-settings-page-C66P4ifT.js} +1 -1
  43. package/dist/gateway/static/root/assets/{connector-service-page-3W0_7-4L.js → connector-service-page-Dp35XdYf.js} +1 -1
  44. package/dist/gateway/static/root/assets/connectors-page-BHcRxYib.js +1 -0
  45. package/dist/gateway/static/root/assets/{date-picker-DBgZBmik.js → date-picker-CddHY982.js} +1 -1
  46. package/dist/gateway/static/root/assets/{dependency-picker-BDJ406kH.js → dependency-picker-Ob6BZTqv.js} +1 -1
  47. package/dist/gateway/static/root/assets/{desktop-pet-Do1XPn6U.js → desktop-pet-dmwCV-I4.js} +1 -1
  48. package/dist/gateway/static/root/assets/{desktop-pet-settings-LKeVh6OH.js → desktop-pet-settings-B-TBkZAZ.js} +1 -1
  49. package/dist/gateway/static/root/assets/device-pairing-wizard-SWHwRgG3.js +1 -0
  50. package/dist/gateway/static/root/assets/{directory-picker-path-field-BMLHoL6g.js → directory-picker-path-field-6VZa4fT1.js} +1 -1
  51. package/dist/gateway/static/root/assets/{extension-debug-page-B0wTBCx4.js → extension-debug-page-C0_njMva.js} +1 -1
  52. package/dist/gateway/static/root/assets/{extension-page-vR2r4uUB.js → extension-page-BeBLMFmW.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-provider-CJZ5EVpQ.js → extension-provider-DWI0KAKT.js} +1 -1
  54. package/dist/gateway/static/root/assets/extension-settings-page-BiLUwoKx.js +1 -0
  55. package/dist/gateway/static/root/assets/{gateway-config-swr-D0tBjSgj.js → gateway-config-swr-CmYcOqhb.js} +1 -1
  56. package/dist/gateway/static/root/assets/{gateway-realtime-BnHraJ3O.js → gateway-realtime-Ci1Jst5g.js} +1 -1
  57. package/dist/gateway/static/root/assets/gateway-realtime-store-BMUiUQMk.js +1 -0
  58. package/dist/gateway/static/root/assets/gateway-settings-CzWT_v09.js +1 -0
  59. package/dist/gateway/static/root/assets/{gateway-startup-retry-C1DQsIH3.js → gateway-startup-retry-C-BG5M7H.js} +1 -1
  60. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BM__yiMn.js → highlighted-body-KQOG7T2V-CsA7lCVc.js} +1 -1
  61. package/dist/gateway/static/root/assets/home-page-BeXJfxsg.js +2 -0
  62. package/dist/gateway/static/root/assets/image-generation-api-B_DqCwtV.js +1 -0
  63. package/dist/gateway/static/root/assets/imports-page-oAvAF9QS.js +1 -0
  64. package/dist/gateway/static/root/assets/index-W9ls-0Yd.css +1 -0
  65. package/dist/gateway/static/root/assets/index-xTL-vb51.js +260 -0
  66. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DpyqH2cP.js → keyboard-shortcuts-settings--MjYe-Pb.js} +1 -1
  67. package/dist/gateway/static/root/assets/{local-app-workbench-page-B4hIoxV8.js → local-app-workbench-page-DL33dtd7.js} +1 -1
  68. package/dist/gateway/static/root/assets/{local-apps-page-S7lUpENM.js → local-apps-page-DOa7mxjB.js} +1 -1
  69. package/dist/gateway/static/root/assets/{local-session-drafts-Be4BGM4Z.js → local-session-drafts-DAtLkTPg.js} +1 -1
  70. package/dist/gateway/static/root/assets/{locale-store-uRu_DsWm.js → locale-store-DMy9W6IG.js} +1 -1
  71. package/dist/gateway/static/root/assets/logs-page-C-GbTYsM.js +2 -0
  72. package/dist/gateway/static/root/assets/management-settings-C0TzuD3-.js +1 -0
  73. package/dist/gateway/static/root/assets/{markdown-view-CBjl-XEc.js → markdown-view-wyOHdXEg.js} +1 -1
  74. package/dist/gateway/static/root/assets/{media-plugins-BombFqsX.js → media-plugins-Pb2zr_-L.js} +1 -1
  75. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-BxyGGa4D.js +1 -0
  76. package/dist/gateway/static/root/assets/messages-O0BEUKnx.js +3 -0
  77. package/dist/gateway/static/root/assets/models-hub-cache-DdH1MODX.js +1 -0
  78. package/dist/gateway/static/root/assets/note-detail-panel-BFpEqskQ.js +5 -0
  79. package/dist/gateway/static/root/assets/{notes-api-BlGP533W.js → notes-api-CYt2pGsm.js} +1 -1
  80. package/dist/gateway/static/root/assets/notes-page-h-qqFJ6Z.js +8 -0
  81. package/dist/gateway/static/root/assets/{page-context-capture-button-C2bSXVbz.js → page-context-capture-button-3uj5EcQC.js} +1 -1
  82. package/dist/gateway/static/root/assets/personal-page-BGyW6cdt.js +1 -0
  83. package/dist/gateway/static/root/assets/{product-open-page-Cn16lm5l.js → product-open-page-hI13tPS1.js} +1 -1
  84. package/dist/gateway/static/root/assets/{product-preview-content-CowgeuoG.js → product-preview-content-lT_in0-Q.js} +1 -1
  85. package/dist/gateway/static/root/assets/project-detail-page-Baj7fQ7N.js +1 -0
  86. package/dist/gateway/static/root/assets/projects-page-D7DyQFU3.js +1 -0
  87. package/dist/gateway/static/root/assets/{registry-api-CYqA7bfl.js → registry-api-CgQrCqL6.js} +1 -1
  88. package/dist/gateway/static/root/assets/remote-access-hub-DU_d93Tm.js +1 -0
  89. package/dist/gateway/static/root/assets/{runtime-tools-api-zzoxjSuR.js → runtime-tools-api-D12qVKeC.js} +1 -1
  90. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DOSPOfCU.js +1 -0
  91. package/dist/gateway/static/root/assets/scenes-page-swyUIF5A.js +2 -0
  92. package/dist/gateway/static/root/assets/{schema-form-I6pzJJzg.js → schema-form-CwOFgsyh.js} +1 -1
  93. package/dist/gateway/static/root/assets/{send-session-input-C293-Hbx.js → send-session-input-nH8Cw0US.js} +1 -1
  94. package/dist/gateway/static/root/assets/{session-api-CzVTrG8n.js → session-api-B9HrwF-c.js} +1 -1
  95. package/dist/gateway/static/root/assets/session-manager-aXqXuqDX.js +16 -0
  96. package/dist/gateway/static/root/assets/sessions-page-CI_PJmlX.js +1 -0
  97. package/dist/gateway/static/root/assets/settings-advanced-gate-DCVaeBLW.js +1 -0
  98. package/dist/gateway/static/root/assets/{settings-page-Dy5oQDbx.js → settings-page-BN70wE6R.js} +1 -1
  99. package/dist/gateway/static/root/assets/setup-status-panel-CHzcVRi-.js +1 -0
  100. package/dist/gateway/static/root/assets/{share-link-dialog-BKGI8Kr0.js → share-link-dialog-B1TDyhPt.js} +1 -1
  101. package/dist/gateway/static/root/assets/{share-preview-page-BF2WaO43.js → share-preview-page-Br-eAZaP.js} +1 -1
  102. package/dist/gateway/static/root/assets/{shares-api-B0HlMAzi.js → shares-api-Bl1ZBh5S.js} +1 -1
  103. package/dist/gateway/static/root/assets/shares-settings-jgCC_E4Y.js +1 -0
  104. package/dist/gateway/static/root/assets/{skill-api-RIjxQs-Y.js → skill-api-ClUw3SRC.js} +1 -1
  105. package/dist/gateway/static/root/assets/{skill-reload-api-CEJx5rPd.js → skill-reload-api--1BfIPzb.js} +1 -1
  106. package/dist/gateway/static/root/assets/skills-page-C9oRZSuL.js +2 -0
  107. package/dist/gateway/static/root/assets/{system-settings-panel-C8aLy8T_.js → system-settings-panel-tWrqu7ai.js} +1 -1
  108. package/dist/gateway/static/root/assets/{task-detail-page-o1O2IDVP.js → task-detail-page-BYRW7Rrr.js} +2 -2
  109. package/dist/gateway/static/root/assets/{task-expandable-content-C9ohICpw.js → task-expandable-content-D2t4ahzR.js} +1 -1
  110. package/dist/gateway/static/root/assets/{theme-store-BUfzeDvL.js → theme-store-BBLjE0fi.js} +1 -1
  111. package/dist/gateway/static/root/assets/{tracing-settings-page-C2q5B3Kp.js → tracing-settings-page-5ATxQH5c.js} +1 -1
  112. package/dist/gateway/static/root/assets/{tunnel-api-JkDu1wiC.js → tunnel-api-CF1Qh4wU.js} +1 -1
  113. package/dist/gateway/static/root/assets/{usage-page-B8K6Y4ro.js → usage-page-CuEHzXil.js} +1 -1
  114. package/dist/gateway/static/root/assets/{use-autosave-DgbCgsao.js → use-autosave-tY3keIbm.js} +1 -1
  115. package/dist/gateway/static/root/assets/{use-composer-attachments-rgW7h4sD.js → use-composer-attachments-CXsocZjt.js} +1 -1
  116. package/dist/gateway/static/root/assets/{use-file-preview-expanded-DSKIxfz9.js → use-file-preview-expanded-CEsxnDnQ.js} +2 -2
  117. package/dist/gateway/static/root/assets/user-model-page-Dvt5TIZ6.js +2 -0
  118. package/dist/gateway/static/root/assets/{voice-api-key-field-4AIkbm9R.js → voice-api-key-field-COTNLUU3.js} +1 -1
  119. package/dist/gateway/static/root/assets/{voice-config-api-Kw1pYlLN.js → voice-config-api-DrxBjSja.js} +1 -1
  120. package/dist/gateway/static/root/assets/voice-transcribe-api-B47j0_xA.js +1 -0
  121. package/dist/gateway/static/root/assets/{work-discovery-overlay-BshsEDRO.js → work-discovery-overlay-PByMJrhV.js} +1 -1
  122. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CRG3paWy.js → workflow-run-setup-panel-CSUkMo63.js} +2 -2
  123. package/dist/gateway/static/root/assets/{workflows-page-c-AoSVzm.js → workflows-page-BUDvFo3R.js} +3 -3
  124. package/dist/gateway/static/root/assets/{workspace-api-JWHOFos6.js → workspace-api-Bmx1O449.js} +2 -2
  125. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-PDSIicr1.js → xopc-cloud-account-card-DVsAbvwP.js} +1 -1
  126. package/dist/gateway/static/root/index.html +28 -27
  127. package/dist/package.js +1 -1
  128. package/dist/packages/gateway-contract/src/clarifications.js +79 -2
  129. package/dist/packages/gateway-contract/src/discussions.js +3 -2
  130. package/dist/packages/gateway-contract/src/index.js +4 -0
  131. package/dist/packages/gateway-contract/src/provider-setup.js +6 -0
  132. package/dist/packages/gateway-contract/src/recording-outcome.js +6 -0
  133. package/dist/packages/image-providers/src/catalog.js +10 -0
  134. package/dist/packages/image-providers/src/execute.js +5 -1
  135. package/dist/packages/image-providers/src/validation.js +19 -1
  136. package/dist/packages/realtime-protocol/src/voice.js +13 -2
  137. package/dist/src/agent/agent-manager.js +25 -21
  138. package/dist/src/agent/agent-scope.js +2 -2
  139. package/dist/src/agent/background-review/prompts.js +5 -1
  140. package/dist/src/agent/background-review/run-background-review.d.ts +0 -1
  141. package/dist/src/agent/background-review/run-background-review.js +60 -14
  142. package/dist/src/agent/child-agent-factory.js +1 -1
  143. package/dist/src/agent/coding/repository-instructions.js +1 -1
  144. package/dist/src/agent/context/coordinator.js +2 -2
  145. package/dist/src/agent/context/execution-context.js +4 -4
  146. package/dist/src/agent/context/execution-scope.js +1 -1
  147. package/dist/src/agent/context/project-context.js +3 -3
  148. package/dist/src/agent/data-acquisition/service.js +1 -1
  149. package/dist/src/agent/embedded/codemode-extension.js +1 -1
  150. package/dist/src/agent/embedded/run-for-session.js +31 -8
  151. package/dist/src/agent/embedded/run-turn.js +26 -14
  152. package/dist/src/agent/embedded/session-runner.d.ts +4 -3
  153. package/dist/src/agent/embedded/session-runner.js +9 -4
  154. package/dist/src/agent/embedded/session-tool-result-guard.js +2 -2
  155. package/dist/src/agent/embedded/tool-result-truncation.js +1 -1
  156. package/dist/src/agent/embedded/xopc-stream-bridge.js +3 -0
  157. package/dist/src/agent/embedded/xopc-tools-bridge.js +1 -1
  158. package/dist/src/agent/external-tools/cliProvider.js +3 -3
  159. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  160. package/dist/src/agent/external-tools/endpoint-provider.js +4 -4
  161. package/dist/src/agent/external-tools/gateway-tools.js +2 -2
  162. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  163. package/dist/src/agent/image/generation/runtime.js +13 -15
  164. package/dist/src/agent/image/index.js +1 -1
  165. package/dist/src/agent/image/load-image-media.js +1 -1
  166. package/dist/src/agent/image/understanding/runtime.js +5 -0
  167. package/dist/src/agent/inbound/attachment-pipeline.js +3 -3
  168. package/dist/src/agent/inbound/inbound-loop.d.ts +1 -15
  169. package/dist/src/agent/inbound/inbound-loop.js +7 -2
  170. package/dist/src/agent/index.js +3 -3
  171. package/dist/src/agent/mcp/connection-drafts.d.ts +50 -0
  172. package/dist/src/agent/mcp/connection-drafts.js +278 -0
  173. package/dist/src/agent/mcp/connection-errors.d.ts +3 -0
  174. package/dist/src/agent/mcp/connection-errors.js +32 -0
  175. package/dist/src/agent/mcp/connection-setup.d.ts +7 -2
  176. package/dist/src/agent/mcp/connection-setup.js +45 -23
  177. package/dist/src/agent/mcp/credential-store.d.ts +6 -0
  178. package/dist/src/agent/mcp/credential-store.js +24 -0
  179. package/dist/src/agent/mcp/native-mcp.d.ts +6 -1
  180. package/dist/src/agent/mcp/native-mcp.js +6 -0
  181. package/dist/src/agent/mcp/tool-catalog.d.ts +7 -2
  182. package/dist/src/agent/mcp/tool-catalog.js +25 -15
  183. package/dist/src/agent/memory/compaction.js +5 -1
  184. package/dist/src/agent/memory/context-budget.js +1 -1
  185. package/dist/src/agent/memory/context-recovery.js +1 -1
  186. package/dist/src/agent/memory/idle-compaction-scheduler.js +3 -1
  187. package/dist/src/agent/memory/index.js +1 -1
  188. package/dist/src/agent/models/manager.d.ts +1 -0
  189. package/dist/src/agent/models/manager.js +4 -2
  190. package/dist/src/agent/orchestration/agent-orchestrator.d.ts +1 -6
  191. package/dist/src/agent/orchestration/agent-orchestrator.js +5 -0
  192. package/dist/src/agent/orchestration/llm-turn-retry.js +1 -1
  193. package/dist/src/agent/prompt/response-language.js +1 -1
  194. package/dist/src/agent/prompt/service-prompt-builder.js +3 -3
  195. package/dist/src/agent/sandbox/exec-policy.js +1 -1
  196. package/dist/src/agent/service/direct-turn-helpers.js +4 -4
  197. package/dist/src/agent/service/process-direct-one-shot.js +5 -0
  198. package/dist/src/agent/service/process-direct-streaming.d.ts +1 -0
  199. package/dist/src/agent/service/process-direct-streaming.js +23 -7
  200. package/dist/src/agent/service/webchat-tts.js +2 -2
  201. package/dist/src/agent/service.js +21 -21
  202. package/dist/src/agent/session/session-config-service.js +3 -3
  203. package/dist/src/agent/session/session-hydrator.js +1 -1
  204. package/dist/src/agent/session/session-inspector.js +1 -1
  205. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  206. package/dist/src/agent/skills/hub-pull.js +2 -2
  207. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
  208. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  209. package/dist/src/agent/source-context/index.js +1 -1
  210. package/dist/src/agent/tasks/task-judge-service.js +7 -7
  211. package/dist/src/agent/tools/clarify-tool.d.ts +2 -3
  212. package/dist/src/agent/tools/clarify-tool.js +15 -9
  213. package/dist/src/agent/tools/cli-clarify.d.ts +0 -3
  214. package/dist/src/agent/tools/cli-clarify.js +18 -32
  215. package/dist/src/agent/tools/create-share-tool.js +3 -3
  216. package/dist/src/agent/tools/dataBatch.js +1 -1
  217. package/dist/src/agent/tools/delegate-tool.js +3 -3
  218. package/dist/src/agent/tools/executor.js +1 -1
  219. package/dist/src/agent/tools/factory.js +19 -19
  220. package/dist/src/agent/tools/image-generate-tool.js +8 -4
  221. package/dist/src/agent/tools/index.js +6 -6
  222. package/dist/src/agent/tools/list-dir.js +1 -1
  223. package/dist/src/agent/tools/personal-attention-tool.js +2 -2
  224. package/dist/src/agent/tools/personal-request-result-tool.js +1 -1
  225. package/dist/src/agent/tools/personal-request-tool.js +4 -4
  226. package/dist/src/agent/tools/personal-result-tool.js +1 -1
  227. package/dist/src/agent/tools/personal-task-tool.d.ts +4 -4
  228. package/dist/src/agent/tools/personal-task-tool.js +6 -6
  229. package/dist/src/agent/tools/publish-artifacts.js +2 -2
  230. package/dist/src/agent/tools/read.js +2 -2
  231. package/dist/src/agent/tools/review-workspace.js +1 -1
  232. package/dist/src/agent/tools/send-media.js +1 -1
  233. package/dist/src/agent/tools/skills-tools.js +1 -1
  234. package/dist/src/agent/tools/task-collaboration-tool.js +3 -3
  235. package/dist/src/agent/tools/tts-tool.js +1 -1
  236. package/dist/src/agent/tools/user-context-tool.js +1 -1
  237. package/dist/src/agent/tools/write.js +2 -2
  238. package/dist/src/agent/tools/xopc-use-tool.js +4 -4
  239. package/dist/src/agent/transcript/index.js +2 -2
  240. package/dist/src/agent/transcript/transcript-hygiene.js +2 -2
  241. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  242. package/dist/src/agent-config/resolver.js +5 -0
  243. package/dist/src/agent-config/schema.d.ts +26 -6
  244. package/dist/src/agent-config/schema.js +2 -0
  245. package/dist/src/agent-matching/delegation-service.js +1 -1
  246. package/dist/src/ai-assist/text-assist.js +6 -17
  247. package/dist/src/auth/oauth/xopc-cloud.js +2 -2
  248. package/dist/src/auth/sync-provider-auth.js +1 -1
  249. package/dist/src/automations/capabilities/write.d.ts +2 -2
  250. package/dist/src/automations/domain/index.js +1 -1
  251. package/dist/src/automations/domain/validation.d.ts +6 -6
  252. package/dist/src/automations/draft/automation-draft-service.js +1 -1
  253. package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
  254. package/dist/src/automations/index.js +2 -2
  255. package/dist/src/automations/service/action-executor.js +3 -1
  256. package/dist/src/browser/native-messaging-host.js +1 -1
  257. package/dist/src/capabilities/store-connector.js +2 -2
  258. package/dist/src/channels/attachments/voice-stt-webchat.js +2 -2
  259. package/dist/src/channels/index.js +3 -3
  260. package/dist/src/channels/manager.js +1 -1
  261. package/dist/src/channels/outbound-sender.js +1 -1
  262. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  263. package/dist/src/channels/pairing/pairing-store.js +6 -6
  264. package/dist/src/chat-commands/builtins/config.js +4 -4
  265. package/dist/src/chat-commands/builtins/session.js +1 -1
  266. package/dist/src/chat-commands/builtins/thinking.js +1 -1
  267. package/dist/src/chat-commands/builtins/tts.js +1 -1
  268. package/dist/src/chat-commands/context.js +2 -2
  269. package/dist/src/chat-commands/index.js +3 -3
  270. package/dist/src/cli/commands/agent.js +7 -7
  271. package/dist/src/cli/commands/channels.js +1 -1
  272. package/dist/src/cli/commands/config.js +1 -1
  273. package/dist/src/cli/commands/connectors.js +2 -2
  274. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -1
  275. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  276. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -1
  277. package/dist/src/cli/commands/extension-dev.js +1 -1
  278. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  279. package/dist/src/cli/commands/extension.js +2 -2
  280. package/dist/src/cli/commands/image.js +1 -1
  281. package/dist/src/cli/commands/init.js +1 -1
  282. package/dist/src/cli/commands/mcp.js +1 -1
  283. package/dist/src/cli/commands/models.js +3 -3
  284. package/dist/src/cli/commands/onboard/channels/registry.js +1 -1
  285. package/dist/src/cli/commands/onboard/model.d.ts +1 -1
  286. package/dist/src/cli/commands/onboard/model.js +21 -2
  287. package/dist/src/cli/commands/onboard.js +2 -2
  288. package/dist/src/cli/commands/project.js +1 -1
  289. package/dist/src/cli/commands/skills.js +2 -2
  290. package/dist/src/cli/commands/tunnel.js +4 -4
  291. package/dist/src/cli/extension-cli-register.js +6 -6
  292. package/dist/src/cli/utils/gateway-client.js +1 -1
  293. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  294. package/dist/src/cli/utils/session.js +1 -1
  295. package/dist/src/computer/runtime.js +1 -1
  296. package/dist/src/config/agent-model-intents.js +4 -1
  297. package/dist/src/config/index.js +5 -5
  298. package/dist/src/config/loader.js +2 -2
  299. package/dist/src/config/models-json.js +1 -1
  300. package/dist/src/config/schema.d.ts +18 -6
  301. package/dist/src/config/schema.js +18 -8
  302. package/dist/src/connectors/cli/authorization.js +1 -1
  303. package/dist/src/connectors/cli/runtime.js +1 -1
  304. package/dist/src/connectors/composio-sessions.js +1 -1
  305. package/dist/src/connectors/composio.js +1 -1
  306. package/dist/src/connectors/connected-source-ingestion.js +4 -4
  307. package/dist/src/connectors/connected-source-understanding.js +4 -4
  308. package/dist/src/connectors/connection-recovery-service.js +4 -4
  309. package/dist/src/connectors/content-enrichment.js +1 -1
  310. package/dist/src/connectors/health.js +1 -1
  311. package/dist/src/connectors/learning-coordinator.js +1 -1
  312. package/dist/src/discussions/analyzer.d.ts +2 -0
  313. package/dist/src/discussions/analyzer.js +38 -9
  314. package/dist/src/discussions/audio-clip.d.ts +3 -0
  315. package/dist/src/discussions/audio-clip.js +72 -0
  316. package/dist/src/discussions/live-worker.js +4 -2
  317. package/dist/src/discussions/long-review.d.ts +17 -0
  318. package/dist/src/discussions/long-review.js +278 -0
  319. package/dist/src/discussions/media-timeline.d.ts +21 -0
  320. package/dist/src/discussions/media-timeline.js +134 -0
  321. package/dist/src/discussions/organizer-worker.d.ts +4 -1
  322. package/dist/src/discussions/organizer-worker.js +17 -12
  323. package/dist/src/discussions/organizer.js +2 -0
  324. package/dist/src/discussions/processing.d.ts +43 -0
  325. package/dist/src/discussions/processing.js +125 -0
  326. package/dist/src/discussions/recording.js +202 -42
  327. package/dist/src/discussions/recordingJobs.js +2 -0
  328. package/dist/src/discussions/repository.js +4 -2
  329. package/dist/src/discussions/review.d.ts +8 -0
  330. package/dist/src/discussions/review.js +183 -0
  331. package/dist/src/discussions/sealer.d.ts +7 -1
  332. package/dist/src/discussions/sealer.js +164 -88
  333. package/dist/src/discussions/service.d.ts +7 -1
  334. package/dist/src/discussions/service.js +51 -15
  335. package/dist/src/discussions/types.d.ts +2 -1
  336. package/dist/src/endpoint-tools/index.js +1 -1
  337. package/dist/src/endpoint-tools/runtime.js +2 -2
  338. package/dist/src/extensions/activation-context.js +3 -3
  339. package/dist/src/extensions/agent-plugins/auth.js +1 -1
  340. package/dist/src/extensions/agent-plugins/credentials.js +1 -1
  341. package/dist/src/extensions/agent-plugins/source-http-fetch.js +1 -1
  342. package/dist/src/extensions/api.js +4 -4
  343. package/dist/src/extensions/bundled-extension-activation.js +1 -1
  344. package/dist/src/extensions/index.js +3 -3
  345. package/dist/src/extensions/install.js +1 -1
  346. package/dist/src/extensions/loader.js +2 -2
  347. package/dist/src/extensions/sdk/index.js +1 -1
  348. package/dist/src/extensions/sdk/media.js +1 -1
  349. package/dist/src/extensions/update.js +1 -1
  350. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  351. package/dist/src/gateway/agents-admin.js +1 -1
  352. package/dist/src/gateway/chat-stream/mapper.js +2 -2
  353. package/dist/src/gateway/chat-stream/protocol.d.ts +2 -3
  354. package/dist/src/gateway/clarify-runtime.d.ts +2 -0
  355. package/dist/src/gateway/clarify-runtime.js +4 -1
  356. package/dist/src/gateway/device-routes.js +2 -2
  357. package/dist/src/gateway/ephemeral-clarification-waiter.d.ts +2 -1
  358. package/dist/src/gateway/ephemeral-clarification-waiter.js +19 -6
  359. package/dist/src/gateway/file-path-classifier.js +2 -2
  360. package/dist/src/gateway/global-defaults-admin.d.ts +3 -1
  361. package/dist/src/gateway/global-defaults-admin.js +15 -3
  362. package/dist/src/gateway/hono/app.js +3 -3
  363. package/dist/src/gateway/hono/lib/config-payload.d.ts +12 -3
  364. package/dist/src/gateway/hono/lib/config-payload.js +6 -4
  365. package/dist/src/gateway/hono/lib/config-write-lock.d.ts +2 -0
  366. package/dist/src/gateway/hono/lib/config-write-lock.js +14 -0
  367. package/dist/src/gateway/hono/lib/voice-settings-revisions.d.ts +5 -0
  368. package/dist/src/gateway/hono/lib/voice-settings-revisions.js +23 -0
  369. package/dist/src/gateway/hono/routes/agent-stream.js +4 -9
  370. package/dist/src/gateway/hono/routes/agents.js +1 -1
  371. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  372. package/dist/src/gateway/hono/routes/commands-skills.js +4 -4
  373. package/dist/src/gateway/hono/routes/config-patch/gateway.js +1 -1
  374. package/dist/src/gateway/hono/routes/config-patch/misc.js +12 -5
  375. package/dist/src/gateway/hono/routes/config.js +19 -5
  376. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  377. package/dist/src/gateway/hono/routes/context-sources.js +2 -2
  378. package/dist/src/gateway/hono/routes/discussions.js +63 -1
  379. package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -1
  380. package/dist/src/gateway/hono/routes/global-defaults.js +8 -1
  381. package/dist/src/gateway/hono/routes/home.js +1 -1
  382. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -1
  383. package/dist/src/gateway/hono/routes/mcp.js +74 -7
  384. package/dist/src/gateway/hono/routes/memory-learning.js +3 -3
  385. package/dist/src/gateway/hono/routes/models.js +17 -9
  386. package/dist/src/gateway/hono/routes/notes.js +1 -1
  387. package/dist/src/gateway/hono/routes/personal-agent.js +1 -1
  388. package/dist/src/gateway/hono/routes/projects.js +3 -3
  389. package/dist/src/gateway/hono/routes/provider-setup.d.ts +3 -0
  390. package/dist/src/gateway/hono/routes/provider-setup.js +106 -0
  391. package/dist/src/gateway/hono/routes/runtime-tools.js +1 -1
  392. package/dist/src/gateway/hono/routes/session-command-handler.js +2 -2
  393. package/dist/src/gateway/hono/routes/session-input-handler.js +5 -5
  394. package/dist/src/gateway/hono/routes/sessions.js +3 -3
  395. package/dist/src/gateway/hono/routes/shares.js +2 -2
  396. package/dist/src/gateway/hono/routes/side-chats.js +5 -4
  397. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  398. package/dist/src/gateway/hono/routes/status.js +2 -0
  399. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  400. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  401. package/dist/src/gateway/hono/routes/user-model.js +7 -7
  402. package/dist/src/gateway/hono/routes/voice.js +30 -17
  403. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  404. package/dist/src/gateway/index.js +1 -1
  405. package/dist/src/gateway/lock.js +11 -11
  406. package/dist/src/gateway/media-access.js +1 -1
  407. package/dist/src/gateway/mobile-privacy.js +2 -2
  408. package/dist/src/gateway/ports.js +6 -6
  409. package/dist/src/gateway/provider-model-setup.d.ts +4 -0
  410. package/dist/src/gateway/provider-model-setup.js +56 -0
  411. package/dist/src/gateway/run-loop.js +1 -1
  412. package/dist/src/gateway/scenes/mailContext.js +1 -1
  413. package/dist/src/gateway/scenes/slackThreadSource.js +1 -1
  414. package/dist/src/gateway/server.js +1 -1
  415. package/dist/src/gateway/service/agent-runner.d.ts +5 -4
  416. package/dist/src/gateway/service/agent-runner.js +35 -19
  417. package/dist/src/gateway/service/config-coordinator.d.ts +619 -1
  418. package/dist/src/gateway/service/config-coordinator.js +38 -26
  419. package/dist/src/gateway/service/marketplace-service.js +2 -2
  420. package/dist/src/gateway/service/run-gateway-agent.js +4 -4
  421. package/dist/src/gateway/service/session-command-service.js +2 -2
  422. package/dist/src/gateway/service.d.ts +6 -3
  423. package/dist/src/gateway/service.js +52 -51
  424. package/dist/src/gateway/session-context-summary.js +4 -4
  425. package/dist/src/gateway/side-chat/run-service.d.ts +2 -1
  426. package/dist/src/gateway/side-chat/run-service.js +6 -3
  427. package/dist/src/gateway/side-chat/types.d.ts +3 -3
  428. package/dist/src/gateway/workspace-editor-path.js +2 -2
  429. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +2 -2
  430. package/dist/src/gateway/xopc-cloud-capability-setup.js +7 -4
  431. package/dist/src/home-intelligence/generator.js +2 -2
  432. package/dist/src/home-intelligence/host.js +2 -2
  433. package/dist/src/imports/compatibility.js +1 -1
  434. package/dist/src/imports/inventory.js +3 -3
  435. package/dist/src/imports/productImport.js +2 -2
  436. package/dist/src/imports/runtime.js +1 -1
  437. package/dist/src/infra/gateway-processes.js +2 -2
  438. package/dist/src/infra/path-env.js +3 -3
  439. package/dist/src/infra/update-global.js +9 -9
  440. package/dist/src/knowledge/connected-knowledge-pipeline.js +2 -2
  441. package/dist/src/knowledge/index.js +1 -1
  442. package/dist/src/knowledge-memory/repository.js +1 -1
  443. package/dist/src/local-apps/service.js +2 -2
  444. package/dist/src/mcp/gateway-http-client.js +1 -1
  445. package/dist/src/media-shared/http/provider-http.d.ts +0 -6
  446. package/dist/src/media-shared/http/provider-http.js +5 -4
  447. package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
  448. package/dist/src/media-understanding/runner.d.ts +0 -28
  449. package/dist/src/media-understanding/runner.js +4 -0
  450. package/dist/src/memory-learning/service.js +3 -2
  451. package/dist/src/memory-learning/source-learning.js +4 -4
  452. package/dist/src/memory-learning/task-receipts.js +1 -1
  453. package/dist/src/notes/agent-context.js +4 -4
  454. package/dist/src/notes/index.js +1 -1
  455. package/dist/src/notes/service.js +3 -3
  456. package/dist/src/personal-agent/capability-service.js +2 -2
  457. package/dist/src/personal-agent/proactivity/routes.js +1 -1
  458. package/dist/src/personal-agent/proactivity/service.js +7 -7
  459. package/dist/src/personal-agent/prompt-context.js +7 -7
  460. package/dist/src/personal-agent/prompts.js +1 -1
  461. package/dist/src/personal-agent/reply-composer.js +9 -9
  462. package/dist/src/personal-agent/request-delivery.js +2 -2
  463. package/dist/src/personal-agent/request-service.js +6 -6
  464. package/dist/src/personal-agent/result-reader.js +1 -1
  465. package/dist/src/personal-agent/service.js +1 -1
  466. package/dist/src/personal-agent/task-cancel.js +1 -1
  467. package/dist/src/platform/client.d.ts +1 -1
  468. package/dist/src/platform/contracts.d.ts +1 -1
  469. package/dist/src/platform/index.js +1 -1
  470. package/dist/src/projects/index.js +1 -1
  471. package/dist/src/projects/project-agent-suggestion.js +1 -1
  472. package/dist/src/projects/project-service.js +1 -1
  473. package/dist/src/projects/project-skill-service.js +2 -2
  474. package/dist/src/projects/workspace.js +1 -1
  475. package/dist/src/providers/env-keys.js +3 -0
  476. package/dist/src/providers/extension-stream-bridge.js +3 -0
  477. package/dist/src/providers/index.js +15 -0
  478. package/dist/src/providers/model-call.d.ts +5 -2
  479. package/dist/src/providers/model-call.js +13 -2
  480. package/dist/src/providers/model-reference-auditor.js +2 -1
  481. package/dist/src/providers/model-registry.js +1 -1
  482. package/dist/src/providers/model-response.js +1 -1
  483. package/dist/src/providers/model-usage.d.ts +15 -0
  484. package/dist/src/providers/model-usage.js +50 -0
  485. package/dist/src/providers/presentation.js +8 -0
  486. package/dist/src/providers/setup/engine.d.ts +37 -0
  487. package/dist/src/providers/setup/engine.js +177 -0
  488. package/dist/src/providers/setup/profiles.d.ts +4 -0
  489. package/dist/src/providers/setup/profiles.js +94 -0
  490. package/dist/src/providers/setup/voice.d.ts +23 -0
  491. package/dist/src/providers/setup/voice.js +234 -0
  492. package/dist/src/realtime/runtime.js +1 -1
  493. package/dist/src/remote-access/exposure-manager.js +1 -1
  494. package/dist/src/routing/agent-session-key.js +1 -1
  495. package/dist/src/scenes/agentExecutor.d.ts +1 -0
  496. package/dist/src/scenes/agentExecutor.js +5 -0
  497. package/dist/src/scenes/execution.d.ts +1 -1
  498. package/dist/src/scenes/taskFollowUp/agentExecutor.js +4 -4
  499. package/dist/src/scenes/taskFollowUp/contracts.d.ts +2 -2
  500. package/dist/src/scenes/taskFollowUp/resources.js +2 -2
  501. package/dist/src/scenes/taskFollowUp/service.d.ts +5 -5
  502. package/dist/src/scenes/taskFollowUp/service.js +6 -6
  503. package/dist/src/scenes/templates.d.ts +2 -2
  504. package/dist/src/session/index.js +2 -2
  505. package/dist/src/session/init-session-turn.js +1 -1
  506. package/dist/src/session/resolve-session.js +1 -1
  507. package/dist/src/session/store.js +5 -5
  508. package/dist/src/session/thinking-resolve.js +1 -1
  509. package/dist/src/share/hosted-session-share.js +2 -2
  510. package/dist/src/share/session-share-service.js +1 -1
  511. package/dist/src/share/share-store.js +1 -1
  512. package/dist/src/share/share-thumbnail.js +1 -1
  513. package/dist/src/share/site-share-store.js +1 -1
  514. package/dist/src/storage/sqlite/clarification-wait-repository.d.ts +3 -5
  515. package/dist/src/storage/sqlite/clarification-wait-repository.js +48 -28
  516. package/dist/src/storage/sqlite/connection.js +9 -9
  517. package/dist/src/storage/sqlite/migrations/253_discussion_processing_recovery.sql +20 -0
  518. package/dist/src/storage/sqlite/migrations/254_discussion_annotations.sql +17 -0
  519. package/dist/src/storage/sqlite/migrations/255_discussion_chapter_progress.sql +10 -0
  520. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  521. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  522. package/dist/src/storage/sqlite/schema.js +1 -1
  523. package/dist/src/tasks/capabilities/management.d.ts +2 -2
  524. package/dist/src/tasks/capabilities/read.js +2 -2
  525. package/dist/src/tasks/capabilities/relations.d.ts +6 -6
  526. package/dist/src/tasks/capabilities/write.d.ts +6 -6
  527. package/dist/src/tasks/capabilities/write.js +1 -1
  528. package/dist/src/tasks/home-query-service.js +2 -2
  529. package/dist/src/tasks/index.js +4 -4
  530. package/dist/src/tasks/task-allocation-service.js +5 -5
  531. package/dist/src/tasks/task-application-service.js +6 -6
  532. package/dist/src/tasks/task-collaboration-delivery.js +1 -1
  533. package/dist/src/tasks/task-context-assembler.js +2 -2
  534. package/dist/src/tasks/task-handoff-service.js +1 -1
  535. package/dist/src/tasks/task-handoff.js +5 -5
  536. package/dist/src/tasks/task-main-update-decision-service.js +3 -3
  537. package/dist/src/tasks/task-model-call.js +1 -1
  538. package/dist/src/tasks/task-research-result.js +4 -4
  539. package/dist/src/tasks/task-result-delivery-repository.js +1 -1
  540. package/dist/src/tasks/task-result-delivery-service.js +2 -2
  541. package/dist/src/tasks/task-run-coordinator.js +4 -4
  542. package/dist/src/tasks/task-run-dispatcher.js +1 -1
  543. package/dist/src/tui/backends/embedded-backend.js +13 -13
  544. package/dist/src/tui/backends/gateway-realtime-backend.js +2 -2
  545. package/dist/src/tui/extension-host/load-extensions.js +2 -2
  546. package/dist/src/tui/tui-agent-events.js +1 -1
  547. package/dist/src/tui/tui-commands.js +5 -5
  548. package/dist/src/tui/tui-picker-overlay.js +1 -1
  549. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  550. package/dist/src/tui/tui-startup-resources.js +4 -4
  551. package/dist/src/tui/tui.js +6 -6
  552. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  553. package/dist/src/usage/recorder.js +2 -1
  554. package/dist/src/usage/scenario-registry.js +128 -123
  555. package/dist/src/user-context/access-policy.js +2 -2
  556. package/dist/src/user-context/config.d.ts +2 -2
  557. package/dist/src/user-model/bootstrap.js +1 -1
  558. package/dist/src/user-model/capture/executor.js +1 -1
  559. package/dist/src/user-model/capture/semantic.d.ts +8 -1
  560. package/dist/src/user-model/capture/semantic.js +26 -5
  561. package/dist/src/user-model/index.js +2 -2
  562. package/dist/src/voice/dashscope/streaming-stt-session.js +3 -0
  563. package/dist/src/voice/dashscope/streaming-tts-stream.js +3 -0
  564. package/dist/src/voice/dictation.d.ts +12 -0
  565. package/dist/src/voice/dictation.js +22 -0
  566. package/dist/src/voice/metadata/builtin.js +54 -0
  567. package/dist/src/voice/platform-streams.js +3 -0
  568. package/dist/src/voice/realtime/agentEngine.js +4 -2
  569. package/dist/src/voice/realtime/memory-context.js +7 -7
  570. package/dist/src/voice/realtime/omniEngine.js +5 -2
  571. package/dist/src/voice/realtime/omniRoute.js +3 -2
  572. package/dist/src/voice/realtime/runtime.js +8 -6
  573. package/dist/src/voice/stt/factory.js +9 -3
  574. package/dist/src/voice/stt/index.js +2 -2
  575. package/dist/src/voice/stt/preflight.js +1 -1
  576. package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
  577. package/dist/src/voice/stt/providers/bailian-plan-transcription.d.ts +2 -0
  578. package/dist/src/voice/stt/providers/bailian-plan-transcription.js +32 -0
  579. package/dist/src/voice/stt/providers/index.d.ts +1 -0
  580. package/dist/src/voice/stt/providers/index.js +2 -1
  581. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
  582. package/dist/src/voice/stt/transcribe-core.js +1 -1
  583. package/dist/src/voice/token-plan.d.ts +8 -0
  584. package/dist/src/voice/token-plan.js +11 -0
  585. package/dist/src/voice/tts/factory.js +4 -1
  586. package/dist/src/voice/tts/index.js +3 -3
  587. package/dist/src/voice/tts/merge-config.js +1 -1
  588. package/dist/src/voice/tts/payload.js +1 -1
  589. package/dist/src/voice/tts/providers/bailian-plan-speech.d.ts +2 -0
  590. package/dist/src/voice/tts/providers/bailian-plan-speech.js +84 -0
  591. package/dist/src/voice/tts/providers/index.d.ts +1 -0
  592. package/dist/src/voice/tts/providers/index.js +2 -1
  593. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
  594. package/dist/src/voice/tts/speak-core.js +11 -2
  595. package/dist/src/work-discovery/incremental-repository.js +1 -1
  596. package/dist/src/work-discovery/service.js +7 -7
  597. package/dist/src/workflows/context/workflow-context.js +1 -1
  598. package/dist/src/workflows/engine/workflow-engine.js +1 -1
  599. package/dist/src/workflows/service/workflow-run-service.js +7 -7
  600. package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
  601. package/package.json +2 -2
  602. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-2VA4eKPf.js +0 -1
  603. package/dist/gateway/static/root/assets/agent-plugin-dialog-DRhTOw_O.js +0 -1
  604. package/dist/gateway/static/root/assets/agents-BemUH_Yf.js +0 -77
  605. package/dist/gateway/static/root/assets/app-management-settings-panel-CR_cc7rj.js +0 -1
  606. package/dist/gateway/static/root/assets/automations-workspace-DOwtT4sS.js +0 -6
  607. package/dist/gateway/static/root/assets/browser-automations-page-B-Ezk_8l.js +0 -3
  608. package/dist/gateway/static/root/assets/browser-settings-page-BSmmTBn4.js +0 -3
  609. package/dist/gateway/static/root/assets/capabilities-page-xZgTYYDn.js +0 -2
  610. package/dist/gateway/static/root/assets/capabilities-settings-panel-oqkuOjcR.js +0 -8
  611. package/dist/gateway/static/root/assets/channels-Dq2C2k9M.js +0 -1
  612. package/dist/gateway/static/root/assets/chat-terminal-dock-srB_M-aQ.js +0 -36
  613. package/dist/gateway/static/root/assets/connectors-page-BZk-Gou5.js +0 -1
  614. package/dist/gateway/static/root/assets/device-pairing-wizard-CvZpnSVw.js +0 -1
  615. package/dist/gateway/static/root/assets/extension-settings-page-1tbWe5xQ.js +0 -1
  616. package/dist/gateway/static/root/assets/fallback-models-CW6a1-GK.js +0 -1
  617. package/dist/gateway/static/root/assets/gateway-realtime-store-BVriF6Zj.js +0 -1
  618. package/dist/gateway/static/root/assets/gateway-settings-vQWTUx2c.js +0 -1
  619. package/dist/gateway/static/root/assets/home-page-hfWuVtcG.js +0 -2
  620. package/dist/gateway/static/root/assets/image-generation-api-DodU6GNC.js +0 -1
  621. package/dist/gateway/static/root/assets/imports-page-CuR6RSUM.js +0 -1
  622. package/dist/gateway/static/root/assets/index-CNH8vwcY.js +0 -260
  623. package/dist/gateway/static/root/assets/index-DBRwvWzm.css +0 -1
  624. package/dist/gateway/static/root/assets/logs-page-CSlZT1-L.js +0 -2
  625. package/dist/gateway/static/root/assets/management-settings-BYCL5CwV.js +0 -1
  626. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-i9N5shss.js +0 -1
  627. package/dist/gateway/static/root/assets/messages-DTqbfje6.js +0 -3
  628. package/dist/gateway/static/root/assets/models-hub-cache-Ct6X5zmB.js +0 -1
  629. package/dist/gateway/static/root/assets/note-detail-panel-CJ5Earr_.js +0 -5
  630. package/dist/gateway/static/root/assets/notes-page-CPGk8-n1.js +0 -8
  631. package/dist/gateway/static/root/assets/personal-page-BjTt5R3s.js +0 -1
  632. package/dist/gateway/static/root/assets/project-detail-page-CyKx4PyN.js +0 -1
  633. package/dist/gateway/static/root/assets/projects-page--_hXxUMC.js +0 -1
  634. package/dist/gateway/static/root/assets/remote-access-hub-Bq_eqQYf.js +0 -1
  635. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-BgCATci5.js +0 -1
  636. package/dist/gateway/static/root/assets/scenes-page-DxE3jRPR.js +0 -2
  637. package/dist/gateway/static/root/assets/session-manager-COd9RECl.js +0 -16
  638. package/dist/gateway/static/root/assets/sessions-page-CQkGFnJM.js +0 -1
  639. package/dist/gateway/static/root/assets/settings-advanced-gate-Dtlsvsci.js +0 -1
  640. package/dist/gateway/static/root/assets/settings-loading-skeleton-BTqvr_Fw.js +0 -1
  641. package/dist/gateway/static/root/assets/setup-status-panel-CrAazq4r.js +0 -1
  642. package/dist/gateway/static/root/assets/shares-settings-BNMhs-Vd.js +0 -1
  643. package/dist/gateway/static/root/assets/skills-page-XVOxILQn.js +0 -2
  644. package/dist/gateway/static/root/assets/user-model-page-C1QX47VR.js +0 -2
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./globe-DSSGFWFn.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./messages-DTqbfje6.js";import{a as l,n as u,r as d}from"./locale-store-uRu_DsWm.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-aIC072nz.js";import{r as m}from"./gateway-config-swr-D0tBjSgj.js";import{n as h,t as g}from"./registry-api-CYqA7bfl.js";import{t as _}from"./skeleton-BI5TyibZ.js";import{t as v}from"./electron-env-Dit0bHgy.js";import{Ho as y,Po as b,Xr as x,_n as S,_s as C,vn as w,vs as T}from"./index-CNH8vwcY.js";import{n as ee,r as te}from"./settings-page-layout-Dx5S-Msc.js";var E=n(),D=e(t(),1),O=r();function ne({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=f(`settings-agent-defaults`,S),r=f(g,h),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,D.useState)(a),[l,u]=(0,D.useState)(!1),[d,m]=(0,D.useState)(``),[v,y]=(0,D.useState)(!1);(0,D.useEffect)(()=>{s(a)},[a]);let b=!o||r.data?.some(e=>e.id===o&&e.computerUse),C=async()=>{u(!0),m(``),y(!1);try{if(!b)throw Error(t.modelUnavailable);let e=await S(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await w({...e.defaults,models:r});await n.mutate(i,!1),y(!0)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,O.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,O.jsx)(_,{className:`h-52 w-full rounded-xl`}):n.error?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,O.jsx)(p,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,O.jsx)(_,{className:`h-11 w-full rounded-lg`}):(0,O.jsx)(x,{value:o,onChange:e=>{s(e),y(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,O.jsx)(p,{variant:`primary`,disabled:l||o===a||!b||!!r.error||r.isLoading,onClick:()=>{C()},children:t.saveModel})]}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{children:t.modelDataUse}),(0,O.jsx)(p,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,O.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,O.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!b&&!r.isLoading&&!r.error&&(0,O.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,O.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,O.jsx)(p,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),d&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:d})]})]})}function k(e){let t=(0,E.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,O.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,O.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,O.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,O.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,E.c)(2),t=u(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,O.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:u}=m(!0),f=n?.payload?.config,[h,g]=(0,D.useState)(!1),[x,S]=(0,D.useState)(``),[w,E]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(!1),[P,F]=(0,D.useState)(null),[re,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(``),[z,B]=(0,D.useState)(!1),[ie,V]=(0,D.useState)(!1),H=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,U=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,D.useEffect)(()=>{if(!H)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await H.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[H]),(0,D.useEffect)(()=>{if(!H?.access)return;let e=!1;return H.access().then(t=>{e||(F(t),I(!1))}).catch(()=>{e||I(!0)}),()=>{e=!0}},[H]);let W=async e=>{g(!0),S(``);try{await e()}catch(e){S(e instanceof Error?e.message:String(e))}finally{g(!1)}},ae=e=>W(async()=>{v()&&(await l(d(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),G=async()=>{S(``),E(!1);try{await H?.stop(),E(!0),H&&j(await H.status())}catch(e){S(e instanceof Error?e.message:String(e))}},K=A?.session?.status??`idle`,q=t.states[K]??K,J=v()&&f?.computer?.enabled===!0,oe=A?.controlPaused?t.pausedNotice:J?A?.connected?`${t.connected} · ${q}`:A?t.disconnected:t.checking:t.disabled,Y=!H||M||A?.reenrollmentRequired===!0||!!(A?.error||A?.session?.errorCode)||A!=null&&(!A.permissions.accessibility||A.permissions.screenRecording!==`granted`),X=A?.permissions.accessibility===!0&&A.permissions.screenRecording===`granted`&&!A.reenrollmentRequired,Z=P?.apps.filter(e=>P.authorizedAppIds.includes(e.appId))??[],Q=P?.apps.filter(e=>!P.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(L.toLocaleLowerCase()))??[],$=(0,O.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),H?M?(0,O.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?X&&!ie?(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(k,{icon:(0,O.jsx)(y,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,O.jsx)(p,{onClick:()=>V(!0),children:t.viewDetails})})}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(k,{icon:(0,O.jsx)(T,{className:`size-5`}),title:t.device,description:(0,O.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,q]}),children:A.reenrollmentRequired&&(0,O.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{j(await H.reenroll())})},children:t.reenroll})}),U&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(k,{icon:(0,O.jsx)(y,{className:`size-5`}),title:t.accessibility,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,O.jsx)(p,{disabled:h,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{W(()=>U.requestAccessibility())},children:t.openSettings})]}),(0,O.jsxs)(k,{icon:(0,O.jsx)(T,{className:`size-5`}),title:t.screen,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,O.jsx)(p,{disabled:h,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{W(()=>U.requestScreen())},children:t.openSettings})]})]}),X&&(0,O.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,O.jsx)(p,{variant:`ghost`,onClick:()=>V(!1),children:t.hideDetails})})]}):(0,O.jsx)(`div`,{"aria-label":t.checking,children:(0,O.jsx)(_,{className:`h-20 w-full rounded-xl`})}):(0,O.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,O.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]});return(0,O.jsxs)(te,{gap:`gap-7`,children:[(0,O.jsx)(ee,{title:t.title,subtitle:t.subtitle,meta:(0,O.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:H&&(0,O.jsxs)(p,{onClick:()=>{G()},children:[(0,O.jsx)(b,{className:`size-3.5`}),t.stop]})}),x&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:x}),w&&(0,O.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,O.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!f&&!u?(0,O.jsx)(_,{className:`h-32 w-full rounded-xl`}):u?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(u),` `,(0,O.jsx)(p,{onClick:()=>{W(()=>r())},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(k,{icon:(0,O.jsx)(C,{className:`size-5`}),title:t.desktop,description:(0,O.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:h||!v(),onClick:()=>{ae(f?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,O.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),A?.controlPaused&&(0,O.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,O.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{H&&j(await H.resume()),E(!1)})},children:t.resume})})]})]}),Y&&$,H?.access&&(0,O.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!P?.allowAllApps&&(0,O.jsxs)(p,{disabled:h,"aria-expanded":z,"aria-controls":z?`computer-app-picker`:void 0,onClick:()=>{B(e=>!e),R(``)},children:[z?(0,O.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,O.jsx)(s,{className:`size-4`,"aria-hidden":!0}),z?t.doneAdding:t.addApp]})]}),P?(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(k,{icon:(0,O.jsx)(C,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":P.allowAllApps===!0,disabled:h,onClick:()=>{W(async()=>{F(await H.setAllAppAccess(!P.allowAllApps)),B(!1)})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,O.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${P.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${P.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!P.allowAllApps&&(0,O.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(p,{disabled:h,variant:`ghost`,onClick:()=>{W(async()=>{let t=await H.setAppAccess(e.appId,!1);F(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,O.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):re?(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,O.jsx)(_,{className:`h-20 w-full rounded-xl`}),z&&!P?.allowAllApps&&(0,O.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{"aria-label":t.searchApps,value:L,onChange:e=>R(e.target.value),placeholder:t.searchApps,className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,O.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{F(await H.access()),I(!1)})},children:t.refreshApps})]}),P&&(0,O.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(p,{disabled:h,variant:`secondary`,onClick:()=>{W(async()=>{let t=await H.setAppAccess(e.appId,!0);F(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,O.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:P.appsBusy?t.appsBusy:P.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,O.jsx)(ne,{zh:e}),!Y&&$,(0,O.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(k,{icon:(0,O.jsx)(o,{className:`size-5`}),title:t.browser,description:f?f.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,O.jsx)(p,{asChild:!0,children:(0,O.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./globe-DSSGFWFn.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./messages-O0BEUKnx.js";import{a as l,n as u,r as d}from"./locale-store-DMy9W6IG.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-aIC072nz.js";import{r as m}from"./gateway-config-swr-CmYcOqhb.js";import{n as h,t as g}from"./registry-api-CgQrCqL6.js";import{t as _}from"./skeleton-BI5TyibZ.js";import{t as v}from"./electron-env-Dit0bHgy.js";import{As as y,Rn as b,_i as x,js as S,qo as C,ts as w,zn as T}from"./index-xTL-vb51.js";import{n as ee,r as te}from"./settings-page-layout-Dx5S-Msc.js";var E=n(),D=e(t(),1),O=r();function ne({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=f(`settings-agent-defaults`,b),r=f(g,h),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,D.useState)(a),[l,u]=(0,D.useState)(!1),[d,m]=(0,D.useState)(``),[v,y]=(0,D.useState)(!1);(0,D.useEffect)(()=>{s(a)},[a]);let S=!o||r.data?.some(e=>e.id===o&&e.computerUse),C=async()=>{u(!0),m(``),y(!1);try{if(!S)throw Error(t.modelUnavailable);let e=await b(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await T({...e.defaults,models:r});await n.mutate(i,!1),y(!0)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,O.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,O.jsx)(_,{className:`h-52 w-full rounded-xl`}):n.error?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,O.jsx)(p,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,O.jsx)(_,{className:`h-11 w-full rounded-lg`}):(0,O.jsx)(x,{value:o,onChange:e=>{s(e),y(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,O.jsx)(p,{variant:`primary`,disabled:l||o===a||!S||!!r.error||r.isLoading,onClick:()=>{C()},children:t.saveModel})]}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{children:t.modelDataUse}),(0,O.jsx)(p,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,O.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,O.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!S&&!r.isLoading&&!r.error&&(0,O.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,O.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,O.jsx)(p,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),d&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:d})]})]})}function k(e){let t=(0,E.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,O.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,O.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,O.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,O.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,E.c)(2),t=u(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,O.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:u}=m(!0),f=n?.payload?.config,[h,g]=(0,D.useState)(!1),[b,x]=(0,D.useState)(``),[T,E]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(!1),[P,F]=(0,D.useState)(null),[re,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(``),[z,B]=(0,D.useState)(!1),[ie,V]=(0,D.useState)(!1),H=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,U=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,D.useEffect)(()=>{if(!H)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await H.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[H]),(0,D.useEffect)(()=>{if(!H?.access)return;let e=!1;return H.access().then(t=>{e||(F(t),I(!1))}).catch(()=>{e||I(!0)}),()=>{e=!0}},[H]);let W=async e=>{g(!0),x(``);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}},ae=e=>W(async()=>{v()&&(await l(d(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),G=async()=>{x(``),E(!1);try{await H?.stop(),E(!0),H&&j(await H.status())}catch(e){x(e instanceof Error?e.message:String(e))}},K=A?.session?.status??`idle`,q=t.states[K]??K,J=v()&&f?.computer?.enabled===!0,oe=A?.controlPaused?t.pausedNotice:J?A?.connected?`${t.connected} · ${q}`:A?t.disconnected:t.checking:t.disabled,Y=!H||M||A?.reenrollmentRequired===!0||!!(A?.error||A?.session?.errorCode)||A!=null&&(!A.permissions.accessibility||A.permissions.screenRecording!==`granted`),X=A?.permissions.accessibility===!0&&A.permissions.screenRecording===`granted`&&!A.reenrollmentRequired,Z=P?.apps.filter(e=>P.authorizedAppIds.includes(e.appId))??[],Q=P?.apps.filter(e=>!P.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(L.toLocaleLowerCase()))??[],$=(0,O.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),H?M?(0,O.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?X&&!ie?(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(k,{icon:(0,O.jsx)(w,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,O.jsx)(p,{onClick:()=>V(!0),children:t.viewDetails})})}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(k,{icon:(0,O.jsx)(S,{className:`size-5`}),title:t.device,description:(0,O.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,q]}),children:A.reenrollmentRequired&&(0,O.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{j(await H.reenroll())})},children:t.reenroll})}),U&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(k,{icon:(0,O.jsx)(w,{className:`size-5`}),title:t.accessibility,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,O.jsx)(p,{disabled:h,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{W(()=>U.requestAccessibility())},children:t.openSettings})]}),(0,O.jsxs)(k,{icon:(0,O.jsx)(S,{className:`size-5`}),title:t.screen,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,O.jsx)(p,{disabled:h,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{W(()=>U.requestScreen())},children:t.openSettings})]})]}),X&&(0,O.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,O.jsx)(p,{variant:`ghost`,onClick:()=>V(!1),children:t.hideDetails})})]}):(0,O.jsx)(`div`,{"aria-label":t.checking,children:(0,O.jsx)(_,{className:`h-20 w-full rounded-xl`})}):(0,O.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,O.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]});return(0,O.jsxs)(te,{gap:`gap-7`,children:[(0,O.jsx)(ee,{title:t.title,subtitle:t.subtitle,meta:(0,O.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:H&&(0,O.jsxs)(p,{onClick:()=>{G()},children:[(0,O.jsx)(C,{className:`size-3.5`}),t.stop]})}),b&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:b}),T&&(0,O.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,O.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!f&&!u?(0,O.jsx)(_,{className:`h-32 w-full rounded-xl`}):u?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(u),` `,(0,O.jsx)(p,{onClick:()=>{W(()=>r())},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(k,{icon:(0,O.jsx)(y,{className:`size-5`}),title:t.desktop,description:(0,O.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:h||!v(),onClick:()=>{ae(f?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,O.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),A?.controlPaused&&(0,O.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,O.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{H&&j(await H.resume()),E(!1)})},children:t.resume})})]})]}),Y&&$,H?.access&&(0,O.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!P?.allowAllApps&&(0,O.jsxs)(p,{disabled:h,"aria-expanded":z,"aria-controls":z?`computer-app-picker`:void 0,onClick:()=>{B(e=>!e),R(``)},children:[z?(0,O.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,O.jsx)(s,{className:`size-4`,"aria-hidden":!0}),z?t.doneAdding:t.addApp]})]}),P?(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(k,{icon:(0,O.jsx)(y,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":P.allowAllApps===!0,disabled:h,onClick:()=>{W(async()=>{F(await H.setAllAppAccess(!P.allowAllApps)),B(!1)})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,O.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${P.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${P.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!P.allowAllApps&&(0,O.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(p,{disabled:h,variant:`ghost`,onClick:()=>{W(async()=>{let t=await H.setAppAccess(e.appId,!1);F(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,O.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):re?(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,O.jsx)(_,{className:`h-20 w-full rounded-xl`}),z&&!P?.allowAllApps&&(0,O.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{"aria-label":t.searchApps,value:L,onChange:e=>R(e.target.value),placeholder:t.searchApps,className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,O.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{F(await H.access()),I(!1)})},children:t.refreshApps})]}),P&&(0,O.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(p,{disabled:h,variant:`secondary`,onClick:()=>{W(async()=>{let t=await H.setAppAccess(e.appId,!0);F(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,O.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:P.appsBusy?t.appsBusy:P.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,O.jsx)(ne,{zh:e}),!Y&&$,(0,O.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(k,{icon:(0,O.jsx)(o,{className:`size-5`}),title:t.browser,description:f?f.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,O.jsx)(p,{asChild:!0,children:(0,O.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
@@ -1 +1 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as o}from"./secret-input-BxWHx6J6.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-DTqbfje6.js";import{n as l}from"./locale-store-uRu_DsWm.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-aIC072nz.js";import{t as b}from"./skeleton-BI5TyibZ.js";import{Ca as x,Ga as S,Ha as C,Nt as w,Pa as T,Wo as E,ui as D}from"./index-CNH8vwcY.js";var O=t({ConnectorServiceDialog:()=>I,ConnectorServicePage:()=>M}),k=r(),A=e(n(),1),j=i();function M(){let e=(0,k.c)(11),t=l(N),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let s=i?`应用连接服务`:`App connection service`,u;e[4]===s?u=e[5]:(u=(0,j.jsx)(`h1`,{className:`text-xl font-semibold`,children:s}),e[4]=s,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),f=(0,j.jsx)(R,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function N(e){return e.language}function P(){let e=(0,k.c)(2),t=l(F)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,j.jsx)(j.Fragment,{children:t}),e[0]=t,e[1]=n),n}function F(e){return e.language}function I(e){let t=(0,k.c)(27),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{open:r,onOpenChange:i,hideTrigger:a}=n,o=a===void 0?!1:a,v=l(L),b;t[2]===v?b=t[3]:(b=c(v),t[2]=v,t[3]=b);let x=b.connectorsSettings,S=v===`zh`,C;t[4]!==o||t[5]!==S?(C=o?null:(0,j.jsx)(d,{asChild:!0,children:(0,j.jsxs)(y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=o,t[5]=S,t[6]=C):C=t[6];let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,j.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=w):w=t[7];let T=S?`应用连接服务`:`App connection service`,D;t[8]===T?D=t[9]:(D=(0,j.jsx)(g,{className:`text-base font-semibold text-fg`,children:T}),t[8]=T,t[9]=D);let O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,j.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),t[10]=O):O=t[10];let A;t[11]===D?A=t[12]:(A=(0,j.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[11]=D,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,j.jsx)(s,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===x.modalClose?N=t[15]:(N=(0,j.jsx)(p,{asChild:!0,children:(0,j.jsx)(y,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":x.modalClose,children:M})}),t[14]=x.modalClose,t[15]=N);let F;t[16]!==N||t[17]!==A?(F=(0,j.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[A,N]}),t[16]=N,t[17]=A,t[18]=F):F=t[18];let I;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,j.jsx)(R,{})}),t[19]=I):I=t[19];let z;t[20]===F?z=t[21]:(z=(0,j.jsxs)(m,{children:[w,(0,j.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[F,I]})]}),t[20]=F,t[21]=z);let B;return t[22]!==i||t[23]!==r||t[24]!==z||t[25]!==C?(B=(0,j.jsxs)(_,{open:r,onOpenChange:i,children:[C,z]}),t[22]=i,t[23]=r,t[24]=z,t[25]=C,t[26]=B):B=t[26],B}function L(e){return e.language}function R(){let e=l(e=>e.language),t=c(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=v(`connector-service`,T),[s,u]=(0,A.useState)(``),[d,f]=(0,A.useState)(!1),[p,m]=(0,A.useState)(),[h,g]=(0,A.useState)();async function _(e){f(!0),m(void 0);try{await e(),u(``),await a()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(b,{className:`h-40 w-full`}):null,r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,j.jsx)(w,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(y,{variant:`secondary`,disabled:d||r.mode===`managed`&&r.configured,onClick:()=>void _(()=>S({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,j.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,j.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,j.jsx)(`li`,{children:t.composioSetupStepProject}),(0,j.jsx)(`li`,{children:t.composioSetupStepKey}),(0,j.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,j.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,j.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,j.jsx)(`span`,{children:`Composio API key`}),(0,j.jsx)(o,{value:s,onChange:u,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(y,{disabled:d||!s.trim(),onClick:()=>void _(()=>x(s)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{children:e.label}),(0,j.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,j.jsx)(y,{variant:`ghost`,disabled:d||!s.trim()||e.credentialSource===`environment`,onClick:()=>void _(()=>x(s,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(y,{variant:`ghost`,disabled:d||e.id===r.backendId,onClick:()=>void _(()=>S({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(y,{variant:`ghost`,disabled:d||e.id===r.backendId,onClick:()=>g(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,p||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p??String(i)}):null,(0,j.jsx)(D,{open:!!h,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>g(void 0),onConfirm:()=>{let e=h;g(void 0),e&&_(()=>C(e))}})]})}export{O as n,I as t};
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as o}from"./secret-input-BxWHx6J6.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-O0BEUKnx.js";import{n as l}from"./locale-store-DMy9W6IG.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-BGTk37IG.js";import{i as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-aIC072nz.js";import{t as b}from"./skeleton-BI5TyibZ.js";import{Dt as x,Ia as S,io as C,ji as w,qa as T,rs as E,to as D}from"./index-xTL-vb51.js";var O=t({ConnectorServiceDialog:()=>I,ConnectorServicePage:()=>M}),k=r(),A=e(n(),1),j=i();function M(){let e=(0,k.c)(11),t=l(N),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let s=i?`应用连接服务`:`App connection service`,u;e[4]===s?u=e[5]:(u=(0,j.jsx)(`h1`,{className:`text-xl font-semibold`,children:s}),e[4]=s,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),f=(0,j.jsx)(R,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function N(e){return e.language}function P(){let e=(0,k.c)(2),t=l(F)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,j.jsx)(j.Fragment,{children:t}),e[0]=t,e[1]=n),n}function F(e){return e.language}function I(e){let t=(0,k.c)(27),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{open:r,onOpenChange:i,hideTrigger:a}=n,o=a===void 0?!1:a,v=l(L),b;t[2]===v?b=t[3]:(b=c(v),t[2]=v,t[3]=b);let x=b.connectorsSettings,S=v===`zh`,C;t[4]!==o||t[5]!==S?(C=o?null:(0,j.jsx)(d,{asChild:!0,children:(0,j.jsxs)(y,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=o,t[5]=S,t[6]=C):C=t[6];let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,j.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=w):w=t[7];let T=S?`应用连接服务`:`App connection service`,D;t[8]===T?D=t[9]:(D=(0,j.jsx)(g,{className:`text-base font-semibold text-fg`,children:T}),t[8]=T,t[9]=D);let O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,j.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),t[10]=O):O=t[10];let A;t[11]===D?A=t[12]:(A=(0,j.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[11]=D,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,j.jsx)(s,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===x.modalClose?N=t[15]:(N=(0,j.jsx)(p,{asChild:!0,children:(0,j.jsx)(y,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":x.modalClose,children:M})}),t[14]=x.modalClose,t[15]=N);let F;t[16]!==N||t[17]!==A?(F=(0,j.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[A,N]}),t[16]=N,t[17]=A,t[18]=F):F=t[18];let I;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,j.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,j.jsx)(R,{})}),t[19]=I):I=t[19];let z;t[20]===F?z=t[21]:(z=(0,j.jsxs)(m,{children:[w,(0,j.jsxs)(h,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[F,I]})]}),t[20]=F,t[21]=z);let B;return t[22]!==i||t[23]!==r||t[24]!==z||t[25]!==C?(B=(0,j.jsxs)(_,{open:r,onOpenChange:i,children:[C,z]}),t[22]=i,t[23]=r,t[24]=z,t[25]=C,t[26]=B):B=t[26],B}function L(e){return e.language}function R(){let e=l(e=>e.language),t=c(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=v(`connector-service`,T),[s,u]=(0,A.useState)(``),[d,f]=(0,A.useState)(!1),[p,m]=(0,A.useState)(),[h,g]=(0,A.useState)();async function _(e){f(!0),m(void 0);try{await e(),u(``),await a()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(b,{className:`h-40 w-full`}):null,r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,j.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,j.jsx)(x,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(y,{variant:`secondary`,disabled:d||r.mode===`managed`&&r.configured,onClick:()=>void _(()=>C({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,j.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,j.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,j.jsx)(`li`,{children:t.composioSetupStepProject}),(0,j.jsx)(`li`,{children:t.composioSetupStepKey}),(0,j.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,j.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,j.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,j.jsx)(`span`,{children:`Composio API key`}),(0,j.jsx)(o,{value:s,onChange:u,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(y,{disabled:d||!s.trim(),onClick:()=>void _(()=>S(s)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`p`,{children:e.label}),(0,j.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,j.jsx)(y,{variant:`ghost`,disabled:d||!s.trim()||e.credentialSource===`environment`,onClick:()=>void _(()=>S(s,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(y,{variant:`ghost`,disabled:d||e.id===r.backendId,onClick:()=>void _(()=>C({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(y,{variant:`ghost`,disabled:d||e.id===r.backendId,onClick:()=>g(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,p||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p??String(i)}):null,(0,j.jsx)(w,{open:!!h,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>g(void 0),onConfirm:()=>{let e=h;g(void 0),e&&_(()=>D(e))}})]})}export{O as n,I as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{_ as i,p as a}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as o}from"./chevron-right-BweFrslA.js";import{n as s,r as c,t as l}from"./popover-select-DHC7J4lG.js";import{t as u}from"./circle-alert-BEjgurr2.js";import{t as d}from"./circle-check-C23XjkUj.js";import{t as f}from"./clock-3-DnrAnuyZ.js";import{t as p}from"./ellipsis-0k4rZLoy.js";import{t as m}from"./external-link-DjqjBmc3.js";import{n as h}from"./secret-input-BxWHx6J6.js";import{t as g}from"./eye-CABVeTq0.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./plus-Q2yW6OE7.js";import{t as y}from"./x-B_N4OPjy.js";import{t as b}from"./messages-O0BEUKnx.js";import{t as x}from"./cn-0WouolD0.js";import{a as S,c as C,n as w,r as T}from"./locale-store-DMy9W6IG.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./dist-BGTk37IG.js";import{r as N}from"./extension-provider-DWI0KAKT.js";import{n as P}from"./copy-to-clipboard-HOJ79TWv.js";import{t as F}from"./button-aIC072nz.js";import{n as I}from"./interaction-BdhHBbYa.js";import{n as L,r as R}from"./gateway-config-swr-CmYcOqhb.js";import{s as z}from"./form-field-width-DJw_jULe.js";import{t as B}from"./skeleton-BI5TyibZ.js";import{n as V}from"./electron-env-Dit0bHgy.js";import{$ as H,$a as U,$n as W,Ba as G,Ca as K,Ec as q,Es as ee,Ga as te,Ha as ne,Ic as re,Io as J,Ja as ie,Ka as ae,La as oe,Q as se,Qa as Y,Qn as ce,Ra as le,To as ue,Ua as de,Uc as fe,Uo as X,Va as pe,Wa as me,X as he,Xa as ge,Xn as _e,Ya as ve,Z as ye,Za as be,Zn as xe,ao as Se,ar as Ce,co as Z,do as we,ec as Te,eo as Ee,et as De,fo as Oe,ho as ke,ir as Ae,is as je,ji as Me,lo as Ne,ls as Pe,mo as Fe,no as Ie,nr as Le,nt as Re,oo as ze,po as Be,ro as Ve,rr as He,rs as Ue,so as We,sr as Ge,ss as Ke,tt as qe,uo as Je,za as Ye}from"./index-xTL-vb51.js";import{n as Xe,t as Ze}from"./capability-header-actions-D9uGs4Pw.js";import{t as Qe}from"./connector-service-page-Dp35XdYf.js";import{t as $e}from"./page-tabs-HLrKIjXH.js";import{n as et}from"./agent-plugin-dialog-CNc6ntzP.js";import{t as tt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),nt=n(),$=r();function rt(e){let t=(0,nt.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(it),m=e.slice(0,2),h=Math.max(0,e.length-m.length),g=o.connect,_;t[11]!==n||t[12]!==o?(_=H(n,o),t[11]=n,t[12]=o,t[13]=_):_=t[13];let v=_,y=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,b;t[14]!==g||t[15]!==n||t[16]!==i?(b=e=>(0,$.jsxs)(F,{type:`button`,variant:`primary`,className:x(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(ee,{className:`size-4`}),g]}),t[14]=g,t[15]=n,t[16]=i,t[17]=b):b=t[17],s=b,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(Re,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===y?w=t[24]:(w=y?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:y}):null,t[23]=y,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==s?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==o.connectedBadge?(O=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=O):O=t[36];let k;t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],t[40]!==E||t[41]!==k?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,k]}),t[40]=E,t[41]=k,t[42]=l):l=t[42],t[43]===v?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:v,children:v}),t[43]=v,t[44]=u),f=m.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),h>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,h]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10];let m;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[45]=c,t[46]=l,t[47]=u,t[48]=f,t[49]=m):m=t[49];let h;t[50]!==r||t[51]!==s?(h=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=h):h=t[52];let g;return t[53]!==p||t[54]!==m||t[55]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g):g=t[56],g}function it(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var at=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ot(e,t){return t.some(t=>t.connectorId===e.id)}var st=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ct(){let e=(0,nt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:x(`size-10 shrink-0 rounded-xl`,st)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:x(`h-4 min-w-0 flex-1`,st)}),(0,$.jsx)(`div`,{className:x(`h-8 w-[4.5rem] shrink-0 rounded-lg`,st)})]}),(0,$.jsx)(`div`,{className:x(`h-3 w-full`,st)}),(0,$.jsx)(`div`,{className:x(`h-3 w-[88%]`,st)})]})]})}),e[1]=n):n=e[1],n}var lt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ut(){let e=(0,nt.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:x(`size-10 shrink-0 rounded-xl`,lt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:x(`h-4 w-48 max-w-full`,lt)}),(0,$.jsx)(`div`,{className:x(`h-3 w-72 max-w-full`,lt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:x(`h-9 w-20 rounded-lg`,lt)}),(0,$.jsx)(`div`,{className:x(`h-9 w-20 rounded-lg`,lt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:x(`h-8 w-20 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:x(`h-8 w-24 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:x(`h-8 w-28 rounded-md`,lt)})]}),(0,$.jsx)(`div`,{className:x(`mt-3 h-20 rounded-xl`,lt)})]}),e[3]=i):i=e[3],i}var dt=[`understand`,`act`,`reach`];function ft(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function pt(e){return ft(e)[0]??`act`}function mt(e,t){let n=t?pt(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function ht(e,t){return t.connectorCapabilityLabels[e]??e}function gt(e,t){if(e.runtime.type===`mcp`)return De(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return De(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function _t(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function vt(e){let t=(0,nt.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=H(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,f,p,m,h,g,_,v,b,S,C,w,T,N,P;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=ft(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(xt),...(n.setup.config??[]).filter(bt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,F=n.capabilities.filter(yt);f=M,g=!0,t[27]===i?_=t[28]:(_=e=>{e||i()},t[27]=i,t[28]=_),u=k,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=h):h=t[29],l=A,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=x(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=p):p=t[30];let L;t[31]===n?L=t[32]:(L=(0,$.jsx)(Re,{connector:n,size:`lg`}),t[31]=n,t[32]=L);let R;t[33]===n.displayName?R=t[34]:(R=(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=R);let z;t[35]!==r||t[36]!==o.connectedBadge?(z=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=z):z=t[37];let B;t[38]!==R||t[39]!==z?(B=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[R,z]}),t[38]=R,t[39]=z,t[40]=B):B=t[40];let V;t[41]===c?V=t[42]:(V=(0,$.jsx)(D,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=V);let H;t[43]!==B||t[44]!==V?(H=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[B,V]}),t[43]=B,t[44]=V,t[45]=H):H=t[45];let U;t[46]!==L||t[47]!==H?(U=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[L,H]}),t[46]=L,t[47]=H,t[48]=U):U=t[48];let W;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(W=x(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,I.focusRingPanel),t[49]=W):W=t[49];let G;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(y,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=G):G=t[50];let K;t[51]===o.modalClose?K=t[52]:(K=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:W,"aria-label":o.modalClose,children:G})}),t[51]=o.modalClose,t[52]=K),t[53]!==U||t[54]!==K?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[U,K]}),t[53]=U,t[54]=K,t[55]=m):m=t[55],T=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,N=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let q;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(Te,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=q):q=t[56];let ee;t[57]===o.detailPermissions?ee=t[58]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ee);let te;t[59]!==n||t[60]!==o?(te=_t(n,o),t[59]=n,t[60]=o,t[61]=te):te=t[61];let ne;t[62]===te?ne=t[63]:(ne=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:te}),t[62]=te,t[63]=ne);let re;t[64]!==ee||t[65]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[q,(0,$.jsxs)(`div`,{children:[ee,ne]})]}),t[64]=ee,t[65]=ne,t[66]=re):re=t[66];let J;t[67]===o.connectorSetupTitle?J=t[68]:(J=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=J);let ie;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(ie=s.length?De(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=ie):ie=t[72];let ae;t[73]===ie?ae=t[74]:(ae=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ie}),t[73]=ie,t[74]=ae);let oe;t[75]!==J||t[76]!==ae?(oe=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[J,ae]}),t[75]=J,t[76]=ae,t[77]=oe):oe=t[77],t[78]!==re||t[79]!==oe?(P=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[re,oe]}),t[78]=re,t[79]=oe,t[80]=P):P=t[80],C=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?w=t[82]:(w=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=w),v=`space-y-5 border-t border-edge-subtle px-4 py-4`;let se;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),t[83]=se):se=t[83];let Y;t[84]===o.connectorRuntimeTitle?Y=t[85]:(Y=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[se,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=Y);let ce;t[86]!==n||t[87]!==o?(ce=gt(n,o),t[86]=n,t[87]=o,t[88]=ce):ce=t[88];let le;t[89]===ce?le=t[90]:(le=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ce}),t[89]=ce,t[90]=le),t[91]!==Y||t[92]!==le?(b=(0,$.jsxs)(`div`,{children:[Y,le]}),t[91]=Y,t[92]=le,t[93]=b):b=t[93],S=F.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:F.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:ht(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=b,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=N,t[23]=P}else l=t[8],u=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],b=t[17],S=t[18],C=t[19],w=t[20],T=t[21],N=t[22],P=t[23];let L;t[94]!==v||t[95]!==b||t[96]!==S?(L=(0,$.jsxs)(`div`,{className:v,children:[b,S]}),t[94]=v,t[95]=b,t[96]=S,t[97]=L):L=t[97];let R;t[98]!==L||t[99]!==C||t[100]!==w?(R=(0,$.jsxs)(`details`,{className:C,children:[w,L]}),t[98]=L,t[99]=C,t[100]=w,t[101]=R):R=t[101];let z;t[102]!==R||t[103]!==T||t[104]!==N||t[105]!==P?(z=(0,$.jsxs)(`div`,{className:T,children:[N,P,R]}),t[102]=R,t[103]=T,t[104]=N,t[105]=P,t[106]=z):z=t[106];let B;t[107]===o.modalClose?B=t[108]:(B=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(F,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=B);let V;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(V=r?null:(0,$.jsxs)(F,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(ee,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=V):V=t[114];let U;t[115]!==B||t[116]!==V?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[B,V]}),t[115]=B,t[116]=V,t[117]=U):U=t[117];let W;t[118]!==l||t[119]!==p||t[120]!==m||t[121]!==z||t[122]!==U?(W=(0,$.jsxs)(l,{className:p,children:[m,z,U]}),t[118]=l,t[119]=p,t[120]=m,t[121]=z,t[122]=U,t[123]=W):W=t[123];let G;t[124]!==u||t[125]!==h||t[126]!==W?(G=(0,$.jsxs)(u,{children:[h,W]}),t[124]=u,t[125]=h,t[126]=W,t[127]=G):G=t[127];let K;return t[128]!==f||t[129]!==g||t[130]!==_||t[131]!==G?(K=(0,$.jsx)(f,{open:g,onOpenChange:_,children:G}),t[128]=f,t[129]=g,t[130]=_,t[131]=G,t[132]=K):K=t[132],K}function yt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function bt(e){return e.required}function xt(e){return e.required}var St=(0,Q.memo)(function(e){let t=(0,nt.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,m]=(0,Q.useState)(!1),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=x(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,I.transition),t[0]=h):h=t[0];let g=h,y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=y):y=t[1];let b;t[2]===s?b=t[3]:(b=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=b);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=S):S=t[4];let C;t[5]!==s||t[6]!==b?(C=(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsxs)(F,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[y,b,S]})}),t[5]=s,t[6]=b,t[7]=C):C=t[7];let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(X,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=w):w=t[8];let T;t[9]!==c||t[10]!==a?(T=(0,$.jsxs)(He,{className:g,onSelect:a,children:[w,c]}),t[9]=c,t[10]=a,t[11]=T):T=t[11];let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ue,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=E):E=t[12];let D;t[13]!==l||t[14]!==o?(D=(0,$.jsxs)(He,{className:g,onSelect:o,children:[E,l]}),t[13]=l,t[14]=o,t[15]=D):D=t[15];let O;t[16]!==T||t[17]!==D?(O=(0,$.jsx)(Ae,{children:(0,$.jsxs)(Le,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[T,D]})}),t[16]=T,t[17]=D,t[18]=O):O=t[18];let k;t[19]!==O||t[20]!==C?(k=(0,$.jsxs)(Ce,{children:[C,O]}),t[19]=O,t[20]=C,t[21]=k):k=t[21];let A;t[22]===f?A=t[23]:(A=(0,$.jsx)(Qe,{open:f,onOpenChange:m,hideTrigger:!0}),t[22]=f,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[24]=j):j=t[24];let M;t[25]===d?M=t[26]:(M=(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:j})}),t[25]=d,t[26]=M);let N;t[27]!==n||t[28]!==i||t[29]!==r?(N=n?(0,$.jsxs)(He,{className:g,disabled:r,onSelect:n,children:[r?(0,$.jsx)(_,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(Pe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=N):N=t[30];let P,L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>m(!0),L=(0,$.jsx)(Ue,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=P,t[32]=L):(P=t[31],L=t[32]);let R;t[33]===u?R=t[34]:(R=(0,$.jsxs)(He,{className:g,onSelect:P,children:[L,u]}),t[33]=u,t[34]=R);let z;t[35]!==N||t[36]!==R?(z=(0,$.jsx)(Ae,{children:(0,$.jsxs)(Le,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[N,R]})}),t[35]=N,t[36]=R,t[37]=z):z=t[37];let B;t[38]!==M||t[39]!==z?(B=(0,$.jsxs)(Ce,{children:[M,z]}),t[38]=M,t[39]=z,t[40]=B):B=t[40];let V;return t[41]!==k||t[42]!==A||t[43]!==B?(V=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[k,A,B]}),t[41]=k,t[42]=A,t[43]=B,t[44]=V):V=t[44],V});function Ct(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var wt=/^([^:=]+)[:=](.*)$/;function Tt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Dt(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=wt.exec(t);r&&n.push(Ct(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Et(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function Dt(e){if(!e||typeof e!=`object`)return[Ct()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Ct(e),reference:t}:Ct(e,t==null?``:String(t)));return t.length>0?t:[Ct()]}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function kt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function At(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function jt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=kt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Et(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=At(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Et(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Mt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:Dt(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Nt(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Pt(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Ft(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Mt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Pt(r.url),r})}function It(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Lt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Ot(e)).map(([e,t])=>Mt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Rt(e){return jt(e)}async function zt(e,t){return(await S(T(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Bt(e,t,n,r){return(await S(T(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:jt(e)})})).payload}async function Vt(e,t){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Ht(e){await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ut(e,t=!1){let n=await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return L(),n.payload}async function Wt(e){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Gt(e,t){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function Kt(e){await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function qt(e,t){await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function Jt(e,t){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function Yt(e){let t=await S(T(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function Xt(e){let t=await S(T(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return L(),t.payload}function Zt(e){let t=(0,nt.c)(90),{serverId:n,draftId:r,t:i,onClose:a,onConfigure:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Q.useState)(s),[u,d]=(0,Q.useState)(!0),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(0),v;t[1]!==r||t[2]!==n?(v=()=>{let e=new AbortController,t=!0;return d(!0),p(``),l([]),(r?Jt(r,e.signal):zt(n,e.signal)).then(e=>{t&&l(e)}).catch(e=>{t&&p(e instanceof Error?e.message:String(e))}).finally(()=>{t&&d(!1)}),()=>{t=!1,e.abort()}},t[1]=r,t[2]=n,t[3]=v):v=t[3];let y;t[4]!==r||t[5]!==g||t[6]!==n?(y=[n,r,g],t[4]=r,t[5]=g,t[6]=n,t[7]=y):y=t[7],(0,Q.useEffect)(v,y);let b,x,S,C,w,T,N,P,I,L,R,z;if(t[8]!==f||t[9]!==u||t[10]!==a||t[11]!==o||t[12]!==m||t[13]!==n||t[14]!==i.setupConfigure||t[15]!==i.toolParameters||t[16]!==i.toolsAuthHint||t[17]!==i.toolsDialogSearchEmpty||t[18]!==i.toolsDialogSearchPlaceholder||t[19]!==i.toolsDialogSubtitle||t[20]!==i.toolsDialogTitle||t[21]!==i.toolsEmpty||t[22]!==i.toolsLoading||t[23]!==i.toolsTitle||t[24]!==c){let e=m.trim().toLowerCase(),r=c.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));S=M,w=!0,t[37]===a?T=t[38]:(T=e=>{e||a()},t[37]=a,t[38]=T),x=k,t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(E,{className:`fixed inset-0 z-[60] bg-scrim`}),t[39]=C):C=t[39],b=A,R=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let s;t[40]===i.toolsDialogTitle?s=t[41]:(s=(0,$.jsx)(j,{className:`font-semibold`,children:i.toolsDialogTitle}),t[40]=i.toolsDialogTitle,t[41]=s);let l;t[42]!==u||t[43]!==n||t[44]!==i.toolsDialogSubtitle||t[45]!==c.length?(l=u?n:i.toolsDialogSubtitle.replace(`{{serverId}}`,n).replace(`{{count}}`,String(c.length)),t[42]=u,t[43]=n,t[44]=i.toolsDialogSubtitle,t[45]=c.length,t[46]=l):l=t[46];let d;t[47]===l?d=t[48]:(d=(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:l}),t[47]=l,t[48]=d);let p;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>h(e.target.value),t[49]=p):p=t[49];let g;t[50]!==m||t[51]!==i.toolsDialogSearchPlaceholder?(g=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:m,onChange:p,placeholder:i.toolsDialogSearchPlaceholder,"aria-label":i.toolsDialogSearchPlaceholder}),t[50]=m,t[51]=i.toolsDialogSearchPlaceholder,t[52]=g):g=t[52],t[53]!==s||t[54]!==d||t[55]!==g?(z=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[s,d,g]}),t[53]=s,t[54]=d,t[55]=g,t[56]=z):z=t[56],N=`min-h-0 flex-1 overflow-y-auto p-5`,P=u,t[57]!==i.toolsTitle||t[58]!==c.length?(I=i.toolsTitle.replace(`{{count}}`,String(c.length)),t[57]=i.toolsTitle,t[58]=c.length,t[59]=I):I=t[59],L=u?(0,$.jsx)(`div`,{role:`status`,"aria-label":i.toolsLoading,className:`space-y-3`,children:[0,1,2].map($t)}):f?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:f}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.toolsAuthHint.replace(`{{serverId}}`,n)}),o?(0,$.jsx)(F,{variant:`secondary`,onClick:o,children:i.setupConfigure}):null]}):r.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name}),e.exposure?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.exposure}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:i.toolParameters}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.length?i.toolsDialogSearchEmpty:i.toolsEmpty}),t[8]=f,t[9]=u,t[10]=a,t[11]=o,t[12]=m,t[13]=n,t[14]=i.setupConfigure,t[15]=i.toolParameters,t[16]=i.toolsAuthHint,t[17]=i.toolsDialogSearchEmpty,t[18]=i.toolsDialogSearchPlaceholder,t[19]=i.toolsDialogSubtitle,t[20]=i.toolsDialogTitle,t[21]=i.toolsEmpty,t[22]=i.toolsLoading,t[23]=i.toolsTitle,t[24]=c,t[25]=b,t[26]=x,t[27]=S,t[28]=C,t[29]=w,t[30]=T,t[31]=N,t[32]=P,t[33]=I,t[34]=L,t[35]=R,t[36]=z}else b=t[25],x=t[26],S=t[27],C=t[28],w=t[29],T=t[30],N=t[31],P=t[32],I=t[33],L=t[34],R=t[35],z=t[36];let B;t[60]!==N||t[61]!==P||t[62]!==I||t[63]!==L?(B=(0,$.jsx)(`div`,{className:N,"aria-busy":P,"aria-label":I,children:L}),t[60]=N,t[61]=P,t[62]=I,t[63]=L,t[64]=B):B=t[64];let V;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>_(Qt),t[65]=V):V=t[65];let H;t[66]!==u||t[67]!==i.refreshTools?(H=(0,$.jsx)(F,{variant:`secondary`,disabled:u,onClick:V,children:i.refreshTools}),t[66]=u,t[67]=i.refreshTools,t[68]=H):H=t[68];let U;t[69]!==a||t[70]!==i.toolsDialogClose?(U=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(F,{onClick:a,children:i.toolsDialogClose})}),t[69]=a,t[70]=i.toolsDialogClose,t[71]=U):U=t[71];let W;t[72]!==H||t[73]!==U?(W=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[H,U]}),t[72]=H,t[73]=U,t[74]=W):W=t[74];let G;t[75]!==b||t[76]!==B||t[77]!==W||t[78]!==R||t[79]!==z?(G=(0,$.jsxs)(b,{className:R,children:[z,B,W]}),t[75]=b,t[76]=B,t[77]=W,t[78]=R,t[79]=z,t[80]=G):G=t[80];let K;t[81]!==x||t[82]!==C||t[83]!==G?(K=(0,$.jsxs)(x,{children:[C,G]}),t[81]=x,t[82]=C,t[83]=G,t[84]=K):K=t[84];let q;return t[85]!==S||t[86]!==w||t[87]!==T||t[88]!==K?(q=(0,$.jsx)(S,{open:w,onOpenChange:T,children:K}),t[85]=S,t[86]=w,t[87]=T,t[88]=K,t[89]=q):q=t[89],q}function Qt(e){return e+1}function $t(e){return(0,$.jsx)(B,{className:`h-24 w-full`},e)}function en(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function tn(e){let t=(0,nt.c)(59),{row:n,lastCheck:r,t:i,cs:a,onEdit:o,onRemove:s}=e,[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),m=n.displayName||n.id,h;t[0]===m?h=t[1]:(h=(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:m}),t[0]=m,t[1]=h);let g;t[2]===n?g=t[3]:(g=en(n),t[2]=n,t[3]=g);let _;t[4]===g?_=t[5]:(_=(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:g}),t[4]=g,t[5]=_);let v;t[6]!==o||t[7]!==h||t[8]!==_?(v=(0,$.jsxs)(`button`,{className:`block w-full text-left`,onClick:o,children:[h,_]}),t[6]=o,t[7]=h,t[8]=_,t[9]=v):v=t[9];let y;t[10]!==r||t[11]!==n.extra.enabled||t[12]!==i.setupDisabled||t[13]!==i.setupLastCheck||t[14]!==i.setupUnverified?(y=n.extra.enabled===!1?i.setupDisabled:r?i.setupLastCheck.replace(`{{count}}`,String(r.toolCount)):i.setupUnverified,t[10]=r,t[11]=n.extra.enabled,t[12]=i.setupDisabled,t[13]=i.setupLastCheck,t[14]=i.setupUnverified,t[15]=y):y=t[15];let b;t[16]===y?b=t[17]:(b=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:y}),t[16]=y,t[17]=b);let x;t[18]===r?x=t[19]:(x=r?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`time`,{dateTime:r.checkedAt,children:new Intl.DateTimeFormat(void 0,{dateStyle:`short`,timeStyle:`short`}).format(new Date(r.checkedAt))})}):null,t[18]=r,t[19]=x);let S;t[20]===f?S=t[21]:(S=f?(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:f}):null,t[20]=f,t[21]=S);let C=n.extra.enabled===!1,w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>l(!0),t[22]=w):w=t[22];let T;t[23]!==i.viewTools||t[24]!==C?(T=(0,$.jsx)(F,{variant:`secondary`,disabled:C,onClick:w,children:i.viewTools}),t[23]=i.viewTools,t[24]=C,t[25]=T):T=t[25];let E;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>d(!0),t[26]=E):E=t[26];let D;t[27]===i.removeServer?D=t[28]:(D=(0,$.jsx)(F,{variant:`ghost`,onClick:E,children:i.removeServer}),t[27]=i.removeServer,t[28]=D);let O;t[29]!==T||t[30]!==D?(O=(0,$.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[T,D]}),t[29]=T,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==o||t[33]!==n.id||t[34]!==c||t[35]!==i?(k=c?(0,$.jsx)(Zt,{serverId:n.id,t:i,onClose:()=>l(!1),onConfigure:()=>{l(!1),o()}}):null,t[32]=o,t[33]=n.id,t[34]=c,t[35]=i,t[36]=k):k=t[36];let A;t[37]!==a.removeConfirmTitle||t[38]!==n.displayName||t[39]!==n.id?(A=a.removeConfirmTitle.replace(`{{name}}`,n.displayName||n.id),t[37]=a.removeConfirmTitle,t[38]=n.displayName,t[39]=n.id,t[40]=A):A=t[40];let j;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>d(!1),t[41]=j):j=t[41];let M;t[42]===s?M=t[43]:(M=()=>{d(!1),s().catch(e=>p(String(e)))},t[42]=s,t[43]=M);let N;t[44]!==u||t[45]!==a.modalCancel||t[46]!==a.removeConfirmDescription||t[47]!==i.removeServer||t[48]!==A||t[49]!==M?(N=(0,$.jsx)(Me,{open:u,title:A,description:a.removeConfirmDescription,confirmLabel:i.removeServer,cancelLabel:a.modalCancel,destructive:!0,onCancel:j,onConfirm:M}),t[44]=u,t[45]=a.modalCancel,t[46]=a.removeConfirmDescription,t[47]=i.removeServer,t[48]=A,t[49]=M,t[50]=N):N=t[50];let P;return t[51]!==O||t[52]!==k||t[53]!==N||t[54]!==v||t[55]!==b||t[56]!==x||t[57]!==S?(P=(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[v,b,x,S,O,k,N]}),t[51]=O,t[52]=k,t[53]=N,t[54]=v,t[55]=b,t[56]=x,t[57]=S,t[58]=P):P=t[58],P}function nn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function rn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?nn(t)-nn(e):e.isCurrentAuthorization?-1:1}function an(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(rn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>rn(e.primary,t.primary))}var on=x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function sn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function cn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function ln(e,t,n){return e.status===`connected`?De(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function un(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function dn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function fn({instance:e,t,onChanged:n}){let r=sn(e),i=w(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[l,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)([]),[b,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)({}),[A,j]=(0,Q.useState)(`read`),[M,N]=(0,Q.useState)(!1),[P,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,H]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,q]=(0,Q.useState)(!1),[ee,ne]=(0,Q.useState)(!1),[re,ce]=(0,Q.useState)(!1),le=(0,Q.useRef)(0),ue=(0,Q.useRef)(0),fe=(0,Q.useMemo)(()=>an(a),[a]),X=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),pe=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;N(!0),I(null);let t=++le.current;try{let e=(await Promise.allSettled([X(ge()).then(e=>{t===le.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),q(!0))}),X(ae(r)).then(e=>{t===le.current&&j(e)}),X(te(r)).then(e=>{t===le.current&&(g(e.policy),y(e.agents))})])).find(e=>e.status===`rejected`);t===le.current&&e?.status===`rejected`&&I(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===le.current&&N(!1)}},[e.materialized,r,X]);(0,Q.useEffect)(()=>(pe(),()=>{le.current++}),[pe]);let he=(0,Q.useCallback)(async()=>{if(!r)return;let e=++ue.current;ce(!0),R(!1);let t=t=>n=>{e===ue.current&&t(n)},n=await Promise.allSettled([X(be(r)).then(t(f)),X(Y(20)).then(t(e=>m(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),X(ie(r)).then(t(T)),X(me(r)).then(t(S))]);e===ue.current&&(R(n.some(e=>e.status===`rejected`)),ce(!1))},[r,X]);(0,Q.useEffect)(()=>(ee&&he(),()=>{ue.current++}),[ee,he]),(0,Q.useEffect)(()=>{let e=!1,t=an(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return X(U()).then(t=>{e||D(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await X(ve(e.accountId))])).then(t=>{e||k(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,X]);let _e=(0,Q.useCallback)(async i=>{if(!r)return;let a=V()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),N(!0),I(null);try{if(!V()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await We(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(V()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await ke(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),pe()])}catch(e){I(se(e,t))}finally{a?.close(),N(!1)}},[e.connectorId,pe,n,t,r]),ye=(0,Q.useCallback)(async t=>{N(!0),I(null);try{await Be(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),pe()])}catch(e){I(e instanceof Error?e.message:String(e))}finally{N(!1)}},[e.config,e.instanceId,pe,n]),xe=async e=>{let t=V()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),I(null);try{let n=await de(e.id);if(n.authorizationUrl)if(V())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await pe()}catch(e){t?.close(),I(e instanceof Error?e.message:String(e))}},Ce=(0,Q.useCallback)(async e=>{if(r){j(e),I(null);try{await Se(r,e)}catch(e){I(e instanceof Error?e.message:String(e)),await pe()}}},[pe,r]),Z=(0,Q.useCallback)(async e=>{if(r){I(null);try{g(await Oe(r,e))}catch(e){I(e instanceof Error?e.message:String(e))}}},[r]),Ae=(0,Q.useCallback)(e=>{if(!h)return;let t=h.allowedAgentIds.includes(e);t&&h.allowedAgentIds.length===1||Z({allowedAgentIds:t?h.allowedAgentIds.filter(t=>t!==e):[...h.allowedAgentIds,e]})},[Z,h]),je=(0,Q.useCallback)(async e=>{N(!0),I(null);try{await e(),await pe()}catch(e){I(e instanceof Error?e.message:String(e))}finally{N(!1)}},[pe]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let Ne=fe.filter(e=>e.primary.status===`active`).length,Ie=Ne>0?t.composioAddAccount:t.composioConnectAccount,Le=K&&Ne>0,Re=C?.requiresCustomAuthConfig===!0,He=C?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:x(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Le?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Le?(0,$.jsx)(d,{className:`size-3.5`}):(0,$.jsx)(u,{className:`size-3.5`}),Le?t.connectionReady:K||P?t.connectionNeedsSetup:t.connectionChecking]}),K&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:De(t.composioAccountCount,{count:String(fe.length)})})]}),(0,$.jsxs)(F,{variant:`primary`,className:`shrink-0`,disabled:M,onClick:()=>void _e(),children:[M?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),Ie]})]}),P?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:P}),(0,$.jsx)(F,{variant:`secondary`,disabled:M,onClick:()=>void pe(),children:t.composioRetry})]}):null,b&&!Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:ln(b,Ne,t)}),b.recovery===`none`?null:(0,$.jsx)(F,{variant:`secondary`,disabled:M,onClick:()=>void(b.recovery===`retry`?pe():_e()),children:b.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Re&&He.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,h?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:A===`read`?t.composioAccessReadHint:A===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:A,onChange:e=>void Ce(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),A===`admin`?(0,$.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(s,{value:h.confirmationPolicy,onChange:e=>void Z({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),h.confirmationPolicy===`never`?(0,$.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:x(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Z({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),v.map(e=>(0,$.jsx)(`button`,{type:`button`,className:x(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ae(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:h.selectedAccountIds===null,disabled:M,onChange:e=>void Z({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),h.selectedAccountIds!==null&&fe.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:h.selectedAccountIds.includes(e.accountId),onChange:t=>void Z({selectedAccountIds:t.currentTarget.checked?[...h.selectedAccountIds,e.accountId]:h.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),h.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),K&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:De(t.composioAccountCount,{count:String(fe.length)})})]}),(0,$.jsxs)(F,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:M,onClick:()=>void pe(),children:[(0,$.jsx)(Pe,{className:x(`size-3.5`,M&&`animate-spin`)}),t.refresh]})]}),fe.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:fe.map(e=>{let r=e.primary,a=E.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?O[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:x(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:un(r.status,t)}),a?(0,$.jsx)(`p`,{className:x(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:De(t.connectorLearningStatus,{status:dn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void xe(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(F,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:M,onClick:()=>G(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:M,onClick:()=>void _e(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:M,onClick:()=>void je(()=>Je(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(F,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:M,onClick:()=>void je(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ze(r.accountId),await n?.()}),children:[(0,$.jsx)(Pe,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:r.allowedAgentIds==null,onChange:e=>void je(()=>Je(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&v.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;je(()=>Je(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:M,onChange:e=>void je(()=>Fe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:M,onChange:e=>void je(()=>Fe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:x(on,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&je(()=>we(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(F,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:M,onClick:()=>H(e.id),children:(0,$.jsx)(J,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(F,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:M,onClick:()=>void je(()=>Ee(r.id)),children:(0,$.jsx)(Pe,{className:`size-4`})})})]})]})]},e.key)})}):M&&!K?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(B,{className:`h-16 w-full`}),(0,$.jsx)(B,{className:`h-16 w-full`})]}):K?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>ne(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[re?(0,$.jsx)(B,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,L?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(F,{variant:`ghost`,disabled:re,onClick:()=>void he(),children:t.composioRetry})]}):null,C?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Re?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:M,onChange:e=>void ye(e.currentTarget.value),children:[Re?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),Re&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,He.map(e=>(0,$.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length?l.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[cn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:p.length?p.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(Me,{open:W!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=W;G(null),e&&je(()=>oe(e))},onCancel:()=>G(null)}),(0,$.jsx)(Me,{open:z!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=z;H(null),e&&je(()=>Ve(e))},onCancel:()=>H(null)})]})}var pn=x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function mn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function hn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function gn({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(()=>mn(t,e)),[v,b]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),N=t?.setup.config??[],P=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&N.length>0&&(t?.setup.secrets??[]).length===0,L=e.materialized.type===`mcp`,R=e.materialized.type===`composio`,z=e.materialized.type===`memorySource`,B=t?H(t,i):null,V=(0,Q.useCallback)(async()=>{C(!0),b(null);try{let t=await Ne(e.instanceId);T(t),t.ok||b(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{C(!1)}},[e.instanceId,r,i.healthStatusLabels]),U=(0,Q.useCallback)(async()=>{o(!0),b(null);try{await Ie(e.instanceId),await r(),n()}catch(e){b(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),W=(0,Q.useCallback)(async()=>{if(!(!t||!P)){u(!0),b(null);try{let n={};for(let e of t.setup.config??[]){let t=hn(e.type,h[e.key]??``);t!==void 0&&(n[e.key]=t)}await Be(e.instanceId,{config:n}),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[h,t,e.instanceId,r,P]),G=(0,Q.useCallback)(async()=>{f(!0),m(null),b(null);try{m((await Z(e.connectorId)).recordIds.length),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(M,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(A,{className:x(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,R?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(Re,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:B??(e.materialized.type===`mcp`?De(i.mcpServerRuntime,{serverId:e.materialized.serverId}):De(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:x(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,I.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(y,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[v?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null,L?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:w?.ok?De(i.toolsAvailable,{count:String(w.toolCount)}):w?i.healthStatusLabels[w.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(F,{variant:`secondary`,"aria-busy":S,disabled:S||!e.enabled,onClick:()=>void V(),children:[S?(0,$.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Pe,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),P?N.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,R?(0,$.jsx)(fn,{instance:e,t:i,onChanged:r}):null,z?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),B?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:B}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:De(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(F,{disabled:d,onClick:()=>void G(),children:[d?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(q,{className:`size-4`}),i.composioSyncNow]})]}),P?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:N.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!L&&!R&&!z?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(F,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(J,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(F,{variant:`secondary`,onClick:n,children:i.modalClose}),(L||z)&&P?(0,$.jsxs)(F,{variant:`primary`,disabled:l,onClick:()=>void W(),children:[l?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(Ke,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(Me,{open:s,title:De(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),U()},onCancel:()=>{a||c(!1)}})]})}function _n(e){let t=(0,nt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(qe,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(gn,{...e}),t[0]=e,t[1]=n),n}function vn(e){let t=(0,nt.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:s}=e,c=i===void 0?!1:i,l;t[0]!==r||t[1]!==n?(l=mt(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let p=l.state,m;t[3]!==r||t[4]!==s?(m=r?H(r,s):null,t[3]=r,t[4]=s,t[5]=m):m=t[5];let h=m,g,_,v,y,b,S,C,w,T;if(t[6]!==p||t[7]!==r||t[8]!==c||t[9]!==n||t[10]!==a||t[11]!==s.connectionChecking||t[12]!==s.connectionNeedsSetup||t[13]!==s.connectionReady){g=p===`ready`?{label:s.connectionReady,Icon:d,className:`text-emerald-700 dark:text-emerald-300`}:p===`needs_setup`?{label:s.connectionNeedsSetup,Icon:u,className:`text-amber-700 dark:text-amber-300`}:{label:s.connectionChecking,Icon:f,className:`text-fg-muted`},w=`button`;let e=c&&`bg-accent-soft`;t[23]===e?T=t[24]:(T=x(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,I.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=T),t[25]!==n||t[26]!==a?(_=()=>a(n),t[25]=n,t[26]=a,t[27]=_):_=t[27],t[28]===r?v=t[29]:(v=(0,$.jsx)(Re,{connector:r}),t[28]=r,t[29]=v),C=`min-w-0 flex-1`,b=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?S=t[31]:(S=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=S),y=x(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,g.className),t[6]=p,t[7]=r,t[8]=c,t[9]=n,t[10]=a,t[11]=s.connectionChecking,t[12]=s.connectionNeedsSetup,t[13]=s.connectionReady,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=S,t[20]=C,t[21]=w,t[22]=T}else g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],S=t[19],C=t[20],w=t[21],T=t[22];let E;t[32]===g.Icon?E=t[33]:(E=(0,$.jsx)(g.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=g.Icon,t[33]=E);let D;t[34]!==g.label||t[35]!==E||t[36]!==y?(D=(0,$.jsxs)(`span`,{className:y,children:[E,g.label]}),t[34]=g.label,t[35]=E,t[36]=y,t[37]=D):D=t[37];let O;t[38]!==D||t[39]!==b||t[40]!==S?(O=(0,$.jsxs)(`div`,{className:b,children:[S,D]}),t[38]=D,t[39]=b,t[40]=S,t[41]=O):O=t[41];let k;t[42]===h?k=t[43]:(k=h?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:h}):null,t[42]=h,t[43]=k);let A;t[44]!==O||t[45]!==k||t[46]!==C?(A=(0,$.jsxs)(`div`,{className:C,children:[O,k]}),t[44]=O,t[45]=k,t[46]=C,t[47]=A):A=t[47];let j;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(o,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=j):j=t[48];let M;return t[49]!==_||t[50]!==v||t[51]!==A||t[52]!==w||t[53]!==T?(M=(0,$.jsxs)(`button`,{type:w,className:T,onClick:_,children:[v,A,j]}),t[49]=_,t[50]=v,t[51]=A,t[52]=w,t[53]=T,t[54]=M):M=t[54],M}function yn(e,t){return It()}function bn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Ct()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function xn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Ct(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Ct(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Sn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Cn(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z)}function wn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:p=`Show value`,hideValueLabel:m=`Hide value`,allowPaste:_=!0}){let[v,y]=(0,Q.useState)(new Set),[b,S]=(0,Q.useState)(!1),C=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},w=()=>{d([...u,Ct()])},T=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Ct()])},E=async()=>{try{let e=await P();if(!e){S(!0);return}let t=Tt(e);if(!t?.length){S(!0);return}d(t)}catch{S(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),_?(0,$.jsxs)(F,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void E(),children:[(0,$.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:x(Cn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>C(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:x(Cn(),`min-w-0 font-mono text-xs`),type:v.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>C(t,{value:e.target.value})}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":v.has(e.clientKey)?m:p,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:v.has(e.clientKey)?(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>T(t),"aria-label":r,children:(0,$.jsx)(J,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(Me,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>S(!1),onCancel:()=>S(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:x(`self-start text-sm text-accent hover:underline`,I.press),onClick:w,children:[`+ `,n]})]})}var Tn=x(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,z);function En(e){let t=(0,nt.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=x(Tn,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let p;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(p=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==p?(m=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,p]}),t[8]=i,t[9]=p,t[10]=m):m=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>l(Dn),t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=c?(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=v);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==v||t[15]!==y?(b=(0,$.jsxs)(F,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:_,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let S;return t[17]!==b||t[18]!==m?(S=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,b]}),t[17]=b,t[18]=m,t[19]=S):S=t[19],S}function Dn(e){return!e}function On(e){let t=(0,nt.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(wn,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function kn(e){let t=(0,nt.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,l=i.setupAuthLabel,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=x(Tn,`mt-1.5`),t[0]=u):u=t[0];let d=n.mode,f;t[1]===r?f=t[2]:(f=e=>r({mode:e.target.value}),t[1]=r,t[2]=f);let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=p):p=t[3];let m;t[4]===i.setupAuthModes?m=t[5]:(m=p.map(e=>(0,$.jsx)(c,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=m);let h;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(h=a||n.mode===`existing`?(0,$.jsx)(c,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=h):h=t[9];let g;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==f||t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(s,{"aria-label":l,className:u,value:d,onChange:f,children:[m,h]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=f,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]!==i.setupAuthLabel||t[17]!==g?(_=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,g]}),t[16]=i.setupAuthLabel,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(v=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=v):v=t[21];let y;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(y=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=y):y=t[24];let b;t[25]!==n.mode||t[26]!==i.setupExistingHint?(b=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=b):b=t[27];let S;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(S=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=S):S=t[32];let C;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(C=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:x(Tn,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(En,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=C):C=t[38];let w;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(w=n.mode===`headers`?(0,$.jsx)(On,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=w):w=t[43];let T;return t[44]!==_||t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==S||t[49]!==C||t[50]!==w?(T=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[_,v,y,b,S,C,w]}),t[44]=_,t[45]=v,t[46]=y,t[47]=b,t[48]=S,t[49]=C,t[50]=w,t[51]=T):T=t[51],T}function An(e){let t=(0,nt.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function jn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Dt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=kt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(An,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Tn,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Tn,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(J,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(F,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(On,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Et(e)??{})})}})]})}function Mn(e){let t=(0,nt.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:l}=e,u=a===void 0?`all`:a,d=o===void 0?!1:o,f=l===void 0?!1:l,p=u!==`advanced`,m=u!==`basic`,h;t[0]!==p||t[1]!==i||t[2]!==n||t[3]!==r?(h=p?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Tn,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(jn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(An,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Tn,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(An,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Tn,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=p,t[1]=i,t[2]=n,t[3]=r,t[4]=h):h=t[4];let g;t[5]!==m||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==d||t[10]!==r?(g=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Tn,readOnly:f,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(An,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Tn,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&d?(0,$.jsx)(An,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Tn,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(An,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(s,{"aria-label":r.exposureLabel,className:Tn,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(c,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(An,{label:r.requestTimeoutLabel,children:(0,$.jsx)(tt,{allowEmpty:!0,type:`number`,min:1,className:Tn,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=m,t[6]=f,t[7]=i,t[8]=n,t[9]=d,t[10]=r,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function Nn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Pn(e,t){return JSON.stringify({id:e.id,config:Rt(xn(e,t))})}function Fn(e,t){try{return Pn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function In(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,l]=(0,Q.useState)(()=>bn(e.initialRow)),[u,f]=(0,Q.useState)(`idle`),[p,h]=(0,Q.useState)(``),[g,v]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(),[C,w]=(0,Q.useState)(),[T,O]=(0,Q.useState)(),[N,P]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)([]),[W,G]=(0,Q.useState)(`0`),[K,q]=(0,Q.useState)(0),[ee,te]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(!1),[J,ie]=(0,Q.useState)(!1),ae=e.mode===`edit`,[oe,se]=(0,Q.useState)(``),Y=(0,Q.useRef)(void 0),[ce]=(0,Q.useState)(()=>Fn(e.initialRow,bn(e.initialRow))),le=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),ue=(0,Q.useRef)(void 0),de=(0,Q.useRef)(void 0),fe=(0,Q.useRef)(void 0),X=(0,Q.useRef)(null),pe=(0,Q.useRef)(``),me=(0,Q.useRef)(!0),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(e.onSaved);ve.current=e.onSaved;let ye=T?.state===`starting`||T?.state===`authorizing`,be=u!==`idle`||ye,xe=ce!==Fn(i,o),Se=i.extra.enabled===!1,Ce=!g&&(xe||!!R.trim());(0,Q.useEffect)(()=>(me.current=!0,()=>{me.current=!1,ue.current?.abort(),X.current?.close(),Y.current&&Ht(Y.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Ce)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Ce]),(0,Q.useEffect)(()=>{if(!b)return;let e=ge.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??_e.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!T||!ye)return;let e=new AbortController;de.current=e;let n;async function r(){try{let n=await Gt(Y.current,e.signal);if(e.signal.aborted||(O(n),n.authorizationUrl&&pe.current!==n.authorizationUrl&&(pe.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&h(t.oauthOpenFailed):X.current&&!X.current.closed&&X.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){fe.current=void 0,X.current?.close(),w({state:`connected`,toolCount:n.toolCount}),h(``);return}if(n.state===`error`||n.state===`cancelled`){fe.current=void 0,X.current?.close(),h(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&P(!0);return}}catch{if(e.signal.aborted)return;Z(),X.current?.close(),h(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[T?.id,ye,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Z(){ue.current?.abort(),de.current?.abort(),Y.current&&Ht(Y.current).catch(()=>{}),Y.current=void 0,se(``),re(!1),w(void 0),O(void 0),h(``),S(void 0)}function we(e){a(t=>({...t,...e})),Z()}function Te(e){l(t=>({...t,...e})),Z()}function Ee(){be||(Ce?ie(!0):e.onClose())}function De(){try{U(Ft(R)),G(`0`),V(``)}catch{V(t.setupImportError),U([])}}function Oe(){let t=H[Number(W)];if(!t)return;let n={...t,id:le.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...le.current?{enabled:i.extra.enabled}:{}}};a(n),l(bn(n)),Z(),q(e=>e+1),L(!1),z(``),U([])}function ke(e){function n(e,t){return S({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Pt(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(o.mode===`bearer`&&!o.token.trim().replace(/^Bearer\s*/i,``)||o.mode===`apiKey`&&(!o.apiKey.trim()||!o.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Sn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(o.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(o.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{Rt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Ae(){h(``),f(`checking`),pe.current=``,window.electronAPI?.shell?.openExternalUrl||(X.current=window.open(`about:blank`,`_blank`),X.current&&(X.current.opener=null));try{let e=await Wt(Y.current);if(!me.current){X.current?.close(),Y.current&&Ht(Y.current).catch(()=>{});return}fe.current=e.id,O(e)}catch{X.current?.close(),me.current&&h(t.setupAuthFailed)}finally{me.current&&f(`idle`)}}async function je(){let r=xn(i,o);if(!ke(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==le.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=le.current||r.id.trim()||Nt(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){S({field:`advanced`,message:n.duplicateServerId});return}Z(),f(`checking`);let l=new AbortController;ue.current=l;try{let n=await Bt(r,le.current||void 0,e.initialRow.extra,l.signal);if(!me.current||l.signal.aborted){Ht(n.id).catch(()=>{});return}Y.current=n.id,a(r),se(Fn(r,o));let i=await Vt(n.id,l.signal);if(!me.current||l.signal.aborted)return;w(i),i.state===`error`&&h(Nn(i,t))}catch(e){me.current&&!l.signal.aborted&&h(e.status===409?t.setupConflict:Nn(e,t))}finally{me.current&&ue.current===l&&f(`idle`)}}async function Ne(n=!1){if(!(!Y.current||C?.state!==`connected`||oe!==Fn(i,o))){f(`saving`),h(``);try{let t=await Ut(Y.current,n);Y.current=void 0,await ve.current().catch(()=>{}),t?.reloadRequired?v(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Z(),h(t.setupConflict)):h(t.setupSaveFailed)}finally{me.current&&f(`idle`)}}}async function Pe(){de.current?.abort();let e=Y.current;fe.current=void 0,O(void 0),X.current?.close(),h(t.setupCancelled),f(`checking`);try{e&&await Kt(e)}catch{me.current&&(Z(),h(t.setupCancelled))}finally{me.current&&f(`idle`)}}async function Fe(){T?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(T.authorizationUrl)).ok||h(t.oauthOpenFailed):window.open(T.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(T)try{await qt(Y.current,ee),te(``),h(``)}catch{h(t.setupRedirectInvalid)}}let Le=!!Y.current&&oe===Fn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&C?.state===`oauth_required`)&&C?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),ze=H[Number(W)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(M,{open:e.open,onOpenChange:e=>{e||Ee()},children:(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(A,{ref:he,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),he.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(j,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:be,onClick:Ee,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(y,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[I?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>L(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:x(Tn,`mt-1.5 min-h-40 font-mono text-xs`),value:R,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{z(e.target.value),U([]),V(``)}})]}),(0,$.jsx)(F,{variant:`secondary`,disabled:!R.trim(),onClick:De,children:t.setupImportPreview}),B?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:B}):null,ze?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(s,{"aria-label":t.setupImportChoose,className:x(Tn,`mt-1.5`),value:W,onChange:e=>G(e.target.value),children:H.map((e,t)=>(0,$.jsx)(c,{value:String(t),children:e.displayName||e.id||en(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[ze.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,en(ze)]})]}):null]}):(0,$.jsxs)(`form`,{ref:ge,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Pt(i.url)}catch{S({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),je()},children:[(0,$.jsxs)(`fieldset`,{disabled:be||g,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(F,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>we({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>L(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Mn,{row:i,t,variant:`basic`,onUpdate:we},`${i.transport}-${K}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(kn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:Te,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:_e,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:N,onToggle:e=>P(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Mn,{row:i,t,variant:`advanced`,idReadOnly:ae,showOAuth:o.mode===`oauth`,onUpdate:we}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(On,{additional:!0,headers:o.additionalHeaders,onChange:e=>Te({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Re?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!I&&!g?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&ae&&!xe&&!C&&!p&&!ye?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Se?t.setupDisabled:t.setupSavedUnchecked}):null,C?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(d,{className:`size-4 shrink-0`,"aria-hidden":!0}),C.toolCount?t.setupConnected.replace(`{{count}}`,String(C.toolCount)):t.setupZeroTools]}),(0,$.jsx)(F,{variant:`secondary`,onClick:()=>re(!0),children:t.viewTools})]}):null,C?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,C?.state===`oauth_required`&&!ye?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,ye?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T?.authorizationUrl?(0,$.jsxs)(F,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:()=>void Pe(),children:t.setupCancelAuth})]}),T?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Tn,value:ee,onChange:e=>te(e.target.value)})]}),(0,$.jsx)(F,{className:`mt-2`,disabled:!ee.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,p?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:p}),p!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(F,{variant:`secondary`,disabled:be,onClick:Ee,children:ae||g?t.setupClose:n.modalCancel}),g?null:I?(0,$.jsx)(F,{variant:`primary`,disabled:!ze,onClick:Oe,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{variant:C?.state===`connected`?`secondary`:`primary`,disabled:be,onClick:()=>Le?void Ae():void je(),children:Le?t.setupSignIn:t.setupTestConnection}),C?.state===`connected`&&oe===Fn(i,o)?(0,$.jsxs)($.Fragment,{children:[Se?(0,$.jsx)(F,{variant:`secondary`,disabled:be,onClick:()=>void Ne(!0),children:t.setupEnableSave}):null,(0,$.jsx)(F,{variant:`primary`,disabled:be,"aria-busy":be,onClick:()=>void Ne(),children:ae?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(Me,{open:J,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ie(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),ne?(0,$.jsx)(Zt,{draftId:Y.current,serverId:i.id,t,onClose:()=>re(!1)}):null]})}var Ln=`builtin`,Rn=`composio`,zn=`xopc-store`;function Bn(e){return Ln}function Vn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Hn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Un(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Wn({embedded:e=!1,onHeaderActionChange:t}){let n=N().filter(e=>e.format===`agent-plugin`),r=w(e=>e.language),o=b(r),s=o.connectorsSettings,c=o.mcpSettings,u=C(e=>e.conversationId),d=!!u,f=a(),[p,m]=i(),h=p.get(`understanding`)===`1`,g=Un(p.get(`returnTo`)),v=!!p.get(`returnTo`)&&!h,y=p.get(`tab`),[S,T]=(0,Q.useState)(!h&&y===`connected`?`connected`:`discover`),E=(0,Q.useRef)(!1),[D,O]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[P,I]=(0,Q.useState)(1),[L,z]=(0,Q.useState)(void 0),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(h||v?p.get(`connector`)??``:``),[q,ee]=(0,Q.useState)(Bn(h?`understanding`:`default`)),[te,re]=(0,Q.useState)(`name`),[J,ie]=(0,Q.useState)(h?`understand`:`all`),[ae,oe]=(0,Q.useState)(null),[se,Y]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(null),[fe,X]=(0,Q.useState)(null),[me,ge]=(0,Q.useState)(null),[ve,be]=(0,Q.useState)(null),{data:Se,mutate:Ce}=R(d),Z=Se?.payload?.config,we=(0,Q.useMemo)(()=>Z===void 0?null:Lt(Z),[Z]),Te=we?.servers??[],Ee=D.instances.length+Te.length+n.reduce((e,t)=>e+(t.components?.mcp.length??0),0),[De,Oe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Oe({}),!d||!Z)return;let e=new AbortController;return Yt(e.signal).then(t=>{e.signal.aborted||Oe(t)}).catch(()=>{}),()=>e.abort()},[d,Z]);let ke=(0,Q.useCallback)(async()=>{if(!u){O({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}O(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ye(),G()]);O(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){O({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[u]);(0,Q.useEffect)(()=>{ke()},[ke]),(0,Q.useEffect)(()=>{E.current||D.loading||d&&!we||(T(h?`discover`:Ee>0?`connected`:`discover`),E.current=!0)},[d,Ee,we,h,D.loading]);let Ae=(0,Q.useCallback)(e=>{E.current=!0,T(e)},[]),je=(0,Q.useMemo)(()=>[{id:Rn,displayName:s.composioSourceName},{id:zn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Me=(0,Q.useCallback)(async e=>{if(!d||q===`builtin`){O(e=>({...e,registryCatalog:[]})),I(1),z(void 0);return}let t=H.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=q===`all`?je:je.filter(e=>e.id===q);if(i.length!==0){A(!0),r?O(e=>({...e,error:null})):(I(1),z(void 0),O(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await le({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await pe({q:t||void 0,page:n,pageSize:24,sort:te===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Vn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Hn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));I(n),z(o),O(e=>({...e,registryCatalog:r?Hn([...e.registryCatalog,...a]):a}))}catch(e){O(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{A(!1)}}},[te,H,q,d,je]);(0,Q.useEffect)(()=>{if(S!==`discover`||D.loading)return;if(q===`builtin`){O(e=>({...e,registryCatalog:[]})),I(1),z(void 0);return}let e=window.setTimeout(()=>{Me()},H.trim()?350:0);return()=>window.clearTimeout(e)},[H,q,Me,D.loading,S]);let Ne=(0,Q.useMemo)(()=>new Set(D.instances.map(e=>e.connectorId)),[D.instances]),Pe=(0,Q.useMemo)(()=>new Map([...D.catalog,...D.registryCatalog].map(e=>[e.id,e])),[D.catalog,D.registryCatalog]);(0,Q.useEffect)(()=>{if(D.loading)return;let e=p.get(`connector`),t=p.get(`instance`);if(!e&&!t)return;let n=D.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)E.current=!0,V(``),de(n.instanceId),X(n),T(`connected`);else if(e){let t=Pe.get(e);if(!t)return;E.current=!0,ee(Bn(h?`understanding`:`default`)),U(``),Y(t),T(`discover`)}let r=new URLSearchParams(p);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),m(r,{replace:!0})},[Pe,h,p,m,D.instances,D.loading]);let Fe=(0,Q.useCallback)(async e=>{M(!0),O(e=>({...e,error:null}));try{let t=await ne(e);oe(he(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){O(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{M(!1)}},[]),Ie=(0,Q.useMemo)(()=>new Set(D.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[D.instances]),Le=(0,Q.useCallback)(async e=>{let t=await Xt(e);await Ce(),await ke(),t.reloadRequired&&O(e=>({...e,error:c.setupReloadRequired}))},[ke,Ce,c.setupReloadRequired]),Re=(0,Q.useCallback)(()=>{be({mode:`add`,row:yn(Te,Ie)})},[Te,Ie]),ze=K(e=>e.setPageHeader),Be=K(e=>e.clearPageHeader),Ve=(0,Q.useMemo)(()=>({searchLabel:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(Xe,{value:S===`connected`?B:H,onChange:S===`connected`?V:U,placeholder:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(St,{onRefresh:S===`connected`&&d?ke:void 0,refreshing:D.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Ae(`discover`),onAddCustomServer:Re,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[B,s,H,d,r,ke,o.capabilitiesHub.moreActions,Re,Ae,D.loading,S]);(0,Q.useLayoutEffect)(()=>e?(t?.(Ve),()=>t?.(null)):(ze({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(Ze,{contribution:Ve})}),()=>Be()),[Be,s.title,e,Ve,t,ze]);let He=(0,Q.useMemo)(()=>D.instances.map(e=>({instance:e,value:mt(e,Pe.get(e.connectorId))})),[Pe,D.instances]),Ue=(0,Q.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Q.useMemo)(()=>D.instances.filter(e=>ce(e,B)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ue.get(e.instanceId)?.state??`checking`,i=Ue.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[B,Ue,D.instances]),Ge=(0,Q.useMemo)(()=>We.filter(e=>Ue.get(e.instanceId)?.state===`needs_setup`),[Ue,We]),Ke=(0,Q.useMemo)(()=>We.filter(e=>Ue.get(e.instanceId)?.state!==`needs_setup`),[Ue,We]),qe=(0,Q.useMemo)(()=>Te.filter(e=>_e(e,B)),[B,Te]),Je=(0,Q.useMemo)(()=>{let e=B.trim().toLowerCase();return n.flatMap(t=>(t.components?.mcp??[]).filter(n=>`${t.name} ${n.name}`.toLowerCase().includes(e)).map(e=>({extension:t,server:e})))},[B,n]),Qe=We.length+qe.length+Je.length,tt=(0,Q.useMemo)(()=>D.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&W(e)),[D.catalog]),nt=(0,Q.useMemo)(()=>q===`builtin`?tt:q===`all`?Hn([...tt,...D.registryCatalog]):D.registryCatalog,[tt,q,D.registryCatalog]),it=(0,Q.useMemo)(()=>{let e=h?nt.filter(e=>e.understanding?.mode===`activity`):nt;return xe(J===`all`?e:e.filter(e=>ft(e).includes(J)),H,te)},[te,H,nt,h,J]),st=(0,Q.useMemo)(()=>dt.filter(e=>nt.some(t=>ft(t).includes(e))),[nt]);(0,Q.useEffect)(()=>{J!==`all`&&!st.includes(J)&&ie(`all`)},[st,J]);let lt=S===`discover`&&q!==`builtin`&&!!(L&&P<L),pt=(0,Q.useMemo)(()=>D.instances.find(e=>e.instanceId===ue)??fe,[ue,fe,D.instances]),ht=(0,Q.useMemo)(()=>[{value:`all`,label:s.discoverSourceAll},{value:Ln,label:s.discoverSourceBuiltin},...je.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,je]),gt=[{id:`connected`,label:s.tabConnected,count:Ee},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:x(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[d?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),h?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>f(g),children:s.understandingSetupDone})]}):null,v?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>f(g),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)($e,{items:gt,activeTab:S,onChange:Ae,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),D.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.error}):null,S===`connected`&&d?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:D.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":s.loading,children:at.slice(0,3).map(e=>(0,$.jsx)(ut,{},e))}):Ee===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(F,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ae(`discover`),children:s.addFromCatalog})]}):Qe===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ge.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ge.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ge.map(e=>(0,$.jsx)(vn,{instance:e,definition:Pe.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{ge(null),de(e.instanceId),X(e)},t:s},e.instanceId))})]}):null,Ke.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Ke.map(e=>(0,$.jsx)(vn,{instance:e,definition:Pe.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{ge(null),de(e.instanceId),X(e)},t:s},e.instanceId))})}):null,Je.map(({extension:e,server:t})=>(0,$.jsx)(et,{pluginId:e.pluginId,server:t,enabled:e.active},t.id)),qe.length||!B.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:s.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:qe.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:s.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Re,children:s.addCustomServerAdvanced})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:qe.map(e=>(0,$.jsx)(tn,{row:e,lastCheck:De[e.id],t:c,cs:s,onEdit:()=>be({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Le(e)},e.clientKey))})]})]}):null]})}):null,S===`discover`&&d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[h?null:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,children:[`all`,...st].map(e=>(0,$.jsx)(`button`,{type:`button`,className:x(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,J===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":J===e,onClick:()=>ie(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:x(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,h?`grid-cols-1`:`grid-cols-2`),children:[h?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:q,options:ht,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee})}),(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:te,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>re(e)})})]})]}),(D.loading||k)&&it.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:at.map(e=>(0,$.jsx)(ct,{},e))}):it.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[k?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(_,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:it.map(e=>(0,$.jsx)(rt,{connector:e,installed:Ne.has(e.id)||ot(e,D.instances),onInstall:e=>{if(e.source===`store`){Fe(e.id);return}oe(he(e))},onOpenDetails:e.source===`store`?void 0:Y,t:s},e.id))}),lt?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(F,{type:`button`,variant:`secondary`,disabled:k||j,onClick:()=>void Me({page:P+1,append:!0}),children:[k?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),ae?(0,$.jsx)(ye,{draft:ae,onChange:oe,onClose:()=>oe(null),t:s,onInstalled:async e=>{await ke(),await Ce(),ge(e.instanceId),Ae(`connected`)}}):null,se?(0,$.jsx)(vt,{connector:se,installed:Ne.has(se.id)||ot(se,D.instances),onClose:()=>Y(null),onInstall:e=>oe(he(e)),t:s}):null,pt?(0,$.jsx)(_n,{instance:pt,definition:Pe.get(pt.connectorId),onClose:()=>{de(null),X(null)},onChanged:ke,t:s,mcp:c}):null,ve?(0,$.jsx)(In,{open:!0,mode:ve.mode,initialRow:ve.row,existingCustomServers:Te,config:Z,managedServerIds:Ie,t:c,cs:s,onClose:()=>be(null),onSaved:async()=>{await Ce(),await ke(),Ae(`connected`)}},`${ve.mode}-${ve.row.clientKey}`):null]})})}export{Wn as ConnectorsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chevron-left-DqFhpbvK.js";import{t as a}from"./chevron-right-BweFrslA.js";import{c as ee,l as te,u as ne}from"./popover-select-DHC7J4lG.js";import{t as re}from"./cn-0WouolD0.js";import{n as ie}from"./locale-store-uRu_DsWm.js";import{c as ae,n as oe,s as se}from"./dist-C3DSFZCi.js";import{jc as ce}from"./index-CNH8vwcY.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(105),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=ie(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ee(Se),Ee=ne(te(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=ae,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=re(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=re(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(se,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=ae,Pe=Te??void 0,Fe=ae,Ie=re(Ee,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Le=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(i,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Le?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:I,children:L}),t[42]=Le,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let Re=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(a,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===Re?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:B,children:V}),t[48]=Re,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:re(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let ze=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Be=f===`zh`?`清除`:`Clear`,J;t[75]!==ze||t[76]!==q||t[77]!==Be?(J=(0,c.jsx)(`button`,{type:`button`,disabled:ze,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Be}),t[75]=ze,t[76]=q,t[77]=Be,t[78]=J):J=t[78];let Ve=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let He=f===`zh`?`今天`:`Today`,X;t[81]!==Ve||t[82]!==Y||t[83]!==He?(X=(0,c.jsx)(`button`,{type:`button`,disabled:Ve,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:He}),t[81]=Ve,t[82]=Y,t[83]=He,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let Ue;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,c.jsx)(oe,{className:`fill-surface-overlay`}),t[88]=Ue):Ue=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==U||t[92]!==W||t[93]!==K||t[94]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Ie,children:[U,W,K,Z,Ue]}),t[89]=Fe.Content,t[90]=Ie,t[91]=U,t[92]=W,t[93]=K,t[94]=Z,t[95]=Q):Q=t[95];let $;t[96]!==Ne.Portal||t[97]!==Pe||t[98]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[96]=Ne.Portal,t[97]=Pe,t[98]=Q,t[99]=$):$=t[99];let We;return t[100]!==h||t[101]!==Ae.Root||t[102]!==F||t[103]!==$?(We=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[100]=h,t[101]=Ae.Root,t[102]=F,t[103]=$,t[104]=We):We=t[104],We}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chevron-left-DqFhpbvK.js";import{t as a}from"./chevron-right-BweFrslA.js";import{c as ee,l as te,u as ne}from"./popover-select-DHC7J4lG.js";import{t as re}from"./cn-0WouolD0.js";import{n as ie}from"./locale-store-DMy9W6IG.js";import{c as ae,n as oe,s as se}from"./dist-C3DSFZCi.js";import{Wc as ce}from"./index-xTL-vb51.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(105),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=ie(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ee(Se),Ee=ne(te(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=ae,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=re(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=re(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(se,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=ae,Pe=Te??void 0,Fe=ae,Ie=re(Ee,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Le=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(i,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Le?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:I,children:L}),t[42]=Le,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let Re=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(a,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===Re?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:B,children:V}),t[48]=Re,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:re(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let ze=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Be=f===`zh`?`清除`:`Clear`,J;t[75]!==ze||t[76]!==q||t[77]!==Be?(J=(0,c.jsx)(`button`,{type:`button`,disabled:ze,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Be}),t[75]=ze,t[76]=q,t[77]=Be,t[78]=J):J=t[78];let Ve=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let He=f===`zh`?`今天`:`Today`,X;t[81]!==Ve||t[82]!==Y||t[83]!==He?(X=(0,c.jsx)(`button`,{type:`button`,disabled:Ve,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:He}),t[81]=Ve,t[82]=Y,t[83]=He,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let Ue;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,c.jsx)(oe,{className:`fill-surface-overlay`}),t[88]=Ue):Ue=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==U||t[92]!==W||t[93]!==K||t[94]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Ie,children:[U,W,K,Z,Ue]}),t[89]=Fe.Content,t[90]=Ie,t[91]=U,t[92]=W,t[93]=K,t[94]=Z,t[95]=Q):Q=t[95];let $;t[96]!==Ne.Portal||t[97]!==Pe||t[98]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[96]=Ne.Portal,t[97]=Pe,t[98]=Q,t[99]=$):$=t[99];let We;return t[100]!==h||t[101]!==Ae.Root||t[102]!==F||t[103]!==$?(We=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[100]=h,t[101]=Ae.Root,t[102]=F,t[103]=$,t[104]=We):We=t[104],We}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as a}from"./check-DUBLcKHA.js";import{v as o}from"./use-file-preview-expanded-DSKIxfz9.js";import{t as s}from"./search-DA7gz22f.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-0WouolD0.js";import{t as u}from"./button-aIC072nz.js";import{a as d,i as f,o as p,r as m,s as h}from"./copy-text-row-C7egVuKr.js";import{Ac as g}from"./index-CNH8vwcY.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(p,{children:[(0,y.jsx)(h,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(f,{children:(0,y.jsx)(m,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(u,{type:`button`,variant:`secondary`,className:l(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(o,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(g,{className:l(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:l(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:l(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:l(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:l(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(d,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as a}from"./check-DUBLcKHA.js";import{v as o}from"./use-file-preview-expanded-CEsxnDnQ.js";import{t as s}from"./search-DA7gz22f.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-0WouolD0.js";import{t as u}from"./button-aIC072nz.js";import{a as d,i as f,o as p,r as m,s as h}from"./copy-text-row-C7egVuKr.js";import{Uc as g}from"./index-xTL-vb51.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(p,{children:[(0,y.jsx)(h,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(f,{children:(0,y.jsx)(m,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(c,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(u,{type:`button`,variant:`secondary`,className:l(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(o,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(g,{className:l(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:l(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:l(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:l(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:l(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(d,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-DTqbfje6.js";import{n as o}from"./locale-store-uRu_DsWm.js";import{Ac as s,t as c}from"./index-CNH8vwcY.js";import{t as l}from"./desktop-pet-sprite-BP6iMVw1.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function x(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function S(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function ee(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function te(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function C(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function w(e,t,n,r){let i=C(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var T=8e3;function E(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+T:void 0}}function D(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=E(t,e))}return n}function O(e,t){return t?.runId===e.runId&&t.state===e.state}function k(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function A(e){return e?`/chat/${e.conversationId}`:void 0}var j=r();function M(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function N(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function P(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return N(r?.success,t);if(t.state===`waiting`)return N(r?.waiting,t);if(t.state===`error`)return N(r?.error,t)}function F(e,t,n){return e?n?`${e} · ${t}`:e:t}function I(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function ne(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function L(){let e=a(o(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(ne),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[C,T]=(0,u.useState)(null),E=(0,u.useRef)(null),L=(0,u.useRef)(!1),R=(0,u.useRef)(null),z=(0,u.useRef)(null),B=(0,u.useRef)(null),V=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),H=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),U=(0,u.useMemo)(()=>k(Object.values(r),p),[r,p]),W=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>!O(e,d[e.conversationId])&&w(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),G=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>O(e,d[e.conversationId])&&w(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),K=W[0]??U[0],q=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,J=C??(K?M(K):q),Y=e.personaPhrases[V?.persona?.tone??`calm`],X=te({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:W.length,activeCount:U.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>D(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),D(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=R.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[z.current,B.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),z.current&&r.observe(z.current),B.current&&r.observe(B.current),n(),()=>r.disconnect()},[X,W.length,t.prefs.collapsed,H]);let Z=(e=K)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),c(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(A(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(E.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(T(`released`),window.setTimeout(()=>T(null),700),L.current=!0,window.setTimeout(()=>{L.current=!1},0)))},[]),oe=()=>{L.current||Z()};if(!V)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*H)}px`,"--desktop-pet-menu-size":`${Math.round(28*H)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*H)}px`},$=t.prefs.collapsed?W.length:G;return(0,j.jsxs)(`div`,{ref:R,className:`desktop-pet-window`,style:se,children:[!t.prefs.collapsed&&W.length>0?(0,j.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue`,children:W.map(t=>{let n=S(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=x(t,e.tipCompleteSummary),a=ee(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),o=r??n??a??t.action,s=F(P(V,t,Y),o,!!(r||n||a)),c=I(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,j.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,j.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,j.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,j.jsx)(`strong`,{children:t.sessionLabel}),(0,j.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,j.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,j.jsx)(i,{size:12})})]},t.conversationId)})}):null,X?(0,j.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,j.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,j.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,j.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,j.jsx)(`strong`,{children:e.idleTipTitle}),(0,j.jsx)(`span`,{children:N(V.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,j.jsx)(i,{size:12})})]})}):null,(0,j.jsxs)(`div`,{ref:B,className:`desktop-pet-stage`,children:[(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,j.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,j.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!K&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{E.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,title:e.openApp,children:(0,j.jsx)(l,{pet:V,action:J,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*H)})})]})]})}function R(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,j.jsx)(L,{}),e[0]=t):t=e[0],t}export{R as DesktopPetPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-O0BEUKnx.js";import{n as o}from"./locale-store-DMy9W6IG.js";import{Uc as s,t as c}from"./index-xTL-vb51.js";import{t as l}from"./desktop-pet-sprite-BP6iMVw1.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function x(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function S(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function ee(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function te(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function C(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function w(e,t,n,r){let i=C(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var T=8e3;function E(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+T:void 0}}function D(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=E(t,e))}return n}function O(e,t){return t?.runId===e.runId&&t.state===e.state}function k(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function A(e){return e?`/chat/${e.conversationId}`:void 0}var j=r();function M(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function N(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function P(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return N(r?.success,t);if(t.state===`waiting`)return N(r?.waiting,t);if(t.state===`error`)return N(r?.error,t)}function F(e,t,n){return e?n?`${e} · ${t}`:e:t}function I(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function ne(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function L(){let e=a(o(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(ne),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[C,T]=(0,u.useState)(null),E=(0,u.useRef)(null),L=(0,u.useRef)(!1),R=(0,u.useRef)(null),z=(0,u.useRef)(null),B=(0,u.useRef)(null),V=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),H=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),U=(0,u.useMemo)(()=>k(Object.values(r),p),[r,p]),W=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>!O(e,d[e.conversationId])&&w(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),G=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?U.filter(e=>O(e,d[e.conversationId])&&w(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[U,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),K=W[0]??U[0],q=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,J=C??(K?M(K):q),Y=e.personaPhrases[V?.persona?.tone??`calm`],X=te({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:W.length,activeCount:U.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>D(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),D(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=R.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[z.current,B.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),z.current&&r.observe(z.current),B.current&&r.observe(B.current),n(),()=>r.disconnect()},[X,W.length,t.prefs.collapsed,H]);let Z=(e=K)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),c(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(A(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(E.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(T(`released`),window.setTimeout(()=>T(null),700),L.current=!0,window.setTimeout(()=>{L.current=!1},0)))},[]),oe=()=>{L.current||Z()};if(!V)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*H)}px`,"--desktop-pet-menu-size":`${Math.round(28*H)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*H)}px`},$=t.prefs.collapsed?W.length:G;return(0,j.jsxs)(`div`,{ref:R,className:`desktop-pet-window`,style:se,children:[!t.prefs.collapsed&&W.length>0?(0,j.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue`,children:W.map(t=>{let n=S(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=x(t,e.tipCompleteSummary),a=ee(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),o=r??n??a??t.action,s=F(P(V,t,Y),o,!!(r||n||a)),c=I(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,j.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,j.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,j.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,j.jsx)(`strong`,{children:t.sessionLabel}),(0,j.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,j.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,j.jsx)(i,{size:12})})]},t.conversationId)})}):null,X?(0,j.jsx)(`div`,{ref:z,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,j.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,j.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,j.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,j.jsx)(`strong`,{children:e.idleTipTitle}),(0,j.jsx)(`span`,{children:N(V.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,j.jsx)(i,{size:12})})]})}):null,(0,j.jsxs)(`div`,{ref:B,className:`desktop-pet-stage`,children:[(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,j.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,j.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,j.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!K&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{E.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,title:e.openApp,children:(0,j.jsx)(l,{pet:V,action:J,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*H)})})]})]})}function R(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,j.jsx)(L,{}),e[0]=t):t=e[0],t}export{R as DesktopPetPage};