@xopcai/xopc 0.0.170 → 0.0.172

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 (242) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-CkUp1qvf.js → activity-store-C3Y-bESI.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDuem4HM.js → agent-avatar-dicebear-CPyev9P7.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-Bf_kK2Ay.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-BnuPQhJW.js → api-B7qEr_Rw.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-DdZw8Hi1.js → app-management-settings-panel-Br_9-7fs.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BN8Vk2bX.js → appearance-settings-uyLcRPai.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-DXFCP5-1.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-C82MaDQj.js → archive-plugin-B19REnR5.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-uilrwSdW.js → attachment-load-DLWCC4Yi.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-CkDZjAmy.js → automation-suggestion-card-ky5S5lly.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-D8pT1o2O.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-B7NTL0_T.js → binary-plugins-CtPEzLlo.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-D_LDNlB-.js → block-editor-CQVR4Xij.js} +32 -32
  16. package/dist/gateway/static/root/assets/browser-settings-page-Bav_skKN.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-UFVUzn4v.js → browser-workflow-inputs-CimCGbhq.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CGgC0N92.js → browser-workflows-page-DewuCw3p.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-BHaYYo9E.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-DUIorGUd.js → capability-presets-api-B5RTs-Az.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-PTz00nR4.js → capability-presets-settings-panel-BgchTh81.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-BYwSB8c6.js → channel-recipient-api-Czu0YzIZ.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-BP0e62wt.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-DBWKfeGe.js +1 -0
  25. package/dist/gateway/static/root/assets/connector-logo-Di3gnR_D.js +1 -0
  26. package/dist/gateway/static/root/assets/connectors-page-CC5kh0de.js +2 -0
  27. package/dist/gateway/static/root/assets/{desktop-pet-CkT98fPT.js → desktop-pet-D-ZUNHhn.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-DkbIzdA3.js → desktop-pet-settings-C3L6AI8_.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-dBQvj1sG.js → directory-picker-path-field-Dvq4iG6P.js} +1 -1
  30. package/dist/gateway/static/root/assets/dreaming-settings-D9i54kWO.js +3 -0
  31. package/dist/gateway/static/root/assets/{extension-debug-page-BfxoIiNo.js → extension-debug-page-BecQjU0J.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-EIJ3wIb7.js → extension-page-BeVkPSm-.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-DBBec51N.js → extension-settings-page-DMoo2mKx.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-4_u53Ufq.js → gateway-config-api-Bthb3_6v.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-v9kJM59H.js → gateway-settings-Bh8nPvJQ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-CXITih5d.js → gateway-startup-retry-D3USVm9D.js} +1 -1
  37. package/dist/gateway/static/root/assets/goal-create-dialog-Dp0AyDHI.js +1 -0
  38. package/dist/gateway/static/root/assets/goal-detail-page-CNt7nrdS.js +4 -0
  39. package/dist/gateway/static/root/assets/{goals-config-api-D54YQPon.js → goals-config-api-C_2QWBtb.js} +1 -1
  40. package/dist/gateway/static/root/assets/goals-page-Bm_NZFiZ.js +2 -0
  41. package/dist/gateway/static/root/assets/{goals-settings-DDezXaVi.js → goals-settings-DhL643tc.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-CRsIUeZN.js → heartbeat-settings-COVFwp7C.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-CY6cQUHL.js → image-generation-api-BNQlnwpU.js} +1 -1
  44. package/dist/gateway/static/root/assets/index-C_XSKOH6.css +1 -0
  45. package/dist/gateway/static/root/assets/{index-Dfq2laZe.js → index-DUasAutC.js} +67 -67
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9k7EDdY.js → keyboard-shortcuts-settings-DfdJRJVy.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-DZwkD1co.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-DbaiBolh.js → local-apps-page-BvCPOgoi.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-Dqp9H2Uf.js → locale-store-BP0vD37A.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-DoCY0Mm9.js → logs-page-dNL0Y1dA.js} +3 -3
  51. package/dist/gateway/static/root/assets/{markdown-split-BGlQR-Be.js → markdown-split-YO1rDk9m.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-BpaeV6f_.js → media-plugins-CU_RRf-q.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-BWtP5TFz.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-Cd2HpciM.js → notes-page-CeFiOK3S.js} +1 -1
  55. package/dist/gateway/static/root/assets/notes-workbench-B8MKxpZb.js +4 -0
  56. package/dist/gateway/static/root/assets/{page-tabs-DyimBUp_.js → page-tabs-tiHmRJUA.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-BKZulEYr.js → preview-open-alternatives-CU6XgaCz.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-Bjz9BxBY.js → product-open-page-Dn4_qor4.js} +1 -1
  59. package/dist/gateway/static/root/assets/project-detail-page-CWBuuX-S.js +1 -0
  60. package/dist/gateway/static/root/assets/projects-page-BJSsLsXH.js +1 -0
  61. package/dist/gateway/static/root/assets/remote-access-hub-DXJDb8vB.js +1 -0
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BPTqb2_r.js → save-bar-controls-edDUIbXo.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-YN0D81Dk.js → schedule-field-DqJO_5Yb.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-BmY5PSS2.js → schema-form-CMh0jzy5.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-DeHpWgxM.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-Cf-TEYUd.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-B-RhgD_p.js → settings-form-section-Bb0Bc3nJ.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkPupX2B.js → settings-loading-skeleton-DQhADvz1.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-2QBMvaxj.js → settings-page-b0M5HukN.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-CtrW-LD6.js → settings-page-layout-hvjtIjvh.js} +1 -1
  71. package/dist/gateway/static/root/assets/setup-status-panel-BFyfed_g.js +1 -0
  72. package/dist/gateway/static/root/assets/{share-preview-page-BezIW1n9.js → share-preview-page-rbeaOpTg.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-CYnH9sTt.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-Cr8_m-jS.js +1 -0
  75. package/dist/gateway/static/root/assets/skills-page-Chtc1xDO.js +2 -0
  76. package/dist/gateway/static/root/assets/{system-settings-panel-WAFhKyAu.js → system-settings-panel-BHo_hgnL.js} +1 -1
  77. package/dist/gateway/static/root/assets/{theme-store-BiC0gIBa.js → theme-store-C3KnnjcU.js} +1 -1
  78. package/dist/gateway/static/root/assets/time-picker-D-G-uwVJ.js +1 -0
  79. package/dist/gateway/static/root/assets/{typed-models-lib-WAQO3F_8.js → typed-models-lib-DtRnG-YI.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-channel-catalog-CKlfsSeU.js → use-channel-catalog-CWWItX2g.js} +1 -1
  81. package/dist/gateway/static/root/assets/user-context-page-D7qMR26X.js +1 -0
  82. package/dist/gateway/static/root/assets/{voice-api-key-field-BAFHF0_v.js → voice-api-key-field-BTnltQHZ.js} +1 -1
  83. package/dist/gateway/static/root/assets/work-discovery-page-CpqFZze9.js +1 -0
  84. package/dist/gateway/static/root/assets/work-item-detail-page-t4dXpGC0.js +1 -0
  85. package/dist/gateway/static/root/assets/work-page-BXwDKiMZ.js +1 -0
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-1OP4HyvS.js → workflow-run-setup-panel-D7vKChFZ.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-Bos9HyqT.js +11 -0
  88. package/dist/gateway/static/root/index.html +7 -7
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/embedded/run-for-session.js +71 -24
  91. package/dist/src/agent/embedded/run-turn.js +68 -4
  92. package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
  93. package/dist/src/agent/inbound/inbound-loop.js +0 -2
  94. package/dist/src/agent/memory/builtin-provider.js +4 -4
  95. package/dist/src/agent/memory/compaction-planner.d.ts +16 -0
  96. package/dist/src/agent/memory/compaction-planner.js +152 -0
  97. package/dist/src/agent/memory/compaction-policy.d.ts +10 -0
  98. package/dist/src/agent/memory/compaction-policy.js +24 -0
  99. package/dist/src/agent/memory/compaction.d.ts +21 -22
  100. package/dist/src/agent/memory/compaction.js +220 -194
  101. package/dist/src/agent/memory/context-budget.d.ts +40 -0
  102. package/dist/src/agent/memory/context-budget.js +106 -0
  103. package/dist/src/agent/memory/manager.d.ts +4 -1
  104. package/dist/src/agent/memory/manager.js +8 -3
  105. package/dist/src/agent/memory/understanding/service.d.ts +2 -0
  106. package/dist/src/agent/memory/understanding/service.js +11 -9
  107. package/dist/src/agent/orchestration/context-overflow.d.ts +1 -0
  108. package/dist/src/agent/orchestration/context-overflow.js +19 -0
  109. package/dist/src/agent/orchestration/loop-guard.js +13 -9
  110. package/dist/src/agent/reply/post-compaction-context.d.ts +4 -0
  111. package/dist/src/agent/reply/post-compaction-context.js +5 -3
  112. package/dist/src/agent/service/process-direct-one-shot.js +1 -2
  113. package/dist/src/agent/service/process-direct-streaming.js +1 -2
  114. package/dist/src/agent/service.d.ts +1 -2
  115. package/dist/src/agent/service.js +16 -44
  116. package/dist/src/agent/session/session-inspector.js +10 -2
  117. package/dist/src/automations/domain/validation.d.ts +8 -8
  118. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
  119. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  120. package/dist/src/config/schema.d.ts +17 -1
  121. package/dist/src/connectors/composio-sessions.d.ts +1 -0
  122. package/dist/src/connectors/composio-sessions.js +14 -5
  123. package/dist/src/connectors/composio-triggers.d.ts +1 -1
  124. package/dist/src/connectors/composio-triggers.js +4 -3
  125. package/dist/src/connectors/composio.js +1 -0
  126. package/dist/src/connectors/{connector-memory-sync.d.ts → connected-source-ingestion.d.ts} +11 -4
  127. package/dist/src/connectors/{connector-memory-sync.js → connected-source-ingestion.js} +49 -101
  128. package/dist/src/connectors/connected-source-normalizers.d.ts +15 -0
  129. package/dist/src/connectors/connected-source-normalizers.js +186 -0
  130. package/dist/src/connectors/connector-identity.d.ts +2 -0
  131. package/dist/src/connectors/connector-identity.js +29 -0
  132. package/dist/src/connectors/learning-coordinator.d.ts +25 -0
  133. package/dist/src/connectors/learning-coordinator.js +214 -0
  134. package/dist/src/connectors/learning-recipes.d.ts +22 -0
  135. package/dist/src/connectors/learning-recipes.js +121 -0
  136. package/dist/src/connectors/runtime-status.d.ts +1 -8
  137. package/dist/src/connectors/runtime-status.js +4 -29
  138. package/dist/src/gateway/hono/lib/config-payload.d.ts +23 -0
  139. package/dist/src/gateway/hono/lib/config-payload.js +3 -0
  140. package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
  141. package/dist/src/gateway/hono/routes/config-patch/misc.js +28 -0
  142. package/dist/src/gateway/hono/routes/connectors.js +76 -118
  143. package/dist/src/gateway/hono/routes/models.js +24 -0
  144. package/dist/src/gateway/hono/routes/public-gateway.js +3 -2
  145. package/dist/src/gateway/hono/routes/sessions.js +17 -42
  146. package/dist/src/gateway/hono/routes/you.js +86 -5
  147. package/dist/src/gateway/service/sessions-api.d.ts +2 -3
  148. package/dist/src/gateway/service/sessions-api.js +4 -7
  149. package/dist/src/gateway/service.d.ts +5 -2
  150. package/dist/src/gateway/service.js +16 -11
  151. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +19 -0
  152. package/dist/src/knowledge/connected-understanding-pipeline.js +268 -0
  153. package/dist/src/knowledge/index.d.ts +1 -0
  154. package/dist/src/knowledge/index.js +2 -1
  155. package/dist/src/knowledge/ingestion-service.d.ts +6 -4
  156. package/dist/src/knowledge/ingestion-service.js +13 -10
  157. package/dist/src/knowledge/local-folder-adapter.js +1 -0
  158. package/dist/src/knowledge/people-graph.js +43 -110
  159. package/dist/src/knowledge/types.d.ts +3 -0
  160. package/dist/src/providers/xopc-cloud-account-service.d.ts +40 -0
  161. package/dist/src/providers/xopc-cloud-account-service.js +65 -0
  162. package/dist/src/session/index.d.ts +1 -2
  163. package/dist/src/session/index.js +1 -2
  164. package/dist/src/session/init-session-turn.d.ts +0 -1
  165. package/dist/src/session/init-session-turn.js +1 -2
  166. package/dist/src/session/manager.d.ts +11 -17
  167. package/dist/src/session/manager.js +11 -14
  168. package/dist/src/session/session-context-for-llm.d.ts +19 -1
  169. package/dist/src/session/session-context-for-llm.js +87 -129
  170. package/dist/src/session/store.d.ts +28 -23
  171. package/dist/src/session/store.js +94 -83
  172. package/dist/src/session/transcript-format.d.ts +2 -8
  173. package/dist/src/session/types.d.ts +8 -6
  174. package/dist/src/session/user-round-delete.d.ts +3 -6
  175. package/dist/src/session/user-round-delete.js +12 -16
  176. package/dist/src/storage/sqlite/connector-learning-repository.d.ts +47 -0
  177. package/dist/src/storage/sqlite/connector-learning-repository.js +110 -0
  178. package/dist/src/storage/sqlite/index.d.ts +4 -2
  179. package/dist/src/storage/sqlite/index.js +5 -3
  180. package/dist/src/storage/sqlite/knowledge-repository.d.ts +4 -2
  181. package/dist/src/storage/sqlite/knowledge-repository.js +24 -13
  182. package/dist/src/storage/sqlite/migrations/060_remove_runtime_transcript_messages.sql +45 -0
  183. package/dist/src/storage/sqlite/migrations/061_drop_compaction_checkpoints.sql +2 -0
  184. package/dist/src/storage/sqlite/migrations/062_connector_learning_jobs.sql +27 -0
  185. package/dist/src/storage/sqlite/migrations/063_knowledge_collection_scopes.sql +14 -0
  186. package/dist/src/storage/sqlite/migrations/064_user_claims.sql +60 -0
  187. package/dist/src/storage/sqlite/migrations/065_knowledge_item_scope_identity.sql +116 -0
  188. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  189. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  190. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  191. package/dist/src/storage/sqlite/schema.js +1 -1
  192. package/dist/src/storage/sqlite/schema.sql +0 -19
  193. package/dist/src/storage/sqlite/transcript-repository.d.ts +6 -11
  194. package/dist/src/storage/sqlite/transcript-repository.js +90 -84
  195. package/dist/src/storage/sqlite/user-claims-repository.d.ts +101 -0
  196. package/dist/src/storage/sqlite/user-claims-repository.js +241 -0
  197. package/dist/src/user-context/config.d.ts +67 -2
  198. package/dist/src/user-context/config.js +36 -3
  199. package/dist/src/user-context/projection.d.ts +36 -1
  200. package/dist/src/user-context/projection.js +84 -6
  201. package/dist/src/work-discovery/service.js +1 -0
  202. package/package.json +1 -1
  203. package/dist/gateway/static/root/assets/agents-BiaQhiQp.js +0 -2
  204. package/dist/gateway/static/root/assets/apps-page-CuL8Q4yF.js +0 -1
  205. package/dist/gateway/static/root/assets/automations-page-TZOluRNp.js +0 -6
  206. package/dist/gateway/static/root/assets/browser-settings-page-C-l6O68Z.js +0 -8
  207. package/dist/gateway/static/root/assets/capabilities-settings-panel-BW8c0xPp.js +0 -7
  208. package/dist/gateway/static/root/assets/channels-settings-h9CsE0GT.js +0 -1
  209. package/dist/gateway/static/root/assets/channels-status-swr-C058Mcfr.js +0 -1
  210. package/dist/gateway/static/root/assets/connector-logo-CsbegNqi.js +0 -1
  211. package/dist/gateway/static/root/assets/connectors-page-BWALafGW.js +0 -2
  212. package/dist/gateway/static/root/assets/dreaming-settings-DkdnKMZx.js +0 -3
  213. package/dist/gateway/static/root/assets/goal-create-dialog-y2Y3p7_k.js +0 -1
  214. package/dist/gateway/static/root/assets/goal-detail-page-DuzL-alv.js +0 -4
  215. package/dist/gateway/static/root/assets/goals-page-OeLtfKI2.js +0 -2
  216. package/dist/gateway/static/root/assets/index-o4uaOGKT.css +0 -1
  217. package/dist/gateway/static/root/assets/local-app-workbench-page-3ssYIEK6.js +0 -2
  218. package/dist/gateway/static/root/assets/messages-KEk-hTFt.js +0 -3
  219. package/dist/gateway/static/root/assets/notes-workbench-CatZNAPc.js +0 -4
  220. package/dist/gateway/static/root/assets/project-detail-page-DJUOgqm4.js +0 -1
  221. package/dist/gateway/static/root/assets/projects-page-BQQAD_nu.js +0 -1
  222. package/dist/gateway/static/root/assets/remote-access-hub-fIGXTTnA.js +0 -1
  223. package/dist/gateway/static/root/assets/sessions-page-BuU-8FCe.js +0 -1
  224. package/dist/gateway/static/root/assets/settings-advanced-gate-DlKoeZm3.js +0 -1
  225. package/dist/gateway/static/root/assets/setup-status-panel-BSUcDFnb.js +0 -1
  226. package/dist/gateway/static/root/assets/shares-settings-Bk2-SwGJ.js +0 -1
  227. package/dist/gateway/static/root/assets/skill-reload-api-e_Fx1kVC.js +0 -1
  228. package/dist/gateway/static/root/assets/skills-page-D_cCADfj.js +0 -2
  229. package/dist/gateway/static/root/assets/time-picker-fqRXpNJV.js +0 -1
  230. package/dist/gateway/static/root/assets/user-context-page-9Ov4htPW.js +0 -1
  231. package/dist/gateway/static/root/assets/work-discovery-page-DGN2FxWv.js +0 -1
  232. package/dist/gateway/static/root/assets/work-item-detail-page-HmyWSgUo.js +0 -1
  233. package/dist/gateway/static/root/assets/work-page-D3iKVjFq.js +0 -1
  234. package/dist/gateway/static/root/assets/workflows-page-B5L4SFw4.js +0 -11
  235. package/dist/src/agent/lifecycle/handlers/compaction.d.ts +0 -13
  236. package/dist/src/agent/lifecycle/handlers/compaction.js +0 -18
  237. package/dist/src/connectors/memory-sync-coordinator.d.ts +0 -28
  238. package/dist/src/connectors/memory-sync-coordinator.js +0 -162
  239. package/dist/src/connectors/memory-sync-profile.d.ts +0 -13
  240. package/dist/src/connectors/memory-sync-profile.js +0 -73
  241. package/dist/src/session/compaction-checkpoints.d.ts +0 -8
  242. package/dist/src/session/compaction-checkpoints.js +0 -19
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-RnGYy9bC.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{Qa as t}from"./index-Dfq2laZe.js";async function n(n,r){let i,a=r||`unnamed`,o=`application/octet-stream`,s=0;if(typeof n==`string`){let e=await fetch(n);if(!e.ok)throw Error(`Failed to fetch file`);if(i=await e.arrayBuffer(),s=i.byteLength,o=e.headers.get(`content-type`)||o,!r){let e=n.split(`/`);a=e[e.length-1]||`document`}}else if(n instanceof File)i=await n.arrayBuffer(),s=n.size,o=n.type||o,a=r||n.name;else if(n instanceof Blob)i=await n.arrayBuffer(),s=n.size,o=n.type||o;else if(n instanceof ArrayBuffer)i=n,s=n.byteLength;else throw Error(`Invalid source type`);let c=new Uint8Array(i),l=``,u=32768;for(let e=0;e<c.length;e+=u){let t=c.slice(e,e+u);l+=String.fromCharCode(...t)}let d=btoa(l),f=`${a}_${Date.now()}_${Math.random()}`;if(o===`application/pdf`||a.toLowerCase().endsWith(`.pdf`)){let{processPdf:t}=await e(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPdf:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n,preview:r}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/pdf`,size:s,content:d,extractedText:n,preview:r}}if(o===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||a.toLowerCase().endsWith(`.docx`)){let{processDocx:t}=await e(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processDocx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:s,content:d,extractedText:n}}if(o===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||a.toLowerCase().endsWith(`.pptx`)){let{processPptx:t}=await e(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:s,content:d,extractedText:n}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(o)||a.toLowerCase().endsWith(`.xlsx`)||a.toLowerCase().endsWith(`.xls`)){let{processExcel:t}=await e(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processExcel:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:o&&o.startsWith(`application/vnd`)?o:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:s,content:d,extractedText:n}}if(o?.startsWith(`image/`))return{id:f,type:`image`,name:a,mimeType:o,size:s,content:d,preview:d};if(o?.startsWith(`audio/`))return{id:f,type:`voice`,name:a,mimeType:o,size:s,content:d};if(t(a,o??``)){let e=new TextDecoder().decode(i);return{id:f,type:`document`,name:a,mimeType:o?.startsWith(`text/`)?o:`text/plain`,size:s,content:d,extractedText:e}}throw Error(`Unsupported file type: ${o}`)}export{n as loadAttachment};
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{$a as t}from"./index-DUasAutC.js";async function n(n,r){let i,a=r||`unnamed`,o=`application/octet-stream`,s=0;if(typeof n==`string`){let e=await fetch(n);if(!e.ok)throw Error(`Failed to fetch file`);if(i=await e.arrayBuffer(),s=i.byteLength,o=e.headers.get(`content-type`)||o,!r){let e=n.split(`/`);a=e[e.length-1]||`document`}}else if(n instanceof File)i=await n.arrayBuffer(),s=n.size,o=n.type||o,a=r||n.name;else if(n instanceof Blob)i=await n.arrayBuffer(),s=n.size,o=n.type||o;else if(n instanceof ArrayBuffer)i=n,s=n.byteLength;else throw Error(`Invalid source type`);let c=new Uint8Array(i),l=``,u=32768;for(let e=0;e<c.length;e+=u){let t=c.slice(e,e+u);l+=String.fromCharCode(...t)}let d=btoa(l),f=`${a}_${Date.now()}_${Math.random()}`;if(o===`application/pdf`||a.toLowerCase().endsWith(`.pdf`)){let{processPdf:t}=await e(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPdf:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n,preview:r}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/pdf`,size:s,content:d,extractedText:n,preview:r}}if(o===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||a.toLowerCase().endsWith(`.docx`)){let{processDocx:t}=await e(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processDocx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:s,content:d,extractedText:n}}if(o===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||a.toLowerCase().endsWith(`.pptx`)){let{processPptx:t}=await e(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:s,content:d,extractedText:n}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(o)||a.toLowerCase().endsWith(`.xlsx`)||a.toLowerCase().endsWith(`.xls`)){let{processExcel:t}=await e(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processExcel:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:o&&o.startsWith(`application/vnd`)?o:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:s,content:d,extractedText:n}}if(o?.startsWith(`image/`))return{id:f,type:`image`,name:a,mimeType:o,size:s,content:d,preview:d};if(o?.startsWith(`audio/`))return{id:f,type:`voice`,name:a,mimeType:o,size:s,content:d};if(t(a,o??``)){let e=new TextDecoder().decode(i);return{id:f,type:`document`,name:a,mimeType:o?.startsWith(`text/`)?o:`text/plain`,size:s,content:d,extractedText:e}}throw Error(`Unsupported file type: ${o}`)}export{n as loadAttachment};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{l as n}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-KEk-hTFt.js";import{n as a}from"./locale-store-Dqp9H2Uf.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{Ns as s,b as c,fl as l,hu as u,lc as d,v as f,x as p,y as m}from"./index-Dfq2laZe.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:p,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=a(b),D=i(E).automations.suggestions,O=i(E).automations,k=n(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=o(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>c(e,S)):void 0,N=M?f(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=r(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,C),t[1]=C,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(u,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let i;return t[4]===k?i=t[5]:(i=()=>k(`/automations`),t[4]=k,t[5]=i),(0,g.jsxs)(`section`,{className:e,children:[n,(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:D.coveredTitle}),(0,g.jsx)(s,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:i,children:D.manage})]})}let e;t[6]===C?e=t[7]:(e=r(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,C),t[6]=C,t[7]=e);let n;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(l,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=n):n=t[8];let i;t[9]!==_||t[10]!==p?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:p}),t[9]=_,t[10]=p,t[11]=i):i=t[11];let a;t[12]!==k||t[13]!==x?(a=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[12]=k,t[13]=x,t[14]=a):a=t[14];let o;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[15]=o):o=t[15],(0,g.jsxs)(`section`,{className:e,children:[n,i,(0,g.jsxs)(s,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[o,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=r(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let i;t[19]===k?i=t[20]:(i=()=>k(`/automations`),t[19]=k,t[20]=i);let a;return t[21]!==D||t[22]!==i?(a=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsx)(s,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:i,children:D.manage})}),t[21]=D,t[22]=i,t[23]=a):a=t[23],(0,g.jsxs)(`section`,{className:e,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:D.coveredTitle}),(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:m(D.coveredDescription,{name:M.name})})]})]}),(0,g.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:O.explain.whyCovered}),(0,g.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:N.map(v)})]}),a]})}let P;t[24]===C?P=t[25]:(P=r(`rounded-lg bg-surface-panel p-3 shadow-surface`,C),t[24]=C,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===p?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:p}),t[27]=p,t[28]=I);let L;t[29]===_?L=t[30]:(L=(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:_}),t[29]=_,t[30]=L);let R;t[31]!==I||t[32]!==L?(R=(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[F,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]})]}),t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==k||t[35]!==x?(z=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[34]=k,t[35]=x,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[37]=B):B=t[37];let V;t[38]!==D.create||t[39]!==z?(V=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsxs)(s,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:z,children:[B,D.create]})}),t[38]=D.create,t[39]=z,t[40]=V):V=t[40];let H;return t[41]!==V||t[42]!==P||t[43]!==R?(H=(0,g.jsxs)(`section`,{className:P,children:[R,V]}),t[41]=V,t[42]=P,t[43]=R,t[44]=H):H=t[44],H}function v(e){return(0,g.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function y(){return p.list()}function b(e){return e.language}export{_ as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{l as n}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-BWtP5TFz.js";import{n as a}from"./locale-store-BP0vD37A.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{Ps as s,_u as c,b as l,ml as u,uc as d,v as f,x as p,y as m}from"./index-DUasAutC.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:p,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=a(b),D=i(E).automations.suggestions,O=i(E).automations,k=n(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=o(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>l(e,S)):void 0,N=M?f(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=r(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,C),t[1]=C,t[2]=e);let n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(c,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=t[3];let i;return t[4]===k?i=t[5]:(i=()=>k(`/automations`),t[4]=k,t[5]=i),(0,g.jsxs)(`section`,{className:e,children:[n,(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:D.coveredTitle}),(0,g.jsx)(s,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:i,children:D.manage})]})}let e;t[6]===C?e=t[7]:(e=r(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,C),t[6]=C,t[7]=e);let n;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(u,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=n):n=t[8];let i;t[9]!==_||t[10]!==p?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:p}),t[9]=_,t[10]=p,t[11]=i):i=t[11];let a;t[12]!==k||t[13]!==x?(a=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[12]=k,t[13]=x,t[14]=a):a=t[14];let o;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[15]=o):o=t[15],(0,g.jsxs)(`section`,{className:e,children:[n,i,(0,g.jsxs)(s,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[o,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=r(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=t[18];let i;t[19]===k?i=t[20]:(i=()=>k(`/automations`),t[19]=k,t[20]=i);let a;return t[21]!==D||t[22]!==i?(a=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsx)(s,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:i,children:D.manage})}),t[21]=D,t[22]=i,t[23]=a):a=t[23],(0,g.jsxs)(`section`,{className:e,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[n,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:D.coveredTitle}),(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:m(D.coveredDescription,{name:M.name})})]})]}),(0,g.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:O.explain.whyCovered}),(0,g.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:N.map(v)})]}),a]})}let P;t[24]===C?P=t[25]:(P=r(`rounded-lg bg-surface-panel p-3 shadow-surface`,C),t[24]=C,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===p?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:p}),t[27]=p,t[28]=I);let L;t[29]===_?L=t[30]:(L=(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:_}),t[29]=_,t[30]=L);let R;t[31]!==I||t[32]!==L?(R=(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[F,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]})]}),t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==k||t[35]!==x?(z=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[34]=k,t[35]=x,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[37]=B):B=t[37];let V;t[38]!==D.create||t[39]!==z?(V=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsxs)(s,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:z,children:[B,D.create]})}),t[38]=D.create,t[39]=z,t[40]=V):V=t[40];let H;return t[41]!==V||t[42]!==P||t[43]!==R?(H=(0,g.jsxs)(`section`,{className:P,children:[R,V]}),t[41]=V,t[42]=P,t[43]=R,t[44]=H):H=t[44],H}function v(e){return(0,g.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function y(){return p.list()}function b(e){return e.language}export{_ as t};
@@ -0,0 +1,6 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-BWtP5TFz.js";import{n as l}from"./locale-store-BP0vD37A.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{A as d,Bc as f,Ci as p,Dc as m,Ei as h,Eo as g,Go as _,Hc as v,Hu as y,Ic as b,Is as x,Ji as S,Jl as ee,Jo as C,Ko as w,Ls as T,Pc as E,Pl as D,Ps as O,Qo as k,Rr as te,Si as A,Su as j,Wo as ne,Xo as re,Xs as M,Yo as ie,_u as ae,eo as oe,io as N,ls as P,mc as se,nl as ce,oa as le,sl as ue,ss as F,uc as de,wi as fe,x as I,xi as pe,xu as me,yu as L}from"./index-DUasAutC.js";import{t as he}from"./time-picker-D-G-uwVJ.js";import{t as ge}from"./format-cron-label-arqgGlVV.js";import{a as R,i as _e,n as z,r as ve,t as ye}from"./workflow-run-setup-panel-D7vKChFZ.js";import{i as be,n as xe,r as Se,t as Ce}from"./browser-workflow-inputs-CimCGbhq.js";var B=e(t(),1),V=n(),H=1e3,U=60*H,W=60*U,G=24*W,K=7*G,we=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Te=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),q={en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},Ee={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},J={minute:U,hour:W,day:G,week:K};function De(e){return e===`zh`?`zh-CN`:`en-US`}function Oe(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Te[String(t)].format(e)}function ke(e,t){return t===`zh`?e.join(` `):we.format(e)}function Ae(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(U,Math.round((Number.isFinite(n)&&n>0?n:1)*J[t]))}function je(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*J[t]/J[n]).toFixed(6)))}function Me(e,t){let n=Math.max(H,Math.round(e)),r=n===G?[{unit:`hour`,ms:W}]:n>=K&&n%K===0?[{unit:`week`,ms:K}]:n>=G?[{unit:`day`,ms:G},{unit:`hour`,ms:W},{unit:`minute`,ms:U},{unit:`second`,ms:H}]:n>=W?[{unit:`hour`,ms:W},{unit:`minute`,ms:U},{unit:`second`,ms:H}]:n>=U?[{unit:`minute`,ms:U},{unit:`second`,ms:H}]:[{unit:`second`,ms:H}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Oe(r,e,t)),i%=n)}return ke(a,t)}function Y(e,t){let n=Me(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function X(e,t){return q[t].format(new Date(e))}function Ne(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Pe(e,t,n=Date.now()){let r=new Date(e),i=Math.round((Ne(r)-Ne(new Date(n)))/G),a=Ee[t].format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:X(e,t)}function Fe(e,t){return e.eventType===`goal.status_changed`&&e.payloadMatch?.status===`blocked`?t.trigger.goalBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function Ie(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return Fe(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Pe(Date.parse(i.at),r)):i.kind===`interval`?Y(i.everyMs,r):ge(i.expr,De(r),n.scheduleBadge,{timezone:i.tz})}function Le(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Pe(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function Re(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Pe(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var ze={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,browserWorkflowId:``,browserWorkflowInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`},Be=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Ve(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`goalBlocked`)o={kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Ae(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=ve(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_recipe`?`auto_apply`:e.safetyMode,u=l===`auto_apply`?e.afterRunMode:`none`,d;return d=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:e.actionMode===`browser_recipe`?{kind:`browser_recipe`,recipeId:e.browserWorkflowId.trim(),args:e.browserWorkflowInputs,timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:d,safety:{mode:l},afterRun:u===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:u},reliability:{timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function He(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:ze.time,weekday:ze.weekday,cronExpr:e}}function Ue(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function We(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function Ge(e){let t=e.payloadMatch;return e.eventType===`goal.status_changed`&&e.source===`goals`&&t?.status===`blocked`?{triggerMode:`goalBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function Ke(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function qe(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function Je(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=Ge(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=He(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...Ue(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:We(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?Ke(r.input):{},o=e.afterRun??{kind:`none`},s=r.timeoutSeconds??e.reliability?.timeoutSeconds??300;return{...ze,...n,name:e.name,description:e.description??``,actionMode:r.kind,agentId:r.kind===`browser_recipe`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserWorkflowId:r.kind===`browser_recipe`?r.recipeId:``,browserWorkflowInputs:r.kind===`browser_recipe`?r.args??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?z(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(s),afterRunMode:o.kind,webhookUrl:o.kind===`webhook`?o.url:``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function Ye(e,t,n){let r=Ve(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`?a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}:e.action.kind===`browser_recipe`&&r.action.kind===`browser_recipe`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function Xe(e,t,n){return e?X(e,n):t.never}function Ze(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_recipe`?`Browser automation: ${e.recipeId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function Qe(e){return e.safety?.mode??`auto_apply`}function $e(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function et(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function tt(e){return e.status===`running`||e.status===`queued`}function nt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function rt(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function it(e){return!!rt(e)}function at(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function ot(e){return tt(e)?0:nt(e)?1:e.status===`succeeded`?2:3}function st(e){return[...e].sort((e,t)=>{let n=ot(e)-ot(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function ct(e){let t=(0,V.c)(5),n;t[0]===e?n=t[1]:(n=()=>typeof window>`u`?!1:window.matchMedia(e).matches,t[0]=e,t[1]=n);let[r,i]=(0,B.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),n=()=>i(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,B.useEffect)(a,o),r}function lt(){let e=(0,V.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsx)(N,{className:`h-4 w-36`}),(0,Z.jsx)(N,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(N,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(ut)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(N,{className:`h-4 w-32`}),i=(0,Z.jsx)(N,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Z.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Z.jsx)(N,{className:`h-12 rounded-lg`}),(0,Z.jsx)(N,{className:`h-12 rounded-lg`}),(0,Z.jsx)(N,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function ut(e,t){return(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(N,{className:`size-4 rounded-full`}),(0,Z.jsx)(N,{className:`h-4 w-32`}),(0,Z.jsx)(N,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(N,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(N,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(N,{className:`h-8 w-24 rounded-md`})]})},t)}function dt(){let e=l(e=>e.language),t=c(e),n=t.automations,r=t.cron,a=g(e=>e.setPageHeader),o=g(e=>e.clearPageHeader),[f,m]=i(),v=f.get(`run`)?.trim()??``,y=f.get(`automation`)?.trim()??``,b=f.get(`draft`)?.trim()??``,x=f.get(`action`)?.trim()??``,S=f.get(`projectId`)?.trim()??``,ee=f.get(`autogenerate`)===`1`,D=f.get(`insight`)?.trim()??``,te=(0,B.useRef)(``),j=ct(`(min-width: 1280px)`),[M,ae]=(0,B.useState)(`activity`),[N,P]=(0,B.useState)(!1),[se,ce]=(0,B.useState)(`blank`),[ue,F]=(0,B.useState)(null),[de,me]=(0,B.useState)(!1),[L,he]=(0,B.useState)(ze),[ge,R]=(0,B.useState)(null),[z,ve]=(0,B.useState)(null),[ye,Se]=(0,B.useState)(!1),[Ce,V]=(0,B.useState)(null),[H,U]=(0,B.useState)(``),[W,G]=(0,B.useState)(null),[K,we]=(0,B.useState)(!1),[Te,q]=(0,B.useState)(!1),[Ee,J]=(0,B.useState)(null),[De,Oe]=(0,B.useState)(!1),[ke,Ae]=(0,B.useState)(!1),[je,Me]=(0,B.useState)(!1),[Y,X]=(0,B.useState)(null),Ne=u([`automations`,S],()=>I.list(S?{projectId:S}:void 0),{refreshInterval:15e3}),Pe=u([`automation-runs`,S],()=>I.runs(50,void 0,S?{projectId:S}:void 0),{refreshInterval:1e4}),Fe=u(`automation-metrics`,()=>I.metrics(),{refreshInterval:15e3}),Ie=u(z?`automation-run-events:${z}`:null,()=>I.runEvents(z),{refreshInterval:5e3}),Le=u(`automation-workflow-definitions`,d),Re=u(`automation-browser-workflows`,()=>be.list()),Be=u(`automation-chat-agents`,oe),He=Ne.isLoading&&!Ne.data||Pe.isLoading&&!Pe.data||Fe.isLoading&&!Fe.data,Ue=Ne.data?.automations??[],We=(0,B.useMemo)(()=>st(Pe.data?.runs??[]),[Pe.data?.runs]),Ge=(0,B.useMemo)(()=>Ue.filter(e=>!it(e)),[Ue]),Ke=(0,B.useMemo)(()=>Ue.filter(it),[Ue]),Ze=(0,B.useMemo)(()=>new Set(Ke.map(e=>e.id)),[Ke]),Qe=(0,B.useMemo)(()=>We.filter(e=>!Ze.has(e.automationId)),[We,Ze]),$e=(0,B.useMemo)(()=>{let e;for(let t of Ge){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[Ge]),et=(0,B.useMemo)(()=>We.find(e=>e.id===z)??null,[We,z]),tt=(0,B.useMemo)(()=>Ue.find(e=>e.id===Ce)??null,[Ue,Ce]),rt=(0,B.useMemo)(()=>Ue.find(e=>e.id===ue)??null,[Ue,ue]),at=(0,B.useMemo)(()=>We.filter(e=>e.automationId===Ce),[We,Ce]),ot=Ie.data?.events??[],ut=(0,B.useMemo)(()=>Qe.filter(nt),[Qe]),dt=Qe[0]??null,mt=(0,B.useMemo)(()=>Le.data??[],[Le.data]),ht=(0,B.useMemo)(()=>(Re.data?.workflows??[]).filter(e=>e.enabled),[Re.data]),vt=Be.data?.items??[],yt=(0,B.useMemo)(()=>mt.find(e=>e.id===L.workflowId.trim())??null,[L.workflowId,mt]),bt=(0,B.useMemo)(()=>ht.find(e=>e.id===L.browserWorkflowId.trim())??null,[ht,L.browserWorkflowId]),Ct=L.actionMode===`workflow`&&(!L.workflowId.trim()||mt.length>0&&!mt.some(e=>e.id===L.workflowId)),wt=L.actionMode===`workflow`&&yt?!_e(yt,L.workflowInput,L.workflowInputValid).valid:!1,Tt=!!L.name.trim()&&(L.triggerMode!==`once`||Number.isFinite(new Date(L.onceAt).getTime()))&&(L.triggerMode!==`event`||!!L.eventType.trim()&&qe(L.eventPayloadMatch))&&(L.actionMode===`workflow`?!Ct&&!wt:L.actionMode===`browser_recipe`?bt!==null&&xe(bt,L.browserWorkflowInputs):!!L.instruction.trim())&&(L.afterRunMode!==`webhook`||!!L.webhookUrl.trim()),Et=(0,B.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...ze,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...ze,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:mt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...ze,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...ze,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...ze,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,mt]);(0,B.useEffect)(()=>{M!==`activity`||Qe.length===0||z&&Qe.some(e=>e.id===z)||ve(Qe[0].id)},[z,Qe,M]);let Dt=(0,B.useCallback)(async()=>{await Promise.all([Ne.mutate(),Pe.mutate(),Fe.mutate(),Ie.mutate()])},[Ne.mutate,Fe.mutate,Ie.mutate,Pe.mutate]),Ot=(0,B.useCallback)(e=>{F(null),me(!1),ce(e),P(!0),e===`blank`&&he(ze)},[]),kt=(0,B.useCallback)(e=>{he(Je(e,mt)),F(e.id),me(!1),V(null),ce(`blank`),P(!0)},[mt]),At=(0,B.useCallback)(()=>{W&&(he(Je(W.automation,mt)),F(null),me(!0),ce(`blank`))},[W,mt]),Mt=(0,B.useCallback)(async()=>{Me(!0),R(null);try{await Dt()}catch(e){let t=e instanceof Error?e.message:String(e);R(t),k({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Me(!1)}},[n.feedback.actionFailed,Dt]);(0,B.useEffect)(()=>{v&&(ae(`activity`),ve(v),j||Se(!0))},[v,j]),(0,B.useEffect)(()=>{if(!y)return;let e=Ue.find(e=>e.id===y);e&&(ae(it(e)?`system`:`automations`),V(e.id),m(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[y,Ue,m]),(0,B.useEffect)(()=>{j&&Se(!1)},[j]),(0,B.useEffect)(()=>{x===`create`&&(Ot(`blank`),m(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[x,Ot,m]),(0,B.useEffect)(()=>{if(!b)return;let t=`${e}:${ee?`auto`:`seed`}:${b}`;te.current!==t&&(te.current=t,U(b),G(null),q(!1),ce(`draft`),P(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t.delete(`insight`),t},{replace:!0}),ee&&(R(null),we(!0),I.draft({prompt:b,language:e}).then(e=>{G(e.draft),q(!1),D&&I.completeInsightDraft(D)}).catch(e=>{R(e instanceof Error?e.message:String(e))}).finally(()=>{we(!1)})))},[ee,b,D,e,m]);let Nt=(0,B.useCallback)(e=>{ve(e),j||Se(!0),m(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[m,j]);(0,B.useEffect)(()=>{J(null),Ae(!1)},[z]);async function Q(){if(R(null),Tt){if(de&&W){X(`draft:edit`);try{let e=Ve(L,yt),{simulation:t}=await I.simulate(e);G({...W,automation:e,simulation:t}),q(!1),me(!1),ce(`draft`)}catch(e){let t=e instanceof Error?e.message:String(e);R(t),k({type:`error`,title:n.feedback.actionFailed,message:t})}finally{X(null)}return}if(rt){let e=rt.id;await $(`automation:${e}:edit`,()=>I.update(e,Ye(rt,L,yt)))&&(P(!1),F(null),V(e));return}try{await I.create({...Ve(L,yt),...S?{projectId:S}:{}}),he(ze),P(!1),await Dt()}catch(e){let t=e instanceof Error?e.message:String(e);R(t),k({type:`error`,title:n.feedback.actionFailed,message:t})}}}async function $(e,t){R(null),X(e);try{return await t(),await Dt(),!0}catch(e){let t=e instanceof Error?e.message:String(e);return R(t),k({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{X(null)}}async function Pt(){let t=H.trim();if(t){R(null),we(!0);try{G((await I.draft({prompt:t,language:e})).draft),q(!1)}catch(e){R(e instanceof Error?e.message:String(e))}finally{we(!1)}}}async function Ft(){W&&await $(`draft:publish`,async()=>{await I.create({...W.automation,...S?{projectId:S}:{}}),G(null),U(``),q(!1),P(!1)})}async function It(t){R(null),Oe(!0),J(null),Ae(!1);try{J((await I.repairDraft(t.id,{language:e})).repair)}catch(e){R(e instanceof Error?e.message:String(e))}finally{Oe(!1)}}async function Lt(e){Ee&&await $(`run:${e.id}:repair`,async()=>{await I.update(e.automationId,Ee.patch),J(null),Ae(!1)})}let Rt=(0,B.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(le,{className:`size-9 shrink-0 p-0`,loading:je,label:n.refresh,onClick:Mt}),(0,Z.jsxs)(fe,{children:[(0,Z.jsx)(h,{asChild:!0,children:(0,Z.jsxs)(O,{variant:`primary`,children:[(0,Z.jsx)(E,{className:`size-4`}),n.new]})}),(0,Z.jsx)(p,{children:(0,Z.jsxs)(pe,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ot(`draft`),children:n.createMenu.draft}),(0,Z.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ot(`template`),children:n.createMenu.template}),(0,Z.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ot(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,Ot,je,Mt]);return(0,B.useLayoutEffect)(()=>(a({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:Rt}),()=>o()),[o,Rt,n.subtitle,n.title,a]),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,Z.jsx)(ft,{label:n.dashboard.needsAttention,value:ut.length,tone:ut.length>0?`danger`:`neutral`}),(0,Z.jsx)(ft,{label:n.metrics.running,value:Qe.filter(e=>e.status===`running`).length}),(0,Z.jsx)(ft,{label:n.dashboard.latestResult,value:dt?n.status[dt.status]:n.none,tone:dt&&nt(dt)?`danger`:`neutral`}),(0,Z.jsx)(ft,{label:n.metrics.next,value:$e?Xe($e,n,e):n.none})]}),(0,Z.jsx)(`nav`,{className:`inline-flex w-fit rounded-lg border border-edge bg-surface-panel p-1`,children:[{id:`activity`,label:n.dashboard.activity,count:Qe.length},{id:`automations`,label:n.dashboard.manage,count:Ge.length},{id:`system`,label:n.system.title,count:Ke.length}].map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:s(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,M===e.id&&`bg-surface-hover text-fg`),onClick:()=>{ae(e.id),e.id!==`activity`&&Se(!1)},children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`span`,{className:`rounded-full border border-edge/70 px-1.5 py-0.5 text-[0.6875rem] leading-none text-fg-muted`,children:e.count})]},e.id))}),ge?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:ge}):null,He?(0,Z.jsx)(lt,{}):M===`activity`?(0,Z.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(18rem,22rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(_t,{runs:Qe.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:z,busyAction:Y,className:`h-auto`,onSelectRun:Nt,onAction:$})}),(0,Z.jsx)(xt,{className:`hidden xl:sticky xl:top-4 xl:block`,run:et,events:ot,labels:n,cronLabels:r,language:e,loading:Ie.isLoading,repairDraft:Ee,repairLoading:De,repairApproved:ke,busyAction:Y,onRepairApprovedChange:Ae,onSuggestRepair:It,onApplyRepair:Lt})]}):M===`automations`?(0,Z.jsx)(`section`,{children:(0,Z.jsx)(gt,{automations:Ge,runs:Qe,labels:n,cronLabels:r,language:e,busyAction:Y,onOpenDetails:V,onAction:$})}):(0,Z.jsx)(`section`,{children:(0,Z.jsx)(gt,{automations:Ke,runs:We,labels:n,cronLabels:r,language:e,busyAction:Y,readOnly:!0,onOpenDetails:V,onAction:$})})]}),(0,Z.jsx)(ne,{open:N,onOpenChange:e=>{P(e),e||(F(null),me(!1))},children:(0,Z.jsxs)(ie,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(w,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsx)(re,{className:`text-base font-semibold text-fg`,children:se===`draft`?n.draft.title:se===`template`?n.createMenu.templatesTitle:rt?n.editTitle:de?n.draft.editTitle:n.createTitle}),(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(O,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(T,{className:`size-4`})})})]}),se===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(pt,{labels:n,prompt:H,draft:W,loading:K,approved:Te,publishBusy:Y===`draft:publish`,onPromptChange:U,onGenerate:Pt,onEdit:At,onPublish:Ft,onApprovedChange:q,onDiscard:()=>{G(null),q(!1)}})}):se===`template`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:Et.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{he(e.form),ce(`blank`)},children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(jt,{form:L,labels:n,setForm:he,workflowDefinitions:mt,selectedWorkflow:yt,workflowsLoading:Le.isLoading,browserWorkflows:ht,selectedBrowserWorkflow:bt,browserWorkflowsLoading:Re.isLoading,agentOptions:vt,agentsLoading:Be.isLoading,language:e}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[de?(0,Z.jsx)(O,{variant:`ghost`,onClick:()=>{me(!1),ce(`draft`)},children:n.cancel}):(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(O,{variant:`ghost`,children:n.cancel})}),(0,Z.jsx)(O,{variant:`primary`,onClick:Q,disabled:!Tt||Y===`draft:edit`||!!(rt&&Y),children:Y===`draft:edit`||rt&&Y===`automation:${rt.id}:edit`?n.feedback.working:rt||de?n.save:n.create})]})]})]})]})}),(0,Z.jsx)(St,{automation:tt,runs:at,labels:n,cronLabels:r,language:e,busyAction:Y,onClose:()=>V(null),onSelectRun:e=>{Nt(e),V(null)},onEdit:kt,onAction:$}),(0,Z.jsx)(ne,{open:!j&&ye&&!!et,onOpenChange:Se,children:(0,Z.jsxs)(ie,{children:[(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(w,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(re,{className:`truncate text-base font-semibold text-fg`,children:et?.automationName??n.dashboard.result}),(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(O,{variant:`ghost`,"aria-label":n.close,children:(0,Z.jsx)(T,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(xt,{className:`rounded-none border-0`,run:et,events:ot,labels:n,cronLabels:r,language:e,loading:Ie.isLoading,repairDraft:Ee,repairLoading:De,repairApproved:ke,busyAction:Y,onRepairApprovedChange:Ae,onSuggestRepair:It,onApplyRepair:Lt})})]})]})})]})}function ft(e){let t=(0,V.c)(13),{label:n,value:r,tone:i}=e,a=i===void 0?`neutral`:i,o=a===`danger`&&`bg-red-500/10`,c;t[0]===o?c=t[1]:(c=s(`rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,o),t[0]=o,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=a===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=s(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,Z.jsx)(`div`,{className:d,children:r}),t[6]=d,t[7]=r,t[8]=f):f=t[8];let p;return t[9]!==c||t[10]!==l||t[11]!==f?(p=(0,Z.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function pt(e){let t=(0,V.c)(49),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onEdit:u,onPublish:d,onApprovedChange:p,onDiscard:m}=e,h=s===void 0?!1:s,g=!!(i&&i.simulation.requiredConfirmations.length>0),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Z.jsx)(de,{className:`size-4 text-accent`}),t[0]=_):_=t[0];let v;t[1]===n.draft.title?v=t[2]:(v=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[_,n.draft.title]}),t[1]=n.draft.title,t[2]=v);let y;t[3]===n.draft.subtitle?y=t[4]:(y=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=y);let b;t[5]!==v||t[6]!==y?(b=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[v,y]}),t[5]=v,t[6]=y,t[7]=b):b=t[7];let x;t[8]!==a||t[9]!==r?(x=a||!r.trim(),t[8]=a,t[9]=r,t[10]=x):x=t[10];let S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(de,{className:`size-4`}),t[11]=S):S=t[11];let ee=a?n.draft.generating:n.draft.generate,C;t[12]!==l||t[13]!==x||t[14]!==ee?(C=(0,Z.jsxs)(O,{variant:`primary`,onClick:l,disabled:x,children:[S,ee]}),t[12]=l,t[13]=x,t[14]=ee,t[15]=C):C=t[15];let w;t[16]!==b||t[17]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[b,C]}),t[16]=b,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=e=>c(e.target.value),t[19]=c,t[20]=T);let E;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==T?(E=(0,Z.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:T,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=T,t[24]=E):E=t[24];let D;t[25]!==o||t[26]!==i||t[27]!==n.draft.approval||t[28]!==n.draft.assumptions||t[29]!==n.draft.discard||t[30]!==n.draft.edit||t[31]!==n.draft.publish||t[32]!==n.draft.review||t[33]!==n.draft.risks||t[34]!==n.draft.safety||t[35]!==n.feedback||t[36]!==n.info||t[37]!==n.none||t[38]!==p||t[39]!==m||t[40]!==u||t[41]!==d||t[42]!==h||t[43]!==g?(D=i?(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Z.jsx)(kt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(kt,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Z.jsx)(mt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(mt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(mt,{title:n.draft.risks,items:i.risks,empty:n.none}),g?(0,Z.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>p(e.target.checked)}),(0,Z.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(O,{variant:`ghost`,onClick:m,children:n.draft.discard}),(0,Z.jsxs)(O,{variant:`secondary`,onClick:u,children:[(0,Z.jsx)(f,{className:`size-4`}),n.draft.edit]}),(0,Z.jsx)(O,{variant:`primary`,onClick:d,disabled:h||g&&!o,children:h?n.feedback.working:n.draft.publish})]})]})]}):null,t[25]=o,t[26]=i,t[27]=n.draft.approval,t[28]=n.draft.assumptions,t[29]=n.draft.discard,t[30]=n.draft.edit,t[31]=n.draft.publish,t[32]=n.draft.review,t[33]=n.draft.risks,t[34]=n.draft.safety,t[35]=n.feedback,t[36]=n.info,t[37]=n.none,t[38]=p,t[39]=m,t[40]=u,t[41]=d,t[42]=h,t[43]=g,t[44]=D):D=t[44];let k;return t[45]!==w||t[46]!==E||t[47]!==D?(k=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[w,E,D]}),t[45]=w,t[46]=E,t[47]=D,t[48]=k):k=t[48],k}function mt(e){let t=(0,V.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(ht):(0,Z.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function ht(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function gt(e){let t=(0,V.c)(24),{automations:n,runs:r,labels:i,cronLabels:a,language:o,busyAction:c,readOnly:l,onOpenDetails:u,onAction:d}=e,f=l===void 0?!1:l;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(x,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.automations?n=t[2]:(n=(0,Z.jsx)(At,{icon:e,title:i.empty.automations}),t[1]=i.empty.automations,t[2]=n),n}let p;if(t[3]!==n||t[4]!==c||t[5]!==a||t[6]!==i||t[7]!==o||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==r){let e;t[13]!==c||t[14]!==a||t[15]!==i||t[16]!==o||t[17]!==d||t[18]!==u||t[19]!==f||t[20]!==r?(e=e=>{let t=at(e),n=r.filter(t=>t.automationId===e.id),l=n.find(tt),p=n[0],h=c===`automation:${e.id}:run`,g=c===`automation:${e.id}:toggle`,_=c===`automation:${e.id}:delete`;return(0,Z.jsxs)(`article`,{className:`flex min-h-44 cursor-pointer flex-col rounded-lg border border-edge-subtle bg-surface-base p-3.5 shadow-surface outline-none transition-colors hover:bg-surface-hover`,role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),l?(0,Z.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,Z.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?i.enabled:i.paused})]}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:i.info.when}),(0,Z.jsx)(`span`,{className:`truncate`,children:Ie(e.trigger,i,a,o)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:i.info.run}),(0,Z.jsx)(`span`,{className:`truncate`,children:Ze(e.action,i)})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`span`,{children:[i.last,`: `,Xe(e.state.lastRunAtMs,i,o)]}),(0,Z.jsxs)(`span`,{children:[i.next,`: `,Xe(e.state.nextRunAtMs,i,o)]}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5`,$e(e.state.lastRunStatus)),children:e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.status.notRun}),p?.error?(0,Z.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:p.error}):null]}),f?null:(0,Z.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(O,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:run`,()=>I.runNow(e.id),i.feedback.rerunQueued)},children:(0,Z.jsx)(b,{className:s(`size-4`,h&&`animate-pulse`)})}),(0,Z.jsx)(O,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?i.dashboard.pause:i.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:toggle`,()=>e.enabled?I.pause(e.id):I.resume(e.id),e.enabled?i.feedback.paused:i.dashboard.resumed)},children:g?(0,Z.jsx)(m,{className:`size-4 animate-spin`}):e.enabled?(0,Z.jsx)(v,{className:`size-4`}):(0,Z.jsx)(b,{className:`size-4`})}),(0,Z.jsx)(O,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:delete`,()=>I.remove(e.id),i.dashboard.deleted)},children:_?(0,Z.jsx)(m,{className:`size-4 animate-spin`}):(0,Z.jsx)(M,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=a,t[15]=i,t[16]=o,t[17]=d,t[18]=u,t[19]=f,t[20]=r,t[21]=e):e=t[21],p=n.map(e),t[3]=n,t[4]=c,t[5]=a,t[6]=i,t[7]=o,t[8]=d,t[9]=u,t[10]=f,t[11]=r,t[12]=p}else p=t[12];let h;return t[22]===p?h=t[23]:(h=(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:p}),t[22]=p,t[23]=h),h}function _t(e){let t=(0,V.c)(25),{runs:n,labels:r,cronLabels:i,language:a,selectedRunId:o,busyAction:c,className:l,onSelectRun:u,onAction:d}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(y,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,Z.jsx)(At,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let f;t[3]===l?f=t[4]:(f=s(`overflow-hidden rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,l),t[3]=l,t[4]=f);let p;if(t[5]!==c||t[6]!==i||t[7]!==r||t[8]!==a||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==o){let e;t[14]!==c||t[15]!==i||t[16]!==r||t[17]!==a||t[18]!==d||t[19]!==u||t[20]!==o?(e=e=>(0,Z.jsxs)(`div`,{className:s(`grid cursor-pointer gap-3 border-b border-edge p-4 outline-none last:border-b-0 hover:bg-surface-hover md:grid-cols-[1fr_auto]`,o===e.id&&`bg-surface-hover`),role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs`,$e(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,Z.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,Z.jsx)(`div`,{className:s(`mt-1 line-clamp-2 whitespace-pre-line text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||(tt(e)?r.runDetail.resultPending:r.runDetail.noResult)}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[Xe(e.createdAtMs,r,a),` · `,e.manual?r.trigger.manual:Ie(e.triggerSnapshot,r,i,a)]})]}),e.status===`running`||e.status===`queued`?(0,Z.jsx)(O,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>I.cancelRun(e.id),r.dashboard.cancelled)},children:c===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id),t[14]=c,t[15]=i,t[16]=r,t[17]=a,t[18]=d,t[19]=u,t[20]=o,t[21]=e):e=t[21],p=n.map(e),t[5]=c,t[6]=i,t[7]=r,t[8]=a,t[9]=d,t[10]=u,t[11]=n,t[12]=o,t[13]=p}else p=t[13];let m;return t[22]!==f||t[23]!==p?(m=(0,Z.jsx)(`div`,{className:f,children:p}),t[22]=f,t[23]=p,t[24]=m):m=t[24],m}function vt(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`after_run.started`:return n.afterRunStarted;case`after_run.completed`:return n.afterRunCompleted;case`after_run.failed`:return n.afterRunFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function yt(e){let t=(0,V.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,c]=(0,B.useState)(a===void 0?!1:a),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
2
+ `),t[2]=u,t[3]=d);let f=d.length,p=u.length>720||f>18,m;t[4]!==p||t[5]!==u?(m=p?`${u.split(`
3
+ `).slice(0,10).join(`
4
+ `).trimEnd()}...`:u,t[4]=p,t[5]=u,t[6]=m):m=t[6];let h=m,g;t[7]!==o||t[8]!==p||t[9]!==r||t[10]!==i?(g=p?(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>c(bt),"aria-expanded":o,children:[(0,Z.jsx)(`span`,{children:i}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[o?r.details.hideDetails:r.details.showDetails,(0,Z.jsx)(me,{className:s(`size-3.5 transition-transform`,o&&`rotate-180`),"aria-hidden":!0})]})]}):(0,Z.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=o,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=o||!p?u:h,v;t[12]===_?v=t[13]:(v=(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=v);let y;return t[14]!==g||t[15]!==v?(y=(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[g,v]}),t[14]=g,t[15]=v,t[16]=y):y=t[16],y}function bt(e){return!e}function xt(e){let t=(0,V.c)(148),{className:n,run:r,events:i,labels:c,cronLabels:l,language:u,loading:d,repairDraft:f,repairLoading:p,repairApproved:m,busyAction:h,onRepairApprovedChange:g,onSuggestRepair:_,onApplyRepair:v}=e;if(!r){let e;t[0]===n?e=t[1]:(e=s(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(y,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===c.selectRun?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`mt-2`,children:c.selectRun}),t[3]=c.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,Z.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let b=r.error||r.summary,x=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,ee=r.sessionKey?c.runDetail.openConversation:c.runDetail.openWorkflow,C=r.sessionKey?ce:D,w=tt(r)?y:nt(r)?o:ae,T;t[8]===n?T=t[9]:(T=s(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=T);let E;t[10]===r.automationName?E=t[11]:(E=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=E);let k;t[12]===r.id?k=t[13]:(k=r.id.slice(0,8),t[12]=r.id,t[13]=k);let te;t[14]===k?te=t[15]:(te=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:k}),t[14]=k,t[15]=te);let A;t[16]!==E||t[17]!==te?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[E,te]}),t[16]=E,t[17]=te,t[18]=A):A=t[18];let j;t[19]===r.status?j=t[20]:(j=s(`shrink-0 rounded-full px-2 py-0.5 text-xs`,$e(r.status)),t[19]=r.status,t[20]=j);let ne=c.status[r.status],re;t[21]!==j||t[22]!==ne?(re=(0,Z.jsx)(`span`,{className:j,children:ne}),t[21]=j,t[22]=ne,t[23]=re):re=t[23];let M;t[24]!==A||t[25]!==re?(M=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[A,re]}),t[24]=A,t[25]=re,t[26]=M):M=t[26];let ie;t[27]!==c||t[28]!==u||t[29]!==r.createdAtMs?(ie=Xe(r.createdAtMs,c,u),t[27]=c,t[28]=u,t[29]=r.createdAtMs,t[30]=ie):ie=t[30];let oe;t[31]===ie?oe=t[32]:(oe=(0,Z.jsx)(`span`,{children:ie}),t[31]=ie,t[32]=oe);let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=P):P=t[33];let se=c.details.duration,le;t[34]!==c||t[35]!==r.durationMs?(le=et(r.durationMs,c),t[34]=c,t[35]=r.durationMs,t[36]=le):le=t[36];let F;t[37]!==c.details.duration||t[38]!==le?(F=(0,Z.jsxs)(`span`,{children:[se,` `,le]}),t[37]=c.details.duration,t[38]=le,t[39]=F):F=t[39];let fe;t[40]!==oe||t[41]!==F?(fe=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[oe,P,F]}),t[40]=oe,t[41]=F,t[42]=fe):fe=t[42];let I;t[43]!==c.repair||t[44]!==_||t[45]!==p||t[46]!==r?(I=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(O,{variant:`secondary`,onClick:()=>_(r),disabled:p,children:[(0,Z.jsx)(de,{className:`size-4`}),p?c.repair.generating:c.repair.suggest]})}):null,t[43]=c.repair,t[44]=_,t[45]=p,t[46]=r,t[47]=I):I=t[47];let pe;t[48]!==fe||t[49]!==I||t[50]!==M?(pe=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[M,fe,I]}),t[48]=fe,t[49]=I,t[50]=M,t[51]=pe):pe=t[51];let he;t[52]===r?he=t[53]:(he=tt(r)?`text-blue-500`:nt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=he);let ge;t[54]===he?ge=t[55]:(ge=s(`size-4`,he),t[54]=he,t[55]=ge);let R;t[56]!==w||t[57]!==ge?(R=(0,Z.jsx)(w,{className:ge}),t[56]=w,t[57]=ge,t[58]=R):R=t[58];let _e;t[59]!==c.runDetail.resultTitle||t[60]!==R?(_e=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[R,c.runDetail.resultTitle]}),t[59]=c.runDetail.resultTitle,t[60]=R,t[61]=_e):_e=t[61];let z;t[62]!==C||t[63]!==ee||t[64]!==x?(z=x?(0,Z.jsx)(O,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:x,children:[(0,Z.jsx)(C,{className:`size-3.5`}),ee,(0,Z.jsx)(L,{className:`size-3.5`})]})}):null,t[62]=C,t[63]=ee,t[64]=x,t[65]=z):z=t[65];let ve;t[66]!==_e||t[67]!==z?(ve=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[_e,z]}),t[66]=_e,t[67]=z,t[68]=ve):ve=t[68];let ye=r.error&&`border-red-500/25 bg-red-500/5`,be;t[69]===ye?be=t[70]:(be=s(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,ye),t[69]=ye,t[70]=be);let xe;t[71]!==c.runDetail.noResult||t[72]!==c.runDetail.resultPending||t[73]!==b||t[74]!==r?(xe=b?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:b}):(0,Z.jsx)(S,{content:b,compact:!0,className:`text-sm`,openHttpLinksInNewTab:!0}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:tt(r)?c.runDetail.resultPending:c.runDetail.noResult}),t[71]=c.runDetail.noResult,t[72]=c.runDetail.resultPending,t[73]=b,t[74]=r,t[75]=xe):xe=t[75];let Se;t[76]!==be||t[77]!==xe?(Se=(0,Z.jsx)(`div`,{className:be,children:xe}),t[76]=be,t[77]=xe,t[78]=Se):Se=t[78];let Ce;t[79]!==ve||t[80]!==Se?(Ce=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[ve,Se]}),t[79]=ve,t[80]=Se,t[81]=Ce):Ce=t[81];let B;t[82]===c.runDetail.runInfo?B=t[83]:(B=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:c.runDetail.runInfo}),t[82]=c.runDetail.runInfo,t[83]=B);let H;t[84]!==l||t[85]!==c||t[86]!==u||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(H=r.manual?c.trigger.manual:Ie(r.triggerSnapshot,c,l,u),t[84]=l,t[85]=c,t[86]=u,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=H):H=t[89];let U;t[90]!==c.explain.whyRan||t[91]!==H?(U=(0,Z.jsx)(Dt,{label:c.explain.whyRan,value:H}),t[90]=c.explain.whyRan,t[91]=H,t[92]=U):U=t[92];let W=c.details.started,G;t[93]!==c||t[94]!==u||t[95]!==r.startedAtMs?(G=Xe(r.startedAtMs,c,u),t[93]=c,t[94]=u,t[95]=r.startedAtMs,t[96]=G):G=t[96];let K;t[97]!==c.details.started||t[98]!==G?(K=(0,Z.jsx)(Dt,{label:W,value:G}),t[97]=c.details.started,t[98]=G,t[99]=K):K=t[99];let we;t[100]!==c.details.model||t[101]!==r.model?(we=r.model?(0,Z.jsx)(Dt,{label:c.details.model,value:r.model}):null,t[100]=c.details.model,t[101]=r.model,t[102]=we):we=t[102];let Te;t[103]!==U||t[104]!==K||t[105]!==we?(Te=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[U,K,we]}),t[103]=U,t[104]=K,t[105]=we,t[106]=Te):Te=t[106];let q;t[107]!==B||t[108]!==Te?(q=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[B,Te]}),t[107]=B,t[108]=Te,t[109]=q):q=t[109];let Ee;t[110]!==h||t[111]!==c||t[112]!==v||t[113]!==g||t[114]!==m||t[115]!==f||t[116]!==r?(Ee=f?(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:c.repair.title}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:f.explanation}),f.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:f.expectedEffect}):null,(0,Z.jsx)(mt,{title:c.repair.risks,items:f.risks,empty:c.none}),(0,Z.jsx)(yt,{value:f.patch,labels:c,title:c.details.repairPatch}),f.requiresApproval?(0,Z.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:m,onChange:e=>g(e.target.checked)}),(0,Z.jsx)(`span`,{children:c.repair.approval})]}):null,(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsx)(O,{variant:`primary`,onClick:()=>v(r),disabled:h===`run:${r.id}:repair`||f.requiresApproval&&!m,children:h===`run:${r.id}:repair`?c.feedback.working:c.repair.apply})})]}):null,t[110]=h,t[111]=c,t[112]=v,t[113]=g,t[114]=m,t[115]=f,t[116]=r,t[117]=Ee):Ee=t[117];let J;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(ue,{className:`size-4 shrink-0`}),t[118]=J):J=t[118];let De;t[119]===c.runDetail.technicalEvents?De=t[120]:(De=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[J,c.runDetail.technicalEvents]}),t[119]=c.runDetail.technicalEvents,t[120]=De);let Oe;t[121]!==i.length||t[122]!==c.runDetail.eventCount?(Oe=c.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=c.runDetail.eventCount,t[123]=Oe):Oe=t[123];let ke;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(me,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=ke):ke=t[124];let Ae;t[125]===Oe?Ae=t[126]:(Ae=(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[Oe,ke]}),t[125]=Oe,t[126]=Ae);let je;t[127]!==De||t[128]!==Ae?(je=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[De,Ae]}),t[127]=De,t[128]=Ae,t[129]=je):je=t[129];let Me;t[130]===c.runDetail.technicalEventsDescription?Me=t[131]:(Me=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:c.runDetail.technicalEventsDescription}),t[130]=c.runDetail.technicalEventsDescription,t[131]=Me);let Y;t[132]!==i||t[133]!==c||t[134]!==u||t[135]!==d?(Y=(0,Z.jsx)(`div`,{className:`mt-4`,children:d?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":c.loading,children:[(0,Z.jsx)(N,{className:`h-10 w-full`}),(0,Z.jsx)(N,{className:`h-10 w-4/5`}),(0,Z.jsx)(N,{className:`h-10 w-11/12`})]}):i.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-muted`,children:c.empty.events}):(0,Z.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,Z.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,Z.jsx)(`span`,{className:s(`mt-1 size-2 rounded-full`,Ot(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:vt(e,c)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[Xe(e.createdAtMs,c,u),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,Z.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[c.details.eventData,(0,Z.jsx)(me,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,Z.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=c,t[134]=u,t[135]=d,t[136]=Y):Y=t[136];let X;t[137]!==je||t[138]!==Me||t[139]!==Y?(X=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[je,Me,Y]}),t[137]=je,t[138]=Me,t[139]=Y,t[140]=X):X=t[140];let Ne;return t[141]!==T||t[142]!==pe||t[143]!==Ce||t[144]!==q||t[145]!==Ee||t[146]!==X?(Ne=(0,Z.jsxs)(`aside`,{className:T,children:[pe,Ce,q,Ee,X]}),t[141]=T,t[142]=pe,t[143]=Ce,t[144]=q,t[145]=Ee,t[146]=X,t[147]=Ne):Ne=t[147],Ne}function St(e){let t=(0,V.c)(23),{automation:n,runs:r,labels:i,cronLabels:o,language:c,busyAction:l,onClose:u,onEdit:d,onSelectRun:p,onAction:h}=e,g=n?l===`automation:${n.id}:run`:!1,x=n?l===`automation:${n.id}:toggle`:!1,S=n?l===`automation:${n.id}:delete`:!1,E=!!n,k;t[0]===u?k=t[1]:(k=e=>!e&&u(),t[0]=u,t[1]=k);let te;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Z.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[2]=te):te=t[2];let A;t[3]!==n||t[4]!==l||t[5]!==o||t[6]!==S||t[7]!==i||t[8]!==c||t[9]!==h||t[10]!==u||t[11]!==d||t[12]!==p||t[13]!==g||t[14]!==r||t[15]!==x?(A=n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(re,{className:`truncate text-base font-semibold text-fg`,children:n.name}),n.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:n.description}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs`,n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:n.enabled?i.enabled:i.paused}),(0,Z.jsx)(_,{asChild:!0,children:(0,Z.jsx)(O,{variant:`ghost`,"aria-label":i.close,children:(0,Z.jsx)(T,{className:`size-4`})})})]})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[20rem_1fr]`,children:[(0,Z.jsx)(wt,{automation:n,labels:i,cronLabels:o,language:c}),(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length})]}),r.length===0?(0,Z.jsx)(At,{icon:(0,Z.jsx)(y,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`grid gap-2`,children:r.map(e=>(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`min-w-0 text-left outline-none`,onClick:()=>p(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Z.jsx)(ae,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(y,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:Xe(e.createdAtMs,i,c)}),(0,Z.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs`,$e(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.error||e.summary||Ze(e.actionSnapshot,i)})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.sessionKey?(0,Z.jsx)(O,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,Z.jsxs)(a,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,Z.jsx)(ee,{className:`size-3.5`}),i.dashboard.openSession]})}):null,e.workflowRunId?(0,Z.jsx)(O,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,Z.jsxs)(a,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,Z.jsx)(D,{className:`size-3.5`}),i.feedback.workflow]})}):null]})]})},e.id))})]})]})}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge px-5 py-4`,children:[(0,Z.jsxs)(O,{variant:`ghost`,disabled:l!==null,onClick:()=>void h(`automation:${n.id}:delete`,()=>I.remove(n.id),i.dashboard.deleted).then(e=>{e&&u()}),children:[S?(0,Z.jsx)(m,{className:`size-4 animate-spin`}):(0,Z.jsx)(M,{className:`size-4`}),i.dashboard.delete]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[it(n)?null:(0,Z.jsxs)(O,{variant:`secondary`,disabled:l!==null,onClick:()=>d(n),children:[(0,Z.jsx)(f,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(O,{variant:`secondary`,disabled:l!==null,onClick:()=>void h(`automation:${n.id}:toggle`,()=>n.enabled?I.pause(n.id):I.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[x?(0,Z.jsx)(m,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(v,{className:`size-4`}):(0,Z.jsx)(b,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(O,{variant:`primary`,disabled:l!==null,onClick:()=>void h(`automation:${n.id}:run`,()=>I.runNow(n.id),i.feedback.rerunQueued),children:[g?(0,Z.jsx)(m,{className:`size-4 animate-spin`}):(0,Z.jsx)(b,{className:`size-4`}),i.dashboard.runNow]})]})]})]}):null,t[3]=n,t[4]=l,t[5]=o,t[6]=S,t[7]=i,t[8]=c,t[9]=h,t[10]=u,t[11]=d,t[12]=p,t[13]=g,t[14]=r,t[15]=x,t[16]=A):A=t[16];let j;t[17]===A?j=t[18]:(j=(0,Z.jsxs)(ie,{children:[te,(0,Z.jsx)(w,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,56rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:A})]}),t[17]=A,t[18]=j);let oe;return t[19]!==E||t[20]!==k||t[21]!==j?(oe=(0,Z.jsx)(ne,{open:E,onOpenChange:k,children:j}),t[19]=E,t[20]=k,t[21]=j,t[22]=oe):oe=t[22],oe}function Ct(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function wt(e){let t=(0,V.c)(127),{automation:n,labels:r,cronLabels:i,language:a}=e,o,s,c,l,u,d,f,p,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=Qe(n),_;t[15]!==n||t[16]!==r||t[17]!==a?(_=Le(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=_):_=t[18];let v=_,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?X(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=y):y=t[21];let b=y;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(g=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],g.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],g.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=X(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],g.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],g.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],g.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],g.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],g.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],g.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],g.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=g}else g=t[39];m=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?h=t[71]:(h=(0,Z.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=h),d=`grid gap-4 p-4`;let S;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Z.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t[72]=S):S=t[72];let ee=r.info.schedule,C;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(C=Ie(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=C):C=t[77];let w=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==C||t[81]!==w?(f=(0,Z.jsx)(Et,{icon:S,label:ee,value:C,description:w,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=C,t[81]=w,t[82]=f):f=t[82];let T;t[83]===n.action.kind?T=t[84]:(T=n.action.kind===`workflow`?(0,Z.jsx)(D,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_recipe`?(0,Z.jsx)(ue,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=T);let E=r.info.action,O;t[85]!==n.action||t[86]!==r?(O=Ze(n.action,r),t[85]=n.action,t[86]=r,t[87]=O):O=t[87],t[88]!==r.info.action||t[89]!==T||t[90]!==O?(p=(0,Z.jsx)(Et,{icon:T,label:E,value:O}),t[88]=r.info.action,t[89]=T,t[90]=O,t[91]=p):p=t[91],o=Et,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Z.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[92]=s):s=t[92],c=r.info.permission,l=r.safety[e],u=Ct(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[93]!==o||t[94]!==s||t[95]!==c||t[96]!==l||t[97]!==u?(_=(0,Z.jsx)(o,{icon:s,label:c,value:l,description:u}),t[93]=o,t[94]=s,t[95]=c,t[96]=l,t[97]=u,t[98]=_):_=t[98];let v;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[99]=v):v=t[99];let b=r.info.lastRun,S;t[100]!==n||t[101]!==r||t[102]!==a?(S=Re(n,r,a),t[100]=n,t[101]=r,t[102]=a,t[103]=S):S=t[103];let ee=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,C;t[104]!==r.info.lastRun||t[105]!==S||t[106]!==ee?(C=(0,Z.jsx)(Et,{icon:v,label:b,value:S,valueTone:ee}),t[104]=r.info.lastRun,t[105]=S,t[106]=ee,t[107]=C):C=t[107];let w;t[108]!==n.state.consecutiveFailures||t[109]!==n.state.lastError||t[110]!==r.dashboard?(w=n.state.consecutiveFailures?(0,Z.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,Z.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,Z.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[108]=n.state.consecutiveFailures,t[109]=n.state.lastError,t[110]=r.dashboard,t[111]=w):w=t[111];let T;t[112]!==r.info.technicalDetails||t[113]!==g?(T=g.length>0?(0,Z.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsx)(`span`,{children:r.info.technicalDetails}),(0,Z.jsx)(me,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:g.map(Tt)})]}):null,t[112]=r.info.technicalDetails,t[113]=g,t[114]=T):T=t[114];let E;t[115]!==_||t[116]!==C||t[117]!==w||t[118]!==T||t[119]!==d||t[120]!==f||t[121]!==p?(E=(0,Z.jsxs)(`div`,{className:d,children:[f,p,_,C,w,T]}),t[115]=_,t[116]=C,t[117]=w,t[118]=T,t[119]=d,t[120]=f,t[121]=p,t[122]=E):E=t[122];let O;return t[123]!==E||t[124]!==m||t[125]!==h?(O=(0,Z.jsxs)(`aside`,{className:m,children:[h,E]}),t[123]=E,t[124]=m,t[125]=h,t[126]=O):O=t[126],O}function Tt(e){return(0,Z.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function Et(e){let t=(0,V.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:c}=e,l=c===void 0?`default`:c,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=d);let f=l===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,p;t[4]===f?p=t[5]:(p=s(`mt-1 text-sm font-medium leading-5`,f),t[4]=f,t[5]=p);let m;t[6]!==p||t[7]!==i?(m=(0,Z.jsx)(`div`,{className:p,children:i}),t[6]=p,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==a||t[10]!==o?(h=a?(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:o,children:a}):null,t[9]=a,t[10]=o,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==m||t[14]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[d,m,h]}),t[12]=d,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==u||t[17]!==g?(_=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[u,g]}),t[16]=u,t[17]=g,t[18]=_):_=t[18],_}function Dt(e){let t=(0,V.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Ot(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function kt(e){let t=(0,V.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function At(e){let t=(0,V.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function jt(e){let t=(0,V.c)(224),{form:n,labels:r,setForm:i,workflowDefinitions:a,selectedWorkflow:o,workflowsLoading:l,browserWorkflows:u,selectedBrowserWorkflow:d,browserWorkflowsLoading:f,agentOptions:p,agentsLoading:m,language:h}=e,g=c(h).agentsSettings,_;t[0]===i?_=t[1]:(_=e=>i(t=>({...t,...e})),t[0]=i,t[1]=_);let v=_,y=Ae(n.intervalValue,n.intervalUnit),b=Date.now(),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=[1,2,3],t[2]=x):x=t[2];let S;t[3]!==y||t[4]!==b||t[5]!==h?(S=x.map(e=>Pe(b+y*e,h,b)),t[3]=y,t[4]=b,t[5]=h,t[6]=S):S=t[6];let ee=S,C,w;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==a?(C=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=a[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},w=[n.actionMode,n.workflowId,i,a],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=a,t[11]=C,t[12]=w):(C=t[11],w=t[12]),(0,B.useEffect)(C,w);let T,E;t[13]!==u||t[14]!==n.actionMode||t[15]!==n.browserWorkflowId||t[16]!==i?(T=()=>{if(n.actionMode!==`browser_recipe`||n.browserWorkflowId.trim())return;let e=u[0];e&&i(t=>({...t,browserWorkflowId:e.id,browserWorkflowInputs:Se(e)}))},E=[u,n.actionMode,n.browserWorkflowId,i],t[13]=u,t[14]=n.actionMode,t[15]=n.browserWorkflowId,t[16]=i,t[17]=T,t[18]=E):(T=t[17],E=t[18]),(0,B.useEffect)(T,E);let D;t[19]===v?D=t[20]:(D=e=>v({name:e.target.value}),t[19]=v,t[20]=D);let O;t[21]!==n.name||t[22]!==D?(O=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:D}),t[21]=n.name,t[22]=D,t[23]=O):O=t[23];let k;t[24]!==r.form.name||t[25]!==O?(k=(0,Z.jsx)($,{label:r.form.name,children:O}),t[24]=r.form.name,t[25]=O,t[26]=k):k=t[26];let A;t[27]===v?A=t[28]:(A=e=>v({description:e.target.value}),t[27]=v,t[28]=A);let j;t[29]!==n.description||t[30]!==A?(j=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:A}),t[29]=n.description,t[30]=A,t[31]=j):j=t[31];let ne;t[32]!==r.form.description||t[33]!==j?(ne=(0,Z.jsx)($,{label:r.form.description,children:j}),t[32]=r.form.description,t[33]=j,t[34]=ne):ne=t[34];let re;t[35]===r.form.trigger?re=t[36]:(re=(0,Z.jsx)(Pt,{title:r.form.trigger}),t[35]=r.form.trigger,t[36]=re);let M;t[37]===v?M=t[38]:(M=e=>v({triggerMode:e.target.value}),t[37]=v,t[38]=M);let ie;t[39]===r.trigger.manual?ie=t[40]:(ie=(0,Z.jsx)(P,{value:`manual`,children:r.trigger.manual}),t[39]=r.trigger.manual,t[40]=ie);let ae;t[41]===r.trigger.once?ae=t[42]:(ae=(0,Z.jsx)(P,{value:`once`,children:r.trigger.once}),t[41]=r.trigger.once,t[42]=ae);let oe;t[43]===r.trigger.daily?oe=t[44]:(oe=(0,Z.jsx)(P,{value:`daily`,children:r.trigger.daily}),t[43]=r.trigger.daily,t[44]=oe);let N;t[45]===r.trigger.weekly?N=t[46]:(N=(0,Z.jsx)(P,{value:`weekly`,children:r.trigger.weekly}),t[45]=r.trigger.weekly,t[46]=N);let se;t[47]===r.trigger.interval?se=t[48]:(se=(0,Z.jsx)(P,{value:`interval`,children:r.trigger.interval}),t[47]=r.trigger.interval,t[48]=se);let ce;t[49]===r.trigger.customCron?ce=t[50]:(ce=(0,Z.jsx)(P,{value:`cron`,children:r.trigger.customCron}),t[49]=r.trigger.customCron,t[50]=ce);let le;t[51]===r.trigger.webhook?le=t[52]:(le=(0,Z.jsx)(P,{value:`webhook`,children:r.trigger.webhook}),t[51]=r.trigger.webhook,t[52]=le);let ue;t[53]===r.trigger.goalBlocked?ue=t[54]:(ue=(0,Z.jsx)(P,{value:`goalBlocked`,children:r.trigger.goalBlocked}),t[53]=r.trigger.goalBlocked,t[54]=ue);let de;t[55]===r.trigger.noteCreated?de=t[56]:(de=(0,Z.jsx)(P,{value:`noteCreated`,children:r.trigger.noteCreated}),t[55]=r.trigger.noteCreated,t[56]=de);let fe;t[57]===r.trigger.workflowFailed?fe=t[58]:(fe=(0,Z.jsx)(P,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[57]=r.trigger.workflowFailed,t[58]=fe);let I;t[59]===r.trigger.sessionUpdated?I=t[60]:(I=(0,Z.jsx)(P,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[59]=r.trigger.sessionUpdated,t[60]=I);let pe;t[61]===r.trigger.customEvent?pe=t[62]:(pe=(0,Z.jsx)(P,{value:`event`,children:r.trigger.customEvent}),t[61]=r.trigger.customEvent,t[62]=pe);let me;t[63]!==n.triggerMode||t[64]!==M||t[65]!==ie||t[66]!==ae||t[67]!==oe||t[68]!==N||t[69]!==se||t[70]!==ce||t[71]!==le||t[72]!==ue||t[73]!==de||t[74]!==fe||t[75]!==I||t[76]!==pe?(me=(0,Z.jsxs)(F,{className:Q,value:n.triggerMode,onChange:M,children:[ie,ae,oe,N,se,ce,le,ue,de,fe,I,pe]}),t[63]=n.triggerMode,t[64]=M,t[65]=ie,t[66]=ae,t[67]=oe,t[68]=N,t[69]=se,t[70]=ce,t[71]=le,t[72]=ue,t[73]=de,t[74]=fe,t[75]=I,t[76]=pe,t[77]=me):me=t[77];let L;t[78]!==n.onceAt||t[79]!==n.triggerMode||t[80]!==r.form.onceAt||t[81]!==v?(L=n.triggerMode===`once`?(0,Z.jsx)($,{label:r.form.onceAt,children:(0,Z.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>v({onceAt:e.target.value})})}):null,t[78]=n.onceAt,t[79]=n.triggerMode,t[80]=r.form.onceAt,t[81]=v,t[82]=L):L=t[82];let ge;t[83]!==n.time||t[84]!==n.triggerMode||t[85]!==n.weekday||t[86]!==r.form.day||t[87]!==r.form.time||t[88]!==r.weekdays||t[89]!==v?(ge=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.time,children:(0,Z.jsx)(he,{value:n.time,onChange:e=>v({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,Z.jsx)($,{label:r.form.day,children:(0,Z.jsxs)(F,{className:Q,value:n.weekday,onChange:e=>v({weekday:e.target.value}),children:[(0,Z.jsx)(P,{value:`1`,children:r.weekdays.monday}),(0,Z.jsx)(P,{value:`2`,children:r.weekdays.tuesday}),(0,Z.jsx)(P,{value:`3`,children:r.weekdays.wednesday}),(0,Z.jsx)(P,{value:`4`,children:r.weekdays.thursday}),(0,Z.jsx)(P,{value:`5`,children:r.weekdays.friday}),(0,Z.jsx)(P,{value:`6`,children:r.weekdays.saturday}),(0,Z.jsx)(P,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[83]=n.time,t[84]=n.triggerMode,t[85]=n.weekday,t[86]=r.form.day,t[87]=r.form.time,t[88]=r.weekdays,t[89]=v,t[90]=ge):ge=t[90];let _e=n.triggerMode===`interval`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsx)($,{label:r.form.intervalEvery,children:(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Z.jsx)(`input`,{className:Q,type:`number`,min:6e4/Ae(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>v({intervalValue:e.target.value})}),(0,Z.jsxs)(F,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;v({intervalValue:je(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Z.jsx)(P,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Z.jsx)(P,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Z.jsx)(P,{value:`day`,children:r.form.intervalUnits.day}),(0,Z.jsx)(P,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Be.map(e=>{let t=Ae(e.value,e.unit),n=t===y;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:s(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>v({intervalValue:e.value,intervalUnit:e.unit}),children:Me(t,h)},`${e.value}:${e.unit}`)})})]}),(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:Y(y,h)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,ee.join(h===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,z;t[91]!==n.cronExpr||t[92]!==n.triggerMode||t[93]!==r.form.expression||t[94]!==v?(z=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>v({cronExpr:e.target.value})})}):null,t[91]=n.cronExpr,t[92]=n.triggerMode,t[93]=r.form.expression,t[94]=v,t[95]=z):z=t[95];let ve;t[96]!==n.triggerMode||t[97]!==n.webhookSecretId||t[98]!==r.form.secretId||t[99]!==v?(ve=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>v({webhookSecretId:e.target.value})})}):null,t[96]=n.triggerMode,t[97]=n.webhookSecretId,t[98]=r.form.secretId,t[99]=v,t[100]=ve):ve=t[100];let be;t[101]!==n.eventPayloadMatch||t[102]!==n.eventSource||t[103]!==n.eventType||t[104]!==n.triggerMode||t[105]!==r.form.eventPayloadMatch||t[106]!==r.form.eventSource||t[107]!==r.form.eventType||t[108]!==r.form.invalidJsonObject||t[109]!==v?(be=n.triggerMode===`event`?(0,Z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)($,{label:r.form.eventType,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventType,onChange:e=>v({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>v({eventSource:e.target.value})})})]}),(0,Z.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Z.jsx)(`textarea`,{className:s(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>v({eventPayloadMatch:e.target.value}),placeholder:`{
5
+ "status": "blocked"
6
+ }`}),qe(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[101]=n.eventPayloadMatch,t[102]=n.eventSource,t[103]=n.eventType,t[104]=n.triggerMode,t[105]=r.form.eventPayloadMatch,t[106]=r.form.eventSource,t[107]=r.form.eventType,t[108]=r.form.invalidJsonObject,t[109]=v,t[110]=be):be=t[110];let xe;t[111]===r.form.action?xe=t[112]:(xe=(0,Z.jsx)(Pt,{title:r.form.action}),t[111]=r.form.action,t[112]=xe);let H;t[113]!==n.workflowId||t[114]!==v||t[115]!==a?(H=e=>{let t=e.target.value;v({actionMode:t,...t===`browser_recipe`?{safetyMode:`auto_apply`}:{},...t===`workflow`&&!n.workflowId.trim()&&a[0]?{workflowId:a[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[113]=n.workflowId,t[114]=v,t[115]=a,t[116]=H):H=t[116];let U;t[117]===r.action.runAgent?U=t[118]:(U=(0,Z.jsx)(P,{value:`agent`,children:r.action.runAgent}),t[117]=r.action.runAgent,t[118]=U);let W;t[119]===r.action.runWorkflow?W=t[120]:(W=(0,Z.jsx)(P,{value:`workflow`,children:r.action.runWorkflow}),t[119]=r.action.runWorkflow,t[120]=W);let G=h===`zh`?`浏览器自动化`:`Browser automation`,K;t[121]===G?K=t[122]:(K=(0,Z.jsx)(P,{value:`browser_recipe`,children:G}),t[121]=G,t[122]=K);let we;t[123]!==n.actionMode||t[124]!==H||t[125]!==U||t[126]!==W||t[127]!==K?(we=(0,Z.jsxs)(F,{className:Q,value:n.actionMode,onChange:H,children:[U,W,K]}),t[123]=n.actionMode,t[124]=H,t[125]=U,t[126]=W,t[127]=K,t[128]=we):we=t[128];let Te=n.actionMode===`browser_recipe`?null:(0,Z.jsx)($,{label:r.form.agent,children:(0,Z.jsxs)(F,{className:Q,value:n.agentId,onChange:e=>v({agentId:e.target.value}),children:[(0,Z.jsx)(P,{value:``,children:m?r.form.loadingAgents:r.form.defaultAgent}),p.map(e=>(0,Z.jsx)(P,{value:e.id,children:te(e,g)},e.id))]})}),q;t[129]!==u||t[130]!==f||t[131]!==n.actionMode||t[132]!==n.agentId||t[133]!==n.browserWorkflowId||t[134]!==n.browserWorkflowInputs||t[135]!==n.description||t[136]!==n.instruction||t[137]!==n.name||t[138]!==n.triggerMode||t[139]!==n.workflowId||t[140]!==n.workflowInput||t[141]!==r.form.instruction||t[142]!==r.form.loadingWorkflows||t[143]!==r.form.noWorkflows||t[144]!==r.form.triggeredRun||t[145]!==r.form.workflow||t[146]!==h||t[147]!==d||t[148]!==o||t[149]!==v||t[150]!==a||t[151]!==l?(q=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(R,{value:n.instruction,onApply:e=>v({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:h,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Z.jsx)(`textarea`,{className:s(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>v({instruction:e.target.value})})]}):n.actionMode===`workflow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:r.form.workflow,children:(0,Z.jsxs)(F,{className:Q,value:n.workflowId,onChange:e=>v({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:l||a.length===0,children:[l?(0,Z.jsx)(P,{value:``,children:r.form.loadingWorkflows}):null,!l&&a.length===0?(0,Z.jsx)(P,{value:``,children:r.form.noWorkflows}):null,a.map(Nt)]})}),o?(0,Z.jsx)(ye,{definition:o,language:h,value:n.workflowInput,onChange:e=>v({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>v({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:o.id,workflowTitle:o.title,workflowDescription:o.description}},inputClassName:`rounded-lg`}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:h===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Z.jsxs)(F,{className:Q,value:n.browserWorkflowId,onChange:e=>{let t=u.find(t=>t.id===e.target.value);v({browserWorkflowId:e.target.value,browserWorkflowInputs:t?Se(t):{}})},disabled:f||u.length===0,children:[u.length===0?(0,Z.jsx)(P,{value:``,children:h===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,u.map(Mt)]})}),d&&Object.keys(d.inputs).length>0?(0,Z.jsx)($,{label:h===`zh`?`运行时填写`:`Run inputs`,children:(0,Z.jsx)(Ce,{workflow:d,values:n.browserWorkflowInputs,language:h,onChange:e=>v({browserWorkflowInputs:e})})}):null]}),t[129]=u,t[130]=f,t[131]=n.actionMode,t[132]=n.agentId,t[133]=n.browserWorkflowId,t[134]=n.browserWorkflowInputs,t[135]=n.description,t[136]=n.instruction,t[137]=n.name,t[138]=n.triggerMode,t[139]=n.workflowId,t[140]=n.workflowInput,t[141]=r.form.instruction,t[142]=r.form.loadingWorkflows,t[143]=r.form.noWorkflows,t[144]=r.form.triggeredRun,t[145]=r.form.workflow,t[146]=h,t[147]=d,t[148]=o,t[149]=v,t[150]=a,t[151]=l,t[152]=q):q=t[152];let Ee;t[153]!==n.actionMode||t[154]!==n.afterRunMode||t[155]!==n.safetyMode||t[156]!==r.form.safety||t[157]!==r.safety||t[158]!==v?(Ee=n.actionMode===`browser_recipe`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Pt,{title:r.form.safety}),(0,Z.jsxs)($,{label:r.form.safety,children:[(0,Z.jsxs)(F,{className:Q,value:n.safetyMode,onChange:e=>{let t=e.target.value;v({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},children:[(0,Z.jsx)(P,{value:`suggest_only`,children:r.safety.suggest_only}),(0,Z.jsx)(P,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),(0,Z.jsx)(P,{value:`auto_apply`,children:r.safety.auto_apply})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription})]})]}),t[153]=n.actionMode,t[154]=n.afterRunMode,t[155]=n.safetyMode,t[156]=r.form.safety,t[157]=r.safety,t[158]=v,t[159]=Ee):Ee=t[159];let J;t[160]===r.form.afterRun?J=t[161]:(J=(0,Z.jsx)(Pt,{title:r.form.afterRun}),t[160]=r.form.afterRun,t[161]=J);let De;t[162]===v?De=t[163]:(De=e=>v({afterRunMode:e.target.value}),t[162]=v,t[163]=De);let Oe;t[164]===r.afterRun.none?Oe=t[165]:(Oe=(0,Z.jsx)(P,{value:`none`,children:r.afterRun.none}),t[164]=r.afterRun.none,t[165]=Oe);let ke;t[166]===r.afterRun.saveToSession?ke=t[167]:(ke=(0,Z.jsx)(P,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[166]=r.afterRun.saveToSession,t[167]=ke);let X=n.safetyMode!==`auto_apply`,Ne;t[168]!==r.afterRun.webhook||t[169]!==X?(Ne=(0,Z.jsx)(P,{value:`webhook`,disabled:X,children:r.afterRun.webhook}),t[168]=r.afterRun.webhook,t[169]=X,t[170]=Ne):Ne=t[170];let Fe;t[171]!==n.afterRunMode||t[172]!==De||t[173]!==Oe||t[174]!==ke||t[175]!==Ne?(Fe=(0,Z.jsxs)(F,{className:Q,value:n.afterRunMode,onChange:De,children:[Oe,ke,Ne]}),t[171]=n.afterRunMode,t[172]=De,t[173]=Oe,t[174]=ke,t[175]=Ne,t[176]=Fe):Fe=t[176];let Ie;t[177]!==n.afterRunMode||t[178]!==n.webhookUrl||t[179]!==r.form.webhookUrl||t[180]!==v?(Ie=n.afterRunMode===`webhook`?(0,Z.jsx)($,{label:r.form.webhookUrl,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>v({webhookUrl:e.target.value})})}):null,t[177]=n.afterRunMode,t[178]=n.webhookUrl,t[179]=r.form.webhookUrl,t[180]=v,t[181]=Ie):Ie=t[181];let Le;t[182]===r.form.reliability?Le=t[183]:(Le=(0,Z.jsx)(Pt,{title:r.form.reliability}),t[182]=r.form.reliability,t[183]=Le);let Re;t[184]===v?Re=t[185]:(Re=e=>v({timeoutSeconds:e.target.value}),t[184]=v,t[185]=Re);let ze;t[186]!==n.timeoutSeconds||t[187]!==Re?(ze=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:Re}),t[186]=n.timeoutSeconds,t[187]=Re,t[188]=ze):ze=t[188];let Ve;t[189]!==r.form.timeoutSeconds||t[190]!==ze?(Ve=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:ze}),t[189]=r.form.timeoutSeconds,t[190]=ze,t[191]=Ve):Ve=t[191];let He;t[192]===v?He=t[193]:(He=e=>v({disableAfterFailures:e.target.value}),t[192]=v,t[193]=He);let Ue;t[194]!==n.disableAfterFailures||t[195]!==He?(Ue=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:He}),t[194]=n.disableAfterFailures,t[195]=He,t[196]=Ue):Ue=t[196];let We;t[197]!==r.form.disableAfterFailures||t[198]!==Ue?(We=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:Ue}),t[197]=r.form.disableAfterFailures,t[198]=Ue,t[199]=We):We=t[199];let Ge;t[200]!==Ve||t[201]!==We?(Ge=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Ve,We]}),t[200]=Ve,t[201]=We,t[202]=Ge):Ge=t[202];let Ke;return t[203]!==k||t[204]!==ne||t[205]!==re||t[206]!==me||t[207]!==L||t[208]!==ge||t[209]!==_e||t[210]!==z||t[211]!==ve||t[212]!==be||t[213]!==xe||t[214]!==we||t[215]!==Te||t[216]!==q||t[217]!==Ee||t[218]!==J||t[219]!==Fe||t[220]!==Ie||t[221]!==Le||t[222]!==Ge?(Ke=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[k,ne,re,me,L,ge,_e,z,ve,be,xe,we,Te,q,Ee,J,Fe,Ie,Le,Ge]})}),t[203]=k,t[204]=ne,t[205]=re,t[206]=me,t[207]=L,t[208]=ge,t[209]=_e,t[210]=z,t[211]=ve,t[212]=be,t[213]=xe,t[214]=we,t[215]=Te,t[216]=q,t[217]=Ee,t[218]=J,t[219]=Fe,t[220]=Ie,t[221]=Le,t[222]=Ge,t[223]=Ke):Ke=t[223],Ke}function Mt(e){return(0,Z.jsx)(P,{value:e.id,children:e.name},e.id)}function Nt(e){return(0,Z.jsx)(P,{value:e.id,children:e.title||e.name},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,V.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Pt(e){let t=(0,V.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(D,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{dt as AutomationsPage};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-preview-renderer-DonnL2dL.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-KEk-hTFt.js";import{Ya as o,Za as s}from"./index-Dfq2laZe.js";import{t as c}from"./preview-open-alternatives-BKZulEYr.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-DonnL2dL.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-BWtP5TFz.js";import{Qa as o,Xa as s}from"./index-DUasAutC.js";import{t as c}from"./preview-open-alternatives-CU6XgaCz.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-DonnL2dL.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=o(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,s]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{s({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||s({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,o=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,s):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==o?(u=o?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=o,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==o?(f=o?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=o,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};