agentix-cli 0.122.0 → 0.124.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 (120) hide show
  1. package/dist/{App-2D5W26LY.js → App-BUYK4EGC.js} +2 -2
  2. package/dist/{ChatApp-FZFZD2XY.js → ChatApp-ZS6EPDDK.js} +2 -2
  3. package/dist/{agent-PCRE3TRK.js → agent-W7UNXO6L.js} +2 -2
  4. package/dist/{board-dashboard-ZDJ4UDW4.js → board-dashboard-3AOENRSG.js} +292 -226
  5. package/dist/board-dashboard-3AOENRSG.js.map +1 -0
  6. package/dist/{chunk-XLCUHG3N.js → chunk-46ACP7A7.js} +71 -69
  7. package/dist/chunk-46ACP7A7.js.map +1 -0
  8. package/dist/{chunk-ZLUROC2Y.js → chunk-46JKX6CT.js} +17 -17
  9. package/dist/chunk-46JKX6CT.js.map +1 -0
  10. package/dist/{chunk-ZWZADDXV.js → chunk-5DFUUYEA.js} +2 -2
  11. package/dist/{chunk-NFS2VR3L.js → chunk-5RE2B5YQ.js} +2 -2
  12. package/dist/{chunk-NYAMY7EA.js → chunk-6GLJIA25.js} +2 -2
  13. package/dist/{chunk-5SLTRG66.js → chunk-6HKLRU62.js} +2 -2
  14. package/dist/{chunk-XBRVV4ZT.js → chunk-6PJ6XHG4.js} +2 -2
  15. package/dist/{chunk-54XX2LSW.js → chunk-AKLZ4YO2.js} +4 -4
  16. package/dist/{chunk-54XX2LSW.js.map → chunk-AKLZ4YO2.js.map} +1 -1
  17. package/dist/{chunk-TYFGL2YS.js → chunk-B3B7KEHJ.js} +2 -2
  18. package/dist/{chunk-EHKI2RKD.js → chunk-BN5QMNON.js} +2 -2
  19. package/dist/{chunk-2UDSIG5K.js → chunk-BSTIA4M6.js} +2 -2
  20. package/dist/{chunk-YCMO3KZ4.js → chunk-CY6ABHF2.js} +2 -2
  21. package/dist/{chunk-BRVQZC6P.js → chunk-FHBPKMCF.js} +2 -2
  22. package/dist/{chunk-C52IPIKJ.js → chunk-INLKJEEN.js} +2 -2
  23. package/dist/chunk-ITATBKUL.js +37 -0
  24. package/dist/chunk-ITATBKUL.js.map +1 -0
  25. package/dist/{chunk-DMPTCBX6.js → chunk-K5QUQNFE.js} +3 -3
  26. package/dist/chunk-K5QUQNFE.js.map +1 -0
  27. package/dist/{chunk-UVV6GUOG.js → chunk-PAM56O25.js} +257 -254
  28. package/dist/chunk-PAM56O25.js.map +1 -0
  29. package/dist/{chunk-SB7WMFJV.js → chunk-QQYXYJOG.js} +2 -2
  30. package/dist/{chunk-WJDFR3WE.js → chunk-VHT7HESZ.js} +2 -2
  31. package/dist/{chunk-QCPSGOSK.js → chunk-WEPON4FP.js} +2 -2
  32. package/dist/{chunk-XX6MLDTL.js → chunk-WMTGAVPW.js} +2 -2
  33. package/dist/{chunk-YUNMSLZN.js → chunk-YL4C63S2.js} +2 -2
  34. package/dist/{chunk-7ZGTRXWS.js → chunk-YSIRJZWF.js} +2 -2
  35. package/dist/cli.js +1 -1
  36. package/dist/{client-TFZEASIJ.js → client-PO5LDFS4.js} +2 -2
  37. package/dist/config-L2RQ6EJX.js +2 -0
  38. package/dist/config-mutator-44OAOZXM.js +2 -0
  39. package/dist/doctor-AU5TCOSG.js +2 -0
  40. package/dist/{editor-chat-4MLCP5D2.js → editor-chat-ELKNLXM6.js} +10 -3
  41. package/dist/{editor-chat-4MLCP5D2.js.map → editor-chat-ELKNLXM6.js.map} +1 -1
  42. package/dist/follow-up-tool-AIOLNUF7.js +6 -0
  43. package/dist/follow-up-tool-AIOLNUF7.js.map +1 -0
  44. package/dist/{grants-NGBKFONG.js → grants-HIFE6L5N.js} +2 -2
  45. package/dist/index.d.ts +80 -3
  46. package/dist/index.js +1 -1
  47. package/dist/{program-CGPPGRMR.js → program-EJWE7NVT.js} +221 -221
  48. package/dist/program-EJWE7NVT.js.map +1 -0
  49. package/dist/{promote-VTVIPRTC.js → promote-DPPNEINZ.js} +2 -2
  50. package/dist/push-bridge-325SXDGN.js +1 -1
  51. package/dist/{query-3CVDT2GZ.js → query-SLUOL6MQ.js} +2 -2
  52. package/dist/{registry-NOJMMWE3.js → registry-UBVBEEDW.js} +2 -2
  53. package/dist/{request-planner-E2Q5O66N.js → request-planner-2G73AJ4S.js} +2 -2
  54. package/dist/{review-candidates-I36HEYKX.js → review-candidates-S34UICQD.js} +2 -2
  55. package/dist/routing-K2LAUFRL.js +2 -0
  56. package/dist/schedule-tool-YRANRFHO.js +2 -0
  57. package/dist/scheduler-L4P4Z55R.js +2 -0
  58. package/dist/{seat-NGY2BMP6.js → seat-ZJT5T2NO.js} +2 -2
  59. package/dist/{select-X7VBGZ6X.js → select-Y23SKHCJ.js} +2 -2
  60. package/dist/{set-enabled-6NP63KCU.js → set-enabled-YWXWSKME.js} +2 -2
  61. package/dist/{tool-EZIILXYL.js → tool-5JTCSRTW.js} +2 -2
  62. package/dist/{tool-WKIF52OH.js → tool-FZEC5FQX.js} +2 -2
  63. package/dist/web/workflow-editor.global.js +1 -1
  64. package/dist/web/workflow-editor.global.js.map +1 -1
  65. package/dist/wiki-ZZ3MU5Y5.js +2 -0
  66. package/package.json +1 -1
  67. package/dist/board-dashboard-ZDJ4UDW4.js.map +0 -1
  68. package/dist/chunk-DMPTCBX6.js.map +0 -1
  69. package/dist/chunk-TLCURHW3.js +0 -28
  70. package/dist/chunk-TLCURHW3.js.map +0 -1
  71. package/dist/chunk-UVV6GUOG.js.map +0 -1
  72. package/dist/chunk-XLCUHG3N.js.map +0 -1
  73. package/dist/chunk-ZLUROC2Y.js.map +0 -1
  74. package/dist/config-IXCOAOPZ.js +0 -2
  75. package/dist/config-mutator-EPYIZVSG.js +0 -2
  76. package/dist/doctor-G5TM5GVF.js +0 -2
  77. package/dist/program-CGPPGRMR.js.map +0 -1
  78. package/dist/routing-KBUZON5R.js +0 -2
  79. package/dist/schedule-tool-GUHHYYTO.js +0 -2
  80. package/dist/scheduler-PGUELFMB.js +0 -2
  81. package/dist/wiki-7BFVMMNR.js +0 -2
  82. /package/dist/{App-2D5W26LY.js.map → App-BUYK4EGC.js.map} +0 -0
  83. /package/dist/{ChatApp-FZFZD2XY.js.map → ChatApp-ZS6EPDDK.js.map} +0 -0
  84. /package/dist/{agent-PCRE3TRK.js.map → agent-W7UNXO6L.js.map} +0 -0
  85. /package/dist/{chunk-ZWZADDXV.js.map → chunk-5DFUUYEA.js.map} +0 -0
  86. /package/dist/{chunk-NFS2VR3L.js.map → chunk-5RE2B5YQ.js.map} +0 -0
  87. /package/dist/{chunk-NYAMY7EA.js.map → chunk-6GLJIA25.js.map} +0 -0
  88. /package/dist/{chunk-5SLTRG66.js.map → chunk-6HKLRU62.js.map} +0 -0
  89. /package/dist/{chunk-XBRVV4ZT.js.map → chunk-6PJ6XHG4.js.map} +0 -0
  90. /package/dist/{chunk-TYFGL2YS.js.map → chunk-B3B7KEHJ.js.map} +0 -0
  91. /package/dist/{chunk-EHKI2RKD.js.map → chunk-BN5QMNON.js.map} +0 -0
  92. /package/dist/{chunk-2UDSIG5K.js.map → chunk-BSTIA4M6.js.map} +0 -0
  93. /package/dist/{chunk-YCMO3KZ4.js.map → chunk-CY6ABHF2.js.map} +0 -0
  94. /package/dist/{chunk-BRVQZC6P.js.map → chunk-FHBPKMCF.js.map} +0 -0
  95. /package/dist/{chunk-C52IPIKJ.js.map → chunk-INLKJEEN.js.map} +0 -0
  96. /package/dist/{chunk-SB7WMFJV.js.map → chunk-QQYXYJOG.js.map} +0 -0
  97. /package/dist/{chunk-WJDFR3WE.js.map → chunk-VHT7HESZ.js.map} +0 -0
  98. /package/dist/{chunk-QCPSGOSK.js.map → chunk-WEPON4FP.js.map} +0 -0
  99. /package/dist/{chunk-XX6MLDTL.js.map → chunk-WMTGAVPW.js.map} +0 -0
  100. /package/dist/{chunk-YUNMSLZN.js.map → chunk-YL4C63S2.js.map} +0 -0
  101. /package/dist/{chunk-7ZGTRXWS.js.map → chunk-YSIRJZWF.js.map} +0 -0
  102. /package/dist/{client-TFZEASIJ.js.map → client-PO5LDFS4.js.map} +0 -0
  103. /package/dist/{config-IXCOAOPZ.js.map → config-L2RQ6EJX.js.map} +0 -0
  104. /package/dist/{config-mutator-EPYIZVSG.js.map → config-mutator-44OAOZXM.js.map} +0 -0
  105. /package/dist/{doctor-G5TM5GVF.js.map → doctor-AU5TCOSG.js.map} +0 -0
  106. /package/dist/{grants-NGBKFONG.js.map → grants-HIFE6L5N.js.map} +0 -0
  107. /package/dist/{promote-VTVIPRTC.js.map → promote-DPPNEINZ.js.map} +0 -0
  108. /package/dist/{query-3CVDT2GZ.js.map → query-SLUOL6MQ.js.map} +0 -0
  109. /package/dist/{registry-NOJMMWE3.js.map → registry-UBVBEEDW.js.map} +0 -0
  110. /package/dist/{request-planner-E2Q5O66N.js.map → request-planner-2G73AJ4S.js.map} +0 -0
  111. /package/dist/{review-candidates-I36HEYKX.js.map → review-candidates-S34UICQD.js.map} +0 -0
  112. /package/dist/{routing-KBUZON5R.js.map → routing-K2LAUFRL.js.map} +0 -0
  113. /package/dist/{schedule-tool-GUHHYYTO.js.map → schedule-tool-YRANRFHO.js.map} +0 -0
  114. /package/dist/{scheduler-PGUELFMB.js.map → scheduler-L4P4Z55R.js.map} +0 -0
  115. /package/dist/{seat-NGY2BMP6.js.map → seat-ZJT5T2NO.js.map} +0 -0
  116. /package/dist/{select-X7VBGZ6X.js.map → select-Y23SKHCJ.js.map} +0 -0
  117. /package/dist/{set-enabled-6NP63KCU.js.map → set-enabled-YWXWSKME.js.map} +0 -0
  118. /package/dist/{tool-EZIILXYL.js.map → tool-5JTCSRTW.js.map} +0 -0
  119. /package/dist/{tool-WKIF52OH.js.map → tool-FZEC5FQX.js.map} +0 -0
  120. /package/dist/{wiki-7BFVMMNR.js.map → wiki-ZZ3MU5Y5.js.map} +0 -0
@@ -1338,7 +1338,7 @@ code, .mono {
1338
1338
  font-family: var(--ax-font);
1339
1339
  }
1340
1340
  #wfe-root code, #wfe-root .mono, #wfe-root pre { font-family: var(--ax-mono); }
