@logicplanes/kaeso-ui 0.6.0-rc.1 → 0.6.0-rc.2

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.
@@ -7,11 +7,11 @@ import { c as i } from "../chunks/menu-CRZ-O7Ok.js";
7
7
  import { r as a } from "../chunks/status-dot-BJ_xdPOz.js";
8
8
  import { forwardRef as o, useCallback as s, useEffect as c, useId as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
9
9
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
10
- import { Add01Icon as ee, ArrowExpand01Icon as te, MinusSignIcon as ne, MoreHorizontalIcon as re } from "@hugeicons/core-free-icons";
11
- var g = 176, _ = 40, v = 24, y = 12, b = 176, x = 44, S = 104, C = (e, t) => e ? t ? {
10
+ import { Add01Icon as g, ArrowExpand01Icon as ee, MinusSignIcon as te, MoreHorizontalIcon as ne } from "@hugeicons/core-free-icons";
11
+ var _ = 176, v = 40, y = 24, b = 12, x = (e, t) => e ? t ? {
12
12
  l: Math.min(e.l, t.l),
13
13
  r: Math.max(e.r, t.r)
14
- } : e : t ?? null, w = (e, t) => t < e.contour.length ? e.contour[t] ?? null : e.tail, T = (e, t) => t === 0 ? e : {
14
+ } : e : t ?? null, S = (e, t) => t < e.contour.length ? e.contour[t] ?? null : e.tail, C = (e, t) => t === 0 ? e : {
15
15
  items: e.items.map((e) => ({
16
16
  ...e,
17
17
  x: e.x + t
@@ -25,26 +25,21 @@ var g = 176, _ = 40, v = 24, y = 12, b = 176, x = 44, S = 104, C = (e, t) => e ?
25
25
  r: e.tail.r + t
26
26
  }
27
27
  };
28
- function E(e, t) {
28
+ function re(e, t) {
29
29
  let n = Math.max(e.contour.length, t.contour.length) + 1, r = -Infinity;
30
30
  for (let i = 0; i < n; i++) {
31
- let n = w(e, i), a = w(t, i);
32
- n && a && (r = Math.max(r, n.r - a.l + _));
31
+ let n = S(e, i), a = S(t, i);
32
+ n && a && (r = Math.max(r, n.r - a.l + v));
33
33
  }
34
34
  return r === -Infinity ? 0 : r;
35
35
  }
36
- function D(e) {
37
- let t = Infinity;
38
- for (let n of e.contour.slice(1)) t = Math.min(t, n.l);
39
- return e.tail && (t = Math.min(t, e.tail.l)), t;
40
- }
41
- function O(e) {
36
+ function ie(e) {
42
37
  let t = [], n = null, r = [];
43
- for (let t of e) r.push(...t.items), n = C(n, t.tail);
38
+ for (let t of e) r.push(...t.items), n = x(n, t.tail);
44
39
  let i = Math.max(0, ...e.map((e) => e.contour.length));
45
40
  for (let n = 0; n < i; n++) {
46
41
  let r = null;
47
- for (let t of e) r = C(r, w(t, n));
42
+ for (let t of e) r = x(r, S(t, n));
48
43
  t.push(r ?? {
49
44
  l: 0,
50
45
  r: 0
@@ -56,11 +51,11 @@ function O(e) {
56
51
  tail: n
57
52
  };
58
53
  }
59
- function k(e, t) {
54
+ function ae(e, t) {
60
55
  return t.node ? t.node.id : `${e}::${t.id}`;
61
56
  }
62
- function A(e, t, n, r) {
63
- let i = k(t, n);
57
+ function w(e, t, n, r) {
58
+ let i = ae(t, n);
64
59
  return e.order.push(i), e.placed.set(i, {
65
60
  key: i,
66
61
  kind: "slot",
@@ -75,7 +70,7 @@ function A(e, t, n, r) {
75
70
  children: []
76
71
  }), i;
77
72
  }
78
- function j(e, t, n, r, i) {
73
+ function T(e, t, n, r, i) {
79
74
  let a = e.id, o = e.children ?? [];
80
75
  t.order.push(a), t.placed.set(a, {
81
76
  key: a,
@@ -88,56 +83,14 @@ function j(e, t, n, r, i) {
88
83
  node: e,
89
84
  edge: r,
90
85
  parent: n,
91
- children: o.map((e) => k(a, e))
86
+ children: o.map((e) => ae(a, e))
92
87
  });
93
88
  let s = {
94
89
  l: -120,
95
90
  r: 120
96
- };
97
- if (e.terminal) {
98
- let e = o[0];
99
- if (!e) return {
100
- items: [{
101
- key: a,
102
- x: 0,
103
- level: 0
104
- }],
105
- contour: [s],
106
- tail: null
107
- };
108
- if (!e.node) {
109
- let n = A(t, a, e, i + 1);
110
- return {
111
- items: [{
112
- key: a,
113
- x: 0,
114
- level: 0
115
- }, {
116
- key: n,
117
- x: b,
118
- level: 0
119
- }],
120
- contour: [{
121
- l: s.l,
122
- r: 188
123
- }],
124
- tail: null
125
- };
126
- }
127
- let n = j(e.node, t, a, e, i + 1), r = T(n, Math.max(368, s.l - D(n)));
128
- return {
129
- items: [{
130
- key: a,
131
- x: 0,
132
- level: 0
133
- }, ...r.items],
134
- contour: [C(s, r.contour[0]), ...r.contour.slice(1)],
135
- tail: r.tail
136
- };
137
- }
138
- let c = o.map((e) => e.node ? j(e.node, t, a, e, i + 1) : {
91
+ }, c = o.map((e) => e.node ? T(e.node, t, a, e, i + 1) : {
139
92
  items: [{
140
- key: A(t, a, e, i + 1),
93
+ key: w(t, a, e, i + 1),
141
94
  x: 0,
142
95
  level: 0
143
96
  }],
@@ -148,14 +101,14 @@ function j(e, t, n, r, i) {
148
101
  tail: null
149
102
  }), l = [], u = null;
150
103
  for (let e of c) {
151
- let t = u ? T(e, E(u, e)) : e;
152
- l.push(t), u = u ? O([u, t]) : t;
104
+ let t = u ? C(e, re(u, e)) : e;
105
+ l.push(t), u = u ? ie([u, t]) : t;
153
106
  }
154
107
  if (l.length > 0) {
155
108
  let e = l.map((e) => e.items[0].x), t = -(e[0] + e[e.length - 1]) / 2;
156
- l = l.map((e) => T(e, t));
109
+ l = l.map((e) => C(e, t));
157
110
  }
158
- let d = l.length > 0 ? O(l) : null;
111
+ let d = l.length > 0 ? ie(l) : null;
159
112
  return {
160
113
  items: [{
161
114
  key: a,
@@ -169,95 +122,78 @@ function j(e, t, n, r, i) {
169
122
  tail: d?.tail ?? null
170
123
  };
171
124
  }
172
- var M = (e) => Math.round(e * 2) / 2;
173
- function N(e, t, n, r, i) {
125
+ var E = (e) => Math.round(e * 2) / 2;
126
+ function D(e, t, n, r, i) {
174
127
  if (Math.abs(n - e) < 1) return `M${e} ${t}V${r}`;
175
- let a = n > e ? 1 : -1, o = Math.min(y, Math.abs(n - e) / 2, Math.abs(i - t), Math.abs(r - i));
128
+ let a = n > e ? 1 : -1, o = Math.min(b, Math.abs(n - e) / 2, Math.abs(i - t), Math.abs(r - i));
176
129
  return `M${e} ${t}V${i - o}Q${e} ${i} ${e + a * o} ${i}H${n - a * o}Q${n} ${i} ${n} ${i + o}V${r}`;
177
130
  }
178
- function ie(e, { editing: t = !0 } = {}) {
179
- let n = {
131
+ function oe(e) {
132
+ let t = {
180
133
  placed: /* @__PURE__ */ new Map(),
181
134
  order: []
182
- }, r = j(e, n, null, void 0, 0);
183
- for (let e of r.items) {
184
- let t = n.placed.get(e.key);
185
- t.x = M(e.x), t.y = t.kind === "slot" ? e.level * g + 28 : e.level * g;
135
+ }, n = T(e, t, null, void 0, 0);
136
+ for (let e of n.items) {
137
+ let n = t.placed.get(e.key);
138
+ n.x = E(e.x), n.y = n.kind === "slot" ? e.level * _ + 28 : e.level * _;
186
139
  }
187
- let i = n.placed, a = [], o = 0, s = Infinity, c = -Infinity;
188
- for (let e of i.values()) o = Math.max(o, e.y + e.h), s = Math.min(s, e.x - e.w / 2), c = Math.max(c, e.x + e.w / 2);
189
- let l = (e) => e.label !== void 0 && e.label !== null && e.label !== "";
190
- for (let e of n.order) {
191
- let n = i.get(e);
192
- if (n.parent === null) continue;
193
- let r = i.get(n.parent), o = n.edge, s = o.variant ?? "default";
194
- if (r.node?.terminal) {
195
- let i = r.y + 40, c = r.x + 120, u = n.kind === "node", d = u && l(o) ? {
196
- x: c + (t ? x : 64),
197
- y: i
198
- } : null, f = u ? {
199
- x: c + (d ? S : 64),
200
- y: i
201
- } : null;
202
- a.push({
203
- key: `wire:${e}`,
204
- from: r.key,
205
- to: e,
206
- d: `M${c} ${i}H${n.x - n.w / 2}`,
207
- variant: s,
208
- label: o.label,
209
- labelAt: d,
210
- insertAt: f,
211
- edge: o
212
- });
213
- continue;
214
- }
215
- let c = n.y, u = r.y + 80 + v, d = N(r.x, r.y + 80, n.x, c, u), f = Math.abs(n.x - r.x) < 1 ? r.y + 80 : u, p = c - f, m = l(o) ? {
216
- x: n.x,
217
- y: M(f + Math.min(22, p / 3))
218
- } : null, h = n.kind === "node" ? {
219
- x: n.x,
220
- y: M(m ? c - 20 : f + p / 2)
140
+ let r = t.placed;
141
+ for (let e of t.order) {
142
+ let t = r.get(e), n = t.parent === null ? void 0 : r.get(t.parent);
143
+ t.kind === "slot" && n?.node?.terminal && (t.y = n.y + 80 + 32);
144
+ }
145
+ let i = [], a = 0, o = Infinity, s = -Infinity;
146
+ for (let e of r.values()) a = Math.max(a, e.y + e.h), o = Math.min(o, e.x - e.w / 2), s = Math.max(s, e.x + e.w / 2);
147
+ let c = (e) => e.label !== void 0 && e.label !== null && e.label !== "";
148
+ for (let e of t.order) {
149
+ let t = r.get(e);
150
+ if (t.parent === null) continue;
151
+ let n = r.get(t.parent), a = t.edge, o = a.variant ?? "default", s = t.y, l = n.y + 80 + y, u = D(n.x, n.y + 80, t.x, s, l), d = Math.abs(t.x - n.x) < 1 ? n.y + 80 : l, f = s - d, p = t.kind === "node" && c(a) ? {
152
+ x: t.x,
153
+ y: E(d + Math.min(22, f / 3))
154
+ } : null, m = t.kind === "node" ? {
155
+ x: t.x,
156
+ y: E(p ? s - 20 : d + f / 2)
221
157
  } : null;
222
- a.push({
158
+ i.push({
223
159
  key: `wire:${e}`,
224
- from: r.key,
160
+ from: n.key,
225
161
  to: e,
226
- d,
227
- variant: s,
228
- label: o.label,
229
- labelAt: m,
230
- insertAt: h,
231
- edge: o
162
+ d: u,
163
+ variant: o,
164
+ label: a.label,
165
+ labelAt: p,
166
+ insertAt: m,
167
+ edge: a
232
168
  });
233
169
  }
234
170
  return {
235
- items: i,
236
- order: n.order,
237
- wires: a,
171
+ items: r,
172
+ order: t.order,
173
+ wires: i,
238
174
  bounds: {
239
- minX: s,
240
- maxX: c,
175
+ minX: o,
176
+ maxX: s,
241
177
  minY: 0,
242
- maxY: o
178
+ maxY: a
243
179
  }
244
180
  };
245
181
  }
246
182
  //#endregion
247
183
  //#region src/components/flow-canvas/flow-canvas.tsx
248
- var ae = {
184
+ var se = {
249
185
  success: "var(--k-success-text)",
250
186
  warning: "var(--k-warning-text)",
251
187
  danger: "var(--k-danger-text)"
252
- }, oe = {
188
+ }, ce = {
253
189
  danger: "ring-invalid",
254
190
  warning: "ring-warning",
255
191
  success: "ring-success",
256
192
  neutral: void 0
257
- }, se = { background: {
193
+ }, le = { background: {
258
194
  dots: { classes: "flow-canvas-dots" },
259
195
  plain: { classes: "" }
260
- } }, P = { background: "dots" }, F = [
196
+ } }, O = { background: "dots" }, k = [
261
197
  .25,
262
198
  .33,
263
199
  .5,
@@ -266,13 +202,13 @@ var ae = {
266
202
  1,
267
203
  1.2,
268
204
  1.5
269
- ], I = .25, ce = 1.5, le = .67, L = 48, R = 64, z = 24, ue = 16, de = 4, B = (e) => Math.min(ce, Math.max(I, e)), fe = (e, t) => t > 0 ? F.find((t) => t > e + .001) ?? ce : [...F].reverse().find((t) => t < e - .001) ?? I, V = (e) => Math.round(e * 100) / 100;
205
+ ], A = .25, j = 1.5, M = .67, N = 48, P = 64, F = 24, ue = 16, de = 4, I = (e) => Math.min(j, Math.max(A, e)), fe = (e, t) => t > 0 ? k.find((t) => t > e + .001) ?? j : [...k].reverse().find((t) => t < e - .001) ?? A, L = (e) => Math.round(e * 100) / 100;
270
206
  function pe(e, t, n) {
271
- let r = t > 256 ? R : 0, i = t - r, a = e.maxX - e.minX + 96, o = e.maxY - e.minY + 96, s = i > 0 && n > 0 ? Math.min(1, i / a, n / o) : 1, c = B(Math.max(le, s)), l = c * a <= i ? r + i / 2 - c * (e.minX + e.maxX) / 2 : Math.min(r + L * c - c * e.minX, Math.max(r + i - L * c - c * e.maxX, r + i / 2));
207
+ let r = t > 256 ? P : 0, i = t - r, a = e.maxX - e.minX + 96, o = e.maxY - e.minY + 96, s = i > 0 && n > 0 ? Math.min(1, i / a, n / o) : 1, c = I(Math.max(M, s)), l = c * a <= i ? r + i / 2 - c * (e.minX + e.maxX) / 2 : Math.min(r + N * c - c * e.minX, Math.max(r + i - N * c - c * e.maxX, r + i / 2));
272
208
  return {
273
209
  k: c,
274
210
  x: Math.round(l),
275
- y: Math.round(L * c - e.minY * c)
211
+ y: Math.round(N * c - e.minY * c)
276
212
  };
277
213
  }
278
214
  function me(e) {
@@ -291,131 +227,135 @@ function he(e, t) {
291
227
  return r && r in t ? /* @__PURE__ */ m("span", { children: t[r] }, n) : e;
292
228
  });
293
229
  }
294
- var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.kind == "string" ? e.kind : void 0) : void 0, H = /* @__PURE__ */ o(function({ root: o, selected: g = null, onSelect: _, addMenu: v, nodeActions: y, onDelete: b, trace: x, busy: S, background: C = "dots", className: w, "aria-label": T }, E) {
295
- let D = t(), O = `k-flow-hint-${l().replace(/[^\w-]/g, "")}`, k = !!v, A = d(() => k ? o : me(o), [o, k]), j = d(() => ie(A, { editing: k }), [A, k]), M = d(() => x ? new Set(x) : null, [x]), N = f(null), P = f(/* @__PURE__ */ new Map()), [F, le] = p({
230
+ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.kind == "string" ? e.kind : void 0) : void 0, R = /* @__PURE__ */ o(function({ root: o, selected: _ = null, onSelect: v, addMenu: y, nodeActions: b, onDelete: x, trace: S, busy: C, background: re = "dots", className: ie, "aria-label": ae }, w) {
231
+ let T = t(), E = `k-flow-hint-${l().replace(/[^\w-]/g, "")}`, D = !!y, O = d(() => D ? o : me(o), [o, D]), k = d(() => oe(O), [O]), M = d(() => S ? new Set(S) : null, [S]), P = f(null), R = f(/* @__PURE__ */ new Map()), [z, _e] = p({
296
232
  w: 0,
297
233
  h: 0
298
- }), R = f(F);
299
- R.current = F;
300
- let [H, U] = p({
234
+ }), B = f(z);
235
+ B.current = z;
236
+ let [V, H] = p({
301
237
  x: 0,
302
- y: L,
238
+ y: N,
303
239
  k: 1
304
- }), W = f(!1), [G, K] = p(null), [_e, ve] = p(null), [ye, be] = p(!1), q = f(/* @__PURE__ */ new Map()), J = f(null);
240
+ }), ve = f(!1), [U, ye] = p(null), [be, xe] = p(null), [Se, Ce] = p(!1), W = f(/* @__PURE__ */ new Map()), G = f(null);
305
241
  u(() => {
306
- let e = N.current;
242
+ let e = P.current;
307
243
  if (!e) return;
308
- let t = () => le({
244
+ let t = () => _e({
309
245
  w: e.clientWidth,
310
246
  h: e.clientHeight
311
247
  });
312
248
  return t(), n([e], t);
313
249
  }, []), u(() => {
314
- W.current || F.w === 0 || F.h === 0 || (W.current = !0, U(pe(j.bounds, F.w, F.h)));
315
- }, [j, F]);
316
- let xe = s((e, t, n) => {
317
- U((r) => {
318
- let i = B(r.k * e), a = i / r.k;
250
+ ve.current || z.w === 0 || z.h === 0 || (ve.current = !0, H(pe(k.bounds, z.w, z.h)));
251
+ }, [k, z]);
252
+ let we = s((e, t, n) => {
253
+ H((r) => {
254
+ let i = I(r.k * e), a = i / r.k;
319
255
  return {
320
256
  k: i,
321
- x: V(t - (t - r.x) * a),
322
- y: V(n - (n - r.y) * a)
257
+ x: L(t - (t - r.x) * a),
258
+ y: L(n - (n - r.y) * a)
323
259
  };
324
260
  });
325
- }, []), Y = s((e) => U((t) => {
326
- let n = fe(t.k, e), r = R.current.w / 2, i = R.current.h / 2;
261
+ }, []), K = s((e) => H((t) => {
262
+ let n = fe(t.k, e), r = B.current.w / 2, i = B.current.h / 2;
327
263
  return {
328
264
  k: n,
329
- x: V(r - (r - t.x) * n / t.k),
330
- y: V(i - (i - t.y) * n / t.k)
265
+ x: L(r - (r - t.x) * n / t.k),
266
+ y: L(i - (i - t.y) * n / t.k)
331
267
  };
332
- }), []), Se = s(() => U(pe(j.bounds, R.current.w, R.current.h)), [j]), Ce = s((e) => {
333
- let t = j.items.get(e);
334
- t && U((e) => {
335
- let { w: n, h: r } = R.current;
268
+ }), []), Te = s(() => H(pe(k.bounds, B.current.w, B.current.h)), [k]), q = s((e) => {
269
+ let t = k.items.get(e);
270
+ t && H((e) => {
271
+ let { w: n, h: r } = B.current;
336
272
  if (n === 0 || r === 0) return e;
337
273
  let i = e.x + (t.x - t.w / 2) * e.k, a = e.x + (t.x + t.w / 2) * e.k, o = e.y + t.y * e.k, s = e.y + (t.y + t.h) * e.k, c = 0, l = 0;
338
- return i < z ? c = z - i : a > n - z && (c = Math.max(n - z - a, z - i)), o < z ? l = z - o : s > r - z && (l = Math.max(r - z - s, z - o)), c === 0 && l === 0 ? e : {
274
+ return i < F ? c = F - i : a > n - F && (c = Math.max(n - F - a, F - i)), o < F ? l = F - o : s > r - F && (l = Math.max(r - F - s, F - o)), c === 0 && l === 0 ? e : {
339
275
  ...e,
340
- x: V(e.x + c),
341
- y: V(e.y + l)
276
+ x: L(e.x + c),
277
+ y: L(e.y + l)
342
278
  };
343
279
  });
344
- }, [j]), we = f(Ce);
345
- we.current = Ce, c(() => {
346
- g && we.current(g);
347
- }, [g]), c(() => {
348
- let e = N.current;
280
+ }, [k]), J = f(q);
281
+ J.current = q, c(() => {
282
+ _ && J.current(_);
283
+ }, [_]);
284
+ let Y = S?.[S.length - 1];
285
+ c(() => {
286
+ Y && J.current(Y);
287
+ }, [Y]), c(() => {
288
+ let e = P.current;
349
289
  if (!e) return;
350
290
  let t = (t) => {
351
291
  t.preventDefault();
352
292
  let n = t.deltaMode === 1 ? ue : t.deltaMode === 2 ? e.clientHeight : 1;
353
293
  if (t.ctrlKey || t.metaKey) {
354
294
  let r = e.getBoundingClientRect();
355
- xe(Math.exp(-t.deltaY * n * .01), t.clientX - r.left, t.clientY - r.top);
356
- } else U((e) => ({
295
+ we(Math.exp(-t.deltaY * n * .01), t.clientX - r.left, t.clientY - r.top);
296
+ } else H((e) => ({
357
297
  ...e,
358
- x: V(e.x - t.deltaX * n),
359
- y: V(e.y - t.deltaY * n)
298
+ x: L(e.x - t.deltaX * n),
299
+ y: L(e.y - t.deltaY * n)
360
300
  }));
361
301
  };
362
302
  return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
363
- }, [xe]);
364
- let Te = () => {
365
- let [e, t] = [...q.current.values()];
303
+ }, [we]);
304
+ let Ee = () => {
305
+ let [e, t] = [...W.current.values()];
366
306
  if (!e) {
367
- J.current = null;
307
+ G.current = null;
368
308
  return;
369
309
  }
370
310
  let n = t ? {
371
311
  d: Math.hypot(t.x - e.x, t.y - e.y) || 1,
372
- k: H.k
312
+ k: V.k
373
313
  } : null, r = t ? (e.x + t.x) / 2 : e.x, i = t ? (e.y + t.y) / 2 : e.y;
374
- J.current = {
314
+ G.current = {
375
315
  x: r,
376
316
  y: i,
377
- view: H,
378
- moved: J.current?.moved ?? !1,
317
+ view: V,
318
+ moved: G.current?.moved ?? !1,
379
319
  pinch: n
380
320
  };
381
- }, Ee = (e) => {
382
- e.currentTarget.contains(e.target) && (e.target.closest("[data-flow-interactive]") || (e.pointerType !== "mouse" || e.button === 0) && (e.currentTarget.setPointerCapture?.(e.pointerId), q.current.set(e.pointerId, {
321
+ }, De = (e) => {
322
+ e.currentTarget.contains(e.target) && (e.target.closest("[data-flow-interactive]") || (e.pointerType !== "mouse" || e.button === 0) && (e.currentTarget.setPointerCapture?.(e.pointerId), W.current.set(e.pointerId, {
383
323
  x: e.clientX,
384
324
  y: e.clientY
385
- }), Te()));
386
- }, De = (e) => {
387
- if (!q.current.has(e.pointerId)) return;
388
- q.current.set(e.pointerId, {
325
+ }), Ee()));
326
+ }, Oe = (e) => {
327
+ if (!W.current.has(e.pointerId)) return;
328
+ W.current.set(e.pointerId, {
389
329
  x: e.clientX,
390
330
  y: e.clientY
391
331
  });
392
- let t = J.current;
332
+ let t = G.current;
393
333
  if (!t) return;
394
- let [n, r] = [...q.current.values()];
334
+ let [n, r] = [...W.current.values()];
395
335
  if (t.pinch && n && r) {
396
- let i = e.currentTarget.getBoundingClientRect(), a = B(t.pinch.k * (Math.hypot(r.x - n.x, r.y - n.y) / t.pinch.d)), o = (n.x + r.x) / 2 - i.left, s = (n.y + r.y) / 2 - i.top, c = a / t.view.k, l = t.x - i.left, u = t.y - i.top;
397
- t.moved = !0, U({
336
+ let i = e.currentTarget.getBoundingClientRect(), a = I(t.pinch.k * (Math.hypot(r.x - n.x, r.y - n.y) / t.pinch.d)), o = (n.x + r.x) / 2 - i.left, s = (n.y + r.y) / 2 - i.top, c = a / t.view.k, l = t.x - i.left, u = t.y - i.top;
337
+ t.moved = !0, H({
398
338
  k: a,
399
- x: V(o - (l - t.view.x) * c),
400
- y: V(s - (u - t.view.y) * c)
339
+ x: L(o - (l - t.view.x) * c),
340
+ y: L(s - (u - t.view.y) * c)
401
341
  });
402
342
  return;
403
343
  }
404
344
  if (!n) return;
405
345
  let i = n.x - t.x, a = n.y - t.y;
406
- !t.moved && Math.abs(i) + Math.abs(a) < de || (t.moved || be(!0), t.moved = !0, U({
346
+ !t.moved && Math.abs(i) + Math.abs(a) < de || (t.moved || Ce(!0), t.moved = !0, H({
407
347
  ...t.view,
408
- x: V(t.view.x + i),
409
- y: V(t.view.y + a)
348
+ x: L(t.view.x + i),
349
+ y: L(t.view.y + a)
410
350
  }));
411
- }, Oe = (e) => {
412
- if (!q.current.delete(e.pointerId)) return;
413
- let t = J.current?.moved ?? !1;
414
- q.current.size > 0 ? Te() : (J.current = null, be(!1), !t && e.type === "pointerup" && _?.(null));
415
- }, ke = G && j.items.has(G) ? G : g && j.items.has(g) ? g : A.id, Ae = (e) => {
416
- e && (K(e), P.current.get(e)?.focus({ preventScroll: !0 }), Ce(e));
417
- }, je = (e, t) => {
418
- let n = t.parent ? j.items.get(t.parent).children : [t.key], r = n.indexOf(t.key), i;
351
+ }, ke = (e) => {
352
+ if (!W.current.delete(e.pointerId)) return;
353
+ let t = G.current?.moved ?? !1;
354
+ W.current.size > 0 ? Ee() : (G.current = null, Ce(!1), !t && e.type === "pointerup" && v?.(null));
355
+ }, Ae = U && k.items.has(U) ? U : _ && k.items.has(_) ? _ : O.id, je = (e) => {
356
+ e && (ye(e), R.current.get(e)?.focus({ preventScroll: !0 }), q(e));
357
+ }, Me = (e, t) => {
358
+ let n = t.parent ? k.items.get(t.parent).children : [t.key], r = n.indexOf(t.key), i;
419
359
  switch (e.key) {
420
360
  case "ArrowDown":
421
361
  i = t.children[0];
@@ -430,62 +370,62 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
430
370
  i = n[r + 1];
431
371
  break;
432
372
  case "Home":
433
- i = A.id;
373
+ i = O.id;
434
374
  break;
435
375
  case "End":
436
- i = j.order[j.order.length - 1];
376
+ i = k.order[k.order.length - 1];
437
377
  break;
438
378
  case "Escape":
439
- if (g === null) return;
440
- e.preventDefault(), _?.(null);
379
+ if (_ === null) return;
380
+ e.preventDefault(), v?.(null);
441
381
  return;
442
382
  case "+":
443
383
  case "=":
444
- e.preventDefault(), Y(1);
384
+ e.preventDefault(), K(1);
445
385
  return;
446
386
  case "-":
447
- e.preventDefault(), Y(-1);
387
+ e.preventDefault(), K(-1);
448
388
  return;
449
389
  case "0":
450
- e.preventDefault(), Se();
390
+ e.preventDefault(), Te();
451
391
  return;
452
392
  default:
453
393
  if (t.kind !== "node") return;
454
- e.key === "Enter" || e.key === " " ? (e.preventDefault(), _?.(t.key)) : (e.key === "Delete" || e.key === "Backspace") && b ? (e.preventDefault(), b(t.key)) : (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey) && y?.(t.key) && (e.preventDefault(), ve(t.key));
394
+ e.key === "Enter" || e.key === " " ? (e.preventDefault(), v?.(t.key)) : (e.key === "Delete" || e.key === "Backspace") && x ? (e.preventDefault(), x(t.key)) : (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey) && b?.(t.key) && (e.preventDefault(), xe(t.key));
455
395
  return;
456
396
  }
457
- e.preventDefault(), Ae(i);
458
- }, Me = (e) => (t) => {
459
- t ? P.current.set(e, t) : P.current.delete(e);
460
- }, Ne = (e) => {
461
- let t = j.items.get(e);
462
- return t?.kind === "slot" ? t.edge?.addLabel ?? D("flowCanvas.add", "Add a step") : t?.node?.title;
463
- }, Pe = (e, t) => ({
397
+ e.preventDefault(), je(i);
398
+ }, Ne = (e) => (t) => {
399
+ t ? R.current.set(e, t) : R.current.delete(e);
400
+ }, Pe = (e) => {
401
+ let t = k.items.get(e);
402
+ return t?.kind === "slot" ? t.edge?.addLabel ?? T("flowCanvas.add", "Add a step") : t?.node?.title;
403
+ }, Fe = (e, t) => ({
464
404
  left: e.x - e.w / 2,
465
405
  top: e.y,
466
406
  width: e.w,
467
407
  height: e.h,
468
408
  ...t
469
- }), Fe = (e, t) => g !== null && (e === g || t === g), X = (e, t) => !M || M.has(e) && M.has(t), Z = (e) => e.edge?.tone && X(e.from, e.to) ? e.edge.tone : void 0, Ie = (e) => {
409
+ }), Ie = (e, t) => _ !== null && (e === _ || t === _), X = (e, t) => !M || M.has(e) && M.has(t), Z = (e) => e.edge?.tone && X(e.from, e.to) ? e.edge.tone : void 0, Le = (e) => {
470
410
  let t = Z(e);
471
- return t ? ae[t] : M ? X(e.from, e.to) ? "var(--k-text)" : "var(--k-line)" : Fe(e.from, e.to) ? "var(--k-text-secondary)" : "var(--k-text-tertiary)";
472
- }, Q = (e) => !!M && X(e.from, e.to), Le = [...j.wires].sort((e, t) => Number(Q(e)) + Number(!!Z(e)) - (Number(Q(t)) + Number(!!Z(t)))), Re = {
473
- "--k-flow-dot-gap": `${V(ue * H.k)}px`,
474
- "--k-flow-dot-x": `${H.x}px`,
475
- "--k-flow-dot-y": `${H.y}px`
476
- }, $ = { transform: `translate(${H.x}px, ${H.y}px) scale(${H.k})` }, ze = D("flowCanvas.connection", "{from} to {to}"), Be = D("flowCanvas.connectionLabelled", "{from} to {to}, {label}");
411
+ return t ? se[t] : M ? X(e.from, e.to) ? "var(--k-text)" : "var(--k-line)" : Ie(e.from, e.to) ? "var(--k-text-secondary)" : "var(--k-text-tertiary)";
412
+ }, Q = (e) => !!M && X(e.from, e.to), Re = [...k.wires].sort((e, t) => Number(Q(e)) + Number(!!Z(e)) - (Number(Q(t)) + Number(!!Z(t)))), ze = {
413
+ "--k-flow-dot-gap": `${L(ue * V.k)}px`,
414
+ "--k-flow-dot-x": `${V.x}px`,
415
+ "--k-flow-dot-y": `${V.y}px`
416
+ }, $ = { transform: `translate(${V.x}px, ${V.y}px) scale(${V.k})` }, Be = T("flowCanvas.connection", "{from} to {to}"), Ve = T("flowCanvas.connectionLabelled", "{from} to {to}, {label}");
477
417
  return /* @__PURE__ */ h("div", {
478
418
  ref: (e) => {
479
- N.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
419
+ P.current = e, typeof w == "function" ? w(e) : w && (w.current = e);
480
420
  },
481
421
  "data-flow-canvas": "",
482
- ...ye ? { "data-dragging": "" } : {},
483
- className: e("relative h-full min-h-0 w-full touch-none overflow-hidden bg-panel select-none cursor-grab dragging:cursor-grabbing", se.background[C].classes, w),
484
- style: Re,
485
- onPointerDown: Ee,
486
- onPointerMove: De,
487
- onPointerUp: Oe,
488
- onPointerCancel: Oe,
422
+ ...Se ? { "data-dragging": "" } : {},
423
+ className: e("relative h-full min-h-0 w-full touch-none overflow-hidden bg-panel select-none cursor-grab dragging:cursor-grabbing", le.background[re].classes, ie),
424
+ style: ze,
425
+ onPointerDown: De,
426
+ onPointerMove: Oe,
427
+ onPointerUp: ke,
428
+ onPointerCancel: ke,
489
429
  children: [
490
430
  /* @__PURE__ */ h("div", {
491
431
  "aria-hidden": !0,
@@ -495,15 +435,15 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
495
435
  className: "absolute top-0 left-0 overflow-visible",
496
436
  width: 1,
497
437
  height: 1,
498
- children: Le.map((e) => {
499
- let t = Z(e), n = !!S && Q(e) && !t;
438
+ children: Re.map((e) => {
439
+ let t = Z(e), n = !!C && Q(e) && !t;
500
440
  return /* @__PURE__ */ m("path", {
501
441
  "data-flow-wire": e.key,
502
442
  ...t ? { "data-tone": t } : {},
503
443
  ...n ? { "data-flowing": "" } : {},
504
444
  d: e.d,
505
445
  fill: "none",
506
- stroke: Ie(e),
446
+ stroke: Le(e),
507
447
  strokeWidth: Q(e) ? 2 : 1.5,
508
448
  strokeLinecap: "round",
509
449
  strokeLinejoin: "round",
@@ -511,7 +451,7 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
511
451
  ...e.variant === "fallback" || n ? { strokeDasharray: "4 5" } : {}
512
452
  }, e.key);
513
453
  })
514
- }), j.wires.map((t) => t.labelAt && /* @__PURE__ */ m("span", {
454
+ }), k.wires.map((t) => t.labelAt && /* @__PURE__ */ m("span", {
515
455
  "data-flow-label": t.to,
516
456
  className: e("absolute flex h-20 -translate-x-1/2 -translate-y-1/2 items-center rounded-pill bg-panel px-8 text-caption font-medium whitespace-nowrap text-fg-secondary shadow-ring", !X(t.from, t.to) && "text-fg-tertiary"),
517
457
  style: {
@@ -521,10 +461,10 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
521
461
  children: t.label
522
462
  }, `label:${t.key}`))]
523
463
  }),
524
- v && /* @__PURE__ */ m("div", {
464
+ y && /* @__PURE__ */ m("div", {
525
465
  className: "pointer-events-none absolute top-0 left-0 origin-top-left",
526
466
  style: $,
527
- children: j.wires.map((e) => e.insertAt && e.edge && /* @__PURE__ */ m("span", {
467
+ children: k.wires.map((e) => e.insertAt && e.edge && /* @__PURE__ */ m("span", {
528
468
  "data-flow-interactive": "",
529
469
  className: "pointer-events-auto absolute -translate-x-1/2 -translate-y-1/2",
530
470
  style: {
@@ -532,14 +472,14 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
532
472
  top: e.insertAt.y
533
473
  },
534
474
  children: /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ m(i.Trigger, { children: /* @__PURE__ */ m(r, {
535
- icon: ee,
475
+ icon: g,
536
476
  variant: "secondary",
537
477
  size: "xs",
538
478
  tabIndex: -1,
539
- "aria-label": e.edge.insertLabel ?? D("flowCanvas.insert", "Insert a step here")
479
+ "aria-label": e.edge.insertLabel ?? T("flowCanvas.insert", "Insert a step here")
540
480
  }) }), /* @__PURE__ */ m(i.Content, {
541
481
  align: "center",
542
- children: v({
482
+ children: y({
543
483
  edge: e.edge.id,
544
484
  insert: !0
545
485
  })
@@ -548,56 +488,56 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
548
488
  }),
549
489
  /* @__PURE__ */ m("div", {
550
490
  role: "tree",
551
- "aria-label": T,
552
- "aria-describedby": O,
553
- "aria-busy": S || void 0,
491
+ "aria-label": ae,
492
+ "aria-describedby": E,
493
+ "aria-busy": C || void 0,
554
494
  className: "absolute top-0 left-0 origin-top-left",
555
495
  style: $,
556
- children: j.order.map((t) => {
557
- let n = j.items.get(t), o = n.level + 1, s = n.parent ? j.items.get(n.parent).children : [t], c = {
496
+ children: k.order.map((t) => {
497
+ let n = k.items.get(t), o = n.level + 1, s = n.parent ? k.items.get(n.parent).children : [t], c = {
558
498
  role: "treeitem",
559
499
  "aria-level": o,
560
500
  "aria-setsize": s.length,
561
501
  "aria-posinset": s.indexOf(t) + 1,
562
- tabIndex: ke === t ? 0 : -1,
502
+ tabIndex: Ae === t ? 0 : -1,
563
503
  "data-flow-item": t,
564
504
  "data-flow-interactive": "",
565
- onFocus: () => K(t),
566
- onKeyDown: (e) => je(e, n)
505
+ onFocus: () => ye(t),
506
+ onKeyDown: (e) => Me(e, n)
567
507
  };
568
508
  if (n.kind === "slot") {
569
509
  let e = n.edge;
570
510
  return /* @__PURE__ */ m("span", {
571
511
  className: "absolute flex items-center justify-center",
572
- style: Pe(n),
512
+ style: Fe(n),
573
513
  children: /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ m(i.Trigger, { children: /* @__PURE__ */ m(r, {
574
- ref: Me(t),
514
+ ref: Ne(t),
575
515
  ...c,
576
516
  "aria-selected": !1,
577
- icon: ee,
517
+ icon: g,
578
518
  variant: "secondary",
579
519
  size: "xs",
580
- "aria-label": e.addLabel ?? D("flowCanvas.add", "Add a step")
520
+ "aria-label": e.addLabel ?? T("flowCanvas.add", "Add a step")
581
521
  }) }), /* @__PURE__ */ m(i.Content, {
582
522
  align: "start",
583
- children: v({
523
+ children: y({
584
524
  edge: e.id,
585
525
  insert: !1
586
526
  })
587
527
  })] })
588
528
  }, t);
589
529
  }
590
- let l = n.node, u = !!M && !M.has(t), d = y?.(t), f = ge(l) ?? "";
530
+ let l = n.node, u = !!M && !M.has(t), d = b?.(t), f = ge(l) ?? "";
591
531
  return /* @__PURE__ */ h("div", {
592
- ref: Me(t),
532
+ ref: Ne(t),
593
533
  ...c,
594
- "aria-selected": g === t,
534
+ "aria-selected": _ === t,
595
535
  ...d ? { "aria-haspopup": "menu" } : {},
596
536
  ...l["data-force"] ? { "data-force": l["data-force"] } : {},
597
537
  ...M ? { "data-trace": M.has(t) ? "on" : "off" } : {},
598
- onClick: () => _?.(t),
599
- className: e("absolute flex cursor-pointer flex-col justify-center gap-2 rounded-well bg-panel px-12 py-10 text-left shadow-control transition-control outline-none focus-ring", "hover:shadow-control-hover selected:bg-item-hover selected:shadow-control-selected selected:hover:shadow-control-selected forced-colors:outline-1 forced-colors:outline-solid", l.status && oe[l.status.tone], u && "shadow-ring", d && "pr-40"),
600
- style: Pe(n),
538
+ onClick: () => v?.(t),
539
+ className: e("absolute flex cursor-pointer flex-col justify-center gap-2 rounded-well bg-panel px-12 py-10 text-left shadow-control transition-control outline-none focus-ring", "hover:shadow-control-hover selected:bg-item-hover selected:shadow-control-selected selected:hover:shadow-control-selected forced-colors:outline-1 forced-colors:outline-solid", l.status && ce[l.status.tone], u && "shadow-ring", d && "pr-40"),
540
+ style: Fe(n),
601
541
  children: [
602
542
  /* @__PURE__ */ h("span", {
603
543
  className: "flex h-16 min-w-0 items-center justify-between gap-8 text-caption font-medium text-fg-tertiary",
@@ -634,16 +574,16 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
634
574
  className: "absolute top-1/2 right-8 -translate-y-1/2",
635
575
  onClick: (e) => e.stopPropagation(),
636
576
  onFocus: (e) => {
637
- e.stopPropagation(), P.current.get(t)?.focus({ preventScroll: !0 });
577
+ e.stopPropagation(), R.current.get(t)?.focus({ preventScroll: !0 });
638
578
  },
639
579
  children: /* @__PURE__ */ h(i, {
640
- open: _e === t,
641
- onOpenChange: (e) => ve(e ? t : null),
580
+ open: be === t,
581
+ onOpenChange: (e) => xe(e ? t : null),
642
582
  children: [/* @__PURE__ */ m(i.Trigger, { children: /* @__PURE__ */ m(r, {
643
- icon: re,
583
+ icon: ne,
644
584
  size: "xs",
645
585
  tabIndex: -1,
646
- "aria-label": D("flowCanvas.actionsFor", "Actions for {name}", { name: f })
586
+ "aria-label": T("flowCanvas.actionsFor", "Actions for {name}", { name: f })
647
587
  }) }), /* @__PURE__ */ m(i.Content, {
648
588
  align: "start",
649
589
  children: d
@@ -659,53 +599,53 @@ var ge = (e) => e ? e.label ?? (typeof e.title == "string" ? e.title : typeof e.
659
599
  className: "absolute bottom-24 left-24 flex flex-col gap-8",
660
600
  children: [
661
601
  /* @__PURE__ */ m(r, {
662
- icon: ee,
602
+ icon: g,
663
603
  variant: "secondary",
664
604
  tooltipSide: "right",
665
- "aria-label": D("flowCanvas.zoomIn", "Zoom in"),
666
- disabled: H.k >= ce,
667
- onClick: () => Y(1)
605
+ "aria-label": T("flowCanvas.zoomIn", "Zoom in"),
606
+ disabled: V.k >= j,
607
+ onClick: () => K(1)
668
608
  }),
669
609
  /* @__PURE__ */ m(r, {
670
- icon: ne,
610
+ icon: te,
671
611
  variant: "secondary",
672
612
  tooltipSide: "right",
673
- "aria-label": D("flowCanvas.zoomOut", "Zoom out"),
674
- disabled: H.k <= I,
675
- onClick: () => Y(-1)
613
+ "aria-label": T("flowCanvas.zoomOut", "Zoom out"),
614
+ disabled: V.k <= A,
615
+ onClick: () => K(-1)
676
616
  }),
677
617
  /* @__PURE__ */ m(r, {
678
- icon: te,
618
+ icon: ee,
679
619
  variant: "secondary",
680
620
  tooltipSide: "right",
681
- "aria-label": D("flowCanvas.fit", "Fit to view"),
682
- onClick: Se
621
+ "aria-label": T("flowCanvas.fit", "Fit to view"),
622
+ onClick: Te
683
623
  })
684
624
  ]
685
625
  }),
686
626
  /* @__PURE__ */ m("p", {
687
- id: O,
627
+ id: E,
688
628
  className: "sr-only",
689
- children: D("flowCanvas.keys", "Arrow keys move between steps, Enter selects one, plus and minus zoom, and 0 fits the view.")
629
+ children: T("flowCanvas.keys", "Arrow keys move between steps, Enter selects one, plus and minus zoom, and 0 fits the view.")
690
630
  }),
691
631
  /* @__PURE__ */ m("ul", {
692
632
  className: "sr-only",
693
- children: j.wires.map((e) => /* @__PURE__ */ m("li", { children: he(e.label ? Be : ze, {
694
- from: Ne(e.from),
695
- to: Ne(e.to),
633
+ children: k.wires.map((e) => /* @__PURE__ */ m("li", { children: he(e.label ? Ve : Be, {
634
+ from: Pe(e.from),
635
+ to: Pe(e.to),
696
636
  label: e.label
697
637
  }) }, e.key))
698
638
  })
699
639
  ]
700
640
  });
701
641
  });
702
- process.env.NODE_ENV !== "production" && (H.displayName = "FlowCanvas");
642
+ process.env.NODE_ENV !== "production" && (R.displayName = "FlowCanvas");
703
643
  //#endregion
704
644
  //#region src/components/flow-canvas/flow-workspace.tsx
705
- var U = { width: {
645
+ var z = { width: {
706
646
  default: { classes: "lg:w-400" },
707
647
  wide: { classes: "lg:w-480" }
708
- } }, W = { width: "default" }, G = /* @__PURE__ */ o(function({ children: t, panel: n, panelLabel: r, width: i = "default", className: a, ...o }, s) {
648
+ } }, _e = { width: "default" }, B = /* @__PURE__ */ o(function({ children: t, panel: n, panelLabel: r, width: i = "default", className: a, ...o }, s) {
709
649
  return /* @__PURE__ */ h("div", {
710
650
  ref: s,
711
651
  "data-flow-workspace": "",
@@ -718,13 +658,13 @@ var U = { width: {
718
658
  }), n && /* @__PURE__ */ m("aside", {
719
659
  ...r ? { "aria-label": r } : {},
720
660
  "data-flow-workspace-panel": "",
721
- className: e("relative shrink-0 max-lg:divider-t lg:min-h-0 lg:overflow-y-auto lg:overscroll-contain lg:scrollbar-quiet lg:divider-l", U.width[i].classes),
661
+ className: e("relative shrink-0 max-lg:divider-t lg:min-h-0 lg:overflow-y-auto lg:overscroll-contain lg:scrollbar-quiet lg:divider-l", z.width[i].classes),
722
662
  children: n
723
663
  })]
724
664
  });
725
665
  });
726
- process.env.NODE_ENV !== "production" && (G.displayName = "FlowWorkspace");
727
- var K = /* @__PURE__ */ o(function({ title: t, description: n, actions: r, children: i, className: a, ...o }, s) {
666
+ process.env.NODE_ENV !== "production" && (B.displayName = "FlowWorkspace");
667
+ var V = /* @__PURE__ */ o(function({ title: t, description: n, actions: r, children: i, className: a, ...o }, s) {
728
668
  let c = `k-flow-panel-${l().replace(/[^\w-]/g, "")}`;
729
669
  return /* @__PURE__ */ h("section", {
730
670
  ref: s,
@@ -754,9 +694,9 @@ var K = /* @__PURE__ */ o(function({ title: t, description: n, actions: r, child
754
694
  ]
755
695
  });
756
696
  });
757
- process.env.NODE_ENV !== "production" && (K.displayName = "FlowWorkspace.Panel");
758
- var _e = /* @__PURE__ */ Object.assign(G, { Panel: K });
697
+ process.env.NODE_ENV !== "production" && (V.displayName = "FlowWorkspace.Panel");
698
+ var H = /* @__PURE__ */ Object.assign(B, { Panel: V });
759
699
  //#endregion
760
- export { H as FlowCanvas, _e as FlowWorkspace, K as FlowWorkspacePanel, P as KAESO_FLOW_CANVAS_DEFAULT_VARIANTS, se as KAESO_FLOW_CANVAS_VARIANTS, W as KAESO_FLOW_WORKSPACE_DEFAULT_VARIANTS, U as KAESO_FLOW_WORKSPACE_VARIANTS };
700
+ export { R as FlowCanvas, H as FlowWorkspace, V as FlowWorkspacePanel, O as KAESO_FLOW_CANVAS_DEFAULT_VARIANTS, le as KAESO_FLOW_CANVAS_VARIANTS, _e as KAESO_FLOW_WORKSPACE_DEFAULT_VARIANTS, z as KAESO_FLOW_WORKSPACE_VARIANTS };
761
701
 
762
702
  //# sourceMappingURL=flow-canvas.js.map