@powerhousedao/workflow 6.2.3-dev.50 → 6.2.3-dev.52

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 (86) hide show
  1. package/dist/browser/{BlockSelector-eaXC56EC.js → BlockSelector-CzJnQWsh.js} +1172 -254
  2. package/dist/browser/BlockSelector-CzJnQWsh.js.map +1 -0
  3. package/dist/browser/assets/{entry-E7pSm84X.js → entry-BETsJgYg.js} +2 -2
  4. package/dist/browser/assets/{projection-entry-UE4mfnXc.js → projection-entry-CdlLTrjU.js} +2 -2
  5. package/dist/browser/{connection-form-Db1YlNk2.js → connection-form-cCgfAa1A.js} +3 -3
  6. package/dist/browser/{connection-form-Db1YlNk2.js.map → connection-form-cCgfAa1A.js.map} +1 -1
  7. package/dist/browser/{data-tree-ClKfWUgI.js → data-tree-S_SwaRve.js} +2 -2
  8. package/dist/browser/{data-tree-ClKfWUgI.js.map → data-tree-S_SwaRve.js.map} +1 -1
  9. package/dist/browser/{document-models-DDiMjugM.js → document-models-B08jDa_s.js} +6 -1
  10. package/dist/browser/{document-models-DDiMjugM.js.map → document-models-B08jDa_s.js.map} +1 -1
  11. package/dist/browser/{editor-DFS8U1MR.js → editor-CQyfDOIN.js} +39 -27
  12. package/dist/browser/editor-CQyfDOIN.js.map +1 -0
  13. package/dist/browser/{editor-aRP2k9qa.js → editor-CVXRNht0.js} +4 -4
  14. package/dist/browser/{editor-aRP2k9qa.js.map → editor-CVXRNht0.js.map} +1 -1
  15. package/dist/browser/{editor-BgJ0RzSj.js → editor-CbpyTAEC.js} +4 -4
  16. package/dist/browser/{editor-BgJ0RzSj.js.map → editor-CbpyTAEC.js.map} +1 -1
  17. package/dist/browser/editors/connection-editor/module.js +1 -1
  18. package/dist/browser/editors/workflow-editor/module.js +1 -1
  19. package/dist/browser/editors/workflow-studio/module.js +1 -1
  20. package/dist/browser/index.js +32 -9
  21. package/dist/browser/index.js.map +1 -1
  22. package/dist/browser/reactor/index.js +1 -1
  23. package/dist/browser/{runtime-queries-Bcd7IS3T.js → runtime-queries-2hn7fcKn.js} +17 -11
  24. package/dist/browser/runtime-queries-2hn7fcKn.js.map +1 -0
  25. package/dist/browser/{trigger-text-DxpCRgMq.js → trigger-text-Cfyx8tMq.js} +4 -4
  26. package/dist/browser/{trigger-text-DxpCRgMq.js.map → trigger-text-Cfyx8tMq.js.map} +1 -1
  27. package/dist/node/{BlockSelector-DidV3yJx.mjs → BlockSelector-g9m3yaJj.mjs} +1172 -254
  28. package/dist/node/BlockSelector-g9m3yaJj.mjs.map +1 -0
  29. package/dist/node/{connection-form-BitMCIRb.mjs → connection-form-h0PidbTI.mjs} +3 -3
  30. package/dist/node/{connection-form-BitMCIRb.mjs.map → connection-form-h0PidbTI.mjs.map} +1 -1
  31. package/dist/node/{data-tree-Cn50TNYN.mjs → data-tree-CKKeR7qj.mjs} +2 -2
  32. package/dist/node/{data-tree-Cn50TNYN.mjs.map → data-tree-CKKeR7qj.mjs.map} +1 -1
  33. package/dist/node/{editor-BsWzr32t.mjs → editor-BAbYXi7T.mjs} +4 -4
  34. package/dist/node/{editor-BsWzr32t.mjs.map → editor-BAbYXi7T.mjs.map} +1 -1
  35. package/dist/node/{editor-i7ovccfO.mjs → editor-DCsT8WsQ.mjs} +39 -27
  36. package/dist/node/editor-DCsT8WsQ.mjs.map +1 -0
  37. package/dist/node/{editor-D7GDdxR3.mjs → editor-EeTeVS3A.mjs} +4 -4
  38. package/dist/node/{editor-D7GDdxR3.mjs.map → editor-EeTeVS3A.mjs.map} +1 -1
  39. package/dist/node/editors/connection-editor/module.mjs +1 -1
  40. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  41. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  42. package/dist/node/index.mjs +36 -8
  43. package/dist/node/index.mjs.map +1 -1
  44. package/dist/node/pieces/reactor/descriptor.json +1 -1
  45. package/dist/node/pieces/reactor/package.json +1 -1
  46. package/dist/node/{runtime-queries-CZ7vFHoG.mjs → runtime-queries-BtTx8FU3.mjs} +17 -11
  47. package/dist/node/runtime-queries-BtTx8FU3.mjs.map +1 -0
  48. package/dist/node/{trigger-text-aHI7jqvP.mjs → trigger-text-CtSXg0KB.mjs} +4 -4
  49. package/dist/node/{trigger-text-aHI7jqvP.mjs.map → trigger-text-CtSXg0KB.mjs.map} +1 -1
  50. package/dist/powerhouse.manifest.json +6 -1
  51. package/dist/style.css +99 -28
  52. package/dist/types/ai/tools.d.ts +4 -4
  53. package/dist/types/ai/tools.d.ts.map +1 -1
  54. package/dist/types/editors/workflow-editor/runtime-api.d.ts +2 -1
  55. package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -1
  56. package/dist/types/editors/workflow-editor/runtime-client.d.ts +25 -4
  57. package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
  58. package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -1
  59. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts +15 -2
  60. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
  61. package/dist/types/editors/workflow-editor/ui/CanvasContextMenu.d.ts.map +1 -1
  62. package/dist/types/editors/workflow-editor/ui/PickerPopover.d.ts +12 -0
  63. package/dist/types/editors/workflow-editor/ui/PickerPopover.d.ts.map +1 -0
  64. package/dist/types/editors/workflow-editor/ui/ScheduleBuilder.d.ts.map +1 -1
  65. package/dist/types/editors/workflow-editor/ui/VirtualList.d.ts +14 -0
  66. package/dist/types/editors/workflow-editor/ui/VirtualList.d.ts.map +1 -0
  67. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -1
  68. package/dist/types/editors/workflow-editor/ui/block-picker-layout.test.d.ts +2 -0
  69. package/dist/types/editors/workflow-editor/ui/block-picker-layout.test.d.ts.map +1 -0
  70. package/dist/types/editors/workflow-editor/ui/picker-placement.d.ts +19 -0
  71. package/dist/types/editors/workflow-editor/ui/picker-placement.d.ts.map +1 -0
  72. package/dist/types/editors/workflow-editor/ui/picker-recent.d.ts +4 -0
  73. package/dist/types/editors/workflow-editor/ui/picker-recent.d.ts.map +1 -0
  74. package/dist/types/editors/workflow-editor/ui/piece-source.d.ts +23 -3
  75. package/dist/types/editors/workflow-editor/ui/piece-source.d.ts.map +1 -1
  76. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts +2 -2
  77. package/dist/types/editors/workflow-editor/ui/query-keys.d.ts.map +1 -1
  78. package/dist/types/scripts/ui-stack.d.ts +1 -1
  79. package/dist/types/scripts/ui-stack.d.ts.map +1 -1
  80. package/package.json +8 -8
  81. package/dist/browser/BlockSelector-eaXC56EC.js.map +0 -1
  82. package/dist/browser/editor-DFS8U1MR.js.map +0 -1
  83. package/dist/browser/runtime-queries-Bcd7IS3T.js.map +0 -1
  84. package/dist/node/BlockSelector-DidV3yJx.mjs.map +0 -1
  85. package/dist/node/editor-i7ovccfO.mjs.map +0 -1
  86. package/dist/node/runtime-queries-CZ7vFHoG.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { $ as isCoreBlock, A as keepPreviousData, B as Subscribable, C as infiniteQueryBehavior, D as focusManager, E as pendingThenable, F as resolveStaleTime, G as BRANCH_BLOCK, H as createRuntimeClient, I as shallowEqualObjects, L as shouldThrowError, M as replaceData, N as replaceEqualDeep, O as isServer, P as resolveEnabled, Q as WEBHOOK_TRIGGER, R as timeUntilStale, S as hasPreviousPage, T as notifyManager, U as isSyncingError, W as ASSERT_BLOCK, Y as SCHEDULE_TRIGGER, _ as runtimeKeys, a as pieceActionsQuery, b as QueryClient, c as runQuery, d as secretStatQuery, et as pinBlock, g as queryKind, gt as scheduleConfigIssue, h as blockRefKey, j as noop, k as isValidTimeout, lt as checkTriggerStrategy, m as SHARED_STALE_MS, n as catalogQuery, nt as stepBlock, o as pieceTriggersQuery, p as RESOLVER_STALE_MS, q as MANUAL_TRIGGER, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery, w as fetchState, x as hasNextPage, z as timeoutManager } from "./runtime-queries-Bcd7IS3T.js";
1
+ import { $ as isCoreBlock, A as keepPreviousData, B as Subscribable, C as infiniteQueryBehavior, D as focusManager, E as pendingThenable, F as resolveStaleTime, G as BRANCH_BLOCK, H as createRuntimeClient, I as shallowEqualObjects, L as shouldThrowError, M as replaceData, N as replaceEqualDeep, O as isServer, P as resolveEnabled, Q as WEBHOOK_TRIGGER, R as timeUntilStale, S as hasPreviousPage, T as notifyManager, U as isSyncingError, W as ASSERT_BLOCK, Y as SCHEDULE_TRIGGER, _ as runtimeKeys, a as pieceActionsQuery, b as QueryClient, c as runQuery, d as secretStatQuery, et as pinBlock, g as queryKind, gt as scheduleConfigIssue, h as blockRefKey, j as noop, k as isValidTimeout, lt as checkTriggerStrategy, m as SHARED_STALE_MS, n as catalogQuery, nt as stepBlock, o as pieceTriggersQuery, p as RESOLVER_STALE_MS, q as MANUAL_TRIGGER, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery, w as fetchState, x as hasNextPage, z as timeoutManager } from "./runtime-queries-2hn7fcKn.js";
2
2
  import { Rt as blockKey, zt as compareVersions } from "./module-ozS5EVRx.js";
3
3
  import * as React$1 from "react";
4
4
  import { Component, Fragment, createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
@@ -5585,7 +5585,7 @@ function Tooltip(props) {
5585
5585
  })]
5586
5586
  });
5587
5587
  }
