@uipath/apollo-react 4.16.1 → 4.17.0-pr605.8e85d9c

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 (75) hide show
  1. package/dist/canvas/components/AddNodePanel/AddNodeManager.cjs +35 -21
  2. package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
  3. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.cjs +150 -0
  4. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts +20 -0
  5. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts.map +1 -0
  6. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.js +110 -0
  7. package/dist/canvas/components/AddNodePanel/AddNodeManager.js +35 -21
  8. package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +15 -4
  9. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +5 -1
  10. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
  11. package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +15 -4
  12. package/dist/canvas/components/AddNodePanel/index.d.ts +1 -1
  13. package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
  14. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -1
  15. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
  16. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +23 -1
  17. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +0 -14
  18. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
  19. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +2 -16
  20. package/dist/canvas/components/LoopNode/LoopNode.cjs +25 -19
  21. package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
  22. package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +33 -42
  23. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +9 -10
  24. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -1
  25. package/dist/canvas/components/LoopNode/LoopNode.helpers.js +25 -31
  26. package/dist/canvas/components/LoopNode/LoopNode.js +17 -11
  27. package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +17 -4
  28. package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
  29. package/dist/canvas/components/LoopNode/LoopNodePreview.js +17 -4
  30. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +25 -14
  31. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
  32. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +25 -14
  33. package/dist/canvas/components/Toolbox/ListView.cjs +66 -19
  34. package/dist/canvas/components/Toolbox/ListView.d.ts +12 -1
  35. package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
  36. package/dist/canvas/components/Toolbox/ListView.js +66 -19
  37. package/dist/canvas/components/Toolbox/Toolbox.cjs +6 -5
  38. package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
  39. package/dist/canvas/components/Toolbox/Toolbox.js +6 -5
  40. package/dist/canvas/constants.cjs +0 -8
  41. package/dist/canvas/constants.d.ts +0 -2
  42. package/dist/canvas/constants.d.ts.map +1 -1
  43. package/dist/canvas/constants.js +1 -3
  44. package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +4 -2
  45. package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
  46. package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +4 -2
  47. package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
  48. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  49. package/dist/canvas/utils/NodeUtils.cjs +26 -10
  50. package/dist/canvas/utils/NodeUtils.d.ts +7 -0
  51. package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
  52. package/dist/canvas/utils/NodeUtils.js +13 -6
  53. package/dist/canvas/utils/collapse.cjs +3 -3
  54. package/dist/canvas/utils/collapse.d.ts.map +1 -1
  55. package/dist/canvas/utils/collapse.js +1 -1
  56. package/dist/canvas/utils/container.cjs +642 -0
  57. package/dist/canvas/utils/container.d.ts +97 -0
  58. package/dist/canvas/utils/container.d.ts.map +1 -0
  59. package/dist/canvas/utils/container.js +566 -0
  60. package/dist/canvas/utils/createPreviewGraph.cjs +13 -17
  61. package/dist/canvas/utils/createPreviewGraph.d.ts +10 -8
  62. package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
  63. package/dist/canvas/utils/createPreviewGraph.js +13 -17
  64. package/dist/canvas/utils/createPreviewNode.cjs +16 -10
  65. package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
  66. package/dist/canvas/utils/createPreviewNode.js +16 -10
  67. package/dist/canvas/utils/index.cjs +29 -22
  68. package/dist/canvas/utils/index.d.ts +1 -0
  69. package/dist/canvas/utils/index.d.ts.map +1 -1
  70. package/dist/canvas/utils/index.js +1 -0
  71. package/package.json +3 -3
  72. package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -56
  73. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -7
  74. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
  75. package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -7
