@floegence/floe-webapp-core 0.86.5 → 0.86.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,77 +1,82 @@
1
- import { applyGraphPositions as v } from "./positions.js";
2
- import { computePackedGraphLayout as b } from "./packing.js";
3
- function N(n) {
4
- const o = /* @__PURE__ */ new Set(), c = (e) => {
5
- if (!e || o.has(e)) throw new Error(`Duplicate or empty graph ID: ${e}`);
6
- o.add(e);
7
- }, a = new Map(n.nodes.map((e) => [e.id, e]));
8
- for (const e of n.nodes) {
9
- if (c(e.id), ![e.width, e.height].every((i) => Number.isFinite(i) && i > 0))
10
- throw new Error(`Invalid dimensions for graph node: ${e.id}`);
11
- for (const i of e.ports ?? []) c(i.id);
12
- const s = /* @__PURE__ */ new Set([e.id]);
13
- let d = e.parentId;
14
- for (; d !== void 0; ) {
15
- const i = a.get(d);
16
- if (!i || i.kind !== "group")
17
- throw new Error(`Invalid parent for graph node: ${e.id}`);
18
- if (s.has(d)) throw new Error(`Cyclic graph containment: ${e.id}`);
19
- s.add(d), d = i.parentId;
1
+ import { applyGraphPositions as b } from "./positions.js";
2
+ import { computePackedGraphLayout as k } from "./packing.js";
3
+ function $(a) {
4
+ const o = /* @__PURE__ */ new Set(), c = (t) => {
5
+ if (!t || o.has(t)) throw new Error(`Duplicate or empty graph ID: ${t}`);
6
+ o.add(t);
7
+ }, i = new Map(a.nodes.map((t) => [t.id, t]));
8
+ for (const t of a.nodes) {
9
+ if (c(t.id), ![t.width, t.height].every((n) => Number.isFinite(n) && n > 0))
10
+ throw new Error(`Invalid dimensions for graph node: ${t.id}`);
11
+ for (const n of t.ports ?? []) c(n.id);
12
+ const s = /* @__PURE__ */ new Set([t.id]);
13
+ let r = t.parentId;
14
+ for (; r !== void 0; ) {
15
+ const n = i.get(r);
16
+ if (!n || n.kind !== "group")
17
+ throw new Error(`Invalid parent for graph node: ${t.id}`);
18
+ if (s.has(r)) throw new Error(`Cyclic graph containment: ${t.id}`);
19
+ s.add(r), r = n.parentId;
20
20
  }
21
21
  }
22
- for (const e of n.edges) {
23
- c(e.id);
24
- for (const [s, d] of [
25
- [e.source, e.sourcePort],
26
- [e.target, e.targetPort]
22
+ for (const t of a.edges) {
23
+ c(t.id);
24
+ for (const [s, r] of [
25
+ [t.source, t.sourcePort],
26
+ [t.target, t.targetPort]
27
27
  ]) {
28
- const i = a.get(s);
29
- if (!i || d !== void 0 && !i.ports?.some((h) => h.id === d))
30
- throw new Error(`Invalid endpoint for graph edge: ${e.id}`);
28
+ const n = i.get(s);
29
+ if (!n || r !== void 0 && !n.ports?.some((h) => h.id === r))
30
+ throw new Error(`Invalid endpoint for graph edge: ${t.id}`);
31
31
  }
32
32
  }
33
33
  }
34
- async function P(n, o, c) {
35
- if (N(n), o.aspectRatio !== void 0 && (!Number.isFinite(o.aspectRatio) || o.aspectRatio <= 0))
34
+ async function P(a, o, c) {
35
+ $(a);
36
+ const i = O(a, o);
37
+ if (o.aspectRatio !== void 0 && (!Number.isFinite(o.aspectRatio) || o.aspectRatio <= 0))
36
38
  throw new Error("Graph layout aspect ratio must be finite and positive");
37
- const a = o.groupPadding ?? { top: 64, right: 28, bottom: 28, left: 28 };
38
- if (![...Object.values(a), o.spacing ?? 64].every((t) => Number.isFinite(t) && t >= 0))
39
+ const t = o.groupPadding ?? { top: 64, right: 28, bottom: 28, left: 28 };
40
+ if (![...Object.values(t), o.spacing ?? 64].every((e) => Number.isFinite(e) && e >= 0))
39
41
  throw new Error("Graph layout spacing must be finite and nonnegative");
40
- if (o.aspectRatio !== void 0) return b(n, o, c);
41
- const e = /* @__PURE__ */ new Map();
42
- for (const t of n.nodes)
43
- e.set(t.id, {
44
- id: t.id,
45
- width: t.width,
46
- height: t.height,
47
- ...t.kind === "group" ? { children: [] } : {},
48
- ports: t.ports?.map((r) => ({
49
- id: r.id,
42
+ if (o.layers && (M(a, o.layers), o.positionMode === "fixed" && o.positions?.length))
43
+ throw new Error("Fixed positions cannot be combined with graph layers");
44
+ if (o.aspectRatio !== void 0 || o.layers)
45
+ return k(i, o, c);
46
+ const s = /* @__PURE__ */ new Map();
47
+ for (const e of i.nodes)
48
+ s.set(e.id, {
49
+ id: e.id,
50
+ width: e.width,
51
+ height: e.height,
52
+ ...e.kind === "group" ? { children: [] } : {},
53
+ ports: e.ports?.map((d) => ({
54
+ id: d.id,
50
55
  width: 1,
51
56
  height: 1,
52
- layoutOptions: { "elk.port.side": r.side }
57
+ layoutOptions: { "elk.port.side": d.side }
53
58
  })),
54
59
  layoutOptions: {
55
60
  "elk.portConstraints": "FIXED_ORDER",
56
- "elk.padding": `[top=${a.top},left=${a.left},bottom=${a.bottom},right=${a.right}]`
61
+ "elk.padding": `[top=${t.top},left=${t.left},bottom=${t.bottom},right=${t.right}]`
57
62
  }
58
63
  });
59
- const s = [];
60
- for (const t of n.nodes)
61
- (t.parentId ? e.get(t.parentId).children : s).push(e.get(t.id));
62
- const d = /* @__PURE__ */ new Set([
63
- ...n.nodes.flatMap((t) => [t.id, ...(t.ports ?? []).map((r) => r.id)]),
64
- ...n.edges.map((t) => t.id)
64
+ const r = [];
65
+ for (const e of i.nodes)
66
+ (e.parentId ? s.get(e.parentId).children : r).push(s.get(e.id));
67
+ const n = /* @__PURE__ */ new Set([
68
+ ...i.nodes.flatMap((e) => [e.id, ...(e.ports ?? []).map((d) => d.id)]),
69
+ ...i.edges.map((e) => e.id)
65
70
  ]);
66
- let i = "$graph";
67
- for (; d.has(i); ) i += "$";
68
- const h = await c.layout({
69
- id: i,
70
- children: s,
71
- edges: n.edges.map((t) => ({
72
- id: t.id,
73
- sources: [t.sourcePort ?? t.source],
74
- targets: [t.targetPort ?? t.target]
71
+ let h = "$graph";
72
+ for (; n.has(h); ) h += "$";
73
+ const p = await c.layout({
74
+ id: h,
75
+ children: r,
76
+ edges: i.edges.map((e) => ({
77
+ id: e.id,
78
+ sources: [e.sourcePort ?? e.source],
79
+ targets: [e.targetPort ?? e.target]
75
80
  })),
76
81
  layoutOptions: {
77
82
  "elk.algorithm": "layered",
@@ -83,47 +88,72 @@ async function P(n, o, c) {
83
88
  "elk.layered.considerModelOrder.strategy": "NODES_AND_EDGES",
84
89
  "elk.randomSeed": "1"
85
90
  }
86
- }), f = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), E = (t) => {
87
- for (const r of t.edges ?? []) {
88
- const p = r.container ?? t.id, l = f.get(p) ?? { x: 0, y: 0 };
91
+ }), y = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), E = (e) => {
92
+ for (const d of e.edges ?? []) {
93
+ const g = d.container ?? e.id, f = y.get(g) ?? { x: 0, y: 0 };
89
94
  x.set(
90
- r.id,
91
- (r.sections ?? []).map(
92
- (g) => [g.startPoint, ...g.bendPoints ?? [], g.endPoint].map((w) => ({
93
- x: w.x + l.x,
94
- y: w.y + l.y
95
+ d.id,
96
+ (d.sections ?? []).map(
97
+ (l) => [l.startPoint, ...l.bendPoints ?? [], l.endPoint].map((m) => ({
98
+ x: m.x + f.x,
99
+ y: m.y + f.y
95
100
  }))
96
101
  )
97
102
  );
98
103
  }
99
- for (const r of t.children ?? []) E(r);
100
- }, I = (t, r, p) => {
101
- const l = r + (t.x ?? 0), g = p + (t.y ?? 0);
102
- f.set(t.id, { x: l, y: g, width: t.width ?? 0, height: t.height ?? 0 });
103
- for (const w of t.children ?? []) I(w, l, g);
104
+ for (const d of e.children ?? []) E(d);
105
+ }, v = (e, d, g) => {
106
+ const f = d + (e.x ?? 0), l = g + (e.y ?? 0);
107
+ y.set(e.id, { x: f, y: l, width: e.width ?? 0, height: e.height ?? 0 });
108
+ for (const m of e.children ?? []) v(m, f, l);
104
109
  };
105
- for (const t of h.children ?? []) I(t, 0, 0);
106
- E(h);
107
- const y = !o.positions?.length && o.anchor && f.get(o.anchor.nodeId), m = y ? o.anchor.position.x - y.x : 0, u = y ? o.anchor.position.y - y.y : 0, k = n.nodes.map((t) => {
108
- const r = f.get(t.id);
109
- return { ...t, ...r, x: r.x + m, y: r.y + u };
110
+ for (const e of p.children ?? []) v(e, 0, 0);
111
+ E(p);
112
+ const w = (!o.positions?.length || o.positionMode === "compact") && o.anchor && y.get(o.anchor.nodeId), u = w ? o.anchor.position.x - w.x : 0, I = w ? o.anchor.position.y - w.y : 0, G = i.nodes.map((e) => {
113
+ const d = y.get(e.id);
114
+ return { ...e, ...d, x: d.x + u, y: d.y + I };
110
115
  });
111
- return v(
116
+ return b(
112
117
  {
113
- nodes: k,
114
- edges: n.edges.map((t) => ({
115
- ...t,
116
- sections: (x.get(t.id) ?? []).map(
117
- (r) => r.map((p) => ({ x: p.x + m, y: p.y + u }))
118
+ nodes: G,
119
+ edges: i.edges.map((e) => ({
120
+ ...e,
121
+ sections: (x.get(e.id) ?? []).map(
122
+ (d) => d.map((g) => ({ x: g.x + u, y: g.y + I }))
118
123
  )
119
124
  })),
120
- bounds: { x: m, y: u, width: h.width ?? 0, height: h.height ?? 0 }
125
+ bounds: { x: u, y: I, width: p.width ?? 0, height: p.height ?? 0 }
121
126
  },
122
127
  o,
123
- n.nodes
128
+ i.nodes
124
129
  );
125
130
  }
131
+ function O(a, o) {
132
+ if (o.positionMode !== "compact" || !o.positions?.length) return a;
133
+ const c = o.direction ?? "RIGHT", i = new Map(
134
+ o.positions.map((r) => [
135
+ r.nodeId,
136
+ c === "RIGHT" || c === "LEFT" ? r.y : r.x
137
+ ])
138
+ ), t = new Map(a.nodes.map((r, n) => [r.id, n]));
139
+ return { nodes: [...a.nodes].sort((r, n) => {
140
+ const h = (r.parentId ?? "").localeCompare(n.parentId ?? ""), p = o.layers && !r.parentId && !n.parentId ? 0 : (i.get(r.id) ?? 1 / 0) - (i.get(n.id) ?? 1 / 0);
141
+ return h || p || t.get(r.id) - t.get(n.id);
142
+ }), edges: a.edges };
143
+ }
144
+ function M(a, o) {
145
+ const c = new Map(a.nodes.map((t) => [t.id, t])), i = /* @__PURE__ */ new Set();
146
+ for (const [t, s] of o.entries()) {
147
+ if (!s.length) throw new Error(`Graph layer must not be empty: ${t}`);
148
+ for (const r of s) {
149
+ const n = c.get(r);
150
+ if (!n || n.parentId) throw new Error(`Graph layer object must be a root node: ${r}`);
151
+ if (i.has(r)) throw new Error(`Graph object appears in multiple layers: ${r}`);
152
+ i.add(r);
153
+ }
154
+ }
155
+ }
126
156
  export {
127
157
  P as computeGraphLayout,
128
- N as validateGraphInput
158
+ $ as validateGraphInput
129
159
  };
@@ -1,74 +1,158 @@
1
- import { applyGraphPositions as b, routeGraphGeometry as G } from "./positions.js";
2
- async function O(d, n, k) {
3
- const a = new Map(d.nodes.map((e) => [e.id, { ...e, x: 0, y: 0 }])), r = /* @__PURE__ */ new Map();
4
- for (const e of a.values()) {
5
- const i = r.get(e.parentId) ?? [];
6
- i.push(e), r.set(e.parentId, i);
1
+ import { applyGraphPositions as $ } from "./positions.js";
2
+ import { routeGraphGeometry as P } from "./routing.js";
3
+ async function j(f, i, S) {
4
+ const y = new Map(f.nodes.map((e) => [e.id, { ...e, x: 0, y: 0 }])), O = new Map(f.nodes.map((e, d) => [e.id, d])), m = /* @__PURE__ */ new Map();
5
+ for (const e of y.values()) {
6
+ const d = m.get(e.parentId) ?? [];
7
+ d.push(e), m.set(e.parentId, d);
7
8
  }
8
- const x = /* @__PURE__ */ new Set([
9
- ...d.nodes.flatMap((e) => [e.id, ...(e.ports ?? []).map((i) => i.id)]),
10
- ...d.edges.map((e) => e.id)
9
+ const p = /* @__PURE__ */ new Set([
10
+ ...f.nodes.flatMap((e) => [e.id, ...(e.ports ?? []).map((d) => d.id)]),
11
+ ...f.edges.map((e) => e.id)
11
12
  ]);
12
- let l = "$packed";
13
- for (; x.has(l); ) l += "$";
14
- const g = n.groupPadding ?? { top: 64, right: 28, bottom: 28, left: 28 }, p = (e, i, o) => {
15
- e.x += i, e.y += o;
16
- for (const c of r.get(e.id) ?? []) p(c, i, o);
17
- }, y = (e, i) => {
18
- let o = a.get(e);
19
- for (; o && o.parentId !== i; )
20
- o = o.parentId ? a.get(o.parentId) : void 0;
21
- return o;
22
- }, m = async (e) => {
23
- const i = r.get(e) ?? [];
24
- for (const t of i) {
25
- if (!r.has(t.id)) continue;
26
- const s = await m(t.id);
27
- t.width = Math.max(t.width, s.width), t.height = Math.max(t.height, s.height);
13
+ let T = "$packed";
14
+ for (; p.has(T); ) T += "$";
15
+ const k = i.groupPadding ?? { top: 64, right: 28, bottom: 28, left: 28 }, E = i.direction ?? "RIGHT", w = new Map(
16
+ (i.positions ?? []).map((e) => [
17
+ e.nodeId,
18
+ E === "RIGHT" || E === "LEFT" ? e.y : e.x
19
+ ])
20
+ ), I = (e, d, s) => {
21
+ e.x += d, e.y += s;
22
+ for (const v of m.get(e.id) ?? []) I(v, d, s);
23
+ }, x = (e, d) => {
24
+ let s = y.get(e);
25
+ for (; s && s.parentId !== d; )
26
+ s = s.parentId ? y.get(s.parentId) : void 0;
27
+ return s;
28
+ }, G = async (e) => {
29
+ const d = [...m.get(e) ?? []];
30
+ (e !== void 0 || !i.layers) && d.sort(
31
+ (o, a) => (w.get(o.id) ?? 1 / 0) - (w.get(a.id) ?? 1 / 0) || O.get(o.id) - O.get(a.id)
32
+ );
33
+ for (const o of d) {
34
+ if (!m.has(o.id)) continue;
35
+ const a = await G(o.id);
36
+ o.width = Math.max(o.width, a.width), o.height = Math.max(o.height, a.height);
28
37
  }
29
- if (!i.length) return { width: 0, height: 0 };
30
- const o = /* @__PURE__ */ new Map();
31
- for (const t of d.edges) {
32
- const s = y(t.source, e), h = y(t.target, e);
33
- if (!s || !h || s.id === h.id) continue;
34
- const w = JSON.stringify([s.id, h.id]);
35
- o.has(w) || o.set(w, { id: t.id, sources: [s.id], targets: [h.id] });
38
+ if (!d.length) return { width: 0, height: 0 };
39
+ if (e === void 0 && i.layers)
40
+ return z(d, f, i, x, I);
41
+ const s = /* @__PURE__ */ new Map();
42
+ for (const o of f.edges) {
43
+ const a = x(o.source, e), M = x(o.target, e);
44
+ if (!a || !M || a.id === M.id) continue;
45
+ const H = JSON.stringify([a.id, M.id]);
46
+ s.has(H) || s.set(H, { id: o.id, sources: [a.id], targets: [M.id] });
36
47
  }
37
- const c = await k.layout({
38
- id: e ?? l,
39
- children: i.map((t) => ({ id: t.id, width: t.width, height: t.height })),
40
- edges: [...o.values()],
48
+ const v = await S.layout({
49
+ id: e ?? T,
50
+ children: d.map((o) => ({ id: o.id, width: o.width, height: o.height })),
51
+ edges: [...s.values()],
41
52
  layoutOptions: {
42
- "elk.algorithm": o.size ? "layered" : "rectpacking",
43
- "elk.direction": n.direction ?? "RIGHT",
53
+ "elk.algorithm": s.size ? "layered" : "rectpacking",
54
+ "elk.direction": E,
44
55
  "elk.edgeRouting": "ORTHOGONAL",
45
56
  "elk.separateConnectedComponents": "true",
46
- "elk.aspectRatio": String(n.aspectRatio),
47
- "elk.spacing.componentComponent": String(n.spacing ?? 64),
48
- "elk.spacing.nodeNode": String(n.spacing ?? 64),
49
- "elk.layered.spacing.nodeNodeBetweenLayers": String(n.spacing ?? 64),
57
+ ...i.aspectRatio !== void 0 ? { "elk.aspectRatio": String(i.aspectRatio) } : {},
58
+ "elk.spacing.componentComponent": String(i.spacing ?? 64),
59
+ "elk.spacing.nodeNode": String(i.spacing ?? 64),
60
+ "elk.layered.spacing.nodeNodeBetweenLayers": String(i.spacing ?? 64),
50
61
  "elk.layered.considerModelOrder.strategy": "NODES_AND_EDGES",
51
- "elk.padding": e ? `[top=${g.top},left=${g.left},bottom=${g.bottom},right=${g.right}]` : "[top=12,left=12,bottom=12,right=12]",
62
+ "elk.padding": e ? `[top=${k.top},left=${k.left},bottom=${k.bottom},right=${k.right}]` : "[top=12,left=12,bottom=12,right=12]",
52
63
  "elk.randomSeed": "1"
53
64
  }
54
65
  });
55
- for (const t of c.children ?? []) {
56
- const s = a.get(t.id);
57
- p(s, (t.x ?? 0) - s.x, (t.y ?? 0) - s.y);
66
+ for (const o of v.children ?? []) {
67
+ const a = y.get(o.id);
68
+ I(a, (o.x ?? 0) - a.x, (o.y ?? 0) - a.y);
58
69
  }
59
- return { width: c.width ?? 0, height: c.height ?? 0 };
60
- }, S = await m(), f = !n.positions?.length && n.anchor && a.get(n.anchor.nodeId);
61
- if (f) {
62
- const e = n.anchor.position.x - f.x, i = n.anchor.position.y - f.y;
63
- for (const o of r.get(void 0) ?? []) p(o, e, i);
70
+ return { width: v.width ?? 0, height: v.height ?? 0 };
71
+ }, u = await G(), R = (!i.positions?.length || i.positionMode === "compact" || i.layers) && i.anchor && y.get(i.anchor.nodeId);
72
+ if (R) {
73
+ const e = i.anchor.position.x - R.x, d = i.anchor.position.y - R.y;
74
+ for (const s of m.get(void 0) ?? []) I(s, e, d);
64
75
  }
65
- const u = {
66
- nodes: [...a.values()],
67
- edges: d.edges.map((e) => ({ ...e, sections: [] })),
68
- bounds: { x: 0, y: 0, ...S }
76
+ const C = {
77
+ nodes: [...y.values()],
78
+ edges: f.edges.map((e) => ({ ...e, sections: [] })),
79
+ bounds: { x: 0, y: 0, ...u }
69
80
  };
70
- return n.positions?.length ? b(u, n, d.nodes) : G(u);
81
+ return i.positions?.length && i.positionMode !== "compact" && !i.layers ? $(C, i, f.nodes) : P(C);
82
+ }
83
+ function z(f, i, S, y, O) {
84
+ const m = S.direction ?? "RIGHT", p = m === "RIGHT" || m === "LEFT", T = m === "RIGHT" || m === "DOWN", k = new Map(f.map((t, n) => [t.id, n])), E = new Map(
85
+ (S.positions ?? []).filter((t) => k.has(t.nodeId)).map((t) => [t.nodeId, p ? t.y : t.x])
86
+ ), w = (t, n) => k.get(t) - k.get(n) || t.localeCompare(n), I = (t, n) => (E.get(t) ?? 1 / 0) - (E.get(n) ?? 1 / 0) || w(t, n), x = new Map(f.map((t) => [t.id, /* @__PURE__ */ new Set()]));
87
+ for (const t of i.edges) {
88
+ const n = y(t.source, void 0)?.id, r = y(t.target, void 0)?.id;
89
+ n && r && n !== r && (x.get(n)?.add(r), x.get(r)?.add(n));
90
+ }
91
+ const G = S.layers ?? [], u = /* @__PURE__ */ new Map();
92
+ G.forEach((t, n) => t.forEach((r) => u.set(r, n)));
93
+ const R = new Set(f.map((t) => t.id)), C = [];
94
+ for (const t of [...R].sort(w)) {
95
+ if (!R.has(t)) continue;
96
+ const n = [], r = [t];
97
+ R.delete(t);
98
+ for (let c = 0; c < r.length; c++) {
99
+ const g = r[c];
100
+ n.push(g);
101
+ for (const h of [...x.get(g)].sort(w))
102
+ R.delete(h) && r.push(h);
103
+ }
104
+ C.push(n);
105
+ }
106
+ let e = G.length;
107
+ for (const t of C) {
108
+ const n = t.filter((g) => u.has(g));
109
+ if (!n.length) {
110
+ t.sort(w).forEach((g) => u.set(g, e)), e++;
111
+ continue;
112
+ }
113
+ const r = /* @__PURE__ */ new Map(), c = [...n].sort((g, h) => u.get(g) - u.get(h) || w(g, h));
114
+ for (const g of c) r.set(g, 0);
115
+ for (let g = 0; g < c.length; g++) {
116
+ const h = c[g];
117
+ for (const l of [...x.get(h)].sort(w))
118
+ r.has(l) || (r.set(l, r.get(h) + 1), u.set(l, u.get(h)), c.push(l));
119
+ }
120
+ }
121
+ const d = Math.max(G.length, e), s = Array.from({ length: d }, () => []);
122
+ for (const t of f) s[u.get(t.id)].push(t);
123
+ for (const t of s) t.sort((n, r) => I(n.id, r.id));
124
+ const v = (t, n) => {
125
+ const r = new Map(s[n].map((h, l) => [h.id, l])), c = new Map(s[t].map((h, l) => [h.id, l])), g = (h) => {
126
+ const l = [...x.get(h) ?? []].flatMap((N) => {
127
+ const b = r.get(N);
128
+ return u.get(N) === n && b !== void 0 ? [b] : [];
129
+ });
130
+ return l.length ? l.reduce((N, b) => N + b, 0) / l.length : c.get(h);
131
+ };
132
+ s[t].sort((h, l) => g(h.id) - g(l.id) || I(h.id, l.id));
133
+ };
134
+ for (let t = 1; t < s.length; t++) v(t, t - 1);
135
+ for (let t = s.length - 2; t >= 0; t--) v(t, t + 1);
136
+ const o = S.spacing ?? 64;
137
+ let a = 0, M = 0;
138
+ const H = [], L = [];
139
+ for (const t of s) {
140
+ let n = 0;
141
+ const r = Math.max(0, ...t.map((c) => p ? c.width : c.height));
142
+ H.push(a), L.push(r);
143
+ for (const c of t) {
144
+ const g = a + (r - (p ? c.width : c.height)) / 2, h = p ? g : n, l = p ? n : g;
145
+ O(c, h - c.x, l - c.y), n += (p ? c.height : c.width) + o;
146
+ }
147
+ M = Math.max(M, Math.max(0, n - o)), a += r + o;
148
+ }
149
+ if (a = Math.max(0, a - o), !T)
150
+ for (const t of f) {
151
+ const n = u.get(t.id), c = a - H[n] - L[n] + (L[n] - (p ? t.width : t.height)) / 2;
152
+ O(t, p ? c - t.x : 0, p ? 0 : c - t.y);
153
+ }
154
+ return p ? { width: a, height: M } : { width: M, height: a };
71
155
  }
72
156
  export {
73
- O as computePackedGraphLayout
157
+ j as computePackedGraphLayout
74
158
  };
@@ -1,5 +1,4 @@
1
1
  import type { GraphLayout, GraphLayoutOptions, GraphNode } from './types';
2
+ export { routeGraphGeometry } from './routing';
2
3
  /** Apply explicit fixed or preferred positions, then route the resulting geometry once. */
3
- export declare function applyGraphPositions(layout: GraphLayout, options: GraphLayoutOptions, input: readonly GraphNode[]): GraphLayout;
4
- /** Shared routing and bounds for explicit positions and packed compound geometry. */
5
- export declare function routeGraphGeometry(layout: GraphLayout): GraphLayout;
4
+ export declare function applyGraphPositions(layout: GraphLayout, options: GraphLayoutOptions, input: readonly GraphNode[]): GraphLayout | Promise<GraphLayout>;