4996 lines
150 KiB
JavaScript
4996 lines
150 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 09166d9658efb080.e1742a6c63.js
|
|
* Module id: 768924
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (e) => {
|
|
"use strict";
|
|
var t,
|
|
n,
|
|
o = e.i(462214),
|
|
i = e.i(358379),
|
|
r = e.i(796007),
|
|
a = e.i(292002),
|
|
s = e.i(396805),
|
|
l = e.i(888255);
|
|
e.i(111558);
|
|
let d = (0, i.createContext)(null),
|
|
u = d.Provider,
|
|
c = a.errorMessages.error001();
|
|
function p(e, t) {
|
|
let n = (0, i.useContext)(d);
|
|
if (null === n) throw Error(c);
|
|
return (0, s.useStoreWithEqualityFn)(n, e, t);
|
|
}
|
|
function h() {
|
|
let e = (0, i.useContext)(d);
|
|
if (null === e) throw Error(c);
|
|
return (0, i.useMemo)(
|
|
() => ({
|
|
getState: e.getState,
|
|
setState: e.setState,
|
|
subscribe: e.subscribe,
|
|
}),
|
|
[e],
|
|
);
|
|
}
|
|
let g = { display: "none" },
|
|
f = {
|
|
position: "absolute",
|
|
width: 1,
|
|
height: 1,
|
|
margin: -1,
|
|
border: 0,
|
|
padding: 0,
|
|
overflow: "hidden",
|
|
clip: "rect(0px, 0px, 0px, 0px)",
|
|
clipPath: "inset(100%)",
|
|
},
|
|
m = "react-flow__node-desc",
|
|
y = "react-flow__edge-desc",
|
|
v = (e) => e.ariaLiveMessage,
|
|
w = (e) => e.ariaLabelConfig;
|
|
function x({ rfId: e }) {
|
|
let t = p(v);
|
|
return (0, o.jsx)("div", {
|
|
id: `react-flow__aria-live-${e}`,
|
|
"aria-live": "assertive",
|
|
"aria-atomic": "true",
|
|
style: f,
|
|
children: t,
|
|
});
|
|
}
|
|
function S({ rfId: e, disableKeyboardA11y: t }) {
|
|
let n = p(w);
|
|
return (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
(0, o.jsx)("div", {
|
|
id: `${m}-${e}`,
|
|
style: g,
|
|
children: t
|
|
? n["node.a11yDescription.default"]
|
|
: n["node.a11yDescription.keyboardDisabled"],
|
|
}),
|
|
(0, o.jsx)("div", {
|
|
id: `${y}-${e}`,
|
|
style: g,
|
|
children: n["edge.a11yDescription.default"],
|
|
}),
|
|
!t && (0, o.jsx)(x, { rfId: e }),
|
|
],
|
|
});
|
|
}
|
|
let b = (0, i.forwardRef)(
|
|
(
|
|
{ position: e = "top-left", children: t, className: n, style: i, ...a },
|
|
s,
|
|
) => {
|
|
let l = `${e}`.split("-");
|
|
return (0, o.jsx)("div", {
|
|
className: (0, r.default)(["react-flow__panel", n, ...l]),
|
|
style: i,
|
|
ref: s,
|
|
...a,
|
|
children: t,
|
|
});
|
|
},
|
|
);
|
|
function I({ proOptions: e, position: t = "bottom-right" }) {
|
|
return e?.hideAttribution
|
|
? null
|
|
: (0, o.jsx)(b, {
|
|
position: t,
|
|
className: "react-flow__attribution",
|
|
"data-message":
|
|
"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",
|
|
children: (0, o.jsx)("a", {
|
|
href: "https://reactflow.dev",
|
|
target: "_blank",
|
|
rel: "noopener noreferrer",
|
|
"aria-label": "React Flow attribution",
|
|
children: "React Flow",
|
|
}),
|
|
});
|
|
}
|
|
b.displayName = "Panel";
|
|
let _ = (e) => {
|
|
let t = [],
|
|
n = [];
|
|
for (let [, n] of e.nodeLookup)
|
|
n.selected && t.push(n.internals.userNode);
|
|
for (let [, t] of e.edgeLookup) t.selected && n.push(t);
|
|
return { selectedNodes: t, selectedEdges: n };
|
|
},
|
|
E = (e) => e.id;
|
|
function M(e, t) {
|
|
return (
|
|
(0, l.shallow)(e.selectedNodes.map(E), t.selectedNodes.map(E)) &&
|
|
(0, l.shallow)(e.selectedEdges.map(E), t.selectedEdges.map(E))
|
|
);
|
|
}
|
|
function C({ onSelectionChange: e }) {
|
|
let t = h(),
|
|
{ selectedNodes: n, selectedEdges: o } = p(_, M);
|
|
return (
|
|
(0, i.useEffect)(() => {
|
|
let i = { nodes: n, edges: o };
|
|
e?.(i), t.getState().onSelectionChangeHandlers.forEach((e) => e(i));
|
|
}, [n, o, e]),
|
|
null
|
|
);
|
|
}
|
|
let N = (e) => !!e.onSelectionChangeHandlers;
|
|
function P({ onSelectionChange: e }) {
|
|
let t = p(N);
|
|
return e || t ? (0, o.jsx)(C, { onSelectionChange: e }) : null;
|
|
}
|
|
let k = [0, 0],
|
|
T = { x: 0, y: 0, zoom: 1 },
|
|
O = [
|
|
"nodes",
|
|
"edges",
|
|
"defaultNodes",
|
|
"defaultEdges",
|
|
"onConnect",
|
|
"onConnectStart",
|
|
"onConnectEnd",
|
|
"onClickConnectStart",
|
|
"onClickConnectEnd",
|
|
"nodesDraggable",
|
|
"autoPanOnNodeFocus",
|
|
"nodesConnectable",
|
|
"nodesFocusable",
|
|
"edgesFocusable",
|
|
"edgesReconnectable",
|
|
"elevateNodesOnSelect",
|
|
"elevateEdgesOnSelect",
|
|
"minZoom",
|
|
"maxZoom",
|
|
"nodeExtent",
|
|
"onNodesChange",
|
|
"onEdgesChange",
|
|
"elementsSelectable",
|
|
"connectionMode",
|
|
"snapGrid",
|
|
"snapToGrid",
|
|
"translateExtent",
|
|
"connectOnClick",
|
|
"defaultEdgeOptions",
|
|
"fitView",
|
|
"fitViewOptions",
|
|
"onNodesDelete",
|
|
"onEdgesDelete",
|
|
"onDelete",
|
|
"onNodeDrag",
|
|
"onNodeDragStart",
|
|
"onNodeDragStop",
|
|
"onSelectionDrag",
|
|
"onSelectionDragStart",
|
|
"onSelectionDragStop",
|
|
"onMoveStart",
|
|
"onMove",
|
|
"onMoveEnd",
|
|
"noPanClassName",
|
|
"nodeOrigin",
|
|
"autoPanOnConnect",
|
|
"autoPanOnNodeDrag",
|
|
"onError",
|
|
"connectionRadius",
|
|
"isValidConnection",
|
|
"selectNodesOnDrag",
|
|
"nodeDragThreshold",
|
|
"connectionDragThreshold",
|
|
"onBeforeDelete",
|
|
"debug",
|
|
"autoPanSpeed",
|
|
"ariaLabelConfig",
|
|
"zIndexMode",
|
|
"rfId",
|
|
],
|
|
A = (e) => ({
|
|
setNodes: e.setNodes,
|
|
setEdges: e.setEdges,
|
|
setMinZoom: e.setMinZoom,
|
|
setMaxZoom: e.setMaxZoom,
|
|
setTranslateExtent: e.setTranslateExtent,
|
|
setNodeExtent: e.setNodeExtent,
|
|
reset: e.reset,
|
|
setDefaultNodesAndEdges: e.setDefaultNodesAndEdges,
|
|
}),
|
|
D = {
|
|
translateExtent: a.infiniteExtent,
|
|
nodeOrigin: k,
|
|
minZoom: 0.5,
|
|
maxZoom: 2,
|
|
elementsSelectable: !0,
|
|
noPanClassName: "nopan",
|
|
rfId: "1",
|
|
};
|
|
function L(e) {
|
|
let {
|
|
setNodes: t,
|
|
setEdges: n,
|
|
setMinZoom: o,
|
|
setMaxZoom: r,
|
|
setTranslateExtent: s,
|
|
setNodeExtent: d,
|
|
reset: u,
|
|
setDefaultNodesAndEdges: c,
|
|
} = p(A, l.shallow),
|
|
g = h();
|
|
(0, i.useEffect)(
|
|
() => (
|
|
c(e.defaultNodes, e.defaultEdges),
|
|
() => {
|
|
(f.current = D), u();
|
|
}
|
|
),
|
|
[],
|
|
);
|
|
let f = (0, i.useRef)(D);
|
|
return (
|
|
(0, i.useEffect)(
|
|
() => {
|
|
for (let i of O) {
|
|
let l = e[i];
|
|
l !== f.current[i] &&
|
|
void 0 !== e[i] &&
|
|
("nodes" === i
|
|
? t(l)
|
|
: "edges" === i
|
|
? n(l)
|
|
: "minZoom" === i
|
|
? o(l)
|
|
: "maxZoom" === i
|
|
? r(l)
|
|
: "translateExtent" === i
|
|
? s(l)
|
|
: "nodeExtent" === i
|
|
? d(l)
|
|
: "ariaLabelConfig" === i
|
|
? g.setState({
|
|
ariaLabelConfig: (0, a.mergeAriaLabelConfig)(
|
|
l,
|
|
),
|
|
})
|
|
: "fitView" === i
|
|
? g.setState({ fitViewQueued: l })
|
|
: "fitViewOptions" === i
|
|
? g.setState({ fitViewOptions: l })
|
|
: g.setState({ [i]: l }));
|
|
}
|
|
f.current = e;
|
|
},
|
|
O.map((t) => e[t]),
|
|
),
|
|
null
|
|
);
|
|
}
|
|
function j() {
|
|
return "u" < typeof window || !window.matchMedia
|
|
? null
|
|
: window.matchMedia("(prefers-color-scheme: dark)");
|
|
}
|
|
let R = "u" > typeof document ? document : null;
|
|
function z(e = null, t = { target: R, actInsideInputWithModifier: !0 }) {
|
|
let [n, o] = (0, i.useState)(!1),
|
|
r = (0, i.useRef)(!1),
|
|
s = (0, i.useRef)(new Set([])),
|
|
[l, d] = (0, i.useMemo)(() => {
|
|
if (null !== e) {
|
|
let t = (Array.isArray(e) ? e : [e])
|
|
.filter((e) => "string" == typeof e)
|
|
.map((e) =>
|
|
e.replace("+", "\n").replace("\n\n", "\n+").split("\n"),
|
|
),
|
|
n = t.reduce((e, t) => e.concat(...t), []);
|
|
return [t, n];
|
|
}
|
|
return [[], []];
|
|
}, [e]);
|
|
return (
|
|
(0, i.useEffect)(() => {
|
|
let n = t?.target ?? R,
|
|
i = t?.actInsideInputWithModifier ?? !0;
|
|
if (null !== e) {
|
|
let e = (e) => {
|
|
if (
|
|
((r.current =
|
|
e.ctrlKey || e.metaKey || e.shiftKey || e.altKey),
|
|
(!r.current || (r.current && !i)) && (0, a.isInputDOMNode)(e))
|
|
)
|
|
return !1;
|
|
let n = $(e.code, d);
|
|
if ((s.current.add(e[n]), F(l, s.current, !1))) {
|
|
let n = e.composedPath?.()?.[0] || e.target,
|
|
i = n?.nodeName === "BUTTON" || n?.nodeName === "A";
|
|
!1 !== t.preventDefault &&
|
|
(r.current || !i) &&
|
|
e.preventDefault(),
|
|
o(!0);
|
|
}
|
|
},
|
|
u = (e) => {
|
|
let t = $(e.code, d);
|
|
F(l, s.current, !0)
|
|
? (o(!1), s.current.clear())
|
|
: s.current.delete(e[t]),
|
|
"Meta" === e.key && s.current.clear(),
|
|
(r.current = !1);
|
|
},
|
|
c = () => {
|
|
s.current.clear(), o(!1);
|
|
};
|
|
return (
|
|
n?.addEventListener("keydown", e),
|
|
n?.addEventListener("keyup", u),
|
|
window.addEventListener("blur", c),
|
|
window.addEventListener("contextmenu", c),
|
|
() => {
|
|
n?.removeEventListener("keydown", e),
|
|
n?.removeEventListener("keyup", u),
|
|
window.removeEventListener("blur", c),
|
|
window.removeEventListener("contextmenu", c);
|
|
}
|
|
);
|
|
}
|
|
}, [e, o]),
|
|
n
|
|
);
|
|
}
|
|
function F(e, t, n) {
|
|
return e
|
|
.filter((e) => n || e.length === t.size)
|
|
.some((e) => e.every((e) => t.has(e)));
|
|
}
|
|
function $(e, t) {
|
|
return t.includes(e) ? "code" : "key";
|
|
}
|
|
function B(e, t) {
|
|
let n = [],
|
|
o = new Map(),
|
|
i = [];
|
|
for (let t of e)
|
|
if ("add" === t.type) {
|
|
i.push(t);
|
|
continue;
|
|
} else if ("remove" === t.type || "replace" === t.type)
|
|
o.set(t.id, [t]);
|
|
else {
|
|
let e = o.get(t.id);
|
|
e ? e.push(t) : o.set(t.id, [t]);
|
|
}
|
|
for (let e of t) {
|
|
let t = o.get(e.id);
|
|
if (!t) {
|
|
n.push(e);
|
|
continue;
|
|
}
|
|
if ("remove" === t[0].type) continue;
|
|
if ("replace" === t[0].type) {
|
|
n.push({ ...t[0].item });
|
|
continue;
|
|
}
|
|
let i = { ...e };
|
|
for (let e of t) {
|
|
var r = e,
|
|
a = i;
|
|
switch (r.type) {
|
|
case "select":
|
|
a.selected = r.selected;
|
|
break;
|
|
case "position":
|
|
void 0 !== r.position && (a.position = r.position),
|
|
void 0 !== r.dragging && (a.dragging = r.dragging);
|
|
break;
|
|
case "dimensions":
|
|
void 0 !== r.dimensions &&
|
|
((a.measured = { ...r.dimensions }),
|
|
r.setAttributes &&
|
|
((!0 === r.setAttributes || "width" === r.setAttributes) &&
|
|
(a.width = r.dimensions.width),
|
|
(!0 === r.setAttributes || "height" === r.setAttributes) &&
|
|
(a.height = r.dimensions.height))),
|
|
"boolean" == typeof r.resizing && (a.resizing = r.resizing);
|
|
}
|
|
}
|
|
n.push(i);
|
|
}
|
|
return (
|
|
i.length &&
|
|
i.forEach((e) => {
|
|
void 0 !== e.index
|
|
? n.splice(e.index, 0, { ...e.item })
|
|
: n.push({ ...e.item });
|
|
}),
|
|
n
|
|
);
|
|
}
|
|
function H(e, t) {
|
|
return B(e, t);
|
|
}
|
|
function V(e, t) {
|
|
return B(e, t);
|
|
}
|
|
function U(e, t) {
|
|
return { id: e, type: "select", selected: t };
|
|
}
|
|
function Y(e, t = new Set(), n = !1) {
|
|
let o = [];
|
|
for (let [i, r] of e) {
|
|
let e = t.has(i);
|
|
(void 0 !== r.selected || e) &&
|
|
r.selected !== e &&
|
|
(n && (r.selected = e), o.push(U(r.id, e)));
|
|
}
|
|
return o;
|
|
}
|
|
function W({ items: e = [], lookup: t }) {
|
|
let n = [],
|
|
o = new Map(e.map((e) => [e.id, e]));
|
|
for (let [o, i] of e.entries()) {
|
|
let e = t.get(i.id),
|
|
r = e?.internals?.userNode ?? e;
|
|
void 0 !== r &&
|
|
r !== i &&
|
|
n.push({ id: i.id, item: i, type: "replace" }),
|
|
void 0 === r && n.push({ item: i, type: "add", index: o });
|
|
}
|
|
for (let [e] of t)
|
|
void 0 === o.get(e) && n.push({ id: e, type: "remove" });
|
|
return n;
|
|
}
|
|
function X(e) {
|
|
return { id: e.id, type: "remove" };
|
|
}
|
|
let K = (e) => (0, a.isNodeBase)(e);
|
|
function q(e) {
|
|
return (0, i.forwardRef)(e);
|
|
}
|
|
let Z = "u" > typeof window ? i.useLayoutEffect : i.useEffect;
|
|
function G(e) {
|
|
let [t, n] = (0, i.useState)(BigInt(0)),
|
|
[o] = (0, i.useState)(() => {
|
|
var e;
|
|
let t;
|
|
return (
|
|
(e = () => n((e) => e + BigInt(1))),
|
|
(t = []),
|
|
{
|
|
get: () => t,
|
|
reset: () => {
|
|
t = [];
|
|
},
|
|
push: (n) => {
|
|
t.push(n), e();
|
|
},
|
|
}
|
|
);
|
|
});
|
|
return (
|
|
Z(() => {
|
|
let t = o.get();
|
|
t.length && (e(t), o.reset());
|
|
}, [t]),
|
|
o
|
|
);
|
|
}
|
|
let Q = (0, i.createContext)(null);
|
|
function J({ children: e }) {
|
|
let t = h(),
|
|
n = G(
|
|
(0, i.useCallback)((e) => {
|
|
let {
|
|
nodes: n = [],
|
|
setNodes: o,
|
|
hasDefaultNodes: i,
|
|
onNodesChange: r,
|
|
nodeLookup: a,
|
|
fitViewQueued: s,
|
|
onNodesChangeMiddlewareMap: l,
|
|
} = t.getState(),
|
|
d = n;
|
|
for (let t of e) d = "function" == typeof t ? t(d) : t;
|
|
let u = W({ items: d, lookup: a });
|
|
for (let e of l.values()) u = e(u);
|
|
i && o(d),
|
|
u.length > 0
|
|
? r?.(u)
|
|
: s &&
|
|
window.requestAnimationFrame(() => {
|
|
let {
|
|
fitViewQueued: e,
|
|
nodes: n,
|
|
setNodes: o,
|
|
} = t.getState();
|
|
e && o(n);
|
|
});
|
|
}, []),
|
|
),
|
|
r = G(
|
|
(0, i.useCallback)((e) => {
|
|
let {
|
|
edges: n = [],
|
|
setEdges: o,
|
|
hasDefaultEdges: i,
|
|
onEdgesChange: r,
|
|
edgeLookup: a,
|
|
} = t.getState(),
|
|
s = n;
|
|
for (let t of e) s = "function" == typeof t ? t(s) : t;
|
|
i ? o(s) : r && r(W({ items: s, lookup: a }));
|
|
}, []),
|
|
),
|
|
a = (0, i.useMemo)(() => ({ nodeQueue: n, edgeQueue: r }), []);
|
|
return (0, o.jsx)(Q.Provider, { value: a, children: e });
|
|
}
|
|
let ee = (e) => !!e.panZoom;
|
|
function et() {
|
|
let e,
|
|
t =
|
|
((e = h()),
|
|
(0, i.useMemo)(
|
|
() => ({
|
|
zoomIn: (t) => {
|
|
let { panZoom: n } = e.getState();
|
|
return n
|
|
? n.scaleBy(1.2, { duration: t?.duration })
|
|
: Promise.resolve(!1);
|
|
},
|
|
zoomOut: (t) => {
|
|
let { panZoom: n } = e.getState();
|
|
return n
|
|
? n.scaleBy(1 / 1.2, { duration: t?.duration })
|
|
: Promise.resolve(!1);
|
|
},
|
|
zoomTo: (t, n) => {
|
|
let { panZoom: o } = e.getState();
|
|
return o
|
|
? o.scaleTo(t, { duration: n?.duration })
|
|
: Promise.resolve(!1);
|
|
},
|
|
getZoom: () => e.getState().transform[2],
|
|
setViewport: async (t, n) => {
|
|
let {
|
|
transform: [o, i, r],
|
|
panZoom: a,
|
|
} = e.getState();
|
|
return a
|
|
? (await a.setViewport(
|
|
{ x: t.x ?? o, y: t.y ?? i, zoom: t.zoom ?? r },
|
|
n,
|
|
),
|
|
Promise.resolve(!0))
|
|
: Promise.resolve(!1);
|
|
},
|
|
getViewport: () => {
|
|
let [t, n, o] = e.getState().transform;
|
|
return { x: t, y: n, zoom: o };
|
|
},
|
|
setCenter: async (t, n, o) => e.getState().setCenter(t, n, o),
|
|
fitBounds: async (t, n) => {
|
|
let {
|
|
width: o,
|
|
height: i,
|
|
minZoom: r,
|
|
maxZoom: s,
|
|
panZoom: l,
|
|
} = e.getState(),
|
|
d = (0, a.getViewportForBounds)(
|
|
t,
|
|
o,
|
|
i,
|
|
r,
|
|
s,
|
|
n?.padding ?? 0.1,
|
|
);
|
|
return l
|
|
? (await l.setViewport(d, {
|
|
duration: n?.duration,
|
|
ease: n?.ease,
|
|
interpolate: n?.interpolate,
|
|
}),
|
|
Promise.resolve(!0))
|
|
: Promise.resolve(!1);
|
|
},
|
|
screenToFlowPosition: (t, n = {}) => {
|
|
let {
|
|
transform: o,
|
|
snapGrid: i,
|
|
snapToGrid: r,
|
|
domNode: s,
|
|
} = e.getState();
|
|
if (!s) return t;
|
|
let { x: l, y: d } = s.getBoundingClientRect(),
|
|
u = { x: t.x - l, y: t.y - d },
|
|
c = n.snapGrid ?? i,
|
|
p = n.snapToGrid ?? r;
|
|
return (0, a.pointToRendererPoint)(u, o, p, c);
|
|
},
|
|
flowToScreenPosition: (t) => {
|
|
let { transform: n, domNode: o } = e.getState();
|
|
if (!o) return t;
|
|
let { x: i, y: r } = o.getBoundingClientRect(),
|
|
s = (0, a.rendererPointToPoint)(t, n);
|
|
return { x: s.x + i, y: s.y + r };
|
|
},
|
|
}),
|
|
[],
|
|
)),
|
|
n = h(),
|
|
o = (function () {
|
|
let e = (0, i.useContext)(Q);
|
|
if (!e)
|
|
throw Error("useBatchContext must be used within a BatchProvider");
|
|
return e;
|
|
})(),
|
|
r = p(ee),
|
|
s = (0, i.useMemo)(() => {
|
|
let e = (e) => n.getState().nodeLookup.get(e),
|
|
t = (e) => {
|
|
o.nodeQueue.push(e);
|
|
},
|
|
i = (e) => {
|
|
o.edgeQueue.push(e);
|
|
},
|
|
r = (e) => {
|
|
let { nodeLookup: t, nodeOrigin: o } = n.getState(),
|
|
i = K(e) ? e : t.get(e.id),
|
|
r = i.parentId
|
|
? (0, a.evaluateAbsolutePosition)(
|
|
i.position,
|
|
i.measured,
|
|
i.parentId,
|
|
t,
|
|
o,
|
|
)
|
|
: i.position,
|
|
s = {
|
|
...i,
|
|
position: r,
|
|
width: i.measured?.width ?? i.width,
|
|
height: i.measured?.height ?? i.height,
|
|
};
|
|
return (0, a.nodeToRect)(s);
|
|
},
|
|
s = (e, n, o = { replace: !1 }) => {
|
|
t((t) =>
|
|
t.map((t) => {
|
|
if (t.id === e) {
|
|
let e = "function" == typeof n ? n(t) : n;
|
|
return o.replace && K(e) ? e : { ...t, ...e };
|
|
}
|
|
return t;
|
|
}),
|
|
);
|
|
},
|
|
l = (e, t, n = { replace: !1 }) => {
|
|
i((o) =>
|
|
o.map((o) => {
|
|
if (o.id === e) {
|
|
let e = "function" == typeof t ? t(o) : t;
|
|
return n.replace && (0, a.isEdgeBase)(e)
|
|
? e
|
|
: { ...o, ...e };
|
|
}
|
|
return o;
|
|
}),
|
|
);
|
|
};
|
|
return {
|
|
getNodes: () => n.getState().nodes.map((e) => ({ ...e })),
|
|
getNode: (t) => e(t)?.internals.userNode,
|
|
getInternalNode: e,
|
|
getEdges: () => {
|
|
let { edges: e = [] } = n.getState();
|
|
return e.map((e) => ({ ...e }));
|
|
},
|
|
getEdge: (e) => n.getState().edgeLookup.get(e),
|
|
setNodes: t,
|
|
setEdges: i,
|
|
addNodes: (e) => {
|
|
let t = Array.isArray(e) ? e : [e];
|
|
o.nodeQueue.push((e) => [...e, ...t]);
|
|
},
|
|
addEdges: (e) => {
|
|
let t = Array.isArray(e) ? e : [e];
|
|
o.edgeQueue.push((e) => [...e, ...t]);
|
|
},
|
|
toObject: () => {
|
|
let { nodes: e = [], edges: t = [], transform: o } = n.getState(),
|
|
[i, r, a] = o;
|
|
return {
|
|
nodes: e.map((e) => ({ ...e })),
|
|
edges: t.map((e) => ({ ...e })),
|
|
viewport: { x: i, y: r, zoom: a },
|
|
};
|
|
},
|
|
deleteElements: async ({ nodes: e = [], edges: t = [] }) => {
|
|
let {
|
|
nodes: o,
|
|
edges: i,
|
|
onNodesDelete: r,
|
|
onEdgesDelete: s,
|
|
triggerNodeChanges: l,
|
|
triggerEdgeChanges: d,
|
|
onDelete: u,
|
|
onBeforeDelete: c,
|
|
} = n.getState(),
|
|
{ nodes: p, edges: h } = await (0, a.getElementsToRemove)({
|
|
nodesToRemove: e,
|
|
edgesToRemove: t,
|
|
nodes: o,
|
|
edges: i,
|
|
onBeforeDelete: c,
|
|
}),
|
|
g = h.length > 0,
|
|
f = p.length > 0;
|
|
if (g) {
|
|
let e = h.map(X);
|
|
s?.(h), d(e);
|
|
}
|
|
if (f) {
|
|
let e = p.map(X);
|
|
r?.(p), l(e);
|
|
}
|
|
return (
|
|
(f || g) && u?.({ nodes: p, edges: h }),
|
|
{ deletedNodes: p, deletedEdges: h }
|
|
);
|
|
},
|
|
getIntersectingNodes: (e, t = !0, o) => {
|
|
let i = (0, a.isRectObject)(e),
|
|
s = i ? e : r(e),
|
|
l = void 0 !== o;
|
|
return s
|
|
? (o || n.getState().nodes).filter((o) => {
|
|
let r = n.getState().nodeLookup.get(o.id);
|
|
if (
|
|
r &&
|
|
!i &&
|
|
(o.id === e.id || !r.internals.positionAbsolute)
|
|
)
|
|
return !1;
|
|
let d = (0, a.nodeToRect)(l ? o : r),
|
|
u = (0, a.getOverlappingArea)(d, s);
|
|
return (
|
|
(t && u > 0) ||
|
|
u >= d.width * d.height ||
|
|
u >= s.width * s.height
|
|
);
|
|
})
|
|
: [];
|
|
},
|
|
isNodeIntersecting: (e, t, n = !0) => {
|
|
let o = (0, a.isRectObject)(e) ? e : r(e);
|
|
if (!o) return !1;
|
|
let i = (0, a.getOverlappingArea)(o, t);
|
|
return (
|
|
(n && i > 0) ||
|
|
i >= t.width * t.height ||
|
|
i >= o.width * o.height
|
|
);
|
|
},
|
|
updateNode: s,
|
|
updateNodeData: (e, t, n = { replace: !1 }) => {
|
|
s(
|
|
e,
|
|
(e) => {
|
|
let o = "function" == typeof t ? t(e) : t;
|
|
return n.replace
|
|
? { ...e, data: o }
|
|
: { ...e, data: { ...e.data, ...o } };
|
|
},
|
|
n,
|
|
);
|
|
},
|
|
updateEdge: l,
|
|
updateEdgeData: (e, t, n = { replace: !1 }) => {
|
|
l(
|
|
e,
|
|
(e) => {
|
|
let o = "function" == typeof t ? t(e) : t;
|
|
return n.replace
|
|
? { ...e, data: o }
|
|
: { ...e, data: { ...e.data, ...o } };
|
|
},
|
|
n,
|
|
);
|
|
},
|
|
getNodesBounds: (e) => {
|
|
let { nodeLookup: t, nodeOrigin: o } = n.getState();
|
|
return (0, a.getNodesBounds)(e, { nodeLookup: t, nodeOrigin: o });
|
|
},
|
|
getHandleConnections: ({ type: e, id: t, nodeId: o }) =>
|
|
Array.from(
|
|
n
|
|
.getState()
|
|
.connectionLookup.get(`${o}-${e}${t ? `-${t}` : ""}`)
|
|
?.values() ?? [],
|
|
),
|
|
getNodeConnections: ({ type: e, handleId: t, nodeId: o }) =>
|
|
Array.from(
|
|
n
|
|
.getState()
|
|
.connectionLookup.get(
|
|
`${o}${e ? (t ? `-${e}-${t}` : `-${e}`) : ""}`,
|
|
)
|
|
?.values() ?? [],
|
|
),
|
|
fitView: async (e) => {
|
|
let t = n.getState().fitViewResolver ?? (0, a.withResolvers)();
|
|
return (
|
|
n.setState({
|
|
fitViewQueued: !0,
|
|
fitViewOptions: e,
|
|
fitViewResolver: t,
|
|
}),
|
|
o.nodeQueue.push((e) => [...e]),
|
|
t.promise
|
|
);
|
|
},
|
|
};
|
|
}, []);
|
|
return (0, i.useMemo)(
|
|
() => ({ ...s, ...t, viewportInitialized: r }),
|
|
[r],
|
|
);
|
|
}
|
|
let en = (e) => e.selected,
|
|
eo = "u" > typeof window ? window : void 0,
|
|
ei = {
|
|
position: "absolute",
|
|
width: "100%",
|
|
height: "100%",
|
|
top: 0,
|
|
left: 0,
|
|
},
|
|
er = (e) => ({
|
|
userSelectionActive: e.userSelectionActive,
|
|
lib: e.lib,
|
|
connectionInProgress: e.connection.inProgress,
|
|
});
|
|
function ea({
|
|
onPaneContextMenu: e,
|
|
zoomOnScroll: t = !0,
|
|
zoomOnPinch: n = !0,
|
|
panOnScroll: r = !1,
|
|
panOnScrollSpeed: s = 0.5,
|
|
panOnScrollMode: d = a.PanOnScrollMode.Free,
|
|
zoomOnDoubleClick: u = !0,
|
|
panOnDrag: c = !0,
|
|
defaultViewport: g,
|
|
translateExtent: f,
|
|
minZoom: m,
|
|
maxZoom: y,
|
|
zoomActivationKeyCode: v,
|
|
preventScrolling: w = !0,
|
|
children: x,
|
|
noWheelClassName: S,
|
|
noPanClassName: b,
|
|
onViewportChange: I,
|
|
isControlledViewport: _,
|
|
paneClickDistance: E,
|
|
selectionOnDrag: M,
|
|
}) {
|
|
let C,
|
|
N = h(),
|
|
P = (0, i.useRef)(null),
|
|
{
|
|
userSelectionActive: k,
|
|
lib: T,
|
|
connectionInProgress: O,
|
|
} = p(er, l.shallow),
|
|
A = z(v),
|
|
D = (0, i.useRef)();
|
|
(C = h()),
|
|
(0, i.useEffect)(() => {
|
|
let e = () => {
|
|
if (!P.current || !(P.current.checkVisibility?.() ?? !0)) return !1;
|
|
let e = (0, a.getDimensions)(P.current);
|
|
(0 === e.height || 0 === e.width) &&
|
|
C.getState().onError?.("004", a.errorMessages.error004()),
|
|
C.setState({ width: e.width || 500, height: e.height || 500 });
|
|
};
|
|
if (P.current) {
|
|
e(), window.addEventListener("resize", e);
|
|
let t = new ResizeObserver(() => e());
|
|
return (
|
|
t.observe(P.current),
|
|
() => {
|
|
window.removeEventListener("resize", e),
|
|
t && P.current && t.unobserve(P.current);
|
|
}
|
|
);
|
|
}
|
|
}, []);
|
|
let L = (0, i.useCallback)(
|
|
(e) => {
|
|
I?.({ x: e[0], y: e[1], zoom: e[2] }),
|
|
_ || N.setState({ transform: e });
|
|
},
|
|
[I, _],
|
|
);
|
|
return (
|
|
(0, i.useEffect)(() => {
|
|
if (P.current) {
|
|
D.current = (0, a.XYPanZoom)({
|
|
domNode: P.current,
|
|
minZoom: m,
|
|
maxZoom: y,
|
|
translateExtent: f,
|
|
viewport: g,
|
|
onDraggingChange: (e) => N.setState({ paneDragging: e }),
|
|
onPanZoomStart: (e, t) => {
|
|
let { onViewportChangeStart: n, onMoveStart: o } = N.getState();
|
|
o?.(e, t), n?.(t);
|
|
},
|
|
onPanZoom: (e, t) => {
|
|
let { onViewportChange: n, onMove: o } = N.getState();
|
|
o?.(e, t), n?.(t);
|
|
},
|
|
onPanZoomEnd: (e, t) => {
|
|
let { onViewportChangeEnd: n, onMoveEnd: o } = N.getState();
|
|
o?.(e, t), n?.(t);
|
|
},
|
|
});
|
|
let { x: e, y: t, zoom: n } = D.current.getViewport();
|
|
return (
|
|
N.setState({
|
|
panZoom: D.current,
|
|
transform: [e, t, n],
|
|
domNode: P.current.closest(".react-flow"),
|
|
}),
|
|
() => {
|
|
D.current?.destroy();
|
|
}
|
|
);
|
|
}
|
|
}, []),
|
|
(0, i.useEffect)(() => {
|
|
D.current?.update({
|
|
onPaneContextMenu: e,
|
|
zoomOnScroll: t,
|
|
zoomOnPinch: n,
|
|
panOnScroll: r,
|
|
panOnScrollSpeed: s,
|
|
panOnScrollMode: d,
|
|
zoomOnDoubleClick: u,
|
|
panOnDrag: c,
|
|
zoomActivationKeyPressed: A,
|
|
preventScrolling: w,
|
|
noPanClassName: b,
|
|
userSelectionActive: k,
|
|
noWheelClassName: S,
|
|
lib: T,
|
|
onTransformChange: L,
|
|
connectionInProgress: O,
|
|
selectionOnDrag: M,
|
|
paneClickDistance: E,
|
|
});
|
|
}, [e, t, n, r, s, d, u, c, A, w, b, k, S, T, L, O, M, E]),
|
|
(0, o.jsx)("div", {
|
|
className: "react-flow__renderer",
|
|
ref: P,
|
|
style: ei,
|
|
children: x,
|
|
})
|
|
);
|
|
}
|
|
let es = (e) => ({
|
|
userSelectionActive: e.userSelectionActive,
|
|
userSelectionRect: e.userSelectionRect,
|
|
});
|
|
function el() {
|
|
let { userSelectionActive: e, userSelectionRect: t } = p(es, l.shallow);
|
|
return e && t
|
|
? (0, o.jsx)("div", {
|
|
className: "react-flow__selection react-flow__container",
|
|
style: {
|
|
width: t.width,
|
|
height: t.height,
|
|
transform: `translate(${t.x}px, ${t.y}px)`,
|
|
},
|
|
})
|
|
: null;
|
|
}
|
|
let ed = (e, t) => (n) => {
|
|
n.target === t.current && e?.(n);
|
|
},
|
|
eu = (e) => ({
|
|
userSelectionActive: e.userSelectionActive,
|
|
elementsSelectable: e.elementsSelectable,
|
|
connectionInProgress: e.connection.inProgress,
|
|
dragging: e.paneDragging,
|
|
});
|
|
function ec({
|
|
isSelecting: e,
|
|
selectionKeyPressed: t,
|
|
selectionMode: n = a.SelectionMode.Full,
|
|
panOnDrag: s,
|
|
paneClickDistance: d,
|
|
selectionOnDrag: u,
|
|
onSelectionStart: c,
|
|
onSelectionEnd: g,
|
|
onPaneClick: f,
|
|
onPaneContextMenu: m,
|
|
onPaneScroll: y,
|
|
onPaneMouseEnter: v,
|
|
onPaneMouseMove: w,
|
|
onPaneMouseLeave: x,
|
|
children: S,
|
|
}) {
|
|
let b = h(),
|
|
{
|
|
userSelectionActive: I,
|
|
elementsSelectable: _,
|
|
dragging: E,
|
|
connectionInProgress: M,
|
|
} = p(eu, l.shallow),
|
|
C = _ && (e || I),
|
|
N = (0, i.useRef)(null),
|
|
P = (0, i.useRef)(),
|
|
k = (0, i.useRef)(new Set()),
|
|
T = (0, i.useRef)(new Set()),
|
|
O = (0, i.useRef)(!1),
|
|
A = (e) => {
|
|
if (O.current || M) {
|
|
O.current = !1;
|
|
return;
|
|
}
|
|
f?.(e),
|
|
b.getState().resetSelectedElements(),
|
|
b.setState({ nodesSelectionActive: !1 });
|
|
},
|
|
D = !0 === s || (Array.isArray(s) && s.includes(0));
|
|
return (0, o.jsxs)("div", {
|
|
className: (0, r.default)([
|
|
"react-flow__pane",
|
|
{ draggable: D, dragging: E, selection: e },
|
|
]),
|
|
onClick: C ? void 0 : ed(A, N),
|
|
onContextMenu: ed((e) => {
|
|
Array.isArray(s) && s?.includes(2) ? e.preventDefault() : m?.(e);
|
|
}, N),
|
|
onWheel: ed(y ? (e) => y(e) : void 0, N),
|
|
onPointerEnter: C ? void 0 : v,
|
|
onPointerMove: C
|
|
? (e) => {
|
|
let {
|
|
userSelectionRect: o,
|
|
transform: i,
|
|
nodeLookup: r,
|
|
edgeLookup: s,
|
|
connectionLookup: l,
|
|
triggerNodeChanges: u,
|
|
triggerEdgeChanges: p,
|
|
defaultEdgeOptions: h,
|
|
resetSelectedElements: g,
|
|
} = b.getState();
|
|
if (!P.current || !o) return;
|
|
let { x: f, y: m } = (0, a.getEventPosition)(
|
|
e.nativeEvent,
|
|
P.current,
|
|
),
|
|
{ startX: y, startY: v } = o;
|
|
if (!O.current) {
|
|
if (Math.hypot(f - y, m - v) <= (t ? 0 : d)) return;
|
|
g(), c?.(e);
|
|
}
|
|
O.current = !0;
|
|
let w = {
|
|
startX: y,
|
|
startY: v,
|
|
x: f < y ? f : y,
|
|
y: m < v ? m : v,
|
|
width: Math.abs(f - y),
|
|
height: Math.abs(m - v),
|
|
},
|
|
x = k.current,
|
|
S = T.current;
|
|
(k.current = new Set(
|
|
(0, a.getNodesInside)(
|
|
r,
|
|
w,
|
|
i,
|
|
n === a.SelectionMode.Partial,
|
|
!0,
|
|
).map((e) => e.id),
|
|
)),
|
|
(T.current = new Set());
|
|
let I = h?.selectable ?? !0;
|
|
for (let e of k.current) {
|
|
let t = l.get(e);
|
|
if (t)
|
|
for (let { edgeId: e } of t.values()) {
|
|
let t = s.get(e);
|
|
t && (t.selectable ?? I) && T.current.add(e);
|
|
}
|
|
}
|
|
(0, a.areSetsEqual)(x, k.current) || u(Y(r, k.current, !0)),
|
|
(0, a.areSetsEqual)(S, T.current) || p(Y(s, T.current)),
|
|
b.setState({
|
|
userSelectionRect: w,
|
|
userSelectionActive: !0,
|
|
nodesSelectionActive: !1,
|
|
});
|
|
}
|
|
: w,
|
|
onPointerUp: C
|
|
? (e) => {
|
|
0 === e.button &&
|
|
(e.target?.releasePointerCapture?.(e.pointerId),
|
|
!I &&
|
|
e.target === N.current &&
|
|
b.getState().userSelectionRect &&
|
|
A?.(e),
|
|
b.setState({
|
|
userSelectionActive: !1,
|
|
userSelectionRect: null,
|
|
}),
|
|
O.current &&
|
|
(g?.(e),
|
|
b.setState({ nodesSelectionActive: k.current.size > 0 })));
|
|
}
|
|
: void 0,
|
|
onPointerDownCapture: C
|
|
? (n) => {
|
|
let { domNode: o } = b.getState();
|
|
if (((P.current = o?.getBoundingClientRect()), !P.current))
|
|
return;
|
|
let i = n.target === N.current;
|
|
if (
|
|
(!i && n.target.closest(".nokey")) ||
|
|
!e ||
|
|
!((u && i) || t) ||
|
|
0 !== n.button ||
|
|
!n.isPrimary
|
|
)
|
|
return;
|
|
n.target?.setPointerCapture?.(n.pointerId), (O.current = !1);
|
|
let { x: r, y: s } = (0, a.getEventPosition)(
|
|
n.nativeEvent,
|
|
P.current,
|
|
);
|
|
b.setState({
|
|
userSelectionRect: {
|
|
width: 0,
|
|
height: 0,
|
|
startX: r,
|
|
startY: s,
|
|
x: r,
|
|
y: s,
|
|
},
|
|
}),
|
|
i || (n.stopPropagation(), n.preventDefault());
|
|
}
|
|
: void 0,
|
|
onClickCapture: C
|
|
? (e) => {
|
|
O.current && (e.stopPropagation(), (O.current = !1));
|
|
}
|
|
: void 0,
|
|
onPointerLeave: x,
|
|
ref: N,
|
|
style: ei,
|
|
children: [S, (0, o.jsx)(el, {})],
|
|
});
|
|
}
|
|
function ep({ id: e, store: t, unselect: n = !1, nodeRef: o }) {
|
|
let {
|
|
addSelectedNodes: i,
|
|
unselectNodesAndEdges: r,
|
|
multiSelectionActive: s,
|
|
nodeLookup: l,
|
|
onError: d,
|
|
} = t.getState(),
|
|
u = l.get(e);
|
|
u
|
|
? (t.setState({ nodesSelectionActive: !1 }),
|
|
u.selected
|
|
? (n || (u.selected && s)) &&
|
|
(r({ nodes: [u], edges: [] }),
|
|
requestAnimationFrame(() => o?.current?.blur()))
|
|
: i([e]))
|
|
: d?.("012", a.errorMessages.error012(e));
|
|
}
|
|
function eh({
|
|
nodeRef: e,
|
|
disabled: t = !1,
|
|
noDragClassName: n,
|
|
handleSelector: o,
|
|
nodeId: r,
|
|
isSelectable: s,
|
|
nodeClickDistance: l,
|
|
}) {
|
|
let d = h(),
|
|
[u, c] = (0, i.useState)(!1),
|
|
p = (0, i.useRef)();
|
|
return (
|
|
(0, i.useEffect)(() => {
|
|
p.current = (0, a.XYDrag)({
|
|
getStoreItems: () => d.getState(),
|
|
onNodeMouseDown: (t) => {
|
|
ep({ id: t, store: d, nodeRef: e });
|
|
},
|
|
onDragStart: () => {
|
|
c(!0);
|
|
},
|
|
onDragStop: () => {
|
|
c(!1);
|
|
},
|
|
});
|
|
}, []),
|
|
(0, i.useEffect)(() => {
|
|
if (t) p.current?.destroy();
|
|
else if (e.current)
|
|
return (
|
|
p.current?.update({
|
|
noDragClassName: n,
|
|
handleSelector: o,
|
|
domNode: e.current,
|
|
isSelectable: s,
|
|
nodeId: r,
|
|
nodeClickDistance: l,
|
|
}),
|
|
() => {
|
|
p.current?.destroy();
|
|
}
|
|
);
|
|
}, [n, o, t, s, e, r]),
|
|
u
|
|
);
|
|
}
|
|
function eg() {
|
|
let e = h();
|
|
return (0, i.useCallback)((t) => {
|
|
let {
|
|
nodeExtent: n,
|
|
snapToGrid: o,
|
|
snapGrid: i,
|
|
nodesDraggable: r,
|
|
onError: s,
|
|
updateNodePositions: l,
|
|
nodeLookup: d,
|
|
nodeOrigin: u,
|
|
} = e.getState(),
|
|
c = new Map(),
|
|
p = (e) =>
|
|
e.selected && (e.draggable || (r && void 0 === e.draggable)),
|
|
h = o ? i[0] : 5,
|
|
g = o ? i[1] : 5,
|
|
f = t.direction.x * h * t.factor,
|
|
m = t.direction.y * g * t.factor;
|
|
for (let [, e] of d) {
|
|
if (!p(e)) continue;
|
|
let t = {
|
|
x: e.internals.positionAbsolute.x + f,
|
|
y: e.internals.positionAbsolute.y + m,
|
|
};
|
|
o && (t = (0, a.snapPosition)(t, i));
|
|
let { position: r, positionAbsolute: l } = (0,
|
|
a.calculateNodePosition)({
|
|
nodeId: e.id,
|
|
nextPosition: t,
|
|
nodeLookup: d,
|
|
nodeExtent: n,
|
|
nodeOrigin: u,
|
|
onError: s,
|
|
});
|
|
(e.position = r), (e.internals.positionAbsolute = l), c.set(e.id, e);
|
|
}
|
|
l(c);
|
|
}, []);
|
|
}
|
|
let ef = (0, i.createContext)(null),
|
|
em = ef.Provider;
|
|
ef.Consumer;
|
|
let ey = () => (0, i.useContext)(ef),
|
|
ev = (e) => ({
|
|
connectOnClick: e.connectOnClick,
|
|
noPanClassName: e.noPanClassName,
|
|
rfId: e.rfId,
|
|
}),
|
|
ew = (0, i.memo)(
|
|
q(function (
|
|
{
|
|
type: e = "source",
|
|
position: t = a.Position.Top,
|
|
isValidConnection: n,
|
|
isConnectable: i = !0,
|
|
isConnectableStart: s = !0,
|
|
isConnectableEnd: d = !0,
|
|
id: u,
|
|
onConnect: c,
|
|
children: g,
|
|
className: f,
|
|
onMouseDown: m,
|
|
onTouchStart: y,
|
|
...v
|
|
},
|
|
w,
|
|
) {
|
|
let x = u || null,
|
|
S = "target" === e,
|
|
b = h(),
|
|
I = ey(),
|
|
{
|
|
connectOnClick: _,
|
|
noPanClassName: E,
|
|
rfId: M,
|
|
} = p(ev, l.shallow),
|
|
{
|
|
connectingFrom: C,
|
|
connectingTo: N,
|
|
clickConnecting: P,
|
|
isPossibleEndHandle: k,
|
|
connectionInProcess: T,
|
|
clickConnectionInProcess: O,
|
|
valid: A,
|
|
} = p((t) => {
|
|
let {
|
|
connectionClickStartHandle: n,
|
|
connectionMode: o,
|
|
connection: i,
|
|
} = t,
|
|
{ fromHandle: r, toHandle: s, isValid: l } = i,
|
|
d = s?.nodeId === I && s?.id === x && s?.type === e;
|
|
return {
|
|
connectingFrom: r?.nodeId === I && r?.id === x && r?.type === e,
|
|
connectingTo: d,
|
|
clickConnecting:
|
|
n?.nodeId === I && n?.id === x && n?.type === e,
|
|
isPossibleEndHandle:
|
|
o === a.ConnectionMode.Strict
|
|
? r?.type !== e
|
|
: I !== r?.nodeId || x !== r?.id,
|
|
connectionInProcess: !!r,
|
|
clickConnectionInProcess: !!n,
|
|
valid: d && l,
|
|
};
|
|
}, l.shallow);
|
|
I || b.getState().onError?.("010", a.errorMessages.error010());
|
|
let D = (e) => {
|
|
let {
|
|
defaultEdgeOptions: t,
|
|
onConnect: n,
|
|
hasDefaultEdges: o,
|
|
} = b.getState(),
|
|
i = { ...t, ...e };
|
|
if (o) {
|
|
let { edges: e, setEdges: t } = b.getState();
|
|
t((0, a.addEdge)(i, e));
|
|
}
|
|
n?.(i), c?.(i);
|
|
},
|
|
L = (e) => {
|
|
if (!I) return;
|
|
let t = (0, a.isMouseEvent)(e.nativeEvent);
|
|
if (s && ((t && 0 === e.button) || !t)) {
|
|
let t = b.getState();
|
|
a.XYHandle.onPointerDown(e.nativeEvent, {
|
|
handleDomNode: e.currentTarget,
|
|
autoPanOnConnect: t.autoPanOnConnect,
|
|
connectionMode: t.connectionMode,
|
|
connectionRadius: t.connectionRadius,
|
|
domNode: t.domNode,
|
|
nodeLookup: t.nodeLookup,
|
|
lib: t.lib,
|
|
isTarget: S,
|
|
handleId: x,
|
|
nodeId: I,
|
|
flowId: t.rfId,
|
|
panBy: t.panBy,
|
|
cancelConnection: t.cancelConnection,
|
|
onConnectStart: t.onConnectStart,
|
|
onConnectEnd: t.onConnectEnd,
|
|
updateConnection: t.updateConnection,
|
|
onConnect: D,
|
|
isValidConnection: n || t.isValidConnection,
|
|
getTransform: () => b.getState().transform,
|
|
getFromHandle: () => b.getState().connection.fromHandle,
|
|
autoPanSpeed: t.autoPanSpeed,
|
|
dragThreshold: t.connectionDragThreshold,
|
|
});
|
|
}
|
|
t ? m?.(e) : y?.(e);
|
|
};
|
|
return (0, o.jsx)("div", {
|
|
"data-handleid": x,
|
|
"data-nodeid": I,
|
|
"data-handlepos": t,
|
|
"data-id": `${M}-${I}-${x}-${e}`,
|
|
className: (0, r.default)([
|
|
"react-flow__handle",
|
|
`react-flow__handle-${t}`,
|
|
"nodrag",
|
|
E,
|
|
f,
|
|
{
|
|
source: !S,
|
|
target: S,
|
|
connectable: i,
|
|
connectablestart: s,
|
|
connectableend: d,
|
|
clickconnecting: P,
|
|
connectingfrom: C,
|
|
connectingto: N,
|
|
valid: A,
|
|
connectionindicator: i && (!T || k) && (T || O ? d : s),
|
|
},
|
|
]),
|
|
onMouseDown: L,
|
|
onTouchStart: L,
|
|
onClick: _
|
|
? (t) => {
|
|
let {
|
|
onClickConnectStart: o,
|
|
onClickConnectEnd: i,
|
|
connectionClickStartHandle: r,
|
|
connectionMode: l,
|
|
isValidConnection: d,
|
|
lib: u,
|
|
rfId: c,
|
|
nodeLookup: p,
|
|
connection: h,
|
|
} = b.getState();
|
|
if (!I || (!r && !s)) return;
|
|
if (!r) {
|
|
o?.(t.nativeEvent, {
|
|
nodeId: I,
|
|
handleId: x,
|
|
handleType: e,
|
|
}),
|
|
b.setState({
|
|
connectionClickStartHandle: {
|
|
nodeId: I,
|
|
type: e,
|
|
id: x,
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
let g = (0, a.getHostForElement)(t.target),
|
|
f = n || d,
|
|
{ connection: m, isValid: y } = a.XYHandle.isValid(
|
|
t.nativeEvent,
|
|
{
|
|
handle: { nodeId: I, id: x, type: e },
|
|
connectionMode: l,
|
|
fromNodeId: r.nodeId,
|
|
fromHandleId: r.id || null,
|
|
fromType: r.type,
|
|
isValidConnection: f,
|
|
flowId: c,
|
|
doc: g,
|
|
lib: u,
|
|
nodeLookup: p,
|
|
},
|
|
);
|
|
y && m && D(m);
|
|
let v = structuredClone(h);
|
|
delete v.inProgress,
|
|
(v.toPosition = v.toHandle ? v.toHandle.position : null),
|
|
i?.(t, v),
|
|
b.setState({ connectionClickStartHandle: null });
|
|
}
|
|
: void 0,
|
|
ref: w,
|
|
...v,
|
|
children: g,
|
|
});
|
|
}),
|
|
),
|
|
ex = {
|
|
ArrowUp: { x: 0, y: -1 },
|
|
ArrowDown: { x: 0, y: 1 },
|
|
ArrowLeft: { x: -1, y: 0 },
|
|
ArrowRight: { x: 1, y: 0 },
|
|
},
|
|
eS = {
|
|
input: function ({
|
|
data: e,
|
|
isConnectable: t,
|
|
sourcePosition: n = a.Position.Bottom,
|
|
}) {
|
|
return (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
e?.label,
|
|
(0, o.jsx)(ew, { type: "source", position: n, isConnectable: t }),
|
|
],
|
|
});
|
|
},
|
|
default: function ({
|
|
data: e,
|
|
isConnectable: t,
|
|
targetPosition: n = a.Position.Top,
|
|
sourcePosition: i = a.Position.Bottom,
|
|
}) {
|
|
return (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
(0, o.jsx)(ew, { type: "target", position: n, isConnectable: t }),
|
|
e?.label,
|
|
(0, o.jsx)(ew, { type: "source", position: i, isConnectable: t }),
|
|
],
|
|
});
|
|
},
|
|
output: function ({
|
|
data: e,
|
|
isConnectable: t,
|
|
targetPosition: n = a.Position.Top,
|
|
}) {
|
|
return (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
(0, o.jsx)(ew, { type: "target", position: n, isConnectable: t }),
|
|
e?.label,
|
|
],
|
|
});
|
|
},
|
|
group: function () {
|
|
return null;
|
|
},
|
|
},
|
|
eb = (e) => {
|
|
let {
|
|
width: t,
|
|
height: n,
|
|
x: o,
|
|
y: i,
|
|
} = (0, a.getInternalNodesBounds)(e.nodeLookup, {
|
|
filter: (e) => !!e.selected,
|
|
});
|
|
return {
|
|
width: (0, a.isNumeric)(t) ? t : null,
|
|
height: (0, a.isNumeric)(n) ? n : null,
|
|
userSelectionActive: e.userSelectionActive,
|
|
transformString: `translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${i}px)`,
|
|
};
|
|
};
|
|
function eI({
|
|
onSelectionContextMenu: e,
|
|
noPanClassName: t,
|
|
disableKeyboardA11y: n,
|
|
}) {
|
|
let a = h(),
|
|
{
|
|
width: s,
|
|
height: d,
|
|
transformString: u,
|
|
userSelectionActive: c,
|
|
} = p(eb, l.shallow),
|
|
g = eg(),
|
|
f = (0, i.useRef)(null);
|
|
if (
|
|
((0, i.useEffect)(() => {
|
|
n || f.current?.focus({ preventScroll: !0 });
|
|
}, [n]),
|
|
eh({ nodeRef: f }),
|
|
c || !s || !d)
|
|
)
|
|
return null;
|
|
let m = e
|
|
? (t) => {
|
|
e(
|
|
t,
|
|
a.getState().nodes.filter((e) => e.selected),
|
|
);
|
|
}
|
|
: void 0;
|
|
return (0, o.jsx)("div", {
|
|
className: (0, r.default)([
|
|
"react-flow__nodesselection",
|
|
"react-flow__container",
|
|
t,
|
|
]),
|
|
style: { transform: u },
|
|
children: (0, o.jsx)("div", {
|
|
ref: f,
|
|
className: "react-flow__nodesselection-rect",
|
|
onContextMenu: m,
|
|
tabIndex: n ? void 0 : -1,
|
|
onKeyDown: n
|
|
? void 0
|
|
: (e) => {
|
|
Object.prototype.hasOwnProperty.call(ex, e.key) &&
|
|
(e.preventDefault(),
|
|
g({ direction: ex[e.key], factor: e.shiftKey ? 4 : 1 }));
|
|
},
|
|
style: { width: s, height: d },
|
|
}),
|
|
});
|
|
}
|
|
let e_ = "u" > typeof window ? window : void 0,
|
|
eE = (e) => ({
|
|
nodesSelectionActive: e.nodesSelectionActive,
|
|
userSelectionActive: e.userSelectionActive,
|
|
});
|
|
function eM({
|
|
children: e,
|
|
onPaneClick: t,
|
|
onPaneMouseEnter: n,
|
|
onPaneMouseMove: r,
|
|
onPaneMouseLeave: a,
|
|
onPaneContextMenu: s,
|
|
onPaneScroll: d,
|
|
paneClickDistance: u,
|
|
deleteKeyCode: c,
|
|
selectionKeyCode: g,
|
|
selectionOnDrag: f,
|
|
selectionMode: m,
|
|
onSelectionStart: y,
|
|
onSelectionEnd: v,
|
|
multiSelectionKeyCode: w,
|
|
panActivationKeyCode: x,
|
|
zoomActivationKeyCode: S,
|
|
elementsSelectable: b,
|
|
zoomOnScroll: I,
|
|
zoomOnPinch: _,
|
|
panOnScroll: E,
|
|
panOnScrollSpeed: M,
|
|
panOnScrollMode: C,
|
|
zoomOnDoubleClick: N,
|
|
panOnDrag: P,
|
|
defaultViewport: k,
|
|
translateExtent: T,
|
|
minZoom: O,
|
|
maxZoom: A,
|
|
preventScrolling: D,
|
|
onSelectionContextMenu: L,
|
|
noWheelClassName: j,
|
|
noPanClassName: R,
|
|
disableKeyboardA11y: F,
|
|
onViewportChange: $,
|
|
isControlledViewport: B,
|
|
}) {
|
|
let { nodesSelectionActive: H, userSelectionActive: V } = p(
|
|
eE,
|
|
l.shallow,
|
|
),
|
|
U = z(g, { target: e_ }),
|
|
Y = z(x, { target: e_ }),
|
|
W = Y || P,
|
|
X = Y || E,
|
|
K = f && !0 !== W,
|
|
q = U || V || K;
|
|
return (
|
|
!(function ({ deleteKeyCode: e, multiSelectionKeyCode: t }) {
|
|
let n = h(),
|
|
{ deleteElements: o } = et(),
|
|
r = z(e, { actInsideInputWithModifier: !1 }),
|
|
a = z(t, { target: eo });
|
|
(0, i.useEffect)(() => {
|
|
if (r) {
|
|
let { edges: e, nodes: t } = n.getState();
|
|
o({ nodes: t.filter(en), edges: e.filter(en) }),
|
|
n.setState({ nodesSelectionActive: !1 });
|
|
}
|
|
}, [r]),
|
|
(0, i.useEffect)(() => {
|
|
n.setState({ multiSelectionActive: a });
|
|
}, [a]);
|
|
})({ deleteKeyCode: c, multiSelectionKeyCode: w }),
|
|
(0, o.jsx)(ea, {
|
|
onPaneContextMenu: s,
|
|
elementsSelectable: b,
|
|
zoomOnScroll: I,
|
|
zoomOnPinch: _,
|
|
panOnScroll: X,
|
|
panOnScrollSpeed: M,
|
|
panOnScrollMode: C,
|
|
zoomOnDoubleClick: N,
|
|
panOnDrag: !U && W,
|
|
defaultViewport: k,
|
|
translateExtent: T,
|
|
minZoom: O,
|
|
maxZoom: A,
|
|
zoomActivationKeyCode: S,
|
|
preventScrolling: D,
|
|
noWheelClassName: j,
|
|
noPanClassName: R,
|
|
onViewportChange: $,
|
|
isControlledViewport: B,
|
|
paneClickDistance: u,
|
|
selectionOnDrag: K,
|
|
children: (0, o.jsxs)(ec, {
|
|
onSelectionStart: y,
|
|
onSelectionEnd: v,
|
|
onPaneClick: t,
|
|
onPaneMouseEnter: n,
|
|
onPaneMouseMove: r,
|
|
onPaneMouseLeave: a,
|
|
onPaneContextMenu: s,
|
|
onPaneScroll: d,
|
|
panOnDrag: W,
|
|
isSelecting: !!q,
|
|
selectionMode: m,
|
|
selectionKeyPressed: U,
|
|
paneClickDistance: u,
|
|
selectionOnDrag: K,
|
|
children: [
|
|
e,
|
|
H &&
|
|
(0, o.jsx)(eI, {
|
|
onSelectionContextMenu: L,
|
|
noPanClassName: R,
|
|
disableKeyboardA11y: F,
|
|
}),
|
|
],
|
|
}),
|
|
})
|
|
);
|
|
}
|
|
eM.displayName = "FlowRenderer";
|
|
let eC = (0, i.memo)(eM),
|
|
eN = (e) => e.updateNodeInternals;
|
|
var eP = (0, i.memo)(function ({
|
|
id: e,
|
|
onClick: t,
|
|
onMouseEnter: n,
|
|
onMouseMove: s,
|
|
onMouseLeave: d,
|
|
onContextMenu: u,
|
|
onDoubleClick: c,
|
|
nodesDraggable: g,
|
|
elementsSelectable: f,
|
|
nodesConnectable: y,
|
|
nodesFocusable: v,
|
|
resizeObserver: w,
|
|
noDragClassName: x,
|
|
noPanClassName: S,
|
|
disableKeyboardA11y: b,
|
|
rfId: I,
|
|
nodeTypes: _,
|
|
nodeClickDistance: E,
|
|
onError: M,
|
|
}) {
|
|
let {
|
|
node: C,
|
|
internals: N,
|
|
isParent: P,
|
|
} = p((t) => {
|
|
let n = t.nodeLookup.get(e),
|
|
o = t.parentLookup.has(e);
|
|
return { node: n, internals: n.internals, isParent: o };
|
|
}, l.shallow),
|
|
k = C.type || "default",
|
|
T = _?.[k] || eS[k];
|
|
void 0 === T &&
|
|
(M?.("003", a.errorMessages.error003(k)),
|
|
(k = "default"),
|
|
(T = _?.default || eS.default));
|
|
let O = !!(C.draggable || (g && void 0 === C.draggable)),
|
|
A = !!(C.selectable || (f && void 0 === C.selectable)),
|
|
D = !!(C.connectable || (y && void 0 === C.connectable)),
|
|
L = !!(C.focusable || (v && void 0 === C.focusable)),
|
|
j = h(),
|
|
R = (0, a.nodeHasDimensions)(C),
|
|
z = (function ({
|
|
node: e,
|
|
nodeType: t,
|
|
hasDimensions: n,
|
|
resizeObserver: o,
|
|
}) {
|
|
let r = h(),
|
|
a = (0, i.useRef)(null),
|
|
s = (0, i.useRef)(null),
|
|
l = (0, i.useRef)(e.sourcePosition),
|
|
d = (0, i.useRef)(e.targetPosition),
|
|
u = (0, i.useRef)(t),
|
|
c = n && !!e.internals.handleBounds;
|
|
return (
|
|
(0, i.useEffect)(() => {
|
|
!a.current ||
|
|
e.hidden ||
|
|
(c && s.current === a.current) ||
|
|
(s.current && o?.unobserve(s.current),
|
|
o?.observe(a.current),
|
|
(s.current = a.current));
|
|
}, [c, e.hidden]),
|
|
(0, i.useEffect)(
|
|
() => () => {
|
|
s.current && (o?.unobserve(s.current), (s.current = null));
|
|
},
|
|
[],
|
|
),
|
|
(0, i.useEffect)(() => {
|
|
if (a.current) {
|
|
let n = u.current !== t,
|
|
o = l.current !== e.sourcePosition,
|
|
i = d.current !== e.targetPosition;
|
|
(n || o || i) &&
|
|
((u.current = t),
|
|
(l.current = e.sourcePosition),
|
|
(d.current = e.targetPosition),
|
|
r
|
|
.getState()
|
|
.updateNodeInternals(
|
|
new Map([
|
|
[e.id, { id: e.id, nodeElement: a.current, force: !0 }],
|
|
]),
|
|
));
|
|
}
|
|
}, [e.id, t, e.sourcePosition, e.targetPosition]),
|
|
a
|
|
);
|
|
})({ node: C, nodeType: k, hasDimensions: R, resizeObserver: w }),
|
|
F = eh({
|
|
nodeRef: z,
|
|
disabled: C.hidden || !O,
|
|
noDragClassName: x,
|
|
handleSelector: C.dragHandle,
|
|
nodeId: e,
|
|
isSelectable: A,
|
|
nodeClickDistance: E,
|
|
}),
|
|
$ = eg();
|
|
if (C.hidden) return null;
|
|
let B = (0, a.getNodeDimensions)(C),
|
|
H =
|
|
void 0 === C.internals.handleBounds
|
|
? {
|
|
width: C.width ?? C.initialWidth ?? C.style?.width,
|
|
height: C.height ?? C.initialHeight ?? C.style?.height,
|
|
}
|
|
: {
|
|
width: C.width ?? C.style?.width,
|
|
height: C.height ?? C.style?.height,
|
|
},
|
|
V = A || O || t || n || s || d,
|
|
U = n ? (e) => n(e, { ...N.userNode }) : void 0,
|
|
Y = s ? (e) => s(e, { ...N.userNode }) : void 0,
|
|
W = d ? (e) => d(e, { ...N.userNode }) : void 0,
|
|
X = u ? (e) => u(e, { ...N.userNode }) : void 0,
|
|
K = c ? (e) => c(e, { ...N.userNode }) : void 0;
|
|
return (0, o.jsx)("div", {
|
|
className: (0, r.default)([
|
|
"react-flow__node",
|
|
`react-flow__node-${k}`,
|
|
{ [S]: O },
|
|
C.className,
|
|
{
|
|
selected: C.selected,
|
|
selectable: A,
|
|
parent: P,
|
|
draggable: O,
|
|
dragging: F,
|
|
},
|
|
]),
|
|
ref: z,
|
|
style: {
|
|
zIndex: N.z,
|
|
transform: `translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,
|
|
pointerEvents: V ? "all" : "none",
|
|
visibility: R ? "visible" : "hidden",
|
|
...C.style,
|
|
...H,
|
|
},
|
|
"data-id": e,
|
|
"data-testid": `rf__node-${e}`,
|
|
onMouseEnter: U,
|
|
onMouseMove: Y,
|
|
onMouseLeave: W,
|
|
onContextMenu: X,
|
|
onClick: (n) => {
|
|
let { selectNodesOnDrag: o, nodeDragThreshold: i } = j.getState();
|
|
A && (!o || !O || i > 0) && ep({ id: e, store: j, nodeRef: z }),
|
|
t && t(n, { ...N.userNode });
|
|
},
|
|
onDoubleClick: K,
|
|
onKeyDown: L
|
|
? (t) => {
|
|
if (!(0, a.isInputDOMNode)(t.nativeEvent) && !b) {
|
|
if (a.elementSelectionKeys.includes(t.key) && A)
|
|
ep({
|
|
id: e,
|
|
store: j,
|
|
unselect: "Escape" === t.key,
|
|
nodeRef: z,
|
|
});
|
|
else if (
|
|
O &&
|
|
C.selected &&
|
|
Object.prototype.hasOwnProperty.call(ex, t.key)
|
|
) {
|
|
t.preventDefault();
|
|
let { ariaLabelConfig: e } = j.getState();
|
|
j.setState({
|
|
ariaLiveMessage: e["node.a11yDescription.ariaLiveMessage"]({
|
|
direction: t.key.replace("Arrow", "").toLowerCase(),
|
|
x: ~~N.positionAbsolute.x,
|
|
y: ~~N.positionAbsolute.y,
|
|
}),
|
|
}),
|
|
$({ direction: ex[t.key], factor: t.shiftKey ? 4 : 1 });
|
|
}
|
|
}
|
|
}
|
|
: void 0,
|
|
tabIndex: L ? 0 : void 0,
|
|
onFocus: L
|
|
? () => {
|
|
if (b || !z.current?.matches(":focus-visible")) return;
|
|
let {
|
|
transform: t,
|
|
width: n,
|
|
height: o,
|
|
autoPanOnNodeFocus: i,
|
|
setCenter: r,
|
|
} = j.getState();
|
|
!i ||
|
|
(0, a.getNodesInside)(
|
|
new Map([[e, C]]),
|
|
{ x: 0, y: 0, width: n, height: o },
|
|
t,
|
|
!0,
|
|
).length > 0 ||
|
|
r(C.position.x + B.width / 2, C.position.y + B.height / 2, {
|
|
zoom: t[2],
|
|
});
|
|
}
|
|
: void 0,
|
|
role: C.ariaRole ?? (L ? "group" : void 0),
|
|
"aria-roledescription": "node",
|
|
"aria-describedby": b ? void 0 : `${m}-${I}`,
|
|
"aria-label": C.ariaLabel,
|
|
...C.domAttributes,
|
|
children: (0, o.jsx)(em, {
|
|
value: e,
|
|
children: (0, o.jsx)(T, {
|
|
id: e,
|
|
data: C.data,
|
|
type: k,
|
|
positionAbsoluteX: N.positionAbsolute.x,
|
|
positionAbsoluteY: N.positionAbsolute.y,
|
|
selected: C.selected ?? !1,
|
|
selectable: A,
|
|
draggable: O,
|
|
deletable: C.deletable ?? !0,
|
|
isConnectable: D,
|
|
sourcePosition: C.sourcePosition,
|
|
targetPosition: C.targetPosition,
|
|
dragging: F,
|
|
dragHandle: C.dragHandle,
|
|
zIndex: N.z,
|
|
parentId: C.parentId,
|
|
...B,
|
|
}),
|
|
}),
|
|
});
|
|
});
|
|
let ek = (e) => ({
|
|
nodesDraggable: e.nodesDraggable,
|
|
nodesConnectable: e.nodesConnectable,
|
|
nodesFocusable: e.nodesFocusable,
|
|
elementsSelectable: e.elementsSelectable,
|
|
onError: e.onError,
|
|
});
|
|
function eT(e) {
|
|
var t;
|
|
let {
|
|
nodesDraggable: n,
|
|
nodesConnectable: r,
|
|
nodesFocusable: s,
|
|
elementsSelectable: d,
|
|
onError: u,
|
|
} = p(ek, l.shallow),
|
|
c =
|
|
((t = e.onlyRenderVisibleElements),
|
|
p(
|
|
(0, i.useCallback)(
|
|
(e) =>
|
|
t
|
|
? (0, a.getNodesInside)(
|
|
e.nodeLookup,
|
|
{ x: 0, y: 0, width: e.width, height: e.height },
|
|
e.transform,
|
|
!0,
|
|
).map((e) => e.id)
|
|
: Array.from(e.nodeLookup.keys()),
|
|
[t],
|
|
),
|
|
l.shallow,
|
|
)),
|
|
h = (function () {
|
|
let e = p(eN),
|
|
[t] = (0, i.useState)(() =>
|
|
"u" < typeof ResizeObserver
|
|
? null
|
|
: new ResizeObserver((t) => {
|
|
let n = new Map();
|
|
t.forEach((e) => {
|
|
let t = e.target.getAttribute("data-id");
|
|
n.set(t, { id: t, nodeElement: e.target, force: !0 });
|
|
}),
|
|
e(n);
|
|
}),
|
|
);
|
|
return (
|
|
(0, i.useEffect)(
|
|
() => () => {
|
|
t?.disconnect();
|
|
},
|
|
[t],
|
|
),
|
|
t
|
|
);
|
|
})();
|
|
return (0, o.jsx)("div", {
|
|
className: "react-flow__nodes",
|
|
style: ei,
|
|
children: c.map((t) =>
|
|
(0, o.jsx)(
|
|
eP,
|
|
{
|
|
id: t,
|
|
nodeTypes: e.nodeTypes,
|
|
nodeExtent: e.nodeExtent,
|
|
onClick: e.onNodeClick,
|
|
onMouseEnter: e.onNodeMouseEnter,
|
|
onMouseMove: e.onNodeMouseMove,
|
|
onMouseLeave: e.onNodeMouseLeave,
|
|
onContextMenu: e.onNodeContextMenu,
|
|
onDoubleClick: e.onNodeDoubleClick,
|
|
noDragClassName: e.noDragClassName,
|
|
noPanClassName: e.noPanClassName,
|
|
rfId: e.rfId,
|
|
disableKeyboardA11y: e.disableKeyboardA11y,
|
|
resizeObserver: h,
|
|
nodesDraggable: n,
|
|
nodesConnectable: r,
|
|
nodesFocusable: s,
|
|
elementsSelectable: d,
|
|
nodeClickDistance: e.nodeClickDistance,
|
|
onError: u,
|
|
},
|
|
t,
|
|
),
|
|
),
|
|
});
|
|
}
|
|
eT.displayName = "NodeRenderer";
|
|
let eO = (0, i.memo)(eT),
|
|
eA = {
|
|
[a.MarkerType.Arrow]: ({ color: e = "none", strokeWidth: t = 1 }) => {
|
|
let n = { strokeWidth: t, ...(e && { stroke: e }) };
|
|
return (0, o.jsx)("polyline", {
|
|
className: "arrow",
|
|
style: n,
|
|
strokeLinecap: "round",
|
|
fill: "none",
|
|
strokeLinejoin: "round",
|
|
points: "-5,-4 0,0 -5,4",
|
|
});
|
|
},
|
|
[a.MarkerType.ArrowClosed]: ({
|
|
color: e = "none",
|
|
strokeWidth: t = 1,
|
|
}) => {
|
|
let n = { strokeWidth: t, ...(e && { stroke: e, fill: e }) };
|
|
return (0, o.jsx)("polyline", {
|
|
className: "arrowclosed",
|
|
style: n,
|
|
strokeLinecap: "round",
|
|
strokeLinejoin: "round",
|
|
points: "-5,-4 0,0 -5,4 -5,-4",
|
|
});
|
|
},
|
|
},
|
|
eD = ({
|
|
id: e,
|
|
type: t,
|
|
color: n,
|
|
width: r = 12.5,
|
|
height: s = 12.5,
|
|
markerUnits: l = "strokeWidth",
|
|
strokeWidth: d,
|
|
orient: u = "auto-start-reverse",
|
|
}) => {
|
|
let c,
|
|
p =
|
|
((c = h()),
|
|
(0, i.useMemo)(
|
|
() =>
|
|
Object.prototype.hasOwnProperty.call(eA, t)
|
|
? eA[t]
|
|
: (c.getState().onError?.("009", a.errorMessages.error009(t)),
|
|
null),
|
|
[t],
|
|
));
|
|
return p
|
|
? (0, o.jsx)("marker", {
|
|
className: "react-flow__arrowhead",
|
|
id: e,
|
|
markerWidth: `${r}`,
|
|
markerHeight: `${s}`,
|
|
viewBox: "-10 -10 20 20",
|
|
markerUnits: l,
|
|
orient: u,
|
|
refX: "0",
|
|
refY: "0",
|
|
children: (0, o.jsx)(p, { color: n, strokeWidth: d }),
|
|
})
|
|
: null;
|
|
},
|
|
eL = ({ defaultColor: e, rfId: t }) => {
|
|
let n = p((e) => e.edges),
|
|
r = p((e) => e.defaultEdgeOptions),
|
|
s = (0, i.useMemo)(
|
|
() =>
|
|
(0, a.createMarkerIds)(n, {
|
|
id: t,
|
|
defaultColor: e,
|
|
defaultMarkerStart: r?.markerStart,
|
|
defaultMarkerEnd: r?.markerEnd,
|
|
}),
|
|
[n, r, t, e],
|
|
);
|
|
return s.length
|
|
? (0, o.jsx)("svg", {
|
|
className: "react-flow__marker",
|
|
"aria-hidden": "true",
|
|
children: (0, o.jsx)("defs", {
|
|
children: s.map((e) =>
|
|
(0, o.jsx)(
|
|
eD,
|
|
{
|
|
id: e.id,
|
|
type: e.type,
|
|
color: e.color,
|
|
width: e.width,
|
|
height: e.height,
|
|
markerUnits: e.markerUnits,
|
|
strokeWidth: e.strokeWidth,
|
|
orient: e.orient,
|
|
},
|
|
e.id,
|
|
),
|
|
),
|
|
}),
|
|
})
|
|
: null;
|
|
};
|
|
eL.displayName = "MarkerDefinitions";
|
|
var ej = (0, i.memo)(eL);
|
|
function eR({
|
|
x: e,
|
|
y: t,
|
|
label: n,
|
|
labelStyle: a,
|
|
labelShowBg: s = !0,
|
|
labelBgStyle: l,
|
|
labelBgPadding: d = [2, 4],
|
|
labelBgBorderRadius: u = 2,
|
|
children: c,
|
|
className: p,
|
|
...h
|
|
}) {
|
|
let [g, f] = (0, i.useState)({ x: 1, y: 0, width: 0, height: 0 }),
|
|
m = (0, r.default)(["react-flow__edge-textwrapper", p]),
|
|
y = (0, i.useRef)(null);
|
|
return ((0, i.useEffect)(() => {
|
|
if (y.current) {
|
|
let e = y.current.getBBox();
|
|
f({ x: e.x, y: e.y, width: e.width, height: e.height });
|
|
}
|
|
}, [n]),
|
|
n)
|
|
? (0, o.jsxs)("g", {
|
|
transform: `translate(${e - g.width / 2} ${t - g.height / 2})`,
|
|
className: m,
|
|
visibility: g.width ? "visible" : "hidden",
|
|
...h,
|
|
children: [
|
|
s &&
|
|
(0, o.jsx)("rect", {
|
|
width: g.width + 2 * d[0],
|
|
x: -d[0],
|
|
y: -d[1],
|
|
height: g.height + 2 * d[1],
|
|
className: "react-flow__edge-textbg",
|
|
style: l,
|
|
rx: u,
|
|
ry: u,
|
|
}),
|
|
(0, o.jsx)("text", {
|
|
className: "react-flow__edge-text",
|
|
y: g.height / 2,
|
|
dy: "0.3em",
|
|
ref: y,
|
|
style: a,
|
|
children: n,
|
|
}),
|
|
c,
|
|
],
|
|
})
|
|
: null;
|
|
}
|
|
eR.displayName = "EdgeText";
|
|
let ez = (0, i.memo)(eR);
|
|
function eF({
|
|
path: e,
|
|
labelX: t,
|
|
labelY: n,
|
|
label: i,
|
|
labelStyle: s,
|
|
labelShowBg: l,
|
|
labelBgStyle: d,
|
|
labelBgPadding: u,
|
|
labelBgBorderRadius: c,
|
|
interactionWidth: p = 20,
|
|
...h
|
|
}) {
|
|
return (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
(0, o.jsx)("path", {
|
|
...h,
|
|
d: e,
|
|
fill: "none",
|
|
className: (0, r.default)(["react-flow__edge-path", h.className]),
|
|
}),
|
|
p
|
|
? (0, o.jsx)("path", {
|
|
d: e,
|
|
fill: "none",
|
|
strokeOpacity: 0,
|
|
strokeWidth: p,
|
|
className: "react-flow__edge-interaction",
|
|
})
|
|
: null,
|
|
i && (0, a.isNumeric)(t) && (0, a.isNumeric)(n)
|
|
? (0, o.jsx)(ez, {
|
|
x: t,
|
|
y: n,
|
|
label: i,
|
|
labelStyle: s,
|
|
labelShowBg: l,
|
|
labelBgStyle: d,
|
|
labelBgPadding: u,
|
|
labelBgBorderRadius: c,
|
|
})
|
|
: null,
|
|
],
|
|
});
|
|
}
|
|
function e$({ pos: e, x1: t, y1: n, x2: o, y2: i }) {
|
|
return e === a.Position.Left || e === a.Position.Right
|
|
? [0.5 * (t + o), n]
|
|
: [t, 0.5 * (n + i)];
|
|
}
|
|
function eB({
|
|
sourceX: e,
|
|
sourceY: t,
|
|
sourcePosition: n = a.Position.Bottom,
|
|
targetX: o,
|
|
targetY: i,
|
|
targetPosition: r = a.Position.Top,
|
|
}) {
|
|
let [s, l] = e$({ pos: n, x1: e, y1: t, x2: o, y2: i }),
|
|
[d, u] = e$({ pos: r, x1: o, y1: i, x2: e, y2: t }),
|
|
[c, p, h, g] = (0, a.getBezierEdgeCenter)({
|
|
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, h, g];
|
|
}
|
|
function eH(e) {
|
|
return (0, i.memo)(
|
|
({
|
|
id: t,
|
|
sourceX: n,
|
|
sourceY: i,
|
|
targetX: r,
|
|
targetY: a,
|
|
sourcePosition: s,
|
|
targetPosition: l,
|
|
label: d,
|
|
labelStyle: u,
|
|
labelShowBg: c,
|
|
labelBgStyle: p,
|
|
labelBgPadding: h,
|
|
labelBgBorderRadius: g,
|
|
style: f,
|
|
markerEnd: m,
|
|
markerStart: y,
|
|
interactionWidth: v,
|
|
}) => {
|
|
let [w, x, S] = eB({
|
|
sourceX: n,
|
|
sourceY: i,
|
|
sourcePosition: s,
|
|
targetX: r,
|
|
targetY: a,
|
|
targetPosition: l,
|
|
}),
|
|
b = e.isInternal ? void 0 : t;
|
|
return (0, o.jsx)(eF, {
|
|
id: b,
|
|
path: w,
|
|
labelX: x,
|
|
labelY: S,
|
|
label: d,
|
|
labelStyle: u,
|
|
labelShowBg: c,
|
|
labelBgStyle: p,
|
|
labelBgPadding: h,
|
|
labelBgBorderRadius: g,
|
|
style: f,
|
|
markerEnd: m,
|
|
markerStart: y,
|
|
interactionWidth: v,
|
|
});
|
|
},
|
|
);
|
|
}
|
|
let eV = eH({ isInternal: !1 }),
|
|
eU = eH({ isInternal: !0 });
|
|
function eY(e) {
|
|
return (0, i.memo)(
|
|
({
|
|
id: t,
|
|
sourceX: n,
|
|
sourceY: i,
|
|
targetX: r,
|
|
targetY: s,
|
|
label: l,
|
|
labelStyle: d,
|
|
labelShowBg: u,
|
|
labelBgStyle: c,
|
|
labelBgPadding: p,
|
|
labelBgBorderRadius: h,
|
|
style: g,
|
|
sourcePosition: f = a.Position.Bottom,
|
|
targetPosition: m = a.Position.Top,
|
|
markerEnd: y,
|
|
markerStart: v,
|
|
pathOptions: w,
|
|
interactionWidth: x,
|
|
}) => {
|
|
let [S, b, I] = (0, a.getSmoothStepPath)({
|
|
sourceX: n,
|
|
sourceY: i,
|
|
sourcePosition: f,
|
|
targetX: r,
|
|
targetY: s,
|
|
targetPosition: m,
|
|
borderRadius: w?.borderRadius,
|
|
offset: w?.offset,
|
|
stepPosition: w?.stepPosition,
|
|
}),
|
|
_ = e.isInternal ? void 0 : t;
|
|
return (0, o.jsx)(eF, {
|
|
id: _,
|
|
path: S,
|
|
labelX: b,
|
|
labelY: I,
|
|
label: l,
|
|
labelStyle: d,
|
|
labelShowBg: u,
|
|
labelBgStyle: c,
|
|
labelBgPadding: p,
|
|
labelBgBorderRadius: h,
|
|
style: g,
|
|
markerEnd: y,
|
|
markerStart: v,
|
|
interactionWidth: x,
|
|
});
|
|
},
|
|
);
|
|
}
|
|
(eV.displayName = "SimpleBezierEdge"),
|
|
(eU.displayName = "SimpleBezierEdgeInternal");
|
|
let eW = eY({ isInternal: !1 }),
|
|
eX = eY({ isInternal: !0 });
|
|
function eK(e) {
|
|
return (0, i.memo)(({ id: t, ...n }) => {
|
|
let r = e.isInternal ? void 0 : t;
|
|
return (0, o.jsx)(eW, {
|
|
...n,
|
|
id: r,
|
|
pathOptions: (0, i.useMemo)(
|
|
() => ({ borderRadius: 0, offset: n.pathOptions?.offset }),
|
|
[n.pathOptions?.offset],
|
|
),
|
|
});
|
|
});
|
|
}
|
|
(eW.displayName = "SmoothStepEdge"),
|
|
(eX.displayName = "SmoothStepEdgeInternal");
|
|
let eq = eK({ isInternal: !1 }),
|
|
eZ = eK({ isInternal: !0 });
|
|
function eG(e) {
|
|
return (0, i.memo)(
|
|
({
|
|
id: t,
|
|
sourceX: n,
|
|
sourceY: i,
|
|
targetX: r,
|
|
targetY: s,
|
|
label: l,
|
|
labelStyle: d,
|
|
labelShowBg: u,
|
|
labelBgStyle: c,
|
|
labelBgPadding: p,
|
|
labelBgBorderRadius: h,
|
|
style: g,
|
|
markerEnd: f,
|
|
markerStart: m,
|
|
interactionWidth: y,
|
|
}) => {
|
|
let [v, w, x] = (0, a.getStraightPath)({
|
|
sourceX: n,
|
|
sourceY: i,
|
|
targetX: r,
|
|
targetY: s,
|
|
}),
|
|
S = e.isInternal ? void 0 : t;
|
|
return (0, o.jsx)(eF, {
|
|
id: S,
|
|
path: v,
|
|
labelX: w,
|
|
labelY: x,
|
|
label: l,
|
|
labelStyle: d,
|
|
labelShowBg: u,
|
|
labelBgStyle: c,
|
|
labelBgPadding: p,
|
|
labelBgBorderRadius: h,
|
|
style: g,
|
|
markerEnd: f,
|
|
markerStart: m,
|
|
interactionWidth: y,
|
|
});
|
|
},
|
|
);
|
|
}
|
|
(eq.displayName = "StepEdge"), (eZ.displayName = "StepEdgeInternal");
|
|
let eQ = eG({ isInternal: !1 }),
|
|
eJ = eG({ isInternal: !0 });
|
|
function e0(e) {
|
|
return (0, i.memo)(
|
|
({
|
|
id: t,
|
|
sourceX: n,
|
|
sourceY: i,
|
|
targetX: r,
|
|
targetY: s,
|
|
sourcePosition: l = a.Position.Bottom,
|
|
targetPosition: d = a.Position.Top,
|
|
label: u,
|
|
labelStyle: c,
|
|
labelShowBg: p,
|
|
labelBgStyle: h,
|
|
labelBgPadding: g,
|
|
labelBgBorderRadius: f,
|
|
style: m,
|
|
markerEnd: y,
|
|
markerStart: v,
|
|
pathOptions: w,
|
|
interactionWidth: x,
|
|
}) => {
|
|
let [S, b, I] = (0, a.getBezierPath)({
|
|
sourceX: n,
|
|
sourceY: i,
|
|
sourcePosition: l,
|
|
targetX: r,
|
|
targetY: s,
|
|
targetPosition: d,
|
|
curvature: w?.curvature,
|
|
}),
|
|
_ = e.isInternal ? void 0 : t;
|
|
return (0, o.jsx)(eF, {
|
|
id: _,
|
|
path: S,
|
|
labelX: b,
|
|
labelY: I,
|
|
label: u,
|
|
labelStyle: c,
|
|
labelShowBg: p,
|
|
labelBgStyle: h,
|
|
labelBgPadding: g,
|
|
labelBgBorderRadius: f,
|
|
style: m,
|
|
markerEnd: y,
|
|
markerStart: v,
|
|
interactionWidth: x,
|
|
});
|
|
},
|
|
);
|
|
}
|
|
(eQ.displayName = "StraightEdge"),
|
|
(eJ.displayName = "StraightEdgeInternal");
|
|
let e1 = e0({ isInternal: !1 }),
|
|
e2 = e0({ isInternal: !0 });
|
|
(e1.displayName = "BezierEdge"), (e2.displayName = "BezierEdgeInternal");
|
|
let e3 = {
|
|
default: e2,
|
|
straight: eJ,
|
|
step: eZ,
|
|
smoothstep: eX,
|
|
simplebezier: eU,
|
|
},
|
|
e5 = {
|
|
sourceX: null,
|
|
sourceY: null,
|
|
targetX: null,
|
|
targetY: null,
|
|
sourcePosition: null,
|
|
targetPosition: null,
|
|
},
|
|
e4 = "react-flow__edgeupdater";
|
|
function e6({
|
|
position: e,
|
|
centerX: t,
|
|
centerY: n,
|
|
radius: i = 10,
|
|
onMouseDown: s,
|
|
onMouseEnter: l,
|
|
onMouseOut: d,
|
|
type: u,
|
|
}) {
|
|
return (0, o.jsx)("circle", {
|
|
onMouseDown: s,
|
|
onMouseEnter: l,
|
|
onMouseOut: d,
|
|
className: (0, r.default)([e4, `${e4}-${u}`]),
|
|
cx: e === a.Position.Left ? t - i : e === a.Position.Right ? t + i : t,
|
|
cy: e === a.Position.Top ? n - i : e === a.Position.Bottom ? n + i : n,
|
|
r: i,
|
|
stroke: "transparent",
|
|
fill: "transparent",
|
|
});
|
|
}
|
|
function e7({
|
|
isReconnectable: e,
|
|
reconnectRadius: t,
|
|
edge: n,
|
|
sourceX: i,
|
|
sourceY: r,
|
|
targetX: s,
|
|
targetY: l,
|
|
sourcePosition: d,
|
|
targetPosition: u,
|
|
onReconnect: c,
|
|
onReconnectStart: p,
|
|
onReconnectEnd: g,
|
|
setReconnecting: f,
|
|
setUpdateHover: m,
|
|
}) {
|
|
let y = h(),
|
|
v = (e, t) => {
|
|
if (0 !== e.button) return;
|
|
let {
|
|
autoPanOnConnect: o,
|
|
domNode: i,
|
|
isValidConnection: r,
|
|
connectionMode: s,
|
|
connectionRadius: l,
|
|
lib: d,
|
|
onConnectStart: u,
|
|
onConnectEnd: h,
|
|
cancelConnection: m,
|
|
nodeLookup: v,
|
|
rfId: w,
|
|
panBy: x,
|
|
updateConnection: S,
|
|
} = y.getState(),
|
|
b = "target" === t.type;
|
|
a.XYHandle.onPointerDown(e.nativeEvent, {
|
|
autoPanOnConnect: o,
|
|
connectionMode: s,
|
|
connectionRadius: l,
|
|
domNode: i,
|
|
handleId: t.id,
|
|
nodeId: t.nodeId,
|
|
nodeLookup: v,
|
|
isTarget: b,
|
|
edgeUpdaterType: t.type,
|
|
lib: d,
|
|
flowId: w,
|
|
cancelConnection: m,
|
|
panBy: x,
|
|
isValidConnection: r,
|
|
onConnect: (e) => c?.(n, e),
|
|
onConnectStart: (o, i) => {
|
|
f(!0), p?.(e, n, t.type), u?.(o, i);
|
|
},
|
|
onConnectEnd: h,
|
|
onReconnectEnd: (e, o) => {
|
|
f(!1), g?.(e, n, t.type, o);
|
|
},
|
|
updateConnection: S,
|
|
getTransform: () => y.getState().transform,
|
|
getFromHandle: () => y.getState().connection.fromHandle,
|
|
dragThreshold: y.getState().connectionDragThreshold,
|
|
handleDomNode: e.currentTarget,
|
|
});
|
|
},
|
|
w = () => m(!0),
|
|
x = () => m(!1);
|
|
return (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
(!0 === e || "source" === e) &&
|
|
(0, o.jsx)(e6, {
|
|
position: d,
|
|
centerX: i,
|
|
centerY: r,
|
|
radius: t,
|
|
onMouseDown: (e) =>
|
|
v(e, {
|
|
nodeId: n.target,
|
|
id: n.targetHandle ?? null,
|
|
type: "target",
|
|
}),
|
|
onMouseEnter: w,
|
|
onMouseOut: x,
|
|
type: "source",
|
|
}),
|
|
(!0 === e || "target" === e) &&
|
|
(0, o.jsx)(e6, {
|
|
position: u,
|
|
centerX: s,
|
|
centerY: l,
|
|
radius: t,
|
|
onMouseDown: (e) =>
|
|
v(e, {
|
|
nodeId: n.source,
|
|
id: n.sourceHandle ?? null,
|
|
type: "source",
|
|
}),
|
|
onMouseEnter: w,
|
|
onMouseOut: x,
|
|
type: "target",
|
|
}),
|
|
],
|
|
});
|
|
}
|
|
var e8 = (0, i.memo)(function ({
|
|
id: e,
|
|
edgesFocusable: t,
|
|
edgesReconnectable: n,
|
|
elementsSelectable: s,
|
|
onClick: d,
|
|
onDoubleClick: u,
|
|
onContextMenu: c,
|
|
onMouseEnter: g,
|
|
onMouseMove: f,
|
|
onMouseLeave: m,
|
|
reconnectRadius: v,
|
|
onReconnect: w,
|
|
onReconnectStart: x,
|
|
onReconnectEnd: S,
|
|
rfId: b,
|
|
edgeTypes: I,
|
|
noPanClassName: _,
|
|
onError: E,
|
|
disableKeyboardA11y: M,
|
|
}) {
|
|
let C = p((t) => t.edgeLookup.get(e)),
|
|
N = p((e) => e.defaultEdgeOptions),
|
|
P = (C = N ? { ...N, ...C } : C).type || "default",
|
|
k = I?.[P] || e3[P];
|
|
void 0 === k &&
|
|
(E?.("011", a.errorMessages.error011(P)),
|
|
(P = "default"),
|
|
(k = I?.default || e3.default));
|
|
let T = !!(C.focusable || (t && void 0 === C.focusable)),
|
|
O =
|
|
void 0 !== w &&
|
|
(C.reconnectable || (n && void 0 === C.reconnectable)),
|
|
A = !!(C.selectable || (s && void 0 === C.selectable)),
|
|
D = (0, i.useRef)(null),
|
|
[L, j] = (0, i.useState)(!1),
|
|
[R, z] = (0, i.useState)(!1),
|
|
F = h(),
|
|
{
|
|
zIndex: $,
|
|
sourceX: B,
|
|
sourceY: H,
|
|
targetX: V,
|
|
targetY: U,
|
|
sourcePosition: Y,
|
|
targetPosition: W,
|
|
} = p(
|
|
(0, i.useCallback)(
|
|
(t) => {
|
|
let n = t.nodeLookup.get(C.source),
|
|
o = t.nodeLookup.get(C.target);
|
|
if (!n || !o) return { zIndex: C.zIndex, ...e5 };
|
|
let i = (0, a.getEdgePosition)({
|
|
id: e,
|
|
sourceNode: n,
|
|
targetNode: o,
|
|
sourceHandle: C.sourceHandle || null,
|
|
targetHandle: C.targetHandle || null,
|
|
connectionMode: t.connectionMode,
|
|
onError: E,
|
|
});
|
|
return {
|
|
zIndex: (0, a.getElevatedEdgeZIndex)({
|
|
selected: C.selected,
|
|
zIndex: C.zIndex,
|
|
sourceNode: n,
|
|
targetNode: o,
|
|
elevateOnSelect: t.elevateEdgesOnSelect,
|
|
zIndexMode: t.zIndexMode,
|
|
}),
|
|
...(i || e5),
|
|
};
|
|
},
|
|
[
|
|
C.source,
|
|
C.target,
|
|
C.sourceHandle,
|
|
C.targetHandle,
|
|
C.selected,
|
|
C.zIndex,
|
|
],
|
|
),
|
|
l.shallow,
|
|
),
|
|
X = (0, i.useMemo)(
|
|
() =>
|
|
C.markerStart
|
|
? `url('#${(0, a.getMarkerId)(C.markerStart, b)}')`
|
|
: void 0,
|
|
[C.markerStart, b],
|
|
),
|
|
K = (0, i.useMemo)(
|
|
() =>
|
|
C.markerEnd
|
|
? `url('#${(0, a.getMarkerId)(C.markerEnd, b)}')`
|
|
: void 0,
|
|
[C.markerEnd, b],
|
|
);
|
|
if (C.hidden || null === B || null === H || null === V || null === U)
|
|
return null;
|
|
let q = u
|
|
? (e) => {
|
|
u(e, { ...C });
|
|
}
|
|
: void 0,
|
|
Z = c
|
|
? (e) => {
|
|
c(e, { ...C });
|
|
}
|
|
: void 0,
|
|
G = g
|
|
? (e) => {
|
|
g(e, { ...C });
|
|
}
|
|
: void 0,
|
|
Q = f
|
|
? (e) => {
|
|
f(e, { ...C });
|
|
}
|
|
: void 0,
|
|
J = m
|
|
? (e) => {
|
|
m(e, { ...C });
|
|
}
|
|
: void 0;
|
|
return (0, o.jsx)("svg", {
|
|
style: { zIndex: $ },
|
|
children: (0, o.jsxs)("g", {
|
|
className: (0, r.default)([
|
|
"react-flow__edge",
|
|
`react-flow__edge-${P}`,
|
|
C.className,
|
|
_,
|
|
{
|
|
selected: C.selected,
|
|
animated: C.animated,
|
|
inactive: !A && !d,
|
|
updating: L,
|
|
selectable: A,
|
|
},
|
|
]),
|
|
onClick: (t) => {
|
|
let {
|
|
addSelectedEdges: n,
|
|
unselectNodesAndEdges: o,
|
|
multiSelectionActive: i,
|
|
} = F.getState();
|
|
A &&
|
|
(F.setState({ nodesSelectionActive: !1 }),
|
|
C.selected && i
|
|
? (o({ nodes: [], edges: [C] }), D.current?.blur())
|
|
: n([e])),
|
|
d && d(t, C);
|
|
},
|
|
onDoubleClick: q,
|
|
onContextMenu: Z,
|
|
onMouseEnter: G,
|
|
onMouseMove: Q,
|
|
onMouseLeave: J,
|
|
onKeyDown: T
|
|
? (t) => {
|
|
if (!M && a.elementSelectionKeys.includes(t.key) && A) {
|
|
let { unselectNodesAndEdges: n, addSelectedEdges: o } =
|
|
F.getState();
|
|
"Escape" === t.key
|
|
? (D.current?.blur(), n({ edges: [C] }))
|
|
: o([e]);
|
|
}
|
|
}
|
|
: void 0,
|
|
tabIndex: T ? 0 : void 0,
|
|
role: C.ariaRole ?? (T ? "group" : "img"),
|
|
"aria-roledescription": "edge",
|
|
"data-id": e,
|
|
"data-testid": `rf__edge-${e}`,
|
|
"aria-label":
|
|
null === C.ariaLabel
|
|
? void 0
|
|
: C.ariaLabel || `Edge from ${C.source} to ${C.target}`,
|
|
"aria-describedby": T ? `${y}-${b}` : void 0,
|
|
ref: D,
|
|
...C.domAttributes,
|
|
children: [
|
|
!R &&
|
|
(0, o.jsx)(k, {
|
|
id: e,
|
|
source: C.source,
|
|
target: C.target,
|
|
type: C.type,
|
|
selected: C.selected,
|
|
animated: C.animated,
|
|
selectable: A,
|
|
deletable: C.deletable ?? !0,
|
|
label: C.label,
|
|
labelStyle: C.labelStyle,
|
|
labelShowBg: C.labelShowBg,
|
|
labelBgStyle: C.labelBgStyle,
|
|
labelBgPadding: C.labelBgPadding,
|
|
labelBgBorderRadius: C.labelBgBorderRadius,
|
|
sourceX: B,
|
|
sourceY: H,
|
|
targetX: V,
|
|
targetY: U,
|
|
sourcePosition: Y,
|
|
targetPosition: W,
|
|
data: C.data,
|
|
style: C.style,
|
|
sourceHandleId: C.sourceHandle,
|
|
targetHandleId: C.targetHandle,
|
|
markerStart: X,
|
|
markerEnd: K,
|
|
pathOptions: "pathOptions" in C ? C.pathOptions : void 0,
|
|
interactionWidth: C.interactionWidth,
|
|
}),
|
|
O &&
|
|
(0, o.jsx)(e7, {
|
|
edge: C,
|
|
isReconnectable: O,
|
|
reconnectRadius: v,
|
|
onReconnect: w,
|
|
onReconnectStart: x,
|
|
onReconnectEnd: S,
|
|
sourceX: B,
|
|
sourceY: H,
|
|
targetX: V,
|
|
targetY: U,
|
|
sourcePosition: Y,
|
|
targetPosition: W,
|
|
setUpdateHover: j,
|
|
setReconnecting: z,
|
|
}),
|
|
],
|
|
}),
|
|
});
|
|
});
|
|
let e9 = (e) => ({
|
|
edgesFocusable: e.edgesFocusable,
|
|
edgesReconnectable: e.edgesReconnectable,
|
|
elementsSelectable: e.elementsSelectable,
|
|
connectionMode: e.connectionMode,
|
|
onError: e.onError,
|
|
});
|
|
function te({
|
|
defaultMarkerColor: e,
|
|
onlyRenderVisibleElements: t,
|
|
rfId: n,
|
|
edgeTypes: r,
|
|
noPanClassName: s,
|
|
onReconnect: d,
|
|
onEdgeContextMenu: u,
|
|
onEdgeMouseEnter: c,
|
|
onEdgeMouseMove: h,
|
|
onEdgeMouseLeave: g,
|
|
onEdgeClick: f,
|
|
reconnectRadius: m,
|
|
onEdgeDoubleClick: y,
|
|
onReconnectStart: v,
|
|
onReconnectEnd: w,
|
|
disableKeyboardA11y: x,
|
|
}) {
|
|
let {
|
|
edgesFocusable: S,
|
|
edgesReconnectable: b,
|
|
elementsSelectable: I,
|
|
onError: _,
|
|
} = p(e9, l.shallow),
|
|
E = p(
|
|
(0, i.useCallback)(
|
|
(e) => {
|
|
if (!t) return e.edges.map((e) => e.id);
|
|
let n = [];
|
|
if (e.width && e.height)
|
|
for (let t of e.edges) {
|
|
let o = e.nodeLookup.get(t.source),
|
|
i = e.nodeLookup.get(t.target);
|
|
o &&
|
|
i &&
|
|
(0, a.isEdgeVisible)({
|
|
sourceNode: o,
|
|
targetNode: i,
|
|
width: e.width,
|
|
height: e.height,
|
|
transform: e.transform,
|
|
}) &&
|
|
n.push(t.id);
|
|
}
|
|
return n;
|
|
},
|
|
[t],
|
|
),
|
|
l.shallow,
|
|
);
|
|
return (0, o.jsxs)("div", {
|
|
className: "react-flow__edges",
|
|
children: [
|
|
(0, o.jsx)(ej, { defaultColor: e, rfId: n }),
|
|
E.map((e) =>
|
|
(0, o.jsx)(
|
|
e8,
|
|
{
|
|
id: e,
|
|
edgesFocusable: S,
|
|
edgesReconnectable: b,
|
|
elementsSelectable: I,
|
|
noPanClassName: s,
|
|
onReconnect: d,
|
|
onContextMenu: u,
|
|
onMouseEnter: c,
|
|
onMouseMove: h,
|
|
onMouseLeave: g,
|
|
onClick: f,
|
|
reconnectRadius: m,
|
|
onDoubleClick: y,
|
|
onReconnectStart: v,
|
|
onReconnectEnd: w,
|
|
rfId: n,
|
|
onError: _,
|
|
edgeTypes: r,
|
|
disableKeyboardA11y: x,
|
|
},
|
|
e,
|
|
),
|
|
),
|
|
],
|
|
});
|
|
}
|
|
te.displayName = "EdgeRenderer";
|
|
let tt = (0, i.memo)(te),
|
|
tn = (e) =>
|
|
`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;
|
|
function to({ children: e }) {
|
|
let t = p(tn);
|
|
return (0, o.jsx)("div", {
|
|
className:
|
|
"react-flow__viewport xyflow__viewport react-flow__container",
|
|
style: { transform: t },
|
|
children: e,
|
|
});
|
|
}
|
|
let ti = (e) => e.panZoom?.syncViewport;
|
|
function tr(e) {
|
|
return e.connection.inProgress
|
|
? {
|
|
...e.connection,
|
|
to: (0, a.pointToRendererPoint)(e.connection.to, e.transform),
|
|
}
|
|
: { ...e.connection };
|
|
}
|
|
let ta = (e) => ({
|
|
nodesConnectable: e.nodesConnectable,
|
|
isValid: e.connection.isValid,
|
|
inProgress: e.connection.inProgress,
|
|
width: e.width,
|
|
height: e.height,
|
|
});
|
|
function ts({ containerStyle: e, style: t, type: n, component: i }) {
|
|
let {
|
|
nodesConnectable: s,
|
|
width: d,
|
|
height: u,
|
|
isValid: c,
|
|
inProgress: h,
|
|
} = p(ta, l.shallow);
|
|
return d && s && h
|
|
? (0, o.jsx)("svg", {
|
|
style: e,
|
|
width: d,
|
|
height: u,
|
|
className: "react-flow__connectionline react-flow__container",
|
|
children: (0, o.jsx)("g", {
|
|
className: (0, r.default)([
|
|
"react-flow__connection",
|
|
(0, a.getConnectionStatus)(c),
|
|
]),
|
|
children: (0, o.jsx)(tl, {
|
|
style: t,
|
|
type: n,
|
|
CustomComponent: i,
|
|
isValid: c,
|
|
}),
|
|
}),
|
|
})
|
|
: null;
|
|
}
|
|
let tl = ({
|
|
style: e,
|
|
type: t = a.ConnectionLineType.Bezier,
|
|
CustomComponent: n,
|
|
isValid: i,
|
|
}) => {
|
|
let {
|
|
inProgress: r,
|
|
from: s,
|
|
fromNode: d,
|
|
fromHandle: u,
|
|
fromPosition: c,
|
|
to: h,
|
|
toNode: g,
|
|
toHandle: f,
|
|
toPosition: m,
|
|
pointer: y,
|
|
} = p(tr, l.shallow);
|
|
if (!r) return;
|
|
if (n)
|
|
return (0, o.jsx)(n, {
|
|
connectionLineType: t,
|
|
connectionLineStyle: e,
|
|
fromNode: d,
|
|
fromHandle: u,
|
|
fromX: s.x,
|
|
fromY: s.y,
|
|
toX: h.x,
|
|
toY: h.y,
|
|
fromPosition: c,
|
|
toPosition: m,
|
|
connectionStatus: (0, a.getConnectionStatus)(i),
|
|
toNode: g,
|
|
toHandle: f,
|
|
pointer: y,
|
|
});
|
|
let v = "",
|
|
w = {
|
|
sourceX: s.x,
|
|
sourceY: s.y,
|
|
sourcePosition: c,
|
|
targetX: h.x,
|
|
targetY: h.y,
|
|
targetPosition: m,
|
|
};
|
|
switch (t) {
|
|
case a.ConnectionLineType.Bezier:
|
|
[v] = (0, a.getBezierPath)(w);
|
|
break;
|
|
case a.ConnectionLineType.SimpleBezier:
|
|
[v] = eB(w);
|
|
break;
|
|
case a.ConnectionLineType.Step:
|
|
[v] = (0, a.getSmoothStepPath)({ ...w, borderRadius: 0 });
|
|
break;
|
|
case a.ConnectionLineType.SmoothStep:
|
|
[v] = (0, a.getSmoothStepPath)(w);
|
|
break;
|
|
default:
|
|
[v] = (0, a.getStraightPath)(w);
|
|
}
|
|
return (0, o.jsx)("path", {
|
|
d: v,
|
|
fill: "none",
|
|
className: "react-flow__connection-path",
|
|
style: e,
|
|
});
|
|
};
|
|
tl.displayName = "ConnectionLine";
|
|
let td = {};
|
|
function tu(e = td) {
|
|
(0, i.useRef)(e), h(), (0, i.useEffect)(() => {}, [e]);
|
|
}
|
|
function tc({
|
|
nodeTypes: e,
|
|
edgeTypes: t,
|
|
onInit: n,
|
|
onNodeClick: r,
|
|
onEdgeClick: a,
|
|
onNodeDoubleClick: s,
|
|
onEdgeDoubleClick: l,
|
|
onNodeMouseEnter: d,
|
|
onNodeMouseMove: u,
|
|
onNodeMouseLeave: c,
|
|
onNodeContextMenu: g,
|
|
onSelectionContextMenu: f,
|
|
onSelectionStart: m,
|
|
onSelectionEnd: y,
|
|
connectionLineType: v,
|
|
connectionLineStyle: w,
|
|
connectionLineComponent: x,
|
|
connectionLineContainerStyle: S,
|
|
selectionKeyCode: b,
|
|
selectionOnDrag: I,
|
|
selectionMode: _,
|
|
multiSelectionKeyCode: E,
|
|
panActivationKeyCode: M,
|
|
zoomActivationKeyCode: C,
|
|
deleteKeyCode: N,
|
|
onlyRenderVisibleElements: P,
|
|
elementsSelectable: k,
|
|
defaultViewport: T,
|
|
translateExtent: O,
|
|
minZoom: A,
|
|
maxZoom: D,
|
|
preventScrolling: L,
|
|
defaultMarkerColor: j,
|
|
zoomOnScroll: R,
|
|
zoomOnPinch: z,
|
|
panOnScroll: F,
|
|
panOnScrollSpeed: $,
|
|
panOnScrollMode: B,
|
|
zoomOnDoubleClick: H,
|
|
panOnDrag: V,
|
|
onPaneClick: U,
|
|
onPaneMouseEnter: Y,
|
|
onPaneMouseMove: W,
|
|
onPaneMouseLeave: X,
|
|
onPaneScroll: K,
|
|
onPaneContextMenu: q,
|
|
paneClickDistance: Z,
|
|
nodeClickDistance: G,
|
|
onEdgeContextMenu: Q,
|
|
onEdgeMouseEnter: J,
|
|
onEdgeMouseMove: ee,
|
|
onEdgeMouseLeave: en,
|
|
reconnectRadius: eo,
|
|
onReconnect: ei,
|
|
onReconnectStart: er,
|
|
onReconnectEnd: ea,
|
|
noDragClassName: es,
|
|
noWheelClassName: el,
|
|
noPanClassName: ed,
|
|
disableKeyboardA11y: eu,
|
|
nodeExtent: ec,
|
|
rfId: ep,
|
|
viewport: eh,
|
|
onViewportChange: eg,
|
|
}) {
|
|
let ef, em, ey, ev;
|
|
return (
|
|
tu(e),
|
|
tu(t),
|
|
h(),
|
|
(0, i.useRef)(!1),
|
|
(0, i.useEffect)(() => {}, []),
|
|
(ef = et()),
|
|
(em = (0, i.useRef)(!1)),
|
|
(0, i.useEffect)(() => {
|
|
!em.current &&
|
|
ef.viewportInitialized &&
|
|
n &&
|
|
(setTimeout(() => n(ef), 1), (em.current = !0));
|
|
}, [n, ef.viewportInitialized]),
|
|
(ey = p(ti)),
|
|
(ev = h()),
|
|
(0, i.useEffect)(() => {
|
|
eh && (ey?.(eh), ev.setState({ transform: [eh.x, eh.y, eh.zoom] }));
|
|
}, [eh, ey]),
|
|
(0, o.jsx)(eC, {
|
|
onPaneClick: U,
|
|
onPaneMouseEnter: Y,
|
|
onPaneMouseMove: W,
|
|
onPaneMouseLeave: X,
|
|
onPaneContextMenu: q,
|
|
onPaneScroll: K,
|
|
paneClickDistance: Z,
|
|
deleteKeyCode: N,
|
|
selectionKeyCode: b,
|
|
selectionOnDrag: I,
|
|
selectionMode: _,
|
|
onSelectionStart: m,
|
|
onSelectionEnd: y,
|
|
multiSelectionKeyCode: E,
|
|
panActivationKeyCode: M,
|
|
zoomActivationKeyCode: C,
|
|
elementsSelectable: k,
|
|
zoomOnScroll: R,
|
|
zoomOnPinch: z,
|
|
zoomOnDoubleClick: H,
|
|
panOnScroll: F,
|
|
panOnScrollSpeed: $,
|
|
panOnScrollMode: B,
|
|
panOnDrag: V,
|
|
defaultViewport: T,
|
|
translateExtent: O,
|
|
minZoom: A,
|
|
maxZoom: D,
|
|
onSelectionContextMenu: f,
|
|
preventScrolling: L,
|
|
noDragClassName: es,
|
|
noWheelClassName: el,
|
|
noPanClassName: ed,
|
|
disableKeyboardA11y: eu,
|
|
onViewportChange: eg,
|
|
isControlledViewport: !!eh,
|
|
children: (0, o.jsxs)(to, {
|
|
children: [
|
|
(0, o.jsx)(tt, {
|
|
edgeTypes: t,
|
|
onEdgeClick: a,
|
|
onEdgeDoubleClick: l,
|
|
onReconnect: ei,
|
|
onReconnectStart: er,
|
|
onReconnectEnd: ea,
|
|
onlyRenderVisibleElements: P,
|
|
onEdgeContextMenu: Q,
|
|
onEdgeMouseEnter: J,
|
|
onEdgeMouseMove: ee,
|
|
onEdgeMouseLeave: en,
|
|
reconnectRadius: eo,
|
|
defaultMarkerColor: j,
|
|
noPanClassName: ed,
|
|
disableKeyboardA11y: eu,
|
|
rfId: ep,
|
|
}),
|
|
(0, o.jsx)(ts, {
|
|
style: w,
|
|
type: v,
|
|
component: x,
|
|
containerStyle: S,
|
|
}),
|
|
(0, o.jsx)("div", {
|
|
className: "react-flow__edgelabel-renderer",
|
|
}),
|
|
(0, o.jsx)(eO, {
|
|
nodeTypes: e,
|
|
onNodeClick: r,
|
|
onNodeDoubleClick: s,
|
|
onNodeMouseEnter: d,
|
|
onNodeMouseMove: u,
|
|
onNodeMouseLeave: c,
|
|
onNodeContextMenu: g,
|
|
nodeClickDistance: G,
|
|
onlyRenderVisibleElements: P,
|
|
noPanClassName: ed,
|
|
noDragClassName: es,
|
|
disableKeyboardA11y: eu,
|
|
nodeExtent: ec,
|
|
rfId: ep,
|
|
}),
|
|
(0, o.jsx)("div", { className: "react-flow__viewport-portal" }),
|
|
],
|
|
}),
|
|
})
|
|
);
|
|
}
|
|
tc.displayName = "GraphView";
|
|
let tp = (0, i.memo)(tc),
|
|
th = ({
|
|
nodes: e,
|
|
edges: t,
|
|
defaultNodes: n,
|
|
defaultEdges: o,
|
|
width: i,
|
|
height: r,
|
|
fitView: s,
|
|
fitViewOptions: l,
|
|
minZoom: d = 0.5,
|
|
maxZoom: u = 2,
|
|
nodeOrigin: c,
|
|
nodeExtent: p,
|
|
zIndexMode: h = "basic",
|
|
} = {}) => {
|
|
let g = new Map(),
|
|
f = new Map(),
|
|
m = new Map(),
|
|
y = new Map(),
|
|
v = o ?? t ?? [],
|
|
w = n ?? e ?? [],
|
|
x = c ?? [0, 0],
|
|
S = p ?? a.infiniteExtent;
|
|
(0, a.updateConnectionLookup)(m, y, v);
|
|
let b = (0, a.adoptUserNodes)(w, g, f, {
|
|
nodeOrigin: x,
|
|
nodeExtent: S,
|
|
zIndexMode: h,
|
|
}),
|
|
I = [0, 0, 1];
|
|
if (s && i && r) {
|
|
let e = (0, a.getInternalNodesBounds)(g, {
|
|
filter: (e) =>
|
|
!!(
|
|
(e.width || e.initialWidth) &&
|
|
(e.height || e.initialHeight)
|
|
),
|
|
}),
|
|
{
|
|
x: t,
|
|
y: n,
|
|
zoom: o,
|
|
} = (0, a.getViewportForBounds)(e, i, r, d, u, l?.padding ?? 0.1);
|
|
I = [t, n, o];
|
|
}
|
|
return {
|
|
rfId: "1",
|
|
width: i ?? 0,
|
|
height: r ?? 0,
|
|
transform: I,
|
|
nodes: w,
|
|
nodesInitialized: b,
|
|
nodeLookup: g,
|
|
parentLookup: f,
|
|
edges: v,
|
|
edgeLookup: y,
|
|
connectionLookup: m,
|
|
onNodesChange: null,
|
|
onEdgesChange: null,
|
|
hasDefaultNodes: void 0 !== n,
|
|
hasDefaultEdges: void 0 !== o,
|
|
panZoom: null,
|
|
minZoom: d,
|
|
maxZoom: u,
|
|
translateExtent: a.infiniteExtent,
|
|
nodeExtent: S,
|
|
nodesSelectionActive: !1,
|
|
userSelectionActive: !1,
|
|
userSelectionRect: null,
|
|
connectionMode: a.ConnectionMode.Strict,
|
|
domNode: null,
|
|
paneDragging: !1,
|
|
noPanClassName: "nopan",
|
|
nodeOrigin: x,
|
|
nodeDragThreshold: 1,
|
|
connectionDragThreshold: 1,
|
|
snapGrid: [15, 15],
|
|
snapToGrid: !1,
|
|
nodesDraggable: !0,
|
|
nodesConnectable: !0,
|
|
nodesFocusable: !0,
|
|
edgesFocusable: !0,
|
|
edgesReconnectable: !0,
|
|
elementsSelectable: !0,
|
|
elevateNodesOnSelect: !0,
|
|
elevateEdgesOnSelect: !0,
|
|
selectNodesOnDrag: !0,
|
|
multiSelectionActive: !1,
|
|
fitViewQueued: s ?? !1,
|
|
fitViewOptions: l,
|
|
fitViewResolver: null,
|
|
connection: { ...a.initialConnection },
|
|
connectionClickStartHandle: null,
|
|
connectOnClick: !0,
|
|
ariaLiveMessage: "",
|
|
autoPanOnConnect: !0,
|
|
autoPanOnNodeDrag: !0,
|
|
autoPanOnNodeFocus: !0,
|
|
autoPanSpeed: 15,
|
|
connectionRadius: 20,
|
|
onError: a.devWarn,
|
|
isValidConnection: void 0,
|
|
onSelectionChangeHandlers: [],
|
|
lib: "react",
|
|
debug: !1,
|
|
ariaLabelConfig: a.defaultAriaLabelConfig,
|
|
zIndexMode: h,
|
|
onNodesChangeMiddlewareMap: new Map(),
|
|
onEdgesChangeMiddlewareMap: new Map(),
|
|
};
|
|
};
|
|
function tg({
|
|
initialNodes: e,
|
|
initialEdges: t,
|
|
defaultNodes: n,
|
|
defaultEdges: r,
|
|
initialWidth: l,
|
|
initialHeight: d,
|
|
initialMinZoom: c,
|
|
initialMaxZoom: p,
|
|
initialFitViewOptions: h,
|
|
fitView: g,
|
|
nodeOrigin: f,
|
|
nodeExtent: m,
|
|
zIndexMode: y,
|
|
children: v,
|
|
}) {
|
|
let [w] = (0, i.useState)(() =>
|
|
(({
|
|
nodes: e,
|
|
edges: t,
|
|
defaultNodes: n,
|
|
defaultEdges: o,
|
|
width: i,
|
|
height: r,
|
|
fitView: l,
|
|
fitViewOptions: d,
|
|
minZoom: u,
|
|
maxZoom: c,
|
|
nodeOrigin: p,
|
|
nodeExtent: h,
|
|
zIndexMode: g,
|
|
}) =>
|
|
(0, s.createWithEqualityFn)((s, f) => {
|
|
async function m() {
|
|
let {
|
|
nodeLookup: e,
|
|
panZoom: t,
|
|
fitViewOptions: n,
|
|
fitViewResolver: o,
|
|
width: i,
|
|
height: r,
|
|
minZoom: l,
|
|
maxZoom: d,
|
|
} = f();
|
|
t &&
|
|
(await (0, a.fitViewport)(
|
|
{
|
|
nodes: e,
|
|
width: i,
|
|
height: r,
|
|
panZoom: t,
|
|
minZoom: l,
|
|
maxZoom: d,
|
|
},
|
|
n,
|
|
),
|
|
o?.resolve(!0),
|
|
s({ fitViewResolver: null }));
|
|
}
|
|
return {
|
|
...th({
|
|
nodes: e,
|
|
edges: t,
|
|
width: i,
|
|
height: r,
|
|
fitView: l,
|
|
fitViewOptions: d,
|
|
minZoom: u,
|
|
maxZoom: c,
|
|
nodeOrigin: p,
|
|
nodeExtent: h,
|
|
defaultNodes: n,
|
|
defaultEdges: o,
|
|
zIndexMode: g,
|
|
}),
|
|
setNodes: (e) => {
|
|
let {
|
|
nodeLookup: t,
|
|
parentLookup: n,
|
|
nodeOrigin: o,
|
|
elevateNodesOnSelect: i,
|
|
fitViewQueued: r,
|
|
zIndexMode: l,
|
|
} = f(),
|
|
d = (0, a.adoptUserNodes)(e, t, n, {
|
|
nodeOrigin: o,
|
|
nodeExtent: h,
|
|
elevateNodesOnSelect: i,
|
|
checkEquality: !0,
|
|
zIndexMode: l,
|
|
});
|
|
r && d
|
|
? (m(),
|
|
s({
|
|
nodes: e,
|
|
nodesInitialized: d,
|
|
fitViewQueued: !1,
|
|
fitViewOptions: void 0,
|
|
}))
|
|
: s({ nodes: e, nodesInitialized: d });
|
|
},
|
|
setEdges: (e) => {
|
|
let { connectionLookup: t, edgeLookup: n } = f();
|
|
(0, a.updateConnectionLookup)(t, n, e), s({ edges: e });
|
|
},
|
|
setDefaultNodesAndEdges: (e, t) => {
|
|
if (e) {
|
|
let { setNodes: t } = f();
|
|
t(e), s({ hasDefaultNodes: !0 });
|
|
}
|
|
if (t) {
|
|
let { setEdges: e } = f();
|
|
e(t), s({ hasDefaultEdges: !0 });
|
|
}
|
|
},
|
|
updateNodeInternals: (e) => {
|
|
let {
|
|
triggerNodeChanges: t,
|
|
nodeLookup: n,
|
|
parentLookup: o,
|
|
domNode: i,
|
|
nodeOrigin: r,
|
|
nodeExtent: l,
|
|
debug: d,
|
|
fitViewQueued: u,
|
|
zIndexMode: c,
|
|
} = f(),
|
|
{ changes: p, updatedInternals: h } = (0,
|
|
a.updateNodeInternals)(e, n, o, i, r, l, c);
|
|
h &&
|
|
((0, a.updateAbsolutePositions)(n, o, {
|
|
nodeOrigin: r,
|
|
nodeExtent: l,
|
|
zIndexMode: c,
|
|
}),
|
|
u
|
|
? (m(), s({ fitViewQueued: !1, fitViewOptions: void 0 }))
|
|
: s({}),
|
|
p?.length > 0 &&
|
|
(d && console.log("React Flow: trigger node changes", p),
|
|
t?.(p)));
|
|
},
|
|
updateNodePositions: (e, t = !1) => {
|
|
let n = [],
|
|
o = [],
|
|
{
|
|
nodeLookup: i,
|
|
triggerNodeChanges: r,
|
|
connection: s,
|
|
updateConnection: l,
|
|
onNodesChangeMiddlewareMap: d,
|
|
} = f();
|
|
for (let [r, d] of e) {
|
|
let e = i.get(r),
|
|
u = !!(e?.expandParent && e?.parentId && d?.position),
|
|
c = {
|
|
id: r,
|
|
type: "position",
|
|
position: u
|
|
? {
|
|
x: Math.max(0, d.position.x),
|
|
y: Math.max(0, d.position.y),
|
|
}
|
|
: d.position,
|
|
dragging: t,
|
|
};
|
|
if (e && s.inProgress && s.fromNode.id === e.id) {
|
|
let t = (0, a.getHandlePosition)(
|
|
e,
|
|
s.fromHandle,
|
|
a.Position.Left,
|
|
!0,
|
|
);
|
|
l({ ...s, from: t });
|
|
}
|
|
u &&
|
|
e.parentId &&
|
|
n.push({
|
|
id: r,
|
|
parentId: e.parentId,
|
|
rect: {
|
|
...d.internals.positionAbsolute,
|
|
width: d.measured.width ?? 0,
|
|
height: d.measured.height ?? 0,
|
|
},
|
|
}),
|
|
o.push(c);
|
|
}
|
|
if (n.length > 0) {
|
|
let { parentLookup: e, nodeOrigin: t } = f(),
|
|
r = (0, a.handleExpandParent)(n, i, e, t);
|
|
o.push(...r);
|
|
}
|
|
for (let e of d.values()) o = e(o);
|
|
r(o);
|
|
},
|
|
triggerNodeChanges: (e) => {
|
|
let {
|
|
onNodesChange: t,
|
|
setNodes: n,
|
|
nodes: o,
|
|
hasDefaultNodes: i,
|
|
debug: r,
|
|
} = f();
|
|
e?.length &&
|
|
(i && n(B(e, o)),
|
|
r && console.log("React Flow: trigger node changes", e),
|
|
t?.(e));
|
|
},
|
|
triggerEdgeChanges: (e) => {
|
|
let {
|
|
onEdgesChange: t,
|
|
setEdges: n,
|
|
edges: o,
|
|
hasDefaultEdges: i,
|
|
debug: r,
|
|
} = f();
|
|
e?.length &&
|
|
(i && n(B(e, o)),
|
|
r && console.log("React Flow: trigger edge changes", e),
|
|
t?.(e));
|
|
},
|
|
addSelectedNodes: (e) => {
|
|
let {
|
|
multiSelectionActive: t,
|
|
edgeLookup: n,
|
|
nodeLookup: o,
|
|
triggerNodeChanges: i,
|
|
triggerEdgeChanges: r,
|
|
} = f();
|
|
t
|
|
? i(e.map((e) => U(e, !0)))
|
|
: (i(Y(o, new Set([...e]), !0)), r(Y(n)));
|
|
},
|
|
addSelectedEdges: (e) => {
|
|
let {
|
|
multiSelectionActive: t,
|
|
edgeLookup: n,
|
|
nodeLookup: o,
|
|
triggerNodeChanges: i,
|
|
triggerEdgeChanges: r,
|
|
} = f();
|
|
t
|
|
? r(e.map((e) => U(e, !0)))
|
|
: (r(Y(n, new Set([...e]))), i(Y(o, new Set(), !0)));
|
|
},
|
|
unselectNodesAndEdges: ({ nodes: e, edges: t } = {}) => {
|
|
let {
|
|
edges: n,
|
|
nodes: o,
|
|
nodeLookup: i,
|
|
triggerNodeChanges: r,
|
|
triggerEdgeChanges: a,
|
|
} = f(),
|
|
s = (e || o).map((e) => {
|
|
let t = i.get(e.id);
|
|
return t && (t.selected = !1), U(e.id, !1);
|
|
}),
|
|
l = (t || n).map((e) => U(e.id, !1));
|
|
r(s), a(l);
|
|
},
|
|
setMinZoom: (e) => {
|
|
let { panZoom: t, maxZoom: n } = f();
|
|
t?.setScaleExtent([e, n]), s({ minZoom: e });
|
|
},
|
|
setMaxZoom: (e) => {
|
|
let { panZoom: t, minZoom: n } = f();
|
|
t?.setScaleExtent([n, e]), s({ maxZoom: e });
|
|
},
|
|
setTranslateExtent: (e) => {
|
|
f().panZoom?.setTranslateExtent(e), s({ translateExtent: e });
|
|
},
|
|
resetSelectedElements: () => {
|
|
let {
|
|
edges: e,
|
|
nodes: t,
|
|
triggerNodeChanges: n,
|
|
triggerEdgeChanges: o,
|
|
elementsSelectable: i,
|
|
} = f();
|
|
if (!i) return;
|
|
let r = t.reduce(
|
|
(e, t) => (t.selected ? [...e, U(t.id, !1)] : e),
|
|
[],
|
|
),
|
|
a = e.reduce(
|
|
(e, t) => (t.selected ? [...e, U(t.id, !1)] : e),
|
|
[],
|
|
);
|
|
n(r), o(a);
|
|
},
|
|
setNodeExtent: (e) => {
|
|
let {
|
|
nodes: t,
|
|
nodeLookup: n,
|
|
parentLookup: o,
|
|
nodeOrigin: i,
|
|
elevateNodesOnSelect: r,
|
|
nodeExtent: l,
|
|
zIndexMode: d,
|
|
} = f();
|
|
(e[0][0] !== l[0][0] ||
|
|
e[0][1] !== l[0][1] ||
|
|
e[1][0] !== l[1][0] ||
|
|
e[1][1] !== l[1][1]) &&
|
|
((0, a.adoptUserNodes)(t, n, o, {
|
|
nodeOrigin: i,
|
|
nodeExtent: e,
|
|
elevateNodesOnSelect: r,
|
|
checkEquality: !1,
|
|
zIndexMode: d,
|
|
}),
|
|
s({ nodeExtent: e }));
|
|
},
|
|
panBy: (e) => {
|
|
let {
|
|
transform: t,
|
|
width: n,
|
|
height: o,
|
|
panZoom: i,
|
|
translateExtent: r,
|
|
} = f();
|
|
return (0, a.panBy)({
|
|
delta: e,
|
|
panZoom: i,
|
|
transform: t,
|
|
translateExtent: r,
|
|
width: n,
|
|
height: o,
|
|
});
|
|
},
|
|
setCenter: async (e, t, n) => {
|
|
let { width: o, height: i, maxZoom: r, panZoom: a } = f();
|
|
if (!a) return Promise.resolve(!1);
|
|
let s = void 0 !== n?.zoom ? n.zoom : r;
|
|
return (
|
|
await a.setViewport(
|
|
{ x: o / 2 - e * s, y: i / 2 - t * s, zoom: s },
|
|
{
|
|
duration: n?.duration,
|
|
ease: n?.ease,
|
|
interpolate: n?.interpolate,
|
|
},
|
|
),
|
|
Promise.resolve(!0)
|
|
);
|
|
},
|
|
cancelConnection: () => {
|
|
s({ connection: { ...a.initialConnection } });
|
|
},
|
|
updateConnection: (e) => {
|
|
s({ connection: e });
|
|
},
|
|
reset: () => s({ ...th() }),
|
|
};
|
|
}, Object.is))({
|
|
nodes: e,
|
|
edges: t,
|
|
defaultNodes: n,
|
|
defaultEdges: r,
|
|
width: l,
|
|
height: d,
|
|
fitView: g,
|
|
minZoom: c,
|
|
maxZoom: p,
|
|
fitViewOptions: h,
|
|
nodeOrigin: f,
|
|
nodeExtent: m,
|
|
zIndexMode: y,
|
|
}),
|
|
);
|
|
return (0, o.jsx)(u, {
|
|
value: w,
|
|
children: (0, o.jsx)(J, { children: v }),
|
|
});
|
|
}
|
|
function tf({
|
|
children: e,
|
|
nodes: t,
|
|
edges: n,
|
|
defaultNodes: r,
|
|
defaultEdges: a,
|
|
width: s,
|
|
height: l,
|
|
fitView: u,
|
|
fitViewOptions: c,
|
|
minZoom: p,
|
|
maxZoom: h,
|
|
nodeOrigin: g,
|
|
nodeExtent: f,
|
|
zIndexMode: m,
|
|
}) {
|
|
return (0, i.useContext)(d)
|
|
? (0, o.jsx)(o.Fragment, { children: e })
|
|
: (0, o.jsx)(tg, {
|
|
initialNodes: t,
|
|
initialEdges: n,
|
|
defaultNodes: r,
|
|
defaultEdges: a,
|
|
initialWidth: s,
|
|
initialHeight: l,
|
|
fitView: u,
|
|
initialFitViewOptions: c,
|
|
initialMinZoom: p,
|
|
initialMaxZoom: h,
|
|
nodeOrigin: g,
|
|
nodeExtent: f,
|
|
zIndexMode: m,
|
|
children: e,
|
|
});
|
|
}
|
|
let tm = {
|
|
width: "100%",
|
|
height: "100%",
|
|
overflow: "hidden",
|
|
position: "relative",
|
|
zIndex: 0,
|
|
};
|
|
var ty = q(function (
|
|
{
|
|
nodes: e,
|
|
edges: t,
|
|
defaultNodes: n,
|
|
defaultEdges: s,
|
|
className: l,
|
|
nodeTypes: d,
|
|
edgeTypes: u,
|
|
onNodeClick: c,
|
|
onEdgeClick: p,
|
|
onInit: h,
|
|
onMove: g,
|
|
onMoveStart: f,
|
|
onMoveEnd: m,
|
|
onConnect: y,
|
|
onConnectStart: v,
|
|
onConnectEnd: w,
|
|
onClickConnectStart: x,
|
|
onClickConnectEnd: b,
|
|
onNodeMouseEnter: _,
|
|
onNodeMouseMove: E,
|
|
onNodeMouseLeave: M,
|
|
onNodeContextMenu: C,
|
|
onNodeDoubleClick: N,
|
|
onNodeDragStart: O,
|
|
onNodeDrag: A,
|
|
onNodeDragStop: D,
|
|
onNodesDelete: R,
|
|
onEdgesDelete: z,
|
|
onDelete: F,
|
|
onSelectionChange: $,
|
|
onSelectionDragStart: B,
|
|
onSelectionDrag: H,
|
|
onSelectionDragStop: V,
|
|
onSelectionContextMenu: U,
|
|
onSelectionStart: Y,
|
|
onSelectionEnd: W,
|
|
onBeforeDelete: X,
|
|
connectionMode: K,
|
|
connectionLineType: q = a.ConnectionLineType.Bezier,
|
|
connectionLineStyle: Z,
|
|
connectionLineComponent: G,
|
|
connectionLineContainerStyle: Q,
|
|
deleteKeyCode: J = "Backspace",
|
|
selectionKeyCode: ee = "Shift",
|
|
selectionOnDrag: et = !1,
|
|
selectionMode: en = a.SelectionMode.Full,
|
|
panActivationKeyCode: eo = "Space",
|
|
multiSelectionKeyCode: ei = (0, a.isMacOs)() ? "Meta" : "Control",
|
|
zoomActivationKeyCode: er = (0, a.isMacOs)() ? "Meta" : "Control",
|
|
snapToGrid: ea,
|
|
snapGrid: es,
|
|
onlyRenderVisibleElements: el = !1,
|
|
selectNodesOnDrag: ed,
|
|
nodesDraggable: eu,
|
|
autoPanOnNodeFocus: ec,
|
|
nodesConnectable: ep,
|
|
nodesFocusable: eh,
|
|
nodeOrigin: eg = k,
|
|
edgesFocusable: ef,
|
|
edgesReconnectable: em,
|
|
elementsSelectable: ey = !0,
|
|
defaultViewport: ev = T,
|
|
minZoom: ew = 0.5,
|
|
maxZoom: ex = 2,
|
|
translateExtent: eS = a.infiniteExtent,
|
|
preventScrolling: eb = !0,
|
|
nodeExtent: eI,
|
|
defaultMarkerColor: e_ = "#b1b1b7",
|
|
zoomOnScroll: eE = !0,
|
|
zoomOnPinch: eM = !0,
|
|
panOnScroll: eC = !1,
|
|
panOnScrollSpeed: eN = 0.5,
|
|
panOnScrollMode: eP = a.PanOnScrollMode.Free,
|
|
zoomOnDoubleClick: ek = !0,
|
|
panOnDrag: eT = !0,
|
|
onPaneClick: eO,
|
|
onPaneMouseEnter: eA,
|
|
onPaneMouseMove: eD,
|
|
onPaneMouseLeave: eL,
|
|
onPaneScroll: ej,
|
|
onPaneContextMenu: eR,
|
|
paneClickDistance: ez = 1,
|
|
nodeClickDistance: eF = 0,
|
|
children: e$,
|
|
onReconnect: eB,
|
|
onReconnectStart: eH,
|
|
onReconnectEnd: eV,
|
|
onEdgeContextMenu: eU,
|
|
onEdgeDoubleClick: eY,
|
|
onEdgeMouseEnter: eW,
|
|
onEdgeMouseMove: eX,
|
|
onEdgeMouseLeave: eK,
|
|
reconnectRadius: eq = 10,
|
|
onNodesChange: eZ,
|
|
onEdgesChange: eG,
|
|
noDragClassName: eQ = "nodrag",
|
|
noWheelClassName: eJ = "nowheel",
|
|
noPanClassName: e0 = "nopan",
|
|
fitView: e1,
|
|
fitViewOptions: e2,
|
|
connectOnClick: e3,
|
|
attributionPosition: e5,
|
|
proOptions: e4,
|
|
defaultEdgeOptions: e6,
|
|
elevateNodesOnSelect: e7 = !0,
|
|
elevateEdgesOnSelect: e8 = !1,
|
|
disableKeyboardA11y: e9 = !1,
|
|
autoPanOnConnect: te,
|
|
autoPanOnNodeDrag: tt,
|
|
autoPanSpeed: tn,
|
|
connectionRadius: to,
|
|
isValidConnection: ti,
|
|
onError: tr,
|
|
style: ta,
|
|
id: ts,
|
|
nodeDragThreshold: tl,
|
|
connectionDragThreshold: td,
|
|
viewport: tu,
|
|
onViewportChange: tc,
|
|
width: th,
|
|
height: tg,
|
|
colorMode: ty = "light",
|
|
debug: tv,
|
|
onScroll: tw,
|
|
ariaLabelConfig: tx,
|
|
zIndexMode: tS = "basic",
|
|
...tb
|
|
},
|
|
tI,
|
|
) {
|
|
let t_ = ts || "1",
|
|
tE = (function (e) {
|
|
let [t, n] = (0, i.useState)("system" === e ? null : e);
|
|
return (
|
|
(0, i.useEffect)(() => {
|
|
if ("system" !== e) return void n(e);
|
|
let t = j(),
|
|
o = () => n(t?.matches ? "dark" : "light");
|
|
return (
|
|
o(),
|
|
t?.addEventListener("change", o),
|
|
() => {
|
|
t?.removeEventListener("change", o);
|
|
}
|
|
);
|
|
}, [e]),
|
|
null !== t ? t : j()?.matches ? "dark" : "light"
|
|
);
|
|
})(ty),
|
|
tM = (0, i.useCallback)(
|
|
(e) => {
|
|
e.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" }),
|
|
tw?.(e);
|
|
},
|
|
[tw],
|
|
);
|
|
return (0, o.jsx)("div", {
|
|
"data-testid": "rf__wrapper",
|
|
...tb,
|
|
onScroll: tM,
|
|
style: { ...ta, ...tm },
|
|
ref: tI,
|
|
className: (0, r.default)(["react-flow", l, tE]),
|
|
id: ts,
|
|
role: "application",
|
|
children: (0, o.jsxs)(tf, {
|
|
nodes: e,
|
|
edges: t,
|
|
width: th,
|
|
height: tg,
|
|
fitView: e1,
|
|
fitViewOptions: e2,
|
|
minZoom: ew,
|
|
maxZoom: ex,
|
|
nodeOrigin: eg,
|
|
nodeExtent: eI,
|
|
zIndexMode: tS,
|
|
children: [
|
|
(0, o.jsx)(tp, {
|
|
onInit: h,
|
|
onNodeClick: c,
|
|
onEdgeClick: p,
|
|
onNodeMouseEnter: _,
|
|
onNodeMouseMove: E,
|
|
onNodeMouseLeave: M,
|
|
onNodeContextMenu: C,
|
|
onNodeDoubleClick: N,
|
|
nodeTypes: d,
|
|
edgeTypes: u,
|
|
connectionLineType: q,
|
|
connectionLineStyle: Z,
|
|
connectionLineComponent: G,
|
|
connectionLineContainerStyle: Q,
|
|
selectionKeyCode: ee,
|
|
selectionOnDrag: et,
|
|
selectionMode: en,
|
|
deleteKeyCode: J,
|
|
multiSelectionKeyCode: ei,
|
|
panActivationKeyCode: eo,
|
|
zoomActivationKeyCode: er,
|
|
onlyRenderVisibleElements: el,
|
|
defaultViewport: ev,
|
|
translateExtent: eS,
|
|
minZoom: ew,
|
|
maxZoom: ex,
|
|
preventScrolling: eb,
|
|
zoomOnScroll: eE,
|
|
zoomOnPinch: eM,
|
|
zoomOnDoubleClick: ek,
|
|
panOnScroll: eC,
|
|
panOnScrollSpeed: eN,
|
|
panOnScrollMode: eP,
|
|
panOnDrag: eT,
|
|
onPaneClick: eO,
|
|
onPaneMouseEnter: eA,
|
|
onPaneMouseMove: eD,
|
|
onPaneMouseLeave: eL,
|
|
onPaneScroll: ej,
|
|
onPaneContextMenu: eR,
|
|
paneClickDistance: ez,
|
|
nodeClickDistance: eF,
|
|
onSelectionContextMenu: U,
|
|
onSelectionStart: Y,
|
|
onSelectionEnd: W,
|
|
onReconnect: eB,
|
|
onReconnectStart: eH,
|
|
onReconnectEnd: eV,
|
|
onEdgeContextMenu: eU,
|
|
onEdgeDoubleClick: eY,
|
|
onEdgeMouseEnter: eW,
|
|
onEdgeMouseMove: eX,
|
|
onEdgeMouseLeave: eK,
|
|
reconnectRadius: eq,
|
|
defaultMarkerColor: e_,
|
|
noDragClassName: eQ,
|
|
noWheelClassName: eJ,
|
|
noPanClassName: e0,
|
|
rfId: t_,
|
|
disableKeyboardA11y: e9,
|
|
nodeExtent: eI,
|
|
viewport: tu,
|
|
onViewportChange: tc,
|
|
}),
|
|
(0, o.jsx)(L, {
|
|
nodes: e,
|
|
edges: t,
|
|
defaultNodes: n,
|
|
defaultEdges: s,
|
|
onConnect: y,
|
|
onConnectStart: v,
|
|
onConnectEnd: w,
|
|
onClickConnectStart: x,
|
|
onClickConnectEnd: b,
|
|
nodesDraggable: eu,
|
|
autoPanOnNodeFocus: ec,
|
|
nodesConnectable: ep,
|
|
nodesFocusable: eh,
|
|
edgesFocusable: ef,
|
|
edgesReconnectable: em,
|
|
elementsSelectable: ey,
|
|
elevateNodesOnSelect: e7,
|
|
elevateEdgesOnSelect: e8,
|
|
minZoom: ew,
|
|
maxZoom: ex,
|
|
nodeExtent: eI,
|
|
onNodesChange: eZ,
|
|
onEdgesChange: eG,
|
|
snapToGrid: ea,
|
|
snapGrid: es,
|
|
connectionMode: K,
|
|
translateExtent: eS,
|
|
connectOnClick: e3,
|
|
defaultEdgeOptions: e6,
|
|
fitView: e1,
|
|
fitViewOptions: e2,
|
|
onNodesDelete: R,
|
|
onEdgesDelete: z,
|
|
onDelete: F,
|
|
onNodeDragStart: O,
|
|
onNodeDrag: A,
|
|
onNodeDragStop: D,
|
|
onSelectionDrag: H,
|
|
onSelectionDragStart: B,
|
|
onSelectionDragStop: V,
|
|
onMove: g,
|
|
onMoveStart: f,
|
|
onMoveEnd: m,
|
|
noPanClassName: e0,
|
|
nodeOrigin: eg,
|
|
rfId: t_,
|
|
autoPanOnConnect: te,
|
|
autoPanOnNodeDrag: tt,
|
|
autoPanSpeed: tn,
|
|
onError: tr,
|
|
connectionRadius: to,
|
|
isValidConnection: ti,
|
|
selectNodesOnDrag: ed,
|
|
nodeDragThreshold: tl,
|
|
connectionDragThreshold: td,
|
|
onBeforeDelete: X,
|
|
debug: tv,
|
|
ariaLabelConfig: tx,
|
|
zIndexMode: tS,
|
|
}),
|
|
(0, o.jsx)(P, { onSelectionChange: $ }),
|
|
e$,
|
|
(0, o.jsx)(I, { proOptions: e4, position: e5 }),
|
|
(0, o.jsx)(S, { rfId: t_, disableKeyboardA11y: e9 }),
|
|
],
|
|
}),
|
|
});
|
|
});
|
|
function tv() {
|
|
let e = h();
|
|
return (0, i.useCallback)((t) => {
|
|
let { domNode: n, updateNodeInternals: o } = e.getState(),
|
|
i = Array.isArray(t) ? t : [t],
|
|
r = new Map();
|
|
i.forEach((e) => {
|
|
let t = n?.querySelector(`.react-flow__node[data-id="${e}"]`);
|
|
t && r.set(e, { id: e, nodeElement: t, force: !0 });
|
|
}),
|
|
requestAnimationFrame(() => o(r, { triggerFitView: !1 }));
|
|
}, []);
|
|
}
|
|
let tw = (e) => ({
|
|
x: e.transform[0],
|
|
y: e.transform[1],
|
|
zoom: e.transform[2],
|
|
});
|
|
function tx() {
|
|
return p(tw, l.shallow);
|
|
}
|
|
function tS({ onStart: e, onChange: t, onEnd: n }) {
|
|
let o = h();
|
|
(0, i.useEffect)(() => {
|
|
o.setState({ onViewportChangeStart: e });
|
|
}, [e]),
|
|
(0, i.useEffect)(() => {
|
|
o.setState({ onViewportChange: t });
|
|
}, [t]),
|
|
(0, i.useEffect)(() => {
|
|
o.setState({ onViewportChangeEnd: n });
|
|
}, [n]);
|
|
}
|
|
function tb({ onChange: e }) {
|
|
let t = h();
|
|
(0, i.useEffect)(() => {
|
|
let n = [...t.getState().onSelectionChangeHandlers, e];
|
|
return (
|
|
t.setState({ onSelectionChangeHandlers: n }),
|
|
() => {
|
|
let n = t
|
|
.getState()
|
|
.onSelectionChangeHandlers.filter((t) => t !== e);
|
|
t.setState({ onSelectionChangeHandlers: n });
|
|
}
|
|
);
|
|
}, [e]);
|
|
}
|
|
function tI({ dimensions: e, lineWidth: t, variant: n, className: i }) {
|
|
return (0, o.jsx)("path", {
|
|
strokeWidth: t,
|
|
d: `M${e[0] / 2} 0 V${e[1]} M0 ${e[1] / 2} H${e[0]}`,
|
|
className: (0, r.default)(["react-flow__background-pattern", n, i]),
|
|
});
|
|
}
|
|
function t_({ radius: e, className: t }) {
|
|
return (0, o.jsx)("circle", {
|
|
cx: e,
|
|
cy: e,
|
|
r: e,
|
|
className: (0, r.default)([
|
|
"react-flow__background-pattern",
|
|
"dots",
|
|
t,
|
|
]),
|
|
});
|
|
}
|
|
a.errorMessages.error014(),
|
|
((t = n || (n = {})).Lines = "lines"),
|
|
(t.Dots = "dots"),
|
|
(t.Cross = "cross");
|
|
let tE = { [n.Dots]: 1, [n.Lines]: 1, [n.Cross]: 6 },
|
|
tM = (e) => ({ transform: e.transform, patternId: `pattern-${e.rfId}` });
|
|
function tC({
|
|
id: e,
|
|
variant: t = n.Dots,
|
|
gap: a = 20,
|
|
size: s,
|
|
lineWidth: d = 1,
|
|
offset: u = 0,
|
|
color: c,
|
|
bgColor: h,
|
|
style: g,
|
|
className: f,
|
|
patternClassName: m,
|
|
}) {
|
|
let y = (0, i.useRef)(null),
|
|
{ transform: v, patternId: w } = p(tM, l.shallow),
|
|
x = s || tE[t],
|
|
S = t === n.Dots,
|
|
b = t === n.Cross,
|
|
I = Array.isArray(a) ? a : [a, a],
|
|
_ = [I[0] * v[2] || 1, I[1] * v[2] || 1],
|
|
E = x * v[2],
|
|
M = Array.isArray(u) ? u : [u, u],
|
|
C = b ? [E, E] : _,
|
|
N = [M[0] * v[2] || 1 + C[0] / 2, M[1] * v[2] || 1 + C[1] / 2],
|
|
P = `${w}${e || ""}`;
|
|
return (0, o.jsxs)("svg", {
|
|
className: (0, r.default)(["react-flow__background", f]),
|
|
style: {
|
|
...g,
|
|
...ei,
|
|
"--xy-background-color-props": h,
|
|
"--xy-background-pattern-color-props": c,
|
|
},
|
|
ref: y,
|
|
"data-testid": "rf__background",
|
|
children: [
|
|
(0, o.jsx)("pattern", {
|
|
id: P,
|
|
x: v[0] % _[0],
|
|
y: v[1] % _[1],
|
|
width: _[0],
|
|
height: _[1],
|
|
patternUnits: "userSpaceOnUse",
|
|
patternTransform: `translate(-${N[0]},-${N[1]})`,
|
|
children: S
|
|
? (0, o.jsx)(t_, { radius: E / 2, className: m })
|
|
: (0, o.jsx)(tI, {
|
|
dimensions: C,
|
|
lineWidth: d,
|
|
variant: t,
|
|
className: m,
|
|
}),
|
|
}),
|
|
(0, o.jsx)("rect", {
|
|
x: "0",
|
|
y: "0",
|
|
width: "100%",
|
|
height: "100%",
|
|
fill: `url(#${P})`,
|
|
}),
|
|
],
|
|
});
|
|
}
|
|
tC.displayName = "Background";
|
|
let tN = (0, i.memo)(tC);
|
|
function tP() {
|
|
return (0, o.jsx)("svg", {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 32 32",
|
|
children: (0, o.jsx)("path", {
|
|
d: "M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z",
|
|
}),
|
|
});
|
|
}
|
|
function tk() {
|
|
return (0, o.jsx)("svg", {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 32 5",
|
|
children: (0, o.jsx)("path", { d: "M0 0h32v4.2H0z" }),
|
|
});
|
|
}
|
|
function tT() {
|
|
return (0, o.jsx)("svg", {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 32 30",
|
|
children: (0, o.jsx)("path", {
|
|
d: "M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z",
|
|
}),
|
|
});
|
|
}
|
|
function tO() {
|
|
return (0, o.jsx)("svg", {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 25 32",
|
|
children: (0, o.jsx)("path", {
|
|
d: "M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z",
|
|
}),
|
|
});
|
|
}
|
|
function tA() {
|
|
return (0, o.jsx)("svg", {
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
viewBox: "0 0 25 32",
|
|
children: (0, o.jsx)("path", {
|
|
d: "M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z",
|
|
}),
|
|
});
|
|
}
|
|
function tD({ children: e, className: t, ...n }) {
|
|
return (0, o.jsx)("button", {
|
|
type: "button",
|
|
className: (0, r.default)(["react-flow__controls-button", t]),
|
|
...n,
|
|
children: e,
|
|
});
|
|
}
|
|
let tL = (e) => ({
|
|
isInteractive:
|
|
e.nodesDraggable || e.nodesConnectable || e.elementsSelectable,
|
|
minZoomReached: e.transform[2] <= e.minZoom,
|
|
maxZoomReached: e.transform[2] >= e.maxZoom,
|
|
ariaLabelConfig: e.ariaLabelConfig,
|
|
});
|
|
function tj({
|
|
style: e,
|
|
showZoom: t = !0,
|
|
showFitView: n = !0,
|
|
showInteractive: i = !0,
|
|
fitViewOptions: a,
|
|
onZoomIn: s,
|
|
onZoomOut: d,
|
|
onFitView: u,
|
|
onInteractiveChange: c,
|
|
className: g,
|
|
children: f,
|
|
position: m = "bottom-left",
|
|
orientation: y = "vertical",
|
|
"aria-label": v,
|
|
}) {
|
|
let w = h(),
|
|
{
|
|
isInteractive: x,
|
|
minZoomReached: S,
|
|
maxZoomReached: I,
|
|
ariaLabelConfig: _,
|
|
} = p(tL, l.shallow),
|
|
{ zoomIn: E, zoomOut: M, fitView: C } = et();
|
|
return (0, o.jsxs)(b, {
|
|
className: (0, r.default)([
|
|
"react-flow__controls",
|
|
"horizontal" === y ? "horizontal" : "vertical",
|
|
g,
|
|
]),
|
|
position: m,
|
|
style: e,
|
|
"data-testid": "rf__controls",
|
|
"aria-label": v ?? _["controls.ariaLabel"],
|
|
children: [
|
|
t &&
|
|
(0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
(0, o.jsx)(tD, {
|
|
onClick: () => {
|
|
E(), s?.();
|
|
},
|
|
className: "react-flow__controls-zoomin",
|
|
title: _["controls.zoomIn.ariaLabel"],
|
|
"aria-label": _["controls.zoomIn.ariaLabel"],
|
|
disabled: I,
|
|
children: (0, o.jsx)(tP, {}),
|
|
}),
|
|
(0, o.jsx)(tD, {
|
|
onClick: () => {
|
|
M(), d?.();
|
|
},
|
|
className: "react-flow__controls-zoomout",
|
|
title: _["controls.zoomOut.ariaLabel"],
|
|
"aria-label": _["controls.zoomOut.ariaLabel"],
|
|
disabled: S,
|
|
children: (0, o.jsx)(tk, {}),
|
|
}),
|
|
],
|
|
}),
|
|
n &&
|
|
(0, o.jsx)(tD, {
|
|
className: "react-flow__controls-fitview",
|
|
onClick: () => {
|
|
C(a), u?.();
|
|
},
|
|
title: _["controls.fitView.ariaLabel"],
|
|
"aria-label": _["controls.fitView.ariaLabel"],
|
|
children: (0, o.jsx)(tT, {}),
|
|
}),
|
|
i &&
|
|
(0, o.jsx)(tD, {
|
|
className: "react-flow__controls-interactive",
|
|
onClick: () => {
|
|
w.setState({
|
|
nodesDraggable: !x,
|
|
nodesConnectable: !x,
|
|
elementsSelectable: !x,
|
|
}),
|
|
c?.(!x);
|
|
},
|
|
title: _["controls.interactive.ariaLabel"],
|
|
"aria-label": _["controls.interactive.ariaLabel"],
|
|
children: x ? (0, o.jsx)(tA, {}) : (0, o.jsx)(tO, {}),
|
|
}),
|
|
f,
|
|
],
|
|
});
|
|
}
|
|
(tj.displayName = "Controls"), (0, i.memo)(tj);
|
|
let tR = (0, i.memo)(function ({
|
|
id: e,
|
|
x: t,
|
|
y: n,
|
|
width: i,
|
|
height: a,
|
|
style: s,
|
|
color: l,
|
|
strokeColor: d,
|
|
strokeWidth: u,
|
|
className: c,
|
|
borderRadius: p,
|
|
shapeRendering: h,
|
|
selected: g,
|
|
onClick: f,
|
|
}) {
|
|
let { background: m, backgroundColor: y } = s || {};
|
|
return (0, o.jsx)("rect", {
|
|
className: (0, r.default)([
|
|
"react-flow__minimap-node",
|
|
{ selected: g },
|
|
c,
|
|
]),
|
|
x: t,
|
|
y: n,
|
|
rx: p,
|
|
ry: p,
|
|
width: i,
|
|
height: a,
|
|
style: { fill: l || m || y, stroke: d, strokeWidth: u },
|
|
shapeRendering: h,
|
|
onClick: f ? (t) => f(t, e) : void 0,
|
|
});
|
|
}),
|
|
tz = (e) => e.nodes.map((e) => e.id),
|
|
tF = (e) => (e instanceof Function ? e : () => e),
|
|
t$ = (0, i.memo)(function ({
|
|
id: e,
|
|
nodeColorFunc: t,
|
|
nodeStrokeColorFunc: n,
|
|
nodeClassNameFunc: i,
|
|
nodeBorderRadius: r,
|
|
nodeStrokeWidth: s,
|
|
shapeRendering: d,
|
|
NodeComponent: u,
|
|
onClick: c,
|
|
}) {
|
|
let {
|
|
node: h,
|
|
x: g,
|
|
y: f,
|
|
width: m,
|
|
height: y,
|
|
} = p((t) => {
|
|
let { internals: n } = t.nodeLookup.get(e),
|
|
o = n.userNode,
|
|
{ x: i, y: r } = n.positionAbsolute,
|
|
{ width: s, height: l } = (0, a.getNodeDimensions)(o);
|
|
return { node: o, x: i, y: r, width: s, height: l };
|
|
}, l.shallow);
|
|
return h && !h.hidden && (0, a.nodeHasDimensions)(h)
|
|
? (0, o.jsx)(u, {
|
|
x: g,
|
|
y: f,
|
|
width: m,
|
|
height: y,
|
|
style: h.style,
|
|
selected: !!h.selected,
|
|
className: i(h),
|
|
color: t(h),
|
|
borderRadius: r,
|
|
strokeColor: n(h),
|
|
strokeWidth: s,
|
|
shapeRendering: d,
|
|
onClick: c,
|
|
id: h.id,
|
|
})
|
|
: null;
|
|
});
|
|
var tB = (0, i.memo)(function ({
|
|
nodeStrokeColor: e,
|
|
nodeColor: t,
|
|
nodeClassName: n = "",
|
|
nodeBorderRadius: i = 5,
|
|
nodeStrokeWidth: r,
|
|
nodeComponent: a = tR,
|
|
onClick: s,
|
|
}) {
|
|
let d = p(tz, l.shallow),
|
|
u = tF(t),
|
|
c = tF(e),
|
|
h = tF(n),
|
|
g =
|
|
"u" < typeof window || window.chrome
|
|
? "crispEdges"
|
|
: "geometricPrecision";
|
|
return (0, o.jsx)(o.Fragment, {
|
|
children: d.map((e) =>
|
|
(0, o.jsx)(
|
|
t$,
|
|
{
|
|
id: e,
|
|
nodeColorFunc: u,
|
|
nodeStrokeColorFunc: c,
|
|
nodeClassNameFunc: h,
|
|
nodeBorderRadius: i,
|
|
nodeStrokeWidth: r,
|
|
NodeComponent: a,
|
|
onClick: s,
|
|
shapeRendering: g,
|
|
},
|
|
e,
|
|
),
|
|
),
|
|
});
|
|
});
|
|
let tH = (e) => !e.hidden,
|
|
tV = (e) => {
|
|
let t = {
|
|
x: -e.transform[0] / e.transform[2],
|
|
y: -e.transform[1] / e.transform[2],
|
|
width: e.width / e.transform[2],
|
|
height: e.height / e.transform[2],
|
|
};
|
|
return {
|
|
viewBB: t,
|
|
boundingRect:
|
|
e.nodeLookup.size > 0
|
|
? (0, a.getBoundsOfRects)(
|
|
(0, a.getInternalNodesBounds)(e.nodeLookup, { filter: tH }),
|
|
t,
|
|
)
|
|
: t,
|
|
rfId: e.rfId,
|
|
panZoom: e.panZoom,
|
|
translateExtent: e.translateExtent,
|
|
flowWidth: e.width,
|
|
flowHeight: e.height,
|
|
ariaLabelConfig: e.ariaLabelConfig,
|
|
};
|
|
};
|
|
function tU({
|
|
style: e,
|
|
className: t,
|
|
nodeStrokeColor: n,
|
|
nodeColor: s,
|
|
nodeClassName: d = "",
|
|
nodeBorderRadius: u = 5,
|
|
nodeStrokeWidth: c,
|
|
nodeComponent: g,
|
|
bgColor: f,
|
|
maskColor: m,
|
|
maskStrokeColor: y,
|
|
maskStrokeWidth: v,
|
|
position: w = "bottom-right",
|
|
onClick: x,
|
|
onNodeClick: S,
|
|
pannable: I = !1,
|
|
zoomable: _ = !1,
|
|
ariaLabel: E,
|
|
inversePan: M,
|
|
zoomStep: C = 1,
|
|
offsetScale: N = 5,
|
|
}) {
|
|
let P = h(),
|
|
k = (0, i.useRef)(null),
|
|
{
|
|
boundingRect: T,
|
|
viewBB: O,
|
|
rfId: A,
|
|
panZoom: D,
|
|
translateExtent: L,
|
|
flowWidth: j,
|
|
flowHeight: R,
|
|
ariaLabelConfig: z,
|
|
} = p(tV, l.shallow),
|
|
F = e?.width ?? 200,
|
|
$ = e?.height ?? 150,
|
|
B = Math.max(T.width / F, T.height / $),
|
|
H = B * F,
|
|
V = B * $,
|
|
U = N * B,
|
|
Y = T.x - (H - T.width) / 2 - U,
|
|
W = T.y - (V - T.height) / 2 - U,
|
|
X = H + 2 * U,
|
|
K = V + 2 * U,
|
|
q = `react-flow__minimap-desc-${A}`,
|
|
Z = (0, i.useRef)(0),
|
|
G = (0, i.useRef)();
|
|
(Z.current = B),
|
|
(0, i.useEffect)(() => {
|
|
if (k.current && D)
|
|
return (
|
|
(G.current = (0, a.XYMinimap)({
|
|
domNode: k.current,
|
|
panZoom: D,
|
|
getTransform: () => P.getState().transform,
|
|
getViewScale: () => Z.current,
|
|
})),
|
|
() => {
|
|
G.current?.destroy();
|
|
}
|
|
);
|
|
}, [D]),
|
|
(0, i.useEffect)(() => {
|
|
G.current?.update({
|
|
translateExtent: L,
|
|
width: j,
|
|
height: R,
|
|
inversePan: M,
|
|
pannable: I,
|
|
zoomStep: C,
|
|
zoomable: _,
|
|
});
|
|
}, [I, _, M, C, L, j, R]);
|
|
let Q = x
|
|
? (e) => {
|
|
let [t, n] = G.current?.pointer(e) || [0, 0];
|
|
x(e, { x: t, y: n });
|
|
}
|
|
: void 0,
|
|
J = S
|
|
? (0, i.useCallback)((e, t) => {
|
|
S(e, P.getState().nodeLookup.get(t).internals.userNode);
|
|
}, [])
|
|
: void 0,
|
|
ee = E ?? z["minimap.ariaLabel"];
|
|
return (0, o.jsx)(b, {
|
|
position: w,
|
|
style: {
|
|
...e,
|
|
"--xy-minimap-background-color-props":
|
|
"string" == typeof f ? f : void 0,
|
|
"--xy-minimap-mask-background-color-props":
|
|
"string" == typeof m ? m : void 0,
|
|
"--xy-minimap-mask-stroke-color-props":
|
|
"string" == typeof y ? y : void 0,
|
|
"--xy-minimap-mask-stroke-width-props":
|
|
"number" == typeof v ? v * B : void 0,
|
|
"--xy-minimap-node-background-color-props":
|
|
"string" == typeof s ? s : void 0,
|
|
"--xy-minimap-node-stroke-color-props":
|
|
"string" == typeof n ? n : void 0,
|
|
"--xy-minimap-node-stroke-width-props":
|
|
"number" == typeof c ? c : void 0,
|
|
},
|
|
className: (0, r.default)(["react-flow__minimap", t]),
|
|
"data-testid": "rf__minimap",
|
|
children: (0, o.jsxs)("svg", {
|
|
width: F,
|
|
height: $,
|
|
viewBox: `${Y} ${W} ${X} ${K}`,
|
|
className: "react-flow__minimap-svg",
|
|
role: "img",
|
|
"aria-labelledby": q,
|
|
ref: k,
|
|
onClick: Q,
|
|
children: [
|
|
ee && (0, o.jsx)("title", { id: q, children: ee }),
|
|
(0, o.jsx)(tB, {
|
|
onClick: J,
|
|
nodeColor: s,
|
|
nodeStrokeColor: n,
|
|
nodeBorderRadius: u,
|
|
nodeClassName: d,
|
|
nodeStrokeWidth: c,
|
|
nodeComponent: g,
|
|
}),
|
|
(0, o.jsx)("path", {
|
|
className: "react-flow__minimap-mask",
|
|
d: `M${Y - U},${W - U}h${X + 2 * U}v${K + 2 * U}h${-X - 2 * U}z
|
|
M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,
|
|
fillRule: "evenodd",
|
|
pointerEvents: "none",
|
|
}),
|
|
],
|
|
}),
|
|
});
|
|
}
|
|
tU.displayName = "MiniMap";
|
|
let tY = (0, i.memo)(tU),
|
|
tW = {
|
|
[a.ResizeControlVariant.Line]: "right",
|
|
[a.ResizeControlVariant.Handle]: "bottom-right",
|
|
},
|
|
tX = (0, i.memo)(function ({
|
|
nodeId: e,
|
|
position: t,
|
|
variant: n = a.ResizeControlVariant.Handle,
|
|
className: s,
|
|
style: d,
|
|
children: u,
|
|
color: c,
|
|
minWidth: g = 10,
|
|
minHeight: f = 10,
|
|
maxWidth: m = Number.MAX_VALUE,
|
|
maxHeight: y = Number.MAX_VALUE,
|
|
keepAspectRatio: v = !1,
|
|
resizeDirection: w,
|
|
autoScale: x = !0,
|
|
shouldResize: S,
|
|
onResizeStart: b,
|
|
onResize: I,
|
|
onResizeEnd: _,
|
|
}) {
|
|
let E,
|
|
M = ey(),
|
|
C = "string" == typeof e ? e : M,
|
|
N = h(),
|
|
P = (0, i.useRef)(null),
|
|
k = n === a.ResizeControlVariant.Handle,
|
|
T = p(
|
|
(0, i.useCallback)(
|
|
((E = k && x),
|
|
(e) => (E ? `${Math.max(1 / e.transform[2], 1)}` : void 0)),
|
|
[k, x],
|
|
),
|
|
l.shallow,
|
|
),
|
|
O = (0, i.useRef)(null),
|
|
A = t ?? tW[n];
|
|
(0, i.useEffect)(() => {
|
|
if (P.current && C)
|
|
return (
|
|
O.current ||
|
|
(O.current = (0, a.XYResizer)({
|
|
domNode: P.current,
|
|
nodeId: C,
|
|
getStoreItems: () => {
|
|
let {
|
|
nodeLookup: e,
|
|
transform: t,
|
|
snapGrid: n,
|
|
snapToGrid: o,
|
|
nodeOrigin: i,
|
|
domNode: r,
|
|
} = N.getState();
|
|
return {
|
|
nodeLookup: e,
|
|
transform: t,
|
|
snapGrid: n,
|
|
snapToGrid: o,
|
|
nodeOrigin: i,
|
|
paneDomNode: r,
|
|
};
|
|
},
|
|
onChange: (e, t) => {
|
|
let {
|
|
triggerNodeChanges: n,
|
|
nodeLookup: o,
|
|
parentLookup: i,
|
|
nodeOrigin: r,
|
|
} = N.getState(),
|
|
s = [],
|
|
l = { x: e.x, y: e.y },
|
|
d = o.get(C);
|
|
if (d && d.expandParent && d.parentId) {
|
|
let t = d.origin ?? r,
|
|
n = e.width ?? d.measured.width ?? 0,
|
|
u = e.height ?? d.measured.height ?? 0,
|
|
c = {
|
|
id: d.id,
|
|
parentId: d.parentId,
|
|
rect: {
|
|
width: n,
|
|
height: u,
|
|
...(0, a.evaluateAbsolutePosition)(
|
|
{
|
|
x: e.x ?? d.position.x,
|
|
y: e.y ?? d.position.y,
|
|
},
|
|
{ width: n, height: u },
|
|
d.parentId,
|
|
o,
|
|
t,
|
|
),
|
|
},
|
|
},
|
|
p = (0, a.handleExpandParent)([c], o, i, r);
|
|
s.push(...p),
|
|
(l.x = e.x ? Math.max(t[0] * n, e.x) : void 0),
|
|
(l.y = e.y ? Math.max(t[1] * u, e.y) : void 0);
|
|
}
|
|
if (void 0 !== l.x && void 0 !== l.y) {
|
|
let e = { id: C, type: "position", position: { ...l } };
|
|
s.push(e);
|
|
}
|
|
if (void 0 !== e.width && void 0 !== e.height) {
|
|
let t = {
|
|
id: C,
|
|
type: "dimensions",
|
|
resizing: !0,
|
|
setAttributes:
|
|
!w || ("horizontal" === w ? "width" : "height"),
|
|
dimensions: { width: e.width, height: e.height },
|
|
};
|
|
s.push(t);
|
|
}
|
|
for (let e of t) {
|
|
let t = { ...e, type: "position" };
|
|
s.push(t);
|
|
}
|
|
n(s);
|
|
},
|
|
onEnd: ({ width: e, height: t }) => {
|
|
N.getState().triggerNodeChanges([
|
|
{
|
|
id: C,
|
|
type: "dimensions",
|
|
resizing: !1,
|
|
dimensions: { width: e, height: t },
|
|
},
|
|
]);
|
|
},
|
|
})),
|
|
O.current.update({
|
|
controlPosition: A,
|
|
boundaries: {
|
|
minWidth: g,
|
|
minHeight: f,
|
|
maxWidth: m,
|
|
maxHeight: y,
|
|
},
|
|
keepAspectRatio: v,
|
|
resizeDirection: w,
|
|
onResizeStart: b,
|
|
onResize: I,
|
|
onResizeEnd: _,
|
|
shouldResize: S,
|
|
}),
|
|
() => {
|
|
O.current?.destroy();
|
|
}
|
|
);
|
|
}, [A, g, f, m, y, v, b, I, _, S]);
|
|
let D = A.split("-");
|
|
return (0, o.jsx)("div", {
|
|
className: (0, r.default)([
|
|
"react-flow__resize-control",
|
|
"nodrag",
|
|
...D,
|
|
n,
|
|
s,
|
|
]),
|
|
ref: P,
|
|
style: {
|
|
...d,
|
|
scale: T,
|
|
...(c && { [k ? "backgroundColor" : "borderColor"]: c }),
|
|
},
|
|
children: u,
|
|
});
|
|
});
|
|
function tK({
|
|
nodeId: e,
|
|
isVisible: t = !0,
|
|
handleClassName: n,
|
|
handleStyle: i,
|
|
lineClassName: r,
|
|
lineStyle: s,
|
|
color: l,
|
|
minWidth: d = 10,
|
|
minHeight: u = 10,
|
|
maxWidth: c = Number.MAX_VALUE,
|
|
maxHeight: p = Number.MAX_VALUE,
|
|
keepAspectRatio: h = !1,
|
|
autoScale: g = !0,
|
|
shouldResize: f,
|
|
onResizeStart: m,
|
|
onResize: y,
|
|
onResizeEnd: v,
|
|
}) {
|
|
return t
|
|
? (0, o.jsxs)(o.Fragment, {
|
|
children: [
|
|
a.XY_RESIZER_LINE_POSITIONS.map((t) =>
|
|
(0, o.jsx)(
|
|
tX,
|
|
{
|
|
className: r,
|
|
style: s,
|
|
nodeId: e,
|
|
position: t,
|
|
variant: a.ResizeControlVariant.Line,
|
|
color: l,
|
|
minWidth: d,
|
|
minHeight: u,
|
|
maxWidth: c,
|
|
maxHeight: p,
|
|
onResizeStart: m,
|
|
keepAspectRatio: h,
|
|
autoScale: g,
|
|
shouldResize: f,
|
|
onResize: y,
|
|
onResizeEnd: v,
|
|
},
|
|
t,
|
|
),
|
|
),
|
|
a.XY_RESIZER_HANDLE_POSITIONS.map((t) =>
|
|
(0, o.jsx)(
|
|
tX,
|
|
{
|
|
className: n,
|
|
style: i,
|
|
nodeId: e,
|
|
position: t,
|
|
color: l,
|
|
minWidth: d,
|
|
minHeight: u,
|
|
maxWidth: c,
|
|
maxHeight: p,
|
|
onResizeStart: m,
|
|
keepAspectRatio: h,
|
|
autoScale: g,
|
|
shouldResize: f,
|
|
onResize: y,
|
|
onResizeEnd: v,
|
|
},
|
|
t,
|
|
),
|
|
),
|
|
],
|
|
})
|
|
: null;
|
|
}
|
|
e.s([
|
|
"Background",
|
|
() => tN,
|
|
"Handle",
|
|
() => ew,
|
|
"MiniMap",
|
|
() => tY,
|
|
"NodeResizer",
|
|
() => tK,
|
|
"ReactFlow",
|
|
() => ty,
|
|
"applyEdgeChanges",
|
|
() => V,
|
|
"applyNodeChanges",
|
|
() => H,
|
|
"useNodeId",
|
|
() => ey,
|
|
"useOnSelectionChange",
|
|
() => tb,
|
|
"useOnViewportChange",
|
|
() => tS,
|
|
"useReactFlow",
|
|
() => et,
|
|
"useStore",
|
|
() => p,
|
|
"useStoreApi",
|
|
() => h,
|
|
"useUpdateNodeInternals",
|
|
() => tv,
|
|
"useViewport",
|
|
() => tx,
|
|
]);
|
|
};
|
|
|
|
export default moduleFactory;
|