1341
- `;var Pp=oe(tp(),1);var O=oe(Nt(),1);var Be=oe(Nt(),1);var v=oe(Ce(),1),D=({children:e,size:t=14,...n})=>(0,v.jsx)("svg",{viewBox:"0 0 16 16",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",...n,children:e}),A={gitlab:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M8 14L2 7l1.2-4.5L5 7h6l1.8-4.5L14 7z"})}),clock:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,v.jsx)("path",{d:"M8 5v3l2 1.5"})]}),hook:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M4 3v4a4 4 0 0 0 4 4h4"}),(0,v.jsx)("path",{d:"M10 9l2 2-2 2"})]}),play:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M5 3.5l7 4.5-7 4.5z",fill:"currentColor"})}),box:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"1.5"}),(0,v.jsx)("path",{d:"M2.5 6h11M6 2.5v11"})]}),branch:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"4",cy:"4",r:"1.5"}),(0,v.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,v.jsx)("circle",{cx:"12",cy:"4",r:"1.5"}),(0,v.jsx)("path",{d:"M4 5.5v3a2 2 0 0 0 2 2h4.5"}),(0,v.jsx)("path",{d:"M12 5.5v5"})]}),stop:()=>(0,v.jsx)(D,{children:(0,v.jsx)("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),msg:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M2.5 3.5h11v8h-6l-3 2.5v-2.5h-2z"})}),tag:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M8 2h5v5l-6 6-5-5z"}),(0,v.jsx)("circle",{cx:"10.5",cy:"5.5",r:.8,fill:"currentColor"})]}),bell:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M4 11V7a4 4 0 0 1 8 0v4l1 1.5H3zM6.5 13.5a1.5 1.5 0 0 0 3 0"})}),globe:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,v.jsx)("path",{d:"M2.5 8h11M8 2.5c2 2 2 9 0 11M8 2.5c-2 2-2 9 0 11"})]}),search:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"7",cy:"7",r:"4"}),(0,v.jsx)("path",{d:"M10 10l3.5 3.5"})]}),undo:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M4 7h6a3 3 0 0 1 0 6H7"}),(0,v.jsx)("path",{d:"M6.5 4.5L4 7l2.5 2.5"})]}),redo:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M12 7H6a3 3 0 0 0 0 6h3"}),(0,v.jsx)("path",{d:"M9.5 4.5L12 7 9.5 9.5"})]}),save:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M3 3h8l2 2v8H3z"}),(0,v.jsx)("path",{d:"M5 3v4h6V3M5 13v-4h6v4"})]}),run:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M5 3.5l7 4.5-7 4.5z",fill:"currentColor"})}),stop2:()=>(0,v.jsx)(D,{children:(0,v.jsx)("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1",fill:"currentColor"})}),sun:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"2.75"}),(0,v.jsx)("path",{d:"M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.5 3.5l1.4 1.4M11.1 11.1l1.4 1.4M3.5 12.5l1.4-1.4M11.1 4.9l1.4-1.4"})]}),moon:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M13 9.5A5.5 5.5 0 0 1 6.5 3 5.5 5.5 0 1 0 13 9.5z"})}),plus:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M8 3v10M3 8h10"})}),trash:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 4.5h10M6 4.5V3h4v1.5M4.5 4.5l.5 8h6l.5-8"})}),chev:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M4 6l4 4 4-4"})}),x:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M4 4l8 8M12 4l-8 8"})}),more:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"4",cy:"8",r:"1",fill:"currentColor",stroke:"none"}),(0,v.jsx)("circle",{cx:"8",cy:"8",r:"1",fill:"currentColor",stroke:"none"}),(0,v.jsx)("circle",{cx:"12",cy:"8",r:"1",fill:"currentColor",stroke:"none"})]}),check:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 8.5l3 3 7-7"})}),warn:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M8 2l6 11H2z"}),(0,v.jsx)("path",{d:"M8 6.5v3M8 11.2v.3"})]}),err:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,v.jsx)("path",{d:"M8 5v3.5M8 10.5v.3"})]}),zoomin:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"7",cy:"7",r:"4"}),(0,v.jsx)("path",{d:"M10 10l3.5 3.5M5 7h4M7 5v4"})]}),zoomout:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"7",cy:"7",r:"4"}),(0,v.jsx)("path",{d:"M10 10l3.5 3.5M5 7h4"})]}),fit:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M3 5V3h2M13 5V3h-2M3 11v2h2M13 11v2h-2"}),(0,v.jsx)("rect",{x:"6",y:"6",width:"4",height:"4",rx:.5})]}),minus:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 8h10"})}),kbd:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"1.5",y:"4",width:"13",height:"8",rx:"1.5"}),(0,v.jsx)("path",{d:"M4 7h.5M6 7h.5M8 7h.5M10 7h.5M4 10h7"})]}),lightning:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M9 2L3 9h4l-1 5 6-7H8z",fill:"currentColor",fillOpacity:.2})}),variable:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M4 3c-2 3-2 7 0 10M12 3c2 3 2 7 0 10"}),(0,v.jsx)("path",{d:"M6 7.5h.5l1 1 1-1h.5M6 10l1.5-1.5M9 10l-1.5-1.5"})]}),users:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"6",cy:"6",r:"2"}),(0,v.jsx)("path",{d:"M2.5 12c.5-2 2-3 3.5-3s3 1 3.5 3"}),(0,v.jsx)("circle",{cx:"11",cy:"5",r:"1.5"}),(0,v.jsx)("path",{d:"M10 10.5c.5-1 1.2-1.5 2-1.5 1 0 2 .8 2.3 2"})]}),grid:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2.5",y:"2.5",width:"4",height:"4"}),(0,v.jsx)("rect",{x:"9.5",y:"2.5",width:"4",height:"4"}),(0,v.jsx)("rect",{x:"2.5",y:"9.5",width:"4",height:"4"}),(0,v.jsx)("rect",{x:"9.5",y:"9.5",width:"4",height:"4"})]}),eye:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M1.5 8C3 5 5.3 3.5 8 3.5S13 5 14.5 8C13 11 10.7 12.5 8 12.5S3 11 1.5 8z"}),(0,v.jsx)("circle",{cx:"8",cy:"8",r:"1.8"})]}),slide:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2.5",y:"3.5",width:"11",height:"9",rx:"1"}),(0,v.jsx)("path",{d:"M5 6h6M5 8.5h4M5 11h5"})]}),gear:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"2"}),(0,v.jsx)("path",{d:"M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.5 3.5l1.4 1.4M11.1 11.1l1.4 1.4M3.5 12.5l1.4-1.4M11.1 4.9l1.4-1.4"})]}),flag:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 13V3h7l-1 2.5L10 8H3"})}),dup:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),(0,v.jsx)("path",{d:"M3 9V3h6"})]}),layout:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M2.5 3.5h11v9h-11z"}),(0,v.jsx)("path",{d:"M2.5 7h11M7 7v5.5"})]}),panelLeft:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,v.jsx)("path",{d:"M6 3v10"}),(0,v.jsx)("rect",{x:"2.5",y:"3.5",width:"3.5",height:"9",fill:"currentColor",fillOpacity:.18,stroke:"none"})]}),panelRight:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,v.jsx)("path",{d:"M10 3v10"}),(0,v.jsx)("rect",{x:"10",y:"3.5",width:"3.5",height:"9",fill:"currentColor",fillOpacity:.18,stroke:"none"})]})};var ls=[{section:"What starts it",items:[{id:"trigger.channel.whatsapp",type:"trigger.channel",label:"A WhatsApp message",hint:"Someone messages you on WhatsApp",glyph:"g-trigger",icon:"msg"},{id:"trigger.channel.telegram",type:"trigger.channel",label:"A Telegram message",hint:"Someone messages you on Telegram",glyph:"g-trigger",icon:"msg"},{id:"trigger.channel.gitlab",type:"trigger.channel",label:"Something on GitLab",hint:"An issue, merge request or pipeline changes",glyph:"g-trigger",icon:"gitlab"},{id:"trigger.hook.n8n",type:"trigger.hook",label:"n8n hands work over",hint:"n8n calls this workflow \u2014 it keeps the connectors, you keep the agents",glyph:"g-trigger",icon:"hook"},{id:"trigger.hook",type:"trigger.hook",label:"Something calls in",hint:"Any service that can POST a webhook",glyph:"g-trigger",icon:"hook"},{id:"trigger.cron",type:"trigger.cron",label:"A time of day",hint:"Runs on a schedule you set",glyph:"g-trigger",icon:"clock"},{id:"trigger.poll",type:"trigger.poll",label:"Something new shows up",hint:"Checks a command every so often; runs once per new item",glyph:"g-trigger",icon:"clock"},{id:"trigger.manual",type:"trigger.manual",label:"You start it",hint:"Only runs when you press run",glyph:"g-trigger",icon:"play"},{id:"trigger.form",type:"trigger.form",label:"Someone fills a form",hint:"A person submits a form to begin",glyph:"g-trigger",icon:"plus"}]},{section:"Put an agent on it",items:[{id:"node.agent",type:"agent",label:"Ask an agent",hint:"Give an agent the job, in your own words",glyph:"g-state",icon:"box"},{id:"node.transform",type:"transform",label:"Reshape the data",hint:"Build a value out of earlier steps",glyph:"g-state",icon:"variable"}]},{section:"Bring in a person",items:[{id:"node.userTask",type:"userTask",label:"Ask a person",hint:"Send someone a form and wait for their answer",glyph:"g-state",icon:"box"},{id:"node.checkpoint",type:"checkpoint",label:"Wait for approval",hint:"Hold here until someone says go",glyph:"g-branch",icon:"flag"},{id:"node.timer.boundary",type:"timer.boundary",label:"Wait a while",hint:"Pause for an hour, a day, however long",glyph:"g-branch",icon:"clock"}]},{section:"Decide what happens next",items:[{id:"node.classify",type:"classify",label:"Sort it into buckets",hint:"Pick one of your labels \u2014 and take the \u201Cnot sure\u201D path when it cannot tell",glyph:"g-branch",icon:"branch"},{id:"node.branch",type:"branch",label:"If this, then that",hint:"Send the run down one path or another",glyph:"g-branch",icon:"branch"},{id:"node.rule",type:"rule",label:"A table of rules",hint:"Several conditions at once; first match wins",glyph:"g-branch",icon:"branch"},{id:"node.gateway.parallel",type:"gateway.parallel",label:"Do several at once",hint:"Split into parallel paths, then join them",glyph:"g-branch",icon:"branch"},{id:"node.end",type:"end",label:"Finish",hint:"The run ends here",glyph:"g-end",icon:"stop"}]},{section:"Do something",items:[{id:"action.send",type:"action.send",label:"Send a message",hint:"Post to WhatsApp, Telegram, GitLab \u2014 anywhere you have a channel",glyph:"g-action",icon:"msg"},{id:"action.createIssue",type:"action.createIssue",label:"Open an issue",hint:"Create a new GitLab issue",glyph:"g-action",icon:"plus"},{id:"action.setLabel",type:"action.setLabel",label:"Change a label",hint:"Add or remove labels",glyph:"g-action",icon:"tag"},{id:"action.react",type:"action.react",label:"React to a message",hint:"Add an emoji reaction",glyph:"g-action",icon:"msg"},{id:"action.editMessage",type:"action.editMessage",label:"Edit a message",hint:"Change a message you already sent",glyph:"g-action",icon:"msg"},{id:"action.readLabel",type:"action.readLabel",label:"Read a label",hint:"Look at the labels on an issue before deciding",glyph:"g-action",icon:"tag"},{id:"action.callHTTP",type:"action.callHTTP",label:"Call a web address",hint:"Hand work to n8n, or any service with a URL",glyph:"g-action",icon:"globe"},{id:"action.builtin",type:"action.builtin",label:"Use a built-in step",hint:"Fetch a page, extract fields, and other bundled helpers",glyph:"g-action",icon:"lightning"},{id:"action.run",type:"action.run",label:"Run a saved action",hint:"Invoke something from your action registry",glyph:"g-action",icon:"lightning"},{id:"action.logTime",type:"action.logTime",label:"Log time spent",hint:"Record how long this took",glyph:"g-action",icon:"clock"}]},{section:"Talk to other workflows",items:[{id:"node.subProcess",type:"subProcess",label:"Run another workflow",hint:"Call one, and carry on when it finishes",glyph:"g-state",icon:"box"},{id:"node.signal.emit",type:"signal.emit",label:"Tell other workflows",hint:"Announce that something happened",glyph:"g-action",icon:"msg"},{id:"node.signal.wait",type:"signal.wait",label:"Wait to be told",hint:"Hold until another workflow announces it",glyph:"g-branch",icon:"flag"}]}],ss=[{group:"issue",items:[{path:"issue.title",type:"string"},{path:"issue.labels",type:"string[]"},{path:"issue.assignee",type:"string?"},{path:"issue.author",type:"string"},{path:"issue.body",type:"string"},{path:"issue.iid",type:"number"},{path:"issue.url",type:"string"}]},{group:"run",items:[{path:"run.id",type:"string"},{path:"run.state",type:"string"},{path:"run.workflow",type:"string"},{path:"run.homeNode",type:"string"}]},{group:"pipeline",items:[{path:"pipeline.status",type:"enum"},{path:"pipeline.ref",type:"string"},{path:"pipeline.id",type:"number"}]},{group:"state",items:[{path:"state.previous",type:"string?"},{path:"state.next",type:"string?"}]},{group:"env",items:[{path:"env.GITLAB_TOKEN",type:"secret (allowlist req.)"},{path:"env.GITLAB_HOST",type:"string (allowlist req.)"}]}],us=[{id:"tpl.gitlab",title:"GitLab issue lifecycle",hint:"Triage \u2192 Review \u2192 QA \u2192 Done \xB7 5 states",dots:3},{id:"tpl.mr",title:"MR review loop",hint:"Agent-driven 3-state review",dots:2},{id:"tpl.blank",title:"Blank canvas",hint:"Start from a single trigger",dots:1}],ip=[{id:"triage-agent",name:"Triage Agent",tags:["default"],color:200},{id:"dev-agent",name:"Dev Agent",tags:["default"],color:145},{id:"code-reviewer",name:"Code Reviewer",tags:["default"],color:28}];function ap(e){for(let t of ls){let n=t.items.find(r=>r.type===e);if(n)return n.label}return e}function lp(e,t){let n=o=>typeof t[o]=="string"?t[o].trim():"",r=(o,i=70)=>o.length>i?o.slice(0,i-1)+"\u2026":o;switch(e){case"trigger.channel":return n("source")?`when ${n("source")} has activity`:"";case"trigger.cron":return n("schedule")?`at ${n("schedule")}`:"";case"trigger.hook":return n("event")==="on:n8n"?"when n8n calls":n("event")?`on ${n("event")}`:"";case"trigger.poll":return n("actionId")?`new items from ${n("actionId")}`:"";case"trigger.form":return n("formId")?`form: ${n("formId")}`:"";case"agent":{let o=n("agentId")||n("agent"),i=n("prompt")||n("message");return[o&&`ask ${o}`,i&&r(i)].filter(Boolean).join(" \u2014 ")}case"action.send":return r(n("text")||n("body"))||n("channel")&&`to ${n("channel")}`;case"action.callHTTP":return r(n("url"));case"action.builtin":return n("name");case"action.run":return n("action")||n("name");case"action.createIssue":return r(n("title"));case"action.setLabel":return n("label")?`label: ${n("label")}`:"";case"subProcess":return n("workflowId")?`runs ${n("workflowId")}`:"";case"signal.emit":case"signal.wait":return n("signal")?`signal: ${n("signal")}`:"";case"timer.boundary":return n("duration")?`waits ${n("duration")}`:"";case"userTask":return n("assignTo")?`asks ${n("assignTo")}`:"";case"branch":{let o=Array.isArray(t.cases)?t.cases.length:0;return o?`${o} way${o===1?"":"s"} out`:""}default:return""}}var F=oe(Ce(),1),ch={trigger:220,state:240,branch:260,action:220,end:160,agent:240,checkpoint:220,transform:220},dh={trigger:46,state:118,branch:110,action:78,end:46,agent:118,checkpoint:92,transform:78};function up(e){return e.startsWith("trigger.")?"trigger":e.startsWith("action.")?"action":e}function nr(e){let t=up(e.type);return{w:ch[t]??220,h:dh[t]??100}}function rr(e){return e.position?.x??0}function or(e){return e.position?.y??0}function Ii(e,t){let{w:n,h:r}=nr(e),o=rr(e),i=or(e);return t==="in"?{x:o,y:i+r/2}:t==="out"?{x:o+n,y:i+r/2}:t==="true"?{x:o+n,y:i+r*.3}:t==="false"?{x:o+n,y:i+r*.7}:{x:o+n/2,y:i+r/2}}function sp(e,t){let n=Math.max(40,Math.abs(t.x-e.x)*.45);return`M ${e.x} ${e.y} C ${e.x+n} ${e.y}, ${t.x-n} ${t.y}, ${t.x} ${t.y}`}function ph(e){let{n:t,selected:n,state:r}=e,{w:o}=nr(t),i=up(t.type),a=lp(t.type,t.config??{}),u=t.config,s=i==="trigger"?u.source==="cron"?"clock":u.source==="webhook"||u.source==="hook"?"hook":u.source==="manual"?"play":"gitlab":i==="agent"?"box":i==="branch"?"branch":i==="action"?t.type==="action.send"?"msg":t.type==="action.setLabel"?"tag":t.type==="action.react"?"bell":t.type==="action.callHTTP"?"globe":t.type==="action.logTime"?"clock":t.type==="action.createIssue"?"plus":"lightning":i==="checkpoint"?"flag":i==="transform"?"variable":"stop",c=A[s]??A.box,d=["node",`t-${i}`,n&&"is-selected",r==="running"&&"is-running",r==="visited"&&"is-visited",r==="error"&&"is-error"].filter(Boolean).join(" "),p={left:rr(t),top:or(t),width:o},m=u.agentId,y=u.prompt;return(0,F.jsxs)("div",{className:d,style:p,onMouseDown:w=>e.onMouseDown?.(w,t),onClick:w=>e.onClick?.(w,t),onDoubleClick:w=>e.onDoubleClick?.(w,t),children:[(0,F.jsx)("div",{className:"node__stripe"}),(0,F.jsxs)("div",{className:"node__head",children:[(0,F.jsx)("div",{className:"node__icon",children:(0,F.jsx)(c,{})}),(0,F.jsxs)("div",{className:"node__meta",children:[(0,F.jsx)("div",{className:"node__kind",children:ap(t.type)}),(0,F.jsx)("div",{className:"node__name",children:t.id})]}),i!=="trigger"&&i!=="end"&&(0,F.jsx)("div",{className:"node__chev",children:(0,F.jsx)(A.more,{})})]}),a&&(0,F.jsx)("div",{className:"node__body",children:(0,F.jsx)("div",{className:"node__row node__row--summary",children:a})}),i!=="trigger"&&(0,F.jsx)("div",{className:"handle h-in",onMouseDown:w=>e.onPortDown?.(w,t,"in"),onMouseEnter:()=>e.onPortEnter?.(t,"in"),onMouseLeave:()=>e.onPortLeave?.()}),i==="branch"?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("div",{className:"handle h-true",onMouseDown:w=>e.onPortDown?.(w,t,"true"),onMouseEnter:()=>e.onPortEnter?.(t,"true"),onMouseLeave:()=>e.onPortLeave?.(),children:(0,F.jsx)("span",{className:"handle__label",children:"true"})}),(0,F.jsx)("div",{className:"handle h-false",onMouseDown:w=>e.onPortDown?.(w,t,"false"),onMouseEnter:()=>e.onPortEnter?.(t,"false"),onMouseLeave:()=>e.onPortLeave?.(),children:(0,F.jsx)("span",{className:"handle__label",children:"false"})})]}):i!=="end"&&(0,F.jsx)("div",{className:"handle h-out",onMouseDown:w=>e.onPortDown?.(w,t,"out"),onMouseEnter:()=>e.onPortEnter?.(t,"out"),onMouseLeave:()=>e.onPortLeave?.()})]})}function fh({nodes:e,viewBox:t,selection:n,hostRef:r}){let[o,i]=(0,Be.useState)(!1);if(!e.length)return null;let a=60,u=e.map(E=>rr(E)),s=e.map(E=>or(E)),c=e.map(E=>nr(E).w),d=e.map(E=>nr(E).h),p=Math.min(...u)-a,m=Math.min(...s)-a,y=Math.max(...u.map((E,K)=>E+c[K]))+a,w=Math.max(...s.map((E,K)=>E+d[K]))+a,S=y-p,H=w-m,g=r.current?.getBoundingClientRect(),f=g?.width??800,h=g?.height??500,x=-t.tx/t.zoom,C=-t.ty/t.zoom,P=f/t.zoom,M=h/t.zoom;return(0,F.jsxs)("div",{className:"cv__mini"+(o?" is-collapsed":""),children:[(0,F.jsxs)("div",{className:"cv__mini-head",children:[(0,F.jsx)("span",{children:"Map"}),(0,F.jsx)("button",{onClick:()=>i(!o),children:(0,F.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",children:(0,F.jsx)("path",{d:o?"M2 4l3 3 3-3":"M2 6l3-3 3 3",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"})})})]}),!o&&(0,F.jsxs)("svg",{viewBox:`${p} ${m} ${S} ${H}`,preserveAspectRatio:"xMidYMid meet",children:[(0,F.jsx)("rect",{className:"mini-view",x,y:C,width:P,height:M}),e.map(E=>{let K=nr(E),W=n?.kind==="node"&&n.id===E.id;return(0,F.jsx)("rect",{className:"mini-node"+(W?" sel":""),x:rr(E),y:or(E),width:K.w,height:K.h,rx:3},E.id)})]})]})}function cp(e){let{nodes:t,edges:n,selection:r,setSelection:o,onNodeMove:i,onAddNode:a,onConnect:u,runState:s,viewBox:c,setViewBox:d}=e,p=(0,Be.useRef)(null),[m,y]=(0,Be.useState)(null),[w,S]=(0,Be.useState)(null),[H,g]=(0,Be.useState)(!1),[f,h]=(0,Be.useState)(null),[x,C]=(0,Be.useState)(null),[P,M]=(0,Be.useState)(null),{zoom:E,tx:K,ty:W}=c,ve=(N,j)=>{let U=p.current;if(!U)return{x:0,y:0};let Y=U.getBoundingClientRect();return{x:(N-Y.left-K)/E,y:(j-Y.top-W)/E}},ir=N=>{let j=N.target;j!==N.currentTarget&&!j.classList.contains("cv__viewport")||N.button!==0&&N.button!==1||(o(null),C({startX:N.clientX,startY:N.clientY,tx:K,ty:W}))},Sn=(N,j)=>{if(N.target.classList.contains("handle"))return;N.stopPropagation(),o({kind:"node",id:j.id});let U=ve(N.clientX,N.clientY);y({id:j.id,offX:U.x-rr(j),offY:U.y-or(j)})},ar=(N,j,U)=>{N.stopPropagation(),N.preventDefault();let Y=Ii(j,U);S({from:{id:j.id,port:U},x:Y.x,y:Y.y})},ao=(N,j)=>{w&&h({id:N.id,port:j})},lr=()=>h(null);(0,Be.useEffect)(()=>{let N=U=>{if(m){let Y=ve(U.clientX,U.clientY);i(m.id,Y.x-m.offX,Y.y-m.offY)}else if(w){let Y=ve(U.clientX,U.clientY);S(q=>q&&{...q,x:Y.x,y:Y.y})}else x&&d(Y=>({...Y,tx:x.tx+(U.clientX-x.startX),ty:x.ty+(U.clientY-x.startY)}))},j=()=>{w&&f&&f.id!==w.from.id&&u({from:w.from.id,fromPort:w.from.port,to:f.id,toPort:"in"}),y(null),S(null),C(null),h(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",j)}},[m,w,x,f,u,i,d]);let at=N=>{if(!N.ctrlKey&&!N.metaKey&&Math.abs(N.deltaY)<30){d(Z=>({...Z,tx:Z.tx-N.deltaX,ty:Z.ty-N.deltaY}));return}N.preventDefault();let j=p.current;if(!j)return;let U=j.getBoundingClientRect(),Y=N.clientX-U.left,q=N.clientY-U.top,Ge=-N.deltaY*.0015;d(Z=>{let qe=Math.min(2,Math.max(.3,Z.zoom*(1+Ge))),ze=qe/Z.zoom;return{zoom:qe,tx:Y-(Y-Z.tx)*ze,ty:q-(q-Z.ty)*ze}})},lt=()=>d(N=>({...N,zoom:Math.min(2,N.zoom*1.15)})),Ai=()=>d(N=>({...N,zoom:Math.max(.3,N.zoom/1.15)})),Di=()=>{let N=p.current;if(!N||!t.length)return;let j=N.getBoundingClientRect(),U=60,Y=1/0,q=1/0,Ge=-1/0,Z=-1/0;t.forEach(st=>{let cr=nr(st),dr=rr(st),lo=or(st);Y=Math.min(Y,dr),q=Math.min(q,lo),Ge=Math.max(Ge,dr+cr.w),Z=Math.max(Z,lo+cr.h)});let qe=Ge-Y+U*2,ze=Z-q+U*2,ye=Math.min(1,Math.min(j.width/qe,j.height/ze));d({zoom:ye,tx:(j.width-qe*ye)/2-(Y-U)*ye,ty:(j.height-ze*ye)/2-(q-U)*ye})},sr=N=>{N.preventDefault(),g(!0)},Cn=()=>g(!1),ur=N=>{N.preventDefault(),g(!1);let j=N.dataTransfer.getData("application/x-wfe-item");if(j)try{let U=JSON.parse(j),Y=ve(N.clientX,N.clientY);a(U,Y.x-100,Y.y-40)}catch{}},ji=N=>{let j=N.id??"",U=["wfe-edge"];return r?.kind==="edge"&&r.id===j&&U.push("is-selected"),P===j&&U.push("is-hover"),s?.currentEdgeId===j&&U.push("is-running"),j&&s?.visitedEdges?.has(j)&&U.push("is-visited"),N.fromPort==="true"&&U.push("is-true"),N.fromPort==="false"&&U.push("is-false"),U.join(" ")},Ui=N=>s?.currentNodeId===N.id?"running":s?.visitedNodes?.has(N.id)?"visited":null,Wi=(0,Be.useMemo)(()=>{if(!w)return null;let N=t.find(Y=>Y.id===w.from.id);if(!N)return null;let j=Ii(N,w.from.port),U={x:w.x,y:w.y};return(0,F.jsx)("svg",{className:"cv__ghost-edge",width:"4000",height:"2400",children:(0,F.jsx)("path",{d:sp(j,U)})})},[w,t]);return(0,F.jsxs)("div",{className:"cv"+(x?" is-panning":"")+(H?" is-drop-target":""),ref:p,onWheel:at,onMouseDown:ir,onDragOver:sr,onDragLeave:Cn,onDrop:ur,children:[(0,F.jsxs)("div",{className:"cv__viewport",style:{transform:`translate(${K}px, ${W}px) scale(${E})`},children:[(0,F.jsxs)("svg",{className:"cv__edges",width:"4000",height:"2400",children:[(0,F.jsxs)("defs",{children:[(0,F.jsx)("marker",{id:"arr",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"currentColor"})}),(0,F.jsx)("marker",{id:"arr-ok",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"var(--ok)"})}),(0,F.jsx)("marker",{id:"arr-err",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"var(--err)"})}),(0,F.jsx)("marker",{id:"arr-acc",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"var(--accent)"})})]}),n.map((N,j)=>{let U=t.find(st=>st.id===N.from),Y=t.find(st=>st.id===N.to);if(!U||!Y)return null;let q=N.id??`e-${j}`,Ge=Ii(U,N.fromPort??"out"),Z=Ii(Y,N.toPort??"in"),qe=sp(Ge,Z),ze={x:(Ge.x+Z.x)/2,y:(Ge.y+Z.y)/2},ye=s?.currentEdgeId===q||s?.visitedEdges?.has(q)?"url(#arr-acc)":N.fromPort==="true"?"url(#arr-ok)":N.fromPort==="false"?"url(#arr-err)":"url(#arr)";return(0,F.jsxs)("g",{children:[(0,F.jsx)("path",{className:"edge-bg",d:qe,onMouseEnter:()=>M(q),onMouseLeave:()=>M(null),onClick:()=>o({kind:"edge",id:q})}),(0,F.jsx)("path",{className:ji(N),d:qe,markerEnd:ye}),N.label&&(0,F.jsxs)("g",{transform:`translate(${ze.x},${ze.y})`,children:[(0,F.jsx)("rect",{className:"edge-label-bg",x:-N.label.length*3.6-6,y:-9,rx:3,width:N.label.length*7.2+12,height:18}),(0,F.jsx)("text",{className:"edge-label",y:4,textAnchor:"middle",children:N.label})]})]},q)})]}),Wi,t.map(N=>(0,F.jsx)(ph,{n:N,selected:r?.kind==="node"&&r.id===N.id,state:Ui(N),onMouseDown:Sn,onPortDown:ar,onPortEnter:ao,onPortLeave:lr,onClick:(j,U)=>{j.stopPropagation(),o({kind:"node",id:U.id})}},N.id))]}),(0,F.jsxs)("div",{className:"cv__controls",children:[(0,F.jsx)("button",{title:"Zoom out",onClick:Ai,children:(0,F.jsx)(A.zoomout,{})}),(0,F.jsxs)("div",{className:"cv__zoom",children:[Math.round(E*100),"%"]}),(0,F.jsx)("button",{title:"Zoom in",onClick:lt,children:(0,F.jsx)(A.zoomin,{})}),(0,F.jsx)("button",{title:"Fit",onClick:Di,children:(0,F.jsx)(A.fit,{})})]}),(0,F.jsx)(fh,{nodes:t,viewBox:c,selection:r,hostRef:p})]})}var ne=oe(Nt(),1);var gh=[{path:"channel",type:"string",description:"Channel name that received the event.",example:'"whatsapp"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"chatId",type:"string",description:"Stable chat id \u2014 conversation partner JID (WhatsApp) or chat integer (Telegram). Use as `action.send` chatId to reply on the same thread.",example:'"10000000000@s.whatsapp.net"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"accountId",type:"string",description:"Which bot account received the message. Telegram routes this per-account; inherit into `action.send` to reply through the same bot.",example:'"default"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"text",type:"string",description:"Message body (caption for media), lower-cased for routing but the raw text here is verbatim.",example:'"hello"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"fromJid",type:"string",description:"Raw sender JID/id straight from the platform. Use `sender.id` for the normalized form.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"sender.id",type:"string",description:"Normalized sender id.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"sender.name",type:"string",description:"Display name, e.g. WhatsApp pushName or Telegram first_name.",example:'"Alex"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"sender.username",type:"string",description:"Platform-specific handle when available (Telegram @username, ...).",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"group.id",type:"string",description:"Group chat id when the message came from a group; undefined for DMs.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"group.name",type:"string",description:"Group display name when available.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"replyTo",type:"string",description:"ID of the message this one quoted, when any.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"replyToText",type:"string",description:"Text of the quoted message when available.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"media.path",type:"string",description:"Filesystem path of the attached media after download.",sourceFilter:["whatsapp-message","telegram-message"]},{path:"media.type",type:"string",description:"MIME type of the media (`image/jpeg`, `audio/ogg`, ...).",sourceFilter:["whatsapp-message","telegram-message"]},{path:"event.id",type:"string",description:"Platform message id. Use as `action.send` replyTo to thread replies.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"event.timestamp",type:"string",description:"ISO-8601 timestamp of the source message.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"issue.iid",type:"number",description:"GitLab internal issue id (per project).",example:"42",sourceFilter:["gitlab-issue"]},{path:"issue.title",type:"string",description:"Issue title.",sourceFilter:["gitlab-issue"]},{path:"issue.description",type:"string",description:"Issue description body.",sourceFilter:["gitlab-issue"]},{path:"issue.url",type:"string",description:"Web URL of the issue.",sourceFilter:["gitlab-issue"]},{path:"issue.action",type:"string",description:"Action that triggered the event (`open`, `update`, `close`, ...).",sourceFilter:["gitlab-issue"]},{path:"issue.labels",type:"array",description:"Current labels on the issue.",sourceFilter:["gitlab-issue"]},{path:"issue.assignees",type:"array",description:"Assignees on the issue.",sourceFilter:["gitlab-issue"]},{path:"project",type:"string",description:"GitLab project path.",example:'"acme/web"',sourceFilter:["gitlab-issue","gitlab-pipeline"]},{path:"chatId",type:"string",description:'Stable entity id for GitLab: "<project>:issue:<iid>" (issue) or "<project>:merge_request:<iid>" (pipeline).',sourceFilter:["gitlab-issue","gitlab-pipeline"]},{path:"channel",type:"string",description:'Always `"gitlab"` for GitLab sources.',sourceFilter:["gitlab-issue","gitlab-pipeline"]},{path:"pipeline.id",type:"number",description:"Pipeline id.",sourceFilter:["gitlab-pipeline"]},{path:"pipeline.status",type:"string",description:"Pipeline status (`success`, `failed`, `canceled`, ...).",sourceFilter:["gitlab-pipeline"]},{path:"pipeline.ref",type:"string",description:"Git ref the pipeline ran on.",sourceFilter:["gitlab-pipeline"]}],hh=[{path:"reply",type:"string",description:"Full agent response text. Most common template target (e.g. echoing it back via `action.send`).",example:'"Got it \u2014 routing to..."'},{path:"result",type:"string",description:"Parsed `RESULT: <token>` marker from the agent's reply (lowercased), or `approved`/`rejected`/`done`/`failed` from a `[BRACKET]`. Used by `branch` nodes to route on agent classification.",example:'"approved"'},{path:"json",type:"any",description:"When `resultParser` is `json`, the parsed first fenced ```json ... ``` block. Useful for structured agent outputs."},{path:"taskId",type:"string",description:"Opaque workflow-scoped task id \u2014 mostly for diagnostics.",example:'"wf-<runId>-<suffix>"'},{path:"durationMs",type:"number",description:"Wall-clock duration of the agent call.",example:"14520"}],mh=[{path:"messageId",type:"string",description:"Platform message id of the sent message. `null` when the adapter couldn't capture it (e.g. mesh-forwarded sends may return null)."},{path:"viaMesh",type:"bool",description:"`true` when the send was forwarded over the mesh to a peer that hosts the channel (workflow on one node, channel adapter on another). Absent for local sends."}],vh=[{path:"issue.iid",type:"number",description:"Newly-created issue iid.",example:"123"},{path:"issue.url",type:"string",description:"Web URL of the new issue."},{path:"issue.webUrl",type:"string",description:"Alias of `issue.url`."}],yh=[{path:"labels",type:"array",description:"Label list after the change."},{path:"add",type:"array",description:"Labels that were added in this call."},{path:"remove",type:"array",description:"Labels that were removed in this call."}],wh=[{path:"labels",type:"array",description:"Current label list on the entity. Use with a `branch` node to route on label state."}],xh=[{path:"emoji",type:"string",description:"The emoji reaction that was applied (echoes the input for debugging)."}],kh=[{path:"edited",type:"bool",description:"`true` when the platform accepted the edit. Treat `false` as a soft miss \u2014 text may have been unchanged or the message was too old."}],bh=[{path:"durationMs",type:"number",description:"Duration logged, in milliseconds (echoed for downstream use)."}],_h=[{path:"ok",type:"bool",description:"Response.ok \u2014 `true` for 2xx."},{path:"status",type:"number",description:"HTTP status code.",example:"200"},{path:"body",type:"any",description:"Parsed JSON body when the response was JSON; otherwise the raw text string."}],Sh=[{path:"ok",type:"bool",description:"`true` when the action exited 0 (shell) or returned 2xx (http)."},{path:"status",type:"number",description:"Exit code (shell) or HTTP status (http)."},{path:"output",type:"string",description:"stdout (shell) or response body text (http). Capped at 32KB."},{path:"errors",type:"string",description:"stderr (shell) or transport error (http). Empty when none."},{path:"durationMs",type:"number",description:"Wall time of the invocation, in milliseconds."}],Ch=[{path:"*",type:"any",description:"The built-in's typed response. Shape depends on the action \u2014 e.g. http.fetch returns {status, statusText, headers, body, truncated, url}; mesh.delegate returns {peer, agent, response}; extract.structured returns {data, model, usage}. See GET /api/actions/builtin for each action's schema."}],Nh=[{path:"port",type:"string",description:"Which outgoing port matched. Downstream edges with `fromPort` matching this value will fire."}],Eh=[{path:"label",type:"string",description:"The label chosen. Also the port that fires.",example:'"bug"'},{path:"result",type:"string",description:"Alias of `label`, so a workflow migrating off an `agent` + RESULT-token node keeps its existing {{node.result}} references working.",example:'"bug"'},{path:"confidence",type:"number",description:"How peaked the distribution was, 0-1. Compare against the node's minConfidence.",example:"0.93"},{path:"probabilities",type:"object",description:"The full distribution over labels \u2014 every label with its probability.",example:'{"bug":0.93,"feature":0.05,"question":0.02}'},{path:"unsure",type:"bool",description:"True when confidence fell below minConfidence and the `unsure` port fired instead of a label port.",example:"false"},{path:"port",type:"string",description:"The port that fired: the chosen label, or `unsure`.",example:'"bug"'}],Th=[{path:"value",type:"any",description:"When config uses `path`, this carries the value picked from context. In `template` mode, keys from the rendered template land at the top level of this node's output (no `.value` prefix)."}],Ph=[{path:"event",type:"any",description:"Payload of the event that resumed this checkpoint. Fields mirror whichever trigger source delivered the resume event."}],Fh=[{path:"name",type:"string",description:"Name of the signal that resumed the wait."},{path:"payload",type:"any",description:"Payload the emitter attached to the signal."},{path:"receivedAt",type:"string",description:"ISO-8601 time the signal was observed."}],Mh=[{path:"emittedAt",type:"string",description:"ISO-8601 time the signal was published."}],Ih=[{path:"firedAt",type:"string",description:"ISO-8601 time the timer elapsed (when resumed)."},{path:"scheduledFor",type:"string",description:"ISO-8601 time the timer was originally scheduled for."}],Rh=[{path:"childRunId",type:"string",description:"Run id of the spawned child workflow."},{path:"result",type:"any",description:"Output bundle of the child's terminal `end` node (if any)."}],cs={"trigger.channel":{summary:"Raw event payload from the source channel. Shape varies by `source` \u2014 the Context panel filters accordingly.",fields:gh},"trigger.manual":{summary:"Arbitrary payload posted by `agentx workflow run <id>` / POST /workflows/:id/run.",fields:[{path:"",type:"any",description:"Whatever JSON the caller supplied."}]},"trigger.cron":{summary:"Scheduled tick \u2014 no data bundle beyond the firing metadata.",fields:[{path:"firedAt",type:"string",description:"ISO-8601 time the tick fired."},{path:"cronSpec",type:"string",description:"The `spec` from the node's config (echoed for debug)."}]},"trigger.hook":{summary:"Fires when a custom hook event bubbles through the registry. Payload is whatever the hook subscriber chose to emit.",fields:[{path:"",type:"any",description:"Hook-specific payload."}]},"trigger.form":{summary:"Starts when a published form receives a submission.",fields:[{path:"formId",type:"string",description:"Form id that received the submission."},{path:"submission",type:"object",description:"Submitted values keyed by field id."},{path:"submittedBy",type:"string",description:"Actor id of the submitter."}]},"trigger.poll":{summary:"Runs a registered action on an interval and starts one run per new item it prints (one JSON object per line). The item is the payload.",fields:[{path:"",type:"any",description:"The item's own fields, e.g. `{{trigger.msgId}}`, `{{trigger.text}}`. Whatever the poll command printed for this item."}]},agent:{summary:"Agent response after executing the prompt template.",fields:hh},classify:{summary:"A typed classification with a full probability distribution. Branches on its own result: the port named after the winning label fires, or `unsure` when nothing clears minConfidence.",fields:Eh},transform:{summary:"Value picked from upstream context (path mode) or rendered template bundle (template mode).",fields:Th},branch:{summary:"Which outgoing port fired. Downstream edges match via `fromPort`.",fields:Nh},"gateway.parallel":{summary:"All incoming branches joined here. No output.",fields:[]},rule:{summary:"Evaluates a declarative rule against context; may short-circuit the walk.",fields:[]},"action.send":{summary:"Dispatched an outbound message through the chosen channel.",fields:mh},"action.createIssue":{summary:"Created an issue on GitLab/GitHub.",fields:vh},"action.setLabel":{summary:"Added/removed labels on a GitLab issue or MR.",fields:yh},"action.readLabel":{summary:"Fetched the current label list \u2014 useful before a `branch`.",fields:wh},"action.react":{summary:"Emoji reaction on a message (Telegram/WhatsApp).",fields:xh},"action.editMessage":{summary:"Edited an existing message in place.",fields:kh},"action.logTime":{summary:"Logged time spent on a GitLab issue/MR.",fields:bh},"action.callHTTP":{summary:"Made an outbound HTTP request with templated params.",fields:_h},"action.run":{summary:"Invoked a registered action from the action registry. Output is the full ActionRunResult.",fields:Sh},"action.builtin":{summary:"Invoked a daemon-shipped typed built-in action (improvement plan #6) by name. Output is the built-in's validated response.",fields:Ch},subProcess:{summary:"Spawned a child workflow and waited for its completion.",fields:Rh},"signal.emit":{summary:"Published a signal to the bus. Runs elsewhere can resume on it via `signal.wait`.",fields:Mh},"signal.wait":{summary:"Paused until a matching signal arrives. Resumes with that signal in this node's output.",fields:Fh},"timer.boundary":{summary:"Paused until a timer elapses. Resumes with timing metadata.",fields:Ih},checkpoint:{summary:"Paused until a matching resume event arrives on this entity.",fields:Ph},end:{summary:"Terminal node \u2014 closes the run with the configured status. No output downstream.",fields:[]}};function dp(e,t={}){let n=cs[e];if(!n)return[];let r=typeof t.source=="string"?t.source:void 0;return r?n.fields.filter(o=>!o.sourceFilter||o.sourceFilter.includes(r)):n.fields.filter(o=>!o.sourceFilter)}var l=oe(Ce(),1);function L({title:e,children:t,defaultOpen:n=!0,right:r}){let[o,i]=(0,ne.useState)(n);return(0,l.jsxs)("div",{className:"insp__section"+(o?"":" is-collapsed"),children:[(0,l.jsxs)("div",{className:"insp__section-head",onClick:()=>i(!o),children:[(0,l.jsx)("span",{className:"chev",children:(0,l.jsx)(A.chev,{})}),(0,l.jsx)("h4",{children:e}),r]}),(0,l.jsx)("div",{className:"insp__section-body",children:t})]})}function k({label:e,hint:t,err:n,children:r,mono:o}){return(0,l.jsxs)("div",{className:"fld"+(o?" is-mono":"")+(n?" is-err":""),children:[(0,l.jsxs)("div",{className:"fld__label",children:[(0,l.jsx)("span",{children:e}),t&&(0,l.jsx)("span",{className:"fld__hint",children:t})]}),r,n&&(0,l.jsxs)("div",{className:"fld__err",children:[(0,l.jsx)(A.err,{}),n]})]})}function R({value:e,onChange:t,placeholder:n,mono:r,list:o}){return(0,l.jsx)("input",{className:"fld__input"+(r?" mono":""),type:"text",value:e,placeholder:n,list:o,onChange:i=>t(i.target.value)})}function on({value:e,onChange:t,placeholder:n}){return(0,l.jsx)("input",{className:"fld__input",type:"number",value:e??"",placeholder:n,onChange:r=>{let o=r.target.value.trim();t(o===""?void 0:Number(o))}})}function Ri({value:e,onChange:t,rows:n=3,placeholder:r,mono:o}){return(0,l.jsx)("textarea",{className:"fld__input"+(o?" mono":""),rows:n,spellCheck:!1,value:e,placeholder:r,onChange:i=>t(i.target.value)})}function ue({value:e,onChange:t,options:n}){return(0,l.jsx)("select",{className:"fld__select",value:e,onChange:r=>t(r.target.value),children:n.map(r=>{let o=typeof r=="string"?r:r.value,i=typeof r=="string"?r:r.label;return(0,l.jsx)("option",{value:o,children:i},o)})})}function Li({checked:e,onChange:t,label:n}){return(0,l.jsxs)("label",{className:"fld__check",style:{display:"flex",gap:8,alignItems:"center",fontSize:12},children:[(0,l.jsx)("input",{type:"checkbox",checked:e,onChange:r=>t(r.target.checked)}),(0,l.jsx)("span",{children:n})]})}function vt({value:e,onChange:t,placeholder:n,mono:r}){return(0,l.jsx)("input",{className:"fld__input"+(r?" mono":""),type:"text",value:e.join(", "),placeholder:n,onChange:o=>t(o.target.value.split(",").map(i=>i.trim()).filter(Boolean))})}function Lh(e){return typeof e=="boolean"?"boolean":typeof e=="number"?"number":Array.isArray(e)?"list":e&&typeof e=="object"?"json":"string"}function bn({value:e,onChange:t,keyPlaceholder:n="key",valuePlaceholder:r="value",allowedTypes:o=["string","number","boolean","list","json"],emptyHint:i}){let a=Object.entries(e||{}),u=s=>{let c={};for(let[d,p]of s)d&&(c[d]=p);t(c)};return(0,l.jsxs)("div",{className:"kv-editor",children:[a.length===0&&i&&(0,l.jsx)("div",{className:"kv-editor__empty",children:i}),a.map(([s,c],d)=>(0,l.jsx)(Oh,{k:s,v:c,allowedTypes:o,keyPlaceholder:n,valuePlaceholder:r,onKey:p=>{let m=a.slice();m[d]=[p,m[d][1]],u(m)},onValue:p=>{let m=a.slice();m[d]=[m[d][0],p],u(m)},onRemove:()=>{let p=a.slice();p.splice(d,1),u(p)}},d)),(0,l.jsx)("button",{type:"button",className:"kv-editor__add",onClick:()=>u([...a,["",""]]),children:"+ Add field"})]})}function Oh({k:e,v:t,allowedTypes:n,keyPlaceholder:r,valuePlaceholder:o,onKey:i,onValue:a,onRemove:u}){let[s,c]=(0,ne.useState)(Lh(t)),d=p=>{c(p),a(p==="boolean"?typeof t=="boolean"?t:!1:p==="number"?typeof t=="number"?t:Number(t)||0:p==="list"?Array.isArray(t)?t:typeof t=="string"&&t?t.split(",").map(m=>m.trim()):[]:p==="json"?typeof t=="object"&&t&&!Array.isArray(t)?t:{}:typeof t=="string"?t:String(t??""))};return(0,l.jsxs)("div",{className:"kv-editor__row",children:[(0,l.jsx)("input",{className:"fld__input mono kv-editor__key",type:"text",value:e,placeholder:r,onChange:p=>i(p.target.value)}),n.length>1&&(0,l.jsx)("select",{className:"fld__input kv-editor__type",value:s,onChange:p=>d(p.target.value),children:n.map(p=>(0,l.jsx)("option",{value:p,children:p},p))}),(0,l.jsxs)("div",{className:"kv-editor__val",children:[s==="string"&&(0,l.jsx)(kn,{rows:1,value:typeof t=="string"?t:"",onChange:p=>a(p),placeholder:o}),s==="number"&&(0,l.jsx)("input",{className:"fld__input",type:"number",value:typeof t=="number"?String(t):"",onChange:p=>a(p.target.value===""?0:Number(p.target.value))}),s==="boolean"&&(0,l.jsx)(Li,{checked:!!t,onChange:p=>a(p),label:String(!!t)}),s==="list"&&(0,l.jsx)(vt,{value:Array.isArray(t)?t.map(String):[],onChange:p=>a(p),placeholder:"comma,separated,values"}),s==="json"&&(0,l.jsx)("textarea",{className:"fld__input mono kv-editor__json",rows:2,value:JSON.stringify(t??{},null,2),onChange:p=>{try{a(JSON.parse(p.target.value))}catch{}}})]}),(0,l.jsx)("button",{type:"button",className:"kv-editor__remove",onClick:u,title:"Remove field",children:"\xD7"})]})}function kn({value:e,onChange:t,placeholder:n,rows:r=3}){let[o,i]=(0,ne.useState)(!1),[a,u]=(0,ne.useState)(0),s=(0,ne.useRef)(null),c=(0,ne.useMemo)(()=>{let m=[];return ss.forEach(y=>y.items.forEach(w=>m.push({group:y.group,...w}))),m},[]),d=m=>{let y=s.current;if(!y)return;let w=y.selectionStart,S=e.slice(0,w),H=e.slice(w),f=S.endsWith("{{")?S:S+"{{",h=f+m+"}}"+H;t(h),i(!1),requestAnimationFrame(()=>{y.focus();let x=f.length+m.length+2;y.setSelectionRange(x,x)})};return(0,l.jsxs)("div",{className:"expr",style:{position:"relative"},children:[(0,l.jsx)("textarea",{ref:s,className:"fld__input mono",rows:r,spellCheck:!1,value:e,placeholder:n,onChange:m=>t(m.target.value),onKeyDown:m=>{if(!o){m.key==="{"&&m.shiftKey&&i(!0);return}m.key==="ArrowDown"?(m.preventDefault(),u(y=>(y+1)%c.length)):m.key==="ArrowUp"?(m.preventDefault(),u(y=>(y-1+c.length)%c.length)):m.key==="Enter"||m.key==="Tab"?(m.preventDefault(),d(c[a].path)):m.key==="Escape"&&i(!1)}}),(0,l.jsxs)("div",{className:"fld__hint",style:{display:"flex",alignItems:"center",gap:6,marginTop:4},children:[(0,l.jsx)(A.variable,{}),"Type ",(0,l.jsx)("code",{children:"{{"})," to insert a variable \xB7 ",(0,l.jsx)("kbd",{children:"\u2191\u2193"})," ",(0,l.jsx)("kbd",{children:"\u21B5"}),(0,l.jsx)("button",{type:"button",style:{marginLeft:"auto",background:"none",border:"none",color:"inherit",cursor:"pointer"},onClick:()=>i(!o),children:(0,l.jsx)(A.plus,{})})]}),o&&(0,l.jsx)("div",{className:"expr__popover",style:{position:"absolute",left:0,right:0,top:"100%",zIndex:10,background:"var(--bg)",border:"1px solid var(--line)",borderRadius:4,maxHeight:260,overflowY:"auto",boxShadow:"0 6px 20px rgba(0,0,0,0.25)"},children:ss.map(m=>(0,l.jsxs)(ne.Fragment,{children:[(0,l.jsx)("div",{className:"expr__pop-group",style:{padding:"4px 10px",fontSize:10,color:"var(--muted)",textTransform:"uppercase",letterSpacing:.5},children:m.group}),m.items.map(y=>{let w=c.findIndex(H=>H.path===y.path);return(0,l.jsxs)("div",{onMouseEnter:()=>u(w),onClick:()=>d(y.path),style:{padding:"4px 10px",cursor:"pointer",fontSize:11,display:"flex",justifyContent:"space-between",gap:12,fontFamily:"var(--ax-mono, ui-monospace)",background:w===a?"var(--accent-soft)":"transparent"},children:[(0,l.jsx)("span",{children:`{{${y.path}}}`}),(0,l.jsx)("span",{style:{color:"var(--muted)",fontSize:10},children:y.type})]},y.path)})]},m.group))})]})}function zh({value:e,onChange:t,agents:n}){let[r,o]=(0,ne.useState)(!1),[i,a]=(0,ne.useState)(""),u=(0,ne.useRef)(null);(0,ne.useEffect)(()=>{let d=p=>{u.current&&!u.current.contains(p.target)&&o(!1)};return window.addEventListener("mousedown",d),()=>window.removeEventListener("mousedown",d)},[]);let s=n.find(d=>d.id===e),c=n.filter(d=>!i||d.name.toLowerCase().includes(i.toLowerCase())||d.id.includes(i));return(0,l.jsxs)("div",{ref:u,style:{position:"relative"},children:[(0,l.jsxs)("button",{type:"button",className:"fld__input",onClick:()=>o(d=>!d),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",cursor:"pointer"},children:[(0,l.jsx)("span",{style:{display:"inline-flex",width:22,height:22,borderRadius:4,background:`oklch(0.78 0.13 ${s?.color??260})`,color:"#fff",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,flexShrink:0},children:(s?.name??"??").slice(0,2).toUpperCase()}),(0,l.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("div",{style:{fontSize:12,fontWeight:500},children:s?.name??"Select agent\u2026"}),(0,l.jsx)("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--ax-mono, ui-monospace)"},children:s?.id??"\u2014"})]}),(0,l.jsx)(A.chev,{})]}),r&&(0,l.jsxs)("div",{style:{position:"absolute",left:0,right:0,top:"100%",zIndex:10,background:"var(--bg)",border:"1px solid var(--line)",borderRadius:4,marginTop:4,maxHeight:280,overflowY:"auto",boxShadow:"0 6px 20px rgba(0,0,0,0.25)"},children:[(0,l.jsx)("div",{style:{padding:6,borderBottom:"1px solid var(--line)"},children:(0,l.jsx)("input",{autoFocus:!0,className:"fld__input",value:i,placeholder:"Filter agents\u2026",onChange:d=>a(d.target.value),style:{width:"100%"}})}),(0,l.jsxs)("div",{children:[c.map(d=>(0,l.jsxs)("div",{onClick:()=>{t(d.id),o(!1),a("")},style:{padding:"6px 10px",cursor:"pointer",display:"flex",gap:8,alignItems:"center",background:d.id===e?"var(--accent-soft)":"transparent"},children:[(0,l.jsx)("span",{style:{display:"inline-flex",width:22,height:22,borderRadius:4,background:`oklch(0.78 0.13 ${d.color})`,color:"#fff",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,flexShrink:0},children:d.name.slice(0,2).toUpperCase()}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("div",{style:{fontSize:12,fontWeight:500},children:d.name}),(0,l.jsx)("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--ax-mono, ui-monospace)"},children:d.id})]}),d.tags.length>0&&(0,l.jsx)("div",{style:{display:"flex",gap:3},children:d.tags.map(p=>(0,l.jsx)("span",{style:{fontSize:9,color:"var(--muted)",background:"var(--surface)",padding:"1px 5px",borderRadius:3},children:p},p))})]},d.id)),c.length===0&&(0,l.jsx)("div",{style:{padding:10,fontSize:11,color:"var(--muted)"},children:"No agents match."})]})]}),(0,l.jsx)(k,{label:"",hint:"Free text \u2014 type an agent id directly if it isn't in the list yet",children:(0,l.jsx)(R,{value:e??"",onChange:t,placeholder:"agent-id",mono:!0})})]})}var fs={"whatsapp-message":{label:"WhatsApp \u2014 Incoming message",fires:"Fires when a contact or group sends a WhatsApp message to the paired account.",wired:!0,group:"channel-msg",hasLabels:!1},"telegram-message":{label:"Telegram \u2014 Incoming message",fires:"Fires when a Telegram user or group sends a message to the bot.",wired:!0,group:"channel-msg",hasLabels:!1},"discord-message":{label:"Discord \u2014 Incoming message",fires:"Fires when a Discord user posts a message in a watched channel or DM.",wired:!1,group:"channel-msg",hasLabels:!1},"slack-message":{label:"Slack \u2014 Incoming message",fires:"Fires when a Slack user posts a message in a watched channel or DM.",wired:!1,group:"channel-msg",hasLabels:!1},"gitlab-issue":{label:"GitLab \u2014 Issue event",fires:"Fires when a GitLab issue is opened, updated, reopened, or closed.",wired:!0,group:"gitlab",hasLabels:!0},"gitlab-mr":{label:"GitLab \u2014 Merge request event",fires:"Fires when a GitLab merge request is opened, updated, approved, merged, or closed.",wired:!0,group:"gitlab",hasLabels:!0},"gitlab-note":{label:"GitLab \u2014 Comment on issue or MR",fires:"Fires when a comment is posted on a GitLab issue or merge request.",wired:!0,group:"gitlab",hasLabels:!1},"gitlab-pipeline":{label:"GitLab \u2014 Pipeline status change",fires:"Fires when a CI/CD pipeline transitions state (running, success, failed).",wired:!0,group:"gitlab",hasLabels:!1},"github-issue":{label:"GitHub \u2014 Issue event",fires:"Fires when a GitHub issue is opened, updated, or closed (after webhook signature verification).",wired:!0,group:"github",hasLabels:!0},"github-pr":{label:"GitHub \u2014 Pull request event",fires:"Fires when a GitHub pull request is opened, updated, reviewed, merged, or closed.",wired:!0,group:"github",hasLabels:!0},"stripe-event":{label:"Stripe \u2014 Webhook event",fires:"Fires on any Stripe webhook (invoice.paid, customer.subscription.deleted, charge.refunded, etc.). Filter by event type in the workflow body.",wired:!0,group:"external-webhook",hasLabels:!1},"sentry-issue":{label:"Sentry \u2014 Issue alert",fires:"Fires when Sentry triggers an issue alert (new issue, regression, threshold breach).",wired:!0,group:"external-webhook",hasLabels:!1},"vercel-deployment":{label:"Vercel \u2014 Deployment event",fires:"Fires when Vercel reports a deployment state change (created, ready, error).",wired:!0,group:"external-webhook",hasLabels:!1},"odoo-event":{label:"Odoo \u2014 ERP/CRM event",fires:"Fires on any Odoo webhook (contact create, lead won, sale confirmed, invoice paid, project task updated, etc.). Filter by event/model in the workflow body.",wired:!0,group:"external-webhook",hasLabels:!1},"hubspot-event":{label:"HubSpot \u2014 CRM event",fires:"Fires on any HubSpot v3 webhook (contact.creation, deal.propertyChange, conversation.newMessage, etc.). Filter by subscriptionType in the workflow body.",wired:!0,group:"external-webhook",hasLabels:!1}},Ah=Object.entries(fs).map(([e,t])=>({value:e,label:t.wired?`${t.label} \u2713`:`${t.label} \u26A0 schema-only`}));function Dh({node:e,patchData:t}){let n=e.config,r=n.filter??{},o=p=>t({filter:{...r,...p}}),i=String(n.source??"whatsapp-message"),a=fs[i]??fs["whatsapp-message"],u=a.group==="channel-msg",s=a.group==="gitlab",c=a.group==="github",d=u||s||c;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Source",children:[(0,l.jsx)(k,{label:"Event",hint:a.wired?"\u2713 wired end-to-end":"\u26A0 schema-only \u2014 no webhook subscriber configured for this source yet",children:(0,l.jsx)(ue,{value:i,onChange:p=>t({source:p,filter:{}}),options:Ah})}),(0,l.jsx)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:-6,marginBottom:12},children:a.fires})]}),d&&(0,l.jsxs)(L,{title:"Match criteria",children:[(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:8},children:["Limit when this trigger fires. Leave empty or use ",(0,l.jsx)("span",{className:"mono",children:"*"})," to match anything."]}),s&&(0,l.jsx)(k,{label:"Project",hint:'GitLab project path. Empty or "*" matches any.',children:(0,l.jsx)(R,{mono:!0,value:String(r.project??""),onChange:p=>o({project:p}),placeholder:"* (any) or acme/web"})}),c&&(0,l.jsx)(k,{label:"Repo",hint:'GitHub "owner/repo". Empty or "*" matches any.',children:(0,l.jsx)(R,{mono:!0,value:String(r.repo??""),onChange:p=>o({repo:p}),placeholder:"* (any) or owner/repo"})}),u&&(0,l.jsx)(k,{label:"Chat",hint:i==="whatsapp-message"?'Contact number or JID (e.g. "+216 00 000 000", "10000000000@s.whatsapp.net"). Empty or "*" matches any.':i==="telegram-message"?'Telegram chat id ("1816212449" for a DM, "-1003861455814" for a group). Empty or "*" matches any.':'Exact chat id. Empty or "*" matches any.',children:(0,l.jsx)(R,{mono:!0,value:String(r.chat??""),onChange:p=>o({chat:p}),placeholder:"* (any)"})}),a.hasLabels&&(0,l.jsx)(k,{label:"Labels (any of)",hint:"Fires only when at least one of these labels is present on the issue/MR. Empty = no label filter.",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(r.labels)?r.labels:[],onChange:p=>o({labels:p}),placeholder:"bug, needs-review"})})]}),u&&(0,l.jsx)(L,{title:"Routing",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Pass data straight through",hint:"When on, the default agent router ALSO replies alongside this workflow. Use for observability-only workflows (tag, log, forward) that shouldn't own the conversation.",children:(0,l.jsx)(Li,{checked:!!n.passthrough,onChange:p=>t({passthrough:p}),label:"Let the default agent also reply"})})})]})}function jh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Schedule",children:[(0,l.jsx)(k,{label:"When it runs",hint:"5 fields: minute hour day month weekday. E.g. '0 9 * * 1-5' = 9am Mon\u2013Fri.",children:(0,l.jsx)(R,{mono:!0,value:String(n.spec??"0 * * * *"),onChange:r=>t({spec:r}),placeholder:"0 9 * * *"})}),(0,l.jsx)(k,{label:"Timezone",hint:"IANA timezone (e.g. Europe/London, America/New_York). Defaults to UTC.",children:(0,l.jsx)(R,{mono:!0,value:String(n.timezone??"UTC"),onChange:r=>t({timezone:r}),placeholder:"Europe/London"})}),(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:4},children:["Fires the workflow on the schedule. The trigger payload is empty \u2014 downstream nodes won't have ",(0,l.jsx)("span",{className:"mono",children:"{{start.*}}"})," data unless you wire it."]})]})}function Uh({node:e,patchData:t}){let n=e.config,r=Array.isArray(n.filter)?n.filter.length:0;return(0,l.jsxs)(L,{title:"Poll",children:[(0,l.jsx)(k,{label:"Which saved action",hint:"Slug of a registered action (.agentx/actions/<id>.json). It must print one JSON object per line.",children:(0,l.jsx)(R,{mono:!0,value:String(n.actionId??""),onChange:o=>t({actionId:o}),placeholder:"list-new-messages"})}),(0,l.jsx)(k,{label:"Every (seconds)",hint:"How often the action runs. 5 or more; defaults to 60.",children:(0,l.jsx)(on,{value:n.everySeconds,onChange:o=>t({everySeconds:o}),placeholder:"60"})}),(0,l.jsx)(k,{label:"Item key",hint:"Field that identifies an item, e.g. msgId. Each key starts one run, once.",children:(0,l.jsx)(R,{mono:!0,value:String(n.key??""),onChange:o=>t({key:o}),placeholder:"id"})}),(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:4},children:["The first poll only records what is already there. After that, each new item starts one run with its fields as ",(0,l.jsx)("span",{className:"mono",children:"{{trigger.*}}"}),"."," ",r>0?`${r} filter condition(s) set.`:"No filter."," Edit ",(0,l.jsx)("span",{className:"mono",children:"filter"})," under Advanced."]})]})}var ds=[{value:"on:gitlab-issue",label:"on:gitlab-issue",fires:"Fires when a GitLab issue is opened, updated, reopened, or closed (after the channel adapter dispatched it)."},{value:"on:gitlab-mr",label:"on:gitlab-mr",fires:"Fires when a GitLab merge request is opened, updated, approved, merged, or closed."},{value:"on:gitlab-note",label:"on:gitlab-note",fires:"Fires when a comment is posted on a GitLab issue or merge request."},{value:"on:gitlab-pipeline",label:"on:gitlab-pipeline",fires:"Fires when a GitLab CI/CD pipeline transitions state."},{value:"on:github-issue",label:"on:github-issue",fires:"Fires when a GitHub issue is opened, updated, or closed (signature-verified webhook)."},{value:"on:github-pr",label:"on:github-pr",fires:"Fires when a GitHub pull request is opened, reviewed, merged, or closed."},{value:"on:github-push",label:"on:github-push",fires:"Fires on any GitHub push event (branch updates)."},{value:"on:stripe-event",label:"on:stripe-event",fires:"Fires on any Stripe webhook (invoice.paid, charge.refunded, subscription.deleted, etc.). Filter by event type inside the workflow."},{value:"on:sentry-issue",label:"on:sentry-issue",fires:"Fires when a Sentry issue alert lands (new issue, regression, error threshold)."},{value:"on:vercel-deployment",label:"on:vercel-deployment",fires:"Fires when a Vercel deployment changes state."},{value:"on:odoo-event",label:"on:odoo-event",fires:"Fires on any Odoo webhook (res.partner.create, sale.order.action_confirm, account.move.paid, etc.). Filter by event/model inside the workflow."},{value:"on:hubspot-event",label:"on:hubspot-event",fires:"Fires on any HubSpot v3 webhook (contact.creation, deal.propertyChange, conversation.newMessage, etc.). Filter by subscriptionType inside the workflow."},{value:"on:error",label:"on:error",fires:"Fires when an agent task fails. Useful for incident-routing workflows."}];function Wh({node:e,patchData:t}){let n=e.config,r=String(n.event??"on:"),i=ds.find(a=>a.value===r)?.fires??(r.startsWith("on:")&&r!=="on:"?"Custom hook event. Fires whenever code in your agentx setup emits this event via the bus. Subscribe responsibly.":'Hook event names must start with "on:" \u2014 e.g. on:gitlab-issue.');return(0,l.jsxs)(L,{title:"Hook subscription",children:[(0,l.jsxs)(k,{label:"Event",hint:"Pick a known event or type your own (must start with on:)",children:[(0,l.jsx)(R,{mono:!0,value:r,onChange:a=>t({event:a}),placeholder:"on:gitlab-issue",list:"hook-events-list"}),(0,l.jsx)("datalist",{id:"hook-events-list",children:ds.map(a=>(0,l.jsx)("option",{value:a.value,children:a.fires},a.value))})]}),(0,l.jsx)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:-6,marginBottom:4},children:i}),(0,l.jsxs)("details",{style:{marginTop:8},children:[(0,l.jsx)("summary",{style:{cursor:"pointer",fontSize:12,color:"var(--muted)"},children:"Available hook events"}),(0,l.jsx)("ul",{style:{fontSize:11,color:"var(--muted)",paddingLeft:16,marginTop:6},children:ds.map(a=>(0,l.jsxs)("li",{style:{marginBottom:4},children:[(0,l.jsx)("span",{className:"mono",children:a.value})," \u2014 ",a.fires]},a.value))})]})]})}function Hh(e){return(0,l.jsx)(L,{title:"Manual run",children:(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5},children:["No configuration needed. Fire this workflow via:",(0,l.jsx)("pre",{style:{marginTop:8,padding:8,background:"var(--bg)",border:"1px solid var(--line)",borderRadius:4,fontSize:11},children:"agentx workflow run <id>"}),"or ",(0,l.jsx)("span",{className:"mono",children:"POST /workflows/<id>/run"}),"."]})})}function Bh({node:e,patchData:t,agents:n}){let r=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Agent",children:[(0,l.jsx)(k,{label:"Which agent runs",children:(0,l.jsx)(zh,{value:r.agentId,onChange:o=>t({agentId:o}),agents:n})}),(0,l.jsx)(k,{label:"What to ask for",hint:"Supports {{nodeId.path}} variables from upstream context",children:(0,l.jsx)(kn,{value:r.prompt??"",onChange:o=>t({prompt:o}),placeholder:"Classify {{trigger.text}} \u2014 reply RESULT: status-check | new-request | other",rows:5})})]}),(0,l.jsxs)(L,{title:"Behavior",defaultOpen:!1,children:[(0,l.jsx)(k,{label:"How to read the reply",hint:"How to extract a routing token from the agent's reply",children:(0,l.jsx)(ue,{value:String(r.resultParser??"acme-result-token"),onChange:o=>t({resultParser:o}),options:[{value:"acme-result-token",label:"RESULT: token (recommended)"},{value:"json",label:"JSON block (```json \u2026```)"},{value:"raw",label:"Raw reply (no parsing)"}]})}),(0,l.jsx)(k,{label:"Give up after (minutes)",children:(0,l.jsx)(on,{value:r.timeoutMinutes,onChange:o=>t({timeoutMinutes:o}),placeholder:"5"})})]})]})}function Gh({node:e,patchData:t}){let n=e.config,[r,o]=(0,ne.useState)(n.template&&typeof n.template=="object"?"template":"path");return(0,l.jsxs)(L,{title:"Transform",children:[(0,l.jsx)(k,{label:"Mode",children:(0,l.jsx)(ue,{value:r,onChange:i=>{let a=i;o(a),t(a==="path"?{path:n.path??"",template:void 0}:{template:n.template??{},path:void 0})},options:[{value:"path",label:"Pick value from context (dotted path)"},{value:"template",label:"Build a bundle (template object)"}]})}),r==="path"&&(0,l.jsx)(k,{label:"Path",hint:"e.g. classify.reply or trigger.contact.name",children:(0,l.jsx)(R,{mono:!0,value:String(n.path??""),onChange:i=>t({path:i}),placeholder:"classify.reply"})}),r==="template"&&(0,l.jsx)(k,{label:"Template",hint:"One field per output key. String values support {{nodeId.path}} variables.",children:(0,l.jsx)(bn,{value:n.template??{},onChange:i=>t({template:i}),keyPlaceholder:"output key (e.g. greeting)",valuePlaceholder:"hi {{trigger.sender.name}}",emptyHint:"No fields yet \u2014 click + Add field below."})})]})}function $h({node:e,patchData:t}){let n=e.config,r=n.cases??[],o=s=>t({cases:s}),i=(s,c)=>o(r.map((d,p)=>p===s?c:d)),a=(s,c)=>i(s,{...r[s],when:{...r[s].when,...c}}),u=(s,c)=>i(s,{...r[s],when:{...r[s].when,params:{...r[s].when.params,...c}}});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Cases",right:(0,l.jsx)("span",{className:"card__kind",children:r.length}),children:[r.map((s,c)=>{let d=s.when.params??{};return(0,l.jsxs)("div",{style:{border:"1px solid var(--line)",borderRadius:4,padding:10,marginBottom:8,background:"var(--bg)"},children:[(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,l.jsxs)("strong",{style:{fontSize:11},children:["Case #",c+1]}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",onClick:()=>o(r.filter((p,m)=>m!==c)),children:(0,l.jsx)(A.trash,{})})]}),(0,l.jsx)(k,{label:"If",children:(0,l.jsx)(ue,{value:s.when.kind,onChange:p=>a(c,{kind:p,params:{}}),options:[{value:"equals",label:"Path equals value"},{value:"contains",label:"Path contains value"},{value:"matches",label:"Path matches regex"},{value:"exists",label:"Path exists (non-empty)"}]})}),(0,l.jsx)(k,{label:"Path",hint:"e.g. classify.result",children:(0,l.jsx)(R,{mono:!0,value:String(d.path??""),onChange:p=>u(c,{path:p}),placeholder:"classify.result"})}),(s.when.kind==="equals"||s.when.kind==="contains")&&(0,l.jsx)(k,{label:"Value",children:(0,l.jsx)(R,{mono:!0,value:String(d.value??""),onChange:p=>u(c,{value:p})})}),s.when.kind==="matches"&&(0,l.jsx)(k,{label:"Regex",children:(0,l.jsx)(R,{mono:!0,value:String(d.regex??""),onChange:p=>u(c,{regex:p}),placeholder:"^(approved|done)$"})}),(0,l.jsx)(k,{label:"Port",hint:"Outgoing edge's `fromPort` must match this",children:(0,l.jsx)(R,{mono:!0,value:s.to,onChange:p=>i(c,{...s,to:p}),placeholder:"approved"})})]},c)}),(0,l.jsxs)("button",{className:"btn btn--ghost-icon",style:{width:"100%",padding:8,justifyContent:"center"},onClick:()=>o([...r,{when:{kind:"equals",params:{path:"",value:""}},to:`case${r.length+1}`}]),children:[(0,l.jsx)(A.plus,{})," Add case"]})]}),(0,l.jsx)(L,{title:"Fallback",defaultOpen:!1,children:(0,l.jsx)(k,{label:"If nothing matches, go to",hint:"Used when no case matches. Leave blank to drop the event.",children:(0,l.jsx)(R,{mono:!0,value:String(n.default??"fallback"),onChange:s=>t({default:s})})})})]})}function Vh({node:e,patchData:t}){let n=e.config,r=n.waitFor??{},o=a=>t({waitFor:{...r,...a}}),i=n.resumeMatch??{};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Checkpoint",children:(0,l.jsx)(k,{label:"Name",hint:"Human label shown in logs + run timelines",children:(0,l.jsx)(R,{value:String(n.name??e.id),onChange:a=>t({name:a}),placeholder:"await-label-change"})})}),(0,l.jsxs)(L,{title:"Wait for",children:[(0,l.jsx)(k,{label:"Source",hint:"Which kind of event unpauses this run",children:(0,l.jsx)(ue,{value:String(r.source??""),onChange:a=>o({source:a||void 0}),options:[{value:"",label:"Any (same entity)"},{value:"gitlab-issue",label:"GitLab issue update"},{value:"gitlab-pipeline",label:"GitLab pipeline event"},{value:"whatsapp-message",label:"WhatsApp reply"},{value:"telegram-message",label:"Telegram reply"},{value:"manual",label:"Manual poke"}]})}),(0,l.jsx)(k,{label:"Labels (any of)",hint:"e.g. a label change to one of these resumes the run",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(r.labels)?r.labels:[],onChange:a=>o({labels:a.length?a:void 0})})})]}),(0,l.jsx)(L,{title:"Advanced match",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Only if the event mentions",hint:"Optional substring match on the incoming event's id",children:(0,l.jsx)(R,{mono:!0,value:String(i.eventIdLike??""),onChange:a=>t({resumeMatch:{...i,eventIdLike:a||void 0}})})})})]})}function Kh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Terminal",children:[(0,l.jsx)(k,{label:"Status",children:(0,l.jsx)(ue,{value:String(n.status??"completed"),onChange:r=>t({status:r}),options:[{value:"completed",label:"Completed (success)"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}]})}),(0,l.jsx)(k,{label:"Short summary",hint:"Surfaced in run history + notifications",children:(0,l.jsx)(Ri,{value:String(n.summary??""),onChange:r=>t({summary:r}),rows:2})})]})}var Yh=["gitlab","github","whatsapp","telegram","discord","slack"],ps=new Map,pp=6e4;function Qh(e){let[t,n]=(0,ne.useState)(()=>{let r=ps.get(e);return r&&Date.now()-r.at<pp?{chats:r.chats,source:r.source,loading:!1}:{chats:[],source:"",loading:!0}});return(0,ne.useEffect)(()=>{let r=!1,o=ps.get(e);if(o&&Date.now()-o.at<pp){n({chats:o.chats,source:o.source,loading:!1});return}return n(i=>({...i,loading:!0})),fetch(`/channels/${encodeURIComponent(e)}/chats`).then(i=>i.ok?i.json():{chats:[],source:""}).then(i=>{if(r)return;let a=Array.isArray(i.chats)?i.chats:[],u=typeof i.source=="string"?i.source:"";ps.set(e,{at:Date.now(),chats:a,source:u}),n({chats:a,source:u,loading:!1})}).catch(()=>{r||n({chats:[],source:"",loading:!1})}),()=>{r=!0}},[e]),t}function Jh({node:e,patchData:t,nodes:n}){let r=e.config,o=n.find(c=>c.type.startsWith("trigger."))?.id??"trigger",i=c=>`{{${o}.${c}}}`,a=String(r.channel??"whatsapp"),u=Qh(a),s=`chats-${a}`;return(0,l.jsxs)(L,{title:"Send message",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:a,onChange:c=>t({channel:c}),options:Yh})}),(0,l.jsxs)(k,{label:"Chat id",hint:u.chats.length>0?`Use ${i("chatId")} to reply to the trigger's chat, or pick one of the ${u.chats.length} known chat(s) ${u.source==="local"?"on this node":`from ${u.source}`} (click the field to see the list).`:u.loading?`Loading known chats for "${a}"\u2026`:`Use ${i("chatId")} to reply to the trigger's chat. For a different destination, paste the channel-specific id (no discovered chats for "${a}" yet).`,children:[(0,l.jsx)(R,{mono:!0,value:String(r.chatId??""),onChange:c=>t({chatId:c}),placeholder:i("chatId"),list:u.chats.length>0?s:void 0}),u.chats.length>0&&(0,l.jsx)("datalist",{id:s,children:u.chats.map(c=>(0,l.jsx)("option",{value:c.id,children:c.name?`${c.name} \u2014 ${c.id}${c.kind==="group"?" (group)":""}`:`${c.id}${c.kind==="group"?" (group)":""}`},c.id))})]}),(0,l.jsx)(k,{label:"Text",hint:"Supports {{nodeId.path}} templates from any upstream node",children:(0,l.jsx)(kn,{value:String(r.text??""),onChange:c=>t({text:c}),rows:4,placeholder:`Thanks ${i("sender.name")} \u2014 working on it.`})}),(0,l.jsx)(k,{label:"Account id",hint:"Telegram only: which bot account sends. Leave empty to inherit from the trigger's account (recommended).",children:(0,l.jsx)(R,{mono:!0,value:String(r.accountId??""),onChange:c=>t({accountId:c}),placeholder:`(inherit from ${i("accountId")})`})}),(0,l.jsx)(k,{label:"Reply to which message",hint:"Optional. When set, the platform threads this reply under the referenced message.",children:(0,l.jsx)(R,{mono:!0,value:String(r.replyTo??""),onChange:c=>t({replyTo:c}),placeholder:i("event.id")})}),(0,l.jsx)(k,{label:"Text formatting",hint:r.channel==="telegram"?'Telegram default is "markdown" (Telegram-flavoured HTML conversion). Use "plain" to send raw text without escaping.':"Platform-specific. WhatsApp ignores; Telegram supports markdown/html.",children:(0,l.jsx)(ue,{value:String(r.parseMode??"markdown"),onChange:c=>t({parseMode:c}),options:["markdown","plain","html"]})})]})}function Xh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Target",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab","github"]})}),(0,l.jsx)(k,{label:"Project",hint:'GitLab "group/project" or GitHub "owner/repo"',children:(0,l.jsx)(R,{mono:!0,value:String(n.project??""),onChange:r=>t({project:r}),placeholder:"acme/web"})})]}),(0,l.jsxs)(L,{title:"Issue",children:[(0,l.jsx)(k,{label:"Title",children:(0,l.jsx)(kn,{rows:1,value:String(n.title??""),onChange:r=>t({title:r}),placeholder:"From WhatsApp: {{trigger.sender.name}}"})}),(0,l.jsx)(k,{label:"Description",children:(0,l.jsx)(kn,{rows:6,value:String(n.description??""),onChange:r=>t({description:r}),placeholder:"Reported by {{trigger.sender.name}}\\n\\n{{trigger.text}}"})}),(0,l.jsx)(k,{label:"Labels",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(n.labels)?n.labels:[],onChange:r=>t({labels:r}),placeholder:"Triage, source::whatsapp"})}),(0,l.jsx)(k,{label:"Assignees",hint:"GitLab usernames (resolved to ids at runtime)",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(n.assignees)?n.assignees:[],onChange:r=>t({assignees:r}),placeholder:"alice, bob"})})]})]})}function qh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Target",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab","github"]})}),(0,l.jsx)(k,{label:"What it is about",children:(0,l.jsx)(ue,{value:String(n.kind??"issue"),onChange:r=>t({kind:r}),options:["issue","merge_request"]})}),(0,l.jsx)(k,{label:"Project",children:(0,l.jsx)(R,{mono:!0,value:String(n.project??""),onChange:r=>t({project:r}),placeholder:"{{trigger.project}}"})}),(0,l.jsx)(k,{label:"Issue number",children:(0,l.jsx)(R,{mono:!0,value:String(n.iid??""),onChange:r=>t({iid:r}),placeholder:"{{trigger.issue.iid}}"})})]}),(0,l.jsxs)(L,{title:"Labels",children:[(0,l.jsx)(k,{label:"Add",hint:"Comma-separated list",children:(0,l.jsx)(vt,{value:Array.isArray(n.add)?n.add:[],onChange:r=>t({add:r}),placeholder:"In review"})}),(0,l.jsx)(k,{label:"Remove",children:(0,l.jsx)(vt,{value:Array.isArray(n.remove)?n.remove:[],onChange:r=>t({remove:r}),placeholder:"Triage"})})]})]})}function Zh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Read labels",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab","github"]})}),(0,l.jsx)(k,{label:"What it is about",children:(0,l.jsx)(ue,{value:String(n.kind??"issue"),onChange:r=>t({kind:r}),options:["issue","merge_request"]})}),(0,l.jsx)(k,{label:"Project",children:(0,l.jsx)(R,{mono:!0,value:String(n.project??""),onChange:r=>t({project:r})})}),(0,l.jsx)(k,{label:"Issue number",children:(0,l.jsx)(R,{mono:!0,value:String(n.iid??""),onChange:r=>t({iid:r})})}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginTop:8},children:["Output bundle: ",(0,l.jsx)("span",{className:"mono",children:"{{ <nodeId>.labels }}"})," = string[]"]})]})}function em({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"React",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"telegram"),onChange:r=>t({channel:r}),options:["telegram","whatsapp"]})}),(0,l.jsx)(k,{label:"Chat id",children:(0,l.jsx)(R,{mono:!0,value:String(n.chatId??""),onChange:r=>t({chatId:r}),placeholder:"{{trigger.chatId}}"})}),(0,l.jsx)(k,{label:"Message id",children:(0,l.jsx)(R,{mono:!0,value:String(n.messageId??""),onChange:r=>t({messageId:r}),placeholder:"{{trigger.event.id}}"})}),(0,l.jsx)(k,{label:"Emoji",children:(0,l.jsx)(R,{value:String(n.emoji??"\u{1F440}"),onChange:r=>t({emoji:r})})})]})}function tm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Edit message",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"telegram"),onChange:r=>t({channel:r}),options:["telegram","whatsapp","gitlab","github","discord","slack"]})}),(0,l.jsx)(k,{label:"Chat id",children:(0,l.jsx)(R,{mono:!0,value:String(n.chatId??""),onChange:r=>t({chatId:r})})}),(0,l.jsx)(k,{label:"Message id",children:(0,l.jsx)(R,{mono:!0,value:String(n.messageId??""),onChange:r=>t({messageId:r})})}),(0,l.jsx)(k,{label:"Replace the text with",children:(0,l.jsx)(kn,{value:String(n.text??""),onChange:r=>t({text:r}),rows:3})}),(0,l.jsx)(k,{label:"Text formatting",children:(0,l.jsx)(ue,{value:String(n.parseMode??"plain"),onChange:r=>t({parseMode:r}),options:["plain","markdown","html"]})})]})}function nm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Log time",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab"]})}),(0,l.jsx)(k,{label:"Chat id",hint:'"project:issue:42" or "project:merge_request:7"',children:(0,l.jsx)(R,{mono:!0,value:String(n.chatId??""),onChange:r=>t({chatId:r}),placeholder:"{{trigger.chatId}}"})}),(0,l.jsx)(k,{label:"How long to wait",children:(0,l.jsx)(on,{value:n.durationMs,onChange:r=>t({durationMs:r}),placeholder:"900000"})})]})}function rm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Action",children:(0,l.jsx)(k,{label:"Which saved action",hint:"Slug of a registered action (.agentx/actions/<id>.json). Manage in Settings \u2192 Actions or via `agentx actions`.",children:(0,l.jsx)(R,{mono:!0,value:String(n.actionId??""),onChange:r=>t({actionId:r}),placeholder:"deploy-staging"})})}),(0,l.jsx)(L,{title:"Inputs",defaultOpen:!0,children:(0,l.jsx)(k,{label:"Inputs",hint:"One field per input key. String values support {{nodeId.path}} variables.",children:(0,l.jsx)(bn,{value:n.inputs??{},onChange:r=>t({inputs:r}),keyPlaceholder:"input name (e.g. version)",valuePlaceholder:"{{trigger.tag}}",emptyHint:"No inputs configured."})})}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginTop:8,padding:"0 10px"},children:["Output: ",(0,l.jsx)("span",{className:"mono",children:"{{ <nodeId>.ok / .status / .output / .errors / .durationMs }}"})]})]})}function om({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Request",children:[(0,l.jsx)(k,{label:"URL",children:(0,l.jsx)(R,{mono:!0,value:String(n.url??""),onChange:r=>t({url:r}),placeholder:"https://example.com/webhook"})}),(0,l.jsx)(k,{label:"Method",children:(0,l.jsx)(ue,{value:String(n.method??"POST"),onChange:r=>t({method:r}),options:["GET","POST","PUT","PATCH","DELETE"]})})]}),(0,l.jsx)(L,{title:"Body",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Body",hint:"String \u2014 rendered with {{nodeId.path}}. Server parses as JSON when possible.",children:(0,l.jsx)(kn,{rows:5,value:typeof n.body=="string"?n.body:n.body?JSON.stringify(n.body,null,2):"",onChange:r=>t({body:r})})})}),(0,l.jsx)(L,{title:"Headers",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Headers",hint:"HTTP request headers \u2014 string values support {{env.*}} and {{nodeId.path}}.",children:(0,l.jsx)(bn,{value:n.headers??{},onChange:r=>t({headers:r}),keyPlaceholder:"Header-Name",valuePlaceholder:"Bearer {{env.TOKEN}}",allowedTypes:["string"],emptyHint:"No headers set."})})}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginTop:8,padding:"0 10px"},children:["Output: ",(0,l.jsx)("span",{className:"mono",children:"{{ <nodeId>.ok / .status / .body }}"})]})]})}var im=["text","long-text","number","boolean","date","select","multi-select","file"];function fp({form:e,patch:t}){let n=e.fields??[],r=(s,c)=>{let d=[...n];d[s]={...d[s],...c},t({...e,fields:d})},o=(s,c)=>{let d=[...n];d[s]={...d[s],validate:{...d[s].validate??{},...c}},t({...e,fields:d})},i=s=>t({...e,fields:n.filter((c,d)=>d!==s)}),a=(s,c)=>{let d=s+c;if(d<0||d>=n.length)return;let p=[...n];[p[s],p[d]]=[p[d],p[s]],t({...e,fields:p})},u=()=>t({...e,fields:[...n,{key:`field_${n.length+1}`,label:"New field",type:"text"}]});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Form",children:[(0,l.jsx)(k,{label:"Title",hint:"Header shown to the assignee above the form",children:(0,l.jsx)(R,{value:e.title??"",onChange:s=>t({...e,title:s}),placeholder:"Review application"})}),(0,l.jsx)(k,{label:"Description",hint:"Optional one-line context shown under the title",children:(0,l.jsx)(R,{value:e.description??"",onChange:s=>t({...e,description:s}),placeholder:""})}),(0,l.jsx)(k,{label:"Primary button",hint:"Label on the submit button; default: Submit",children:(0,l.jsx)(R,{value:e.submitLabel??"Submit",onChange:s=>t({...e,submitLabel:s})})}),(0,l.jsx)(k,{label:"Secondary action",hint:"Optional reject/hold button. Submissions carry action='secondary'.",children:(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[(0,l.jsx)(R,{value:e.secondaryAction?.key??"",onChange:s=>t({...e,secondaryAction:s?{key:s,label:e.secondaryAction?.label??s}:void 0}),placeholder:"key (e.g. reject)",mono:!0}),(0,l.jsx)(R,{value:e.secondaryAction?.label??"",onChange:s=>t({...e,secondaryAction:{key:e.secondaryAction?.key??"secondary",label:s}}),placeholder:"label (e.g. Reject)"})]})})]}),(0,l.jsxs)(L,{title:`Fields (${n.length})`,children:[n.length===0&&(0,l.jsx)("div",{className:"hint",style:{fontSize:12,color:"var(--ax-muted)"},children:"No fields \u2014 approve/reject form with no input."}),n.map((s,c)=>(0,l.jsxs)("div",{className:"fld__field-row",style:{border:"1px solid var(--ax-border)",borderRadius:6,padding:8,marginBottom:8},children:[(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:6,alignItems:"end"},children:[(0,l.jsx)(k,{label:"Key",hint:"Stored under values.<key>",children:(0,l.jsx)(R,{mono:!0,value:s.key,onChange:d=>r(c,{key:d})})}),(0,l.jsx)(k,{label:"Label",children:(0,l.jsx)(R,{value:s.label,onChange:d=>r(c,{label:d})})}),(0,l.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>a(c,-1),title:"Move up",children:"\u2191"}),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>a(c,1),title:"Move down",children:"\u2193"}),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>i(c),title:"Remove",children:"\u2715"})]})]}),(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6,marginTop:6},children:[(0,l.jsx)(k,{label:"Type",children:(0,l.jsx)(ue,{value:s.type,onChange:d=>r(c,{type:d}),options:im.slice()})}),(0,l.jsx)(k,{label:"",children:(0,l.jsx)(Li,{checked:!!s.required,onChange:d=>r(c,{required:d}),label:"Required"})})]}),(s.type==="select"||s.type==="multi-select")&&(0,l.jsx)(k,{label:"Options",hint:"Comma-separated list of allowed values",children:(0,l.jsx)(vt,{value:s.options??[],onChange:d=>r(c,{options:d}),placeholder:"low, medium, high"})}),(0,l.jsx)(k,{label:"Hint",hint:"Helper text shown under the input",children:(0,l.jsx)(R,{value:s.hint??"",onChange:d=>r(c,{hint:d})})}),(s.type==="text"||s.type==="long-text"||s.type==="number")&&(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:s.type==="number"?"1fr 1fr":"1fr 1fr 1fr",gap:6},children:[(0,l.jsx)(k,{label:"Min",children:(0,l.jsx)(on,{value:s.validate?.min,onChange:d=>o(c,{min:d})})}),(0,l.jsx)(k,{label:"Max",children:(0,l.jsx)(on,{value:s.validate?.max,onChange:d=>o(c,{max:d})})}),s.type!=="number"&&(0,l.jsx)(k,{label:"Pattern",hint:"Regex \u2014 optional",children:(0,l.jsx)(R,{mono:!0,value:s.validate?.pattern??"",onChange:d=>o(c,{pattern:d})})})]})]},c)),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:u,style:{marginTop:4},children:"+ Add field"})]})]})}function am({node:e,patchData:t}){let n=e.config,r=n.form??{title:"",fields:[],submitLabel:"Submit"};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Assignment",children:[(0,l.jsx)(k,{label:"Assignee",hint:"actor:<id> or role:<id> \u2014 managed via `agentx actor` / `agentx role`",children:(0,l.jsx)(R,{mono:!0,value:String(n.assignTo??""),onChange:o=>t({assignTo:o}),placeholder:"role:reviewers"})}),(0,l.jsx)(k,{label:"Title",hint:"Shown in the inbox + notification",children:(0,l.jsx)(R,{value:String(n.title??""),onChange:o=>t({title:o})})}),(0,l.jsx)(k,{label:"Description",children:(0,l.jsx)(Ri,{value:String(n.description??""),onChange:o=>t({description:o}),rows:2})}),(0,l.jsx)(k,{label:"Due in",hint:"ISO-8601 duration (PT2H, P1D) or number of minutes",children:(0,l.jsx)(R,{mono:!0,value:String(n.dueIn??""),onChange:o=>t({dueIn:o}),placeholder:"P2D"})})]}),(0,l.jsx)(fp,{form:r,patch:o=>t({form:o})})]})}function lm({node:e,patchData:t}){let n=e.config,r=n.form??{title:"",fields:[],submitLabel:"Submit"};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Start conditions",children:(0,l.jsx)(k,{label:"Who can start it",hint:"actor:<id> or role:<id> \u2014 who is allowed to initiate a new run",children:(0,l.jsx)(R,{mono:!0,value:String(n.startableBy??""),onChange:o=>t({startableBy:o}),placeholder:"role:public"})})}),(0,l.jsx)(fp,{form:r,patch:o=>t({form:o})})]})}function sm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Sub-process",children:[(0,l.jsx)(k,{label:"Which workflow",hint:"id of another workflow definition \u2014 it runs to completion, then parent resumes",children:(0,l.jsx)(R,{mono:!0,value:String(n.workflowId??""),onChange:r=>t({workflowId:r}),placeholder:"child-workflow-id"})}),(0,l.jsx)(k,{label:"Values to pass on",hint:'Map child-context keys \u2192 templated values. Use a single key "*" for full inheritance.',children:(0,l.jsx)(bn,{value:n.inputMap??{},onChange:r=>t({inputMap:r}),keyPlaceholder:"child key",valuePlaceholder:"{{trigger.foo}}",emptyHint:"No mapping \u2014 child workflow runs with no parent context."})})]})}function um({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Emit signal",children:[(0,l.jsx)(k,{label:"Name",hint:"Signal identifier; other workflows' signal.wait nodes subscribe by this",children:(0,l.jsx)(R,{mono:!0,value:String(n.name??""),onChange:r=>t({name:r}),placeholder:"approved"})}),(0,l.jsx)(k,{label:"Scope",hint:"workflow = only same-workflow waiters; global = every waiter",children:(0,l.jsx)(ue,{value:String(n.scope??"workflow"),onChange:r=>t({scope:r}),options:["workflow","global"]})}),(0,l.jsx)(k,{label:"Payload",hint:"Object delivered with the signal. String values support {{nodeId.path}}.",children:(0,l.jsx)(bn,{value:n.payload??{},onChange:r=>t({payload:r}),keyPlaceholder:"payload key",valuePlaceholder:"{{trigger.iid}}",emptyHint:"Empty signal payload."})})]})}function cm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Wait for signal",children:[(0,l.jsx)(k,{label:"Name",children:(0,l.jsx)(R,{mono:!0,value:String(n.name??""),onChange:r=>t({name:r}),placeholder:"approved"})}),(0,l.jsx)(k,{label:"Scope",children:(0,l.jsx)(ue,{value:String(n.scope??"workflow"),onChange:r=>t({scope:r}),options:["workflow","global"]})}),(0,l.jsx)(k,{label:"Only when",hint:"Only resume when every key here matches the emitted payload. Empty = match any payload.",children:(0,l.jsx)(bn,{value:n.match??{},onChange:r=>t({match:r}),keyPlaceholder:"payload key",valuePlaceholder:"expected value",emptyHint:"No filter \u2014 matches any payload."})})]})}function dm({node:e,patchData:t}){let n=e.config;return(0,l.jsx)(L,{title:"Timer",children:(0,l.jsx)(k,{label:"After",hint:"ISO-8601 duration (PT30M, PT2H, P1D) or minutes as a number",children:(0,l.jsx)(R,{mono:!0,value:String(n.after??""),onChange:r=>t({after:r}),placeholder:"PT1H"})})})}function pm({node:e,patchData:t}){let n=e.config;return(0,l.jsx)(L,{title:"Parallel gateway",children:(0,l.jsx)(k,{label:"Mode",hint:"fanOut = send to all outgoing edges; join = wait for every incoming edge",children:(0,l.jsx)(ue,{value:String(n.mode??"fanOut"),onChange:r=>t({mode:r}),options:["fanOut","join"]})})})}function fm({node:e,patchData:t}){let n=e.config,r=Array.isArray(n.inputs)?n.inputs.map(String):[],o=Array.isArray(n.rules)?n.rules:[],i=c=>t({inputs:c,rules:o.map(d=>({...d,when:(Array.isArray(d.when)?d.when.slice(0,c.length):[]).concat(Array(Math.max(0,c.length-(d.when?.length??0))).fill("*"))}))}),a=(c,d)=>{let p=[...o];p[c]={...p[c],...d},t({rules:p})},u=()=>t({rules:[...o,{when:r.map(()=>"*"),to:"port",output:{}}]}),s=c=>t({rules:o.filter((d,p)=>p!==c)});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Inputs",children:(0,l.jsx)(k,{label:"Values to read",hint:"Comma-separated; each is a template evaluated per-run against the run context",children:(0,l.jsx)(vt,{mono:!0,value:r,onChange:i,placeholder:"{{classify.result}}, {{trigger.values.amount}}"})})}),(0,l.jsxs)(L,{title:`Rules (${o.length})`,children:[o.map((c,d)=>(0,l.jsxs)("div",{style:{border:"1px solid var(--ax-border)",borderRadius:6,padding:8,marginBottom:8},children:[(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:6,alignItems:"end"},children:[(0,l.jsx)(k,{label:"Goes to",hint:"Outgoing edge port taken when this row matches",children:(0,l.jsx)(R,{mono:!0,value:String(c.to??""),onChange:p=>a(d,{to:p})})}),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>s(d),children:"\u2715"})]}),(0,l.jsx)(k,{label:"When these are true",hint:'One per input. "*" wildcard, "x" equals, ">10" numeric, "!=x", "/regex/"',children:(0,l.jsx)(vt,{mono:!0,value:(Array.isArray(c.when)?c.when:[]).map(String),onChange:p=>a(d,{when:p}),placeholder:"gold, >100"})}),(0,l.jsx)(k,{label:"Output",hint:"Fields written when this rule matches.",children:(0,l.jsx)(bn,{value:c.output??{},onChange:p=>a(d,{output:p}),keyPlaceholder:"output key",valuePlaceholder:"value",emptyHint:"No outputs."})})]},d)),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:u,children:"+ Add rule"})]}),(0,l.jsx)(L,{title:"Default",children:(0,l.jsx)(k,{label:"Goes to",children:(0,l.jsx)(R,{mono:!0,value:String(n.default?.to??"fallback"),onChange:c=>t({default:{...n.default??{},to:c}})})})})]})}var gm={"trigger.channel":e=>(0,l.jsx)(Dh,{...e}),"trigger.cron":e=>(0,l.jsx)(jh,{...e}),"trigger.poll":e=>(0,l.jsx)(Uh,{...e}),"trigger.hook":e=>(0,l.jsx)(Wh,{...e}),"trigger.manual":e=>(0,l.jsx)(Hh,{...e}),"trigger.form":e=>(0,l.jsx)(lm,{...e}),agent:e=>(0,l.jsx)(Bh,{...e}),transform:e=>(0,l.jsx)(Gh,{...e}),branch:e=>(0,l.jsx)($h,{...e}),"gateway.parallel":e=>(0,l.jsx)(pm,{...e}),rule:e=>(0,l.jsx)(fm,{...e}),checkpoint:e=>(0,l.jsx)(Vh,{...e}),userTask:e=>(0,l.jsx)(am,{...e}),subProcess:e=>(0,l.jsx)(sm,{...e}),"signal.emit":e=>(0,l.jsx)(um,{...e}),"signal.wait":e=>(0,l.jsx)(cm,{...e}),"timer.boundary":e=>(0,l.jsx)(dm,{...e}),end:e=>(0,l.jsx)(Kh,{...e}),"action.send":e=>(0,l.jsx)(Jh,{...e}),"action.createIssue":e=>(0,l.jsx)(Xh,{...e}),"action.setLabel":e=>(0,l.jsx)(qh,{...e}),"action.readLabel":e=>(0,l.jsx)(Zh,{...e}),"action.react":e=>(0,l.jsx)(em,{...e}),"action.editMessage":e=>(0,l.jsx)(tm,{...e}),"action.logTime":e=>(0,l.jsx)(nm,{...e}),"action.callHTTP":e=>(0,l.jsx)(om,{...e}),"action.run":e=>(0,l.jsx)(rm,{...e})};function gp(e){let{selection:t,nodes:n,edges:r,patch:o,patchData:i,onDelete:a,onDuplicate:u,validation:s,runState:c,agents:d,meta:p,patchMeta:m,onDeleteWorkflow:y,isNew:w}=e;if(!t)return(0,l.jsx)(km,{meta:p,patchMeta:m,onDeleteWorkflow:y,isNew:w});if(t.kind==="edge"){let H=r.find(g=>g.id===t.id);return H?(0,l.jsx)(bm,{edge:{...H,id:H.id??""},patch:o,onDelete:()=>a(t)}):null}let S=n.find(H=>H.id===t.id);return S?(0,l.jsx)(hm,{node:S,nodes:n,edges:r,patch:o,patchData:i,onDelete:()=>a(t),onDuplicate:()=>u(t),validation:s,runOutput:c?.outputs?.[S.id],agents:d}):null}function hm({node:e,nodes:t,edges:n,patch:r,patchData:o,onDelete:i,onDuplicate:a,validation:u,runOutput:s,agents:c}){let[d,p]=(0,ne.useState)("config"),m=gm[e.type];return(0,l.jsxs)("aside",{className:"insp",children:[(0,l.jsxs)("div",{className:"insp__head",children:[(0,l.jsxs)("div",{className:"insp__top",children:[(0,l.jsx)("span",{className:"insp__type-pill",children:e.type}),(0,l.jsx)("input",{className:"insp__name",value:e.id,onChange:y=>r({id:y.target.value})}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",title:"Duplicate",onClick:a,children:(0,l.jsx)(A.dup,{})}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",title:"Delete",onClick:i,children:(0,l.jsx)(A.trash,{})})]}),(0,l.jsxs)("div",{className:"insp__tabs",children:[(0,l.jsxs)("button",{className:"insp__tab"+(d==="config"?" is-active":""),onClick:()=>p("config"),children:[(0,l.jsx)(A.gear,{})," Config"]}),(0,l.jsxs)("button",{className:"insp__tab"+(d==="advanced"?" is-active":""),onClick:()=>p("advanced"),children:[(0,l.jsx)(A.layout,{})," Advanced"]}),(0,l.jsxs)("button",{className:"insp__tab"+(d==="preview"?" is-active":""),onClick:()=>p("preview"),children:[(0,l.jsx)(A.eye,{})," Preview ",s&&(0,l.jsx)("span",{className:"count",children:"\u25CF"})]})]})]}),(0,l.jsxs)("div",{className:"insp__body",children:[d==="config"&&(0,l.jsxs)(l.Fragment,{children:[m?m({node:e,nodes:t,patch:r,patchData:o,agents:c}):(0,l.jsx)(L,{title:"Config",children:(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:8},children:["No typed form yet for ",(0,l.jsx)("span",{className:"mono",children:e.type}),". Use the Advanced tab to edit raw JSON."]})}),(0,l.jsx)(vm,{node:e,nodes:t,edges:n})]}),d==="advanced"&&(0,l.jsx)(xm,{node:e,patchData:o}),d==="preview"&&(0,l.jsx)(L,{title:"Latest run output",children:s?(0,l.jsx)("pre",{style:{fontSize:11,color:"var(--ink-2)",padding:8,background:"var(--bg)",borderRadius:4,border:"1px solid var(--line)"},dangerouslySetInnerHTML:{__html:s}}):(0,l.jsx)("div",{style:{fontSize:12,color:"var(--muted)"},children:"No run data for this node yet."})}),u&&u.length>0&&(0,l.jsx)(L,{title:"Issues",right:(0,l.jsx)("span",{className:"card__kind",style:{color:"var(--err)"},children:u.length}),children:u.map((y,w)=>(0,l.jsxs)("div",{className:"fld__err",style:{padding:"6px 0"},children:[(0,l.jsx)(A.warn,{})," ",y.message]},w))})]})]})}function mm(e,t,n){let r=new Map(t.map(u=>[u.id,u])),o=new Set,i=[],a=u=>{if(!o.has(u)){o.add(u);for(let s of n)s.to===u&&a(s.from);if(u!==e){let s=r.get(u);s&&i.push(s)}}};a(e);for(let u of t)u.type.startsWith("trigger.")&&!o.has(u.id)&&u.id!==e&&i.push(u);return i}function vm({node:e,nodes:t,edges:n}){let r=(0,ne.useMemo)(()=>mm(e.id,t,n),[e.id,t,n]);return r.length===0?(0,l.jsx)(L,{title:"Available inputs",defaultOpen:!1,children:(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)"},children:["No upstream nodes yet \u2014 connect a trigger or upstream node to make its outputs available as ",(0,l.jsx)("span",{className:"mono",children:"{{nodeId.path}}"})," templates here."]})}):(0,l.jsx)(L,{title:`Available inputs (${r.length})`,defaultOpen:!1,right:(0,l.jsx)("span",{className:"card__kind",style:{color:"var(--muted)"},children:"click to copy"}),children:(0,l.jsx)("div",{style:{display:"grid",gap:10},children:r.map(o=>(0,l.jsx)(ym,{node:o},o.id))})})}function ym({node:e}){let t=cs[e.type],n=t?dp(e.type,e.config):[];return(0,l.jsxs)("div",{style:{border:"1px solid var(--line)",borderRadius:6,padding:8,background:"var(--bg)"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,l.jsx)("span",{className:"mono",style:{fontSize:11,color:"var(--ink-2)"},children:e.id}),(0,l.jsx)("span",{className:"insp__type-pill",style:{fontSize:10},children:e.type})]}),t?.summary&&(0,l.jsx)("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:6},children:t.summary}),n.length===0?(0,l.jsx)("div",{style:{fontSize:11,color:"var(--muted)"},children:"No declared outputs."}):(0,l.jsx)("div",{style:{display:"grid",gap:2},children:n.map(r=>(0,l.jsx)(wm,{nodeId:e.id,field:r},r.path))})]})}function wm({nodeId:e,field:t}){let[n,r]=(0,ne.useState)(!1),o=t.path?`{{${e}.${t.path}}}`:`{{${e}}}`;return(0,l.jsxs)("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(o),r(!0),window.setTimeout(()=>r(!1),900)}catch{}},title:t.description,style:{textAlign:"left",display:"grid",gridTemplateColumns:"1fr auto",gap:6,padding:"4px 6px",background:n?"var(--ok-soft, rgba(0, 200, 100, 0.12))":"transparent",border:"1px solid transparent",borderRadius:4,cursor:"pointer",color:"var(--ink-1)",fontSize:11,lineHeight:1.35},children:[(0,l.jsx)("span",{className:"mono",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o}),(0,l.jsx)("span",{style:{color:n?"var(--ok, #2ea043)":"var(--muted)",fontSize:10},children:n?"copied":t.type})]})}function xm({node:e,patchData:t}){let[n,r]=(0,ne.useState)(()=>JSON.stringify(e.config,null,2)),[o,i]=(0,ne.useState)(null);return(0,ne.useMemo)(()=>{r(JSON.stringify(e.config,null,2)),i(null)},[e.id]),(0,l.jsxs)(L,{title:"Raw config JSON",children:[(0,l.jsx)(Ri,{mono:!0,rows:14,value:n,onChange:r}),(0,l.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,l.jsxs)("button",{className:"btn btn--ghost-icon",onClick:()=>{try{let u=JSON.parse(n);u&&typeof u=="object"&&!Array.isArray(u)?(t(u),i(null)):i("config must be a JSON object")}catch(u){i(u.message)}},children:[(0,l.jsx)(A.check,{})," Apply"]}),(0,l.jsxs)("button",{className:"btn btn--ghost-icon",onClick:()=>r(JSON.stringify(e.config,null,2)),children:[(0,l.jsx)(A.undo,{})," Reset"]})]}),o&&(0,l.jsxs)("div",{className:"fld__err",style:{color:"var(--err)",fontSize:11,marginTop:4},children:[(0,l.jsx)(A.err,{})," ",o]})]})}function km({meta:e,patchMeta:t,onDeleteWorkflow:n,isNew:r}){let o=e.retention??{maxRuns:500,maxDays:90};return(0,l.jsxs)("aside",{className:"insp",children:[(0,l.jsx)("div",{className:"insp__head",children:(0,l.jsxs)("div",{className:"insp__top",children:[(0,l.jsx)("span",{className:"insp__type-pill",children:"workflow"}),(0,l.jsx)("input",{className:"insp__name",value:e.title,placeholder:"Untitled workflow",onChange:i=>t({title:i.target.value})})]})}),(0,l.jsxs)("div",{className:"insp__body",children:[(0,l.jsxs)(L,{title:"Identity",children:[(0,l.jsx)(k,{label:"ID",hint:r?"URL slug \u2014 set once on first save":"URL slug \u2014 read-only after creation",children:(0,l.jsx)(R,{mono:!0,value:e.id,onChange:i=>r&&t({id:i})})}),(0,l.jsx)(k,{label:"Title",children:(0,l.jsx)(R,{value:e.title,onChange:i=>t({title:i})})}),(0,l.jsx)(k,{label:"Description",hint:"Optional one-liner shown on the workflows index",children:(0,l.jsx)(Ri,{rows:2,value:e.description??"",onChange:i=>t({description:i})})})]}),(0,l.jsxs)(L,{title:"Execution",children:[(0,l.jsx)(k,{label:"Priority",hint:"Higher numbers run before lower ones when multiple workflows match the same trigger",children:(0,l.jsx)(on,{value:e.priority,onChange:i=>t({priority:i??0}),placeholder:"0"})}),(0,l.jsx)(k,{label:"",children:(0,l.jsx)(Li,{checked:!!e.fanOut,onChange:i=>t({fanOut:i}),label:"Fan out \u2014 let multiple workflows match the same trigger event"})}),(0,l.jsx)(k,{label:"Secrets this flow may use",hint:"Comma-separated. Only these env names are exposed to actions/agents in this flow.",children:(0,l.jsx)(vt,{mono:!0,value:e.envAllow??[],onChange:i=>t({envAllow:i}),placeholder:"GITLAB_TOKEN, SLACK_WEBHOOK"})})]}),(0,l.jsxs)(L,{title:"Retention",defaultOpen:!1,children:[(0,l.jsx)(k,{label:"How many runs to keep",children:(0,l.jsx)(on,{value:o.maxRuns,onChange:i=>t({retention:{...o,maxRuns:i??0}}),placeholder:"500"})}),(0,l.jsx)(k,{label:"Keep runs for (days)",children:(0,l.jsx)(on,{value:o.maxDays,onChange:i=>t({retention:{...o,maxDays:i??0}}),placeholder:"90"})})]}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",padding:"4px 16px 14px",borderTop:"1px solid var(--line-soft)",marginTop:4},children:["Tip: pick a node or edge on the canvas to edit its config. Each node's output becomes available as"," ",(0,l.jsx)("span",{className:"mono",children:"{{nodeId.path}}"})," to downstream nodes."]}),n&&!r&&(0,l.jsx)("div",{className:"insp__danger",children:(0,l.jsxs)("button",{className:"btn btn--ghost-icon insp__delete-wf",onClick:n,title:"Delete this workflow permanently",children:[(0,l.jsx)(A.trash,{})," Delete workflow"]})})]})]})}function bm({edge:e,patch:t,onDelete:n}){return(0,l.jsxs)("aside",{className:"insp",children:[(0,l.jsx)("div",{className:"insp__head",children:(0,l.jsxs)("div",{className:"insp__top",children:[(0,l.jsx)("span",{className:"insp__type-pill",children:"edge"}),(0,l.jsxs)("div",{className:"insp__name",style:{padding:0,fontSize:13,color:"var(--ink-2)"},children:[(0,l.jsx)("span",{className:"mono",children:e.from}),e.fromPort?(0,l.jsxs)("span",{className:"mono",children:[" :",e.fromPort]}):null," \u2192 ",(0,l.jsx)("span",{className:"mono",children:e.to})]}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",onClick:n,children:(0,l.jsx)(A.trash,{})})]})}),(0,l.jsxs)("div",{className:"insp__body",children:[(0,l.jsx)(L,{title:"Label",children:(0,l.jsx)(k,{label:"Label",hint:"Shown on the edge (cosmetic only)",children:(0,l.jsx)(R,{mono:!0,value:e.label??"",onChange:r=>t({label:r})})})}),(0,l.jsx)(L,{title:"Port",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Leaves from",hint:"Set when the source is a branch node. Must match a case's `to` field or the default port.",children:(0,l.jsx)(R,{mono:!0,value:e.fromPort??"",onChange:r=>t({fromPort:r||void 0})})})})]})]})}var St=oe(Nt(),1);var $=oe(Ce(),1);function hp({onLoadTemplate:e}){let[t,n]=(0,St.useState)(""),[r,o]=(0,St.useState)([]);(0,St.useEffect)(()=>{let u=!0;return fetch("/api/n8n/workflows").then(s=>s.json()).then(s=>{if(!u)return;let c=(s.workflows??[]).filter(d=>d.webhookUrl).map(d=>({id:"n8n."+d.id,type:"action.callHTTP",label:d.name,hint:d.active?"Hands this over to n8n":"In n8n, but switched off there",glyph:"g-action",icon:"globe",config:{url:d.webhookUrl,method:"POST",body:"{{trigger}}"}}));o(c.length?[{section:"From your n8n",items:c}]:[])}).catch(()=>{}),()=>{u=!1}},[]);let i=(0,St.useMemo)(()=>[...ls,...r],[r]),a=(0,St.useMemo)(()=>{if(!t.trim())return i;let u=t.toLowerCase();return i.map(s=>({...s,items:s.items.filter(c=>c.label.toLowerCase().includes(u)||c.hint.toLowerCase().includes(u)||c.type.includes(u))})).filter(s=>s.items.length>0)},[t,i]);return(0,$.jsxs)("aside",{className:"pal",children:[(0,$.jsxs)("div",{className:"pal__search",children:[(0,$.jsx)(A.search,{}),(0,$.jsx)("input",{value:t,onChange:u=>n(u.target.value),placeholder:"Search nodes\u2026"}),(0,$.jsx)("kbd",{children:"/"})]}),(0,$.jsxs)("div",{className:"pal__scroll",children:[a.map(u=>(0,$.jsxs)(St.Fragment,{children:[(0,$.jsxs)("div",{className:"pal__section",children:[(0,$.jsx)("span",{children:u.section}),(0,$.jsx)("span",{className:"pal__section-count",children:u.items.length.toString().padStart(2,"0")})]}),u.items.map(s=>(0,$.jsx)(_m,{item:s},s.id))]},u.section)),!t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{className:"pal__section",children:[(0,$.jsx)("span",{children:"Templates"}),(0,$.jsx)("span",{className:"pal__section-count",children:us.length.toString().padStart(2,"0")})]}),us.map(u=>(0,$.jsxs)("div",{className:"pal__tpl",onClick:()=>e(u),children:[(0,$.jsx)("div",{className:"pal__tpl-dots",children:[0,1,2].map(s=>(0,$.jsx)("span",{className:s<u.dots?"on":""},s))}),(0,$.jsx)("div",{className:"pal__tpl-title",children:u.title}),(0,$.jsx)("div",{className:"pal__tpl-hint",children:u.hint})]},u.id))]})]}),(0,$.jsxs)("div",{className:"pal__foot",children:[(0,$.jsx)(A.lightning,{}),(0,$.jsx)("span",{children:"Drag items onto the canvas"})]})]})}function _m({item:e}){let t=A[e.icon]??A.box;return(0,$.jsxs)("div",{className:"pal__item",draggable:!0,onDragStart:r=>{r.dataTransfer.setData("application/x-wfe-item",JSON.stringify(e)),r.dataTransfer.effectAllowed="copy";let o=document.createElement("div");o.textContent=e.label,o.style.cssText="position:absolute;top:-1000px;padding:6px 10px;background:var(--accent);color:#fff;border-radius:6px;font:500 12px 'Space Grotesk';",document.body.appendChild(o),r.dataTransfer.setDragImage(o,10,10),setTimeout(()=>document.body.removeChild(o),0)},children:[(0,$.jsx)("div",{className:"pal__glyph "+e.glyph,children:(0,$.jsx)(t,{})}),(0,$.jsxs)("div",{className:"pal__meta",children:[(0,$.jsx)("div",{className:"pal__label",children:e.label}),(0,$.jsx)("div",{className:"pal__hint",children:e.hint})]})]})}var gs=oe(Nt(),1);var _=oe(Ce(),1);function mp(e){return(0,_.jsxs)("div",{className:"tb",children:[(0,_.jsxs)("div",{className:"tb__brand",children:[(0,_.jsx)("div",{className:"tb__mark",children:"\u2726"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"tb__brand-label",children:"Workflow Editor"}),(0,_.jsx)("div",{className:"tb__brand-sub",children:e.workflowIdLabel})]})]}),(0,_.jsxs)("div",{className:"tb__main",children:[(0,_.jsxs)("div",{className:"tb__crumbs",children:[(0,_.jsx)("a",{href:"/workflows",children:"Workflows"}),(0,_.jsx)("span",{className:"sep",children:"/"}),(0,_.jsx)("input",{value:e.title,onChange:t=>e.setTitle(t.target.value)})]}),(0,_.jsx)("span",{className:"tb__sep"}),(0,_.jsxs)("div",{className:"tb__status "+e.status,children:[(0,_.jsx)("span",{className:"dot"}),e.statusLabel??(e.status==="is-dirty"?"unsaved":e.status==="is-running"?"running":e.status==="is-validating"?"validating\u2026":"saved")]}),(0,_.jsx)("div",{className:"tb__spacer"}),(0,_.jsx)("button",{className:"btn btn--ghost-icon"+(e.paletteOpen?" is-active":""),title:e.paletteOpen?"Hide palette":"Show palette",onClick:()=>e.setPaletteOpen(!e.paletteOpen),children:(0,_.jsx)(A.panelLeft,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon"+(e.inspectorOpen?" is-active":""),title:e.inspectorOpen?"Hide inspector":"Show inspector",onClick:()=>e.setInspectorOpen(!e.inspectorOpen),children:(0,_.jsx)(A.panelRight,{})}),(0,_.jsx)("span",{className:"tb__sep"}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Undo (\u2318Z)",onClick:e.onUndo,disabled:!e.canUndo,children:(0,_.jsx)(A.undo,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Redo (\u2318\u21E7Z)",onClick:e.onRedo,disabled:!e.canRedo,children:(0,_.jsx)(A.redo,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Auto layout",onClick:e.onLayout,children:(0,_.jsx)(A.layout,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Keyboard shortcuts",onClick:e.onHelp,children:(0,_.jsx)(A.kbd,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon"+(e.tweaksOpen?" is-active":""),title:"Tweaks",onClick:()=>e.setTweaksOpen(!e.tweaksOpen),children:(0,_.jsx)(A.gear,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Toggle theme",onClick:()=>e.setTheme(e.theme==="dark"?"light":"dark"),children:e.theme==="dark"?(0,_.jsx)(A.sun,{}):(0,_.jsx)(A.moon,{})})]}),(0,_.jsxs)("div",{className:"tb__actions",children:[(0,_.jsxs)("button",{className:"btn btn--outline",onClick:e.onSave,children:[(0,_.jsx)(A.save,{})," Save"]}),(0,_.jsx)("button",{className:"btn btn--primary",onClick:e.onRun,children:e.running?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(A.stop2,{})," Stop"]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(A.run,{})," Run preview"]})})]})]})}function vp({running:e,script:t,cursor:n,onStop:r}){if(!e)return null;let o=t.filter(i=>i.nodeId);return(0,_.jsxs)("div",{className:"run",children:[(0,_.jsxs)("div",{className:"run__head",children:[(0,_.jsx)(A.lightning,{}),(0,_.jsx)("div",{className:"run__title",children:"Live run"}),(0,_.jsxs)("span",{className:"run__chip",children:[(0,_.jsx)("span",{className:"dot"})," streaming"]}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",onClick:r,style:{height:24,width:24},children:(0,_.jsx)(A.x,{})})]}),(0,_.jsx)("div",{className:"run__body",children:o.map((i,a)=>{let u=t.indexOf(i),s=u<n,c=["run__step"];return s&&c.push("is-done"),u===n&&c.push("is-current"),(0,_.jsxs)("div",{className:c.join(" "),children:[(0,_.jsx)("div",{className:"run__marker",children:s?(0,_.jsx)(A.check,{}):a+1}),(0,_.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,_.jsx)("div",{className:"run__step-title",children:i.title}),i.body&&(0,_.jsx)("div",{className:"run__step-body",dangerouslySetInnerHTML:{__html:i.body}})]})]},a)})}),(0,_.jsxs)("div",{className:"run__foot",children:[(0,_.jsxs)("span",{children:[Math.min(n+1,t.length),"/",t.length]}),(0,_.jsxs)("span",{children:[t.length?Math.round((n+1)/t.length*100):0,"%"]})]})]})}var Sm=[{h:255,name:"indigo"},{h:220,name:"blue"},{h:180,name:"teal"},{h:145,name:"green"},{h:70,name:"amber"},{h:28,name:"orange"},{h:330,name:"pink"}];function yp(e){return e.open?(0,_.jsxs)("div",{className:"tweaks",children:[(0,_.jsxs)("div",{className:"tweaks__head",children:[(0,_.jsx)("span",{children:"Tweaks"}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",style:{height:22,width:22},onClick:()=>e.setOpen(!1),children:(0,_.jsx)(A.x,{})})]}),(0,_.jsxs)("div",{className:"tweaks__body",children:[(0,_.jsxs)("div",{className:"tweaks__row",children:[(0,_.jsx)("label",{children:"Theme"}),(0,_.jsx)("div",{className:"tweaks__opts",children:["dark","light"].map(t=>(0,_.jsx)("button",{className:e.theme===t?"on":"",onClick:()=>e.setTheme(t),children:t},t))})]}),(0,_.jsxs)("div",{className:"tweaks__row",children:[(0,_.jsx)("label",{children:"Density"}),(0,_.jsx)("div",{className:"tweaks__opts",children:["compact","cozy","roomy"].map(t=>(0,_.jsx)("button",{className:e.density===t?"on":"",onClick:()=>e.setDensity(t),children:t},t))})]}),(0,_.jsxs)("div",{className:"tweaks__row",style:{alignItems:"flex-start",flexDirection:"column",gap:6},children:[(0,_.jsx)("label",{children:"Accent hue"}),(0,_.jsx)("div",{className:"tweaks__hue",children:Sm.map(t=>(0,_.jsx)("button",{title:t.name,className:e.hue===t.h?"on":"",style:{background:`oklch(0.70 0.16 ${t.h})`},onClick:()=>e.setHue(t.h)},t.h))})]})]})]}):null}function wp({open:e,onClose:t}){return e?(0,_.jsx)("div",{className:"kbd-overlay",onClick:t,children:(0,_.jsxs)("div",{className:"kbd-card",onClick:r=>r.stopPropagation(),children:[(0,_.jsx)("h3",{children:"Keyboard shortcuts"}),[["Save workflow","\u2318S"],["Undo / Redo","\u2318Z / \u2318\u21E7Z"],["Delete selection","Delete"],["Duplicate node","\u2318D"],["Run preview","\u2318\u23CE"],["Focus search","/"],["Fit view","F"],["Close panels","Esc"]].map(([r,o])=>(0,_.jsxs)("div",{className:"row",children:[(0,_.jsx)("span",{children:r}),(0,_.jsx)("span",{children:o.split(" ").map((i,a)=>(0,_.jsxs)(gs.Fragment,{children:[i.includes("/")?i.split("/").map((u,s)=>(0,_.jsxs)(gs.Fragment,{children:[s>0&&" / ",(0,_.jsx)("kbd",{children:u.trim()})]},s)):(0,_.jsx)("kbd",{children:i})," "]},a))})]},r))]})}):null}var Me=oe(Nt(),1),V=oe(Ce(),1),ms="agentx.editor.chat.v1";function xp({currentWorkflow:e,onApplyWorkflow:t,agentId:n}){let[r,o]=(0,Me.useState)(!1),[i,a]=(0,Me.useState)(()=>Tm()),[u,s]=(0,Me.useState)(""),[c,d]=(0,Me.useState)(!1),p=(0,Me.useRef)(null),m=(0,Me.useRef)(null);(0,Me.useEffect)(()=>{let g=i.filter(f=>!f.pending).map(f=>({role:f.role,content:f.content}));try{sessionStorage.setItem(ms,JSON.stringify(g))}catch{}},[i]),(0,Me.useEffect)(()=>{let g=p.current;g&&(g.scrollTop=g.scrollHeight)},[i,r]),(0,Me.useEffect)(()=>{r&&m.current?.focus()},[r]);let y=(0,Me.useCallback)(async()=>{let g=u.trim();if(!g||c)return;let f=i.filter(x=>!x.pending).map(x=>({role:x.role,content:x.content})),h=[...i,{role:"user",content:g},{role:"assistant",content:"\u2026",pending:!0}];a(h),s(""),d(!0);try{let x=await fetch("/api/workflows/editor/chat",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-Requested-With":"agentx-board"},body:JSON.stringify({messages:[...f,{role:"user",content:g}],currentWorkflow:e,agentId:n})}),C=await x.json().catch(()=>({}));x.ok?a(P=>hs(P,{role:"assistant",content:C.reply||"",workflow:C.workflow||void 0})):a(P=>hs(P,{role:"assistant",content:"",error:C.error||`HTTP ${x.status}`}))}catch(x){a(C=>hs(C,{role:"assistant",content:"",error:x?.message||"network error"}))}finally{d(!1)}},[n,c,e,u,i]),w=()=>{a([]);try{sessionStorage.removeItem(ms)}catch{}},S=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),y())},H=(0,Me.useMemo)(()=>["Describe the process you want \u2014 I'll generate the workflow.","","Examples:",'\u2022 "Expense approval: employee submits form, manager approves over $500 otherwise auto-approve"','\u2022 "Telegram bot that classifies messages as billing/bug/other and routes to the right agent"',`\u2022 "Triage a GitLab issue: label 'bug' \u2192 dev agent; label 'feature' \u2192 product agent; otherwise close"`].join(`
1341
+ `;var Pp=oe(tp(),1);var O=oe(Nt(),1);var Be=oe(Nt(),1);var v=oe(Ce(),1),D=({children:e,size:t=14,...n})=>(0,v.jsx)("svg",{viewBox:"0 0 16 16",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",...n,children:e}),A={gitlab:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M8 14L2 7l1.2-4.5L5 7h6l1.8-4.5L14 7z"})}),clock:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,v.jsx)("path",{d:"M8 5v3l2 1.5"})]}),hook:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M4 3v4a4 4 0 0 0 4 4h4"}),(0,v.jsx)("path",{d:"M10 9l2 2-2 2"})]}),play:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M5 3.5l7 4.5-7 4.5z",fill:"currentColor"})}),box:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"1.5"}),(0,v.jsx)("path",{d:"M2.5 6h11M6 2.5v11"})]}),branch:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"4",cy:"4",r:"1.5"}),(0,v.jsx)("circle",{cx:"12",cy:"12",r:"1.5"}),(0,v.jsx)("circle",{cx:"12",cy:"4",r:"1.5"}),(0,v.jsx)("path",{d:"M4 5.5v3a2 2 0 0 0 2 2h4.5"}),(0,v.jsx)("path",{d:"M12 5.5v5"})]}),stop:()=>(0,v.jsx)(D,{children:(0,v.jsx)("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),msg:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M2.5 3.5h11v8h-6l-3 2.5v-2.5h-2z"})}),tag:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M8 2h5v5l-6 6-5-5z"}),(0,v.jsx)("circle",{cx:"10.5",cy:"5.5",r:.8,fill:"currentColor"})]}),bell:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M4 11V7a4 4 0 0 1 8 0v4l1 1.5H3zM6.5 13.5a1.5 1.5 0 0 0 3 0"})}),globe:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,v.jsx)("path",{d:"M2.5 8h11M8 2.5c2 2 2 9 0 11M8 2.5c-2 2-2 9 0 11"})]}),search:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"7",cy:"7",r:"4"}),(0,v.jsx)("path",{d:"M10 10l3.5 3.5"})]}),undo:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M4 7h6a3 3 0 0 1 0 6H7"}),(0,v.jsx)("path",{d:"M6.5 4.5L4 7l2.5 2.5"})]}),redo:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M12 7H6a3 3 0 0 0 0 6h3"}),(0,v.jsx)("path",{d:"M9.5 4.5L12 7 9.5 9.5"})]}),save:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M3 3h8l2 2v8H3z"}),(0,v.jsx)("path",{d:"M5 3v4h6V3M5 13v-4h6v4"})]}),run:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M5 3.5l7 4.5-7 4.5z",fill:"currentColor"})}),stop2:()=>(0,v.jsx)(D,{children:(0,v.jsx)("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1",fill:"currentColor"})}),sun:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"2.75"}),(0,v.jsx)("path",{d:"M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.5 3.5l1.4 1.4M11.1 11.1l1.4 1.4M3.5 12.5l1.4-1.4M11.1 4.9l1.4-1.4"})]}),moon:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M13 9.5A5.5 5.5 0 0 1 6.5 3 5.5 5.5 0 1 0 13 9.5z"})}),plus:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M8 3v10M3 8h10"})}),trash:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 4.5h10M6 4.5V3h4v1.5M4.5 4.5l.5 8h6l.5-8"})}),chev:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M4 6l4 4 4-4"})}),x:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M4 4l8 8M12 4l-8 8"})}),more:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"4",cy:"8",r:"1",fill:"currentColor",stroke:"none"}),(0,v.jsx)("circle",{cx:"8",cy:"8",r:"1",fill:"currentColor",stroke:"none"}),(0,v.jsx)("circle",{cx:"12",cy:"8",r:"1",fill:"currentColor",stroke:"none"})]}),check:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 8.5l3 3 7-7"})}),warn:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M8 2l6 11H2z"}),(0,v.jsx)("path",{d:"M8 6.5v3M8 11.2v.3"})]}),err:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"5.5"}),(0,v.jsx)("path",{d:"M8 5v3.5M8 10.5v.3"})]}),zoomin:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"7",cy:"7",r:"4"}),(0,v.jsx)("path",{d:"M10 10l3.5 3.5M5 7h4M7 5v4"})]}),zoomout:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"7",cy:"7",r:"4"}),(0,v.jsx)("path",{d:"M10 10l3.5 3.5M5 7h4"})]}),fit:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M3 5V3h2M13 5V3h-2M3 11v2h2M13 11v2h-2"}),(0,v.jsx)("rect",{x:"6",y:"6",width:"4",height:"4",rx:.5})]}),minus:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 8h10"})}),kbd:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"1.5",y:"4",width:"13",height:"8",rx:"1.5"}),(0,v.jsx)("path",{d:"M4 7h.5M6 7h.5M8 7h.5M10 7h.5M4 10h7"})]}),lightning:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M9 2L3 9h4l-1 5 6-7H8z",fill:"currentColor",fillOpacity:.2})}),variable:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M4 3c-2 3-2 7 0 10M12 3c2 3 2 7 0 10"}),(0,v.jsx)("path",{d:"M6 7.5h.5l1 1 1-1h.5M6 10l1.5-1.5M9 10l-1.5-1.5"})]}),users:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"6",cy:"6",r:"2"}),(0,v.jsx)("path",{d:"M2.5 12c.5-2 2-3 3.5-3s3 1 3.5 3"}),(0,v.jsx)("circle",{cx:"11",cy:"5",r:"1.5"}),(0,v.jsx)("path",{d:"M10 10.5c.5-1 1.2-1.5 2-1.5 1 0 2 .8 2.3 2"})]}),grid:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2.5",y:"2.5",width:"4",height:"4"}),(0,v.jsx)("rect",{x:"9.5",y:"2.5",width:"4",height:"4"}),(0,v.jsx)("rect",{x:"2.5",y:"9.5",width:"4",height:"4"}),(0,v.jsx)("rect",{x:"9.5",y:"9.5",width:"4",height:"4"})]}),eye:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M1.5 8C3 5 5.3 3.5 8 3.5S13 5 14.5 8C13 11 10.7 12.5 8 12.5S3 11 1.5 8z"}),(0,v.jsx)("circle",{cx:"8",cy:"8",r:"1.8"})]}),slide:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2.5",y:"3.5",width:"11",height:"9",rx:"1"}),(0,v.jsx)("path",{d:"M5 6h6M5 8.5h4M5 11h5"})]}),gear:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("circle",{cx:"8",cy:"8",r:"2"}),(0,v.jsx)("path",{d:"M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.5 3.5l1.4 1.4M11.1 11.1l1.4 1.4M3.5 12.5l1.4-1.4M11.1 4.9l1.4-1.4"})]}),flag:()=>(0,v.jsx)(D,{children:(0,v.jsx)("path",{d:"M3 13V3h7l-1 2.5L10 8H3"})}),dup:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),(0,v.jsx)("path",{d:"M3 9V3h6"})]}),layout:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("path",{d:"M2.5 3.5h11v9h-11z"}),(0,v.jsx)("path",{d:"M2.5 7h11M7 7v5.5"})]}),panelLeft:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,v.jsx)("path",{d:"M6 3v10"}),(0,v.jsx)("rect",{x:"2.5",y:"3.5",width:"3.5",height:"9",fill:"currentColor",fillOpacity:.18,stroke:"none"})]}),panelRight:()=>(0,v.jsxs)(D,{children:[(0,v.jsx)("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),(0,v.jsx)("path",{d:"M10 3v10"}),(0,v.jsx)("rect",{x:"10",y:"3.5",width:"3.5",height:"9",fill:"currentColor",fillOpacity:.18,stroke:"none"})]})};var ls=[{section:"What starts it",items:[{id:"trigger.channel.whatsapp",type:"trigger.channel",label:"A WhatsApp message",hint:"Someone messages you on WhatsApp",glyph:"g-trigger",icon:"msg"},{id:"trigger.channel.telegram",type:"trigger.channel",label:"A Telegram message",hint:"Someone messages you on Telegram",glyph:"g-trigger",icon:"msg"},{id:"trigger.channel.gitlab",type:"trigger.channel",label:"Something on GitLab",hint:"An issue, merge request or pipeline changes",glyph:"g-trigger",icon:"gitlab"},{id:"trigger.hook.n8n",type:"trigger.hook",label:"n8n hands work over",hint:"n8n calls this workflow \u2014 it keeps the connectors, you keep the agents",glyph:"g-trigger",icon:"hook"},{id:"trigger.hook",type:"trigger.hook",label:"Something calls in",hint:"Any service that can POST a webhook",glyph:"g-trigger",icon:"hook"},{id:"trigger.cron",type:"trigger.cron",label:"A time of day",hint:"Runs on a schedule you set",glyph:"g-trigger",icon:"clock"},{id:"trigger.poll",type:"trigger.poll",label:"Something new shows up",hint:"Checks a command every so often; runs once per new item",glyph:"g-trigger",icon:"clock"},{id:"trigger.manual",type:"trigger.manual",label:"You start it",hint:"Only runs when you press run",glyph:"g-trigger",icon:"play"},{id:"trigger.form",type:"trigger.form",label:"Someone fills a form",hint:"A person submits a form to begin",glyph:"g-trigger",icon:"plus"}]},{section:"Put an agent on it",items:[{id:"node.agent",type:"agent",label:"Ask an agent",hint:"Give an agent the job, in your own words",glyph:"g-state",icon:"box"},{id:"node.transform",type:"transform",label:"Reshape the data",hint:"Build a value out of earlier steps",glyph:"g-state",icon:"variable"}]},{section:"Bring in a person",items:[{id:"node.userTask",type:"userTask",label:"Ask a person",hint:"Send someone a form and wait for their answer",glyph:"g-state",icon:"box"},{id:"node.checkpoint",type:"checkpoint",label:"Wait for approval",hint:"Hold here until someone says go",glyph:"g-branch",icon:"flag"},{id:"node.timer.boundary",type:"timer.boundary",label:"Wait a while",hint:"Pause for an hour, a day, however long",glyph:"g-branch",icon:"clock"},{id:"node.owner.notify",type:"owner.notify",label:"Tell me",hint:"Send yourself a note through your notifications",glyph:"g-action",icon:"msg"},{id:"node.owner.ask",type:"owner.ask",label:"Ask me to decide",hint:"A decision card; goes on with yes, no or no answer",glyph:"g-branch",icon:"flag"},{id:"node.person.message",type:"person.message",label:"Message someone",hint:"Write to an employee or a client, once you approve the text",glyph:"g-action",icon:"msg"},{id:"node.person.wait",type:"person.wait",label:"Wait for their reply",hint:"Hold until they answer or send a file, with a deadline and reminders",glyph:"g-branch",icon:"clock"}]},{section:"Decide what happens next",items:[{id:"node.classify",type:"classify",label:"Sort it into buckets",hint:"Pick one of your labels \u2014 and take the \u201Cnot sure\u201D path when it cannot tell",glyph:"g-branch",icon:"branch"},{id:"node.branch",type:"branch",label:"If this, then that",hint:"Send the run down one path or another",glyph:"g-branch",icon:"branch"},{id:"node.rule",type:"rule",label:"A table of rules",hint:"Several conditions at once; first match wins",glyph:"g-branch",icon:"branch"},{id:"node.gateway.parallel",type:"gateway.parallel",label:"Do several at once",hint:"Split into parallel paths, then join them",glyph:"g-branch",icon:"branch"},{id:"node.end",type:"end",label:"Finish",hint:"The run ends here",glyph:"g-end",icon:"stop"}]},{section:"Do something",items:[{id:"action.send",type:"action.send",label:"Send a message",hint:"Post to WhatsApp, Telegram, GitLab \u2014 anywhere you have a channel",glyph:"g-action",icon:"msg"},{id:"action.createIssue",type:"action.createIssue",label:"Open an issue",hint:"Create a new GitLab issue",glyph:"g-action",icon:"plus"},{id:"action.setLabel",type:"action.setLabel",label:"Change a label",hint:"Add or remove labels",glyph:"g-action",icon:"tag"},{id:"action.react",type:"action.react",label:"React to a message",hint:"Add an emoji reaction",glyph:"g-action",icon:"msg"},{id:"action.editMessage",type:"action.editMessage",label:"Edit a message",hint:"Change a message you already sent",glyph:"g-action",icon:"msg"},{id:"action.readLabel",type:"action.readLabel",label:"Read a label",hint:"Look at the labels on an issue before deciding",glyph:"g-action",icon:"tag"},{id:"action.callHTTP",type:"action.callHTTP",label:"Call a web address",hint:"Hand work to n8n, or any service with a URL",glyph:"g-action",icon:"globe"},{id:"action.builtin",type:"action.builtin",label:"Use a built-in step",hint:"Fetch a page, extract fields, and other bundled helpers",glyph:"g-action",icon:"lightning"},{id:"action.run",type:"action.run",label:"Run a saved action",hint:"Invoke something from your action registry",glyph:"g-action",icon:"lightning"},{id:"action.logTime",type:"action.logTime",label:"Log time spent",hint:"Record how long this took",glyph:"g-action",icon:"clock"}]},{section:"Talk to other workflows",items:[{id:"node.subProcess",type:"subProcess",label:"Run another workflow",hint:"Call one, and carry on when it finishes",glyph:"g-state",icon:"box"},{id:"node.signal.emit",type:"signal.emit",label:"Tell other workflows",hint:"Announce that something happened",glyph:"g-action",icon:"msg"},{id:"node.signal.wait",type:"signal.wait",label:"Wait to be told",hint:"Hold until another workflow announces it",glyph:"g-branch",icon:"flag"}]}],ss=[{group:"issue",items:[{path:"issue.title",type:"string"},{path:"issue.labels",type:"string[]"},{path:"issue.assignee",type:"string?"},{path:"issue.author",type:"string"},{path:"issue.body",type:"string"},{path:"issue.iid",type:"number"},{path:"issue.url",type:"string"}]},{group:"run",items:[{path:"run.id",type:"string"},{path:"run.state",type:"string"},{path:"run.workflow",type:"string"},{path:"run.homeNode",type:"string"}]},{group:"pipeline",items:[{path:"pipeline.status",type:"enum"},{path:"pipeline.ref",type:"string"},{path:"pipeline.id",type:"number"}]},{group:"state",items:[{path:"state.previous",type:"string?"},{path:"state.next",type:"string?"}]},{group:"env",items:[{path:"env.GITLAB_TOKEN",type:"secret (allowlist req.)"},{path:"env.GITLAB_HOST",type:"string (allowlist req.)"}]}],us=[{id:"tpl.gitlab",title:"GitLab issue lifecycle",hint:"Triage \u2192 Review \u2192 QA \u2192 Done \xB7 5 states",dots:3},{id:"tpl.mr",title:"MR review loop",hint:"Agent-driven 3-state review",dots:2},{id:"tpl.blank",title:"Blank canvas",hint:"Start from a single trigger",dots:1}],ip=[{id:"triage-agent",name:"Triage Agent",tags:["default"],color:200},{id:"dev-agent",name:"Dev Agent",tags:["default"],color:145},{id:"code-reviewer",name:"Code Reviewer",tags:["default"],color:28}];function ap(e){for(let t of ls){let n=t.items.find(r=>r.type===e);if(n)return n.label}return e}function lp(e,t){let n=o=>typeof t[o]=="string"?t[o].trim():"",r=(o,i=70)=>o.length>i?o.slice(0,i-1)+"\u2026":o;switch(e){case"trigger.channel":return n("source")?`when ${n("source")} has activity`:"";case"trigger.cron":return n("schedule")?`at ${n("schedule")}`:"";case"trigger.hook":return n("event")==="on:n8n"?"when n8n calls":n("event")?`on ${n("event")}`:"";case"trigger.poll":return n("actionId")?`new items from ${n("actionId")}`:"";case"trigger.form":return n("formId")?`form: ${n("formId")}`:"";case"agent":{let o=n("agentId")||n("agent"),i=n("prompt")||n("message");return[o&&`ask ${o}`,i&&r(i)].filter(Boolean).join(" \u2014 ")}case"action.send":return r(n("text")||n("body"))||n("channel")&&`to ${n("channel")}`;case"action.callHTTP":return r(n("url"));case"action.builtin":return n("name");case"action.run":return n("action")||n("name");case"action.createIssue":return r(n("title"));case"action.setLabel":return n("label")?`label: ${n("label")}`:"";case"subProcess":return n("workflowId")?`runs ${n("workflowId")}`:"";case"signal.emit":case"signal.wait":return n("signal")?`signal: ${n("signal")}`:"";case"timer.boundary":return n("duration")?`waits ${n("duration")}`:"";case"userTask":return n("assignTo")?`asks ${n("assignTo")}`:"";case"owner.notify":return r(n("text"));case"owner.ask":return r(n("ask"));case"person.message":return[n("to")&&`to ${n("to")}`,r(n("text"))].filter(Boolean).join(" \u2014 ");case"person.wait":return n("timeout")?`waits up to ${n("timeout")}`:"";case"branch":{let o=Array.isArray(t.cases)?t.cases.length:0;return o?`${o} way${o===1?"":"s"} out`:""}default:return""}}var F=oe(Ce(),1),ch={trigger:220,state:240,branch:260,action:220,end:160,agent:240,checkpoint:220,transform:220},dh={trigger:46,state:118,branch:110,action:78,end:46,agent:118,checkpoint:92,transform:78};function up(e){return e.startsWith("trigger.")?"trigger":e.startsWith("action.")?"action":e}function nr(e){let t=up(e.type);return{w:ch[t]??220,h:dh[t]??100}}function rr(e){return e.position?.x??0}function or(e){return e.position?.y??0}function Ii(e,t){let{w:n,h:r}=nr(e),o=rr(e),i=or(e);return t==="in"?{x:o,y:i+r/2}:t==="out"?{x:o+n,y:i+r/2}:t==="true"?{x:o+n,y:i+r*.3}:t==="false"?{x:o+n,y:i+r*.7}:{x:o+n/2,y:i+r/2}}function sp(e,t){let n=Math.max(40,Math.abs(t.x-e.x)*.45);return`M ${e.x} ${e.y} C ${e.x+n} ${e.y}, ${t.x-n} ${t.y}, ${t.x} ${t.y}`}function ph(e){let{n:t,selected:n,state:r}=e,{w:o}=nr(t),i=up(t.type),a=lp(t.type,t.config??{}),u=t.config,s=i==="trigger"?u.source==="cron"?"clock":u.source==="webhook"||u.source==="hook"?"hook":u.source==="manual"?"play":"gitlab":i==="agent"?"box":i==="branch"?"branch":i==="action"?t.type==="action.send"?"msg":t.type==="action.setLabel"?"tag":t.type==="action.react"?"bell":t.type==="action.callHTTP"?"globe":t.type==="action.logTime"?"clock":t.type==="action.createIssue"?"plus":"lightning":i==="checkpoint"?"flag":i==="transform"?"variable":"stop",c=A[s]??A.box,d=["node",`t-${i}`,n&&"is-selected",r==="running"&&"is-running",r==="visited"&&"is-visited",r==="error"&&"is-error"].filter(Boolean).join(" "),p={left:rr(t),top:or(t),width:o},m=u.agentId,y=u.prompt;return(0,F.jsxs)("div",{className:d,style:p,onMouseDown:w=>e.onMouseDown?.(w,t),onClick:w=>e.onClick?.(w,t),onDoubleClick:w=>e.onDoubleClick?.(w,t),children:[(0,F.jsx)("div",{className:"node__stripe"}),(0,F.jsxs)("div",{className:"node__head",children:[(0,F.jsx)("div",{className:"node__icon",children:(0,F.jsx)(c,{})}),(0,F.jsxs)("div",{className:"node__meta",children:[(0,F.jsx)("div",{className:"node__kind",children:ap(t.type)}),(0,F.jsx)("div",{className:"node__name",children:t.id})]}),i!=="trigger"&&i!=="end"&&(0,F.jsx)("div",{className:"node__chev",children:(0,F.jsx)(A.more,{})})]}),a&&(0,F.jsx)("div",{className:"node__body",children:(0,F.jsx)("div",{className:"node__row node__row--summary",children:a})}),i!=="trigger"&&(0,F.jsx)("div",{className:"handle h-in",onMouseDown:w=>e.onPortDown?.(w,t,"in"),onMouseEnter:()=>e.onPortEnter?.(t,"in"),onMouseLeave:()=>e.onPortLeave?.()}),i==="branch"?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("div",{className:"handle h-true",onMouseDown:w=>e.onPortDown?.(w,t,"true"),onMouseEnter:()=>e.onPortEnter?.(t,"true"),onMouseLeave:()=>e.onPortLeave?.(),children:(0,F.jsx)("span",{className:"handle__label",children:"true"})}),(0,F.jsx)("div",{className:"handle h-false",onMouseDown:w=>e.onPortDown?.(w,t,"false"),onMouseEnter:()=>e.onPortEnter?.(t,"false"),onMouseLeave:()=>e.onPortLeave?.(),children:(0,F.jsx)("span",{className:"handle__label",children:"false"})})]}):i!=="end"&&(0,F.jsx)("div",{className:"handle h-out",onMouseDown:w=>e.onPortDown?.(w,t,"out"),onMouseEnter:()=>e.onPortEnter?.(t,"out"),onMouseLeave:()=>e.onPortLeave?.()})]})}function fh({nodes:e,viewBox:t,selection:n,hostRef:r}){let[o,i]=(0,Be.useState)(!1);if(!e.length)return null;let a=60,u=e.map(E=>rr(E)),s=e.map(E=>or(E)),c=e.map(E=>nr(E).w),d=e.map(E=>nr(E).h),p=Math.min(...u)-a,m=Math.min(...s)-a,y=Math.max(...u.map((E,K)=>E+c[K]))+a,w=Math.max(...s.map((E,K)=>E+d[K]))+a,S=y-p,H=w-m,g=r.current?.getBoundingClientRect(),f=g?.width??800,h=g?.height??500,x=-t.tx/t.zoom,C=-t.ty/t.zoom,P=f/t.zoom,M=h/t.zoom;return(0,F.jsxs)("div",{className:"cv__mini"+(o?" is-collapsed":""),children:[(0,F.jsxs)("div",{className:"cv__mini-head",children:[(0,F.jsx)("span",{children:"Map"}),(0,F.jsx)("button",{onClick:()=>i(!o),children:(0,F.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",children:(0,F.jsx)("path",{d:o?"M2 4l3 3 3-3":"M2 6l3-3 3 3",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"})})})]}),!o&&(0,F.jsxs)("svg",{viewBox:`${p} ${m} ${S} ${H}`,preserveAspectRatio:"xMidYMid meet",children:[(0,F.jsx)("rect",{className:"mini-view",x,y:C,width:P,height:M}),e.map(E=>{let K=nr(E),W=n?.kind==="node"&&n.id===E.id;return(0,F.jsx)("rect",{className:"mini-node"+(W?" sel":""),x:rr(E),y:or(E),width:K.w,height:K.h,rx:3},E.id)})]})]})}function cp(e){let{nodes:t,edges:n,selection:r,setSelection:o,onNodeMove:i,onAddNode:a,onConnect:u,runState:s,viewBox:c,setViewBox:d}=e,p=(0,Be.useRef)(null),[m,y]=(0,Be.useState)(null),[w,S]=(0,Be.useState)(null),[H,g]=(0,Be.useState)(!1),[f,h]=(0,Be.useState)(null),[x,C]=(0,Be.useState)(null),[P,M]=(0,Be.useState)(null),{zoom:E,tx:K,ty:W}=c,ve=(N,j)=>{let U=p.current;if(!U)return{x:0,y:0};let Y=U.getBoundingClientRect();return{x:(N-Y.left-K)/E,y:(j-Y.top-W)/E}},ir=N=>{let j=N.target;j!==N.currentTarget&&!j.classList.contains("cv__viewport")||N.button!==0&&N.button!==1||(o(null),C({startX:N.clientX,startY:N.clientY,tx:K,ty:W}))},Sn=(N,j)=>{if(N.target.classList.contains("handle"))return;N.stopPropagation(),o({kind:"node",id:j.id});let U=ve(N.clientX,N.clientY);y({id:j.id,offX:U.x-rr(j),offY:U.y-or(j)})},ar=(N,j,U)=>{N.stopPropagation(),N.preventDefault();let Y=Ii(j,U);S({from:{id:j.id,port:U},x:Y.x,y:Y.y})},ao=(N,j)=>{w&&h({id:N.id,port:j})},lr=()=>h(null);(0,Be.useEffect)(()=>{let N=U=>{if(m){let Y=ve(U.clientX,U.clientY);i(m.id,Y.x-m.offX,Y.y-m.offY)}else if(w){let Y=ve(U.clientX,U.clientY);S(q=>q&&{...q,x:Y.x,y:Y.y})}else x&&d(Y=>({...Y,tx:x.tx+(U.clientX-x.startX),ty:x.ty+(U.clientY-x.startY)}))},j=()=>{w&&f&&f.id!==w.from.id&&u({from:w.from.id,fromPort:w.from.port,to:f.id,toPort:"in"}),y(null),S(null),C(null),h(null)};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",j)}},[m,w,x,f,u,i,d]);let at=N=>{if(!N.ctrlKey&&!N.metaKey&&Math.abs(N.deltaY)<30){d(Z=>({...Z,tx:Z.tx-N.deltaX,ty:Z.ty-N.deltaY}));return}N.preventDefault();let j=p.current;if(!j)return;let U=j.getBoundingClientRect(),Y=N.clientX-U.left,q=N.clientY-U.top,Ge=-N.deltaY*.0015;d(Z=>{let qe=Math.min(2,Math.max(.3,Z.zoom*(1+Ge))),ze=qe/Z.zoom;return{zoom:qe,tx:Y-(Y-Z.tx)*ze,ty:q-(q-Z.ty)*ze}})},lt=()=>d(N=>({...N,zoom:Math.min(2,N.zoom*1.15)})),Ai=()=>d(N=>({...N,zoom:Math.max(.3,N.zoom/1.15)})),Di=()=>{let N=p.current;if(!N||!t.length)return;let j=N.getBoundingClientRect(),U=60,Y=1/0,q=1/0,Ge=-1/0,Z=-1/0;t.forEach(st=>{let cr=nr(st),dr=rr(st),lo=or(st);Y=Math.min(Y,dr),q=Math.min(q,lo),Ge=Math.max(Ge,dr+cr.w),Z=Math.max(Z,lo+cr.h)});let qe=Ge-Y+U*2,ze=Z-q+U*2,ye=Math.min(1,Math.min(j.width/qe,j.height/ze));d({zoom:ye,tx:(j.width-qe*ye)/2-(Y-U)*ye,ty:(j.height-ze*ye)/2-(q-U)*ye})},sr=N=>{N.preventDefault(),g(!0)},Cn=()=>g(!1),ur=N=>{N.preventDefault(),g(!1);let j=N.dataTransfer.getData("application/x-wfe-item");if(j)try{let U=JSON.parse(j),Y=ve(N.clientX,N.clientY);a(U,Y.x-100,Y.y-40)}catch{}},ji=N=>{let j=N.id??"",U=["wfe-edge"];return r?.kind==="edge"&&r.id===j&&U.push("is-selected"),P===j&&U.push("is-hover"),s?.currentEdgeId===j&&U.push("is-running"),j&&s?.visitedEdges?.has(j)&&U.push("is-visited"),N.fromPort==="true"&&U.push("is-true"),N.fromPort==="false"&&U.push("is-false"),U.join(" ")},Ui=N=>s?.currentNodeId===N.id?"running":s?.visitedNodes?.has(N.id)?"visited":null,Wi=(0,Be.useMemo)(()=>{if(!w)return null;let N=t.find(Y=>Y.id===w.from.id);if(!N)return null;let j=Ii(N,w.from.port),U={x:w.x,y:w.y};return(0,F.jsx)("svg",{className:"cv__ghost-edge",width:"4000",height:"2400",children:(0,F.jsx)("path",{d:sp(j,U)})})},[w,t]);return(0,F.jsxs)("div",{className:"cv"+(x?" is-panning":"")+(H?" is-drop-target":""),ref:p,onWheel:at,onMouseDown:ir,onDragOver:sr,onDragLeave:Cn,onDrop:ur,children:[(0,F.jsxs)("div",{className:"cv__viewport",style:{transform:`translate(${K}px, ${W}px) scale(${E})`},children:[(0,F.jsxs)("svg",{className:"cv__edges",width:"4000",height:"2400",children:[(0,F.jsxs)("defs",{children:[(0,F.jsx)("marker",{id:"arr",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"currentColor"})}),(0,F.jsx)("marker",{id:"arr-ok",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"var(--ok)"})}),(0,F.jsx)("marker",{id:"arr-err",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"var(--err)"})}),(0,F.jsx)("marker",{id:"arr-acc",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto",children:(0,F.jsx)("path",{d:"M0 0L10 5L0 10z",fill:"var(--accent)"})})]}),n.map((N,j)=>{let U=t.find(st=>st.id===N.from),Y=t.find(st=>st.id===N.to);if(!U||!Y)return null;let q=N.id??`e-${j}`,Ge=Ii(U,N.fromPort??"out"),Z=Ii(Y,N.toPort??"in"),qe=sp(Ge,Z),ze={x:(Ge.x+Z.x)/2,y:(Ge.y+Z.y)/2},ye=s?.currentEdgeId===q||s?.visitedEdges?.has(q)?"url(#arr-acc)":N.fromPort==="true"?"url(#arr-ok)":N.fromPort==="false"?"url(#arr-err)":"url(#arr)";return(0,F.jsxs)("g",{children:[(0,F.jsx)("path",{className:"edge-bg",d:qe,onMouseEnter:()=>M(q),onMouseLeave:()=>M(null),onClick:()=>o({kind:"edge",id:q})}),(0,F.jsx)("path",{className:ji(N),d:qe,markerEnd:ye}),N.label&&(0,F.jsxs)("g",{transform:`translate(${ze.x},${ze.y})`,children:[(0,F.jsx)("rect",{className:"edge-label-bg",x:-N.label.length*3.6-6,y:-9,rx:3,width:N.label.length*7.2+12,height:18}),(0,F.jsx)("text",{className:"edge-label",y:4,textAnchor:"middle",children:N.label})]})]},q)})]}),Wi,t.map(N=>(0,F.jsx)(ph,{n:N,selected:r?.kind==="node"&&r.id===N.id,state:Ui(N),onMouseDown:Sn,onPortDown:ar,onPortEnter:ao,onPortLeave:lr,onClick:(j,U)=>{j.stopPropagation(),o({kind:"node",id:U.id})}},N.id))]}),(0,F.jsxs)("div",{className:"cv__controls",children:[(0,F.jsx)("button",{title:"Zoom out",onClick:Ai,children:(0,F.jsx)(A.zoomout,{})}),(0,F.jsxs)("div",{className:"cv__zoom",children:[Math.round(E*100),"%"]}),(0,F.jsx)("button",{title:"Zoom in",onClick:lt,children:(0,F.jsx)(A.zoomin,{})}),(0,F.jsx)("button",{title:"Fit",onClick:Di,children:(0,F.jsx)(A.fit,{})})]}),(0,F.jsx)(fh,{nodes:t,viewBox:c,selection:r,hostRef:p})]})}var ne=oe(Nt(),1);var gh=[{path:"channel",type:"string",description:"Channel name that received the event.",example:'"whatsapp"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"chatId",type:"string",description:"Stable chat id \u2014 conversation partner JID (WhatsApp) or chat integer (Telegram). Use as `action.send` chatId to reply on the same thread.",example:'"10000000000@s.whatsapp.net"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"accountId",type:"string",description:"Which bot account received the message. Telegram routes this per-account; inherit into `action.send` to reply through the same bot.",example:'"default"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"text",type:"string",description:"Message body (caption for media), lower-cased for routing but the raw text here is verbatim.",example:'"hello"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"fromJid",type:"string",description:"Raw sender JID/id straight from the platform. Use `sender.id` for the normalized form.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"sender.id",type:"string",description:"Normalized sender id.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"sender.name",type:"string",description:"Display name, e.g. WhatsApp pushName or Telegram first_name.",example:'"Alex"',sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"sender.username",type:"string",description:"Platform-specific handle when available (Telegram @username, ...).",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"group.id",type:"string",description:"Group chat id when the message came from a group; undefined for DMs.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"group.name",type:"string",description:"Group display name when available.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"replyTo",type:"string",description:"ID of the message this one quoted, when any.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"replyToText",type:"string",description:"Text of the quoted message when available.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"media.path",type:"string",description:"Filesystem path of the attached media after download.",sourceFilter:["whatsapp-message","telegram-message"]},{path:"media.type",type:"string",description:"MIME type of the media (`image/jpeg`, `audio/ogg`, ...).",sourceFilter:["whatsapp-message","telegram-message"]},{path:"event.id",type:"string",description:"Platform message id. Use as `action.send` replyTo to thread replies.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"event.timestamp",type:"string",description:"ISO-8601 timestamp of the source message.",sourceFilter:["whatsapp-message","telegram-message","discord-message","slack-message"]},{path:"issue.iid",type:"number",description:"GitLab internal issue id (per project).",example:"42",sourceFilter:["gitlab-issue"]},{path:"issue.title",type:"string",description:"Issue title.",sourceFilter:["gitlab-issue"]},{path:"issue.description",type:"string",description:"Issue description body.",sourceFilter:["gitlab-issue"]},{path:"issue.url",type:"string",description:"Web URL of the issue.",sourceFilter:["gitlab-issue"]},{path:"issue.action",type:"string",description:"Action that triggered the event (`open`, `update`, `close`, ...).",sourceFilter:["gitlab-issue"]},{path:"issue.labels",type:"array",description:"Current labels on the issue.",sourceFilter:["gitlab-issue"]},{path:"issue.assignees",type:"array",description:"Assignees on the issue.",sourceFilter:["gitlab-issue"]},{path:"project",type:"string",description:"GitLab project path.",example:'"acme/web"',sourceFilter:["gitlab-issue","gitlab-pipeline"]},{path:"chatId",type:"string",description:'Stable entity id for GitLab: "<project>:issue:<iid>" (issue) or "<project>:merge_request:<iid>" (pipeline).',sourceFilter:["gitlab-issue","gitlab-pipeline"]},{path:"channel",type:"string",description:'Always `"gitlab"` for GitLab sources.',sourceFilter:["gitlab-issue","gitlab-pipeline"]},{path:"pipeline.id",type:"number",description:"Pipeline id.",sourceFilter:["gitlab-pipeline"]},{path:"pipeline.status",type:"string",description:"Pipeline status (`success`, `failed`, `canceled`, ...).",sourceFilter:["gitlab-pipeline"]},{path:"pipeline.ref",type:"string",description:"Git ref the pipeline ran on.",sourceFilter:["gitlab-pipeline"]}],hh=[{path:"reply",type:"string",description:"Full agent response text. Most common template target (e.g. echoing it back via `action.send`).",example:'"Got it \u2014 routing to..."'},{path:"result",type:"string",description:"Parsed `RESULT: <token>` marker from the agent's reply (lowercased), or `approved`/`rejected`/`done`/`failed` from a `[BRACKET]`. Used by `branch` nodes to route on agent classification.",example:'"approved"'},{path:"json",type:"any",description:"When `resultParser` is `json`, the parsed first fenced ```json ... ``` block. Useful for structured agent outputs."},{path:"taskId",type:"string",description:"Opaque workflow-scoped task id \u2014 mostly for diagnostics.",example:'"wf-<runId>-<suffix>"'},{path:"durationMs",type:"number",description:"Wall-clock duration of the agent call.",example:"14520"}],mh=[{path:"messageId",type:"string",description:"Platform message id of the sent message. `null` when the adapter couldn't capture it (e.g. mesh-forwarded sends may return null)."},{path:"viaMesh",type:"bool",description:"`true` when the send was forwarded over the mesh to a peer that hosts the channel (workflow on one node, channel adapter on another). Absent for local sends."}],vh=[{path:"issue.iid",type:"number",description:"Newly-created issue iid.",example:"123"},{path:"issue.url",type:"string",description:"Web URL of the new issue."},{path:"issue.webUrl",type:"string",description:"Alias of `issue.url`."}],yh=[{path:"labels",type:"array",description:"Label list after the change."},{path:"add",type:"array",description:"Labels that were added in this call."},{path:"remove",type:"array",description:"Labels that were removed in this call."}],wh=[{path:"labels",type:"array",description:"Current label list on the entity. Use with a `branch` node to route on label state."}],xh=[{path:"emoji",type:"string",description:"The emoji reaction that was applied (echoes the input for debugging)."}],kh=[{path:"edited",type:"bool",description:"`true` when the platform accepted the edit. Treat `false` as a soft miss \u2014 text may have been unchanged or the message was too old."}],bh=[{path:"durationMs",type:"number",description:"Duration logged, in milliseconds (echoed for downstream use)."}],_h=[{path:"ok",type:"bool",description:"Response.ok \u2014 `true` for 2xx."},{path:"status",type:"number",description:"HTTP status code.",example:"200"},{path:"body",type:"any",description:"Parsed JSON body when the response was JSON; otherwise the raw text string."}],Sh=[{path:"ok",type:"bool",description:"`true` when the action exited 0 (shell) or returned 2xx (http)."},{path:"status",type:"number",description:"Exit code (shell) or HTTP status (http)."},{path:"output",type:"string",description:"stdout (shell) or response body text (http). Capped at 32KB."},{path:"errors",type:"string",description:"stderr (shell) or transport error (http). Empty when none."},{path:"durationMs",type:"number",description:"Wall time of the invocation, in milliseconds."}],Ch=[{path:"*",type:"any",description:"The built-in's typed response. Shape depends on the action \u2014 e.g. http.fetch returns {status, statusText, headers, body, truncated, url}; mesh.delegate returns {peer, agent, response}; extract.structured returns {data, model, usage}. See GET /api/actions/builtin for each action's schema."}],Nh=[{path:"port",type:"string",description:"Which outgoing port matched. Downstream edges with `fromPort` matching this value will fire."}],Eh=[{path:"label",type:"string",description:"The label chosen. Also the port that fires.",example:'"bug"'},{path:"result",type:"string",description:"Alias of `label`, so a workflow migrating off an `agent` + RESULT-token node keeps its existing {{node.result}} references working.",example:'"bug"'},{path:"confidence",type:"number",description:"How peaked the distribution was, 0-1. Compare against the node's minConfidence.",example:"0.93"},{path:"probabilities",type:"object",description:"The full distribution over labels \u2014 every label with its probability.",example:'{"bug":0.93,"feature":0.05,"question":0.02}'},{path:"unsure",type:"bool",description:"True when confidence fell below minConfidence and the `unsure` port fired instead of a label port.",example:"false"},{path:"port",type:"string",description:"The port that fired: the chosen label, or `unsure`.",example:'"bug"'}],Th=[{path:"value",type:"any",description:"When config uses `path`, this carries the value picked from context. In `template` mode, keys from the rendered template land at the top level of this node's output (no `.value` prefix)."}],Ph=[{path:"event",type:"any",description:"Payload of the event that resumed this checkpoint. Fields mirror whichever trigger source delivered the resume event."}],Fh=[{path:"name",type:"string",description:"Name of the signal that resumed the wait."},{path:"payload",type:"any",description:"Payload the emitter attached to the signal."},{path:"receivedAt",type:"string",description:"ISO-8601 time the signal was observed."}],Mh=[{path:"emittedAt",type:"string",description:"ISO-8601 time the signal was published."}],Ih=[{path:"firedAt",type:"string",description:"ISO-8601 time the timer elapsed (when resumed)."},{path:"scheduledFor",type:"string",description:"ISO-8601 time the timer was originally scheduled for."}],Rh=[{path:"childRunId",type:"string",description:"Run id of the spawned child workflow."},{path:"result",type:"any",description:"Output bundle of the child's terminal `end` node (if any)."}],cs={"trigger.channel":{summary:"Raw event payload from the source channel. Shape varies by `source` \u2014 the Context panel filters accordingly.",fields:gh},"trigger.manual":{summary:"Arbitrary payload posted by `agentx workflow run <id>` / POST /workflows/:id/run.",fields:[{path:"",type:"any",description:"Whatever JSON the caller supplied."}]},"trigger.cron":{summary:"Scheduled tick \u2014 no data bundle beyond the firing metadata.",fields:[{path:"firedAt",type:"string",description:"ISO-8601 time the tick fired."},{path:"cronSpec",type:"string",description:"The `spec` from the node's config (echoed for debug)."}]},"trigger.hook":{summary:"Fires when a custom hook event bubbles through the registry. Payload is whatever the hook subscriber chose to emit.",fields:[{path:"",type:"any",description:"Hook-specific payload."}]},"trigger.form":{summary:"Starts when a published form receives a submission.",fields:[{path:"formId",type:"string",description:"Form id that received the submission."},{path:"submission",type:"object",description:"Submitted values keyed by field id."},{path:"submittedBy",type:"string",description:"Actor id of the submitter."}]},"trigger.poll":{summary:"Runs a registered action on an interval and starts one run per new item it prints (one JSON object per line). The item is the payload.",fields:[{path:"",type:"any",description:"The item's own fields, e.g. `{{trigger.msgId}}`, `{{trigger.text}}`. Whatever the poll command printed for this item."}]},agent:{summary:"Agent response after executing the prompt template.",fields:hh},classify:{summary:"A typed classification with a full probability distribution. Branches on its own result: the port named after the winning label fires, or `unsure` when nothing clears minConfidence.",fields:Eh},transform:{summary:"Value picked from upstream context (path mode) or rendered template bundle (template mode).",fields:Th},branch:{summary:"Which outgoing port fired. Downstream edges match via `fromPort`.",fields:Nh},"gateway.parallel":{summary:"All incoming branches joined here. No output.",fields:[]},rule:{summary:"Evaluates a declarative rule against context; may short-circuit the walk.",fields:[]},"action.send":{summary:"Dispatched an outbound message through the chosen channel.",fields:mh},"action.createIssue":{summary:"Created an issue on GitLab/GitHub.",fields:vh},"action.setLabel":{summary:"Added/removed labels on a GitLab issue or MR.",fields:yh},"action.readLabel":{summary:"Fetched the current label list \u2014 useful before a `branch`.",fields:wh},"action.react":{summary:"Emoji reaction on a message (Telegram/WhatsApp).",fields:xh},"action.editMessage":{summary:"Edited an existing message in place.",fields:kh},"action.logTime":{summary:"Logged time spent on a GitLab issue/MR.",fields:bh},"action.callHTTP":{summary:"Made an outbound HTTP request with templated params.",fields:_h},"action.run":{summary:"Invoked a registered action from the action registry. Output is the full ActionRunResult.",fields:Sh},"action.builtin":{summary:"Invoked a daemon-shipped typed built-in action (improvement plan #6) by name. Output is the built-in's validated response.",fields:Ch},subProcess:{summary:"Spawned a child workflow and waited for its completion.",fields:Rh},"signal.emit":{summary:"Published a signal to the bus. Runs elsewhere can resume on it via `signal.wait`.",fields:Mh},"signal.wait":{summary:"Paused until a matching signal arrives. Resumes with that signal in this node's output.",fields:Fh},"timer.boundary":{summary:"Paused until a timer elapses. Resumes with timing metadata.",fields:Ih},checkpoint:{summary:"Paused until a matching resume event arrives on this entity.",fields:Ph},end:{summary:"Terminal node \u2014 closes the run with the configured status. No output downstream.",fields:[]},"owner.notify":{summary:"Told the owner, through the node's notifications.",fields:[{path:"text",type:"string",description:"What the owner was told."},{path:"sentAt",type:"string",description:"When (ISO time)."}]},"owner.ask":{summary:"The owner's answer on a decision card. Leaves on port yes, no or expired.",fields:[{path:"port",type:"string",description:"yes, no or expired.",example:'"yes"'},{path:"choice",type:"string",description:"The option the owner picked, when the card offered choices."},{path:"text",type:"string",description:"The draft as the owner approved it, after any edit."},{path:"note",type:"string",description:"The owner's note on the card."},{path:"cardId",type:"string",description:"The decision card's id."}]},"person.message":{summary:"A message to a person, sent once the owner approved it. Leaves on port sent or declined.",fields:[{path:"text",type:"string",description:"The text that was sent (the owner may have edited it)."},{path:"channel",type:"string",description:"Channel it went out on."},{path:"chatId",type:"string",description:"The person's chat."},{path:"messageId",type:"string",description:"Id of the sent message, when the channel gives one."},{path:"approved",type:"string",description:"start (approved with the run) or step (on its own card)."}]},"person.wait":{summary:"A person's reply. Leaves on port reply, or timeout when the deadline passed.",fields:[{path:"text",type:"string",description:"What the person wrote."},{path:"from",type:"string",description:"Sender id."},{path:"media",type:"any",description:"Attached file, when they sent one."},{path:"reminders",type:"number",description:"Reminders sent before the reply came."},{path:"timedOut",type:"bool",description:"True on the timeout port."}]}};function dp(e,t={}){let n=cs[e];if(!n)return[];let r=typeof t.source=="string"?t.source:void 0;return r?n.fields.filter(o=>!o.sourceFilter||o.sourceFilter.includes(r)):n.fields.filter(o=>!o.sourceFilter)}var l=oe(Ce(),1);function L({title:e,children:t,defaultOpen:n=!0,right:r}){let[o,i]=(0,ne.useState)(n);return(0,l.jsxs)("div",{className:"insp__section"+(o?"":" is-collapsed"),children:[(0,l.jsxs)("div",{className:"insp__section-head",onClick:()=>i(!o),children:[(0,l.jsx)("span",{className:"chev",children:(0,l.jsx)(A.chev,{})}),(0,l.jsx)("h4",{children:e}),r]}),(0,l.jsx)("div",{className:"insp__section-body",children:t})]})}function k({label:e,hint:t,err:n,children:r,mono:o}){return(0,l.jsxs)("div",{className:"fld"+(o?" is-mono":"")+(n?" is-err":""),children:[(0,l.jsxs)("div",{className:"fld__label",children:[(0,l.jsx)("span",{children:e}),t&&(0,l.jsx)("span",{className:"fld__hint",children:t})]}),r,n&&(0,l.jsxs)("div",{className:"fld__err",children:[(0,l.jsx)(A.err,{}),n]})]})}function R({value:e,onChange:t,placeholder:n,mono:r,list:o}){return(0,l.jsx)("input",{className:"fld__input"+(r?" mono":""),type:"text",value:e,placeholder:n,list:o,onChange:i=>t(i.target.value)})}function on({value:e,onChange:t,placeholder:n}){return(0,l.jsx)("input",{className:"fld__input",type:"number",value:e??"",placeholder:n,onChange:r=>{let o=r.target.value.trim();t(o===""?void 0:Number(o))}})}function Ri({value:e,onChange:t,rows:n=3,placeholder:r,mono:o}){return(0,l.jsx)("textarea",{className:"fld__input"+(o?" mono":""),rows:n,spellCheck:!1,value:e,placeholder:r,onChange:i=>t(i.target.value)})}function ue({value:e,onChange:t,options:n}){return(0,l.jsx)("select",{className:"fld__select",value:e,onChange:r=>t(r.target.value),children:n.map(r=>{let o=typeof r=="string"?r:r.value,i=typeof r=="string"?r:r.label;return(0,l.jsx)("option",{value:o,children:i},o)})})}function Li({checked:e,onChange:t,label:n}){return(0,l.jsxs)("label",{className:"fld__check",style:{display:"flex",gap:8,alignItems:"center",fontSize:12},children:[(0,l.jsx)("input",{type:"checkbox",checked:e,onChange:r=>t(r.target.checked)}),(0,l.jsx)("span",{children:n})]})}function vt({value:e,onChange:t,placeholder:n,mono:r}){return(0,l.jsx)("input",{className:"fld__input"+(r?" mono":""),type:"text",value:e.join(", "),placeholder:n,onChange:o=>t(o.target.value.split(",").map(i=>i.trim()).filter(Boolean))})}function Lh(e){return typeof e=="boolean"?"boolean":typeof e=="number"?"number":Array.isArray(e)?"list":e&&typeof e=="object"?"json":"string"}function bn({value:e,onChange:t,keyPlaceholder:n="key",valuePlaceholder:r="value",allowedTypes:o=["string","number","boolean","list","json"],emptyHint:i}){let a=Object.entries(e||{}),u=s=>{let c={};for(let[d,p]of s)d&&(c[d]=p);t(c)};return(0,l.jsxs)("div",{className:"kv-editor",children:[a.length===0&&i&&(0,l.jsx)("div",{className:"kv-editor__empty",children:i}),a.map(([s,c],d)=>(0,l.jsx)(Oh,{k:s,v:c,allowedTypes:o,keyPlaceholder:n,valuePlaceholder:r,onKey:p=>{let m=a.slice();m[d]=[p,m[d][1]],u(m)},onValue:p=>{let m=a.slice();m[d]=[m[d][0],p],u(m)},onRemove:()=>{let p=a.slice();p.splice(d,1),u(p)}},d)),(0,l.jsx)("button",{type:"button",className:"kv-editor__add",onClick:()=>u([...a,["",""]]),children:"+ Add field"})]})}function Oh({k:e,v:t,allowedTypes:n,keyPlaceholder:r,valuePlaceholder:o,onKey:i,onValue:a,onRemove:u}){let[s,c]=(0,ne.useState)(Lh(t)),d=p=>{c(p),a(p==="boolean"?typeof t=="boolean"?t:!1:p==="number"?typeof t=="number"?t:Number(t)||0:p==="list"?Array.isArray(t)?t:typeof t=="string"&&t?t.split(",").map(m=>m.trim()):[]:p==="json"?typeof t=="object"&&t&&!Array.isArray(t)?t:{}:typeof t=="string"?t:String(t??""))};return(0,l.jsxs)("div",{className:"kv-editor__row",children:[(0,l.jsx)("input",{className:"fld__input mono kv-editor__key",type:"text",value:e,placeholder:r,onChange:p=>i(p.target.value)}),n.length>1&&(0,l.jsx)("select",{className:"fld__input kv-editor__type",value:s,onChange:p=>d(p.target.value),children:n.map(p=>(0,l.jsx)("option",{value:p,children:p},p))}),(0,l.jsxs)("div",{className:"kv-editor__val",children:[s==="string"&&(0,l.jsx)(kn,{rows:1,value:typeof t=="string"?t:"",onChange:p=>a(p),placeholder:o}),s==="number"&&(0,l.jsx)("input",{className:"fld__input",type:"number",value:typeof t=="number"?String(t):"",onChange:p=>a(p.target.value===""?0:Number(p.target.value))}),s==="boolean"&&(0,l.jsx)(Li,{checked:!!t,onChange:p=>a(p),label:String(!!t)}),s==="list"&&(0,l.jsx)(vt,{value:Array.isArray(t)?t.map(String):[],onChange:p=>a(p),placeholder:"comma,separated,values"}),s==="json"&&(0,l.jsx)("textarea",{className:"fld__input mono kv-editor__json",rows:2,value:JSON.stringify(t??{},null,2),onChange:p=>{try{a(JSON.parse(p.target.value))}catch{}}})]}),(0,l.jsx)("button",{type:"button",className:"kv-editor__remove",onClick:u,title:"Remove field",children:"\xD7"})]})}function kn({value:e,onChange:t,placeholder:n,rows:r=3}){let[o,i]=(0,ne.useState)(!1),[a,u]=(0,ne.useState)(0),s=(0,ne.useRef)(null),c=(0,ne.useMemo)(()=>{let m=[];return ss.forEach(y=>y.items.forEach(w=>m.push({group:y.group,...w}))),m},[]),d=m=>{let y=s.current;if(!y)return;let w=y.selectionStart,S=e.slice(0,w),H=e.slice(w),f=S.endsWith("{{")?S:S+"{{",h=f+m+"}}"+H;t(h),i(!1),requestAnimationFrame(()=>{y.focus();let x=f.length+m.length+2;y.setSelectionRange(x,x)})};return(0,l.jsxs)("div",{className:"expr",style:{position:"relative"},children:[(0,l.jsx)("textarea",{ref:s,className:"fld__input mono",rows:r,spellCheck:!1,value:e,placeholder:n,onChange:m=>t(m.target.value),onKeyDown:m=>{if(!o){m.key==="{"&&m.shiftKey&&i(!0);return}m.key==="ArrowDown"?(m.preventDefault(),u(y=>(y+1)%c.length)):m.key==="ArrowUp"?(m.preventDefault(),u(y=>(y-1+c.length)%c.length)):m.key==="Enter"||m.key==="Tab"?(m.preventDefault(),d(c[a].path)):m.key==="Escape"&&i(!1)}}),(0,l.jsxs)("div",{className:"fld__hint",style:{display:"flex",alignItems:"center",gap:6,marginTop:4},children:[(0,l.jsx)(A.variable,{}),"Type ",(0,l.jsx)("code",{children:"{{"})," to insert a variable \xB7 ",(0,l.jsx)("kbd",{children:"\u2191\u2193"})," ",(0,l.jsx)("kbd",{children:"\u21B5"}),(0,l.jsx)("button",{type:"button",style:{marginLeft:"auto",background:"none",border:"none",color:"inherit",cursor:"pointer"},onClick:()=>i(!o),children:(0,l.jsx)(A.plus,{})})]}),o&&(0,l.jsx)("div",{className:"expr__popover",style:{position:"absolute",left:0,right:0,top:"100%",zIndex:10,background:"var(--bg)",border:"1px solid var(--line)",borderRadius:4,maxHeight:260,overflowY:"auto",boxShadow:"0 6px 20px rgba(0,0,0,0.25)"},children:ss.map(m=>(0,l.jsxs)(ne.Fragment,{children:[(0,l.jsx)("div",{className:"expr__pop-group",style:{padding:"4px 10px",fontSize:10,color:"var(--muted)",textTransform:"uppercase",letterSpacing:.5},children:m.group}),m.items.map(y=>{let w=c.findIndex(H=>H.path===y.path);return(0,l.jsxs)("div",{onMouseEnter:()=>u(w),onClick:()=>d(y.path),style:{padding:"4px 10px",cursor:"pointer",fontSize:11,display:"flex",justifyContent:"space-between",gap:12,fontFamily:"var(--ax-mono, ui-monospace)",background:w===a?"var(--accent-soft)":"transparent"},children:[(0,l.jsx)("span",{children:`{{${y.path}}}`}),(0,l.jsx)("span",{style:{color:"var(--muted)",fontSize:10},children:y.type})]},y.path)})]},m.group))})]})}function zh({value:e,onChange:t,agents:n}){let[r,o]=(0,ne.useState)(!1),[i,a]=(0,ne.useState)(""),u=(0,ne.useRef)(null);(0,ne.useEffect)(()=>{let d=p=>{u.current&&!u.current.contains(p.target)&&o(!1)};return window.addEventListener("mousedown",d),()=>window.removeEventListener("mousedown",d)},[]);let s=n.find(d=>d.id===e),c=n.filter(d=>!i||d.name.toLowerCase().includes(i.toLowerCase())||d.id.includes(i));return(0,l.jsxs)("div",{ref:u,style:{position:"relative"},children:[(0,l.jsxs)("button",{type:"button",className:"fld__input",onClick:()=>o(d=>!d),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",cursor:"pointer"},children:[(0,l.jsx)("span",{style:{display:"inline-flex",width:22,height:22,borderRadius:4,background:`oklch(0.78 0.13 ${s?.color??260})`,color:"#fff",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,flexShrink:0},children:(s?.name??"??").slice(0,2).toUpperCase()}),(0,l.jsxs)("span",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("div",{style:{fontSize:12,fontWeight:500},children:s?.name??"Select agent\u2026"}),(0,l.jsx)("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--ax-mono, ui-monospace)"},children:s?.id??"\u2014"})]}),(0,l.jsx)(A.chev,{})]}),r&&(0,l.jsxs)("div",{style:{position:"absolute",left:0,right:0,top:"100%",zIndex:10,background:"var(--bg)",border:"1px solid var(--line)",borderRadius:4,marginTop:4,maxHeight:280,overflowY:"auto",boxShadow:"0 6px 20px rgba(0,0,0,0.25)"},children:[(0,l.jsx)("div",{style:{padding:6,borderBottom:"1px solid var(--line)"},children:(0,l.jsx)("input",{autoFocus:!0,className:"fld__input",value:i,placeholder:"Filter agents\u2026",onChange:d=>a(d.target.value),style:{width:"100%"}})}),(0,l.jsxs)("div",{children:[c.map(d=>(0,l.jsxs)("div",{onClick:()=>{t(d.id),o(!1),a("")},style:{padding:"6px 10px",cursor:"pointer",display:"flex",gap:8,alignItems:"center",background:d.id===e?"var(--accent-soft)":"transparent"},children:[(0,l.jsx)("span",{style:{display:"inline-flex",width:22,height:22,borderRadius:4,background:`oklch(0.78 0.13 ${d.color})`,color:"#fff",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,flexShrink:0},children:d.name.slice(0,2).toUpperCase()}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("div",{style:{fontSize:12,fontWeight:500},children:d.name}),(0,l.jsx)("div",{style:{fontSize:10,color:"var(--muted)",fontFamily:"var(--ax-mono, ui-monospace)"},children:d.id})]}),d.tags.length>0&&(0,l.jsx)("div",{style:{display:"flex",gap:3},children:d.tags.map(p=>(0,l.jsx)("span",{style:{fontSize:9,color:"var(--muted)",background:"var(--surface)",padding:"1px 5px",borderRadius:3},children:p},p))})]},d.id)),c.length===0&&(0,l.jsx)("div",{style:{padding:10,fontSize:11,color:"var(--muted)"},children:"No agents match."})]})]}),(0,l.jsx)(k,{label:"",hint:"Free text \u2014 type an agent id directly if it isn't in the list yet",children:(0,l.jsx)(R,{value:e??"",onChange:t,placeholder:"agent-id",mono:!0})})]})}var fs={"whatsapp-message":{label:"WhatsApp \u2014 Incoming message",fires:"Fires when a contact or group sends a WhatsApp message to the paired account.",wired:!0,group:"channel-msg",hasLabels:!1},"telegram-message":{label:"Telegram \u2014 Incoming message",fires:"Fires when a Telegram user or group sends a message to the bot.",wired:!0,group:"channel-msg",hasLabels:!1},"discord-message":{label:"Discord \u2014 Incoming message",fires:"Fires when a Discord user posts a message in a watched channel or DM.",wired:!1,group:"channel-msg",hasLabels:!1},"slack-message":{label:"Slack \u2014 Incoming message",fires:"Fires when a Slack user posts a message in a watched channel or DM.",wired:!1,group:"channel-msg",hasLabels:!1},"gitlab-issue":{label:"GitLab \u2014 Issue event",fires:"Fires when a GitLab issue is opened, updated, reopened, or closed.",wired:!0,group:"gitlab",hasLabels:!0},"gitlab-mr":{label:"GitLab \u2014 Merge request event",fires:"Fires when a GitLab merge request is opened, updated, approved, merged, or closed.",wired:!0,group:"gitlab",hasLabels:!0},"gitlab-note":{label:"GitLab \u2014 Comment on issue or MR",fires:"Fires when a comment is posted on a GitLab issue or merge request.",wired:!0,group:"gitlab",hasLabels:!1},"gitlab-pipeline":{label:"GitLab \u2014 Pipeline status change",fires:"Fires when a CI/CD pipeline transitions state (running, success, failed).",wired:!0,group:"gitlab",hasLabels:!1},"github-issue":{label:"GitHub \u2014 Issue event",fires:"Fires when a GitHub issue is opened, updated, or closed (after webhook signature verification).",wired:!0,group:"github",hasLabels:!0},"github-pr":{label:"GitHub \u2014 Pull request event",fires:"Fires when a GitHub pull request is opened, updated, reviewed, merged, or closed.",wired:!0,group:"github",hasLabels:!0},"stripe-event":{label:"Stripe \u2014 Webhook event",fires:"Fires on any Stripe webhook (invoice.paid, customer.subscription.deleted, charge.refunded, etc.). Filter by event type in the workflow body.",wired:!0,group:"external-webhook",hasLabels:!1},"sentry-issue":{label:"Sentry \u2014 Issue alert",fires:"Fires when Sentry triggers an issue alert (new issue, regression, threshold breach).",wired:!0,group:"external-webhook",hasLabels:!1},"vercel-deployment":{label:"Vercel \u2014 Deployment event",fires:"Fires when Vercel reports a deployment state change (created, ready, error).",wired:!0,group:"external-webhook",hasLabels:!1},"odoo-event":{label:"Odoo \u2014 ERP/CRM event",fires:"Fires on any Odoo webhook (contact create, lead won, sale confirmed, invoice paid, project task updated, etc.). Filter by event/model in the workflow body.",wired:!0,group:"external-webhook",hasLabels:!1},"hubspot-event":{label:"HubSpot \u2014 CRM event",fires:"Fires on any HubSpot v3 webhook (contact.creation, deal.propertyChange, conversation.newMessage, etc.). Filter by subscriptionType in the workflow body.",wired:!0,group:"external-webhook",hasLabels:!1}},Ah=Object.entries(fs).map(([e,t])=>({value:e,label:t.wired?`${t.label} \u2713`:`${t.label} \u26A0 schema-only`}));function Dh({node:e,patchData:t}){let n=e.config,r=n.filter??{},o=p=>t({filter:{...r,...p}}),i=String(n.source??"whatsapp-message"),a=fs[i]??fs["whatsapp-message"],u=a.group==="channel-msg",s=a.group==="gitlab",c=a.group==="github",d=u||s||c;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Source",children:[(0,l.jsx)(k,{label:"Event",hint:a.wired?"\u2713 wired end-to-end":"\u26A0 schema-only \u2014 no webhook subscriber configured for this source yet",children:(0,l.jsx)(ue,{value:i,onChange:p=>t({source:p,filter:{}}),options:Ah})}),(0,l.jsx)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:-6,marginBottom:12},children:a.fires})]}),d&&(0,l.jsxs)(L,{title:"Match criteria",children:[(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:8},children:["Limit when this trigger fires. Leave empty or use ",(0,l.jsx)("span",{className:"mono",children:"*"})," to match anything."]}),s&&(0,l.jsx)(k,{label:"Project",hint:'GitLab project path. Empty or "*" matches any.',children:(0,l.jsx)(R,{mono:!0,value:String(r.project??""),onChange:p=>o({project:p}),placeholder:"* (any) or acme/web"})}),c&&(0,l.jsx)(k,{label:"Repo",hint:'GitHub "owner/repo". Empty or "*" matches any.',children:(0,l.jsx)(R,{mono:!0,value:String(r.repo??""),onChange:p=>o({repo:p}),placeholder:"* (any) or owner/repo"})}),u&&(0,l.jsx)(k,{label:"Chat",hint:i==="whatsapp-message"?'Contact number or JID (e.g. "+216 00 000 000", "10000000000@s.whatsapp.net"). Empty or "*" matches any.':i==="telegram-message"?'Telegram chat id ("1816212449" for a DM, "-1003861455814" for a group). Empty or "*" matches any.':'Exact chat id. Empty or "*" matches any.',children:(0,l.jsx)(R,{mono:!0,value:String(r.chat??""),onChange:p=>o({chat:p}),placeholder:"* (any)"})}),a.hasLabels&&(0,l.jsx)(k,{label:"Labels (any of)",hint:"Fires only when at least one of these labels is present on the issue/MR. Empty = no label filter.",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(r.labels)?r.labels:[],onChange:p=>o({labels:p}),placeholder:"bug, needs-review"})})]}),u&&(0,l.jsx)(L,{title:"Routing",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Pass data straight through",hint:"When on, the default agent router ALSO replies alongside this workflow. Use for observability-only workflows (tag, log, forward) that shouldn't own the conversation.",children:(0,l.jsx)(Li,{checked:!!n.passthrough,onChange:p=>t({passthrough:p}),label:"Let the default agent also reply"})})})]})}function jh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Schedule",children:[(0,l.jsx)(k,{label:"When it runs",hint:"5 fields: minute hour day month weekday. E.g. '0 9 * * 1-5' = 9am Mon\u2013Fri.",children:(0,l.jsx)(R,{mono:!0,value:String(n.spec??"0 * * * *"),onChange:r=>t({spec:r}),placeholder:"0 9 * * *"})}),(0,l.jsx)(k,{label:"Timezone",hint:"IANA timezone (e.g. Europe/London, America/New_York). Defaults to UTC.",children:(0,l.jsx)(R,{mono:!0,value:String(n.timezone??"UTC"),onChange:r=>t({timezone:r}),placeholder:"Europe/London"})}),(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:4},children:["Fires the workflow on the schedule. The trigger payload is empty \u2014 downstream nodes won't have ",(0,l.jsx)("span",{className:"mono",children:"{{start.*}}"})," data unless you wire it."]})]})}function Uh({node:e,patchData:t}){let n=e.config,r=Array.isArray(n.filter)?n.filter.length:0;return(0,l.jsxs)(L,{title:"Poll",children:[(0,l.jsx)(k,{label:"Which saved action",hint:"Slug of a registered action (.agentx/actions/<id>.json). It must print one JSON object per line.",children:(0,l.jsx)(R,{mono:!0,value:String(n.actionId??""),onChange:o=>t({actionId:o}),placeholder:"list-new-messages"})}),(0,l.jsx)(k,{label:"Every (seconds)",hint:"How often the action runs. 5 or more; defaults to 60.",children:(0,l.jsx)(on,{value:n.everySeconds,onChange:o=>t({everySeconds:o}),placeholder:"60"})}),(0,l.jsx)(k,{label:"Item key",hint:"Field that identifies an item, e.g. msgId. Each key starts one run, once.",children:(0,l.jsx)(R,{mono:!0,value:String(n.key??""),onChange:o=>t({key:o}),placeholder:"id"})}),(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:4},children:["The first poll only records what is already there. After that, each new item starts one run with its fields as ",(0,l.jsx)("span",{className:"mono",children:"{{trigger.*}}"}),"."," ",r>0?`${r} filter condition(s) set.`:"No filter."," Edit ",(0,l.jsx)("span",{className:"mono",children:"filter"})," under Advanced."]})]})}var ds=[{value:"on:gitlab-issue",label:"on:gitlab-issue",fires:"Fires when a GitLab issue is opened, updated, reopened, or closed (after the channel adapter dispatched it)."},{value:"on:gitlab-mr",label:"on:gitlab-mr",fires:"Fires when a GitLab merge request is opened, updated, approved, merged, or closed."},{value:"on:gitlab-note",label:"on:gitlab-note",fires:"Fires when a comment is posted on a GitLab issue or merge request."},{value:"on:gitlab-pipeline",label:"on:gitlab-pipeline",fires:"Fires when a GitLab CI/CD pipeline transitions state."},{value:"on:github-issue",label:"on:github-issue",fires:"Fires when a GitHub issue is opened, updated, or closed (signature-verified webhook)."},{value:"on:github-pr",label:"on:github-pr",fires:"Fires when a GitHub pull request is opened, reviewed, merged, or closed."},{value:"on:github-push",label:"on:github-push",fires:"Fires on any GitHub push event (branch updates)."},{value:"on:stripe-event",label:"on:stripe-event",fires:"Fires on any Stripe webhook (invoice.paid, charge.refunded, subscription.deleted, etc.). Filter by event type inside the workflow."},{value:"on:sentry-issue",label:"on:sentry-issue",fires:"Fires when a Sentry issue alert lands (new issue, regression, error threshold)."},{value:"on:vercel-deployment",label:"on:vercel-deployment",fires:"Fires when a Vercel deployment changes state."},{value:"on:odoo-event",label:"on:odoo-event",fires:"Fires on any Odoo webhook (res.partner.create, sale.order.action_confirm, account.move.paid, etc.). Filter by event/model inside the workflow."},{value:"on:hubspot-event",label:"on:hubspot-event",fires:"Fires on any HubSpot v3 webhook (contact.creation, deal.propertyChange, conversation.newMessage, etc.). Filter by subscriptionType inside the workflow."},{value:"on:error",label:"on:error",fires:"Fires when an agent task fails. Useful for incident-routing workflows."}];function Wh({node:e,patchData:t}){let n=e.config,r=String(n.event??"on:"),i=ds.find(a=>a.value===r)?.fires??(r.startsWith("on:")&&r!=="on:"?"Custom hook event. Fires whenever code in your agentx setup emits this event via the bus. Subscribe responsibly.":'Hook event names must start with "on:" \u2014 e.g. on:gitlab-issue.');return(0,l.jsxs)(L,{title:"Hook subscription",children:[(0,l.jsxs)(k,{label:"Event",hint:"Pick a known event or type your own (must start with on:)",children:[(0,l.jsx)(R,{mono:!0,value:r,onChange:a=>t({event:a}),placeholder:"on:gitlab-issue",list:"hook-events-list"}),(0,l.jsx)("datalist",{id:"hook-events-list",children:ds.map(a=>(0,l.jsx)("option",{value:a.value,children:a.fires},a.value))})]}),(0,l.jsx)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5,marginTop:-6,marginBottom:4},children:i}),(0,l.jsxs)("details",{style:{marginTop:8},children:[(0,l.jsx)("summary",{style:{cursor:"pointer",fontSize:12,color:"var(--muted)"},children:"Available hook events"}),(0,l.jsx)("ul",{style:{fontSize:11,color:"var(--muted)",paddingLeft:16,marginTop:6},children:ds.map(a=>(0,l.jsxs)("li",{style:{marginBottom:4},children:[(0,l.jsx)("span",{className:"mono",children:a.value})," \u2014 ",a.fires]},a.value))})]})]})}function Hh(e){return(0,l.jsx)(L,{title:"Manual run",children:(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",lineHeight:1.5},children:["No configuration needed. Fire this workflow via:",(0,l.jsx)("pre",{style:{marginTop:8,padding:8,background:"var(--bg)",border:"1px solid var(--line)",borderRadius:4,fontSize:11},children:"agentx workflow run <id>"}),"or ",(0,l.jsx)("span",{className:"mono",children:"POST /workflows/<id>/run"}),"."]})})}function Bh({node:e,patchData:t,agents:n}){let r=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Agent",children:[(0,l.jsx)(k,{label:"Which agent runs",children:(0,l.jsx)(zh,{value:r.agentId,onChange:o=>t({agentId:o}),agents:n})}),(0,l.jsx)(k,{label:"What to ask for",hint:"Supports {{nodeId.path}} variables from upstream context",children:(0,l.jsx)(kn,{value:r.prompt??"",onChange:o=>t({prompt:o}),placeholder:"Classify {{trigger.text}} \u2014 reply RESULT: status-check | new-request | other",rows:5})})]}),(0,l.jsxs)(L,{title:"Behavior",defaultOpen:!1,children:[(0,l.jsx)(k,{label:"How to read the reply",hint:"How to extract a routing token from the agent's reply",children:(0,l.jsx)(ue,{value:String(r.resultParser??"acme-result-token"),onChange:o=>t({resultParser:o}),options:[{value:"acme-result-token",label:"RESULT: token (recommended)"},{value:"json",label:"JSON block (```json \u2026```)"},{value:"raw",label:"Raw reply (no parsing)"}]})}),(0,l.jsx)(k,{label:"Give up after (minutes)",children:(0,l.jsx)(on,{value:r.timeoutMinutes,onChange:o=>t({timeoutMinutes:o}),placeholder:"5"})})]})]})}function Gh({node:e,patchData:t}){let n=e.config,[r,o]=(0,ne.useState)(n.template&&typeof n.template=="object"?"template":"path");return(0,l.jsxs)(L,{title:"Transform",children:[(0,l.jsx)(k,{label:"Mode",children:(0,l.jsx)(ue,{value:r,onChange:i=>{let a=i;o(a),t(a==="path"?{path:n.path??"",template:void 0}:{template:n.template??{},path:void 0})},options:[{value:"path",label:"Pick value from context (dotted path)"},{value:"template",label:"Build a bundle (template object)"}]})}),r==="path"&&(0,l.jsx)(k,{label:"Path",hint:"e.g. classify.reply or trigger.contact.name",children:(0,l.jsx)(R,{mono:!0,value:String(n.path??""),onChange:i=>t({path:i}),placeholder:"classify.reply"})}),r==="template"&&(0,l.jsx)(k,{label:"Template",hint:"One field per output key. String values support {{nodeId.path}} variables.",children:(0,l.jsx)(bn,{value:n.template??{},onChange:i=>t({template:i}),keyPlaceholder:"output key (e.g. greeting)",valuePlaceholder:"hi {{trigger.sender.name}}",emptyHint:"No fields yet \u2014 click + Add field below."})})]})}function $h({node:e,patchData:t}){let n=e.config,r=n.cases??[],o=s=>t({cases:s}),i=(s,c)=>o(r.map((d,p)=>p===s?c:d)),a=(s,c)=>i(s,{...r[s],when:{...r[s].when,...c}}),u=(s,c)=>i(s,{...r[s],when:{...r[s].when,params:{...r[s].when.params,...c}}});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Cases",right:(0,l.jsx)("span",{className:"card__kind",children:r.length}),children:[r.map((s,c)=>{let d=s.when.params??{};return(0,l.jsxs)("div",{style:{border:"1px solid var(--line)",borderRadius:4,padding:10,marginBottom:8,background:"var(--bg)"},children:[(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,l.jsxs)("strong",{style:{fontSize:11},children:["Case #",c+1]}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",onClick:()=>o(r.filter((p,m)=>m!==c)),children:(0,l.jsx)(A.trash,{})})]}),(0,l.jsx)(k,{label:"If",children:(0,l.jsx)(ue,{value:s.when.kind,onChange:p=>a(c,{kind:p,params:{}}),options:[{value:"equals",label:"Path equals value"},{value:"contains",label:"Path contains value"},{value:"matches",label:"Path matches regex"},{value:"exists",label:"Path exists (non-empty)"}]})}),(0,l.jsx)(k,{label:"Path",hint:"e.g. classify.result",children:(0,l.jsx)(R,{mono:!0,value:String(d.path??""),onChange:p=>u(c,{path:p}),placeholder:"classify.result"})}),(s.when.kind==="equals"||s.when.kind==="contains")&&(0,l.jsx)(k,{label:"Value",children:(0,l.jsx)(R,{mono:!0,value:String(d.value??""),onChange:p=>u(c,{value:p})})}),s.when.kind==="matches"&&(0,l.jsx)(k,{label:"Regex",children:(0,l.jsx)(R,{mono:!0,value:String(d.regex??""),onChange:p=>u(c,{regex:p}),placeholder:"^(approved|done)$"})}),(0,l.jsx)(k,{label:"Port",hint:"Outgoing edge's `fromPort` must match this",children:(0,l.jsx)(R,{mono:!0,value:s.to,onChange:p=>i(c,{...s,to:p}),placeholder:"approved"})})]},c)}),(0,l.jsxs)("button",{className:"btn btn--ghost-icon",style:{width:"100%",padding:8,justifyContent:"center"},onClick:()=>o([...r,{when:{kind:"equals",params:{path:"",value:""}},to:`case${r.length+1}`}]),children:[(0,l.jsx)(A.plus,{})," Add case"]})]}),(0,l.jsx)(L,{title:"Fallback",defaultOpen:!1,children:(0,l.jsx)(k,{label:"If nothing matches, go to",hint:"Used when no case matches. Leave blank to drop the event.",children:(0,l.jsx)(R,{mono:!0,value:String(n.default??"fallback"),onChange:s=>t({default:s})})})})]})}function Vh({node:e,patchData:t}){let n=e.config,r=n.waitFor??{},o=a=>t({waitFor:{...r,...a}}),i=n.resumeMatch??{};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Checkpoint",children:(0,l.jsx)(k,{label:"Name",hint:"Human label shown in logs + run timelines",children:(0,l.jsx)(R,{value:String(n.name??e.id),onChange:a=>t({name:a}),placeholder:"await-label-change"})})}),(0,l.jsxs)(L,{title:"Wait for",children:[(0,l.jsx)(k,{label:"Source",hint:"Which kind of event unpauses this run",children:(0,l.jsx)(ue,{value:String(r.source??""),onChange:a=>o({source:a||void 0}),options:[{value:"",label:"Any (same entity)"},{value:"gitlab-issue",label:"GitLab issue update"},{value:"gitlab-pipeline",label:"GitLab pipeline event"},{value:"whatsapp-message",label:"WhatsApp reply"},{value:"telegram-message",label:"Telegram reply"},{value:"manual",label:"Manual poke"}]})}),(0,l.jsx)(k,{label:"Labels (any of)",hint:"e.g. a label change to one of these resumes the run",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(r.labels)?r.labels:[],onChange:a=>o({labels:a.length?a:void 0})})})]}),(0,l.jsx)(L,{title:"Advanced match",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Only if the event mentions",hint:"Optional substring match on the incoming event's id",children:(0,l.jsx)(R,{mono:!0,value:String(i.eventIdLike??""),onChange:a=>t({resumeMatch:{...i,eventIdLike:a||void 0}})})})})]})}function Kh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Terminal",children:[(0,l.jsx)(k,{label:"Status",children:(0,l.jsx)(ue,{value:String(n.status??"completed"),onChange:r=>t({status:r}),options:[{value:"completed",label:"Completed (success)"},{value:"failed",label:"Failed"},{value:"canceled",label:"Canceled"}]})}),(0,l.jsx)(k,{label:"Short summary",hint:"Surfaced in run history + notifications",children:(0,l.jsx)(Ri,{value:String(n.summary??""),onChange:r=>t({summary:r}),rows:2})})]})}var Yh=["gitlab","github","whatsapp","telegram","discord","slack"],ps=new Map,pp=6e4;function Qh(e){let[t,n]=(0,ne.useState)(()=>{let r=ps.get(e);return r&&Date.now()-r.at<pp?{chats:r.chats,source:r.source,loading:!1}:{chats:[],source:"",loading:!0}});return(0,ne.useEffect)(()=>{let r=!1,o=ps.get(e);if(o&&Date.now()-o.at<pp){n({chats:o.chats,source:o.source,loading:!1});return}return n(i=>({...i,loading:!0})),fetch(`/channels/${encodeURIComponent(e)}/chats`).then(i=>i.ok?i.json():{chats:[],source:""}).then(i=>{if(r)return;let a=Array.isArray(i.chats)?i.chats:[],u=typeof i.source=="string"?i.source:"";ps.set(e,{at:Date.now(),chats:a,source:u}),n({chats:a,source:u,loading:!1})}).catch(()=>{r||n({chats:[],source:"",loading:!1})}),()=>{r=!0}},[e]),t}function Jh({node:e,patchData:t,nodes:n}){let r=e.config,o=n.find(c=>c.type.startsWith("trigger."))?.id??"trigger",i=c=>`{{${o}.${c}}}`,a=String(r.channel??"whatsapp"),u=Qh(a),s=`chats-${a}`;return(0,l.jsxs)(L,{title:"Send message",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:a,onChange:c=>t({channel:c}),options:Yh})}),(0,l.jsxs)(k,{label:"Chat id",hint:u.chats.length>0?`Use ${i("chatId")} to reply to the trigger's chat, or pick one of the ${u.chats.length} known chat(s) ${u.source==="local"?"on this node":`from ${u.source}`} (click the field to see the list).`:u.loading?`Loading known chats for "${a}"\u2026`:`Use ${i("chatId")} to reply to the trigger's chat. For a different destination, paste the channel-specific id (no discovered chats for "${a}" yet).`,children:[(0,l.jsx)(R,{mono:!0,value:String(r.chatId??""),onChange:c=>t({chatId:c}),placeholder:i("chatId"),list:u.chats.length>0?s:void 0}),u.chats.length>0&&(0,l.jsx)("datalist",{id:s,children:u.chats.map(c=>(0,l.jsx)("option",{value:c.id,children:c.name?`${c.name} \u2014 ${c.id}${c.kind==="group"?" (group)":""}`:`${c.id}${c.kind==="group"?" (group)":""}`},c.id))})]}),(0,l.jsx)(k,{label:"Text",hint:"Supports {{nodeId.path}} templates from any upstream node",children:(0,l.jsx)(kn,{value:String(r.text??""),onChange:c=>t({text:c}),rows:4,placeholder:`Thanks ${i("sender.name")} \u2014 working on it.`})}),(0,l.jsx)(k,{label:"Account id",hint:"Telegram only: which bot account sends. Leave empty to inherit from the trigger's account (recommended).",children:(0,l.jsx)(R,{mono:!0,value:String(r.accountId??""),onChange:c=>t({accountId:c}),placeholder:`(inherit from ${i("accountId")})`})}),(0,l.jsx)(k,{label:"Reply to which message",hint:"Optional. When set, the platform threads this reply under the referenced message.",children:(0,l.jsx)(R,{mono:!0,value:String(r.replyTo??""),onChange:c=>t({replyTo:c}),placeholder:i("event.id")})}),(0,l.jsx)(k,{label:"Text formatting",hint:r.channel==="telegram"?'Telegram default is "markdown" (Telegram-flavoured HTML conversion). Use "plain" to send raw text without escaping.':"Platform-specific. WhatsApp ignores; Telegram supports markdown/html.",children:(0,l.jsx)(ue,{value:String(r.parseMode??"markdown"),onChange:c=>t({parseMode:c}),options:["markdown","plain","html"]})})]})}function Xh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Target",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab","github"]})}),(0,l.jsx)(k,{label:"Project",hint:'GitLab "group/project" or GitHub "owner/repo"',children:(0,l.jsx)(R,{mono:!0,value:String(n.project??""),onChange:r=>t({project:r}),placeholder:"acme/web"})})]}),(0,l.jsxs)(L,{title:"Issue",children:[(0,l.jsx)(k,{label:"Title",children:(0,l.jsx)(kn,{rows:1,value:String(n.title??""),onChange:r=>t({title:r}),placeholder:"From WhatsApp: {{trigger.sender.name}}"})}),(0,l.jsx)(k,{label:"Description",children:(0,l.jsx)(kn,{rows:6,value:String(n.description??""),onChange:r=>t({description:r}),placeholder:"Reported by {{trigger.sender.name}}\\n\\n{{trigger.text}}"})}),(0,l.jsx)(k,{label:"Labels",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(n.labels)?n.labels:[],onChange:r=>t({labels:r}),placeholder:"Triage, source::whatsapp"})}),(0,l.jsx)(k,{label:"Assignees",hint:"GitLab usernames (resolved to ids at runtime)",children:(0,l.jsx)(vt,{mono:!0,value:Array.isArray(n.assignees)?n.assignees:[],onChange:r=>t({assignees:r}),placeholder:"alice, bob"})})]})]})}function qh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Target",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab","github"]})}),(0,l.jsx)(k,{label:"What it is about",children:(0,l.jsx)(ue,{value:String(n.kind??"issue"),onChange:r=>t({kind:r}),options:["issue","merge_request"]})}),(0,l.jsx)(k,{label:"Project",children:(0,l.jsx)(R,{mono:!0,value:String(n.project??""),onChange:r=>t({project:r}),placeholder:"{{trigger.project}}"})}),(0,l.jsx)(k,{label:"Issue number",children:(0,l.jsx)(R,{mono:!0,value:String(n.iid??""),onChange:r=>t({iid:r}),placeholder:"{{trigger.issue.iid}}"})})]}),(0,l.jsxs)(L,{title:"Labels",children:[(0,l.jsx)(k,{label:"Add",hint:"Comma-separated list",children:(0,l.jsx)(vt,{value:Array.isArray(n.add)?n.add:[],onChange:r=>t({add:r}),placeholder:"In review"})}),(0,l.jsx)(k,{label:"Remove",children:(0,l.jsx)(vt,{value:Array.isArray(n.remove)?n.remove:[],onChange:r=>t({remove:r}),placeholder:"Triage"})})]})]})}function Zh({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Read labels",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab","github"]})}),(0,l.jsx)(k,{label:"What it is about",children:(0,l.jsx)(ue,{value:String(n.kind??"issue"),onChange:r=>t({kind:r}),options:["issue","merge_request"]})}),(0,l.jsx)(k,{label:"Project",children:(0,l.jsx)(R,{mono:!0,value:String(n.project??""),onChange:r=>t({project:r})})}),(0,l.jsx)(k,{label:"Issue number",children:(0,l.jsx)(R,{mono:!0,value:String(n.iid??""),onChange:r=>t({iid:r})})}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginTop:8},children:["Output bundle: ",(0,l.jsx)("span",{className:"mono",children:"{{ <nodeId>.labels }}"})," = string[]"]})]})}function em({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"React",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"telegram"),onChange:r=>t({channel:r}),options:["telegram","whatsapp"]})}),(0,l.jsx)(k,{label:"Chat id",children:(0,l.jsx)(R,{mono:!0,value:String(n.chatId??""),onChange:r=>t({chatId:r}),placeholder:"{{trigger.chatId}}"})}),(0,l.jsx)(k,{label:"Message id",children:(0,l.jsx)(R,{mono:!0,value:String(n.messageId??""),onChange:r=>t({messageId:r}),placeholder:"{{trigger.event.id}}"})}),(0,l.jsx)(k,{label:"Emoji",children:(0,l.jsx)(R,{value:String(n.emoji??"\u{1F440}"),onChange:r=>t({emoji:r})})})]})}function tm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Edit message",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"telegram"),onChange:r=>t({channel:r}),options:["telegram","whatsapp","gitlab","github","discord","slack"]})}),(0,l.jsx)(k,{label:"Chat id",children:(0,l.jsx)(R,{mono:!0,value:String(n.chatId??""),onChange:r=>t({chatId:r})})}),(0,l.jsx)(k,{label:"Message id",children:(0,l.jsx)(R,{mono:!0,value:String(n.messageId??""),onChange:r=>t({messageId:r})})}),(0,l.jsx)(k,{label:"Replace the text with",children:(0,l.jsx)(kn,{value:String(n.text??""),onChange:r=>t({text:r}),rows:3})}),(0,l.jsx)(k,{label:"Text formatting",children:(0,l.jsx)(ue,{value:String(n.parseMode??"plain"),onChange:r=>t({parseMode:r}),options:["plain","markdown","html"]})})]})}function nm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Log time",children:[(0,l.jsx)(k,{label:"Channel",children:(0,l.jsx)(ue,{value:String(n.channel??"gitlab"),onChange:r=>t({channel:r}),options:["gitlab"]})}),(0,l.jsx)(k,{label:"Chat id",hint:'"project:issue:42" or "project:merge_request:7"',children:(0,l.jsx)(R,{mono:!0,value:String(n.chatId??""),onChange:r=>t({chatId:r}),placeholder:"{{trigger.chatId}}"})}),(0,l.jsx)(k,{label:"How long to wait",children:(0,l.jsx)(on,{value:n.durationMs,onChange:r=>t({durationMs:r}),placeholder:"900000"})})]})}function rm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Action",children:(0,l.jsx)(k,{label:"Which saved action",hint:"Slug of a registered action (.agentx/actions/<id>.json). Manage in Settings \u2192 Actions or via `agentx actions`.",children:(0,l.jsx)(R,{mono:!0,value:String(n.actionId??""),onChange:r=>t({actionId:r}),placeholder:"deploy-staging"})})}),(0,l.jsx)(L,{title:"Inputs",defaultOpen:!0,children:(0,l.jsx)(k,{label:"Inputs",hint:"One field per input key. String values support {{nodeId.path}} variables.",children:(0,l.jsx)(bn,{value:n.inputs??{},onChange:r=>t({inputs:r}),keyPlaceholder:"input name (e.g. version)",valuePlaceholder:"{{trigger.tag}}",emptyHint:"No inputs configured."})})}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginTop:8,padding:"0 10px"},children:["Output: ",(0,l.jsx)("span",{className:"mono",children:"{{ <nodeId>.ok / .status / .output / .errors / .durationMs }}"})]})]})}function om({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Request",children:[(0,l.jsx)(k,{label:"URL",children:(0,l.jsx)(R,{mono:!0,value:String(n.url??""),onChange:r=>t({url:r}),placeholder:"https://example.com/webhook"})}),(0,l.jsx)(k,{label:"Method",children:(0,l.jsx)(ue,{value:String(n.method??"POST"),onChange:r=>t({method:r}),options:["GET","POST","PUT","PATCH","DELETE"]})})]}),(0,l.jsx)(L,{title:"Body",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Body",hint:"String \u2014 rendered with {{nodeId.path}}. Server parses as JSON when possible.",children:(0,l.jsx)(kn,{rows:5,value:typeof n.body=="string"?n.body:n.body?JSON.stringify(n.body,null,2):"",onChange:r=>t({body:r})})})}),(0,l.jsx)(L,{title:"Headers",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Headers",hint:"HTTP request headers \u2014 string values support {{env.*}} and {{nodeId.path}}.",children:(0,l.jsx)(bn,{value:n.headers??{},onChange:r=>t({headers:r}),keyPlaceholder:"Header-Name",valuePlaceholder:"Bearer {{env.TOKEN}}",allowedTypes:["string"],emptyHint:"No headers set."})})}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",marginTop:8,padding:"0 10px"},children:["Output: ",(0,l.jsx)("span",{className:"mono",children:"{{ <nodeId>.ok / .status / .body }}"})]})]})}var im=["text","long-text","number","boolean","date","select","multi-select","file"];function fp({form:e,patch:t}){let n=e.fields??[],r=(s,c)=>{let d=[...n];d[s]={...d[s],...c},t({...e,fields:d})},o=(s,c)=>{let d=[...n];d[s]={...d[s],validate:{...d[s].validate??{},...c}},t({...e,fields:d})},i=s=>t({...e,fields:n.filter((c,d)=>d!==s)}),a=(s,c)=>{let d=s+c;if(d<0||d>=n.length)return;let p=[...n];[p[s],p[d]]=[p[d],p[s]],t({...e,fields:p})},u=()=>t({...e,fields:[...n,{key:`field_${n.length+1}`,label:"New field",type:"text"}]});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Form",children:[(0,l.jsx)(k,{label:"Title",hint:"Header shown to the assignee above the form",children:(0,l.jsx)(R,{value:e.title??"",onChange:s=>t({...e,title:s}),placeholder:"Review application"})}),(0,l.jsx)(k,{label:"Description",hint:"Optional one-line context shown under the title",children:(0,l.jsx)(R,{value:e.description??"",onChange:s=>t({...e,description:s}),placeholder:""})}),(0,l.jsx)(k,{label:"Primary button",hint:"Label on the submit button; default: Submit",children:(0,l.jsx)(R,{value:e.submitLabel??"Submit",onChange:s=>t({...e,submitLabel:s})})}),(0,l.jsx)(k,{label:"Secondary action",hint:"Optional reject/hold button. Submissions carry action='secondary'.",children:(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:[(0,l.jsx)(R,{value:e.secondaryAction?.key??"",onChange:s=>t({...e,secondaryAction:s?{key:s,label:e.secondaryAction?.label??s}:void 0}),placeholder:"key (e.g. reject)",mono:!0}),(0,l.jsx)(R,{value:e.secondaryAction?.label??"",onChange:s=>t({...e,secondaryAction:{key:e.secondaryAction?.key??"secondary",label:s}}),placeholder:"label (e.g. Reject)"})]})})]}),(0,l.jsxs)(L,{title:`Fields (${n.length})`,children:[n.length===0&&(0,l.jsx)("div",{className:"hint",style:{fontSize:12,color:"var(--ax-muted)"},children:"No fields \u2014 approve/reject form with no input."}),n.map((s,c)=>(0,l.jsxs)("div",{className:"fld__field-row",style:{border:"1px solid var(--ax-border)",borderRadius:6,padding:8,marginBottom:8},children:[(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:6,alignItems:"end"},children:[(0,l.jsx)(k,{label:"Key",hint:"Stored under values.<key>",children:(0,l.jsx)(R,{mono:!0,value:s.key,onChange:d=>r(c,{key:d})})}),(0,l.jsx)(k,{label:"Label",children:(0,l.jsx)(R,{value:s.label,onChange:d=>r(c,{label:d})})}),(0,l.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>a(c,-1),title:"Move up",children:"\u2191"}),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>a(c,1),title:"Move down",children:"\u2193"}),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>i(c),title:"Remove",children:"\u2715"})]})]}),(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6,marginTop:6},children:[(0,l.jsx)(k,{label:"Type",children:(0,l.jsx)(ue,{value:s.type,onChange:d=>r(c,{type:d}),options:im.slice()})}),(0,l.jsx)(k,{label:"",children:(0,l.jsx)(Li,{checked:!!s.required,onChange:d=>r(c,{required:d}),label:"Required"})})]}),(s.type==="select"||s.type==="multi-select")&&(0,l.jsx)(k,{label:"Options",hint:"Comma-separated list of allowed values",children:(0,l.jsx)(vt,{value:s.options??[],onChange:d=>r(c,{options:d}),placeholder:"low, medium, high"})}),(0,l.jsx)(k,{label:"Hint",hint:"Helper text shown under the input",children:(0,l.jsx)(R,{value:s.hint??"",onChange:d=>r(c,{hint:d})})}),(s.type==="text"||s.type==="long-text"||s.type==="number")&&(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:s.type==="number"?"1fr 1fr":"1fr 1fr 1fr",gap:6},children:[(0,l.jsx)(k,{label:"Min",children:(0,l.jsx)(on,{value:s.validate?.min,onChange:d=>o(c,{min:d})})}),(0,l.jsx)(k,{label:"Max",children:(0,l.jsx)(on,{value:s.validate?.max,onChange:d=>o(c,{max:d})})}),s.type!=="number"&&(0,l.jsx)(k,{label:"Pattern",hint:"Regex \u2014 optional",children:(0,l.jsx)(R,{mono:!0,value:s.validate?.pattern??"",onChange:d=>o(c,{pattern:d})})})]})]},c)),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:u,style:{marginTop:4},children:"+ Add field"})]})]})}function am({node:e,patchData:t}){let n=e.config,r=n.form??{title:"",fields:[],submitLabel:"Submit"};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(L,{title:"Assignment",children:[(0,l.jsx)(k,{label:"Assignee",hint:"actor:<id> or role:<id> \u2014 managed via `agentx actor` / `agentx role`",children:(0,l.jsx)(R,{mono:!0,value:String(n.assignTo??""),onChange:o=>t({assignTo:o}),placeholder:"role:reviewers"})}),(0,l.jsx)(k,{label:"Title",hint:"Shown in the inbox + notification",children:(0,l.jsx)(R,{value:String(n.title??""),onChange:o=>t({title:o})})}),(0,l.jsx)(k,{label:"Description",children:(0,l.jsx)(Ri,{value:String(n.description??""),onChange:o=>t({description:o}),rows:2})}),(0,l.jsx)(k,{label:"Due in",hint:"ISO-8601 duration (PT2H, P1D) or number of minutes",children:(0,l.jsx)(R,{mono:!0,value:String(n.dueIn??""),onChange:o=>t({dueIn:o}),placeholder:"P2D"})})]}),(0,l.jsx)(fp,{form:r,patch:o=>t({form:o})})]})}function lm({node:e,patchData:t}){let n=e.config,r=n.form??{title:"",fields:[],submitLabel:"Submit"};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Start conditions",children:(0,l.jsx)(k,{label:"Who can start it",hint:"actor:<id> or role:<id> \u2014 who is allowed to initiate a new run",children:(0,l.jsx)(R,{mono:!0,value:String(n.startableBy??""),onChange:o=>t({startableBy:o}),placeholder:"role:public"})})}),(0,l.jsx)(fp,{form:r,patch:o=>t({form:o})})]})}function sm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Sub-process",children:[(0,l.jsx)(k,{label:"Which workflow",hint:"id of another workflow definition \u2014 it runs to completion, then parent resumes",children:(0,l.jsx)(R,{mono:!0,value:String(n.workflowId??""),onChange:r=>t({workflowId:r}),placeholder:"child-workflow-id"})}),(0,l.jsx)(k,{label:"Values to pass on",hint:'Map child-context keys \u2192 templated values. Use a single key "*" for full inheritance.',children:(0,l.jsx)(bn,{value:n.inputMap??{},onChange:r=>t({inputMap:r}),keyPlaceholder:"child key",valuePlaceholder:"{{trigger.foo}}",emptyHint:"No mapping \u2014 child workflow runs with no parent context."})})]})}function um({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Emit signal",children:[(0,l.jsx)(k,{label:"Name",hint:"Signal identifier; other workflows' signal.wait nodes subscribe by this",children:(0,l.jsx)(R,{mono:!0,value:String(n.name??""),onChange:r=>t({name:r}),placeholder:"approved"})}),(0,l.jsx)(k,{label:"Scope",hint:"workflow = only same-workflow waiters; global = every waiter",children:(0,l.jsx)(ue,{value:String(n.scope??"workflow"),onChange:r=>t({scope:r}),options:["workflow","global"]})}),(0,l.jsx)(k,{label:"Payload",hint:"Object delivered with the signal. String values support {{nodeId.path}}.",children:(0,l.jsx)(bn,{value:n.payload??{},onChange:r=>t({payload:r}),keyPlaceholder:"payload key",valuePlaceholder:"{{trigger.iid}}",emptyHint:"Empty signal payload."})})]})}function cm({node:e,patchData:t}){let n=e.config;return(0,l.jsxs)(L,{title:"Wait for signal",children:[(0,l.jsx)(k,{label:"Name",children:(0,l.jsx)(R,{mono:!0,value:String(n.name??""),onChange:r=>t({name:r}),placeholder:"approved"})}),(0,l.jsx)(k,{label:"Scope",children:(0,l.jsx)(ue,{value:String(n.scope??"workflow"),onChange:r=>t({scope:r}),options:["workflow","global"]})}),(0,l.jsx)(k,{label:"Only when",hint:"Only resume when every key here matches the emitted payload. Empty = match any payload.",children:(0,l.jsx)(bn,{value:n.match??{},onChange:r=>t({match:r}),keyPlaceholder:"payload key",valuePlaceholder:"expected value",emptyHint:"No filter \u2014 matches any payload."})})]})}function dm({node:e,patchData:t}){let n=e.config;return(0,l.jsx)(L,{title:"Timer",children:(0,l.jsx)(k,{label:"After",hint:"ISO-8601 duration (PT30M, PT2H, P1D) or minutes as a number",children:(0,l.jsx)(R,{mono:!0,value:String(n.after??""),onChange:r=>t({after:r}),placeholder:"PT1H"})})})}function pm({node:e,patchData:t}){let n=e.config;return(0,l.jsx)(L,{title:"Parallel gateway",children:(0,l.jsx)(k,{label:"Mode",hint:"fanOut = send to all outgoing edges; join = wait for every incoming edge",children:(0,l.jsx)(ue,{value:String(n.mode??"fanOut"),onChange:r=>t({mode:r}),options:["fanOut","join"]})})})}function fm({node:e,patchData:t}){let n=e.config,r=Array.isArray(n.inputs)?n.inputs.map(String):[],o=Array.isArray(n.rules)?n.rules:[],i=c=>t({inputs:c,rules:o.map(d=>({...d,when:(Array.isArray(d.when)?d.when.slice(0,c.length):[]).concat(Array(Math.max(0,c.length-(d.when?.length??0))).fill("*"))}))}),a=(c,d)=>{let p=[...o];p[c]={...p[c],...d},t({rules:p})},u=()=>t({rules:[...o,{when:r.map(()=>"*"),to:"port",output:{}}]}),s=c=>t({rules:o.filter((d,p)=>p!==c)});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{title:"Inputs",children:(0,l.jsx)(k,{label:"Values to read",hint:"Comma-separated; each is a template evaluated per-run against the run context",children:(0,l.jsx)(vt,{mono:!0,value:r,onChange:i,placeholder:"{{classify.result}}, {{trigger.values.amount}}"})})}),(0,l.jsxs)(L,{title:`Rules (${o.length})`,children:[o.map((c,d)=>(0,l.jsxs)("div",{style:{border:"1px solid var(--ax-border)",borderRadius:6,padding:8,marginBottom:8},children:[(0,l.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:6,alignItems:"end"},children:[(0,l.jsx)(k,{label:"Goes to",hint:"Outgoing edge port taken when this row matches",children:(0,l.jsx)(R,{mono:!0,value:String(c.to??""),onChange:p=>a(d,{to:p})})}),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:()=>s(d),children:"\u2715"})]}),(0,l.jsx)(k,{label:"When these are true",hint:'One per input. "*" wildcard, "x" equals, ">10" numeric, "!=x", "/regex/"',children:(0,l.jsx)(vt,{mono:!0,value:(Array.isArray(c.when)?c.when:[]).map(String),onChange:p=>a(d,{when:p}),placeholder:"gold, >100"})}),(0,l.jsx)(k,{label:"Output",hint:"Fields written when this rule matches.",children:(0,l.jsx)(bn,{value:c.output??{},onChange:p=>a(d,{output:p}),keyPlaceholder:"output key",valuePlaceholder:"value",emptyHint:"No outputs."})})]},d)),(0,l.jsx)("button",{className:"fld__btn",type:"button",onClick:u,children:"+ Add rule"})]}),(0,l.jsx)(L,{title:"Default",children:(0,l.jsx)(k,{label:"Goes to",children:(0,l.jsx)(R,{mono:!0,value:String(n.default?.to??"fallback"),onChange:c=>t({default:{...n.default??{},to:c}})})})})]})}var gm={"trigger.channel":e=>(0,l.jsx)(Dh,{...e}),"trigger.cron":e=>(0,l.jsx)(jh,{...e}),"trigger.poll":e=>(0,l.jsx)(Uh,{...e}),"trigger.hook":e=>(0,l.jsx)(Wh,{...e}),"trigger.manual":e=>(0,l.jsx)(Hh,{...e}),"trigger.form":e=>(0,l.jsx)(lm,{...e}),agent:e=>(0,l.jsx)(Bh,{...e}),transform:e=>(0,l.jsx)(Gh,{...e}),branch:e=>(0,l.jsx)($h,{...e}),"gateway.parallel":e=>(0,l.jsx)(pm,{...e}),rule:e=>(0,l.jsx)(fm,{...e}),checkpoint:e=>(0,l.jsx)(Vh,{...e}),userTask:e=>(0,l.jsx)(am,{...e}),subProcess:e=>(0,l.jsx)(sm,{...e}),"signal.emit":e=>(0,l.jsx)(um,{...e}),"signal.wait":e=>(0,l.jsx)(cm,{...e}),"timer.boundary":e=>(0,l.jsx)(dm,{...e}),end:e=>(0,l.jsx)(Kh,{...e}),"action.send":e=>(0,l.jsx)(Jh,{...e}),"action.createIssue":e=>(0,l.jsx)(Xh,{...e}),"action.setLabel":e=>(0,l.jsx)(qh,{...e}),"action.readLabel":e=>(0,l.jsx)(Zh,{...e}),"action.react":e=>(0,l.jsx)(em,{...e}),"action.editMessage":e=>(0,l.jsx)(tm,{...e}),"action.logTime":e=>(0,l.jsx)(nm,{...e}),"action.callHTTP":e=>(0,l.jsx)(om,{...e}),"action.run":e=>(0,l.jsx)(rm,{...e})};function gp(e){let{selection:t,nodes:n,edges:r,patch:o,patchData:i,onDelete:a,onDuplicate:u,validation:s,runState:c,agents:d,meta:p,patchMeta:m,onDeleteWorkflow:y,isNew:w}=e;if(!t)return(0,l.jsx)(km,{meta:p,patchMeta:m,onDeleteWorkflow:y,isNew:w});if(t.kind==="edge"){let H=r.find(g=>g.id===t.id);return H?(0,l.jsx)(bm,{edge:{...H,id:H.id??""},patch:o,onDelete:()=>a(t)}):null}let S=n.find(H=>H.id===t.id);return S?(0,l.jsx)(hm,{node:S,nodes:n,edges:r,patch:o,patchData:i,onDelete:()=>a(t),onDuplicate:()=>u(t),validation:s,runOutput:c?.outputs?.[S.id],agents:d}):null}function hm({node:e,nodes:t,edges:n,patch:r,patchData:o,onDelete:i,onDuplicate:a,validation:u,runOutput:s,agents:c}){let[d,p]=(0,ne.useState)("config"),m=gm[e.type];return(0,l.jsxs)("aside",{className:"insp",children:[(0,l.jsxs)("div",{className:"insp__head",children:[(0,l.jsxs)("div",{className:"insp__top",children:[(0,l.jsx)("span",{className:"insp__type-pill",children:e.type}),(0,l.jsx)("input",{className:"insp__name",value:e.id,onChange:y=>r({id:y.target.value})}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",title:"Duplicate",onClick:a,children:(0,l.jsx)(A.dup,{})}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",title:"Delete",onClick:i,children:(0,l.jsx)(A.trash,{})})]}),(0,l.jsxs)("div",{className:"insp__tabs",children:[(0,l.jsxs)("button",{className:"insp__tab"+(d==="config"?" is-active":""),onClick:()=>p("config"),children:[(0,l.jsx)(A.gear,{})," Config"]}),(0,l.jsxs)("button",{className:"insp__tab"+(d==="advanced"?" is-active":""),onClick:()=>p("advanced"),children:[(0,l.jsx)(A.layout,{})," Advanced"]}),(0,l.jsxs)("button",{className:"insp__tab"+(d==="preview"?" is-active":""),onClick:()=>p("preview"),children:[(0,l.jsx)(A.eye,{})," Preview ",s&&(0,l.jsx)("span",{className:"count",children:"\u25CF"})]})]})]}),(0,l.jsxs)("div",{className:"insp__body",children:[d==="config"&&(0,l.jsxs)(l.Fragment,{children:[m?m({node:e,nodes:t,patch:r,patchData:o,agents:c}):(0,l.jsx)(L,{title:"Config",children:(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:8},children:["No typed form yet for ",(0,l.jsx)("span",{className:"mono",children:e.type}),". Use the Advanced tab to edit raw JSON."]})}),(0,l.jsx)(vm,{node:e,nodes:t,edges:n})]}),d==="advanced"&&(0,l.jsx)(xm,{node:e,patchData:o}),d==="preview"&&(0,l.jsx)(L,{title:"Latest run output",children:s?(0,l.jsx)("pre",{style:{fontSize:11,color:"var(--ink-2)",padding:8,background:"var(--bg)",borderRadius:4,border:"1px solid var(--line)"},dangerouslySetInnerHTML:{__html:s}}):(0,l.jsx)("div",{style:{fontSize:12,color:"var(--muted)"},children:"No run data for this node yet."})}),u&&u.length>0&&(0,l.jsx)(L,{title:"Issues",right:(0,l.jsx)("span",{className:"card__kind",style:{color:"var(--err)"},children:u.length}),children:u.map((y,w)=>(0,l.jsxs)("div",{className:"fld__err",style:{padding:"6px 0"},children:[(0,l.jsx)(A.warn,{})," ",y.message]},w))})]})]})}function mm(e,t,n){let r=new Map(t.map(u=>[u.id,u])),o=new Set,i=[],a=u=>{if(!o.has(u)){o.add(u);for(let s of n)s.to===u&&a(s.from);if(u!==e){let s=r.get(u);s&&i.push(s)}}};a(e);for(let u of t)u.type.startsWith("trigger.")&&!o.has(u.id)&&u.id!==e&&i.push(u);return i}function vm({node:e,nodes:t,edges:n}){let r=(0,ne.useMemo)(()=>mm(e.id,t,n),[e.id,t,n]);return r.length===0?(0,l.jsx)(L,{title:"Available inputs",defaultOpen:!1,children:(0,l.jsxs)("div",{style:{fontSize:12,color:"var(--muted)"},children:["No upstream nodes yet \u2014 connect a trigger or upstream node to make its outputs available as ",(0,l.jsx)("span",{className:"mono",children:"{{nodeId.path}}"})," templates here."]})}):(0,l.jsx)(L,{title:`Available inputs (${r.length})`,defaultOpen:!1,right:(0,l.jsx)("span",{className:"card__kind",style:{color:"var(--muted)"},children:"click to copy"}),children:(0,l.jsx)("div",{style:{display:"grid",gap:10},children:r.map(o=>(0,l.jsx)(ym,{node:o},o.id))})})}function ym({node:e}){let t=cs[e.type],n=t?dp(e.type,e.config):[];return(0,l.jsxs)("div",{style:{border:"1px solid var(--line)",borderRadius:6,padding:8,background:"var(--bg)"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,l.jsx)("span",{className:"mono",style:{fontSize:11,color:"var(--ink-2)"},children:e.id}),(0,l.jsx)("span",{className:"insp__type-pill",style:{fontSize:10},children:e.type})]}),t?.summary&&(0,l.jsx)("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:6},children:t.summary}),n.length===0?(0,l.jsx)("div",{style:{fontSize:11,color:"var(--muted)"},children:"No declared outputs."}):(0,l.jsx)("div",{style:{display:"grid",gap:2},children:n.map(r=>(0,l.jsx)(wm,{nodeId:e.id,field:r},r.path))})]})}function wm({nodeId:e,field:t}){let[n,r]=(0,ne.useState)(!1),o=t.path?`{{${e}.${t.path}}}`:`{{${e}}}`;return(0,l.jsxs)("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(o),r(!0),window.setTimeout(()=>r(!1),900)}catch{}},title:t.description,style:{textAlign:"left",display:"grid",gridTemplateColumns:"1fr auto",gap:6,padding:"4px 6px",background:n?"var(--ok-soft, rgba(0, 200, 100, 0.12))":"transparent",border:"1px solid transparent",borderRadius:4,cursor:"pointer",color:"var(--ink-1)",fontSize:11,lineHeight:1.35},children:[(0,l.jsx)("span",{className:"mono",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o}),(0,l.jsx)("span",{style:{color:n?"var(--ok, #2ea043)":"var(--muted)",fontSize:10},children:n?"copied":t.type})]})}function xm({node:e,patchData:t}){let[n,r]=(0,ne.useState)(()=>JSON.stringify(e.config,null,2)),[o,i]=(0,ne.useState)(null);return(0,ne.useMemo)(()=>{r(JSON.stringify(e.config,null,2)),i(null)},[e.id]),(0,l.jsxs)(L,{title:"Raw config JSON",children:[(0,l.jsx)(Ri,{mono:!0,rows:14,value:n,onChange:r}),(0,l.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8},children:[(0,l.jsxs)("button",{className:"btn btn--ghost-icon",onClick:()=>{try{let u=JSON.parse(n);u&&typeof u=="object"&&!Array.isArray(u)?(t(u),i(null)):i("config must be a JSON object")}catch(u){i(u.message)}},children:[(0,l.jsx)(A.check,{})," Apply"]}),(0,l.jsxs)("button",{className:"btn btn--ghost-icon",onClick:()=>r(JSON.stringify(e.config,null,2)),children:[(0,l.jsx)(A.undo,{})," Reset"]})]}),o&&(0,l.jsxs)("div",{className:"fld__err",style:{color:"var(--err)",fontSize:11,marginTop:4},children:[(0,l.jsx)(A.err,{})," ",o]})]})}function km({meta:e,patchMeta:t,onDeleteWorkflow:n,isNew:r}){let o=e.retention??{maxRuns:500,maxDays:90};return(0,l.jsxs)("aside",{className:"insp",children:[(0,l.jsx)("div",{className:"insp__head",children:(0,l.jsxs)("div",{className:"insp__top",children:[(0,l.jsx)("span",{className:"insp__type-pill",children:"workflow"}),(0,l.jsx)("input",{className:"insp__name",value:e.title,placeholder:"Untitled workflow",onChange:i=>t({title:i.target.value})})]})}),(0,l.jsxs)("div",{className:"insp__body",children:[(0,l.jsxs)(L,{title:"Identity",children:[(0,l.jsx)(k,{label:"ID",hint:r?"URL slug \u2014 set once on first save":"URL slug \u2014 read-only after creation",children:(0,l.jsx)(R,{mono:!0,value:e.id,onChange:i=>r&&t({id:i})})}),(0,l.jsx)(k,{label:"Title",children:(0,l.jsx)(R,{value:e.title,onChange:i=>t({title:i})})}),(0,l.jsx)(k,{label:"Description",hint:"Optional one-liner shown on the workflows index",children:(0,l.jsx)(Ri,{rows:2,value:e.description??"",onChange:i=>t({description:i})})})]}),(0,l.jsxs)(L,{title:"Execution",children:[(0,l.jsx)(k,{label:"Priority",hint:"Higher numbers run before lower ones when multiple workflows match the same trigger",children:(0,l.jsx)(on,{value:e.priority,onChange:i=>t({priority:i??0}),placeholder:"0"})}),(0,l.jsx)(k,{label:"",children:(0,l.jsx)(Li,{checked:!!e.fanOut,onChange:i=>t({fanOut:i}),label:"Fan out \u2014 let multiple workflows match the same trigger event"})}),(0,l.jsx)(k,{label:"Secrets this flow may use",hint:"Comma-separated. Only these env names are exposed to actions/agents in this flow.",children:(0,l.jsx)(vt,{mono:!0,value:e.envAllow??[],onChange:i=>t({envAllow:i}),placeholder:"GITLAB_TOKEN, SLACK_WEBHOOK"})})]}),(0,l.jsxs)(L,{title:"Retention",defaultOpen:!1,children:[(0,l.jsx)(k,{label:"How many runs to keep",children:(0,l.jsx)(on,{value:o.maxRuns,onChange:i=>t({retention:{...o,maxRuns:i??0}}),placeholder:"500"})}),(0,l.jsx)(k,{label:"Keep runs for (days)",children:(0,l.jsx)(on,{value:o.maxDays,onChange:i=>t({retention:{...o,maxDays:i??0}}),placeholder:"90"})})]}),(0,l.jsxs)("div",{style:{fontSize:11,color:"var(--muted)",padding:"4px 16px 14px",borderTop:"1px solid var(--line-soft)",marginTop:4},children:["Tip: pick a node or edge on the canvas to edit its config. Each node's output becomes available as"," ",(0,l.jsx)("span",{className:"mono",children:"{{nodeId.path}}"})," to downstream nodes."]}),n&&!r&&(0,l.jsx)("div",{className:"insp__danger",children:(0,l.jsxs)("button",{className:"btn btn--ghost-icon insp__delete-wf",onClick:n,title:"Delete this workflow permanently",children:[(0,l.jsx)(A.trash,{})," Delete workflow"]})})]})]})}function bm({edge:e,patch:t,onDelete:n}){return(0,l.jsxs)("aside",{className:"insp",children:[(0,l.jsx)("div",{className:"insp__head",children:(0,l.jsxs)("div",{className:"insp__top",children:[(0,l.jsx)("span",{className:"insp__type-pill",children:"edge"}),(0,l.jsxs)("div",{className:"insp__name",style:{padding:0,fontSize:13,color:"var(--ink-2)"},children:[(0,l.jsx)("span",{className:"mono",children:e.from}),e.fromPort?(0,l.jsxs)("span",{className:"mono",children:[" :",e.fromPort]}):null," \u2192 ",(0,l.jsx)("span",{className:"mono",children:e.to})]}),(0,l.jsx)("button",{className:"btn btn--ghost-icon",onClick:n,children:(0,l.jsx)(A.trash,{})})]})}),(0,l.jsxs)("div",{className:"insp__body",children:[(0,l.jsx)(L,{title:"Label",children:(0,l.jsx)(k,{label:"Label",hint:"Shown on the edge (cosmetic only)",children:(0,l.jsx)(R,{mono:!0,value:e.label??"",onChange:r=>t({label:r})})})}),(0,l.jsx)(L,{title:"Port",defaultOpen:!1,children:(0,l.jsx)(k,{label:"Leaves from",hint:"Set when the source is a branch node. Must match a case's `to` field or the default port.",children:(0,l.jsx)(R,{mono:!0,value:e.fromPort??"",onChange:r=>t({fromPort:r||void 0})})})})]})]})}var St=oe(Nt(),1);var $=oe(Ce(),1);function hp({onLoadTemplate:e}){let[t,n]=(0,St.useState)(""),[r,o]=(0,St.useState)([]);(0,St.useEffect)(()=>{let u=!0;return fetch("/api/n8n/workflows").then(s=>s.json()).then(s=>{if(!u)return;let c=(s.workflows??[]).filter(d=>d.webhookUrl).map(d=>({id:"n8n."+d.id,type:"action.callHTTP",label:d.name,hint:d.active?"Hands this over to n8n":"In n8n, but switched off there",glyph:"g-action",icon:"globe",config:{url:d.webhookUrl,method:"POST",body:"{{trigger}}"}}));o(c.length?[{section:"From your n8n",items:c}]:[])}).catch(()=>{}),()=>{u=!1}},[]);let i=(0,St.useMemo)(()=>[...ls,...r],[r]),a=(0,St.useMemo)(()=>{if(!t.trim())return i;let u=t.toLowerCase();return i.map(s=>({...s,items:s.items.filter(c=>c.label.toLowerCase().includes(u)||c.hint.toLowerCase().includes(u)||c.type.includes(u))})).filter(s=>s.items.length>0)},[t,i]);return(0,$.jsxs)("aside",{className:"pal",children:[(0,$.jsxs)("div",{className:"pal__search",children:[(0,$.jsx)(A.search,{}),(0,$.jsx)("input",{value:t,onChange:u=>n(u.target.value),placeholder:"Search nodes\u2026"}),(0,$.jsx)("kbd",{children:"/"})]}),(0,$.jsxs)("div",{className:"pal__scroll",children:[a.map(u=>(0,$.jsxs)(St.Fragment,{children:[(0,$.jsxs)("div",{className:"pal__section",children:[(0,$.jsx)("span",{children:u.section}),(0,$.jsx)("span",{className:"pal__section-count",children:u.items.length.toString().padStart(2,"0")})]}),u.items.map(s=>(0,$.jsx)(_m,{item:s},s.id))]},u.section)),!t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)("div",{className:"pal__section",children:[(0,$.jsx)("span",{children:"Templates"}),(0,$.jsx)("span",{className:"pal__section-count",children:us.length.toString().padStart(2,"0")})]}),us.map(u=>(0,$.jsxs)("div",{className:"pal__tpl",onClick:()=>e(u),children:[(0,$.jsx)("div",{className:"pal__tpl-dots",children:[0,1,2].map(s=>(0,$.jsx)("span",{className:s<u.dots?"on":""},s))}),(0,$.jsx)("div",{className:"pal__tpl-title",children:u.title}),(0,$.jsx)("div",{className:"pal__tpl-hint",children:u.hint})]},u.id))]})]}),(0,$.jsxs)("div",{className:"pal__foot",children:[(0,$.jsx)(A.lightning,{}),(0,$.jsx)("span",{children:"Drag items onto the canvas"})]})]})}function _m({item:e}){let t=A[e.icon]??A.box;return(0,$.jsxs)("div",{className:"pal__item",draggable:!0,onDragStart:r=>{r.dataTransfer.setData("application/x-wfe-item",JSON.stringify(e)),r.dataTransfer.effectAllowed="copy";let o=document.createElement("div");o.textContent=e.label,o.style.cssText="position:absolute;top:-1000px;padding:6px 10px;background:var(--accent);color:#fff;border-radius:6px;font:500 12px 'Space Grotesk';",document.body.appendChild(o),r.dataTransfer.setDragImage(o,10,10),setTimeout(()=>document.body.removeChild(o),0)},children:[(0,$.jsx)("div",{className:"pal__glyph "+e.glyph,children:(0,$.jsx)(t,{})}),(0,$.jsxs)("div",{className:"pal__meta",children:[(0,$.jsx)("div",{className:"pal__label",children:e.label}),(0,$.jsx)("div",{className:"pal__hint",children:e.hint})]})]})}var gs=oe(Nt(),1);var _=oe(Ce(),1);function mp(e){return(0,_.jsxs)("div",{className:"tb",children:[(0,_.jsxs)("div",{className:"tb__brand",children:[(0,_.jsx)("div",{className:"tb__mark",children:"\u2726"}),(0,_.jsxs)("div",{children:[(0,_.jsx)("div",{className:"tb__brand-label",children:"Workflow Editor"}),(0,_.jsx)("div",{className:"tb__brand-sub",children:e.workflowIdLabel})]})]}),(0,_.jsxs)("div",{className:"tb__main",children:[(0,_.jsxs)("div",{className:"tb__crumbs",children:[(0,_.jsx)("a",{href:"/workflows",children:"Workflows"}),(0,_.jsx)("span",{className:"sep",children:"/"}),(0,_.jsx)("input",{value:e.title,onChange:t=>e.setTitle(t.target.value)})]}),(0,_.jsx)("span",{className:"tb__sep"}),(0,_.jsxs)("div",{className:"tb__status "+e.status,children:[(0,_.jsx)("span",{className:"dot"}),e.statusLabel??(e.status==="is-dirty"?"unsaved":e.status==="is-running"?"running":e.status==="is-validating"?"validating\u2026":"saved")]}),(0,_.jsx)("div",{className:"tb__spacer"}),(0,_.jsx)("button",{className:"btn btn--ghost-icon"+(e.paletteOpen?" is-active":""),title:e.paletteOpen?"Hide palette":"Show palette",onClick:()=>e.setPaletteOpen(!e.paletteOpen),children:(0,_.jsx)(A.panelLeft,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon"+(e.inspectorOpen?" is-active":""),title:e.inspectorOpen?"Hide inspector":"Show inspector",onClick:()=>e.setInspectorOpen(!e.inspectorOpen),children:(0,_.jsx)(A.panelRight,{})}),(0,_.jsx)("span",{className:"tb__sep"}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Undo (\u2318Z)",onClick:e.onUndo,disabled:!e.canUndo,children:(0,_.jsx)(A.undo,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Redo (\u2318\u21E7Z)",onClick:e.onRedo,disabled:!e.canRedo,children:(0,_.jsx)(A.redo,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Auto layout",onClick:e.onLayout,children:(0,_.jsx)(A.layout,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Keyboard shortcuts",onClick:e.onHelp,children:(0,_.jsx)(A.kbd,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon"+(e.tweaksOpen?" is-active":""),title:"Tweaks",onClick:()=>e.setTweaksOpen(!e.tweaksOpen),children:(0,_.jsx)(A.gear,{})}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",title:"Toggle theme",onClick:()=>e.setTheme(e.theme==="dark"?"light":"dark"),children:e.theme==="dark"?(0,_.jsx)(A.sun,{}):(0,_.jsx)(A.moon,{})})]}),(0,_.jsxs)("div",{className:"tb__actions",children:[(0,_.jsxs)("button",{className:"btn btn--outline",onClick:e.onSave,children:[(0,_.jsx)(A.save,{})," Save"]}),(0,_.jsx)("button",{className:"btn btn--primary",onClick:e.onRun,children:e.running?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(A.stop2,{})," Stop"]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(A.run,{})," Run preview"]})})]})]})}function vp({running:e,script:t,cursor:n,onStop:r}){if(!e)return null;let o=t.filter(i=>i.nodeId);return(0,_.jsxs)("div",{className:"run",children:[(0,_.jsxs)("div",{className:"run__head",children:[(0,_.jsx)(A.lightning,{}),(0,_.jsx)("div",{className:"run__title",children:"Live run"}),(0,_.jsxs)("span",{className:"run__chip",children:[(0,_.jsx)("span",{className:"dot"})," streaming"]}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",onClick:r,style:{height:24,width:24},children:(0,_.jsx)(A.x,{})})]}),(0,_.jsx)("div",{className:"run__body",children:o.map((i,a)=>{let u=t.indexOf(i),s=u<n,c=["run__step"];return s&&c.push("is-done"),u===n&&c.push("is-current"),(0,_.jsxs)("div",{className:c.join(" "),children:[(0,_.jsx)("div",{className:"run__marker",children:s?(0,_.jsx)(A.check,{}):a+1}),(0,_.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,_.jsx)("div",{className:"run__step-title",children:i.title}),i.body&&(0,_.jsx)("div",{className:"run__step-body",dangerouslySetInnerHTML:{__html:i.body}})]})]},a)})}),(0,_.jsxs)("div",{className:"run__foot",children:[(0,_.jsxs)("span",{children:[Math.min(n+1,t.length),"/",t.length]}),(0,_.jsxs)("span",{children:[t.length?Math.round((n+1)/t.length*100):0,"%"]})]})]})}var Sm=[{h:255,name:"indigo"},{h:220,name:"blue"},{h:180,name:"teal"},{h:145,name:"green"},{h:70,name:"amber"},{h:28,name:"orange"},{h:330,name:"pink"}];function yp(e){return e.open?(0,_.jsxs)("div",{className:"tweaks",children:[(0,_.jsxs)("div",{className:"tweaks__head",children:[(0,_.jsx)("span",{children:"Tweaks"}),(0,_.jsx)("button",{className:"btn btn--ghost-icon",style:{height:22,width:22},onClick:()=>e.setOpen(!1),children:(0,_.jsx)(A.x,{})})]}),(0,_.jsxs)("div",{className:"tweaks__body",children:[(0,_.jsxs)("div",{className:"tweaks__row",children:[(0,_.jsx)("label",{children:"Theme"}),(0,_.jsx)("div",{className:"tweaks__opts",children:["dark","light"].map(t=>(0,_.jsx)("button",{className:e.theme===t?"on":"",onClick:()=>e.setTheme(t),children:t},t))})]}),(0,_.jsxs)("div",{className:"tweaks__row",children:[(0,_.jsx)("label",{children:"Density"}),(0,_.jsx)("div",{className:"tweaks__opts",children:["compact","cozy","roomy"].map(t=>(0,_.jsx)("button",{className:e.density===t?"on":"",onClick:()=>e.setDensity(t),children:t},t))})]}),(0,_.jsxs)("div",{className:"tweaks__row",style:{alignItems:"flex-start",flexDirection:"column",gap:6},children:[(0,_.jsx)("label",{children:"Accent hue"}),(0,_.jsx)("div",{className:"tweaks__hue",children:Sm.map(t=>(0,_.jsx)("button",{title:t.name,className:e.hue===t.h?"on":"",style:{background:`oklch(0.70 0.16 ${t.h})`},onClick:()=>e.setHue(t.h)},t.h))})]})]})]}):null}function wp({open:e,onClose:t}){return e?(0,_.jsx)("div",{className:"kbd-overlay",onClick:t,children:(0,_.jsxs)("div",{className:"kbd-card",onClick:r=>r.stopPropagation(),children:[(0,_.jsx)("h3",{children:"Keyboard shortcuts"}),[["Save workflow","\u2318S"],["Undo / Redo","\u2318Z / \u2318\u21E7Z"],["Delete selection","Delete"],["Duplicate node","\u2318D"],["Run preview","\u2318\u23CE"],["Focus search","/"],["Fit view","F"],["Close panels","Esc"]].map(([r,o])=>(0,_.jsxs)("div",{className:"row",children:[(0,_.jsx)("span",{children:r}),(0,_.jsx)("span",{children:o.split(" ").map((i,a)=>(0,_.jsxs)(gs.Fragment,{children:[i.includes("/")?i.split("/").map((u,s)=>(0,_.jsxs)(gs.Fragment,{children:[s>0&&" / ",(0,_.jsx)("kbd",{children:u.trim()})]},s)):(0,_.jsx)("kbd",{children:i})," "]},a))})]},r))]})}):null}var Me=oe(Nt(),1),V=oe(Ce(),1),ms="agentx.editor.chat.v1";function xp({currentWorkflow:e,onApplyWorkflow:t,agentId:n}){let[r,o]=(0,Me.useState)(!1),[i,a]=(0,Me.useState)(()=>Tm()),[u,s]=(0,Me.useState)(""),[c,d]=(0,Me.useState)(!1),p=(0,Me.useRef)(null),m=(0,Me.useRef)(null);(0,Me.useEffect)(()=>{let g=i.filter(f=>!f.pending).map(f=>({role:f.role,content:f.content}));try{sessionStorage.setItem(ms,JSON.stringify(g))}catch{}},[i]),(0,Me.useEffect)(()=>{let g=p.current;g&&(g.scrollTop=g.scrollHeight)},[i,r]),(0,Me.useEffect)(()=>{r&&m.current?.focus()},[r]);let y=(0,Me.useCallback)(async()=>{let g=u.trim();if(!g||c)return;let f=i.filter(x=>!x.pending).map(x=>({role:x.role,content:x.content})),h=[...i,{role:"user",content:g},{role:"assistant",content:"\u2026",pending:!0}];a(h),s(""),d(!0);try{let x=await fetch("/api/workflows/editor/chat",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-Requested-With":"agentx-board"},body:JSON.stringify({messages:[...f,{role:"user",content:g}],currentWorkflow:e,agentId:n})}),C=await x.json().catch(()=>({}));x.ok?a(P=>hs(P,{role:"assistant",content:C.reply||"",workflow:C.workflow||void 0})):a(P=>hs(P,{role:"assistant",content:"",error:C.error||`HTTP ${x.status}`}))}catch(x){a(C=>hs(C,{role:"assistant",content:"",error:x?.message||"network error"}))}finally{d(!1)}},[n,c,e,u,i]),w=()=>{a([]);try{sessionStorage.removeItem(ms)}catch{}},S=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),y())},H=(0,Me.useMemo)(()=>["Describe the process you want \u2014 I'll generate the workflow.","","Examples:",'\u2022 "Expense approval: employee submits form, manager approves over $500 otherwise auto-approve"','\u2022 "Telegram bot that classifies messages as billing/bug/other and routes to the right agent"',`\u2022 "Triage a GitLab issue: label 'bug' \u2192 dev agent; label 'feature' \u2192 product agent; otherwise close"`].join(`
1342
1342
  `),[]);return(0,V.jsxs)(V.Fragment,{children:[!r&&(0,V.jsxs)("button",{className:"ax-chat__pill","aria-label":"Open workflow assistant",onClick:()=>o(!0),children:[(0,V.jsx)("span",{className:"ax-chat__pill-glyph",children:"\u2728"}),(0,V.jsx)("span",{className:"ax-chat__pill-text",children:"Ask AI to build\u2026"})]}),r&&(0,V.jsxs)("div",{className:"ax-chat__panel",role:"dialog","aria-label":"Workflow assistant",children:[(0,V.jsxs)("header",{className:"ax-chat__head",children:[(0,V.jsxs)("div",{className:"ax-chat__title",children:[(0,V.jsx)("span",{className:"ax-chat__dot"})," Workflow assistant"]}),(0,V.jsxs)("div",{className:"ax-chat__head-actions",children:[(0,V.jsx)("button",{className:"ax-chat__iconbtn",onClick:w,title:"Clear conversation",children:"\u232B"}),(0,V.jsx)("button",{className:"ax-chat__iconbtn",onClick:()=>o(!1),title:"Collapse",children:"\u25BC"})]})]}),(0,V.jsxs)("div",{className:"ax-chat__body",ref:p,children:[i.length===0&&(0,V.jsx)("pre",{className:"ax-chat__empty",children:H}),i.map((g,f)=>(0,V.jsx)(Cm,{m:g,onApply:t},f))]}),(0,V.jsxs)("footer",{className:"ax-chat__foot",children:[(0,V.jsx)("textarea",{ref:m,className:"ax-chat__input",value:u,onChange:g=>s(g.target.value),onKeyDown:S,placeholder:"Describe the workflow you want\u2026 (Enter to send, Shift+Enter for newline)",rows:2,disabled:c}),(0,V.jsx)("button",{className:"ax-chat__send",onClick:()=>void y(),disabled:c||!u.trim(),children:c?"\u2026":"Send"})]})]}),(0,V.jsx)("style",{children:Pm})]})}function Cm({m:e,onApply:t}){if(e.error)return(0,V.jsxs)("div",{className:"ax-chat__msg ax-chat__msg--err",children:["\u26A0 ",e.error]});if(e.pending)return(0,V.jsx)("div",{className:"ax-chat__msg ax-chat__msg--assistant ax-chat__msg--pending",children:(0,V.jsxs)("span",{className:"ax-chat__typing",children:[(0,V.jsx)("span",{}),(0,V.jsx)("span",{}),(0,V.jsx)("span",{})]})});let n=e.role==="user"?"ax-chat__msg ax-chat__msg--user":"ax-chat__msg ax-chat__msg--assistant",r=Nm(e.content,!!e.workflow),o=e.role==="assistant"?Em(r):Oi(r);return(0,V.jsxs)("div",{className:n,children:[(0,V.jsx)("div",{className:"ax-chat__text",dangerouslySetInnerHTML:{__html:o}}),e.workflow&&(0,V.jsxs)("div",{className:"ax-chat__apply",children:[(0,V.jsx)("button",{className:"ax-chat__applybtn",onClick:()=>t(e.workflow),children:"Apply to canvas"}),(0,V.jsx)("span",{className:"ax-chat__apply-hint",children:"replaces the current workflow"})]})]})}function Nm(e,t){return t?e.replace(/```(?:json)?\s*\n[\s\S]*?```/g,"").trim():e}function Oi(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Em(e){let t=[],n=e.replace(/```([a-zA-Z0-9_-]*)\n([\s\S]*?)```/g,(d,p,m)=>{let y=Oi(m.replace(/\n+$/,"")),w=p?` class="lang-${Oi(p)}"`:"";return t.push(`<pre><code${w}>${y}</code></pre>`),`\0CODE${t.length-1}\0`});n=Oi(n),n=n.replace(/`([^`\n]+)`/g,(d,p)=>`<code>${p}</code>`),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(d,p,m)=>`<a href="${/^https?:\/\/|^\//.test(m)?m:"#"}" target="_blank" rel="noopener noreferrer">${p}</a>`),n=n.replace(/\*\*([^*\n]+)\*\*/g,"<strong>$1</strong>"),n=n.replace(/(?<!\*)\*([^*\n]+)\*(?!\*)/g,"<em>$1</em>");let r=n.split(`
1343
1343
  `),o=[],i=null,a=()=>{i&&(o.push(`</${i}>`),i=null)},u=[],s=()=>{if(!u.length)return;let d=u.join(" ").trim();d&&o.push(`<p>${d}</p>`),u=[]};for(let d of r){let p=d.trimEnd();if(/^\s*$/.test(p)){s(),a();continue}let m=/^(#{1,3})\s+(.+)/.exec(p);if(m){s(),a();let S=m[1].length+2;o.push(`<h${S}>${m[2]}</h${S}>`);continue}let y=/^\s*[-*]\s+(.+)/.exec(p);if(y){s(),i!=="ul"&&(a(),o.push("<ul>"),i="ul"),o.push(`<li>${y[1]}</li>`);continue}let w=/^\s*\d+\.\s+(.+)/.exec(p);if(w){s(),i!=="ol"&&(a(),o.push("<ol>"),i="ol"),o.push(`<li>${w[1]}</li>`);continue}a(),u.push(p)}s(),a();let c=o.join(`
1344
1344
  `);return c=c.replace(/CODE(\d+)/g,(d,p)=>t[Number(p)]||""),c}function hs(e,t){let n=[...e];for(let r=n.length-1;r>=0;r--)if(n[r].pending||n[r].role==="assistant")return n[r]=t,n;return n.push(t),n}function Tm(){try{let e=sessionStorage.getItem(ms);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>n&&(n.role==="user"||n.role==="assistant")&&typeof n.content=="string"):[]}catch{return[]}}var Pm=`