@xopcai/xopc 0.0.176 → 0.0.178

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 (238) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DsFM1upC.js → activity-store-BzGX__8I.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DvdMLOga.js → agent-avatar-dicebear-BzxntcaZ.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DC9F12Kw.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-BdPLCCBm.js → api-hi6f2Xtp.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-DMLDOHul.js → app-management-settings-panel-fTY1F7ac.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DbI9foFR.js → appearance-settings-BZ-IxQfB.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-5bKr05Fa.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Dfdxuwvb.js → archive-plugin-ZSLLG8wB.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dn3RlnYD.js → attachment-load-D4YktqIF.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-Bc0Y7A9u.js → automation-suggestion-card-B7mxFRtf.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-Dg6dmt5g.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-0XtB-xC0.js → binary-plugins-BIkPxfxj.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-C4fXWbEE.js → block-editor-Q3v_YQom.js} +6 -6
  16. package/dist/gateway/static/root/assets/{browser-settings-page-lC86-drr.js → browser-settings-page-BHoo6Rpq.js} +4 -4
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CZmzNymN.js → browser-workflow-inputs-M5lTEW1I.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CBYM9HqG.js → browser-workflows-page-B3T1KYk4.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-BlsqN8Fu.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BiJxmmhW.js → capability-presets-api-DE09c0VB.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DJeT8_B4.js +1 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-BKTUZDp-.js → channel-recipient-api-CFR5FBfS.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-C4VVjYEm.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-Pr4RIKjj.js → connector-logo-B1mD-3pM.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-DNcrDThX.js +2 -0
  27. package/dist/gateway/static/root/assets/desktop-pet-B1urphOZ.js +1 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-CEQacUDF.js → desktop-pet-settings-DTL6J3EP.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-DWnxdZtc.js → directory-picker-path-field-BYQJ2XUS.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-D2e2w2Ho.js → dreaming-settings-BXcb8fwx.js} +3 -3
  31. package/dist/gateway/static/root/assets/{extension-debug-page-BLjTGbv3.js → extension-debug-page-O1Xu1r4Q.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-D2_UC6hy.js → extension-page-C2Jraq8l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-BsH6o_PX.js → extension-settings-page-DcXQDTpG.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-C-DkC6UJ.js → gateway-config-api-DmPIZrvg.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-DEOGiimF.js → gateway-settings-DmObBx9b.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-BlSLh1TF.js → gateway-startup-retry-BZEkOdPm.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goal-create-dialog-CSFcRE_N.js → goal-create-dialog-BRhmmBe9.js} +1 -1
  38. package/dist/gateway/static/root/assets/goal-detail-page-C1k7_s_O.js +4 -0
  39. package/dist/gateway/static/root/assets/{goals-config-api-CcdS9qek.js → goals-config-api-Fwu1wjEP.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goals-page-BAcErdch.js → goals-page-hOu9uA3q.js} +2 -2
  41. package/dist/gateway/static/root/assets/{goals-settings-BY7crl0z.js → goals-settings-DY-JjvHz.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-DtTkS0gs.js → heartbeat-settings-BtKu2NWT.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-WGgkbwDZ.js → image-generation-api-05Gg8wsU.js} +1 -1
  44. package/dist/gateway/static/root/assets/{index-2UImfRDC.js → index-C0CGebQ1.js} +65 -65
  45. package/dist/gateway/static/root/assets/index-eqq25gvV.css +1 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C5lpWQ3f.js → keyboard-shortcuts-settings-CfmDR9Sc.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-EjsNT7nJ.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-b05wWvXG.js → local-apps-page-Df8BW1A_.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-sToMfHX_.js → locale-store-CTwSy7yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-cDE1jLJv.js → logs-page-Dswjlraa.js} +3 -3
  51. package/dist/gateway/static/root/assets/{markdown-split-0gPVst5y.js → markdown-split-B3FvKbaP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-Rxyq_KTm.js → media-plugins-DsjrvvB6.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-DRhNDl_Q.js → notes-page-tuzIwy3c.js} +1 -1
  55. package/dist/gateway/static/root/assets/notes-workbench-DSh3-hMY.js +4 -0
  56. package/dist/gateway/static/root/assets/{page-tabs-cOEOQqHh.js → page-tabs-ke9s4nYi.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-BopOLFvu.js → preview-open-alternatives-Cp1eI4S9.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-DWVPmmOq.js → product-open-page-dXQCMAtH.js} +1 -1
  59. package/dist/gateway/static/root/assets/project-detail-page-D0QPRHR_.js +1 -0
  60. package/dist/gateway/static/root/assets/projects-page-CI5Vz62F.js +1 -0
  61. package/dist/gateway/static/root/assets/remote-access-hub-S1jpzBS5.js +1 -0
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BfZmKe1t.js → save-bar-controls-Bl30zjHc.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-Cpi4jCRV.js → schedule-field-DqhmXQKo.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-OXFkcZQe.js → schema-form-DkUCy6vf.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-CTm66k7h.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-BwqkZCHJ.js → settings-form-section-C6ZbNpdy.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BbqH_S3Y.js → settings-loading-skeleton-Bk58_cr7.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-BoxC-JSa.js → settings-page-k8iE_NdX.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-Ddu2iGaW.js → settings-page-layout-DgFSya2e.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-z1Lwv0js.js → setup-status-panel-B_KDlyZA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-CVazOFjy.js → share-preview-page-CV7nL_J9.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-DK6XK95e.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +1 -0
  75. package/dist/gateway/static/root/assets/skills-page-BGHvVbay.js +2 -0
  76. package/dist/gateway/static/root/assets/{skills-page.utils-DgyB1tSo.js → skills-page.utils-kahBIHg0.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-BoLSQL65.js → system-settings-panel-JV3-MG5F.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-CBNcGOfj.js → theme-store-DFLyzoLO.js} +1 -1
  79. package/dist/gateway/static/root/assets/{time-picker-gochWrny.js → time-picker-XwpxdZFr.js} +1 -1
  80. package/dist/gateway/static/root/assets/{typed-models-lib-DvRnr7YB.js → typed-models-lib-60Aqo-UJ.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-CA9BFVB7.js → use-channel-catalog-CnTkHDnw.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-context-page-DBCMk-Vn.js +1 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-v8tgylEZ.js → voice-api-key-field-CNa8qUgS.js} +1 -1
  84. package/dist/gateway/static/root/assets/work-discovery-page-C1UIdsCl.js +1 -0
  85. package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +1 -0
  86. package/dist/gateway/static/root/assets/work-page-D5qYmCTq.js +3 -0
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CC3cJn5k.js → workflow-run-setup-panel-yV_x595t.js} +2 -2
  88. package/dist/gateway/static/root/assets/workflows-page-yrK17ZZ5.js +11 -0
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/embedded/model-runtime.js +3 -0
  92. package/dist/src/agent/embedded/run-for-session.js +18 -5
  93. package/dist/src/agent/embedded/run-turn.js +6 -3
  94. package/dist/src/agent/embedded/types.d.ts +2 -0
  95. package/dist/src/automations/service/automation-service.d.ts +3 -0
  96. package/dist/src/automations/service/automation-service.js +37 -7
  97. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  98. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  99. package/dist/src/cli/commands/update.js +1 -1
  100. package/dist/src/connectors/composio-sessions.js +1 -1
  101. package/dist/src/gateway/hono/routes/home.d.ts +18 -2
  102. package/dist/src/gateway/hono/routes/home.js +19 -0
  103. package/dist/src/gateway/hono/routes/index.js +2 -2
  104. package/dist/src/gateway/hono/routes/local-apps.js +1 -1
  105. package/dist/src/gateway/hono/routes/proactive.d.ts +4 -0
  106. package/dist/src/gateway/hono/routes/proactive.js +157 -0
  107. package/dist/src/gateway/hono/routes/projects.js +2 -2
  108. package/dist/src/gateway/hono/routes/update.js +2 -2
  109. package/dist/src/gateway/index.js +1 -1
  110. package/dist/src/gateway/run-loop.js +1 -1
  111. package/dist/src/gateway/service.d.ts +10 -1
  112. package/dist/src/gateway/service.js +36 -36
  113. package/dist/src/infra/gateway-processes.js +1 -1
  114. package/dist/src/infra/update-restart.js +1 -1
  115. package/dist/src/infra/update-runner.js +2 -2
  116. package/dist/src/infra/update-startup.js +1 -1
  117. package/dist/src/mcp/channel-bridge.js +1 -1
  118. package/dist/src/mobile/notification-service.d.ts +1 -0
  119. package/dist/src/mobile/notification-service.js +38 -18
  120. package/dist/src/mobile/notification-types.d.ts +2 -2
  121. package/dist/src/proactive/events/envelope.d.ts +2 -0
  122. package/dist/src/proactive/events/envelope.js +54 -0
  123. package/dist/src/proactive/events/publisher.d.ts +4 -0
  124. package/dist/src/proactive/events/repository.d.ts +9 -0
  125. package/dist/src/proactive/events/repository.js +62 -0
  126. package/dist/src/proactive/events/types.d.ts +44 -0
  127. package/dist/src/proactive/events/types.js +15 -0
  128. package/dist/src/proactive/execution/agent-executor.d.ts +16 -0
  129. package/dist/src/proactive/execution/agent-executor.js +104 -0
  130. package/dist/src/proactive/execution/context.d.ts +31 -0
  131. package/dist/src/proactive/execution/context.js +72 -0
  132. package/dist/src/proactive/execution/insight.d.ts +4 -0
  133. package/dist/src/proactive/execution/insight.js +74 -0
  134. package/dist/src/proactive/execution/repository.d.ts +23 -0
  135. package/dist/src/proactive/execution/repository.js +122 -0
  136. package/dist/src/proactive/execution/types.d.ts +54 -0
  137. package/dist/src/proactive/execution/types.js +1 -0
  138. package/dist/src/proactive/execution/worker.d.ts +15 -0
  139. package/dist/src/proactive/execution/worker.js +96 -0
  140. package/dist/src/proactive/inbox/repository.d.ts +24 -0
  141. package/dist/src/proactive/inbox/repository.js +117 -0
  142. package/dist/src/proactive/inbox/service.d.ts +17 -0
  143. package/dist/src/proactive/inbox/service.js +22 -0
  144. package/dist/src/proactive/inbox/types.d.ts +38 -0
  145. package/dist/src/proactive/inbox/types.js +1 -0
  146. package/dist/src/proactive/inbox/worker.d.ts +12 -0
  147. package/dist/src/proactive/inbox/worker.js +56 -0
  148. package/dist/src/proactive/index.d.ts +17 -0
  149. package/dist/src/proactive/index.js +11 -0
  150. package/dist/src/proactive/routing/batch-repository.d.ts +27 -0
  151. package/dist/src/proactive/routing/batch-repository.js +56 -0
  152. package/dist/src/proactive/routing/matcher.d.ts +5 -0
  153. package/dist/src/proactive/routing/matcher.js +56 -0
  154. package/dist/src/proactive/routing/types.d.ts +44 -0
  155. package/dist/src/proactive/routing/types.js +1 -0
  156. package/dist/src/proactive/scenarios/prompt-composer.d.ts +14 -0
  157. package/dist/src/proactive/scenarios/prompt-composer.js +24 -0
  158. package/dist/src/proactive/scenarios/repository.d.ts +23 -0
  159. package/dist/src/proactive/scenarios/repository.js +162 -0
  160. package/dist/src/proactive/scenarios/service.d.ts +15 -0
  161. package/dist/src/proactive/scenarios/service.js +26 -0
  162. package/dist/src/proactive/scenarios/types.d.ts +36 -0
  163. package/dist/src/proactive/scenarios/types.js +1 -0
  164. package/dist/src/proactive/service.d.ts +18 -0
  165. package/dist/src/proactive/service.js +61 -0
  166. package/dist/src/projects/project-service.d.ts +3 -1
  167. package/dist/src/projects/project-service.js +62 -32
  168. package/dist/src/providers/provider-auth-service.js +3 -0
  169. package/dist/src/providers/register-bundled-oauth-flows.d.ts +2 -0
  170. package/dist/src/providers/register-bundled-oauth-flows.js +16 -0
  171. package/dist/src/session/store.d.ts +2 -0
  172. package/dist/src/session/store.js +30 -0
  173. package/dist/src/storage/sqlite/migrations/068_proactive_event_spine.sql +71 -0
  174. package/dist/src/storage/sqlite/migrations/069_proactive_scenario_control.sql +69 -0
  175. package/dist/src/storage/sqlite/migrations/070_proactive_execution.sql +55 -0
  176. package/dist/src/storage/sqlite/migrations/071_proactive_inbox.sql +45 -0
  177. package/dist/src/storage/sqlite/migrations/072_proactive_judgments.sql +14 -0
  178. package/dist/src/storage/sqlite/migrations/073_enable_default_proactive_scenarios.sql +13 -0
  179. package/dist/src/storage/sqlite/migrations/074_deduplicate_blocked_work_routing.sql +5 -0
  180. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  181. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  182. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  183. package/dist/src/storage/sqlite/schema.js +1 -1
  184. package/dist/src/work-discovery/thread-service.d.ts +1 -3
  185. package/dist/src/work-discovery/thread-service.js +13 -25
  186. package/dist/src/work-items/work-item-service.d.ts +3 -1
  187. package/dist/src/work-items/work-item-service.js +67 -36
  188. package/package.json +3 -11
  189. package/dist/gateway/static/root/assets/agents-BVjlpbeZ.js +0 -2
  190. package/dist/gateway/static/root/assets/api-Bop4IQRW.js +0 -1
  191. package/dist/gateway/static/root/assets/apps-page-njqxLWYD.js +0 -1
  192. package/dist/gateway/static/root/assets/automations-page-D-eweHZJ.js +0 -6
  193. package/dist/gateway/static/root/assets/capabilities-settings-panel-6tYNfHqJ.js +0 -7
  194. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co-ymbd9.js +0 -1
  195. package/dist/gateway/static/root/assets/channels-settings-D46eVjaQ.js +0 -1
  196. package/dist/gateway/static/root/assets/channels-status-swr-BMRAO4zZ.js +0 -1
  197. package/dist/gateway/static/root/assets/connectors-page-Dw1eYbRi.js +0 -2
  198. package/dist/gateway/static/root/assets/copy-VueTIC2x.js +0 -1
  199. package/dist/gateway/static/root/assets/desktop-pet-B8cZuQUt.js +0 -1
  200. package/dist/gateway/static/root/assets/focus-detail-page-BBXUtxRB.js +0 -1
  201. package/dist/gateway/static/root/assets/goal-detail-page-VjRArfAJ.js +0 -4
  202. package/dist/gateway/static/root/assets/index-CS9sVShT.css +0 -1
  203. package/dist/gateway/static/root/assets/local-app-workbench-page-Cl0fcPL4.js +0 -2
  204. package/dist/gateway/static/root/assets/messages-CarlxqXV.js +0 -3
  205. package/dist/gateway/static/root/assets/notes-workbench-BKNBk0Uf.js +0 -4
  206. package/dist/gateway/static/root/assets/project-detail-page-BhjEXNQW.js +0 -1
  207. package/dist/gateway/static/root/assets/projects-page-B80e69PH.js +0 -1
  208. package/dist/gateway/static/root/assets/remote-access-hub-CwdVob6H.js +0 -1
  209. package/dist/gateway/static/root/assets/sessions-page-BGt3Asj6.js +0 -1
  210. package/dist/gateway/static/root/assets/settings-advanced-gate-BnTdM9Nn.js +0 -1
  211. package/dist/gateway/static/root/assets/shares-settings-C4lXuyQj.js +0 -1
  212. package/dist/gateway/static/root/assets/skill-reload-api-DSuIDkeI.js +0 -1
  213. package/dist/gateway/static/root/assets/skills-page-xgZczqVe.js +0 -2
  214. package/dist/gateway/static/root/assets/user-context-page-CEfIy4WZ.js +0 -1
  215. package/dist/gateway/static/root/assets/work-discovery-page-B-3MClaf.js +0 -1
  216. package/dist/gateway/static/root/assets/work-item-detail-page-CEsFEdax.js +0 -1
  217. package/dist/gateway/static/root/assets/work-page-CT9AHnq6.js +0 -3
  218. package/dist/gateway/static/root/assets/workflows-page-C-1-_Zp1.js +0 -11
  219. package/dist/src/focuses/candidate-repository.d.ts +0 -15
  220. package/dist/src/focuses/candidate-repository.js +0 -91
  221. package/dist/src/focuses/index.d.ts +0 -7
  222. package/dist/src/focuses/index.js +0 -7
  223. package/dist/src/focuses/insight-repository.d.ts +0 -22
  224. package/dist/src/focuses/insight-repository.js +0 -77
  225. package/dist/src/focuses/prompts.d.ts +0 -2
  226. package/dist/src/focuses/prompts.js +0 -18
  227. package/dist/src/focuses/reconciler.d.ts +0 -5
  228. package/dist/src/focuses/reconciler.js +0 -26
  229. package/dist/src/focuses/repository.d.ts +0 -61
  230. package/dist/src/focuses/repository.js +0 -214
  231. package/dist/src/focuses/run-processor.d.ts +0 -18
  232. package/dist/src/focuses/run-processor.js +0 -162
  233. package/dist/src/focuses/service.d.ts +0 -42
  234. package/dist/src/focuses/service.js +0 -241
  235. package/dist/src/focuses/types.d.ts +0 -89
  236. package/dist/src/gateway/hono/routes/focuses.d.ts +0 -3
  237. package/dist/src/gateway/hono/routes/focuses.js +0 -319
  238. /package/dist/src/{focuses/types.js → proactive/events/publisher.js} +0 -0
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-CarlxqXV.js";import{l as c,n as l}from"./locale-store-sToMfHX_.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{As as d,Bo as f,Cs as p,Du as m,Go as h,Ho as g,It as _,Kr as v,Ks as y,Mu as b,Ns as x,Oc as S,Ps as C,Pu as w,Ql as T,Uo as E,Vo as D,Wl as O,Wo as k,as as A,cc as j,gl as M,is as N,jc as ee,ls as P,nl as F,ns as te,ts as I,us as L,vu as R,yc as z,zo as B}from"./index-2UImfRDC.js";import{n as V,r as H}from"./settings-page-layout-Ddu2iGaW.js";import{n as ne,r as U}from"./settings-loading-skeleton-BbqH_S3Y.js";import{n as W,t as G}from"./settings-form-section-BwqkZCHJ.js";import{a as K,i as re,n as ie,o as ae,r as oe,t as se}from"./capability-presets-api-BiJxmmhW.js";import{a as ce,i as le,o as q,s as J,t as Y}from"./typed-models-lib-DvRnr7YB.js";import{r as X}from"./image-generation-api-WGgkbwDZ.js";var ue=n(),de=e(t(),1),Z=r(),fe=[`deep`,`fast`,`cheap`,`code`,`review`];function Q(e){return fe.includes(e)}function pe(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,de.useRef)([]),c=(0,de.useRef)(0);for(;s.current.length<t.length;)s.current.push(`preset-model-row-${c.current++}`);s.current.length>t.length&&(s.current.length=t.length);let l=i??(t.some(e=>e.id===`deep`)?`deep`:t[0]?.id)??`deep`,u=t.findIndex(e=>e.id===l),f=u>=0?t[u]:void 0,p=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),m=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},h=e=>{if(u>=0){m(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:Q(l)?o.roleDescriptions[l]:``},...t])},g=e=>{let n=t[e];n&&m(e,{fallbacks:[...n.fallbacks??[],``]})},v=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,m(e,{fallbacks:a})},b=(e,n)=>{let r=t[e];r&&m(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},x=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},S=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:Q(r)?o.roleDescriptions[r]:``}])},C=[...fe.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],w=(e,t)=>(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.fallbackModels}),(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>g(t),children:[(0,Z.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(_,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,n,e)}),(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>b(t,n),children:(0,Z.jsx)(y,{className:`size-4`,"aria-hidden":!0})})]},`${s.current[t]}-fallback-${n}`))}):(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.fallbackEmptyHint})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-muted`,children:[o.description,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.description,disabled:r,placeholder:o.descriptionPlaceholder,onChange:e=>m(t,{description:e.target.value})})]})]});return(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,Z.jsx)(_,{value:f?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:h})]}),f?(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-md text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(R,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:w(f,u)})]}):null]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.otherRolesTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.otherRolesHint})]}),p.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:p.map(({row:e,index:t})=>{let n=Q(e.id)?e.id:void 0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 p-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)] md:items-end`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n?o.roleNames[n]:o.customRole}),n?(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:e.id}):(0,Z.jsxs)(`label`,{className:`mt-1 grid gap-1 text-[11px] text-fg-muted`,children:[o.roleId,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.id,disabled:r,placeholder:o.roleIdPlaceholder,onChange:e=>m(t,{id:e.target.value.toLowerCase()})})]})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,Z.jsx)(_,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>m(t,{model:e})})]})]}),(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(R,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[w(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>x(t),children:[(0,Z.jsx)(y,{className:`size-4`,"aria-hidden":!0}),o.removeRole]})})]})]})]},s.current[t])})}):(0,Z.jsx)(`p`,{className:`mt-3 rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:o.otherRolesEmpty}),(0,Z.jsx)(I,{value:``,options:C,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:S})]})]})}function me(e){let t=(0,ue.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,Z.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,Z.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,Z.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function he(e){return e.name||e.directoryId}function ge(e){let t=(0,ue.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,f=n===`allowlist`||n===`denylist`,p;t[0]===i?p=t[1]:(p=i.map(he).filter(Boolean),t[0]=i,t[1]=p);let h=p,g;bb0:{if(n===`inherit`){g=u.inheritSummary;break bb0}if(n===`all`){g=u.allSummary;break bb0}if(n===`off`){g=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],g=i}let _=g,v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),t[5]=v):v=t[5];let y;t[6]===u.overrideSummaryTitle?y=t[7]:(y=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[v,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=y);let b;t[8]===_?b=t[9]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:_}),t[8]=_,t[9]=b);let x;t[10]!==y||t[11]!==b?(x=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[y,b]}),t[10]=y,t[11]=b,t[12]=x):x=t[12];let S;t[13]===u.modeLabel?S=t[14]:(S=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=S);let C;t[15]===u.modeInherit?C=t[16]:(C=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=C);let w;t[17]===u.modeAll?w=t[18]:(w=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=w);let T;t[19]===u.modeAllowlist?T=t[20]:(T=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=T);let E;t[21]===u.modeDenylist?E=t[22]:(E=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=E);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==E||t[26]!==D||t[27]!==C||t[28]!==w||t[29]!==T?(O=[C,w,T,E,D],t[25]=E,t[26]=D,t[27]=C,t[28]=w,t[29]=T,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==S?(j=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,A]}),t[36]=A,t[37]=S,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==h||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==f||t[50]!==r?(M=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:s||a||h.length===0,onClick:()=>l(new Set(h)),children:u.quickSelectAll}),(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(U,{rows:3}):i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=he(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,Z.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,Z.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Z.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=h,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=f,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==x?(N=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[x,j,M]}),t[52]=j,t[53]=M,t[54]=x,t[55]=N):N=t[55],N}var _e=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],ve=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],ye=[`send_message`,`send_media`,`text_to_speech`,`create_share`],be=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],xe=[..._e,...ye],Se=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],Ce=[`send_message`,`send_media`];function we(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function Te(e){let t=(0,ue.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let f=u,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(Ee),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of K){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=ae(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==i||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=_):_=t[14];let v=_,y;t[15]!==i||t[16]!==r?(y=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=y):y=t[17];let b=y,x;t[18]!==f||t[19]!==i?(x=e=>{i(we(f,e))},t[18]=f,t[19]=i,t[20]=x):x=t[20];let S=x;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let C;t[23]===l.quickActionsLabel?C=t[24]:(C=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=C);let w;t[25]===i?w=t[26]:(w=()=>i({}),t[25]=i,t[26]=w);let T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==w?(T=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:w,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=w,t[30]=T):T=t[30];let E;t[31]===S?E=t[32]:(E=()=>S([[_e,`deny`]]),t[31]=S,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===S?O=t[38]:(O=()=>S([[ve,`deny`]]),t[37]=S,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:O,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=k):k=t[42];let A;t[43]===S?A=t[44]:(A=()=>S([[ye,`deny`]]),t[43]=S,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let M;t[49]===S?M=t[50]:(M=()=>S([[be,`allow`],[xe,`deny`]]),t[49]=S,t[50]=M);let ee;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==M?(ee=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:M,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=M,t[54]=ee):ee=t[54];let P;t[55]===S?P=t[56]:(P=()=>S([[Se,`allow`],[Ce,`deny`]]),t[55]=S,t[56]=P);let F;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==P?(F=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:P,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=P,t[60]=F):F=t[60];let I;t[61]!==k||t[62]!==j||t[63]!==ee||t[64]!==F||t[65]!==T||t[66]!==D?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,ee,F]}),t[61]=k,t[62]=j,t[63]=ee,t[64]=F,t[65]=T,t[66]=D,t[67]=I):I=t[67];let L;t[68]!==I||t[69]!==C?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[C,I]}),t[68]=I,t[69]=C,t[70]=L):L=t[70];let R;t[71]===l.overrideSummaryTitle?R=t[72]:(R=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=R);let z;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==m?(z=m.length>0?(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,Z.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,Z.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=m,t[78]=z):z=t[78];let B;t[79]!==R||t[80]!==z?(B=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[R,z]}),t[79]=R,t[80]=z,t[81]=B):B=t[81];let V;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==g||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==v||t[98]!==r||t[99]!==b?(V=(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,Z.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,Z.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,Z.jsxs)(te,{value:n.scope??``,disabled:a,onChange:t=>b(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(N,{value:``,children:l.scopeInherit}),(0,Z.jsx)(N,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(N,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(N,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)(Oe,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>b(e,e=>De(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)(Oe,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>b(e,e=>De(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=g,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=v,t[98]=r,t[99]=b,t[100]=V):V=t[100];let H;return t[101]!==L||t[102]!==B||t[103]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[L,B,V]}),t[101]=L,t[102]=B,t[103]=V,t[104]=H):H=t[104],H}function Ee(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function De(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function Oe(e){let t=(0,ue.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var ke=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ae=[{id:`overview`,icon:T},{id:`models`,icon:M},{id:`tools`,icon:C},{id:`skills`,icon:S},{id:`advanced`,icon:j},{id:`impact`,icon:O}];function je(e){return le(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function $(e){return structuredClone(e?.tools?.builtin??{})}function Me(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Ne(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Pe(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Fe(){return{imageModel:Ne(),imageGenerationModel:Ne(),allowFallbacks:``,maxCostTier:``}}function Ie(e){return{imageModel:Pe(e?.models?.imageModel),imageGenerationModel:Pe(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Le(e){return e===void 0?``:JSON.stringify(e,null,2)}function Re(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function ze(e){return{mcp:Le(e?.tools?.mcp),workflows:Le(e?.workflows),boundaries:Le(e?.boundaries),runtime:Le(e?.runtime),locks:Le(e?.locks)}}function Be(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:je(e),modelAdvanced:Ie(e),toolPolicies:$(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Me(e),extendsIds:[...e?.extends??[]],jsonFields:ze(e)}}function Ve(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function He(e,t){let n=Y(e.modelRows),r=Ve(e.modelAdvanced.imageModel),i=Ve(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function Ue(e){return e.trim()?JSON.parse(e):void 0}function We(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ge(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Ue(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Ke(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function qe(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Je(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:He(e,t),tools:{builtin:Ke(e.toolPolicies),mcp:We(e.jsonFields.mcp)},skills:qe(e),extends:[...e.extendsIds].toSorted(),workflows:We(e.jsonFields.workflows),boundaries:We(e.jsonFields.boundaries),runtime:We(e.jsonFields.runtime),locks:We(e.jsonFields.locks)}}function Ye(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Ke(e.tools?.builtin),mcp:We(Le(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:We(Le(e.workflows)),boundaries:We(Le(e.boundaries)),runtime:We(Le(e.runtime)),locks:We(Le(e.locks))}:null}function Xe(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function Ze(){return{modelAdvanced:Fe(),extendsIds:[],jsonFields:Re()}}function Qe(e,t){return{extends:[...e.extendsIds],models:He(e,t)??void 0,tools:Ge(e)??void 0,skills:qe(e)??void 0,workflows:Ue(e.jsonFields.workflows),boundaries:Ue(e.jsonFields.boundaries),runtime:Ue(e.jsonFields.runtime),locks:Ue(e.jsonFields.locks)}}function $e(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...Ze()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...Ze()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...Ze()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...Ze()}}function et(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(d,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(b,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:m,error:_,isLoading:N,mutate:te}=u(r?`settings-capability-presets`:null,oe,{revalidateOnFocus:!1}),{data:I=[],isLoading:R}=u(r?`settings-capability-presets-skills-catalog`:null,v,{revalidateOnFocus:!1}),[U,K]=i(),[ae,le]=(0,de.useState)(``),[q,J]=(0,de.useState)(`overview`),[Y,X]=(0,de.useState)(()=>$e(`blank`,t)),[ue,fe]=(0,de.useState)(null),[Q,he]=(0,de.useState)(!1),[_e,ve]=(0,de.useState)(null),[ye,be]=(0,de.useState)(!1),[xe,Se]=(0,de.useState)(null),[Ce,we]=(0,de.useState)(null),Ee=m?.presets??[],De=m?.defaultPresetId??`default`,Oe=Ee.find(e=>e.id===De)??null,je=Ee.filter(e=>e.id!==De),$=(0,de.useMemo)(()=>Ee.find(e=>e.id===ae)??Ee[0]??null,[Ee,ae]),Me=!$||Y.id.trim()!==$.id,Ne=!!($&&$.id===De),Pe=JSON.stringify(Je(Y,$))!==JSON.stringify(Ye($)),Fe=Je(Y,$),Ie=Ye($),Le=[Fe.id!==Ie?.id||Fe.name!==Ie?.name||Fe.description!==Ie?.description?t.tabs.overview:``,JSON.stringify(Fe.models)===JSON.stringify(Ie?.models)?``:t.tabs.models,JSON.stringify(Fe.tools)===JSON.stringify(Ie?.tools)?``:t.tabs.tools,JSON.stringify(Fe.skills)===JSON.stringify(Ie?.skills)?``:t.tabs.skills,JSON.stringify({extends:Fe.extends,workflows:Fe.workflows,boundaries:Fe.boundaries,runtime:Fe.runtime,locks:Fe.locks})===JSON.stringify({extends:Ie?.extends,workflows:Ie?.workflows,boundaries:Ie?.boundaries,runtime:Ie?.runtime,locks:Ie?.locks})?``:t.tabs.advanced].filter(Boolean),Re=_e??(_ instanceof Error?_.message:null),ze=U.get(`action`)===`new`||!!U.get(`preset`),Ve=U.get(`action`)===`new`&&ue===null,He=Me?t.newPreset:$?.name??t.editorTitle,We=t=>e.agentsSettings.toolsDisableGroups[t],Ge=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,de.useEffect)(()=>{if(!m||Q)return;if(U.get(`action`)===`new`){le(``),X($e(`blank`,t)),J(`overview`);return}let e=U.get(`preset`)?.trim(),n=e?m.presets.find(t=>t.id===e):null;if(n){le(n.id),X(Be(n)),J(U.get(`tab`)??`overview`);return}$&&(le($.id),X(e=>e.id===$.id?e:Be($)))},[Q,m,U,$]);function Ke(e){fe(null),le(e.id),X(Be(e)),K({preset:e.id},{replace:!0}),J(`overview`)}function qe(){fe(null),le(``),X($e(`blank`,t)),ve(null),K({action:`new`},{replace:!0}),J(`overview`)}function Ze(e){fe(e),X($e(e,t)),ve(null),J(`overview`)}function et(){if(ue){let e=$e(ue,t);if(JSON.stringify(Je(Y,null))!==JSON.stringify(Je(e,null))&&!window.confirm(t.changeTemplateConfirm))return}fe(null),ve(null)}function rt(){!Ve&&Pe&&!window.confirm(t.discardConfirm)||(be(!1),Se(null),K({},{replace:!0}),fe(null),ve(null),X(Be($)),J(`overview`))}async function it(){let e=ce(Y.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ve(e),J(`models`);return}for(let e of[Y.modelAdvanced.imageModel,Y.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){ve(t.invalidModelRef),J(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ve(t.advancedPositiveIntegerError),J(`models`);return}}for(let e of Object.values(Y.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){ve(t.advancedPositiveIntegerError),J(`tools`);return}for(let e of Object.keys(Y.jsonFields))try{Ue(Y.jsonFields[e])}catch{ve(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),J(`advanced`);return}he(!0),ve(null);try{let e=Qe(Y,$);if(Me){let t=await se({id:Y.id.trim(),name:Y.name.trim(),...Y.description.trim()?{description:Y.description.trim()}:{},...e});await te(t.presets,{revalidate:!1}),le(t.presetId),fe(null),K({preset:t.presetId},{replace:!0})}else $&&await te(await re($.id,{name:Y.name.trim(),description:Y.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){ve(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function at(){if($){he(!0),ve(null),Se(null);try{await te(await ie($.id),{revalidate:!1}),be(!1),le(``),fe(null),X($e(`blank`,t)),J(`overview`),K({},{replace:!0})}catch(e){Se(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(H,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(V,{title:t.title,subtitle:t.subtitle,actions:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,Z.jsxs)(d,{type:`button`,onClick:qe,disabled:Q,children:[(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Re?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Re}):null,N?(0,Z.jsx)(ne,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Oe?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:M,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Ke(Oe),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Oe.name}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Oe.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Oe.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Oe.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Xe(Oe,t)})]})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:M,title:t.listTitle,subtitle:t.listHint}),je.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,Z.jsx)(`p`,{children:t.empty}),(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,onClick:qe,disabled:Q,children:[(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:je.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Ke(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:Xe(e,t)})]},e.id))})]})]}),(0,Z.jsx)(B,{open:ze,onOpenChange:e=>{e||rt()},children:(0,Z.jsxs)(k,{children:[(0,Z.jsx)(E,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,L)}),(0,Z.jsx)(D,{ref:we,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,P),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(A,{layer:`modal`,portalContainer:Ce,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!Ve&&Me&&ue?(0,Z.jsx)(`button`,{type:`button`,className:o(p,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:et,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(w,{className:`size-4`,"aria-hidden":!0})}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(h,{className:`truncate text-base font-semibold text-fg`,children:He}),(0,Z.jsx)(g,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ve?t.templatePickerSubtitle:Me&&ue?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[ue].title)}`:Me?t.editorHint:Y.id})]})]}),(0,Z.jsx)(f,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(p,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(x,{className:`size-4`,"aria-hidden":!0})})})]}),Ve?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,Z.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:ke.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ze(e),children:[(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,Z.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,Z.jsx)(d,{type:`button`,variant:`secondary`,onClick:rt,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Re?(0,Z.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Re}):null,(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:Ae.map(({id:e,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,q===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>J(e),children:[(0,Z.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,Z.jsxs)(`div`,{className:`w-full`,children:[q===`overview`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:T,title:t.overviewTitle,subtitle:t.overviewHint}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:Y.id,disabled:Q||!Me,onChange:e=>X(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Me&&$?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String($.version))})]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:Y.name,disabled:Q,onChange:e=>X(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,Z.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:Y.description,disabled:Q,onChange:e=>X(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(tt,{icon:M,label:t.modelsTitle,value:String(Y.modelRows.length)}),(0,Z.jsx)(tt,{icon:C,label:t.toolsTitle,value:String(Object.keys(Y.toolPolicies).length)}),(0,Z.jsx)(tt,{icon:S,label:t.skillsTitle,value:t.skillModeLabels[Y.skillMode]})]})]}):null,q===`models`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:M,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(pe,{rows:Y.modelRows,onChange:e=>X(t=>({...t,modelRows:e})),disabled:Q,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{defaultTitle:t.modelDefaultTitle,defaultHint:t.modelDefaultHint,defaultBadge:t.modelDefaultBadge,roleId:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,moreSettings:t.modelMoreSettings,otherRolesTitle:t.modelOtherRolesTitle,otherRolesHint:t.modelOtherRolesHint,otherRolesEmpty:t.modelOtherRolesEmpty,addTaskModel:t.modelAddTaskModel,customRole:t.modelCustomRole,removeRole:t.removeModelRole,roleIdPlaceholder:`custom-role`,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,Z.jsx)(nt,{value:Y.modelAdvanced,onChange:e=>X(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,q===`tools`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:C,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(Te,{builtinToolIds:m?.builtinToolIds??[],toolPolicies:Y.toolPolicies,onChange:e=>X(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ge,getGroupTitle:We,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,q===`skills`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:S,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(ge,{mode:Y.skillMode,selected:Y.skillPick,catalog:I,loading:R,disabled:Q,onModeChange:e=>X(t=>({...t,skillMode:e})),onSelectedChange:e=>X(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,q===`advanced`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:j,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(me,{extendsIds:Y.extendsIds,onExtendsChange:e=>X(t=>({...t,extendsIds:e})),presetOptions:Ee.filter(e=>e.id!==$?.id&&e.id!==De),jsonFields:Y.jsonFields,onJsonFieldsChange:e=>X(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,q===`impact`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:O,title:t.usageTitle,subtitle:t.usageHint}),(0,Z.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Le.length>0?t.changePreviewSections.replace(`{{sections}}`,Le.join(`、`)):t.changePreviewEmpty})]}),$?.usage.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:Pe?t.unsavedTitle:t.noUnsavedTitle}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Pe?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Pe?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>X(Be($)),children:t.discard}):null,$&&!Ne?(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{Se(null),be(!0)},children:[(0,Z.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(d,{type:`button`,disabled:Q||!Y.id.trim()||!Y.name.trim()||!Pe,onClick:()=>void it(),children:[(0,Z.jsx)(z,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(B,{open:ye,onOpenChange:e=>{Q||(be(e),e||Se(null))},children:(0,Z.jsxs)(k,{children:[(0,Z.jsx)(E,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,L)}),(0,Z.jsxs)(D,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,P),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsx)(h,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,Z.jsx)(g,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),xe?(0,Z.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:xe}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(d,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>be(!1),children:t.cancel}),(0,Z.jsxs)(d,{type:`button`,disabled:Q||!$,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void at(),children:[Q?(0,Z.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(y,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(H,{gap:`gap-3`,children:[(0,Z.jsx)(V,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function tt(e){let t=(0,ue.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function nt(e){let t=(0,ue.c)(121),{value:n,onChange:r,disabled:i,cp:a,chat:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c,isLoading:l,error:d}=u(`capability-preset-image-generation-models`,X,s),f;t[1]===c?f=t[2]:(f=(c??[]).filter(at).flatMap(it),t[1]=c,t[2]=f);let p=f,m;t[3]===p?m=t[4]:(m=new Set(p.map(rt)),t[3]=p,t[4]=m);let h=m,g,_;t[5]!==h||t[6]!==c||t[7]!==r||t[8]!==n?(g=()=>{if(!c)return;let e=n.imageGenerationModel,t=h.has(e.primary)?e.primary:``,i=e.fallbacks.filter(e=>h.has(e));t===e.primary&&i.length===e.fallbacks.length||r({...n,imageGenerationModel:{...e,primary:t,fallbacks:i}})},_=[h,c,r,n],t[5]=h,t[6]=c,t[7]=r,t[8]=n,t[9]=g,t[10]=_):(g=t[9],_=t[10]),(0,de.useEffect)(g,_);let v;t[11]!==r||t[12]!==n?(v=(e,t)=>{r({...n,[e]:t})},t[11]=r,t[12]=n,t[13]=v):v=t[13];let y=v,b;t[14]===a.modelSpecializedTitle?b=t[15]:(b=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[14]=a.modelSpecializedTitle,t[15]=b);let x;t[16]!==a.modelNotSet||t[17]!==a.modelSpecializedSummary||t[18]!==n.imageGenerationModel.primary||t[19]!==n.imageModel.primary?(x=a.modelSpecializedSummary.replace(`{{image}}`,n.imageModel.primary||a.modelNotSet).replace(`{{generation}}`,n.imageGenerationModel.primary||a.modelNotSet),t[16]=a.modelNotSet,t[17]=a.modelSpecializedSummary,t[18]=n.imageGenerationModel.primary,t[19]=n.imageModel.primary,t[20]=x):x=t[20];let S;t[21]===x?S=t[22]:(S=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:x}),t[21]=x,t[22]=S);let C;t[23]!==b||t[24]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[b,S]}),t[23]=b,t[24]=S,t[25]=C):C=t[25];let w;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(R,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=w):w=t[26];let T;t[27]===C?T=t[28]:(T=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[C,w]}),t[27]=C,t[28]=T);let E;t[29]===y?E=t[30]:(E=e=>y(`imageModel`,e),t[29]=y,t[30]=E);let D;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==E||t[35]!==n.imageModel?(D=(0,Z.jsx)(ot,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:E,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=E,t[35]=n.imageModel,t[36]=D):D=t[36];let O;t[37]===y?O=t[38]:(O=e=>y(`imageGenerationModel`,e),t[37]=y,t[38]=O);let k;t[39]===a.modelImageSettingsLink?k=t[40]:(k={label:a.modelImageSettingsLink,path:`/settings/capabilities/image`},t[39]=a.modelImageSettingsLink,t[40]=k);let A;t[41]!==o||t[42]!==a||t[43]!==i||t[44]!==p||t[45]!==d||t[46]!==l||t[47]!==O||t[48]!==k||t[49]!==n.imageGenerationModel?(A=(0,Z.jsx)(ot,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:O,disabled:i,cp:a,chat:o,models:p,modelsLoading:l,modelsError:d,noMatches:a.modelNoConfiguredImageModels,settingsFooterLink:k}),t[41]=o,t[42]=a,t[43]=i,t[44]=p,t[45]=d,t[46]=l,t[47]=O,t[48]=k,t[49]=n.imageGenerationModel,t[50]=A):A=t[50];let j;t[51]!==D||t[52]!==A?(j=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[D,A]}),t[51]=D,t[52]=A,t[53]=j):j=t[53];let M;t[54]!==T||t[55]!==j?(M=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[T,j]}),t[54]=T,t[55]=j,t[56]=M):M=t[56];let ee;t[57]===a.modelAdvancedTitle?ee=t[58]:(ee=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[57]=a.modelAdvancedTitle,t[58]=ee);let P;t[59]===a.modelAdvancedHint?P=t[60]:(P=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[59]=a.modelAdvancedHint,t[60]=P);let F;t[61]!==ee||t[62]!==P?(F=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[ee,P]}),t[61]=ee,t[62]=P,t[63]=F):F=t[63];let I;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(R,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=I):I=t[64];let L;t[65]===F?L=t[66]:(L=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[F,I]}),t[65]=F,t[66]=L);let z;t[67]===a.modelAllowFallbacksLabel?z=t[68]:(z=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[67]=a.modelAllowFallbacksLabel,t[68]=z);let B;t[69]!==r||t[70]!==n?(B=e=>r({...n,allowFallbacks:e.target.value}),t[69]=r,t[70]=n,t[71]=B):B=t[71];let V;t[72]===a.policyInherit?V=t[73]:(V=(0,Z.jsx)(N,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=V);let H;t[74]===a.policyEnabled?H=t[75]:(H=(0,Z.jsx)(N,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=H);let ne;t[76]===a.policyDisabled?ne=t[77]:(ne=(0,Z.jsx)(N,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=ne);let U;t[78]!==i||t[79]!==B||t[80]!==V||t[81]!==H||t[82]!==ne||t[83]!==n.allowFallbacks?(U=(0,Z.jsxs)(te,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:B,children:[V,H,ne]}),t[78]=i,t[79]=B,t[80]=V,t[81]=H,t[82]=ne,t[83]=n.allowFallbacks,t[84]=U):U=t[84];let W;t[85]!==z||t[86]!==U?(W=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[z,U]}),t[85]=z,t[86]=U,t[87]=W):W=t[87];let G;t[88]===a.modelMaxCostTierLabel?G=t[89]:(G=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=G);let K;t[90]!==r||t[91]!==n?(K=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=K):K=t[92];let re;t[93]===a.policyInherit?re=t[94]:(re=(0,Z.jsx)(N,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=re);let ie;t[95]===a.costTierLow?ie=t[96]:(ie=(0,Z.jsx)(N,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ie);let ae;t[97]===a.costTierMedium?ae=t[98]:(ae=(0,Z.jsx)(N,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=ae);let oe;t[99]===a.costTierHigh?oe=t[100]:(oe=(0,Z.jsx)(N,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=oe);let se;t[101]!==i||t[102]!==K||t[103]!==re||t[104]!==ie||t[105]!==ae||t[106]!==oe||t[107]!==n.maxCostTier?(se=(0,Z.jsxs)(te,{value:n.maxCostTier,disabled:i,side:`top`,onChange:K,children:[re,ie,ae,oe]}),t[101]=i,t[102]=K,t[103]=re,t[104]=ie,t[105]=ae,t[106]=oe,t[107]=n.maxCostTier,t[108]=se):se=t[108];let ce;t[109]!==G||t[110]!==se?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[G,se]}),t[109]=G,t[110]=se,t[111]=ce):ce=t[111];let le;t[112]!==W||t[113]!==ce?(le=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[W,ce]}),t[112]=W,t[113]=ce,t[114]=le):le=t[114];let q;t[115]!==L||t[116]!==le?(q=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[L,le]}),t[115]=L,t[116]=le,t[117]=q):q=t[117];let J;return t[118]!==M||t[119]!==q?(J=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[M,q]}),t[118]=M,t[119]=q,t[120]=J):J=t[120],J}function rt(e){return e.id}function it(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function at(e){return e.configured||e.credentialMode===`none`}function ot(e){let t=(0,ue.c)(109),{title:n,value:r,onChange:i,disabled:a,cp:o,chat:s,capabilitiesFilter:c,models:l,modelsLoading:u,modelsError:f,noMatches:p,settingsFooterLink:m}=e,h;t[0]!==i||t[1]!==r?(h=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=h):h=t[2];let g=h,v;t[3]===n?v=t[4]:(v=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=v);let b=r.primary||o.modelNotSet,S;t[5]===b?S=t[6]:(S=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:b}),t[5]=b,t[6]=S);let C;t[7]!==v||t[8]!==S?(C=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[v,S]}),t[7]=v,t[8]=S,t[9]=C):C=t[9];let w;t[10]===o.modelToolPrimaryLabel?w=t[11]:(w=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=w);let T=p??s.modelNoMatches,E;t[12]!==i||t[13]!==r?(E=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=E):E=t[14];let D;t[15]!==c||t[16]!==s.modelPlaceholder||t[17]!==s.modelSearchPlaceholder||t[18]!==a||t[19]!==l||t[20]!==f||t[21]!==u||t[22]!==m||t[23]!==T||t[24]!==E||t[25]!==r.primary?(D=(0,Z.jsx)(_,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:T,models:l,modelsLoading:u,modelsError:f,settingsFooterLink:m,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:E}),t[15]=c,t[16]=s.modelPlaceholder,t[17]=s.modelSearchPlaceholder,t[18]=a,t[19]=l,t[20]=f,t[21]=u,t[22]=m,t[23]=T,t[24]=E,t[25]=r.primary,t[26]=D):D=t[26];let O;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(O=r.primary?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(x,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=O):O=t[31];let k;t[32]!==D||t[33]!==O?(k=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[D,O]}),t[32]=D,t[33]=O,t[34]=k):k=t[34];let A;t[35]!==k||t[36]!==w?(A=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[w,k]}),t[35]=k,t[36]=w,t[37]=A):A=t[37];let j;t[38]===o.modelToolFallbacksLabel?j=t[39]:(j=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=j);let M;t[40]!==i||t[41]!==r?(M=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=M):M=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(ee,{className:`size-3.5`,strokeWidth:1.75}),t[43]=P):P=t[43];let F;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==M?(F=(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:M,children:[P,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=M,t[47]=F):F=t[47];let I;t[48]!==j||t[49]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[j,F]}),t[48]=j,t[49]=F,t[50]=I):I=t[50];let L;t[51]!==c||t[52]!==s.modelNoMatches||t[53]!==s.modelSearchPlaceholder||t[54]!==o.modelFallbackEmptyHint||t[55]!==o.modelFallbackPlaceholder||t[56]!==o.modelRemoveFallback||t[57]!==a||t[58]!==l||t[59]!==f||t[60]!==u||t[61]!==p||t[62]!==i||t[63]!==m||t[64]!==g||t[65]!==r?(L=r.fallbacks.length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:r.fallbacks.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(_,{value:e,disabled:a,placeholder:o.modelFallbackPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:p??s.modelNoMatches,models:l,modelsLoading:u,modelsError:f,settingsFooterLink:m,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>g(t,e)}),(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelRemoveFallback,onClick:()=>i({...r,fallbacks:r.fallbacks.filter((e,n)=>n!==t)}),children:(0,Z.jsx)(y,{className:`size-4`,strokeWidth:1.75})})]},`fallback-${t}`))}):(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-xs text-fg-muted`,children:o.modelFallbackEmptyHint}),t[51]=c,t[52]=s.modelNoMatches,t[53]=s.modelSearchPlaceholder,t[54]=o.modelFallbackEmptyHint,t[55]=o.modelFallbackPlaceholder,t[56]=o.modelRemoveFallback,t[57]=a,t[58]=l,t[59]=f,t[60]=u,t[61]=p,t[62]=i,t[63]=m,t[64]=g,t[65]=r,t[66]=L):L=t[66];let R;t[67]!==I||t[68]!==L?(R=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[I,L]}),t[67]=I,t[68]=L,t[69]=R):R=t[69];let z;t[70]!==i||t[71]!==r?(z=e=>i({...r,timeoutMs:e.target.value}),t[70]=i,t[71]=r,t[72]=z):z=t[72];let B;t[73]!==a||t[74]!==z||t[75]!==r.timeoutMs?(B=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:z}),t[73]=a,t[74]=z,t[75]=r.timeoutMs,t[76]=B):B=t[76];let V;t[77]!==o.toolTimeoutLabel||t[78]!==B?(V=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.toolTimeoutLabel,B]}),t[77]=o.toolTimeoutLabel,t[78]=B,t[79]=V):V=t[79];let H;t[80]!==i||t[81]!==r?(H=e=>i({...r,autoProviderFallback:e.target.value}),t[80]=i,t[81]=r,t[82]=H):H=t[82];let ne;t[83]===o.policyInherit?ne=t[84]:(ne=(0,Z.jsx)(N,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=ne);let U;t[85]===o.policyEnabled?U=t[86]:(U=(0,Z.jsx)(N,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=U);let W;t[87]===o.policyDisabled?W=t[88]:(W=(0,Z.jsx)(N,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=W);let G;t[89]!==a||t[90]!==H||t[91]!==ne||t[92]!==U||t[93]!==W||t[94]!==r.autoProviderFallback?(G=(0,Z.jsxs)(te,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:H,children:[ne,U,W]}),t[89]=a,t[90]=H,t[91]=ne,t[92]=U,t[93]=W,t[94]=r.autoProviderFallback,t[95]=G):G=t[95];let K;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==G?(K=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,G]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=G,t[98]=K):K=t[98];let re;t[99]!==V||t[100]!==K?(re=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[V,K]}),t[99]=V,t[100]=K,t[101]=re):re=t[101];let ie;t[102]!==A||t[103]!==R||t[104]!==re?(ie=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[A,R,re]}),t[102]=A,t[103]=R,t[104]=re,t[105]=ie):ie=t[105];let ae;return t[106]!==ie||t[107]!==C?(ae=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[C,ie]}),t[106]=ie,t[107]=C,t[108]=ae):ae=t[108],ae}export{et as CapabilityPresetsSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-CarlxqXV.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-sToMfHX_.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,As as g,Bo as _,Cs as v,Dc as y,Et as b,Gl as x,Go as S,Gs as C,Ho as w,Ns as T,Rr as E,To as D,Uo as O,Vo as k,Wo as A,ai as j,as as M,ii as N,io as P,ls as F,mu as I,nl as L,oa as R,pc as z,ri as ee,ro as B,tc as te,ts as ne,us as re,xc as ie,zo as ae}from"./index-2UImfRDC.js";import{n as oe,r as se}from"./settings-page-layout-Ddu2iGaW.js";import{n as ce}from"./settings-loading-skeleton-BbqH_S3Y.js";import{t as le}from"./schema-form-OXFkcZQe.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-BMRAO4zZ.js";import{t as pe}from"./use-channel-catalog-CA9BFVB7.js";var V=e(t(),1),H=n();function me(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var he=e(ue(),1),U=r();async function ge(e){let t=await d(f(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>me(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await ge({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),he.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||ge({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),m=K(c.payload,e.id),h=m?c.generatedQr:q(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,b=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(g,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(L,{className:`size-4 animate-spin`}):(0,U.jsx)(y,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(g,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(te,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,U.jsxs)(`div`,{className:s(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,U.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(B,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(B,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(B,{className:`h-4 w-36 max-w-full`})]}),m?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(x,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(I,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,v?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,U.jsx)(g,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ve=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ye(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function be(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ve,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function xe(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Se(e,t,n){let r=xe(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?s(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,F):s(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,F,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function we(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,y=n===`drawer`,[b,x]=(0,V.useState)(null),C;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,U.jsx)(O,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,re)}),t[0]=C):C=t[0];let E;t[1]!==n||t[2]!==h?(E=Ce(n,h),t[1]=n,t[2]=h,t[3]=E):E=t[3];let D;t[4]===c?D=t[5]:(D=c?(0,U.jsx)(S,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=D);let j;t[6]===l?j=t[7]:(j=l?(0,U.jsx)(w,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=j);let N;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==y||t[12]!==a?(N=y?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(_,{asChild:!0,children:(0,U.jsx)(g,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(T,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(_,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:s(v,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(T,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=y,t[12]=a,t[13]=N):N=t[13];let P=y?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=s(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==d||t[17]!==F?(I=(0,U.jsx)(`div`,{className:F,children:d}),t[16]=d,t[17]=F,t[18]=I):I=t[18];let L;t[19]!==f||t[20]!==b||t[21]!==D||t[22]!==j||t[23]!==N||t[24]!==I?(L=(0,U.jsxs)(M,{layer:`modal`,portalContainer:b,children:[D,j,N,I,f]}),t[19]=f,t[20]=b,t[21]=D,t[22]=j,t[23]=N,t[24]=I,t[25]=L):L=t[25];let R;t[26]!==L||t[27]!==E?(R=(0,U.jsxs)(A,{children:[C,(0,U.jsx)(k,{ref:x,className:E,onOpenAutoFocus:Te,children:L})]}),t[26]=L,t[27]=E,t[28]=R):R=t[28];let z;return t[29]!==i||t[30]!==r||t[31]!==R?(z=(0,U.jsx)(ae,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=z):z=t[32],z}function Te(e){return e.preventDefault()}var Ee=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(R,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function De(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(g,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(g,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let _=i?n.saving:n.save,v;t[13]!==m||t[14]!==h||t[15]!==_?(v=(0,U.jsx)(g,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:_}),t[13]=m,t[14]=h,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}var Oe=`channels-status`;function ke(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ae(e){let t=t=>e(t.detail);return window.addEventListener(Oe,t),()=>window.removeEventListener(Oe,t)}function je(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ae(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Me(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ne(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Pe=[`enabled`];async function Fe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Ie(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Le(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Re(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function ze(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Be(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ve(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Pe.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Pe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ye(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=Y(e),r=me(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Xe(e,t){let n=me(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Qe(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Ie(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(P,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=s(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=s(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,_,v,y,b,x;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let g;t[21]===n.label?g=t[22]:(g=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Be(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Re(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==g?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[g,w]}),t[31]=w,t[32]=g,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(et,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(x=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],h=`button`,_=l,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else m=t[12],h=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==h||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,U.jsx)(`button`,{type:h,onClick:_,className:v,children:y}),t[48]=h,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,U.jsx)(L,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(g,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,U.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function nt(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?I:n===`stopped`||n===`needs_setup`?o:L,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==m||t[1]!==h||t[2]!==_||t[3]!==v||t[4]!==y?(b=s(`mt-0.5 size-5 shrink-0`,m,h,_,v,y),t[0]=m,t[1]=h,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==p||t[7]!==b?(x=(0,U.jsx)(p,{className:b}),t[6]=p,t[7]=b,t[8]=x):x=t[8];let S;t[9]===l.connectionStatus?S=t[10]:(S=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=S);let C;t[11]!==l||t[12]!==n?(C=ze(n,l),t[11]=l,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,U.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,U.jsx)(L,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?l.checkingConnection:l.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(g,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(L,{className:`size-4 animate-spin`}):(0,U.jsx)(ie,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=c?(0,U.jsx)(g,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function at(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(C,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:Qe(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=a(),{channelId:o}=i(),p=j(o),g=pe(n,e),_=g.entries,{data:v,mutate:y,isValidating:S}=m(n?fe():null,de,{revalidateOnFocus:!0}),{data:C,mutate:w}=m(n?`channels-config-map`:null,Fe,{revalidateOnFocus:!1}),T=C?.channels??{},O=C?.bindings??[],{data:k}=m(n?`channel-routing-agents`:null,h,{revalidateOnFocus:!1}),A=D(e=>e.setPageHeader),M=D(e=>e.clearPageHeader),P=(0,V.useMemo)(()=>_.find(e=>e.id===p),[p,_]),F=P?Le(P):null,{data:I,mutate:L}=m(n&&F?Me(F):null,()=>Ne(F)),[R,B]=(0,V.useState)(null),[te,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[he,ge]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),ve=R??I??{},J=t.channelsSettings,xe=(0,V.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),Ce=(0,V.useMemo)(()=>We(xe,Pe),[xe]),Te=(0,V.useMemo)(()=>Ve(P),[P]),Oe=(0,V.useMemo)(()=>He(Ce,Te),[Te,Ce]),Ae=(0,V.useMemo)(()=>We(Ce,Te),[Te,Ce]),Ie=(0,V.useMemo)(()=>Ge(Oe),[Oe]),ze=P?K??ye(O,P.id):``,X=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=E(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Z=k?.items.find(e=>e.id===k.defaultId),Ue=Z?E(Z,t.agentsSettings):k?.defaultId??``,Ke=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),qe=(0,V.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,V.useCallback)(e=>Se(e,qe.get(e.id),Je),[qe,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([g.mutate(),y()])},[g,y]);je((0,V.useCallback)(e=>{let t=ke(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Ee,{ch:J,refreshing:g.isValidating||S,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,J,n,S,Q]);(0,V.useLayoutEffect)(()=>(A({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,A]);let Ze=(0,V.useCallback)(e=>{r(N(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(ee),B(null),q(null),G(null)},[r]),nt=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await d(f(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),ge(!1)},[P?.id]);let rt=(0,V.useCallback)(async()=>{if(!P||!R&&K===null)return!1;let e=Le(P);re(!0),G(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:be(O,P.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await L(R,!1),await w(),await g.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[P,K,O,g,R,w,L]),ot=(0,V.useCallback)(async e=>{let t=Y(e),n=Le(e),r=P?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await g.mutate(),await w(),await y(),P?.id===e.id&&(await L(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[P?.id,g,R,w,L,y,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!Y(P).ready||he:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[g.isLoading?(0,U.jsx)(ce,{sections:2}):g.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,U.jsx)(tt,{entry:e,config:T[Le(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(we,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:P?.label??J.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,U.jsx)(De,{ch:J,dirty:!!R||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(null),q(null)},onSave:rt}):null,children:P?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)($e,{entry:P}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,U.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Be(ct)),children:Re(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(P).ready&&me(P)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,U.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(x,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(P).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(et,{checked:Y(P).enabled,disabled:ie===P.id,label:J.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void ot(P)})]})]})}),(0,U.jsx)(it,{runtime:ct,restarting:ue===P.id,checking:S,showConnectionOptions:he,canManageConnection:Y(P).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void nt(P),onCheck:()=>void Q(),onManageConnection:()=>ge(e=>!e)}),(0,U.jsx)(at,{entry:P,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(_e,{entry:P,locale:e,messages:J,compact:!0,onChanged:async()=>{await L(),await Q(),await w()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(b,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:ve}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(b,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:ve}}):null,st&&Ie?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:Oe,values:ve,onChange:e=>B(e),disabled:te,labels:Ke})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(z,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(ne,{value:ze,options:X,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,Ue||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!k,onChange:e=>q(e)})]})]}),st&&Ge(Ae)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(z,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Ae,values:ve,onChange:e=>B(e),disabled:te,labels:Ke})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
@@ -1 +0,0 @@
1
- import{r as e}from"./locale-store-sToMfHX_.js";import{n as t}from"./channel-recipient-api-BKTUZDp-.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-CarlxqXV.js";import{l as u,n as d,r as f,s as p}from"./locale-store-sToMfHX_.js";import{$s as m,As as h,Bi as g,Bo as _,Cc as v,Ci as y,Ei as b,Gl as x,Go as S,Hi as C,Ho as w,Ko as T,Ks as E,Mc as D,Nc as O,Ns as k,Pc as A,Ps as j,Rs as M,Si as N,To as P,Uc as F,Ui as I,Uo as ee,Vi as L,Vo as te,Wi as R,Wo as ne,Xl as z,_l as B,au as V,gc as re,is as H,iu as ie,jc as ae,ks as U,ls as oe,mc as se,mu as ce,nc as le,nl as W,no as ue,ns as de,oa as fe,pc as pe,to as me,ts as he,uc as ge,us as _e,vu as ve,wi as ye,ws as G,xi as K,xs as q,yc as J,zc as be,zl as xe,zo as Y}from"./index-2UImfRDC.js";import{t as Se}from"./page-tabs-cOEOQqHh.js";import{A as Ce,C as we,D as Te,E as Ee,M as De,N as Oe,O as ke,P as Ae,S as je,T as Me,_ as Ne,a as Pe,b as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,i as Ve,j as He,k as Ue,l as We,m as Ge,n as Ke,o as qe,p as Je,r as Ye,s as Xe,t as Ze,u as Qe,v as $e,w as et,x as tt,y as nt}from"./connector-logo-Pr4RIKjj.js";var X=e(t(),1),Z=n(),Q=r();function rt(e){let t=(0,Z.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,m,g,_,v;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o.connect||t[5]!==o.connectedBadge||t[6]!==o.connectorBeta||t[7]!==o.connectorCapabilityLabels||t[8]!==o.connectorExperimental||t[9]!==o.connectorVerified){let e=n.capabilities.filter(it),y=e.slice(0,3),b=Math.max(0,e.length-y.length),x=o.connect,S=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,C;t[20]!==x||t[21]!==n||t[22]!==i?(C=e=>(0,Q.jsxs)(h,{type:`button`,variant:`primary`,className:s(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Q.jsx)(F,{className:`size-4`}),x]}),t[20]=x,t[21]=n,t[22]=i,t[23]=C):C=t[23],c=C;let w;t[24]!==n||t[25]!==a?(w=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=w):w=t[26];let T=w,E=a?`cursor-pointer`:null;t[27]===E?p=t[28]:(p=s(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=p),m=a?`button`:void 0,g=a?0:void 0,t[29]!==n||t[30]!==a?(_=()=>a?.(n),t[29]=n,t[30]=a,t[31]=_):_=t[31],v=T,l=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n?D=t[33]:(D=(0,Q.jsx)(Ze,{connector:n}),t[32]=n,t[33]=D);let O;t[34]===n.displayName?O=t[35]:(O=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=O);let k;t[36]===S?k=t[37]:(k=S?(0,Q.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:S}):null,t[36]=S,t[37]=k);let A;t[38]!==O||t[39]!==k?(A=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==D||t[42]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,A]}),t[41]=D,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==r||t[45]!==c?(M=r?null:(0,Q.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=M):M=t[46];let N;t[47]!==r||t[48]!==o.connectedBadge?(N=r?(0,Q.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,Q.jsx)(ce,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=N):N=t[49];let P;t[50]!==M||t[51]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[M,N]}),t[50]=M,t[51]=N,t[52]=P):P=t[52],t[53]!==j||t[54]!==P?(u=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,P]}),t[53]=j,t[54]=P,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=y.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[y.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),b>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,b]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o.connect,t[5]=o.connectedBadge,t[6]=o.connectorBeta,t[7]=o.connectorCapabilityLabels,t[8]=o.connectorExperimental,t[9]=o.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m,t[17]=g,t[18]=_,t[19]=v}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],g=t[17],_=t[18],v=t[19];let y;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(y=(0,Q.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=y):y=t[62];let b;t[63]!==r||t[64]!==c?(b=r?null:(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=b):b=t[65];let x;return t[66]!==y||t[67]!==b||t[68]!==p||t[69]!==m||t[70]!==g||t[71]!==_||t[72]!==v?(x=(0,Q.jsxs)(`div`,{className:p,role:m,tabIndex:g,onClick:_,onKeyDown:v,children:[y,b]}),t[66]=y,t[67]=b,t[68]=p,t[69]=m,t[70]=g,t[71]=_,t[72]=v,t[73]=x):x=t[73],x}function it(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var at=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ot(e,t){return t.some(t=>t.connectorId===e.id)}var st=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ct(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,st)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.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,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-4 min-w-0 flex-1`,st)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-[4.5rem] shrink-0 rounded-lg`,st)})]}),(0,Q.jsx)(`div`,{className:s(`h-3 w-full`,st)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-[88%]`,st)})]})]})}),e[1]=n):n=e[1],n}var lt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ut(){let e=(0,Z.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,lt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-4 w-48 max-w-full`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-72 max-w-full`,lt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,lt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-8 w-20 rounded-md`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-24 rounded-md`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-28 rounded-md`,lt)})]}),(0,Q.jsx)(`div`,{className:s(`mt-3 h-20 rounded-xl`,lt)})]}),e[3]=i):i=e[3],i}function dt(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function ft(e,t){return t.connectorCapabilityLabels[e]??e}function pt(e,t){if(e.runtime.type===`mcp`)return dt(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return dt(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function mt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function ht(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function gt(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(_t),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function _t(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function vt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),f=ht(e),p=e.capabilities.slice(0,8),m=Math.max(0,e.capabilities.length-p.length),g=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],v=async()=>{o(!0),d(null);try{l(await Fe(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Q.jsx)(Y,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(te,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:e,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md 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,Q.jsx)(ce,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(S,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(w,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?dt(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:mt(e,i)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:dt(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:ft(e,i)},e)),m>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,m]}):null]})]}),u?(0,Q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(gt,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(gt,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(gt,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??dt(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(B,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:mt(e,i)})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),g.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:g.map(e=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:pt(e,i)})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsx)(h,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(h,{variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(j,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(h,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(A,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(h,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(F,{className:`size-4`}),i.connect]})]})]})]})})}var yt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U);function bt(e){let t=(0,Z.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Q.jsx)(D,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let g;t[5]===l.runtimeSettingsTitle?g=t[6]:(g=(0,Q.jsx)(S,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let v;t[7]===l.runtimeSettingsHint?v=t[8]:(v=(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=v);let y;t[9]!==g||t[10]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[m,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[g,v]})]}),t[9]=g,t[10]=v,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),t[12]=b):b=t[12];let x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=x):x=t[13];let C;t[14]===l.modalClose?C=t[15]:(C=(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:b,"aria-label":l.modalClose,children:x})}),t[14]=l.modalClose,t[15]=C);let T;t[16]!==C||t[17]!==y?(T=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[y,C]}),t[16]=C,t[17]=y,t[18]=T):T=t[18];let E;t[19]===u.idleTtlLabel?E=t[20]:(E=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=E);let O;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(O=s(yt,`w-40 flex-none`),t[21]=O):O=t[21];let A=r??``,j;t[22]===a?j=t[23]:(j=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=j);let M;t[24]!==u.idleTtlPlaceholder||t[25]!==A||t[26]!==j?(M=(0,Q.jsx)(`input`,{type:`number`,min:0,className:O,value:A,placeholder:u.idleTtlPlaceholder,onChange:j}),t[24]=u.idleTtlPlaceholder,t[25]=A,t[26]=j,t[27]=M):M=t[27];let N;t[28]===u.idleTtlHint?N=t[29]:(N=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=N);let P;t[30]!==E||t[31]!==M||t[32]!==N?(P=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[E,M,N]})}),t[30]=E,t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(F=(0,Q.jsx)(h,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=F):F=t[37];let I;t[38]===o?I=t[39]:(I=()=>void o(),t[38]=o,t[39]=I);let L;t[40]===i?L=t[41]:(L=i?(0,Q.jsx)(W,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=L);let R;t[42]!==u.save||t[43]!==i||t[44]!==I||t[45]!==L?(R=(0,Q.jsxs)(h,{type:`button`,variant:`primary`,disabled:i,onClick:I,children:[L,u.save]}),t[42]=u.save,t[43]=i,t[44]=I,t[45]=L,t[46]=R):R=t[46];let z;t[47]!==F||t[48]!==R?(z=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[F,R]}),t[47]=F,t[48]=R,t[49]=z):z=t[49];let B;t[50]!==T||t[51]!==P||t[52]!==z?(B=(0,Q.jsxs)(ne,{children:[f,(0,Q.jsxs)(te,{className:p,children:[T,P,z]})]}),t[50]=T,t[51]=P,t[52]=z,t[53]=B):B=t[53];let V;return t[54]!==n||t[55]!==d||t[56]!==B?(V=(0,Q.jsx)(Y,{open:n,onOpenChange:d,children:B}),t[54]=n,t[55]=d,t[56]=B,t[57]=V):V=t[57],V}var xt=(0,X.memo)(function(e){let t=(0,Z.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=s(`relative flex min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface`,a),t[0]=a,t[1]=o);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Q.jsxs)(`label`,{className:o,children:[c,u]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}),St=(0,X.memo)(function(e){let t=(0,Z.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(pe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Q.jsxs)(h,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(ae,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(ve,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=g):g=t[8];let _;t[9]===a?_=t[10]:(_=(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsxs)(h,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,g]})}),t[9]=a,t[10]=_);let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,G.transition),t[11]=v):v=t[11];let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(m,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=x):x=t[12];let S;t[13]!==o||t[14]!==n?(S=(0,Q.jsxs)(N,{className:v,onSelect:n,children:[x,o]}),t[13]=o,t[14]=n,t[15]=S):S=t[15];let C;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,G.transition),t[16]=C):C=t[16];let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(j,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=w):w=t[17];let T;t[18]!==c||t[19]!==r?(T=(0,Q.jsxs)(N,{className:C,onSelect:r,children:[w,c]}),t[18]=c,t[19]=r,t[20]=T):T=t[20];let E;t[21]!==T||t[22]!==S?(E=(0,Q.jsx)(y,{children:(0,Q.jsxs)(K,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[S,T]})}),t[21]=T,t[22]=S,t[23]=E):E=t[23];let D;t[24]!==E||t[25]!==_?(D=(0,Q.jsxs)(ye,{children:[_,E]}),t[24]=E,t[25]=_,t[26]=D):D=t[26];let O;return t[27]!==D||t[28]!==f?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,D]}),t[27]=D,t[28]=f,t[29]=O):O=t[29],O}),Ct=/^([^:=]+)[:=](.*)$/;function wt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Ct.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Tt(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function Et(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function Dt(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 Ot(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||Dt(t)&&(r[e]=t);return r}function kt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function At(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function jt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=kt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=At(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Tt(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function Mt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Et(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function Nt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function Pt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||Dt(t)?[]:[Mt(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function Ft(e){return jt(e)}async function It(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=jt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await p(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),me()}function Lt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Rt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function zt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function Bt(e,t){let n=await p(f(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Lt(n.payload.tools),i=Rt(n.payload.resources),a=zt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function Vt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Ht(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Ut(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),p=Ut(e),m=(0,X.useCallback)(async()=>{o(!0),f(null);try{let t=await Bt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),g=(0,X.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(h,{variant:`ghost`,disabled:s,onClick:()=>void g(),children:[s?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(E,{className:`size-4`}),t.removeServer]})]})]})]})}function Gt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Kt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Gt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function qt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Jt(e){let t=(0,Z.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,c]=(0,X.useState)(``),l;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Kt(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===o?d=t[8]:(d=o.trim(),t[7]=o,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=s(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,U),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,Q.jsxs)(`div`,{className:`relative`,children:[p,(0,Q.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==u||t[23]!==a||t[24]!==r?(y=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||qt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function Yt(e){let t=(0,Z.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ee,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,_e)}),t[0]=m):m=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=s(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,oe,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(j,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=v):v=t[2];let y;t[3]===a?y=t[4]:(y=(0,Q.jsxs)(S,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[v,a]}),t[3]=a,t[4]=y);let b;t[5]!==i||t[6]!==o||t[7]!==f.length?(b=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=b):b=t[8];let x;t[9]===b?x=t[10]:(x=(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:b}),t[9]=b,t[10]=x);let C;t[11]!==y||t[12]!==x?(C=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[y,x]}),t[11]=y,t[12]=x,t[13]=C):C=t[13];let T;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(k,{className:`size-4`,"aria-hidden":!0}),t[14]=T):T=t[14];let E;t[15]===d?E=t[16]:(E=(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:T})}),t[15]=d,t[16]=E);let D;t[17]!==C||t[18]!==E?(D=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[C,E]}),t[17]=C,t[18]=E,t[19]=D):D=t[19];let O;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(O=f.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(Jt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=O):O=t[27];let A;t[28]===d?A=t[29]:(A=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsx)(h,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=A);let M;t[30]!==D||t[31]!==O||t[32]!==A?(M=(0,Q.jsxs)(ne,{children:[m,(0,Q.jsxs)(te,{className:g,children:[D,O,A]})]}),t[30]=D,t[31]=O,t[32]=A,t[33]=M):M=t[33];let N;return t[34]!==r||t[35]!==n||t[36]!==M?(N=(0,Q.jsx)(Y,{open:n,onOpenChange:r,children:M}),t[34]=r,t[35]=n,t[36]=M,t[37]=N):N=t[37],N}var Xt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U);function Zt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function Qt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function $t(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function en({instance:e,t,onChanged:n}){let r=Zt(e),[i,o]=(0,X.useState)([]),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,g]=(0,X.useState)(null),[_,y]=(0,X.useState)([]),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)([]),[w,D]=(0,X.useState)(`read`),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(null),P=(0,X.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){j(!0),N(null);try{let[t,n,i,a,s,c,u,f]=await Promise.all([Be().catch(()=>[]),ze(r).catch(()=>[]),Ne(20).catch(()=>[]),Le(r).catch(()=>`read`),$e().catch(()=>[]),Qe(r).catch(()=>null),We(r).catch(()=>null),nt().catch(()=>[])]);o(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),D(a),p(s.filter(t=>t.connectorId===e.connectorId)),g(c?.policy??null),y(c?.agents??[]),x(u),C(f)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[e.connectorId,e.materialized,r]);(0,X.useEffect)(()=>{P()},[P]);let F=(0,X.useCallback)(async()=>{if(r){j(!0),N(null);try{let t=await ke(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(T()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);await Te((await Ae(r,t.connectionId)).id),await n?.(),await P()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[e.connectorId,P,n,r]),I=(0,X.useCallback)(async e=>{if(r){D(e);try{await Me(r,e),await P()}catch(e){N(e instanceof Error?e.message:String(e))}}},[P,r]),ee=(0,X.useCallback)(async(e,t)=>{j(!0),N(null);try{await we(e,t),await P()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[P]),L=(0,X.useCallback)(async e=>{if(r){N(null);try{g(await De(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),te=(0,X.useCallback)(e=>{m&&L({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[L,m]),R=(0,X.useCallback)(async e=>{j(!0),N(null);try{await e(),await P()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[P]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:A,onClick:()=>void F(),children:[A?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(B,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(h,{variant:`ghost`,disabled:A,onClick:()=>void P(),children:t.refresh})]})]}),M?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M}):null,b?(0,Q.jsxs)(`div`,{className:s(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,b.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Q.jsx)(`span`,{children:b.status===`connected`?$(t.composioHealthConnected,{count:String(b.activeConnections)}):b.status===`reauthorization_required`?t.composioHealthReconnect:b.status===`degraded`?$t(b,t):t.composioHealthDisconnected}),b.recovery===`none`?null:(0,Q.jsx)(h,{variant:`ghost`,disabled:A,onClick:()=>void(b.recovery===`retry`?P():F()),children:b.recovery===`retry`?t.composioRetry:t.connectOAuth}),b.status===`degraded`&&b.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:b.message}):null]}):null,m?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Q.jsxs)(de,{className:s(Xt,`mt-1 h-9 py-1`),value:w,onChange:e=>void I(e.currentTarget.value),children:[(0,Q.jsx)(H,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(H,{value:`write`,children:t.composioAccessReadWrite}),w===`admin`?(0,Q.jsx)(H,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:w===`read`?t.composioAccessReadHint:w===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(de,{className:s(Xt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void L({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(H,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(H,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(H,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>te(e.id),children:e.name},e.id))})]})]}):null,f.length?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:A,onClick:()=>void ee(e.id,`denied`),children:[(0,Q.jsx)(k,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(h,{disabled:A,onClick:()=>void ee(e.id,`approved`),children:[(0,Q.jsx)(a,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),i.length?i.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(()=>{let n=S.find(t=>t.connectionId===e.id);return n?(0,Q.jsx)(`p`,{className:s(`text-xs`,n.status===`failed`?`text-red-600`:`text-fg-subtle`),children:$(t.connectorLearningStatus,{status:n.status,count:String(n.candidatesCreated)})}):null})(),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),(0,Q.jsx)(`input`,{className:s(Xt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&R(()=>He(e.id,{alias:t.currentTarget.value}))}}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(h,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:A||e.isDefault,onClick:()=>void R(async()=>{await He(e.id,{isDefault:!0}),r&&await De(r,{selectedConnectionIds:[e.id]})}),children:(0,Q.jsx)(le,{className:s(`size-4`,e.isDefault&&`fill-current`)})}),(0,Q.jsx)(h,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void R(()=>tt(e.id)),children:(0,Q.jsx)(v,{className:`size-4`})}),(0,Q.jsx)(h,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:A,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&R(()=>et(e.id))},children:(0,Q.jsx)(E,{className:`size-4 text-red-500`})})]}),e.status===`active`?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(h,{variant:`secondary`,className:`flex-1`,disabled:A,onClick:()=>void R(async()=>{await Te(e.id),await n?.()}),children:[A?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(v,{className:`size-4`}),t.composioSyncNow]}),(0,Q.jsx)(h,{variant:`ghost`,disabled:A||!S.some(t=>t.connectionId===e.id),onClick:()=>void R(async()=>{let t=S.find(t=>t.connectionId===e.id)?.status!==`paused`;await Ee(e.id,t)}),children:S.find(t=>t.connectionId===e.id)?.status===`paused`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{className:`size-4`}),t.connectorLearningResume]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(be,{className:`size-4`}),t.connectorLearningPause]})})]}):null]},e.id)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Q.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-3`,children:(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Q.jsxs)(de,{className:s(Xt,`mt-1 h-9 py-1`),value:w,onChange:e=>void I(e.currentTarget.value),children:[(0,Q.jsx)(H,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(H,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(H,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Qt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var tn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U);function nn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function rn(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 an(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(e){let t=(0,Z.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(I,{children:[(0,Q.jsx)(R,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:r,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,Q.jsx)(L,{children:(0,Q.jsx)(g,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,c;t[2]===n?c=t[3]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,o]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}function sn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[g,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(null),[x,C]=(0,X.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[T,D]=(0,X.useState)(!1),[O,M]=(0,X.useState)(()=>rn(t,e)),[N,P]=(0,X.useState)(null),F=t?.setup.config??[],I=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&F.length>0&&(t?.setup.secrets??[]).length===0,L=y?y.toolCount:e.usage.lastToolCount,R=(0,X.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,ge,i.detailHealth],[`tools`,j,`${i.detailTools} ${y?y.toolCount:e.usage.lastToolCount??``}`],[`resources`,z,`${i.detailResources} ${y?y.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,xe,`${i.detailPrompts} ${y?y.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,B,i.detailPermissions]]:[[`permissions`,B,i.detailPermissions]];return I?[...t,[`config`,z,i.connectorConfigLabel]]:t},[y,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,I,i]),V=(0,X.useCallback)(async()=>{c(!0),P(null);try{let t=await Ce(e.instanceId);b(t),t.toolCount>0&&C(`tools`),r()}catch(e){P(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),re=(0,X.useCallback)(async()=>{u(!0),P(null);try{await je(e.instanceId),await r(),n()}catch(e){P(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),H=(0,X.useCallback)(async()=>{if(!(!t||!I)){f(!0),P(null);try{let n={};for(let e of t.setup.config??[]){let t=an(e.type,O[e.key]??``);t!==void 0&&(n[e.key]=t)}await Oe(e.instanceId,{config:n}),await r(),C(`health`)}catch(e){P(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[O,t,e.instanceId,r,I]),ie=(0,X.useCallback)(async()=>{m(!0),v(null),P(null);try{v((await Ue(e.connectorId)).recordIds.length),await r()}catch(e){P(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(Y,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(te,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(S,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[N?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:R.map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,className:s(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,x===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>C(e),children:[(0,Q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[x===`health`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Q.jsx)(`span`,{className:y?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:nn(y?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),y?.action?(0,Q.jsx)(`p`,{children:y.action}):null]}):null,x===`tools`?y?.tools.length?(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(y.tools.length)})}),(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>D(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.tools.slice(0,8).map(e=>(0,Q.jsx)(on,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:L?$(i.toolsLastCheckSummary,{count:String(L)}):i.toolsRunTestHint}),(0,Q.jsxs)(h,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),i.test]})]}):null,x===`resources`?y?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.resources.slice(0,8).map(e=>(0,Q.jsx)(on,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,x===`prompts`?y?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.prompts.slice(0,8).map(e=>(0,Q.jsx)(on,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,x===`permissions`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,x===`config`&&I?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:F.map(e=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Q.jsx)(`input`,{className:tn,value:O[e.key]??``,placeholder:e.placeholder,onChange:t=>M(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)(en,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),g===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(g)})})]}),(0,Q.jsxs)(h,{disabled:p,onClick:()=>void ie(),children:[p?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(z,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(h,{variant:`secondary`,onClick:n,children:i.modalClose}),x===`config`&&I?(0,Q.jsxs)(h,{variant:`primary`,disabled:d,onClick:()=>void H(),children:[d?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(J,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(h,{variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(h,{variant:`ghost`,disabled:l,onClick:()=>void re(),children:[l?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(E,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Yt,{open:T,onOpenChange:D,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:y?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var cn=[`understand`,`act`,`reach`];function ln(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 un(e){return ln(e)[0]??`act`}function dn(e,t){let n=t?un(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 fn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),m=(0,X.useCallback)(async()=>{l(!0),p(null);try{await Ce(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[e.instanceId,i]),g=(0,X.useCallback)(async()=>{d(!0),p(null);try{await je(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e)),d(!1)}},[e.instanceId,i]),_=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,v=e.usage.lastToolCount??0,y=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),b=dn(e,t).state,x=b===`ready`?{label:a.connectionReady,Icon:ce,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:b===`needs_setup`?{label:a.connectionNeedsSetup,Icon:o,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:ie,className:`border-edge bg-surface-base text-fg-muted`};return(0,Q.jsxs)(`div`,{className:s(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Q.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,x.className),children:[(0,Q.jsx)(x.Icon,{className:`size-3`,"aria-hidden":!0}),x.label]}),y?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,_]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(v)})})]}),f?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[b===`needs_setup`?(0,Q.jsxs)(h,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(o,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(h,{variant:`secondary`,disabled:c,onClick:()=>void m(),children:[c?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(h,{variant:`ghost`,disabled:u,onClick:()=>void g(),children:[u?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(E,{className:`size-4`}),a.remove]})]})]})]})}var pn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U),mn=s(pn,`min-h-28 font-mono`);function hn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function gn(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 _n(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(vn),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function vn(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function yn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,o=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,[l,u]=(0,X.useState)(!o),[d,f]=(0,X.useState)(o),[p,m]=(0,X.useState)(``),[g,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(!o)return;let e=!1;return Re().then(({configured:t})=>{e||u(t)}).catch(t=>{e||v(t instanceof Error?t.message:String(t))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[a.id,o]);let C=e.result?`complete`:e.installing?`health`:`configure`,E=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],D=(0,X.useCallback)(async()=>{let n=T(),i=o&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),v(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!l&&(await Ke(p),u(!0));let s={};for(let t of a.setup.config??[]){let n=gn(t.type,e.config[t.key]??``);n!==void 0&&(s[t.key]=n)}let d=e.store?await Ge(e.store.packageName,{secrets:e.secrets,config:s},e.store.version):await Je(a.id,{secrets:e.secrets,config:s,definition:a.source===`registry`?a:void 0}),f=null;try{if(o)if((c?await We(c).catch(()=>null):null)?.status===`connected`){i?.close();let e=await Ae(c);y&&await Te(e.id)}else{let e=await ke(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else i?i.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await Ae(c,e.connectionId);i?.close(),y&&await Te(t.id)}}catch(n){i?.close(),t({...e,installing:!1,result:d,health:null,error:n instanceof Error?n.message:String(n)}),await r(d);return}if(!o)try{f=await Ce(d.instanceId)}catch{f=null}t({...e,installing:!1,result:d,health:f}),await r(d)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[p,l,c,a,e,o,y,t,r]);return(0,Q.jsx)(Y,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(te,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:a,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(S,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(w,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Q.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:E.map((e,t)=>{let n=E.findIndex(e=>e.id===C);return(0,Q.jsxs)(`div`,{className:s(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&!l?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Q.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Q.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Q.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Q.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Q.jsx)(x,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(q,{className:`mt-3`,value:p,onChange:m,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,o?(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:y,onChange:e=>b(e.currentTarget.checked)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i.learnAfterConnect}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:i.learnAfterConnectHint})]})]}):null,e.store?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Q.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Q.jsx)(q,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Q.jsx)(`textarea`,{className:mn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Q.jsx)(`input`,{className:pn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Q.jsx)(W,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,g?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g}):null,e.result?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:hn(e.health?.status,i)})]}),e.health?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Q.jsx)(`div`,{children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Q.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Q.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Q.jsx)(_n,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(_n,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(_n,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Q.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Q.jsxs)(h,{variant:`primary`,disabled:!!e.result||e.installing||d||o&&!l&&!p.trim(),onClick:()=>void D(),children:[e.installing?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(ce,{className:`size-4`}):(0,Q.jsx)(F,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function bn(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function xn(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return Nt(r)}function Sn(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function Cn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U)}function wn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},g=async()=>{try{let e=await c();if(!e){window.alert(a);return}let t=wt(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:e}),t?(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Q.jsxs)(h,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void g(),children:[(0,Q.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:s(Cn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>f(t,{key:e.target.value})}),(0,Q.jsx)(`input`,{className:s(Cn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Q.jsx)(E,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Sn(e,t,u)))}),(0,Q.jsxs)(`button`,{type:`button`,className:s(`self-start text-sm text-accent hover:underline`,G.press),onClick:p,children:[`+ `,n]})]})}var Tn=[`stdio`,`sse`,`streamable-http`];function En(e){let t=(0,Z.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Q.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Dn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,U)}function On(e){let t=(0,Z.c)(29),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,c=o===void 0?`all`:o,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(de,{className:Dn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Tn.map(e=>(0,Q.jsx)(H,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(En,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:Dn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Q.jsx)(En,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:Dn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:Dn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(En,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:Dn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(En,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:s(Dn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:(0,Q.jsx)(En,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:s(Dn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Q.jsx)(wn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Q.jsx)(En,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:Dn(),value:Vt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Ht(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function kn(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function An(e){let t=(0,Z.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=kn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==o?(u=(0,Q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Q.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(I,{children:[(0,Q.jsx)(R,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:l,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,Q.jsx)(L,{children:(0,Q.jsx)(g,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function jn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,X.useState)(n),[m,g]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),[C,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)({status:`idle`}),[O,M]=(0,X.useState)(null),N=n.id.trim(),P=f.id.trim()!==N&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,F=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,I=f.id.trim().length>0&&!P&&!F&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),L=Ut(f),R=(0,X.useCallback)(async()=>{if(f.id.trim()){y(!0),x(null),D({status:`loading`});try{D({status:`ok`,tools:(await Bt(f.id.trim(),Ft(f))).tools})}catch(e){D({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},[f]),z=(0,X.useCallback)(async()=>{if(!(!I||m)){g(!0),x(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await It({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Ot(a)),await d(),u()}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[I,a,r,n.clientKey,t,u,d,N,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(te,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(S,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,G.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(k,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:L||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Q.jsx)(On,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),x(null)},idConflictMessage:P??F})]}),E.status===`ok`?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(j,{className:`size-4 text-accent`,"aria-hidden":!0}),E.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(E.tools.length))]}),E.tools.length>0?(0,Q.jsx)(h,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>M(E.tools),children:c.viewAllTools}):null]}),E.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:E.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(An,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,E.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E.message}):null,b?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b}):null,(0,Q.jsxs)(`details`,{open:C,onToggle:e=>T(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(ve,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Q.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Q.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Q.jsx)(On,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),x(null)}})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(h,{variant:`secondary`,disabled:!f.id.trim()||v,onClick:()=>void R(),children:[v?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(_,{asChild:!0,children:(0,Q.jsx)(h,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(h,{variant:`primary`,disabled:!I||m,onClick:()=>void z(),children:[m?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(ce,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),O?(0,Q.jsx)(Yt,{open:!0,onOpenChange:e=>{e||M(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:O,stripPrefix:`${f.id.trim()}__`}):null]}):null}function Mn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Nn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Pn(e,t,n){return e.filter(e=>Nn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Fn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function In(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var Ln=`all`,Rn=`builtin`,zn=`composio`,Bn=`xopc-store`;function Vn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function Hn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Un(){let e=l(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=u(e=>e.token),a=!!r,[o,c]=i(),[f,p]=(0,X.useState)(o.get(`tab`)===`connected`?`connected`:`discover`),m=(0,X.useRef)(!1),[g,_]=(0,X.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(1),[w,T]=(0,X.useState)(void 0),[E,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(!1),[N,F]=(0,X.useState)(``),[I,ee]=(0,X.useState)(Rn),[L,te]=(0,X.useState)(`name`),[R,ne]=(0,X.useState)(`all`),[z,B]=(0,X.useState)(null),[V,re]=(0,X.useState)(null),[H,ie]=(0,X.useState)(null),[ae,U]=(0,X.useState)(null),[oe,se]=(0,X.useState)(null),[ce,le]=(0,X.useState)(null),[de,pe]=(0,X.useState)(!1),[me,ge]=(0,X.useState)(void 0),[_e,ve]=(0,X.useState)(!1),{data:ye,mutate:G}=ue(a),K=ye?.payload?.config,q=(0,X.useMemo)(()=>K===void 0?null:Pt(K),[K]),J=q?.servers??[],be=g.instances.length+J.length;(0,X.useEffect)(()=>{q&&ge(q.sessionIdleTtlMinutes)},[q]);let xe=(0,X.useCallback)(async()=>{if(!r){_({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}_(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Pe(),qe(),Ve(``,12).catch(()=>null)]);_(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){_({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,X.useEffect)(()=>{xe()},[xe]),(0,X.useEffect)(()=>{if(!a||f!==`connected`)return;let e=!1,t=window.setTimeout(()=>{j(!0),Ve(O,50).then(t=>{e||_(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||j(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[a,O,f]),(0,X.useEffect)(()=>{m.current||g.loading||a&&!q||(p(be>0?`connected`:`discover`),m.current=!0)},[a,be,q,g.loading]);let Y=(0,X.useCallback)(e=>{m.current=!0,p(e)},[]),Ce=(0,X.useMemo)(()=>[{id:zn,displayName:t.composioSourceName},{id:Bn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),we=(0,X.useCallback)(async e=>{if(!a||I===Rn){_(e=>({...e,registryCatalog:[]})),C(1),T(void 0);return}let t=N.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=I===Ln?Ce:Ce.filter(e=>e.id===I);if(i.length!==0){y(!0),r?_(e=>({...e,error:null})):(C(1),T(void 0),_(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===zn){let e=await Ye({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Xe({q:t||void 0,page:n,pageSize:24,sort:L===`source`?`newest`:`downloads`});return{connectors:r.items.map(Vn),totalPages:r.meta.totalPages}})),a=Hn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));C(n),T(o),_(e=>({...e,registryCatalog:r?Hn([...e.registryCatalog,...a]):a}))}catch(e){_(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{y(!1)}}},[L,N,I,a,Ce]);(0,X.useEffect)(()=>{if(f!==`discover`||g.loading)return;if(I===Rn){_(e=>({...e,registryCatalog:[]})),C(1),T(void 0);return}let e=window.setTimeout(()=>{we()},N.trim()?350:0);return()=>window.clearTimeout(e)},[N,I,we,g.loading,f]);let Te=(0,X.useMemo)(()=>new Set(g.instances.map(e=>e.connectorId)),[g.instances]),Ee=(0,X.useMemo)(()=>new Map([...g.catalog,...g.registryCatalog].map(e=>[e.id,e])),[g.catalog,g.registryCatalog]);(0,X.useEffect)(()=>{if(g.loading)return;let e=o.get(`connector`),t=o.get(`instance`);if(!e&&!t)return;let n=g.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)m.current=!0,D(``),ie(n.instanceId),U(n),p(`connected`);else if(e){let t=Ee.get(e);if(!t)return;m.current=!0,ee(Rn),F(``),re(t),p(`discover`)}let r=new URLSearchParams(o);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),c(r,{replace:!0})},[Ee,o,c,g.instances,g.loading]);let De=(0,X.useCallback)(async e=>{x(!0),_(e=>({...e,error:null}));try{let t=await Ie(e);B(bn(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){_(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}},[]),Oe=(0,X.useMemo)(()=>new Set(g.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[g.instances]),ke=(0,X.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await It({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},Ot(K)),await G(),await xe()},[K,J,xe,q,G]),Ae=(0,X.useCallback)(()=>{le({mode:`add`,row:xn(J,Oe)})},[J,Oe]),je=(0,X.useCallback)(async()=>{if(!(!q||K===void 0||_e)){ve(!0);try{await It({sessionIdleTtlMinutes:me,servers:J},Ot(K)),await G(),pe(!1)}finally{ve(!1)}}},[K,J,n.saved,q,G,me,_e]),Me=P(e=>e.setPageHeader),Ne=P(e=>e.clearPageHeader),Fe=(0,X.useMemo)(()=>(0,Q.jsx)(St,{onBrowseCatalog:()=>Y(`discover`),onAddCustomServer:Ae,onOpenRuntimeSettings:()=>pe(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ae,Y]);(0,X.useLayoutEffect)(()=>(Me({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Fe}),()=>Ne()),[Ne,t.title,Fe,Me]);let Le=(0,X.useMemo)(()=>g.instances.map(e=>({instance:e,value:dn(e,Ee.get(e.connectorId))})),[Ee,g.instances]),Re=(0,X.useMemo)(()=>new Map(Le.map(({instance:e,value:t})=>[e.instanceId,t])),[Le]),ze=(0,X.useMemo)(()=>g.instances.filter(e=>Fn(e,E)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Re.get(e.instanceId)?.state??`checking`,i=Re.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[E,Re,g.instances]),Be=(0,X.useMemo)(()=>J.filter(e=>In(e,E)),[E,J]),He=ze.length+Be.length,Ue=(0,X.useMemo)(()=>g.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Mn(e)),[g.catalog]),We=(0,X.useMemo)(()=>I===Rn?Ue:I===Ln?Hn([...Ue,...g.registryCatalog]):g.registryCatalog,[Ue,I,g.registryCatalog]),Ge=(0,X.useMemo)(()=>Pn(R===`all`?We:We.filter(e=>ln(e).includes(R)),N,L),[L,N,We,R]),Ke=(0,X.useMemo)(()=>cn.filter(e=>We.some(t=>ln(t).includes(e))),[We]);(0,X.useEffect)(()=>{R!==`all`&&!Ke.includes(R)&&ne(`all`)},[Ke,R]);let Je=f===`discover`&&I!==Rn&&!!(w&&S<w),Ze=(0,X.useMemo)(()=>g.instances.find(e=>e.instanceId===H)??ae,[H,ae,g.instances]),Qe=(0,X.useMemo)(()=>[{value:Ln,label:t.discoverSourceAll},{value:Rn,label:t.discoverSourceBuiltin},...Ce.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ce]),$e=[{id:`connected`,label:t.tabConnected,count:be},{id:`discover`,label:t.tabDiscover}];return(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[a?null:(0,Q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(Se,{items:$e,activeTab:f,onChange:Y,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),g.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g.error}):null,f===`connected`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(xt,{value:E,onChange:D,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(fe,{className:`size-9 shrink-0 p-0`,loading:g.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:xe})]}),g.peopleGraph&&(g.peopleGraph.people.length>0||O)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(M,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(g.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(g.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(xt,{value:O,onChange:k,placeholder:t.peopleGraphSearchPlaceholder}),A?(0,Q.jsx)(W,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),g.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:g.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(g.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,g.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:at.slice(0,3).map(e=>(0,Q.jsx)(ut,{},e))}):be===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Q.jsx)(h,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Y(`discover`),children:t.addFromCatalog})]}):He===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[ze.map(e=>(0,Q.jsx)(fn,{instance:e,definition:Ee.get(e.connectorId),highlighted:e.instanceId===oe,onOpenDetails:e=>{se(null),ie(e.instanceId),U(e)},onChanged:xe,t},e.instanceId)),Be.map(e=>(0,Q.jsx)(Wt,{row:e,t:n,cs:t,onEdit:()=>le({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>ke(e)},e.clientKey))]})]}):null,f===`discover`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...Ke].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,R===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":R===e,onClick:()=>ne(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(xt,{value:N,onChange:F,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,Q.jsx)(he,{value:I,options:Qe,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee}),(0,Q.jsx)(he,{value:L,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>te(e)})]})]}),(g.loading||v)&&Ge.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:at.map(e=>(0,Q.jsx)(ct,{},e))}):Ge.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[v?(0,Q.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":t.loading,children:(0,Q.jsx)(W,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ge.map(e=>(0,Q.jsx)(rt,{connector:e,installed:Te.has(e.id)||ot(e,g.instances),onInstall:e=>{if(e.source===`store`){De(e.id);return}B(bn(e))},onOpenDetails:e.source===`store`?void 0:re,t},e.id))}),Je?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(h,{type:`button`,variant:`secondary`,disabled:v||b,onClick:()=>void we({page:S+1,append:!0}),children:[v?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),z?(0,Q.jsx)(yn,{draft:z,onChange:B,onClose:()=>B(null),t,onInstalled:async e=>{await xe(),await G(),se(e.instanceId),Y(`connected`)}}):null,V?(0,Q.jsx)(vt,{connector:V,installed:Te.has(V.id)||ot(V,g.instances),onClose:()=>re(null),onInstall:e=>B(bn(e)),t}):null,Ze?(0,Q.jsx)(sn,{instance:Ze,definition:Ee.get(Ze.connectorId),onClose:()=>{ie(null),U(null)},onChanged:xe,t,mcp:n}):null,ce?(0,Q.jsx)(jn,{open:!0,mode:ce.mode,initialRow:ce.row,existingCustomServers:J,sessionIdleTtlMinutes:me,config:K,managedServerIds:Oe,t:n,cs:t,onClose:()=>le(null),onSaved:async()=>{await G(),await xe(),Y(`connected`)}},`${ce.mode}-${ce.row.clientKey}`):null,(0,Q.jsx)(bt,{open:de,sessionIdleTtlMinutes:me,saving:_e,onChange:ge,onSave:je,onClose:()=>pe(!1),t,mcp:n})]})})}export{Un as ConnectorsPage};
@@ -1 +0,0 @@
1
- var e=e=>e===`zh`?{current:`当前关注事项`,candidates:`可能值得关注`,candidatesHint:`根据近期工作识别,确认后才会开始关注。`,progress:`进展监测`,external:`外部动态监测`,enableProgress:`开启进展监测`,enableExternal:`开启外部动态监测`,disableMonitor:`关闭监测`,enabled:`已开启`,disabled:`未开启`,queued:`等待运行`,running:`正在检查`,failed:`运行失败`,lastRun:`上次运行`,nextRun:`下次运行`,neverRun:`尚未运行`,runNow:`立即运行`,pause:`暂停关注`,resume:`恢复关注`,complete:`标记完成`,remove:`移除关注`,accept:`加入关注`,dismiss:`不关注`,details:`查看详情`,latest:`最新发现`,activity:`活动记录`,evidence:`证据`,why:`为什么重要`,next:`建议下一步`,investigate:`继续调查`,operationDone:`操作已完成`,monitorStarted:`监测已开启,首次检查已加入队列`,monitorStopped:`监测已关闭`,empty:`还没有关注事项`,emptyHint:`从建议中加入,或让助手识别值得持续关注的工作。`,back:`返回工作台`,retry:`重试`,deleteConfirm:`确定移除这个关注事项?相关监测和历史记录也会被删除。`,noActivity:`还没有活动记录`,noInsights:`尚未发现需要你关注的变化`}:{current:`Current focuses`,candidates:`Worth watching`,candidatesHint:`Detected from recent work. Nothing is monitored until you confirm.`,progress:`Progress monitoring`,external:`External change monitoring`,enableProgress:`Enable progress monitoring`,enableExternal:`Enable external monitoring`,disableMonitor:`Disable monitoring`,enabled:`Enabled`,disabled:`Not enabled`,queued:`Queued`,running:`Checking now`,failed:`Run failed`,lastRun:`Last run`,nextRun:`Next run`,neverRun:`Not run yet`,runNow:`Run now`,pause:`Pause focus`,resume:`Resume focus`,complete:`Mark complete`,remove:`Remove focus`,accept:`Add focus`,dismiss:`Dismiss`,details:`View details`,latest:`Latest findings`,activity:`Activity`,evidence:`Evidence`,why:`Why it matters`,next:`Suggested next step`,investigate:`Investigate`,operationDone:`Done`,monitorStarted:`Monitoring is enabled and the first check is queued`,monitorStopped:`Monitoring is disabled`,empty:`No focuses yet`,emptyHint:`Add one from suggestions or ask the assistant to find work worth watching.`,back:`Back to work`,retry:`Retry`,deleteConfirm:`Remove this focus? Its monitors and history will also be deleted.`,noActivity:`No activity yet`,noInsights:`No important changes found yet`};export{e as t};
@@ -1 +0,0 @@
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"./messages-CarlxqXV.js";import{n as a}from"./locale-store-sToMfHX_.js";import{Ns as o,t as s,vu as c}from"./index-2UImfRDC.js";import{t as l}from"./desktop-pet-sprite-DTqXSpqf.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function x(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function S(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function C(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function w(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+D:void 0}}function k(e,t){let n={...e};for(let e of t){let t=n[e.sessionKey];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.sessionKey]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function ee(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function j(e){return e?`/chat/${e.sessionKey}`:void 0}var M=r();function N(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??s(e.phase):`idle`}function P(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.sessionKey}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function F(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return P(r?.success,t);if(t.state===`waiting`)return P(r?.waiting,t);if(t.state===`error`)return P(r?.error,t)}function I(e,t,n){return e?n?`${e} · ${t}`:e:t}function L(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function R(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function z(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(R),[r,s]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[T,D]=(0,u.useState)(null),O=(0,u.useRef)(null),z=(0,u.useRef)(!1),B=(0,u.useRef)(null),V=(0,u.useRef)(null),H=(0,u.useRef)(null),U=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,u.useMemo)(()=>ee(Object.values(r),p),[r,p]),K=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,d[e.sessionKey])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,d[e.sessionKey])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=T??(J?N(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=w({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),s(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>s(t=>(_(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;D(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>D(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.sessionKey,e.runId),s(t=>{let{[e.sessionKey]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(j(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(O.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=O.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,D(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=O.current;!t||t.pointerId!==e.pointerId||(O.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(D(`released`),window.setTimeout(()=>D(null),700),z.current=!0,window.setTimeout(()=>{z.current=!1},0)))},[]),oe=()=>{z.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,M.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,M.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=S(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=x(t,e.tipCompleteSummary),i=C(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,s=I(F(U,t,Y),a,!!(r||n||i)),c=L(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,M.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,M.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,M.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,M.jsx)(`strong`,{children:t.sessionLabel}),(0,M.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,M.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,M.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.sessionKey,t.runId),f(e=>({...e,[t.sessionKey]:{runId:t.runId,state:t.state}}))},children:(0,M.jsx)(o,{size:12})})]},t.sessionKey)})}):null,X?(0,M.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,M.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,M.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,M.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,M.jsx)(`strong`,{children:e.idleTipTitle}),(0,M.jsx)(`span`,{children:P(U.persona?.phrases?.greeting??Y.greeting,{sessionKey:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,M.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,M.jsx)(o,{size:12})})]})}):null,(0,M.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,M.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,M.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,M.jsx)(c,{className:`desktop-pet-menu-chevron size-4`})}),(0,M.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&D(`greet`)},onPointerLeave:()=>{O.current||D(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,title:e.openApp,children:(0,M.jsx)(l,{pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)})})]})]})}function B(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(z,{}),e[0]=t):t=e[0],t}export{B as DesktopPetPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as o}from"./locale-store-sToMfHX_.js";import{As as s,Gl as c,Nc as l,Pu as u,Tc as d,To as f,mu as p,ro as m,vt as h}from"./index-2UImfRDC.js";import{c as g,d as _,i as v,n as y,o as b,r as x,t as S,u as C}from"./api-Bop4IQRW.js";import{t as w}from"./copy-VueTIC2x.js";var T=e(t(),1),E=n();function D(){let{focusId:e=``}=r(),t=i(),n=w(o(e=>e.language)),D=f(e=>e.setPageHeader),O=f(e=>e.clearPageHeader),[k,A]=(0,T.useState)(null),[j,M]=(0,T.useState)([]),[N,P]=(0,T.useState)([]),[F,I]=(0,T.useState)(!0),[L,R]=(0,T.useState)(null),[z,B]=(0,T.useState)(null),[V,H]=(0,T.useState)(null),U=(0,T.useCallback)(async()=>{if(e){B(null);try{let[t,n,r]=await Promise.all([x(e),v(e),b(e)]);A(t),M(n),P(r)}catch(e){B(e instanceof Error?e.message:String(e))}finally{I(!1)}}},[e]);(0,T.useEffect)(()=>{U()},[U]),(0,T.useEffect)(()=>{let e=()=>void U(),t=[`focus-updated`,`focus-monitor-updated`,`focus-run-updated`,`focus-insight-updated`,`focus-insight-created`];return t.forEach(t=>window.addEventListener(t,e)),()=>t.forEach(t=>window.removeEventListener(t,e))},[U]),(0,T.useLayoutEffect)(()=>(D({startExtra:null,main:(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`h1`,{className:`truncate text-base font-semibold text-fg`,children:k?.title??n.current}),(0,E.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:k?.summary??``})]}),end:null}),()=>O()),[O,n.current,k?.summary,k?.title,D]);let W=async(e,t,r=n.operationDone)=>{R(e),B(null),H(null);try{await t(),H(r),await U()}catch(e){B(e instanceof Error?e.message:String(e))}finally{R(null)}};return F?(0,E.jsxs)(`main`,{className:`mx-auto w-full max-w-[1000px] space-y-4 px-4 py-7 sm:px-6`,children:[(0,E.jsx)(m,{className:`h-28 rounded-xl`}),(0,E.jsx)(m,{className:`h-48 rounded-xl`}),(0,E.jsx)(m,{className:`h-64 rounded-xl`})]}):(0,E.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1000px] flex-1 flex-col gap-6 px-4 py-7 sm:px-6 lg:py-9`,children:[(0,E.jsxs)(a,{to:`/work`,className:`flex w-fit items-center gap-1 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,E.jsx)(u,{className:`size-3.5`}),n.back]}),z?(0,E.jsx)(`div`,{role:`alert`,className:`rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:z}):null,V?(0,E.jsx)(`div`,{role:`status`,className:`rounded-xl border border-success/25 bg-success-soft px-4 py-3 text-sm text-success`,children:V}):null,k?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-panel p-5`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`h2`,{className:`text-xl font-semibold text-fg`,children:k.title}),(0,E.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:k.summary})]}),(0,E.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-xs text-fg-muted`,children:k.status})]}),(0,E.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[(0,E.jsx)(s,{variant:`secondary`,disabled:L!==null,onClick:()=>void W(`status`,async()=>{A(await _(k.id,{status:k.status===`paused`?`active`:`paused`}))}),children:k.status===`paused`?n.resume:n.pause}),(0,E.jsxs)(s,{variant:`secondary`,disabled:L!==null||k.status===`completed`,onClick:()=>void W(`complete`,async()=>{A(await _(k.id,{status:`completed`}))}),children:[(0,E.jsx)(p,{className:`size-4`}),n.complete]}),(0,E.jsx)(s,{variant:`ghost`,className:`text-danger`,disabled:L!==null,onClick:()=>{window.confirm(n.deleteConfirm)&&W(`delete`,async()=>{await y(k.id),t(`/work`)})},children:n.remove})]})]}),(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`mb-3 text-base font-semibold text-fg`,children:n.current}),(0,E.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[`progress`,`external_changes`].map(e=>{let t=k.monitors.find(t=>t.kind===e),r=t?.enabled===!0;return(0,E.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,E.jsx)(d,{className:`size-4 text-accent`}),e===`progress`?n.progress:n.external]}),(0,E.jsx)(`span`,{className:`size-2 rounded-full ${r?`bg-success`:`bg-fg-subtle/40`}`})]}),(0,E.jsxs)(`dl`,{className:`mt-3 space-y-2 text-xs text-fg-muted`,children:[(0,E.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,E.jsx)(`dt`,{children:n.lastRun}),(0,E.jsx)(`dd`,{children:t?.lastRunAt?h(new Date(t.lastRunAt)):n.neverRun})]}),(0,E.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,E.jsx)(`dt`,{children:n.nextRun}),(0,E.jsx)(`dd`,{children:t?.nextRunAt?h(new Date(t.nextRunAt)):`—`})]})]}),t?.lastError?(0,E.jsx)(`p`,{className:`mt-3 rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,children:t.lastError}):null,(0,E.jsxs)(`div`,{className:`mt-4 flex gap-2 border-t border-edge-subtle pt-3`,children:[(0,E.jsx)(s,{variant:r?`secondary`:`primary`,className:`h-8 text-xs`,disabled:L!==null||k.status!==`active`,onClick:()=>void W(`monitor-${e}`,async()=>{A(await S(k.id,e,!r))},r?n.monitorStopped:n.monitorStarted),children:r?n.disableMonitor:e===`progress`?n.enableProgress:n.enableExternal}),r?(0,E.jsxs)(s,{variant:`ghost`,className:`h-8 text-xs`,disabled:L!==null,onClick:()=>void W(`run-${e}`,()=>C(k.id,e),n.queued),children:[(0,E.jsx)(l,{className:`size-3.5`}),n.runNow]}):null]})]},e)})})]}),(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`mb-3 text-base font-semibold text-fg`,children:n.latest}),(0,E.jsxs)(`div`,{className:`space-y-3`,children:[N.filter(e=>e.status===`unread`).map(e=>(0,E.jsxs)(`article`,{className:`rounded-xl border border-accent/20 bg-accent-soft/15 p-4`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,E.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:e.summary}),(0,E.jsxs)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:[(0,E.jsxs)(`b`,{className:`text-fg`,children:[n.why,`: `]}),e.whyItMatters]}),(0,E.jsxs)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:[(0,E.jsxs)(`b`,{className:`text-fg`,children:[n.next,`: `]}),e.nextAction]}),(0,E.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:e.evidence.map((e,t)=>(0,E.jsxs)(`span`,{className:`rounded-full border border-edge-subtle px-2 py-1 text-[11px] text-fg-subtle`,children:[e.label,e.source?` · ${e.source}`:``]},`${e.label}-${t}`))}),(0,E.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-edge-subtle pt-3`,children:[(0,E.jsx)(s,{variant:`ghost`,className:`h-8 text-xs`,disabled:L!==null,onClick:()=>void W(`dismiss-${e.id}`,()=>g(k.id,e.id,`dismiss`)),children:n.dismiss}),(0,E.jsxs)(s,{variant:`primary`,className:`h-8 text-xs`,disabled:L!==null,onClick:()=>void W(`investigate-${e.id}`,()=>g(k.id,e.id,`investigate`)),children:[(0,E.jsx)(c,{className:`size-3.5`}),n.investigate]})]})]},e.id)),N.every(e=>e.status!==`unread`)?(0,E.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge p-6 text-center text-sm text-fg-muted`,children:n.noInsights}):null]})]}),(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`mb-3 text-base font-semibold text-fg`,children:n.activity}),(0,E.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-4`,children:[j.map(e=>(0,E.jsxs)(`div`,{className:`flex gap-3 border-b border-edge-subtle py-3 last:border-0`,children:[(0,E.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`}),(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,E.jsx)(`time`,{className:`mt-1 block text-xs text-fg-subtle`,children:h(new Date(e.createdAt))})]})]},e.id)),j.length===0?(0,E.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.noActivity}):null]})]})]}):(0,E.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge p-8 text-center`,children:[(0,E.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Focus not found`}),(0,E.jsx)(s,{className:`mt-3`,onClick:()=>void U(),children:n.retry})]})]})}export{D as FocusDetailPage};