@mcurcio/patchbay 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +8 -7
  2. package/dist/composites.css +1 -1
  3. package/dist/composites.js +573 -53
  4. package/dist/composites.js.map +1 -1
  5. package/dist/graph.css +1 -0
  6. package/dist/graph.js +696 -0
  7. package/dist/graph.js.map +1 -0
  8. package/dist/hooks.js +433 -28
  9. package/dist/hooks.js.map +1 -1
  10. package/dist/primitives.css +1 -1
  11. package/dist/primitives.js +34 -16
  12. package/dist/primitives.js.map +1 -1
  13. package/dist/tokens.css +22 -2
  14. package/dist/types/composites/command-palette/CommandPalette.d.ts +68 -0
  15. package/dist/types/composites/command-palette/index.d.ts +4 -0
  16. package/dist/types/composites/command-palette/rank.d.ts +39 -0
  17. package/dist/types/composites/index.d.ts +3 -0
  18. package/dist/types/composites/shortcut-sheet/ShortcutSheet.d.ts +41 -0
  19. package/dist/types/composites/shortcut-sheet/index.d.ts +2 -0
  20. package/dist/types/composites/toaster/Toaster.d.ts +38 -0
  21. package/dist/types/composites/toaster/index.d.ts +2 -0
  22. package/dist/types/graph/add-at/index.d.ts +2 -0
  23. package/dist/types/graph/add-at/useAddAt.d.ts +32 -0
  24. package/dist/types/graph/canvas-tools/CanvasTools.d.ts +40 -0
  25. package/dist/types/graph/canvas-tools/index.d.ts +2 -0
  26. package/dist/types/graph/canvas-tools/motion.d.ts +2 -0
  27. package/dist/types/graph/connect-hints/index.d.ts +4 -0
  28. package/dist/types/graph/connect-hints/mergeFlowProps.d.ts +10 -0
  29. package/dist/types/graph/connect-hints/useConnectHints.d.ts +48 -0
  30. package/dist/types/graph/follow-fit/index.d.ts +2 -0
  31. package/dist/types/graph/follow-fit/useFollowFit.d.ts +21 -0
  32. package/dist/types/graph/ghost-wire/GhostWire.d.ts +16 -0
  33. package/dist/types/graph/ghost-wire/index.d.ts +2 -0
  34. package/dist/types/graph/index.d.ts +9 -1
  35. package/dist/types/graph/meter/Meter.d.ts +56 -0
  36. package/dist/types/graph/meter/index.d.ts +2 -0
  37. package/dist/types/graph/node-box/NodeBox.d.ts +53 -0
  38. package/dist/types/graph/node-box/geometry.d.ts +47 -0
  39. package/dist/types/graph/node-box/index.d.ts +4 -0
  40. package/dist/types/graph/port-row/PortRow.d.ts +31 -0
  41. package/dist/types/graph/port-row/index.d.ts +2 -0
  42. package/dist/types/graph/wire/Wire.d.ts +27 -0
  43. package/dist/types/graph/wire/index.d.ts +2 -0
  44. package/dist/types/hooks/index.d.ts +4 -0
  45. package/dist/types/hooks/use-live-value/index.d.ts +2 -0
  46. package/dist/types/hooks/use-live-value/useLiveValue.d.ts +9 -0
  47. package/dist/types/hooks/use-media-breakpoint/index.d.ts +2 -0
  48. package/dist/types/hooks/use-media-breakpoint/useMediaBreakpoint.d.ts +25 -0
  49. package/dist/types/hooks/use-shortcuts/index.d.ts +2 -0
  50. package/dist/types/hooks/use-shortcuts/useShortcuts.d.ts +58 -0
  51. package/dist/types/hooks/use-toasts/index.d.ts +4 -0
  52. package/dist/types/hooks/use-toasts/toastQueue.d.ts +76 -0
  53. package/dist/types/hooks/use-toasts/useToasts.d.ts +31 -0
  54. package/dist/types/primitives/button/Button.d.ts +4 -1
  55. package/package.json +2 -2
