@redvars/peacock 4.0.0 → 4.2.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 (467) hide show
  1. package/dist/{BaseField-CAog9TIc.js → BaseField-_unSNU5x.js} +43 -4
  2. package/dist/BaseField-_unSNU5x.js.map +1 -0
  3. package/dist/{BaseInput-CcMfg1Y2.js → BaseInput-DtZH0fPJ.js} +7 -4
  4. package/dist/BaseInput-DtZH0fPJ.js.map +1 -0
  5. package/dist/accordion.js.map +1 -1
  6. package/dist/ai-badge.js +32 -6
  7. package/dist/ai-badge.js.map +1 -1
  8. package/dist/ai-summary.js +2 -2
  9. package/dist/alert.js +2 -2
  10. package/dist/anchor-nav.js +2 -2
  11. package/dist/app-shell.js +2 -2
  12. package/dist/assistant-panel.js +2 -2
  13. package/dist/assistant-step.js +2 -2
  14. package/dist/assistant-steps.js +2 -2
  15. package/dist/avatar-group.js +2 -2
  16. package/dist/banner.js +2 -2
  17. package/dist/{base-button-Do2TUy8M.js → base-button-BJMGMcMv.js} +3 -1
  18. package/dist/base-button-BJMGMcMv.js.map +1 -0
  19. package/dist/{base-progress-BiLlZVHJ.js → base-progress-D7Nmfh1s.js} +4 -2
  20. package/dist/base-progress-D7Nmfh1s.js.map +1 -0
  21. package/dist/bottom-sheet.js +2 -2
  22. package/dist/breadcrumb.js +2 -2
  23. package/dist/button-group.js +4 -4
  24. package/dist/button.js +14 -8
  25. package/dist/button.js.map +1 -1
  26. package/dist/calendar.js +2 -2
  27. package/dist/canvas-base-CWQ4rQ2s.js +788 -0
  28. package/dist/canvas-base-CWQ4rQ2s.js.map +1 -0
  29. package/dist/canvas-link-CtgsALq4.js +54 -0
  30. package/dist/canvas-link-CtgsALq4.js.map +1 -0
  31. package/dist/{cartesian-chart-C-f1frt0.js → cartesian-chart-CS5yRLfE.js} +3 -2
  32. package/dist/cartesian-chart-CS5yRLfE.js.map +1 -0
  33. package/dist/{cb-group-base-DeuCVx3a.js → cb-group-base-CO30uFQZ.js} +2 -2
  34. package/dist/{cb-group-base-DeuCVx3a.js.map → cb-group-base-CO30uFQZ.js.map} +1 -1
  35. package/dist/cb-group.js +3 -3
  36. package/dist/cb-rule.js +3 -3
  37. package/dist/chart-area.js +5 -4
  38. package/dist/chart-area.js.map +1 -1
  39. package/dist/chart-bar.js +5 -4
  40. package/dist/chart-bar.js.map +1 -1
  41. package/dist/chart-base-C_XKVyhf.js +833 -0
  42. package/dist/chart-base-C_XKVyhf.js.map +1 -0
  43. package/dist/chart-doughnut.js +4 -3
  44. package/dist/chart-doughnut.js.map +1 -1
  45. package/dist/chart-line.js +5 -4
  46. package/dist/chart-line.js.map +1 -1
  47. package/dist/chart-pie.js +4 -3
  48. package/dist/chart-pie.js.map +1 -1
  49. package/dist/chat-event.js +152 -0
  50. package/dist/chat-event.js.map +1 -0
  51. package/dist/chat-message.js +195 -19
  52. package/dist/chat-message.js.map +1 -1
  53. package/dist/chat-thread.js +26 -9
  54. package/dist/chat-thread.js.map +1 -1
  55. package/dist/checkbox-group.js +5 -5
  56. package/dist/checkbox.js +5 -5
  57. package/dist/chip-set.js +4 -4
  58. package/dist/chip.js +4 -4
  59. package/dist/circular-progress.js +3 -3
  60. package/dist/citation.js +2 -2
  61. package/dist/code-editor.js +6 -5
  62. package/dist/code-editor.js.map +1 -1
  63. package/dist/code-highlighter.js +2 -2
  64. package/dist/color-field.js +6 -6
  65. package/dist/color-picker.js +2 -2
  66. package/dist/command-palette.js +2 -2
  67. package/dist/comment-composer.js +6 -6
  68. package/dist/condition-builder.js +3 -3
  69. package/dist/confirm-dialog.js +2 -2
  70. package/dist/copy-button.js +2 -2
  71. package/dist/currency-field.js +6 -6
  72. package/dist/custom-elements-jsdocs.json +2330 -397
  73. package/dist/custom-elements.json +20464 -542
  74. package/dist/date-field.js +7 -7
  75. package/dist/date-picker.js +4 -2
  76. package/dist/date-picker.js.map +1 -1
  77. package/dist/date-range-field.js +7 -7
  78. package/dist/datetime-field.js +7 -7
  79. package/dist/dependency-map-layout-5KUueabk.js +1390 -0
  80. package/dist/dependency-map-layout-5KUueabk.js.map +1 -0
  81. package/dist/dependency-map.js +1605 -0
  82. package/dist/dependency-map.js.map +1 -0
  83. package/dist/description-item.js +2 -2
  84. package/dist/description-list.js +2 -2
  85. package/dist/diagram-Va096vj9.js +2029 -0
  86. package/dist/diagram-Va096vj9.js.map +1 -0
  87. package/dist/diagram-controls.js +345 -0
  88. package/dist/diagram-controls.js.map +1 -0
  89. package/dist/diagram-minimap.js +216 -0
  90. package/dist/diagram-minimap.js.map +1 -0
  91. package/dist/diagram.js +20 -0
  92. package/dist/diagram.js.map +1 -0
  93. package/dist/diff-viewer.js +2 -2
  94. package/dist/discussion-activity.js +4 -4
  95. package/dist/discussion-comment.js +4 -4
  96. package/dist/{discussion-time-BegaYfhf.js → discussion-time-DqykqvNy.js} +2 -2
  97. package/dist/{discussion-time-BegaYfhf.js.map → discussion-time-DqykqvNy.js.map} +1 -1
  98. package/dist/discussion.js +8 -8
  99. package/dist/{document-editor-BO7QPbO5.js → document-editor-Dc8JeFVB.js} +2 -2
  100. package/dist/{document-editor-BO7QPbO5.js.map → document-editor-Dc8JeFVB.js.map} +1 -1
  101. package/dist/document-editor.js +3 -3
  102. package/dist/draft-card.js +14 -4
  103. package/dist/draft-card.js.map +1 -1
  104. package/dist/dropdown-button.js +3 -2
  105. package/dist/dropdown-button.js.map +1 -1
  106. package/dist/erd.js +2021 -0
  107. package/dist/erd.js.map +1 -0
  108. package/dist/fab.js +4 -4
  109. package/dist/field.js +257 -43
  110. package/dist/field.js.map +1 -1
  111. package/dist/file-upload.js +38 -16
  112. package/dist/file-upload.js.map +1 -1
  113. package/dist/filter-bar.js +2 -2
  114. package/dist/flow.js +27 -970
  115. package/dist/flow.js.map +1 -1
  116. package/dist/focus-ring.js +2 -0
  117. package/dist/focus-ring.js.map +1 -1
  118. package/dist/{form-associated-D3Tn33s_.js → form-associated-BHbg72PG.js} +3 -1
  119. package/dist/{form-associated-D3Tn33s_.js.map → form-associated-BHbg72PG.js.map} +1 -1
  120. package/dist/{form-submitter-DWwv6K9-.js → form-submitter-beG1CXAn.js} +7 -1
  121. package/dist/{form-submitter-DWwv6K9-.js.map → form-submitter-beG1CXAn.js.map} +1 -1
  122. package/dist/form.js +3 -3
  123. package/dist/{generative-view-DmtpDobn.js → generative-view-BKlcuujw.js} +13 -13
  124. package/dist/generative-view-BKlcuujw.js.map +1 -0
  125. package/dist/generative-view.js +3 -3
  126. package/dist/geometry-INg82Lxq.js +305 -0
  127. package/dist/geometry-INg82Lxq.js.map +1 -0
  128. package/dist/history-YbTSQZHj.js +45 -0
  129. package/dist/history-YbTSQZHj.js.map +1 -0
  130. package/dist/host-CZK7xhzh.js +40 -0
  131. package/dist/host-CZK7xhzh.js.map +1 -0
  132. package/dist/html-editor.js +6 -6
  133. package/dist/{hyperlink-DhE9RlVS.js → hyperlink-DycWPKwU.js} +10 -1
  134. package/dist/hyperlink-DycWPKwU.js.map +1 -0
  135. package/dist/{i18n-controller-urcQKYGe.js → i18n-controller-DJHsE1YH.js} +2 -2
  136. package/dist/{i18n-controller-urcQKYGe.js.map → i18n-controller-DJHsE1YH.js.map} +1 -1
  137. package/dist/icon-button.js +11 -9
  138. package/dist/icon-button.js.map +1 -1
  139. package/dist/image.js +2 -2
  140. package/dist/index.js +42 -22
  141. package/dist/index.js.map +1 -1
  142. package/dist/inline-edit.js +2 -2
  143. package/dist/input.js +5 -5
  144. package/dist/json-viewer.js +2 -2
  145. package/dist/kanban.js +2 -2
  146. package/dist/kbd.js +2 -2
  147. package/dist/linear-progress.js +3 -3
  148. package/dist/link-button.js +9 -7
  149. package/dist/link-button.js.map +1 -1
  150. package/dist/list-item.js +2 -2
  151. package/dist/list.js +2 -2
  152. package/dist/listbox.js +4 -4
  153. package/dist/loader-full.js +17 -16
  154. package/dist/loader-full.js.map +1 -1
  155. package/dist/loader.js +51 -18
  156. package/dist/loader.js.map +1 -1
  157. package/dist/markdown-editor.js +6 -6
  158. package/dist/markers-BFmh1OCz.js +46 -0
  159. package/dist/markers-BFmh1OCz.js.map +1 -0
  160. package/dist/measure-controller-Dmc5hZKg.js +89 -0
  161. package/dist/measure-controller-Dmc5hZKg.js.map +1 -0
  162. package/dist/mention-input.js +7 -6
  163. package/dist/mention-input.js.map +1 -1
  164. package/dist/menu-item.js +3 -2
  165. package/dist/menu-item.js.map +1 -1
  166. package/dist/{menu-trigger-controller-DyLpTxM7.js → menu-trigger-controller-CEJq1ugC.js} +11 -14
  167. package/dist/menu-trigger-controller-CEJq1ugC.js.map +1 -0
  168. package/dist/menu.js +2 -2
  169. package/dist/modal.js +2 -2
  170. package/dist/navigation-bar.js +2 -2
  171. package/dist/navigation-drawer.js +2 -2
  172. package/dist/navigation-rail.js +2 -2
  173. package/dist/notification-center.js +3 -3
  174. package/dist/number-field.js +7 -6
  175. package/dist/number-field.js.map +1 -1
  176. package/dist/option.js +2 -2
  177. package/dist/page-header.js +2 -2
  178. package/dist/pagination.js +2 -2
  179. package/dist/password-field.js +6 -6
  180. package/dist/password-rules.js +2 -2
  181. package/dist/phone-field.js +6 -6
  182. package/dist/{picker-field-B4DtcJfL.js → picker-field-CUI05sWc.js} +3 -3
  183. package/dist/{picker-field-B4DtcJfL.js.map → picker-field-CUI05sWc.js.map} +1 -1
  184. package/dist/pin-input.js +6 -6
  185. package/dist/presence-indicator.js +2 -2
  186. package/dist/prompt-input.js +6 -6
  187. package/dist/radio-group.js +2 -1
  188. package/dist/radio-group.js.map +1 -1
  189. package/dist/radio.js +6 -6
  190. package/dist/radio.js.map +1 -1
  191. package/dist/rating.js +6 -5
  192. package/dist/rating.js.map +1 -1
  193. package/dist/redvars-loader.js +2 -2
  194. package/dist/{relative-time-BVQXLuHm.js → relative-time-BNxqvEbg.js} +13 -2
  195. package/dist/relative-time-BNxqvEbg.js.map +1 -0
  196. package/dist/relative-time.js +3 -3
  197. package/dist/resizable-panels.js +2 -2
  198. package/dist/{rich-text-input-DLICqof1.js → rich-text-input-N_hqnXej.js} +3 -3
  199. package/dist/{rich-text-input-DLICqof1.js.map → rich-text-input-N_hqnXej.js.map} +1 -1
  200. package/dist/ripple.js +2 -0
  201. package/dist/ripple.js.map +1 -1
  202. package/dist/{schema-hMt-NRLk.js → schema-Dy0z-80u.js} +2 -2
  203. package/dist/{schema-hMt-NRLk.js.map → schema-Dy0z-80u.js.map} +1 -1
  204. package/dist/search.js +5 -5
  205. package/dist/segmented-button-group.js +1 -1
  206. package/dist/select.js +8 -8
  207. package/dist/side-sheet.js +2 -2
  208. package/dist/signature-pad.js +6 -5
  209. package/dist/signature-pad.js.map +1 -1
  210. package/dist/slider.js +6 -5
  211. package/dist/slider.js.map +1 -1
  212. package/dist/snackbar.js +2 -2
  213. package/dist/sparkline.js +2 -2
  214. package/dist/split-button.js +109 -21
  215. package/dist/split-button.js.map +1 -1
  216. package/dist/src/__internal/ai/suggestion-controller.d.ts +2 -0
  217. package/dist/src/__internal/diagram/canvas-base.d.ts +105 -0
  218. package/dist/src/__internal/diagram/canvas-link.d.ts +21 -0
  219. package/dist/src/__internal/diagram/geometry.d.ts +49 -0
  220. package/dist/src/__internal/diagram/history.d.ts +17 -0
  221. package/dist/src/__internal/diagram/host.d.ts +45 -0
  222. package/dist/src/__internal/diagram/markers.d.ts +16 -0
  223. package/dist/src/__internal/diagram/measure-controller.d.ts +32 -0
  224. package/dist/src/__internal/diagram/motion.d.ts +22 -0
  225. package/dist/src/__internal/diagram/selection.d.ts +20 -0
  226. package/dist/src/__internal/diagram/types.d.ts +39 -0
  227. package/dist/src/__internal/diagram/viewport-controller.d.ts +89 -0
  228. package/dist/src/__internal/i18n/strings.d.ts +155 -0
  229. package/dist/src/__internal/menu-trigger-controller.d.ts +11 -8
  230. package/dist/src/__internal/toggle-base.d.ts +8 -0
  231. package/dist/src/__internal/utils/deprecate.d.ts +3 -3
  232. package/dist/src/__internal/utils/relative-time.d.ts +5 -0
  233. package/dist/src/accordion/accordion.d.ts +1 -0
  234. package/dist/src/ai-badge/ai-badge.d.ts +8 -0
  235. package/dist/src/button/button/button.d.ts +4 -0
  236. package/dist/src/chat-message/chat-message.d.ts +51 -10
  237. package/dist/src/chat-message/index.d.ts +1 -1
  238. package/dist/src/chat-thread/chat-event.d.ts +37 -0
  239. package/dist/src/chat-thread/chat-thread.d.ts +7 -4
  240. package/dist/src/chat-thread/index.d.ts +1 -0
  241. package/dist/src/code-editor/code-editor.d.ts +1 -0
  242. package/dist/src/date-picker/date-picker.d.ts +2 -0
  243. package/dist/src/dependency-map/dependency-map-layout.d.ts +48 -0
  244. package/dist/src/dependency-map/dependency-map.d.ts +241 -0
  245. package/dist/src/dependency-map/index.d.ts +2 -0
  246. package/dist/src/diagram/diagram.d.ts +300 -0
  247. package/dist/src/diagram/flow.d.ts +53 -0
  248. package/dist/src/diagram/index.d.ts +4 -0
  249. package/dist/src/diagram-controls/diagram-controls.d.ts +46 -0
  250. package/dist/src/diagram-controls/index.d.ts +1 -0
  251. package/dist/src/diagram-minimap/diagram-minimap.d.ts +39 -0
  252. package/dist/src/diagram-minimap/index.d.ts +1 -0
  253. package/dist/src/erd/erd-layout.d.ts +27 -0
  254. package/dist/src/erd/erd.d.ts +266 -0
  255. package/dist/src/erd/index.d.ts +2 -0
  256. package/dist/src/field/field.d.ts +38 -1
  257. package/dist/src/file-upload/file-upload.d.ts +3 -1
  258. package/dist/src/focus-ring/focus-ring.d.ts +2 -0
  259. package/dist/src/index.d.ts +17 -4
  260. package/dist/src/input/BaseField.d.ts +15 -1
  261. package/dist/src/input/BaseInput.d.ts +4 -0
  262. package/dist/src/menu/menu-item/menu-item.d.ts +1 -0
  263. package/dist/src/number-field/number-field.d.ts +4 -0
  264. package/dist/src/progress/base-progress.d.ts +3 -0
  265. package/dist/src/radio/radio-group.d.ts +1 -0
  266. package/dist/src/rating/rating.d.ts +1 -0
  267. package/dist/src/ripple/ripple.d.ts +2 -0
  268. package/dist/src/signature-pad/signature-pad.d.ts +1 -0
  269. package/dist/src/slider/slider.d.ts +1 -0
  270. package/dist/src/split-button/split-button.d.ts +7 -2
  271. package/dist/src/switch/switch.d.ts +1 -0
  272. package/dist/src/tabs/tab.d.ts +2 -0
  273. package/dist/src/tabs/tabs.d.ts +1 -0
  274. package/dist/src/textarea/textarea.d.ts +3 -0
  275. package/dist/src/time-picker/time-picker.d.ts +2 -0
  276. package/dist/src/transfer-list/transfer-list.d.ts +1 -0
  277. package/dist/src/tree-chart/index.d.ts +2 -0
  278. package/dist/src/tree-chart/tree-chart-layout.d.ts +49 -0
  279. package/dist/src/tree-chart/tree-chart.d.ts +221 -0
  280. package/dist/src/workflow/index.d.ts +2 -0
  281. package/dist/src/workflow/workflow-format.d.ts +5 -0
  282. package/dist/src/workflow/workflow-model.d.ts +194 -0
  283. package/dist/src/workflow/workflow.d.ts +313 -0
  284. package/dist/src/workflow-timeline/index.d.ts +1 -0
  285. package/dist/src/workflow-timeline/workflow-timeline.d.ts +41 -0
  286. package/dist/stat.js +2 -2
  287. package/dist/status-indicator.js +2 -2
  288. package/dist/step.js +2 -2
  289. package/dist/stepper.js +2 -2
  290. package/dist/{strings-DmbqMTfs.js → strings-DnYjGbbc.js} +169 -1
  291. package/dist/{strings-DmbqMTfs.js.map → strings-DnYjGbbc.js.map} +1 -1
  292. package/dist/sub-menu.js +2 -2
  293. package/dist/{suggestion-controller-CW17adxd.js → suggestion-controller-7YRQqkaI.js} +3 -1
  294. package/dist/{suggestion-controller-CW17adxd.js.map → suggestion-controller-7YRQqkaI.js.map} +1 -1
  295. package/dist/svg.js +2 -2
  296. package/dist/switch.js +6 -5
  297. package/dist/switch.js.map +1 -1
  298. package/dist/tab.js +1 -0
  299. package/dist/tab.js.map +1 -1
  300. package/dist/table.js +50 -11
  301. package/dist/table.js.map +1 -1
  302. package/dist/tabs.js +1 -0
  303. package/dist/tabs.js.map +1 -1
  304. package/dist/test/diagram-controls.test.d.ts +1 -0
  305. package/dist/test/diagram-geometry.test.d.ts +1 -0
  306. package/dist/test/diagram.test.d.ts +1 -0
  307. package/dist/test/erd.test.d.ts +1 -0
  308. package/dist/test/toggle-label.test.d.ts +1 -0
  309. package/dist/test/tree-chart.test.d.ts +1 -0
  310. package/dist/test/workflow-debug.test.d.ts +1 -0
  311. package/dist/test/workflow.test.d.ts +1 -0
  312. package/dist/textarea.js +13 -6
  313. package/dist/textarea.js.map +1 -1
  314. package/dist/time-field.js +7 -7
  315. package/dist/time-picker.js +4 -2
  316. package/dist/time-picker.js.map +1 -1
  317. package/dist/timeline-item.js +2 -2
  318. package/dist/timeline.js +2 -2
  319. package/dist/{toggle-base-BQO5pjrU.js → toggle-base-CXmFSp3b.js} +19 -3
  320. package/dist/toggle-base-CXmFSp3b.js.map +1 -0
  321. package/dist/tour.js +2 -2
  322. package/dist/transfer-list.js +6 -5
  323. package/dist/transfer-list.js.map +1 -1
  324. package/dist/{chart-base-B-gOg2Di.js → transform-CxeQFXXB.js} +9 -839
  325. package/dist/transform-CxeQFXXB.js.map +1 -0
  326. package/dist/tree-chart.js +1986 -0
  327. package/dist/tree-chart.js.map +1 -0
  328. package/dist/tree-item.js +2 -2
  329. package/dist/tree.js +2 -2
  330. package/dist/tsconfig.tsbuildinfo +1 -1
  331. package/dist/typing-indicator.js +2 -2
  332. package/dist/url-field.js +6 -6
  333. package/dist/user-menu.js +3 -3
  334. package/dist/virtual-list.js +2 -2
  335. package/dist/workflow-format-BsyveyeC.js +34 -0
  336. package/dist/workflow-format-BsyveyeC.js.map +1 -0
  337. package/dist/workflow-model-CauduOG2.js +330 -0
  338. package/dist/workflow-model-CauduOG2.js.map +1 -0
  339. package/dist/workflow-timeline.js +354 -0
  340. package/dist/workflow-timeline.js.map +1 -0
  341. package/dist/workflow.js +3337 -0
  342. package/dist/workflow.js.map +1 -0
  343. package/dist/workspace-switcher.js +3 -3
  344. package/package.json +1 -1
  345. package/readme.md +44 -2
  346. package/src/LoaderUtils.ts +9 -2
  347. package/src/__internal/ai/suggestion-controller.ts +3 -1
  348. package/src/__internal/diagram/canvas-base.ts +410 -0
  349. package/src/__internal/diagram/canvas-link.ts +66 -0
  350. package/src/__internal/diagram/geometry.ts +372 -0
  351. package/src/__internal/diagram/history.ts +49 -0
  352. package/src/__internal/diagram/host.ts +76 -0
  353. package/src/__internal/diagram/markers.ts +56 -0
  354. package/src/__internal/diagram/measure-controller.ts +104 -0
  355. package/src/__internal/diagram/motion.ts +89 -0
  356. package/src/__internal/diagram/selection.ts +69 -0
  357. package/src/__internal/diagram/types.ts +56 -0
  358. package/src/__internal/diagram/viewport-controller.ts +494 -0
  359. package/src/__internal/i18n/strings.ts +207 -0
  360. package/src/__internal/menu-trigger-controller.ts +11 -15
  361. package/src/__internal/mixins/field.ts +3 -0
  362. package/src/__internal/mixins/form-associated.ts +2 -0
  363. package/src/__internal/mixins/form-submitter.ts +6 -0
  364. package/src/__internal/mixins/hyperlink.ts +10 -0
  365. package/src/__internal/toggle-base.ts +16 -0
  366. package/src/__internal/utils/deprecate.ts +5 -4
  367. package/src/__internal/utils/relative-time.ts +20 -0
  368. package/src/accordion/accordion.ts +1 -0
  369. package/src/ai-badge/ai-badge.scss +8 -0
  370. package/src/ai-badge/ai-badge.ts +21 -4
  371. package/src/button/base-button/base-button.ts +2 -0
  372. package/src/button/button/button-base.scss +9 -2
  373. package/src/button/button/button-layers.scss +3 -1
  374. package/src/button/button/button.ts +4 -0
  375. package/src/chat-message/chat-message.scss +72 -0
  376. package/src/chat-message/chat-message.ts +137 -18
  377. package/src/chat-message/index.ts +1 -0
  378. package/src/chat-thread/chat-event.scss +36 -0
  379. package/src/chat-thread/chat-event.ts +79 -0
  380. package/src/chat-thread/chat-thread.scss +4 -1
  381. package/src/chat-thread/chat-thread.ts +22 -6
  382. package/src/chat-thread/index.ts +1 -0
  383. package/src/code-editor/code-editor.ts +1 -0
  384. package/src/date-picker/date-picker.ts +2 -0
  385. package/src/dependency-map/dependency-map-layout.ts +505 -0
  386. package/src/dependency-map/dependency-map.scss +626 -0
  387. package/src/dependency-map/dependency-map.ts +1280 -0
  388. package/src/dependency-map/index.ts +16 -0
  389. package/src/diagram/diagram.scss +513 -0
  390. package/src/diagram/diagram.ts +1852 -0
  391. package/src/diagram/flow.ts +81 -0
  392. package/src/diagram/index.ts +44 -0
  393. package/src/diagram-controls/diagram-controls.scss +68 -0
  394. package/src/diagram-controls/diagram-controls.ts +255 -0
  395. package/src/diagram-controls/index.ts +1 -0
  396. package/src/diagram-minimap/diagram-minimap.scss +41 -0
  397. package/src/diagram-minimap/diagram-minimap.ts +149 -0
  398. package/src/diagram-minimap/index.ts +1 -0
  399. package/src/draft-card/draft-card.scss +16 -2
  400. package/src/dropdown-button/dropdown-button.ts +2 -1
  401. package/src/erd/erd-layout.ts +92 -0
  402. package/src/erd/erd.scss +636 -0
  403. package/src/erd/erd.ts +1728 -0
  404. package/src/erd/index.ts +17 -0
  405. package/src/field/field.scss +197 -23
  406. package/src/field/field.ts +109 -16
  407. package/src/file-upload/file-upload.scss +37 -10
  408. package/src/file-upload/file-upload.ts +3 -1
  409. package/src/focus-ring/focus-ring.ts +2 -0
  410. package/src/generative-view/catalog.generated.ts +12 -11
  411. package/src/index.ts +123 -3
  412. package/src/input/BaseField.ts +45 -2
  413. package/src/input/BaseInput.ts +4 -1
  414. package/src/loader.ts +29 -0
  415. package/src/mention-input/mention-input.scss +2 -0
  416. package/src/menu/menu-item/menu-item.ts +1 -0
  417. package/src/number-field/number-field.ts +4 -0
  418. package/src/progress/base-progress.ts +3 -0
  419. package/src/radio/radio-group.ts +1 -0
  420. package/src/radio/radio.ts +1 -1
  421. package/src/rating/rating.ts +1 -0
  422. package/src/ripple/ripple.ts +2 -0
  423. package/src/signature-pad/signature-pad.ts +1 -0
  424. package/src/slider/slider.ts +1 -0
  425. package/src/split-button/split-button-colors.scss +9 -0
  426. package/src/split-button/split-button-sizes.scss +32 -5
  427. package/src/split-button/split-button.scss +61 -8
  428. package/src/split-button/split-button.ts +15 -8
  429. package/src/switch/switch.ts +1 -0
  430. package/src/table/table.scss +57 -9
  431. package/src/table/table.ts +3 -1
  432. package/src/tabs/tab.ts +2 -0
  433. package/src/tabs/tabs.ts +1 -0
  434. package/src/textarea/textarea.scss +2 -0
  435. package/src/textarea/textarea.ts +8 -0
  436. package/src/time-picker/time-picker.ts +2 -0
  437. package/src/transfer-list/transfer-list.ts +1 -0
  438. package/src/tree-chart/index.ts +13 -0
  439. package/src/tree-chart/tree-chart-layout.ts +185 -0
  440. package/src/tree-chart/tree-chart.scss +377 -0
  441. package/src/tree-chart/tree-chart.ts +1170 -0
  442. package/src/workflow/index.ts +35 -0
  443. package/src/workflow/workflow-format.ts +29 -0
  444. package/src/workflow/workflow-model.ts +583 -0
  445. package/src/workflow/workflow.scss +1164 -0
  446. package/src/workflow/workflow.ts +2674 -0
  447. package/src/workflow-timeline/index.ts +1 -0
  448. package/src/workflow-timeline/workflow-timeline.scss +128 -0
  449. package/src/workflow-timeline/workflow-timeline.ts +238 -0
  450. package/dist/BaseField-CAog9TIc.js.map +0 -1
  451. package/dist/BaseInput-CcMfg1Y2.js.map +0 -1
  452. package/dist/base-button-Do2TUy8M.js.map +0 -1
  453. package/dist/base-progress-BiLlZVHJ.js.map +0 -1
  454. package/dist/cartesian-chart-C-f1frt0.js.map +0 -1
  455. package/dist/chart-base-B-gOg2Di.js.map +0 -1
  456. package/dist/generative-view-DmtpDobn.js.map +0 -1
  457. package/dist/hyperlink-DhE9RlVS.js.map +0 -1
  458. package/dist/menu-trigger-controller-DyLpTxM7.js.map +0 -1
  459. package/dist/relative-time-BVQXLuHm.js.map +0 -1
  460. package/dist/src/flow/flow.d.ts +0 -178
  461. package/dist/src/flow/index.d.ts +0 -2
  462. package/dist/toggle-base-BQO5pjrU.js.map +0 -1
  463. package/src/button/button-group/readme.md +0 -23
  464. package/src/flow/flow.scss +0 -215
  465. package/src/flow/flow.ts +0 -958
  466. package/src/flow/index.ts +0 -10
  467. /package/dist/test/{flow.test.d.ts → dependency-map.test.d.ts} +0 -0
