@xopcai/xopc 0.0.87 → 0.0.89

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 (282) hide show
  1. package/README.md +8 -1
  2. package/README.zh-CN.md +8 -1
  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/agents-B6PJB07W.js +222 -0
  6. package/dist/gateway/static/root/assets/apps-page-BOr0B1wv.js +1 -0
  7. package/dist/gateway/static/root/assets/channels-settings-BelUKggl.js +1 -0
  8. package/dist/gateway/static/root/assets/{channels-status-swr-BSHqqCF1.js → channels-status-swr-DaHGkRF1.js} +1 -1
  9. package/dist/gateway/static/root/assets/cron-api-CjOg-BIj.js +1 -0
  10. package/dist/gateway/static/root/assets/cron-page-DhoZmZXb.js +1 -0
  11. package/dist/gateway/static/root/assets/{dist-Cmjp2APP.js → dist-6LecgDx5.js} +1 -1
  12. package/dist/gateway/static/root/assets/{extension-debug-page-CFa9z_1N.js → extension-debug-page-CtuKJ9tE.js} +1 -1
  13. package/dist/gateway/static/root/assets/{extension-page-BI8eaTPq.js → extension-page-ykzjOkR5.js} +1 -1
  14. package/dist/gateway/static/root/assets/extension-settings-page-Ce2qrdpO.js +1 -0
  15. package/dist/gateway/static/root/assets/{fetch-DRqwef_Q.js → fetch-C9FFJjuH.js} +1 -1
  16. package/dist/gateway/static/root/assets/{field-primitives-BiNHBo2Y.js → field-primitives-BFcrNeTU.js} +1 -1
  17. package/dist/gateway/static/root/assets/{heartbeat-config-api-ZRb8qhuz.js → heartbeat-config-api-CEg4Vr9R.js} +1 -1
  18. package/dist/gateway/static/root/assets/{index-Cu7bKuUi.js → index-CZfy9oxs.js} +85 -85
  19. package/dist/gateway/static/root/assets/index-CiN1cQiQ.css +1 -0
  20. package/dist/gateway/static/root/assets/logs-page-BwWLfqvd.js +1 -0
  21. package/dist/gateway/static/root/assets/sessions-page-DV5WN8uk.js +1 -0
  22. package/dist/gateway/static/root/assets/{settings-form-section-DiqqVs6m.js → settings-form-section-BqdzA28u.js} +1 -1
  23. package/dist/gateway/static/root/assets/settings-page-CfOBRbPX.js +3 -0
  24. package/dist/gateway/static/root/assets/{share-preview-page-n1Gprylk.js → share-preview-page-Di5Bzh4g.js} +1 -1
  25. package/dist/gateway/static/root/assets/skills-page-D0H5Kaxg.js +2 -0
  26. package/dist/gateway/static/root/assets/{theme-store-CZOh1nT3.js → theme-store-CNqbmTNV.js} +1 -1
  27. package/dist/gateway/static/root/assets/url-aYn-Rj1C.js +7 -0
  28. package/dist/gateway/static/root/assets/{utils-CkWBfxs4.js → utils-BWm2tG2w.js} +1 -1
  29. package/dist/gateway/static/root/assets/voice-api-key-field-X2UfnHeq.js +1 -0
  30. package/dist/gateway/static/root/assets/workflows-page-BOPpO3NG.js +27 -0
  31. package/dist/gateway/static/root/index.html +5 -5
  32. package/dist/package.js +1 -1
  33. package/dist/src/agent/agent-manager.d.ts +2 -0
  34. package/dist/src/agent/agent-manager.js +1 -0
  35. package/dist/src/agent/agent-manager.js.map +1 -1
  36. package/dist/src/agent/child-agent-factory.d.ts +15 -0
  37. package/dist/src/agent/child-agent-factory.js +35 -2
  38. package/dist/src/agent/child-agent-factory.js.map +1 -1
  39. package/dist/src/agent/client-error-format.d.ts +20 -0
  40. package/dist/src/agent/client-error-format.js +97 -0
  41. package/dist/src/agent/client-error-format.js.map +1 -0
  42. package/dist/src/agent/embedded/run-turn.js +23 -4
  43. package/dist/src/agent/embedded/run-turn.js.map +1 -1
  44. package/dist/src/agent/goals/goal-locale.d.ts +1 -1
  45. package/dist/src/agent/inbound/turn-dispatcher.js +1 -1
  46. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  47. package/dist/src/agent/orchestration/llm-turn-retry.d.ts +2 -0
  48. package/dist/src/agent/orchestration/llm-turn-retry.js +9 -1
  49. package/dist/src/agent/orchestration/llm-turn-retry.js.map +1 -1
  50. package/dist/src/agent/service/process-direct-streaming.js +19 -3
  51. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  52. package/dist/src/agent/service/webchat-tts.d.ts +1 -2
  53. package/dist/src/agent/service/webchat-tts.js +1 -1
  54. package/dist/src/agent/service/webchat-tts.js.map +1 -1
  55. package/dist/src/agent/service.js +2 -1
  56. package/dist/src/agent/service.js.map +1 -1
  57. package/dist/src/agent/service.types.d.ts +3 -1
  58. package/dist/src/agent/tools/cronjob-tool.js +2 -1
  59. package/dist/src/agent/tools/cronjob-tool.js.map +1 -1
  60. package/dist/src/agent/tools/factory.d.ts +3 -0
  61. package/dist/src/agent/tools/factory.js +2 -23
  62. package/dist/src/agent/tools/factory.js.map +1 -1
  63. package/dist/src/agent/tools/workflow-tool.d.ts +6 -28
  64. package/dist/src/agent/tools/workflow-tool.js +61 -213
  65. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  66. package/dist/src/agent/workflow/agent-progress.d.ts +5 -0
  67. package/dist/src/agent/workflow/agent-progress.js +65 -0
  68. package/dist/src/agent/workflow/agent-progress.js.map +1 -0
  69. package/dist/src/agent/workflow/builtins/audit-repo.d.ts +1 -1
  70. package/dist/src/agent/workflow/builtins/audit-repo.js +14 -0
  71. package/dist/src/agent/workflow/builtins/audit-repo.js.map +1 -1
  72. package/dist/src/agent/workflow/builtins/debug-incident.d.ts +1 -1
  73. package/dist/src/agent/workflow/builtins/debug-incident.js +14 -0
  74. package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -1
  75. package/dist/src/agent/workflow/builtins/implementation-plan.d.ts +12 -0
  76. package/dist/src/agent/workflow/builtins/implementation-plan.js +175 -0
  77. package/dist/src/agent/workflow/builtins/implementation-plan.js.map +1 -0
  78. package/dist/src/agent/workflow/builtins/index.d.ts +3 -1
  79. package/dist/src/agent/workflow/builtins/index.js +11 -1
  80. package/dist/src/agent/workflow/builtins/index.js.map +1 -1
  81. package/dist/src/agent/workflow/builtins/multi-perspective-review.d.ts +1 -1
  82. package/dist/src/agent/workflow/builtins/multi-perspective-review.js +14 -0
  83. package/dist/src/agent/workflow/builtins/multi-perspective-review.js.map +1 -1
  84. package/dist/src/agent/workflow/builtins/pr-review.d.ts +1 -1
  85. package/dist/src/agent/workflow/builtins/pr-review.js +14 -0
  86. package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -1
  87. package/dist/src/agent/workflow/builtins/release-check.d.ts +11 -0
  88. package/dist/src/agent/workflow/builtins/release-check.js +165 -0
  89. package/dist/src/agent/workflow/builtins/release-check.js.map +1 -0
  90. package/dist/src/agent/workflow/builtins/research.d.ts +1 -1
  91. package/dist/src/agent/workflow/builtins/research.js +14 -0
  92. package/dist/src/agent/workflow/builtins/research.js.map +1 -1
  93. package/dist/src/agent/workflow/index.d.ts +2 -1
  94. package/dist/src/agent/workflow/index.js +3 -2
  95. package/dist/src/agent/workflow/meta-locale.d.ts +12 -0
  96. package/dist/src/agent/workflow/meta-locale.js +62 -0
  97. package/dist/src/agent/workflow/meta-locale.js.map +1 -0
  98. package/dist/src/agent/workflow/parser.js +3 -0
  99. package/dist/src/agent/workflow/parser.js.map +1 -1
  100. package/dist/src/agent/workflow/runtime.d.ts +2 -2
  101. package/dist/src/agent/workflow/runtime.js +21 -14
  102. package/dist/src/agent/workflow/runtime.js.map +1 -1
  103. package/dist/src/agent/workflow/snapshot.js +2 -12
  104. package/dist/src/agent/workflow/snapshot.js.map +1 -1
  105. package/dist/src/agent/workflow/step-labels.d.ts +8 -0
  106. package/dist/src/agent/workflow/step-labels.js +48 -0
  107. package/dist/src/agent/workflow/step-labels.js.map +1 -0
  108. package/dist/src/agent/workflow/subagent-runner.js +46 -1
  109. package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
  110. package/dist/src/agent/workflow/types.d.ts +74 -1
  111. package/dist/src/agent/workflow/workflow-child-tools.d.ts +4 -0
  112. package/dist/src/agent/workflow/workflow-child-tools.js +21 -0
  113. package/dist/src/agent/workflow/workflow-child-tools.js.map +1 -0
  114. package/dist/src/auth/credentials.d.ts +19 -2
  115. package/dist/src/auth/credentials.js +47 -13
  116. package/dist/src/auth/credentials.js.map +1 -1
  117. package/dist/src/auth/oauth/types.d.ts +16 -0
  118. package/dist/src/cli/commands/auth.js +6 -0
  119. package/dist/src/cli/commands/auth.js.map +1 -1
  120. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  121. package/dist/src/cli/commands/onboard/model.js +6 -0
  122. package/dist/src/cli/commands/onboard/model.js.map +1 -1
  123. package/dist/src/config/agent-typed-models.d.ts +18 -0
  124. package/dist/src/config/agent-typed-models.js +53 -0
  125. package/dist/src/config/agent-typed-models.js.map +1 -0
  126. package/dist/src/config/index.js +2 -2
  127. package/dist/src/config/schema.d.ts +52 -0
  128. package/dist/src/config/schema.js +39 -3
  129. package/dist/src/config/schema.js.map +1 -1
  130. package/dist/src/config/voice.d.ts +3 -28
  131. package/dist/src/config/voice.js +27 -261
  132. package/dist/src/config/voice.js.map +1 -1
  133. package/dist/src/cron/executor.d.ts +2 -0
  134. package/dist/src/cron/executor.js +59 -5
  135. package/dist/src/cron/executor.js.map +1 -1
  136. package/dist/src/cron/job-content.js +2 -1
  137. package/dist/src/cron/job-content.js.map +1 -1
  138. package/dist/src/cron/types.d.ts +21 -1
  139. package/dist/src/cron/validation.d.ts +76 -0
  140. package/dist/src/cron/validation.js +26 -1
  141. package/dist/src/cron/validation.js.map +1 -1
  142. package/dist/src/gateway/agents-admin.d.ts +9 -0
  143. package/dist/src/gateway/agents-admin.js +16 -0
  144. package/dist/src/gateway/agents-admin.js.map +1 -1
  145. package/dist/src/gateway/config-tools-web.js +3 -2
  146. package/dist/src/gateway/config-tools-web.js.map +1 -1
  147. package/dist/src/gateway/gateway-workflow-host.types.d.ts +17 -0
  148. package/dist/src/gateway/gateway-workflow-host.types.js +1 -0
  149. package/dist/src/gateway/hono/lib/agent-model.d.ts +7 -0
  150. package/dist/src/gateway/hono/lib/agent-model.js +36 -1
  151. package/dist/src/gateway/hono/lib/agent-model.js.map +1 -1
  152. package/dist/src/gateway/hono/lib/config-payload.js +28 -5
  153. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  154. package/dist/src/gateway/hono/lib/mask-secret-length.d.ts +6 -0
  155. package/dist/src/gateway/hono/lib/mask-secret-length.js +16 -0
  156. package/dist/src/gateway/hono/lib/mask-secret-length.js.map +1 -0
  157. package/dist/src/gateway/hono/lib/safe-providers-config.d.ts +1 -1
  158. package/dist/src/gateway/hono/lib/safe-providers-config.js +2 -1
  159. package/dist/src/gateway/hono/lib/safe-providers-config.js.map +1 -1
  160. package/dist/src/gateway/hono/lib/safe-voice-config.js +2 -1
  161. package/dist/src/gateway/hono/lib/safe-voice-config.js.map +1 -1
  162. package/dist/src/gateway/hono/oauth-async.js +40 -15
  163. package/dist/src/gateway/hono/oauth-async.js.map +1 -1
  164. package/dist/src/gateway/hono/oauth.js +31 -6
  165. package/dist/src/gateway/hono/oauth.js.map +1 -1
  166. package/dist/src/gateway/hono/routes/agents.js +1 -1
  167. package/dist/src/gateway/hono/routes/config-patch/agents.js +8 -2
  168. package/dist/src/gateway/hono/routes/config-patch/agents.js.map +1 -1
  169. package/dist/src/gateway/hono/routes/config-patch/gateway.js +3 -2
  170. package/dist/src/gateway/hono/routes/config-patch/gateway.js.map +1 -1
  171. package/dist/src/gateway/hono/routes/config-patch/misc.js +7 -2
  172. package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
  173. package/dist/src/gateway/hono/routes/config.js +59 -0
  174. package/dist/src/gateway/hono/routes/config.js.map +1 -1
  175. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  176. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  177. package/dist/src/gateway/hono/routes/models.js +84 -15
  178. package/dist/src/gateway/hono/routes/models.js.map +1 -1
  179. package/dist/src/gateway/hono/routes/voice.js +75 -0
  180. package/dist/src/gateway/hono/routes/voice.js.map +1 -1
  181. package/dist/src/gateway/hono/routes/workflows.d.ts +3 -0
  182. package/dist/src/gateway/hono/routes/workflows.js +226 -0
  183. package/dist/src/gateway/hono/routes/workflows.js.map +1 -0
  184. package/dist/src/gateway/service/run-gateway-agent.js +2 -20
  185. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  186. package/dist/src/gateway/service.d.ts +8 -0
  187. package/dist/src/gateway/service.js +28 -2
  188. package/dist/src/gateway/service.js.map +1 -1
  189. package/dist/src/mcp/channel-bridge.js +1 -1
  190. package/dist/src/providers/index.d.ts +8 -0
  191. package/dist/src/providers/index.js +51 -12
  192. package/dist/src/providers/index.js.map +1 -1
  193. package/dist/src/share/site-share-config.d.ts +3 -2
  194. package/dist/src/share/site-share-config.js.map +1 -1
  195. package/dist/src/tui/tui-agent-events.js +2 -1
  196. package/dist/src/tui/tui-agent-events.js.map +1 -1
  197. package/dist/src/voice/metadata/builtin.d.ts +2 -0
  198. package/dist/src/voice/metadata/builtin.js +420 -0
  199. package/dist/src/voice/metadata/builtin.js.map +1 -0
  200. package/dist/src/voice/metadata/index.d.ts +4 -0
  201. package/dist/src/voice/metadata/index.js +3 -0
  202. package/dist/src/voice/metadata/registry.d.ts +5 -0
  203. package/dist/src/voice/metadata/registry.js +34 -0
  204. package/dist/src/voice/metadata/registry.js.map +1 -0
  205. package/dist/src/voice/metadata/types.d.ts +41 -0
  206. package/dist/src/voice/metadata/types.js +1 -0
  207. package/dist/src/voice/stt/list-providers.d.ts +3 -3
  208. package/dist/src/voice/stt/list-providers.js +41 -6
  209. package/dist/src/voice/stt/list-providers.js.map +1 -1
  210. package/dist/src/voice/tts/list-providers.d.ts +3 -3
  211. package/dist/src/voice/tts/list-providers.js +41 -6
  212. package/dist/src/voice/tts/list-providers.js.map +1 -1
  213. package/dist/src/workflows/domain/command.d.ts +19 -0
  214. package/dist/src/workflows/domain/command.js +1 -0
  215. package/dist/src/workflows/domain/definition-utils.d.ts +14 -0
  216. package/dist/src/workflows/domain/definition-utils.js +50 -0
  217. package/dist/src/workflows/domain/definition-utils.js.map +1 -0
  218. package/dist/src/workflows/domain/definition.d.ts +62 -0
  219. package/dist/src/workflows/domain/definition.js +1 -0
  220. package/dist/src/workflows/domain/event.d.ts +67 -0
  221. package/dist/src/workflows/domain/event.js +1 -0
  222. package/dist/src/workflows/domain/index.d.ts +7 -0
  223. package/dist/src/workflows/domain/index.js +4 -0
  224. package/dist/src/workflows/domain/result.d.ts +65 -0
  225. package/dist/src/workflows/domain/result.js +1 -0
  226. package/dist/src/workflows/domain/run.d.ts +177 -0
  227. package/dist/src/workflows/domain/run.js +14 -0
  228. package/dist/src/workflows/domain/run.js.map +1 -0
  229. package/dist/src/workflows/domain/validation.d.ts +19 -0
  230. package/dist/src/workflows/domain/validation.js +66 -0
  231. package/dist/src/workflows/domain/validation.js.map +1 -0
  232. package/dist/src/workflows/engine/index.d.ts +2 -0
  233. package/dist/src/workflows/engine/index.js +3 -0
  234. package/dist/src/workflows/engine/projector.d.ts +3 -0
  235. package/dist/src/workflows/engine/projector.js +205 -0
  236. package/dist/src/workflows/engine/projector.js.map +1 -0
  237. package/dist/src/workflows/engine/workflow-engine.d.ts +32 -0
  238. package/dist/src/workflows/engine/workflow-engine.js +189 -0
  239. package/dist/src/workflows/engine/workflow-engine.js.map +1 -0
  240. package/dist/src/workflows/index.d.ts +10 -0
  241. package/dist/src/workflows/index.js +18 -0
  242. package/dist/src/workflows/runtime/index.d.ts +1 -0
  243. package/dist/src/workflows/runtime/index.js +4 -0
  244. package/dist/src/workflows/runtime/script-runtime.d.ts +3 -0
  245. package/dist/src/workflows/runtime/script-runtime.js +3 -0
  246. package/dist/src/workflows/service/run-view-to-snapshot.d.ts +4 -0
  247. package/dist/src/workflows/service/run-view-to-snapshot.js +61 -0
  248. package/dist/src/workflows/service/run-view-to-snapshot.js.map +1 -0
  249. package/dist/src/workflows/service/workflow-run-service.d.ts +36 -0
  250. package/dist/src/workflows/service/workflow-run-service.js +279 -0
  251. package/dist/src/workflows/service/workflow-run-service.js.map +1 -0
  252. package/dist/src/workflows/service/workflow-run-service.types.d.ts +47 -0
  253. package/dist/src/workflows/service/workflow-run-service.types.js +1 -0
  254. package/dist/src/workflows/service/workflow-session-bridge.d.ts +29 -0
  255. package/dist/src/workflows/service/workflow-session-bridge.js +177 -0
  256. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -0
  257. package/dist/src/workflows/service/workflow-session-key.d.ts +3 -0
  258. package/dist/src/workflows/service/workflow-session-key.js +21 -0
  259. package/dist/src/workflows/service/workflow-session-key.js.map +1 -0
  260. package/dist/src/workflows/store/event-store.d.ts +17 -0
  261. package/dist/src/workflows/store/event-store.js +83 -0
  262. package/dist/src/workflows/store/event-store.js.map +1 -0
  263. package/dist/src/workflows/store/paths.d.ts +7 -0
  264. package/dist/src/workflows/store/paths.js +26 -0
  265. package/dist/src/workflows/store/paths.js.map +1 -0
  266. package/dist/src/workflows/store/run-store.d.ts +13 -0
  267. package/dist/src/workflows/store/run-store.js +69 -0
  268. package/dist/src/workflows/store/run-store.js.map +1 -0
  269. package/package.json +5 -5
  270. package/dist/gateway/static/root/assets/agents-BEAbXpuP.js +0 -222
  271. package/dist/gateway/static/root/assets/apps-page-Dg8R-Szf.js +0 -1
  272. package/dist/gateway/static/root/assets/channels-settings-yohw9YSu.js +0 -1
  273. package/dist/gateway/static/root/assets/cron-api-0h_QT8U3.js +0 -1
  274. package/dist/gateway/static/root/assets/cron-page-BkfKFfFk.js +0 -1
  275. package/dist/gateway/static/root/assets/extension-settings-page-x4BB7q1X.js +0 -1
  276. package/dist/gateway/static/root/assets/index-a5gWIdZQ.css +0 -1
  277. package/dist/gateway/static/root/assets/logs-page-BFZ8GgCv.js +0 -1
  278. package/dist/gateway/static/root/assets/sessions-page-CD7AfB-2.js +0 -1
  279. package/dist/gateway/static/root/assets/settings-page-BBOjEQW3.js +0 -3
  280. package/dist/gateway/static/root/assets/skills-page-CcN_gj--.js +0 -2
  281. package/dist/gateway/static/root/assets/url-Dd8Q7kZZ.js +0 -3
  282. package/dist/gateway/static/root/assets/voice-api-key-field-O6awz9hi.js +0 -1