@@ -0,0 +1,642 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ CONTAINER_SEQUENCE_GAP_PX: ()=>CONTAINER_SEQUENCE_GAP_PX,
28
+ DEFAULT_CONTAINER_WIDTH: ()=>DEFAULT_CONTAINER_WIDTH,
29
+ DEFAULT_CONTAINER_HEIGHT: ()=>DEFAULT_CONTAINER_HEIGHT,
30
+ getContainerSafeArea: ()=>container_getContainerSafeArea,
31
+ isContainerNodeManifest: ()=>isContainerNodeManifest,
32
+ placeContainerNode: ()=>placeContainerNode,
33
+ DEFAULT_CONTAINER_MIN_HEIGHT: ()=>DEFAULT_CONTAINER_MIN_HEIGHT,
34
+ getContainerNodeForEdge: ()=>getContainerNodeForEdge,
35
+ resolveContainerPreview: ()=>resolveContainerPreview,
36
+ getContainerFitGeometry: ()=>container_getContainerFitGeometry,
37
+ CONTAINER_FRAME_INSET_PX: ()=>CONTAINER_FRAME_INSET_PX,
38
+ ensureContainersFitChildren: ()=>ensureContainersFitChildren,
39
+ getNodeDimensions: ()=>container_getNodeDimensions,
40
+ DEFAULT_CONTAINER_MIN_WIDTH: ()=>DEFAULT_CONTAINER_MIN_WIDTH,
41
+ getContainerPlacement: ()=>getContainerPlacement
42
+ });
43
+ const external_constants_cjs_namespaceObject = require("../constants.cjs");
44
+ const external_NodeUtils_cjs_namespaceObject = require("./NodeUtils.cjs");
45
+ const DEFAULT_CONTAINER_WIDTH = 35 * external_constants_cjs_namespaceObject.GRID_SPACING;
46
+ const DEFAULT_CONTAINER_HEIGHT = 20 * external_constants_cjs_namespaceObject.GRID_SPACING;
47
+ const DEFAULT_CONTAINER_MIN_WIDTH = 25 * external_constants_cjs_namespaceObject.GRID_SPACING;
48
+ const DEFAULT_CONTAINER_MIN_HEIGHT = 14 * external_constants_cjs_namespaceObject.GRID_SPACING;
49
+ const CONTAINER_FRAME_INSET_PX = 10;
50
+ const CONTAINER_BODY_PADDING_PX = 2 * external_constants_cjs_namespaceObject.GRID_SPACING;
51
+ const CONTAINER_INNER_HANDLE_RAIL_WIDTH_PX = 5 * external_constants_cjs_namespaceObject.GRID_SPACING;
52
+ const CONTAINER_CHILD_SAFE_GAP_PX = external_constants_cjs_namespaceObject.GRID_SPACING;
53
+ const DEFAULT_CONTAINER_HEADER_HEIGHT_PX = 40;
54
+ const CONTAINER_SEQUENCE_GAP_PX = 3 * external_constants_cjs_namespaceObject.GRID_SPACING;
55
+ const PLACEMENT_DATA_KEY = 'placement';
56
+ function readNumericDimension(...values) {
57
+ for (const value of values){
58
+ if ('number' == typeof value && Number.isFinite(value)) return value;
59
+ if ('string' == typeof value) {
60
+ const parsedValue = Number.parseFloat(value);
61
+ if (Number.isFinite(parsedValue)) return parsedValue;
62
+ }
63
+ }
64
+ }
65
+ function container_getNodeDimensions(node, fallback = {
66
+ width: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
67
+ height: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
68
+ }) {
69
+ return {
70
+ width: readNumericDimension(node.width, node.measured?.width, node.style?.width) ?? fallback.width,
71
+ height: readNumericDimension(node.height, node.measured?.height, node.style?.height) ?? fallback.height
72
+ };
73
+ }
74
+ function container_getContainerSafeArea(containerNode, fallback = {
75
+ width: DEFAULT_CONTAINER_WIDTH,
76
+ height: DEFAULT_CONTAINER_HEIGHT
77
+ }) {
78
+ const size = container_getNodeDimensions(containerNode, fallback);
79
+ const horizontalPadding = (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(CONTAINER_FRAME_INSET_PX + CONTAINER_BODY_PADDING_PX + CONTAINER_INNER_HANDLE_RAIL_WIDTH_PX + CONTAINER_CHILD_SAFE_GAP_PX);
80
+ const verticalPadding = (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(CONTAINER_FRAME_INSET_PX + CONTAINER_BODY_PADDING_PX);
81
+ const padding = {
82
+ left: horizontalPadding,
83
+ right: horizontalPadding,
84
+ top: (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(DEFAULT_CONTAINER_HEADER_HEIGHT_PX + verticalPadding),
85
+ bottom: verticalPadding
86
+ };
87
+ return {
88
+ x: padding.left,
89
+ y: padding.top,
90
+ width: Math.max(0, size.width - padding.left - padding.right),
91
+ height: Math.max(0, size.height - padding.top - padding.bottom),
92
+ padding
93
+ };
94
+ }
95
+ function container_getContainerFitGeometry() {
96
+ const padding = container_getContainerSafeArea({
97
+ width: DEFAULT_CONTAINER_WIDTH,
98
+ height: DEFAULT_CONTAINER_HEIGHT
99
+ }).padding;
100
+ return {
101
+ minWidth: DEFAULT_CONTAINER_MIN_WIDTH,
102
+ minHeight: DEFAULT_CONTAINER_MIN_HEIGHT,
103
+ padding: {
104
+ right: padding.right,
105
+ bottom: padding.bottom
106
+ }
107
+ };
108
+ }
109
+ function isContainerNodeManifest(manifest) {
110
+ return manifest?.display.shape === 'container';
111
+ }
112
+ function getAncestorContainerIds(containerId, nodesById) {
113
+ const ancestors = [];
114
+ let parentId = nodesById.get(containerId)?.parentId;
115
+ while(parentId){
116
+ ancestors.push(parentId);
117
+ parentId = nodesById.get(parentId)?.parentId;
118
+ }
119
+ return ancestors;
120
+ }
121
+ function getContainerDepth(containerId, nodesById) {
122
+ let depth = 0;
123
+ let parentId = nodesById.get(containerId)?.parentId;
124
+ while(parentId){
125
+ depth += 1;
126
+ parentId = nodesById.get(parentId)?.parentId;
127
+ }
128
+ return depth;
129
+ }
130
+ function withNodeDimensions(node, size) {
131
+ return {
132
+ ...node,
133
+ width: size.width,
134
+ height: size.height,
135
+ style: {
136
+ ...node.style,
137
+ width: size.width,
138
+ height: size.height
139
+ }
140
+ };
141
+ }
142
+ function ensureContainersFitChildren(nodes, { containerIds, getContainerFitGeometry: resolveContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, ignoredNodeTypes = [], includeAncestors = true } = {}) {
143
+ let nextNodes = nodes;
144
+ const changes = [];
145
+ const ignoredTypes = new Set(ignoredNodeTypes);
146
+ const nodesById = new Map(nextNodes.map((node)=>[
147
+ node.id,
148
+ node
149
+ ]));
150
+ const idsToFit = new Set();
151
+ if (containerIds) for (const id of containerIds)idsToFit.add(id);
152
+ else for (const node of nextNodes)if (node.parentId) idsToFit.add(node.parentId);
153
+ if (includeAncestors) for (const id of Array.from(idsToFit))for (const ancestorId of getAncestorContainerIds(id, nodesById))idsToFit.add(ancestorId);
154
+ const orderedContainerIds = Array.from(idsToFit).sort((left, right)=>getContainerDepth(right, nodesById) - getContainerDepth(left, nodesById));
155
+ for (const containerId of orderedContainerIds){
156
+ const containerNode = nextNodes.find((node)=>node.id === containerId);
157
+ const geometry = resolveContainerFitGeometry?.(containerNode);
158
+ if (!geometry) continue;
159
+ const currentSize = resolveNodeDimensions(containerNode);
160
+ const padding = geometry.padding ?? {};
161
+ let requiredWidth = geometry.minWidth;
162
+ let requiredHeight = geometry.minHeight;
163
+ for (const childNode of nextNodes){
164
+ if (childNode.id === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || childNode.hidden || childNode.parentId !== containerId || ignoredTypes.has(childNode.type ?? '')) continue;
165
+ const childSize = resolveNodeDimensions(childNode);
166
+ requiredWidth = Math.max(requiredWidth, childNode.position.x + childSize.width + (padding.right ?? 0));
167
+ requiredHeight = Math.max(requiredHeight, childNode.position.y + childSize.height + (padding.bottom ?? 0));
168
+ }
169
+ const nextSize = {
170
+ width: Math.max(currentSize.width, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredWidth)),
171
+ height: Math.max(currentSize.height, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredHeight))
172
+ };
173
+ if (nextSize.width !== currentSize.width || nextSize.height !== currentSize.height) {
174
+ nextNodes = nextNodes.map((node)=>node.id === containerId ? withNodeDimensions(node, nextSize) : node);
175
+ nodesById.set(containerId, nextNodes.find((node)=>node.id === containerId));
176
+ changes.push({
177
+ containerId,
178
+ previousSize: currentSize,
179
+ nextSize
180
+ });
181
+ }
182
+ }
183
+ return {
184
+ nodes: nextNodes,
185
+ changes
186
+ };
187
+ }
188
+ function getSafeArea(containerNode, safeArea) {
189
+ return safeArea ?? container_getContainerSafeArea(containerNode);
190
+ }
191
+ function clampTopLeftToSafeArea(position, safeArea, nodeSize) {
192
+ const maxX = safeArea.x + Math.max(0, safeArea.width - nodeSize.width);
193
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
194
+ return {
195
+ x: (0, external_NodeUtils_cjs_namespaceObject.clamp)(position.x, safeArea.x, maxX),
196
+ y: (0, external_NodeUtils_cjs_namespaceObject.clamp)(position.y, safeArea.y, maxY)
197
+ };
198
+ }
199
+ function clampTopToSafeArea(top, safeArea, nodeSize) {
200
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
201
+ return (0, external_NodeUtils_cjs_namespaceObject.clamp)(top, safeArea.y, maxY);
202
+ }
203
+ function rangesOverlap(startA, endA, startB, endB) {
204
+ return startA < endB && endA > startB;
205
+ }
206
+ function centerInSafeArea(safeArea, nodeSize) {
207
+ return {
208
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(safeArea.x + (safeArea.width - nodeSize.width) / 2)),
209
+ y: Math.max(safeArea.y, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(safeArea.y + (safeArea.height - nodeSize.height) / 2))
210
+ };
211
+ }
212
+ function getLocalNodePosition(node, containerNode, nodes) {
213
+ if (!node || node.id === containerNode.id) return null;
214
+ if (node.parentId === containerNode.id) return node.position;
215
+ const containerPosition = (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(containerNode, nodes);
216
+ const nodePosition = node.parentId ? (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(node, nodes) : node.position;
217
+ return {
218
+ x: nodePosition.x - containerPosition.x,
219
+ y: nodePosition.y - containerPosition.y
220
+ };
221
+ }
222
+ function getPlacementDirection(sourcePosition, targetPosition) {
223
+ if (!sourcePosition || !targetPosition) return sourcePosition ? 'right' : 'left';
224
+ return targetPosition.x >= sourcePosition.x ? 'right' : 'left';
225
+ }
226
+ function getSiblingNodes(containerId, nodes, insertedNodeId) {
227
+ return nodes.filter((node)=>node.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID && node.id !== insertedNodeId && node.parentId === containerId);
228
+ }
229
+ function resolveSequenceTopLeft({ sourceNode, targetNode, containerNode, nodes, safeArea, previewNodeSize, gap, getNodeDimensions }) {
230
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
231
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
232
+ const sourceSize = sourceNode ? getNodeDimensions(sourceNode) : void 0;
233
+ const targetSize = targetNode ? getNodeDimensions(targetNode) : void 0;
234
+ if (sourcePosition && sourceSize && targetPosition) {
235
+ const sourceRight = sourcePosition.x + sourceSize.width;
236
+ const targetLeft = targetPosition.x;
237
+ const centerX = targetLeft - sourceRight >= previewNodeSize.width + 2 * gap ? sourceRight + (targetLeft - sourceRight) / 2 : sourceRight + gap + previewNodeSize.width / 2;
238
+ return {
239
+ x: centerX - previewNodeSize.width / 2,
240
+ y: sourcePosition.y + sourceSize.height / 2 - previewNodeSize.height / 2
241
+ };
242
+ }
243
+ if (sourcePosition && sourceSize) return {
244
+ x: sourcePosition.x + sourceSize.width + gap,
245
+ y: sourcePosition.y + sourceSize.height / 2 - previewNodeSize.height / 2
246
+ };
247
+ if (targetPosition && targetSize) return {
248
+ x: targetPosition.x - previewNodeSize.width - gap,
249
+ y: targetPosition.y + targetSize.height / 2 - previewNodeSize.height / 2
250
+ };
251
+ return {
252
+ x: safeArea.x + safeArea.width / 2 - previewNodeSize.width / 2,
253
+ y: safeArea.y + safeArea.height / 2 - previewNodeSize.height / 2
254
+ };
255
+ }
256
+ function getContainerNodeForEdge(sourceNode, targetNode, nodes) {
257
+ if (sourceNode.parentId === targetNode.id) return targetNode;
258
+ if (targetNode.parentId === sourceNode.id) return sourceNode;
259
+ if (sourceNode.parentId && sourceNode.parentId === targetNode.parentId) return nodes.find((node)=>node.id === sourceNode.parentId);
260
+ return null;
261
+ }
262
+ function handleMatches(edgeHandleId, handleId) {
263
+ return (edgeHandleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID) === handleId;
264
+ }
265
+ function getOutgoingEdges(sourceNodeId, sourceHandleId, edges) {
266
+ return edges.filter((edge)=>edge.source !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID && edge.target !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID && edge.source === sourceNodeId && handleMatches(edge.sourceHandle, sourceHandleId));
267
+ }
268
+ function getSingleOutgoingEdge(sourceNodeId, sourceHandleId, edges) {
269
+ const outgoingEdges = getOutgoingEdges(sourceNodeId, sourceHandleId, edges);
270
+ return 1 === outgoingEdges.length ? outgoingEdges[0] : null;
271
+ }
272
+ function isPreviewGraphEdge(edge) {
273
+ return edge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || edge.target === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
274
+ }
275
+ function getDefaultNextContainerSequenceNodeId({ nodeId, edges, nodesById, containerId, isSequenceEdge }) {
276
+ const localOutgoingEdges = edges.filter((edge)=>{
277
+ if (isPreviewGraphEdge(edge) || edge.source !== nodeId) return false;
278
+ if (isSequenceEdge && !isSequenceEdge(edge)) return false;
279
+ const targetNode = nodesById.get(edge.target);
280
+ return edge.target === containerId || targetNode?.parentId === containerId;
281
+ });
282
+ return 1 === localOutgoingEdges.length ? localOutgoingEdges[0].target : null;
283
+ }
284
+ function collectDownstreamNodes({ targetNodeId, containerId, nodes, edges, isSequenceEdge, getNextNodeId }) {
285
+ if (!targetNodeId || targetNodeId === containerId) return [];
286
+ const nodesById = new Map(nodes.map((node)=>[
287
+ node.id,
288
+ node
289
+ ]));
290
+ const collectedIds = [];
291
+ const visitedIds = new Set();
292
+ let currentNodeId = targetNodeId;
293
+ while(currentNodeId && !visitedIds.has(currentNodeId)){
294
+ const currentNode = nodesById.get(currentNodeId);
295
+ if (!currentNode || currentNode.parentId !== containerId) break;
296
+ collectedIds.push(currentNodeId);
297
+ visitedIds.add(currentNodeId);
298
+ const nextNodeId = getNextNodeId?.({
299
+ nodeId: currentNodeId,
300
+ edges,
301
+ nodesById,
302
+ containerId
303
+ }) ?? getDefaultNextContainerSequenceNodeId({
304
+ nodeId: currentNodeId,
305
+ edges,
306
+ nodesById,
307
+ containerId,
308
+ isSequenceEdge
309
+ });
310
+ if (!nextNodeId || nextNodeId === containerId) break;
311
+ currentNodeId = nextNodeId;
312
+ }
313
+ return collectedIds;
314
+ }
315
+ function resolveInsertPreview({ source, sourceHandleType, reactFlowInstance, isContainerNode, getContainerSafeArea, previewNodeSize, gap, getNodeDimensions }) {
316
+ if ('source' !== sourceHandleType || !source.handleId) return null;
317
+ const replacedEdge = getSingleOutgoingEdge(source.nodeId, source.handleId, reactFlowInstance.getEdges());
318
+ if (!replacedEdge) return null;
319
+ const sourceNode = reactFlowInstance.getNode(replacedEdge.source);
320
+ const targetNode = reactFlowInstance.getNode(replacedEdge.target);
321
+ const nodes = reactFlowInstance.getNodes();
322
+ const containerNode = getContainerNodeForEdge(sourceNode, targetNode, nodes);
323
+ if (!containerNode) return null;
324
+ if (isContainerNode && !isContainerNode(containerNode)) return null;
325
+ const containerPlacement = getPreviewPlacement({
326
+ sourceNode,
327
+ targetNode,
328
+ containerNode,
329
+ nodes,
330
+ safeArea: getContainerSafeArea?.(containerNode),
331
+ previewNodeSize,
332
+ gap,
333
+ getNodeDimensions
334
+ });
335
+ const placement = {
336
+ containerId: containerPlacement.containerId,
337
+ sourceNodeId: sourceNode.id,
338
+ targetNodeId: targetNode.id,
339
+ mode: 'sequence'
340
+ };
341
+ return {
342
+ position: containerPlacement.centerPosition,
343
+ positionMode: 'center',
344
+ data: {
345
+ originalEdge: replacedEdge,
346
+ [PLACEMENT_DATA_KEY]: placement
347
+ },
348
+ target: {
349
+ nodeId: replacedEdge.target,
350
+ handleId: replacedEdge.targetHandle
351
+ },
352
+ containerId: containerPlacement.containerId
353
+ };
354
+ }
355
+ function resolveAppendPreview({ source, sourceHandleType, reactFlowInstance, ...options }) {
356
+ if ('source' !== sourceHandleType || !source.handleId) return null;
357
+ const sourceNode = reactFlowInstance.getNode(source.nodeId);
358
+ if (!sourceNode?.parentId) return null;
359
+ const outgoingEdges = getOutgoingEdges(source.nodeId, source.handleId, reactFlowInstance.getEdges());
360
+ if (outgoingEdges.length > 0) return null;
361
+ const nodes = reactFlowInstance.getNodes();
362
+ const containerNode = nodes.find((node)=>node.id === sourceNode.parentId);
363
+ if (options.isContainerNode && !options.isContainerNode(containerNode)) return null;
364
+ const continuationTarget = options.getContainerContinuationTarget?.({
365
+ containerNode,
366
+ sourceNode,
367
+ source,
368
+ reactFlowInstance
369
+ });
370
+ if (!continuationTarget) return null;
371
+ const targetNode = continuationTarget.nodeId === containerNode.id ? containerNode : reactFlowInstance.getNode(continuationTarget.nodeId);
372
+ const containerPlacement = getPreviewPlacement({
373
+ sourceNode,
374
+ targetNode,
375
+ containerNode,
376
+ nodes,
377
+ safeArea: options.getContainerSafeArea?.(containerNode),
378
+ previewNodeSize: options.previewNodeSize,
379
+ gap: options.gap,
380
+ avoidSiblings: options.avoidSiblings ?? true,
381
+ getNodeDimensions: options.getNodeDimensions
382
+ });
383
+ const placement = {
384
+ containerId: containerPlacement.containerId,
385
+ sourceNodeId: sourceNode.id,
386
+ targetNodeId: continuationTarget.nodeId,
387
+ mode: 'sequence'
388
+ };
389
+ return {
390
+ position: containerPlacement.centerPosition,
391
+ positionMode: 'center',
392
+ data: {
393
+ [PLACEMENT_DATA_KEY]: placement
394
+ },
395
+ target: continuationTarget,
396
+ containerId: containerPlacement.containerId
397
+ };
398
+ }
399
+ function resolveContainerPreview({ source, sourceHandleType, reactFlowInstance, ...options }) {
400
+ return resolveInsertPreview({
401
+ source,
402
+ sourceHandleType,
403
+ reactFlowInstance,
404
+ ...options
405
+ }) ?? resolveAppendPreview({
406
+ source,
407
+ sourceHandleType,
408
+ reactFlowInstance,
409
+ ...options
410
+ });
411
+ }
412
+ function getPreviewPlacement({ sourceNode, targetNode, containerNode, nodes, containerAbsolutePosition = (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(containerNode, nodes), safeArea, previewNodeSize = {
413
+ width: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
414
+ height: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
415
+ }, gap = CONTAINER_SEQUENCE_GAP_PX, avoidSiblings = false, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions }) {
416
+ const resolvedSafeArea = getSafeArea(containerNode, safeArea);
417
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
418
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
419
+ const direction = getPlacementDirection(sourcePosition, targetPosition);
420
+ const initialPosition = resolveSequenceTopLeft({
421
+ sourceNode,
422
+ targetNode,
423
+ containerNode,
424
+ nodes,
425
+ safeArea: resolvedSafeArea,
426
+ previewNodeSize,
427
+ gap,
428
+ getNodeDimensions: resolveNodeDimensions
429
+ });
430
+ const collisionPosition = avoidSiblings ? (0, external_NodeUtils_cjs_namespaceObject.getNonOverlappingPositionForDirection)(getSiblingNodes(containerNode.id, nodes), initialPosition, previewNodeSize, direction, gap) : initialPosition;
431
+ const position = clampTopLeftToSafeArea(collisionPosition, resolvedSafeArea, previewNodeSize);
432
+ return {
433
+ containerId: containerNode.id,
434
+ centerPosition: {
435
+ x: containerAbsolutePosition.x + position.x + previewNodeSize.width / 2,
436
+ y: containerAbsolutePosition.y + position.y + previewNodeSize.height / 2
437
+ }
438
+ };
439
+ }
440
+ function getNodeCenterY(position, nodeSize) {
441
+ return position.y + nodeSize.height / 2;
442
+ }
443
+ function getInsertedPosition({ sourceNode, targetNode, insertedNode, containerNode, nodes, safeArea, insertedNodeSize, gap, getNodeDimensions }) {
444
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
445
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
446
+ const sourceSize = sourceNode ? getNodeDimensions(sourceNode) : void 0;
447
+ const targetSize = targetNode ? getNodeDimensions(targetNode) : void 0;
448
+ const sourceIsContainer = sourceNode?.id === containerNode.id;
449
+ const targetIsContainer = targetNode?.id === containerNode.id;
450
+ if (sourcePosition && sourceSize && !sourceIsContainer) return {
451
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(sourcePosition.x + sourceSize.width + gap)),
452
+ y: clampTopToSafeArea((0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(getNodeCenterY(sourcePosition, sourceSize) - insertedNodeSize.height / 2), safeArea, insertedNodeSize)
453
+ };
454
+ if (targetPosition && targetSize && !targetIsContainer) return {
455
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(targetPosition.x - insertedNodeSize.width - gap)),
456
+ y: clampTopToSafeArea((0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(getNodeCenterY(targetPosition, targetSize) - insertedNodeSize.height / 2), safeArea, insertedNodeSize)
457
+ };
458
+ return {
459
+ x: Math.max(safeArea.x, (0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(insertedNode.position.x)),
460
+ y: clampTopToSafeArea((0, external_NodeUtils_cjs_namespaceObject.snapToGrid)(insertedNode.position.y), safeArea, insertedNodeSize)
461
+ };
462
+ }
463
+ function getNodeDepth(node, nodesById) {
464
+ let depth = 0;
465
+ let parentId = node?.parentId;
466
+ while(parentId){
467
+ depth += 1;
468
+ parentId = nodesById.get(parentId)?.parentId;
469
+ }
470
+ return depth;
471
+ }
472
+ function sortContainerSizeChanges(changes, nodes) {
473
+ const nodesById = new Map(nodes.map((node)=>[
474
+ node.id,
475
+ node
476
+ ]));
477
+ return [
478
+ ...changes
479
+ ].sort((left, right)=>{
480
+ const leftNode = nodesById.get(left.containerId);
481
+ const rightNode = nodesById.get(right.containerId);
482
+ const depthDifference = getNodeDepth(rightNode, nodesById) - getNodeDepth(leftNode, nodesById);
483
+ if (0 !== depthDifference) return depthDifference;
484
+ if (leftNode.parentId === rightNode.parentId) return leftNode.position.x - rightNode.position.x;
485
+ return 0;
486
+ });
487
+ }
488
+ function pushSiblingsAfterContainerGrowth({ nodes, changes, getNodeDimensions, gap }) {
489
+ let shifted = false;
490
+ let nextNodes = nodes;
491
+ for (const change of sortContainerSizeChanges(changes, nextNodes)){
492
+ const widthDelta = change.nextSize.width - change.previousSize.width;
493
+ if (widthDelta <= 0) continue;
494
+ const containerNode = nextNodes.find((node)=>node.id === change.containerId);
495
+ const oldRight = containerNode.position.x + change.previousSize.width;
496
+ const newRight = containerNode.position.x + change.nextSize.width;
497
+ const containerTop = containerNode.position.y;
498
+ const containerBottom = containerNode.position.y + Math.max(change.previousSize.height, change.nextSize.height);
499
+ nextNodes = nextNodes.map((node)=>{
500
+ if (node.id === containerNode.id || node.parentId !== containerNode.parentId) return node;
501
+ const nodeSize = getNodeDimensions(node);
502
+ const isRightSibling = node.position.x >= oldRight;
503
+ const verticallyOverlaps = rangesOverlap(node.position.y, node.position.y + nodeSize.height, containerTop, containerBottom);
504
+ if (!isRightSibling || !verticallyOverlaps) return node;
505
+ const nextX = Math.max(node.position.x + widthDelta, (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(newRight + gap));
506
+ if (nextX === node.position.x) return node;
507
+ shifted = true;
508
+ return {
509
+ ...node,
510
+ position: {
511
+ ...node.position,
512
+ x: nextX
513
+ }
514
+ };
515
+ });
516
+ }
517
+ return {
518
+ nodes: nextNodes,
519
+ shifted
520
+ };
521
+ }
522
+ function fitContainersAndPushSiblings({ nodes, containerIds, getContainerFitGeometry, getNodeDimensions, gap }) {
523
+ let nextNodes = nodes;
524
+ for(let iteration = 0; iteration < 10; iteration += 1){
525
+ const fitResult = ensureContainersFitChildren(nextNodes, {
526
+ containerIds,
527
+ getContainerFitGeometry,
528
+ getNodeDimensions,
529
+ includeAncestors: true
530
+ });
531
+ nextNodes = fitResult.nodes;
532
+ if (0 === fitResult.changes.length) break;
533
+ const pushResult = pushSiblingsAfterContainerGrowth({
534
+ nodes: nextNodes,
535
+ changes: fitResult.changes,
536
+ getNodeDimensions,
537
+ gap
538
+ });
539
+ nextNodes = pushResult.nodes;
540
+ if (!pushResult.shifted) break;
541
+ }
542
+ return nextNodes;
543
+ }
544
+ function getContainerPlacement({ previewNode, isContainerId }) {
545
+ const placement = previewNode.data?.[PLACEMENT_DATA_KEY];
546
+ if (!placement) return null;
547
+ if (previewNode.parentId && placement.containerId !== previewNode.parentId) return null;
548
+ return isContainerId && !isContainerId(placement.containerId) ? null : placement;
549
+ }
550
+ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry = container_getContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, gap = CONTAINER_SEQUENCE_GAP_PX, downstreamNodeIds, edges }) {
551
+ const containerNode = nodes.find((node)=>node.id === placement.containerId);
552
+ const nodesById = new Map(nodes.map((node)=>[
553
+ node.id,
554
+ node
555
+ ]));
556
+ const insertedSize = resolveNodeDimensions(insertedNode);
557
+ const resolvedSafeArea = getSafeArea(containerNode, safeArea);
558
+ const positionedNode = 'first-child' === placement.mode ? {
559
+ ...insertedNode,
560
+ position: centerInSafeArea(resolvedSafeArea, insertedSize)
561
+ } : {
562
+ ...insertedNode,
563
+ position: getInsertedPosition({
564
+ sourceNode: placement.sourceNodeId ? nodesById.get(placement.sourceNodeId) : void 0,
565
+ targetNode: placement.targetNodeId ? nodesById.get(placement.targetNodeId) : void 0,
566
+ insertedNode,
567
+ containerNode,
568
+ nodes,
569
+ safeArea: resolvedSafeArea,
570
+ insertedNodeSize: insertedSize,
571
+ gap,
572
+ getNodeDimensions: resolveNodeDimensions
573
+ })
574
+ };
575
+ const targetNode = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? nodesById.get(placement.targetNodeId) : void 0;
576
+ const fallbackTargetIds = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? [
577
+ placement.targetNodeId
578
+ ] : [];
579
+ const idsToShift = new Set(downstreamNodeIds ?? (edges ? collectDownstreamNodes({
580
+ targetNodeId: placement.targetNodeId,
581
+ containerId: placement.containerId,
582
+ nodes,
583
+ edges
584
+ }) : fallbackTargetIds));
585
+ const requiredTargetLeft = positionedNode.position.x + insertedSize.width + gap;
586
+ const downstreamShift = targetNode && targetNode.position.x < requiredTargetLeft ? (0, external_NodeUtils_cjs_namespaceObject.snapUpToGrid)(requiredTargetLeft - targetNode.position.x) : 0;
587
+ const positionedNodes = nodes.map((node)=>{
588
+ if (node.id === insertedNode.id) return positionedNode;
589
+ if (downstreamShift > 0 && idsToShift.has(node.id)) return {
590
+ ...node,
591
+ position: {
592
+ ...node.position,
593
+ x: node.position.x + downstreamShift
594
+ }
595
+ };
596
+ return node;
597
+ });
598
+ return fitContainersAndPushSiblings({
599
+ nodes: positionedNodes,
600
+ containerIds: [
601
+ placement.containerId
602
+ ],
603
+ getContainerFitGeometry: resolveContainerFitGeometry,
604
+ getNodeDimensions: resolveNodeDimensions,
605
+ gap
606
+ });
607
+ }
608
+ exports.CONTAINER_FRAME_INSET_PX = __webpack_exports__.CONTAINER_FRAME_INSET_PX;
609
+ exports.CONTAINER_SEQUENCE_GAP_PX = __webpack_exports__.CONTAINER_SEQUENCE_GAP_PX;
610
+ exports.DEFAULT_CONTAINER_HEIGHT = __webpack_exports__.DEFAULT_CONTAINER_HEIGHT;
611
+ exports.DEFAULT_CONTAINER_MIN_HEIGHT = __webpack_exports__.DEFAULT_CONTAINER_MIN_HEIGHT;
612
+ exports.DEFAULT_CONTAINER_MIN_WIDTH = __webpack_exports__.DEFAULT_CONTAINER_MIN_WIDTH;
613
+ exports.DEFAULT_CONTAINER_WIDTH = __webpack_exports__.DEFAULT_CONTAINER_WIDTH;
614
+ exports.ensureContainersFitChildren = __webpack_exports__.ensureContainersFitChildren;
615
+ exports.getContainerFitGeometry = __webpack_exports__.getContainerFitGeometry;
616
+ exports.getContainerNodeForEdge = __webpack_exports__.getContainerNodeForEdge;
617
+ exports.getContainerPlacement = __webpack_exports__.getContainerPlacement;
618
+ exports.getContainerSafeArea = __webpack_exports__.getContainerSafeArea;
619
+ exports.getNodeDimensions = __webpack_exports__.getNodeDimensions;
620
+ exports.isContainerNodeManifest = __webpack_exports__.isContainerNodeManifest;
621
+ exports.placeContainerNode = __webpack_exports__.placeContainerNode;
622
+ exports.resolveContainerPreview = __webpack_exports__.resolveContainerPreview;
623
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
624
+ "CONTAINER_FRAME_INSET_PX",
625
+ "CONTAINER_SEQUENCE_GAP_PX",
626
+ "DEFAULT_CONTAINER_HEIGHT",
627
+ "DEFAULT_CONTAINER_MIN_HEIGHT",
628
+ "DEFAULT_CONTAINER_MIN_WIDTH",
629
+ "DEFAULT_CONTAINER_WIDTH",
630
+ "ensureContainersFitChildren",
631
+ "getContainerFitGeometry",
632
+ "getContainerNodeForEdge",
633
+ "getContainerPlacement",
634
+ "getContainerSafeArea",
635
+ "getNodeDimensions",
636
+ "isContainerNodeManifest",
637
+ "placeContainerNode",
638
+ "resolveContainerPreview"
639
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
640
+ Object.defineProperty(exports, '__esModule', {
641
+ value: true
642
+ });