@notmrabhi/flowforge 0.1.4 → 0.1.6

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.
@@ -0,0 +1,2799 @@
1
+ import { jsxs as m, jsx as f, Fragment as Lt } from "react/jsx-runtime";
2
+ import P, { useRef as pt, useEffect as ie, useState as j, useMemo as W, useCallback as Y } from "react";
3
+ import _r, { useStore as Tr, useReactFlow as Nr, Background as Cr, Controls as Sr, MiniMap as Ir } from "reactflow";
4
+ import "reactflow/dist/style.css";
5
+ import { e as Or, G as Mr, E as jr, P as Fr, L as zr, d as Rr, f as Dr } from "./GatewayBranchEdge-DHqcdxpD.js";
6
+ import { Dialog as Lr, Box as te, Drawer as Ar, Typography as Pr, IconButton as bt, Button as yt } from "@mui/material";
7
+ import { MdClose as Br, MdCalendarToday as Wr, MdBolt as Gr, MdArrowBack as $r, MdChevronRight as At, MdAddCircleOutline as Yr, MdApps as Kr, MdErrorOutline as Ur, MdAccountTree as Vr, MdAdd as Hr, MdSearch as qr, MdCategory as Xr, MdCancel as Pt, MdError as Bt, MdCheckCircle as Wt, MdPlayArrow as Gt, MdHourglassEmpty as Jr, MdSchedule as mt, MdPerson as Zr, MdExpandLess as Qr, MdExpandMore as en } from "react-icons/md";
8
+ import { GrTrigger as tn } from "react-icons/gr";
9
+ import { BiCollapse as rn, BiExpand as nn } from "react-icons/bi";
10
+ import { a as on } from "./index-D6g2IXSf.js";
11
+ import { m as sn } from "./messages-CO299wPN.js";
12
+ import { T as ln, E as q } from "./canvasTokens-CAD6G24b.js";
13
+ var $t = Object.defineProperty, an = (e, t, r) => t in e ? $t(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, dn = (e, t) => {
14
+ for (var r in t) $t(e, r, { get: t[r], enumerable: !0 });
15
+ }, cn = (e, t, r) => an(e, t + "", r), Yt = {};
16
+ dn(Yt, { Graph: () => G, alg: () => Ve, json: () => Ut, version: () => hn });
17
+ var un = Object.defineProperty, Kt = (e, t) => {
18
+ for (var r in t) un(e, r, { get: t[r], enumerable: !0 });
19
+ }, G = class {
20
+ constructor(e) {
21
+ this._isDirected = !0, this._isMultigraph = !1, this._isCompound = !1, this._nodes = {}, this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {}, this._nodeCount = 0, this._edgeCount = 0, this._defaultNodeLabelFn = () => {
22
+ }, this._defaultEdgeLabelFn = () => {
23
+ }, e && (this._isDirected = "directed" in e ? e.directed : !0, this._isMultigraph = "multigraph" in e ? e.multigraph : !1, this._isCompound = "compound" in e ? e.compound : !1), this._isCompound && (this._parent = {}, this._children = {}, this._children["\0"] = {});
24
+ }
25
+ isDirected() {
26
+ return this._isDirected;
27
+ }
28
+ isMultigraph() {
29
+ return this._isMultigraph;
30
+ }
31
+ isCompound() {
32
+ return this._isCompound;
33
+ }
34
+ setGraph(e) {
35
+ return this._label = e, this;
36
+ }
37
+ graph() {
38
+ return this._label;
39
+ }
40
+ setDefaultNodeLabel(e) {
41
+ return typeof e != "function" ? this._defaultNodeLabelFn = () => e : this._defaultNodeLabelFn = e, this;
42
+ }
43
+ nodeCount() {
44
+ return this._nodeCount;
45
+ }
46
+ nodes() {
47
+ return Object.keys(this._nodes);
48
+ }
49
+ sources() {
50
+ return this.nodes().filter((e) => Object.keys(this._in[e]).length === 0);
51
+ }
52
+ sinks() {
53
+ return this.nodes().filter((e) => Object.keys(this._out[e]).length === 0);
54
+ }
55
+ setNodes(e, t) {
56
+ return e.forEach((r) => {
57
+ t !== void 0 ? this.setNode(r, t) : this.setNode(r);
58
+ }), this;
59
+ }
60
+ setNode(e, t) {
61
+ return e in this._nodes ? (arguments.length > 1 && (this._nodes[e] = t), this) : (this._nodes[e] = arguments.length > 1 ? t : this._defaultNodeLabelFn(e), this._isCompound && (this._parent[e] = "\0", this._children[e] = {}, this._children["\0"][e] = !0), this._in[e] = {}, this._preds[e] = {}, this._out[e] = {}, this._sucs[e] = {}, ++this._nodeCount, this);
62
+ }
63
+ node(e) {
64
+ return this._nodes[e];
65
+ }
66
+ hasNode(e) {
67
+ return e in this._nodes;
68
+ }
69
+ removeNode(e) {
70
+ if (e in this._nodes) {
71
+ let t = (r) => this.removeEdge(this._edgeObjs[r]);
72
+ delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((r) => {
73
+ this.setParent(r);
74
+ }), delete this._children[e]), Object.keys(this._in[e]).forEach(t), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(t), delete this._out[e], delete this._sucs[e], --this._nodeCount;
75
+ }
76
+ return this;
77
+ }
78
+ setParent(e, t) {
79
+ if (!this._isCompound) throw new Error("Cannot set parent in a non-compound graph");
80
+ if (t === void 0) t = "\0";
81
+ else {
82
+ t += "";
83
+ for (let r = t; r !== void 0; r = this.parent(r)) if (r === e) throw new Error("Setting " + t + " as parent of " + e + " would create a cycle");
84
+ this.setNode(t);
85
+ }
86
+ return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = t, this._children[t][e] = !0, this;
87
+ }
88
+ parent(e) {
89
+ if (this._isCompound) {
90
+ let t = this._parent[e];
91
+ if (t !== "\0") return t;
92
+ }
93
+ }
94
+ children(e = "\0") {
95
+ if (this._isCompound) {
96
+ let t = this._children[e];
97
+ if (t) return Object.keys(t);
98
+ } else {
99
+ if (e === "\0") return this.nodes();
100
+ if (this.hasNode(e)) return [];
101
+ }
102
+ return [];
103
+ }
104
+ predecessors(e) {
105
+ let t = this._preds[e];
106
+ if (t) return Object.keys(t);
107
+ }
108
+ successors(e) {
109
+ let t = this._sucs[e];
110
+ if (t) return Object.keys(t);
111
+ }
112
+ neighbors(e) {
113
+ let t = this.predecessors(e);
114
+ if (t) {
115
+ let r = new Set(t);
116
+ for (let n of this.successors(e)) r.add(n);
117
+ return Array.from(r.values());
118
+ }
119
+ }
120
+ isLeaf(e) {
121
+ let t;
122
+ return this.isDirected() ? t = this.successors(e) : t = this.neighbors(e), t.length === 0;
123
+ }
124
+ filterNodes(e) {
125
+ let t = new this.constructor({ directed: this._isDirected, multigraph: this._isMultigraph, compound: this._isCompound });
126
+ t.setGraph(this.graph()), Object.entries(this._nodes).forEach(([o, i]) => {
127
+ e(o) && t.setNode(o, i);
128
+ }), Object.values(this._edgeObjs).forEach((o) => {
129
+ t.hasNode(o.v) && t.hasNode(o.w) && t.setEdge(o, this.edge(o));
130
+ });
131
+ let r = {}, n = (o) => {
132
+ let i = this.parent(o);
133
+ return !i || t.hasNode(i) ? (r[o] = i ?? void 0, i ?? void 0) : i in r ? r[i] : n(i);
134
+ };
135
+ return this._isCompound && t.nodes().forEach((o) => t.setParent(o, n(o))), t;
136
+ }
137
+ setDefaultEdgeLabel(e) {
138
+ return typeof e != "function" ? this._defaultEdgeLabelFn = () => e : this._defaultEdgeLabelFn = e, this;
139
+ }
140
+ edgeCount() {
141
+ return this._edgeCount;
142
+ }
143
+ edges() {
144
+ return Object.values(this._edgeObjs);
145
+ }
146
+ setPath(e, t) {
147
+ return e.reduce((r, n) => (t !== void 0 ? this.setEdge(r, n, t) : this.setEdge(r, n), n)), this;
148
+ }
149
+ setEdge(e, t, r, n) {
150
+ let o, i, s, l, d = !1;
151
+ typeof e == "object" && e !== null && "v" in e ? (o = e.v, i = e.w, s = e.name, arguments.length === 2 && (l = t, d = !0)) : (o = e, i = t, s = n, arguments.length > 2 && (l = r, d = !0)), o = "" + o, i = "" + i, s !== void 0 && (s = "" + s);
152
+ let a = ge(this._isDirected, o, i, s);
153
+ if (a in this._edgeLabels) return d && (this._edgeLabels[a] = l), this;
154
+ if (s !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
155
+ this.setNode(o), this.setNode(i), this._edgeLabels[a] = d ? l : this._defaultEdgeLabelFn(o, i, s);
156
+ let c = fn(this._isDirected, o, i, s);
157
+ return o = c.v, i = c.w, Object.freeze(c), this._edgeObjs[a] = c, wt(this._preds[i], o), wt(this._sucs[o], i), this._in[i][a] = c, this._out[o][a] = c, this._edgeCount++, this;
158
+ }
159
+ edge(e, t, r) {
160
+ let n = arguments.length === 1 ? Fe(this._isDirected, e) : ge(this._isDirected, e, t, r);
161
+ return this._edgeLabels[n];
162
+ }
163
+ edgeAsObj(e, t, r) {
164
+ let n = arguments.length === 1 ? this.edge(e) : this.edge(e, t, r);
165
+ return typeof n != "object" ? { label: n } : n;
166
+ }
167
+ hasEdge(e, t, r) {
168
+ return (arguments.length === 1 ? Fe(this._isDirected, e) : ge(this._isDirected, e, t, r)) in this._edgeLabels;
169
+ }
170
+ removeEdge(e, t, r) {
171
+ let n = arguments.length === 1 ? Fe(this._isDirected, e) : ge(this._isDirected, e, t, r), o = this._edgeObjs[n];
172
+ if (o) {
173
+ let i = o.v, s = o.w;
174
+ delete this._edgeLabels[n], delete this._edgeObjs[n], vt(this._preds[s], i), vt(this._sucs[i], s), delete this._in[s][n], delete this._out[i][n], this._edgeCount--;
175
+ }
176
+ return this;
177
+ }
178
+ inEdges(e, t) {
179
+ return this.isDirected() ? this.filterEdges(this._in[e], e, t) : this.nodeEdges(e, t);
180
+ }
181
+ outEdges(e, t) {
182
+ return this.isDirected() ? this.filterEdges(this._out[e], e, t) : this.nodeEdges(e, t);
183
+ }
184
+ nodeEdges(e, t) {
185
+ if (e in this._nodes) return this.filterEdges({ ...this._in[e], ...this._out[e] }, e, t);
186
+ }
187
+ _removeFromParentsChildList(e) {
188
+ delete this._children[this._parent[e]][e];
189
+ }
190
+ filterEdges(e, t, r) {
191
+ if (!e) return;
192
+ let n = Object.values(e);
193
+ return r ? n.filter((o) => o.v === t && o.w === r || o.v === r && o.w === t) : n;
194
+ }
195
+ };
196
+ function wt(e, t) {
197
+ e[t] ? e[t]++ : e[t] = 1;
198
+ }
199
+ function vt(e, t) {
200
+ e[t] !== void 0 && !--e[t] && delete e[t];
201
+ }
202
+ function ge(e, t, r, n) {
203
+ let o = "" + t, i = "" + r;
204
+ if (!e && o > i) {
205
+ let s = o;
206
+ o = i, i = s;
207
+ }
208
+ return o + "" + i + "" + (n === void 0 ? "\0" : n);
209
+ }
210
+ function fn(e, t, r, n) {
211
+ let o = "" + t, i = "" + r;
212
+ if (!e && o > i) {
213
+ let l = o;
214
+ o = i, i = l;
215
+ }
216
+ let s = { v: o, w: i };
217
+ return n && (s.name = n), s;
218
+ }
219
+ function Fe(e, t) {
220
+ return ge(e, t.v, t.w, t.name);
221
+ }
222
+ var hn = "4.0.1", Ut = {};
223
+ Kt(Ut, { read: () => yn, write: () => gn });
224
+ function gn(e) {
225
+ let t = { options: { directed: e.isDirected(), multigraph: e.isMultigraph(), compound: e.isCompound() }, nodes: pn(e), edges: bn(e) }, r = e.graph();
226
+ return r !== void 0 && (t.value = structuredClone(r)), t;
227
+ }
228
+ function pn(e) {
229
+ return e.nodes().map((t) => {
230
+ let r = e.node(t), n = e.parent(t), o = { v: t };
231
+ return r !== void 0 && (o.value = r), n !== void 0 && (o.parent = n), o;
232
+ });
233
+ }
234
+ function bn(e) {
235
+ return e.edges().map((t) => {
236
+ let r = e.edge(t), n = { v: t.v, w: t.w };
237
+ return t.name !== void 0 && (n.name = t.name), r !== void 0 && (n.value = r), n;
238
+ });
239
+ }
240
+ function yn(e) {
241
+ let t = new G(e.options);
242
+ return e.value !== void 0 && t.setGraph(e.value), e.nodes.forEach((r) => {
243
+ t.setNode(r.v, r.value), r.parent && t.setParent(r.v, r.parent);
244
+ }), e.edges.forEach((r) => {
245
+ t.setEdge({ v: r.v, w: r.w, name: r.name }, r.value);
246
+ }), t;
247
+ }
248
+ var Ve = {};
249
+ Kt(Ve, { CycleException: () => _e, bellmanFord: () => Vt, components: () => vn, dijkstra: () => xe, dijkstraAll: () => xn, findCycles: () => _n, floydWarshall: () => Nn, isAcyclic: () => Sn, postorder: () => On, preorder: () => Mn, prim: () => jn, shortestPaths: () => Fn, tarjan: () => qt, topsort: () => Xt });
250
+ var mn = () => 1;
251
+ function Vt(e, t, r, n) {
252
+ return wn(e, String(t), r || mn, n || function(o) {
253
+ return e.outEdges(o);
254
+ });
255
+ }
256
+ function wn(e, t, r, n) {
257
+ let o = {}, i, s = 0, l = e.nodes(), d = function(u) {
258
+ let h = r(u);
259
+ o[u.v].distance + h < o[u.w].distance && (o[u.w] = { distance: o[u.v].distance + h, predecessor: u.v }, i = !0);
260
+ }, a = function() {
261
+ l.forEach(function(u) {
262
+ n(u).forEach(function(h) {
263
+ let g = h.v === u ? h.v : h.w, b = g === h.v ? h.w : h.v;
264
+ d({ v: g, w: b });
265
+ });
266
+ });
267
+ };
268
+ l.forEach(function(u) {
269
+ let h = u === t ? 0 : Number.POSITIVE_INFINITY;
270
+ o[u] = { distance: h, predecessor: "" };
271
+ });
272
+ let c = l.length;
273
+ for (let u = 1; u < c && (i = !1, s++, a(), !!i); u++) ;
274
+ if (s === c - 1 && (i = !1, a(), i)) throw new Error("The graph contains a negative weight cycle");
275
+ return o;
276
+ }
277
+ function vn(e) {
278
+ let t = {}, r = [], n;
279
+ function o(i) {
280
+ i in t || (t[i] = !0, n.push(i), e.successors(i).forEach(o), e.predecessors(i).forEach(o));
281
+ }
282
+ return e.nodes().forEach(function(i) {
283
+ n = [], o(i), n.length && r.push(n);
284
+ }), r;
285
+ }
286
+ var Ht = class {
287
+ constructor() {
288
+ this._arr = [], this._keyIndices = {};
289
+ }
290
+ size() {
291
+ return this._arr.length;
292
+ }
293
+ keys() {
294
+ return this._arr.map((e) => e.key);
295
+ }
296
+ has(e) {
297
+ return e in this._keyIndices;
298
+ }
299
+ priority(e) {
300
+ let t = this._keyIndices[e];
301
+ if (t !== void 0) return this._arr[t].priority;
302
+ }
303
+ min() {
304
+ if (this.size() === 0) throw new Error("Queue underflow");
305
+ return this._arr[0].key;
306
+ }
307
+ add(e, t) {
308
+ let r = this._keyIndices, n = String(e);
309
+ if (!(n in r)) {
310
+ let o = this._arr, i = o.length;
311
+ return r[n] = i, o.push({ key: n, priority: t }), this._decrease(i), !0;
312
+ }
313
+ return !1;
314
+ }
315
+ removeMin() {
316
+ this._swap(0, this._arr.length - 1);
317
+ let e = this._arr.pop();
318
+ return delete this._keyIndices[e.key], this._heapify(0), e.key;
319
+ }
320
+ decrease(e, t) {
321
+ let r = this._keyIndices[e];
322
+ if (r === void 0) throw new Error(`Key not found: ${e}`);
323
+ let n = this._arr[r].priority;
324
+ if (t > n) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${n} New: ${t}`);
325
+ this._arr[r].priority = t, this._decrease(r);
326
+ }
327
+ _heapify(e) {
328
+ let t = this._arr, r = 2 * e, n = r + 1, o = e;
329
+ r < t.length && (o = t[r].priority < t[o].priority ? r : o, n < t.length && (o = t[n].priority < t[o].priority ? n : o), o !== e && (this._swap(e, o), this._heapify(o)));
330
+ }
331
+ _decrease(e) {
332
+ let t = this._arr, r = t[e].priority, n;
333
+ for (; e !== 0 && (n = e >> 1, !(t[n].priority < r)); ) this._swap(e, n), e = n;
334
+ }
335
+ _swap(e, t) {
336
+ let r = this._arr, n = this._keyIndices, o = r[e], i = r[t];
337
+ r[e] = i, r[t] = o, n[i.key] = e, n[o.key] = t;
338
+ }
339
+ }, En = () => 1;
340
+ function xe(e, t, r, n) {
341
+ let o = function(i) {
342
+ return e.outEdges(i);
343
+ };
344
+ return kn(e, String(t), r || En, n || o);
345
+ }
346
+ function kn(e, t, r, n) {
347
+ let o = {}, i = new Ht(), s, l, d = function(a) {
348
+ let c = a.v !== s ? a.v : a.w, u = o[c], h = r(a), g = l.distance + h;
349
+ if (h < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + a + " Weight: " + h);
350
+ g < u.distance && (u.distance = g, u.predecessor = s, i.decrease(c, g));
351
+ };
352
+ for (e.nodes().forEach(function(a) {
353
+ let c = a === t ? 0 : Number.POSITIVE_INFINITY;
354
+ o[a] = { distance: c, predecessor: "" }, i.add(a, c);
355
+ }); i.size() > 0 && (s = i.removeMin(), l = o[s], l.distance !== Number.POSITIVE_INFINITY); ) n(s).forEach(d);
356
+ return o;
357
+ }
358
+ function xn(e, t, r) {
359
+ return e.nodes().reduce(function(n, o) {
360
+ return n[o] = xe(e, o, t, r), n;
361
+ }, {});
362
+ }
363
+ function qt(e) {
364
+ let t = 0, r = [], n = {}, o = [];
365
+ function i(s) {
366
+ let l = n[s] = { onStack: !0, lowlink: t, index: t++ };
367
+ if (r.push(s), e.successors(s).forEach(function(d) {
368
+ d in n ? n[d].onStack && (l.lowlink = Math.min(l.lowlink, n[d].index)) : (i(d), l.lowlink = Math.min(l.lowlink, n[d].lowlink));
369
+ }), l.lowlink === l.index) {
370
+ let d = [], a;
371
+ do
372
+ a = r.pop(), n[a].onStack = !1, d.push(a);
373
+ while (s !== a);
374
+ o.push(d);
375
+ }
376
+ }
377
+ return e.nodes().forEach(function(s) {
378
+ s in n || i(s);
379
+ }), o;
380
+ }
381
+ function _n(e) {
382
+ return qt(e).filter(function(t) {
383
+ return t.length > 1 || t.length === 1 && e.hasEdge(t[0], t[0]);
384
+ });
385
+ }
386
+ var Tn = () => 1;
387
+ function Nn(e, t, r) {
388
+ return Cn(e, t || Tn, r || function(n) {
389
+ return e.outEdges(n);
390
+ });
391
+ }
392
+ function Cn(e, t, r) {
393
+ let n = {}, o = e.nodes();
394
+ return o.forEach(function(i) {
395
+ n[i] = {}, n[i][i] = { distance: 0, predecessor: "" }, o.forEach(function(s) {
396
+ i !== s && (n[i][s] = { distance: Number.POSITIVE_INFINITY, predecessor: "" });
397
+ }), r(i).forEach(function(s) {
398
+ let l = s.v === i ? s.w : s.v, d = t(s);
399
+ n[i][l] = { distance: d, predecessor: i };
400
+ });
401
+ }), o.forEach(function(i) {
402
+ let s = n[i];
403
+ o.forEach(function(l) {
404
+ let d = n[l];
405
+ o.forEach(function(a) {
406
+ let c = d[i], u = s[a], h = d[a], g = c.distance + u.distance;
407
+ g < h.distance && (h.distance = g, h.predecessor = u.predecessor);
408
+ });
409
+ });
410
+ }), n;
411
+ }
412
+ var _e = class extends Error {
413
+ constructor(...e) {
414
+ super(...e);
415
+ }
416
+ };
417
+ function Xt(e) {
418
+ let t = {}, r = {}, n = [];
419
+ function o(i) {
420
+ if (i in r) throw new _e();
421
+ i in t || (r[i] = !0, t[i] = !0, e.predecessors(i).forEach(o), delete r[i], n.push(i));
422
+ }
423
+ if (e.sinks().forEach(o), Object.keys(t).length !== e.nodeCount()) throw new _e();
424
+ return n;
425
+ }
426
+ function Sn(e) {
427
+ try {
428
+ Xt(e);
429
+ } catch (t) {
430
+ if (t instanceof _e) return !1;
431
+ throw t;
432
+ }
433
+ return !0;
434
+ }
435
+ function In(e, t, r, n, o) {
436
+ Array.isArray(t) || (t = [t]);
437
+ let i = (l) => {
438
+ var d;
439
+ return (d = e.isDirected() ? e.successors(l) : e.neighbors(l)) != null ? d : [];
440
+ }, s = {};
441
+ return t.forEach(function(l) {
442
+ if (!e.hasNode(l)) throw new Error("Graph does not have node: " + l);
443
+ o = Jt(e, l, r === "post", s, i, n, o);
444
+ }), o;
445
+ }
446
+ function Jt(e, t, r, n, o, i, s) {
447
+ return t in n || (n[t] = !0, r || (s = i(s, t)), o(t).forEach(function(l) {
448
+ s = Jt(e, l, r, n, o, i, s);
449
+ }), r && (s = i(s, t))), s;
450
+ }
451
+ function Zt(e, t, r) {
452
+ return In(e, t, r, function(n, o) {
453
+ return n.push(o), n;
454
+ }, []);
455
+ }
456
+ function On(e, t) {
457
+ return Zt(e, t, "post");
458
+ }
459
+ function Mn(e, t) {
460
+ return Zt(e, t, "pre");
461
+ }
462
+ function jn(e, t) {
463
+ let r = new G(), n = {}, o = new Ht(), i;
464
+ function s(d) {
465
+ let a = d.v === i ? d.w : d.v, c = o.priority(a);
466
+ if (c !== void 0) {
467
+ let u = t(d);
468
+ u < c && (n[a] = i, o.decrease(a, u));
469
+ }
470
+ }
471
+ if (e.nodeCount() === 0) return r;
472
+ e.nodes().forEach(function(d) {
473
+ o.add(d, Number.POSITIVE_INFINITY), r.setNode(d);
474
+ }), o.decrease(e.nodes()[0], 0);
475
+ let l = !1;
476
+ for (; o.size() > 0; ) {
477
+ if (i = o.removeMin(), i in n) r.setEdge(i, n[i]);
478
+ else {
479
+ if (l) throw new Error("Input graph is not connected: " + e);
480
+ l = !0;
481
+ }
482
+ e.nodeEdges(i).forEach(s);
483
+ }
484
+ return r;
485
+ }
486
+ function Fn(e, t, r, n) {
487
+ return zn(e, t, r, n ?? ((o) => {
488
+ let i = e.outEdges(o);
489
+ return i ?? [];
490
+ }));
491
+ }
492
+ function zn(e, t, r, n) {
493
+ if (r === void 0) return xe(e, t, r, n);
494
+ let o = !1, i = e.nodes();
495
+ for (let s = 0; s < i.length; s++) {
496
+ let l = n(i[s]);
497
+ for (let d = 0; d < l.length; d++) {
498
+ let a = l[d], c = a.v === i[s] ? a.v : a.w, u = c === a.v ? a.w : a.v;
499
+ r({ v: c, w: u }) < 0 && (o = !0);
500
+ }
501
+ if (o) return Vt(e, t, r, n);
502
+ }
503
+ return xe(e, t, r, n);
504
+ }
505
+ function fe(e, t, r, n) {
506
+ let o = n;
507
+ for (; e.hasNode(o); ) o = He(n);
508
+ return r.dummy = t, e.setNode(o, r), o;
509
+ }
510
+ function Rn(e) {
511
+ let t = new G().setGraph(e.graph());
512
+ return e.nodes().forEach((r) => t.setNode(r, e.node(r))), e.edges().forEach((r) => {
513
+ let n = t.edge(r.v, r.w) || { weight: 0, minlen: 1 }, o = e.edge(r);
514
+ t.setEdge(r.v, r.w, { weight: n.weight + o.weight, minlen: Math.max(n.minlen, o.minlen) });
515
+ }), t;
516
+ }
517
+ function Qt(e) {
518
+ let t = new G({ multigraph: e.isMultigraph() }).setGraph(e.graph());
519
+ return e.nodes().forEach((r) => {
520
+ e.children(r).length || t.setNode(r, e.node(r));
521
+ }), e.edges().forEach((r) => {
522
+ t.setEdge(r, e.edge(r));
523
+ }), t;
524
+ }
525
+ function Et(e, t) {
526
+ let r = e.x, n = e.y, o = t.x - r, i = t.y - n, s = e.width / 2, l = e.height / 2;
527
+ if (!o && !i) throw new Error("Not possible to find intersection inside of the rectangle");
528
+ let d, a;
529
+ return Math.abs(i) * s > Math.abs(o) * l ? (i < 0 && (l = -l), d = l * o / i, a = l) : (o < 0 && (s = -s), d = s, a = s * i / o), { x: r + d, y: n + a };
530
+ }
531
+ function ye(e) {
532
+ let t = pe(tr(e) + 1).map(() => []);
533
+ return e.nodes().forEach((r) => {
534
+ let n = e.node(r), o = n.rank;
535
+ o !== void 0 && (t[o] || (t[o] = []), t[o][n.order] = r);
536
+ }), t;
537
+ }
538
+ function Dn(e) {
539
+ let t = e.nodes().map((n) => {
540
+ let o = e.node(n).rank;
541
+ return o === void 0 ? Number.MAX_VALUE : o;
542
+ }), r = K(Math.min, t);
543
+ e.nodes().forEach((n) => {
544
+ let o = e.node(n);
545
+ Object.hasOwn(o, "rank") && (o.rank -= r);
546
+ });
547
+ }
548
+ function Ln(e) {
549
+ let t = e.nodes().map((s) => e.node(s).rank).filter((s) => s !== void 0), r = K(Math.min, t), n = [];
550
+ e.nodes().forEach((s) => {
551
+ let l = e.node(s).rank - r;
552
+ n[l] || (n[l] = []), n[l].push(s);
553
+ });
554
+ let o = 0, i = e.graph().nodeRankFactor;
555
+ Array.from(n).forEach((s, l) => {
556
+ s === void 0 && l % i !== 0 ? --o : s !== void 0 && o && s.forEach((d) => e.node(d).rank += o);
557
+ });
558
+ }
559
+ function kt(e, t, r, n) {
560
+ let o = { width: 0, height: 0 };
561
+ return arguments.length >= 4 && (o.rank = r, o.order = n), fe(e, "border", o, t);
562
+ }
563
+ function An(e, t = er) {
564
+ let r = [];
565
+ for (let n = 0; n < e.length; n += t) {
566
+ let o = e.slice(n, n + t);
567
+ r.push(o);
568
+ }
569
+ return r;
570
+ }
571
+ var er = 65535;
572
+ function K(e, t) {
573
+ if (t.length > er) {
574
+ let r = An(t);
575
+ return e(...r.map((n) => e(...n)));
576
+ } else return e(...t);
577
+ }
578
+ function tr(e) {
579
+ let t = e.nodes().map((r) => {
580
+ let n = e.node(r).rank;
581
+ return n === void 0 ? Number.MIN_VALUE : n;
582
+ });
583
+ return K(Math.max, t);
584
+ }
585
+ function Pn(e, t) {
586
+ let r = { lhs: [], rhs: [] };
587
+ return e.forEach((n) => {
588
+ t(n) ? r.lhs.push(n) : r.rhs.push(n);
589
+ }), r;
590
+ }
591
+ function rr(e, t) {
592
+ let r = Date.now();
593
+ try {
594
+ return t();
595
+ } finally {
596
+ console.log(e + " time: " + (Date.now() - r) + "ms");
597
+ }
598
+ }
599
+ function nr(e, t) {
600
+ return t();
601
+ }
602
+ var Bn = 0;
603
+ function He(e) {
604
+ let t = ++Bn;
605
+ return e + ("" + t);
606
+ }
607
+ function pe(e, t, r = 1) {
608
+ t == null && (t = e, e = 0);
609
+ let n = (i) => i < t;
610
+ r < 0 && (n = (i) => t < i);
611
+ let o = [];
612
+ for (let i = e; n(i); i += r) o.push(i);
613
+ return o;
614
+ }
615
+ function Te(e, t) {
616
+ let r = {};
617
+ for (let n of t) e[n] !== void 0 && (r[n] = e[n]);
618
+ return r;
619
+ }
620
+ function Ne(e, t) {
621
+ let r;
622
+ return typeof t == "string" ? r = (n) => n[t] : r = t, Object.entries(e).reduce((n, [o, i]) => (n[o] = r(i, o), n), {});
623
+ }
624
+ function Wn(e, t) {
625
+ return e.reduce((r, n, o) => (r[n] = t[o], r), {});
626
+ }
627
+ var Ce = "\0", Gn = "3.0.0", $n = class {
628
+ constructor() {
629
+ cn(this, "_sentinel");
630
+ let e = {};
631
+ e._next = e._prev = e, this._sentinel = e;
632
+ }
633
+ dequeue() {
634
+ let e = this._sentinel, t = e._prev;
635
+ if (t !== e) return xt(t), t;
636
+ }
637
+ enqueue(e) {
638
+ let t = this._sentinel;
639
+ e._prev && e._next && xt(e), e._next = t._next, t._next._prev = e, t._next = e, e._prev = t;
640
+ }
641
+ toString() {
642
+ let e = [], t = this._sentinel, r = t._prev;
643
+ for (; r !== t; ) e.push(JSON.stringify(r, Yn)), r = r._prev;
644
+ return "[" + e.join(", ") + "]";
645
+ }
646
+ };
647
+ function xt(e) {
648
+ e._prev._next = e._next, e._next._prev = e._prev, delete e._next, delete e._prev;
649
+ }
650
+ function Yn(e, t) {
651
+ if (e !== "_next" && e !== "_prev") return t;
652
+ }
653
+ var Kn = $n, Un = () => 1;
654
+ function Vn(e, t) {
655
+ if (e.nodeCount() <= 1) return [];
656
+ let r = qn(e, t || Un);
657
+ return Hn(r.graph, r.buckets, r.zeroIdx).flatMap((n) => e.outEdges(n.v, n.w) || []);
658
+ }
659
+ function Hn(e, t, r) {
660
+ var n;
661
+ let o = [], i = t[t.length - 1], s = t[0], l;
662
+ for (; e.nodeCount(); ) {
663
+ for (; l = s.dequeue(); ) ze(e, t, r, l);
664
+ for (; l = i.dequeue(); ) ze(e, t, r, l);
665
+ if (e.nodeCount()) {
666
+ for (let d = t.length - 2; d > 0; --d) if (l = (n = t[d]) == null ? void 0 : n.dequeue(), l) {
667
+ o = o.concat(ze(e, t, r, l, !0) || []);
668
+ break;
669
+ }
670
+ }
671
+ }
672
+ return o;
673
+ }
674
+ function ze(e, t, r, n, o) {
675
+ let i = [], s = o ? i : void 0;
676
+ return (e.inEdges(n.v) || []).forEach((l) => {
677
+ let d = e.edge(l), a = e.node(l.v);
678
+ o && i.push({ v: l.v, w: l.w }), a.out -= d, Ge(t, r, a);
679
+ }), (e.outEdges(n.v) || []).forEach((l) => {
680
+ let d = e.edge(l), a = l.w, c = e.node(a);
681
+ c.in -= d, Ge(t, r, c);
682
+ }), e.removeNode(n.v), s;
683
+ }
684
+ function qn(e, t) {
685
+ let r = new G(), n = 0, o = 0;
686
+ e.nodes().forEach((l) => {
687
+ r.setNode(l, { v: l, in: 0, out: 0 });
688
+ }), e.edges().forEach((l) => {
689
+ let d = r.edge(l.v, l.w) || 0, a = t(l), c = d + a;
690
+ r.setEdge(l.v, l.w, c);
691
+ let u = r.node(l.v), h = r.node(l.w);
692
+ o = Math.max(o, u.out += a), n = Math.max(n, h.in += a);
693
+ });
694
+ let i = Xn(o + n + 3).map(() => new Kn()), s = n + 1;
695
+ return r.nodes().forEach((l) => {
696
+ Ge(i, s, r.node(l));
697
+ }), { graph: r, buckets: i, zeroIdx: s };
698
+ }
699
+ function Ge(e, t, r) {
700
+ var n, o, i;
701
+ r.out ? r.in ? (i = e[r.out - r.in + t]) == null || i.enqueue(r) : (o = e[e.length - 1]) == null || o.enqueue(r) : (n = e[0]) == null || n.enqueue(r);
702
+ }
703
+ function Xn(e) {
704
+ let t = [];
705
+ for (let r = 0; r < e; r++) t.push(r);
706
+ return t;
707
+ }
708
+ function Jn(e) {
709
+ (e.graph().acyclicer === "greedy" ? Vn(e, t(e)) : Zn(e)).forEach((r) => {
710
+ let n = e.edge(r);
711
+ e.removeEdge(r), n.forwardName = r.name, n.reversed = !0, e.setEdge(r.w, r.v, n, He("rev"));
712
+ });
713
+ function t(r) {
714
+ return (n) => r.edge(n).weight;
715
+ }
716
+ }
717
+ function Zn(e) {
718
+ let t = [], r = {}, n = {};
719
+ function o(i) {
720
+ Object.hasOwn(n, i) || (n[i] = !0, r[i] = !0, e.outEdges(i).forEach((s) => {
721
+ Object.hasOwn(r, s.w) ? t.push(s) : o(s.w);
722
+ }), delete r[i]);
723
+ }
724
+ return e.nodes().forEach(o), t;
725
+ }
726
+ function Qn(e) {
727
+ e.edges().forEach((t) => {
728
+ let r = e.edge(t);
729
+ if (r.reversed) {
730
+ e.removeEdge(t);
731
+ let n = r.forwardName;
732
+ delete r.reversed, delete r.forwardName, e.setEdge(t.w, t.v, r, n);
733
+ }
734
+ });
735
+ }
736
+ function eo(e) {
737
+ e.graph().dummyChains = [], e.edges().forEach((t) => to(e, t));
738
+ }
739
+ function to(e, t) {
740
+ let r = t.v, n = e.node(r).rank, o = t.w, i = e.node(o).rank, s = t.name, l = e.edge(t), d = l.labelRank;
741
+ if (i === n + 1) return;
742
+ e.removeEdge(t);
743
+ let a, c, u;
744
+ for (u = 0, ++n; n < i; ++u, ++n) l.points = [], c = { width: 0, height: 0, edgeLabel: l, edgeObj: t, rank: n }, a = fe(e, "edge", c, "_d"), n === d && (c.width = l.width, c.height = l.height, c.dummy = "edge-label", c.labelpos = l.labelpos), e.setEdge(r, a, { weight: l.weight }, s), u === 0 && e.graph().dummyChains.push(a), r = a;
745
+ e.setEdge(r, o, { weight: l.weight }, s);
746
+ }
747
+ function ro(e) {
748
+ e.graph().dummyChains.forEach((t) => {
749
+ let r = e.node(t), n = r.edgeLabel, o;
750
+ for (e.setEdge(r.edgeObj, n); r.dummy; ) o = e.successors(t)[0], e.removeNode(t), n.points.push({ x: r.x, y: r.y }), r.dummy === "edge-label" && (n.x = r.x, n.y = r.y, n.width = r.width, n.height = r.height), t = o, r = e.node(t);
751
+ });
752
+ }
753
+ function qe(e) {
754
+ let t = {};
755
+ function r(n) {
756
+ let o = e.node(n);
757
+ if (Object.hasOwn(t, n)) return o.rank;
758
+ t[n] = !0;
759
+ let i = e.outEdges(n), s = i ? i.map((d) => d == null ? Number.POSITIVE_INFINITY : r(d.w) - e.edge(d).minlen) : [], l = K(Math.min, s);
760
+ return l === Number.POSITIVE_INFINITY && (l = 0), o.rank = l;
761
+ }
762
+ e.sources().forEach(r);
763
+ }
764
+ function ue(e, t) {
765
+ return e.node(t.w).rank - e.node(t.v).rank - e.edge(t).minlen;
766
+ }
767
+ var or = no;
768
+ function no(e) {
769
+ let t = new G({ directed: !1 }), r = e.nodes();
770
+ if (r.length === 0) throw new Error("Graph must have at least one node");
771
+ let n = r[0], o = e.nodeCount();
772
+ t.setNode(n, {});
773
+ let i, s;
774
+ for (; oo(t, e) < o && (i = io(t, e), !!i); ) s = t.hasNode(i.v) ? ue(e, i) : -ue(e, i), so(t, e, s);
775
+ return t;
776
+ }
777
+ function oo(e, t) {
778
+ function r(n) {
779
+ let o = t.nodeEdges(n);
780
+ o && o.forEach((i) => {
781
+ let s = i.v, l = n === s ? i.w : s;
782
+ !e.hasNode(l) && !ue(t, i) && (e.setNode(l, {}), e.setEdge(n, l, {}), r(l));
783
+ });
784
+ }
785
+ return e.nodes().forEach(r), e.nodeCount();
786
+ }
787
+ function io(e, t) {
788
+ return t.edges().reduce((r, n) => {
789
+ let o = Number.POSITIVE_INFINITY;
790
+ return e.hasNode(n.v) !== e.hasNode(n.w) && (o = ue(t, n)), o < r[0] ? [o, n] : r;
791
+ }, [Number.POSITIVE_INFINITY, null])[1];
792
+ }
793
+ function so(e, t, r) {
794
+ e.nodes().forEach((n) => t.node(n).rank += r);
795
+ }
796
+ var { preorder: lo, postorder: ao } = Ve, co = se;
797
+ se.initLowLimValues = Je;
798
+ se.initCutValues = Xe;
799
+ se.calcCutValue = ir;
800
+ se.leaveEdge = lr;
801
+ se.enterEdge = ar;
802
+ se.exchangeEdges = dr;
803
+ function se(e) {
804
+ e = Rn(e), qe(e);
805
+ let t = or(e);
806
+ Je(t), Xe(t, e);
807
+ let r, n;
808
+ for (; r = lr(t); ) n = ar(t, e, r), dr(t, e, r, n);
809
+ }
810
+ function Xe(e, t) {
811
+ let r = ao(e, e.nodes());
812
+ r = r.slice(0, r.length - 1), r.forEach((n) => uo(e, t, n));
813
+ }
814
+ function uo(e, t, r) {
815
+ let n = e.node(r).parent, o = e.edge(r, n);
816
+ o.cutvalue = ir(e, t, r);
817
+ }
818
+ function ir(e, t, r) {
819
+ let n = e.node(r).parent, o = !0, i = t.edge(r, n), s = 0;
820
+ i || (o = !1, i = t.edge(n, r)), s = i.weight;
821
+ let l = t.nodeEdges(r);
822
+ return l && l.forEach((d) => {
823
+ let a = d.v === r, c = a ? d.w : d.v;
824
+ if (c !== n) {
825
+ let u = a === o, h = t.edge(d).weight;
826
+ if (s += u ? h : -h, ho(e, r, c)) {
827
+ let g = e.edge(r, c).cutvalue;
828
+ s += u ? -g : g;
829
+ }
830
+ }
831
+ }), s;
832
+ }
833
+ function Je(e, t) {
834
+ arguments.length < 2 && (t = e.nodes()[0]), sr(e, {}, 1, t);
835
+ }
836
+ function sr(e, t, r, n, o) {
837
+ let i = r, s = e.node(n);
838
+ t[n] = !0;
839
+ let l = e.neighbors(n);
840
+ return l && l.forEach((d) => {
841
+ Object.hasOwn(t, d) || (r = sr(e, t, r, d, n));
842
+ }), s.low = i, s.lim = r++, o ? s.parent = o : delete s.parent, r;
843
+ }
844
+ function lr(e) {
845
+ return e.edges().find((t) => e.edge(t).cutvalue < 0);
846
+ }
847
+ function ar(e, t, r) {
848
+ let n = r.v, o = r.w;
849
+ t.hasEdge(n, o) || (n = r.w, o = r.v);
850
+ let i = e.node(n), s = e.node(o), l = i, d = !1;
851
+ return i.lim > s.lim && (l = s, d = !0), t.edges().filter((a) => d === _t(e, e.node(a.v), l) && d !== _t(e, e.node(a.w), l)).reduce((a, c) => ue(t, c) < ue(t, a) ? c : a);
852
+ }
853
+ function dr(e, t, r, n) {
854
+ let o = r.v, i = r.w;
855
+ e.removeEdge(o, i), e.setEdge(n.v, n.w, {}), Je(e), Xe(e, t), fo(e, t);
856
+ }
857
+ function fo(e, t) {
858
+ let r = e.nodes().find((o) => !e.node(o).parent);
859
+ if (!r) return;
860
+ let n = lo(e, [r]);
861
+ n = n.slice(1), n.forEach((o) => {
862
+ let i = e.node(o).parent, s = t.edge(o, i), l = !1;
863
+ s || (s = t.edge(i, o), l = !0), t.node(o).rank = t.node(i).rank + (l ? s.minlen : -s.minlen);
864
+ });
865
+ }
866
+ function ho(e, t, r) {
867
+ return e.hasEdge(t, r);
868
+ }
869
+ function _t(e, t, r) {
870
+ return r.low <= t.lim && t.lim <= r.lim;
871
+ }
872
+ var go = po;
873
+ function po(e) {
874
+ let t = e.graph().ranker;
875
+ if (typeof t == "function") return t(e);
876
+ switch (t) {
877
+ case "network-simplex":
878
+ Tt(e);
879
+ break;
880
+ case "tight-tree":
881
+ yo(e);
882
+ break;
883
+ case "longest-path":
884
+ bo(e);
885
+ break;
886
+ case "none":
887
+ break;
888
+ default:
889
+ Tt(e);
890
+ }
891
+ }
892
+ var bo = qe;
893
+ function yo(e) {
894
+ qe(e), or(e);
895
+ }
896
+ function Tt(e) {
897
+ co(e);
898
+ }
899
+ var mo = wo;
900
+ function wo(e) {
901
+ let t = Eo(e);
902
+ e.graph().dummyChains.forEach((r) => {
903
+ let n = e.node(r), o = n.edgeObj, i = vo(e, t, o.v, o.w), s = i.path, l = i.lca, d = 0, a = s[d], c = !0;
904
+ for (; r !== o.w; ) {
905
+ if (n = e.node(r), c) {
906
+ for (; (a = s[d]) !== l && e.node(a).maxRank < n.rank; ) d++;
907
+ a === l && (c = !1);
908
+ }
909
+ if (!c) {
910
+ for (; d < s.length - 1 && e.node(s[d + 1]).minRank <= n.rank; ) d++;
911
+ a = s[d];
912
+ }
913
+ a !== void 0 && e.setParent(r, a), r = e.successors(r)[0];
914
+ }
915
+ });
916
+ }
917
+ function vo(e, t, r, n) {
918
+ let o = [], i = [], s = Math.min(t[r].low, t[n].low), l = Math.max(t[r].lim, t[n].lim), d;
919
+ d = r;
920
+ do
921
+ d = e.parent(d), o.push(d);
922
+ while (d && (t[d].low > s || l > t[d].lim));
923
+ let a = d, c = n;
924
+ for (; (c = e.parent(c)) !== a; ) i.push(c);
925
+ return { path: o.concat(i.reverse()), lca: a };
926
+ }
927
+ function Eo(e) {
928
+ let t = {}, r = 0;
929
+ function n(o) {
930
+ let i = r;
931
+ e.children(o).forEach(n), t[o] = { low: i, lim: r++ };
932
+ }
933
+ return e.children(Ce).forEach(n), t;
934
+ }
935
+ function ko(e) {
936
+ let t = fe(e, "root", {}, "_root"), r = xo(e), n = Object.values(r), o = K(Math.max, n) - 1, i = 2 * o + 1;
937
+ e.graph().nestingRoot = t, e.edges().forEach((l) => e.edge(l).minlen *= i);
938
+ let s = _o(e) + 1;
939
+ e.children(Ce).forEach((l) => cr(e, t, i, s, o, r, l)), e.graph().nodeRankFactor = i;
940
+ }
941
+ function cr(e, t, r, n, o, i, s) {
942
+ var l;
943
+ let d = e.children(s);
944
+ if (!d.length) {
945
+ s !== t && e.setEdge(t, s, { weight: 0, minlen: r });
946
+ return;
947
+ }
948
+ let a = kt(e, "_bt"), c = kt(e, "_bb"), u = e.node(s);
949
+ e.setParent(a, s), u.borderTop = a, e.setParent(c, s), u.borderBottom = c, d.forEach((h) => {
950
+ var g;
951
+ cr(e, t, r, n, o, i, h);
952
+ let b = e.node(h), y = b.borderTop ? b.borderTop : h, p = b.borderBottom ? b.borderBottom : h, v = b.borderTop ? n : 2 * n, N = y !== p ? 1 : o - ((g = i[s]) != null ? g : 0) + 1;
953
+ e.setEdge(a, y, { weight: v, minlen: N, nestingEdge: !0 }), e.setEdge(p, c, { weight: v, minlen: N, nestingEdge: !0 });
954
+ }), e.parent(s) || e.setEdge(t, a, { weight: 0, minlen: o + ((l = i[s]) != null ? l : 0) });
955
+ }
956
+ function xo(e) {
957
+ let t = {};
958
+ function r(n, o) {
959
+ let i = e.children(n);
960
+ i && i.length && i.forEach((s) => r(s, o + 1)), t[n] = o;
961
+ }
962
+ return e.children(Ce).forEach((n) => r(n, 1)), t;
963
+ }
964
+ function _o(e) {
965
+ return e.edges().reduce((t, r) => t + e.edge(r).weight, 0);
966
+ }
967
+ function To(e) {
968
+ let t = e.graph();
969
+ e.removeNode(t.nestingRoot), delete t.nestingRoot, e.edges().forEach((r) => {
970
+ e.edge(r).nestingEdge && e.removeEdge(r);
971
+ });
972
+ }
973
+ var No = Co;
974
+ function Co(e) {
975
+ function t(r) {
976
+ let n = e.children(r), o = e.node(r);
977
+ if (n.length && n.forEach(t), Object.hasOwn(o, "minRank")) {
978
+ o.borderLeft = [], o.borderRight = [];
979
+ for (let i = o.minRank, s = o.maxRank + 1; i < s; ++i) Nt(e, "borderLeft", "_bl", r, o, i), Nt(e, "borderRight", "_br", r, o, i);
980
+ }
981
+ }
982
+ e.children(Ce).forEach(t);
983
+ }
984
+ function Nt(e, t, r, n, o, i) {
985
+ let s = { width: 0, height: 0, rank: i, borderType: t }, l = o[t][i - 1], d = fe(e, "border", s, r);
986
+ o[t][i] = d, e.setParent(d, n), l && e.setEdge(l, d, { weight: 1 });
987
+ }
988
+ function So(e) {
989
+ var t;
990
+ let r = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
991
+ (r === "lr" || r === "rl") && ur(e);
992
+ }
993
+ function Io(e) {
994
+ var t;
995
+ let r = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
996
+ (r === "bt" || r === "rl") && Oo(e), (r === "lr" || r === "rl") && (Mo(e), ur(e));
997
+ }
998
+ function ur(e) {
999
+ e.nodes().forEach((t) => Ct(e.node(t))), e.edges().forEach((t) => Ct(e.edge(t)));
1000
+ }
1001
+ function Ct(e) {
1002
+ let t = e.width;
1003
+ e.width = e.height, e.height = t;
1004
+ }
1005
+ function Oo(e) {
1006
+ e.nodes().forEach((t) => Re(e.node(t))), e.edges().forEach((t) => {
1007
+ var r;
1008
+ let n = e.edge(t);
1009
+ (r = n.points) == null || r.forEach(Re), Object.hasOwn(n, "y") && Re(n);
1010
+ });
1011
+ }
1012
+ function Re(e) {
1013
+ e.y = -e.y;
1014
+ }
1015
+ function Mo(e) {
1016
+ e.nodes().forEach((t) => De(e.node(t))), e.edges().forEach((t) => {
1017
+ var r;
1018
+ let n = e.edge(t);
1019
+ (r = n.points) == null || r.forEach(De), Object.hasOwn(n, "x") && De(n);
1020
+ });
1021
+ }
1022
+ function De(e) {
1023
+ let t = e.x;
1024
+ e.x = e.y, e.y = t;
1025
+ }
1026
+ function jo(e) {
1027
+ let t = {}, r = e.nodes().filter((l) => !e.children(l).length), n = r.map((l) => e.node(l).rank), o = K(Math.max, n), i = pe(o + 1).map(() => []);
1028
+ function s(l) {
1029
+ if (t[l]) return;
1030
+ t[l] = !0;
1031
+ let d = e.node(l);
1032
+ i[d.rank].push(l);
1033
+ let a = e.successors(l);
1034
+ a && a.forEach(s);
1035
+ }
1036
+ return r.sort((l, d) => e.node(l).rank - e.node(d).rank).forEach(s), i;
1037
+ }
1038
+ function Fo(e, t) {
1039
+ let r = 0;
1040
+ for (let n = 1; n < t.length; ++n) r += zo(e, t[n - 1], t[n]);
1041
+ return r;
1042
+ }
1043
+ function zo(e, t, r) {
1044
+ let n = Wn(r, r.map((a, c) => c)), o = t.flatMap((a) => {
1045
+ let c = e.outEdges(a);
1046
+ return c ? c.map((u) => ({ pos: n[u.w], weight: e.edge(u).weight })).sort((u, h) => u.pos - h.pos) : [];
1047
+ }), i = 1;
1048
+ for (; i < r.length; ) i <<= 1;
1049
+ let s = 2 * i - 1;
1050
+ i -= 1;
1051
+ let l = new Array(s).fill(0), d = 0;
1052
+ return o.forEach((a) => {
1053
+ let c = a.pos + i;
1054
+ l[c] += a.weight;
1055
+ let u = 0;
1056
+ for (; c > 0; ) c % 2 && (u += l[c + 1]), c = c - 1 >> 1, l[c] += a.weight;
1057
+ d += a.weight * u;
1058
+ }), d;
1059
+ }
1060
+ function Ro(e, t = []) {
1061
+ return t.map((r) => {
1062
+ let n = e.inEdges(r);
1063
+ if (!n || !n.length) return { v: r };
1064
+ {
1065
+ let o = n.reduce((i, s) => {
1066
+ let l = e.edge(s), d = e.node(s.v);
1067
+ return { sum: i.sum + l.weight * d.order, weight: i.weight + l.weight };
1068
+ }, { sum: 0, weight: 0 });
1069
+ return { v: r, barycenter: o.sum / o.weight, weight: o.weight };
1070
+ }
1071
+ });
1072
+ }
1073
+ function Do(e, t) {
1074
+ let r = {};
1075
+ e.forEach((o, i) => {
1076
+ let s = { indegree: 0, in: [], out: [], vs: [o.v], i };
1077
+ o.barycenter !== void 0 && (s.barycenter = o.barycenter, s.weight = o.weight), r[o.v] = s;
1078
+ }), t.edges().forEach((o) => {
1079
+ let i = r[o.v], s = r[o.w];
1080
+ i !== void 0 && s !== void 0 && (s.indegree++, i.out.push(s));
1081
+ });
1082
+ let n = Object.values(r).filter((o) => !o.indegree);
1083
+ return Lo(n);
1084
+ }
1085
+ function Lo(e) {
1086
+ let t = [];
1087
+ function r(o) {
1088
+ return (i) => {
1089
+ i.merged || (i.barycenter === void 0 || o.barycenter === void 0 || i.barycenter >= o.barycenter) && Ao(o, i);
1090
+ };
1091
+ }
1092
+ function n(o) {
1093
+ return (i) => {
1094
+ i.in.push(o), --i.indegree === 0 && e.push(i);
1095
+ };
1096
+ }
1097
+ for (; e.length; ) {
1098
+ let o = e.pop();
1099
+ t.push(o), o.in.reverse().forEach(r(o)), o.out.forEach(n(o));
1100
+ }
1101
+ return t.filter((o) => !o.merged).map((o) => Te(o, ["vs", "i", "barycenter", "weight"]));
1102
+ }
1103
+ function Ao(e, t) {
1104
+ let r = 0, n = 0;
1105
+ e.weight && (r += e.barycenter * e.weight, n += e.weight), t.weight && (r += t.barycenter * t.weight, n += t.weight), e.vs = t.vs.concat(e.vs), e.barycenter = r / n, e.weight = n, e.i = Math.min(t.i, e.i), t.merged = !0;
1106
+ }
1107
+ function Po(e, t) {
1108
+ let r = Pn(e, (c) => Object.hasOwn(c, "barycenter")), n = r.lhs, o = r.rhs.sort((c, u) => u.i - c.i), i = [], s = 0, l = 0, d = 0;
1109
+ n.sort(Bo(!!t)), d = St(i, o, d), n.forEach((c) => {
1110
+ d += c.vs.length, i.push(c.vs), s += c.barycenter * c.weight, l += c.weight, d = St(i, o, d);
1111
+ });
1112
+ let a = { vs: i.flat(1) };
1113
+ return l && (a.barycenter = s / l, a.weight = l), a;
1114
+ }
1115
+ function St(e, t, r) {
1116
+ let n;
1117
+ for (; t.length && (n = t[t.length - 1]).i <= r; ) t.pop(), e.push(n.vs), r++;
1118
+ return r;
1119
+ }
1120
+ function Bo(e) {
1121
+ return (t, r) => t.barycenter < r.barycenter ? -1 : t.barycenter > r.barycenter ? 1 : e ? r.i - t.i : t.i - r.i;
1122
+ }
1123
+ function fr(e, t, r, n) {
1124
+ let o = e.children(t), i = e.node(t), s = i ? i.borderLeft : void 0, l = i ? i.borderRight : void 0, d = {};
1125
+ s && (o = o.filter((h) => h !== s && h !== l));
1126
+ let a = Ro(e, o);
1127
+ a.forEach((h) => {
1128
+ if (e.children(h.v).length) {
1129
+ let g = fr(e, h.v, r, n);
1130
+ d[h.v] = g, Object.hasOwn(g, "barycenter") && Go(h, g);
1131
+ }
1132
+ });
1133
+ let c = Do(a, r);
1134
+ Wo(c, d);
1135
+ let u = Po(c, n);
1136
+ if (s && l) {
1137
+ u.vs = [s, u.vs, l].flat(1);
1138
+ let h = e.predecessors(s);
1139
+ if (h && h.length) {
1140
+ let g = e.node(h[0]), b = e.predecessors(l), y = e.node(b[0]);
1141
+ Object.hasOwn(u, "barycenter") || (u.barycenter = 0, u.weight = 0), u.barycenter = (u.barycenter * u.weight + g.order + y.order) / (u.weight + 2), u.weight += 2;
1142
+ }
1143
+ }
1144
+ return u;
1145
+ }
1146
+ function Wo(e, t) {
1147
+ e.forEach((r) => {
1148
+ r.vs = r.vs.flatMap((n) => t[n] ? t[n].vs : n);
1149
+ });
1150
+ }
1151
+ function Go(e, t) {
1152
+ e.barycenter !== void 0 ? (e.barycenter = (e.barycenter * e.weight + t.barycenter * t.weight) / (e.weight + t.weight), e.weight += t.weight) : (e.barycenter = t.barycenter, e.weight = t.weight);
1153
+ }
1154
+ function $o(e, t, r, n) {
1155
+ n || (n = e.nodes());
1156
+ let o = Yo(e), i = new G({ compound: !0 }).setGraph({ root: o }).setDefaultNodeLabel((s) => e.node(s));
1157
+ return n.forEach((s) => {
1158
+ let l = e.node(s), d = e.parent(s);
1159
+ if (l.rank === t || l.minRank <= t && t <= l.maxRank) {
1160
+ i.setNode(s), i.setParent(s, d || o);
1161
+ let a = e[r](s);
1162
+ a && a.forEach((c) => {
1163
+ let u = c.v === s ? c.w : c.v, h = i.edge(u, s), g = h !== void 0 ? h.weight : 0;
1164
+ i.setEdge(u, s, { weight: e.edge(c).weight + g });
1165
+ }), Object.hasOwn(l, "minRank") && i.setNode(s, { borderLeft: l.borderLeft[t], borderRight: l.borderRight[t] });
1166
+ }
1167
+ }), i;
1168
+ }
1169
+ function Yo(e) {
1170
+ let t;
1171
+ for (; e.hasNode(t = He("_root")); ) ;
1172
+ return t;
1173
+ }
1174
+ function Ko(e, t, r) {
1175
+ let n = {}, o;
1176
+ r.forEach((i) => {
1177
+ let s = e.parent(i), l, d;
1178
+ for (; s; ) {
1179
+ if (l = e.parent(s), l ? (d = n[l], n[l] = s) : (d = o, o = s), d && d !== s) {
1180
+ t.setEdge(d, s);
1181
+ return;
1182
+ }
1183
+ s = l;
1184
+ }
1185
+ });
1186
+ }
1187
+ function hr(e, t = {}) {
1188
+ if (typeof t.customOrder == "function") {
1189
+ t.customOrder(e, hr);
1190
+ return;
1191
+ }
1192
+ let r = tr(e), n = It(e, pe(1, r + 1), "inEdges"), o = It(e, pe(r - 1, -1, -1), "outEdges"), i = jo(e);
1193
+ if (Ot(e, i), t.disableOptimalOrderHeuristic) return;
1194
+ let s = Number.POSITIVE_INFINITY, l, d = t.constraints || [];
1195
+ for (let a = 0, c = 0; c < 4; ++a, ++c) {
1196
+ Uo(a % 2 ? n : o, a % 4 >= 2, d), i = ye(e);
1197
+ let u = Fo(e, i);
1198
+ u < s ? (c = 0, l = Object.assign({}, i), s = u) : u === s && (l = structuredClone(i));
1199
+ }
1200
+ Ot(e, l);
1201
+ }
1202
+ function It(e, t, r) {
1203
+ let n = /* @__PURE__ */ new Map(), o = (i, s) => {
1204
+ n.has(i) || n.set(i, []), n.get(i).push(s);
1205
+ };
1206
+ for (let i of e.nodes()) {
1207
+ let s = e.node(i);
1208
+ if (typeof s.rank == "number" && o(s.rank, i), typeof s.minRank == "number" && typeof s.maxRank == "number") for (let l = s.minRank; l <= s.maxRank; l++) l !== s.rank && o(l, i);
1209
+ }
1210
+ return t.map(function(i) {
1211
+ return $o(e, i, r, n.get(i) || []);
1212
+ });
1213
+ }
1214
+ function Uo(e, t, r) {
1215
+ let n = new G();
1216
+ e.forEach(function(o) {
1217
+ r.forEach((l) => n.setEdge(l.left, l.right));
1218
+ let i = o.graph().root, s = fr(o, i, n, t);
1219
+ s.vs.forEach((l, d) => o.node(l).order = d), Ko(o, n, s.vs);
1220
+ });
1221
+ }
1222
+ function Ot(e, t) {
1223
+ Object.values(t).forEach((r) => r.forEach((n, o) => e.node(n).order = o));
1224
+ }
1225
+ function Vo(e, t) {
1226
+ let r = {};
1227
+ function n(o, i) {
1228
+ let s = 0, l = 0, d = o.length, a = i[i.length - 1];
1229
+ return i.forEach((c, u) => {
1230
+ let h = qo(e, c), g = h ? e.node(h).order : d;
1231
+ (h || c === a) && (i.slice(l, u + 1).forEach((b) => {
1232
+ let y = e.predecessors(b);
1233
+ y && y.forEach((p) => {
1234
+ let v = e.node(p), N = v.order;
1235
+ (N < s || g < N) && !(v.dummy && e.node(b).dummy) && gr(r, p, b);
1236
+ });
1237
+ }), l = u + 1, s = g);
1238
+ }), i;
1239
+ }
1240
+ return t.length && t.reduce(n), r;
1241
+ }
1242
+ function Ho(e, t) {
1243
+ let r = {};
1244
+ function n(i, s, l, d, a) {
1245
+ pe(s, l).forEach((c) => {
1246
+ let u = i[c];
1247
+ if (u !== void 0 && e.node(u).dummy) {
1248
+ let h = e.predecessors(u);
1249
+ h && h.forEach((g) => {
1250
+ if (g === void 0) return;
1251
+ let b = e.node(g);
1252
+ b.dummy && (b.order < d || b.order > a) && gr(r, g, u);
1253
+ });
1254
+ }
1255
+ });
1256
+ }
1257
+ function o(i, s) {
1258
+ let l = -1, d = -1, a = 0;
1259
+ return s.forEach((c, u) => {
1260
+ if (e.node(c).dummy === "border") {
1261
+ let h = e.predecessors(c);
1262
+ if (h && h.length) {
1263
+ let g = h[0];
1264
+ if (g === void 0) return;
1265
+ d = e.node(g).order, n(s, a, u, l, d), a = u, l = d;
1266
+ }
1267
+ }
1268
+ n(s, a, s.length, d, i.length);
1269
+ }), s;
1270
+ }
1271
+ return t.length && t.reduce(o), r;
1272
+ }
1273
+ function qo(e, t) {
1274
+ if (e.node(t).dummy) {
1275
+ let r = e.predecessors(t);
1276
+ if (r) return r.find((n) => e.node(n).dummy);
1277
+ }
1278
+ }
1279
+ function gr(e, t, r) {
1280
+ if (t > r) {
1281
+ let o = t;
1282
+ t = r, r = o;
1283
+ }
1284
+ let n = e[t];
1285
+ n || (e[t] = n = {}), n[r] = !0;
1286
+ }
1287
+ function Xo(e, t, r) {
1288
+ if (t > r) {
1289
+ let o = t;
1290
+ t = r, r = o;
1291
+ }
1292
+ let n = e[t];
1293
+ return n !== void 0 && Object.hasOwn(n, r);
1294
+ }
1295
+ function Jo(e, t, r, n) {
1296
+ let o = {}, i = {}, s = {};
1297
+ return t.forEach((l) => {
1298
+ l.forEach((d, a) => {
1299
+ o[d] = d, i[d] = d, s[d] = a;
1300
+ });
1301
+ }), t.forEach((l) => {
1302
+ let d = -1;
1303
+ l.forEach((a) => {
1304
+ let c = n(a);
1305
+ if (c && c.length) {
1306
+ let u = c.sort((g, b) => {
1307
+ let y = s[g], p = s[b];
1308
+ return (y !== void 0 ? y : 0) - (p !== void 0 ? p : 0);
1309
+ }), h = (u.length - 1) / 2;
1310
+ for (let g = Math.floor(h), b = Math.ceil(h); g <= b; ++g) {
1311
+ let y = u[g];
1312
+ if (y === void 0) continue;
1313
+ let p = s[y];
1314
+ if (p !== void 0 && i[a] === a && d < p && !Xo(r, a, y)) {
1315
+ let v = o[y];
1316
+ v !== void 0 && (i[y] = a, i[a] = o[a] = v, d = p);
1317
+ }
1318
+ }
1319
+ }
1320
+ });
1321
+ }), { root: o, align: i };
1322
+ }
1323
+ function Zo(e, t, r, n, o = !1) {
1324
+ let i = {}, s = Qo(e, t, r, o), l = o ? "borderLeft" : "borderRight";
1325
+ function d(g, b) {
1326
+ let y = s.nodes().slice(), p = {}, v = y.pop();
1327
+ for (; v; ) {
1328
+ if (p[v]) g(v);
1329
+ else {
1330
+ p[v] = !0, y.push(v);
1331
+ for (let N of b(v)) y.push(N);
1332
+ }
1333
+ v = y.pop();
1334
+ }
1335
+ }
1336
+ function a(g) {
1337
+ let b = s.inEdges(g);
1338
+ b ? i[g] = b.reduce((y, p) => {
1339
+ var v;
1340
+ let N = (v = i[p.v]) != null ? v : 0, O = s.edge(p);
1341
+ return Math.max(y, N + (O !== void 0 ? O : 0));
1342
+ }, 0) : i[g] = 0;
1343
+ }
1344
+ function c(g) {
1345
+ let b = s.outEdges(g), y = Number.POSITIVE_INFINITY;
1346
+ b && (y = b.reduce((v, N) => {
1347
+ let O = i[N.w], M = s.edge(N);
1348
+ return Math.min(v, (O !== void 0 ? O : 0) - (M !== void 0 ? M : 0));
1349
+ }, Number.POSITIVE_INFINITY));
1350
+ let p = e.node(g);
1351
+ y !== Number.POSITIVE_INFINITY && p.borderType !== l && (i[g] = Math.max(i[g] !== void 0 ? i[g] : 0, y));
1352
+ }
1353
+ function u(g) {
1354
+ return s.predecessors(g) || [];
1355
+ }
1356
+ function h(g) {
1357
+ return s.successors(g) || [];
1358
+ }
1359
+ return d(a, u), d(c, h), Object.keys(n).forEach((g) => {
1360
+ var b;
1361
+ let y = r[g];
1362
+ y !== void 0 && (i[g] = (b = i[y]) != null ? b : 0);
1363
+ }), i;
1364
+ }
1365
+ function Qo(e, t, r, n) {
1366
+ let o = new G(), i = e.graph(), s = oi(i.nodesep, i.edgesep, n);
1367
+ return t.forEach((l) => {
1368
+ let d;
1369
+ l.forEach((a) => {
1370
+ let c = r[a];
1371
+ if (c !== void 0) {
1372
+ if (o.setNode(c), d !== void 0) {
1373
+ let u = r[d];
1374
+ if (u !== void 0) {
1375
+ let h = o.edge(u, c);
1376
+ o.setEdge(u, c, Math.max(s(e, a, d), h || 0));
1377
+ }
1378
+ }
1379
+ d = a;
1380
+ }
1381
+ });
1382
+ }), o;
1383
+ }
1384
+ function ei(e, t) {
1385
+ return Object.values(t).reduce((r, n) => {
1386
+ let o = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
1387
+ Object.entries(n).forEach(([l, d]) => {
1388
+ let a = ii(e, l) / 2;
1389
+ o = Math.max(d + a, o), i = Math.min(d - a, i);
1390
+ });
1391
+ let s = o - i;
1392
+ return s < r[0] && (r = [s, n]), r;
1393
+ }, [Number.POSITIVE_INFINITY, null])[1];
1394
+ }
1395
+ function ti(e, t) {
1396
+ let r = Object.values(t), n = K(Math.min, r), o = K(Math.max, r);
1397
+ ["u", "d"].forEach((i) => {
1398
+ ["l", "r"].forEach((s) => {
1399
+ let l = i + s, d = e[l];
1400
+ if (!d || d === t) return;
1401
+ let a = Object.values(d), c = n - K(Math.min, a);
1402
+ s !== "l" && (c = o - K(Math.max, a)), c && (e[l] = Ne(d, (u) => u + c));
1403
+ });
1404
+ });
1405
+ }
1406
+ function ri(e, t = void 0) {
1407
+ let r = e.ul;
1408
+ return r ? Ne(r, (n, o) => {
1409
+ var i, s;
1410
+ if (t) {
1411
+ let d = t.toLowerCase(), a = e[d];
1412
+ if (a && a[o] !== void 0) return a[o];
1413
+ }
1414
+ let l = Object.values(e).map((d) => {
1415
+ let a = d[o];
1416
+ return a !== void 0 ? a : 0;
1417
+ }).sort((d, a) => d - a);
1418
+ return (((i = l[1]) != null ? i : 0) + ((s = l[2]) != null ? s : 0)) / 2;
1419
+ }) : {};
1420
+ }
1421
+ function ni(e) {
1422
+ let t = ye(e), r = Object.assign(Vo(e, t), Ho(e, t)), n = {}, o;
1423
+ ["u", "d"].forEach((s) => {
1424
+ o = s === "u" ? t : Object.values(t).reverse(), ["l", "r"].forEach((l) => {
1425
+ l === "r" && (o = o.map((c) => Object.values(c).reverse()));
1426
+ let d = Jo(e, o, r, (c) => (s === "u" ? e.predecessors(c) : e.successors(c)) || []), a = Zo(e, o, d.root, d.align, l === "r");
1427
+ l === "r" && (a = Ne(a, (c) => -c)), n[s + l] = a;
1428
+ });
1429
+ });
1430
+ let i = ei(e, n);
1431
+ return ti(n, i), ri(n, e.graph().align);
1432
+ }
1433
+ function oi(e, t, r) {
1434
+ return (n, o, i) => {
1435
+ let s = n.node(o), l = n.node(i), d = 0, a;
1436
+ if (d += s.width / 2, Object.hasOwn(s, "labelpos")) switch (s.labelpos.toLowerCase()) {
1437
+ case "l":
1438
+ a = -s.width / 2;
1439
+ break;
1440
+ case "r":
1441
+ a = s.width / 2;
1442
+ break;
1443
+ }
1444
+ if (a && (d += r ? a : -a), a = void 0, d += (s.dummy ? t : e) / 2, d += (l.dummy ? t : e) / 2, d += l.width / 2, Object.hasOwn(l, "labelpos")) switch (l.labelpos.toLowerCase()) {
1445
+ case "l":
1446
+ a = l.width / 2;
1447
+ break;
1448
+ case "r":
1449
+ a = -l.width / 2;
1450
+ break;
1451
+ }
1452
+ return a && (d += r ? a : -a), d;
1453
+ };
1454
+ }
1455
+ function ii(e, t) {
1456
+ return e.node(t).width;
1457
+ }
1458
+ function si(e) {
1459
+ e = Qt(e), li(e), Object.entries(ni(e)).forEach(([t, r]) => e.node(t).x = r);
1460
+ }
1461
+ function li(e) {
1462
+ let t = ye(e), r = e.graph(), n = r.ranksep, o = r.rankalign, i = 0;
1463
+ t.forEach((s) => {
1464
+ let l = s.reduce((d, a) => {
1465
+ var c;
1466
+ let u = (c = e.node(a).height) != null ? c : 0;
1467
+ return d > u ? d : u;
1468
+ }, 0);
1469
+ s.forEach((d) => {
1470
+ let a = e.node(d);
1471
+ o === "top" ? a.y = i + a.height / 2 : o === "bottom" ? a.y = i + l - a.height / 2 : a.y = i + l / 2;
1472
+ }), i += l + n;
1473
+ });
1474
+ }
1475
+ function ai(e, t = {}) {
1476
+ let r = t.debugTiming ? rr : nr;
1477
+ return r("layout", () => {
1478
+ let n = r(" buildLayoutGraph", () => mi(e));
1479
+ return r(" runLayout", () => di(n, r, t)), r(" updateInputGraph", () => ci(e, n)), n;
1480
+ });
1481
+ }
1482
+ function di(e, t, r) {
1483
+ t(" makeSpaceForEdgeLabels", () => wi(e)), t(" removeSelfEdges", () => Si(e)), t(" acyclic", () => Jn(e)), t(" nestingGraph.run", () => ko(e)), t(" rank", () => go(Qt(e))), t(" injectEdgeLabelProxies", () => vi(e)), t(" removeEmptyRanks", () => Ln(e)), t(" nestingGraph.cleanup", () => To(e)), t(" normalizeRanks", () => Dn(e)), t(" assignRankMinMax", () => Ei(e)), t(" removeEdgeLabelProxies", () => ki(e)), t(" normalize.run", () => eo(e)), t(" parentDummyChains", () => mo(e)), t(" addBorderSegments", () => No(e)), t(" order", () => hr(e, r)), t(" insertSelfEdges", () => Ii(e)), t(" adjustCoordinateSystem", () => So(e)), t(" position", () => si(e)), t(" positionSelfEdges", () => Oi(e)), t(" removeBorderNodes", () => Ci(e)), t(" normalize.undo", () => ro(e)), t(" fixupEdgeLabelCoords", () => Ti(e)), t(" undoCoordinateSystem", () => Io(e)), t(" translateGraph", () => xi(e)), t(" assignNodeIntersects", () => _i(e)), t(" reversePoints", () => Ni(e)), t(" acyclic.undo", () => Qn(e));
1484
+ }
1485
+ function ci(e, t) {
1486
+ e.nodes().forEach((r) => {
1487
+ let n = e.node(r), o = t.node(r);
1488
+ n && (n.x = o.x, n.y = o.y, n.order = o.order, n.rank = o.rank, t.children(r).length && (n.width = o.width, n.height = o.height));
1489
+ }), e.edges().forEach((r) => {
1490
+ let n = e.edge(r), o = t.edge(r);
1491
+ n.points = o.points, Object.hasOwn(o, "x") && (n.x = o.x, n.y = o.y);
1492
+ }), e.graph().width = t.graph().width, e.graph().height = t.graph().height;
1493
+ }
1494
+ var ui = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"], fi = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "TB", rankalign: "center" }, hi = ["acyclicer", "ranker", "rankdir", "align", "rankalign"], gi = ["width", "height", "rank"], Mt = { width: 0, height: 0 }, pi = ["minlen", "weight", "width", "height", "labeloffset"], bi = { minlen: 1, weight: 1, width: 0, height: 0, labeloffset: 10, labelpos: "r" }, yi = ["labelpos"];
1495
+ function mi(e) {
1496
+ let t = new G({ multigraph: !0, compound: !0 }), r = Ae(e.graph());
1497
+ return t.setGraph(Object.assign({}, fi, Le(r, ui), Te(r, hi))), e.nodes().forEach((n) => {
1498
+ let o = Ae(e.node(n)), i = Le(o, gi);
1499
+ Object.keys(Mt).forEach((l) => {
1500
+ i[l] === void 0 && (i[l] = Mt[l]);
1501
+ }), t.setNode(n, i);
1502
+ let s = e.parent(n);
1503
+ s !== void 0 && t.setParent(n, s);
1504
+ }), e.edges().forEach((n) => {
1505
+ let o = Ae(e.edge(n));
1506
+ t.setEdge(n, Object.assign({}, bi, Le(o, pi), Te(o, yi)));
1507
+ }), t;
1508
+ }
1509
+ function wi(e) {
1510
+ let t = e.graph();
1511
+ t.ranksep /= 2, e.edges().forEach((r) => {
1512
+ let n = e.edge(r);
1513
+ n.minlen *= 2, n.labelpos.toLowerCase() !== "c" && (t.rankdir === "TB" || t.rankdir === "BT" ? n.width += n.labeloffset : n.height += n.labeloffset);
1514
+ });
1515
+ }
1516
+ function vi(e) {
1517
+ e.edges().forEach((t) => {
1518
+ let r = e.edge(t);
1519
+ if (r.width && r.height) {
1520
+ let n = e.node(t.v), o = { rank: (e.node(t.w).rank - n.rank) / 2 + n.rank, e: t };
1521
+ fe(e, "edge-proxy", o, "_ep");
1522
+ }
1523
+ });
1524
+ }
1525
+ function Ei(e) {
1526
+ let t = 0;
1527
+ e.nodes().forEach((r) => {
1528
+ let n = e.node(r);
1529
+ n.borderTop && (n.minRank = e.node(n.borderTop).rank, n.maxRank = e.node(n.borderBottom).rank, t = Math.max(t, n.maxRank));
1530
+ }), e.graph().maxRank = t;
1531
+ }
1532
+ function ki(e) {
1533
+ e.nodes().forEach((t) => {
1534
+ let r = e.node(t);
1535
+ if (r.dummy === "edge-proxy") {
1536
+ let n = r;
1537
+ e.edge(n.e).labelRank = r.rank, e.removeNode(t);
1538
+ }
1539
+ });
1540
+ }
1541
+ function xi(e) {
1542
+ let t = Number.POSITIVE_INFINITY, r = 0, n = Number.POSITIVE_INFINITY, o = 0, i = e.graph(), s = i.marginx || 0, l = i.marginy || 0;
1543
+ function d(a) {
1544
+ let c = a.x, u = a.y, h = a.width, g = a.height;
1545
+ t = Math.min(t, c - h / 2), r = Math.max(r, c + h / 2), n = Math.min(n, u - g / 2), o = Math.max(o, u + g / 2);
1546
+ }
1547
+ e.nodes().forEach((a) => d(e.node(a))), e.edges().forEach((a) => {
1548
+ let c = e.edge(a);
1549
+ Object.hasOwn(c, "x") && d(c);
1550
+ }), t -= s, n -= l, e.nodes().forEach((a) => {
1551
+ let c = e.node(a);
1552
+ c.x -= t, c.y -= n;
1553
+ }), e.edges().forEach((a) => {
1554
+ let c = e.edge(a);
1555
+ c.points.forEach((u) => {
1556
+ u.x -= t, u.y -= n;
1557
+ }), Object.hasOwn(c, "x") && (c.x -= t), Object.hasOwn(c, "y") && (c.y -= n);
1558
+ }), i.width = r - t + s, i.height = o - n + l;
1559
+ }
1560
+ function _i(e) {
1561
+ e.edges().forEach((t) => {
1562
+ let r = e.edge(t), n = e.node(t.v), o = e.node(t.w), i, s;
1563
+ r.points ? (i = r.points[0], s = r.points[r.points.length - 1]) : (r.points = [], i = o, s = n), r.points.unshift(Et(n, i)), r.points.push(Et(o, s));
1564
+ });
1565
+ }
1566
+ function Ti(e) {
1567
+ e.edges().forEach((t) => {
1568
+ let r = e.edge(t);
1569
+ if (Object.hasOwn(r, "x")) switch ((r.labelpos === "l" || r.labelpos === "r") && (r.width -= r.labeloffset), r.labelpos) {
1570
+ case "l":
1571
+ r.x -= r.width / 2 + r.labeloffset;
1572
+ break;
1573
+ case "r":
1574
+ r.x += r.width / 2 + r.labeloffset;
1575
+ break;
1576
+ }
1577
+ });
1578
+ }
1579
+ function Ni(e) {
1580
+ e.edges().forEach((t) => {
1581
+ let r = e.edge(t);
1582
+ r.reversed && r.points.reverse();
1583
+ });
1584
+ }
1585
+ function Ci(e) {
1586
+ e.nodes().forEach((t) => {
1587
+ if (e.children(t).length) {
1588
+ let r = e.node(t), n = e.node(r.borderTop), o = e.node(r.borderBottom), i = e.node(r.borderLeft[r.borderLeft.length - 1]), s = e.node(r.borderRight[r.borderRight.length - 1]);
1589
+ r.width = Math.abs(s.x - i.x), r.height = Math.abs(o.y - n.y), r.x = i.x + r.width / 2, r.y = n.y + r.height / 2;
1590
+ }
1591
+ }), e.nodes().forEach((t) => {
1592
+ e.node(t).dummy === "border" && e.removeNode(t);
1593
+ });
1594
+ }
1595
+ function Si(e) {
1596
+ e.edges().forEach((t) => {
1597
+ if (t.v === t.w) {
1598
+ let r = e.node(t.v);
1599
+ r.selfEdges || (r.selfEdges = []), r.selfEdges.push({ e: t, label: e.edge(t) }), e.removeEdge(t);
1600
+ }
1601
+ });
1602
+ }
1603
+ function Ii(e) {
1604
+ ye(e).forEach((t) => {
1605
+ let r = 0;
1606
+ t.forEach((n, o) => {
1607
+ let i = e.node(n);
1608
+ i.order = o + r, (i.selfEdges || []).forEach((s) => {
1609
+ fe(e, "selfedge", { width: s.label.width, height: s.label.height, rank: i.rank, order: o + ++r, e: s.e, label: s.label }, "_se");
1610
+ }), delete i.selfEdges;
1611
+ });
1612
+ });
1613
+ }
1614
+ function Oi(e) {
1615
+ e.nodes().forEach((t) => {
1616
+ let r = e.node(t);
1617
+ if (r.dummy === "selfedge") {
1618
+ let n = r, o = e.node(n.e.v), i = o.x + o.width / 2, s = o.y, l = r.x - i, d = o.height / 2;
1619
+ e.setEdge(n.e, n.label), e.removeNode(t), n.label.points = [{ x: i + 2 * l / 3, y: s - d }, { x: i + 5 * l / 6, y: s - d }, { x: i + l, y: s }, { x: i + 5 * l / 6, y: s + d }, { x: i + 2 * l / 3, y: s + d }], n.label.x = r.x, n.label.y = r.y;
1620
+ }
1621
+ });
1622
+ }
1623
+ function Le(e, t) {
1624
+ return Ne(Te(e, t), Number);
1625
+ }
1626
+ function Ae(e) {
1627
+ let t = {};
1628
+ return e && Object.entries(e).forEach(([r, n]) => {
1629
+ typeof r == "string" && (r = r.toLowerCase()), t[r] = n;
1630
+ }), t;
1631
+ }
1632
+ function Mi(e) {
1633
+ let t = ye(e), r = new G({ compound: !0, multigraph: !0 }).setGraph({});
1634
+ return e.nodes().forEach((n) => {
1635
+ r.setNode(n, { label: n }), r.setParent(n, "layer" + e.node(n).rank);
1636
+ }), e.edges().forEach((n) => r.setEdge(n.v, n.w, {}, n.name)), t.forEach((n, o) => {
1637
+ let i = "layer" + o;
1638
+ r.setNode(i, { rank: "same" }), n.reduce((s, l) => (r.setEdge(s, l, { style: "invis" }), l));
1639
+ }), r;
1640
+ }
1641
+ var ji = { graphlib: Yt, version: Gn, layout: ai, debug: Mi, util: { time: rr, notime: nr } }, jt = ji;
1642
+ /*! For license information please see dagre.esm.js.LEGAL.txt */
1643
+ const Fi = (e) => {
1644
+ const t = [];
1645
+ return e.nodeInternals.forEach((r, n) => t.push(`${n}:${r.height ?? 0}`)), t.join(",");
1646
+ }, zi = ({ onHeightsReady: e, nodeCount: t }) => {
1647
+ const r = Tr(Fi), n = pt("");
1648
+ pt(0);
1649
+ const { fitView: o } = Nr();
1650
+ return ie(() => {
1651
+ if (!r || r === n.current) return;
1652
+ const i = {};
1653
+ for (const s of r.split(",")) {
1654
+ const [l, d] = s.split(":"), a = Number(d);
1655
+ l && a > 0 && (i[l] = a);
1656
+ }
1657
+ Object.keys(i).length !== 0 && (n.current = r, e(i));
1658
+ }, [r]), null;
1659
+ }, Se = ({ isOpen: e, onClose: t, title: r, icon: n, children: o, footer: i, width: s = 600 }) => {
1660
+ const [l, d] = j(!1), a = () => d((h) => !h), c = () => /* @__PURE__ */ m(te, { sx: { display: "flex", alignItems: "center", p: 2, pt: 3, borderBottom: "1px solid #e0e0e0", mb: 0, flexShrink: 0 }, children: [
1661
+ n && /* @__PURE__ */ f(te, { sx: { mr: 1.5, display: "flex", alignItems: "center", fontSize: "1.25rem", color: "#1DBF60" }, children: n }),
1662
+ /* @__PURE__ */ f(Pr, { variant: "h6", component: "div", sx: { flexGrow: 1, fontSize: "0.875rem", fontWeight: 600 }, children: r }),
1663
+ /* @__PURE__ */ f(bt, { onClick: a, size: "small", sx: { mr: 1 }, title: l ? "Collapse" : "Expand", "data-testid": "expand-collapse-base-drawer-btn", children: l ? /* @__PURE__ */ f(rn, {}) : /* @__PURE__ */ f(nn, {}) }),
1664
+ /* @__PURE__ */ f(bt, { onClick: t, size: "small", "data-testid": "close-drawer-button", children: /* @__PURE__ */ f(Br, {}) })
1665
+ ] }), u = () => i ? /* @__PURE__ */ f(te, { sx: { flexShrink: 0, p: 2, borderTop: "1px solid #e0e0e0", display: "flex", justifyContent: "flex-end", gap: 2 }, children: i }) : null;
1666
+ return l ? /* @__PURE__ */ m(Lr, { open: e, onClose: t, maxWidth: !1, fullWidth: !0, PaperProps: { sx: { display: "flex", flexDirection: "column", height: "80vh", boxShadow: 24, width: "750px", maxWidth: "100%" } }, children: [
1667
+ /* @__PURE__ */ f(c, {}),
1668
+ /* @__PURE__ */ f(te, { sx: { flexGrow: 1, overflowY: "auto", p: 0 }, children: o }),
1669
+ /* @__PURE__ */ f(u, {})
1670
+ ] }) : /* @__PURE__ */ m(
1671
+ Ar,
1672
+ {
1673
+ anchor: "right",
1674
+ open: e,
1675
+ onClose: t,
1676
+ variant: "persistent",
1677
+ sx: { zIndex: 900 },
1678
+ ModalProps: { keepMounted: !1 },
1679
+ PaperProps: {
1680
+ sx: {
1681
+ width: s,
1682
+ position: "fixed",
1683
+ top: "64px",
1684
+ height: "calc(100% - 74px)",
1685
+ right: "10px",
1686
+ borderRadius: "8px",
1687
+ border: "1px solid #bdbdbd",
1688
+ boxShadow: "none",
1689
+ zIndex: 900,
1690
+ display: "flex",
1691
+ flexDirection: "column"
1692
+ }
1693
+ },
1694
+ children: [
1695
+ /* @__PURE__ */ f(c, {}),
1696
+ /* @__PURE__ */ f(te, { sx: { flexGrow: 1, overflowY: "auto", p: 0 }, children: o }),
1697
+ /* @__PURE__ */ f(u, {})
1698
+ ]
1699
+ }
1700
+ );
1701
+ }, Ri = ({ open: e, templates: t, messages: r, onSelect: n, onClose: o }) => /* @__PURE__ */ f(Se, { isOpen: e, onClose: o, title: r.addTriggerTitle, icon: /* @__PURE__ */ f(tn, {}), width: 500, children: /* @__PURE__ */ m(te, { sx: { p: 2 }, children: [
1702
+ /* @__PURE__ */ f("p", { className: "ff-text-muted ff-mb-3", style: { fontSize: 13 }, children: r.chooseTrigger }),
1703
+ /* @__PURE__ */ m("div", { className: "ff-d-flex ff-flex-column ff-gap-2", children: [
1704
+ t.map((i) => /* @__PURE__ */ m(
1705
+ "div",
1706
+ {
1707
+ className: "ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",
1708
+ style: { cursor: "pointer", transition: "background 0.15s" },
1709
+ onClick: () => n(i),
1710
+ role: "button",
1711
+ tabIndex: 0,
1712
+ onKeyDown: (s) => {
1713
+ s.key === "Enter" && n(i);
1714
+ },
1715
+ onMouseEnter: (s) => {
1716
+ s.currentTarget.style.background = "#f5f5f5";
1717
+ },
1718
+ onMouseLeave: (s) => {
1719
+ s.currentTarget.style.background = "";
1720
+ },
1721
+ children: [
1722
+ /* @__PURE__ */ f("div", { style: { color: i.triggerCategory === "scheduler" ? "#1976d2" : "#f57c00", marginTop: 2, flexShrink: 0 }, children: i.triggerCategory === "scheduler" ? /* @__PURE__ */ f(Wr, { size: 18 }) : /* @__PURE__ */ f(Gr, { size: 18 }) }),
1723
+ /* @__PURE__ */ m("div", { children: [
1724
+ /* @__PURE__ */ f("div", { style: { fontSize: 14, fontWeight: 600, color: "#212121" }, children: i.label }),
1725
+ i.description && /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#757575", marginTop: 2 }, children: i.description })
1726
+ ] })
1727
+ ]
1728
+ },
1729
+ i.triggerKey
1730
+ )),
1731
+ t.length === 0 && /* @__PURE__ */ f("p", { className: "ff-text-muted ff-text-center", style: { fontSize: 13 }, children: r.noTriggers })
1732
+ ] })
1733
+ ] }) }), Pe = {
1734
+ cursor: "pointer",
1735
+ transition: "background 0.15s"
1736
+ }, Be = "ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3", Di = ({ open: e, availableDescriptors: t, messages: r, onSelect: n, onClose: o }) => {
1737
+ const { apps: i, ungrouped: s } = W(() => {
1738
+ const u = /* @__PURE__ */ new Map(), h = [];
1739
+ for (const g of t)
1740
+ if (g.app) {
1741
+ const b = u.get(g.app.key);
1742
+ b ? b.descriptors.push(g) : u.set(g.app.key, {
1743
+ key: g.app.key,
1744
+ label: g.app.label,
1745
+ icon: g.app.icon,
1746
+ description: g.app.description,
1747
+ descriptors: [g]
1748
+ });
1749
+ } else
1750
+ h.push(g);
1751
+ return { apps: [...u.values()], ungrouped: h };
1752
+ }, [t]), [l, d] = j(null), a = l ? i.find((u) => u.key === l) ?? null : null;
1753
+ ie(() => {
1754
+ e || d(null);
1755
+ }, [e]), ie(() => {
1756
+ d(null);
1757
+ }, [t]);
1758
+ const c = !a;
1759
+ return /* @__PURE__ */ f(
1760
+ Se,
1761
+ {
1762
+ isOpen: e,
1763
+ onClose: o,
1764
+ title: c ? r.addStepTitle : a.label,
1765
+ icon: c ? /* @__PURE__ */ f(Yr, {}) : a.icon ?? /* @__PURE__ */ f(Kr, {}),
1766
+ width: 500,
1767
+ children: /* @__PURE__ */ m(te, { sx: { p: 2 }, children: [
1768
+ !c && /* @__PURE__ */ m(
1769
+ "div",
1770
+ {
1771
+ role: "button",
1772
+ tabIndex: 0,
1773
+ onClick: () => d(null),
1774
+ onKeyDown: (u) => {
1775
+ u.key === "Enter" && d(null);
1776
+ },
1777
+ className: "ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",
1778
+ style: { cursor: "pointer", color: "#0066cc", fontSize: 13, fontWeight: 500, width: "fit-content" },
1779
+ children: [
1780
+ /* @__PURE__ */ f($r, { size: 16 }),
1781
+ /* @__PURE__ */ f("span", { children: r.addStepTitle })
1782
+ ]
1783
+ }
1784
+ ),
1785
+ /* @__PURE__ */ f("p", { className: "ff-text-muted ff-mb-3", style: { fontSize: 13 }, children: c ? r.chooseAction : `Pick an action from ${a.label}` }),
1786
+ /* @__PURE__ */ f("div", { className: "ff-d-flex ff-flex-column ff-gap-2", children: c ? /* @__PURE__ */ m(Lt, { children: [
1787
+ i.map((u) => /* @__PURE__ */ m(
1788
+ "div",
1789
+ {
1790
+ className: Be,
1791
+ style: Pe,
1792
+ onClick: () => d(u.key),
1793
+ role: "button",
1794
+ tabIndex: 0,
1795
+ onKeyDown: (h) => {
1796
+ h.key === "Enter" && d(u.key);
1797
+ },
1798
+ onMouseEnter: (h) => {
1799
+ h.currentTarget.style.background = "#f5f5f5";
1800
+ },
1801
+ onMouseLeave: (h) => {
1802
+ h.currentTarget.style.background = "";
1803
+ },
1804
+ children: [
1805
+ u.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0 }, children: u.icon }),
1806
+ /* @__PURE__ */ m("div", { style: { flex: 1, minWidth: 0 }, children: [
1807
+ /* @__PURE__ */ f("div", { style: { fontSize: 14, fontWeight: 600, color: "#212121" }, children: u.label }),
1808
+ /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#757575", marginTop: 2 }, children: u.description ?? `${u.descriptors.length} action${u.descriptors.length === 1 ? "" : "s"}` })
1809
+ ] }),
1810
+ /* @__PURE__ */ f(At, { size: 18, color: "#9e9e9e" })
1811
+ ]
1812
+ },
1813
+ `app-${u.key}`
1814
+ )),
1815
+ s.map((u) => /* @__PURE__ */ m(
1816
+ "div",
1817
+ {
1818
+ className: Be,
1819
+ style: Pe,
1820
+ onClick: () => n(u),
1821
+ role: "button",
1822
+ tabIndex: 0,
1823
+ onKeyDown: (h) => {
1824
+ h.key === "Enter" && n(u);
1825
+ },
1826
+ onMouseEnter: (h) => {
1827
+ h.currentTarget.style.background = "#f5f5f5";
1828
+ },
1829
+ onMouseLeave: (h) => {
1830
+ h.currentTarget.style.background = "";
1831
+ },
1832
+ children: [
1833
+ u.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0 }, children: u.icon }),
1834
+ /* @__PURE__ */ f("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: u.label })
1835
+ ]
1836
+ },
1837
+ u.type
1838
+ )),
1839
+ i.length === 0 && s.length === 0 && /* @__PURE__ */ f("p", { className: "ff-text-muted ff-text-center", style: { fontSize: 13 }, children: r.noActions })
1840
+ ] }) : (
1841
+ /* Stage 2 — actions for the selected app */
1842
+ a.descriptors.map((u) => /* @__PURE__ */ m(
1843
+ "div",
1844
+ {
1845
+ className: Be,
1846
+ style: Pe,
1847
+ onClick: () => n(u),
1848
+ role: "button",
1849
+ tabIndex: 0,
1850
+ onKeyDown: (h) => {
1851
+ h.key === "Enter" && n(u);
1852
+ },
1853
+ onMouseEnter: (h) => {
1854
+ h.currentTarget.style.background = "#f5f5f5";
1855
+ },
1856
+ onMouseLeave: (h) => {
1857
+ h.currentTarget.style.background = "";
1858
+ },
1859
+ children: [
1860
+ u.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0 }, children: u.icon }),
1861
+ /* @__PURE__ */ f("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: u.label })
1862
+ ]
1863
+ },
1864
+ u.type
1865
+ ))
1866
+ ) })
1867
+ ] })
1868
+ }
1869
+ );
1870
+ }, Ft = "_conditionConfig", Li = ({ open: e, nodeId: t, descriptor: r, initialValues: n, messages: o, onSave: i, onClose: s }) => {
1871
+ const [l, d] = j([]), [a, c] = j(!1), [u, h] = j(null), [g, b] = j({});
1872
+ ie(() => {
1873
+ b((n == null ? void 0 : n[Ft]) ?? {});
1874
+ }, [n, t]), ie(() => {
1875
+ let N = !1;
1876
+ if (h(null), !r || !t) {
1877
+ d([]), c(!1);
1878
+ return;
1879
+ }
1880
+ const O = r.formSchema;
1881
+ return typeof O == "function" ? (c(!0), O(t).then((M) => {
1882
+ N || (d(M), c(!1));
1883
+ }).catch((M) => {
1884
+ N || (d([]), h(M instanceof Error ? M.message : "Unable to load configuration."), c(!1));
1885
+ })) : (d(O), c(!1)), () => {
1886
+ N = !0;
1887
+ };
1888
+ }, [r, t]);
1889
+ const y = t ? `node-config-form-${t}` : "node-config-form", p = !a && !u && l.length > 0, v = p ? /* @__PURE__ */ m(Lt, { children: [
1890
+ /* @__PURE__ */ f(yt, { type: "button", variant: "outlined", size: "small", onClick: s, children: o.cancel }),
1891
+ /* @__PURE__ */ f(yt, { type: "submit", form: y, variant: "contained", size: "small", children: o.save })
1892
+ ] }) : null;
1893
+ return /* @__PURE__ */ f(
1894
+ Se,
1895
+ {
1896
+ isOpen: e,
1897
+ onClose: s,
1898
+ title: (r == null ? void 0 : r.label) ?? o.configureStep,
1899
+ icon: r == null ? void 0 : r.icon,
1900
+ width: 500,
1901
+ footer: v,
1902
+ children: /* @__PURE__ */ m(te, { sx: { p: 2 }, children: [
1903
+ a && /* @__PURE__ */ f("p", { className: "ff-text-muted", style: { fontSize: 13 }, children: o.loadingConfiguration }),
1904
+ !a && u && /* @__PURE__ */ f("p", { style: { fontSize: 13, color: "#d32f2f" }, children: u }),
1905
+ !a && !u && l.length === 0 && /* @__PURE__ */ f("p", { className: "ff-text-muted", style: { fontSize: 13 }, children: o.noConfigurationNeeded }),
1906
+ p && /* @__PURE__ */ f(
1907
+ on,
1908
+ {
1909
+ schema: { layout: "flat", fields: l },
1910
+ initialValues: n ?? {},
1911
+ formId: y,
1912
+ conditionConfig: g,
1913
+ onConditionConfigChange: b,
1914
+ onSubmit: (N) => {
1915
+ if (!t) return;
1916
+ const O = Object.keys(g).length > 0;
1917
+ i(t, { ...N, [Ft]: O ? g : void 0 }), s();
1918
+ }
1919
+ }
1920
+ )
1921
+ ] })
1922
+ }
1923
+ );
1924
+ }, Ai = ({
1925
+ isOpen: e,
1926
+ onClose: t,
1927
+ workflowId: r,
1928
+ workflowLabel: n,
1929
+ onFetchWorkflow: o
1930
+ }) => {
1931
+ const [i, s] = j({ status: "idle" });
1932
+ return ie(() => {
1933
+ if (!e || !r) {
1934
+ s({ status: "idle" });
1935
+ return;
1936
+ }
1937
+ s({ status: "loading" }), o(r).then((l) => s({ status: "loaded", state: l })).catch((l) => s({ status: "error", message: (l == null ? void 0 : l.message) ?? "Failed to load workflow" }));
1938
+ }, [e, r, o]), /* @__PURE__ */ f(
1939
+ Se,
1940
+ {
1941
+ isOpen: e,
1942
+ onClose: t,
1943
+ title: n ? `Preview: ${n}` : "Sub-Workflow Preview",
1944
+ icon: /* @__PURE__ */ f(Vr, { size: 18, color: "#00695c" }),
1945
+ width: 700,
1946
+ children: /* @__PURE__ */ m("div", { style: { height: "100%", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", padding: 24 }, children: [
1947
+ i.status === "idle" && /* @__PURE__ */ f("span", { style: { color: "#9e9e9e", fontSize: 14 }, children: "Select a workflow to preview" }),
1948
+ i.status === "loading" && /* @__PURE__ */ m("div", { style: { textAlign: "center", color: "#9e9e9e" }, children: [
1949
+ /* @__PURE__ */ f("div", { style: { width: 32, height: 32, borderRadius: "50%", border: "3px solid #e0e0e0", borderTopColor: "#00897b", animation: "spin 0.8s linear infinite", margin: "0 auto 12px" } }),
1950
+ /* @__PURE__ */ f("span", { style: { fontSize: 14 }, children: "Loading workflow…" }),
1951
+ /* @__PURE__ */ f("style", { children: "@keyframes spin { to { transform: rotate(360deg); } }" })
1952
+ ] }),
1953
+ i.status === "error" && /* @__PURE__ */ m("div", { style: { textAlign: "center", color: "#c62828" }, children: [
1954
+ /* @__PURE__ */ f(Ur, { size: 32, style: { marginBottom: 8 } }),
1955
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 14 }, children: i.message })
1956
+ ] }),
1957
+ i.status === "loaded" && /* @__PURE__ */ f("div", { style: { width: "100%", flex: 1 }, children: /* @__PURE__ */ f(Pi, { state: i.state }) })
1958
+ ] })
1959
+ }
1960
+ );
1961
+ }, Pi = ({ state: e }) => {
1962
+ const [t, r] = j(null), [n, o] = j(null);
1963
+ return ie(() => {
1964
+ Promise.all([
1965
+ Promise.resolve().then(() => Ki).then((i) => i.default),
1966
+ import("./nodeRegistry.js").then((i) => i.nodeTypeRegistry),
1967
+ import("./templateRegistry.js").then((i) => i.templateRegistry)
1968
+ ]).then(([i, s, l]) => {
1969
+ r(() => i), o({ nodeTypeRegistry: s, templateRegistry: l });
1970
+ });
1971
+ }, []), !t || !n ? /* @__PURE__ */ f("div", { style: { color: "#9e9e9e", fontSize: 13, textAlign: "center" }, children: "Loading canvas…" }) : /* @__PURE__ */ f("div", { style: { width: "100%", height: 480, border: "1px solid #e0e0e0", borderRadius: 8, overflow: "hidden" }, children: /* @__PURE__ */ f(
1972
+ t,
1973
+ {
1974
+ nodeRegistry: n.nodeTypeRegistry,
1975
+ templateRegistry: n.templateRegistry,
1976
+ initialValue: e,
1977
+ readOnly: !0
1978
+ }
1979
+ ) });
1980
+ }, be = 350, $e = 70, Ye = 60, Ke = {
1981
+ startNode: 40,
1982
+ endNode: 40,
1983
+ addTriggerNode: 56,
1984
+ triggerNode: 110,
1985
+ actionNode: 90,
1986
+ filterNode: 90,
1987
+ approvalNode: 90,
1988
+ delayNode: 80,
1989
+ notificationNode: 80
1990
+ }, Bi = {
1991
+ plusEdge: Rr,
1992
+ labelPlusEdge: zr,
1993
+ plainEdge: Fr,
1994
+ edgeWithPlusLabel: jr,
1995
+ gatewayBranchEdge: Mr
1996
+ };
1997
+ function zt() {
1998
+ return [
1999
+ { id: "start", kind: "start", reactFlowType: "startNode" },
2000
+ { id: "addTrigger", kind: "addTrigger", reactFlowType: "addTriggerNode" },
2001
+ { id: "end", kind: "end", reactFlowType: "endNode" }
2002
+ ];
2003
+ }
2004
+ function Wi(e, t, r, n = "TB") {
2005
+ const o = new jt.graphlib.Graph();
2006
+ return o.setGraph({ rankdir: n, ranksep: 70, nodesep: 50 }), o.setDefaultEdgeLabel(() => ({})), e.forEach((i) => {
2007
+ const s = r[i.id] ?? { width: be, height: Ke[i.type ?? ""] ?? 80 };
2008
+ o.setNode(i.id, { width: s.width, height: s.height });
2009
+ }), t.forEach((i) => o.setEdge(i.source, i.target)), jt.layout(o), e.map((i) => {
2010
+ var a, c;
2011
+ const s = o.node(i.id), l = ((a = r[i.id]) == null ? void 0 : a.width) ?? be, d = ((c = r[i.id]) == null ? void 0 : c.height) ?? Ke[i.type ?? ""] ?? 80;
2012
+ return { ...i, position: { x: s.x - l / 2, y: s.y - d / 2 } };
2013
+ });
2014
+ }
2015
+ const oe = (e) => e === "filter" || e === "approval";
2016
+ function Gi(e, t, r, n) {
2017
+ const s = $e, l = 30, d = 30, a = {}, c = {}, u = /* @__PURE__ */ new Map();
2018
+ for (const p of e) u.set(p.id, p);
2019
+ for (const p of Object.values(t))
2020
+ for (const v of Object.values(p))
2021
+ for (const N of v) u.set(N.id, N);
2022
+ const h = (p, v, N) => {
2023
+ const O = n[p] ?? { width: be, height: 80 };
2024
+ return a[p] = { x: v - O.width / 2, y: N }, N + O.height;
2025
+ }, g = (p, v, N) => {
2026
+ let O = N;
2027
+ for (const M of p)
2028
+ O = h(M.id, v, O) + s, oe(M.kind) && t[M.id] && (O = b(M.id, v, O));
2029
+ return O;
2030
+ }, b = (p, v, N) => {
2031
+ const O = v + 180, M = t[p], F = Object.keys(M), B = u.get(p), re = (B == null ? void 0 : B.branchLabels) ?? { pass: "Pass", fail: "Fail" }, he = a[p], z = n[p] ?? { height: 80 }, me = he.y + z.height, we = [];
2032
+ let U = N;
2033
+ return F.forEach((le, X) => {
2034
+ const R = M[le], J = U;
2035
+ we.push({
2036
+ y: J - me,
2037
+ label: re[le] ?? le,
2038
+ isPass: X === 0
2039
+ }), U = g(R, O, U + d), X < F.length - 1 && (U += l);
2040
+ }), c[p] = {
2041
+ branches: we,
2042
+ height: U - me,
2043
+ indent: 180
2044
+ }, U;
2045
+ };
2046
+ let y = Ye;
2047
+ for (const p of e)
2048
+ y = h(p.id, 400, y) + s, oe(p.kind) && t[p.id] && (y = b(p.id, 400, y));
2049
+ return {
2050
+ nodes: r.map((p) => a[p.id] ? { ...p, position: a[p.id] } : p),
2051
+ railSpecs: c
2052
+ };
2053
+ }
2054
+ function Rt(e) {
2055
+ return {
2056
+ id: e.id,
2057
+ type: e.reactFlowType,
2058
+ position: { x: 0, y: 0 },
2059
+ data: { ...e.nodeData, ...e.formData, descriptorType: e.descriptorType },
2060
+ draggable: !1,
2061
+ selectable: !1
2062
+ };
2063
+ }
2064
+ function $i(e, t, r, n, o) {
2065
+ return {
2066
+ id: `e-${e.id}-${t.id}`,
2067
+ source: e.id,
2068
+ target: t.id,
2069
+ type: "plusEdge",
2070
+ style: { stroke: r },
2071
+ data: {
2072
+ onAddStepClick: n,
2073
+ referenceNodeType: e.reactFlowType,
2074
+ ...o ?? {}
2075
+ }
2076
+ };
2077
+ }
2078
+ function Yi(e, t, r, n, o = {}, i = "TB", s = "horizontal") {
2079
+ const l = o.edgeColor ?? "#b0bec5", d = [], a = [], c = (b, y) => {
2080
+ const p = t[b];
2081
+ if (!p) return;
2082
+ const N = y ?? { pass: "Pass", fail: "Fail" }, O = Object.keys(p), M = (F, B, re, he) => {
2083
+ if (F.length !== 0) {
2084
+ F.forEach((z) => d.push(Rt(z))), a.push({
2085
+ id: `e-${b}-${B}-start`,
2086
+ source: b,
2087
+ target: F[0].id,
2088
+ type: "gatewayBranchEdge",
2089
+ style: { stroke: l },
2090
+ data: { branch: B, filterId: b, label: re, isFirst: he === 0, onAddStepClick: r, verticalRouting: s === "vertical" }
2091
+ });
2092
+ for (let z = 1; z < F.length; z++)
2093
+ oe(F[z - 1].kind) || a.push($i(F[z - 1], F[z], l, r, { filterId: b, branch: B }));
2094
+ for (const z of F)
2095
+ oe(z.kind) && t[z.id] && c(z.id, z.branchLabels);
2096
+ }
2097
+ };
2098
+ O.forEach((F, B) => {
2099
+ M(p[F], F, N[F] ?? F, B);
2100
+ });
2101
+ };
2102
+ for (let b = 0; b < e.length; b++) {
2103
+ const y = e[b];
2104
+ if (d.push(Rt(y)), b > 0) {
2105
+ const p = e[b - 1], v = p.kind === "start" || p.kind === "addTrigger";
2106
+ if (p.kind === "filter" || p.kind === "approval") continue;
2107
+ a.push({
2108
+ id: `e-${p.id}-${y.id}`,
2109
+ source: p.id,
2110
+ target: y.id,
2111
+ type: v ? "plainEdge" : "plusEdge",
2112
+ style: { stroke: l },
2113
+ data: v ? {} : {
2114
+ onAddStepClick: r,
2115
+ referenceNodeType: p.reactFlowType
2116
+ }
2117
+ });
2118
+ }
2119
+ (y.kind === "filter" || y.kind === "approval") && t[y.id] && c(y.id, y.branchLabels);
2120
+ }
2121
+ const u = {};
2122
+ if (d.forEach((b) => {
2123
+ u[b.id] = {
2124
+ width: be,
2125
+ height: n[b.id] ?? Ke[b.type ?? ""] ?? 80
2126
+ };
2127
+ }), !(Object.keys(t).length > 0)) {
2128
+ if (i === "LR") {
2129
+ let N = Ye;
2130
+ return { nodes: d.map((M) => {
2131
+ const F = u[M.id].width, B = u[M.id].height, re = { ...M, position: { x: N, y: 300 - B / 2 } };
2132
+ return N += F + $e, re;
2133
+ }), edges: a };
2134
+ }
2135
+ const b = 400;
2136
+ let y = Ye;
2137
+ return { nodes: d.map((v) => {
2138
+ const N = u[v.id].height, O = { ...v, position: { x: b - be / 2, y } };
2139
+ return y += N + $e, O;
2140
+ }), edges: a };
2141
+ }
2142
+ if (s === "vertical") {
2143
+ const { nodes: b, railSpecs: y } = Gi(e, t, d, u);
2144
+ return { nodes: b.map(
2145
+ (v) => y[v.id] ? { ...v, data: { ...v.data, _branchRail: y[v.id] } } : v
2146
+ ), edges: a };
2147
+ }
2148
+ return { nodes: Wi(d, a, u, i), edges: a };
2149
+ }
2150
+ const Dt = ({
2151
+ nodeRegistry: e,
2152
+ templateRegistry: t,
2153
+ initialValue: r,
2154
+ nodeTypes: n,
2155
+ edgeTypes: o,
2156
+ onSave: i,
2157
+ readOnly: s = !1,
2158
+ theme: l = {},
2159
+ messages: d,
2160
+ canvasOptions: a = {},
2161
+ renderTriggerSelector: c,
2162
+ renderNodePicker: u,
2163
+ renderNodeConfig: h,
2164
+ onNodeClick: g,
2165
+ maxNodes: b,
2166
+ layoutDirection: y = "TB",
2167
+ executionRecord: p,
2168
+ onFetchWorkflow: v
2169
+ }) => {
2170
+ const {
2171
+ fitView: N = !0,
2172
+ fitViewPadding: O = 0.3,
2173
+ showControls: M = !0,
2174
+ showMiniMap: F = !1,
2175
+ panOnScroll: B = !0,
2176
+ zoomOnScroll: re = !1,
2177
+ minZoom: he = 0.25,
2178
+ maxZoom: z = 2,
2179
+ snapToGrid: me = !1,
2180
+ snapGrid: we = [15, 15],
2181
+ branchLayout: U = "horizontal",
2182
+ nodeBody: le = "full"
2183
+ } = a, X = W(() => sn(d), [d]), [R, J] = j(() => (r == null ? void 0 : r.slots) ?? zt()), [V, Z] = j(() => (r == null ? void 0 : r.branches) ?? {}), [ae, $] = j(null), [Ie, Ze] = j(null), [de, ve] = j(null), [Oe, Qe] = j(null), [Ee, et] = j(null), [Q, tt] = j(() => {
2184
+ const w = r == null ? void 0 : r.slots.find((k) => k.kind === "triggerFixed"), E = w != null && w.id.startsWith("trigger-") ? w.id.slice(8) : void 0;
2185
+ return E ? t.lookup(E) ?? null : null;
2186
+ }), [rt, br] = j({}), yr = Y((w) => {
2187
+ br(w);
2188
+ }, []), mr = W(() => ({ ...Or, ...n }), [n]), wr = W(() => ({ ...Bi, ...o }), [o]), vr = W(() => {
2189
+ const w = R.filter((k) => k.kind === "userTask").length, E = Object.values(V).flatMap((k) => Object.values(k).flat()).filter((k) => k.kind === "userTask").length;
2190
+ return w + E;
2191
+ }, [R, V]), nt = b ?? (Q == null ? void 0 : Q.maxTasks), ot = nt !== void 0 && vr >= nt, ne = Y((w) => {
2192
+ const E = R.find((k) => k.id === w);
2193
+ if (E) return E;
2194
+ for (const k of Object.values(V)) {
2195
+ const C = Object.values(k).flat().find((x) => x.id === w);
2196
+ if (C) return C;
2197
+ }
2198
+ return null;
2199
+ }, [R, V]), Me = Y((w) => {
2200
+ s || (Ze(w), $("nodeConfig"));
2201
+ }, [s]), it = Y((w) => {
2202
+ if (!s) {
2203
+ if (R.some((E) => E.id === w)) {
2204
+ const E = R.find((k) => k.id === w);
2205
+ if ((E == null ? void 0 : E.kind) === "triggerFixed") {
2206
+ J(zt()), Z({}), tt(null);
2207
+ return;
2208
+ }
2209
+ J((k) => {
2210
+ const C = k.filter((x) => x.id !== w);
2211
+ return oe((E == null ? void 0 : E.kind) ?? "") && !C.some((x) => x.kind === "end") ? [...C, { id: "end", kind: "end", reactFlowType: "endNode" }] : C;
2212
+ }), Z((k) => {
2213
+ const C = { ...k }, x = (_) => {
2214
+ C[_] && (Object.values(C[_]).flat().filter((T) => oe(T.kind)).forEach((T) => x(T.id)), delete C[_]);
2215
+ };
2216
+ return x(w), C;
2217
+ });
2218
+ return;
2219
+ }
2220
+ Z((E) => {
2221
+ const k = (x, _) => {
2222
+ const T = [];
2223
+ for (const S of x)
2224
+ oe(S.kind) && _[S.id] && (T.push(S.id), Object.values(_[S.id]).forEach((I) => T.push(...k(I, _))));
2225
+ return T;
2226
+ }, C = { ...E };
2227
+ for (const x of Object.keys(C))
2228
+ for (const _ of Object.keys(C[x])) {
2229
+ const T = C[x][_], S = T.findIndex((A) => A.id === w);
2230
+ if (S === -1 || T[S].kind === "end") continue;
2231
+ const I = T[S];
2232
+ let D = T.filter((A) => A.id !== w);
2233
+ return I.kind === "filter" && ((I.id in C ? k([I], C) : []).forEach((L) => delete C[L]), delete C[I.id], D.some((L) => L.kind === "end") || (D = [...D, { id: `end-${x}-${_}`, kind: "end", reactFlowType: "endNode" }])), C[x] = { ...C[x], [_]: D }, C;
2234
+ }
2235
+ return C;
2236
+ });
2237
+ }
2238
+ }, [s, R]), je = Y(() => {
2239
+ s || $("triggerSelect");
2240
+ }, [s]), st = Y((w, E) => {
2241
+ s || ot || (ve(w), Qe(E.filterId && E.branch ? { filterId: E.filterId, branch: E.branch } : null), $("nodePicker"));
2242
+ }, [s, ot]), lt = Y((w) => {
2243
+ tt(w), $(null), Z({}), J([
2244
+ { id: "start", kind: "start", reactFlowType: "startNode" },
2245
+ {
2246
+ id: `trigger-${w.triggerKey}`,
2247
+ kind: "triggerFixed",
2248
+ reactFlowType: "triggerNode",
2249
+ nodeData: { label: w.label, source: w.source },
2250
+ deletable: !1
2251
+ },
2252
+ { id: "end", kind: "end", reactFlowType: "endNode" }
2253
+ ]);
2254
+ }, []), at = Y(() => {
2255
+ const w = e.list();
2256
+ return (Q != null && Q.availableTasks ? w.filter((k) => Q.availableTasks.includes(k.type)) : w).filter((k) => k.maxPerWorkflow === void 0 ? !0 : R.filter((x) => x.descriptorType === k.type).length + Object.values(V).flatMap((x) => Object.values(x).flat()).filter((x) => x.descriptorType === k.type).length < k.maxPerWorkflow);
2257
+ }, [e, Q, R, V]), dt = Y((w) => {
2258
+ if (!de) return;
2259
+ const E = `${w.type}-${Date.now()}`, k = w.reactFlowType === "filterNode" || w.reactFlowType === "approvalNode" || w.reactFlowType === "conditionBranchNode", C = w.branchLabels ?? { pass: "Pass", fail: "Fail" }, x = {
2260
+ id: E,
2261
+ kind: k ? w.reactFlowType === "approvalNode" ? "approval" : "filter" : "userTask",
2262
+ reactFlowType: w.reactFlowType,
2263
+ descriptorType: w.type,
2264
+ formData: {},
2265
+ nodeData: { title: w.label },
2266
+ deletable: !0,
2267
+ branchLabels: C
2268
+ };
2269
+ if (Oe) {
2270
+ const { filterId: _, branch: T } = Oe;
2271
+ Z((S) => {
2272
+ const I = [...S[_][T]];
2273
+ if (k) {
2274
+ const ee = I.filter((ce) => ce.kind !== "end"), gt = ee.findIndex((ce) => ce.id === de), xr = gt === -1 ? ee.length : gt + 1;
2275
+ return ee.splice(xr, 0, x), {
2276
+ ...S,
2277
+ [_]: { ...S[_], [T]: ee },
2278
+ [E]: Object.fromEntries(
2279
+ Object.keys(C).map((ce) => [ce, [{ id: `end-${E}-${ce}`, kind: "end", reactFlowType: "endNode" }]])
2280
+ )
2281
+ };
2282
+ }
2283
+ const D = I.findIndex((ee) => ee.id === de), A = I.findIndex((ee) => ee.kind === "end"), L = D === -1 ? A === -1 ? I.length : A : D + 1;
2284
+ return I.splice(L, 0, x), { ...S, [_]: { ...S[_], [T]: I } };
2285
+ });
2286
+ } else
2287
+ k ? (J((_) => {
2288
+ const T = _.findIndex((I) => I.id === de);
2289
+ return [..._.filter((I) => I.kind !== "end").slice(0, T + 1), x];
2290
+ }), Z((_) => ({
2291
+ ..._,
2292
+ [E]: Object.fromEntries(
2293
+ Object.keys(C).map((T) => [T, [{ id: `end-${E}-${T}`, kind: "end", reactFlowType: "endNode" }]])
2294
+ )
2295
+ }))) : J((_) => {
2296
+ const T = _.findIndex((S) => S.id === de);
2297
+ return T === -1 ? _ : [..._.slice(0, T + 1), x, ..._.slice(T + 1)];
2298
+ });
2299
+ ve(null), Qe(null), Ze(E), $("nodeConfig");
2300
+ }, [de, Oe]), ct = Y((w, E) => {
2301
+ const k = (x) => {
2302
+ const _ = ne(w);
2303
+ if ((_ == null ? void 0 : _.descriptorType) !== "conditionBranch") return x;
2304
+ const T = E.branchConfigs ?? [], S = T.map((L) => L.key).filter(Boolean);
2305
+ if (S.length === 0) return x;
2306
+ const I = x[w] ?? {}, D = {};
2307
+ S.forEach((L) => {
2308
+ D[L] = I[L] ?? [{ id: `end-${w}-${L}`, kind: "end", reactFlowType: "endNode" }];
2309
+ });
2310
+ const A = {};
2311
+ return T.forEach((L) => {
2312
+ L.key && (A[L.key] = L.label || L.key);
2313
+ }), { ...x, [w]: D };
2314
+ }, C = (x, _) => {
2315
+ if (x.descriptorType !== "conditionBranch") return { ...x, formData: _ };
2316
+ const T = _.branchConfigs ?? [], S = {};
2317
+ return T.forEach((I) => {
2318
+ I.key && (S[I.key] = I.label || I.key);
2319
+ }), { ...x, formData: _, branchLabels: S };
2320
+ };
2321
+ if (R.some((x) => x.id === w)) {
2322
+ Z((x) => {
2323
+ const _ = k(x);
2324
+ return J((T) => {
2325
+ const S = T.map((I) => I.id === w ? C(I, E) : I);
2326
+ return i == null || i({ slots: S, branches: _ }), S;
2327
+ }), _;
2328
+ });
2329
+ return;
2330
+ }
2331
+ Z((x) => {
2332
+ const T = { ...k(x) };
2333
+ for (const S of Object.keys(T)) {
2334
+ const I = (D) => D.map((A) => A.id === w ? C(A, E) : A);
2335
+ for (const D of Object.keys(T[S]))
2336
+ if (T[S][D].some((A) => A.id === w))
2337
+ return T[S] = { ...T[S], [D]: I(T[S][D]) }, i == null || i({ slots: R, branches: T }), T;
2338
+ }
2339
+ return T;
2340
+ });
2341
+ }, [R, V, ne, i]), H = W(() => ne(Ie ?? ""), [ne, Ie]), ut = W(() => H != null && H.descriptorType ? e.forType(H.descriptorType) ?? null : null, [H, e]), { nodes: ft, edges: Er } = W(
2342
+ () => Yi(R, V, s ? null : st, rt, l, y, U),
2343
+ [R, V, s, st, rt, l, y, U]
2344
+ ), ht = W(() => {
2345
+ const w = p ? new Map(p.steps.map((E) => [E.nodeId, E])) : null;
2346
+ return ft.map((E) => {
2347
+ let k = {};
2348
+ if (w) {
2349
+ const C = w.get(E.id);
2350
+ C && (k = { _executionStatus: C.status, _executionError: C.error });
2351
+ }
2352
+ return E.type === "subWorkflowNode" && v && (k.onPreview = (C) => {
2353
+ var _;
2354
+ const x = ne(E.id);
2355
+ et({ workflowId: C, workflowLabel: ((_ = x == null ? void 0 : x.formData) == null ? void 0 : _.workflowLabel) ?? void 0 });
2356
+ }), Object.keys(k).length > 0 ? { ...E, data: { ...E.data, ...k } } : E;
2357
+ });
2358
+ }, [ft, p, v, ne]), kr = W(() => ({ onEditNode: Me, onDeleteNode: it, onAddStep: () => {
2359
+ }, onClickAddTrigger: je, messages: X, nodeRegistry: e, nodeBody: le }), [Me, it, je, X, e, le]);
2360
+ return /* @__PURE__ */ f(Dr.Provider, { value: kr, children: /* @__PURE__ */ m(
2361
+ "div",
2362
+ {
2363
+ style: {
2364
+ width: "100%",
2365
+ height: "100%",
2366
+ position: "relative",
2367
+ // CSS variable consumed by edge SCSS for primary/hover color
2368
+ "--ff-primary": l.primaryColor ?? "#1dbf60",
2369
+ "--ff-edge-color": l.edgeColor ?? "#b0bec5",
2370
+ "--ff-text": l.textColor ?? "#212121",
2371
+ "--ff-muted": l.mutedTextColor ?? "#9ca3af",
2372
+ "--ff-surface": l.surfaceColor ?? "#fff",
2373
+ "--ff-border": l.borderColor ?? "#dee2e6",
2374
+ "--ff-danger": l.dangerColor ?? "#d32f2f",
2375
+ "--ff-radius": `${l.borderRadius ?? 6}px`,
2376
+ "--ff-font-family": l.fontFamily
2377
+ },
2378
+ children: [
2379
+ /* @__PURE__ */ m(
2380
+ _r,
2381
+ {
2382
+ nodes: ht,
2383
+ edges: Er,
2384
+ nodeTypes: mr,
2385
+ edgeTypes: wr,
2386
+ fitView: N,
2387
+ fitViewOptions: { padding: O },
2388
+ nodesDraggable: !1,
2389
+ nodesConnectable: !1,
2390
+ panOnScroll: B,
2391
+ zoomOnScroll: re,
2392
+ minZoom: he,
2393
+ maxZoom: z,
2394
+ snapToGrid: me,
2395
+ snapGrid: we,
2396
+ proOptions: { hideAttribution: !0 },
2397
+ onNodeClick: (w, E) => {
2398
+ const k = ne(E.id);
2399
+ k && (g != null && g(k) || (k.kind === "addTrigger" || k.kind === "triggerFixed" ? je() : (k.kind === "userTask" || k.kind === "filter" || k.kind === "approval") && Me(E.id)));
2400
+ },
2401
+ children: [
2402
+ l.background !== "none" && /* @__PURE__ */ f(
2403
+ Cr,
2404
+ {
2405
+ variant: l.background,
2406
+ color: l.backgroundColor ?? "#e0e0e0",
2407
+ gap: 20
2408
+ }
2409
+ ),
2410
+ M && /* @__PURE__ */ f(Sr, { showInteractive: !1 }),
2411
+ F && /* @__PURE__ */ f(Ir, { zoomable: !0, pannable: !0 }),
2412
+ /* @__PURE__ */ f(zi, { onHeightsReady: yr, nodeCount: ht.length })
2413
+ ]
2414
+ }
2415
+ ),
2416
+ c ? ae === "triggerSelect" && c(t.list(), lt, () => $(null)) : /* @__PURE__ */ f(Ri, { open: ae === "triggerSelect", templates: t.list(), messages: X, onSelect: lt, onClose: () => $(null) }),
2417
+ u ? ae === "nodePicker" && u(at(), dt, () => {
2418
+ $(null), ve(null);
2419
+ }) : /* @__PURE__ */ f(Di, { open: ae === "nodePicker", availableDescriptors: at(), messages: X, onSelect: dt, onClose: () => {
2420
+ $(null), ve(null);
2421
+ } }),
2422
+ h ? ae === "nodeConfig" && h(ut ?? void 0, H, ct, () => $(null)) : /* @__PURE__ */ f(Li, { open: ae === "nodeConfig", nodeId: Ie, descriptor: ut, initialValues: H == null ? void 0 : H.formData, messages: X, onSave: ct, onClose: () => $(null) }),
2423
+ v && Ee && /* @__PURE__ */ f(
2424
+ Ai,
2425
+ {
2426
+ isOpen: !!Ee,
2427
+ onClose: () => et(null),
2428
+ workflowId: Ee.workflowId,
2429
+ workflowLabel: Ee.workflowLabel,
2430
+ onFetchWorkflow: v
2431
+ }
2432
+ )
2433
+ ]
2434
+ }
2435
+ ) });
2436
+ }, Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2437
+ __proto__: null,
2438
+ WorkflowCanvas: Dt,
2439
+ default: Dt
2440
+ }, Symbol.toStringTag, { value: "Module" })), We = "All";
2441
+ function Ui({ template: e, onSelect: t }) {
2442
+ var o, i;
2443
+ const r = e.triggerCategory ? ln[e.triggerCategory] : null, n = ((o = e.skeletonState) == null ? void 0 : o.slots.filter((s) => s.kind === "userTask").length) ?? 0;
2444
+ return /* @__PURE__ */ m(
2445
+ "div",
2446
+ {
2447
+ role: "button",
2448
+ tabIndex: 0,
2449
+ onClick: t,
2450
+ onKeyDown: (s) => {
2451
+ (s.key === "Enter" || s.key === " ") && t();
2452
+ },
2453
+ style: {
2454
+ border: "1.5px solid #e0e0e0",
2455
+ borderRadius: 10,
2456
+ padding: "16px",
2457
+ background: "#fff",
2458
+ cursor: "pointer",
2459
+ transition: "border-color 0.15s, box-shadow 0.15s",
2460
+ display: "flex",
2461
+ flexDirection: "column",
2462
+ gap: 8,
2463
+ outline: "none"
2464
+ },
2465
+ onMouseEnter: (s) => {
2466
+ s.currentTarget.style.borderColor = "#1976d2", s.currentTarget.style.boxShadow = "0 2px 8px rgba(25,118,210,0.12)";
2467
+ },
2468
+ onMouseLeave: (s) => {
2469
+ s.currentTarget.style.borderColor = "#e0e0e0", s.currentTarget.style.boxShadow = "none";
2470
+ },
2471
+ children: [
2472
+ /* @__PURE__ */ m("div", { style: { display: "flex", alignItems: "flex-start", gap: 10 }, children: [
2473
+ e.icon && /* @__PURE__ */ f("div", { style: { flexShrink: 0, width: 36, height: 36, borderRadius: 8, background: "#f5f5f5", display: "flex", alignItems: "center", justifyContent: "center" }, children: e.icon }),
2474
+ /* @__PURE__ */ m("div", { style: { flex: 1, minWidth: 0 }, children: [
2475
+ /* @__PURE__ */ f("div", { style: { fontWeight: 600, fontSize: 14, color: "#212121", marginBottom: 2 }, children: e.label }),
2476
+ e.description && /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#757575", lineHeight: 1.4, display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical", overflow: "hidden" }, children: e.description })
2477
+ ] })
2478
+ ] }),
2479
+ /* @__PURE__ */ m("div", { style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 4 }, children: [
2480
+ r && /* @__PURE__ */ f("span", { style: { fontSize: 10, fontWeight: 600, padding: "2px 7px", borderRadius: 10, background: r.bg, color: r.color }, children: r.label }),
2481
+ (i = e.tags) == null ? void 0 : i.map((s) => /* @__PURE__ */ f("span", { style: { fontSize: 10, padding: "2px 7px", borderRadius: 10, background: "#f5f5f5", color: "#616161" }, children: s }, s)),
2482
+ n > 0 && /* @__PURE__ */ m("span", { style: { fontSize: 10, color: "#9e9e9e", marginLeft: "auto" }, children: [
2483
+ n,
2484
+ " step",
2485
+ n !== 1 ? "s" : ""
2486
+ ] })
2487
+ ] }),
2488
+ e.author && /* @__PURE__ */ m("div", { style: { fontSize: 11, color: "#bdbdbd" }, children: [
2489
+ "by ",
2490
+ e.author
2491
+ ] })
2492
+ ]
2493
+ }
2494
+ );
2495
+ }
2496
+ const as = ({
2497
+ templates: e,
2498
+ onSelectTemplate: t,
2499
+ onStartFromScratch: r
2500
+ }) => {
2501
+ const [n, o] = j(""), [i, s] = j(We), l = W(() => {
2502
+ const a = /* @__PURE__ */ new Set();
2503
+ return e.forEach((c) => {
2504
+ c.category && a.add(c.category);
2505
+ }), [We, ...Array.from(a)];
2506
+ }, [e]), d = W(() => {
2507
+ let a = e;
2508
+ if (i !== We && (a = a.filter((c) => c.category === i)), n.trim()) {
2509
+ const c = n.toLowerCase();
2510
+ a = a.filter(
2511
+ (u) => {
2512
+ var h, g;
2513
+ return u.label.toLowerCase().includes(c) || ((h = u.description) == null ? void 0 : h.toLowerCase().includes(c)) || ((g = u.tags) == null ? void 0 : g.some((b) => b.toLowerCase().includes(c)));
2514
+ }
2515
+ );
2516
+ }
2517
+ return [...a].sort((c, u) => (u.popularity ?? 0) - (c.popularity ?? 0));
2518
+ }, [e, i, n]);
2519
+ return /* @__PURE__ */ m("div", { style: { display: "flex", flexDirection: "column", height: "100%", fontFamily: "inherit" }, children: [
2520
+ /* @__PURE__ */ m("div", { style: { padding: "24px 24px 0", borderBottom: "1px solid #f0f0f0", paddingBottom: 16 }, children: [
2521
+ /* @__PURE__ */ m("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 16 }, children: [
2522
+ /* @__PURE__ */ m("div", { children: [
2523
+ /* @__PURE__ */ f("h2", { style: { margin: 0, fontSize: 20, fontWeight: 700, color: "#212121" }, children: "Workflow Templates" }),
2524
+ /* @__PURE__ */ f("p", { style: { margin: "4px 0 0", fontSize: 13, color: "#757575" }, children: "Choose a pre-built template or start from scratch" })
2525
+ ] }),
2526
+ r && /* @__PURE__ */ m(
2527
+ "button",
2528
+ {
2529
+ onClick: r,
2530
+ style: { display: "flex", alignItems: "center", gap: 6, padding: "8px 16px", border: "1.5px solid #1976d2", borderRadius: 6, background: "#fff", color: "#1976d2", fontSize: 13, fontWeight: 600, cursor: "pointer" },
2531
+ children: [
2532
+ /* @__PURE__ */ f(Hr, { size: 16 }),
2533
+ "Start from Scratch"
2534
+ ]
2535
+ }
2536
+ )
2537
+ ] }),
2538
+ /* @__PURE__ */ m("div", { style: { display: "flex", alignItems: "center", gap: 8, background: "#f5f5f5", borderRadius: 8, padding: "8px 12px", marginBottom: 12 }, children: [
2539
+ /* @__PURE__ */ f(qr, { size: 18, color: "#9e9e9e" }),
2540
+ /* @__PURE__ */ f(
2541
+ "input",
2542
+ {
2543
+ value: n,
2544
+ onChange: (a) => o(a.target.value),
2545
+ placeholder: "Search templates...",
2546
+ style: { border: "none", background: "transparent", outline: "none", fontSize: 14, color: "#212121", flex: 1 }
2547
+ }
2548
+ )
2549
+ ] }),
2550
+ l.length > 1 && /* @__PURE__ */ f("div", { style: { display: "flex", gap: 4, flexWrap: "wrap" }, children: l.map((a) => /* @__PURE__ */ f(
2551
+ "button",
2552
+ {
2553
+ onClick: () => s(a),
2554
+ style: {
2555
+ padding: "4px 12px",
2556
+ borderRadius: 20,
2557
+ border: "1.5px solid",
2558
+ borderColor: i === a ? "#1976d2" : "#e0e0e0",
2559
+ background: i === a ? "#e3f2fd" : "#fff",
2560
+ color: i === a ? "#1565c0" : "#616161",
2561
+ fontSize: 12,
2562
+ fontWeight: i === a ? 600 : 400,
2563
+ cursor: "pointer"
2564
+ },
2565
+ children: a
2566
+ },
2567
+ a
2568
+ )) })
2569
+ ] }),
2570
+ /* @__PURE__ */ f("div", { style: { flex: 1, overflowY: "auto", padding: 24 }, children: d.length === 0 ? /* @__PURE__ */ m("div", { style: { textAlign: "center", padding: "40px 0", color: "#9e9e9e" }, children: [
2571
+ /* @__PURE__ */ f(Xr, { size: 36, style: { marginBottom: 8 } }),
2572
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 14 }, children: "No templates found" })
2573
+ ] }) : /* @__PURE__ */ f("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(280px, 1fr))", gap: 16 }, children: d.map((a) => /* @__PURE__ */ f(Ui, { template: a, onSelect: () => t(a) }, a.triggerKey)) }) })
2574
+ ] });
2575
+ }, ke = {
2576
+ running: { label: "Running", color: q.running, icon: P.createElement(Gt, { size: 14 }) },
2577
+ success: { label: "Success", color: q.success, icon: P.createElement(Wt, { size: 14 }) },
2578
+ failed: { label: "Failed", color: q.failed, icon: P.createElement(Bt, { size: 14 }) },
2579
+ cancelled: { label: "Cancelled", color: q.cancelled, icon: P.createElement(Pt, { size: 14 }) }
2580
+ }, Vi = {
2581
+ pending: { color: q.pending, icon: P.createElement(Jr, { size: 14 }) },
2582
+ running: { color: q.running, icon: P.createElement(Gt, { size: 14 }) },
2583
+ success: { color: q.success, icon: P.createElement(Wt, { size: 14 }) },
2584
+ failed: { color: q.failed, icon: P.createElement(Bt, { size: 14 }) },
2585
+ skipped: { color: q.skipped, icon: P.createElement(Pt, { size: 14 }) }
2586
+ };
2587
+ function Ue(e) {
2588
+ try {
2589
+ return new Date(e).toLocaleString();
2590
+ } catch {
2591
+ return e;
2592
+ }
2593
+ }
2594
+ function pr(e, t) {
2595
+ try {
2596
+ const r = new Date(t ?? (/* @__PURE__ */ new Date()).toISOString()).getTime() - new Date(e).getTime();
2597
+ return r < 1e3 ? `${r}ms` : r < 6e4 ? `${(r / 1e3).toFixed(1)}s` : `${Math.floor(r / 6e4)}m ${Math.floor(r % 6e4 / 1e3)}s`;
2598
+ } catch {
2599
+ return "—";
2600
+ }
2601
+ }
2602
+ function Hi({ step: e }) {
2603
+ const [t, r] = j(!1), n = Vi[e.status], o = !!(e.inputs || e.outputs || e.error);
2604
+ return /* @__PURE__ */ m("div", { style: { borderBottom: "1px solid #f5f5f5" }, children: [
2605
+ /* @__PURE__ */ m(
2606
+ "div",
2607
+ {
2608
+ style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", cursor: o ? "pointer" : "default" },
2609
+ onClick: () => {
2610
+ o && r((i) => !i);
2611
+ },
2612
+ role: o ? "button" : void 0,
2613
+ tabIndex: o ? 0 : void 0,
2614
+ onKeyDown: (i) => {
2615
+ o && (i.key === "Enter" || i.key === " ") && r((s) => !s);
2616
+ },
2617
+ children: [
2618
+ /* @__PURE__ */ f("span", { style: { color: n.color, flexShrink: 0 }, children: P.cloneElement(n.icon, { color: n.color }) }),
2619
+ /* @__PURE__ */ f("span", { style: { flex: 1, fontSize: 13, color: "#212121" }, children: e.label || e.nodeId }),
2620
+ e.branchTaken && /* @__PURE__ */ f("span", { style: { fontSize: 10, padding: "1px 6px", borderRadius: 10, background: "#e3f2fd", color: "#1565c0", fontWeight: 600 }, children: e.branchTaken }),
2621
+ /* @__PURE__ */ f("span", { style: { fontSize: 11, color: "#9e9e9e", flexShrink: 0 }, children: e.startedAt ? pr(e.startedAt, e.completedAt) : "—" }),
2622
+ o && /* @__PURE__ */ f("span", { style: { color: "#9e9e9e", flexShrink: 0 }, children: t ? P.createElement(Qr, { size: 16 }) : P.createElement(en, { size: 16 }) })
2623
+ ]
2624
+ }
2625
+ ),
2626
+ t && o && /* @__PURE__ */ m("div", { style: { padding: "0 12px 10px 32px", fontSize: 12 }, children: [
2627
+ e.error && /* @__PURE__ */ f("div", { style: { padding: "6px 10px", borderRadius: 6, background: "#ffebee", color: "#c62828", marginBottom: 6 }, children: e.error }),
2628
+ e.inputs && Object.keys(e.inputs).length > 0 && /* @__PURE__ */ m("details", { style: { marginBottom: 4 }, children: [
2629
+ /* @__PURE__ */ f("summary", { style: { cursor: "pointer", color: "#616161", marginBottom: 4 }, children: "Inputs" }),
2630
+ /* @__PURE__ */ f("pre", { style: { margin: 0, fontSize: 11, background: "#f5f5f5", padding: 8, borderRadius: 4, overflowX: "auto" }, children: JSON.stringify(e.inputs, null, 2) })
2631
+ ] }),
2632
+ e.outputs && Object.keys(e.outputs).length > 0 && /* @__PURE__ */ m("details", { children: [
2633
+ /* @__PURE__ */ f("summary", { style: { cursor: "pointer", color: "#616161", marginBottom: 4 }, children: "Outputs" }),
2634
+ /* @__PURE__ */ f("pre", { style: { margin: 0, fontSize: 11, background: "#f5f5f5", padding: 8, borderRadius: 4, overflowX: "auto" }, children: JSON.stringify(e.outputs, null, 2) })
2635
+ ] })
2636
+ ] })
2637
+ ] });
2638
+ }
2639
+ function qi({ record: e, selected: t, onSelect: r }) {
2640
+ const n = ke[e.status];
2641
+ return /* @__PURE__ */ m(
2642
+ "div",
2643
+ {
2644
+ role: "button",
2645
+ tabIndex: 0,
2646
+ onClick: r,
2647
+ onKeyDown: (o) => {
2648
+ (o.key === "Enter" || o.key === " ") && r();
2649
+ },
2650
+ style: {
2651
+ padding: "10px 14px",
2652
+ borderBottom: "1px solid #f0f0f0",
2653
+ cursor: "pointer",
2654
+ background: t ? "#e3f2fd" : "#fff",
2655
+ display: "flex",
2656
+ alignItems: "center",
2657
+ gap: 10,
2658
+ outline: "none"
2659
+ },
2660
+ children: [
2661
+ /* @__PURE__ */ f("span", { style: { color: n.color, flexShrink: 0 }, children: P.cloneElement(n.icon, { color: n.color, size: 16 }) }),
2662
+ /* @__PURE__ */ m("div", { style: { flex: 1, minWidth: 0 }, children: [
2663
+ /* @__PURE__ */ f("div", { style: { fontSize: 12, color: "#212121", fontWeight: t ? 600 : 400, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: Ue(e.triggeredAt) }),
2664
+ /* @__PURE__ */ m("div", { style: { fontSize: 11, color: "#9e9e9e" }, children: [
2665
+ e.triggeredBy ? `by ${e.triggeredBy}` : "System",
2666
+ " · ",
2667
+ e.steps.length,
2668
+ " step",
2669
+ e.steps.length !== 1 ? "s" : ""
2670
+ ] })
2671
+ ] }),
2672
+ /* @__PURE__ */ f("span", { style: { fontSize: 11, fontWeight: 600, color: n.color, flexShrink: 0 }, children: n.label }),
2673
+ /* @__PURE__ */ f(At, { size: 14, color: "#bdbdbd" })
2674
+ ]
2675
+ }
2676
+ );
2677
+ }
2678
+ const ds = ({ records: e, onViewOnCanvas: t }) => {
2679
+ var s;
2680
+ const [r, n] = j(((s = e[0]) == null ? void 0 : s.id) ?? null), o = e.find((l) => l.id === r) ?? null, i = [...e].sort((l, d) => new Date(d.triggeredAt).getTime() - new Date(l.triggeredAt).getTime());
2681
+ return e.length === 0 ? /* @__PURE__ */ m("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: 300, color: "#9e9e9e", gap: 8 }, children: [
2682
+ /* @__PURE__ */ f(mt, { size: 36 }),
2683
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 14 }, children: "No executions yet" }),
2684
+ /* @__PURE__ */ f("p", { style: { margin: 0, fontSize: 12 }, children: "Run history will appear here" })
2685
+ ] }) : /* @__PURE__ */ m("div", { style: { display: "flex", height: "100%", fontFamily: "inherit", border: "1px solid #e0e0e0", borderRadius: 8, overflow: "hidden" }, children: [
2686
+ /* @__PURE__ */ m("div", { style: { width: 260, flexShrink: 0, borderRight: "1px solid #e0e0e0", overflowY: "auto", background: "#fafafa" }, children: [
2687
+ /* @__PURE__ */ m("div", { style: { padding: "12px 14px", borderBottom: "1px solid #e0e0e0", fontWeight: 600, fontSize: 13, color: "#212121" }, children: [
2688
+ "Run History (",
2689
+ e.length,
2690
+ ")"
2691
+ ] }),
2692
+ i.map((l) => /* @__PURE__ */ f(qi, { record: l, selected: l.id === r, onSelect: () => n(l.id) }, l.id))
2693
+ ] }),
2694
+ /* @__PURE__ */ f("div", { style: { flex: 1, overflowY: "auto" }, children: o ? /* @__PURE__ */ m("div", { children: [
2695
+ /* @__PURE__ */ m("div", { style: { padding: "16px 20px", borderBottom: "1px solid #f0f0f0", display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 12 }, children: [
2696
+ /* @__PURE__ */ m("div", { children: [
2697
+ /* @__PURE__ */ m("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 4 }, children: [
2698
+ P.cloneElement(ke[o.status].icon, { color: ke[o.status].color, size: 18 }),
2699
+ /* @__PURE__ */ f("span", { style: { fontWeight: 700, fontSize: 15, color: "#212121" }, children: ke[o.status].label })
2700
+ ] }),
2701
+ /* @__PURE__ */ m("div", { style: { fontSize: 12, color: "#757575", display: "flex", flexDirection: "column", gap: 2 }, children: [
2702
+ /* @__PURE__ */ m("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
2703
+ /* @__PURE__ */ f(mt, { size: 13 }),
2704
+ " ",
2705
+ Ue(o.triggeredAt),
2706
+ o.completedAt && ` → ${Ue(o.completedAt)} (${pr(o.triggeredAt, o.completedAt)})`
2707
+ ] }),
2708
+ o.triggeredBy && /* @__PURE__ */ m("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
2709
+ /* @__PURE__ */ f(Zr, { size: 13 }),
2710
+ " ",
2711
+ o.triggeredBy
2712
+ ] })
2713
+ ] })
2714
+ ] }),
2715
+ t && /* @__PURE__ */ f(
2716
+ "button",
2717
+ {
2718
+ onClick: () => t(o),
2719
+ style: { padding: "6px 12px", border: "1.5px solid #1976d2", borderRadius: 6, background: "#fff", color: "#1976d2", fontSize: 12, fontWeight: 600, cursor: "pointer", flexShrink: 0 },
2720
+ children: "View on Canvas"
2721
+ }
2722
+ )
2723
+ ] }),
2724
+ o.error && /* @__PURE__ */ f("div", { style: { margin: "12px 16px", padding: "10px 14px", borderRadius: 6, background: "#ffebee", color: "#c62828", fontSize: 13 }, children: o.error }),
2725
+ /* @__PURE__ */ m("div", { children: [
2726
+ /* @__PURE__ */ m("div", { style: { padding: "10px 12px", fontSize: 12, fontWeight: 600, color: "#757575", borderBottom: "1px solid #f0f0f0" }, children: [
2727
+ "STEPS (",
2728
+ o.steps.length,
2729
+ ")"
2730
+ ] }),
2731
+ o.steps.map((l, d) => /* @__PURE__ */ f(Hi, { step: l }, `${l.nodeId}-${d}`))
2732
+ ] }),
2733
+ o.inputs && Object.keys(o.inputs).length > 0 && /* @__PURE__ */ f("div", { style: { padding: "10px 16px" }, children: /* @__PURE__ */ m("details", { children: [
2734
+ /* @__PURE__ */ f("summary", { style: { cursor: "pointer", fontSize: 12, fontWeight: 600, color: "#757575", marginBottom: 6 }, children: "TRIGGER INPUTS" }),
2735
+ /* @__PURE__ */ f("pre", { style: { margin: 0, fontSize: 11, background: "#f5f5f5", padding: 10, borderRadius: 4, overflowX: "auto" }, children: JSON.stringify(o.inputs, null, 2) })
2736
+ ] }) })
2737
+ ] }) : /* @__PURE__ */ f("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", height: "100%", color: "#9e9e9e", fontSize: 14 }, children: "Select a run to see details" }) })
2738
+ ] });
2739
+ }, cs = {
2740
+ slots: [
2741
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2742
+ { id: "trigger-END_USER_CREATION", kind: "triggerFixed", reactFlowType: "triggerNode", deletable: !0, label: "New User Registration", nodeData: { label: "New User Registration" } },
2743
+ { id: "notification-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Welcome Email", nodeData: { title: "Welcome Email" } },
2744
+ { id: "approval-1", kind: "approval", reactFlowType: "approvalNode", descriptorType: "approval", deletable: !0, label: "Manager Approval", branchLabels: { pass: "Approved", fail: "Rejected" } },
2745
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2746
+ ],
2747
+ branches: {
2748
+ "approval-1": {
2749
+ pass: [{ id: "notification-pass-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Approval Confirmed", nodeData: { title: "Approval Confirmed" } }],
2750
+ fail: [{ id: "notification-fail-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Rejection Notice", nodeData: { title: "Rejection Notice" } }]
2751
+ }
2752
+ }
2753
+ }, us = {
2754
+ slots: [
2755
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2756
+ { id: "trigger-ACCESS_REQUEST", kind: "triggerFixed", reactFlowType: "triggerNode", deletable: !0, label: "Access Request Submitted", nodeData: { label: "Access Request Submitted" } },
2757
+ { id: "approval-1", kind: "approval", reactFlowType: "approvalNode", descriptorType: "approval", deletable: !0, label: "Access Approval", branchLabels: { pass: "Approved", fail: "Denied" } },
2758
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2759
+ ],
2760
+ branches: {
2761
+ "approval-1": {
2762
+ pass: [
2763
+ { id: "restApi-1", kind: "userTask", reactFlowType: "restApiNode", descriptorType: "restApi", deletable: !0, label: "Provision Access", nodeData: { title: "Provision Access" } },
2764
+ { id: "notification-pass-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Access Granted Email", nodeData: { title: "Access Granted Email" } }
2765
+ ],
2766
+ fail: [
2767
+ { id: "notification-fail-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Access Denied Email", nodeData: { title: "Access Denied Email" } }
2768
+ ]
2769
+ }
2770
+ }
2771
+ }, fs = {
2772
+ slots: [
2773
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2774
+ { id: "trigger-USER_DEACTIVATION", kind: "triggerFixed", reactFlowType: "triggerNode", deletable: !0, label: "User Deactivation", nodeData: { label: "User Deactivation" } },
2775
+ { id: "delay-1", kind: "userTask", reactFlowType: "delayNode", descriptorType: "delay", deletable: !0, label: "Grace Period", nodeData: { title: "Grace Period", duration: 7, unit: "days" }, formData: { duration: 7, unit: "days" } },
2776
+ { id: "notification-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Notify IT Team", nodeData: { title: "Notify IT Team" } },
2777
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2778
+ ],
2779
+ branches: {}
2780
+ }, hs = {
2781
+ slots: [
2782
+ { id: "start", kind: "start", reactFlowType: "startNode", deletable: !1 },
2783
+ { id: "trigger-WEBHOOK_TRIGGER", kind: "triggerFixed", reactFlowType: "webhookTriggerNode", deletable: !0, label: "Incoming Webhook", nodeData: { label: "Incoming Webhook" } },
2784
+ { id: "restApi-1", kind: "userTask", reactFlowType: "restApiNode", descriptorType: "restApi", deletable: !0, label: "Call External API", nodeData: { title: "Call External API" } },
2785
+ { id: "notification-1", kind: "userTask", reactFlowType: "notificationNode", descriptorType: "notification", deletable: !0, label: "Notify on Completion", nodeData: { title: "Notify on Completion" } },
2786
+ { id: "end", kind: "end", reactFlowType: "endNode", deletable: !1 }
2787
+ ],
2788
+ branches: {}
2789
+ };
2790
+ export {
2791
+ Dt as F,
2792
+ Ai as S,
2793
+ ds as W,
2794
+ as as a,
2795
+ us as b,
2796
+ fs as o,
2797
+ cs as u,
2798
+ hs as w
2799
+ };