@xopcai/xopc 0.0.415 → 0.0.416

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 (251) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +4 -1
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +4 -1
  3. package/dist/browser-ext/dist/assets/{page-context-MuzjMBlJ.js → page-context-CVvmTWZb.js} +33 -9
  4. package/dist/browser-ext/dist/background.js +39 -10
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +22 -3
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/telegram/xopc.extension.json +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CJFwitU2.js → agent-avatar-dicebear-CufU7cqe.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DHDAcss8.js +1 -0
  11. package/dist/gateway/static/root/assets/agents-BV3dAoa0.js +77 -0
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-DgwqNi5i.js → app-management-settings-panel-D4-n1uBg.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-C0wJfFyz.js → appearance-settings-Cgn4eNsX.js} +1 -1
  14. package/dist/gateway/static/root/assets/apps-page-BOYzD7Zz.js +1 -0
  15. package/dist/gateway/static/root/assets/{archive-plugin-Ch7wolHE.js → archive-plugin-B4btCsiV.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automations-page-DK7AU79v.js → automations-page-yb1EL_3N.js} +1 -1
  17. package/dist/gateway/static/root/assets/automations-workspace-J7LJ4RuV.js +8 -0
  18. package/dist/gateway/static/root/assets/{binary-plugins-B4HcHYsC.js → binary-plugins-DQT9e258.js} +1 -1
  19. package/dist/gateway/static/root/assets/{block-editor-BQAWEZF-.js → block-editor-B50rU9tL.js} +4 -4
  20. package/dist/gateway/static/root/assets/browser-automations-page-BiQz6lJA.js +3 -0
  21. package/dist/gateway/static/root/assets/browser-settings-page-W9kuxBbE.js +3 -0
  22. package/dist/gateway/static/root/assets/capabilities-page-iXe87MdG.js +2 -0
  23. package/dist/gateway/static/root/assets/capabilities-settings-panel-CRLSXe7Z.js +8 -0
  24. package/dist/gateway/static/root/assets/{capability-header-actions-D4Yq35fD.js → capability-header-actions-BMnbzHms.js} +1 -1
  25. package/dist/gateway/static/root/assets/channels-CrRJkOKX.js +1 -0
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-zdMySdMm.js → chat-terminal-dock-Bd3af4gL.js} +2 -2
  27. package/dist/gateway/static/root/assets/{computer-settings-page-C5Z6Jr0p.js → computer-settings-page-DXfqy7xh.js} +1 -1
  28. package/dist/gateway/static/root/assets/{connector-service-page-Cxus0qrZ.js → connector-service-page-B-cw0CPU.js} +1 -1
  29. package/dist/gateway/static/root/assets/connectors-page-DbFxc0Fd.js +1 -0
  30. package/dist/gateway/static/root/assets/{date-picker-DuyyD6jz.js → date-picker-CqzXevH6.js} +1 -1
  31. package/dist/gateway/static/root/assets/{dependency-picker-BZN72rrk.js → dependency-picker-pgT4Gyaf.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-BcyP7Z6v.js → desktop-pet-settings-Dy_-i2L8.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-BtvTIDCi.js → desktop-pet-zICeqw9c.js} +1 -1
  34. package/dist/gateway/static/root/assets/device-pairing-wizard-ByGbxqkg.js +1 -0
  35. package/dist/gateway/static/root/assets/{directory-picker-path-field-DOusKz-O.js → directory-picker-path-field-C-aQ7qoM.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-debug-page-Bt4FwsFu.js → extension-debug-page-2NwpYkS5.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-0vsxX3FB.js → extension-page-y9J0z7_Q.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-settings-page-5Pt5_ELc.js → extension-settings-page-BtowusUh.js} +1 -1
  39. package/dist/gateway/static/root/assets/gateway-realtime-C52ghnBK.js +1 -0
  40. package/dist/gateway/static/root/assets/gateway-settings-BYSKzUMR.js +1 -0
  41. package/dist/gateway/static/root/assets/highlight-code-Cz6eeDH5.js +1 -0
  42. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-Cbk7eMlg.js → highlighted-body-KQOG7T2V-BiAa8HKC.js} +1 -1
  43. package/dist/gateway/static/root/assets/home-page-Cd1BjYHj.js +2 -0
  44. package/dist/gateway/static/root/assets/{image-generation-api-CAS8QVla.js → image-generation-api-gBFro48x.js} +1 -1
  45. package/dist/gateway/static/root/assets/{imports-page-BCLBYzV1.js → imports-page-BZQpXgjj.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-Cy16gQST.css +1 -0
  47. package/dist/gateway/static/root/assets/index-DRyGCING.js +710 -0
  48. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CM_kt5XN.js → keyboard-shortcuts-settings-CYunR34k.js} +1 -1
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-B_Ac1lly.js +1 -0
  50. package/dist/gateway/static/root/assets/{local-apps-page-BTSOChhk.js → local-apps-page-w-J5bY02.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-Dnjvvx2i.js +2 -0
  52. package/dist/gateway/static/root/assets/management-settings-w1EDwgLW.js +1 -0
  53. package/dist/gateway/static/root/assets/{media-plugins-DYQDjCVQ.js → media-plugins-CIx1koXw.js} +1 -1
  54. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DISkHmEC.js +1 -0
  55. package/dist/gateway/static/root/assets/note-detail-panel-CNkxMTFU.js +5 -0
  56. package/dist/gateway/static/root/assets/note-image-lightbox-D5GH2wuC.js +1 -0
  57. package/dist/gateway/static/root/assets/notes-page-DZgKqFBG.js +8 -0
  58. package/dist/gateway/static/root/assets/{page-context-capture-button-DVn_dU83.js → page-context-capture-button-DusR2Itk.js} +1 -1
  59. package/dist/gateway/static/root/assets/personal-page-CR5JFkQ9.js +1 -0
  60. package/dist/gateway/static/root/assets/{personal-settings-panel-C16Iqe7X.js → personal-settings-panel-B7undvlr.js} +1 -1
  61. package/dist/gateway/static/root/assets/phone-model-picker-fWDltRUJ.js +1 -0
  62. package/dist/gateway/static/root/assets/phone-settings-page-CsOirAiy.js +1 -0
  63. package/dist/gateway/static/root/assets/plugin-details-dialog-BOBVIB3j.js +1 -0
  64. package/dist/gateway/static/root/assets/{preview-open-alternatives-RlHk76TI.js → preview-open-alternatives-CMxjsKSw.js} +1 -1
  65. package/dist/gateway/static/root/assets/{product-open-page-Dh-HqLrE.js → product-open-page-CrlyJx5M.js} +1 -1
  66. package/dist/gateway/static/root/assets/{product-preview-content-c3K-4DWc.js → product-preview-content-B-Jhzi7W.js} +1 -1
  67. package/dist/gateway/static/root/assets/project-detail-page-DoYUbtcI.js +7 -0
  68. package/dist/gateway/static/root/assets/{projects-page-B8HAt9sD.js → projects-page-xGQd9oAZ.js} +1 -1
  69. package/dist/gateway/static/root/assets/refresh-cw-BRlGaq2w.js +1 -0
  70. package/dist/gateway/static/root/assets/remote-access-hub-Gs0Xkws9.js +1 -0
  71. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Bwg7U7TR.js +1 -0
  72. package/dist/gateway/static/root/assets/{schema-form-CXO1B1k4.js → schema-form-ByzTNR_C.js} +1 -1
  73. package/dist/gateway/static/root/assets/{session-manager-CA1NkTR_.js → session-manager-B_h0jlLb.js} +1 -1
  74. package/dist/gateway/static/root/assets/sessions-page-XzK1ftbR.js +1 -0
  75. package/dist/gateway/static/root/assets/settings-advanced-gate-D_8Mvnog.js +1 -0
  76. package/dist/gateway/static/root/assets/{settings-form-section-BQxKmbbJ.js → settings-form-section-Brgd8IOV.js} +1 -1
  77. package/dist/gateway/static/root/assets/{settings-page-DvVMpKiA.js → settings-page-B6Mv02eg.js} +1 -1
  78. package/dist/gateway/static/root/assets/settings-page-header-BWyxJKOG.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-page-layout-B20AfmFG.js → settings-page-layout-DLHcS-0T.js} +1 -1
  80. package/dist/gateway/static/root/assets/setup-status-panel-DSCj5yis.js +1 -0
  81. package/dist/gateway/static/root/assets/{share-preview-page-XgZk8Oa1.js → share-preview-page-DF8Of0aZ.js} +1 -1
  82. package/dist/gateway/static/root/assets/shares-settings-DXNPe4Tl.js +1 -0
  83. package/dist/gateway/static/root/assets/{skill-api-CV-WT2hj.js → skill-api-CKCDCHLq.js} +1 -1
  84. package/dist/gateway/static/root/assets/skill-reload-api-BH0WF6Br.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-DFWMVRW4.js +2 -0
  86. package/dist/gateway/static/root/assets/system-settings-panel-DB-ttubV.js +1 -0
  87. package/dist/gateway/static/root/assets/task-detail-page-BJY7c8wb.js +2 -0
  88. package/dist/gateway/static/root/assets/{task-result-evidence-D-gGKNX9.js → task-result-evidence-B-vt1BgK.js} +1 -1
  89. package/dist/gateway/static/root/assets/{tracing-settings-page-CQw3G-FB.js → tracing-settings-page-Dt51Z_ws.js} +1 -1
  90. package/dist/gateway/static/root/assets/{tunnel-api-B2HnCi0U.js → tunnel-api-Dok3t7Qe.js} +1 -1
  91. package/dist/gateway/static/root/assets/usage-page-lJym5G7F.js +1 -0
  92. package/dist/gateway/static/root/assets/{use-autosave-Dc0nwUpX.js → use-autosave-D4EMIB-V.js} +1 -1
  93. package/dist/gateway/static/root/assets/user-model-page-BXdNkITp.js +2 -0
  94. package/dist/gateway/static/root/assets/{voice-api-key-field-BSWXZkGa.js → voice-api-key-field-CO3KuanA.js} +1 -1
  95. package/dist/gateway/static/root/assets/{work-discovery-overlay-H3cdwq3l.js → work-discovery-overlay-BJRtgQM3.js} +1 -1
  96. package/dist/gateway/static/root/assets/wrench-DFb4r8bH.js +1 -0
  97. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CS-_GxHV.js +1 -0
  98. package/dist/gateway/static/root/browser-setup-test.html +5 -0
  99. package/dist/gateway/static/root/browser-setup-test.js +7 -0
  100. package/dist/gateway/static/root/index.html +7 -4
  101. package/dist/package.js +1 -1
  102. package/dist/packages/gateway-contract/src/browser-setup.js +6 -0
  103. package/dist/packages/gateway-contract/src/index.js +4 -0
  104. package/dist/packages/gateway-contract/src/phone-setup.js +6 -0
  105. package/dist/packages/realtime-client/src/index.js +1 -0
  106. package/dist/packages/realtime-protocol/src/index.js +1 -0
  107. package/dist/src/agent/agent-manager.d.ts +4 -0
  108. package/dist/src/agent/agent-manager.js +12 -1
  109. package/dist/src/agent/embedded/tool-search-extension.js +14 -1
  110. package/dist/src/agent/service.d.ts +1 -0
  111. package/dist/src/agent/service.js +5 -0
  112. package/dist/src/agent/service.types.d.ts +2 -0
  113. package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
  114. package/dist/src/agent/tool-manuals/phone.js +1 -1
  115. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -0
  116. package/dist/src/agent/tool-manuals/xopc-configuration.js +25 -0
  117. package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +2 -0
  118. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +6 -2
  119. package/dist/src/agent/tools/factory.d.ts +3 -0
  120. package/dist/src/agent/tools/factory.js +11 -1
  121. package/dist/src/agent/tools/phone-use-tool.d.ts +1 -0
  122. package/dist/src/agent/tools/phone-use-tool.js +9 -1
  123. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
  124. package/dist/src/agent/tools/tool-manual-tool.js +3 -1
  125. package/dist/src/agent/tools/toolExposure.js +3 -0
  126. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  127. package/dist/src/agent/tools/xopc-use-tool.js +40 -2
  128. package/dist/src/browser/drivers/browser-driver.d.ts +2 -2
  129. package/dist/src/browser/drivers/extension-driver.d.ts +2 -2
  130. package/dist/src/browser/drivers/extension-driver.js +6 -3
  131. package/dist/src/browser/providers/browser-ext-install.js +2 -1
  132. package/dist/src/browser/runtime/browser-runtime.d.ts +4 -1
  133. package/dist/src/browser/runtime/browser-runtime.js +29 -17
  134. package/dist/src/browser/setup/repository.d.ts +5 -0
  135. package/dist/src/browser/setup/repository.js +42 -0
  136. package/dist/src/browser/setup/service.d.ts +152 -0
  137. package/dist/src/browser/setup/service.js +404 -0
  138. package/dist/src/browser/setup/types.d.ts +38 -0
  139. package/dist/src/browser/setup/types.js +1 -0
  140. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  141. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  142. package/dist/src/config/schema.d.ts +2 -0
  143. package/dist/src/connectors/connected-source-understanding.js +1 -1
  144. package/dist/src/connectors/learning-coordinator.js +1 -1
  145. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  146. package/dist/src/gateway/hono/routes/browser-setup.d.ts +3 -0
  147. package/dist/src/gateway/hono/routes/browser-setup.js +114 -0
  148. package/dist/src/gateway/hono/routes/browser.d.ts +2 -1
  149. package/dist/src/gateway/hono/routes/browser.js +1 -1
  150. package/dist/src/gateway/hono/routes/connectors.js +7 -7
  151. package/dist/src/gateway/hono/routes/home.js +1 -1
  152. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  153. package/dist/src/gateway/hono/routes/phone-dependencies.js +1 -1
  154. package/dist/src/gateway/hono/routes/phone-setup.d.ts +7 -0
  155. package/dist/src/gateway/hono/routes/phone-setup.js +162 -0
  156. package/dist/src/gateway/hono/routes/phone.js +3 -7
  157. package/dist/src/gateway/hono/routes/public-gateway.js +3 -1
  158. package/dist/src/gateway/provider-model-setup.js +1 -1
  159. package/dist/src/gateway/service/config-coordinator.d.ts +2 -0
  160. package/dist/src/gateway/service.d.ts +5 -0
  161. package/dist/src/gateway/service.js +57 -12
  162. package/dist/src/gateway/xopc-cloud-capability-setup.js +7 -1
  163. package/dist/src/home-intelligence/host.js +2 -2
  164. package/dist/src/infra/update-restart.js +1 -1
  165. package/dist/src/phone/adb-driver.d.ts +2 -0
  166. package/dist/src/phone/adb-driver.js +35 -17
  167. package/dist/src/phone/contracts.d.ts +40 -0
  168. package/dist/src/phone/contracts.js +17 -4
  169. package/dist/src/phone/model-adapter.d.ts +59 -2
  170. package/dist/src/phone/model-adapter.js +107 -13
  171. package/dist/src/phone/numeric-entry.d.ts +31 -0
  172. package/dist/src/phone/numeric-entry.js +126 -0
  173. package/dist/src/phone/planning.d.ts +27 -0
  174. package/dist/src/phone/planning.js +79 -0
  175. package/dist/src/phone/recovery.d.ts +37 -0
  176. package/dist/src/phone/recovery.js +81 -0
  177. package/dist/src/phone/repository.d.ts +1 -0
  178. package/dist/src/phone/repository.js +3 -0
  179. package/dist/src/phone/runtime.js +232 -54
  180. package/dist/src/phone/semantic-controls.d.ts +13 -0
  181. package/dist/src/phone/semantic-controls.js +76 -0
  182. package/dist/src/phone/setup/service.d.ts +148 -0
  183. package/dist/src/phone/setup/service.js +251 -0
  184. package/dist/src/providers/presentation.js +2 -2
  185. package/dist/src/providers/xopc-cloud-model-source.js +6 -2
  186. package/dist/src/realtime/runtime.js +1 -1
  187. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  188. package/dist/src/storage/sqlite/schema.js +7 -7
  189. package/dist/src/storage/sqlite/schema.sql +10 -0
  190. package/dist/src/storage/sqlite/upgrades/260_browser_setup.sql +9 -0
  191. package/dist/src/user-context/sources/index.js +1 -1
  192. package/dist/src/work-discovery/service.js +2 -2
  193. package/package.json +6 -6
  194. package/skills/tools/configure-xopc/SKILL.md +47 -0
  195. package/skills/tools/configure-xopc/references/browser/acceptance.md +31 -0
  196. package/skills/tools/configure-xopc/references/browser/chrome-extension.md +19 -0
  197. package/skills/tools/configure-xopc/references/browser/overview.md +22 -0
  198. package/skills/tools/configure-xopc/references/browser/permissions.md +25 -0
  199. package/skills/tools/configure-xopc/references/browser/troubleshooting.md +24 -0
  200. package/skills/tools/configure-xopc/references/phone/acceptance.md +25 -0
  201. package/skills/tools/configure-xopc/references/phone/aliyun.md +29 -0
  202. package/skills/tools/configure-xopc/references/phone/dependencies.md +18 -0
  203. package/skills/tools/configure-xopc/references/phone/local.md +19 -0
  204. package/skills/tools/configure-xopc/references/phone/models.md +18 -0
  205. package/skills/tools/configure-xopc/references/phone/overview.md +30 -0
  206. package/skills/tools/configure-xopc/references/phone/troubleshooting.md +24 -0
  207. package/skills/tools/configure-xopc/references/scene-index.md +12 -0
  208. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DclyJr1N.js +0 -1
  209. package/dist/gateway/static/root/assets/agents-jhErNtzi.js +0 -77
  210. package/dist/gateway/static/root/assets/apps-page-C0LcnI4h.js +0 -1
  211. package/dist/gateway/static/root/assets/automations-workspace-CBxiV34x.js +0 -8
  212. package/dist/gateway/static/root/assets/browser-automations-page-vJIrTxdi.js +0 -3
  213. package/dist/gateway/static/root/assets/browser-settings-page-in5Roh_E.js +0 -3
  214. package/dist/gateway/static/root/assets/capabilities-page-CiGx8wpQ.js +0 -2
  215. package/dist/gateway/static/root/assets/capabilities-settings-panel-a8kqjzQu.js +0 -8
  216. package/dist/gateway/static/root/assets/channels-C_CxcjKT.js +0 -1
  217. package/dist/gateway/static/root/assets/connectors-page-DCBO2CxK.js +0 -1
  218. package/dist/gateway/static/root/assets/device-pairing-wizard-Ctbgr50F.js +0 -1
  219. package/dist/gateway/static/root/assets/gateway-realtime-DkWCHVzI.js +0 -1
  220. package/dist/gateway/static/root/assets/gateway-settings-BsVOcmV5.js +0 -1
  221. package/dist/gateway/static/root/assets/highlight-code-C8eS9949.js +0 -1
  222. package/dist/gateway/static/root/assets/home-page-BZDZnmyc.js +0 -2
  223. package/dist/gateway/static/root/assets/index-Bys6njTY.js +0 -710
  224. package/dist/gateway/static/root/assets/index-Vsf0bj5e.css +0 -1
  225. package/dist/gateway/static/root/assets/local-app-workbench-page-Dk87jtcc.js +0 -1
  226. package/dist/gateway/static/root/assets/logs-page-D3gVdm8S.js +0 -2
  227. package/dist/gateway/static/root/assets/management-settings-BQNYFE4J.js +0 -1
  228. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-ChweJKTv.js +0 -1
  229. package/dist/gateway/static/root/assets/note-detail-panel-CYKwUCte.js +0 -5
  230. package/dist/gateway/static/root/assets/note-image-lightbox-BTSZb9ZT.js +0 -1
  231. package/dist/gateway/static/root/assets/notes-page-CJ5nhWfL.js +0 -8
  232. package/dist/gateway/static/root/assets/personal-page-DcW14lqn.js +0 -1
  233. package/dist/gateway/static/root/assets/phone-dependencies-card-D3l9uPFM.js +0 -1
  234. package/dist/gateway/static/root/assets/phone-model-picker-DOv38vBn.js +0 -1
  235. package/dist/gateway/static/root/assets/phone-settings-page-DUHp1q_9.js +0 -1
  236. package/dist/gateway/static/root/assets/plugin-details-dialog-BpfgDlVa.js +0 -1
  237. package/dist/gateway/static/root/assets/project-detail-page-GD8TxKad.js +0 -7
  238. package/dist/gateway/static/root/assets/remote-access-hub-D3el7lHK.js +0 -1
  239. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Dbskk6RG.js +0 -1
  240. package/dist/gateway/static/root/assets/sessions-page-07liaSHH.js +0 -1
  241. package/dist/gateway/static/root/assets/settings-advanced-gate-BGjU8rfN.js +0 -1
  242. package/dist/gateway/static/root/assets/settings-page-header-CYpuTXUW.js +0 -1
  243. package/dist/gateway/static/root/assets/setup-status-panel-DKo_VTx-.js +0 -1
  244. package/dist/gateway/static/root/assets/shares-settings-BODFqK8k.js +0 -1
  245. package/dist/gateway/static/root/assets/skill-reload-api-Ce6OUk2C.js +0 -1
  246. package/dist/gateway/static/root/assets/skills-page-B7ehOIML.js +0 -2
  247. package/dist/gateway/static/root/assets/system-settings-panel-CxJkZRT4.js +0 -1
  248. package/dist/gateway/static/root/assets/task-detail-page-CxRR0QuW.js +0 -2
  249. package/dist/gateway/static/root/assets/usage-page-uUEkO38r.js +0 -1
  250. package/dist/gateway/static/root/assets/user-model-page-ICUutbKL.js +0 -2
  251. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CvT_W6YS.js +0 -1
