Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

3039 lines
95 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: 09166d9658efb080.e1742a6c63.js
* Module id: 292002
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e) => {
"use strict";
e.i(23741);
var t,
n,
o,
i,
r,
a,
s,
l,
d,
u,
c,
p,
h,
g,
f = e.i(8164),
m = e.i(692423),
y = e.i(954542),
v = e.i(816947),
w = e.i(811975);
let x = (e) => () => e;
function S(
e,
{
sourceEvent: t,
subject: n,
target: o,
identifier: i,
active: r,
x: a,
y: s,
dx: l,
dy: d,
dispatch: u,
},
) {
Object.defineProperties(this, {
type: { value: e, enumerable: !0, configurable: !0 },
sourceEvent: { value: t, enumerable: !0, configurable: !0 },
subject: { value: n, enumerable: !0, configurable: !0 },
target: { value: o, enumerable: !0, configurable: !0 },
identifier: { value: i, enumerable: !0, configurable: !0 },
active: { value: r, enumerable: !0, configurable: !0 },
x: { value: a, enumerable: !0, configurable: !0 },
y: { value: s, enumerable: !0, configurable: !0 },
dx: { value: l, enumerable: !0, configurable: !0 },
dy: { value: d, enumerable: !0, configurable: !0 },
_: { value: u },
});
}
function b(e) {
return !e.ctrlKey && !e.button;
}
function I() {
return this.parentNode;
}
function _(e, t) {
return null == t ? { x: e.x, y: e.y } : t;
}
function E() {
return navigator.maxTouchPoints || "ontouchstart" in this;
}
function M() {
var e,
t,
n,
o,
i = b,
r = I,
a = _,
s = E,
l = {},
d = (0, f.dispatch)("start", "drag", "end"),
u = 0,
c = 0;
function p(e) {
e.on("mousedown.drag", h)
.filter(s)
.on("touchstart.drag", C)
.on("touchmove.drag", N, w.nonpassive)
.on("touchend.drag touchcancel.drag", P)
.style("touch-action", "none")
.style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
}
function h(a, s) {
if (!o && i.call(this, a, s)) {
var l = k(this, r.call(this, a, s), a, s, "mouse");
l &&
((0, m.select)(a.view)
.on("mousemove.drag", g, w.nonpassivecapture)
.on("mouseup.drag", M, w.nonpassivecapture),
(0, v.default)(a.view),
(0, w.nopropagation)(a),
(n = !1),
(e = a.clientX),
(t = a.clientY),
l("start", a));
}
}
function g(o) {
if (((0, w.default)(o), !n)) {
var i = o.clientX - e,
r = o.clientY - t;
n = i * i + r * r > c;
}
l.mouse("drag", o);
}
function M(e) {
(0, m.select)(e.view).on("mousemove.drag mouseup.drag", null),
(0, v.yesdrag)(e.view, n),
(0, w.default)(e),
l.mouse("end", e);
}
function C(e, t) {
if (i.call(this, e, t)) {
var n,
o,
a = e.changedTouches,
s = r.call(this, e, t),
l = a.length;
for (n = 0; n < l; ++n)
(o = k(this, s, e, t, a[n].identifier, a[n])) &&
((0, w.nopropagation)(e), o("start", e, a[n]));
}
}
function N(e) {
var t,
n,
o = e.changedTouches,
i = o.length;
for (t = 0; t < i; ++t)
(n = l[o[t].identifier]) && ((0, w.default)(e), n("drag", e, o[t]));
}
function P(e) {
var t,
n,
i = e.changedTouches,
r = i.length;
for (
o && clearTimeout(o),
o = setTimeout(function () {
o = null;
}, 500),
t = 0;
t < r;
++t
)
(n = l[i[t].identifier]) &&
((0, w.nopropagation)(e), n("end", e, i[t]));
}
function k(e, t, n, o, i, r) {
var s,
c,
h,
g = d.copy(),
f = (0, y.pointer)(r || n, t);
if (
null !=
(h = a.call(
e,
new S("beforestart", {
sourceEvent: n,
target: p,
identifier: i,
active: u,
x: f[0],
y: f[1],
dx: 0,
dy: 0,
dispatch: g,
}),
o,
))
)
return (
(s = h.x - f[0] || 0),
(c = h.y - f[1] || 0),
function n(r, a, d) {
var m,
v = f;
switch (r) {
case "start":
(l[i] = n), (m = u++);
break;
case "end":
delete l[i], --u;
case "drag":
(f = (0, y.pointer)(d || a, t)), (m = u);
}
g.call(
r,
e,
new S(r, {
sourceEvent: a,
subject: h,
target: p,
identifier: i,
active: m,
x: f[0] + s,
y: f[1] + c,
dx: f[0] - v[0],
dy: f[1] - v[1],
dispatch: g,
}),
o,
);
}
);
}
return (
(p.filter = function (e) {
return arguments.length
? ((i = "function" == typeof e ? e : x(!!e)), p)
: i;
}),
(p.container = function (e) {
return arguments.length
? ((r = "function" == typeof e ? e : x(e)), p)
: r;
}),
(p.subject = function (e) {
return arguments.length
? ((a = "function" == typeof e ? e : x(e)), p)
: a;
}),
(p.touchable = function (e) {
return arguments.length
? ((s = "function" == typeof e ? e : x(!!e)), p)
: s;
}),
(p.on = function () {
var e = d.on.apply(d, arguments);
return e === d ? p : e;
}),
(p.clickDistance = function (e) {
return arguments.length ? ((c = (e *= 1) * e), p) : Math.sqrt(c);
}),
p
);
}
(S.prototype.on = function () {
var e = this._.on.apply(this._, arguments);
return e === this._ ? this : e;
}),
e.i(250149);
var C = e.i(953752),
C = C,
N = e.i(644200),
N = N,
P = N,
k = e.i(274017),
T = e.i(678152);
let O = {
error001: () =>
"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",
error002: () =>
"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",
error003: (e) =>
`Node type "${e}" not found. Using fallback type "default".`,
error004: () =>
"The React Flow parent container needs a width and a height to render the graph.",
error005: () => "Only child nodes can use a parent extent.",
error006: () =>
"Can't create edge. An edge needs a source and a target.",
error007: (e) => `The old edge with id=${e} does not exist.`,
error009: (e) => `Marker type "${e}" doesn't exist.`,
error008: (e, { id: t, sourceHandle: n, targetHandle: o }) =>
`Couldn't create edge for ${e} handle id: "${"source" === e ? n : o}", edge id: ${t}.`,
error010: () =>
"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",
error011: (e) =>
`Edge type "${e}" not found. Using fallback type "default".`,
error012: (e) =>
`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,
error013: (e = "react") =>
`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,
error014: () =>
"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",
error015: () =>
"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",
},
A = [
[-1 / 0, -1 / 0],
[1 / 0, 1 / 0],
],
D = ["Enter", " ", "Escape"],
L = {
"node.a11yDescription.default":
"Press enter or space to select a node. Press delete to remove it and escape to cancel.",
"node.a11yDescription.keyboardDisabled":
"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.",
"node.a11yDescription.ariaLiveMessage": ({
direction: e,
x: t,
y: n,
}) => `Moved selected node ${e}. New position, x: ${t}, y: ${n}`,
"edge.a11yDescription.default":
"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.",
"controls.ariaLabel": "Control Panel",
"controls.zoomIn.ariaLabel": "Zoom In",
"controls.zoomOut.ariaLabel": "Zoom Out",
"controls.fitView.ariaLabel": "Fit View",
"controls.interactive.ariaLabel": "Toggle Interactivity",
"minimap.ariaLabel": "Mini Map",
"handle.ariaLabel": "Handle",
};
((t = l || (l = {})).Strict = "strict"),
(t.Loose = "loose"),
((n = d || (d = {})).Free = "free"),
(n.Vertical = "vertical"),
(n.Horizontal = "horizontal"),
((o = u || (u = {})).Partial = "partial"),
(o.Full = "full");
let j = {
inProgress: !1,
isValid: null,
from: null,
fromHandle: null,
fromPosition: null,
fromNode: null,
to: null,
toHandle: null,
toPosition: null,
toNode: null,
pointer: null,
};
((i = c || (c = {})).Bezier = "default"),
(i.Straight = "straight"),
(i.Step = "step"),
(i.SmoothStep = "smoothstep"),
(i.SimpleBezier = "simplebezier"),
((r = p || (p = {})).Arrow = "arrow"),
(r.ArrowClosed = "arrowclosed"),
((a = h || (h = {})).Left = "left"),
(a.Top = "top"),
(a.Right = "right"),
(a.Bottom = "bottom");
let R = {
[h.Left]: h.Right,
[h.Right]: h.Left,
[h.Top]: h.Bottom,
[h.Bottom]: h.Top,
};
function z(e, t) {
if (!e && !t) return !0;
if (!e || !t || e.size !== t.size) return !1;
if (!e.size && !t.size) return !0;
for (let n of e.keys()) if (!t.has(n)) return !1;
return !0;
}
function F(e, t, n) {
if (!n) return;
let o = [];
e.forEach((e, n) => {
t?.has(n) || o.push(e);
}),
o.length && n(o);
}
function $(e) {
return null === e ? null : e ? "valid" : "invalid";
}
let B = (e) => "id" in e && "source" in e && "target" in e,
H = (e) =>
"id" in e && "position" in e && !("source" in e) && !("target" in e),
V = (e) =>
"id" in e && "internals" in e && !("source" in e) && !("target" in e),
U = (e, t = [0, 0]) => {
let { width: n, height: o } = ew(e),
i = e.origin ?? t,
r = n * i[0],
a = o * i[1];
return { x: e.position.x - r, y: e.position.y - a };
},
Y = (e, t = { nodeOrigin: [0, 0] }) =>
0 === e.length
? { x: 0, y: 0, width: 0, height: 0 }
: ei(
e.reduce(
(e, n) => {
let o = "string" == typeof n,
i = t.nodeLookup || o ? void 0 : n;
return (
t.nodeLookup &&
(i = o
? t.nodeLookup.get(n)
: V(n)
? n
: t.nodeLookup.get(n.id)),
en(
e,
i ? ea(i, t.nodeOrigin) : { x: 0, y: 0, x2: 0, y2: 0 },
)
);
},
{ x: 1 / 0, y: 1 / 0, x2: -1 / 0, y2: -1 / 0 },
),
),
W = (e, t = {}) => {
let n = { x: 1 / 0, y: 1 / 0, x2: -1 / 0, y2: -1 / 0 },
o = !1;
return (
e.forEach((e) => {
(void 0 === t.filter || t.filter(e)) &&
((n = en(n, ea(e))), (o = !0));
}),
o ? ei(n) : { x: 0, y: 0, width: 0, height: 0 }
);
},
X = (e, t, [n, o, i] = [0, 0, 1], r = !1, a = !1) => {
let s = {
...eh(t, [n, o, i]),
width: t.width / i,
height: t.height / i,
},
l = [];
for (let t of e.values()) {
let { measured: e, selectable: n = !0, hidden: o = !1 } = t;
if ((a && !n) || o) continue;
let i = e.width ?? t.width ?? t.initialWidth ?? null,
d = e.height ?? t.height ?? t.initialHeight ?? null,
u = el(s, er(t)),
c = (i ?? 0) * (d ?? 0),
p = r && u > 0;
(!t.internals.handleBounds || p || u >= c || t.dragging) && l.push(t);
}
return l;
};
async function K(
{ nodes: e, width: t, height: n, panZoom: o, minZoom: i, maxZoom: r },
a,
) {
let s, l;
if (0 === e.size) return Promise.resolve(!0);
let d = em(
W(
((s = new Map()),
(l = a?.nodes ? new Set(a.nodes.map((e) => e.id)) : null),
e.forEach((e) => {
e.measured.width &&
e.measured.height &&
(a?.includeHiddenNodes || !e.hidden) &&
(!l || l.has(e.id)) &&
s.set(e.id, e);
}),
s),
),
t,
n,
a?.minZoom ?? i,
a?.maxZoom ?? r,
a?.padding ?? 0.1,
);
return (
await o.setViewport(d, {
duration: a?.duration,
ease: a?.ease,
interpolate: a?.interpolate,
}),
Promise.resolve(!0)
);
}
function q({
nodeId: e,
nextPosition: t,
nodeLookup: n,
nodeOrigin: o = [0, 0],
nodeExtent: i,
onError: r,
}) {
let a = n.get(e),
s = a.parentId ? n.get(a.parentId) : void 0,
{ x: l, y: d } = s ? s.internals.positionAbsolute : { x: 0, y: 0 },
u = a.origin ?? o,
c = a.extent || i;
if ("parent" !== a.extent || a.expandParent)
s &&
ev(a.extent) &&
(c = [
[a.extent[0][0] + l, a.extent[0][1] + d],
[a.extent[1][0] + l, a.extent[1][1] + d],
]);
else if (s) {
let e = s.measured.width,
t = s.measured.height;
e &&
t &&
(c = [
[l, d],
[l + e, d + t],
]);
} else r?.("005", O.error005());
let p = ev(c) ? Q(t, c, a.measured) : t;
return (
(void 0 === a.measured.width || void 0 === a.measured.height) &&
r?.("015", O.error015()),
{
position: {
x: p.x - l + (a.measured.width ?? 0) * u[0],
y: p.y - d + (a.measured.height ?? 0) * u[1],
},
positionAbsolute: p,
}
);
}
async function Z({
nodesToRemove: e = [],
edgesToRemove: t = [],
nodes: n,
edges: o,
onBeforeDelete: i,
}) {
let r,
a = new Set(e.map((e) => e.id)),
s = [];
for (let e of n) {
if (!1 === e.deletable) continue;
let t = a.has(e.id),
n = !t && e.parentId && s.find((t) => t.id === e.parentId);
(t || n) && s.push(e);
}
let l = new Set(t.map((e) => e.id)),
d = o.filter((e) => !1 !== e.deletable),
u =
((r = new Set()),
s.forEach((e) => {
r.add(e.id);
}),
d.filter((e) => r.has(e.source) || r.has(e.target)));
for (let e of d)
l.has(e.id) && !u.find((t) => t.id === e.id) && u.push(e);
if (!i) return { edges: u, nodes: s };
let c = await i({ nodes: s, edges: u });
return "boolean" == typeof c
? c
? { edges: u, nodes: s }
: { edges: [], nodes: [] }
: c;
}
let G = (e, t = 0, n = 1) => Math.min(Math.max(e, t), n),
Q = (e = { x: 0, y: 0 }, t, n) => ({
x: G(e.x, t[0][0], t[1][0] - (n?.width ?? 0)),
y: G(e.y, t[0][1], t[1][1] - (n?.height ?? 0)),
});
function J(e, t, n) {
let { width: o, height: i } = ew(n),
{ x: r, y: a } = n.internals.positionAbsolute;
return Q(
e,
[
[r, a],
[r + o, a + i],
],
t,
);
}
let ee = (e, t, n) =>
e < t
? G(Math.abs(e - t), 1, t) / t
: e > n
? -G(Math.abs(e - n), 1, t) / t
: 0,
et = (e, t, n = 15, o = 40) => [
ee(e.x, o, t.width - o) * n,
ee(e.y, o, t.height - o) * n,
],
en = (e, t) => ({
x: Math.min(e.x, t.x),
y: Math.min(e.y, t.y),
x2: Math.max(e.x2, t.x2),
y2: Math.max(e.y2, t.y2),
}),
eo = ({ x: e, y: t, width: n, height: o }) => ({
x: e,
y: t,
x2: e + n,
y2: t + o,
}),
ei = ({ x: e, y: t, x2: n, y2: o }) => ({
x: e,
y: t,
width: n - e,
height: o - t,
}),
er = (e, t = [0, 0]) => {
let { x: n, y: o } = V(e) ? e.internals.positionAbsolute : U(e, t);
return {
x: n,
y: o,
width: e.measured?.width ?? e.width ?? e.initialWidth ?? 0,
height: e.measured?.height ?? e.height ?? e.initialHeight ?? 0,
};
},
ea = (e, t = [0, 0]) => {
let { x: n, y: o } = V(e) ? e.internals.positionAbsolute : U(e, t);
return {
x: n,
y: o,
x2: n + (e.measured?.width ?? e.width ?? e.initialWidth ?? 0),
y2: o + (e.measured?.height ?? e.height ?? e.initialHeight ?? 0),
};
},
es = (e, t) => ei(en(eo(e), eo(t))),
el = (e, t) =>
Math.ceil(
Math.max(
0,
Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x),
) *
Math.max(
0,
Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y),
),
),
ed = (e) => eu(e.width) && eu(e.height) && eu(e.x) && eu(e.y),
eu = (e) => !isNaN(e) && isFinite(e),
ec = (e, t) => {},
ep = (e, t = [1, 1]) => ({
x: t[0] * Math.round(e.x / t[0]),
y: t[1] * Math.round(e.y / t[1]),
}),
eh = ({ x: e, y: t }, [n, o, i], r = !1, a = [1, 1]) => {
let s = { x: (e - n) / i, y: (t - o) / i };
return r ? ep(s, a) : s;
},
eg = ({ x: e, y: t }, [n, o, i]) => ({ x: e * i + n, y: t * i + o });
function ef(e, t) {
if ("number" == typeof e) return Math.floor((t - t / (1 + e)) * 0.5);
if ("string" == typeof e && e.endsWith("px")) {
let t = parseFloat(e);
if (!Number.isNaN(t)) return Math.floor(t);
}
if ("string" == typeof e && e.endsWith("%")) {
let n = parseFloat(e);
if (!Number.isNaN(n)) return Math.floor(t * n * 0.01);
}
return (
console.error(
`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`,
),
0
);
}
let em = (e, t, n, o, i, r) => {
let a = (function (e, t, n) {
if ("string" == typeof e || "number" == typeof e) {
let o = ef(e, n),
i = ef(e, t);
return {
top: o,
right: i,
bottom: o,
left: i,
x: 2 * i,
y: 2 * o,
};
}
if ("object" == typeof e) {
let o = ef(e.top ?? e.y ?? 0, n),
i = ef(e.bottom ?? e.y ?? 0, n),
r = ef(e.left ?? e.x ?? 0, t),
a = ef(e.right ?? e.x ?? 0, t);
return {
top: o,
right: a,
bottom: i,
left: r,
x: r + a,
y: o + i,
};
}
return { top: 0, right: 0, bottom: 0, left: 0, x: 0, y: 0 };
})(r, t, n),
s = G(Math.min((t - a.x) / e.width, (n - a.y) / e.height), o, i),
l = e.x + e.width / 2,
d = e.y + e.height / 2,
u = t / 2 - l * s,
c = n / 2 - d * s,
p = (function (e, t, n, o, i, r) {
let { x: a, y: s } = eg(e, [t, n, o]),
{ x: l, y: d } = eg({ x: e.x + e.width, y: e.y + e.height }, [
t,
n,
o,
]);
return {
left: Math.floor(a),
top: Math.floor(s),
right: Math.floor(i - l),
bottom: Math.floor(r - d),
};
})(e, u, c, s, t, n),
h = {
left: Math.min(p.left - a.left, 0),
top: Math.min(p.top - a.top, 0),
right: Math.min(p.right - a.right, 0),
bottom: Math.min(p.bottom - a.bottom, 0),
};
return { x: u - h.left + h.right, y: c - h.top + h.bottom, zoom: s };
},
ey = () =>
"u" > typeof navigator && navigator?.userAgent?.indexOf("Mac") >= 0;
function ev(e) {
return null != e && "parent" !== e;
}
function ew(e) {
return {
width: e.measured?.width ?? e.width ?? e.initialWidth ?? 0,
height: e.measured?.height ?? e.height ?? e.initialHeight ?? 0,
};
}
function ex(e) {
return (
(e.measured?.width ?? e.width ?? e.initialWidth) !== void 0 &&
(e.measured?.height ?? e.height ?? e.initialHeight) !== void 0
);
}
function eS(e, t = { width: 0, height: 0 }, n, o, i) {
let r = { ...e },
a = o.get(n);
if (a) {
let e = a.origin || i;
(r.x += a.internals.positionAbsolute.x - (t.width ?? 0) * e[0]),
(r.y += a.internals.positionAbsolute.y - (t.height ?? 0) * e[1]);
}
return r;
}
function eb(e, t) {
if (e.size !== t.size) return !1;
for (let n of e) if (!t.has(n)) return !1;
return !0;
}
function eI() {
let e, t;
return {
promise: new Promise((n, o) => {
(e = n), (t = o);
}),
resolve: e,
reject: t,
};
}
function e_(e) {
return { ...L, ...(e || {}) };
}
function eE(
e,
{
snapGrid: t = [0, 0],
snapToGrid: n = !1,
transform: o,
containerBounds: i,
},
) {
let { x: r, y: a } = eT(e),
s = eh({ x: r - (i?.left ?? 0), y: a - (i?.top ?? 0) }, o),
{ x: l, y: d } = n ? ep(s, t) : s;
return { xSnapped: l, ySnapped: d, ...s };
}
let eM = (e) => ({ width: e.offsetWidth, height: e.offsetHeight }),
eC = (e) => e?.getRootNode?.() || window?.document,
eN = ["INPUT", "SELECT", "TEXTAREA"];
function eP(e) {
let t = e.composedPath?.()?.[0] || e.target;
return (
t?.nodeType === 1 &&
(eN.includes(t.nodeName) ||
t.hasAttribute("contenteditable") ||
!!t.closest(".nokey"))
);
}
let ek = (e) => "clientX" in e,
eT = (e, t) => {
let n = ek(e),
o = n ? e.clientX : e.touches?.[0].clientX,
i = n ? e.clientY : e.touches?.[0].clientY;
return { x: o - (t?.left ?? 0), y: i - (t?.top ?? 0) };
},
eO = (e, t, n, o, i) => {
let r = t.querySelectorAll(`.${e}`);
return r && r.length
? Array.from(r).map((t) => {
let r = t.getBoundingClientRect();
return {
id: t.getAttribute("data-handleid"),
type: e,
nodeId: i,
position: t.getAttribute("data-handlepos"),
x: (r.left - n.left) / o,
y: (r.top - n.top) / o,
...eM(t),
};
})
: null;
};
function eA({
sourceX: e,
sourceY: t,
targetX: n,
targetY: o,
sourceControlX: i,
sourceControlY: r,
targetControlX: a,
targetControlY: s,
}) {
let l = 0.125 * e + 0.375 * i + 0.375 * a + 0.125 * n,
d = 0.125 * t + 0.375 * r + 0.375 * s + 0.125 * o,
u = Math.abs(l - e),
c = Math.abs(d - t);
return [l, d, u, c];
}
function eD(e, t) {
return e >= 0 ? 0.5 * e : 25 * t * Math.sqrt(-e);
}
function eL({ pos: e, x1: t, y1: n, x2: o, y2: i, c: r }) {
switch (e) {
case h.Left:
return [t - eD(t - o, r), n];
case h.Right:
return [t + eD(o - t, r), n];
case h.Top:
return [t, n - eD(n - i, r)];
case h.Bottom:
return [t, n + eD(i - n, r)];
}
}
function ej({
sourceX: e,
sourceY: t,
sourcePosition: n = h.Bottom,
targetX: o,
targetY: i,
targetPosition: r = h.Top,
curvature: a = 0.25,
}) {
let [s, l] = eL({ pos: n, x1: e, y1: t, x2: o, y2: i, c: a }),
[d, u] = eL({ pos: r, x1: o, y1: i, x2: e, y2: t, c: a }),
[c, p, g, f] = eA({
sourceX: e,
sourceY: t,
targetX: o,
targetY: i,
sourceControlX: s,
sourceControlY: l,
targetControlX: d,
targetControlY: u,
});
return [`M${e},${t} C${s},${l} ${d},${u} ${o},${i}`, c, p, g, f];
}
function eR({ sourceX: e, sourceY: t, targetX: n, targetY: o }) {
let i = Math.abs(n - e) / 2,
r = Math.abs(o - t) / 2;
return [n < e ? n + i : n - i, o < t ? o + r : o - r, i, r];
}
function ez({
sourceNode: e,
targetNode: t,
selected: n = !1,
zIndex: o = 0,
elevateOnSelect: i = !1,
zIndexMode: r = "basic",
}) {
if ("manual" === r) return o;
let a = Math.max(
e.parentId || (i && e.selected) ? e.internals.z : 0,
t.parentId || (i && t.selected) ? t.internals.z : 0,
);
return (i && n ? o + 1e3 : o) + a;
}
function eF({
sourceNode: e,
targetNode: t,
width: n,
height: o,
transform: i,
}) {
let r = en(ea(e), ea(t));
return (
r.x === r.x2 && (r.x2 += 1),
r.y === r.y2 && (r.y2 += 1),
el(
{
x: -i[0] / i[2],
y: -i[1] / i[2],
width: n / i[2],
height: o / i[2],
},
ei(r),
) > 0
);
}
let e$ = ({ source: e, sourceHandle: t, target: n, targetHandle: o }) =>
`xy-edge__${e}${t || ""}-${n}${o || ""}`,
eB = (e, t, n = {}) => {
let o, i;
if (!e.source || !e.target) return ec("006", O.error006()), t;
let r = n.getEdgeId || e$;
return ((i = o = B(e) ? { ...e } : { ...e, id: r(e) }),
t.some(
(e) =>
e.source === i.source &&
e.target === i.target &&
(e.sourceHandle === i.sourceHandle ||
(!e.sourceHandle && !i.sourceHandle)) &&
(e.targetHandle === i.targetHandle ||
(!e.targetHandle && !i.targetHandle)),
))
? t
: (null === o.sourceHandle && delete o.sourceHandle,
null === o.targetHandle && delete o.targetHandle,
t.concat(o));
};
function eH({ sourceX: e, sourceY: t, targetX: n, targetY: o }) {
let [i, r, a, s] = eR({ sourceX: e, sourceY: t, targetX: n, targetY: o });
return [`M ${e},${t}L ${n},${o}`, i, r, a, s];
}
let eV = {
[h.Left]: { x: -1, y: 0 },
[h.Right]: { x: 1, y: 0 },
[h.Top]: { x: 0, y: -1 },
[h.Bottom]: { x: 0, y: 1 },
},
eU = ({ source: e, sourcePosition: t = h.Bottom, target: n }) =>
t === h.Left || t === h.Right
? e.x < n.x
? { x: 1, y: 0 }
: { x: -1, y: 0 }
: e.y < n.y
? { x: 0, y: 1 }
: { x: 0, y: -1 },
eY = (e, t) => Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2));
function eW({
sourceX: e,
sourceY: t,
sourcePosition: n = h.Bottom,
targetX: o,
targetY: i,
targetPosition: r = h.Top,
borderRadius: a = 5,
centerX: s,
centerY: l,
offset: d = 20,
stepPosition: u = 0.5,
}) {
let [c, p, g, f, m] = (function ({
source: e,
sourcePosition: t = h.Bottom,
target: n,
targetPosition: o = h.Top,
center: i,
offset: r,
stepPosition: a,
}) {
let s,
l,
d = eV[t],
u = eV[o],
c = { x: e.x + d.x * r, y: e.y + d.y * r },
p = { x: n.x + u.x * r, y: n.y + u.y * r },
g = eU({ source: c, sourcePosition: t, target: p }),
f = 0 !== g.x ? "x" : "y",
m = g[f],
y = [],
v = { x: 0, y: 0 },
w = { x: 0, y: 0 },
[, , x, S] = eR({
sourceX: e.x,
sourceY: e.y,
targetX: n.x,
targetY: n.y,
});
if (d[f] * u[f] == -1) {
"x" === f
? ((s = i.x ?? c.x + (p.x - c.x) * a), (l = i.y ?? (c.y + p.y) / 2))
: ((s = i.x ?? (c.x + p.x) / 2),
(l = i.y ?? c.y + (p.y - c.y) * a));
let e = [
{ x: s, y: c.y },
{ x: s, y: p.y },
],
t = [
{ x: c.x, y: l },
{ x: p.x, y: l },
];
y = d[f] === m ? ("x" === f ? e : t) : "x" === f ? t : e;
} else {
let i = [{ x: c.x, y: p.y }],
a = [{ x: p.x, y: c.y }];
if (
((y = "x" === f ? (d.x === m ? a : i) : d.y === m ? i : a), t === o)
) {
let t = Math.abs(e[f] - n[f]);
if (t <= r) {
let o = Math.min(r - 1, r - t);
d[f] === m
? (v[f] = (c[f] > e[f] ? -1 : 1) * o)
: (w[f] = (p[f] > n[f] ? -1 : 1) * o);
}
}
if (t !== o) {
let e = "x" === f ? "y" : "x",
t = d[f] === u[e],
n = c[e] > p[e],
o = c[e] < p[e];
((1 === d[f] && ((!t && n) || (t && o))) ||
(1 !== d[f] && ((!t && o) || (t && n)))) &&
(y = "x" === f ? i : a);
}
let h = { x: c.x + v.x, y: c.y + v.y },
g = { x: p.x + w.x, y: p.y + w.y };
Math.max(Math.abs(h.x - y[0].x), Math.abs(g.x - y[0].x)) >=
Math.max(Math.abs(h.y - y[0].y), Math.abs(g.y - y[0].y))
? ((s = (h.x + g.x) / 2), (l = y[0].y))
: ((s = y[0].x), (l = (h.y + g.y) / 2));
}
return [
[
e,
{ x: c.x + v.x, y: c.y + v.y },
...y,
{ x: p.x + w.x, y: p.y + w.y },
n,
],
s,
l,
x,
S,
];
})({
source: { x: e, y: t },
sourcePosition: n,
target: { x: o, y: i },
targetPosition: r,
center: { x: s, y: l },
offset: d,
stepPosition: u,
});
return [
c.reduce(
(e, t, n) =>
e +
(n > 0 && n < c.length - 1
? (function (e, t, n, o) {
let i = Math.min(eY(e, t) / 2, eY(t, n) / 2, o),
{ x: r, y: a } = t;
if ((e.x === r && r === n.x) || (e.y === a && a === n.y))
return `L${r} ${a}`;
if (e.y === a) {
let t = e.x < n.x ? -1 : 1,
o = e.y < n.y ? 1 : -1;
return `L ${r + i * t},${a}Q ${r},${a} ${r},${a + i * o}`;
}
let s = e.x < n.x ? 1 : -1,
l = e.y < n.y ? -1 : 1;
return `L ${r},${a + i * l}Q ${r},${a} ${r + i * s},${a}`;
})(c[n - 1], t, c[n + 1], a)
: `${0 === n ? "M" : "L"}${t.x} ${t.y}`),
"",
),
p,
g,
f,
m,
];
}
function eX(e) {
return (
e &&
!!(e.internals.handleBounds || e.handles?.length) &&
!!(e.measured.width || e.width || e.initialWidth)
);
}
function eK(e) {
let { sourceNode: t, targetNode: n } = e;
if (!eX(t) || !eX(n)) return null;
let o = t.internals.handleBounds || eq(t.handles),
i = n.internals.handleBounds || eq(n.handles),
r = eG(o?.source ?? [], e.sourceHandle),
a = eG(
e.connectionMode === l.Strict
? (i?.target ?? [])
: (i?.target ?? []).concat(i?.source ?? []),
e.targetHandle,
);
if (!r || !a)
return (
e.onError?.(
"008",
O.error008(!r ? "source" : "target", {
id: e.id,
sourceHandle: e.sourceHandle,
targetHandle: e.targetHandle,
}),
),
null
);
let s = r?.position || h.Bottom,
d = a?.position || h.Top,
u = eZ(t, r, s),
c = eZ(n, a, d);
return {
sourceX: u.x,
sourceY: u.y,
targetX: c.x,
targetY: c.y,
sourcePosition: s,
targetPosition: d,
};
}
function eq(e) {
if (!e) return null;
let t = [],
n = [];
for (let o of e)
(o.width = o.width ?? 1),
(o.height = o.height ?? 1),
"source" === o.type ? t.push(o) : "target" === o.type && n.push(o);
return { source: t, target: n };
}
function eZ(e, t, n = h.Left, o = !1) {
let i = (t?.x ?? 0) + e.internals.positionAbsolute.x,
r = (t?.y ?? 0) + e.internals.positionAbsolute.y,
{ width: a, height: s } = t ?? ew(e);
if (o) return { x: i + a / 2, y: r + s / 2 };
switch (t?.position ?? n) {
case h.Top:
return { x: i + a / 2, y: r };
case h.Right:
return { x: i + a, y: r + s / 2 };
case h.Bottom:
return { x: i + a / 2, y: r + s };
case h.Left:
return { x: i, y: r + s / 2 };
}
}
function eG(e, t) {
return (e && (t ? e.find((e) => e.id === t) : e[0])) || null;
}
function eQ(e, t) {
if (!e) return "";
if ("string" == typeof e) return e;
let n = t ? `${t}__` : "";
return `${n}${Object.keys(e)
.sort()
.map((t) => `${t}=${e[t]}`)
.join("&")}`;
}
function eJ(
e,
{ id: t, defaultColor: n, defaultMarkerStart: o, defaultMarkerEnd: i },
) {
let r = new Set();
return e
.reduce(
(e, a) => (
[a.markerStart || o, a.markerEnd || i].forEach((o) => {
if (o && "object" == typeof o) {
let i = eQ(o, t);
r.has(i) ||
(e.push({ id: i, color: o.color || n, ...o }), r.add(i));
}
}),
e
),
[],
)
.sort((e, t) => e.id.localeCompare(t.id));
}
function e0(e, t, n, o, i) {
let r = 0.5;
"start" === i ? (r = 0) : "end" === i && (r = 1);
let a = [(e.x + e.width * r) * t.zoom + t.x, e.y * t.zoom + t.y - o],
s = [-100 * r, -100];
switch (n) {
case h.Right:
(a = [
(e.x + e.width) * t.zoom + t.x + o,
(e.y + e.height * r) * t.zoom + t.y,
]),
(s = [0, -100 * r]);
break;
case h.Bottom:
(a[1] = (e.y + e.height) * t.zoom + t.y + o), (s[1] = 0);
break;
case h.Left:
(a = [e.x * t.zoom + t.x - o, (e.y + e.height * r) * t.zoom + t.y]),
(s = [-100, -100 * r]);
}
return `translate(${a[0]}px, ${a[1]}px) translate(${s[0]}%, ${s[1]}%)`;
}
let e1 = { left: 0, center: 50, right: 100 },
e2 = { top: 0, center: 50, bottom: 100 };
function e3(e, t, n, o = "center", i = "center") {
return `translate(${e}px, ${t}px) scale(${1 / n}) translate(${-(e1[o] ?? 50)}%, ${-(e2[i] ?? 50)}%)`;
}
let e5 = {
nodeOrigin: [0, 0],
nodeExtent: A,
elevateNodesOnSelect: !0,
zIndexMode: "basic",
defaults: {},
},
e4 = { ...e5, checkEquality: !0 };
function e6(e, t) {
let n = { ...e };
for (let e in t) void 0 !== t[e] && (n[e] = t[e]);
return n;
}
function e7(e, t, n) {
let o = e6(e5, n);
for (let n of e.values())
if (n.parentId) te(n, e, t, o);
else {
let e = Q(
U(n, o.nodeOrigin),
ev(n.extent) ? n.extent : o.nodeExtent,
ew(n),
);
n.internals.positionAbsolute = e;
}
}
function e8(e) {
return "manual" === e;
}
function e9(e, t, n, o = {}) {
let i = e6(e4, o),
r = { i: 0 },
a = new Map(t),
s = i?.elevateNodesOnSelect && !e8(i.zIndexMode) ? 1e3 : 0,
l = e.length > 0;
for (let d of (t.clear(), n.clear(), e)) {
let e = a.get(d.id);
if (i.checkEquality && d === e?.internals.userNode) t.set(d.id, e);
else {
let n = Q(
U(d, i.nodeOrigin),
ev(d.extent) ? d.extent : i.nodeExtent,
ew(d),
);
(e = {
...i.defaults,
...d,
measured: { width: d.measured?.width, height: d.measured?.height },
internals: {
positionAbsolute: n,
handleBounds: (function (e, t) {
if (!e.handles)
return e.measured ? t?.internals.handleBounds : void 0;
let n = [],
o = [];
for (let t of e.handles) {
let i = {
id: t.id,
width: t.width ?? 1,
height: t.height ?? 1,
nodeId: e.id,
x: t.x,
y: t.y,
position: t.position,
type: t.type,
};
"source" === t.type
? n.push(i)
: "target" === t.type && o.push(i);
}
return { source: n, target: o };
})(d, e),
z: tt(d, s, i.zIndexMode),
userNode: d,
},
}),
t.set(d.id, e);
}
(void 0 !== e.measured &&
void 0 !== e.measured.width &&
void 0 !== e.measured.height) ||
e.hidden ||
(l = !1),
d.parentId && te(e, t, n, o, r);
}
return l;
}
function te(e, t, n, o, i) {
let {
elevateNodesOnSelect: r,
nodeOrigin: a,
nodeExtent: s,
zIndexMode: l,
} = e6(e5, o),
d = e.parentId,
u = t.get(d);
if (!u)
return void console.warn(
`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`,
);
!(function (e, t) {
if (!e.parentId) return;
let n = t.get(e.parentId);
n ? n.set(e.id, e) : t.set(e.parentId, new Map([[e.id, e]]));
})(e, n),
i &&
!u.parentId &&
void 0 === u.internals.rootParentIndex &&
"auto" === l &&
((u.internals.rootParentIndex = ++i.i),
(u.internals.z = u.internals.z + 10 * i.i)),
i &&
void 0 !== u.internals.rootParentIndex &&
(i.i = u.internals.rootParentIndex);
let {
x: c,
y: p,
z: h,
} = (function (e, t, n, o, i, r) {
let { x: a, y: s } = t.internals.positionAbsolute,
l = ew(e),
d = U(e, n),
u = ev(e.extent) ? Q(d, e.extent, l) : d,
c = Q({ x: a + u.x, y: s + u.y }, o, l);
"parent" === e.extent && (c = J(c, l, t));
let p = tt(e, i, r),
h = t.internals.z ?? 0;
return { x: c.x, y: c.y, z: h >= p ? h + 1 : p };
})(e, u, a, s, r && !e8(l) ? 1e3 : 0, l),
{ positionAbsolute: g } = e.internals,
f = c !== g.x || p !== g.y;
(f || h !== e.internals.z) &&
t.set(e.id, {
...e,
internals: {
...e.internals,
positionAbsolute: f ? { x: c, y: p } : g,
z: h,
},
});
}
function tt(e, t, n) {
let o = eu(e.zIndex) ? e.zIndex : 0;
return e8(n) ? o : o + (e.selected ? t : 0);
}
function tn(e, t, n, o = [0, 0]) {
let i = [],
r = new Map();
for (let n of e) {
let e = t.get(n.parentId);
if (!e) continue;
let o = es(r.get(n.parentId)?.expandedRect ?? er(e), n.rect);
r.set(n.parentId, { expandedRect: o, parent: e });
}
return (
r.size > 0 &&
r.forEach(({ expandedRect: t, parent: r }, a) => {
let s = r.internals.positionAbsolute,
l = ew(r),
d = r.origin ?? o,
u = t.x < s.x ? Math.round(Math.abs(s.x - t.x)) : 0,
c = t.y < s.y ? Math.round(Math.abs(s.y - t.y)) : 0,
p = Math.max(l.width, Math.round(t.width)),
h = Math.max(l.height, Math.round(t.height)),
g = (p - l.width) * d[0],
f = (h - l.height) * d[1];
(u > 0 || c > 0 || g || f) &&
(i.push({
id: a,
type: "position",
position: { x: r.position.x - u + g, y: r.position.y - c + f },
}),
n.get(a)?.forEach((t) => {
e.some((e) => e.id === t.id) ||
i.push({
id: t.id,
type: "position",
position: { x: t.position.x + u, y: t.position.y + c },
});
})),
(l.width < t.width || l.height < t.height || u || c) &&
i.push({
id: a,
type: "dimensions",
setAttributes: !0,
dimensions: {
width: p + (u ? d[0] * u - g : 0),
height: h + (c ? d[1] * c - f : 0),
},
});
}),
i
);
}
function to(e, t, n, o, i, r, a) {
let s = o?.querySelector(".xyflow__viewport"),
l = !1;
if (!s) return { changes: [], updatedInternals: l };
let d = [],
u = window.getComputedStyle(s),
{ m22: c } = new window.DOMMatrixReadOnly(u.transform),
p = [];
for (let o of e.values()) {
let e = t.get(o.id);
if (!e) continue;
if (e.hidden) {
t.set(e.id, {
...e,
internals: { ...e.internals, handleBounds: void 0 },
}),
(l = !0);
continue;
}
let s = eM(o.nodeElement),
u = e.measured.width !== s.width || e.measured.height !== s.height;
if (
s.width &&
s.height &&
(u || !e.internals.handleBounds || o.force)
) {
let h = o.nodeElement.getBoundingClientRect(),
g = ev(e.extent) ? e.extent : r,
{ positionAbsolute: f } = e.internals;
e.parentId && "parent" === e.extent
? (f = J(f, s, t.get(e.parentId)))
: g && (f = Q(f, g, s));
let m = {
...e,
measured: s,
internals: {
...e.internals,
positionAbsolute: f,
handleBounds: {
source: eO("source", o.nodeElement, h, c, e.id),
target: eO("target", o.nodeElement, h, c, e.id),
},
},
};
t.set(e.id, m),
e.parentId && te(m, t, n, { nodeOrigin: i, zIndexMode: a }),
(l = !0),
u &&
(d.push({ id: e.id, type: "dimensions", dimensions: s }),
e.expandParent &&
e.parentId &&
p.push({ id: e.id, parentId: e.parentId, rect: er(m, i) }));
}
}
if (p.length > 0) {
let e = tn(p, t, n, i);
d.push(...e);
}
return { changes: d, updatedInternals: l };
}
async function ti({
delta: e,
panZoom: t,
transform: n,
translateExtent: o,
width: i,
height: r,
}) {
if (!t || (!e.x && !e.y)) return Promise.resolve(!1);
let a = await t.setViewportConstrained(
{ x: n[0] + e.x, y: n[1] + e.y, zoom: n[2] },
[
[0, 0],
[i, r],
],
o,
);
return Promise.resolve(
!!a && (a.x !== n[0] || a.y !== n[1] || a.k !== n[2]),
);
}
function tr(e, t, n, o, i, r) {
let a = i,
s = o.get(a) || new Map();
o.set(a, s.set(n, t)), (a = `${i}-${e}`);
let l = o.get(a) || new Map();
if ((o.set(a, l.set(n, t)), r)) {
a = `${i}-${e}-${r}`;
let s = o.get(a) || new Map();
o.set(a, s.set(n, t));
}
}
function ta(e, t, n) {
for (let o of (e.clear(), t.clear(), n)) {
let {
source: n,
target: i,
sourceHandle: r = null,
targetHandle: a = null,
} = o,
s = {
edgeId: o.id,
source: n,
target: i,
sourceHandle: r,
targetHandle: a,
},
l = `${n}-${r}--${i}-${a}`;
tr("source", s, `${i}-${a}--${n}-${r}`, e, n, r),
tr("target", s, l, e, i, a),
t.set(o.id, o);
}
}
function ts(e, t) {
if (null === e || null === t) return !1;
let n = Array.isArray(e) ? e : [e],
o = Array.isArray(t) ? t : [t];
if (n.length !== o.length) return !1;
for (let e = 0; e < n.length; e++)
if (
n[e].id !== o[e].id ||
n[e].type !== o[e].type ||
!Object.is(n[e].data, o[e].data)
)
return !1;
return !0;
}
function tl(e, t, n) {
let o = e;
do {
if (o?.matches?.(t)) return !0;
if (o === n) break;
o = o?.parentElement;
} while (o);
return !1;
}
function td({ nodeId: e, dragItems: t, nodeLookup: n, dragging: o = !0 }) {
let i = [];
for (let [e, r] of t) {
let t = n.get(e)?.internals.userNode;
t && i.push({ ...t, position: r.position, dragging: o });
}
if (!e) return [i[0], i];
let r = n.get(e)?.internals.userNode;
return [
r
? { ...r, position: t.get(e)?.position || r.position, dragging: o }
: i[0],
i,
];
}
function tu({
onNodeMouseDown: e,
getStoreItems: t,
onDragStart: n,
onDrag: o,
onDragStop: i,
}) {
let r = { x: null, y: null },
a = 0,
s = new Map(),
l = !1,
d = { x: 0, y: 0 },
u = null,
c = !1,
p = null,
h = !1,
g = !1,
f = null;
return {
update: function ({
noDragClassName: y,
handleSelector: v,
domNode: w,
isSelectable: x,
nodeId: S,
nodeClickDistance: b = 0,
}) {
function I({ x: e, y: n }) {
let {
nodeLookup: i,
nodeExtent: a,
snapGrid: l,
snapToGrid: d,
nodeOrigin: u,
onNodeDrag: c,
onSelectionDrag: p,
onError: h,
updateNodePositions: m,
} = t();
r = { x: e, y: n };
let y = !1,
v = s.size > 1,
w = v && a ? eo(W(s)) : null,
x =
v && d
? (function ({ dragItems: e, snapGrid: t, x: n, y: o }) {
let i = e.values().next().value;
if (!i) return null;
let r = { x: n - i.distance.x, y: o - i.distance.y },
a = ep(r, t);
return { x: a.x - r.x, y: a.y - r.y };
})({ dragItems: s, snapGrid: l, x: e, y: n })
: null;
for (let [t, o] of s) {
if (!i.has(t)) continue;
let r = { x: e - o.distance.x, y: n - o.distance.y };
d &&
(r = x
? { x: Math.round(r.x + x.x), y: Math.round(r.y + x.y) }
: ep(r, l));
let s = null;
if (v && a && !o.extent && w) {
let { positionAbsolute: e } = o.internals,
t = e.x - w.x + a[0][0],
n = e.x + o.measured.width - w.x2 + a[1][0];
s = [
[t, e.y - w.y + a[0][1]],
[n, e.y + o.measured.height - w.y2 + a[1][1]],
];
}
let { position: c, positionAbsolute: p } = q({
nodeId: t,
nextPosition: r,
nodeLookup: i,
nodeExtent: s || a,
nodeOrigin: u,
onError: h,
});
(y = y || o.position.x !== c.x || o.position.y !== c.y),
(o.position = c),
(o.internals.positionAbsolute = p);
}
if (((g = g || y), y && (m(s, !0), f && (o || c || (!S && p))))) {
let [e, t] = td({ nodeId: S, dragItems: s, nodeLookup: i });
o?.(f, s, e, t), c?.(f, e, t), S || p?.(f, t);
}
}
async function _() {
if (!u) return;
let {
transform: e,
panBy: n,
autoPanSpeed: o,
autoPanOnNodeDrag: i,
} = t();
if (!i) {
(l = !1), cancelAnimationFrame(a);
return;
}
let [s, c] = et(d, u, o);
(0 !== s || 0 !== c) &&
((r.x = (r.x ?? 0) - s / e[2]),
(r.y = (r.y ?? 0) - c / e[2]),
(await n({ x: s, y: c })) && I(r)),
(a = requestAnimationFrame(_));
}
function E(o) {
let {
nodeLookup: i,
multiSelectionActive: a,
nodesDraggable: l,
transform: d,
snapGrid: p,
snapToGrid: h,
selectNodesOnDrag: g,
onNodeDragStart: f,
onSelectionDragStart: m,
unselectNodesAndEdges: y,
} = t();
(c = !0),
(g && x) || a || !S || i.get(S)?.selected || y(),
x && g && S && e?.(S);
let v = eE(o.sourceEvent, {
transform: d,
snapGrid: p,
snapToGrid: h,
containerBounds: u,
});
if (
((r = v),
(s = (function (e, t, n, o) {
let i = new Map();
for (let [r, a] of e)
if (
(a.selected || a.id === o) &&
(!a.parentId ||
!(function e(t, n) {
if (!t.parentId) return !1;
let o = n.get(t.parentId);
return !!o && (!!o.selected || e(o, n));
})(a, e)) &&
(a.draggable || (t && void 0 === a.draggable))
) {
let t = e.get(r);
t &&
i.set(r, {
id: r,
position: t.position || { x: 0, y: 0 },
distance: {
x: n.x - t.internals.positionAbsolute.x,
y: n.y - t.internals.positionAbsolute.y,
},
extent: t.extent,
parentId: t.parentId,
origin: t.origin,
expandParent: t.expandParent,
internals: {
positionAbsolute: t.internals.positionAbsolute || {
x: 0,
y: 0,
},
},
measured: {
width: t.measured.width ?? 0,
height: t.measured.height ?? 0,
},
});
}
return i;
})(i, l, v, S)).size > 0 &&
(n || f || (!S && m)))
) {
let [e, t] = td({ nodeId: S, dragItems: s, nodeLookup: i });
n?.(o.sourceEvent, s, e, t),
f?.(o.sourceEvent, e, t),
S || m?.(o.sourceEvent, t);
}
}
p = (0, m.select)(w);
let C = M()
.clickDistance(b)
.on("start", (e) => {
let {
domNode: n,
nodeDragThreshold: o,
transform: i,
snapGrid: a,
snapToGrid: s,
} = t();
(u = n?.getBoundingClientRect() || null),
(h = !1),
(g = !1),
(f = e.sourceEvent),
0 === o && E(e),
(r = eE(e.sourceEvent, {
transform: i,
snapGrid: a,
snapToGrid: s,
containerBounds: u,
})),
(d = eT(e.sourceEvent, u));
})
.on("drag", (e) => {
let {
autoPanOnNodeDrag: n,
transform: o,
snapGrid: i,
snapToGrid: a,
nodeDragThreshold: p,
nodeLookup: g,
} = t(),
m = eE(e.sourceEvent, {
transform: o,
snapGrid: i,
snapToGrid: a,
containerBounds: u,
});
if (
((f = e.sourceEvent),
(("touchmove" === e.sourceEvent.type &&
e.sourceEvent.touches.length > 1) ||
(S && !g.has(S))) &&
(h = !0),
!h)
) {
if ((!l && n && c && ((l = !0), _()), !c)) {
let t = eT(e.sourceEvent, u),
n = t.x - d.x,
o = t.y - d.y;
Math.sqrt(n * n + o * o) > p && E(e);
}
(r.x !== m.xSnapped || r.y !== m.ySnapped) &&
s &&
c &&
((d = eT(e.sourceEvent, u)), I(m));
}
})
.on("end", (e) => {
if (
c &&
!h &&
((l = !1), (c = !1), cancelAnimationFrame(a), s.size > 0)
) {
let {
nodeLookup: n,
updateNodePositions: o,
onNodeDragStop: r,
onSelectionDragStop: a,
} = t();
if ((g && (o(s, !1), (g = !1)), i || r || (!S && a))) {
let [t, o] = td({
nodeId: S,
dragItems: s,
nodeLookup: n,
dragging: !1,
});
i?.(e.sourceEvent, s, t, o),
r?.(e.sourceEvent, t, o),
S || a?.(e.sourceEvent, o);
}
}
})
.filter((e) => {
let t = e.target;
return (
!e.button && (!y || !tl(t, `.${y}`, w)) && (!v || tl(t, v, w))
);
});
p.call(C);
},
destroy: function () {
p?.on(".drag", null);
},
};
}
function tc(e, t, n, o, i, r = !1) {
let a = o.get(e);
if (!a) return null;
let s =
"strict" === i
? a.internals.handleBounds?.[t]
: [
...(a.internals.handleBounds?.source ?? []),
...(a.internals.handleBounds?.target ?? []),
],
l = (n ? s?.find((e) => e.id === n) : s?.[0]) ?? null;
return l && r ? { ...l, ...eZ(a, l, l.position, !0) } : l;
}
function tp(e, t) {
return e
? e
: t?.classList.contains("target")
? "target"
: t?.classList.contains("source")
? "source"
: null;
}
let th = () => !0;
function tg(
e,
{
handle: t,
connectionMode: n,
fromNodeId: o,
fromHandleId: i,
fromType: r,
doc: a,
lib: s,
flowId: d,
isValidConnection: u = th,
nodeLookup: c,
},
) {
let p = "target" === r,
h = t
? a.querySelector(
`.${s}-flow__handle[data-id="${d}-${t?.nodeId}-${t?.id}-${t?.type}"]`,
)
: null,
{ x: g, y: f } = eT(e),
m = a.elementFromPoint(g, f),
y = m?.classList.contains(`${s}-flow__handle`) ? m : h,
v = { handleDomNode: y, isValid: !1, connection: null, toHandle: null };
if (y) {
let e = tp(void 0, y),
t = y.getAttribute("data-nodeid"),
r = y.getAttribute("data-handleid"),
a = y.classList.contains("connectable"),
s = y.classList.contains("connectableend");
if (!t || !e) return v;
let d = {
source: p ? t : o,
sourceHandle: p ? r : i,
target: p ? o : t,
targetHandle: p ? i : r,
};
(v.connection = d),
(v.isValid =
a &&
s &&
(n === l.Strict
? (p && "source" === e) || (!p && "target" === e)
: t !== o || r !== i) &&
u(d)),
(v.toHandle = tc(t, e, r, c, n, !0));
}
return v;
}
let tf = {
onPointerDown: function (
e,
{
connectionMode: t,
connectionRadius: n,
handleId: o,
nodeId: i,
edgeUpdaterType: r,
isTarget: a,
domNode: s,
nodeLookup: l,
lib: d,
autoPanOnConnect: u,
flowId: c,
panBy: p,
cancelConnection: g,
onConnectStart: f,
onConnect: m,
onConnectEnd: y,
isValidConnection: v = th,
onReconnectEnd: w,
updateConnection: x,
getTransform: S,
getFromHandle: b,
autoPanSpeed: I,
dragThreshold: _ = 1,
handleDomNode: E,
},
) {
let M,
C = eC(e.target),
N = 0,
{ x: P, y: k } = eT(e),
T = tp(r, E),
O = s?.getBoundingClientRect(),
A = !1;
if (!O || !T) return;
let D = tc(i, T, o, l, t);
if (!D) return;
let L = eT(e, O),
j = !1,
z = null,
F = !1,
$ = null,
B = { ...D, nodeId: i, type: T, position: D.position },
H = l.get(i),
V = {
inProgress: !0,
isValid: null,
from: eZ(H, B, h.Left, !0),
fromHandle: B,
fromPosition: B.position,
fromNode: H,
to: L,
toHandle: null,
toPosition: R[B.position],
toNode: null,
pointer: L,
};
function U() {
(A = !0), x(V), f?.(e, { nodeId: i, handleId: o, handleType: T });
}
function Y(e) {
var r, s;
let g;
if (!A) {
let { x: t, y: n } = eT(e),
o = t - P,
i = n - k;
if (!(o * o + i * i > _ * _)) return;
U();
}
if (!b() || !B) return void W(e);
let f = S();
(M = (function (e, t, n, o) {
let i = [],
r = 1 / 0;
for (let a of (function (e, t, n) {
let o = [],
i = { x: e.x - n, y: e.y - n, width: 2 * n, height: 2 * n };
for (let e of t.values()) el(i, er(e)) > 0 && o.push(e);
return o;
})(e, n, t + 250))
for (let n of [
...(a.internals.handleBounds?.source ?? []),
...(a.internals.handleBounds?.target ?? []),
]) {
if (o.nodeId === n.nodeId && o.type === n.type && o.id === n.id)
continue;
let { x: s, y: l } = eZ(a, n, n.position, !0),
d = Math.sqrt(Math.pow(s - e.x, 2) + Math.pow(l - e.y, 2));
d > t ||
(d < r
? ((i = [{ ...n, x: s, y: l }]), (r = d))
: d === r && i.push({ ...n, x: s, y: l }));
}
if (!i.length) return null;
if (i.length > 1) {
let e = "source" === o.type ? "target" : "source";
return i.find((t) => t.type === e) ?? i[0];
}
return i[0];
})(eh((L = eT(e, O)), f, !1, [1, 1]), n, l, B)),
j ||
(!(function e() {
if (!u || !O) return;
let [t, n] = et(L, O, I);
p({ x: t, y: n }), (N = requestAnimationFrame(e));
})(),
(j = !0));
let m = tg(e, {
handle: M,
connectionMode: t,
fromNodeId: i,
fromHandleId: o,
fromType: a ? "target" : "source",
isValidConnection: v,
doc: C,
lib: d,
flowId: c,
nodeLookup: l,
});
($ = m.handleDomNode),
(z = m.connection),
(r = !!M),
(s = m.isValid),
(g = null),
s ? (g = !0) : r && !s && (g = !1),
(F = g);
let y = l.get(i),
w = y ? eZ(y, B, h.Left, !0) : V.from,
E = {
...V,
from: w,
isValid: F,
to:
m.toHandle && F
? eg({ x: m.toHandle.x, y: m.toHandle.y }, f)
: L,
toHandle: m.toHandle,
toPosition: F && m.toHandle ? m.toHandle.position : R[B.position],
toNode: m.toHandle ? l.get(m.toHandle.nodeId) : null,
pointer: L,
};
x(E), (V = E);
}
function W(e) {
if (!("touches" in e) || !(e.touches.length > 0)) {
if (A) {
(M || $) && z && F && m?.(z);
let { inProgress: t, ...n } = V,
o = { ...n, toPosition: V.toHandle ? V.toPosition : null };
y?.(e, o), r && w?.(e, o);
}
g(),
cancelAnimationFrame(N),
(j = !1),
(F = !1),
(z = null),
($ = null),
C.removeEventListener("mousemove", Y),
C.removeEventListener("mouseup", W),
C.removeEventListener("touchmove", Y),
C.removeEventListener("touchend", W);
}
}
0 === _ && U(),
C.addEventListener("mousemove", Y),
C.addEventListener("mouseup", W),
C.addEventListener("touchmove", Y),
C.addEventListener("touchend", W);
},
isValid: tg,
};
function tm({ domNode: e, panZoom: t, getTransform: n, getViewScale: o }) {
let i = (0, m.select)(e);
return {
update: function ({
translateExtent: e,
width: r,
height: a,
zoomStep: s = 1,
pannable: l = !0,
zoomable: d = !0,
inversePan: u = !1,
}) {
let c = [0, 0],
p = (0, C.default)()
.on("start", (e) => {
("mousedown" === e.sourceEvent.type ||
"touchstart" === e.sourceEvent.type) &&
(c = [
e.sourceEvent.clientX ?? e.sourceEvent.touches[0].clientX,
e.sourceEvent.clientY ?? e.sourceEvent.touches[0].clientY,
]);
})
.on(
"zoom",
l
? (i) => {
let s = n();
if (
("mousemove" !== i.sourceEvent.type &&
"touchmove" !== i.sourceEvent.type) ||
!t
)
return;
let l = [
i.sourceEvent.clientX ??
i.sourceEvent.touches[0].clientX,
i.sourceEvent.clientY ??
i.sourceEvent.touches[0].clientY,
],
d = [l[0] - c[0], l[1] - c[1]];
c = l;
let p =
o() * Math.max(s[2], Math.log(s[2])) * (u ? -1 : 1),
h = { x: s[0] - d[0] * p, y: s[1] - d[1] * p };
t.setViewportConstrained(
{ x: h.x, y: h.y, zoom: s[2] },
[
[0, 0],
[r, a],
],
e,
);
}
: null,
)
.on(
"zoom.wheel",
d
? (e) => {
if ("wheel" !== e.sourceEvent.type || !t) return;
let o = n(),
i = e.sourceEvent.ctrlKey && ey() ? 10 : 1,
r =
-e.sourceEvent.deltaY *
(1 === e.sourceEvent.deltaMode
? 0.05
: e.sourceEvent.deltaMode
? 1
: 0.002) *
s,
a = o[2] * Math.pow(2, r * i);
t.scaleTo(a);
}
: null,
);
i.call(p, {});
},
destroy: function () {
i.on("zoom", null);
},
pointer: y.pointer,
};
}
let ty = (e) => ({ x: e.x, y: e.y, zoom: e.k }),
tv = ({ x: e, y: t, zoom: n }) => N.identity.translate(e, t).scale(n),
tw = (e, t) => e.target.closest(`.${t}`),
tx = (e, t) => 2 === t && Array.isArray(e) && e.includes(2),
tS = (e) => ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2,
tb = (e, t = 0, n = tS, o = () => {}) => {
let i = "number" == typeof t && t > 0;
return (
i || o(), i ? e.transition().duration(t).ease(n).on("end", o) : e
);
},
tI = (e) => {
let t = e.ctrlKey && ey() ? 10 : 1;
return (
-e.deltaY * (1 === e.deltaMode ? 0.05 : e.deltaMode ? 1 : 0.002) * t
);
};
function t_({
domNode: e,
minZoom: t,
maxZoom: n,
translateExtent: o,
viewport: i,
onPanZoom: r,
onPanZoomStart: a,
onPanZoomEnd: s,
onDraggingChange: l,
}) {
let u = {
isZoomingOrPanning: !1,
usedRightMouseButton: !1,
prevViewport: { x: 0, y: 0, zoom: 0 },
mouseButton: 0,
timerId: void 0,
panScrollTimeout: void 0,
isPanScrolling: !1,
},
c = e.getBoundingClientRect(),
p = (0, C.default)().scaleExtent([t, n]).translateExtent(o),
h = (0, m.select)(e).call(p);
x(
{ x: i.x, y: i.y, zoom: G(i.zoom, t, n) },
[
[0, 0],
[c.width, c.height],
],
o,
);
let g = h.on("wheel.zoom"),
f = h.on("dblclick.zoom");
function v(e, t) {
return h
? new Promise((n) => {
p?.interpolate(
t?.interpolate === "linear" ? T.interpolate : k.interpolateZoom,
).transform(
tb(h, t?.duration, t?.ease, () => n(!0)),
e,
);
})
: Promise.resolve(!1);
}
function w() {
p.on("zoom", null);
}
async function x(e, t, n) {
let o = tv(e),
i = p?.constrain()(o, t, n);
return i && (await v(i)), new Promise((e) => e(i));
}
return (
p.wheelDelta(tI),
{
update: function ({
noWheelClassName: e,
noPanClassName: t,
onPaneContextMenu: n,
userSelectionActive: o,
panOnScroll: i,
panOnDrag: c,
panOnScrollMode: m,
panOnScrollSpeed: v,
preventScrolling: x,
zoomOnPinch: S,
zoomOnScroll: b,
zoomOnDoubleClick: I,
zoomActivationKeyPressed: _,
lib: E,
onTransformChange: M,
connectionInProgress: C,
paneClickDistance: N,
selectionOnDrag: P,
}) {
o && !u.isZoomingOrPanning && w();
let k = i && !_ && !o;
p.clickDistance(P ? 1 / 0 : !eu(N) || N < 0 ? 0 : N);
let T = k
? (function ({
zoomPanValues: e,
noWheelClassName: t,
d3Selection: n,
d3Zoom: o,
panOnScrollMode: i,
panOnScrollSpeed: r,
zoomOnPinch: a,
onPanZoomStart: s,
onPanZoom: l,
onPanZoomEnd: u,
}) {
return (c) => {
if (tw(c, t)) return c.ctrlKey && c.preventDefault(), !1;
c.preventDefault(), c.stopImmediatePropagation();
let p = n.property("__zoom").k || 1;
if (c.ctrlKey && a) {
let e = (0, y.pointer)(c),
t = p * Math.pow(2, tI(c));
o.scaleTo(n, t, e, c);
return;
}
let h = 1 === c.deltaMode ? 20 : 1,
g = i === d.Vertical ? 0 : c.deltaX * h,
f = i === d.Horizontal ? 0 : c.deltaY * h;
!ey() &&
c.shiftKey &&
i !== d.Vertical &&
((g = c.deltaY * h), (f = 0)),
o.translateBy(n, -(g / p) * r, -(f / p) * r, {
internal: !0,
});
let m = ty(n.property("__zoom"));
clearTimeout(e.panScrollTimeout),
e.isPanScrolling
? (l?.(c, m),
(e.panScrollTimeout = setTimeout(() => {
u?.(c, m), (e.isPanScrolling = !1);
}, 150)))
: ((e.isPanScrolling = !0), s?.(c, m));
};
})({
zoomPanValues: u,
noWheelClassName: e,
d3Selection: h,
d3Zoom: p,
panOnScrollMode: m,
panOnScrollSpeed: v,
zoomOnPinch: S,
onPanZoomStart: a,
onPanZoom: r,
onPanZoomEnd: s,
})
: (function ({
noWheelClassName: e,
preventScrolling: t,
d3ZoomHandler: n,
}) {
return function (o, i) {
let r = "wheel" === o.type,
a = !t && r && !o.ctrlKey,
s = tw(o, e);
if ((o.ctrlKey && r && s && o.preventDefault(), a || s))
return null;
o.preventDefault(), n.call(this, o, i);
};
})({
noWheelClassName: e,
preventScrolling: x,
d3ZoomHandler: g,
});
if ((h.on("wheel.zoom", T, { passive: !1 }), !o)) {
let e = (function ({
zoomPanValues: e,
onDraggingChange: t,
onPanZoomStart: n,
}) {
return (o) => {
if (o.sourceEvent?.internal) return;
let i = ty(o.transform);
(e.mouseButton = o.sourceEvent?.button || 0),
(e.isZoomingOrPanning = !0),
(e.prevViewport = i),
o.sourceEvent?.type === "mousedown" && t(!0),
n && n?.(o.sourceEvent, i);
};
})({ zoomPanValues: u, onDraggingChange: l, onPanZoomStart: a });
p.on("start", e);
let t = (function ({
zoomPanValues: e,
panOnDrag: t,
onPaneContextMenu: n,
onTransformChange: o,
onPanZoom: i,
}) {
return (r) => {
(e.usedRightMouseButton = !!(n && tx(t, e.mouseButton ?? 0))),
r.sourceEvent?.sync ||
o([r.transform.x, r.transform.y, r.transform.k]),
i &&
!r.sourceEvent?.internal &&
i?.(r.sourceEvent, ty(r.transform));
};
})({
zoomPanValues: u,
panOnDrag: c,
onPaneContextMenu: !!n,
onPanZoom: r,
onTransformChange: M,
});
p.on("zoom", t);
let o = (function ({
zoomPanValues: e,
panOnDrag: t,
panOnScroll: n,
onDraggingChange: o,
onPanZoomEnd: i,
onPaneContextMenu: r,
}) {
return (a) => {
if (
!a.sourceEvent?.internal &&
((e.isZoomingOrPanning = !1),
r &&
tx(t, e.mouseButton ?? 0) &&
!e.usedRightMouseButton &&
a.sourceEvent &&
r(a.sourceEvent),
(e.usedRightMouseButton = !1),
o(!1),
i)
) {
let t = ty(a.transform);
(e.prevViewport = t),
clearTimeout(e.timerId),
(e.timerId = setTimeout(() => {
i?.(a.sourceEvent, t);
}, 150 * !!n));
}
};
})({
zoomPanValues: u,
panOnDrag: c,
panOnScroll: i,
onPaneContextMenu: n,
onPanZoomEnd: s,
onDraggingChange: l,
});
p.on("end", o);
}
let O = (function ({
zoomActivationKeyPressed: e,
zoomOnScroll: t,
zoomOnPinch: n,
panOnDrag: o,
panOnScroll: i,
zoomOnDoubleClick: r,
userSelectionActive: a,
noWheelClassName: s,
noPanClassName: l,
lib: d,
connectionInProgress: u,
}) {
return (c) => {
let p = e || t,
h = n && c.ctrlKey,
g = "wheel" === c.type;
if (
1 === c.button &&
"mousedown" === c.type &&
(tw(c, `${d}-flow__node`) || tw(c, `${d}-flow__edge`))
)
return !0;
if (
(!o && !p && !i && !r && !n) ||
a ||
(u && !g) ||
(tw(c, s) && g) ||
(tw(c, l) && (!g || (i && g && !e))) ||
(!n && c.ctrlKey && g)
)
return !1;
if (!n && "touchstart" === c.type && c.touches?.length > 1)
return c.preventDefault(), !1;
if (
(!p && !i && !h && g) ||
(!o && ("mousedown" === c.type || "touchstart" === c.type)) ||
(Array.isArray(o) &&
!o.includes(c.button) &&
"mousedown" === c.type)
)
return !1;
let f =
(Array.isArray(o) && o.includes(c.button)) ||
!c.button ||
c.button <= 1;
return (!c.ctrlKey || g) && f;
};
})({
zoomActivationKeyPressed: _,
panOnDrag: c,
zoomOnScroll: b,
panOnScroll: i,
zoomOnDoubleClick: I,
zoomOnPinch: S,
userSelectionActive: o,
noPanClassName: t,
noWheelClassName: e,
lib: E,
connectionInProgress: C,
});
p.filter(O),
I ? h.on("dblclick.zoom", f) : h.on("dblclick.zoom", null);
},
destroy: w,
setViewport: async function e(e, t) {
let n = tv(e);
return await v(n, t), new Promise((e) => e(n));
},
setViewportConstrained: x,
getViewport: function () {
let e = h ? (0, P.default)(h.node()) : { x: 0, y: 0, k: 1 };
return { x: e.x, y: e.y, zoom: e.k };
},
scaleTo: function (e, t) {
return h
? new Promise((n) => {
p?.interpolate(
t?.interpolate === "linear"
? T.interpolate
: k.interpolateZoom,
).scaleTo(
tb(h, t?.duration, t?.ease, () => n(!0)),
e,
);
})
: Promise.resolve(!1);
},
scaleBy: function (e, t) {
return h
? new Promise((n) => {
p?.interpolate(
t?.interpolate === "linear"
? T.interpolate
: k.interpolateZoom,
).scaleBy(
tb(h, t?.duration, t?.ease, () => n(!0)),
e,
);
})
: Promise.resolve(!1);
},
setScaleExtent: function (e) {
p?.scaleExtent(e);
},
setTranslateExtent: function (e) {
p?.translateExtent(e);
},
syncViewport: function (e) {
if (h) {
let t = tv(e),
n = h.property("__zoom");
(n.k !== e.zoom || n.x !== e.x || n.y !== e.y) &&
p?.transform(h, t, null, { sync: !0 });
}
},
setClickDistance: function (e) {
let t = !eu(e) || e < 0 ? 0 : e;
p?.clickDistance(t);
},
}
);
}
((s = g || (g = {})).Line = "line"), (s.Handle = "handle");
let tE = ["top-left", "top-right", "bottom-left", "bottom-right"],
tM = ["top", "right", "bottom", "left"];
function tC(e) {
let t = e.includes("right") || e.includes("left"),
n = e.includes("bottom") || e.includes("top");
return {
isHorizontal: t,
isVertical: n,
affectsX: e.includes("left"),
affectsY: e.includes("top"),
};
}
function tN(e, t) {
return Math.max(0, t - e);
}
function tP(e, t) {
return Math.max(0, e - t);
}
function tk(e, t, n) {
return Math.max(0, t - e, e - n);
}
let tT = { width: 0, height: 0, x: 0, y: 0 },
tO = { ...tT, pointerX: 0, pointerY: 0, aspectRatio: 1 };
function tA({
domNode: e,
nodeId: t,
getStoreItems: n,
onChange: o,
onEnd: i,
}) {
let r = (0, m.select)(e),
a = {
controlDirection: tC("bottom-right"),
boundaries: {
minWidth: 0,
minHeight: 0,
maxWidth: Number.MAX_VALUE,
maxHeight: Number.MAX_VALUE,
},
resizeDirection: void 0,
keepAspectRatio: !1,
};
return {
update: function ({
controlPosition: e,
boundaries: s,
keepAspectRatio: l,
resizeDirection: d,
onResizeStart: u,
onResize: c,
onResizeEnd: p,
shouldResize: h,
}) {
let g,
f,
m,
y,
v = { ...tT },
w = { ...tO };
a = {
boundaries: s,
resizeDirection: d,
keepAspectRatio: l,
controlDirection: tC(e),
};
let x = null,
S = [],
b = !1,
I = M()
.on("start", (e) => {
let {
nodeLookup: o,
transform: i,
snapGrid: r,
snapToGrid: a,
nodeOrigin: s,
paneDomNode: l,
} = n();
if (!(g = o.get(t))) return;
x = l?.getBoundingClientRect() ?? null;
let { xSnapped: d, ySnapped: c } = eE(e.sourceEvent, {
transform: i,
snapGrid: r,
snapToGrid: a,
containerBounds: x,
});
if (
((w = {
...(v = {
width: g.measured.width ?? 0,
height: g.measured.height ?? 0,
x: g.position.x ?? 0,
y: g.position.y ?? 0,
}),
pointerX: d,
pointerY: c,
aspectRatio: v.width / v.height,
}),
(f = void 0),
g.parentId && ("parent" === g.extent || g.expandParent))
) {
var p;
m =
(f = o.get(g.parentId)) && "parent" === g.extent
? [
[0, 0],
[(p = f).measured.width, p.measured.height],
]
: void 0;
}
for (let [e, n] of ((S = []), (y = void 0), o))
if (
n.parentId === t &&
(S.push({
id: e,
position: { ...n.position },
extent: n.extent,
}),
"parent" === n.extent || n.expandParent)
) {
let e = (function (e, t, n) {
let o = t.position.x + e.position.x,
i = t.position.y + e.position.y,
r = e.measured.width ?? 0,
a = e.measured.height ?? 0,
s = n[0] * r,
l = n[1] * a;
return [
[o - s, i - l],
[o + r - s, i + a - l],
];
})(n, g, n.origin ?? s);
y = y
? [
[
Math.min(e[0][0], y[0][0]),
Math.min(e[0][1], y[0][1]),
],
[
Math.max(e[1][0], y[1][0]),
Math.max(e[1][1], y[1][1]),
],
]
: e;
}
u?.(e, { ...v });
})
.on("drag", (e) => {
let {
transform: t,
snapGrid: i,
snapToGrid: r,
nodeOrigin: s,
} = n(),
l = eE(e.sourceEvent, {
transform: t,
snapGrid: i,
snapToGrid: r,
containerBounds: x,
}),
d = [];
if (!g) return;
let { x: u, y: p, width: I, height: _ } = v,
E = {},
M = g.origin ?? s,
{
width: C,
height: N,
x: P,
y: k,
} = (function (e, t, n, o, i, r, a, s) {
var l, d, u, c;
let { affectsX: p, affectsY: h } = t,
{ isHorizontal: g, isVertical: f } = t,
m = g && f,
{ xSnapped: y, ySnapped: v } = n,
{
minWidth: w,
maxWidth: x,
minHeight: S,
maxHeight: b,
} = o,
{ x: I, y: _, width: E, height: M, aspectRatio: C } = e,
N = Math.floor(g ? y - e.pointerX : 0),
P = Math.floor(f ? v - e.pointerY : 0),
k = E + (p ? -N : N),
T = M + (h ? -P : P),
O = -r[0] * E,
A = -r[1] * M,
D = tk(k, w, x),
L = tk(T, S, b);
if (a) {
let e = 0,
t = 0;
p && N < 0
? (e = tN(I + N + O, a[0][0]))
: !p && N > 0 && (e = tP(I + k + O, a[1][0])),
h && P < 0
? (t = tN(_ + P + A, a[0][1]))
: !h && P > 0 && (t = tP(_ + T + A, a[1][1])),
(D = Math.max(D, e)),
(L = Math.max(L, t));
}
if (s) {
let e = 0,
t = 0;
p && N > 0
? (e = tP(I + N, s[0][0]))
: !p && N < 0 && (e = tN(I + k, s[1][0])),
h && P > 0
? (t = tP(_ + P, s[0][1]))
: !h && P < 0 && (t = tN(_ + T, s[1][1])),
(D = Math.max(D, e)),
(L = Math.max(L, t));
}
if (i) {
if (g) {
((D = Math.max(D, tk(k / C, S, b) * C)), a) &&
(D = Math.max(
D,
(p || h) && (!p || h || !m)
? tN(_ + A + (p ? N : -N) / C, a[0][1]) * C
: tP(_ + A + k / C, a[1][1]) * C,
));
s &&
(D = Math.max(
D,
(p || h) && (!p || h || !m)
? tP(_ + (p ? N : -N) / C, s[0][1]) * C
: tN(_ + k / C, s[1][1]) * C,
));
}
if (f) {
((L = Math.max(L, tk(T * C, w, x) / C)), a) &&
(L = Math.max(
L,
(p || h) && (!h || p || !m)
? tN(I + (h ? P : -P) * C + O, a[0][0]) / C
: tP(I + T * C + O, a[1][0]) / C,
));
s &&
(L = Math.max(
L,
(p || h) && (!h || p || !m)
? tP(I + (h ? P : -P) * C, s[0][0]) / C
: tN(I + T * C, s[1][0]) / C,
));
}
}
(P += P < 0 ? L : -L),
(N += N < 0 ? D : -D),
i &&
(m
? k > T * C
? (P =
(((l = p), (d = h), l ? !d : d) ? -N : N) / C)
: (N =
(((u = p), (c = h), u ? !c : c) ? -P : P) * C)
: g
? ((P = N / C), (h = p))
: ((N = P * C), (p = h)));
let j = p ? I + N : I,
R = h ? _ + P : _;
return {
width: E + (p ? -N : N),
height: M + (h ? -P : P),
x: r[0] * N * (p ? -1 : 1) + j,
y: r[1] * P * (h ? -1 : 1) + R,
};
})(
w,
a.controlDirection,
l,
a.boundaries,
a.keepAspectRatio,
M,
m,
y,
),
T = C !== I,
O = N !== _,
A = P !== u && T,
D = k !== p && O;
if (!A && !D && !T && !O) return;
if (
(A || D || 1 === M[0] || 1 === M[1]) &&
((E.x = A ? P : v.x),
(E.y = D ? k : v.y),
(v.x = E.x),
(v.y = E.y),
S.length > 0)
) {
let e = P - u,
t = k - p;
for (let n of S)
(n.position = {
x: n.position.x - e + M[0] * (C - I),
y: n.position.y - t + M[1] * (N - _),
}),
d.push(n);
}
if (
((T || O) &&
((E.width =
T &&
(!a.resizeDirection || "horizontal" === a.resizeDirection)
? C
: v.width),
(E.height =
O &&
(!a.resizeDirection || "vertical" === a.resizeDirection)
? N
: v.height),
(v.width = E.width),
(v.height = E.height)),
f && g.expandParent)
) {
let e = M[0] * (E.width ?? 0);
E.x && E.x < e && ((v.x = e), (w.x = w.x - (E.x - e)));
let t = M[1] * (E.height ?? 0);
E.y && E.y < t && ((v.y = t), (w.y = w.y - (E.y - t)));
}
let L = (function ({
width: e,
prevWidth: t,
height: n,
prevHeight: o,
affectsX: i,
affectsY: r,
}) {
let a = e - t,
s = n - o,
l = [
a > 0 ? 1 : a < 0 ? -1 : 0,
s > 0 ? 1 : s < 0 ? -1 : 0,
];
return (
a && i && (l[0] = -1 * l[0]),
s && r && (l[1] = -1 * l[1]),
l
);
})({
width: v.width,
prevWidth: I,
height: v.height,
prevHeight: _,
affectsX: a.controlDirection.affectsX,
affectsY: a.controlDirection.affectsY,
}),
j = { ...v, direction: L };
!1 !== h?.(e, j) && ((b = !0), c?.(e, j), o(E, d));
})
.on("end", (e) => {
b && (p?.(e, { ...v }), i?.({ ...v }), (b = !1));
});
r.call(I);
},
destroy: function () {
r.on(".drag", null);
},
};
}
e.s(
[
"ConnectionLineType",
() => c,
"ConnectionMode",
() => l,
"MarkerType",
() => p,
"PanOnScrollMode",
() => d,
"Position",
() => h,
"ResizeControlVariant",
() => g,
"SelectionMode",
() => u,
"XYDrag",
() => tu,
"XYHandle",
() => tf,
"XYMinimap",
() => tm,
"XYPanZoom",
() => t_,
"XYResizer",
() => tA,
"XY_RESIZER_HANDLE_POSITIONS",
() => tE,
"XY_RESIZER_LINE_POSITIONS",
() => tM,
"addEdge",
() => eB,
"adoptUserNodes",
() => e9,
"areConnectionMapsEqual",
() => z,
"areSetsEqual",
() => eb,
"calculateNodePosition",
() => q,
"createMarkerIds",
() => eJ,
"defaultAriaLabelConfig",
() => L,
"devWarn",
() => ec,
"elementSelectionKeys",
() => D,
"errorMessages",
() => O,
"evaluateAbsolutePosition",
() => eS,
"fitViewport",
() => K,
"getBezierEdgeCenter",
() => eA,
"getBezierPath",
() => ej,
"getBoundsOfRects",
() => es,
"getConnectionStatus",
() => $,
"getDimensions",
() => eM,
"getEdgePosition",
() => eK,
"getEdgeToolbarTransform",
() => e3,
"getElementsToRemove",
() => Z,
"getElevatedEdgeZIndex",
() => ez,
"getEventPosition",
() => eT,
"getHandlePosition",
() => eZ,
"getHostForElement",
() => eC,
"getInternalNodesBounds",
() => W,
"getMarkerId",
() => eQ,
"getNodeDimensions",
() => ew,
"getNodeToolbarTransform",
() => e0,
"getNodesBounds",
() => Y,
"getNodesInside",
() => X,
"getOverlappingArea",
() => el,
"getSmoothStepPath",
() => eW,
"getStraightPath",
() => eH,
"getViewportForBounds",
() => em,
"handleConnectionChange",
() => F,
"handleExpandParent",
() => tn,
"infiniteExtent",
() => A,
"initialConnection",
() => j,
"isEdgeBase",
() => B,
"isEdgeVisible",
() => eF,
"isInputDOMNode",
() => eP,
"isMacOs",
() => ey,
"isMouseEvent",
() => ek,
"isNodeBase",
() => H,
"isNumeric",
() => eu,
"isRectObject",
() => ed,
"mergeAriaLabelConfig",
() => e_,
"nodeHasDimensions",
() => ex,
"nodeToRect",
() => er,
"panBy",
() => ti,
"pointToRendererPoint",
() => eh,
"rendererPointToPoint",
() => eg,
"shallowNodeData",
() => ts,
"snapPosition",
() => ep,
"updateAbsolutePositions",
() => e7,
"updateConnectionLookup",
() => ta,
"updateNodeInternals",
() => to,
"withResolvers",
() => eI,
],
292002,
);
};
export default moduleFactory;