@@ -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-Dd8Q7kZZ.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,i as u,n as d,o as f,r as p,s as m}from"./dist-BTWC-BTN.js";import{a as h,n as g,t as _}from"./fetch-DRqwef_Q.js";import{Bn as v,Bt as y,Cn as b,Dn as x,En as S,Hi as C,Ji as w,Jr as T,Mr as E,N as D,Ti as O,Tn as k,Vr as A,da as j,ii as M,ir as N,kr as P,nr as F,oa as I,pr as L,s as R,ta as ee,tr as z,wn as B}from"./index-Cu7bKuUi.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 _(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 _(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 _(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 _(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=h(e=>!!e.token),r=B(),{mutate:l}=s(),[u,d]=(0,V.useReducer)(R,X),{q:f,debounced:p,detailPkg:m,rowBusy:_,actionError:v,restartHint:y}=u,b=n?`marketplace-${p}`:null;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>d({type:`patch`,patch:{debounced:f.trim()}}),300);return()=>window.clearTimeout(e)},[f]);let{data:x,isLoading:S,error:w}=c(b,async()=>g(p.length>0?o(`/api/marketplace?q=${encodeURIComponent(p)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),O=(0,V.useCallback)(()=>{l(`gateway-extensions-list`),D()},[l]),k=(0,V.useCallback)(async(e,n)=>{d({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await G({name:e,overwrite:n});O(),r.requiresGatewayRestart&&d({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw d({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{d({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,O]),A=(0,V.useCallback)(async e=>{d({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await q(e);O(),n.requiresGatewayRestart&&d({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw d({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{d({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,O]),j=x?.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)(E,{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:f,onChange:e=>d({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`})]}),w?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w instanceof Error?w.message:t.marketplaceLoadFailed}):null,v?(0,J.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v}):null,y?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y}):null,S&&!x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:j.length===0?(0,J.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):j.map(e=>{let n=Y(r,e.id),i=_===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:()=>d({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d({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)(C,{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)(T,{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)&&A(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)(M,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(L,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{k(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)(M,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),m?(0,J.jsx)(re,{packageName:m,copy:t,extensions:r,onClose:()=>d({type:`patch`,patch:{detailPkg:null}}),onInstall:k,onUninstall:A}):null]})}function re(e){let t=(0,H.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[p,g]=(0,V.useState)(!1),_=h(se)?`ext-mp-detail-${n}`:null,v;t[0]===n?v=t[1]:(v=async()=>te(n),t[0]=n,t[1]=v);let b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b={revalidateOnFocus:!1},t[2]=b):b=t[2];let{data:x,error:S,isLoading:C}=c(_,v,b),w;t[3]!==i||t[4]!==n?(w=Y(i,n),t[3]=i,t[4]=n,t[5]=w):w=t[5];let T=w,E=T===`user`,D;t[6]!==r.marketplaceNoReadme||t[7]!==x?(D=x?.readme?.trim()||(x?.description?.trim()?`### ${x.name}\n\n${x.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=x,t[8]=D):D=t[8];let O=D,k;t[9]===a?k=t[10]:(k=e=>!e&&a(),t[9]=a,t[10]=k);let A;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,J.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=A):A=t[11];let j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,J.jsx)(ee,{className:`size-5`}),t[12]=j):j=t[12];let P;t[13]!==r.detailBack||t[14]!==a?(P=(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:j}),t[13]=r.detailBack,t[14]=a,t[15]=P):P=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,J.jsx)(m,{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)(N,{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]!==P||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:[P,R,B]}),t[22]=B,t[23]=P,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]!==x||t[32]!==S||t[33]!==C||t[34]!==O?(W=C&&!x?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):S?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):x?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:x.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:x.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:x.author.username})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,J.jsx)(`dd`,{children:x.latestVersion.version})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,J.jsx)(`dd`,{children:x.downloads})]})]}),x.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)(y,{content:O})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=x,t[32]=S,t[33]=C,t[34]=O,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]!==p||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]!==x||t[47]!==T||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==E?(K=x?(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)(I,{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:p,onClick:()=>{E&&!window.confirm(r.marketplaceReinstallConfirm)||(g(!0),o(n,E).catch(ae).finally(()=>g(!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:[p?(0,J.jsx)(M,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,E?r.marketplaceReinstall:r.marketplaceInstall]}),E?(0,J.jsxs)(`button`,{type:`button`,disabled:p,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(g(!0),s(n).then(()=>a()).catch(ie).finally(()=>g(!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)(L,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=p,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]=x,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)(l,{children:[A,(0,J.jsxs)(d,{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]!==k?(X=(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:k,children:q}),t[58]=q,t[59]=k,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=v(e=>e.setPageHeader),r=v(e=>e.clearPageHeader),o=B(),s=k(),[c,l]=j(),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),y=c.toString(),b=(0,V.useRef)(y);if(b.current!==y){b.current=y;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 x=(0,V.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),S=(0,V.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),C=f===`builtin`?x:S,w=(0,V.useMemo)(()=>{let t=m.trim().toLowerCase(),n=C;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)},[C,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:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,J.jsx)(`h1`,{className:`min-w-0 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 T=f!==`marketplace`&&C.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)(`header`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.appsPage.title}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.appsPage.subtitle})]}),(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:[`(`,x.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:[`(`,S.length,`)`]})]})]}),T?(0,J.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,J.jsx)(E,{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`&&x.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&S.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyUser}):w.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:w.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)(w,{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)(A,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==r.cardNoDescription||t[21]!==n.description?(v=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=v):v=t[22];let y;t[23]===v?y=t[24]:(y=(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:v}),t[23]=v,t[24]=y);let b=n.hasUi?r.badgeKindUi:r.badgeKindBackend,x;t[25]!==b||t[26]!==c?(x=(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:b}),t[25]=b,t[26]=c,t[27]=x):x=t[27];let S;t[28]!==r||t[29]!==n||t[30]!==i?(S=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]=S):S=t[31];let C;t[32]!==x||t[33]!==S?(C=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[x,S]}),t[32]=x,t[33]=S,t[34]=C):C=t[34];let T;t[35]!==_||t[36]!==y||t[37]!==C?(T=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,y,C]}),t[35]=_,t[36]=y,t[37]=C,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),[h,g]=(0,V.useState)(!1),_=e.activationEligible===!0,v=(0,V.useCallback)(async()=>{if(e.source===`bundled`){c(null),g(!1),a(!0);try{let{requiresGatewayRestart:t}=await K({extensionId:e.id,enabled:!_});await r(`gateway-extensions-list`),D(),g(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[_,t.builtinToggleFailed,e.id,e.source,r]),y=e.ui?.contributions?.pages??[],C=e.ui?.contributions?.settingsPanels??[],w=e.ui?.contributions?.chatWidgets??[],T=e.ui?.contributions?.sidebarPanels??[],E=y.find(e=>e.showInNav)??y[0],k=C[0],A=E?b(e.id,E):null,j=k?`/settings/ext/${e.id}/${k.id}`:e.hasConfigSchema||S(e)?`/settings/ext/${e.id}`:null;return(0,J.jsx)(f,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(l,{children:[(0,J.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,J.jsxs)(d,{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)(ee,{className:`size-5`})}),(0,J.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,J.jsxs)(p,{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)(N,{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)(z,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void v(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(M,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):_?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,h?(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&&(y.length>0||C.length>0||w.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:y.length,hidden:y.length===0}),(0,J.jsx)($,{template:t.badgeSettings,count:C.length,hidden:C.length===0}),(0,J.jsx)($,{template:t.badgeWidgets,count:w.length,hidden:w.length===0}),(0,J.jsx)($,{template:t.badgeSidebar,count:T.length,hidden:T.length===0})]})]}):null,x(e)&&(A||j)?(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[A?(0,J.jsxs)(I,{to:A,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)(O,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,j?(0,J.jsxs)(I,{to:j,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)(P,{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-Dd8Q7kZZ.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{a as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./dist-BTWC-BTN.js";import{a as h,n as g}from"./fetch-DRqwef_Q.js";import{Ai as _,Bn as v,Ci as y,F as b,Gt as x,Ji as S,On as C,Rr as w,Rt as T,Sn as E,Ti as D,Wn as O,Zn as k,_n as A,ct as j,da as M,g as N,h as P,ir as F,la as I,lt as L,mn as R,nr as z,qi as ee,st as B,tr as V,ua as H,ut as U,wi as te,zt as W}from"./index-Cu7bKuUi.js";import{a as G,c as ne,i as K,o as re,r as q,s as ie,t as J}from"./utils-CkWBfxs4.js";import{n as Y,r as ae,t as oe}from"./field-primitives-BiNHBo2Y.js";import{_ as se,a as ce,c as le,d as ue,f as de,g as fe,h as pe,i as me,l as he,m as ge,n as _e,o as ve,p as ye,r as be,s as xe,t as X,u as Se,v as Ce,y as we}from"./channels-status-swr-BSHqqCF1.js";var Z=e(t(),1),Q=n(),$=r();function Te(e){switch(e){case`running`:return`bg-success-soft text-success`;case`offline`:return`bg-amber-100 text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`;case`disabled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Ee(e,t){switch(t){case`running`:return e.hubStatusRunning;case`offline`:return e.hubStatusOffline;case`disabled`:return e.hubStatusDisabled;default:return e.hubStatusNotConfigured}}function De(e,t){switch(t){case`setup`:return e.hubSetupButton;case`fix`:return e.hubFixButton;case`pairing`:return e.hubPairingButton;default:return e.hubManageButton}}function Oe(e){let t=(0,Q.c)(62),{channelId:n,title:r,subtitle:i,vm:a,toggleDisabled:o,onOpen:s,onReviewPairing:c,onToggle:l,ch:u}=e,d=a.configured&&a.manageable,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=z(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),t[0]=f):f=t[0];let p=a.status===`running`?`bg-accent-soft`:`bg-surface-base`,m;t[1]===p?m=t[2]:(m=z(`flex size-11 shrink-0 items-center justify-center rounded-xl ring-1 ring-edge-subtle/40`,p),t[1]=p,t[2]=m);let h;t[3]===n?h=t[4]:(h=(0,$.jsx)(E,{sourceChannel:n,className:`size-5`}),t[3]=n,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,$.jsx)(`div`,{className:m,"aria-hidden":!0,children:h}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===r?_=t[9]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[8]=r,t[9]=_);let v;t[10]===a.status?v=t[11]:(v=z(`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium`,Te(a.status)),t[10]=a.status,t[11]=v);let y;t[12]!==u||t[13]!==a.status?(y=Ee(u,a.status),t[12]=u,t[13]=a.status,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,$.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==u||t[19]!==c||t[20]!==a.pendingPairing?(x=a.pendingPairing>0?(0,$.jsx)(`button`,{type:`button`,className:z(`inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,W.press),onClick:e=>{e.stopPropagation(),c()},children:u.hubPairingPendingBadge.replace(`{{count}}`,String(a.pendingPairing))}):null,t[18]=u,t[19]=c,t[20]=a.pendingPairing,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==_?(C=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,S]}),t[25]=S,t[26]=_,t[27]=C):C=t[27];let w;t[28]!==u||t[29]!==l||t[30]!==d||t[31]!==r||t[32]!==o||t[33]!==a.enabled?(w=d?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a.enabled,"aria-label":`${r} — ${u.enableChannelAria}`,disabled:o,className:z(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,W.press,a.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:e=>{e.stopPropagation(),l(!a.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,t[28]=u,t[29]=l,t[30]=d,t[31]=r,t[32]=o,t[33]=a.enabled,t[34]=w):w=t[34];let T;t[35]!==C||t[36]!==w||t[37]!==g?(T=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,C,w]}),t[35]=C,t[36]=w,t[37]=g,t[38]=T):T=t[38];let D;t[39]===i?D=t[40]:(D=(0,$.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:i}),t[39]=i,t[40]=D);let O;t[41]===a.summaryLines?O=t[42]:(O=a.summaryLines.length>0?(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5`,children:a.summaryLines.map(ke)}):null,t[41]=a.summaryLines,t[42]=O);let k;t[43]!==D||t[44]!==O?(k=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O]}),t[43]=D,t[44]=O,t[45]=k):k=t[45];let A;t[46]!==s||t[47]!==c||t[48]!==a.manageable||t[49]!==a.pendingPairing||t[50]!==a.primaryAction?(A=()=>{if(a.manageable&&(a.primaryAction===`pairing`||a.pendingPairing>0)){c();return}s()},t[46]=s,t[47]=c,t[48]=a.manageable,t[49]=a.pendingPairing,t[50]=a.primaryAction,t[51]=A):A=t[51];let j;t[52]!==u||t[53]!==a.primaryAction?(j=De(u,a.primaryAction),t[52]=u,t[53]=a.primaryAction,t[54]=j):j=t[54];let M;t[55]!==A||t[56]!==j?(M=(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(V,{type:`button`,variant:`primary`,className:`w-full`,onClick:A,children:j})}),t[55]=A,t[56]=j,t[57]=M):M=t[57];let N;return t[58]!==T||t[59]!==k||t[60]!==M?(N=(0,$.jsxs)(`article`,{className:f,children:[T,k,M]}),t[58]=T,t[59]=k,t[60]=M,t[61]=N):N=t[61],N}function ke(e){return(0,$.jsx)(`li`,{className:`text-xs text-fg-muted`,children:e},e)}function Ae(e){let t=(0,Q.c)(17),{catalog:n,cards:r,ch:i,saving:a,onOpenChannel:o,onToggleChannel:s}=e,c;t[0]===r?c=t[1]:(c=new Map(r.map(je)),t[0]=r,t[1]=c);let l=c,u;if(t[2]!==l||t[3]!==n||t[4]!==i||t[5]!==o||t[6]!==s||t[7]!==a){let e;t[9]!==l||t[10]!==i||t[11]!==o||t[12]!==s||t[13]!==a?(e=e=>{let t=l.get(e.id);return t?(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Oe,{channelId:e.id,title:e.title,subtitle:e.subtitle,vm:t,toggleDisabled:a||!t.manageable,onOpen:()=>o(e.id),onReviewPairing:()=>o(e.id,{scrollToPairing:!0}),onToggle:t=>s(e.id,t),ch:i})},e.id):null},t[9]=l,t[10]=i,t[11]=o,t[12]=s,t[13]=a,t[14]=e):e=t[14],u=n.map(e),t[2]=l,t[3]=n,t[4]=i,t[5]=o,t[6]=s,t[7]=a,t[8]=u}else u=t[8];let d;return t[15]===u?d=t[16]:(d=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,role:`list`,children:u}),t[15]=u,t[16]=d),d}function je(e){return[e.id,e]}var Me=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Ne(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:z(`size-11 shrink-0 rounded-xl`,Me)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:z(`h-4 w-2/5`,Me)}),(0,$.jsx)(`div`,{className:z(`h-5 w-16 rounded-full`,Me)})]}),(0,$.jsx)(`div`,{className:z(`h-6 w-10 shrink-0 rounded-full`,Me)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:z(`h-3 w-full`,Me)}),(0,$.jsx)(`div`,{className:z(`h-3 w-[88%]`,Me)})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-[13.5rem] flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm dark:border-edge-subtle`,"aria-hidden":!0,children:[n,r,(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(`div`,{className:z(`h-10 w-full rounded-lg`,Me)})})]}),e[3]=i):i=e[3],i}function Pe(e){let t=(0,Q.c)(2),{count:n}=e,r=n===void 0?3:n,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,"aria-busy":!0,children:Array.from({length:r},Fe)}),t[0]=r,t[1]=i),i}function Fe(e,t){return(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Ne,{})},t)}function Ie(e,t=!1){return e===`drawer`?z(`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`,P):z(`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)]`,P,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Le(e){let t=(0,Q.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:h,closeAriaLabel:g,children:_,footer:v,wide:y,headerExtra:b}=e,x=y===void 0?!1:y,S=n===`drawer`,C;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(l,{className:z(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),t[0]=C):C=t[0];let w;t[1]!==n||t[2]!==x?(w=Ie(n,x),t[1]=n,t[2]=x,t[3]=w):w=t[3];let E;t[4]===s?E=t[5]:(E=s?(0,$.jsx)(p,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=E);let D;t[6]===h?D=t[7]:(D=h?(0,$.jsx)(f,{className:`sr-only`,children:h}):null,t[6]=h,t[7]=D);let O;t[8]!==g||t[9]!==o||t[10]!==b||t[11]!==S||t[12]!==a?(O=S?(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:[a?(0,$.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,$.jsx)(m,{asChild:!0,children:(0,$.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":g,children:(0,$.jsx)(F,{className:`size-5`,strokeWidth:1.75})})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:z(T,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":g,children:(0,$.jsx)(F,{className:`size-4`})})}),b]}),t[8]=g,t[9]=o,t[10]=b,t[11]=S,t[12]=a,t[13]=O):O=t[13];let k=S?`px-4 py-4`:`p-6`,A;t[14]===k?A=t[15]:(A=z(`min-h-0 flex-1 overflow-y-auto`,k),t[14]=k,t[15]=A);let j;t[16]!==_||t[17]!==A?(j=(0,$.jsx)(`div`,{className:A,children:_}),t[16]=_,t[17]=A,t[18]=j):j=t[18];let M;t[19]!==v||t[20]!==w||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==j?(M=(0,$.jsxs)(c,{children:[C,(0,$.jsxs)(u,{className:w,onOpenAutoFocus:Re,children:[E,D,O,j,v]})]}),t[19]=v,t[20]=w,t[21]=E,t[22]=D,t[23]=O,t[24]=j,t[25]=M):M=t[25];let P;return t[26]!==i||t[27]!==r||t[28]!==M?(P=(0,$.jsx)(d,{open:r,onOpenChange:i,children:M}),t[26]=i,t[27]=r,t[28]=M,t[29]=P):P=t[29],P}function Re(e){return e.preventDefault()}function ze(e){let t=(0,Q.c)(52),{open:n,onOpenChange:r,entry:i,vm:a,ch:o,language:s}=e,c=a.status===`running`?o.hubStatusRunning:a.status===`offline`?o.hubStatusOffline:a.status===`disabled`?o.hubStatusDisabled:o.hubStatusNotConfigured,l=i.title,u=i.subtitle,d=o.modalCancel,f;t[0]===i.title?f=t[1]:(f=(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.title}),t[0]=i.title,t[1]=f);let p;t[2]===i.subtitle?p=t[3]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),t[2]=i.subtitle,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===o.hubExtensionManageHint?h=t[8]:(h=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hubExtensionManageHint}),t[7]=o.hubExtensionManageHint,t[8]=h);let g;t[9]===o.hubExtensionStatusLabel?g=t[10]:(g=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionStatusLabel}),t[9]=o.hubExtensionStatusLabel,t[10]=g);let _;t[11]===c?_=t[12]:(_=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:c}),t[11]=c,t[12]=_);let v;t[13]!==g||t[14]!==_?(v=(0,$.jsxs)(`div`,{children:[g,_]}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===o.hubExtensionEnabledLabel?y=t[17]:(y=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionEnabledLabel}),t[16]=o.hubExtensionEnabledLabel,t[17]=y);let b=a.enabled?o.hubExtensionYes:o.hubExtensionNo,x;t[18]===b?x=t[19]:(x=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:b}),t[18]=b,t[19]=x);let S;t[20]!==y||t[21]!==x?(S=(0,$.jsxs)(`div`,{children:[y,x]}),t[20]=y,t[21]=x,t[22]=S):S=t[22];let C;t[23]===o.hubExtensionConnectedLabel?C=t[24]:(C=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionConnectedLabel}),t[23]=o.hubExtensionConnectedLabel,t[24]=C);let w=a.connected?o.hubExtensionYes:o.hubExtensionNo,T;t[25]===w?T=t[26]:(T=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:w}),t[25]=w,t[26]=T);let E;t[27]!==C||t[28]!==T?(E=(0,$.jsxs)(`div`,{children:[C,T]}),t[27]=C,t[28]=T,t[29]=E):E=t[29];let k;t[30]!==v||t[31]!==S||t[32]!==E?(k=(0,$.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[v,S,E]}),t[30]=v,t[31]=S,t[32]=E,t[33]=k):k=t[33];let A;t[34]===s?A=t[35]:(A=O(s,`channels`),t[34]=s,t[35]=A);let j;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(D,{className:`ml-2 size-3.5`}),t[36]=j):j=t[36];let M;t[37]!==o.hubViewDocs||t[38]!==A?(M=(0,$.jsx)(V,{type:`button`,variant:`secondary`,asChild:!0,children:(0,$.jsxs)(`a`,{href:A,target:`_blank`,rel:`noreferrer`,children:[o.hubViewDocs,j]})}),t[37]=o.hubViewDocs,t[38]=A,t[39]=M):M=t[39];let N;t[40]!==k||t[41]!==M||t[42]!==h?(N=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,k,M]}),t[40]=k,t[41]=M,t[42]=h,t[43]=N):N=t[43];let P;return t[44]!==o.modalCancel||t[45]!==i.subtitle||t[46]!==i.title||t[47]!==r||t[48]!==n||t[49]!==N||t[50]!==m?(P=(0,$.jsx)(Le,{presentation:`modal`,open:n,onOpenChange:r,srTitle:l,srDescription:u,closeAriaLabel:d,headerExtra:m,children:N}),t[44]=o.modalCancel,t[45]=i.subtitle,t[46]=i.title,t[47]=r,t[48]=n,t[49]=N,t[50]=m,t[51]=P):P=t[51],P}var Be=(0,Z.memo)(function(e){let t=(0,Q.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,$.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=z(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(w,{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,$.jsx)(V,{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,$.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 Ve(e){let t=(0,Q.c)(27),{accountIds:n,routes:r,defaultAgentId:o,agentItems:s,disabled:c,onChange:l,ch:u}=e,d=i(He),f,p,m,h,g;if(t[0]!==n||t[1]!==s||t[2]!==u||t[3]!==o||t[4]!==c||t[5]!==d||t[6]!==l||t[7]!==r){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a(d).agentsSettings;if(n.length===0){g=null;break bb0}let i=s.length>0?s:[{id:o}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let _;t[13]===u.agentRoutingTitle?_=t[14]:(_=(0,$.jsx)(Y,{children:u.agentRoutingTitle}),t[13]=u.agentRoutingTitle,t[14]=_);let v;t[15]===u.agentRoutingHint?v=t[16]:(v=(0,$.jsx)(oe,{children:u.agentRoutingHint}),t[15]=u.agentRoutingHint,t[16]=v),t[17]!==_||t[18]!==v?(h=(0,$.jsxs)(`div`,{children:[_,v]}),t[17]=_,t[18]=v,t[19]=h):h=t[19],f=`space-y-2`,p=n.map(t=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.agentRoutingAccountLabel}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:u.agentRoutingAgentLabel}),(0,$.jsx)(`select`,{id:`agent-route-${t}`,className:z(J(),k),disabled:c,value:(r[t]??o).toLowerCase(),onChange:e=>l(t,e.target.value),children:i.map(t=>(0,$.jsx)(`option`,{value:t.id,children:`${b(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=s,t[2]=u,t[3]=o,t[4]=c,t[5]=d,t[6]=l,t[7]=r,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[20]!==f||t[21]!==p?(_=(0,$.jsx)(`div`,{className:f,children:p}),t[20]=f,t[21]=p,t[22]=_):_=t[22];let v;return t[23]!==m||t[24]!==h||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,_]}),t[23]=m,t[24]=h,t[25]=_,t[26]=v):v=t[26],v}function He(e){return e.language}function Ue(e){return e===`telegram`?`pairing`:`open`}function We(e,t,n){return n?.dmPolicy?n.dmPolicy:t??Ue(e)}function Ge(e,t){if(e===`telegram`){let e=Ce(t);return e.length>0?e:[`default`]}if(e===`weixin`){let e=we(t);return e.length>0?e:[`default`]}let n=se(t);return n.length>0?n:[`default`]}function Ke(e){return e?.enabled!==!1}function qe(e,t,n){let r=t.accounts?.[n];return We(e,t.dmPolicy,r)}function Je(e,t){return Ge(e,t).some(n=>{let r=t.accounts?.[n];return Ke(r)?qe(e,t,n)===`pairing`:!1})}function Ye(e){return!e.configured||!e.channelEnabled||!e.usesPairing?0:e.summaryPending}function Xe(e){let{channel:t,accountId:n,messages:r,mutate:i,setCodeBySender:a,setBusySender:o,setFeedback:s}=e,c=(0,Z.useCallback)(async(e,t)=>{o(e),s(null);try{let n=await t();a(t=>{let n={...t};return delete n[e],n}),s({kind:`ok`,text:r.pairingApproved.replace(`{{id}}`,n.senderId)}),await i()}catch(e){let t=e instanceof Error?e.message:r.pairingInvalid;s({kind:`err`,text:t.includes(`PAIRING`)?r.pairingInvalid:t})}finally{o(null)}},[r.pairingApproved,r.pairingInvalid,i,o,a,s]);return{approveByCode:(0,Z.useCallback)((e,r)=>{let i=r.trim().toUpperCase();i&&c(e,()=>ce({channel:t,accountId:n,code:i}))},[n,t,c]),quickApprove:(0,Z.useCallback)(e=>{c(e,()=>me({channel:t,accountId:n,senderId:e}))},[n,t,c])}}var Ze=[`channels-pairing-requested`,`channels-pairing-refreshed`,`channels-pairing-approved`,`channels-pairing-revoked`,`channels-pairing-dismissed`],Qe=`channel-pairing-summary`;function $e(e){let t=()=>e();for(let e of Ze)window.addEventListener(e,t);return()=>{for(let e of Ze)window.removeEventListener(e,t)}}function et(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return $e(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}function tt(e){return`channel-pairing-${e}`}function nt(e){requestAnimationFrame(()=>{document.getElementById(tt(e))?.scrollIntoView({behavior:`smooth`,block:`start`})})}function rt(e,t){let n=Date.parse(e)-Date.now();if(!Number.isFinite(n))return e;let r=Math.max(1,Math.round(Math.abs(n)/6e4));if(n<=0)return t.startsWith(`zh`)?`已过期`:`expired`;if(r<60)return t.startsWith(`zh`)?`${r} 分钟后`:`in ${r} min`;let i=Math.round(r/60);return t.startsWith(`zh`)?`${i} 小时后`:`in ${i} h`}function it(e,t){return`channel-pairing-${e}-${t}`}var at={codeBySender:{},busySender:null,dismissingId:null,revokingId:null,feedback:null};function ot(e,t){switch(t.type){case`setCodeBySender`:return{...e,codeBySender:t.updater(e.codeBySender)};case`setBusySender`:return{...e,busySender:t.value};case`setDismissingId`:return{...e,dismissingId:t.value};case`setRevokingId`:return{...e,revokingId:t.value};case`setFeedback`:return{...e,feedback:t.value};case`clearSenderCode`:{let n={...e.codeBySender};return delete n[t.senderId],{...e,codeBySender:n}}}}function st({channel:e,accountIds:t,channelConfig:n,active:r,ch:i,language:a,onPairedChange:o}){let c=J,l=(0,Z.useMemo)(()=>{let e=(t??[`default`]).filter(Boolean);return e.length>0?e:[`default`]},[t]),u=(0,Z.useMemo)(()=>Je(e,n),[e,n]),d=(0,Z.useCallback)(t=>qe(e,n,t),[e,n]),[f,p]=(0,Z.useState)(l[0]??`default`),[m,h]=(0,Z.useState)(l);l!==m&&(h(l),l.includes(f)||p(l[0]??`default`));let[g,_]=(0,Z.useReducer)(ot,at),{codeBySender:v,busySender:y,dismissingId:b,revokingId:x,feedback:S}=g,C=d(f)===`pairing`,T=(0,Z.useRef)(o);T.current=o;let{data:E,error:D,isLoading:O,mutate:k}=s(r&&u&&C?it(e,f):null,()=>le(e,f),{revalidateOnFocus:!0,onSuccess:e=>{T.current?.(e.paired.fromCredentials.length)}});et((0,Z.useCallback)(()=>{k()},[k]),r&&u&&C);let A=E?.paired.fromCredentials??[],j=(0,Z.useCallback)(e=>{_({type:`setCodeBySender`,updater:typeof e==`function`?e:()=>e})},[]),M=(0,Z.useCallback)(e=>{_({type:`setBusySender`,value:typeof e==`function`?e(g.busySender):e})},[g.busySender]),N=(0,Z.useCallback)(e=>{_({type:`setFeedback`,value:typeof e==`function`?e(g.feedback):e})},[g.feedback]),{approveByCode:P,quickApprove:I}=Xe({channel:e,accountId:f,messages:{pairingApproved:i.pairingApproved,pairingInvalid:i.pairingInvalid},mutate:k,setCodeBySender:j,setBusySender:M,setFeedback:N}),L=(0,Z.useCallback)(async t=>{_({type:`setDismissingId`,value:t}),_({type:`setFeedback`,value:null});try{await ve({channel:e,accountId:f,senderId:t}),_({type:`clearSenderCode`,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingDismissed.replace(`{{id}}`,t)}}),await k()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingDismissError}})}finally{_({type:`setDismissingId`,value:null})}},[f,e,i.pairingDismissed,i.pairingDismissError,k]),R=(0,Z.useCallback)(async t=>{_({type:`setRevokingId`,value:t}),_({type:`setFeedback`,value:null});try{await fe({channel:e,accountId:f,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingRevoked.replace(`{{id}}`,t)}}),await k()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingRevokeError}})}finally{_({type:`setRevokingId`,value:null})}},[f,e,i.pairingRevoked,i.pairingRevokeError,k]);if(!u)return null;if(!C)return(0,$.jsxs)(`div`,{id:tt(e),className:`space-y-2 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingAccountNotPairing.replace(`{{account}}`,f)}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]});let ee=E?.pending??[],B=E?.paired.fromConfig??[];return(0,$.jsxs)(`div`,{id:tt(e),className:`space-y-3 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i.pairingSubtitle})]}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.pairingRefresh,disabled:O,onClick:()=>void k(),children:(0,$.jsx)(w,{className:z(`size-4 text-fg-muted`,O&&`animate-spin`)})})]}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,$.jsx)(oe,{children:i.pairingSetupHint}),D?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:i.pairingLoadError}):null,S?(0,$.jsx)(`p`,{className:z(`text-xs`,S.kind===`ok`?`text-success`:`text-red-600 dark:text-red-400`),children:S.text}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{children:i.pairingPendingTitle}),ee.length>0?(0,$.jsx)(oe,{children:i.pairingQuickApproveHint}):null,ee.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingPendingEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:ee.map(e=>{let t=v[e.senderId]??``,n=y===e.senderId,r=b===e.senderId;return(0,$.jsxs)(`li`,{className:z(`rounded-lg border bg-surface-panel p-3 dark:border-edge`,e.isStale?`border-amber-300/50 dark:border-amber-800/50`:`border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.senderId}),(0,$.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e.isStale?(0,$.jsx)(`span`,{className:`text-amber-800 dark:text-amber-200`,children:i.pairingStaleItem}):null,e.isStale?` · `:null,i.pairingExpiresHint.replace(`{{time}}`,rt(e.expiresAt,a))]})]}),e.codeLast4?(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:i.pairingCodeHint.replace(`{{suffix}}`,e.codeLast4)}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,$.jsx)(V,{type:`button`,variant:`secondary`,className:`shrink-0 text-xs`,disabled:n||r,onClick:()=>void I(e.senderId),children:n?i.pairingApproving:i.pairingQuickApprove}),(0,$.jsx)(`input`,{className:z(c(),`min-w-0 flex-1 font-mono text-xs uppercase`),value:t,autoComplete:`off`,spellCheck:!1,maxLength:8,placeholder:i.pairingCodePlaceholder,onChange:t=>j(n=>({...n,[e.senderId]:t.target.value.toUpperCase()})),onKeyDown:n=>{n.key===`Enter`&&P(e.senderId,t)}}),(0,$.jsx)(V,{type:`button`,variant:`primary`,className:`shrink-0 text-xs`,disabled:n||r||!t.trim(),onClick:()=>P(e.senderId,t),children:n?i.pairingApproving:i.pairingApprove}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,className:`shrink-0 text-xs text-fg-muted hover:text-danger`,disabled:n||r,onClick:()=>void L(e.senderId),children:r?i.pairingDismissing:i.pairingDismiss})]})]},e.senderId)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3 dark:border-edge-subtle`,children:[(0,$.jsx)(Y,{children:i.pairedTitle}),(0,$.jsxs)(`div`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromConfig}),(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:B.length?B.join(`, `):i.pairedEmpty})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromCredentials}),A.length===0?(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:i.pairedEmpty}):(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:A.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-fg`,children:e}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,className:`size-7 shrink-0 p-0 text-fg-muted hover:text-danger`,"aria-label":i.pairingRevokeAria.replace(`{{id}}`,e),disabled:x===e,onClick:()=>void R(e),children:(0,$.jsx)(F,{className:`size-3.5`})})]},e))})]})]})]})]})}function ct(e){let t=(0,Q.c)(368),{ch:n,form:r,baseline:i,showFeishuSecret:a,setShowFeishuSecret:o,showFeishuWebhookSecrets:s,setShowFeishuWebhookSecrets:c,feishuCopied:l,feishuWebhookCopied:u,copyFeishuSecret:d,copyFeishuWebhookConfig:f,updateFeishu:p,updateChannelAgentRoute:m,feishuAccountsDraft:h,setFeishuAccountsDraft:g,feishuAccountsError:v,onFeishuAccountsBlur:b,dmOpts:x,groupOpts:C,chatAgents:w,saving:T,language:E,dialogOpen:D,pairingFocus:O}=e,k=O===void 0?!1:O,A=r.feishu,j;t[0]===A?j=t[1]:(j=se(A),t[0]=A,t[1]=j);let M=j,N;t[2]===M?N=t[3]:(N=M.length>0?M:[`default`],t[2]=M,t[3]=N);let P=N,F=i?.feishu?.appSecret??``,I;t[4]!==F||t[5]!==A.appSecret||t[6]!==a?(I=!a&&!!String(F).trim()&&A.appSecret===F,t[4]=F,t[5]=A.appSecret,t[6]=a,t[7]=I):I=t[7];let L=I,R=(0,Z.useRef)(null),B,H;t[8]===k?(B=t[9],H=t[10]):(B=()=>{if(!k)return;let e=R.current;e&&(e.open=!0);let t=window.setTimeout(ft,80);return()=>window.clearTimeout(t)},H=[k],t[8]=k,t[9]=B,t[10]=H),(0,Z.useEffect)(B,H);let U;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ee,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[11]=U):U=t[11];let W;t[12]===n.advancedShow?W=t[13]:(W=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[U,n.advancedShow]})}),t[12]=n.advancedShow,t[13]=W);let G;t[14]===n.feishuAdvancedHint?G=t[15]:(G=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[14]=n.feishuAdvancedHint,t[15]=G);let ne;t[16]===p?ne=t[17]:(ne=e=>p({enabled:e.target.checked}),t[16]=p,t[17]=ne);let K;t[18]!==A.enabled||t[19]!==ne?(K=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:A.enabled,onChange:ne}),t[18]=A.enabled,t[19]=ne,t[20]=K):K=t[20];let q;t[21]===n.enableFeishuAria?q=t[22]:(q=(0,$.jsx)(`span`,{children:n.enableFeishuAria}),t[21]=n.enableFeishuAria,t[22]=q);let ce;t[23]!==K||t[24]!==q?(ce=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[K,q]}),t[23]=K,t[24]=q,t[25]=ce):ce=t[25];let le;t[26]===p?le=t[27]:(le=e=>p({dmPolicy:e}),t[26]=p,t[27]=le);let ue;t[28]!==n.dmPolicy||t[29]!==x||t[30]!==A.dmPolicy||t[31]!==le?(ue=(0,$.jsx)(ae,{label:n.dmPolicy,value:A.dmPolicy,onChange:le,options:x}),t[28]=n.dmPolicy,t[29]=x,t[30]=A.dmPolicy,t[31]=le,t[32]=ue):ue=t[32];let de;t[33]!==n||t[34]!==D||t[35]!==A||t[36]!==E||t[37]!==P?(de=(0,$.jsx)(st,{channel:`feishu`,accountIds:P,channelConfig:A,active:D,ch:n,language:E}),t[33]=n,t[34]=D,t[35]=A,t[36]=E,t[37]=P,t[38]=de):de=t[38];let fe;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[39]=fe):fe=t[39];let pe;t[40]===n.feishuAppId?pe=t[41]:(pe=(0,$.jsxs)(Y,{children:[n.feishuAppId,fe]}),t[40]=n.feishuAppId,t[41]=pe);let me;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(me=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[42]=me):me=t[42];let he;t[43]===p?he=t[44]:(he=e=>p({appId:e.target.value}),t[43]=p,t[44]=he);let ge;t[45]!==A.appId||t[46]!==he?(ge=(0,$.jsx)(`input`,{className:me,value:A.appId,onChange:he,placeholder:`cli_xxx`}),t[45]=A.appId,t[46]=he,t[47]=ge):ge=t[47];let _e;t[48]===n.feishuAppIdDesc?_e=t[49]:(_e=(0,$.jsx)(oe,{children:n.feishuAppIdDesc}),t[48]=n.feishuAppIdDesc,t[49]=_e);let ve;t[50]!==pe||t[51]!==ge||t[52]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[pe,ge,_e]}),t[50]=pe,t[51]=ge,t[52]=_e,t[53]=ve):ve=t[53];let ye;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[54]=ye):ye=t[54];let be;t[55]===n.feishuAppSecret?be=t[56]:(be=(0,$.jsxs)(Y,{children:[n.feishuAppSecret,ye]}),t[55]=n.feishuAppSecret,t[56]=be);let xe;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(xe=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[57]=xe):xe=t[57];let X=a?`text`:`password`,Se;t[58]!==L||t[59]!==A.appSecret?(Se=L?`*`.repeat(Math.max(1,A.appSecret.length)):A.appSecret,t[58]=L,t[59]=A.appSecret,t[60]=Se):Se=t[60];let Ce;t[61]!==L||t[62]!==p?(Ce=e=>{L||p({appSecret:e.target.value})},t[61]=L,t[62]=p,t[63]=Ce):Ce=t[63];let we;t[64]!==L||t[65]!==X||t[66]!==Se||t[67]!==Ce?(we=(0,$.jsx)(`input`,{className:xe,type:X,autoComplete:`off`,readOnly:L,value:Se,onChange:Ce,placeholder:`••••••••`}),t[64]=L,t[65]=X,t[66]=Se,t[67]=Ce,t[68]=we):we=t[68];let Te;t[69]!==n.copied||t[70]!==n.copy||t[71]!==d||t[72]!==l||t[73]!==A.appSecret?(Te=A.appSecret?(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void d(),children:[l?(0,$.jsx)(S,{className:`size-3.5`}):(0,$.jsx)(_,{className:`size-3.5`}),l?n.copied:n.copy]}):null,t[69]=n.copied,t[70]=n.copy,t[71]=d,t[72]=l,t[73]=A.appSecret,t[74]=Te):Te=t[74];let Ee;t[75]===o?Ee=t[76]:(Ee=()=>o(dt),t[75]=o,t[76]=Ee);let De;t[77]===a?De=t[78]:(De=a?(0,$.jsx)(te,{className:`size-3.5`}):(0,$.jsx)(y,{className:`size-3.5`}),t[77]=a,t[78]=De);let Oe=a?n.hide:n.show,ke;t[79]!==Ee||t[80]!==De||t[81]!==Oe?(ke=(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:Ee,children:[De,Oe]}),t[79]=Ee,t[80]=De,t[81]=Oe,t[82]=ke):ke=t[82];let Ae;t[83]!==we||t[84]!==Te||t[85]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[we,Te,ke]}),t[83]=we,t[84]=Te,t[85]=ke,t[86]=Ae):Ae=t[86];let je;t[87]===n.feishuAppSecretDesc?je=t[88]:(je=(0,$.jsx)(oe,{children:n.feishuAppSecretDesc}),t[87]=n.feishuAppSecretDesc,t[88]=je);let Me;t[89]!==be||t[90]!==Ae||t[91]!==je?(Me=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[be,Ae,je]}),t[89]=be,t[90]=Ae,t[91]=je,t[92]=Me):Me=t[92];let Ne;t[93]===n.feishuDomain?Ne=t[94]:(Ne=(0,$.jsx)(Y,{children:n.feishuDomain}),t[93]=n.feishuDomain,t[94]=Ne);let Pe;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=J(),t[95]=Pe):Pe=t[95];let Fe=String(A.domain||`feishu`),Ie;t[96]===p?Ie=t[97]:(Ie=e=>p({domain:e.target.value}),t[96]=p,t[97]=Ie);let Le,Re;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(`option`,{value:`feishu`,children:`feishu`}),Re=(0,$.jsx)(`option`,{value:`lark`,children:`lark`}),t[98]=Le,t[99]=Re):(Le=t[98],Re=t[99]);let ze;t[100]!==Fe||t[101]!==Ie?(ze=(0,$.jsxs)(`select`,{className:Pe,value:Fe,onChange:Ie,children:[Le,Re]}),t[100]=Fe,t[101]=Ie,t[102]=ze):ze=t[102];let Be;t[103]!==Ne||t[104]!==ze?(Be=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,ze]}),t[103]=Ne,t[104]=ze,t[105]=Be):Be=t[105];let He;t[106]===n.connectionMode?He=t[107]:(He=(0,$.jsx)(Y,{children:n.connectionMode}),t[106]=n.connectionMode,t[107]=He);let Ue;t[108]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=J(),t[108]=Ue):Ue=t[108];let We;t[109]===p?We=t[110]:(We=e=>p({connectionMode:e.target.value}),t[109]=p,t[110]=We);let Ge,Ke;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(Ge=(0,$.jsx)(`option`,{value:`websocket`,children:`websocket`}),Ke=(0,$.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[111]=Ge,t[112]=Ke):(Ge=t[111],Ke=t[112]);let qe;t[113]!==A.connectionMode||t[114]!==We?(qe=(0,$.jsxs)(`select`,{className:Ue,value:A.connectionMode,onChange:We,children:[Ge,Ke]}),t[113]=A.connectionMode,t[114]=We,t[115]=qe):qe=t[115];let Je;t[116]===n.connectionModeDesc?Je=t[117]:(Je=(0,$.jsx)(oe,{children:n.connectionModeDesc}),t[116]=n.connectionModeDesc,t[117]=Je);let Ye;t[118]!==He||t[119]!==qe||t[120]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[He,qe,Je]}),t[118]=He,t[119]=qe,t[120]=Je,t[121]=Ye):Ye=t[121];let Xe;t[122]!==Be||t[123]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Be,Ye]}),t[122]=Be,t[123]=Ye,t[124]=Xe):Xe=t[124];let Ze;t[125]!==n.copied||t[126]!==n.copy||t[127]!==n.encryptKey||t[128]!==n.encryptKeyDesc||t[129]!==n.hide||t[130]!==n.show||t[131]!==n.verificationToken||t[132]!==n.verificationTokenDesc||t[133]!==n.webhookHost||t[134]!==n.webhookPath||t[135]!==n.webhookPathDesc||t[136]!==n.webhookPort||t[137]!==n.webhookTitle||t[138]!==f||t[139]!==u||t[140]!==A.connectionMode||t[141]!==A.encryptKey||t[142]!==A.verificationToken||t[143]!==A.webhookHost||t[144]!==A.webhookPath||t[145]!==A.webhookPort||t[146]!==c||t[147]!==s||t[148]!==p?(Ze=A.connectionMode===`webhook`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>c(ut),children:[s?(0,$.jsx)(te,{className:`size-3.5`}):(0,$.jsx)(y,{className:`size-3.5`}),s?n.hide:n.show]}),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void f(),children:[u?(0,$.jsx)(S,{className:`size-3.5`}):(0,$.jsx)(_,{className:`size-3.5`}),u?n.copied:n.copy]})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.verificationToken}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),type:s?`text`:`password`,autoComplete:`off`,value:A.verificationToken??``,onChange:e=>p({verificationToken:e.target.value})}),(0,$.jsx)(oe,{children:n.verificationTokenDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.encryptKey}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),type:s?`text`:`password`,autoComplete:`off`,value:A.encryptKey??``,onChange:e=>p({encryptKey:e.target.value})}),(0,$.jsx)(oe,{children:n.encryptKeyDesc})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Y,{children:n.webhookHost}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),value:A.webhookHost??``,onChange:e=>p({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPort}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(A.webhookPort??``),onChange:e=>p({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPath}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),value:A.webhookPath??``,onChange:e=>p({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,$.jsx)(oe,{children:n.webhookPathDesc})]})]}):null,t[125]=n.copied,t[126]=n.copy,t[127]=n.encryptKey,t[128]=n.encryptKeyDesc,t[129]=n.hide,t[130]=n.show,t[131]=n.verificationToken,t[132]=n.verificationTokenDesc,t[133]=n.webhookHost,t[134]=n.webhookPath,t[135]=n.webhookPathDesc,t[136]=n.webhookPort,t[137]=n.webhookTitle,t[138]=f,t[139]=u,t[140]=A.connectionMode,t[141]=A.encryptKey,t[142]=A.verificationToken,t[143]=A.webhookHost,t[144]=A.webhookPath,t[145]=A.webhookPort,t[146]=c,t[147]=s,t[148]=p,t[149]=Ze):Ze=t[149];let Qe;t[150]===n.renderMode?Qe=t[151]:(Qe=(0,$.jsx)(Y,{children:n.renderMode}),t[150]=n.renderMode,t[151]=Qe);let $e;t[152]===Symbol.for(`react.memo_cache_sentinel`)?($e=J(),t[152]=$e):$e=t[152];let et;t[153]===p?et=t[154]:(et=e=>p({renderMode:e.target.value}),t[153]=p,t[154]=et);let tt,nt,rt;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,$.jsx)(`option`,{value:`auto`,children:`auto`}),nt=(0,$.jsx)(`option`,{value:`raw`,children:`raw`}),rt=(0,$.jsx)(`option`,{value:`card`,children:`card`}),t[155]=tt,t[156]=nt,t[157]=rt):(tt=t[155],nt=t[156],rt=t[157]);let it;t[158]!==A.renderMode||t[159]!==et?(it=(0,$.jsxs)(`select`,{className:$e,value:A.renderMode,onChange:et,children:[tt,nt,rt]}),t[158]=A.renderMode,t[159]=et,t[160]=it):it=t[160];let at;t[161]!==Qe||t[162]!==it?(at=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Qe,it]}),t[161]=Qe,t[162]=it,t[163]=at):at=t[163];let ot;t[164]===n.reactionNotifications?ot=t[165]:(ot=(0,$.jsx)(Y,{children:n.reactionNotifications}),t[164]=n.reactionNotifications,t[165]=ot);let ct;t[166]===Symbol.for(`react.memo_cache_sentinel`)?(ct=J(),t[166]=ct):ct=t[166];let pt;t[167]===p?pt=t[168]:(pt=e=>p({reactionNotifications:e.target.value}),t[167]=p,t[168]=pt);let mt,ht,gt;t[169]===Symbol.for(`react.memo_cache_sentinel`)?(mt=(0,$.jsx)(`option`,{value:`off`,children:`off`}),ht=(0,$.jsx)(`option`,{value:`own`,children:`own`}),gt=(0,$.jsx)(`option`,{value:`all`,children:`all`}),t[169]=mt,t[170]=ht,t[171]=gt):(mt=t[169],ht=t[170],gt=t[171]);let _t;t[172]!==A.reactionNotifications||t[173]!==pt?(_t=(0,$.jsxs)(`select`,{className:ct,value:A.reactionNotifications,onChange:pt,children:[mt,ht,gt]}),t[172]=A.reactionNotifications,t[173]=pt,t[174]=_t):_t=t[174];let vt;t[175]!==ot||t[176]!==_t?(vt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ot,_t]}),t[175]=ot,t[176]=_t,t[177]=vt):vt=t[177];let yt;t[178]!==at||t[179]!==vt?(yt=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[at,vt]}),t[178]=at,t[179]=vt,t[180]=yt):yt=t[180];let bt;t[181]===p?bt=t[182]:(bt=e=>p({streaming:e.target.checked}),t[181]=p,t[182]=bt);let xt;t[183]!==A.streaming||t[184]!==bt?(xt=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:A.streaming,onChange:bt}),t[183]=A.streaming,t[184]=bt,t[185]=xt):xt=t[185];let St;t[186]!==n.enableStreaming||t[187]!==xt?(St=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[xt,n.enableStreaming]}),t[186]=n.enableStreaming,t[187]=xt,t[188]=St):St=t[188];let Ct;t[189]===n.groupPolicy?Ct=t[190]:(Ct=(0,$.jsx)(Y,{children:n.groupPolicy}),t[189]=n.groupPolicy,t[190]=Ct);let wt;t[191]===Symbol.for(`react.memo_cache_sentinel`)?(wt=J(),t[191]=wt):wt=t[191];let Tt=A.groupPolicy,Et;t[192]===p?Et=t[193]:(Et=e=>p({groupPolicy:e.target.value}),t[192]=p,t[193]=Et);let Dt;t[194]===C?Dt=t[195]:(Dt=C.map(lt),t[194]=C,t[195]=Dt);let Ot;t[196]!==A.groupPolicy||t[197]!==Et||t[198]!==Dt?(Ot=(0,$.jsx)(`select`,{className:wt,value:Tt,onChange:Et,children:Dt}),t[196]=A.groupPolicy,t[197]=Et,t[198]=Dt,t[199]=Ot):Ot=t[199];let kt;t[200]!==Ct||t[201]!==Ot?(kt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ct,Ot]}),t[200]=Ct,t[201]=Ot,t[202]=kt):kt=t[202];let At;t[203]===p?At=t[204]:(At=e=>p({requireMention:e.target.checked}),t[203]=p,t[204]=At);let jt;t[205]!==A.requireMention||t[206]!==At?(jt=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:A.requireMention,onChange:At}),t[205]=A.requireMention,t[206]=At,t[207]=jt):jt=t[207];let Mt;t[208]!==n.requireMention||t[209]!==jt?(Mt=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[jt,n.requireMention]}),t[208]=n.requireMention,t[209]=jt,t[210]=Mt):Mt=t[210];let Nt;t[211]===n.allowFromDm?Nt=t[212]:(Nt=(0,$.jsx)(Y,{children:n.allowFromDm}),t[211]=n.allowFromDm,t[212]=Nt);let Pt;t[213]===Symbol.for(`react.memo_cache_sentinel`)?(Pt=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[213]=Pt):Pt=t[213];let Ft;t[214]===A.allowFrom?Ft=t[215]:(Ft=re(A.allowFrom),t[214]=A.allowFrom,t[215]=Ft);let It;t[216]===p?It=t[217]:(It=e=>p({allowFrom:ie(e.target.value)}),t[216]=p,t[217]=It);let Lt;t[218]!==Ft||t[219]!==It?(Lt=(0,$.jsx)(`textarea`,{className:Pt,rows:2,placeholder:`ou_xxx, on_xxx`,value:Ft,onChange:It}),t[218]=Ft,t[219]=It,t[220]=Lt):Lt=t[220];let Rt;t[221]===n.allowFromDmDesc?Rt=t[222]:(Rt=(0,$.jsx)(oe,{children:n.allowFromDmDesc}),t[221]=n.allowFromDmDesc,t[222]=Rt);let zt;t[223]!==Nt||t[224]!==Lt||t[225]!==Rt?(zt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Nt,Lt,Rt]}),t[223]=Nt,t[224]=Lt,t[225]=Rt,t[226]=zt):zt=t[226];let Bt;t[227]===n.allowFromGroups?Bt=t[228]:(Bt=(0,$.jsx)(Y,{children:n.allowFromGroups}),t[227]=n.allowFromGroups,t[228]=Bt);let Vt;t[229]===Symbol.for(`react.memo_cache_sentinel`)?(Vt=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[229]=Vt):Vt=t[229];let Ht;t[230]===A.groupAllowFrom?Ht=t[231]:(Ht=re(A.groupAllowFrom),t[230]=A.groupAllowFrom,t[231]=Ht);let Ut;t[232]===p?Ut=t[233]:(Ut=e=>p({groupAllowFrom:ie(e.target.value)}),t[232]=p,t[233]=Ut);let Wt;t[234]!==Ht||t[235]!==Ut?(Wt=(0,$.jsx)(`textarea`,{className:Vt,rows:2,placeholder:`oc_xxx, oc_yyy`,value:Ht,onChange:Ut}),t[234]=Ht,t[235]=Ut,t[236]=Wt):Wt=t[236];let Gt;t[237]===n.allowFromGroupsDesc?Gt=t[238]:(Gt=(0,$.jsx)(oe,{children:n.allowFromGroupsDesc}),t[237]=n.allowFromGroupsDesc,t[238]=Gt);let Kt;t[239]!==Bt||t[240]!==Wt||t[241]!==Gt?(Kt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Bt,Wt,Gt]}),t[239]=Bt,t[240]=Wt,t[241]=Gt,t[242]=Kt):Kt=t[242];let qt;t[243]===n.historyLimit?qt=t[244]:(qt=(0,$.jsx)(Y,{children:n.historyLimit}),t[243]=n.historyLimit,t[244]=qt);let Jt;t[245]===Symbol.for(`react.memo_cache_sentinel`)?(Jt=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[245]=Jt):Jt=t[245];let Yt=String(A.historyLimit),Xt;t[246]===p?Xt=t[247]:(Xt=e=>p({historyLimit:Number(e.target.value||`0`)||0}),t[246]=p,t[247]=Xt);let Zt;t[248]!==Yt||t[249]!==Xt?(Zt=(0,$.jsx)(`input`,{className:Jt,type:`number`,inputMode:`numeric`,value:Yt,onChange:Xt}),t[248]=Yt,t[249]=Xt,t[250]=Zt):Zt=t[250];let Qt;t[251]!==qt||t[252]!==Zt?(Qt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[qt,Zt]}),t[251]=qt,t[252]=Zt,t[253]=Qt):Qt=t[253];let $t;t[254]===n.textChunkLimit?$t=t[255]:($t=(0,$.jsx)(Y,{children:n.textChunkLimit}),t[254]=n.textChunkLimit,t[255]=$t);let en;t[256]===Symbol.for(`react.memo_cache_sentinel`)?(en=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[256]=en):en=t[256];let tn=String(A.textChunkLimit),nn;t[257]===p?nn=t[258]:(nn=e=>p({textChunkLimit:Number(e.target.value||`0`)||0}),t[257]=p,t[258]=nn);let rn;t[259]!==tn||t[260]!==nn?(rn=(0,$.jsx)(`input`,{className:en,type:`number`,inputMode:`numeric`,value:tn,onChange:nn}),t[259]=tn,t[260]=nn,t[261]=rn):rn=t[261];let an;t[262]!==$t||t[263]!==rn?(an=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[$t,rn]}),t[262]=$t,t[263]=rn,t[264]=an):an=t[264];let on;t[265]!==Qt||t[266]!==an?(on=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Qt,an]}),t[265]=Qt,t[266]=an,t[267]=on):on=t[267];let sn;t[268]===n.feishuToolsTitle?sn=t[269]:(sn=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[268]=n.feishuToolsTitle,t[269]=sn);let cn;t[270]===n.feishuToolDoc?cn=t[271]:(cn=[`doc`,n.feishuToolDoc],t[270]=n.feishuToolDoc,t[271]=cn);let ln;t[272]===n.feishuToolWiki?ln=t[273]:(ln=[`wiki`,n.feishuToolWiki],t[272]=n.feishuToolWiki,t[273]=ln);let un;t[274]===n.feishuToolDrive?un=t[275]:(un=[`drive`,n.feishuToolDrive],t[274]=n.feishuToolDrive,t[275]=un);let dn;t[276]===n.feishuToolPerm?dn=t[277]:(dn=[`perm`,n.feishuToolPerm],t[276]=n.feishuToolPerm,t[277]=dn);let fn;t[278]===n.feishuToolBitable?fn=t[279]:(fn=[`bitable`,n.feishuToolBitable],t[278]=n.feishuToolBitable,t[279]=fn);let pn;t[280]===n.feishuToolScopes?pn=t[281]:(pn=[`scopes`,n.feishuToolScopes],t[280]=n.feishuToolScopes,t[281]=pn);let mn;t[282]!==cn||t[283]!==ln||t[284]!==un||t[285]!==dn||t[286]!==fn||t[287]!==pn?(mn=[cn,ln,un,dn,fn,pn],t[282]=cn,t[283]=ln,t[284]=un,t[285]=dn,t[286]=fn,t[287]=pn,t[288]=mn):mn=t[288];let hn=mn,gn;t[289]!==A.tools||t[290]!==hn||t[291]!==p?(gn=(0,$.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:hn.map(e=>{let[t,n]=e;return(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!A.tools?.[t],onChange:e=>p({tools:{...A.tools,[t]:e.target.checked}})}),n]},t)})}),t[289]=A.tools,t[290]=hn,t[291]=p,t[292]=gn):gn=t[292];let _n;t[293]===n.feishuToolsDesc?_n=t[294]:(_n=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(oe,{children:n.feishuToolsDesc})}),t[293]=n.feishuToolsDesc,t[294]=_n);let vn;t[295]!==sn||t[296]!==gn||t[297]!==_n?(vn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[sn,gn,_n]}),t[295]=sn,t[296]=gn,t[297]=_n,t[298]=vn):vn=t[298];let yn;t[299]===n.feishuActionsTitle?yn=t[300]:(yn=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[299]=n.feishuActionsTitle,t[300]=yn);let bn=!!A.actions?.reactions,xn;t[301]!==A.actions||t[302]!==p?(xn=e=>p({actions:{...A.actions,reactions:e.target.checked}}),t[301]=A.actions,t[302]=p,t[303]=xn):xn=t[303];let Sn;t[304]!==bn||t[305]!==xn?(Sn=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:bn,onChange:xn}),t[304]=bn,t[305]=xn,t[306]=Sn):Sn=t[306];let Cn;t[307]!==n.feishuActionReactions||t[308]!==Sn?(Cn=(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[Sn,n.feishuActionReactions]}),t[307]=n.feishuActionReactions,t[308]=Sn,t[309]=Cn):Cn=t[309];let wn;t[310]!==yn||t[311]!==Cn?(wn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[yn,Cn]}),t[310]=yn,t[311]=Cn,t[312]=wn):wn=t[312];let Tn;t[313]===A?Tn=t[314]:(Tn=se(A),t[313]=A,t[314]=Tn);let En;t[315]===w?.items?En=t[316]:(En=w?.items??[],t[315]=w?.items,t[316]=En);let Dn;t[317]===m?Dn=t[318]:(Dn=(e,t)=>m(`feishu`,e,t),t[317]=m,t[318]=Dn);let On;t[319]!==n||t[320]!==r.channelAgentRoutes.feishu||t[321]!==r.defaultAgentId||t[322]!==T||t[323]!==Tn||t[324]!==En||t[325]!==Dn?(On=(0,$.jsx)(Ve,{accountIds:Tn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:En,disabled:T,onChange:Dn,ch:n}),t[319]=n,t[320]=r.channelAgentRoutes.feishu,t[321]=r.defaultAgentId,t[322]=T,t[323]=Tn,t[324]=En,t[325]=Dn,t[326]=On):On=t[326];let kn;t[327]===n.multiAccountJson?kn=t[328]:(kn=(0,$.jsx)(Y,{children:n.multiAccountJson}),t[327]=n.multiAccountJson,t[328]=kn);let An;t[329]===Symbol.for(`react.memo_cache_sentinel`)?(An=z(J(),`min-h-[140px] resize-y font-mono text-xs`),t[329]=An):An=t[329];let jn;t[330]===g?jn=t[331]:(jn=e=>g(e.target.value),t[330]=g,t[331]=jn);let Mn;t[332]!==h||t[333]!==b||t[334]!==jn?(Mn=(0,$.jsx)(`textarea`,{className:An,spellCheck:!1,value:h,onChange:jn,onBlur:b,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[332]=h,t[333]=b,t[334]=jn,t[335]=Mn):Mn=t[335];let Nn;t[336]!==n.multiAccountJsonDesc||t[337]!==v?(Nn=v?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:v}):(0,$.jsx)(oe,{children:n.multiAccountJsonDesc}),t[336]=n.multiAccountJsonDesc,t[337]=v,t[338]=Nn):Nn=t[338];let Pn;t[339]!==kn||t[340]!==Mn||t[341]!==Nn?(Pn=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[kn,Mn,Nn]}),t[339]=kn,t[340]=Mn,t[341]=Nn,t[342]=Pn):Pn=t[342];let Fn;t[343]!==Kt||t[344]!==on||t[345]!==vn||t[346]!==wn||t[347]!==On||t[348]!==Pn||t[349]!==ve||t[350]!==Me||t[351]!==Xe||t[352]!==Ze||t[353]!==yt||t[354]!==St||t[355]!==kt||t[356]!==Mt||t[357]!==zt?(Fn=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ve,Me,Xe,Ze,yt,St,kt,Mt,zt,Kt,on,vn,wn,On,Pn]}),t[343]=Kt,t[344]=on,t[345]=vn,t[346]=wn,t[347]=On,t[348]=Pn,t[349]=ve,t[350]=Me,t[351]=Xe,t[352]=Ze,t[353]=yt,t[354]=St,t[355]=kt,t[356]=Mt,t[357]=zt,t[358]=Fn):Fn=t[358];let In;t[359]!==ce||t[360]!==Fn||t[361]!==ue||t[362]!==de||t[363]!==G?(In=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[G,ce,ue,de,Fn]}),t[359]=ce,t[360]=Fn,t[361]=ue,t[362]=de,t[363]=G,t[364]=In):In=t[364];let Ln;return t[365]!==In||t[366]!==W?(Ln=(0,$.jsxs)(`details`,{ref:R,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[W,In]}),t[365]=In,t[366]=W,t[367]=Ln):Ln=t[367],Ln}function lt(e){return(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ut(e){return!e}function dt(e){return!e}function ft(){return nt(`feishu`)}var pt=e(be(),1);function mt(e){let t=(0,Q.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,$.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,$.jsx)(V,{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,$.jsx)(V,{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,$.jsx)(V,{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,$.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,$.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}var ht={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},gt={sessionKey:null,qrUrl:null};function _t({ch:e,onSetupSuccess:t,onOpenChange:n,closeOnSetupSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(`feishu`),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=C(()=>Se({domain:a}).then(e=>({sessionKey:e.sessionKey,qrUrl:e.qrUrl})),[s,a],{initial:gt,errorData:gt}),m=p.data.sessionKey,h=p.data.qrUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(e=>{u(null),o(e),c(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let e=!1,t,n=async()=>{try{let n=await ue(m);if(e||n.phase===`polling`)return;if(n.phase===`done`){t!==void 0&&(window.clearInterval(t),t=void 0),p.setData(gt),n.ok?(r&&f.current(!1),d.current({appId:n.appId,domain:n.domain,openId:n.openId})):u(n.message);return}n.phase===`unknown`&&(t!==void 0&&window.clearInterval(t),u(n.message),p.setData(gt))}catch(n){e||(t!==void 0&&window.clearInterval(t),u(n instanceof Error?n.message:`Request failed`),p.setData(gt))}};return t=window.setInterval(()=>void n(),3e3),n(),()=>{e=!0,t!==void 0&&window.clearInterval(t)}},[m,r,p.setData]);let b=C(()=>pt.toDataURL(h,ht),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,w=!!(h&&m),T=!v&&!w;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.feishuQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.feishuQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(w||T)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:T?e.feishuQrStarting:e.feishuQrScanHint}),(0,$.jsxs)(`div`,{className:z(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,T&&`bg-surface-muted/40 dark:bg-surface-base`),children:[T?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,w&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,w&&h&&!v&&!x&&!S&&!T?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.feishuQrEncoding}):null,w&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.feishuQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(D,{className:`size-3 shrink-0`}),e.feishuQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":e.feishuRegionSwitchAria,children:(0,$.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:g,className:z(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,W.press,a===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`feishu`),children:e.feishuRegionChina}),(0,$.jsx)(`button`,{type:`button`,disabled:g,className:z(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,W.press,a===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`lark`),children:e.feishuRegionInternational})]})}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(V,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:()=>y(a),children:g?e.feishuQrStarting:e.feishuQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function vt(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onSetupSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnSetupSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(mt,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==r||t[12]!==a||t[13]!==n?(v=n?(0,$.jsx)(_t,{ch:i,onSetupSuccess:a,onOpenChange:r,closeOnSetupSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=r,t[12]=a,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.feishuQrCloseAria||t[16]!==i.feishuQrModalSubtitle||t[17]!==i.feishuQrModalTitle||t[18]!==i.feishuSubtitle||t[19]!==i.feishuTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(Le,{presentation:h,open:n,onOpenChange:r,title:i.feishuTitle,description:i.feishuSubtitle,srTitle:i.feishuQrModalTitle,srDescription:i.feishuQrModalSubtitle,closeAriaLabel:i.feishuQrCloseAria,wide:!0,footer:_,children:v}),t[15]=i.feishuQrCloseAria,t[16]=i.feishuQrModalSubtitle,t[17]=i.feishuQrModalTitle,t[18]=i.feishuSubtitle,t[19]=i.feishuTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function yt(e){let t=(0,Q.c)(25),{ch:n,usesPairing:r,tokenReady:i,pairingComplete:a}=e;if(!r)return null;let o=i,s=a,c=!o,l=o&&!s,u;t[0]!==c||t[1]!==o?(u=(0,$.jsx)(bt,{done:o,current:c,index:1}),t[0]=c,t[1]=o,t[2]=u):u=t[2];let d=o&&`text-fg-muted`,f;t[3]===d?f=t[4]:(f=z(`text-fg`,d),t[3]=d,t[4]=f);let p;t[5]!==n.telegramSetupStepToken||t[6]!==f?(p=(0,$.jsx)(`span`,{className:f,children:n.telegramSetupStepToken}),t[5]=n.telegramSetupStepToken,t[6]=f,t[7]=p):p=t[7];let m;t[8]!==u||t[9]!==p?(m=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[u,p]}),t[8]=u,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==l||t[12]!==s?(h=(0,$.jsx)(bt,{done:s,current:l,index:2}),t[11]=l,t[12]=s,t[13]=h):h=t[13];let g=s&&`text-fg-muted`,_;t[14]===g?_=t[15]:(_=z(`text-fg`,g),t[14]=g,t[15]=_);let v;t[16]!==n.telegramSetupStepPairing||t[17]!==_?(v=(0,$.jsx)(`span`,{className:_,children:n.telegramSetupStepPairing}),t[16]=n.telegramSetupStepPairing,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==h||t[20]!==v?(y=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[h,v]}),t[19]=h,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`ol`,{className:`space-y-2 rounded-xl border border-accent/25 bg-accent-soft/20 px-4 py-3 text-xs`,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function bt(e){let t=(0,Q.c)(7),{done:n,current:r,index:i}=e,a=n&&`border-success bg-success text-white`,o=!n&&r&&`border-accent bg-accent text-white`,s=!n&&!r&&`border-edge text-fg-muted`,c;t[0]!==a||t[1]!==o||t[2]!==s?(c=z(`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold`,a,o,s),t[0]=a,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=n?`✓`:String(i),u;return t[4]!==c||t[5]!==l?(u=(0,$.jsx)(`span`,{className:c,"aria-hidden":!0,children:l}),t[4]=c,t[5]=l,t[6]=u):u=t[6],u}function xt(e){let t=(0,Q.c)(115),{tg:n,updateTelegram:r,ch:i,groupOpts:a,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}=e,f;t[0]===i.apiRoot?f=t[1]:(f=(0,$.jsx)(Y,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(),t[2]=p):p=t[2];let m;t[3]===r?m=t[4]:(m=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=m);let h;t[5]!==m||t[6]!==n.apiRoot?(h=(0,$.jsx)(`input`,{className:p,value:n.apiRoot,onChange:m,placeholder:`https://api.telegram.org`}),t[5]=m,t[6]=n.apiRoot,t[7]=h):h=t[7];let g;t[8]!==f||t[9]!==h?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[f,h]}),t[8]=f,t[9]=h,t[10]=g):g=t[10];let _;t[11]===i.proxy?_=t[12]:(_=(0,$.jsx)(Y,{children:i.proxy}),t[11]=i.proxy,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=J(),t[13]=v):v=t[13];let y;t[14]===r?y=t[15]:(y=e=>r({proxy:e.target.value}),t[14]=r,t[15]=y);let b;t[16]!==y||t[17]!==n.proxy?(b=(0,$.jsx)(`input`,{className:v,value:n.proxy,onChange:y,placeholder:`http://proxy.example.com:8080`}),t[16]=y,t[17]=n.proxy,t[18]=b):b=t[18];let x;t[19]!==_||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,b]}),t[19]=_,t[20]=b,t[21]=x):x=t[21];let S;t[22]===r?S=t[23]:(S=e=>r({groupPolicy:e}),t[22]=r,t[23]=S);let C;t[24]!==i.groupPolicy||t[25]!==a||t[26]!==S||t[27]!==n.groupPolicy?(C=(0,$.jsx)(ae,{label:i.groupPolicy,value:n.groupPolicy,onChange:S,options:a}),t[24]=i.groupPolicy,t[25]=a,t[26]=S,t[27]=n.groupPolicy,t[28]=C):C=t[28];let w;t[29]===r?w=t[30]:(w=e=>r({replyToMode:e}),t[29]=r,t[30]=w);let T;t[31]!==i.replyToMode||t[32]!==o||t[33]!==w||t[34]!==n.replyToMode?(T=(0,$.jsx)(ae,{label:i.replyToMode,value:n.replyToMode,onChange:w,options:o}),t[31]=i.replyToMode,t[32]=o,t[33]=w,t[34]=n.replyToMode,t[35]=T):T=t[35];let E;t[36]===r?E=t[37]:(E=e=>r({streamMode:e}),t[36]=r,t[37]=E);let D;t[38]!==i.streamMode||t[39]!==s||t[40]!==E||t[41]!==n.streamMode?(D=(0,$.jsx)(ae,{label:i.streamMode,value:n.streamMode,onChange:E,options:s}),t[38]=i.streamMode,t[39]=s,t[40]=E,t[41]=n.streamMode,t[42]=D):D=t[42];let O;t[43]===i.allowFromGroups?O=t[44]:(O=(0,$.jsx)(Y,{children:i.allowFromGroups}),t[43]=i.allowFromGroups,t[44]=O);let k;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(k=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[45]=k):k=t[45];let A;t[46]===n.groupAllowFrom?A=t[47]:(A=re(n.groupAllowFrom),t[46]=n.groupAllowFrom,t[47]=A);let j;t[48]===r?j=t[49]:(j=e=>r({groupAllowFrom:ie(e.target.value)}),t[48]=r,t[49]=j);let M;t[50]!==A||t[51]!==j?(M=(0,$.jsx)(`textarea`,{className:k,rows:2,placeholder:`-1001234567890`,value:A,onChange:j}),t[50]=A,t[51]=j,t[52]=M):M=t[52];let N;t[53]!==O||t[54]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[O,M]}),t[53]=O,t[54]=M,t[55]=N):N=t[55];let P;t[56]===i.historyLimit?P=t[57]:(P=(0,$.jsx)(Y,{children:i.historyLimit}),t[56]=i.historyLimit,t[57]=P);let F;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(F=J(),t[58]=F):F=t[58];let I;t[59]===r?I=t[60]:(I=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[59]=r,t[60]=I);let L;t[61]!==I||t[62]!==n.historyLimit?(L=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:F,value:n.historyLimit,onChange:I}),t[61]=I,t[62]=n.historyLimit,t[63]=L):L=t[63];let R;t[64]!==P||t[65]!==L?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[P,L]}),t[64]=P,t[65]=L,t[66]=R):R=t[66];let ee;t[67]===i.textChunkLimit?ee=t[68]:(ee=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[67]=i.textChunkLimit,t[68]=ee);let B;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(B=J(),t[69]=B):B=t[69];let V;t[70]===r?V=t[71]:(V=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[70]=r,t[71]=V);let H;t[72]!==V||t[73]!==n.textChunkLimit?(H=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:B,value:n.textChunkLimit,onChange:V}),t[72]=V,t[73]=n.textChunkLimit,t[74]=H):H=t[74];let U;t[75]!==ee||t[76]!==H?(U=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ee,H]}),t[75]=ee,t[76]=H,t[77]=U):U=t[77];let te;t[78]!==R||t[79]!==U?(te=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,U]}),t[78]=R,t[79]=U,t[80]=te):te=t[80];let W;t[81]===r?W=t[82]:(W=e=>r({debug:e.target.checked}),t[81]=r,t[82]=W);let G;t[83]!==W||t[84]!==n.debug?(G=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:W}),t[83]=W,t[84]=n.debug,t[85]=G):G=t[85];let ne;t[86]!==i.telegramDebug||t[87]!==G?(ne=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[G,i.telegramDebug]}),t[86]=i.telegramDebug,t[87]=G,t[88]=ne):ne=t[88];let K;t[89]===i.multiAccountJson?K=t[90]:(K=(0,$.jsx)(Y,{children:i.multiAccountJson}),t[89]=i.multiAccountJson,t[90]=K);let q;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(q=z(J(),`min-h-[140px] resize-y font-mono text-xs`),t[91]=q):q=t[91];let se;t[92]===l?se=t[93]:(se=e=>l(e.target.value),t[92]=l,t[93]=se);let ce;t[94]!==d||t[95]!==se||t[96]!==c?(ce=(0,$.jsx)(`textarea`,{className:q,spellCheck:!1,value:c,onChange:se,onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[94]=d,t[95]=se,t[96]=c,t[97]=ce):ce=t[97];let le;t[98]!==i.multiAccountJsonDesc||t[99]!==u?(le=u?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,$.jsx)(oe,{children:i.multiAccountJsonDesc}),t[98]=i.multiAccountJsonDesc,t[99]=u,t[100]=le):le=t[100];let ue;t[101]!==K||t[102]!==ce||t[103]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[K,ce,le]}),t[101]=K,t[102]=ce,t[103]=le,t[104]=ue):ue=t[104];let de;return t[105]!==x||t[106]!==C||t[107]!==T||t[108]!==D||t[109]!==N||t[110]!==te||t[111]!==ne||t[112]!==ue||t[113]!==g?(de=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[g,x,C,T,D,N,te,ne,ue]}),t[105]=x,t[106]=C,t[107]=T,t[108]=D,t[109]=N,t[110]=te,t[111]=ne,t[112]=ue,t[113]=g,t[114]=de):de=t[114],de}function St(e){let t=(0,Q.c)(169),{open:n,onOpenChange:r,presentation:i,ch:a,form:o,baseline:s,tgAdvanced:c,setTgAdvanced:l,showToken:u,setShowToken:d,copied:f,copyToken:p,updateTelegram:m,updateChannelAgentRoute:h,tgAccountsDraft:g,setTgAccountsDraft:v,tgAccountsError:b,onTgAccountsBlur:x,dmOpts:C,groupOpts:w,replyOpts:T,streamOpts:E,chatAgents:D,saving:O,dirty:k,save:A,discard:j,language:M,scrollToPairingOnOpen:N,closeOnSave:P}=e,F=i===void 0?`modal`:i,I=N===void 0?!1:N,L=P===void 0?!0:P,R=o.telegram,B;t[0]===s?B=t[1]:(B=s?ne(s.telegram):``,t[0]=s,t[1]=B);let H=B,U=ne(R),W=!u&&!!String(H).trim()&&U===H,[G,K]=(0,Z.useState)(0),q=!!U.trim()&&R.enabled,se;t[2]===R?se=t[3]:(se=Ce(R),t[2]=R,t[3]=se);let ce=se,le,ue;t[4]!==n||t[5]!==I?(le=()=>{if(!n||!I)return;let e=window.setTimeout(Tt,80);return()=>window.clearTimeout(e)},ue=[n,I],t[4]=n,t[5]=I,t[6]=le,t[7]=ue):(le=t[6],ue=t[7]),(0,Z.useEffect)(le,ue);let de=a.telegramTitle,fe=a.telegramSubtitle,pe=a.telegramTitle,me=a.telegramSubtitle,he=a.modalCancel,ge;t[8]!==a.telegramSubtitle||t[9]!==a.telegramTitle||t[10]!==F?(ge=F===`modal`?(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:a.telegramTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.telegramSubtitle})]}):void 0,t[8]=a.telegramSubtitle,t[9]=a.telegramTitle,t[10]=F,t[11]=ge):ge=t[11];let _e;t[12]===r?_e=t[13]:(_e=()=>r(!1),t[12]=r,t[13]=_e);let ve;t[14]!==L||t[15]!==r||t[16]!==A?(ve=async()=>{await A()&&L&&r(!1)},t[14]=L,t[15]=r,t[16]=A,t[17]=ve):ve=t[17];let ye;t[18]!==a||t[19]!==k||t[20]!==j||t[21]!==O||t[22]!==_e||t[23]!==ve?(ye=(0,$.jsx)(mt,{ch:a,dirty:k,saving:O,onCancel:_e,onDiscard:j,onSave:ve}),t[18]=a,t[19]=k,t[20]=j,t[21]=O,t[22]=_e,t[23]=ve,t[24]=ye):ye=t[24];let be;t[25]===m?be=t[26]:(be=e=>m({enabled:e.target.checked}),t[25]=m,t[26]=be);let X;t[27]!==be||t[28]!==R.enabled?(X=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:R.enabled,onChange:be}),t[27]=be,t[28]=R.enabled,t[29]=X):X=t[29];let Se;t[30]===a.enableTelegramAria?Se=t[31]:(Se=(0,$.jsx)(`span`,{children:a.enableTelegramAria}),t[30]=a.enableTelegramAria,t[31]=Se);let we;t[32]!==X||t[33]!==Se?(we=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[X,Se]}),t[32]=X,t[33]=Se,t[34]=we):we=t[34];let Te;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[35]=Te):Te=t[35];let Ee;t[36]===a.telegramToken?Ee=t[37]:(Ee=(0,$.jsxs)(Y,{children:[a.telegramToken,Te]}),t[36]=a.telegramToken,t[37]=Ee);let De;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(De=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[38]=De):De=t[38];let Oe=u?`text`:`password`,ke;t[39]!==W||t[40]!==H||t[41]!==U?(ke=W?`*`.repeat(Math.max(1,H.length)):U,t[39]=W,t[40]=H,t[41]=U,t[42]=ke):ke=t[42];let Ae;t[43]!==W||t[44]!==R.accounts||t[45]!==m?(Ae=e=>{if(W)return;let t=R.accounts?.default??xe(`default`);m({accounts:{...R.accounts,default:{...t,accountId:`default`,botToken:e.target.value}}})},t[43]=W,t[44]=R.accounts,t[45]=m,t[46]=Ae):Ae=t[46];let je;t[47]!==Oe||t[48]!==ke||t[49]!==Ae||t[50]!==W?(je=(0,$.jsx)(`input`,{className:De,type:Oe,autoComplete:`off`,readOnly:W,value:ke,onChange:Ae,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`}),t[47]=Oe,t[48]=ke,t[49]=Ae,t[50]=W,t[51]=je):je=t[51];let Me;t[52]!==a.copied||t[53]!==a.copy||t[54]!==f||t[55]!==p||t[56]!==U?(Me=U?(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void p(),children:[f?(0,$.jsx)(S,{className:`size-3.5`}):(0,$.jsx)(_,{className:`size-3.5`}),f?a.copied:a.copy]}):null,t[52]=a.copied,t[53]=a.copy,t[54]=f,t[55]=p,t[56]=U,t[57]=Me):Me=t[57];let Ne;t[58]===d?Ne=t[59]:(Ne=()=>d(wt),t[58]=d,t[59]=Ne);let Pe;t[60]===u?Pe=t[61]:(Pe=u?(0,$.jsx)(te,{className:`size-3.5`}):(0,$.jsx)(y,{className:`size-3.5`}),t[60]=u,t[61]=Pe);let Fe=u?a.hide:a.show,Ie;t[62]!==Ne||t[63]!==Pe||t[64]!==Fe?(Ie=(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:Ne,children:[Pe,Fe]}),t[62]=Ne,t[63]=Pe,t[64]=Fe,t[65]=Ie):Ie=t[65];let Re;t[66]!==je||t[67]!==Me||t[68]!==Ie?(Re=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[je,Me,Ie]}),t[66]=je,t[67]=Me,t[68]=Ie,t[69]=Re):Re=t[69];let ze;t[70]===a.telegramTokenDesc?ze=t[71]:(ze=(0,$.jsx)(oe,{children:a.telegramTokenDesc}),t[70]=a.telegramTokenDesc,t[71]=ze);let Be;t[72]!==Ee||t[73]!==Re||t[74]!==ze?(Be=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ee,Re,ze]}),t[72]=Ee,t[73]=Re,t[74]=ze,t[75]=Be):Be=t[75];let He;t[76]===R?He=t[77]:(He=Je(`telegram`,R),t[76]=R,t[77]=He);let Ue=G>0,We;t[78]!==a||t[79]!==He||t[80]!==Ue||t[81]!==q?(We=(0,$.jsx)(yt,{ch:a,usesPairing:He,tokenReady:q,pairingComplete:Ue}),t[78]=a,t[79]=He,t[80]=Ue,t[81]=q,t[82]=We):We=t[82];let Ge;t[83]===m?Ge=t[84]:(Ge=e=>m({dmPolicy:e}),t[83]=m,t[84]=Ge);let Ke;t[85]!==a.dmPolicy||t[86]!==C||t[87]!==Ge||t[88]!==R.dmPolicy?(Ke=(0,$.jsx)(ae,{label:a.dmPolicy,value:R.dmPolicy,onChange:Ge,options:C}),t[85]=a.dmPolicy,t[86]=C,t[87]=Ge,t[88]=R.dmPolicy,t[89]=Ke):Ke=t[89];let qe;t[90]!==a||t[91]!==M||t[92]!==n||t[93]!==K||t[94]!==R||t[95]!==ce?(qe=(0,$.jsx)(st,{channel:`telegram`,accountIds:ce,channelConfig:R,active:n,ch:a,language:M,onPairedChange:K}),t[90]=a,t[91]=M,t[92]=n,t[93]=K,t[94]=R,t[95]=ce,t[96]=qe):qe=t[96];let Ye;t[97]===a.allowFromDm?Ye=t[98]:(Ye=(0,$.jsx)(Y,{children:a.allowFromDm}),t[97]=a.allowFromDm,t[98]=Ye);let Xe;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[99]=Xe):Xe=t[99];let Ze;t[100]===R.allowFrom?Ze=t[101]:(Ze=re(R.allowFrom),t[100]=R.allowFrom,t[101]=Ze);let Qe;t[102]===m?Qe=t[103]:(Qe=e=>m({allowFrom:ie(e.target.value)}),t[102]=m,t[103]=Qe);let $e;t[104]!==Ze||t[105]!==Qe?($e=(0,$.jsx)(`textarea`,{className:Xe,rows:2,placeholder:`123456789, 987654321`,value:Ze,onChange:Qe}),t[104]=Ze,t[105]=Qe,t[106]=$e):$e=t[106];let et;t[107]===a.allowFromDmDesc?et=t[108]:(et=(0,$.jsx)(oe,{children:a.allowFromDmDesc}),t[107]=a.allowFromDmDesc,t[108]=et);let tt;t[109]!==Ye||t[110]!==$e||t[111]!==et?(tt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ye,$e,et]}),t[109]=Ye,t[110]=$e,t[111]=et,t[112]=tt):tt=t[112];let nt;t[113]===R?nt=t[114]:(nt=Ce(R),t[113]=R,t[114]=nt);let rt;t[115]===D?.items?rt=t[116]:(rt=D?.items??[],t[115]=D?.items,t[116]=rt);let it;t[117]===h?it=t[118]:(it=(e,t)=>h(`telegram`,e,t),t[117]=h,t[118]=it);let at;t[119]!==a||t[120]!==o.channelAgentRoutes.telegram||t[121]!==o.defaultAgentId||t[122]!==O||t[123]!==nt||t[124]!==rt||t[125]!==it?(at=(0,$.jsx)(Ve,{accountIds:nt,routes:o.channelAgentRoutes.telegram,defaultAgentId:o.defaultAgentId,agentItems:rt,disabled:O,onChange:it,ch:a}),t[119]=a,t[120]=o.channelAgentRoutes.telegram,t[121]=o.defaultAgentId,t[122]=O,t[123]=nt,t[124]=rt,t[125]=it,t[126]=at):at=t[126];let ot;t[127]===l?ot=t[128]:(ot=()=>l(Ct),t[127]=l,t[128]=ot);let ct=c&&`rotate-180`,lt;t[129]===ct?lt=t[130]:(lt=z(`mr-1 size-4 transition-transform`,ct),t[129]=ct,t[130]=lt);let ut;t[131]===lt?ut=t[132]:(ut=(0,$.jsx)(ee,{className:lt}),t[131]=lt,t[132]=ut);let dt=c?a.advancedHide:a.advancedShow,ft;t[133]!==ot||t[134]!==ut||t[135]!==dt?(ft=(0,$.jsxs)(V,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:ot,children:[ut,dt]}),t[133]=ot,t[134]=ut,t[135]=dt,t[136]=ft):ft=t[136];let pt;t[137]!==a||t[138]!==w||t[139]!==x||t[140]!==T||t[141]!==v||t[142]!==E||t[143]!==R||t[144]!==g||t[145]!==b||t[146]!==c||t[147]!==m?(pt=c?(0,$.jsx)(xt,{tg:R,updateTelegram:m,ch:a,groupOpts:w,replyOpts:T,streamOpts:E,tgAccountsDraft:g,setTgAccountsDraft:v,tgAccountsError:b,onTgAccountsBlur:x}):null,t[137]=a,t[138]=w,t[139]=x,t[140]=T,t[141]=v,t[142]=E,t[143]=R,t[144]=g,t[145]=b,t[146]=c,t[147]=m,t[148]=pt):pt=t[148];let ht;t[149]!==Be||t[150]!==We||t[151]!==Ke||t[152]!==qe||t[153]!==tt||t[154]!==at||t[155]!==ft||t[156]!==pt?(ht=(0,$.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Be,We,Ke,qe,tt,at,ft,pt]}),t[149]=Be,t[150]=We,t[151]=Ke,t[152]=qe,t[153]=tt,t[154]=at,t[155]=ft,t[156]=pt,t[157]=ht):ht=t[157];let gt;return t[158]!==a.modalCancel||t[159]!==a.telegramSubtitle||t[160]!==a.telegramTitle||t[161]!==r||t[162]!==n||t[163]!==F||t[164]!==ge||t[165]!==ye||t[166]!==we||t[167]!==ht?(gt=(0,$.jsxs)(Le,{presentation:F,open:n,onOpenChange:r,title:de,description:fe,srTitle:pe,srDescription:me,closeAriaLabel:he,wide:!0,headerExtra:ge,footer:ye,children:[we,ht]}),t[158]=a.modalCancel,t[159]=a.telegramSubtitle,t[160]=a.telegramTitle,t[161]=r,t[162]=n,t[163]=F,t[164]=ge,t[165]=ye,t[166]=we,t[167]=ht,t[168]=gt):gt=t[168],gt}function Ct(e){return!e}function wt(e){return!e}function Tt(){return nt(`telegram`)}var Et=[{id:`telegram`,titleKey:`telegramTitle`,subtitleKey:`telegramSubtitle`},{id:`weixin`,titleKey:`weixinTitle`,subtitleKey:`weixinSubtitle`},{id:`feishu`,titleKey:`feishuTitle`,subtitleKey:`feishuSubtitle`}];function Dt(){return o(`/api/channels/meta`)}async function Ot(){return(await g(Dt())).payload?.channels??[]}var kt=new Map(Et.map(e=>[e.id,e])),At=new Map(Et.map((e,t)=>[e.id,t]));function jt(e,t){return{title:t[e.titleKey],subtitle:t[e.subtitleKey]}}function Mt(e,t){let n=new Map;for(let r of e??[]){let e=kt.get(r.id),i=e?jt(e,t):{title:r.label,subtitle:r.description||t.hubExtensionSubtitle};n.set(r.id,{id:r.id,title:i.title,subtitle:i.subtitle,manageable:r.manageable,order:r.order})}if(n.size===0)return Et.map((e,n)=>{let r=jt(e,t);return{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:n}});for(let e of Et){if(n.has(e.id))continue;let r=jt(e,t);n.set(e.id,{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:At.get(e.id)??0})}return Array.from(n.values()).sort((e,t)=>e.order===t.order?e.id.localeCompare(t.id):e.order-t.order)}function Nt(e,t){let n=(0,Q.c)(11),r;n[0]===e?r=n[1]:(r=e?Dt():null,n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},n[2]=i):i=n[2];let{data:a,error:o,isLoading:c,mutate:l}=s(r,Ot,i),u;n[3]!==t||n[4]!==a?(u=Mt(a,t),n[3]=t,n[4]=a,n[5]=u):u=n[5];let d=u,f;return n[6]!==d||n[7]!==o||n[8]!==c||n[9]!==l?(f={entries:d,isLoading:c,error:o,mutate:l},n[6]=d,n[7]=o,n[8]=c,n[9]=l,n[10]=f):f=n[10],f}function Pt(e,t){return e.find(e=>e.name===t)?.connected??!1}function Ft(e,t){return e.find(e=>e.name===t)?.enabled??!1}function It(e,t){let n=e&&typeof e==`object`?e.channels:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n[t]:void 0;return!r||typeof r!=`object`?!1:Object.keys(r).length>0}function Lt(e,t,n){return e?t?n?`running`:`offline`:`disabled`:`not_configured`}function Rt(e,t,n){return n?e===`not_configured`?`setup`:t>0?`pairing`:e===`offline`?`fix`:`manage`:`manage`}function zt(e,t){return e.policy.dm[t]}function Bt(e,t){return e.hubSummaryAccountCount.replace(`{{count}}`,String(t))}function Vt(e,t){let n=t.telegram,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))],i=Ce(n).length;return i>0&&r.push(Bt(e,i)),r}function Ht(e,t){let n=t.weixin,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))];r.push(e.hubSummaryStream.replace(`{{mode}}`,e.policy.stream[n.streamMode]));let i=we(n).length;return i>0&&r.push(Bt(e,i)),r}function Ut(e,t){let n=t.feishu,r=n.connectionMode===`webhook`?e.hubConnectionWebhook:e.hubConnectionWebsocket,i=[e.hubSummaryConnection.replace(`{{mode}}`,r)],a=se(n).length;return a>0&&i.push(Bt(e,a)),i}function Wt(e,t){return t[e]}function Gt(e){let{id:t,form:n,connected:r,pairingSummary:i,ch:a}=e,o=n.telegram,s=n.weixin,c=n.feishu,l=t===`telegram`?K(o):t===`weixin`?G(s):q(c),u=t===`telegram`?o.enabled:t===`weixin`?s.enabled:c.enabled,d=Ye({configured:l,channelEnabled:u,usesPairing:Je(t,t===`telegram`?o:t===`weixin`?s:c),summaryPending:Wt(t,i).pending}),f=Lt(l,u,r);return{id:t,manageable:!0,configured:l,enabled:u,connected:r,status:f,summaryLines:l?t===`telegram`?Vt(a,n):t===`weixin`?Ht(a,n):Ut(a,n):[],pendingPairing:d,primaryAction:Rt(f,d,!0)}}function Kt(e){let{id:t,config:n,statuses:r,ch:i}=e,a=It(n,t),o=Ft(r,t),s=Pt(r,t);return{id:t,manageable:!1,configured:a,enabled:o,connected:s,status:Lt(a,o,s),summaryLines:a?[i.hubExtensionConfiguredHint]:[],pendingPairing:0,primaryAction:`manage`}}function qt(e){return L(e.id)?Gt({id:e.id,form:e.form,connected:Pt(e.statuses,e.id),pairingSummary:e.pairingSummary,ch:e.ch}):Kt({id:e.id,config:e.config,statuses:e.statuses,ch:e.ch})}function Jt(e){return e.catalogIds.map(t=>qt({id:t,form:e.form,config:e.config,statuses:e.statuses,pairingSummary:e.pairingSummary,ch:e.ch}))}var Yt=`channels-status`;function Xt(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Zt(e){let t=t=>e(t.detail);return window.addEventListener(Yt,t),()=>window.removeEventListener(Yt,t)}function Qt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Zt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}var $t={telegram:{pending:0,stale:0,atCapacity:!1},feishu:{pending:0,stale:0,atCapacity:!1},weixin:{pending:0,stale:0,atCapacity:!1}};function en(e){let t=(0,Q.c)(8),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!0},t[0]=n):n=t[0];let{data:r,mutate:i,isLoading:a,error:o}=s(e?Qe:null,he,n),c;t[1]===i?c=t[2]:(c=()=>{i()},t[1]=i,t[2]=c);let l=c;et(l,e);let u=r??$t,d;return t[3]!==o||t[4]!==a||t[5]!==l||t[6]!==u?(d={summary:u,isLoading:a,error:o,refresh:l},t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d):d=t[7],d}var tn=3e4;function nn(e){let t=(0,Q.c)(25),{hasToken:n,form:r,ch:i}=e,{data:a,mutate:o}=A(n),{entries:c,mutate:l}=Nt(n,i),u;t[0]===n?u=t[1]:(u=n?X():null,t[0]=n,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!0,refreshInterval:tn},t[2]=d):d=t[2];let{data:f,mutate:p}=s(u,_e,d),m;t[3]===f?m=t[4]:(m=f===void 0?[]:f,t[3]=f,t[4]=m);let h=m,g;t[5]===p?g=t[6]:(g=e=>{let t=Xt(e);if(t){p(t,{revalidate:!1});return}p()},t[5]=p,t[6]=g),Qt(g,n);let{summary:_,refresh:v}=en(n),y;t[7]===c?y=t[8]:(y=c.map(rn),t[7]=c,t[8]=y);let b=y,x=a?.payload?.config,S;bb0:{if(!r||b.length===0){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],S=e;break bb0}let e;t[10]!==b||t[11]!==i||t[12]!==x||t[13]!==r||t[14]!==_||t[15]!==h?(e=Jt({catalogIds:b,form:r,config:x,statuses:h,pairingSummary:_,ch:i}),t[10]=b,t[11]=i,t[12]=x,t[13]=r,t[14]=_,t[15]=h,t[16]=e):e=t[16],S=e}let C=S,w;t[17]!==l||t[18]!==o||t[19]!==p||t[20]!==v?(w=()=>{p(),l(),o(),v()},t[17]=l,t[18]=o,t[19]=p,t[20]=v,t[21]=w):w=t[21];let T=w,E;return t[22]!==C||t[23]!==T?(E={cards:C,refreshAll:T},t[22]=C,t[23]=T,t[24]=E):E=t[24],E}function rn(e){return e.id}var an={form:null,baseline:null,tgAccountsDraft:``,tgAccountsError:``,wxAccountsDraft:``,wxAccountsError:``,feishuAccountsDraft:``,feishuAccountsError:``};function on(e){return{tgAccountsDraft:JSON.stringify(e.telegram.accounts??{},null,2),tgAccountsError:``,wxAccountsDraft:JSON.stringify(e.weixin.accounts??{},null,2),wxAccountsError:``,feishuAccountsDraft:JSON.stringify(e.feishu?.accounts??{},null,2),feishuAccountsError:``}}function sn(e,t){switch(t.type){case`reset`:return an;case`load`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`commitSaved`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`discard`:{if(!e.baseline)return e;let t=structuredClone(e.baseline);return{form:t,baseline:e.baseline,...on(t)}}case`updateTelegram`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,...t.patch}}}:e;case`updateWeixin`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,...t.patch}}}:e;case`updateFeishu`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,...t.patch}}}:e;case`updateChannelAgentRoute`:{if(!e.form)return e;let n=t.channel===`telegram`?`telegram`:t.channel===`weixin`?`weixin`:`feishu`;return{...e,form:{...e.form,channelAgentRoutes:{...e.form.channelAgentRoutes,[n]:{...e.form.channelAgentRoutes[n],[t.accountId]:t.agentId.trim().toLowerCase()}}}}}case`setTgAccountsDraft`:return{...e,tgAccountsDraft:t.value};case`setWxAccountsDraft`:return{...e,wxAccountsDraft:t.value};case`setFeishuAccountsDraft`:return{...e,feishuAccountsDraft:t.value};case`setTgAccountsError`:return{...e,tgAccountsError:t.value};case`setWxAccountsError`:return{...e,wxAccountsError:t.value};case`setFeishuAccountsError`:return{...e,feishuAccountsError:t.value};case`applyTgAccounts`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,accounts:t.accounts}},tgAccountsError:``}:e;case`applyWxAccounts`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,accounts:t.accounts}},wxAccountsError:``}:e;case`applyFeishuAccounts`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,accounts:t.accounts}},feishuAccountsError:``}:e;case`restoreForm`:return{...e,form:structuredClone(t.payload)}}}function cn(){let e=i(e=>e.language),t=a(e),n=t.channelsSettings,r=!!h(e=>e.token),o=(0,Z.useRef)(!1),[c,l]=(0,Z.useReducer)(sn,an),[u,d]=(0,Z.useState)({hasToken:r,parsed:null}),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(!1),[L,z]=(0,Z.useState)(!1),{data:ee}=s(r?`gateway-chat-agents-ch`:null,R,{revalidateOnFocus:!1}),{data:B,error:V,isLoading:H,mutate:U}=A(r),te=(0,Z.useMemo)(()=>B?.payload?.config===void 0?null:ge(B.payload.config),[B]);(r!==u.hasToken||te!==u.parsed)&&(d({hasToken:r,parsed:te}),r?te!==null&&!o.current&&(l({type:`load`,payload:te}),v(!1)):(o.current=!1,l({type:`reset`}),v(!1)));let{form:W,baseline:G,tgAccountsDraft:K,tgAccountsError:re,wxAccountsDraft:q,wxAccountsError:ie,feishuAccountsDraft:J,feishuAccountsError:Y}=c,ae=(0,Z.useMemo)(()=>!W||!G?!1:JSON.stringify(W)!==JSON.stringify(G),[W,G]),oe=!!(r&&H&&B===void 0&&!V),se=V instanceof Error?V.message:V?String(V):null,ce=(0,Z.useCallback)((e,t,n)=>{o.current=!0,l({type:`updateChannelAgentRoute`,channel:e,accountId:t,agentId:n})},[]),le=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateTelegram`,patch:e})},[]),ue=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateWeixin`,patch:e})},[]),de=(0,Z.useCallback)(e=>{o.current=!0,l({type:`updateFeishu`,patch:e})},[]),fe=(0,Z.useCallback)(async()=>{if(!W||f)return!1;p(!0),g(null),v(!1);try{let e=await pe(W);return o.current=!1,l({type:`commitSaved`,payload:e}),v(!0),window.setTimeout(()=>v(!1),2500),!0}catch(e){return g(e instanceof Error?e.message:n.saveError),!1}finally{p(!1)}},[W,f,n.saveError]),me=(0,Z.useCallback)(()=>{G&&(o.current=!1,l({type:`discard`}),g(null),v(!1))},[G]),he=(0,Z.useCallback)(async(e,t)=>{if(!W||f)return;let r=W,i=e===`weixin`?{...W,weixin:{...W.weixin,enabled:t}}:e===`telegram`?{...W,telegram:{...W.telegram,enabled:t}}:{...W,feishu:{...W.feishu,enabled:t}};o.current=!0,l(e===`weixin`?{type:`updateWeixin`,patch:{enabled:t}}:e===`telegram`?{type:`updateTelegram`,patch:{enabled:t}}:{type:`updateFeishu`,patch:{enabled:t}}),p(!0),g(null);try{let e=await pe(i);o.current=!1,l({type:`commitSaved`,payload:e})}catch(e){g(e instanceof Error?e.message:n.saveError),o.current=!0,l({type:`restoreForm`,payload:r})}finally{p(!1)}},[W,f,n.saveError]),_e=(0,Z.useCallback)(async()=>{let e=W?ne(W.telegram):``;e&&await x(e)&&(P(!0),window.setTimeout(()=>P(!1),2e3))},[W]),ve=(0,Z.useCallback)(e=>{de({appId:e.appId,domain:e.domain,enabled:!0}),U(),C(n.feishuQrSetupSuccess),window.setTimeout(()=>C(null),4e3)},[de,U,n.feishuQrSetupSuccess]),ye=(0,Z.useCallback)(async()=>{let e=W?.feishu?.appSecret;e&&await x(e)&&(I(!0),window.setTimeout(()=>I(!1),2e3))},[W]),be=(0,Z.useCallback)(async()=>{let e=W?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await x(JSON.stringify(t,null,2))&&(z(!0),window.setTimeout(()=>z(!1),2e3))},[W]);return{language:e,m:t,ch:n,hasToken:r,loading:oe,fetchError:se,mutate:U,form:W,baseline:G,dirty:ae,saving:f,error:m,saveOk:_,weixinSuccessBanner:y,setWeixinSuccessBanner:b,feishuSetupSuccessBanner:S,tgAdvanced:w,setTgAdvanced:T,showToken:E,setShowToken:D,showFeishuSecret:O,setShowFeishuSecret:k,showFeishuWebhookSecrets:j,setShowFeishuWebhookSecrets:M,copied:N,feishuCopied:F,feishuWebhookCopied:L,tgAccountsDraft:K,setTgAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setTgAccountsDraft`,value:e})},[]),tgAccountsError:re,wxAccountsDraft:q,setWxAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setWxAccountsDraft`,value:e})},[]),wxAccountsError:ie,feishuAccountsDraft:J,setFeishuAccountsDraft:(0,Z.useCallback)(e=>{l({type:`setFeishuAccountsDraft`,value:e})},[]),feishuAccountsError:Y,chatAgents:ee,updateChannelAgentRoute:ce,updateTelegram:le,updateWeixin:ue,updateFeishu:de,save:fe,discard:me,toggleChannelEnabled:he,copyToken:_e,handleFeishuQrSetupSuccess:ve,copyFeishuSecret:ye,copyFeishuWebhookConfig:be,onTgAccountsBlur:(0,Z.useCallback)(()=>{if(!W)return;let e=K.trim();if(!e){o.current=!0,l({type:`applyTgAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyTgAccounts`,accounts:t})}catch(e){l({type:`setTgAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[W,K,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Z.useCallback)(()=>{if(!W)return;let e=q.trim();if(!e){o.current=!0,l({type:`applyWxAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyWxAccounts`,accounts:t})}catch(e){l({type:`setWxAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[W,q,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Z.useCallback)(()=>{if(!W)return;let e=J.trim();if(!e){o.current=!0,l({type:`applyFeishuAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,l({type:`applyFeishuAccounts`,accounts:t})}catch(e){l({type:`setFeishuAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[W,J,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Z.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Z.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Z.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Z.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}var ln={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},un={sessionKey:null,qrcodeUrl:null};function dn({ch:e,onLoginSuccess:t,onOpenChange:n,closeOnLoginSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=C(()=>de().then(e=>({sessionKey:e.sessionKey,qrcodeUrl:e.qrcodeUrl})),[a],{initial:un,errorData:un}),m=p.data.sessionKey,h=p.data.qrcodeUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(()=>{u(null),c(null),o(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let t=!1,n,i=async()=>{try{let i=await ye(m);if(t)return;if(i.phase===`polling`){p.setData(e=>({...e,qrcodeUrl:i.qrcodeUrl})),c(i.qrStatus===`scaned`?e.weixinQrLoginScanned:null);return}if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p.setData(un),i.ok?(r&&f.current(!1),await d.current()):u(i.message);return}i.phase===`unknown`&&c(null)}catch(e){t||(n!==void 0&&window.clearInterval(n),u(e instanceof Error?e.message:`Request failed`),p.setData(un))}};return n=window.setInterval(()=>void i(),2e3),i(),()=>{t=!0,n!==void 0&&window.clearInterval(n)}},[m,e.weixinQrLoginScanned,r,p.setData]);let b=C(()=>pt.toDataURL(h,ln),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,w=!!(h&&m),T=!v&&!w;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.weixinQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.weixinQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(w||T)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:z(`min-h-[1.25rem] text-center text-sm`,s&&!T?`text-accent`:`text-fg-muted`),children:T?e.weixinQrLoginBusy:s??`\xA0`}),(0,$.jsxs)(`div`,{className:z(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,T&&`bg-surface-muted/40 dark:bg-surface-base`),children:[T?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,w&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,w&&h&&!v&&!x&&!S&&!T?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.weixinQrEncoding}):null,w&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.weixinQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(D,{className:`size-3 shrink-0`}),e.weixinQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(V,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:y,children:g?e.weixinQrLoginBusy:e.weixinQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function fn(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onLoginSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnLoginSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(mt,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==a||t[12]!==r||t[13]!==n?(v=n?(0,$.jsx)(dn,{ch:i,onLoginSuccess:a,onOpenChange:r,closeOnLoginSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=a,t[12]=r,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.weixinQrModalCloseAria||t[16]!==i.weixinQrModalSubtitle||t[17]!==i.weixinQrModalTitle||t[18]!==i.weixinSubtitle||t[19]!==i.weixinTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(Le,{presentation:h,open:n,onOpenChange:r,title:i.weixinTitle,description:i.weixinSubtitle,srTitle:i.weixinQrModalTitle,srDescription:i.weixinQrModalSubtitle,closeAriaLabel:i.weixinQrModalCloseAria,wide:!0,footer:_,children:v}),t[15]=i.weixinQrModalCloseAria,t[16]=i.weixinQrModalSubtitle,t[17]=i.weixinQrModalTitle,t[18]=i.weixinSubtitle,t[19]=i.weixinTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function pn(e){let t=(0,Q.c)(108),{wx:n,updateWeixin:r,ch:i,streamOpts:a,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}=e,h;t[0]===i.weixinAllowFrom?h=t[1]:(h=(0,$.jsx)(Y,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=g):g=t[2];let _;t[3]===n.allowFrom?_=t[4]:(_=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=_);let v;t[5]===r?v=t[6]:(v=e=>r({allowFrom:e.target.value.split(/[,\n]/).flatMap(mn)}),t[5]=r,t[6]=v);let y;t[7]!==_||t[8]!==v?(y=(0,$.jsx)(`textarea`,{className:g,rows:2,placeholder:`wxid_..., openid_...`,value:_,onChange:v}),t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===i.weixinAllowFromDesc?b=t[11]:(b=(0,$.jsx)(oe,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=b);let x;t[12]!==h||t[13]!==y||t[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y,b]}),t[12]=h,t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===r?S=t[17]:(S=e=>r({streamMode:e}),t[16]=r,t[17]=S);let C;t[18]!==i.streamMode||t[19]!==a||t[20]!==S||t[21]!==n.streamMode?(C=(0,$.jsx)(ae,{label:i.streamMode,value:n.streamMode,onChange:S,options:a}),t[18]=i.streamMode,t[19]=a,t[20]=S,t[21]=n.streamMode,t[22]=C):C=t[22];let w;t[23]===i.historyLimit?w=t[24]:(w=(0,$.jsx)(Y,{children:i.historyLimit}),t[23]=i.historyLimit,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=J(),t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[26]=r,t[27]=E);let D;t[28]!==E||t[29]!==n.historyLimit?(D=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:T,value:n.historyLimit,onChange:E}),t[28]=E,t[29]=n.historyLimit,t[30]=D):D=t[30];let O;t[31]!==w||t[32]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,D]}),t[31]=w,t[32]=D,t[33]=O):O=t[33];let k;t[34]===i.textChunkLimit?k=t[35]:(k=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[34]=i.textChunkLimit,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=J(),t[36]=A):A=t[36];let j;t[37]===r?j=t[38]:(j=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[37]=r,t[38]=j);let M;t[39]!==j||t[40]!==n.textChunkLimit?(M=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:A,value:n.textChunkLimit,onChange:j}),t[39]=j,t[40]=n.textChunkLimit,t[41]=M):M=t[41];let N;t[42]!==k||t[43]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,M]}),t[42]=k,t[43]=M,t[44]=N):N=t[44];let P;t[45]!==O||t[46]!==N?(P=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[O,N]}),t[45]=O,t[46]=N,t[47]=P):P=t[47];let F;t[48]===i.weixinRouteTag?F=t[49]:(F=(0,$.jsx)(Y,{children:i.weixinRouteTag}),t[48]=i.weixinRouteTag,t[49]=F);let I;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(I=J(),t[50]=I):I=t[50];let L;t[51]===r?L=t[52]:(L=e=>r({routeTag:e.target.value}),t[51]=r,t[52]=L);let R;t[53]!==i.routeTagPlaceholder||t[54]!==L||t[55]!==n.routeTag?(R=(0,$.jsx)(`input`,{className:I,value:n.routeTag,onChange:L,placeholder:i.routeTagPlaceholder}),t[53]=i.routeTagPlaceholder,t[54]=L,t[55]=n.routeTag,t[56]=R):R=t[56];let ee;t[57]===i.weixinRouteTagDesc?ee=t[58]:(ee=(0,$.jsx)(oe,{children:i.weixinRouteTagDesc}),t[57]=i.weixinRouteTagDesc,t[58]=ee);let B;t[59]!==F||t[60]!==R||t[61]!==ee?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[F,R,ee]}),t[59]=F,t[60]=R,t[61]=ee,t[62]=B):B=t[62];let V;t[63]===r?V=t[64]:(V=e=>r({debug:e.target.checked}),t[63]=r,t[64]=V);let H;t[65]!==V||t[66]!==n.debug?(H=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:V}),t[65]=V,t[66]=n.debug,t[67]=H):H=t[67];let U;t[68]!==i.weixinDebug||t[69]!==H?(U=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[H,i.weixinDebug]}),t[68]=i.weixinDebug,t[69]=H,t[70]=U):U=t[70];let te;t[71]===i.weixinDebugDesc?te=t[72]:(te=(0,$.jsx)(oe,{children:i.weixinDebugDesc}),t[71]=i.weixinDebugDesc,t[72]=te);let W;t[73]===i.weixinAccountsJson?W=t[74]:(W=(0,$.jsx)(Y,{children:i.weixinAccountsJson}),t[73]=i.weixinAccountsJson,t[74]=W);let G;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(G=z(J(),`min-h-[140px] resize-y font-mono text-xs`),t[75]=G):G=t[75];let ne;t[76]===s?ne=t[77]:(ne=e=>s(e.target.value),t[76]=s,t[77]=ne);let K;t[78]!==l||t[79]!==ne||t[80]!==o?(K=(0,$.jsx)(`textarea`,{className:G,spellCheck:!1,value:o,onChange:ne,onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[78]=l,t[79]=ne,t[80]=o,t[81]=K):K=t[81];let re;t[82]!==i.weixinAccountsJsonDesc||t[83]!==c?(re=c?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,$.jsx)(oe,{children:i.weixinAccountsJsonDesc}),t[82]=i.weixinAccountsJsonDesc,t[83]=c,t[84]=re):re=t[84];let q;t[85]!==W||t[86]!==K||t[87]!==re?(q=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[W,K,re]}),t[85]=W,t[86]=K,t[87]=re,t[88]=q):q=t[88];let ie;t[89]===n?ie=t[90]:(ie=we(n),t[89]=n,t[90]=ie);let se;t[91]!==f||t[92]!==i||t[93]!==u||t[94]!==d||t[95]!==p||t[96]!==m||t[97]!==ie?(se=(0,$.jsx)(Ve,{accountIds:ie,routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:i}),t[91]=f,t[92]=i,t[93]=u,t[94]=d,t[95]=p,t[96]=m,t[97]=ie,t[98]=se):se=t[98];let ce;return t[99]!==P||t[100]!==B||t[101]!==U||t[102]!==te||t[103]!==q||t[104]!==se||t[105]!==x||t[106]!==C?(ce=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[x,C,P,B,U,te,q,se]}),t[99]=P,t[100]=B,t[101]=U,t[102]=te,t[103]=q,t[104]=se,t[105]=x,t[106]=C,t[107]=ce):ce=t[107],ce}function mn(e){let t=e.trim();return t?[t]:[]}function hn(e){let t=(0,Q.c)(60),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,form:d,chatAgents:f,onAgentRouteChange:p,saving:m,language:h,dialogOpen:g,pairingFocus:_}=e,v=_===void 0?!1:_,y;t[0]===r?y=t[1]:(y=we(r),t[0]=r,t[1]=y);let b=y,x;t[2]===b?x=t[3]:(x=b.length>0?b:[`default`],t[2]=b,t[3]=x);let S=x,C=(0,Z.useRef)(null),w,T;t[4]===v?(w=t[5],T=t[6]):(w=()=>{if(!v)return;let e=C.current;e&&(e.open=!0);let t=window.setTimeout(gn,80);return()=>window.clearTimeout(t)},T=[v],t[4]=v,t[5]=w,t[6]=T),(0,Z.useEffect)(w,T);let E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ee,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[7]=E):E=t[7];let D;t[8]===n.advancedShow?D=t[9]:(D=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[E,n.advancedShow]})}),t[8]=n.advancedShow,t[9]=D);let O;t[10]===n.weixinAdvancedHint?O=t[11]:(O=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[10]=n.weixinAdvancedHint,t[11]=O);let k;t[12]===i?k=t[13]:(k=e=>i({enabled:e.target.checked}),t[12]=i,t[13]=k);let A;t[14]!==k||t[15]!==r.enabled?(A=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:k}),t[14]=k,t[15]=r.enabled,t[16]=A):A=t[16];let j;t[17]===n.enableWeixinAria?j=t[18]:(j=(0,$.jsx)(`span`,{children:n.enableWeixinAria}),t[17]=n.enableWeixinAria,t[18]=j);let M;t[19]!==A||t[20]!==j?(M=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[A,j]}),t[19]=A,t[20]=j,t[21]=M):M=t[21];let N;t[22]===i?N=t[23]:(N=e=>i({dmPolicy:e}),t[22]=i,t[23]=N);let P;t[24]!==n.dmPolicy||t[25]!==a||t[26]!==N||t[27]!==r.dmPolicy?(P=(0,$.jsx)(ae,{label:n.dmPolicy,value:r.dmPolicy,onChange:N,options:a}),t[24]=n.dmPolicy,t[25]=a,t[26]=N,t[27]=r.dmPolicy,t[28]=P):P=t[28];let F;t[29]!==n||t[30]!==g||t[31]!==h||t[32]!==S||t[33]!==r?(F=(0,$.jsx)(st,{channel:`weixin`,accountIds:S,channelConfig:r,active:g,ch:n,language:h}),t[29]=n,t[30]=g,t[31]=h,t[32]=S,t[33]=r,t[34]=F):F=t[34];let I;t[35]===f?.items?I=t[36]:(I=f?.items??[],t[35]=f?.items,t[36]=I);let L;t[37]!==n||t[38]!==d.channelAgentRoutes.weixin||t[39]!==d.defaultAgentId||t[40]!==p||t[41]!==u||t[42]!==m||t[43]!==c||t[44]!==o||t[45]!==I||t[46]!==i||t[47]!==r||t[48]!==s||t[49]!==l?(L=(0,$.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,$.jsx)(pn,{wx:r,updateWeixin:i,ch:n,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d.channelAgentRoutes.weixin,defaultAgentId:d.defaultAgentId,agentItems:I,onAgentRouteChange:p,routingDisabled:m})}),t[37]=n,t[38]=d.channelAgentRoutes.weixin,t[39]=d.defaultAgentId,t[40]=p,t[41]=u,t[42]=m,t[43]=c,t[44]=o,t[45]=I,t[46]=i,t[47]=r,t[48]=s,t[49]=l,t[50]=L):L=t[50];let R;t[51]!==M||t[52]!==P||t[53]!==F||t[54]!==L||t[55]!==O?(R=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[O,M,P,F,L]}),t[51]=M,t[52]=P,t[53]=F,t[54]=L,t[55]=O,t[56]=R):R=t[56];let z;return t[57]!==R||t[58]!==D?(z=(0,$.jsxs)(`details`,{ref:C,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[D,R]}),t[57]=R,t[58]=D,t[59]=z):z=t[59],z}function gn(){return nt(`weixin`)}function _n(){let e=I(),{channelId:t}=H(),[n]=M(),{language:r,m:i,ch:a,hasToken:o,loading:s,fetchError:c,mutate:l,form:u,baseline:d,dirty:f,saving:p,error:m,saveOk:h,weixinSuccessBanner:g,setWeixinSuccessBanner:_,feishuSetupSuccessBanner:v,tgAdvanced:y,setTgAdvanced:b,showToken:x,setShowToken:S,showFeishuSecret:C,setShowFeishuSecret:w,showFeishuWebhookSecrets:T,setShowFeishuWebhookSecrets:E,copied:k,feishuCopied:A,feishuWebhookCopied:N,tgAccountsDraft:P,setTgAccountsDraft:F,tgAccountsError:R,wxAccountsDraft:z,setWxAccountsDraft:ee,wxAccountsError:te,feishuAccountsDraft:W,setFeishuAccountsDraft:G,feishuAccountsError:ne,chatAgents:K,updateChannelAgentRoute:re,updateTelegram:q,updateWeixin:ie,updateFeishu:J,save:Y,discard:ae,toggleChannelEnabled:oe,copyToken:se,handleFeishuQrSetupSuccess:ce,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,onTgAccountsBlur:de,onWxAccountsBlur:fe,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e}=cn(),[ve,ye]=(0,Z.useState)(!1),{entries:be}=Nt(o,a),xe=(0,Z.useMemo)(()=>new Map(be.map(e=>[e.id,e])),[be]),X=U(t),Se=n.get(`pairing`)===`1`,Ce=!!(X&&xe.has(X)),{cards:we,refreshAll:Q}=nn({hasToken:o,form:u,ch:a}),Te=X?xe.get(X):void 0,Ee=X?we.find(e=>e.id===X):void 0;(0,Z.useEffect)(()=>{!X||be.length===0||xe.has(X)||e(B,{replace:!0})},[X,xe,be.length,e]);let De=(0,Z.useCallback)((t,n)=>{e(j(t,{pairing:n?.scrollToPairing}))},[e]),Oe=(0,Z.useCallback)(()=>{e(B)},[e]),ke=(0,Z.useCallback)(e=>{e||Oe()},[Oe]),je=(0,Z.useCallback)(async()=>{await l(),_(a.weixinQrLoginSuccess),window.setTimeout(()=>_(null),4e3)},[a.weixinQrLoginSuccess,l,_]),Me=(0,Z.useCallback)(async()=>{ye(!0);try{Q(),await l()}finally{ye(!1)}},[l,Q]);if(!o)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:Me}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})]})]});if(s)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:Me}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`h-7 w-40 animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`}),(0,$.jsx)(`div`,{className:`h-4 w-full max-w-md animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`})]}),(0,$.jsx)(Pe,{}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading})]})]});if(!u)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:Me}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??c??a.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void l(),children:a.retry})]})]});let Ne=u.weixin,Fe=Se&&X===`weixin`,Ie=Se&&X===`feishu`,Le=(0,$.jsx)(hn,{ch:a,wx:Ne,updateWeixin:ie,dmOpts:me,streamOpts:_e,wxAccountsDraft:z,setWxAccountsDraft:ee,wxAccountsError:te,onWxAccountsBlur:fe,form:u,chatAgents:K,onAgentRouteChange:(e,t)=>re(`weixin`,e,t),saving:p,language:r,dialogOpen:Ce&&X===`weixin`,pairingFocus:Fe}),Re=(0,$.jsx)(ct,{ch:a,form:u,baseline:d,showFeishuSecret:C,setShowFeishuSecret:w,showFeishuWebhookSecrets:T,setShowFeishuWebhookSecrets:E,feishuCopied:A,feishuWebhookCopied:N,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,updateFeishu:J,updateChannelAgentRoute:re,feishuAccountsDraft:W,setFeishuAccountsDraft:G,feishuAccountsError:ne,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,chatAgents:K,saving:p,language:r,dialogOpen:Ce&&X===`feishu`,pairingFocus:Ie});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:Me}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.subtitle}),(0,$.jsxs)(`a`,{href:O(r,`channels`),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[a.docsLink,(0,$.jsx)(D,{className:`size-3.5`})]})]}),m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,g?(0,$.jsx)(`p`,{className:`text-xs text-accent`,children:g}):null,v?(0,$.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:v}):null,ve?(0,$.jsx)(Pe,{count:Math.max(be.length,3)}):(0,$.jsx)(Ae,{catalog:be,cards:we,ch:a,saving:p,onOpenChannel:De,onToggleChannel:(e,t)=>{L(e)&&oe(e,t)}}),X===`weixin`?(0,$.jsx)(fn,{open:Ce,onOpenChange:ke,ch:a,onLoginSuccess:je,moreSettings:Le,settingsDirty:f,settingsSaving:p,onSettingsDiscard:ae,onSettingsSave:Y}):null,X===`telegram`?(0,$.jsx)(St,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,form:u,baseline:d,tgAdvanced:y,setTgAdvanced:b,showToken:x,setShowToken:S,copied:k,copyToken:se,updateTelegram:q,updateChannelAgentRoute:re,tgAccountsDraft:P,setTgAccountsDraft:F,tgAccountsError:R,onTgAccountsBlur:de,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e,chatAgents:K,saving:p,dirty:f,save:Y,discard:ae,language:r,scrollToPairingOnOpen:Se,closeOnSave:!1}):null,X===`feishu`?(0,$.jsx)(vt,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,onSetupSuccess:ce,moreSettings:Re,settingsDirty:f,settingsSaving:p,onSettingsDiscard:ae,onSettingsSave:Y}):null,Te&&Ee&&!Te.manageable?(0,$.jsx)(ze,{open:Ce,onOpenChange:e=>{e||Oe()},entry:Te,vm:Ee,ch:a,language:r}):null]})]})}function vn(e){let t=(0,Q.c)(11),{hasToken:n,ch:r,refreshing:i,saveOk:a,onRefresh:o}=e,s=v(bn),c=v(yn),l;t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==a?(l=(0,$.jsx)(Be,{ch:r,refreshing:i,saveOk:a,onRefresh:o}),t[0]=r,t[1]=o,t[2]=i,t[3]=a,t[4]=l):l=t[4];let u=l,d,f;return t[5]!==u||t[6]!==c||t[7]!==n||t[8]!==s?(d=()=>n?(s({startExtra:null,main:null,end:u}),()=>c()):(c(),()=>c()),f=[u,c,n,s],t[5]=u,t[6]=c,t[7]=n,t[8]=s,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Z.useLayoutEffect)(d,f),null}function yn(e){return e.clearPageHeader}function bn(e){return e.setPageHeader}export{_n as ChannelsSettingsPanel};
@@ -1 +0,0 @@
1
- import{t as e}from"./url-Dd8Q7kZZ.js";import{t}from"./fetch-DRqwef_Q.js";import{j as n}from"./index-Cu7bKuUi.js";function r(e){let t=e.payload;return t.kind===`systemEvent`?t.text??``:t.message??``}function i(e){if(!e||typeof e!=`object`)return``;let t=e.agents?.defaults?.model;if(t==null)return``;if(typeof t==`string`)return t.trim();if(typeof t==`object`&&t&&`primary`in t){let e=t.primary;return typeof e==`string`?e.trim():``}return``}async function a(e,n){let r=await t(e,n),i=await r.json().catch(()=>({}));if(!r.ok){let e=typeof i.error==`string`?i.error:`HTTP ${r.status}`;throw Error(e)}return i}async function o(){return(await a(e(`/api/cron`))).jobs||[]}async function s(n){let r=await t(e(`/api/cron/${encodeURIComponent(n)}`));if(r.status===404)return null;let i=await r.json().catch(()=>({}));if(!r.ok)throw Error(typeof i.error==`string`?i.error:`HTTP ${r.status}`);return i.job??null}async function c(t,n){return a(e(`/api/cron`),{method:`POST`,body:JSON.stringify({schedule:t,...n})})}async function l(t,n){return(await a(e(`/api/cron/${encodeURIComponent(t)}`),{method:`PATCH`,body:JSON.stringify(n)})).updated}async function u(t){return(await a(e(`/api/cron/${encodeURIComponent(t)}`),{method:`DELETE`})).removed}async function d(t,n){return(await a(e(`/api/cron/${encodeURIComponent(t)}/toggle`),{method:`POST`,body:JSON.stringify({enabled:n})})).toggled}async function f(t){await a(e(`/api/cron/${encodeURIComponent(t)}/run`),{method:`POST`})}async function p(t,n=10){return(await a(e(`/api/cron/${encodeURIComponent(t)}/history?limit=${n}`))).history||[]}async function m(t=40){return(await a(e(`/api/cron/runs/history?limit=${t}`))).runs||[]}async function h(){return(await a(e(`/api/channels/status`))).payload?.channels||[]}async function g(){return(await n()).map(e=>({id:e.id,name:e.name,provider:e.provider}))}async function _(){let t=(await a(e(`/api/config`))).payload?.config;return{model:i(t)}}async function v(t){return(await a(e(`/api/sessions/chat-ids${t?`?channel=${encodeURIComponent(t)}`:``}`))).payload?.chatIds||[]}export{_ as a,g as c,u as d,f,h as i,v as l,l as m,r as n,p as o,d as p,m as r,s,c as t,o as u};
@@ -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}from"./url-Dd8Q7kZZ.js";import{a as o,i as s,n as c,o as l,s as u,t as d}from"./dist-BTWC-BTN.js";import{i as f}from"./theme-store-CZOh1nT3.js";import{a as p}from"./fetch-DRqwef_Q.js";import{$n as m,Bn as h,Bt as g,Ci as _,Ei as v,F as y,Gi as b,Hn as x,On as S,Pi as C,Rr as w,Vr as T,Vt as E,Xn as D,Zn as O,bn as k,c as A,ca as j,ci as M,hn as N,i as P,ii as F,ir as I,l as L,mi as R,mn as z,nr as B,oa as V,s as H,tr as U,u as W,xn as G,xr as K}from"./index-Cu7bKuUi.js";import{a as q,c as J,d as Y,i as X,l as ee,n as te,o as ne,s as re,t as ie,u as ae}from"./cron-dreaming-jobs-DueM3rBz.js";import{a as oe,c as se,d as ce,f as le,i as ue,l as de,m as fe,n as pe,o as me,p as he,r as ge,s as _e,t as ve,u as ye}from"./cron-api-0h_QT8U3.js";import{s as be,t as xe}from"./heartbeat-config-api-ZRb8qhuz.js";import{a as Se,i as Ce,n as we,r as Te,t as Ee}from"./dist-Cmjp2APP.js";var Z=e(t(),1),Q=n(),$=r();function De(e){let t=(0,Q.c)(25),{open:n,onOpenChange:r,action:i,c:a,onDismiss:d,onConfirm:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),t[0]=p):p=t[0];let m=i===`delete`?a.delete:a.runNow,h;t[1]===m?h=t[2]:(h=(0,$.jsx)(u,{className:`text-base font-semibold text-fg`,children:m}),t[1]=m,t[2]=h);let g=i===`delete`?a.confirmDelete:a.confirmRun,_;t[3]===g?_=t[4]:(_=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:g}),t[3]=g,t[4]=_);let v;t[5]!==a.cancel||t[6]!==d?(v=(0,$.jsx)(U,{type:`button`,variant:`secondary`,onClick:d,children:a.cancel}),t[5]=a.cancel,t[6]=d,t[7]=v):v=t[7];let y=i===`delete`?`bg-red-600 hover:bg-red-700`:void 0,b;t[8]===f?b=t[9]:(b=()=>void f(),t[8]=f,t[9]=b);let x=i===`delete`?a.delete:a.runNow,S;t[10]!==y||t[11]!==b||t[12]!==x?(S=(0,$.jsx)(U,{type:`button`,variant:`primary`,className:y,onClick:b,children:x}),t[10]=y,t[11]=b,t[12]=x,t[13]=S):S=t[13];let C;t[14]!==S||t[15]!==v?(C=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[v,S]}),t[14]=S,t[15]=v,t[16]=C):C=t[16];let w;t[17]!==C||t[18]!==h||t[19]!==_?(w=(0,$.jsxs)(o,{children:[p,(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:[h,_,C]})})]}),t[17]=C,t[18]=h,t[19]=_,t[20]=w):w=t[20];let T;return t[21]!==r||t[22]!==n||t[23]!==w?(T=(0,$.jsx)(l,{open:n,onOpenChange:r,children:w}),t[21]=r,t[22]=n,t[23]=w,t[24]=T):T=t[24],T}var Oe=`*/5 * * * *`;function ke(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function Ae(e){let t=ke(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function je(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function Me(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function Ne(e){return B(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,D,e&&`cursor-not-allowed opacity-60`)}function Pe(){return B(m,O)}var Fe=B(m,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),Ie=B(m,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function Le(e){let t=(0,Q.c)(55),{open:n,onDismiss:r,detailJob:i,detailLoading:a,detailHistory:f,c:p,chatWorkingDirNotSet:m,statusLabels:h}=e,_;t[0]===r?_=t[1]:(_=e=>{e||r()},t[0]=r,t[1]=_);let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=v):v=t[2];let y;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(y=B(`xopc-drawer-right fixed right-0 top-0 z-[60] flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,`dark:border-edge`),t[3]=y):y=t[3];let b;t[4]!==i?.id||t[5]!==i?.name?(b=i?.name?.trim()||i?.id||`—`,t[4]=i?.id,t[5]=i?.name,t[6]=b):b=t[6];let x;t[7]===b?x=t[8]:(x=(0,$.jsx)(u,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:b}),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(I,{className:`size-5`,strokeWidth:1.75}),t[9]=S):S=t[9];let C;t[10]===p.close?C=t[11]:(C=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.close,children:S})}),t[10]=p.close,t[11]=C);let w;t[12]!==x||t[13]!==C?(w=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[x,C]}),t[12]=x,t[13]=C,t[14]=w):w=t[14];let T;t[15]!==p.agentProfile||t[16]!==p.agentProfileDefault||t[17]!==p.channelLocal||t[18]!==p.colChat||t[19]!==p.colDetail||t[20]!==p.colDuration||t[21]!==p.colStarted||t[22]!==p.deliveryLocalOnly||t[23]!==p.deliveryTarget||t[24]!==p.deliveryTargetLocalChannel||t[25]!==p.detailRunHistory||t[26]!==p.disabled||t[27]!==p.enabled||t[28]!==p.messageLabel||t[29]!==p.mode||t[30]!==p.modeAgentOption||t[31]!==p.modeDirectOption||t[32]!==p.nextRun||t[33]!==p.noRunsYet||t[34]!==p.openChat||t[35]!==p.openChatTitle||t[36]!==p.scheduleLabel||t[37]!==p.status||t[38]!==p.timeLabels||t[39]!==p.workingDirectoryLabel||t[40]!==m||t[41]!==f||t[42]!==i||t[43]!==a||t[44]!==h?(T=a?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(F,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.scheduleLabel}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:(0,$.jsx)(`code`,{children:i.schedule})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.messageLabel}),(0,$.jsx)(`dd`,{className:`mt-1 min-w-0 break-words text-fg`,children:(0,$.jsx)(g,{content:pe(i),compact:!0,className:`text-sm`})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.mode}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:i.sessionTarget===`isolated`?p.modeAgentOption:p.modeDirectOption})]}),i.sessionTarget===`isolated`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.agentProfile}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:i.agentId?.trim()?i.agentId.trim():p.agentProfileDefault})]}):null,i.sessionTarget===`isolated`?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.workingDirectoryLabel}),(0,$.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:i.workingDirectory?.trim()?i.workingDirectory.trim():m})]}):null,i.delivery?.channel===`local`||i.sessionTarget===`isolated`&&!i.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.deliveryTarget}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:i.delivery?.channel===`local`?p.deliveryTargetLocalChannel:p.deliveryLocalOnly})]}):i.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.deliveryTarget}),(0,$.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,$.jsx)(`code`,{className:`text-xs`,children:i.delivery?.channel??``}),` → `,q(i,p.channelLocal)]})]}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.status}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:i.enabled?p.enabled:p.disabled})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:p.nextRun}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:i.next_run?re(i.next_run,p.timeLabels):`—`})]})]}),(0,$.jsx)(`h3`,{className:`mt-6 text-sm font-semibold text-fg`,children:p.detailRunHistory}),f.length===0?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:p.noRunsYet}):(0,$.jsx)(`div`,{className:`mt-2 overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-edge text-fg-muted`,children:[(0,$.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:p.colStarted}),(0,$.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:p.status}),(0,$.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:p.colDuration}),(0,$.jsx)(`th`,{className:`py-1.5 pr-2 font-medium`,children:p.colDetail}),(0,$.jsx)(`th`,{className:`py-1.5 font-medium`,children:p.colChat})]})}),(0,$.jsx)(`tbody`,{children:f.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-edge/60`,children:[(0,$.jsx)(`td`,{className:`whitespace-nowrap py-1.5 pr-2 text-fg`,children:(0,$.jsx)(`time`,{dateTime:e.startedAt,children:ae(e.startedAt)})}),(0,$.jsx)(`td`,{className:`py-1.5 pr-2`,children:(0,$.jsx)(`span`,{className:B(`inline-flex rounded px-1.5 py-0.5 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`),children:X(e.status,h)})}),(0,$.jsx)(`td`,{className:`py-1.5 pr-2 text-fg-muted`,children:ne(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-[8rem] truncate py-1.5 pr-2 text-fg-muted`,title:e.summary||e.error||``,children:Y(e.summary||e.error,120)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap py-1.5`,children:e.sessionKey?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:p.openChatTitle,"aria-label":p.openChatTitle,onClick:()=>Me(e.sessionKey),children:p.openChat}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})})]}):null,t[15]=p.agentProfile,t[16]=p.agentProfileDefault,t[17]=p.channelLocal,t[18]=p.colChat,t[19]=p.colDetail,t[20]=p.colDuration,t[21]=p.colStarted,t[22]=p.deliveryLocalOnly,t[23]=p.deliveryTarget,t[24]=p.deliveryTargetLocalChannel,t[25]=p.detailRunHistory,t[26]=p.disabled,t[27]=p.enabled,t[28]=p.messageLabel,t[29]=p.mode,t[30]=p.modeAgentOption,t[31]=p.modeDirectOption,t[32]=p.nextRun,t[33]=p.noRunsYet,t[34]=p.openChat,t[35]=p.openChatTitle,t[36]=p.scheduleLabel,t[37]=p.status,t[38]=p.timeLabels,t[39]=p.workingDirectoryLabel,t[40]=m,t[41]=f,t[42]=i,t[43]=a,t[44]=h,t[45]=T):T=t[45];let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:T}),t[46]=T,t[47]=E);let D;t[48]!==E||t[49]!==w?(D=(0,$.jsxs)(o,{children:[v,(0,$.jsxs)(c,{className:y,"aria-describedby":void 0,children:[w,E]})]}),t[48]=E,t[49]=w,t[50]=D):D=t[50];let O;return t[51]!==n||t[52]!==_||t[53]!==D?(O=(0,$.jsx)(l,{open:n,onOpenChange:_,children:D}),t[51]=n,t[52]=_,t[53]=D,t[54]=O):O=t[54],O}function Re(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=A(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}`),g=i||f.picking,_=o??a.notSet,v;t[5]!==c||t[6]!==f.pick||t[7]!==h||t[8]!==g||t[9]!==_||t[10]!==n?(v=(0,$.jsx)(L,{value:n,onPick:f.pick,disabled:g,placeholder:_,title:h,maxWidthClass:c}),t[5]=c,t[6]=f.pick,t[7]=h,t[8]=g,t[9]=_,t[10]=n,t[11]=v):v=t[11];let y;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==f.picking||t[16]!==m?(y=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]=y):y=t[17];let b;t[18]!==v||t[19]!==y?(b=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[18]=v,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==f.confirmPick||t[22]!==f.hasNativePicker||t[23]!==f.modalOpen||t[24]!==f.setModalOpen||t[25]!==m||t[26]!==a?(x=f.hasNativePicker?null:(0,$.jsx)(P,{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]=x):x=t[27];let S;return t[28]!==b||t[29]!==x?(S=(0,$.jsxs)($.Fragment,{children:[b,x]}),t[28]=b,t[29]=x,t[30]=S):S=t[30],S}function ze(e){let t=(0,Q.c)(164),{open:n,onRequestClose:r,c:i,chatM:a,agentsMessages:f,isDark:p,channels:m,sessionChatIds:h,cronAgentSelectOptions:v,defaultModelResolver:b,formMode:x,formJobId:S,formName:C,onFormNameChange:T,formSchedule:D,onFormScheduleChange:O,formSubmitting:k,formSessionTarget:A,onFormSessionTargetChange:j,formAgentLocalOnly:M,onFormAgentLocalOnlyChange:N,formModel:P,onFormModelUserChange:F,formAgentId:L,onFormAgentIdChange:R,formWorkingDirectory:z,onFormWorkingDirectoryChange:V,formChannel:H,onFormChannelChange:G,formChatId:q,onFormChatIdChange:Y,formMessage:X,onFormMessageChange:ee,formMessageMdMode:te,onSetMessageMdMode:ne,messageEditorNonce:re,needsDeliveryChat:ie,showChannelPicker:ae,canSubmit:oe,onSubmit:se,onRefreshRecipients:ce}=e,le;t[0]===r?le=t[1]:(le=e=>!e&&r(),t[0]=r,t[1]=le);let ue;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=ue):ue=t[2];let de=x===`edit`?i.editJob:i.addJob,fe;t[3]===de?fe=t[4]:(fe=(0,$.jsx)(u,{className:`text-base font-semibold text-fg`,children:de}),t[3]=de,t[4]=fe);let pe;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(I,{className:`size-5`,strokeWidth:1.75}),t[5]=pe):pe=t[5];let me;t[6]===i.close?me=t[7]:(me=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:pe})}),t[6]=i.close,t[7]=me);let he;t[8]!==fe||t[9]!==me?(he=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[fe,me]}),t[8]=fe,t[9]=me,t[10]=he):he=t[10];let ge;t[11]===i.name?ge=t[12]:(ge=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.name}),t[11]=i.name,t[12]=ge);let _e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_e=Ne(),t[13]=_e):_e=t[13];let ve;t[14]===T?ve=t[15]:(ve=e=>T(e.target.value),t[14]=T,t[15]=ve);let ye;t[16]!==i.namePlaceholder||t[17]!==C||t[18]!==ve?(ye=(0,$.jsx)(`input`,{type:`text`,className:_e,value:C,onChange:ve,placeholder:i.namePlaceholder}),t[16]=i.namePlaceholder,t[17]=C,t[18]=ve,t[19]=ye):ye=t[19];let xe;t[20]!==ye||t[21]!==ge?(xe=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[ge,ye]}),t[20]=ye,t[21]=ge,t[22]=xe):xe=t[22];let Se;t[23]!==i.schedulePicker||t[24]!==D||t[25]!==k||t[26]!==O?(Se=(0,$.jsx)(be,{value:D,onChange:O,disabled:k,labels:i.schedulePicker}),t[23]=i.schedulePicker,t[24]=D,t[25]=k,t[26]=O,t[27]=Se):Se=t[27];let Ce;t[28]===i.mode?Ce=t[29]:(Ce=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.mode}),t[28]=i.mode,t[29]=Ce);let we;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(we=Pe(),t[30]=we):we=t[30];let Te;t[31]!==b||t[32]!==P||t[33]!==j?(Te=e=>{let t=e.target.value;j(t,b,P.trim())},t[31]=b,t[32]=P,t[33]=j,t[34]=Te):Te=t[34];let Ee;t[35]===i.modeDirectOption?Ee=t[36]:(Ee=(0,$.jsx)(`option`,{value:`main`,children:i.modeDirectOption}),t[35]=i.modeDirectOption,t[36]=Ee);let Z;t[37]===i.modeAgentOption?Z=t[38]:(Z=(0,$.jsx)(`option`,{value:`isolated`,children:i.modeAgentOption}),t[37]=i.modeAgentOption,t[38]=Z);let De;t[39]!==A||t[40]!==Te||t[41]!==Ee||t[42]!==Z?(De=(0,$.jsxs)(`select`,{className:we,value:A,onChange:Te,children:[Ee,Z]}),t[39]=A,t[40]=Te,t[41]=Ee,t[42]=Z,t[43]=De):De=t[43];let Oe=A===`main`?i.modeDirect:i.modeAgent,ke;t[44]===Oe?ke=t[45]:(ke=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Oe}),t[44]=Oe,t[45]=ke);let Ae;t[46]!==Ce||t[47]!==De||t[48]!==ke?(Ae=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[Ce,De,ke]}),t[46]=Ce,t[47]=De,t[48]=ke,t[49]=Ae):Ae=t[49];let je;t[50]!==f||t[51]!==i.agentLocalOnly||t[52]!==i.agentLocalOnlyHint||t[53]!==i.agentProfile||t[54]!==i.agentProfileDefault||t[55]!==i.agentProfileHint||t[56]!==i.model||t[57]!==i.workingDirectoryHint||t[58]!==i.workingDirectoryLabel||t[59]!==i.workingDirectoryReset||t[60]!==a||t[61]!==v||t[62]!==L||t[63]!==M||t[64]!==P||t[65]!==A||t[66]!==k||t[67]!==z||t[68]!==R||t[69]!==N||t[70]!==F||t[71]!==V?(je=A===`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:i.model}),(0,$.jsx)(W,{value:P,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:F})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.agentProfile}),(0,$.jsxs)(`select`,{className:Pe(),value:L,disabled:k,onChange:e=>R(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:i.agentProfileDefault}),v.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${y(e,f)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.agentProfileHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.workingDirectoryLabel}),(0,$.jsx)(Re,{value:z,onChange:V,disabled:k,wd:a.workingDirectory,placeholder:a.workingDirectory.notSet,maxWidthClass:`max-w-[min(16rem,48vw)]`,clearLabel:i.workingDirectoryReset,onClear:()=>V(``)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.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:B(`ui-checkbox`,`mt-0.5`),checked:M,onChange:e=>N(e.target.checked),"aria-label":i.agentLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:i.agentLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i.agentLocalOnlyHint})]})]})]}):null,t[50]=f,t[51]=i.agentLocalOnly,t[52]=i.agentLocalOnlyHint,t[53]=i.agentProfile,t[54]=i.agentProfileDefault,t[55]=i.agentProfileHint,t[56]=i.model,t[57]=i.workingDirectoryHint,t[58]=i.workingDirectoryLabel,t[59]=i.workingDirectoryReset,t[60]=a,t[61]=v,t[62]=L,t[63]=M,t[64]=P,t[65]=A,t[66]=k,t[67]=z,t[68]=R,t[69]=N,t[70]=F,t[71]=V,t[72]=je):je=t[72];let Me;t[73]!==i.channel||t[74]!==i.channelLocal||t[75]!==i.enterManuallyOrSelect||t[76]!==i.lastActiveLabels||t[77]!==i.noRecentChats||t[78]!==i.noRecentChatsOption||t[79]!==i.recipient||t[80]!==i.recipientPlaceholder||t[81]!==i.refreshList||t[82]!==i.refreshRecipientHint||t[83]!==i.selectRecipient||t[84]!==m||t[85]!==H||t[86]!==q||t[87]!==ie||t[88]!==G||t[89]!==Y||t[90]!==ce||t[91]!==h||t[92]!==ae?(Me=ae?(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:i.channel}),(0,$.jsxs)(`select`,{className:Pe(),value:H,onChange:e=>{let t=e.target.value;G(t)},children:[(0,$.jsx)(`option`,{value:`local`,children:i.channelLocal}),m.map(Be)]})]}),ie?(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:i.recipient}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:i.refreshRecipientHint,onClick:()=>void ce(),children:[(0,$.jsx)(w,{className:`size-3.5`,strokeWidth:1.75}),i.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:B(Ne(),`min-w-0 w-full sm:flex-1`),value:q,onChange:e=>Y(e.target.value),placeholder:i.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:Fe,value:q,onChange:e=>{let t=e.target.value;t&&Y(t)},children:[(0,$.jsx)(`option`,{value:``,children:i.selectRecipient}),h.length>0?h.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:J(e,i.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:i.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:h.length>0?i.enterManuallyOrSelect:i.noRecentChats})]}):null]}):null,t[73]=i.channel,t[74]=i.channelLocal,t[75]=i.enterManuallyOrSelect,t[76]=i.lastActiveLabels,t[77]=i.noRecentChats,t[78]=i.noRecentChatsOption,t[79]=i.recipient,t[80]=i.recipientPlaceholder,t[81]=i.refreshList,t[82]=i.refreshRecipientHint,t[83]=i.selectRecipient,t[84]=m,t[85]=H,t[86]=q,t[87]=ie,t[88]=G,t[89]=Y,t[90]=ce,t[91]=h,t[92]=ae,t[93]=Me):Me=t[93];let Ie;t[94]===i.message?Ie=t[95]:(Ie=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.message}),t[94]=i.message,t[95]=Ie);let Le=te===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`,ze;t[96]===Le?ze=t[97]:(ze=B(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Le),t[96]=Le,t[97]=ze);let He;t[98]===ne?He=t[99]:(He=()=>ne(`edit`),t[98]=ne,t[99]=He);let Ue;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,$.jsx)(K,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[100]=Ue):Ue=t[100];let We;t[101]!==i.messageEdit||t[102]!==ze||t[103]!==He?(We=(0,$.jsxs)(`button`,{type:`button`,className:ze,onClick:He,children:[Ue,i.messageEdit]}),t[101]=i.messageEdit,t[102]=ze,t[103]=He,t[104]=We):We=t[104];let Ge=te===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`,Ke;t[105]===Ge?Ke=t[106]:(Ke=B(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,Ge),t[105]=Ge,t[106]=Ke);let qe;t[107]===ne?qe=t[108]:(qe=()=>ne(`preview`),t[107]=ne,t[108]=qe);let Je;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(Je=(0,$.jsx)(_,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[109]=Je):Je=t[109];let Ye;t[110]!==i.messagePreview||t[111]!==Ke||t[112]!==qe?(Ye=(0,$.jsxs)(`button`,{type:`button`,className:Ke,onClick:qe,children:[Je,i.messagePreview]}),t[110]=i.messagePreview,t[111]=Ke,t[112]=qe,t[113]=Ye):Ye=t[113];let Xe;t[114]!==We||t[115]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[We,Ye]}),t[114]=We,t[115]=Ye,t[116]=Xe):Xe=t[116];let Ze;t[117]!==Ie||t[118]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[Ie,Xe]}),t[117]=Ie,t[118]=Xe,t[119]=Ze):Ze=t[119];let Qe=k&&`pointer-events-none opacity-60`,$e;t[120]===Qe?$e=t[121]:($e=B(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,Qe),t[120]=Qe,t[121]=$e);let et;t[122]!==i.messagePlaceholder||t[123]!==S||t[124]!==X||t[125]!==te||t[126]!==p||t[127]!==re||t[128]!==ee?(et=te===`edit`?(0,$.jsx)(E,{initialContent:X,onChange:ee,isDark:p,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${S??`new`}-${re}`):(0,$.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:X.trim()?(0,$.jsx)(g,{content:X,compact:!0,className:`text-sm`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.messagePlaceholder})}),t[122]=i.messagePlaceholder,t[123]=S,t[124]=X,t[125]=te,t[126]=p,t[127]=re,t[128]=ee,t[129]=et):et=t[129];let tt;t[130]!==$e||t[131]!==et?(tt=(0,$.jsx)(`div`,{className:$e,children:et}),t[130]=$e,t[131]=et,t[132]=tt):tt=t[132];let nt;t[133]===i.messageMarkdownHint?nt=t[134]:(nt=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.messageMarkdownHint}),t[133]=i.messageMarkdownHint,t[134]=nt);let rt;t[135]!==Ze||t[136]!==tt||t[137]!==nt?(rt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[Ze,tt,nt]}),t[135]=Ze,t[136]=tt,t[137]=nt,t[138]=rt):rt=t[138];let it;t[139]!==xe||t[140]!==Se||t[141]!==Ae||t[142]!==je||t[143]!==Me||t[144]!==rt?(it=(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:[xe,Se,Ae,je,Me,rt]})}),t[139]=xe,t[140]=Se,t[141]=Ae,t[142]=je,t[143]=Me,t[144]=rt,t[145]=it):it=t[145];let at;t[146]!==i.cancel||t[147]!==r?(at=(0,$.jsx)(U,{type:`button`,variant:`secondary`,onClick:r,children:i.cancel}),t[146]=i.cancel,t[147]=r,t[148]=at):at=t[148];let ot=k||!oe,st=k?i.loading:x===`edit`?i.save:i.create,ct;t[149]!==se||t[150]!==ot||t[151]!==st?(ct=(0,$.jsx)(U,{type:`button`,variant:`primary`,disabled:ot,onClick:se,children:st}),t[149]=se,t[150]=ot,t[151]=st,t[152]=ct):ct=t[152];let lt;t[153]!==at||t[154]!==ct?(lt=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[at,ct]}),t[153]=at,t[154]=ct,t[155]=lt):lt=t[155];let ut;t[156]!==it||t[157]!==lt||t[158]!==he?(ut=(0,$.jsxs)(o,{children:[ue,(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 max-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:Ve,children:[he,it,lt]})})]}),t[156]=it,t[157]=lt,t[158]=he,t[159]=ut):ut=t[159];let dt;return t[160]!==n||t[161]!==le||t[162]!==ut?(dt=(0,$.jsx)($.Fragment,{children:(0,$.jsx)(l,{open:n,onOpenChange:le,children:ut})}),t[160]=n,t[161]=le,t[162]=ut,t[163]=dt):dt=t[163],dt}function Be(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Ve(e){return e.preventDefault()}function He(e){let t=(0,Q.c)(66),{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]:(_=B(`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=B(`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=B(`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 A;t[22]!==n.tabRunHistory||t[23]!==T||t[24]!==D||t[25]!==O?(A=(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]=A):A=t[26];let j;t[27]!==n.title||t[28]!==w||t[29]!==A||t[30]!==y?(j=(0,$.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":m,children:[y,w,A]}),t[27]=n.title,t[28]=w,t[29]=A,t[30]=y,t[31]=j):j=t[31];let M=r===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,N;t[32]===M?N=t[33]:(N=B(`flex min-w-0 items-center gap-2`,M),t[32]=M,t[33]=N);let P;t[34]!==n.sortCreatedAsc||t[35]!==n.sortCreatedDesc||t[36]!==a||t[37]!==r||t[38]!==o?(P=r===`myTasks`||r===`systemTasks`?(0,$.jsxs)(`select`,{className:Ie,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[34]=n.sortCreatedAsc,t[35]=n.sortCreatedDesc,t[36]=a,t[37]=r,t[38]=o,t[39]=P):P=t[39];let F;t[40]!==n.execStatusCancelled||t[41]!==n.execStatusFailed||t[42]!==n.execStatusRunning||t[43]!==n.execStatusSuccess||t[44]!==n.filterAllStatuses||t[45]!==n.filterAllTasks||t[46]!==n.historyRangeDay||t[47]!==n.historyRangeMonth||t[48]!==n.historyRangeWeek||t[49]!==n.runHistoryTitle||t[50]!==l||t[51]!==s||t[52]!==d||t[53]!==p||t[54]!==r||t[55]!==u||t[56]!==c||t[57]!==f?(F=r===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:B(G,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:B(k,`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:Ie,value:l,onChange:e=>u(e.target.value),"aria-label":n.filterAllTasks,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllTasks}),p.map(Ue)]}),(0,$.jsxs)(`select`,{className:Ie,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[40]=n.execStatusCancelled,t[41]=n.execStatusFailed,t[42]=n.execStatusRunning,t[43]=n.execStatusSuccess,t[44]=n.filterAllStatuses,t[45]=n.filterAllTasks,t[46]=n.historyRangeDay,t[47]=n.historyRangeMonth,t[48]=n.historyRangeWeek,t[49]=n.runHistoryTitle,t[50]=l,t[51]=s,t[52]=d,t[53]=p,t[54]=r,t[55]=u,t[56]=c,t[57]=f,t[58]=F):F=t[58];let I;t[59]!==N||t[60]!==P||t[61]!==F?(I=(0,$.jsxs)(`div`,{className:N,children:[P,F]}),t[59]=N,t[60]=P,t[61]=F,t[62]=I):I=t[62];let L;return t[63]!==j||t[64]!==I?(L=(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:[j,I]}),t[63]=j,t[64]=I,t[65]=L):L=t[65],L}function Ue(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function We(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=B(`size-4`,f),t[2]=f,t[3]=p);let m;t[4]===p?m=t[5]:(m=(0,$.jsx)(w,{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)(U,{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)(M,{className:`size-4`,strokeWidth:1.75}),t[11]=g):g=t[11];let _;t[12]!==n.fromTemplate||t[13]!==o?(_=(0,$.jsxs)(U,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:o,children:[g,n.fromTemplate]}),t[12]=n.fromTemplate,t[13]=o,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(T,{className:`size-4`,strokeWidth:1.75}),t[15]=v):v=t[15];let y;t[16]!==n.addJob||t[17]!==s?(y=(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`gap-2`,onClick:s,children:[v,n.addJob]}),t[16]=n.addJob,t[17]=s,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==h||t[21]!==_?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[h,_,y]}),t[19]=y,t[20]=h,t[21]=_,t[22]=b):b=t[22],b}function Ge(e){let t=(0,Q.c)(43),{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]:(_=B(`size-4`,g),t[9]=g,t[10]=_);let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(w,{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)(U,{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.emptyHistoryHint||t[27]!==n.emptyHistoryTitle||t[28]!==n.noRunsYet||t[29]!==n.openChat||t[30]!==n.openChatTitle||t[31]!==n.runHistoryHint||t[32]!==n.status||t[33]!==a||t[34]!==o||t[35]!==c||t[36]!==i||t[37]!==r||t[38]!==l?(x=r&&i.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(F,{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)(C,{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.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:ae(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:B(`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:X(e.status,l)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:ne(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:Y(e.summary||e.error,96)}),(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:()=>Me(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.emptyHistoryHint,t[27]=n.emptyHistoryTitle,t[28]=n.noRunsYet,t[29]=n.openChat,t[30]=n.openChatTitle,t[31]=n.runHistoryHint,t[32]=n.status,t[33]=a,t[34]=o,t[35]=c,t[36]=i,t[37]=r,t[38]=l,t[39]=x):x=t[39];let S;return t[40]!==b||t[41]!==x?(S=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[b,x]}),t[40]=b,t[41]=x,t[42]=S):S=t[42],S}function Ke(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=B(`flex 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 _=n.enabled,y=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,b;t[6]===y?b=t[7]:(b=B(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,y),t[6]=y,t[7]=b);let x;t[8]!==n||t[9]!==l?(x=e=>{e.stopPropagation(),l(n,!n.enabled)},t[8]=n,t[9]=l,t[10]=x):x=t[10];let S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[11]=S):S=t[11];let w;t[12]!==n.enabled||t[13]!==b||t[14]!==x?(w=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":_,className:b,onClick:x,children:S}),t[12]=n.enabled,t[13]=b,t[14]=x,t[15]=w):w=t[15];let T;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(v,{className:`size-4`,strokeWidth:1.75}),t[16]=T):T=t[16];let E;t[17]===r.jobCardMenuAria?E=t[18]:(E=(0,$.jsx)(Se,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:Je,children:T})}),t[17]=r.jobCardMenuAria,t[18]=E);let D;t[19]!==n||t[20]!==u||t[21]!==s?(D=()=>{s(n.id),u(n)},t[19]=n,t[20]=u,t[21]=s,t[22]=D):D=t[22];let O;t[23]!==r.edit||t[24]!==D?(O=(0,$.jsx)(we,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:D,children:r.edit}),t[23]=r.edit,t[24]=D,t[25]=O):O=t[25];let k;t[26]!==n||t[27]!==d||t[28]!==s?(k=()=>{s(n.id),d(n)},t[26]=n,t[27]=d,t[28]=s,t[29]=k):k=t[29];let A;t[30]!==r.runNow||t[31]!==k?(A=(0,$.jsx)(we,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:k,children:r.runNow}),t[30]=r.runNow,t[31]=k,t[32]=A):A=t[32];let j;t[33]!==n||t[34]!==f||t[35]!==s?(j=()=>{s(n.id),f(n)},t[33]=n,t[34]=f,t[35]=s,t[36]=j):j=t[36];let M;t[37]!==r.delete||t[38]!==j?(M=(0,$.jsx)(we,{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:j,children:r.delete}),t[37]=r.delete,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==O||t[41]!==A||t[42]!==M?(N=(0,$.jsx)(Te,{children:(0,$.jsxs)(Ee,{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:qe,children:[O,A,M]})}),t[40]=O,t[41]=A,t[42]=M,t[43]=N):N=t[43];let P;t[44]!==E||t[45]!==N?(P=(0,$.jsxs)(Ce,{children:[E,N]}),t[44]=E,t[45]=N,t[46]=P):P=t[46];let F;t[47]!==P||t[48]!==w?(F=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[w,P]}),t[47]=P,t[48]=w,t[49]=F):F=t[49];let I=n.name||n.id,L;t[50]===I?L=t[51]:(L=(0,$.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:I}),t[50]=I,t[51]=L);let R;t[52]===n?R=t[53]:(R=pe(n),t[52]=n,t[53]=R);let z;t[54]===n?z=t[55]:(z=pe(n),t[54]=n,t[55]=z);let V;t[56]===z?V=t[57]:(V=(0,$.jsx)(g,{content:z,compact:!0}),t[56]=z,t[57]=V);let H;t[58]!==R||t[59]!==V?(H=(0,$.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:R,children:V}),t[58]=R,t[59]=V,t[60]=H):H=t[60];let W;t[61]!==L||t[62]!==H?(W=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[L,H]}),t[61]=L,t[62]=H,t[63]=W):W=t[63];let G;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(C,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=G):G=t[64];let K;t[65]!==n||t[66]!==i||t[67]!==a?(K=ee(n,i,a),t[65]=n,t[66]=i,t[67]=a,t[68]=K):K=t[68];let q;t[69]===K?q=t[70]:(q=(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:[G,(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:K})]}),t[69]=K,t[70]=q);let J;return t[71]!==m||t[72]!==F||t[73]!==W||t[74]!==h||t[75]!==q?(J=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,className:p,onClick:m,onKeyDown:h,children:[F,W,q]}),t[71]=m,t[72]=F,t[73]=W,t[74]=h,t[75]=q,t[76]=J):J=t[76],J}function qe(e){return e.preventDefault()}function Je(e){return e.stopPropagation()}function Ye(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:x}=e,S,C,w,T,E,D,O,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=te(l.intervalMs,i,a(r).heartbeatSettings.intervalPresets);M=`cron-system-tasks-panel`,N=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?C=t[34]:(C=(0,$.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=C),t[35]===n.systemTasksIntro?w=t[36]:(w=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=w);let o;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(R,{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=B(`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 x;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[49]=x):x=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:x}),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?(T=(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]=T):T=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 H;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(b,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=H):H=t[69];let W;t[70]===n.systemHeartbeatSettingsLink?W=t[71]:(W=(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(V,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,H]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=W),t[72]!==z||t[73]!==W?(j=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[z,W]}),t[72]=z,t[73]=W,t[74]=j):j=t[74],O=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let G;t[75]===n.systemHeartbeatStatus?G=t[76]:(G=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=G);let K=l.enabled?n.enabled:n.disabled,q;t[77]===K?q=t[78]:(q=(0,$.jsx)(`dd`,{className:`text-fg`,children:K}),t[77]=K,t[78]=q),t[79]!==G||t[80]!==q?(k=(0,$.jsxs)(`div`,{children:[G,q]}),t[79]=G,t[80]=q,t[81]=k):k=t[81],t[82]===n.systemHeartbeatInterval?D=t[83]:(D=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatInterval}),t[82]=n.systemHeartbeatInterval,t[83]=D),S=`text-fg`;let J;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(J=/\{\{value\}\}/g,t[84]=J):J=t[84],E=n.systemHeartbeatEvery.replace(J,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]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=N}else S=t[21],C=t[22],w=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30],M=t[31],N=t[32];let P;t[85]!==S||t[86]!==E?(P=(0,$.jsx)(`dd`,{className:S,children:E}),t[85]=S,t[86]=E,t[87]=P):P=t[87];let I;t[88]!==P||t[89]!==D?(I=(0,$.jsxs)(`div`,{children:[D,P]}),t[88]=P,t[89]=D,t[90]=I):I=t[90];let L;t[91]!==I||t[92]!==O||t[93]!==k?(L=(0,$.jsxs)(`dl`,{className:O,children:[k,I]}),t[91]=I,t[92]=O,t[93]=k,t[94]=L):L=t[94];let z;t[95]!==L||t[96]!==A||t[97]!==j?(z=(0,$.jsxs)(`div`,{className:A,children:[j,L]}),t[95]=L,t[96]=A,t[97]=j,t[98]=z):z=t[98];let H;t[99]===n.systemDreamingTitle?H=t[100]:(H=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=H);let W;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(b,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=W):W=t[101];let G;t[102]===n.systemDreamingSettingsLink?G=t[103]:(G=(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(V,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,W]})}),t[102]=n.systemDreamingSettingsLink,t[103]=G);let K;t[104]!==H||t[105]!==G?(K=(0,$.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[H,G]}),t[104]=H,t[105]=G,t[106]=K):K=t[106];let q;t[107]===n.systemDreamingHint?q=t[108]:(q=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=q);let J;t[109]!==m||t[110]!==n||t[111]!==s||t[112]!==i||t[113]!==x||t[114]!==v||t[115]!==g||t[116]!==y||t[117]!==_||t[118]!==h||t[119]!==o||t[120]!==c?(J=s&&c.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,$.jsx)(F,{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 gap-4 sm:grid-cols-2`,children:c.map(e=>(0,$.jsx)(Ke,{job:e,c:n,localeTag:i,scheduleBadgeLabels:o,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:x},e.id))}),t[109]=m,t[110]=n,t[111]=s,t[112]=i,t[113]=x,t[114]=v,t[115]=g,t[116]=y,t[117]=_,t[118]=h,t[119]=o,t[120]=c,t[121]=J):J=t[121];let Y;t[122]!==K||t[123]!==q||t[124]!==J?(Y=(0,$.jsxs)(`div`,{children:[K,q,J]}),t[122]=K,t[123]=q,t[124]=J,t[125]=Y):Y=t[125];let X;return t[126]!==C||t[127]!==w||t[128]!==T||t[129]!==z||t[130]!==Y||t[131]!==M||t[132]!==N?(X=(0,$.jsxs)(`section`,{"aria-labelledby":M,className:N,children:[C,w,T,z,Y]}),t[126]=C,t[127]=w,t[128]=T,t[129]=z,t[130]=Y,t[131]=M,t[132]=N,t[133]=X):X=t[133],X}function Xe(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 Ze=[`daily`,`monitoring`,`reports`,`automation`],Qe=[{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:`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`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{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`},{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:`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:`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 $e(e){return Qe.find(t=>t.templateId===e)}function et(e){let t=(0,Q.c)(21),{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:a,onCategoryFilterChange:o,onSelectTemplate:s}=e,c;if(t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==o||t[4]!==s||t[5]!==i){let e=a===`all`?[...Qe]:Qe.filter(e=>e.category===a),l=n.fromTemplate,u=a===`all`?`secondary`:`ghost`,d;t[7]===o?d=t[8]:(d=()=>o(`all`),t[7]=o,t[8]=d);let f;t[9]!==n.templateFilterAll||t[10]!==u||t[11]!==d?(f=(0,$.jsx)(U,{type:`button`,variant:u,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:d,children:n.templateFilterAll}),t[9]=n.templateFilterAll,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==a||t[14]!==n.templateCategories||t[15]!==o?(p=Ze.map(e=>(0,$.jsx)(U,{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[13]=a,t[14]=n.templateCategories,t[15]=o,t[16]=p):p=t[16];let m;t[17]!==n.fromTemplate||t[18]!==f||t[19]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":l,children:[f,p]}),t[17]=n.fromTemplate,t[18]=f,t[19]=p,t[20]=m):m=t[20],c=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[m,e.length===0?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted`,children:n.templatesEmptyHint}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let t=Xe(n,e.templateId);if(!t)return null;let a=ee({schedule:e.defaultSchedule,timezone:void 0,next_run:void 0},r,i);return(0,$.jsxs)(`button`,{type:`button`,className:B(`flex 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`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>s(e.templateId),"aria-label":`${n.templateCategories[e.category]} — ${t.title}`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:t.title}),(0,$.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:t.description}),(0,$.jsx)(`span`,{className:`mt-1 flex items-center gap-1 text-xs text-fg-muted`,children:(0,$.jsx)(`span`,{className:`tabular-nums`,children:a})})]},e.templateId)})})]}),t[0]=a,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i,t[6]=c}else c=t[6];return c}function tt(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)(R,{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=B(`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 I;t[21]!==P||t[22]!==E?(I=(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]=I):I=t[23];let L;t[24]!==I||t[25]!==T?(L=(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,I]}),t[24]=I,t[25]=T,t[26]=L):L=t[26];let z;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?(z=a&&o===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,$.jsx)(F,{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)(et,{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(U,{type:`button`,variant:`primary`,onClick:b,children:n.emptyStateCta})})]}):(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:s.map(e=>(0,$.jsx)(Ke,{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]=z):z=t[44];let V;return t[45]!==C||t[46]!==L||t[47]!==z?(V=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[C,L,z]}),t[45]=C,t[46]=L,t[47]=z,t[48]=V):V=t[48],V}function nt(e){let t=(0,Q.c)(23),{open:n,onOpenChange:r,c:i,localeTag:a,scheduleBadgeLabels:f,categoryFilter:p,onCategoryFilterChange:m,onSelectTemplate:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),t[0]=g):g=t[0];let _;t[1]===i.fromTemplate?_=t[2]:(_=(0,$.jsx)(u,{className:`sr-only`,children:i.fromTemplate}),t[1]=i.fromTemplate,t[2]=_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(I,{className:`size-5`,strokeWidth:1.75}),t[3]=v):v=t[3];let y;t[4]===i.close?y=t[5]:(y=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:v})}),t[4]=i.close,t[5]=y);let b;t[6]!==_||t[7]!==y?(b=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end border-b border-edge px-4 py-3`,children:[_,y]}),t[6]=_,t[7]=y,t[8]=b):b=t[8];let x;t[9]!==i||t[10]!==p||t[11]!==a||t[12]!==m||t[13]!==h||t[14]!==f?(x=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,$.jsx)(et,{cron:i,localeTag:a,scheduleBadgeLabels:f,categoryFilter:p,onCategoryFilterChange:m,onSelectTemplate:h})}),t[9]=i,t[10]=p,t[11]=a,t[12]=m,t[13]=h,t[14]=f,t[15]=x):x=t[15];let S;t[16]!==b||t[17]!==x?(S=(0,$.jsxs)(o,{children:[g,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(c,{className:`xopc-dialog-content-pane pointer-events-auto relative flex max-h-[min(90vh,840px)] w-full max-w-lg flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-2xl dark:border-edge`,onOpenAutoFocus:rt,children:[b,x]})})]}),t[16]=b,t[17]=x,t[18]=S):S=t[18];let C;return t[19]!==r||t[20]!==n||t[21]!==S?(C=(0,$.jsx)(l,{open:n,onOpenChange:r,children:S}),t[19]=r,t[20]=n,t[21]=S,t[22]=C):C=t[22],C}function rt(e){return e.preventDefault()}function it(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:Oe,formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function at(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 ot(e,t){let n=it();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);n.formMessage=r??``,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 st(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,Z.useReducer)(at,void 0,it),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=S(()=>de(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.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly),p=a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly,m=!!a.formName.trim()&&!!a.formSchedule.trim()&&!!a.formMessage.trim()&&(!f||!!a.formChatId.trim()),h=(0,Z.useCallback)(e=>{s.current=!1,o({type:`replace`,state:ot(e,n)})},[n]),g=(0,Z.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),_=(0,Z.useCallback)(e=>{let r=$e(e),i=r?Xe(t.cron,e):void 0;return!r||!i?!1:(s.current=!1,o({type:`replace`,state:{...it(),formOpen:!0,formMode:`add`,formName:i.title,formSchedule:r.defaultSchedule,formMessage:i.prompt,formSessionTarget:r.defaultSessionTarget,formModel:n(),messageEditorNonce:1}}),!0)},[n,t.cron]),v=(0,Z.useCallback)(()=>{s.current=!1,o({type:`replace`,state:it()})},[]),y=(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})},[]),b=(0,Z.useCallback)(e=>{o({type:`patch`,patch:{formChannel:e,formChatId:``,...e===`local`?{formAgentLocalOnly:!1}:{}}})},[]),x=(0,Z.useCallback)(e=>{s.current=!0,o({type:`patch`,patch:{formModel:e}})},[]),C=(0,Z.useCallback)(()=>{de(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,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}),setFormAgentId:e=>w({formAgentId:e}),setFormAgentLocalOnly:e=>w({formAgentLocalOnly:e}),setFormWorkingDirectory:e=>w({formWorkingDirectory:e}),setFormSubmitting:e=>w({formSubmitting:e}),canSubmit:m,needsDeliveryChat:f,showChannelPicker:p,cronAgentSelectOptions:d,openForm:h,closeForm:v,applyCronTemplate:_,setMessageMdMode:g,handleFormSessionTargetChange:y,handleFormChannelChange:b,handleFormModelUserChange:x,refreshRecipientsList:C}}function ct(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||x(),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 lt(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,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=(0,Z.useCallback)(async()=>{x(!0),C(null);try{a(await ye())}catch(e){C(e instanceof Error?e.message:n.failedToLoadJobs)}finally{x(!1)}},[n.failedToLoadJobs]),T=(0,Z.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([ue(),se(),oe(),N(),z().catch(()=>null)]);s(e),l(t),d(n.model||``),h(r.payload?.config??null),i&&p(i.items)}catch{}},[]),E=(0,Z.useCallback)(async()=>{y(!0);try{_(await ge(400))}catch{}finally{y(!1)}},[]);return(0,Z.useEffect)(()=>{t&&(w(),T())},[t,w,T]),(0,Z.useEffect)(()=>{if(!t)return;let e=()=>{N().then(e=>{h(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,Z.useEffect)(()=>{!t||!r||E()},[t,r,E]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:m,runHistory:g,runHistoryLoading:v,loading:b,error:S,setError:C,userCronJobs:(0,Z.useMemo)(()=>i.filter(e=>!ie(e)),[i]),systemCronJobs:(0,Z.useMemo)(()=>i.filter(e=>ie(e)),[i]),heartbeatFromConfig:(0,Z.useMemo)(()=>xe(m),[m]),loadJobs:w,loadAux:T,loadRunHistoryOnly:E,refreshAll:(0,Z.useCallback)(()=>{w(),T(),E()},[w,T,E])}}function ut(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 dt(e,t,n,r){let i=new Date,a=t===`day`?ke(i):t===`week`?Ae(i):je(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var ft={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function pt(){let e=i(e=>e.language),t=a(e),n=t.cron,r=t.chat,o=!!p(e=>e.token),s=f(e=>e.resolved)===`dark`,c=e===`zh`?`zh-CN`:`en-US`,[l,u]=(0,Z.useReducer)(H,ft),{mainTab:d,jobSort:m,historyRange:h,historyJobFilter:g,historyStatusFilter:_,detailOpen:v,detailJob:y,detailHistory:b,detailLoading:x,confirmOpen:S,templatePickerOpen:C,templateCategoryFilter:w}=l,T=lt({hasToken:o,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:d===`history`}),{setError:E}=T,D=ct({onUnavailable:()=>E(n.wakeLockUnavailable)}),O=(0,Z.useCallback)(()=>T.defaultModel||(T.availableModels.length>0?T.availableModels[0].id:``),[T.defaultModel,T.availableModels]),k=st({m:t,defaultModelForForm:O,channels:T.channels,chatAgents:T.chatAgents}),A=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useCallback)((e,t)=>{A.current=e,M.current=t,u({type:`patch`,patch:{confirmOpen:!0}})},[]),P=(0,Z.useCallback)(()=>{u({type:`patch`,patch:{confirmOpen:!1}}),M.current=null,A.current=null},[]),F=(0,Z.useRef)(null),I=(0,Z.useCallback)(e=>{F.current=e,window.setTimeout(()=>{F.current===e&&(F.current=null)},400)},[]),L=(0,Z.useCallback)(e=>{k.applyCronTemplate(e)&&u({type:`patch`,patch:{templatePickerOpen:!1}})},[k]),R=async()=>{if(!k.formName.trim()){E(n.nameRequired);return}if(!k.formSchedule.trim()||!k.formMessage.trim()){E(n.scheduleRequired);return}if(k.needsDeliveryChat&&!k.formChatId.trim()){E(n.chatIdRequired);return}k.setFormSubmitting(!0),E(null);try{let e=k.formMessage.trim(),t;t=k.formSessionTarget===`isolated`&&k.formAgentLocalOnly?{mode:`none`}:k.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:k.formChannel,to:k.formChatId.trim()};let n=k.formSessionTarget===`isolated`?{kind:`agentTurn`,message:e,...k.formModel.trim()?{model:k.formModel.trim()}:{}}:{kind:`systemEvent`,text:e},r=k.formModel.trim(),i=k.formAgentId.trim().toLowerCase(),a=k.formSessionTarget===`main`?null:i||null,o=k.formWorkingDirectory.trim(),s={name:k.formName.trim(),schedule:k.formSchedule.trim(),sessionTarget:k.formSessionTarget,model:k.formSessionTarget===`isolated`&&r?r:void 0,delivery:t,payload:n,...k.formMode===`edit`?{agentId:a,workingDirectory:k.formSessionTarget===`isolated`&&o||null}:{...k.formSessionTarget===`isolated`&&i?{agentId:i}:{},...k.formSessionTarget===`isolated`&&o?{workingDirectory:o}:{}}};if(k.formMode===`edit`&&k.formJobId)await fe(k.formJobId,s);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=s;await ve(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}k.closeForm(),await T.loadJobs(),await T.loadAux()}catch(e){E(e instanceof Error?e.message:k.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{k.setFormSubmitting(!1)}},z=async e=>{u({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[]}});try{let t=await _e(e.id);t&&u({type:`patch`,patch:{detailJob:t,detailHistory:await me(e.id,20)}})}catch{}finally{u({type:`patch`,patch:{detailLoading:!1}})}},B=(0,Z.useCallback)(()=>{u({type:`patch`,patch:{detailOpen:!1,detailJob:null}})},[]),V=(0,Z.useCallback)(()=>{u({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),U=async(e,t)=>{try{await he(e.id,t),await Promise.all([T.loadJobs(),T.loadAux()])}catch(e){E(e instanceof Error?e.message:n.failedToToggleJob)}},W=async()=>{let e=M.current,t=A.current;if(!(!e||!t)){P();try{t===`run`?await le(e):(await ce(e),y?.id===e&&u({type:`patch`,patch:{detailOpen:!1,detailJob:null}})),await Promise.all([T.loadJobs(),T.loadAux(),T.loadRunHistoryOnly()])}catch(e){E(e instanceof Error?e.message:n.actionFailed)}}};(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(k.formOpen?k.closeForm():v&&u({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[k,v]);let G=(0,Z.useMemo)(()=>({running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled}),[n.execStatusCancelled,n.execStatusFailed,n.execStatusRunning,n.execStatusSuccess]),K=(0,Z.useMemo)(()=>ut(T.userCronJobs,m),[T.userCronJobs,m]),q=(0,Z.useMemo)(()=>ut(T.systemCronJobs,m),[T.systemCronJobs,m]),J=(0,Z.useMemo)(()=>dt(T.runHistory,h,g,_),[T.runHistory,h,g,_]),Y=n.scheduleBadge,{pathname:X}=j(),ee=X.startsWith(`/settings/`);return o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mt,{hasToken:o,c:n,loading:T.loading,runHistoryLoading:T.runHistoryLoading,onRefresh:T.refreshAll,onOpenTemplatePicker:V,onAddJob:()=>k.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:[T.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:T.error}):null,(0,$.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle})]})}),ee?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(We,{c:n,loading:T.loading,runHistoryLoading:T.runHistoryLoading,onRefresh:T.refreshAll,onOpenTemplatePicker:V,onAddJob:()=>k.openForm()})}):null,(0,$.jsx)(He,{c:n,mainTab:d,onMainTabChange:e=>u({type:`patch`,patch:{mainTab:e}}),jobSort:m,onJobSortChange:e=>u({type:`patch`,patch:{jobSort:e}}),historyRange:h,onHistoryRangeChange:e=>u({type:`patch`,patch:{historyRange:e}}),historyJobFilter:g,onHistoryJobFilterChange:e=>u({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:_,onHistoryStatusFilterChange:e=>u({type:`patch`,patch:{historyStatusFilter:e}}),jobs:T.jobs}),d===`myTasks`?(0,$.jsx)(tt,{c:n,localeTag:c,scheduleBadgeLabels:Y,loading:T.loading,jobsCount:T.userCronJobs.length,sortedJobs:K,templateCategoryFilter:w,onTemplateCategoryFilterChange:e=>u({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:L,keepAwake:D.keepAwake,wakeSupported:D.featureAvailable,onWakeUnsupportedClick:()=>E(n.wakeLockUnavailable),onKeepAwakeToggle:()=>D.setKeepAwake(e=>!e),absorbCardClickJobIdRef:F,scheduleAbsorbNextMenuCardClick:I,onOpenDetail:e=>void z(e),onToggle:(e,t)=>void U(e,t),onEdit:e=>k.openForm(e),onAddJob:()=>k.openForm(),onRunNow:e=>N(`run`,e.id),onDelete:e=>N(`delete`,e.id)}):d===`systemTasks`?(0,$.jsx)(Ye,{c:n,language:e,localeTag:c,scheduleBadgeLabels:Y,loading:T.loading,sortedSystemJobs:q,heartbeat:T.heartbeatFromConfig,keepAwake:D.keepAwake,wakeSupported:D.featureAvailable,onWakeUnsupportedClick:()=>E(n.wakeLockUnavailable),onKeepAwakeToggle:()=>D.setKeepAwake(e=>!e),absorbCardClickJobIdRef:F,scheduleAbsorbNextMenuCardClick:I,onOpenDetail:e=>void z(e),onToggle:(e,t)=>void U(e,t),onEdit:e=>k.openForm(e),onRunNow:e=>N(`run`,e.id),onDelete:e=>N(`delete`,e.id)}):(0,$.jsx)(Ge,{c:n,runHistoryLoading:T.runHistoryLoading,runHistory:T.runHistory,filteredRunHistory:J,jobs:T.jobs,onRefreshHistory:()=>void T.loadRunHistoryOnly(),onOpenJobDetail:e=>void z(e),statusLabels:G})]}),(0,$.jsx)(ze,{open:k.formOpen,onRequestClose:k.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:s,channels:T.channels,sessionChatIds:k.sessionChatIds,cronAgentSelectOptions:k.cronAgentSelectOptions,defaultModelResolver:O,formMode:k.formMode,formJobId:k.formJobId,formName:k.formName,onFormNameChange:k.setFormName,formSchedule:k.formSchedule,onFormScheduleChange:k.setFormSchedule,formSubmitting:k.formSubmitting,formSessionTarget:k.formSessionTarget,onFormSessionTargetChange:k.handleFormSessionTargetChange,formAgentLocalOnly:k.formAgentLocalOnly,onFormAgentLocalOnlyChange:k.setFormAgentLocalOnly,formModel:k.formModel,onFormModelUserChange:k.handleFormModelUserChange,formAgentId:k.formAgentId,onFormAgentIdChange:k.setFormAgentId,formWorkingDirectory:k.formWorkingDirectory,onFormWorkingDirectoryChange:k.setFormWorkingDirectory,formChannel:k.formChannel,onFormChannelChange:k.handleFormChannelChange,formChatId:k.formChatId,onFormChatIdChange:k.setFormChatId,formMessage:k.formMessage,onFormMessageChange:k.setFormMessage,formMessageMdMode:k.formMessageMdMode,onSetMessageMdMode:k.setMessageMdMode,messageEditorNonce:k.messageEditorNonce,needsDeliveryChat:k.needsDeliveryChat,showChannelPicker:k.showChannelPicker,canSubmit:k.canSubmit,onSubmit:()=>void R(),onRefreshRecipients:k.refreshRecipientsList}),(0,$.jsx)(nt,{open:C,onOpenChange:e=>{u({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:c,scheduleBadgeLabels:Y,categoryFilter:w,onCategoryFilterChange:e=>u({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:L}),(0,$.jsx)(Le,{open:v,onDismiss:B,detailJob:y,detailLoading:x,detailHistory:b,c:n,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:G}),(0,$.jsx)(De,{open:S,onOpenChange:e=>u({type:`patch`,patch:{confirmOpen:e}}),action:A.current,c:n,onDismiss:P,onConfirm:W})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mt,{hasToken:o,c:n,loading:T.loading,runHistoryLoading:T.runHistoryLoading,onRefresh:T.refreshAll,onOpenTemplatePicker:V,onAddJob:()=>k.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 mt(e){let t=(0,Q.c)(16),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,{pathname:l}=j(),u;t[0]===l?u=t[1]:(u=l.startsWith(`/settings/`),t[0]=l,t[1]=u);let d=u,f=h(gt),p=h(ht),m;t[2]!==r||t[3]!==i||t[4]!==c||t[5]!==s||t[6]!==o||t[7]!==a?(m=(0,$.jsx)(We,{c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}),t[2]=r,t[3]=i,t[4]=c,t[5]=s,t[6]=o,t[7]=a,t[8]=m):m=t[8];let g=m,_,v;return t[9]!==p||t[10]!==g||t[11]!==n||t[12]!==d||t[13]!==f?(_=()=>!n||d?(p(),()=>p()):(f({startExtra:null,main:null,end:g}),()=>p()),v=[p,g,n,d,f],t[9]=p,t[10]=g,t[11]=n,t[12]=d,t[13]=f,t[14]=_,t[15]=v):(_=t[14],v=t[15]),(0,Z.useLayoutEffect)(_,v),null}function ht(e){return e.clearPageHeader}function gt(e){return e.setPageHeader}export{pt as CronPage};