@runfusion/fusion 0.44.0 → 0.46.0

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 (240) hide show
  1. package/README.md +2 -1
  2. package/dist/bin.js +7431 -2240
  3. package/dist/client/.vite/manifest.json +1118 -331
  4. package/dist/client/assets/AgentDetailView-CgbB51Iw.css +1 -0
  5. package/dist/client/assets/AgentDetailView-D1cA9Bfj.js +18 -0
  6. package/dist/client/assets/{AgentPermissionPolicyEditor--YS4iMUY.js → AgentPermissionPolicyEditor-DE0wv8-L.js} +2 -2
  7. package/dist/client/assets/AgentsView-Bm_FA_1w.js +29 -0
  8. package/dist/client/assets/AgentsView-CzMa5Olf.css +1 -0
  9. package/dist/client/assets/ChatView-BtjkE0V7.css +1 -0
  10. package/dist/client/assets/ChatView-CHEkov6q.js +19 -0
  11. package/dist/client/assets/CommandCenter-Cfgek-dC.js +71 -0
  12. package/dist/client/assets/CommandCenter-DDjpYkPe.css +1 -0
  13. package/dist/client/assets/DevServerView-DgDksVH2.css +1 -0
  14. package/dist/client/assets/DevServerView-_or2KLVw.js +1 -0
  15. package/dist/client/assets/DirectoryPicker-etVwa-6X.js +1 -0
  16. package/dist/client/assets/DocumentsView-e8ZTdPIZ.js +1 -0
  17. package/dist/client/assets/EvalsView-CTbgPUne.css +1 -0
  18. package/dist/client/assets/EvalsView-CjDRQFMQ.js +1 -0
  19. package/dist/client/assets/ExperimentalAgentOnboardingModal-3ZEFv8sr.css +1 -0
  20. package/dist/client/assets/ExperimentalAgentOnboardingModal-DXR0OAsR.js +1 -0
  21. package/dist/client/assets/GoalsView-CUh8JBnJ.css +1 -0
  22. package/dist/client/assets/GoalsView-WWDKVslN.js +2 -0
  23. package/dist/client/assets/InsightsView-C7yRTMPn.css +1 -0
  24. package/dist/client/assets/InsightsView-DxIfxOzx.js +11 -0
  25. package/dist/client/assets/MemoryView-BVW2hkWf.js +2 -0
  26. package/dist/client/assets/MemoryView-CBDUr2Jy.css +1 -0
  27. package/dist/client/assets/PiExtensionsManager-CpSfMok2.js +11 -0
  28. package/dist/client/assets/PluginManager-CpBCy656.js +1 -0
  29. package/dist/client/assets/PullRequestView-BMspX1ga.js +6 -0
  30. package/dist/client/assets/PullRequestView-CpdE3Yo_.css +1 -0
  31. package/dist/client/assets/ResearchView--YEtcv_s.js +1 -0
  32. package/dist/client/assets/ResearchView-DIVNQF4_.css +1 -0
  33. package/dist/client/assets/SecretsView-CC6QDMWN.js +1 -0
  34. package/dist/client/assets/SecretsView-CvFioX7R.css +1 -0
  35. package/dist/client/assets/SessionTerminal-D4R3ScvQ.css +1 -0
  36. package/dist/client/assets/SessionTerminal-DJGtgIls.js +2 -0
  37. package/dist/client/assets/SettingsModal-4d_p8D7W.js +1 -0
  38. package/dist/client/assets/SettingsModal-BESN59Ao.css +1 -0
  39. package/dist/client/assets/SettingsModal-ino68pI2.css +1 -0
  40. package/dist/client/assets/SettingsModal-wABa7xmZ.js +21 -0
  41. package/dist/client/assets/SetupWizardModal-DHe2tXzx.js +2 -0
  42. package/dist/client/assets/ShadcnColorPicker-HX3j1v66.js +11 -0
  43. package/dist/client/assets/ShadcnColorPicker-pqVWCC5-.css +1 -0
  44. package/dist/client/assets/SkillsView-CJ8snrma.css +1 -0
  45. package/dist/client/assets/SkillsView-mdFVTX-r.js +1 -0
  46. package/dist/client/assets/TodoView-CIsL_uvQ.css +1 -0
  47. package/dist/client/assets/TodoView-DQVugDpW.js +6 -0
  48. package/dist/client/assets/WorkflowNodeEditor-CeERQHHu.js +8 -0
  49. package/dist/client/assets/WorkflowNodeEditor-f_XPV5Jd.css +1 -0
  50. package/dist/client/assets/{addon-fit-SnYDEvGm.js → addon-fit-C1WQXRvu.js} +1 -1
  51. package/dist/client/assets/{addon-unicode11-s5GoZCpi.js → addon-unicode11-BVmNDUBM.js} +1 -1
  52. package/dist/client/assets/{addon-web-links-jjt2f_oV.js → addon-web-links-CkVew5xs.js} +1 -1
  53. package/dist/client/assets/{addon-webgl-Icn-RnEx.js → addon-webgl-uLc0RKcC.js} +1 -1
  54. package/dist/client/assets/agentSkills-C2v1wbxh.js +1 -0
  55. package/dist/client/assets/{ExperimentalAgentOnboardingModal-CZ_jbgep.css → agentSkills-bQJ4X1gH.css} +1 -1
  56. package/dist/client/assets/agentsOrgChartLayout-BMvyuaLA.js +1 -0
  57. package/dist/client/assets/app-BJGkp7Tt.js +13 -0
  58. package/dist/client/assets/app-BKLUvvm8.js +13 -0
  59. package/dist/client/assets/app-BaoNC9zg.js +13 -0
  60. package/dist/client/assets/app-CZQ_fFNf.js +13 -0
  61. package/dist/client/assets/app-DAu3AzsS.js +13 -0
  62. package/dist/client/assets/app-DgezOJub.js +13 -0
  63. package/dist/client/assets/arc-cxkkNsnK.js +1 -0
  64. package/dist/client/assets/architectureDiagram-3BPJPVTR-CGEhhgX_.js +36 -0
  65. package/dist/client/assets/band-CquvqAHh.js +1 -0
  66. package/dist/client/assets/blockDiagram-GPEHLZMM-D0DTo0HT.js +132 -0
  67. package/dist/client/assets/c4Diagram-AAUBKEIU-DNykNaRb.js +10 -0
  68. package/dist/client/assets/channel-Dwf1FoGU.js +1 -0
  69. package/dist/client/assets/chunk-2J33WTMH-5oQfAhmr.js +1 -0
  70. package/dist/client/assets/chunk-4BX2VUAB-BqLZXgFw.js +1 -0
  71. package/dist/client/assets/chunk-55IACEB6-C1oIjX3T.js +1 -0
  72. package/dist/client/assets/chunk-727SXJPM-BaovQTgk.js +206 -0
  73. package/dist/client/assets/chunk-AQP2D5EJ-B4ikBK42.js +231 -0
  74. package/dist/client/assets/chunk-FMBD7UC4-5zgtNnG2.js +15 -0
  75. package/dist/client/assets/chunk-ND2GUHAM-ByrypRna.js +1 -0
  76. package/dist/client/assets/chunk-QZHKN3VN-B7D1exsu.js +1 -0
  77. package/dist/client/assets/classDiagram-4FO5ZUOK-WqSUwcK_.js +1 -0
  78. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-WqSUwcK_.js +1 -0
  79. package/dist/client/assets/common-BDp2y6CF.js +1 -0
  80. package/dist/client/assets/common-BnEo5fLN.js +1 -0
  81. package/dist/client/assets/common-Bzr_Y8h4.js +1 -0
  82. package/dist/client/assets/common-CvwyFzfv.js +1 -0
  83. package/dist/client/assets/common-CztCXRkz.js +1 -0
  84. package/dist/client/assets/common-DPe2mbb7.js +1 -0
  85. package/dist/client/assets/cose-bilkent-S5V4N54A-CQmiNzGr.js +1 -0
  86. package/dist/client/assets/cytoscape.esm-OyMbaexL.js +331 -0
  87. package/dist/client/assets/dagre-BM42HDAG-BH8Uk0Up.js +4 -0
  88. package/dist/client/assets/{dashboard-view-B4LXCv5H.js → dashboard-view-CWJ-b59n.js} +1680 -1620
  89. package/dist/client/assets/dashboard-view-D3PWY2PH.js +1 -0
  90. package/dist/client/assets/dashboard-view-D_zsA-kz.css +1 -0
  91. package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  92. package/dist/client/assets/diagram-2AECGRRQ-CDoHfkxY.js +43 -0
  93. package/dist/client/assets/diagram-5GNKFQAL-DARILCuD.js +10 -0
  94. package/dist/client/assets/diagram-KO2AKTUF-CNP-qi0y.js +3 -0
  95. package/dist/client/assets/diagram-LMA3HP47-SCiVmkcf.js +24 -0
  96. package/dist/client/assets/diagram-OG6HWLK6-iTJLXH61.js +24 -0
  97. package/dist/client/assets/erDiagram-TEJ5UH35-ByMpiPIa.js +85 -0
  98. package/dist/client/assets/flowDiagram-I6XJVG4X-DW3m3ZpM.js +162 -0
  99. package/dist/client/assets/{folder-open-33WGVnbp.js → folder-open-G-9vPAdv.js} +1 -1
  100. package/dist/client/assets/ganttDiagram-6RSMTGT7-BJeYH7Ol.js +292 -0
  101. package/dist/client/assets/gitGraphDiagram-PVQCEYII-CK_Chj4m.js +106 -0
  102. package/dist/client/assets/graph--OzhPTMs.js +1 -0
  103. package/dist/client/assets/index-BZBQ_KsL.css +1 -0
  104. package/dist/client/assets/index-ccFe_1av.js +1459 -0
  105. package/dist/client/assets/infoDiagram-5YYISTIA-D8Wg1IgN.js +2 -0
  106. package/dist/client/assets/init-Dmth1JHB.js +1 -0
  107. package/dist/client/assets/ishikawaDiagram-YF4QCWOH-DWROR2aX.js +70 -0
  108. package/dist/client/assets/journeyDiagram-JHISSGLW-Bns9774_.js +139 -0
  109. package/dist/client/assets/kanban-definition-UN3LZRKU-QtURfAoI.js +89 -0
  110. package/dist/client/assets/katex-HP8lGamR.js +257 -0
  111. package/dist/client/assets/layout-SsrduOYp.js +1 -0
  112. package/dist/client/assets/linear-dXivciGL.js +1 -0
  113. package/dist/client/assets/mermaid.core-DqgrgWWm.js +309 -0
  114. package/dist/client/assets/mindmap-definition-RKZ34NQL-jLaDb5_X.js +96 -0
  115. package/dist/client/assets/ordinal-DILIJJjt.js +1 -0
  116. package/dist/client/assets/pieDiagram-4H26LBE5-CjbHuIje.js +30 -0
  117. package/dist/client/assets/quadrantDiagram-W4KKPZXB-xgHbylQr.js +7 -0
  118. package/dist/client/assets/requirementDiagram-4Y6WPE33-CHdD7W41.js +84 -0
  119. package/dist/client/assets/sankeyDiagram-5OEKKPKP-C3me87g9.js +40 -0
  120. package/dist/client/assets/sequenceDiagram-3UESZ5HK-DSHfs1kU.js +162 -0
  121. package/dist/client/assets/{shield-alert-CqeGWBUK.js → shield-alert-DkGlhVjI.js} +1 -1
  122. package/dist/client/assets/stateDiagram-AJRCARHV-C08n7sMP.js +1 -0
  123. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BosoAbfO.js +1 -0
  124. package/dist/client/assets/step-yuy0qJer.js +1 -0
  125. package/dist/client/assets/time-DoDTxsna.js +1 -0
  126. package/dist/client/assets/timeline-definition-PNZ67QCA-C21h9Zqh.js +120 -0
  127. package/dist/client/assets/{upload-C11J2diI.js → upload-B9B-tYt9.js} +1 -1
  128. package/dist/client/assets/{users-a-ELbyyZ.js → users-C_BA3C7E.js} +1 -1
  129. package/dist/client/assets/{vendor-i18n-DYlSUfot.js → vendor-i18n-GF3RlKbq.js} +2 -2
  130. package/dist/client/assets/{vendor-react-BTgM5bbZ.js → vendor-react-SZ_qB27O.js} +1 -1
  131. package/dist/client/assets/vendor-reactflow-Bg-Qjzh8.js +15 -0
  132. package/dist/client/assets/{vendor-xterm-ea7-K05z.js → vendor-xterm-BNq00GSj.js} +1 -1
  133. package/dist/client/assets/vennDiagram-CIIHVFJN-Bv3G0dwI.js +34 -0
  134. package/dist/client/assets/wardley-L42UT6IY-WX0hHKcN.js +173 -0
  135. package/dist/client/assets/wardleyDiagram-YWT4CUSO-CMwIPWm7.js +78 -0
  136. package/dist/client/assets/xychartDiagram-2RQKCTM6-CZvFdt6j.js +7 -0
  137. package/dist/client/assets/zoom-out-NWbVkreR.js +41 -0
  138. package/dist/client/index.html +30 -10
  139. package/dist/client/sw.js +1 -1
  140. package/dist/client/theme-data.css +3082 -206
  141. package/dist/client/version.json +1 -1
  142. package/dist/droid-cli/index.ts +56 -40
  143. package/dist/droid-cli/package.json +1 -1
  144. package/dist/droid-cli/src/__tests__/index.test.ts +47 -21
  145. package/dist/droid-cli/src/__tests__/process-manager.test.ts +50 -33
  146. package/dist/extension.js +5405 -919
  147. package/dist/pi-claude-cli/package.json +1 -1
  148. package/dist/pi-claude-cli/src/__tests__/process-manager.test.ts +25 -0
  149. package/dist/pi-claude-cli/src/process-manager.ts +11 -1
  150. package/dist/plugin-sdk/index.d.ts +137 -4
  151. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  152. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  153. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  154. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  155. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  156. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +68 -44
  157. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  158. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  159. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  160. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  161. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  162. package/dist/plugins/fusion-plugin-roadmap/bundled.js +5 -11
  163. package/dist/plugins/fusion-plugin-roadmap/manifest.json +1 -11
  164. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  165. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  166. package/package.json +3 -3
  167. package/skill/fusion/SKILL.md +1 -1
  168. package/skill/fusion/references/cli-commands.md +2 -1
  169. package/skill/fusion/references/extension-tools.md +10 -0
  170. package/skill/fusion/references/fusion-capabilities.md +3 -1
  171. package/dist/client/assets/AgentDetailView-CanIeYHg.css +0 -1
  172. package/dist/client/assets/AgentDetailView-DxV8pFHX.js +0 -18
  173. package/dist/client/assets/AgentsView-BVILQjdS.css +0 -1
  174. package/dist/client/assets/AgentsView-CTzbcvhK.js +0 -29
  175. package/dist/client/assets/ChatView-COygcnyk.js +0 -6
  176. package/dist/client/assets/ChatView-DwJAd5G1.css +0 -1
  177. package/dist/client/assets/CommandCenter-CTaopaC0.css +0 -1
  178. package/dist/client/assets/CommandCenter-DoKX2HWm.js +0 -56
  179. package/dist/client/assets/DevServerView-Cyevyvqx.js +0 -1
  180. package/dist/client/assets/DevServerView-VTQY28P7.css +0 -1
  181. package/dist/client/assets/DirectoryPicker-DBdyXEhR.js +0 -1
  182. package/dist/client/assets/DocumentsView-BzSMyrns.js +0 -1
  183. package/dist/client/assets/DocumentsView-WfVoTZt8.css +0 -1
  184. package/dist/client/assets/EvalsView-CUNJ1TLc.css +0 -1
  185. package/dist/client/assets/EvalsView-ikz00o9g.js +0 -1
  186. package/dist/client/assets/ExperimentalAgentOnboardingModal-D-rzCCET.js +0 -499
  187. package/dist/client/assets/GoalsView-Bfu1Oy2-.js +0 -2
  188. package/dist/client/assets/GoalsView-rg9VSIza.css +0 -1
  189. package/dist/client/assets/InsightsView-Cgmf5nES.js +0 -11
  190. package/dist/client/assets/InsightsView-LMv1M1dU.css +0 -1
  191. package/dist/client/assets/MemoryView-DkEuDKQs.js +0 -2
  192. package/dist/client/assets/MemoryView-zaXewZzi.css +0 -1
  193. package/dist/client/assets/NodesView-7VInxyf_.css +0 -1
  194. package/dist/client/assets/NodesView-B_KYfS4o.js +0 -14
  195. package/dist/client/assets/PiExtensionsManager-Dz69kkKs.js +0 -11
  196. package/dist/client/assets/PluginManager-LHCVcduP.js +0 -1
  197. package/dist/client/assets/PullRequestView-3AdbS2a1.css +0 -1
  198. package/dist/client/assets/PullRequestView-DBJutLLl.js +0 -6
  199. package/dist/client/assets/ResearchView-DTh8FLUm.css +0 -1
  200. package/dist/client/assets/ResearchView-gpn1XcVy.js +0 -1
  201. package/dist/client/assets/SecretsView-B7YqIowt.js +0 -1
  202. package/dist/client/assets/SecretsView-Djo1rahi.css +0 -1
  203. package/dist/client/assets/SessionTerminal-9l4bdKcn.js +0 -2
  204. package/dist/client/assets/SessionTerminal-BNgtmXb3.css +0 -1
  205. package/dist/client/assets/SettingsModal-BGEK9_9A.js +0 -31
  206. package/dist/client/assets/SettingsModal-CKv0TJfM.css +0 -1
  207. package/dist/client/assets/SettingsModal-CXogw-Er.css +0 -1
  208. package/dist/client/assets/SettingsModal-DIIoHGUH.js +0 -1
  209. package/dist/client/assets/SetupWizardModal-BcVeMxeX.js +0 -1
  210. package/dist/client/assets/SetupWizardModal-CIqFbkrD.css +0 -1
  211. package/dist/client/assets/SkillsView-3bhGyWs1.css +0 -1
  212. package/dist/client/assets/SkillsView-BxSJ4PHL.js +0 -1
  213. package/dist/client/assets/StashRecoveryView-B_8WIQEo.css +0 -1
  214. package/dist/client/assets/StashRecoveryView-BhFQ2FsP.js +0 -1
  215. package/dist/client/assets/TodoView-7xIh-Fmi.css +0 -1
  216. package/dist/client/assets/TodoView-BZpewjy0.js +0 -6
  217. package/dist/client/assets/WorkflowNodeEditor-Yn1FRF2v.css +0 -1
  218. package/dist/client/assets/WorkflowNodeEditor-tWsgCdVt.js +0 -8
  219. package/dist/client/assets/app-BmGA0Hiz.js +0 -13
  220. package/dist/client/assets/app-CEVYlVuJ.js +0 -13
  221. package/dist/client/assets/app-CbBFax2C.js +0 -13
  222. package/dist/client/assets/app-DORKrGAz.js +0 -13
  223. package/dist/client/assets/app-DQibuQ9z.js +0 -13
  224. package/dist/client/assets/app-k76GrQP0.js +0 -13
  225. package/dist/client/assets/common-BRyX4VxB.js +0 -1
  226. package/dist/client/assets/common-CN9QPI2d.js +0 -1
  227. package/dist/client/assets/common-CNbjPELi.js +0 -1
  228. package/dist/client/assets/common-DFDqu_n0.js +0 -1
  229. package/dist/client/assets/common-DgWWKG8Z.js +0 -1
  230. package/dist/client/assets/common-X6PzBnVA.js +0 -1
  231. package/dist/client/assets/createLucideIcon-DmVITl5d.js +0 -21
  232. package/dist/client/assets/dashboard-view-BFoyhTYF.js +0 -3
  233. package/dist/client/assets/dashboard-view-Cxzm_eqc.js +0 -1
  234. package/dist/client/assets/dashboard-view-DdGlfuu-.css +0 -1
  235. package/dist/client/assets/dashboard-view-_8yfNwju.css +0 -1
  236. package/dist/client/assets/index-Bglw05rM.js +0 -791
  237. package/dist/client/assets/index-FYgnflWD.css +0 -1
  238. package/dist/client/assets/vendor-reactflow-ZasuEfF9.js +0 -15
  239. package/dist/client/assets/x-PItWc-wQ.js +0 -61
  240. package/dist/client/assets/zoom-out-CzlHv0Kj.js +0 -21
