@xopcai/xopc 0.0.201 → 0.0.203

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 (164) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DOhnAQOQ.js → activity-store-SZAay-ze.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D8Cw0Mve.js → agent-avatar-dicebear-DPLJtxoS.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-DyjRuuRa.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-E9Bk-Idp.js → api-C1cSt2ru.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-BubrReXg.js → app-management-settings-panel-B3PCMqor.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BY5Az2p4.js → appearance-settings-txSx3REK.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-BEhBaooZ.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BY8843mB.js → archive-plugin-B2VVc17j.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-DG45KScf.js → attachment-load-Crk7x8qR.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BUC6FL6O.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-DGIF2ZAv.js → binary-plugins-CLlJsq5D.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-C1Qktr1g.js → block-editor-cJ5lVNAG.js} +46 -46
  15. package/dist/gateway/static/root/assets/browser-settings-page-Bq2m4VpX.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-D_jnndyz.js → browser-workflow-inputs-WRiFG88u.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-DyIRvPaq.js → browser-workflows-page-BHLdVoOC.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-BiQbVvYU.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api--tz0mGLY.js → capability-presets-api-DmElfgC9.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CYlZQpLY.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-CkOKF9nc.js → channel-recipient-api-BUEOtPft.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-DlDiCMhO.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-Dm_-934M.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-FBOe9SWC.js → connectors-api-BCdn44_o.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-Ce-eaPHw.js +2 -0
  26. package/dist/gateway/static/root/assets/cron-expression-D2hF3t68.js +2 -0
  27. package/dist/gateway/static/root/assets/{date-picker-Dtn7e6TW.js → date-picker-Dvjoq2mB.js} +1 -1
  28. package/dist/gateway/static/root/assets/dependency-picker-zv1OIhk3.js +1 -0
  29. package/dist/gateway/static/root/assets/desktop-pet-DJZhKLTb.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-FDmaty3P.js → desktop-pet-settings-B3ubM-eY.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-X2e8xn8j.js → directory-picker-path-field-BZEJIWOT.js} +1 -1
  32. package/dist/gateway/static/root/assets/download-Dk-ZjtO6.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-Dx4MBfga.js → extension-debug-page-Bvq3E1A1.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-Bf_FEDhM.js → extension-page-CuCJjWNm.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-CrOgZxkf.js → extension-settings-page-CpTk_ajr.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-api-CZ4r-7qT.js → gateway-config-api-C2yM6qj7.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-swr-Cv2ywpdb.js → gateway-config-swr-CN-JHMAh.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-DpWmVi0w.js → gateway-settings-COwi--2Q.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-undf-k5g.js → gateway-startup-retry-Dq1RyCjz.js} +1 -1
  40. package/dist/gateway/static/root/assets/{heartbeat-settings-DSQZhSvT.js → heartbeat-settings-Dc6H4VGF.js} +1 -1
  41. package/dist/gateway/static/root/assets/home-page-BB3RGxwm.js +3 -0
  42. package/dist/gateway/static/root/assets/index-CPTLS-Zn.js +85 -0
  43. package/dist/gateway/static/root/assets/index-Dm-cvIpl.css +2 -0
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bc3Quw42.js → keyboard-shortcuts-settings-cue30Z5p.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-DfO6FOB9.js +2 -0
  46. package/dist/gateway/static/root/assets/local-apps-page-DKQSCsa0.js +1 -0
  47. package/dist/gateway/static/root/assets/{locale-store-CnamlR07.js → locale-store-81Gv0wwo.js} +1 -1
  48. package/dist/gateway/static/root/assets/logs-page-DODbODyl.js +2 -0
  49. package/dist/gateway/static/root/assets/{management-settings-CJmcaVje.js → management-settings--4H26QR-.js} +1 -1
  50. package/dist/gateway/static/root/assets/{markdown-split-AcuFp0TH.js → markdown-split-BTvpyjAi.js} +1 -1
  51. package/dist/gateway/static/root/assets/markdown-view-B12xeflb.css +1 -0
  52. package/dist/gateway/static/root/assets/markdown-view-B4iBrVWK.js +69 -0
  53. package/dist/gateway/static/root/assets/{media-plugins-BvFgsiJL.js → media-plugins-DrejWl8t.js} +1 -1
  54. package/dist/gateway/static/root/assets/messages-ELK_1h2D.js +3 -0
  55. package/dist/gateway/static/root/assets/{notes-page-IW7IQ9nJ.js → notes-page-DfSzeQKd.js} +1 -1
  56. package/dist/gateway/static/root/assets/notes-workbench-DxL4GhwV.js +4 -0
  57. package/dist/gateway/static/root/assets/plus-Q2yW6OE7.js +1 -0
  58. package/dist/gateway/static/root/assets/preview-open-alternatives-yjh1_7K3.js +1 -0
  59. package/dist/gateway/static/root/assets/{product-open-page-CWEzLykF.js → product-open-page-DopWBJLa.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-Bl3LJHZB.js +1 -0
  61. package/dist/gateway/static/root/assets/projects-page-DStOErTC.js +1 -0
  62. package/dist/gateway/static/root/assets/remote-access-hub-C_hh9ztK.js +1 -0
  63. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DAohEZrX.js → runtime-tools-settings-panel-_dHhbYV2.js} +2 -2
  64. package/dist/gateway/static/root/assets/{schema-form-C_OBW8A5.js → schema-form-DZhORvJZ.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-DDY21KYw.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-BJrHIcw8.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-C7w2WS-A.js → settings-form-section-Du5eAgFS.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-zwibve4m.js → settings-loading-skeleton-DWS27sv1.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-B9W03dSW.js → settings-page-DPD0MwoN.js} +1 -1
  70. package/dist/gateway/static/root/assets/setup-status-panel-CnXN4LH_.js +1 -0
  71. package/dist/gateway/static/root/assets/share-preview-page-D6HmH2ga.js +2 -0
  72. package/dist/gateway/static/root/assets/shares-settings-U3lvtO3Y.js +1 -0
  73. package/dist/gateway/static/root/assets/skill-reload-api-B6GiZgZU.js +1 -0
  74. package/dist/gateway/static/root/assets/skills-page-XVO7d3fh.js +2 -0
  75. package/dist/gateway/static/root/assets/{skills-page.utils-D9QT5cxj.js → skills-page.utils-DwxIpWrI.js} +1 -1
  76. package/dist/gateway/static/root/assets/{system-settings-panel-c1HVtv1Y.js → system-settings-panel-BmKbxR8_.js} +1 -1
  77. package/dist/gateway/static/root/assets/task-detail-page-DA6ItYrc.js +1 -0
  78. package/dist/gateway/static/root/assets/{theme-store-BDyUTObE.js → theme-store-hOF81tUQ.js} +1 -1
  79. package/dist/gateway/static/root/assets/{use-autosave-D6UkH_Ga.js → use-autosave-GJfDpf66.js} +1 -1
  80. package/dist/gateway/static/root/assets/user-context-page-CQ1QrRE6.js +1 -0
  81. package/dist/gateway/static/root/assets/{voice-api-key-field-BOxkKbGh.js → voice-api-key-field-B0zve9EE.js} +1 -1
  82. package/dist/gateway/static/root/assets/work-discovery-overlay-DrIbHnBz.js +1 -0
  83. package/dist/gateway/static/root/assets/work-discovery-page-CQW8pPec.js +1 -0
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ZA3bP65I.js → workflow-run-setup-panel-D-_zQxim.js} +2 -2
  85. package/dist/gateway/static/root/assets/workflows-page-O21l_f5c.js +5 -0
  86. package/dist/gateway/static/root/assets/{working-directory-picker-modal-BcyiDXU3.js → working-directory-picker-modal-5xYx48tV.js} +1 -1
  87. package/dist/gateway/static/root/assets/x-B_N4OPjy.js +1 -0
  88. package/dist/gateway/static/root/index.html +19 -14
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/agent-manager.js +2 -1
  91. package/dist/src/agent/embedded/run-for-session.js +3 -2
  92. package/dist/src/agent/embedded/run-turn.js +29 -16
  93. package/dist/src/agent/embedded/types.d.ts +2 -2
  94. package/dist/src/agent/embedded/xopc-stream-bridge.d.ts +2 -1
  95. package/dist/src/agent/embedded/xopc-stream-bridge.js +2 -2
  96. package/dist/src/agent/memory/context-budget.d.ts +6 -1
  97. package/dist/src/agent/memory/context-budget.js +94 -2
  98. package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
  99. package/dist/src/agent/prompt/cache-boundary.js +10 -1
  100. package/dist/src/agent/prompt/sections/project-context.d.ts +1 -4
  101. package/dist/src/agent/prompt/sections/project-context.js +6 -13
  102. package/dist/src/agent/prompt/service-prompt-builder.js +2 -1
  103. package/dist/src/agent/prompt/system-prompt.d.ts +1 -3
  104. package/dist/src/agent/prompt/system-prompt.js +6 -15
  105. package/dist/src/agent/tools/cache-stability.d.ts +3 -0
  106. package/dist/src/agent/tools/cache-stability.js +19 -0
  107. package/dist/src/agent/tools/factory.js +2 -1
  108. package/dist/src/agent-manifest/schema.d.ts +40 -20
  109. package/dist/src/agent-manifest/schema.js +4 -5
  110. package/dist/src/config/schema.d.ts +40 -20
  111. package/dist/src/extensions/types/providers.d.ts +0 -2
  112. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -1
  113. package/dist/src/gateway/hono/oauth-async.d.ts +1 -0
  114. package/dist/src/gateway/hono/oauth-async.js +14 -2
  115. package/dist/src/providers/extension-stream-bridge.js +0 -2
  116. package/dist/src/providers/google-managed-prompt-cache.d.ts +14 -0
  117. package/dist/src/providers/google-managed-prompt-cache.js +125 -0
  118. package/dist/src/providers/prompt-cache-fingerprint.d.ts +4 -0
  119. package/dist/src/providers/prompt-cache-fingerprint.js +44 -0
  120. package/dist/src/providers/prompt-cache-lifecycle.d.ts +9 -0
  121. package/dist/src/providers/prompt-cache-lifecycle.js +31 -0
  122. package/dist/src/providers/prompt-cache-observability.d.ts +20 -0
  123. package/dist/src/providers/prompt-cache-observability.js +44 -0
  124. package/dist/src/providers/prompt-cache-payload.d.ts +10 -3
  125. package/dist/src/providers/prompt-cache-payload.js +204 -31
  126. package/dist/src/providers/prompt-cache-plan.d.ts +15 -0
  127. package/dist/src/providers/prompt-cache-plan.js +29 -0
  128. package/package.json +3 -3
  129. package/dist/gateway/static/root/assets/agents-ANavi648.js +0 -68
  130. package/dist/gateway/static/root/assets/apps-page-CFh9MBxc.js +0 -1
  131. package/dist/gateway/static/root/assets/automations-page-751CeNI3.js +0 -6
  132. package/dist/gateway/static/root/assets/browser-settings-page-CGAWs-TT.js +0 -8
  133. package/dist/gateway/static/root/assets/capabilities-settings-panel-CghUK68J.js +0 -7
  134. package/dist/gateway/static/root/assets/capability-presets-settings-panel-XsTfkvUn.js +0 -3
  135. package/dist/gateway/static/root/assets/channels-settings-DkoAZZMe.js +0 -1
  136. package/dist/gateway/static/root/assets/channels-status-swr-DNDvMWpl.js +0 -1
  137. package/dist/gateway/static/root/assets/connectors-page-e4vekkAu.js +0 -2
  138. package/dist/gateway/static/root/assets/cron-expression-Q4QaYjpI.js +0 -2
  139. package/dist/gateway/static/root/assets/dependency-picker-Br6nPaM6.js +0 -1
  140. package/dist/gateway/static/root/assets/desktop-pet-DzTM6aH8.js +0 -1
  141. package/dist/gateway/static/root/assets/home-page-L0uHiu0T.js +0 -3
  142. package/dist/gateway/static/root/assets/index-Bp8I_eX4.css +0 -1
  143. package/dist/gateway/static/root/assets/index-DRrjYYzZ.js +0 -152
  144. package/dist/gateway/static/root/assets/local-app-workbench-page-Copi3sdP.js +0 -2
  145. package/dist/gateway/static/root/assets/local-apps-page-CP9X_vtz.js +0 -1
  146. package/dist/gateway/static/root/assets/logs-page-DMKq6e29.js +0 -2
  147. package/dist/gateway/static/root/assets/messages-D7kOD_o_.js +0 -3
  148. package/dist/gateway/static/root/assets/notes-workbench-Zb8U0anO.js +0 -4
  149. package/dist/gateway/static/root/assets/preview-open-alternatives-C-b34dgQ.js +0 -1
  150. package/dist/gateway/static/root/assets/project-detail-page-BuIbLnan.js +0 -1
  151. package/dist/gateway/static/root/assets/projects-page-BwUfRqNV.js +0 -1
  152. package/dist/gateway/static/root/assets/remote-access-hub-BTaXxcEi.js +0 -1
  153. package/dist/gateway/static/root/assets/sessions-page-BnHoTCD3.js +0 -1
  154. package/dist/gateway/static/root/assets/settings-advanced-gate-BTB_fxjt.js +0 -1
  155. package/dist/gateway/static/root/assets/setup-status-panel-C8Hec2Af.js +0 -1
  156. package/dist/gateway/static/root/assets/share-preview-page-6e3ks2be.js +0 -2
  157. package/dist/gateway/static/root/assets/shares-settings-Bwc5HfLI.js +0 -1
  158. package/dist/gateway/static/root/assets/skill-reload-api-D7kunhqy.js +0 -1
  159. package/dist/gateway/static/root/assets/skills-page-WgkaNzpc.js +0 -2
  160. package/dist/gateway/static/root/assets/task-detail-page-CjP-6WVU.js +0 -1
  161. package/dist/gateway/static/root/assets/user-context-page-D8ZhPDNF.js +0 -1
  162. package/dist/gateway/static/root/assets/work-discovery-overlay-Dd19yK9t.js +0 -1
  163. package/dist/gateway/static/root/assets/work-discovery-page-DUkdJl1e.js +0 -1
  164. package/dist/gateway/static/root/assets/workflows-page-C2b5W5bw.js +0 -5
