@xopcai/xopc 0.0.110 → 0.0.111

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 (301) hide show
  1. package/README.md +46 -4
  2. package/README.zh-CN.md +46 -4
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/Combination-BzaXOLd9.js +41 -0
  6. package/dist/gateway/static/root/assets/agent-avatar-dicebear-zlx9l5Yp.js +1 -0
  7. package/dist/gateway/static/root/assets/agent-browser-settings-page-B-0zGjt8.js +6 -0
  8. package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-Bz7JWjRM.js +1 -0
  9. package/dist/gateway/static/root/assets/agents-DwDnJlXT.js +71 -0
  10. package/dist/gateway/static/root/assets/app-management-settings-panel-DaQwdeCq.js +1 -0
  11. package/dist/gateway/static/root/assets/appearance-settings-D2zv6r3P.js +1 -0
  12. package/dist/gateway/static/root/assets/apps-page-BIppe_jj.js +1 -0
  13. package/dist/gateway/static/root/assets/archive-plugin-DEmu8eH7.js +1 -0
  14. package/dist/gateway/static/root/assets/attachment-load-B98lJoN5.js +2 -0
  15. package/dist/gateway/static/root/assets/{attachment-preview-renderer-CybMSIoS.js → attachment-preview-renderer-DonnL2dL.js} +1 -1
  16. package/dist/gateway/static/root/assets/binary-plugins-CL9QKmyo.js +2 -0
  17. package/dist/gateway/static/root/assets/block-editor-BOAhMAhT.js +180 -0
  18. package/dist/gateway/static/root/assets/channels-settings-Br8iRnXp.js +1 -0
  19. package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +1 -0
  20. package/dist/gateway/static/root/assets/code-editor-dZTY2dRW.js +1 -0
  21. package/dist/gateway/static/root/assets/config-api-0o1WYdz2.js +3 -0
  22. package/dist/gateway/static/root/assets/connectors-settings-DDvHo9in.js +2 -0
  23. package/dist/gateway/static/root/assets/cron-api-Dj_UZKST.js +1 -0
  24. package/dist/gateway/static/root/assets/cron-dreaming-jobs-nCMWCf0p.js +1 -0
  25. package/dist/gateway/static/root/assets/cron-page-Dv7GII9G.js +1 -0
  26. package/dist/gateway/static/root/assets/cron-schedule-picker-DH10KgD6.js +1 -0
  27. package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +1 -0
  28. package/dist/gateway/static/root/assets/dist-CkobR7mk.js +1 -0
  29. package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +1 -0
  30. package/dist/gateway/static/root/assets/dreaming-scene-BHMRVEUS.js +4585 -0
  31. package/dist/gateway/static/root/assets/dreaming-settings-L2rgZDQl.js +1 -0
  32. package/dist/gateway/static/root/assets/extension-debug-page-Cjx6pZVz.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-page-W1wiG38F.js → extension-page-BSPNL90V.js} +1 -1
  34. package/dist/gateway/static/root/assets/extension-settings-page-m_UQYkVc.js +1 -0
  35. package/dist/gateway/static/root/assets/fetch-Bs7in_4F.js +1 -0
  36. package/dist/gateway/static/root/assets/format-interval-label-CftJ5uXu.js +1 -0
  37. package/dist/gateway/static/root/assets/gateway-config-api-Clfck-hW.js +1 -0
  38. package/dist/gateway/static/root/assets/gateway-settings-CS177xni.js +1 -0
  39. package/dist/gateway/static/root/assets/gateway-startup-retry-BkjVJc38.js +1 -0
  40. package/dist/gateway/static/root/assets/goal-detail-page-kqJue0sE.js +1 -0
  41. package/dist/gateway/static/root/assets/goals-page-C0FujUB5.js +2 -0
  42. package/dist/gateway/static/root/assets/goals-settings-CJnzNSDo.js +1 -0
  43. package/dist/gateway/static/root/assets/heartbeat-config-api-Cp7CPuIn.js +1 -0
  44. package/dist/gateway/static/root/assets/heartbeat-settings-ifSI1Wbh.js +1 -0
  45. package/dist/gateway/static/root/assets/html-workspace-editor-CQLWDiwE.js +1 -0
  46. package/dist/gateway/static/root/assets/index-COkF54xv.js +121 -0
  47. package/dist/gateway/static/root/assets/index-DIaSNGEO.css +1 -0
  48. package/dist/gateway/static/root/assets/interval-presets-B29Ss_2y.js +2 -0
  49. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings--MI1rYl7.js +1 -0
  50. package/dist/gateway/static/root/assets/locale-store-DjbfSsfA.js +1 -0
  51. package/dist/gateway/static/root/assets/logs-page-BwrVNlyW.js +2 -0
  52. package/dist/gateway/static/root/assets/markdown-editor-AssmZFx4.js +2 -0
  53. package/dist/gateway/static/root/assets/markdown-split-B_oc9lJe.js +1 -0
  54. package/dist/gateway/static/root/assets/media-plugins-DLPvB5H3.js +1 -0
  55. package/dist/gateway/static/root/assets/mermaid-render-BbqDc_LQ.js +134 -0
  56. package/dist/gateway/static/root/assets/messages-Csef1aW7.js +3 -0
  57. package/dist/gateway/static/root/assets/middleware-Pd0e8Igk.js +1 -0
  58. package/dist/gateway/static/root/assets/models-hub-panel-DHGiTIvf.js +2 -0
  59. package/dist/gateway/static/root/assets/note-detail-page-BM7zlDiT.js +2 -0
  60. package/dist/gateway/static/root/assets/note-image-lightbox-rSqAgOi9.js +1 -0
  61. package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +1 -0
  62. package/dist/gateway/static/root/assets/notes-page-C9ACGEty.js +1 -0
  63. package/dist/gateway/static/root/assets/preview-open-alternatives-Bw_N2oZi.js +1 -0
  64. package/dist/gateway/static/root/assets/remote-access-hub-BhcWIKuM.js +1 -0
  65. package/dist/gateway/static/root/assets/save-bar-controls-CNP2jmw0.js +1 -0
  66. package/dist/gateway/static/root/assets/schedule-field-BPAWui3P.js +1 -0
  67. package/dist/gateway/static/root/assets/schedule-summary-B-hdSRdR.js +1 -0
  68. package/dist/gateway/static/root/assets/schema-form-CDPzua9q.js +1 -0
  69. package/dist/gateway/static/root/assets/sessions-page-DzkpSDZr.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-BYS-rpzn.js +1 -0
  71. package/dist/gateway/static/root/assets/settings-collapsible-section-C9bff85B.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-form-section-BsrK7TBF.js +1 -0
  73. package/dist/gateway/static/root/assets/settings-page-DWK4Zo7s.js +1 -0
  74. package/dist/gateway/static/root/assets/setup-status-panel-DJiksNu4.js +1 -0
  75. package/dist/gateway/static/root/assets/share-preview-page-DnutoY_S.js +2 -0
  76. package/dist/gateway/static/root/assets/shares-settings-6oRgJMpn.js +1 -0
  77. package/dist/gateway/static/root/assets/skill-reload-api-CU9i0nJV.js +1 -0
  78. package/dist/gateway/static/root/assets/skills-page-ERbdWENm.js +2 -0
  79. package/dist/gateway/static/root/assets/system-settings-panel-qP1JDtDd.js +1 -0
  80. package/dist/gateway/static/root/assets/theme-store-CD2wtgZV.js +1 -0
  81. package/dist/gateway/static/root/assets/use-agent-defaults-form-D3FGVLZb.js +1 -0
  82. package/dist/gateway/static/root/assets/use-blob-object-url-D4BFuzZB.js +1 -0
  83. package/dist/gateway/static/root/assets/use-channel-catalog-C4mg1hjD.js +1 -0
  84. package/dist/gateway/static/root/assets/use-settings-tab-guard-F6C0mpJt.js +1 -0
  85. package/dist/gateway/static/root/assets/vendor-codemirror-CNP1wPe7.js +45 -0
  86. package/dist/gateway/static/root/assets/voice-api-key-field-BnDDb6qO.js +1 -0
  87. package/dist/gateway/static/root/assets/voice-player-store-B2EwIhtY.js +1 -0
  88. package/dist/gateway/static/root/assets/{workflow-page.utils-EYg_xBQS.js → workflow-page.utils-CRB7WX9l.js} +1 -1
  89. package/dist/gateway/static/root/assets/workflows-page-2Fptr0je.js +18 -0
  90. package/dist/gateway/static/root/index.html +12 -10
  91. package/dist/package.js +1 -1
  92. package/dist/src/agent/goals/checklist-judge.d.ts +5 -0
  93. package/dist/src/agent/goals/checklist-judge.js +26 -2
  94. package/dist/src/agent/goals/checklist-judge.js.map +1 -1
  95. package/dist/src/agent/goals/evaluate-turn.d.ts +5 -1
  96. package/dist/src/agent/goals/evaluate-turn.js +29 -3
  97. package/dist/src/agent/goals/evaluate-turn.js.map +1 -1
  98. package/dist/src/agent/goals/goal-locale.d.ts +0 -2
  99. package/dist/src/agent/goals/goal-locale.js +2 -15
  100. package/dist/src/agent/goals/goal-locale.js.map +1 -1
  101. package/dist/src/agent/goals/persistent-goal-service.d.ts +9 -0
  102. package/dist/src/agent/goals/persistent-goal-service.js +2 -1
  103. package/dist/src/agent/goals/persistent-goal-service.js.map +1 -1
  104. package/dist/src/agent/goals/post-turn.d.ts +7 -0
  105. package/dist/src/agent/goals/post-turn.js +68 -23
  106. package/dist/src/agent/goals/post-turn.js.map +1 -1
  107. package/dist/src/agent/goals/state.d.ts +0 -5
  108. package/dist/src/agent/goals/state.js +1 -96
  109. package/dist/src/agent/goals/state.js.map +1 -1
  110. package/dist/src/agent/messaging/command-handler.d.ts +4 -0
  111. package/dist/src/agent/messaging/command-handler.js +6 -2
  112. package/dist/src/agent/messaging/command-handler.js.map +1 -1
  113. package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -0
  114. package/dist/src/agent/service/direct-turn-helpers.js +3 -2
  115. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  116. package/dist/src/agent/service/process-direct-streaming.js +10 -1
  117. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  118. package/dist/src/agent/service.js +20 -1
  119. package/dist/src/agent/service.js.map +1 -1
  120. package/dist/src/agent/service.types.d.ts +8 -0
  121. package/dist/src/agent/tools/cronjob-tool.d.ts +2 -0
  122. package/dist/src/agent/tools/cronjob-tool.js +27 -4
  123. package/dist/src/agent/tools/cronjob-tool.js.map +1 -1
  124. package/dist/src/agent/tools/edit.d.ts +2 -0
  125. package/dist/src/agent/tools/edit.js +10 -0
  126. package/dist/src/agent/tools/edit.js.map +1 -1
  127. package/dist/src/agent/tools/factory.js +16 -3
  128. package/dist/src/agent/tools/factory.js.map +1 -1
  129. package/dist/src/agent/tools/goal-evidence-recorder.d.ts +6 -0
  130. package/dist/src/agent/tools/goal-evidence-recorder.js +34 -0
  131. package/dist/src/agent/tools/goal-evidence-recorder.js.map +1 -0
  132. package/dist/src/agent/tools/goal-tool.d.ts +19 -0
  133. package/dist/src/agent/tools/goal-tool.js +101 -0
  134. package/dist/src/agent/tools/goal-tool.js.map +1 -0
  135. package/dist/src/agent/tools/index.d.ts +1 -0
  136. package/dist/src/agent/tools/index.js +2 -1
  137. package/dist/src/agent/tools/shell.d.ts +2 -0
  138. package/dist/src/agent/tools/shell.js +17 -2
  139. package/dist/src/agent/tools/shell.js.map +1 -1
  140. package/dist/src/agent/tools/workflow-tool.d.ts +1 -0
  141. package/dist/src/agent/tools/workflow-tool.js +10 -2
  142. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  143. package/dist/src/agent/tools/write.d.ts +2 -0
  144. package/dist/src/agent/tools/write.js +11 -0
  145. package/dist/src/agent/tools/write.js.map +1 -1
  146. package/dist/src/channels/attachments/inbound-persist.d.ts +7 -0
  147. package/dist/src/channels/attachments/inbound-persist.js +20 -2
  148. package/dist/src/channels/attachments/inbound-persist.js.map +1 -1
  149. package/dist/src/chat-commands/builtins/goal.d.ts +1 -1
  150. package/dist/src/chat-commands/builtins/goal.js +55 -97
  151. package/dist/src/chat-commands/builtins/goal.js.map +1 -1
  152. package/dist/src/chat-commands/builtins/subgoal.d.ts +1 -1
  153. package/dist/src/chat-commands/builtins/subgoal.js +49 -108
  154. package/dist/src/chat-commands/builtins/subgoal.js.map +1 -1
  155. package/dist/src/chat-commands/builtins/workflow.js +132 -8
  156. package/dist/src/chat-commands/builtins/workflow.js.map +1 -1
  157. package/dist/src/chat-commands/context.d.ts +3 -0
  158. package/dist/src/chat-commands/context.js +5 -0
  159. package/dist/src/chat-commands/context.js.map +1 -1
  160. package/dist/src/chat-commands/types.d.ts +5 -0
  161. package/dist/src/cli/command-catalog.js +43 -0
  162. package/dist/src/cli/command-catalog.js.map +1 -1
  163. package/dist/src/cli/command-loaders.js +1 -0
  164. package/dist/src/cli/command-loaders.js.map +1 -1
  165. package/dist/src/cli/command-manifest.js +4 -0
  166. package/dist/src/cli/command-manifest.js.map +1 -1
  167. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  168. package/dist/src/cli/commands/goal.d.ts +4 -0
  169. package/dist/src/cli/commands/goal.js +213 -0
  170. package/dist/src/cli/commands/goal.js.map +1 -0
  171. package/dist/src/cli/commands/onboard.js +11 -5
  172. package/dist/src/cli/commands/onboard.js.map +1 -1
  173. package/dist/src/config/index.js +2 -2
  174. package/dist/src/config/schema.d.ts +115 -0
  175. package/dist/src/config/schema.js +63 -4
  176. package/dist/src/config/schema.js.map +1 -1
  177. package/dist/src/config/web-patch.d.ts +14 -0
  178. package/dist/src/config/web-patch.js +45 -6
  179. package/dist/src/config/web-patch.js.map +1 -1
  180. package/dist/src/cron/executor.d.ts +2 -0
  181. package/dist/src/cron/executor.js +25 -0
  182. package/dist/src/cron/executor.js.map +1 -1
  183. package/dist/src/cron/job-content.js +1 -0
  184. package/dist/src/cron/job-content.js.map +1 -1
  185. package/dist/src/cron/types.d.ts +19 -1
  186. package/dist/src/cron/validation.d.ts +20 -0
  187. package/dist/src/cron/validation.js +7 -0
  188. package/dist/src/cron/validation.js.map +1 -1
  189. package/dist/src/gateway/hono/lib/config-payload.d.ts +14 -0
  190. package/dist/src/gateway/hono/routes/goals.d.ts +1 -1
  191. package/dist/src/gateway/hono/routes/goals.js +670 -173
  192. package/dist/src/gateway/hono/routes/goals.js.map +1 -1
  193. package/dist/src/gateway/hono/routes/home.d.ts +5 -0
  194. package/dist/src/gateway/hono/routes/home.js +88 -3
  195. package/dist/src/gateway/hono/routes/home.js.map +1 -1
  196. package/dist/src/gateway/hono/routes/notes.js +20 -14
  197. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  198. package/dist/src/gateway/hono/routes/workflows.js +6 -2
  199. package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
  200. package/dist/src/gateway/hono/sse.js.map +1 -1
  201. package/dist/src/gateway/service/agent-runner.d.ts +2 -0
  202. package/dist/src/gateway/service/agent-runner.js +6 -2
  203. package/dist/src/gateway/service/agent-runner.js.map +1 -1
  204. package/dist/src/gateway/service/run-gateway-agent.d.ts +3 -0
  205. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  206. package/dist/src/gateway/service.d.ts +8 -0
  207. package/dist/src/gateway/service.js +69 -2
  208. package/dist/src/gateway/service.js.map +1 -1
  209. package/dist/src/goals/goal-notifications.d.ts +29 -0
  210. package/dist/src/goals/goal-notifications.js +154 -0
  211. package/dist/src/goals/goal-notifications.js.map +1 -0
  212. package/dist/src/goals/goal-queue-store.d.ts +16 -0
  213. package/dist/src/goals/goal-queue-store.js +131 -0
  214. package/dist/src/goals/goal-queue-store.js.map +1 -0
  215. package/dist/src/goals/goal-queue-types.d.ts +31 -0
  216. package/dist/src/goals/goal-queue-types.js +1 -0
  217. package/dist/src/goals/goal-runner.d.ts +17 -0
  218. package/dist/src/goals/goal-runner.js +127 -0
  219. package/dist/src/goals/goal-runner.js.map +1 -0
  220. package/dist/src/goals/goal-service.d.ts +77 -0
  221. package/dist/src/goals/goal-service.js +261 -0
  222. package/dist/src/goals/goal-service.js.map +1 -0
  223. package/dist/src/goals/goal-store.d.ts +38 -0
  224. package/dist/src/goals/goal-store.js +404 -0
  225. package/dist/src/goals/goal-store.js.map +1 -0
  226. package/dist/src/goals/goal-workflow-judge.d.ts +13 -0
  227. package/dist/src/goals/goal-workflow-judge.js +147 -0
  228. package/dist/src/goals/goal-workflow-judge.js.map +1 -0
  229. package/dist/src/goals/index.d.ts +10 -0
  230. package/dist/src/goals/index.js +7 -0
  231. package/dist/src/goals/types.d.ts +119 -0
  232. package/dist/src/goals/types.js +1 -0
  233. package/dist/src/storage/sqlite/migrations/006_add_goals.sql +108 -0
  234. package/dist/src/storage/sqlite/migrations/007_goal_run_judge_schema.sql +4 -0
  235. package/dist/src/storage/sqlite/migrations/008_goal_queue_workflow_runs.sql +53 -0
  236. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  237. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  238. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  239. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  240. package/dist/src/storage/sqlite/schema.js +1 -1
  241. package/dist/src/storage/sqlite/schema.sql +163 -0
  242. package/dist/src/utils/logger/stats.d.ts +1 -1
  243. package/dist/src/workflows/domain/run.d.ts +1 -0
  244. package/dist/src/workflows/domain/run.js.map +1 -1
  245. package/dist/src/workflows/service/workflow-run-service.d.ts +1 -0
  246. package/dist/src/workflows/service/workflow-run-service.js +5 -1
  247. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  248. package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -0
  249. package/dist/src/workflows/service/workflow-session-bridge.js +7 -0
  250. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  251. package/dist/src/workflows/store/run-index-store.d.ts +8 -0
  252. package/dist/src/workflows/store/run-index-store.js +58 -0
  253. package/dist/src/workflows/store/run-index-store.js.map +1 -0
  254. package/dist/src/workflows/store/run-store.d.ts +2 -0
  255. package/dist/src/workflows/store/run-store.js +14 -21
  256. package/dist/src/workflows/store/run-store.js.map +1 -1
  257. package/package.json +9 -3
  258. package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +0 -41
  259. package/dist/gateway/static/root/assets/agents-CFFioJCI.js +0 -78
  260. package/dist/gateway/static/root/assets/apps-page-BYDmkbzG.js +0 -1
  261. package/dist/gateway/static/root/assets/channels-settings-CsbDaMvd.js +0 -1
  262. package/dist/gateway/static/root/assets/circle-check-C23XjkUj.js +0 -1
  263. package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +0 -1
  264. package/dist/gateway/static/root/assets/cron-page-Apk-7p4p.js +0 -1
  265. package/dist/gateway/static/root/assets/dist-DmGDgpy2.js +0 -1
  266. package/dist/gateway/static/root/assets/extension-debug-page-pxFC-tUa.js +0 -1
  267. package/dist/gateway/static/root/assets/extension-settings-page-COXSv6xP.js +0 -1
  268. package/dist/gateway/static/root/assets/fetch-CFdKBnE6.js +0 -1
  269. package/dist/gateway/static/root/assets/gateway-startup-retry-DdngdObI.js +0 -1
  270. package/dist/gateway/static/root/assets/heartbeat-config-api-DcmAMYmN.js +0 -1
  271. package/dist/gateway/static/root/assets/index-C_2yKRJX.js +0 -4845
  272. package/dist/gateway/static/root/assets/index-DI5_GsZt.css +0 -1
  273. package/dist/gateway/static/root/assets/logs-page-DvTWUOzd.js +0 -2
  274. package/dist/gateway/static/root/assets/note-detail-page-CZbdugWZ.js +0 -180
  275. package/dist/gateway/static/root/assets/note-time-RdyBZxj3.js +0 -1
  276. package/dist/gateway/static/root/assets/notes-page-mEAwy3e1.js +0 -1
  277. package/dist/gateway/static/root/assets/schema-form-DEvdni_r.js +0 -1
  278. package/dist/gateway/static/root/assets/sessions-page-BsgffzV4.js +0 -1
  279. package/dist/gateway/static/root/assets/settings-advanced-gate-t6v8Dwb8.js +0 -2
  280. package/dist/gateway/static/root/assets/settings-form-section-BoYYZmJG.js +0 -1
  281. package/dist/gateway/static/root/assets/settings-page-ClIthYF8.js +0 -3
  282. package/dist/gateway/static/root/assets/share-preview-page-Dd9et7KD.js +0 -2
  283. package/dist/gateway/static/root/assets/skills-page-DEXtxyfQ.js +0 -2
  284. package/dist/gateway/static/root/assets/theme-store-BZozwAeK.js +0 -1
  285. package/dist/gateway/static/root/assets/url-DQRqHuL-.js +0 -3
  286. package/dist/gateway/static/root/assets/vendor-codemirror-DYoKfS8f.js +0 -45
  287. package/dist/gateway/static/root/assets/voice-api-key-field-CNrKzQrf.js +0 -1
  288. package/dist/gateway/static/root/assets/workflows-page-EMZkzJNN.js +0 -18
  289. package/dist/src/agent/goals/checklist-user.d.ts +0 -24
  290. package/dist/src/agent/goals/checklist-user.js +0 -92
  291. package/dist/src/agent/goals/checklist-user.js.map +0 -1
  292. package/dist/src/agent/goals/goal-run-store.d.ts +0 -19
  293. package/dist/src/agent/goals/goal-run-store.js +0 -138
  294. package/dist/src/agent/goals/goal-run-store.js.map +0 -1
  295. package/dist/src/agent/goals/goal-run-types.d.ts +0 -28
  296. package/dist/src/agent/goals/goal-run-types.js +0 -6
  297. package/dist/src/agent/goals/goal-run-types.js.map +0 -1
  298. package/dist/src/agent/goals/patch-from-user-action.d.ts +0 -20
  299. package/dist/src/agent/goals/patch-from-user-action.js +0 -103
  300. package/dist/src/agent/goals/patch-from-user-action.js.map +0 -1
  301. /package/dist/gateway/static/root/assets/{note-detail-page-D4ZIVQbk.css → block-editor-D4ZIVQbk.css} +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{i,o as a,t as o}from"./url-DQRqHuL-.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,n as u,t as d}from"./fetch-CFdKBnE6.js";import{Ar as f,Cr as p,Dr as m,Ei as h,Er as g,Fo as _,Go as v,Or as y,R as b,Sr as x,Vr as S,Zi as C,Zo as w,br as T,do as E,fi as D,hi as O,ja as k,jr as A,jt as j,ko as M,kr as N,ns as P,pi as F,qi as I,ua as L,va as R,xr as z,yr as B,zn as ee}from"./index-C_2yKRJX.js";var V=e(t(),1),H=n();function U(e){return e===`builtin`||e===`user`?e:`marketplace`}async function W(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function te(e){let t=await d(o(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function G(e){let t=await d(o(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await d(o(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function q(e){let t=await d(o(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var J=r();function Y(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var X={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(i(e=>e.language)).appsPage,n=l(e=>!!e.token),r=T(),{mutate:d}=s(),[f,p]=(0,V.useReducer)(b,X),{q:m,debounced:g,detailPkg:_,rowBusy:v,actionError:y,restartHint:x}=f,S=n?`marketplace-${g}`:null;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>p({type:`patch`,patch:{debounced:m.trim()}}),300);return()=>window.clearTimeout(e)},[m]);let{data:w,isLoading:E,error:D}=c(S,async()=>u(g.length>0?o(`/api/marketplace?q=${encodeURIComponent(g)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),O=(0,V.useCallback)(()=>{d(`gateway-extensions-list`),j()},[d]),A=(0,V.useCallback)(async(e,n)=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await G({name:e,overwrite:n});O(),r.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,O]),N=(0,V.useCallback)(async e=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await q(e);O(),n.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,O]),P=w?.extensions??[];return(0,J.jsxs)(`div`,{className:F(`flex flex-col gap-4`,e),children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(C,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>p({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),D?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,y?(0,J.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null,x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x}):null,E&&!w?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,J.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=Y(r,e.id),i=v===e.id;return(0,J.jsx)(`li`,{className:`list-none`,children:(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>p({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p({type:`patch`,patch:{detailPkg:e.id}}))},className:F(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,J.jsx)(M,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,J.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,J.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,J.jsx)(R,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,J.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(k,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(h,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{A(e.id,!1).catch(()=>{})},className:F(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(k,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),_?(0,J.jsx)(re,{packageName:_,copy:t,extensions:r,onClose:()=>p({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:N}):null]})}function re(e){let t=(0,H.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[u,d]=(0,V.useState)(!1),p=l(se)?`ext-mp-detail-${n}`:null,m;t[0]===n?m=t[1]:(m=async()=>te(n),t[0]=n,t[1]=m);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},t[2]=_):_=t[2];let{data:b,error:x,isLoading:S}=c(p,m,_),C;t[3]!==i||t[4]!==n?(C=Y(i,n),t[3]=i,t[4]=n,t[5]=C):C=t[5];let T=C,E=T===`user`,D;t[6]!==r.marketplaceNoReadme||t[7]!==b?(D=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=D):D=t[8];let j=D,M;t[9]===a?M=t[10]:(M=e=>!e&&a(),t[9]=a,t[10]=M);let P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,J.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=P):P=t[11];let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,J.jsx)(v,{className:`size-5`}),t[12]=I):I=t[12];let L;t[13]!==r.detailBack||t[14]!==a?(L=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:I}),t[13]=r.detailBack,t[14]=a,t[15]=L):L=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,J.jsx)(A,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=R);let z;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,J.jsx)(O,{className:`size-5`}),t[18]=z):z=t[18];let B;t[19]!==r.detailClose||t[20]!==a?(B=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:z}),t[19]=r.detailClose,t[20]=a,t[21]=B):B=t[21];let U;t[22]!==B||t[23]!==L||t[24]!==R?(U=(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[L,R,B]}),t[22]=B,t[23]=L,t[24]=R,t[25]=U):U=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==x||t[33]!==S||t[34]!==j?(W=S&&!b?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.name}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:b.id})}),(0,J.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,J.jsx)(`dd`,{children:b.author.username})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,J.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,J.jsx)(`dd`,{children:b.downloads})]})]}),b.readme?.trim()?(0,J.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,J.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,J.jsx)(ee,{content:j})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=x,t[33]=S,t[34]=j,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==T||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==E?(K=b?(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:T===`bundled`?(0,J.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,J.jsx)(w,{to:`/apps?tab=builtin`,onClick:a,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{E&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,E).catch(ae).finally(()=>d(!1)))},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,J.jsx)(k,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,E?r.marketplaceReinstall:r.marketplaceInstall]}),E?(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),s(n).then(()=>a()).catch(ie).finally(()=>d(!1)))},className:F(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,J.jsx)(h,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=b,t[47]=T,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=E,t[53]=K):K=t[53];let q;t[54]!==U||t[55]!==G||t[56]!==K?(q=(0,J.jsxs)(N,{children:[P,(0,J.jsxs)(g,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:oe,children:[U,G,K]})]}),t[54]=U,t[55]=G,t[56]=K,t[57]=q):q=t[57];let X;return t[58]!==q||t[59]!==M?(X=(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:M,children:q}),t[58]=q,t[59]=M,t[60]=X):X=t[60],X}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=i(e=>e.language),t=a(e),n=S(e=>e.setPageHeader),r=S(e=>e.clearPageHeader),o=T(),s=z(),[c,l]=P(),u=U(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,V.useState)(u),[m,h]=(0,V.useState)(d),[g,_]=(0,V.useState)(null),v=c.toString(),y=(0,V.useRef)(v);if(y.current!==v){y.current=v;let e=U(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,V.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,V.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),x=(0,V.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),w=f===`builtin`?b:x,E=(0,V.useMemo)(()=>{let t=m.trim().toLowerCase(),n=w;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[w,m,e]);if((0,V.useEffect)(()=>{_(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[o]),(0,V.useLayoutEffect)(()=>(n({startExtra:null,main:(0,J.jsx)(`div`,{className:`min-w-0`,children:(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,J.jsx)(pe,{});let D=f!==`marketplace`&&w.length>0;return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,J.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:F(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:F(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,b.length,`)`]})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:F(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]})]}),D?(0,J.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,J.jsx)(C,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,J.jsx)(ne,{}):f===`builtin`&&b.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyUser}):E.length===0?(0,J.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,J.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,J.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,J.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,H.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Z(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=F(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(0,J.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,J.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,J.jsx)(_,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,J.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,J.jsx)(L,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let v;t[17]!==h||t[18]!==g?(v=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==c?(S=(0,J.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=c,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==i?(C=n.source===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,J.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==v||t[36]!==b||t[37]!==w?(T=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==f?(E=(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[f,T]}),t[39]=T,t[40]=f,t[41]=E):E=t[41];let D;return t[42]!==a||t[43]!==E?(D=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:l,children:E}),t[42]=a,t[43]=E,t[44]=D):D=t[44],D}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,V.useState)(!1),[o,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=e.activationEligible===!0,h=(0,V.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),a(!0);try{let{requiresGatewayRestart:t}=await K({extensionId:e.id,enabled:!d});await r(`gateway-extensions-list`),j(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],b=e.ui?.contributions?.settingsPanels??[],S=e.ui?.contributions?.chatWidgets??[],C=e.ui?.contributions?.sidebarPanels??[],T=_.find(e=>e.showInNav)??_[0],M=b[0],P=T?B(e.id,T):null,L=M?`/settings/ext/${e.id}/${M.id}`:e.hasConfigSchema||x(e)?`/settings/ext/${e.id}`:null;return(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(N,{children:[(0,J.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,J.jsxs)(g,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,J.jsx)(v,{className:`size-5`})}),(0,J.jsx)(A,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,J.jsxs)(m,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,J.jsx)(O,{className:`size-5`})})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,J.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,J.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,J.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,J.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,J.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void h(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(k,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):d?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,l?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,J.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(_.length>0||b.length>0||S.length>0)?(0,J.jsxs)(`section`,{className:`mt-8`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsx)($,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,J.jsx)($,{template:t.badgeSettings,count:b.length,hidden:b.length===0}),(0,J.jsx)($,{template:t.badgeWidgets,count:S.length,hidden:S.length===0}),(0,J.jsx)($,{template:t.badgeSidebar,count:C.length,hidden:C.length===0})]})]}):null,p(e)&&(P||L)?(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[P?(0,J.jsxs)(w,{to:P,onClick:n,className:F(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,J.jsx)(E,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,L?(0,J.jsxs)(w,{to:L,onClick:n,className:F(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,J.jsx)(I,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,J.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,H.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,J.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function pe(){let e=(0,H.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,J.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,J.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,J.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,J.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,H.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,J.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
