@xopcai/xopc 0.0.192 → 0.0.193

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 (121) 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-B-tzXpDD.js → activity-store-BwmdJ5pv.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-xOu0qNwc.js → agent-avatar-dicebear-DmNq0t2n.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-BOo1rVn9.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-fMItZb-h.js → api-BM1hNzjw.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-D6Rv3OWI.js → app-management-settings-panel-B3xStqSX.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-CKoNCwco.js → appearance-settings-DglyenDq.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-DC9qPFTx.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-BokNQBwH.js → archive-plugin-DvtcrBss.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dx1HglsM.js → attachment-load-CALdq4xM.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-page-BIGGKb0T.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-CPYAflIG.js → binary-plugins-GaVuvrDI.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-BFLgl8SS.js → block-editor-C2KrMYa_.js} +47 -47
  15. package/dist/gateway/static/root/assets/browser-settings-page-CPW_E-xj.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-CqLnqA9z.js → browser-workflow-inputs-FfEEjhIS.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-Db5v3HtE.js → browser-workflows-page-DFP9_UQk.js} +2 -2
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-CsD8aGHU.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-lov0J9A2.js → capability-presets-api-BoOzFotX.js} +1 -1
  20. package/dist/gateway/static/root/assets/capability-presets-settings-panel-NCeyWH6Z.js +3 -0
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-DSJznouK.js → channel-recipient-api-_8IiTxRB.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-settings-CknzwxNC.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-status-swr-DPaJSYX_.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-3ccRyS3L.js → connectors-api-vaSrhPF8.js} +1 -1
  25. package/dist/gateway/static/root/assets/connectors-page-DEGE7xp_.js +2 -0
  26. package/dist/gateway/static/root/assets/{cron-expression-C9hhCiuo.js → cron-expression-BjFuXlGY.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dependency-picker-CTtZFZug.js → dependency-picker-DOdkHdPv.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-DOUeNVmC.js → desktop-pet-Dz-Yf8Uu.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-D4704vtl.js → desktop-pet-settings-C8EHFEtd.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-DJDXeA1B.js → directory-picker-path-field-DKbfmZlZ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-C0n2NMF1.js → extension-debug-page-Dq0xsr_e.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-vG-xxRNs.js → extension-page-IgSLUyWP.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-CtuY2THd.js → extension-settings-page-VC-8Pjn2.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-CZra7GuI.js → gateway-config-api-CH2R7yqo.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-Cz33jRkR.js → gateway-settings-DLQJWaBQ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-BbVV0udv.js → gateway-startup-retry--2njcDpC.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-D2XMlA_U.js → heartbeat-settings-43loWoGb.js} +1 -1
  38. package/dist/gateway/static/root/assets/home-page-DqvpI6LC.js +3 -0
  39. package/dist/gateway/static/root/assets/{image-generation-api-BgrOvhaJ.js → image-generation-api-Cki7jfEV.js} +1 -1
  40. package/dist/gateway/static/root/assets/{index-DzmbmOGA.js → index-BpkdvHH0.js} +61 -61
  41. package/dist/gateway/static/root/assets/index-CFVjH-EK.css +1 -0
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BfyAEG1G.js → keyboard-shortcuts-settings-DJDZes_8.js} +1 -1
  43. package/dist/gateway/static/root/assets/local-app-workbench-page-CvNQM6qm.js +2 -0
  44. package/dist/gateway/static/root/assets/{local-apps-page-BYalcRSY.js → local-apps-page-C2ajOn1D.js} +1 -1
  45. package/dist/gateway/static/root/assets/{locale-store-VOY1wMO9.js → locale-store-Bjvw7jtg.js} +1 -1
  46. package/dist/gateway/static/root/assets/logs-page-BLm5yWqQ.js +2 -0
  47. package/dist/gateway/static/root/assets/{management-settings-BQf-6s32.js → management-settings--_eXnFVr.js} +1 -1
  48. package/dist/gateway/static/root/assets/{markdown-split-Cy_2SN1Q.js → markdown-split-iL2oi-x2.js} +1 -1
  49. package/dist/gateway/static/root/assets/{media-plugins-CkDupqb2.js → media-plugins-BIbkLVpQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{messages-DMJ-6-1m.js → messages-DQ5X6cXp.js} +2 -2
  51. package/dist/gateway/static/root/assets/{notes-page-kiGRR9jo.js → notes-page-xFxaZ6gT.js} +1 -1
  52. package/dist/gateway/static/root/assets/notes-workbench-PAftxL3V.js +4 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-CvzSdYVj.js → page-tabs-CROi9zm1.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-kZ0nco7e.js → preview-open-alternatives-BwYcPjOM.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DgoieqQC.js → product-open-page-BezeuVFd.js} +1 -1
  56. package/dist/gateway/static/root/assets/project-detail-page-CCdfZcw-.js +1 -0
  57. package/dist/gateway/static/root/assets/projects-page-DOG9zm5e.js +1 -0
  58. package/dist/gateway/static/root/assets/remote-access-hub-DQBFgveI.js +1 -0
  59. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bud_NTEZ.js → runtime-tools-settings-panel-Bs6tpSyX.js} +2 -2
  60. package/dist/gateway/static/root/assets/{schema-form-GlbsCBmv.js → schema-form-CWoSjz9s.js} +1 -1
  61. package/dist/gateway/static/root/assets/sessions-page-Db6L6M2H.js +1 -0
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-CcO2bd6q.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-form-section-CKLns16d.js → settings-form-section-BJaMEHsX.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BDzpxgk0.js → settings-loading-skeleton-sn4k17x7.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-BH0pF7QB.js → settings-page-D2hfeFPX.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-J793iqfm.js → settings-page-layout-CLtUsWsu.js} +1 -1
  67. package/dist/gateway/static/root/assets/setup-status-panel-UmQC_uZ1.js +1 -0
  68. package/dist/gateway/static/root/assets/{share-preview-page-UTm_7r0l.js → share-preview-page-BJ58AluH.js} +1 -1
  69. package/dist/gateway/static/root/assets/shares-settings-BZKn6Fdc.js +1 -0
  70. package/dist/gateway/static/root/assets/skill-reload-api-Cx3i24w_.js +1 -0
  71. package/dist/gateway/static/root/assets/skills-page-DjUllGtk.js +2 -0
  72. package/dist/gateway/static/root/assets/{skills-page.utils-Bwid1TGB.js → skills-page.utils-CZYIuE26.js} +1 -1
  73. package/dist/gateway/static/root/assets/system-settings-panel-DUrgdQMk.js +1 -0
  74. package/dist/gateway/static/root/assets/task-detail-page-BGG2cFe9.js +1 -0
  75. package/dist/gateway/static/root/assets/{theme-store-GVZOImyb.js → theme-store-DtxpMC5S.js} +1 -1
  76. package/dist/gateway/static/root/assets/{typed-models-lib-CT2c85Ju.js → typed-models-lib-CRNMvvFX.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-autosave-CcvY7DTh.js → use-autosave-Dle3-zdQ.js} +1 -1
  78. package/dist/gateway/static/root/assets/user-context-page-BLLmw5S1.js +1 -0
  79. package/dist/gateway/static/root/assets/{voice-api-key-field-Ricc3QGo.js → voice-api-key-field-BrWH0dCl.js} +1 -1
  80. package/dist/gateway/static/root/assets/{work-discovery-overlay-BoomfqhX.js → work-discovery-overlay-BZ1l9CFM.js} +1 -1
  81. package/dist/gateway/static/root/assets/work-discovery-page-BnPF2vx7.js +1 -0
  82. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BK6e9yzK.js +3 -0
  83. package/dist/gateway/static/root/assets/workflows-page-Bp5JxQJa.js +5 -0
  84. package/dist/gateway/static/root/index.html +7 -7
  85. package/dist/gateway/static/root/notification-sw.js +15 -0
  86. package/dist/package.js +1 -1
  87. package/dist/src/auth/oauth/xopc-cloud.js +163 -7
  88. package/dist/src/gateway/heartbeat/service.js +1 -1
  89. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  90. package/dist/src/gateway/service/run-gateway-agent.js +21 -8
  91. package/dist/src/heartbeat/index.js +1 -1
  92. package/package.json +3 -3
  93. package/dist/gateway/static/root/assets/agents-CxuwvDk0.js +0 -68
  94. package/dist/gateway/static/root/assets/apps-page-wAb5dnHZ.js +0 -1
  95. package/dist/gateway/static/root/assets/automations-page-Drgazevs.js +0 -6
  96. package/dist/gateway/static/root/assets/browser-settings-page-DmYlFJW7.js +0 -8
  97. package/dist/gateway/static/root/assets/capabilities-settings-panel-D7Z8T0o5.js +0 -7
  98. package/dist/gateway/static/root/assets/capability-presets-settings-panel-COjnwO0U.js +0 -3
  99. package/dist/gateway/static/root/assets/channels-settings-DcRYBNN7.js +0 -1
  100. package/dist/gateway/static/root/assets/channels-status-swr-C2UYdebT.js +0 -1
  101. package/dist/gateway/static/root/assets/connectors-page-FVmvBG9H.js +0 -2
  102. package/dist/gateway/static/root/assets/home-page-CPrHkPN6.js +0 -3
  103. package/dist/gateway/static/root/assets/index-Cg7Xnlu3.css +0 -1
  104. package/dist/gateway/static/root/assets/local-app-workbench-page-Clz47vSr.js +0 -2
  105. package/dist/gateway/static/root/assets/logs-page-Cxq9WMf5.js +0 -2
  106. package/dist/gateway/static/root/assets/notes-workbench-DkYkPGyB.js +0 -4
  107. package/dist/gateway/static/root/assets/project-detail-page-CeSjJd-N.js +0 -1
  108. package/dist/gateway/static/root/assets/projects-page-fZ1rm4b9.js +0 -1
  109. package/dist/gateway/static/root/assets/remote-access-hub-CbYI6KC8.js +0 -1
  110. package/dist/gateway/static/root/assets/sessions-page-sOJ_TnLm.js +0 -1
  111. package/dist/gateway/static/root/assets/settings-advanced-gate-BI0u77dt.js +0 -1
  112. package/dist/gateway/static/root/assets/setup-status-panel-CGsml89P.js +0 -1
  113. package/dist/gateway/static/root/assets/shares-settings-BM--lgUS.js +0 -1
  114. package/dist/gateway/static/root/assets/skill-reload-api-CGCOC-rV.js +0 -1
  115. package/dist/gateway/static/root/assets/skills-page-iLyaOl48.js +0 -2
  116. package/dist/gateway/static/root/assets/system-settings-panel-BcB3p1e3.js +0 -1
  117. package/dist/gateway/static/root/assets/task-detail-page-DQYEf08v.js +0 -1
  118. package/dist/gateway/static/root/assets/user-context-page-CGI41bfO.js +0 -1
  119. package/dist/gateway/static/root/assets/work-discovery-page-mbnepbQk.js +0 -1
  120. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DSWG2xqL.js +0 -3
  121. package/dist/gateway/static/root/assets/workflows-page-DtV0ruyk.js +0 -5
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as ee}from"./messages-DMJ-6-1m.js";import{n as te}from"./locale-store-VOY1wMO9.js";import{Ba as ne,Cl as re,Dt as ie,Ga as ae,Ha as s,Hl as oe,Ia as c,Ja as se,Ka as ce,La as le,Lc as l,Ra as ue,Ta as u,Ua as de,Va as d,Wa as fe,Xs as f,_l as p,gs as pe,hs as m,iu as me,jt as he,nu as h,pl as ge,qa as g,vs as _e,za as ve}from"./index-DzmbmOGA.js";var _=e(t(),1),v=new Set([`completed`,`failed`,`canceled`]);function ye(){return new Promise(e=>window.setTimeout(e,1200))}async function be(e,t){let n=[],r=t.wait??ye;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!v.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var y=n(),xe=[`folder_structure`,`recent_progress`,`next_steps`];function b(e){return e instanceof Error?e.message:String(e)}function x({embedded:e=!1,onRequestClose:t}={}){let n=te(e=>e.language),v=ee(n).onboarding.workDiscovery,ye=ee(n).chat.workingDirectory,x=i(),[Se]=r(),Ce=e||Se.get(`new`)===`1`,[S,C]=(0,_.useState)(`loading`),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(null),[we,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(``),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(()=>new Set),[z,Te]=(0,_.useState)([]),[B,Ee]=(0,_.useState)(()=>new Set),[De,V]=(0,_.useState)([]),[Oe,ke]=(0,_.useState)(!1),[H,U]=(0,_.useState)({current:0,total:0}),[Ae,je]=(0,_.useState)([]),[W,Me]=(0,_.useState)(()=>new Set),G=(0,_.useRef)(!1),Ne=e=>{Me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,_.useEffect)(()=>{let e=!1;return window.electronAPI?.understandingSources?.catalog().then(t=>{e||je(t)}),()=>{e=!0}},[]);let K=(0,_.useCallback)(e=>{c.getState().updateDirectoryRun(e),D(e),e.status===`completed`?(R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},[]),Pe=async()=>{k(!0),j(null);try{let e=await ue();if(!e.length){j(v.noCandidates);return}Te(e),Ee(new Set([e[0].rootPath])),C(`candidates`)}catch(e){j(b(e))}finally{k(!1)}},Fe=e=>{Ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ie=(0,_.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),D(e),U({current:t+1,total:n}),V(n=>{let r=[...n];return r[t]=e,r}),C(`running`)},[]),Le=(0,_.useCallback)(e=>{V(t=>t.map(t=>t?.id===e.id?e:t))},[]),Re=async()=>{let e=z.filter(e=>B.has(e.rootPath));if(!e.length)return;k(!0),j(null),V([]),U({current:1,total:e.length}),ke(!0),G.current=!1;let t=!1;try{let n=await be(e,{grantDirectory:s,startRun:ce,fetchRun:d,shouldStop:()=>G.current,onRun:(e,n,r)=>{Ie(e,n,r),t||(t=!0,c.getState().collectSources(e.id,[...W]))},onError:(t,n,r)=>{U({current:r+1,total:e.length}),j(v.folderAnalysisFailed.replace(`{{folder}}`,n.displayName).replace(`{{error}}`,b(t)))}});if(G.current)return;let r=n.find(e=>e.status===`completed`)??n.at(-1);r?K(r):C(`candidates`)}catch(e){j(b(e)),C(`candidates`)}finally{ke(!1),k(!1)}},q=he({onPicked:(0,_.useCallback)(async e=>{k(!0),j(null);try{T(await de(e)),C(`consent`)}catch(e){j(b(e)),C(`intro`)}finally{k(!1)}},[])});(0,_.useEffect)(()=>{let e=!1;return ne().then(async({enabled:n,state:r})=>{if(!e){if(!n){t?t():x(`/chat`,{replace:!0});return}if(!Ce&&r.activeRunId)try{let t=await d(r.activeRunId);e||K(t);return}catch{}e||C(`intro`)}}).catch(t=>{e||(j(b(t)),C(`intro`))}),()=>{e=!0}},[K,x,t,Ce]),(0,_.useEffect)(()=>{if(!E||S!==`running`||Oe)return;let e=!1,t=async()=>{try{let t=await d(E.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===E.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[K,Oe,S,E]);let J=async()=>{k(!0);try{await ve()}finally{t?t():x(`/chat`,{replace:!0})}},ze=async()=>{if(w){k(!0),j(null),V([]),U({current:0,total:0});try{await s(w.canonicalRootPath);let e=await ce(w.canonicalRootPath);K(e),c.getState().collectSources(e.id,[...W])}catch(e){j(b(e)),C(`consent`)}finally{k(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;x(`/chat/${encodeURIComponent(e)}${n}`)},Be=e=>{D(e),M(!1),I(!1),R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},Ve=async()=>{E&&(G.current=!0,K(await le(E.id)))},X=async(e,t)=>{if(!E)return;await ae(E.id,e.id).catch(()=>{});let r=t?`${n===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${e.actionPrompt}`:e.actionPrompt;Y(E.sessionKey,r)},He=async()=>{if(E){k(!0),j(null);try{let e=E.result?.profileCandidates??[],t=await g((e.length>0?await se(E.id,e.map(e=>({id:e.id,status:L.has(e.id)?`accepted`:`rejected`}))):E).id,`confirmed`);D(t),Le(t),C(`recommendation`)}catch(e){j(b(e))}finally{k(!1)}}},Z=async e=>{if(!(!E||!N.trim())){k(!0),j(null);try{let t=await g(E.id,e,N.trim());D(t),Y(t.sessionKey,N.trim())}catch(e){j(b(e)),k(!1)}}},Ue=async()=>{if(E){k(!0);try{Y((await g(E.id,`dismissed`)).sessionKey)}catch(e){j(b(e)),k(!1)}}},Q=E?.result?.suggestions.find(e=>e.id===E.result?.primarySuggestionId)??E?.result?.suggestions[0],We=E?.result?.suggestions.filter(e=>e.id!==Q?.id)??[],Ge=e=>e===`command`?v.riskCommand:e===`file_write`?v.riskFileWrite:v.riskAnalysis,Ke=De.filter(e=>e?.status===`completed`),qe=e&&S===`candidates`,$=Ke.length>1?(0,y.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,y.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:v.analysisResults}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ke.map(e=>{let t=z.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,y.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===E?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Be(e),children:t},e.id)})})]}):null;return(0,y.jsxs)(`div`,{className:e?`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-base`:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,y.jsxs)(`main`,{className:e?`mx-auto flex h-full min-h-0 w-full max-w-[40rem] flex-1 flex-col px-5 py-7 sm:px-8 sm:py-9 ${qe?`overflow-hidden`:`overflow-y-auto [scrollbar-gutter:stable]`}`:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[e?null:(0,y.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,y.jsx)(pe,{className:`size-11`})}),S===`loading`?(0,y.jsxs)(`div`,{className:`mx-auto flex min-h-[26rem] w-full max-w-md flex-col items-center`,"aria-busy":!0,children:[(0,y.jsx)(u,{className:`h-8 w-64 max-w-full`}),(0,y.jsx)(u,{className:`mt-4 h-4 w-full max-w-sm`}),(0,y.jsx)(u,{className:`mt-2 h-4 w-4/5 max-w-xs`}),(0,y.jsx)(u,{className:`mt-10 h-12 w-full rounded-xl`}),(0,y.jsx)(u,{className:`mt-3 h-11 w-full rounded-xl`}),(0,y.jsx)(u,{className:`mt-5 h-4 w-3/5 max-w-56`})]}):null,S===`intro`?(0,y.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,y.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.title}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:v.subtitle})]}),(0,y.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[Ae.length?(0,y.jsxs)(`div`,{className:`mb-5 rounded-xl border border-edge bg-surface-panel p-3 text-left`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.localSourcesTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.localSourcesSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3`,children:Ae.map(e=>{let t=W.has(e.id);return(0,y.jsxs)(`button`,{type:`button`,className:o(`flex min-h-16 flex-col items-center justify-center gap-1 rounded-lg border px-2 py-2 text-xs font-medium transition-colors`,t?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":t,onClick:()=>Ne(e.id),children:[(0,y.jsx)(`span`,{className:o(`flex size-4 items-center justify-center rounded-full border`,t?`border-accent bg-accent text-white`:`border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),e.displayName]},e.id)})})]}):null,(0,y.jsxs)(m,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void Pe(),disabled:O||q.picking,children:[O?(0,y.jsx)(l,{className:`size-4 animate-spin`}):(0,y.jsx)(f,{className:`size-4`}),v.quickScan]}),(0,y.jsxs)(m,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:q.pick,disabled:O||q.picking,children:[q.picking?(0,y.jsx)(l,{className:`size-4 animate-spin`}):(0,y.jsx)(p,{className:`size-4`}),v.chooseFolderManually]}),(0,y.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:v.quickScanNote})]}),(0,y.jsx)(`button`,{type:`button`,className:`mt-4 text-sm font-medium text-accent-fg hover:underline`,onClick:()=>x(`/connectors?understanding=1&returnTo=%2Fonboarding%2Fworkspace`),children:v.connectCloudSource}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:O,children:v.skip})]}):null,S===`candidates`?(0,y.jsxs)(`section`,{className:e?`flex h-full min-h-0 flex-col`:void 0,"aria-labelledby":`work-discovery-candidates-title`,children:[(0,y.jsxs)(`div`,{className:e?`shrink-0 text-center`:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.candidatesTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:v.candidatesSubtitle})]}),(0,y.jsx)(`div`,{className:e?`mt-5 min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1 [scrollbar-gutter:stable]`:`mt-7 space-y-2`,children:z.map((e,t)=>{let n=B.has(e.rootPath);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${n?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Fe(e.rootPath),children:[(0,y.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${n?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,y.jsx)(a,{className:`size-3.5`})}),(0,y.jsx)(p,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),t===0?(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:v.recommendedCandidate}):null]}),(0,y.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,y.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,y.jsx)(`span`,{children:e.projectKind===`coding`?v.codingProject:e.projectKind===`general`?v.generalProject:v.unknownProject}),e.branch?(0,y.jsx)(`span`,{children:v.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,y.jsx)(`span`,{children:v.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,y.jsxs)(`div`,{className:e?`shrink-0 border-t border-edge-subtle pt-4`:void 0,children:[(0,y.jsxs)(`div`,{className:`${e?``:`mt-5 `}flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:v.multiFolderPrivacyNote})]}),A?(0,y.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`${e?`mt-4`:`mt-7`} flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(m,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O||B.size===0,onClick:()=>void Re(),children:[O?(0,y.jsx)(l,{className:`mr-2 size-4 animate-spin`}):null,v.analyzeSelected.replace(`{{count}}`,String(B.size))]}),(0,y.jsx)(m,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:q.pick,children:v.chooseFolderManually})]}),(0,y.jsx)(`button`,{type:`button`,className:`${e?`mt-3`:`mt-6`} mx-auto block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>C(`intro`),children:v.back})]})]}):null,S===`consent`&&w?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.selectedTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:v.selectedSubtitle})]}),(0,y.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,y.jsx)(p,{className:`size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:w.displayName}),(0,y.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:w.canonicalRootPath})]}),(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:w.projectKind===`coding`?v.codingProject:w.projectKind===`general`?v.generalProject:v.unknownProject})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.localFingerprint}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:w.fingerprint.branch?v.branchValue.replace(`{{branch}}`,w.fingerprint.branch):v.noGitBranch})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.recentActivity}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:v.changedFiles.replace(`{{count}}`,String(w.fingerprint.changedFileCount))})]}),w.fingerprint.recentAreas.length>0?(0,y.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.recentAreas}),(0,y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:w.fingerprint.recentAreas.map(e=>(0,y.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,y.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.willRead}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:v.willReadValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(_e,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.willIgnore}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:v.willIgnoreValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:w.remoteModel?v.providerDisclosure.replace(`{{provider}}`,w.provider):v.localDisclosure})]})]})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(m,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void ze(),children:[O?(0,y.jsx)(l,{className:`mr-2 size-4 animate-spin`}):null,v.startAnalysis]}),(0,y.jsx)(m,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:q.pick,children:v.changeFolder})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:v.skip})]}):null,S===`running`&&E?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:v.analyzingTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:v.analyzingSubtitle}),H.total>1?(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:v.analyzingFolderProgress.replace(`{{current}}`,String(H.current)).replace(`{{total}}`,String(H.total))}):null]}),(0,y.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:xe.map((e,t)=>{let n=Math.max(0,xe.indexOf(E.stage??`folder_structure`)),r=t<n,i=t===n;return(0,y.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,y.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${r?`bg-accent text-white`:i?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:r?(0,y.jsx)(a,{className:`size-4`}):i?(0,y.jsx)(l,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,y.jsx)(`span`,{className:i||r?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:v.stages[e]})]},e)})}),(0,y.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:E.rootPath}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,y.jsx)(m,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>x(`/chat`),children:v.continueInBackground}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Ve(),children:v.cancelAnalysis})]})]}):null,S===`recognition`&&E?.result?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:v.recognitionEyebrow}),(0,y.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:E.result.lowConfidence?v.lowConfidenceTitle:v.recognitionTitle})]}),$,(0,y.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,y.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:E.result.projectSummary}),(0,y.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:E.result.currentState}),!E.result.lowConfidence&&Q?.evidence.length?(0,y.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,y.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(ge,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{children:[e.path?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),E.result.workThreads?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.workThreadsTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.workThreadsSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:E.result.workThreads.map(e=>(0,y.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?v.workThreadCurrent:e.horizon===`ongoing`?v.workThreadOngoing:v.workThreadLongTerm}),(0,y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,y.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,E.result.profileCandidates?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.profileCandidatesTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:v.profileCandidatesSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 space-y-2`,children:E.result.profileCandidates.map(e=>(0,y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,y.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:L.has(e.id),onChange:()=>R(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,y.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,E.result.lowConfidence?(0,y.jsxs)(`div`,{className:`mt-5`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:E.result.contextQuestion}),(0,y.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:v.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsx)(m,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:O||!N.trim(),onClick:()=>void Z(`different_goal`),children:v.continueWithCorrection})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(m,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void He(),children:[O?(0,y.jsx)(l,{className:`size-4 animate-spin`}):(0,y.jsx)(a,{className:`size-4`}),v.confirmUnderstanding]}),(0,y.jsx)(m,{variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:()=>M(e=>!e),children:v.notQuiteRight})]}),we?(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:v.correctionLabel}),(0,y.jsx)(`textarea`,{id:`work-discovery-correction`,value:N,onChange:e=>P(e.target.value),placeholder:v.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,y.jsx)(m,{variant:`ghost`,disabled:O||!N.trim(),onClick:()=>void Z(`different_goal`),children:v.differentGoal}),(0,y.jsx)(m,{variant:`primary`,disabled:O||!N.trim(),onClick:()=>void Z(`corrected`),children:v.useCorrection})]})]}):null]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsx)(`button`,{type:`button`,disabled:O,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Ue(),children:v.openConversation})]}):null,S===`recommendation`&&E?.result&&Q?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:v.understandingConfirmed}),(0,y.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:v.primaryRecommendationTitle})]}),$,(0,y.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,y.jsx)(h,{className:`size-5`})}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,y.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,y.jsx)(oe,{className:`size-3.5`}),v.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,y.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ge(Q.risk)})]}),(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:v.expectedTask}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedTask})]}),(0,y.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,y.jsx)(m,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:v.startRecommendedAction}),(0,y.jsx)(m,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:v.explainFirst})]})]})]})}),We.length>0?(0,y.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>I(e=>!e),children:[v.otherDirections,(0,y.jsx)(me,{className:`size-4 transition-transform ${F?`rotate-180`:``}`})]}),F?(0,y.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:We.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,y.jsx)(h,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedTask})]})]},e.id))}):null]}):null,(0,y.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(E.sessionKey),children:v.doSomethingElse}),(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{M(!0),C(`recognition`)},children:v.correctUnderstanding})]})]}):null,S===`error`&&E?(0,y.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,y.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,y.jsx)(_e,{className:`size-5`})}),(0,y.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:v.errorTitle}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:E.errorMessage}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsx)(m,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void fe(E.id).then(K),children:v.retry}),(0,y.jsx)(m,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{D(null),T(null),C(`intro`)},children:v.chooseDifferent})]}),(0,y.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(E.sessionKey),children:v.openConversation})]}):null]}),q.hasNativePicker?null:(0,y.jsx)(ie,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:w?.canonicalRootPath,onConfirm:q.confirmPick,wd:ye})]})}export{x as WorkDiscoveryPage};
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-DMJ-6-1m.js";import{o,r as s}from"./locale-store-VOY1wMO9.js";import{Ao as c,Dl as l,Do as u,Eo as d,G as f,Gs as p,Ho as m,I as h,Is as g,Mo as _,Oo as v,Ts as y,Uo as b,Us as x,Zc as S,_i as C,et as w,hs as T,iu as E,j as D,jo as ee,oc as O,qs as k,tt as A,vs as j}from"./index-DzmbmOGA.js";var M=e(t(),1),N=n();function P(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function F(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function I(e,t={}){let n=P(e.split(`
2
- `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
- `));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(F(n));return null}async function L(e,t={}){let n=await o(s(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,c=``,l=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=I(e,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});n!==null&&(c=n)}}if(e)break}if(a.trim()){let e=I(a,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});e!==null&&(c=e)}let u=c.trim();if(!u)throw Error(`AI returned an empty suggestion`);return{text:u,thinking:l.trim()||void 0}}function te(){let[e,t]=(0,M.useState)(``),[n,r]=(0,M.useState)(``),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,M.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await L(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,M.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var R=r(),ne=5;function re(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,generate:`生成建议`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,generate:`Generate suggestion`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function z(e){let t=(0,N.c)(239),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:f,intent:m,locale:h,context:g,disabled:y,className:b,showLabel:S}=e,w=s===void 0?`generic.text`:s,D=f===void 0?`plain`:f,k=m===void 0?`improve`:m,A=S===void 0?!0:S,[P,F]=(0,M.useState)(!1),[I,L]=(0,M.useState)(n),[z,B]=(0,M.useState)(`preview`),[V,H]=(0,M.useState)(``),[U,oe]=(0,M.useState)(`edit`),[W,G]=(0,M.useState)(!0),[se,ce]=(0,M.useState)(!1),[K,q]=(0,M.useState)(null),le=(0,M.useRef)(null),ue=(0,M.useRef)(!0),{suggestion:de,thinking:J,loading:Y,error:X,generate:fe,reset:pe}=te(),me;t[0]===h?me=t[1]:(me=re(h),t[0]=h,t[1]=me);let Z=me,he;t[2]!==Y||t[3]!==J?(he=Y&&J.trim().length>0,t[2]=Y,t[3]=J,t[4]=he):he=t[4];let Q=he,ge,_e;t[5]!==P||t[6]!==n?(ge=()=>{P||L(n)},_e=[P,n],t[5]=P,t[6]=n,t[7]=ge,t[8]=_e):(ge=t[7],_e=t[8]),(0,M.useEffect)(ge,_e);let ve,ye;t[9]===de?(ve=t[10],ye=t[11]):(ye=()=>{H(de)},ve=[de],t[9]=de,t[10]=ve,t[11]=ye),(0,M.useEffect)(ye,ve);let be,xe;t[12]===J?(be=t[13],xe=t[14]):(be=()=>{J.trim()&&G(!0)},xe=[J],t[12]=J,t[13]=be,t[14]=xe),(0,M.useEffect)(be,xe);let Se;t[15]!==Q||t[16]!==W?(Se=()=>{let e=le.current;!e||!Q||!W||ue.current&&(e.scrollTop=e.scrollHeight)},t[15]=Q,t[16]=W,t[17]=Se):Se=t[17];let Ce;t[18]!==Q||t[19]!==J||t[20]!==W?(Ce=[Q,J,W],t[18]=Q,t[19]=J,t[20]=W,t[21]=Ce):Ce=t[21],(0,M.useLayoutEffect)(Se,Ce);let we;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>{let e=le.current;e&&(ue.current=e.scrollHeight-e.scrollTop-e.clientHeight<=ne)},t[22]=we):we=t[22];let Te=we,Ee;t[23]!==g||t[24]!==a||t[25]!==o||t[26]!==D||t[27]!==fe||t[28]!==k||t[29]!==h||t[30]!==w?(Ee=async e=>{oe(`edit`),G(!0),ue.current=!0,await fe({intent:k,scenario:w,input:e,locale:h,field:{id:a,label:o,format:D},context:g})},t[23]=g,t[24]=a,t[25]=o,t[26]=D,t[27]=fe,t[28]=k,t[29]=h,t[30]=w,t[31]=Ee):Ee=t[31];let De=Ee,Oe;t[32]!==pe||t[33]!==n?(Oe=e=>{ce(!!e.currentTarget.closest(`[role="dialog"]`)),q(document.querySelector(`.app-main-surface`)),L(n),B(`preview`),H(``),oe(`edit`),G(!0),pe(),F(!0)},t[32]=pe,t[33]=n,t[34]=Oe):Oe=t[34];let ke=Oe,Ae;t[35]!==I||t[36]!==De?(Ae=async()=>{await De(I)},t[35]=I,t[36]=De,t[37]=Ae):Ae=t[37];let je=Ae,Me;t[38]!==pe||t[39]!==n?(Me=()=>{F(!1),L(n),B(`preview`),H(``),oe(`edit`),G(!0),pe()},t[38]=pe,t[39]=n,t[40]=Me):Me=t[40];let $=Me,Ne;t[41]!==$||t[42]!==I||t[43]!==r?(Ne=()=>{r(I),$()},t[41]=$,t[42]=I,t[43]=r,t[44]=Ne):Ne=t[44];let Pe=Ne,Fe;t[45]!==$||t[46]!==V||t[47]!==r?(Fe=()=>{V.trim()&&(r(V),$())},t[45]=$,t[46]=V,t[47]=r,t[48]=Fe):Fe=t[48];let Ie=Fe,Le;t[49]!==$||t[50]!==I||t[51]!==V||t[52]!==r?(Le=()=>{if(!V.trim())return;let e=I.trimEnd();r(e?`${e}\n\n${V}`:V),$()},t[49]=$,t[50]=I,t[51]=V,t[52]=r,t[53]=Le):Le=t[53];let Re=Le,ze;t[54]!==V||t[55]!==X||t[56]!==Y?(ze=!Y&&!X&&V.trim().length>0,t[54]=V,t[55]=X,t[56]=Y,t[57]=ze):ze=t[57];let Be=ze,Ve=I!==n,He;t[58]!==V||t[59]!==X||t[60]!==J?(He=V.trim().length>0||J.trim().length>0||!!X,t[58]=V,t[59]=X,t[60]=J,t[61]=He):He=t[61];let Ue=He,We=!A&&`size-7 p-0`,Ge;t[62]!==b||t[63]!==We?(Ge=i(`h-7 gap-1 px-2 text-xs`,We,b),t[62]=b,t[63]=We,t[64]=Ge):Ge=t[64];let Ke=y||Y,qe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,R.jsx)(p,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=qe):qe=t[65];let Je=A?Z.buttonTitle:null,Ye;t[66]!==Z.buttonTitle||t[67]!==ke||t[68]!==Ge||t[69]!==Ke||t[70]!==Je?(Ye=(0,R.jsxs)(T,{type:`button`,variant:`ghost`,className:Ge,title:Z.buttonTitle,"aria-label":Z.buttonTitle,disabled:Ke,onClick:ke,children:[qe,Je]}),t[66]=Z.buttonTitle,t[67]=ke,t[68]=Ge,t[69]=Ke,t[70]=Je,t[71]=Ye):Ye=t[71];let Xe;t[72]===$?Xe=t[73]:(Xe=e=>e?F(!0):$(),t[72]=$,t[73]=Xe);let Ze=K??void 0,Qe=se?`bg-transparent`:`bg-scrim`,$e;t[74]===Qe?$e=t[75]:($e=i(`xopc-dialog-overlay absolute inset-0 z-[80]`,Qe),t[74]=Qe,t[75]=$e);let et;t[76]===$e?et=t[77]:(et=(0,R.jsx)(c,{className:$e}),t[76]=$e,t[77]=et);let tt;t[78]===Z.title?tt=t[79]:(tt=(0,R.jsx)(_,{className:`text-base font-semibold text-fg`,children:Z.title}),t[78]=Z.title,t[79]=tt);let nt;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,R.jsx)(j,{className:`size-5`,strokeWidth:1.75}),t[80]=nt):nt=t[80];let rt;t[81]===Z.close?rt=t[82]:(rt=(0,R.jsx)(u,{asChild:!0,children:(0,R.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":Z.close,children:nt})}),t[81]=Z.close,t[82]=rt);let it;t[83]!==tt||t[84]!==rt?(it=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[tt,rt]}),t[83]=tt,t[84]=rt,t[85]=it):it=t[85];let at;t[86]===Z.current?at=t[87]:(at=(0,R.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:Z.current}),t[86]=Z.current,t[87]=at);let ot=z===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,st;t[88]===ot?st=t[89]:(st=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,ot),t[88]=ot,t[89]=st);let ct,lt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ct=()=>B(`edit`),lt=(0,R.jsx)(x,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[90]=ct,t[91]=lt):(ct=t[90],lt=t[91]);let ut;t[92]!==Z.edit||t[93]!==st?(ut=(0,R.jsxs)(`button`,{type:`button`,className:st,onClick:ct,children:[lt,Z.edit]}),t[92]=Z.edit,t[93]=st,t[94]=ut):ut=t[94];let dt=z===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,ft;t[95]===dt?ft=t[96]:(ft=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,dt),t[95]=dt,t[96]=ft);let pt,mt;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>B(`preview`),mt=(0,R.jsx)(l,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[97]=pt,t[98]=mt):(pt=t[97],mt=t[98]);let ht;t[99]!==Z.preview||t[100]!==ft?(ht=(0,R.jsxs)(`button`,{type:`button`,className:ft,onClick:pt,children:[mt,Z.preview]}),t[99]=Z.preview,t[100]=ft,t[101]=ht):ht=t[101];let gt;t[102]!==ut||t[103]!==ht?(gt=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[ut,ht]}),t[102]=ut,t[103]=ht,t[104]=gt):gt=t[104];let _t;t[105]!==at||t[106]!==gt?(_t=(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[at,gt]}),t[105]=at,t[106]=gt,t[107]=_t):_t=t[107];let vt;t[108]!==I||t[109]!==z||t[110]!==D||t[111]!==Z.current||t[112]!==Z.empty?(vt=z===`preview`?(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:D===`markdown`?(0,R.jsx)(C,{content:I||Z.empty,compact:!0,className:`text-sm`}):(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:I||Z.empty})}):(0,R.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:I,onChange:e=>L(e.currentTarget.value),placeholder:Z.empty,"aria-label":Z.current}),t[108]=I,t[109]=z,t[110]=D,t[111]=Z.current,t[112]=Z.empty,t[113]=vt):vt=t[113];let yt;t[114]!==_t||t[115]!==vt?(yt=(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[_t,vt]}),t[114]=_t,t[115]=vt,t[116]=yt):yt=t[116];let bt;t[117]===Z.editedSuggestion?bt=t[118]:(bt=(0,R.jsx)(`span`,{children:Z.editedSuggestion}),t[117]=Z.editedSuggestion,t[118]=bt);let xt;t[119]!==Z.loading||t[120]!==Y?(xt=Y?(0,R.jsx)(`span`,{className:`ml-2 font-normal`,children:Z.loading}):null,t[119]=Z.loading,t[120]=Y,t[121]=xt):xt=t[121];let St;t[122]!==bt||t[123]!==xt?(St=(0,R.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[bt,xt]}),t[122]=bt,t[123]=xt,t[124]=St):St=t[124];let Ct=U===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,wt;t[125]===Ct?wt=t[126]:(wt=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Ct),t[125]=Ct,t[126]=wt);let Tt,Et;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=()=>oe(`edit`),Et=(0,R.jsx)(x,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[127]=Tt,t[128]=Et):(Tt=t[127],Et=t[128]);let Dt;t[129]!==Z.edit||t[130]!==wt?(Dt=(0,R.jsxs)(`button`,{type:`button`,className:wt,onClick:Tt,children:[Et,Z.edit]}),t[129]=Z.edit,t[130]=wt,t[131]=Dt):Dt=t[131];let Ot=U===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,kt;t[132]===Ot?kt=t[133]:(kt=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Ot),t[132]=Ot,t[133]=kt);let At,jt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(At=()=>oe(`preview`),jt=(0,R.jsx)(l,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[134]=At,t[135]=jt):(At=t[134],jt=t[135]);let Mt;t[136]!==Z.preview||t[137]!==kt?(Mt=(0,R.jsxs)(`button`,{type:`button`,className:kt,onClick:At,children:[jt,Z.preview]}),t[136]=Z.preview,t[137]=kt,t[138]=Mt):Mt=t[138];let Nt;t[139]!==Dt||t[140]!==Mt?(Nt=(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[Dt,Mt]}),t[139]=Dt,t[140]=Mt,t[141]=Nt):Nt=t[141];let Pt;t[142]!==St||t[143]!==Nt?(Pt=(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[St,Nt]}),t[142]=St,t[143]=Nt,t[144]=Pt):Pt=t[144];let Ft=Q?`opacity-100`:`pointer-events-none opacity-0`,It;t[145]===Ft?It=t[146]:(It=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ft),t[145]=Ft,t[146]=It);let Lt=!Q,Rt;t[147]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=()=>G(ie),t[147]=Rt):Rt=t[147];let zt;t[148]!==Z.thinkingLoading||t[149]!==Y?(zt=Y?(0,R.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,Z.thinkingLoading]}):null,t[148]=Z.thinkingLoading,t[149]=Y,t[150]=zt):zt=t[150];let Bt;t[151]!==Z.thinking||t[152]!==zt?(Bt=(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Z.thinking,zt]}),t[151]=Z.thinking,t[152]=zt,t[153]=Bt):Bt=t[153];let Vt=W&&`rotate-180`,Ht;t[154]===Vt?Ht=t[155]:(Ht=i(`size-3.5 shrink-0 transition-transform`,Vt),t[154]=Vt,t[155]=Ht);let Ut;t[156]===Ht?Ut=t[157]:(Ut=(0,R.jsx)(E,{className:Ht,strokeWidth:1.75,"aria-hidden":!0}),t[156]=Ht,t[157]=Ut);let Wt;t[158]!==Bt||t[159]!==Ut?(Wt=(0,R.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:Rt,children:[Bt,Ut]}),t[158]=Bt,t[159]=Ut,t[160]=Wt):Wt=t[160];let Gt;t[161]!==J||t[162]!==W?(Gt=W?(0,R.jsx)(`pre`,{ref:le,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:Te,children:J}):null,t[161]=J,t[162]=W,t[163]=Gt):Gt=t[163];let Kt;t[164]!==Wt||t[165]!==Gt?(Kt=(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[Wt,Gt]}),t[164]=Wt,t[165]=Gt,t[166]=Kt):Kt=t[166];let qt;t[167]!==It||t[168]!==Lt||t[169]!==Kt?(qt=(0,R.jsx)(`div`,{className:It,"aria-hidden":Lt,children:Kt}),t[167]=It,t[168]=Lt,t[169]=Kt,t[170]=qt):qt=t[170];let Jt=Q?`pointer-events-none opacity-0`:`opacity-100`,Yt;t[171]===Jt?Yt=t[172]:(Yt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Jt),t[171]=Jt,t[172]=Yt);let Xt;t[173]!==V||t[174]!==X||t[175]!==D||t[176]!==Z.empty||t[177]!==Z.loading||t[178]!==Z.suggestion||t[179]!==Y||t[180]!==U?(Xt=X?(0,R.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:X}):U===`preview`?(0,R.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:Y&&!V.trim()?(0,R.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Z.loading}):D===`markdown`?(0,R.jsx)(C,{content:V||Z.empty,compact:!0,className:`text-sm`}):(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:V||Z.empty})}):(0,R.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:V,onChange:e=>H(e.currentTarget.value),disabled:Y,placeholder:Y?Z.loading:Z.empty,"aria-label":Z.suggestion}),t[173]=V,t[174]=X,t[175]=D,t[176]=Z.empty,t[177]=Z.loading,t[178]=Z.suggestion,t[179]=Y,t[180]=U,t[181]=Xt):Xt=t[181];let Zt;t[182]!==Yt||t[183]!==Xt?(Zt=(0,R.jsx)(`div`,{className:Yt,children:Xt}),t[182]=Yt,t[183]=Xt,t[184]=Zt):Zt=t[184];let Qt;t[185]!==qt||t[186]!==Zt?(Qt=(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[qt,Zt]}),t[185]=qt,t[186]=Zt,t[187]=Qt):Qt=t[187];let $t;t[188]!==Pt||t[189]!==Qt?($t=(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Pt,Qt]}),t[188]=Pt,t[189]=Qt,t[190]=$t):$t=t[190];let en;t[191]!==yt||t[192]!==$t?(en=(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[yt,$t]}),t[191]=yt,t[192]=$t,t[193]=en):en=t[193];let tn;t[194]!==$||t[195]!==Z.cancel?(tn=(0,R.jsx)(T,{type:`button`,variant:`secondary`,onClick:$,children:Z.cancel}),t[194]=$,t[195]=Z.cancel,t[196]=tn):tn=t[196];let nn=!Ve,rn;t[197]!==Pe||t[198]!==Z.applyCurrent||t[199]!==nn?(rn=(0,R.jsx)(T,{type:`button`,variant:`secondary`,disabled:nn,onClick:Pe,children:Z.applyCurrent}),t[197]=Pe,t[198]=Z.applyCurrent,t[199]=nn,t[200]=rn):rn=t[200];let an;t[201]===je?an=t[202]:(an=()=>void je(),t[201]=je,t[202]=an);let on;t[203]===Ue?on=t[204]:(on=Ue?(0,R.jsx)(O,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,R.jsx)(p,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[203]=Ue,t[204]=on);let sn=Ue?Z.regenerate:Z.generate,cn;t[205]!==Y||t[206]!==an||t[207]!==on||t[208]!==sn?(cn=(0,R.jsxs)(T,{type:`button`,variant:`secondary`,disabled:Y,onClick:an,children:[on,sn]}),t[205]=Y,t[206]=an,t[207]=on,t[208]=sn,t[209]=cn):cn=t[209];let ln=!Be,un;t[210]!==Re||t[211]!==Z.append||t[212]!==ln?(un=(0,R.jsx)(T,{type:`button`,variant:`secondary`,disabled:ln,onClick:Re,children:Z.append}),t[210]=Re,t[211]=Z.append,t[212]=ln,t[213]=un):un=t[213];let dn=!Be,fn;t[214]!==Ie||t[215]!==Z.replace||t[216]!==dn?(fn=(0,R.jsx)(T,{type:`button`,variant:`primary`,disabled:dn,onClick:Ie,children:Z.replace}),t[214]=Ie,t[215]=Z.replace,t[216]=dn,t[217]=fn):fn=t[217];let pn;t[218]!==fn||t[219]!==tn||t[220]!==rn||t[221]!==cn||t[222]!==un?(pn=(0,R.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[tn,rn,cn,un,fn]}),t[218]=fn,t[219]=tn,t[220]=rn,t[221]=cn,t[222]=un,t[223]=pn):pn=t[223];let mn;t[224]!==pn||t[225]!==it||t[226]!==en?(mn=(0,R.jsx)(`div`,{className:`absolute inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,R.jsxs)(v,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,onOpenAutoFocus:ae,children:[it,en,pn]})}),t[224]=pn,t[225]=it,t[226]=en,t[227]=mn):mn=t[227];let hn;t[228]!==mn||t[229]!==Ze||t[230]!==et?(hn=(0,R.jsxs)(ee,{container:Ze,children:[et,mn]}),t[228]=mn,t[229]=Ze,t[230]=et,t[231]=hn):hn=t[231];let gn;t[232]!==P||t[233]!==hn||t[234]!==Xe?(gn=(0,R.jsx)(d,{open:P,onOpenChange:Xe,children:hn}),t[232]=P,t[233]=hn,t[234]=Xe,t[235]=gn):gn=t[235];let _n;return t[236]!==gn||t[237]!==Ye?(_n=(0,R.jsxs)(R.Fragment,{children:[Ye,gn]}),t[236]=gn,t[237]=Ye,t[238]=_n):_n=t[238],_n}function ie(e){return!e}function ae(e){return e.preventDefault()}function B(e){return!!(e&&e.type===`object`&&e.properties&&!Array.isArray(e.properties))}function V(e){let t=e.properties??{},n=new Set(e.required??[]);return Object.entries(t).map(([e,t])=>({key:e,schema:t,required:n.has(e)}))}function H(e,t){return!B(e)||!e?!0:V(e).every(e=>{if(!e.required)return!0;let n=t[e.key];return n==null?!1:typeof n==`string`?n.trim().length>0:!0})}function U(e,t){if(e)return B(e.inputSchema)?Object.keys(t.schemaInput).length>0?t.schemaInput:void 0:D(t.argValues)}function oe(e,t,n){let r=a(t).workflows;if(!e)return r.noInputSummary;let i=A(e,t);if(B(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function W(e,t,n=!0){return e?n?B(e.inputSchema)?H(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(f[e.name]??[]).every(e=>!e.required||!!t.argValues[e.key]?.trim())}:{valid:!1,reason:`raw-json`}:{valid:!1}}function G(e,t){return e[t]??t}function se(e,t){let n=f[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function ce(e){let t=(0,N.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,R.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function K(e){let t=(0,N.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:p,aiAssist:m}=e,h;t[0]===u?h=t[1]:(h=u===void 0?[]:u,t[0]=u,t[1]=h);let g=h,_=d===void 0?!0:d,v,y,b,x,S,C,T;if(t[2]!==m||t[3]!==o||t[4]!==g||t[5]!==c||t[6]!==p||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==_||t[11]!==n){b=a(r).workflows;let e=f[n]??[];y=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,p),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{w(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],v=d,x=`flex flex-col gap-3`,S=e.map(e=>{let t=G(b.args,e.labelKey),a=G(b.args,e.placeholderKey),c=o[e.key]??``;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&m?(0,R.jsx)(z,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:m.argScenario??`workflow.arg`,locale:r,context:{...m.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:m.disabled,showLabel:!1}):null]}),e.multiline?(0,R.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,R.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),C=y&&g.length>0?(0,R.jsx)(ce,{examples:g,labels:b,onSelect:v}):null,T=_?(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:b.goalLabel}),m?(0,R.jsx)(z,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:b.goalLabel,scenario:m.goalScenario??`cron.workflowGoal`,locale:r,context:{...m.context,workflowName:n,workflowArgs:o},disabled:m.disabled,showLabel:!1}):null]}),(0,R.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:b.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=m,t[3]=o,t[4]=g,t[5]=c,t[6]=p,t[7]=r,t[8]=s,t[9]=l,t[10]=_,t[11]=n,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=T}else v=t[12],y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],T=t[18];let E;t[23]!==v||t[24]!==g||t[25]!==y||t[26]!==b?(E=!y&&g.length>0?(0,R.jsx)(ce,{examples:g,labels:b,onSelect:v}):null,t[23]=v,t[24]=g,t[25]=y,t[26]=b,t[27]=E):E=t[27];let D;return t[28]!==x||t[29]!==S||t[30]!==C||t[31]!==T||t[32]!==E?(D=(0,R.jsxs)(`div`,{className:x,children:[S,C,T,E]}),t[28]=x,t[29]=S,t[30]=C,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}var q=`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`;function le({schema:e,value:t,onChange:n,labels:r,aiAssist:a,onValidChange:o}){let s=(0,M.useMemo)(()=>V(e),[e]),[c,l]=(0,M.useState)(!1),[u,d]=(0,M.useState)(()=>JSON.stringify(t,null,2)),[f,p]=(0,M.useState)(null);if(s.length===0)return null;let m=(e,r)=>{let i={...t,[e]:r};(r===``||r===void 0)&&delete i[e],n(i),c&&d(JSON.stringify(i,null,2))},h=e=>{d(e);try{let t=e.trim()?JSON.parse(e):{};if(!t||typeof t!=`object`||Array.isArray(t)){p(r.rawJsonInvalid),o?.(!1);return}p(null),n(t),o?.(!0,t)}catch{p(r.rawJsonInvalid),o?.(!1)}};return(0,R.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel/70 p-4 shadow-surface`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.inputSchemaHeading}),(0,R.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>{let e=!c;l(e),e&&(d(JSON.stringify(t,null,2)),p(null),o?.(!0))},children:r.rawJson})]}),c?(0,R.jsxs)(`div`,{className:`mt-3`,children:[(0,R.jsx)(`textarea`,{value:u,onChange:e=>h(e.target.value),spellCheck:!1,className:i(q,`min-h-40 font-mono text-xs leading-5`)}),f?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-300`,children:f}):null]}):(0,R.jsx)(`div`,{className:`mt-3 grid gap-3`,children:s.map(e=>(0,R.jsx)(ue,{field:e,value:t[e.key],labels:r,aiAssist:a,allValues:t,onChange:t=>m(e.key,t)},e.key))})]})}function ue(e){let t=(0,N.c)(30),{field:n,value:r,labels:a,aiAssist:o,allValues:s,onChange:c}=e,l=n.schema.title||n.key,u=typeof n.schema.description==`string`?n.schema.description:void 0,d=Array.isArray(n.schema.type)?n.schema.type[0]:n.schema.type,f;t[0]===n.schema.enum?f=t[1]:(f=Array.isArray(n.schema.enum)?n.schema.enum:[],t[0]=n.schema.enum,t[1]=f);let p=f,h=!!o&&!p.length&&(d===`string`||!d),g=String(l),_=n.required?` *`:``,v;t[2]!==g||t[3]!==_?(v=(0,R.jsxs)(`span`,{className:`text-xs font-medium text-fg`,children:[g,_]}),t[2]=g,t[3]=_,t[4]=v):v=t[4];let y;t[5]!==o||t[6]!==s||t[7]!==n.key||t[8]!==n.schema||t[9]!==c||t[10]!==h||t[11]!==l||t[12]!==r?(y=h&&o?(0,R.jsx)(z,{value:typeof r==`string`?r:r==null?``:String(r),onApply:c,fieldId:`workflow.schema.${n.key}`,fieldLabel:String(l),scenario:o.scenario??`workflow.arg`,locale:o.locale,context:{...o.context,fieldKey:n.key,fieldSchema:n.schema,inputValues:s},disabled:o.disabled,showLabel:!1}):null,t[5]=o,t[6]=s,t[7]=n.key,t[8]=n.schema,t[9]=c,t[10]=h,t[11]=l,t[12]=r,t[13]=y):y=t[13];let x;t[14]!==v||t[15]!==y?(x=(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[v,y]}),t[14]=v,t[15]=y,t[16]=x):x=t[16];let S;t[17]===u?S=t[18]:(S=u?(0,R.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=S);let C;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(C=p.length>0?(0,R.jsxs)(m,{value:r==null?``:String(r),onChange:e=>c(e.target.value),className:q,children:[(0,R.jsx)(b,{value:``}),p.map(de)]}):d===`boolean`?(0,R.jsxs)(m,{value:typeof r==`boolean`?String(r):``,onChange:e=>c(e.target.value===``?void 0:e.target.value===`true`),className:q,children:[(0,R.jsx)(b,{value:``}),(0,R.jsx)(b,{value:`true`,children:a.booleanTrue}),(0,R.jsx)(b,{value:`false`,children:a.booleanFalse})]}):d===`number`||d===`integer`?(0,R.jsx)(`input`,{type:`number`,value:typeof r==`number`||typeof r==`string`?String(r):``,onChange:e=>c(e.target.value===``?void 0:Number(e.target.value)),className:q}):(0,R.jsx)(`textarea`,{value:typeof r==`string`?r:r==null?``:String(r),onChange:e=>c(e.target.value),className:i(q,u&&u.length>80?`min-h-20 resize-y`:`min-h-10 resize-y`)}),t[19]=u,t[20]=p,t[21]=a,t[22]=c,t[23]=d,t[24]=r,t[25]=C):C=t[25];let w;return t[26]!==x||t[27]!==S||t[28]!==C?(w=(0,R.jsxs)(`div`,{className:`block`,children:[x,S,C]}),t[26]=x,t[27]=S,t[28]=C,t[29]=w):w=t[29],w}function de(e){return(0,R.jsx)(b,{value:String(e),children:String(e)},String(e))}function J(e){let t=(0,N.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,R.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,R.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Y(e){let t=(0,N.c)(114),{definition:n,language:r,value:o,onChange:s,aiAssist:c,inputClassName:l,onValidityChange:u}=e,d;t[0]===r?d=t[1]:(d=a(r),t[0]=r,t[1]=d);let f=d.workflows,p;t[2]!==n||t[3]!==r?(p=A(n,r),t[2]=n,t[3]=r,t[4]=p):p=t[4];let m=p,[h,g]=(0,M.useState)(!0),_;t[5]===m.examplePrompts?_=t[6]:(_=m.examplePrompts??[],t[5]=m.examplePrompts,t[6]=_);let v=_,y;t[7]===n.inputSchema?y=t[8]:(y=B(n.inputSchema),t[7]=n.inputSchema,t[8]=y);let b=y,x,S,C,w,T,E,D,ee,O,k;if(t[9]!==c||t[10]!==n||t[11]!==v||t[12]!==b||t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==m.description||t[17]!==s||t[18]!==u||t[19]!==h||t[20]!==o){T=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,l),a;t[31]!==n||t[32]!==s||t[33]!==u||t[34]!==h?(a=(e,t)=>{let r=t===void 0?h:t;s(e),u?.(W(n,e,r))},t[31]=n,t[32]=s,t[33]=u,t[34]=h,t[35]=a):a=t[35];let d=a,p;t[36]!==d||t[37]!==o?(p=e=>d({...o,goal:e}),t[36]=d,t[37]=o,t[38]=p):p=t[38];let _=p,y;t[39]!==d||t[40]!==o?(y=e=>d({...o,schemaInput:e}),t[39]=d,t[40]=o,t[41]=y):y=t[41];let A=y,j;t[42]!==d||t[43]!==o?(j=e=>d({...o,argValues:e}),t[42]=d,t[43]=o,t[44]=j):j=t[44];let M=j,N;if(t[45]!==_||t[46]!==A||t[47]!==o.schemaInput?(N=e=>{if(e.field===`goal`){_(e.text);return}A({...o.schemaInput,[e.field]:e.text})},t[45]=_,t[46]=A,t[47]=o.schemaInput,t[48]=N):N=t[48],x=N,!b){let e;t[49]!==c||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==m.description?(e=c?{disabled:c.disabled,argScenario:c.inputScenario??`workflow.arg`,goalScenario:c.goalScenario??`workflow.goal`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,t[49]=c,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=m.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==v||t[57]!==l||t[58]!==r||t[59]!==M||t[60]!==_||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,R.jsx)(K,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:M,goal:o.goal,onGoalChange:_,examplePrompts:v,inputClassName:l,aiAssist:e}),t[55]=n.name,t[56]=v,t[57]=l,t[58]=r,t[59]=M,t[60]=_,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],T=i;break bb0}C=`flex flex-col gap-3`,t[65]!==c||t[66]!==n||t[67]!==f.booleanFalse||t[68]!==f.booleanTrue||t[69]!==f.inputSchemaHeading||t[70]!==f.rawJson||t[71]!==f.rawJsonInvalid||t[72]!==r||t[73]!==m.description||t[74]!==u||t[75]!==A||t[76]!==o?(w=n.inputSchema?(0,R.jsx)(le,{schema:n.inputSchema,value:o.schemaInput,onChange:A,onValidChange:(e,t)=>{g(e),u?.(W(n,t?{...o,schemaInput:t}:o,e))},aiAssist:c?{locale:r,disabled:c.disabled,scenario:c.inputScenario??`workflow.arg`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,labels:{inputSchemaHeading:f.inputSchemaHeading,rawJson:f.rawJson,rawJsonInvalid:f.rawJsonInvalid,booleanTrue:f.booleanTrue,booleanFalse:f.booleanFalse}}):null,t[65]=c,t[66]=n,t[67]=f.booleanFalse,t[68]=f.booleanTrue,t[69]=f.inputSchemaHeading,t[70]=f.rawJson,t[71]=f.rawJsonInvalid,t[72]=r,t[73]=m.description,t[74]=u,t[75]=A,t[76]=o,t[77]=w):w=t[77],k=`flex flex-col gap-1`;let P;t[78]===f.goalLabel?P=t[79]:(P=(0,R.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:f.goalLabel}),t[78]=f.goalLabel,t[79]=P);let F;t[80]!==c||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==f.goalLabel||t[85]!==r||t[86]!==m.description||t[87]!==_||t[88]!==o.goal||t[89]!==o.schemaInput?(F=c?(0,R.jsx)(z,{value:o.goal,onApply:_,fieldId:`workflow.goal`,fieldLabel:f.goalLabel,scenario:c.goalScenario??`workflow.goal`,locale:r,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description,workflowInput:o.schemaInput},disabled:c.disabled,showLabel:!1}):null,t[80]=c,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=f.goalLabel,t[85]=r,t[86]=m.description,t[87]=_,t[88]=o.goal,t[89]=o.schemaInput,t[90]=F):F=t[90],t[91]!==P||t[92]!==F?(S=(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[P,F]}),t[91]=P,t[92]=F,t[93]=S):S=t[93],E=o.goal,t[94]===_?D=t[95]:(D=e=>_(e.target.value),t[94]=_,t[95]=D),ee=f.goalPlaceholder,O=i(e,`min-h-20 resize-y`)}t[9]=c,t[10]=n,t[11]=v,t[12]=b,t[13]=l,t[14]=f,t[15]=r,t[16]=m.description,t[17]=s,t[18]=u,t[19]=h,t[20]=o,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T,t[26]=E,t[27]=D,t[28]=ee,t[29]=O,t[30]=k}else x=t[21],S=t[22],C=t[23],w=t[24],T=t[25],E=t[26],D=t[27],ee=t[28],O=t[29],k=t[30];if(T!==Symbol.for(`react.early_return_sentinel`))return T;let j;t[96]!==E||t[97]!==D||t[98]!==ee||t[99]!==O?(j=(0,R.jsx)(`textarea`,{value:E,onChange:D,placeholder:ee,className:O}),t[96]=E,t[97]=D,t[98]=ee,t[99]=O,t[100]=j):j=t[100];let P;t[101]!==S||t[102]!==j||t[103]!==k?(P=(0,R.jsxs)(`div`,{className:k,children:[S,j]}),t[101]=S,t[102]=j,t[103]=k,t[104]=P):P=t[104];let F;t[105]!==x||t[106]!==v||t[107]!==f?(F=(0,R.jsx)(J,{examples:v,labels:f,onSelect:x}),t[105]=x,t[106]=v,t[107]=f,t[108]=F):F=t[108];let I;return t[109]!==C||t[110]!==w||t[111]!==P||t[112]!==F?(I=(0,R.jsxs)(`div`,{className:C,children:[w,P,F]}),t[109]=C,t[110]=w,t[111]=P,t[112]=F,t[113]=I):I=t[113],I}function X(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?h(t.agentScaleExact,{count:n.min}):h(t.agentScaleRange,{min:n.min,max:n.max}):h(t.agentScaleExact,{count:e.defaults.maxSubagents})}function fe(e){let t=(0,N.c)(41),{definition:n,language:r,value:o,onChange:s,mode:c,badgeLabel:l,aiAssist:u,inputClassName:d,showTimeout:f,defaultAdvancedOpen:p,onValidityChange:m}=e,_=f===void 0?!1:f,v=p===void 0?!1:p,b=a(r).workflows,[x,C]=(0,M.useState)(v),w;t[0]!==n||t[1]!==r?(w=A(n,r),t[0]=n,t[1]=r,t[2]=w):w=t[2];let T=w,D;t[3]!==n.defaults||t[4]!==o.concurrency?(D=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=D):D=t[5];let ee=D,O;t[6]!==n.defaults||t[7]!==o.maxSubagents?(O=o.maxSubagents.trim()?Number(o.maxSubagents):n.defaults.maxSubagents,t[6]=n.defaults,t[7]=o.maxSubagents,t[8]=O):O=t[8];let j=O,P;t[9]!==n||t[10]!==r||t[11]!==o?(P=oe(n,r,o),t[9]=n,t[10]=r,t[11]=o,t[12]=P):P=t[12];let F=P,I=l??b.readyToStart,L;t[13]!==s||t[14]!==o?(L=e=>s({...o,...e}),t[13]=s,t[14]=o,t[15]=L):L=t[15];let te=L,ne=c===`automation`&&`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,re;t[16]===ne?re=t[17]:(re=i(`space-y-4`,ne),t[16]=ne,t[17]=re);let z=F||T.description,ie;t[18]===z?ie=t[19]:(ie=(0,R.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:z}),t[18]=z,t[19]=ie);let ae;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,R.jsx)(S,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[20]=ae):ae=t[20];let B;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,R.jsx)(y,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=B):B=t[21];let V;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,R.jsx)(k,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=V):V=t[22];let H;t[23]!==s||t[24]!==o?(H=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=H):H=t[25];let U;t[26]===m?U=t[27]:(U=e=>{m?.(e)},t[26]=m,t[27]=U);let W;t[28]!==u||t[29]!==n||t[30]!==d||t[31]!==r||t[32]!==H||t[33]!==U||t[34]!==o?(W=(0,R.jsx)(Y,{definition:n,language:r,value:o,onChange:H,onValidityChange:U,aiAssist:u,inputClassName:d}),t[28]=u,t[29]=n,t[30]=d,t[31]=r,t[32]=H,t[33]=U,t[34]=o,t[35]=W):W=t[35];let G;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>C(pe),t[36]=G):G=t[36];let se=b.advancedSettings,ce=x&&`rotate-180`,K;t[37]===ce?K=t[38]:(K=i(`size-4 transition-transform`,ce),t[37]=ce,t[38]=K);let q;return t[39]===K?q=t[40]:(q=(0,R.jsx)(E,{className:K}),t[39]=K,t[40]=q),(0,R.jsxs)(`div`,{className:re,children:[(0,R.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:b.runPlanPreview}),ie]}),(0,R.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-1 text-[11px] font-medium text-accent-fg`,children:I})]}),(0,R.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-fg-muted sm:grid-cols-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[ae,(0,R.jsx)(`span`,{children:h(b.phaseCount,{count:n.phases.length})})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[B,(0,R.jsx)(`span`,{children:X(n,b)})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[V,(0,R.jsx)(`span`,{children:h(b.runLimitsSummary,{concurrency:ee,max:j})})]})]}),n.phases.length>0?(0,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[(0,R.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),b.startPlanPhases]}),(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:n.phases.map(me)})]}):null]}),W,(0,R.jsxs)(`div`,{className:`rounded-xl border border-edge`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between px-3 py-2.5 text-left text-sm text-fg`,onClick:G,children:[se,q]}),x?(0,R.jsxs)(`div`,{className:`grid gap-3 border-t border-edge px-3 pb-3 pt-3 sm:grid-cols-2`,children:[(0,R.jsx)(`input`,{value:o.concurrency,onChange:e=>te({concurrency:e.target.value}),placeholder:h(b.concurrencyPlaceholder,{default:n.defaults.concurrency}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,R.jsx)(`input`,{value:o.maxSubagents,onChange:e=>te({maxSubagents:e.target.value}),placeholder:h(b.maxSubagentsPlaceholder,{default:n.defaults.maxSubagents}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),_?(0,R.jsx)(`input`,{value:o.timeoutSeconds??``,onChange:e=>te({timeoutSeconds:e.target.value}),placeholder:h(b.timeoutSecondsPlaceholder,{default:n.defaults.timeoutSec}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}):null]}):null]})]})}function pe(e){return!e}function me(e,t){return(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t>0?(0,R.jsx)(`span`,{className:`text-fg-subtle`,children:`→`}):null,(0,R.jsx)(`span`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1 text-[11px] text-fg-muted`,children:e.title})]},e.id)}export{z as a,W as i,se as n,U as r,fe as t};
@@ -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{t as l}from"./cn-JdwAhgNB.js";import{t as u}from"./copy-to-clipboard-HOJ79TWv.js";import{t as d}from"./messages-DMJ-6-1m.js";import{l as f,n as p}from"./locale-store-VOY1wMO9.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$ as h,A as g,B as _,C as v,E as y,F as b,Fa as x,Fl as S,Gs as C,H as w,Ho as T,I as E,Il as D,J as O,Jl as k,K as A,L as j,M,Mc as N,Ml as P,Ms as F,N as I,P as L,Q as R,R as z,Rc as B,S as V,T as H,Ta as U,Ts as W,U as ee,Uo as G,V as te,Vo as ne,W as re,Wc as ie,X as K,Y as ae,Yc as q,Z as oe,Zc as se,_ as ce,_i as le,ac as ue,b as J,ct as de,cu as fe,d as pe,f as me,g as he,h as ge,hc as _e,hs as Y,i as ve,it as ye,iu as be,ji as xe,js as Se,kl as X,ls as Ce,lt as we,m as Te,mr as Ee,nc as De,nu as Oe,ol as ke,ot as Ae,p as je,pc as Me,pl as Ne,q as Pe,qc as Fe,rc as Ie,rt as Le,sr as Re,st as ze,tl as Be,tt as Ve,u as He,ut as Ue,uu as We,v as Ge,vs as Ke,w as qe,x as Je,xs as Ye,y as Xe,yc as Ze,yu as Qe,z as $e}from"./index-DzmbmOGA.js";import{t as et}from"./page-tabs-CvzSdYVj.js";import{i as tt,r as nt,t as rt}from"./workflow-run-setup-panel-DSWG2xqL.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||!$e(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 ye(-r,`second`,n);let i=Math.round(r/60);if(i<60)return ye(-i,`minute`,n);let a=Math.round(i/60);return a<48?ye(-a,`hour`,n):ye(-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:u,onRetry:f}=e,p=d(r).workflows,[m,h]=(0,Z.useState)(!1),g;t[0]===n?g=t[1]:(g=ht(n),t[0]=n,t[1]=g);let v=!g,y;t[2]===n?y=t[3]:(y=Ot(n),t[2]=n,t[3]=y);let b=y,x=n.status===`running`||n.status===`queued`,S;t[4]!==n.metrics.agentCount||t[5]!==n.metrics.doneAgentCount?(S=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]=S):S=t[6];let C=S,w=n.metrics.errorAgentCount>0,T=n.startedAtMs??n.createdAtMs,D=L(b?a-T:n.metrics.durationMs),O=E(p.taskArtifacts,{count:n.metrics.artifactCount}),k;t[7]===n?k=t[8]:(k=yt(n),t[7]=n,t[8]=k);let A=k,j;t[9]===n?j=t[10]:(j=bt(n),t[9]=n,t[10]=j);let M=j,N;t[11]!==s||t[12]!==n?(N=()=>{s(n)},t[11]=s,t[12]=n,t[13]=N):N=t[13];let P=N,F;t[14]!==v||t[15]!==c||t[16]!==n?(F=()=>{v||c(n)},t[14]=v,t[15]=c,t[16]=n,t[17]=F):F=t[17];let I=F,R=o&&`ring-1 ring-accent/30`,z;t[18]===R?z=t[19]:(z=l(`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=l(`w-full text-left`,Ce.focusRingPanel),t[20]=B):B=t[20];let V;t[21]===A?V=t[22]:(V=(0,$.jsx)(`div`,{className:`line-clamp-2 text-sm font-medium leading-5 text-fg`,children:A}),t[21]=A,t[22]=V);let H;t[23]===M?H=t[24]:(H=(0,$.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:M}),t[23]=M,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=l(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,_(n.status)),t[28]=n.status,t[29]=W);let ee;t[30]!==i||t[31]!==a||t[32]!==T?(ee=Dt(T,a,i),t[30]=i,t[31]=a,t[32]=T,t[33]=ee):ee=t[33];let G;t[34]===ee?G=t[35]:(G=(0,$.jsx)(`span`,{children:ee}),t[34]=ee,t[35]=G);let te=D===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:E(p.taskElapsed,{duration:D})})]}),ne;t[36]!==G||t[37]!==te?(ne=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[G,te]}),t[36]=G,t[37]=te,t[38]=ne):ne=t[38];let re=n.metrics.artifactCount>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:O}):null,ie=o?(0,$.jsx)(`span`,{className:`font-medium text-accent-fg`,children:p.taskOpenDetails}):null,K;t[39]!==re||t[40]!==ie?(K=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,children:[re,ie]}),t[39]=re,t[40]=ie,t[41]=K):K=t[41];let ae=v&&`cursor-not-allowed text-fg-disabled hover:bg-transparent`,q;t[42]===ae?q=t[43]:(q=l(`rounded-md px-2 py-1 text-xs font-medium`,`text-accent-fg hover:bg-accent-soft`,Ce.focusRingPanel,ae),t[42]=ae,t[43]=q);let oe;t[44]!==v||t[45]!==I||t[46]!==p.continueInChat||t[47]!==q?(oe=(0,$.jsx)(`button`,{type:`button`,className:q,disabled:v,onClick:I,children:p.continueInChat}),t[44]=v,t[45]=I,t[46]=p.continueInChat,t[47]=q,t[48]=oe):oe=t[48];let se;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(se=l(`rounded-md px-2 py-1 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,Ce.focusRingPanel),t[49]=se):se=t[49];let ce;t[50]!==P||t[51]!==p.taskOpenDetails?(ce=(0,$.jsx)(`button`,{type:`button`,className:se,onClick:P,children:p.taskOpenDetails}),t[50]=P,t[51]=p.taskOpenDetails,t[52]=ce):ce=t[52];let le;t[53]!==oe||t[54]!==ce?(le=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-2`,children:[oe,ce]}),t[53]=oe,t[54]=ce,t[55]=le):le=t[55];let ue;t[56]===h?ue=t[57]:(ue=()=>h(Mt),t[56]=h,t[57]=ue);let J;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(X,{className:`size-4`,"aria-hidden":!0}),t[58]=J):J=t[58];let de;t[59]!==p.taskActionsAria||t[60]!==m||t[61]!==ue?(de=(0,$.jsx)(Y,{variant:`ghost`,className:`size-7 p-0 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,"aria-label":p.taskActionsAria,"aria-expanded":m,onClick:ue,children:J}),t[59]=p.taskActionsAria,t[60]=m,t[61]=ue,t[62]=de):de=t[62];let fe;t[63]!==b||t[64]!==p.cancel||t[65]!==p.rerun||t[66]!==p.taskCloseMenu||t[67]!==m||t[68]!==u||t[69]!==f||t[70]!==n||t[71]!==h?(fe=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-10 cursor-default`,"aria-label":p.taskCloseMenu,onClick:()=>h(!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:[b?(0,$.jsx)(jt,{label:p.cancel,tone:`danger`,onClick:()=>{h(!1),u(n.id)}}):null,kt(n)?(0,$.jsx)(jt,{label:p.rerun,onClick:()=>{h(!1),f(n.id)}}):null]})]}):null,t[63]=b,t[64]=p.cancel,t[65]=p.rerun,t[66]=p.taskCloseMenu,t[67]=m,t[68]=u,t[69]=f,t[70]=n,t[71]=h,t[72]=fe):fe=t[72];let pe;return t[73]!==de||t[74]!==fe?(pe=(0,$.jsxs)(`div`,{className:`absolute right-2 top-2`,children:[de,fe]}),t[73]=de,t[74]=fe,t[75]=pe):pe=t[75],(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:P,"aria-label":`${p.taskOpenDetails}: ${A}`,"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:p.status[n.status]??n.status})]}),ne]}),x?(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:E(p.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{children:[C,`%`]})]}),(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:`${C}%`}})})]}):null,K,w?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(Se,{className:`size-3 shrink-0`,"aria-hidden":!0}),E(p.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null]}),le,pe]})});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=l(`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 u;return t[3]!==r||t[4]!==n||t[5]!==a||t[6]!==c?(u=(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]=u):u=t[7],u}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:u,onCancelRun:f,onRetryRun:p}=e,m=d(r).workflows,[h,g]=(0,Z.useState)(!1),_=n.id===`succeeded`,v=_?5:n.runs.length,y;t[0]!==v||t[1]!==n.runs||t[2]!==h||t[3]!==_?(y=_&&!h?n.runs.slice(0,v):n.runs,t[0]=v,t[1]=n.runs,t[2]=h,t[3]=_,t[4]=y):y=t[4];let b=y,x=_&&n.runs.length>5&&!h,S=_&&h,C;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=l(`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]=C):C=t[5];let w;t[6]===n.runs.length?w=t[7]:(w=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.runs.length}),t[6]=n.runs.length,t[7]=w);let T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=T):T=t[8];let D=s&&b.length===0?(0,$.jsx)(Ft,{}):b.length===0?(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:m.boardColumnEmpty}):b.map(e=>(0,$.jsx)(At,{run:e,language:r,localeTag:i,nowMs:a,selected:e.id===o,onOpen:c,onOpenChat:u,onCancel:f,onRetry:p},e.id)),O=x?(0,$.jsx)(Y,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>g(!0),children:E(m.boardExpandSucceeded,{count:Math.min(n.runs.length,n.totalInWindow??n.runs.length)})}):null,k;t[9]!==S||t[10]!==m||t[11]!==g?(k=S?(0,$.jsx)(Y,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>g(!1),children:m.boardCollapseSucceeded}):null,t[9]=S,t[10]=m,t[11]=g,t[12]=k):k=t[12];let A;return t[13]!==D||t[14]!==O||t[15]!==k?(A=(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:[D,O,k]}),t[13]=D,t[14]=O,t[15]=k,t[16]=A):A=t[16],(0,$.jsxs)(`section`,{className:C,"aria-label":Nt(n.id,m),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,m)}),w]}),T]}),A]})});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)(U,{className:`size-4/5`}),(0,$.jsx)(U,{className:`mt-2 h-3 w-24`})]}),(0,$.jsx)(U,{className:`h-5 w-14 rounded-full`})]}),(0,$.jsx)(U,{className:`mt-3 h-3 w-2/3`}),(0,$.jsx)(U,{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:m,onStart:h}=e,g;t[0]===n?g=t[1]:(g=n.some(Rt),t[0]=n,t[1]=g);let _=g,v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),[b,x]=(0,Z.useState)(zt),[S,C]=(0,Z.useState)(!1),w,T;t[2]===_?(w=t[3],T=t[4]):(w=()=>{if(!_)return;let e=window.setInterval(()=>x(Date.now()),1e3);return()=>window.clearInterval(e)},T=[_],t[2]=_,t[3]=w,t[4]=T),(0,Z.useEffect)(w,T);let E;t[5]!==b||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==s?(E=Et(St(n,{searchQuery:o,workflowFilterId:s,triggerFilter:c}),b),t[5]=b,t[6]=n,t[7]=o,t[8]=c,t[9]=s,t[10]=E):E=t[10];let D=E,O=D.reduce(Bt,0),k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{let t=y.current;!t||t.pointerId!==e.pointerId||(y.current=null,C(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},t[11]=k):k=t[11];let A=k,j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{if(e.button!==0||It(e.target))return;let t=v.current;t&&(y.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},t[12]=j):j=t[12];let M=j,N;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{let t=y.current,n=v.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,C(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},t[13]=N):N=t[13];let P=N;if(!u&&O===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]!==h?(r=(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsx)(Y,{variant:`primary`,onClick:h,children:a.boardStart})}),t[18]=a.boardStart,t[19]=h,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 F=S?`cursor-grabbing select-none`:`cursor-grab`,I;t[25]===F?I=t[26]:(I=[`min-h-0 h-full min-w-0 overflow-x-auto rounded-lg p-2`,F],t[25]=F,t[26]=I);let L=I.join(` `),R;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{y.current?.pointerId===e.pointerId&&(y.current=null,C(!1))},t[27]=R):R=t[27];let z;if(t[28]!==D||t[29]!==r||t[30]!==u||t[31]!==i||t[32]!==b||t[33]!==p||t[34]!==d||t[35]!==f||t[36]!==m||t[37]!==l){let e;t[39]!==r||t[40]!==u||t[41]!==i||t[42]!==b||t[43]!==p||t[44]!==d||t[45]!==f||t[46]!==m||t[47]!==l?(e=e=>(0,$.jsx)(Pt,{column:e,language:r,localeTag:i,nowMs:b,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m},e.id),t[39]=r,t[40]=u,t[41]=i,t[42]=b,t[43]=p,t[44]=d,t[45]=f,t[46]=m,t[47]=l,t[48]=e):e=t[48],z=D.map(e),t[28]=D,t[29]=r,t[30]=u,t[31]=i,t[32]=b,t[33]=p,t[34]=d,t[35]=f,t[36]=m,t[37]=l,t[38]=z}else z=t[38];let B;t[49]===z?B=t[50]:(B=(0,$.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:z}),t[49]=z,t[50]=B);let V;return t[51]!==L||t[52]!==B?(V=(0,$.jsx)(`div`,{ref:v,className:L,onPointerDown:M,onPointerMove:P,onPointerUp:A,onPointerCancel:A,onLostPointerCapture:R,children:B}),t[51]=L,t[52]=B,t[53]=V):V=t[53],V});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?E(t.agentScaleExact,{count:n.min}):E(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 u=c,d;t[3]!==n||t[4]!==i?(d=Vt(n,i),t[3]=n,t[4]=i,t[5]=d):d=t[5];let f=d,p=n.metadata.source===`user`,m=p?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-muted`,h;t[6]===m?h=t[7]:(h=l(`rounded-full px-2 py-0.5 text-[10px] font-medium`,m),t[6]=m,t[7]=h);let g=p?i.badgeUser:i.badgeBuiltin,_;t[8]!==h||t[9]!==g?(_=(0,$.jsx)(`span`,{className:h,children:g}),t[8]=h,t[9]=g,t[10]=_):_=t[10];let v;t[11]!==n.inputSchema||t[12]!==i.inputSchemaBadge?(v=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)(fe,{className:`size-2.5`,"aria-hidden":!0}),i.inputSchemaBadge]}):null,t[11]=n.inputSchema,t[12]=i.inputSchemaBadge,t[13]=v):v=t[13];let y;t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=l(`mt-2 line-clamp-2 text-left text-sm font-semibold leading-5 text-fg hover:text-accent-fg`,Ce.focusRingPanel),t[17]=b):b=t[17];let x;t[18]!==n||t[19]!==o?(x=()=>o(n),t[18]=n,t[19]=o,t[20]=x):x=t[20];let S;t[21]!==n.title||t[22]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:b,onClick:x,children:n.title}),t[21]=n.title,t[22]=x,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==y?(C=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,S]}),t[24]=S,t[25]=y,t[26]=C):C=t[26];let w=`${p?i.editWorkflow:i.copyAndEditWorkflow}: ${n.title}`,T;t[27]!==n||t[28]!==s?(T=()=>s(n),t[27]=n,t[28]=s,t[29]=T):T=t[29];let O;t[30]===p?O=t[31]:(O=p?(0,$.jsx)(Ze,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t[30]=p,t[31]=O);let k;t[32]!==w||t[33]!==T||t[34]!==O?(k=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":w,onClick:T,children:O}),t[32]=w,t[33]=T,t[34]=O,t[35]=k):k=t[35];let A;t[36]!==C||t[37]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[C,k]}),t[36]=C,t[37]=k,t[38]=A):A=t[38];let j=u.whenToUse||u.description||n.description,M;t[39]===j?M=t[40]:(M=(0,$.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:j}),t[39]=j,t[40]=M);let N;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(se,{className:`size-3`,"aria-hidden":!0}),t[41]=N):N=t[41];let P;t[42]!==n.phases.length||t[43]!==i.phaseCount?(P=E(i.phaseCount,{count:n.phases.length}),t[42]=n.phases.length,t[43]=i.phaseCount,t[44]=P):P=t[44];let F;t[45]===P?F=t[46]:(F=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[N,P]}),t[45]=P,t[46]=F);let I;t[47]===f?I=t[48]:(I=f?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(W,{className:`size-3`,"aria-hidden":!0}),f]}):null,t[47]=f,t[48]=I);let L;t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-3 pt-4 text-[11px] text-fg-subtle`,children:[F,I]}),t[49]=F,t[50]=I,t[51]=L):L=t[51];let R;t[52]!==n||t[53]!==a?(R=()=>a(n),t[52]=n,t[53]=a,t[54]=R):R=t[54];let z;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),t[55]=z):z=t[55];let B;t[56]!==i.configureAndRun||t[57]!==R?(B=(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`h-8 flex-1 rounded-lg text-xs`,onClick:R,children:[z,i.configureAndRun]}),t[56]=i.configureAndRun,t[57]=R,t[58]=B):B=t[58];let V;t[59]!==n||t[60]!==o?(V=()=>o(n),t[59]=n,t[60]=o,t[61]=V):V=t[61];let H;t[62]!==i.viewDetails||t[63]!==V?(H=(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:V,children:i.viewDetails}),t[62]=i.viewDetails,t[63]=V,t[64]=H):H=t[64];let U;t[65]!==B||t[66]!==H?(U=(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[B,H]}),t[65]=B,t[66]=H,t[67]=U):U=t[67];let ee;return t[68]!==A||t[69]!==M||t[70]!==L||t[71]!==U?(ee=(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:[A,M,L,U]}),t[68]=A,t[69]=M,t[70]=L,t[71]=U,t[72]=ee):ee=t[72],ee}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),u=d(i).workflows,f=i===`zh`?`zh-CN`:`en-US`,[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(`all`),[_,v]=(0,Z.useState)(`all`),y;t[0]!==h||t[1]!==n||t[2]!==p||t[3]!==_?(y=I(n,p,h,_),t[0]=h,t[1]=n,t[2]=p,t[3]=_,t[4]=y):y=t[4];let b=y,x;if(t[5]!==n||t[6]!==r){let e=new Map(n.map(Gt)),i=new Set;x=[...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]=x}else x=t[7];let S=x,C=E(u.workflowCount,{count:b.length}),w;t[8]===C?w=t[9]:(w=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:C}),t[8]=C,t[9]=w);let D=u.sourceFilterAria,O;t[10]!==u.sources||t[11]!==v||t[12]!==_?(O=K.map(e=>(0,$.jsx)(`button`,{type:`button`,className:l(`h-8 rounded-md px-2.5 text-xs font-medium transition-colors`,_===e?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`,Ce.focusRingPanel),"aria-pressed":_===e,onClick:()=>v(e),children:u.sources[e]},e)),t[10]=u.sources,t[11]=v,t[12]=_,t[13]=O):O=t[13];let k;t[14]!==u.sourceFilterAria||t[15]!==O?(k=(0,$.jsx)(`div`,{className:`flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":D,children:O}),t[14]=u.sourceFilterAria,t[15]=O,t[16]=k):k=t[16];let j=u.categoryFilterAria,M;t[17]===g?M=t[18]:(M=e=>g(e.target.value),t[17]=g,t[18]=M);let N;t[19]===u.categories?N=t[20]:(N=A.map(e=>(0,$.jsx)(G,{value:e,children:u.categories[e]},e)),t[19]=u.categories,t[20]=N);let P;t[21]!==h||t[22]!==u.categoryFilterAria||t[23]!==M||t[24]!==N?(P=(0,$.jsx)(T,{value:h,"aria-label":j,onChange:M,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:N}),t[21]=h,t[22]=u.categoryFilterAria,t[23]=M,t[24]=N,t[25]=P):P=t[25];let F;t[26]!==P||t[27]!==k?(F=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k,P]}),t[26]=P,t[27]=k,t[28]=F):F=t[28];let L;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(De,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[29]=L):L=t[29];let R;t[30]===m?R=t[31]:(R=e=>m(e.target.value),t[30]=m,t[31]=R);let z=u.librarySearchPlaceholder,B;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(B=l(`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`,Ce.focusRingPanel),t[32]=B):B=t[32];let V;t[33]!==u.librarySearchPlaceholder||t[34]!==p||t[35]!==R?(V=(0,$.jsxs)(`div`,{className:`relative max-w-xl`,children:[L,(0,$.jsx)(`input`,{value:p,onChange:R,placeholder:z,className:B})]}),t[33]=u.librarySearchPlaceholder,t[34]=p,t[35]=R,t[36]=V):V=t[36];let H;return t[37]!==b||t[38]!==u||t[39]!==i||t[40]!==o||t[41]!==s||t[42]!==a?(H=b.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:u.noDefinitions}),(0,$.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-5 text-fg-muted`,children:u.noDefinitionsHint})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pt-4 sm:grid-cols-2 xl:grid-cols-3`,children:b.map(e=>(0,$.jsx)(Ht,{definition:e,language:i,labels:u,onPick:a,onDetail:o,onEdit:s},e.id))}),t[37]=b,t[38]=u,t[39]=i,t[40]=o,t[41]=s,t[42]=a,t[43]=H):H=t[43],(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5`,children:[S.length>0&&!p&&h===`all`&&_===`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:u.recentlyUsed}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:S.map(e=>{let{definition:t,lastRunAtMs:n}=e;return(0,$.jsxs)(`button`,{type:`button`,className:l(`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`,Ce.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)(_e,{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:u.allWorkflows}),w]}),F]}),V]}),H]})]})}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:u}=e,f,p,m,h,g,v,y,b,x,S,C,w,T,D,O,k,A;if(t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==n){m=d(r).workflows;let e;t[22]===n?e=t[23]:(e=Ot(n),t[22]=n,t[23]=e),f=e;let s;t[24]===n?s=t[25]:(s=kt(n),t[24]=n,t[25]=s),h=s;let c;t[26]===n?c=t[27]:(c=ht(n),t[26]=n,t[27]=c),p=!!c;let u=n.startedAtMs??n.createdAtMs,j=L(f?a-u: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;x=`group border-b border-edge-subtle last:border-b-0`,b=`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`,k=`button`,t[31]!==o||t[32]!==n?(A=()=>o(n),t[31]=o,t[32]=n,t[33]=A):A=t[33],t[34]===Symbol.for(`react.memo_cache_sentinel`)?(v=l(`min-w-0 flex-1 text-left`,Ce.focusRingPanel),t[34]=v):v=t[34];let P=m.taskOpenDetails,F;t[35]===n?F=t[36]:(F=yt(n),t[35]=n,t[36]=F),y=`${P}: ${F}`,D=`flex min-w-0 items-start gap-3`;let I;t[37]===n.status?I=t[38]:(I=l(`mt-0.5 shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold`,_(n.status)),t[37]=n.status,t[38]=I),O=(0,$.jsx)(`span`,{className:I,children:m.status[n.status]??n.status}),g=`min-w-0 flex-1`;let R;t[39]===n?R=t[40]:(R=yt(n),t[39]=n,t[40]=R),t[41]===R?S=t[42]:(S=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:R}),t[41]=R,t[42]=S);let z;t[43]===n?z=t[44]:(z=bt(n),t[43]=n,t[44]=z);let B;t[45]===z?B=t[46]:(B=(0,$.jsx)(`span`,{className:`truncate font-medium`,children:z}),t[45]=z,t[46]=B);let V;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[47]=V):V=t[47];let H;t[48]!==i||t[49]!==a||t[50]!==u?(H=Dt(u,a,i),t[48]=i,t[49]=a,t[50]=u,t[51]=H):H=t[51];let U;t[52]===H?U=t[53]:(U=(0,$.jsx)(`span`,{children:H}),t[52]=H,t[53]=U);let W=j===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:E(m.taskElapsed,{duration:j})})]});t[54]!==B||t[55]!==U||t[56]!==W?(C=(0,$.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[B,V,U,W]}),t[54]=B,t[55]=U,t[56]=W,t[57]=C):C=t[57],w=f&&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:E(m.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,T=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)(Se,{className:`size-3 shrink-0`,"aria-hidden":!0}),E(m.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null,t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=n,t[5]=f,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=v,t[11]=y,t[12]=b,t[13]=x,t[14]=S,t[15]=C,t[16]=w,t[17]=T,t[18]=D,t[19]=O,t[20]=k,t[21]=A}else f=t[5],p=t[6],m=t[7],h=t[8],g=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],D=t[18],O=t[19],k=t[20],A=t[21];let j;t[58]!==g||t[59]!==S||t[60]!==C||t[61]!==w||t[62]!==T?(j=(0,$.jsxs)(`span`,{className:g,children:[S,C,w,T]}),t[58]=g,t[59]=S,t[60]=C,t[61]=w,t[62]=T,t[63]=j):j=t[63];let M;t[64]!==j||t[65]!==D||t[66]!==O?(M=(0,$.jsxs)(`div`,{className:D,children:[O,j]}),t[64]=j,t[65]=D,t[66]=O,t[67]=M):M=t[67];let N;t[68]!==v||t[69]!==y||t[70]!==M||t[71]!==k||t[72]!==A?(N=(0,$.jsx)(`button`,{type:k,onClick:A,className:v,"aria-label":y,children:M}),t[68]=v,t[69]=y,t[70]=M,t[71]=k,t[72]=A,t[73]=N):N=t[73];let P;t[74]!==m.rerun||t[75]!==u||t[76]!==h||t[77]!==n.id?(P=h?(0,$.jsx)(Y,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>u(n.id),children:m.rerun}):null,t[74]=m.rerun,t[75]=u,t[76]=h,t[77]=n.id,t[78]=P):P=t[78];let F;t[79]!==p||t[80]!==m.continueInChat||t[81]!==s||t[82]!==n?(F=n.status===`succeeded`&&p?(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>s(n),children:m.continueInChat}):null,t[79]=p,t[80]=m.continueInChat,t[81]=s,t[82]=n,t[83]=F):F=t[83];let I;t[84]!==f||t[85]!==m.cancel||t[86]!==c||t[87]!==n.id?(I=f?(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg text-xs text-red-600 dark:text-red-300`,onClick:()=>c(n.id),children:m.cancel}):null,t[84]=f,t[85]=m.cancel,t[86]=c,t[87]=n.id,t[88]=I):I=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)(Oe,{className:`size-4`,"aria-hidden":!0}),t[92]=z):z=t[92];let B;t[93]!==m.taskOpenDetails||t[94]!==R?(B=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":m.taskOpenDetails,onClick:R,children:z}),t[93]=m.taskOpenDetails,t[94]=R,t[95]=B):B=t[95];let V;t[96]!==P||t[97]!==F||t[98]!==I||t[99]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1.5 pl-7 lg:pl-0`,children:[P,F,I,B]}),t[96]=P,t[97]=F,t[98]=I,t[99]=B,t[100]=V):V=t[100];let H;t[101]!==b||t[102]!==N||t[103]!==V?(H=(0,$.jsxs)(`div`,{className:b,children:[N,V]}),t[101]=b,t[102]=N,t[103]=V,t[104]=H):H=t[104];let U;return t[105]!==x||t[106]!==H?(U=(0,$.jsx)(`article`,{className:x,children:H}),t[105]=x,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:l,refreshAll:u}=n,f;t[0]!==c||t[1]!==r.agentFilterAria||t[2]!==i||t[3]!==o||t[4]!==l?(f=c.length>1?(0,$.jsx)(T,{value:o??``,"aria-label":r.agentFilterAria,onChange:e=>l(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)(G,{value:e.id,children:Re(e,d(i).agentsSettings)},e.id))}):null,t[0]=c,t[1]=r.agentFilterAria,t[2]=i,t[3]=o,t[4]=l,t[5]=f):f=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Me,{className:`size-4`,"aria-hidden":!0}),t[6]=p):p=t[6];let m;t[7]===r.addWorkflow?m=t[8]:(m=(0,$.jsx)(Y,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(s,{to:`/workflows/new`,children:[p,r.addWorkflow]})}),t[7]=r.addWorkflow,t[8]=m);let h;t[9]!==r.refresh||t[10]!==a||t[11]!==u?(h=(0,$.jsx)(xe,{className:`size-9 shrink-0 p-0`,loading:a,label:r.refresh,onClick:u}),t[9]=r.refresh,t[10]=a,t[11]=u,t[12]=h):h=t[12];let g;return t[13]!==f||t[14]!==m||t[15]!==h?(g=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[f,m,h]}),t[13]=f,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}var Yt=new Set([`failed`,`timeout`,`cancelled`]),Xt=[{id:`runs`,icon:ie},{id:`library`,icon:Fe}],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)(U,{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)(U,{className:`h-4 w-52 max-w-full`}),(0,$.jsx)(U,{className:`mt-2 h-3 w-36 max-w-full`})]}),(0,$.jsx)(U,{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:u,setSearchQuery:d,workflowFilterId:f,setWorkflowFilterId:p,triggerFilter:m,setTriggerFilter:h,statusFilter:g,setStatusFilter:_,clearRunFilters:v,pageTab:y,setPageTab:b,runLayout:S,setRunLayout:C,openRunDetails:w,openRunInChat:E,openDefinitionDetails:D,openWorkflowEditor:O,startWorkflow:k,actionError:A,loading:j,error:M,cancelRun:N,retryRun:P}=n,F=x(cn),I=x(sn),L=Date.now(),R=en(c.filter(Qt)),z;t[0]===g?z=t[1]:(z=e=>$t(e,g),t[0]=g,t[1]=z);let V=en(St(c,{searchQuery:u,workflowFilterId:f,triggerFilter:m}).filter(z)),H=!!(u||f||m!==`all`||g!==`all`),U,W;if(t[2]!==I||t[3]!==o||t[4]!==a.librarySubtitle||t[5]!==a.runsSubtitle||t[6]!==a.title||t[7]!==y||t[8]!==F||t[9]!==n?(U=()=>{if(!o){I();return}return F({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:y===`runs`?a.runsSubtitle:a.librarySubtitle})]}),end:(0,$.jsx)(Jt,{vm:n})}),()=>I()},W=[I,o,a.librarySubtitle,a.runsSubtitle,a.title,y,F,n],t[2]=I,t[3]=o,t[4]=a.librarySubtitle,t[5]=a.runsSubtitle,t[6]=a.title,t[7]=y,t[8]=F,t[9]=n,t[10]=U,t[11]=W):(U=t[10],W=t[11]),(0,Z.useLayoutEffect)(U,W),!o){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Ne,{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,te=Xt.map(e=>{let{id:t,icon:n}=e;return(0,$.jsxs)(`button`,{id:`workflow-tab-${t}`,type:`button`,role:`tab`,"aria-selected":y===t,"aria-controls":`workflow-panel-${t}`,tabIndex:y===t?0:-1,draggable:!1,className:l(`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`,y===t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>b(t),onKeyDown:e=>{let n=tn(e.key,t);n&&(e.preventDefault(),b(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`&&R.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:R.length}):null]},t)}),ne;t[20]!==a.pageTabsAria||t[21]!==te?(ne=(0,$.jsx)(`nav`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,"aria-label":ee,role:`tablist`,children:te}),t[20]=a.pageTabsAria,t[21]=te,t[22]=ne):ne=t[22];let re;t[23]!==A||t[24]!==M?(re=A??M?(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:A??M}):null,t[23]=A,t[24]=M,t[25]=re):re=t[25];let ie=y===`runs`?(0,$.jsxs)(`div`,{id:`workflow-panel-runs`,role:`tabpanel`,"aria-labelledby":`workflow-tab-runs`,className:`flex flex-col gap-4 py-4`,children:[R.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)(Se,{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:R.length})]}),(0,$.jsxs)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:[yt(R[0]),` · `,Dt(R[0].completedAtMs??R[0].createdAtMs,L,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)(Y,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>w(R[0]),children:a.attentionView}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>void P(R[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)(De,{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:u,onChange:e=>d(e.target.value),placeholder:a.runsSearchPlaceholder,className:l(`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`,Ce.focusRingPanel)})]}),(0,$.jsx)(T,{value:g,"aria-label":a.statusFilterAria,onChange:e=>_(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)(G,{value:e,children:a.runStatuses[e]},e))}),(0,$.jsxs)(T,{value:m,"aria-label":a.boardTriggerFilterAria,onChange:e=>h(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)(G,{value:`all`,children:a.boardTriggerFilterAll}),(0,$.jsx)(G,{value:`automation`,children:a.boardTriggerFilterAutomation}),(0,$.jsx)(G,{value:`webui`,children:a.boardTriggerFilterWebui}),(0,$.jsx)(G,{value:`chat`,children:a.boardTriggerFilterChat}),(0,$.jsx)(G,{value:`api`,children:a.boardTriggerFilterApi})]}),(0,$.jsxs)(T,{value:f,"aria-label":a.boardWorkflowFilterAria,onChange:e=>p(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)(G,{value:``,children:a.boardWorkflowFilterAll}),s.map(on)]}),H?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:v,children:[(0,$.jsx)(Ke,{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:l(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,S===`list`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,Ce.focusRingPanel),"aria-pressed":S===`list`,onClick:()=>C(`list`),children:[(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.list]}),(0,$.jsxs)(`button`,{type:`button`,className:l(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,S===`board`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,Ce.focusRingPanel),"aria-pressed":S===`board`,onClick:()=>C(`board`),children:[(0,$.jsx)(q,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.board]})]})]})}),S===`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:V.length})]}),j&&V.length===0?Array.from({length:4}).map(an):V.length>0?V.map(e=>(0,$.jsx)(qt,{run:e,language:r,localeTag:i,nowMs:L,onOpen:w,onOpenChat:E,onCancel:e=>void N(e),onRetry:e=>void P(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)(Ne,{className:`size-8 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`mt-3 text-sm font-semibold text-fg`,children:H?a.noRunResultsTitle:a.noRunsTitle}),(0,$.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-5 text-fg-muted`,children:H?a.noRunResultsHint:a.noRunsStartHint}),(0,$.jsx)(Y,{type:`button`,variant:H?`secondary`:`primary`,className:`mt-4 h-9 rounded-lg text-xs`,onClick:H?v:()=>b(`library`),children:H?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:V,language:r,localeTag:i,labels:{boardEmptyTitle:a.boardEmptyTitle,boardEmptyHint:a.boardEmptyHint,boardStart:a.chooseWorkflow,loading:a.loading},searchQuery:``,workflowFilterId:``,triggerFilter:`all`,selectedRunId:null,loading:j,onOpenRun:w,onOpenRunChat:E,onCancelRun:e=>void N(e),onRetryRun:e=>void P(e),onStart:()=>b(`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:k,onDetail:D,onEdit:O})]}),K;return t[26]!==re||t[27]!==ie||t[28]!==ne?(K=(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:[ne,re,ie]})}),t[26]=re,t[27]=ie,t[28]=ne,t[29]=K):K=t[29],K}function an(e,t){return(0,$.jsx)(nn,{},t)}function on(e){return(0,$.jsx)(G,{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=p(mn),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.workflows,i=t===`zh`?`zh-CN`:`en-US`,s=f(pn),c=!!s,l=o(),[u,g]=a(),_;e[2]===u?_=e[3]:(_=u.get(`q`)??``,e[2]=u,e[3]=_);let v=_,y;e[4]===u?y=e[5]:(y=u.get(`wf`)?.trim()??``,e[4]=u,e[5]=y);let b=y,x;e[6]===u?x=e[7]:(x=u.get(`trigger`)?.trim()||`all`,e[6]=u,e[7]=x);let S=x,C,w,T,E;if(e[8]!==u){let t=u.get(`status`)?.trim()??``,n=u.get(`tab`)?.trim()??``,r=u.get(`layout`)?.trim()??``;C=u.get(`agent`)?.trim()??``,w=Pe.has(n)?n:`runs`,T=ae.has(r)?r:`list`,E=R.has(t)?t:`all`,e[8]=u,e[9]=C,e[10]=w,e[11]=T,e[12]=E}else C=e[9],w=e[10],T=e[11],E=e[12];let D=E,[k,A]=(0,Z.useState)(null),j;e[13]!==c||e[14]!==s?(j=c?[`workflow-agents`,s]:null,e[13]=c,e[14]=s,e[15]=j):j=e[15];let M;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(M={revalidateOnFocus:!1},e[16]=M):M=e[16];let N=m(j,Ee,M),P;bb0:{let e=N.data?.agents??[];if(C&&(e.length===0||e.some(e=>e.id===C))){P=C;break bb0}P=N.data?.defaultId}let F=P,I;e[17]!==c||e[18]!==s?(I=c?[`workflow-definitions`,s]:null,e[17]=c,e[18]=s,e[19]=I):I=e[19];let L;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[20]=L):L=e[20];let z=m(I,ce,L),B;e[21]!==c||e[22]!==F||e[23]!==s?(B=c&&F?[`workflow-runs`,s,F]:null,e[21]=c,e[22]=F,e[23]=s,e[24]=B):B=e[24];let H;e[25]===F?H=e[26]:(H=()=>Xe(100,{ownerAgentId:F}),e[25]=F,e[26]=H);let U;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(U={revalidateOnFocus:!1,refreshInterval:dn},e[27]=U):U=e[27];let W=m(B,H,U),ee;e[28]===z.data?ee=e[29]:(ee=z.data??[],e[28]=z.data,e[29]=ee);let G=ee,ne;e[30]===W.data?ne=e[31]:(ne=W.data??[],e[30]=W.data,e[31]=ne);let ie=ne,K;e[32]===g?K=e[33]:(K=e=>{g(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},e[32]=g,e[33]=K);let q=K,se;e[34]===q?se=e[35]:(se=e=>q(t=>{let n=e.trim();n?t.set(`q`,n):t.delete(`q`)}),e[34]=q,e[35]=se);let le=se,ue;e[36]===q?ue=e[37]:(ue=e=>q(t=>{let n=e.trim();n?t.set(re,n):t.delete(re)}),e[36]=q,e[37]=ue);let J=ue,de;e[38]===q?de=e[39]:(de=e=>q(t=>{let n=e.trim();n?t.set(`wf`,n):t.delete(`wf`)}),e[38]=q,e[39]=de);let fe=de,me;e[40]===q?me=e[41]:(me=e=>q(t=>{e&&e!==`all`?t.set(h,e):t.delete(h)}),e[40]=q,e[41]=me);let he=me,ge;e[42]===q?ge=e[43]:(ge=e=>q(t=>{e===`runs`?t.delete(`tab`):t.set(`tab`,e)}),e[42]=q,e[43]=ge);let _e=ge,Y;e[44]===q?Y=e[45]:(Y=e=>q(t=>{e===`list`?t.delete(O):t.set(O,e)}),e[44]=q,e[45]=Y);let ve=Y,ye;e[46]===q?ye=e[47]:(ye=e=>q(t=>{e===`all`?t.delete(oe):t.set(oe,e)}),e[46]=q,e[47]=ye);let be=ye,xe;e[48]===q?xe=e[49]:(xe=()=>q(un),e[48]=q,e[49]=xe);let Se=xe,X=F?`?agentId=${encodeURIComponent(F)}`:``,Ce;e[50]!==l||e[51]!==X?(Ce=e=>l(`/workflows/${e.id}${X}`),e[50]=l,e[51]=X,e[52]=Ce):Ce=e[52];let we=Ce,Te=we,De;e[53]!==l||e[54]!==F||e[55]!==X?(De=e=>{l(e.metadata.source===`user`?`/workflows/${e.id}/edit${X}`:`/workflows/new?copy=${encodeURIComponent(e.id)}${F?`&agentId=${encodeURIComponent(F)}`:``}`)},e[53]=l,e[54]=F,e[55]=X,e[56]=De):De=e[56];let Oe=De,ke;e[57]!==l||e[58]!==X?(ke=e=>l(`/workflows/runs/${e.id}${X}`),e[57]=l,e[58]=X,e[59]=ke):ke=e[59];let Ae=ke,je;e[60]===l?je=e[61]:(je=e=>{let t=ht(e);t&&l(te(t))},e[60]=l,e[61]=je);let Me=je,Ne;e[62]!==r.cancelFailed||e[63]!==F||e[64]!==W?(Ne=async e=>{try{await pe(e,{ownerAgentId:F}),await W.mutate()}catch(e){let t=e;A(t instanceof Error?t.message:r.cancelFailed)}},e[62]=r.cancelFailed,e[63]=F,e[64]=W,e[65]=Ne):Ne=e[65];let Fe=Ne,Ie;e[66]!==r.retryFailed||e[67]!==l||e[68]!==F||e[69]!==X?(Ie=async e=>{try{l(`/workflows/runs/${(await V(e,{ownerAgentId:F})).runId}${X}`)}catch(e){let t=e;A(t instanceof Error?t.message:r.retryFailed)}},e[66]=r.retryFailed,e[67]=l,e[68]=F,e[69]=X,e[70]=Ie):Ie=e[70];let Le=Ie,Re,ze;e[71]===W?(Re=e[72],ze=e[73]):(Re=()=>{let e=()=>void W.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)}},ze=[W],e[71]=W,e[72]=Re,e[73]=ze),(0,Z.useEffect)(Re,ze);let Be;e[74]!==N||e[75]!==z||e[76]!==W?(Be=()=>{Promise.all([N.mutate(),z.mutate(),W.mutate()])},e[74]=N,e[75]=z,e[76]=W,e[77]=Be):Be=e[77];let Ve=Be,He=N.isLoading||z.isLoading||W.isLoading,Ue=N.error?.message??z.error?.message??W.error?.message??null,We;e[78]===N.data?.agents?We=e[79]:(We=N.data?.agents??[],e[78]=N.data?.agents,e[79]=We);let Ge;return e[80]!==k||e[81]!==Fe||e[82]!==Se||e[83]!==G||e[84]!==Ue||e[85]!==c||e[86]!==r||e[87]!==t||e[88]!==He||e[89]!==i||e[90]!==we||e[91]!==Ae||e[92]!==Me||e[93]!==Oe||e[94]!==F||e[95]!==w||e[96]!==Ve||e[97]!==Le||e[98]!==T||e[99]!==ie||e[100]!==v||e[101]!==J||e[102]!==_e||e[103]!==ve||e[104]!==le||e[105]!==be||e[106]!==he||e[107]!==fe||e[108]!==Te||e[109]!==D||e[110]!==We||e[111]!==S||e[112]!==b?(Ge={language:t,localeTag:i,labels:r,hasToken:c,searchQuery:v,setSearchQuery:le,ownerAgentId:F,agentOptions:We,setOwnerAgentId:J,workflowFilterId:b,setWorkflowFilterId:fe,triggerFilter:S,setTriggerFilter:he,statusFilter:D,setStatusFilter:be,clearRunFilters:Se,pageTab:w,setPageTab:_e,runLayout:T,setRunLayout:ve,definitions:G,runs:ie,openDefinitionDetails:we,startWorkflow:Te,openWorkflowEditor:Oe,openRunDetails:Ae,openRunInChat:Me,actionError:k,loading:He,error:Ue,refreshAll:Ve,cancelRun:Fe,retryRun:Le},e[80]=k,e[81]=Fe,e[82]=Se,e[83]=G,e[84]=Ue,e[85]=c,e[86]=r,e[87]=t,e[88]=He,e[89]=i,e[90]=we,e[91]=Ae,e[92]=Me,e[93]=Oe,e[94]=F,e[95]=w,e[96]=Ve,e[97]=Le,e[98]=T,e[99]=ie,e[100]=v,e[101]=J,e[102]=_e,e[103]=ve,e[104]=le,e[105]=be,e[106]=he,e[107]=fe,e[108]=Te,e[109]=D,e[110]=We,e[111]=S,e[112]=b,e[113]=Ge):Ge=e[113],Ge}function un(e){e.delete(`q`),e.delete(`wf`),e.delete(h),e.delete(oe)}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:u,onClearSaveConflict:d,onReloadLatest:f}){let p=zn(e),[m,h]=(0,Z.useState)(`my_workflow`),[g,_]=(0,Z.useState)(()=>Mn()),[b,x]=(0,Z.useState)(()=>({title:p.untitled,description:``,tags:[`custom`]})),[S,w]=(0,Z.useState)(`agent-1`),[T,E,D]=dt(g.nodes.map(e=>An(e,e.id===`agent-1`))),[O,k]=(0,Z.useState)(``),[A,j]=(0,Z.useState)(``),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)(!!r),[B,V]=(0,Z.useState)(null),[H,U]=(0,Z.useState)(`idle`),[W,ee]=(0,Z.useState)(0),[G,te]=(0,Z.useState)([]),[ne,re]=(0,Z.useState)(null),ie=(0,Z.useRef)(``),K=(0,Z.useRef)(``),ae=(0,Z.useRef)(void 0),q=(0,Z.useRef)(void 0),oe=(0,Z.useRef)(!1),ce=(0,Z.useRef)(null),[le,J]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=`${r?.mode??`new`}:${r?.name??i}:${r?.baseRevision??0}:${r?.repairPrompt??``}`;ie.current!==e&&(ie.current=e,h(r?.name??i),_(structuredClone(r?.graph??Mn())),J(e=>e+1),x(structuredClone(r?.manifest??{title:p.untitled,description:``,tags:[`custom`]})),w(r?.graph.nodes.find(e=>e.kind===`agent`)?.id??`agent-1`),k(r?.repairPrompt??``),F(null),L(null),z(!!r),j(``),V(null),ee(r?.baseRevision??0),te([]),re(null),ae.current=void 0,q.current=void 0,U(`idle`))},[p.untitled,r,i]),(0,Z.useEffect)(()=>{r?.mode===`edit`&&Ge(r.name).then(te).catch(()=>te([]))},[r?.mode,r?.name]),(0,Z.useEffect)(()=>{if(!m.trim())return;let e=window.setTimeout(()=>{y(m,g).then(V).catch(()=>V(null))},350);return()=>window.clearTimeout(e)},[g,m]),(0,Z.useEffect)(()=>{if(!m.trim())return;U(`saving`);let e=window.setTimeout(()=>{v({id:ae.current,workflowName:m,graph:g,manifest:b,baseRevision:W,expectedUpdatedAtMs:q.current}).then(e=>{ae.current=e.id,q.current=e.updatedAtMs,U(`saved`)}).catch(()=>U(`error`))},900);return()=>window.clearTimeout(e)},[W,g,b,m]);let de=(0,Z.useMemo)(()=>Pn(g,P?.graph??null),[g,P?.graph]),fe=(0,Z.useMemo)(()=>{if(!P)return g;let e=new Set(P.graph.nodes.map(e=>e.id)),t=g.nodes.filter(t=>!e.has(t.id));return{...P.graph,nodes:[...P.graph.nodes,...t]}},[g,P]);(0,Z.useLayoutEffect)(()=>{E(e=>{let t=new Map(e.map(e=>[e.id,e]));return fe.nodes.map(e=>({...t.get(e.id),...An(e,e.id===S,de.nodeStates.get(e.id))}))})},[fe.nodes,de.nodeStates,S,E]),(0,Z.useEffect)(()=>{let e=ce.current;if(!e||fe.nodes.length===0)return;let t=window.requestAnimationFrame(()=>{e.fitView(yn)});return()=>window.cancelAnimationFrame(t)},[fe.nodes.length,le]);let pe=(0,Z.useMemo)(()=>fe.edges.map(jn),[fe.edges]),he=g.nodes.find(e=>e.id===S)??null,ge=(0,Z.useMemo)(()=>new Set(a),[a]),ve=r?.mode!==`edit`&&ge.has(m),ye=ve?_n(m,ge):m,be=B?.valid===!0&&!ve&&!n&&!M,xe=(0,Z.useCallback)(e=>{_(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})},[]),Se=(0,Z.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&_(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}))}))},[]),X=(0,Z.useCallback)(e=>{!e.source||!e.target||_(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}))}))},[]),we=(0,Z.useCallback)((e,t)=>{_(n=>({...n,nodes:n.nodes.map(n=>n.id===e?t(n):n)}))},[]),Te=e=>{let t=`${e}-${crypto.randomUUID().slice(0,8)}`,n=Nn(e,t,g.nodes.length);_(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]}}),J(e=>e+1),w(t)},Ee=()=>{!he||he.kind===`input`||he.kind===`output`||(_(e=>({...e,nodes:e.nodes.filter(e=>e.id!==he.id),edges:e.edges.filter(e=>e.source!==he.id&&e.target!==he.id)})),J(e=>e+1),w(``))},De=(0,Z.useCallback)(async()=>{if(O.trim()){N(!0);try{let n=await me({prompt:O,agentId:t,language:e===`zh`?`zh`:`en`,mode:r||g.nodes.length>3?`improve`:`create`,existingGraph:g}),i=r?.mode===`edit`?r.name:_n(n.name,ge);L(i===n.name?null:n.name),F(i===n.name?n:{...n,name:i}),z(!0),J(e=>e+1),w(n.graph.nodes.find(e=>e.kind===`agent`)?.id??``)}finally{N(!1)}}},[O,ge,g,r,e,t]);(0,Z.useEffect)(()=>{let e=r?.repairPrompt?.trim();!e||O.trim()!==e||M||P||K.current===e||(K.current=e,De())},[O,De,M,r?.repairPrompt,P]);let Oe=()=>{F(null),L(null),w(g.nodes.find(e=>e.kind===`agent`)?.id??``),J(e=>e+1)},Ae=async()=>{if(!(!P||n||oe.current)){oe.current=!0;try{let e=await c({name:P.name,graph:P.graph,manifest:P.manifest,expectedRevision:W});if(!e)return;h(e.name),_(structuredClone(e.graph)),x(gn(e)),V(P.validation),ee(e.revision),F(null),L(null),k(``),w(e.graph.nodes.find(e=>e.kind===`agent`)?.id??``),ae.current&&await je(ae.current).catch(()=>void 0)}catch{}finally{oe.current=!1}}},Me=async e=>{if(!be||oe.current)return;oe.current=!0;let t={name:m,graph:g,manifest:b,expectedRevision:W};try{if(e)await u({...t,goal:A.trim()||b.description||m});else{let e=await c(t);if(!e)return;ee(e.revision)}ae.current&&await je(ae.current).catch(()=>void 0)}catch{return}finally{oe.current=!1}},Pe=async e=>{if(!(ne!==null||r?.mode!==`edit`)){re(e);try{let t=await Je(r.name,e,W);_(t.graph),J(e=>e+1),x(gn(t)),ee(t.revision),w(t.graph.nodes.find(e=>e.kind===`agent`)?.id??``),te(await Ge(r.name))}finally{re(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:l(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,Ce.focusRingPanel),"aria-label":e===`zh`?`返回工作流`:`Back to workflows`,children:(0,$.jsx)(Qe,{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`?p.editTitle:p.createTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:p.subtitle})]}),(0,$.jsx)(`span`,{className:l(`text-xs`,H===`error`?`text-danger`:`text-fg-subtle`),children:H===`saving`?p.savingDraft:H===`saved`?p.savedDraft:H===`error`?p.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)(Y,{variant:`secondary`,className:`h-8`,onClick:()=>{h(o.suggestedName),d()},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)(Y,{variant:`secondary`,className:`h-8`,onClick:f,children:e===`zh`?`加载最新版本`:`Load latest`})]}):null,!o&&ve?(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`?`内部名称“${m}”已被使用。`:`The internal name “${m}” is already in use.`}),(0,$.jsx)(Y,{variant:`secondary`,className:`h-8`,onClick:()=>h(ye),children:e===`zh`?`使用 ${ye}`:`Use ${ye}`})]}):null,!o&&!ve&&I&&P?(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`?`“${I}”已存在,方案将保存为“${P.name}”。`:`“${I}” already exists. This proposal will be saved as “${P.name}”.`}):null,R?(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:p.flowTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:p.stepCount(g.nodes.length)})]}),(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!P,onClick:()=>Te(`agent`),children:[(0,$.jsx)(We,{className:`size-3.5`}),p.addAgent]}),(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!P,onClick:()=>Te(`decision`),children:[(0,$.jsx)(Ne,{className:`size-3.5`}),p.addDecision]}),(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!P,onClick:()=>Te(`merge`),children:[(0,$.jsx)(se,{className:`size-3.5`}),p.addMerge]}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-subtle`,children:p.canvasHint})]}),(0,$.jsx)(`div`,{className:`relative min-h-72 flex-1`,children:g.nodes.length>0?(0,$.jsxs)(lt,{"aria-label":p.flowAria,nodes:T,edges:pe,nodeTypes:Dn,onNodesChange:D,onEdgesChange:Se,onConnect:X,nodesDraggable:!P,nodesConnectable:!P,onNodeClick:(e,t)=>w(t.id),onNodeDragStart:(e,t)=>w(t.id),onNodeDragStop:(e,t)=>xe(t),onInit:e=>{ce.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:p.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:P?(0,$.jsx)(Sn,{proposal:P,diff:de,copy:p,saving:n,onAccept:()=>void Ae(),onReject:Oe}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`label`,{className:`block text-xs font-medium text-fg`,htmlFor:`workflow-title`,children:p.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:p.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:p.advanced}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-name`,children:p.workflowName}),(0,$.jsx)(`input`,{id:`workflow-name`,value:m,onChange:e=>h(Ln(e.target.value)),className:kn}),ve?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e===`zh`?`该内部名称已被使用,请换一个名称。`:`This internal name is already in use.`}):null,r?.mode===`edit`&&G.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)(ke,{className:`size-3.5`}),p.versions,` · v`,W]}),(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:G.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,` · `,Le(t.createdAtMs,e)]}),t.revision===W?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:p.currentVersion}):(0,$.jsxs)(Y,{variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:ne!==null,onClick:()=>void Pe(t.revision),children:[(0,$.jsx)(ue,{className:`size-3`}),ne===t.revision?p.restoring:p.restore]})]},t.revision))})]}):null]})]}),(0,$.jsx)(`div`,{className:`my-4 border-t border-edge`}),he?(0,$.jsx)(On,{node:he,copy:p,updateNode:we,onDelete:Ee}):(0,$.jsx)(`div`,{className:`py-8 text-center text-sm text-fg-muted`,children:p.selectNode}),B&&!B.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:p.needsAttention}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-danger`,children:B.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)(C,{className:`size-4 shrink-0 text-accent-fg`}),(0,$.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&De()},placeholder:p.aiPlaceholder,className:`${kn} mt-0 flex-1`}),(0,$.jsx)(Y,{variant:`secondary`,className:`h-10 shrink-0`,disabled:!!P||M||!O.trim(),onClick:()=>void De(),children:M?p.designing:p.applyWithAi})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:p.testGoal,className:`${kn} mt-0 w-52`}),(0,$.jsxs)(Y,{variant:`secondary`,disabled:!be,onClick:()=>void Me(!1),children:[(0,$.jsx)(Ie,{className:`size-4`}),p.publish]}),(0,$.jsxs)(Y,{variant:`primary`,disabled:!be,onClick:()=>void Me(!0),children:[(0,$.jsx)(_e,{className:`size-4`}),p.publishAndRun]})]})]})})]}):(0,$.jsx)(xn,{copy:p,prompt:O,generating:M,onPromptChange:k,onGenerate:()=>void De(),onManual:()=>z(!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)(C,{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 m;t[16]===p?m=t[17]:(m=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:p}),t[16]=p,t[17]=m);let h;t[18]!==i||t[19]!==r?(h=!r.trim()||i,t[18]=i,t[19]=r,t[20]=h):h=t[20];let g;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(C,{className:`size-4`}),t[21]=g):g=t[21];let _=i?n.designing:n.designWorkflow,v;t[22]!==o||t[23]!==_||t[24]!==h?(v=(0,$.jsxs)(Y,{variant:`primary`,disabled:h,onClick:o,children:[g,_]}),t[22]=o,t[23]=_,t[24]=h,t[25]=v):v=t[25];let y;t[26]!==n.manualStart||t[27]!==s?(y=(0,$.jsx)(Y,{variant:`ghost`,onClick:s,children:n.manualStart}),t[26]=n.manualStart,t[27]=s,t[28]=y):y=t[28];let b;t[29]!==v||t[30]!==y?(b=(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3`,children:[v,y]}),t[29]=v,t[30]=y,t[31]=b):b=t[31];let x;return t[32]!==b||t[33]!==l||t[34]!==u||t[35]!==f||t[36]!==m?(x=(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,m,b]})}),t[32]=b,t[33]=l,t[34]=u,t[35]=f,t[36]=m,t[37]=x):x=t[37],x}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)(C,{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,m;t[8]===p?m=t[9]:(m=(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:p}),t[8]=p,t[9]=m);let h=n.explanation||n.manifest.description,g;t[10]===h?g=t[11]:(g=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h}),t[10]=h,t[11]=g);let _;t[12]===i.added?_=t[13]:(_=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.added}),t[12]=i.added,t[13]=_);let v;t[14]===r.addedIds.length?v=t[15]:(v=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-success`,children:r.addedIds.length}),t[14]=r.addedIds.length,t[15]=v);let y;t[16]!==v||t[17]!==_?(y=(0,$.jsxs)(`div`,{className:`rounded-lg bg-success-soft p-2`,children:[_,v]}),t[16]=v,t[17]=_,t[18]=y):y=t[18];let b;t[19]===i.changed?b=t[20]:(b=(0,$.jsx)(`dt`,{className:`text-fg-subtle`,children:i.changed}),t[19]=i.changed,t[20]=b);let x=r.changedIds.length+r.connectionChanges,S;t[21]===x?S=t[22]:(S=(0,$.jsx)(`dd`,{className:`mt-1 font-semibold text-accent-fg`,children:x}),t[21]=x,t[22]=S);let w;t[23]!==b||t[24]!==S?(w=(0,$.jsxs)(`div`,{className:`rounded-lg bg-accent-soft p-2`,children:[b,S]}),t[23]=b,t[24]=S,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]!==y||t[34]!==w||t[35]!==D?(O=(0,$.jsxs)(`dl`,{className:`mt-3 grid grid-cols-3 gap-2 text-center text-xs`,children:[y,w,D]}),t[33]=y,t[34]=w,t[35]=D,t[36]=O):O=t[36];let k;t[37]!==O||t[38]!==m||t[39]!==g?(k=(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base/50 p-3`,children:[m,g,O]}),t[37]=O,t[38]=m,t[39]=g,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)(Y,{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)(Ke,{className:`size-4`}),t[58]=R):R=t[58];let z;t[59]!==i.rejectProposal||t[60]!==s||t[61]!==a?(z=(0,$.jsxs)(Y,{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)(Be,{}):i.kind===`agent`?(0,$.jsx)(We,{}):i.kind===`decision`?(0,$.jsx)(Ne,{}):i.kind===`merge`?(0,$.jsx)(se,{}):(0,$.jsx)(_e,{}),t[0]=i.kind,t[1]=o);let s=o,c=r?`border-accent ring-2 ring-accent/20`:`border-edge`,u=a===`added`&&`border-success ring-2 ring-success/15`,d=a===`changed`&&`border-accent ring-2 ring-accent/15`,f=a===`removed`&&`border-dashed border-danger opacity-55`,p;t[2]!==c||t[3]!==u||t[4]!==d||t[5]!==f?(p=l(`w-52 rounded-xl border bg-surface-panel p-3 shadow-surface transition-colors`,c,u,d,f),t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=p):p=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:l(`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]!==p||t[32]!==m?(C=(0,$.jsxs)(`div`,{className:p,children:[m,x,S]}),t[29]=x,t[30]=S,t[31]=p,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 d;t[8]!==r.remove||t[9]!==n.kind||t[10]!==a?(d=n.kind!==`input`&&n.kind!==`output`?(0,$.jsxs)(Y,{variant:`ghost`,className:`h-8 px-2 text-danger`,onClick:a,children:[(0,$.jsx)(F,{className:`size-3.5`}),r.remove]}):null,t[8]=r.remove,t[9]=n.kind,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.stepName?p=t[16]:(p=(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]=p);let m;t[17]===s?m=t[18]:(m=e=>s({title:e.target.value}),t[17]=s,t[18]=m);let h;t[19]!==n.title||t[20]!==m?(h=(0,$.jsx)(`input`,{id:`node-title`,value:n.title,onChange:m,className:kn}),t[19]=n.title,t[20]=m,t[21]=h):h=t[21];let g;t[22]===r.stepPurpose?g=t[23]:(g=(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]=g);let _=n.description??``,v;t[24]===s?v=t[25]:(v=e=>s({description:e.target.value}),t[24]=s,t[25]=v);let y;t[26]!==_||t[27]!==v?(y=(0,$.jsx)(`textarea`,{id:`node-description`,value:_,onChange:v,className:`${kn} min-h-16 resize-y`}),t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;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?(b=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]=b):b=t[36];let x;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?(x=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)(ne,{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]=x):x=t[47];let S;t[48]!==r.combineAs||t[49]!==r.listResults||t[50]!==r.namedResults||t[51]!==n.config||t[52]!==n.kind||t[53]!==l?(S=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)(ne,{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]=S):S=t[54];let C;t[55]!==r.autoSummary||t[56]!==r.summaryTemplate||t[57]!==n.config||t[58]!==n.kind||t[59]!==l?(C=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]=C):C=t[60];let w;return t[61]!==y||t[62]!==b||t[63]!==x||t[64]!==S||t[65]!==C||t[66]!==f||t[67]!==p||t[68]!==h||t[69]!==g?(w=(0,$.jsxs)(`section`,{children:[f,p,h,g,y,b,x,S,C]}),t[61]=y,t[62]=b,t[63]=x,t[64]=S,t[65]=C,t[66]=f,t[67]=p,t[68]=h,t[69]=g,t[70]=w):w=t[70],w}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),u;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),u=n.nodes.map(e),t[2]=o.kind,t[3]=n.nodes,t[4]=u}else u=t[4];let d=u,f;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],f=n.edges.map(e),t[7]=o.no,t[8]=o.yes,t[9]=n.edges,t[10]=f}else f=t[10];let p=f,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]!==p||t[20]!==n.nodes||t[21]!==d||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=l(`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=l(`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 u;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(u={padding:.24,minZoom:.45,maxZoom:1},t[39]=u):u=t[39];let f,x,S;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(f={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]=f,t[41]=x,t[42]=S):(f=t[40],x=t[41],S=t[42]),t[43]!==p||t[44]!==d?(b=(0,$.jsx)(`div`,{className:`h-[22rem] min-h-72`,children:(0,$.jsxs)(lt,{nodes:d,edges:p,nodeTypes:Wn,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:a,fitView:!0,fitViewOptions:u,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:f,children:[x,S]})}),t[43]=p,t[44]=d,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]=p,t[20]=n.nodes,t[21]=d,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=l(`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 u;t[6]===c?u=t[7]:(u=(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]=u);let d;t[8]===i.title?d=t[9]:(d=(0,$.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[8]=i.title,t[9]=d);let f;t[10]===n.kindLabel?f=t[11]:(f=(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.kindLabel}),t[10]=n.kindLabel,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==u||t[16]!==p?(m=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[u,p]}),t[15]=u,t[16]=p,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)(Be,{className:`size-4`,"aria-hidden":!0}):e===`agent`?(0,$.jsx)(We,{className:`size-4`,"aria-hidden":!0}):e===`decision`?(0,$.jsx)(Ne,{className:`size-4`,"aria-hidden":!0}):e===`merge`?(0,$.jsx)(se,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(_e,{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)(),u=(0,Z.useRef)(null),d=(0,Z.useRef)(void 0),f;t[0]===i?f=t[1]:(f=tr(i),t[0]=i,t[1]=f);let p=f,m;t[2]===r.nodes?m=t[3]:(m=new Map(r.nodes.map(Zn)),t[2]=r.nodes,t[3]=m);let h=m,g;if(t[4]!==n.nodes||t[5]!==h){let e;t[7]===h?e=t[8]:(e=e=>({id:e.id,type:`runNode`,position:e.position,data:{definitionNode:e,runNode:h.get(e.id)}}),t[7]=h,t[8]=e),g=n.nodes.map(e),t[4]=n.nodes,t[5]=h,t[6]=g}else g=t[6];let _=g,v;if(t[9]!==n.edges||t[10]!==h){let e;t[12]===h?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:h.get(e.source)?.status===`running`,style:{stroke:h.get(e.source)?.status===`done`?`var(--color-success)`:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[12]=h,t[13]=e),v=n.edges.map(e),t[9]=n.edges,t[10]=h,t[11]=v}else v=t[11];let y=v,b;t[14]!==o||t[15]!==h?(b=o?h.get(o):void 0,t[14]=o,t[15]=h,t[16]=b):b=t[16];let x=b,S;t[17]!==n.nodes||t[18]!==o?(S=o?n.nodes.find(e=>e.id===o):void 0,t[17]=n.nodes,t[18]=o,t[19]=S):S=t[19];let C=S,w;t[20]===r.nodes?w=t[21]:(w=r.nodes.some(Xn),t[20]=r.nodes,t[21]=w);let T=w,E,D;t[22]===r.nodes?(E=t[23],D=t[24]):(E=()=>{let e=r.nodes.find(Yn)??r.nodes.find(Jn)??[...r.nodes].reverse().find(qn);if(!e||d.current===e.id)return;d.current=e.id,s(e.id);let t=window.requestAnimationFrame(()=>{u.current?.fitView({nodes:[{id:e.id}],padding:1.4,minZoom:.65,maxZoom:1,duration:300})});return()=>window.cancelAnimationFrame(t)},D=[r.nodes],t[22]=r.nodes,t[23]=E,t[24]=D),(0,Z.useEffect)(E,D);let O;t[25]===p.title?O=t[26]:(O=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.title}),t[25]=p.title,t[26]=O);let k;t[27]===p.hint?k=t[28]:(k=(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:p.hint}),t[27]=p.hint,t[28]=k);let A;t[29]!==O||t[30]!==k?(A=(0,$.jsxs)(`div`,{children:[O,k]}),t[29]=O,t[30]=k,t[31]=A):A=t[31];let j;t[32]!==p.repair||t[33]!==T||t[34]!==a?(j=T&&a?(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 text-xs`,onClick:a,children:[(0,$.jsx)(ue,{className:`size-3.5`}),p.repair]}):null,t[32]=p.repair,t[33]=T,t[34]=a,t[35]=j):j=t[35];let M;t[36]!==A||t[37]!==j?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38];let N,P;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(N=(e,t)=>s(t.id),P=e=>{u.current=e},t[39]=N,t[40]=P):(N=t[39],P=t[40]);let F,I;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(F={hideAttribution:!0},I=(0,$.jsx)(ft,{color:`var(--color-edge)`,gap:22,size:1}),t[41]=F,t[42]=I):(F=t[41],I=t[42]);let L;t[43]!==y||t[44]!==_?(L=(0,$.jsx)(`div`,{className:`h-[28rem]`,children:(0,$.jsx)(lt,{nodes:_,edges:y,nodeTypes:er,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:N,onInit:P,fitView:!0,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:F,children:I})}),t[43]=y,t[44]=_,t[45]=L):L=t[45];let R;t[46]!==p.status||t[47]!==x||t[48]!==C?(R=x?(0,$.jsxs)(`div`,{className:l(`flex items-start gap-2 border-t border-edge px-4 py-3 text-xs`,x.status===`error`?`text-danger`:`text-fg-muted`),children:[x.status===`error`?(0,$.jsx)(Se,{className:`mt-0.5 size-3.5 shrink-0`}):x.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:x.title}),C?.description?(0,$.jsx)(`span`,{className:`block pt-0.5 text-fg-subtle`,children:C.description}):null,(0,$.jsx)(`span`,{className:`block pt-1`,children:x.error||x.resultPreview||p.status[x.status]})]})]}):null,t[46]=p.status,t[47]=x,t[48]=C,t[49]=R):R=t[49];let z;return t[50]!==M||t[51]!==L||t[52]!==R?(z=(0,$.jsxs)(`section`,{className:`mt-5 overflow-hidden rounded-2xl border border-edge bg-surface-base/35`,children:[M,L,R]}),t[50]=M,t[51]=L,t[52]=R,t[53]=z):z=t[53],z}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)(Be,{}):i.kind===`agent`?(0,$.jsx)(We,{}):i.kind===`decision`?(0,$.jsx)(Ne,{}):i.kind===`merge`?(0,$.jsx)(se,{}):(0,$.jsx)(_e,{}),t[0]=i.kind,t[1]=o);let s=o,c=a===`running`&&`border-accent ring-2 ring-accent/20`,u=a===`done`&&`border-success/50`,d=a===`error`&&`border-danger ring-2 ring-danger/15`,f=(a===`pending`||a===`skipped`)&&`border-edge opacity-70`,p=r&&`ring-2 ring-accent/25`,m;t[2]!==c||t[3]!==u||t[4]!==d||t[5]!==f||t[6]!==p?(m=l(`w-48 rounded-xl border bg-surface-panel px-3 py-2.5 shadow-surface`,c,u,d,f,p),t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=p,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)(Se,{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`?E(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:E(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 z(e)}function sr({view:e,comparison:t,loading:n,language:r,localeTag:i,activeTab:a,onTabChange:s,onCancel:f,onRetry:p,onReplay:m,onOpenRunId:h,ownerAgentId:v,onRepairWorkflow:y}){let x=d(r).workflows,C=g(r),T=o(),[D,O]=(0,Z.useState)(!1),[A,F]=(0,Z.useState)(!1),[I,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(null),[W,G]=(0,Z.useState)(null),[,ne]=(0,Z.useState)(0),re=e?.run.status,ie=re?ee.has(re):!1;(0,Z.useEffect)(()=>{e?.run.id&&(O(!1),H(null))},[e?.run.id,ie,re,e?.run.metrics.errorAgentCount]),(0,Z.useEffect)(()=>{if(!ie)return;let e=window.setInterval(()=>ne(e=>e+1),1e3);return()=>window.clearInterval(e)},[ie]);let K=(0,Z.useMemo)(()=>e?He(e):null,[e]),ae=(0,Z.useMemo)(()=>K?Ue(K):{phases:[],unphased:null},[K]),q=(0,Z.useMemo)(()=>I==null||!K?null:K.agents.find(e=>e.id===I)??null,[I,K]);(0,Z.useEffect)(()=>{K?.runId&&R((K.agents.find(e=>e.status===`error`||e.status===`skipped`)??K.agents.find(e=>e.status===`running`)??null)?.id??null)},[K?.runId]);let oe=(0,Z.useCallback)(e=>{R(e.id)},[]),se=(0,Z.useMemo)(()=>e?M(e):[],[e]),ce=e?j(e.run.result):void 0,J=ce?kr(ce):null,de=ce?w(ce):``,fe=!!ce,pe=(0,Z.useCallback)(async()=>{fe&&await u(de)&&(B(!0),window.setTimeout(()=>B(!1),1500))},[fe,de]),me=(0,Z.useCallback)(()=>{if(!fe||!e)return;let t=new Blob([de],{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)},[fe,de,e]),he=(0,Z.useCallback)(()=>{if(!e)return;let t=or(e);t&&T(te(t))},[T,e]),ge=(0,Z.useCallback)(async t=>{if(e){H(null),G(t.id);try{Dr(await Te(e.run.id,t.id,{ownerAgentId:v}),t.name||t.id)}catch(e){H(e instanceof Error?e.message:String(e))}finally{G(null)}}},[v,e]),_e=(0,Z.useCallback)(t=>{if(!e||!t.prompt)return;let n=or(e);if(!n){u(t.prompt);return}T(te(n,t.prompt))},[T,e]),ve=(0,Z.useCallback)(e=>{if(e.kind===`copy_result`){pe();return}if(e.kind===`open_artifact`){let t=jr(e.payload),n=J?.artifacts.find(e=>e.id===t||e.name===t);n&&ge(n);return}let t=jr(e.payload),n=J?.followUps.find(e=>e.id===t);if(n?.prompt){_e(n);return}let r=Mr(e.payload);r&&_e({id:e.id,title:e.label,prompt:r})},[pe,ge,_e,J?.artifacts,J?.followUps]),ye=(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);R(Number.isFinite(i)?i:r+1)},[e]),be=e?or(e):null,xe=J?.actions.filter(e=>Nr(e,J))??[],Se=xe.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)(U,{className:`h-8 w-72 max-w-full`}),(0,$.jsx)(U,{className:`mt-4 h-28 rounded-2xl`}),(0,$.jsx)(U,{className:`mt-5 h-[28rem] rounded-2xl`})]})});if(!e||!K)return null;let{run:X}=e,Ce=e.controls.canCancel&&ie,we=ie&&X.startedAtMs!=null?L(Date.now()-X.startedAtMs):L(X.metrics.durationMs??void 0),Ee=ir(e,x),De=ar(e,x),Oe=e.controls.canRetry&&e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.prompt?.trim()),ke=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())),je=X.goal?.trim()||X.title,Me=e.nodes.find(e=>e.status===`running`)??e.nodes.find(e=>e.status===`error`)??[...e.nodes].reverse().find(e=>e.status===`done`),Ne=Me?.kind===`output`&&!Me.error?ce?.summary??Me.resultPreview:null,Pe=Ne??(Me?Me.error||(r===`zh`?`${Me.status===`running`?`正在执行`:Me.status===`done`?`刚刚完成`:`需要处理`}:${Me.title}`:`${Me.status===`running`?`Working on`:Me.status===`done`?`Just completed`:`Needs attention`}: ${Me.title}`):Ee),Fe=se.length>0||!!De,Ie=(X.status===`failed`||X.status===`timeout`)&&!!y,Le=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:je}),(0,$.jsx)(`span`,{className:l(`rounded-full px-2 py-0.5 text-xs font-medium`,_(X.status)),children:nr(X.status,x)})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[X.title,` · `,X.definitionId]}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:Ee}),De?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:De}):null,(0,$.jsxs)(`div`,{className:l(`mt-4 rounded-xl border px-3 py-2.5`,Me?.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`}),Ne?(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)(le,{content:Pe,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:Pe})]})]})}),(0,$.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsx)(Rr,{label:x.metrics.startedAt,value:b(X.startedAtMs??X.createdAtMs,i)}),(0,$.jsx)(Rr,{label:x.metrics.duration,value:we}),(0,$.jsx)(Rr,{label:x.metrics.agents,value:E(x.agentProgress,{done:X.metrics.doneAgentCount,total:X.metrics.agentCount})}),(0,$.jsx)(Rr,{label:x.metrics.artifacts,value:String(X.metrics.artifactCount)})]})]}),(0,$.jsx)(lr,{activeTab:Le,onChange:s,labels:x,artifactCount:J?.artifacts.length??e.artifacts.length}),Le===`result`?(0,$.jsxs)(`section`,{className:`mt-5 space-y-4`,children:[fe?(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:x.resultTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:x.resultReadyHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[be?(0,$.jsxs)(Y,{variant:`primary`,className:`h-8 text-xs`,onClick:he,children:[(0,$.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),x.continueInChat]}):null,xe.map(e=>(0,$.jsx)(Y,{variant:`secondary`,className:`h-8 text-xs`,onClick:()=>ve(e),children:e.label},e.id)),Se?null:(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 text-xs`,onClick:pe,children:[z?(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),z?x.copied:x.copyResult]}),(0,$.jsxs)(Y,{variant:`secondary`,className:`h-8 text-xs`,onClick:me,children:[(0,$.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),x.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)(Ae,{result:ce,labels:C.result})})})]}):X.status!==`failed`&&X.status!==`timeout`?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:x.noResult}):null,X.status===`failed`||X.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:x.recoveryActionsTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:De})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ie?(0,$.jsxs)(Y,{variant:`primary`,onClick:y,children:[(0,$.jsx)(Ye,{className:`size-4`,"aria-hidden":!0}),r===`zh`?`让 AI 修复`:`Fix with AI`]}):null,Oe?(0,$.jsxs)(Y,{variant:`secondary`,onClick:()=>m(`failed_agents`),children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),x.replayFailedAgents]}):null,ke?(0,$.jsxs)(Y,{variant:`secondary`,onClick:()=>m(`failed_phases`),children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),x.replayFailedPhases]}):null,e.controls.canRetry?(0,$.jsxs)(Y,{variant:`secondary`,onClick:p,children:[(0,$.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),x.rerun]}):null]})]}),(0,$.jsx)(br,{view:e,language:r})]}):null,J?(0,$.jsx)(Er,{task:J,labels:x,downloadingArtifactId:W,downloadError:V,onCopyText:e=>void u(e),onDownloadArtifact:e=>void ge(e),onStartFollowUp:_e,compact:!0}):null,Ce?(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{variant:`secondary`,onClick:f,className:`text-red-600 dark:text-red-300`,children:[(0,$.jsx)(k,{className:`size-4`,"aria-hidden":!0}),x.cancel]})}):null]}):null,Le===`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,Fe?(0,$.jsx)(cr,{diagnostics:se,labels:x,hint:De,onOpenAgent:ye}):null,(0,$.jsx)(ur,{snapshot:K,rollup:ae,view:e,labels:x,cardLabels:C,isActive:ie,processExpanded:D,logsExpanded:A,selectedAgentId:I,selectedAgent:q,durationText:we,onToggleProcess:()=>O(e=>!e),onToggleLogs:()=>F(e=>!e),onSelectAgent:oe}),(0,$.jsx)(gr,{view:e,comparison:t,labels:x,onOpenRunId:h}),(0,$.jsx)(_r,{view:e,labels:x})]}):null,Le===`artifacts`?(0,$.jsx)(Er,{task:J,labels:x,downloadingArtifactId:W,downloadError:V,onCopyText:e=>void u(e),onDownloadArtifact:e=>void ge(e),onStartFollowUp:_e}):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)(Se,{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)(Y,{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:u,selectedAgentId:d,selectedAgent:f,durationText:p,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=E(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]!==p||t[7]!==v?(y=(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[v,` · `,p]}),t[6]=p,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 x=c?`rotate-180`:null,S;t[12]===x?S=t[13]:(S=l(`size-4 shrink-0 text-fg-subtle transition-transform`,x),t[12]=x,t[13]=S);let C;t[14]===S?C=t[15]:(C=(0,$.jsx)(be,{className:S,"aria-hidden":!0}),t[14]=S,t[15]=C);let w;t[16]!==m||t[17]!==c||t[18]!==b||t[19]!==C?(w=(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,C]}),t[16]=m,t[17]=c,t[18]=b,t[19]=C,t[20]=w):w=t[20];let T;t[21]!==o||t[22]!==s||t[23]!==a||t[24]!==u||t[25]!==g||t[26]!==h||t[27]!==c||t[28]!==r||t[29]!==f||t[30]!==d||t[31]!==n||t[32]!==i.phases?(T=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)(de,{snapshot:n,labels:o,logsExpanded:u,onToggleLogs:h,selectedAgentId:d,onSelectAgent:g}):(0,$.jsx)(ze,{rollup:r,currentPhase:n.currentPhase,labels:o.phase,recentLogs:n.logs,recentLogsHeading:o.recentLogsHeading,showAllLogsLabel:o.showAllLogs,logsExpanded:u,onToggleLogs:h,selectedAgentId:d,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:f,snapshot:n,labels:a,cardLabels:o})]})}):null,t[21]=o,t[22]=s,t[23]=a,t[24]=u,t[25]=g,t[26]=h,t[27]=c,t[28]=r,t[29]=f,t[30]=d,t[31]=n,t[32]=i.phases,t[33]=T):T=t[33];let D;return t[34]!==w||t[35]!==T?(D=(0,$.jsxs)(`div`,{className:`mt-5 rounded-2xl border border-edge bg-surface-base/35`,children:[w,T]}),t[34]=w,t[35]=T,t[36]=D):D=t[36],D}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 u=n?.id,d;if(t[1]===u?d=t[2]:(d=[u],t[1]=u,t[2]=d),(0,Z.useEffect)(c,d),!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 f;t[5]===n?f=t[6]:(f=we(n),t[5]=n,t[6]=f);let p=f,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]!==p||t[10]!==g?(_=[g,p].filter(Boolean),t[9]=p,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 x;t[17]===n.status?x=t[18]:(x=l(`rounded-full px-2 py-0.5 text-xs font-medium`,Lr(n.status)),t[17]=n.status,t[18]=x);let S=i.agentStatus[n.status]??n.status,C;t[19]!==x||t[20]!==S?(C=(0,$.jsx)(`span`,{className:x,children:S}),t[19]=x,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==b||t[23]!==C?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b,C]}),t[22]=b,t[23]=C,t[24]=w):w=t[24];let T;t[25]===i.agentOutputHeading?T=t[26]:(T=(0,$.jsx)(`h4`,{className:`text-xs font-semibold text-fg`,children:i.agentOutputHeading}),t[25]=i.agentOutputHeading,t[26]=T);let E=n.error?`font-mono text-rose-600 dark:text-rose-400`:`text-fg-muted`,D;t[27]===E?D=t[28]:(D=l(`mt-2 max-h-72 overflow-auto whitespace-pre-wrap wrap-break-word text-sm leading-6`,E),t[27]=E,t[28]=D);let O;t[29]!==m||t[30]!==D?(O=(0,$.jsx)(`div`,{className:D,children:m}),t[29]=m,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==T||t[33]!==O?(k=(0,$.jsxs)(`section`,{className:`mt-4 rounded-xl border border-edge-subtle bg-surface-base/60 p-3`,children:[T,O]}),t[32]=T,t[33]=O,t[34]=k):k=t[34];let A;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>s(mr),t[35]=A):A=t[35];let j=i.debugDetailsTitle,M=o&&`rotate-180`,N;t[36]===M?N=t[37]:(N=l(`size-4 shrink-0 text-fg-subtle transition-transform`,M),t[36]=M,t[37]=N);let P;t[38]===N?P=t[39]:(P=(0,$.jsx)(be,{className:N,"aria-hidden":!0}),t[38]=N,t[39]=P);let F;t[40]!==o||t[41]!==i.debugDetailsTitle||t[42]!==P?(F=(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:A,"aria-expanded":o,children:[j,P]}),t[40]=o,t[41]=i.debugDetailsTitle,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==o||t[45]!==n||t[46]!==a||t[47]!==i||t[48]!==r?(I=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]=I):I=t[49];let L;t[50]!==F||t[51]!==I?(L=(0,$.jsxs)(`section`,{className:`mt-3 rounded-xl border border-edge-subtle bg-surface-base/40`,children:[F,I]}),t[50]=F,t[51]=I,t[52]=L):L=t[52];let R;return t[53]!==w||t[54]!==k||t[55]!==L?(R=(0,$.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-edge bg-surface-panel p-4`,children:[w,k,L]}),t[53]=w,t[54]=k,t[55]=L,t[56]=R):R=t[56],R}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?E(t.diagnosticsRunErrorWithCode,{code:e.code}):t.diagnosticsRunError:e.kind===`agent_error`?E(t.diagnosticsAgentError,{agent:e.agentLabel??String(e.agentId??`—`)}):e.kind===`step_error`?E(t.diagnosticsStepError,{agent:e.agentLabel??String(e.agentId??`—`),step:e.stepLabel??e.stepId??`—`}):E(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=E(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 m;t[16]!==u||t[17]!==p?(m=(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]=m):m=t[18];let h;t[19]!==r||t[20]!==i.replayDurationDelta||t[21]!==i.replayFixedAgents||t[22]!==i.replayStillFailingAgents?(h=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]=h):h=t[23];let g;t[24]!==s||t[25]!==l||t[26]!==m||t[27]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[s,l,m,h]}),t[24]=s,t[25]=l,t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==i.replayOpenSource||t[30]!==a||t[31]!==o.sourceRunId?(_=a?(0,$.jsx)(Y,{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]=_):_=t[32];let v;return t[33]!==g||t[34]!==_?(v=(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:[g,_]})}),t[33]=g,t[34]=_,t[35]=v):v=t[35],v}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?`-`:``}${L(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:u}=e,d=u===void 0?!1:u;if(!n||!n.artifacts.length&&!n.followUps.length){if(d)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 f=!d&&`mt-5`,p;t[2]===f?p=t[3]:(p=l(`grid gap-3 lg:grid-cols-3`,f),t[2]=f,t[3]=p);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)(P,{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]!==p||t[16]!==m||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[15]=p,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=l(`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=f(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=m(o,Ee,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=f(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=m(r,ce,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,p;t[10]===a.data?p=t[11]:(p=a.data??[],t[10]=a.data,t[11]=p);let h;return t[12]!==s||t[13]!==a.error||t[14]!==a.isLoading||t[15]!==d||t[16]!==p||t[17]!==l?(h={definition:s,definitions:p,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]=p,t[17]=l,t[18]=h):h=t[18],h}function Ur(e){return e.token}var Wr=()=>({goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``});function Gr(){let{definitionId:e}=i(),[t]=a(),n=o(),r=p(e=>e.language),c=d(r).workflows,l=r===`zh`?`zh-CN`:`en-US`,{ownerAgentId:u}=Br(),f=t.get(`projectId`)?.trim()||void 0,{definition:h,loading:g,error:_}=Hr(e),v=m(u?[`workflow-detail-runs`,u,e,f??``]:null,()=>Xe(100,{ownerAgentId:u,projectId:f}),{revalidateOnFocus:!1}),[y,b]=(0,Z.useState)(Wr),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=(0,Z.useMemo)(()=>(v.data??[]).filter(e=>e.definitionId===h?.id).slice(0,6),[h?.id,v.data]),E=tt(h,y),O=h?Ve(h,r):null,k=(0,Z.useCallback)(async()=>{if(!(!h||!E.valid||x)){S(!0),w(null);try{n(`/workflows/runs/${(await H({definitionId:h.id,goal:y.goal.trim()||O?.description||h.title,input:nt(h,y),agentId:u,projectId:f,concurrency:y.concurrency.trim()?Number(y.concurrency):void 0,maxSubagents:y.maxSubagents.trim()?Number(y.maxSubagents):void 0})).runId}${u?`?agentId=${encodeURIComponent(u)}`:``}`)}catch(e){w(e instanceof Error?e.message:c.startFailed)}finally{S(!1)}}},[h,E.valid,c.startFailed,O?.description,n,u,f,y,x]);if(g)return(0,$.jsx)(Xr,{});if(!h||!O)return(0,$.jsx)(Zr,{message:_?.message??(r===`zh`?`没有找到这个工作流`:`Workflow not found`)});let A=new URLSearchParams;u&&A.set(`agentId`,u),f&&A.set(`projectId`,f),h.metadata.source!==`user`&&A.set(`copy`,h.id);let j=`${h.metadata.source===`user`?`/workflows/${h.id}/edit`:`/workflows/new`}${A.size?`?${A.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)(Qe,{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:h.metadata.source===`user`?c.badgeUser:c.badgeBuiltin}),(0,$.jsx)(`span`,{children:`·`}),(0,$.jsx)(`span`,{children:r===`zh`?`版本 ${h.revision}`:`Version ${h.revision}`})]}),(0,$.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:h.title}),(0,$.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:O.description})]}),(0,$.jsx)(Y,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,$.jsxs)(s,{to:j,children:[h.metadata.source===`user`?(0,$.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(D,{className:`size-4`,"aria-hidden":!0}),h.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:h.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:h,language:r,value:y,onChange:b,mode:`manual`,badgeLabel:c.readyToStart,aiAssist:{context:{surface:`workflow-start`,workflowId:h.id,workflowName:h.name,workflowTitle:h.title,workflowDescription:O.description}}})}),C?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:C}):null,(0,$.jsxs)(Y,{variant:`primary`,className:`mt-4 w-full`,disabled:!E.valid||x,onClick:()=>void k(),children:[(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),x?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`}),T.length?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-3`,children:T.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:Le(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=p(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:h,refreshDefinitions:g}=Hr(e??c),_=m(l&&s?[`workflow-repair-run`,l,s]:null,()=>ge(l,{ownerAgentId:s}),{revalidateOnFocus:!1}),[v,y]=(0,Z.useState)(!1),[b,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=(_.data?.nodes.filter(e=>e.status===`error`)??[]).map(e=>r===`zh`?`${e.title}:${e.error??`执行失败`}`:`${e.title}: ${e.error??`execution failed`}`).join(r===`zh`?`;`:`; `)||_.data?.run.error?.message||void 0,i=l&&_.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,_.data?.nodes,l]),D=(0,Z.useCallback)(async e=>{y(!0),x(null),C(null);try{let t=await qe(e.name,e.graph,e.manifest,e.expectedRevision);return await h(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{y(!1)}},[n,h]),O=(0,Z.useCallback)(async e=>{y(!0),x(null),C(null);try{let t=await qe(e.name,e.graph,e.manifest,e.expectedRevision);await h(t),n(`/workflows/runs/${(await H({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{y(!1)}},[n,s,h]);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:[b?(0,$.jsx)(`div`,{className:`border-b border-danger/30 bg-danger/5 px-4 py-2 text-sm text-danger`,children:b}):null,(0,$.jsx)(bn,{language:r,ownerAgentId:s,saving:v,initialDraft:E,initialName:T,existingNames:w,saveConflict:S,onSave:D,onSaveAndStart:O,onClearSaveConflict:()=>C(null),onReloadLatest:()=>{C(null),x(null),g()}})]})}function qr(){let e=(0,Q.c)(53),{runId:t}=i(),n=o(),r=p(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=ve(t,c),[u,d]=(0,Z.useState)(`process`),f=(0,Z.useRef)(!0),h;e[2]!==l.view?.run.metadata?.replay||e[3]!==s||e[4]!==t?(h=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]=h):h=e[5];let g;e[6]!==s||e[7]!==t?(g=()=>he(t,{ownerAgentId:s}),e[6]=s,e[7]=t,e[8]=g):g=e[8];let _;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},e[9]=_):_=e[9];let v=m(h,g,_),y;e[10]===l.view?y=e[11]:(y=l.view?ee.has(l.view.run.status):!0,e[10]=l.view,e[11]=y);let b=y,x,S;e[12]===b?(x=e[13],S=e[14]):(x=()=>{f.current&&!b&&d(`result`),f.current=b},S=[b],e[12]=b,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,T;e[18]!==w||e[19]!==s||e[20]!==t?(T=async()=>{t&&w((await V(t,{ownerAgentId:s})).runId)},e[18]=w,e[19]=s,e[20]=t,e[21]=T):T=e[21];let E=T,D;e[22]!==w||e[23]!==s||e[24]!==t?(D=async e=>{t&&w((await J(t,e,{ownerAgentId:s})).runId)},e[22]=w,e[23]=s,e[24]=t,e[25]=D):D=e[25];let O=D;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 k;e[28]!==l||e[29]!==s||e[30]!==t?(k=()=>t&&void pe(t,{ownerAgentId:s}).then(()=>l.mutate()),e[28]=l,e[29]=s,e[30]=t,e[31]=k):k=e[31];let A;e[32]===E?A=e[33]:(A=()=>void E(),e[32]=E,e[33]=A);let j;e[34]===O?j=e[35]:(j=e=>void O(e),e[34]=O,e[35]=j);let M;e[36]!==l.view||e[37]!==n||e[38]!==s?(M=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]=M):M=e[39];let N;return e[40]!==u||e[41]!==v.data||e[42]!==r||e[43]!==l.loading||e[44]!==l.view||e[45]!==a||e[46]!==w||e[47]!==s||e[48]!==k||e[49]!==A||e[50]!==j||e[51]!==M?(N=(0,$.jsx)(sr,{view:l.view,comparison:v.data,loading:l.loading,language:r,localeTag:a,activeTab:u,onTabChange:d,onCancel:k,onRetry:A,onReplay:j,onOpenRunId:w,ownerAgentId:s,onRepairWorkflow:M}),e[40]=u,e[41]=v.data,e[42]=r,e[43]=l.loading,e[44]=l.view,e[45]=a,e[46]=w,e[47]=s,e[48]=k,e[49]=A,e[50]=j,e[51]=M,e[52]=N):N=e[52],N}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)(U,{className:`h-5 w-36`}),(0,$.jsx)(U,{className:`mt-5 h-9 w-80 max-w-full`}),(0,$.jsx)(U,{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)(Y,{asChild:!0,variant:`secondary`,className:`mt-4`,children:(0,$.jsxs)(s,{to:`/workflows`,children:[(0,$.jsx)(Qe,{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};