@powerhousedao/workflow 6.2.3-dev.24 → 6.2.3-dev.26

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 (308) hide show
  1. package/README.md +37 -0
  2. package/dist/browser/BlockSelector-QQgOCVH3.js +1355 -0
  3. package/dist/browser/BlockSelector-QQgOCVH3.js.map +1 -0
  4. package/dist/browser/{PieceMarkdown-CZYNY1qQ.js → PieceMarkdown-C8Gv88TV.js} +139 -105
  5. package/dist/browser/PieceMarkdown-C8Gv88TV.js.map +1 -0
  6. package/dist/browser/assets/{entry-CSJBrcX5.js → entry-DhaRsTID.js} +2 -3
  7. package/dist/browser/assets/{projection-entry-D67cdPsg.js → projection-entry-qrF_MLsE.js} +7 -13
  8. package/dist/browser/{connection-DEe5aDuU.js → connection-BUum0hJI.js} +2 -2
  9. package/dist/browser/{connection-DEe5aDuU.js.map → connection-BUum0hJI.js.map} +1 -1
  10. package/dist/browser/connection-form-XKR4zQgQ.js +533 -0
  11. package/dist/browser/connection-form-XKR4zQgQ.js.map +1 -0
  12. package/dist/browser/data-tree-DKrDFeQg.js +1896 -0
  13. package/dist/browser/data-tree-DKrDFeQg.js.map +1 -0
  14. package/dist/browser/document-models/connection/index.js +2 -2
  15. package/dist/browser/document-models/index.js +3 -3
  16. package/dist/browser/document-models/workflow/index.js +2 -2
  17. package/dist/browser/{document-models-BYheX-te.js → document-models-C6ebrsd9.js} +3 -3
  18. package/dist/browser/{document-models-BYheX-te.js.map → document-models-C6ebrsd9.js.map} +1 -1
  19. package/dist/browser/editor-C_E_JTp6.js +257 -0
  20. package/dist/browser/editor-C_E_JTp6.js.map +1 -0
  21. package/dist/browser/{editor-D0sdUxJa.js → editor-YZw296bf.js} +3348 -1610
  22. package/dist/browser/editor-YZw296bf.js.map +1 -0
  23. package/dist/browser/editor-fjwq-8Yq.js +1527 -0
  24. package/dist/browser/editor-fjwq-8Yq.js.map +1 -0
  25. package/dist/browser/editors/connection-editor/module.js +1 -1
  26. package/dist/browser/editors/connection-editor/module.js.map +1 -1
  27. package/dist/browser/editors/workflow-editor/module.js +1 -1
  28. package/dist/browser/editors/workflow-editor/module.js.map +1 -1
  29. package/dist/browser/editors/workflow-studio/module.js +1 -1
  30. package/dist/browser/editors/workflow-studio/module.js.map +1 -1
  31. package/dist/browser/index.js +7 -5
  32. package/dist/browser/index.js.map +1 -1
  33. package/dist/browser/{module-CYQnNZWl.js → module-Bkms70LV.js} +3 -3
  34. package/dist/browser/{module-CYQnNZWl.js.map → module-Bkms70LV.js.map} +1 -1
  35. package/dist/{node/module-IA-Ay7ig.mjs → browser/module-jDZ4pq3W.js} +2 -2
  36. package/dist/browser/{module-12vI18HY.js.map → module-jDZ4pq3W.js.map} +1 -1
  37. package/dist/browser/piece-auth-Z4mZEOtL.js +113 -0
  38. package/dist/browser/piece-auth-Z4mZEOtL.js.map +1 -0
  39. package/dist/browser/reactor/index.js +2 -2
  40. package/dist/browser/{chunk-BoAXSpZd.js → rolldown-runtime-DC62tzP2.js} +2 -2
  41. package/dist/browser/{runtime-api-DKlnn45K.js → runtime-api-xwvg5PzA.js} +40 -123
  42. package/dist/browser/runtime-api-xwvg5PzA.js.map +1 -0
  43. package/dist/browser/style.css +26 -0
  44. package/dist/browser/trigger-text-CdNxQOHw.js +551 -0
  45. package/dist/browser/trigger-text-CdNxQOHw.js.map +1 -0
  46. package/dist/browser/upgrade-manifests-BLrv3cf2.js +8 -0
  47. package/dist/browser/{upgrade-manifests-Cnpfo6kC.js.map → upgrade-manifests-BLrv3cf2.js.map} +1 -1
  48. package/dist/browser/{workflow-CFZUezoY.js → workflow-CGtVlhr8.js} +2 -2
  49. package/dist/browser/{workflow-CFZUezoY.js.map → workflow-CGtVlhr8.js.map} +1 -1
  50. package/dist/node/BlockSelector-COZm6-ev.mjs +1355 -0
  51. package/dist/node/BlockSelector-COZm6-ev.mjs.map +1 -0
  52. package/dist/node/{PieceMarkdown-D9nI2gI2.mjs → PieceMarkdown-DIxZY5aG.mjs} +132 -100
  53. package/dist/node/PieceMarkdown-DIxZY5aG.mjs.map +1 -0
  54. package/dist/node/{connection-DGsS2Db3.mjs → connection-D544oqVW.mjs} +2 -2
  55. package/dist/node/{connection-DGsS2Db3.mjs.map → connection-D544oqVW.mjs.map} +1 -1
  56. package/dist/node/connection-form-BLduFusc.mjs +533 -0
  57. package/dist/node/connection-form-BLduFusc.mjs.map +1 -0
  58. package/dist/node/data-tree-CmiGqG7C.mjs +1903 -0
  59. package/dist/node/data-tree-CmiGqG7C.mjs.map +1 -0
  60. package/dist/node/document-models/connection/index.mjs +2 -2
  61. package/dist/node/document-models/index.mjs +3 -3
  62. package/dist/node/document-models/workflow/index.mjs +2 -2
  63. package/dist/node/{editor-sVzt1o51.mjs → editor-B2ZoeGue.mjs} +3200 -1508
  64. package/dist/node/editor-B2ZoeGue.mjs.map +1 -0
  65. package/dist/node/editor-CN4PEGrW.mjs +257 -0
  66. package/dist/node/editor-CN4PEGrW.mjs.map +1 -0
  67. package/dist/node/editor-CyNBEKoj.mjs +1527 -0
  68. package/dist/node/editor-CyNBEKoj.mjs.map +1 -0
  69. package/dist/node/editors/connection-editor/module.mjs +1 -1
  70. package/dist/node/editors/connection-editor/module.mjs.map +1 -1
  71. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  72. package/dist/node/editors/workflow-editor/module.mjs.map +1 -1
  73. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  74. package/dist/node/editors/workflow-studio/module.mjs.map +1 -1
  75. package/dist/node/index.mjs +8 -6
  76. package/dist/node/index.mjs.map +1 -1
  77. package/dist/{browser/module-12vI18HY.js → node/module-BMwJQh65.mjs} +2 -2
  78. package/dist/node/{module-IA-Ay7ig.mjs.map → module-BMwJQh65.mjs.map} +1 -1
  79. package/dist/node/{module-IRMgzJC1.mjs → module-DuxxhgKs.mjs} +3 -3
  80. package/dist/node/{module-IRMgzJC1.mjs.map → module-DuxxhgKs.mjs.map} +1 -1
  81. package/dist/node/piece-auth-Z4mZEOtL.mjs +113 -0
  82. package/dist/node/piece-auth-Z4mZEOtL.mjs.map +1 -0
  83. package/dist/node/pieces/index.mjs.map +1 -1
  84. package/dist/node/pieces/reactor/index.mjs +226 -488
  85. package/dist/node/pieces/reactor/index.mjs.map +1 -1
  86. package/dist/node/{chunk-BSw8zbkd.mjs → rolldown-runtime-BMI-E3GI.mjs} +11 -4
  87. package/dist/node/{runtime-api-CtvvFHut.mjs → runtime-api-xwvg5PzA.mjs} +40 -123
  88. package/dist/node/runtime-api-xwvg5PzA.mjs.map +1 -0
  89. package/dist/node/style.css +26 -0
  90. package/dist/node/trigger-text-qj_U3Qzd.mjs +551 -0
  91. package/dist/node/trigger-text-qj_U3Qzd.mjs.map +1 -0
  92. package/dist/node/upgrade-manifests-C1sl_M-H.mjs +8 -0
  93. package/dist/node/{upgrade-manifests-3VN0Bfcf.mjs.map → upgrade-manifests-C1sl_M-H.mjs.map} +1 -1
  94. package/dist/node/{workflow-fFvyypuu.mjs → workflow-C-uuQPnf.mjs} +2 -2
  95. package/dist/node/{workflow-fFvyypuu.mjs.map → workflow-C-uuQPnf.mjs.map} +1 -1
  96. package/dist/style.css +927 -252
  97. package/dist/types/document-models/connection/upgrades/versions.d.ts.map +1 -1
  98. package/dist/types/document-models/connection/v1/actions.d.ts +6 -10
  99. package/dist/types/document-models/connection/v1/actions.d.ts.map +1 -1
  100. package/dist/types/document-models/connection/v1/gen/config/creators.d.ts.map +1 -1
  101. package/dist/types/document-models/connection/v1/gen/config/error.d.ts.map +1 -1
  102. package/dist/types/document-models/connection/v1/gen/connection/creators.d.ts.map +1 -1
  103. package/dist/types/document-models/connection/v1/gen/health/creators.d.ts.map +1 -1
  104. package/dist/types/document-models/connection/v1/gen/schema/zod.d.ts.map +1 -1
  105. package/dist/types/document-models/connection/v1/module.d.ts +6 -10
  106. package/dist/types/document-models/connection/v1/module.d.ts.map +1 -1
  107. package/dist/types/document-models/connection/v1/tests/document-model.test.d.ts +0 -8
  108. package/dist/types/document-models/connection/v1/tests/document-model.test.d.ts.map +1 -1
  109. package/dist/types/document-models/document-models.d.ts +15 -23
  110. package/dist/types/document-models/document-models.d.ts.map +1 -1
  111. package/dist/types/document-models/workflow/upgrades/versions.d.ts.map +1 -1
  112. package/dist/types/document-models/workflow/v1/actions.d.ts +9 -13
  113. package/dist/types/document-models/workflow/v1/actions.d.ts.map +1 -1
  114. package/dist/types/document-models/workflow/v1/gen/edges/creators.d.ts.map +1 -1
  115. package/dist/types/document-models/workflow/v1/gen/edges/error.d.ts.map +1 -1
  116. package/dist/types/document-models/workflow/v1/gen/policy/creators.d.ts.map +1 -1
  117. package/dist/types/document-models/workflow/v1/gen/runtime/creators.d.ts.map +1 -1
  118. package/dist/types/document-models/workflow/v1/gen/schema/zod.d.ts.map +1 -1
  119. package/dist/types/document-models/workflow/v1/gen/steps/creators.d.ts.map +1 -1
  120. package/dist/types/document-models/workflow/v1/gen/steps/error.d.ts.map +1 -1
  121. package/dist/types/document-models/workflow/v1/gen/trigger/creators.d.ts.map +1 -1
  122. package/dist/types/document-models/workflow/v1/gen/trigger/error.d.ts.map +1 -1
  123. package/dist/types/document-models/workflow/v1/gen/variables/creators.d.ts.map +1 -1
  124. package/dist/types/document-models/workflow/v1/gen/variables/error.d.ts.map +1 -1
  125. package/dist/types/document-models/workflow/v1/gen/workflow/creators.d.ts.map +1 -1
  126. package/dist/types/document-models/workflow/v1/module.d.ts +9 -13
  127. package/dist/types/document-models/workflow/v1/module.d.ts.map +1 -1
  128. package/dist/types/document-models/workflow/v1/tests/document-model.test.d.ts +0 -8
  129. package/dist/types/document-models/workflow/v1/tests/document-model.test.d.ts.map +1 -1
  130. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts +2 -0
  131. package/dist/types/editors/connection-editor/ConnectionToolbar.d.ts.map +1 -1
  132. package/dist/types/editors/connection-editor/UsedBy.d.ts +6 -0
  133. package/dist/types/editors/connection-editor/UsedBy.d.ts.map +1 -0
  134. package/dist/types/editors/connection-editor/connection-callbacks.d.ts.map +1 -1
  135. package/dist/types/editors/connection-editor/connection-callbacks.test.d.ts +2 -0
  136. package/dist/types/editors/connection-editor/connection-callbacks.test.d.ts.map +1 -0
  137. package/dist/types/editors/connection-editor/connection-form.d.ts +5 -1
  138. package/dist/types/editors/connection-editor/connection-form.d.ts.map +1 -1
  139. package/dist/types/editors/connection-editor/connection-usage.d.ts.map +1 -0
  140. package/dist/types/editors/connection-editor/connection-usage.test.d.ts.map +1 -0
  141. package/dist/types/editors/connection-editor/editor.d.ts.map +1 -1
  142. package/dist/types/editors/connection-editor/piece-auth.d.ts +2 -0
  143. package/dist/types/editors/connection-editor/piece-auth.d.ts.map +1 -1
  144. package/dist/types/editors/connection-editor/status.d.ts +3 -1
  145. package/dist/types/editors/connection-editor/status.d.ts.map +1 -1
  146. package/dist/types/editors/shared/DocumentErrorBoundary.d.ts.map +1 -1
  147. package/dist/types/editors/shared/controls.d.ts +98 -0
  148. package/dist/types/editors/shared/controls.d.ts.map +1 -0
  149. package/dist/types/editors/shared/data-tree.d.ts +5 -0
  150. package/dist/types/editors/shared/data-tree.d.ts.map +1 -0
  151. package/dist/types/editors/shared/data-viewer.d.ts +7 -0
  152. package/dist/types/editors/shared/data-viewer.d.ts.map +1 -0
  153. package/dist/types/editors/shared/editor-chrome.d.ts +7 -0
  154. package/dist/types/editors/shared/editor-chrome.d.ts.map +1 -0
  155. package/dist/types/editors/shared/icons.d.ts +36 -0
  156. package/dist/types/editors/shared/icons.d.ts.map +1 -0
  157. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  158. package/dist/types/editors/workflow-editor/runtime-api.d.ts +2 -0
  159. package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -1
  160. package/dist/types/editors/workflow-editor/ui/ActionListEditor.d.ts.map +1 -1
  161. package/dist/types/editors/workflow-editor/ui/Autocomplete.d.ts +1 -0
  162. package/dist/types/editors/workflow-editor/ui/Autocomplete.d.ts.map +1 -1
  163. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts +1 -0
  164. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
  165. package/dist/types/editors/workflow-editor/ui/ConnectionField.d.ts.map +1 -1
  166. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts +1 -1
  167. package/dist/types/editors/workflow-editor/ui/CreateConnectionModal.d.ts.map +1 -1
  168. package/dist/types/editors/workflow-editor/ui/ExpressionPicker.d.ts.map +1 -1
  169. package/dist/types/editors/workflow-editor/ui/PieceMarkdown.d.ts.map +1 -1
  170. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
  171. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts +5 -0
  172. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts.map +1 -0
  173. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts +1 -0
  174. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
  175. package/dist/types/editors/workflow-editor/ui/WorkflowCanvas.d.ts.map +1 -1
  176. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts +3 -0
  177. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
  178. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts.map +1 -1
  179. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts +1 -0
  180. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts.map +1 -1
  181. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -1
  182. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts +6 -0
  183. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
  184. package/dist/types/editors/workflow-editor/ui/connection-create.d.ts +1 -1
  185. package/dist/types/editors/workflow-editor/ui/connection-create.d.ts.map +1 -1
  186. package/dist/types/editors/workflow-editor/ui/forms.d.ts +14 -0
  187. package/dist/types/editors/workflow-editor/ui/forms.d.ts.map +1 -1
  188. package/dist/types/editors/workflow-editor/ui/model.test.d.ts +2 -0
  189. package/dist/types/editors/workflow-editor/ui/model.test.d.ts.map +1 -0
  190. package/dist/types/editors/workflow-editor/ui/schedule-draft.d.ts +35 -0
  191. package/dist/types/editors/workflow-editor/ui/schedule-draft.d.ts.map +1 -0
  192. package/dist/types/editors/workflow-editor/ui/schedule-draft.test.d.ts +2 -0
  193. package/dist/types/editors/workflow-editor/ui/schedule-draft.test.d.ts.map +1 -0
  194. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts +9 -0
  195. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts.map +1 -0
  196. package/dist/types/editors/workflow-editor/ui/trigger-text.test.d.ts +2 -0
  197. package/dist/types/editors/workflow-editor/ui/trigger-text.test.d.ts.map +1 -0
  198. package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -1
  199. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts +2 -0
  200. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
  201. package/dist/types/editors/workflow-studio/components/RunsTable.test.d.ts +2 -0
  202. package/dist/types/editors/workflow-studio/components/RunsTable.test.d.ts.map +1 -0
  203. package/dist/types/editors/workflow-studio/components/RunsView.d.ts.map +1 -1
  204. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts +1 -1
  205. package/dist/types/editors/workflow-studio/components/Sidebar.d.ts.map +1 -1
  206. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts +8 -0
  207. package/dist/types/editors/workflow-studio/components/WorkflowBoard.d.ts.map +1 -0
  208. package/dist/types/editors/workflow-studio/components/WorkflowHeader.d.ts.map +1 -1
  209. package/dist/types/editors/workflow-studio/components/WorkflowSteps.d.ts.map +1 -1
  210. package/dist/types/editors/workflow-studio/components/WorkflowStudio.d.ts.map +1 -1
  211. package/dist/types/editors/workflow-studio/components/chain.d.ts +18 -0
  212. package/dist/types/editors/workflow-studio/components/chain.d.ts.map +1 -0
  213. package/dist/types/editors/workflow-studio/components/run-format.d.ts +29 -6
  214. package/dist/types/editors/workflow-studio/components/run-format.d.ts.map +1 -1
  215. package/dist/types/editors/workflow-studio/components/run-format.test.d.ts +2 -0
  216. package/dist/types/editors/workflow-studio/components/run-format.test.d.ts.map +1 -0
  217. package/dist/types/editors/workflow-studio/components/run-timeline.test.d.ts +2 -0
  218. package/dist/types/editors/workflow-studio/components/run-timeline.test.d.ts.map +1 -0
  219. package/dist/types/editors/workflow-studio/components/ui.d.ts +20 -0
  220. package/dist/types/editors/workflow-studio/components/ui.d.ts.map +1 -0
  221. package/dist/types/editors/workflow-studio/components/useRuns.d.ts +1 -1
  222. package/dist/types/editors/workflow-studio/components/useRuns.d.ts.map +1 -1
  223. package/dist/types/pieces/index.d.ts.map +1 -1
  224. package/dist/types/pieces/reactor/index.d.ts.map +1 -1
  225. package/dist/types/pieces/reactor/lib/reactor.d.ts.map +1 -1
  226. package/dist/types/pieces/reactor/lib/triggers/document-event.d.ts +12 -12
  227. package/dist/types/playwright.config.d.ts +3 -0
  228. package/dist/types/playwright.config.d.ts.map +1 -0
  229. package/dist/types/scripts/ui-shots.d.ts +2 -0
  230. package/dist/types/scripts/ui-shots.d.ts.map +1 -0
  231. package/dist/types/scripts/ui-stack.d.ts +77 -0
  232. package/dist/types/scripts/ui-stack.d.ts.map +1 -0
  233. package/dist/types/test/ui/connection-editor.spec.d.ts +2 -0
  234. package/dist/types/test/ui/connection-editor.spec.d.ts.map +1 -0
  235. package/dist/types/test/ui/data-viewer.spec.d.ts +2 -0
  236. package/dist/types/test/ui/data-viewer.spec.d.ts.map +1 -0
  237. package/dist/types/test/ui/fixtures.d.ts +9 -0
  238. package/dist/types/test/ui/fixtures.d.ts.map +1 -0
  239. package/dist/types/test/ui/global-setup.d.ts +2 -0
  240. package/dist/types/test/ui/global-setup.d.ts.map +1 -0
  241. package/dist/types/test/ui/pieces.spec.d.ts +2 -0
  242. package/dist/types/test/ui/pieces.spec.d.ts.map +1 -0
  243. package/dist/types/test/ui/step-panel.spec.d.ts +2 -0
  244. package/dist/types/test/ui/step-panel.spec.d.ts.map +1 -0
  245. package/dist/types/test/ui/studio.spec.d.ts +2 -0
  246. package/dist/types/test/ui/studio.spec.d.ts.map +1 -0
  247. package/dist/types/vitest.config.d.ts.map +1 -1
  248. package/package.json +18 -12
  249. package/dist/browser/PieceMarkdown-CZYNY1qQ.js.map +0 -1
  250. package/dist/browser/ap-layout-BpKqIHQt.js +0 -337
  251. package/dist/browser/ap-layout-BpKqIHQt.js.map +0 -1
  252. package/dist/browser/connection-form-B1SkwNgY.js +0 -453
  253. package/dist/browser/connection-form-B1SkwNgY.js.map +0 -1
  254. package/dist/browser/editor-CCKpl-Gd.js +0 -1550
  255. package/dist/browser/editor-CCKpl-Gd.js.map +0 -1
  256. package/dist/browser/editor-CIZRPdKM.js +0 -134
  257. package/dist/browser/editor-CIZRPdKM.js.map +0 -1
  258. package/dist/browser/editor-D0sdUxJa.js.map +0 -1
  259. package/dist/browser/runtime-api-DKlnn45K.js.map +0 -1
  260. package/dist/browser/status-kpDX5CIA.js +0 -11
  261. package/dist/browser/status-kpDX5CIA.js.map +0 -1
  262. package/dist/browser/upgrade-manifests-Cnpfo6kC.js +0 -8
  263. package/dist/browser/use-runtime-url-By5q3sa_.js +0 -174
  264. package/dist/browser/use-runtime-url-By5q3sa_.js.map +0 -1
  265. package/dist/node/PieceMarkdown-D9nI2gI2.mjs.map +0 -1
  266. package/dist/node/ap-layout-Dzhi9JFC.mjs +0 -337
  267. package/dist/node/ap-layout-Dzhi9JFC.mjs.map +0 -1
  268. package/dist/node/connection-form-DejaNF09.mjs +0 -453
  269. package/dist/node/connection-form-DejaNF09.mjs.map +0 -1
  270. package/dist/node/editor-DfFRZS9L.mjs +0 -134
  271. package/dist/node/editor-DfFRZS9L.mjs.map +0 -1
  272. package/dist/node/editor-NbAB78He.mjs +0 -1550
  273. package/dist/node/editor-NbAB78He.mjs.map +0 -1
  274. package/dist/node/editor-sVzt1o51.mjs.map +0 -1
  275. package/dist/node/runtime-api-CtvvFHut.mjs.map +0 -1
  276. package/dist/node/status-CDRcDUMS.mjs +0 -11
  277. package/dist/node/status-CDRcDUMS.mjs.map +0 -1
  278. package/dist/node/upgrade-manifests-3VN0Bfcf.mjs +0 -8
  279. package/dist/node/use-runtime-url-BbFEkaZy.mjs +0 -174
  280. package/dist/node/use-runtime-url-BbFEkaZy.mjs.map +0 -1
  281. package/dist/types/document-models/connection/v1/tests/config.test.d.ts +0 -2
  282. package/dist/types/document-models/connection/v1/tests/config.test.d.ts.map +0 -1
  283. package/dist/types/document-models/connection/v1/tests/connection.test.d.ts +0 -2
  284. package/dist/types/document-models/connection/v1/tests/connection.test.d.ts.map +0 -1
  285. package/dist/types/document-models/connection/v1/tests/health.test.d.ts +0 -2
  286. package/dist/types/document-models/connection/v1/tests/health.test.d.ts.map +0 -1
  287. package/dist/types/document-models/workflow/v1/tests/edges.test.d.ts +0 -2
  288. package/dist/types/document-models/workflow/v1/tests/edges.test.d.ts.map +0 -1
  289. package/dist/types/document-models/workflow/v1/tests/policy.test.d.ts +0 -2
  290. package/dist/types/document-models/workflow/v1/tests/policy.test.d.ts.map +0 -1
  291. package/dist/types/document-models/workflow/v1/tests/runtime.test.d.ts +0 -2
  292. package/dist/types/document-models/workflow/v1/tests/runtime.test.d.ts.map +0 -1
  293. package/dist/types/document-models/workflow/v1/tests/steps.test.d.ts +0 -2
  294. package/dist/types/document-models/workflow/v1/tests/steps.test.d.ts.map +0 -1
  295. package/dist/types/document-models/workflow/v1/tests/trigger.test.d.ts +0 -2
  296. package/dist/types/document-models/workflow/v1/tests/trigger.test.d.ts.map +0 -1
  297. package/dist/types/document-models/workflow/v1/tests/variables.test.d.ts +0 -2
  298. package/dist/types/document-models/workflow/v1/tests/variables.test.d.ts.map +0 -1
  299. package/dist/types/document-models/workflow/v1/tests/workflow.test.d.ts +0 -2
  300. package/dist/types/document-models/workflow/v1/tests/workflow.test.d.ts.map +0 -1
  301. package/dist/types/editors/workflow-studio/components/ConnectionView.d.ts +0 -7
  302. package/dist/types/editors/workflow-studio/components/ConnectionView.d.ts.map +0 -1
  303. package/dist/types/editors/workflow-studio/components/EditorToolbar.d.ts +0 -8
  304. package/dist/types/editors/workflow-studio/components/EditorToolbar.d.ts.map +0 -1
  305. package/dist/types/editors/workflow-studio/components/connection-usage.d.ts.map +0 -1
  306. package/dist/types/editors/workflow-studio/components/connection-usage.test.d.ts.map +0 -1
  307. /package/dist/types/editors/{workflow-studio/components → connection-editor}/connection-usage.d.ts +0 -0
  308. /package/dist/types/editors/{workflow-studio/components → connection-editor}/connection-usage.test.d.ts +0 -0
