@xopcai/xopc 0.0.404 → 0.0.406

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 (172) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CdwFK70g.js → agent-avatar-dicebear-BE3ci_lj.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BMj9HwIQ.js → agent-defaults-settings-panel-DzDaum4Y.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-hrm6V8Dp.js → agents-BfC3FYYe.js} +3 -3
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-Rg9jOmoj.js → app-management-settings-panel-BDbJKxa-.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-S3yp0GUO.js → appearance-settings-CEOOrVYb.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-ChrJSB_2.js → apps-page-CpoG_3PG.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-J7hwA5cs.js → archive-plugin-B7pzPErg.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-Cesz1cjw.js → automations-page-CcQjEiqk.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-workspace-DdopDyED.js → automations-workspace-BVTP3pzt.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-Bg4Se8Kg.js → binary-plugins-D5kTu6gH.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-Bw1sO9YH.js → block-editor-CnW6rF_e.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-automation-inputs-Y46Mf8aY.js → browser-automation-inputs-CAcUtInP.js} +1 -1
  15. package/dist/gateway/static/root/assets/{browser-automations-page-BcNjBdFQ.js → browser-automations-page-DT7-lnPN.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-ByeqxrSF.js → browser-settings-page-ByK8znt2.js} +1 -1
  17. package/dist/gateway/static/root/assets/{capabilities-CIv3LUQk.js → capabilities-Dl3LttAm.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capabilities-page-BUTQSo3A.js → capabilities-page-C8tv6M_O.js} +2 -2
  19. package/dist/gateway/static/root/assets/{capabilities-settings-panel-B-Uwmjbo.js → capabilities-settings-panel-OVLgL6yL.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-header-actions-BGGJKzPL.js → capability-header-actions-jztljvVW.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-z6iuM4HE.js → channels-D8BKMMPW.js} +1 -1
  22. package/dist/gateway/static/root/assets/{chat-terminal-dock-oMmP0flJ.js → chat-terminal-dock-BVlFOKJj.js} +1 -1
  23. package/dist/gateway/static/root/assets/{computer-settings-page-CERhSG5W.js → computer-settings-page-CvQgrTwb.js} +1 -1
  24. package/dist/gateway/static/root/assets/{connector-service-page-DyW3mLTh.js → connector-service-page-BNcTUa99.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connectors-page-CdMwhiio.js → connectors-page-CWlLRQpK.js} +1 -1
  26. package/dist/gateway/static/root/assets/{date-picker-CO3Jhdzg.js → date-picker-BKUmdSp7.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-DbyMpo5J.js → dependency-picker-BarQvwoO.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-DJ9OAPJs.js → desktop-pet-IvADYxyi.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-CNrNXWlk.js → desktop-pet-settings-y6WzhGEK.js} +1 -1
  30. package/dist/gateway/static/root/assets/{device-pairing-wizard-TzK-VCuf.js → device-pairing-wizard-D3IUZ8xW.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-BmFgRA8G.js → directory-picker-path-field-DnEvwMTm.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-debug-page-C3ZpHHYc.js → extension-debug-page-CCvuK1m0.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-page-gfOwpT2R.js → extension-page-DegRwY3R.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-settings-page-BS7cDqZJ.js → extension-settings-page-B8UQgGgZ.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-UB6hyqcj.js → gateway-settings-DlLyLsXY.js} +1 -1
  36. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BRfDRn2k.js → highlighted-body-KQOG7T2V-MjAoJQJX.js} +1 -1
  37. package/dist/gateway/static/root/assets/{home-page-DBUnR1DO.js → home-page-DAYtNK3o.js} +1 -1
  38. package/dist/gateway/static/root/assets/{image-generation-api-BoMWmqwF.js → image-generation-api-SQDixWjO.js} +1 -1
  39. package/dist/gateway/static/root/assets/{imports-page-CPiPsiEP.js → imports-page-1ZId0Ng0.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-DmURUvvA.js → index-K2cy4f-3.js} +116 -116
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9y8h4dR.js → keyboard-shortcuts-settings-yMwBt1Sv.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-app-workbench-page-DoAmV6on.js → local-app-workbench-page-a7J0NPIs.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-apps-page-CE6Ag8oQ.js → local-apps-page-CF6_kS9C.js} +1 -1
  44. package/dist/gateway/static/root/assets/{logs-page-DFysUb2k.js → logs-page-C8y5yhoM.js} +1 -1
  45. package/dist/gateway/static/root/assets/{management-settings-CmXPsu0I.js → management-settings-C7dL_jNu.js} +1 -1
  46. package/dist/gateway/static/root/assets/{media-plugins-DvfdiczR.js → media-plugins-UYX1YivF.js} +1 -1
  47. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-7zpLTDLZ.js +1 -0
  48. package/dist/gateway/static/root/assets/{note-detail-panel-BpddDFQt.js → note-detail-panel-Bxm523Up.js} +3 -3
  49. package/dist/gateway/static/root/assets/note-image-lightbox-B7ARnjnB.js +1 -0
  50. package/dist/gateway/static/root/assets/{notes-page-DQ4KZsWt.js → notes-page-BOeS2v6x.js} +1 -1
  51. package/dist/gateway/static/root/assets/{page-context-capture-button-BcxVEGa2.js → page-context-capture-button-DOrPS73o.js} +1 -1
  52. package/dist/gateway/static/root/assets/{personal-page-CCQDxb7E.js → personal-page-BujiHops.js} +1 -1
  53. package/dist/gateway/static/root/assets/{plugin-details-dialog-CGFQ_-bG.js → plugin-details-dialog-XOzQrJQN.js} +1 -1
  54. package/dist/gateway/static/root/assets/{plugin-presentation-DF1gfuGf.js → plugin-presentation-CPEwVLd4.js} +1 -1
  55. package/dist/gateway/static/root/assets/{preview-open-alternatives-CXjjpXVx.js → preview-open-alternatives-BP9C0kH3.js} +1 -1
  56. package/dist/gateway/static/root/assets/{product-open-page-DqiyvM4c.js → product-open-page-D151rJVy.js} +1 -1
  57. package/dist/gateway/static/root/assets/{product-preview-content-f7Q4giA3.js → product-preview-content-CAo0XpP-.js} +1 -1
  58. package/dist/gateway/static/root/assets/project-detail-page-CxB_kF0F.js +1 -0
  59. package/dist/gateway/static/root/assets/{projects-page-DO_pIhy-.js → projects-page-Dvu_3c2g.js} +1 -1
  60. package/dist/gateway/static/root/assets/{remote-access-hub-BFtELmg0.js → remote-access-hub-CbzBV_BL.js} +1 -1
  61. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B9Beu-oK.js → runtime-tools-settings-panel-DyLxlqWV.js} +1 -1
  62. package/dist/gateway/static/root/assets/{schema-form-ZAX7C5uI.js → schema-form-ClP4uPSj.js} +1 -1
  63. package/dist/gateway/static/root/assets/{session-manager-BUMUjup5.js → session-manager-DMDBMYfh.js} +2 -2
  64. package/dist/gateway/static/root/assets/{sessions-page-D27knqOl.js → sessions-page-CvfoPeM6.js} +1 -1
  65. package/dist/gateway/static/root/assets/settings-advanced-gate-BOkrHL8q.js +1 -0
  66. package/dist/gateway/static/root/assets/{settings-form-section-BTUFu5KS.js → settings-form-section-B4NShgv-.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-YFr6zzh7.js → settings-page-C54bw5J9.js} +1 -1
  68. package/dist/gateway/static/root/assets/{setup-status-panel-C5Jszsd1.js → setup-status-panel-BVKQ2inq.js} +1 -1
  69. package/dist/gateway/static/root/assets/{share-preview-page-CsfrvY_G.js → share-preview-page-BxN9t3MD.js} +1 -1
  70. package/dist/gateway/static/root/assets/{shares-settings-BW6BNot0.js → shares-settings-BOa9NAUc.js} +1 -1
  71. package/dist/gateway/static/root/assets/{skill-api-o3HSgF_K.js → skill-api-E0E-MH1S.js} +1 -1
  72. package/dist/gateway/static/root/assets/{skill-reload-api-BJsPnE87.js → skill-reload-api-DEN6tOwG.js} +1 -1
  73. package/dist/gateway/static/root/assets/{skills-page-Kuf2t7MG.js → skills-page-CeNVBQG9.js} +1 -1
  74. package/dist/gateway/static/root/assets/{style-DOz6lLJB.js → style-Bs9x3WBj.js} +1 -1
  75. package/dist/gateway/static/root/assets/{system-settings-panel-B69rR6vw.js → system-settings-panel-DpQPaJId.js} +1 -1
  76. package/dist/gateway/static/root/assets/task-detail-page-DzK53B5p.js +2 -0
  77. package/dist/gateway/static/root/assets/{task-expandable-content-BZCJqajv.js → task-expandable-content-BoGtWYbk.js} +1 -1
  78. package/dist/gateway/static/root/assets/{tasks-PuIUgF9L.js → tasks-B4bZpO6O.js} +1 -1
  79. package/dist/gateway/static/root/assets/{tracing-settings-page-BIq3Ayeg.js → tracing-settings-page-BUUnZfZW.js} +1 -1
  80. package/dist/gateway/static/root/assets/{tunnel-api-V9pJ8fUo.js → tunnel-api-3GopOQ_S.js} +1 -1
  81. package/dist/gateway/static/root/assets/{usage-page-DZdpti28.js → usage-page-B8j47CWQ.js} +1 -1
  82. package/dist/gateway/static/root/assets/{use-autosave-BnMIUc_5.js → use-autosave-CYIuWnRn.js} +1 -1
  83. package/dist/gateway/static/root/assets/{user-model-page-BEgJ97hp.js → user-model-page-DxcH74eP.js} +1 -1
  84. package/dist/gateway/static/root/assets/{voice-api-key-field-1h6fMaZL.js → voice-api-key-field-BN37Lklj.js} +1 -1
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-CVNqSNz8.js → work-discovery-overlay-C_bcAAX6.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dq63AthQ.js → workflow-run-setup-panel-B5oKCzTn.js} +1 -1
  87. package/dist/gateway/static/root/assets/{workflows-page-CfA1iwZu.js → workflows-page-Bo5b5t_9.js} +1 -1
  88. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BsW2acj1.js → xopc-cloud-account-card-DGGi4zVC.js} +1 -1
  89. package/dist/gateway/static/root/index.html +4 -4
  90. package/dist/package.js +1 -1
  91. package/dist/packages/gateway-contract/src/tasks.js +27 -8
  92. package/dist/src/agent/agent-manager.js +1 -1
  93. package/dist/src/agent/background-review/run-background-review.js +1 -1
  94. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  95. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  96. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  97. package/dist/src/agent/service.js +1 -1
  98. package/dist/src/agent/skills/index.js +1 -1
  99. package/dist/src/agent/skills/managed-store.js +1 -1
  100. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  101. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  102. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  103. package/dist/src/agent-catalog/capabilities.js +2 -2
  104. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
  105. package/dist/src/agent-catalog/repository.js +1 -1
  106. package/dist/src/automations/capabilities/drafts.js +1 -1
  107. package/dist/src/automations/capabilities/write.d.ts +14 -0
  108. package/dist/src/automations/domain/validation.d.ts +28 -0
  109. package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
  110. package/dist/src/bootstrap/application-state.js +1 -1
  111. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  112. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  113. package/dist/src/capabilities/runtime/product.js +1 -1
  114. package/dist/src/cli/commands/agents.js +1 -1
  115. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  116. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  117. package/dist/src/cli/commands/extension.js +1 -1
  118. package/dist/src/cli/commands/models.js +1 -1
  119. package/dist/src/cli/commands/onboard/model.js +1 -1
  120. package/dist/src/cli/commands/onboard.js +1 -1
  121. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  122. package/dist/src/config/agent-profile.js +1 -1
  123. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  124. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  125. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  126. package/dist/src/extensions/update.js +1 -1
  127. package/dist/src/gateway/agents-admin.js +2 -2
  128. package/dist/src/gateway/hono/routes/agents.js +1 -1
  129. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  130. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  131. package/dist/src/gateway/hono/routes/config.js +1 -1
  132. package/dist/src/gateway/hono/routes/notes.js +2 -2
  133. package/dist/src/gateway/hono/routes/projects.js +2 -2
  134. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  135. package/dist/src/gateway/hono/routes/tasks.js +3 -2
  136. package/dist/src/gateway/image-generation-setup.js +1 -1
  137. package/dist/src/gateway/service/config-coordinator.js +1 -1
  138. package/dist/src/gateway/service/run-gateway-agent.js +1 -0
  139. package/dist/src/gateway/service.js +6 -6
  140. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  141. package/dist/src/home-intelligence/host.js +2 -2
  142. package/dist/src/imports/importService.js +1 -1
  143. package/dist/src/infra/update-runner.js +1 -1
  144. package/dist/src/local-apps/service.js +1 -1
  145. package/dist/src/personal-agent/service.js +1 -1
  146. package/dist/src/providers/prompt-cache-lifecycle.d.ts +1 -1
  147. package/dist/src/providers/prompt-cache-lifecycle.js +1 -1
  148. package/dist/src/runtime-tools/archive.js +1 -1
  149. package/dist/src/storage/sqlite/migrations/258_task_phase_changes.sql +20 -0
  150. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  151. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  152. package/dist/src/storage/sqlite/schema.js +1 -1
  153. package/dist/src/tasks/capabilities/read.js +3 -2
  154. package/dist/src/tasks/capabilities/write.js +3 -3
  155. package/dist/src/tasks/task-application-service.d.ts +2 -1
  156. package/dist/src/tasks/task-application-service.js +80 -12
  157. package/dist/src/tasks/task-collaboration-delivery.js +2 -1
  158. package/dist/src/tasks/task-context-assembler.js +2 -1
  159. package/dist/src/tasks/task-read-model-projector.js +13 -5
  160. package/dist/src/tasks/task-repository.d.ts +11 -1
  161. package/dist/src/tasks/task-repository.js +42 -7
  162. package/dist/src/tasks/task-run-coordinator.d.ts +2 -0
  163. package/dist/src/tasks/task-run-coordinator.js +26 -17
  164. package/dist/src/tasks/task-run-repository.js +5 -2
  165. package/dist/src/tui/backends/embedded-backend.js +1 -1
  166. package/dist/src/voice/realtime/persona-context.js +1 -1
  167. package/package.json +4 -4
  168. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-SuiLTd5Y.js +0 -1
  169. package/dist/gateway/static/root/assets/note-image-lightbox-CMLVzPsQ.js +0 -1
  170. package/dist/gateway/static/root/assets/project-detail-page-PBK7vXK5.js +0 -1
  171. package/dist/gateway/static/root/assets/settings-advanced-gate-CDzdr1zW.js +0 -1
  172. package/dist/gateway/static/root/assets/task-detail-page-DOb97OLI.js +0 -2
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/skills-page-Kuf2t7MG.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-DmURUvvA.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-D5h-Ha6-.js","assets/messages-Bwv-AOYl.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-CthsQiiO.js","assets/dist-BGTk37IG.js","assets/chunk-KS7C4IRE-B2HK1psj.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/mermaid-render-604gISVe.js","assets/xml-_d7dTN2Q.js","assets/app-link-BV_eGr7l.js","assets/product-delivery-DwmnNJvk.js","assets/schemas-CObaziC7.js","assets/local-apps-yys1VChX.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-Ct4sKkUf.css","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/folder-open-CyzJ19I9.js","assets/session-manager-BUMUjup5.js","assets/gateway-realtime-SBtdXzco.js","assets/gateway-realtime-store-dKq2fm2X.js","assets/local-session-drafts-DhJjHCfQ.js","assets/session-api-fVuszA_P.js","assets/gateway-startup-retry-CEpuztYK.js","assets/constants-DeXt1mV-.js","assets/tool-activity-BtJkgjFf.js","assets/registry-api-Bf0hVPNV.js","assets/attachment-utils-core-BIOUBrpT.js","assets/agents-admin-api-D6XzhsQy.js","assets/gateway-config-swr-BvuySoCX.js","assets/capabilities-CIv3LUQk.js","assets/tasks-PuIUgF9L.js","assets/specialists-4bkS5rZ4.js","assets/files-Bw4SBGdM.js","assets/sliding-indicator-hwz0sx3h.js","assets/index-QegseiyI.css","assets/capability-header-actions-BGGJKzPL.js","assets/capability-icon-DVoZxEgW.js","assets/capability-links-DzQWK1Fh.js","assets/skill-api-o3HSgF_K.js","assets/skill-reload-api-BJsPnE87.js","assets/connectors-page-CdMwhiio.js","assets/number-input-DDeqHK-G.js","assets/connector-service-page-DyW3mLTh.js","assets/plugin-details-dialog-CGFQ_-bG.js","assets/plugin-presentation-DF1gfuGf.js","assets/browser-BLJWD7WI.js","assets/apps-page-ChrJSB_2.js","assets/agents-hrm6V8Dp.js","assets/directory-picker-path-field-BmFgRA8G.js","assets/image-generation-api-BoMWmqwF.js","assets/settings-page-layout-Dx5S-Msc.js","assets/channels-z6iuM4HE.js","assets/schema-form-ZAX7C5uI.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as ee}from"./messages-Bwv-AOYl.js";import{n as te}from"./locale-store-D5h-Ha6-.js";import{Go as u,Rc as d,bl as f,yl as p}from"./index-DmURUvvA.js";import{t as m}from"./capability-links-DzQWK1Fh.js";import{t as ne}from"./capability-header-actions-BGGJKzPL.js";var h=n(),g=r();function re(e){let t=(0,h.c)(11),{section:n,zh:r}=e,i;t[0]!==n||t[1]!==r?(i=n===`skills`?{text:r?`查看 Agent 可使用的技能。插件附带的技能由所属插件统一更新和卸载。`:`Browse skills available to agents. Skills included in a plugin are updated and removed with that plugin.`,href:`/capabilities/extensions?tab=user`,label:r?`管理插件`:`Manage plugins`}:n===`connectors`?{text:r?`管理账号连接与授权。插件提供的账号统一在插件详情中连接。`:`Manage accounts and authorization. Connect plugin accounts from their plugin details.`,href:`/capabilities/extensions?tab=marketplace`,label:r?`发现更多插件`:`Discover plugins`}:n===`extensions`?{text:r?`安装和管理整套能力,包括技能、工具与账号连接。默认供所有 Agent 使用。`:`Install and manage skills, tools and account connections together. Available to all agents by default.`,href:`/capabilities/connectors?tab=connected`,label:r?`查看账号连接`:`View connections`}:null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;t[3]===a.text?o=t[4]:(o=(0,g.jsx)(`p`,{className:`text-fg-muted`,children:a.text}),t[3]=a.text,t[4]=o);let s;t[5]!==a.href||t[6]!==a.label?(s=(0,g.jsx)(l,{className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:a.href,children:a.label}),t[5]=a.href,t[6]=a.label,t[7]=s):s=t[7];let c;return t[8]!==o||t[9]!==s?(c=(0,g.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-wrap items-center gap-x-3 gap-y-1 px-4 pb-1 pt-3 text-xs leading-5 sm:px-6 lg:px-8`,children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10],c}var _=e(t(),1),ie=(0,_.lazy)(()=>i(()=>import(`./skills-page-Kuf2t7MG.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59]))),ae=(0,_.lazy)(()=>i(()=>import(`./connectors-page-CdMwhiio.js`).then(e=>({default:e.ConnectorsPage})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,61,55,56,57,62]))),oe=(0,_.lazy)(()=>i(()=>import(`./plugin-details-dialog-CGFQ_-bG.js`).then(e=>({default:e.PluginDetailsDialog})),__vite__mapDeps([63,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,56,57,64,65]))),se=(0,_.lazy)(()=>i(()=>import(`./apps-page-ChrJSB_2.js`).then(e=>({default:e.ExtensionsPage})),__vite__mapDeps([66,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,64,65]))),ce=(0,_.lazy)(()=>i(()=>import(`./agents-hrm6V8Dp.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([67,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,61,68,69,70]))),v=(0,_.lazy)(()=>i(()=>import(`./channels-z6iuM4HE.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([71,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,65,72,61,70])));function y(e){return p.includes(e)?e:null}function b(e){let t=(0,h.c)(3),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Array.from({length:6},x),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,g.jsx)(`div`,{className:`mx-auto grid w-full max-w-7xl gap-4 px-4 pb-7 pt-3 sm:grid-cols-2 sm:px-6 lg:grid-cols-3 lg:px-8 lg:pb-9 lg:pt-4`,"aria-label":n,"aria-busy":!0,children:r}),t[1]=n,t[2]=i),i}function x(e,t){return(0,g.jsx)(d,{className:`h-40 rounded-xl`},t)}function S(){let e=(0,h.c)(70),t=te(T),n;e[0]===t?n=e[1]:(n=ee(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesHub,{section:l,detailId:d}=s(),[x]=o(),S=a(),E;e[2]===x?E=e[3]:(E=x.get(`plugin`),e[2]=x,e[3]=E);let D=E,O;e[4]!==S||e[5]!==x?(O=()=>{let e=new URLSearchParams(x);e.delete(`plugin`),e.delete(`connect`),S({search:e.toString()},{replace:!0,preventScrollReset:!0})},e[4]=S,e[5]=x,e[6]=O):O=e[6];let k=O,A;e[7]===l?A=e[8]:(A=y(l),e[7]=l,e[8]=A);let j=A,M=j??p[0],N=r.productNavigation.sections[`capabilities-${M}`],P=u(w),F=u(C),I;e[9]===M?I=e[10]:(I={section:M,value:null},e[9]=M,e[10]=I);let[L,R]=(0,_.useState)(I),z=M===`extensions`&&d?null:L.section===M?L.value:null,B;e[11]===M?B=e[12]:(B=e=>{R({section:M,value:e})},e[11]=M,e[12]=B);let V=B,H,U;if(e[13]!==F||e[14]!==z||e[15]!==N||e[16]!==P?(H=()=>(P({startExtra:null,main:(0,g.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:N}),end:(0,g.jsx)(ne,{contribution:z})}),()=>F()),U=[F,z,N,P],e[13]=F,e[14]=z,e[15]=N,e[16]=P,e[17]=H,e[18]=U):(H=e[17],U=e[18]),(0,_.useLayoutEffect)(H,U),M===`extensions`&&d){let t;e[19]===x?t=e[20]:(t=x.get(`from`)===`connections`?`connections`:x.get(`from`)===`skills`?`skills`:`installed`,e[19]=x,e[20]=t);let n;e[21]===x?n=e[22]:(n=x.get(`connect`),e[21]=x,e[22]=n);let r=n===`1`,i;e[23]!==d||e[24]!==x||e[25]!==r||e[26]!==t?(i=m(d,t,r,x.get(`returnTo`)??void 0),e[23]=d,e[24]=x,e[25]=r,e[26]=t,e[27]=i):i=e[27];let a;return e[28]===i?a=e[29]:(a=(0,g.jsx)(c,{replace:!0,to:i}),e[28]=i,e[29]=a),a}if(!j){let t;return e[30]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,g.jsx)(c,{to:f(p[0]),replace:!0}),e[30]=t):t=e[30],t}let W;e[31]!==d||e[32]!==t||e[33]!==M?(W=d?null:(0,g.jsx)(re,{section:M,zh:t.startsWith(`zh`)}),e[31]=d,e[32]=t,e[33]=M,e[34]=W):W=e[34];let G;e[35]===i.discoverLoading?G=e[36]:(G=(0,g.jsx)(b,{label:i.discoverLoading}),e[35]=i.discoverLoading,e[36]=G);let K;e[37]!==d||e[38]!==V||e[39]!==M?(K=M===`agents`?(0,g.jsx)(ce,{agentId:d,onHeaderActionChange:V}):null,e[37]=d,e[38]=V,e[39]=M,e[40]=K):K=e[40];let q;e[41]!==V||e[42]!==M?(q=M===`skills`?(0,g.jsx)(ie,{embedded:!0,onHeaderActionChange:V}):null,e[41]=V,e[42]=M,e[43]=q):q=e[43];let J;e[44]!==V||e[45]!==M?(J=M===`connectors`?(0,g.jsx)(ae,{embedded:!0,onHeaderActionChange:V}):null,e[44]=V,e[45]=M,e[46]=J):J=e[46];let Y;e[47]!==d||e[48]!==V||e[49]!==M?(Y=M===`channels`?(0,g.jsx)(v,{channelId:d,onHeaderActionChange:V}):null,e[47]=d,e[48]=V,e[49]=M,e[50]=Y):Y=e[50];let X;e[51]!==V||e[52]!==M?(X=M===`extensions`?(0,g.jsx)(se,{embedded:!0,onHeaderActionChange:V}):null,e[51]=V,e[52]=M,e[53]=X):X=e[53];let Z;e[54]!==M||e[55]!==K||e[56]!==q||e[57]!==J||e[58]!==Y||e[59]!==X||e[60]!==G?(Z=(0,g.jsxs)(_.Suspense,{fallback:G,children:[K,q,J,Y,X]},M),e[54]=M,e[55]=K,e[56]=q,e[57]=J,e[58]=Y,e[59]=X,e[60]=G,e[61]=Z):Z=e[61];let Q;e[62]!==k||e[63]!==D||e[64]!==x?(Q=D?(0,g.jsx)(_.Suspense,{fallback:null,children:(0,g.jsx)(oe,{pluginId:D,initialConnect:x.get(`connect`)===`1`,onClose:k},D)}):null,e[62]=k,e[63]=D,e[64]=x,e[65]=Q):Q=e[65];let $;return e[66]!==Z||e[67]!==Q||e[68]!==W?($=(0,g.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[W,Z,Q]}),e[66]=Z,e[67]=Q,e[68]=W,e[69]=$):$=e[69],$}function C(e){return e.clearPageHeader}function w(e){return e.setPageHeader}function T(e){return e.language}export{S as CapabilitiesPage};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/skills-page-CeNVBQG9.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-K2cy4f-3.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/middleware-Pd0e8Igk.js","assets/locale-store-D5h-Ha6-.js","assets/messages-Bwv-AOYl.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-CthsQiiO.js","assets/dist-BGTk37IG.js","assets/chunk-KS7C4IRE-B2HK1psj.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/mermaid-render-604gISVe.js","assets/xml-_d7dTN2Q.js","assets/app-link-BV_eGr7l.js","assets/product-delivery-DwmnNJvk.js","assets/schemas-CObaziC7.js","assets/local-apps-yys1VChX.js","assets/cn-0WouolD0.js","assets/bundle-mjs-rHxsej31.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-Ct4sKkUf.css","assets/vendor-swr-BIWyz7Rc.js","assets/check-DUBLcKHA.js","assets/circle-check-C23XjkUj.js","assets/copy-Dv6d4Dvw.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/eye-CABVeTq0.js","assets/folder-open-CyzJ19I9.js","assets/session-manager-DMDBMYfh.js","assets/gateway-realtime-SBtdXzco.js","assets/gateway-realtime-store-dKq2fm2X.js","assets/local-session-drafts-DhJjHCfQ.js","assets/session-api-fVuszA_P.js","assets/gateway-startup-retry-CEpuztYK.js","assets/constants-DeXt1mV-.js","assets/tool-activity-BtJkgjFf.js","assets/registry-api-Bf0hVPNV.js","assets/attachment-utils-core-BIOUBrpT.js","assets/agents-admin-api-D6XzhsQy.js","assets/gateway-config-swr-BvuySoCX.js","assets/capabilities-Dl3LttAm.js","assets/tasks-B4bZpO6O.js","assets/specialists-4bkS5rZ4.js","assets/files-Bw4SBGdM.js","assets/sliding-indicator-hwz0sx3h.js","assets/index-QegseiyI.css","assets/capability-header-actions-jztljvVW.js","assets/capability-icon-DVoZxEgW.js","assets/capability-links-DzQWK1Fh.js","assets/skill-api-E0E-MH1S.js","assets/skill-reload-api-DEN6tOwG.js","assets/connectors-page-CWlLRQpK.js","assets/number-input-DDeqHK-G.js","assets/connector-service-page-BNcTUa99.js","assets/plugin-details-dialog-XOzQrJQN.js","assets/plugin-presentation-CPEwVLd4.js","assets/browser-BLJWD7WI.js","assets/apps-page-CpoG_3PG.js","assets/agents-BfC3FYYe.js","assets/directory-picker-path-field-DnEvwMTm.js","assets/image-generation-api-SQDixWjO.js","assets/settings-page-layout-Dx5S-Msc.js","assets/channels-D8BKMMPW.js","assets/schema-form-ClP4uPSj.js"])))=>i.map(i=>d[i]);
2
+ 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"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as ee}from"./messages-Bwv-AOYl.js";import{n as te}from"./locale-store-D5h-Ha6-.js";import{Go as u,Rc as d,bl as f,yl as p}from"./index-K2cy4f-3.js";import{t as m}from"./capability-links-DzQWK1Fh.js";import{t as ne}from"./capability-header-actions-jztljvVW.js";var h=n(),g=r();function re(e){let t=(0,h.c)(11),{section:n,zh:r}=e,i;t[0]!==n||t[1]!==r?(i=n===`skills`?{text:r?`查看 Agent 可使用的技能。插件附带的技能由所属插件统一更新和卸载。`:`Browse skills available to agents. Skills included in a plugin are updated and removed with that plugin.`,href:`/capabilities/extensions?tab=user`,label:r?`管理插件`:`Manage plugins`}:n===`connectors`?{text:r?`管理账号连接与授权。插件提供的账号统一在插件详情中连接。`:`Manage accounts and authorization. Connect plugin accounts from their plugin details.`,href:`/capabilities/extensions?tab=marketplace`,label:r?`发现更多插件`:`Discover plugins`}:n===`extensions`?{text:r?`安装和管理整套能力,包括技能、工具与账号连接。默认供所有 Agent 使用。`:`Install and manage skills, tools and account connections together. Available to all agents by default.`,href:`/capabilities/connectors?tab=connected`,label:r?`查看账号连接`:`View connections`}:null,t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;t[3]===a.text?o=t[4]:(o=(0,g.jsx)(`p`,{className:`text-fg-muted`,children:a.text}),t[3]=a.text,t[4]=o);let s;t[5]!==a.href||t[6]!==a.label?(s=(0,g.jsx)(l,{className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:a.href,children:a.label}),t[5]=a.href,t[6]=a.label,t[7]=s):s=t[7];let c;return t[8]!==o||t[9]!==s?(c=(0,g.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-wrap items-center gap-x-3 gap-y-1 px-4 pb-1 pt-3 text-xs leading-5 sm:px-6 lg:px-8`,children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10],c}var _=e(t(),1),ie=(0,_.lazy)(()=>i(()=>import(`./skills-page-CeNVBQG9.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59]))),ae=(0,_.lazy)(()=>i(()=>import(`./connectors-page-CWlLRQpK.js`).then(e=>({default:e.ConnectorsPage})),__vite__mapDeps([60,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,61,55,56,57,62]))),oe=(0,_.lazy)(()=>i(()=>import(`./plugin-details-dialog-XOzQrJQN.js`).then(e=>({default:e.PluginDetailsDialog})),__vite__mapDeps([63,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,56,57,64,65]))),se=(0,_.lazy)(()=>i(()=>import(`./apps-page-CpoG_3PG.js`).then(e=>({default:e.ExtensionsPage})),__vite__mapDeps([66,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,64,65]))),ce=(0,_.lazy)(()=>i(()=>import(`./agents-BfC3FYYe.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([67,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,61,68,69,70]))),v=(0,_.lazy)(()=>i(()=>import(`./channels-D8BKMMPW.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([71,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,65,72,61,70])));function y(e){return p.includes(e)?e:null}function b(e){let t=(0,h.c)(3),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Array.from({length:6},x),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,g.jsx)(`div`,{className:`mx-auto grid w-full max-w-7xl gap-4 px-4 pb-7 pt-3 sm:grid-cols-2 sm:px-6 lg:grid-cols-3 lg:px-8 lg:pb-9 lg:pt-4`,"aria-label":n,"aria-busy":!0,children:r}),t[1]=n,t[2]=i),i}function x(e,t){return(0,g.jsx)(d,{className:`h-40 rounded-xl`},t)}function S(){let e=(0,h.c)(70),t=te(T),n;e[0]===t?n=e[1]:(n=ee(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesHub,{section:l,detailId:d}=s(),[x]=o(),S=a(),E;e[2]===x?E=e[3]:(E=x.get(`plugin`),e[2]=x,e[3]=E);let D=E,O;e[4]!==S||e[5]!==x?(O=()=>{let e=new URLSearchParams(x);e.delete(`plugin`),e.delete(`connect`),S({search:e.toString()},{replace:!0,preventScrollReset:!0})},e[4]=S,e[5]=x,e[6]=O):O=e[6];let k=O,A;e[7]===l?A=e[8]:(A=y(l),e[7]=l,e[8]=A);let j=A,M=j??p[0],N=r.productNavigation.sections[`capabilities-${M}`],P=u(w),F=u(C),I;e[9]===M?I=e[10]:(I={section:M,value:null},e[9]=M,e[10]=I);let[L,R]=(0,_.useState)(I),z=M===`extensions`&&d?null:L.section===M?L.value:null,B;e[11]===M?B=e[12]:(B=e=>{R({section:M,value:e})},e[11]=M,e[12]=B);let V=B,H,U;if(e[13]!==F||e[14]!==z||e[15]!==N||e[16]!==P?(H=()=>(P({startExtra:null,main:(0,g.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:N}),end:(0,g.jsx)(ne,{contribution:z})}),()=>F()),U=[F,z,N,P],e[13]=F,e[14]=z,e[15]=N,e[16]=P,e[17]=H,e[18]=U):(H=e[17],U=e[18]),(0,_.useLayoutEffect)(H,U),M===`extensions`&&d){let t;e[19]===x?t=e[20]:(t=x.get(`from`)===`connections`?`connections`:x.get(`from`)===`skills`?`skills`:`installed`,e[19]=x,e[20]=t);let n;e[21]===x?n=e[22]:(n=x.get(`connect`),e[21]=x,e[22]=n);let r=n===`1`,i;e[23]!==d||e[24]!==x||e[25]!==r||e[26]!==t?(i=m(d,t,r,x.get(`returnTo`)??void 0),e[23]=d,e[24]=x,e[25]=r,e[26]=t,e[27]=i):i=e[27];let a;return e[28]===i?a=e[29]:(a=(0,g.jsx)(c,{replace:!0,to:i}),e[28]=i,e[29]=a),a}if(!j){let t;return e[30]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,g.jsx)(c,{to:f(p[0]),replace:!0}),e[30]=t):t=e[30],t}let W;e[31]!==d||e[32]!==t||e[33]!==M?(W=d?null:(0,g.jsx)(re,{section:M,zh:t.startsWith(`zh`)}),e[31]=d,e[32]=t,e[33]=M,e[34]=W):W=e[34];let G;e[35]===i.discoverLoading?G=e[36]:(G=(0,g.jsx)(b,{label:i.discoverLoading}),e[35]=i.discoverLoading,e[36]=G);let K;e[37]!==d||e[38]!==V||e[39]!==M?(K=M===`agents`?(0,g.jsx)(ce,{agentId:d,onHeaderActionChange:V}):null,e[37]=d,e[38]=V,e[39]=M,e[40]=K):K=e[40];let q;e[41]!==V||e[42]!==M?(q=M===`skills`?(0,g.jsx)(ie,{embedded:!0,onHeaderActionChange:V}):null,e[41]=V,e[42]=M,e[43]=q):q=e[43];let J;e[44]!==V||e[45]!==M?(J=M===`connectors`?(0,g.jsx)(ae,{embedded:!0,onHeaderActionChange:V}):null,e[44]=V,e[45]=M,e[46]=J):J=e[46];let Y;e[47]!==d||e[48]!==V||e[49]!==M?(Y=M===`channels`?(0,g.jsx)(v,{channelId:d,onHeaderActionChange:V}):null,e[47]=d,e[48]=V,e[49]=M,e[50]=Y):Y=e[50];let X;e[51]!==V||e[52]!==M?(X=M===`extensions`?(0,g.jsx)(se,{embedded:!0,onHeaderActionChange:V}):null,e[51]=V,e[52]=M,e[53]=X):X=e[53];let Z;e[54]!==M||e[55]!==K||e[56]!==q||e[57]!==J||e[58]!==Y||e[59]!==X||e[60]!==G?(Z=(0,g.jsxs)(_.Suspense,{fallback:G,children:[K,q,J,Y,X]},M),e[54]=M,e[55]=K,e[56]=q,e[57]=J,e[58]=Y,e[59]=X,e[60]=G,e[61]=Z):Z=e[61];let Q;e[62]!==k||e[63]!==D||e[64]!==x?(Q=D?(0,g.jsx)(_.Suspense,{fallback:null,children:(0,g.jsx)(oe,{pluginId:D,initialConnect:x.get(`connect`)===`1`,onClose:k},D)}):null,e[62]=k,e[63]=D,e[64]=x,e[65]=Q):Q=e[65];let $;return e[66]!==Z||e[67]!==Q||e[68]!==W?($=(0,g.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[W,Z,Q]}),e[66]=Z,e[67]=Q,e[68]=W,e[69]=$):$=e[69],$}function C(e){return e.clearPageHeader}function w(e){return e.setPageHeader}function T(e){return e.language}export{S as CapabilitiesPage};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-zJ_50EbN.js";import{d as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./external-link-DjqjBmc3.js";import{t as f}from"./eye-CABVeTq0.js";import{t as p}from"./plus-Q2yW6OE7.js";import{t as m}from"./x-B_N4OPjy.js";import{t as h}from"./messages-Bwv-AOYl.js";import{t as g}from"./cn-0WouolD0.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-D5h-Ha6-.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./dist-BGTk37IG.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{n as A,r as j}from"./gateway-config-swr-BvuySoCX.js";import{n as M,t as N}from"./registry-api-Bf0hVPNV.js";import{$i as P,$l as F,$s as I,Ao as L,As as R,At as ee,Bt as z,Cn as B,Ct as V,Dn as H,Dt as te,En as U,Et as ne,F as W,Fc as G,Fn as K,Ft as re,G as ie,Gs as ae,Gt as oe,Ht as se,I as q,Ic as ce,In as J,Is as le,Js as Y,Jt as ue,Ju as de,Kc as X,Ks as fe,Kt as pe,Ku as me,L as he,Ls as ge,Lt as _e,Ml as ve,Mt as ye,Nl as be,Ns as xe,Nt as Se,Of as Ce,Ot as we,Ps as Te,Pt as Ee,Rc as De,Rs as Oe,Rt as ke,Sl as Ae,Sn as je,St as Me,Tn as Ne,Tt as Pe,Ut as Fe,Vs as Ie,Vt as Le,Wl as Re,Ws as ze,Xd as Be,Xl as Ve,Xs as He,Xt as Ue,Ys as We,Yt as Ge,Za as Ke,_t as qe,as as Je,bn as Ye,bt as Xe,cf as Ze,dd as Qe,df as $e,ds as et,du as tt,ea as nt,ec as rt,eo as it,fs as Z,hd as at,js as ot,jt as st,kf as ct,kt as lt,nu as ut,qn as dt,qs as ft,qt as pt,ss as mt,to as ht,us as gt,vl as _t,vs as vt,vt as yt,vu as bt,wl as xt,wn as St,wt as Ct,wu as wt,xn as Tt,xt as Et,ys as Dt,yt as Ot,yu as kt,zt as At,zu as jt}from"./index-DmURUvvA.js";import{t as Mt}from"./number-input-DDeqHK-G.js";import{n as Nt,r as Pt}from"./settings-page-layout-Dx5S-Msc.js";import{n as Ft,t as It}from"./settings-form-section-BTUFu5KS.js";import{n as Lt,t as Rt}from"./use-autosave-BnMIUc_5.js";import{c as zt,f as Bt,i as Vt,l as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./voice-config-api-CRjdZdJF.js";import{t as Yt}from"./voice-api-key-field-1h6fMaZL.js";import{a as Xt,i as Zt,n as Qt,o as $t,r as en,s as tn,t as nn}from"./image-generation-api-BoMWmqwF.js";import{t as rn}from"./xopc-cloud-account-card-BsW2acj1.js";var an=n(),Q=e(t(),1),$=r(),on={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},sn=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function cn(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function ln(e){let t=e.split(`
2
+ 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"./preload-helper-zJ_50EbN.js";import{d as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./external-link-DjqjBmc3.js";import{t as f}from"./eye-CABVeTq0.js";import{t as p}from"./plus-Q2yW6OE7.js";import{t as m}from"./x-B_N4OPjy.js";import{t as h}from"./messages-Bwv-AOYl.js";import{t as g}from"./cn-0WouolD0.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-D5h-Ha6-.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./dist-BGTk37IG.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{n as A,r as j}from"./gateway-config-swr-BvuySoCX.js";import{n as M,t as N}from"./registry-api-Bf0hVPNV.js";import{$i as P,$l as F,$s as I,Ao as L,As as R,At as ee,Bt as z,Cn as B,Ct as V,Dn as H,Dt as te,En as U,Et as ne,F as W,Fc as G,Fn as K,Ft as re,G as ie,Gs as ae,Gt as oe,Ht as se,I as q,Ic as ce,In as J,Is as le,Js as Y,Jt as ue,Ju as de,Kc as X,Ks as fe,Kt as pe,Ku as me,L as he,Ls as ge,Lt as _e,Ml as ve,Mt as ye,Nl as be,Ns as xe,Nt as Se,Of as Ce,Ot as we,Ps as Te,Pt as Ee,Rc as De,Rs as Oe,Rt as ke,Sl as Ae,Sn as je,St as Me,Tn as Ne,Tt as Pe,Ut as Fe,Vs as Ie,Vt as Le,Wl as Re,Ws as ze,Xd as Be,Xl as Ve,Xs as He,Xt as Ue,Ys as We,Yt as Ge,Za as Ke,_t as qe,as as Je,bn as Ye,bt as Xe,cf as Ze,dd as Qe,df as $e,ds as et,du as tt,ea as nt,ec as rt,eo as it,fs as Z,hd as at,js as ot,jt as st,kf as ct,kt as lt,nu as ut,qn as dt,qs as ft,qt as pt,ss as mt,to as ht,us as gt,vl as _t,vs as vt,vt as yt,vu as bt,wl as xt,wn as St,wt as Ct,wu as wt,xn as Tt,xt as Et,ys as Dt,yt as Ot,yu as kt,zt as At,zu as jt}from"./index-K2cy4f-3.js";import{t as Mt}from"./number-input-DDeqHK-G.js";import{n as Nt,r as Pt}from"./settings-page-layout-Dx5S-Msc.js";import{n as Ft,t as It}from"./settings-form-section-B4NShgv-.js";import{n as Lt,t as Rt}from"./use-autosave-CYIuWnRn.js";import{c as zt,f as Bt,i as Vt,l as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt,u as Jt}from"./voice-config-api-CRjdZdJF.js";import{t as Yt}from"./voice-api-key-field-BN37Lklj.js";import{a as Xt,i as Zt,n as Qt,o as $t,r as en,s as tn,t as nn}from"./image-generation-api-SQDixWjO.js";import{t as rn}from"./xopc-cloud-account-card-DGGi4zVC.js";var an=n(),Q=e(t(),1),$=r(),on={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},sn=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function cn(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function ln(e){let t=e.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function un({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=on[i],[l,u]=(0,Q.useState)(``),[d,h]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`bearer`),[x,k]=(0,Q.useState)(`x-api-key`),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(`/images/generations`),[R,ee]=(0,Q.useState)(`/images/edits`),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(``),[te,U]=(0,Q.useState)([cn()]),[ne,W]=(0,Q.useState)(``),[G,K]=(0,Q.useState)(),[re,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(),[se,q]=(0,Q.useState)(),[ce,J]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!G),()=>s?.(!1)),[G,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),h(t?.name??``),v(n?.baseUrl??``),b(t?.auth.type??`bearer`),k(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),j(r?`••••••••••••`:``),N(t?.apiKeyUrl??``),F(t?.documentationUrl??``),L(t?.paths?.generations??`/images/generations`),ee(t?.paths?.edits??`/images/edits`),B(t?.network?.allowedHosts.join(`
4
4
  `)??``),H(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
5
  `)),U(t?.models.map(cn)??[cn()]),W(t?.defaultModel??``),q(void 0),K(void 0),ie(!1),oe(void 0),J(void 0)},[r,e,n]);let le=(0,Q.useMemo)(()=>te.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[te]),Y=(e,t)=>{U(n=>n.map((n,r)=>r===e?{...n,...t}:n))},ue=()=>{let e=l.trim(),t=te.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!d.trim()||!_.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=ne||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=ln(V)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:_.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:d.trim(),...P.trim()?{documentationUrl:P.trim()}:{},...M.trim()?{apiKeyUrl:M.trim()}:{},defaultModel:n,auth:y===`header`?{type:`header`,headerName:x.trim()}:{type:y},paths:{...I.trim()?{generations:I.trim()}:{},...R.trim()?{edits:R.trim()}:{}},...z.trim()?{network:{allowedHosts:z.split(`
@@ -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{Ds as i,Es as a,Kc as o,Ts as s,W as c,au as l,ws as u}from"./index-DmURUvvA.js";var d=n(),f=e(t(),1),p=r(),m=(0,f.memo)(function(e){let t=(0,d.c)(8),{value:n,onChange:r,placeholder:i,ariaLabel:a}=e,o=a===void 0?i:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,p.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===r?c=t[2]:(c=e=>r(e.currentTarget.value),t[1]=r,t[2]=c);let u;return t[3]!==o||t[4]!==i||t[5]!==c||t[6]!==n?(u=(0,p.jsxs)(`label`,{className:`relative flex h-11 min-w-0 w-full cursor-text items-center rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-fg shadow-none focus-within:border-accent/60 focus-within:ring-2 focus-within:ring-accent/30 md:h-9`,children:[s,(0,p.jsx)(`input`,{type:`search`,"aria-label":o,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent text-base leading-normal text-fg caret-current placeholder:text-fg-muted focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 md:text-sm`})]}),t[3]=o,t[4]=i,t[5]=c,t[6]=n,t[7]=u):u=t[7],u});function h(e){let t=(0,d.c)(8),{contribution:n}=e,r=c(`(min-width: 768px)`),f;t[0]!==n||t[1]!==r?(f=n?.search?r?(0,p.jsx)(`div`,{className:`min-w-0 max-w-60 flex-1`,children:n.search}):(0,p.jsxs)(a,{children:[(0,p.jsx)(i,{asChild:!0,children:(0,p.jsx)(o,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":n.searchLabel,title:n.searchLabel,children:(0,p.jsx)(l,{className:`size-4`,"aria-hidden":!0})})}),(0,p.jsx)(s,{children:(0,p.jsx)(u,{align:`end`,sideOffset:8,className:`z-50 w-[min(20rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover`,children:n.search})})]}):null,t[0]=n,t[1]=r,t[2]=f):f=t[2];let m=n?.secondary,h=n?.primary,g=n?.overflow,_;return t[3]!==f||t[4]!==m||t[5]!==h||t[6]!==g?(_=(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 xl:w-[27rem] 2xl:w-[31rem]`,children:[f,m,h,g]}),t[3]=f,t[4]=m,t[5]=h,t[6]=g,t[7]=_):_=t[7],_}export{m as n,h 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{Ds as i,Es as a,Kc as o,Ts as s,W as c,au as l,ws as u}from"./index-K2cy4f-3.js";var d=n(),f=e(t(),1),p=r(),m=(0,f.memo)(function(e){let t=(0,d.c)(8),{value:n,onChange:r,placeholder:i,ariaLabel:a}=e,o=a===void 0?i:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,p.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===r?c=t[2]:(c=e=>r(e.currentTarget.value),t[1]=r,t[2]=c);let u;return t[3]!==o||t[4]!==i||t[5]!==c||t[6]!==n?(u=(0,p.jsxs)(`label`,{className:`relative flex h-11 min-w-0 w-full cursor-text items-center rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-fg shadow-none focus-within:border-accent/60 focus-within:ring-2 focus-within:ring-accent/30 md:h-9`,children:[s,(0,p.jsx)(`input`,{type:`search`,"aria-label":o,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent text-base leading-normal text-fg caret-current placeholder:text-fg-muted focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 md:text-sm`})]}),t[3]=o,t[4]=i,t[5]=c,t[6]=n,t[7]=u):u=t[7],u});function h(e){let t=(0,d.c)(8),{contribution:n}=e,r=c(`(min-width: 768px)`),f;t[0]!==n||t[1]!==r?(f=n?.search?r?(0,p.jsx)(`div`,{className:`min-w-0 max-w-60 flex-1`,children:n.search}):(0,p.jsxs)(a,{children:[(0,p.jsx)(i,{asChild:!0,children:(0,p.jsx)(o,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":n.searchLabel,title:n.searchLabel,children:(0,p.jsx)(l,{className:`size-4`,"aria-hidden":!0})})}),(0,p.jsx)(s,{children:(0,p.jsx)(u,{align:`end`,sideOffset:8,className:`z-50 w-[min(20rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover`,children:n.search})})]}):null,t[0]=n,t[1]=r,t[2]=f):f=t[2];let m=n?.secondary,h=n?.primary,g=n?.overflow,_;return t[3]!==f||t[4]!==m||t[5]!==h||t[6]!==g?(_=(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 xl:w-[27rem] 2xl:w-[31rem]`,children:[f,m,h,g]}),t[3]=f,t[4]=m,t[5]=h,t[6]=g,t[7]=_):_=t[7],_}export{m as n,h 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{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-Bwv-AOYl.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-D5h-Ha6-.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{Fc as C,G as w,Gn as T,Hl as E,Ju as D,Kc as O,Ml as k,On as A,Rc as j,Rn as M,Un as N,Vi as P,Wn as F,Xa as I,ms as L,mu as R,nu as z,so as ee,uf as te,uo as ne,us as re,uu as ie,vs as ae,ys as oe}from"./index-DmURUvvA.js";import{r as se}from"./settings-page-layout-Dx5S-Msc.js";import{t as ce}from"./browser-BLJWD7WI.js";import{t as le}from"./schema-form-ZAX7C5uI.js";var B=e(t(),1),V=n();async function ue(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function de(){return m(`/api/channels/status`)}var fe=ue;function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ce(),1),H=r();async function U(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function he({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let s=(0,B.useMemo)(()=>pe(e),[e]),c=(0,B.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,d]=(0,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,B.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});d(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,B.useEffect)(()=>{let t=K(u.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,B.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,u.poll]);let p=s?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,h=G(u.payload),g=K(u.payload,e.id),_=g?u.generatedQr:q(u.payload),v=s?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),y=u.payload?.type===`form`?u.payload:null,b=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,H.jsxs)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(s[0]),children:[u.busy?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(R,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(O,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void f(`doctor.run`),children:[(0,H.jsx)(E,{className:`size-4`}),m]}):null]})]}),h?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,u.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,v?(0,H.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,H.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(j,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(j,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(j,{className:`h-4 w-36 max-w-full`})]}),g?(0,H.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,H.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,H.jsx)(a,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.jsx)(`span`,{className:u.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:u.payload.message??(u.payload.ok?n.complete:n.failed)})]}):null,y?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(le,{schema:y.schema,values:u.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:u.busy,labels:c}),(0,H.jsx)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(y.submitAction,u.formDraft),children:n.saveSetup})]}):null,b?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ge=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function _e(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ve(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ge,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ye(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function be(e,t,n){let r=ye(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function xe(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,ae):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,ae,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Se(e){let t=(0,V.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:S}=e,w=m===void 0?!1:m,T=n===`drawer`,[E,D]=(0,B.useState)(null),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(h,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,oe)}),t[0]=k):k=t[0];let A;t[1]!==n||t[2]!==w?(A=xe(n,w),t[1]=n,t[2]=w,t[3]=A):A=t[3];let j;t[4]===c?j=t[5]:(j=c?(0,H.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=j);let M;t[6]===u?M=t[7]:(M=u?(0,H.jsx)(g,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=M);let N;t[8]!==d||t[9]!==o||t[10]!==S||t[11]!==T||t[12]!==a?(N=T?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,H.jsx)(s,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:l(C,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,H.jsx)(s,{className:`size-4`})})}),S]}),t[8]=d,t[9]=o,t[10]=S,t[11]=T,t[12]=a,t[13]=N):N=t[13];let P=T?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=l(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==f||t[17]!==F?(I=(0,H.jsx)(`div`,{className:F,children:f}),t[16]=f,t[17]=F,t[18]=I):I=t[18];let R;t[19]!==p||t[20]!==E||t[21]!==j||t[22]!==M||t[23]!==N||t[24]!==I?(R=(0,H.jsxs)(L,{layer:`modal`,portalContainer:E,children:[j,M,N,I,p]}),t[19]=p,t[20]=E,t[21]=j,t[22]=M,t[23]=N,t[24]=I,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==A?(z=(0,H.jsxs)(v,{children:[k,(0,H.jsx)(y,{ref:D,className:A,onOpenAutoFocus:Ce,children:R})]}),t[26]=R,t[27]=A,t[28]=z):z=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==z?(ee=(0,H.jsx)(x,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=ee):ee=t[32],ee}function Ce(e){return e.preventDefault()}var we=(0,B.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,H.jsx)(I,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Te(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,H.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,H.jsx)(O,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,H.jsx)(O,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,H.jsx)(O,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,H.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ee(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await u(Ee(e))).payload?.channels??[]}function Oe(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ee(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>De(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=S(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var ke=`channels-status`;function Ae(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function je(e){let t=t=>e(t.detail);return window.addEventListener(ke,t),()=>window.removeEventListener(ke,t)}function Me(e,t){let n=(0,V.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return je(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,B.useEffect)(i,a)}function Ne(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`],Ie=`max-w-7xl`,Le=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function We(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Fe.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Fe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Q(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,B.useState)(!1),r=(0,B.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,H.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,H.jsx)(ne,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,H.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,H.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,V.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,H.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,H.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,H.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(O,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,H.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?a:n===`stopped`||n===`needs_setup`?te:D,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,H.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,H.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,k;t[22]===i?k=t[23]:(k=i?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==d||t[25]!==E||t[26]!==k||t[27]!==A?(j=(0,H.jsxs)(O,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:d,children:[k,A]}),t[24]=d,t[25]=E,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,H.jsxs)(O,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(ie,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==o?(N=s?(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=o,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==T||t[49]!==P?(F=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,P]})}),t[48]=T,t[49]=P,t[50]=F):F=t[50],F}function st(e){let t=(0,V.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,H.jsx)(k,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,H.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,H.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,H.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,H.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,H.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct({channelId:e,onHeaderActionChange:t}){let n=p(e=>e.language),r=c(n),a=d(e=>!!e.conversationId),s=i(),u=T(e),h=Oe(a,n),g=h.entries,{data:_,mutate:v,isValidating:y}=S(a?de():null,fe,{revalidateOnFocus:!0}),{data:b,mutate:x}=S(a?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),C=b?.channels??{},E=b?.bindings??[],{data:D}=S(a?`channel-routing-agents`:null,ee,{revalidateOnFocus:!1}),O=(0,B.useMemo)(()=>g.find(e=>e.id===u),[u,g]),k=O?Be(O):null,{data:j,mutate:I}=S(a&&k?Ne(k):null,()=>Pe(k)),[L,R]=(0,B.useState)(null),[te,ne]=(0,B.useState)(!1),[ie,ae]=(0,B.useState)(null),[oe,ce]=(0,B.useState)(null),[V,ue]=(0,B.useState)(!1),[me,U]=(0,B.useState)(null),[W,G]=(0,B.useState)(null),K=L??j??{},q=r.channelsSettings,ge=(0,B.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),J=(0,B.useMemo)(()=>qe(ge,Fe),[ge]),ye=(0,B.useMemo)(()=>We(O),[O]),xe=(0,B.useMemo)(()=>Ge(J,ye),[ye,J]),Ce=(0,B.useMemo)(()=>qe(J,ye),[ye,J]),Ee=(0,B.useMemo)(()=>Je(xe),[xe]),De=O?W??_e(E,O.id):``,ke=(0,B.useMemo)(()=>(D?.items??[]).map(e=>{let t=M(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[D?.items,r.agentsSettings]),je=D?.items.find(e=>e.id===D.defaultId),ze=je?M(je,r.agentsSettings):D?.defaultId??``,He=(0,B.useMemo)(()=>({defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),X=(0,B.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Z=_!==void 0,Ke=(0,B.useCallback)(e=>be(e,X.get(e.id),Z),[X,Z]),Q=(0,B.useCallback)(async()=>{await Promise.all([h.mutate(),v()])},[h,v]);Me((0,B.useCallback)(e=>{let t=Ae(e);t&&v(t,!1)},[v]),a);let Ye=(0,B.useMemo)(()=>a?{secondary:(0,H.jsx)(we,{ch:q,refreshing:h.isValidating||y,saveOk:!1,onRefresh:()=>void Q()})}:null,[h.isValidating,q,a,y,Q]);(0,B.useLayoutEffect)(()=>(t?.(Ye),()=>t?.(null)),[Ye,t]);let Xe=(0,B.useCallback)(e=>{s(F(e)),R(null),G(null),U(null)},[s]),Ze=(0,B.useCallback)(()=>{s(N),R(null),G(null),U(null)},[s]),Qe=(0,B.useCallback)(async e=>{ce(e.id),U(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{ce(null)}},[Q]);(0,B.useEffect)(()=>{G(null),ue(!1)},[O?.id]);let $e=(0,B.useCallback)(async()=>{if(!O||!L&&W===null)return!1;let e=Be(O);ne(!0),U(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...L?{channels:{[e]:L}}:{},...W===null?{}:{bindings:ve(E,O.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return L&&await I(L,!1),await x(),await h.mutate(),R(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[O,W,E,h,L,x,I]),et=(0,B.useCallback)(async e=>{let t=Y(e),n=Be(e),r=O?.id===e.id?L:null;if(!t.enabled&&!t.ready&&!r){Xe(e.id);return}ae(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await x(),await v(),O?.id===e.id&&(await I(),R(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{ae(null)}},[O?.id,h,L,x,I,v,Xe]),$=O?.ui?.modal,it=$?.placement!==`replace-config`,at=O?Ke(O):`checking`,ct=O?!Y(O).ready||V:!1;return a?(0,H.jsxs)(se,{gap:`gap-4`,className:Ie,padding:Le,children:[h.isLoading?(0,H.jsx)(A,{sections:2}):h.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,H.jsx)(rt,{entry:e,config:C[Be(e)]?.config,runtime:Ke(e),busy:ie===e.id,restarting:oe===e.id,ch:q,onOpen:()=>Xe(e.id),onToggle:()=>void et(e),onRestart:()=>void Qe(e)},e.id))}),me?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:me}):null,(0,H.jsx)(Se,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Ze()},closeAriaLabel:q.close,srTitle:O?.label??q.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,H.jsx)(Te,{ch:q,dirty:!!L||W!==null,saving:te,onCancel:Ze,onDiscard:()=>{R(null),G(null)},onSave:$e}):null,children:O?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:O}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:O.label}),(0,H.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(at)),children:Ve(at,q)})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(O).ready&&pe(O)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,H.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(O).enabled?q.enabledLabel:q.disabledLabel}),(0,H.jsx)(nt,{checked:Y(O).enabled,disabled:ie===O.id,label:q.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void et(O)})]})]})}),(0,H.jsx)(ot,{runtime:at,restarting:oe===O.id,checking:y,showConnectionOptions:V,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void Qe(O),onCheck:()=>void Q(),onManageConnection:()=>ue(e=>!e)}),(0,H.jsx)(st,{entry:O,ch:q}),ct&&$?.placement!==`replace-config`?(0,H.jsx)(he,{entry:O,locale:n,messages:q,compact:!0,onChanged:async()=>{await I(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:K}}):null,it&&Ee?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,H.jsx)(le,{schema:xe,values:K,onChange:e=>R(e),disabled:te,labels:He})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(z,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,H.jsx)(re,{value:De,options:ke,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,ze||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:te||!D,onChange:e=>G(e)})]})]}),it&&Je(Ce)?(0,H.jsx)(w,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(z,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(le,{schema:Ce,values:K,onChange:e=>R(e),disabled:te,labels:He})})]})}):null,me?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:me}):null]}):null})]}):(0,H.jsx)(se,{gap:`gap-3`,className:Ie,padding:Le,children:(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}export{ct as ChannelsSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-Bwv-AOYl.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-D5h-Ha6-.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{Fc as C,G as w,Gn as T,Hl as E,Ju as D,Kc as O,Ml as k,On as A,Rc as j,Rn as M,Un as N,Vi as P,Wn as F,Xa as I,ms as L,mu as R,nu as z,so as ee,uf as te,uo as ne,us as re,uu as ie,vs as ae,ys as oe}from"./index-K2cy4f-3.js";import{r as se}from"./settings-page-layout-Dx5S-Msc.js";import{t as ce}from"./browser-BLJWD7WI.js";import{t as le}from"./schema-form-ClP4uPSj.js";var B=e(t(),1),V=n();async function ue(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function de(){return m(`/api/channels/status`)}var fe=ue;function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ce(),1),H=r();async function U(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function he({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let s=(0,B.useMemo)(()=>pe(e),[e]),c=(0,B.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,d]=(0,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,B.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});d(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,B.useEffect)(()=>{let t=K(u.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,B.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,u.poll]);let p=s?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,h=G(u.payload),g=K(u.payload,e.id),_=g?u.generatedQr:q(u.payload),v=s?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),y=u.payload?.type===`form`?u.payload:null,b=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,H.jsxs)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(s[0]),children:[u.busy?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(R,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(O,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void f(`doctor.run`),children:[(0,H.jsx)(E,{className:`size-4`}),m]}):null]})]}),h?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,u.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,v?(0,H.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,H.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(j,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(j,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(j,{className:`h-4 w-36 max-w-full`})]}),g?(0,H.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,H.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,H.jsx)(a,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.jsx)(`span`,{className:u.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:u.payload.message??(u.payload.ok?n.complete:n.failed)})]}):null,y?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(le,{schema:y.schema,values:u.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:u.busy,labels:c}),(0,H.jsx)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(y.submitAction,u.formDraft),children:n.saveSetup})]}):null,b?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ge=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function _e(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ve(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ge,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ye(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function be(e,t,n){let r=ye(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function xe(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,ae):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,ae,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Se(e){let t=(0,V.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:S}=e,w=m===void 0?!1:m,T=n===`drawer`,[E,D]=(0,B.useState)(null),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(h,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,oe)}),t[0]=k):k=t[0];let A;t[1]!==n||t[2]!==w?(A=xe(n,w),t[1]=n,t[2]=w,t[3]=A):A=t[3];let j;t[4]===c?j=t[5]:(j=c?(0,H.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=j);let M;t[6]===u?M=t[7]:(M=u?(0,H.jsx)(g,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=M);let N;t[8]!==d||t[9]!==o||t[10]!==S||t[11]!==T||t[12]!==a?(N=T?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,H.jsx)(s,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:l(C,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,H.jsx)(s,{className:`size-4`})})}),S]}),t[8]=d,t[9]=o,t[10]=S,t[11]=T,t[12]=a,t[13]=N):N=t[13];let P=T?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=l(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==f||t[17]!==F?(I=(0,H.jsx)(`div`,{className:F,children:f}),t[16]=f,t[17]=F,t[18]=I):I=t[18];let R;t[19]!==p||t[20]!==E||t[21]!==j||t[22]!==M||t[23]!==N||t[24]!==I?(R=(0,H.jsxs)(L,{layer:`modal`,portalContainer:E,children:[j,M,N,I,p]}),t[19]=p,t[20]=E,t[21]=j,t[22]=M,t[23]=N,t[24]=I,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==A?(z=(0,H.jsxs)(v,{children:[k,(0,H.jsx)(y,{ref:D,className:A,onOpenAutoFocus:Ce,children:R})]}),t[26]=R,t[27]=A,t[28]=z):z=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==z?(ee=(0,H.jsx)(x,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=ee):ee=t[32],ee}function Ce(e){return e.preventDefault()}var we=(0,B.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,H.jsx)(I,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Te(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,H.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,H.jsx)(O,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,H.jsx)(O,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,H.jsx)(O,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,H.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ee(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await u(Ee(e))).payload?.channels??[]}function Oe(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ee(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>De(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=S(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var ke=`channels-status`;function Ae(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function je(e){let t=t=>e(t.detail);return window.addEventListener(ke,t),()=>window.removeEventListener(ke,t)}function Me(e,t){let n=(0,V.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return je(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,B.useEffect)(i,a)}function Ne(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`],Ie=`max-w-7xl`,Le=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function We(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Fe.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Fe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Q(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,B.useState)(!1),r=(0,B.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,H.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,H.jsx)(ne,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,H.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,H.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,V.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,H.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,H.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,H.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(O,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,H.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?a:n===`stopped`||n===`needs_setup`?te:D,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,H.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,H.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,k;t[22]===i?k=t[23]:(k=i?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==d||t[25]!==E||t[26]!==k||t[27]!==A?(j=(0,H.jsxs)(O,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:d,children:[k,A]}),t[24]=d,t[25]=E,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,H.jsxs)(O,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(ie,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==o?(N=s?(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=o,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==T||t[49]!==P?(F=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,P]})}),t[48]=T,t[49]=P,t[50]=F):F=t[50],F}function st(e){let t=(0,V.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,H.jsx)(k,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,H.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,H.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,H.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,H.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,H.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct({channelId:e,onHeaderActionChange:t}){let n=p(e=>e.language),r=c(n),a=d(e=>!!e.conversationId),s=i(),u=T(e),h=Oe(a,n),g=h.entries,{data:_,mutate:v,isValidating:y}=S(a?de():null,fe,{revalidateOnFocus:!0}),{data:b,mutate:x}=S(a?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),C=b?.channels??{},E=b?.bindings??[],{data:D}=S(a?`channel-routing-agents`:null,ee,{revalidateOnFocus:!1}),O=(0,B.useMemo)(()=>g.find(e=>e.id===u),[u,g]),k=O?Be(O):null,{data:j,mutate:I}=S(a&&k?Ne(k):null,()=>Pe(k)),[L,R]=(0,B.useState)(null),[te,ne]=(0,B.useState)(!1),[ie,ae]=(0,B.useState)(null),[oe,ce]=(0,B.useState)(null),[V,ue]=(0,B.useState)(!1),[me,U]=(0,B.useState)(null),[W,G]=(0,B.useState)(null),K=L??j??{},q=r.channelsSettings,ge=(0,B.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),J=(0,B.useMemo)(()=>qe(ge,Fe),[ge]),ye=(0,B.useMemo)(()=>We(O),[O]),xe=(0,B.useMemo)(()=>Ge(J,ye),[ye,J]),Ce=(0,B.useMemo)(()=>qe(J,ye),[ye,J]),Ee=(0,B.useMemo)(()=>Je(xe),[xe]),De=O?W??_e(E,O.id):``,ke=(0,B.useMemo)(()=>(D?.items??[]).map(e=>{let t=M(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[D?.items,r.agentsSettings]),je=D?.items.find(e=>e.id===D.defaultId),ze=je?M(je,r.agentsSettings):D?.defaultId??``,He=(0,B.useMemo)(()=>({defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),X=(0,B.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Z=_!==void 0,Ke=(0,B.useCallback)(e=>be(e,X.get(e.id),Z),[X,Z]),Q=(0,B.useCallback)(async()=>{await Promise.all([h.mutate(),v()])},[h,v]);Me((0,B.useCallback)(e=>{let t=Ae(e);t&&v(t,!1)},[v]),a);let Ye=(0,B.useMemo)(()=>a?{secondary:(0,H.jsx)(we,{ch:q,refreshing:h.isValidating||y,saveOk:!1,onRefresh:()=>void Q()})}:null,[h.isValidating,q,a,y,Q]);(0,B.useLayoutEffect)(()=>(t?.(Ye),()=>t?.(null)),[Ye,t]);let Xe=(0,B.useCallback)(e=>{s(F(e)),R(null),G(null),U(null)},[s]),Ze=(0,B.useCallback)(()=>{s(N),R(null),G(null),U(null)},[s]),Qe=(0,B.useCallback)(async e=>{ce(e.id),U(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{ce(null)}},[Q]);(0,B.useEffect)(()=>{G(null),ue(!1)},[O?.id]);let $e=(0,B.useCallback)(async()=>{if(!O||!L&&W===null)return!1;let e=Be(O);ne(!0),U(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...L?{channels:{[e]:L}}:{},...W===null?{}:{bindings:ve(E,O.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return L&&await I(L,!1),await x(),await h.mutate(),R(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[O,W,E,h,L,x,I]),et=(0,B.useCallback)(async e=>{let t=Y(e),n=Be(e),r=O?.id===e.id?L:null;if(!t.enabled&&!t.ready&&!r){Xe(e.id);return}ae(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await x(),await v(),O?.id===e.id&&(await I(),R(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{ae(null)}},[O?.id,h,L,x,I,v,Xe]),$=O?.ui?.modal,it=$?.placement!==`replace-config`,at=O?Ke(O):`checking`,ct=O?!Y(O).ready||V:!1;return a?(0,H.jsxs)(se,{gap:`gap-4`,className:Ie,padding:Le,children:[h.isLoading?(0,H.jsx)(A,{sections:2}):h.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,H.jsx)(rt,{entry:e,config:C[Be(e)]?.config,runtime:Ke(e),busy:ie===e.id,restarting:oe===e.id,ch:q,onOpen:()=>Xe(e.id),onToggle:()=>void et(e),onRestart:()=>void Qe(e)},e.id))}),me?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:me}):null,(0,H.jsx)(Se,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Ze()},closeAriaLabel:q.close,srTitle:O?.label??q.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,H.jsx)(Te,{ch:q,dirty:!!L||W!==null,saving:te,onCancel:Ze,onDiscard:()=>{R(null),G(null)},onSave:$e}):null,children:O?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:O}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:O.label}),(0,H.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(at)),children:Ve(at,q)})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(O).ready&&pe(O)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,H.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(O).enabled?q.enabledLabel:q.disabledLabel}),(0,H.jsx)(nt,{checked:Y(O).enabled,disabled:ie===O.id,label:q.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void et(O)})]})]})}),(0,H.jsx)(ot,{runtime:at,restarting:oe===O.id,checking:y,showConnectionOptions:V,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void Qe(O),onCheck:()=>void Q(),onManageConnection:()=>ue(e=>!e)}),(0,H.jsx)(st,{entry:O,ch:q}),ct&&$?.placement!==`replace-config`?(0,H.jsx)(he,{entry:O,locale:n,messages:q,compact:!0,onChanged:async()=>{await I(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:K}}):null,it&&Ee?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,H.jsx)(le,{schema:xe,values:K,onChange:e=>R(e),disabled:te,labels:He})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(z,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,H.jsx)(re,{value:De,options:ke,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,ze||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:te||!D,onChange:e=>G(e)})]})]}),it&&Je(Ce)?(0,H.jsx)(w,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(z,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(le,{schema:Ce,values:K,onChange:e=>R(e),disabled:te,labels:He})})]})}):null,me?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:me}):null]}):null})]}):(0,H.jsx)(se,{gap:`gap-3`,className:Ie,padding:Le,children:(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}export{ct as ChannelsSettingsPanel};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-Bwv-AOYl.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{u as s}from"./session-api-fVuszA_P.js";import{t as c}from"./session-manager-BUMUjup5.js";import{Ao as l,Gl as u,Kc as d,Rc as f,cr as p,or as m,sr as h}from"./index-DmURUvvA.js";var g=2,_=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(g,Math.floor(u/e.css.cell.width)),rows:Math.max(_,Math.floor(l/e.css.cell.height))}}},te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,re=(e,t)=>{for(var n in t)te(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?ne(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&te(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ie=`Terminal input`,ae={get:()=>ie,set:e=>ie=e},oe=`Too much output to announce, navigate to rows manually to read`,b={get:()=>oe,set:e=>oe=e};function se(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ce(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function le(e,t,n,r){e.stopPropagation(),e.clipboardData&&ue(e.clipboardData.getData(`text/plain`),t,n,r)}function ue(e,t,n,r){e=se(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function S(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function de(e,t,n,r,i){S(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function fe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var pe=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},me=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},w=``,he=` `,ge=class e{constructor(){this.fg=0,this.bg=0,this.extended=new _e}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},_e=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends ge{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _e,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ve=`di$target`,ye=`di$dependencies`,be=new Map;function xe(e){return e[ye]||[]}function E(e){if(be.has(e))return be.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Se(t,e,r)};return t._id=e,be.set(e,t),t}function Se(e,t,n){t[ve]===t?t[ye].push({id:e,index:n}):(t[ye]=[{id:e,index:n}],t[ve]=t)}var D=E(`BufferService`),Ce=E(`CoreMouseService`),we=E(`CoreService`),Te=E(`CharsetService`),Ee=E(`InstantiationService`),De=E(`LogService`),O=E(`OptionsService`),Oe=E(`OscLinkService`),ke=E(`UnicodeService`),Ae=E(`DecorationService`),je=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Me(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};je=v([y(0,D),y(1,O),y(2,Oe)],je);function Me(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{t as a}from"./messages-Bwv-AOYl.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{u as s}from"./session-api-fVuszA_P.js";import{t as c}from"./session-manager-DMDBMYfh.js";import{Ao as l,Gl as u,Kc as d,Rc as f,cr as p,or as m,sr as h}from"./index-K2cy4f-3.js";var g=2,_=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(g,Math.floor(u/e.css.cell.width)),rows:Math.max(_,Math.floor(l/e.css.cell.height))}}},te=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,re=(e,t)=>{for(var n in t)te(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?ne(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&te(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ie=`Terminal input`,ae={get:()=>ie,set:e=>ie=e},oe=`Too much output to announce, navigate to rows manually to read`,b={get:()=>oe,set:e=>oe=e};function se(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ce(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function le(e,t,n,r){e.stopPropagation(),e.clipboardData&&ue(e.clipboardData.getData(`text/plain`),t,n,r)}function ue(e,t,n,r){e=se(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function S(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function de(e,t,n,r,i){S(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function fe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var pe=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},me=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},w=``,he=` `,ge=class e{constructor(){this.fg=0,this.bg=0,this.extended=new _e}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},_e=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends ge{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _e,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ve=`di$target`,ye=`di$dependencies`,be=new Map;function xe(e){return e[ye]||[]}function E(e){if(be.has(e))return be.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Se(t,e,r)};return t._id=e,be.set(e,t),t}function Se(e,t,n){t[ve]===t?t[ye].push({id:e,index:n}):(t[ye]=[{id:e,index:n}],t[ve]=t)}var D=E(`BufferService`),Ce=E(`CoreMouseService`),we=E(`CoreService`),Te=E(`CharsetService`),Ee=E(`InstantiationService`),De=E(`LogService`),O=E(`OptionsService`),Oe=E(`OscLinkService`),ke=E(`UnicodeService`),Ae=E(`DecorationService`),je=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Me(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};je=v([y(0,D),y(1,O),y(2,Oe)],je);function Me(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ne=E(`CharSizeService`),Pe=E(`CoreBrowserService`),Fe=E(`MouseService`),Ie=E(`RenderService`),Le=E(`SelectionService`),Re=E(`CharacterJoinerService`),ze=E(`ThemeService`),Be=E(`LinkProviderService`),Ve=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?qe.isErrorNoTelemetry(e)?new qe(e.message+`
4
4
 
@@ -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-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./messages-Bwv-AOYl.js";import{a as c,n as l,r as u}from"./locale-store-D5h-Ha6-.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{r as f}from"./gateway-config-swr-BvuySoCX.js";import{n as p,t as m}from"./registry-api-Bf0hVPNV.js";import{$i as h,$l as g,Fn as _,Fu as v,In as y,Iu as b,Kc as x,Rc as S,Td as C,Wl as w,as as T}from"./index-DmURUvvA.js";import{n as E,r as ee}from"./settings-page-layout-Dx5S-Msc.js";var D=n(),O=e(t(),1),k=r();function te({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,_),r=d(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,O.useState)(a),[l,u]=(0,O.useState)(!1),[f,g]=(0,O.useState)(``),[v,b]=(0,O.useState)(!1);(0,O.useEffect)(()=>{c(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),g(``),b(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await _(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await y({...e.defaults,models:r});await n.mutate(i,!1),b(!0)}catch(e){g(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,k.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,k.jsx)(S,{className:`h-52 w-full rounded-xl`}):n.error?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,k.jsx)(x,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,k.jsx)(S,{className:`h-11 w-full rounded-lg`}):(0,k.jsx)(h,{value:o,onChange:e=>{c(e),b(!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,k.jsx)(x,{variant:`primary`,disabled:l||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:t.modelDataUse}),(0,k.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,k.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,k.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!C&&!r.isLoading&&!r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,k.jsx)(x,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),f&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:f})]})]})}function A(e){let t=(0,D.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,k.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,k.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,k.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,k.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,k.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,k.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 j(){let e=(0,D.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,k.jsx)(N,{zh:t}),e[0]=t,e[1]=n),n}function M(e){return e.language}function N({zh:e}){let t=s(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:l}=f(!0),d=n?.payload?.config,[p,m]=(0,O.useState)(!1),[h,_]=(0,O.useState)(``),[y,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(null),[ne,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),[re,H]=(0,O.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,O.useEffect)(()=>{if(!U)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await U.status();e||(M(t),P(!1))}catch{e||(M(null),P(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[U]),(0,O.useEffect)(()=>{if(!U?.access)return;let e=!1;return U.access().then(t=>{e||(I(t),L(!1))}).catch(()=>{e||L(!0)}),()=>{e=!0}},[U]);let G=async e=>{m(!0),_(``);try{await e()}catch(e){_(e instanceof Error?e.message:String(e))}finally{m(!1)}},ie=e=>G(async()=>{T()&&(await c(u(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{_(``),D(!1);try{await U?.stop(),D(!0),U&&M(await U.status())}catch(e){_(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=T()&&d?.computer?.enabled===!0,oe=j?.controlPaused?t.pausedNotice:J?j?.connected?`${t.connected} · ${q}`:j?t.disconnected:t.checking:t.disabled,Y=!U||N||j?.reenrollmentRequired===!0||!!(j?.error||j?.session?.errorCode)||j!=null&&(!j.permissions.accessibility||j.permissions.screenRecording!==`granted`),X=j?.permissions.accessibility===!0&&j.permissions.screenRecording===`granted`&&!j.reenrollmentRequired,Z=F?.apps.filter(e=>F.authorizedAppIds.includes(e.appId))??[],Q=F?.apps.filter(e=>!F.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(R.toLocaleLowerCase()))??[],$=(0,k.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,k.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(g,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,k.jsx)(x,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(b,{className:`size-5`}),title:t.device,description:(0,k.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(A,{icon:(0,k.jsx)(g,{className:`size-5`}),title:t.accessibility,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,k.jsxs)(A,{icon:(0,k.jsx)(b,{className:`size-5`}),title:t.screen,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,k.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,k.jsx)(x,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,k.jsx)(`div`,{"aria-label":t.checking,children:(0,k.jsx)(S,{className:`h-20 w-full rounded-xl`})}):(0,k.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}),(j?.error||j?.session?.errorCode)&&(0,k.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,k.jsxs)(ee,{gap:`gap-7`,children:[(0,k.jsx)(E,{title:t.title,subtitle:t.subtitle,meta:(0,k.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:U&&(0,k.jsxs)(x,{onClick:()=>{ae()},children:[(0,k.jsx)(w,{className:`size-3.5`}),t.stop]})}),h&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:h}),y&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,k.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,k.jsx)(S,{className:`h-32 w-full rounded-xl`}):l?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,k.jsx)(x,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.desktop,description:(0,k.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:p||!T(),onClick:()=>{ie(d?.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,k.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,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,k.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{U&&M(await U.resume()),D(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,k.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,k.jsxs)(x,{disabled:p,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,k.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,k.jsx)(o,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,k.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:p,onClick:()=>{G(async()=>{I(await U.setAllAppAccess(!F.allowAllApps)),V(!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,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${F.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,k.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,k.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,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`ghost`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!1);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,k.jsx)(S,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,k.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{"aria-label":t.searchApps,value:R,onChange:e=>z(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,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,k.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,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`secondary`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!0);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:F.appsBusy?t.appsBusy:F.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,k.jsx)(te,{zh:e}),!Y&&$,(0,k.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(C,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,k.jsx)(x,{asChild:!0,children:(0,k.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{j as ComputerSettingsPage,N 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-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./messages-Bwv-AOYl.js";import{a as c,n as l,r as u}from"./locale-store-D5h-Ha6-.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{r as f}from"./gateway-config-swr-BvuySoCX.js";import{n as p,t as m}from"./registry-api-Bf0hVPNV.js";import{$i as h,$l as g,Fn as _,Fu as v,In as y,Iu as b,Kc as x,Rc as S,Td as C,Wl as w,as as T}from"./index-K2cy4f-3.js";import{n as E,r as ee}from"./settings-page-layout-Dx5S-Msc.js";var D=n(),O=e(t(),1),k=r();function te({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,_),r=d(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,O.useState)(a),[l,u]=(0,O.useState)(!1),[f,g]=(0,O.useState)(``),[v,b]=(0,O.useState)(!1);(0,O.useEffect)(()=>{c(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),g(``),b(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await _(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await y({...e.defaults,models:r});await n.mutate(i,!1),b(!0)}catch(e){g(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,k.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,k.jsx)(S,{className:`h-52 w-full rounded-xl`}):n.error?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,k.jsx)(x,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,k.jsx)(S,{className:`h-11 w-full rounded-lg`}):(0,k.jsx)(h,{value:o,onChange:e=>{c(e),b(!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,k.jsx)(x,{variant:`primary`,disabled:l||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:t.modelDataUse}),(0,k.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,k.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,k.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!C&&!r.isLoading&&!r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,k.jsx)(x,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),f&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:f})]})]})}function A(e){let t=(0,D.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,k.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,k.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,k.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,k.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,k.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,k.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 j(){let e=(0,D.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,k.jsx)(N,{zh:t}),e[0]=t,e[1]=n),n}function M(e){return e.language}function N({zh:e}){let t=s(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:l}=f(!0),d=n?.payload?.config,[p,m]=(0,O.useState)(!1),[h,_]=(0,O.useState)(``),[y,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(null),[ne,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),[re,H]=(0,O.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,O.useEffect)(()=>{if(!U)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await U.status();e||(M(t),P(!1))}catch{e||(M(null),P(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[U]),(0,O.useEffect)(()=>{if(!U?.access)return;let e=!1;return U.access().then(t=>{e||(I(t),L(!1))}).catch(()=>{e||L(!0)}),()=>{e=!0}},[U]);let G=async e=>{m(!0),_(``);try{await e()}catch(e){_(e instanceof Error?e.message:String(e))}finally{m(!1)}},ie=e=>G(async()=>{T()&&(await c(u(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{_(``),D(!1);try{await U?.stop(),D(!0),U&&M(await U.status())}catch(e){_(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=T()&&d?.computer?.enabled===!0,oe=j?.controlPaused?t.pausedNotice:J?j?.connected?`${t.connected} · ${q}`:j?t.disconnected:t.checking:t.disabled,Y=!U||N||j?.reenrollmentRequired===!0||!!(j?.error||j?.session?.errorCode)||j!=null&&(!j.permissions.accessibility||j.permissions.screenRecording!==`granted`),X=j?.permissions.accessibility===!0&&j.permissions.screenRecording===`granted`&&!j.reenrollmentRequired,Z=F?.apps.filter(e=>F.authorizedAppIds.includes(e.appId))??[],Q=F?.apps.filter(e=>!F.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(R.toLocaleLowerCase()))??[],$=(0,k.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,k.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(g,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,k.jsx)(x,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(b,{className:`size-5`}),title:t.device,description:(0,k.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(A,{icon:(0,k.jsx)(g,{className:`size-5`}),title:t.accessibility,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,k.jsxs)(A,{icon:(0,k.jsx)(b,{className:`size-5`}),title:t.screen,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,k.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,k.jsx)(x,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,k.jsx)(`div`,{"aria-label":t.checking,children:(0,k.jsx)(S,{className:`h-20 w-full rounded-xl`})}):(0,k.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}),(j?.error||j?.session?.errorCode)&&(0,k.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,k.jsxs)(ee,{gap:`gap-7`,children:[(0,k.jsx)(E,{title:t.title,subtitle:t.subtitle,meta:(0,k.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:U&&(0,k.jsxs)(x,{onClick:()=>{ae()},children:[(0,k.jsx)(w,{className:`size-3.5`}),t.stop]})}),h&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:h}),y&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,k.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,k.jsx)(S,{className:`h-32 w-full rounded-xl`}):l?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,k.jsx)(x,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.desktop,description:(0,k.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:p||!T(),onClick:()=>{ie(d?.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,k.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,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,k.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{U&&M(await U.resume()),D(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,k.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,k.jsxs)(x,{disabled:p,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,k.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,k.jsx)(o,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,k.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:p,onClick:()=>{G(async()=>{I(await U.setAllAppAccess(!F.allowAllApps)),V(!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,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${F.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,k.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,k.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,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`ghost`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!1);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,k.jsx)(S,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,k.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{"aria-label":t.searchApps,value:R,onChange:e=>z(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,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,k.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,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`secondary`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!0);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:F.appsBusy?t.appsBusy:F.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,k.jsx)(te,{zh:e}),!Y&&$,(0,k.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(C,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,k.jsx)(x,{asChild:!0,children:(0,k.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{j as ComputerSettingsPage,N 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-B2HK1psj.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./messages-Bwv-AOYl.js";import{n as c}from"./locale-store-D5h-Ha6-.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{Cc as v,It as y,Kc as b,Ns as x,Rc as S,Za as C,bc as w,fc as T,tc as E,tu as D}from"./index-DmURUvvA.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=c(N),n;e[0]===t?n=e[1]:(n=s(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 l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,j.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,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=c(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,_=a===void 0?!1:a,v=c(L),y;t[2]===v?y=t[3]:(y=s(v),t[2]=v,t[3]=y);let x=y.connectorsSettings,S=v===`zh`,C;t[4]!==_||t[5]!==S?(C=_?null:(0,j.jsx)(u,{asChild:!0,children:(0,j.jsxs)(b,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(D,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=_,t[5]=S,t[6]=C):C=t[6];let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,j.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=w):w=t[7];let T=S?`应用连接服务`:`App connection service`,E;t[8]===T?E=t[9]:(E=(0,j.jsx)(h,{className:`text-base font-semibold text-fg`,children:T}),t[8]=T,t[9]=E);let O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,j.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),t[10]=O):O=t[10];let A;t[11]===E?A=t[12]:(A=(0,j.jsxs)(`div`,{className:`min-w-0`,children:[E,O]}),t[11]=E,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,j.jsx)(o,{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)(f,{asChild:!0,children:(0,j.jsx)(b,{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)(p,{children:[w,(0,j.jsxs)(m,{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)(g,{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=c(e=>e.language),t=s(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,T),[o,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(),[m,h]=(0,A.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(S,{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)(y,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(b,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>v({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)(x,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(b,{disabled:u||!o.trim(),onClick:()=>void g(()=>E(o)),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)(b,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>E(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(b,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>v({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(b,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,j.jsx)(C,{open:!!m,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:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>w(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-B2HK1psj.js";import{t as o}from"./x-B_N4OPjy.js";import{t as s}from"./messages-Bwv-AOYl.js";import{n as c}from"./locale-store-D5h-Ha6-.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{Cc as v,It as y,Kc as b,Ns as x,Rc as S,Za as C,bc as w,fc as T,tc as E,tu as D}from"./index-K2cy4f-3.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=c(N),n;e[0]===t?n=e[1]:(n=s(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 l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,j.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,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=c(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,_=a===void 0?!1:a,v=c(L),y;t[2]===v?y=t[3]:(y=s(v),t[2]=v,t[3]=y);let x=y.connectorsSettings,S=v===`zh`,C;t[4]!==_||t[5]!==S?(C=_?null:(0,j.jsx)(u,{asChild:!0,children:(0,j.jsxs)(b,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(D,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=_,t[5]=S,t[6]=C):C=t[6];let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,j.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[7]=w):w=t[7];let T=S?`应用连接服务`:`App connection service`,E;t[8]===T?E=t[9]:(E=(0,j.jsx)(h,{className:`text-base font-semibold text-fg`,children:T}),t[8]=T,t[9]=E);let O;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,j.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,j.jsx)(P,{})}),t[10]=O):O=t[10];let A;t[11]===E?A=t[12]:(A=(0,j.jsxs)(`div`,{className:`min-w-0`,children:[E,O]}),t[11]=E,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,j.jsx)(o,{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)(f,{asChild:!0,children:(0,j.jsx)(b,{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)(p,{children:[w,(0,j.jsxs)(m,{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)(g,{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=c(e=>e.language),t=s(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,T),[o,l]=(0,A.useState)(``),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(),[m,h]=(0,A.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(S,{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)(y,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(b,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>v({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)(x,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(b,{disabled:u||!o.trim(),onClick:()=>void g(()=>E(o)),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)(b,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>E(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(b,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>v({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(b,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,j.jsx)(C,{open:!!m,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:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>w(e))}})]})}export{O as n,I as t};