@xopcai/xopc 0.0.256 → 0.0.258

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 (139) 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/{agent-avatar-dicebear-BZJZvmYw.js → agent-avatar-dicebear-D7tpOS12.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DGHLpxj_.js +1 -0
  5. package/dist/gateway/static/root/assets/{agents-1vtaw07m.js → agents-DDiR9MCE.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-DG64SQsx.js → app-management-settings-panel-xtMKAVbv.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-BRWQdIIy.js → appearance-settings-Cngeu2w8.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-D3ziBisx.js → apps-page-CXiCvD0B.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-D3FQ9VzV.js → archive-plugin-DXKFrMNm.js} +1 -1
  10. package/dist/gateway/static/root/assets/{attachment-load-Cid3dBaW.js → attachment-load-DLYGTBVf.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-BUTNaZtj.js → automations-page-BTp6bGo4.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-CuyEKO6M.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-BSYMCuaB.js → binary-plugins-BcvVtSvZ.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-qDlC3t7b.js → block-editor-hZg3H6K-.js} +3 -3
  15. package/dist/gateway/static/root/assets/{browser-automations-page-Du1KVE01.js → browser-automations-page-COsWjB_N.js} +2 -2
  16. package/dist/gateway/static/root/assets/browser-settings-page-D9CfpBLt.js +8 -0
  17. package/dist/gateway/static/root/assets/capabilities-settings-panel-CEOmYG_f.js +7 -0
  18. package/dist/gateway/static/root/assets/channels-settings-DS3vq4cr.js +1 -0
  19. package/dist/gateway/static/root/assets/{chat-terminal-dock-CY-I_bCe.js → chat-terminal-dock-CmV1RMyj.js} +2 -2
  20. package/dist/gateway/static/root/assets/connectors-page-C51TR-Ov.js +2 -0
  21. package/dist/gateway/static/root/assets/{cron-expression-z4WOWyBU.js → cron-expression-DsEb7fyV.js} +1 -1
  22. package/dist/gateway/static/root/assets/{date-picker-vKUcJeQZ.js → date-picker-ChR8KQ7f.js} +1 -1
  23. package/dist/gateway/static/root/assets/{dependency-picker-BpZ9A2gi.js → dependency-picker-DGz0raEu.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-ClrAMqgn.js → desktop-pet-_nHlkhRg.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-DKNKGiEG.js → desktop-pet-settings-B_tVwGUL.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-debug-page-C39hFkJm.js → extension-debug-page-DJttDDUz.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-page-DkqVsWB7.js → extension-page-vv7-Kg1n.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-settings-page-Be4lFw8f.js → extension-settings-page-BpsPHT1o.js} +1 -1
  29. package/dist/gateway/static/root/assets/gateway-settings-BrIcafAP.js +1 -0
  30. package/dist/gateway/static/root/assets/heartbeat-settings-BIqk_r9f.js +1 -0
  31. package/dist/gateway/static/root/assets/home-page-DQxTTwVp.js +1 -0
  32. package/dist/gateway/static/root/assets/index-B1zcAf8-.css +2 -0
  33. package/dist/gateway/static/root/assets/{index-BWdn9NaX.js → index-DfvY-SO6.js} +19 -19
  34. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ge76J038.js → keyboard-shortcuts-settings-CjUFDVZk.js} +1 -1
  35. package/dist/gateway/static/root/assets/local-app-workbench-page-Cl4VINRc.js +2 -0
  36. package/dist/gateway/static/root/assets/{local-apps-page-gkw7VRL4.js → local-apps-page-DNK11iaj.js} +1 -1
  37. package/dist/gateway/static/root/assets/{logs-page-HHtDMSUW.js → logs-page-Cqy0hmu5.js} +2 -2
  38. package/dist/gateway/static/root/assets/{management-settings-DOfCSojd.js → management-settings-LejmrKSf.js} +1 -1
  39. package/dist/gateway/static/root/assets/{media-plugins-D8wMcUtB.js → media-plugins-BFQxVZ03.js} +1 -1
  40. package/dist/gateway/static/root/assets/{mobile-pairing-wizard-B4Ewewwr.js → mobile-pairing-wizard-DfT_mH8L.js} +1 -1
  41. package/dist/gateway/static/root/assets/note-detail-panel-CvFzG1Bp.js +5 -0
  42. package/dist/gateway/static/root/assets/notes-page-k297u-gH.js +8 -0
  43. package/dist/gateway/static/root/assets/{page-tabs-DoxnT3X4.js → page-tabs-CMZs-2FR.js} +1 -1
  44. package/dist/gateway/static/root/assets/{preview-open-alternatives-D4oL1yua.js → preview-open-alternatives-BUprGPfS.js} +1 -1
  45. package/dist/gateway/static/root/assets/project-detail-page-CXcG3Su-.js +1 -0
  46. package/dist/gateway/static/root/assets/projects-page-BaOV7aDd.js +1 -0
  47. package/dist/gateway/static/root/assets/remote-access-hub-WY2alRLt.js +1 -0
  48. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CrOpchy5.js → runtime-tools-settings-panel-BIrnrKec.js} +2 -2
  49. package/dist/gateway/static/root/assets/{schema-form-Dk52v4cQ.js → schema-form-CjQ582_7.js} +1 -1
  50. package/dist/gateway/static/root/assets/sessions-page-CUIrWSsD.js +1 -0
  51. package/dist/gateway/static/root/assets/settings-advanced-gate-BOdZicC_.js +1 -0
  52. package/dist/gateway/static/root/assets/{settings-form-section-dvGi1APN.js → settings-form-section-d1SWWFyj.js} +1 -1
  53. package/dist/gateway/static/root/assets/{settings-page-CEYjEm2D.js → settings-page-CeSoibS9.js} +1 -1
  54. package/dist/gateway/static/root/assets/setup-status-panel-DfUt3_r7.js +1 -0
  55. package/dist/gateway/static/root/assets/{share-preview-page-DP4Qgsv6.js → share-preview-page-D7MJNTsV.js} +1 -1
  56. package/dist/gateway/static/root/assets/shares-settings-BS2kgw-8.js +1 -0
  57. package/dist/gateway/static/root/assets/{skill-reload-api-BicZK04u.js → skill-reload-api-BrEpq0C1.js} +1 -1
  58. package/dist/gateway/static/root/assets/{skills-page-Dlr1Ue1w.js → skills-page-DTFxG_j4.js} +1 -1
  59. package/dist/gateway/static/root/assets/{skills-page.utils-I1wcnceD.js → skills-page.utils-Co0GHVOk.js} +1 -1
  60. package/dist/gateway/static/root/assets/{system-settings-panel-DIaFAHT0.js → system-settings-panel-Cu9GTXm7.js} +1 -1
  61. package/dist/gateway/static/root/assets/task-detail-page-Dg3NARt6.js +1 -0
  62. package/dist/gateway/static/root/assets/{tunnel-api-DAXx1rHF.js → tunnel-api-cyxe_LpB.js} +1 -1
  63. package/dist/gateway/static/root/assets/{use-autosave-BwEFbveP.js → use-autosave-YQ_35Glb.js} +1 -1
  64. package/dist/gateway/static/root/assets/user-model-page-BZMPfbEY.js +2 -0
  65. package/dist/gateway/static/root/assets/{voice-api-key-field-C-WbC2fM.js → voice-api-key-field-1e1_bhD3.js} +1 -1
  66. package/dist/gateway/static/root/assets/{work-discovery-overlay-DiGw5KKj.js → work-discovery-overlay-Ur-4XdYe.js} +1 -1
  67. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BIU2wg99.js → workflow-run-setup-panel-Bn8Y5Xq4.js} +2 -2
  68. package/dist/gateway/static/root/assets/workflows-page-DCh0jiOu.js +6 -0
  69. package/dist/gateway/static/root/index.html +2 -2
  70. package/dist/package.js +1 -1
  71. package/dist/packages/gateway-contract/src/notifications.js +8 -1
  72. package/dist/src/agent/agent-manager.js +4 -4
  73. package/dist/src/agent/background-review/run-background-review.js +1 -1
  74. package/dist/src/agent/embedded/model-runtime.js +1 -1
  75. package/dist/src/agent/embedded/run-for-session.js +1 -1
  76. package/dist/src/agent/image/tool-model-config.js +1 -1
  77. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  78. package/dist/src/agent/service.js +2 -2
  79. package/dist/src/agent/session/session-inspector.js +1 -1
  80. package/dist/src/agent/skills/hub-lock.js +1 -1
  81. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  82. package/dist/src/ai-assist/text-assist.js +1 -1
  83. package/dist/src/auth/credentials.js +2 -2
  84. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  85. package/dist/src/auth/profiles/store.js +1 -1
  86. package/dist/src/auth/sync-provider-auth.js +2 -2
  87. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  88. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  89. package/dist/src/cli/commands/models.js +1 -1
  90. package/dist/src/config/index.js +4 -4
  91. package/dist/src/config/loader.js +2 -2
  92. package/dist/src/config/models-json.js +1 -1
  93. package/dist/src/connectors/connected-source-understanding.js +1 -4
  94. package/dist/src/extensions/lockfile.js +1 -1
  95. package/dist/src/gateway/agents-admin.js +1 -1
  96. package/dist/src/gateway/file-path-classifier.js +1 -1
  97. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  98. package/dist/src/gateway/hono/routes/models.js +1 -1
  99. package/dist/src/gateway/hono/routes/user-model.js +39 -8
  100. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  101. package/dist/src/gateway/service/config-coordinator.js +1 -1
  102. package/dist/src/gateway/service.js +4 -4
  103. package/dist/src/notifications/planner.js +35 -0
  104. package/dist/src/notifications/service.js +2 -0
  105. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  106. package/dist/src/providers/index.js +2 -2
  107. package/dist/src/providers/model-registry.js +1 -1
  108. package/dist/src/providers/register-runtime-providers.js +1 -1
  109. package/dist/src/tui/tui-startup-resources.js +1 -1
  110. package/dist/src/tui/tui.js +2 -2
  111. package/dist/src/user-model/index.js +2 -2
  112. package/dist/src/user-model/repository.d.ts +8 -0
  113. package/dist/src/user-model/repository.js +89 -1
  114. package/dist/src/work-discovery/service.js +2 -5
  115. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  116. package/package.json +4 -4
  117. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bq7GNF1L.js +0 -1
  118. package/dist/gateway/static/root/assets/automations-workspace-D4NJSE8l.js +0 -6
  119. package/dist/gateway/static/root/assets/browser-settings-page-WZ0Jt5Hp.js +0 -8
  120. package/dist/gateway/static/root/assets/capabilities-settings-panel-D1AYoRx4.js +0 -7
  121. package/dist/gateway/static/root/assets/channels-settings-CZnlYu2L.js +0 -1
  122. package/dist/gateway/static/root/assets/connectors-page-CkH3gaqs.js +0 -2
  123. package/dist/gateway/static/root/assets/gateway-settings-HIHGY-0Y.js +0 -1
  124. package/dist/gateway/static/root/assets/heartbeat-settings-DiYjWa1F.js +0 -1
  125. package/dist/gateway/static/root/assets/home-page-BLZNEVmk.js +0 -1
  126. package/dist/gateway/static/root/assets/index-50Kr6L6C.css +0 -2
  127. package/dist/gateway/static/root/assets/local-app-workbench-page-E47xrPDI.js +0 -2
  128. package/dist/gateway/static/root/assets/note-detail-panel-DPd5L2A9.js +0 -5
  129. package/dist/gateway/static/root/assets/notes-page-CE_De-iQ.js +0 -8
  130. package/dist/gateway/static/root/assets/project-detail-page-DXhBJzJy.js +0 -1
  131. package/dist/gateway/static/root/assets/projects-page-CcqhmZoX.js +0 -1
  132. package/dist/gateway/static/root/assets/remote-access-hub-ulmJT_Ac.js +0 -1
  133. package/dist/gateway/static/root/assets/sessions-page-RM0kAsNa.js +0 -1
  134. package/dist/gateway/static/root/assets/settings-advanced-gate-BfLbu67w.js +0 -1
  135. package/dist/gateway/static/root/assets/setup-status-panel-BZ4i0CYX.js +0 -1
  136. package/dist/gateway/static/root/assets/shares-settings-B5yHTrGO.js +0 -1
  137. package/dist/gateway/static/root/assets/task-detail-page-4_5g-V8B.js +0 -1
  138. package/dist/gateway/static/root/assets/user-model-page-CQnXw4ba.js +0 -2
  139. package/dist/gateway/static/root/assets/workflows-page-D3Z7JVHH.js +0 -6
@@ -1,6 +1,7 @@
1
1
  import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
2
2
  import { USER_MODEL_PRINCIPAL_ID, validateCandidate, validateScope } from "./domain.js";
3
3
  import { defaultReviewAt, requiresBoundedValidity } from "./temporal.js";
4
+ import { basename } from "node:path";
4
5
  import { randomUUID } from "node:crypto";
5
6
  //#region src/user-model/repository.ts