@@ -0,0 +1,1355 @@
1
+ import { y as setRuntimeUrl } from "./runtime-api-xwvg5PzA.js";
2
+ import { DEFAULT_SWITCHBOARD_URL, parseDriveUrl, subgraphUrlFromGraphqlUrl, useDefaultDrivesUrl, useSelectedDriveSafe, useSyncList } from "@powerhousedao/reactor-browser";
3
+ import { Component, Fragment, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
+ import { DOCUMENT_SCOPE_ACTION_TYPES } from "@powerhousedao/shared/document-model";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+ import { createPortal } from "react-dom";
7
+ new Set([...DOCUMENT_SCOPE_ACTION_TYPES].filter((type) => type !== "CREATE_DOCUMENT"));
8
+ const DRIVE_COLLECTION_PREFIX = "drive.";
9
+ /**
10
+ * Identifies the collection a remote synchronizes. Collections are drive-level
11
+ * abstractions (document-drive and reactor-drive), so a collection id is the
12
+ * drive document id plus the branch it scopes to rather than an opaque string.
13
+ *
14
+ * The canonical string form (`drive.${branch}.${driveId}`) is produced only by
15
+ * `key` and parsed only by `fromKey`; that string is the wire and storage
16
+ * representation and is byte-for-byte identical to the legacy
17
+ * `driveCollectionId(branch, driveId)` output, so existing `document_collections`
18
+ * rows and persisted remotes remain valid without migration.
19
+ */
20
+ var DriveCollectionId = class DriveCollectionId {
21
+ driveId;
22
+ branch;
23
+ constructor(driveId, branch) {
24
+ this.driveId = driveId;
25
+ this.branch = branch;
26
+ }
27
+ static forDrive(driveId, branch = "main") {
28
+ return new DriveCollectionId(driveId, branch);
29
+ }
30
+ /**
31
+ * The single deserializer for the wire/storage form. `branch` may contain
32
+ * dots, while `driveId` is a dot-free document id, so the drive id is the
33
+ * final dot-delimited segment.
34
+ */
35
+ static fromKey(key) {
36
+ if (!key.startsWith(DRIVE_COLLECTION_PREFIX)) throw new Error(`Unsupported collection id: ${key}`);
37
+ const rest = key.slice(6);
38
+ const lastDot = rest.lastIndexOf(".");
39
+ if (lastDot === -1 || lastDot === rest.length - 1) throw new Error(`Malformed drive collection id: ${key}`);
40
+ return new DriveCollectionId(rest.slice(lastDot + 1), rest.slice(0, lastDot));
41
+ }
42
+ get key() {
43
+ return `${DRIVE_COLLECTION_PREFIX}${this.branch}.${this.driveId}`;
44
+ }
45
+ toString() {
46
+ return this.key;
47
+ }
48
+ equals(other) {
49
+ return this.driveId === other.driveId && this.branch === other.branch;
50
+ }
51
+ };
52
+ //#endregion
53
+ //#region editors/shared/DocumentErrorBoundary.tsx
54
+ /** Best-effort message for anything thrown, without stringifying an object. */
55
+ function errorMessage(error) {
56
+ if (error instanceof Error) return error.message;
57
+ if (typeof error === "string") return error;
58
+ return "Unknown error";
59
+ }
60
+ /** Inline "could not load" panel, also used for hook-level (non-thrown) failures. */
61
+ function DocumentLoadError(props) {
62
+ return /* @__PURE__ */ jsxs("div", {
63
+ className: "m-3 rounded border border-solid border-wf-fail/40 bg-wf-fail/10 p-3",
64
+ children: [
65
+ /* @__PURE__ */ jsx("p", {
66
+ className: "text-sm font-medium text-wf-fail",
67
+ children: props.title ?? "This document could not be loaded"
68
+ }),
69
+ props.label ? /* @__PURE__ */ jsx("p", {
70
+ className: "mt-0.5 text-xs text-wf-fail",
71
+ children: props.label
72
+ }) : null,
73
+ props.documentId ? /* @__PURE__ */ jsx("p", {
74
+ className: "mt-0.5 font-mono text-[11px] text-wf-fail",
75
+ children: props.documentId
76
+ }) : null,
77
+ /* @__PURE__ */ jsx("p", {
78
+ className: "mt-1 text-xs text-muted-foreground",
79
+ children: errorMessage(props.error)
80
+ }),
81
+ /* @__PURE__ */ jsxs("div", {
82
+ className: "mt-2 flex gap-2",
83
+ children: [props.onRetry ? /* @__PURE__ */ jsx("button", {
84
+ type: "button",
85
+ className: "rounded border border-solid border-wf-fail/40 px-2 py-0.5 text-xs font-medium text-wf-fail",
86
+ onClick: props.onRetry,
87
+ children: "Retry"
88
+ }) : null, props.onDismiss ? /* @__PURE__ */ jsx("button", {
89
+ type: "button",
90
+ className: "rounded border border-solid border-foreground/15 px-2 py-0.5 text-xs text-muted-foreground",
91
+ onClick: props.onDismiss,
92
+ children: "Dismiss"
93
+ }) : null]
94
+ })
95
+ ]
96
+ });
97
+ }
98
+ var DocumentErrorBoundary = class extends Component {
99
+ state = {
100
+ error: void 0,
101
+ attempt: 0
102
+ };
103
+ static getDerivedStateFromError(error) {
104
+ return { error };
105
+ }
106
+ componentDidCatch(error, info) {
107
+ console.error(`Failed to render document ${this.props.documentId ?? "(unknown id)"}:`, error, info.componentStack);
108
+ }
109
+ retry = () => {
110
+ this.setState((state) => ({
111
+ error: void 0,
112
+ attempt: state.attempt + 1
113
+ }));
114
+ };
115
+ dismiss = () => {
116
+ this.setState({ error: void 0 });
117
+ this.props.onDismiss?.();
118
+ };
119
+ render() {
120
+ if (this.state.error !== void 0) return /* @__PURE__ */ jsx(DocumentLoadError, {
121
+ label: this.props.label,
122
+ documentId: this.props.documentId,
123
+ error: this.state.error,
124
+ onRetry: this.retry,
125
+ onDismiss: this.props.onDismiss ? this.dismiss : void 0
126
+ });
127
+ return /* @__PURE__ */ jsx(Fragment, { children: this.props.children }, this.state.attempt);
128
+ }
129
+ };
130
+ //#endregion
131
+ //#region editors/shared/icons.tsx
132
+ const ICON_PATHS = {
133
+ pencil: "M4 20h4L19 9l-4-4L4 16v4zM14 6l4 4",
134
+ trash: "M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3",
135
+ plus: "M12 5v14M5 12h14",
136
+ list: "M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01",
137
+ play: "M7 5v14l12-7z",
138
+ chevron: "M9 6l6 6-6 6",
139
+ chevronDown: "M6 9l6 6 6-6",
140
+ retry: "M4 12a8 8 0 1 0 2.3-5.7M4 4v4h4",
141
+ back: "M15 6l-6 6 6 6",
142
+ close: "M6 6l12 12M18 6L6 18",
143
+ check: "M5 12l5 5 9-10",
144
+ search: "M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4",
145
+ braces: "M8 4c-2 0-3 1-3 3v2c0 1.5-1 3-2 3 1 0 2 1.5 2 3v2c0 2 1 3 3 3M16 4c2 0 3 1 3 3v2c0 1.5 1 3 2 3-1 0-2 1.5-2 3v2c0 2-1 3-3 3",
146
+ link: "M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",
147
+ arrowRight: "M5 12h14M13 6l6 6-6 6",
148
+ alert: "M12 8v5M12 16.5v.01M10.3 4l-7.6 13.2A2 2 0 0 0 4.4 20h15.2a2 2 0 0 0 1.7-2.8L13.7 4a2 2 0 0 0-3.4 0z",
149
+ copy: "M9 9h10v10H9zM5 15V5h10",
150
+ sliders: "M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4",
151
+ eye: "M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12zM12 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5z",
152
+ eyeOff: "M3 3l18 18M10.6 5.6A10 10 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a17 17 0 0 1-3 3.7M6.6 6.6C4 8.3 2.5 12 2.5 12s3.5 6.5 9.5 6.5a9.6 9.6 0 0 0 4.4-1M9.9 9.9a3 3 0 0 0 4.2 4.2",
153
+ undo: "M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",
154
+ redo: "M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",
155
+ clock: "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2",
156
+ bolt: "M13 3L5 13h6l-1 8 8-10h-6l1-8z",
157
+ branch: "M6 4v10M6 14a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 4a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 10c0 4-6 3-11 6",
158
+ lock: "M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3M12 15v2"
159
+ };
160
+ function Icon(props) {
161
+ return /* @__PURE__ */ jsx("svg", {
162
+ "aria-hidden": true,
163
+ viewBox: "0 0 24 24",
164
+ fill: "none",
165
+ stroke: "currentColor",
166
+ strokeWidth: 1.75,
167
+ strokeLinecap: "round",
168
+ strokeLinejoin: "round",
169
+ width: props.size,
170
+ height: props.size,
171
+ className: `shrink-0 ${props.size ? "" : "h-4 w-4"} ${props.className ?? ""}`,
172
+ children: /* @__PURE__ */ jsx("path", { d: ICON_PATHS[props.name] })
173
+ });
174
+ }
175
+ //#endregion
176
+ //#region editors/shared/controls.tsx
177
+ const FOCUS_RING = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40";
178
+ const BUTTON_SIZE = {
179
+ sm: "h-7 gap-1 rounded-md px-2 text-xs",
180
+ md: "h-8 gap-1.5 rounded-md px-3 text-[13px]"
181
+ };
182
+ const BUTTON_VARIANT = {
183
+ primary: "bg-primary text-primary-foreground hover:opacity-90",
184
+ secondary: "border border-solid border-foreground/15 bg-card text-foreground hover:bg-accent",
185
+ ghost: "text-muted-foreground hover:bg-accent hover:text-foreground",
186
+ danger: "text-wf-fail hover:bg-wf-fail/10"
187
+ };
188
+ function Button(props) {
189
+ const { variant = "secondary", size = "md", className = "", ...rest } = props;
190
+ return /* @__PURE__ */ jsx("button", {
191
+ type: "button",
192
+ className: `inline-flex shrink-0 items-center font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING} ${BUTTON_SIZE[size]} ${BUTTON_VARIANT[variant]} ${className}`,
193
+ ...rest
194
+ });
195
+ }
196
+ function IconButton(props) {
197
+ const { icon, label, active, className = "", ...rest } = props;
198
+ return /* @__PURE__ */ jsx("button", {
199
+ type: "button",
200
+ title: label,
201
+ "aria-label": label,
202
+ className: `inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING} ${active ? "bg-wf-run/10 text-wf-run" : "text-muted-foreground hover:bg-accent hover:text-foreground"} ${className}`,
203
+ ...rest,
204
+ children: /* @__PURE__ */ jsx(Icon, {
205
+ name: icon,
206
+ className: "h-3.5 w-3.5"
207
+ })
208
+ });
209
+ }
210
+ const inputClass = "w-full rounded-md border border-solid border-foreground/15 bg-card px-2.5 text-[13px] text-foreground placeholder:text-muted-foreground/70 transition-colors hover:border-foreground/25 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25 disabled:cursor-not-allowed disabled:opacity-60";
211
+ const textInputClass = `${inputClass} h-9`;
212
+ const textAreaClass = `${inputClass} min-h-20 py-2 leading-relaxed`;
213
+ const invalidClass = "border-wf-warn/70 hover:border-wf-warn";
214
+ /** Label row above a control: name, optional marker, and a trailing action. */
215
+ function FieldLabel(props) {
216
+ const LabelTag = props.htmlFor ? "label" : "span";
217
+ return /* @__PURE__ */ jsxs("div", {
218
+ className: "mb-1.5 flex min-h-6 items-center justify-between gap-2",
219
+ children: [/* @__PURE__ */ jsxs(LabelTag, {
220
+ htmlFor: props.htmlFor,
221
+ className: "flex min-w-0 items-baseline gap-1.5 text-[13px] font-medium text-foreground",
222
+ children: [
223
+ /* @__PURE__ */ jsx("span", {
224
+ className: "truncate",
225
+ children: props.label
226
+ }),
227
+ props.optional ? /* @__PURE__ */ jsx("span", {
228
+ className: "shrink-0 text-xs font-normal text-muted-foreground",
229
+ children: "Optional"
230
+ }) : null,
231
+ props.needsValue ? /* @__PURE__ */ jsx("span", {
232
+ className: "shrink-0 text-xs font-normal text-wf-warn",
233
+ children: "Needs a value"
234
+ }) : null
235
+ ]
236
+ }), props.action ? /* @__PURE__ */ jsx("span", {
237
+ className: "flex shrink-0 items-center gap-0.5",
238
+ children: props.action
239
+ }) : null]
240
+ });
241
+ }
242
+ const LONG_HINT = 140;
243
+ /** Help text under a control; long piece descriptions fold to two lines. */
244
+ function Hint(props) {
245
+ const [open, setOpen] = useState(false);
246
+ const text = props.text;
247
+ if (text !== void 0) {
248
+ if (!text.trim()) return null;
249
+ const long = text.length > LONG_HINT;
250
+ return /* @__PURE__ */ jsxs("p", {
251
+ className: "mt-1.5 text-xs leading-relaxed text-muted-foreground",
252
+ children: [/* @__PURE__ */ jsx("span", {
253
+ className: long && !open ? "line-clamp-2" : void 0,
254
+ children: text
255
+ }), long ? /* @__PURE__ */ jsx("button", {
256
+ type: "button",
257
+ className: "mt-0.5 block font-medium text-foreground/70 hover:text-foreground",
258
+ onClick: () => setOpen((value) => !value),
259
+ children: open ? "Show less" : "Show more"
260
+ }) : null]
261
+ });
262
+ }
263
+ return /* @__PURE__ */ jsx("p", {
264
+ className: "mt-1.5 text-xs leading-relaxed text-muted-foreground",
265
+ children: props.children
266
+ });
267
+ }
268
+ function FieldError(props) {
269
+ if (!props.children) return null;
270
+ return /* @__PURE__ */ jsx("p", {
271
+ className: "mt-1.5 text-xs text-wf-fail",
272
+ children: props.children
273
+ });
274
+ }
275
+ function Switch(props) {
276
+ const id = useId();
277
+ return /* @__PURE__ */ jsxs("div", {
278
+ className: "flex items-start justify-between gap-4",
279
+ children: [/* @__PURE__ */ jsxs("label", {
280
+ htmlFor: id,
281
+ className: "min-w-0",
282
+ children: [/* @__PURE__ */ jsx("span", {
283
+ className: "block text-[13px] font-medium text-foreground",
284
+ children: props.label
285
+ }), props.description ? /* @__PURE__ */ jsx(Hint, { text: props.description }) : null]
286
+ }), /* @__PURE__ */ jsx("button", {
287
+ id,
288
+ type: "button",
289
+ role: "switch",
290
+ "aria-checked": props.checked,
291
+ disabled: props.disabled,
292
+ className: `relative mt-0.5 inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:opacity-50 ${FOCUS_RING} ${props.checked ? "bg-primary" : "bg-foreground/20"}`,
293
+ onClick: () => props.onChange(!props.checked),
294
+ children: /* @__PURE__ */ jsx("span", { className: `inline-block h-4 w-4 rounded-full bg-card shadow-sm transition-transform ${props.checked ? "translate-x-[18px]" : "translate-x-0.5"}` })
295
+ })]
296
+ });
297
+ }
298
+ function Tabs(props) {
299
+ return /* @__PURE__ */ jsx("div", {
300
+ role: "tablist",
301
+ className: "flex gap-4",
302
+ children: props.tabs.map((tab) => {
303
+ const selected = tab.value === props.value;
304
+ return /* @__PURE__ */ jsxs("button", {
305
+ type: "button",
306
+ role: "tab",
307
+ "aria-selected": selected,
308
+ className: `-mb-px flex items-center gap-1.5 border-b-2 border-solid pb-2 text-[13px] font-medium transition-colors ${FOCUS_RING} ${selected ? "border-foreground text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`,
309
+ onClick: () => props.onChange(tab.value),
310
+ children: [tab.label, tab.badge]
311
+ }, tab.value);
312
+ })
313
+ });
314
+ }
315
+ /** Two or three short, mutually exclusive choices shown side by side. */
316
+ function Segmented(props) {
317
+ return /* @__PURE__ */ jsx("div", {
318
+ role: "radiogroup",
319
+ className: `flex h-9 w-full items-center gap-0.5 rounded-md bg-muted p-0.5 ${props.invalid ? "ring-1 ring-wf-warn/60" : ""}`,
320
+ children: props.options.map((option) => {
321
+ const selected = option.value === props.value;
322
+ return /* @__PURE__ */ jsx("button", {
323
+ type: "button",
324
+ role: "radio",
325
+ "aria-checked": selected,
326
+ className: `h-8 min-w-0 flex-1 truncate rounded px-2 text-[13px] transition-colors ${FOCUS_RING} ${selected ? "bg-card font-medium text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
327
+ onClick: () => props.onChange(option.value),
328
+ children: option.label
329
+ }, option.value);
330
+ })
331
+ });
332
+ }
333
+ const SEARCH_THRESHOLD = 7;
334
+ function Select(props) {
335
+ const [open, setOpen] = useState(false);
336
+ const [query, setQuery] = useState("");
337
+ const [active, setActive] = useState(0);
338
+ const triggerRef = useRef(null);
339
+ const popoverRef = useRef(null);
340
+ const searchRef = useRef(null);
341
+ const listId = useId();
342
+ const [position, setPosition] = useState(null);
343
+ const selected = props.multiple ? props.value : props.value ? [props.value] : [];
344
+ const selectedSet = new Set(selected);
345
+ const searchable = props.options.length > SEARCH_THRESHOLD;
346
+ const needle = query.trim().toLowerCase();
347
+ const visible = useMemo(() => needle ? props.options.filter((option) => `${option.label} ${option.description ?? ""}`.toLowerCase().includes(needle)) : props.options, [needle, props.options]);
348
+ const close = () => {
349
+ setOpen(false);
350
+ setQuery("");
351
+ triggerRef.current?.focus();
352
+ };
353
+ const place = () => {
354
+ const rect = triggerRef.current?.getBoundingClientRect();
355
+ if (!rect) return;
356
+ const below = window.innerHeight - rect.bottom - 8;
357
+ const above = rect.top - 8;
358
+ const flip = below < 240 && above > below;
359
+ setPosition({
360
+ left: rect.left,
361
+ width: rect.width,
362
+ top: flip ? void 0 : rect.bottom + 4,
363
+ bottom: flip ? window.innerHeight - rect.top + 4 : void 0,
364
+ maxHeight: Math.min(320, flip ? above : below)
365
+ });
366
+ };
367
+ const openList = () => {
368
+ const index = props.options.findIndex((option) => selectedSet.has(option.value));
369
+ setActive(Math.max(0, index));
370
+ setOpen(true);
371
+ };
372
+ useLayoutEffect(() => {
373
+ if (!open) return;
374
+ place();
375
+ }, [open]);
376
+ const placed = position !== null;
377
+ useEffect(() => {
378
+ if (open && placed && searchable) searchRef.current?.focus();
379
+ }, [
380
+ open,
381
+ placed,
382
+ searchable
383
+ ]);
384
+ useEffect(() => {
385
+ if (!open) return;
386
+ const onPointer = (event) => {
387
+ const target = event.target;
388
+ if (!popoverRef.current?.contains(target) && !triggerRef.current?.contains(target)) {
389
+ setOpen(false);
390
+ setQuery("");
391
+ }
392
+ };
393
+ window.addEventListener("mousedown", onPointer);
394
+ window.addEventListener("resize", place);
395
+ window.addEventListener("scroll", place, true);
396
+ return () => {
397
+ window.removeEventListener("mousedown", onPointer);
398
+ window.removeEventListener("resize", place);
399
+ window.removeEventListener("scroll", place, true);
400
+ };
401
+ }, [open, searchable]);
402
+ useEffect(() => {
403
+ popoverRef.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: "nearest" });
404
+ }, [active]);
405
+ const choose = (option) => {
406
+ if (option.disabled) return;
407
+ if (props.multiple) {
408
+ props.onChange(selectedSet.has(option.value) ? props.value.filter((value) => value !== option.value) : [...props.value, option.value]);
409
+ return;
410
+ }
411
+ props.onChange(option.value);
412
+ close();
413
+ };
414
+ const onListKey = (event) => {
415
+ if (event.key === "ArrowDown") {
416
+ event.preventDefault();
417
+ setActive((index) => Math.min(visible.length - 1, index + 1));
418
+ } else if (event.key === "ArrowUp") {
419
+ event.preventDefault();
420
+ setActive((index) => Math.max(0, index - 1));
421
+ } else if (event.key === "Enter") {
422
+ event.preventDefault();
423
+ const option = visible[active];
424
+ if (option) choose(option);
425
+ } else if (event.key === "Escape") {
426
+ event.preventDefault();
427
+ close();
428
+ } else if (event.key === "Tab") {
429
+ setOpen(false);
430
+ setQuery("");
431
+ }
432
+ };
433
+ const labels = props.options.filter((option) => selectedSet.has(option.value)).map((option) => option.label);
434
+ const unknown = selected.filter((value) => !props.options.some((option) => option.value === value));
435
+ const shown = [...labels, ...unknown];
436
+ const selectedIcon = props.multiple ? void 0 : props.options.find((option) => option.value === props.value)?.icon;
437
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("button", {
438
+ ref: triggerRef,
439
+ id: props.id,
440
+ type: "button",
441
+ role: "combobox",
442
+ "aria-expanded": open,
443
+ "aria-controls": open ? listId : void 0,
444
+ "aria-activedescendant": open && visible.length > 0 ? `${listId}-${active}` : void 0,
445
+ "aria-haspopup": "listbox",
446
+ disabled: props.disabled,
447
+ className: `${textInputClass} flex items-center gap-2 text-left ${props.invalid ? invalidClass : ""} ${open ? "border-ring ring-2 ring-ring/25" : ""}`,
448
+ onClick: () => open ? close() : openList(),
449
+ onKeyDown: (event) => {
450
+ if (open) {
451
+ onListKey(event);
452
+ return;
453
+ }
454
+ if (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") {
455
+ event.preventDefault();
456
+ openList();
457
+ }
458
+ },
459
+ children: [
460
+ selectedIcon,
461
+ /* @__PURE__ */ jsx("span", {
462
+ className: `min-w-0 flex-1 truncate ${shown.length ? "" : "text-muted-foreground/70"}`,
463
+ children: shown.length > 0 ? shown.join(", ") : props.loading ? "Loading…" : props.placeholder ?? "Choose…"
464
+ }),
465
+ props.multiple && shown.length > 1 ? /* @__PURE__ */ jsx("span", {
466
+ className: "shrink-0 rounded bg-muted px-1.5 text-[11px] tabular-nums text-muted-foreground",
467
+ children: shown.length
468
+ }) : null,
469
+ /* @__PURE__ */ jsx(Icon, {
470
+ name: "chevronDown",
471
+ className: `h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? "rotate-180" : ""}`
472
+ })
473
+ ]
474
+ }), open && position ? createPortal(/* @__PURE__ */ jsxs("div", {
475
+ ref: popoverRef,
476
+ tabIndex: -1,
477
+ className: "workflow-select-popover fixed flex flex-col overflow-hidden rounded-lg border border-solid border-foreground/10 bg-popover text-popover-foreground shadow-lg outline-none",
478
+ style: {
479
+ left: position.left,
480
+ width: Math.max(position.width, 220),
481
+ top: position.top,
482
+ bottom: position.bottom,
483
+ maxHeight: position.maxHeight
484
+ },
485
+ onKeyDown: onListKey,
486
+ children: [
487
+ searchable || props.onRefresh ? /* @__PURE__ */ jsxs("div", {
488
+ className: "flex items-center gap-1 border-b border-solid border-foreground/10 px-2",
489
+ children: [searchable ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Icon, {
490
+ name: "search",
491
+ className: "h-3.5 w-3.5 text-muted-foreground"
492
+ }), /* @__PURE__ */ jsx("input", {
493
+ ref: searchRef,
494
+ className: "h-9 min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground/70 focus:outline-none",
495
+ placeholder: "Search",
496
+ value: query,
497
+ onChange: (event) => {
498
+ setQuery(event.target.value);
499
+ setActive(0);
500
+ }
501
+ })] }) : /* @__PURE__ */ jsx("span", { className: "h-9 flex-1" }), props.onRefresh ? /* @__PURE__ */ jsx(IconButton, {
502
+ icon: "retry",
503
+ label: "Reload options",
504
+ disabled: props.loading,
505
+ onClick: props.onRefresh
506
+ }) : null]
507
+ }) : null,
508
+ /* @__PURE__ */ jsx("div", {
509
+ id: listId,
510
+ role: "listbox",
511
+ "aria-multiselectable": props.multiple || void 0,
512
+ className: "min-h-0 flex-1 overflow-y-auto p-1",
513
+ children: props.loading && props.options.length === 0 ? /* @__PURE__ */ jsx("p", {
514
+ className: "px-2 py-2 text-[13px] text-muted-foreground",
515
+ children: "Loading options…"
516
+ }) : visible.length === 0 ? /* @__PURE__ */ jsx("p", {
517
+ className: "px-2 py-2 text-[13px] text-muted-foreground",
518
+ children: needle ? "Nothing matches." : props.emptyText ?? "No options."
519
+ }) : visible.map((option, index) => {
520
+ const isSelected = selectedSet.has(option.value);
521
+ return /* @__PURE__ */ jsxs("div", {
522
+ id: `${listId}-${index}`,
523
+ role: "option",
524
+ "aria-selected": isSelected,
525
+ "aria-disabled": option.disabled || void 0,
526
+ "data-index": index,
527
+ className: `flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-[13px] ${index === active ? "bg-accent" : ""} ${option.disabled ? "cursor-not-allowed opacity-50" : ""}`,
528
+ onMouseEnter: () => setActive(index),
529
+ onMouseDown: (event) => {
530
+ event.preventDefault();
531
+ choose(option);
532
+ },
533
+ children: [
534
+ props.multiple ? /* @__PURE__ */ jsx("span", {
535
+ className: `flex h-4 w-4 shrink-0 items-center justify-center rounded border border-solid ${isSelected ? "border-primary bg-primary text-primary-foreground" : "border-foreground/25"}`,
536
+ children: isSelected ? /* @__PURE__ */ jsx(Icon, {
537
+ name: "check",
538
+ className: "h-3 w-3"
539
+ }) : null
540
+ }) : null,
541
+ option.icon,
542
+ /* @__PURE__ */ jsxs("span", {
543
+ className: "min-w-0 flex-1",
544
+ children: [/* @__PURE__ */ jsx("span", {
545
+ className: "block truncate",
546
+ children: option.label
547
+ }), option.description ? /* @__PURE__ */ jsx("span", {
548
+ className: "block truncate text-xs text-muted-foreground",
549
+ children: option.description
550
+ }) : null]
551
+ }),
552
+ !props.multiple && isSelected ? /* @__PURE__ */ jsx(Icon, {
553
+ name: "check",
554
+ className: "h-3.5 w-3.5 text-foreground"
555
+ }) : null
556
+ ]
557
+ }, option.value);
558
+ })
559
+ }),
560
+ !props.multiple && props.clearable && props.value ? /* @__PURE__ */ jsx("div", {
561
+ className: "border-t border-solid border-foreground/10 p-1",
562
+ children: /* @__PURE__ */ jsxs("button", {
563
+ type: "button",
564
+ className: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground",
565
+ onMouseDown: (event) => {
566
+ event.preventDefault();
567
+ props.onChange("");
568
+ close();
569
+ },
570
+ children: [/* @__PURE__ */ jsx(Icon, {
571
+ name: "close",
572
+ className: "h-3.5 w-3.5"
573
+ }), "Clear selection"]
574
+ })
575
+ }) : null
576
+ ]
577
+ }), document.body) : null] });
578
+ }
579
+ //#endregion
580
+ //#region editors/workflow-editor/use-runtime-url.ts
581
+ const SUBGRAPH_NAME = "workflow-runtime";
582
+ function baseFromChannelUrl(channelUrl) {
583
+ try {
584
+ const url = new URL(channelUrl);
585
+ url.search = "";
586
+ url.hash = "";
587
+ url.pathname = url.pathname.replace(/\/r\/?$/, "");
588
+ return url.toString();
589
+ } catch {
590
+ return;
591
+ }
592
+ }
593
+ function useWorkflowRuntimeUrl() {
594
+ const [drive] = useSelectedDriveSafe();
595
+ const remotes = useSyncList();
596
+ const defaultDrivesUrl = useDefaultDrivesUrl();
597
+ const driveId = drive?.header.id;
598
+ return useMemo(() => {
599
+ let base;
600
+ if (driveId) {
601
+ const channelUrl = (remotes.find((entry) => entry.meta.collectionId.equals(DriveCollectionId.forDrive(driveId)))?.channel)?.config.url;
602
+ if (typeof channelUrl === "string") base = baseFromChannelUrl(channelUrl);
603
+ }
604
+ if (!base && defaultDrivesUrl) try {
605
+ base = parseDriveUrl(defaultDrivesUrl).graphqlEndpoint.replace(/\/r$/, "");
606
+ } catch {}
607
+ return subgraphUrlFromGraphqlUrl(base ?? DEFAULT_SWITCHBOARD_URL, SUBGRAPH_NAME);
608
+ }, [
609
+ driveId,
610
+ remotes,
611
+ defaultDrivesUrl
612
+ ]);
613
+ }
614
+ function useSyncWorkflowRuntimeUrl() {
615
+ const url = useWorkflowRuntimeUrl();
616
+ useEffect(() => {
617
+ setRuntimeUrl(url);
618
+ }, [url]);
619
+ }
620
+ //#endregion
621
+ //#region editors/workflow-studio/components/run-format.ts
622
+ const RUN_STATUSES = [
623
+ "RUNNING",
624
+ "SUCCEEDED",
625
+ "FAILED"
626
+ ];
627
+ const TONE_TEXT = {
628
+ ok: "text-wf-ok",
629
+ fail: "text-wf-fail",
630
+ warn: "text-wf-warn",
631
+ run: "text-wf-run",
632
+ idle: "text-muted-foreground"
633
+ };
634
+ const TONE_DOT = {
635
+ ok: "bg-wf-ok",
636
+ fail: "bg-wf-fail",
637
+ warn: "bg-wf-warn",
638
+ run: "bg-wf-run",
639
+ idle: "bg-muted-foreground/40"
640
+ };
641
+ const TONE_BADGE = {
642
+ ok: "bg-wf-ok/12 text-wf-ok",
643
+ fail: "bg-wf-fail/12 text-wf-fail",
644
+ warn: "bg-wf-warn/12 text-wf-warn",
645
+ run: "bg-wf-run/12 text-wf-run",
646
+ idle: "bg-muted text-muted-foreground"
647
+ };
648
+ const RUN_TONE = {
649
+ SUCCEEDED: "ok",
650
+ FAILED: "fail",
651
+ RUNNING: "run",
652
+ WAITING: "run",
653
+ PENDING: "idle",
654
+ PARKED: "warn",
655
+ CANCELLED: "idle"
656
+ };
657
+ const STEP_TONE = {
658
+ ...RUN_TONE,
659
+ SKIPPED: "idle",
660
+ REPLAYED: "run"
661
+ };
662
+ const WORKFLOW_TONE = {
663
+ ENABLED: "ok",
664
+ DRAFT: "idle",
665
+ DISABLED: "warn",
666
+ ARCHIVED: "idle"
667
+ };
668
+ function workflowHealth(status, lastRunStatus) {
669
+ const state = statusLabel(status ?? "DRAFT");
670
+ if (status !== "ENABLED") return {
671
+ tone: "idle",
672
+ label: state
673
+ };
674
+ if (!lastRunStatus) return {
675
+ tone: "idle",
676
+ label: `${state}, not run yet`
677
+ };
678
+ return {
679
+ tone: toneOf(RUN_TONE, lastRunStatus),
680
+ label: `${state}, last run ${statusLabel(lastRunStatus).toLowerCase()}`
681
+ };
682
+ }
683
+ const CONNECTION_TONE = {
684
+ OK: "ok",
685
+ ERROR: "fail",
686
+ REVOKED: "fail",
687
+ UNCONFIGURED: "warn"
688
+ };
689
+ function toneOf(map, status) {
690
+ return (status ? map[status] : void 0) ?? "idle";
691
+ }
692
+ function statusLabel(status) {
693
+ return status.charAt(0) + status.slice(1).toLowerCase();
694
+ }
695
+ function formatDuration(startedAt, endedAt) {
696
+ if (!endedAt) return "…";
697
+ return formatMs(new Date(endedAt).getTime() - new Date(startedAt).getTime());
698
+ }
699
+ function runTimeline(run) {
700
+ const start = new Date(run.startedAt).getTime();
701
+ const ends = run.steps.map((step) => step.endedAt ? new Date(step.endedAt).getTime() : 0).concat(run.endedAt ? new Date(run.endedAt).getTime() : 0);
702
+ const total = Math.max(...ends) - start;
703
+ const spans = /* @__PURE__ */ new Map();
704
+ if (total <= 0) return spans;
705
+ for (const step of run.steps) {
706
+ if (!step.startedAt || !step.endedAt) continue;
707
+ const from = new Date(step.startedAt).getTime() - start;
708
+ const ms = new Date(step.endedAt).getTime() - new Date(step.startedAt).getTime();
709
+ spans.set(step.stepId, {
710
+ offset: Math.min(Math.max(from / total, 0), 1),
711
+ width: Math.min(Math.max(ms / total, 0), 1),
712
+ ms
713
+ });
714
+ }
715
+ return spans;
716
+ }
717
+ function formatMs(ms) {
718
+ if (ms < 1e3) return `${ms}ms`;
719
+ const tenths = Math.round(ms / 100);
720
+ if (tenths < 600) return `${(tenths / 10).toFixed(1)}s`;
721
+ const seconds = Math.round(ms / 1e3);
722
+ return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
723
+ }
724
+ function durationMs(startedAt, endedAt) {
725
+ if (!endedAt) return null;
726
+ return new Date(endedAt).getTime() - new Date(startedAt).getTime();
727
+ }
728
+ function formatWhen(startedAt) {
729
+ const diff = Date.now() - new Date(startedAt).getTime();
730
+ if (diff < 6e4) return "just now";
731
+ if (diff < 36e5) return `${Math.floor(diff / 6e4)}m ago`;
732
+ if (diff < 864e5) return `${Math.floor(diff / 36e5)}h ago`;
733
+ return new Date(startedAt).toLocaleDateString();
734
+ }
735
+ function formatAbsolute(iso) {
736
+ return new Date(iso).toLocaleString();
737
+ }
738
+ function formatTrigger(kind) {
739
+ return kind.replace(/[-_]/g, " ").toLowerCase();
740
+ }
741
+ function runStats(runs) {
742
+ const succeeded = runs.filter((run) => run.status === "SUCCEEDED").length;
743
+ const failed = runs.filter((run) => run.status === "FAILED").length;
744
+ const finished = succeeded + failed;
745
+ return {
746
+ total: runs.length,
747
+ succeeded,
748
+ failed,
749
+ running: runs.filter((run) => run.status === "RUNNING").length,
750
+ lastRun: runs[0],
751
+ successRate: finished === 0 ? null : Math.round(succeeded / finished * 100)
752
+ };
753
+ }
754
+ //#endregion
755
+ //#region editors/workflow-editor/ui/piece-source.ts
756
+ function triggerStrategyRuns(strategy) {
757
+ return (strategy ?? "POLLING") !== "APP_WEBHOOK";
758
+ }
759
+ function blockUnavailable(entry) {
760
+ if (entry.unsupported) return entry.unsupported;
761
+ if (entry.kind !== "trigger") return void 0;
762
+ const strategy = entry.strategy ?? "POLLING";
763
+ return triggerStrategyRuns(strategy) ? void 0 : `${strategy.toLowerCase()} — not supported yet`;
764
+ }
765
+ let source;
766
+ function registerPieceSource(next) {
767
+ source = next;
768
+ }
769
+ function getPieceSource() {
770
+ return source;
771
+ }
772
+ //#endregion
773
+ //#region editors/workflow-editor/ui/block-meta.ts
774
+ const CORE_META = {
775
+ "core#manual": {
776
+ displayName: "Manual",
777
+ subtitle: "Trigger",
778
+ glyph: "▶"
779
+ },
780
+ "core#schedule": {
781
+ displayName: "Schedule",
782
+ subtitle: "Trigger",
783
+ glyph: "◷"
784
+ },
785
+ "core#webhook": {
786
+ displayName: "Webhook",
787
+ subtitle: "Trigger",
788
+ glyph: "⇲"
789
+ },
790
+ "core#branch": {
791
+ displayName: "Branch",
792
+ subtitle: "Core",
793
+ glyph: "⑂"
794
+ },
795
+ "core#assert": {
796
+ displayName: "Assert",
797
+ subtitle: "Core",
798
+ glyph: "!"
799
+ }
800
+ };
801
+ function parsePieceBlockType(blockType) {
802
+ const separator = blockType.lastIndexOf("#");
803
+ if (separator <= 0) return void 0;
804
+ const packageSpec = blockType.slice(0, separator);
805
+ const fragment = blockType.slice(separator + 1);
806
+ const isTrigger = fragment.startsWith("trigger:");
807
+ const actionName = isTrigger ? fragment.slice(8) : fragment;
808
+ const versionAt = packageSpec.indexOf("@", 1);
809
+ const packageName = versionAt > 0 ? packageSpec.slice(0, versionAt) : packageSpec;
810
+ return {
811
+ packageName,
812
+ pieceName: packageName.split("/").pop()?.replace(/^piece-/, "") ?? "",
813
+ actionName,
814
+ isTrigger
815
+ };
816
+ }
817
+ const pieceLogos = /* @__PURE__ */ new Map();
818
+ const pieceNames = /* @__PURE__ */ new Map();
819
+ const listeners = /* @__PURE__ */ new Set();
820
+ let logoRevision = 0;
821
+ function registerPieceLogos(entries) {
822
+ let changed = false;
823
+ for (const entry of entries) {
824
+ if (!entry.name) continue;
825
+ if (entry.displayName && pieceNames.get(entry.name) !== entry.displayName) {
826
+ pieceNames.set(entry.name, entry.displayName);
827
+ changed = true;
828
+ }
829
+ if (!entry.logoUrl || pieceLogos.get(entry.name) === entry.logoUrl) continue;
830
+ pieceLogos.set(entry.name, entry.logoUrl);
831
+ changed = true;
832
+ }
833
+ if (!changed) return;
834
+ logoRevision += 1;
835
+ for (const listener of listeners) listener();
836
+ }
837
+ function pieceLogo(packageName) {
838
+ return pieceLogos.get(packageName);
839
+ }
840
+ function pieceDisplayName(packageName) {
841
+ return pieceNames.get(packageName);
842
+ }
843
+ const blockNames = /* @__PURE__ */ new Map();
844
+ const namesRequested = /* @__PURE__ */ new Set();
845
+ function nameKey(blockType) {
846
+ const piece = parsePieceBlockType(blockType);
847
+ if (!piece) return void 0;
848
+ const fragment = piece.isTrigger ? `trigger:${piece.actionName}` : piece.actionName;
849
+ return `${piece.packageName}#${fragment}`;
850
+ }
851
+ function registerBlockNames(entries) {
852
+ let changed = false;
853
+ for (const entry of entries) {
854
+ const key = nameKey(entry.blockType);
855
+ if (!key || !entry.displayName || blockNames.get(key) === entry.displayName) continue;
856
+ blockNames.set(key, entry.displayName);
857
+ changed = true;
858
+ }
859
+ if (!changed) return;
860
+ logoRevision += 1;
861
+ for (const listener of listeners) listener();
862
+ }
863
+ function requestBlockNames(packageName) {
864
+ if (namesRequested.has(packageName)) return;
865
+ const source = getPieceSource();
866
+ if (!source) return;
867
+ namesRequested.add(packageName);
868
+ Promise.all([source.loadActions(packageName), source.loadTriggers(packageName)]).then(([actions, triggers]) => registerBlockNames([...actions, ...triggers])).catch(() => namesRequested.delete(packageName));
869
+ }
870
+ function subscribePieceLogos(listener) {
871
+ listeners.add(listener);
872
+ return () => listeners.delete(listener);
873
+ }
874
+ function pieceLogoRevision() {
875
+ return logoRevision;
876
+ }
877
+ let catalogLoad;
878
+ function ensurePieceLogos() {
879
+ const source = getPieceSource();
880
+ if (!source) return Promise.resolve();
881
+ catalogLoad ??= source.loadCatalog().then((pieces) => registerPieceLogos(pieces)).catch(() => {
882
+ catalogLoad = void 0;
883
+ });
884
+ return catalogLoad;
885
+ }
886
+ function blockMeta(blockType) {
887
+ const core = CORE_META[blockType];
888
+ if (core) return core;
889
+ const piece = parsePieceBlockType(blockType);
890
+ if (piece) {
891
+ const pieceLabel = pieceNames.get(piece.packageName) ?? titleCase(piece.pieceName);
892
+ const known = blockNames.get(nameKey(blockType) ?? "");
893
+ if (!known) requestBlockNames(piece.packageName);
894
+ return {
895
+ displayName: known ?? titleCase(piece.actionName),
896
+ subtitle: piece.isTrigger ? `${pieceLabel} · Trigger` : pieceLabel,
897
+ logoUrl: pieceLogo(piece.packageName),
898
+ glyph: piece.pieceName.slice(0, 1).toUpperCase() || "?"
899
+ };
900
+ }
901
+ return {
902
+ displayName: blockType,
903
+ subtitle: "",
904
+ glyph: "?"
905
+ };
906
+ }
907
+ function titleCase(value) {
908
+ return value.replaceAll(/[-_]/g, " ").replace(/^\w/, (char) => char.toUpperCase());
909
+ }
910
+ function usePieceLogos() {
911
+ const revision = useSyncExternalStore(subscribePieceLogos, pieceLogoRevision, pieceLogoRevision);
912
+ useEffect(() => {
913
+ ensurePieceLogos();
914
+ }, []);
915
+ return revision;
916
+ }
917
+ function useBlockMeta(blockType) {
918
+ usePieceLogos();
919
+ return blockMeta(blockType);
920
+ }
921
+ //#endregion
922
+ //#region editors/workflow-editor/ui/BlockSelector.tsx
923
+ const ROW_LOGO = 24;
924
+ const CORE_TILE = {
925
+ "core#manual": {
926
+ icon: "play",
927
+ color: "#2563eb"
928
+ },
929
+ "core#schedule": {
930
+ icon: "clock",
931
+ color: "#7c3aed"
932
+ },
933
+ "core#webhook": {
934
+ icon: "bolt",
935
+ color: "#0891b2"
936
+ },
937
+ "core#branch": {
938
+ icon: "branch",
939
+ color: "#d97706"
940
+ },
941
+ "core#assert": {
942
+ icon: "alert",
943
+ color: "#dc2626"
944
+ }
945
+ };
946
+ function CoreTile(props) {
947
+ const tile = CORE_TILE[props.blockType];
948
+ const glyph = Math.round(props.size * (props.bare ? .9 : .55));
949
+ if (props.bare) return /* @__PURE__ */ jsx("span", {
950
+ className: "flex shrink-0 items-center justify-center",
951
+ style: {
952
+ width: props.size,
953
+ height: props.size,
954
+ color: tile.color
955
+ },
956
+ children: /* @__PURE__ */ jsx(Icon, {
957
+ name: tile.icon,
958
+ size: glyph
959
+ })
960
+ });
961
+ return /* @__PURE__ */ jsx("span", {
962
+ className: "flex shrink-0 items-center justify-center rounded-[22%] text-white",
963
+ style: {
964
+ width: props.size,
965
+ height: props.size,
966
+ backgroundColor: tile.color
967
+ },
968
+ children: /* @__PURE__ */ jsx(Icon, {
969
+ name: tile.icon,
970
+ size: glyph
971
+ })
972
+ });
973
+ }
974
+ function BlockLogo(props) {
975
+ const meta = useBlockMeta(props.blockType);
976
+ if (props.blockType in CORE_TILE) return /* @__PURE__ */ jsx(CoreTile, {
977
+ blockType: props.blockType,
978
+ size: props.size ?? 36,
979
+ bare: props.bare
980
+ });
981
+ return /* @__PURE__ */ jsx(LogoFrame, {
982
+ src: meta.logoUrl,
983
+ alt: meta.displayName,
984
+ size: props.size ?? 36,
985
+ glyph: meta.glyph,
986
+ bare: props.bare
987
+ });
988
+ }
989
+ function GlyphBadge(props) {
990
+ return /* @__PURE__ */ jsx("div", {
991
+ className: "flex shrink-0 items-center justify-center rounded-sm border border-solid border-foreground/10 bg-muted/50 text-muted-foreground",
992
+ style: {
993
+ width: props.size,
994
+ height: props.size,
995
+ fontSize: props.size / 2
996
+ },
997
+ children: props.glyph ?? "?"
998
+ });
999
+ }
1000
+ function LogoFrame(props) {
1001
+ const [broken, setBroken] = useState(false);
1002
+ useEffect(() => {
1003
+ setBroken(false);
1004
+ }, [props.src]);
1005
+ if (!props.src || broken) return /* @__PURE__ */ jsx(GlyphBadge, {
1006
+ glyph: props.glyph,
1007
+ size: props.size
1008
+ });
1009
+ return /* @__PURE__ */ jsx("div", {
1010
+ className: `flex shrink-0 items-center justify-center ${props.bare ? "" : "dark:rounded-[22%] dark:bg-white dark:p-[var(--logo-pad)]"}`,
1011
+ style: {
1012
+ width: props.size,
1013
+ height: props.size,
1014
+ "--logo-pad": `${Math.round(props.size * .12)}px`
1015
+ },
1016
+ children: /* @__PURE__ */ jsx("img", {
1017
+ src: props.src,
1018
+ alt: props.alt,
1019
+ className: "h-full w-full object-contain drop-shadow-sm",
1020
+ onError: () => setBroken(true)
1021
+ })
1022
+ });
1023
+ }
1024
+ function Row(props) {
1025
+ return /* @__PURE__ */ jsxs("button", {
1026
+ type: "button",
1027
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-left ${props.disabled ? "cursor-not-allowed opacity-50" : "hover:bg-muted/50"}`,
1028
+ disabled: props.disabled,
1029
+ onClick: props.onClick,
1030
+ children: [props.logo, /* @__PURE__ */ jsxs("span", {
1031
+ className: "min-w-0",
1032
+ children: [/* @__PURE__ */ jsx("span", {
1033
+ className: "block truncate text-xs font-medium text-foreground",
1034
+ children: props.label
1035
+ }), /* @__PURE__ */ jsx("span", {
1036
+ className: "block truncate text-[11px] text-muted-foreground/80",
1037
+ children: props.description
1038
+ })]
1039
+ })]
1040
+ });
1041
+ }
1042
+ function SectionLabel(props) {
1043
+ return /* @__PURE__ */ jsx("div", {
1044
+ className: "px-3 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/60",
1045
+ children: props.children
1046
+ });
1047
+ }
1048
+ const CATEGORY_LABELS = {
1049
+ ARTIFICIAL_INTELLIGENCE: "AI",
1050
+ UNIVERSAL_AI: "AI",
1051
+ PRODUCTIVITY: "Productivity",
1052
+ MARKETING: "Marketing",
1053
+ COMMUNICATION: "Communication",
1054
+ SALES_AND_CRM: "Sales & CRM",
1055
+ DEVELOPER_TOOLS: "Developer tools",
1056
+ CONTENT_AND_FILES: "Content & files",
1057
+ BUSINESS_INTELLIGENCE: "Business intelligence",
1058
+ CORE: "Utilities",
1059
+ FLOW_CONTROL: "Utilities",
1060
+ COMMERCE: "Commerce",
1061
+ FORMS_AND_SURVEYS: "Forms & surveys",
1062
+ ACCOUNTING: "Accounting",
1063
+ CUSTOMER_SUPPORT: "Customer support",
1064
+ PAYMENT_PROCESSING: "Payments",
1065
+ HUMAN_RESOURCES: "HR"
1066
+ };
1067
+ const CORE_CHIP = "Core";
1068
+ const POWERHOUSE_CHIP = "Powerhouse";
1069
+ const AI_CHIP = "AI";
1070
+ function categoryLabel(id) {
1071
+ return CATEGORY_LABELS[id] ?? id.toLowerCase().replaceAll("_", " ").replace(/^\w/, (char) => char.toUpperCase());
1072
+ }
1073
+ function chipsOf(piece) {
1074
+ return new Set(piece.categories.map(categoryLabel));
1075
+ }
1076
+ function orderChips(pieces) {
1077
+ const counts = /* @__PURE__ */ new Map();
1078
+ for (const piece of pieces) for (const chip of chipsOf(piece)) counts.set(chip, (counts.get(chip) ?? 0) + 1);
1079
+ const rest = [...counts.entries()].filter(([chip]) => chip !== AI_CHIP).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([chip]) => chip);
1080
+ return [
1081
+ CORE_CHIP,
1082
+ POWERHOUSE_CHIP,
1083
+ ...counts.has(AI_CHIP) ? [AI_CHIP] : [],
1084
+ ...rest
1085
+ ];
1086
+ }
1087
+ function PieceEntries(props) {
1088
+ const [entries, setEntries] = useState(null);
1089
+ const [error, setError] = useState(null);
1090
+ useEffect(() => {
1091
+ let cancelled = false;
1092
+ const pieceSource = getPieceSource();
1093
+ (props.mode === "triggers" ? pieceSource?.loadTriggers(props.piece.name) : pieceSource?.loadActions(props.piece.name))?.then((result) => {
1094
+ if (!cancelled) setEntries(result);
1095
+ }).catch((loadError) => {
1096
+ if (!cancelled) setError(loadError instanceof Error ? loadError.message : String(loadError));
1097
+ });
1098
+ return () => {
1099
+ cancelled = true;
1100
+ };
1101
+ }, [props.piece.name, props.mode]);
1102
+ return /* @__PURE__ */ jsxs("div", {
1103
+ className: "max-h-80 overflow-y-auto py-1",
1104
+ children: [/* @__PURE__ */ jsxs("button", {
1105
+ type: "button",
1106
+ className: "flex w-full items-center gap-1 px-3 py-1 text-[11px] text-muted-foreground/80 hover:text-muted-foreground",
1107
+ onClick: props.onBack,
1108
+ children: ["← ", props.piece.displayName]
1109
+ }), error ? /* @__PURE__ */ jsx("div", {
1110
+ className: "px-3 py-2 text-xs text-wf-fail",
1111
+ children: error
1112
+ }) : entries === null ? /* @__PURE__ */ jsx("div", {
1113
+ className: "px-3 py-2 text-xs text-muted-foreground/80",
1114
+ children: "Loading…"
1115
+ }) : entries.map((entry) => {
1116
+ const unavailable = blockUnavailable({
1117
+ ...entry,
1118
+ kind: props.mode === "triggers" ? "trigger" : "action"
1119
+ });
1120
+ return /* @__PURE__ */ jsx(Row, {
1121
+ logo: /* @__PURE__ */ jsx(LogoFrame, {
1122
+ src: props.piece.logoUrl,
1123
+ alt: props.piece.displayName,
1124
+ size: ROW_LOGO
1125
+ }),
1126
+ label: entry.displayName,
1127
+ description: unavailable ?? entry.description,
1128
+ disabled: unavailable !== void 0,
1129
+ onClick: () => props.onPick({
1130
+ label: entry.displayName,
1131
+ blockType: entry.blockType,
1132
+ description: entry.description,
1133
+ defaultConfig: {}
1134
+ })
1135
+ }, entry.name);
1136
+ })]
1137
+ });
1138
+ }
1139
+ const SEARCH_MIN_CHARS = 2;
1140
+ const SEARCH_DEBOUNCE_MS = 250;
1141
+ const INDEXING_RETRY_MS = 2e3;
1142
+ function useBlockSearch(query, enabled) {
1143
+ const [state, setState] = useState({ kind: "idle" });
1144
+ const [attempt, setAttempt] = useState(0);
1145
+ const trimmed = query.trim();
1146
+ const active = enabled && trimmed.length >= SEARCH_MIN_CHARS;
1147
+ useEffect(() => {
1148
+ const search = getPieceSource()?.searchBlocks;
1149
+ if (!active || !search) {
1150
+ setState({ kind: "idle" });
1151
+ return;
1152
+ }
1153
+ let alive = true;
1154
+ let retry;
1155
+ const timer = setTimeout(() => {
1156
+ setState((previous) => previous.kind === "done" ? previous : { kind: "loading" });
1157
+ search(trimmed).then((result) => {
1158
+ if (!alive) return;
1159
+ setState({
1160
+ kind: "done",
1161
+ result
1162
+ });
1163
+ if (result.status === "indexing") retry = setTimeout(() => setAttempt((value) => value + 1), INDEXING_RETRY_MS);
1164
+ }, (error) => {
1165
+ if (alive) setState({
1166
+ kind: "error",
1167
+ message: error instanceof Error ? error.message : String(error)
1168
+ });
1169
+ });
1170
+ }, SEARCH_DEBOUNCE_MS);
1171
+ return () => {
1172
+ alive = false;
1173
+ clearTimeout(timer);
1174
+ if (retry) clearTimeout(retry);
1175
+ };
1176
+ }, [
1177
+ active,
1178
+ trimmed,
1179
+ attempt
1180
+ ]);
1181
+ return active ? state : { kind: "idle" };
1182
+ }
1183
+ function Chip(props) {
1184
+ return /* @__PURE__ */ jsx("button", {
1185
+ type: "button",
1186
+ className: `rounded-full border px-2 py-0.5 text-[10px] font-medium ${props.active ? "border-primary bg-primary text-primary-foreground" : "border-foreground/10 text-muted-foreground hover:border-foreground/25"}`,
1187
+ onClick: props.onClick,
1188
+ children: props.label
1189
+ });
1190
+ }
1191
+ function BlockSelector(props) {
1192
+ const [query, setQuery] = useState("");
1193
+ const [chip, setChip] = useState(null);
1194
+ const [catalog, setCatalog] = useState(null);
1195
+ const [piece, setPiece] = useState(null);
1196
+ const containerRef = useRef(null);
1197
+ useEffect(() => {
1198
+ const handler = (event) => {
1199
+ if (!containerRef.current?.contains(event.target)) props.onClose();
1200
+ };
1201
+ window.addEventListener("mousedown", handler);
1202
+ return () => window.removeEventListener("mousedown", handler);
1203
+ }, [props]);
1204
+ const pieceSource = props.showPieces ? getPieceSource() : void 0;
1205
+ useEffect(() => {
1206
+ if (!pieceSource) return;
1207
+ let cancelled = false;
1208
+ pieceSource.loadCatalog().then((pieces) => {
1209
+ if (!cancelled) setCatalog({ pieces });
1210
+ }).catch((error) => {
1211
+ if (!cancelled) setCatalog({
1212
+ pieces: [],
1213
+ error: error instanceof Error ? error.message : String(error)
1214
+ });
1215
+ });
1216
+ return () => {
1217
+ cancelled = true;
1218
+ };
1219
+ }, [pieceSource]);
1220
+ const mode = props.pieceMode ?? "actions";
1221
+ const lowered = query.toLowerCase();
1222
+ const modePieces = useMemo(() => (catalog?.pieces ?? []).filter((entry) => (mode === "triggers" ? entry.triggerCount : entry.actionCount) > 0), [catalog, mode]);
1223
+ const chips = useMemo(() => orderChips(modePieces), [modePieces]);
1224
+ const chipsByPiece = useMemo(() => new Map(modePieces.map((entry) => [entry.name, chipsOf(entry)])), [modePieces]);
1225
+ const inChip = (pieceName) => chip === null || chip === "Core" ? true : chipsByPiece.get(pieceName)?.has(chip) ?? false;
1226
+ const showCatalog = pieceSource !== void 0 && !(chip === "Core" || chip === "Powerhouse");
1227
+ const matching = props.presets.filter((preset) => `${preset.label} ${preset.blockType}`.toLowerCase().includes(lowered));
1228
+ const corePresets = chip === null || chip === "Core" ? matching.filter((preset) => preset.group !== "powerhouse") : [];
1229
+ const powerhousePresets = chip === null || chip === "Powerhouse" ? matching.filter((preset) => preset.group === "powerhouse") : [];
1230
+ const filteredAttach = (props.onAttach ? props.attachSteps ?? [] : []).filter((step) => `${step.name} ${step.key} ${step.blockType}`.toLowerCase().includes(lowered));
1231
+ const filteredPieces = showCatalog ? modePieces.filter((entry) => inChip(entry.name) && `${entry.displayName} ${entry.name} ${entry.description}`.toLowerCase().includes(lowered)) : [];
1232
+ const search = useBlockSearch(query, showCatalog && !piece);
1233
+ const presetRow = (preset) => /* @__PURE__ */ jsx(Row, {
1234
+ logo: /* @__PURE__ */ jsx(BlockLogo, {
1235
+ blockType: preset.blockType,
1236
+ size: ROW_LOGO
1237
+ }),
1238
+ label: preset.label,
1239
+ description: preset.description,
1240
+ onClick: () => props.onPick(preset)
1241
+ }, preset.blockType + preset.label);
1242
+ const labelPresets = showCatalog || filteredAttach.length > 0 || corePresets.length > 0 && powerhousePresets.length > 0;
1243
+ const wantedKind = mode === "triggers" ? "trigger" : "action";
1244
+ const hits = search.kind === "done" ? search.result.hits.filter((hit) => hit.kind === wantedKind && inChip(hit.pieceName)) : [];
1245
+ const searchActive = search.kind !== "idle";
1246
+ return /* @__PURE__ */ jsxs("div", {
1247
+ ref: containerRef,
1248
+ className: "nodrag nopan nowheel w-80 rounded-md border border-solid border-foreground/10 bg-card shadow-lg",
1249
+ onClick: (event) => event.stopPropagation(),
1250
+ children: [/* @__PURE__ */ jsxs("div", {
1251
+ className: "border-b border-foreground/10 p-2",
1252
+ children: [/* @__PURE__ */ jsx("div", {
1253
+ className: "mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/80",
1254
+ children: props.title
1255
+ }), piece ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("input", {
1256
+ autoFocus: true,
1257
+ className: "w-full rounded border border-foreground/10 px-2 py-1 text-xs",
1258
+ placeholder: pieceSource ? "Search pieces, actions, triggers…" : "Search…",
1259
+ value: query,
1260
+ onChange: (event) => setQuery(event.target.value)
1261
+ }), pieceSource && catalog && !catalog.error ? /* @__PURE__ */ jsx("div", {
1262
+ className: "mt-1.5 flex flex-wrap gap-1 px-0.5",
1263
+ children: chips.map((label) => /* @__PURE__ */ jsx(Chip, {
1264
+ label,
1265
+ active: chip === label,
1266
+ onClick: () => setChip(chip === label ? null : label)
1267
+ }, label))
1268
+ }) : null] })]
1269
+ }), piece ? /* @__PURE__ */ jsx(PieceEntries, {
1270
+ piece,
1271
+ mode,
1272
+ onPick: props.onPick,
1273
+ onBack: () => setPiece(null)
1274
+ }) : /* @__PURE__ */ jsxs("div", {
1275
+ className: "max-h-80 overflow-y-auto py-1",
1276
+ children: [
1277
+ filteredAttach.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Attach existing step" }), filteredAttach.map((step) => /* @__PURE__ */ jsx(Row, {
1278
+ logo: /* @__PURE__ */ jsx(BlockLogo, {
1279
+ blockType: step.blockType,
1280
+ size: ROW_LOGO
1281
+ }),
1282
+ label: step.name,
1283
+ description: `{{steps.${step.key}}} · detached`,
1284
+ onClick: () => props.onAttach?.(step.id)
1285
+ }, step.id))] }) : null,
1286
+ corePresets.length > 0 && labelPresets ? /* @__PURE__ */ jsx(SectionLabel, { children: "Core" }) : null,
1287
+ corePresets.map(presetRow),
1288
+ powerhousePresets.length > 0 && labelPresets ? /* @__PURE__ */ jsx(SectionLabel, { children: "Powerhouse" }) : null,
1289
+ powerhousePresets.map(presetRow),
1290
+ searchActive ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: mode === "triggers" ? "Triggers" : "Actions & triggers" }), search.kind === "loading" ? /* @__PURE__ */ jsx("div", {
1291
+ className: "px-3 py-1 text-xs text-muted-foreground/80",
1292
+ children: "Searching…"
1293
+ }) : search.kind === "error" ? /* @__PURE__ */ jsx("div", {
1294
+ className: "px-3 py-1 text-xs text-wf-fail",
1295
+ children: search.message
1296
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [hits.map((hit) => {
1297
+ const unavailable = blockUnavailable(hit);
1298
+ return /* @__PURE__ */ jsx(Row, {
1299
+ logo: /* @__PURE__ */ jsx(LogoFrame, {
1300
+ src: hit.logoUrl,
1301
+ alt: hit.pieceDisplayName,
1302
+ size: ROW_LOGO
1303
+ }),
1304
+ label: `${hit.displayName} · ${hit.pieceDisplayName}`,
1305
+ description: unavailable ?? (hit.description || hit.pieceDisplayName),
1306
+ disabled: unavailable !== void 0,
1307
+ onClick: () => props.onPick({
1308
+ label: hit.displayName,
1309
+ blockType: hit.blockType,
1310
+ description: hit.description,
1311
+ defaultConfig: {}
1312
+ })
1313
+ }, hit.blockType);
1314
+ }), search.result.status === "indexing" ? /* @__PURE__ */ jsx("div", {
1315
+ className: "px-3 py-1 text-xs text-muted-foreground/80",
1316
+ children: "Indexing the catalog… more results appear shortly."
1317
+ }) : search.result.status === "error" ? /* @__PURE__ */ jsx("div", {
1318
+ className: "px-3 py-1 text-xs text-wf-fail",
1319
+ children: search.result.error ?? "Search failed"
1320
+ }) : hits.length === 0 ? /* @__PURE__ */ jsxs("div", {
1321
+ className: "px-3 py-1 text-xs text-muted-foreground/80",
1322
+ children: [
1323
+ "No matching ",
1324
+ wantedKind,
1325
+ "s"
1326
+ ]
1327
+ }) : null] })] }) : null,
1328
+ showCatalog ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Pieces" }), catalog === null ? /* @__PURE__ */ jsx("div", {
1329
+ className: "px-3 py-2 text-xs text-muted-foreground/80",
1330
+ children: "Loading catalog…"
1331
+ }) : catalog.error ? /* @__PURE__ */ jsx("div", {
1332
+ className: "px-3 py-2 text-xs text-wf-fail",
1333
+ children: catalog.error
1334
+ }) : filteredPieces.map((entry) => /* @__PURE__ */ jsx(Row, {
1335
+ logo: /* @__PURE__ */ jsx(LogoFrame, {
1336
+ src: entry.logoUrl,
1337
+ alt: entry.displayName,
1338
+ size: ROW_LOGO
1339
+ }),
1340
+ label: entry.displayName,
1341
+ description: entry.unsupported ?? (mode === "triggers" ? `${entry.triggerCount} trigger${entry.triggerCount === 1 ? "" : "s"} · ${entry.description}` : `${entry.actionCount} action${entry.actionCount === 1 ? "" : "s"} · ${entry.description}`),
1342
+ onClick: () => setPiece(entry)
1343
+ }, entry.name))] }) : null,
1344
+ corePresets.length + powerhousePresets.length === 0 && filteredPieces.length === 0 && filteredAttach.length === 0 && !searchActive ? /* @__PURE__ */ jsx("div", {
1345
+ className: "px-3 py-2 text-xs text-muted-foreground/80",
1346
+ children: "No matches"
1347
+ }) : null
1348
+ ]
1349
+ })]
1350
+ });
1351
+ }
1352
+ //#endregion
1353
+ export { FieldError as A, textInputClass as B, runStats as C, workflowHealth as D, toneOf as E, Select as F, DocumentErrorBoundary as H, Switch as I, Tabs as L, Hint as M, IconButton as N, useSyncWorkflowRuntimeUrl as O, Segmented as P, invalidClass as R, formatWhen as S, statusLabel as T, DocumentLoadError as U, Icon as V, errorMessage as W, durationMs as _, pieceLogo as a, formatMs as b, registerPieceSource as c, RUN_TONE as d, STEP_TONE as f, WORKFLOW_TONE as g, TONE_TEXT as h, pieceDisplayName as i, FieldLabel as j, Button as k, CONNECTION_TONE as l, TONE_DOT as m, BlockSelector as n, useBlockMeta as o, TONE_BADGE as p, blockMeta as r, usePieceLogos as s, BlockLogo as t, RUN_STATUSES as u, formatAbsolute as v, runTimeline as w, formatTrigger as x, formatDuration as y, textAreaClass as z };
1354
+
1355
+ //# sourceMappingURL=BlockSelector-QQgOCVH3.js.map