@@ -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-BvcCCgTW.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./globe-DSSGFWFn.js";import{t as s}from"./messages-BYq0cPbn.js";import{i as c,n as l,o as u}from"./locale-store-B7s2Hb35.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-aIC072nz.js";import{t as p}from"./skeleton-BI5TyibZ.js";import{r as m}from"./gateway-config-swr-fQKBHBi1.js";import{n as h,t as g}from"./registry-api-BcfoLEna.js";import{t as _}from"./electron-env-Dit0bHgy.js";import{Dn as v,On as y,Ul as b,cu as x,hl as S,ii as C,su as w,wl as T}from"./index-Bys6njTY.js";import{n as ee,t as te}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";var E=n(),D=e(t(),1),O=r();function k({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,v),r=d(g,h),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,D.useState)(a),[l,u]=(0,D.useState)(!1),[m,_]=(0,D.useState)(``),[b,x]=(0,D.useState)(!1);(0,D.useEffect)(()=>{c(a)},[a]);let S=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),_(``),x(!1);try{if(!S)throw Error(t.modelUnavailable);let e=await v(),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),x(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,O.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,O.jsx)(p,{className:`h-52 w-full rounded-xl`}):n.error?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,O.jsx)(f,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,O.jsx)(p,{className:`h-11 w-full rounded-lg`}):(0,O.jsx)(C,{value:o,onChange:e=>{c(e),x(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,O.jsx)(f,{variant:`primary`,disabled:l||o===a||!S||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{children:t.modelDataUse}),(0,O.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,O.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),b&&(0,O.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!S&&!r.isLoading&&!r.error&&(0,O.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,O.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,O.jsx)(f,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),m&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:m})]})]})}function A(e){let t=(0,E.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,O.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,O.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,O.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,O.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function j(){let e=(0,E.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,O.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}=m(!0),d=n?.payload?.config,[h,g]=(0,D.useState)(!1),[v,y]=(0,D.useState)(``),[C,E]=(0,D.useState)(!1),[j,M]=(0,D.useState)(null),[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(null),[ne,L]=(0,D.useState)(!1),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[re,H]=(0,D.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,D.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,D.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=>{g(!0),y(``);try{await e()}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(!1)}},ie=e=>G(async()=>{_()&&(await u(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{y(``),E(!1);try{await U?.stop(),E(!0),U&&M(await U.status())}catch(e){y(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=_()&&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,O.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,O.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(A,{icon:(0,O.jsx)(T,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,O.jsx)(f,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(A,{icon:(0,O.jsx)(x,{className:`size-5`}),title:t.device,description:(0,O.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,O.jsx)(f,{disabled:h,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(A,{icon:(0,O.jsx)(T,{className:`size-5`}),title:t.accessibility,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,O.jsx)(f,{disabled:h,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,O.jsxs)(A,{icon:(0,O.jsx)(x,{className:`size-5`}),title:t.screen,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,O.jsx)(f,{disabled:h,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,O.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,O.jsx)(f,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,O.jsx)(`div`,{"aria-label":t.checking,children:(0,O.jsx)(p,{className:`h-20 w-full rounded-xl`})}):(0,O.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(j?.error||j?.session?.errorCode)&&(0,O.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,O.jsxs)(ee,{gap:`gap-7`,children:[(0,O.jsx)(te,{title:t.title,subtitle:t.subtitle,meta:(0,O.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:U&&(0,O.jsxs)(f,{onClick:()=>{ae()},children:[(0,O.jsx)(S,{className:`size-3.5`}),t.stop]})}),v&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:v}),C&&(0,O.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,O.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,O.jsx)(p,{className:`h-32 w-full rounded-xl`}):l?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,O.jsx)(f,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(A,{icon:(0,O.jsx)(w,{className:`size-5`}),title:t.desktop,description:(0,O.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:h||!_(),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,O.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,O.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,O.jsx)(f,{disabled:h,onClick:()=>{G(async()=>{U&&M(await U.resume()),E(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,O.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,O.jsxs)(f,{disabled:h,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,O.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,O.jsx)(b,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(A,{icon:(0,O.jsx)(w,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:h,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,O.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,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,O.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(f,{disabled:h,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,O.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,O.jsx)(p,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,O.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{"aria-label":t.searchApps,value: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,O.jsx)(f,{disabled:h,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,O.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(f,{disabled:h,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,O.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,O.jsx)(k,{zh:e}),!Y&&$,(0,O.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(A,{icon:(0,O.jsx)(o,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,O.jsx)(f,{asChild:!0,children:(0,O.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{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-BvcCCgTW.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./globe-DSSGFWFn.js";import{t as s}from"./messages-BYq0cPbn.js";import{i as c,n as l,o as u}from"./locale-store-B7s2Hb35.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-aIC072nz.js";import{t as p}from"./skeleton-BI5TyibZ.js";import{r as m}from"./gateway-config-swr-fQKBHBi1.js";import{n as h,t as g}from"./registry-api-BcfoLEna.js";import{t as _}from"./electron-env-Dit0bHgy.js";import{An as v,El as y,Wl as b,_l as x,cu as S,jn as C,si as w,su as T}from"./index-DRyGCING.js";import{n as ee,t as te}from"./settings-page-header-BWyxJKOG.js";import"./settings-page-layout-DLHcS-0T.js";var E=n(),D=e(t(),1),O=r();function k({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,v),r=d(g,h),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,D.useState)(a),[l,u]=(0,D.useState)(!1),[m,_]=(0,D.useState)(``),[y,b]=(0,D.useState)(!1);(0,D.useEffect)(()=>{c(a)},[a]);let x=!o||r.data?.some(e=>e.id===o&&e.computerUse),S=async()=>{u(!0),_(``),b(!1);try{if(!x)throw Error(t.modelUnavailable);let e=await v(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await C({...e.defaults,models:r});await n.mutate(i,!1),b(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,O.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,O.jsx)(p,{className:`h-52 w-full rounded-xl`}):n.error?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,O.jsx)(f,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,O.jsx)(p,{className:`h-11 w-full rounded-lg`}):(0,O.jsx)(w,{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,O.jsx)(f,{variant:`primary`,disabled:l||o===a||!x||!!r.error||r.isLoading,onClick:()=>{S()},children:t.saveModel})]}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{children:t.modelDataUse}),(0,O.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,O.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),y&&(0,O.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!x&&!r.isLoading&&!r.error&&(0,O.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,O.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,O.jsx)(f,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),m&&(0,O.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:m})]})]})}function A(e){let t=(0,E.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,O.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,O.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,O.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,O.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function j(){let e=(0,E.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,O.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}=m(!0),d=n?.payload?.config,[h,g]=(0,D.useState)(!1),[v,C]=(0,D.useState)(``),[w,E]=(0,D.useState)(!1),[j,M]=(0,D.useState)(null),[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(null),[ne,L]=(0,D.useState)(!1),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[re,H]=(0,D.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,D.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,D.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=>{g(!0),C(``);try{await e()}catch(e){C(e instanceof Error?e.message:String(e))}finally{g(!1)}},ie=e=>G(async()=>{_()&&(await u(c(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{C(``),E(!1);try{await U?.stop(),E(!0),U&&M(await U.status())}catch(e){C(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=_()&&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,O.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,O.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(A,{icon:(0,O.jsx)(y,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,O.jsx)(f,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(A,{icon:(0,O.jsx)(S,{className:`size-5`}),title:t.device,description:(0,O.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,O.jsx)(f,{disabled:h,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(A,{icon:(0,O.jsx)(y,{className:`size-5`}),title:t.accessibility,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,O.jsx)(f,{disabled:h,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,O.jsxs)(A,{icon:(0,O.jsx)(S,{className:`size-5`}),title:t.screen,children:[(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,O.jsx)(f,{disabled:h,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,O.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,O.jsx)(f,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,O.jsx)(`div`,{"aria-label":t.checking,children:(0,O.jsx)(p,{className:`h-20 w-full rounded-xl`})}):(0,O.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(j?.error||j?.session?.errorCode)&&(0,O.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,O.jsxs)(ee,{gap:`gap-7`,children:[(0,O.jsx)(te,{title:t.title,subtitle:t.subtitle,meta:(0,O.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:U&&(0,O.jsxs)(f,{onClick:()=>{ae()},children:[(0,O.jsx)(x,{className:`size-3.5`}),t.stop]})}),v&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:v}),w&&(0,O.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,O.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,O.jsx)(p,{className:`h-32 w-full rounded-xl`}):l?(0,O.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,O.jsx)(f,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,O.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(A,{icon:(0,O.jsx)(T,{className:`size-5`}),title:t.desktop,description:(0,O.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:h||!_(),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,O.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,O.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,O.jsx)(f,{disabled:h,onClick:()=>{G(async()=>{U&&M(await U.resume()),E(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,O.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,O.jsxs)(f,{disabled:h,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,O.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,O.jsx)(b,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,O.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,O.jsx)(A,{icon:(0,O.jsx)(T,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:h,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,O.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,O.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,O.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(f,{disabled:h,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,O.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,O.jsx)(p,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,O.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{"aria-label":t.searchApps,value: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,O.jsx)(f,{disabled:h,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,O.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,O.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,O.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,O.jsx)(f,{disabled:h,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,O.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,O.jsx)(k,{zh:e}),!Y&&$,(0,O.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,O.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,O.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,O.jsx)(A,{icon:(0,O.jsx)(o,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,O.jsx)(f,{asChild:!0,children:(0,O.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{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-BvcCCgTW.js";import{t as o}from"./messages-BYq0cPbn.js";import{n as s}from"./locale-store-B7s2Hb35.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{t as l}from"./button-aIC072nz.js";import{t as u}from"./skeleton-BI5TyibZ.js";import{Bc as d,Do as f,El as p,Hc as m,Ic as h,Jc as g,Lc as _,Ot as v,Rc as y,Uc as b,Vc as x,Yo as S,_s as C,ms as w,na as T,os as E,zc as D}from"./index-Bys6njTY.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=s(N),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,c;e[2]===r.title?c=e[3]:(c=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=c);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]!==c||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[c,u,d,f]}),e[8]=c,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=s(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,c=a===void 0?!1:a,u=s(L),f;t[2]===u?f=t[3]:(f=o(u),t[2]=u,t[3]=f);let v=f.connectorsSettings,S=u===`zh`,C;t[4]!==c||t[5]!==S?(C=c?null:(0,j.jsx)(b,{asChild:!0,children:(0,j.jsxs)(l,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(p,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=c,t[5]=S,t[6]=C):C=t[6];let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,j.jsx)(d,{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)(m,{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)(g,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===v.modalClose?N=t[15]:(N=(0,j.jsx)(_,{asChild:!0,children:(0,j.jsx)(l,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":v.modalClose,children:M})}),t[14]=v.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)(x,{children:[w,(0,j.jsxs)(y,{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)(h,{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=s(e=>e.language),t=o(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=c(`connector-service`,E),[d,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(!1),[g,_]=(0,A.useState)(),[y,b]=(0,A.useState)();async function x(e){h(!0),_(void 0);try{await e(),p(``),await a()}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(u,{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)(v,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(l,{variant:`secondary`,disabled:m||r.mode===`managed`&&r.configured,onClick:()=>void x(()=>C({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,j.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,j.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,j.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,j.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,j.jsx)(`li`,{children:t.composioSetupStepProject}),(0,j.jsx)(`li`,{children:t.composioSetupStepKey}),(0,j.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,j.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,j.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,j.jsx)(`span`,{children:`Composio API key`}),(0,j.jsx)(f,{value:d,onChange:p,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(l,{disabled:m||!d.trim(),onClick:()=>void x(()=>S(d)),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)(l,{variant:`ghost`,disabled:m||!d.trim()||e.credentialSource===`environment`,onClick:()=>void x(()=>S(d,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(l,{variant:`ghost`,disabled:m||e.id===r.backendId,onClick:()=>void x(()=>C({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(l,{variant:`ghost`,disabled:m||e.id===r.backendId,onClick:()=>b(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,g||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g??String(i)}):null,(0,j.jsx)(T,{open:!!y,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:()=>b(void 0),onConfirm:()=>{let e=y;b(void 0),e&&x(()=>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-BvcCCgTW.js";import{t as o}from"./messages-BYq0cPbn.js";import{n as s}from"./locale-store-B7s2Hb35.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{t as l}from"./button-aIC072nz.js";import{t as u}from"./skeleton-BI5TyibZ.js";import{Ao as d,Bc as f,Gc as p,Hc as m,Kc as h,Ol as g,Qo as _,Uc as v,Vc as y,Wc as b,Zc as x,_s as S,aa as C,bs as w,jt as T,ls as E,zc as D}from"./index-DRyGCING.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=s(N),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,c;e[2]===r.title?c=e[3]:(c=(0,j.jsx)(a,{to:`/capabilities/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=c);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]!==c||e[9]!==u?(p=(0,j.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[c,u,d,f]}),e[8]=c,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=s(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,c=a===void 0?!1:a,u=s(L),d;t[2]===u?d=t[3]:(d=o(u),t[2]=u,t[3]=d);let _=d.connectorsSettings,S=u===`zh`,C;t[4]!==c||t[5]!==S?(C=c?null:(0,j.jsx)(h,{asChild:!0,children:(0,j.jsxs)(l,{type:`button`,variant:`secondary`,className:`shrink-0`,"aria-label":S?`应用连接服务`:`Connection service`,children:[(0,j.jsx)(g,{className:`size-4`,"aria-hidden":!0}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:S?`应用连接服务`:`Connection service`})]})}),t[4]=c,t[5]=S,t[6]=C):C=t[6];let w;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,j.jsx)(v,{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)(p,{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)(m,{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)(x,{className:`size-5`,"aria-hidden":!0}),t[13]=M):M=t[13];let N;t[14]===_.modalClose?N=t[15]:(N=(0,j.jsx)(f,{asChild:!0,children:(0,j.jsx)(l,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":_.modalClose,children:M})}),t[14]=_.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)(b,{children:[w,(0,j.jsxs)(y,{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)(D,{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=s(e=>e.language),t=o(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=c(`connector-service`,E),[f,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(!1),[g,v]=(0,A.useState)(),[y,b]=(0,A.useState)();async function x(e){h(!0),v(void 0);try{await e(),p(``),await a()}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(!1)}}return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,j.jsx)(u,{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)(T,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,j.jsx)(l,{variant:`secondary`,disabled:m||r.mode===`managed`&&r.configured,onClick:()=>void x(()=>w({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)(d,{value:f,onChange:p,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,j.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,j.jsx)(l,{disabled:m||!f.trim(),onClick:()=>void x(()=>_(f)),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)(l,{variant:`ghost`,disabled:m||!f.trim()||e.credentialSource===`environment`,onClick:()=>void x(()=>_(f,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,j.jsx)(l,{variant:`ghost`,disabled:m||e.id===r.backendId,onClick:()=>void x(()=>w({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,j.jsx)(l,{variant:`ghost`,disabled:m||e.id===r.backendId,onClick:()=>b(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,g||i?(0,j.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g??String(i)}):null,(0,j.jsx)(C,{open:!!y,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:()=>b(void 0),onConfirm:()=>{let e=y;b(void 0),e&&x(()=>S(e))}})]})}export{O as n,I as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,u as a}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{n as s,r as c,t as l}from"./popover-select-DGKUpVsz.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./ellipsis-0k4rZLoy.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./eye-CABVeTq0.js";import{t as m}from"./loader-circle-CifKLtgG.js";import{t as h}from"./refresh-cw-BRlGaq2w.js";import{t as g}from"./wrench-DFb4r8bH.js";import{t as _}from"./messages-BYq0cPbn.js";import{t as v}from"./cn-0WouolD0.js";import{i as y,l as b,n as x,o as S}from"./locale-store-B7s2Hb35.js";import{n as C}from"./copy-to-clipboard-HOJ79TWv.js";import{i as w}from"./vendor-swr-BIWyz7Rc.js";import{t as T}from"./button-aIC072nz.js";import{t as E}from"./skeleton-BI5TyibZ.js";import{n as D,r as O}from"./gateway-config-swr-fQKBHBi1.js";import{n as k}from"./electron-env-Dit0bHgy.js";import{$o as A,Al as j,As as M,Bc as N,Cs as P,Dd as F,Ds as I,Es as L,F as R,Fo as z,G as B,Ga as V,Gc as H,Gl as U,Gn as W,Hc as ee,I as G,Iu as te,J as ne,K,Kn as re,Md as ie,Ns as q,O as J,Ol as ae,Os as Y,Pl as oe,R as se,Sd as ce,So as X,Ss as le,Ts as Z,U as ue,Uc as de,Un as fe,V as pe,Vc as me,W as he,Wc as ge,Wl as _e,Wn as ve,Y as ye,Zc as be,aa as xe,as as Se,ca as Ce,co as we,cs as Te,da as Ee,dl as De,ds as Oe,es as ke,fd as Ae,fs as je,gs as Me,hs as Ne,is as Pe,iu as Fe,jd as Ie,js as Le,k as Re,ks as ze,la as Be,ld as Ve,ms as He,no as Ue,ns as We,os as Ge,pa as Ke,pl as qe,ps as Je,q as Ye,rs as Xe,sl as Ze,ss as Qe,ts as $e,ua as et,us as tt,vs as nt,ws as rt,xd as it,xs as at,ys as ot,zc as st}from"./index-DRyGCING.js";import{n as ct,t as lt}from"./capability-header-actions-BMnbzHms.js";import{t as ut}from"./connector-service-page-B-cw0CPU.js";import{t as dt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),ft=n(),$=r();function pt(e){let t=(0,ft.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,d,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(mt),m=e.slice(0,2),h=Math.max(0,e.length-m.length),g=o.connect,_;t[11]!==n||t[12]!==o?(_=K(n,o),t[11]=n,t[12]=o,t[13]=_):_=t[13];let y=_,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==g||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(T,{type:`button`,variant:`secondary`,className:v(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(Fe,{className:`size-4`}),g]}),t[14]=g,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(he,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let E;t[25]!==w||t[26]!==C?(E=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=E):E=t[27];let D;t[28]!==E||t[29]!==S?(D=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,E]}),t[28]=E,t[29]=S,t[30]=D):D=t[30];let O;t[31]!==r||t[32]!==s?(O=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=O):O=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==O||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[37]=O,t[38]=k,t[39]=A):A=t[39],t[40]!==D||t[41]!==A?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[40]=D,t[41]=A,t[42]=l):l=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=m.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),h>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,h]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=d,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],d=t[8],f=t[9],p=t[10];let m;t[45]!==c||t[46]!==l||t[47]!==d||t[48]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[l,d,f]}),t[45]=c,t[46]=l,t[47]=d,t[48]=f,t[49]=m):m=t[49];let h;t[50]!==r||t[51]!==s?(h=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=h):h=t[52];let g;return t[53]!==p||t[54]!==m||t[55]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g):g=t[56],g}function mt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ht=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function gt(e,t){return t.some(t=>t.connectorId===e.id)}var _t=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function vt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:v(`size-10 shrink-0 rounded-xl`,_t)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:v(`h-4 min-w-0 flex-1`,_t)}),(0,$.jsx)(`div`,{className:v(`h-8 w-[4.5rem] shrink-0 rounded-lg`,_t)})]}),(0,$.jsx)(`div`,{className:v(`h-3 w-full`,_t)}),(0,$.jsx)(`div`,{className:v(`h-3 w-[88%]`,_t)})]})]})}),e[1]=n):n=e[1],n}function yt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(E,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(E,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(E,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(E,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(E,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var bt=[`understand`,`act`,`reach`];function xt(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function St(e){return xt(e)[0]??`act`}function Ct(e,t){let n=t?St(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function wt(e,t){return t.connectorCapabilityLabels[e]??e}function Tt(e,t){if(e.runtime.type===`mcp`)return Ye(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return Ye(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Et(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Dt(e){let t=(0,ft.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=K(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,d,f,p,m,h,g,_,y,b,x,S,C,w,E,D;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=xt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(At),...(n.setup.config??[]).filter(kt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,T=n.capabilities.filter(Ot);f=st,g=!0,t[27]===i?_=t[28]:(_=e=>{e||i()},t[27]=i,t[28]=_),d=ge,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(de,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=h):h=t[29],l=me,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=v(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=p):p=t[30];let O;t[31]===n?O=t[32]:(O=(0,$.jsx)(he,{connector:n,size:`lg`}),t[31]=n,t[32]=O);let k;t[33]===n.displayName?k=t[34]:(k=(0,$.jsx)(H,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=k);let A;t[35]!==r||t[36]!==o.connectedBadge?(A=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(u,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=A):A=t[37];let M;t[38]!==k||t[39]!==A?(M=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k,A]}),t[38]=k,t[39]=A,t[40]=M):M=t[40];let P;t[41]===c?P=t[42]:(P=(0,$.jsx)(ee,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=P);let F;t[43]!==M||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[M,P]}),t[43]=M,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==O||t[47]!==F?(I=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[O,F]}),t[46]=O,t[47]=F,t[48]=I):I=t[48];let L;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(L=v(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.focusRingPanel),t[49]=L):L=t[49];let R;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(be,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=R):R=t[50];let z;t[51]===o.modalClose?z=t[52]:(z=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:L,"aria-label":o.modalClose,children:R})}),t[51]=o.modalClose,t[52]=z),t[53]!==I||t[54]!==z?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[I,z]}),t[53]=I,t[54]=z,t[55]=m):m=t[55],w=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,E=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let B;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(te,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=B):B=t[56];let V;t[57]===o.detailPermissions?V=t[58]:(V=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=V);let U;t[59]!==n||t[60]!==o?(U=Et(n,o),t[59]=n,t[60]=o,t[61]=U):U=t[61];let W;t[62]===U?W=t[63]:(W=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:U}),t[62]=U,t[63]=W);let G;t[64]!==V||t[65]!==W?(G=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[B,(0,$.jsxs)(`div`,{children:[V,W]})]}),t[64]=V,t[65]=W,t[66]=G):G=t[66];let ne;t[67]===o.connectorSetupTitle?ne=t[68]:(ne=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=ne);let K;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(K=s.length?Ye(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=K):K=t[72];let re;t[73]===K?re=t[74]:(re=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:K}),t[73]=K,t[74]=re);let ie;t[75]!==ne||t[76]!==re?(ie=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[ne,re]}),t[75]=ne,t[76]=re,t[77]=ie):ie=t[77],t[78]!==G||t[79]!==ie?(D=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[G,ie]}),t[78]=G,t[79]=ie,t[80]=D):D=t[80],S=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?C=t[82]:(C=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=C),y=`space-y-5 border-t border-edge-subtle px-4 py-4`;let J;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),t[83]=J):J=t[83];let ae;t[84]===o.connectorRuntimeTitle?ae=t[85]:(ae=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[J,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=ae);let Y;t[86]!==n||t[87]!==o?(Y=Tt(n,o),t[86]=n,t[87]=o,t[88]=Y):Y=t[88];let oe;t[89]===Y?oe=t[90]:(oe=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:Y}),t[89]=Y,t[90]=oe),t[91]!==ae||t[92]!==oe?(b=(0,$.jsxs)(`div`,{children:[ae,oe]}),t[91]=ae,t[92]=oe,t[93]=b):b=t[93],x=T.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:T.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:wt(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=E,t[23]=D}else l=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],E=t[22],D=t[23];let O;t[94]!==y||t[95]!==b||t[96]!==x?(O=(0,$.jsxs)(`div`,{className:y,children:[b,x]}),t[94]=y,t[95]=b,t[96]=x,t[97]=O):O=t[97];let k;t[98]!==O||t[99]!==S||t[100]!==C?(k=(0,$.jsxs)(`details`,{className:S,children:[C,O]}),t[98]=O,t[99]=S,t[100]=C,t[101]=k):k=t[101];let A;t[102]!==k||t[103]!==w||t[104]!==E||t[105]!==D?(A=(0,$.jsxs)(`div`,{className:w,children:[E,D,k]}),t[102]=k,t[103]=w,t[104]=E,t[105]=D,t[106]=A):A=t[106];let M;t[107]===o.modalClose?M=t[108]:(M=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(T,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=M);let P;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(P=r?null:(0,$.jsxs)(T,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(Fe,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=P):P=t[114];let F;t[115]!==M||t[116]!==P?(F=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[M,P]}),t[115]=M,t[116]=P,t[117]=F):F=t[117];let I;t[118]!==l||t[119]!==p||t[120]!==m||t[121]!==A||t[122]!==F?(I=(0,$.jsxs)(l,{className:p,children:[m,A,F]}),t[118]=l,t[119]=p,t[120]=m,t[121]=A,t[122]=F,t[123]=I):I=t[123];let L;t[124]!==d||t[125]!==h||t[126]!==I?(L=(0,$.jsxs)(d,{children:[h,I]}),t[124]=d,t[125]=h,t[126]=I,t[127]=L):L=t[127];let R;return t[128]!==f||t[129]!==g||t[130]!==_||t[131]!==L?(R=(0,$.jsx)(f,{open:g,onOpenChange:_,children:L}),t[128]=f,t[129]=g,t[130]=_,t[131]=L,t[132]=R):R=t[132],R}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function kt(e){return e.required}function At(e){return e.required}var jt=(0,Q.memo)(function(e){let t=(0,ft.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:s,addLabel:c,browseLabel:l,customLabel:u,serviceLabel:f,moreActionsLabel:p}=e,[_,y]=(0,Q.useState)(!1),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=v(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,q.transition),t[0]=b):b=t[0];let x=b,S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(_e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=S):S=t[1];let C;t[2]===c?C=t[3]:(C=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[2]=c,t[3]=C);let w;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(o,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=w):w=t[4];let E;t[5]!==c||t[6]!==C?(E=(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsxs)(T,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":c,children:[S,C,w]})}),t[5]=c,t[6]=C,t[7]=E):E=t[7];let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(qe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=D):D=t[8];let O;t[9]!==l||t[10]!==a?(O=(0,$.jsxs)(Be,{className:x,onSelect:a,children:[D,l]}),t[9]=l,t[10]=a,t[11]=O):O=t[11];let k;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(g,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=k):k=t[12];let A;t[13]!==u||t[14]!==s?(A=(0,$.jsxs)(Be,{className:x,onSelect:s,children:[k,u]}),t[13]=u,t[14]=s,t[15]=A):A=t[15];let j;t[16]!==O||t[17]!==A?(j=(0,$.jsx)(et,{children:(0,$.jsxs)(Ce,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[O,A]})}),t[16]=O,t[17]=A,t[18]=j):j=t[18];let M;t[19]!==j||t[20]!==E?(M=(0,$.jsxs)(Ee,{children:[E,j]}),t[19]=j,t[20]=E,t[21]=M):M=t[21];let N;t[22]===_?N=t[23]:(N=(0,$.jsx)(ut,{open:_,onOpenChange:y,hideTrigger:!0}),t[22]=_,t[23]=N);let P;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[24]=P):P=t[24];let F;t[25]===p?F=t[26]:(F=(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":p,title:p,children:P})}),t[25]=p,t[26]=F);let I;t[27]!==n||t[28]!==i||t[29]!==r?(I=n?(0,$.jsxs)(Be,{className:x,disabled:r,onSelect:n,children:[r?(0,$.jsx)(m,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(h,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=I):I=t[30];let L,R;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>y(!0),R=(0,$.jsx)(ae,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=L,t[32]=R):(L=t[31],R=t[32]);let z;t[33]===f?z=t[34]:(z=(0,$.jsxs)(Be,{className:x,onSelect:L,children:[R,f]}),t[33]=f,t[34]=z);let B;t[35]!==I||t[36]!==z?(B=(0,$.jsx)(et,{children:(0,$.jsxs)(Ce,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[I,z]})}),t[35]=I,t[36]=z,t[37]=B):B=t[37];let V;t[38]!==F||t[39]!==B?(V=(0,$.jsxs)(Ee,{children:[F,B]}),t[38]=F,t[39]=B,t[40]=V):V=t[40];let H;return t[41]!==M||t[42]!==N||t[43]!==V?(H=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[M,N,V]}),t[41]=M,t[42]=N,t[43]=V,t[44]=H):H=t[44],H});function Mt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Nt=/^([^:=]+)[:=](.*)$/;function Pt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return It(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Nt.exec(t);r&&n.push(Mt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Ft(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function It(e){if(!e||typeof e!=`object`)return[Mt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Mt(e),reference:t}:Mt(e,t==null?``:String(t)));return t.length>0?t:[Mt()]}function Lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Rt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function zt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Bt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=Rt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Ft(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=zt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Ft(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Vt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:It(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Ht(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Ut(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Wt(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Vt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ut(r.url),r})}function Gt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Kt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Lt(e)).map(([e,t])=>Vt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function qt(e){return Bt(e)}async function Jt(e,t){return(await S(y(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Yt(e,t,n,r){return(await S(y(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Bt(e)})})).payload}async function Xt(e,t){return(await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Zt(e){await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Qt(e,t=!1){let n=await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return D(),n.payload}async function $t(e){return(await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function en(e,t){return(await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function tn(e){await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function nn(e,t){await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function rn(e,t){return(await S(y(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function an(e){let t=await S(y(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function on(e){let t=await S(y(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return D(),t.payload}function sn(e){let t=(0,ft.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),b=(0,Q.useRef)(!1),x;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(x=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?rn(a,e.signal):Jt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=x):x=t[8];let S;t[9]!==a||t[10]!==v||t[11]!==n||t[12]!==o?(S=[n,a,v,o],t[9]=a,t[10]=v,t[11]=n,t[12]=o,t[13]=S):S=t[13],(0,Q.useEffect)(x,S);let C,w,E,D,O,k,A,j,M,P,F,I,L;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));E=st,k=!0,t[52]===s?A=t[53]:(A=e=>{e||s()},t[52]=s,t[53]=A),w=ge,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(de,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=O):O=t[54],C=me,t[55]===i?I=t[56]:(I=e=>{(b.current||i)&&e.preventDefault(),!b.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=I),L=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(H,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let v;t[66]===h?v=t[67]:(v=(0,$.jsx)(ee,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=v);let y;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>_(e.target.value),t[68]=y):y=t[68];let x;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(x=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:g,onChange:y,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=x):x=t[71];let S=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==v||t[74]!==x||t[75]!==S?(D=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,v,x,S]}),t[72]=p,t[73]=v,t[74]=x,t[75]=S,t[76]=D):D=t[76],j=`min-h-0 flex-1 overflow-y-auto p-5`,M=f,t[77]!==o.toolsTitle||t[78]!==u.length?(P=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=P):P=t[79],F=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(ln)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(T,{variant:`secondary`,onClick:()=>{b.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(T,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=C,t[37]=w,t[38]=E,t[39]=D,t[40]=O,t[41]=k,t[42]=A,t[43]=j,t[44]=M,t[45]=P,t[46]=F,t[47]=I,t[48]=L}else C=t[36],w=t[37],E=t[38],D=t[39],O=t[40],k=t[41],A=t[42],j=t[43],M=t[44],P=t[45],F=t[46],I=t[47],L=t[48];let R;t[80]!==j||t[81]!==M||t[82]!==P||t[83]!==F?(R=(0,$.jsx)(`div`,{className:j,"aria-busy":M,"aria-label":P,children:F}),t[80]=j,t[81]=M,t[82]=P,t[83]=F,t[84]=R):R=t[84];let z;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(z=()=>y(cn),t[85]=z):z=t[85];let B;t[86]!==f||t[87]!==o.refreshTools?(B=(0,$.jsx)(T,{variant:`secondary`,disabled:f,onClick:z,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=B):B=t[88];let V;t[89]!==s||t[90]!==o.toolsDialogClose?(V=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(T,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=V):V=t[91];let U;t[92]!==B||t[93]!==V?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[B,V]}),t[92]=B,t[93]=V,t[94]=U):U=t[94];let W;t[95]!==C||t[96]!==D||t[97]!==R||t[98]!==U||t[99]!==I||t[100]!==L?(W=(0,$.jsxs)(C,{onCloseAutoFocus:I,className:L,children:[D,R,U]}),t[95]=C,t[96]=D,t[97]=R,t[98]=U,t[99]=I,t[100]=L,t[101]=W):W=t[101];let G;t[102]!==w||t[103]!==O||t[104]!==W?(G=(0,$.jsxs)(w,{children:[O,W]}),t[102]=w,t[103]=O,t[104]=W,t[105]=G):G=t[105];let te;return t[106]!==E||t[107]!==k||t[108]!==A||t[109]!==G?(te=(0,$.jsx)(E,{open:k,onOpenChange:A,children:G}),t[106]=E,t[107]=k,t[108]=A,t[109]=G,t[110]=te):te=t[110],te}function cn(e){return e+1}function ln(e){return(0,$.jsx)(E,{className:`h-24 w-full`},e)}function un(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function dn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=x(e=>e.language),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),g=e.displayName||e.id,_=un(e),y=e.extra.enabled===!1,b=y?F:t?u:it,S=e.transport===`stdio`?De:j,C=y?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,w=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(S,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:g,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:w?r.customLastChecked.replace(`{{time}}`,w):void 0,"aria-label":w?`${C} · ${r.customLastChecked.replace(`{{time}}`,w)}`:C,className:v(`inline-flex shrink-0 items-center gap-1`,!y&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),C]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:_,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:_})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(T,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(T,{ref:l,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:y,onClick:()=>c(!0),children:n.viewTools}),(0,$.jsxs)(Ee,{children:[(0,$.jsx)(Ke,{asChild:!0,children:(0,$.jsx)(T,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,g),title:r.customManage.replace(`{{name}}`,g),children:(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(et,{children:(0,$.jsx)(Ce,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(Be,{onSelect:()=>p(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),m?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:m}):null,s?(0,$.jsx)(sn,{serverId:e.id,displayName:e.displayName,returnFocusTo:l.current,t:n,onClose:()=>c(!1),onConfigure:()=>{c(!1),i()}}):null,(0,$.jsx)(xe,{open:f,title:r.removeConfirmTitle.replace(`{{name}}`,g),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>p(!1),onConfirm:()=>{p(!1),h(``),a().catch(()=>h(n.setupRemoveFailed))}})]})}function fn(e){let t=(0,ft.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(T,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(dn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function pn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function mn(e){let t=(0,ft.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,d=n.activationEligible===!1,f=n.authorizationStatus===`required`,p;t[4]!==d||t[5]!==n.readiness||t[6]!==f||t[7]!==l||t[8]!==c?(p=l?c(`准备未完成`,`Setup incomplete`):d?c(`已停用`,`Disabled`):f?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=d,t[5]=n.readiness,t[6]=f,t[7]=l,t[8]=c,t[9]=p):p=t[9];let m=p,h;t[10]!==d||t[11]!==f||t[12]!==l||t[13]!==c?(h=l?c(`继续安装`,`Continue setup`):!d&&f?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=d,t[11]=f,t[12]=l,t[13]=c,t[14]=h):h=t[14];let g=h,_;t[15]===n.setup?.authorizations?_=t[16]:(_=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=_);let y=_,b=y.length===1?y[0].title:n.name,x=l||!d&&(f||n.readiness===`blocked`||n.readiness===`degraded`),S=l?it:d?F:x?Ie:u,C=x&&`border-amber-500/25`,w;t[17]===C?w=t[18]:(w=v(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,C),t[17]=C,t[18]=w);let T=n.branding?.iconUrl,E;t[19]===T?E=t[20]:(E=(0,$.jsx)(se,{iconUrl:T,fallback:U,className:`size-9`}),t[19]=T,t[20]=E);let D;t[21]===b?D=t[22]:(D=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:b,children:b}),t[21]=b,t[22]=D);let O=x?`text-amber-700 dark:text-amber-300`:d?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,k;t[23]===O?k=t[24]:(k=v(`mt-1 inline-flex items-center gap-1 text-[11px]`,O),t[23]=O,t[24]=k);let A;t[25]===S?A=t[26]:(A=(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t[25]=S,t[26]=A);let j;t[27]!==m||t[28]!==k||t[29]!==A?(j=(0,$.jsxs)(`span`,{className:k,children:[A,m]}),t[27]=m,t[28]=k,t[29]=A,t[30]=j):j=t[30];let M;t[31]!==D||t[32]!==j?(M=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[D,j]}),t[31]=D,t[32]=j,t[33]=M):M=t[33];let N;t[34]!==M||t[35]!==E?(N=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[E,M]}),t[34]=M,t[35]=E,t[36]=N):N=t[36];let P=n.name,I;t[37]===c?I=t[38]:(I=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=I);let L;t[39]!==n.name||t[40]!==I?(L=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:P,children:[I,` · `,n.name]}),t[39]=n.name,t[40]=I,t[41]=L):L=t[41];let R=x?`text-accent-fg`:`text-fg-muted`,z;t[42]===R?z=t[43]:(z=v(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,R),t[42]=R,t[43]=z);let B;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ie,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=B):B=t[44];let V;t[45]!==g||t[46]!==z?(V=(0,$.jsxs)(`span`,{className:z,children:[g,B]}),t[45]=g,t[46]=z,t[47]=V):V=t[47];let H;return t[48]!==i||t[49]!==N||t[50]!==L||t[51]!==V||t[52]!==w?(H=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:w,children:[N,L,V]}),t[48]=i,t[49]=N,t[50]=L,t[51]=V,t[52]=w,t[53]=H):H=t[53],H}function hn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function gn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?hn(t)-hn(e):e.isCurrentAuthorization?-1:1}function _n(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(gn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>gn(e.primary,t.primary))}var vn=v(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function yn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function bn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function xn(e,t,n){return e.status===`connected`?Ye(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function Sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function Cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function wn({instance:e,t,onChanged:n}){let r=yn(e),i=x(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[l,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[y,b]=(0,Q.useState)([]),[S,C]=(0,Q.useState)(null),[w,D]=(0,Q.useState)(null),[O,j]=(0,Q.useState)([]),[N,F]=(0,Q.useState)({}),[R,z]=(0,Q.useState)(`read`),[V,H]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(null),[ee,G]=(0,Q.useState)(!1),[ne,K]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(null),[q,J]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),X=(0,Q.useRef)(0),Z=(0,Q.useRef)(0),ue=(0,Q.useMemo)(()=>_n(a),[a]),de=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),fe=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;H(!0),W(null);let t=++X.current;try{let e=(await Promise.allSettled([de(je()).then(e=>{t===X.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),J(!0))}),de(Te(r)).then(e=>{t===X.current&&z(e)}),de(Qe(r)).then(e=>{t===X.current&&(_(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===X.current&&e?.status===`rejected`&&W(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===X.current&&H(!1)}},[e.materialized,r,de]);(0,Q.useEffect)(()=>(fe(),()=>{X.current++}),[fe]);let pe=(0,Q.useCallback)(async()=>{if(!r)return;let e=++Z.current;ce(!0),G(!1);let t=t=>n=>{e===Z.current&&t(n)},n=await Promise.allSettled([de(Je(r)).then(t(d)),de(He(20)).then(t(e=>p(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),de(tt(r)).then(t(D)),de(Ge(r)).then(t(C))]);e===Z.current&&(G(n.some(e=>e.status===`rejected`)),ce(!1))},[r,de]);(0,Q.useEffect)(()=>(ae&&pe(),()=>{Z.current++}),[ae,pe]),(0,Q.useEffect)(()=>{let e=!1,t=_n(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return de(Ne()).then(t=>{e||j(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await de(Oe(e.accountId))])).then(t=>{e||F(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,de]);let me=(0,Q.useCallback)(async i=>{if(!r)return;let a=k()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),H(!0),W(null);try{if(!k()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await P(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(k()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await Le(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),fe()])}catch(e){W(B(e,t))}finally{a?.close(),H(!1)}},[e.connectorId,fe,n,t,r]),he=(0,Q.useCallback)(async t=>{H(!0),W(null);try{await ze(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),fe()])}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}},[e.config,e.instanceId,fe,n]),ge=async e=>{let t=k()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),W(null);try{let n=await Se(e.id);if(n.authorizationUrl)if(k())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await fe()}catch(e){t?.close(),W(e instanceof Error?e.message:String(e))}},_e=(0,Q.useCallback)(async e=>{if(r){z(e),W(null);try{await at(r,e)}catch(e){W(e instanceof Error?e.message:String(e)),await fe()}}},[fe,r]),ve=(0,Q.useCallback)(async e=>{if(r){W(null);try{_(await Y(r,e))}catch(e){W(e instanceof Error?e.message:String(e))}}},[r]),ye=(0,Q.useCallback)(e=>{if(!g)return;let t=g.allowedAgentIds.includes(e);t&&g.allowedAgentIds.length===1||ve({allowedAgentIds:t?g.allowedAgentIds.filter(t=>t!==e):[...g.allowedAgentIds,e]})},[ve,g]),be=(0,Q.useCallback)(async e=>{H(!0),W(null);try{await e(),await fe()}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}},[fe]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let Ce=ue.filter(e=>e.primary.status===`active`).length,we=Ce>0?t.composioAddAccount:t.composioConnectAccount,Ee=q&&Ce>0,De=w?.requiresCustomAuthConfig===!0,ke=w?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:v(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Ee?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Ee?(0,$.jsx)(u,{className:`size-3.5`}):(0,$.jsx)(Ie,{className:`size-3.5`}),Ee?t.connectionReady:q||U?t.connectionNeedsSetup:t.connectionChecking]}),q&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Ye(t.composioAccountCount,{count:String(ue.length)})})]}),(0,$.jsxs)(T,{variant:`primary`,className:`shrink-0`,disabled:V,onClick:()=>void me(),children:[V?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(te,{className:`size-4`}),we]})]}),U?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:U}),(0,$.jsx)(T,{variant:`secondary`,disabled:V,onClick:()=>void fe(),children:t.composioRetry})]}):null,S&&!Ee?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:xn(S,Ce,t)}),S.recovery===`none`?null:(0,$.jsx)(T,{variant:`secondary`,disabled:V,onClick:()=>void(S.recovery===`retry`?fe():me()),children:S.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,De&&ke.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,g?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:R===`read`?t.composioAccessReadHint:R===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:R,onChange:e=>void _e(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),R===`admin`?(0,$.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(s,{value:g.confirmationPolicy,onChange:e=>void ve({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),g.confirmationPolicy===`never`?(0,$.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void ve({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),y.map(e=>(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>ye(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g.selectedAccountIds===null,disabled:V,onChange:e=>void ve({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),g.selectedAccountIds!==null&&ue.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:V,checked:g.selectedAccountIds.includes(e.accountId),onChange:t=>void ve({selectedAccountIds:t.currentTarget.checked?[...g.selectedAccountIds,e.accountId]:g.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),g.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),q&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Ye(t.composioAccountCount,{count:String(ue.length)})})]}),(0,$.jsxs)(T,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:V,onClick:()=>void fe(),children:[(0,$.jsx)(h,{className:v(`size-3.5`,V&&`animate-spin`)}),t.refresh]})]}),ue.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ue.map(e=>{let r=e.primary,a=O.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?N[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:v(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:Sn(r.status,t)}),a?(0,$.jsx)(`p`,{className:v(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:Ye(t.connectorLearningStatus,{status:Cn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(T,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void ge(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(T,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:V,onClick:()=>ie(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(T,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:V,onClick:()=>void me(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(T,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:V,onClick:()=>void be(()=>L(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(T,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:V,onClick:()=>void be(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await le(r.accountId),await n?.()}),children:[(0,$.jsx)(h,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:V,checked:r.allowedAgentIds==null,onChange:e=>void be(()=>L(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&y.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:V,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;be(()=>L(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:V,onChange:e=>void be(()=>M(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:V,onChange:e=>void be(()=>M(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:v(vn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&be(()=>I(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(T,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:V,onClick:()=>K(e.id),children:(0,$.jsx)(Ze,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(T,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:V,onClick:()=>void be(()=>Me(r.id)),children:(0,$.jsx)(h,{className:`size-4`})})})]})]})]},e.key)})}):V&&!q?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(E,{className:`h-16 w-full`}),(0,$.jsx)(E,{className:`h-16 w-full`})]}):q?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>oe(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[se?(0,$.jsx)(E,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,ee?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(T,{variant:`ghost`,disabled:se,onClick:()=>void pe(),children:t.composioRetry})]}):null,w?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:De?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:V,onChange:e=>void he(e.currentTarget.value),children:[De?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),De&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,ke.map(e=>(0,$.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length?l.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[bn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:f.length?f.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(xe,{open:re!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=re;ie(null),e&&be(()=>A(e))},onCancel:()=>ie(null)}),(0,$.jsx)(xe,{open:ne!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=ne;K(null),e&&be(()=>ot(e))},onCancel:()=>K(null)})]})}var Tn=v(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function En(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Dn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function On({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,g]=(0,Q.useState)(null),[_,y]=(0,Q.useState)(()=>En(t,e)),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),D=t?.setup.config??[],O=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&D.length>0&&(t?.setup.secrets??[]).length===0,k=e.materialized.type===`mcp`,A=e.materialized.type===`composio`,j=e.materialized.type===`memorySource`,M=t?K(t,i):null,P=(0,Q.useCallback)(async()=>{C(!0),x(null);try{let t=await Z(e.instanceId);E(t),t.ok||x(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){x(e instanceof Error?e.message:String(e))}finally{C(!1)}},[e.instanceId,r,i.healthStatusLabels]),F=(0,Q.useCallback)(async()=>{o(!0),x(null);try{await nt(e.instanceId),await r(),n()}catch(e){x(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),I=(0,Q.useCallback)(async()=>{if(!(!t||!O)){u(!0),x(null);try{let n={};for(let e of t.setup.config??[]){let t=Dn(e.type,_[e.key]??``);t!==void 0&&(n[e.key]=t)}await ze(e.instanceId,{config:n}),await r()}catch(e){x(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[_,t,e.instanceId,r,O]),L=(0,Q.useCallback)(async()=>{f(!0),g(null),x(null);try{g((await rt(e.connectorId)).recordIds.length),await r()}catch(e){x(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(st,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(ge,{children:[(0,$.jsx)(de,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(me,{className:v(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,A?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(he,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(H,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(ee,{className:`mt-1 text-sm text-fg-muted`,children:M??(e.materialized.type===`mcp`?Ye(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Ye(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(N,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:v(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,q.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(be,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[b?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b}):null,k?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:w?.ok?Ye(i.toolsAvailable,{count:String(w.toolCount)}):w?i.healthStatusLabels[w.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(T,{variant:`secondary`,"aria-busy":S,disabled:S||!e.enabled,onClick:()=>void P(),children:[S?(0,$.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),O?D.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>y(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,A?(0,$.jsx)(wn,{instance:e,t:i,onChanged:r}):null,j?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),M?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:M}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:Ye(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(T,{disabled:d,onClick:()=>void L(),children:[d?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(Ae,{className:`size-4`}),i.composioSyncNow]})]}),O?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:D.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:Tn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>y(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!k&&!A&&!j?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(T,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(Ze,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(T,{variant:`secondary`,onClick:n,children:i.modalClose}),(k||j)&&O?(0,$.jsxs)(T,{variant:`primary`,disabled:l,onClick:()=>void I(),children:[l?(0,$.jsx)(m,{className:`size-4 animate-spin`}):(0,$.jsx)(oe,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(xe,{open:s,title:Ye(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),F()},onCancel:()=>{a||c(!1)}})]})}function kn(e){let t=(0,ft.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(ne,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(On,{...e}),t[0]=e,t[1]=n),n}function An(e){let t=(0,ft.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=Ct(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,d;t[3]!==r||t[4]!==o?(d=r?K(r,o):null,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f=d,p,m,h,g,_,y,b,x,S;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){p=l===`ready`?{label:o.connectionReady,Icon:u,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:Ie,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:it,className:`text-fg-muted`},S=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(m=v(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,q.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=m):m=t[25],t[26]!==n||t[27]!==a?(h=()=>a(n),t[26]=n,t[27]=a,t[28]=h):h=t[28],b=`flex w-full min-w-0 items-start gap-3`,t[29]===r?x=t[30]:(x=(0,$.jsx)(he,{connector:r,size:`sm`}),t[29]=r,t[30]=x),_=`min-w-0 flex-1`,t[31]===n.displayName?y=t[32]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=y),g=v(`mt-1 inline-flex items-center gap-1 text-[11px]`,p.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else p=t[14],m=t[15],h=t[16],g=t[17],_=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[33]===p.Icon?C=t[34]:(C=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=p.Icon,t[34]=C);let w;t[35]!==p.label||t[36]!==C||t[37]!==g?(w=(0,$.jsxs)(`span`,{className:g,children:[C,p.label]}),t[35]=p.label,t[36]=C,t[37]=g,t[38]=w):w=t[38];let T;t[39]!==w||t[40]!==_||t[41]!==y?(T=(0,$.jsxs)(`div`,{className:_,children:[y,w]}),t[39]=w,t[40]=_,t[41]=y,t[42]=T):T=t[42];let E;t[43]!==T||t[44]!==b||t[45]!==x?(E=(0,$.jsxs)(`div`,{className:b,children:[x,T]}),t[43]=T,t[44]=b,t[45]=x,t[46]=E):E=t[46];let D;t[47]===f?D=t[48]:(D=f?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:f,children:f}):null,t[47]=f,t[48]=D);let O;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ie,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=O):O=t[49];let k;t[50]===o.installedDetails?k=t[51]:(k=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,O]}),t[50]=o.installedDetails,t[51]=k);let A;return t[52]!==m||t[53]!==h||t[54]!==E||t[55]!==D||t[56]!==k||t[57]!==S?(A=(0,$.jsxs)(`button`,{type:S,className:m,onClick:h,children:[E,D,k]}),t[52]=m,t[53]=h,t[54]=E,t[55]=D,t[56]=k,t[57]=S,t[58]=A):A=t[58],A}function jn(e,t){return Gt()}function Mn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Mt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Nn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Mt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Mt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Pn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Fn(){return v(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z)}function In({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:m=`Show value`,hideValueLabel:h=`Hide value`,allowPaste:g=!0}){let[_,y]=(0,Q.useState)(new Set),[b,x]=(0,Q.useState)(!1),S=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},w=()=>{d([...u,Mt()])},E=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Mt()])},D=async()=>{try{let e=await C();if(!e){x(!0);return}let t=Pt(e);if(!t?.length){x(!0);return}d(t)}catch{x(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),g?(0,$.jsxs)(T,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void D(),children:[(0,$.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:v(Fn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>S(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:v(Fn(),`min-w-0 font-mono text-xs`),type:_.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>S(t,{value:e.target.value})}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":_.has(e.clientKey)?h:m,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:_.has(e.clientKey)?(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>E(t),"aria-label":r,children:(0,$.jsx)(Ze,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(xe,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>x(!1),onCancel:()=>x(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:v(`self-start text-sm text-accent hover:underline`,q.press),onClick:w,children:[`+ `,n]})]})}var Ln=v(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,z);function Rn(e){let t=(0,ft.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=v(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let m;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(m=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=m):m=t[7];let h;t[8]!==i||t[9]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,m]}),t[8]=i,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>l(zn),t[11]=g):g=t[11];let _;t[12]===c?_=t[13]:(_=c?(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=_);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==_||t[15]!==y?(b=(0,$.jsxs)(T,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:g,children:[_,y]}),t[14]=_,t[15]=y,t[16]=b):b=t[16];let x;return t[17]!==b||t[18]!==h?(x=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[h,b]}),t[17]=b,t[18]=h,t[19]=x):x=t[19],x}function zn(e){return!e}function Bn(e){let t=(0,ft.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(In,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function Vn(e){let t=(0,ft.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,l=i.setupAuthLabel,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=v(Ln,`mt-1.5`),t[0]=u):u=t[0];let d=n.mode,f;t[1]===r?f=t[2]:(f=e=>r({mode:e.target.value}),t[1]=r,t[2]=f);let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=p):p=t[3];let m;t[4]===i.setupAuthModes?m=t[5]:(m=p.map(e=>(0,$.jsx)(c,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=m);let h;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(h=a||n.mode===`existing`?(0,$.jsx)(c,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=h):h=t[9];let g;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==f||t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(s,{"aria-label":l,className:u,value:d,onChange:f,children:[m,h]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=f,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]!==i.setupAuthLabel||t[17]!==g?(_=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,g]}),t[16]=i.setupAuthLabel,t[17]=g,t[18]=_):_=t[18];let y;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(y=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=y):y=t[21];let b;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(b=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=b):b=t[24];let x;t[25]!==n.mode||t[26]!==i.setupExistingHint?(x=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=x):x=t[27];let S;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(S=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=S):S=t[32];let C;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(C=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:v(Ln,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(Rn,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=C):C=t[38];let w;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(w=n.mode===`headers`?(0,$.jsx)(Bn,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=w):w=t[43];let T;return t[44]!==_||t[45]!==y||t[46]!==b||t[47]!==x||t[48]!==S||t[49]!==C||t[50]!==w?(T=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[_,y,b,x,S,C,w]}),t[44]=_,t[45]=y,t[46]=b,t[47]=x,t[48]=S,t[49]=C,t[50]=w,t[51]=T):T=t[51],T}function Hn(e){let t=(0,ft.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Un({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>It(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Rt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Hn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Ln,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Ln,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(Ze,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(T,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Bn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Ft(e)??{})})}})]})}function Wn(e){let t=(0,ft.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:l}=e,u=a===void 0?`all`:a,d=o===void 0?!1:o,f=l===void 0?!1:l,p=u!==`advanced`,m=u!==`basic`,h;t[0]!==p||t[1]!==i||t[2]!==n||t[3]!==r?(h=p?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Ln,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Un,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Hn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Ln,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Hn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=p,t[1]=i,t[2]=n,t[3]=r,t[4]=h):h=t[4];let g;t[5]!==m||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==d||t[10]!==r?(g=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Ln,readOnly:f,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Hn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Ln,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&d?(0,$.jsx)(Hn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Hn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(s,{"aria-label":r.exposureLabel,className:Ln,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(c,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Hn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(dt,{allowEmpty:!0,type:`number`,min:1,className:Ln,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=m,t[6]=f,t[7]=i,t[8]=n,t[9]=d,t[10]=r,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function Gn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Kn(e,t){return JSON.stringify({id:e.id,config:qt(Nn(e,t))})}function qn(e,t){try{return Kn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Jn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,l]=(0,Q.useState)(()=>Mn(e.initialRow)),[d,p]=(0,Q.useState)(`idle`),[h,g]=(0,Q.useState)(``),[_,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(),[S,C]=(0,Q.useState)(),[w,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)([]),[L,R]=(0,Q.useState)(`0`),[z,B]=(0,Q.useState)(0),[U,W]=(0,Q.useState)(``),[G,te]=(0,Q.useState)(!1),[ne,K]=(0,Q.useState)(!1),re=e.mode===`edit`,[ie,q]=(0,Q.useState)(``),J=(0,Q.useRef)(void 0),[ae]=(0,Q.useState)(()=>qn(e.initialRow,Mn(e.initialRow))),Y=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),oe=(0,Q.useRef)(void 0),se=(0,Q.useRef)(void 0),ce=(0,Q.useRef)(void 0),X=(0,Q.useRef)(null),le=(0,Q.useRef)(``),Z=(0,Q.useRef)(!0),ue=(0,Q.useRef)(null),fe=(0,Q.useRef)(null),pe=(0,Q.useRef)(null),he=(0,Q.useRef)(null),_e=(0,Q.useRef)(e.onSaved);_e.current=e.onSaved;let ve=w?.state===`starting`||w?.state===`authorizing`,ye=d!==`idle`||ve,Se=ae!==qn(i,o),Ce=i.extra.enabled===!1,we=!_&&(Se||!!j.trim());(0,Q.useEffect)(()=>(Z.current=!0,()=>{Z.current=!1,oe.current?.abort(),X.current?.close(),J.current&&Zt(J.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!we)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[we]),(0,Q.useEffect)(()=>{if(!b)return;let e=pe.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??he.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!w||!ve)return;let e=new AbortController;se.current=e;let n;async function r(){try{let n=await en(J.current,e.signal);if(e.signal.aborted||(E(n),n.authorizationUrl&&le.current!==n.authorizationUrl&&(le.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&g(t.oauthOpenFailed):X.current&&!X.current.closed&&X.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){ce.current=void 0,X.current?.close(),C({state:`connected`,toolCount:n.toolCount}),g(``);return}if(n.state===`error`||n.state===`cancelled`){ce.current=void 0,X.current?.close(),g(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&O(!0);return}}catch{if(e.signal.aborted)return;Te(),X.current?.close(),g(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[w?.id,ve,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Te(){oe.current?.abort(),se.current?.abort(),J.current&&Zt(J.current).catch(()=>{}),J.current=void 0,q(``),te(!1),C(void 0),E(void 0),g(``),x(void 0)}function Ee(e){a(t=>({...t,...e})),Te()}function De(e){l(t=>({...t,...e})),Te()}function Oe(){d===`saving`||ve||(d===`checking`&&(Te(),p(`idle`)),we?K(!0):e.onClose())}function ke(){try{I(Wt(j)),R(`0`),P(``)}catch{P(t.setupImportError),I([])}}function Ae(){let t=F[Number(L)];if(!t)return;let n={...t,id:Y.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...Y.current?{enabled:i.extra.enabled}:{}}};a(n),l(Mn(n)),Te(),B(e=>e+1),A(!1),M(``),I([])}function je(e){function n(e,t){return x({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ut(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(o.mode===`bearer`&&!o.token.trim().replace(/^Bearer\s*/i,``)||o.mode===`apiKey`&&(!o.apiKey.trim()||!o.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Pn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(o.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(o.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{qt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Me(){g(``),p(`checking`),le.current=``,window.electronAPI?.shell?.openExternalUrl||(X.current=window.open(`about:blank`,`_blank`),X.current&&(X.current.opener=null));try{let e=await $t(J.current);if(!Z.current){X.current?.close(),J.current&&Zt(J.current).catch(()=>{});return}ce.current=e.id,E(e)}catch{X.current?.close(),Z.current&&g(t.setupAuthFailed)}finally{Z.current&&p(`idle`)}}async function Ne(){let r=Nn(i,o);if(!je(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==Y.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=Y.current||r.id.trim()||Ht(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){x({field:`advanced`,message:n.duplicateServerId});return}Te(),p(`checking`);let l=new AbortController;oe.current=l;try{let n=await Yt(r,Y.current||void 0,e.initialRow.extra,l.signal);if(!Z.current||l.signal.aborted){Zt(n.id).catch(()=>{});return}J.current=n.id,a(r),q(qn(r,o));let i=await Xt(n.id,l.signal);if(!Z.current||l.signal.aborted)return;C(i),i.state===`error`&&g(Gn(i,t))}catch(e){Z.current&&!l.signal.aborted&&g(e.status===409?t.setupConflict:Gn(e,t))}finally{Z.current&&oe.current===l&&p(`idle`)}}async function Pe(n=!1){if(!(!J.current||S?.state!==`connected`||ie!==qn(i,o))){p(`saving`),g(``);try{let t=await Qt(J.current,n);J.current=void 0,await _e.current().catch(()=>{}),t?.reloadRequired?y(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Te(),g(t.setupConflict)):g(t.setupSaveFailed)}finally{Z.current&&p(`idle`)}}}async function Fe(){se.current?.abort();let e=J.current;ce.current=void 0,E(void 0),X.current?.close(),g(t.setupCancelled),p(`checking`);try{e&&await tn(e)}catch{Z.current&&(Te(),g(t.setupCancelled))}finally{Z.current&&p(`idle`)}}async function Ie(){w?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(w.authorizationUrl)).ok||g(t.oauthOpenFailed):window.open(w.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Le(){if(w)try{await nn(J.current,U),W(``),g(``)}catch{g(t.setupRedirectInvalid)}}let Re=!!J.current&&ie===qn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&S?.state===`oauth_required`)&&S?.state!==`connected`,ze=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),Be=F[Number(L)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(st,{open:e.open,onOpenChange:e=>{e||Oe()},children:(0,$.jsxs)(ge,{children:[(0,$.jsx)(de,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(me,{ref:ue,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),ue.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(H,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(ee,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:d===`saving`||ve,onClick:Oe,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(be,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[k?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(T,{variant:`ghost`,onClick:()=>A(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:v(Ln,`mt-1.5 min-h-40 font-mono text-xs`),value:j,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{M(e.target.value),I([]),P(``)}})]}),(0,$.jsx)(T,{variant:`secondary`,disabled:!j.trim(),onClick:ke,children:t.setupImportPreview}),N?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:N}):null,Be?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(s,{"aria-label":t.setupImportChoose,className:v(Ln,`mt-1.5`),value:L,onChange:e=>R(e.target.value),children:F.map((e,t)=>(0,$.jsx)(c,{value:String(t),children:e.displayName||e.id||un(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Be.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,un(Be)]})]}):null]}):(0,$.jsxs)(`form`,{ref:pe,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Ut(i.url)}catch{x({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Ne()},children:[(0,$.jsxs)(`fieldset`,{disabled:ye||_,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(V,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(T,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>Ee({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(T,{type:`button`,variant:`ghost`,onClick:()=>A(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Wn,{row:i,t,variant:`basic`,onUpdate:Ee},`${i.transport}-${z}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Vn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:De,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:he,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:D,onToggle:e=>O(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Wn,{row:i,t,variant:`advanced`,idReadOnly:re,showOAuth:o.mode===`oauth`,onUpdate:Ee}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(Bn,{additional:!0,headers:o.additionalHeaders,onChange:e=>De({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:ze?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!k&&!_?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[d===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),d===`saving`?t.setupSaving:t.setupChecking]}),d===`idle`&&re&&!Se&&!S&&!h&&!ve?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Ce?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,S?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(u,{className:`size-4 shrink-0`,"aria-hidden":!0}),S.toolCount?t.setupConnected.replace(`{{count}}`,String(S.toolCount)):t.setupZeroTools]}),(0,$.jsx)(T,{ref:fe,variant:`secondary`,onClick:()=>te(!0),children:t.viewTools})]}):null,S?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,S?.state===`oauth_required`&&!ve?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,ve?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(m,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[w?.authorizationUrl?(0,$.jsxs)(T,{variant:`secondary`,onClick:()=>void Ie(),children:[(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(T,{variant:`ghost`,onClick:()=>void Fe(),children:t.setupCancelAuth})]}),w?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Ln,value:U,onChange:e=>W(e.target.value)})]}),(0,$.jsx)(T,{className:`mt-2`,disabled:!U.trim(),onClick:()=>void Le(),children:t.setupContinue})]}):null]}):null,h?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:h}),h!==t.setupSaveFailed&&d!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(T,{variant:`secondary`,disabled:d===`saving`||ve,onClick:Oe,children:re||_?t.setupClose:n.modalCancel}),_?null:k?(0,$.jsx)(T,{variant:`primary`,disabled:!Be,onClick:Ae,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{variant:S?.state===`connected`?`secondary`:`primary`,disabled:ye,onClick:()=>Re?void Me():void Ne(),children:Re?t.setupSignIn:t.setupTestConnection}),S?.state===`connected`&&ie===qn(i,o)?(0,$.jsxs)($.Fragment,{children:[Ce?(0,$.jsx)(T,{variant:`secondary`,disabled:ye,onClick:()=>void Pe(!0),children:t.setupEnableSave}):null,(0,$.jsx)(T,{variant:`primary`,disabled:ye,"aria-busy":ye,onClick:()=>void Pe(),children:re?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(xe,{open:ne,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>K(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),G?(0,$.jsx)(sn,{draftId:J.current,serverId:i.id,displayName:i.displayName,returnFocusTo:fe.current,t,onClose:()=>te(!1)}):null]})}var Yn=`recommended`,Xn=`builtin`,Zn=`composio`,Qn=`xopc-store`;function $n(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Yn:Xn}function er(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function tr(e){return G(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function nr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function rr({embedded:e=!1,onHeaderActionChange:t}){let n=Ue().filter(pn),r=x(e=>e.language),o=_(r),s=o.connectorsSettings,c=o.mcpSettings,u=b(e=>e.conversationId),d=!!u,f=a(),[p,h]=i(),g=p.get(`understanding`)===`1`,y=nr(p.get(`returnTo`)),S=!!p.get(`returnTo`)&&!g,C=p.get(`tab`),[E,D]=(0,Q.useState)(!g&&C===`connected`?`connected`:`discover`),{data:k}=w(d&&E===`discover`&&!g?[`service-recommendations`,r]:null,()=>Re(r),{revalidateOnFocus:!1}),A=(0,Q.useMemo)(()=>new Set(k?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>R(e.id))??[]),[k]),j=(0,Q.useRef)(!1),[M,N]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(1),[H,U]=(0,Q.useState)(void 0),[ee,G]=(0,Q.useState)(``),[te,ne]=(0,Q.useState)(g||S?p.get(`connector`)??``:``),[K,ie]=(0,Q.useState)($n(g?`understanding`:`default`,r)),[q,ae]=(0,Q.useState)(`name`),[Y,oe]=(0,Q.useState)(g?`understand`:`all`),[se,ce]=(0,Q.useState)(null),[le,Z]=(0,Q.useState)(null),[de,me]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),[_e,be]=(0,Q.useState)(null),[xe,Se]=(0,Q.useState)(null),{data:Ce,mutate:Te}=O(d),Ee=Ce?.payload?.config,De=(0,Q.useMemo)(()=>Ee===void 0?null:Kt(Ee),[Ee]),Oe=De?.servers??[],Ae=M.instances.length+Oe.length+n.length,[je,Me]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Me({}),!d||!Ee)return;let e=new AbortController;return an(e.signal).then(t=>{e.signal.aborted||Me(t)}).catch(()=>{}),()=>e.abort()},[d,Ee]);let Ne=(0,Q.useCallback)(async()=>{if(!u){N({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}N(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([$e(),We()]);N(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){N({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[u]);(0,Q.useEffect)(()=>{Ne()},[Ne]),(0,Q.useEffect)(()=>{j.current||M.loading||d&&!De||(D(g?`discover`:Ae>0?`connected`:`discover`),j.current=!0)},[d,Ae,De,g,M.loading]),(0,Q.useEffect)(()=>{ie(e=>e===`builtin`||e===`recommended`?$n(g?`understanding`:`default`,r):e)},[r,g]);let Fe=(0,Q.useCallback)(e=>{j.current=!0,D(e)},[]),Ie=(0,Q.useMemo)(()=>[{id:Zn,displayName:s.composioSourceName},{id:Qn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Le=(0,Q.useCallback)(async e=>{if(!d||K===`builtin`||K===`recommended`){N(e=>({...e,registryCatalog:[]})),B(1),U(void 0);return}let t=te.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=K===`all`?Ie:Ie.filter(e=>e.id===K);if(a.length!==0){F(!0),i?N(e=>({...e,error:null})):(B(1),U(void 0),N(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await ke({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await Xe({q:t||void 0,page:n,pageSize:24,sort:q===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=er(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=tr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));B(n),U(s),N(e=>({...e,registryCatalog:i?tr([...e.registryCatalog,...o]):o}))}catch(e){N(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{F(!1)}}},[q,te,K,d,Ie,r]);(0,Q.useEffect)(()=>{if(E!==`discover`||M.loading)return;if(K===`builtin`||K===`recommended`){N(e=>({...e,registryCatalog:[]})),B(1),U(void 0);return}let e=window.setTimeout(()=>{Le()},te.trim()?350:0);return()=>window.clearTimeout(e)},[te,K,Le,M.loading,E]);let ze=(0,Q.useMemo)(()=>new Set(M.instances.map(e=>e.connectorId)),[M.instances]),Be=(0,Q.useMemo)(()=>new Map([...M.catalog,...M.registryCatalog].map(e=>[e.id,e])),[M.catalog,M.registryCatalog]);(0,Q.useEffect)(()=>{if(M.loading)return;let e=p.get(`connector`),t=p.get(`instance`);if(!e&&!t)return;let n=M.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)j.current=!0,G(``),me(n.instanceId),ge(n),D(`connected`);else if(e){let t=Be.get(e);if(!t)return;j.current=!0,ie($n(g?`understanding`:`default`,r)),ne(``),Z(t),D(`discover`)}let i=new URLSearchParams(p);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),h(i,{replace:!0})},[Be,g,r,p,h,M.instances,M.loading]);let Ve=(0,Q.useCallback)(async e=>{L(!0),N(e=>({...e,error:null}));try{let t=await Pe(e);ce(ye(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){N(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{L(!1)}},[]);(0,Q.useEffect)(()=>{let e=p.get(`storeConnector`);if(!d||!e)return;let t=new URLSearchParams(p);t.delete(`storeConnector`),h(t,{replace:!0}),Ve(e)},[d,p,h,Ve]);let He=(0,Q.useMemo)(()=>new Set(M.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[M.instances]),Ge=(0,Q.useCallback)(async e=>{let t=await on(e);await Te(),await Ne(),t.reloadRequired&&N(e=>({...e,error:c.setupReloadRequired}))},[Ne,Te,c.setupReloadRequired]),Ke=(0,Q.useCallback)(()=>{Se({mode:`add`,row:jn(Oe,He)})},[Oe,He]),qe=we(e=>e.setPageHeader),Je=we(e=>e.clearPageHeader),Ye=(0,Q.useMemo)(()=>({searchLabel:E===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(ct,{value:E===`connected`?ee:te,onChange:E===`connected`?G:ne,placeholder:E===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(jt,{onRefresh:E===`connected`&&d?Ne:void 0,refreshing:M.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Fe(`discover`),onAddCustomServer:Ke,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[ee,s,te,d,r,Ne,o.capabilitiesHub.moreActions,Ke,Fe,M.loading,E]);(0,Q.useLayoutEffect)(()=>e?(t?.(Ye),()=>t?.(null)):(qe({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(lt,{contribution:Ye})}),()=>Je()),[Je,s.title,e,Ye,t,qe]);let Ze=(0,Q.useMemo)(()=>M.instances.map(e=>({instance:e,value:Ct(e,Be.get(e.connectorId))})),[Be,M.instances]),Qe=(0,Q.useMemo)(()=>new Map(Ze.map(({instance:e,value:t})=>[e.instanceId,t])),[Ze]),et=(0,Q.useMemo)(()=>M.instances.filter(e=>W(e,ee)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Qe.get(e.instanceId)?.state??`checking`,i=Qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[ee,Qe,M.instances]),tt=(0,Q.useMemo)(()=>et.filter(e=>Qe.get(e.instanceId)?.state===`needs_setup`),[Qe,et]),nt=(0,Q.useMemo)(()=>et.filter(e=>Qe.get(e.instanceId)?.state!==`needs_setup`),[Qe,et]),rt=(0,Q.useMemo)(()=>Oe.filter(e=>fe(e,ee)),[ee,Oe]),it=(0,Q.useMemo)(()=>{let e=ee.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[ee,n]),at=et.length+rt.length+it.length,ot=(0,Q.useMemo)(()=>M.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&re(e)),[M.catalog]),st=(0,Q.useMemo)(()=>K===`recommended`?[]:K===`builtin`?ot:K===`all`?tr([...ot,...M.registryCatalog]):M.registryCatalog,[ot,K,M.registryCatalog]),ut=(0,Q.useMemo)(()=>{let e=g?st.filter(e=>e.understanding?.mode===`activity`):tr(st).filter(e=>!A.has(R(e.id)));return ve(Y===`all`?e:e.filter(e=>xt(e).includes(Y)),te,q)},[q,te,st,g,Y,A]),dt=(0,Q.useMemo)(()=>bt.filter(e=>st.some(t=>xt(t).includes(e))),[st]);(0,Q.useEffect)(()=>{Y!==`all`&&!dt.includes(Y)&&oe(`all`)},[dt,Y]);let ft=E===`discover`&&K!==`builtin`&&!!(H&&z<H),mt=(0,Q.useMemo)(()=>M.instances.find(e=>e.instanceId===de)??he,[de,he,M.instances]),_t=(0,Q.useMemo)(()=>[{value:Yn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:s.discoverSourceAll},{value:Xn,label:s.discoverSourceBuiltin},...Ie.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,Ie,r]),St=[{id:`connected`,label:s.tabConnected,count:Ae},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:v(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[d?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),g?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>f(y),children:s.understandingSetupDone})]}):null,S?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(T,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>f(y),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(X,{items:St,activeTab:E,onChange:Fe,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),M.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M.error}):null,E===`connected`&&d?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:M.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ht.slice(0,3).map(e=>(0,$.jsx)(yt,{},e))}):Ae===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(T,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Fe(`discover`),children:s.addFromCatalog})]}):at===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[tt.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:tt.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:tt.map(e=>(0,$.jsx)(An,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{be(null),me(e.instanceId),ge(e)},t:s},e.instanceId))})]}):null,nt.length||it.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[nt.map(e=>(0,$.jsx)(An,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{be(null),me(e.instanceId),ge(e)},t:s},e.instanceId)),it.map(e=>(0,$.jsx)(mn,{extension:e,language:r,onOpen:()=>f(pe(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,rt.length||!ee.trim()?(0,$.jsx)(fn,{servers:rt,lastChecks:je,t:c,cs:s,onAdd:Ke,onEdit:e=>Se({mode:`edit`,row:structuredClone(e)}),onRemove:Ge}):null]})}):null,E===`discover`&&d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[g?null:(0,$.jsx)(V,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:v(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Y===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":Y===e,onClick:()=>oe(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:v(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,g?`grid-cols-1`:`grid-cols-2`),children:[g?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:K,options:_t,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ie})}),K===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:q,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>ae(e)})})]})]}),K===`recommended`?(0,$.jsx)(J,{layout:`cards`,initialCount:6,query:te,onChanged:async()=>{await Ne(),await Te()}}):(M.loading||P)&&ut.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ht.map(e=>(0,$.jsx)(vt,{},e))}):ut.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[P?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(m,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:ut.map(e=>(0,$.jsx)(pt,{connector:e,installed:ze.has(e.id)||gt(e,M.instances),onInstall:e=>{if(e.source===`store`){Ve(e.id);return}ce(ye(e))},onOpenDetails:e.source===`store`?void 0:Z,t:s},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(T,{type:`button`,variant:`secondary`,disabled:P||I,onClick:()=>void Le({page:z+1,append:!0}),children:[P?(0,$.jsx)(m,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),se?(0,$.jsx)(ue,{draft:se,onChange:ce,onClose:()=>ce(null),t:s,onInstalled:async e=>{await Ne(),await Te(),be(e.instanceId),Fe(`connected`)}}):null,le?(0,$.jsx)(Dt,{connector:le,installed:ze.has(le.id)||gt(le,M.instances),onClose:()=>Z(null),onInstall:e=>ce(ye(e)),t:s}):null,mt?(0,$.jsx)(kn,{instance:mt,definition:Be.get(mt.connectorId),onClose:()=>{me(null),ge(null)},onChanged:Ne,t:s,mcp:c}):null,xe?(0,$.jsx)(Jn,{open:!0,mode:xe.mode,initialRow:xe.row,lastCheck:xe.mode===`edit`?je[xe.row.id]:void 0,existingCustomServers:Oe,config:Ee,managedServerIds:He,t:c,cs:s,onClose:()=>Se(null),onSaved:async()=>{await Te(),await Ne(),Fe(`connected`)}},`${xe.mode}-${xe.row.clientKey}`):null]})})}export{rr as ConnectorsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,l as a,u as ee}from"./popover-select-DGKUpVsz.js";import{t as te}from"./cn-0WouolD0.js";import{n as ne}from"./locale-store-B7s2Hb35.js";import{c as re,n as ie,s as ae}from"./dist-C3DSFZCi.js";import{Md as oe,Nd as se,Pd as ce}from"./index-Bys6njTY.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(105),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=ne(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=i(Se),Ee=ee(a(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=re,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=te(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=te(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ae,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=re,Pe=Te??void 0,Fe=re,Ie=te(Ee,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Le=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Le?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:I,children:L}),t[42]=Le,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let Re=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===Re?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:B,children:V}),t[48]=Re,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:te(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let ze=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Be=f===`zh`?`清除`:`Clear`,J;t[75]!==ze||t[76]!==q||t[77]!==Be?(J=(0,c.jsx)(`button`,{type:`button`,disabled:ze,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Be}),t[75]=ze,t[76]=q,t[77]=Be,t[78]=J):J=t[78];let Ve=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let He=f===`zh`?`今天`:`Today`,X;t[81]!==Ve||t[82]!==Y||t[83]!==He?(X=(0,c.jsx)(`button`,{type:`button`,disabled:Ve,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:He}),t[81]=Ve,t[82]=Y,t[83]=He,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let Ue;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,c.jsx)(ie,{className:`fill-surface-overlay`}),t[88]=Ue):Ue=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==U||t[92]!==W||t[93]!==K||t[94]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Ie,children:[U,W,K,Z,Ue]}),t[89]=Fe.Content,t[90]=Ie,t[91]=U,t[92]=W,t[93]=K,t[94]=Z,t[95]=Q):Q=t[95];let $;t[96]!==Ne.Portal||t[97]!==Pe||t[98]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[96]=Ne.Portal,t[97]=Pe,t[98]=Q,t[99]=$):$=t[99];let We;return t[100]!==h||t[101]!==Ae.Root||t[102]!==F||t[103]!==$?(We=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[100]=h,t[101]=Ae.Root,t[102]=F,t[103]=$,t[104]=We):We=t[104],We}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,l as a,u as ee}from"./popover-select-DGKUpVsz.js";import{t as te}from"./cn-0WouolD0.js";import{n as ne}from"./locale-store-B7s2Hb35.js";import{c as re,n as ie,s as ae}from"./dist-C3DSFZCi.js";import{Md as oe,Nd as se,Pd as ce}from"./index-DRyGCING.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(105),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=ne(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=i(Se),Ee=ee(a(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=re,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=te(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=te(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ae,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=re,Pe=Te??void 0,Fe=re,Ie=te(Ee,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Le=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Le?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:I,children:L}),t[42]=Le,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let Re=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===Re?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:B,children:V}),t[48]=Re,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:te(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let ze=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Be=f===`zh`?`清除`:`Clear`,J;t[75]!==ze||t[76]!==q||t[77]!==Be?(J=(0,c.jsx)(`button`,{type:`button`,disabled:ze,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Be}),t[75]=ze,t[76]=q,t[77]=Be,t[78]=J):J=t[78];let Ve=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let He=f===`zh`?`今天`:`Today`,X;t[81]!==Ve||t[82]!==Y||t[83]!==He?(X=(0,c.jsx)(`button`,{type:`button`,disabled:Ve,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:He}),t[81]=Ve,t[82]=Y,t[83]=He,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let Ue;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,c.jsx)(ie,{className:`fill-surface-overlay`}),t[88]=Ue):Ue=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==U||t[92]!==W||t[93]!==K||t[94]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Ie,children:[U,W,K,Z,Ue]}),t[89]=Fe.Content,t[90]=Ie,t[91]=U,t[92]=W,t[93]=K,t[94]=Z,t[95]=Q):Q=t[95];let $;t[96]!==Ne.Portal||t[97]!==Pe||t[98]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[96]=Ne.Portal,t[97]=Pe,t[98]=Q,t[99]=$):$=t[99];let We;return t[100]!==h||t[101]!==Ae.Root||t[102]!==F||t[103]!==$?(We=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[100]=h,t[101]=Ae.Root,t[102]=F,t[103]=$,t[104]=We):We=t[104],We}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{t as s}from"./cn-0WouolD0.js";import{t as c}from"./button-aIC072nz.js";import{Al as l,Bi as u,Jc as d,Li as f,Ou as p,Ri as m,Vi as h,zi as g}from"./index-Bys6njTY.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(h,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(m,{children:(0,y.jsx)(f,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(d,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(c,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(p,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(o,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(l,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(g,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{t as s}from"./cn-0WouolD0.js";import{t as c}from"./button-aIC072nz.js";import{Bi as l,Hi as u,Ml as d,Ou as f,Ui as p,Vi as m,Wi as h,Zc as g}from"./index-DRyGCING.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w===void 0?!1:w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(p,{children:[(0,y.jsx)(h,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(m,{children:(0,y.jsx)(l,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(g,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(c,{type:`button`,variant:`secondary`,className:s(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(f,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(o,{className:s(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:s(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(d,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:s(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:s(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:s(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(u,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{n as o,r as s}from"./popover-select-DGKUpVsz.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./messages-BYq0cPbn.js";import{t as u}from"./cn-0WouolD0.js";import{n as d}from"./locale-store-B7s2Hb35.js";import{t as f}from"./skeleton-BI5TyibZ.js";import{n as p}from"./electron-env-Dit0bHgy.js";import{As as m,Fl as h,Xc as g,Zl as _,jd as v,mu as y,ta as b}from"./index-Bys6njTY.js";import{t as x}from"./desktop-pet-sprite-Bd-aOI7N.js";import{n as S,t as C}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";var w=n(),T=e(t(),1),E=r();function D(e){let t=(0,w.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,E.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,E.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,E.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,E.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,E.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function O(){let e=l(d(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,T.useState)(null),[w,O]=(0,T.useState)(!1),[k,A]=(0,T.useState)(null),j=typeof window<`u`?window.electronAPI?.pet:void 0,M=(0,T.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),N=(0,T.useCallback)(async()=>{if(j){O(!0);try{r(await j.getState())}finally{O(!1)}}},[j]);if((0,T.useEffect)(()=>{if(j)return N(),j.onStateChanged(r)},[j,N]),!p()||!j)return null;if(!n)return(0,E.jsxs)(S,{gap:`gap-4`,children:[(0,E.jsx)(C,{title:e.title,subtitle:e.subtitle}),(0,E.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsx)(f,{className:`h-14 rounded-xl`}),(0,E.jsx)(f,{className:`h-14 rounded-xl`}),(0,E.jsx)(f,{className:`h-24 rounded-xl`}),(0,E.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,E.jsx)(f,{className:`h-16 rounded-xl`},t))})]})})]});let P=async e=>{O(!0);try{r(await j.setPrefs(e))}finally{O(!1)}},F=async e=>{e?(await j.show(),r(await j.getState())):r(await j.setPrefs({enabled:!1}))},I=e=>{P({selectedPetId:e})},L=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},R=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},z=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=L(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},B=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),V=()=>{R(e.createChatDraft)},H=t=>{R(B(e.optimizeChatDraft,{id:t.id,name:L(t).name,description:L(t).description,sourcePrompt:z(t)}))},U=t=>{R(B(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},W=k??n.prefs.sizePercent,G=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),K=async(e=W)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));A(null),t!==n.prefs.sizePercent&&await P({sizePercent:t})};return(0,E.jsxs)(S,{gap:`gap-5`,children:[(0,E.jsx)(C,{title:e.title,subtitle:e.subtitle,actions:(0,E.jsx)(b,{className:`size-9 shrink-0 p-0`,disabled:w,label:e.refresh,onClick:N})}),(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,E.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:M?(0,E.jsx)(x,{pet:M,action:`idle`,displayHeight:Math.round(104*W/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,E.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:M?L(M).name:e.title}),(0,E.jsx)(D,{title:e.enable,checked:n.prefs.enabled,disabled:w,onChange:e=>void F(e)})]}),(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(G)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,E.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,E.jsx)(o,{"aria-label":e.petList,value:M?.id??``,onChange:e=>I(e.target.value),disabled:w,children:n.pets.map(e=>(0,E.jsx)(s,{value:e.id,children:L(e).name},e.id))})}):null,M&&!M.builtin?(0,E.jsxs)(`button`,{type:`button`,onClick:()=>H(M),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(_,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,E.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:V,className:u(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,m.press),children:[(0,E.jsx)(g,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,E.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,E.jsx)(v,{className:`size-4`}),e.invalidPets]}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,E.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,E.jsxs)(`details`,{className:`mt-1`,children:[(0,E.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,E.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,E.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,E.jsx)(y,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,E.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:w,onChange:e=>void P({showOnStartup:e})}),(0,E.jsx)(D,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:w,onChange:e=>void P({alwaysOnTop:e})}),(0,E.jsx)(D,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:w,onChange:e=>void P({bubbleEnabled:e})}),(0,E.jsxs)(`div`,{className:`py-3`,children:[(0,E.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,E.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[W,`%`]})]}),(0,E.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:W,disabled:w,onChange:e=>A(Number(e.target.value)),onBlur:()=>void K(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&K()},onPointerUp:()=>void K()})]})]})]}),(0,E.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:w,onChange:e=>void P({proactiveTipsEnabled:e})}),(0,E.jsx)(D,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:w,onChange:e=>void P({interactionEnabled:e})}),(0,E.jsx)(D,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:w,onChange:e=>void P({reducedMotion:e})}),(0,E.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,E.jsxs)(o,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:w,onChange:e=>void P({behaviorMode:e.target.value}),children:[(0,E.jsx)(s,{value:`focus`,children:e.behaviorFocus}),(0,E.jsx)(s,{value:`companion`,children:e.behaviorCompanion}),(0,E.jsx)(s,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,E.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,E.jsx)(a,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,E.jsx)(D,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:w,onChange:e=>void P({clickThroughWhenIdle:e})}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,E.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void j.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(c,{className:`size-3.5`}),e.openFolder]})]}),(0,E.jsxs)(`button`,{type:`button`,className:u(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,m.press),disabled:w,onClick:()=>void j.resetPosition().then(r),children:[(0,E.jsx)(h,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{O as DesktopPetSettings};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{n as o,r as s}from"./popover-select-DGKUpVsz.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./messages-BYq0cPbn.js";import{t as u}from"./cn-0WouolD0.js";import{n as d}from"./locale-store-B7s2Hb35.js";import{t as f}from"./skeleton-BI5TyibZ.js";import{n as p}from"./electron-env-Dit0bHgy.js";import{Ll as m,Ns as h,Qc as g,Ql as _,ia as v,jd as y,mu as b}from"./index-DRyGCING.js";import{t as x}from"./desktop-pet-sprite-Bd-aOI7N.js";import{n as S,t as C}from"./settings-page-header-BWyxJKOG.js";import"./settings-page-layout-DLHcS-0T.js";var w=n(),T=e(t(),1),E=r();function D(e){let t=(0,w.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,E.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,E.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,E.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,E.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,E.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function O(){let e=l(d(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,T.useState)(null),[w,O]=(0,T.useState)(!1),[k,A]=(0,T.useState)(null),j=typeof window<`u`?window.electronAPI?.pet:void 0,M=(0,T.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),N=(0,T.useCallback)(async()=>{if(j){O(!0);try{r(await j.getState())}finally{O(!1)}}},[j]);if((0,T.useEffect)(()=>{if(j)return N(),j.onStateChanged(r)},[j,N]),!p()||!j)return null;if(!n)return(0,E.jsxs)(S,{gap:`gap-4`,children:[(0,E.jsx)(C,{title:e.title,subtitle:e.subtitle}),(0,E.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsx)(f,{className:`h-14 rounded-xl`}),(0,E.jsx)(f,{className:`h-14 rounded-xl`}),(0,E.jsx)(f,{className:`h-24 rounded-xl`}),(0,E.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,E.jsx)(f,{className:`h-16 rounded-xl`},t))})]})})]});let P=async e=>{O(!0);try{r(await j.setPrefs(e))}finally{O(!1)}},F=async e=>{e?(await j.show(),r(await j.getState())):r(await j.setPrefs({enabled:!1}))},I=e=>{P({selectedPetId:e})},L=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},R=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},z=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=L(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},B=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),V=()=>{R(e.createChatDraft)},H=t=>{R(B(e.optimizeChatDraft,{id:t.id,name:L(t).name,description:L(t).description,sourcePrompt:z(t)}))},U=t=>{R(B(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},W=k??n.prefs.sizePercent,G=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),K=async(e=W)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));A(null),t!==n.prefs.sizePercent&&await P({sizePercent:t})};return(0,E.jsxs)(S,{gap:`gap-5`,children:[(0,E.jsx)(C,{title:e.title,subtitle:e.subtitle,actions:(0,E.jsx)(v,{className:`size-9 shrink-0 p-0`,disabled:w,label:e.refresh,onClick:N})}),(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,E.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:M?(0,E.jsx)(x,{pet:M,action:`idle`,displayHeight:Math.round(104*W/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,E.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:M?L(M).name:e.title}),(0,E.jsx)(D,{title:e.enable,checked:n.prefs.enabled,disabled:w,onChange:e=>void F(e)})]}),(0,E.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(G)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,E.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,E.jsx)(o,{"aria-label":e.petList,value:M?.id??``,onChange:e=>I(e.target.value),disabled:w,children:n.pets.map(e=>(0,E.jsx)(s,{value:e.id,children:L(e).name},e.id))})}):null,M&&!M.builtin?(0,E.jsxs)(`button`,{type:`button`,onClick:()=>H(M),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(_,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,E.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:V,className:u(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,h.press),children:[(0,E.jsx)(g,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,E.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,E.jsx)(y,{className:`size-4`}),e.invalidPets]}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,E.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,E.jsxs)(`details`,{className:`mt-1`,children:[(0,E.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,E.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,E.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,E.jsx)(b,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,E.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:w,onChange:e=>void P({showOnStartup:e})}),(0,E.jsx)(D,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:w,onChange:e=>void P({alwaysOnTop:e})}),(0,E.jsx)(D,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:w,onChange:e=>void P({bubbleEnabled:e})}),(0,E.jsxs)(`div`,{className:`py-3`,children:[(0,E.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,E.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[W,`%`]})]}),(0,E.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:W,disabled:w,onChange:e=>A(Number(e.target.value)),onBlur:()=>void K(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&K()},onPointerUp:()=>void K()})]})]})]}),(0,E.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,E.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,E.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,E.jsx)(D,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:w,onChange:e=>void P({proactiveTipsEnabled:e})}),(0,E.jsx)(D,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:w,onChange:e=>void P({interactionEnabled:e})}),(0,E.jsx)(D,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:w,onChange:e=>void P({reducedMotion:e})}),(0,E.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,E.jsxs)(o,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:w,onChange:e=>void P({behaviorMode:e.target.value}),children:[(0,E.jsx)(s,{value:`focus`,children:e.behaviorFocus}),(0,E.jsx)(s,{value:`companion`,children:e.behaviorCompanion}),(0,E.jsx)(s,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,E.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,E.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,E.jsx)(a,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,E.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,E.jsx)(D,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:w,onChange:e=>void P({clickThroughWhenIdle:e})}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,E.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void j.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(c,{className:`size-3.5`}),e.openFolder]})]}),(0,E.jsxs)(`button`,{type:`button`,className:u(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,h.press),disabled:w,onClick:()=>void j.resetPosition().then(r),children:[(0,E.jsx)(m,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{O as DesktopPetSettings};