6
7
  function slotFromRow(row) {
@@ -219,6 +220,93 @@ function listUserAssertions(input = {}) {
219
220
  WHERE s.principal_id = ? AND a.status IN (${placeholders})
220
221
  ORDER BY a.recorded_at DESC LIMIT ?`).all(principalId, ...statuses, limit).map(assertionFromRow);
221
222
  }
223
+ function listUserAssertionSources(assertionIds) {
224
+ const uniqueIds = [...new Set(assertionIds.filter(Boolean))];
225
+ const result = /* @__PURE__ */ new Map();
226
+ if (!uniqueIds.length) return result;
227
+ const placeholders = uniqueIds.map(() => "?").join(", ");
228
+ const rows = getSqliteDatabase().prepare(`
229
+ SELECT ae.assertion_id, e.source_type, e.source_instance_id, e.source_ref, e.observed_at,
230
+ g.adapter_id AS grant_adapter_id, g.display_name AS grant_display_name,
231
+ g.category AS grant_category, w.project_id AS work_project_id, w.root_path AS work_root_path
232
+ FROM user_assertion_evidence ae
233
+ JOIN context_evidence e ON e.evidence_id = ae.evidence_id
234
+ LEFT JOIN understanding_source_grants g
235
+ ON e.source_ref LIKE ('understanding-source-grant:' || g.grant_id || ':%')
236
+ OR (e.source_type = 'connector' AND e.source_instance_id IS NOT NULL
237
+ AND json_extract(g.config_json, '$.sourceInstanceId') = e.source_instance_id)
238
+ LEFT JOIN work_discovery_runs w
239
+ ON e.source_ref LIKE ('work-discovery:' || w.id || ':%')
240
+ WHERE ae.assertion_id IN (${placeholders}) AND ae.relation = 'supports'
241
+ ORDER BY e.observed_at DESC
242
+ `).all(...uniqueIds);
243
+ const rowsByAssertion = /* @__PURE__ */ new Map();
244
+ for (const row of rows) rowsByAssertion.set(row.assertion_id, [...rowsByAssertion.get(row.assertion_id) ?? [], row]);
245
+ for (const assertionId of uniqueIds) {
246
+ const assertionRows = rowsByAssertion.get(assertionId) ?? [];
247
+ const hasSpecificUnderstandingSource = assertionRows.some((row) => row.grant_adapter_id || row.work_root_path);
248
+ const sources = /* @__PURE__ */ new Map();
249
+ for (const row of assertionRows) {
250
+ let source;
251
+ if (row.grant_adapter_id === "local-work-folders") source = {
252
+ id: `work-folder:${row.grant_display_name ?? row.grant_adapter_id}`,
253
+ kind: "work_folder",
254
+ label: row.grant_display_name ?? row.grant_adapter_id,
255
+ category: "files",
256
+ observedAt: row.observed_at
257
+ };
258
+ else if (row.grant_adapter_id?.startsWith("connector:")) source = {
259
+ id: row.grant_adapter_id,
260
+ kind: "connector",
261
+ label: row.grant_display_name ?? row.grant_adapter_id.slice(10),
262
+ ...row.grant_category ? { category: row.grant_category } : {},
263
+ observedAt: row.observed_at
264
+ };
265
+ else if (row.grant_adapter_id) source = {
266
+ id: `source:${row.grant_adapter_id}`,
267
+ kind: "local_source",
268
+ label: row.grant_display_name ?? row.grant_adapter_id,
269
+ ...row.grant_category ? { category: row.grant_category } : {},
270
+ observedAt: row.observed_at
271
+ };
272
+ else if (row.work_root_path) source = {
273
+ id: `work-folder:${row.work_project_id ?? basename(row.work_root_path)}`,
274
+ kind: "work_folder",
275
+ label: basename(row.work_root_path),
276
+ category: "files",
277
+ observedAt: row.observed_at
278
+ };
279
+ else if (row.source_type === "user") source = {
280
+ id: "user",
281
+ kind: "user",
282
+ observedAt: row.observed_at
283
+ };
284
+ else if (row.source_type === "conversation") source = {
285
+ id: "conversation",
286
+ kind: "conversation",
287
+ observedAt: row.observed_at
288
+ };
289
+ else if (row.source_type === "connector") source = {
290
+ id: `connector:${row.source_instance_id ?? row.source_ref.split(":", 1)[0]}`,
291
+ kind: "connector",
292
+ ...row.source_instance_id ? { label: row.source_instance_id } : {},
293
+ observedAt: row.observed_at
294
+ };
295
+ else {
296
+ if (hasSpecificUnderstandingSource && row.source_ref.startsWith("understanding-source:onboarding:")) continue;
297
+ source = {
298
+ id: "inference",
299
+ kind: "inference",
300
+ observedAt: row.observed_at
301
+ };
302
+ }
303
+ const existing = sources.get(source.id);
304
+ if (!existing || existing.observedAt < source.observedAt) sources.set(source.id, source);
305
+ }
306
+ result.set(assertionId, [...sources.values()]);
307
+ }
308
+ return result;
309
+ }
222
310
  function getActiveAssertionByPredicate(predicate) {
223
311
  const row = getSqliteDatabase().prepare(`SELECT a.* FROM user_assertions a
224
312
  JOIN user_assertion_slots s ON s.slot_id = a.slot_id
@@ -265,4 +353,4 @@ function setAssertionStatus(assertionId, status, input) {
265
353
  return getUserAssertion(assertionId);
266
354
  }
267
355
  //#endregion
268
- export { getActiveAssertionByPredicate, getActiveAssertionForSlot, getAssertionSlot, getUserAssertion, getUserTimezone, linkAssertionEvidence, listSlotAssertions, listUserAssertions, reconcileAssertion, setAssertionStatus };
356
+ export { getActiveAssertionByPredicate, getActiveAssertionForSlot, getAssertionSlot, getUserAssertion, getUserTimezone, linkAssertionEvidence, listSlotAssertions, listUserAssertionSources, listUserAssertions, reconcileAssertion, setAssertionStatus };
@@ -6,12 +6,12 @@ import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
6
6
  import { buildSessionKey, init_session_key } from "../routing/session-key.js";
7
7
  import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
8
8
  import { init_providers, resolveModel } from "../providers/index.js";
9
- import { isLocalModelBaseUrl } from "../providers/model-call.js";
10
9
  import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
11
10
  import "../knowledge-memory/index.js";
12
11
  import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
13
12
  import { getAssertionSlot, getUserAssertion, linkAssertionEvidence, reconcileAssertion, setAssertionStatus } from "../user-model/repository.js";
14
13
  import "../user-model/index.js";
14
+ import { isLocalModelBaseUrl } from "../providers/model-call.js";
15
15
  import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
16
16
  import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
17
17
  import { createUnderstandingSourceRun, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
@@ -1051,10 +1051,7 @@ var WorkDiscoveryService = class {
1051
1051
  persistProfileCandidates(run, result) {
1052
1052
  if (!result.profileCandidates?.length) return result;
1053
1053
  const profileCandidates = result.profileCandidates.map((candidate) => {
1054
- const assertion = persistUnderstandingCandidate(candidate, {
1055
- type: "project",
1056
- id: run.projectId
1057
- }, `work-discovery:${run.id}`);
1054
+ const assertion = persistUnderstandingCandidate(candidate, { type: "global" }, `work-discovery:${run.id}`);
1058
1055
  return {
1059
1056
  ...candidate,
1060
1057
  assertionId: assertion.id
@@ -1,7 +1,7 @@
1
1
  import { TaskRunRepository } from "../../tasks/task-run-repository.js";
2
2
  import { getDefaultAgentId, init_resolve_route } from "../../routing/resolve-route.js";
3
- import { init_providers, resolveModel } from "../../providers/index.js";
4
3
  import { extractProfileAgentId, resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
4
+ import { init_providers, resolveModel } from "../../providers/index.js";
5
5
  import { TaskRepository } from "../../tasks/task-repository.js";
6
6
  import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
7
7
  import { getProjectWorkspacePathForSession } from "../../projects/workspace.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xopcai/xopc",
3
- "version": "0.0.256",
3
+ "version": "0.0.258",
4
4
  "description": "Local-first personal AI assistant with reviewable user understanding, durable tasks, workflows, automations, and local or cloud models.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -163,10 +163,10 @@
163
163
  "vitest": "4.1.5",
164
164
  "vue": "^3.5.35",
165
165
  "@xopcai/browser-control-contract": "0.1.0",
166
- "@xopcai/endpoint-tools-protocol": "0.0.0",
167
- "@xopcai/realtime-protocol": "0.0.0",
166
+ "@xopcai/gateway-contract": "0.0.0",
168
167
  "@xopcai/realtime-client": "0.0.0",
169
- "@xopcai/gateway-contract": "0.0.0"
168
+ "@xopcai/realtime-protocol": "0.0.0",
169
+ "@xopcai/endpoint-tools-protocol": "0.0.0"
170
170
  },
171
171
  "scripts": {
172
172
  "assets:brand": "node scripts/generate-brand-assets.mjs",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./popover-select-CKBYnT3c.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./x-B_N4OPjy.js";import{n as c,s as l}from"./locale-store-DJPCr2mb.js";import{t as u}from"./cn-JdwAhgNB.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-CtTvuElV.js";import{r as p}from"./gateway-config-swr-DEKSw3d-.js";import{t as m}from"./skeleton-BwbyijEw.js";import{n as h,t as g}from"./registry-api-Dalzf2w0.js";import{Eu as _,Qt as v,Sc as y,Tl as b,Vc as x,Zr as S,Zt as C,_c as w,an as T,ic as E,nc as D,pc as ee,sc as O,tl as k,wu as A,y as te}from"./index-BWdn9NaX.js";import{n as j,r as M}from"./settings-page-layout-BRQNel6r.js";import{u as ne}from"./voice-config-api-Ds0z9O11.js";import{r as re}from"./image-generation-api-CJIPVk_d.js";var N=e(t(),1),ie=n(),P=r(),F={"xopc-cloud":`XOPC Cloud`,"xopc-local":`XOPC Local`,alibaba:`Alibaba Cloud`,edge:`Microsoft Edge`,groq:`Groq`,minimax:`MiniMax`,openai:`OpenAI`,"tts-local-cli":`Local TTS`};function I(e,t,n){let r=e?.[t]?.[n];return typeof r==`string`&&r.trim()?r.trim():void 0}function L(e){return F[e]??e}function R(e){let t=(0,ie.c)(17),{icon:n,label:r,enabled:i,details:a,zh:o}=e,s;t[0]===n?s=t[1]:(s=(0,P.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,P.jsx)(n,{className:`size-4`,"aria-hidden":!0})}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=c);let l=i?o?`已启用`:`On`:o?`已关闭`:`Off`,u;t[4]===l?u=t[5]:(u=(0,P.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-fg-muted`,children:l}),t[4]=l,t[5]=u);let d;t[6]!==c||t[7]!==u?(d=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f=i?a:o?`不处理语音`:`Voice processing is disabled`,p;t[9]===f?p=t[10]:(p=(0,P.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,P.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==s||t[15]!==m?(h=(0,P.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-panel p-4`,children:[s,m]}),t[14]=s,t[15]=m,t[16]=h):h=t[16],h}function ae(e){let t=(0,ie.c)(27),{zh:n}=e,{data:r,error:a,isLoading:o}=p(!0),s=r?.payload?.config,c,l,u;if(t[0]!==s){u=s===void 0?void 0:ne(s);let e=u?I(u.stt.providers,u.stt.provider,`model`):void 0,n=u?I(u.tts.providers,u.tts.provider,`model`):void 0,r=u?I(u.tts.providers,u.tts.provider,`voice`):void 0;c=u?[L(u.stt.provider),e].filter(Boolean).join(` · `):void 0,l=u?[L(u.tts.provider),n,r].filter(Boolean).join(` · `):void 0,t[0]=s,t[1]=c,t[2]=l,t[3]=u}else c=t[1],l=t[2],u=t[3];let d=l,h=n?`语音能力`:`Voice capabilities`,g;t[4]===h?g=t[5]:(g=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:h}),t[4]=h,t[5]=g);let v=n?`STT 和 TTS 由所有 Agent 共用,在全局语音设置中统一管理。`:`STT and TTS are shared by every agent and managed in global voice settings.`,y;t[6]===v?y=t[7]:(y=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v}),t[6]=v,t[7]=y);let b;t[8]!==g||t[9]!==y?(b=(0,P.jsxs)(`div`,{children:[g,y]}),t[8]=g,t[9]=y,t[10]=b):b=t[10];let S=n?`管理语音设置`:`Manage voice settings`,C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,P.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t[11]=C):C=t[11];let w;t[12]===S?w=t[13]:(w=(0,P.jsx)(f,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,P.jsxs)(i,{to:`/settings/capabilities/voice`,children:[S,C]})}),t[12]=S,t[13]=w);let T;t[14]!==b||t[15]!==w?(T=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b,w]}),t[14]=b,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==o||t[19]!==c||t[20]!==d||t[21]!==u||t[22]!==n?(E=o||!u?a?(0,P.jsx)(`p`,{className:`mt-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:n?`暂时无法读取语音配置。`:`Voice settings could not be loaded.`}):(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(m,{className:`h-20 rounded-xl`}),(0,P.jsx)(m,{className:`h-20 rounded-xl`})]}):(0,P.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,P.jsx)(R,{icon:x,label:n?`语音转文字(STT)`:`Speech to text (STT)`,enabled:u.stt.enabled,details:c,zh:n}),(0,P.jsx)(R,{icon:A,label:n?`文字转语音(TTS)`:`Text to speech (TTS)`,enabled:u.tts.enabled,details:d,zh:n})]}),t[17]=a,t[18]=o,t[19]=c,t[20]=d,t[21]=u,t[22]=n,t[23]=E):E=t[23];let D;return t[24]!==T||t[25]!==E?(D=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26],D}var z=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],oe=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,B={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function se(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function V(e){let t=(0,ie.c)(35),{primary:n,value:r,models:i,loading:a,error:o,zh:c,onChange:l}=e,u;if(t[0]!==i||t[1]!==n||t[2]!==r){let e;t[4]!==n||t[5]!==r?(e=e=>e.id!==n&&!r.includes(e.id),t[4]=n,t[5]=r,t[6]=e):e=t[6],u=i.filter(e),t[0]=i,t[1]=n,t[2]=r,t[3]=u}else u=t[3];let d=u,f=c?`回退顺序`:`Fallback order`,p;t[7]===f?p=t[8]:(p=(0,P.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),t[7]=f,t[8]=p);let m=c?`主模型不可用时,按从左到右的顺序尝试。`:`Tried from left to right when the primary model is unavailable.`,h;t[9]===m?h=t[10]:(h=(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]!==p||t[12]!==h?(g=(0,P.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,P.jsxs)(`div`,{children:[p,h]})}),t[11]=p,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==i||t[15]!==l||t[16]!==r||t[17]!==c?(_=r.length>0?(0,P.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r.map((e,t)=>(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-edge bg-surface-panel py-1 pl-2.5 pr-1 text-xs text-fg`,children:[(0,P.jsx)(`span`,{className:`text-fg-subtle`,children:t+1}),(0,P.jsx)(`span`,{children:i.find(t=>t.id===e)?.name??e}),(0,P.jsx)(`button`,{type:`button`,"aria-label":c?`移除 ${e}`:`Remove ${e}`,className:`rounded-full p-1 text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>l(r.filter(t=>t!==e)),children:(0,P.jsx)(s,{className:`size-3`})})]},e))}):(0,P.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:c?`未设置回退模型。`:`No fallback models configured.`}),t[14]=i,t[15]=l,t[16]=r,t[17]=c,t[18]=_):_=t[18];let v=c?`添加回退模型`:`Add fallback model`,y=c?`搜索模型或服务商`:`Search models or providers`,b=c?`没有可添加的模型`:`No models available to add`,x=c?`添加回退模型`:`Add fallback model`,C;t[19]!==l||t[20]!==r?(C=e=>{e&&l([...r,e])},t[19]=l,t[20]=r,t[21]=C):C=t[21];let w;t[22]!==d||t[23]!==o||t[24]!==a||t[25]!==b||t[26]!==x||t[27]!==C||t[28]!==v||t[29]!==y?(w=(0,P.jsx)(S,{value:``,models:d,modelsLoading:a,modelsError:o,placeholder:v,searchPlaceholder:y,noMatches:b,showProviderInTrigger:!1,contentAlign:`start`,className:`mt-3 w-full max-w-md`,ariaLabel:x,onChange:C}),t[22]=d,t[23]=o,t[24]=a,t[25]=b,t[26]=x,t[27]=C,t[28]=v,t[29]=y,t[30]=w):w=t[30];let T;return t[31]!==w||t[32]!==g||t[33]!==_?(T=(0,P.jsxs)(`div`,{children:[g,_,w]}),t[31]=w,t[32]=g,t[33]=_,t[34]=T):T=t[34],T}function ce(e){let t=(0,ie.c)(121),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let o=d(g,h,a),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[1]=s):s=t[1];let c=d(`agent-defaults-image-models`,re,s),l;t[2]===o.data?l=t[3]:(l=o.data??[],t[2]=o.data,t[3]=l);let u=l,p;t[4]===c.data?p=t[5]:(p=c.data??[],t[4]=c.data,t[5]=p);let m;t[6]===p?m=t[7]:(m=p.flatMap(H),t[6]=p,t[7]=m);let _=m,v=i?B.zh:B.en,y;t[8]!==n||t[9]!==r?(y=(e,t)=>{let i={...n.models.intents};t?i[e]=se(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[8]=n,t[9]=r,t[10]=y):y=t[10];let b=y,x=i?`默认对话模型`:`Default conversation model`,C;t[11]===x?C=t[12]:(C=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),t[11]=x,t[12]=C);let w=i?`大多数对话和没有专用路由的任务都会使用它。`:`Used for most conversations and every task without a dedicated route.`,T;t[13]===w?T=t[14]:(T=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[13]=w,t[14]=T);let E;t[15]!==T||t[16]!==C?(E=(0,P.jsxs)(`div`,{children:[C,T]}),t[15]=T,t[16]=C,t[17]=E):E=t[17];let D=i?`主模型`:`Primary model`,ee;t[18]===D?ee=t[19]:(ee=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:D}),t[18]=D,t[19]=ee);let O=i?`选择模型`:`Select a model`,k=i?`搜索模型或服务商`:`Search models or providers`,A=i?`没有匹配的模型`:`No matching models`,te=i?`默认对话模型`:`Default conversation model`,j;t[20]!==n||t[21]!==r?(j=e=>r({...n,models:{...n.models,chat:{...n.models.chat,primary:e}}}),t[20]=n,t[21]=r,t[22]=j):j=t[22];let M;t[23]!==n.models.chat.primary||t[24]!==O||t[25]!==k||t[26]!==A||t[27]!==te||t[28]!==j?(M=(0,P.jsx)(S,{value:n.models.chat.primary,placeholder:O,searchPlaceholder:k,noMatches:A,showProviderSettingsFooter:!0,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:te,onChange:j}),t[23]=n.models.chat.primary,t[24]=O,t[25]=k,t[26]=A,t[27]=te,t[28]=j,t[29]=M):M=t[29];let ne;t[30]!==ee||t[31]!==M?(ne=(0,P.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[ee,M]}),t[30]=ee,t[31]=M,t[32]=ne):ne=t[32];let N;t[33]!==n||t[34]!==r?(N=e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}}),t[33]=n,t[34]=r,t[35]=N):N=t[35];let F;t[36]!==n.models.chat.fallbacks||t[37]!==n.models.chat.primary||t[38]!==u||t[39]!==o.error||t[40]!==o.isLoading||t[41]!==N||t[42]!==i?(F=(0,P.jsx)(`div`,{className:`mt-6 border-t border-edge pt-5`,children:(0,P.jsx)(V,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:u,loading:o.isLoading,error:o.error,zh:i,onChange:N})}),t[36]=n.models.chat.fallbacks,t[37]=n.models.chat.primary,t[38]=u,t[39]=o.error,t[40]=o.isLoading,t[41]=N,t[42]=i,t[43]=F):F=t[43];let I;t[44]!==E||t[45]!==ne||t[46]!==F?(I=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[E,ne,F]}),t[44]=E,t[45]=ne,t[46]=F,t[47]=I):I=t[47];let L=i?`图片能力`:`Image capabilities`,R;t[48]===L?R=t[49]:(R=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:L}),t[48]=L,t[49]=R);let ce=i?`没有图片任务时可以保持关闭。`:`Leave these off when the agents do not work with images.`,U;t[50]===ce?U=t[51]:(U=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ce}),t[50]=ce,t[51]=U);let W=i?`图片理解模型`:`Image understanding model`,G;t[52]===W?G=t[53]:(G=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:W}),t[52]=W,t[53]=G);let K=n.models.imageUnderstanding?.primary??``,q=i?`关闭图片理解`:`Image understanding off`,J=i?`搜索视觉模型`:`Search vision models`,le=i?`没有可用的视觉模型`:`No vision models available`,ue=i?`关闭图片理解`:`Image understanding off`,de=i?`图片理解模型`:`Image understanding model`,Y;t[54]!==n||t[55]!==r?(Y=e=>{let t={...n.models};e?t.imageUnderstanding=se(t.imageUnderstanding,e):delete t.imageUnderstanding,r({...n,models:t})},t[54]=n,t[55]=r,t[56]=Y):Y=t[56];let X;t[57]!==K||t[58]!==q||t[59]!==J||t[60]!==le||t[61]!==ue||t[62]!==de||t[63]!==Y?(X=(0,P.jsx)(S,{value:K,placeholder:q,searchPlaceholder:J,noMatches:le,capabilitiesFilter:`vision`,allowEmpty:!0,emptyLabel:ue,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:de,onChange:Y}),t[57]=K,t[58]=q,t[59]=J,t[60]=le,t[61]=ue,t[62]=de,t[63]=Y,t[64]=X):X=t[64];let fe;t[65]!==G||t[66]!==X?(fe=(0,P.jsxs)(`div`,{children:[G,X]}),t[65]=G,t[66]=X,t[67]=fe):fe=t[67];let pe=i?`图片生成模型`:`Image generation model`,me;t[68]===pe?me=t[69]:(me=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:pe}),t[68]=pe,t[69]=me);let he=n.models.imageGeneration?.primary??``,ge=i?`关闭图片生成`:`Image generation off`,_e=i?`搜索图片模型或服务商`:`Search image models or providers`,ve=i?`没有可用的图片生成模型`:`No image generation models available`,ye=i?`关闭图片生成`:`Image generation off`,be=i?`图片生成模型`:`Image generation model`,Z;t[70]!==n||t[71]!==r?(Z=e=>{let t={...n.models};e?t.imageGeneration={primary:e,fallbacks:t.imageGeneration?.fallbacks??[],timeoutMs:t.imageGeneration?.timeoutMs,autoProviderFallback:t.imageGeneration?.autoProviderFallback??!0}:delete t.imageGeneration,r({...n,models:t})},t[70]=n,t[71]=r,t[72]=Z):Z=t[72];let xe;t[73]!==_||t[74]!==c.error||t[75]!==c.isLoading||t[76]!==he||t[77]!==ge||t[78]!==_e||t[79]!==ve||t[80]!==ye||t[81]!==be||t[82]!==Z?(xe=(0,P.jsx)(S,{value:he,models:_,modelsLoading:c.isLoading,modelsError:c.error,placeholder:ge,searchPlaceholder:_e,noMatches:ve,allowEmpty:!0,emptyLabel:ye,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:be,onChange:Z}),t[73]=_,t[74]=c.error,t[75]=c.isLoading,t[76]=he,t[77]=ge,t[78]=_e,t[79]=ve,t[80]=ye,t[81]=be,t[82]=Z,t[83]=xe):xe=t[83];let Q;t[84]!==me||t[85]!==xe?(Q=(0,P.jsxs)(`div`,{children:[me,xe]}),t[84]=me,t[85]=xe,t[86]=Q):Q=t[86];let $;t[87]!==fe||t[88]!==Q?($=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-2`,children:[fe,Q]}),t[87]=fe,t[88]=Q,t[89]=$):$=t[89];let Se;t[90]!==n||t[91]!==r||t[92]!==i?(Se=n.models.imageGeneration?(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 border-t border-edge pt-5 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,P.jsx)(`input`,{type:`number`,min:1,className:`${oe} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,P.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[!0,!1].map(e=>(0,P.jsx)(f,{variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]}):null,t[90]=n,t[91]=r,t[92]=i,t[93]=Se):Se=t[93];let Ce;t[94]!==R||t[95]!==U||t[96]!==$||t[97]!==Se?(Ce=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[R,U,$,Se]}),t[94]=R,t[95]=U,t[96]=$,t[97]=Se,t[98]=Ce):Ce=t[98];let we;t[99]===i?we=t[100]:(we=(0,P.jsx)(ae,{zh:i}),t[99]=i,t[100]=we);let Te=i?`按任务选择模型`:`Route by task`,Ee;t[101]===Te?Ee=t[102]:(Ee=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:Te}),t[101]=Te,t[102]=Ee);let De=i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`,Oe;t[103]===De?Oe=t[104]:(Oe=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:De}),t[103]=De,t[104]=Oe);let ke;t[105]!==v||t[106]!==n.models.intents||t[107]!==b||t[108]!==i?(ke=z.map(e=>(0,P.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v[e][0]}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v[e][1]})]}),(0,P.jsx)(S,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${v[e][0]}模型`:`${v[e][0]} model`,onChange:t=>b(e,t)})]},e)),t[105]=v,t[106]=n.models.intents,t[107]=b,t[108]=i,t[109]=ke):ke=t[109];let Ae;t[110]===ke?Ae=t[111]:(Ae=(0,P.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:ke}),t[110]=ke,t[111]=Ae);let je;t[112]!==Ee||t[113]!==Oe||t[114]!==Ae?(je=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[Ee,Oe,Ae]}),t[112]=Ee,t[113]=Oe,t[114]=Ae,t[115]=je):je=t[115];let Me;return t[116]!==I||t[117]!==Ce||t[118]!==we||t[119]!==je?(Me=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[I,Ce,we,je]}),t[116]=I,t[117]=Ce,t[118]=we,t[119]=je,t[120]=Me):Me=t[120],Me}function H(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}var U=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function W(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function G(e){let t=(0,ie.c)(151),{draft:n,setDraft:r,zh:i}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=d(`agent-defaults-workflows`,te,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l;t[3]===c?l=t[4]:(l=c.map(K),t[3]=c,t[4]=l);let p=l,m=n.workflows.allowed===void 0,h;t[5]!==n||t[6]!==r?(h=(e,t)=>{let i=n.workflows.allowed??[],a=t?[...new Set([...i,e])]:i.filter(t=>t!==e);r({...n,workflows:{...n.workflows,allowed:a}})},t[5]=n,t[6]=r,t[7]=h):h=t[7];let g=h,_=i?`执行限制`:`Execution limits`,v;t[8]===_?v=t[9]:(v=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:_}),t[8]=_,t[9]=v);let y=i?`为所有 Agent 设置安全上限;留空时使用系统默认值。`:`Set safe upper bounds for every agent. Empty fields use system defaults.`,b;t[10]===y?b=t[11]:(b=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let x=i?`每次运行最多轮数`:`Maximum turns per run`,S=n.runtime.maxTurns??``,C=i?`系统默认`:`System default`,w;t[12]!==n||t[13]!==r?(w=e=>r({...n,runtime:{...n.runtime,maxTurns:W(e.target.value)}}),t[12]=n,t[13]=r,t[14]=w):w=t[14];let T;t[15]!==S||t[16]!==C||t[17]!==w?(T=(0,P.jsx)(`input`,{type:`number`,min:1,value:S,placeholder:C,onChange:w,className:`${U} mt-2`}),t[15]=S,t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i?`单轮超时(毫秒)`:`Turn timeout (ms)`,ee=n.runtime.timeoutMs??``,O=i?`系统默认`:`System default`,k;t[22]!==n||t[23]!==r?(k=e=>r({...n,runtime:{...n.runtime,timeoutMs:W(e.target.value)}}),t[22]=n,t[23]=r,t[24]=k):k=t[24];let A;t[25]!==ee||t[26]!==O||t[27]!==k?(A=(0,P.jsx)(`input`,{type:`number`,min:1,value:ee,placeholder:O,onChange:k,className:`${U} mt-2`}),t[25]=ee,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==D||t[30]!==A?(j=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[D,A]}),t[29]=D,t[30]=A,t[31]=j):j=t[31];let M=i?`每轮最多工具失败次数`:`Maximum tool failures per turn`,ne=n.runtime.maxToolFailuresPerTurn??``,re=i?`系统默认`:`System default`,N;t[32]!==n||t[33]!==r?(N=e=>r({...n,runtime:{...n.runtime,maxToolFailuresPerTurn:W(e.target.value)}}),t[32]=n,t[33]=r,t[34]=N):N=t[34];let F;t[35]!==ne||t[36]!==re||t[37]!==N?(F=(0,P.jsx)(`input`,{type:`number`,min:1,value:ne,placeholder:re,onChange:N,className:`${U} mt-2`}),t[35]=ne,t[36]=re,t[37]=N,t[38]=F):F=t[38];let I;t[39]!==M||t[40]!==F?(I=(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[M,F]}),t[39]=M,t[40]=F,t[41]=I):I=t[41];let L;t[42]!==E||t[43]!==j||t[44]!==I?(L=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:[E,j,I]}),t[42]=E,t[43]=j,t[44]=I,t[45]=L):L=t[45];let R;t[46]!==L||t[47]!==v||t[48]!==b?(R=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[v,b,L]}),t[46]=L,t[47]=v,t[48]=b,t[49]=R):R=t[49];let ae=i?`提示词缓存`:`Prompt cache`,z;t[50]===ae?z=t[51]:(z=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ae}),t[50]=ae,t[51]=z);let oe=i?`复用稳定的上下文以降低响应延迟和模型费用。`:`Reuse stable context to reduce latency and model cost.`,B;t[52]===oe?B=t[53]:(B=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:oe}),t[52]=oe,t[53]=B);let se=i?`缓存模式`:`Cache mode`,V;t[54]===se?V=t[55]:(V=(0,P.jsx)(`span`,{children:se}),t[54]=se,t[55]=V);let ce;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ce=[`auto`,`off`],t[56]=ce):ce=t[56];let H;t[57]!==n||t[58]!==r||t[59]!==i?(H=(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:ce.map(e=>(0,P.jsx)(f,{variant:n.runtime.promptCache?.mode===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:e,lifetime:n.runtime.promptCache?.lifetime??`short`}}}),children:e===`auto`?i?`自动`:`Automatic`:i?`关闭`:`Off`},e))}),t[57]=n,t[58]=r,t[59]=i,t[60]=H):H=t[60];let G;t[61]!==V||t[62]!==H?(G=(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[V,H]}),t[61]=V,t[62]=H,t[63]=G):G=t[63];let q;t[64]!==n||t[65]!==r||t[66]!==i?(q=n.runtime.promptCache?.mode===`auto`?(0,P.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,P.jsx)(`span`,{children:i?`缓存周期`:`Cache lifetime`}),(0,P.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[`short`,`long`].map(e=>(0,P.jsx)(f,{variant:n.runtime.promptCache?.lifetime===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:`auto`,lifetime:e}}}),children:e===`short`?i?`短期`:`Short`:i?`长期`:`Long`},e))})]}):null,t[64]=n,t[65]=r,t[66]=i,t[67]=q):q=t[67];let J;t[68]!==G||t[69]!==q?(J=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[G,q]}),t[68]=G,t[69]=q,t[70]=J):J=t[70];let le;t[71]!==z||t[72]!==B||t[73]!==J?(le=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[z,B,J]}),t[71]=z,t[72]=B,t[73]=J,t[74]=le):le=t[74];let ue=i?`工作流`:`Workflows`,de;t[75]===ue?de=t[76]:(de=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ue}),t[75]=ue,t[76]=de);let Y=i?`设置默认工作流,并决定 Agent 可以调用哪些工作流。`:`Set a default workflow and control which workflows agents may invoke.`,X;t[77]===Y?X=t[78]:(X=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y}),t[77]=Y,t[78]=X);let fe=i?`默认工作流`:`Default workflow`,pe;t[79]===fe?pe=t[80]:(pe=(0,P.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:fe}),t[79]=fe,t[80]=pe);let me=n.workflows.default??``,he=s.isLoading?i?`正在加载…`:`Loading…`:i?`不设置默认工作流`:`No default workflow`,ge=i?`不设置默认工作流`:`No default workflow`,_e=i?`默认工作流`:`Default workflow`,ve;t[81]!==n||t[82]!==r?(ve=e=>r({...n,workflows:{...n.workflows,default:e||void 0}}),t[81]=n,t[82]=r,t[83]=ve):ve=t[83];let ye;t[84]!==me||t[85]!==he||t[86]!==ge||t[87]!==_e||t[88]!==ve||t[89]!==p||t[90]!==s.isLoading?(ye=(0,P.jsx)(a,{value:me,options:p,placeholder:he,emptyLabel:ge,disabled:s.isLoading,ariaLabel:_e,onChange:ve,triggerClassName:`mt-2`}),t[84]=me,t[85]=he,t[86]=ge,t[87]=_e,t[88]=ve,t[89]=p,t[90]=s.isLoading,t[91]=ye):ye=t[91];let be;t[92]!==pe||t[93]!==ye?(be=(0,P.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[pe,ye]}),t[92]=pe,t[93]=ye,t[94]=be):be=t[94];let Z;t[95]===s.error?Z=t[96]:(Z=s.error?(0,P.jsx)(`p`,{className:`mt-3 text-sm text-red-600`,children:s.error instanceof Error?s.error.message:String(s.error)}):null,t[95]=s.error,t[96]=Z);let xe=i?`允许调用的工作流`:`Allowed workflows`,Q;t[97]===xe?Q=t[98]:(Q=(0,P.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:xe}),t[97]=xe,t[98]=Q);let $;t[99]!==n||t[100]!==r?($=()=>r({...n,workflows:{...n.workflows,allowed:void 0}}),t[99]=n,t[100]=r,t[101]=$):$=t[101];let Se=m?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-panel hover:border-edge-strong`,Ce;t[102]===Se?Ce=t[103]:(Ce=u(`rounded-xl border p-4 text-left`,Se),t[102]=Se,t[103]=Ce);let we=i?`允许全部工作流`:`Allow every workflow`,Te;t[104]===we?Te=t[105]:(Te=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:we}),t[104]=we,t[105]=Te);let Ee=i?`新增工作流也会自动可用。`:`New workflows become available automatically.`,De;t[106]===Ee?De=t[107]:(De=(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Ee}),t[106]=Ee,t[107]=De);let Oe;t[108]!==$||t[109]!==Ce||t[110]!==Te||t[111]!==De?(Oe=(0,P.jsxs)(`button`,{type:`button`,onClick:$,className:Ce,children:[Te,De]}),t[108]=$,t[109]=Ce,t[110]=Te,t[111]=De,t[112]=Oe):Oe=t[112];let ke;t[113]!==n||t[114]!==r?(ke=()=>r({...n,workflows:{...n.workflows,allowed:[]}}),t[113]=n,t[114]=r,t[115]=ke):ke=t[115];let Ae=m?`border-edge bg-surface-panel hover:border-edge-strong`:`border-accent bg-accent/5 ring-1 ring-accent/20`,je;t[116]===Ae?je=t[117]:(je=u(`rounded-xl border p-4 text-left`,Ae),t[116]=Ae,t[117]=je);let Me=i?`只允许选中的工作流`:`Allow selected workflows only`,Ne;t[118]===Me?Ne=t[119]:(Ne=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Me}),t[118]=Me,t[119]=Ne);let Pe=i?`未选中的工作流不能被调用。`:`Unselected workflows cannot be invoked.`,Fe;t[120]===Pe?Fe=t[121]:(Fe=(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Pe}),t[120]=Pe,t[121]=Fe);let Ie;t[122]!==ke||t[123]!==je||t[124]!==Ne||t[125]!==Fe?(Ie=(0,P.jsxs)(`button`,{type:`button`,onClick:ke,className:je,children:[Ne,Fe]}),t[122]=ke,t[123]=je,t[124]=Ne,t[125]=Fe,t[126]=Ie):Ie=t[126];let Le;t[127]!==Oe||t[128]!==Ie?(Le=(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Oe,Ie]}),t[127]=Oe,t[128]=Ie,t[129]=Le):Le=t[129];let Re;t[130]!==m||t[131]!==n.workflows.allowed||t[132]!==g||t[133]!==s.data||t[134]!==s.isLoading||t[135]!==i?(Re=m?null:(0,P.jsxs)(`div`,{className:`mt-3 divide-y divide-edge rounded-xl border border-edge bg-surface-panel`,children:[(s.data??[]).map(e=>(0,P.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:n.workflows.allowed?.includes(e.id)??!1,onChange:t=>g(e.id,t.target.checked),className:`mt-0.5 size-4 accent-[var(--color-accent)]`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title||e.name}),e.description?(0,P.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description}):null]})]},e.id)),(s.data??[]).length===0&&!s.isLoading?(0,P.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`还没有工作流。`:`No workflows yet.`}):null]}),t[130]=m,t[131]=n.workflows.allowed,t[132]=g,t[133]=s.data,t[134]=s.isLoading,t[135]=i,t[136]=Re):Re=t[136];let ze;t[137]!==Q||t[138]!==Le||t[139]!==Re?(ze=(0,P.jsxs)(`div`,{className:`mt-6 border-t border-edge pt-5`,children:[Q,Le,Re]}),t[137]=Q,t[138]=Le,t[139]=Re,t[140]=ze):ze=t[140];let Be;t[141]!==de||t[142]!==X||t[143]!==be||t[144]!==Z||t[145]!==ze?(Be=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[de,X,be,Z,ze]}),t[141]=de,t[142]=X,t[143]=be,t[144]=Z,t[145]=ze,t[146]=Be):Be=t[146];let Ve;return t[147]!==R||t[148]!==le||t[149]!==Be?(Ve=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[R,le,Be]}),t[147]=R,t[148]=le,t[149]=Be,t[150]=Ve):Ve=t[150],Ve}function K(e){return{value:e.id,label:e.title||e.name}}function q(e){return[...new Set(e)].sort()}function J(e){let t=(0,ie.c)(99),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let{data:s,error:c,isLoading:l}=d(`agent-defaults-skills-catalog`,T,a),[f,p]=(0,N.useState)(``),m=n.skills.mode===`selected`?n.skills.include:n.skills.exclude;s?.catalog;let h;if(t[1]!==m||t[2]!==s?.catalog||t[3]!==f){let e=[...s?.catalog??[]],n=new Set(e.map(de));for(let t of m)n.has(t)||e.push({name:t,description:``,enabled:!0});let r=f.trim().toLowerCase();h=e.filter(e=>!r||`${e.name} ${e.description}`.toLowerCase().includes(r)).sort(ue),t[1]=m,t[2]=s?.catalog,t[3]=f,t[4]=h}else h=t[4];let g=h,_;t[5]!==n.skills.exclude||t[6]!==n.skills.include||t[7]!==n.skills.mode?(_=e=>n.skills.mode===`selected`?n.skills.include.includes(e):!n.skills.exclude.includes(e),t[5]=n.skills.exclude,t[6]=n.skills.include,t[7]=n.skills.mode,t[8]=_):_=t[8];let v=_,y;t[9]!==n||t[10]!==r?(y=e=>{if(n.skills.mode===`selected`){let t=n.skills.include.includes(e)?n.skills.include.filter(t=>t!==e):q([...n.skills.include,e]);r({...n,skills:{mode:`selected`,include:t}});return}let t=n.skills.exclude.includes(e)?n.skills.exclude.filter(t=>t!==e):q([...n.skills.exclude,e]);r({...n,skills:{mode:`all-enabled`,exclude:t}})},t[9]=n,t[10]=r,t[11]=y):y=t[11];let b=y,x;t[12]===s?.catalog?x=t[13]:(x=s?.catalog??[],t[12]=s?.catalog,t[13]=x);let S;if(t[14]!==v||t[15]!==x){let e;t[17]===v?e=t[18]:(e=e=>e.enabled&&v(e.name),t[17]=v,t[18]=e),S=x.filter(e),t[14]=v,t[15]=x,t[16]=S}else S=t[16];let C=S.length,w=i?`技能策略`:`Skill policy`,E;t[19]===w?E=t[20]:(E=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:w}),t[19]=w,t[20]=E);let D=i?`决定所有 Agent 默认可以发现和使用哪些技能。`:`Choose which skills every agent can discover and use by default.`,O;t[21]===D?O=t[22]:(O=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:D}),t[21]=D,t[22]=O);let A;t[23]!==n||t[24]!==r?(A=()=>r({...n,skills:{mode:`all-enabled`,exclude:[]}}),t[23]=n,t[24]=r,t[25]=A):A=t[25];let te=n.skills.mode===`all-enabled`?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-panel hover:border-edge-strong`,j;t[26]===te?j=t[27]:(j=u(`flex items-start gap-3 rounded-xl border p-4 text-left`,te),t[26]=te,t[27]=j);let M;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,P.jsx)(o,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[28]=M):M=t[28];let ne=i?`使用所有已启用技能`:`Use every enabled skill`,re;t[29]===ne?re=t[30]:(re=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:ne}),t[29]=ne,t[30]=re);let F=i?`推荐。以后启用的新技能也会自动可用,可单独排除。`:`Recommended. Newly enabled skills become available automatically; exclude exceptions below.`,I;t[31]===F?I=t[32]:(I=(0,P.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:F}),t[31]=F,t[32]=I);let L;t[33]!==re||t[34]!==I?(L=(0,P.jsxs)(`span`,{children:[re,I]}),t[33]=re,t[34]=I,t[35]=L):L=t[35];let R;t[36]!==A||t[37]!==j||t[38]!==L?(R=(0,P.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[M,L]}),t[36]=A,t[37]=j,t[38]=L,t[39]=R):R=t[39];let ae;t[40]!==n||t[41]!==r?(ae=()=>r({...n,skills:{mode:`selected`,include:[]}}),t[40]=n,t[41]=r,t[42]=ae):ae=t[42];let z=n.skills.mode===`selected`?`border-accent bg-accent/5 ring-1 ring-accent/20`:`border-edge bg-surface-panel hover:border-edge-strong`,oe;t[43]===z?oe=t[44]:(oe=u(`flex items-start gap-3 rounded-xl border p-4 text-left`,z),t[43]=z,t[44]=oe);let B;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,P.jsx)(k,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[45]=B):B=t[45];let se=i?`只使用选中的技能`:`Use selected skills only`,V;t[46]===se?V=t[47]:(V=(0,P.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:se}),t[46]=se,t[47]=V);let ce=i?`适合严格受控的环境;新增技能不会自动加入。`:`For tightly controlled environments; new skills are not added automatically.`,H;t[48]===ce?H=t[49]:(H=(0,P.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:ce}),t[48]=ce,t[49]=H);let U;t[50]!==V||t[51]!==H?(U=(0,P.jsxs)(`span`,{children:[V,H]}),t[50]=V,t[51]=H,t[52]=U):U=t[52];let W;t[53]!==ae||t[54]!==oe||t[55]!==U?(W=(0,P.jsxs)(`button`,{type:`button`,onClick:ae,className:oe,children:[B,U]}),t[53]=ae,t[54]=oe,t[55]=U,t[56]=W):W=t[56];let G;t[57]!==R||t[58]!==W?(G=(0,P.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[R,W]}),t[57]=R,t[58]=W,t[59]=G):G=t[59];let K;t[60]!==O||t[61]!==G||t[62]!==E?(K=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[E,O,G]}),t[60]=O,t[61]=G,t[62]=E,t[63]=K):K=t[63];let J=n.skills.mode===`selected`?i?`选择可用技能`:`Select available skills`:i?`管理例外`:`Manage exceptions`,Y;t[64]===J?Y=t[65]:(Y=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:J}),t[64]=J,t[65]=Y);let X=i?`当前默认可用 ${C} 个技能。`:`${C} skills are available by default.`,fe;t[66]===X?fe=t[67]:(fe=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:X}),t[66]=X,t[67]=fe);let pe;t[68]!==Y||t[69]!==fe?(pe=(0,P.jsxs)(`div`,{children:[Y,fe]}),t[68]=Y,t[69]=fe,t[70]=pe):pe=t[70];let me=i?`搜索技能`:`Search skills`,he;t[71]===me?he=t[72]:(he=(0,P.jsx)(`span`,{className:`sr-only`,children:me}),t[71]=me,t[72]=he);let ge;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,P.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[73]=ge):ge=t[73];let _e;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>p(e.target.value),t[74]=_e):_e=t[74];let ve=i?`搜索技能`:`Search skills`,ye;t[75]!==f||t[76]!==ve?(ye=(0,P.jsx)(`input`,{type:`search`,value:f,onChange:_e,placeholder:ve,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[75]=f,t[76]=ve,t[77]=ye):ye=t[77];let be;t[78]!==he||t[79]!==ye?(be=(0,P.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[he,ge,ye]}),t[78]=he,t[79]=ye,t[80]=be):be=t[80];let Z;t[81]!==pe||t[82]!==be?(Z=(0,P.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[pe,be]}),t[81]=pe,t[82]=be,t[83]=Z):Z=t[83];let xe;t[84]===c?xe=t[85]:(xe=c?(0,P.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:c instanceof Error?c.message:String(c)}):null,t[84]=c,t[85]=xe);let Q;t[86]!==v||t[87]!==l||t[88]!==g||t[89]!==b||t[90]!==i?(Q=l?(0,P.jsx)(`div`,{className:`mt-4 space-y-2`,children:[0,1,2,3].map(le)}):(0,P.jsxs)(`div`,{className:`mt-4 max-h-[32rem] divide-y divide-edge overflow-y-auto rounded-xl border border-edge bg-surface-panel`,children:[g.map(e=>{let t=v(e.name);return(0,P.jsxs)(`label`,{className:u(`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,!e.enabled&&`cursor-not-allowed opacity-55`),children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:t,disabled:!e.enabled,onChange:()=>b(e.name),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),e.enabled?null:(0,P.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] text-fg-muted`,children:i?`全局未启用`:`Disabled globally`})]}),e.description?(0,P.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]})]},e.name)}),g.length===0?(0,P.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`没有匹配的技能。`:`No matching skills.`}):null]}),t[86]=v,t[87]=l,t[88]=g,t[89]=b,t[90]=i,t[91]=Q):Q=t[91];let $;t[92]!==Z||t[93]!==xe||t[94]!==Q?($=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[Z,xe,Q]}),t[92]=Z,t[93]=xe,t[94]=Q,t[95]=$):$=t[95];let Se;return t[96]!==K||t[97]!==$?(Se=(0,P.jsxs)(`div`,{className:`space-y-5`,children:[K,$]}),t[96]=K,t[97]=$,t[98]=Se):Se=t[98],Se}function le(e){return(0,P.jsx)(m,{className:`h-14 rounded-xl`},e)}function ue(e,t){return e.name.localeCompare(t.name)}function de(e){return e.name}function Y(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function X(e){let t=(0,ie.c)(92),{draft:n,setDraft:r,builtinTools:i,zh:a}=e,[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(`all`),[d,p]=(0,N.useState)(),m;t[0]===i?m=t[1]:(m=new Map(i.map(pe)),t[0]=i,t[1]=m);let h=m,g;t[2]!==i||t[3]!==n.tools?(g=[...new Set([...i.map(fe),...Object.keys(n.tools)])].sort(),t[2]=i,t[3]=n.tools,t[4]=g):g=t[4];let _=g,v;if(t[5]!==_||t[6]!==n.tools){let e;t[8]===n.tools?e=t[9]:(e=e=>(n.tools[e]?.mode??`allow`)===`allow`,t[8]=n.tools,t[9]=e),v=_.filter(e),t[5]=_,t[6]=n.tools,t[7]=v}else v=t[7];let y=v.length,b;if(t[10]!==_||t[11]!==n.tools){let e;t[13]===n.tools?e=t[14]:(e=e=>n.tools[e]?.mode===`ask`,t[13]=n.tools,t[14]=e),b=_.filter(e),t[10]=_,t[11]=n.tools,t[12]=b}else b=t[12];let x=b.length,S;if(t[15]!==_||t[16]!==n.tools){let e;t[18]===n.tools?e=t[19]:(e=e=>n.tools[e]?.mode===`deny`,t[18]=n.tools,t[19]=e),S=_.filter(e),t[15]=_,t[16]=n.tools,t[17]=S}else S=t[17];let C;t[20]!==v.length||t[21]!==b.length||t[22]!==S.length?(C={allow:y,ask:x,deny:S.length},t[20]=v.length,t[21]=b.length,t[22]=S.length,t[23]=C):C=t[23];let w=C,T;if(t[24]!==_||t[25]!==h||t[26]!==n.tools||t[27]!==c||t[28]!==o){let e=o.trim().toLowerCase();T=_.filter(t=>{let r=n.tools[t]?.mode??`allow`,i=h.get(t),a=`${t} ${i?.en??``} ${i?.zh??``}`.toLowerCase();return(!e||a.includes(e))&&(c===`all`||r===c)}),t[24]=_,t[25]=h,t[26]=n.tools,t[27]=c,t[28]=o,t[29]=T}else T=t[29];let D=T,O;t[30]!==n||t[31]!==r?(O=(e,t)=>{let i=n.tools[e]??{mode:`allow`};r({...n,tools:{...n.tools,[e]:{...i,...t}}})},t[30]=n,t[31]=r,t[32]=O):O=t[32];let k=O,A=a?`全部 ${_.length}`:`All ${_.length}`,te;t[33]===A?te=t[34]:(te={id:`all`,label:A},t[33]=A,t[34]=te);let j=a?`允许 ${w.allow}`:`Allow ${w.allow}`,M;t[35]===j?M=t[36]:(M={id:`allow`,label:j},t[35]=j,t[36]=M);let ne=a?`询问 ${w.ask}`:`Ask ${w.ask}`,re;t[37]===ne?re=t[38]:(re={id:`ask`,label:ne},t[37]=ne,t[38]=re);let F=a?`禁用 ${w.deny}`:`Deny ${w.deny}`,I;t[39]===F?I=t[40]:(I={id:`deny`,label:F},t[39]=F,t[40]=I);let L;t[41]!==te||t[42]!==M||t[43]!==re||t[44]!==I?(L=[te,M,re,I],t[41]=te,t[42]=M,t[43]=re,t[44]=I,t[45]=L):L=t[45];let R=L,ae=a?`默认工具权限`:`Default tool permissions`,z;t[46]===ae?z=t[47]:(z=(0,P.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:ae}),t[46]=ae,t[47]=z);let oe=a?`允许:直接执行;询问:执行前确认;禁用:Agent 无法使用。`:`Allow runs directly, Ask requires confirmation, and Deny makes the tool unavailable.`,B;t[48]===oe?B=t[49]:(B=(0,P.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:oe}),t[48]=oe,t[49]=B);let se;t[50]!==z||t[51]!==B?(se=(0,P.jsxs)(`div`,{children:[z,B]}),t[50]=z,t[51]=B,t[52]=se):se=t[52];let V;t[53]!==c||t[54]!==R?(V=(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-xl bg-surface-panel p-1`,children:R.map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>l(e.id),className:u(`rounded-lg px-3 py-1.5 text-xs font-medium`,c===e.id?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`),children:e.label},e.id))}),t[53]=c,t[54]=R,t[55]=V):V=t[55];let ce=a?`搜索工具`:`Search tools`,H;t[56]===ce?H=t[57]:(H=(0,P.jsx)(`span`,{className:`sr-only`,children:ce}),t[56]=ce,t[57]=H);let U;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,P.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[58]=U):U=t[58];let W;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(W=e=>s(e.target.value),t[59]=W):W=t[59];let G=a?`搜索工具`:`Search tools`,K;t[60]!==o||t[61]!==G?(K=(0,P.jsx)(`input`,{type:`search`,value:o,onChange:W,placeholder:G,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[60]=o,t[61]=G,t[62]=K):K=t[62];let q;t[63]!==H||t[64]!==K?(q=(0,P.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[H,U,K]}),t[63]=H,t[64]=K,t[65]=q):q=t[65];let J;t[66]!==V||t[67]!==q?(J=(0,P.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center justify-between gap-3`,children:[V,q]}),t[66]=V,t[67]=q,t[68]=J):J=t[68];let le;if(t[69]!==h||t[70]!==n.tools||t[71]!==d||t[72]!==k||t[73]!==D||t[74]!==a){let e;t[76]!==h||t[77]!==n.tools||t[78]!==d||t[79]!==k||t[80]!==a?(e=e=>{let t=n.tools[e]??{mode:`allow`},r=h.get(e),i=d===e;return(0,P.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`code`,{className:`text-xs font-medium text-fg`,children:e}),r?(0,P.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:a?r.zh:r.en}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`flex rounded-lg bg-surface-base p-1`,children:[`allow`,`ask`,`deny`].map(n=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(e,{mode:n}),className:u(`rounded-md px-2.5 py-1 text-xs font-medium capitalize`,t.mode===n?`bg-accent text-white`:`text-fg-muted hover:text-fg`),children:n===`allow`?a?`允许`:`Allow`:n===`ask`?a?`询问`:`Ask`:a?`禁用`:`Deny`},n))}),(0,P.jsx)(f,{variant:`ghost`,className:`px-2 py-1`,"aria-label":a?`${e} 调用限制`:`${e} call limits`,onClick:()=>p(i?void 0:e),children:(0,P.jsx)(E,{className:`size-4`})})]})]}),i?(0,P.jsxs)(`div`,{className:`mt-3 grid gap-3 rounded-lg bg-surface-base p-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`每轮最多调用次数`:`Maximum calls per turn`,(0,P.jsx)(`input`,{type:`number`,min:1,value:t.maxCallsPerTurn??``,placeholder:a?`不限制`:`Unlimited`,onChange:t=>k(e,{maxCallsPerTurn:Y(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]}),(0,P.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`单次超时(毫秒)`:`Call timeout (ms)`,(0,P.jsx)(`input`,{type:`number`,min:1,value:t.timeoutMs??``,placeholder:a?`使用系统默认值`:`Use system default`,onChange:t=>k(e,{timeoutMs:Y(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]})]}):null]},e)},t[76]=h,t[77]=n.tools,t[78]=d,t[79]=k,t[80]=a,t[81]=e):e=t[81],le=D.map(e),t[69]=h,t[70]=n.tools,t[71]=d,t[72]=k,t[73]=D,t[74]=a,t[75]=le}else le=t[75];let ue;t[82]!==D.length||t[83]!==a?(ue=D.length===0?(0,P.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-fg-muted`,children:a?`没有匹配的工具。`:`No matching tools.`}):null,t[82]=D.length,t[83]=a,t[84]=ue):ue=t[84];let de;t[85]!==le||t[86]!==ue?(de=(0,P.jsxs)(`div`,{className:`mt-4 max-h-[38rem] divide-y divide-edge overflow-y-auto rounded-xl border border-edge bg-surface-panel`,children:[le,ue]}),t[85]=le,t[86]=ue,t[87]=de):de=t[87];let X;return t[88]!==se||t[89]!==J||t[90]!==de?(X=(0,P.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-5`,children:[se,J,de]}),t[88]=se,t[89]=J,t[90]=de,t[91]=X):X=t[91],X}function fe(e){return e.id}function pe(e){return[e.id,e.description]}function me(){let e=(0,ie.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsxs)(M,{gap:`gap-5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(m,{className:`h-7 w-56`}),(0,P.jsx)(m,{className:`h-4 w-96 max-w-full`})]}),(0,P.jsx)(m,{className:`h-9 w-28`})]}),(0,P.jsx)(m,{className:`h-20 rounded-2xl`}),(0,P.jsx)(m,{className:`h-12 rounded-xl`}),(0,P.jsx)(m,{className:`h-72 rounded-2xl`})]}),e[0]=t):t=e[0],t}function he({initial:e,builtinTools:t,zh:n}){let[r,i]=(0,N.useState)(`models`),[a,o]=(0,N.useState)(()=>structuredClone(e)),[s,c]=(0,N.useState)(()=>structuredClone(e)),[l,d]=(0,N.useState)(!1),[p,m]=(0,N.useState)(null),h=JSON.stringify(a)!==JSON.stringify(s),g=[{id:`models`,label:n?`模型路由`:`Model routing`,summary:a.models.chat.primary.split(`/`).at(-1)??a.models.chat.primary,icon:D},{id:`skills`,label:n?`技能`:`Skills`,summary:a.skills.mode===`all-enabled`?n?`所有已启用`:`All enabled`:n?`已选 ${a.skills.include.length}`:`${a.skills.include.length} selected`,icon:y},{id:`tools`,label:n?`工具权限`:`Tool access`,summary:n?`${Object.values(a.tools).filter(e=>e.mode===`deny`).length} 个禁用`:`${Object.values(a.tools).filter(e=>e.mode===`deny`).length} denied`,icon:O},{id:`runtime`,label:n?`运行设置`:`Runtime`,summary:a.runtime.maxTurns?n?`最多 ${a.runtime.maxTurns} 轮`:`${a.runtime.maxTurns} turns`:n?`系统限制`:`System limits`,icon:b}],_=async()=>{let e=structuredClone(a);d(!0),m(null);try{let t=await v(e),n=structuredClone(t.defaults);o(t=>JSON.stringify(t)===JSON.stringify(e)?n:t),c(structuredClone(n))}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,P.jsxs)(M,{gap:`gap-5`,children:[(0,P.jsx)(j,{title:n?`Agent 默认配置`:`Agent defaults`,subtitle:n?`为所有 Agent 设置统一的能力基线;单个 Agent 只需配置不同之处。`:`Set one capability baseline for every agent; individual agents only configure what differs.`,actions:(0,P.jsxs)(P.Fragment,{children:[h?(0,P.jsx)(`span`,{className:`hidden text-xs text-amber-700 sm:inline dark:text-amber-300`,children:n?`有未保存的更改`:`Unsaved changes`}):null,h?(0,P.jsxs)(f,{onClick:()=>o(structuredClone(s)),children:[(0,P.jsx)(w,{className:`size-4`}),n?`撤销`:`Reset`]}):null,(0,P.jsx)(f,{variant:`primary`,disabled:l||!h,onClick:()=>void _(),children:l?n?`保存中…`:`Saving…`:n?`保存默认配置`:`Save defaults`})]})}),p?(0,P.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:p}):null,(0,P.jsx)(`section`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-accent/20 bg-accent/5 px-4 py-3`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n?`这些设置会影响谁?`:`Who uses these settings?`}),(0,P.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:n?`新 Agent 自动使用;已有 Agent 中未单独修改的项目也会同步更新。`:`New agents use them automatically, and existing agents update every setting they have not customized.`})]})}),(0,P.jsx)(`nav`,{className:`grid grid-cols-2 gap-2 rounded-2xl border border-edge bg-surface-base p-2 lg:grid-cols-4`,"aria-label":n?`默认配置分区`:`Default configuration sections`,children:g.map(({id:e,label:t,summary:n,icon:a})=>(0,P.jsxs)(`button`,{type:`button`,"aria-pressed":r===e,onClick:()=>i(e),className:u(`flex min-w-0 items-center gap-3 rounded-xl px-3 py-2.5 text-left transition-colors`,r===e?`bg-surface-panel text-fg shadow-surface ring-1 ring-edge`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,P.jsx)(a,{className:u(`size-4 shrink-0`,r===e?`text-accent`:`text-fg-subtle`)}),(0,P.jsxs)(`span`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`block text-sm font-medium`,children:t}),(0,P.jsx)(`span`,{className:`block truncate text-[11px] text-fg-subtle`,children:n})]})]},e))}),r===`models`?(0,P.jsx)(ce,{draft:a,setDraft:o,zh:n}):null,r===`skills`?(0,P.jsx)(J,{draft:a,setDraft:o,zh:n}):null,r===`tools`?(0,P.jsx)(X,{draft:a,setDraft:o,builtinTools:t,zh:n}):null,r===`runtime`?(0,P.jsx)(G,{draft:a,setDraft:o,zh:n}):null]})}function ge(){let e=(0,ie.c)(16),t=l(ve),n=c(_e)===`zh`,{data:r,error:i,isLoading:a,mutate:o}=d(t?`settings-agent-defaults`:null,C);if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(M,{children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Gateway token required.`})}),e[0]=t):t=e[0],t}if(i&&!r){let t=String(i),r;e[1]===t?r=e[2]:(r=(0,P.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:t}),e[1]=t,e[2]=r);let a;e[3]===o?a=e[4]:(a=()=>void o(),e[3]=o,e[4]=a);let s=n?`重试`:`Retry`,c;e[5]!==a||e[6]!==s?(c=(0,P.jsx)(f,{onClick:a,children:s}),e[5]=a,e[6]=s,e[7]=c):c=e[7];let l;return e[8]!==r||e[9]!==c?(l=(0,P.jsxs)(M,{children:[r,c]}),e[8]=r,e[9]=c,e[10]=l):l=e[10],l}if(a||!r){let t;return e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(me,{}),e[11]=t):t=e[11],t}let s;return e[12]!==r.builtinTools||e[13]!==r.defaults||e[14]!==n?(s=(0,P.jsx)(he,{initial:r.defaults,builtinTools:r.builtinTools,zh:n}),e[12]=r.builtinTools,e[13]=r.defaults,e[14]=n,e[15]=s):s=e[15],s}function _e(e){return e.language}function ve(e){return e.token}export{ge as AgentDefaultsSettingsPanel};
@@ -1,6 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i,t as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as o,n as s,o as c,r as l,s as u,t as d}from"./dist-CpzYSoz7.js";import{n as f,r as p}from"./popover-select-CKBYnT3c.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./markdown-view-k_PJsY2C.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./x-B_N4OPjy.js";import{t as ee}from"./messages-BeIiRpmk.js";import{n as v}from"./locale-store-DJPCr2mb.js";import{t as y}from"./cn-JdwAhgNB.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{t as x}from"./button-CtTvuElV.js";import{t as S}from"./skeleton-BwbyijEw.js";import{$t as te,Ac as ne,As as re,Ec as ie,Gc as C,Hs as ae,Mc as oe,Mu as se,Oa as ce,Rl as w,Xc as le,ca as T,cu as E,eo as D,fu as O,gn as k,hn as A,l as j,mn as ue,nc as M,pc as de,pn as fe,sc as N,su as pe,uu as P,vc as F,vn as me,wl as I,y as L,zi as R}from"./index-BWdn9NaX.js";import{a as z,i as B,o as V,r as H}from"./cron-expression-z4WOWyBU.js";import{a as U,i as he,n as ge,r as _e,t as ve}from"./workflow-run-setup-panel-BIU2wg99.js";import{i as ye,n as be,r as xe,t as W}from"./browser-automation-inputs-rA2QROKe.js";var G=e(t(),1),K=n(),Se=z();function q(e,t,n){let r=new Date;return r.setHours(e,t,0,0),r.toLocaleTimeString(n,{hour:`numeric`,minute:`2-digit`})}function Ce(e,t){let n=e===7?0:e;return new Date(Date.UTC(2023,0,1)+n*864e5).toLocaleDateString(t,{weekday:`short`,timeZone:`UTC`})}function we(e,t){return e.length<=1?e[0]??``:t.startsWith(`zh`)?e.join(`、`):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function Te(e){return e.length===5&&e.every((e,t)=>e===t+1)}function Ee(e){if(e.length!==2)return!1;let t=[...e].toSorted((e,t)=>e-t);return t[0]===0&&t[1]===6}function De(e,t,n,r){try{let i=Se.CronExpressionParser.parse(e,{...r?.timezone?{tz:r.timezone}:{}}).fields,a=H(i.minute.values),o=H(i.hour.values),s=H(i.dayOfWeek.values),c=H(i.dayOfMonth.values);if(a.length===60&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.everyMinute;if(!i.minute.isWildcard&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&a.length>1){let e=B(a);if(e!=null&&e>0)return n.everyNMinutes.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length>1&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard){let e=B(o);if(e!=null&&e>0)return n.everyNHours.replace(`{{n}}`,String(e))}if(!i.minute.isWildcard&&a.length===1&&i.hour.isWildcard&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard&&o.length===24)return n.hourly;let l=!i.minute.isWildcard&&a.length===1&&!i.hour.isWildcard&&o.length===1?q(o[0],a[0],t):``;if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&i.dayOfWeek.isWildcard)return n.dailyAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Te(s))return n.weekdaysAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&Ee(s))return n.weekendsAt.replace(`{{time}}`,l);if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length===1){let e=Ce(s[0],t);return n.weeklyOn.replace(`{{day}}`,e).replace(`{{time}}`,l)}if(l&&i.dayOfMonth.isWildcard&&i.month.isWildcard&&!i.dayOfWeek.isWildcard&&s.length>1){let e=we(s.map(e=>Ce(e,t)),t);return n.daysAt.replace(`{{days}}`,e).replace(`{{time}}`,l)}return l&&!i.dayOfMonth.isWildcard&&c.length===1&&i.month.isWildcard&&i.dayOfWeek.isWildcard?n.monthlyAt.replace(`{{day}}`,String(c[0])).replace(`{{time}}`,l):n.customSchedule}catch{return null}}function J(e,t,n,r){let i=e.trim();return i?De(i,t,n,r)||Oe(r?.nextRun,t)||n.customSchedule:Oe(r?.nextRun,t)||`—`}function Oe(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleString(t,{weekday:`short`,hour:`numeric`,minute:`2-digit`})}var ke=1e3,Y=60*ke,X=60*Y,Ae=24*X,je=7*Ae,Me=new Intl.ListFormat(`en-US`,{type:`conjunction`}),Ne=Object.fromEntries([`second`,`minute`,`hour`,`day`,`week`].map(e=>[e,new Intl.NumberFormat(`en-US`,{style:`unit`,unit:e,unitDisplay:`long`})])),Pe={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`})},Fe={en:new Intl.DateTimeFormat(`en-US`,{hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})},Ie={minute:Y,hour:X,day:Ae,week:je};function Le(e){return e===`zh`?`zh-CN`:`en-US`}function Re(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:Ne[String(t)].format(e)}function ze(e,t){return t===`zh`?e.join(` `):Me.format(e)}function Be(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(Y,Math.round((Number.isFinite(n)&&n>0?n:1)*Ie[t]))}function Ve(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*Ie[t]/Ie[n]).toFixed(6)))}function He(e,t){let n=Math.max(ke,Math.round(e)),r=n===Ae?[{unit:`hour`,ms:X}]:n>=je&&n%je===0?[{unit:`week`,ms:je}]:n>=Ae?[{unit:`day`,ms:Ae},{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=X?[{unit:`hour`,ms:X},{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:n>=Y?[{unit:`minute`,ms:Y},{unit:`second`,ms:ke}]:[{unit:`second`,ms:ke}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(Re(r,e,t)),i%=n)}return ze(a,t)}function Ue(e,t){let n=He(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function We(e,t){return Pe[t].format(new Date(e))}function Ge(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Ke(e,t,n=Date.now()){let r=new Date(e),i=Math.round((Ge(r)-Ge(new Date(n)))/Ae),a=Fe[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}`:We(e,t)}function qe(e,t){return e.eventType===`task.attention_required.v2`&&e.payloadMatch?.reason===`blocked`?t.trigger.taskBlockedWhen: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 Je(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 qe(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Ke(Date.parse(i.at),r)):i.kind===`interval`?Ue(i.everyMs,r):J(i.expr,Le(r),n.scheduleBadge,{timezone:i.tz})}function Ye(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Ke(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 Xe(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Ke(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Ze={name:``,description:``,projectId:``,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,browserAutomationId:``,browserAutomationInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,conversationMode:`new_session`,notificationPolicy:`attention`,completionWebhookUrl:``,disableAfterFailures:`3`},Qe=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function $e(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===`taskBlocked`)o={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`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:Be(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=_e(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.actionMode===`browser_automation`?`auto_apply`:e.safetyMode,u;return u=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)}:{}}:e.actionMode===`browser_automation`?{kind:`browser_automation`,automationId:e.browserAutomationId.trim(),inputs:e.browserAutomationInputs}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:o,action:u,safety:{mode:l},conversationMode:e.conversationMode,notificationPolicy:e.notificationPolicy,...l===`auto_apply`&&e.completionWebhookUrl.trim()?{completionWebhookUrl:e.completionWebhookUrl.trim()}:{},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function et(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 tt(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 nt(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 rt(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}: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 it(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function at(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 ot(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=rt(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=et(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...tt(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:nt(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?it(r.input):{},o=e.reliability?.executionTimeoutSeconds??r.timeoutSeconds??e.reliability?.timeoutSeconds??(r.kind===`browser_automation`?600:1800);return{...Ze,...n,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:r.kind,agentId:r.kind===`browser_automation`?``:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,browserAutomationId:r.kind===`browser_automation`?r.automationId:``,browserAutomationInputs:r.kind===`browser_automation`?r.inputs??{}:{},workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?ge(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(o),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.notificationPolicy??`attention`,completionWebhookUrl:e.completionWebhookUrl??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function st(e,t,n){let r=$e(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_automation`&&r.action.kind===`browser_automation`&&(a={...e.action,...r.action}),{...r,description:t.description.trim(),projectId:t.projectId.trim(),completionWebhookUrl:t.completionWebhookUrl.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}var Z=r();function ct(e,t,n){return e?We(e,n):t.never}function lt(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.kind===`browser_automation`?`Browser automation: ${e.automationId}`:e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function ut(e){return e.safety?.mode??`auto_apply`}function dt(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`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function ft(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 pt(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function mt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ht(e,t){if((e.state.consecutiveFailures??0)>0)return!0;let n=t.reduce((t,n)=>n.automationId===e.id&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0);return n?mt(n):!1}function gt(e,t){return e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`&&e.action.goal?.trim()||lt(e.action,t)}function _t(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function vt(e){return!!_t(e)}function yt(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function bt(e){return pt(e)?0:mt(e)?1:e.status===`succeeded`?2:3}function xt(e){return[...e].sort((e,t)=>{let n=bt(e)-bt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function St(){let e=(0,K.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)(S,{className:`h-4 w-36`}),(0,Z.jsx)(S,{className:`h-3 w-56 max-w-full`})]}),(0,Z.jsx)(S,{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(Ct)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(S,{className:`h-4 w-32`}),i=(0,Z.jsx)(S,{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)(S,{className:`h-12 rounded-lg`}),(0,Z.jsx)(S,{className:`h-12 rounded-lg`}),(0,Z.jsx)(S,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ct(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)(S,{className:`size-4 rounded-full`}),(0,Z.jsx)(S,{className:`h-4 w-32`}),(0,Z.jsx)(S,{className:`h-5 w-20 rounded-full`})]}),(0,Z.jsx)(S,{className:`mt-3 h-4 w-full`}),(0,Z.jsx)(S,{className:`mt-2 h-4 w-3/5`})]}),(0,Z.jsx)(S,{className:`h-8 w-24 rounded-md`})]})},t)}function wt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=v(e=>e.language),m=ee(a),h=m.automations,S=m.cron,te=D(e=>e.setPageHeader),ne=D(e=>e.clearPageHeader),[ie,C]=i(),ae=ie.get(`run`)?.trim()??``,oe=ie.get(`automation`)?.trim()??``,se=ie.get(`draft`)?.trim()??``,le=ie.get(`action`)?.trim()??``,E=ie.get(`projectId`)?.trim()??``,O=e?.trim()||E,M=!!e?.trim(),N=ie.get(`autogenerate`)===`1`,pe=(0,G.useRef)(``),[P,F]=(0,G.useState)(`all`),[I,z]=(0,G.useState)(``),[B,V]=(0,G.useState)(!1),[H,U]=(0,G.useState)(`blank`),[ge,_e]=(0,G.useState)(null),[ve,xe]=(0,G.useState)(!1),[W,K]=(0,G.useState)(Ze),[Se,q]=(0,G.useState)(null),[Ce,we]=(0,G.useState)(null),[Te,Ee]=(0,G.useState)(!1),[De,J]=(0,G.useState)(null),[Oe,ke]=(0,G.useState)(``),[Y,X]=(0,G.useState)(null),[Ae,je]=(0,G.useState)(!1),[Me,Ne]=(0,G.useState)(!1),[Pe,Fe]=(0,G.useState)(O),[Ie,Le]=(0,G.useState)(`new_session`),[Re,ze]=(0,G.useState)(`attention`),[Be,Ve]=(0,G.useState)(null),[He,Ue]=(0,G.useState)(!1),[We,Ge]=(0,G.useState)(!1),[Ke,qe]=(0,G.useState)(!1),[Ye,Xe]=(0,G.useState)(null),Qe=b([`automations`,O],()=>j.list(O?{projectId:O}:void 0),{refreshInterval:15e3}),et=b([`automation-runs`,O],()=>j.runs(50,void 0,O?{projectId:O}:void 0),{refreshInterval:1e4}),tt=b(Ce?`automation-run-events:${Ce}`:null,()=>j.runEvents(Ce),{refreshInterval:5e3}),nt=b(`automation-workflow-definitions`,L),rt=b(`automation-browser-automations`,()=>ye.list()),it=b(`automation-chat-agents`,ce),ct=b(`automation-projects`,()=>T({sortBy:`name`,sortOrder:`asc`,limit:200})),lt=Qe.isLoading&&!Qe.data||et.isLoading&&!et.data,ut=Qe.data?.automations??[],dt=(0,G.useMemo)(()=>xt(et.data?.runs??[]),[et.data?.runs]),ft=(0,G.useMemo)(()=>ut.filter(e=>!vt(e)),[ut]),mt=(0,G.useMemo)(()=>ut.filter(vt),[ut]),ht=(0,G.useMemo)(()=>new Set(mt.map(e=>e.id)),[mt]),_t=(0,G.useMemo)(()=>dt.filter(e=>!ht.has(e.automationId)),[dt,ht]),bt=(0,G.useMemo)(()=>dt.find(e=>e.id===Ce)??null,[dt,Ce]),Ct=(0,G.useMemo)(()=>ut.find(e=>e.id===De)??null,[ut,De]),wt=(0,G.useMemo)(()=>ut.find(e=>e.id===ge)??null,[ut,ge]),Et=(0,G.useMemo)(()=>dt.filter(e=>e.automationId===De).sort((e,t)=>t.createdAtMs-e.createdAtMs),[dt,De]),Dt=tt.data?.events??[],Ot=(0,G.useMemo)(()=>_t.filter(e=>!pt(e)&&e.readAtMs==null),[_t]),At=I.trim().toLocaleLowerCase(),jt=(0,G.useMemo)(()=>(P===`system`?mt:ft).filter(e=>P===`active`&&!e.enabled||P===`paused`&&e.enabled?!1:At?[e.name,yt(e),gt(e,h),Je(e.trigger,h,S,a)].some(e=>e.toLocaleLowerCase().includes(At)):!0),[S,P,h,a,At,mt,ft,_t]),Mt=(0,G.useMemo)(()=>nt.data??[],[nt.data]),Nt=(0,G.useMemo)(()=>(rt.data?.automations??[]).filter(e=>e.enabled),[rt.data]),It=it.data?.items??[],Lt=ct.data?.items??[],Rt=(0,G.useMemo)(()=>Mt.find(e=>e.id===W.workflowId.trim())??null,[W.workflowId,Mt]),zt=(0,G.useMemo)(()=>Nt.find(e=>e.id===W.browserAutomationId.trim())??null,[Nt,W.browserAutomationId]),Bt=W.actionMode===`workflow`&&(!W.workflowId.trim()||Mt.length>0&&!Mt.some(e=>e.id===W.workflowId)),Vt=W.actionMode===`workflow`&&Rt?!he(Rt,W.workflowInput,W.workflowInputValid).valid:!1,Ht=!!W.name.trim()&&(W.triggerMode!==`once`||Number.isFinite(new Date(W.onceAt).getTime()))&&(W.triggerMode!==`event`||!!W.eventType.trim()&&at(W.eventPayloadMatch))&&(W.actionMode===`workflow`?!Bt&&!Vt:W.actionMode===`browser_automation`?zt!==null&&be(zt,W.browserAutomationInputs):!!W.instruction.trim()),Gt=(0,G.useMemo)(()=>[{name:h.templates.dailyAgent.name,description:h.templates.dailyAgent.description,form:{...Ze,name:h.templates.dailyAgent.name,instruction:h.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:h.templates.morningWorkflow.name,description:h.templates.morningWorkflow.description,form:{...Ze,name:h.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:Mt[0]?.id??``}},{name:h.templates.webhookAgent.name,description:h.templates.webhookAgent.description,form:{...Ze,name:h.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:h.templates.blockedTask.name,description:h.templates.blockedTask.description,form:{...Ze,name:h.templates.blockedTask.formName,triggerMode:`taskBlocked`,instruction:h.templates.blockedTask.instruction}},{name:h.templates.noteCreated.name,description:h.templates.noteCreated.description,form:{...Ze,name:h.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:h.templates.noteCreated.instruction}}],[h,Mt]);(0,G.useEffect)(()=>{if(jt.length===0){J(null);return}De&&jt.some(e=>e.id===De)||J(jt[0].id)},[jt,De]);let Kt=(0,G.useCallback)(async()=>{await Promise.all([Qe.mutate(),et.mutate(),tt.mutate()])},[Qe.mutate,tt.mutate,et.mutate]),qt=(0,G.useCallback)(e=>{if(M){J(null),we(null);return}C(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),J(null),we(null)},[M,C]);(0,G.useEffect)(()=>{M&&(Fe(O),K(e=>e.projectId===O?e:{...e,projectId:O}))},[O,M]);let $=(0,G.useCallback)(e=>{if(_e(null),xe(!1),U(e),V(!0),e===`blank`){K({...Ze,projectId:O});return}ke(``),X(null),Ne(!1),Fe(O),Le(`new_session`),ze(`attention`)},[O]),Jt=(0,G.useCallback)(e=>{K(ot(e,Mt)),_e(e.id),xe(!1),J(null),U(`blank`),V(!0)},[Mt]),Yt=(0,G.useCallback)(()=>{Y&&(K({...ot(Y.automation,Mt),projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),_e(null),xe(!0),U(`blank`))},[Y,Ie,Re,Pe,Mt]),Xt=(0,G.useCallback)(async()=>{qe(!0),q(null);try{await Kt()}catch(e){q(e instanceof Error?e.message:String(e))}finally{qe(!1)}},[h.feedback.actionFailed,Kt]);(0,G.useEffect)(()=>{if(!oe)return;let e=ut.find(e=>e.id===oe);e&&(F(vt(e)?`system`:`all`),J(e.id),C(e=>{let t=new URLSearchParams(e);return t.delete(`automation`),t},{replace:!0}))},[oe,ut,C]),(0,G.useEffect)(()=>{le===`create`&&($(`blank`),C(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[le,$,C]),(0,G.useEffect)(()=>{if(!se)return;let e=`${a}:${N?`auto`:`seed`}:${se}`;pe.current!==e&&(pe.current=e,ke(se),X(null),Ne(!1),Fe(O),U(`draft`),V(!0),C(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),N&&(q(null),je(!0),j.draft({prompt:se,language:a}).then(e=>{X(e.draft),Ne(!1)}).catch(e=>{q(e instanceof Error?e.message:String(e))}).finally(()=>{je(!1)})))},[N,se,a,O,C]);let Zt=(0,G.useCallback)(e=>{let t=dt.find(t=>t.id===e);if(!t||pt(t)||t.readAtMs!=null)return;let n=Date.now();et.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),j.markRunRead(e).catch(e=>{q(e instanceof Error?e.message:String(e)),et.mutate()})},[dt,et.mutate]),Qt=(0,G.useCallback)(e=>{Zt(e),we(e),Ee(!0),C(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[Zt,C]),$t=(0,G.useCallback)(e=>{J(e);let t=dt.find(t=>t.automationId===e);t&&t.readAtMs==null&&!pt(t)&&Zt(t.id)},[Zt,dt]);(0,G.useEffect)(()=>{ae&&(Zt(ae),we(ae),Ee(!0))},[Zt,ae]),(0,G.useEffect)(()=>{Ve(null),Ge(!1)},[Ce]);async function en(){if(q(null),Ht){if(ve&&Y){Xe(`draft:edit`);try{let e=$e(W,Rt),{simulation:t}=await j.simulate(e);X({...Y,automation:e,simulation:t}),Fe(W.projectId),Le(W.conversationMode),ze(W.notificationPolicy),Ne(!1),xe(!1),U(`draft`)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Xe(null)}return}if(wt){let e=wt.id;await tn(`automation:${e}:edit`,()=>j.update(e,st(wt,W,Rt)))&&(V(!1),_e(null),J(e));return}try{let e=$e(W,Rt),{automation:t}=await j.create(e);K(Ze),V(!1),F(`all`),z(``),qt(t.projectId??``),await Kt(),J(t.id)}catch(e){q(e instanceof Error?e.message:String(e))}}}async function tn(e,t){q(null),Xe(e);try{return await t(),await Kt(),!0}catch(e){return q(e instanceof Error?e.message:String(e)),!1}finally{Xe(null)}}async function nn(){await tn(`runs:read-all`,()=>j.markAllRunsRead(O||void 0))}async function rn(){let e=Oe.trim();if(e){q(null),je(!0);try{X((await j.draft({prompt:e,language:a})).draft),Ne(!1)}catch(e){q(e instanceof Error?e.message:String(e))}finally{je(!1)}}}async function an(){if(!Y)return;let e=``,t=``;await tn(`draft:publish`,async()=>{let{automation:n}=await j.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re});X(null),ke(``),Ne(!1),V(!1),F(`all`),z(``),e=n.id,t=n.projectId??``})&&e&&(qt(t),J(e))}async function on(){if(!Y)return;let e=``,t=``,n=``;await tn(`draft:test`,async()=>{let{automation:r}=await j.create({...Y.automation,...Pe?{projectId:Pe}:{projectId:void 0},conversationMode:Ie,notificationPolicy:Re,enabled:!1}),{run:i}=await j.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,X(null),ke(``),Ne(!1),V(!1),F(`all`),z(``)})&&e&&n&&(qt(t),J(e),Qt(n))}async function sn(e){q(null),Ue(!0),Ve(null),Ge(!1);try{Ve((await j.repairDraft(e.id,{language:a})).repair)}catch(e){q(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}async function cn(e){Be&&await tn(`run:${e.id}:repair`,async()=>{await j.update(e.automationId,Be.patch),Ve(null),Ge(!1)})}let ln=(0,G.useMemo)(()=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{className:`size-9 shrink-0 p-0`,loading:Ke,label:h.refresh,onClick:Xt}),(0,Z.jsxs)(x,{variant:`primary`,onClick:()=>$(`draft`),children:[(0,Z.jsx)(g,{className:`size-4`}),h.new]})]}),[h.new,h.refresh,$,Ke,Xt]);return(0,G.useLayoutEffect)(()=>{if(!t)return te({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:h.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:h.subtitle})]}),end:ln}),()=>ne()},[ne,t,ln,h.subtitle,h.title,te]),(0,Z.jsxs)(`div`,{className:y(`flex min-h-0 min-w-0 flex-1 flex-col`,t?`bg-transparent`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:y(`flex w-full flex-col gap-4`,t?`py-1`:`px-3 py-5 sm:px-5 xl:px-6`),children:[t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(re,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||h.title})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||h.subtitle})]}),ln]}):null,Se?(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:Se}):null,lt?(0,Z.jsx)(St,{}):(0,Z.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[20rem_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`aside`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle p-3`,children:[M?null:(0,Z.jsxs)(f,{"aria-label":h.filters.project,className:Q,value:O,onChange:e=>qt(e.target.value),children:[(0,Z.jsx)(p,{value:``,children:h.filters.allProjects}),Lt.map(e=>(0,Z.jsx)(p,{value:e.id,children:e.name},e.id))]}),(0,Z.jsxs)(`label`,{className:y(`flex items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted focus-within:border-accent`,!M&&`mt-2`),children:[(0,Z.jsx)(de,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:I,onChange:e=>z(e.target.value),placeholder:h.filters.search})]}),(0,Z.jsxs)(`nav`,{className:`mt-3 flex items-center gap-1`,"aria-label":h.filters.status,children:[[{id:`all`,label:h.filters.all},{id:`active`,label:h.filters.active},{id:`paused`,label:h.paused}].map(e=>(0,Z.jsx)(`button`,{type:`button`,className:y(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,P===e.id&&`bg-surface-hover text-fg`),onClick:()=>F(e.id),children:e.label},e.id)),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(me,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:y(`ml-auto rounded-md p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,P===`system`&&`bg-surface-hover text-fg`),"aria-label":h.system.title,children:(0,Z.jsx)(w,{className:`size-4`})})}),(0,Z.jsx)(A,{children:(0,Z.jsx)(fe,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,Z.jsxs)(ue,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>F(`system`),children:[h.system.title,` `,mt.length]})})})]})]}),Ot.length>0&&P!==`system`?(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 rounded-md bg-accent/8 px-2.5 py-1.5 text-xs text-accent-fg`,children:[(0,Z.jsxs)(`span`,{children:[h.filters.unread,` · `,Ot.length]}),(0,Z.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:Ye===`runs:read-all`,onClick:()=>void nn(),children:h.filters.markAllRead})]}):null]}),(0,Z.jsx)(kt,{automations:jt,runs:P===`system`?dt:_t,labels:h,cronLabels:S,language:a,selectedAutomationId:De,onOpenDetails:$t})]}),Ct?(0,Z.jsx)(Ft,{automation:Ct,runs:Et,labels:h,cronLabels:S,language:a,projects:Lt,busyAction:Ye,onEdit:Jt,onSelectRun:Qt,onAction:tn}):(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(re,{className:`size-5`}),title:h.empty.filtered})]})]}),(0,Z.jsx)(d,{open:B,onOpenChange:e=>{V(e),e||(_e(null),xe(!1))},children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(l,{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)(u,{className:`text-base font-semibold text-fg`,children:H===`draft`?h.draft.title:wt?h.editTitle:ve?h.draft.editTitle:h.createTitle}),(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(x,{variant:`ghost`,"aria-label":h.close,children:(0,Z.jsx)(_,{className:`size-4`})})})]}),H===`draft`?(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Z.jsx)(Tt,{labels:h,prompt:Oe,draft:Y,loading:Ae,approved:Me,publishBusy:Ye===`draft:publish`,testBusy:Ye===`draft:test`,templates:Gt,projects:Lt,projectId:Pe,conversationMode:Ie,notificationPolicy:Re,onPromptChange:ke,onGenerate:rn,onEdit:Yt,onPublish:an,onTest:on,onProjectChange:Fe,onConversationModeChange:Le,onNotificationPolicyChange:ze,projectLocked:M,onApprovedChange:Ne,onDiscard:()=>{X(null),Ne(!1)},onTemplateSelect:e=>{K({...e,projectId:Pe}),U(`blank`)},onOpenAdvanced:()=>{K({...Ze,projectId:Pe,conversationMode:Ie,notificationPolicy:Re}),U(`blank`)}})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wt,{form:W,labels:h,setForm:K,projects:Lt,workflowDefinitions:Mt,selectedWorkflow:Rt,workflowsLoading:nt.isLoading,browserAutomations:Nt,selectedBrowserAutomation:zt,browserAutomationsLoading:rt.isLoading,agentOptions:It,agentsLoading:it.isLoading,language:a,projectLocked:M}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[ve?(0,Z.jsx)(x,{variant:`ghost`,onClick:()=>{xe(!1),U(`draft`)},children:h.cancel}):(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(x,{variant:`ghost`,children:h.cancel})}),(0,Z.jsx)(x,{variant:`primary`,onClick:en,disabled:!Ht||Ye===`draft:edit`||!!(wt&&Ye),children:Ye===`draft:edit`||wt&&Ye===`automation:${wt.id}:edit`?h.feedback.working:wt||ve?h.save:h.create})]})]})]})]})}),(0,Z.jsx)(d,{open:Te&&!!bt,onOpenChange:e=>{Ee(e),!e&&C(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,Z.jsxs)(c,{children:[(0,Z.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Z.jsxs)(l,{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)(u,{className:`truncate text-base font-semibold text-fg`,children:bt?.automationName??h.dashboard.result}),(0,Z.jsx)(s,{asChild:!0,children:(0,Z.jsx)(x,{variant:`ghost`,"aria-label":h.close,children:(0,Z.jsx)(_,{className:`size-4`})})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Z.jsx)(Pt,{className:`rounded-none border-0`,run:bt,events:Dt,labels:h,cronLabels:S,language:a,loading:tt.isLoading,repairDraft:Be,repairLoading:He,repairApproved:We,busyAction:Ye,onRepairApprovedChange:Ge,onSuggestRepair:sn,onApplyRepair:cn})})]})]})})]})}function Tt(e){let t=(0,K.c)(108),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,testBusy:c,templates:l,projects:u,projectId:d,conversationMode:m,notificationPolicy:h,onPromptChange:g,onGenerate:_,onEdit:ee,onPublish:v,onTest:b,onProjectChange:S,onConversationModeChange:te,onNotificationPolicyChange:re,onApprovedChange:C,onDiscard:ae,onTemplateSelect:oe,onOpenAdvanced:se,projectLocked:ce}=e,w=s===void 0?!1:s,le=c===void 0?!1:c,T=ce===void 0?!1:ce,E=!!(i&&i.simulation.requiredConfirmations.length>0),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(M,{className:`size-4 text-accent`}),t[0]=D):D=t[0];let O;t[1]===n.draft.title?O=t[2]:(O=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[D,n.draft.title]}),t[1]=n.draft.title,t[2]=O);let k;t[3]===n.draft.subtitle?k=t[4]:(k=(0,Z.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=k);let A;t[5]!==O||t[6]!==k?(A=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[5]=O,t[6]=k,t[7]=A):A=t[7];let j;t[8]!==a||t[9]!==r?(j=a||!r.trim(),t[8]=a,t[9]=r,t[10]=j):j=t[10];let ue;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(M,{className:`size-4`}),t[11]=ue):ue=t[11];let de=a?n.draft.generating:n.draft.generate,fe;t[12]!==_||t[13]!==de||t[14]!==j?(fe=(0,Z.jsxs)(x,{variant:`primary`,onClick:_,disabled:j,children:[ue,de]}),t[12]=_,t[13]=de,t[14]=j,t[15]=fe):fe=t[15];let N;t[16]!==fe||t[17]!==A?(N=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[A,fe]}),t[16]=fe,t[17]=A,t[18]=N):N=t[18];let pe;t[19]===g?pe=t[20]:(pe=e=>g(e.target.value),t[19]=g,t[20]=pe);let P;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==pe?(P=(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:pe,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=pe,t[24]=P):P=t[24];let F=T?`sm:grid-cols-2`:`sm:grid-cols-3`,me;t[25]===F?me=t[26]:(me=y(`mt-3 grid gap-3`,F),t[25]=F,t[26]=me);let I;t[27]!==n.draft.noProject||t[28]!==n.draft.project||t[29]!==S||t[30]!==d||t[31]!==T||t[32]!==u?(I=T?null:(0,Z.jsx)($,{label:n.draft.project,children:(0,Z.jsxs)(f,{className:Q,value:d,onChange:e=>S(e.target.value),children:[(0,Z.jsx)(p,{value:``,children:n.draft.noProject}),u.map(Et)]})}),t[27]=n.draft.noProject,t[28]=n.draft.project,t[29]=S,t[30]=d,t[31]=T,t[32]=u,t[33]=I):I=t[33];let L;t[34]===te?L=t[35]:(L=e=>te(e.target.value),t[34]=te,t[35]=L);let R;t[36]===n.draft.newConversation?R=t[37]:(R=(0,Z.jsx)(p,{value:`new_session`,children:n.draft.newConversation}),t[36]=n.draft.newConversation,t[37]=R);let z;t[38]===n.draft.continuousConversation?z=t[39]:(z=(0,Z.jsx)(p,{value:`continuous`,children:n.draft.continuousConversation}),t[38]=n.draft.continuousConversation,t[39]=z);let B;t[40]!==m||t[41]!==L||t[42]!==R||t[43]!==z?(B=(0,Z.jsxs)(f,{className:Q,value:m,onChange:L,children:[R,z]}),t[40]=m,t[41]=L,t[42]=R,t[43]=z,t[44]=B):B=t[44];let V;t[45]!==n.draft.conversation||t[46]!==B?(V=(0,Z.jsx)($,{label:n.draft.conversation,children:B}),t[45]=n.draft.conversation,t[46]=B,t[47]=V):V=t[47];let H;t[48]===re?H=t[49]:(H=e=>re(e.target.value),t[48]=re,t[49]=H);let U;t[50]===n.draft.notifyAttention?U=t[51]:(U=(0,Z.jsx)(p,{value:`attention`,children:n.draft.notifyAttention}),t[50]=n.draft.notifyAttention,t[51]=U);let he;t[52]===n.draft.notifyAll?he=t[53]:(he=(0,Z.jsx)(p,{value:`all`,children:n.draft.notifyAll}),t[52]=n.draft.notifyAll,t[53]=he);let ge;t[54]===n.draft.notifyNone?ge=t[55]:(ge=(0,Z.jsx)(p,{value:`none`,children:n.draft.notifyNone}),t[54]=n.draft.notifyNone,t[55]=ge);let _e;t[56]!==h||t[57]!==H||t[58]!==U||t[59]!==he||t[60]!==ge?(_e=(0,Z.jsxs)(f,{className:Q,value:h,onChange:H,children:[U,he,ge]}),t[56]=h,t[57]=H,t[58]=U,t[59]=he,t[60]=ge,t[61]=_e):_e=t[61];let ve;t[62]!==n.draft.notifications||t[63]!==_e?(ve=(0,Z.jsx)($,{label:n.draft.notifications,children:_e}),t[62]=n.draft.notifications,t[63]=_e,t[64]=ve):ve=t[64];let ye;t[65]!==me||t[66]!==I||t[67]!==V||t[68]!==ve?(ye=(0,Z.jsxs)(`div`,{className:me,children:[I,V,ve]}),t[65]=me,t[66]=I,t[67]=V,t[68]=ve,t[69]=ye):ye=t[69];let be;t[70]!==i||t[71]!==n.draft.advancedCreate||t[72]!==n.draft.suggestions||t[73]!==n.draft.suggestionsDescription||t[74]!==se||t[75]!==oe||t[76]!==l?(be=i?null:(0,Z.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,Z.jsx)(x,{variant:`ghost`,onClick:se,children:n.draft.advancedCreate})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:l.slice(0,4).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>oe(e.form),children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.name))})]}),t[70]=i,t[71]=n.draft.advancedCreate,t[72]=n.draft.suggestions,t[73]=n.draft.suggestionsDescription,t[74]=se,t[75]=oe,t[76]=l,t[77]=be):be=t[77];let xe;t[78]!==o||t[79]!==i||t[80]!==n.draft.approval||t[81]!==n.draft.assumptions||t[82]!==n.draft.discard||t[83]!==n.draft.edit||t[84]!==n.draft.publish||t[85]!==n.draft.review||t[86]!==n.draft.risks||t[87]!==n.draft.safety||t[88]!==n.draft.testOnce||t[89]!==n.draft.testing||t[90]!==n.feedback||t[91]!==n.info||t[92]!==n.none||t[93]!==C||t[94]!==ae||t[95]!==ee||t[96]!==v||t[97]!==b||t[98]!==w||t[99]!==E||t[100]!==le?(xe=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)(Ht,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Z.jsx)(Ht,{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)(Dt,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Z.jsx)(Dt,{title:n.draft.risks,items:i.risks,empty:n.none}),E?(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=>C(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)(x,{variant:`ghost`,onClick:ae,children:n.draft.discard}),(0,Z.jsxs)(x,{variant:`secondary`,onClick:ee,children:[(0,Z.jsx)(ne,{className:`size-4`}),n.draft.edit]}),(0,Z.jsxs)(x,{variant:`secondary`,onClick:b,disabled:le||w||E&&!o,children:[(0,Z.jsx)(ie,{className:`size-4`}),le?n.draft.testing:n.draft.testOnce]}),(0,Z.jsx)(x,{variant:`primary`,onClick:v,disabled:w||E&&!o,children:w?n.feedback.working:n.draft.publish})]})]})]}):null,t[78]=o,t[79]=i,t[80]=n.draft.approval,t[81]=n.draft.assumptions,t[82]=n.draft.discard,t[83]=n.draft.edit,t[84]=n.draft.publish,t[85]=n.draft.review,t[86]=n.draft.risks,t[87]=n.draft.safety,t[88]=n.draft.testOnce,t[89]=n.draft.testing,t[90]=n.feedback,t[91]=n.info,t[92]=n.none,t[93]=C,t[94]=ae,t[95]=ee,t[96]=v,t[97]=b,t[98]=w,t[99]=E,t[100]=le,t[101]=xe):xe=t[101];let W;return t[102]!==N||t[103]!==P||t[104]!==ye||t[105]!==be||t[106]!==xe?(W=(0,Z.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[N,P,ye,be,xe]}),t[102]=N,t[103]=P,t[104]=ye,t[105]=be,t[106]=xe,t[107]=W):W=t[107],W}function Et(e){return(0,Z.jsx)(p,{value:e.id,children:e.name},e.id)}function Dt(e){let t=(0,K.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(Ot):(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 Ot(e){return(0,Z.jsxs)(`li`,{children:[`- `,e]},e)}function kt(e){let t=(0,K.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(re,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,Z.jsx)(Ut,{className:`rounded-none border-0 shadow-none`,icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(At),n=t.find(pt),l=t[0];return(0,Z.jsxs)(`button`,{type:`button`,className:y(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),onClick:()=>c(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:y(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:ht(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),l&&l.readAtMs==null&&!pt(l)?(0,Z.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,Z.jsx)(`div`,{className:`mt-1 truncate pl-4 text-xs text-fg-muted`,children:Je(e.trigger,i,a,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:y(`truncate`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.enabled?`${i.next}: ${ct(e.state.nextRunAtMs,i,o)}`:i.paused}),l?.status?(0,Z.jsx)(`span`,{className:y(`shrink-0 rounded-full px-1.5 py-0.5`,dt(l.status)),children:i.status[l.status]}):null]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function At(e,t){return t.createdAtMs-e.createdAtMs}function jt(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`completion_hook.started`:return n.completionHookStarted;case`completion_hook.completed`:return n.completionHookCompleted;case`completion_hook.failed`:return n.completionHookFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Mt(e){let t=(0,K.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,G.useState)(a===void 0?!1:a),c;t[0]===n?c=t[1]:(c=JSON.stringify(n,null,2),t[0]=n,t[1]=c);let l=c,u;t[2]===l?u=t[3]:(u=l.split(`
2
- `),t[2]=l,t[3]=u);let d=u.length,f=l.length>720||d>18,p;t[4]!==f||t[5]!==l?(p=f?`${l.split(`
3
- `).slice(0,10).join(`
4
- `).trimEnd()}...`:l,t[4]=f,t[5]=l,t[6]=p):p=t[6];let m=p,h;t[7]!==o||t[8]!==f||t[9]!==r||t[10]!==i?(h=f?(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:()=>s(Nt),"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)(P,{className:y(`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]=f,t[9]=r,t[10]=i,t[11]=h):h=t[11];let g=o||!f?l:m,_;t[12]===g?_=t[13]:(_=(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:g}),t[12]=g,t[13]=_);let ee;return t[14]!==h||t[15]!==_?(ee=(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[h,_]}),t[14]=h,t[15]=_,t[16]=ee):ee=t[16],ee}function Nt(e){return!e}function Pt(e){let t=(0,K.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:c,loading:l,repairDraft:u,repairLoading:d,repairApproved:f,busyAction:p,onRepairApprovedChange:g,onSuggestRepair:_,onApplyRepair:ee}=e;if(!r){let e;t[0]===n?e=t[1]:(e=y(`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)(se,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===o.selectRun?i=t[4]:(i=(0,Z.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.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 v=r.error||r.summary,b=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,te=r.sessionKey?o.runDetail.openConversation:o.runDetail.openWorkflow,ne=r.sessionKey?C:I,re=pt(r)?se:mt(r)?pe:m,ie;t[8]===n?ie=t[9]:(ie=y(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=ie);let ae;t[10]===r.automationName?ae=t[11]:(ae=(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=ae);let oe;t[12]===r.id?oe=t[13]:(oe=r.id.slice(0,8),t[12]=r.id,t[13]=oe);let ce;t[14]===oe?ce=t[15]:(ce=(0,Z.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:oe}),t[14]=oe,t[15]=ce);let w;t[16]!==ae||t[17]!==ce?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[ae,ce]}),t[16]=ae,t[17]=ce,t[18]=w):w=t[18];let T;t[19]===r.status?T=t[20]:(T=y(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(r.status)),t[19]=r.status,t[20]=T);let D=o.status[r.status],O;t[21]!==T||t[22]!==D?(O=(0,Z.jsx)(`span`,{className:T,children:D}),t[21]=T,t[22]=D,t[23]=O):O=t[23];let k;t[24]!==w||t[25]!==O?(k=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[w,O]}),t[24]=w,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==o||t[28]!==c||t[29]!==r.createdAtMs?(A=ct(r.createdAtMs,o,c),t[27]=o,t[28]=c,t[29]=r.createdAtMs,t[30]=A):A=t[30];let j;t[31]===A?j=t[32]:(j=(0,Z.jsx)(`span`,{children:A}),t[31]=A,t[32]=j);let ue;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=ue):ue=t[33];let de=o.details.duration,fe;t[34]!==o||t[35]!==r.durationMs?(fe=ft(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=fe):fe=t[36];let N;t[37]!==o.details.duration||t[38]!==fe?(N=(0,Z.jsxs)(`span`,{children:[de,` `,fe]}),t[37]=o.details.duration,t[38]=fe,t[39]=N):N=t[39];let F;t[40]!==j||t[41]!==N?(F=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[j,ue,N]}),t[40]=j,t[41]=N,t[42]=F):F=t[42];let me;t[43]!==o.repair||t[44]!==_||t[45]!==d||t[46]!==r?(me=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(x,{variant:`secondary`,onClick:()=>_(r),disabled:d,children:[(0,Z.jsx)(M,{className:`size-4`}),d?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=_,t[45]=d,t[46]=r,t[47]=me):me=t[47];let L;t[48]!==F||t[49]!==me||t[50]!==k?(L=(0,Z.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[k,F,me]}),t[48]=F,t[49]=me,t[50]=k,t[51]=L):L=t[51];let R;t[52]===r?R=t[53]:(R=pt(r)?`text-blue-500`:mt(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=R);let z;t[54]===R?z=t[55]:(z=y(`size-4`,R),t[54]=R,t[55]=z);let B;t[56]!==re||t[57]!==z?(B=(0,Z.jsx)(re,{className:z}),t[56]=re,t[57]=z,t[58]=B):B=t[58];let V;t[59]!==o.runDetail.resultTitle||t[60]!==B?(V=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[B,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=B,t[61]=V):V=t[61];let H;t[62]!==ne||t[63]!==te||t[64]!==b?(H=b?(0,Z.jsx)(x,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Z.jsxs)(a,{to:b,children:[(0,Z.jsx)(ne,{className:`size-3.5`}),te,(0,Z.jsx)(E,{className:`size-3.5`})]})}):null,t[62]=ne,t[63]=te,t[64]=b,t[65]=H):H=t[65];let U;t[66]!==V||t[67]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[V,H]}),t[66]=V,t[67]=H,t[68]=U):U=t[68];let he=r.error&&`border-red-500/25 bg-red-500/5`,ge;t[69]===he?ge=t[70]:(ge=y(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,he),t[69]=he,t[70]=ge);let _e;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==v||t[74]!==r?(_e=v?r.error?(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:v}):(0,Z.jsx)(h,{content:v,compact:!0,className:`text-sm`}):(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:pt(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=v,t[74]=r,t[75]=_e):_e=t[75];let ve;t[76]!==ge||t[77]!==_e?(ve=(0,Z.jsx)(`div`,{className:ge,children:_e}),t[76]=ge,t[77]=_e,t[78]=ve):ve=t[78];let ye;t[79]!==U||t[80]!==ve?(ye=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[U,ve]}),t[79]=U,t[80]=ve,t[81]=ye):ye=t[81];let be;t[82]===o.runDetail.runInfo?be=t[83]:(be=(0,Z.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=be);let xe;t[84]!==s||t[85]!==o||t[86]!==c||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(xe=r.manual?o.trigger.manual:Je(r.triggerSnapshot,o,s,c),t[84]=s,t[85]=o,t[86]=c,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=xe):xe=t[89];let W;t[90]!==o.explain.whyRan||t[91]!==xe?(W=(0,Z.jsx)(Bt,{label:o.explain.whyRan,value:xe}),t[90]=o.explain.whyRan,t[91]=xe,t[92]=W):W=t[92];let G=o.details.started,Se;t[93]!==o||t[94]!==c||t[95]!==r.startedAtMs?(Se=ct(r.startedAtMs,o,c),t[93]=o,t[94]=c,t[95]=r.startedAtMs,t[96]=Se):Se=t[96];let q;t[97]!==o.details.started||t[98]!==Se?(q=(0,Z.jsx)(Bt,{label:G,value:Se}),t[97]=o.details.started,t[98]=Se,t[99]=q):q=t[99];let Ce;t[100]!==o.details.model||t[101]!==r.model?(Ce=r.model?(0,Z.jsx)(Bt,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=Ce):Ce=t[102];let we;t[103]!==W||t[104]!==q||t[105]!==Ce?(we=(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[W,q,Ce]}),t[103]=W,t[104]=q,t[105]=Ce,t[106]=we):we=t[106];let Te;t[107]!==be||t[108]!==we?(Te=(0,Z.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[be,we]}),t[107]=be,t[108]=we,t[109]=Te):Te=t[109];let Ee;t[110]!==p||t[111]!==o||t[112]!==ee||t[113]!==g||t[114]!==f||t[115]!==u||t[116]!==r?(Ee=u?(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:o.repair.title}),(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:u.explanation}),u.expectedEffect?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:u.expectedEffect}):null,(0,Z.jsx)(Dt,{title:o.repair.risks,items:u.risks,empty:o.none}),(0,Z.jsx)(Mt,{value:u.patch,labels:o,title:o.details.repairPatch}),u.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:f,onChange:e=>g(e.target.checked)}),(0,Z.jsx)(`span`,{children:o.repair.approval})]}):null,(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsx)(x,{variant:`primary`,onClick:()=>ee(r),disabled:p===`run:${r.id}:repair`||u.requiresApproval&&!f,children:p===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=p,t[111]=o,t[112]=ee,t[113]=g,t[114]=f,t[115]=u,t[116]=r,t[117]=Ee):Ee=t[117];let De;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Z.jsx)(le,{className:`size-4 shrink-0`}),t[118]=De):De=t[118];let J;t[119]===o.runDetail.technicalEvents?J=t[120]:(J=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[De,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=J);let Oe;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(Oe=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=Oe):Oe=t[123];let ke;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Z.jsx)(P,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=ke):ke=t[124];let Y;t[125]===Oe?Y=t[126]:(Y=(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]=Y);let X;t[127]!==J||t[128]!==Y?(X=(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:[J,Y]}),t[127]=J,t[128]=Y,t[129]=X):X=t[129];let Ae;t[130]===o.runDetail.technicalEventsDescription?Ae=t[131]:(Ae=(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:o.runDetail.technicalEventsDescription}),t[130]=o.runDetail.technicalEventsDescription,t[131]=Ae);let je;t[132]!==i||t[133]!==o||t[134]!==c||t[135]!==l?(je=(0,Z.jsx)(`div`,{className:`mt-4`,children:l?(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-label":o.loading,children:[(0,Z.jsx)(S,{className:`h-10 w-full`}),(0,Z.jsx)(S,{className:`h-10 w-4/5`}),(0,Z.jsx)(S,{className:`h-10 w-11/12`})]}):i.length===0?(0,Z.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.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:y(`mt-1 size-2 rounded-full`,Vt(e.type))}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm text-fg`,children:jt(e,o)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[ct(e.createdAtMs,o,c),` · `,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:[o.details.eventData,(0,Z.jsx)(P,{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]=o,t[134]=c,t[135]=l,t[136]=je):je=t[136];let Me;t[137]!==X||t[138]!==Ae||t[139]!==je?(Me=(0,Z.jsxs)(`details`,{className:`group px-4 py-3`,children:[X,Ae,je]}),t[137]=X,t[138]=Ae,t[139]=je,t[140]=Me):Me=t[140];let Ne;return t[141]!==ie||t[142]!==L||t[143]!==ye||t[144]!==Te||t[145]!==Ee||t[146]!==Me?(Ne=(0,Z.jsxs)(`aside`,{className:ie,children:[L,ye,Te,Ee,Me]}),t[141]=ie,t[142]=L,t[143]=ye,t[144]=Te,t[145]=Ee,t[146]=Me,t[147]=Ne):Ne=t[147],Ne}function Ft(e){let t=(0,K.c)(83),{automation:n,runs:r,labels:i,cronLabels:a,language:o,projects:s,busyAction:c,onEdit:l,onSelectRun:u,onAction:d}=e,f=c===`automation:${n.id}:run`,p=c===`automation:${n.id}:toggle`,g=c===`automation:${n.id}:delete`,_;t[0]===n?_=t[1]:(_=vt(n),t[0]=n,t[1]=_);let ee=_,v;t[2]===n.name?v=t[3]:(v=(0,Z.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[2]=n.name,t[3]=v);let b=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,S;t[4]===b?S=t[5]:(S=y(`shrink-0 rounded-full px-2 py-0.5 text-xs`,b),t[4]=b,t[5]=S);let te=n.enabled?i.enabled:i.paused,re;t[6]!==S||t[7]!==te?(re=(0,Z.jsx)(`span`,{className:S,children:te}),t[6]=S,t[7]=te,t[8]=re):re=t[8];let C;t[9]!==v||t[10]!==re?(C=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[v,re]}),t[9]=v,t[10]=re,t[11]=C):C=t[11];let ce;t[12]===n?ce=t[13]:(ce=yt(n)?(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:yt(n)}):null,t[12]=n,t[13]=ce);let le;t[14]!==C||t[15]!==ce?(le=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[C,ce]}),t[14]=C,t[15]=ce,t[16]=le):le=t[16];let T;t[17]!==n||t[18]!==c||t[19]!==g||t[20]!==i.dashboard.delete||t[21]!==i.dashboard.deleted||t[22]!==i.dashboard.pause||t[23]!==i.dashboard.resume||t[24]!==i.dashboard.resumed||t[25]!==i.dashboard.runNow||t[26]!==i.details||t[27]!==i.edit||t[28]!==i.feedback||t[29]!==d||t[30]!==l||t[31]!==ee||t[32]!==f||t[33]!==p?(T=ee?null:(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(x,{variant:`secondary`,disabled:c!==null,onClick:()=>void d(`automation:${n.id}:toggle`,()=>n.enabled?j.pause(n.id):j.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[p?(0,Z.jsx)(F,{className:`size-4 animate-spin`}):n.enabled?(0,Z.jsx)(oe,{className:`size-4`}):(0,Z.jsx)(ie,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Z.jsxs)(x,{variant:`primary`,disabled:c!==null,onClick:()=>void d(`automation:${n.id}:run`,()=>j.runNow(n.id),i.feedback.rerunQueued),children:[f?(0,Z.jsx)(F,{className:`size-4 animate-spin`}):(0,Z.jsx)(ie,{className:`size-4`}),i.dashboard.runNow]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(me,{asChild:!0,children:(0,Z.jsx)(x,{variant:`ghost`,className:`size-9 p-0`,"aria-label":i.details.moreActions,children:(0,Z.jsx)(w,{className:`size-4`})})}),(0,Z.jsx)(A,{children:(0,Z.jsxs)(fe,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Z.jsxs)(ue,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>l(n),children:[(0,Z.jsx)(ne,{className:`size-4`}),i.edit]}),(0,Z.jsxs)(ue,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-red-700 outline-none hover:bg-red-500/10 dark:text-red-300`,disabled:c!==null,onSelect:()=>void d(`automation:${n.id}:delete`,()=>j.remove(n.id),i.dashboard.deleted),children:[g?(0,Z.jsx)(F,{className:`size-4 animate-spin`}):(0,Z.jsx)(ae,{className:`size-4`}),i.dashboard.delete]})]})})]})]}),t[17]=n,t[18]=c,t[19]=g,t[20]=i.dashboard.delete,t[21]=i.dashboard.deleted,t[22]=i.dashboard.pause,t[23]=i.dashboard.resume,t[24]=i.dashboard.resumed,t[25]=i.dashboard.runNow,t[26]=i.details,t[27]=i.edit,t[28]=i.feedback,t[29]=d,t[30]=l,t[31]=ee,t[32]=f,t[33]=p,t[34]=T):T=t[34];let E;t[35]!==T||t[36]!==le?(E=(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[le,T]}),t[35]=T,t[36]=le,t[37]=E):E=t[37];let D;t[38]===i.info.task?D=t[39]:(D=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.info.task}),t[38]=i.info.task,t[39]=D);let O;t[40]!==n||t[41]!==i?(O=gt(n,i),t[40]=n,t[41]=i,t[42]=O):O=t[42];let M;t[43]===O?M=t[44]:(M=(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base p-4`,children:(0,Z.jsx)(h,{content:O,compact:!0})}),t[43]=O,t[44]=M);let de;t[45]!==D||t[46]!==M?(de=(0,Z.jsxs)(`section`,{children:[D,M]}),t[45]=D,t[46]=M,t[47]=de):de=t[47];let N;t[48]!==n||t[49]!==a||t[50]!==i||t[51]!==o||t[52]!==s?(N=(0,Z.jsx)(Lt,{automation:n,labels:i,cronLabels:a,language:o,projects:s}),t[48]=n,t[49]=a,t[50]=i,t[51]=o,t[52]=s,t[53]=N):N=t[53];let pe;t[54]===i.dashboard.runHistory?pe=t[55]:(pe=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),t[54]=i.dashboard.runHistory,t[55]=pe);let P;t[56]===i.dashboard.runHistoryDescription?P=t[57]:(P=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription}),t[56]=i.dashboard.runHistoryDescription,t[57]=P);let I;t[58]!==pe||t[59]!==P?(I=(0,Z.jsxs)(`div`,{children:[pe,P]}),t[58]=pe,t[59]=P,t[60]=I):I=t[60];let L;t[61]===r.length?L=t[62]:(L=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[61]=r.length,t[62]=L);let R;t[63]!==I||t[64]!==L?(R=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[I,L]}),t[63]=I,t[64]=L,t[65]=R):R=t[65];let z;t[66]!==i||t[67]!==o||t[68]!==u||t[69]!==r?(z=r.length===0?(0,Z.jsx)(Ut,{icon:(0,Z.jsx)(se,{className:`size-5`}),title:i.empty.runs}):(0,Z.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>u(e.id),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Z.jsx)(m,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Z.jsx)(se,{className:`size-4 shrink-0 text-fg-muted`}),(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:ct(e.createdAtMs,i,o)})]}),(0,Z.jsx)(`span`,{className:y(`shrink-0 rounded-full px-2 py-0.5 text-xs`,dt(e.status)),children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:y(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||lt(e.actionSnapshot,i)})]},e.id))}),t[66]=i,t[67]=o,t[68]=u,t[69]=r,t[70]=z):z=t[70];let B;t[71]!==R||t[72]!==z?(B=(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[R,z]}),t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==N||t[75]!==B?(V=(0,Z.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[20rem_minmax(0,1fr)]`,children:[N,B]}),t[74]=N,t[75]=B,t[76]=V):V=t[76];let H;t[77]!==de||t[78]!==V?(H=(0,Z.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[de,V]}),t[77]=de,t[78]=V,t[79]=H):H=t[79];let U;return t[80]!==E||t[81]!==H?(U=(0,Z.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[E,H]}),t[80]=E,t[81]=H,t[82]=U):U=t[82],U}function It(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function Lt(e){let t=(0,K.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,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=ut(n),o;t[15]!==n||t[16]!==r||t[17]!==a?(o=Ye(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=o):o=t[18];let ee=o,v;t[19]!==n.state.nextRunAtMs||t[20]!==a?(v=n.state.nextRunAtMs?We(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=v):v=t[21];let y=v;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(_=[],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],_.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],_.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=We(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],_.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],_.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],_.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],_.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],_.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],_.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],_.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]=_}else _=t[39];h=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?g=t[71]:(g=(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]=g),f=`grid gap-4 p-4`;let b;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Z.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[72]=b):b=t[72];let x=r.info.schedule,S;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(S=Je(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=S):S=t[77];let te=n.enabled?`${r.info.nextRun}:${ee}`:ee;t[78]!==r.info.schedule||t[79]!==y||t[80]!==S||t[81]!==te?(p=(0,Z.jsx)(zt,{icon:b,label:x,value:S,description:te,descriptionTitle:y}),t[78]=r.info.schedule,t[79]=y,t[80]=S,t[81]=te,t[82]=p):p=t[82];let ne;t[83]===n.action.kind?ne=t[84]:(ne=n.action.kind===`workflow`?(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`browser_automation`?(0,Z.jsx)(le,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=ne);let ie=r.info.action,C;t[85]!==n.action||t[86]!==r?(C=lt(n.action,r),t[85]=n.action,t[86]=r,t[87]=C):C=t[87],t[88]!==r.info.action||t[89]!==ne||t[90]!==C?(m=(0,Z.jsx)(zt,{icon:ne,label:ie,value:C}),t[88]=r.info.action,t[89]=ne,t[90]=C,t[91]=m):m=t[91],s=zt,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[92]=c):c=t[92],l=r.info.permission,u=r.safety[e],d=It(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,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]=_}else s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14];let ee;t[93]!==s||t[94]!==c||t[95]!==l||t[96]!==u||t[97]!==d?(ee=(0,Z.jsx)(s,{icon:c,label:l,value:u,description:d}),t[93]=s,t[94]=c,t[95]=l,t[96]=u,t[97]=d,t[98]=ee):ee=t[98];let v;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t[99]=v):v=t[99];let y;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(y=o.find(e=>e.id===n.projectId)?.name??r.info.noProject,t[100]=n.projectId,t[101]=r.info.noProject,t[102]=o,t[103]=y):y=t[103];let b;t[104]!==r.info.project||t[105]!==y?(b=(0,Z.jsx)(zt,{icon:v,label:r.info.project,value:y}),t[104]=r.info.project,t[105]=y,t[106]=b):b=t[106];let x;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[107]=x):x=t[107];let S=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,te;t[108]!==r.info.conversation||t[109]!==S?(te=(0,Z.jsx)(zt,{icon:x,label:r.info.conversation,value:S}),t[108]=r.info.conversation,t[109]=S,t[110]=te):te=t[110];let ne;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Z.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),t[111]=ne):ne=t[111];let ie=n.notificationPolicy===`all`?r.info.notifyAll:n.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,ae;t[112]!==r.info.notifications||t[113]!==ie?(ae=(0,Z.jsx)(zt,{icon:ne,label:r.info.notifications,value:ie}),t[112]=r.info.notifications,t[113]=ie,t[114]=ae):ae=t[114];let oe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[115]=oe):oe=t[115];let ce=r.info.lastRun,w;t[116]!==n||t[117]!==r||t[118]!==a?(w=Xe(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=w):w=t[119];let T=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,E;t[120]!==r.info.lastRun||t[121]!==w||t[122]!==T?(E=(0,Z.jsx)(zt,{icon:oe,label:ce,value:w,valueTone:T}),t[120]=r.info.lastRun,t[121]=w,t[122]=T,t[123]=E):E=t[123];let D;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(D=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[124]=n.state.consecutiveFailures,t[125]=n.state.lastError,t[126]=r.dashboard,t[127]=D):D=t[127];let k;t[128]!==r.info.technicalDetails||t[129]!==_?(k=_.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)(P,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:_.map(Rt)})]}):null,t[128]=r.info.technicalDetails,t[129]=_,t[130]=k):k=t[130];let A;t[131]!==ee||t[132]!==b||t[133]!==te||t[134]!==ae||t[135]!==E||t[136]!==D||t[137]!==k||t[138]!==f||t[139]!==p||t[140]!==m?(A=(0,Z.jsxs)(`div`,{className:f,children:[p,m,ee,b,te,ae,E,D,k]}),t[131]=ee,t[132]=b,t[133]=te,t[134]=ae,t[135]=E,t[136]=D,t[137]=k,t[138]=f,t[139]=p,t[140]=m,t[141]=A):A=t[141];let j;return t[142]!==A||t[143]!==h||t[144]!==g?(j=(0,Z.jsxs)(`aside`,{className:h,children:[g,A]}),t[142]=A,t[143]=h,t[144]=g,t[145]=j):j=t[145],j}function Rt(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 zt(e){let t=(0,K.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,c=s===void 0?`default`:s,l;t[0]===n?l=t[1]:(l=(0,Z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=u);let d=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,f;t[4]===d?f=t[5]:(f=y(`mt-1 text-sm font-medium leading-5`,d),t[4]=d,t[5]=f);let p;t[6]!==f||t[7]!==i?(p=(0,Z.jsx)(`div`,{className:f,children:i}),t[6]=f,t[7]=i,t[8]=p):p=t[8];let m;t[9]!==a||t[10]!==o?(m=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]=m):m=t[11];let h;t[12]!==u||t[13]!==p||t[14]!==m?(h=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[u,p,m]}),t[12]=u,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==l||t[17]!==h?(g=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[l,h]}),t[16]=l,t[17]=h,t[18]=g):g=t[18],g}function Bt(e){let t=(0,K.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 Vt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ht(e){let t=(0,K.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 Ut(e){let t=(0,K.c)(8),{className:n,icon:r,title:i}=e,a;t[0]===n?a=t[1]:(a=y(`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=(0,Z.jsx)(`div`,{className:`mt-2 text-sm`,children:i}),t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:a,children:[r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Wt(e){let t=(0,K.c)(274),{form:n,labels:r,setForm:i,projects:a,workflowDefinitions:o,selectedWorkflow:s,workflowsLoading:c,browserAutomations:l,selectedBrowserAutomation:u,browserAutomationsLoading:d,agentOptions:m,agentsLoading:h,language:g,projectLocked:_}=e,v=_===void 0?!1:_,b=ee(g).agentsSettings,x;t[0]===i?x=t[1]:(x=e=>i(t=>({...t,...e})),t[0]=i,t[1]=x);let S=x,ne=Be(n.intervalValue,n.intervalUnit),re=Date.now(),ie;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(ie=[1,2,3],t[2]=ie):ie=t[2];let C;t[3]!==ne||t[4]!==re||t[5]!==g?(C=ie.map(e=>Ke(re+ne*e,g,re)),t[3]=ne,t[4]=re,t[5]=g,t[6]=C):C=t[6];let ae=C,oe,se;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==o?(oe=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=o[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},se=[n.actionMode,n.workflowId,i,o],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=o,t[11]=oe,t[12]=se):(oe=t[11],se=t[12]),(0,G.useEffect)(oe,se);let ce,w;t[13]!==l||t[14]!==n.actionMode||t[15]!==n.browserAutomationId||t[16]!==i?(ce=()=>{if(n.actionMode!==`browser_automation`||n.browserAutomationId.trim())return;let e=l[0];e&&i(t=>({...t,browserAutomationId:e.id,browserAutomationInputs:xe(e)}))},w=[l,n.actionMode,n.browserAutomationId,i],t[13]=l,t[14]=n.actionMode,t[15]=n.browserAutomationId,t[16]=i,t[17]=ce,t[18]=w):(ce=t[17],w=t[18]),(0,G.useEffect)(ce,w);let le;t[19]===S?le=t[20]:(le=e=>S({name:e.target.value}),t[19]=S,t[20]=le);let T;t[21]!==n.name||t[22]!==le?(T=(0,Z.jsx)(`input`,{className:Q,value:n.name,onChange:le}),t[21]=n.name,t[22]=le,t[23]=T):T=t[23];let E;t[24]!==r.form.name||t[25]!==T?(E=(0,Z.jsx)($,{label:r.form.name,children:T}),t[24]=r.form.name,t[25]=T,t[26]=E):E=t[26];let D;t[27]===S?D=t[28]:(D=e=>S({description:e.target.value}),t[27]=S,t[28]=D);let O;t[29]!==n.description||t[30]!==D?(O=(0,Z.jsx)(`input`,{className:Q,value:n.description,onChange:D}),t[29]=n.description,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==r.form.description||t[33]!==O?(k=(0,Z.jsx)($,{label:r.form.description,children:O}),t[32]=r.form.description,t[33]=O,t[34]=k):k=t[34];let A;t[35]!==n.projectId||t[36]!==r.form.noProject||t[37]!==r.form.project||t[38]!==v||t[39]!==a||t[40]!==S?(A=v?null:(0,Z.jsx)($,{label:r.form.project,children:(0,Z.jsxs)(f,{className:Q,value:n.projectId,onChange:e=>S({projectId:e.target.value}),children:[(0,Z.jsx)(p,{value:``,children:r.form.noProject}),a.map(qt)]})}),t[35]=n.projectId,t[36]=r.form.noProject,t[37]=r.form.project,t[38]=v,t[39]=a,t[40]=S,t[41]=A):A=t[41];let j;t[42]===r.form.trigger?j=t[43]:(j=(0,Z.jsx)(Jt,{title:r.form.trigger}),t[42]=r.form.trigger,t[43]=j);let ue;t[44]===S?ue=t[45]:(ue=e=>S({triggerMode:e.target.value}),t[44]=S,t[45]=ue);let M;t[46]===r.trigger.manual?M=t[47]:(M=(0,Z.jsx)(p,{value:`manual`,children:r.trigger.manual}),t[46]=r.trigger.manual,t[47]=M);let de;t[48]===r.trigger.once?de=t[49]:(de=(0,Z.jsx)(p,{value:`once`,children:r.trigger.once}),t[48]=r.trigger.once,t[49]=de);let fe;t[50]===r.trigger.daily?fe=t[51]:(fe=(0,Z.jsx)(p,{value:`daily`,children:r.trigger.daily}),t[50]=r.trigger.daily,t[51]=fe);let N;t[52]===r.trigger.weekly?N=t[53]:(N=(0,Z.jsx)(p,{value:`weekly`,children:r.trigger.weekly}),t[52]=r.trigger.weekly,t[53]=N);let pe;t[54]===r.trigger.interval?pe=t[55]:(pe=(0,Z.jsx)(p,{value:`interval`,children:r.trigger.interval}),t[54]=r.trigger.interval,t[55]=pe);let F;t[56]===r.trigger.customCron?F=t[57]:(F=(0,Z.jsx)(p,{value:`cron`,children:r.trigger.customCron}),t[56]=r.trigger.customCron,t[57]=F);let me;t[58]===r.trigger.webhook?me=t[59]:(me=(0,Z.jsx)(p,{value:`webhook`,children:r.trigger.webhook}),t[58]=r.trigger.webhook,t[59]=me);let I;t[60]===r.trigger.taskBlocked?I=t[61]:(I=(0,Z.jsx)(p,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[60]=r.trigger.taskBlocked,t[61]=I);let L;t[62]===r.trigger.noteCreated?L=t[63]:(L=(0,Z.jsx)(p,{value:`noteCreated`,children:r.trigger.noteCreated}),t[62]=r.trigger.noteCreated,t[63]=L);let R;t[64]===r.trigger.workflowFailed?R=t[65]:(R=(0,Z.jsx)(p,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[64]=r.trigger.workflowFailed,t[65]=R);let z;t[66]===r.trigger.sessionUpdated?z=t[67]:(z=(0,Z.jsx)(p,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[66]=r.trigger.sessionUpdated,t[67]=z);let B;t[68]===r.trigger.customEvent?B=t[69]:(B=(0,Z.jsx)(p,{value:`event`,children:r.trigger.customEvent}),t[68]=r.trigger.customEvent,t[69]=B);let H;t[70]!==n.triggerMode||t[71]!==ue||t[72]!==M||t[73]!==de||t[74]!==fe||t[75]!==N||t[76]!==pe||t[77]!==F||t[78]!==me||t[79]!==I||t[80]!==L||t[81]!==R||t[82]!==z||t[83]!==B?(H=(0,Z.jsxs)(f,{className:Q,value:n.triggerMode,onChange:ue,children:[M,de,fe,N,pe,F,me,I,L,R,z,B]}),t[70]=n.triggerMode,t[71]=ue,t[72]=M,t[73]=de,t[74]=fe,t[75]=N,t[76]=pe,t[77]=F,t[78]=me,t[79]=I,t[80]=L,t[81]=R,t[82]=z,t[83]=B,t[84]=H):H=t[84];let he;t[85]!==n.onceAt||t[86]!==n.triggerMode||t[87]!==r.form.onceAt||t[88]!==S?(he=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=>S({onceAt:e.target.value})})}):null,t[85]=n.onceAt,t[86]=n.triggerMode,t[87]=r.form.onceAt,t[88]=S,t[89]=he):he=t[89];let ge;t[90]!==n.time||t[91]!==n.triggerMode||t[92]!==n.weekday||t[93]!==r.form.day||t[94]!==r.form.time||t[95]!==r.weekdays||t[96]!==S?(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)(V,{value:n.time,onChange:e=>S({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=>S({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[90]=n.time,t[91]=n.triggerMode,t[92]=n.weekday,t[93]=r.form.day,t[94]=r.form.time,t[95]=r.weekdays,t[96]=S,t[97]=ge):ge=t[97];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/Be(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>S({intervalValue:e.target.value})}),(0,Z.jsxs)(f,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;S({intervalValue:Ve(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:Qe.map(e=>{let t=Be(e.value,e.unit),n=t===ne;return(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":n,className:y(`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:()=>S({intervalValue:e.value,intervalUnit:e.unit}),children:He(t,g)},`${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:Ue(ne,g)}),(0,Z.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,ae.join(g===`zh`?`、`:`, `)]}),(0,Z.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,ye;t[98]!==n.cronExpr||t[99]!==n.triggerMode||t[100]!==r.form.expression||t[101]!==S?(ye=n.triggerMode===`cron`?(0,Z.jsx)($,{label:r.form.expression,children:(0,Z.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>S({cronExpr:e.target.value})})}):null,t[98]=n.cronExpr,t[99]=n.triggerMode,t[100]=r.form.expression,t[101]=S,t[102]=ye):ye=t[102];let be;t[103]!==n.triggerMode||t[104]!==n.webhookSecretId||t[105]!==r.form.secretId||t[106]!==S?(be=n.triggerMode===`webhook`?(0,Z.jsx)($,{label:r.form.secretId,children:(0,Z.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>S({webhookSecretId:e.target.value})})}):null,t[103]=n.triggerMode,t[104]=n.webhookSecretId,t[105]=r.form.secretId,t[106]=S,t[107]=be):be=t[107];let Se;t[108]!==n.eventPayloadMatch||t[109]!==n.eventSource||t[110]!==n.eventType||t[111]!==n.triggerMode||t[112]!==r.form.eventPayloadMatch||t[113]!==r.form.eventSource||t[114]!==r.form.eventType||t[115]!==r.form.invalidJsonObject||t[116]!==S?(Se=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=>S({eventType:e.target.value})})}),(0,Z.jsx)($,{label:r.form.eventSource,children:(0,Z.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>S({eventSource:e.target.value})})})]}),(0,Z.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Z.jsx)(`textarea`,{className:y(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>S({eventPayloadMatch:e.target.value}),placeholder:`{
5
- "status": "blocked"
6
- }`}),at(n.eventPayloadMatch)?null:(0,Z.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[108]=n.eventPayloadMatch,t[109]=n.eventSource,t[110]=n.eventType,t[111]=n.triggerMode,t[112]=r.form.eventPayloadMatch,t[113]=r.form.eventSource,t[114]=r.form.eventType,t[115]=r.form.invalidJsonObject,t[116]=S,t[117]=Se):Se=t[117];let q;t[118]===r.form.action?q=t[119]:(q=(0,Z.jsx)(Jt,{title:r.form.action}),t[118]=r.form.action,t[119]=q);let Ce;t[120]!==n.timeoutSeconds||t[121]!==n.workflowId||t[122]!==S||t[123]!==o?(Ce=e=>{let t=e.target.value,r=Number.parseInt(n.timeoutSeconds,10);S({actionMode:t,...r===600||r===1800?{timeoutSeconds:t===`browser_automation`?`600`:`1800`}:{},...t===`browser_automation`?{safetyMode:`auto_apply`}:{},...t===`workflow`&&!n.workflowId.trim()&&o[0]?{workflowId:o[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[120]=n.timeoutSeconds,t[121]=n.workflowId,t[122]=S,t[123]=o,t[124]=Ce):Ce=t[124];let we;t[125]===r.action.runAgent?we=t[126]:(we=(0,Z.jsx)(p,{value:`agent`,children:r.action.runAgent}),t[125]=r.action.runAgent,t[126]=we);let Te;t[127]===r.action.runWorkflow?Te=t[128]:(Te=(0,Z.jsx)(p,{value:`workflow`,children:r.action.runWorkflow}),t[127]=r.action.runWorkflow,t[128]=Te);let Ee=g===`zh`?`浏览器自动化`:`Browser automation`,De;t[129]===Ee?De=t[130]:(De=(0,Z.jsx)(p,{value:`browser_automation`,children:Ee}),t[129]=Ee,t[130]=De);let J;t[131]!==n.actionMode||t[132]!==Ce||t[133]!==we||t[134]!==Te||t[135]!==De?(J=(0,Z.jsxs)(f,{className:Q,value:n.actionMode,onChange:Ce,children:[we,Te,De]}),t[131]=n.actionMode,t[132]=Ce,t[133]=we,t[134]=Te,t[135]=De,t[136]=J):J=t[136];let Oe=n.actionMode===`browser_automation`?null:(0,Z.jsx)($,{label:r.form.agent,children:(0,Z.jsxs)(f,{className:Q,value:n.agentId,onChange:e=>S({agentId:e.target.value}),children:[(0,Z.jsx)(p,{value:``,children:h?r.form.loadingAgents:r.form.defaultAgent}),m.map(e=>(0,Z.jsx)(p,{value:e.id,children:te(e,b)},e.id))]})}),ke;t[137]!==l||t[138]!==d||t[139]!==n.actionMode||t[140]!==n.agentId||t[141]!==n.browserAutomationId||t[142]!==n.browserAutomationInputs||t[143]!==n.description||t[144]!==n.instruction||t[145]!==n.name||t[146]!==n.triggerMode||t[147]!==n.workflowId||t[148]!==n.workflowInput||t[149]!==r.form.instruction||t[150]!==r.form.loadingWorkflows||t[151]!==r.form.noWorkflows||t[152]!==r.form.triggeredRun||t[153]!==r.form.workflow||t[154]!==g||t[155]!==u||t[156]!==s||t[157]!==S||t[158]!==o||t[159]!==c?(ke=n.actionMode===`agent`?(0,Z.jsxs)($,{label:r.form.instruction,children:[(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsx)(U,{value:n.instruction,onApply:e=>S({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:g,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,Z.jsx)(`textarea`,{className:y(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>S({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=>S({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:c||o.length===0,children:[c?(0,Z.jsx)(p,{value:``,children:r.form.loadingWorkflows}):null,!c&&o.length===0?(0,Z.jsx)(p,{value:``,children:r.form.noWorkflows}):null,o.map(Kt)]})}),s?(0,Z.jsx)(ve,{definition:s,language:g,value:n.workflowInput,onChange:e=>S({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>S({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:s.id,workflowTitle:s.title,workflowDescription:s.description}},inputClassName:`rounded-lg`}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:g===`zh`?`浏览器自动化`:`Browser automation`,children:(0,Z.jsxs)(f,{className:Q,value:n.browserAutomationId,onChange:e=>{let t=l.find(t=>t.id===e.target.value);S({browserAutomationId:e.target.value,browserAutomationInputs:t?xe(t):{}})},disabled:d||l.length===0,children:[l.length===0?(0,Z.jsx)(p,{value:``,children:g===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,l.map(Gt)]})}),u&&Object.keys(u.inputs).length>0?(0,Z.jsx)($,{label:g===`zh`?`运行时填写`:`Run inputs`,children:(0,Z.jsx)(W,{automation:u,values:n.browserAutomationInputs,language:g,onChange:e=>S({browserAutomationInputs:e})})}):null]}),t[137]=l,t[138]=d,t[139]=n.actionMode,t[140]=n.agentId,t[141]=n.browserAutomationId,t[142]=n.browserAutomationInputs,t[143]=n.description,t[144]=n.instruction,t[145]=n.name,t[146]=n.triggerMode,t[147]=n.workflowId,t[148]=n.workflowInput,t[149]=r.form.instruction,t[150]=r.form.loadingWorkflows,t[151]=r.form.noWorkflows,t[152]=r.form.triggeredRun,t[153]=r.form.workflow,t[154]=g,t[155]=u,t[156]=s,t[157]=S,t[158]=o,t[159]=c,t[160]=ke):ke=t[160];let Y;t[161]===r.form.advancedDescription?Y=t[162]:(Y=(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[161]=r.form.advancedDescription,t[162]=Y);let X;t[163]!==r.form.advanced||t[164]!==Y?(X=(0,Z.jsxs)(`span`,{children:[r.form.advanced,Y]}),t[163]=r.form.advanced,t[164]=Y,t[165]=X):X=t[165];let Ae;t[166]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Z.jsx)(P,{className:`size-4 transition-transform group-open:rotate-180`}),t[166]=Ae):Ae=t[166];let je;t[167]===X?je=t[168]:(je=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[X,Ae]}),t[167]=X,t[168]=je);let Me;t[169]!==n.actionMode||t[170]!==n.safetyMode||t[171]!==r.form.safety||t[172]!==r.safety||t[173]!==S?(Me=n.actionMode===`browser_automation`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Jt,{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;S({safetyMode:t})},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[169]=n.actionMode,t[170]=n.safetyMode,t[171]=r.form.safety,t[172]=r.safety,t[173]=S,t[174]=Me):Me=t[174];let Ne;t[175]===r.form.results?Ne=t[176]:(Ne=(0,Z.jsx)(Jt,{title:r.form.results}),t[175]=r.form.results,t[176]=Ne);let Pe;t[177]===S?Pe=t[178]:(Pe=e=>S({conversationMode:e.target.value}),t[177]=S,t[178]=Pe);let Fe;t[179]===r.form.newConversation?Fe=t[180]:(Fe=(0,Z.jsx)(p,{value:`new_session`,children:r.form.newConversation}),t[179]=r.form.newConversation,t[180]=Fe);let Ie;t[181]===r.form.continuousConversation?Ie=t[182]:(Ie=(0,Z.jsx)(p,{value:`continuous`,children:r.form.continuousConversation}),t[181]=r.form.continuousConversation,t[182]=Ie);let Le;t[183]!==n.conversationMode||t[184]!==Pe||t[185]!==Fe||t[186]!==Ie?(Le=(0,Z.jsxs)(f,{className:Q,value:n.conversationMode,onChange:Pe,children:[Fe,Ie]}),t[183]=n.conversationMode,t[184]=Pe,t[185]=Fe,t[186]=Ie,t[187]=Le):Le=t[187];let Re;t[188]!==r.form.conversation||t[189]!==Le?(Re=(0,Z.jsx)($,{label:r.form.conversation,children:Le}),t[188]=r.form.conversation,t[189]=Le,t[190]=Re):Re=t[190];let ze;t[191]===S?ze=t[192]:(ze=e=>S({notificationPolicy:e.target.value}),t[191]=S,t[192]=ze);let We;t[193]===r.form.notifyAttention?We=t[194]:(We=(0,Z.jsx)(p,{value:`attention`,children:r.form.notifyAttention}),t[193]=r.form.notifyAttention,t[194]=We);let Ge;t[195]===r.form.notifyAll?Ge=t[196]:(Ge=(0,Z.jsx)(p,{value:`all`,children:r.form.notifyAll}),t[195]=r.form.notifyAll,t[196]=Ge);let qe;t[197]===r.form.notifyNone?qe=t[198]:(qe=(0,Z.jsx)(p,{value:`none`,children:r.form.notifyNone}),t[197]=r.form.notifyNone,t[198]=qe);let Je;t[199]!==n.notificationPolicy||t[200]!==ze||t[201]!==We||t[202]!==Ge||t[203]!==qe?(Je=(0,Z.jsxs)(f,{className:Q,value:n.notificationPolicy,onChange:ze,children:[We,Ge,qe]}),t[199]=n.notificationPolicy,t[200]=ze,t[201]=We,t[202]=Ge,t[203]=qe,t[204]=Je):Je=t[204];let Ye;t[205]!==r.form.notifications||t[206]!==Je?(Ye=(0,Z.jsx)($,{label:r.form.notifications,children:Je}),t[205]=r.form.notifications,t[206]=Je,t[207]=Ye):Ye=t[207];let Xe;t[208]!==n.completionWebhookUrl||t[209]!==n.safetyMode||t[210]!==r.form.completionWebhook||t[211]!==S?(Xe=n.safetyMode===`auto_apply`?(0,Z.jsx)($,{label:r.form.completionWebhook,children:(0,Z.jsx)(`input`,{className:Q,value:n.completionWebhookUrl,onChange:e=>S({completionWebhookUrl:e.target.value})})}):null,t[208]=n.completionWebhookUrl,t[209]=n.safetyMode,t[210]=r.form.completionWebhook,t[211]=S,t[212]=Xe):Xe=t[212];let Ze;t[213]===r.form.reliability?Ze=t[214]:(Ze=(0,Z.jsx)(Jt,{title:r.form.reliability}),t[213]=r.form.reliability,t[214]=Ze);let $e;t[215]===S?$e=t[216]:($e=e=>S({timeoutSeconds:e.target.value}),t[215]=S,t[216]=$e);let et;t[217]!==n.timeoutSeconds||t[218]!==$e?(et=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:$e}),t[217]=n.timeoutSeconds,t[218]=$e,t[219]=et):et=t[219];let tt;t[220]!==r.form.timeoutSeconds||t[221]!==et?(tt=(0,Z.jsx)($,{label:r.form.timeoutSeconds,children:et}),t[220]=r.form.timeoutSeconds,t[221]=et,t[222]=tt):tt=t[222];let nt;t[223]===S?nt=t[224]:(nt=e=>S({disableAfterFailures:e.target.value}),t[223]=S,t[224]=nt);let rt;t[225]!==n.disableAfterFailures||t[226]!==nt?(rt=(0,Z.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:nt}),t[225]=n.disableAfterFailures,t[226]=nt,t[227]=rt):rt=t[227];let it;t[228]!==r.form.disableAfterFailures||t[229]!==rt?(it=(0,Z.jsx)($,{label:r.form.disableAfterFailures,children:rt}),t[228]=r.form.disableAfterFailures,t[229]=rt,t[230]=it):it=t[230];let ot;t[231]!==tt||t[232]!==it?(ot=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[tt,it]}),t[231]=tt,t[232]=it,t[233]=ot):ot=t[233];let st;t[234]===r.form.effectivePolicy?st=t[235]:(st=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[234]=r.form.effectivePolicy,t[235]=st);let ct=n.timeoutSeconds||`—`,lt;t[236]!==r.form.executionDeadline||t[237]!==ct?(lt=(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,ct,`s`]}),t[236]=r.form.executionDeadline,t[237]=ct,t[238]=lt):lt=t[238];let ut;t[239]===r.form.downstreamTimeoutHint?ut=t[240]:(ut=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[239]=r.form.downstreamTimeoutHint,t[240]=ut);let dt;t[241]!==st||t[242]!==lt||t[243]!==ut?(dt=(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-muted/40 px-3 py-2.5`,children:[st,lt,ut]}),t[241]=st,t[242]=lt,t[243]=ut,t[244]=dt):dt=t[244];let ft;t[245]!==Me||t[246]!==Ne||t[247]!==Re||t[248]!==Ye||t[249]!==Xe||t[250]!==Ze||t[251]!==ot||t[252]!==dt?(ft=(0,Z.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[Me,Ne,Re,Ye,Xe,Ze,ot,dt]}),t[245]=Me,t[246]=Ne,t[247]=Re,t[248]=Ye,t[249]=Xe,t[250]=Ze,t[251]=ot,t[252]=dt,t[253]=ft):ft=t[253];let pt;t[254]!==je||t[255]!==ft?(pt=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[je,ft]}),t[254]=je,t[255]=ft,t[256]=pt):pt=t[256];let mt;return t[257]!==E||t[258]!==k||t[259]!==A||t[260]!==j||t[261]!==H||t[262]!==he||t[263]!==ge||t[264]!==_e||t[265]!==ye||t[266]!==be||t[267]!==Se||t[268]!==q||t[269]!==J||t[270]!==Oe||t[271]!==ke||t[272]!==pt?(mt=(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:[E,k,A,j,H,he,ge,_e,ye,be,Se,q,J,Oe,ke,pt]})}),t[257]=E,t[258]=k,t[259]=A,t[260]=j,t[261]=H,t[262]=he,t[263]=ge,t[264]=_e,t[265]=ye,t[266]=be,t[267]=Se,t[268]=q,t[269]=J,t[270]=Oe,t[271]=ke,t[272]=pt,t[273]=mt):mt=t[273],mt}function Gt(e){return(0,Z.jsx)(p,{value:e.id,children:e.name},e.id)}function Kt(e){return(0,Z.jsx)(p,{value:e.id,children:e.title||e.name},e.id)}function qt(e){return(0,Z.jsx)(p,{value:e.id,children: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,K.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 Jt(e){let t=(0,K.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(I,{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{wt as t};