@@ -0,0 +1,3337 @@
1
+ import { i, _ as __decorate, I as IndividualComponent, D, w, b, A } from './IndividualComponent-BK7XZjE2.js';
2
+ import { n } from './property-B2TG3KEE.js';
3
+ import { r } from './state-BCeDVCI9.js';
4
+ import { e } from './query-CHb9Ft_d.js';
5
+ import { e as e$1 } from './class-map-NDIkZErE.js';
6
+ import { D as DiagramCanvasElement, p as prefersReducedMotion, a as animateOut } from './canvas-base-CWQ4rQ2s.js';
7
+ import { r as roundedPath } from './geometry-INg82Lxq.js';
8
+ import { H as History } from './history-YbTSQZHj.js';
9
+ import { W as WORKFLOW_LOGIC_STEPS, f as findStep, w as walk, i as isReached, r as replaceStep, a as removeStep, g as getList, c as createStep, b as allIds, d as insertStep, m as moveStep, l as listKey, e as cloneWithNewIds, h as contains, j as countInside, k as listTerminates, s as stepTerminates } from './workflow-model-CauduOG2.js';
10
+ import { f as formatDuration } from './workflow-format-BsyveyeC.js';
11
+ import './base-Cl6v8-BZ.js';
12
+ import './directive-ZPhl09Yt.js';
13
+ import './i18n-controller-DJHsE1YH.js';
14
+ import './strings-DnYjGbbc.js';
15
+ import './locale-DEsJZCQG.js';
16
+ import './host-CZK7xhzh.js';
17
+
18
+ var css_248z = i`* {
19
+ box-sizing: border-box;
20
+ -webkit-tap-highlight-color: transparent;
21
+ }
22
+
23
+ .screen-reader-only {
24
+ position: absolute !important;
25
+ inline-size: 1px !important;
26
+ block-size: 1px !important;
27
+ padding: 0 !important;
28
+ margin: -1px !important;
29
+ overflow: hidden !important;
30
+ clip-path: inset(50%) !important;
31
+ white-space: nowrap !important;
32
+ border: 0 !important;
33
+ }
34
+
35
+ [hidden] {
36
+ display: none !important;
37
+ }
38
+
39
+ @media (forced-colors: active) {
40
+ .selected,
41
+ [aria-selected=true],
42
+ [aria-pressed=true],
43
+ [aria-checked=true],
44
+ [aria-current]:not([aria-current=false]) {
45
+ outline: 2px solid Highlight;
46
+ outline-offset: -2px;
47
+ }
48
+ .disabled,
49
+ [aria-disabled=true] {
50
+ color: GrayText;
51
+ }
52
+ }
53
+ :host {
54
+ display: block;
55
+ position: relative;
56
+ inline-size: 100%;
57
+ block-size: 100%;
58
+ min-block-size: 240px;
59
+ overflow: hidden;
60
+ --workflow-background: var(--color-surface-container-lowest, #fbfbfd);
61
+ --workflow-dot-color: var(--color-outline-variant, #c5c6cb);
62
+ --workflow-connector-color: color-mix(in srgb, var(--color-primary, #005faf) 45%, var(--color-outline-variant, #c5c6cb));
63
+ --workflow-card-width: 280px;
64
+ --_gap: 56px;
65
+ }
66
+
67
+ /* Canvas coordinates are physical x/y and do not mirror in right-to-left layouts. */
68
+ /* stylelint-disable property-disallowed-list */
69
+ .wf-viewport {
70
+ position: absolute;
71
+ inset: 0;
72
+ overflow: hidden;
73
+ background-color: var(--workflow-background);
74
+ background-image: radial-gradient(var(--workflow-dot-color) 1px, transparent 1.2px);
75
+ border: 1px solid var(--color-outline-variant);
76
+ border-radius: var(--shape-corner-large);
77
+ touch-action: none;
78
+ outline: none;
79
+ container-type: inline-size;
80
+ container-name: diagram;
81
+ }
82
+ .wf-viewport:focus-visible {
83
+ box-shadow: inset 0 0 0 2px var(--color-primary);
84
+ }
85
+ .wf-viewport.is-space {
86
+ cursor: grab;
87
+ }
88
+ .wf-viewport.is-panning {
89
+ cursor: grabbing;
90
+ }
91
+ .wf-viewport.is-dragging {
92
+ cursor: grabbing;
93
+ }
94
+
95
+ .wf-world {
96
+ position: absolute;
97
+ left: 0;
98
+ top: 0;
99
+ transform-origin: 0 0;
100
+ }
101
+
102
+ .wf-connectors {
103
+ position: absolute;
104
+ left: 0;
105
+ top: 0;
106
+ overflow: visible;
107
+ pointer-events: none;
108
+ }
109
+
110
+ /* stylelint-enable property-disallowed-list */
111
+ .wf-conn {
112
+ fill: none;
113
+ stroke: var(--workflow-connector-color);
114
+ stroke-width: 2;
115
+ stroke-linecap: round;
116
+ stroke-linejoin: round;
117
+ transition: stroke 150ms ease, stroke-width 150ms ease;
118
+ }
119
+ .wf-conn.is-hover {
120
+ stroke: var(--color-primary);
121
+ stroke-width: 3;
122
+ }
123
+ .wf-conn.is-stub {
124
+ stroke-dasharray: 2 5;
125
+ }
126
+ .wf-conn.is-error {
127
+ stroke: color-mix(in srgb, var(--color-error) 70%, transparent);
128
+ }
129
+
130
+ .wf-arrow {
131
+ fill: var(--workflow-connector-color);
132
+ }
133
+
134
+ .wf-root {
135
+ position: absolute;
136
+ inset-block-start: 0;
137
+ inset-inline-start: 0;
138
+ padding: 48px;
139
+ display: flex;
140
+ font-size: 13px;
141
+ color: var(--color-on-surface);
142
+ }
143
+
144
+ .wf-seq {
145
+ display: flex;
146
+ flex-direction: column;
147
+ align-items: center;
148
+ }
149
+ .horizontal .wf-seq {
150
+ flex-direction: row;
151
+ }
152
+
153
+ .wf-item {
154
+ display: flex;
155
+ flex-direction: column;
156
+ align-items: center;
157
+ }
158
+ .horizontal .wf-item {
159
+ flex-direction: row;
160
+ }
161
+
162
+ .wf-gap {
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ min-block-size: var(--_gap);
167
+ }
168
+ .horizontal .wf-gap {
169
+ min-block-size: 0;
170
+ min-inline-size: var(--_gap);
171
+ }
172
+ .wf-gap.is-trailing {
173
+ min-block-size: 44px;
174
+ }
175
+ .horizontal .wf-gap.is-trailing {
176
+ min-block-size: 0;
177
+ min-inline-size: 44px;
178
+ }
179
+ .wf-gap.is-drop .wf-plus {
180
+ transform: scale(1.35);
181
+ background: var(--color-primary);
182
+ border-color: var(--color-primary);
183
+ --icon-color: var(--color-on-primary);
184
+ }
185
+
186
+ .wf-plus {
187
+ background: transparent;
188
+ border: none;
189
+ appearance: none;
190
+ margin: 0;
191
+ outline: none;
192
+ padding: 0;
193
+ position: relative;
194
+ z-index: 2;
195
+ display: inline-flex;
196
+ align-items: center;
197
+ justify-content: center;
198
+ inline-size: 24px;
199
+ block-size: 24px;
200
+ border-radius: 50%;
201
+ background: var(--workflow-background);
202
+ border: 1.5px solid var(--workflow-connector-color);
203
+ cursor: pointer;
204
+ --icon-size: 0.875rem;
205
+ --icon-color: var(--color-on-surface-variant);
206
+ transition: transform 150ms cubic-bezier(0.2, 0, 0, 1), background-color 150ms ease, border-color 150ms ease;
207
+ }
208
+ .wf-plus:hover, .wf-plus:focus-visible {
209
+ transform: scale(1.2);
210
+ background: var(--color-primary);
211
+ border-color: var(--color-primary);
212
+ --icon-color: var(--color-on-primary);
213
+ }
214
+ .wf-plus:focus-visible {
215
+ outline: 2px solid var(--color-primary);
216
+ outline-offset: 2px;
217
+ }
218
+
219
+ .wf-card {
220
+ position: relative;
221
+ z-index: 1;
222
+ inline-size: var(--workflow-card-width);
223
+ background: var(--color-surface-container-lowest);
224
+ border: 1px solid var(--color-outline-variant);
225
+ border-radius: var(--shape-corner-large);
226
+ box-shadow: var(--elevation-level1);
227
+ cursor: pointer;
228
+ outline: none;
229
+ transition: box-shadow 150ms ease, border-color 150ms ease;
230
+ touch-action: none;
231
+ }
232
+ .density-compact .wf-card {
233
+ inline-size: calc(var(--workflow-card-width) - 60px);
234
+ }
235
+ .density-expanded .wf-card {
236
+ inline-size: calc(var(--workflow-card-width) + 40px);
237
+ }
238
+ .wf-card:hover {
239
+ border-color: var(--color-outline);
240
+ }
241
+ .wf-card:focus-visible {
242
+ outline: 2px solid var(--color-primary);
243
+ outline-offset: 3px;
244
+ }
245
+ .wf-card.is-selected {
246
+ border-color: var(--color-primary);
247
+ box-shadow: 0 0 0 2px var(--color-primary), var(--elevation-level2);
248
+ }
249
+ .wf-card.is-invalid {
250
+ border-color: var(--color-error);
251
+ }
252
+ .wf-card.is-dragging {
253
+ opacity: 0.4;
254
+ }
255
+ .wf-card:hover .wf-more, .wf-card:focus-within .wf-more, .wf-card.is-selected .wf-more {
256
+ opacity: 1;
257
+ }
258
+
259
+ .wf-card-head {
260
+ display: flex;
261
+ align-items: center;
262
+ gap: 12px;
263
+ padding: 12px 8px 12px 12px;
264
+ }
265
+
266
+ .wf-tile {
267
+ display: inline-flex;
268
+ align-items: center;
269
+ justify-content: center;
270
+ flex: none;
271
+ inline-size: 36px;
272
+ block-size: 36px;
273
+ border-radius: var(--shape-corner-medium);
274
+ background: var(--_tile-bg, var(--color-primary-container));
275
+ --icon-color: var(--_tile-fg, var(--color-on-primary-container));
276
+ --icon-size: 1.25rem;
277
+ }
278
+
279
+ .accent-primary {
280
+ --_tile-bg: var(--color-primary-container);
281
+ --_tile-fg: var(--color-on-primary-container);
282
+ }
283
+
284
+ .accent-tertiary {
285
+ --_tile-bg: var(--color-tertiary-container);
286
+ --_tile-fg: var(--color-on-tertiary-container);
287
+ }
288
+
289
+ .accent-blue {
290
+ --_tile-bg: var(--color-blue-container);
291
+ --_tile-fg: var(--color-on-blue-container);
292
+ }
293
+
294
+ .accent-green {
295
+ --_tile-bg: var(--color-green-container);
296
+ --_tile-fg: var(--color-on-green-container);
297
+ }
298
+
299
+ .accent-orange {
300
+ --_tile-bg: var(--color-orange-container);
301
+ --_tile-fg: var(--color-on-orange-container);
302
+ }
303
+
304
+ .accent-purple {
305
+ --_tile-bg: var(--color-purple-container);
306
+ --_tile-fg: var(--color-on-purple-container);
307
+ }
308
+
309
+ .accent-red {
310
+ --_tile-bg: var(--color-error-container);
311
+ --_tile-fg: var(--color-on-error-container);
312
+ }
313
+
314
+ .accent-yellow {
315
+ --_tile-bg: var(--color-yellow-container);
316
+ --_tile-fg: var(--color-on-yellow-container);
317
+ }
318
+
319
+ .accent-neutral {
320
+ --_tile-bg: var(--color-surface-container-high);
321
+ --_tile-fg: var(--color-on-surface-variant);
322
+ }
323
+
324
+ .wf-names {
325
+ display: flex;
326
+ flex-direction: column;
327
+ flex: 1;
328
+ min-inline-size: 0;
329
+ }
330
+
331
+ .wf-headline {
332
+ font-size: 14px;
333
+ font-weight: 500;
334
+ line-height: 1.3;
335
+ white-space: nowrap;
336
+ overflow: hidden;
337
+ text-overflow: ellipsis;
338
+ }
339
+
340
+ .wf-kind {
341
+ font-size: 12px;
342
+ color: var(--color-on-surface-variant);
343
+ white-space: nowrap;
344
+ overflow: hidden;
345
+ text-overflow: ellipsis;
346
+ }
347
+
348
+ .wf-badge {
349
+ display: inline-flex;
350
+ --icon-color: var(--color-error);
351
+ --icon-size: 1.125rem;
352
+ }
353
+
354
+ .wf-more {
355
+ opacity: 0;
356
+ transition: opacity 150ms ease;
357
+ }
358
+
359
+ .wf-card-body {
360
+ display: flex;
361
+ flex-direction: column;
362
+ gap: 4px;
363
+ padding: 0 12px 12px 60px;
364
+ }
365
+
366
+ .wf-summary {
367
+ font-size: 12px;
368
+ color: var(--color-on-surface-variant);
369
+ }
370
+
371
+ .wf-field {
372
+ display: flex;
373
+ align-items: baseline;
374
+ gap: 8px;
375
+ min-inline-size: 0;
376
+ }
377
+
378
+ .wf-field-label {
379
+ flex: none;
380
+ inline-size: 68px;
381
+ font-size: 12px;
382
+ color: var(--color-on-surface-variant);
383
+ }
384
+
385
+ .wf-field-value {
386
+ min-inline-size: 0;
387
+ font-family: var(--typography-code-small-font-family, monospace);
388
+ font-size: 12px;
389
+ white-space: nowrap;
390
+ overflow: hidden;
391
+ text-overflow: ellipsis;
392
+ }
393
+
394
+ .wf-ref {
395
+ display: inline-flex;
396
+ align-items: center;
397
+ gap: 4px;
398
+ padding: 1px 8px 1px 6px;
399
+ font-family: inherit;
400
+ font-size: 12px;
401
+ vertical-align: middle;
402
+ border-radius: var(--shape-corner-full);
403
+ background: var(--color-secondary-container);
404
+ color: var(--color-on-secondary-container);
405
+ --icon-size: 0.875rem;
406
+ --icon-color: var(--color-on-secondary-container);
407
+ }
408
+ .wf-field-value .wf-ref {
409
+ font-family: var(--typography-body-small-font-family, inherit);
410
+ }
411
+
412
+ .wf-card-foot {
413
+ display: flex;
414
+ flex-wrap: wrap;
415
+ align-items: center;
416
+ gap: 6px;
417
+ padding: 8px 12px;
418
+ border-block-start: 1px solid var(--color-outline-variant);
419
+ font-size: 12px;
420
+ color: var(--color-on-surface-variant);
421
+ }
422
+
423
+ .wf-assignee {
424
+ display: inline-flex;
425
+ align-items: center;
426
+ gap: 6px;
427
+ }
428
+
429
+ .wf-foot-label {
430
+ margin-inline-end: 2px;
431
+ }
432
+
433
+ .wf-chip {
434
+ display: inline-flex;
435
+ align-items: center;
436
+ gap: 4px;
437
+ padding: 1px 8px;
438
+ font-size: 11px;
439
+ border-radius: var(--shape-corner-full);
440
+ border: 1px solid var(--color-outline-variant);
441
+ --icon-size: 0.75rem;
442
+ }
443
+ .wf-chip.tool {
444
+ border-color: transparent;
445
+ background: var(--color-tertiary-container);
446
+ color: var(--color-on-tertiary-container);
447
+ --icon-color: var(--color-on-tertiary-container);
448
+ }
449
+
450
+ .wf-block {
451
+ display: flex;
452
+ flex-direction: column;
453
+ align-items: center;
454
+ }
455
+ .horizontal .wf-block {
456
+ flex-direction: row;
457
+ }
458
+
459
+ .wf-paths {
460
+ display: flex;
461
+ align-items: stretch;
462
+ gap: 32px;
463
+ margin-block-start: 40px;
464
+ }
465
+ .horizontal .wf-paths {
466
+ flex-direction: column;
467
+ margin-block-start: 0;
468
+ margin-inline-start: 40px;
469
+ }
470
+
471
+ .wf-path {
472
+ display: flex;
473
+ flex-direction: column;
474
+ align-items: center;
475
+ }
476
+ .horizontal .wf-path {
477
+ flex-direction: row;
478
+ }
479
+
480
+ .wf-path-tail {
481
+ flex: 1;
482
+ }
483
+
484
+ .wf-pill {
485
+ position: relative;
486
+ z-index: 1;
487
+ padding: 3px 12px;
488
+ font-size: 12px;
489
+ font-weight: 500;
490
+ white-space: nowrap;
491
+ border-radius: var(--shape-corner-full);
492
+ background: var(--color-primary-container);
493
+ color: var(--color-on-primary-container);
494
+ }
495
+ .wf-pill.is-default {
496
+ background: var(--color-surface-container-high);
497
+ color: var(--color-on-surface-variant);
498
+ }
499
+ .wf-pill.is-error {
500
+ background: var(--color-error-container);
501
+ color: var(--color-on-error-container);
502
+ }
503
+
504
+ .wf-join {
505
+ position: relative;
506
+ z-index: 1;
507
+ inline-size: 10px;
508
+ block-size: 10px;
509
+ margin-block-start: 40px;
510
+ border-radius: 50%;
511
+ background: var(--workflow-connector-color);
512
+ }
513
+ .horizontal .wf-join {
514
+ margin-block-start: 0;
515
+ margin-inline-start: 40px;
516
+ }
517
+ .wf-join.is-bar {
518
+ inline-size: auto;
519
+ block-size: auto;
520
+ padding: 3px 12px;
521
+ font-size: 11px;
522
+ font-weight: 500;
523
+ border-radius: var(--shape-corner-full);
524
+ background: var(--color-surface-container-high);
525
+ color: var(--color-on-surface-variant);
526
+ border: 2px solid var(--workflow-connector-color);
527
+ }
528
+
529
+ .wf-loop {
530
+ padding: 12px 24px 28px 40px;
531
+ border: 1.5px dashed var(--color-outline);
532
+ border-radius: var(--shape-corner-extra-large);
533
+ background: color-mix(in srgb, var(--color-surface-container-low) 70%, transparent);
534
+ }
535
+ .horizontal .wf-loop {
536
+ padding: 40px 28px 24px 12px;
537
+ }
538
+
539
+ .wf-loop-head {
540
+ display: flex;
541
+ flex-direction: column;
542
+ align-items: center;
543
+ gap: 8px;
544
+ }
545
+
546
+ .wf-loop-over {
547
+ display: inline-flex;
548
+ align-items: center;
549
+ gap: 6px;
550
+ font-size: 12px;
551
+ color: var(--color-on-surface-variant);
552
+ }
553
+
554
+ .wf-has-error {
555
+ display: grid;
556
+ grid-template-columns: 1fr auto 1fr;
557
+ align-items: start;
558
+ gap: 48px;
559
+ }
560
+ .horizontal .wf-has-error {
561
+ grid-template-columns: none;
562
+ grid-template-rows: 1fr auto 1fr;
563
+ justify-items: start;
564
+ }
565
+
566
+ .wf-error-col {
567
+ display: flex;
568
+ flex-direction: column;
569
+ align-items: center;
570
+ margin-block-start: 64px;
571
+ }
572
+ .horizontal .wf-error-col {
573
+ flex-direction: row;
574
+ margin-block-start: 0;
575
+ margin-inline-start: 64px;
576
+ }
577
+
578
+ .wf-end {
579
+ position: relative;
580
+ z-index: 1;
581
+ display: inline-flex;
582
+ align-items: center;
583
+ gap: 6px;
584
+ padding: 6px 16px;
585
+ font-size: 12px;
586
+ font-weight: 500;
587
+ border-radius: var(--shape-corner-full);
588
+ border: 1px solid var(--color-outline-variant);
589
+ background: var(--color-surface-container-low);
590
+ color: var(--color-on-surface-variant);
591
+ cursor: pointer;
592
+ outline: none;
593
+ --icon-size: 1rem;
594
+ }
595
+ .wf-end:focus-visible {
596
+ outline: 2px solid var(--color-primary);
597
+ outline-offset: 2px;
598
+ }
599
+ .wf-end.is-selected {
600
+ border-color: var(--color-primary);
601
+ box-shadow: 0 0 0 2px var(--color-primary);
602
+ }
603
+ .wf-end.is-invalid {
604
+ border-color: var(--color-error);
605
+ }
606
+
607
+ .wf-add-trigger {
608
+ background: transparent;
609
+ border: none;
610
+ appearance: none;
611
+ margin: 0;
612
+ outline: none;
613
+ padding: 0;
614
+ display: inline-flex;
615
+ align-items: center;
616
+ justify-content: center;
617
+ gap: 8px;
618
+ inline-size: var(--workflow-card-width);
619
+ block-size: 64px;
620
+ font-size: 14px;
621
+ font-weight: 500;
622
+ color: var(--color-primary);
623
+ border: 1.5px dashed var(--color-primary);
624
+ border-radius: var(--shape-corner-large);
625
+ background: color-mix(in srgb, var(--color-primary) 6%, transparent);
626
+ cursor: pointer;
627
+ --icon-color: var(--color-primary);
628
+ }
629
+ .wf-add-trigger:hover, .wf-add-trigger:focus-visible {
630
+ background: color-mix(in srgb, var(--color-primary) 12%, transparent);
631
+ }
632
+
633
+ .wf-palette {
634
+ position: absolute;
635
+ z-index: 30;
636
+ display: flex;
637
+ flex-direction: column;
638
+ inline-size: 300px;
639
+ max-block-size: 380px;
640
+ overflow: hidden;
641
+ background: var(--color-surface-container-lowest);
642
+ border: 1px solid var(--color-outline-variant);
643
+ border-radius: var(--shape-corner-large);
644
+ box-shadow: var(--elevation-level3);
645
+ }
646
+
647
+ .wf-palette-search {
648
+ display: flex;
649
+ align-items: center;
650
+ gap: 8px;
651
+ margin: 8px;
652
+ padding: 0 12px;
653
+ block-size: 40px;
654
+ border-radius: var(--shape-corner-full);
655
+ background: var(--color-surface-container);
656
+ --icon-color: var(--color-on-surface-variant);
657
+ }
658
+ .wf-palette-search input {
659
+ flex: 1;
660
+ min-inline-size: 0;
661
+ border: 0;
662
+ outline: none;
663
+ background: transparent;
664
+ font: inherit;
665
+ font-size: 14px;
666
+ color: var(--color-on-surface);
667
+ }
668
+ .wf-palette-search:focus-within {
669
+ box-shadow: 0 0 0 2px var(--color-primary);
670
+ }
671
+
672
+ .wf-palette-list {
673
+ overflow-y: auto;
674
+ overscroll-behavior: contain;
675
+ padding: 0 4px 8px;
676
+ }
677
+
678
+ .wf-palette-heading {
679
+ padding: 8px 12px 4px;
680
+ font-size: 11px;
681
+ font-weight: 500;
682
+ color: var(--color-on-surface-variant);
683
+ }
684
+
685
+ .wf-option {
686
+ display: flex;
687
+ align-items: center;
688
+ gap: 12px;
689
+ padding: 6px 8px;
690
+ border-radius: var(--shape-corner-medium);
691
+ cursor: pointer;
692
+ }
693
+ .wf-option .wf-tile {
694
+ inline-size: 32px;
695
+ block-size: 32px;
696
+ --icon-size: 1.125rem;
697
+ }
698
+ .wf-option.is-active {
699
+ background: color-mix(in srgb, var(--color-primary) 10%, transparent);
700
+ }
701
+
702
+ .wf-option-text {
703
+ display: flex;
704
+ flex-direction: column;
705
+ min-inline-size: 0;
706
+ }
707
+
708
+ .wf-option-title {
709
+ font-size: 14px;
710
+ font-weight: 500;
711
+ }
712
+
713
+ .wf-option-sub {
714
+ font-size: 12px;
715
+ color: var(--color-on-surface-variant);
716
+ }
717
+
718
+ .wf-palette-empty {
719
+ padding: 16px;
720
+ font-size: 13px;
721
+ color: var(--color-on-surface-variant);
722
+ text-align: center;
723
+ }
724
+
725
+ .wf-ghost {
726
+ position: absolute;
727
+ z-index: 40;
728
+ display: inline-flex;
729
+ align-items: center;
730
+ gap: 8px;
731
+ padding: 8px 14px;
732
+ font-size: 13px;
733
+ font-weight: 500;
734
+ pointer-events: none;
735
+ transform: translate(12px, 12px) rotate(-2deg);
736
+ background: var(--color-surface-container-lowest);
737
+ border: 1px solid var(--color-primary);
738
+ border-radius: var(--shape-corner-medium);
739
+ box-shadow: var(--elevation-level3);
740
+ --icon-size: 1.125rem;
741
+ }
742
+
743
+ .wf-problems {
744
+ background: transparent;
745
+ border: none;
746
+ appearance: none;
747
+ margin: 0;
748
+ outline: none;
749
+ padding: 0;
750
+ position: absolute;
751
+ z-index: 20;
752
+ inset-block-start: 16px;
753
+ inset-inline-start: 16px;
754
+ display: inline-flex;
755
+ align-items: center;
756
+ gap: 6px;
757
+ padding: 6px 14px;
758
+ font-size: 13px;
759
+ font-weight: 500;
760
+ border-radius: var(--shape-corner-full);
761
+ background: var(--color-error-container);
762
+ color: var(--color-on-error-container);
763
+ cursor: pointer;
764
+ box-shadow: var(--elevation-level1);
765
+ --icon-color: var(--color-on-error-container);
766
+ --icon-size: 1.125rem;
767
+ }
768
+
769
+ .back-to-content {
770
+ position: absolute;
771
+ inset-inline-start: 50%;
772
+ inset-block-end: 24px;
773
+ transform: translateX(-50%);
774
+ box-shadow: var(--elevation-level2);
775
+ border-radius: var(--shape-corner-full);
776
+ z-index: 20;
777
+ }
778
+
779
+ .slot-controls,
780
+ .slot-minimap {
781
+ position: absolute;
782
+ inset-block-end: 16px;
783
+ z-index: 20;
784
+ }
785
+
786
+ .slot-controls {
787
+ inset-inline-start: 16px;
788
+ }
789
+
790
+ .slot-minimap {
791
+ inset-inline-end: 16px;
792
+ }
793
+
794
+ @container diagram (max-width: 480px) {
795
+ .slot-minimap {
796
+ display: none;
797
+ }
798
+ .slot-controls {
799
+ inset-inline-start: 8px;
800
+ inset-block-end: 8px;
801
+ }
802
+ }
803
+ .sr-only {
804
+ position: absolute;
805
+ inline-size: 1px;
806
+ block-size: 1px;
807
+ padding: 0;
808
+ margin: -1px;
809
+ overflow: hidden;
810
+ clip-path: inset(50%);
811
+ white-space: nowrap;
812
+ border: 0;
813
+ }
814
+
815
+ .wf-conn.is-taken {
816
+ stroke: var(--color-primary);
817
+ stroke-width: 2.75;
818
+ }
819
+ .wf-conn.is-active {
820
+ stroke-dasharray: 7 6;
821
+ animation: wf-flow 0.9s linear infinite;
822
+ }
823
+ .wf-conn.is-untaken {
824
+ stroke: var(--color-outline-variant);
825
+ stroke-dasharray: 4 5;
826
+ opacity: 0.7;
827
+ }
828
+
829
+ .wf-tokens {
830
+ position: absolute;
831
+ inset-block-start: 0;
832
+ inset-inline-start: 0;
833
+ overflow: visible;
834
+ pointer-events: none;
835
+ }
836
+
837
+ .wf-token {
838
+ fill: var(--color-primary);
839
+ }
840
+
841
+ .wf-token-halo {
842
+ fill: color-mix(in srgb, var(--color-primary) 22%, transparent);
843
+ }
844
+
845
+ .wf-status {
846
+ position: absolute;
847
+ z-index: 2;
848
+ inset-block-start: -11px;
849
+ inset-inline-end: 12px;
850
+ display: inline-flex;
851
+ align-items: center;
852
+ gap: 4px;
853
+ block-size: 22px;
854
+ padding: 0 8px 0 4px;
855
+ font-size: 11px;
856
+ font-weight: 500;
857
+ white-space: nowrap;
858
+ color: var(--color-on-surface-variant);
859
+ background: var(--color-surface-container-lowest);
860
+ border: 1px solid var(--color-outline-variant);
861
+ border-radius: var(--shape-corner-full);
862
+ --icon-size: 0.9375rem;
863
+ }
864
+ .wf-status.st-success {
865
+ border-color: var(--color-success);
866
+ }
867
+ .wf-status.st-failed {
868
+ border-color: var(--color-error);
869
+ }
870
+ .wf-status.st-running, .wf-status.st-paused, .wf-status.st-waiting {
871
+ border-color: var(--color-primary);
872
+ }
873
+ .wf-status.st-success {
874
+ --icon-color: var(--color-success);
875
+ }
876
+ .wf-status.st-failed {
877
+ color: var(--color-error);
878
+ --icon-color: var(--color-error);
879
+ }
880
+ .wf-status.st-running, .wf-status.st-paused, .wf-status.st-waiting {
881
+ color: var(--color-primary);
882
+ --icon-color: var(--color-primary);
883
+ }
884
+ .wf-status.st-running wc-icon {
885
+ animation: wf-spin 1s linear infinite;
886
+ }
887
+
888
+ .wf-attempts {
889
+ padding: 0 6px;
890
+ font-size: 11px;
891
+ border-radius: var(--shape-corner-full);
892
+ background: var(--color-surface-container-high);
893
+ }
894
+
895
+ .wf-card.st-success,
896
+ .wf-end.st-success {
897
+ border-color: var(--color-success);
898
+ }
899
+ .wf-card.st-failed,
900
+ .wf-end.st-failed {
901
+ border-color: var(--color-error);
902
+ box-shadow: 0 0 0 1px var(--color-error), var(--elevation-level1);
903
+ }
904
+ .wf-card.st-running, .wf-card.st-paused, .wf-card.st-waiting,
905
+ .wf-end.st-running,
906
+ .wf-end.st-paused,
907
+ .wf-end.st-waiting {
908
+ border-color: var(--color-primary);
909
+ animation: wf-pulse 1.6s ease-in-out infinite;
910
+ }
911
+ .wf-card.st-skipped, .wf-card.st-queued, .wf-card.st-canceled,
912
+ .wf-end.st-skipped,
913
+ .wf-end.st-queued,
914
+ .wf-end.st-canceled {
915
+ opacity: 0.5;
916
+ box-shadow: none;
917
+ }
918
+
919
+ .wf-run-error {
920
+ display: flex;
921
+ align-items: center;
922
+ gap: 8px;
923
+ margin: 0 12px 12px;
924
+ padding: 8px 10px;
925
+ font-size: 12px;
926
+ border-radius: var(--shape-corner-small);
927
+ background: var(--color-error-container);
928
+ color: var(--color-on-error-container);
929
+ }
930
+
931
+ .wf-run-error-text {
932
+ flex: 1;
933
+ min-inline-size: 0;
934
+ overflow: hidden;
935
+ text-overflow: ellipsis;
936
+ white-space: nowrap;
937
+ }
938
+
939
+ .wf-retry {
940
+ background: transparent;
941
+ border: none;
942
+ appearance: none;
943
+ margin: 0;
944
+ outline: none;
945
+ padding: 0;
946
+ display: inline-flex;
947
+ align-items: center;
948
+ gap: 4px;
949
+ flex: none;
950
+ padding: 2px 8px;
951
+ font-size: 12px;
952
+ font-weight: 500;
953
+ color: inherit;
954
+ border-radius: var(--shape-corner-full);
955
+ cursor: pointer;
956
+ --icon-size: 0.875rem;
957
+ --icon-color: currentcolor;
958
+ }
959
+ .wf-retry:hover {
960
+ background: color-mix(in srgb, currentcolor 12%, transparent);
961
+ }
962
+
963
+ .wf-pin {
964
+ display: inline-flex;
965
+ --icon-color: var(--color-primary);
966
+ --icon-size: 1rem;
967
+ }
968
+
969
+ .wf-bp {
970
+ background: transparent;
971
+ border: none;
972
+ appearance: none;
973
+ margin: 0;
974
+ outline: none;
975
+ padding: 0;
976
+ position: absolute;
977
+ inset-block-start: 16px;
978
+ inset-inline-start: -26px;
979
+ inline-size: 14px;
980
+ block-size: 14px;
981
+ border-radius: 50%;
982
+ border: 1.5px dashed var(--color-outline);
983
+ background: transparent;
984
+ cursor: pointer;
985
+ opacity: 0;
986
+ transition: opacity 150ms ease;
987
+ }
988
+ .wf-card:hover .wf-bp, .wf-card:focus-within .wf-bp, .wf-bp.is-on {
989
+ opacity: 1;
990
+ }
991
+ .wf-bp.is-on {
992
+ border: 0;
993
+ background: var(--color-error);
994
+ box-shadow: 0 0 0 3px var(--workflow-background);
995
+ }
996
+
997
+ .wf-iterations {
998
+ display: inline-flex;
999
+ align-items: center;
1000
+ gap: 2px;
1001
+ padding: 2px 8px 2px 2px;
1002
+ font-size: 12px;
1003
+ border-radius: var(--shape-corner-full);
1004
+ background: var(--color-surface-container-lowest);
1005
+ border: 1px solid var(--color-outline-variant);
1006
+ }
1007
+
1008
+ .wf-iteration-label {
1009
+ min-inline-size: 44px;
1010
+ text-align: center;
1011
+ font-variant-numeric: tabular-nums;
1012
+ }
1013
+
1014
+ .wf-ticks {
1015
+ display: inline-flex;
1016
+ gap: 3px;
1017
+ margin-inline-start: 6px;
1018
+ }
1019
+
1020
+ .wf-tick {
1021
+ background: transparent;
1022
+ border: none;
1023
+ appearance: none;
1024
+ margin: 0;
1025
+ outline: none;
1026
+ padding: 0;
1027
+ inline-size: 8px;
1028
+ block-size: 8px;
1029
+ border-radius: var(--shape-corner-extra-small);
1030
+ background: var(--color-outline-variant);
1031
+ cursor: pointer;
1032
+ }
1033
+ .wf-tick.st-success {
1034
+ background: var(--color-success);
1035
+ }
1036
+ .wf-tick.st-failed {
1037
+ background: var(--color-error);
1038
+ }
1039
+ .wf-tick.st-running {
1040
+ background: var(--color-primary);
1041
+ }
1042
+ .wf-tick.is-current {
1043
+ outline: 2px solid color-mix(in srgb, var(--color-primary) 45%, transparent);
1044
+ outline-offset: 1px;
1045
+ }
1046
+
1047
+ .wf-debugbar,
1048
+ .wf-runbar {
1049
+ position: absolute;
1050
+ z-index: 25;
1051
+ inset-block-start: 16px;
1052
+ inset-inline-start: 50%;
1053
+ transform: translateX(-50%);
1054
+ display: flex;
1055
+ align-items: center;
1056
+ gap: 6px;
1057
+ padding: 6px;
1058
+ background: var(--color-surface-container-lowest);
1059
+ border: 1px solid var(--color-outline-variant);
1060
+ border-radius: var(--shape-corner-full);
1061
+ box-shadow: var(--elevation-level2);
1062
+ }
1063
+
1064
+ .wf-runbar {
1065
+ padding: 8px 16px;
1066
+ font-size: 13px;
1067
+ font-weight: 500;
1068
+ }
1069
+ .wf-runbar.st-success {
1070
+ color: var(--color-success);
1071
+ }
1072
+ .wf-runbar.st-failed {
1073
+ color: var(--color-error);
1074
+ }
1075
+
1076
+ .wf-run-status {
1077
+ padding: 4px 12px;
1078
+ margin-inline-end: 4px;
1079
+ font-size: 12px;
1080
+ font-weight: 500;
1081
+ border-radius: var(--shape-corner-full);
1082
+ background: var(--color-surface-container-high);
1083
+ color: var(--color-on-surface-variant);
1084
+ }
1085
+ .wf-run-status.st-paused {
1086
+ background: var(--color-yellow-container);
1087
+ color: var(--color-on-yellow-container);
1088
+ }
1089
+ .wf-run-status.st-running {
1090
+ background: var(--color-primary-container);
1091
+ color: var(--color-on-primary-container);
1092
+ }
1093
+ .wf-run-status.st-failed {
1094
+ background: var(--color-error-container);
1095
+ color: var(--color-on-error-container);
1096
+ }
1097
+ .wf-run-status.st-success {
1098
+ background: var(--color-green-container);
1099
+ color: var(--color-on-green-container);
1100
+ }
1101
+
1102
+ @keyframes wf-flow {
1103
+ to {
1104
+ stroke-dashoffset: -26;
1105
+ }
1106
+ }
1107
+ @keyframes wf-spin {
1108
+ to {
1109
+ transform: rotate(360deg);
1110
+ }
1111
+ }
1112
+ @keyframes wf-pulse {
1113
+ 0%, 100% {
1114
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent), var(--elevation-level2);
1115
+ }
1116
+ 50% {
1117
+ box-shadow: 0 0 0 7px color-mix(in srgb, var(--color-primary) 30%, transparent), var(--elevation-level2);
1118
+ }
1119
+ }
1120
+ @media (prefers-reduced-motion: reduce) {
1121
+ .wf-conn,
1122
+ .wf-plus,
1123
+ .wf-card,
1124
+ .wf-more,
1125
+ .wf-bp {
1126
+ transition: none;
1127
+ }
1128
+ .wf-conn.is-active,
1129
+ .wf-status.st-running wc-icon,
1130
+ .wf-card.st-running,
1131
+ .wf-card.st-paused,
1132
+ .wf-card.st-waiting,
1133
+ .wf-end.st-running {
1134
+ animation: none;
1135
+ }
1136
+ }`;
1137
+
1138
+ var Workflow_1;
1139
+ /** Below this zoom a fitted workflow is hard to read, so it starts at its beginning instead. */
1140
+ const MIN_FIT_ZOOM = 0.6;
1141
+ /** Pointer travel, in screen pixels, before a press on a step becomes a drag. */
1142
+ const DRAG_THRESHOLD = 5;
1143
+ /** Screen pixels within which a dragged step snaps to a gap. */
1144
+ const DROP_DISTANCE = 64;
1145
+ const CORNER = 20;
1146
+ const TRIGGER_GAP = '__trigger';
1147
+ const DATA_PILL = /\{\{\s*([^}]+?)\s*\}\}/g;
1148
+ /** Elements inside a card that handle their own pointer input. */
1149
+ const INTERACTIVE = 'button, a, input, select, textarea, wc-icon-button, wc-button, [contenteditable]';
1150
+ /** Shared between workflows on a page, like the system clipboard. */
1151
+ let clipboard;
1152
+ /**
1153
+ * @label Workflow
1154
+ * @tag wc-workflow
1155
+ * @rawTag workflow
1156
+ * @summary A structured builder for business rules and processes: steps, branches that merge back, parallel paths, loops, error paths and ends.
1157
+ *
1158
+ * @overview
1159
+ * <p>Set <code>value</code> to a trigger and a list of steps. Steps are <code>action</code>,
1160
+ * <code>wait</code> and <code>end</code> cards, <code>branch</code> and <code>parallel</code> blocks whose
1161
+ * paths sit side by side and merge back below (a path that ends draws no merge), and
1162
+ * <code>loop</code> frames. An action's <code>onError</code> steps run as a side path. The layout is
1163
+ * automatic: top to bottom, or left to right with <code>direction="horizontal"</code>, joined by rounded
1164
+ * connectors.</p>
1165
+ * <p>Cards show a tinted icon, a headline and the kind of step, up to three <code>fields</code>
1166
+ * (<code>{{Step.output}}</code> in a value renders as a data pill), and a footer with outputs, tools or
1167
+ * an assignee. <code>density</code> shows less (<code>compact</code>) or everything
1168
+ * (<code>expanded</code>). Put your own card in <code>slot="step:&lt;id&gt;"</code>.</p>
1169
+ * <p>With <code>editable</code>, a "+" on every connector opens a searchable palette built from
1170
+ * <code>stepTypes</code>; <code>step-add</code> fires first and can be canceled to show your own dialog.
1171
+ * Drag a step to another "+" to move it, delete it with Delete, duplicate with Ctrl+D, copy and paste,
1172
+ * and undo with Ctrl+Z. Steps glide to their new places. Every edit fires <code>change</code> with the
1173
+ * new <code>value</code>; selecting a step fires <code>select</code>, for your inspector. Apply its edits
1174
+ * with <code>updateStep()</code>.</p>
1175
+ * <p>The canvas is infinite, like <code>wc-diagram</code>: pan, zoom, <code>start-position</code>,
1176
+ * <code>home()</code>, and the <code>controls</code> and <code>minimap</code> slots. Steps are a tree for
1177
+ * screen readers. Up and Down move through steps in reading order, Left and Right move between the
1178
+ * paths of a branch (in a horizontal workflow the keys swap), Insert opens the palette after the
1179
+ * focused step, Alt + Up or Down moves it, and Shift + Enter collapses or expands a block.</p>
1180
+ * <p><code>mode="debug"</code> and <code>mode="history"</code> show a <code>run</code> from your engine:
1181
+ * each card gets its status and duration, the path taken is drawn solid and paths not taken are
1182
+ * dashed, the running step pulses and a dot travels into each step the run reaches
1183
+ * (<code>follow</code> keeps it in view). A failed step shows its error with "Retry from here". In
1184
+ * debug mode a debug bar fires <code>debug-action</code> (Continue F5, Step over F10, Step into F11,
1185
+ * Restart, Stop Shift+F5), and the dot left of each card toggles a breakpoint (F9) and fires
1186
+ * <code>breakpoint-toggle</code>. A loop shows an iteration picker; the steps inside show the picked
1187
+ * iteration. History mode is read-only. Editing is off outside <code>design</code>. Pair it with
1188
+ * <code>wc-workflow-timeline</code> for a timeline of the run.</p>
1189
+ *
1190
+ * @example
1191
+ * ```html
1192
+ * <wc-workflow id="rule" editable style="height: 600px">
1193
+ * <wc-diagram-controls slot="controls"></wc-diagram-controls>
1194
+ * </wc-workflow>
1195
+ * <script>
1196
+ * document.getElementById('rule').value = {
1197
+ * trigger: { id: 'created', type: 'action', headline: 'Expense created', icon: 'bolt' },
1198
+ * steps: [
1199
+ * {
1200
+ * id: 'amount', type: 'branch', headline: 'Amount check',
1201
+ * paths: [
1202
+ * { id: 'big', label: 'amount > 1,000', steps: [{ id: 'approve', type: 'action', headline: 'Manager approval' }] },
1203
+ * { id: 'small', label: 'Otherwise', isDefault: true, steps: [] }
1204
+ * ]
1205
+ * },
1206
+ * { id: 'end', type: 'end' }
1207
+ * ]
1208
+ * };
1209
+ * </script>
1210
+ * ```
1211
+ *
1212
+ * @slot controls - A `wc-diagram-controls`, shown at the bottom start corner.
1213
+ * @slot minimap - A `wc-diagram-minimap`, shown at the bottom end corner.
1214
+ * @slot step:<id> - Custom content for the step with that id, in place of the built-in card.
1215
+ *
1216
+ * @fires {CustomEvent<WorkflowSelectDetail>} select - A step was chosen with a click, Enter or Space. Detail contains `{ id, step }`.
1217
+ * @fires {CustomEvent<WorkflowStepAddDetail>} step-add - Before a step from the palette is added. Cancel it to add the step your own way. Detail contains `{ stepType, list, index, trigger }`.
1218
+ * @fires {CustomEvent<WorkflowDeleteDetail>} delete - Before steps are removed. Cancel it to keep them. Detail contains `{ ids }`.
1219
+ * @fires {CustomEvent<WorkflowChangeDetail>} change - After every edit. Detail contains `{ value, reason }`.
1220
+ * @fires {CustomEvent<WorkflowViewportDetail>} viewport-change - Once per frame while the camera moves and once when it settles. Detail contains `{ x, y, zoom, settled }`.
1221
+ * @fires {CustomEvent<WorkflowDebugActionDetail>} debug-action - A debug bar button, a debug shortcut or "Retry from here" was used. Detail contains `{ action, stepId }`.
1222
+ * @fires {CustomEvent<WorkflowBreakpointDetail>} breakpoint-toggle - A breakpoint was set or cleared in debug mode. Detail contains `{ id, enabled, breakpoints }`.
1223
+ * @fires {CustomEvent<WorkflowIterationDetail>} iteration-change - A different loop iteration was picked. Detail contains `{ loopId, index }`.
1224
+ *
1225
+ * @cssprop --workflow-card-width - Width of a standard card. Defaults to 280px.
1226
+ * @cssprop --workflow-connector-color - Colour of connectors. Defaults to a mix of primary and outline-variant.
1227
+ * @cssprop --workflow-background - Canvas background. Defaults to surface-container-lowest.
1228
+ * @tags data
1229
+ */
1230
+ let Workflow = Workflow_1 = class Workflow extends DiagramCanvasElement {
1231
+ constructor() {
1232
+ // ── Static
1233
+ super(...arguments);
1234
+ // ── Properties
1235
+ /** The workflow: a trigger and its steps. Replaced with a new object, never mutated, on every edit. */
1236
+ this.value = { steps: [] };
1237
+ /** Entries of the add-step palette. Defaults to the logic steps (branch, parallel, loop, wait, end). */
1238
+ this.stepTypes = WORKFLOW_LOGIC_STEPS;
1239
+ /** Lays the workflow out top to bottom or left to right. */
1240
+ this.direction = 'vertical';
1241
+ /** How much each card shows: the header only, up to three fields, or everything. */
1242
+ this.density = 'standard';
1243
+ /** Id of the selected step. */
1244
+ this.selected = '';
1245
+ /**
1246
+ * `design` edits the workflow. `debug` shows a live `run` with a debug bar and breakpoints.
1247
+ * `history` replays a past `run`, read-only. Editing is off outside `design`.
1248
+ */
1249
+ this.mode = 'design';
1250
+ /** Ids of steps with a breakpoint, shown and toggled in `debug` mode. */
1251
+ this.breakpoints = [];
1252
+ /** Keeps the step that is running in view as the run moves. */
1253
+ this.follow = false;
1254
+ this._collapsed = new Set();
1255
+ this._focusId = '';
1256
+ this._hoverGap = '';
1257
+ this._menuFor = '';
1258
+ this._announcement = '';
1259
+ /** The iteration shown for each loop, when the person picked one. */
1260
+ this._iterations = new Map();
1261
+ /** For each step, the loops it is inside, outermost first. */
1262
+ this.loopParents = new Map();
1263
+ /** Step statuses at the last render, to spot steps the run just reached. */
1264
+ this.lastStatuses = new Map();
1265
+ this.pendingTokens = [];
1266
+ this.history = new History();
1267
+ this.handledKeys = new WeakSet();
1268
+ /** Gap keys to the list and index they insert at, from the last render. */
1269
+ this.gaps = new Map();
1270
+ this.unreachable = new Set();
1271
+ this.seenCollapsed = new Set();
1272
+ this.connectorsDirty = true;
1273
+ this.trackFrame = 0;
1274
+ this.problemIndex = -1;
1275
+ this.onPaletteKeyDown = (event) => {
1276
+ const p = this._palette;
1277
+ if (!p)
1278
+ return;
1279
+ const entries = this.paletteEntries();
1280
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
1281
+ event.preventDefault();
1282
+ const delta = event.key === 'ArrowDown' ? 1 : -1;
1283
+ const count = Math.max(entries.length, 1);
1284
+ this._palette = { ...p, active: (p.active + delta + count) % count };
1285
+ }
1286
+ else if (event.key === 'Enter') {
1287
+ event.preventDefault();
1288
+ const entry = entries[p.active];
1289
+ if (entry)
1290
+ this.choose(entry);
1291
+ }
1292
+ else if (event.key === 'Escape') {
1293
+ event.preventDefault();
1294
+ this.closePalette();
1295
+ }
1296
+ event.stopPropagation();
1297
+ this.handledKeys.add(event);
1298
+ };
1299
+ this.onViewportKeyDown = (event) => {
1300
+ if (event.defaultPrevented || this.handledKeys.has(event))
1301
+ return;
1302
+ const origin = event.composedPath()[0];
1303
+ if (origin instanceof HTMLElement &&
1304
+ origin.matches('input, textarea, select, [contenteditable]')) {
1305
+ return;
1306
+ }
1307
+ const mod = event.ctrlKey || event.metaKey;
1308
+ const key = event.key.toLowerCase();
1309
+ const run = (fn) => {
1310
+ event.preventDefault();
1311
+ fn();
1312
+ };
1313
+ if (mod && key === 'z' && this.editing)
1314
+ run(() => (event.shiftKey ? this.redo() : this.undo()));
1315
+ else if (mod && key === 'y' && this.editing)
1316
+ run(() => this.redo());
1317
+ else if (mod && key === 'c' && this.selected)
1318
+ run(() => this.copy(this.selected));
1319
+ else if (mod && key === 'v' && this.editing)
1320
+ run(() => this.paste());
1321
+ else if (mod && key === 'd' && this.editing && this.selected) {
1322
+ run(() => {
1323
+ this.copy(this.selected);
1324
+ this.paste();
1325
+ });
1326
+ }
1327
+ else if (key === 'escape') {
1328
+ run(() => {
1329
+ this._palette = undefined;
1330
+ this.selected = '';
1331
+ });
1332
+ }
1333
+ else if (this.mode === 'debug' && this.handleDebugKey(event)) {
1334
+ event.preventDefault();
1335
+ }
1336
+ else
1337
+ this.handleCanvasKey(event);
1338
+ };
1339
+ this.onMenuActivate = (event) => {
1340
+ const item = event.detail?.item;
1341
+ const id = this._menuFor;
1342
+ if (!item || !id)
1343
+ return;
1344
+ if (item.value === 'duplicate') {
1345
+ this.copy(id);
1346
+ this.selected = id;
1347
+ this.paste();
1348
+ }
1349
+ else if (item.value === 'collapse')
1350
+ this.collapse(id);
1351
+ else if (item.value === 'expand')
1352
+ this.expand(id);
1353
+ else if (item.value === 'delete')
1354
+ this.removeStep(id);
1355
+ else if (item.value === 'pin')
1356
+ this.updateStep(id, { pinned: true });
1357
+ else if (item.value === 'unpin')
1358
+ this.updateStep(id, { pinned: false });
1359
+ };
1360
+ this.onStepPointerMove = (event) => {
1361
+ const drag = this.stepDrag;
1362
+ if (!drag || event.pointerId !== drag.pointerId)
1363
+ return;
1364
+ const canMove = this.editing && drag.id !== this.value.trigger?.id;
1365
+ if (!canMove)
1366
+ return;
1367
+ if (!drag.moved &&
1368
+ Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY) <
1369
+ DRAG_THRESHOLD) {
1370
+ return;
1371
+ }
1372
+ drag.moved = true;
1373
+ const vr = this._viewportEl?.getBoundingClientRect();
1374
+ this._drag = {
1375
+ id: drag.id,
1376
+ x: event.clientX - (vr?.left ?? 0),
1377
+ y: event.clientY - (vr?.top ?? 0),
1378
+ target: this.dropTarget(drag.id, event.clientX, event.clientY),
1379
+ };
1380
+ };
1381
+ this.onStepPointerUp = (event) => {
1382
+ if (!this.stepDrag || event.pointerId !== this.stepDrag.pointerId)
1383
+ return;
1384
+ this.endStepDrag(true);
1385
+ };
1386
+ this.onStepPointerCancel = () => {
1387
+ this.endStepDrag(false);
1388
+ };
1389
+ }
1390
+ // ── Lifecycle
1391
+ disconnectedCallback() {
1392
+ super.disconnectedCallback();
1393
+ this.rootObserver?.disconnect();
1394
+ cancelAnimationFrame(this.trackFrame);
1395
+ this.endStepDrag(false);
1396
+ }
1397
+ willUpdate(changed) {
1398
+ super.willUpdate(changed);
1399
+ if (changed.has('value')) {
1400
+ this.syncCollapsed();
1401
+ this.unreachable = this.findUnreachable();
1402
+ this.loopParents = this.findLoopParents();
1403
+ if (this.selected && !findStep(this.value, this.selected))
1404
+ this.selected = '';
1405
+ }
1406
+ if (changed.has('run') || changed.has('mode'))
1407
+ this.trackRunChanges();
1408
+ if (changed.has('run') ||
1409
+ changed.has('mode') ||
1410
+ changed.has('breakpoints') ||
1411
+ changed.has('_iterations') ||
1412
+ changed.has('value') ||
1413
+ changed.has('direction') ||
1414
+ changed.has('density') ||
1415
+ changed.has('editable') ||
1416
+ changed.has('readonly') ||
1417
+ changed.has('_collapsed') ||
1418
+ changed.has('_hoverGap') ||
1419
+ changed.has('_drag') ||
1420
+ changed.has('selected')) {
1421
+ this.connectorsDirty = true;
1422
+ }
1423
+ }
1424
+ firstUpdated() {
1425
+ if (typeof ResizeObserver !== 'undefined' && this._rootEl) {
1426
+ this.rootObserver = new ResizeObserver(() => {
1427
+ this.layoutConnectors();
1428
+ this.requestUpdate();
1429
+ });
1430
+ this.rootObserver.observe(this._rootEl);
1431
+ }
1432
+ document.fonts?.ready.then(() => {
1433
+ this.connectorsDirty = true;
1434
+ this.requestUpdate();
1435
+ });
1436
+ }
1437
+ updated(changed) {
1438
+ if (this.connectorsDirty) {
1439
+ this.connectorsDirty = false;
1440
+ this.layoutConnectors();
1441
+ }
1442
+ this.playFlip();
1443
+ if (this.pendingTokens.length) {
1444
+ this.animateTokens(this.pendingTokens);
1445
+ this.pendingTokens = [];
1446
+ }
1447
+ if (changed.has('run') &&
1448
+ this.follow &&
1449
+ this.mode !== 'design' &&
1450
+ this.run?.current) {
1451
+ this.keepInView(this.run.current);
1452
+ }
1453
+ super.updated(changed);
1454
+ }
1455
+ // ── Debugging
1456
+ /** Whether editing is on: `editable`, not `readonly`, and in `design` mode. */
1457
+ get editing() {
1458
+ return this.editable && !this.readonly && this.mode === 'design';
1459
+ }
1460
+ /** Whether step cards offer a menu (edit actions in design mode, pinning in debug mode). */
1461
+ get hasMenu() {
1462
+ return this.editable && !this.readonly && this.mode !== 'history';
1463
+ }
1464
+ findLoopParents() {
1465
+ const out = new Map();
1466
+ const visitList = (steps, loops) => {
1467
+ for (const step of steps) {
1468
+ out.set(step.id, loops);
1469
+ if (step.type === 'loop')
1470
+ visitList(step.steps, [...loops, step.id]);
1471
+ else if (step.type === 'branch' || step.type === 'parallel') {
1472
+ for (const p of step.paths)
1473
+ visitList(p.steps, loops);
1474
+ }
1475
+ else if (step.type === 'action' && step.onError) {
1476
+ visitList(step.onError, loops);
1477
+ }
1478
+ }
1479
+ };
1480
+ visitList(this.value.steps, []);
1481
+ return out;
1482
+ }
1483
+ /** The iteration a loop shows: the one picked, else the latest. */
1484
+ iterationIndex(loopId, total) {
1485
+ const picked = this._iterations.get(loopId);
1486
+ return picked !== undefined && picked < total ? picked : total - 1;
1487
+ }
1488
+ /** What the run did with a step, looking inside the shown iteration of each loop around it. */
1489
+ runStep(id) {
1490
+ const { run } = this;
1491
+ if (!run || this.mode === 'design')
1492
+ return undefined;
1493
+ let record = run.steps;
1494
+ for (const loopId of this.loopParents.get(id) ?? []) {
1495
+ const iterations = record[loopId]?.iterations;
1496
+ if (!iterations?.length)
1497
+ break;
1498
+ record =
1499
+ iterations[this.iterationIndex(loopId, iterations.length)] ?? record;
1500
+ }
1501
+ return record[id] ?? run.steps[id];
1502
+ }
1503
+ statusLabel(status) {
1504
+ const key = {
1505
+ queued: 'workflowStatusQueued',
1506
+ running: 'workflowStatusRunning',
1507
+ waiting: 'workflowStatusWaiting',
1508
+ paused: 'workflowStatusPaused',
1509
+ success: 'workflowStatusSuccess',
1510
+ failed: 'workflowStatusFailed',
1511
+ skipped: 'workflowStatusSkipped',
1512
+ canceled: 'workflowStatusCanceled',
1513
+ }[status];
1514
+ return this.i18n.t(key);
1515
+ }
1516
+ /** Notes the steps the run has just reached, for the travelling token and announcements. */
1517
+ trackRunChanges() {
1518
+ const next = new Map();
1519
+ const ids = [];
1520
+ if (this.value.trigger)
1521
+ ids.push(this.value.trigger.id);
1522
+ walk(this.value, ({ step }) => ids.push(step.id));
1523
+ const reached = [];
1524
+ let latest;
1525
+ for (const id of ids) {
1526
+ const status = this.runStep(id)?.status;
1527
+ if (status) {
1528
+ next.set(id, status);
1529
+ const before = this.lastStatuses.get(id);
1530
+ if (before !== status)
1531
+ latest = { id, status };
1532
+ if (isReached(status) && !isReached(before) && this.lastStatuses.size) {
1533
+ reached.push(id);
1534
+ }
1535
+ }
1536
+ }
1537
+ if (latest && this.lastStatuses.size) {
1538
+ const step = findStep(this.value, latest.id)?.step;
1539
+ if (step) {
1540
+ this.announce(this.i18n.t('workflowStepStatus')(this.stepLabel(step), this.statusLabel(latest.status)));
1541
+ }
1542
+ }
1543
+ this.lastStatuses = next;
1544
+ this.pendingTokens = reached;
1545
+ }
1546
+ /** Sends a dot along the connector into each step the run just reached. */
1547
+ animateTokens(ids) {
1548
+ const layer = this._tokensEl;
1549
+ const lines = this._connectorsEl;
1550
+ if (!layer || !lines || prefersReducedMotion())
1551
+ return;
1552
+ for (const id of ids) {
1553
+ const path = lines.querySelector(`path[data-to="${CSS.escape(id)}"]`);
1554
+ if (path && typeof path.getTotalLength === 'function') {
1555
+ const length = path.getTotalLength();
1556
+ const halo = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
1557
+ const dot = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
1558
+ halo.setAttribute('class', 'wf-token-halo');
1559
+ halo.setAttribute('r', '12');
1560
+ dot.setAttribute('class', 'wf-token');
1561
+ dot.setAttribute('r', '5');
1562
+ layer.append(halo, dot);
1563
+ const start = performance.now();
1564
+ const duration = 520;
1565
+ const step = (now) => {
1566
+ const p = Math.min(1, (now - start) / duration);
1567
+ const eased = p < 0.5 ? 4 * p ** 3 : 1 - (-2 * p + 2) ** 3 / 2;
1568
+ const point = path.getPointAtLength(length * eased);
1569
+ for (const c of [halo, dot]) {
1570
+ c.setAttribute('cx', String(point.x));
1571
+ c.setAttribute('cy', String(point.y));
1572
+ }
1573
+ if (p < 1)
1574
+ requestAnimationFrame(step);
1575
+ else {
1576
+ halo.remove();
1577
+ dot.remove();
1578
+ }
1579
+ };
1580
+ requestAnimationFrame(step);
1581
+ }
1582
+ }
1583
+ }
1584
+ toggleBreakpoint(id) {
1585
+ const enabled = !this.breakpoints.includes(id);
1586
+ this.breakpoints = enabled
1587
+ ? [...this.breakpoints, id]
1588
+ : this.breakpoints.filter(b => b !== id);
1589
+ this.emit('breakpoint-toggle', {
1590
+ id,
1591
+ enabled,
1592
+ breakpoints: this.breakpoints,
1593
+ });
1594
+ }
1595
+ debugAction(action, stepId) {
1596
+ this.emit('debug-action', { action, stepId });
1597
+ }
1598
+ setIteration(loopId, index) {
1599
+ const next = new Map(this._iterations);
1600
+ next.set(loopId, index);
1601
+ this._iterations = next;
1602
+ this.emit('iteration-change', { loopId, index });
1603
+ }
1604
+ /** How a loop's iteration went overall, for its tick. */
1605
+ static iterationStatus(record) {
1606
+ const statuses = Object.values(record).map(r => r.status);
1607
+ if (statuses.includes('failed'))
1608
+ return 'failed';
1609
+ if (statuses.some(s => s === 'running' || s === 'paused' || s === 'waiting')) {
1610
+ return 'running';
1611
+ }
1612
+ if (statuses.length &&
1613
+ statuses.every(s => s === 'success' || s === 'skipped')) {
1614
+ return 'success';
1615
+ }
1616
+ return 'queued';
1617
+ }
1618
+ // ── Public API
1619
+ /** Whether `undo()` has something to undo. */
1620
+ get canUndo() {
1621
+ return this.history.canUndo;
1622
+ }
1623
+ /** Whether `redo()` has something to redo. */
1624
+ get canRedo() {
1625
+ return this.history.canRedo;
1626
+ }
1627
+ /** Steps that need attention: those marked `invalid`, and steps that can never run. */
1628
+ get problems() {
1629
+ const out = [];
1630
+ const visit = (step) => {
1631
+ if (step.invalid)
1632
+ out.push({ id: step.id, message: step.errorText ?? '' });
1633
+ else if (this.unreachable.has(step.id)) {
1634
+ out.push({ id: step.id, message: this.i18n.t('workflowUnreachable') });
1635
+ }
1636
+ };
1637
+ if (this.value.trigger)
1638
+ visit(this.value.trigger);
1639
+ walk(this.value, ({ step }) => visit(step));
1640
+ return out;
1641
+ }
1642
+ undo() {
1643
+ const previous = this.history.undo(this.value);
1644
+ if (previous)
1645
+ this.commit(previous, 'undo', false);
1646
+ }
1647
+ redo() {
1648
+ const next = this.history.redo(this.value);
1649
+ if (next)
1650
+ this.commit(next, 'redo', false);
1651
+ }
1652
+ /** Forgets the undo and redo history, for example after saving. */
1653
+ clearHistory() {
1654
+ this.history.clear();
1655
+ this.listeners.notify();
1656
+ }
1657
+ /** Changes a step, for example from an inspector. Records an undo step and fires `change`. */
1658
+ updateStep(id, patch) {
1659
+ if (!findStep(this.value, id))
1660
+ return;
1661
+ this.commit(replaceStep(this.value, id, step => ({ ...step, ...patch, id, type: step.type })), 'update');
1662
+ }
1663
+ /** Removes a step and everything inside it, after a cancelable `delete` event. */
1664
+ removeStep(id) {
1665
+ const found = findStep(this.value, id);
1666
+ if (!found)
1667
+ return;
1668
+ if (!this.emit('delete', { ids: [id] }, true))
1669
+ return;
1670
+ const neighbour = this.neighbourAfterRemoval(id);
1671
+ const el = this.cardElement(id)?.closest('.wf-item');
1672
+ animateOut(el ? [el] : [], () => {
1673
+ this.commit(removeStep(this.value, id), 'remove');
1674
+ this.announce(this.i18n.t('workflowStepRemoved')(this.stepLabel(found.step)));
1675
+ if (this.selected === id)
1676
+ this.selected = '';
1677
+ if (neighbour)
1678
+ this.focusStep(neighbour);
1679
+ });
1680
+ }
1681
+ /** Moves keyboard focus to a step and pans it into view. */
1682
+ focusStep(id) {
1683
+ this._focusId = id;
1684
+ this.updateComplete.then(() => {
1685
+ const el = this.cardElement(id);
1686
+ el?.focus({ preventScroll: true });
1687
+ this.keepInView(id);
1688
+ });
1689
+ }
1690
+ /** Selects a step as a click would, fires `select`, and brings it into view. */
1691
+ selectStep(id) {
1692
+ const step = findStep(this.value, id)?.step;
1693
+ if (!step)
1694
+ return;
1695
+ this.select(step);
1696
+ this.focusStep(id);
1697
+ }
1698
+ collapse(id) {
1699
+ const next = new Set(this._collapsed);
1700
+ next.add(id);
1701
+ this._collapsed = next;
1702
+ }
1703
+ expand(id) {
1704
+ const next = new Set(this._collapsed);
1705
+ next.delete(id);
1706
+ this._collapsed = next;
1707
+ }
1708
+ // ── Canvas hooks
1709
+ viewportElement() {
1710
+ return this._viewportEl;
1711
+ }
1712
+ contentBounds() {
1713
+ const root = this._rootEl;
1714
+ if (!root ||
1715
+ (!this.value.trigger && !this.value.steps.length && !this.editing)) {
1716
+ return undefined;
1717
+ }
1718
+ return { x: 0, y: 0, width: root.offsetWidth, height: root.offsetHeight };
1719
+ }
1720
+ selectionRects() {
1721
+ const r = this.selected ? this.itemRect(this.selected) : undefined;
1722
+ return r ? [r] : [];
1723
+ }
1724
+ itemRect(id) {
1725
+ const el = this.cardElement(id);
1726
+ return el ? this.rectOf(el) : undefined;
1727
+ }
1728
+ firstItemRect() {
1729
+ const el = this._rootEl?.querySelector('[data-card-id], .wf-add-trigger');
1730
+ return el ? this.rectOf(el) : undefined;
1731
+ }
1732
+ overviewItems() {
1733
+ const root = this._rootEl;
1734
+ if (!root || !this._worldEl)
1735
+ return [];
1736
+ return Array.from(root.querySelectorAll('[data-card-id]')).map(el => ({
1737
+ ...this.rectOf(el),
1738
+ selected: el.dataset.cardId === this.selected,
1739
+ }));
1740
+ }
1741
+ isBackground(target) {
1742
+ const el = target;
1743
+ if (!el)
1744
+ return false;
1745
+ if (el === this._viewportEl)
1746
+ return true;
1747
+ const cls = el.classList;
1748
+ return (!!cls &&
1749
+ [
1750
+ 'wf-world',
1751
+ 'wf-root',
1752
+ 'wf-seq',
1753
+ 'wf-paths',
1754
+ 'wf-path',
1755
+ 'wf-path-tail',
1756
+ 'wf-gap',
1757
+ 'wf-connectors',
1758
+ 'wf-item',
1759
+ 'wf-error-col',
1760
+ 'wf-error-spacer',
1761
+ ].some(c => cls.contains(c)));
1762
+ }
1763
+ onBackgroundClick() {
1764
+ this._palette = undefined;
1765
+ this.selected = '';
1766
+ }
1767
+ /** Fits the workflow, or shows its start at 60% when fitting it all would be too small to read. */
1768
+ computeStartView() {
1769
+ if (this.startView || this.startPosition !== 'fit')
1770
+ return super.computeStartView();
1771
+ const bounds = this.contentBounds();
1772
+ if (!bounds)
1773
+ return super.computeStartView();
1774
+ const fitted = this.viewport.viewForRect(bounds, this.padding);
1775
+ if (fitted.zoom >= MIN_FIT_ZOOM)
1776
+ return fitted;
1777
+ const zoom = MIN_FIT_ZOOM;
1778
+ const { width, height } = this.viewport.size();
1779
+ return this.direction === 'vertical'
1780
+ ? {
1781
+ zoom,
1782
+ x: width / 2 - (bounds.x + bounds.width / 2) * zoom,
1783
+ y: this.padding - bounds.y * zoom,
1784
+ }
1785
+ : {
1786
+ zoom,
1787
+ x: this.padding - bounds.x * zoom,
1788
+ y: height / 2 - (bounds.y + bounds.height / 2) * zoom,
1789
+ };
1790
+ }
1791
+ // ── Private methods: data
1792
+ /** Records an undo step (unless restoring one), animates the change and fires `change`. */
1793
+ commit(next, reason, record = true) {
1794
+ if (record)
1795
+ this.history.push(this.value);
1796
+ this.captureFlip();
1797
+ this.value = next;
1798
+ this.emit('change', { value: next, reason });
1799
+ this.listeners.notify();
1800
+ }
1801
+ announce(message) {
1802
+ this._announcement = '';
1803
+ requestAnimationFrame(() => {
1804
+ this._announcement = message;
1805
+ });
1806
+ }
1807
+ syncCollapsed() {
1808
+ const next = new Set(this._collapsed);
1809
+ let changed = false;
1810
+ const visit = (step) => {
1811
+ if (step.collapsed && !this.seenCollapsed.has(step.id)) {
1812
+ this.seenCollapsed.add(step.id);
1813
+ next.add(step.id);
1814
+ changed = true;
1815
+ }
1816
+ };
1817
+ walk(this.value, ({ step }) => visit(step));
1818
+ if (changed)
1819
+ this._collapsed = next;
1820
+ }
1821
+ /** Steps after a step that always ends the flow, in the same list. */
1822
+ findUnreachable() {
1823
+ const out = new Set();
1824
+ const visitList = (steps, dead) => {
1825
+ let gone = dead;
1826
+ for (const step of steps) {
1827
+ if (gone)
1828
+ out.add(step.id);
1829
+ if (step.type === 'branch' || step.type === 'parallel') {
1830
+ for (const p of step.paths)
1831
+ visitList(p.steps, gone);
1832
+ }
1833
+ else if (step.type === 'loop') {
1834
+ visitList(step.steps, gone);
1835
+ }
1836
+ else if (step.type === 'action' && step.onError) {
1837
+ visitList(step.onError, gone);
1838
+ }
1839
+ if (stepTerminates(step))
1840
+ gone = true;
1841
+ }
1842
+ };
1843
+ visitList(this.value.steps, false);
1844
+ return out;
1845
+ }
1846
+ stepLabel(step) {
1847
+ if (step.headline)
1848
+ return step.headline;
1849
+ if (step.type === 'end')
1850
+ return this.i18n.t('workflowEnd');
1851
+ return step.id;
1852
+ }
1853
+ neighbourAfterRemoval(id) {
1854
+ const found = findStep(this.value, id);
1855
+ if (!found || found.index < 0)
1856
+ return this.value.steps[0]?.id;
1857
+ const list = getList(this.value, found.ref) ?? [];
1858
+ return (list[found.index + 1]?.id ??
1859
+ list[found.index - 1]?.id ??
1860
+ (found.ref.kind === 'root' ? this.value.trigger?.id : found.ref.stepId));
1861
+ }
1862
+ /** Steps in reading order, skipping what is inside collapsed blocks. */
1863
+ navOrder() {
1864
+ const ids = [];
1865
+ if (this.value.trigger)
1866
+ ids.push(this.value.trigger.id);
1867
+ walk(this.value, ({ step }) => ids.push(step.id), {
1868
+ skip: step => this._collapsed.has(step.id),
1869
+ });
1870
+ return ids;
1871
+ }
1872
+ // ── Private methods: geometry
1873
+ cardElement(id) {
1874
+ return (this._rootEl?.querySelector(`[data-card-id="${CSS.escape(id)}"]`) ?? null);
1875
+ }
1876
+ /** An element's box in canvas coordinates. */
1877
+ rectOf(el) {
1878
+ const world = this._worldEl;
1879
+ const { zoom } = this.viewport.view;
1880
+ const r = el.getBoundingClientRect();
1881
+ const w = world?.getBoundingClientRect();
1882
+ return {
1883
+ x: (r.left - (w?.left ?? 0)) / zoom,
1884
+ y: (r.top - (w?.top ?? 0)) / zoom,
1885
+ width: r.width / zoom,
1886
+ height: r.height / zoom,
1887
+ };
1888
+ }
1889
+ keepInView(id) {
1890
+ const r = this.itemRect(id);
1891
+ if (!r)
1892
+ return;
1893
+ const v = this.viewport.visibleRect();
1894
+ const inside = r.x >= v.x &&
1895
+ r.y >= v.y &&
1896
+ r.x + r.width <= v.x + v.width &&
1897
+ r.y + r.height <= v.y + v.height;
1898
+ if (!inside)
1899
+ this.centerOn(r.x + r.width / 2, r.y + r.height / 2);
1900
+ }
1901
+ /** Draws every connector from the measured positions of cards, pills and joins. */
1902
+ layoutConnectors() {
1903
+ const root = this._rootEl;
1904
+ const target = this._connectorsEl;
1905
+ if (!root || !target || !this._worldEl)
1906
+ return;
1907
+ const vertical = this.direction === 'vertical';
1908
+ const S = (r) => (vertical ? r.y : r.x);
1909
+ const E = (r) => (vertical ? r.y + r.height : r.x + r.width);
1910
+ const C = (r) => vertical ? r.x + r.width / 2 : r.y + r.height / 2;
1911
+ const CS = (r) => (vertical ? r.x : r.y);
1912
+ const CE = (r) => (vertical ? r.x + r.width : r.y + r.height);
1913
+ const MC = (r) => vertical ? r.y + r.height / 2 : r.x + r.width / 2;
1914
+ const P = (m, c) => vertical ? { x: c, y: m } : { x: m, y: c };
1915
+ const q = (selector) => root.querySelector(selector);
1916
+ const rect = (el) => this.rectOf(el);
1917
+ const paths = [];
1918
+ const { run } = this;
1919
+ const showRun = !!run && this.mode !== 'design';
1920
+ const finished = !!run && ['success', 'failed', 'canceled'].includes(run.status);
1921
+ // A connector is taken when the run reached the step it leads to (or, for a merge, when the
1922
+ // step it leaves succeeded), and not taken when that step was skipped or the run is over.
1923
+ const runClass = (to, from) => {
1924
+ if (!showRun)
1925
+ return '';
1926
+ let status;
1927
+ if (to)
1928
+ status = this.runStep(to)?.status;
1929
+ else if (from && this.runStep(from)?.status === 'success')
1930
+ status = 'success';
1931
+ if (isReached(status)) {
1932
+ return status === 'success' || status === 'failed'
1933
+ ? ' is-taken'
1934
+ : ' is-taken is-active';
1935
+ }
1936
+ if (status === 'skipped' || finished)
1937
+ return ' is-untaken';
1938
+ return '';
1939
+ };
1940
+ const line = (points, cls, to, from) => {
1941
+ paths.push(w `<path class=${cls + runClass(to, from)} data-to=${to ?? A} d=${roundedPath(points, CORNER)}></path>`);
1942
+ };
1943
+ const link = (from, to, cls, toId) => {
1944
+ if (Math.abs(from.c - to.c) < 0.5) {
1945
+ line([P(from.m, from.c), P(to.m, from.c)], cls, toId);
1946
+ }
1947
+ else {
1948
+ const mid = (from.m + to.m) / 2;
1949
+ line([P(from.m, from.c), P(mid, from.c), P(mid, to.c), P(to.m, to.c)], cls, toId);
1950
+ }
1951
+ };
1952
+ const gapClass = (ref, index, extra = '') => {
1953
+ const key = `${listKey(ref)}#${index}`;
1954
+ return `wf-conn${extra}${this._hoverGap === key || this._drag?.target === key ? ' is-hover' : ''}`;
1955
+ };
1956
+ const walkList = (steps, ref, entry, extra = '') => {
1957
+ let prev = entry;
1958
+ steps.forEach((step, index) => {
1959
+ const inEl = q(`[data-in-for="${CSS.escape(step.id)}"]`);
1960
+ if (!inEl)
1961
+ return;
1962
+ const r = rect(inEl);
1963
+ if (prev) {
1964
+ link(prev, { m: S(r), c: C(r) }, gapClass(ref, index, extra), step.id);
1965
+ }
1966
+ // walkList and layoutStep call each other for nested paths.
1967
+ // eslint-disable-next-line no-use-before-define
1968
+ prev = layoutStep(step, extra);
1969
+ });
1970
+ const trailing = q(`[data-gap="${CSS.escape(`${listKey(ref)}#${steps.length}`)}"] .wf-plus`);
1971
+ if (prev && trailing) {
1972
+ const r = rect(trailing);
1973
+ link(prev, { m: S(r), c: C(r) }, gapClass(ref, steps.length, `${extra} is-stub`));
1974
+ }
1975
+ return prev;
1976
+ };
1977
+ const layoutStep = (step, extra) => {
1978
+ const card = q(`[data-card-id="${CSS.escape(step.id)}"]`);
1979
+ if (!card)
1980
+ return null;
1981
+ const cr = rect(card);
1982
+ if (step.type === 'end')
1983
+ return null;
1984
+ const collapsed = this._collapsed.has(step.id);
1985
+ if ((step.type === 'branch' || step.type === 'parallel') && !collapsed) {
1986
+ const rowEl = q(`[data-paths-for="${CSS.escape(step.id)}"]`);
1987
+ const joinEl = q(`[data-join-for="${CSS.escape(step.id)}"]`);
1988
+ const row = rowEl ? rect(rowEl) : cr;
1989
+ const join = joinEl ? rect(joinEl) : undefined;
1990
+ for (const p of step.paths) {
1991
+ const pillEl = q(`[data-pill="${CSS.escape(p.id)}"]`);
1992
+ if (pillEl) {
1993
+ const pr = rect(pillEl);
1994
+ const fork = (E(cr) + S(pr)) / 2;
1995
+ line([
1996
+ P(E(cr), C(cr)),
1997
+ P(fork, C(cr)),
1998
+ P(fork, C(pr)),
1999
+ P(S(pr), C(pr)),
2000
+ ], `wf-conn${extra}`, p.steps[0]?.id);
2001
+ const exit = walkList(p.steps, { kind: 'path', stepId: step.id, pathId: p.id }, { m: E(pr), c: C(pr) }, extra);
2002
+ if (exit && join) {
2003
+ const merge = (E(row) + S(join)) / 2;
2004
+ line([
2005
+ P(exit.m, exit.c),
2006
+ P(merge, exit.c),
2007
+ P(merge, C(join)),
2008
+ P(S(join), C(join)),
2009
+ ], `wf-conn${extra}`, undefined, p.steps[p.steps.length - 1]?.id);
2010
+ }
2011
+ }
2012
+ }
2013
+ return join ? { m: E(join), c: C(join) } : null;
2014
+ }
2015
+ if (step.type === 'loop' && !collapsed) {
2016
+ const frameEl = q(`[data-loop-for="${CSS.escape(step.id)}"]`);
2017
+ if (!frameEl)
2018
+ return null;
2019
+ const fr = rect(frameEl);
2020
+ const exit = walkList(step.steps, { kind: 'loop', stepId: step.id }, { m: E(cr), c: C(cr) }, extra);
2021
+ const firstEl = step.steps[0]
2022
+ ? q(`[data-in-for="${CSS.escape(step.steps[0].id)}"]`)
2023
+ : null;
2024
+ if (exit && firstEl) {
2025
+ const first = rect(firstEl);
2026
+ const lane = CS(fr) + 18;
2027
+ const bottom = Math.min(exit.m + 16, E(fr) - 10);
2028
+ const tipC = CS(first) - 2;
2029
+ line([
2030
+ P(exit.m, exit.c),
2031
+ P(bottom, exit.c),
2032
+ P(bottom, lane),
2033
+ P(MC(first), lane),
2034
+ P(MC(first), tipC),
2035
+ ], `wf-conn wf-loop-back${extra}${showRun && (this.runStep(step.id)?.iterations?.length ?? 0) > 1
2036
+ ? ' is-taken'
2037
+ : ''}`);
2038
+ const tip = P(MC(first), tipC);
2039
+ const arrow = vertical
2040
+ ? `M ${tip.x} ${tip.y} l -8 -4.5 l 0 9 z`
2041
+ : `M ${tip.x} ${tip.y} l -4.5 -8 l 9 0 z`;
2042
+ paths.push(w `<path class="wf-arrow" d=${arrow}></path>`);
2043
+ }
2044
+ return { m: E(fr), c: C(fr) };
2045
+ }
2046
+ if (step.type === 'action' && step.onError) {
2047
+ const pillEl = q(`[data-error-pill="${CSS.escape(step.id)}"]`);
2048
+ if (pillEl) {
2049
+ const pr = rect(pillEl);
2050
+ line([P(MC(cr), CE(cr)), P(MC(cr), C(pr)), P(S(pr), C(pr))], 'wf-conn is-error', step.onError[0]?.id);
2051
+ walkList(step.onError, { kind: 'error', stepId: step.id }, { m: E(pr), c: C(pr) }, ' is-error');
2052
+ }
2053
+ }
2054
+ if (stepTerminates(step))
2055
+ return null;
2056
+ return { m: E(cr), c: C(cr) };
2057
+ };
2058
+ const triggerEl = q('[data-trigger]');
2059
+ const entry = triggerEl
2060
+ ? { m: E(rect(triggerEl)), c: C(rect(triggerEl)) }
2061
+ : null;
2062
+ walkList(this.value.steps, { kind: 'root' }, entry);
2063
+ D(w `${paths}`, target);
2064
+ }
2065
+ /** Keeps connectors on their cards while cards glide. */
2066
+ trackConnectors(duration) {
2067
+ cancelAnimationFrame(this.trackFrame);
2068
+ const until = performance.now() + duration;
2069
+ const step = () => {
2070
+ this.layoutConnectors();
2071
+ if (performance.now() < until)
2072
+ this.trackFrame = requestAnimationFrame(step);
2073
+ };
2074
+ this.trackFrame = requestAnimationFrame(step);
2075
+ }
2076
+ captureFlip() {
2077
+ const root = this._rootEl;
2078
+ if (!root || prefersReducedMotion())
2079
+ return;
2080
+ const before = new Map();
2081
+ root.querySelectorAll('[data-flip]').forEach(el => {
2082
+ before.set(el.dataset.flip ?? '', el.getBoundingClientRect());
2083
+ });
2084
+ this.flipBefore = before;
2085
+ }
2086
+ /** Slides moved elements from where they were and pops in new ones. */
2087
+ playFlip() {
2088
+ const before = this.flipBefore;
2089
+ const root = this._rootEl;
2090
+ this.flipBefore = undefined;
2091
+ if (!before || !root)
2092
+ return;
2093
+ const { zoom } = this.viewport.view;
2094
+ const moved = new Map();
2095
+ let animated = false;
2096
+ root.querySelectorAll('[data-flip]').forEach(el => {
2097
+ if (typeof el.animate !== 'function')
2098
+ return;
2099
+ const was = before.get(el.dataset.flip ?? '');
2100
+ const now = el.getBoundingClientRect();
2101
+ if (!was) {
2102
+ el.animate([
2103
+ { opacity: 0, transform: 'scale(0.92)' },
2104
+ { opacity: 1, transform: 'none' },
2105
+ ], { duration: 260, easing: 'cubic-bezier(0.2, 0.9, 0.3, 1.2)' });
2106
+ animated = true;
2107
+ return;
2108
+ }
2109
+ const total = {
2110
+ x: (was.left - now.left) / zoom,
2111
+ y: (was.top - now.top) / zoom,
2112
+ };
2113
+ moved.set(el, total);
2114
+ const parent = el.parentElement?.closest('[data-flip]');
2115
+ const inherited = (parent && moved.get(parent)) || { x: 0, y: 0 };
2116
+ const dx = total.x - inherited.x;
2117
+ const dy = total.y - inherited.y;
2118
+ if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5)
2119
+ return;
2120
+ el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], {
2121
+ duration: 320,
2122
+ easing: 'cubic-bezier(0.2, 0, 0, 1)',
2123
+ });
2124
+ animated = true;
2125
+ });
2126
+ if (animated)
2127
+ this.trackConnectors(340);
2128
+ }
2129
+ // ── Private methods: palette
2130
+ openPalette(ref, index, anchor, trigger = false) {
2131
+ const vp = this._viewportEl;
2132
+ if (!vp || !this.editing)
2133
+ return;
2134
+ const vr = vp.getBoundingClientRect();
2135
+ const ar = anchor?.getBoundingClientRect() ?? vr;
2136
+ const width = 300;
2137
+ const height = 380;
2138
+ const x = Math.max(8, Math.min(ar.right - vr.left + 12, vr.width - width - 8));
2139
+ const y = Math.max(8, Math.min(ar.top - vr.top - 24, vr.height - height - 8));
2140
+ this._palette = { ref, index, trigger, x, y, query: '', active: 0 };
2141
+ this.updateComplete.then(() => {
2142
+ this.renderRoot
2143
+ .querySelector('.wf-palette input')
2144
+ ?.focus();
2145
+ });
2146
+ }
2147
+ closePalette(refocus = true) {
2148
+ const p = this._palette;
2149
+ this._palette = undefined;
2150
+ if (refocus && p) {
2151
+ const prev = getList(this.value, p.ref)?.[p.index - 1];
2152
+ if (prev)
2153
+ this.focusStep(prev.id);
2154
+ else
2155
+ this._viewportEl?.focus({ preventScroll: true });
2156
+ }
2157
+ }
2158
+ paletteEntries() {
2159
+ const p = this._palette;
2160
+ if (!p)
2161
+ return [];
2162
+ const needle = p.query.trim().toLowerCase();
2163
+ return this.stepTypes.filter(t => !!t.trigger === p.trigger &&
2164
+ (!needle ||
2165
+ t.headline.toLowerCase().includes(needle) ||
2166
+ (t.supportingText ?? '').toLowerCase().includes(needle) ||
2167
+ (t.category ?? '').toLowerCase().includes(needle)));
2168
+ }
2169
+ choose(type) {
2170
+ const p = this._palette;
2171
+ if (!p)
2172
+ return;
2173
+ this._palette = undefined;
2174
+ const allowed = this.emit('step-add', { stepType: type, list: p.ref, index: p.index, trigger: p.trigger }, true);
2175
+ if (!allowed)
2176
+ return;
2177
+ const step = createStep(type, allIds(this.value));
2178
+ const next = p.trigger
2179
+ ? {
2180
+ ...this.value,
2181
+ trigger: { ...step, type: 'action' },
2182
+ }
2183
+ : insertStep(this.value, p.ref, p.index, step);
2184
+ this.commit(next, 'add');
2185
+ this.selected = step.id;
2186
+ this.emit('select', { id: step.id, step });
2187
+ this.announce(this.i18n.t('workflowStepAdded')(this.stepLabel(step)));
2188
+ this.focusStep(step.id);
2189
+ }
2190
+ // ── Private methods: keyboard
2191
+ onCardKeyDown(event, step) {
2192
+ if (event.target !== event.currentTarget)
2193
+ return;
2194
+ const handled = (fn) => {
2195
+ event.preventDefault();
2196
+ this.handledKeys.add(event);
2197
+ fn();
2198
+ };
2199
+ const vertical = this.direction === 'vertical';
2200
+ const mainNext = vertical ? 'ArrowDown' : 'ArrowRight';
2201
+ const mainPrev = vertical ? 'ArrowUp' : 'ArrowLeft';
2202
+ const crossNext = vertical ? 'ArrowRight' : 'ArrowDown';
2203
+ const crossPrev = vertical ? 'ArrowLeft' : 'ArrowUp';
2204
+ const order = this.navOrder();
2205
+ const at = order.indexOf(step.id);
2206
+ const isTrigger = this.value.trigger?.id === step.id;
2207
+ const { key } = event;
2208
+ if (key === 'Enter' && event.shiftKey && this.isBlock(step)) {
2209
+ handled(() => this._collapsed.has(step.id)
2210
+ ? this.expand(step.id)
2211
+ : this.collapse(step.id));
2212
+ }
2213
+ else if (key === 'Enter' || key === ' ') {
2214
+ handled(() => this.select(step));
2215
+ }
2216
+ else if (event.altKey &&
2217
+ (key === mainNext || key === mainPrev) &&
2218
+ this.editing &&
2219
+ !isTrigger) {
2220
+ handled(() => this.nudge(step.id, key === mainNext ? 1 : -1));
2221
+ }
2222
+ else if (key === mainNext && order[at + 1]) {
2223
+ handled(() => this.focusStep(order[at + 1]));
2224
+ }
2225
+ else if (key === mainPrev && at > 0) {
2226
+ handled(() => this.focusStep(order[at - 1]));
2227
+ }
2228
+ else if (key === crossNext || key === crossPrev) {
2229
+ const target = this.crossTarget(step, key === crossNext ? 1 : -1);
2230
+ if (target)
2231
+ handled(() => this.focusStep(target));
2232
+ }
2233
+ else if (key === 'Home' && order[0]) {
2234
+ handled(() => this.focusStep(order[0]));
2235
+ }
2236
+ else if (key === 'End' && order.length) {
2237
+ handled(() => this.focusStep(order[order.length - 1]));
2238
+ }
2239
+ else if ((key === 'Delete' || key === 'Backspace') && this.editing) {
2240
+ handled(() => this.removeStep(step.id));
2241
+ }
2242
+ else if (key === 'Insert' && this.editing && !isTrigger) {
2243
+ handled(() => this.openPaletteAfter(step));
2244
+ }
2245
+ else if ((key === 'F10' && event.shiftKey) || key === 'ContextMenu') {
2246
+ if (this.hasMenu) {
2247
+ handled(() => this.openMenu(step.id, event.currentTarget));
2248
+ }
2249
+ }
2250
+ else if (key === 'F9' && this.mode === 'debug' && step.type !== 'end') {
2251
+ handled(() => this.toggleBreakpoint(step.id));
2252
+ }
2253
+ }
2254
+ /** F5 continue or pause (Shift: stop, Ctrl+Shift: restart), F10 step over, F11 step into. */
2255
+ handleDebugKey(event) {
2256
+ const mod = event.ctrlKey || event.metaKey;
2257
+ if (event.key === 'F5') {
2258
+ if (mod && event.shiftKey)
2259
+ this.debugAction('restart');
2260
+ else if (event.shiftKey)
2261
+ this.debugAction('stop');
2262
+ else
2263
+ this.debugAction(this.run?.status === 'running' ? 'pause' : 'continue');
2264
+ return true;
2265
+ }
2266
+ if (event.key === 'F10' && !event.shiftKey) {
2267
+ this.debugAction('step-over');
2268
+ return true;
2269
+ }
2270
+ if (event.key === 'F11') {
2271
+ this.debugAction('step-into');
2272
+ return true;
2273
+ }
2274
+ return false;
2275
+ }
2276
+ crossTarget(step, delta) {
2277
+ const found = findStep(this.value, step.id);
2278
+ if (!found)
2279
+ return undefined;
2280
+ if (delta === 1 && step.type === 'action' && step.onError?.[0])
2281
+ return step.onError[0].id;
2282
+ if (found.ref.kind === 'error' && delta === -1)
2283
+ return found.ref.stepId;
2284
+ if (found.ref.kind !== 'path')
2285
+ return undefined;
2286
+ const { stepId, pathId } = found.ref;
2287
+ const owner = findStep(this.value, stepId)?.step;
2288
+ if (!owner || (owner.type !== 'branch' && owner.type !== 'parallel'))
2289
+ return undefined;
2290
+ const i = owner.paths.findIndex(p => p.id === pathId);
2291
+ const path = owner.paths[i + delta];
2292
+ if (!path?.steps.length)
2293
+ return undefined;
2294
+ return path.steps[Math.min(found.index, path.steps.length - 1)].id;
2295
+ }
2296
+ nudge(id, delta) {
2297
+ const found = findStep(this.value, id);
2298
+ if (!found || found.index < 0)
2299
+ return;
2300
+ const list = getList(this.value, found.ref) ?? [];
2301
+ const target = found.index + delta;
2302
+ if (target < 0 || target >= list.length)
2303
+ return;
2304
+ this.commit(moveStep(this.value, id, found.ref, delta === 1 ? target + 1 : target), 'move');
2305
+ this.announce(this.i18n.t('workflowStepMoved')(this.stepLabel(found.step)));
2306
+ this.focusStep(id);
2307
+ }
2308
+ openPaletteAfter(step) {
2309
+ const found = findStep(this.value, step.id);
2310
+ if (!found)
2311
+ return;
2312
+ const ref = found.index < 0 ? { kind: 'root' } : found.ref;
2313
+ const index = found.index + 1;
2314
+ const gap = this._rootEl?.querySelector(`[data-gap="${CSS.escape(`${listKey(ref)}#${index}`)}"]`);
2315
+ this.openPalette(ref, index, gap ?? this.cardElement(step.id));
2316
+ }
2317
+ copy(id) {
2318
+ const step = findStep(this.value, id)?.step;
2319
+ if (step && step.id !== this.value.trigger?.id)
2320
+ clipboard = step;
2321
+ }
2322
+ paste() {
2323
+ if (!clipboard)
2324
+ return;
2325
+ const step = cloneWithNewIds(clipboard, allIds(this.value));
2326
+ const found = this.selected
2327
+ ? findStep(this.value, this.selected)
2328
+ : undefined;
2329
+ const ref = found && found.index >= 0 ? found.ref : { kind: 'root' };
2330
+ // After the selected step; at the start when the trigger is selected; else at the end.
2331
+ let index = this.value.steps.length;
2332
+ if (found)
2333
+ index = found.index >= 0 ? found.index + 1 : 0;
2334
+ this.commit(insertStep(this.value, ref, index, step), 'paste');
2335
+ this.select(step);
2336
+ this.focusStep(step.id);
2337
+ }
2338
+ select(step) {
2339
+ this.selected = step.id;
2340
+ this.emit('select', { id: step.id, step });
2341
+ }
2342
+ isBlock(step) {
2343
+ return (step.type === 'branch' || step.type === 'parallel' || step.type === 'loop');
2344
+ }
2345
+ nextProblem() {
2346
+ const { problems } = this;
2347
+ if (!problems.length)
2348
+ return;
2349
+ this.problemIndex = (this.problemIndex + 1) % problems.length;
2350
+ const { id } = problems[this.problemIndex];
2351
+ const step = findStep(this.value, id)?.step;
2352
+ if (step)
2353
+ this.select(step);
2354
+ this.zoomTo(id);
2355
+ this.focusStep(id);
2356
+ }
2357
+ // ── Private methods: menu
2358
+ openMenu(id, anchor) {
2359
+ const menu = this._menu;
2360
+ if (!menu)
2361
+ return;
2362
+ this._menuFor = id;
2363
+ menu.anchorElement = anchor;
2364
+ this.updateComplete.then(() => menu.show('first'));
2365
+ }
2366
+ // ── Private methods: dragging steps
2367
+ onCardPointerDown(event, step) {
2368
+ if (event.button !== 0 || this.viewport.spaceHeld)
2369
+ return;
2370
+ const origin = event.composedPath()[0];
2371
+ if (origin instanceof Element && origin.closest(INTERACTIVE))
2372
+ return;
2373
+ event.stopPropagation();
2374
+ const element = event.currentTarget;
2375
+ element.focus({ preventScroll: true });
2376
+ this._focusId = step.id;
2377
+ this.stepDrag = {
2378
+ pointerId: event.pointerId,
2379
+ startX: event.clientX,
2380
+ startY: event.clientY,
2381
+ id: step.id,
2382
+ element,
2383
+ moved: false,
2384
+ };
2385
+ try {
2386
+ element.setPointerCapture(event.pointerId);
2387
+ }
2388
+ catch {
2389
+ // Synthetic pointers cannot be captured.
2390
+ }
2391
+ element.addEventListener('pointermove', this.onStepPointerMove);
2392
+ element.addEventListener('pointerup', this.onStepPointerUp);
2393
+ element.addEventListener('pointercancel', this.onStepPointerCancel);
2394
+ }
2395
+ endStepDrag(commit) {
2396
+ const drag = this.stepDrag;
2397
+ if (!drag)
2398
+ return;
2399
+ this.stepDrag = undefined;
2400
+ const target = this._drag?.target;
2401
+ this._drag = undefined;
2402
+ const { element } = drag;
2403
+ element.removeEventListener('pointermove', this.onStepPointerMove);
2404
+ element.removeEventListener('pointerup', this.onStepPointerUp);
2405
+ element.removeEventListener('pointercancel', this.onStepPointerCancel);
2406
+ try {
2407
+ if (element.hasPointerCapture(drag.pointerId))
2408
+ element.releasePointerCapture(drag.pointerId);
2409
+ }
2410
+ catch {
2411
+ // The pointer is already gone.
2412
+ }
2413
+ if (!commit)
2414
+ return;
2415
+ const step = findStep(this.value, drag.id)?.step;
2416
+ if (!step)
2417
+ return;
2418
+ if (!drag.moved) {
2419
+ this.select(step);
2420
+ return;
2421
+ }
2422
+ const gap = target ? this.gaps.get(target) : undefined;
2423
+ if (!gap)
2424
+ return;
2425
+ this.commit(moveStep(this.value, drag.id, gap.ref, gap.index), 'move');
2426
+ this.announce(this.i18n.t('workflowStepMoved')(this.stepLabel(step)));
2427
+ }
2428
+ /** The nearest gap the dragged step can drop into. */
2429
+ dropTarget(id, clientX, clientY) {
2430
+ const found = findStep(this.value, id);
2431
+ if (!found)
2432
+ return undefined;
2433
+ let best;
2434
+ for (const [key, gap] of this.gaps) {
2435
+ const owner = gap.ref.kind === 'root'
2436
+ ? undefined
2437
+ : findStep(this.value, gap.ref.stepId)?.step;
2438
+ const inside = owner ? contains(found.step, owner.id) : false;
2439
+ const same = listKey(gap.ref) === listKey(found.ref);
2440
+ const noOp = same && (gap.index === found.index || gap.index === found.index + 1);
2441
+ const el = this._rootEl?.querySelector(`[data-gap="${CSS.escape(key)}"]`);
2442
+ if (!inside && !noOp && el) {
2443
+ const r = el.getBoundingClientRect();
2444
+ const d = Math.hypot(clientX - (r.left + r.width / 2), clientY - (r.top + r.height / 2));
2445
+ if (d < DROP_DISTANCE && (!best || d < best.d))
2446
+ best = { key, d };
2447
+ }
2448
+ }
2449
+ return best?.key;
2450
+ }
2451
+ // ── Render helpers
2452
+ renderValue(text) {
2453
+ const parts = [];
2454
+ let last = 0;
2455
+ for (const match of text.matchAll(DATA_PILL)) {
2456
+ const index = match.index ?? 0;
2457
+ if (index > last)
2458
+ parts.push(text.slice(last, index));
2459
+ const ref = match[1];
2460
+ const source = ref.split('.')[0].trim();
2461
+ let icon = 'data_object';
2462
+ const { trigger } = this.value;
2463
+ if (trigger &&
2464
+ (source === 'Trigger' ||
2465
+ source === trigger.headline ||
2466
+ source === trigger.id)) {
2467
+ icon = trigger.icon ?? 'bolt';
2468
+ }
2469
+ else {
2470
+ walk(this.value, ({ step }) => {
2471
+ if (step.headline === source || step.id === source)
2472
+ icon = step.icon ?? icon;
2473
+ });
2474
+ }
2475
+ parts.push(b `<span class="wf-ref"
2476
+ ><wc-icon name=${icon}></wc-icon>${ref.replace(/\./, ' · ')}</span
2477
+ >`);
2478
+ last = index + match[0].length;
2479
+ }
2480
+ if (last < text.length)
2481
+ parts.push(text.slice(last));
2482
+ return parts;
2483
+ }
2484
+ renderCardBody(step) {
2485
+ if (this.density === 'compact')
2486
+ return A;
2487
+ const limit = this.density === 'expanded' ? Infinity : 3;
2488
+ const rows = [];
2489
+ if (step.type === 'action')
2490
+ rows.push(...(step.fields ?? []).map(f => [f.label, f.value]));
2491
+ if (step.type === 'wait' && step.until)
2492
+ rows.push([this.i18n.t('workflowUntil'), step.until]);
2493
+ const collapsed = this._collapsed.has(step.id) && this.isBlock(step);
2494
+ let pathCount = 1;
2495
+ if (step.type === 'branch' || step.type === 'parallel') {
2496
+ pathCount = step.paths.length;
2497
+ }
2498
+ const summary = collapsed
2499
+ ? this.i18n.t('workflowCollapsedSummary')(pathCount, countInside(step))
2500
+ : '';
2501
+ if (!rows.length && !summary)
2502
+ return A;
2503
+ return b `<div class="wf-card-body">
2504
+ ${summary ? b `<div class="wf-summary">${summary}</div>` : A}
2505
+ ${rows
2506
+ .slice(0, limit)
2507
+ .map(([label, value]) => b `<div class="wf-field">
2508
+ <span class="wf-field-label">${label}</span
2509
+ ><span class="wf-field-value">${this.renderValue(value)}</span>
2510
+ </div>`)}
2511
+ </div>`;
2512
+ }
2513
+ renderStatus(run) {
2514
+ const icon = {
2515
+ queued: 'schedule',
2516
+ running: 'progress_activity',
2517
+ waiting: 'hourglass_top',
2518
+ paused: 'pause_circle',
2519
+ success: 'check_circle',
2520
+ failed: 'error',
2521
+ skipped: 'block',
2522
+ canceled: 'cancel',
2523
+ }[run.status];
2524
+ const done = run.status === 'success' || run.status === 'failed';
2525
+ const text = done && run.durationMs !== undefined
2526
+ ? formatDuration(run.durationMs, this.i18n.locale)
2527
+ : this.statusLabel(run.status);
2528
+ return b `<span
2529
+ class=${`wf-status st-${run.status}`}
2530
+ title=${this.statusLabel(run.status)}
2531
+ ><wc-icon name=${icon}></wc-icon>${text}${run.attempts && run.attempts > 1
2532
+ ? b `<span class="wf-attempts">×${run.attempts}</span>`
2533
+ : A}</span
2534
+ >`;
2535
+ }
2536
+ renderRunError(step, run) {
2537
+ if (!run || run.status !== 'failed' || !run.error)
2538
+ return A;
2539
+ return b `<div class="wf-run-error">
2540
+ <span
2541
+ class="wf-run-error-text"
2542
+ title=${run.error.detail ?? run.error.message}
2543
+ >${run.error.message}</span
2544
+ >
2545
+ ${this.mode === 'debug'
2546
+ ? b `<button
2547
+ class="wf-retry"
2548
+ type="button"
2549
+ tabindex="-1"
2550
+ @click=${() => this.debugAction('retry', step.id)}
2551
+ >
2552
+ <wc-icon name="replay"></wc-icon>${this.i18n.t('workflowRetryFromHere')}
2553
+ </button>`
2554
+ : A}
2555
+ </div>`;
2556
+ }
2557
+ /** The iteration picker in a loop's header: previous, "3 / 12", next and a tick per iteration. */
2558
+ renderIterations(loopId) {
2559
+ const iterations = this.runStep(loopId)?.iterations;
2560
+ if (!iterations?.length)
2561
+ return A;
2562
+ const total = iterations.length;
2563
+ const index = this.iterationIndex(loopId, total);
2564
+ const ticks = total <= 24;
2565
+ return b `<div
2566
+ class="wf-iterations"
2567
+ role="group"
2568
+ aria-label=${this.i18n.t('workflowIteration')(index + 1, total)}
2569
+ >
2570
+ <wc-icon-button
2571
+ variant="text"
2572
+ shape="round"
2573
+ size="xs"
2574
+ aria-label=${this.i18n.t('workflowPreviousIteration')}
2575
+ ?disabled=${index === 0}
2576
+ @click=${() => this.setIteration(loopId, index - 1)}
2577
+ ><wc-icon name="chevron_left"></wc-icon
2578
+ ></wc-icon-button>
2579
+ <span class="wf-iteration-label"
2580
+ >${this.i18n.t('workflowIterationShort')(index + 1, total)}</span
2581
+ >
2582
+ <wc-icon-button
2583
+ variant="text"
2584
+ shape="round"
2585
+ size="xs"
2586
+ aria-label=${this.i18n.t('workflowNextIteration')}
2587
+ ?disabled=${index === total - 1}
2588
+ @click=${() => this.setIteration(loopId, index + 1)}
2589
+ ><wc-icon name="chevron_right"></wc-icon
2590
+ ></wc-icon-button>
2591
+ ${ticks
2592
+ ? b `<span class="wf-ticks">
2593
+ ${iterations.map((record, i) => b `<button
2594
+ type="button"
2595
+ tabindex="-1"
2596
+ class=${e$1({
2597
+ 'wf-tick': true,
2598
+ [`st-${Workflow_1.iterationStatus(record)}`]: true,
2599
+ 'is-current': i === index,
2600
+ })}
2601
+ aria-label=${this.i18n.t('workflowIteration')(i + 1, total)}
2602
+ @click=${() => this.setIteration(loopId, i)}
2603
+ ></button>`)}
2604
+ </span>`
2605
+ : A}
2606
+ </div>`;
2607
+ }
2608
+ renderDebugBar() {
2609
+ const { run } = this;
2610
+ if (this.mode === 'history') {
2611
+ if (!run)
2612
+ return A;
2613
+ return b `<div class=${`wf-runbar st-${run.status}`} role="status">
2614
+ ${this.i18n.t('workflowRunSummary')(run.id, this.statusLabel(run.status), formatDuration(run.durationMs, this.i18n.locale))}
2615
+ </div>`;
2616
+ }
2617
+ if (this.mode !== 'debug')
2618
+ return A;
2619
+ const finished = !run ||
2620
+ run.status === 'success' ||
2621
+ run.status === 'failed' ||
2622
+ run.status === 'canceled';
2623
+ const running = run?.status === 'running';
2624
+ const button = (action, icon, label, disabled = false) => b `<wc-icon-button
2625
+ shape="round"
2626
+ variant=${action === 'continue' || action === 'pause'
2627
+ ? 'filled'
2628
+ : 'tonal'}
2629
+ aria-label=${label}
2630
+ tooltip=${label}
2631
+ ?disabled=${disabled}
2632
+ @click=${() => this.debugAction(action)}
2633
+ ><wc-icon name=${icon}></wc-icon
2634
+ ></wc-icon-button>`;
2635
+ return b `<div
2636
+ class="wf-debugbar"
2637
+ role="toolbar"
2638
+ aria-label=${this.i18n.t('workflowDebugBar')}
2639
+ >
2640
+ ${run
2641
+ ? b `<span class=${`wf-run-status st-${run.status}`}
2642
+ >${this.statusLabel(run.status)}</span
2643
+ >`
2644
+ : A}
2645
+ ${running
2646
+ ? button('pause', 'pause', `${this.i18n.t('workflowPause')} (F5)`)
2647
+ : button('continue', 'play_arrow', `${this.i18n.t('workflowContinue')} (F5)`, finished && !!run)}
2648
+ ${button('step-over', 'step_over', `${this.i18n.t('workflowStepOver')} (F10)`, finished)}
2649
+ ${button('step-into', 'step_into', `${this.i18n.t('workflowStepInto')} (F11)`, finished)}
2650
+ ${button('restart', 'restart_alt', `${this.i18n.t('workflowRestart')} (Ctrl+Shift+F5)`)}
2651
+ ${button('stop', 'stop', `${this.i18n.t('workflowStop')} (Shift+F5)`, finished)}
2652
+ </div>`;
2653
+ }
2654
+ renderCardFooter(step) {
2655
+ if (this.density === 'compact' || step.type !== 'action')
2656
+ return A;
2657
+ const { outputs, tools, assignee } = step;
2658
+ if (!outputs?.length && !tools?.length && !assignee)
2659
+ return A;
2660
+ return b `<div class="wf-card-foot">
2661
+ ${assignee
2662
+ ? b `<span class="wf-assignee"
2663
+ ><wc-avatar
2664
+ size="sm"
2665
+ name=${assignee.name}
2666
+ src=${assignee.src ?? A}
2667
+ ></wc-avatar
2668
+ >${assignee.name}</span
2669
+ >`
2670
+ : A}
2671
+ ${outputs?.length
2672
+ ? b `<span class="wf-foot-label"
2673
+ >${this.i18n.t('workflowOutputs')}</span
2674
+ >${outputs.map(o => b `<span class="wf-chip" title=${o.type ?? A}
2675
+ >${o.name}</span
2676
+ >`)}`
2677
+ : A}
2678
+ ${tools?.length
2679
+ ? tools.map(t => b `<span class="wf-chip tool"
2680
+ ><wc-icon name=${t.icon ?? 'build'}></wc-icon
2681
+ >${t.headline}</span
2682
+ >`)
2683
+ : A}
2684
+ </div>`;
2685
+ }
2686
+ renderCard(step, ctx) {
2687
+ const selected = this.selected === step.id;
2688
+ const invalid = !!step.invalid || this.unreachable.has(step.id);
2689
+ const block = this.isBlock(step);
2690
+ const collapsed = block && this._collapsed.has(step.id);
2691
+ const accent = step.accent ?? this.defaultAccent(step, !!ctx.trigger);
2692
+ const focusId = this._focusId || this.navOrder()[0];
2693
+ const problem = invalid
2694
+ ? step.errorText || this.i18n.t('workflowUnreachable')
2695
+ : '';
2696
+ const run = this.runStep(step.id);
2697
+ const statusText = run ? this.statusLabel(run.status) : '';
2698
+ const label = [
2699
+ this.stepLabel(step),
2700
+ step.supportingText,
2701
+ statusText,
2702
+ problem,
2703
+ ]
2704
+ .filter(Boolean)
2705
+ .join(', ');
2706
+ const breakpoint = this.breakpoints.includes(step.id);
2707
+ return b `<div
2708
+ class=${e$1({
2709
+ 'wf-card': true,
2710
+ [`accent-${accent}`]: true,
2711
+ 'is-selected': selected,
2712
+ 'is-invalid': invalid,
2713
+ 'is-trigger': !!ctx.trigger,
2714
+ 'is-dragging': this._drag?.id === step.id,
2715
+ [`st-${run?.status}`]: !!run,
2716
+ 'is-current': !!run && this.run?.current === step.id,
2717
+ })}
2718
+ data-card-id=${step.id}
2719
+ data-flip=${`card:${step.id}`}
2720
+ data-in-for=${ctx.inAnchor === false ? A : step.id}
2721
+ data-out-for=${ctx.outAnchor === false ? A : step.id}
2722
+ ?data-trigger=${!!ctx.trigger}
2723
+ role="treeitem"
2724
+ aria-level=${ctx.depth}
2725
+ aria-setsize=${ctx.size}
2726
+ aria-posinset=${ctx.index + 1}
2727
+ aria-selected=${selected ? 'true' : 'false'}
2728
+ aria-expanded=${block ? String(!collapsed) : A}
2729
+ aria-label=${label}
2730
+ tabindex=${focusId === step.id ? '0' : '-1'}
2731
+ @pointerdown=${(e) => this.onCardPointerDown(e, step)}
2732
+ @keydown=${(e) => this.onCardKeyDown(e, step)}
2733
+ @focus=${() => {
2734
+ this._focusId = step.id;
2735
+ }}
2736
+ >
2737
+ ${this.mode === 'debug'
2738
+ ? b `<button
2739
+ class=${e$1({ 'wf-bp': true, 'is-on': breakpoint })}
2740
+ type="button"
2741
+ tabindex="-1"
2742
+ aria-pressed=${breakpoint ? 'true' : 'false'}
2743
+ aria-label=${this.i18n.t('workflowToggleBreakpoint')}
2744
+ title=${this.i18n.t('workflowBreakpoint')}
2745
+ @click=${() => this.toggleBreakpoint(step.id)}
2746
+ ></button>`
2747
+ : A}
2748
+ <slot name=${`step:${step.id}`}>
2749
+ <div class="wf-card-head">
2750
+ <span class="wf-tile"
2751
+ >${step.icon
2752
+ ? b `<wc-icon name=${step.icon}></wc-icon>`
2753
+ : A}</span
2754
+ >
2755
+ <span class="wf-names">
2756
+ <span class="wf-headline">${this.stepLabel(step)}</span>
2757
+ ${step.supportingText
2758
+ ? b `<span class="wf-kind">${step.supportingText}</span>`
2759
+ : A}
2760
+ </span>
2761
+ ${step.pinned
2762
+ ? b `<span class="wf-pin" title=${this.i18n.t('workflowPinned')}
2763
+ ><wc-icon name="keep"></wc-icon
2764
+ ></span>`
2765
+ : A}
2766
+ ${invalid && !run
2767
+ ? b `<span
2768
+ class="wf-badge"
2769
+ title=${step.errorText || this.i18n.t('workflowUnreachable')}
2770
+ ><wc-icon name="error"></wc-icon
2771
+ ></span>`
2772
+ : A}
2773
+ ${run ? this.renderStatus(run) : A}
2774
+ ${block
2775
+ ? b `<wc-icon-button
2776
+ class="wf-toggle"
2777
+ variant="text"
2778
+ shape="round"
2779
+ size="xs"
2780
+ tabindex="-1"
2781
+ aria-label=${this.i18n.t(collapsed ? 'workflowExpand' : 'workflowCollapse')}
2782
+ @click=${() => collapsed ? this.expand(step.id) : this.collapse(step.id)}
2783
+ ><wc-icon
2784
+ name=${collapsed ? 'unfold_more' : 'unfold_less'}
2785
+ ></wc-icon
2786
+ ></wc-icon-button>`
2787
+ : A}
2788
+ ${this.hasMenu
2789
+ ? b `<wc-icon-button
2790
+ class="wf-more"
2791
+ variant="text"
2792
+ shape="round"
2793
+ size="xs"
2794
+ tabindex="-1"
2795
+ aria-label=${this.i18n.t('workflowMoreActions')}
2796
+ @click=${(e) => this.openMenu(step.id, e.currentTarget)}
2797
+ ><wc-icon name="more_vert"></wc-icon
2798
+ ></wc-icon-button>`
2799
+ : A}
2800
+ </div>
2801
+ ${this.renderCardBody(step)} ${this.renderRunError(step, run)}
2802
+ ${this.renderCardFooter(step)}
2803
+ </slot>
2804
+ </div>`;
2805
+ }
2806
+ defaultAccent(step, trigger) {
2807
+ if (trigger)
2808
+ return 'primary';
2809
+ switch (step.type) {
2810
+ case 'branch':
2811
+ case 'parallel':
2812
+ return 'orange';
2813
+ case 'loop':
2814
+ return 'purple';
2815
+ case 'wait':
2816
+ return 'yellow';
2817
+ case 'end':
2818
+ return 'neutral';
2819
+ default:
2820
+ return 'blue';
2821
+ }
2822
+ }
2823
+ renderGap(ref, index, previous, owner, trailing = false) {
2824
+ const key = `${listKey(ref)}#${index}`;
2825
+ this.gaps.set(key, { ref, index });
2826
+ const name = previous
2827
+ ? this.i18n.t('workflowAddStepAfter')(this.stepLabel(previous))
2828
+ : this.i18n.t('workflowAddStepIn')(owner ? this.stepLabel(owner) : this.i18n.t('workflowLabel'));
2829
+ return b `<div
2830
+ class=${e$1({
2831
+ 'wf-gap': true,
2832
+ 'is-trailing': trailing,
2833
+ 'is-drop': this._drag?.target === key,
2834
+ })}
2835
+ data-gap=${key}
2836
+ >
2837
+ ${this.editing
2838
+ ? b `<button
2839
+ class="wf-plus"
2840
+ type="button"
2841
+ tabindex="-1"
2842
+ aria-label=${name}
2843
+ title=${this.i18n.t('workflowAddStep')}
2844
+ @click=${(e) => this.openPalette(ref, index, e.currentTarget)}
2845
+ @mouseenter=${() => {
2846
+ this._hoverGap = key;
2847
+ }}
2848
+ @mouseleave=${() => {
2849
+ if (this._hoverGap === key)
2850
+ this._hoverGap = '';
2851
+ }}
2852
+ >
2853
+ <wc-icon name="add"></wc-icon>
2854
+ </button>`
2855
+ : A}
2856
+ </div>`;
2857
+ }
2858
+ renderList(steps, ref, depth, leading, owner) {
2859
+ return b `<div class="wf-seq" role="group">
2860
+ ${this.renderItems(steps, ref, depth, leading, owner)}
2861
+ </div>`;
2862
+ }
2863
+ renderItems(steps, ref, depth, leading, owner) {
2864
+ const out = [];
2865
+ steps.forEach((step, i) => {
2866
+ if (i > 0 || leading)
2867
+ out.push(this.renderGap(ref, i, steps[i - 1], owner));
2868
+ out.push(this.renderStep(step, i, steps.length, depth));
2869
+ });
2870
+ if (!listTerminates(steps) && this.editing) {
2871
+ out.push(this.renderGap(ref, steps.length, steps[steps.length - 1], owner, true));
2872
+ }
2873
+ return out;
2874
+ }
2875
+ renderStep(step, index, size, depth) {
2876
+ const ctx = { depth, index, size };
2877
+ const collapsed = this._collapsed.has(step.id);
2878
+ if (step.type === 'end') {
2879
+ const selected = this.selected === step.id;
2880
+ const focusId = this._focusId || this.navOrder()[0];
2881
+ const reached = this.runStep(step.id)?.status;
2882
+ return b `<div class="wf-item">
2883
+ <div
2884
+ class=${e$1({
2885
+ 'wf-end': true,
2886
+ 'is-selected': selected,
2887
+ 'is-invalid': this.unreachable.has(step.id),
2888
+ [`st-${reached}`]: !!reached,
2889
+ })}
2890
+ data-card-id=${step.id}
2891
+ data-in-for=${step.id}
2892
+ data-flip=${`card:${step.id}`}
2893
+ role="treeitem"
2894
+ aria-label=${this.stepLabel(step)}
2895
+ aria-level=${depth}
2896
+ aria-setsize=${size}
2897
+ aria-posinset=${index + 1}
2898
+ aria-selected=${selected ? 'true' : 'false'}
2899
+ tabindex=${focusId === step.id ? '0' : '-1'}
2900
+ @pointerdown=${(e) => this.onCardPointerDown(e, step)}
2901
+ @keydown=${(e) => this.onCardKeyDown(e, step)}
2902
+ @focus=${() => {
2903
+ this._focusId = step.id;
2904
+ }}
2905
+ >
2906
+ <wc-icon name=${step.icon ?? 'stop_circle'}></wc-icon
2907
+ >${this.stepLabel(step)}
2908
+ </div>
2909
+ </div>`;
2910
+ }
2911
+ if ((step.type === 'branch' || step.type === 'parallel') && !collapsed) {
2912
+ const ends = stepTerminates(step);
2913
+ return b `<div
2914
+ class=${e$1({
2915
+ 'wf-item': true,
2916
+ 'wf-block': true,
2917
+ [step.type]: true,
2918
+ })}
2919
+ >
2920
+ ${this.renderCard(step, { ...ctx, outAnchor: false })}
2921
+ <div class="wf-paths" data-paths-for=${step.id}>
2922
+ ${step.paths.map(p => {
2923
+ const ref = {
2924
+ kind: 'path',
2925
+ stepId: step.id,
2926
+ pathId: p.id,
2927
+ };
2928
+ return b `<div class="wf-path" role="group" aria-label=${p.label}>
2929
+ <div
2930
+ class=${e$1({
2931
+ 'wf-pill': true,
2932
+ 'is-default': !!p.isDefault,
2933
+ })}
2934
+ data-pill=${p.id}
2935
+ data-flip=${`pill:${p.id}`}
2936
+ >
2937
+ ${p.label}
2938
+ </div>
2939
+ ${this.renderList(p.steps, ref, depth + 1, true, step)}
2940
+ <div class="wf-path-tail"></div>
2941
+ </div>`;
2942
+ })}
2943
+ </div>
2944
+ ${ends
2945
+ ? A
2946
+ : b `<div
2947
+ class=${e$1({
2948
+ 'wf-join': true,
2949
+ 'is-bar': step.type === 'parallel',
2950
+ })}
2951
+ data-join-for=${step.id}
2952
+ data-out-for=${step.id}
2953
+ data-flip=${`join:${step.id}`}
2954
+ >
2955
+ ${step.type === 'parallel'
2956
+ ? b `<span>${this.i18n.t('workflowWaitForAll')}</span>`
2957
+ : A}
2958
+ </div>`}
2959
+ </div>`;
2960
+ }
2961
+ if (step.type === 'loop' && !collapsed) {
2962
+ const mode = {
2963
+ 'for-each': this.i18n.t('workflowLoopForEach'),
2964
+ while: this.i18n.t('workflowLoopWhile'),
2965
+ until: this.i18n.t('workflowLoopUntil'),
2966
+ }[step.mode ?? 'for-each'];
2967
+ return b `<div
2968
+ class="wf-item wf-block wf-loop"
2969
+ data-loop-for=${step.id}
2970
+ data-in-for=${step.id}
2971
+ data-out-for=${step.id}
2972
+ data-flip=${`loop:${step.id}`}
2973
+ >
2974
+ <div class="wf-loop-head">
2975
+ ${this.renderCard({ ...step, supportingText: step.supportingText ?? mode }, { ...ctx, inAnchor: false, outAnchor: false })}
2976
+ ${step.over
2977
+ ? b `<span class="wf-loop-over"
2978
+ >${this.renderValue(step.over)}</span
2979
+ >`
2980
+ : A}
2981
+ ${this.renderIterations(step.id)}
2982
+ </div>
2983
+ ${this.renderList(step.steps, { kind: 'loop', stepId: step.id }, depth + 1, true, step)}
2984
+ </div>`;
2985
+ }
2986
+ const card = this.renderCard(step, ctx);
2987
+ if (step.type === 'action' && step.onError) {
2988
+ return b `<div class="wf-item wf-has-error">
2989
+ <div class="wf-error-spacer"></div>
2990
+ ${card}
2991
+ <div class="wf-error-col">
2992
+ <div
2993
+ class="wf-pill is-error"
2994
+ data-error-pill=${step.id}
2995
+ data-flip=${`err:${step.id}`}
2996
+ >
2997
+ ${this.i18n.t('workflowOnError')}
2998
+ </div>
2999
+ ${this.renderList(step.onError, { kind: 'error', stepId: step.id }, depth + 1, true, step)}
3000
+ </div>
3001
+ </div>`;
3002
+ }
3003
+ return b `<div class="wf-item">${card}</div>`;
3004
+ }
3005
+ renderPalette() {
3006
+ const p = this._palette;
3007
+ if (!p)
3008
+ return A;
3009
+ const entries = this.paletteEntries();
3010
+ const groups = new Map();
3011
+ entries.forEach((entry, index) => {
3012
+ const name = entry.category ?? '';
3013
+ if (!groups.has(name))
3014
+ groups.set(name, []);
3015
+ groups.get(name)?.push({ entry, index });
3016
+ });
3017
+ const activeId = entries[p.active] ? `wf-option-${p.active}` : '';
3018
+ return b `<div
3019
+ class="wf-palette"
3020
+ data-diagram-overlay
3021
+ role="dialog"
3022
+ aria-label=${this.i18n.t(p.trigger ? 'workflowAddTrigger' : 'workflowAddStep')}
3023
+ style="left: ${p.x}px; top: ${p.y}px;"
3024
+ @pointerdown=${(e) => e.stopPropagation()}
3025
+ >
3026
+ <label class="wf-palette-search">
3027
+ <wc-icon name="search"></wc-icon>
3028
+ <input
3029
+ type="search"
3030
+ role="combobox"
3031
+ aria-expanded="true"
3032
+ aria-controls="wf-palette-list"
3033
+ aria-activedescendant=${activeId || A}
3034
+ placeholder=${this.i18n.t('workflowSearchSteps')}
3035
+ aria-label=${this.i18n.t('workflowSearchSteps')}
3036
+ .value=${p.query}
3037
+ @input=${(e) => {
3038
+ this._palette = {
3039
+ ...p,
3040
+ query: e.target.value,
3041
+ active: 0,
3042
+ };
3043
+ }}
3044
+ @keydown=${this.onPaletteKeyDown}
3045
+ />
3046
+ </label>
3047
+ <div
3048
+ class="wf-palette-list"
3049
+ id="wf-palette-list"
3050
+ role="listbox"
3051
+ aria-label=${this.i18n.t('workflowAddStep')}
3052
+ >
3053
+ ${entries.length
3054
+ ? [...groups].map(([name, items]) => b `<div
3055
+ class="wf-palette-group"
3056
+ role="group"
3057
+ aria-label=${name || A}
3058
+ >
3059
+ ${name
3060
+ ? b `<div class="wf-palette-heading" aria-hidden="true">
3061
+ ${name}
3062
+ </div>`
3063
+ : A}
3064
+ ${items.map(({ entry, index }) => b `<div
3065
+ id=${`wf-option-${index}`}
3066
+ class=${e$1({
3067
+ 'wf-option': true,
3068
+ 'is-active': index === p.active,
3069
+ })}
3070
+ role="option"
3071
+ aria-selected=${index === p.active ? 'true' : 'false'}
3072
+ @click=${() => this.choose(entry)}
3073
+ @keydown=${this.onPaletteKeyDown}
3074
+ @pointermove=${() => {
3075
+ if (this._palette && this._palette.active !== index)
3076
+ this._palette = { ...this._palette, active: index };
3077
+ }}
3078
+ >
3079
+ <span
3080
+ class=${`wf-tile accent-${entry.accent ?? this.defaultAccent({ id: '', type: entry.type }, !!entry.trigger)}`}
3081
+ >${entry.icon
3082
+ ? b `<wc-icon name=${entry.icon}></wc-icon>`
3083
+ : A}</span
3084
+ >
3085
+ <span class="wf-option-text">
3086
+ <span class="wf-option-title">${entry.headline}</span>
3087
+ ${entry.supportingText
3088
+ ? b `<span class="wf-option-sub"
3089
+ >${entry.supportingText}</span
3090
+ >`
3091
+ : A}
3092
+ </span>
3093
+ </div>`)}
3094
+ </div>`)
3095
+ : b `<div class="wf-palette-empty">
3096
+ ${this.i18n.t('workflowNoSteps')}
3097
+ </div>`}
3098
+ </div>
3099
+ </div>`;
3100
+ }
3101
+ renderMenu() {
3102
+ const step = this._menuFor
3103
+ ? findStep(this.value, this._menuFor)?.step
3104
+ : undefined;
3105
+ const block = step ? this.isBlock(step) : false;
3106
+ const collapsed = step ? this._collapsed.has(step.id) : false;
3107
+ const isTrigger = step?.id === this.value.trigger?.id;
3108
+ const pin = b `<wc-menu-item value=${step?.pinned ? 'unpin' : 'pin'}
3109
+ ><wc-icon slot="start" name="keep"></wc-icon>${this.i18n.t(step?.pinned ? 'workflowUnpinData' : 'workflowPinData')}</wc-menu-item
3110
+ >`;
3111
+ if (!this.editing) {
3112
+ return b `<wc-menu
3113
+ placement="bottom-end"
3114
+ @menu-item-activate=${this.onMenuActivate}
3115
+ >
3116
+ ${pin}
3117
+ </wc-menu>`;
3118
+ }
3119
+ return b `<wc-menu
3120
+ placement="bottom-end"
3121
+ @menu-item-activate=${this.onMenuActivate}
3122
+ >
3123
+ ${pin}
3124
+ ${isTrigger
3125
+ ? A
3126
+ : b `<wc-menu-item value="duplicate"
3127
+ ><wc-icon slot="start" name="content_copy"></wc-icon>${this.i18n.t('workflowDuplicate')}<span slot="trailing-supporting-text">Ctrl+D</span></wc-menu-item
3128
+ >`}
3129
+ ${block
3130
+ ? b `<wc-menu-item value=${collapsed ? 'expand' : 'collapse'}
3131
+ ><wc-icon
3132
+ slot="start"
3133
+ name=${collapsed ? 'unfold_more' : 'unfold_less'}
3134
+ ></wc-icon
3135
+ >${this.i18n.t(collapsed ? 'workflowExpand' : 'workflowCollapse')}</wc-menu-item
3136
+ >`
3137
+ : A}
3138
+ <wc-menu-item value="delete"
3139
+ ><wc-icon slot="start" name="delete"></wc-icon>${this.i18n.t('workflowDelete')}<span slot="trailing-supporting-text">Del</span></wc-menu-item
3140
+ >
3141
+ </wc-menu>`;
3142
+ }
3143
+ renderDragGhost() {
3144
+ const drag = this._drag;
3145
+ if (!drag)
3146
+ return A;
3147
+ const step = findStep(this.value, drag.id)?.step;
3148
+ if (!step)
3149
+ return A;
3150
+ return b `<div
3151
+ class="wf-ghost"
3152
+ style="left: ${drag.x}px; top: ${drag.y}px;"
3153
+ >
3154
+ ${step.icon
3155
+ ? b `<wc-icon name=${step.icon}></wc-icon>`
3156
+ : A}${this.stepLabel(step)}
3157
+ </div>`;
3158
+ }
3159
+ /** The trigger card, or a button to add one while editing. */
3160
+ renderTrigger() {
3161
+ const { trigger } = this.value;
3162
+ if (trigger) {
3163
+ return b `<div class="wf-item">
3164
+ ${this.renderCard(trigger, {
3165
+ depth: 1,
3166
+ index: 0,
3167
+ size: 1,
3168
+ trigger: true,
3169
+ })}
3170
+ </div>`;
3171
+ }
3172
+ if (!this.editing)
3173
+ return A;
3174
+ return b `<div class="wf-item">
3175
+ <button
3176
+ class="wf-add-trigger"
3177
+ type="button"
3178
+ data-trigger
3179
+ data-flip=${TRIGGER_GAP}
3180
+ @click=${(e) => this.openPalette({ kind: 'root' }, 0, e.currentTarget, true)}
3181
+ >
3182
+ <wc-icon name="bolt"></wc-icon>${this.i18n.t('workflowAddTrigger')}
3183
+ </button>
3184
+ </div>`;
3185
+ }
3186
+ // ── Render
3187
+ render() {
3188
+ const { x, y, zoom } = this.viewport.view;
3189
+ this.gaps = new Map();
3190
+ const { trigger } = this.value;
3191
+ const { problems } = this;
3192
+ return b `
3193
+ <div
3194
+ class=${e$1({
3195
+ 'wf-viewport': true,
3196
+ 'is-panning': this.viewport.panning,
3197
+ 'is-space': this.viewport.spaceHeld,
3198
+ 'is-dragging': !!this._drag,
3199
+ })}
3200
+ tabindex="0"
3201
+ role="region"
3202
+ aria-label=${this.label || this.i18n.t('workflowLabel')}
3203
+ aria-describedby="instructions"
3204
+ style=${this.gridStyle()}
3205
+ @keydown=${this.onViewportKeyDown}
3206
+ @pointerdown=${() => {
3207
+ if (this._palette)
3208
+ this._palette = undefined;
3209
+ }}
3210
+ >
3211
+ <div
3212
+ class="wf-world"
3213
+ style="transform: translate(${x}px, ${y}px) scale(${zoom});"
3214
+ >
3215
+ <svg
3216
+ class="wf-connectors"
3217
+ width="1"
3218
+ height="1"
3219
+ aria-hidden="true"
3220
+ ></svg>
3221
+ <div
3222
+ class=${e$1({
3223
+ 'wf-root': true,
3224
+ [this.direction]: true,
3225
+ [`density-${this.density}`]: true,
3226
+ })}
3227
+ role="tree"
3228
+ aria-label=${this.label || this.i18n.t('workflowLabel')}
3229
+ >
3230
+ <div class="wf-seq" role="group">
3231
+ ${this.renderTrigger()}
3232
+ ${this.renderItems(this.value.steps, { kind: 'root' }, 1, !!trigger || this.editing)}
3233
+ </div>
3234
+ </div>
3235
+ <svg class="wf-tokens" width="1" height="1" aria-hidden="true"></svg>
3236
+ </div>
3237
+ ${this.renderDebugBar()}
3238
+ ${problems.length && this.mode === 'design'
3239
+ ? b `<button
3240
+ class="wf-problems"
3241
+ type="button"
3242
+ @click=${() => this.nextProblem()}
3243
+ >
3244
+ <wc-icon name="error"></wc-icon>${this.i18n.t('workflowProblems')(problems.length)}
3245
+ </button>`
3246
+ : A}
3247
+ ${this.renderPalette()} ${this.renderDragGhost()}
3248
+ ${this.renderBackToContent()}
3249
+ <div class="slot-controls"><slot name="controls"></slot></div>
3250
+ <div class="slot-minimap"><slot name="minimap"></slot></div>
3251
+ <div id="instructions" hidden>
3252
+ ${this.i18n.t('diagramInstructions')}
3253
+ </div>
3254
+ <div class="sr-only" aria-live="polite">${this._announcement}</div>
3255
+ ${this.renderMenu()}
3256
+ </div>
3257
+ `;
3258
+ }
3259
+ };
3260
+ Workflow.styles = [css_248z];
3261
+ __decorate([
3262
+ n({ attribute: false })
3263
+ ], Workflow.prototype, "value", void 0);
3264
+ __decorate([
3265
+ n({ attribute: false })
3266
+ ], Workflow.prototype, "stepTypes", void 0);
3267
+ __decorate([
3268
+ n({ type: String, reflect: true })
3269
+ ], Workflow.prototype, "direction", void 0);
3270
+ __decorate([
3271
+ n({ type: String, reflect: true })
3272
+ ], Workflow.prototype, "density", void 0);
3273
+ __decorate([
3274
+ n({ type: String, reflect: true })
3275
+ ], Workflow.prototype, "selected", void 0);
3276
+ __decorate([
3277
+ n({ type: String, reflect: true })
3278
+ ], Workflow.prototype, "mode", void 0);
3279
+ __decorate([
3280
+ n({ attribute: false })
3281
+ ], Workflow.prototype, "run", void 0);
3282
+ __decorate([
3283
+ n({ attribute: false })
3284
+ ], Workflow.prototype, "breakpoints", void 0);
3285
+ __decorate([
3286
+ n({ type: Boolean })
3287
+ ], Workflow.prototype, "follow", void 0);
3288
+ __decorate([
3289
+ r()
3290
+ ], Workflow.prototype, "_palette", void 0);
3291
+ __decorate([
3292
+ r()
3293
+ ], Workflow.prototype, "_collapsed", void 0);
3294
+ __decorate([
3295
+ r()
3296
+ ], Workflow.prototype, "_focusId", void 0);
3297
+ __decorate([
3298
+ r()
3299
+ ], Workflow.prototype, "_hoverGap", void 0);
3300
+ __decorate([
3301
+ r()
3302
+ ], Workflow.prototype, "_drag", void 0);
3303
+ __decorate([
3304
+ r()
3305
+ ], Workflow.prototype, "_menuFor", void 0);
3306
+ __decorate([
3307
+ r()
3308
+ ], Workflow.prototype, "_announcement", void 0);
3309
+ __decorate([
3310
+ r()
3311
+ ], Workflow.prototype, "_iterations", void 0);
3312
+ __decorate([
3313
+ e('.wf-viewport')
3314
+ ], Workflow.prototype, "_viewportEl", void 0);
3315
+ __decorate([
3316
+ e('.wf-world')
3317
+ ], Workflow.prototype, "_worldEl", void 0);
3318
+ __decorate([
3319
+ e('.wf-root')
3320
+ ], Workflow.prototype, "_rootEl", void 0);
3321
+ __decorate([
3322
+ e('.wf-connectors')
3323
+ ], Workflow.prototype, "_connectorsEl", void 0);
3324
+ __decorate([
3325
+ e('wc-menu')
3326
+ ], Workflow.prototype, "_menu", void 0);
3327
+ __decorate([
3328
+ e('.wf-tokens')
3329
+ ], Workflow.prototype, "_tokensEl", void 0);
3330
+ Workflow = Workflow_1 = __decorate([
3331
+ IndividualComponent
3332
+ ], Workflow);
3333
+ // The connector layer is measured after each render, so a second update is expected.
3334
+ Workflow.disableWarning?.('change-in-update');
3335
+
3336
+ export { WORKFLOW_LOGIC_STEPS, Workflow };
3337
+ //# sourceMappingURL=workflow.js.map