5588
- function Tabs(props) {
5588
+ function Tabs$1(props) {
5589
5589
  return /* @__PURE__ */ jsx("div", {
5590
5590
  role: "tablist",
5591
5591
  className: "flex gap-4",
@@ -5994,7 +5994,7 @@ function usePieceSource() {
5994
5994
  return useContext(PieceSourceContext);
5995
5995
  }
5996
5996
  //#endregion
5997
- //#region ../reactor/dist/drive-container-types-Ci1pdv4X.js
5997
+ //#region ../reactor/dist/drive-container-types-BAfFzBOf.js
5998
5998
  const DRIVE_COLLECTION_PREFIX = "drive.";
5999
5999
  /**
6000
6000
  * Identifies the collection a remote synchronizes. Collections are drive-level
@@ -6021,6 +6021,16 @@ var DriveCollectionId = class DriveCollectionId {
6021
6021
  * The single deserializer for the wire/storage form. `branch` may contain
6022
6022
  * dots, while `driveId` is a dot-free document id, so the drive id is the
6023
6023
  * final dot-delimited segment.
6024
+ *
6025
+ * That asymmetry is a real constraint, not a convention: a drive id
6026
+ * containing a dot does NOT survive `key` -> `fromKey`, because the split
6027
+ * takes the LAST dot and so hands the tail of the drive id back as the drive
6028
+ * id and everything before it as the branch. The key format is the wire and
6029
+ * storage representation of existing `document_collections` rows, so it
6030
+ * cannot be changed; callers that accept a drive id or branch from outside
6031
+ * (a UI field, an RPC payload) must reject dots in the drive id at their own
6032
+ * boundary. The round-trip is verifiable without parsing rules:
6033
+ * `DriveCollectionId.fromKey(id.key).key === id.key`.
6024
6034
  */
6025
6035
  static fromKey(key) {
6026
6036
  if (!key.startsWith(DRIVE_COLLECTION_PREFIX)) throw new Error(`Unsupported collection id: ${key}`);
@@ -6078,6 +6088,7 @@ function useWorkflowRuntimeUrl() {
6078
6088
  //#endregion
6079
6089
  //#region editors/workflow-editor/runtime-context.tsx
6080
6090
  const RuntimeContext = createContext(null);
6091
+ const SEARCH_STALE_MS = 3e5;
6081
6092
  function runtimePieceSource(client, queryClient) {
6082
6093
  return {
6083
6094
  loadCatalog: () => queryClient.fetchQuery(catalogQuery(client)),
@@ -6087,7 +6098,16 @@ function runtimePieceSource(client, queryClient) {
6087
6098
  }),
6088
6099
  loadActions: (packageName) => queryClient.fetchQuery(pieceActionsQuery(client, packageName)),
6089
6100
  loadTriggers: (packageName) => queryClient.fetchQuery(pieceTriggersQuery(client, packageName)),
6090
- searchBlocks: (query, limit) => client.searchBlocks(query, limit)
6101
+ searchPieces: async (query, filter) => {
6102
+ const key = runtimeKeys.searchPieces(client.url, query, filter);
6103
+ const result = await queryClient.fetchQuery({
6104
+ queryKey: key,
6105
+ queryFn: () => client.searchPieces(query, filter),
6106
+ staleTime: SEARCH_STALE_MS
6107
+ });
6108
+ if (result.status !== "ready") queryClient.removeQueries({ queryKey: key });
6109
+ return result;
6110
+ }
6091
6111
  };
6092
6112
  }
6093
6113
  function RuntimeProvider(props) {
@@ -7106,6 +7126,197 @@ function VersionSummary(props) {
7106
7126
  });
7107
7127
  }
7108
7128
  //#endregion
7129
+ //#region editors/workflow-editor/ui/picker-placement.ts
7130
+ const MARGIN = 8;
7131
+ const GAP = 6;
7132
+ const MIN_HEIGHT = 240;
7133
+ function pickerPlacement(anchor, size, viewport) {
7134
+ const width = Math.min(size.width, viewport.width - 16);
7135
+ const below = viewport.height - anchor.bottom - GAP - MARGIN;
7136
+ const above = anchor.top - GAP - MARGIN;
7137
+ const downward = below >= Math.min(size.height, MIN_HEIGHT) || below >= above;
7138
+ const height = Math.max(Math.min(size.height, downward ? below : above), Math.min(size.height, MIN_HEIGHT));
7139
+ const centre = (anchor.left + anchor.right) / 2;
7140
+ const left = Math.min(Math.max(centre - width / 2, MARGIN), viewport.width - width - MARGIN);
7141
+ const top = downward ? Math.min(anchor.bottom + GAP, viewport.height - height - MARGIN) : Math.max(anchor.top - GAP - height, MARGIN);
7142
+ return {
7143
+ left,
7144
+ top: Math.max(top, MARGIN),
7145
+ width,
7146
+ height,
7147
+ above: !downward
7148
+ };
7149
+ }
7150
+ //#endregion
7151
+ //#region editors/workflow-editor/ui/PickerPopover.tsx
7152
+ const PICKER_SIZE = {
7153
+ width: 640,
7154
+ height: 480
7155
+ };
7156
+ function PickerPopover(props) {
7157
+ const [placement, setPlacement] = useState(null);
7158
+ const { anchor, onClose } = props;
7159
+ useLayoutEffect(() => {
7160
+ const place = () => {
7161
+ const rect = anchor.current?.getBoundingClientRect();
7162
+ if (!rect) return;
7163
+ setPlacement(pickerPlacement(rect, PICKER_SIZE, {
7164
+ width: window.innerWidth,
7165
+ height: window.innerHeight
7166
+ }));
7167
+ };
7168
+ place();
7169
+ const onWheel = (event) => {
7170
+ const target = event.target;
7171
+ if (!(target instanceof Element && target.closest("[data-selector-open]"))) onClose();
7172
+ };
7173
+ window.addEventListener("resize", onClose);
7174
+ window.addEventListener("wheel", onWheel, {
7175
+ capture: true,
7176
+ passive: true
7177
+ });
7178
+ return () => {
7179
+ window.removeEventListener("resize", onClose);
7180
+ window.removeEventListener("wheel", onWheel, { capture: true });
7181
+ };
7182
+ }, [anchor, onClose]);
7183
+ const host = anchor.current?.closest(".react-flow")?.parentElement ?? document.body;
7184
+ if (!placement) return null;
7185
+ return createPortal(/* @__PURE__ */ jsx("div", {
7186
+ "data-selector-open": "true",
7187
+ className: "nodrag nopan nowheel fixed z-50 motion-safe:animate-[wf-picker-in_120ms_ease-out]",
7188
+ style: placement.above ? {
7189
+ left: placement.left,
7190
+ bottom: window.innerHeight - placement.top - placement.height,
7191
+ transformOrigin: "bottom center"
7192
+ } : {
7193
+ left: placement.left,
7194
+ top: placement.top,
7195
+ transformOrigin: "top center"
7196
+ },
7197
+ children: props.children(placement)
7198
+ }), host);
7199
+ }
7200
+ //#endregion
7201
+ //#region editors/workflow-editor/ui/picker-recent.ts
7202
+ const STORAGE_KEY = "ph-workflow-picker-recent:v1";
7203
+ const MAX_RECENT = 6;
7204
+ function isStoredPick(value) {
7205
+ const entry = value;
7206
+ const block = entry?.block;
7207
+ return typeof entry?.label === "string" && typeof block?.pieceName === "string" && typeof block.name === "string" && (block.kind === "action" || block.kind === "trigger");
7208
+ }
7209
+ function readAll() {
7210
+ try {
7211
+ const raw = window.localStorage.getItem(STORAGE_KEY);
7212
+ const parsed = raw ? JSON.parse(raw) : [];
7213
+ return Array.isArray(parsed) ? parsed.filter(isStoredPick) : [];
7214
+ } catch {
7215
+ return [];
7216
+ }
7217
+ }
7218
+ function recentPicks(kind) {
7219
+ return readAll().filter((entry) => entry.block.kind === kind).map((entry) => ({
7220
+ label: entry.label,
7221
+ description: entry.description ?? "",
7222
+ block: entry.block,
7223
+ defaultConfig: {}
7224
+ }));
7225
+ }
7226
+ function rememberPick(preset) {
7227
+ const { pieceName, kind, name } = preset.block;
7228
+ const entry = {
7229
+ label: preset.label,
7230
+ description: preset.description,
7231
+ block: {
7232
+ pieceName,
7233
+ kind,
7234
+ name
7235
+ }
7236
+ };
7237
+ const same = (other) => other.block.pieceName === pieceName && other.block.kind === kind && other.block.name === name;
7238
+ const all = readAll();
7239
+ const ofKind = all.filter((other) => other.block.kind === kind);
7240
+ const others = all.filter((other) => other.block.kind !== kind);
7241
+ const next = [entry, ...ofKind.filter((other) => !same(other))].slice(0, MAX_RECENT);
7242
+ try {
7243
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify([...next, ...others]));
7244
+ } catch {}
7245
+ }
7246
+ //#endregion
7247
+ //#region editors/workflow-editor/ui/VirtualList.tsx
7248
+ const OVERSCAN = 6;
7249
+ function rowOffsets(heights) {
7250
+ const offsets = [0];
7251
+ for (const height of heights) offsets.push(offsets.at(-1) + height);
7252
+ return offsets;
7253
+ }
7254
+ function visibleRange(offsets, scrollTop, height, overscan = OVERSCAN) {
7255
+ const count = offsets.length - 1;
7256
+ let start = 0;
7257
+ while (start < count && offsets[start + 1] <= scrollTop) start++;
7258
+ let end = start;
7259
+ while (end < count && offsets[end] < scrollTop + height) end++;
7260
+ return [Math.max(0, start - overscan), Math.min(count, end + overscan)];
7261
+ }
7262
+ function VirtualList(props) {
7263
+ const ref = useRef(null);
7264
+ const [scrollTop, setScrollTop] = useState(0);
7265
+ const [height, setHeight] = useState(400);
7266
+ const offsets = useMemo(() => rowOffsets(props.items.map(props.heightOf)), [props.items, props.heightOf]);
7267
+ useLayoutEffect(() => {
7268
+ const element = ref.current;
7269
+ if (!element) return;
7270
+ const observer = new ResizeObserver(() => setHeight(element.clientHeight));
7271
+ observer.observe(element);
7272
+ setHeight(element.clientHeight);
7273
+ return () => observer.disconnect();
7274
+ }, []);
7275
+ useEffect(() => {
7276
+ if (ref.current) ref.current.scrollTop = 0;
7277
+ }, [props.resetKey]);
7278
+ useEffect(() => {
7279
+ const element = ref.current;
7280
+ const index = props.activeIndex;
7281
+ if (!element || index === void 0 || index < 0) return;
7282
+ const top = offsets.at(index);
7283
+ const bottom = offsets.at(index + 1);
7284
+ if (top === void 0 || bottom === void 0) return;
7285
+ if (top < element.scrollTop) element.scrollTop = top;
7286
+ else if (bottom > element.scrollTop + element.clientHeight) element.scrollTop = bottom - element.clientHeight;
7287
+ }, [props.activeIndex, offsets]);
7288
+ const [start, end] = visibleRange(offsets, scrollTop, height);
7289
+ return /* @__PURE__ */ jsx("div", {
7290
+ ref,
7291
+ id: props.id,
7292
+ role: "listbox",
7293
+ "aria-label": props.label,
7294
+ className: `min-h-0 overflow-y-auto ${props.className ?? ""}`,
7295
+ onScroll: (event) => setScrollTop(event.currentTarget.scrollTop),
7296
+ children: /* @__PURE__ */ jsx("div", {
7297
+ role: "presentation",
7298
+ style: {
7299
+ height: offsets.at(-1),
7300
+ position: "relative"
7301
+ },
7302
+ children: props.items.slice(start, end).map((item, i) => {
7303
+ const index = start + i;
7304
+ return /* @__PURE__ */ jsx("div", {
7305
+ role: "presentation",
7306
+ style: {
7307
+ position: "absolute",
7308
+ top: offsets[index],
7309
+ left: 0,
7310
+ right: 0,
7311
+ height: offsets[index + 1] - offsets[index]
7312
+ },
7313
+ children: props.render(item, index)
7314
+ }, props.keyOf(item, index));
7315
+ })
7316
+ })
7317
+ });
7318
+ }
7319
+ //#endregion
7109
7320
  //#region editors/workflow-editor/ui/BlockSelector.tsx
7110
7321
  const ROW_LOGO = 24;
7111
7322
  const CORE_TILE = {
@@ -7210,33 +7421,55 @@ function LogoFrame(props) {
7210
7421
  });
7211
7422
  }
7212
7423
  function Row(props) {
7213
- return /* @__PURE__ */ jsxs("button", {
7214
- type: "button",
7215
- className: `group 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"}`,
7216
- disabled: props.disabled,
7217
- onClick: props.onClick,
7424
+ return /* @__PURE__ */ jsxs("div", {
7425
+ ...optionAttributes(props.option),
7426
+ role: "option",
7427
+ "aria-selected": (props.active ?? false) || (props.selected ?? false),
7428
+ "aria-disabled": props.disabled,
7429
+ className: `group mx-1.5 my-px flex h-[calc(100%-2px)] cursor-pointer items-center gap-2.5 rounded-md px-2 text-left ${rowTone(props.active, props.selected)} ${props.disabled ? "cursor-not-allowed opacity-50" : ""}`,
7430
+ title: props.title,
7431
+ onClick: props.disabled ? void 0 : props.onClick,
7432
+ onMouseDown: (event) => event.preventDefault(),
7218
7433
  onMouseEnter: props.onHover,
7219
- onFocus: props.onHover,
7220
7434
  children: [
7221
- props.logo,
7435
+ /* @__PURE__ */ jsx("span", {
7436
+ "aria-hidden": "true",
7437
+ className: "contents",
7438
+ children: props.logo
7439
+ }),
7222
7440
  /* @__PURE__ */ jsxs("span", {
7223
7441
  className: "min-w-0",
7224
7442
  children: [/* @__PURE__ */ jsx("span", {
7225
- className: "block truncate text-xs font-medium text-foreground",
7443
+ className: "block truncate text-[13px] font-medium leading-[18px] text-foreground",
7226
7444
  children: props.label
7227
7445
  }), /* @__PURE__ */ jsx("span", {
7228
- className: "block truncate text-[11px] text-muted-foreground/80",
7446
+ className: `text-xs leading-4 text-muted-foreground ${props.tall ? "line-clamp-2" : "block truncate"}`,
7229
7447
  children: props.description
7230
7448
  })]
7231
7449
  }),
7232
7450
  props.version ? /* @__PURE__ */ jsxs("span", {
7233
- className: `ml-auto shrink-0 pl-2 text-[10px] tabular-nums text-muted-foreground/70 ${props.versionNote ? "" : "hidden group-hover:inline group-focus-visible:inline"}`,
7451
+ className: `ml-auto shrink-0 pl-2 text-[11px] tabular-nums text-muted-foreground ${props.versionNote ? "" : props.active ? "" : "hidden group-hover:inline"}`,
7234
7452
  title: props.versionNote ?? `Pinned to version ${props.version}`,
7235
7453
  children: ["v", props.version]
7236
7454
  }) : null
7237
7455
  ]
7238
7456
  });
7239
7457
  }
7458
+ function rowTone(active, selected) {
7459
+ if (active) return "bg-wf-run/10 ring-1 ring-inset ring-wf-run/25";
7460
+ if (selected) return "bg-card shadow-sm ring-1 ring-foreground/10";
7461
+ return "hover:bg-foreground/[0.05]";
7462
+ }
7463
+ function optionId(list, index) {
7464
+ return `${list}-${index}`;
7465
+ }
7466
+ function optionAttributes(place) {
7467
+ return place ? {
7468
+ id: optionId(place.list, place.index),
7469
+ "aria-posinset": place.index + 1,
7470
+ "aria-setsize": place.size
7471
+ } : {};
7472
+ }
7240
7473
  function shownVersion(pieceName, version) {
7241
7474
  return isCoreBlock({ pieceName }) ? void 0 : version;
7242
7475
  }
@@ -7246,16 +7479,11 @@ function useVersionNote(catalog) {
7246
7479
  if (!piece || !version) return void 0;
7247
7480
  const others = [...new Set(draft.filter((block) => block.pieceName === piece && block.pieceVersion !== version).map((block) => `v${block.pieceVersion}`))];
7248
7481
  if (others.length > 0) return `Other steps of this workflow use ${others.join(", ")}`;
7482
+ if (piece === "@powerhousedao/piece-reactor") return void 0;
7249
7483
  const published = catalog?.find((entry) => entry.name === piece)?.publishedVersion;
7250
7484
  return published && published !== version ? `A local build; v${published} is published` : void 0;
7251
7485
  };
7252
7486
  }
7253
- function SectionLabel(props) {
7254
- return /* @__PURE__ */ jsx("div", {
7255
- className: "px-3 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/60",
7256
- children: props.children
7257
- });
7258
- }
7259
7487
  const CATEGORY_LABELS = {
7260
7488
  ARTIFICIAL_INTELLIGENCE: "AI",
7261
7489
  UNIVERSAL_AI: "AI",
@@ -7275,8 +7503,6 @@ const CATEGORY_LABELS = {
7275
7503
  PAYMENT_PROCESSING: "Payments",
7276
7504
  HUMAN_RESOURCES: "HR"
7277
7505
  };
7278
- const CORE_CHIP = "Core";
7279
- const POWERHOUSE_CHIP = "Powerhouse";
7280
7506
  const AI_CHIP = "AI";
7281
7507
  function categoryLabel(id) {
7282
7508
  return CATEGORY_LABELS[id] ?? id.toLowerCase().replaceAll("_", " ").replace(/^\w/, (char) => char.toUpperCase());
@@ -7284,111 +7510,84 @@ function categoryLabel(id) {
7284
7510
  function chipsOf(piece) {
7285
7511
  return new Set(piece.categories.map(categoryLabel));
7286
7512
  }
7513
+ function categoriesOfChip(chip, pieces) {
7514
+ return [...new Set(pieces.flatMap((piece) => piece.categories))].filter((id) => categoryLabel(id) === chip);
7515
+ }
7287
7516
  function orderChips(pieces) {
7288
7517
  const counts = /* @__PURE__ */ new Map();
7289
7518
  for (const piece of pieces) for (const chip of chipsOf(piece)) counts.set(chip, (counts.get(chip) ?? 0) + 1);
7290
7519
  const rest = [...counts.entries()].filter(([chip]) => chip !== AI_CHIP).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([chip]) => chip);
7291
- return [
7292
- CORE_CHIP,
7293
- POWERHOUSE_CHIP,
7294
- ...counts.has(AI_CHIP) ? [AI_CHIP] : [],
7295
- ...rest
7296
- ];
7520
+ return [...counts.has(AI_CHIP) ? [AI_CHIP] : [], ...rest];
7297
7521
  }
7298
- function PieceEntries(props) {
7299
- const [entries, setEntries] = useState(null);
7300
- const [error, setError] = useState(null);
7301
- const pieceSource = usePieceSource();
7302
- useEffect(() => {
7303
- let cancelled = false;
7304
- (props.mode === "triggers" ? pieceSource?.loadTriggers(props.piece.name) : pieceSource?.loadActions(props.piece.name))?.then((result) => {
7305
- if (!cancelled) setEntries(result);
7306
- }).catch((loadError) => {
7307
- if (!cancelled) setError(loadError instanceof Error ? loadError.message : String(loadError));
7308
- });
7309
- return () => {
7310
- cancelled = true;
7311
- };
7312
- }, [
7313
- props.piece.name,
7314
- props.mode,
7315
- pieceSource
7316
- ]);
7317
- return /* @__PURE__ */ jsxs("div", {
7318
- className: "max-h-80 overflow-y-auto py-1",
7319
- children: [/* @__PURE__ */ jsxs("button", {
7320
- type: "button",
7321
- className: "flex w-full items-center gap-1 px-3 py-1 text-[11px] text-muted-foreground/80 hover:text-muted-foreground",
7322
- onClick: props.onBack,
7323
- children: ["← ", props.piece.displayName]
7324
- }), error ? /* @__PURE__ */ jsx("div", {
7325
- className: "px-3 py-2 text-xs text-wf-fail",
7326
- children: error
7327
- }) : entries === null ? /* @__PURE__ */ jsx("div", {
7328
- className: "px-3 py-2 text-xs text-muted-foreground/80",
7329
- children: "Loading…"
7330
- }) : entries.map((entry) => {
7331
- const kind = props.mode === "triggers" ? "trigger" : "action";
7332
- const unavailable = blockUnavailable({
7333
- ...entry,
7334
- kind
7335
- });
7336
- const block = {
7337
- pieceName: entry.pieceName,
7338
- pieceVersion: entry.pieceVersion,
7339
- kind,
7340
- name: entry.name
7341
- };
7342
- return /* @__PURE__ */ jsx(Row, {
7343
- logo: /* @__PURE__ */ jsx(LogoFrame, {
7344
- src: props.piece.logoUrl,
7345
- alt: props.piece.displayName,
7346
- size: ROW_LOGO
7347
- }),
7348
- label: entry.displayName,
7349
- description: unavailable ?? entry.description,
7350
- disabled: unavailable !== void 0,
7351
- version: shownVersion(entry.pieceName, entry.pieceVersion),
7352
- versionNote: props.versionNote(props.piece.name, entry.pieceVersion),
7353
- onHover: unavailable === void 0 ? () => props.onHover(block) : void 0,
7354
- onClick: () => props.onPick({
7355
- label: entry.displayName,
7356
- block,
7357
- description: entry.description,
7358
- defaultConfig: {}
7359
- })
7360
- }, entry.name);
7361
- })]
7362
- });
7522
+ const TAB_LABELS = {
7523
+ all: "All",
7524
+ core: "Core",
7525
+ powerhouse: "Powerhouse",
7526
+ activepieces: "Integrations"
7527
+ };
7528
+ const TAB_SOURCES = {
7529
+ all: void 0,
7530
+ core: [],
7531
+ powerhouse: ["local", "registry"],
7532
+ activepieces: ["activepieces"]
7533
+ };
7534
+ function inTab(tab, piece) {
7535
+ const sources = TAB_SOURCES[tab];
7536
+ return sources === void 0 || sources.includes(piece.source ?? "activepieces");
7537
+ }
7538
+ function folded(text) {
7539
+ return text.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase();
7540
+ }
7541
+ function queryTokens(query) {
7542
+ return folded(query).split(/[^\p{L}\p{N}]+/u).filter(Boolean);
7543
+ }
7544
+ function matchesQuery(text, tokens) {
7545
+ const lowered = folded(text);
7546
+ return tokens.every((token) => lowered.includes(token));
7547
+ }
7548
+ function escapeRegExp(text) {
7549
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7550
+ }
7551
+ function Highlight(props) {
7552
+ if (props.tokens.length === 0) return /* @__PURE__ */ jsx(Fragment$1, { children: props.text });
7553
+ const pattern = new RegExp(`(?<![\\p{L}\\p{N}])(${props.tokens.map(escapeRegExp).join("|")})`, "giu");
7554
+ const parts = props.text.split(pattern);
7555
+ return /* @__PURE__ */ jsx(Fragment$1, { children: parts.map((part, i) => i % 2 === 1 ? /* @__PURE__ */ jsx("mark", {
7556
+ className: "bg-transparent font-semibold text-inherit",
7557
+ children: part
7558
+ }, i) : part) });
7363
7559
  }
7364
7560
  const SEARCH_MIN_CHARS = 2;
7365
7561
  const SEARCH_DEBOUNCE_MS = 250;
7366
7562
  const INDEXING_RETRY_MS = 2e3;
7367
- function useBlockSearch(query, enabled) {
7563
+ function usePieceSearch(query, filter) {
7368
7564
  const [state, setState] = useState({ kind: "idle" });
7369
7565
  const [attempt, setAttempt] = useState(0);
7370
7566
  const trimmed = query.trim();
7371
- const active = enabled && trimmed.length >= SEARCH_MIN_CHARS;
7372
- const search = usePieceSource()?.searchBlocks;
7567
+ const search = usePieceSource()?.searchPieces;
7568
+ const active = filter !== null && search !== void 0 && trimmed.length >= SEARCH_MIN_CHARS;
7569
+ const filterKey = JSON.stringify(filter);
7570
+ const key = `${trimmed}\n${filterKey}`;
7373
7571
  useEffect(() => {
7374
- if (!active || !search) {
7572
+ if (!active) {
7375
7573
  setState({ kind: "idle" });
7376
7574
  return;
7377
7575
  }
7378
7576
  let alive = true;
7379
7577
  let retry;
7380
7578
  const timer = setTimeout(() => {
7381
- setState((previous) => previous.kind === "done" ? previous : { kind: "loading" });
7382
- search(trimmed).then((result) => {
7579
+ search(trimmed, JSON.parse(filterKey)).then((result) => {
7383
7580
  if (!alive) return;
7384
7581
  setState({
7385
7582
  kind: "done",
7583
+ key,
7386
7584
  result
7387
7585
  });
7388
7586
  if (result.status === "indexing") retry = setTimeout(() => setAttempt((value) => value + 1), INDEXING_RETRY_MS);
7389
7587
  }, (error) => {
7390
7588
  if (alive) setState({
7391
7589
  kind: "error",
7590
+ key,
7392
7591
  message: error instanceof Error ? error.message : String(error)
7393
7592
  });
7394
7593
  });
@@ -7401,32 +7600,431 @@ function useBlockSearch(query, enabled) {
7401
7600
  }, [
7402
7601
  active,
7403
7602
  trimmed,
7603
+ filterKey,
7604
+ key,
7404
7605
  attempt,
7405
7606
  search
7406
7607
  ]);
7407
- return active ? state : { kind: "idle" };
7608
+ if (!active) return { kind: "idle" };
7609
+ if (state.kind === "idle") return { kind: "loading" };
7610
+ if (state.kind === "error") return state.key === key ? {
7611
+ kind: "error",
7612
+ message: state.message
7613
+ } : { kind: "loading" };
7614
+ return {
7615
+ kind: "done",
7616
+ result: state.result,
7617
+ stale: state.key !== key
7618
+ };
7619
+ }
7620
+ function rovingFocus(event) {
7621
+ const delta = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
7622
+ if (delta === 0) return;
7623
+ event.preventDefault();
7624
+ const buttons = [...event.currentTarget.querySelectorAll("button")];
7625
+ const at = buttons.indexOf(document.activeElement);
7626
+ buttons.at((at + delta) % buttons.length)?.focus();
7408
7627
  }
7409
7628
  function Chip(props) {
7410
7629
  return /* @__PURE__ */ jsx("button", {
7411
7630
  type: "button",
7412
- 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"}`,
7413
- onClick: props.onClick,
7631
+ "aria-pressed": props.active,
7632
+ tabIndex: props.tabStop ? 0 : -1,
7633
+ className: `shrink-0 rounded-full border px-2.5 py-0.5 text-[11px] font-medium focus-visible:outline-2 focus-visible:outline-wf-run ${props.active ? "border-wf-run/40 bg-wf-run/10 text-wf-run" : "border-foreground/10 text-muted-foreground hover:border-foreground/25 hover:text-foreground"}`,
7634
+ onClick: (event) => props.onClick(event.detail === 0),
7414
7635
  children: props.label
7415
7636
  });
7416
7637
  }
7638
+ function ChipBar(props) {
7639
+ const ref = useRef(null);
7640
+ const [more, setMore] = useState({
7641
+ left: false,
7642
+ right: false
7643
+ });
7644
+ const measure = () => {
7645
+ const element = ref.current;
7646
+ if (!element) return;
7647
+ const left = element.scrollLeft > 1;
7648
+ const right = element.scrollLeft + element.clientWidth < element.scrollWidth - 1;
7649
+ setMore((previous) => previous.left === left && previous.right === right ? previous : {
7650
+ left,
7651
+ right
7652
+ });
7653
+ };
7654
+ useLayoutEffect(() => {
7655
+ const element = ref.current;
7656
+ if (!element) return;
7657
+ const observer = new ResizeObserver(measure);
7658
+ observer.observe(element);
7659
+ return () => observer.disconnect();
7660
+ }, []);
7661
+ const fade = (side) => /* @__PURE__ */ jsx("span", {
7662
+ "aria-hidden": "true",
7663
+ className: "pointer-events-none absolute inset-y-0 w-14",
7664
+ style: {
7665
+ [side]: 0,
7666
+ background: `linear-gradient(to ${side === "left" ? "right" : "left"}, var(--card), transparent)`
7667
+ }
7668
+ });
7669
+ return /* @__PURE__ */ jsxs("div", {
7670
+ className: "relative shrink-0 border-b border-foreground/10",
7671
+ children: [
7672
+ /* @__PURE__ */ jsx("div", {
7673
+ ref,
7674
+ role: "toolbar",
7675
+ "aria-label": "Categories",
7676
+ className: "flex gap-1.5 overflow-x-auto whitespace-nowrap px-3 py-2 [scrollbar-width:none]",
7677
+ onKeyDown: rovingFocus,
7678
+ onScroll: measure,
7679
+ children: props.children
7680
+ }),
7681
+ more.left ? fade("left") : null,
7682
+ more.right ? fade("right") : null
7683
+ ]
7684
+ });
7685
+ }
7686
+ function Tabs(props) {
7687
+ return /* @__PURE__ */ jsx("div", {
7688
+ role: "tablist",
7689
+ "aria-label": "Piece sources",
7690
+ className: "inline-flex gap-0.5 rounded-md bg-foreground/[0.05] p-0.5",
7691
+ onKeyDown: (event) => {
7692
+ rovingFocus(event);
7693
+ const tab = document.activeElement?.dataset.tab;
7694
+ if (tab && tab !== props.active) props.onSelect(tab, true);
7695
+ },
7696
+ children: props.tabs.map((tab) => /* @__PURE__ */ jsx("button", {
7697
+ type: "button",
7698
+ role: "tab",
7699
+ "data-tab": tab,
7700
+ "aria-selected": props.active === tab,
7701
+ tabIndex: props.active === tab ? 0 : -1,
7702
+ className: `rounded px-2.5 py-1 text-xs font-medium focus-visible:outline-2 focus-visible:outline-wf-run ${props.active === tab ? "bg-card text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
7703
+ onClick: (event) => props.onSelect(tab, event.detail === 0),
7704
+ children: TAB_LABELS[tab]
7705
+ }, tab))
7706
+ });
7707
+ }
7708
+ function Status(props) {
7709
+ return /* @__PURE__ */ jsx("div", {
7710
+ role: "status",
7711
+ className: `px-4 py-2.5 text-xs ${props.error ? "text-wf-fail" : "text-muted-foreground"}`,
7712
+ children: props.children
7713
+ });
7714
+ }
7715
+ const ROW_HEIGHT = 46;
7716
+ const BLOCK_HEIGHT = 60;
7717
+ const HEADER_LOGO = 36;
7718
+ const HEADER_HEIGHT = 38;
7719
+ const MORE_HEIGHT = 28;
7720
+ const GROUP_BLOCKS = 4;
7721
+ const HOVER_PREVIEW_MS = 120;
7722
+ const searchRowHeight = (row) => row.type === "entry" ? BLOCK_HEIGHT : row.type === "more" ? MORE_HEIGHT : HEADER_HEIGHT;
7723
+ const sourceHeight = () => ROW_HEIGHT;
7724
+ const entryHeight = () => BLOCK_HEIGHT;
7725
+ function listTile(icon, color) {
7726
+ return (size) => /* @__PURE__ */ jsx(CoreTile, {
7727
+ tile: {
7728
+ icon,
7729
+ color
7730
+ },
7731
+ size
7732
+ });
7733
+ }
7734
+ function EntryRow(props) {
7735
+ const { entry } = props;
7736
+ return /* @__PURE__ */ jsx(Row, {
7737
+ logo: props.indent ? /* @__PURE__ */ jsx("span", {
7738
+ className: "shrink-0",
7739
+ style: { width: ROW_LOGO }
7740
+ }) : entry.logo,
7741
+ label: /* @__PURE__ */ jsx(Highlight, {
7742
+ text: entry.label,
7743
+ tokens: props.tokens
7744
+ }),
7745
+ title: entry.description || entry.label,
7746
+ description: entry.unavailable ?? /* @__PURE__ */ jsx(Highlight, {
7747
+ text: entry.description,
7748
+ tokens: props.tokens
7749
+ }),
7750
+ disabled: entry.unavailable !== void 0,
7751
+ active: props.active,
7752
+ tall: true,
7753
+ option: props.option,
7754
+ version: entry.version,
7755
+ versionNote: entry.versionNote,
7756
+ onHover: () => {
7757
+ props.onActivate();
7758
+ if (entry.unavailable === void 0) entry.warm?.();
7759
+ },
7760
+ onClick: entry.pick
7761
+ });
7762
+ }
7763
+ function SourceRow(props) {
7764
+ const { source } = props;
7765
+ if (source.kind === "list") return /* @__PURE__ */ jsx(Row, {
7766
+ logo: source.logo(ROW_LOGO),
7767
+ label: source.title,
7768
+ description: source.subtitle,
7769
+ active: props.active,
7770
+ selected: props.selected,
7771
+ option: props.option,
7772
+ onHover: props.onActivate,
7773
+ onClick: props.onOpen
7774
+ });
7775
+ const { piece } = source;
7776
+ const count = props.mode === "triggers" ? piece.triggerCount : piece.actionCount;
7777
+ const noun = props.mode === "triggers" ? "trigger" : "action";
7778
+ return /* @__PURE__ */ jsx(Row, {
7779
+ logo: /* @__PURE__ */ jsx(LogoFrame, {
7780
+ src: piece.logoUrl,
7781
+ alt: piece.displayName,
7782
+ size: ROW_LOGO
7783
+ }),
7784
+ label: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Highlight, {
7785
+ text: piece.displayName,
7786
+ tokens: props.tokens
7787
+ }), piece.deprecated ? " (deprecated)" : ""] }),
7788
+ title: piece.description || piece.displayName,
7789
+ description: piece.unsupported ?? `${count} ${noun}${count === 1 ? "" : "s"}`,
7790
+ active: props.active,
7791
+ selected: props.selected,
7792
+ option: props.option,
7793
+ onHover: props.onActivate,
7794
+ onClick: props.onOpen
7795
+ });
7796
+ }
7797
+ function usePieceEntries(piece, mode) {
7798
+ const pieceSource = usePieceSource();
7799
+ const [state, setState] = useState(null);
7800
+ const name = piece?.name;
7801
+ useEffect(() => {
7802
+ if (!name || !pieceSource) return;
7803
+ let cancelled = false;
7804
+ (mode === "triggers" ? pieceSource.loadTriggers(name) : pieceSource.loadActions(name)).then((entries) => {
7805
+ if (!cancelled) setState({
7806
+ name,
7807
+ entries,
7808
+ error: null
7809
+ });
7810
+ }, (error) => {
7811
+ if (!cancelled) setState({
7812
+ name,
7813
+ entries: null,
7814
+ error: error instanceof Error ? error.message : String(error)
7815
+ });
7816
+ });
7817
+ return () => {
7818
+ cancelled = true;
7819
+ };
7820
+ }, [
7821
+ name,
7822
+ mode,
7823
+ pieceSource
7824
+ ]);
7825
+ return state && state.name === name ? {
7826
+ entries: state.entries,
7827
+ error: state.error
7828
+ } : {
7829
+ entries: null,
7830
+ error: null
7831
+ };
7832
+ }
7833
+ function EntriesPane(props) {
7834
+ const { source } = props;
7835
+ const entries = source?.kind === "list" ? source.entries : props.pieceEntries;
7836
+ const kind = props.mode === "triggers" ? "trigger" : "action";
7837
+ const title = source?.kind === "list" ? source.title : source?.piece.displayName;
7838
+ const about = source?.kind === "list" ? source.subtitle : source?.piece.description;
7839
+ return /* @__PURE__ */ jsxs("div", {
7840
+ className: "flex min-h-0 min-w-0 flex-1 flex-col",
7841
+ children: [source && props.showHeader ? /* @__PURE__ */ jsxs("div", {
7842
+ className: "flex shrink-0 items-start gap-3 border-b border-foreground/10 px-4 py-3",
7843
+ children: [/* @__PURE__ */ jsx("span", {
7844
+ "aria-hidden": "true",
7845
+ className: "contents",
7846
+ children: source.kind === "list" ? source.logo(HEADER_LOGO) : /* @__PURE__ */ jsx(LogoFrame, {
7847
+ src: source.piece.logoUrl,
7848
+ alt: "",
7849
+ size: HEADER_LOGO
7850
+ })
7851
+ }), /* @__PURE__ */ jsxs("div", {
7852
+ className: "min-w-0",
7853
+ children: [/* @__PURE__ */ jsx("div", {
7854
+ className: "truncate text-sm font-semibold leading-5 text-foreground",
7855
+ children: title
7856
+ }), about ? /* @__PURE__ */ jsx("div", {
7857
+ className: "line-clamp-2 text-xs leading-4 text-muted-foreground",
7858
+ title: about,
7859
+ children: about
7860
+ }) : null]
7861
+ })]
7862
+ }) : null, !source ? /* @__PURE__ */ jsxs(Status, { children: [
7863
+ "Pick a piece to see its ",
7864
+ kind,
7865
+ "s"
7866
+ ] }) : props.pieceError ? /* @__PURE__ */ jsx(Status, {
7867
+ error: true,
7868
+ children: props.pieceError
7869
+ }) : entries === null ? /* @__PURE__ */ jsx(Status, { children: "Loading…" }) : entries.length === 0 ? /* @__PURE__ */ jsxs(Status, { children: [
7870
+ "No ",
7871
+ kind,
7872
+ "s"
7873
+ ] }) : /* @__PURE__ */ jsx(VirtualList, {
7874
+ id: props.listId,
7875
+ resetKey: source.id,
7876
+ label: `${title ?? ""} ${kind}s`,
7877
+ className: "flex-1 py-1",
7878
+ items: entries,
7879
+ heightOf: entryHeight,
7880
+ keyOf: (entry) => entry.key,
7881
+ activeIndex: props.activeIndex,
7882
+ render: (entry, index) => /* @__PURE__ */ jsx(EntryRow, {
7883
+ entry,
7884
+ tokens: props.tokens,
7885
+ active: index === props.activeIndex,
7886
+ option: {
7887
+ list: props.listId,
7888
+ index,
7889
+ size: entries.length
7890
+ },
7891
+ onActivate: () => props.onActivate(index)
7892
+ })
7893
+ })]
7894
+ });
7895
+ }
7896
+ function SearchList(props) {
7897
+ const size = props.rows.length;
7898
+ return /* @__PURE__ */ jsxs("div", {
7899
+ className: "flex min-h-0 flex-1 flex-col",
7900
+ children: [props.status, /* @__PURE__ */ jsx(VirtualList, {
7901
+ id: props.listId,
7902
+ label: "Search results",
7903
+ resetKey: props.resetKey,
7904
+ className: `flex-1 py-1 ${props.stale ? "opacity-60" : ""}`,
7905
+ items: props.rows,
7906
+ heightOf: searchRowHeight,
7907
+ keyOf: (row, index) => row.type === "entry" ? `e:${row.entry.key}` : row.type === "piece" ? `p:${row.match.pieceName}` : row.type === "list" ? `l:${row.source.id}` : `m:${row.pieceName}:${index}`,
7908
+ activeIndex: props.activeIndex,
7909
+ render: (row, index) => {
7910
+ const active = index === props.activeIndex;
7911
+ const activate = () => props.onActivate(index);
7912
+ const option = {
7913
+ list: props.listId,
7914
+ index,
7915
+ size
7916
+ };
7917
+ if (row.type === "entry") return /* @__PURE__ */ jsx(EntryRow, {
7918
+ entry: row.entry,
7919
+ tokens: props.tokens,
7920
+ active,
7921
+ option,
7922
+ indent: true,
7923
+ onActivate: activate
7924
+ });
7925
+ if (row.type === "more") return /* @__PURE__ */ jsxs("div", {
7926
+ ...optionAttributes(option),
7927
+ role: "option",
7928
+ "aria-selected": active,
7929
+ className: `mx-1.5 my-px flex h-[calc(100%-2px)] cursor-pointer items-center rounded-md pl-[42px] text-xs text-muted-foreground hover:text-foreground ${rowTone(active)}`,
7930
+ onMouseDown: (event) => event.preventDefault(),
7931
+ onMouseEnter: activate,
7932
+ onClick: () => props.onExpand(row.pieceName),
7933
+ children: [row.hidden, " more…"]
7934
+ });
7935
+ const header = row.type === "piece" ? {
7936
+ logo: /* @__PURE__ */ jsx(LogoFrame, {
7937
+ src: row.match.logoUrl,
7938
+ alt: row.match.displayName,
7939
+ size: 20
7940
+ }),
7941
+ label: row.match.displayName,
7942
+ note: row.match.deprecated ? "Deprecated" : row.match.unsupported ?? void 0,
7943
+ kind: props.kind,
7944
+ open: () => props.onOpenPiece(row.match.pieceName)
7945
+ } : {
7946
+ logo: row.source.logo(20),
7947
+ label: row.source.title,
7948
+ note: void 0,
7949
+ kind: props.kind,
7950
+ open: () => props.onOpenList(row.source.id)
7951
+ };
7952
+ return /* @__PURE__ */ jsxs("div", {
7953
+ ...optionAttributes(option),
7954
+ role: "option",
7955
+ "aria-selected": active,
7956
+ title: `Open ${header.label}`,
7957
+ className: `group mx-1.5 mt-1 flex h-[calc(100%-4px)] cursor-pointer items-center gap-2.5 rounded-md px-2 text-left ${rowTone(active)}`,
7958
+ onMouseDown: (event) => event.preventDefault(),
7959
+ onMouseEnter: activate,
7960
+ onClick: header.open,
7961
+ children: [
7962
+ /* @__PURE__ */ jsx("span", {
7963
+ "aria-hidden": "true",
7964
+ className: "contents",
7965
+ children: header.logo
7966
+ }),
7967
+ /* @__PURE__ */ jsx("span", {
7968
+ className: "truncate text-[13px] font-semibold text-foreground",
7969
+ children: /* @__PURE__ */ jsx(Highlight, {
7970
+ text: header.label,
7971
+ tokens: props.tokens
7972
+ })
7973
+ }),
7974
+ header.note ? /* @__PURE__ */ jsx("span", {
7975
+ className: "truncate text-[11px] text-muted-foreground",
7976
+ children: header.note
7977
+ }) : null,
7978
+ /* @__PURE__ */ jsxs("span", {
7979
+ className: `ml-auto flex shrink-0 items-center gap-0.5 text-[11px] text-muted-foreground ${active ? "" : "opacity-0 group-hover:opacity-100"}`,
7980
+ children: [
7981
+ "All ",
7982
+ header.kind,
7983
+ "s",
7984
+ /* @__PURE__ */ jsx(Icon, {
7985
+ name: "chevron",
7986
+ size: 12
7987
+ })
7988
+ ]
7989
+ })
7990
+ ]
7991
+ });
7992
+ }
7993
+ })]
7994
+ });
7995
+ }
7417
7996
  function BlockSelector(props) {
7418
7997
  const [query, setQuery] = useState("");
7998
+ const [tab, setTab] = useState("all");
7419
7999
  const [chip, setChip] = useState(null);
7420
8000
  const [catalog, setCatalog] = useState(null);
7421
- const [piece, setPiece] = useState(null);
8001
+ const [selectedId, setSelectedId] = useState(null);
8002
+ const [paneState, setPane] = useState("sources");
8003
+ const [entryIndex, setEntryIndex] = useState(-1);
8004
+ const [rowIndex, setRowIndex] = useState(-1);
8005
+ const [expanded, setExpanded] = useState(/* @__PURE__ */ new Set());
7422
8006
  const containerRef = useRef(null);
8007
+ const inputRef = useRef(null);
8008
+ const baseId = useId();
8009
+ const listIds = {
8010
+ sources: `${baseId}-sources`,
8011
+ entries: `${baseId}-entries`,
8012
+ results: `${baseId}-results`
8013
+ };
8014
+ const pointerMoved = useRef(false);
8015
+ const hoverTimer = useRef(void 0);
8016
+ const { anchor, onClose } = props;
7423
8017
  useEffect(() => {
7424
8018
  const handler = (event) => {
7425
- if (!containerRef.current?.contains(event.target)) props.onClose();
8019
+ const target = event.target;
8020
+ if (containerRef.current?.contains(target)) return;
8021
+ if (anchor?.current?.contains(target)) return;
8022
+ onClose();
7426
8023
  };
7427
- window.addEventListener("mousedown", handler);
7428
- return () => window.removeEventListener("mousedown", handler);
7429
- }, [props]);
8024
+ window.addEventListener("pointerdown", handler, true);
8025
+ return () => window.removeEventListener("pointerdown", handler, true);
8026
+ }, [anchor, onClose]);
8027
+ useEffect(() => () => clearTimeout(hoverTimer.current), []);
7430
8028
  const anySource = usePieceSource();
7431
8029
  const pieceSource = props.showPieces ? anySource : void 0;
7432
8030
  const [catalogRound, setCatalogRound] = useState(0);
@@ -7461,176 +8059,496 @@ function BlockSelector(props) {
7461
8059
  const pinned = (preset) => pinBlock(preset.block, installed);
7462
8060
  const pick = (preset) => {
7463
8061
  const block = pinned(preset);
7464
- if (block) props.onPick({
8062
+ if (!block) return;
8063
+ rememberPick(preset);
8064
+ props.onPick({
7465
8065
  ...preset,
7466
8066
  block
7467
8067
  });
7468
8068
  };
7469
8069
  const prefetch = useBlockFormPrefetch();
7470
8070
  const mode = props.pieceMode ?? "actions";
7471
- const lowered = query.toLowerCase();
7472
- const modePieces = useMemo(() => (catalog?.pieces ?? []).filter((entry) => (mode === "triggers" ? entry.triggerCount : entry.actionCount) > 0), [catalog, mode]);
7473
- const chips = useMemo(() => orderChips(modePieces), [modePieces]);
7474
- const chipsByPiece = useMemo(() => new Map(modePieces.map((entry) => [entry.name, chipsOf(entry)])), [modePieces]);
7475
- const inChip = (pieceName) => chip === null || chip === "Core" ? true : chipsByPiece.get(pieceName)?.has(chip) ?? false;
7476
- const showCatalog = pieceSource !== void 0 && !(chip === "Core" || chip === "Powerhouse");
7477
- const matching = props.presets.filter((preset) => `${preset.label} ${preset.block.pieceName} ${preset.block.name}`.toLowerCase().includes(lowered));
7478
- const corePresets = chip === null || chip === "Core" ? matching.filter((preset) => preset.group !== "powerhouse") : [];
7479
- const powerhousePresets = chip === null || chip === "Powerhouse" ? matching.filter((preset) => preset.group === "powerhouse") : [];
7480
- const filteredAttach = (props.onAttach ? props.attachSteps ?? [] : []).filter((step) => `${step.name} ${step.key} ${step.pieceName} ${step.actionName}`.toLowerCase().includes(lowered));
7481
- const filteredPieces = showCatalog ? modePieces.filter((entry) => inChip(entry.name) && `${entry.displayName} ${entry.name} ${entry.description}`.toLowerCase().includes(lowered)) : [];
7482
- const search = useBlockSearch(query, showCatalog && !piece);
7483
- const presetRow = (preset) => {
8071
+ const kind = mode === "triggers" ? "trigger" : "action";
8072
+ const tokens = queryTokens(query);
8073
+ const searching = query.trim().length >= SEARCH_MIN_CHARS;
8074
+ const showCatalog = pieceSource !== void 0 && tab !== "core";
8075
+ const tabs = pieceSource ? [
8076
+ "all",
8077
+ "core",
8078
+ "powerhouse",
8079
+ "activepieces"
8080
+ ] : [
8081
+ "all",
8082
+ "core",
8083
+ "powerhouse"
8084
+ ];
8085
+ const modePieces = useMemo(() => {
8086
+ const presetCounts = /* @__PURE__ */ new Map();
8087
+ for (const preset of props.presets) {
8088
+ const name = preset.block.pieceName;
8089
+ presetCounts.set(name, (presetCounts.get(name) ?? 0) + 1);
8090
+ }
8091
+ return (catalog?.pieces ?? []).filter((entry) => {
8092
+ return (mode === "triggers" ? entry.triggerCount : entry.actionCount) > (presetCounts.get(entry.name) ?? 0);
8093
+ });
8094
+ }, [
8095
+ catalog,
8096
+ mode,
8097
+ props.presets
8098
+ ]);
8099
+ const tabPieces = useMemo(() => modePieces.filter((entry) => inTab(tab, entry)), [modePieces, tab]);
8100
+ const chips = useMemo(() => orderChips(tabPieces), [tabPieces]);
8101
+ const showChips = showCatalog && (tab === "activepieces" || tab === "powerhouse") && chips.length > 1;
8102
+ const activeChip = showChips && chip !== null && chips.includes(chip) ? chip : null;
8103
+ const searchFilter = useMemo(() => showCatalog ? {
8104
+ kind,
8105
+ ...TAB_SOURCES[tab] ? { sources: TAB_SOURCES[tab] } : {},
8106
+ ...activeChip ? { categories: categoriesOfChip(activeChip, tabPieces) } : {}
8107
+ } : null, [
8108
+ showCatalog,
8109
+ kind,
8110
+ tab,
8111
+ activeChip,
8112
+ tabPieces
8113
+ ]);
8114
+ const search = usePieceSearch(query, searchFilter);
8115
+ const presetEntry = (preset) => {
7484
8116
  const block = pinned(preset);
7485
- return /* @__PURE__ */ jsx(Row, {
8117
+ return {
8118
+ key: `${blockKey(preset.block)} ${preset.label}`,
7486
8119
  logo: /* @__PURE__ */ jsx(BlockLogo, {
7487
8120
  block: preset.block,
7488
8121
  size: ROW_LOGO
7489
8122
  }),
7490
8123
  label: preset.label,
7491
- description: block ? preset.description : catalog === null ? "Loading…" : "Not installed on this runtime",
7492
- disabled: !block,
8124
+ description: preset.description,
8125
+ unavailable: block ? void 0 : catalog === null ? "Loading…" : "Not installed on this runtime",
7493
8126
  version: shownVersion(preset.block.pieceName, block?.pieceVersion),
7494
8127
  versionNote: versionNote(preset.block.pieceName, block?.pieceVersion),
7495
- onHover: block ? () => prefetch(block) : void 0,
7496
- onClick: () => pick(preset)
7497
- }, blockKey(preset.block) + preset.label);
8128
+ pick: () => pick(preset),
8129
+ warm: block ? () => prefetch(block) : void 0
8130
+ };
7498
8131
  };
7499
- const labelPresets = showCatalog || filteredAttach.length > 0 || corePresets.length > 0 && powerhousePresets.length > 0;
7500
- const wantedKind = mode === "triggers" ? "trigger" : "action";
7501
- const hits = search.kind === "done" ? search.result.hits.filter((hit) => hit.kind === wantedKind && inChip(hit.pieceName)) : [];
7502
- const searchActive = search.kind !== "idle";
8132
+ const blockEntry = (entry, logo) => {
8133
+ const block = {
8134
+ pieceName: entry.pieceName,
8135
+ pieceVersion: entry.pieceVersion,
8136
+ kind,
8137
+ name: entry.name
8138
+ };
8139
+ return {
8140
+ key: blockKey(block),
8141
+ logo,
8142
+ label: entry.displayName,
8143
+ description: entry.description,
8144
+ unavailable: blockUnavailable({
8145
+ ...entry,
8146
+ kind
8147
+ }),
8148
+ version: shownVersion(entry.pieceName, entry.pieceVersion),
8149
+ versionNote: versionNote(entry.pieceName, entry.pieceVersion),
8150
+ pick: () => pick({
8151
+ label: entry.displayName,
8152
+ block,
8153
+ description: entry.description,
8154
+ defaultConfig: {}
8155
+ }),
8156
+ warm: () => prefetch(block)
8157
+ };
8158
+ };
8159
+ const lists = (() => {
8160
+ if (activeChip !== null) return [];
8161
+ const result = [];
8162
+ const add = (id, title, subtitle, logo, entries) => {
8163
+ if (entries.length > 0) result.push({
8164
+ kind: "list",
8165
+ id,
8166
+ title,
8167
+ subtitle,
8168
+ logo,
8169
+ entries
8170
+ });
8171
+ };
8172
+ if (tab === "all") {
8173
+ if (props.onAttach) add("attach", "Detached steps", "Re-attach a step at this point", listTile("branch", "#64748b"), (props.attachSteps ?? []).map((step) => ({
8174
+ key: `attach ${step.id}`,
8175
+ logo: /* @__PURE__ */ jsx(BlockLogo, {
8176
+ block: stepBlock(step),
8177
+ size: ROW_LOGO
8178
+ }),
8179
+ label: step.name,
8180
+ description: `{{steps.${step.key}}} · detached`,
8181
+ pick: () => props.onAttach?.(step.id)
8182
+ })));
8183
+ }
8184
+ if (tab === "all" || tab === "core") add("core", "Core", "Built into the workflow engine", listTile("bolt", "#2563eb"), props.presets.filter((preset) => preset.group !== "powerhouse").map(presetEntry));
8185
+ if (tab === "all" || tab === "powerhouse") {
8186
+ const reactorPreset = props.presets.find((preset) => preset.group === "powerhouse");
8187
+ add("powerhouse", "Documents", "Read and change documents on this reactor", (size) => reactorPreset ? /* @__PURE__ */ jsx(BlockLogo, {
8188
+ block: reactorPreset.block,
8189
+ size
8190
+ }) : null, props.presets.filter((preset) => preset.group === "powerhouse").map(presetEntry));
8191
+ }
8192
+ if (tab === "all") {
8193
+ const recent = recentPicks(kind).filter((preset) => isCoreBlock(preset.block) || installed(preset.block.pieceName));
8194
+ add("recent", "Recently used", `Your last ${kind}s`, listTile("clock", "#64748b"), recent.map((preset) => {
8195
+ const entry = presetEntry(preset);
8196
+ const reason = catalog?.pieces.find((piece) => piece.name === preset.block.pieceName)?.unsupported;
8197
+ return reason ? {
8198
+ ...entry,
8199
+ unavailable: reason
8200
+ } : entry;
8201
+ }));
8202
+ }
8203
+ return result;
8204
+ })();
8205
+ const sources = (() => {
8206
+ const listSources = lists.map((list) => ({
8207
+ ...list,
8208
+ entries: list.entries.filter((entry) => matchesQuery(`${entry.label} ${entry.description}`, tokens))
8209
+ })).filter((list) => list.entries.length > 0);
8210
+ const pieceSources = showCatalog ? tabPieces.filter((entry) => (activeChip === null || chipsOf(entry).has(activeChip)) && matchesQuery(`${entry.displayName} ${entry.name} ${entry.description}`, tokens)).map((piece) => ({
8211
+ kind: "piece",
8212
+ id: piece.name,
8213
+ piece
8214
+ })) : [];
8215
+ return [...listSources, ...pieceSources];
8216
+ })();
8217
+ const selected = sources.find((source) => source.id === selectedId) ?? sources.at(0);
8218
+ const sourceIndex = selected ? sources.indexOf(selected) : -1;
8219
+ const selectedPiece = selected?.kind === "piece" ? selected.piece : void 0;
8220
+ const loaded = usePieceEntries(selectedPiece, mode);
8221
+ const pieceEntries = selectedPiece && loaded.entries ? loaded.entries.map((entry) => blockEntry(entry, /* @__PURE__ */ jsx(LogoFrame, {
8222
+ src: selectedPiece.logoUrl,
8223
+ alt: selectedPiece.displayName,
8224
+ size: ROW_LOGO
8225
+ }))) : null;
8226
+ const entries = selected?.kind === "list" ? selected.entries : pieceEntries ?? [];
8227
+ const entryAt = entries.length === 0 ? -1 : Math.min(entryIndex, entries.length - 1);
8228
+ const presetKeys = new Set(props.presets.map((preset) => `${preset.block.pieceName} ${preset.block.name}`));
8229
+ const rows = [];
8230
+ if (searching) {
8231
+ for (const source of sources) {
8232
+ if (source.kind !== "list" || source.id === "recent") continue;
8233
+ rows.push({
8234
+ type: "list",
8235
+ source
8236
+ });
8237
+ for (const entry of source.entries) rows.push({
8238
+ type: "entry",
8239
+ entry
8240
+ });
8241
+ }
8242
+ const groups = search.kind === "done" ? search.result.pieces.map((match) => ({
8243
+ ...match,
8244
+ blocks: match.blocks.filter((hit) => !presetKeys.has(`${hit.pieceName} ${hit.name}`))
8245
+ })).filter((match) => match.blocks.length > 0) : [];
8246
+ for (const match of groups) {
8247
+ rows.push({
8248
+ type: "piece",
8249
+ match
8250
+ });
8251
+ const shown = groups.length <= 2 || expanded.has(match.pieceName) ? match.blocks : match.blocks.slice(0, GROUP_BLOCKS);
8252
+ const logo = /* @__PURE__ */ jsx(LogoFrame, {
8253
+ src: match.logoUrl,
8254
+ alt: match.displayName,
8255
+ size: ROW_LOGO
8256
+ });
8257
+ for (const hit of shown) rows.push({
8258
+ type: "entry",
8259
+ entry: blockEntry(hit, logo)
8260
+ });
8261
+ if (shown.length < match.blocks.length) rows.push({
8262
+ type: "more",
8263
+ pieceName: match.pieceName,
8264
+ hidden: match.blocks.length - shown.length
8265
+ });
8266
+ }
8267
+ const partial = !pieceSource?.searchPieces || search.kind === "done" && search.result.status !== "ready";
8268
+ if (showCatalog && partial) {
8269
+ const grouped = new Set(groups.map((match) => match.pieceName));
8270
+ const named = (source) => source.kind === "piece" && matchesQuery(source.piece.displayName, tokens) ? 0 : 1;
8271
+ for (const source of [...sources].sort((a, b) => named(a) - named(b))) {
8272
+ if (source.kind !== "piece" || grouped.has(source.id)) continue;
8273
+ rows.push({
8274
+ type: "piece",
8275
+ match: {
8276
+ pieceName: source.piece.name,
8277
+ pieceVersion: source.piece.version ?? "",
8278
+ displayName: source.piece.displayName,
8279
+ description: source.piece.description,
8280
+ logoUrl: source.piece.logoUrl,
8281
+ categories: source.piece.categories,
8282
+ source: source.piece.source ?? "activepieces",
8283
+ namedPiece: true,
8284
+ blocks: []
8285
+ }
8286
+ });
8287
+ }
8288
+ }
8289
+ }
8290
+ const activeRow = rowIndex < 0 ? rows.findIndex((row) => row.type === "entry") : Math.min(rowIndex, rows.length - 1);
8291
+ const twoPane = showCatalog || sources.length > 1;
8292
+ const pane = twoPane ? paneState : "entries";
8293
+ const selectSource = (id) => {
8294
+ setSelectedId(id);
8295
+ setPane("sources");
8296
+ setEntryIndex(-1);
8297
+ };
8298
+ const openSource = (id) => {
8299
+ setSelectedId(id);
8300
+ setPane("entries");
8301
+ setEntryIndex(0);
8302
+ };
8303
+ const openPiece = (pieceName) => {
8304
+ if (!modePieces.some((piece) => piece.name === pieceName)) {
8305
+ setExpanded(/* @__PURE__ */ new Set([...expanded, pieceName]));
8306
+ return;
8307
+ }
8308
+ setQuery("");
8309
+ setChip(null);
8310
+ if (tab !== "all") setTab("all");
8311
+ openSource(pieceName);
8312
+ inputRef.current?.focus();
8313
+ };
8314
+ const hoverSource = (id) => {
8315
+ if (!pointerMoved.current) return;
8316
+ clearTimeout(hoverTimer.current);
8317
+ hoverTimer.current = setTimeout(() => selectSource(id), HOVER_PREVIEW_MS);
8318
+ };
8319
+ const step = (index, delta, count) => count === 0 ? index : Math.min(Math.max(index + delta, 0), count - 1);
8320
+ const onKeyDown = (event) => {
8321
+ const key = event.key;
8322
+ if (key !== "Escape" && event.target !== inputRef.current) return;
8323
+ if (key === "Escape") {
8324
+ event.stopPropagation();
8325
+ if (query !== "") setQuery("");
8326
+ else if (twoPane && pane === "entries" && !searching) setPane("sources");
8327
+ else onClose();
8328
+ return;
8329
+ }
8330
+ const delta = key === "ArrowDown" ? 1 : key === "ArrowUp" ? -1 : 0;
8331
+ if (searching) {
8332
+ if (delta !== 0) {
8333
+ event.preventDefault();
8334
+ setRowIndex(Math.max(step(activeRow, delta, rows.length), 0));
8335
+ return;
8336
+ }
8337
+ if (key === "Enter") {
8338
+ event.preventDefault();
8339
+ if (search.kind === "done" && search.stale) return;
8340
+ const row = rows.at(activeRow);
8341
+ if (!row) return;
8342
+ if (row.type === "entry") {
8343
+ if (row.entry.unavailable === void 0) row.entry.pick();
8344
+ } else if (row.type === "piece") openPiece(row.match.pieceName);
8345
+ else if (row.type === "list") openSource(row.source.id);
8346
+ else setExpanded(/* @__PURE__ */ new Set([...expanded, row.pieceName]));
8347
+ }
8348
+ return;
8349
+ }
8350
+ const sideways = query === "";
8351
+ if (pane === "sources") {
8352
+ if (delta !== 0) {
8353
+ event.preventDefault();
8354
+ const next = sources.at(step(sourceIndex, delta, sources.length));
8355
+ if (next) selectSource(next.id);
8356
+ } else if (key === "Enter" || sideways && key === "ArrowRight") {
8357
+ event.preventDefault();
8358
+ if (selected) openSource(selected.id);
8359
+ }
8360
+ return;
8361
+ }
8362
+ if (delta !== 0) {
8363
+ event.preventDefault();
8364
+ setEntryIndex(step(entryIndex, delta, entries.length));
8365
+ } else if (sideways && key === "ArrowLeft") {
8366
+ event.preventDefault();
8367
+ setPane("sources");
8368
+ } else if (key === "Enter") {
8369
+ event.preventDefault();
8370
+ const entry = entryAt < 0 ? void 0 : entries.at(entryAt);
8371
+ if (entry && entry.unavailable === void 0) entry.pick();
8372
+ }
8373
+ };
8374
+ const width = props.width ?? (pieceSource ? PICKER_SIZE.width : 360);
8375
+ const activeList = searching ? listIds.results : pane === "entries" ? listIds.entries : listIds.sources;
8376
+ const activeIndex = searching ? activeRow : pane === "entries" ? entryAt : sourceIndex;
8377
+ const activeOption = activeIndex >= 0 ? optionId(activeList, activeIndex) : void 0;
8378
+ const searchStatus = search.kind === "loading" || search.kind === "done" && search.stale ? /* @__PURE__ */ jsx(Status, { children: "Searching…" }) : search.kind === "error" ? /* @__PURE__ */ jsx(Status, {
8379
+ error: true,
8380
+ children: search.message
8381
+ }) : search.kind === "done" && search.result.status === "indexing" ? /* @__PURE__ */ jsx(Status, { children: "Still indexing the catalog: pieces are matched by name until it is ready." }) : search.kind === "done" && search.result.status === "error" ? /* @__PURE__ */ jsxs(Status, {
8382
+ error: true,
8383
+ children: [search.result.error ?? "Search failed", "; pieces are matched by name."]
8384
+ }) : rows.length === 0 ? /* @__PURE__ */ jsxs(Status, { children: [
8385
+ "No matching ",
8386
+ kind,
8387
+ "s"
8388
+ ] }) : null;
8389
+ const compact = !twoPane && !searching;
8390
+ const height = props.height ?? PICKER_SIZE.height;
7503
8391
  return /* @__PURE__ */ jsxs("div", {
7504
8392
  ref: containerRef,
7505
- className: "nodrag nopan nowheel w-80 rounded-md border border-solid border-foreground/10 bg-card shadow-lg",
8393
+ className: "nodrag nopan nowheel flex flex-col overflow-hidden rounded-lg border border-solid border-foreground/10 bg-card shadow-xl",
8394
+ style: compact ? {
8395
+ width,
8396
+ maxHeight: height
8397
+ } : {
8398
+ width,
8399
+ height
8400
+ },
7506
8401
  onClick: (event) => event.stopPropagation(),
7507
- children: [/* @__PURE__ */ jsxs("div", {
7508
- className: "border-b border-foreground/10 p-2",
7509
- children: [/* @__PURE__ */ jsx("div", {
7510
- className: "mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/80",
7511
- children: props.title
7512
- }), piece ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("input", {
7513
- autoFocus: true,
7514
- className: "w-full rounded border border-foreground/10 px-2 py-1 text-xs",
7515
- placeholder: pieceSource ? "Search pieces, actions, triggers…" : "Search…",
7516
- value: query,
7517
- onChange: (event) => setQuery(event.target.value)
7518
- }), pieceSource && catalog && !catalog.error ? /* @__PURE__ */ jsx("div", {
7519
- className: "mt-1.5 flex flex-wrap gap-1 px-0.5",
7520
- children: chips.map((label) => /* @__PURE__ */ jsx(Chip, {
7521
- label,
7522
- active: chip === label,
7523
- onClick: () => setChip(chip === label ? null : label)
7524
- }, label))
7525
- }) : null] })]
7526
- }), piece ? /* @__PURE__ */ jsx(PieceEntries, {
7527
- piece,
7528
- mode,
7529
- onPick: pick,
7530
- onHover: prefetch,
7531
- onBack: () => setPiece(null),
7532
- versionNote
7533
- }) : /* @__PURE__ */ jsxs("div", {
7534
- className: "max-h-80 overflow-y-auto py-1",
7535
- children: [
7536
- filteredAttach.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Attach existing step" }), filteredAttach.map((step) => /* @__PURE__ */ jsx(Row, {
7537
- logo: /* @__PURE__ */ jsx(BlockLogo, {
7538
- block: stepBlock(step),
7539
- size: ROW_LOGO
7540
- }),
7541
- label: step.name,
7542
- description: `{{steps.${step.key}}} · detached`,
7543
- onClick: () => props.onAttach?.(step.id)
7544
- }, step.id))] }) : null,
7545
- corePresets.length > 0 && labelPresets ? /* @__PURE__ */ jsx(SectionLabel, { children: "Core" }) : null,
7546
- corePresets.map(presetRow),
7547
- powerhousePresets.length > 0 && labelPresets ? /* @__PURE__ */ jsx(SectionLabel, { children: "Powerhouse" }) : null,
7548
- powerhousePresets.map(presetRow),
7549
- searchActive ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: mode === "triggers" ? "Triggers" : "Actions & triggers" }), search.kind === "loading" ? /* @__PURE__ */ jsx("div", {
7550
- className: "px-3 py-1 text-xs text-muted-foreground/80",
7551
- children: "Searching…"
7552
- }) : search.kind === "error" ? /* @__PURE__ */ jsx("div", {
7553
- className: "px-3 py-1 text-xs text-wf-fail",
7554
- children: search.message
7555
- }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [hits.map((hit) => {
7556
- const unavailable = blockUnavailable(hit);
7557
- const block = {
7558
- pieceName: hit.pieceName,
7559
- pieceVersion: hit.pieceVersion,
7560
- kind: hit.kind,
7561
- name: hit.name
7562
- };
7563
- return /* @__PURE__ */ jsx(Row, {
7564
- logo: /* @__PURE__ */ jsx(LogoFrame, {
7565
- src: hit.logoUrl,
7566
- alt: hit.pieceDisplayName,
7567
- size: ROW_LOGO
8402
+ onKeyDown,
8403
+ onMouseMove: () => {
8404
+ pointerMoved.current = true;
8405
+ },
8406
+ children: [
8407
+ /* @__PURE__ */ jsxs("div", {
8408
+ className: "shrink-0 border-b border-foreground/10",
8409
+ children: [/* @__PURE__ */ jsxs("div", {
8410
+ className: "flex items-center gap-2 px-3.5 pt-3 text-muted-foreground",
8411
+ children: [
8412
+ /* @__PURE__ */ jsx(Icon, {
8413
+ name: "search",
8414
+ size: 15
7568
8415
  }),
7569
- label: `${hit.displayName} · ${hit.pieceDisplayName}`,
7570
- description: unavailable ?? (hit.description || hit.pieceDisplayName),
7571
- disabled: unavailable !== void 0,
7572
- version: shownVersion(hit.pieceName, hit.pieceVersion),
7573
- versionNote: versionNote(hit.pieceName, hit.pieceVersion),
7574
- onHover: unavailable === void 0 ? () => prefetch(block) : void 0,
7575
- onClick: () => pick({
7576
- label: hit.displayName,
7577
- block,
7578
- description: hit.description,
7579
- defaultConfig: {}
8416
+ /* @__PURE__ */ jsx("input", {
8417
+ ref: inputRef,
8418
+ autoFocus: true,
8419
+ role: "combobox",
8420
+ "aria-expanded": true,
8421
+ "aria-autocomplete": "list",
8422
+ "aria-label": `Search ${props.title.toLowerCase()}`,
8423
+ "aria-controls": activeList,
8424
+ "aria-activedescendant": activeOption,
8425
+ className: "min-w-0 flex-1 bg-transparent py-1 text-sm text-foreground outline-none placeholder:text-muted-foreground",
8426
+ placeholder: pieceSource ? `Search pieces and ${kind}s…` : "Search…",
8427
+ value: query,
8428
+ onChange: (event) => {
8429
+ setQuery(event.target.value);
8430
+ setRowIndex(-1);
8431
+ setExpanded(/* @__PURE__ */ new Set());
8432
+ }
8433
+ }),
8434
+ /* @__PURE__ */ jsx("span", {
8435
+ className: "shrink-0 truncate text-xs",
8436
+ children: props.title
7580
8437
  })
7581
- }, blockKey(block));
7582
- }), search.result.status === "indexing" ? /* @__PURE__ */ jsx("div", {
7583
- className: "px-3 py-1 text-xs text-muted-foreground/80",
7584
- children: "Indexing the catalog… more results appear shortly."
7585
- }) : search.result.status === "error" ? /* @__PURE__ */ jsx("div", {
7586
- className: "px-3 py-1 text-xs text-wf-fail",
7587
- children: search.result.error ?? "Search failed"
7588
- }) : hits.length === 0 ? /* @__PURE__ */ jsxs("div", {
7589
- className: "px-3 py-1 text-xs text-muted-foreground/80",
8438
+ ]
8439
+ }), /* @__PURE__ */ jsx("div", {
8440
+ className: "px-3 pb-2.5 pt-2",
8441
+ children: /* @__PURE__ */ jsx(Tabs, {
8442
+ tabs,
8443
+ active: tab,
8444
+ onSelect: (next, fromKeyboard) => {
8445
+ setTab(next);
8446
+ setChip(null);
8447
+ setSelectedId(null);
8448
+ setPane("sources");
8449
+ if (!fromKeyboard) inputRef.current?.focus();
8450
+ }
8451
+ })
8452
+ })]
8453
+ }),
8454
+ showChips && catalog && !catalog.error ? /* @__PURE__ */ jsx(ChipBar, { children: chips.map((label, index) => /* @__PURE__ */ jsx(Chip, {
8455
+ label,
8456
+ active: activeChip === label,
8457
+ tabStop: activeChip === null ? index === 0 : activeChip === label,
8458
+ onClick: (fromKeyboard) => {
8459
+ setChip(activeChip === label ? null : label);
8460
+ setSelectedId(null);
8461
+ if (!fromKeyboard) inputRef.current?.focus();
8462
+ }
8463
+ }, label)) }) : null,
8464
+ searching ? /* @__PURE__ */ jsx(SearchList, {
8465
+ rows,
8466
+ tokens,
8467
+ activeIndex: activeRow,
8468
+ onActivate: (index) => {
8469
+ if (pointerMoved.current) setRowIndex(index);
8470
+ },
8471
+ onOpenPiece: openPiece,
8472
+ onOpenList: (id) => {
8473
+ setQuery("");
8474
+ openSource(id);
8475
+ },
8476
+ onExpand: (name) => setExpanded(/* @__PURE__ */ new Set([...expanded, name])),
8477
+ status: searchStatus,
8478
+ kind,
8479
+ listId: listIds.results,
8480
+ resetKey: `${query} ${JSON.stringify(searchFilter)}`,
8481
+ stale: search.kind === "done" && search.stale
8482
+ }) : /* @__PURE__ */ jsxs("div", {
8483
+ className: "flex min-h-0 flex-1",
8484
+ children: [twoPane ? /* @__PURE__ */ jsxs("div", {
8485
+ className: "flex w-56 shrink-0 flex-col border-r border-foreground/10 bg-foreground/[0.025]",
7590
8486
  children: [
7591
- "No matching ",
7592
- wantedKind,
7593
- "s"
8487
+ catalog?.error ? /* @__PURE__ */ jsxs("div", {
8488
+ className: "flex items-center gap-2 px-3 py-2 text-xs text-wf-fail",
8489
+ children: [/* @__PURE__ */ jsx("span", {
8490
+ className: "min-w-0 flex-1",
8491
+ children: catalog.error
8492
+ }), /* @__PURE__ */ jsx("button", {
8493
+ type: "button",
8494
+ className: "shrink-0 cursor-pointer rounded border border-solid border-foreground/15 bg-card px-1.5 py-0.5 text-foreground hover:border-foreground/25",
8495
+ onClick: () => {
8496
+ setCatalog(null);
8497
+ setCatalogRound((round) => round + 1);
8498
+ },
8499
+ children: "Retry"
8500
+ })]
8501
+ }) : null,
8502
+ /* @__PURE__ */ jsx(VirtualList, {
8503
+ id: listIds.sources,
8504
+ label: "Pieces",
8505
+ resetKey: `${tab} ${activeChip ?? ""} ${query}`,
8506
+ className: "flex-1 py-1",
8507
+ items: sources,
8508
+ heightOf: sourceHeight,
8509
+ keyOf: (source) => `${source.kind}:${source.id}`,
8510
+ activeIndex: sourceIndex,
8511
+ render: (source, index) => /* @__PURE__ */ jsx(SourceRow, {
8512
+ source,
8513
+ tokens,
8514
+ mode,
8515
+ active: pane === "sources" && index === sourceIndex,
8516
+ selected: index === sourceIndex,
8517
+ option: {
8518
+ list: listIds.sources,
8519
+ index,
8520
+ size: sources.length
8521
+ },
8522
+ onActivate: () => hoverSource(source.id),
8523
+ onOpen: () => {
8524
+ clearTimeout(hoverTimer.current);
8525
+ openSource(source.id);
8526
+ inputRef.current?.focus();
8527
+ }
8528
+ })
8529
+ }),
8530
+ showCatalog && catalog === null ? /* @__PURE__ */ jsx(Status, { children: "Loading catalog…" }) : sources.length === 0 ? /* @__PURE__ */ jsx(Status, { children: tab === "powerhouse" && tokens.length === 0 ? "No registry pieces on this runtime" : "No matching pieces" }) : null
7594
8531
  ]
7595
- }) : null] })] }) : null,
7596
- showCatalog ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionLabel, { children: "Pieces" }), catalog === null ? /* @__PURE__ */ jsx("div", {
7597
- className: "px-3 py-2 text-xs text-muted-foreground/80",
7598
- children: "Loading catalog…"
7599
- }) : catalog.error ? /* @__PURE__ */ jsxs("div", {
7600
- className: "flex items-center gap-2 px-3 py-2 text-xs text-wf-fail",
7601
- children: [/* @__PURE__ */ jsx("span", {
7602
- className: "min-w-0 flex-1",
7603
- children: catalog.error
7604
- }), /* @__PURE__ */ jsx("button", {
7605
- type: "button",
7606
- className: "shrink-0 cursor-pointer rounded border border-solid border-foreground/15 bg-card px-1.5 py-0.5 text-foreground hover:border-foreground/25",
7607
- onClick: () => {
7608
- setCatalog(null);
7609
- setCatalogRound((round) => round + 1);
7610
- },
7611
- children: "Retry"
7612
- })]
7613
- }) : filteredPieces.map((entry) => /* @__PURE__ */ jsx(Row, {
7614
- logo: /* @__PURE__ */ jsx(LogoFrame, {
7615
- src: entry.logoUrl,
7616
- alt: entry.displayName,
7617
- size: ROW_LOGO
7618
- }),
7619
- label: entry.deprecated ? `${entry.displayName} (deprecated)` : entry.displayName,
7620
- description: entry.unsupported ?? (mode === "triggers" ? `${entry.triggerCount} trigger${entry.triggerCount === 1 ? "" : "s"} · ${entry.description}` : `${entry.actionCount} action${entry.actionCount === 1 ? "" : "s"} · ${entry.description}`),
7621
- version: shownVersion(entry.name, entry.version),
7622
- versionNote: versionNote(entry.name, entry.version),
7623
- onClick: () => setPiece(entry)
7624
- }, entry.name))] }) : null,
7625
- corePresets.length + powerhousePresets.length === 0 && filteredPieces.length === 0 && filteredAttach.length === 0 && !searchActive ? /* @__PURE__ */ jsx("div", {
7626
- className: "px-3 py-2 text-xs text-muted-foreground/80",
7627
- children: "No matches"
7628
- }) : null
7629
- ]
7630
- })]
8532
+ }) : null, /* @__PURE__ */ jsx(EntriesPane, {
8533
+ source: selected,
8534
+ mode,
8535
+ pieceEntries,
8536
+ pieceError: selected?.kind === "piece" ? loaded.error : null,
8537
+ tokens,
8538
+ activeIndex: pane === "entries" ? entryAt : -1,
8539
+ listId: listIds.entries,
8540
+ showHeader: twoPane,
8541
+ onActivate: (index) => {
8542
+ if (!pointerMoved.current) return;
8543
+ setPane("entries");
8544
+ setEntryIndex(index);
8545
+ }
8546
+ })]
8547
+ })
8548
+ ]
7631
8549
  });
7632
8550
  }
7633
8551
  //#endregion
7634
- export { useWebhookEndpoint as $, runTimeline as A, Toggle as At, useBlockResolutions as B, useQuery as Bt, formatAbsolute as C, FieldLabel as Ct, formatWhen as D, Select as Dt, formatTrigger as E, Segmented as Et, DesignTimeProvider as F, Icon as Ft, useDynamicLookup as G, useConnectionList as H, useBlockForm as I, isIconName as It, useOptionSearch as J, useDynamicPrefetch as K, useBlockFormLoader as L, DocumentErrorBoundary as Lt, statusLabel as M, invalidClass as Mt, toneOf as N, textAreaClass as Nt, runStats as O, Switch as Ot, workflowHealth as P, textInputClass as Pt, useTestTrigger as Q, useBlockForms as R, DocumentLoadError as Rt, durationMs as S, FieldError as St, formatMs as T, IconButton as Tt, useDesignTime as U, useCachedBlockForm as V, useDynamicCache as W, useRunById as X, useResolvedProp as Y, useTestStepRunner as Z, RUN_TONE as _, useRunsQuery as _t, resolutionText as a, settingFor as at, TONE_TEXT as b, useSecretStat as bt, useResolution as c, undeclaredPortIssues as ct, pieceDisplayName as d, WorkflowRuntimeProvider as dt, blockMissing as et, pieceLogo as f, useOAuthAttempt as ft, RUN_STATUSES as g, useRunQuery as gt, CONNECTION_TONE as h, useRunPagesQuery as ht, VersionSummary as i, resolverInputFor as it, runTone as j, Tooltip as jt, runStatusLabel as k, Tabs as kt, versionBadge as l, withSetting as lt, usePieceLogos as m, usePieceCatalog as mt, BlockSelector as n, isPropVisible as nt, runsDifferentVersion as o, storedSchema as ot, useBlockMeta as p, useOAuthRedirectUri as pt, useLatestRun as q, BlockResolutionsProvider as r, parsePropList as rt, updateVersion as s, stripOptions as st, BlockLogo as t, isEmptyValue as tt, blockMeta as u, workflowReadiness as ut, STEP_TONE as v, useRuntime as vt, formatDuration as w, Hint as wt, canRerun as x, Button as xt, TONE_DOT as y, useRuntimeActions as yt, useBlockPorts as z, errorMessage as zt };
8552
+ export { useTestStepRunner as $, runStats as A, Switch as At, useBlockForms as B, DocumentLoadError as Bt, canRerun as C, Button as Ct, formatMs as D, IconButton as Dt, formatDuration as E, Hint as Et, toneOf as F, textAreaClass as Ft, useDesignTime as G, useBlockResolutions as H, useQuery as Ht, workflowHealth as I, textInputClass as It, useDynamicPrefetch as J, useDynamicCache as K, DesignTimeProvider as L, Icon as Lt, runTimeline as M, Toggle as Mt, runTone as N, Tooltip as Nt, formatTrigger as O, Segmented as Ot, statusLabel as P, invalidClass as Pt, useRunById as Q, useBlockForm as R, isIconName as Rt, TONE_TEXT as S, useSecretStat as St, formatAbsolute as T, FieldLabel as Tt, useCachedBlockForm as U, useBlockPorts as V, errorMessage as Vt, useConnectionList as W, useOptionSearch as X, useLatestRun as Y, useResolvedProp as Z, CONNECTION_TONE as _, useRunPagesQuery as _t, BlockResolutionsProvider as a, parsePropList as at, STEP_TONE as b, useRuntime as bt, runsDifferentVersion as c, storedSchema as ct, versionBadge as d, withSetting as dt, useTestTrigger as et, blockMeta as f, workflowReadiness as ft, usePieceLogos as g, usePieceCatalog as gt, useBlockMeta as h, useOAuthRedirectUri as ht, PickerPopover as i, isPropVisible as it, runStatusLabel as j, Tabs$1 as jt, formatWhen as k, Select as kt, updateVersion as l, stripOptions as lt, pieceLogo as m, useOAuthAttempt as mt, BlockSelector as n, blockMissing as nt, VersionSummary as o, resolverInputFor as ot, pieceDisplayName as p, WorkflowRuntimeProvider as pt, useDynamicLookup as q, PICKER_SIZE as r, isEmptyValue as rt, resolutionText as s, settingFor as st, BlockLogo as t, useWebhookEndpoint as tt, useResolution as u, undeclaredPortIssues as ut, RUN_STATUSES as v, useRunQuery as vt, durationMs as w, FieldError as wt, TONE_DOT as x, useRuntimeActions as xt, RUN_TONE as y, useRunsQuery as yt, useBlockFormLoader as z, DocumentErrorBoundary as zt };
7635
8553
 
7636
- //# sourceMappingURL=BlockSelector-eaXC56EC.js.map
8554
+ //# sourceMappingURL=BlockSelector-CzJnQWsh.js.map