@@ -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{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./circle-check-C23XjkUj.js";import{a as l,n as u,t as d}from"./fetch-CFdKBnE6.js";import{Ar as f,Dr as p,Er as m,Ii as h,Ji as g,N as _,Or as v,Tn as y,Tr as b,Vr as x,cn as S,do as C,es as w,fi as T,hi as E,ia as D,ja as O,jr as k,kr as A,on as j,pi as M,ri as N,sa as P,sn as F,ts as I,vr as L,wn as R}from"./index-C_2yKRJX.js";import{t as z}from"./schema-form-DEvdni_r.js";import{t as B}from"./browser-BLJWD7WI.js";var V=n(),H=e(B(),1),U=e(t(),1),W=r();function G(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}async function K(e){let t=await d(o(`/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 q(e){return e?.type===`poll`&&e.phase===`done`}function J(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function Y(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function X(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ee({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:i=!1,compact:a=!1}){let o=(0,U.useMemo)(()=>G(e),[e]),s=(0,U.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,U.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,U.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,U.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await K({channelId:e.id,actionId:n,locale:t,input:i});u(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){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,U.useEffect)(()=>{!i||!o||o[1].result!==`qr`||l.payload||l.busy||l.error||d(o[0])},[i,o,d,l.busy,l.error,l.payload]),(0,U.useEffect)(()=>{let t=Y(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),H.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,U.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||K({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:q(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),q(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=o?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=J(l.payload),g=Y(l.payload,e.id),_=g?l.generatedQr:X(l.payload),v=l.payload?.type===`form`?l.payload:null,y=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,W.jsxs)(`div`,{className:a?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:M(`flex flex-wrap items-start gap-3`,a?`justify-end`:`justify-between`),children:[a?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,W.jsxs)(T,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(o[0]),children:[l.busy?(0,W.jsx)(O,{className:`size-4 animate-spin`}):(0,W.jsx)(P,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(T,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,W.jsx)(h,{className:`size-4`}),p]}):null]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,_?(0,W.jsxs)(`div`,{className:M(`flex flex-wrap items-start gap-4`,a?`justify-center`:`mt-4`),children:[(0,W.jsx)(`div`,{className:`rounded-lg border border-edge bg-white p-3`,children:(0,W.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`h-52 w-52 object-contain`})}),(0,W.jsxs)(`div`,{className:M(`max-w-sm text-sm text-fg-muted`,a&&`w-full text-center`),children:[(0,W.jsx)(`p`,{children:n.waitingConfirmation}),g?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(C,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm`,children:[(0,W.jsx)(c,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,v?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(z,{schema:v.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:s}),(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(v.submitAction,l.formDraft),children:n.saveSetup})]}):null,y?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function te(e,t=!1){return e===`drawer`?M(`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`,R):M(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ne(e){let t=(0,V.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:d,wide:h,headerExtra:g}=e,_=h===void 0?!1:h,x=n===`drawer`,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,W.jsx)(v,{className:M(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,y)}),t[0]=S):S=t[0];let C;t[1]!==n||t[2]!==_?(C=te(n,_),t[1]=n,t[2]=_,t[3]=C):C=t[3];let w;t[4]===s?w=t[5]:(w=s?(0,W.jsx)(k,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=w);let D;t[6]===c?D=t[7]:(D=c?(0,W.jsx)(p,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=D);let O;t[8]!==l||t[9]!==o||t[10]!==g||t[11]!==x||t[12]!==a?(O=x?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,W.jsx)(E,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:M(N,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,W.jsx)(E,{className:`size-4`})})}),g]}),t[8]=l,t[9]=o,t[10]=g,t[11]=x,t[12]=a,t[13]=O):O=t[13];let j=x?`px-4 py-4`:`p-6`,P;t[14]===j?P=t[15]:(P=M(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=P);let F;t[16]!==u||t[17]!==P?(F=(0,W.jsx)(`div`,{className:P,children:u}),t[16]=u,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==d||t[20]!==C||t[21]!==w||t[22]!==D||t[23]!==O||t[24]!==F?(I=(0,W.jsxs)(A,{children:[S,(0,W.jsxs)(m,{className:C,onOpenAutoFocus:re,children:[w,D,O,F,d]})]}),t[19]=d,t[20]=C,t[21]=w,t[22]=D,t[23]=O,t[24]=F,t[25]=I):I=t[25];let L;return t[26]!==i||t[27]!==r||t[28]!==I?(L=(0,W.jsx)(f,{open:r,onOpenChange:i,children:I}),t[26]=i,t[27]=r,t[28]=I,t[29]=L):L=t[29],L}function re(e){return e.preventDefault()}var ie=(0,U.memo)(function(e){let t=(0,V.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=M(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,W.jsx)(D,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function ae(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,W.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,W.jsx)(T,{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,W.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function oe(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function se(e){return(await u(oe(e))).payload?.channels??[]}function ce(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>se(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:c,isLoading:l,isValidating:u,mutate:d}=s(r,i,a),f;n[6]===o?f=n[7]:(f=o??[],n[6]=o,n[7]=f);let p;return n[8]!==c||n[9]!==l||n[10]!==u||n[11]!==d||n[12]!==f?(p={entries:f,isLoading:l,isValidating:u,error:c,mutate:d},n[8]=c,n[9]=l,n[10]=u,n[11]=d,n[12]=f,n[13]=p):p=n[13],p}function le(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function ue(e){return(await u(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}async function de(){return(await u(o(`/api/config`))).payload?.config?.channels??{}}function Z(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function fe(e,t){return e.enabled&&e.runtime===`loaded`?t.hubStatusRunning:e.enabled?t.hubStatusEnabled:e.configured?t.hubStatusConfigured:t.hubStatusNotConfigured}function pe(e){return e.enabled&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e.enabled||e.configured?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function me(e){if(!e)return[`enabled`];let t=e.uiHints??{},n=Object.entries(t).filter(([,e])=>!Q(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e);return n.length>0?n:[`enabled`]}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function he(e,t){let n={...$(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(!Q(r)||!Q(r[n]))break;let o=Q(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...$(r[n]),properties:{}}),e===t.length-1){o[n]=$(r[n]);break}i=r[n],a=o[n]}}return n}function ge(e){let t=e.properties;if(!Q(t))return!1;for(let[e,n]of Object.entries(t))Q(n)&&n.type===`object`&&ge(n)&&delete t[e];return Object.keys(t).length===0}function _e(e,t){let n=$(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Q(i))break;if(e===t.length-1){delete i[n];break}if(!Q(i[n]))break;r=i[n]}}return ge(n),n}function ve(e){return e.type===`object`&&Q(e.properties)&&Object.keys(e.properties).length>0}function ye(e,t){let n=e;for(let e of t.split(`.`)){if(!Q(n))return;n=n[e]}return n}function be(e){let t=e.accounts;return Q(t)?Object.values(t).filter(e=>Q(e)&&e.enabled!==!1).length:+(e.configured===!0)}function xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Se(e,t,n){let r=[];if(t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=xe(e,ye(t,e),n);i&&r.push(i)}let a=be(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,3):e.configured?[n.hubStatusConfigured]:[]}function Ce(e,t){let n=G(e);return n?.[1].label?n[1].label:e.configured?t.manageChannel:t.startConfiguration}function we({entry:e}){let t=l(e=>e.token),[n,r]=(0,U.useState)(!1),i=(0,U.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Z(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(L,{sourceChannel:e.id,className:`size-7`})})}function Te(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=M(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=M(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,W.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function Ee(e){let t=(0,V.c)(64),{entry:n,config:r,busy:i,ch:a,onOpen:o,onToggle:s}=e,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==o||t[5]!==s){let e=Se(n,r,a);p=`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`;let h;t[13]===n?h=t[14]:(h=(0,W.jsx)(we,{entry:n}),t[13]=n,t[14]=h);let g;t[15]===n.label?g=t[16]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[15]=n.label,t[16]=g);let _;t[17]===n?_=t[18]:(_=M(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,pe(n)),t[17]=n,t[18]=_);let v;t[19]!==a||t[20]!==n?(v=fe(n,a),t[19]=a,t[20]=n,t[21]=v):v=t[21];let y;t[22]!==_||t[23]!==v?(y=(0,W.jsx)(`span`,{className:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==h?(x=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,b]}),t[28]=b,t[29]=h,t[30]=x):x=t[30];let S=n.enabled===!0,C;t[31]!==a.toggleChannel||t[32]!==n.label?(C=a.toggleChannel.replace(`{{channel}}`,n.label),t[31]=a.toggleChannel,t[32]=n.label,t[33]=C):C=t[33];let w;t[34]!==i||t[35]!==s||t[36]!==S||t[37]!==C?(w=(0,W.jsx)(Te,{checked:S,disabled:i,label:C,onToggle:s}),t[34]=i,t[35]=s,t[36]=S,t[37]=C,t[38]=w):w=t[38],t[39]!==x||t[40]!==w?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[x,w]}),t[39]=x,t[40]=w,t[41]=m):m=t[41],c=`button`,l=o,u=`mt-5 min-h-[4.5rem] text-left`;let T=n.description??n.id;t[42]===T?d=t[43]:(d=(0,W.jsx)(`p`,{className:`line-clamp-3 text-sm leading-6 text-fg-muted`,children:T}),t[42]=T,t[43]=d),f=e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(De)}):null,t[0]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[44]!==c||t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,W.jsxs)(`button`,{type:c,onClick:l,className:u,children:[d,f]}),t[44]=c,t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]===i?g=t[51]:(g=i?(0,W.jsx)(O,{className:`size-4 animate-spin`}):null,t[50]=i,t[51]=g);let _;t[52]!==a||t[53]!==n?(_=Ce(n,a),t[52]=a,t[53]=n,t[54]=_):_=t[54];let v;t[55]!==o||t[56]!==_||t[57]!==g?(v=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(T,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:o,children:[g,_]})}),t[55]=o,t[56]=_,t[57]=g,t[58]=v):v=t[58];let y;return t[59]!==v||t[60]!==p||t[61]!==m||t[62]!==h?(y=(0,W.jsxs)(`article`,{className:p,children:[m,h,v]}),t[59]=v,t[60]=p,t[61]=m,t[62]=h,t[63]=y):y=t[63],y}function De(e){return(0,W.jsx)(`p`,{children:e},e)}function Oe(){let e=i(e=>e.language),t=a(e),n=l(e=>!!e.token),r=w(),{channelId:c}=I(),u=S(c),f=ce(n,e),p=f.entries,{data:m={},mutate:h}=s(n?`channels-config-map`:null,de,{revalidateOnFocus:!1}),v=x(e=>e.setPageHeader),y=x(e=>e.clearPageHeader),b=(0,U.useMemo)(()=>p.find(e=>e.id===u),[u,p]),{data:T,mutate:E}=s(n&&b?le(b.id):null,()=>ue(b.id)),[D,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(!1),[N,P]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),B=D??T??{},V=t.channelsSettings,H=(0,U.useMemo)(()=>b?.configSchema??{type:`object`,properties:{}},[b?.configSchema]),K=(0,U.useMemo)(()=>me(b),[b]),q=(0,U.useMemo)(()=>he(H,K),[K,H]),J=(0,U.useMemo)(()=>_e(H,K),[K,H]),Y=(0,U.useMemo)(()=>({defaultBooleanLabel:V.schemaBooleanDefault,unsupportedArrayType:V.schemaUnsupportedArrayType,arrayAddPlaceholder:V.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>V.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[V]),X=(0,U.useMemo)(()=>n?(0,W.jsx)(ie,{ch:V,refreshing:f.isValidating,saveOk:!1,onRefresh:()=>void f.mutate()}):null,[f,V,n]);(0,U.useLayoutEffect)(()=>(v({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:X}),()=>y()),[y,X,t.settingsSections.channels,v]);let te=(0,U.useCallback)(e=>{r(F(e)),O(null),R(null)},[r]),re=(0,U.useCallback)(()=>{r(j),O(null),R(null)},[r]),oe=(0,U.useCallback)(async()=>{if(!b||!D)return!1;A(!0),R(null);try{let e=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[b.id]:D}})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error?.message??e.statusText)}return await E(D,!1),await h(),await f.mutate(),O(null),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{A(!1)}},[b,f,D,h,E]),se=(0,U.useCallback)(async e=>{P(e.id),R(null);try{let t=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e.id]:{enabled:e.enabled!==!0}}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await f.mutate(),await h(),b?.id===e.id&&await E()}catch(e){R(e instanceof Error?e.message:String(e))}finally{P(null)}},[b?.id,f,h,E]),Z=b?.ui?.modal,Q=Z?.placement!==`replace-config`;return n?(0,W.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-6`,children:[f.isLoading?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.loadingChannels}):f.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(f.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,W.jsx)(Ee,{entry:e,config:m[e.id]?.config,busy:N===e.id,ch:V,onOpen:()=>te(e.id),onToggle:()=>void se(e)},e.id))}),L?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:L}):null,(0,W.jsx)(ne,{presentation:`modal`,open:!!b,onOpenChange:e=>{e||re()},closeAriaLabel:V.close,srTitle:b?.label??V.selectChannel,srDescription:b?.description,wide:!0,footer:b?(0,W.jsx)(ae,{ch:V,dirty:!!D,saving:k,onCancel:re,onDiscard:()=>O(null),onSave:oe}):null,children:b?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(we,{entry:b}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:b.label}),(0,W.jsx)(`span`,{className:M(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,pe(b)),children:fe(b,V)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:G(b)?.[1].result===`qr`?V.scanLoginHint.replace(`{{channel}}`,b.label):b.description}),b.docsPath?(0,W.jsxs)(`a`,{href:b.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[V.docs,(0,W.jsx)(C,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:V.enabledLabel}),(0,W.jsx)(Te,{checked:b.enabled===!0,disabled:N===b.id,label:V.toggleChannel.replace(`{{channel}}`,b.label),onToggle:()=>void se(b)})]})]})}),Z?.entrypoint&&Z.placement===`before-config`?(0,W.jsx)(_,{extensionId:b.extensionId,extensionName:b.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:b.id,entry:b,config:B}}):null,Z?.placement===`replace-config`?null:(0,W.jsx)(ee,{entry:b,locale:e,messages:V,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await E(),await f.mutate(),await h()}},b.id),Z?.entrypoint&&Z.placement!==`before-config`?(0,W.jsx)(_,{extensionId:b.extensionId,extensionName:b.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:b.id,entry:b,config:B}}):null,Q?(0,W.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:V.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:V.basicConfigurationHint})]}),(0,W.jsx)(z,{schema:q,values:B,onChange:e=>O(e),disabled:k,labels:Y})]}):null,Q&&ve(J)?(0,W.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,W.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,W.jsx)(g,{className:`size-4 text-fg-muted`}),V.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,W.jsx)(z,{schema:J,values:B,onChange:e=>O(e),disabled:k,labels:Y})})]}):null,L?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:L}):null]}):null})]}):(0,W.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.tokenRequired})})}export{Oe as ChannelsSettingsPanel};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]);export{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{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{i as l}from"./theme-store-BZozwAeK.js";import{a as u,n as d}from"./fetch-CFdKBnE6.js";import{i as f,n as p,r as m}from"./gateway-startup-retry-DdngdObI.js";import{Ar as h,B as g,Ba as _,Bn as v,Dr as y,E as b,Ea as x,Ei as S,Er as C,F as w,Fo as T,Io as E,Ji as D,Mo as O,Nt as k,Or as A,Po as j,R as M,Tr as N,Ur as P,V as F,Vr as I,Zi as L,Zo as R,_r as z,ci as B,di as V,ei as H,fa as U,fi as W,gr as G,hi as K,ia as q,ii as ee,ja as te,jr as ne,kr as re,ns as ie,o as J,pi as Y,po as X,pr as ae,qa as oe,ro as se,si as ce,ua as le,ui as ue,uo as de,wr as fe,xo as pe,z as me,zi as he,zn as ge}from"./index-C_2yKRJX.js";import{n as _e,t as ve}from"./settings-form-section-BoYYZmJG.js";import{C as ye,E as be,S as xe,T as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,l as je,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,w as Ve,x as He,y as Ue}from"./settings-advanced-gate-t6v8Dwb8.js";import{s as We,t as Ge}from"./heartbeat-config-api-DcmAMYmN.js";import{h as Ke,m as qe,t as Je}from"./workflow-page.utils-EYg_xBQS.js";import{i as Ye,n as Xe,o as Ze,r as Qe,t as $e}from"./dist-DmGDgpy2.js";var Z=e(t(),1),Q=n(),$=r();function et(e){let t=(0,Q.c)(25),{open:n,onOpenChange:r,action:i,c:a,onDismiss:o,onConfirm:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),t[0]=c):c=t[0];let l=i===`delete`?a.delete:a.runNow,u;t[1]===l?u=t[2]:(u=(0,$.jsx)(ne,{className:`text-base font-semibold text-fg`,children:l}),t[1]=l,t[2]=u);let d=i===`delete`?a.confirmDelete:a.confirmRun,f;t[3]===d?f=t[4]:(f=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d}),t[3]=d,t[4]=f);let p;t[5]!==a.cancel||t[6]!==o?(p=(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:o,children:a.cancel}),t[5]=a.cancel,t[6]=o,t[7]=p):p=t[7];let m=i===`delete`?`bg-red-600 hover:bg-red-700`:void 0,g;t[8]===s?g=t[9]:(g=()=>void s(),t[8]=s,t[9]=g);let _=i===`delete`?a.delete:a.runNow,v;t[10]!==m||t[11]!==g||t[12]!==_?(v=(0,$.jsx)(W,{type:`button`,variant:`primary`,className:m,onClick:g,children:_}),t[10]=m,t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==v||t[15]!==p?(y=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[p,v]}),t[14]=v,t[15]=p,t[16]=y):y=t[16];let b;t[17]!==y||t[18]!==u||t[19]!==f?(b=(0,$.jsxs)(re,{children:[c,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(C,{className:`xopc-dialog-content-pane pointer-events-auto relative w-full max-w-md rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,y]})})]}),t[17]=y,t[18]=u,t[19]=f,t[20]=b):b=t[20];let x;return t[21]!==r||t[22]!==n||t[23]!==b?(x=(0,$.jsx)(h,{open:n,onOpenChange:r,children:b}),t[21]=r,t[22]=n,t[23]=b,t[24]=x):x=t[24],x}var tt={enabled:!0,maxConcurrentJobs:5,defaultTimezone:`UTC`,historyRetentionDays:7,enableMetrics:!0};function nt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rt(e){let t=nt(e)?e:{},n=nt(t.cron)?t.cron:{};return{enabled:n.enabled!==!1,maxConcurrentJobs:typeof n.maxConcurrentJobs==`number`&&Number.isFinite(n.maxConcurrentJobs)?Math.max(1,Math.min(100,Math.floor(n.maxConcurrentJobs))):tt.maxConcurrentJobs,defaultTimezone:typeof n.defaultTimezone==`string`&&n.defaultTimezone.trim()?n.defaultTimezone.trim():tt.defaultTimezone,historyRetentionDays:typeof n.historyRetentionDays==`number`&&Number.isFinite(n.historyRetentionDays)?Math.max(1,Math.min(365,Math.floor(n.historyRetentionDays))):tt.historyRetentionDays,enableMetrics:n.enableMetrics!==!1}}async function it(e){await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({cron:e})}),m()}function at(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,V,`dark:border-edge`)}function ot(){return{form:null,baseline:null,saving:!1,error:null,saveOk:!1,dirty:!1}}function st(e,t){switch(t.type){case`sync`:return{...e,form:structuredClone(t.parsed),baseline:structuredClone(t.parsed),saveOk:!1,dirty:!1};case`patch`:return e.form?{...e,form:{...e.form,...t.patch},dirty:!0,saveOk:!1}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline),dirty:!1}:e;case`saveStart`:return{...e,saving:!0,error:null};case`saveSuccess`:return e.form?{...e,saving:!1,baseline:structuredClone(e.form),dirty:!1,saveOk:!0}:{...e,saving:!1};case`saveError`:return{...e,saving:!1,error:t.error};case`clearSaveOk`:return{...e,saveOk:!1}}}function ct(e){let t=(0,Q.c)(83),{hasToken:n}=e,r=i(lt),o;t[0]===r?o=t[1]:(o=a(r),t[0]=r,t[1]=o);let s=o.cron.globals,{data:c,isLoading:l}=f(n),u;t[2]===c?u=t[3]:(u=c?.payload?.config===void 0?null:structuredClone(rt(c.payload.config)),t[2]=c,t[3]=u);let d=u,[p,m]=(0,Z.useReducer)(st,void 0,ot),h=(0,Z.useRef)(null),g,_;t[4]!==n||t[5]!==d||t[6]!==p.dirty?(g=()=>{!n||d===null||p.dirty||h.current===d||(h.current=d,m({type:`sync`,parsed:d}))},_=[n,d,p.dirty],t[4]=n,t[5]=d,t[6]=p.dirty,t[7]=g,t[8]=_):(g=t[7],_=t[8]),(0,Z.useEffect)(g,_);let v;t[9]!==p.baseline||t[10]!==p.form?(v=p.form&&p.baseline&&JSON.stringify(p.form)!==JSON.stringify(p.baseline),t[9]=p.baseline,t[10]=p.form,t[11]=v):v=t[11];let y=!!v,b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{m({type:`patch`,patch:e})},t[12]=b):b=t[12];let x=b,S;t[13]!==s.saveError||t[14]!==p.form||t[15]!==p.saving?(S=async()=>{if(!(!p.form||p.saving)){m({type:`saveStart`});try{await it(p.form),m({type:`saveSuccess`}),window.setTimeout(()=>m({type:`clearSaveOk`}),2500)}catch(e){let t=e;m({type:`saveError`,error:t instanceof Error?t.message:s.saveError})}}},t[13]=s.saveError,t[14]=p.form,t[15]=p.saving,t[16]=S):S=t[16];let C=S;if(!n||!p.form){if(l){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(te,{className:`size-4 animate-spin`}),t[17]=e):e=t[17];let n;return t[18]===s.loading?n=t[19]:(n=(0,$.jsx)(ve,{children:(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[e,s.loading]})}),t[18]=s.loading,t[19]=n),n}return null}let w;t[20]!==s.hint||t[21]!==s.title?(w=(0,$.jsx)(_e,{icon:pe,title:s.title,subtitle:s.hint}),t[20]=s.hint,t[21]=s.title,t[22]=w):w=t[22];let T;t[23]!==s.saved||t[24]!==p.saveOk?(T=p.saveOk?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:s.saved}):null,t[23]=s.saved,t[24]=p.saveOk,t[25]=T):T=t[25];let E=!y||p.saving,D;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>m({type:`discard`}),t[26]=D):D=t[26];let O;t[27]!==s.discard||t[28]!==E?(O=(0,$.jsx)(W,{type:`button`,variant:`secondary`,disabled:E,onClick:D,children:s.discard}),t[27]=s.discard,t[28]=E,t[29]=O):O=t[29];let k=!y||p.saving,A;t[30]===C?A=t[31]:(A=()=>void C(),t[30]=C,t[31]=A);let j=p.saving?s.saving:s.save,M;t[32]!==k||t[33]!==A||t[34]!==j?(M=(0,$.jsx)(W,{type:`button`,variant:`primary`,disabled:k,onClick:A,children:j}),t[32]=k,t[33]=A,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==O||t[37]!==M||t[38]!==T?(N=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-end gap-2`,children:[T,O,M]}),t[36]=O,t[37]=M,t[38]=T,t[39]=N):N=t[39];let P;t[40]===p.error?P=t[41]:(P=p.error?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p.error}):null,t[40]=p.error,t[41]=P);let F;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>x({enabled:e.target.checked}),t[42]=F):F=t[42];let I;t[43]===p.form.enabled?I=t[44]:(I=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:p.form.enabled,onChange:F}),t[43]=p.form.enabled,t[44]=I);let L;t[45]!==s.enabled||t[46]!==I?(L=(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[I,s.enabled]}),t[45]=s.enabled,t[46]=I,t[47]=L):L=t[47];let R=!p.form.enabled,z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x({maxConcurrentJobs:e}),t[48]=z):z=t[48];let B;t[49]!==s.maxConcurrent||t[50]!==R||t[51]!==p.form.maxConcurrentJobs?(B=(0,$.jsx)(ut,{label:s.maxConcurrent,value:p.form.maxConcurrentJobs,min:1,max:100,disabled:R,onChange:z}),t[49]=s.maxConcurrent,t[50]=R,t[51]=p.form.maxConcurrentJobs,t[52]=B):B=t[52];let V=!p.form.enabled,H;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>x({defaultTimezone:e}),t[53]=H):H=t[53];let U;t[54]!==s.timezone||t[55]!==V||t[56]!==p.form.defaultTimezone?(U=(0,$.jsx)(ut,{label:s.timezone,text:!0,value:p.form.defaultTimezone,disabled:V,onTextChange:H}),t[54]=s.timezone,t[55]=V,t[56]=p.form.defaultTimezone,t[57]=U):U=t[57];let G=!p.form.enabled,K;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>x({historyRetentionDays:e}),t[58]=K):K=t[58];let q;t[59]!==s.retentionDays||t[60]!==G||t[61]!==p.form.historyRetentionDays?(q=(0,$.jsx)(ut,{label:s.retentionDays,value:p.form.historyRetentionDays,min:1,max:365,disabled:G,onChange:K}),t[59]=s.retentionDays,t[60]=G,t[61]=p.form.historyRetentionDays,t[62]=q):q=t[62];let ee=!p.form.enabled,ne;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>x({enableMetrics:e.target.checked}),t[63]=ne):ne=t[63];let re;t[64]!==ee||t[65]!==p.form.enableMetrics?(re=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:p.form.enableMetrics,disabled:ee,onChange:ne}),t[64]=ee,t[65]=p.form.enableMetrics,t[66]=re):re=t[66];let ie;t[67]!==s.metrics||t[68]!==re?(ie=(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[re,s.metrics]}),t[67]=s.metrics,t[68]=re,t[69]=ie):ie=t[69];let J;t[70]!==B||t[71]!==U||t[72]!==q||t[73]!==ie?(J=(0,$.jsxs)(Re,{children:[B,U,q,ie]}),t[70]=B,t[71]=U,t[72]=q,t[73]=ie,t[74]=J):J=t[74];let Y;t[75]!==L||t[76]!==J?(Y=(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[L,J]}),t[75]=L,t[76]=J,t[77]=Y):Y=t[77];let X;return t[78]!==N||t[79]!==P||t[80]!==Y||t[81]!==w?(X=(0,$.jsxs)(ve,{children:[w,N,P,Y]}),t[78]=N,t[79]=P,t[80]=Y,t[81]=w,t[82]=X):X=t[82],X}function lt(e){return e.language}function ut(e){let t=(0,Q.c)(13),{label:n,value:r,min:i,max:a,disabled:o,text:s,onChange:c,onTextChange:l}=e,u;t[0]===n?u=t[1]:(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==o||t[3]!==a||t[4]!==i||t[5]!==c||t[6]!==l||t[7]!==s||t[8]!==r?(d=s?(0,$.jsx)(`input`,{className:Y(at(),`font-mono text-xs`),value:String(r),disabled:o,onChange:e=>l?.(e.target.value)}):(0,$.jsx)(`input`,{type:`number`,min:i,max:a,disabled:o,className:Y(at(),`max-w-xs font-mono text-xs`),value:typeof r==`number`?r:0,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&c&&i!==void 0&&a!==void 0&&c(Math.max(i,Math.min(a,Math.floor(t))))}}),t[2]=o,t[3]=a,t[4]=i,t[5]=c,t[6]=l,t[7]=s,t[8]=r,t[9]=d):d=t[9];let f;return t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}var dt=`*/5 * * * *`,ft=2100*1e3;function pt(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function mt(e){let t=pt(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function ht(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function gt(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function _t(e){let t=e?.trim();t&&(window.location.hash=`/workflows?run=${encodeURIComponent(t)}`)}function vt(e){return Y(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,ce,e&&`cursor-not-allowed opacity-60`)}function yt(){return Y(ue,B)}var bt=Y(ue,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),xt=Y(ue,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function St(e){return e===`settings`?`settings`:e===`system`||e===`systemTasks`?`systemTasks`:e===`history`?`history`:`myTasks`}function Ct(e){return e===`myTasks`?null:e===`systemTasks`?`system`:e===`history`?`history`:`settings`}function wt(e){switch(e){case`success`:return`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`;case`failed`:return`bg-red-500/15 text-red-800 dark:text-red-300`;case`running`:return`bg-accent/15 text-accent`;case`cancelled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Tt(e,t){return e.payload.kind===`workflowRun`?t.taskKindWorkflowRun:e.payload.kind===`agentTurn`?t.taskKindMessage:t.modeDirectOption}function Et(e){return e.length===0?null:e.find(e=>e.status===`failed`)?.id??e[0]?.id??null}function Dt(e){let t=(0,Q.c)(56),{row:n,expanded:r,onToggle:i,c:a,statusLabels:o}=e,s=n.error||n.summary||n.output||``,c;t[0]===s?c=t[1]:(c=s.trim(),t[0]=s,t[1]=c);let l=c,u=l.length>0,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover`,children:(0,$.jsx)(pe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0})}),t[2]=d):d=t[2];let f=n.startedAt,p;t[3]===n.startedAt?p=t[4]:(p=Se(n.startedAt),t[3]=n.startedAt,t[4]=p);let m;t[5]!==n.startedAt||t[6]!==p?(m=(0,$.jsx)(`time`,{className:`text-sm font-medium text-fg`,dateTime:f,children:p}),t[5]=n.startedAt,t[6]=p,t[7]=m):m=t[7];let h;t[8]===n.status?h=t[9]:(h=Y(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,wt(n.status)),t[8]=n.status,t[9]=h);let g;t[10]!==n.status||t[11]!==o?(g=Ue(n.status,o),t[10]=n.status,t[11]=o,t[12]=g):g=t[12];let _;t[13]!==h||t[14]!==g?(_=(0,$.jsx)(`span`,{className:h,children:g}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===n.duration?v=t[17]:(v=He(n.duration),t[16]=n.duration,t[17]=v);let y;t[18]===v?y=t[19]:(y=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:v}),t[18]=v,t[19]=y);let b;t[20]!==y||t[21]!==m||t[22]!==_?(b=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,_,y]}),t[20]=y,t[21]=m,t[22]=_,t[23]=b):b=t[23];let S;t[24]!==l||t[25]!==r||t[26]!==u?(S=!r&&u?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:l}):null,t[24]=l,t[25]=r,t[26]=u,t[27]=S):S=t[27];let C;t[28]!==l||t[29]!==r||t[30]!==u?(C=r&&u?(0,$.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-edge-subtle bg-surface-panel/80 p-2.5 font-mono text-xs leading-relaxed text-fg-muted`,children:l}):null,t[28]=l,t[29]=r,t[30]=u,t[31]=C):C=t[31];let w;t[32]!==b||t[33]!==S||t[34]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[d,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,S,C]})]}),t[32]=b,t[33]=S,t[34]=C,t[35]=w):w=t[35];let T;t[36]!==a||t[37]!==r||t[38]!==u||t[39]!==i?(T=u?(0,$.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:i,children:[(0,$.jsx)(j,{className:Y(`size-3.5 transition-transform`,r&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),r?a.detailCollapseRun:a.detailExpandRun]}):null,t[36]=a,t[37]=r,t[38]=u,t[39]=i,t[40]=T):T=t[40];let E;t[41]!==a||t[42]!==n.workflowRunId?(E=n.workflowRunId?.trim()?(0,$.jsxs)(W,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openWorkflowTitle,onClick:()=>_t(n.workflowRunId),children:[(0,$.jsx)(se,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openWorkflow]}):null,t[41]=a,t[42]=n.workflowRunId,t[43]=E):E=t[43];let D;t[44]!==a||t[45]!==n.sessionKey?(D=n.sessionKey?.trim()?(0,$.jsxs)(W,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openChatTitle,onClick:()=>gt(n.sessionKey),children:[(0,$.jsx)(x,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openChat]}):null,t[44]=a,t[45]=n.sessionKey,t[46]=D):D=t[46];let O;t[47]!==E||t[48]!==D?(O=(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[E,D]}),t[47]=E,t[48]=D,t[49]=O):O=t[49];let k;t[50]!==T||t[51]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle px-3 py-2 dark:border-edge-subtle`,children:[T,O]}),t[50]=T,t[51]=O,t[52]=k):k=t[52];let A;return t[53]!==w||t[54]!==k?(A=(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:[w,k]}),t[53]=w,t[54]=k,t[55]=A):A=t[55],A}function Ot(e){let t=(0,Q.c)(13),{icon:n,label:r,value:i,valueClassName:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]!==r||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[o,r]}),t[2]=r,t[3]=o,t[4]=s):s=t[4];let c;t[5]===a?c=t[6]:(c=Y(`mt-1 truncate text-sm font-medium text-fg`,a),t[5]=a,t[6]=c);let l;t[7]!==c||t[8]!==i?(l=(0,$.jsx)(`p`,{className:c,children:i}),t[7]=c,t[8]=i,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-2.5 dark:border-edge-subtle`,children:[s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12],u}function kt({open:e,onDismiss:t,detailJob:n,detailLoading:r,detailHistory:i,c:a,localeTag:o,scheduleBadgeLabels:s,chatWorkingDirNotSet:l,statusLabels:u,onEdit:d,onRunNow:f,onToggle:p,onDelete:m}){let[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!1),w=(0,Z.useMemo)(()=>{let e=0,t=0;for(let n of i)n.status===`success`&&(e+=1),n.status===`failed`&&(t+=1);return{success:e,failed:t}},[i]),O=i[0]??null;(0,Z.useEffect)(()=>{if(!e){_(!1),y(null),x(!1);return}y(Et(i))},[e,n?.id,i]);let k=(0,Z.useCallback)(async()=>{n?.schedule&&await H(n.schedule)&&(x(!0),window.setTimeout(()=>x(!1),1500))},[n?.schedule]),M=n?Ve(n,o,s):`—`;return(0,$.jsx)(h,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(re,{children:[(0,$.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(C,{className:Y(`xopc-dialog-content-pane pointer-events-auto relative flex w-full max-w-lg flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,`max-h-[min(85vh,44rem)]`,`dark:border-edge`),"aria-describedby":void 0,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(ne,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n?.name?.trim()||n?.id||`—`}),n?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:M}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n.enabled,"aria-label":n.enabled?a.enabled:a.disabled,className:Y(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`),onClick:()=>p(n,!n.enabled),children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:(0,$.jsx)(K,{className:`size-5`,strokeWidth:1.75})})})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:r?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(te,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.scheduleLabel}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-sm font-medium leading-relaxed text-fg`,children:M}),(0,$.jsx)(W,{type:`button`,variant:`secondary`,className:`size-8 shrink-0 p-0`,title:a.detailCopySchedule,"aria-label":a.detailCopySchedule,onClick:()=>void k(),children:b?(0,$.jsx)(T,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75}):(0,$.jsx)(c,{className:`size-3.5`,strokeWidth:1.75})})]}),(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-subtle`,children:[a.detailCronTechnical,`: `]}),(0,$.jsx)(`code`,{className:`font-mono`,children:n.schedule})]})]})]}),(0,$.jsxs)(`section`,{"aria-label":a.statsRegion,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(Ot,{icon:E,label:a.nextRun,value:n.next_run?xe(n.next_run,a.timeLabels):`—`}),(0,$.jsx)(Ot,{icon:pe,label:a.detailLastRun,value:O?Ue(O.status,u):a.detailNoRecentRuns,valueClassName:O?.status===`failed`?`text-red-700 dark:text-red-300`:O?.status===`success`?`text-emerald-800 dark:text-emerald-300`:void 0})]}),i.length>0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:a.detailRunCount.replace(`{{success}}`,String(w.success)).replace(`{{failed}}`,String(w.failed))}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailWhatItDoes}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 p-3 dark:border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`mb-2 inline-flex rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:Tt(n,a)}),(0,$.jsx)(`div`,{className:`min-w-0 break-words text-fg [&_.markdown-body]:text-sm [&_.markdown-body]:leading-relaxed`,children:(0,$.jsx)(ge,{content:Pe(n),compact:!0,className:`text-sm`})})]})]}),(0,$.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base/35`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left`,"aria-expanded":g,onClick:()=>_(e=>!e),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunSettings})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.detailRunSettingsHint})]}),(0,$.jsx)(j,{className:Y(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,g&&`rotate-180`),"aria-hidden":!0})]}),g?(0,$.jsxs)(`dl`,{className:`grid gap-3 border-t border-edge px-4 py-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.sessionTarget===`isolated`?a.modeAgentOption:a.modeDirectOption})]}),n.sessionTarget===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.agentId?.trim()?n.agentId.trim():a.agentProfileDefault})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:n.workingDirectory?.trim()?n.workingDirectory.trim():l})]})]}):null,n.delivery?.channel===`local`||n.sessionTarget===`isolated`&&!n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.delivery?.channel===`local`?a.deliveryTargetLocalChannel:a.deliveryLocalOnly})]}):n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,$.jsx)(`code`,{className:`text-xs`,children:n.delivery?.channel??``}),` → `,Te(n,a.channelLocal)]})]}):null,n.model?.trim()?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.model.trim()})]}):null]}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunHistory}),i.length>0?(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.length}):null]}),i.length===0?(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-dashed border-edge-subtle px-4 py-8 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(pe,{className:`mx-auto size-8 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:a.noRunsYet})]}):(0,$.jsx)(`ul`,{className:`mt-2 space-y-2`,children:i.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(Dt,{row:e,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),c:a,statusLabels:u})},e.id))})]})]}):null}),n&&!r?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(W,{type:`button`,className:`gap-1.5`,onClick:()=>f(n),children:[(0,$.jsx)(U,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.runNow]}),(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:()=>d(n),children:a.edit}),(0,$.jsxs)(W,{type:`button`,variant:`secondary`,className:`ml-auto text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:()=>m(n),children:[(0,$.jsx)(S,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.delete]})]})}):null]})})]})})}function At(e){let t=(0,Q.c)(31),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,title:s,maxWidthClass:c,clearLabel:l,onClear:u}=e,d;t[0]!==r||t[1]!==n?(d={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=d):d=t[2];let f=me(d),p;t[3]===n?p=t[4]:(p=n.trim(),t[3]=n,t[4]=p);let m=p,h=s??(m?`${m}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`),_=i||f.picking,v=o??a.notSet,y;t[5]!==c||t[6]!==f.pick||t[7]!==h||t[8]!==_||t[9]!==v||t[10]!==n?(y=(0,$.jsx)(g,{value:n,onPick:f.pick,disabled:_,placeholder:v,title:h,maxWidthClass:c}),t[5]=c,t[6]=f.pick,t[7]=h,t[8]=_,t[9]=v,t[10]=n,t[11]=y):y=t[11];let b;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==f.picking||t[16]!==m?(b=l&&m&&u?(0,$.jsx)(`button`,{type:`button`,disabled:i||f.picking,className:`text-xs font-medium text-accent hover:underline disabled:opacity-50`,onClick:u,children:l}):null,t[12]=l,t[13]=i,t[14]=u,t[15]=f.picking,t[16]=m,t[17]=b):b=t[17];let x;t[18]!==y||t[19]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y,b]}),t[18]=y,t[19]=b,t[20]=x):x=t[20];let S;t[21]!==f.confirmPick||t[22]!==f.hasNativePicker||t[23]!==f.modalOpen||t[24]!==f.setModalOpen||t[25]!==m||t[26]!==a?(S=f.hasNativePicker?null:(0,$.jsx)(w,{open:f.modalOpen,onOpenChange:f.setModalOpen,initialAbsolutePath:m||void 0,onConfirm:f.confirmPick,wd:a}),t[21]=f.confirmPick,t[22]=f.hasNativePicker,t[23]=f.modalOpen,t[24]=f.setModalOpen,t[25]=m,t[26]=a,t[27]=S):S=t[27];let C;return t[28]!==x||t[29]!==S?(C=(0,$.jsxs)($.Fragment,{children:[x,S]}),t[28]=x,t[29]=S,t[30]=C):C=t[30],C}function jt(e,t){return e[t]??t}function Mt(e,t){let n=J[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function Nt(e,t){return(J[e]??[]).every(e=>!e.required||!!t[e.key]?.trim())}function Pt(e){let t=(0,Q.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Ft(e){let t=(0,Q.c)(33),{workflowName:n,language:r,argValues:i,onArgValuesChange:o,goal:s,onGoalChange:c,examplePrompts:l,showGoal:u,inputClassName:d}=e,f;t[0]===l?f=t[1]:(f=l===void 0?[]:l,t[0]=l,t[1]=f);let p=f,m=u===void 0?!0:u,h,g,_,v,y,b,x;if(t[2]!==i||t[3]!==p||t[4]!==s||t[5]!==d||t[6]!==r||t[7]!==o||t[8]!==c||t[9]!==m||t[10]!==n){_=a(r).workflows;let e=J[n]??[];g=e.length>0;let l=Y(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,d),u;t[18]!==i||t[19]!==o||t[20]!==c?(u=e=>{qe(e,c,e=>{o(e(i))})},t[18]=i,t[19]=o,t[20]=c,t[21]=u):u=t[21],h=u,v=`flex flex-col gap-3`,y=e.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[jt(_.args,e.labelKey),e.required?` *`:``]}),e.multiline?(0,$.jsx)(`textarea`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:jt(_.args,e.placeholderKey),className:Y(l,`min-h-20 resize-y`)}):(0,$.jsx)(`input`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:jt(_.args,e.placeholderKey),className:l})]},e.key)),b=g&&p.length>0?(0,$.jsx)(Pt,{examples:p,labels:_,onSelect:h}):null,x=m?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:_.goalLabel}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:_.goalPlaceholder,className:Y(l,`min-h-20 resize-y`)})]}):null,t[2]=i,t[3]=p,t[4]=s,t[5]=d,t[6]=r,t[7]=o,t[8]=c,t[9]=m,t[10]=n,t[11]=h,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x}else h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17];let S;t[22]!==h||t[23]!==p||t[24]!==g||t[25]!==_?(S=!g&&p.length>0?(0,$.jsx)(Pt,{examples:p,labels:_,onSelect:h}):null,t[22]=h,t[23]=p,t[24]=g,t[25]=_,t[26]=S):S=t[26];let C;return t[27]!==v||t[28]!==y||t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b,x,S]}),t[27]=v,t[28]=y,t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32],C}function It(e){let t=(0,Q.c)(190),{open:n,onRequestClose:r,c:a,chatM:o,agentsMessages:s,isDark:c,channels:l,sessionChatIds:u,cronAgentSelectOptions:d,defaultModelResolver:f,formMode:p,formJobId:m,formName:g,onFormNameChange:_,formSchedule:y,onFormScheduleChange:b,formSubmitting:x,formTaskKind:S,onFormTaskKindChange:w,workflowDefinitions:T,workflowDefinitionsLoading:E,formWorkflowDefinitionId:D,onFormWorkflowDefinitionIdChange:O,formWorkflowGoal:j,onFormWorkflowGoalChange:M,formWorkflowArgValues:P,onFormWorkflowArgValuesChange:I,formSessionTarget:L,onFormSessionTargetChange:R,formAgentLocalOnly:z,onFormAgentLocalOnlyChange:B,formModel:V,onFormModelUserChange:H,formAgentId:U,onFormAgentIdChange:G,formWorkingDirectory:ee,onFormWorkingDirectoryChange:te,formChannel:ie,onFormChannelChange:J,formChatId:X,onFormChatIdChange:ae,formMessage:oe,onFormMessageChange:se,formMessageMdMode:ce,onSetMessageMdMode:le,messageEditorNonce:ue,needsDeliveryChat:fe,showChannelPicker:pe,canSubmit:me,onSubmit:_e,onRefreshRecipients:ve}=e,be=i(Bt),xe,Se;if(t[0]!==D||t[1]!==be||t[2]!==T){let e;t[5]===D?e=t[6]:(e=e=>e.id===D.trim(),t[5]=D,t[6]=e),xe=T.find(e),Se=xe?Ke(xe,be):null,t[0]=D,t[1]=be,t[2]=T,t[3]=xe,t[4]=Se}else xe=t[3],Se=t[4];let Ce=Se,we;t[7]===r?we=t[8]:(we=e=>!e&&r(),t[7]=r,t[8]=we);let Te;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[9]=Te):Te=t[9];let Ee=p===`edit`?a.editJob:a.addJob,De;t[10]===Ee?De=t[11]:(De=(0,$.jsx)(ne,{className:`text-base font-semibold text-fg`,children:Ee}),t[10]=Ee,t[11]=De);let Oe;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(K,{className:`size-5`,strokeWidth:1.75}),t[12]=Oe):Oe=t[12];let ke;t[13]===a.close?ke=t[14]:(ke=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:Oe})}),t[13]=a.close,t[14]=ke);let Ae;t[15]!==De||t[16]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[De,ke]}),t[15]=De,t[16]=ke,t[17]=Ae):Ae=t[17];let je;t[18]===a.name?je=t[19]:(je=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.name}),t[18]=a.name,t[19]=je);let Me;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Me=vt(),t[20]=Me):Me=t[20];let Ne;t[21]===_?Ne=t[22]:(Ne=e=>_(e.target.value),t[21]=_,t[22]=Ne);let Pe;t[23]!==a.namePlaceholder||t[24]!==g||t[25]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`text`,className:Me,value:g,onChange:Ne,placeholder:a.namePlaceholder}),t[23]=a.namePlaceholder,t[24]=g,t[25]=Ne,t[26]=Pe):Pe=t[26];let Fe;t[27]!==Pe||t[28]!==je?(Fe=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[je,Pe]}),t[27]=Pe,t[28]=je,t[29]=Fe):Fe=t[29];let Ie;t[30]!==a.schedulePicker||t[31]!==y||t[32]!==x||t[33]!==b?(Ie=(0,$.jsx)(We,{value:y,onChange:b,disabled:x,labels:a.schedulePicker}),t[30]=a.schedulePicker,t[31]=y,t[32]=x,t[33]=b,t[34]=Ie):Ie=t[34];let Le;t[35]===a.taskKind?Le=t[36]:(Le=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.taskKind}),t[35]=a.taskKind,t[36]=Le);let Re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Re=yt(),t[37]=Re):Re=t[37];let ze;t[38]===w?ze=t[39]:(ze=e=>w(e.target.value),t[38]=w,t[39]=ze);let Be;t[40]===a.taskKindMessage?Be=t[41]:(Be=(0,$.jsx)(`option`,{value:`message`,children:a.taskKindMessage}),t[40]=a.taskKindMessage,t[41]=Be);let Ve;t[42]===a.taskKindWorkflowRun?Ve=t[43]:(Ve=(0,$.jsx)(`option`,{value:`workflowRun`,children:a.taskKindWorkflowRun}),t[42]=a.taskKindWorkflowRun,t[43]=Ve);let He;t[44]!==x||t[45]!==S||t[46]!==ze||t[47]!==Be||t[48]!==Ve?(He=(0,$.jsxs)(`select`,{className:Re,value:S,disabled:x,onChange:ze,children:[Be,Ve]}),t[44]=x,t[45]=S,t[46]=ze,t[47]=Be,t[48]=Ve,t[49]=He):He=t[49];let Ue;t[50]!==Le||t[51]!==He?(Ue=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[Le,He]}),t[50]=Le,t[51]=He,t[52]=Ue):Ue=t[52];let Ge;t[53]!==s||t[54]!==a.agentProfile||t[55]!==a.agentProfileDefault||t[56]!==a.agentProfileHint||t[57]!==a.channel||t[58]!==a.channelLocal||t[59]!==a.lastActiveLabels||t[60]!==a.noRecentChatsOption||t[61]!==a.recipient||t[62]!==a.recipientPlaceholder||t[63]!==a.refreshList||t[64]!==a.refreshRecipientHint||t[65]!==a.selectRecipient||t[66]!==a.workflowDefinition||t[67]!==a.workflowDefinitionCustom||t[68]!==a.workflowDefinitionMissing||t[69]!==a.workflowDefinitionPlaceholder||t[70]!==a.workflowDefinitionsEmpty||t[71]!==a.workflowDefinitionsLoading||t[72]!==a.workflowDeliveryHint||t[73]!==a.workflowLocalOnly||t[74]!==a.workflowLocalOnlyHint||t[75]!==l||t[76]!==d||t[77]!==U||t[78]!==z||t[79]!==ie||t[80]!==X||t[81]!==x||t[82]!==S||t[83]!==P||t[84]!==D||t[85]!==j||t[86]!==be||t[87]!==fe||t[88]!==G||t[89]!==B||t[90]!==J||t[91]!==ae||t[92]!==I||t[93]!==O||t[94]!==M||t[95]!==ve||t[96]!==xe||t[97]!==Ce||t[98]!==u||t[99]!==pe||t[100]!==T||t[101]!==E?(Ge=S===`workflowRun`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workflowDefinition}),(0,$.jsxs)(`select`,{className:yt(),value:D,disabled:x||E,onChange:e=>O(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:E?a.workflowDefinitionsLoading:a.workflowDefinitionPlaceholder}),D.trim()&&!T.some(e=>e.id===D.trim())?(0,$.jsx)(`option`,{value:D,children:D}):null,T.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.title,e.metadata.source===`user`?` (${a.workflowDefinitionCustom})`:``]},e.id))]}),!E&&T.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDefinitionsEmpty}):null,Ce?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:Ce.description}):D.trim()&&!xe?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.workflowDefinitionMissing}):null]}),D.trim()?(0,$.jsx)(Ft,{workflowName:D.trim(),language:be,argValues:P,onArgValuesChange:I,goal:j,onGoalChange:M,examplePrompts:Ce?.examplePrompts??[],inputClassName:vt()}):null,(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:yt(),value:U,disabled:x,onChange:e=>G(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${k(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:Y(`ui-checkbox`,`mt-0.5`),checked:z,onChange:e=>B(e.target.checked),"aria-label":a.workflowLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.workflowLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.workflowLocalOnlyHint})]})]}),pe?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:yt(),value:ie,onChange:e=>J(e.target.value),children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(Rt)]})]}),fe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(q,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:Y(vt(),`min-w-0 w-full sm:flex-1`),value:X,onChange:e=>ae(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:bt,value:X,onChange:e=>{let t=e.target.value;t&&ae(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:ye(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDeliveryHint})]}):null]}):null]}):null,t[53]=s,t[54]=a.agentProfile,t[55]=a.agentProfileDefault,t[56]=a.agentProfileHint,t[57]=a.channel,t[58]=a.channelLocal,t[59]=a.lastActiveLabels,t[60]=a.noRecentChatsOption,t[61]=a.recipient,t[62]=a.recipientPlaceholder,t[63]=a.refreshList,t[64]=a.refreshRecipientHint,t[65]=a.selectRecipient,t[66]=a.workflowDefinition,t[67]=a.workflowDefinitionCustom,t[68]=a.workflowDefinitionMissing,t[69]=a.workflowDefinitionPlaceholder,t[70]=a.workflowDefinitionsEmpty,t[71]=a.workflowDefinitionsLoading,t[72]=a.workflowDeliveryHint,t[73]=a.workflowLocalOnly,t[74]=a.workflowLocalOnlyHint,t[75]=l,t[76]=d,t[77]=U,t[78]=z,t[79]=ie,t[80]=X,t[81]=x,t[82]=S,t[83]=P,t[84]=D,t[85]=j,t[86]=be,t[87]=fe,t[88]=G,t[89]=B,t[90]=J,t[91]=ae,t[92]=I,t[93]=O,t[94]=M,t[95]=ve,t[96]=xe,t[97]=Ce,t[98]=u,t[99]=pe,t[100]=T,t[101]=E,t[102]=Ge):Ge=t[102];let qe;t[103]!==s||t[104]!==a.agentLocalOnly||t[105]!==a.agentLocalOnlyHint||t[106]!==a.agentProfile||t[107]!==a.agentProfileDefault||t[108]!==a.agentProfileHint||t[109]!==a.channel||t[110]!==a.channelLocal||t[111]!==a.enterManuallyOrSelect||t[112]!==a.lastActiveLabels||t[113]!==a.message||t[114]!==a.messageEdit||t[115]!==a.messageMarkdownHint||t[116]!==a.messagePlaceholder||t[117]!==a.messagePreview||t[118]!==a.mode||t[119]!==a.modeAgent||t[120]!==a.modeAgentOption||t[121]!==a.modeDirect||t[122]!==a.modeDirectOption||t[123]!==a.model||t[124]!==a.noRecentChats||t[125]!==a.noRecentChatsOption||t[126]!==a.recipient||t[127]!==a.recipientPlaceholder||t[128]!==a.refreshList||t[129]!==a.refreshRecipientHint||t[130]!==a.selectRecipient||t[131]!==a.workingDirectoryHint||t[132]!==a.workingDirectoryLabel||t[133]!==a.workingDirectoryReset||t[134]!==l||t[135]!==o||t[136]!==d||t[137]!==f||t[138]!==U||t[139]!==z||t[140]!==ie||t[141]!==X||t[142]!==m||t[143]!==oe||t[144]!==ce||t[145]!==V||t[146]!==L||t[147]!==x||t[148]!==S||t[149]!==ee||t[150]!==c||t[151]!==ue||t[152]!==fe||t[153]!==G||t[154]!==B||t[155]!==J||t[156]!==ae||t[157]!==se||t[158]!==H||t[159]!==R||t[160]!==te||t[161]!==ve||t[162]!==le||t[163]!==u||t[164]!==pe?(qe=S===`message`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsxs)(`select`,{className:yt(),value:L,onChange:e=>{let t=e.target.value;R(t,f,V.trim())},children:[(0,$.jsx)(`option`,{value:`main`,children:a.modeDirectOption}),(0,$.jsx)(`option`,{value:`isolated`,children:a.modeAgentOption})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:L===`main`?a.modeDirect:a.modeAgent})]}),L===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(F,{value:V,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:H})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:yt(),value:U,disabled:x,onChange:e=>G(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${k(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(At,{value:ee,onChange:te,disabled:x,wd:o.workingDirectory,placeholder:o.workingDirectory.notSet,maxWidthClass:`max-w-[min(16rem,48vw)]`,clearLabel:a.workingDirectoryReset,onClear:()=>te(``)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workingDirectoryHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:Y(`ui-checkbox`,`mt-0.5`),checked:z,onChange:e=>B(e.target.checked),"aria-label":a.agentLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.agentLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.agentLocalOnlyHint})]})]})]}):null,pe?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:yt(),value:ie,onChange:e=>{let t=e.target.value;J(t)},children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(Lt)]})]}),fe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(q,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:Y(vt(),`min-w-0 w-full sm:flex-1`),value:X,onChange:e=>ae(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:bt,value:X,onChange:e=>{let t=e.target.value;t&&ae(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:ye(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.length>0?a.enterManuallyOrSelect:a.noRecentChats})]}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.message}),(0,$.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,ce===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>le(`edit`),children:[(0,$.jsx)(he,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messageEdit]}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,ce===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>le(`preview`),children:[(0,$.jsx)(de,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messagePreview]})]})]}),(0,$.jsx)(`div`,{className:Y(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,x&&`pointer-events-none opacity-60`),children:ce===`edit`?(0,$.jsx)(v,{initialContent:oe,onChange:se,isDark:c,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${m??`new`}-${ue}`):(0,$.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:oe.trim()?(0,$.jsx)(ge,{content:oe,compact:!0,className:`text-sm`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.messagePlaceholder})})}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.messageMarkdownHint})]})]}):null,t[103]=s,t[104]=a.agentLocalOnly,t[105]=a.agentLocalOnlyHint,t[106]=a.agentProfile,t[107]=a.agentProfileDefault,t[108]=a.agentProfileHint,t[109]=a.channel,t[110]=a.channelLocal,t[111]=a.enterManuallyOrSelect,t[112]=a.lastActiveLabels,t[113]=a.message,t[114]=a.messageEdit,t[115]=a.messageMarkdownHint,t[116]=a.messagePlaceholder,t[117]=a.messagePreview,t[118]=a.mode,t[119]=a.modeAgent,t[120]=a.modeAgentOption,t[121]=a.modeDirect,t[122]=a.modeDirectOption,t[123]=a.model,t[124]=a.noRecentChats,t[125]=a.noRecentChatsOption,t[126]=a.recipient,t[127]=a.recipientPlaceholder,t[128]=a.refreshList,t[129]=a.refreshRecipientHint,t[130]=a.selectRecipient,t[131]=a.workingDirectoryHint,t[132]=a.workingDirectoryLabel,t[133]=a.workingDirectoryReset,t[134]=l,t[135]=o,t[136]=d,t[137]=f,t[138]=U,t[139]=z,t[140]=ie,t[141]=X,t[142]=m,t[143]=oe,t[144]=ce,t[145]=V,t[146]=L,t[147]=x,t[148]=S,t[149]=ee,t[150]=c,t[151]=ue,t[152]=fe,t[153]=G,t[154]=B,t[155]=J,t[156]=ae,t[157]=se,t[158]=H,t[159]=R,t[160]=te,t[161]=ve,t[162]=le,t[163]=u,t[164]=pe,t[165]=qe):qe=t[165];let Je;t[166]!==Fe||t[167]!==Ie||t[168]!==Ue||t[169]!==Ge||t[170]!==qe?(Je=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Fe,Ie,Ue,Ge,qe]})}),t[166]=Fe,t[167]=Ie,t[168]=Ue,t[169]=Ge,t[170]=qe,t[171]=Je):Je=t[171];let Ye;t[172]!==a.cancel||t[173]!==r?(Ye=(0,$.jsx)(W,{type:`button`,variant:`secondary`,onClick:r,children:a.cancel}),t[172]=a.cancel,t[173]=r,t[174]=Ye):Ye=t[174];let Xe=x||!me,Ze=x?a.loading:p===`edit`?a.save:a.create,Qe;t[175]!==_e||t[176]!==Xe||t[177]!==Ze?(Qe=(0,$.jsx)(W,{type:`button`,variant:`primary`,disabled:Xe,onClick:_e,children:Ze}),t[175]=_e,t[176]=Xe,t[177]=Ze,t[178]=Qe):Qe=t[178];let $e;t[179]!==Ye||t[180]!==Qe?($e=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Ye,Qe]}),t[179]=Ye,t[180]=Qe,t[181]=$e):$e=t[181];let Z;t[182]!==Je||t[183]!==$e||t[184]!==Ae?(Z=(0,$.jsxs)(re,{children:[Te,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(C,{className:`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,800px)] w-full max-w-md flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-lg lg:max-w-xl dark:border-edge`,onOpenAutoFocus:zt,children:[Ae,Je,$e]})})]}),t[182]=Je,t[183]=$e,t[184]=Ae,t[185]=Z):Z=t[185];let et;return t[186]!==n||t[187]!==we||t[188]!==Z?(et=(0,$.jsx)($.Fragment,{children:(0,$.jsx)(h,{open:n,onOpenChange:we,children:Z})}),t[186]=n,t[187]=we,t[188]=Z,t[189]=et):et=t[189],et}function Lt(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Rt(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function zt(e){return e.preventDefault()}function Bt(e){return e.language}function Vt(e){let t=(0,Q.c)(76),{c:n,mainTab:r,onMainTabChange:i,jobSort:a,onJobSortChange:o,historyRange:s,onHistoryRangeChange:c,historyJobFilter:l,onHistoryJobFilterChange:u,historyStatusFilter:d,onHistoryStatusFilterChange:f,jobs:p}=e,m=n.title,h=r===`myTasks`,g=r===`myTasks`?`text-fg`:`text-fg-muted hover:text-fg`,_;t[0]===g?_=t[1]:(_=Y(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,g),t[0]=g,t[1]=_);let v;t[2]===i?v=t[3]:(v=()=>i(`myTasks`),t[2]=i,t[3]=v);let y;t[4]!==n.tabMyTasks||t[5]!==h||t[6]!==_||t[7]!==v?(y=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h,className:_,onClick:v,children:n.tabMyTasks}),t[4]=n.tabMyTasks,t[5]=h,t[6]=_,t[7]=v,t[8]=y):y=t[8];let b=r===`systemTasks`,x=r===`systemTasks`?`text-fg`:`text-fg-muted hover:text-fg`,S;t[9]===x?S=t[10]:(S=Y(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,x),t[9]=x,t[10]=S);let C;t[11]===i?C=t[12]:(C=()=>i(`systemTasks`),t[11]=i,t[12]=C);let w;t[13]!==n.tabSystemTasks||t[14]!==C||t[15]!==b||t[16]!==S?(w=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":b,className:S,onClick:C,children:n.tabSystemTasks}),t[13]=n.tabSystemTasks,t[14]=C,t[15]=b,t[16]=S,t[17]=w):w=t[17];let T=r===`history`,E=r===`history`?`text-fg`:`text-fg-muted hover:text-fg`,D;t[18]===E?D=t[19]:(D=Y(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,E),t[18]=E,t[19]=D);let O;t[20]===i?O=t[21]:(O=()=>i(`history`),t[20]=i,t[21]=O);let k;t[22]!==n.tabRunHistory||t[23]!==T||t[24]!==D||t[25]!==O?(k=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":T,className:D,onClick:O,children:n.tabRunHistory}),t[22]=n.tabRunHistory,t[23]=T,t[24]=D,t[25]=O,t[26]=k):k=t[26];let A=r===`settings`,j=r===`settings`?`text-fg`:`text-fg-muted hover:text-fg`,M;t[27]===j?M=t[28]:(M=Y(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,j),t[27]=j,t[28]=M);let N;t[29]===i?N=t[30]:(N=()=>i(`settings`),t[29]=i,t[30]=N);let P;t[31]!==n.globals.title||t[32]!==A||t[33]!==M||t[34]!==N?(P=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":A,className:M,onClick:N,children:n.globals.title}),t[31]=n.globals.title,t[32]=A,t[33]=M,t[34]=N,t[35]=P):P=t[35];let F;t[36]!==n.title||t[37]!==w||t[38]!==k||t[39]!==P||t[40]!==y?(F=(0,$.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":m,children:[y,w,k,P]}),t[36]=n.title,t[37]=w,t[38]=k,t[39]=P,t[40]=y,t[41]=F):F=t[41];let I=r===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,L;t[42]===I?L=t[43]:(L=Y(`flex min-w-0 items-center gap-2`,I),t[42]=I,t[43]=L);let R;t[44]!==n.sortCreatedAsc||t[45]!==n.sortCreatedDesc||t[46]!==a||t[47]!==r||t[48]!==o?(R=r===`myTasks`||r===`systemTasks`?(0,$.jsxs)(`select`,{className:xt,value:a,onChange:e=>o(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,$.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,$.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):null,t[44]=n.sortCreatedAsc,t[45]=n.sortCreatedDesc,t[46]=a,t[47]=r,t[48]=o,t[49]=R):R=t[49];let B;t[50]!==n.execStatusCancelled||t[51]!==n.execStatusFailed||t[52]!==n.execStatusRunning||t[53]!==n.execStatusSuccess||t[54]!==n.filterAllStatuses||t[55]!==n.filterAllTasks||t[56]!==n.historyRangeDay||t[57]!==n.historyRangeMonth||t[58]!==n.historyRangeWeek||t[59]!==n.runHistoryTitle||t[60]!==l||t[61]!==s||t[62]!==d||t[63]!==p||t[64]!==r||t[65]!==u||t[66]!==c||t[67]!==f?(B=r===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:Y(z,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(G,`px-2.5 py-1`,s===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,s===e&&`text-fg`),onClick:()=>c(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,$.jsxs)(`select`,{className:xt,value:l,onChange:e=>u(e.target.value),"aria-label":n.filterAllTasks,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllTasks}),p.map(Ht)]}),(0,$.jsxs)(`select`,{className:xt,value:d,onChange:e=>f(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,$.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,$.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,$.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,$.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]}):null,t[50]=n.execStatusCancelled,t[51]=n.execStatusFailed,t[52]=n.execStatusRunning,t[53]=n.execStatusSuccess,t[54]=n.filterAllStatuses,t[55]=n.filterAllTasks,t[56]=n.historyRangeDay,t[57]=n.historyRangeMonth,t[58]=n.historyRangeWeek,t[59]=n.runHistoryTitle,t[60]=l,t[61]=s,t[62]=d,t[63]=p,t[64]=r,t[65]=u,t[66]=c,t[67]=f,t[68]=B):B=t[68];let V;t[69]!==L||t[70]!==R||t[71]!==B?(V=(0,$.jsxs)(`div`,{className:L,children:[R,B]}),t[69]=L,t[70]=R,t[71]=B,t[72]=V):V=t[72];let H;return t[73]!==F||t[74]!==V?(H=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[F,V]}),t[73]=F,t[74]=V,t[75]=H):H=t[75],H}function Ht(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function Ut(e){let t=(0,Q.c)(23),{c:n,loading:r,runHistoryLoading:i,onRefresh:a,onOpenTemplatePicker:o,onAddJob:s}=e,c=r||i,l=n.refresh,u=n.refresh,d;t[0]===a?d=t[1]:(d=()=>void a(),t[0]=a,t[1]=d);let f=c&&`animate-spin`,p;t[2]===f?p=t[3]:(p=Y(`size-4`,f),t[2]=f,t[3]=p);let m;t[4]===p?m=t[5]:(m=(0,$.jsx)(q,{className:p,strokeWidth:1.75}),t[4]=p,t[5]=m);let h;t[6]!==c||t[7]!==n.refresh||t[8]!==d||t[9]!==m?(h=(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:c,title:l,"aria-label":u,onClick:d,children:m}),t[6]=c,t[7]=n.refresh,t[8]=d,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(_,{className:`size-4`,strokeWidth:1.75}),t[11]=g):g=t[11];let v;t[12]!==n.fromTemplate||t[13]!==o?(v=(0,$.jsxs)(W,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:o,children:[g,n.fromTemplate]}),t[12]=n.fromTemplate,t[13]=o,t[14]=v):v=t[14];let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(le,{className:`size-4`,strokeWidth:1.75}),t[15]=y):y=t[15];let b;t[16]!==n.addJob||t[17]!==s?(b=(0,$.jsxs)(W,{type:`button`,variant:`primary`,className:`gap-2`,onClick:s,children:[y,n.addJob]}),t[16]=n.addJob,t[17]=s,t[18]=b):b=t[18];let x;return t[19]!==b||t[20]!==h||t[21]!==v?(x=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[h,v,b]}),t[19]=b,t[20]=h,t[21]=v,t[22]=x):x=t[22],x}function Wt(e){let t=(0,Q.c)(46),{c:n,runHistoryLoading:r,runHistory:i,filteredRunHistory:a,jobs:o,onRefreshHistory:s,onOpenJobDetail:c,statusLabels:l}=e,u;t[0]===n.tabRunHistory?u=t[1]:(u=(0,$.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),t[0]=n.tabRunHistory,t[1]=u);let d;t[2]===n.runHistoryHint?d=t[3]:(d=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint}),t[2]=n.runHistoryHint,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=n.refresh,m=n.refresh,h;t[7]===s?h=t[8]:(h=()=>void s(),t[7]=s,t[8]=h);let g=r&&`animate-spin`,_;t[9]===g?_=t[10]:(_=Y(`size-4`,g),t[9]=g,t[10]=_);let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(q,{className:_,strokeWidth:1.75}),t[11]=_,t[12]=v);let y;t[13]!==n.refresh||t[14]!==r||t[15]!==h||t[16]!==v?(y=(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:p,"aria-label":m,onClick:h,children:v}),t[13]=n.refresh,t[14]=r,t[15]=h,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==y||t[19]!==f?(b=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[f,y]}),t[18]=y,t[19]=f,t[20]=b):b=t[20];let x;t[21]!==n.colChat||t[22]!==n.colDetail||t[23]!==n.colDuration||t[24]!==n.colJob||t[25]!==n.colStarted||t[26]!==n.colWorkflow||t[27]!==n.emptyHistoryHint||t[28]!==n.emptyHistoryTitle||t[29]!==n.noRunsYet||t[30]!==n.openChat||t[31]!==n.openChatTitle||t[32]!==n.openWorkflow||t[33]!==n.openWorkflowTitle||t[34]!==n.runHistoryHint||t[35]!==n.status||t[36]!==a||t[37]!==o||t[38]!==c||t[39]!==i||t[40]!==r||t[41]!==l?(x=r&&i.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(te,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):a.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center rounded-2xl border border-dashed border-edge-subtle px-6 py-16 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(pe,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:i.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:i.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colWorkflow}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,$.jsx)(`tbody`,{children:a.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,$.jsx)(`time`,{dateTime:e.startedAt,children:Se(e.startedAt)})}),(0,$.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:o.some(t=>t.id===e.jobId)?(0,$.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=o.find(t=>t.id===e.jobId);t&&c(t)},children:e.jobName||e.jobId}):(0,$.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,$.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,$.jsx)(`span`,{className:Y(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`,e.status===`running`&&`bg-accent/15 text-accent`,e.status===`cancelled`&&`bg-surface-hover text-fg-muted`),children:Ue(e.status,l)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:He(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:be(e.summary||e.error,96)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.workflowRunId?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openWorkflowTitle,"aria-label":n.openWorkflowTitle,onClick:()=>_t(e.workflowRunId),children:n.openWorkflow}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>gt(e.sessionKey),children:n.openChat}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})}),t[21]=n.colChat,t[22]=n.colDetail,t[23]=n.colDuration,t[24]=n.colJob,t[25]=n.colStarted,t[26]=n.colWorkflow,t[27]=n.emptyHistoryHint,t[28]=n.emptyHistoryTitle,t[29]=n.noRunsYet,t[30]=n.openChat,t[31]=n.openChatTitle,t[32]=n.openWorkflow,t[33]=n.openWorkflowTitle,t[34]=n.runHistoryHint,t[35]=n.status,t[36]=a,t[37]=o,t[38]=c,t[39]=i,t[40]=r,t[41]=l,t[42]=x):x=t[42];let S;return t[43]!==b||t[44]!==x?(S=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[b,x]}),t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function Gt(e){let t=(0,Q.c)(77),{job:n,c:r,localeTag:i,scheduleBadgeLabels:a,absorbCardClickJobIdRef:o,scheduleAbsorbNextMenuCardClick:s,onOpenDetail:c,onToggle:l,onEdit:u,onRunNow:d,onDelete:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=Y(`flex h-full min-h-0 cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-base text-left transition-colors duration-150 ease-out dark:border-edge-subtle`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[0]=p):p=t[0];let m,h;t[1]!==o||t[2]!==n||t[3]!==c?(m=()=>{if(o.current===n.id){o.current=null;return}c(n)},h=e=>{if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),o.current===n.id){o.current=null;return}c(n)}},t[1]=o,t[2]=n,t[3]=c,t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=n.enabled,_=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,v;t[6]===_?v=t[7]:(v=Y(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,_),t[6]=_,t[7]=v);let y;t[8]!==n||t[9]!==l?(y=e=>{e.stopPropagation(),l(n,!n.enabled)},t[8]=n,t[9]=l,t[10]=y):y=t[10];let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[11]=b):b=t[11];let x;t[12]!==n.enabled||t[13]!==v||t[14]!==y?(x=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":g,className:v,onClick:y,children:b}),t[12]=n.enabled,t[13]=v,t[14]=y,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(X,{className:`size-4`,strokeWidth:1.75}),t[16]=S):S=t[16];let C;t[17]===r.jobCardMenuAria?C=t[18]:(C=(0,$.jsx)(Ze,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:qt,children:S})}),t[17]=r.jobCardMenuAria,t[18]=C);let w;t[19]!==n||t[20]!==u||t[21]!==s?(w=()=>{s(n.id),u(n)},t[19]=n,t[20]=u,t[21]=s,t[22]=w):w=t[22];let T;t[23]!==r.edit||t[24]!==w?(T=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:w,children:r.edit}),t[23]=r.edit,t[24]=w,t[25]=T):T=t[25];let E;t[26]!==n||t[27]!==d||t[28]!==s?(E=()=>{s(n.id),d(n)},t[26]=n,t[27]=d,t[28]=s,t[29]=E):E=t[29];let D;t[30]!==r.runNow||t[31]!==E?(D=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:E,children:r.runNow}),t[30]=r.runNow,t[31]=E,t[32]=D):D=t[32];let O;t[33]!==n||t[34]!==f||t[35]!==s?(O=()=>{s(n.id),f(n)},t[33]=n,t[34]=f,t[35]=s,t[36]=O):O=t[36];let k;t[37]!==r.delete||t[38]!==O?(k=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-red-600 outline-none data-highlighted:bg-red-500/10 dark:text-red-400`,onSelect:O,children:r.delete}),t[37]=r.delete,t[38]=O,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==D||t[42]!==k?(A=(0,$.jsx)(Qe,{children:(0,$.jsxs)($e,{className:`z-50 min-w-[10rem] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,sideOffset:4,align:`end`,onCloseAutoFocus:Kt,children:[T,D,k]})}),t[40]=T,t[41]=D,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==C||t[45]!==A?(j=(0,$.jsxs)(Ye,{children:[C,A]}),t[44]=C,t[45]=A,t[46]=j):j=t[46];let M;t[47]!==j||t[48]!==x?(M=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[x,j]}),t[47]=j,t[48]=x,t[49]=M):M=t[49];let N=n.name||n.id,P;t[50]===N?P=t[51]:(P=(0,$.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:N}),t[50]=N,t[51]=P);let F;t[52]===n?F=t[53]:(F=Pe(n),t[52]=n,t[53]=F);let I;t[54]===n?I=t[55]:(I=Pe(n),t[54]=n,t[55]=I);let L;t[56]===I?L=t[57]:(L=(0,$.jsx)(ge,{content:I,compact:!0}),t[56]=I,t[57]=L);let R;t[58]!==F||t[59]!==L?(R=(0,$.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:F,children:L}),t[58]=F,t[59]=L,t[60]=R):R=t[60];let z;t[61]!==P||t[62]!==R?(z=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[P,R]}),t[61]=P,t[62]=R,t[63]=z):z=t[63];let B;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(pe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=B):B=t[64];let V;t[65]!==n||t[66]!==i||t[67]!==a?(V=Ve(n,i,a),t[65]=n,t[66]=i,t[67]=a,t[68]=V):V=t[68];let H;t[69]===V?H=t[70]:(H=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-edge-subtle/90 px-4 py-2.5 text-xs text-fg-muted dark:border-edge-subtle`,children:[B,(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:V})]}),t[69]=V,t[70]=H);let U;return t[71]!==m||t[72]!==M||t[73]!==z||t[74]!==h||t[75]!==H?(U=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,className:p,onClick:m,onKeyDown:h,children:[M,z,H]}),t[71]=m,t[72]=M,t[73]=z,t[74]=h,t[75]=H,t[76]=U):U=t[76],U}function Kt(e){return e.preventDefault()}function qt(e){return e.stopPropagation()}function Jt(e){let t=(0,Q.c)(134),{c:n,language:r,localeTag:i,scheduleBadgeLabels:o,loading:s,sortedSystemJobs:c,heartbeat:l,keepAwake:u,wakeSupported:d,onWakeUnsupportedClick:f,onKeepAwakeToggle:p,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:b}=e,x,S,C,w,T,E,D,k,A,j,M,N;if(t[0]!==n.disabled||t[1]!==n.enabled||t[2]!==n.keepAwake||t[3]!==n.systemHeartbeatEvery||t[4]!==n.systemHeartbeatHint||t[5]!==n.systemHeartbeatInterval||t[6]!==n.systemHeartbeatSettingsLink||t[7]!==n.systemHeartbeatStatus||t[8]!==n.systemHeartbeatTitle||t[9]!==n.systemTasksIntro||t[10]!==n.tabSystemTasks||t[11]!==n.wakeBanner||t[12]!==n.wakeLockUnavailable||t[13]!==l.enabled||t[14]!==l.intervalMs||t[15]!==u||t[16]!==r||t[17]!==i||t[18]!==p||t[19]!==f||t[20]!==d){let e=Ie(l.intervalMs,i,a(r).heartbeatSettings.intervalPresets);M=`cron-system-tasks-panel`,N=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?S=t[34]:(S=(0,$.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=S),t[35]===n.systemTasksIntro?C=t[36]:(C=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=C);let o;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[37]=o):o=t[37];let s;t[38]===n.wakeBanner?s=t[39]:(s=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[o,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[38]=n.wakeBanner,t[39]=s);let c;t[40]===n.keepAwake?c=t[41]:(c=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[40]=n.keepAwake,t[41]=c);let m=!d,h=d?void 0:n.wakeLockUnavailable,g=u?`justify-end bg-accent`:`justify-start bg-surface-hover`,_=!d&&`cursor-not-allowed opacity-50`,v;t[42]!==g||t[43]!==_?(v=Y(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,g,_),t[42]=g,t[43]=_,t[44]=v):v=t[44];let y;t[45]!==p||t[46]!==f||t[47]!==d?(y=()=>{d?p():f()},t[45]=p,t[46]=f,t[47]=d,t[48]=y):y=t[48];let b;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[49]=b):b=t[49];let P;t[50]!==u||t[51]!==m||t[52]!==h||t[53]!==v||t[54]!==y?(P=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":u,disabled:m,title:h,className:v,onClick:y,children:b}),t[50]=u,t[51]=m,t[52]=h,t[53]=v,t[54]=y,t[55]=P):P=t[55];let F;t[56]!==c||t[57]!==P?(F=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[c,P]}),t[56]=c,t[57]=P,t[58]=F):F=t[58],t[59]!==s||t[60]!==F?(w=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[s,F]}),t[59]=s,t[60]=F,t[61]=w):w=t[61],A=`rounded-xl border border-edge bg-surface-base p-4 dark:bg-surface-hover/20`;let I;t[62]===n.systemHeartbeatTitle?I=t[63]:(I=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemHeartbeatTitle}),t[62]=n.systemHeartbeatTitle,t[63]=I);let L;t[64]===n.systemHeartbeatHint?L=t[65]:(L=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.systemHeartbeatHint}),t[64]=n.systemHeartbeatHint,t[65]=L);let z;t[66]!==I||t[67]!==L?(z=(0,$.jsxs)(`div`,{children:[I,L]}),t[66]=I,t[67]=L,t[68]=z):z=t[68];let B;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(O,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=B):B=t[69];let V;t[70]===n.systemHeartbeatSettingsLink?V=t[71]:(V=(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(R,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,B]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=V),t[72]!==z||t[73]!==V?(j=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[z,V]}),t[72]=z,t[73]=V,t[74]=j):j=t[74],D=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let H;t[75]===n.systemHeartbeatStatus?H=t[76]:(H=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=H);let U=l.enabled?n.enabled:n.disabled,G;t[77]===U?G=t[78]:(G=(0,$.jsx)(`dd`,{className:`text-fg`,children:U}),t[77]=U,t[78]=G),t[79]!==H||t[80]!==G?(k=(0,$.jsxs)(`div`,{children:[H,G]}),t[79]=H,t[80]=G,t[81]=k):k=t[81],t[82]===n.systemHeartbeatInterval?E=t[83]:(E=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatInterval}),t[82]=n.systemHeartbeatInterval,t[83]=E),x=`text-fg`;let K;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(K=/\{\{value\}\}/g,t[84]=K):K=t[84],T=n.systemHeartbeatEvery.replace(K,e),t[0]=n.disabled,t[1]=n.enabled,t[2]=n.keepAwake,t[3]=n.systemHeartbeatEvery,t[4]=n.systemHeartbeatHint,t[5]=n.systemHeartbeatInterval,t[6]=n.systemHeartbeatSettingsLink,t[7]=n.systemHeartbeatStatus,t[8]=n.systemHeartbeatTitle,t[9]=n.systemTasksIntro,t[10]=n.tabSystemTasks,t[11]=n.wakeBanner,t[12]=n.wakeLockUnavailable,t[13]=l.enabled,t[14]=l.intervalMs,t[15]=u,t[16]=r,t[17]=i,t[18]=p,t[19]=f,t[20]=d,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=N}else x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],k=t[28],A=t[29],j=t[30],M=t[31],N=t[32];let P;t[85]!==x||t[86]!==T?(P=(0,$.jsx)(`dd`,{className:x,children:T}),t[85]=x,t[86]=T,t[87]=P):P=t[87];let F;t[88]!==P||t[89]!==E?(F=(0,$.jsxs)(`div`,{children:[E,P]}),t[88]=P,t[89]=E,t[90]=F):F=t[90];let I;t[91]!==F||t[92]!==D||t[93]!==k?(I=(0,$.jsxs)(`dl`,{className:D,children:[k,F]}),t[91]=F,t[92]=D,t[93]=k,t[94]=I):I=t[94];let L;t[95]!==I||t[96]!==A||t[97]!==j?(L=(0,$.jsxs)(`div`,{className:A,children:[j,I]}),t[95]=I,t[96]=A,t[97]=j,t[98]=L):L=t[98];let z;t[99]===n.systemDreamingTitle?z=t[100]:(z=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=z);let B;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(O,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=B):B=t[101];let V;t[102]===n.systemDreamingSettingsLink?V=t[103]:(V=(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(R,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,B]})}),t[102]=n.systemDreamingSettingsLink,t[103]=V);let H;t[104]!==z||t[105]!==V?(H=(0,$.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[z,V]}),t[104]=z,t[105]=V,t[106]=H):H=t[106];let U;t[107]===n.systemDreamingHint?U=t[108]:(U=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=U);let G;t[109]!==m||t[110]!==n||t[111]!==s||t[112]!==i||t[113]!==b||t[114]!==v||t[115]!==g||t[116]!==y||t[117]!==_||t[118]!==h||t[119]!==o||t[120]!==c?(G=s&&c.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,$.jsx)(te,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):c.length===0?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/30 px-3 py-4 text-sm text-fg-muted dark:border-edge-subtle`,children:n.systemDreamingEmpty}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:c.map(e=>(0,$.jsx)(Gt,{job:e,c:n,localeTag:i,scheduleBadgeLabels:o,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:b},e.id))}),t[109]=m,t[110]=n,t[111]=s,t[112]=i,t[113]=b,t[114]=v,t[115]=g,t[116]=y,t[117]=_,t[118]=h,t[119]=o,t[120]=c,t[121]=G):G=t[121];let K;t[122]!==H||t[123]!==U||t[124]!==G?(K=(0,$.jsxs)(`div`,{children:[H,U,G]}),t[122]=H,t[123]=U,t[124]=G,t[125]=K):K=t[125];let q;return t[126]!==S||t[127]!==C||t[128]!==w||t[129]!==L||t[130]!==K||t[131]!==M||t[132]!==N?(q=(0,$.jsxs)(`section`,{"aria-labelledby":M,className:N,children:[S,C,w,L,K]}),t[126]=S,t[127]=C,t[128]=w,t[129]=L,t[130]=K,t[131]=M,t[132]=N,t[133]=q):q=t[133],q}function Yt(e,t){let n=e.templates;if(!n||typeof n!=`object`)return;let r=n[t];if(!r||typeof r!=`object`)return;let i=r.title?.trim(),a=r.prompt?.trim();if(!(!i||!a))return{title:i,description:(r.description??``).trim(),prompt:a}}var Xt=[`daily`,`monitoring`,`reports`,`automation`],Zt=[{templateId:`morning_briefing`,category:`daily`,defaultSchedule:`0 7 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`standup_prep`,category:`daily`,defaultSchedule:`0 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`meeting_prep`,category:`daily`,defaultSchedule:`0 9 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`meeting_prep`},{templateId:`end_of_day_wrap_up`,category:`daily`,defaultSchedule:`0 18 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`inbox_triage`,category:`daily`,defaultSchedule:`30 8 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`inbox_triage`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`competitor_scan`},{templateId:`trending_topics_monitor`,category:`monitoring`,defaultSchedule:`0 10 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`tech_radar_stack`,category:`monitoring`,defaultSchedule:`0 11 * * 3`,defaultSessionTarget:`isolated`},{templateId:`dependency_check_audit`,category:`monitoring`,defaultSchedule:`0 9 * * 0`,defaultSessionTarget:`isolated`},{templateId:`weekly_review`,category:`reports`,defaultSchedule:`0 17 * * 5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`weekly_review`},{templateId:`code_quality_report`,category:`reports`,defaultSchedule:`0 14 * * 1`,defaultSessionTarget:`isolated`},{templateId:`git_activity_summary`,category:`reports`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`user_feedback_digest`,category:`reports`,defaultSchedule:`0 16 * * 5`,defaultSessionTarget:`isolated`},{templateId:`content_repurpose`,category:`reports`,defaultSchedule:`0 11 * * 4`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`content_repurpose`},{templateId:`stale_todo_or_issue_sweep`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`},{templateId:`release_notes_or_changelog_draft`,category:`automation`,defaultSchedule:`0 10 * * 4`,defaultSessionTarget:`isolated`},{templateId:`client_proposal`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`client_proposal`},{templateId:`offer_design`,category:`automation`,defaultSchedule:`0 14 1 * *`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`offer_design`},{templateId:`decision_compare`,category:`automation`,defaultSchedule:`0 15 * * 3`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`decision_compare`},{templateId:`workspace_cleanup_suggestions`,category:`automation`,defaultSchedule:`30 18 * * 5`,defaultSessionTarget:`isolated`},{templateId:`smoke_or_ci_health_reminder`,category:`automation`,defaultSchedule:`0 8 * * 1`,defaultSessionTarget:`isolated`}];function Qt(e){return Zt.find(t=>t.templateId===e)}function $t(e,t,n){let r=t.trim().toLowerCase();return Zt.filter(t=>{if(n!==`all`&&t.category!==n)return!1;if(!r)return!0;let i=Yt(e,t.templateId);return[t.templateId,i?.title,i?.description,e.templateCategories[t.category]].filter(Boolean).join(` `).toLowerCase().includes(r)})}function en(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return Xt.flatMap(e=>{let n=t.get(e);return n?.length?[{category:e,items:n}]:[]})}function tn(e){let t=(0,Q.c)(23),{template:n,cron:r,localeTag:i,scheduleBadgeLabels:a,onSelectTemplate:o}=e,s;t[0]!==r||t[1]!==n.templateId?(s=Yt(r,n.templateId),t[0]=r,t[1]=n.templateId,t[2]=s):s=t[2];let c=s;if(!c)return null;let l;t[3]!==i||t[4]!==a||t[5]!==n.defaultSchedule?(l=Ve({schedule:n.defaultSchedule,timezone:void 0,next_run:void 0},i,a),t[3]=i,t[4]=a,t[5]=n.defaultSchedule,t[6]=l):l=t[6];let u=l,d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(`flex h-full flex-col gap-1.5 rounded-xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:border-accent/40 hover:bg-surface-hover`,ee.focusRingPanel),t[7]=d):d=t[7];let f;t[8]!==o||t[9]!==n.templateId?(f=()=>o(n.templateId),t[8]=o,t[9]=n.templateId,t[10]=f):f=t[10];let p=`${r.templateCategories[n.category]} — ${c.title}`,m;t[11]===c.title?m=t[12]:(m=(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:c.title}),t[11]=c.title,t[12]=m);let h;t[13]===c.description?h=t[14]:(h=(0,$.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:c.description}),t[13]=c.description,t[14]=h);let g;t[15]===u?g=t[16]:(g=(0,$.jsx)(`span`,{className:`mt-auto flex items-center gap-1 pt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`span`,{className:`tabular-nums`,children:u})}),t[15]=u,t[16]=g);let _;return t[17]!==f||t[18]!==p||t[19]!==m||t[20]!==h||t[21]!==g?(_=(0,$.jsxs)(`button`,{type:`button`,className:d,onClick:f,"aria-label":p,children:[m,h,g]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function nn(e){let t=(0,Q.c)(49),{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:a,onCategoryFilterChange:o,onSelectTemplate:s,variant:c}=e,l=c===void 0?`embedded`:c,[u,d]=(0,Z.useState)(``),f;t[0]!==a||t[1]!==n||t[2]!==u?(f=$t(n,u,a),t[0]=a,t[1]=n,t[2]=u,t[3]=f):f=t[3];let p=f,m;t[4]===p?m=t[5]:(m=en(p),t[4]=p,t[5]=m);let h=m,g;t[6]!==a||t[7]!==u?(g=a===`all`&&!u.trim(),t[6]=a,t[7]=u,t[8]=g):g=t[8];let _=g,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(L,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>d(e.target.value),t[10]=y):y=t[10];let b=n.templateSearchPlaceholder,x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=Y(`h-10 w-full rounded-xl border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,ee.focusRingPanel),t[11]=x):x=t[11];let S;t[12]!==n.templateSearchPlaceholder||t[13]!==u?(S=(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{value:u,onChange:y,placeholder:b,className:x})]}),t[12]=n.templateSearchPlaceholder,t[13]=u,t[14]=S):S=t[14];let C=n.fromTemplate,w=a===`all`?`secondary`:`ghost`,T;t[15]===o?T=t[16]:(T=()=>o(`all`),t[15]=o,t[16]=T);let E;t[17]!==n.templateFilterAll||t[18]!==w||t[19]!==T?(E=(0,$.jsx)(W,{type:`button`,variant:w,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:T,children:n.templateFilterAll}),t[17]=n.templateFilterAll,t[18]=w,t[19]=T,t[20]=E):E=t[20];let D;t[21]!==a||t[22]!==n.templateCategories||t[23]!==o?(D=Xt.map(e=>(0,$.jsx)(W,{type:`button`,variant:a===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>o(e),children:n.templateCategories[e]},e)),t[21]=a,t[22]=n.templateCategories,t[23]=o,t[24]=D):D=t[24];let O;t[25]!==n.fromTemplate||t[26]!==E||t[27]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":C,children:[E,D]}),t[25]=n.fromTemplate,t[26]=E,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==O||t[30]!==S?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[S,O]}),t[29]=O,t[30]=S,t[31]=k):k=t[31];let A=k,j;t[32]!==n||t[33]!==p||t[34]!==h||t[35]!==r||t[36]!==s||t[37]!==i||t[38]!==_||t[39]!==l?(j=p.length===0?(0,$.jsx)(`div`,{className:Y(`text-center text-sm text-fg-muted`,l===`dialog`&&`flex h-full flex-col items-center justify-center px-4 py-12`),children:n.templatesEmptyHint}):_?(0,$.jsx)(`div`,{className:`flex flex-col gap-6 pb-1`,children:h.map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n.templateCategories[e.category]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:e.items.map(e=>(0,$.jsx)(tn,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))})]},e.category))}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pb-1 sm:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,$.jsx)(tn,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))}),t[32]=n,t[33]=p,t[34]=h,t[35]=r,t[36]=s,t[37]=i,t[38]=_,t[39]=l,t[40]=j):j=t[40];let M=j;if(l===`dialog`){let e;t[41]===M?e=t[42]:(e=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:M}),t[41]=M,t[42]=e);let n;return t[43]!==A||t[44]!==e?(n=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[A,e]}),t[43]=A,t[44]=e,t[45]=n):n=t[45],n}let N;return t[46]!==A||t[47]!==M?(N=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[A,M]}),t[46]=A,t[47]=M,t[48]=N):N=t[48],N}function rn(e){let t=(0,Q.c)(49),{c:n,localeTag:r,scheduleBadgeLabels:i,loading:a,jobsCount:o,sortedJobs:s,templateCategoryFilter:c,onTemplateCategoryFilterChange:l,onSelectTemplate:u,keepAwake:d,wakeSupported:f,onWakeUnsupportedClick:p,onKeepAwakeToggle:m,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onAddJob:b,onRunNow:x,onDelete:S}=e,C;t[0]===n.tabMyTasks?C=t[1]:(C=(0,$.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),t[0]=n.tabMyTasks,t[1]=C);let w;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(oe,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=w):w=t[2];let T;t[3]===n.wakeBanner?T=t[4]:(T=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[w,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[3]=n.wakeBanner,t[4]=T);let E;t[5]===n.keepAwake?E=t[6]:(E=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[5]=n.keepAwake,t[6]=E);let D=!f,O=f?void 0:n.wakeLockUnavailable,k=d?`justify-end bg-accent`:`justify-start bg-surface-hover`,A=!f&&`cursor-not-allowed opacity-50`,j;t[7]!==k||t[8]!==A?(j=Y(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,k,A),t[7]=k,t[8]=A,t[9]=j):j=t[9];let M;t[10]!==m||t[11]!==p||t[12]!==f?(M=()=>{f?m():p()},t[10]=m,t[11]=p,t[12]=f,t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[14]=N):N=t[14];let P;t[15]!==d||t[16]!==M||t[17]!==D||t[18]!==O||t[19]!==j?(P=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":d,disabled:D,title:O,className:j,onClick:M,children:N}),t[15]=d,t[16]=M,t[17]=D,t[18]=O,t[19]=j,t[20]=P):P=t[20];let F;t[21]!==P||t[22]!==E?(F=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[E,P]}),t[21]=P,t[22]=E,t[23]=F):F=t[23];let I;t[24]!==F||t[25]!==T?(I=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[T,F]}),t[24]=F,t[25]=T,t[26]=I):I=t[26];let L;t[27]!==h||t[28]!==n||t[29]!==o||t[30]!==a||t[31]!==r||t[32]!==b||t[33]!==S||t[34]!==y||t[35]!==_||t[36]!==x||t[37]!==u||t[38]!==l||t[39]!==v||t[40]!==g||t[41]!==i||t[42]!==s||t[43]!==c?(L=a&&o===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,$.jsx)(te,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):o===0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 rounded-2xl bg-surface-base px-4 py-8 dark:bg-surface-hover/25 sm:px-6 sm:py-10`,children:[(0,$.jsx)(`div`,{className:`w-full max-w-6xl`,children:(0,$.jsx)(nn,{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(W,{type:`button`,variant:`primary`,onClick:b,children:n.emptyStateCta})})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:s.map(e=>(0,$.jsx)(Gt,{job:e,c:n,localeTag:r,scheduleBadgeLabels:i,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:e=>void _(e),onToggle:(e,t)=>void v(e,t),onEdit:y,onRunNow:x,onDelete:S},e.id))}),t[27]=h,t[28]=n,t[29]=o,t[30]=a,t[31]=r,t[32]=b,t[33]=S,t[34]=y,t[35]=_,t[36]=x,t[37]=u,t[38]=l,t[39]=v,t[40]=g,t[41]=i,t[42]=s,t[43]=c,t[44]=L):L=t[44];let R;return t[45]!==C||t[46]!==I||t[47]!==L?(R=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[C,I,L]}),t[45]=C,t[46]=I,t[47]=L,t[48]=R):R=t[48],R}function an(e){let t=(0,Q.c)(29),{open:n,onOpenChange:r,c:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=Y(`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,840px)] w-full max-w-5xl flex-col`,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,ee.focusRingPanel),t[1]=d):d=t[1];let f;t[2]===i.fromTemplate?f=t[3]:(f=(0,$.jsx)(ne,{className:`text-lg font-semibold text-fg`,children:i.fromTemplate}),t[2]=i.fromTemplate,t[3]=f);let p;t[4]===i.templatePickerHint?p=t[5]:(p=(0,$.jsx)(y,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.templatePickerHint}),t[4]=i.templatePickerHint,t[5]=p);let m;t[6]!==f||t[7]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[6]=f,t[7]=p,t[8]=m):m=t[8];let g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(K,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=g):g=t[9];let _;t[10]===i.close?_=t[11]:(_=(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:g})}),t[10]=i.close,t[11]=_);let v;t[12]!==m||t[13]!==_?(v=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge-subtle px-6 py-5`,children:[m,_]}),t[12]=m,t[13]=_,t[14]=v):v=t[14];let b;t[15]!==i||t[16]!==s||t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==o?(b=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-6 py-5`,children:(0,$.jsx)(nn,{variant:`dialog`,cron:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:l})}),t[15]=i,t[16]=s,t[17]=a,t[18]=c,t[19]=l,t[20]=o,t[21]=b):b=t[21];let x;t[22]!==v||t[23]!==b?(x=(0,$.jsxs)(re,{children:[u,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(C,{className:d,onOpenAutoFocus:on,children:[v,b]})})]}),t[22]=v,t[23]=b,t[24]=x):x=t[24];let S;return t[25]!==r||t[26]!==n||t[27]!==x?(S=(0,$.jsx)(h,{open:n,onOpenChange:r,children:x}),t[25]=r,t[26]=n,t[27]=x,t[28]=S):S=t[28],S}function on(e){return e.preventDefault()}function sn(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:dt,formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,formTaskKind:`message`,formWorkflowDefinitionId:``,formWorkflowGoal:``,formWorkflowArgValues:{},messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function cn(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`replace`:return t.state;case`setMessageMdMode`:return{...e,formMessageMdMode:t.mode,messageEditorNonce:t.mode===`edit`?e.messageEditorNonce+1:e.messageEditorNonce}}}function ln(e,t){let n=sn();if(n.formOpen=!0,n.formMode=e?`edit`:`add`,n.formJobId=e?.id??null,!e)return n.formModel=t(),n;n.formName=e.name||``,n.formSchedule=e.schedule&&String(e.schedule).trim()||`*/5 * * * *`;let r=Pe(e);if(n.formMessage=r??``,e.payload.kind===`workflowRun`){n.formTaskKind=`workflowRun`,n.formWorkflowDefinitionId=e.payload.definitionId,n.formWorkflowGoal=e.payload.goal||``,n.formWorkflowArgValues=Mt(e.payload.definitionId,e.payload.inputEnvelope?.payload??e.payload.input??{});let t=e.payload.agentId?.trim().toLowerCase();t&&(n.formAgentId=t)}n.formSessionTarget=e.sessionTarget||`main`,n.formAgentId=(e.sessionTarget||`main`)===`isolated`&&e.agentId?.trim()?e.agentId.trim().toLowerCase():``,n.formWorkingDirectory=(e.sessionTarget||`main`)===`isolated`&&e.workingDirectory?.trim()?e.workingDirectory.trim():``;let i=e.payload?.kind===`agentTurn`&&e.payload.model?.trim()?e.payload.model.trim():``;n.formModel=e.model?.trim()||i||t();let a=e.delivery?.channel===`local`,o=(e.sessionTarget||`main`)===`isolated`&&!a&&(!e.delivery?.to||e.delivery.mode===`none`);if(n.formAgentLocalOnly=o,a)n.formChannel=`local`,n.formChatId=``;else if(e.delivery&&e.delivery.mode!==`none`&&e.delivery.to)n.formChannel=e.delivery.channel||`telegram`,n.formChatId=e.delivery.to||``;else if(o)n.formChannel=`telegram`,n.formChatId=``;else{let e=r.split(`:`);e.length>=3&&[`telegram`,`cli`,`gateway`,`local`].includes(e[0])?(n.formChannel=e[0],n.formChatId=e[1],n.formMessage=e.slice(2).join(`:`)):(n.formChannel=`telegram`,n.formChatId=``)}return n.formMessageMdMode=`edit`,n.messageEditorNonce=1,n}function un(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,Z.useReducer)(cn,void 0,sn),s=(0,Z.useRef)(!1),c=(0,Z.useMemo)(()=>new Set([`local`,...r.map(e=>e.name)]),[r]);if(a.formOpen&&a.formMode===`add`&&!c.has(a.formChannel)&&o({type:`patch`,patch:{formChannel:`local`}}),a.formOpen&&a.formMode===`add`&&!s.current){let e=n();e&&e!==a.formModel&&o({type:`patch`,patch:{formModel:e}})}let l=fe(()=>Fe(a.formChannel),[a.formChannel],{enabled:a.formOpen&&a.formChannel!==`local`,initial:[],errorData:[]}),u=a.formChannel===`local`?[]:l.data,d=(0,Z.useMemo)(()=>{let e=new Set(i.map(e=>e.id)),t=[...i],n=a.formAgentId.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[i,a.formAgentId]),f=a.formChannel!==`local`&&(a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly)||a.formTaskKind===`workflowRun`&&!a.formAgentLocalOnly),p=a.formTaskKind===`workflowRun`?!a.formAgentLocalOnly:a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly),m=a.formTaskKind===`workflowRun`?!!a.formWorkflowDefinitionId.trim()&&Nt(a.formWorkflowDefinitionId.trim(),a.formWorkflowArgValues):!!a.formMessage.trim(),h=!!a.formName.trim()&&!!a.formSchedule.trim()&&m&&(!f||!!a.formChatId.trim()),g=(0,Z.useCallback)(e=>{s.current=!1,o({type:`replace`,state:ln(e,n)})},[n]),_=(0,Z.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),v=(0,Z.useCallback)(e=>{let r=Qt(e),i=r?Yt(t.cron,e):void 0;if(!r||!i)return!1;let a=r.taskKind===`workflowRun`&&!!r.workflowDefinitionId;return s.current=!1,o({type:`replace`,state:{...sn(),formOpen:!0,formMode:`add`,formName:i.title,formSchedule:r.defaultSchedule,formMessage:a?``:i.prompt,formTaskKind:a?`workflowRun`:`message`,formWorkflowDefinitionId:a?r.workflowDefinitionId:``,formWorkflowGoal:a?i.description:``,formSessionTarget:r.defaultSessionTarget,formModel:n(),formAgentLocalOnly:a,messageEditorNonce:1}}),!0},[n,t.cron]),y=(0,Z.useCallback)(()=>{s.current=!1,o({type:`replace`,state:sn()})},[]),b=(0,Z.useCallback)((e,t,n)=>{let r={formSessionTarget:e};e===`main`?(r.formAgentLocalOnly=!1,r.formAgentId=``,r.formWorkingDirectory=``):e===`isolated`&&!n&&(r.formModel=t()),o({type:`patch`,patch:r})},[]),x=(0,Z.useCallback)(e=>{o({type:`patch`,patch:{formChannel:e,formChatId:``,...e===`local`?{formAgentLocalOnly:!1}:{}}})},[]),S=(0,Z.useCallback)(e=>{s.current=!0,o({type:`patch`,patch:{formModel:e}})},[]),C=(0,Z.useCallback)(()=>{Fe(a.formChannel).then(l.setData)},[a.formChannel,l.setData]),w=(0,Z.useCallback)(e=>{o({type:`patch`,patch:e})},[]);return{formOpen:a.formOpen,formMode:a.formMode,formJobId:a.formJobId,formName:a.formName,formSchedule:a.formSchedule,formChannel:a.formChannel,formChatId:a.formChatId,formMessage:a.formMessage,formMessageMdMode:a.formMessageMdMode,formTaskKind:a.formTaskKind,formWorkflowDefinitionId:a.formWorkflowDefinitionId,formWorkflowGoal:a.formWorkflowGoal,formWorkflowArgValues:a.formWorkflowArgValues,messageEditorNonce:a.messageEditorNonce,formSessionTarget:a.formSessionTarget,formAgentId:a.formAgentId,formAgentLocalOnly:a.formAgentLocalOnly,formWorkingDirectory:a.formWorkingDirectory,formModel:a.formModel,formSubmitting:a.formSubmitting,sessionChatIds:u,setFormName:e=>w({formName:e}),setFormSchedule:e=>w({formSchedule:e}),setFormChatId:e=>w({formChatId:e}),setFormMessage:e=>w({formMessage:e}),setFormTaskKind:e=>w(e===`workflowRun`?{formTaskKind:e,formSessionTarget:`isolated`,formAgentLocalOnly:!1}:{formTaskKind:e}),setFormWorkflowDefinitionId:e=>w({formWorkflowDefinitionId:e,formWorkflowArgValues:{}}),setFormWorkflowGoal:e=>w({formWorkflowGoal:e}),setFormWorkflowArgValues:e=>w({formWorkflowArgValues:e}),setFormAgentId:e=>w({formAgentId:e}),setFormAgentLocalOnly:e=>w({formAgentLocalOnly:e}),setFormWorkingDirectory:e=>w({formWorkingDirectory:e}),setFormSubmitting:e=>w({formSubmitting:e}),canSubmit:h,needsDeliveryChat:f,showChannelPicker:p,cronAgentSelectOptions:d,openForm:g,closeForm:y,applyCronTemplate:v,setMessageMdMode:_,handleFormSessionTargetChange:b,handleFormChannelChange:x,handleFormModelUserChange:S,refreshRecipientsList:C}}function dn(e){let{onUnavailable:t}=e,[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(`none`),o=(0,Z.useRef)(n),s=typeof navigator<`u`&&`wakeLock`in navigator,c=s||P(),l=(0,Z.useCallback)(async()=>{if(a.current===`electron`){try{await window.electronAPI?.cron?.setDisplaySleepPrevented?.(!1)}catch{}a.current=`none`;return}try{await i.current?.release()}catch{}i.current=null,a.current=`none`},[]),u=(0,Z.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.cron?.setDisplaySleepPrevented:void 0;if(e)try{await e(!0),a.current=`electron`;return}catch{t(),r(!1);return}if(s)try{let e=await navigator.wakeLock.request(`screen`);i.current=e,a.current=`navigator`,e.addEventListener(`release`,()=>{i.current=null,a.current=`none`})}catch{t(),r(!1)}},[t,s]);return o.current=n,(0,Z.useEffect)(()=>{if(!n){l();return}u();let e=()=>{document.visibilityState===`visible`&&o.current&&u()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),l()}},[n,u,l]),{keepAwake:n,setKeepAwake:r,featureAvailable:c}}function fn(e){let{hasToken:t,failMessages:n,isHistoryTab:r}=e,[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=(0,Z.useCallback)(async()=>{S(!0),w(null);try{a(await Me())}catch(e){w(e instanceof Error?e.message:n.failedToLoadJobs)}finally{S(!1)}},[n.failedToLoadJobs]),E=(0,Z.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([Ee(),Oe(),je(),p(),ae().catch(()=>null)]);s(e),l(t),d(n.model||``),g(r.payload?.config??null),i&&m(i.items)}catch{}},[]),D=(0,Z.useCallback)(async()=>{b(!0);try{v(await Le(400))}catch{}finally{b(!1)}},[]);return(0,Z.useEffect)(()=>{t&&(T(),E())},[t,T,E]),(0,Z.useEffect)(()=>{if(!t)return;let e=()=>{p().then(e=>{g(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,Z.useEffect)(()=>{!t||!r||D()},[t,r,D]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:h,runHistory:_,runHistoryLoading:y,loading:x,error:C,setError:w,userCronJobs:(0,Z.useMemo)(()=>i.filter(e=>!Ne(e)),[i]),systemCronJobs:(0,Z.useMemo)(()=>i.filter(e=>Ne(e)),[i]),heartbeatFromConfig:(0,Z.useMemo)(()=>Ge(h),[h]),loadJobs:T,loadAux:E,loadRunHistoryOnly:D,refreshAll:(0,Z.useCallback)(()=>{T(),E(),D()},[T,E,D])}}function pn(e,t){let n=[...e];return n.sort((e,n)=>{let r=new Date(e.created_at).getTime(),i=new Date(n.created_at).getTime();return t===`created_desc`?i-r:r-i}),n}function mn(e,t,n,r){let i=new Date,a=t===`day`?pt(i):t===`week`?mt(i):ht(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var hn={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function gn(){let e=i(e=>e.language),t=a(e),n=t.cron,r=t.chat,o=u(e=>e.token),c=!!o,d=l(e=>e.resolved)===`dark`,f=e===`zh`?`zh-CN`:`en-US`,[p,m]=ie(),[h,g]=(0,Z.useReducer)(M,p,e=>({...hn,mainTab:St(e.get(`tab`))})),{mainTab:_,jobSort:v,historyRange:y,historyJobFilter:x,historyStatusFilter:S,detailOpen:C,detailJob:w,detailHistory:T,detailLoading:E,confirmOpen:D,templatePickerOpen:O,templateCategoryFilter:k}=h,A=St(p.get(`tab`));(0,Z.useEffect)(()=>{A!==_&&g({type:`patch`,patch:{mainTab:A}})},[A,_]);let j=(0,Z.useCallback)(e=>{g({type:`patch`,patch:{mainTab:e}}),m(t=>{let n=new URLSearchParams(t),r=Ct(e);return r?n.set(`tab`,r):n.delete(`tab`),n},{replace:!0})},[m]),N=fn({hasToken:c,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:_===`history`}),{setError:P}=N,F=dn({onUnavailable:()=>P(n.wakeLockUnavailable)}),I=(0,Z.useCallback)(()=>N.defaultModel||(N.availableModels.length>0?N.availableModels[0].id:``),[N.defaultModel,N.availableModels]),L=un({m:t,defaultModelForForm:I,channels:N.channels,chatAgents:N.chatAgents}),R=s(c&&L.formOpen?[`workflow-definitions-cron`,o]:null,b,{revalidateOnFocus:!1}),z=R.data??[],B=(0,Z.useRef)(null),V=(0,Z.useRef)(null),H=(0,Z.useCallback)((e,t)=>{B.current=e,V.current=t,g({type:`patch`,patch:{confirmOpen:!0}})},[]),U=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{confirmOpen:!1}}),V.current=null,B.current=null},[]),W=(0,Z.useRef)(null),G=(0,Z.useCallback)(e=>{W.current=e,window.setTimeout(()=>{W.current===e&&(W.current=null)},400)},[]),K=(0,Z.useCallback)(e=>{L.applyCronTemplate(e)&&g({type:`patch`,patch:{templatePickerOpen:!1}})},[L]),q=async()=>{if(!L.formName.trim()){P(n.nameRequired);return}if(!L.formSchedule.trim()){P(n.scheduleRequired);return}if(L.formTaskKind===`message`&&!L.formMessage.trim()){P(n.scheduleRequired);return}if(L.formTaskKind===`workflowRun`&&!L.formWorkflowDefinitionId.trim()){P(n.workflowDefinitionRequired);return}if(L.formTaskKind===`workflowRun`&&!Nt(L.formWorkflowDefinitionId.trim(),L.formWorkflowArgValues)){P(n.workflowArgsRequired);return}if(L.needsDeliveryChat&&!L.formChatId.trim()){P(n.chatIdRequired);return}L.setFormSubmitting(!0),P(null);try{let e=L.formMessage.trim(),t=L.formModel.trim(),n=L.formAgentId.trim().toLowerCase(),r=L.formWorkingDirectory.trim(),i=L.formTaskKind===`workflowRun`,a=L.formTaskKind===`message`&&L.formSessionTarget===`isolated`,o=i?`isolated`:L.formSessionTarget,s;s=i?L.formAgentLocalOnly?{mode:`none`}:L.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:L.formChannel,to:L.formChatId.trim()}:L.formSessionTarget===`isolated`&&L.formAgentLocalOnly?{mode:`none`}:L.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:L.formChannel,to:L.formChatId.trim()};let c;if(i){let e=L.formWorkflowDefinitionId.trim(),t=Je(L.formWorkflowArgValues);c={kind:`workflowRun`,definitionId:e,...t===void 0?{}:{inputEnvelope:{payload:t}},...L.formWorkflowGoal.trim()?{goal:L.formWorkflowGoal.trim()}:{},...n?{agentId:n}:{}}}else c=a?{kind:`agentTurn`,message:e,...t?{model:t}:{}}:{kind:`systemEvent`,text:e};let l=o===`main`?null:n||null,u={name:L.formName.trim(),schedule:L.formSchedule.trim(),sessionTarget:o,model:a&&t?t:void 0,...i?{timeout:ft}:{},delivery:s,payload:c,...L.formMode===`edit`?{agentId:l,workingDirectory:a&&r||null}:{...o===`isolated`&&n?{agentId:n}:{},...a&&r?{workingDirectory:r}:{}}};if(L.formMode===`edit`&&L.formJobId)await Be(L.formJobId,u);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=u;await we(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}L.closeForm(),await N.loadJobs()}catch(e){P(e instanceof Error?e.message:L.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{L.setFormSubmitting(!1)}},ee=async e=>{g({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[]}});try{let t=await De(e.id);t&&g({type:`patch`,patch:{detailJob:t,detailHistory:await ze(e.id,20)}})}catch{}finally{g({type:`patch`,patch:{detailLoading:!1}})}},te=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})},[]),ne=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),re=async(e,t)=>{try{await Ce(e.id,t),w?.id===e.id&&g({type:`patch`,patch:{detailJob:{...w,enabled:t}}}),await Promise.all([N.loadJobs(),N.loadAux()])}catch(e){P(e instanceof Error?e.message:n.failedToToggleJob)}},J=async()=>{let e=V.current,t=B.current;if(!(!e||!t)){U();try{t===`run`?await ke(e):(await Ae(e),w?.id===e&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})),await Promise.all([N.loadJobs(),N.loadAux(),N.loadRunHistoryOnly()])}catch(e){P(e instanceof Error?e.message:n.actionFailed)}}};(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(L.formOpen?L.closeForm():C&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[L,C]);let Y=(0,Z.useMemo)(()=>({running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled}),[n.execStatusCancelled,n.execStatusFailed,n.execStatusRunning,n.execStatusSuccess]),X=(0,Z.useMemo)(()=>pn(N.userCronJobs,v),[N.userCronJobs,v]),ae=(0,Z.useMemo)(()=>pn(N.systemCronJobs,v),[N.systemCronJobs,v]),oe=(0,Z.useMemo)(()=>mn(N.runHistory,y,x,S),[N.runHistory,y,x,S]),se=n.scheduleBadge;return c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{hasToken:c,c:n,loading:N.loading,runHistoryLoading:N.runHistoryLoading,onRefresh:N.refreshAll,onOpenTemplatePicker:ne,onAddJob:()=>L.openForm()}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[N.error?(0,$.jsx)(`div`,{className:`rounded-xl 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`,role:`alert`,children:N.error}):null,(0,$.jsx)(Vt,{c:n,mainTab:_,onMainTabChange:j,jobSort:v,onJobSortChange:e=>g({type:`patch`,patch:{jobSort:e}}),historyRange:y,onHistoryRangeChange:e=>g({type:`patch`,patch:{historyRange:e}}),historyJobFilter:x,onHistoryJobFilterChange:e=>g({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:S,onHistoryStatusFilterChange:e=>g({type:`patch`,patch:{historyStatusFilter:e}}),jobs:N.jobs}),_===`myTasks`?(0,$.jsx)(rn,{c:n,localeTag:f,scheduleBadgeLabels:se,loading:N.loading,jobsCount:N.userCronJobs.length,sortedJobs:X,templateCategoryFilter:k,onTemplateCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K,keepAwake:F.keepAwake,wakeSupported:F.featureAvailable,onWakeUnsupportedClick:()=>P(n.wakeLockUnavailable),onKeepAwakeToggle:()=>F.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void ee(e),onToggle:(e,t)=>void re(e,t),onEdit:e=>L.openForm(e),onAddJob:()=>L.openForm(),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):_===`systemTasks`?(0,$.jsx)(Jt,{c:n,language:e,localeTag:f,scheduleBadgeLabels:se,loading:N.loading,sortedSystemJobs:ae,heartbeat:N.heartbeatFromConfig,keepAwake:F.keepAwake,wakeSupported:F.featureAvailable,onWakeUnsupportedClick:()=>P(n.wakeLockUnavailable),onKeepAwakeToggle:()=>F.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void ee(e),onToggle:(e,t)=>void re(e,t),onEdit:e=>L.openForm(e),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):_===`history`?(0,$.jsx)(Wt,{c:n,runHistoryLoading:N.runHistoryLoading,runHistory:N.runHistory,filteredRunHistory:oe,jobs:N.jobs,onRefreshHistory:()=>void N.loadRunHistoryOnly(),onOpenJobDetail:e=>void ee(e),statusLabels:Y}):(0,$.jsx)(ct,{hasToken:c})]}),(0,$.jsx)(It,{open:L.formOpen,onRequestClose:L.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:d,channels:N.channels,sessionChatIds:L.sessionChatIds,cronAgentSelectOptions:L.cronAgentSelectOptions,defaultModelResolver:I,formMode:L.formMode,formJobId:L.formJobId,formName:L.formName,onFormNameChange:L.setFormName,formSchedule:L.formSchedule,onFormScheduleChange:L.setFormSchedule,formSubmitting:L.formSubmitting,formTaskKind:L.formTaskKind,onFormTaskKindChange:L.setFormTaskKind,workflowDefinitions:z,workflowDefinitionsLoading:R.isLoading,formWorkflowDefinitionId:L.formWorkflowDefinitionId,onFormWorkflowDefinitionIdChange:L.setFormWorkflowDefinitionId,formWorkflowGoal:L.formWorkflowGoal,onFormWorkflowGoalChange:L.setFormWorkflowGoal,formWorkflowArgValues:L.formWorkflowArgValues,onFormWorkflowArgValuesChange:L.setFormWorkflowArgValues,formSessionTarget:L.formSessionTarget,onFormSessionTargetChange:L.handleFormSessionTargetChange,formAgentLocalOnly:L.formAgentLocalOnly,onFormAgentLocalOnlyChange:L.setFormAgentLocalOnly,formModel:L.formModel,onFormModelUserChange:L.handleFormModelUserChange,formAgentId:L.formAgentId,onFormAgentIdChange:L.setFormAgentId,formWorkingDirectory:L.formWorkingDirectory,onFormWorkingDirectoryChange:L.setFormWorkingDirectory,formChannel:L.formChannel,onFormChannelChange:L.handleFormChannelChange,formChatId:L.formChatId,onFormChatIdChange:L.setFormChatId,formMessage:L.formMessage,onFormMessageChange:L.setFormMessage,formMessageMdMode:L.formMessageMdMode,onSetMessageMdMode:L.setMessageMdMode,messageEditorNonce:L.messageEditorNonce,needsDeliveryChat:L.needsDeliveryChat,showChannelPicker:L.showChannelPicker,canSubmit:L.canSubmit,onSubmit:()=>void q(),onRefreshRecipients:L.refreshRecipientsList}),(0,$.jsx)(an,{open:O,onOpenChange:e=>{g({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:f,scheduleBadgeLabels:se,categoryFilter:k,onCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K}),(0,$.jsx)(kt,{open:C,onDismiss:te,detailJob:w,detailLoading:E,detailHistory:T,c:n,localeTag:f,scheduleBadgeLabels:se,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:Y,onEdit:e=>{te(),L.openForm(e)},onRunNow:e=>H(`run`,e.id),onToggle:(e,t)=>void re(e,t),onDelete:e=>H(`delete`,e.id)}),(0,$.jsx)(et,{open:D,onOpenChange:e=>g({type:`patch`,patch:{confirmOpen:e}}),action:B.current,c:n,onDismiss:U,onConfirm:J})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{hasToken:c,c:n,loading:N.loading,runHistoryLoading:N.runHistoryLoading,onRefresh:N.refreshAll,onOpenTemplatePicker:ne,onAddJob:()=>L.openForm()}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-16 text-center text-sm text-fg-muted sm:px-8`,children:n.needToken})]})}function _n(e){let t=(0,Q.c)(14),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,l=I(yn),u=I(vn),d;t[0]!==r||t[1]!==i||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==a?(d=(0,$.jsx)(Ut,{c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}),t[0]=r,t[1]=i,t[2]=c,t[3]=s,t[4]=o,t[5]=a,t[6]=d):d=t[6];let f=d,p,m;return t[7]!==r.title||t[8]!==u||t[9]!==f||t[10]!==n||t[11]!==l?(p=()=>n?(l({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title})}),end:f}),()=>u()):(u(),()=>u()),m=[r.title,u,f,n,l],t[7]=r.title,t[8]=u,t[9]=f,t[10]=n,t[11]=l,t[12]=p,t[13]=m):(p=t[12],m=t[13]),(0,Z.useLayoutEffect)(p,m),null}function vn(e){return e.clearPageHeader}function yn(e){return e.setPageHeader}export{gn as CronPage};
@@ -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{_ as r,a as i,b as a,c as o,d as s,f as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,t as g,u as _,v,y}from"./Combination-HAlzriaz.js";import{Br as b,Ir as x,Lr as S,Rr as ee,zr as C}from"./index-C_2yKRJX.js";var w=e(t(),1),T=n();function E(e){let t=e+`CollectionProvider`,[n,i]=r(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=e=>{let{scope:t,children:n}=e,r=w.useRef(null),i=w.useRef(new Map).current;return(0,T.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};c.displayName=t;let l=e+`CollectionSlot`,u=d(l),f=w.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,T.jsx)(u,{ref:a(t,s(l,n).collectionRef),children:r})});f.displayName=l;let p=e+`CollectionItemSlot`,m=`data-radix-collection-item`,h=d(p),g=w.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=w.useRef(null),c=a(t,o),l=s(p,n);return w.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,T.jsx)(h,{[m]:``,ref:c,children:r})});g.displayName=p;function _(t){let n=s(e+`CollectionConsumer`,t);return w.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${m}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:c,Slot:f,ItemSlot:g},_,i]}var D=w.createContext(void 0);function O(e){let t=w.useContext(D);return e||t||`ltr`}var k=`rovingFocusGroup.onEntryFocus`,te={bubbles:!1,cancelable:!0},A=`RovingFocusGroup`,[j,M,N]=E(A),[ne,P]=r(A,[N]),[re,F]=ne(A),I=w.forwardRef((e,t)=>(0,T.jsx)(j.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(j.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(ie,{...e,ref:t})})}));I.displayName=A;var ie=w.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...m}=e,g=w.useRef(null),_=a(t,g),y=O(o),[b,x]=h({prop:l,defaultProp:u??null,onChange:d,caller:A}),[S,ee]=w.useState(!1),C=s(f),E=M(n),D=w.useRef(!1),[j,N]=w.useState(0);return w.useEffect(()=>{let e=g.current;if(e)return e.addEventListener(k,C),()=>e.removeEventListener(k,C)},[C]),(0,T.jsx)(re,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:b,onItemFocus:w.useCallback(e=>x(e),[x]),onItemShiftTab:w.useCallback(()=>ee(!0),[]),onFocusableItemAdd:w.useCallback(()=>N(e=>e+1),[]),onFocusableItemRemove:w.useCallback(()=>N(e=>e-1),[]),children:(0,T.jsx)(c.div,{tabIndex:S||j===0?-1:0,"data-orientation":r,...m,ref:_,style:{outline:`none`,...e.style},onMouseDown:v(e.onMouseDown,()=>{D.current=!0}),onFocus:v(e.onFocus,e=>{let t=!D.current;if(e.target===e.currentTarget&&t&&!S){let t=new CustomEvent(k,te);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=E().filter(e=>e.focusable);ce([e.find(e=>e.active),e.find(e=>e.id===b),...e].filter(Boolean).map(e=>e.ref.current),p)}}D.current=!1}),onBlur:v(e.onBlur,()=>ee(!1))})})}),L=`RovingFocusGroupItem`,R=w.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,l=p(),u=a||l,d=F(L,n),f=d.currentTabStopId===u,m=M(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:_}=d;return w.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),(0,T.jsx)(j.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,T.jsx)(c.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:v(e.onMouseDown,e=>{r?d.onItemFocus(u):e.preventDefault()}),onFocus:v(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:v(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=se(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?le(n,r+1):n.slice(r+1)}setTimeout(()=>ce(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:_!=null}):o})})});R.displayName=L;var ae={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function oe(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function se(e,t,n){let r=oe(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ae[r]}function ce(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function le(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ue=I,de=R,fe=[`Enter`,` `],pe=[`ArrowDown`,`PageUp`,`Home`],me=[`ArrowUp`,`PageDown`,`End`],he=[...pe,...me],ge={ltr:[...fe,`ArrowRight`],rtl:[...fe,`ArrowLeft`]},_e={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z=`Menu`,[B,ve,ye]=E(z),[V,be]=r(z,[ye,b,P]),H=b(),xe=P(),[Se,U]=V(z),[Ce,W]=V(z),we=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,c=H(t),[l,u]=w.useState(null),d=w.useRef(!1),f=s(a),p=O(i);return w.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,T.jsx)(C,{...c,children:(0,T.jsx)(Se,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:(0,T.jsx)(Ce,{scope:t,onClose:w.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})};we.displayName=z;var Te=`MenuAnchor`,Ee=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,T.jsx)(x,{...i,...r,ref:t})});Ee.displayName=Te;var De=`MenuPortal`,[Oe,ke]=V(De,{forceMount:void 0}),Ae=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=U(De,t);return(0,T.jsx)(Oe,{scope:t,forceMount:n,children:(0,T.jsx)(l,{present:n||o.open,children:(0,T.jsx)(i,{asChild:!0,container:a,children:r})})})};Ae.displayName=De;var G=`MenuContent`,[je,Me]=V(G),Ne=w.forwardRef((e,t)=>{let n=ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=U(G,e.__scopeMenu),o=W(G,e.__scopeMenu);return(0,T.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(l,{present:r||a.open,children:(0,T.jsx)(B.Slot,{scope:e.__scopeMenu,children:o.modal?(0,T.jsx)(Pe,{...i,ref:t}):(0,T.jsx)(Fe,{...i,ref:t})})})})}),Pe=w.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu),r=w.useRef(null),i=a(t,r);return w.useEffect(()=>{let e=r.current;if(e)return f(e)},[]),(0,T.jsx)(Le,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:v(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Fe=w.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu);return(0,T.jsx)(Le,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ie=d(`MenuContent.ScrollLock`),Le=w.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:y,disableOutsideScroll:b,...x}=e,S=U(G,n),C=W(G,n),E=H(n),D=xe(n),O=ve(n),[k,te]=w.useState(null),A=w.useRef(null),j=a(t,A,S.onContentChange),M=w.useRef(0),N=w.useRef(``),ne=w.useRef(0),P=w.useRef(null),re=w.useRef(`right`),F=w.useRef(0),I=b?g:w.Fragment,ie=b?{as:Ie,allowPinchZoom:!0}:void 0,L=e=>{let t=N.current+e,n=O().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=gt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){N.current=t,window.clearTimeout(M.current),t!==``&&(M.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};w.useEffect(()=>()=>window.clearTimeout(M.current),[]),u();let R=w.useCallback(e=>re.current===P.current?.side&&vt(e,P.current?.area),[]);return(0,T.jsx)(je,{scope:n,searchRef:N,onItemEnter:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:w.useCallback(e=>{R(e)||(A.current?.focus(),te(null))},[R]),onTriggerLeave:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:ne,onPointerGraceIntentChange:w.useCallback(e=>{P.current=e},[]),children:(0,T.jsx)(I,{...ie,children:(0,T.jsx)(o,{asChild:!0,trapped:i,onMountAutoFocus:v(s,e=>{e.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:(0,T.jsx)(_,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:y,children:(0,T.jsx)(ue,{asChild:!0,...D,dir:C.dir,orientation:`vertical`,loop:r,currentTabStopId:k,onCurrentTabStopIdChange:te,onEntryFocus:v(d,e=>{C.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,T.jsx)(ee,{role:`menu`,"aria-orientation":`vertical`,"data-state":pt(S.open),"data-radix-menu-content":``,dir:C.dir,...E,...x,ref:j,style:{outline:`none`,...x.style},onKeyDown:v(x.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&L(e.key));let i=A.current;if(e.target!==i||!he.includes(e.key))return;e.preventDefault();let a=O().filter(e=>!e.disabled).map(e=>e.ref.current);me.includes(e.key)&&a.reverse(),mt(a)}),onBlur:v(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current=``)}),onPointerMove:v(e.onPointerMove,Z(e=>{let t=e.target,n=F.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>F.current?`right`:`left`,F.current=e.clientX)}))})})})})})})});Ne.displayName=G;var Re=`MenuGroup`,ze=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`group`,...r,ref:t})});ze.displayName=Re;var Be=`MenuLabel`,Ve=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{...r,ref:t})});Ve.displayName=Be;var K=`MenuItem`,He=`menu.itemSelect`,q=w.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=w.useRef(null),s=W(K,e.__scopeMenu),c=Me(K,e.__scopeMenu),l=a(t,o),u=w.useRef(!1),d=()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(He,{bubbles:!0,cancelable:!0});e.addEventListener(He,e=>r?.(e),{once:!0}),m(e,t),t.defaultPrevented?u.current=!1:s.onClose()}};return(0,T.jsx)(Ue,{...i,ref:l,disabled:n,onClick:v(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:v(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:v(e.onKeyDown,e=>{let t=c.searchRef.current!==``;n||t&&e.key===` `||fe.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});q.displayName=K;var Ue=w.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=Me(K,n),l=xe(n),u=w.useRef(null),d=a(t,u),[f,p]=w.useState(!1),[m,h]=w.useState(``);return w.useEffect(()=>{let e=u.current;e&&h((e.textContent??``).trim())},[o.children]),(0,T.jsx)(B.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,T.jsx)(de,{asChild:!0,...l,focusable:!r,children:(0,T.jsx)(c.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...o,ref:d,onPointerMove:v(e.onPointerMove,Z(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:v(e.onPointerLeave,Z(e=>s.onItemLeave(e))),onFocus:v(e.onFocus,()=>p(!0)),onBlur:v(e.onBlur,()=>p(!1))})})})}),We=`MenuCheckboxItem`,Ge=w.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,T.jsx)($e,{scope:e.__scopeMenu,checked:n,children:(0,T.jsx)(q,{role:`menuitemcheckbox`,"aria-checked":Y(n)?`mixed`:n,...i,ref:t,"data-state":X(n),onSelect:v(i.onSelect,()=>r?.(Y(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ge.displayName=We;var Ke=`MenuRadioGroup`,[qe,Je]=V(Ke,{value:void 0,onValueChange:()=>{}}),Ye=w.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=s(r);return(0,T.jsx)(qe,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,T.jsx)(ze,{...i,ref:t})})});Ye.displayName=Ke;var Xe=`MenuRadioItem`,Ze=w.forwardRef((e,t)=>{let{value:n,...r}=e,i=Je(Xe,e.__scopeMenu),a=n===i.value;return(0,T.jsx)($e,{scope:e.__scopeMenu,checked:a,children:(0,T.jsx)(q,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":X(a),onSelect:v(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Ze.displayName=Xe;var Qe=`MenuItemIndicator`,[$e,et]=V(Qe,{checked:!1}),tt=w.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=et(Qe,n);return(0,T.jsx)(l,{present:r||Y(a.checked)||a.checked===!0,children:(0,T.jsx)(c.span,{...i,ref:t,"data-state":X(a.checked)})})});tt.displayName=Qe;var nt=`MenuSeparator`,rt=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});rt.displayName=nt;var it=`MenuArrow`,at=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,T.jsx)(S,{...i,...r,ref:t})});at.displayName=it;var ot=`MenuSub`,[st,ct]=V(ot),lt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=U(ot,t),o=H(t),[c,l]=w.useState(null),[u,d]=w.useState(null),f=s(i);return w.useEffect(()=>(a.open===!1&&f(!1),()=>f(!1)),[a.open,f]),(0,T.jsx)(C,{...o,children:(0,T.jsx)(Se,{scope:t,open:r,onOpenChange:f,content:u,onContentChange:d,children:(0,T.jsx)(st,{scope:t,contentId:p(),triggerId:p(),trigger:c,onTriggerChange:l,children:n})})})};lt.displayName=ot;var J=`MenuSubTrigger`,ut=w.forwardRef((e,t)=>{let n=U(J,e.__scopeMenu),r=W(J,e.__scopeMenu),i=ct(J,e.__scopeMenu),a=Me(J,e.__scopeMenu),o=w.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=w.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return w.useEffect(()=>u,[u]),w.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,T.jsx)(Ee,{asChild:!0,...l,children:(0,T.jsx)(Ue,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":pt(n.open),...e,ref:y(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:v(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:v(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:v(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||ge[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ut.displayName=J;var dt=`MenuSubContent`,ft=w.forwardRef((e,t)=>{let n=ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=U(G,e.__scopeMenu),s=W(G,e.__scopeMenu),c=ct(dt,e.__scopeMenu),u=w.useRef(null),d=a(t,u);return(0,T.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(l,{present:r||o.open,children:(0,T.jsx)(B.Slot,{scope:e.__scopeMenu,children:(0,T.jsx)(Le,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:d,align:`start`,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:v(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:v(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:v(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=_e[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});ft.displayName=dt;function pt(e){return e?`open`:`closed`}function Y(e){return e===`indeterminate`}function X(e){return Y(e)?`indeterminate`:e?`checked`:`unchecked`}function mt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ht(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function gt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ht(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function _t(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function vt(e,t){return t?_t({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var yt=we,bt=Ee,xt=Ae,St=Ne,Ct=ze,wt=Ve,Tt=q,Et=Ge,Dt=Ye,Ot=Ze,kt=tt,At=rt,jt=at,Mt=ut,Nt=ft,Q=`DropdownMenu`,[Pt,Ft]=r(Q,[be]),$=be(),[It,Lt]=Pt(Q),Rt=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$(t),l=w.useRef(null),[u,d]=h({prop:i,defaultProp:a??!1,onChange:o,caller:Q});return(0,T.jsx)(It,{scope:t,triggerId:p(),triggerRef:l,contentId:p(),open:u,onOpenChange:d,onOpenToggle:w.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,T.jsx)(yt,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Rt.displayName=Q;var zt=`DropdownMenuTrigger`,Bt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Lt(zt,n),o=$(n);return(0,T.jsx)(bt,{asChild:!0,...o,children:(0,T.jsx)(c.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:y(t,a.triggerRef),onPointerDown:v(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:v(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Bt.displayName=zt;var Vt=`DropdownMenuPortal`,Ht=e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,T.jsx)(xt,{...r,...n})};Ht.displayName=Vt;var Ut=`DropdownMenuContent`,Wt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Lt(Ut,n),a=$(n),o=w.useRef(!1);return(0,T.jsx)(St,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:v(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:v(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Wt.displayName=Ut;var Gt=`DropdownMenuGroup`,Kt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Ct,{...i,...r,ref:t})});Kt.displayName=Gt;var qt=`DropdownMenuLabel`,Jt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(wt,{...i,...r,ref:t})});Jt.displayName=qt;var Yt=`DropdownMenuItem`,Xt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Tt,{...i,...r,ref:t})});Xt.displayName=Yt;var Zt=`DropdownMenuCheckboxItem`,Qt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Et,{...i,...r,ref:t})});Qt.displayName=Zt;var $t=`DropdownMenuRadioGroup`,en=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Dt,{...i,...r,ref:t})});en.displayName=$t;var tn=`DropdownMenuRadioItem`,nn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Ot,{...i,...r,ref:t})});nn.displayName=tn;var rn=`DropdownMenuItemIndicator`,an=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(kt,{...i,...r,ref:t})});an.displayName=rn;var on=`DropdownMenuSeparator`,sn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(At,{...i,...r,ref:t})});sn.displayName=on;var cn=`DropdownMenuArrow`,ln=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(jt,{...i,...r,ref:t})});ln.displayName=cn;var un=`DropdownMenuSubTrigger`,dn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Mt,{...i,...r,ref:t})});dn.displayName=un;var fn=`DropdownMenuSubContent`,pn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Nt,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});pn.displayName=fn;var mn=Rt,hn=Bt,gn=Ht,_n=Wt,vn=Xt,yn=sn;export{yn as a,mn as i,vn as n,hn as o,gn as r,_n 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{br as i,rs as a}from"./index-C_2yKRJX.js";var o=n(),s=e(t(),1),c=r(),l=`xopc.extensionUiGrants.v1`;function u(){let e=(0,o.c)(79),{t}=a(),n=i(),[r,l]=(0,s.useState)(p),u;e[0]===n?u=e[1]:(u=n.toSorted(f),e[0]=n,e[1]=u);let h=u,g;e[2]===t?g=e[3]:(g=t(`extensionDebug.title`),e[2]=t,e[3]=g);let _;e[4]===g?_=e[5]:(_=(0,c.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:g}),e[4]=g,e[5]=_);let v;e[6]===t?v=e[7]:(v=t(`extensionDebug.subtitle`),e[6]=t,e[7]=v);let y;e[8]===v?y=e[9]:(y=(0,c.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v}),e[8]=v,e[9]=y);let b;e[10]!==_||e[11]!==y?(b=(0,c.jsxs)(`div`,{children:[_,y]}),e[10]=_,e[11]=y,e[12]=b):b=e[12];let x;e[13]===t?x=e[14]:(x=t(`extensionDebug.grantsHeading`),e[13]=t,e[14]=x);let S;e[15]===x?S=e[16]:(S=(0,c.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:x}),e[15]=x,e[16]=S);let C;e[17]===t?C=e[18]:(C=t(`extensionDebug.grantsHint`),e[17]=t,e[18]=C);let w;e[19]===C?w=e[20]:(w=(0,c.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:C}),e[19]=C,e[20]=w);let T;e[21]===r?T=e[22]:(T=(0,c.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg border border-edge-subtle bg-surface-muted p-3 font-mono text-xs text-fg`,children:r}),e[21]=r,e[22]=T);let E;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>l(m()),e[23]=E):E=e[23];let D;e[24]===t?D=e[25]:(D=t(`extensionDebug.refresh`),e[24]=t,e[25]=D);let O;e[26]===D?O=e[27]:(O=(0,c.jsx)(`button`,{type:`button`,className:`mt-3 rounded-lg border border-edge px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,onClick:E,children:D}),e[26]=D,e[27]=O);let k;e[28]!==T||e[29]!==O||e[30]!==S||e[31]!==w?(k=(0,c.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[S,w,T,O]}),e[28]=T,e[29]=O,e[30]=S,e[31]=w,e[32]=k):k=e[32];let A;e[33]===t?A=e[34]:(A=t(`extensionDebug.listHeading`),e[33]=t,e[34]=A);let j;e[35]===A?j=e[36]:(j=(0,c.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:A}),e[35]=A,e[36]=j);let M;e[37]===t?M=e[38]:(M=t(`extensionDebug.colId`),e[37]=t,e[38]=M);let N;e[39]===M?N=e[40]:(N=(0,c.jsx)(`th`,{className:`py-2 pr-2`,children:M}),e[39]=M,e[40]=N);let P;e[41]===t?P=e[42]:(P=t(`extensionDebug.colName`),e[41]=t,e[42]=P);let F;e[43]===P?F=e[44]:(F=(0,c.jsx)(`th`,{className:`py-2 pr-2`,children:P}),e[43]=P,e[44]=F);let I;e[45]===t?I=e[46]:(I=t(`extensionDebug.colPermissions`),e[45]=t,e[46]=I);let L;e[47]===I?L=e[48]:(L=(0,c.jsx)(`th`,{className:`py-2`,children:I}),e[47]=I,e[48]=L);let R;e[49]!==N||e[50]!==F||e[51]!==L?(R=(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[N,F,L]})}),e[49]=N,e[50]=F,e[51]=L,e[52]=R):R=e[52];let z;e[53]===h?z=e[54]:(z=h.map(d),e[53]=h,e[54]=z);let B;e[55]===z?B=e[56]:(B=(0,c.jsx)(`tbody`,{children:z}),e[55]=z,e[56]=B);let V;e[57]!==R||e[58]!==B?(V=(0,c.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,c.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[R,B]})}),e[57]=R,e[58]=B,e[59]=V):V=e[59];let H;e[60]!==j||e[61]!==V?(H=(0,c.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[j,V]}),e[60]=j,e[61]=V,e[62]=H):H=e[62];let U;e[63]===t?U=e[64]:(U=t(`extensionDebug.futureHeading`),e[63]=t,e[64]=U);let W;e[65]===U?W=e[66]:(W=(0,c.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:U}),e[65]=U,e[66]=W);let G;e[67]===t?G=e[68]:(G=t(`extensionDebug.futureBody`),e[67]=t,e[68]=G);let K;e[69]===G?K=e[70]:(K=(0,c.jsx)(`p`,{className:`mt-2`,children:G}),e[69]=G,e[70]=K);let q;e[71]!==W||e[72]!==K?(q=(0,c.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-muted/50 p-4 text-sm text-fg-muted`,children:[W,K]}),e[71]=W,e[72]=K,e[73]=q):q=e[73];let J;return e[74]!==k||e[75]!==H||e[76]!==q||e[77]!==b?(J=(0,c.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[b,k,H,q]}),e[74]=k,e[75]=H,e[76]=q,e[77]=b,e[78]=J):J=e[78],J}function d(e){return(0,c.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,c.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,c.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,c.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(){return m()}function m(){try{let e=localStorage.getItem(l);if(!e)return`{}`;let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(e){return e instanceof Error?e.message:String(e)}}export{u as ExtensionDebugPage};
@@ -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{i,o as a,t as o}from"./url-DQRqHuL-.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,n as l,t as u}from"./fetch-CFdKBnE6.js";import{N as d,Zo as f,br as p,ci as m,di as h,fi as g,ja as _,pi as v,ts as y,ui as b}from"./index-C_2yKRJX.js";import{a as x,c as S,d as C,i as w,l as T,s as E,t as D,u as O}from"./voice-api-key-field-CNrKzQrf.js";import{t as k}from"./schema-form-DEvdni_r.js";var A=n(),j=e(t(),1),M=r(),N=()=>o(C);function P(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function F(e){let t=(0,A.c)(40),{extensionId:n}=e,r=i(L),o;t[0]===r?o=t[1]:(o=a(r),t[0]=r,t[1]=o);let l=o,u=l.imageModelsSettings,d=c(I),f;t[2]===d?f=t[3]:(f=d?N():null,t[2]=d,t[3]=f);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=s(f,O,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let v=g,y;if(t[7]!==v||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),y=v.filter(e),t[7]=v,t[8]=n,t[9]=y}else y=t[9];let b=y,x=S(b),C;t[12]===u?C=t[13]:(C=P(u),t[12]=u,t[13]=C);let w=C,E;t[14]!==l.providersSettings.getApiKey||t[15]!==l.providersSettings.getApiKeyCn||t[16]!==l.providersSettings.getApiKeyIntl?(E={getApiKey:l.providersSettings.getApiKey,getApiKeyIntl:l.providersSettings.getApiKeyIntl,getApiKeyCn:l.providersSettings.getApiKeyCn},t[14]=l.providersSettings.getApiKey,t[15]=l.providersSettings.getApiKeyCn,t[16]=l.providersSettings.getApiKeyIntl,t[17]=E):E=t[17];let D=E;if(!d)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,M.jsx)(_,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(b.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let k;t[21]!==x||t[22]!==u.credentialsSaveError?(k=()=>void x.saveCredentials(u.credentialsSaveError),t[21]=x,t[22]=u.credentialsSaveError,t[23]=k):k=t[23];let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,t[24]=j):j=t[24];let F;return t[25]!==D||t[26]!==x.credBaseline||t[27]!==x.credDirty||t[28]!==x.credDraft||t[29]!==x.credError||t[30]!==x.credNoopFlash||t[31]!==x.credSavedFlash||t[32]!==x.credSaving||t[33]!==x.onDiscardCredentials||t[34]!==x.updateCredRow||t[35]!==r||t[36]!==w||t[37]!==b||t[38]!==k?(F=(0,M.jsx)(T,{summaries:b,credDraft:x.credDraft,credBaseline:x.credBaseline,credDirty:x.credDirty,credSaving:x.credSaving,credError:x.credError,credSavedFlash:x.credSavedFlash,credNoopFlash:x.credNoopFlash,updateCredRow:x.updateCredRow,onDiscardCredentials:x.onDiscardCredentials,onSaveCredentials:k,extensionIds:j,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:D,messages:w}),t[25]=D,t[26]=x.credBaseline,t[27]=x.credDirty,t[28]=x.credDraft,t[29]=x.credError,t[30]=x.credNoopFlash,t[31]=x.credSavedFlash,t[32]=x.credSaving,t[33]=x.onDiscardCredentials,t[34]=x.updateCredRow,t[35]=r,t[36]=w,t[37]=b,t[38]=k,t[39]=F):F=t[39],F}function I(e){return!!e.token}function L(e){return e.language}function R(e){let t=(0,A.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var z=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function B(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function V(){return v(b,m)}function H(){return v(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h,`dark:border-edge`)}function U(e,t){if(!e||!t)return{apiKey:``,model:z[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:z[0].id}}function W({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(i(e=>e.language)),c=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:c.apiKeyMaskedHelp,copy:c.apiKeyCopy,copied:c.apiKeyCopied,show:c.apiKeyShow,hide:c.apiKeyHide,notInConfigFile:c.apiKeyNotInConfigFile,loadFailed:c.apiKeyRevealFailed},{data:d}=s(o(`/api/voice/stt-providers`),x,{revalidateOnFocus:!1}),f=(0,j.useMemo)(()=>d?.providers.some(t=>t.id===e&&t.configured)??!1,[e,d]),p=(0,j.useMemo)(()=>U(t,e),[e,t]),h=(0,j.useRef)(!1),[_,y]=(0,j.useState)(null),[b,S]=(0,j.useState)(!1),[C,w]=(0,j.useState)(null),[T,O]=(0,j.useState)(!1),k=_??p,A=p,N=k.apiKey!==A.apiKey||k.model!==A.model,P=(0,j.useCallback)(async()=>{S(!0),w(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:k.apiKey,model:k.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:k.apiKey,model:k.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:k.apiKey,model:k.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await E(r),await n(r,!1),h.current=!1,y(null),O(!0),window.setTimeout(()=>O(!1),2500)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},[k.apiKey,k.model,n,e,t]),F=e===`groq`?z:[{id:k.model,name:k.model}];return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,M.jsx)(`span`,{className:v(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?l.configured:l.notConfigured})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,m),children:[(0,M.jsx)(R,{children:c.stt.apiKey}),(0,M.jsx)(D,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:k.apiKey,onChange:e=>{h.current=!0,y(t=>({...t??p,apiKey:e})),w(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[c.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,M.jsxs)(`div`,{className:v(`flex flex-col gap-1.5`,m),children:[(0,M.jsx)(R,{children:c.stt.model}),e===`groq`?(0,M.jsx)(`select`,{className:V(),value:k.model,onChange:e=>{h.current=!0,y(t=>({...t??p,model:e.target.value})),w(null)},children:F.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.name},e.id))}):(0,M.jsx)(`input`,{className:H(),value:k.model,onChange:e=>{h.current=!0,y(t=>({...t??p,model:e.target.value})),w(null)}})]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[T?(0,M.jsx)(`span`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:c.saved}):null,C?(0,M.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:C}):null,(0,M.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!N||b,onClick:()=>{h.current=!1,y(null),w(null)},children:c.discard}),(0,M.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!N||b,onClick:()=>void P(),children:b?c.saving:c.save})]})]})}function G(e){let t=(0,A.c)(13),{extensionId:n}=e,r=i(q),a=c(K),u;t[0]===n?u=t[1]:(u=()=>l(o(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=u);let{data:d,isLoading:f}=s(a&&n?`ext-stt-detail-${n}`:null,u),p;t[2]===d?p=t[3]:(p=B(d),t[2]=d,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:v,isLoading:y}=s(a?`voice-settings-ext-stt`:null,w,h);if(!a)return null;if(f||y){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,M.jsx)(_,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let b=`${n}:${m}`,x;return t[8]!==v||t[9]!==m||t[10]!==b||t[11]!==g?(x=(0,M.jsx)(W,{providerId:m,voiceSettings:g,mutateVoice:v},b),t[8]=v,t[9]=m,t[10]=b,t[11]=g,t[12]=x):x=t[12],x}function K(e){return!!e.token}function q(e){return e.language}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){let t={};if(e.type!==`object`||!J(e.properties))return t;for(let[n,r]of Object.entries(e.properties))J(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function X(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Z({extensionId:e}){let t=a(i(e=>e.language)).agentSettings,n=c(e=>!!e.token),{data:r,error:d}=s(n&&e?`ext-detail-${e}`:null,()=>l(o(`/api/extensions/${encodeURIComponent(e)}`))),{data:f,mutate:p,error:m}=s(n&&e?`ext-cfg-${e}`:null,()=>l(o(`/api/extensions/${encodeURIComponent(e)}/config`))),h=r?.manifest?.configSchema,_=(0,j.useMemo)(()=>h&&h.type===`object`?Y(h):{},[h]),v=(0,j.useMemo)(()=>({..._,...f??{}}),[_,f]),[y,b]=(0,j.useReducer)(X,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[x,S]=(0,j.useState)(!1),C=(0,j.useRef)(!1),w=(0,j.useRef)(v);!C.current&&w.current!==v&&(w.current=v,b({type:`sync`,value:v}));let T=(0,j.useCallback)(e=>{C.current=!0,b({type:`change`,value:e})},[]),E=(0,j.useCallback)(()=>{C.current=!1,b({type:`discard`,value:v})},[v]),D=(0,j.useCallback)(()=>{!h||h.type!==`object`||(C.current=!0,b({type:`reset-defaults`,value:{...Y(h)}}))},[h]),O=(0,j.useCallback)(async()=>{if(e){b({type:`save-start`});try{let t=await u(o(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(y.localValues)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await p(y.localValues,!1),C.current=!1,b({type:`save-success`,value:y.localValues}),S(!0),window.setTimeout(()=>S(!1),3e3)}catch(e){b({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[y.localValues,e,p]);if(!n)return null;if(d||m){let e=d??m;return(0,M.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!h||h.type!==`object`?null:(0,M.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x?(0,M.jsx)(`span`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:t.saved}):null,y.saveError?(0,M.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:y.saveError}):null,(0,M.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!y.isDirty,onClick:E,children:t.discard}),(0,M.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:D,children:`Reset to defaults`}),(0,M.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!y.isDirty||y.saving,onClick:()=>void O(),children:y.saving?t.saving:t.save})]})]}),(0,M.jsx)(k,{schema:h,values:y.localValues,onChange:T,disabled:y.saving})]})}function Q(){let e=(0,A.c)(47),t=i(ee),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,o=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=y(),u=p();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let m,h,g;if(e[3]!==c||e[4]!==u||e[5]!==l){g=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),m=u.find(t),!m){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,M.jsx)($,{message:t}),e[11]=t,e[12]=n),g=n;break bb0}let n=m.ui?.contributions?.settingsPanels;h=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=m,e[7]=h,e[8]=g}else m=e[6],h=e[7],g=e[8];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _=h,v=!!(_&&m.ui),b=!!m.hasConfigSchema,x=m.kind===`image-generation`,S=m.kind===`media-provider`;if(!b&&!v&&!(x||S)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,M.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=_?.title??`${m.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==o?(T=x?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:o.banner}),(0,M.jsx)(f,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:o.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=o,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==x?(E=x?(0,M.jsx)(F,{extensionId:c}):null,e[21]=c,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==s?(D=S?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,M.jsx)(f,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=S,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==S?(O=S?(0,M.jsx)(G,{extensionId:c}):null,e[27]=c,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==b?(k=b?(0,M.jsx)(Z,{extensionId:c}):null,e[30]=c,e[31]=b,e[32]=k):k=e[32];let j;e[33]!==m.name||e[34]!==m.ui||e[35]!==c||e[36]!==v||e[37]!==_?(j=v&&_&&m.ui?(0,M.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,M.jsx)(d,{extensionId:c,extensionName:m.name,entrypoint:_.entrypoint,permissions:m.ui?.permissions,title:_.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=m.name,e[34]=m.ui,e[35]=c,e[36]=v,e[37]=_,e[38]=j):j=e[38];let N;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==j?(N=(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[w,T,E,D,O,k,j]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=j,e[46]=N):N=e[46],N}function ee(e){return e.language}function $(e){let t=(0,A.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{Q as ExtensionSettingsPage};
@@ -1 +0,0 @@
1
- import{a as e,c as t,d as n,i as r,o as i,u as a}from"./url-DQRqHuL-.js";var o=e((e,r)=>({baseUrl:typeof window<`u`?window.location.origin:``,token:void 0,tokenDialogOpen:!1,tokenExpired:!1,setGatewayToken:t=>{n(t),e({token:t,tokenDialogOpen:!1,tokenExpired:!1}),window.dispatchEvent(new CustomEvent(`token-saved`,{detail:{token:t}}))},clearGatewayToken:()=>{t(),e({token:void 0})},openTokenDialog:()=>e({tokenDialogOpen:!0}),closeTokenDialog:()=>e({tokenDialogOpen:!1}),onUnauthorized:()=>{r().clearGatewayToken(),e({tokenDialogOpen:!1,tokenExpired:!0}),window.dispatchEvent(new CustomEvent(`token-expired`))}}));function s(){let e=new URLSearchParams(window.location.search).get(`token`);if(e){o.getState().setGatewayToken(e);let t=window.location.pathname+window.location.hash,n=window.history.state,r=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:n;window.history.replaceState(r,``,t);return}let t=a();o.setState({token:t||void 0,tokenDialogOpen:!1})}function c(){return r.getState().language}function l(e,t,n){let r=e.trim().toLowerCase();return!!(!r||r===`http ${t}`||n&&r===n.trim().toLowerCase()||t===500&&r===`internal server error`)}function u(e,t,n){let r=n?.trim()??``;if(r&&!l(r,e,t))return r;let a=i(c()).api;return e>=500?e===502?a.errorBadGateway:e===503?a.errorServiceUnavailable:e===504?a.errorGatewayTimeout:e===500?a.errorInternal:a.errorServer.replace(`{{status}}`,String(e)):e===404?a.errorNotFound:e===403?a.errorForbidden:a.errorRequest.replace(`{{status}}`,String(e))}var d=null,f=null;function p(){d||=new Promise(e=>{f=e})}function m(){d&&(f?.(),d=null,f=null)}typeof window<`u`&&window.addEventListener(`token-saved`,m);async function h(e,t){d&&await d;let n=o.getState().token,r=new Headers(t?.headers),i=t?.body,a=typeof FormData<`u`&&i instanceof FormData;!r.has(`Content-Type`)&&!a&&r.set(`Content-Type`,`application/json`),n&&r.set(`Authorization`,`Bearer ${n}`);let s=await fetch(e,{...t,headers:r});return s.status===401&&(p(),o.getState().onUnauthorized()),s}async function g(e,t){let n=await h(e,t);if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message,r=u(n.status,n.statusText,t);throw Error(r)}return n.json()}export{o as a,s as i,g as n,u as r,h as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./url-DQRqHuL-.js";import{i,o as a}from"./vendor-swr-BIWyz7Rc.js";import{n as o,t as s}from"./fetch-CFdKBnE6.js";var c=n(),l=e(t(),1);function u(){return r(`/api/config`)}var d=null;async function f(){return d||(d=o(u()).finally(()=>{d=null}),d)}function p(e){let t=(0,c.c)(6),n;t[0]===e?n=t[1]:(n=e?u():null,t[0]=e,t[1]=n);let r=n,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[2]=o):o=t[2];let s=i(r,f,o),d,p;return t[3]===e?(d=t[4],p=t[5]):(d=()=>{if(!e)return;let t=u(),n=()=>{a(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},p=[e],t[3]=e,t[4]=d,t[5]=p),(0,l.useEffect)(d,p),s}function m(){return a(u())}var h=6e4,g=500,_=5e3;function v(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`STARTUP_UNAVAILABLE`&&t.retryable===!0&&typeof t.retryAfterMs==`number`}function y(e){return new Promise(t=>setTimeout(t,e))}function b(e){let t=typeof e.retryAfterMs==`number`?e.retryAfterMs:g;return Math.min(Math.max(t,100),_)}async function x(e,t,n){let r=Date.now(),i=n?.timeoutMs??h;for(;;){let n=await s(e,t);if(n.status!==503)return n;let a=await n.clone().json().catch(()=>null);if(!v(a)||Date.now()-r>=i)return n;await y(b(a))}}export{p as i,f as n,m as r,x as t};
@@ -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{t as r}from"./url-DQRqHuL-.js";import{o as i}from"./vendor-swr-BIWyz7Rc.js";import{n as a}from"./fetch-CFdKBnE6.js";import{r as o}from"./gateway-startup-retry-DdngdObI.js";import{pi as s,si as c,ui as l}from"./index-C_2yKRJX.js";import{O as u,k as d}from"./settings-advanced-gate-t6v8Dwb8.js";var f=e(t(),1),p=n(),m=Array.from({length:60},(e,t)=>t),h=s(l,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),g=s(`h-9 min-w-[6.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,c,`dark:bg-surface-panel`),_=s(`h-9 min-w-[9.5rem] shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-sm text-fg`,c),v=s(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,c),y=s(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,c);function b(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function x(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function S(e,t){switch(t.type){case`reset`:return b(t.state);case`replace`:return t.state}}function C({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let a=(0,f.useMemo)(()=>d(e),[e]),[o,c]=(0,f.useReducer)(S,a,b),l=(0,f.useRef)(e);l.current!==e&&(l.current=e,c({type:`reset`,state:a}));let C=(0,f.useCallback)(e=>{let n={...o,...e};c({type:`replace`,state:n});let r=x(n),i=x(o);Object.keys(r).some(e=>r[e]!==i[e])&&t(u(r))},[t,o]),{mode:w,intervalKind:T,onceDate:E,intervalMinutes:D,intervalHours:O,minute:k,hour:A,weekDays:j,dayOfMonth:M,rawCron:N,intervalMinutesDraft:P,intervalHoursDraft:F}=o,I=`${String(A).padStart(2,`0`)}:${String(k).padStart(2,`0`)}`,L=e=>{let t=e.target.value;if(!t)return;let[n,r]=t.split(`:`).map(e=>parseInt(e,10));Number.isNaN(n)||Number.isNaN(r)||C({minute:r,hour:n})},R=(0,p.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,p.jsxs)(`select`,{className:h,disabled:r,value:w,onChange:e=>{let t=e.target.value;C({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,p.jsx)(`option`,{value:`no_repeat`,children:n.modeNoRepeat}),(0,p.jsx)(`option`,{value:`interval`,children:n.modeInterval}),(0,p.jsx)(`option`,{value:`hourly`,children:n.modeHourly}),(0,p.jsx)(`option`,{value:`daily`,children:n.modeDaily}),(0,p.jsx)(`option`,{value:`weekly`,children:n.modeWeekly}),(0,p.jsx)(`option`,{value:`monthly`,children:n.modeMonthly}),(0,p.jsx)(`option`,{value:`custom`,children:n.modeCustom})]}),w===`no_repeat`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{type:`date`,disabled:r,className:_,value:E,onChange:e=>{C({onceDate:e.target.value})},"aria-label":n.modeNoRepeat}),(0,p.jsx)(`input`,{type:`time`,step:60,disabled:r,className:g,value:I,onChange:L,"aria-label":n.scheduleTimeLabel})]}),w===`interval`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`select`,{className:s(h,`w-auto min-w-[5rem]`),disabled:r,value:T,onChange:e=>{let t=e.target.value;C({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,p.jsx)(`option`,{value:`minutes`,children:n.intervalKindMinutes}),(0,p.jsx)(`option`,{value:`hours`,children:n.intervalKindHours})]}),T===`minutes`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:v,value:P??String(D),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),C(r)},onBlur:()=>{if(P===null)return;let e=parseInt(P,10);C({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,p.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:v,value:F??String(O),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),C(r)},onBlur:()=>{if(F===null)return;let e=parseInt(F,10);C({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,p.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,p.jsx)(`select`,{className:s(h,`w-auto min-w-[4rem]`),disabled:r,value:k,onChange:e=>{C({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:m.map(e=>(0,p.jsx)(`option`,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,p.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),w===`daily`&&(0,p.jsx)(`input`,{type:`time`,step:60,disabled:r,className:g,value:I,onChange:L,"aria-label":n.scheduleTimeLabel}),w===`weekly`&&(0,p.jsx)(`input`,{type:`time`,step:60,disabled:r,className:g,value:I,onChange:L,"aria-label":n.scheduleTimeLabel}),w===`monthly`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`select`,{className:s(h,`w-auto min-w-[4.5rem]`),disabled:r,value:M,onChange:e=>{C({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))}),(0,p.jsx)(`input`,{type:`time`,step:60,disabled:r,className:g,value:I,onChange:L,"aria-label":n.scheduleTimeLabel})]}),w===`hourly`&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`select`,{className:s(h,`w-auto min-w-[4rem]`),disabled:r,value:k,onChange:e=>{C({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:m.map(e=>(0,p.jsx)(`option`,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,p.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),z=w===`weekly`?(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=j[t];return(0,p.jsx)(`button`,{type:`button`,disabled:r,className:s(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...j];e[t]=!e[t],C({weekDays:e})},children:e},e)})}):null,B=w===`custom`?(0,p.jsxs)(`div`,{className:`pt-1`,children:[(0,p.jsx)(`textarea`,{disabled:r,className:y,rows:2,spellCheck:!1,value:N,placeholder:`*/5 * * * *`,onChange:e=>{C({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,p.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,p.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,R,z,B]})}function w(){return r(`/api/workspace/heartbeat-md`)}async function T(){let e=await a(w());return typeof e.payload?.content==`string`?e.payload.content:``}function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e){let t=E(e)?e:{},n=E(t.gateway)?t.gateway:{},r=E(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=E(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function O(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function k(e){await a(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:O(e)}})}),o()}async function A(e){await a(r(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),i(w())}async function j(e){await a(r(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}export{T as a,j as i,k as n,w as o,A as r,C as s,D as t};