package/dist/graph.js CHANGED
@@ -0,0 +1,696 @@
1
+ import "./graph.css";import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
2
+ import { createContext as r, memo as i, useCallback as a, useContext as o, useEffect as s, useId as c, useImperativeHandle as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
3
+ import { Badge as m, IconButton as h, ToolGroup as g, WarnMark as _ } from "./primitives.js";
4
+ import { useLiveValue as v } from "./hooks.js";
5
+ import { BaseEdge as y, EdgeLabelRenderer as b, Handle as x, MiniMap as S, Panel as C, Position as w, getBezierPath as T, useNodeId as E, useReactFlow as D, useStore as O, useStoreApi as k, useUpdateNodeInternals as A } from "@xyflow/react";
6
+ // src/graph/add-at/useAddAt.ts
7
+ var j = (e) => e instanceof Element && e.classList.contains("react-flow__pane");
8
+ function M(e) {
9
+ if ("changedTouches" in e) {
10
+ let t = e.changedTouches[0];
11
+ return t === void 0 ? null : {
12
+ x: t.clientX,
13
+ y: t.clientY
14
+ };
15
+ }
16
+ return {
17
+ x: e.clientX,
18
+ y: e.clientY
19
+ };
20
+ }
21
+ var N = ({ x: e, y: t }) => typeof document.elementFromPoint == "function" ? document.elementFromPoint(e, t) : null;
22
+ function ee(e, t = {}) {
23
+ let n = t.enabled ?? !0, { screenToFlowPosition: r } = D(), i = f({
24
+ onAddAt: e,
25
+ enabled: n,
26
+ screenToFlowPosition: r
27
+ });
28
+ u(() => {
29
+ i.current = {
30
+ onAddAt: e,
31
+ enabled: n,
32
+ screenToFlowPosition: r
33
+ };
34
+ });
35
+ let a = f(null);
36
+ return { flowProps: d(() => ({
37
+ onDoubleClick: (e) => {
38
+ let { onAddAt: t, enabled: n, screenToFlowPosition: r } = i.current;
39
+ n && j(e.target) && t(r({
40
+ x: e.clientX,
41
+ y: e.clientY
42
+ }));
43
+ },
44
+ onConnectStart: (e, { nodeId: t, handleId: n, handleType: r }) => {
45
+ a.current = t === null ? null : {
46
+ nodeId: t,
47
+ handleId: n,
48
+ side: r === "target" ? "input" : "output"
49
+ };
50
+ },
51
+ onConnectEnd: (e, t) => {
52
+ let n = a.current;
53
+ a.current = null;
54
+ let { onAddAt: r, enabled: o, screenToFlowPosition: s } = i.current;
55
+ if (!o || n === null || t.toHandle !== null) return;
56
+ let c = M(e);
57
+ c !== null && j("changedTouches" in e ? N(c) : e.target) && r(s(c), n);
58
+ },
59
+ zoomOnDoubleClick: !1
60
+ }), []) };
61
+ }
62
+ // src/graph/canvas-tools/motion.ts
63
+ var P = 180;
64
+ function F(e) {
65
+ let t = e == null ? "" : getComputedStyle(e).getPropertyValue("--pb-motion-slow"), n = /^\s*(\d+(?:\.\d+)?)(ms|s)\s*$/.exec(t);
66
+ return n === null ? typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : P : Number(n[1]) * (n[2] === "s" ? 1e3 : 1);
67
+ }
68
+ // src/graph/canvas-tools/CanvasTools.tsx
69
+ var I = {
70
+ toolbar: "Canvas",
71
+ zoomIn: "Zoom in",
72
+ zoomOut: "Zoom out",
73
+ fit: "Fit the view",
74
+ tidy: "Tidy the layout",
75
+ minimap: "Minimap"
76
+ }, L = (e) => /* @__PURE__ */ t("svg", {
77
+ viewBox: "0 0 16 16",
78
+ width: "14",
79
+ height: "14",
80
+ "aria-hidden": "true",
81
+ children: /* @__PURE__ */ t("path", {
82
+ d: e,
83
+ fill: "none",
84
+ stroke: "currentColor",
85
+ strokeWidth: "1.5",
86
+ strokeLinecap: "round",
87
+ strokeLinejoin: "round"
88
+ })
89
+ }), te = {
90
+ zoomIn: L("M3 8h10M8 3v10"),
91
+ zoomOut: L("M3 8h10"),
92
+ fit: L("M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4"),
93
+ tidy: L("M2 2h5v5H2zM9 2h5v5H9zM2 9h5v5H2zM9 9h5v5H9z"),
94
+ minimap: L("M1.5 3h13v10h-13zM8.5 8h4v3h-4z")
95
+ };
96
+ function ne({ position: r = "bottom-left", fitOptions: i, onFit: a, onTidy: o, minimap: s = !1, onMinimap: c, minimapNodeClassName: l, keyShortcuts: u, labels: d, className: f, children: p }) {
97
+ let m = {
98
+ ...I,
99
+ ...d
100
+ }, _ = D(), v = k(), y = () => F(v.getState().domNode), b = (e, n, r) => {
101
+ let i = u?.[e];
102
+ return /* @__PURE__ */ t(h, {
103
+ label: m[e],
104
+ title: i === void 0 || i === "" ? m[e] : `${m[e]} (${i})`,
105
+ "aria-keyshortcuts": i === "" ? void 0 : i,
106
+ "aria-pressed": r,
107
+ onClick: n,
108
+ children: te[e]
109
+ });
110
+ };
111
+ return /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(C, {
112
+ position: r,
113
+ className: f === void 0 ? "pb-canvas-tools" : `pb-canvas-tools ${f}`,
114
+ children: /* @__PURE__ */ n(g, {
115
+ label: m.toolbar,
116
+ children: [
117
+ b("zoomIn", () => void _.zoomIn({ duration: y() })),
118
+ b("zoomOut", () => void _.zoomOut({ duration: y() })),
119
+ b("fit", () => {
120
+ a === void 0 ? _.fitView({
121
+ ...i,
122
+ duration: y()
123
+ }) : a();
124
+ }),
125
+ o !== void 0 && b("tidy", o),
126
+ c !== void 0 && b("minimap", () => {
127
+ c(!s);
128
+ }, s),
129
+ p
130
+ ]
131
+ })
132
+ }), s && /* @__PURE__ */ t(S, {
133
+ className: "pb-canvas-minimap",
134
+ ariaLabel: m.minimap,
135
+ nodeClassName: l
136
+ })] });
137
+ }
138
+ // src/graph/connect-hints/mergeFlowProps.ts
139
+ function re(...e) {
140
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
141
+ for (let r of e) if (r !== void 0) {
142
+ for (let [e, i] of Object.entries(r)) if (i !== void 0) {
143
+ if (typeof i == "function") {
144
+ let r = n.get(e) ?? [];
145
+ r.push(i), n.set(e, r), t.delete(e);
146
+ } else t.set(e, i), n.delete(e);
147
+ }
148
+ }
149
+ let r = Object.fromEntries(t);
150
+ for (let [e, t] of n) {
151
+ let [n] = t;
152
+ r[e] = t.length === 1 && n !== void 0 ? n : e === "isValidConnection" ? (...e) => t.every((t) => t(...e) === !0) : (...e) => {
153
+ for (let n of t) n(...e);
154
+ };
155
+ }
156
+ return r;
157
+ }
158
+ // src/graph/connect-hints/useConnectHints.tsx
159
+ var R = r(null);
160
+ function ie({ value: e, children: n }) {
161
+ return /* @__PURE__ */ t(R, {
162
+ value: e,
163
+ children: n
164
+ });
165
+ }
166
+ function ae() {
167
+ return o(R);
168
+ }
169
+ var oe = (e, t) => JSON.stringify([
170
+ e.nodeId,
171
+ e.handleId,
172
+ t.nodeId,
173
+ t.handleId
174
+ ]), se = (e, t) => e.nodeId === t.nodeId && e.handleId === t.handleId;
175
+ function ce(e) {
176
+ let t = f(e);
177
+ u(() => {
178
+ t.current = e;
179
+ });
180
+ let n = f(null), [r, i] = p(null), a = d(() => (e, r) => {
181
+ let i = n.current;
182
+ if (i === null) return t.current(e, r);
183
+ let a = oe(e, r), o = i.get(a);
184
+ if (o !== void 0) return o;
185
+ let s = t.current(e, r);
186
+ return i.set(a, s), s;
187
+ }, []), o = d(() => ({
188
+ onConnectStart: (e, { nodeId: t, handleId: r, handleType: a }) => {
189
+ t !== null && (n.current = /* @__PURE__ */ new Map(), i({
190
+ nodeId: t,
191
+ handleId: r,
192
+ side: a === "target" ? "input" : "output"
193
+ }));
194
+ },
195
+ onConnectEnd: () => {
196
+ n.current = null, i(null);
197
+ },
198
+ isValidConnection: (e) => a({
199
+ nodeId: e.source,
200
+ handleId: e.sourceHandle ?? null
201
+ }, {
202
+ nodeId: e.target,
203
+ handleId: e.targetHandle ?? null
204
+ }) === !0
205
+ }), [a]);
206
+ return {
207
+ value: d(() => r === null ? null : {
208
+ origin: r,
209
+ hintFor: (e, t) => {
210
+ if (t === r.side) return { hint: se(e, r) ? "origin" : null };
211
+ let n = {
212
+ nodeId: r.nodeId,
213
+ handleId: r.handleId
214
+ }, i = t === "input" ? a(n, e) : a(e, n);
215
+ return i === !0 ? { hint: "ok" } : typeof i == "string" ? {
216
+ hint: "no",
217
+ reason: i
218
+ } : { hint: "no" };
219
+ }
220
+ }, [r, a]),
221
+ flowProps: o
222
+ };
223
+ }
224
+ // src/graph/follow-fit/useFollowFit.ts
225
+ var z = (e) => {
226
+ for (let t of e.nodeLookup.values()) if (t.hidden !== !0 && (t.measured.width === void 0 || t.measured.height === void 0)) return !1;
227
+ return !0;
228
+ };
229
+ function B({ key: e, fitOptions: t, onFitted: n }) {
230
+ let r = D(), i = k(), o = O((e) => e.width), c = O((e) => e.height), l = O(z), [m, h] = p(!0), g = f({
231
+ key: e,
232
+ width: o,
233
+ height: c,
234
+ fitOptions: t,
235
+ onFitted: n
236
+ });
237
+ u(() => {
238
+ g.current = {
239
+ key: e,
240
+ width: o,
241
+ height: c,
242
+ fitOptions: t,
243
+ onFitted: n
244
+ };
245
+ });
246
+ let _ = f(null), v = a(async (e) => {
247
+ i.getState().nodeLookup.size > 0 && await r.fitView({
248
+ ...g.current.fitOptions,
249
+ duration: e
250
+ }), requestAnimationFrame(() => {
251
+ g.current.onFitted?.(r.getViewport());
252
+ });
253
+ }, [r, i]);
254
+ return s(() => {
255
+ if (!m || o === 0 || c === 0 || !z(i.getState())) return;
256
+ let t = _.current;
257
+ t !== null && Object.is(t.key, e) && t.width === o && t.height === c || (_.current = {
258
+ key: e,
259
+ width: o,
260
+ height: c
261
+ }, v(0));
262
+ }, [
263
+ m,
264
+ e,
265
+ o,
266
+ c,
267
+ l,
268
+ i,
269
+ v
270
+ ]), {
271
+ following: m,
272
+ fit: a(() => {
273
+ let e = g.current;
274
+ _.current = {
275
+ key: e.key,
276
+ width: e.width,
277
+ height: e.height
278
+ }, h(!0), v(F(i.getState().domNode));
279
+ }, [v, i]),
280
+ flowProps: d(() => ({ onMoveStart: (e) => {
281
+ e !== null && h(!1);
282
+ } }), [])
283
+ };
284
+ }
285
+ // src/graph/ghost-wire/GhostWire.tsx
286
+ function V({ id: r, sourceX: i, sourceY: a, targetX: o, targetY: s, sourcePosition: c, targetPosition: l, data: u }) {
287
+ let [f, p, m] = d(() => T({
288
+ sourceX: i,
289
+ sourceY: a,
290
+ sourcePosition: c,
291
+ targetX: o,
292
+ targetY: s,
293
+ targetPosition: l
294
+ }), [
295
+ i,
296
+ a,
297
+ c,
298
+ o,
299
+ s,
300
+ l
301
+ ]), h = u?.tone === "refused" ? "refused" : "pending", g = u?.label;
302
+ return /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("g", {
303
+ className: "pb-ghost-wire",
304
+ "data-tone": h,
305
+ "aria-hidden": "true",
306
+ children: /* @__PURE__ */ t(y, {
307
+ id: r,
308
+ path: f,
309
+ className: "pb-ghost-wire-path",
310
+ interactionWidth: 0
311
+ })
312
+ }), g != null && /* @__PURE__ */ t(b, { children: /* @__PURE__ */ t("div", {
313
+ className: "pb-ghost-wire-label",
314
+ "data-tone": h,
315
+ style: { transform: `translate(-50%, -50%) translate(${p}px, ${m}px)` },
316
+ children: g
317
+ }) })] });
318
+ }
319
+ // src/graph/meter/Meter.tsx
320
+ var H = {
321
+ floor: -60,
322
+ zones: [-18, -6],
323
+ holdMs: 1500,
324
+ fallDbPerS: 20,
325
+ clipAt: 1,
326
+ clipHoldMs: 2e3
327
+ }, U = 250;
328
+ function W(e) {
329
+ return Number.isFinite(e) && e > 0 ? 20 * Math.log10(e) : e === Infinity ? Infinity : -Infinity;
330
+ }
331
+ function G(e, t) {
332
+ return Number.isNaN(e) || t >= 0 ? 0 : Math.min(1, Math.max(0, (e - t) / -t));
333
+ }
334
+ var K = (e) => e === -Infinity ? "−∞" : e.toFixed(1), q = (e, t) => `peak ${K(e)} dB, rms ${K(t)} dB`, J = () => ({
335
+ peakDb: -Infinity,
336
+ rmsDb: -Infinity,
337
+ heldDb: -Infinity,
338
+ heldAt: -Infinity,
339
+ clippedAt: -Infinity
340
+ });
341
+ function le(e) {
342
+ let t = null, n = e, r = J(), i, a = !1, o = -Infinity, s = !1, c = (e) => {
343
+ let t = Math.max(0, e - r.heldAt - n.holdMs), i = t === 0 ? r.heldDb : r.heldDb - Math.max(0, n.fallDbPerS) * t / 1e3;
344
+ return Math.max(r.peakDb, i);
345
+ }, l = (e) => {
346
+ if (t === null) return;
347
+ let i = e - r.clippedAt < n.clipHoldMs;
348
+ t.title = n.title(r.peakDb, r.rmsDb, i), o = e, s = !1;
349
+ }, u = (e) => {
350
+ if (t === null) return !1;
351
+ let i = c(e), u = e - r.clippedAt < n.clipHoldMs;
352
+ return t.style.setProperty("--pb-meter-level", String(G(r.rmsDb, n.floor))), t.style.setProperty("--pb-meter-tick", String(G(i, n.floor))), t.dataset.peak = i > n.floor ? "shown" : "hidden", t.dataset.clipped = String(u), a && e - o >= 250 && l(e), i > r.peakDb && i > n.floor || u || a && s;
353
+ }, d = () => {
354
+ i = void 0, u(performance.now()) && (i = requestAnimationFrame(d));
355
+ }, f = () => {
356
+ i === void 0 && t !== null && (i = requestAnimationFrame(d));
357
+ }, p = () => {
358
+ i !== void 0 && cancelAnimationFrame(i), i = void 0;
359
+ };
360
+ return {
361
+ attach(e) {
362
+ t = e, e === null ? p() : f();
363
+ },
364
+ setScale(e) {
365
+ let t = e.floor !== n.floor || e.holdMs !== n.holdMs || e.fallDbPerS !== n.fallDbPerS || e.clipHoldMs !== n.clipHoldMs;
366
+ n = e, t && f();
367
+ },
368
+ take: ([e, t]) => {
369
+ let i = performance.now(), a = W(e), o = c(i);
370
+ r.peakDb = a, r.rmsDb = W(t), a >= o && (r.heldDb = a, r.heldAt = i), e >= n.clipAt && (r.clippedAt = i), s = !0, f();
371
+ },
372
+ reset: () => {
373
+ r = J(), p();
374
+ let e = performance.now();
375
+ u(e), a && l(e);
376
+ },
377
+ hover(e) {
378
+ a = e, e && l(performance.now());
379
+ }
380
+ };
381
+ }
382
+ function ue({ subscribe: e, read: r, orientation: i = "horizontal", floor: o = H.floor, zones: s = H.zones, holdMs: c = H.holdMs, fallDbPerS: d = H.fallDbPerS, clipAt: f = H.clipAt, clipHoldMs: m = H.clipHoldMs, label: h = "Level", title: g = q, ref: _, className: y, style: b, onPointerEnter: x, onPointerLeave: S, ...C }) {
383
+ let [w] = p(() => le({
384
+ floor: o,
385
+ holdMs: c,
386
+ fallDbPerS: d,
387
+ clipAt: f,
388
+ clipHoldMs: m,
389
+ title: g
390
+ }));
391
+ u(() => {
392
+ w.setScale({
393
+ floor: o,
394
+ holdMs: c,
395
+ fallDbPerS: d,
396
+ clipAt: f,
397
+ clipHoldMs: m,
398
+ title: g
399
+ });
400
+ });
401
+ let T = a((e) => {
402
+ w.attach(e);
403
+ }, [w]);
404
+ v(e, r, w.take), l(_, () => ({ reset: w.reset }), [w]);
405
+ let [E, D] = s, O = y === void 0 ? "pb-meter" : `pb-meter ${y}`, k = {
406
+ ...b,
407
+ "--pb-meter-mid-at": String(G(E, o)),
408
+ "--pb-meter-hot-at": String(G(D, o))
409
+ };
410
+ return /* @__PURE__ */ n("div", {
411
+ ...C,
412
+ ref: T,
413
+ className: O,
414
+ role: "img",
415
+ "aria-label": h,
416
+ "data-orientation": i,
417
+ "data-peak": "hidden",
418
+ "data-clipped": "false",
419
+ style: k,
420
+ onPointerEnter: (e) => {
421
+ w.hover(!0), x?.(e);
422
+ },
423
+ onPointerLeave: (e) => {
424
+ w.hover(!1), S?.(e);
425
+ },
426
+ children: [/* @__PURE__ */ n("span", {
427
+ className: "pb-meter-track",
428
+ "aria-hidden": "true",
429
+ children: [/* @__PURE__ */ t("span", { className: "pb-meter-bar" }), /* @__PURE__ */ t("span", { className: "pb-meter-peak" })]
430
+ }), /* @__PURE__ */ t("span", {
431
+ className: "pb-meter-lamp",
432
+ "aria-hidden": "true"
433
+ })]
434
+ });
435
+ }
436
+ // src/graph/port-row/PortRow.tsx
437
+ var de = [
438
+ "ok",
439
+ "no",
440
+ "origin"
441
+ ];
442
+ function Y({ id: e, side: r, label: i, typeLabel: a, hint: o, reason: s, problem: c, trailing: l, connectable: u = !0 }) {
443
+ let d = r !== "output", f = ae(), p = E(), m = o === void 0 && f !== null && p !== null ? f.hintFor({
444
+ nodeId: p,
445
+ handleId: e
446
+ }, d ? "input" : "output") : void 0, h = m === void 0 ? o ?? null : m.hint, g = m === void 0 ? s : m.reason ?? s, v = h !== null && de.includes(h) ? h : void 0, y = v === "no" && g !== void 0 ? g : void 0;
447
+ return /* @__PURE__ */ n("div", {
448
+ className: "pb-port-row",
449
+ "data-side": d ? "input" : "output",
450
+ "data-hint": v,
451
+ title: y ?? (typeof i == "string" ? i : void 0),
452
+ children: [
453
+ /* @__PURE__ */ t(x, {
454
+ id: e,
455
+ type: d ? "target" : "source",
456
+ position: d ? w.Left : w.Right,
457
+ isConnectable: u,
458
+ className: "pb-port-handle",
459
+ "data-hint": v,
460
+ title: y
461
+ }),
462
+ /* @__PURE__ */ n("span", {
463
+ className: "pb-port-words",
464
+ children: [
465
+ /* @__PURE__ */ t("span", {
466
+ className: "pb-port-label",
467
+ children: i
468
+ }),
469
+ a !== void 0 && /* @__PURE__ */ t("code", {
470
+ className: "pb-port-type",
471
+ children: a
472
+ }),
473
+ c !== void 0 && /* @__PURE__ */ t(_, {
474
+ label: c,
475
+ title: c
476
+ })
477
+ ]
478
+ }),
479
+ l !== void 0 && /* @__PURE__ */ t("span", {
480
+ className: "pb-port-trailing",
481
+ children: l
482
+ })
483
+ ]
484
+ });
485
+ }
486
+ // src/graph/node-box/NodeBox.tsx
487
+ var X = {
488
+ added: "added",
489
+ removed: "removed",
490
+ renamed: "renamed",
491
+ changed: "changed"
492
+ }, fe = [
493
+ "added",
494
+ "removed",
495
+ "renamed",
496
+ "changed"
497
+ ];
498
+ function pe({ title: e, subtitle: r, tone: i, disabled: a = !1, failed: o = !1, change: s, changeLabels: l, status: u, line: d, inputs: f = [], outputs: p = [], ports: h = "stacked", footer: g, selected: _ = !1, width: v, className: y, style: b, ...x }) {
499
+ let S = c(), C = h === "side-by-side" ? "side-by-side" : "stacked";
500
+ me(f, p, C);
501
+ let w = {
502
+ ...X,
503
+ ...l
504
+ }, T = s === void 0 ? void 0 : fe.includes(s) ? w[s] : s, E = f.length > 0 || p.length > 0, D = f.map((e) => /* @__PURE__ */ t(Y, {
505
+ ...e,
506
+ side: "input"
507
+ }, e.id)), O = p.map((e) => /* @__PURE__ */ t(Y, {
508
+ ...e,
509
+ side: "output"
510
+ }, e.id));
511
+ return /* @__PURE__ */ n("div", {
512
+ ...x,
513
+ className: y === void 0 ? "pb-node-box" : `pb-node-box ${y}`,
514
+ role: "group",
515
+ "aria-labelledby": S,
516
+ "data-tone": i,
517
+ "data-change": s,
518
+ "data-disabled": a ? "" : void 0,
519
+ "data-failed": o ? "" : void 0,
520
+ "data-selected": _ ? "" : void 0,
521
+ style: v === void 0 ? b : {
522
+ ...b,
523
+ width: `${v}px`
524
+ },
525
+ children: [
526
+ /* @__PURE__ */ n("div", {
527
+ className: "pb-node-header",
528
+ children: [
529
+ /* @__PURE__ */ n("div", {
530
+ className: "pb-node-heading",
531
+ children: [/* @__PURE__ */ t("span", {
532
+ id: S,
533
+ className: "pb-node-title",
534
+ title: typeof e == "string" ? e : void 0,
535
+ children: e
536
+ }), r !== void 0 && /* @__PURE__ */ t("span", {
537
+ className: "pb-node-subtitle",
538
+ children: r
539
+ })]
540
+ }),
541
+ T !== void 0 && /* @__PURE__ */ t(m, {
542
+ tone: s ?? "",
543
+ className: "pb-node-change",
544
+ children: T
545
+ }),
546
+ u !== void 0 && /* @__PURE__ */ t("div", {
547
+ className: "pb-node-status",
548
+ children: u
549
+ })
550
+ ]
551
+ }),
552
+ d !== void 0 && /* @__PURE__ */ t("div", {
553
+ className: "pb-node-line",
554
+ title: typeof d == "string" ? d : void 0,
555
+ children: d
556
+ }),
557
+ E && (C === "side-by-side" ? /* @__PURE__ */ n("div", {
558
+ className: "pb-node-ports",
559
+ "data-ports": "side-by-side",
560
+ children: [/* @__PURE__ */ t("div", {
561
+ className: "pb-node-column",
562
+ "data-side": "input",
563
+ children: D
564
+ }), /* @__PURE__ */ t("div", {
565
+ className: "pb-node-column",
566
+ "data-side": "output",
567
+ children: O
568
+ })]
569
+ }) : /* @__PURE__ */ n("div", {
570
+ className: "pb-node-ports",
571
+ "data-ports": "stacked",
572
+ children: [D, O]
573
+ })),
574
+ g !== void 0 && /* @__PURE__ */ t("div", {
575
+ className: "pb-node-footer",
576
+ children: g
577
+ })
578
+ ]
579
+ });
580
+ }
581
+ function me(e, t, n) {
582
+ let r = E(), i = A(), a = JSON.stringify([
583
+ n,
584
+ e.map((e) => e.id),
585
+ t.map((e) => e.id)
586
+ ]), o = f(a);
587
+ s(() => {
588
+ o.current !== a && (o.current = a, r !== null && i(r));
589
+ }, [
590
+ a,
591
+ r,
592
+ i
593
+ ]);
594
+ }
595
+ // src/graph/node-box/geometry.ts
596
+ var he = 240, ge = 46, _e = 22, ve = 22, ye = 8, be = 28, xe = 10, Se = 20;
597
+ function Z(e, t, n) {
598
+ return n === "side-by-side" ? Math.max(e, t) : e + t;
599
+ }
600
+ function Ce({ inputs: e, outputs: t, ports: n, line: r, footer: i, width: a = 240 }) {
601
+ let o = Z(Math.max(0, e), Math.max(0, t), n);
602
+ return {
603
+ width: a,
604
+ height: 46 + (r ? 22 : 0) + (o > 0 ? 16 + o * 22 : 0) + (i ? 28 : 0)
605
+ };
606
+ }
607
+ // src/graph/wire/Wire.tsx
608
+ var Q = 8, $ = 4;
609
+ function we(e) {
610
+ return typeof e != "number" || Number.isNaN(e) ? 0 : Math.min(1, Math.max(0, e));
611
+ }
612
+ function Te(e, t, n) {
613
+ let r = n === w.Left ? -1 : +(n === w.Right), i = n === w.Top ? -1 : +(n === w.Bottom), a = e + r * Q, o = t + i * Q, s = -i * $, c = r * $;
614
+ return `M ${e} ${t} L ${a + s} ${o + c} L ${a - s} ${o - c} Z`;
615
+ }
616
+ var Ee = i(function({ id: r, path: i, flow: a, arrow: o, title: s, interactionWidth: c, markerStart: l, markerEnd: u, style: d }) {
617
+ return /* @__PURE__ */ n(e, { children: [
618
+ /* @__PURE__ */ t(y, {
619
+ id: r,
620
+ path: i,
621
+ className: "pb-wire-path",
622
+ interactionWidth: 0,
623
+ markerStart: l,
624
+ markerEnd: u,
625
+ style: d
626
+ }),
627
+ a && /* @__PURE__ */ t("path", {
628
+ d: i,
629
+ fill: "none",
630
+ className: "pb-wire-flow",
631
+ "aria-hidden": "true"
632
+ }),
633
+ o !== void 0 && /* @__PURE__ */ t("path", {
634
+ d: o,
635
+ className: "pb-wire-arrow",
636
+ "aria-hidden": "true"
637
+ }),
638
+ c > 0 && /* @__PURE__ */ t("path", {
639
+ d: i,
640
+ fill: "none",
641
+ strokeOpacity: 0,
642
+ strokeWidth: c,
643
+ className: "react-flow__edge-interaction",
644
+ children: s !== void 0 && /* @__PURE__ */ t("title", { children: s })
645
+ })
646
+ ] });
647
+ });
648
+ function De({ id: r, sourceX: i, sourceY: a, targetX: o, targetY: s, sourcePosition: c, targetPosition: l, data: u, selected: f, interactionWidth: p = 20, markerStart: m, markerEnd: h, style: g }) {
649
+ let [_, v, y] = d(() => T({
650
+ sourceX: i,
651
+ sourceY: a,
652
+ sourcePosition: c,
653
+ targetX: o,
654
+ targetY: s,
655
+ targetPosition: l
656
+ }), [
657
+ i,
658
+ a,
659
+ c,
660
+ o,
661
+ s,
662
+ l
663
+ ]), x = u?.arrow === !0, S = d(() => x ? Te(o, s, l) : void 0, [
664
+ x,
665
+ o,
666
+ s,
667
+ l
668
+ ]), C = u?.emphasis === void 0 ? void 0 : we(u.emphasis), w = C === void 0 ? void 0 : { "--pb-wire-emphasis": C }, E = u?.label;
669
+ return /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("g", {
670
+ className: "pb-wire",
671
+ "data-tone": u?.tone,
672
+ "data-selected": f === !0 ? "" : void 0,
673
+ "data-dashed": u?.dashed === !0 ? "" : void 0,
674
+ "data-emphasis": C === void 0 ? void 0 : "",
675
+ style: w,
676
+ children: /* @__PURE__ */ t(Ee, {
677
+ id: r,
678
+ path: _,
679
+ flow: u?.flow === !0,
680
+ arrow: S,
681
+ title: u?.title,
682
+ interactionWidth: p,
683
+ markerStart: m,
684
+ markerEnd: h,
685
+ style: g
686
+ })
687
+ }), E != null && /* @__PURE__ */ t(b, { children: /* @__PURE__ */ t("div", {
688
+ className: "pb-wire-label",
689
+ "data-tone": u?.tone,
690
+ style: { transform: `translate(-50%, -50%) translate(${v}px, ${y}px)` },
691
+ children: E
692
+ }) })] });
693
+ }
694
+ export { ne as CanvasTools, ie as ConnectHints, V as GhostWire, Se as HANDLE_HIT, xe as HANDLE_SIZE, ue as Meter, be as NODE_FOOTER, ge as NODE_HEADER, _e as NODE_LINE, ye as NODE_PAD, ve as NODE_ROW, he as NODE_WIDTH, pe as NodeBox, Y as PortRow, De as Wire, I as defaultCanvasToolsLabels, X as defaultChangeLabels, H as defaultMeterScale, q as defaultMeterTitle, re as mergeFlowProps, G as meterFraction, U as meterTitleEveryMs, Ce as nodeBoxSize, W as toDb, ee as useAddAt, ce as useConnectHints, B as useFollowFit };
695
+
696
+ //# sourceMappingURL=graph.js.map