@cascivo/flow 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1138 +1 @@
1
- "use client";
2
- import { cn as e, useComputed as t, useControllableSignal as n, useDraggable as r, useEffectPropSignal as i, useResizeObserver as a, useSignal as o, useSignalEffect as s, useSignals as c } from "@cascivo/core";
3
- import { useId as l, useRef as u } from "react";
4
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
- import { cn as m } from "@cascivo/core/pure";
6
- import { builtin as h, t as g } from "@cascivo/i18n";
7
- //#region src/engine/types.ts
8
- var _ = {
9
- width: 150,
10
- height: 40
11
- }, v = {
12
- x: 0,
13
- y: 0,
14
- zoom: 1
15
- };
16
- function y(e = {}) {
17
- let [t, r] = n({
18
- value: e.nodes,
19
- defaultValue: e.defaultNodes ?? [],
20
- onChange: e.onNodesChange
21
- }), [i, a] = n({
22
- value: e.edges,
23
- defaultValue: e.defaultEdges ?? [],
24
- onChange: e.onEdgesChange
25
- }), [o, s] = n({
26
- value: e.viewport,
27
- defaultValue: e.defaultViewport ?? v,
28
- onChange: e.onViewportChange
29
- });
30
- return {
31
- nodes: t,
32
- edges: i,
33
- viewport: o,
34
- setNodes: r,
35
- updateNode: (e, n) => {
36
- r(t.value.map((t) => t.id === e ? {
37
- ...t,
38
- ...n
39
- } : t));
40
- },
41
- setEdges: a,
42
- addEdge: (e) => {
43
- a([...i.value, e]);
44
- },
45
- setViewport: s
46
- };
47
- }
48
- //#endregion
49
- //#region src/engine/transform.ts
50
- function b(e, t = .2, n = 2) {
51
- return Math.min(n, Math.max(t, e));
52
- }
53
- function x(e, t) {
54
- return {
55
- x: (e.x - t.x) / t.zoom,
56
- y: (e.y - t.y) / t.zoom
57
- };
58
- }
59
- function S(e, t) {
60
- return {
61
- x: e.x * t.zoom + t.x,
62
- y: e.y * t.zoom + t.y
63
- };
64
- }
65
- //#endregion
66
- //#region src/engine/geometry.ts
67
- function C(e) {
68
- return {
69
- width: e.width ?? _.width,
70
- height: e.height ?? _.height
71
- };
72
- }
73
- function w(e) {
74
- let { width: t, height: n } = C(e);
75
- return {
76
- x: e.position.x,
77
- y: e.position.y,
78
- width: t,
79
- height: n
80
- };
81
- }
82
- function T(e, t) {
83
- let { x: n, y: r, width: i, height: a } = w(e);
84
- switch (t) {
85
- case "top": return {
86
- x: n + i / 2,
87
- y: r
88
- };
89
- case "right": return {
90
- x: n + i,
91
- y: r + a / 2
92
- };
93
- case "bottom": return {
94
- x: n + i / 2,
95
- y: r + a
96
- };
97
- case "left": return {
98
- x: n,
99
- y: r + a / 2
100
- };
101
- }
102
- }
103
- function E(e) {
104
- if (e.length === 0) return null;
105
- let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
106
- for (let a of e) {
107
- let e = w(a);
108
- t = Math.min(t, e.x), n = Math.min(n, e.y), r = Math.max(r, e.x + e.width), i = Math.max(i, e.y + e.height);
109
- }
110
- return {
111
- x: t,
112
- y: n,
113
- width: r - t,
114
- height: i - n
115
- };
116
- }
117
- function D(e, t, n = {}) {
118
- let { padding: r = .1, minZoom: i = .2, maxZoom: a = 2 } = n;
119
- if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0) return {
120
- x: t.width / 2 - e.x,
121
- y: t.height / 2 - e.y,
122
- zoom: 1
123
- };
124
- let o = t.width / (e.width * (1 + r * 2)), s = t.height / (e.height * (1 + r * 2)), c = b(Math.min(o, s), i, a);
125
- return {
126
- x: t.width / 2 - (e.x + e.width / 2) * c,
127
- y: t.height / 2 - (e.y + e.height / 2) * c,
128
- zoom: c
129
- };
130
- }
131
- //#endregion
132
- //#region src/engine/path.ts
133
- var O = (e) => Number.isInteger(e) ? String(e) : e.toFixed(2).replace(/\.?0+$/, ""), k = (e, t) => ({
134
- x: (e.x + t.x) / 2,
135
- y: (e.y + t.y) / 2
136
- });
137
- function A(e) {
138
- switch (e) {
139
- case "top": return {
140
- x: 0,
141
- y: -1
142
- };
143
- case "bottom": return {
144
- x: 0,
145
- y: 1
146
- };
147
- case "left": return {
148
- x: -1,
149
- y: 0
150
- };
151
- case "right": return {
152
- x: 1,
153
- y: 0
154
- };
155
- }
156
- }
157
- function j({ source: e, target: t }) {
158
- return {
159
- d: `M${O(e.x)},${O(e.y)} L${O(t.x)},${O(t.y)}`,
160
- mid: k(e, t)
161
- };
162
- }
163
- function M(e) {
164
- let { source: t, target: n, curvature: r = .25 } = e, i = e.sourcePosition ?? "right", a = e.targetPosition ?? "left", o = Math.hypot(n.x - t.x, n.y - t.y), s = Math.max(r * o, 20), c = A(i), l = A(a), u = {
165
- x: t.x + c.x * s,
166
- y: t.y + c.y * s
167
- }, d = {
168
- x: n.x + l.x * s,
169
- y: n.y + l.y * s
170
- }, f = {
171
- x: (t.x + 3 * u.x + 3 * d.x + n.x) / 8,
172
- y: (t.y + 3 * u.y + 3 * d.y + n.y) / 8
173
- };
174
- return {
175
- d: `M${O(t.x)},${O(t.y)} C${O(u.x)},${O(u.y)} ${O(d.x)},${O(d.y)} ${O(n.x)},${O(n.y)}`,
176
- mid: f
177
- };
178
- }
179
- function N(e, t) {
180
- return Math.hypot(t.x - e.x, t.y - e.y);
181
- }
182
- function P(e, t, n) {
183
- let r = N(e, t) || 1;
184
- return {
185
- x: e.x + (t.x - e.x) / r * n,
186
- y: e.y + (t.y - e.y) / r * n
187
- };
188
- }
189
- function F(e, t) {
190
- if (e.length < 2) return "";
191
- let n = e[0], r = `M${O(n.x)},${O(n.y)}`;
192
- for (let n = 1; n < e.length - 1; n++) {
193
- let i = e[n - 1], a = e[n], o = e[n + 1], s = Math.min(t, N(i, a) / 2, N(a, o) / 2), c = P(a, i, s), l = P(a, o, s);
194
- r += ` L${O(c.x)},${O(c.y)} Q${O(a.x)},${O(a.y)} ${O(l.x)},${O(l.y)}`;
195
- }
196
- let i = e[e.length - 1];
197
- return r += ` L${O(i.x)},${O(i.y)}`, r;
198
- }
199
- function I(e) {
200
- let { source: t, target: n, borderRadius: r = 8 } = e, i = e.sourcePosition ?? "right", a = i === "left" || i === "right", o = [t];
201
- if (a) {
202
- let e = (t.x + n.x) / 2;
203
- o.push({
204
- x: e,
205
- y: t.y
206
- }, {
207
- x: e,
208
- y: n.y
209
- });
210
- } else {
211
- let e = (t.y + n.y) / 2;
212
- o.push({
213
- x: t.x,
214
- y: e
215
- }, {
216
- x: n.x,
217
- y: e
218
- });
219
- }
220
- return o.push(n), {
221
- d: F(o, r),
222
- mid: k(t, n)
223
- };
224
- }
225
- function L(e, t) {
226
- switch (e) {
227
- case "straight": return j(t);
228
- case "smoothstep": return I(t);
229
- case "bezier": return M(t);
230
- }
231
- }
232
- //#endregion
233
- //#region src/engine/layout.ts
234
- function R(e, t = {}) {
235
- let n = t.gap ?? 40, r = t.nodeWidth ?? _.width, i = t.nodeHeight ?? _.height, a = t.columns ?? Math.max(1, Math.ceil(Math.sqrt(e.length)));
236
- return e.map((e, t) => {
237
- let o = t % a, s = Math.floor(t / a);
238
- return {
239
- ...e,
240
- position: {
241
- x: o * (r + n),
242
- y: s * (i + n)
243
- }
244
- };
245
- });
246
- }
247
- function z(e, t, n = {}) {
248
- let r = n.direction ?? "LR", i = n.gap ?? 60, a = n.nodeWidth ?? _.width, o = n.nodeHeight ?? _.height, s = new Set(e.map((e) => e.id)), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
249
- for (let t of e) l.set(t.id, 0);
250
- for (let e of t) !s.has(e.source) || !s.has(e.target) || (c.set(e.source, [...c.get(e.source) ?? [], e.target]), l.set(e.target, (l.get(e.target) ?? 0) + 1));
251
- let u = /* @__PURE__ */ new Map(), d = e.filter((e) => (l.get(e.id) ?? 0) === 0).map((e) => e.id);
252
- for (let e of d) u.set(e, 0);
253
- let f = new Map(l);
254
- for (; d.length > 0;) {
255
- let e = [];
256
- for (let t of d) {
257
- let n = u.get(t) ?? 0;
258
- for (let r of c.get(t) ?? []) u.set(r, Math.max(u.get(r) ?? 0, n + 1)), f.set(r, (f.get(r) ?? 0) - 1), (f.get(r) ?? 0) === 0 && e.push(r);
259
- }
260
- d = e;
261
- }
262
- for (let t of e) u.has(t.id) || u.set(t.id, 0);
263
- let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
264
- for (let t of e) {
265
- let e = u.get(t.id) ?? 0, n = m.get(e) ?? 0;
266
- p.set(t.id, n), m.set(e, n + 1);
267
- }
268
- return e.map((e) => {
269
- let t = u.get(e.id) ?? 0, n = p.get(e.id) ?? 0, s = r === "LR" ? {
270
- x: t * (a + i),
271
- y: n * (o + i)
272
- } : {
273
- x: n * (a + i),
274
- y: t * (o + i)
275
- };
276
- return {
277
- ...e,
278
- position: s
279
- };
280
- });
281
- }
282
- function B(e, t, n) {
283
- return n === "grid" ? R(e) : n === "layered" ? z(e, t) : n(e, t);
284
- }
285
- //#endregion
286
- //#region src/engine/script.ts
287
- function V(e) {
288
- return "edge" in e;
289
- }
290
- function ee(e, t) {
291
- let n = {
292
- label: e.label,
293
- description: e.description,
294
- duration: e.duration
295
- };
296
- if (V(e)) {
297
- let r = t.find((t) => t.id === e.edge);
298
- if (!r) throw Error(`FlowStory: step references unknown edge "${e.edge}"`);
299
- return {
300
- edgeId: r.id,
301
- direction: e.reverse ? "reverse" : "forward",
302
- ...n
303
- };
304
- }
305
- let r = t.find((t) => t.source === e.from && t.target === e.to);
306
- if (r) return {
307
- edgeId: r.id,
308
- direction: "forward",
309
- ...n
310
- };
311
- let i = t.find((t) => t.source === e.to && t.target === e.from);
312
- if (i) return {
313
- edgeId: i.id,
314
- direction: "reverse",
315
- ...n
316
- };
317
- throw Error(`FlowStory: no edge connects "${e.from}" and "${e.to}"`);
318
- }
319
- function te(e, t) {
320
- return e.map((e) => ee(e, t));
321
- }
322
- //#endregion
323
- //#region src/core/use-viewport.ts
324
- var H = 1.2;
325
- function U(e, t = {}) {
326
- let { minZoom: n = .2, maxZoom: i = 2, panOnDrag: o = !0, zoomOnScroll: c = !0, fitPadding: l = .1, fitOnInit: d = !1 } = t, { viewport: f, setViewport: p } = e, { ref: m, size: h } = a(), { handleRef: g, offset: _, isDragging: v } = r({ isDisabled: !o }), y = (e, t) => {
327
- let n = f.peek();
328
- p({
329
- x: n.x + e,
330
- y: n.y + t,
331
- zoom: n.zoom
332
- });
333
- }, S = (e, t) => {
334
- let r = f.peek(), a = b(e, n, i);
335
- if (!t) {
336
- p({
337
- x: r.x,
338
- y: r.y,
339
- zoom: a
340
- });
341
- return;
342
- }
343
- let o = x(t, r);
344
- p({
345
- x: t.x - o.x * a,
346
- y: t.y - o.y * a,
347
- zoom: a
348
- });
349
- }, C = () => {
350
- let e = m.current;
351
- if (e) return {
352
- x: e.clientWidth / 2,
353
- y: e.clientHeight / 2
354
- };
355
- }, w = () => S(f.peek().zoom * H, C()), T = () => S(f.peek().zoom / H, C()), O = () => {
356
- let e = h.peek();
357
- if (e && e.width > 0 && e.height > 0) return e;
358
- let t = m.current;
359
- return t && t.clientWidth > 0 ? {
360
- width: t.clientWidth,
361
- height: t.clientHeight
362
- } : null;
363
- }, k = (t) => {
364
- let r = E(e.nodes.peek());
365
- if (!r) return;
366
- let a = t ?? O();
367
- a && p(D(r, a, {
368
- padding: l,
369
- minZoom: n,
370
- maxZoom: i
371
- }));
372
- }, A = u(null);
373
- s(() => {
374
- let e = v.value, t = _.value;
375
- if (!o) return;
376
- if (!e) {
377
- A.current = null;
378
- return;
379
- }
380
- A.current ||= {
381
- vp: f.peek(),
382
- off: t
383
- };
384
- let n = A.current;
385
- p({
386
- x: n.vp.x + (t.x - n.off.x),
387
- y: n.vp.y + (t.y - n.off.y),
388
- zoom: n.vp.zoom
389
- });
390
- }), s(() => {
391
- if (!c || typeof window > "u") return;
392
- let e = m.current;
393
- if (!e) return;
394
- let t = (t) => {
395
- t.preventDefault();
396
- let n = e.getBoundingClientRect(), r = {
397
- x: t.clientX - n.left,
398
- y: t.clientY - n.top
399
- }, i = t.deltaY < 0 ? H : 1 / H;
400
- S(f.peek().zoom * i, r);
401
- };
402
- return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
403
- });
404
- let j = u(!1);
405
- return s(() => {
406
- if (!d || j.current) return;
407
- let e = h.value;
408
- !e || e.width === 0 || (j.current = !0, k(e));
409
- }), {
410
- containerRef: m,
411
- panHandleRef: g,
412
- viewport: f,
413
- pan: y,
414
- zoomTo: S,
415
- zoomIn: w,
416
- zoomOut: T,
417
- fitView: k
418
- };
419
- }
420
- //#endregion
421
- //#region src/core/use-connection.ts
422
- var ne = "[data-flow-handle][data-handle-type=\"source\"]", re = "[data-flow-handle][data-handle-type=\"target\"]";
423
- function ie(e) {
424
- let { containerRef: t } = e, n = o(null), r = u(e.onConnect);
425
- r.current = e.onConnect;
426
- let a = u(e.isValid);
427
- a.current = e.isValid;
428
- let c = u(e.clientToFlow);
429
- c.current = e.clientToFlow;
430
- let l = i(e.enabled ?? !0);
431
- return s(() => {
432
- if (!l.value || typeof window > "u") return;
433
- let e = t.current;
434
- if (!e) return;
435
- let i = (e) => {
436
- let t = n.peek();
437
- t && (n.value = {
438
- ...t,
439
- to: c.current(e.clientX, e.clientY)
440
- });
441
- }, o = (e) => {
442
- let t = n.peek();
443
- if (window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), n.value = null, !t) return;
444
- let s = e.target, c = s instanceof Element ? s.closest(re) : null, l = c?.closest("[data-node-id]");
445
- if (!l) return;
446
- let u = {
447
- source: t.source,
448
- target: l.getAttribute("data-node-id") ?? "",
449
- sourceHandle: t.sourceHandle,
450
- targetHandle: c?.getAttribute("data-handle-id") ?? void 0
451
- };
452
- !u.target || u.source === u.target || a.current && !a.current(u) || r.current?.(u);
453
- }, s = (e) => {
454
- let t = e.target;
455
- if (!(t instanceof Element)) return;
456
- let r = t.closest(ne);
457
- if (!r) return;
458
- let a = r.closest("[data-node-id]");
459
- if (!a) return;
460
- e.stopPropagation();
461
- let s = r.getBoundingClientRect();
462
- n.value = {
463
- source: a.getAttribute("data-node-id") ?? "",
464
- sourceHandle: r.getAttribute("data-handle-id") ?? void 0,
465
- from: c.current(s.left + s.width / 2, s.top + s.height / 2),
466
- to: c.current(e.clientX, e.clientY)
467
- }, window.addEventListener("pointermove", i), window.addEventListener("pointerup", o);
468
- };
469
- return e.addEventListener("pointerdown", s), () => {
470
- e.removeEventListener("pointerdown", s), window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o);
471
- };
472
- }), { connection: n };
473
- }
474
- //#endregion
475
- //#region src/core/use-story.ts
476
- var ae = 1500;
477
- function oe(e) {
478
- let { steps: r, loop: i = !0, stepDuration: a = ae, stepGap: o = 0 } = e, [c, l] = n({
479
- value: e.currentStep,
480
- defaultValue: e.defaultCurrentStep ?? 0,
481
- onChange: e.onStepChange
482
- }), [d, f] = n({
483
- value: e.playing,
484
- defaultValue: e.defaultPlaying ?? !0,
485
- onChange: e.onPlayingChange
486
- }), p = t(() => r[c.value] ?? null), m = u(e.clock);
487
- m.current = e.clock;
488
- let h = u(r);
489
- h.current = r;
490
- let g = () => m.current ?? {
491
- setTimeout: (e, t) => window.setTimeout(e, t),
492
- clearTimeout: (e) => window.clearTimeout(e)
493
- }, _ = (e) => {
494
- let t = h.current.length;
495
- if (t === 0) return;
496
- let n = c.peek() + e;
497
- l(i ? (n % t + t) % t : Math.max(0, Math.min(t - 1, n)));
498
- };
499
- return s(() => {
500
- if (!d.value) return;
501
- let e = c.value, t = r.length;
502
- if (t === 0 || typeof window > "u" && !m.current) return;
503
- let n = (r[e]?.duration ?? a) + o, s = g(), u = s.setTimeout(() => {
504
- let n = e + 1;
505
- n >= t ? i ? l(0) : f(!1) : l(n);
506
- }, n);
507
- return () => s.clearTimeout(u);
508
- }), {
509
- currentStep: c,
510
- playing: d,
511
- activeStep: p,
512
- play: () => f(!0),
513
- pause: () => f(!1),
514
- toggle: () => f(!d.peek()),
515
- next: () => _(1),
516
- prev: () => _(-1),
517
- restart: () => {
518
- l(0), f(!0);
519
- }
520
- };
521
- }
522
- var W = {
523
- canvas: "_canvas_6fiig_2",
524
- pane: "_pane_6fiig_13",
525
- panSurface: "_panSurface_6fiig_24"
526
- };
527
- //#endregion
528
- //#region src/core/flow-canvas/flow-canvas.tsx
529
- function se({ children: t, flow: n, viewport: r, defaultViewport: i, onViewportChange: a, minZoom: o, maxZoom: s, panOnDrag: l = !0, zoomOnScroll: u = !0, fitView: d = !1, controller: m, chrome: h, className: g, role: _ = "application", ...v }) {
530
- c();
531
- let b = y({
532
- viewport: r,
533
- defaultViewport: i,
534
- onViewportChange: a
535
- }), x = n ?? b, S = U(x, {
536
- minZoom: o,
537
- maxZoom: s,
538
- panOnDrag: l,
539
- zoomOnScroll: u,
540
- fitOnInit: d
541
- }), C = m ?? S, w = x.viewport.value;
542
- return /* @__PURE__ */ p("div", {
543
- ref: C.containerRef,
544
- className: e(W.canvas, g),
545
- role: _,
546
- ...v,
547
- children: [/* @__PURE__ */ p("div", {
548
- className: W.pane,
549
- style: {
550
- "--flow-tx": `${w.x}px`,
551
- "--flow-ty": `${w.y}px`,
552
- "--flow-scale": String(w.zoom)
553
- },
554
- children: [/* @__PURE__ */ f("div", {
555
- ref: C.panHandleRef,
556
- className: W.panSurface,
557
- "aria-hidden": "true"
558
- }), t]
559
- }), h]
560
- });
561
- }
562
- var ce = { background: "_background_1pu9x_2" };
563
- //#endregion
564
- //#region src/flows/flow-background/flow-background.tsx
565
- function le({ variant: e = "dots", gap: t = 20, size: n = 1, color: r, className: i, style: a, ...o }) {
566
- return /* @__PURE__ */ f("div", {
567
- "data-variant": e,
568
- "aria-hidden": "true",
569
- className: m(ce.background, i),
570
- style: {
571
- "--flow-bg-gap": `${t}px`,
572
- "--flow-bg-size": `${n}px`,
573
- "--flow-bg-thick": `${Math.max(1, n)}px`,
574
- ...r ? { "--flow-bg-color": r } : {},
575
- ...a
576
- },
577
- ...o
578
- });
579
- }
580
- var ue = { node: "_node_9zyg4_2" };
581
- //#endregion
582
- //#region src/flows/flow-node/flow-node.tsx
583
- function de({ id: t, position: i, defaultPosition: a, onPositionChange: o, onMeasure: l, zoom: d = 1, selected: p = !1, draggable: m = !0, interactive: h = !0, onSelect: g, children: _, className: v, onClick: y, onKeyDown: b, ...x }) {
584
- c();
585
- let S = m && h, [C, w] = n({
586
- value: i,
587
- defaultValue: a ?? i ?? {
588
- x: 0,
589
- y: 0
590
- },
591
- onChange: o
592
- }), { handleRef: T, targetRef: E, offset: D, isDragging: O } = r({ isDisabled: !S }), k = u(null), A = (e) => {
593
- k.current = e, T.current = e, E.current = e;
594
- }, j = u(l);
595
- j.current = l, s(() => {
596
- let e = k.current;
597
- if (!e || typeof ResizeObserver > "u") return;
598
- let t = () => {
599
- let t = e.offsetWidth, n = e.offsetHeight;
600
- t > 0 && n > 0 && j.current?.({
601
- width: t,
602
- height: n
603
- });
604
- };
605
- t();
606
- let n = new ResizeObserver(t);
607
- return n.observe(e), () => n.disconnect();
608
- });
609
- let M = u(d);
610
- M.current = d;
611
- let N = u(null);
612
- s(() => {
613
- let e = O.value, t = D.value;
614
- if (!S) return;
615
- if (!e) {
616
- N.current = null;
617
- return;
618
- }
619
- N.current ||= {
620
- pos: C.peek(),
621
- off: t
622
- };
623
- let n = N.current, r = M.current || 1;
624
- w({
625
- x: n.pos.x + (t.x - n.off.x) / r,
626
- y: n.pos.y + (t.y - n.off.y) / r
627
- });
628
- });
629
- let P = C.value;
630
- return /* @__PURE__ */ f("div", {
631
- ref: A,
632
- "data-node-id": t,
633
- "data-selected": p || void 0,
634
- "data-dragging": O.value || void 0,
635
- "data-static": !h || void 0,
636
- role: "group",
637
- tabIndex: h ? 0 : void 0,
638
- className: e(ue.node, v),
639
- style: {
640
- "--flow-x": `${P.x}px`,
641
- "--flow-y": `${P.y}px`
642
- },
643
- onClick: (e) => {
644
- h && g?.(t), y?.(e);
645
- },
646
- onKeyDown: (e) => {
647
- h && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), g?.(t)), b?.(e);
648
- },
649
- ...x,
650
- children: _
651
- });
652
- }
653
- var G = {
654
- handle: "_handle_8a1xa_2",
655
- dot: "_dot_8a1xa_41"
656
- };
657
- //#endregion
658
- //#region src/flows/flow-handle/flow-handle.tsx
659
- function fe(e) {
660
- return e === "source" ? "right" : "left";
661
- }
662
- function K({ type: e, position: t, id: n, isConnectable: r = !0, className: i, ...a }) {
663
- return /* @__PURE__ */ f("div", {
664
- "data-handle-type": e,
665
- "data-handle-pos": t ?? fe(e),
666
- "data-handle-id": n,
667
- "data-connectable": r || void 0,
668
- "data-flow-handle": "",
669
- tabIndex: r ? 0 : -1,
670
- className: m(G.handle, i),
671
- ...a,
672
- children: /* @__PURE__ */ f("span", {
673
- className: G.dot,
674
- "aria-hidden": "true"
675
- })
676
- });
677
- }
678
- var q = {
679
- edgeSvg: "_edgeSvg_789n0_2",
680
- edgePath: "_edgePath_789n0_11",
681
- hit: "_hit_789n0_18",
682
- arrow: "_arrow_789n0_26",
683
- "cascivo-flow-dash": "_cascivo-flow-dash_789n0_1",
684
- label: "_label_789n0_64"
685
- };
686
- //#endregion
687
- //#region src/flows/flow-edge/flow-edge.tsx
688
- function J({ id: t, sourceX: n, sourceY: r, targetX: i, targetY: a, sourcePosition: o = "right", targetPosition: s = "left", type: c = "bezier", animated: u = !1, label: m, selected: h = !1, markerStart: g = !1, markerEnd: _ = !0, direction: v = "forward", active: y, className: b }) {
689
- let x = l(), S = `flow-arrow-${t ?? x}`, C = g || _, { d: w, mid: T } = L(c, {
690
- source: {
691
- x: n,
692
- y: r
693
- },
694
- target: {
695
- x: i,
696
- y: a
697
- },
698
- sourcePosition: o,
699
- targetPosition: s
700
- });
701
- return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("svg", {
702
- className: e(q.edgeSvg, b),
703
- "data-edge-id": t,
704
- "data-animated": u || void 0,
705
- "data-selected": h || void 0,
706
- "data-active": y || void 0,
707
- "data-direction": v,
708
- "aria-hidden": "true",
709
- children: [
710
- C && /* @__PURE__ */ f("defs", { children: /* @__PURE__ */ f("marker", {
711
- id: S,
712
- viewBox: "0 0 10 10",
713
- refX: "9",
714
- refY: "5",
715
- markerWidth: "7",
716
- markerHeight: "7",
717
- orient: "auto-start-reverse",
718
- children: /* @__PURE__ */ f("path", {
719
- className: q.arrow,
720
- d: "M0,0 L10,5 L0,10 z"
721
- })
722
- }) }),
723
- /* @__PURE__ */ f("path", {
724
- className: q.hit,
725
- d: w
726
- }),
727
- /* @__PURE__ */ f("path", {
728
- className: q.edgePath,
729
- d: w,
730
- markerStart: g ? `url(#${S})` : void 0,
731
- markerEnd: _ ? `url(#${S})` : void 0
732
- })
733
- ]
734
- }), m != null && /* @__PURE__ */ f("div", {
735
- className: q.label,
736
- style: {
737
- "--flow-label-x": `${T.x}px`,
738
- "--flow-label-y": `${T.y}px`
739
- },
740
- children: m
741
- })] });
742
- }
743
- var Y = {
744
- controls: "_controls_s32im_2",
745
- button: "_button_s32im_32"
746
- }, X = {
747
- width: 18,
748
- height: 18,
749
- viewBox: "0 0 24 24",
750
- fill: "none",
751
- "aria-hidden": !0
752
- };
753
- function pe({ position: t = "bottom-left", showZoom: n = !0, showFitView: r = !0, onZoomIn: i, onZoomOut: a, onFitView: o, labels: s, className: l, ...u }) {
754
- return c(), /* @__PURE__ */ p("div", {
755
- "data-position": t,
756
- className: e(Y.controls, l),
757
- ...u,
758
- children: [n && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
759
- type: "button",
760
- className: Y.button,
761
- "aria-label": s?.zoomIn ?? g(h.flow.zoomIn),
762
- onClick: i,
763
- children: /* @__PURE__ */ f("svg", {
764
- ...X,
765
- children: /* @__PURE__ */ f("path", {
766
- d: "M12 5v14M5 12h14",
767
- stroke: "currentColor",
768
- strokeWidth: "2",
769
- strokeLinecap: "round"
770
- })
771
- })
772
- }), /* @__PURE__ */ f("button", {
773
- type: "button",
774
- className: Y.button,
775
- "aria-label": s?.zoomOut ?? g(h.flow.zoomOut),
776
- onClick: a,
777
- children: /* @__PURE__ */ f("svg", {
778
- ...X,
779
- children: /* @__PURE__ */ f("path", {
780
- d: "M5 12h14",
781
- stroke: "currentColor",
782
- strokeWidth: "2",
783
- strokeLinecap: "round"
784
- })
785
- })
786
- })] }), r && /* @__PURE__ */ f("button", {
787
- type: "button",
788
- className: Y.button,
789
- "aria-label": s?.fitView ?? g(h.flow.fitView),
790
- onClick: o,
791
- children: /* @__PURE__ */ f("svg", {
792
- ...X,
793
- children: /* @__PURE__ */ f("path", {
794
- d: "M4 9V5a1 1 0 0 1 1-1h4M15 4h4a1 1 0 0 1 1 1v4M20 15v4a1 1 0 0 1-1 1h-4M9 20H5a1 1 0 0 1-1-1v-4",
795
- stroke: "currentColor",
796
- strokeWidth: "2",
797
- strokeLinecap: "round",
798
- strokeLinejoin: "round"
799
- })
800
- })
801
- })]
802
- });
803
- }
804
- var Z = {
805
- minimap: "_minimap_rdahv_2",
806
- node: "_node_rdahv_28",
807
- viewport: "_viewport_rdahv_32"
808
- };
809
- //#endregion
810
- //#region src/flows/flow-minimap/flow-minimap.tsx
811
- function me({ nodes: t, viewport: n, containerWidth: i, containerHeight: a, width: o = 200, height: l = 150, position: d = "bottom-right", nodeColor: m, onViewportChange: _, label: v, ariaLabel: y, className: b }) {
812
- c();
813
- let S = E(t) ?? {
814
- x: 0,
815
- y: 0,
816
- width: 1,
817
- height: 1
818
- }, C = S.width || 1, T = S.height || 1, D = C * .1, O = T * .1, k = {
819
- x: S.x - D,
820
- y: S.y - O,
821
- width: C + D * 2,
822
- height: T + O * 2
823
- }, A = Math.min(o / k.width, l / k.height), j = -k.x * A + (o - k.width * A) / 2, M = -k.y * A + (l - k.height * A) / 2, N = (e) => ({
824
- x: e.x * A + j,
825
- y: e.y * A + M
826
- }), P = null;
827
- if (i && a) {
828
- let e = x({
829
- x: 0,
830
- y: 0
831
- }, n), t = x({
832
- x: i,
833
- y: a
834
- }, n), r = N(e);
835
- P = {
836
- x: r.x,
837
- y: r.y,
838
- w: (t.x - e.x) * A,
839
- h: (t.y - e.y) * A
840
- };
841
- }
842
- let { handleRef: F, offset: I, isDragging: L } = r({ isDisabled: !_ }), R = u(null), z = (e) => {
843
- R.current = e, F.current = e;
844
- }, B = u(_);
845
- B.current = _;
846
- let V = u(null);
847
- return s(() => {
848
- let e = L.value, t = I.value;
849
- if (!B.current) return;
850
- if (!e) {
851
- V.current = null;
852
- return;
853
- }
854
- V.current ||= {
855
- vp: n,
856
- off: t
857
- };
858
- let r = V.current, i = r.vp.zoom;
859
- B.current({
860
- x: r.vp.x - (t.x - r.off.x) / A * i,
861
- y: r.vp.y - (t.y - r.off.y) / A * i,
862
- zoom: i
863
- });
864
- }), /* @__PURE__ */ p("svg", {
865
- "data-position": d,
866
- className: e(Z.minimap, b),
867
- width: o,
868
- height: l,
869
- role: "img",
870
- "aria-label": y ?? v ?? g(h.flow.minimap),
871
- children: [t.map((e) => {
872
- let t = w(e), n = N({
873
- x: t.x,
874
- y: t.y
875
- });
876
- return /* @__PURE__ */ f("rect", {
877
- "data-node-id": e.id,
878
- className: Z.node,
879
- x: n.x,
880
- y: n.y,
881
- width: t.width * A,
882
- height: t.height * A,
883
- fill: m
884
- }, e.id);
885
- }), P && /* @__PURE__ */ f("rect", {
886
- ref: z,
887
- "data-viewport": "",
888
- className: Z.viewport,
889
- x: P.x,
890
- y: P.y,
891
- width: P.w,
892
- height: P.h
893
- })]
894
- });
895
- }
896
- var he = { panel: "_panel_l0cix_2" };
897
- //#endregion
898
- //#region src/flows/flow-panel/flow-panel.tsx
899
- function ge({ position: e = "top-right", children: t, className: n, ...r }) {
900
- return /* @__PURE__ */ f("div", {
901
- "data-position": e,
902
- className: m(he.panel, n),
903
- ...r,
904
- children: t
905
- });
906
- }
907
- var _e = { flow: "_flow_vejge_2" }, ve = 0;
908
- function ye({ nodes: t, edges: n, onNodesChange: r, onEdgesChange: i, onConnect: a, nodeTypes: s, fitView: l = !0, background: u = !1, controls: m = !1, minimap: h = !1, layout: g, minZoom: _, maxZoom: v, interactive: b = !0, activeEdgeId: S, activeDirection: C, className: w, style: E }) {
909
- c();
910
- let D = y({
911
- defaultNodes: g ? B(t, n, g) : t,
912
- defaultEdges: n,
913
- onNodesChange: r,
914
- onEdgesChange: i
915
- }), O = U(D, {
916
- minZoom: _,
917
- maxZoom: v,
918
- fitOnInit: l
919
- }), { connection: k } = ie({
920
- containerRef: O.containerRef,
921
- clientToFlow: (e, t) => {
922
- let n = O.containerRef.current?.getBoundingClientRect();
923
- return x({
924
- x: e - (n?.left ?? 0),
925
- y: t - (n?.top ?? 0)
926
- }, D.viewport.peek());
927
- },
928
- enabled: b,
929
- onConnect: (e) => {
930
- D.addEdge({
931
- id: `e-${++ve}`,
932
- source: e.source,
933
- target: e.target
934
- }), a?.(e);
935
- }
936
- }), A = (e) => {
937
- D.setNodes(D.nodes.value.map((t) => ({
938
- ...t,
939
- selected: t.id === e
940
- })));
941
- }, j = o({}), M = (e, t) => {
942
- let n = j.peek()[e];
943
- n && n.width === t.width && n.height === t.height || (j.value = {
944
- ...j.peek(),
945
- [e]: t
946
- });
947
- }, N = D.nodes.value, P = D.edges.value, F = D.viewport.value.zoom, I = j.value, L = new Map(N.map((e) => {
948
- let t = I[e.id];
949
- return [e.id, t ? {
950
- ...e,
951
- width: t.width,
952
- height: t.height
953
- } : e];
954
- })), R = k.value;
955
- return /* @__PURE__ */ p(se, {
956
- flow: D,
957
- controller: O,
958
- minZoom: _,
959
- maxZoom: v,
960
- chrome: /* @__PURE__ */ p(d, { children: [m && /* @__PURE__ */ f(pe, {
961
- onZoomIn: O.zoomIn,
962
- onZoomOut: O.zoomOut,
963
- onFitView: () => O.fitView()
964
- }), h && /* @__PURE__ */ f(me, {
965
- nodes: N,
966
- viewport: D.viewport.value,
967
- containerWidth: O.containerRef.current?.clientWidth,
968
- containerHeight: O.containerRef.current?.clientHeight,
969
- onViewportChange: D.setViewport
970
- })] }),
971
- className: e(_e.flow, w),
972
- style: E,
973
- children: [
974
- u && /* @__PURE__ */ f(le, { ...typeof u == "object" ? u : {} }),
975
- P.map((e) => {
976
- let t = L.get(e.source), n = L.get(e.target);
977
- if (!t || !n) return null;
978
- let r = T(t, "right"), i = T(n, "left"), a = S === e.id, o = a ? C : void 0, s = o === "reverse" ? !0 : o === "forward" ? !1 : e.markerStart ?? !1, c = o === "reverse" ? !1 : o === "forward" ? !0 : e.markerEnd ?? !0;
979
- return /* @__PURE__ */ f(J, {
980
- id: e.id,
981
- sourceX: r.x,
982
- sourceY: r.y,
983
- targetX: i.x,
984
- targetY: i.y,
985
- type: e.type ?? "bezier",
986
- animated: e.animated || a,
987
- active: a,
988
- direction: o,
989
- markerStart: s,
990
- markerEnd: c,
991
- label: e.label,
992
- selected: e.selected
993
- }, e.id);
994
- }),
995
- R && /* @__PURE__ */ f(J, {
996
- sourceX: R.from.x,
997
- sourceY: R.from.y,
998
- targetX: R.to.x,
999
- targetY: R.to.y,
1000
- markerEnd: !1
1001
- }),
1002
- N.map((e) => /* @__PURE__ */ f(de, {
1003
- id: e.id,
1004
- position: e.position,
1005
- zoom: F,
1006
- interactive: b,
1007
- selected: e.selected ?? !1,
1008
- onSelect: b ? A : void 0,
1009
- onMeasure: (t) => M(e.id, t),
1010
- onPositionChange: (t) => D.updateNode(e.id, { position: t }),
1011
- children: s && e.type && s[e.type] ? s[e.type]({ node: e }) : /* @__PURE__ */ p(d, { children: [
1012
- /* @__PURE__ */ f("span", { children: String(e.data?.label ?? e.id) }),
1013
- b && /* @__PURE__ */ f(K, {
1014
- type: "target",
1015
- position: "left"
1016
- }),
1017
- b && /* @__PURE__ */ f(K, {
1018
- type: "source",
1019
- position: "right"
1020
- })
1021
- ] })
1022
- }, e.id))
1023
- ]
1024
- });
1025
- }
1026
- var Q = {
1027
- story: "_story_btt88_2",
1028
- overlay: "_overlay_btt88_7",
1029
- caption: "_caption_btt88_20",
1030
- captionText: "_captionText_btt88_36",
1031
- captionDesc: "_captionDesc_btt88_48",
1032
- controls: "_controls_btt88_52",
1033
- button: "_button_btt88_64",
1034
- indicator: "_indicator_btt88_93"
1035
- }, $ = {
1036
- width: 18,
1037
- height: 18,
1038
- viewBox: "0 0 24 24",
1039
- fill: "currentColor",
1040
- "aria-hidden": !0
1041
- };
1042
- function be({ nodes: t, edges: n, script: r, loop: i = !0, stepDuration: a = 1500, stepGap: o = 0, playing: s, currentStep: l, onStepChange: u, controls: d = !0, autoPlay: m = !0, background: _ = !0, interactive: v = !1, labels: y, clock: b, className: x, style: S }) {
1043
- c();
1044
- let C = te(r, n), w = oe({
1045
- steps: C,
1046
- loop: i,
1047
- stepDuration: a,
1048
- stepGap: o,
1049
- playing: s,
1050
- defaultPlaying: m,
1051
- currentStep: l,
1052
- defaultCurrentStep: 0,
1053
- onStepChange: u,
1054
- clock: b
1055
- }), T = w.activeStep.value, E = w.currentStep.value, D = w.playing.value;
1056
- return /* @__PURE__ */ p("div", {
1057
- className: e(Q.story, x),
1058
- style: S,
1059
- children: [/* @__PURE__ */ f(ye, {
1060
- nodes: t,
1061
- edges: n,
1062
- background: _,
1063
- interactive: v,
1064
- activeEdgeId: T?.edgeId,
1065
- activeDirection: T?.direction
1066
- }), /* @__PURE__ */ p("div", {
1067
- className: Q.overlay,
1068
- children: [/* @__PURE__ */ f("div", {
1069
- className: Q.caption,
1070
- "aria-live": "polite",
1071
- children: T?.label && /* @__PURE__ */ p("span", {
1072
- className: Q.captionText,
1073
- children: [/* @__PURE__ */ f("strong", { children: T.label }), T.description && /* @__PURE__ */ p("span", {
1074
- className: Q.captionDesc,
1075
- children: [" — ", T.description]
1076
- })]
1077
- }, E)
1078
- }), d && /* @__PURE__ */ p("div", {
1079
- className: Q.controls,
1080
- children: [
1081
- /* @__PURE__ */ f("button", {
1082
- type: "button",
1083
- className: Q.button,
1084
- "aria-label": y?.previous ?? g(h.flow.previous),
1085
- onClick: w.prev,
1086
- children: /* @__PURE__ */ f("svg", {
1087
- ...$,
1088
- children: /* @__PURE__ */ f("path", {
1089
- d: "M15 6 9 12l6 6",
1090
- stroke: "currentColor",
1091
- strokeWidth: "2",
1092
- fill: "none"
1093
- })
1094
- })
1095
- }),
1096
- /* @__PURE__ */ f("button", {
1097
- type: "button",
1098
- className: Q.button,
1099
- "aria-label": D ? y?.pause ?? g(h.flow.pause) : y?.play ?? g(h.flow.play),
1100
- "aria-pressed": D,
1101
- onClick: w.toggle,
1102
- children: D ? /* @__PURE__ */ f("svg", {
1103
- ...$,
1104
- children: /* @__PURE__ */ f("path", { d: "M7 5h3v14H7zM14 5h3v14h-3z" })
1105
- }) : /* @__PURE__ */ f("svg", {
1106
- ...$,
1107
- children: /* @__PURE__ */ f("path", { d: "M7 5l11 7-11 7z" })
1108
- })
1109
- }),
1110
- /* @__PURE__ */ f("button", {
1111
- type: "button",
1112
- className: Q.button,
1113
- "aria-label": y?.next ?? g(h.flow.next),
1114
- onClick: w.next,
1115
- children: /* @__PURE__ */ f("svg", {
1116
- ...$,
1117
- children: /* @__PURE__ */ f("path", {
1118
- d: "M9 6l6 6-6 6",
1119
- stroke: "currentColor",
1120
- strokeWidth: "2",
1121
- fill: "none"
1122
- })
1123
- })
1124
- }),
1125
- /* @__PURE__ */ f("span", {
1126
- className: Q.indicator,
1127
- children: g(h.flow.step, {
1128
- current: E + 1,
1129
- total: C.length
1130
- })
1131
- })
1132
- ]
1133
- })]
1134
- })]
1135
- });
1136
- }
1137
- //#endregion
1138
- export { _ as DEFAULT_NODE_SIZE, ye as Flow, le as FlowBackground, se as FlowCanvas, pe as FlowControls, J as FlowEdge, K as FlowHandle, me as FlowMiniMap, de as FlowNode, ge as FlowPanel, be as FlowStory, B as applyLayout, M as bezierPath, b as clampZoom, L as edgePath, D as fitViewport, S as flowToScreen, E as graphBounds, R as gridLayout, T as handleAnchor, z as layeredLayout, w as nodeBounds, C as nodeSize, te as resolveScript, ee as resolveStep, x as screenToFlow, I as smoothStepPath, j as straightPath, ie as useConnection, y as useFlow, oe as useStory, U as useViewport };
1
+ "use client";import{cn as e,useComputed as t,useControllableSignal as r,useDraggable as i,useEffectPropSignal as a,useResizeObserver as o,useSignal as s,useSignalEffect as c,useSignals as l}from"@cascivo/core";import{useId as u,useRef as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{cn as h}from"@cascivo/core/pure";import{builtin as g,t as _}from"@cascivo/i18n";var v={width:150,height:40},y={x:0,y:0,zoom:1};function useFlow(e={}){let[t,i]=r({value:e.nodes,defaultValue:e.defaultNodes??[],onChange:e.onNodesChange}),[a,o]=r({value:e.edges,defaultValue:e.defaultEdges??[],onChange:e.onEdgesChange}),[s,c]=r({value:e.viewport,defaultValue:e.defaultViewport??y,onChange:e.onViewportChange});return{nodes:t,edges:a,viewport:s,setNodes:i,updateNode:(e,r)=>{i(t.value.map(t=>t.id===e?{...t,...r}:t))},setEdges:o,addEdge:e=>{o([...a.value,e])},setViewport:c}}function clampZoom(e,t=.2,r=2){return Math.min(r,Math.max(t,e))}function screenToFlow(e,t){return{x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}}function flowToScreen(e,t){return{x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}}function nodeSize(e){return{width:e.width??v.width,height:e.height??v.height}}function nodeBounds(e){let{width:t,height:r}=nodeSize(e);return{x:e.position.x,y:e.position.y,width:t,height:r}}function handleAnchor(e,t){let{x:r,y:i,width:a,height:o}=nodeBounds(e);switch(t){case`top`:return{x:r+a/2,y:i};case`right`:return{x:r+a,y:i+o/2};case`bottom`:return{x:r+a/2,y:i+o};case`left`:return{x:r,y:i+o/2}}}function graphBounds(e){if(e.length===0)return null;let t=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of e){let e=nodeBounds(o);t=Math.min(t,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height)}return{x:t,y:r,width:i-t,height:a-r}}function fitViewport(e,t,r={}){let{padding:i=.1,minZoom:a=.2,maxZoom:o=2}=r;if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{x:t.width/2-e.x,y:t.height/2-e.y,zoom:1};let s=t.width/(e.width*(1+i*2)),c=t.height/(e.height*(1+i*2)),l=clampZoom(Math.min(s,c),a,o);return{x:t.width/2-(e.x+e.width/2)*l,y:t.height/2-(e.y+e.height/2)*l,zoom:l}}var n=e=>Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.?0+$/,``),midpoint=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});function normal(e){switch(e){case`top`:return{x:0,y:-1};case`bottom`:return{x:0,y:1};case`left`:return{x:-1,y:0};case`right`:return{x:1,y:0}}}function straightPath({source:e,target:t}){return{d:`M${n(e.x)},${n(e.y)} L${n(t.x)},${n(t.y)}`,mid:midpoint(e,t)}}function bezierPath(e){let{source:t,target:r,curvature:i=.25}=e,a=e.sourcePosition??`right`,o=e.targetPosition??`left`,s=Math.hypot(r.x-t.x,r.y-t.y),c=Math.max(i*s,20),l=normal(a),u=normal(o),d={x:t.x+l.x*c,y:t.y+l.y*c},f={x:r.x+u.x*c,y:r.y+u.y*c},p={x:(t.x+3*d.x+3*f.x+r.x)/8,y:(t.y+3*d.y+3*f.y+r.y)/8};return{d:`M${n(t.x)},${n(t.y)} C${n(d.x)},${n(d.y)} ${n(f.x)},${n(f.y)} ${n(r.x)},${n(r.y)}`,mid:p}}function len(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function towards(e,t,r){let i=len(e,t)||1;return{x:e.x+(t.x-e.x)/i*r,y:e.y+(t.y-e.y)/i*r}}function roundedPath(e,t){if(e.length<2)return``;let r=e[0],i=`M${n(r.x)},${n(r.y)}`;for(let r=1;r<e.length-1;r++){let a=e[r-1],o=e[r],s=e[r+1],c=Math.min(t,len(a,o)/2,len(o,s)/2),l=towards(o,a,c),u=towards(o,s,c);i+=` L${n(l.x)},${n(l.y)} Q${n(o.x)},${n(o.y)} ${n(u.x)},${n(u.y)}`}let a=e[e.length-1];return i+=` L${n(a.x)},${n(a.y)}`,i}function smoothStepPath(e){let{source:t,target:r,borderRadius:i=8}=e,a=e.sourcePosition??`right`,o=a===`left`||a===`right`,s=[t];if(o){let e=(t.x+r.x)/2;s.push({x:e,y:t.y},{x:e,y:r.y})}else{let e=(t.y+r.y)/2;s.push({x:t.x,y:e},{x:r.x,y:e})}return s.push(r),{d:roundedPath(s,i),mid:midpoint(t,r)}}function edgePath(e,t){switch(e){case`straight`:return straightPath(t);case`smoothstep`:return smoothStepPath(t);case`bezier`:return bezierPath(t)}}function gridLayout(e,t={}){let r=t.gap??40,i=t.nodeWidth??v.width,a=t.nodeHeight??v.height,o=t.columns??Math.max(1,Math.ceil(Math.sqrt(e.length)));return e.map((e,t)=>{let s=t%o,c=Math.floor(t/o);return{...e,position:{x:s*(i+r),y:c*(a+r)}}})}function layeredLayout(e,t,r={}){let i=r.direction??`LR`,a=r.gap??60,o=r.nodeWidth??v.width,s=r.nodeHeight??v.height,c=new Set(e.map(e=>e.id)),l=new Map,u=new Map;for(let t of e)u.set(t.id,0);for(let e of t)!c.has(e.source)||!c.has(e.target)||(l.set(e.source,[...l.get(e.source)??[],e.target]),u.set(e.target,(u.get(e.target)??0)+1));let d=new Map,f=e.filter(e=>(u.get(e.id)??0)===0).map(e=>e.id);for(let e of f)d.set(e,0);let p=new Map(u);for(;f.length>0;){let e=[];for(let t of f){let r=d.get(t)??0;for(let i of l.get(t)??[])d.set(i,Math.max(d.get(i)??0,r+1)),p.set(i,(p.get(i)??0)-1),(p.get(i)??0)===0&&e.push(i)}f=e}for(let t of e)d.has(t.id)||d.set(t.id,0);let m=new Map,h=new Map;for(let t of e){let e=d.get(t.id)??0,r=h.get(e)??0;m.set(t.id,r),h.set(e,r+1)}return e.map(e=>{let t=d.get(e.id)??0,r=m.get(e.id)??0,c=i===`LR`?{x:t*(o+a),y:r*(s+a)}:{x:r*(o+a),y:t*(s+a)};return{...e,position:c}})}function applyLayout(e,t,r){return r===`grid`?gridLayout(e):r===`layered`?layeredLayout(e,t):r(e,t)}function isEdgeStep(e){return`edge`in e}function resolveStep(e,t){let r={label:e.label,description:e.description,duration:e.duration};if(isEdgeStep(e)){let i=t.find(t=>t.id===e.edge);if(!i)throw Error(`FlowStory: step references unknown edge "${e.edge}"`);return{edgeId:i.id,direction:e.reverse?`reverse`:`forward`,...r}}let i=t.find(t=>t.source===e.from&&t.target===e.to);if(i)return{edgeId:i.id,direction:`forward`,...r};let a=t.find(t=>t.source===e.to&&t.target===e.from);if(a)return{edgeId:a.id,direction:`reverse`,...r};throw Error(`FlowStory: no edge connects "${e.from}" and "${e.to}"`)}function resolveScript(e,t){return e.map(e=>resolveStep(e,t))}var b=1.2;function useViewport(e,t={}){let{minZoom:r=.2,maxZoom:a=2,panOnDrag:s=!0,zoomOnScroll:l=!0,fitPadding:u=.1,fitOnInit:f=!1}=t,{viewport:p,setViewport:m}=e,{ref:h,size:g}=o(),{handleRef:_,offset:v,isDragging:y}=i({isDisabled:!s}),pan=(e,t)=>{let r=p.peek();m({x:r.x+e,y:r.y+t,zoom:r.zoom})},zoomTo=(e,t)=>{let i=p.peek(),o=clampZoom(e,r,a);if(!t){m({x:i.x,y:i.y,zoom:o});return}let s=screenToFlow(t,i);m({x:t.x-s.x*o,y:t.y-s.y*o,zoom:o})},containerCenter=()=>{let e=h.current;if(e)return{x:e.clientWidth/2,y:e.clientHeight/2}},zoomIn=()=>zoomTo(p.peek().zoom*b,containerCenter()),zoomOut=()=>zoomTo(p.peek().zoom/b,containerCenter()),measuredSize=()=>{let e=g.peek();if(e&&e.width>0&&e.height>0)return e;let t=h.current;return t&&t.clientWidth>0?{width:t.clientWidth,height:t.clientHeight}:null},fitView=t=>{let i=graphBounds(e.nodes.peek());if(!i)return;let o=t??measuredSize();o&&m(fitViewport(i,o,{padding:u,minZoom:r,maxZoom:a}))},x=d(null);c(()=>{let e=y.value,t=v.value;if(!s)return;if(!e){x.current=null;return}x.current||={vp:p.peek(),off:t};let r=x.current;m({x:r.vp.x+(t.x-r.off.x),y:r.vp.y+(t.y-r.off.y),zoom:r.vp.zoom})}),c(()=>{if(!l||typeof window>`u`)return;let e=h.current;if(!e)return;let onWheel=t=>{t.preventDefault();let r=e.getBoundingClientRect(),i={x:t.clientX-r.left,y:t.clientY-r.top},a=t.deltaY<0?b:1/b;zoomTo(p.peek().zoom*a,i)};return e.addEventListener(`wheel`,onWheel,{passive:!1}),()=>e.removeEventListener(`wheel`,onWheel)});let S=d(!1);return c(()=>{if(!f||S.current)return;let e=g.value;!e||e.width===0||(S.current=!0,fitView(e))}),{containerRef:h,panHandleRef:_,viewport:p,pan,zoomTo,zoomIn,zoomOut,fitView}}var x=`[data-flow-handle][data-handle-type="source"]`,S=`[data-flow-handle][data-handle-type="target"]`;function useConnection(e){let{containerRef:t}=e,r=s(null),i=d(e.onConnect);i.current=e.onConnect;let o=d(e.isValid);o.current=e.isValid;let l=d(e.clientToFlow);l.current=e.clientToFlow;let u=a(e.enabled??!0);return c(()=>{if(!u.value||typeof window>`u`)return;let e=t.current;if(!e)return;let onMove=e=>{let t=r.peek();t&&(r.value={...t,to:l.current(e.clientX,e.clientY)})},onUp=e=>{let t=r.peek();if(window.removeEventListener(`pointermove`,onMove),window.removeEventListener(`pointerup`,onUp),r.value=null,!t)return;let a=e.target,s=a instanceof Element?a.closest(S):null,c=s?.closest(`[data-node-id]`);if(!c)return;let l={source:t.source,target:c.getAttribute(`data-node-id`)??``,sourceHandle:t.sourceHandle,targetHandle:s?.getAttribute(`data-handle-id`)??void 0};!l.target||l.source===l.target||o.current&&!o.current(l)||i.current?.(l)},onDown=e=>{let t=e.target;if(!(t instanceof Element))return;let i=t.closest(x);if(!i)return;let a=i.closest(`[data-node-id]`);if(!a)return;e.stopPropagation();let o=i.getBoundingClientRect();r.value={source:a.getAttribute(`data-node-id`)??``,sourceHandle:i.getAttribute(`data-handle-id`)??void 0,from:l.current(o.left+o.width/2,o.top+o.height/2),to:l.current(e.clientX,e.clientY)},window.addEventListener(`pointermove`,onMove),window.addEventListener(`pointerup`,onUp)};return e.addEventListener(`pointerdown`,onDown),()=>{e.removeEventListener(`pointerdown`,onDown),window.removeEventListener(`pointermove`,onMove),window.removeEventListener(`pointerup`,onUp)}}),{connection:r}}var C=1500;function useStory(e){let{steps:i,loop:a=!0,stepDuration:o=C,stepGap:s=0}=e,[l,u]=r({value:e.currentStep,defaultValue:e.defaultCurrentStep??0,onChange:e.onStepChange}),[f,p]=r({value:e.playing,defaultValue:e.defaultPlaying??!0,onChange:e.onPlayingChange}),m=t(()=>i[l.value]??null),h=d(e.clock);h.current=e.clock;let g=d(i);g.current=i;let clock=()=>h.current??{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)},advance=e=>{let t=g.current.length;if(t===0)return;let r=l.peek()+e;u(a?(r%t+t)%t:Math.max(0,Math.min(t-1,r)))};return c(()=>{if(!f.value)return;let e=l.value,t=i.length;if(t===0||typeof window>`u`&&!h.current)return;let r=(i[e]?.duration??o)+s,c=clock(),d=c.setTimeout(()=>{let r=e+1;r>=t?a?u(0):p(!1):u(r)},r);return()=>c.clearTimeout(d)}),{currentStep:l,playing:f,activeStep:m,play:()=>p(!0),pause:()=>p(!1),toggle:()=>p(!f.peek()),next:()=>advance(1),prev:()=>advance(-1),restart:()=>{u(0),p(!0)}}}var w={canvas:`_canvas_6fiig_2`,pane:`_pane_6fiig_13`,panSurface:`_panSurface_6fiig_24`};function FlowCanvas({children:t,flow:r,viewport:i,defaultViewport:a,onViewportChange:o,minZoom:s,maxZoom:c,panOnDrag:u=!0,zoomOnScroll:d=!0,fitView:f=!1,controller:h,chrome:g,className:_,role:v=`application`,...y}){l();let b=useFlow({viewport:i,defaultViewport:a,onViewportChange:o}),x=r??b,S=useViewport(x,{minZoom:s,maxZoom:c,panOnDrag:u,zoomOnScroll:d,fitOnInit:f}),C=h??S,T=x.viewport.value;return m(`div`,{ref:C.containerRef,className:e(w.canvas,_),role:v,...y,children:[m(`div`,{className:w.pane,style:{"--flow-tx":`${T.x}px`,"--flow-ty":`${T.y}px`,"--flow-scale":String(T.zoom)},children:[p(`div`,{ref:C.panHandleRef,className:w.panSurface,"aria-hidden":`true`}),t]}),g]})}var T={background:`_background_1pu9x_2`};function FlowBackground({variant:e=`dots`,gap:t=20,size:r=1,color:i,className:a,style:o,...s}){return p(`div`,{"data-variant":e,"aria-hidden":`true`,className:h(T.background,a),style:{"--flow-bg-gap":`${t}px`,"--flow-bg-size":`${r}px`,"--flow-bg-thick":`${Math.max(1,r)}px`,...i?{"--flow-bg-color":i}:{},...o},...s})}var E={node:`_node_9zyg4_2`};function FlowNode({id:t,position:a,defaultPosition:o,onPositionChange:s,onMeasure:u,zoom:f=1,selected:m=!1,draggable:h=!0,interactive:g=!0,onSelect:_,children:v,className:y,onClick:b,onKeyDown:x,...S}){l();let C=h&&g,[w,T]=r({value:a,defaultValue:o??a??{x:0,y:0},onChange:s}),{handleRef:D,targetRef:O,offset:k,isDragging:A}=i({isDisabled:!C}),j=d(null),setRefs=e=>{j.current=e,D.current=e,O.current=e},M=d(u);M.current=u,c(()=>{let e=j.current;if(!e||typeof ResizeObserver>`u`)return;let report=()=>{let t=e.offsetWidth,r=e.offsetHeight;t>0&&r>0&&M.current?.({width:t,height:r})};report();let t=new ResizeObserver(report);return t.observe(e),()=>t.disconnect()});let N=d(f);N.current=f;let P=d(null);c(()=>{let e=A.value,t=k.value;if(!C)return;if(!e){P.current=null;return}P.current||={pos:w.peek(),off:t};let r=P.current,i=N.current||1;T({x:r.pos.x+(t.x-r.off.x)/i,y:r.pos.y+(t.y-r.off.y)/i})});let F=w.value;return p(`div`,{ref:setRefs,"data-node-id":t,"data-selected":m||void 0,"data-dragging":A.value||void 0,"data-static":!g||void 0,role:`group`,tabIndex:g?0:void 0,className:e(E.node,y),style:{"--flow-x":`${F.x}px`,"--flow-y":`${F.y}px`},onClick:e=>{g&&_?.(t),b?.(e)},onKeyDown:e=>{g&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_?.(t)),x?.(e)},...S,children:v})}var D={handle:`_handle_8a1xa_2`,dot:`_dot_8a1xa_41`};function defaultPosition(e){return e===`source`?`right`:`left`}function FlowHandle({type:e,position:t,id:r,isConnectable:i=!0,className:a,...o}){return p(`div`,{"data-handle-type":e,"data-handle-pos":t??defaultPosition(e),"data-handle-id":r,"data-connectable":i||void 0,"data-flow-handle":``,tabIndex:i?0:-1,className:h(D.handle,a),...o,children:p(`span`,{className:D.dot,"aria-hidden":`true`})})}var O={edgeSvg:`_edgeSvg_789n0_2`,edgePath:`_edgePath_789n0_11`,hit:`_hit_789n0_18`,arrow:`_arrow_789n0_26`,"cascivo-flow-dash":`_cascivo-flow-dash_789n0_1`,label:`_label_789n0_64`};function FlowEdge({id:t,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s=`right`,targetPosition:c=`left`,type:l=`bezier`,animated:d=!1,label:h,selected:g=!1,markerStart:_=!1,markerEnd:v=!0,direction:y=`forward`,active:b,className:x}){let S=u(),C=`flow-arrow-${t??S}`,w=_||v,{d:T,mid:E}=edgePath(l,{source:{x:r,y:i},target:{x:a,y:o},sourcePosition:s,targetPosition:c});return m(f,{children:[m(`svg`,{className:e(O.edgeSvg,x),"data-edge-id":t,"data-animated":d||void 0,"data-selected":g||void 0,"data-active":b||void 0,"data-direction":y,"aria-hidden":`true`,children:[w&&p(`defs`,{children:p(`marker`,{id:C,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:p(`path`,{className:O.arrow,d:`M0,0 L10,5 L0,10 z`})})}),p(`path`,{className:O.hit,d:T}),p(`path`,{className:O.edgePath,d:T,markerStart:_?`url(#${C})`:void 0,markerEnd:v?`url(#${C})`:void 0})]}),h!=null&&p(`div`,{className:O.label,style:{"--flow-label-x":`${E.x}px`,"--flow-label-y":`${E.y}px`},children:h})]})}var k={controls:`_controls_s32im_2`,button:`_button_s32im_32`},A={width:18,height:18,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":!0};function FlowControls({position:t=`bottom-left`,showZoom:r=!0,showFitView:i=!0,onZoomIn:a,onZoomOut:o,onFitView:s,labels:c,className:u,...d}){return l(),m(`div`,{"data-position":t,className:e(k.controls,u),...d,children:[r&&m(f,{children:[p(`button`,{type:`button`,className:k.button,"aria-label":c?.zoomIn??_(g.flow.zoomIn),onClick:a,children:p(`svg`,{...A,children:p(`path`,{d:`M12 5v14M5 12h14`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})}),p(`button`,{type:`button`,className:k.button,"aria-label":c?.zoomOut??_(g.flow.zoomOut),onClick:o,children:p(`svg`,{...A,children:p(`path`,{d:`M5 12h14`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})})]}),i&&p(`button`,{type:`button`,className:k.button,"aria-label":c?.fitView??_(g.flow.fitView),onClick:s,children:p(`svg`,{...A,children:p(`path`,{d:`M4 9V5a1 1 0 0 1 1-1h4M15 4h4a1 1 0 0 1 1 1v4M20 15v4a1 1 0 0 1-1 1h-4M9 20H5a1 1 0 0 1-1-1v-4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]})}var j={minimap:`_minimap_rdahv_2`,node:`_node_rdahv_28`,viewport:`_viewport_rdahv_32`};function FlowMiniMap({nodes:t,viewport:r,containerWidth:a,containerHeight:o,width:s=200,height:u=150,position:f=`bottom-right`,nodeColor:h,onViewportChange:v,label:y,ariaLabel:b,className:x}){l();let S=graphBounds(t)??{x:0,y:0,width:1,height:1},C=S.width||1,w=S.height||1,T=C*.1,E=w*.1,D={x:S.x-T,y:S.y-E,width:C+T*2,height:w+E*2},O=Math.min(s/D.width,u/D.height),k=-D.x*O+(s-D.width*O)/2,A=-D.y*O+(u-D.height*O)/2,toMM=e=>({x:e.x*O+k,y:e.y*O+A}),M=null;if(a&&o){let e=screenToFlow({x:0,y:0},r),t=screenToFlow({x:a,y:o},r),i=toMM(e);M={x:i.x,y:i.y,w:(t.x-e.x)*O,h:(t.y-e.y)*O}}let{handleRef:N,offset:P,isDragging:F}=i({isDisabled:!v}),I=d(null),setRectRef=e=>{I.current=e,N.current=e},L=d(v);L.current=v;let R=d(null);return c(()=>{let e=F.value,t=P.value;if(!L.current)return;if(!e){R.current=null;return}R.current||={vp:r,off:t};let i=R.current,a=i.vp.zoom;L.current({x:i.vp.x-(t.x-i.off.x)/O*a,y:i.vp.y-(t.y-i.off.y)/O*a,zoom:a})}),m(`svg`,{"data-position":f,className:e(j.minimap,x),width:s,height:u,role:`img`,"aria-label":b??y??_(g.flow.minimap),children:[t.map(e=>{let t=nodeBounds(e),r=toMM({x:t.x,y:t.y});return p(`rect`,{"data-node-id":e.id,className:j.node,x:r.x,y:r.y,width:t.width*O,height:t.height*O,fill:h},e.id)}),M&&p(`rect`,{ref:setRectRef,"data-viewport":``,className:j.viewport,x:M.x,y:M.y,width:M.w,height:M.h})]})}var M={panel:`_panel_l0cix_2`};function FlowPanel({position:e=`top-right`,children:t,className:r,...i}){return p(`div`,{"data-position":e,className:h(M.panel,r),...i,children:t})}var N={flow:`_flow_vejge_2`},P=0;function Flow({nodes:t,edges:r,onNodesChange:i,onEdgesChange:a,onConnect:o,nodeTypes:c,fitView:u=!0,background:d=!1,controls:h=!1,minimap:g=!1,layout:_,minZoom:v,maxZoom:y,interactive:b=!0,activeEdgeId:x,activeDirection:S,className:C,style:w}){l();let T=useFlow({defaultNodes:_?applyLayout(t,r,_):t,defaultEdges:r,onNodesChange:i,onEdgesChange:a}),E=useViewport(T,{minZoom:v,maxZoom:y,fitOnInit:u}),{connection:D}=useConnection({containerRef:E.containerRef,clientToFlow:(e,t)=>{let r=E.containerRef.current?.getBoundingClientRect();return screenToFlow({x:e-(r?.left??0),y:t-(r?.top??0)},T.viewport.peek())},enabled:b,onConnect:e=>{T.addEdge({id:`e-${++P}`,source:e.source,target:e.target}),o?.(e)}}),select=e=>{T.setNodes(T.nodes.value.map(t=>({...t,selected:t.id===e})))},O=s({}),measure=(e,t)=>{let r=O.peek()[e];r&&r.width===t.width&&r.height===t.height||(O.value={...O.peek(),[e]:t})},k=T.nodes.value,A=T.edges.value,j=T.viewport.value.zoom,M=O.value,F=new Map(k.map(e=>{let t=M[e.id];return[e.id,t?{...e,width:t.width,height:t.height}:e]})),I=D.value;return m(FlowCanvas,{flow:T,controller:E,minZoom:v,maxZoom:y,chrome:m(f,{children:[h&&p(FlowControls,{onZoomIn:E.zoomIn,onZoomOut:E.zoomOut,onFitView:()=>E.fitView()}),g&&p(FlowMiniMap,{nodes:k,viewport:T.viewport.value,containerWidth:E.containerRef.current?.clientWidth,containerHeight:E.containerRef.current?.clientHeight,onViewportChange:T.setViewport})]}),className:e(N.flow,C),style:w,children:[d&&p(FlowBackground,{...typeof d==`object`?d:{}}),A.map(e=>{let t=F.get(e.source),r=F.get(e.target);if(!t||!r)return null;let i=handleAnchor(t,`right`),a=handleAnchor(r,`left`),o=x===e.id,s=o?S:void 0,c=s===`reverse`?!0:s===`forward`?!1:e.markerStart??!1,l=s===`reverse`?!1:s===`forward`?!0:e.markerEnd??!0;return p(FlowEdge,{id:e.id,sourceX:i.x,sourceY:i.y,targetX:a.x,targetY:a.y,type:e.type??`bezier`,animated:e.animated||o,active:o,direction:s,markerStart:c,markerEnd:l,label:e.label,selected:e.selected},e.id)}),I&&p(FlowEdge,{sourceX:I.from.x,sourceY:I.from.y,targetX:I.to.x,targetY:I.to.y,markerEnd:!1}),k.map(e=>p(FlowNode,{id:e.id,position:e.position,zoom:j,interactive:b,selected:e.selected??!1,onSelect:b?select:void 0,onMeasure:t=>measure(e.id,t),onPositionChange:t=>T.updateNode(e.id,{position:t}),children:c&&e.type&&c[e.type]?c[e.type]({node:e}):m(f,{children:[p(`span`,{children:String(e.data?.label??e.id)}),b&&p(FlowHandle,{type:`target`,position:`left`}),b&&p(FlowHandle,{type:`source`,position:`right`})]})},e.id))]})}var F={story:`_story_btt88_2`,overlay:`_overlay_btt88_7`,caption:`_caption_btt88_20`,captionText:`_captionText_btt88_36`,captionDesc:`_captionDesc_btt88_48`,controls:`_controls_btt88_52`,button:`_button_btt88_64`,indicator:`_indicator_btt88_93`},I={width:18,height:18,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0};function FlowStory({nodes:t,edges:r,script:i,loop:a=!0,stepDuration:o=1500,stepGap:s=0,playing:c,currentStep:u,onStepChange:d,controls:f=!0,autoPlay:h=!0,background:v=!0,interactive:y=!1,labels:b,clock:x,className:S,style:C}){l();let w=resolveScript(i,r),T=useStory({steps:w,loop:a,stepDuration:o,stepGap:s,playing:c,defaultPlaying:h,currentStep:u,defaultCurrentStep:0,onStepChange:d,clock:x}),E=T.activeStep.value,D=T.currentStep.value,O=T.playing.value;return m(`div`,{className:e(F.story,S),style:C,children:[p(Flow,{nodes:t,edges:r,background:v,interactive:y,activeEdgeId:E?.edgeId,activeDirection:E?.direction}),m(`div`,{className:F.overlay,children:[p(`div`,{className:F.caption,"aria-live":`polite`,children:E?.label&&m(`span`,{className:F.captionText,children:[p(`strong`,{children:E.label}),E.description&&m(`span`,{className:F.captionDesc,children:[` — `,E.description]})]},D)}),f&&m(`div`,{className:F.controls,children:[p(`button`,{type:`button`,className:F.button,"aria-label":b?.previous??_(g.flow.previous),onClick:T.prev,children:p(`svg`,{...I,children:p(`path`,{d:`M15 6 9 12l6 6`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`})})}),p(`button`,{type:`button`,className:F.button,"aria-label":O?b?.pause??_(g.flow.pause):b?.play??_(g.flow.play),"aria-pressed":O,onClick:T.toggle,children:O?p(`svg`,{...I,children:p(`path`,{d:`M7 5h3v14H7zM14 5h3v14h-3z`})}):p(`svg`,{...I,children:p(`path`,{d:`M7 5l11 7-11 7z`})})}),p(`button`,{type:`button`,className:F.button,"aria-label":b?.next??_(g.flow.next),onClick:T.next,children:p(`svg`,{...I,children:p(`path`,{d:`M9 6l6 6-6 6`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`})})}),p(`span`,{className:F.indicator,children:_(g.flow.step,{current:D+1,total:w.length})})]})]})]})}export{v as DEFAULT_NODE_SIZE,Flow,FlowBackground,FlowCanvas,FlowControls,FlowEdge,FlowHandle,FlowMiniMap,FlowNode,FlowPanel,FlowStory,applyLayout,bezierPath,clampZoom,edgePath,fitViewport,flowToScreen,graphBounds,gridLayout,handleAnchor,layeredLayout,nodeBounds,nodeSize,resolveScript,resolveStep,screenToFlow,smoothStepPath,straightPath,useConnection,useFlow,useStory,useViewport};