@@ -1,8 +0,0 @@
1
- import{r as o,j as e,b as Qa}from"./vendor-react-BTgM5bbZ.js";import{R as Za,u as eo,d as to,e as so,i as ao,B as oo,C as no,M as lo}from"./vendor-reactflow-ZasuEfF9.js";import{c as io,eM as Vt,eN as ke,eO as ca,eP as ro,eQ as co,eR as uo,eS as ua,z as ae,j as mt,J as ye,T as De,B as fo,al as mo,a as Ne,U as ve,ba as fa,e3 as po,i as pt,e4 as Is,aq as ma,b9 as Gt,b as Pe,m as Ut,b8 as wo,eT as ho,eU as go,eV as Rs,eW as xo,eX as bo,eY as ko,e9 as vo,p as jo,d4 as Ps,v as No,eZ as yo,e_ as Co,e$ as So,f0 as Eo,f1 as Fo,f2 as Ao,e0 as Mo,f3 as Io,f4 as Ro,f5 as Po,f6 as Ds,f7 as Ts,f8 as zs,f9 as Do,fa as To,fb as zo,fc as Lo,fd as Oo,fe as $o,ff as Wo,fg as Bo,fh as _o,fi as qo,fj as Vo,fk as Ls,fl as Go,fm as Os,fn as $s,fo as Uo,fp as Ot,fq as Ho,fr as pa,fs as Yo,ft as Ws,fu as Ko,bY as Bs,eC as wa,M as Jo,X as Ht,L as Ae,bN as Xo,fv as $t,cP as ha,bz as Qo,eG as Zo,bA as en,b2 as tn,cT as sn,fw as an,fx as on,fy as nn,fz as _s,fA as ln,fB as rn,fC as dn,b5 as ft,ax as Be,fD as cn,fE as un,fF as fn,fG as mn,cE as pn,fH as wn,fI as hn}from"./index-Bglw05rM.js";import{u as je}from"./vendor-i18n-DYlSUfot.js";import{U as gn}from"./upload-C11J2diI.js";import"./vendor-xterm-ea7-K05z.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
- * @license lucide-react v1.7.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const xn=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],bn=io("library",xn),kn=80,vn=24,qs=16,Vs=ro+kn,jn=0,Nn=0,Wt=ca+vn;function yn(s){return!(ke(s.id)||s.parentId)}function Cn(s,d){const r=new Set(s),w=new Map,i=new Map;for(const N of s)i.set(N,0);for(const N of d)N.data?.kind!=="rework"&&(!r.has(N.source)||!r.has(N.target)||N.source!==N.target&&((w.get(N.source)??w.set(N.source,[]).get(N.source)).push(N.target),i.set(N.target,(i.get(N.target)??0)+1)));const g=s.filter(N=>N==="start"),I=g.length?g:s.filter(N=>(i.get(N)??0)===0),u=new Map,D=s.length+1,A=[];for(const N of I)u.set(N,0),A.push(N);let C=s.length*s.length+s.length+1;for(;A.length&&C-- >0;){const N=A.shift(),p=u.get(N)??0;for(const c of w.get(N)??[]){const j=p+1,h=u.get(c);(h===void 0||j>h)&&j<=D&&(u.set(c,j),A.push(c))}}let L=0;for(const N of u.values())N>L&&(L=N);const b=u.size?L+1:0;for(const N of s)u.has(N)||u.set(N,b);return u}function Gs(s,d,r){const w=s.filter(yn),i=w.map(C=>C.id),g=Cn(i,d),I=new Map(w.map(C=>[C.id,C])),u=new Map,D=new Map;for(const C of i){const L=g.get(C)??0;(D.get(L)??D.set(L,[]).get(L)).push(C)}const A=r.length>0;for(const[C,L]of D){const b=[...L].sort((c,j)=>{const h=I.get(c),z=I.get(j);return h.position.y!==z.position.y?h.position.y-z.position.y:c<j?-1:c>j?1:0}),N=jn+C*Vs;if(!A){b.forEach((c,j)=>{u.set(c,{x:N,y:Nn+j*Wt})});continue}const p=new Map;for(const c of b){const j=I.get(c),h=j.data.column??(Vt(j.position.y,r)?Vt(j.position.y,r):void 0);if(!h){u.set(c,{x:N,y:j.position.y});continue}const z=r.findIndex(v=>v.id===h),k=z>=0?z:0,R=co(k),P=R+qs,K=R+uo-ca-qs,_=Math.max(1,Math.floor((K-P)/Wt)+1),Y=p.get(h??`__idx${k}`)??0,de=Y%_,q=Math.floor(Y/_),J=P+de*Wt,ce=N+q*(Vs/2);u.set(c,{x:ce,y:J}),p.set(h??`__idx${k}`,Y+1)}}return u}function Us(s,d){return s.map(r=>{const w=d.get(r.id);return w?{...r,position:w}:r})}let Hs=0;function Sn(){return Hs+=1,`col-${Date.now().toString(36)}-${Hs}`}function Ys({columns:s,onChange:d,violations:r,readOnly:w,projectId:i,addToast:g,columnAgentsEnabled:I}){const{t:u}=je("app"),[D,A]=o.useState([]),[C,L]=o.useState([]),[b,N]=o.useState(!0),[p,c]=o.useState(null);o.useEffect(()=>{let v=!1;return ua(i).then(S=>{v||A(S)}).catch(S=>{v||g(ae(S)||u("workflowColumns.traitsLoadFailed","Failed to load traits"),"error")}),()=>{v=!0}},[i,g,u]),o.useEffect(()=>{let v=!1;return N(!0),c(null),Promise.resolve(mt(void 0,i)).then(S=>{v||(L(S??[]),N(!1))}).catch(S=>{if(v)return;const W=ae(S)||u("workflowColumns.agentsLoadFailed","Failed to load agents");c(W),N(!1),g(W,"error")}),()=>{v=!0}},[i,g,u]);const j=o.useMemo(()=>C.map(v=>v.id).join(","),[C]),h=o.useMemo(()=>{const v=new Map;for(const S of C)v.set(S.id,S);return v},[j]),z=o.useCallback((v,S)=>{d(s.map(W=>{if(W.id!==v)return W;if(!S){const{agent:B,...ne}=W;return ne}return{...W,agent:S}}))},[s,d]),k=o.useCallback((v,S)=>{if(!S){z(v,void 0);return}const W=s.find(B=>B.id===v)?.agent;z(v,{agentId:S,mode:W?.mode??"defer"})},[s,z]),R=o.useCallback((v,S)=>{const W=s.find(B=>B.id===v)?.agent;W&&z(v,{...W,mode:S})},[s,z]),P=w||!I||b||!!p,K=r.filter(v=>v.columnId===null),_=o.useCallback(v=>r.filter(S=>S.columnId===v),[r]),Y=o.useCallback(()=>{const v=Sn();d([...s,{id:v,name:u("workflowColumns.newColumnName","New column"),traits:[]}])},[s,d,u]),de=o.useCallback((v,S)=>{d(s.map(W=>W.id===v?{...W,name:S}:W))},[s,d]),q=o.useCallback(v=>{d(s.filter(S=>S.id!==v))},[s,d]),J=o.useCallback((v,S)=>{const W=v+S;if(W<0||W>=s.length)return;const B=[...s];[B[v],B[W]]=[B[W],B[v]],d(B)},[s,d]),ce=o.useCallback((v,S)=>{d(s.map(W=>{if(W.id!==v)return W;const B=W.traits.some(ne=>ne.trait===S);return{...W,traits:B?W.traits.filter(ne=>ne.trait!==S):[...W.traits,{trait:S}]}}))},[s,d]);return e.jsxs("aside",{className:"wf-column-panel","data-testid":"wf-column-panel",children:[e.jsxs("header",{className:"wf-column-panel-header",children:[e.jsx("h3",{children:u("workflowColumns.title","Columns")}),e.jsxs("button",{className:"wf-column-add",onClick:Y,disabled:w,title:w?u("workflowColumns.readOnlyHint","Built-in workflows are read-only — duplicate to edit"):void 0,children:[e.jsx(ye,{size:13})," ",u("workflowColumns.add","Add column")]})]}),K.length>0&&e.jsx("div",{className:"wf-column-panel-errors",role:"alert",children:K.map((v,S)=>e.jsxs("p",{className:"wf-column-violation",children:[e.jsx(De,{size:12,"aria-hidden":!0})," ",v.message]},`${v.code}-${S}`))}),s.length===0?e.jsx("p",{className:"wf-column-panel-empty",children:u("workflowColumns.empty","No columns yet. Add a column to place nodes into board lanes.")}):e.jsx("ul",{className:"wf-column-list",children:s.map((v,S)=>{const W=_(v.id),B=v.agent?.agentId,ne=B?h.get(B):void 0,le=!!B&&!b&&!p&&!ne,ie=ne?.name??(le?u("workflowColumns.agentNotFound","Agent not found — {{id}}",{id:B??""}):B);return e.jsxs("li",{className:`wf-column-item${W.length?" wf-column-item--error":""}`,"data-testid":`wf-column-${v.id}`,"data-column-error":W.length?"true":void 0,children:[e.jsxs("div",{className:"wf-column-item-head",children:[e.jsx("input",{className:"wf-column-name","aria-label":u("workflowColumns.nameLabel","Column name"),value:v.name,disabled:w,onChange:Z=>de(v.id,Z.target.value)}),B&&e.jsxs("span",{className:`wf-column-agent-badge${le?" wf-column-agent-badge--stale":""}`,"data-testid":`wf-column-agent-badge-${v.id}`,title:v.agent?.mode==="override"?u("workflowColumns.agentBadgeOverride","Column agent (override)"):u("workflowColumns.agentBadgeDefer","Column agent (defer)"),children:[e.jsx(fo,{size:11,"aria-hidden":!0})," ",ie]}),e.jsxs("div",{className:"wf-column-item-actions",children:[e.jsx("button",{className:"wf-column-move","aria-label":u("workflowColumns.moveUp","Move column up"),disabled:w||S===0,onClick:()=>J(S,-1),children:e.jsx(mo,{size:13})}),e.jsx("button",{className:"wf-column-move","aria-label":u("workflowColumns.moveDown","Move column down"),disabled:w||S===s.length-1,onClick:()=>J(S,1),children:e.jsx(Ne,{size:13})}),e.jsx("button",{className:"wf-column-remove","aria-label":u("workflowColumns.remove","Remove column"),disabled:w,onClick:()=>q(v.id),children:e.jsx(ve,{size:13})})]})]}),W.map((Z,se)=>e.jsxs("p",{className:"wf-column-violation",role:"alert",children:[e.jsx(De,{size:12,"aria-hidden":!0})," ",Z.message]},`${Z.code}-${se}`)),e.jsxs("div",{className:"wf-column-traits",children:[e.jsx("span",{className:"wf-column-traits-label",children:u("workflowColumns.traits","Traits")}),e.jsx("div",{className:"wf-column-trait-options",children:D.map(Z=>{const se=v.traits.some(E=>E.trait===Z.id);return e.jsxs("label",{className:"wf-column-trait",title:Z.description,children:[e.jsx("input",{type:"checkbox",checked:se,disabled:w,onChange:()=>ce(v.id,Z.id)}),e.jsx("span",{children:Z.name})]},Z.id)})})]}),e.jsxs("div",{className:"wf-column-agent",children:[e.jsx("span",{className:"wf-column-agent-label",children:u("workflowColumns.agent","Column agent")}),e.jsxs("select",{className:"wf-column-agent-select","data-testid":`wf-column-agent-select-${v.id}`,"aria-label":u("workflowColumns.agentLabel","Column agent"),value:B??"",disabled:P,title:I?w?u("workflowColumns.readOnlyHint","Built-in workflows are read-only — duplicate to edit"):void 0:u("workflowColumns.agentFlagHint","Enable both experimentalFeatures.workflowColumns and experimentalFeatures.workflowGraphExecutor to staff columns with agents"),onChange:Z=>k(v.id,Z.target.value),children:[e.jsx("option",{value:"",children:u("workflowColumns.agentNone","(none)")}),le&&B&&e.jsx("option",{value:B,children:u("workflowColumns.agentNotFound","Agent not found — {{id}}",{id:B})}),C.map(Z=>e.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),p&&e.jsxs("p",{className:"wf-column-agent-error",role:"alert",children:[e.jsx(De,{size:12,"aria-hidden":!0})," ",p]}),le&&e.jsxs("p",{className:"wf-column-agent-stale",role:"alert","data-testid":`wf-column-agent-stale-${v.id}`,children:[e.jsx(De,{size:12,"aria-hidden":!0})," ",u("workflowColumns.agentNotFound","Agent not found — {{id}}",{id:B??""})]}),B&&e.jsxs("div",{className:"wf-column-agent-mode",role:"radiogroup","aria-label":u("workflowColumns.agentMode","Agent mode"),children:[e.jsxs("label",{className:"wf-column-agent-mode-option",children:[e.jsx("input",{type:"radio",name:`wf-column-agent-mode-${v.id}`,checked:(v.agent?.mode??"defer")==="defer",disabled:P,onChange:()=>R(v.id,"defer")}),e.jsx("span",{title:u("workflowColumns.agentModeDeferHint","Column agent applies only when the work carries no agent/model settings of its own"),children:u("workflowColumns.agentModeDefer","Defer")})]}),e.jsxs("label",{className:"wf-column-agent-mode-option",children:[e.jsx("input",{type:"radio",name:`wf-column-agent-mode-${v.id}`,checked:v.agent?.mode==="override",disabled:P,onChange:()=>R(v.id,"override")}),e.jsx("span",{title:u("workflowColumns.agentModeOverrideHint","Column agent supersedes node- and task-level agent/model settings"),children:u("workflowColumns.agentModeOverride","Override")})]})]})]})]},v.id)})})]})}const En=["string","text","number","boolean","enum","multi-enum","date","url"],Ks={string:["input"],text:["textarea","input"],number:["input"],boolean:["toggle"],enum:["select","radio","chips"],"multi-enum":["chips"],date:["input"],url:["input"]},Fn=["#4f7cff","#22c55e","#f59e0b","#ef4444","#a855f7","#06b6d4","#ec4899","#64748b"];function wt(s){return s==="enum"||s==="multi-enum"}function An(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}let Js=0;function Mn(){return Js+=1,`field-${Date.now().toString(36)}-${Js}`}function In({field:s}){const d=o.useMemo(()=>{if(wt(s.type)){const w=s.options?.[0];return w?s.type==="multi-enum"?{node:e.jsx("span",{className:"card-field-badge card-field-badge--multi",title:s.name,children:(s.options??[]).slice(0,2).map(i=>e.jsx("span",{className:"card-field-badge-token",style:i.color?{backgroundColor:i.color,borderColor:i.color,color:"#fff"}:void 0,children:i.label},i.value))})}:{node:e.jsx("span",{className:"card-field-badge card-field-badge--enum",title:`${s.name}: ${w.label}`,style:w.color?{backgroundColor:w.color,borderColor:w.color,color:"#fff"}:void 0,children:w.label})}:null}if(s.type==="boolean")return{node:e.jsx("span",{className:"card-field-badge card-field-badge--boolean",title:s.name,children:s.name})};const r=s.type==="number"?"42":s.type==="date"?"2026-06-04":s.type==="url"?"example.com":s.name;return{node:e.jsx("span",{className:"card-field-badge",title:s.name,children:r})}},[s]);return d?e.jsx("div",{className:"wf-field-preview","data-testid":`wf-field-preview-${s.id}`,children:e.jsx("div",{className:"card-field-badges",children:d.node})}):null}function Xs({fields:s,onChange:d,readOnly:r,addToast:w}){const{t:i}=je("app"),[g,I]=o.useState(null),u=o.useCallback((c,j)=>{d(s.map(h=>h.id===c?{...h,...j}:h))},[s,d]),D=o.useCallback(()=>{const c=Mn();d([...s,{id:c,name:i("workflowFields.newFieldName","New field"),type:"string"}])},[s,d,i]),A=o.useCallback(c=>{d(s.filter(j=>j.id!==c))},[s,d]),C=o.useCallback((c,j)=>{const h=An(j);if(h){if(h!==c&&s.some(z=>z.id===h)){w(i("workflowFields.duplicateId","A field with that id already exists"),"error");return}u(c,{id:h})}},[s,u,w,i]),L=o.useCallback((c,j)=>{const h=s.find(k=>k.id===c);if(!h)return;const z={type:j};wt(j)?(!h.options||h.options.length===0)&&(z.options=[{value:"option-1",label:i("workflowFields.newOptionLabel","Option 1")}]):z.options=void 0,h.render?.widget&&!Ks[j].includes(h.render.widget)&&(z.render={...h.render,widget:void 0}),z.default=void 0,u(c,z)},[s,u,i]),b=o.useCallback((c,j)=>u(c,{options:j}),[u]),N=o.useCallback((c,j)=>{const h=!j||j.placement===void 0&&j.widget===void 0&&!j.badge;u(c,{render:h?void 0:j})},[u]),p=c=>{const j=k=>u(c.id,{default:k});if(c.type==="boolean")return e.jsxs("label",{className:"wf-field--checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.default===!0,disabled:r,onChange:k=>j(k.target.checked)}),e.jsx("span",{children:i("workflowFields.defaultTrue","Default on")})]});if(wt(c.type)){const k=c.type==="multi-enum"?Array.isArray(c.default)?c.default[0]??"":"":typeof c.default=="string"?c.default:"";return e.jsxs("select",{"aria-label":i("workflowFields.defaultLabel","Default value"),value:k,disabled:r,onChange:R=>{const P=R.target.value;if(P==="")return j(void 0);j(c.type==="multi-enum"?[P]:P)},children:[e.jsx("option",{value:"",children:i("workflowFields.noDefault","— none —")}),(c.options??[]).map(R=>e.jsx("option",{value:R.value,children:R.label},R.value))]})}const h=c.type==="number"?"number":c.type==="date"?"date":c.type==="url"?"url":"text",z=c.type==="number"?typeof c.default=="number"?String(c.default):"":typeof c.default=="string"?c.default:"";return e.jsx("input",{type:h,"aria-label":i("workflowFields.defaultLabel","Default value"),defaultValue:z,disabled:r,onBlur:k=>{const R=k.target.value;if(R==="")return j(void 0);j(c.type==="number"?Number(R):R)}})};return e.jsxs("aside",{className:"wf-fields-panel","data-testid":"wf-fields-panel",children:[e.jsxs("header",{className:"wf-fields-panel-header",children:[e.jsx("h3",{children:i("workflowFields.title","Fields")}),e.jsxs("button",{className:"wf-fields-add",onClick:D,disabled:r,title:r?i("workflowFields.readOnlyHint","Built-in workflows are read-only — duplicate to edit"):void 0,children:[e.jsx(ye,{size:13})," ",i("workflowFields.add","Add field")]})]}),s.length===0?e.jsx("p",{className:"wf-fields-panel-empty",children:i("workflowFields.empty","No custom fields yet. Add a field to extend the task form and cards.")}):e.jsx("ul",{className:"wf-fields-list",children:s.map(c=>{const j=Ks[c.type],h=c.render?.placement??"detail",z=g===c.id;return e.jsxs("li",{className:"wf-field-item","data-testid":`wf-field-${c.id}`,children:[e.jsxs("div",{className:"wf-field-item-head",children:[e.jsx("input",{className:"wf-field-name","aria-label":i("workflowFields.nameLabel","Field name"),value:c.name,disabled:r,onChange:k=>u(c.id,{name:k.target.value})}),e.jsx("button",{className:"wf-field-remove","aria-label":i("workflowFields.remove","Remove field"),disabled:r,onClick:()=>A(c.id),children:e.jsx(ve,{size:13})})]}),e.jsx("div",{className:"wf-field-id-row",children:z?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"wf-field-id","aria-label":i("workflowFields.idLabel","Field id"),defaultValue:c.id,disabled:r,onBlur:k=>{C(c.id,k.target.value),I(null)}}),e.jsxs("p",{className:"wf-field-id-warn",role:"note",children:[e.jsx(De,{size:11,"aria-hidden":!0})," ",i("workflowFields.idWarn","Changing the id discards values stored under the old id (remove + add).")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"wf-field-id-static",children:c.id}),e.jsx("button",{className:"wf-field-id-edit",disabled:r,onClick:()=>I(c.id),children:i("workflowFields.editId","Edit id")})]})}),e.jsxs("div",{className:"wf-field-row",children:[e.jsxs("label",{className:"wf-field-sub",children:[e.jsx("span",{children:i("workflowFields.typeLabel","Type")}),e.jsx("select",{value:c.type,disabled:r,onChange:k=>L(c.id,k.target.value),children:En.map(k=>e.jsx("option",{value:k,children:k},k))})]}),e.jsxs("label",{className:"wf-field--checkbox wf-field-required",children:[e.jsx("input",{type:"checkbox",checked:c.required===!0,disabled:r,onChange:k=>u(c.id,{required:k.target.checked||void 0})}),e.jsx("span",{children:i("workflowFields.required","Required")})]})]}),e.jsxs("label",{className:"wf-field-sub",children:[e.jsx("span",{children:i("workflowFields.default","Default")}),p(c)]}),wt(c.type)&&e.jsxs("div",{className:"wf-field-options","data-testid":`wf-field-options-${c.id}`,children:[e.jsx("span",{className:"wf-field-options-label",children:i("workflowFields.options","Options")}),(c.options??[]).map((k,R)=>e.jsxs("div",{className:"wf-field-option-row",children:[e.jsx("input",{className:"wf-field-option-value","aria-label":i("workflowFields.optionValue","Option value"),value:k.value,disabled:r,onChange:P=>{const K=[...c.options??[]];K[R]={...k,value:P.target.value},b(c.id,K)}}),e.jsx("input",{className:"wf-field-option-label","aria-label":i("workflowFields.optionLabel","Option label"),value:k.label,disabled:r,onChange:P=>{const K=[...c.options??[]];K[R]={...k,label:P.target.value},b(c.id,K)}}),e.jsx("div",{className:"wf-field-option-colors",role:"group","aria-label":i("workflowFields.optionColor","Option color"),children:Fn.map(P=>e.jsx("button",{type:"button",className:`wf-field-color-swatch${k.color===P?" is-active":""}`,style:{backgroundColor:P},"aria-label":P,"aria-pressed":k.color===P,disabled:r,onClick:()=>{const K=[...c.options??[]];K[R]={...k,color:k.color===P?void 0:P},b(c.id,K)}},P))}),e.jsx("button",{className:"wf-field-option-remove","aria-label":i("workflowFields.removeOption","Remove option"),disabled:r,onClick:()=>b(c.id,(c.options??[]).filter((P,K)=>K!==R)),children:e.jsx(ve,{size:12})})]},R)),e.jsxs("button",{className:"wf-field-option-add",disabled:r,onClick:()=>{const k=(c.options??[]).length+1;b(c.id,[...c.options??[],{value:`option-${k}`,label:i("workflowFields.optionN","Option {{n}}",{n:k})}])},children:[e.jsx(ye,{size:12})," ",i("workflowFields.addOption","Add option")]})]}),e.jsxs("div",{className:"wf-field-render",children:[e.jsxs("label",{className:"wf-field-sub",children:[e.jsx("span",{children:i("workflowFields.placement","Placement")}),e.jsxs("select",{value:h,disabled:r,onChange:k=>N(c.id,{...c.render,placement:k.target.value}),children:[e.jsx("option",{value:"detail",children:i("workflowFields.placementDetail","Detail (inline)")}),e.jsx("option",{value:"detail-section",children:i("workflowFields.placementSection","Detail section")}),e.jsx("option",{value:"card",children:i("workflowFields.placementCard","Card badge")})]})]}),e.jsxs("label",{className:"wf-field-sub",children:[e.jsx("span",{children:i("workflowFields.widget","Widget")}),e.jsxs("select",{value:c.render?.widget??"",disabled:r,onChange:k=>N(c.id,{...c.render,widget:k.target.value||void 0}),children:[e.jsx("option",{value:"",children:i("workflowFields.widgetDefault","Default")}),j.map(k=>e.jsx("option",{value:k,children:k},k))]})]}),e.jsxs("label",{className:"wf-field--checkbox",children:[e.jsx("input",{type:"checkbox",checked:c.render?.badge===!0,disabled:r,onChange:k=>N(c.id,{...c.render,badge:k.target.checked||void 0})}),e.jsx("span",{children:i("workflowFields.badge","Render as badge")})]})]}),h==="card"&&e.jsx(In,{field:c})]},c.id)})})]})}const Rn={planningProvider:{group:"models",label:"Plan/Triage provider",description:"Provider used when planning or triaging tasks."},planningModelId:{group:"models",label:"Plan/Triage model",description:"Model used when planning or triaging tasks."},planningFallbackProvider:{group:"models",label:"Plan/Triage fallback provider"},planningFallbackModelId:{group:"models",label:"Plan/Triage fallback model"},executionProvider:{group:"models",label:"Executor provider",description:"Provider used by task implementation agents."},executionModelId:{group:"models",label:"Executor model",description:"Model used by task implementation agents."},validatorProvider:{group:"models",label:"Reviewer provider",description:"Provider used by review and validation agents."},validatorModelId:{group:"models",label:"Reviewer model",description:"Model used by review and validation agents."},validatorFallbackProvider:{group:"models",label:"Reviewer fallback provider"},validatorFallbackModelId:{group:"models",label:"Reviewer fallback model"},requirePrApproval:{group:"review",label:"Require PR approval"},requirePlanApproval:{group:"review",label:"Require plan approval"},reviewHandoffPolicy:{group:"review",label:"Review handoff policy"},maxReviewerContextRetries:{group:"review",label:"Reviewer context retries"},maxReviewerFallbackRetries:{group:"review",label:"Reviewer fallback retries"},reflectionEnabled:{group:"review",label:"Reflection enabled"},workflowStepTimeoutMs:{group:"steps",label:"Step timeout"},workflowStepScopeEnforcement:{group:"steps",label:"Step scope enforcement"},planOnlyScopeLeakEnforcement:{group:"steps",label:"Plan-only scope leak enforcement"},workflowRevisionForkOnScopeMismatch:{group:"steps",label:"Fork revision on scope mismatch"},strictScopeEnforcement:{group:"steps",label:"Strict scope enforcement"},runStepsInNewSessions:{group:"steps",label:"Run steps in new sessions"},maxParallelSteps:{group:"steps",label:"Max parallel steps"},buildRetryCount:{group:"steps",label:"Build retry count"},verificationFixRetries:{group:"steps",label:"Verification fix retries"},maxPostReviewFixes:{group:"steps",label:"Post-review fix passes"}},Pn=["models","review","steps","advanced"],Dn={models:"Models",review:"Review & Approval",steps:"Step Execution",advanced:"Advanced"};function ga(s){return Rn[s.id]??{group:"advanced",label:s.name,description:s.description}}function Tn(s){const d=new Map;for(const r of s){const w=ga(r).group,i=d.get(w)??[];i.push(r),d.set(w,i)}return Pn.map(r=>({group:r,settings:d.get(r)??[]})).filter(r=>r.settings.length>0)}function qe({htmlFor:s,label:d,help:r,error:w,scope:i,disabled:g,clearable:I,onClear:u,children:D}){const{t:A}=je("app");return e.jsxs("div",{className:`settings-field-row${g?" is-disabled":""}`,children:[e.jsxs("div",{className:"settings-field-row-head",children:[e.jsx("label",{className:"settings-field-row-label",htmlFor:s,children:d}),i&&e.jsx("span",{className:`settings-field-row-scope settings-field-row-scope--${i}`,"data-testid":"settings-field-row-scope",children:i})]}),e.jsxs("div",{className:"settings-field-row-control",children:[D,I&&e.jsx("button",{type:"button",className:"settings-field-row-clear","aria-label":A("settings.clearToDefault","Reset to default"),title:A("settings.clearToDefault","Reset to default"),disabled:g,onClick:u,children:e.jsx(fa,{size:13,"aria-hidden":!0})})]}),r&&e.jsx("p",{className:"settings-field-row-help",children:r}),w&&e.jsx("p",{className:"settings-field-row-error",role:"alert",children:w})]})}function zn({descriptor:s,value:d,onChange:r,error:w,clearable:i}){const{key:g,label:I,help:u,scope:D,disabled:A}=s;return e.jsx(qe,{htmlFor:g,label:I,help:u,error:w,scope:D,disabled:A,clearable:i,onClear:()=>r(null),children:e.jsx("label",{className:"settings-toggle",children:e.jsx("input",{id:g,type:"checkbox",checked:d===!0,disabled:A,onChange:C=>r(C.target.checked)})})})}function Ln({descriptor:s,value:d,onChange:r,error:w,clearable:i}){const{key:g,label:I,help:u,scope:D,disabled:A,min:C,max:L,step:b,placeholder:N}=s;return e.jsx(qe,{htmlFor:g,label:I,help:u,error:w,scope:D,disabled:A,clearable:i,onClear:()=>r(null),children:e.jsx("input",{id:g,className:"settings-number",type:"number",value:d??"",min:C,max:L,step:b,placeholder:N,disabled:A,onChange:p=>{const c=p.target.value;if(c==="")return r(null);const j=Number(c);Number.isNaN(j)||r(j)}})})}function Qs({descriptor:s,value:d,onChange:r,error:w,clearable:i}){const{key:g,label:I,help:u,scope:D,disabled:A,options:C}=s;return e.jsx(qe,{htmlFor:g,label:I,help:u,error:w,scope:D,disabled:A,clearable:i,onClear:()=>r(null),children:e.jsx("select",{id:g,className:"settings-select",value:d??"",disabled:A,onChange:L=>r(L.target.value),children:C.map(L=>e.jsx("option",{value:L.value,children:L.label},L.value))})})}function On({descriptor:s,value:d,onChange:r,error:w,clearable:i}){const{key:g,label:I,help:u,scope:D,disabled:A,placeholder:C}=s;return e.jsx(qe,{htmlFor:g,label:I,help:u,error:w,scope:D,disabled:A,clearable:i,onClear:()=>r(null),children:e.jsx("input",{id:g,className:"settings-text",type:"text",value:d??"",placeholder:C,disabled:A,onChange:L=>r(L.target.value)})})}function $n({descriptor:s,value:d,onChange:r,error:w,clearable:i}){const{key:g,label:I,help:u,scope:D,disabled:A,placeholder:C}=s;return e.jsx(qe,{htmlFor:g,label:I,help:u,error:w,scope:D,disabled:A,clearable:i,onClear:()=>r(null),children:e.jsx("textarea",{id:g,className:"settings-textarea",value:d??"",placeholder:C,disabled:A,rows:3,onChange:L=>r(L.target.value)})})}const Wn=["string","text","number","boolean","enum","multi-enum"],Zs={string:["input"],text:["textarea","input"],number:["input"],boolean:["toggle"],enum:["select","radio","chips"],"multi-enum":["chips"]},Bn=["#4f7cff","#22c55e","#f59e0b","#ef4444","#a855f7","#06b6d4","#ec4899","#64748b"];function Bt(s){return s==="enum"||s==="multi-enum"}function _n(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}let ea=0;function qn(){return ea+=1,`setting-${Date.now().toString(36)}-${ea}`}function Vn({settings:s,onChange:d,readOnly:r,addToast:w}){const{t:i}=je("app"),[g,I]=o.useState(null),u=o.useCallback((p,c)=>{d(s.map(j=>j.id===p?{...j,...c}:j))},[s,d]),D=o.useCallback(()=>{d([...s,{id:qn(),name:i("workflowSettings.newSettingName","New setting"),type:"string"}])},[s,d,i]),A=o.useCallback(p=>d(s.filter(c=>c.id!==p)),[s,d]),C=o.useCallback((p,c)=>{const j=_n(c);if(j){if(j!==p&&s.some(h=>h.id===j)){w(i("workflowSettings.duplicateId","A setting with that id already exists"),"error");return}u(p,{id:j})}},[s,u,w,i]),L=o.useCallback((p,c)=>{const j=s.find(z=>z.id===p);if(!j)return;const h={type:c};Bt(c)?(!j.options||j.options.length===0)&&(h.options=[{value:"option-1",label:i("workflowSettings.newOptionLabel","Option 1")}]):h.options=void 0,j.render?.widget&&!Zs[c].includes(j.render.widget)&&(h.render=void 0),h.default=void 0,u(p,h)},[s,u,i]),b=o.useCallback((p,c)=>u(p,{options:c}),[u]),N=p=>{const c=z=>u(p.id,{default:z});if(p.type==="boolean")return e.jsxs("label",{className:"wf-setting--checkbox",children:[e.jsx("input",{type:"checkbox",checked:p.default===!0,disabled:r,onChange:z=>c(z.target.checked)}),e.jsx("span",{children:i("workflowSettings.defaultTrue","Default on")})]});if(Bt(p.type)){const z=p.type==="multi-enum"?Array.isArray(p.default)?p.default[0]??"":"":typeof p.default=="string"?p.default:"";return e.jsxs("select",{"aria-label":i("workflowSettings.defaultLabel","Default value"),value:z,disabled:r,onChange:k=>{const R=k.target.value;if(R==="")return c(void 0);c(p.type==="multi-enum"?[R]:R)},children:[e.jsx("option",{value:"",children:i("workflowSettings.noDefault","— none —")}),(p.options??[]).map(k=>e.jsx("option",{value:k.value,children:k.label},k.value))]})}const j=p.type==="number"?"number":"text",h=p.type==="number"?typeof p.default=="number"?String(p.default):"":typeof p.default=="string"?p.default:"";return e.jsx("input",{type:j,"aria-label":i("workflowSettings.defaultLabel","Default value"),defaultValue:h,disabled:r,onBlur:z=>{const k=z.target.value;if(k==="")return c(void 0);c(p.type==="number"?Number(k):k)}})};return e.jsxs("div",{className:"wf-settings-tabpanel","data-testid":"wf-settings-definitions",children:[e.jsx("div",{className:"wf-settings-tabpanel-head",children:e.jsxs("button",{className:"wf-settings-add",onClick:D,disabled:r,title:r?i("workflowSettings.readOnlyHint","Built-in workflows are read-only — duplicate to edit"):void 0,children:[e.jsx(ye,{size:13})," ",i("workflowSettings.add","Add setting")]})}),r&&e.jsx("p",{className:"wf-settings-note wf-settings-note--info",role:"note",children:i("workflowSettings.builtinDefinitionsReadOnly","Built-in workflow — declarations are read-only. Values are editable below.")}),s.length===0?e.jsx("p",{className:"wf-settings-empty",children:i("workflowSettings.empty","No settings declared yet. Add a setting to expose a typed, per-project knob.")}):e.jsx("ul",{className:"wf-settings-list",children:s.map(p=>{const c=Zs[p.type],j=g===p.id;return e.jsxs("li",{className:"wf-setting-item","data-testid":`wf-setting-${p.id}`,children:[e.jsxs("div",{className:"wf-setting-item-head",children:[e.jsx("input",{className:"wf-setting-name","aria-label":i("workflowSettings.nameLabel","Setting name"),value:p.name,disabled:r,onChange:h=>u(p.id,{name:h.target.value})}),e.jsx("button",{className:"wf-setting-remove","aria-label":i("workflowSettings.remove","Remove setting"),disabled:r,onClick:()=>A(p.id),children:e.jsx(ve,{size:13})})]}),e.jsx("div",{className:"wf-setting-id-row",children:j?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"wf-setting-id","aria-label":i("workflowSettings.idLabel","Setting id"),defaultValue:p.id,disabled:r,onBlur:h=>{C(p.id,h.target.value),I(null)}}),e.jsxs("p",{className:"wf-setting-id-warn",role:"note",children:[e.jsx(De,{size:11,"aria-hidden":!0})," ",i("workflowSettings.idWarn","Changing the id discards values stored under the old id (remove + add).")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"wf-setting-id-static",children:p.id}),e.jsx("button",{className:"wf-setting-id-edit",disabled:r,onClick:()=>I(p.id),children:i("workflowSettings.editId","Edit id")})]})}),e.jsxs("div",{className:"wf-setting-row",children:[e.jsxs("label",{className:"wf-setting-sub",children:[e.jsx("span",{children:i("workflowSettings.typeLabel","Type")}),e.jsx("select",{value:p.type,disabled:r,onChange:h=>L(p.id,h.target.value),children:Wn.map(h=>e.jsx("option",{value:h,children:h},h))})]}),e.jsxs("label",{className:"wf-setting-sub",children:[e.jsx("span",{children:i("workflowSettings.widget","Widget")}),e.jsxs("select",{value:p.render?.widget??"",disabled:r,onChange:h=>u(p.id,{render:h.target.value?{widget:h.target.value}:void 0}),children:[e.jsx("option",{value:"",children:i("workflowSettings.widgetDefault","Default")}),c.map(h=>e.jsx("option",{value:h,children:h},h))]})]})]}),e.jsxs("label",{className:"wf-setting-sub",children:[e.jsx("span",{children:i("workflowSettings.default","Default")}),N(p)]}),e.jsxs("label",{className:"wf-setting-sub",children:[e.jsx("span",{children:i("workflowSettings.description","Description")}),e.jsx("input",{"aria-label":i("workflowSettings.descriptionLabel","Setting description"),value:p.description??"",disabled:r,onChange:h=>u(p.id,{description:h.target.value||void 0})})]}),Bt(p.type)&&e.jsxs("div",{className:"wf-setting-options","data-testid":`wf-setting-options-${p.id}`,children:[e.jsx("span",{className:"wf-setting-options-label",children:i("workflowSettings.options","Options")}),(p.options??[]).map((h,z)=>e.jsxs("div",{className:"wf-setting-option-row",children:[e.jsx("input",{className:"wf-setting-option-value","aria-label":i("workflowSettings.optionValue","Option value"),value:h.value,disabled:r,onChange:k=>{const R=[...p.options??[]];R[z]={...h,value:k.target.value},b(p.id,R)}}),e.jsx("input",{className:"wf-setting-option-label","aria-label":i("workflowSettings.optionLabel","Option label"),value:h.label,disabled:r,onChange:k=>{const R=[...p.options??[]];R[z]={...h,label:k.target.value},b(p.id,R)}}),e.jsx("div",{className:"wf-setting-option-colors",role:"group","aria-label":i("workflowSettings.optionColor","Option color"),children:Bn.map(k=>e.jsx("button",{type:"button",className:`wf-setting-color-swatch${h.color===k?" is-active":""}`,style:{backgroundColor:k},"aria-label":k,"aria-pressed":h.color===k,disabled:r,onClick:()=>{const R=[...p.options??[]];R[z]={...h,color:h.color===k?void 0:k},b(p.id,R)}},k))}),e.jsx("button",{className:"wf-setting-option-remove","aria-label":i("workflowSettings.removeOption","Remove option"),disabled:r,onClick:()=>b(p.id,(p.options??[]).filter((k,R)=>R!==z)),children:e.jsx(ve,{size:12})})]},z)),e.jsxs("button",{className:"wf-setting-option-add",disabled:r,onClick:()=>{const h=(p.options??[]).length+1;b(p.id,[...p.options??[],{value:`option-${h}`,label:i("workflowSettings.optionN","Option {{n}}",{n:h})}])},children:[e.jsx(ye,{size:12})," ",i("workflowSettings.addOption","Add option")]})]})]},p.id)})})]})}function Gn(s){if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return String(s)}}const Un=[{id:"planning",providerId:"planningProvider",modelId:"planningModelId",label:"Plan/Triage Model",help:"Provider and model used when planning or triaging tasks. Leave unset to inherit from the default lane."},{id:"execution",providerId:"executionProvider",modelId:"executionModelId",label:"Executor Model",help:"Provider and model used by task implementation agents. Leave unset to inherit from the default lane."},{id:"validator",providerId:"validatorProvider",modelId:"validatorModelId",label:"Reviewer Model",help:"Provider and model used by review and validation agents. Leave unset to inherit from the default lane."},{id:"planning-fallback",providerId:"planningFallbackProvider",modelId:"planningFallbackModelId",label:"Planning Fallback Model",help:"Fallback provider and model used when the primary Plan/Triage model cannot be used."},{id:"validator-fallback",providerId:"validatorFallbackProvider",modelId:"validatorFallbackModelId",label:"Reviewer Fallback Model",help:"Fallback provider and model used when the primary Reviewer model cannot be used."}];function Hn(s){if(!s)return null;const d=s.indexOf("/");return d<=0||d===s.length-1?null:{provider:s.slice(0,d),modelId:s.slice(d+1)}}function Yn({workflowId:s,settings:d,boundProjectId:r,currentProjectId:w,addToast:i}){const{t:g}=je("app"),[I,u]=o.useState(null),[D,A]=o.useState(!1),[C,L]=o.useState({}),[b,N]=o.useState({}),[p,c]=o.useState(!1),[j,h]=o.useState(!1),[z,k]=o.useState([]),[R,P]=o.useState(!1),[K,_]=o.useState([]),[Y,de]=o.useState([]),q=o.useRef(0),J=o.useRef(0),ce=o.useMemo(()=>new Map(d.map(f=>[f.id,f])),[d]),v=o.useMemo(()=>Un.filter(f=>{const T=ce.get(f.providerId),G=ce.get(f.modelId);return T?.type==="string"&&G?.type==="string"}),[ce]),S=o.useMemo(()=>new Set(v.flatMap(f=>[f.providerId,f.modelId])),[v]),W=r!==void 0&&w!==void 0&&w!==r,B=o.useCallback(async()=>{if(r===void 0)return;const f=++q.current;A(!0);try{const T=await po(s,r);q.current===f&&(u(T),L({}),N({}))}catch{q.current===f&&i(g("workflowSettings.loadFailed","Failed to load setting values"),"error")}finally{q.current===f&&A(!1)}},[s,r,i,g]);if(o.useEffect(()=>{B()},[B]),o.useEffect(()=>{if(r===void 0||v.length===0){k([]),_([]),de([]),P(!1);return}const f=++J.current;P(!0),pt().then(T=>{J.current===f&&(k(T.models??[]),_(T.favoriteProviders??[]),de(T.favoriteModels??[]))}).catch(()=>{J.current===f&&(k([]),_([]),de([]),i(g("workflowSettings.modelsLoadFailed","Failed to load available models"),"error"))}).finally(()=>{J.current===f&&P(!1)})},[r,v.length,i,g]),r===void 0)return e.jsx("div",{className:"wf-settings-tabpanel","data-testid":"wf-settings-values",children:e.jsx("p",{className:"wf-settings-note wf-settings-note--info",role:"note",children:g("workflowSettings.requiresProject","Open a project to view and edit per-project setting values.")})});const ne=f=>{if(Object.prototype.hasOwnProperty.call(C,f.id)){const T=C[f.id];return T===null?f.default:T}return I?.effective?.[f.id]??f.default},le=f=>Object.prototype.hasOwnProperty.call(C,f.id)?C[f.id]!==null:I?Object.prototype.hasOwnProperty.call(I.stored,f.id):!1,ie=(f,T)=>{L(G=>({...G,[f]:T})),N(G=>{if(!G[f])return G;const ee={...G};return delete ee[f],ee})},Z=f=>ie(f,null),se=(f,T)=>{const G=Hn(T);L(ee=>({...ee,[f.providerId]:G?.provider??null,[f.modelId]:G?.modelId??null})),N(ee=>{if(!ee[f.providerId]&&!ee[f.modelId])return ee;const re={...ee};return delete re[f.providerId],delete re[f.modelId],re})},E=Object.keys(C).length>0,H=o.useCallback(async()=>{if(!E)return;const f=new Set(Object.keys(C));c(!0);try{const T=await Is(s,C,r);u(T),L(G=>{const ee={...G};for(const re of f)delete ee[re];return ee}),N({}),i(g("workflowSettings.valuesSaved","Setting values saved"),"success")}catch(T){if(T instanceof ma&&T.status===400&&T.details){const G=T.details.rejections??[];if(G.length>0){const ee={};for(const re of G)ee[re.settingId]=re;N(ee),i(g("workflowSettings.valuesRejected","Some values were rejected — see the highlighted fields"),"error");return}}i(g("workflowSettings.saveFailed","Failed to save setting values"),"error")}finally{c(!1)}},[E,s,C,r,i,g]),a=f=>{const T=ce.get(f);return T?ne(T):void 0},ue=f=>{const T=ce.get(f);return T?le(T):!1},Ce=f=>{const T=a(f.providerId),G=a(f.modelId),ee=typeof T=="string"&&typeof G=="string"?`${T}/${G}`:"",re=b[f.providerId]?.message??b[f.modelId]?.message,X=ue(f.providerId)||ue(f.modelId),he=R||z.length===0,Q=!R&&z.length===0?` ${g("workflowSettings.noModelsAvailable","No models are available. Configure authentication before selecting a workflow model.")}`:"";return e.jsxs("div",{className:"wf-settings-value-item","data-testid":`wf-settings-value-${f.id}`,children:[e.jsx(qe,{htmlFor:`wf-model-lane-${f.id}`,label:f.label,help:`${f.help}${Q}`,error:re,scope:"project",disabled:R,clearable:X,onClear:()=>se(f,""),children:e.jsx(Ut,{id:`wf-model-lane-${f.id}`,label:f.label,models:z,value:ee,onChange:fe=>se(f,fe),placeholder:g("workflowSettings.selectModel","Select a model…"),defaultOptionLabel:g("workflowSettings.useInheritedModel","Use inherited/default model"),disabled:he,favoriteProviders:K,favoriteModels:Y})}),X&&e.jsx("span",{className:"wf-settings-customized","data-testid":`wf-settings-customized-${f.id}`,children:g("workflowSettings.customized","Customized")})]},f.id)},oe=f=>{const T=ne(f),G=b[f.id]?.message,ee=le(f),re=ga(f),X={key:f.id,label:re.label,help:re.description??f.description,scope:"project"},he=ee;switch(f.type){case"boolean":return e.jsx(zn,{descriptor:X,value:T===!0,error:G,clearable:he,onChange:Q=>Q===null?Z(f.id):ie(f.id,Q)});case"number":return e.jsx(Ln,{descriptor:X,value:typeof T=="number"?T:null,error:G,clearable:he,onChange:Q=>Q===null?Z(f.id):ie(f.id,Q)});case"enum":return e.jsx(Qs,{descriptor:{...X,options:(f.options??[]).map(Q=>({value:Q.value,label:Q.label}))},value:typeof T=="string"?T:null,error:G,clearable:he,onChange:Q=>Q===null?Z(f.id):ie(f.id,Q)});case"multi-enum":{const Q=Array.isArray(T)?T[0]??null:null;return e.jsx(Qs,{descriptor:{...X,options:(f.options??[]).map(fe=>({value:fe.value,label:fe.label}))},value:Q,error:G,clearable:he,onChange:fe=>fe===null?Z(f.id):ie(f.id,[fe])})}case"text":return e.jsx($n,{descriptor:X,value:typeof T=="string"?T:null,error:G,clearable:he,onChange:Q=>Q===null||Q===""?Z(f.id):ie(f.id,Q)});case"string":default:return e.jsx(On,{descriptor:X,value:typeof T=="string"?T:null,error:G,clearable:he,onChange:Q=>Q===null||Q===""?Z(f.id):ie(f.id,Q)})}},Te=I?.orphaned??[],Qe=o.useCallback(async f=>{try{const T=await Is(s,{[f]:null},r);u(T),i(g("workflowSettings.orphanDeleted","Orphaned value removed"),"success")}catch{i(g("workflowSettings.saveFailed","Failed to save setting values"),"error")}},[s,r,i,g]);return e.jsxs("div",{className:"wf-settings-tabpanel","data-testid":"wf-settings-values",children:[W&&e.jsxs("p",{className:"wf-settings-note wf-settings-note--warn",role:"note","data-testid":"wf-settings-stale-notice",children:[e.jsx(De,{size:12,"aria-hidden":!0})," ",g("workflowSettings.staleContext","Values shown are for project {{project}} — reopen the editor to edit values for the current project.",{project:r})]}),e.jsx("div",{className:"wf-settings-values-head",children:e.jsxs("button",{className:"wf-settings-save-values",onClick:H,disabled:!E||p||W,"data-testid":"wf-settings-save-values",children:[e.jsx(Gt,{size:13})," ",g("workflowSettings.saveValues","Save values")]})}),d.length===0?e.jsx("p",{className:"wf-settings-empty",children:D?g("workflowSettings.loading","Loading…"):g("workflowSettings.noDeclarations","This workflow declares no settings, so there are no values to edit.")}):e.jsx("div",{className:"wf-settings-values-list",children:Tn(d).map(({group:f,settings:T})=>{const G=new Set(T.map(X=>X.id)),ee=f==="models"?v.filter(X=>G.has(X.providerId)&&G.has(X.modelId)):[],re=T.filter(X=>!S.has(X.id));return e.jsxs("section",{className:"wf-settings-value-group","data-testid":`wf-settings-group-${f}`,children:[e.jsx("h4",{className:"wf-settings-value-group-title",children:g(`workflowSettings.group.${f}`,Dn[f])}),ee.map(X=>Ce(X)),re.map(X=>e.jsxs("div",{className:"wf-settings-value-item","data-testid":`wf-settings-value-${X.id}`,children:[oe(X),le(X)&&e.jsx("span",{className:"wf-settings-customized","data-testid":`wf-settings-customized-${X.id}`,children:g("workflowSettings.customized","Customized")})]},X.id))]},f)})}),Te.length>0&&e.jsxs("div",{className:"wf-settings-orphaned","data-testid":"wf-settings-orphaned",children:[e.jsxs("button",{className:"wf-settings-orphaned-toggle",onClick:()=>h(f=>!f),"aria-expanded":j,children:[j?e.jsx(Ne,{size:13}):e.jsx(Pe,{size:13})," ",g("workflowSettings.orphanedTitle","Orphaned values ({{count}})",{count:Te.length})]}),j&&e.jsxs("div",{className:"wf-settings-orphaned-body",children:[e.jsx("p",{className:"wf-settings-note wf-settings-note--muted",role:"note",children:g("workflowSettings.orphanedNote","These stored values no longer match a current declaration (the setting was retyped or removed). They are ignored by the engine; delete them to clean up.")}),e.jsx("ul",{className:"wf-settings-orphaned-list",children:Te.map(f=>e.jsxs("li",{className:"wf-settings-orphaned-row","data-testid":`wf-settings-orphan-${f.id}`,children:[e.jsx("code",{className:"wf-settings-orphan-id",children:f.id}),e.jsx("span",{className:"wf-settings-orphan-value",children:Gn(f.value)}),e.jsx("button",{className:"wf-settings-orphan-delete","aria-label":g("workflowSettings.deleteOrphan","Delete orphaned value"),disabled:W||p,onClick:()=>Qe(f.id),children:e.jsx(ve,{size:12})})]},f.id))})]})]}),d.length>0&&e.jsxs("p",{className:"wf-settings-reset-hint",role:"note",children:[e.jsx(fa,{size:11,"aria-hidden":!0})," ",g("workflowSettings.clearHint","Use the reset control on a row to clear a value back to its declaration default.")]})]})}function ta({workflowId:s,settings:d,onChange:r,readOnly:w,projectId:i,addToast:g,initialTab:I}){const{t:u}=je("app"),[D,A]=o.useState(()=>I??(d.length>0?"values":"definitions")),C=o.useRef({workflowId:s,projectId:i});C.current.workflowId!==s&&(C.current={workflowId:s,projectId:i});const L=C.current.projectId;return e.jsxs("aside",{className:"wf-settings-panel","data-testid":"wf-settings-panel",children:[e.jsx("header",{className:"wf-settings-panel-header",children:e.jsx("h3",{children:u("workflowSettings.title","Settings")})}),e.jsxs("div",{className:"wf-settings-tabs",role:"tablist",children:[e.jsx("button",{role:"tab","aria-selected":D==="definitions",className:`wf-settings-tab${D==="definitions"?" is-active":""}`,onClick:()=>A("definitions"),"data-testid":"wf-settings-tab-definitions",children:u("workflowSettings.definitionsTab","Definitions")}),e.jsx("button",{role:"tab","aria-selected":D==="values",className:`wf-settings-tab${D==="values"?" is-active":""}`,onClick:()=>A("values"),"data-testid":"wf-settings-tab-values",children:u("workflowSettings.valuesTab","Values")})]}),D==="definitions"?e.jsx(Vn,{settings:d,onChange:r,readOnly:w,addToast:g}):e.jsx(Yn,{workflowId:s,settings:d,boundProjectId:L,currentProjectId:i,addToast:g},s)]})}function xa(s,d){return s[d]?.editable?{up:s[d-1]?.editable===!0,down:s[d+1]?.editable===!0}:{up:!1,down:!1}}function ba({row:s,depth:d,selectedNodeId:r,selectedEdgeId:w,onSelectNode:i,onSelectEdge:g,onCreateConnection:I,canReorder:u,onMoveNode:D,canMoveUp:A,canMoveDown:C}){const{t:L}=je("app"),b=s.children.length>0,[N,p]=o.useState(d===0),[c,j]=o.useState(!1),h=r===s.id,z=s.connectionTargets??[],k=!!I&&s.editable&&z.length>0,R=!!u&&!!D&&s.editable;return e.jsxs("div",{className:"mobile-wf-node-group",children:[e.jsxs("div",{className:`mobile-wf-node-row${h?" mobile-wf-node-row--selected":""}`,style:{"--mobile-wf-depth":String(d)},"data-testid":`mobile-wf-node-${s.id}`,children:[e.jsxs("button",{type:"button",className:"mobile-wf-node-main",onClick:()=>i(s.id),"aria-current":h?"true":void 0,children:[e.jsx("span",{className:"mobile-wf-node-kind",children:s.kind}),e.jsxs("span",{className:"mobile-wf-node-text",children:[e.jsx("span",{className:"mobile-wf-node-title",children:s.label}),s.summary?e.jsx("span",{className:"mobile-wf-node-summary",children:s.summary}):null]}),s.editable?e.jsx(wo,{size:14,"aria-hidden":!0}):null]}),b||R?e.jsxs("div",{className:"mobile-wf-node-actions",children:[R?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn-icon mobile-wf-node-move","data-testid":`mobile-wf-node-move-up-${s.id}`,"aria-label":L("workflowNodes.mobileMoveUp","Move up"),disabled:!A,onClick:()=>D?.(s.id,"up"),children:e.jsx(ho,{size:16,"aria-hidden":!0})}),e.jsx("button",{type:"button",className:"btn-icon mobile-wf-node-move","data-testid":`mobile-wf-node-move-down-${s.id}`,"aria-label":L("workflowNodes.mobileMoveDown","Move down"),disabled:!C,onClick:()=>D?.(s.id,"down"),children:e.jsx(go,{size:16,"aria-hidden":!0})})]}):null,b?e.jsx("button",{type:"button",className:"mobile-wf-node-expand","aria-expanded":N,"aria-label":N?L("common.collapse","Collapse"):L("common.expand","Expand"),onClick:()=>p(P=>!P),children:N?e.jsx(Ne,{size:16}):e.jsx(Pe,{size:16})}):null]}):null]}),k?e.jsx("div",{className:"mobile-wf-node-actions mobile-wf-node-actions--connect",style:{"--mobile-wf-depth":String(d)},children:e.jsxs("button",{type:"button",className:"mobile-wf-connect-button","data-testid":`mobile-wf-connect-${s.id}`,"aria-expanded":c,onClick:()=>j(P=>!P),children:[e.jsx(Rs,{size:14,"aria-hidden":!0}),e.jsx("span",{children:L("workflowNodes.mobileConnect","Connect")})]})}):null,k&&c?e.jsxs("div",{className:"mobile-wf-connect-picker",style:{"--mobile-wf-depth":String(d)},children:[e.jsx("label",{className:"mobile-wf-connect-label",htmlFor:`mobile-wf-connect-target-${s.id}`,children:L("workflowNodes.mobileConnectTarget","Target node")}),e.jsxs("select",{id:`mobile-wf-connect-target-${s.id}`,className:"input mobile-wf-connect-select","data-testid":`mobile-wf-connect-target-${s.id}`,defaultValue:"",onChange:P=>{const K=P.currentTarget.value;K&&(I?.(s.id,K),P.currentTarget.value="",j(!1))},children:[e.jsx("option",{value:"",children:L("workflowNodes.mobileConnectChooseTarget","Choose a target…")}),z.map(P=>e.jsxs("option",{value:P.id,children:[P.label," (",P.kind,")"]},P.id))]})]}):null,(s.columnName||s.outgoing.length>0)&&e.jsxs("div",{className:"mobile-wf-node-meta",style:{"--mobile-wf-depth":String(d)},children:[s.columnName?e.jsx("span",{className:"mobile-wf-column-chip",children:s.columnName}):null,s.outgoing.map(P=>e.jsxs("button",{type:"button",className:`mobile-wf-edge-chip${w===P.id?" mobile-wf-edge-chip--selected":""}`,"data-testid":`mobile-wf-edge-${P.id}`,onClick:()=>g(P.id),children:[e.jsx(Rs,{size:12,"aria-hidden":!0}),e.jsx("span",{children:P.label}),e.jsx("span",{className:"mobile-wf-edge-target",children:P.targetLabel})]},P.id))]}),b&&N?e.jsx("div",{className:"mobile-wf-node-children",children:s.children.map((P,K)=>{const _=xa(s.children,K);return e.jsx(ba,{row:P,depth:d+1,selectedNodeId:r,selectedEdgeId:w,onSelectNode:i,onSelectEdge:g,onCreateConnection:I,canReorder:u,onMoveNode:D,canMoveUp:_.up,canMoveDown:_.down},P.id)})}):null]})}function Kn({rows:s,selectedNodeId:d,selectedEdgeId:r,onSelectNode:w,onSelectEdge:i,onCreateConnection:g,canReorder:I,onMoveNode:u}){const{t:D}=je("app");return s.length===0?e.jsx("div",{className:"mobile-wf-graph-empty","data-testid":"mobile-wf-graph-empty",children:D("workflowNodes.mobileGraphEmpty","No graph nodes yet.")}):e.jsx("div",{className:"mobile-wf-graph","data-testid":"mobile-wf-graph",children:s.map((A,C)=>{const L=xa(s,C);return e.jsx(ba,{row:A,depth:0,selectedNodeId:d,selectedEdgeId:r,onSelectNode:w,onSelectEdge:i,onCreateConnection:g,canReorder:I,onMoveNode:u,canMoveUp:L.up,canMoveDown:L.down},A.id)})})}function Jn(s){return typeof s.label=="string"&&s.label.trim()?s.label:String(s.data?.condition??"success")}function sa(s){return s.data.label||s.id}function Yt(s,d){const r=Math.round(s.position.y),w=Math.round(d.position.y);return r!==w?r-w:Math.round(s.position.x)-Math.round(d.position.x)}function aa(s){return s.data.kind!=="start"&&s.data.kind!=="end"&&!ke(s.id)}function Xn(s,d){return ke(d.id)?!1:s.parentId||d.parentId?s.parentId===d.parentId:s.data.column===d.data.column}function Qn(s,d,r){const w=s.find(u=>u.id===d);if(!w||!aa(w))return s;const i=s.filter(u=>Xn(w,u)).sort(Yt),g=i.findIndex(u=>u.id===d),I=i[g+(r==="up"?-1:1)];return!I||!aa(I)?s:s.map(u=>u.id===w.id?{...u,position:{...I.position}}:u.id===I.id?{...u,position:{...w.position}}:u)}function Zn(s,d){const r=new Map(s.map(w=>[w.id,w.name||w.id]));for(const w of d){if(!ke(w.id))continue;const i=xo(w.id);r.has(i)||r.set(i,w.data.label||i)}return r}function el(s,d,r=[],w={},i){const g=Zn(r,s),I=new Map(s.map(b=>[b.id,b])),u=new Map,D=new Map;for(const b of s){if(!b.parentId)continue;const N=u.get(b.parentId)??[];N.push(b),u.set(b.parentId,N)}for(const b of u.values())b.sort(Yt);for(const b of d){const N=D.get(b.source)??[];N.push(b),D.set(b.source,N)}const A=b=>{const N=I.get(b.target);return{id:b.id,source:b.source,target:b.target,targetLabel:N?sa(N):b.target,label:Jn(b),kind:typeof b.data?.kind=="string"?b.data.kind:void 0}},C=b=>{const N=(u.get(b.id)??[]).map(C),p=b.data.column;return{id:b.id,label:sa(b),kind:b.data.kind,summary:ko(b.data,w,i),columnName:p?g.get(p)??p:void 0,editable:b.data.kind!=="start"&&b.data.kind!=="end"&&!ke(b.id),parentId:b.parentId,templateLocalId:b.parentId?bo(b.parentId,b.id):void 0,outgoing:(D.get(b.id)??[]).map(A),children:N}};return s.filter(b=>!b.parentId&&!ke(b.id)).sort(Yt).map(C)}function tl(s){switch(typeof s?.seam=="string"?s.seam:""){case"planning":return"Generate the task plan and write the planning artifact that downstream workflow nodes consume.";case"execute":return"Run Fusion's standard implementation prompt for this task, generated from the task spec, current project context, workflow fields, and available tools.";case"step-execute":return"Run Fusion's step implementation prompt for the active planned step in the task worktree.";case"review":return"Run Fusion's review boundary for completed implementation work and route the task based on the review result.";case"merge":return"Run Fusion's merge boundary: verify merge readiness, apply the configured merge strategy, and update the final task state.";default:return""}}const sl=[{id:"claude-code",name:"Claude Code",tier:"native"},{id:"codex",name:"Codex",tier:"hybrid"},{id:"droid",name:"Droid",tier:"hybrid"},{id:"pi",name:"Pi",tier:"hybrid"},{id:"generic",name:"Generic CLI",tier:"generic"}],_e=s=>s.startsWith("builtin:");function oa(s,d){return s&&d?`${s}/${d}`:""}function na(s){if(!s)return{provider:"",modelId:""};const d=s.indexOf("/");return d===-1?{provider:"",modelId:""}:{provider:s.slice(0,d),modelId:s.slice(d+1)}}function _t(s,d,r,w,i,g,I){const{ir:u,layout:D}=pa(s,r,w,i.length?i:void 0,g.length?g:void 0,I.length?I:void 0);return JSON.stringify({name:s,description:d,ir:u,layout:D})}let la=0;function ia(){return la+=1,`n-${Date.now().toString(36)}-${la}`}const al=["step-headings","json-steps"],ol=["approve","revise","rethink","unavailable"],ra=["in-review","merged","failed","awaiting-approval","task-created","workflow-notify"],qt="__custom",da=[{kind:"prompt",label:"Prompt",icon:Qo},{kind:"prompt",label:"User input",icon:Zo,presetConfig:{awaitInput:!0}},{kind:"script",label:"Script",icon:en},{kind:"gate",label:"Gate",icon:tn},{kind:"merge",label:"Merge boundary",icon:sn},{kind:"hold",label:"Hold",icon:an,presetConfig:{release:"manual"}},{kind:"split",label:"Split",icon:on},{kind:"join",label:"Join",icon:nn,presetConfig:{mode:"all",onBranchFailure:"collect"}},{kind:"foreach",label:"For-each step",icon:_s,presetConfig:{source:"task-steps"}},{kind:"loop",label:"Loop",icon:_s,presetConfig:{maxIterations:3,exitWhen:{type:"output-contains",value:"DONE"}}},{kind:"step-review",label:"Step review",icon:ln,presetConfig:{type:"code"}},{kind:"parse-steps",label:"Parse steps",icon:ha,presetConfig:{artifact:"PROMPT.md",parser:"step-headings"}},{kind:"code",label:"Code",icon:rn,presetConfig:{source:""}},{kind:"notify",label:"Notify",icon:dn,presetConfig:{event:"in-review",title:"{{taskTitle}}",message:""}}];function nl(s){const d={name:s.name,gateMode:s.gateMode??"advisory"};return s.description&&(d.description=s.description),s.mode==="script"?(s.scriptName&&(d.scriptName=s.scriptName),{kind:"script",label:s.name,config:d}):(d.prompt=s.prompt??"",d.toolMode=s.toolMode==="coding"?"coding":"readonly",s.modelProvider&&s.modelId&&(d.modelProvider=s.modelProvider,d.modelId=s.modelId),{kind:"prompt",label:s.name,config:d})}const ll=new Set(["prompt","script","gate","code","hold","split","join","foreach","loop","step-review","parse-steps","notify","merge"]);function il({workflows:s,onCreate:d,onDesign:r,onClose:w}){const{t:i}=je("app"),[g,I]=o.useState(""),[u,D]=o.useState(""),[A,C]=o.useState(null),[L,b]=o.useState(!1),[N,p]=o.useState(!1),[c,j]=o.useState(""),[h,z]=o.useState(!1),[k,R]=o.useState(null),P=o.useRef(null),[K,_]=o.useState(!1),Y=o.useRef(null),de=o.useRef([]),q=o.useMemo(()=>{const E={id:null,name:i("workflows.templateBlank","Blank"),description:i("workflows.templateBlankDescription","Start from an empty start → end graph."),nodeCount:0,builtin:!1},H=s.filter(oe=>oe.kind!=="fragment"),a=oe=>({id:oe.id,name:oe.name,description:oe.description??"",nodeCount:oe.ir.nodes.length,source:oe,builtin:_e(oe.id)}),ue=H.filter(oe=>_e(oe.id)).map(a),Ce=H.filter(oe=>!_e(oe.id)).map(a);return[E,...ue,...Ce]},[s,i]),[J,ce]=o.useState(0),v=q[J]??q[0];o.useEffect(()=>{Y.current?.focus()},[]);const S=o.useCallback(E=>{const H=q[E];H&&(ce(E),K||(H.id===null?(I(""),D("")):(I(i("workflows.templateCopyName","{{name}} copy",{name:H.name})),D(H.description))),A&&C(null))},[q,K,A,i]),W=o.useCallback(E=>{if(E.key==="ArrowDown"||E.key==="ArrowRight"){E.preventDefault();const H=Math.min(J+1,q.length-1);S(H),de.current[H]?.focus()}else if(E.key==="ArrowUp"||E.key==="ArrowLeft"){E.preventDefault();const H=Math.max(J-1,0);S(H),de.current[H]?.focus()}else(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),S(J),Y.current?.focus())},[J,q.length,S]),B=wa(w),ne=o.useCallback(async E=>{E.preventDefault();const H=g.trim();if(!H){C(i("workflows.createNameRequired","Enter a workflow name"));return}b(!0),C(null);try{await d(H,u.trim(),v)}catch(a){C(ae(a)||i("workflows.createFailed","Failed to create workflow")),b(!1)}},[g,u,v,d,i]),le=o.useCallback(async()=>{const E=c.trim();if(!E){R(i("workflows.aiPromptRequired","Describe the workflow you want"));return}const H=new AbortController;P.current=H,z(!0),R(null);try{await r(E,g.trim(),H.signal)}catch(a){if(H.signal.aborted)return;R(ae(a)||i("workflows.aiFailed","Failed to design workflow"))}finally{P.current===H&&(P.current=null),z(!1)}},[c,g,r,i]),ie=o.useCallback(()=>{P.current?.abort(),z(!1)},[]),Z=q.findIndex(E=>E.id!==null&&E.builtin),se=q.findIndex(E=>E.id!==null&&!E.builtin);return e.jsx("div",{className:"modal-overlay open wf-create-overlay",...B,children:e.jsxs("div",{className:"modal wf-create-modal","data-testid":"wf-create-dialog",role:"dialog","aria-modal":"true","aria-label":i("workflows.createTitle","New workflow"),onClick:E=>E.stopPropagation(),onKeyDown:E=>{E.key==="Escape"&&(E.stopPropagation(),w())},children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:i("workflows.createTitle","New workflow")}),e.jsx("button",{type:"button",className:"modal-close",onClick:w,"aria-label":i("actions.close","Close"),children:e.jsx(Ht,{size:16})})]}),e.jsxs("form",{onSubmit:ne,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"wf-ai-create","aria-busy":h,"data-testid":"wf-ai-create",children:[e.jsxs("button",{type:"button",className:"wf-ai-toggle","data-testid":"wf-ai-toggle","aria-expanded":N,onClick:()=>{p(E=>!E),R(null)},children:[e.jsx(Be,{size:13})," ",i("workflows.aiToggle","Describe it instead")]}),N&&e.jsxs("div",{className:"wf-ai-create-body",children:[e.jsx("textarea",{className:"wf-ai-prompt","data-testid":"wf-ai-prompt",rows:3,value:c,disabled:h,placeholder:i("workflows.aiPromptPlaceholder","e.g. Run lint and tests before merge, then post a changelog comment after merge"),onChange:E=>{j(E.target.value),k&&R(null)}}),k&&e.jsx("p",{className:"wf-create-error",role:"alert","data-testid":"wf-ai-error",children:k}),e.jsxs("div",{className:"wf-ai-actions",children:[e.jsxs("button",{type:"button",className:"btn btn-primary wf-ai-submit","data-testid":"wf-ai-submit",disabled:h,onClick:()=>void le(),children:[h?e.jsx(Ae,{size:13,className:"wf-spin"}):e.jsx(Be,{size:13})," ",i("workflows.aiSubmit","Design with AI")]}),h&&e.jsx("button",{type:"button",className:"btn wf-ai-cancel","data-testid":"wf-ai-cancel",onClick:ie,children:i("common.cancel","Cancel")})]})]})]}),e.jsxs("div",{className:"wf-field",children:[e.jsx("span",{id:"wf-template-label",children:i("workflows.templatePickerLabel","Start from")}),e.jsx("div",{className:"wf-template-list",role:"radiogroup","aria-labelledby":"wf-template-label","data-testid":"wf-template-list",children:q.map((E,H)=>{const a=H===J,ue=E.id??"blank";return e.jsxs("div",{children:[H===Z&&Z>=0&&e.jsx("p",{className:"wf-template-section",children:i("workflows.templateSectionBuiltin","Built-in workflows")}),H===se&&se>=0&&e.jsx("p",{className:"wf-template-section",children:i("workflows.templateSectionYours","Your workflows")}),e.jsxs("div",{ref:Ce=>{de.current[H]=Ce},role:"radio","aria-checked":a,tabIndex:a?0:-1,className:`wf-template-option${a?" selected":""}`,"data-testid":E.id===null?"wf-template-option-blank":`wf-template-option-${E.id}`,onClick:()=>{S(H),de.current[H]?.focus()},onKeyDown:W,children:[e.jsx("span",{className:"wf-template-option-name",children:E.name}),E.description&&e.jsx("span",{className:"wf-template-option-desc",children:E.description}),E.id!==null&&e.jsx("span",{className:"wf-template-option-count",children:i("workflows.templateNodeCount","{{count}} nodes",{count:E.nodeCount})})]})]},ue)})})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:i("workflows.createName","Name")}),e.jsx("input",{ref:Y,"data-testid":"wf-create-name",value:g,onChange:E=>{I(E.target.value),_(!0),A&&C(null)}})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:i("workflows.createDescription","Description (optional)")}),e.jsx("textarea",{rows:2,"data-testid":"wf-create-description",value:u,onChange:E=>D(E.target.value)})]}),A&&e.jsx("p",{className:"wf-create-error",role:"alert","data-testid":"wf-create-error",children:A})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:w,children:i("common.cancel","Cancel")}),e.jsxs("button",{type:"submit",className:"btn btn-primary","data-testid":"wf-create-submit",disabled:L,children:[L?e.jsx(Ae,{size:13,className:"wf-spin"}):null," ",i("workflows.createSubmit","Create")]})]})]})]})})}function rl({onClose:s,addToast:d,projectId:r,initialPanel:w,initialAction:i,initialWorkflowId:g,modalRef:I}){const[u,D]=o.useState([]),[A,C]=o.useState(null),b=jo()==="mobile",[N,p]=o.useState(()=>Ps()),[c,j]=o.useState(!1),[h,z]=o.useState(!1),[k,R]=o.useState(null),[P,K]=o.useState(!1),[_,Y,de]=eo([]),[q,J,ce]=to([]),[v,S]=o.useState(null),[W,B]=o.useState(null),[ne,le]=o.useState(!1),[ie,Z]=o.useState(!1),[se,E]=o.useState(()=>w==="settings"?"settings":"graph"),H=b||ie,{t:a}=je("app"),{confirm:ue}=No(),[Ce,oe]=o.useState(i==="create"),Te=o.useRef(null),Qe=o.useRef(null),[f,T]=o.useState(""),[G,ee]=o.useState(""),[re,X]=o.useState(!1),[he,Q]=o.useState(!1),fe=o.useRef(null),[te,Ve]=o.useState([]),[Se,Ge]=o.useState([]),[Ee,Ze]=o.useState([]),ht=o.useRef(null),[Kt,ka]=o.useState([]),[va,ja]=o.useState([...al]),[gt,Na]=o.useState([]),[xt,ya]=o.useState([]),Jt="fusion:wf-templates-collapsed",[ze,Ca]=o.useState(()=>{try{const t=localStorage.getItem(Jt);return t!=null?t==="1":Ps()}catch{return!1}}),[et,Xt]=o.useState(""),[tt,Qt]=o.useState(null),Zt="fusion:wf-sidebar-columns-collapsed",es="fusion:wf-sidebar-fields-collapsed",ts="fusion:wf-sidebar-settings-collapsed",[Ue,Sa]=o.useState(()=>{try{return localStorage.getItem(Zt)==="1"}catch{return!1}}),[He,Ea]=o.useState(()=>{try{return localStorage.getItem(es)==="1"}catch{return!1}}),[Ye,Fa]=o.useState(()=>{try{return localStorage.getItem(ts)==="1"}catch{return!1}});o.useEffect(()=>{try{localStorage.setItem(Zt,Ue?"1":"0")}catch{}},[Ue]),o.useEffect(()=>{try{localStorage.setItem(es,He?"1":"0")}catch{}},[He]),o.useEffect(()=>{try{localStorage.setItem(ts,Ye?"1":"0")}catch{}},[Ye]);const{setViewport:ss}=so(),bt=o.useRef(null),st=o.useMemo(()=>`fusion:wf-migration-notice-dismissed${r?`:${r}`:""}`,[r]),[Aa,as]=o.useState(!1),[os,kt]=o.useState(null),[ns,ls]=o.useState([]),[is,rs]=o.useState(!1),at=o.useRef(null),[vt,jt]=o.useState(!1),[ot,Nt]=o.useState(""),[ge,yt]=o.useState(!1),[Le,Oe]=o.useState(null),nt=o.useRef(null),Ct=o.useRef(!1),F=o.useMemo(()=>u.find(t=>t.id===A),[u,A]),V=!!F&&_e(F.id),ds=o.useRef(A);ds.current=A;const Ma=o.useMemo(()=>!F||V?!1:!_.some(t=>ll.has(t.data.kind)),[F,V,_]),{experimentalFeatures:cs}=yo(r),us=cs?.workflowColumns===!0&&cs?.workflowGraphExecutor===!0;o.useEffect(()=>{let t=!1;return ua(r).then(n=>{t||ka(n)}).catch(()=>{}),()=>{t=!0}},[r]),o.useEffect(()=>{let t=!1;return Co(r).then(n=>{!t&&n.length>0&&ja(n)}).catch(()=>{}),()=>{t=!0}},[r]),o.useEffect(()=>{let t=!1;return So().then(n=>{t||Na(n.templates??[])}).catch(()=>{}),Eo().then(n=>{t||ya(n.templates??[])}).catch(()=>{}),()=>{t=!0}},[]),o.useEffect(()=>{try{localStorage.setItem(Jt,ze?"1":"0")}catch{}},[ze]),o.useEffect(()=>{v&&le(!1)},[v]),o.useEffect(()=>{w==="settings"&&E("settings")},[w]);const St=o.useMemo(()=>u.filter(t=>t.kind==="fragment"),[u]),me=o.useMemo(()=>{const t=et.trim().toLowerCase(),n=M=>!t||M.toLowerCase().includes(t),l=(M,U)=>M.name.localeCompare(U.name),x=[...St].sort(l).filter(M=>n(M.name)),y=[...gt].sort(l).filter(M=>n(M.name)),$=[...xt].sort((M,U)=>M.template.name.localeCompare(U.template.name)).filter(M=>n(M.template.name));return{fragmentEntries:x,stepEntries:y,pluginEntries:$}},[St,gt,xt,et]),Et=St.length+gt.length+xt.length,fs=Et>0,Ft=o.useMemo(()=>te.length?Fo(te,Kt):[],[te,Kt]),Me=o.useMemo(()=>Ao(_,te),[_,te]),ms=Ft.filter(t=>t.severity==="error").length,Ke=o.useMemo(()=>V||!F||fe.current===null?!1:_t(f,G,_,q,te,Se,Ee)!==fe.current,[V,F,f,G,_,q,te,Se,Ee]),$e=o.useCallback(async()=>{j(!0);try{const t=await Mo(r);D(t),C(n=>n&&t.some(l=>l.id===n)?n:i!=="create"&&g&&t.some(l=>l.id===g)?g:b?null:t[0]?.id??null)}catch(t){d(ae(t)||"Failed to load workflows","error")}finally{j(!1)}},[r,d,b,i,g]);o.useEffect(()=>{$e()},[$e]),o.useEffect(()=>{!g||!b||!N||A===g&&Qe.current!==g&&(Qe.current=g,p(!1))},[A,g,b,N]);const ps=o.useRef(!1);o.useEffect(()=>{if(ps.current)return;ps.current=!0;let t=!1;return(async()=>{try{const n=await Io(r);if(t)return;if(n.migrated>0){if(await $e(),t)return;let l=!1;try{l=localStorage.getItem(st)==="1"}catch{}l||as(!0)}}catch{}})(),()=>{t=!0}},[r,$e,st]);const Ia=o.useCallback(()=>{as(!1);try{localStorage.setItem(st,"1")}catch{}},[st]),lt=o.useCallback(async()=>{if(F)try{await Ro(F.id,r)}catch(t){d(ae(t)||a("workflows.exportFailed","Failed to export workflow"),"error")}},[F,r,d,a]),Ra=o.useCallback(async t=>{const n=t.target.files?.[0];if(at.current&&(at.current.value=""),!!n){kt(null),ls([]),rs(!0);try{const l=await n.text();let x;try{x=JSON.parse(l)}catch{kt(a("workflows.importInvalidJson","That file isn't valid JSON."));return}const y=await Po(x,r);await $e(),C(y.workflow.id),p(!1),d(a("workflows.imported",'Imported workflow "{{name}}"',{name:y.workflow.name}),"success"),y.strippedApprovalFlags&&d(a("workflows.importStripped","Auto-approval flags were removed from imported nodes"),"warning"),y.warnings.length>0&&ls(y.warnings)}catch(l){l instanceof ma&&l.status>=400&&l.status<500?kt(ae(l)||a("workflows.importFailed","Import failed")):d(ae(l)||a("workflows.importFailed","Import failed"),"error")}finally{rs(!1)}}},[r,$e,d,a]);o.useEffect(()=>{if(!F){Y([]),J([]),Ve([]),Ge([]),Ze([]),T(""),ee(""),fe.current=null;return}const t=Ds(F),n=Ts(F),l=zs(F),x=Do(F),y=Gs(t.nodes,t.edges,n),$=Us(t.nodes,y);Y($),J(t.edges),Ve(n),Ge(l),Ze(x),T(F.name),ee(F.description??""),X(!1),Q(!1),fe.current=_t(F.name,F.description??"",$,t.edges,n,l,x),S(null),B(null),R(null),ss({x:0,y:0,zoom:1},{duration:0}),Ct.current?(Ct.current=!1,K(!0)):K(!1)},[F,Y,J,ss]);const At=o.useRef(!1);o.useEffect(()=>{if(w!=="settings"||At.current||!F)return;const t=ht.current;t&&(At.current=!0,t.scrollIntoView({behavior:"smooth",inline:"end",block:"nearest"}))},[w,F]),o.useEffect(()=>()=>{At.current=!1},[w]);const[Mt,ws]=o.useState(null);o.useEffect(()=>{Y(t=>{const n=t.filter(l=>!ke(l.id)&&l.type!=="group");return[...To(te),...zo(n,te)]})},[te,Y]);const it=o.useCallback((t,n={})=>{const l=Lo(t,q,_);if("error"in l){l.error==="cycle"?d(a("workflowNodes.cycleBlocked","That connection would create a cycle — only rework edges inside a for-each template may loop back"),"warning"):l.error==="duplicate"&&d(a("workflowNodes.duplicateBlocked","That connection already exists"),"warning");return}J(x=>[...x,l.edge]),n.selectCreatedEdge&&(B(l.edge.id),S(null),le(!1))},[q,_,J,d,a]),Pa=o.useCallback(t=>{it(t)},[it]),Da=o.useCallback((t,n)=>{it({source:t,target:n,sourceHandle:null,targetHandle:null},{selectCreatedEdge:!0})},[it]),Ta=o.useCallback((t,n)=>{Y(l=>Qn(l,t,n))},[Y]),za=o.useCallback((t,n)=>{if(ke(n.id)||te.length===0)return;const l=Vt(n.position.y,te);l&&Y(x=>x.map(y=>y.id===n.id?{...y,data:{...y.data,column:l}}:y))},[te,Y]),rt=o.useCallback((t,n,l)=>{const x=ia(),y=n??(t==="merge"?"Merge boundary":t.charAt(0).toUpperCase()+t.slice(1)),$=t==="gate"?{gateMode:"gate"}:{},M=l?{...$,...l}:$;if(t==="foreach"||t==="loop"){const U=Oo(x,ia()),we=t==="foreach"?a("workflowNodes.stepExecuteLabel","Step execute"):a("workflowNodes.loopStepLabel","Loop step"),Fe=t==="foreach"?{seam:"step-execute"}:{prompt:""};Y(Lt=>[...Lt,{id:x,type:t,position:{x:200+Lt.length*40,y:240+Lt.length%3*70},data:{kind:t,label:y,config:M,templateEmpty:!1},style:{width:Wo,height:$o},deletable:!0},{id:U,type:"prompt",position:{x:_o,y:Bo},parentId:x,extent:"parent",data:{kind:"prompt",label:we,config:Fe},deletable:!0}]),S(x);return}Y(U=>[...U,{id:x,type:t,position:{x:200+U.length*40,y:240+U.length%3*70},data:{kind:t,label:y,config:M},deletable:!0}]),S(x)},[Y,a]),dt=o.useCallback(t=>{if(V)return;const{kind:n,label:l,config:x}=nl(t);rt(n,l,x)},[V,rt]),hs=o.useCallback(t=>{if(V)return!1;const n=qo(t.ir,_);if(n.length>0)return Qt(n.join(", ")),!1;Qt(null);const l=Vo(_,q,t.ir,{x:240,y:200+_.length%4*40},t.layout);return Y(l.nodes),J(l.edges),S(l.insertedNodeIds[0]??null),!0},[V,_,q,Y,J]),gs=o.useCallback(()=>{Y(t=>Us(t,Gs(t,q,te)))},[Y,q,te]),xs=o.useCallback(async()=>{if(!F||V)return;const t=ot.trim();if(!t){Oe(a("workflows.aiPromptRequired","Describe the workflow you want"));return}const n=new AbortController;nt.current=n;const l=F;yt(!0),Oe(null);try{const x=await Ls({prompt:t,workflowId:l.id},r,n.signal);if(ds.current!==l.id){d(a("workflows.aiStaleDiscarded","Discarded AI design — you switched workflows"),"warning");return}if(!await ue({title:a("workflows.aiReplaceTitle","Replace graph?"),message:a("workflows.aiReplaceConfirm","Replace the current graph with the AI design? Unsaved changes will be lost."),confirmLabel:a("workflows.aiReplaceConfirmLabel","Replace"),danger:!0}))return;const $=Ds({...l,ir:x.ir,layout:x.layout});Y($.nodes),J($.edges),Ve(Ts({...l,ir:x.ir})),Ge(zs({...l,ir:x.ir})),S(null),B(null),R(null),K(x.interpreterOnly),x.strippedApprovalFlags&&d(a("workflows.importStripped","Auto-approval flags were removed from imported nodes"),"warning"),jt(!1),Nt("")}catch(x){if(n.signal.aborted)return;Oe(ae(x)||a("workflows.aiFailed","Failed to design workflow"))}finally{nt.current===n&&(nt.current=null),yt(!1)}},[F,V,ot,r,ue,a,Y,J,d]),bs=o.useCallback(()=>{nt.current?.abort(),yt(!1)},[]),O=o.useCallback(t=>{v&&Y(n=>n.map(l=>l.id===v?{...l,data:{...l.data,..."config"in t?{config:typeof t.config=="function"?t.config(l.data.config??{}):{...l.data.config??{},...t.config}}:t}}:l))},[v,Y]),It=o.useCallback(t=>{W&&J(n=>n.map(l=>{if(l.id!==W)return l;const x=t.condition??l.data?.condition??"success",y=t.rework??l.data?.kind==="rework";return{...l,label:y?`${Os(x)} (rework)`:Os(x),data:{...l.data??{},condition:x,kind:y?"rework":void 0},type:y?"step":void 0,animated:y,className:Go(x,y)}}))},[W,J]),ks=o.useCallback(t=>{const n=new Set(t);let l=null;Y(x=>(l=$s(x,q,n),l.nodes)),l&&J(l.edges),v!==null&&n.has(v)&&S(null),W!==null&&n.has(W)&&B(null)},[q,Y,J,v,W]),La=o.useCallback(async({nodes:t,edges:n})=>{if(V)return!1;const l=new Set([...t.map(M=>M.id),...n.map(M=>M.id)]),x=$s(_,q,l),y=new Set(_.map(M=>M.id));for(const M of x.nodes)y.delete(M.id);const $=new Set(q.map(M=>M.id));for(const M of x.edges)$.delete(M.id);return y.size===0&&$.size===0?!1:{nodes:_.filter(M=>y.has(M.id)),edges:q.filter(M=>$.has(M.id))}},[V,_,q]),Oa=o.useCallback(()=>{S(null),bt.current?.focus()},[]),$a=o.useCallback(()=>{B(null),bt.current?.focus()},[]),Je=o.useCallback(()=>{oe(!1),Te.current?.focus()},[]),Wa=o.useCallback(async(t,n,l)=>{const x=l.source!==void 0?Uo(l.source.ir,l.source.layout):{ir:hn(t),layout:wn()},y=await Ot({name:t,description:n||void 0,kind:"workflow",ir:x.ir,layout:x.layout},r);D($=>[...$,y]),C(y.id),p(!1),d(a("workflows.created",'Created workflow "{{name}}"',{name:y.name}),"success"),Je()},[r,d,a,Je]),Ba=o.useCallback(async(t,n,l)=>{const x=await Ls({prompt:t},r,l),y=`AI: ${t.slice(0,30)}`,M=await Ot({name:n||y,kind:"workflow",ir:x.ir,layout:x.layout},r);Ct.current=x.interpreterOnly,D(U=>[...U,M]),C(M.id),p(!1),d(a("workflows.created",'Created workflow "{{name}}"',{name:M.name}),"success"),x.strippedApprovalFlags&&d(a("workflows.importStripped","Auto-approval flags were removed from imported nodes"),"warning"),Je()},[r,d,a,Je]),vs=o.useCallback(async()=>{if(!(!F||_e(F.id)||!await ue({title:a("workflows.deleteTitle","Delete workflow?"),message:a("workflows.deleteMessage",'Delete workflow "{{name}}"? This cannot be undone.',{name:F.name}),confirmLabel:a("common.delete","Delete"),danger:!0})))try{await Ho(F.id,r),D(n=>n.filter(l=>l.id!==F.id)),C(null),b&&p(!0),d(a("workflows.deleted","Workflow deleted"),"success")}catch(n){d(ae(n)||a("workflows.deleteFailed","Failed to delete workflow"),"error")}},[F,r,d,ue,a,b]),js=o.useCallback(async()=>{if(F)try{const t=await Ot({name:`${F.name} (copy)`,description:F.description,ir:F.ir,layout:F.layout},r);D(n=>[...n,t]),C(t.id),p(!1),d(`Duplicated to "${t.name}" — editable`,"success")}catch(t){d(ae(t)||"Failed to duplicate workflow","error")}},[F,r,d]),Ns=o.useCallback(async()=>{if(F&&!_e(F.id)){if(Me.length>0){const t=a("workflowColumns.unplacedCount","{{count}} nodes not placed in a column",{count:Me.length});R(t),d(t,"error");return}if(ms>0){const t=a("workflowColumns.compositionBlocked","Resolve trait conflicts on highlighted columns before saving");R(t),d(t,"error");return}z(!0),R(null),K(!1),ws(null);try{const t=f.trim()||F.name,{ir:n,layout:l}=pa(t,_,q,te.length?te:void 0,Se.length?Se:void 0,Ee.length?Ee:void 0),x=t!==F.name,y=G!==(F.description??""),$=async U=>{D(we=>we.map(Fe=>Fe.id===U.id?U:Fe)),fe.current=_t(U.name,U.description??"",_,q,te,Se,Ee),T(U.name),ee(U.description??"");try{await Yo(U.id,r),d(a("workflows.saved","Workflow saved"),"success")}catch(we){const Fe=ae(we)||"";Fe.includes("require the workflow interpreter (deferred)")?K(!0):R(Fe||a("workflows.savedNotCompilable","Workflow saved but cannot be compiled"))}},M={ir:n,layout:l,...x?{name:t}:{},...y?{description:G}:{}};try{await $(await Ws(F.id,M,r))}catch(U){if(!(U?.details?.policyEscalation===!0))throw U;if(!window.confirm(`${ae(U)}
7
-
8
- ${a("workflowColumns.confirmPolicyEscalation","Bind it anyway? The column agent will run with broader permissions than this project's default.")}`)){d(a("workflowColumns.escalationDeclined","Save cancelled — column agent binding not confirmed"),"error");return}await $(await Ws(F.id,{...M,confirmPolicyEscalation:!0},r))}}catch(t){const n=ae(t)||a("workflows.saveFailed","Failed to save workflow"),l=/node '([^']+)'/.exec(n);l&&_.some(x=>x.id===l[1])&&ws({nodeId:l[1],message:n}),R(n),d(n,"error")}finally{z(!1)}}},[F,f,G,_,q,te,Se,Ee,Me,ms,r,d,a]),We=o.useMemo(()=>{const t=new Set(Me),n=new Map;for(const l of _)l.parentId&&n.set(l.parentId,(n.get(l.parentId)??0)+1);return _.map(l=>{let x;t.has(l.id)&&(x=a("workflowColumns.nodeUnplaced","Not placed in a column")),Mt?.nodeId===l.id&&(x=Mt.message);const y=l.data.kind==="foreach"||l.data.kind==="loop",$=l.data.kind==="loop"?a("workflowNodes.loopEmptyHint","Drag loop steps here"):a("workflowNodes.foreachEmptyHint","Drag a step-execute node here"),M=y?(n.get(l.id)??0)===0:void 0;return x===l.data.errorBadge&&(!y||M===l.data.templateEmpty&&l.data.emptyHint===$)?l:{...l,data:{...l.data,errorBadge:x,...y?{templateEmpty:M,emptyHint:$}:{}}}})},[_,Me,Mt,a]),m=_.find(t=>t.id===v)??null,ys=m!==null&&m.data.kind!=="end",xe=q.find(t=>t.id===W)??null,_a=b&&ys&&!ne,qa=b&&xe!==null,[Rt,Cs]=o.useState(!1),Ss=o.useCallback(()=>{Cs(t=>!t)},[]),Va=o.useCallback(t=>{!Rt||t.key!=="Escape"||(t.preventDefault(),t.stopPropagation(),Cs(!1))},[Rt]),Es=m&&(m.data.kind==="prompt"||m.data.kind==="gate")?String(m.data.config?.prompt??(V?tl(m.data.config):"")):"",Fs=o.useMemo(()=>{if(!xe)return"readonly";const t=_.find(n=>n.id===xe.source);return Ko(t?.data.kind)},[xe,_]),Pt=o.useMemo(()=>{const t=F?.ir;return t&&t.version==="v2"&&Array.isArray(t.artifacts)?t.artifacts.map(n=>n.key):[]},[F]),[Ie,Dt]=o.useState([]),[be,ct]=o.useState([]);o.useEffect(()=>{ct([])},[r]);const[Xe,As]=o.useState([]),[Ga,Ua]=o.useState(sl);o.useEffect(()=>{let t=!1;return Promise.resolve(pt()).then(n=>{!t&&n?.models&&Dt(n.models)}).catch(()=>{}),Promise.resolve(mt()).then(n=>{!t&&Array.isArray(n)&&ct(n)}).catch(()=>{}),Promise.resolve(Bs(r)).then(n=>{!t&&Array.isArray(n)&&As(n)}).catch(()=>{}),()=>{t=!0}},[r]);const Tt=o.useMemo(()=>({models:Ie.map(t=>({provider:t.provider,id:t.id,name:t.name})),agents:be.map(t=>({id:t.id,name:t.name})),skills:Xe.map(t=>({id:t.id,name:t.name}))}),[Ie,be,Xe]),Ms=o.useMemo(()=>{const t=We.filter(l=>!ke(l.id)&&l.data.kind!=="start").map(l=>({id:l.id,label:l.data.label||l.id,kind:l.data.kind})),n=new Map;for(const l of We){if(ke(l.id)||l.data.kind==="start"||l.data.kind==="end")continue;const x=t.filter(y=>y.id!==l.id);x.length>0&&n.set(l.id,x)}return n},[We]),Ha=o.useMemo(()=>{const t=n=>n.map(l=>({...l,connectionTargets:V?[]:Ms.get(l.id)??[],children:t(l.children)}));return t(el(We,q,te,Tt,a))},[We,q,te,Tt,a,V,Ms]),pe=m?.data.config?.executor??"model",Re=o.useMemo(()=>{const t=m?.data.column??(m?.parentId?_.find(l=>l.id===m.parentId)?.data.column:void 0);if(!t)return;const n=te.find(l=>l.id===t);if(!(!n?.agent||n.agent.mode!=="override"))return n.agent},[m?.data.column,m?.parentId,_,te]),Ya=o.useMemo(()=>Re?be.find(t=>t.id===Re.agentId):void 0,[Re,be]);o.useEffect(()=>{if(pe!=="cli-agent")return;let t=!1;return fetch("/api/cli-agents").then(n=>n.ok?n.json():null).then(n=>{t||!n?.adapters||Ua(n.adapters)}).catch(()=>{}),()=>{t=!0}},[pe]),o.useEffect(()=>{if(m?.data.kind==="step-review"&&Ie.length===0){pt().then(t=>Dt(t.models)).catch(t=>{d(ae(t)||"Failed to load models","error")});return}!m||m.data.kind!=="prompt"&&m.data.kind!=="gate"||(pe==="model"&&Ie.length===0?pt().then(t=>Dt(t.models)).catch(t=>{d(ae(t)||"Failed to load models","error")}):pe==="agent"&&be.length===0?mt(void 0,r).then(ct).catch(t=>{d(ae(t)||"Failed to load agents","error")}):pe==="skill"&&Xe.length===0&&Bs(r).then(As).catch(t=>{d(ae(t)||"Failed to load skills","error")}))},[pe,m?.id,m?.data.kind,r,d,Ie.length,be.length,Xe.length]);const ut=o.useCallback(t=>{if(!Ke){t();return}ue({title:a("workflows.discardTitle","Discard unsaved changes?"),message:a("workflows.discardMessage","You have unsaved changes to this workflow. Discard them?"),confirmLabel:a("workflows.discardConfirm","Discard"),danger:!0}).then(n=>{n&&t()})},[Ke,ue,a]),zt=o.useCallback(()=>{ut(s)},[ut,s]),Ka=o.useCallback(t=>{if(t===A){p(!1);return}ut(()=>{C(t),p(!1)})},[ut,A]);o.useEffect(()=>{if(!Re||be.length>0)return;let t=!1;return Promise.resolve(mt(void 0,r)).then(n=>{t||ct(n??[])}).catch(n=>{t||d(ae(n)||"Failed to load agents","error")}),()=>{t=!0}},[Re,be.length,r,d]);const Ja=wa(zt),Xa=Rt&&(m?.data.kind==="prompt"||m?.data.kind==="gate")?Qa.createPortal(e.jsxs("div",{className:"wf-prompt-editor wf-prompt-editor--fullscreen",onKeyDown:Va,children:[e.jsxs("div",{className:"wf-prompt-fullscreen-header",children:[e.jsx("span",{children:a("workflowEditor.editingPrompt","Editing Prompt")}),e.jsx("button",{type:"button",className:"btn btn-sm wf-prompt-expand-btn",onClick:Ss,"aria-label":a("workflowEditor.collapsePrompt","Collapse prompt editor"),title:a("workflowEditor.collapsePrompt","Collapse prompt editor"),children:e.jsx(Jo,{size:14})})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Prompt"}),e.jsx("textarea",{rows:void 0,value:Es,readOnly:V,onChange:t=>O({config:{prompt:t.target.value}}),autoFocus:!0})]})]}),document.body):null;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"modal-overlay open wf-editor-overlay",...Ja,children:e.jsxs("div",{className:"modal wf-editor-modal",ref:I,onClick:t=>t.stopPropagation(),onKeyDown:t=>{if(t.key!=="Escape"||Ce)return;const l=t.target.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||(t.stopPropagation(),zt())},children:[e.jsxs("header",{className:"wf-editor-header",children:[e.jsx("h2",{children:"Workflows"}),e.jsx("button",{className:"wf-editor-close",onClick:zt,"aria-label":"Close workflow editor",children:e.jsx(Ht,{size:18})})]}),Aa?e.jsxs("div",{className:"wf-migration-notice",role:"status","data-testid":"wf-migration-notice",children:[e.jsx("span",{className:"wf-migration-notice-text",children:a("workflows.migrationNotice",'Your legacy workflow steps were converted — find them as templates in the palette and as the "Migrated steps" workflow.')}),e.jsx("button",{type:"button",className:"wf-migration-notice-dismiss","data-testid":"wf-migration-notice-dismiss",onClick:Ia,"aria-label":a("common.dismiss","Dismiss"),children:e.jsx(Ht,{size:14})})]}):null,e.jsxs("div",{className:`wf-editor-body${N?" wf-editor-body--list-stage":" wf-editor-body--editor-stage"}${H?" wf-editor-body--simple-layout":""}${_a?" wf-editor-body--mobile-node-detail":""}${qa?" wf-editor-body--mobile-edge-detail":""}`,children:[e.jsxs("aside",{className:"wf-editor-sidebar",children:[e.jsxs("button",{className:"wf-editor-new",ref:Te,"data-testid":"wf-new-workflow",onClick:()=>oe(!0),children:[e.jsx(ye,{size:14})," ",a("workflows.newWorkflow","New workflow")]}),e.jsxs("button",{type:"button",className:"wf-editor-import","data-testid":"wf-import",disabled:is,onClick:()=>at.current?.click(),title:a("workflows.importTooltip","Import a workflow from a JSON file"),children:[is?e.jsx(Ae,{size:14,className:"wf-spin"}):e.jsx(gn,{size:14})," ",a("workflows.import","Import")]}),e.jsx("input",{ref:at,type:"file",accept:".json",className:"wf-editor-import-input","data-testid":"wf-import-input",style:{display:"none"},onChange:Ra}),os&&e.jsx("div",{className:"wf-editor-import-error",role:"alert","data-testid":"wf-import-error",children:os}),ns.length>0&&e.jsx("div",{className:"wf-editor-import-warnings","data-testid":"wf-import-warnings",children:ns.map((t,n)=>e.jsx("p",{className:"wf-editor-import-warning",children:t},n))}),b&&u.length>0&&!F?e.jsx("div",{className:"wf-editor-select-note","data-testid":"wf-mobile-select-note",children:a("workflows.mobileSelectNote","Select a workflow to edit.")}):null,c?e.jsxs("div",{className:"wf-editor-empty",children:[e.jsx(Ae,{size:16,className:"wf-spin"})," Loading…"]}):u.length===0?e.jsx("div",{className:"wf-editor-empty",children:"No workflows yet."}):e.jsx("ul",{className:"wf-editor-list",children:u.map(t=>e.jsx("li",{children:e.jsx("button",{className:`wf-editor-list-item${t.id===A?" active":""}`,onClick:()=>Ka(t.id),children:t.name})},t.id))}),F&&!H&&e.jsxs("div",{className:"wf-sidebar-panels",children:[e.jsxs("section",{className:"wf-sidebar-section","data-testid":"wf-sidebar-columns-section",children:[e.jsxs("button",{type:"button",className:"wf-sidebar-section-toggle","aria-expanded":!Ue,"data-testid":"wf-sidebar-columns-toggle",onClick:()=>Sa(t=>!t),children:[Ue?e.jsx(Pe,{size:13}):e.jsx(Ne,{size:13}),e.jsx("span",{children:a("workflowColumns.title","Columns")})]}),!Ue&&e.jsx(Ys,{columns:te,onChange:Ve,violations:Ft,readOnly:V,projectId:r,addToast:d,columnAgentsEnabled:us})]}),e.jsxs("section",{className:"wf-sidebar-section","data-testid":"wf-sidebar-fields-section",children:[e.jsxs("button",{type:"button",className:"wf-sidebar-section-toggle","aria-expanded":!He,"data-testid":"wf-sidebar-fields-toggle",onClick:()=>Ea(t=>!t),children:[He?e.jsx(Pe,{size:13}):e.jsx(Ne,{size:13}),e.jsx("span",{children:a("workflowFields.title","Fields")})]}),!He&&e.jsx(Xs,{fields:Se,onChange:Ge,readOnly:V,addToast:d})]}),e.jsxs("section",{className:"wf-sidebar-section","data-testid":"wf-sidebar-settings-section",children:[e.jsxs("button",{type:"button",className:"wf-sidebar-section-toggle","aria-expanded":!Ye,"data-testid":"wf-sidebar-settings-toggle",onClick:()=>Fa(t=>!t),children:[Ye?e.jsx(Pe,{size:13}):e.jsx(Ne,{size:13}),e.jsx("span",{children:a("workflowSettings.title","Settings")})]}),!Ye&&e.jsx("div",{ref:ht,className:"wf-settings-panel-wrap",children:e.jsx(ta,{workflowId:F.id,settings:Ee,onChange:Ze,readOnly:V,projectId:r,addToast:d,initialTab:"values"})})]})]})]}),e.jsxs("section",{className:"wf-editor-canvas-wrap",children:[e.jsxs("button",{type:"button",className:"wf-editor-mobile-back",onClick:()=>p(!0),"aria-label":a("workflows.backToWorkflowList","Back to workflows"),children:[e.jsx(Xo,{size:16}),e.jsx("span",{children:a("common.back","Back")})]}),F?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"wf-name-strip",children:[V?e.jsx("span",{className:"wf-workflow-name wf-workflow-name--readonly","data-testid":"wf-workflow-name",children:F.name}):re?e.jsx("input",{className:"wf-workflow-name-input","data-testid":"wf-workflow-name-input",autoFocus:!0,value:f,"aria-label":a("workflows.nameLabel","Workflow name"),onChange:t=>T(t.target.value),onKeyDown:t=>{t.key==="Enter"?(t.preventDefault(),f.trim()||T(F.name),X(!1)):t.key==="Escape"&&(t.preventDefault(),T(F.name),X(!1))},onBlur:()=>{f.trim()||T(F.name),X(!1)}}):e.jsx("button",{type:"button",className:"wf-workflow-name","data-testid":"wf-workflow-name",onClick:()=>X(!0),title:a("workflows.clickToRename","Click to rename"),children:f||F.name}),V?F.description?e.jsx("span",{className:"wf-workflow-description wf-workflow-description--readonly","data-testid":"wf-workflow-description",children:F.description}):null:he?e.jsx("input",{className:"wf-workflow-description-input","data-testid":"wf-workflow-description-input",autoFocus:!0,value:G,"aria-label":a("workflows.descriptionLabel","Workflow description"),placeholder:a("workflows.descriptionPlaceholder","Add a description"),onChange:t=>ee(t.target.value),onKeyDown:t=>{t.key==="Enter"?(t.preventDefault(),Q(!1)):t.key==="Escape"&&(t.preventDefault(),ee(F.description??""),Q(!1))},onBlur:()=>Q(!1)}):e.jsx("button",{type:"button",className:"wf-workflow-description","data-testid":"wf-workflow-description",onClick:()=>Q(!0),title:a("workflows.clickToEditDescription","Click to edit description"),children:G||a("workflows.descriptionPlaceholder","Add a description")}),!b&&e.jsxs("button",{type:"button",className:"wf-layout-toggle","data-testid":"wf-layout-toggle","aria-pressed":ie,onClick:()=>Z(t=>!t),children:[ie?e.jsx($t,{size:14}):e.jsx(ha,{size:14}),e.jsx("span",{children:ie?a("workflows.showCanvasEditor","Show canvas editor"):a("workflows.showSimpleEditor","Show simple editor")})]})]}),H&&e.jsxs("div",{className:"wf-mobile-shell","data-testid":"wf-mobile-shell",children:[e.jsx("nav",{className:"wf-mobile-tabs","aria-label":a("workflows.mobileEditorNav","Workflow editor sections"),children:[["graph",a("workflowNodes.mobileGraph","Graph")],["add",a("workflowNodes.mobileAdd","Add")],["settings",a("workflowSettings.title","Settings")],["fields",a("workflowFields.title","Fields")],["columns",a("workflowColumns.title","Columns")],["actions",a("workflowNodes.mobileActions","Actions")]].map(([t,n])=>e.jsx("button",{type:"button",className:`wf-mobile-tab${se===t?" wf-mobile-tab--active":""}`,"aria-current":se===t?"page":void 0,"data-testid":`wf-mobile-tab-${t}`,onClick:()=>E(t),children:n},t))}),e.jsxs("div",{className:"wf-mobile-panel","data-testid":`wf-mobile-panel-${se}`,children:[se==="graph"&&e.jsx(Kn,{rows:Ha,selectedNodeId:v,selectedEdgeId:W,onSelectNode:t=>{S(t),B(null),le(!1)},onSelectEdge:t=>{B(t),S(null)},onCreateConnection:V?void 0:Da,canReorder:!V,onMoveNode:Ta}),se==="add"&&e.jsx("div",{className:"wf-mobile-add",children:V?e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflows.readOnlyBuiltin","Read-only built-in workflow")}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"wf-mobile-add-section",children:[e.jsx("h3",{children:a("workflowNodes.mobileNodeKinds","Node types")}),e.jsx("div",{className:"wf-mobile-add-grid",children:da.map(({kind:t,label:n,icon:l,presetConfig:x})=>e.jsxs("button",{type:"button",className:"wf-mobile-add-option","data-testid":`wf-mobile-add-${t}-${n.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,onClick:()=>{rt(t,n,x),E("graph")},children:[e.jsx(l,{size:16,"aria-hidden":!0}),e.jsx("span",{children:n})]},n))})]}),fs&&e.jsxs("section",{className:"wf-mobile-add-section",children:[e.jsx("h3",{children:a("workflowNodes.templatesSection","Templates")}),Et>8&&e.jsx("input",{type:"text",className:"wf-templates-filter wf-mobile-template-filter","data-testid":"wf-mobile-template-filter",value:et,onChange:t=>Xt(t.target.value),placeholder:a("workflowNodes.templateFilterPlaceholder","Filter templates"),"aria-label":a("workflowNodes.templateFilterLabel","Filter templates")}),tt&&e.jsx("div",{className:"wf-templates-conflict",role:"alert","data-testid":"wf-mobile-tpl-conflict",children:a("workflowNodes.templateSeamConflict",`This fragment duplicates the "{{seam}}" seam already on the canvas, so it can't be inserted.`,{seam:tt})}),me.fragmentEntries.length>0&&e.jsxs("div",{className:"wf-mobile-template-group",children:[e.jsx("h4",{children:a("workflowNodes.templatesFragments","Fragments")}),me.fragmentEntries.map(t=>e.jsx("button",{type:"button",className:"wf-mobile-template-option","data-testid":`wf-mobile-tpl-fragment-${t.id}`,onClick:()=>{hs(t)&&E("graph")},children:t.name},t.id))]}),me.stepEntries.length>0&&e.jsxs("div",{className:"wf-mobile-template-group",children:[e.jsx("h4",{children:a("workflowNodes.templatesBuiltinSteps","Built-in steps")}),me.stepEntries.map(t=>e.jsx("button",{type:"button",className:"wf-mobile-template-option","data-testid":`wf-mobile-tpl-step-${t.id}`,onClick:()=>{dt(t),E("graph")},children:t.name},t.id))]}),me.pluginEntries.length>0&&e.jsxs("div",{className:"wf-mobile-template-group",children:[e.jsx("h4",{children:a("workflowNodes.templatesPluginSteps","Plugin steps")}),me.pluginEntries.map(({pluginId:t,template:n})=>e.jsxs("button",{type:"button",className:"wf-mobile-template-option","data-testid":`wf-mobile-tpl-plugin-${n.id}`,onClick:()=>{dt(n),E("graph")},children:[e.jsx("span",{children:n.name}),e.jsx("span",{className:"wf-templates-badge",children:t})]},`${t}:${n.id}`))]})]})]})}),se==="settings"&&F&&e.jsx("div",{ref:ht,className:"wf-mobile-destination",children:e.jsx(ta,{workflowId:F.id,settings:Ee,onChange:Ze,readOnly:V,projectId:r,addToast:d,initialTab:"values"})}),se==="fields"&&e.jsx("div",{className:"wf-mobile-destination",children:e.jsx(Xs,{fields:Se,onChange:Ge,readOnly:V,addToast:d})}),se==="columns"&&e.jsx("div",{className:"wf-mobile-destination",children:e.jsx(Ys,{columns:te,onChange:Ve,violations:Ft,readOnly:V,projectId:r,addToast:d,columnAgentsEnabled:us})}),se==="actions"&&e.jsx("div",{className:"wf-mobile-actions",children:V?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflows.readOnlyBuiltin","Read-only built-in workflow")}),e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-mobile-export",onClick:lt,children:[e.jsx(ft,{size:15})," ",a("workflows.export","Export")]}),e.jsxs("button",{className:"wf-editor-save wf-editor-duplicate-primary","data-testid":"wf-mobile-duplicate",onClick:js,children:[e.jsx(ye,{size:15})," ",a("workflows.duplicateToCustomize","Duplicate to customize")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"wf-editor-save","data-testid":"wf-mobile-save",onClick:Ns,disabled:h,children:[h?e.jsx(Ae,{size:15,className:"wf-spin"}):e.jsx(Gt,{size:15}),a("common.save","Save")]}),e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-mobile-ai-edit",onClick:()=>jt(t=>!t),children:[e.jsx(Be,{size:15})," ",a("workflows.aiEdit","Design with AI")]}),vt&&e.jsxs("div",{className:"wf-ai-panel wf-mobile-ai-panel","data-testid":"wf-mobile-ai-panel",role:"dialog","aria-busy":ge,children:[e.jsx("textarea",{className:"wf-ai-prompt","data-testid":"wf-mobile-ai-edit-prompt",rows:4,value:ot,disabled:ge,placeholder:a("workflows.aiPromptPlaceholder","e.g. Run lint and tests before merge, then post a changelog comment after merge"),onChange:t=>{Nt(t.target.value),Le&&Oe(null)}}),Le&&e.jsx("p",{className:"wf-create-error",role:"alert","data-testid":"wf-mobile-ai-edit-error",children:Le}),e.jsxs("div",{className:"wf-ai-actions",children:[e.jsxs("button",{type:"button",className:"btn btn-primary wf-ai-submit","data-testid":"wf-mobile-ai-edit-submit",disabled:ge,onClick:()=>void xs(),children:[ge?e.jsx(Ae,{size:13,className:"wf-spin"}):e.jsx(Be,{size:13}),a("workflows.aiSubmit","Design with AI")]}),ge&&e.jsx("button",{type:"button",className:"btn wf-ai-cancel",onClick:bs,children:a("common.cancel","Cancel")})]})]}),e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-mobile-auto-layout",onClick:gs,children:[e.jsx($t,{size:15})," ",a("workflowNodes.autoLayout","Auto-layout")]}),e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-mobile-export",onClick:lt,disabled:Ke,children:[e.jsx(ft,{size:15})," ",a("workflows.export","Export")]}),e.jsxs("button",{className:"wf-editor-delete","data-testid":"wf-mobile-delete",onClick:vs,children:[e.jsx(ve,{size:15})," ",a("common.delete","Delete")]})]})})]})]}),V?e.jsxs("div",{className:"wf-editor-readonly-banner",role:"status","data-testid":"wf-readonly-banner",children:[e.jsx("span",{className:"wf-editor-readonly-note",children:a("workflows.readOnlyBuiltin","Read-only built-in workflow")}),e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-export",onClick:lt,title:a("workflows.exportTooltip","Download as JSON — contains your full prompt and command text"),children:[e.jsx(ft,{size:13})," ",a("workflows.export","Export")]}),e.jsxs("button",{className:"wf-editor-save wf-editor-duplicate-primary",onClick:js,children:[e.jsx(ye,{size:13})," ",a("workflows.duplicateToCustomize","Duplicate to customize")]})]}):e.jsxs("div",{className:"wf-editor-toolbar",children:[e.jsx("div",{className:"wf-editor-palette",children:da.map(({kind:t,label:n,icon:l,presetConfig:x})=>e.jsxs("button",{className:"wf-palette-btn",onClick:()=>rt(t,n,x),children:[e.jsx(l,{size:13})," ",n]},n))}),e.jsxs("div",{className:"wf-editor-actions",children:[e.jsxs("div",{className:"wf-ai-edit-wrap",children:[e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-ai-edit","aria-expanded":vt,onClick:()=>{jt(t=>!t),Oe(null)},children:[e.jsx(Be,{size:13})," ",a("workflows.aiEdit","Design with AI")]}),vt&&e.jsxs("div",{className:"wf-ai-panel","data-testid":"wf-ai-panel",role:"dialog","aria-busy":ge,"aria-label":a("workflows.aiEdit","Design with AI"),children:[e.jsx("textarea",{className:"wf-ai-prompt","data-testid":"wf-ai-edit-prompt",rows:3,value:ot,disabled:ge,placeholder:a("workflows.aiPromptPlaceholder","e.g. Run lint and tests before merge, then post a changelog comment after merge"),onChange:t=>{Nt(t.target.value),Le&&Oe(null)}}),Le&&e.jsx("p",{className:"wf-create-error",role:"alert","data-testid":"wf-ai-edit-error",children:Le}),e.jsxs("div",{className:"wf-ai-actions",children:[e.jsxs("button",{type:"button",className:"btn btn-primary wf-ai-submit","data-testid":"wf-ai-edit-submit",disabled:ge,onClick:()=>void xs(),children:[ge?e.jsx(Ae,{size:13,className:"wf-spin"}):e.jsx(Be,{size:13})," ",a("workflows.aiSubmit","Design with AI")]}),ge&&e.jsx("button",{type:"button",className:"btn wf-ai-cancel","data-testid":"wf-ai-edit-cancel",onClick:bs,children:a("common.cancel","Cancel")})]})]})]}),e.jsxs("button",{className:"wf-editor-action",onClick:gs,"data-testid":"wf-auto-layout",children:[e.jsx($t,{size:13})," ",a("workflowNodes.autoLayout","Auto-layout")]}),e.jsxs("button",{className:"wf-editor-action","data-testid":"wf-export",onClick:lt,disabled:Ke,title:Ke?a("workflows.exportDirtyTooltip","Save before exporting"):a("workflows.exportTooltip","Download as JSON — contains your full prompt and command text"),children:[e.jsx(ft,{size:13})," ",a("workflows.export","Export")]}),e.jsxs("button",{className:"wf-editor-delete",onClick:vs,children:[e.jsx(ve,{size:13})," ",a("common.delete","Delete")]}),e.jsxs("button",{className:"wf-editor-save",onClick:Ns,disabled:h,children:[h?e.jsx(Ae,{size:13,className:"wf-spin"}):e.jsx(Gt,{size:13})," ",a("common.save","Save")]})]})]}),fs&&e.jsxs("section",{className:"wf-templates","data-testid":"wf-palette-templates","aria-label":a("workflowNodes.templatesSection","Templates"),children:[e.jsxs("div",{className:"wf-templates-header",children:[e.jsxs("button",{type:"button",className:"wf-templates-toggle","aria-expanded":!ze,"data-testid":"wf-templates-toggle",onClick:()=>Ca(t=>!t),children:[ze?e.jsx(Pe,{size:13}):e.jsx(Ne,{size:13}),e.jsx(bn,{size:13})," ",a("workflowNodes.templatesSection","Templates")]}),!ze&&Et>8&&e.jsx("input",{type:"text",className:"wf-templates-filter","data-testid":"wf-template-filter",value:et,onChange:t=>Xt(t.target.value),placeholder:a("workflowNodes.templateFilterPlaceholder","Filter templates"),"aria-label":a("workflowNodes.templateFilterLabel","Filter templates")})]}),!ze&&e.jsxs("div",{className:"wf-templates-body",children:[tt&&e.jsx("div",{className:"wf-templates-conflict",role:"alert","data-testid":"wf-tpl-conflict",children:a("workflowNodes.templateSeamConflict",`This fragment duplicates the "{{seam}}" seam already on the canvas, so it can't be inserted.`,{seam:tt})}),me.fragmentEntries.length>0&&e.jsxs("div",{className:"wf-templates-group",children:[e.jsx("h4",{className:"wf-templates-group-title",children:a("workflowNodes.templatesFragments","Fragments")}),e.jsx("div",{className:"wf-templates-entries",children:me.fragmentEntries.map(t=>e.jsx("button",{type:"button",className:"wf-templates-entry","data-testid":`wf-tpl-fragment-${t.id}`,disabled:V,"aria-label":a("workflowNodes.insertTemplate","Insert template {{name}}",{name:t.name}),onClick:()=>hs(t),children:t.name},t.id))})]}),me.stepEntries.length>0&&e.jsxs("div",{className:"wf-templates-group",children:[e.jsx("h4",{className:"wf-templates-group-title",children:a("workflowNodes.templatesBuiltinSteps","Built-in steps")}),e.jsx("div",{className:"wf-templates-entries",children:me.stepEntries.map(t=>e.jsx("button",{type:"button",className:"wf-templates-entry","data-testid":`wf-tpl-step-${t.id}`,disabled:V,"aria-label":a("workflowNodes.insertTemplate","Insert template {{name}}",{name:t.name}),onClick:()=>dt(t),children:t.name},t.id))})]}),me.pluginEntries.length>0&&e.jsxs("div",{className:"wf-templates-group",children:[e.jsx("h4",{className:"wf-templates-group-title",children:a("workflowNodes.templatesPluginSteps","Plugin steps")}),e.jsx("div",{className:"wf-templates-entries",children:me.pluginEntries.map(({pluginId:t,template:n})=>e.jsxs("button",{type:"button",className:"wf-templates-entry","data-testid":`wf-tpl-plugin-${n.id}`,disabled:V,"aria-label":a("workflowNodes.insertTemplate","Insert template {{name}}",{name:n.name}),onClick:()=>dt(n),children:[n.name,e.jsx("span",{className:"wf-templates-badge",children:t})]},`${t}:${n.id}`))})]})]})]}),k&&e.jsx("div",{className:"wf-editor-banner",role:"alert",children:k}),P&&e.jsx("div",{className:"wf-editor-banner wf-editor-banner--info",role:"status","data-testid":"wf-interpreter-only-banner",children:a("workflowNodes.interpreterOnly","This workflow branches, so it runs on the graph interpreter — it can't compile to the linear step engine, but it will still run.")}),Me.length>0&&e.jsx("div",{className:"wf-editor-banner wf-editor-banner--warn",role:"alert","data-testid":"wf-unplaced-summary",children:a("workflowColumns.unplacedCount","{{count}} nodes not placed in a column",{count:Me.length})}),e.jsxs("div",{className:"wf-editor-canvas",ref:bt,tabIndex:-1,children:[b&&ne&&m&&m.data.kind!=="end"&&e.jsxs("button",{type:"button",className:"wf-inspector-toggle wf-inspector-toggle--collapsed","data-testid":"wf-inspector-toggle","aria-expanded":"false",onClick:()=>le(!1),children:[e.jsx(Pe,{size:13}),e.jsx("span",{children:a("workflowNodes.showInspector","Show node details")})]}),Ma&&e.jsx("div",{className:"wf-trivial-hint",role:"status","data-testid":"wf-trivial-hint",children:a("workflowNodes.trivialGraphHint","This workflow only runs start → end. Add steps from the palette above to build it out.")}),e.jsx(cn.Provider,{value:Tt,children:e.jsxs(ao,{nodes:We,edges:q,nodeTypes:fn,onNodesChange:de,onEdgesChange:ce,onConnect:Pa,onNodeDragStop:za,deleteKeyCode:V?null:["Backspace","Delete"],onBeforeDelete:La,onNodesDelete:Oa,onEdgesDelete:$a,onNodeClick:(t,n)=>{S(n.id),B(null),le(!1)},onEdgeClick:(t,n)=>{B(n.id),S(null)},onPaneClick:()=>{S(null),B(null)},defaultEdgeOptions:{interactionWidth:un},defaultViewport:{x:0,y:0,zoom:1},children:[e.jsx(oo,{}),e.jsx(no,{}),e.jsx(lo,{pannable:!0,zoomable:!0})]})})]})]}):e.jsxs("div",{className:"wf-editor-empty wf-editor-canvas-empty wf-editor-onboard",children:[e.jsx(mn,{className:"wf-editor-onboard-icon",size:40,"aria-hidden":!0}),e.jsx("h3",{className:"wf-editor-onboard-title",children:a("workflows.emptyTitle","No workflow selected")}),e.jsx("p",{className:"wf-editor-onboard-text",children:a("workflows.emptyDescription","Workflows orchestrate the steps and gates that run around task execution. Create one to start arranging that flow.")}),e.jsxs("button",{className:"wf-editor-save wf-editor-onboard-cta","data-testid":"wf-empty-create",onClick:()=>oe(!0),children:[e.jsx(ye,{size:14})," ",a("workflows.newWorkflow","New workflow")]})]})]}),ys&&!(b&&ne)&&!(ie&&!b)&&e.jsxs("aside",{className:"wf-editor-inspector","data-testid":"wf-node-inspector",children:[e.jsxs("div",{className:"wf-inspector-heading",children:[e.jsx("h3",{children:"Node"}),b&&e.jsxs("button",{type:"button",className:"wf-inspector-toggle wf-inspector-toggle--expanded","data-testid":"wf-inspector-toggle","aria-expanded":"true",onClick:()=>{H?S(null):le(!0)},children:[e.jsx(Ne,{size:13}),e.jsx("span",{children:a("workflowNodes.collapseInspector","Collapse")})]})]}),V&&e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:"Read-only built-in — duplicate the workflow to edit nodes."}),e.jsxs("fieldset",{className:"wf-inspector-fields",disabled:V,children:[m.data.kind!=="start"&&e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{value:m.data.label,onChange:t=>O({label:t.target.value})})]}),m.data.kind==="start"&&e.jsxs("div",{"data-testid":"wf-start-inspector",children:[e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.startNote","The start node marks where a task enters the workflow.")}),te.length>0&&e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.startEntryColumn","Entry column")}),e.jsxs("select",{"data-testid":"wf-start-entry-column",value:String(m.data.column??""),onChange:t=>O({column:t.target.value||void 0}),children:[e.jsx("option",{value:"",children:a("workflowNodes.startEntryColumnAuto","— Auto (first column)")}),te.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]})]})]}),m.data.kind==="prompt"||m.data.kind==="gate"?e.jsxs("div",{className:"wf-prompt-editor",children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Prompt"}),e.jsx("textarea",{rows:5,value:Es,readOnly:V,onChange:t=>O({config:{prompt:t.target.value}})})]}),e.jsx("button",{type:"button",className:"btn btn-sm wf-prompt-expand-btn wf-prompt-expand-btn--inline",onClick:Ss,"aria-label":a("workflowEditor.expandPrompt","Expand prompt editor"),title:a("workflowEditor.expandPrompt","Expand prompt editor"),children:e.jsx(pn,{size:14})})]}):null,e.jsxs("fieldset",{className:"wf-inspector-fields",disabled:V,children:[m.data.kind==="prompt"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Executor"}),e.jsxs("select",{value:pe,onChange:t=>O({config:{executor:t.target.value}}),children:[e.jsx("option",{value:"model",children:"Model"}),e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"skill",children:"Skill"}),e.jsx("option",{value:"cli",children:"CLI / script"}),e.jsx("option",{value:"cli-agent",children:a("workflowEditor.cliAgent.executorOption")})]})]}),Re&&e.jsx("p",{className:"wf-inspector-note wf-inspector-note--warn","data-testid":"wf-node-overridden-by-column-agent",children:a("workflowColumns.overriddenByColumnAgent","Overridden by column agent {{name}} — this node's executor settings are superseded.",{name:Ya?.name??a("workflowColumns.agentNotFound","Agent not found — {{id}}",{id:Re.agentId})})}),pe==="model"&&e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Model"}),e.jsx(Ut,{label:"Model",models:Ie,value:oa(String(m.data.config?.modelProvider??""),String(m.data.config?.modelId??"")),onChange:t=>{const{provider:n,modelId:l}=na(t);O({config:{modelProvider:n||void 0,modelId:l||void 0}})}})]}),pe==="agent"&&(()=>{const t=String(m.data.config?.agentId??""),n=t!==""&&!be.some(l=>l.id===t);return e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Agent"}),e.jsxs("select",{value:t,onChange:l=>O({config:{agentId:l.target.value||void 0}}),children:[e.jsx("option",{value:"",children:"— select agent —"}),n&&e.jsx("option",{value:t,children:a("workflowColumns.agentNotFound","Agent not found — {{id}}",{id:t})}),be.map(l=>e.jsx("option",{value:l.id,children:l.name},l.id))]}),n&&e.jsx("p",{className:"wf-inspector-note wf-inspector-note--warn","data-testid":"wf-node-agent-stale",children:a("workflowColumns.agentNotFound","Agent not found — {{id}}",{id:t})})]})})(),pe==="skill"&&e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Skill"}),e.jsxs("select",{value:String(m.data.config?.skillName??""),onChange:t=>O({config:{skillName:t.target.value||void 0}}),children:[e.jsx("option",{value:"",children:"— select skill —"}),Xe.map(t=>e.jsx("option",{value:t.name,children:t.name},t.id))]})]}),pe==="cli"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"CLI mode"}),e.jsxs("select",{value:String(m.data.config?.cliMode??"command"),onChange:t=>O({config:{cliMode:t.target.value}}),children:[e.jsx("option",{value:"command",children:"Command"}),e.jsx("option",{value:"script",children:"Named script"})]})]}),(m.data.config?.cliMode??"command")==="command"?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Command"}),e.jsx("textarea",{rows:3,placeholder:"npm test -- --runInBand",value:String(m.data.config?.cliCommand??""),onChange:t=>O({config:{cliCommand:t.target.value}})}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:"Runs an arbitrary command in the task worktree. The first time this exact command runs, the task pauses for your approval. The node prompt is passed via FUSION_NODE_PROMPT."}),e.jsxs("label",{className:"wf-field wf-field--checkbox",children:[e.jsx("input",{type:"checkbox",checked:m.data.config?.cliSkipApproval===!0,onChange:t=>O({config:{cliSkipApproval:t.target.checked}})}),e.jsx("span",{children:"Skip first-run approval (runs without pausing)"})]})]}):e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Script name"}),e.jsx("input",{value:String(m.data.config?.scriptName??""),onChange:t=>O({config:{scriptName:t.target.value}})}),e.jsx("span",{className:"wf-inspector-note",children:"Named script from project settings. The node prompt is passed via FUSION_NODE_PROMPT."})]})]}),pe==="cli-agent"&&e.jsxs("div",{"data-testid":"cli-agent-config",children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowEditor.cliAgent.adapterLabel")}),e.jsxs("select",{"data-testid":"cli-agent-adapter",value:String(m.data.config?.cliAdapterId??""),onChange:t=>O({config:{cliAdapterId:t.target.value||void 0}}),children:[e.jsx("option",{value:"",children:a("workflowEditor.cliAgent.adapterPlaceholder")}),Ga.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",a(`workflowEditor.cliAgent.tier.${t.tier}`),")"]},t.id))]}),e.jsx("span",{className:"wf-inspector-note",children:a("workflowEditor.cliAgent.adapterNote")})]}),e.jsxs("label",{className:"wf-field wf-field--checkbox",children:[e.jsx("input",{type:"checkbox","data-testid":"cli-agent-autonomy",checked:!!m.data.config?.cliAutonomy?.autoApprove,onChange:t=>O({config:{cliAutonomy:{...m.data.config?.cliAutonomy??{},autoApprove:t.target.checked}}})}),e.jsx("span",{children:a("workflowEditor.cliAgent.autonomyLabel")})]}),!!m.data.config?.cliAutonomy?.autoApprove&&e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowEditor.cliAgent.autonomyNote")}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowEditor.cliAgent.notifyLabel")}),e.jsxs("select",{"data-testid":"cli-agent-notify",value:String(m.data.config?.cliNotify?.mode??"banner"),onChange:t=>O({config:{cliNotify:{mode:t.target.value}}}),children:[e.jsx("option",{value:"banner",children:a("workflowEditor.cliAgent.notify.banner")}),e.jsx("option",{value:"banner+notify",children:a("workflowEditor.cliAgent.notify.bannerNotify")})]}),e.jsx("span",{className:"wf-inspector-note",children:a("workflowEditor.cliAgent.notifyNote")})]})]}),e.jsxs("label",{className:"wf-field wf-field--checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!m.data.config?.autoApprove,onChange:t=>O({config:{autoApprove:t.target.checked}})}),e.jsx("span",{children:"Auto-approve requests"})]}),!!m.data.config?.autoApprove&&e.jsx("p",{className:"wf-inspector-note",children:"Runs without pausing for approval — e.g. a CLI command executes on its first run without waiting for your sign-off."}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Max retries"}),e.jsx("input",{type:"number",min:1,max:10,placeholder:"default",value:m.data.config?.maxRetries!=null?String(m.data.config.maxRetries):"",onChange:t=>{const n=t.target.value.trim();if(n==="")O({config:l=>{const x={...l};return delete x.maxRetries,x}});else{const l=parseInt(n,10);isNaN(l)||O({config:{maxRetries:l}})}}})]}),e.jsxs("label",{className:"wf-field wf-field--checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!m.data.config?.awaitInput,onChange:t=>O({config:{awaitInput:t.target.checked}})}),e.jsx("span",{children:"Wait for user input"})]}),!!m.data.config?.awaitInput&&e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:"This node pauses the task until you reply in the task's comments and unpause. The Prompt field above is shown to the user as the question."})]}):null,m.data.kind==="script"?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:"Script name"}),e.jsx("input",{value:String(m.data.config?.scriptName??""),onChange:t=>O({config:{scriptName:t.target.value}})})]}):null,m.data.kind==="hold"?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.releaseCondition","Release condition")}),e.jsxs("select",{value:String(m.data.config?.release??"manual"),onChange:t=>O({config:{release:t.target.value}}),children:[e.jsx("option",{value:"manual",children:a("workflowNodes.releaseManual","Manual promote")}),e.jsx("option",{value:"timer",children:a("workflowNodes.releaseTimer","Timer")}),e.jsx("option",{value:"capacity",children:a("workflowNodes.releaseCapacity","Downstream capacity")}),e.jsx("option",{value:"dependency",children:a("workflowNodes.releaseDependency","Dependency complete")}),e.jsx("option",{value:"external-event",children:a("workflowNodes.releaseExternal","External event")})]})]}):null,m.data.kind==="join"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.joinMode","Join mode")}),e.jsxs("select",{value:(()=>{const t=m.data.config?.mode;return t&&typeof t=="object"&&"quorum"in t?"quorum":typeof t=="string"?t:"all"})(),onChange:t=>{const n=t.target.value;O(n==="quorum"?{config:{mode:{quorum:2}}}:{config:{mode:n}})},children:[e.jsx("option",{value:"all",children:a("workflowNodes.joinAll","All branches")}),e.jsx("option",{value:"any",children:a("workflowNodes.joinAny","Any branch")}),e.jsx("option",{value:"quorum",children:a("workflowNodes.joinQuorum","Quorum (n)")})]})]}),(()=>{const t=m.data.config?.mode;return t&&typeof t=="object"&&"quorum"in t})()&&e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.quorumN","Quorum count (n)")}),e.jsx("input",{type:"number",min:1,value:String(m.data.config?.mode?.quorum??2),onChange:t=>{const n=parseInt(t.target.value,10);isNaN(n)||O({config:{mode:{quorum:n}}})}})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.failurePolicy","On branch failure")}),e.jsxs("select",{value:String(m.data.config?.onBranchFailure??"collect"),onChange:t=>O({config:{onBranchFailure:t.target.value}}),children:[e.jsx("option",{value:"collect",children:a("workflowNodes.failureCollect","Collect (wait for all)")}),e.jsx("option",{value:"fail-fast",children:a("workflowNodes.failureFailFast","Fail-fast (cancel siblings)")})]})]})]}):null,m.data.kind==="split"?e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.splitNote","Branches run concurrently from this node. Execute and merge seams are not allowed inside a branch.")}):null,m.data.kind==="foreach"?(()=>{const t=String(m.data.config?.mode??"sequential"),n=t==="parallel";return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.foreachMode","Mode")}),e.jsxs("select",{value:t,onChange:l=>{const x=l.target.value;O({config:y=>({...y,mode:x,...x==="parallel"&&y.isolation==="shared"?{isolation:"worktree"}:{}})})},children:[e.jsx("option",{value:"sequential",children:a("workflowNodes.foreachSequential","Sequential")}),e.jsx("option",{value:"parallel",children:a("workflowNodes.foreachParallel","Parallel")})]})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.foreachIsolation","Isolation")}),e.jsxs("select",{value:String(m.data.config?.isolation??(n?"worktree":"shared")),onChange:l=>O({config:{isolation:l.target.value}}),children:[e.jsx("option",{value:"shared",disabled:n,children:a("workflowNodes.foreachShared","Shared worktree")}),e.jsx("option",{value:"worktree",children:a("workflowNodes.foreachWorktree","Per-step worktree")})]})]}),n&&e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.foreachConcurrency","Concurrency")}),e.jsx("input",{type:"number",min:1,max:8,placeholder:"2",value:m.data.config?.concurrency!=null?String(m.data.config.concurrency):"",onChange:l=>{const x=l.target.value.trim();if(x==="")O({config:y=>{const $={...y};return delete $.concurrency,$}});else{const y=parseInt(x,10);isNaN(y)||O({config:{concurrency:y}})}}})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.foreachMaxRework","Max rework cycles")}),e.jsx("input",{type:"number",min:1,max:10,placeholder:"3",value:m.data.config?.maxReworkCycles!=null?String(m.data.config.maxReworkCycles):"",onChange:l=>{const x=l.target.value.trim();if(x==="")O({config:y=>{const $={...y};return delete $.maxReworkCycles,$}});else{const y=parseInt(x,10);isNaN(y)||O({config:{maxReworkCycles:y}})}}})]}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.foreachNote","Expands once per planned step. Drop a step-execute node (and optional step-review) into the region.")})]})})():null,m.data.kind==="loop"?(()=>{const t=m.data.config?.exitWhen&&typeof m.data.config.exitWhen=="object"?m.data.config.exitWhen:{type:"output-contains",value:"DONE"},n=String(t.type??"output-contains"),l=String(n==="output-matches"?t.pattern??"":t.value??"");return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.loopExitType","Exit condition")}),e.jsxs("select",{value:n,onChange:x=>{const y=x.target.value;O({config:$=>{const M=$.exitWhen&&typeof $.exitWhen=="object"?$.exitWhen:{},U=String(y==="output-matches"?M.pattern??M.value??"":M.value??M.pattern??""),we={...M,type:y};return delete we.pattern,delete we.value,{...$,exitWhen:y==="output-matches"?{...we,pattern:U}:{...we,value:U}}}})},children:[e.jsx("option",{value:"output-contains",children:a("workflowNodes.loopOutputContains","Output contains")}),e.jsx("option",{value:"output-matches",children:a("workflowNodes.loopOutputMatches","Output matches regex")})]})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:n==="output-matches"?a("workflowNodes.loopPattern","Pattern"):a("workflowNodes.loopValue","Value")}),e.jsx("input",{value:l,placeholder:n==="output-matches"?"DONE|COMPLETE":"DONE",onChange:x=>{const y=x.target.value;O({config:$=>{const M=$.exitWhen&&typeof $.exitWhen=="object"?$.exitWhen:{};return{...$,exitWhen:n==="output-matches"?{...M,type:n,pattern:y}:{...M,type:n,value:y}}}})}})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.loopNodeId","Watch node id (optional)")}),e.jsx("input",{value:String(t.nodeId??""),placeholder:a("workflowNodes.loopNodeIdPlaceholder","Template exit node"),onChange:x=>{const y=x.target.value.trim();O({config:$=>{const U={...$.exitWhen&&typeof $.exitWhen=="object"?$.exitWhen:{type:"output-contains",value:"DONE"}};return y?U.nodeId=y:delete U.nodeId,{...$,exitWhen:U}}})}})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.loopMaxIterations","Max iterations")}),e.jsx("input",{type:"number",min:1,max:50,placeholder:"3",value:m.data.config?.maxIterations!=null?String(m.data.config.maxIterations):"",onChange:x=>{const y=x.target.value.trim();O({config:$=>{const M={...$};if(y==="")delete M.maxIterations;else{const U=parseInt(y,10);isNaN(U)||(M.maxIterations=U)}return M}})}})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.loopTimeoutMs","Timeout (ms)")}),e.jsx("input",{type:"number",min:1,max:36e5,placeholder:"300000",value:m.data.config?.timeoutMs!=null?String(m.data.config.timeoutMs):"",onChange:x=>{const y=x.target.value.trim();O({config:$=>{const M={...$};if(y==="")delete M.timeoutMs;else{const U=parseInt(y,10);isNaN(U)||(M.timeoutMs=U)}return M}})}})]}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.loopNote","Repeats the template until the selected output matches, an iteration limit is reached, or the timeout expires.")})]})})():null,m.data.kind==="step-review"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.reviewType","Review type")}),e.jsxs("select",{value:String(m.data.config?.type??"code"),onChange:t=>O({config:{type:t.target.value}}),children:[e.jsx("option",{value:"plan",children:a("workflowNodes.reviewPlan","Plan review")}),e.jsx("option",{value:"code",children:a("workflowNodes.reviewCode","Code review")})]})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.reviewModel","Review model (optional)")}),e.jsx(Ut,{label:a("workflowNodes.reviewModel","Review model (optional)"),models:Ie,value:oa(String(m.data.config?.modelProvider??""),String(m.data.config?.modelId??"")),onChange:t=>{const{provider:n,modelId:l}=na(t);O({config:{modelProvider:n||void 0,modelId:l||void 0,model:t||void 0}})}})]}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.reviewNote","Verdicts route as outcome edges. Click an outgoing edge to set its verdict and rework behavior.")})]}):null,m.data.kind==="parse-steps"?e.jsxs(e.Fragment,{children:[Pt.length>0?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.parseArtifact","Artifact")}),e.jsx("select",{value:String(m.data.config?.artifact??Pt[0]),onChange:t=>O({config:{artifact:t.target.value}}),children:Pt.map(t=>e.jsx("option",{value:t,children:t},t))})]}):e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.parseArtifact","Artifact")}),e.jsx("input",{placeholder:"PROMPT.md",value:String(m.data.config?.artifact??"PROMPT.md"),onChange:t=>O({config:{artifact:t.target.value}})})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.parseParser","Parser")}),e.jsx("select",{value:String(m.data.config?.parser??"step-headings"),onChange:t=>O({config:{parser:t.target.value}}),children:Array.from(new Set([String(m.data.config?.parser??"step-headings"),...va])).map(t=>e.jsx("option",{value:t,children:t},t))})]})]}):null,m.data.kind==="code"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.codeSource","Source (TypeScript)")}),e.jsx("textarea",{className:"wf-code-source",rows:8,spellCheck:!1,placeholder:'export default async (ctx) => ({ outcome: "success" });',value:String(m.data.config?.source??""),onChange:t=>O({config:{source:t.target.value}})})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.codeTimeout","Timeout (ms)")}),e.jsx("input",{type:"number",min:1,placeholder:"30000",value:m.data.config?.timeoutMs!=null?String(m.data.config.timeoutMs):"",onChange:t=>{const n=t.target.value.trim();if(n==="")O({config:l=>{const x={...l};return delete x.timeoutMs,x}});else{const l=parseInt(n,10);isNaN(l)||O({config:{timeoutMs:l}})}}})]}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.codeNote","Runs sandboxed TypeScript. Syntax is validated at save.")})]}):null,m.data.kind==="notify"?(()=>{const t=String(m.data.config?.event??"workflow-notify"),n=!ra.includes(t);return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.notifyEvent","Event type")}),e.jsxs("select",{value:n?qt:t,onChange:l=>{const x=l.target.value;O({config:{event:x===qt?"custom-event":x}})},children:[ra.map(l=>e.jsx("option",{value:l,children:l},l)),e.jsx("option",{value:qt,children:a("workflowNodes.notifyCustom","Custom")})]})]}),n?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.notifyCustomEvent","Custom event")}),e.jsx("input",{value:t,placeholder:"custom-event",onChange:l=>O({config:{event:l.target.value}})})]}):null,e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.notifyTitle","Title (optional)")}),e.jsx("input",{value:String(m.data.config?.title??"{{taskTitle}}"),placeholder:"{{taskTitle}}",onChange:l=>O({config:{title:l.target.value}})})]}),e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.notifyMessage","Message (optional)")}),e.jsx("textarea",{rows:4,value:String(m.data.config?.message??""),placeholder:"Task {{taskId}} reached {{workflowName}}",onChange:l=>O({config:{message:l.target.value}})})]}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.notifyNote","Templates may use {{taskTitle}}, {{taskId}}, {{workflowName}}, and {{context:key}}.")})]})})():null,m.data.kind==="prompt"||m.data.kind==="gate"||m.data.kind==="script"?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.gateMode","Gate mode")}),e.jsxs("select",{value:String(m.data.config?.gateMode??(m.data.kind==="prompt"?"advisory":"gate")),onChange:t=>O({config:{gateMode:t.target.value}}),children:[e.jsx("option",{value:"advisory",children:a("workflowNodes.advisory","Advisory")}),e.jsx("option",{value:"gate",children:a("workflowNodes.gateBlocks","Gate (blocks)")})]})]}):m.data.kind==="merge"?e.jsx("p",{className:"wf-inspector-note",children:a("workflowNodes.mergeBoundaryNote","Steps before this marker run pre-merge; steps after run post-merge.")}):null]}),!V&&e.jsxs("button",{type:"button",className:"wf-editor-delete wf-inspector-delete","data-testid":"wf-delete-node",onClick:()=>{ks([m.id]),S(null)},children:[e.jsx(ve,{size:13})," ",a("workflowNodes.deleteNode","Delete node")]})]}),xe&&e.jsxs("aside",{className:"wf-editor-inspector","data-testid":"wf-edge-inspector",children:[e.jsxs("div",{className:"wf-inspector-heading",children:[e.jsx("h3",{children:a("workflowNodes.edgeInspector","Edge")}),b&&e.jsxs("button",{type:"button",className:"wf-inspector-toggle wf-inspector-toggle--expanded","data-testid":"wf-edge-inspector-close","aria-expanded":"true",onClick:()=>B(null),children:[e.jsx(Ne,{size:13}),e.jsx("span",{children:a("workflowNodes.collapseInspector","Collapse")})]})]}),e.jsx("fieldset",{className:"wf-inspector-fields",disabled:V,children:Fs==="verdicts"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.edgeVerdict","Review verdict")}),e.jsxs("select",{"data-testid":"wf-edge-verdict",value:(()=>{const t=String(xe.data?.condition??"success");return t.startsWith("outcome:")?t.slice(8):""})(),onChange:t=>{const n=t.target.value;It({condition:n?`outcome:${n}`:"success"})},children:[e.jsx("option",{value:"",children:a("workflowNodes.edgeNoVerdict","— success (no verdict) —")}),ol.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{className:"wf-field wf-field--checkbox",children:[e.jsx("input",{type:"checkbox","data-testid":"wf-edge-rework",checked:xe.data?.kind==="rework",onChange:t=>It({rework:t.target.checked})}),e.jsx("span",{children:a("workflowNodes.edgeRework","Rework edge (loop back, bounded)")})]}),e.jsx("p",{className:"wf-inspector-note wf-inspector-note--info",children:a("workflowNodes.edgeReworkNote","Rework edges are the only legal cycles — they loop back within the for-each step instance, bounded by Max rework cycles.")})]}):Fs==="conditions"?e.jsxs("label",{className:"wf-field",children:[e.jsx("span",{children:a("workflowNodes.edgeCondition","Condition")}),e.jsxs("select",{"data-testid":"wf-edge-condition",value:String(xe.data?.condition??"success"),onChange:t=>It({condition:t.target.value}),children:[e.jsx("option",{value:"success",children:"success"}),e.jsx("option",{value:"failure",children:"failure"})]})]}):e.jsx("p",{className:"wf-inspector-note",children:a("workflowNodes.edgeConditionLabel","Condition: {{condition}}",{condition:String(xe.data?.condition??"success")})})}),!V&&e.jsxs("button",{type:"button",className:"wf-editor-delete wf-inspector-delete","data-testid":"wf-delete-edge",onClick:()=>{ks([xe.id]),B(null)},children:[e.jsx(ve,{size:13})," ",a("workflowNodes.deleteEdge","Delete edge")]})]})]}),Ce&&e.jsx(il,{workflows:u,onCreate:Wa,onDesign:Ba,onClose:Je})]})}),Xa]})}function hl({isOpen:s,onClose:d,addToast:r,projectId:w,initialPanel:i,initialAction:g,initialWorkflowId:I}){const u=o.useRef(null);return vo(u,s,"fusion:workflow-node-editor-size"),s?e.jsx(Za,{children:e.jsx(rl,{onClose:d,addToast:r,projectId:w,initialPanel:i,initialAction:g,initialWorkflowId:I,modalRef:u})}):null}export{hl as WorkflowNodeEditor};