@@ -1,5 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,l as o,t as s}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as c}from"./check-DUBLcKHA.js";import{n as l,r as u,t as d}from"./popover-select-BzdnTy3h.js";import{t as f}from"./copy-Dv6d4Dvw.js";import{t as p}from"./cn-JdwAhgNB.js";import{t as m}from"./button-CSEbl4zT.js";import{n as h}from"./interaction-BmQogeqz.js";import{t as g}from"./copy-to-clipboard-HOJ79TWv.js";import{t as _}from"./messages-D7kOD_o_.js";import{l as v,n as y}from"./locale-store-CnamlR07.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{Al as x,An as S,Ar as C,Br as w,C as T,Cc as E,D,Dc as O,Dr as k,E as A,Er as j,Fl as M,Fr as N,Gr as P,Hc as F,Hr as I,Ic as L,Ir as R,Is as z,Kr as B,Ks as V,Ll as H,Ln as U,Lr as W,Mr as G,Na as K,Nr as ee,Ns as te,Ol as ne,Or as re,Pr as ie,Ps as q,Qo as ae,Qr as J,Ri as oe,Rr as se,S as ce,Ss as le,T as ue,Tc as de,Ur as fe,Vr as pe,Wa as me,Wr as he,Ws as ge,Xs as _e,Yo as Y,Yr as ve,Zr as ye,_ as be,a as xe,al as Se,b as Ce,bc as we,bl as Te,cl as Ee,cs as X,d as De,ei as Oe,f as ke,g as Ae,h as je,ii as Me,jc as Ne,jr as Pe,kr as Fe,lc as Ie,ls as Le,m as Re,mc as ze,ni as Be,nl as Ve,ns as He,p as Ue,ql as We,qr as Ge,ri as Ke,ti as qe,v as Je,w as Ye,wi as Xe,wr as Ze,x as Qe,y as $e}from"./index-DRrjYYzZ.js";import{t as et}from"./page-tabs-BaEQMYm_.js";import{i as tt,r as nt,t as rt}from"./workflow-run-setup-panel-ZA3bP65I.js";import{a as it,c as at,i as ot,l as st,n as ct,o as lt,r as ut,s as dt,t as ft}from"./style-TIDOdKy0.js";var Z=e(t(),1),Q=n(),pt=[`queued`,`running`,`succeeded`,`attention`],mt=new Set([`failed`,`timeout`,`cancelled`]);function ht(e){return e.metadata?.sessionKey?.trim()||null}function gt(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function _t(e,t){if(!e||typeof e!=`object`)return null;let n=e;for(let e of t){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}return null}function vt(e,t=90){let n=e.metadata?.input?.goal?.trim()||(typeof e.metadata?.input?.payload==`string`?e.metadata.input.payload.trim():null)||_t(e.metadata?.input?.payload,[`query`,`goal`,`prompt`,`input`,`message`])||_t(e.metadata?.input?.variables,[`query`,`goal`,`prompt`,`input`,`message`]);return n?gt(n,t):null}function yt(e,t=90){return vt(e,t)??gt(e.title?.trim()||e.definitionId,t)}function bt(e,t=44){return gt(e.title?.trim()||e.definitionId,t)}function xt(e,t){let n=t.trim().toLowerCase();return n?[vt(e,500),e.title,e.definitionId,e.id].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function St(e,t){let n=t.workflowFilterId.trim();return e.filter(e=>n&&e.definitionId!==n||!ee(e,t.triggerFilter??`all`)?!1:xt(e,t.searchQuery))}function Ct(e){return e.completedAtMs??e.createdAtMs}function wt(e,t){return e.status===`queued`?`queued`:e.status===`running`?`running`:e.status===`succeeded`?`succeeded`:mt.has(e.status)?`attention`:null}function Tt(e,t){let n=[...t];return e===`queued`?n.sort((e,t)=>e.createdAtMs-t.createdAtMs):e===`running`?n.sort((e,t)=>(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)):n.sort((e,t)=>Ct(t)-Ct(e))}function Et(e,t){let n={queued:[],running:[],succeeded:[],attention:[]};for(let r of e){let e=wt(r,t);e&&n[e].push(r)}return pt.map(e=>{if(e===`succeeded`){let t=Tt(`succeeded`,n.succeeded);return{id:e,runs:t,totalInWindow:t.length}}return{id:e,runs:Tt(e,n[e])}})}function Dt(e,t,n){let r=Math.round((t-e)/1e3);if(r<60)return J(-r,`second`,n);let i=Math.round(r/60);if(i<60)return J(-i,`minute`,n);let a=Math.round(i/60);return a<48?J(-a,`hour`,n):J(-Math.round(a/24),`day`,n)}function Ot(e){return e.status===`queued`||e.status===`running`}function kt(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}var $=r(),At=(0,Z.memo)(function(e){let t=(0,Q.c)(76),{run:n,language:r,localeTag:i,nowMs:a,selected:o,onOpen:s,onOpenChat:c,onCancel:l,onRetry:u}=e,d=_(r).workflows,[f,g]=(0,Z.useState)(!1),v;t[0]===n?v=t[1]:(v=ht(n),t[0]=n,t[1]=v);let y=!v,b;t[2]===n?b=t[3]:(b=Ot(n),t[2]=n,t[3]=b);let x=b,S=n.status===`running`||n.status===`queued`,w;t[4]!==n.metrics.agentCount||t[5]!==n.metrics.doneAgentCount?(w=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[4]=n.metrics.agentCount,t[5]=n.metrics.doneAgentCount,t[6]=w):w=t[6];let T=w,E=n.metrics.errorAgentCount>0,D=n.startedAtMs??n.createdAtMs,O=re(x?a-D:n.metrics.durationMs),k=C(d.taskArtifacts,{count:n.metrics.artifactCount}),A;t[7]===n?A=t[8]:(A=yt(n),t[7]=n,t[8]=A);let j=A,M;t[9]===n?M=t[10]:(M=bt(n),t[9]=n,t[10]=M);let N=M,P;t[11]!==s||t[12]!==n?(P=()=>{s(n)},t[11]=s,t[12]=n,t[13]=P):P=t[13];let F=P,I;t[14]!==y||t[15]!==c||t[16]!==n?(I=()=>{y||c(n)},t[14]=y,t[15]=c,t[16]=n,t[17]=I):I=t[17];let L=I,R=o&&`ring-1 ring-accent/30`,z;t[18]===R?z=t[19]:(z=p(`group relative min-h-24 overflow-hidden rounded-lg bg-surface-panel p-3 shadow-surface transition-colors`,R,`hover:bg-surface-hover`),t[18]=R,t[19]=z);let B;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(B=p(`w-full text-left`,h.focusRingPanel),t[20]=B):B=t[20];let V;t[21]===j?V=t[22]:(V=(0,$.jsx)(`div`,{className:`line-clamp-2 text-sm font-medium leading-5 text-fg`,children:j}),t[21]=j,t[22]=V);let H;t[23]===N?H=t[24]:(H=(0,$.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:N}),t[23]=N,t[24]=H);let U;t[25]!==V||t[26]!==H?(U=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[V,H]}),t[25]=V,t[26]=H,t[27]=U):U=t[27];let W;t[28]===n.status?W=t[29]:(W=p(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,ie(n.status)),t[28]=n.status,t[29]=W);let G;t[30]!==i||t[31]!==a||t[32]!==D?(G=Dt(D,a,i),t[30]=i,t[31]=a,t[32]=D,t[33]=G):G=t[33];let K;t[34]===G?K=t[35]:(K=(0,$.jsx)(`span`,{children:G}),t[34]=G,t[35]=K);let ee=O===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:C(d.taskElapsed,{duration:O})})]}),te;t[36]!==K||t[37]!==ee?(te=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[K,ee]}),t[36]=K,t[37]=ee,t[38]=te):te=t[38];let ne=n.metrics.artifactCount>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:k}):null,q=o?(0,$.jsx)(`span`,{className:`font-medium text-accent-fg`,children:d.taskOpenDetails}):null,ae;t[39]!==ne||t[40]!==q?(ae=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,children:[ne,q]}),t[39]=ne,t[40]=q,t[41]=ae):ae=t[41];let J=y&&`cursor-not-allowed text-fg-disabled hover:bg-transparent`,oe;t[42]===J?oe=t[43]:(oe=p(`rounded-md px-2 py-1 text-xs font-medium`,`text-accent-fg hover:bg-accent-soft`,h.focusRingPanel,J),t[42]=J,t[43]=oe);let se;t[44]!==y||t[45]!==L||t[46]!==d.continueInChat||t[47]!==oe?(se=(0,$.jsx)(`button`,{type:`button`,className:oe,disabled:y,onClick:L,children:d.continueInChat}),t[44]=y,t[45]=L,t[46]=d.continueInChat,t[47]=oe,t[48]=se):se=t[48];let ce;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ce=p(`rounded-md px-2 py-1 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,h.focusRingPanel),t[49]=ce):ce=t[49];let le;t[50]!==F||t[51]!==d.taskOpenDetails?(le=(0,$.jsx)(`button`,{type:`button`,className:ce,onClick:F,children:d.taskOpenDetails}),t[50]=F,t[51]=d.taskOpenDetails,t[52]=le):le=t[52];let ue;t[53]!==se||t[54]!==le?(ue=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-2`,children:[se,le]}),t[53]=se,t[54]=le,t[55]=ue):ue=t[55];let de;t[56]===g?de=t[57]:(de=()=>g(Mt),t[56]=g,t[57]=de);let fe;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(Ve,{className:`size-4`,"aria-hidden":!0}),t[58]=fe):fe=t[58];let pe;t[59]!==d.taskActionsAria||t[60]!==f||t[61]!==de?(pe=(0,$.jsx)(m,{variant:`ghost`,className:`size-7 p-0 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,"aria-label":d.taskActionsAria,"aria-expanded":f,onClick:de,children:fe}),t[59]=d.taskActionsAria,t[60]=f,t[61]=de,t[62]=pe):pe=t[62];let me;t[63]!==x||t[64]!==d.cancel||t[65]!==d.rerun||t[66]!==d.taskCloseMenu||t[67]!==f||t[68]!==l||t[69]!==u||t[70]!==n||t[71]!==g?(me=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-10 cursor-default`,"aria-label":d.taskCloseMenu,onClick:()=>g(!1)}),(0,$.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 min-w-36 rounded-lg border border-edge bg-surface-panel py-1 shadow-surface`,children:[x?(0,$.jsx)(jt,{label:d.cancel,tone:`danger`,onClick:()=>{g(!1),l(n.id)}}):null,kt(n)?(0,$.jsx)(jt,{label:d.rerun,onClick:()=>{g(!1),u(n.id)}}):null]})]}):null,t[63]=x,t[64]=d.cancel,t[65]=d.rerun,t[66]=d.taskCloseMenu,t[67]=f,t[68]=l,t[69]=u,t[70]=n,t[71]=g,t[72]=me):me=t[72];let he;return t[73]!==pe||t[74]!==me?(he=(0,$.jsxs)(`div`,{className:`absolute right-2 top-2`,children:[pe,me]}),t[73]=pe,t[74]=me,t[75]=he):he=t[75],(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:F,"aria-label":`${d.taskOpenDetails}: ${j}`,"aria-current":o?`true`:void 0,className:B,children:[(0,$.jsxs)(`div`,{className:`pr-7`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[U,(0,$.jsx)(`span`,{className:W,children:d.status[n.status]??n.status})]}),te]}),S?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{children:C(d.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{children:[T,`%`]})]}),(0,$.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${T}%`}})})]}):null,ae,E?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(X,{className:`size-3 shrink-0`,"aria-hidden":!0}),C(d.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null]}),ue,he]})});function jt(e){let t=(0,Q.c)(8),{label:n,disabled:r,tone:i,onClick:a}=e,o=r?`cursor-not-allowed text-fg-subtle`:`text-fg hover:bg-surface-hover`,s=i===`danger`&&!r&&`text-red-600 dark:text-red-300`,c;t[0]!==o||t[1]!==s?(c=p(`block w-full px-3 py-1.5 text-left text-xs`,o,s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let l;return t[3]!==r||t[4]!==n||t[5]!==a||t[6]!==c?(l=(0,$.jsx)(`button`,{type:`button`,disabled:r,onClick:a,className:c,children:n}),t[3]=r,t[4]=n,t[5]=a,t[6]=c,t[7]=l):l=t[7],l}function Mt(e){return!e}function Nt(e,t){return t.boardColumns[e]}var Pt=(0,Z.memo)(function(e){let t=(0,Q.c)(17),{column:n,language:r,localeTag:i,nowMs:a,selectedRunId:o,loading:s,onOpenRun:c,onOpenRunChat:l,onCancelRun:u,onRetryRun:d}=e,f=_(r).workflows,[h,g]=(0,Z.useState)(!1),v=n.id===`succeeded`,y=v?5:n.runs.length,b;t[0]!==y||t[1]!==n.runs||t[2]!==h||t[3]!==v?(b=v&&!h?n.runs.slice(0,y):n.runs,t[0]=y,t[1]=n.runs,t[2]=h,t[3]=v,t[4]=b):b=t[4];let x=b,S=v&&n.runs.length>5&&!h,w=v&&h,T;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(T=p(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`),t[5]=T):T=t[5];let E;t[6]===n.runs.length?E=t[7]:(E=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.runs.length}),t[6]=n.runs.length,t[7]=E);let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Ve,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=D):D=t[8];let O=s&&x.length===0?(0,$.jsx)(Ft,{}):x.length===0?(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:f.boardColumnEmpty}):x.map(e=>(0,$.jsx)(At,{run:e,language:r,localeTag:i,nowMs:a,selected:e.id===o,onOpen:c,onOpenChat:l,onCancel:u,onRetry:d},e.id)),k=S?(0,$.jsx)(m,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>g(!0),children:C(f.boardExpandSucceeded,{count:Math.min(n.runs.length,n.totalInWindow??n.runs.length)})}):null,A;t[9]!==w||t[10]!==f||t[11]!==g?(A=w?(0,$.jsx)(m,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>g(!1),children:f.boardCollapseSucceeded}):null,t[9]=w,t[10]=f,t[11]=g,t[12]=A):A=t[12];let j;return t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,$.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[O,k,A]}),t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16],(0,$.jsxs)(`section`,{className:T,"aria-label":Nt(n.id,f),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Nt(n.id,f)}),E]}),D]}),j]})});function Ft(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`article`,{className:`min-h-24 rounded-lg bg-surface-panel p-3 shadow-surface`,"aria-hidden":`true`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(K,{className:`size-4/5`}),(0,$.jsx)(K,{className:`mt-2 h-3 w-24`})]}),(0,$.jsx)(K,{className:`h-5 w-14 rounded-full`})]}),(0,$.jsx)(K,{className:`mt-3 h-3 w-2/3`}),(0,$.jsx)(K,{className:`mt-4 h-5 w-20 rounded-full`})]}),e[0]=t):t=e[0],t}function It(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Lt=(0,Z.memo)(function(e){let t=(0,Q.c)(54),{runs:n,language:r,localeTag:i,labels:a,searchQuery:o,workflowFilterId:s,triggerFilter:c,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:h,onStart:g}=e,_;t[0]===n?_=t[1]:(_=n.some(Rt),t[0]=n,t[1]=_);let v=_,y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),[x,S]=(0,Z.useState)(zt),[C,w]=(0,Z.useState)(!1),T,E;t[2]===v?(T=t[3],E=t[4]):(T=()=>{if(!v)return;let e=window.setInterval(()=>S(Date.now()),1e3);return()=>window.clearInterval(e)},E=[v],t[2]=v,t[3]=T,t[4]=E),(0,Z.useEffect)(T,E);let D;t[5]!==x||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==s?(D=Et(St(n,{searchQuery:o,workflowFilterId:s,triggerFilter:c}),x),t[5]=x,t[6]=n,t[7]=o,t[8]=c,t[9]=s,t[10]=D):D=t[10];let O=D,k=O.reduce(Bt,0),A;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{let t=b.current;!t||t.pointerId!==e.pointerId||(b.current=null,w(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},t[11]=A):A=t[11];let j=A,M;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>{if(e.button!==0||It(e.target))return;let t=y.current;t&&(b.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},t[12]=M):M=t[12];let N=M,P;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{let t=b.current,n=y.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,w(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},t[13]=P):P=t[13];let F=P;if(!u&&k===0){let e;t[14]===a.boardEmptyTitle?e=t[15]:(e=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:a.boardEmptyTitle}),t[14]=a.boardEmptyTitle,t[15]=e);let n;t[16]===a.boardEmptyHint?n=t[17]:(n=(0,$.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.boardEmptyHint}),t[16]=a.boardEmptyHint,t[17]=n);let r;t[18]!==a.boardStart||t[19]!==g?(r=(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsx)(m,{variant:`primary`,onClick:g,children:a.boardStart})}),t[18]=a.boardStart,t[19]=g,t[20]=r):r=t[20];let i;return t[21]!==r||t[22]!==e||t[23]!==n?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center rounded-2xl border border-dashed border-edge bg-surface-panel/40 px-6 py-12 text-center`,children:[e,n,r]}),t[21]=r,t[22]=e,t[23]=n,t[24]=i):i=t[24],i}let I=C?`cursor-grabbing select-none`:`cursor-grab`,L;t[25]===I?L=t[26]:(L=[`min-h-0 h-full min-w-0 overflow-x-auto rounded-lg p-2`,I],t[25]=I,t[26]=L);let R=L.join(` `),z;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{b.current?.pointerId===e.pointerId&&(b.current=null,w(!1))},t[27]=z):z=t[27];let B;if(t[28]!==O||t[29]!==r||t[30]!==u||t[31]!==i||t[32]!==x||t[33]!==p||t[34]!==d||t[35]!==f||t[36]!==h||t[37]!==l){let e;t[39]!==r||t[40]!==u||t[41]!==i||t[42]!==x||t[43]!==p||t[44]!==d||t[45]!==f||t[46]!==h||t[47]!==l?(e=e=>(0,$.jsx)(Pt,{column:e,language:r,localeTag:i,nowMs:x,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:h},e.id),t[39]=r,t[40]=u,t[41]=i,t[42]=x,t[43]=p,t[44]=d,t[45]=f,t[46]=h,t[47]=l,t[48]=e):e=t[48],B=O.map(e),t[28]=O,t[29]=r,t[30]=u,t[31]=i,t[32]=x,t[33]=p,t[34]=d,t[35]=f,t[36]=h,t[37]=l,t[38]=B}else B=t[38];let V;t[49]===B?V=t[50]:(V=(0,$.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:B}),t[49]=B,t[50]=V);let H;return t[51]!==R||t[52]!==V?(H=(0,$.jsx)(`div`,{ref:y,className:R,onPointerDown:N,onPointerMove:F,onPointerUp:j,onPointerCancel:j,onLostPointerCapture:z,children:V}),t[51]=R,t[52]=V,t[53]=H):H=t[53],H});function Rt(e){return e.status===`queued`||e.status===`running`}function zt(){return Date.now()}function Bt(e,t){return e+t.runs.length}function Vt(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?C(t.agentScaleExact,{count:n.min}):C(t.agentScaleRange,{min:n.min,max:n.max}):null}function Ht(e){let t=(0,Q.c)(73),{definition:n,language:r,labels:i,onPick:a,onDetail:o,onEdit:s}=e,c;t[0]!==n||t[1]!==r?(c=ve(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let l=c,u;t[3]!==n||t[4]!==i?(u=Vt(n,i),t[3]=n,t[4]=i,t[5]=u):u=t[5];let d=u,f=n.metadata.source===`user`,g=f?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-muted`,_;t[6]===g?_=t[7]:(_=p(`rounded-full px-2 py-0.5 text-[10px] font-medium`,g),t[6]=g,t[7]=_);let v=f?i.badgeUser:i.badgeBuiltin,y;t[8]!==_||t[9]!==v?(y=(0,$.jsx)(`span`,{className:_,children:v}),t[8]=_,t[9]=v,t[10]=y):y=t[10];let b;t[11]!==n.inputSchema||t[12]!==i.inputSchemaBadge?(b=n.inputSchema?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[10px] text-fg-subtle`,children:[(0,$.jsx)(M,{className:`size-2.5`,"aria-hidden":!0}),i.inputSchemaBadge]}):null,t[11]=n.inputSchema,t[12]=i.inputSchemaBadge,t[13]=b):b=t[13];let x;t[14]!==y||t[15]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[y,b]}),t[14]=y,t[15]=b,t[16]=x):x=t[16];let S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=p(`mt-2 line-clamp-2 text-left text-sm font-semibold leading-5 text-fg hover:text-accent-fg`,h.focusRingPanel),t[17]=S):S=t[17];let w;t[18]!==n||t[19]!==o?(w=()=>o(n),t[18]=n,t[19]=o,t[20]=w):w=t[20];let T;t[21]!==n.title||t[22]!==w?(T=(0,$.jsx)(`button`,{type:`button`,className:S,onClick:w,children:n.title}),t[21]=n.title,t[22]=w,t[23]=T):T=t[23];let E;t[24]!==T||t[25]!==x?(E=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,T]}),t[24]=T,t[25]=x,t[26]=E):E=t[26];let D=`${f?i.editWorkflow:i.copyAndEditWorkflow}: ${n.title}`,k;t[27]!==n||t[28]!==s?(k=()=>s(n),t[27]=n,t[28]=s,t[29]=k):k=t[29];let A;t[30]===f?A=t[31]:(A=f?(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}),t[30]=f,t[31]=A);let j;t[32]!==D||t[33]!==k||t[34]!==A?(j=(0,$.jsx)(m,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":D,onClick:k,children:A}),t[32]=D,t[33]=k,t[34]=A,t[35]=j):j=t[35];let N;t[36]!==E||t[37]!==j?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[E,j]}),t[36]=E,t[37]=j,t[38]=N):N=t[38];let P=l.whenToUse||l.description||n.description,F;t[39]===P?F=t[40]:(F=(0,$.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:P}),t[39]=P,t[40]=F);let I;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(O,{className:`size-3`,"aria-hidden":!0}),t[41]=I):I=t[41];let L;t[42]!==n.phases.length||t[43]!==i.phaseCount?(L=C(i.phaseCount,{count:n.phases.length}),t[42]=n.phases.length,t[43]=i.phaseCount,t[44]=L):L=t[44];let R;t[45]===L?R=t[46]:(R=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,L]}),t[45]=L,t[46]=R);let z;t[47]===d?z=t[48]:(z=d?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(He,{className:`size-3`,"aria-hidden":!0}),d]}):null,t[47]=d,t[48]=z);let B;t[49]!==R||t[50]!==z?(B=(0,$.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-3 pt-4 text-[11px] text-fg-subtle`,children:[R,z]}),t[49]=R,t[50]=z,t[51]=B):B=t[51];let H;t[52]!==n||t[53]!==a?(H=()=>a(n),t[52]=n,t[53]=a,t[54]=H):H=t[54];let U;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),t[55]=U):U=t[55];let W;t[56]!==i.configureAndRun||t[57]!==H?(W=(0,$.jsxs)(m,{type:`button`,variant:`primary`,className:`h-8 flex-1 rounded-lg text-xs`,onClick:H,children:[U,i.configureAndRun]}),t[56]=i.configureAndRun,t[57]=H,t[58]=W):W=t[58];let G;t[59]!==n||t[60]!==o?(G=()=>o(n),t[59]=n,t[60]=o,t[61]=G):G=t[61];let K;t[62]!==i.viewDetails||t[63]!==G?(K=(0,$.jsx)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:G,children:i.viewDetails}),t[62]=i.viewDetails,t[63]=G,t[64]=K):K=t[64];let ee;t[65]!==W||t[66]!==K?(ee=(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[W,K]}),t[65]=W,t[66]=K,t[67]=ee):ee=t[67];let te;return t[68]!==N||t[69]!==F||t[70]!==B||t[71]!==ee?(te=(0,$.jsxs)(`article`,{className:`flex min-h-48 flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 transition-colors hover:border-edge hover:bg-surface-hover/35`,children:[N,F,B,ee]}),t[68]=N,t[69]=F,t[70]=B,t[71]=ee,t[72]=te):te=t[72],te}function Ut(e){let t=(0,Q.c)(44),{definitions:n,runs:r,language:i,onPick:a,onDetail:o,onEdit:s}=e,[c]=(0,Z.useState)(Kt),d=_(i).workflows,f=i===`zh`?`zh-CN`:`en-US`,[m,g]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(`all`),[b,x]=(0,Z.useState)(`all`),S;t[0]!==v||t[1]!==n||t[2]!==m||t[3]!==b?(S=k(n,m,v,b),t[0]=v,t[1]=n,t[2]=m,t[3]=b,t[4]=S):S=t[4];let T=S,E;if(t[5]!==n||t[6]!==r){let e=new Map(n.map(Gt)),i=new Set;E=[...r].sort(Wt).flatMap(t=>{if(i.has(t.definitionId))return[];let n=e.get(t.definitionId);return n?(i.add(t.definitionId),[{definition:n,lastRunAtMs:t.startedAtMs??t.createdAtMs}]):[]}).slice(0,3),t[5]=n,t[6]=r,t[7]=E}else E=t[7];let D=E,O=C(d.workflowCount,{count:T.length}),A;t[8]===O?A=t[9]:(A=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O}),t[8]=O,t[9]=A);let j=d.sourceFilterAria,M;t[10]!==d.sources||t[11]!==x||t[12]!==b?(M=he.map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`h-8 rounded-md px-2.5 text-xs font-medium transition-colors`,b===e?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`,h.focusRingPanel),"aria-pressed":b===e,onClick:()=>x(e),children:d.sources[e]},e)),t[10]=d.sources,t[11]=x,t[12]=b,t[13]=M):M=t[13];let N;t[14]!==d.sourceFilterAria||t[15]!==M?(N=(0,$.jsx)(`div`,{className:`flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":j,children:M}),t[14]=d.sourceFilterAria,t[15]=M,t[16]=N):N=t[16];let P=d.categoryFilterAria,F;t[17]===y?F=t[18]:(F=e=>y(e.target.value),t[17]=y,t[18]=F);let I;t[19]===d.categories?I=t[20]:(I=w.map(e=>(0,$.jsx)(u,{value:e,children:d.categories[e]},e)),t[19]=d.categories,t[20]=I);let L;t[21]!==v||t[22]!==d.categoryFilterAria||t[23]!==F||t[24]!==I?(L=(0,$.jsx)(l,{value:v,"aria-label":P,onChange:F,className:`h-9 min-w-36 rounded-lg border border-edge bg-surface-base px-2.5 text-xs font-medium text-fg shadow-surface`,children:I}),t[21]=v,t[22]=d.categoryFilterAria,t[23]=F,t[24]=I,t[25]=L):L=t[25];let R;t[26]!==L||t[27]!==N?(R=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[N,L]}),t[26]=L,t[27]=N,t[28]=R):R=t[28];let z;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(te,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[29]=z):z=t[29];let B;t[30]===g?B=t[31]:(B=e=>g(e.target.value),t[30]=g,t[31]=B);let H=d.librarySearchPlaceholder,U;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(U=p(`h-10 w-full rounded-lg border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-muted`,h.focusRingPanel),t[32]=U):U=t[32];let W;t[33]!==d.librarySearchPlaceholder||t[34]!==m||t[35]!==B?(W=(0,$.jsxs)(`div`,{className:`relative max-w-xl`,children:[z,(0,$.jsx)(`input`,{value:m,onChange:B,placeholder:H,className:U})]}),t[33]=d.librarySearchPlaceholder,t[34]=m,t[35]=B,t[36]=W):W=t[36];let G;return t[37]!==T||t[38]!==d||t[39]!==i||t[40]!==o||t[41]!==s||t[42]!==a?(G=T.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-4 py-12 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.noDefinitions}),(0,$.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-5 text-fg-muted`,children:d.noDefinitionsHint})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pt-4 sm:grid-cols-2 xl:grid-cols-3`,children:T.map(e=>(0,$.jsx)(Ht,{definition:e,language:i,labels:d,onPick:a,onDetail:o,onEdit:s},e.id))}),t[37]=T,t[38]=d,t[39]=i,t[40]=o,t[41]=s,t[42]=a,t[43]=G):G=t[43],(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5`,children:[D.length>0&&!m&&v===`all`&&b===`all`?(0,$.jsxs)(`section`,{"aria-labelledby":`recent-workflows-heading`,children:[(0,$.jsx)(`h2`,{id:`recent-workflows-heading`,className:`text-sm font-semibold text-fg`,children:d.recentlyUsed}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:D.map(e=>{let{definition:t,lastRunAtMs:n}=e;return(0,$.jsxs)(`button`,{type:`button`,className:p(`flex min-w-52 flex-1 items-center justify-between gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-left hover:bg-surface-hover`,`sm:max-w-sm`,h.focusRingPanel),onClick:()=>a(t),children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:t.title}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-fg-subtle`,children:Dt(n,c,f)})]}),(0,$.jsx)(V,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0})]},t.id)})})]}):null,(0,$.jsxs)(`section`,{"aria-labelledby":`all-workflows-heading`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{id:`all-workflows-heading`,className:`text-sm font-semibold text-fg`,children:d.allWorkflows}),A]}),R]}),W]}),G]})]})}function Wt(e,t){return(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)}function Gt(e){return[e.id,e]}function Kt(){return Date.now()}var qt=(0,Z.memo)(function(e){let t=(0,Q.c)(108),{run:n,language:r,localeTag:i,nowMs:a,onOpen:o,onOpenChat:s,onCancel:c,onRetry:l}=e,u,d,f,g,v,y,b,x,S,w,T,E,D,O,k,A,j;if(t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==n){f=_(r).workflows;let e;t[22]===n?e=t[23]:(e=Ot(n),t[22]=n,t[23]=e),u=e;let s;t[24]===n?s=t[25]:(s=kt(n),t[24]=n,t[25]=s),g=s;let c;t[26]===n?c=t[27]:(c=ht(n),t[26]=n,t[27]=c),d=!!c;let l=n.startedAtMs??n.createdAtMs,m=re(u?a-l:n.metrics.durationMs),M;t[28]!==n.metrics.agentCount||t[29]!==n.metrics.doneAgentCount?(M=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[28]=n.metrics.agentCount,t[29]=n.metrics.doneAgentCount,t[30]=M):M=t[30];let N=M;S=`group border-b border-edge-subtle last:border-b-0`,x=`flex min-w-0 flex-col gap-3 p-3 transition-colors hover:bg-surface-hover/55 sm:px-4 lg:flex-row lg:items-center`,A=`button`,t[31]!==o||t[32]!==n?(j=()=>o(n),t[31]=o,t[32]=n,t[33]=j):j=t[33],t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=p(`min-w-0 flex-1 text-left`,h.focusRingPanel),t[34]=y):y=t[34];let P=f.taskOpenDetails,F;t[35]===n?F=t[36]:(F=yt(n),t[35]=n,t[36]=F),b=`${P}: ${F}`,O=`flex min-w-0 items-start gap-3`;let I;t[37]===n.status?I=t[38]:(I=p(`mt-0.5 shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold`,ie(n.status)),t[37]=n.status,t[38]=I),k=(0,$.jsx)(`span`,{className:I,children:f.status[n.status]??n.status}),v=`min-w-0 flex-1`;let L;t[39]===n?L=t[40]:(L=yt(n),t[39]=n,t[40]=L),t[41]===L?w=t[42]:(w=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:L}),t[41]=L,t[42]=w);let R;t[43]===n?R=t[44]:(R=bt(n),t[43]=n,t[44]=R);let z;t[45]===R?z=t[46]:(z=(0,$.jsx)(`span`,{className:`truncate font-medium`,children:R}),t[45]=R,t[46]=z);let B;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[47]=B):B=t[47];let V;t[48]!==i||t[49]!==a||t[50]!==l?(V=Dt(l,a,i),t[48]=i,t[49]=a,t[50]=l,t[51]=V):V=t[51];let H;t[52]===V?H=t[53]:(H=(0,$.jsx)(`span`,{children:V}),t[52]=V,t[53]=H);let U=m===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:C(f.taskElapsed,{duration:m})})]});t[54]!==z||t[55]!==H||t[56]!==U?(T=(0,$.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[z,B,H,U]}),t[54]=z,t[55]=H,t[56]=U,t[57]=T):T=t[57],E=u&&n.metrics.agentCount>0?(0,$.jsxs)(`span`,{className:`mt-2 block max-w-md`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:C(f.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[N,`%`]})]}),(0,$.jsx)(`span`,{className:`mt-1 block h-1.5 overflow-hidden rounded-full bg-surface-muted`,children:(0,$.jsx)(`span`,{className:`block h-full rounded-full bg-accent transition-[width] duration-200 motion-reduce:transition-none`,style:{width:`${N}%`}})})]}):null,D=n.metrics.errorAgentCount>0?(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(X,{className:`size-3 shrink-0`,"aria-hidden":!0}),C(f.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null,t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=n,t[5]=u,t[6]=d,t[7]=f,t[8]=g,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=w,t[15]=T,t[16]=E,t[17]=D,t[18]=O,t[19]=k,t[20]=A,t[21]=j}else u=t[5],d=t[6],f=t[7],g=t[8],v=t[9],y=t[10],b=t[11],x=t[12],S=t[13],w=t[14],T=t[15],E=t[16],D=t[17],O=t[18],k=t[19],A=t[20],j=t[21];let M;t[58]!==v||t[59]!==w||t[60]!==T||t[61]!==E||t[62]!==D?(M=(0,$.jsxs)(`span`,{className:v,children:[w,T,E,D]}),t[58]=v,t[59]=w,t[60]=T,t[61]=E,t[62]=D,t[63]=M):M=t[63];let N;t[64]!==M||t[65]!==O||t[66]!==k?(N=(0,$.jsxs)(`div`,{className:O,children:[k,M]}),t[64]=M,t[65]=O,t[66]=k,t[67]=N):N=t[67];let P;t[68]!==y||t[69]!==b||t[70]!==N||t[71]!==A||t[72]!==j?(P=(0,$.jsx)(`button`,{type:A,onClick:j,className:y,"aria-label":b,children:N}),t[68]=y,t[69]=b,t[70]=N,t[71]=A,t[72]=j,t[73]=P):P=t[73];let F;t[74]!==f.rerun||t[75]!==l||t[76]!==g||t[77]!==n.id?(F=g?(0,$.jsx)(m,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>l(n.id),children:f.rerun}):null,t[74]=f.rerun,t[75]=l,t[76]=g,t[77]=n.id,t[78]=F):F=t[78];let I;t[79]!==d||t[80]!==f.continueInChat||t[81]!==s||t[82]!==n?(I=n.status===`succeeded`&&d?(0,$.jsx)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>s(n),children:f.continueInChat}):null,t[79]=d,t[80]=f.continueInChat,t[81]=s,t[82]=n,t[83]=I):I=t[83];let L;t[84]!==u||t[85]!==f.cancel||t[86]!==c||t[87]!==n.id?(L=u?(0,$.jsx)(m,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg text-xs text-red-600 dark:text-red-300`,onClick:()=>c(n.id),children:f.cancel}):null,t[84]=u,t[85]=f.cancel,t[86]=c,t[87]=n.id,t[88]=L):L=t[88];let R;t[89]!==o||t[90]!==n?(R=()=>o(n),t[89]=o,t[90]=n,t[91]=R):R=t[91];let z;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[92]=z):z=t[92];let B;t[93]!==f.taskOpenDetails||t[94]!==R?(B=(0,$.jsx)(m,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":f.taskOpenDetails,onClick:R,children:z}),t[93]=f.taskOpenDetails,t[94]=R,t[95]=B):B=t[95];let V;t[96]!==F||t[97]!==I||t[98]!==L||t[99]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1.5 pl-7 lg:pl-0`,children:[F,I,L,B]}),t[96]=F,t[97]=I,t[98]=L,t[99]=B,t[100]=V):V=t[100];let H;t[101]!==x||t[102]!==P||t[103]!==V?(H=(0,$.jsxs)(`div`,{className:x,children:[P,V]}),t[101]=x,t[102]=P,t[103]=V,t[104]=H):H=t[104];let U;return t[105]!==S||t[106]!==H?(U=(0,$.jsx)(`article`,{className:S,children:H}),t[105]=S,t[106]=H,t[107]=U):U=t[107],U});function Jt(e){let t=(0,Q.c)(17),{vm:n}=e,{labels:r,language:i,loading:a,ownerAgentId:o,agentOptions:c,setOwnerAgentId:d,refreshAll:f}=n,p;t[0]!==c||t[1]!==r.agentFilterAria||t[2]!==i||t[3]!==o||t[4]!==d?(p=c.length>1?(0,$.jsx)(l,{value:o??``,"aria-label":r.agentFilterAria,onChange:e=>d(e.target.value),className:`h-9 min-w-32 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:c.map(e=>(0,$.jsx)(u,{value:e.id,children:S(e,_(i).agentsSettings)},e.id))}):null,t[0]=c,t[1]=r.agentFilterAria,t[2]=i,t[3]=o,t[4]=d,t[5]=p):p=t[5];let h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),t[6]=h):h=t[6];let g;t[7]===r.addWorkflow?g=t[8]:(g=(0,$.jsx)(m,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(s,{to:`/workflows/new`,children:[h,r.addWorkflow]})}),t[7]=r.addWorkflow,t[8]=g);let v;t[9]!==r.refresh||t[10]!==a||t[11]!==f?(v=(0,$.jsx)(oe,{className:`size-9 shrink-0 p-0`,loading:a,label:r.refresh,onClick:f}),t[9]=r.refresh,t[10]=a,t[11]=f,t[12]=v):v=t[12];let y;return t[13]!==p||t[14]!==g||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[p,g,v]}),t[13]=p,t[14]=g,t[15]=v,t[16]=y):y=t[16],y}var Yt=new Set([`failed`,`timeout`,`cancelled`]),Xt=[{id:`runs`,icon:we},{id:`library`,icon:E}],Zt={failed:0,timeout:0,cancelled:0,running:1,queued:2,succeeded:3};function Qt(e){return Yt.has(e.status)}function $t(e,t){return t===`all`?!0:t===`attention`?Qt(e):e.status===t}function en(e){return[...e].sort((e,t)=>{let n=(Zt[e.status]??4)-(Zt[t.status]??4);if(n!==0)return n;if(e.status===`queued`&&t.status===`queued`)return e.createdAtMs-t.createdAtMs;let r=e.completedAtMs??e.startedAtMs??e.createdAtMs;return(t.completedAtMs??t.startedAtMs??t.createdAtMs)-r})}function tn(e,t){return e===`Home`?`runs`:e===`End`?`library`:e===`ArrowLeft`||e===`ArrowRight`?t===`runs`?`library`:`runs`:null}function nn(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(K,{className:`h-5 w-16 rounded-full`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle p-4 last:border-b-0`,"aria-hidden":`true`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(K,{className:`h-4 w-52 max-w-full`}),(0,$.jsx)(K,{className:`mt-2 h-3 w-36 max-w-full`})]}),(0,$.jsx)(K,{className:`hidden h-8 w-20 rounded-lg sm:block`})]}),e[1]=n):n=e[1],n}function rn(e){let t=(0,Q.c)(30),{vm:n}=e,{language:r,localeTag:i,labels:a,hasToken:o,definitions:s,runs:c,searchQuery:d,setSearchQuery:f,workflowFilterId:g,setWorkflowFilterId:_,triggerFilter:v,setTriggerFilter:y,statusFilter:b,setStatusFilter:x,clearRunFilters:S,pageTab:C,setPageTab:w,runLayout:T,setRunLayout:E,openRunDetails:D,openRunInChat:O,openDefinitionDetails:k,openWorkflowEditor:A,startWorkflow:j,actionError:M,loading:N,error:P,cancelRun:I,retryRun:L}=n,R=me(cn),z=me(sn),B=Date.now(),V=en(c.filter(Qt)),H;t[0]===b?H=t[1]:(H=e=>$t(e,b),t[0]=b,t[1]=H);let U=en(St(c,{searchQuery:d,workflowFilterId:g,triggerFilter:v}).filter(H)),W=!!(d||g||v!==`all`||b!==`all`),G,K;if(t[2]!==z||t[3]!==o||t[4]!==a.librarySubtitle||t[5]!==a.runsSubtitle||t[6]!==a.title||t[7]!==C||t[8]!==R||t[9]!==n?(G=()=>{if(!o){z();return}return R({startExtra:null,main:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:C===`runs`?a.runsSubtitle:a.librarySubtitle})]}),end:(0,$.jsx)(Jt,{vm:n})}),()=>z()},K=[z,o,a.librarySubtitle,a.runsSubtitle,a.title,C,R,n],t[2]=z,t[3]=o,t[4]=a.librarySubtitle,t[5]=a.runsSubtitle,t[6]=a.title,t[7]=C,t[8]=R,t[9]=n,t[10]=G,t[11]=K):(G=t[10],K=t[11]),(0,Z.useLayoutEffect)(G,K),!o){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(F,{className:`size-10 text-accent-fg`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===a.title?n=t[14]:(n=(0,$.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:a.title}),t[13]=a.title,t[14]=n);let r;t[15]===a.needToken?r=t[16]:(r=(0,$.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.needToken}),t[15]=a.needToken,t[16]=r);let i;return t[17]!==n||t[18]!==r?(i=(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-auto bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center px-3 py-16 text-center sm:px-5 xl:px-6`,children:[e,n,r]})}),t[17]=n,t[18]=r,t[19]=i):i=t[19],i}let ee=a.pageTabsAria,ne=Xt.map(e=>{let{id:t,icon:n}=e;return(0,$.jsxs)(`button`,{id:`workflow-tab-${t}`,type:`button`,role:`tab`,"aria-selected":C===t,"aria-controls":`workflow-panel-${t}`,tabIndex:C===t?0:-1,draggable:!1,className:p(`relative inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`transition-transform duration-150 ease-out active:scale-95 motion-reduce:transition-none motion-reduce:active:scale-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,C===t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>w(t),onKeyDown:e=>{let n=tn(e.key,t);n&&(e.preventDefault(),w(n),window.requestAnimationFrame(()=>{document.getElementById(`workflow-tab-${n}`)?.focus()}))},children:[(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a.pageTabs[t]}),t===`runs`&&V.length>0?(0,$.jsx)(`span`,{className:`rounded-full bg-red-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-red-700 dark:text-red-300`,children:V.length}):null]},t)}),re;t[20]!==a.pageTabsAria||t[21]!==ne?(re=(0,$.jsx)(`nav`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,"aria-label":ee,role:`tablist`,children:ne}),t[20]=a.pageTabsAria,t[21]=ne,t[22]=re):re=t[22];let ie;t[23]!==M||t[24]!==P?(ie=M??P?(0,$.jsx)(`div`,{className:`mt-4 rounded-lg border border-red-500/25 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,role:`alert`,children:M??P}):null,t[23]=M,t[24]=P,t[25]=ie):ie=t[25];let q=C===`runs`?(0,$.jsxs)(`div`,{id:`workflow-panel-runs`,role:`tabpanel`,"aria-labelledby":`workflow-tab-runs`,className:`flex flex-col gap-4 py-4`,children:[V.length>0?(0,$.jsx)(`section`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/8 px-4 py-3`,"aria-labelledby":`workflow-attention-heading`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(X,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h2`,{id:`workflow-attention-heading`,className:`text-sm font-semibold text-fg`,children:a.attentionTitle}),(0,$.jsx)(`span`,{className:`rounded-full bg-amber-500/15 px-2 py-0.5 text-[10px] font-semibold text-amber-800 dark:text-amber-200`,children:V.length})]}),(0,$.jsxs)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:[yt(V[0]),` · `,Dt(V[0].completedAtMs??V[0].createdAtMs,B,i)]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.attentionHint})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pl-7 lg:pl-0`,children:[(0,$.jsx)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>D(V[0]),children:a.attentionView}),(0,$.jsx)(m,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>void L(V[0].id),children:a.rerun})]})]})}):null,(0,$.jsx)(`section`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base p-3`,"aria-label":a.runFiltersAria,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-52 flex-1 sm:max-w-sm`,children:[(0,$.jsx)(te,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:a.runsSearchPlaceholder,className:p(`h-9 w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg shadow-surface`,`placeholder:text-fg-muted`,h.focusRingPanel)})]}),(0,$.jsx)(l,{value:b,"aria-label":a.statusFilterAria,onChange:e=>x(e.target.value),className:`h-9 min-w-32 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[`all`,`attention`,`running`,`queued`,`succeeded`].map(e=>(0,$.jsx)(u,{value:e,children:a.runStatuses[e]},e))}),(0,$.jsxs)(l,{value:v,"aria-label":a.boardTriggerFilterAria,onChange:e=>y(e.target.value),className:`h-9 min-w-[7.5rem] rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[(0,$.jsx)(u,{value:`all`,children:a.boardTriggerFilterAll}),(0,$.jsx)(u,{value:`automation`,children:a.boardTriggerFilterAutomation}),(0,$.jsx)(u,{value:`webui`,children:a.boardTriggerFilterWebui}),(0,$.jsx)(u,{value:`chat`,children:a.boardTriggerFilterChat}),(0,$.jsx)(u,{value:`api`,children:a.boardTriggerFilterApi})]}),(0,$.jsxs)(l,{value:g,"aria-label":a.boardWorkflowFilterAria,onChange:e=>_(e.target.value),className:`h-9 min-w-40 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[(0,$.jsx)(u,{value:``,children:a.boardWorkflowFilterAll}),s.map(on)]}),W?(0,$.jsxs)(m,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:S,children:[(0,$.jsx)(Y,{className:`size-3.5`,"aria-hidden":!0}),a.clearFilters]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":a.layoutAria,children:[(0,$.jsxs)(`button`,{type:`button`,className:p(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,T===`list`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,h.focusRingPanel),"aria-pressed":T===`list`,onClick:()=>E(`list`),children:[(0,$.jsx)(ze,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.list]}),(0,$.jsxs)(`button`,{type:`button`,className:p(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,T===`board`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,h.focusRingPanel),"aria-pressed":T===`board`,onClick:()=>E(`board`),children:[(0,$.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.board]})]})]})}),T===`list`?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,"aria-labelledby":`workflow-runs-heading`,children:[(0,$.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{id:`workflow-runs-heading`,className:`text-sm font-semibold text-fg`,children:a.allRuns}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.allRunsHint})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-semibold tabular-nums text-fg-muted`,children:U.length})]}),N&&U.length===0?Array.from({length:4}).map(an):U.length>0?U.map(e=>(0,$.jsx)(qt,{run:e,language:r,localeTag:i,nowMs:B,onOpen:D,onOpenChat:O,onCancel:e=>void I(e),onRetry:e=>void L(e)},e.id)):(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-4 py-12 text-center`,children:[(0,$.jsx)(F,{className:`size-8 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`mt-3 text-sm font-semibold text-fg`,children:W?a.noRunResultsTitle:a.noRunsTitle}),(0,$.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-5 text-fg-muted`,children:W?a.noRunResultsHint:a.noRunsStartHint}),(0,$.jsx)(m,{type:`button`,variant:W?`secondary`:`primary`,className:`mt-4 h-9 rounded-lg text-xs`,onClick:W?S:()=>w(`library`),children:W?a.clearFilters:a.chooseWorkflow})]})]}):(0,$.jsx)(`div`,{className:`h-[min(72vh,48rem)] min-h-[24rem] w-full sm:min-h-[28rem]`,children:(0,$.jsx)(Lt,{runs:U,language:r,localeTag:i,labels:{boardEmptyTitle:a.boardEmptyTitle,boardEmptyHint:a.boardEmptyHint,boardStart:a.chooseWorkflow,loading:a.loading},searchQuery:``,workflowFilterId:``,triggerFilter:`all`,selectedRunId:null,loading:N,onOpenRun:D,onOpenRunChat:O,onCancelRun:e=>void I(e),onRetryRun:e=>void L(e),onStart:()=>w(`library`)})})]}):(0,$.jsxs)(`section`,{id:`workflow-panel-library`,role:`tabpanel`,"aria-labelledby":`workflow-tab-library`,className:`py-5`,children:[(0,$.jsxs)(`div`,{className:`mb-5`,children:[(0,$.jsx)(`h2`,{id:`workflow-library-heading`,className:`text-base font-semibold text-fg`,children:a.libraryTitle}),(0,$.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:a.libraryDescription})]}),(0,$.jsx)(Ut,{definitions:s,runs:c,language:r,onPick:j,onDetail:k,onEdit:A})]}),ae;return t[26]!==ie||t[27]!==q||t[28]!==re?(ae=(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[96rem] flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[re,ie,q]})}),t[26]=ie,t[27]=q,t[28]=re,t[29]=ae):ae=t[29],ae}function an(e,t){return(0,$.jsx)(nn,{},t)}function on(e){return(0,$.jsx)(u,{value:e.id,children:e.title},e.id)}function sn(e){return e.clearPageHeader}function cn(e){return e.setPageHeader}function ln(){let e=(0,Q.c)(114),t=y(mn),n;e[0]===t?n=e[1]:(n=_(t),e[0]=t,e[1]=n);let r=n.workflows,i=t===`zh`?`zh-CN`:`en-US`,s=v(pn),c=!!s,l=o(),[u,d]=a(),f;e[2]===u?f=e[3]:(f=u.get(`q`)??``,e[2]=u,e[3]=f);let p=f,m;e[4]===u?m=e[5]:(m=u.get(`wf`)?.trim()??``,e[4]=u,e[5]=m);let h=m,g;e[6]===u?g=e[7]:(g=u.get(`trigger`)?.trim()||`all`,e[6]=u,e[7]=g);let x=g,S,C,w,E;if(e[8]!==u){let t=u.get(`status`)?.trim()??``,n=u.get(`tab`)?.trim()??``,r=u.get(`layout`)?.trim()??``;S=u.get(`agent`)?.trim()??``,C=pe.has(n)?n:`runs`,w=fe.has(r)?r:`list`,E=B.has(t)?t:`all`,e[8]=u,e[9]=S,e[10]=C,e[11]=w,e[12]=E}else S=e[9],C=e[10],w=e[11],E=e[12];let D=E,[O,k]=(0,Z.useState)(null),A;e[13]!==c||e[14]!==s?(A=c?[`workflow-agents`,s]:null,e[13]=c,e[14]=s,e[15]=A):A=e[15];let j;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},e[16]=j):j=e[16];let M=b(A,U,j),F;bb0:{let e=M.data?.agents??[];if(S&&(e.length===0||e.some(e=>e.id===S))){F=S;break bb0}F=M.data?.defaultId}let L=F,R;e[17]!==c||e[18]!==s?(R=c?[`workflow-definitions`,s]:null,e[17]=c,e[18]=s,e[19]=R):R=e[19];let z;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(z={revalidateOnFocus:!1},e[20]=z):z=e[20];let V=b(R,Je,z),H;e[21]!==c||e[22]!==L||e[23]!==s?(H=c&&L?[`workflow-runs`,s,L]:null,e[21]=c,e[22]=L,e[23]=s,e[24]=H):H=e[24];let W;e[25]===L?W=e[26]:(W=()=>Ce(100,{ownerAgentId:L}),e[25]=L,e[26]=W);let G;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(G={revalidateOnFocus:!1,refreshInterval:dn},e[27]=G):G=e[27];let K=b(H,W,G),ee;e[28]===V.data?ee=e[29]:(ee=V.data??[],e[28]=V.data,e[29]=ee);let te=ee,ne;e[30]===K.data?ne=e[31]:(ne=K.data??[],e[30]=K.data,e[31]=ne);let re=ne,ie;e[32]===d?ie=e[33]:(ie=e=>{d(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},e[32]=d,e[33]=ie);let q=ie,ae;e[34]===q?ae=e[35]:(ae=e=>q(t=>{let n=e.trim();n?t.set(`q`,n):t.delete(`q`)}),e[34]=q,e[35]=ae);let J=ae,oe;e[36]===q?oe=e[37]:(oe=e=>q(t=>{let n=e.trim();n?t.set(se,n):t.delete(se)}),e[36]=q,e[37]=oe);let ce=oe,le;e[38]===q?le=e[39]:(le=e=>q(t=>{let n=e.trim();n?t.set(`wf`,n):t.delete(`wf`)}),e[38]=q,e[39]=le);let ue=le,de;e[40]===q?de=e[41]:(de=e=>q(t=>{e&&e!==`all`?t.set(Ge,e):t.delete(Ge)}),e[40]=q,e[41]=de);let me=de,he;e[42]===q?he=e[43]:(he=e=>q(t=>{e===`runs`?t.delete(`tab`):t.set(`tab`,e)}),e[42]=q,e[43]=he);let ge=he,_e;e[44]===q?_e=e[45]:(_e=e=>q(t=>{e===`list`?t.delete(I):t.set(I,e)}),e[44]=q,e[45]=_e);let Y=_e,ve;e[46]===q?ve=e[47]:(ve=e=>q(t=>{e===`all`?t.delete(P):t.set(P,e)}),e[46]=q,e[47]=ve);let ye=ve,be;e[48]===q?be=e[49]:(be=()=>q(un),e[48]=q,e[49]=be);let xe=be,Se=L?`?agentId=${encodeURIComponent(L)}`:``,we;e[50]!==l||e[51]!==Se?(we=e=>l(`/workflows/${e.id}${Se}`),e[50]=l,e[51]=Se,e[52]=we):we=e[52];let Te=we,Ee=Te,X;e[53]!==l||e[54]!==L||e[55]!==Se?(X=e=>{l(e.metadata.source===`user`?`/workflows/${e.id}/edit${Se}`:`/workflows/new?copy=${encodeURIComponent(e.id)}${L?`&agentId=${encodeURIComponent(L)}`:``}`)},e[53]=l,e[54]=L,e[55]=Se,e[56]=X):X=e[56];let De=X,Oe;e[57]!==l||e[58]!==Se?(Oe=e=>l(`/workflows/runs/${e.id}${Se}`),e[57]=l,e[58]=Se,e[59]=Oe):Oe=e[59];let Ae=Oe,je;e[60]===l?je=e[61]:(je=e=>{let t=ht(e);t&&l(N(t))},e[60]=l,e[61]=je);let Me=je,Ne;e[62]!==r.cancelFailed||e[63]!==L||e[64]!==K?(Ne=async e=>{try{await ke(e,{ownerAgentId:L}),await K.mutate()}catch(e){let t=e;k(t instanceof Error?t.message:r.cancelFailed)}},e[62]=r.cancelFailed,e[63]=L,e[64]=K,e[65]=Ne):Ne=e[65];let Pe=Ne,Fe;e[66]!==r.retryFailed||e[67]!==l||e[68]!==L||e[69]!==Se?(Fe=async e=>{try{l(`/workflows/runs/${(await T(e,{ownerAgentId:L})).runId}${Se}`)}catch(e){let t=e;k(t instanceof Error?t.message:r.retryFailed)}},e[66]=r.retryFailed,e[67]=l,e[68]=L,e[69]=Se,e[70]=Fe):Fe=e[70];let Ie=Fe,Le,Re;e[71]===K?(Le=e[72],Re=e[73]):(Le=()=>{let e=()=>void K.mutate();return window.addEventListener(`workflow-run-updated`,e),window.addEventListener(`workflow-run-error`,e),()=>{window.removeEventListener(`workflow-run-updated`,e),window.removeEventListener(`workflow-run-error`,e)}},Re=[K],e[71]=K,e[72]=Le,e[73]=Re),(0,Z.useEffect)(Le,Re);let ze;e[74]!==M||e[75]!==V||e[76]!==K?(ze=()=>{Promise.all([M.mutate(),V.mutate(),K.mutate()])},e[74]=M,e[75]=V,e[76]=K,e[77]=ze):ze=e[77];let Be=ze,Ve=M.isLoading||V.isLoading||K.isLoading,He=M.error?.message??V.error?.message??K.error?.message??null,Ue;e[78]===M.data?.agents?Ue=e[79]:(Ue=M.data?.agents??[],e[78]=M.data?.agents,e[79]=Ue);let We;return e[80]!==O||e[81]!==Pe||e[82]!==xe||e[83]!==te||e[84]!==He||e[85]!==c||e[86]!==r||e[87]!==t||e[88]!==Ve||e[89]!==i||e[90]!==Te||e[91]!==Ae||e[92]!==Me||e[93]!==De||e[94]!==L||e[95]!==C||e[96]!==Be||e[97]!==Ie||e[98]!==w||e[99]!==re||e[100]!==p||e[101]!==ce||e[102]!==ge||e[103]!==Y||e[104]!==J||e[105]!==ye||e[106]!==me||e[107]!==ue||e[108]!==Ee||e[109]!==D||e[110]!==Ue||e[111]!==x||e[112]!==h?(We={language:t,localeTag:i,labels:r,hasToken:c,searchQuery:p,setSearchQuery:J,ownerAgentId:L,agentOptions:Ue,setOwnerAgentId:ce,workflowFilterId:h,setWorkflowFilterId:ue,triggerFilter:x,setTriggerFilter:me,statusFilter:D,setStatusFilter:ye,clearRunFilters:xe,pageTab:C,setPageTab:ge,runLayout:w,setRunLayout:Y,definitions:te,runs:re,openDefinitionDetails:Te,startWorkflow:Ee,openWorkflowEditor:De,openRunDetails:Ae,openRunInChat:Me,actionError:O,loading:Ve,error:He,refreshAll:Be,cancelRun:Pe,retryRun:Ie},e[80]=O,e[81]=Pe,e[82]=xe,e[83]=te,e[84]=He,e[85]=c,e[86]=r,e[87]=t,e[88]=Ve,e[89]=i,e[90]=Te,e[91]=Ae,e[92]=Me,e[93]=De,e[94]=L,e[95]=C,e[96]=Be,e[97]=Ie,e[98]=w,e[99]=re,e[100]=p,e[101]=ce,e[102]=ge,e[103]=Y,e[104]=J,e[105]=ye,e[106]=me,e[107]=ue,e[108]=Ee,e[109]=D,e[110]=Ue,e[111]=x,e[112]=h,e[113]=We):We=e[113],We}function un(e){e.delete(`q`),e.delete(`wf`),e.delete(Ge),e.delete(P)}function dn(e){return e?.some(fn)?3e3:0}function fn(e){return e.status===`queued`||e.status===`running`}function pn(e){return e.token}function mn(e){return e.language}function hn(){let e=(0,Q.c)(2),t=ln(),n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(rn,{vm:t}),e[0]=t,e[1]=n),n}function gn(e){return{title:e.title,description:e.description,version:e.version,inputSchema:e.inputSchema,outputSchema:e.outputSchema,defaults:e.defaults,tags:e.metadata.tags,whenToUse:e.metadata.whenToUse,estimatedAgents:e.metadata.estimatedAgents,permissions:e.permissions,resources:e.resources}}function _n(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;t<1e3;t+=1){let r=`${e}_${t}`;if(!n.has(r))return r}return`${e}_${Date.now()}`}function vn(e){if(!(e instanceof Error))return null;let t=e;if(t.status!==409||!t.body||typeof t.body!=`object`)return null;let n=t.body,r=typeof n.currentRevision==`number`?n.currentRevision:0;return n.code===`WORKFLOW_NAME_EXISTS`&&typeof n.name==`string`&&typeof n.suggestedName==`string`?{code:`WORKFLOW_NAME_EXISTS`,name:n.name,currentRevision:r,suggestedName:n.suggestedName}:n.code===`WORKFLOW_REVISION_CONFLICT`?{code:`WORKFLOW_REVISION_CONFLICT`,currentRevision:r}:null}var yn={padding:.24,minZoom:.45,maxZoom:1};function bn({language:e,ownerAgentId:t,saving:n,initialDraft:r,initialName:i,existingNames:a,saveConflict:o,onSave:c,onSaveAndStart:l,onClearSaveConflict:u,onReloadLatest:d}){let f=zn(e),[g,_]=(0,Z.useState)(`my_workflow`),[v,y]=(0,Z.useState)(()=>Mn()),[b,x]=(0,Z.useState)(()=>({title:f.untitled,description:``,tags:[`custom`]})),[S,C]=(0,Z.useState)(`agent-1`),[w,T,E]=dt(v.nodes.map(e=>An(e,e.id===`agent-1`))),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(!1),[I,R]=(0,Z.useState)(null),[B,U]=(0,Z.useState)(null),[W,G]=(0,Z.useState)(!!r),[K,ee]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(`idle`),[re,ie]=(0,Z.useState)(0),[ae,J]=(0,Z.useState)([]),[oe,se]=(0,Z.useState)(null),ue=(0,Z.useRef)(``),de=(0,Z.useRef)(``),fe=(0,Z.useRef)(void 0),pe=(0,Z.useRef)(void 0),me=(0,Z.useRef)(!1),he=(0,Z.useRef)(null),[ge,_e]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=`${r?.mode??`new`}:${r?.name??i}:${r?.baseRevision??0}:${r?.repairPrompt??``}`;ue.current!==e&&(ue.current=e,_(r?.name??i),y(structuredClone(r?.graph??Mn())),_e(e=>e+1),x(structuredClone(r?.manifest??{title:f.untitled,description:``,tags:[`custom`]})),C(r?.graph.nodes.find(e=>e.kind===`agent`)?.id??`agent-1`),A(r?.repairPrompt??``),R(null),U(null),G(!!r),M(``),ee(null),ie(r?.baseRevision??0),J([]),se(null),fe.current=void 0,pe.current=void 0,ne(`idle`))},[f.untitled,r,i]),(0,Z.useEffect)(()=>{r?.mode===`edit`&&$e(r.name).then(J).catch(()=>J([]))},[r?.mode,r?.name]),(0,Z.useEffect)(()=>{if(!g.trim())return;let e=window.setTimeout(()=>{D(g,v).then(ee).catch(()=>ee(null))},350);return()=>window.clearTimeout(e)},[v,g]),(0,Z.useEffect)(()=>{if(!g.trim())return;ne(`saving`);let e=window.setTimeout(()=>{Ye({id:fe.current,workflowName:g,graph:v,manifest:b,baseRevision:re,expectedUpdatedAtMs:pe.current}).then(e=>{fe.current=e.id,pe.current=e.updatedAtMs,ne(`saved`)}).catch(()=>ne(`error`))},900);return()=>window.clearTimeout(e)},[re,v,b,g]);let Y=(0,Z.useMemo)(()=>Pn(v,I?.graph??null),[v,I?.graph]),ve=(0,Z.useMemo)(()=>{if(!I)return v;let e=new Set(I.graph.nodes.map(e=>e.id)),t=v.nodes.filter(t=>!e.has(t.id));return{...I.graph,nodes:[...I.graph.nodes,...t]}},[v,I]);(0,Z.useLayoutEffect)(()=>{T(e=>{let t=new Map(e.map(e=>[e.id,e]));return ve.nodes.map(e=>({...t.get(e.id),...An(e,e.id===S,Y.nodeStates.get(e.id))}))})},[ve.nodes,Y.nodeStates,S,T]),(0,Z.useEffect)(()=>{let e=he.current;if(!e||ve.nodes.length===0)return;let t=window.requestAnimationFrame(()=>{e.fitView(yn)});return()=>window.cancelAnimationFrame(t)},[ve.nodes.length,ge]);let be=(0,Z.useMemo)(()=>ve.edges.map(jn),[ve.edges]),xe=v.nodes.find(e=>e.id===S)??null,Se=(0,Z.useMemo)(()=>new Set(a),[a]),Ce=r?.mode!==`edit`&&Se.has(g),we=Ce?_n(g,Se):g,Te=K?.valid===!0&&!Ce&&!n&&!N,Ee=(0,Z.useCallback)(e=>{y(t=>{let n=t.nodes.map(t=>t.id!==e.id||t.position.x===e.position.x&&t.position.y===e.position.y?t:{...t,position:e.position});return n.some((e,n)=>e!==t.nodes[n])?{...t,nodes:n}:t})},[]),X=(0,Z.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&y(e=>({...e,edges:it(t,e.edges.map(jn)).map(e=>({id:e.id,source:e.source,target:e.target,sourcePort:e.sourceHandle===`true`||e.sourceHandle===`false`?e.sourceHandle:void 0}))}))},[]),De=(0,Z.useCallback)(e=>{!e.source||!e.target||y(t=>({...t,edges:ot({...e,id:`edge-${crypto.randomUUID()}`},t.edges.map(jn)).map(e=>({id:e.id,source:e.source,target:e.target,sourcePort:e.sourceHandle===`true`||e.sourceHandle===`false`?e.sourceHandle:void 0}))}))},[]),Oe=(0,Z.useCallback)((e,t)=>{y(n=>({...n,nodes:n.nodes.map(n=>n.id===e?t(n):n)}))},[]),ke=e=>{let t=`${e}-${crypto.randomUUID().slice(0,8)}`,n=Nn(e,t,v.nodes.length);y(e=>{let r=e.nodes.find(e=>e.id===S&&e.kind!==`output`),i=r?[{id:`edge-${crypto.randomUUID()}`,source:r.id,target:t}]:[];return{...e,nodes:[...e.nodes,n],edges:[...e.edges,...i]}}),_e(e=>e+1),C(t)},Ae=()=>{!xe||xe.kind===`input`||xe.kind===`output`||(y(e=>({...e,nodes:e.nodes.filter(e=>e.id!==xe.id),edges:e.edges.filter(e=>e.source!==xe.id&&e.target!==xe.id)})),_e(e=>e+1),C(``))},je=(0,Z.useCallback)(async()=>{if(k.trim()){P(!0);try{let n=await Ue({prompt:k,agentId:t,language:e===`zh`?`zh`:`en`,mode:r||v.nodes.length>3?`improve`:`create`,existingGraph:v}),i=r?.mode===`edit`?r.name:_n(n.name,Se);U(i===n.name?null:n.name),R(i===n.name?n:{...n,name:i}),G(!0),_e(e=>e+1),C(n.graph.nodes.find(e=>e.kind===`agent`)?.id??``)}finally{P(!1)}}},[k,Se,v,r,e,t]);(0,Z.useEffect)(()=>{let e=r?.repairPrompt?.trim();!e||k.trim()!==e||N||I||de.current===e||(de.current=e,je())},[k,je,N,r?.repairPrompt,I]);let Me=()=>{R(null),U(null),C(v.nodes.find(e=>e.kind===`agent`)?.id??``),_e(e=>e+1)},Ne=async()=>{if(!(!I||n||me.current)){me.current=!0;try{let e=await c({name:I.name,graph:I.graph,manifest:I.manifest,expectedRevision:re});if(!e)return;_(e.name),y(structuredClone(e.graph)),x(gn(e)),ee(I.validation),ie(e.revision),R(null),U(null),A(``),C(e.graph.nodes.find(e=>e.kind===`agent`)?.id??``),fe.current&&await Re(fe.current).catch(()=>void 0)}catch{}finally{me.current=!1}}},Pe=async e=>{if(!Te||me.current)return;me.current=!0;let t={name:g,graph:v,manifest:b,expectedRevision:re};try{if(e)await l({...t,goal:j.trim()||b.description||g});else{let e=await c(t);if(!e)return;ie(e.revision)}fe.current&&await Re(fe.current).catch(()=>void 0)}catch{return}finally{me.current=!1}},Fe=async e=>{if(!(oe!==null||r?.mode!==`edit`)){se(e);try{let t=await ce(r.name,e,re);y(t.graph),_e(e=>e+1),x(gn(t)),ie(t.revision),C(t.graph.nodes.find(e=>e.kind===`agent`)?.id??``),J(await $e(r.name))}finally{se(null)}}};return(0,$.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(s,{to:`/workflows`,className:p(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,h.focusRingPanel),"aria-label":e===`zh`?`返回工作流`:`Back to workflows`,children:(0,$.jsx)(We,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:r?.mode===`edit`?f.editTitle:f.createTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.subtitle})]}),(0,$.jsx)(`span`,{className:p(`text-xs`,te===`error`?`text-danger`:`text-fg-subtle`),children:te===`saving`?f.savingDraft:te===`saved`?f.savedDraft:te===`error`?f.draftError:``})]}),o?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/30 bg-warning/5 px-4 py-2 text-sm text-fg`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:o.code===`WORKFLOW_NAME_EXISTS`?e===`zh`?`内部名称“${o.name}”已被使用。`:`The internal name “${o.name}” is already in use.`:e===`zh`?`这个工作流已更新到版本 ${o.currentRevision}。`:`This workflow has changed to revision ${o.currentRevision}.`}),o.code===`WORKFLOW_NAME_EXISTS`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{variant:`secondary`,className:`h-8`,onClick:()=>{_(o.suggestedName),u()},children:e===`zh`?`使用 ${o.suggestedName}`:`Use ${o.suggestedName}`}),(0,$.jsx)(s,{className:`text-sm font-medium text-accent-fg hover:underline`,to:`/workflows/${encodeURIComponent(o.name)}`,children:e===`zh`?`打开已有工作流`:`Open existing`})]}):(0,$.jsx)(m,{variant:`secondary`,className:`h-8`,onClick:d,children:e===`zh`?`加载最新版本`:`Load latest`})]}):null,!o&&Ce?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/30 bg-warning/5 px-4 py-2 text-sm text-fg`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e===`zh`?`内部名称“${g}”已被使用。`:`The internal name “${g}” is already in use.`}),(0,$.jsx)(m,{variant:`secondary`,className:`h-8`,onClick:()=>_(we),children:e===`zh`?`使用 ${we}`:`Use ${we}`})]}):null,!o&&!Ce&&B&&I?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-accent/20 bg-accent/5 px-4 py-2 text-sm text-fg-muted`,children:e===`zh`?`“${B}”已存在,方案将保存为“${I.name}”。`:`“${B}” already exists. This proposal will be saved as “${I.name}”.`}):null,W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,$.jsxs)(`section`,{className:`flex min-h-[32rem] min-w-0 flex-1 flex-col bg-surface-base lg:min-h-0`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mr-2 min-w-36`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:f.flowTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:f.stepCount(v.nodes.length)})]}),(0,$.jsxs)(m,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!I,onClick:()=>ke(`agent`),children:[(0,$.jsx)(H,{className:`size-3.5`}),f.addAgent]}),(0,$.jsxs)(m,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!I,onClick:()=>ke(`decision`),children:[(0,$.jsx)(F,{className:`size-3.5`}),f.addDecision]}),(0,$.jsxs)(m,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!I,onClick:()=>ke(`merge`),children:[(0,$.jsx)(O,{className:`size-3.5`}),f.addMerge]}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-subtle`,children:f.canvasHint})]}),(0,$.jsx)(`div`,{className:`relative min-h-72 flex-1`,children:v.nodes.length>0?(0,$.jsxs)(lt,{"aria-label":f.flowAria,nodes:w,edges:be,nodeTypes:Dn,onNodesChange:E,onEdgesChange:X,onConnect:De,nodesDraggable:!I,nodesConnectable:!I,onNodeClick:(e,t)=>C(t.id),onNodeDragStart:(e,t)=>C(t.id),onNodeDragStop:(e,t)=>Ee(t),onInit:e=>{he.current=e,window.requestAnimationFrame(()=>{e.fitView(yn)})},fitView:!0,fitViewOptions:yn,minZoom:.25,maxZoom:1.5,deleteKeyCode:null,proOptions:{hideAttribution:!0},children:[(0,$.jsx)(ft,{color:`var(--color-edge)`,gap:22,size:1}),(0,$.jsx)(ct,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-fg-muted`,children:f.emptyFlow})})]}),(0,$.jsx)(`aside`,{className:`flex w-full shrink-0 flex-col border-t border-edge bg-surface-panel lg:w-[22rem] lg:border-l lg:border-t-0`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:I?(0,$.jsx)(Sn,{proposal:I,diff:Y,copy:f,saving:n,onAccept:()=>void Ne(),onReject:Me}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`label`,{className:`block text-xs font-medium text-fg`,htmlFor:`workflow-title`,children:f.humanTitle}),(0,$.jsx)(`input`,{id:`workflow-title`,value:b.title??``,onChange:e=>x(t=>({...t,title:e.target.value})),className:kn}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-description`,children:f.task}),(0,$.jsx)(`textarea`,{id:`workflow-description`,value:b.description??``,onChange:e=>x(t=>({...t,description:e.target.value})),className:`${kn} min-h-20 resize-y`}),(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:f.advanced}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-name`,children:f.workflowName}),(0,$.jsx)(`input`,{id:`workflow-name`,value:g,onChange:e=>_(Ln(e.target.value)),className:kn}),Ce?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e===`zh`?`该内部名称已被使用,请换一个名称。`:`This internal name is already in use.`}):null,r?.mode===`edit`&&ae.length>0?(0,$.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(L,{className:`size-3.5`}),f.versions,` · v`,re]}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:ae.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg px-2 py-1.5 hover:bg-surface-hover`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 text-xs text-fg-muted`,children:[`v`,t.revision,` · `,ye(t.createdAtMs,e)]}),t.revision===re?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f.currentVersion}):(0,$.jsxs)(m,{variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:oe!==null,onClick:()=>void Fe(t.revision),children:[(0,$.jsx)(z,{className:`size-3`}),oe===t.revision?f.restoring:f.restore]})]},t.revision))})]}):null]})]}),(0,$.jsx)(`div`,{className:`my-4 border-t border-edge`}),xe?(0,$.jsx)(On,{node:xe,copy:f,updateNode:Oe,onDelete:Ae}):(0,$.jsx)(`div`,{className:`py-8 text-center text-sm text-fg-muted`,children:f.selectNode}),K&&!K.valid?(0,$.jsxs)(`section`,{className:`mt-4 rounded-lg border border-danger/30 bg-danger/5 p-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-danger`,children:f.needsAttention}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-danger`,children:K.errors.slice(0,5).map((e,t)=>(0,$.jsxs)(`li`,{children:[`• `,e.message]},`${e.code}-${t}`))})]}):null]})})})]}),(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-edge bg-surface-panel p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(le,{className:`size-4 shrink-0 text-accent-fg`}),(0,$.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&je()},placeholder:f.aiPlaceholder,className:`${kn} mt-0 flex-1`}),(0,$.jsx)(m,{variant:`secondary`,className:`h-10 shrink-0`,disabled:!!I||N||!k.trim(),onClick:()=>void je(),children:N?f.designing:f.applyWithAi})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),placeholder:f.testGoal,className:`${kn} mt-0 w-52`}),(0,$.jsxs)(m,{variant:`secondary`,disabled:!Te,onClick:()=>void Pe(!1),children:[(0,$.jsx)(q,{className:`size-4`}),f.publish]}),(0,$.jsxs)(m,{variant:`primary`,disabled:!Te,onClick:()=>void Pe(!0),children:[(0,$.jsx)(V,{className:`size-4`}),f.publishAndRun]})]})]})})]}):(0,$.jsx)(xn,{copy:f,prompt:k,generating:N,onPromptChange:A,onGenerate:()=>void je(),onManual:()=>G(!0)})]})}function xn(e){let t=(0,Q.c)(38),{copy:n,prompt:r,generating:i,onPromptChange:a,onGenerate:o,onManual:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-2xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(le,{className:`size-5`})}),t[0]=c):c=t[0];let l;t[1]===n.introTitle?l=t[2]:(l=(0,$.jsx)(`h2`,{className:`mt-5 text-2xl font-semibold text-fg`,children:n.introTitle}),t[1]=n.introTitle,t[2]=l);let u;t[3]===n.introDescription?u=t[4]:(u=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.introDescription}),t[3]=n.introDescription,t[4]=u);let d;t[5]===a?d=t[6]:(d=e=>a(e.target.value),t[5]=a,t[6]=d);let f;t[7]!==n.introPlaceholder||t[8]!==r||t[9]!==d?(f=(0,$.jsx)(`textarea`,{value:r,onChange:d,placeholder:n.introPlaceholder,className:`${kn} mt-6 h-auto min-h-32 resize-y py-3 text-base leading-6`}),t[7]=n.introPlaceholder,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p;if(t[11]!==n.examples||t[12]!==a){let e;t[14]===a?e=t[15]:(e=e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-full border border-edge bg-surface-panel px-3 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>a(e),children:e},e),t[14]=a,t[15]=e),p=n.examples.map(e),t[11]=n.examples,t[12]=a,t[13]=p}else p=t[13];let h;t[16]===p?h=t[17]:(h=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:p}),t[16]=p,t[17]=h);let g;t[18]!==i||t[19]!==r?(g=!r.trim()||i,t[18]=i,t[19]=r,t[20]=g):g=t[20];let _;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(le,{className:`size-4`}),t[21]=_):_=t[21];let v=i?n.designing:n.designWorkflow,y;t[22]!==o||t[23]!==v||t[24]!==g?(y=(0,$.jsxs)(m,{variant:`primary`,disabled:g,onClick:o,children:[_,v]}),t[22]=o,t[23]=v,t[24]=g,t[25]=y):y=t[25];let b;t[26]!==n.manualStart||t[27]!==s?(b=(0,$.jsx)(m,{variant:`ghost`,onClick:s,children:n.manualStart}),t[26]=n.manualStart,t[27]=s,t[28]=b):b=t[28];let x;t[29]!==y||t[30]!==b?(x=(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;return t[32]!==x||t[33]!==l||t[34]!==u||t[35]!==f||t[36]!==h?(S=(0,$.jsx)(`section`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto bg-surface-base px-5 py-10`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[c,l,u,f,h,x]})}),t[32]=x,t[33]=l,t[34]=u,t[35]=f,t[36]=h,t[37]=S):S=t[37],S}function Sn(e){let t=(0,Q.c)(74),{proposal:n,diff:r,copy:i,saving:a,onAccept:o,onReject:s}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(le,{className:`size-4`})}),t[0]=l):l=t[0];let u;t[1]===i.proposalTitle?u=t[2]:(u=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i.proposalTitle}),t[1]=i.proposalTitle,t[2]=u);let d;t[3]===i.proposalHint?d=t[4]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.proposalHint}),t[3]=i.proposalHint,t[4]=d);let f;t[5]!==u||t[6]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[l,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[u,d]})]}),t[5]=u,t[6]=d,t[7]=f):f=t[7];let p=n.manifest.title||n.name,h;t[8]===p?h=t[9]:(h=(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:p}),t[8]=p,t[9]=h);let g=n.explanation||n.manifest.description,_;t[10]===g?_=t[11]:(_=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:g}),t[10]=g,t[11]=_);let v;t[12]===i.added?v=t[13]:(v=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.added}),t[12]=i.added,t[13]=v);let y;t[14]===r.addedIds.length?y=t[15]:(y=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-success`,children:r.addedIds.length}),t[14]=r.addedIds.length,t[15]=y);let b;t[16]!==y||t[17]!==v?(b=(0,$.jsxs)(`div`,{className:`rounded-lg bg-success-soft p-2`,children:[v,y]}),t[16]=y,t[17]=v,t[18]=b):b=t[18];let x;t[19]===i.changed?x=t[20]:(x=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.changed}),t[19]=i.changed,t[20]=x);let S=r.changedIds.length+r.connectionChanges,C;t[21]===S?C=t[22]:(C=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-accent-fg`,children:S}),t[21]=S,t[22]=C);let w;t[23]!==x||t[24]!==C?(w=(0,$.jsxs)(`div`,{className:`rounded-lg bg-accent-soft p-2`,children:[x,C]}),t[23]=x,t[24]=C,t[25]=w):w=t[25];let T;t[26]===i.removed?T=t[27]:(T=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.removed}),t[26]=i.removed,t[27]=T);let E;t[28]===r.removedIds.length?E=t[29]:(E=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-danger`,children:r.removedIds.length}),t[28]=r.removedIds.length,t[29]=E);let D;t[30]!==T||t[31]!==E?(D=(0,$.jsxs)(`div`,{className:`rounded-lg bg-danger/5 p-2`,children:[T,E]}),t[30]=T,t[31]=E,t[32]=D):D=t[32];let O;t[33]!==b||t[34]!==w||t[35]!==D?(O=(0,$.jsxs)(`dl`,{className:`mt-3 grid grid-cols-3 gap-2 text-center text-xs`,children:[b,w,D]}),t[33]=b,t[34]=w,t[35]=D,t[36]=O):O=t[36];let k;t[37]!==O||t[38]!==h||t[39]!==_?(k=(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base/50 p-3`,children:[h,_,O]}),t[37]=O,t[38]=h,t[39]=_,t[40]=k):k=t[40];let A;t[41]!==i.assumptions||t[42]!==n.assumptions?(A=n.assumptions.length?(0,$.jsx)(wn,{title:i.assumptions,items:n.assumptions}):null,t[41]=i.assumptions,t[42]=n.assumptions,t[43]=A):A=t[43];let j;t[44]!==i.risks||t[45]!==n.risks?(j=n.risks.length?(0,$.jsx)(wn,{title:i.risks,items:n.risks}):null,t[44]=i.risks,t[45]=n.risks,t[46]=j):j=t[46];let M;t[47]!==i.permissions||t[48]!==n.permissionsSummary?(M=n.permissionsSummary.length?(0,$.jsx)(wn,{title:i.permissions,items:n.permissionsSummary}):null,t[47]=i.permissions,t[48]=n.permissionsSummary,t[49]=M):M=t[49];let N;t[50]!==n.validation.errors||t[51]!==n.validation.valid?(N=n.validation.valid?null:(0,$.jsx)(`div`,{className:`mt-4 rounded-xl border border-danger/30 bg-danger/5 p-3 text-xs text-danger`,children:n.validation.errors.slice(0,4).map(Cn)}),t[50]=n.validation.errors,t[51]=n.validation.valid,t[52]=N):N=t[52];let P=a||!n.validation.valid,F;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(c,{className:`size-4`}),t[53]=F):F=t[53];let I=a?i.savingProposal:i.acceptAndSave,L;t[54]!==o||t[55]!==P||t[56]!==I?(L=(0,$.jsxs)(m,{variant:`primary`,disabled:P,onClick:o,children:[F,I]}),t[54]=o,t[55]=P,t[56]=I,t[57]=L):L=t[57];let R;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Y,{className:`size-4`}),t[58]=R):R=t[58];let z;t[59]!==i.rejectProposal||t[60]!==s||t[61]!==a?(z=(0,$.jsxs)(m,{variant:`ghost`,disabled:a,onClick:s,children:[R,i.rejectProposal]}),t[59]=i.rejectProposal,t[60]=s,t[61]=a,t[62]=z):z=t[62];let B;t[63]!==L||t[64]!==z?(B=(0,$.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[L,z]}),t[63]=L,t[64]=z,t[65]=B):B=t[65];let V;return t[66]!==k||t[67]!==A||t[68]!==j||t[69]!==M||t[70]!==N||t[71]!==B||t[72]!==f?(V=(0,$.jsxs)(`section`,{children:[f,k,A,j,M,N,B]}),t[66]=k,t[67]=A,t[68]=j,t[69]=M,t[70]=N,t[71]=B,t[72]=f,t[73]=V):V=t[73],V}function Cn(e){return(0,$.jsxs)(`p`,{children:[`• `,e.message]},`${e.code}:${e.message}`)}function wn(e){let t=(0,Q.c)(9),{title:n,items:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,4).map(Tn),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{className:`mt-4`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function Tn(e){return(0,$.jsxs)(`li`,{children:[`• `,e]},e)}function En(e){let t=(0,Q.c)(34),{data:n,selected:r}=e,i=n.workflowNode,a=n.diffState,o;t[0]===i.kind?o=t[1]:(o=i.kind===`input`?(0,$.jsx)(Ne,{}):i.kind===`agent`?(0,$.jsx)(H,{}):i.kind===`decision`?(0,$.jsx)(F,{}):i.kind===`merge`?(0,$.jsx)(O,{}):(0,$.jsx)(V,{}),t[0]=i.kind,t[1]=o);let s=o,c=r?`border-accent ring-2 ring-accent/20`:`border-edge`,l=a===`added`&&`border-success ring-2 ring-success/15`,u=a===`changed`&&`border-accent ring-2 ring-accent/15`,d=a===`removed`&&`border-dashed border-danger opacity-55`,f;t[2]!==c||t[3]!==l||t[4]!==u||t[5]!==d?(f=p(`w-52 rounded-xl border bg-surface-panel p-3 shadow-surface transition-colors`,c,l,u,d),t[2]=c,t[3]=l,t[4]=u,t[5]=d,t[6]=f):f=t[6];let m;t[7]===i.kind?m=t[8]:(m=i.kind===`input`?null:(0,$.jsx)(ut,{type:`target`,position:st.Left,className:`!size-2.5 !border-2 !border-surface-panel !bg-fg-subtle`}),t[7]=i.kind,t[8]=m);let h;t[9]===s?h=t[10]:(h=(0,$.jsx)(`span`,{className:`mt-0.5 [&>svg]:size-4 text-accent-fg`,children:s}),t[9]=s,t[10]=h);let g;t[11]===i.title?g=t[12]:(g=(0,$.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[11]=i.title,t[12]=g);let _;t[13]!==i.description||t[14]!==i.kind?(_=i.description||Rn(i.kind),t[13]=i.description,t[14]=i.kind,t[15]=_):_=t[15];let v;t[16]===_?v=t[17]:(v=(0,$.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-4 text-fg-muted`,children:_}),t[16]=_,t[17]=v);let y;t[18]!==v||t[19]!==g?(y=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[g,v]}),t[18]=v,t[19]=g,t[20]=y):y=t[20];let b;t[21]===a?b=t[22]:(b=a?(0,$.jsx)(`span`,{className:p(`rounded-full px-1.5 py-0.5 text-[10px] font-medium`,a===`added`?`bg-success-soft text-success`:a===`removed`?`bg-danger/10 text-danger`:`bg-accent-soft text-accent-fg`),children:a===`added`?`+`:a===`removed`?`−`:`Δ`}):null,t[21]=a,t[22]=b);let x;t[23]!==y||t[24]!==b||t[25]!==h?(x=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[h,y,b]}),t[23]=y,t[24]=b,t[25]=h,t[26]=x):x=t[26];let S;t[27]===i.kind?S=t[28]:(S=i.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{id:`true`,type:`source`,position:st.Right,style:{top:`38%`},className:`!size-2.5 !border-2 !border-surface-panel !bg-success`}),(0,$.jsx)(ut,{id:`false`,type:`source`,position:st.Right,style:{top:`70%`},className:`!size-2.5 !border-2 !border-surface-panel !bg-danger`})]}):i.kind===`output`?null:(0,$.jsx)(ut,{type:`source`,position:st.Right,className:`!size-2.5 !border-2 !border-surface-panel !bg-accent`}),t[27]=i.kind,t[28]=S);let C;return t[29]!==x||t[30]!==S||t[31]!==f||t[32]!==m?(C=(0,$.jsxs)(`div`,{className:f,children:[m,x,S]}),t[29]=x,t[30]=S,t[31]=f,t[32]=m,t[33]=C):C=t[33],C}var Dn={workflow:En};function On(e){let t=(0,Q.c)(71),{node:n,copy:r,updateNode:i,onDelete:a}=e,o;t[0]!==n.id||t[1]!==i?(o=e=>i(n.id,t=>({...t,...e})),t[0]=n.id,t[1]=i,t[2]=o):o=t[2];let s=o,c;t[3]!==n.id||t[4]!==i?(c=e=>i(n.id,t=>({...t,config:{...t.config,...e}})),t[3]=n.id,t[4]=i,t[5]=c):c=t[5];let l=c,u;t[6]===r.stepSettings?u=t[7]:(u=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.stepSettings}),t[6]=r.stepSettings,t[7]=u);let f;t[8]!==r.remove||t[9]!==n.kind||t[10]!==a?(f=n.kind!==`input`&&n.kind!==`output`?(0,$.jsxs)(m,{variant:`ghost`,className:`h-8 px-2 text-danger`,onClick:a,children:[(0,$.jsx)(Le,{className:`size-3.5`}),r.remove]}):null,t[8]=r.remove,t[9]=n.kind,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==u||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[u,f]}),t[12]=u,t[13]=f,t[14]=p):p=t[14];let h;t[15]===r.stepName?h=t[16]:(h=(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-title`,children:r.stepName}),t[15]=r.stepName,t[16]=h);let g;t[17]===s?g=t[18]:(g=e=>s({title:e.target.value}),t[17]=s,t[18]=g);let _;t[19]!==n.title||t[20]!==g?(_=(0,$.jsx)(`input`,{id:`node-title`,value:n.title,onChange:g,className:kn}),t[19]=n.title,t[20]=g,t[21]=_):_=t[21];let v;t[22]===r.stepPurpose?v=t[23]:(v=(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-description`,children:r.stepPurpose}),t[22]=r.stepPurpose,t[23]=v);let y=n.description??``,b;t[24]===s?b=t[25]:(b=e=>s({description:e.target.value}),t[24]=s,t[25]=b);let x;t[26]!==y||t[27]!==b?(x=(0,$.jsx)(`textarea`,{id:`node-description`,value:y,onChange:b,className:`${kn} min-h-16 resize-y`}),t[26]=y,t[27]=b,t[28]=x):x=t[28];let S;t[29]!==r.advanced||t[30]!==r.defaultModel||t[31]!==r.instructions||t[32]!==r.model||t[33]!==n.config||t[34]!==n.kind||t[35]!==l?(S=n.kind===`agent`?(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:r.advanced}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-prompt`,children:r.instructions}),(0,$.jsx)(`textarea`,{id:`node-prompt`,value:String(n.config.prompt??``),onChange:e=>l({prompt:e.target.value}),className:`${kn} min-h-36 resize-y`}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-model`,children:r.model}),(0,$.jsx)(`input`,{id:`node-model`,value:String(n.config.model??``),onChange:e=>l({model:e.target.value||void 0}),placeholder:r.defaultModel,className:kn})]})}):null,t[29]=r.advanced,t[30]=r.defaultModel,t[31]=r.instructions,t[32]=r.model,t[33]=n.config,t[34]=n.kind,t[35]=l,t[36]=S):S=t[36];let C;t[37]!==r.compareValue||t[38]!==r.condition||t[39]!==r.contains||t[40]!==r.equals||t[41]!==r.exists||t[42]!==r.notEquals||t[43]!==r.valuePath||t[44]!==n.config||t[45]!==n.kind||t[46]!==l?(C=n.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`decision-path`,children:r.valuePath}),(0,$.jsx)(`input`,{id:`decision-path`,value:n.config.rule?.path??``,onChange:e=>l({rule:{...n.config.rule??{operator:`exists`},path:e.target.value}}),placeholder:`result.approved`,className:kn}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,id:`decision-operator-label`,children:r.condition}),(0,$.jsx)(d,{value:n.config.rule?.operator??`exists`,placeholder:r.condition,allowEmpty:!1,ariaLabelledBy:`decision-operator-label`,options:[{value:`exists`,label:r.exists},{value:`equals`,label:r.equals},{value:`not_equals`,label:r.notEquals},{value:`contains`,label:r.contains}],onChange:e=>l({rule:{...n.config.rule??{path:``},operator:e}})}),n.config.rule?.operator===`exists`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`decision-value`,children:r.compareValue}),(0,$.jsx)(`input`,{id:`decision-value`,value:String(n.config.rule?.value??``),onChange:e=>l({rule:{...n.config.rule,value:e.target.value}}),className:kn})]})]}):null,t[37]=r.compareValue,t[38]=r.condition,t[39]=r.contains,t[40]=r.equals,t[41]=r.exists,t[42]=r.notEquals,t[43]=r.valuePath,t[44]=n.config,t[45]=n.kind,t[46]=l,t[47]=C):C=t[47];let w;t[48]!==r.combineAs||t[49]!==r.listResults||t[50]!==r.namedResults||t[51]!==n.config||t[52]!==n.kind||t[53]!==l?(w=n.kind===`merge`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,id:`merge-mode-label`,children:r.combineAs}),(0,$.jsx)(d,{value:String(n.config.mode??`object`),placeholder:r.combineAs,allowEmpty:!1,ariaLabelledBy:`merge-mode-label`,options:[{value:`object`,label:r.namedResults},{value:`array`,label:r.listResults}],onChange:e=>l({mode:e})})]}):null,t[48]=r.combineAs,t[49]=r.listResults,t[50]=r.namedResults,t[51]=n.config,t[52]=n.kind,t[53]=l,t[54]=w):w=t[54];let T;t[55]!==r.autoSummary||t[56]!==r.summaryTemplate||t[57]!==n.config||t[58]!==n.kind||t[59]!==l?(T=n.kind===`output`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`output-summary`,children:r.summaryTemplate}),(0,$.jsx)(`textarea`,{id:`output-summary`,value:String(n.config.summary??``),onChange:e=>l({summary:e.target.value||void 0}),placeholder:r.autoSummary,className:`${kn} min-h-20 resize-y`})]}):null,t[55]=r.autoSummary,t[56]=r.summaryTemplate,t[57]=n.config,t[58]=n.kind,t[59]=l,t[60]=T):T=t[60];let E;return t[61]!==x||t[62]!==S||t[63]!==C||t[64]!==w||t[65]!==T||t[66]!==p||t[67]!==h||t[68]!==_||t[69]!==v?(E=(0,$.jsxs)(`section`,{children:[p,h,_,v,x,S,C,w,T]}),t[61]=x,t[62]=S,t[63]=C,t[64]=w,t[65]=T,t[66]=p,t[67]=h,t[68]=_,t[69]=v,t[70]=E):E=t[70],E}var kn=`mt-1 block h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-edge-strong`;function An(e,t=!1,n){return{id:e.id,type:`workflow`,position:e.position,selected:t,data:{workflowNode:e,diffState:n}}}function jn(e){return{id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,markerEnd:{type:at.ArrowClosed},style:{stroke:`var(--color-fg-subtle)`,strokeWidth:1.5}}}function Mn(){return{schemaVersion:1,nodes:[{id:`input`,kind:`input`,title:`Input`,description:`What the user provides`,position:{x:0,y:120},config:{}},{id:`agent-1`,kind:`agent`,title:`Do the work`,description:`Understand and complete the request`,phaseId:`work`,position:{x:300,y:120},config:{prompt:`Complete this goal: {{goal}}
2
-
3
- User input:
4
- {{input}}`,maxIterations:12}},{id:`output`,kind:`output`,title:`Result`,description:`A clear answer for the user`,position:{x:620,y:120},config:{}}],edges:[{id:`input-agent`,source:`input`,target:`agent-1`},{id:`agent-output`,source:`agent-1`,target:`output`}]}}function Nn(e,t,n){let r={x:280+n%3*280,y:80+Math.floor(n/3)*180};return e===`agent`?{id:t,kind:e,title:`New AI step`,description:`Describe what this step should accomplish`,phaseId:`work`,position:r,config:{prompt:`Use the previous results to complete this step:
5
- {{predecessors}}`,maxIterations:12}}:e===`decision`?{id:t,kind:e,title:`Check a condition`,description:`Choose what happens next`,position:r,config:{rule:{path:``,operator:`exists`}}}:{id:t,kind:e,title:`Combine results`,description:`Bring parallel work together`,position:r,config:{mode:`object`}}}function Pn(e,t){let n=new Map;if(!t)return{addedIds:[],changedIds:[],removedIds:[],connectionChanges:0,nodeStates:n};let r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map(t.nodes.map(e=>[e.id,e])),a=t.nodes.filter(e=>!r.has(e.id)).map(e=>e.id),o=e.nodes.filter(e=>!i.has(e.id)).map(e=>e.id),s=t.nodes.filter(e=>{let t=r.get(e.id);return t?Fn(t)!==Fn(e):!1}).map(e=>e.id);a.forEach(e=>n.set(e,`added`)),s.forEach(e=>n.set(e,`changed`)),o.forEach(e=>n.set(e,`removed`));let c=new Set(e.edges.map(In)),l=new Set(t.edges.map(In));return{addedIds:a,changedIds:s,removedIds:o,connectionChanges:e.edges.filter(e=>!l.has(In(e))).length+t.edges.filter(e=>!c.has(In(e))).length,nodeStates:n}}function Fn(e){let{position:t,...n}=e;return JSON.stringify(n)}function In(e){return`${e.source}:${e.sourcePort??``}->${e.target}`}function Ln(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`_`).replace(/^_+/,``)}function Rn(e){return{input:`User input`,agent:`AI step`,decision:`Decision`,merge:`Combine`,output:`User result`}[e]}function zn(e){return e===`zh`?{untitled:`未命名工作流`,editTitle:`编辑工作流`,createTitle:`创建工作流`,subtitle:`描述目标、确认方案,然后用示例测试。无需编写代码。`,close:`关闭`,savingDraft:`正在保存草稿…`,savedDraft:`草稿已保存`,draftError:`草稿保存失败`,flowTitle:`工作流步骤图`,flowAria:`可编辑的工作流步骤图`,stepCount:e=>`${e} 个步骤 · 点击步骤可编辑`,emptyFlow:`还没有步骤。添加一个 AI 步骤开始设计。`,addAgent:`添加 AI 步骤`,addDecision:`添加判断`,addMerge:`合并结果`,canvasHint:`拖动步骤并连接圆点`,workflowName:`内部名称`,humanTitle:`用户看到的名称`,task:`这个工作流最终帮用户得到什么?`,versions:`版本记录`,currentVersion:`当前`,restore:`恢复为新版本`,restoring:`恢复中…`,selectNode:`选择一个步骤来编辑`,needsAttention:`发布前需要处理`,stepSettings:`步骤设置`,remove:`删除`,stepName:`步骤名称`,stepPurpose:`这一步的作用`,instructions:`告诉 AI 要做什么`,advanced:`高级设置`,model:`模型(可选)`,defaultModel:`使用智能默认值`,valuePath:`要检查的值`,condition:`判断条件`,exists:`存在`,equals:`等于`,notEquals:`不等于`,contains:`包含`,compareValue:`比较值`,combineAs:`合并方式`,namedResults:`按步骤名称组织`,listResults:`按列表组织`,summaryTemplate:`结果摘要(可选)`,autoSummary:`留空则自动生成`,aiPlaceholder:`例如:增加一个风险评审步骤,并与方案分析并行`,designing:`正在设计…`,applyWithAi:`让 AI 提出修改`,testGoal:`用什么例子测试?`,publish:`保存`,publishAndRun:`保存并测试`,introTitle:`你希望这个工作流持续帮你完成什么?`,introDescription:`直接描述最终目标。AI 会先给出一份可理解的步骤方案,只有你确认后才会保存。`,introPlaceholder:`例如:每周整理项目进展,识别风险,并生成一份可以发给团队的周报。`,examples:[`研究一个主题并给出可靠结论`,`评审需求并生成实现计划`,`分析问题、定位原因并给出修复建议`],designWorkflow:`生成方案`,manualStart:`高级:手动搭建`,proposalTitle:`AI 提出的方案`,proposalHint:`绿色是新增,蓝色是修改,红色虚线是删除。确认前不会改变现有工作流。`,added:`新增`,changed:`修改`,removed:`删除`,assumptions:`方案假设`,risks:`需要留意`,permissions:`需要的权限`,acceptAndSave:`采用并保存`,savingProposal:`正在保存…`,rejectProposal:`不采用,返回修改`}:{untitled:`Untitled workflow`,editTitle:`Edit workflow`,createTitle:`Create workflow`,subtitle:`Describe the task, review the plan, then test it with an example. No code required.`,close:`Close`,savingDraft:`Saving draft…`,savedDraft:`Draft saved`,draftError:`Draft could not be saved`,flowTitle:`Workflow map`,flowAria:`Editable workflow step map`,stepCount:e=>`${e} steps · select a step to edit`,emptyFlow:`No steps yet. Add an AI step to start designing.`,addAgent:`Add AI step`,addDecision:`Add decision`,addMerge:`Combine results`,canvasHint:`Drag steps and connect the dots`,workflowName:`Internal name`,humanTitle:`Name users see`,task:`What will this workflow help the user achieve?`,versions:`Version history`,currentVersion:`Current`,restore:`Restore as new`,restoring:`Restoring…`,selectNode:`Select a step to edit it`,needsAttention:`Needs attention before publishing`,stepSettings:`Step settings`,remove:`Remove`,stepName:`Step name`,stepPurpose:`Purpose of this step`,instructions:`Tell the AI what to do`,advanced:`Advanced settings`,model:`Model (optional)`,defaultModel:`Use smart default`,valuePath:`Value to check`,condition:`Condition`,exists:`Exists`,equals:`Equals`,notEquals:`Does not equal`,contains:`Contains`,compareValue:`Compare with`,combineAs:`Combine as`,namedResults:`Named results`,listResults:`List of results`,summaryTemplate:`Result summary (optional)`,autoSummary:`Leave blank to generate automatically`,aiPlaceholder:`For example: add a risk review in parallel with solution analysis`,designing:`Designing…`,applyWithAi:`Ask AI to propose changes`,testGoal:`What example should we test?`,publish:`Save`,publishAndRun:`Save & test`,introTitle:`What should this workflow keep doing for you?`,introDescription:`Describe the task in plain language. AI will propose an understandable plan and will not save anything until you approve it.`,introPlaceholder:`For example: summarize project progress every week, identify risks, and produce a team-ready update.`,examples:[`Research a topic and deliver a reliable conclusion`,`Review a request and produce an implementation plan`,`Analyze an issue, find the cause, and recommend a fix`],designWorkflow:`Generate plan`,manualStart:`Advanced: build manually`,proposalTitle:`AI proposal`,proposalHint:`Green is added, blue is changed, and dashed red is removed. Nothing changes until you approve.`,added:`Added`,changed:`Changed`,removed:`Removed`,assumptions:`Assumptions`,risks:`Things to check`,permissions:`Required access`,acceptAndSave:`Accept & save`,savingProposal:`Saving…`,rejectProposal:`Reject and revise`}}function Bn(e){let t=(0,Q.c)(54),{graph:n,language:r,className:i}=e,a;t[0]===r?a=t[1]:(a=Gn(r),t[0]=r,t[1]=a);let o=a,[s,c]=(0,Z.useState)(n.nodes.find(Vn)?.id??n.nodes[0]?.id),l;if(t[2]!==o.kind||t[3]!==n.nodes){let e;t[5]===o.kind?e=t[6]:(e=e=>({id:e.id,type:`definitionNode`,position:e.position,data:{definitionNode:e,kindLabel:o.kind[e.kind]}}),t[5]=o.kind,t[6]=e),l=n.nodes.map(e),t[2]=o.kind,t[3]=n.nodes,t[4]=l}else l=t[4];let u=l,d;if(t[7]!==o.no||t[8]!==o.yes||t[9]!==n.edges){let e;t[11]!==o.no||t[12]!==o.yes?(e=e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,label:e.sourcePort===`true`?o.yes:e.sourcePort===`false`?o.no:void 0,labelStyle:{fill:`var(--color-fg-subtle)`,fontSize:10},labelBgStyle:{fill:`var(--color-surface-panel)`,fillOpacity:.9},markerEnd:{type:at.ArrowClosed},style:{stroke:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[11]=o.no,t[12]=o.yes,t[13]=e):e=t[13],d=n.edges.map(e),t[7]=o.no,t[8]=o.yes,t[9]=n.edges,t[10]=d}else d=t[10];let f=d,m=n.nodes,h,g,_,v,y,b;if(t[14]!==i||t[15]!==o.ariaLabel||t[16]!==o.empty||t[17]!==o.kind||t[18]!==o.selectHint||t[19]!==f||t[20]!==n.nodes||t[21]!==u||t[22]!==s){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[29]===s?e=t[30]:(e=e=>e.id===s,t[29]=s,t[30]=e);let r=m.find(e);if(n.nodes.length===0){let e;t[31]===i?e=t[32]:(e=p(`flex min-h-72 items-center justify-center bg-surface-base/40 px-6 text-center text-sm text-fg-muted`,i),t[31]=i,t[32]=e);let n;t[33]!==o.empty||t[34]!==e?(n=(0,$.jsx)(`div`,{className:e,children:o.empty}),t[33]=o.empty,t[34]=e,t[35]=n):n=t[35],h=n;break bb0}t[36]===i?v=t[37]:(v=p(`overflow-hidden bg-surface-base/45`,i),t[36]=i,t[37]=v),y=o.ariaLabel;let a;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(a=(e,t)=>c(t.id),t[38]=a):a=t[38];let l;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(l={padding:.24,minZoom:.45,maxZoom:1},t[39]=l):l=t[39];let d,x,S;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(d={hideAttribution:!0},x=(0,$.jsx)(ft,{color:`var(--color-edge)`,gap:22,size:1}),S=(0,$.jsx)(ct,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`}),t[40]=d,t[41]=x,t[42]=S):(d=t[40],x=t[41],S=t[42]),t[43]!==f||t[44]!==u?(b=(0,$.jsx)(`div`,{className:`h-[22rem] min-h-72`,children:(0,$.jsxs)(lt,{nodes:u,edges:f,nodeTypes:Wn,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:a,fitView:!0,fitViewOptions:l,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:d,children:[x,S]})}),t[43]=f,t[44]=u,t[45]=b):b=t[45],g=`flex min-h-16 items-start gap-3 border-t border-edge bg-surface-panel px-4 py-3`,_=r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:Un(r.kind)}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`strong`,{className:`block text-sm font-medium text-fg`,children:r.title}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:r.description||o.kind[r.kind]})]})]}):(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:o.selectHint})}t[14]=i,t[15]=o.ariaLabel,t[16]=o.empty,t[17]=o.kind,t[18]=o.selectHint,t[19]=f,t[20]=n.nodes,t[21]=u,t[22]=s,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b}else h=t[23],g=t[24],_=t[25],v=t[26],y=t[27],b=t[28];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let x;t[46]!==g||t[47]!==_?(x=(0,$.jsx)(`div`,{className:g,children:_}),t[46]=g,t[47]=_,t[48]=x):x=t[48];let S;return t[49]!==x||t[50]!==v||t[51]!==y||t[52]!==b?(S=(0,$.jsxs)(`section`,{className:v,"aria-label":y,children:[b,x]}),t[49]=x,t[50]=v,t[51]=y,t[52]=b,t[53]=S):S=t[53],S}function Vn(e){return e.kind===`agent`}function Hn(e){let t=(0,Q.c)(25),{data:n,selected:r}=e,i=n.definitionNode,a=r?`border-accent ring-2 ring-accent/20`:`border-edge`,o;t[0]===a?o=t[1]:(o=p(`w-48 rounded-xl border bg-surface-panel p-3 shadow-surface transition-colors`,a),t[0]=a,t[1]=o);let s;t[2]===i.kind?s=t[3]:(s=i.kind===`input`?null:(0,$.jsx)(ut,{type:`target`,position:st.Left,className:`!invisible`}),t[2]=i.kind,t[3]=s);let c;t[4]===i.kind?c=t[5]:(c=Un(i.kind),t[4]=i.kind,t[5]=c);let l;t[6]===c?l=t[7]:(l=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:c}),t[6]=c,t[7]=l);let u;t[8]===i.title?u=t[9]:(u=(0,$.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[8]=i.title,t[9]=u);let d;t[10]===n.kindLabel?d=t[11]:(d=(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.kindLabel}),t[10]=n.kindLabel,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let m;t[15]!==l||t[16]!==f?(m=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[l,f]}),t[15]=l,t[16]=f,t[17]=m):m=t[17];let h;t[18]===i.kind?h=t[19]:(h=i.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{id:`true`,type:`source`,position:st.Right,style:{top:`38%`},className:`!invisible`}),(0,$.jsx)(ut,{id:`false`,type:`source`,position:st.Right,style:{top:`70%`},className:`!invisible`})]}):i.kind===`output`?null:(0,$.jsx)(ut,{type:`source`,position:st.Right,className:`!invisible`}),t[18]=i.kind,t[19]=h);let g;return t[20]!==h||t[21]!==o||t[22]!==s||t[23]!==m?(g=(0,$.jsxs)(`div`,{className:o,children:[s,m,h]}),t[20]=h,t[21]=o,t[22]=s,t[23]=m,t[24]=g):g=t[24],g}function Un(e){return e===`input`?(0,$.jsx)(Ne,{className:`size-4`,"aria-hidden":!0}):e===`agent`?(0,$.jsx)(H,{className:`size-4`,"aria-hidden":!0}):e===`decision`?(0,$.jsx)(F,{className:`size-4`,"aria-hidden":!0}):e===`merge`?(0,$.jsx)(O,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0})}var Wn={definitionNode:Hn};function Gn(e){return e===`zh`?{ariaLabel:`工作流步骤图`,empty:`这个工作流还没有可展示的步骤。`,selectHint:`点击步骤查看它的作用。`,yes:`是`,no:`否`,kind:{input:`任务输入`,agent:`AI 执行`,decision:`条件判断`,merge:`汇总结果`,output:`最终结果`}}:{ariaLabel:`Workflow step map`,empty:`This workflow has no steps to display yet.`,selectHint:`Select a step to see what it does.`,yes:`Yes`,no:`No`,kind:{input:`Task input`,agent:`AI work`,decision:`Decision`,merge:`Combine results`,output:`Deliverable`}}}function Kn(e){let t=(0,Q.c)(54),{graph:n,view:r,language:i,onRepair:a}=e,[o,s]=(0,Z.useState)(),l=(0,Z.useRef)(null),u=(0,Z.useRef)(void 0),d;t[0]===i?d=t[1]:(d=tr(i),t[0]=i,t[1]=d);let f=d,h;t[2]===r.nodes?h=t[3]:(h=new Map(r.nodes.map(Zn)),t[2]=r.nodes,t[3]=h);let g=h,_;if(t[4]!==n.nodes||t[5]!==g){let e;t[7]===g?e=t[8]:(e=e=>({id:e.id,type:`runNode`,position:e.position,data:{definitionNode:e,runNode:g.get(e.id)}}),t[7]=g,t[8]=e),_=n.nodes.map(e),t[4]=n.nodes,t[5]=g,t[6]=_}else _=t[6];let v=_,y;if(t[9]!==n.edges||t[10]!==g){let e;t[12]===g?e=t[13]:(e=e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,markerEnd:{type:at.ArrowClosed},animated:g.get(e.source)?.status===`running`,style:{stroke:g.get(e.source)?.status===`done`?`var(--color-success)`:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[12]=g,t[13]=e),y=n.edges.map(e),t[9]=n.edges,t[10]=g,t[11]=y}else y=t[11];let b=y,x;t[14]!==o||t[15]!==g?(x=o?g.get(o):void 0,t[14]=o,t[15]=g,t[16]=x):x=t[16];let S=x,C;t[17]!==n.nodes||t[18]!==o?(C=o?n.nodes.find(e=>e.id===o):void 0,t[17]=n.nodes,t[18]=o,t[19]=C):C=t[19];let w=C,T;t[20]===r.nodes?T=t[21]:(T=r.nodes.some(Xn),t[20]=r.nodes,t[21]=T);let E=T,D,O;t[22]===r.nodes?(D=t[23],O=t[24]):(D=()=>{let e=r.nodes.find(Yn)??r.nodes.find(Jn)??[...r.nodes].reverse().find(qn);if(!e||u.current===e.id)return;u.current=e.id,s(e.id);let t=window.requestAnimationFrame(()=>{l.current?.fitView({nodes:[{id:e.id}],padding:1.4,minZoom:.65,maxZoom:1,duration:300})});return()=>window.cancelAnimationFrame(t)},O=[r.nodes],t[22]=r.nodes,t[23]=D,t[24]=O),(0,Z.useEffect)(D,O);let k;t[25]===f.title?k=t[26]:(k=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.title}),t[25]=f.title,t[26]=k);let A;t[27]===f.hint?A=t[28]:(A=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:f.hint}),t[27]=f.hint,t[28]=A);let j;t[29]!==k||t[30]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[29]=k,t[30]=A,t[31]=j):j=t[31];let M;t[32]!==f.repair||t[33]!==E||t[34]!==a?(M=E&&a?(0,$.jsxs)(m,{variant:`secondary`,className:`h-8 text-xs`,onClick:a,children:[(0,$.jsx)(z,{className:`size-3.5`}),f.repair]}):null,t[32]=f.repair,t[33]=E,t[34]=a,t[35]=M):M=t[35];let N;t[36]!==j||t[37]!==M?(N=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[j,M]}),t[36]=j,t[37]=M,t[38]=N):N=t[38];let P,F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>s(t.id),F=e=>{l.current=e},t[39]=P,t[40]=F):(P=t[39],F=t[40]);let I,L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I={hideAttribution:!0},L=(0,$.jsx)(ft,{color:`var(--color-edge)`,gap:22,size:1}),t[41]=I,t[42]=L):(I=t[41],L=t[42]);let R;t[43]!==b||t[44]!==v?(R=(0,$.jsx)(`div`,{className:`h-[28rem]`,children:(0,$.jsx)(lt,{nodes:v,edges:b,nodeTypes:er,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:P,onInit:F,fitView:!0,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:I,children:L})}),t[43]=b,t[44]=v,t[45]=R):R=t[45];let B;t[46]!==f.status||t[47]!==S||t[48]!==w?(B=S?(0,$.jsxs)(`div`,{className:p(`flex items-start gap-2 border-t border-edge px-4 py-3 text-xs`,S.status===`error`?`text-danger`:`text-fg-muted`),children:[S.status===`error`?(0,$.jsx)(X,{className:`mt-0.5 size-3.5 shrink-0`}):S.status===`done`?(0,$.jsx)(c,{className:`mt-0.5 size-3.5 shrink-0 text-success`}):null,(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`strong`,{className:`font-medium text-fg`,children:S.title}),w?.description?(0,$.jsx)(`span`,{className:`block pt-0.5 text-fg-subtle`,children:w.description}):null,(0,$.jsx)(`span`,{className:`block pt-1`,children:S.error||S.resultPreview||f.status[S.status]})]})]}):null,t[46]=f.status,t[47]=S,t[48]=w,t[49]=B):B=t[49];let V;return t[50]!==N||t[51]!==R||t[52]!==B?(V=(0,$.jsxs)(`section`,{className:`mt-5 overflow-hidden rounded-2xl border border-edge bg-surface-base/35`,children:[N,R,B]}),t[50]=N,t[51]=R,t[52]=B,t[53]=V):V=t[53],V}function qn(e){return e.status===`done`}function Jn(e){return e.status===`error`}function Yn(e){return e.status===`running`}function Xn(e){return e.status===`error`}function Zn(e){return[e.id,e]}function Qn(e){let t=(0,Q.c)(30),{data:n,selected:r}=e,i=n.definitionNode,a=n.runNode?.status??`pending`,o;t[0]===i.kind?o=t[1]:(o=i.kind===`input`?(0,$.jsx)(Ne,{}):i.kind===`agent`?(0,$.jsx)(H,{}):i.kind===`decision`?(0,$.jsx)(F,{}):i.kind===`merge`?(0,$.jsx)(O,{}):(0,$.jsx)(V,{}),t[0]=i.kind,t[1]=o);let s=o,c=a===`running`&&`border-accent ring-2 ring-accent/20`,l=a===`done`&&`border-success/50`,u=a===`error`&&`border-danger ring-2 ring-danger/15`,d=(a===`pending`||a===`skipped`)&&`border-edge opacity-70`,f=r&&`ring-2 ring-accent/25`,m;t[2]!==c||t[3]!==l||t[4]!==u||t[5]!==d||t[6]!==f?(m=p(`w-48 rounded-xl border bg-surface-panel px-3 py-2.5 shadow-surface`,c,l,u,d,f),t[2]=c,t[3]=l,t[4]=u,t[5]=d,t[6]=f,t[7]=m):m=t[7];let h;t[8]===i.kind?h=t[9]:(h=i.kind===`input`?null:(0,$.jsx)(ut,{type:`target`,position:st.Left,className:`!invisible`}),t[8]=i.kind,t[9]=h);let g;t[10]===s?g=t[11]:(g=(0,$.jsx)(`span`,{className:`[&>svg]:size-4 text-fg-subtle`,children:s}),t[10]=s,t[11]=g);let _;t[12]===i.title?_=t[13]:(_=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:i.title}),t[12]=i.title,t[13]=_);let v;t[14]===a?v=t[15]:(v=(0,$.jsx)($n,{status:a}),t[14]=a,t[15]=v);let y;t[16]!==_||t[17]!==v||t[18]!==g?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[g,_,v]}),t[16]=_,t[17]=v,t[18]=g,t[19]=y):y=t[19];let b;t[20]===i.description?b=t[21]:(b=i.description?(0,$.jsx)(`p`,{className:`mt-1.5 line-clamp-2 text-xs leading-4 text-fg-muted`,children:i.description}):null,t[20]=i.description,t[21]=b);let x;t[22]===i.kind?x=t[23]:(x=i.kind===`decision`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ut,{id:`true`,type:`source`,position:st.Right,className:`!invisible`}),(0,$.jsx)(ut,{id:`false`,type:`source`,position:st.Right,className:`!invisible`})]}):i.kind===`output`?null:(0,$.jsx)(ut,{type:`source`,position:st.Right,className:`!invisible`}),t[22]=i.kind,t[23]=x);let S;return t[24]!==y||t[25]!==b||t[26]!==x||t[27]!==m||t[28]!==h?(S=(0,$.jsxs)(`div`,{className:m,children:[h,y,b,x]}),t[24]=y,t[25]=b,t[26]=x,t[27]=m,t[28]=h,t[29]=S):S=t[29],S}function $n(e){let t=(0,Q.c)(4),{status:n}=e;if(n===`done`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-success`,children:(0,$.jsx)(c,{className:`size-3`})}),t[0]=e):e=t[0],e}if(n===`error`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-danger/10 text-danger`,children:(0,$.jsx)(X,{className:`size-3`})}),t[1]=e):e=t[1],e}if(n===`running`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`size-2.5 animate-pulse rounded-full bg-accent motion-reduce:animate-none`}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-edge-strong`}),t[3]=r):r=t[3],r}var er={runNode:Qn};function tr(e){return e===`zh`?{title:`运行过程`,hint:`点选步骤查看当前结果;画布会随着执行自动更新。`,repair:`修复这个工作流`,status:{pending:`等待中`,running:`执行中`,done:`已完成`,error:`失败`,skipped:`已跳过`}}:{title:`Live workflow`,hint:`Select a step to inspect it. The canvas updates as work progresses.`,repair:`Repair workflow`,status:{pending:`Waiting`,running:`Running`,done:`Completed`,error:`Failed`,skipped:`Skipped`}}}function nr(e,t){return t.status[e]??e}function rr(e,t){return t.phaseStatus[e]??e}function ir(e,t){let{run:n}=e;return n.status===`succeeded`?C(t.runSummarySucceeded,{agents:n.metrics.doneAgentCount,artifacts:n.metrics.artifactCount}):n.status===`failed`||n.status===`timeout`?n.error?.message??t.runSummaryFailedFallback:n.status===`cancelled`?t.runSummaryCancelled:C(t.runSummaryActive,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}function ar(e,t){let{run:n}=e;return n.status===`failed`?t.diagnosticFailedHint:n.status===`timeout`?t.diagnosticTimeoutHint:n.status===`cancelled`?t.diagnosticCancelledHint:n.status===`succeeded`&&n.metrics.errorAgentCount>0?t.diagnosticPartialHint:null}function or(e){return G(e)}function sr({view:e,comparison:t,loading:n,language:r,localeTag:i,activeTab:a,onTabChange:s,onCancel:l,onRetry:u,onReplay:d,onOpenRunId:h,ownerAgentId:v,onRepairWorkflow:y}){let b=_(r).workflows,x=Ze(r),S=o(),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),[A,M]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[,B]=(0,Z.useState)(0),V=e?.run.status,H=V?W.has(V):!1;(0,Z.useEffect)(()=>{e?.run.id&&(T(!1),F(null))},[e?.run.id,H,V,e?.run.metrics.errorAgentCount]),(0,Z.useEffect)(()=>{if(!H)return;let e=window.setInterval(()=>B(e=>e+1),1e3);return()=>window.clearInterval(e)},[H]);let U=(0,Z.useMemo)(()=>e?De(e):null,[e]),G=(0,Z.useMemo)(()=>U?Me(U):{phases:[],unphased:null},[U]),ee=(0,Z.useMemo)(()=>O==null||!U?null:U.agents.find(e=>e.id===O)??null,[O,U]);(0,Z.useEffect)(()=>{U?.runId&&k((U.agents.find(e=>e.status===`error`||e.status===`skipped`)??U.agents.find(e=>e.status===`running`)??null)?.id??null)},[U?.runId]);let te=(0,Z.useCallback)(e=>{k(e.id)},[]),ne=(0,Z.useMemo)(()=>e?j(e):[],[e]),q=e?Pe(e.run.result):void 0,J=q?kr(q):null,oe=q?R(q):``,se=!!q,ce=(0,Z.useCallback)(async()=>{se&&await g(oe)&&(M(!0),window.setTimeout(()=>M(!1),1500))},[se,oe]),le=(0,Z.useCallback)(()=>{if(!se||!e)return;let t=new Blob([oe],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.run.definitionId}-${e.run.id.slice(0,8)}.md`,r.click(),URL.revokeObjectURL(n)},[se,oe,e]),ue=(0,Z.useCallback)(()=>{if(!e)return;let t=or(e);t&&S(N(t))},[S,e]),de=(0,Z.useCallback)(async t=>{if(e){F(null),L(t.id);try{Dr(await je(e.run.id,t.id,{ownerAgentId:v}),t.name||t.id)}catch(e){F(e instanceof Error?e.message:String(e))}finally{L(null)}}},[v,e]),fe=(0,Z.useCallback)(t=>{if(!e||!t.prompt)return;let n=or(e);if(!n){g(t.prompt);return}S(N(n,t.prompt))},[S,e]),pe=(0,Z.useCallback)(e=>{if(e.kind===`copy_result`){ce();return}if(e.kind===`open_artifact`){let t=jr(e.payload),n=J?.artifacts.find(e=>e.id===t||e.name===t);n&&de(n);return}let t=jr(e.payload),n=J?.followUps.find(e=>e.id===t);if(n?.prompt){fe(n);return}let r=Mr(e.payload);r&&fe({id:e.id,title:e.label,prompt:r})},[ce,de,fe,J?.artifacts,J?.followUps]),me=(0,Z.useCallback)(t=>{if(!e||t==null)return;let n=String(t),r=e.agents.findIndex(e=>String(e.id)===n);if(r<0)return;let i=Number.parseInt(n,10);k(Number.isFinite(i)?i:r+1)},[e]),he=e?or(e):null,ge=J?.actions.filter(e=>Nr(e,J))??[],_e=ge.some(e=>e.kind===`copy_result`);if(n)return(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel p-5`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl`,"aria-busy":!0,children:[(0,$.jsx)(K,{className:`h-8 w-72 max-w-full`}),(0,$.jsx)(K,{className:`mt-4 h-28 rounded-2xl`}),(0,$.jsx)(K,{className:`mt-5 h-[28rem] rounded-2xl`})]})});if(!e||!U)return null;let{run:Y}=e,ve=e.controls.canCancel&&H,ye=H&&Y.startedAtMs!=null?re(Date.now()-Y.startedAtMs):re(Y.metrics.durationMs??void 0),be=ir(e,b),xe=ar(e,b),Ce=e.controls.canRetry&&e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.prompt?.trim()),we=e.controls.canRetry&&(e.phases.some(t=>t.status===`failed`&&e.agents.some(e=>e.phaseId===t.id&&e.prompt?.trim()))||e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.phaseId&&e.prompt?.trim())),Ee=Y.goal?.trim()||Y.title,X=e.nodes.find(e=>e.status===`running`)??e.nodes.find(e=>e.status===`error`)??[...e.nodes].reverse().find(e=>e.status===`done`),ke=X?.kind===`output`&&!X.error?q?.summary??X.resultPreview:null,Ae=ke??(X?X.error||(r===`zh`?`${X.status===`running`?`正在执行`:X.status===`done`?`刚刚完成`:`需要处理`}:${X.title}`:`${X.status===`running`?`Working on`:X.status===`done`?`Just completed`:`Needs attention`}: ${X.title}`):be),Ne=ne.length>0||!!xe,Le=(Y.status===`failed`||Y.status===`timeout`)&&!!y,Re=a===`diagnostics`||a===`debug`?`process`:a;return(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,$.jsxs)(`section`,{className:`mx-auto w-full max-w-6xl p-5`,children:[(0,$.jsxs)(`header`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold leading-7 text-fg`,children:Ee}),(0,$.jsx)(`span`,{className:p(`rounded-full px-2 py-0.5 text-xs font-medium`,ie(Y.status)),children:nr(Y.status,b)})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Y.title,` · `,Y.definitionId]}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:be}),xe?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:xe}):null,(0,$.jsxs)(`div`,{className:p(`mt-4 rounded-xl border px-3 py-2.5`,X?.status===`error`?`border-danger/30 bg-danger/5`:`border-accent/20 bg-accent-soft/50`),children:[(0,$.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:r===`zh`?`当前状态`:`Current status`}),ke?(0,$.jsx)(`div`,{className:`mt-2 max-h-40 overflow-hidden [mask-image:linear-gradient(to_bottom,black_calc(100%-1.5rem),transparent)]`,children:(0,$.jsx)(Xe,{content:Ae,compact:!0,className:`workflow-status-markdown`,codeCopy:!1,renderMermaid:!1,openHttpLinksInNewTab:!0})}):(0,$.jsx)(`p`,{className:`mt-1 text-sm font-medium text-fg`,children:Ae})]})]})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsx)(Rr,{label:b.metrics.startedAt,value:Fe(Y.startedAtMs??Y.createdAtMs,i)}),(0,$.jsx)(Rr,{label:b.metrics.duration,value:ye}),(0,$.jsx)(Rr,{label:b.metrics.agents,value:C(b.agentProgress,{done:Y.metrics.doneAgentCount,total:Y.metrics.agentCount})}),(0,$.jsx)(Rr,{label:b.metrics.artifacts,value:String(Y.metrics.artifactCount)})]})]}),(0,$.jsx)(lr,{activeTab:Re,onChange:s,labels:b,artifactCount:J?.artifacts.length??e.artifacts.length}),Re===`result`?(0,$.jsxs)(`section`,{className:`mt-5 space-y-4`,children:[se?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-3 border-b border-edge-subtle bg-surface-panel/45 px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b.resultTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:b.resultReadyHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[he?(0,$.jsxs)(m,{variant:`primary`,className:`h-8 text-xs`,onClick:ue,children:[(0,$.jsx)(Ie,{className:`size-3.5`,"aria-hidden":!0}),b.continueInChat]}):null,ge.map(e=>(0,$.jsx)(m,{variant:`secondary`,className:`h-8 text-xs`,onClick:()=>pe(e),children:e.label},e.id)),_e?null:(0,$.jsxs)(m,{variant:`secondary`,className:`h-8 text-xs`,onClick:ce,children:[A?(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),A?b.copied:b.copyResult]}),(0,$.jsxs)(m,{variant:`secondary`,className:`h-8 text-xs`,onClick:le,children:[(0,$.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),b.exportResult]})]})]}),(0,$.jsx)(`div`,{className:`px-5 py-6 sm:px-8 sm:py-8`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl`,children:(0,$.jsx)(Oe,{result:q,labels:x.result})})})]}):Y.status!==`failed`&&Y.status!==`timeout`?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:b.noResult}):null,Y.status===`failed`||Y.status===`timeout`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-2xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b.recoveryActionsTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:xe})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Le?(0,$.jsxs)(m,{variant:`primary`,onClick:y,children:[(0,$.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),r===`zh`?`让 AI 修复`:`Fix with AI`]}):null,Ce?(0,$.jsxs)(m,{variant:`secondary`,onClick:()=>d(`failed_agents`),children:[(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}),b.replayFailedAgents]}):null,we?(0,$.jsxs)(m,{variant:`secondary`,onClick:()=>d(`failed_phases`),children:[(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}),b.replayFailedPhases]}):null,e.controls.canRetry?(0,$.jsxs)(m,{variant:`secondary`,onClick:u,children:[(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}),b.rerun]}):null]})]}),(0,$.jsx)(br,{view:e,language:r})]}):null,J?(0,$.jsx)(Er,{task:J,labels:b,downloadingArtifactId:I,downloadError:P,onCopyText:e=>void g(e),onDownloadArtifact:e=>void de(e),onStartFollowUp:fe,compact:!0}):null,ve?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(m,{variant:`secondary`,onClick:l,className:`text-red-600 dark:text-red-300`,children:[(0,$.jsx)(Te,{className:`size-4`,"aria-hidden":!0}),b.cancel]})}):null]}):null,Re===`process`?(0,$.jsxs)($.Fragment,{children:[e.run.metadata?.definition.graph?(0,$.jsx)(Kn,{graph:e.run.metadata.definition.graph,view:e,language:r,onRepair:y}):null,Ne?(0,$.jsx)(cr,{diagnostics:ne,labels:b,hint:xe,onOpenAgent:me}):null,(0,$.jsx)(ur,{snapshot:U,rollup:G,view:e,labels:b,cardLabels:x,isActive:H,processExpanded:w,logsExpanded:E,selectedAgentId:O,selectedAgent:ee,durationText:ye,onToggleProcess:()=>T(e=>!e),onToggleLogs:()=>D(e=>!e),onSelectAgent:te}),(0,$.jsx)(gr,{view:e,comparison:t,labels:b,onOpenRunId:h}),(0,$.jsx)(_r,{view:e,labels:b})]}):null,Re===`artifacts`?(0,$.jsx)(Er,{task:J,labels:b,downloadingArtifactId:I,downloadError:P,onCopyText:e=>void g(e),onDownloadArtifact:e=>void de(e),onStartFollowUp:fe}):null]})})}function cr(e){let t=(0,Q.c)(13),{diagnostics:n,labels:r,hint:i,onOpenAgent:a}=e;if(n.length===0&&!i)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`rounded-xl bg-rose-500/10 p-2 text-rose-700 dark:text-rose-300`,children:(0,$.jsx)(X,{className:`size-4`,"aria-hidden":!0})}),t[0]=o):o=t[0];let s;t[1]===r.reliabilityTitle?s=t[2]:(s=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.reliabilityTitle}),t[1]=r.reliabilityTitle,t[2]=s);let c=i??r.reliabilityHint,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r||t[7]!==a?(u=n.length>0?(0,$.jsx)(`ul`,{className:`mt-3 space-y-2`,children:n.slice(0,5).map(e=>(0,$.jsx)(`li`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:hr(e,r)}),e.message?(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:e.message}):null,e.detail?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-subtle`,children:e.detail}):null]}),e.agentId==null?null:(0,$.jsx)(m,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,onClick:()=>a(e.agentId),children:r.openAgentDetails})]})},e.key))}):null,t[5]=n,t[6]=r,t[7]=a,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==l||t[11]!==u?(d=(0,$.jsx)(`section`,{className:`mt-5 rounded-2xl border border-rose-500/20 bg-rose-500/5 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,l,u]})]})}),t[9]=s,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function lr(e){let t=(0,Q.c)(16),{activeTab:n,onChange:r,labels:i,artifactCount:a}=e,o;t[0]===i.resultTitle?o=t[1]:(o={id:`result`,label:i.resultTitle},t[0]=i.resultTitle,t[1]=o);let s;t[2]===i.process?s=t[3]:(s={id:`process`,label:i.process},t[2]=i.process,t[3]=s);let c=a||void 0,l;t[4]!==i.taskArtifacts||t[5]!==c?(l={id:`artifacts`,label:i.taskArtifacts,count:c},t[4]=i.taskArtifacts,t[5]=c,t[6]=l):l=t[6];let u;t[7]!==o||t[8]!==s||t[9]!==l?(u=[o,s,l],t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10];let d=u,f;return t[11]!==n||t[12]!==i.taskActionsAria||t[13]!==r||t[14]!==d?(f=(0,$.jsx)(`div`,{className:`mt-5 flex overflow-x-auto border-b border-edge pb-2`,children:(0,$.jsx)(et,{items:d,activeTab:n,onChange:r,ariaLabel:i.taskActionsAria})}),t[11]=n,t[12]=i.taskActionsAria,t[13]=r,t[14]=d,t[15]=f):f=t[15],f}function ur(e){let t=(0,Q.c)(37),{snapshot:n,rollup:r,view:i,labels:a,cardLabels:o,isActive:s,processExpanded:c,logsExpanded:l,selectedAgentId:u,selectedAgent:d,durationText:f,onToggleProcess:m,onToggleLogs:h,onSelectAgent:g}=e,_;t[0]===a.process?_=t[1]:(_=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.process}),t[0]=a.process,t[1]=_);let v;t[2]!==a.agentProgress||t[3]!==i.run.metrics.agentCount||t[4]!==i.run.metrics.doneAgentCount?(v=C(a.agentProgress,{done:i.run.metrics.doneAgentCount,total:i.run.metrics.agentCount}),t[2]=a.agentProgress,t[3]=i.run.metrics.agentCount,t[4]=i.run.metrics.doneAgentCount,t[5]=v):v=t[5];let y;t[6]!==f||t[7]!==v?(y=(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[v,` · `,f]}),t[6]=f,t[7]=v,t[8]=y):y=t[8];let b;t[9]!==_||t[10]!==y?(b=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,y]}),t[9]=_,t[10]=y,t[11]=b):b=t[11];let S=c?`rotate-180`:null,w;t[12]===S?w=t[13]:(w=p(`size-4 shrink-0 text-fg-subtle transition-transform`,S),t[12]=S,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(x,{className:w,"aria-hidden":!0}),t[14]=w,t[15]=T);let E;t[16]!==m||t[17]!==c||t[18]!==b||t[19]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-4 px-4 py-3 text-left`,onClick:m,"aria-expanded":c,children:[b,T]}),t[16]=m,t[17]=c,t[18]=b,t[19]=T,t[20]=E):E=t[20];let D;t[21]!==o||t[22]!==s||t[23]!==a||t[24]!==l||t[25]!==g||t[26]!==h||t[27]!==c||t[28]!==r||t[29]!==d||t[30]!==u||t[31]!==n||t[32]!==i.phases?(D=c?(0,$.jsx)(`div`,{className:`border-t border-edge px-4 pb-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(20rem,26rem)]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s?(0,$.jsx)(Be,{snapshot:n,labels:o,logsExpanded:l,onToggleLogs:h,selectedAgentId:u,onSelectAgent:g}):(0,$.jsx)(qe,{rollup:r,currentPhase:n.currentPhase,labels:o.phase,recentLogs:n.logs,recentLogsHeading:o.recentLogsHeading,showAllLogsLabel:o.showAllLogs,logsExpanded:l,onToggleLogs:h,selectedAgentId:u,onSelectAgent:g}),i.phases.length>0?(0,$.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:i.phases.map(e=>(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:rr(e.status,a)})]})},e.id))}):null]}),(0,$.jsx)(dr,{agent:d,snapshot:n,labels:a,cardLabels:o})]})}):null,t[21]=o,t[22]=s,t[23]=a,t[24]=l,t[25]=g,t[26]=h,t[27]=c,t[28]=r,t[29]=d,t[30]=u,t[31]=n,t[32]=i.phases,t[33]=D):D=t[33];let O;return t[34]!==E||t[35]!==D?(O=(0,$.jsxs)(`div`,{className:`mt-5 rounded-2xl border border-edge bg-surface-base/35`,children:[E,D]}),t[34]=E,t[35]=D,t[36]=O):O=t[36],O}function dr(e){let t=(0,Q.c)(57),{agent:n,snapshot:r,labels:i,cardLabels:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s(!1)},t[0]=c):c=t[0];let l=n?.id,u;if(t[1]===l?u=t[2]:(u=[l],t[1]=l,t[2]=u),(0,Z.useEffect)(c,u),!n){let e;return t[3]===i.noSubagents?e=t[4]:(e=(0,$.jsx)(`aside`,{className:`min-w-0 rounded-2xl border border-dashed border-edge bg-surface-panel/45 p-4 text-sm text-fg-muted`,children:i.noSubagents}),t[3]=i.noSubagents,t[4]=e),e}let d;t[5]===n?d=t[6]:(d=Ke(n),t[5]=n,t[6]=d);let f=d,m=n.error||n.resultPreview||n.currentStep||a.checkDetail.runningPlaceholder,h;t[7]===n.label?h=t[8]:(h=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.label}),t[7]=n.label,t[8]=h);let g=n.phase||i.process,_;t[9]!==f||t[10]!==g?(_=[g,f].filter(Boolean),t[9]=f,t[10]=g,t[11]=_):_=t[11];let v=_.join(` · `),y;t[12]===v?y=t[13]:(y=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:v}),t[12]=v,t[13]=y);let b;t[14]!==h||t[15]!==y?(b=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[h,y]}),t[14]=h,t[15]=y,t[16]=b):b=t[16];let S;t[17]===n.status?S=t[18]:(S=p(`rounded-full px-2 py-0.5 text-xs font-medium`,Lr(n.status)),t[17]=n.status,t[18]=S);let C=i.agentStatus[n.status]??n.status,w;t[19]!==S||t[20]!==C?(w=(0,$.jsx)(`span`,{className:S,children:C}),t[19]=S,t[20]=C,t[21]=w):w=t[21];let T;t[22]!==b||t[23]!==w?(T=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b,w]}),t[22]=b,t[23]=w,t[24]=T):T=t[24];let E;t[25]===i.agentOutputHeading?E=t[26]:(E=(0,$.jsx)(`h4`,{className:`text-xs font-semibold text-fg`,children:i.agentOutputHeading}),t[25]=i.agentOutputHeading,t[26]=E);let D=n.error?`font-mono text-rose-600 dark:text-rose-400`:`text-fg-muted`,O;t[27]===D?O=t[28]:(O=p(`mt-2 max-h-72 overflow-auto whitespace-pre-wrap wrap-break-word text-sm leading-6`,D),t[27]=D,t[28]=O);let k;t[29]!==m||t[30]!==O?(k=(0,$.jsx)(`div`,{className:O,children:m}),t[29]=m,t[30]=O,t[31]=k):k=t[31];let A;t[32]!==E||t[33]!==k?(A=(0,$.jsxs)(`section`,{className:`mt-4 rounded-xl border border-edge-subtle bg-surface-base/60 p-3`,children:[E,k]}),t[32]=E,t[33]=k,t[34]=A):A=t[34];let j;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>s(mr),t[35]=j):j=t[35];let M=i.debugDetailsTitle,N=o&&`rotate-180`,P;t[36]===N?P=t[37]:(P=p(`size-4 shrink-0 text-fg-subtle transition-transform`,N),t[36]=N,t[37]=P);let F;t[38]===P?F=t[39]:(F=(0,$.jsx)(x,{className:P,"aria-hidden":!0}),t[38]=P,t[39]=F);let I;t[40]!==o||t[41]!==i.debugDetailsTitle||t[42]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-xs font-semibold text-fg`,onClick:j,"aria-expanded":o,children:[M,F]}),t[40]=o,t[41]=i.debugDetailsTitle,t[42]=F,t[43]=I):I=t[43];let L;t[44]!==o||t[45]!==n||t[46]!==a||t[47]!==i||t[48]!==r?(L=o?(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle p-3`,children:[n.steps?.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:a.checkDetail.stepsHeading}),(0,$.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.steps.slice(0,8).map(pr)})]}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.agentInputHeading}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-44 overflow-auto whitespace-pre-wrap wrap-break-word rounded-lg bg-surface-panel p-2 font-mono text-xs leading-5 text-fg-muted`,children:n.prompt||`—`})]}),(0,$.jsx)(Pr,{agent:n,labels:i}),r.logs.length>0?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:a.recentLogsHeading}),(0,$.jsx)(`div`,{className:`mt-1 max-h-36 space-y-0.5 overflow-auto rounded-lg bg-surface-panel p-2 font-mono text-xs text-fg-subtle`,children:r.logs.map(fr)})]}):null]}):null,t[44]=o,t[45]=n,t[46]=a,t[47]=i,t[48]=r,t[49]=L):L=t[49];let R;t[50]!==I||t[51]!==L?(R=(0,$.jsxs)(`section`,{className:`mt-3 rounded-xl border border-edge-subtle bg-surface-base/40`,children:[I,L]}),t[50]=I,t[51]=L,t[52]=R):R=t[52];let z;return t[53]!==T||t[54]!==A||t[55]!==R?(z=(0,$.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-edge bg-surface-panel p-4`,children:[T,A,R]}),t[53]=T,t[54]=A,t[55]=R,t[56]=z):z=t[56],z}function fr(e){return(0,$.jsx)(`div`,{className:`wrap-break-word`,children:e},e)}function pr(e){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-subtle`,children:e.status})]}),e.detail||e.resultPreview||e.error?(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.error||e.resultPreview||e.detail}):null]},e.id)}function mr(e){return!e}function hr(e,t){return e.kind===`run_error`?e.code?C(t.diagnosticsRunErrorWithCode,{code:e.code}):t.diagnosticsRunError:e.kind===`agent_error`?C(t.diagnosticsAgentError,{agent:e.agentLabel??String(e.agentId??`—`)}):e.kind===`step_error`?C(t.diagnosticsStepError,{agent:e.agentLabel??String(e.agentId??`—`),step:e.stepLabel??e.stepId??`—`}):C(t.diagnosticsAgentSkipped,{agent:e.agentLabel??String(e.agentId??`—`)})}function gr(e){let t=(0,Q.c)(36),{view:n,comparison:r,labels:i,onOpenRunId:a}=e,o=n.run.metadata?.replay;if(!o)return null;let s;t[0]===i.replayLineageTitle?s=t[1]:(s=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.replayLineageTitle}),t[0]=i.replayLineageTitle,t[1]=s);let c;t[2]!==i||t[3]!==o.scope||t[4]!==o.targetCount?(c=C(i.replayLineageSummary,{scope:yr(o.scope,i),count:o.targetCount}),t[2]=i,t[3]=o.scope,t[4]=o.targetCount,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:c}),t[6]=c,t[7]=l);let u;t[8]!==i.replaySourceRun||t[9]!==o.sourceRunId?(u=(0,$.jsx)(zr,{label:i.replaySourceRun,value:o.sourceRunId}),t[8]=i.replaySourceRun,t[9]=o.sourceRunId,t[10]=u):u=t[10];let d=i.replayTargetAgents,f;t[11]===o.agentIds?f=t[12]:(f=o.agentIds.join(`, `),t[11]=o.agentIds,t[12]=f);let p;t[13]!==i.replayTargetAgents||t[14]!==f?(p=(0,$.jsx)(zr,{label:d,value:f}),t[13]=i.replayTargetAgents,t[14]=f,t[15]=p):p=t[15];let h;t[16]!==u||t[17]!==p?(h=(0,$.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=h):h=t[18];let g;t[19]!==r||t[20]!==i.replayDurationDelta||t[21]!==i.replayFixedAgents||t[22]!==i.replayStillFailingAgents?(g=r?(0,$.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-3`,children:[(0,$.jsx)(Rr,{label:i.replayFixedAgents,value:String(r.fixedAgentIds.length)}),(0,$.jsx)(Rr,{label:i.replayStillFailingAgents,value:String(r.stillFailingAgentIds.length)}),(0,$.jsx)(Rr,{label:i.replayDurationDelta,value:vr(r.durationDeltaMs)})]}):null,t[19]=r,t[20]=i.replayDurationDelta,t[21]=i.replayFixedAgents,t[22]=i.replayStillFailingAgents,t[23]=g):g=t[23];let _;t[24]!==s||t[25]!==l||t[26]!==h||t[27]!==g?(_=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s,l,h,g]}),t[24]=s,t[25]=l,t[26]=h,t[27]=g,t[28]=_):_=t[28];let v;t[29]!==i.replayOpenSource||t[30]!==a||t[31]!==o.sourceRunId?(v=a?(0,$.jsx)(m,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>a(o.sourceRunId),children:i.replayOpenSource}):null,t[29]=i.replayOpenSource,t[30]=a,t[31]=o.sourceRunId,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v?(y=(0,$.jsx)(`section`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[_,v]})}),t[33]=_,t[34]=v,t[35]=y):y=t[35],y}function _r(e){let t=(0,Q.c)(36),{view:n,labels:r}=e,i;t[0]===n.run.metadata?.contextRefs?i=t[1]:(i=n.run.metadata?.contextRefs??[],t[0]=n.run.metadata?.contextRefs,t[1]=i);let a=i,o;t[2]===n.run.metadata?.writebackPolicy?.targets?o=t[3]:(o=n.run.metadata?.writebackPolicy?.targets??[],t[2]=n.run.metadata?.writebackPolicy?.targets,t[3]=o);let s=o;if(!a.length&&!s.length)return null;let c;t[4]===r.contextRefsTitle?c=t[5]:(c=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.contextRefsTitle}),t[4]=r.contextRefsTitle,t[5]=c);let l;t[6]===r.contextRefsHint?l=t[7]:(l=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.contextRefsHint}),t[6]=r.contextRefsHint,t[7]=l);let u;t[8]!==r.contextRefKinds||t[9]!==r.noContextRefs||t[10]!==a?(u=a.length?a.map(e=>(0,$.jsx)(zr,{label:r.contextRefKinds[e.kind]??e.kind,value:[e.title||e.id,e.role].filter(Boolean).join(` · `)},`${e.kind}:${e.id}:${e.role??``}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.noContextRefs}),t[8]=r.contextRefKinds,t[9]=r.noContextRefs,t[10]=a,t[11]=u):u=t[11];let d;t[12]===u?d=t[13]:(d=(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:u}),t[12]=u,t[13]=d);let f;t[14]!==c||t[15]!==l||t[16]!==d?(f=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[c,l,d]}),t[14]=c,t[15]=l,t[16]=d,t[17]=f):f=t[17];let p;t[18]===r.writebackTitle?p=t[19]:(p=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.writebackTitle}),t[18]=r.writebackTitle,t[19]=p);let m;t[20]===r.writebackHint?m=t[21]:(m=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.writebackHint}),t[20]=r.writebackHint,t[21]=m);let h;t[22]!==r.noWritebackTargets||t[23]!==r.writebackModes||t[24]!==r.writebackTargetKinds||t[25]!==s?(h=s.length?s.map(e=>(0,$.jsx)(zr,{label:r.writebackTargetKinds[e.kind]??e.kind,value:`${e.id} · ${r.writebackModes[e.mode]??e.mode}`},`${e.kind}:${e.id}:${e.mode}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.noWritebackTargets}),t[22]=r.noWritebackTargets,t[23]=r.writebackModes,t[24]=r.writebackTargetKinds,t[25]=s,t[26]=h):h=t[26];let g;t[27]===h?g=t[28]:(g=(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:h}),t[27]=h,t[28]=g);let _;t[29]!==g||t[30]!==p||t[31]!==m?(_=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[p,m,g]}),t[29]=g,t[30]=p,t[31]=m,t[32]=_):_=t[32];let v;return t[33]!==_||t[34]!==f?(v=(0,$.jsx)(`section`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:(0,$.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[f,_]})}),t[33]=_,t[34]=f,t[35]=v):v=t[35],v}function vr(e){return e==null?`—`:`${e>0?`+`:e<0?`-`:``}${re(Math.abs(e))}`}function yr(e,t){return e===`failed_phases`?t.replayScopeFailedPhases:t.replayScopeFailedAgents}function br(e){let t=(0,Q.c)(8),{view:n,language:r}=e,i=n.nodes,a,o;if(t[0]!==r||t[1]!==n.nodes){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i.filter(Tr),s=n.nodes.filter(wr);if(e.length===0&&s.length===0){o=null;break bb0}let c=r===`zh`?`已保留的阶段结果`:`Work completed before the failure`,l;t[4]===c?l=t[5]:(l=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c}),t[4]=c,t[5]=l);let u=r===`zh`?`失败不会清空已经完成的工作。你可以先使用这些结果,再让 AI 修复剩余步骤。`:`Completed work is preserved. You can use it now and ask AI to repair the remaining steps.`,d;t[6]===u?d=t[7]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u}),t[6]=u,t[7]=d),a=(0,$.jsxs)(`section`,{className:`rounded-2xl border border-amber-500/25 bg-amber-500/5 p-4`,children:[l,d,e.length>0?(0,$.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(Cr)}):null,s.length>0?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:r===`zh`?`待修复:${s.map(Sr).join(`、`)}`:`Needs repair: ${s.map(xr).join(`, `)}`}):null]})}t[0]=r,t[1]=n.nodes,t[2]=a,t[3]=o}else a=t[2],o=t[3];return o===Symbol.for(`react.early_return_sentinel`)?a:o}function xr(e){return e.title}function Sr(e){return e.title}function Cr(e){return(0,$.jsxs)(`li`,{className:`rounded-xl border border-edge-subtle bg-surface-base/60 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-5 text-fg-muted`,children:e.resultPreview})]},e.id)}function wr(e){return e.status===`error`}function Tr(e){return e.status===`done`&&e.resultPreview?.trim()}function Er(e){let t=(0,Q.c)(19),{task:n,labels:r,downloadingArtifactId:i,downloadError:a,onCopyText:o,onDownloadArtifact:s,onStartFollowUp:c,compact:l}=e,u=l===void 0?!1:l;if(!n||!n.artifacts.length&&!n.followUps.length){if(u)return null;let e;return t[0]===r.noArtifacts?e=t[1]:(e=(0,$.jsx)(`section`,{className:`mt-5 rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:r.noArtifacts}),t[0]=r.noArtifacts,t[1]=e),e}let d=!u&&`mt-5`,f;t[2]===d?f=t[3]:(f=p(`grid gap-3 lg:grid-cols-3`,d),t[2]=d,t[3]=f);let m;t[4]!==a||t[5]!==i||t[6]!==r||t[7]!==s||t[8]!==n.artifacts?(m=n.artifacts.length>0?(0,$.jsxs)(Or,{title:r.taskArtifacts,children:[(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.artifacts.map(e=>(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-base px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,title:e.title??e.name,children:e.title??e.name}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.mimeType}),(0,$.jsxs)(`button`,{type:`button`,className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline disabled:cursor-wait disabled:opacity-60`,disabled:i===e.id,onClick:()=>s(e),children:[(0,$.jsx)(Se,{className:`size-3`,"aria-hidden":!0}),i===e.id?r.downloadingArtifact:r.downloadArtifact]})]},e.id))}),a?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-rose-600 dark:text-rose-400`,children:a}):null]}):null,t[4]=a,t[5]=i,t[6]=r,t[7]=s,t[8]=n.artifacts,t[9]=m):m=t[9];let h;t[10]!==r||t[11]!==o||t[12]!==c||t[13]!==n.followUps?(h=n.followUps.length>0?(0,$.jsx)(Or,{title:r.taskFollowUps,children:(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.followUps.map(e=>(0,$.jsxs)(`li`,{className:`rounded-lg bg-surface-base px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),e.prompt?(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>c(e),children:r.startFollowUp}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-subtle hover:text-fg`,onClick:()=>o(e.prompt??``),children:r.copyPrompt})]}):null]},e.id))})}):null,t[10]=r,t[11]=o,t[12]=c,t[13]=n.followUps,t[14]=h):h=t[14];let g;return t[15]!==f||t[16]!==m||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:f,children:[m,h]}),t[15]=f,t[16]=m,t[17]=h,t[18]=g):g=t[18],g}function Dr(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function Or(e){let t=(0,Q.c)(10),{title:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=p(`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/35 p-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,$.jsx)(`div`,{className:`mt-2`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,$.jsxs)(`section`,{className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function kr(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=Array.isArray(t.actions)?t.actions:[],r=Array.isArray(t.artifacts)?t.artifacts:[],i=Array.isArray(t.followUps)?t.followUps:[];return n.length===0&&r.length===0&&i.length===0?null:{actions:n,artifacts:r,followUps:i}}function Ar(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function jr(e){if(typeof e==`string`)return e.trim()||null;let t=Ar(e);if(!t)return null;for(let e of[`artifactId`,`followUpId`,`id`,`name`])if(typeof t[e]==`string`&&t[e].trim())return t[e].trim();return null}function Mr(e){let t=Ar(e);if(!t)return null;for(let e of[`prompt`,`message`,`text`])if(typeof t[e]==`string`&&t[e].trim())return t[e].trim();return null}function Nr(e,t){if(e.kind===`copy_result`)return!0;let n=jr(e.payload);return e.kind===`open_artifact`?!!(n&&t.artifacts.some(e=>e.id===n||e.name===n)):e.kind===`start_followup`?!!(Mr(e.payload)||n&&t.followUps.some(e=>e.id===n&&e.prompt)):!!Mr(e.payload)}function Pr(e){let t=(0,Q.c)(21),{agent:n,labels:r}=e,i=n.invocation;if(!i)return null;let a=i.resolvedModelRef??i.modelRef,o;t[0]!==r.agentInvocationModel||t[1]!==a?(o={label:r.agentInvocationModel,value:a},t[0]=r.agentInvocationModel,t[1]=a,t[2]=o):o=t[2];let s;t[3]===i.toolset?s=t[4]:(s=i.toolset?.join(`, `),t[3]=i.toolset,t[4]=s);let c;t[5]!==r.agentInvocationTools||t[6]!==s?(c={label:r.agentInvocationTools,value:s},t[5]=r.agentInvocationTools,t[6]=s,t[7]=c):c=t[7];let l=i.maxIterations==null?void 0:String(i.maxIterations),u;t[8]!==r.agentInvocationIterations||t[9]!==l?(u={label:r.agentInvocationIterations,value:l},t[8]=r.agentInvocationIterations,t[9]=l,t[10]=u):u=t[10];let d=i.schema?r.agentInvocationSchemaPresent:void 0,f;t[11]!==r.agentInvocationSchema||t[12]!==d?(f={label:r.agentInvocationSchema,value:d},t[11]=r.agentInvocationSchema,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==c||t[16]!==u||t[17]!==f?(p=[o,c,u,f].filter(Ir),t[14]=o,t[15]=c,t[16]=u,t[17]=f,t[18]=p):p=t[18];let m=p;if(m.length===0)return null;let h;return t[19]===m?h=t[20]:(h=(0,$.jsx)(`dl`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 text-xs sm:grid-cols-2 lg:grid-cols-4`,children:m.map(Fr)}),t[19]=m,t[20]=h),h}function Fr(e){return(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:e.label}),(0,$.jsx)(`dd`,{className:`mt-0.5 truncate font-medium text-fg-muted`,title:e.value,children:e.value})]},e.label)}function Ir(e){return!!e.value}function Lr(e){return e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-rose-500/10 text-rose-700 dark:text-rose-300`:e===`running`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-subtle`}function Rr(e){let t=(0,Q.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(`dd`,{className:`mt-1 text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base/40 p-3`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function zr(e){let t=(0,Q.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(`div`,{className:`mt-1 truncate text-sm font-medium text-fg`,title:r,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Br(){let e=(0,Q.c)(8),t=v(Vr),[n]=a(),r;e[0]===n?r=e[1]:(r=n.get(`agentId`)?.trim()||void 0,e[0]=n,e[1]=r);let i=r,o;e[2]===t?o=e[3]:(o=t?[`workflow-route-agents`,t]:null,e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let c=b(o,U,s),l=i??c.data?.defaultId,u;return e[5]!==c.isLoading||e[6]!==l?(u={ownerAgentId:l,loading:c.isLoading},e[5]=c.isLoading,e[6]=l,e[7]=u):u=e[7],u}function Vr(e){return e.token}function Hr(e){let t=(0,Q.c)(19),n=v(Ur),r;t[0]===n?r=t[1]:(r=n?[`workflow-route-definitions`,n]:null,t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=b(r,Je,i),o;t[3]!==e||t[4]!==a.data?(o=a.data?.find(t=>t.id===e||t.name===e),t[3]=e,t[4]=a.data,t[5]=o):o=t[5];let s=o,c;t[6]===a?c=t[7]:(c=async e=>{await a.mutate(t=>[...(t??[]).filter(t=>t.id!==e.id&&t.name!==e.name),e],{revalidate:!1})},t[6]=a,t[7]=c);let l=c,u;t[8]===a?u=t[9]:(u=async()=>{await a.mutate()},t[8]=a,t[9]=u);let d=u,f;t[10]===a.data?f=t[11]:(f=a.data??[],t[10]=a.data,t[11]=f);let p;return t[12]!==s||t[13]!==a.error||t[14]!==a.isLoading||t[15]!==d||t[16]!==f||t[17]!==l?(p={definition:s,definitions:f,loading:a.isLoading,error:a.error,upsertDefinition:l,refreshDefinitions:d},t[12]=s,t[13]=a.error,t[14]=a.isLoading,t[15]=d,t[16]=f,t[17]=l,t[18]=p):p=t[18],p}function Ur(e){return e.token}var Wr=()=>({goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``});function Gr(){let{definitionId:e}=i(),[t]=a(),n=o(),r=y(e=>e.language),c=_(r).workflows,l=r===`zh`?`zh-CN`:`en-US`,{ownerAgentId:u}=Br(),d=t.get(`projectId`)?.trim()||void 0,{definition:f,loading:p,error:h}=Hr(e),g=b(u?[`workflow-detail-runs`,u,e,d??``]:null,()=>Ce(100,{ownerAgentId:u,projectId:d}),{revalidateOnFocus:!1}),[v,x]=(0,Z.useState)(Wr),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),E=(0,Z.useMemo)(()=>(g.data??[]).filter(e=>e.definitionId===f?.id).slice(0,6),[f?.id,g.data]),D=tt(f,v),O=f?ve(f,r):null,k=(0,Z.useCallback)(async()=>{if(!(!f||!D.valid||S)){C(!0),T(null);try{n(`/workflows/runs/${(await A({definitionId:f.id,goal:v.goal.trim()||O?.description||f.title,input:nt(f,v),agentId:u,projectId:d,concurrency:v.concurrency.trim()?Number(v.concurrency):void 0,maxSubagents:v.maxSubagents.trim()?Number(v.maxSubagents):void 0})).runId}${u?`?agentId=${encodeURIComponent(u)}`:``}`)}catch(e){T(e instanceof Error?e.message:c.startFailed)}finally{C(!1)}}},[f,D.valid,c.startFailed,O?.description,n,u,d,v,S]);if(p)return(0,$.jsx)(Xr,{});if(!f||!O)return(0,$.jsx)(Zr,{message:h?.message??(r===`zh`?`没有找到这个工作流`:`Workflow not found`)});let j=new URLSearchParams;u&&j.set(`agentId`,u),d&&j.set(`projectId`,d),f.metadata.source!==`user`&&j.set(`copy`,f.id);let M=`${f.metadata.source===`user`?`/workflows/${f.id}/edit`:`/workflows/new`}${j.size?`?${j.toString()}`:``}`;return(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 py-5 sm:px-6`,children:[(0,$.jsxs)(s,{to:`/workflows`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-fg-muted hover:text-fg`,children:[(0,$.jsx)(We,{className:`size-4`,"aria-hidden":!0}),r===`zh`?`返回工作流`:`Back to workflows`]}),(0,$.jsxs)(`header`,{className:`mt-4 flex flex-col gap-4 border-b border-edge pb-5 lg:flex-row lg:items-start lg:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:f.metadata.source===`user`?c.badgeUser:c.badgeBuiltin}),(0,$.jsx)(`span`,{children:`·`}),(0,$.jsx)(`span`,{children:r===`zh`?`版本 ${f.revision}`:`Version ${f.revision}`})]}),(0,$.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:f.title}),(0,$.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:O.description})]}),(0,$.jsx)(m,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,$.jsxs)(s,{to:M,children:[f.metadata.source===`user`?(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}),f.metadata.source===`user`?c.editWorkflow:c.copyAndEditWorkflow]})})]}),(0,$.jsxs)(`div`,{className:`mt-5 grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,$.jsxs)(`section`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r===`zh`?`它会怎样完成任务`:`How it completes the task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r===`zh`?`点击步骤查看职责;运行后这里会显示实时状态。`:`Select a step to understand its role. Live status appears here while running.`}),(0,$.jsx)(Bn,{graph:f.graph,language:r,className:`mt-3 h-[28rem] rounded-xl border border-edge`})]}),(0,$.jsxs)(`aside`,{className:`rounded-xl border border-edge bg-surface-base/45 p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r===`zh`?`开始一次运行`:`Start a run`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:O.whenToUse||O.description}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(rt,{definition:f,language:r,value:v,onChange:x,mode:`manual`,badgeLabel:c.readyToStart,aiAssist:{context:{surface:`workflow-start`,workflowId:f.id,workflowName:f.name,workflowTitle:f.title,workflowDescription:O.description}}})}),w?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:w}):null,(0,$.jsxs)(m,{variant:`primary`,className:`mt-4 w-full`,disabled:!D.valid||S,onClick:()=>void k(),children:[(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0}),S?c.starting:c.runWorkflow]})]})]}),(0,$.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r===`zh`?`最近运行`:`Recent runs`}),E.length?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-3`,children:E.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge bg-surface-base/40 p-3 text-left hover:bg-surface-hover`,onClick:()=>n(`/workflows/runs/${e.id}${u?`?agentId=${encodeURIComponent(u)}`:``}`),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:c.status[e.status]})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:ye(e.createdAtMs,l)})]},e.id))}):(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r===`zh`?`还没有运行记录。`:`No runs yet.`})]})]})})}function Kr(){let{definitionId:e}=i(),[t]=a(),n=o(),r=y(e=>e.language),{ownerAgentId:s}=Br(),c=t.get(`copy`)?.trim()||void 0,l=t.get(`repairRun`)?.trim()||void 0,{definition:u,definitions:d,loading:f,upsertDefinition:p,refreshDefinitions:m}=Hr(e??c),h=b(l&&s?[`workflow-repair-run`,l,s]:null,()=>Ae(l,{ownerAgentId:s}),{revalidateOnFocus:!1}),[g,_]=(0,Z.useState)(!1),[v,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),w=(0,Z.useMemo)(()=>d.map(e=>e.name),[d]),T=(0,Z.useMemo)(()=>_n(`my_workflow`,w),[w]),E=(0,Z.useMemo)(()=>{if(!u)return null;let t=e&&u.metadata.source===`user`?`edit`:`copy`,n=(h.data?.nodes.filter(e=>e.status===`error`)??[]).map(e=>r===`zh`?`${e.title}:${e.error??`执行失败`}`:`${e.title}: ${e.error??`execution failed`}`).join(r===`zh`?`;`:`; `)||h.data?.run.error?.message||void 0,i=l&&h.data?r===`zh`?`修复这次运行中的失败步骤,并保持原始目标不变:${n??`请根据运行记录定位失败原因`}`:`Repair the failed steps from this run while preserving the original goal: ${n??`use the run record to identify the failure`}`:void 0;return{mode:t,name:t===`edit`?u.name:Yr(u.name,d),graph:structuredClone(u.graph),manifest:gn(u),baseRevision:t===`edit`?u.revision:0,sourceTitle:u.title,repairPrompt:i}},[u,e,d,r,h.data?.nodes,l]),D=(0,Z.useCallback)(async e=>{_(!0),x(null),C(null);try{let t=await ue(e.name,e.graph,e.manifest,e.expectedRevision);return await p(t),n(`/workflows/${t.id}/edit`,{replace:!0}),t}catch(e){let t=vn(e);C(t),t||x(e instanceof Error?e.message:String(e))}finally{_(!1)}},[n,p]),O=(0,Z.useCallback)(async e=>{_(!0),x(null),C(null);try{let t=await ue(e.name,e.graph,e.manifest,e.expectedRevision);await p(t),n(`/workflows/runs/${(await A({definitionId:t.id,goal:e.goal,input:{goal:e.goal},agentId:s})).runId}${s?`?agentId=${encodeURIComponent(s)}`:``}`)}catch(e){let t=vn(e);throw C(t),t||x(e instanceof Error?e.message:String(e)),e}finally{_(!1)}},[n,s,p]);return f?(0,$.jsx)(Xr,{}):e&&!u?(0,$.jsx)(Zr,{message:r===`zh`?`没有找到这个工作流`:`Workflow not found`}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v?(0,$.jsx)(`div`,{className:`border-b border-danger/30 bg-danger/5 px-4 py-2 text-sm text-danger`,children:v}):null,(0,$.jsx)(bn,{language:r,ownerAgentId:s,saving:g,initialDraft:E,initialName:T,existingNames:w,saveConflict:S,onSave:D,onSaveAndStart:O,onClearSaveConflict:()=>C(null),onReloadLatest:()=>{C(null),x(null),m()}})]})}function qr(){let e=(0,Q.c)(53),{runId:t}=i(),n=o(),r=y(Jr),a=r===`zh`?`zh-CN`:`en-US`,{ownerAgentId:s}=Br(),c;e[0]===s?c=e[1]:(c={ownerAgentId:s},e[0]=s,e[1]=c);let l=xe(t,c),[u,d]=(0,Z.useState)(`process`),f=(0,Z.useRef)(!0),p;e[2]!==l.view?.run.metadata?.replay||e[3]!==s||e[4]!==t?(p=l.view?.run.metadata?.replay&&t?[`workflow-run-page-comparison`,t,s]:null,e[2]=l.view?.run.metadata?.replay,e[3]=s,e[4]=t,e[5]=p):p=e[5];let m;e[6]!==s||e[7]!==t?(m=()=>be(t,{ownerAgentId:s}),e[6]=s,e[7]=t,e[8]=m):m=e[8];let h;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},e[9]=h):h=e[9];let g=b(p,m,h),_;e[10]===l.view?_=e[11]:(_=l.view?W.has(l.view.run.status):!0,e[10]=l.view,e[11]=_);let v=_,x,S;e[12]===v?(x=e[13],S=e[14]):(x=()=>{f.current&&!v&&d(`result`),f.current=v},S=[v],e[12]=v,e[13]=x,e[14]=S),(0,Z.useEffect)(x,S);let C;e[15]!==n||e[16]!==s?(C=e=>{n(`/workflows/runs/${e}${s?`?agentId=${encodeURIComponent(s)}`:``}`)},e[15]=n,e[16]=s,e[17]=C):C=e[17];let w=C,E;e[18]!==w||e[19]!==s||e[20]!==t?(E=async()=>{t&&w((await T(t,{ownerAgentId:s})).runId)},e[18]=w,e[19]=s,e[20]=t,e[21]=E):E=e[21];let D=E,O;e[22]!==w||e[23]!==s||e[24]!==t?(O=async e=>{t&&w((await Qe(t,e,{ownerAgentId:s})).runId)},e[22]=w,e[23]=s,e[24]=t,e[25]=O):O=e[25];let k=O;if(!l.loading&&!l.view){let t=l.error instanceof Error?l.error.message:r===`zh`?`没有找到这次运行`:`Workflow run not found`,n;return e[26]===t?n=e[27]:(n=(0,$.jsx)(Zr,{message:t}),e[26]=t,e[27]=n),n}let A;e[28]!==l||e[29]!==s||e[30]!==t?(A=()=>t&&void ke(t,{ownerAgentId:s}).then(()=>l.mutate()),e[28]=l,e[29]=s,e[30]=t,e[31]=A):A=e[31];let j;e[32]===D?j=e[33]:(j=()=>void D(),e[32]=D,e[33]=j);let M;e[34]===k?M=e[35]:(M=e=>void k(e),e[34]=k,e[35]=M);let N;e[36]!==l.view||e[37]!==n||e[38]!==s?(N=l.view?()=>n(`/workflows/${l.view.run.definitionId}/edit?repairRun=${encodeURIComponent(l.view.run.id)}${s?`&agentId=${encodeURIComponent(s)}`:``}`):void 0,e[36]=l.view,e[37]=n,e[38]=s,e[39]=N):N=e[39];let P;return e[40]!==u||e[41]!==g.data||e[42]!==r||e[43]!==l.loading||e[44]!==l.view||e[45]!==a||e[46]!==w||e[47]!==s||e[48]!==A||e[49]!==j||e[50]!==M||e[51]!==N?(P=(0,$.jsx)(sr,{view:l.view,comparison:g.data,loading:l.loading,language:r,localeTag:a,activeTab:u,onTabChange:d,onCancel:A,onRetry:j,onReplay:M,onOpenRunId:w,ownerAgentId:s,onRepairWorkflow:N}),e[40]=u,e[41]=g.data,e[42]=r,e[43]=l.loading,e[44]=l.view,e[45]=a,e[46]=w,e[47]=s,e[48]=A,e[49]=j,e[50]=M,e[51]=N,e[52]=P):P=e[52],P}function Jr(e){return e.language}function Yr(e,t){let n=new Set(t.map(e=>e.name)),r=`${e}_copy`;if(!n.has(r))return r;for(let e=2;e<100;e+=1){let t=`${r}_${e}`;if(!n.has(t))return t}return`${r}_${Date.now()}`}function Xr(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`main`,{className:`min-h-0 flex-1 overflow-auto bg-surface-panel p-5`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl`,children:[(0,$.jsx)(K,{className:`h-5 w-36`}),(0,$.jsx)(K,{className:`mt-5 h-9 w-80 max-w-full`}),(0,$.jsx)(K,{className:`mt-4 h-[28rem] rounded-xl`})]})}),e[0]=t):t=e[0],t}function Zr(e){let t=(0,Q.c)(5),{message:n}=e,r;t[0]===n?r=t[1]:(r=(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(m,{asChild:!0,variant:`secondary`,className:`mt-4`,children:(0,$.jsxs)(s,{to:`/workflows`,children:[(0,$.jsx)(We,{className:`size-4`}),`Back`]})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,$.jsx)(`main`,{className:`flex min-h-0 flex-1 items-center justify-center bg-surface-panel p-6 text-center`,children:(0,$.jsxs)(`div`,{children:[r,i]})}),t[3]=r,t[4]=a),a}export{Gr as WorkflowDetailPage,Kr as WorkflowEditorPage,qr as WorkflowRunPage,hn as WorkflowsPage};