react-cosmos-diagram 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../react-diagram/packages/react/src/container/DragSelection/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAC;AAsBtE,KAAK,kBAAkB,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACtB,CAAC;AAcF,iBAAS,aAAa,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAsMnE;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../react-diagram/packages/react/src/container/DragSelection/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAC;AAsBtE,KAAK,kBAAkB,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACtB,CAAC;AAcF,iBAAS,aAAa,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA6MnE;AAED,eAAe,aAAa,CAAC"}
@@ -2,6 +2,6 @@ interface KeyOptions {
2
2
  target?: Window | Document | HTMLElement | null;
3
3
  }
4
4
  export type KeyCode = string | Array<string> | null;
5
- declare function useKeyPress(key: KeyCode, options?: KeyOptions): boolean;
5
+ declare function useKeyPress(key?: KeyCode, options?: KeyOptions): boolean;
6
6
  export default useKeyPress;
7
7
  //# sourceMappingURL=useKeyPress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyPress.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/hooks/useKeyPress.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAIpD,iBAAS,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,UAAe,WAgC1D;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"useKeyPress.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/hooks/useKeyPress.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAIpD,iBAAS,WAAW,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAE,UAAe,WAgC3D;AAED,eAAe,WAAW,CAAC"}
package/dist/esm/index.js CHANGED
@@ -396,10 +396,8 @@ function DragSelection({ isSelecting, children }) {
396
396
  const prevSelectedNodesCount = useRef(0);
397
397
  const containerBounds = useRef();
398
398
  const { elementsSelectable, selectionBoxRect, transformString, selectionBoxActive, } = useStore(selector$6, shallow);
399
- const [dragBoxStartPosition, setDragBoxStartPosition] = useState({
400
- x: 0,
401
- y: 0,
402
- });
399
+ const dragBoxStartPosition = useRef({ x: 0, y: 0 });
400
+ const isDragging = useRef(false);
403
401
  const [dragBoxRect, setDragBoxRect] = useState({
404
402
  width: 0,
405
403
  height: 0,
@@ -411,10 +409,8 @@ function DragSelection({ isSelecting, children }) {
411
409
  store.setState({
412
410
  selectionBoxActive: prevSelectedNodesCount.current > 0,
413
411
  });
414
- setDragBoxStartPosition({
415
- x: 0,
416
- y: 0,
417
- });
412
+ dragBoxStartPosition.current = { x: 0, y: 0 };
413
+ isDragging.current = false;
418
414
  setDragBoxRect({
419
415
  width: 0,
420
416
  height: 0,
@@ -450,28 +446,27 @@ function DragSelection({ isSelecting, children }) {
450
446
  x,
451
447
  y,
452
448
  });
453
- setDragBoxStartPosition({
454
- x,
455
- y,
456
- });
449
+ dragBoxStartPosition.current = { x, y };
450
+ isDragging.current = true;
457
451
  };
458
452
  const onMouseMove = (event) => {
459
453
  const { nodeInternals, transform, nodeOrigin, getNodes, onNodesChange } = store.getState();
460
- const hasDragBoxStartPosition = dragBoxStartPosition.x > 0 && dragBoxStartPosition.y > 0;
461
- if (
454
+ if (!isDragging.current ||
455
+ !containerBounds.current
462
456
  // !hasDragBoxPosition ||
463
457
  // !isSelecting ||
464
- !hasDragBoxStartPosition ||
465
- !containerBounds.current) {
458
+ ) {
466
459
  return;
467
460
  }
468
- store.setState({
469
- selectionBoxActive: false,
470
- });
461
+ if (selectionBoxActive) {
462
+ store.setState({
463
+ selectionBoxActive: false,
464
+ });
465
+ }
471
466
  setDragBoxActive(true);
472
467
  const mousePos = getEventPosition(event.nativeEvent, containerBounds.current);
473
- const startX = dragBoxStartPosition.x ?? 0;
474
- const startY = dragBoxStartPosition.y ?? 0;
468
+ const startX = dragBoxStartPosition.current.x;
469
+ const startY = dragBoxStartPosition.current.y;
475
470
  const rect = {
476
471
  x: mousePos.x < startX ? mousePos.x : startX,
477
472
  y: mousePos.y < startY ? mousePos.y : startY,
@@ -494,6 +489,16 @@ function DragSelection({ isSelecting, children }) {
494
489
  if (event.button !== 0) {
495
490
  return;
496
491
  }
492
+ // 드래그 중이었다면, 이후 발생할 click 이벤트가 Pane(d3 click.zoom)으로
493
+ // 버블링되지 않도록 capture phase에서 한 번만 차단
494
+ if (isDragging.current && dragSelection.current) {
495
+ const container = dragSelection.current;
496
+ const stopClick = (e) => {
497
+ e.stopPropagation();
498
+ container.removeEventListener('click', stopClick, true);
499
+ };
500
+ container.addEventListener('click', stopClick, true);
501
+ }
497
502
  resetDragBox();
498
503
  };
499
504
  const onMouseLeave = () => {
@@ -507,7 +512,7 @@ function DragSelection({ isSelecting, children }) {
507
512
  dragBoxActive ||
508
513
  selectionBoxActive,
509
514
  },
510
- ]), onClick: isPossibleDragSelection ? onClick : undefined, onMouseDown: isPossibleDragSelection ? onMouseDown : undefined, onMouseMove: isPossibleDragSelection || dragBoxActive ? onMouseMove : undefined, onMouseUp: elementsSelectable ? onMouseUp : undefined, onMouseLeave: elementsSelectable ? onMouseLeave : undefined, children: [children, dragBoxActive && jsx(DragBox, { rect: dragBoxRect }), selectionBoxActive && (jsx(SelectionBox$1, { rect: selectionBoxRect, transform: transformString }))] }));
515
+ ]), onClick: isPossibleDragSelection && dragBoxActive ? onClick : undefined, onMouseDown: isPossibleDragSelection ? onMouseDown : undefined, onMouseMove: isPossibleDragSelection || dragBoxActive ? onMouseMove : undefined, onMouseUp: elementsSelectable ? onMouseUp : undefined, onMouseLeave: elementsSelectable ? onMouseLeave : undefined, children: [children, dragBoxActive && jsx(DragBox, { rect: dragBoxRect }), selectionBoxActive && (jsx(SelectionBox$1, { rect: selectionBoxRect, transform: transformString }))] }));
511
516
  }
512
517
 
513
518
  const selector$5 = (s) => {
@@ -521,7 +526,7 @@ const selector$5 = (s) => {
521
526
  function DiagramRenderer({ children, multiSelectionKeyCode, dragSelectionKeyCode, deleteKeyCode, noPanClassName, panning, defaultViewport, onMove, onMoveStart, onMoveEnd, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, }) {
522
527
  useGlobalKeyHandler({ multiSelectionKeyCode, deleteKeyCode });
523
528
  const { minZoom, maxZoom, translateExtent } = useStore(selector$5);
524
- const dragSelectionKeyPressed = useKeyPress(dragSelectionKeyCode || 'Shift');
529
+ const dragSelectionKeyPressed = useKeyPress(dragSelectionKeyCode);
525
530
  // useKeyPress
526
531
  const isSelecting = dragSelectionKeyPressed;
527
532
  const isPanning = panning && !isSelecting;
@@ -396,10 +396,8 @@ function DragSelection({ isSelecting, children }) {
396
396
  const prevSelectedNodesCount = useRef(0);
397
397
  const containerBounds = useRef();
398
398
  const { elementsSelectable, selectionBoxRect, transformString, selectionBoxActive, } = useStore(selector$6, shallow);
399
- const [dragBoxStartPosition, setDragBoxStartPosition] = useState({
400
- x: 0,
401
- y: 0,
402
- });
399
+ const dragBoxStartPosition = useRef({ x: 0, y: 0 });
400
+ const isDragging = useRef(false);
403
401
  const [dragBoxRect, setDragBoxRect] = useState({
404
402
  width: 0,
405
403
  height: 0,
@@ -411,10 +409,8 @@ function DragSelection({ isSelecting, children }) {
411
409
  store.setState({
412
410
  selectionBoxActive: prevSelectedNodesCount.current > 0,
413
411
  });
414
- setDragBoxStartPosition({
415
- x: 0,
416
- y: 0,
417
- });
412
+ dragBoxStartPosition.current = { x: 0, y: 0 };
413
+ isDragging.current = false;
418
414
  setDragBoxRect({
419
415
  width: 0,
420
416
  height: 0,
@@ -450,28 +446,27 @@ function DragSelection({ isSelecting, children }) {
450
446
  x,
451
447
  y,
452
448
  });
453
- setDragBoxStartPosition({
454
- x,
455
- y,
456
- });
449
+ dragBoxStartPosition.current = { x, y };
450
+ isDragging.current = true;
457
451
  };
458
452
  const onMouseMove = (event) => {
459
453
  const { nodeInternals, transform, nodeOrigin, getNodes, onNodesChange } = store.getState();
460
- const hasDragBoxStartPosition = dragBoxStartPosition.x > 0 && dragBoxStartPosition.y > 0;
461
- if (
454
+ if (!isDragging.current ||
455
+ !containerBounds.current
462
456
  // !hasDragBoxPosition ||
463
457
  // !isSelecting ||
464
- !hasDragBoxStartPosition ||
465
- !containerBounds.current) {
458
+ ) {
466
459
  return;
467
460
  }
468
- store.setState({
469
- selectionBoxActive: false,
470
- });
461
+ if (selectionBoxActive) {
462
+ store.setState({
463
+ selectionBoxActive: false,
464
+ });
465
+ }
471
466
  setDragBoxActive(true);
472
467
  const mousePos = getEventPosition(event.nativeEvent, containerBounds.current);
473
- const startX = dragBoxStartPosition.x ?? 0;
474
- const startY = dragBoxStartPosition.y ?? 0;
468
+ const startX = dragBoxStartPosition.current.x;
469
+ const startY = dragBoxStartPosition.current.y;
475
470
  const rect = {
476
471
  x: mousePos.x < startX ? mousePos.x : startX,
477
472
  y: mousePos.y < startY ? mousePos.y : startY,
@@ -494,6 +489,16 @@ function DragSelection({ isSelecting, children }) {
494
489
  if (event.button !== 0) {
495
490
  return;
496
491
  }
492
+ // 드래그 중이었다면, 이후 발생할 click 이벤트가 Pane(d3 click.zoom)으로
493
+ // 버블링되지 않도록 capture phase에서 한 번만 차단
494
+ if (isDragging.current && dragSelection.current) {
495
+ const container = dragSelection.current;
496
+ const stopClick = (e) => {
497
+ e.stopPropagation();
498
+ container.removeEventListener('click', stopClick, true);
499
+ };
500
+ container.addEventListener('click', stopClick, true);
501
+ }
497
502
  resetDragBox();
498
503
  };
499
504
  const onMouseLeave = () => {
@@ -507,7 +512,7 @@ function DragSelection({ isSelecting, children }) {
507
512
  dragBoxActive ||
508
513
  selectionBoxActive,
509
514
  },
510
- ]), onClick: isPossibleDragSelection ? onClick : undefined, onMouseDown: isPossibleDragSelection ? onMouseDown : undefined, onMouseMove: isPossibleDragSelection || dragBoxActive ? onMouseMove : undefined, onMouseUp: elementsSelectable ? onMouseUp : undefined, onMouseLeave: elementsSelectable ? onMouseLeave : undefined, children: [children, dragBoxActive && jsx(DragBox, { rect: dragBoxRect }), selectionBoxActive && (jsx(SelectionBox$1, { rect: selectionBoxRect, transform: transformString }))] }));
515
+ ]), onClick: isPossibleDragSelection && dragBoxActive ? onClick : undefined, onMouseDown: isPossibleDragSelection ? onMouseDown : undefined, onMouseMove: isPossibleDragSelection || dragBoxActive ? onMouseMove : undefined, onMouseUp: elementsSelectable ? onMouseUp : undefined, onMouseLeave: elementsSelectable ? onMouseLeave : undefined, children: [children, dragBoxActive && jsx(DragBox, { rect: dragBoxRect }), selectionBoxActive && (jsx(SelectionBox$1, { rect: selectionBoxRect, transform: transformString }))] }));
511
516
  }
512
517
 
513
518
  const selector$5 = (s) => {
@@ -521,7 +526,7 @@ const selector$5 = (s) => {
521
526
  function DiagramRenderer({ children, multiSelectionKeyCode, dragSelectionKeyCode, deleteKeyCode, noPanClassName, panning, defaultViewport, onMove, onMoveStart, onMoveEnd, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, }) {
522
527
  useGlobalKeyHandler({ multiSelectionKeyCode, deleteKeyCode });
523
528
  const { minZoom, maxZoom, translateExtent } = useStore(selector$5);
524
- const dragSelectionKeyPressed = useKeyPress(dragSelectionKeyCode || 'Shift');
529
+ const dragSelectionKeyPressed = useKeyPress(dragSelectionKeyCode);
525
530
  // useKeyPress
526
531
  const isSelecting = dragSelectionKeyPressed;
527
532
  const isPanning = panning && !isSelecting;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../react-diagram/packages/react/src/container/DragSelection/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAC;AAsBtE,KAAK,kBAAkB,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACtB,CAAC;AAcF,iBAAS,aAAa,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAsMnE;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../react-diagram/packages/react/src/container/DragSelection/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiC,SAAS,EAAE,MAAM,OAAO,CAAC;AAsBtE,KAAK,kBAAkB,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACtB,CAAC;AAcF,iBAAS,aAAa,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA6MnE;AAED,eAAe,aAAa,CAAC"}
@@ -2,6 +2,6 @@ interface KeyOptions {
2
2
  target?: Window | Document | HTMLElement | null;
3
3
  }
4
4
  export type KeyCode = string | Array<string> | null;
5
- declare function useKeyPress(key: KeyCode, options?: KeyOptions): boolean;
5
+ declare function useKeyPress(key?: KeyCode, options?: KeyOptions): boolean;
6
6
  export default useKeyPress;
7
7
  //# sourceMappingURL=useKeyPress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyPress.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/hooks/useKeyPress.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAIpD,iBAAS,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,UAAe,WAgC1D;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"useKeyPress.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/hooks/useKeyPress.ts"],"names":[],"mappings":"AAEA,UAAU,UAAU;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAIpD,iBAAS,WAAW,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,GAAE,UAAe,WAgC3D;AAED,eAAe,WAAW,CAAC"}
package/dist/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactCosmosDiagram={},e.jsxRuntime,e.React)}(this,(function(e,t,n){"use strict";var o="http://www.w3.org/1999/xhtml",r={svg:"http://www.w3.org/2000/svg",xhtml:o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function i(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),r.hasOwnProperty(t)?{space:r[t],local:e}:e}function a(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===o&&t.documentElement.namespaceURI===o?t.createElement(e):t.createElementNS(n,e)}}function s(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function u(e){var t=i(e);return(t.local?s:a)(t)}function l(){}function c(e){return null==e?l:function(){return this.querySelector(e)}}function d(){return[]}function h(e){return null==e?d:function(){return this.querySelectorAll(e)}}function f(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function g(e){return function(){return this.matches(e)}}function p(e){return function(t){return t.matches(e)}}var m=Array.prototype.find;function y(){return this.firstElementChild}var v=Array.prototype.filter;function x(){return Array.from(this.children)}function b(e){return new Array(e.length)}function w(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function _(e,t,n,o,r,i){for(var a,s=0,u=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new w(e,i[s]);for(;s<u;++s)(a=t[s])&&(r[s]=a)}function E(e,t,n,o,r,i,a){var s,u,l,c=new Map,d=t.length,h=i.length,f=new Array(d);for(s=0;s<d;++s)(u=t[s])&&(f[s]=l=a.call(u,u.__data__,s,t)+"",c.has(l)?r[s]=u:c.set(l,u));for(s=0;s<h;++s)l=a.call(e,i[s],s,i)+"",(u=c.get(l))?(o[s]=u,u.__data__=i[s],c.delete(l)):n[s]=new w(e,i[s]);for(s=0;s<d;++s)(u=t[s])&&c.get(f[s])===u&&(r[s]=u)}function S(e){return e.__data__}function N(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function P(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function M(e){return function(){this.removeAttribute(e)}}function C(e){return function(){this.removeAttributeNS(e.space,e.local)}}function k(e,t){return function(){this.setAttribute(e,t)}}function A(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function B(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function $(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function I(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function D(e){return function(){this.style.removeProperty(e)}}function T(e,t,n){return function(){this.style.setProperty(e,t,n)}}function j(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function z(e,t){return e.style.getPropertyValue(t)||I(e).getComputedStyle(e,null).getPropertyValue(t)}function R(e){return function(){delete this[e]}}function O(e,t){return function(){this[e]=t}}function X(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function L(e){return e.trim().split(/^|\s+/)}function Y(e){return e.classList||new Z(e)}function Z(e){this._node=e,this._names=L(e.getAttribute("class")||"")}function V(e,t){for(var n=Y(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function U(e,t){for(var n=Y(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function q(e){return function(){V(this,e)}}function K(e){return function(){U(this,e)}}function W(e,t){return function(){(t.apply(this,arguments)?V:U)(this,e)}}function F(){this.textContent=""}function H(e){return function(){this.textContent=e}}function G(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function Q(){this.innerHTML=""}function J(e){return function(){this.innerHTML=e}}function ee(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function te(){this.nextSibling&&this.parentNode.appendChild(this)}function ne(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function oe(){return null}function re(){var e=this.parentNode;e&&e.removeChild(this)}function ie(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ae(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function se(e){return function(){var t=this.__on;if(t){for(var n,o=0,r=-1,i=t.length;o<i;++o)n=t[o],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function ue(e,t,n){return function(){var o,r=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===e.type&&o.name===e.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=t);this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function le(e,t,n){var o=I(e),r=o.CustomEvent;"function"==typeof r?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function ce(e,t){return function(){return le(this,e,t)}}function de(e,t){return function(){return le(this,e,t.apply(this,arguments))}}w.prototype={constructor:w,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},Z.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var he=[null];function fe(e,t){this._groups=e,this._parents=t}function ge(){return new fe([[document.documentElement]],he)}function pe(e){return"string"==typeof e?new fe([[document.querySelector(e)]],[document.documentElement]):new fe([[e]],he)}function me(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}fe.prototype=ge.prototype={constructor:fe,select:function(e){"function"!=typeof e&&(e=c(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=t[r],u=s.length,l=o[r]=new Array(u),d=0;d<u;++d)(i=s[d])&&(a=e.call(i,i.__data__,d,s))&&("__data__"in i&&(a.__data__=i.__data__),l[d]=a);return new fe(o,this._parents)},selectAll:function(e){e="function"==typeof e?f(e):h(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var a,s=t[i],u=s.length,l=0;l<u;++l)(a=s[l])&&(o.push(e.call(a,a.__data__,l,s)),r.push(a));return new fe(o,r)},selectChild:function(e){return this.select(null==e?y:function(e){return function(){return m.call(this.children,e)}}("function"==typeof e?e:p(e)))},selectChildren:function(e){return this.selectAll(null==e?x:function(e){return function(){return v.call(this.children,e)}}("function"==typeof e?e:p(e)))},filter:function(e){"function"!=typeof e&&(e=g(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,u=o[r]=[],l=0;l<s;++l)(i=a[l])&&e.call(i,i.__data__,l,a)&&u.push(i);return new fe(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,S);var n,o=t?E:_,r=this._parents,i=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var a=i.length,s=new Array(a),u=new Array(a),l=new Array(a),c=0;c<a;++c){var d=r[c],h=i[c],f=h.length,g=N(e.call(d,d&&d.__data__,c,r)),p=g.length,m=u[c]=new Array(p),y=s[c]=new Array(p);o(d,h,m,y,l[c]=new Array(f),g,t);for(var v,x,b=0,w=0;b<p;++b)if(v=m[b]){for(b>=w&&(w=b+1);!(x=y[w])&&++w<p;);v._next=x||null}}return(s=new fe(s,r))._enter=u,s._exit=l,s},enter:function(){return new fe(this._enter||this._groups.map(b),this._parents)},exit:function(){return new fe(this._exit||this._groups.map(b),this._parents)},join:function(e,t,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof e?(o=e(o))&&(o=o.selection()):o=o.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),u=0;u<a;++u)for(var l,c=n[u],d=o[u],h=c.length,f=s[u]=new Array(h),g=0;g<h;++g)(l=c[g]||d[g])&&(f[g]=l);for(;u<r;++u)s[u]=n[u];return new fe(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o,r=e[t],i=r.length-1,a=r[i];--i>=0;)(o=r[i])&&(a&&4^o.compareDocumentPosition(a)&&a.parentNode.insertBefore(o,a),a=o);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=P);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var a,s=n[i],u=s.length,l=r[i]=new Array(u),c=0;c<u;++c)(a=s[c])&&(l[c]=a);l.sort(t)}return new fe(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r,i=t[n],a=0,s=i.length;a<s;++a)(r=i[a])&&e.call(r,r.__data__,a,i);return this},attr:function(e,t){var n=i(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==t?n.local?C:M:"function"==typeof t?n.local?$:B:n.local?A:k)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?D:"function"==typeof t?j:T)(e,t,null==n?"":n)):z(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?R:"function"==typeof t?X:O)(e,t)):this.node()[e]},classed:function(e,t){var n=L(e+"");if(arguments.length<2){for(var o=Y(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?W:t?q:K)(n,t))},text:function(e){return arguments.length?this.each(null==e?F:("function"==typeof e?G:H)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?Q:("function"==typeof e?ee:J)(e)):this.node().innerHTML},raise:function(){return this.each(te)},lower:function(){return this.each(ne)},append:function(e){var t="function"==typeof e?e:u(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:u(e),o=null==t?oe:"function"==typeof t?t:c(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(re)},clone:function(e){return this.select(e?ae:ie)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var o,r,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=i.length;if(!(arguments.length<2)){for(s=t?ue:se,o=0;o<a;++o)this.each(s(i[o],t,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(o=0,u=s[l];o<a;++o)if((r=i[o]).type===u.type&&r.name===u.name)return u.value},dispatch:function(e,t){return this.each(("function"==typeof t?de:ce)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o,r=e[t],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};var ye={value:()=>{}};function ve(){for(var e,t=0,n=arguments.length,o={};t<n;++t){if(!(e=arguments[t]+"")||e in o||/[\s.]/.test(e))throw new Error("illegal type: "+e);o[e]=[]}return new xe(o)}function xe(e){this._=e}function be(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function we(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=ye,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}xe.prototype=ve.prototype={constructor:xe,on:function(e,t){var n,o,r=this._,i=(o=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!o.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<s;)if(n=(e=i[a]).type)r[n]=we(r[n],e.name,t);else if(null==t)for(n in r)r[n]=we(r[n],e.name,null);return this}for(;++a<s;)if((n=(e=i[a]).type)&&(n=be(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new xe(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(o=this._[e]).length;i<n;++i)o[i].value.apply(t,r)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};const _e={passive:!1},Ee={capture:!0,passive:!1};function Se(e){e.stopImmediatePropagation()}function Ne(e){e.preventDefault(),e.stopImmediatePropagation()}function Pe(e){var t=e.document.documentElement,n=pe(e).on("dragstart.drag",Ne,Ee);"onselectstart"in t?n.on("selectstart.drag",Ne,Ee):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Me(e,t){var n=e.document.documentElement,o=pe(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ne,Ee),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Ce=e=>()=>e;function ke(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:u,dy:l,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}function Ae(e){return!e.ctrlKey&&!e.button}function Be(){return this.parentNode}function $e(e,t){return null==t?{x:e.x,y:e.y}:t}function Ie(){return navigator.maxTouchPoints||"ontouchstart"in this}function De(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Te(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function je(){}ke.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var ze=.7,Re=1/ze,Oe="\\s*([+-]?\\d+)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Le="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ye=/^#([0-9a-f]{3,8})$/,Ze=new RegExp(`^rgb\\(${Oe},${Oe},${Oe}\\)$`),Ve=new RegExp(`^rgb\\(${Le},${Le},${Le}\\)$`),Ue=new RegExp(`^rgba\\(${Oe},${Oe},${Oe},${Xe}\\)$`),qe=new RegExp(`^rgba\\(${Le},${Le},${Le},${Xe}\\)$`),Ke=new RegExp(`^hsl\\(${Xe},${Le},${Le}\\)$`),We=new RegExp(`^hsla\\(${Xe},${Le},${Le},${Xe}\\)$`),Fe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function He(){return this.rgb().formatHex()}function Ge(){return this.rgb().formatRgb()}function Qe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ye.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?Je(t):3===n?new nt(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?et(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?et(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Ze.exec(e))?new nt(t[1],t[2],t[3],1):(t=Ve.exec(e))?new nt(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ue.exec(e))?et(t[1],t[2],t[3],t[4]):(t=qe.exec(e))?et(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Ke.exec(e))?ut(t[1],t[2]/100,t[3]/100,1):(t=We.exec(e))?ut(t[1],t[2]/100,t[3]/100,t[4]):Fe.hasOwnProperty(e)?Je(Fe[e]):"transparent"===e?new nt(NaN,NaN,NaN,0):null}function Je(e){return new nt(e>>16&255,e>>8&255,255&e,1)}function et(e,t,n,o){return o<=0&&(e=t=n=NaN),new nt(e,t,n,o)}function tt(e,t,n,o){return 1===arguments.length?((r=e)instanceof je||(r=Qe(r)),r?new nt((r=r.rgb()).r,r.g,r.b,r.opacity):new nt):new nt(e,t,n,null==o?1:o);var r}function nt(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function ot(){return`#${st(this.r)}${st(this.g)}${st(this.b)}`}function rt(){const e=it(this.opacity);return`${1===e?"rgb(":"rgba("}${at(this.r)}, ${at(this.g)}, ${at(this.b)}${1===e?")":`, ${e})`}`}function it(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function at(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function st(e){return((e=at(e))<16?"0":"")+e.toString(16)}function ut(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,n,o)}function lt(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof je||(e=Qe(e)),!e)return new ct;if(e instanceof ct)return e;var t=(e=e.rgb()).r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),a=NaN,s=i-r,u=(i+r)/2;return s?(a=t===i?(n-o)/s+6*(n<o):n===i?(o-t)/s+2:(t-n)/s+4,s/=u<.5?i+r:2-i-r,a*=60):s=u>0&&u<1?0:a,new ct(a,s,u,e.opacity)}function ct(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function dt(e){return(e=(e||0)%360)<0?e+360:e}function ht(e){return Math.max(0,Math.min(1,e||0))}function ft(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}De(je,Qe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:He,formatHex:He,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return lt(this).formatHsl()},formatRgb:Ge,toString:Ge}),De(nt,tt,Te(je,{brighter(e){return e=null==e?Re:Math.pow(Re,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?ze:Math.pow(ze,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nt(at(this.r),at(this.g),at(this.b),it(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ot,formatHex:ot,formatHex8:function(){return`#${st(this.r)}${st(this.g)}${st(this.b)}${st(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:rt,toString:rt})),De(ct,(function(e,t,n,o){return 1===arguments.length?lt(e):new ct(e,t,n,null==o?1:o)}),Te(je,{brighter(e){return e=null==e?Re:Math.pow(Re,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?ze:Math.pow(ze,e),new ct(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new nt(ft(e>=240?e-240:e+120,r,o),ft(e,r,o),ft(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new ct(dt(this.h),ht(this.s),ht(this.l),it(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=it(this.opacity);return`${1===e?"hsl(":"hsla("}${dt(this.h)}, ${100*ht(this.s)}%, ${100*ht(this.l)}%${1===e?")":`, ${e})`}`}}));var gt=e=>()=>e;function pt(e){return 1==(e=+e)?mt:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}(t,n,e):gt(isNaN(t)?n:t)}}function mt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):gt(isNaN(e)?t:e)}var yt=function e(t){var n=pt(t);function o(e,t){var o=n((e=tt(e)).r,(t=tt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),a=mt(e.opacity,t.opacity);return function(t){return e.r=o(t),e.g=r(t),e.b=i(t),e.opacity=a(t),e+""}}return o.gamma=e,o}(1);function vt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var xt=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,bt=new RegExp(xt.source,"g");function wt(e,t){var n,o,r,i=xt.lastIndex=bt.lastIndex=0,a=-1,s=[],u=[];for(e+="",t+="";(n=xt.exec(e))&&(o=bt.exec(t));)(r=o.index)>i&&(r=t.slice(i,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,u.push({i:a,x:vt(n,o)})),i=bt.lastIndex;return i<t.length&&(r=t.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?u[0]?function(e){return function(t){return e(t)+""}}(u[0].x):function(e){return function(){return e}}(t):(t=u.length,function(e){for(var n,o=0;o<t;++o)s[(n=u[o]).i]=n.x(e);return s.join("")})}var _t,Et=180/Math.PI,St={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Nt(e,t,n,o,r,i){var a,s,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*o)&&(n-=e*u,o-=t*u),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,u/=s),e*o<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Et,skewX:Math.atan(u)*Et,scaleX:a,scaleY:s}}function Pt(e,t,n,o){function r(e){return e.length?e.pop()+" ":""}return function(i,a){var s=[],u=[];return i=e(i),a=e(a),function(e,o,r,i,a,s){if(e!==r||o!==i){var u=a.push("translate(",null,t,null,n);s.push({i:u-4,x:vt(e,r)},{i:u-2,x:vt(o,i)})}else(r||i)&&a.push("translate("+r+t+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,u),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:vt(e,t)})):t&&n.push(r(n)+"rotate("+t+o)}(i.rotate,a.rotate,s,u),function(e,t,n,i){e!==t?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:vt(e,t)}):t&&n.push(r(n)+"skewX("+t+o)}(i.skewX,a.skewX,s,u),function(e,t,n,o,i,a){if(e!==n||t!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:vt(e,n)},{i:s-2,x:vt(t,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,u),i=a=null,function(e){for(var t,n=-1,o=u.length;++n<o;)s[(t=u[n]).i]=t.x(e);return s.join("")}}}var Mt=Pt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?St:Nt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Ct=Pt((function(e){return null==e?St:(_t||(_t=document.createElementNS("http://www.w3.org/2000/svg","g")),_t.setAttribute("transform",e),(e=_t.transform.baseVal.consolidate())?Nt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):St)}),", ",")",")");function kt(e){return((e=Math.exp(e))+1/e)/2}var At,Bt,$t=function e(t,n,o){function r(e,r){var i,a,s=e[0],u=e[1],l=e[2],c=r[0],d=r[1],h=r[2],f=c-s,g=d-u,p=f*f+g*g;if(p<1e-12)a=Math.log(h/l)/t,i=function(e){return[s+e*f,u+e*g,l*Math.exp(t*e*a)]};else{var m=Math.sqrt(p),y=(h*h-l*l+o*p)/(2*l*n*m),v=(h*h-l*l-o*p)/(2*h*n*m),x=Math.log(Math.sqrt(y*y+1)-y),b=Math.log(Math.sqrt(v*v+1)-v);a=(b-x)/t,i=function(e){var o,r=e*a,i=kt(x),c=l/(n*m)*(i*(o=t*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(e){return((e=Math.exp(e))-1/e)/2}(x));return[s+c*f,u+c*g,l*i/kt(t*r+x)]}}return i.duration=1e3*a*t/Math.SQRT2,i}return r.rho=function(t){var n=Math.max(.001,+t),o=n*n;return e(n,o,o*o)},r}(Math.SQRT2,2,4),It=0,Dt=0,Tt=0,jt=1e3,zt=0,Rt=0,Ot=0,Xt="object"==typeof performance&&performance.now?performance:Date,Lt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yt(){return Rt||(Lt(Zt),Rt=Xt.now()+Ot)}function Zt(){Rt=0}function Vt(){this._call=this._time=this._next=null}function Ut(e,t,n){var o=new Vt;return o.restart(e,t,n),o}function qt(){Rt=(zt=Xt.now())+Ot,It=Dt=0;try{!function(){Yt(),++It;for(var e,t=At;t;)(e=Rt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--It}()}finally{It=0,function(){var e,t,n=At,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:At=t);Bt=e,Wt(o)}(),Rt=0}}function Kt(){var e=Xt.now(),t=e-zt;t>jt&&(Ot-=t,zt=e)}function Wt(e){It||(Dt&&(Dt=clearTimeout(Dt)),e-Rt>24?(e<1/0&&(Dt=setTimeout(qt,e-Xt.now()-Ot)),Tt&&(Tt=clearInterval(Tt))):(Tt||(zt=Xt.now(),Tt=setInterval(Kt,jt)),It=1,Lt(qt)))}function Ft(e,t,n){var o=new Vt;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}Vt.prototype=Ut.prototype={constructor:Vt,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Yt():+n)+(null==t?0:+t),this._next||Bt===this||(Bt?Bt._next=this:At=this,Bt=this),this._call=e,this._time=n,Wt()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wt())}};var Ht=ve("start","end","cancel","interrupt"),Gt=[],Qt=0,Jt=1,en=2,tn=3,nn=4,on=5,rn=6;function an(e,t,n,o,r,i){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var o,r=e.__transition;function i(e){n.state=Jt,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var l,c,d,h;if(n.state!==Jt)return u();for(l in r)if((h=r[l]).name===n.name){if(h.state===tn)return Ft(a);h.state===nn?(h.state=rn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[l]):+l<t&&(h.state=rn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[l])}if(Ft((function(){n.state===tn&&(n.state=nn,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=en,n.on.call("start",e,e.__data__,n.index,n.group),n.state===en){for(n.state=tn,o=new Array(d=n.tween.length),l=0,c=-1;l<d;++l)(h=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(o[++c]=h);o.length=c+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(u),n.state=on,1),i=-1,a=o.length;++i<a;)o[i].call(e,r);n.state===on&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){for(var o in n.state=rn,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Ut(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:Ht,tween:Gt,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Qt})}function sn(e,t){var n=ln(e,t);if(n.state>Qt)throw new Error("too late; already scheduled");return n}function un(e,t){var n=ln(e,t);if(n.state>tn)throw new Error("too late; already running");return n}function ln(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function cn(e,t){var n,o,r,i=e.__transition,a=!0;if(i){for(r in t=null==t?null:t+"",i)(n=i[r]).name===t?(o=n.state>en&&n.state<on,n.state=rn,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete e.__transition}}function dn(e,t){var n,o;return function(){var r=un(this,e),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a<s;++a)if(o[a].name===t){(o=o.slice()).splice(a,1);break}r.tween=o}}function hn(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=un(this,e),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:t,value:n},u=0,l=r.length;u<l;++u)if(r[u].name===t){r[u]=s;break}u===l&&r.push(s)}i.tween=r}}function fn(e,t,n){var o=e._id;return e.each((function(){var e=un(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return ln(e,o).value[t]}}function gn(e,t){var n;return("number"==typeof t?vt:t instanceof Qe?yt:(n=Qe(t))?(t=n,yt):wt)(e,t)}function pn(e){return function(){this.removeAttribute(e)}}function mn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttribute(e);return a===i?null:a===o?r:r=t(o=a,n)}}function vn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===o?r:r=t(o=a,n)}}function xn(e,t,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttribute(e))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,u));this.removeAttribute(e)}}function bn(e,t,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttributeNS(e.space,e.local))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,u));this.removeAttributeNS(e.space,e.local)}}function wn(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function _n(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function En(e,t){return function(){sn(this,e).delay=+t.apply(this,arguments)}}function Sn(e,t){return t=+t,function(){sn(this,e).delay=t}}function Nn(e,t){return function(){un(this,e).duration=+t.apply(this,arguments)}}function Pn(e,t){return t=+t,function(){un(this,e).duration=t}}var Mn=ge.prototype.constructor;function Cn(e){return function(){this.style.removeProperty(e)}}var kn=0;function An(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Bn(){return++kn}var $n=ge.prototype;An.prototype={constructor:An,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=c(e));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,u,l=o[a],d=l.length,h=i[a]=new Array(d),f=0;f<d;++f)(s=l[f])&&(u=e.call(s,s.__data__,f,l))&&("__data__"in s&&(u.__data__=s.__data__),h[f]=u,an(h[f],t,n,f,h,ln(s,n)));return new An(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=h(e));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var u,l=o[s],c=l.length,d=0;d<c;++d)if(u=l[d]){for(var f,g=e.call(u,u.__data__,d,l),p=ln(u,n),m=0,y=g.length;m<y;++m)(f=g[m])&&an(f,t,n,m,g,p);i.push(g),a.push(u)}return new An(i,a,t,n)},selectChild:$n.selectChild,selectChildren:$n.selectChildren,filter:function(e){"function"!=typeof e&&(e=g(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,u=o[r]=[],l=0;l<s;++l)(i=a[l])&&e.call(i,i.__data__,l,a)&&u.push(i);return new An(o,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),a=new Array(o),s=0;s<i;++s)for(var u,l=t[s],c=n[s],d=l.length,h=a[s]=new Array(d),f=0;f<d;++f)(u=l[f]||c[f])&&(h[f]=u);for(;s<o;++s)a[s]=t[s];return new An(a,this._parents,this._name,this._id)},selection:function(){return new Mn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Bn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,l=0;l<u;++l)if(a=s[l]){var c=ln(a,t);an(a,e,n,l,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new An(o,this._parents,e,n)},call:$n.call,nodes:$n.nodes,node:$n.node,size:$n.size,empty:$n.empty,each:$n.each,on:function(e,t){var n=this._id;return arguments.length<2?ln(this.node(),n).on.on(e):this.each(function(e,t,n){var o,r,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?sn:un;return function(){var a=i(this,e),s=a.on;s!==o&&(r=(o=s).copy()).on(t,n),a.on=r}}(n,e,t))},attr:function(e,t){var n=i(e),o="transform"===n?Ct:gn;return this.attrTween(e,"function"==typeof t?(n.local?bn:xn)(n,o,fn(this,"attr."+e,t)):null==t?(n.local?mn:pn)(n):(n.local?vn:yn)(n,o,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var o=i(e);return this.tween(n,(o.local?wn:_n)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?Mt:gn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=z(this,e),a=(this.style.removeProperty(e),z(this,e));return i===a?null:i===n&&a===o?r:r=t(n=i,o=a)}}(e,o)).on("end.style."+e,Cn(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var a=z(this,e),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(e),u=s=z(this,e)),a===u?null:a===o&&u===r?i:(r=u,i=t(o=a,s))}}(e,o,fn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,a="style."+t,s="end."+a;return function(){var u=un(this,e),l=u.on,c=null==u.value[a]?i||(i=Cn(t)):void 0;l===n&&r===c||(o=(n=l).copy()).on(s,r=c),u.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var a=z(this,e);return a===i?null:a===o?r:r=t(o=a,n)}}(e,o,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==t)return this.tween(o,null);if("function"!=typeof t)throw new Error;return this.tween(o,function(e,t,n){var o,r;function i(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&function(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}(e,i,n)),o}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(fn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function o(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&function(e){return function(t){this.textContent=e.call(this,t)}}(o)),t}return o._value=e,o}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o,r=ln(this.node(),n).tween,i=0,a=r.length;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((null==t?dn:hn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?En:Sn)(t,e)):ln(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Nn:Pn)(t,e)):ln(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){un(this,e).ease=t}}(t,e)):ln(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;un(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,o=n._id,r=n.size();return new Promise((function(i,a){var s={value:a},u={value:function(){0==--r&&i()}};n.each((function(){var n=un(this,o),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(u)),n.on=t})),0===r&&i()}))},[Symbol.iterator]:$n[Symbol.iterator]};var In={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function Dn(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}ge.prototype.interrupt=function(e){return this.each((function(){cn(this,e)}))},ge.prototype.transition=function(e){var t,n;e instanceof An?(t=e._id,e=e._name):(t=Bn(),(n=In).time=Yt(),e=null==e?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,l=0;l<u;++l)(a=s[l])&&an(a,e,t,l,s,n||Dn(a,t));return new An(o,this._parents,e,t)};var Tn=e=>()=>e;function jn(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function zn(e,t,n){this.k=e,this.x=t,this.y=n}zn.prototype={constructor:zn,scale:function(e){return 1===e?this:new zn(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new zn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Rn,On=new zn(1,0,0);function Xn(e){for(;!e.__zoom;)if(!(e=e.parentNode))return On;return e.__zoom}function Ln(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function Zn(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Vn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function Un(){return this.__zoom||On}function qn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wn(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}Xn.prototype=zn.prototype,e.Position=void 0,(Rn=e.Position||(e.Position={})).Left="left",Rn.Top="top",Rn.Right="right",Rn.Bottom="bottom";const Fn="internals";e.MarkerType=void 0,(e.MarkerType||(e.MarkerType={})).Arrow="arrow";const Hn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Gn=(e,t,n,o)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const i=Array.from(r),a=t.getBoundingClientRect(),s=a.width*o[0],u=a.height*o[1];return i.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-portid"),position:e.dataset.portPosition,x:(t.left-a.left-s)/n,y:(t.top-a.top-u)/n,...Hn(e)}}))},Qn=e=>"clientX"in e,Jn=(e,t)=>{const n=Qn(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},eo=({x:e,y:t},[n,o,r])=>({x:(e-n)/r,y:(t-o)/r}),to=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),no=(e,{transform:t,gridStep:n,centerStep:o})=>{const{x:r,y:i}=Jn(e),a=eo({x:r,y:i},t);return{getStepPosition:(e={position:a})=>{const{position:t,nodeSize:r}=e;if(!n)return t;let i=n[0]*Math.round(t.x/n[0]),s=n[1]*Math.round(t.y/n[1]);if(o&&r){const e=(n[0]-r.width)/2,o=(n[1]-r.height)/2,a=t.x-e,u=t.y-o;i=n[0]*Math.round(a/n[0])+e,s=n[1]*Math.round(u/n[1])+o}return{x:i,y:s}},...a}},oo={"001":()=>"Seems like you have not used zustand provider as an ancestor","002":()=>"It looks like you`ve created a new nodeTypes or edgeTypes object. If this wasn`t on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.","010":e=>`Node type "${e}" not found. Using fallback type "default".`,"011":()=>"Only child nodes can use a parent extent","020":()=>"Can`t create edge. An edge needs a source and a target.","021":e=>`The old edge with id=${e} does not exist.`,"022":e=>`Marker type "${e}" doesn't exist.`},ro=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),io=(e,t,n,o)=>{const r=t-n;return e<n?ro(Math.abs(e-n),1,50)/50*o:e>r?-ro(Math.abs(e-r),1,50)/50*o:0},ao=(e,t)=>[io(e.x,t.width,30,10),io(e.y,t.height,30,10)],so=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),uo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),lo=e=>!isNaN(e)&&isFinite(e),co=(e={x:0,y:0},t)=>({x:ro(e.x,t[0][0],t[1][0]),y:ro(e.y,t[0][1],t[1][1])}),ho=e=>"source"in e&&"target"in e,fo=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-o};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:r}},go=(e,t,[n,o,r]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const u={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},l=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(a&&!o||r)return!1;const{positionAbsolute:c}=fo(e,s),d={x:c.x,y:c.y,width:t||0,height:n||0},h=((e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)})(u,d);(void 0===t||void 0===n||null===t||null===n||i&&h>0||h>=(t||0)*(n||0)||e.dragging)&&l.push(e)})),l},po=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const{x:o,y:r}=fo(n,t).positionAbsolute,i=so({x:o,y:r,width:n.width||0,height:n.height||0});return a=e,s=i,{x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),x2:Math.max(a.x2,s.x2),y2:Math.max(a.y2,s.y2)};var a,s}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uo(n)};function mo(e,t){const{nodes:n,edges:o}=e,{nodes:r,edges:i}=t,a=[],s=new Set(n?.map((e=>e.id)));for(const e of r){if(!1===e.deletable)continue;const t=s.has(e.id),n=!t&&e.parentNode&&a.find((t=>t.id===e.parentNode));(t||n)&&a.push(e)}const u=i.filter((e=>!1!==e.deletable)),l=function(e,t){const n=new Set;return e.forEach((e=>{n.add(e.id)})),t.filter((e=>n.has(e.source)||n.has(e.target)))}(a,i),c=l,d=new Set(o?.map((e=>e.id)));for(const e of u){const t=c.some((t=>t.id===e.id)),n=d.has(e.id);(o?n&&!t:!t)&&c.push(e)}return{nodes:a,edges:c}}const yo=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},vo=({sourceX:e,sourceY:t,targetX:n,targetY:o})=>{const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,a=Math.abs(o-t)/2;return[i,o<t?o+a:o-a,r,a]},xo=({source:e,sourcePort:t,target:n,targetPort:o})=>`react-diagram__edge-${e}${t}-${n}${o}`,bo={[e.Position.Left]:{x:-1,y:0},[e.Position.Right]:{x:1,y:0},[e.Position.Top]:{x:0,y:-1},[e.Position.Bottom]:{x:0,y:1}},wo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),_o=({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:a,stepPosition:s})=>{const u=bo[n],l=bo[r],c={x:t.x+u.x*a,y:t.y+u.y*a},d={x:o.x+l.x*a,y:o.y+l.y*a},h=(({source:t,sourcePosition:n=e.Position.Bottom,target:o})=>n===e.Position.Left||n===e.Position.Right?t.x<o.x?{x:1,y:0}:{x:-1,y:0}:t.y<o.y?{x:0,y:1}:{x:0,y:-1})({source:c,sourcePosition:n,target:d}),f=0!==h.x?"x":"y",g=h[f];let p,m,y=[];const v={x:0,y:0},x={x:0,y:0},[,,b,w]=vo({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(u[f]*l[f]==-1){"x"===f?(p=i.x??c.x+(d.x-c.x)*s,m=i.y??(c.y+d.y)/2):(p=i.x??(c.x+d.x)/2,m=i.y??c.y+(d.y-c.y)*s);const e=[{x:p,y:c.y},{x:p,y:d.y}],t=[{x:c.x,y:m},{x:d.x,y:m}];y=u[f]===g?"x"===f?e:t:"x"===f?t:e}else{const e=[{x:c.x,y:d.y}],i=[{x:d.x,y:c.y}];if(y="x"===f?u.x===g?i:e:u.y===g?e:i,n===r){const e=Math.abs(t[f]-o[f]);if(e<=a){const n=Math.min(a-1,a-e);u[f]===g?v[f]=(c[f]>t[f]?-1:1)*n:x[f]=(d[f]>o[f]?-1:1)*n}}if(n!==r){const t="x"===f?"y":"x",n=u[f]===l[t],o=c[t]>d[t],r=c[t]<d[t];(1===u[f]&&(!n&&o||n&&r)||1!==u[f]&&(!n&&r||n&&o))&&(y="x"===f?e:i)}const s={x:c.x+v.x,y:c.y+v.y},h={x:d.x+x.x,y:d.y+x.y};Math.max(Math.abs(s.x-y[0].x),Math.abs(h.x-y[0].x))>=Math.max(Math.abs(s.y-y[0].y),Math.abs(h.y-y[0].y))?(p=(s.x+h.x)/2,m=y[0].y):(p=y[0].x,m=(s.y+h.y)/2)}return[[t,{x:c.x+v.x,y:c.y+v.y},...y,{x:d.x+x.x,y:d.y+x.y},o],p,m,b,w]};function Eo({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,borderRadius:s=5,centerX:u,centerY:l,offset:c=20,stepPosition:d=.5}){const[h,f,g,p,m]=_o({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:u,y:l},offset:c,stepPosition:d});return[h.reduce(((e,t,n)=>{let o="";return o=n>0&&n<h.length-1?((e,t,n,o)=>{const r=Math.min(wo(e,t)/2,wo(t,n)/2,o),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a)return`L ${i+r*(e.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+r*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${i},${a+r*(e.y<n.y?-1:1)}Q ${i},${a} ${i+r*s},${a}`})(h[n-1],t,h[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),f,g,p,m]}const So=({sourceX:e,sourceY:t,targetX:n,targetY:o})=>{const[r,i,a,s]=vo({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,a,s]},No=({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s})=>{const u=.125,l=.375,c=e*u+r*l+a*l+n*u,d=t*u+i*l+s*l+o*u;return[c,d,Math.abs(c-e),Math.abs(d-t)]},Po=(e,t)=>e>=0?.5*e:25*t*Math.sqrt(-e),Mo=({pos:t,x1:n,y1:o,x2:r,y2:i,c:a})=>{switch(t){case e.Position.Left:return[n-Po(n-r,a),o];case e.Position.Right:return[n+Po(r-n,a),o];case e.Position.Top:return[n,o-Po(o-i,a)];case e.Position.Bottom:return[n,o+Po(i-o,a)]}},Co=({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,curvature:s=.25})=>{const[u,l]=Mo({pos:o,x1:t,y1:n,x2:r,y2:i,c:s}),[c,d]=Mo({pos:a,x1:r,y1:i,x2:t,y2:n,c:s}),[h,f,g,p]=No({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:u,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${t},${n} C${u},${l} ${c},${d} ${r},${i}`,h,f,g,p]};function ko(e,t,n,o){if(!e.parentNode)return n;const r=t.get(e.parentNode),i=fo(r,o);return ko(r,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r[Fn]?.z??0)>(n.z??0)?r[Fn]?.z??0:n.z??0},o)}function Ao(e,t,n){e.forEach((o=>{if(o.parentNode&&!e.has(o.parentNode))throw new Error(`Parent node ${o.parentNode} not found`);if(o.parentNode||n?.[o.id]){const{x:r,y:i,z:a}=ko(o,e,{...o.position,z:o[Fn]?.z??0},t);o.positionAbsolute={x:r,y:i},o[Fn].z=a,n?.[o.id]&&(o[Fn].isParent=!0)}}))}function Bo(e,t,n,o){const r=new Map,i={},a=o?1e3:0;return e.forEach((e=>{const n=(lo(e.zIndex)?e.zIndex:0)+(e.selected?a:0),o=t.get(e.id),s={width:o?.width,height:o?.height,...e,positionAbsolute:{x:e.position.x,y:e.position.y}};e.parentNode&&(s.parentNode=e.parentNode,i[e.parentNode]=!0),Object.defineProperty(s,Fn,{enumerable:!1,value:{portBounds:o?.[Fn]?.portBounds,z:n}}),r.set(e.id,s)})),Ao(r,n,i),r}function $o(e,t){const{id:n,width:o,height:r,positionAbsolute:i}=e;if(!o||!r)return!1;let a=!1;for(const[e,s]of t){if(n===e)continue;const{positionAbsolute:t,width:u,height:l}=s;if(!u||!l)continue;if(!t||!i)continue;const c=t.x+u>=i.x,d=i.x+o>=t.x,h=t.y+l>=i.y,f=i.y+r>=t.y;if(c&&d&&h&&f){a=!0;break}}return a}const Io=(e,t,n,o)=>(t[n]||[]).reduce(((t,r)=>(`${e.id}-${r.id}-${n}`!==o&&t.push({portId:r.id||null,portType:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+r.x+r.width/2,y:(e.positionAbsolute?.y??0)+r.y+r.height/2}),t)),[]),Do=e=>e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null;let To=null;const jo=({isAnchor:e=!1,event:t,nodeId:n,portId:o,portType:r,domNode:i,autoPanOnConnect:a,connectionRadius:s,nodes:u,getTransform:l,cancelConnection:c,onConnectStart:d,onConnect:h,onConnectEnd:f,onEdgeUpdateEnd:g,panBy:p,updateConnection:m})=>{const y=(v=t.target,v.getRootNode?.()||window?.document);var v;const x=i?.getBoundingClientRect(),{x:b,y:w}=Jn(t),_=y?.elementFromPoint(b,w),E=e?r:Do(_),S=(({nodes:e,nodeId:t,portId:n,portType:o})=>e.reduce(((e,r)=>{if(r[Fn]){const{portBounds:i}=r[Fn];let a=[],s=[];i&&(a=Io(r,i,"source",`${t}-${n}-${o}`),s=Io(r,i,"target",`${t}-${n}-${o}`)),e.push(...a,...s)}return e}),[]))({nodes:u,nodeId:n,portId:o,portType:r});let N=Jn(t,x),P=null,M=!1,C=null,k=0,A=!1;if(!x||!r)return;const B=()=>{if(!a)return;const[e,t]=ao(N,x);p({x:e,y:t}),k=requestAnimationFrame(B)};To={nodeId:n,portId:o,portType:E},m({connectionPosition:N,connectionStartPort:To,connectionEndPort:null}),d?.(t,{nodeId:n,portId:o,portType:r});const $=e=>{const t=l();N=Jn(e,x),P=((e,t,n)=>{let o=null,r=1/0;return n.forEach((n=>{const i=Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));i<=t&&i<r&&(r=i,o=n)})),o})(eo(N,t),s,S),A||(B(),A=!0);const i=((e,t,n,o,r,i)=>{const a="target"===r,s={isValid:!1,connection:null,endPort:null},u=i.querySelector(`.react-diagram__port[data-id="${t?.nodeId}-${t?.portId}-${t?.portType}"]`),{x:l,y:c}=Jn(e),d=i.elementFromPoint(l,c),h=d?.classList.contains("react-diagram__port")?d:u;if(h){const e=Do(h),r=h.getAttribute("data-nodeid"),i=h.getAttribute("data-portid"),u={source:a?r:n,target:a?n:r,sourcePort:a?t?.portId||null:o,targetPort:a?o:t?.portId||null};s.connection=u,(a&&"source"===e||!a&&"target"===e)&&(s.isValid=!0,s.endPort={nodeId:r,portId:i,portType:e})}return s})(e,P,n,o,r,y);M=i.isValid,C=i.connection,m({connectionPosition:P&&M?to(P,t):N,connectionStartPort:To,connectionEndPort:i.endPort})},I=e=>{M&&C&&h?.(C),f?.(e),r&&g?.(e),c(),cancelAnimationFrame(k),M=!1,C=null,A=!1,y.removeEventListener("mousemove",$),y.removeEventListener("mouseup",I),y.removeEventListener("touchmove",$),y.removeEventListener("touchend",I)};y.addEventListener("mousemove",$),y.addEventListener("mouseup",I),y.addEventListener("touchmove",$),y.addEventListener("touchend",I)},zo=(e,t)=>{if(!e.parentNode)return!1;const n=t.get(e.parentNode);return!!n&&(!!n.selected||zo(n,t))},Ro=(e,t)=>e.x!==t.x||e.y!==t.y,Oo=({nodeId:e,dragItems:t,nodeInternals:n})=>{const o=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?o.find((t=>t.id===e)):o[0],o]},Xo=({getStore:e,onNodeMouseDown:t,onDragStart:n,onDrag:o,onDragEnd:r})=>{let i=[],a=null,s={x:0,y:0},u={x:0,y:0},l=null,c=!1,d=0,h=null;return{update:({domNode:f,nodeId:g,noDragClassName:p})=>{const m=(t,n=!1)=>o=>{if(!("distance"in o))return;const{nodeInternals:r,nodeExtent:i,nodeOrigin:a,smoothStep:s,gridStep:u}=e(),{distance:l,width:c,height:d}=o,{x:h,y:f,getStepPosition:g}=t;let p={x:h-l.x,y:f-l.y};if(u&&g){const e=g({position:p,nodeSize:{width:c,height:d}});(!s||s&&n)&&(p=e)}const m=((e,t,n,o,r=[0,0])=>{let i=e.extent||o;if(e.extent&&e.parentNode){const t=n.get(e.parentNode),{x:o,y:a}=fo(t,r).positionAbsolute;i=[[e.extent[0][0]+o,e.extent[0][1]+a],[e.extent[1][0]+o,e.extent[1][1]+a]]}let a={x:0,y:0};if(e.parentNode){const t=n.get(e.parentNode);a=fo(t,r).positionAbsolute}const s=i?co(t,i):t;return{position:{x:s.x-a.x,y:s.y-a.y},positionAbsolute:s}})(o,p,r,i,a);Ro(o.position,m.position)&&(o.position=m.position,o.positionAbsolute=m.positionAbsolute)};h=pe(f);const y=t=>{const{nodeInternals:n,updateNodesPosition:r}=e(),{x:a,y:s}=t;if(u={x:a,y:s},r(i,!0,m(t)),o&&l){const[e,t]=Oo({nodeId:g,dragItems:i,nodeInternals:n});o(l,i,e,t)}},v=()=>{if(!a)return;const[t,n]=ao(s,a);if(0!==t||0!==n){const{transform:o,panBy:r}=e();u.x-=t/o[2],u.y-=n/o[2],y(u),r({x:t,y:n})}d=requestAnimationFrame(v)},x=o=>{const{nodeInternals:r,nodesDraggable:u,domNode:l,transform:c,gridStep:d,centerStep:h}=e();g&&t?.(g);const f=no(o.sourceEvent,{transform:c,gridStep:d,centerStep:h});if(i=((e,t,n,o)=>Array.from(e.values()).filter((n=>{const r=n.width&&n.height,i=n.selected||n.id===o,a=!n.parentNode||!zo(n,e),s=n.draggable||t&&void 0===n.draggable;return r&&i&&a&&s})).map((e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-(e.positionAbsolute?.x??0),y:n.y-(e.positionAbsolute?.y??0)},extent:e.extent,parentNode:e.parentNode,width:e.width||0,height:e.height||0}))))(r,u,f,g),n&&i){const[e,t]=Oo({nodeId:g,dragItems:i,nodeInternals:r});n?.(o.sourceEvent,i,e,t)}a=l?.getBoundingClientRect()||null,s=Jn(o.sourceEvent,a)},b=function(){var e,t,n,o,r=Ae,i=Be,a=$e,s=Ie,u={},l=ve("start","drag","end"),c=0,d=0;function h(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,_e).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(a,s){if(!o&&r.call(this,a,s)){var u=x(this,i.call(this,a,s),a,s,"mouse");u&&(pe(a.view).on("mousemove.drag",g,Ee).on("mouseup.drag",p,Ee),Pe(a.view),Se(a),n=!1,e=a.clientX,t=a.clientY,u("start",a))}}function g(o){if(Ne(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>d}u.mouse("drag",o)}function p(e){pe(e.view).on("mousemove.drag mouseup.drag",null),Me(e.view,n),Ne(e),u.mouse("end",e)}function m(e,t){if(r.call(this,e,t)){var n,o,a=e.changedTouches,s=i.call(this,e,t),u=a.length;for(n=0;n<u;++n)(o=x(this,s,e,t,a[n].identifier,a[n]))&&(Se(e),o("start",e,a[n]))}}function y(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=u[o[t].identifier])&&(Ne(e),n("drag",e,o[t]))}function v(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<i;++t)(n=u[r[t].identifier])&&(Se(e),n("end",e,r[t]))}function x(e,t,n,o,r,i){var s,d,f,g=l.copy(),p=me(i||n,t);if(null!=(f=a.call(e,new ke("beforestart",{sourceEvent:n,target:h,identifier:r,active:c,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return s=f.x-p[0]||0,d=f.y-p[1]||0,function n(i,a,l){var m,y=p;switch(i){case"start":u[r]=n,m=c++;break;case"end":delete u[r],--c;case"drag":p=me(l||a,t),m=c}g.call(i,e,new ke(i,{sourceEvent:a,subject:f,target:h,identifier:r,active:m,x:p[0]+s,y:p[1]+d,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:Ce(!!e),h):r},h.container=function(e){return arguments.length?(i="function"==typeof e?e:Ce(e),h):i},h.subject=function(e){return arguments.length?(a="function"==typeof e?e:Ce(e),h):a},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:Ce(!!e),h):s},h.on=function(){var e=l.on.apply(l,arguments);return e===l?h:e},h.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,h):Math.sqrt(d)},h}().on("start",(e=>{x(e)})).on("drag",(t=>{const{transform:n,gridStep:o,centerStep:r,autoPanOnNodeDrag:d,updateNodesIntersection:h}=e(),f=no(t.sourceEvent,{transform:n,gridStep:o,centerStep:r});!c&&d&&(c=!0,v());Ro(u,f.getStepPosition())&&i&&(l=t.sourceEvent,s=Jn(t.sourceEvent,a),y(f),h())})).on("end",(t=>{if(c=!1,cancelAnimationFrame(d),i){const{nodeInternals:n,transform:o,gridStep:a,centerStep:s,smoothStep:u,updateNodesPosition:l,updateNodesIntersection:c}=e();if(!!a&&u){const e=no(t.sourceEvent,{transform:o,gridStep:a,centerStep:s});l(i,!1,m(e,!0)),c()}else l(i,!1);if(r){const[e,o]=Oo({nodeId:g,dragItems:i,nodeInternals:n});r(t.sourceEvent,i,e,o)}}})).filter((e=>{const t=e.target;if(!f)return!1;const n=!(e.button||p&&((e,t,n)=>{let o=e;do{if(o?.matches(t))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1})(t,`.${p}`,f));return n}));h.call(b)},destroy:()=>{h?.on(".drag",null)}}},Lo=e=>{const{x:t,y:n,k:o}=e;return{x:t,y:n,zoom:o}},Yo=({filter:e,onPaneClick:t})=>function(n){if(e&&!e(n))return null;const o=Xn(this),r={x:o.x,y:o.y,zoom:o.k};t&&t?.(n,r)},Zo=({domNode:e,panning:t,minZoom:n,maxZoom:o,viewport:r,translateExtent:i,onTransformChange:a,onPanningChange:s,onPanZoom:u,onPanZoomStart:l,onPanZoomEnd:c,onPaneClick:d})=>{const h={isZoomingOrPanning:!1,timerId:void 0,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,isPanScrolling:!1},f=e.getBoundingClientRect(),g=function(){var e,t,n,o=Zn,r=Vn,i=Wn,a=qn,s=Kn,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=$t,h=ve("start","zoom","end"),f=500,g=150,p=0,m=10;function y(e){e.property("__zoom",Un).on("wheel.zoom",S,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",C).on("touchend.zoom touchcancel.zoom",k).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(e,t){return(t=Math.max(u[0],Math.min(u[1],t)))===e.k?e:new zn(t,e.x,e.y)}function x(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new zn(e.k,o,r)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function w(e,t,n,o){e.on("start.zoom",(function(){_(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){_(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,i=arguments,a=_(e,i).event(o),s=r.apply(e,i),u=null==n?b(s):"function"==typeof n?n.apply(e,i):n,l=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=e.__zoom,h="function"==typeof t?t.apply(e,i):t,f=d(c.invert(u).concat(l/c.k),h.invert(u).concat(l/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=l/t[2];e=new zn(n,u[0]-t[0]*n,u[1]-t[1]*n)}a.zoom(null,e)}}))}function _(e,t,n){return!n&&e.__zooming||new E(e,t)}function E(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function S(e,...t){if(o.apply(this,arguments)){var n=_(this,t).event(e),r=this.__zoom,s=Math.max(u[0],Math.min(u[1],r.k*Math.pow(2,a.apply(this,arguments)))),c=me(e);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=r.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[c,r.invert(c)],cn(this),n.start()}Yn(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),g),n.zoom("mouse",i(x(v(r,s),n.mouse[0],n.mouse[1]),n.extent,l))}}function N(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,a=_(this,t,!0).event(e),s=pe(e.view).on("mousemove.zoom",(function(e){if(Yn(e),!a.moved){var t=e.clientX-c,n=e.clientY-d;a.moved=t*t+n*n>p}a.event(e).zoom("mouse",i(x(a.that.__zoom,a.mouse[0]=me(e,r),a.mouse[1]),a.extent,l))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),Me(e.view,a.moved),Yn(e),a.event(e).end()}),!0),u=me(e,r),c=e.clientX,d=e.clientY;Pe(e.view),Ln(e),a.mouse=[u,this.__zoom.invert(u)],cn(this),a.start()}}function P(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,a=me(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),u=n.k*(e.shiftKey?.5:2),d=i(x(v(n,u),a,s),r.apply(this,t),l);Yn(e),c>0?pe(this).transition().duration(c).call(w,d,a,e):pe(this).call(y.transform,d,a,e)}}function M(n,...r){if(o.apply(this,arguments)){var i,a,s,u,l=n.touches,c=l.length,d=_(this,r,n.changedTouches.length===c).event(n);for(Ln(n),a=0;a<c;++a)u=[u=me(s=l[a],this),this.__zoom.invert(u),s.identifier],d.touch0?d.touch1||d.touch0[2]===u[2]||(d.touch1=u,d.taps=0):(d.touch0=u,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=u[0],e=setTimeout((function(){e=null}),f)),cn(this),d.start())}}function C(e,...t){if(this.__zooming){var n,o,r,a,s=_(this,t).event(e),u=e.changedTouches,c=u.length;for(Yn(e),n=0;n<c;++n)r=me(o=u[n],this),s.touch0&&s.touch0[2]===o.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===o.identifier&&(s.touch1[0]=r);if(o=s.that.__zoom,s.touch1){var d=s.touch0[0],h=s.touch0[1],f=s.touch1[0],g=s.touch1[1],p=(p=f[0]-d[0])*p+(p=f[1]-d[1])*p,m=(m=g[0]-h[0])*m+(m=g[1]-h[1])*m;o=v(o,Math.sqrt(p/m)),r=[(d[0]+f[0])/2,(d[1]+f[1])/2],a=[(h[0]+g[0])/2,(h[1]+g[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],a=s.touch0[1]}s.zoom("touch",i(x(o,r,a),s.extent,l))}}function k(e,...o){if(this.__zooming){var r,i,a=_(this,o).event(e),s=e.changedTouches,u=s.length;for(Ln(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),f),r=0;r<u;++r)i=s[r],a.touch0&&a.touch0[2]===i.identifier?delete a.touch0:a.touch1&&a.touch1[2]===i.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(i=me(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<m)){var l=pe(this).on("dblclick.zoom");l&&l.apply(this,arguments)}}}return y.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",Un),e!==r?w(e,t,n,o):r.interrupt().each((function(){_(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},y.scaleBy=function(e,t,n,o){y.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},y.scaleTo=function(e,t,n,o){y.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,a=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(a),u="function"==typeof t?t.apply(this,arguments):t;return i(x(v(o,u),a,s),e,l)}),n,o)},y.translateBy=function(e,t,n,o){y.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),l)}),null,o)},y.translateTo=function(e,t,n,o,a){y.transform(e,(function(){var e=r.apply(this,arguments),a=this.__zoom,s=null==o?b(e):"function"==typeof o?o.apply(this,arguments):o;return i(On.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,l)}),o,a)},E.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=pe(this.that).datum();h.call(e,this.that,new jn(e,{sourceEvent:this.sourceEvent,target:y,type:e,transform:this.that.__zoom,dispatch:h}),t)}},y.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:Tn(+e),y):a},y.filter=function(e){return arguments.length?(o="function"==typeof e?e:Tn(!!e),y):o},y.touchable=function(e){return arguments.length?(s="function"==typeof e?e:Tn(!!e),y):s},y.extent=function(e){return arguments.length?(r="function"==typeof e?e:Tn([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),y):r},y.scaleExtent=function(e){return arguments.length?(u[0]=+e[0],u[1]=+e[1],y):[u[0],u[1]]},y.translateExtent=function(e){return arguments.length?(l[0][0]=+e[0][0],l[1][0]=+e[1][0],l[0][1]=+e[0][1],l[1][1]=+e[1][1],y):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},y.constrain=function(e){return arguments.length?(i=e,y):i},y.duration=function(e){return arguments.length?(c=+e,y):c},y.interpolate=function(e){return arguments.length?(d=e,y):d},y.on=function(){var e=h.on.apply(h,arguments);return e===h?y:e},y.clickDistance=function(e){return arguments.length?(p=(e=+e)*e,y):Math.sqrt(p)},y.tapDistance=function(e){return arguments.length?(m=+e,y):m},y}().scaleExtent([n,o]).translateExtent(i),p=pe(e).call(g),m=(e,t,n)=>{const o=(({x:e,y:t,zoom:n})=>On.translate(e,t).scale(n))(e),r=g.constrain()(o,t,n);return r&&((e,t)=>{p&&g?.transform(((e,t=0)=>"number"==typeof t&&t>0?e.transition().duration(t):e)(p,t?.duration),e)})(r),r};m({x:r.x,y:r.y,zoom:ro(r.zoom,n,o)},[[0,0],[f.width,f.height]],i);const y=()=>{g.on("zoom",null),g.on("start",null),g.on("end",null),p.on("click.zoom",null)};return{update:({noPanClassName:e,selection:n})=>{n&&!h.isZoomingOrPanning&&y();const o=o=>{if(n)return!1;if(((e,t)=>e.target.closest(`.${t}`))(o,e)&&"wheel"!==o.type)return!1;if(!t)return!1;return!(o.button&&!(o.button<=1))},r=Yo({filter:o,onPaneClick:d});if(p.on("click.zoom",r,{passive:!1}),!n){const e=(({zoomPanValues:e,onPanningChange:t,onPanZoomStart:n})=>o=>{if(o.sourceEvent?.internal)return;const r=Lo(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r;const i=o.sourceEvent?.type;t&&("mousedown"!==i&&"touchstart"!==i||t(!0)),n&&n?.(o.sourceEvent,r)})({zoomPanValues:h,onPanningChange:s,onPanZoomStart:l}),t=(({onPanZoom:e,onTransformChange:t})=>n=>{t&&(n.sourceEvent?.sync||t([n.transform.x,n.transform.y,n.transform.k])),e&&!n.sourceEvent?.internal&&e?.(n.sourceEvent,Lo(n.transform))})({onPanZoom:u,onTransformChange:a}),n=(({zoomPanValues:e,onPanningChange:t,onPanZoomEnd:n})=>o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,t&&t(!1),n&&((e,t)=>{const{x:n,y:o,zoom:r}=e,{x:i,y:a,k:s}=t;return n!==i||o!==a||r!==s})(e.prevViewport,o.transform))){const t=Lo(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout((()=>{n?.(o.sourceEvent,t)}),0)}})({zoomPanValues:h,onPanningChange:s,onPanZoomEnd:c});g.on("start",e),g.on("zoom",t),g.on("end",n)}g.filter(o)},destroy:y,getViewport:()=>{const e=p?Xn(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},setViewportConstrained:m,setScaleExtent:e=>{g?.scaleExtent(e)}}},Vo=e=>{let t;const n=new Set,o=(e,o)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((n=>n(t,e)))}},r=()=>t,i={setState:o,getState:r,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}};return t=e(o,r,i),i};function Uo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qo,Ko,Wo,Fo={exports:{}},Ho={},Go={exports:{}},Qo={};function Jo(){return Ko||(Ko=1,Go.exports=function(){if(qo)return Qo;qo=1;var e=n,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),u=o({inst:{value:n,getSnapshot:t}}),l=u[0].inst,c=u[1];return i((function(){l.value=n,l.getSnapshot=t,s(l)&&c({inst:l})}),[e,n,t]),r((function(){return s(l)&&c({inst:l}),e((function(){s(l)&&c({inst:l})}))}),[e]),a(n),n};return Qo.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u,Qo}()),Go.exports}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactCosmosDiagram={},e.jsxRuntime,e.React)}(this,(function(e,t,n){"use strict";var o="http://www.w3.org/1999/xhtml",r={svg:"http://www.w3.org/2000/svg",xhtml:o,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function i(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),r.hasOwnProperty(t)?{space:r[t],local:e}:e}function a(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===o&&t.documentElement.namespaceURI===o?t.createElement(e):t.createElementNS(n,e)}}function s(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function u(e){var t=i(e);return(t.local?s:a)(t)}function l(){}function c(e){return null==e?l:function(){return this.querySelector(e)}}function d(){return[]}function h(e){return null==e?d:function(){return this.querySelectorAll(e)}}function f(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function g(e){return function(){return this.matches(e)}}function p(e){return function(t){return t.matches(e)}}var m=Array.prototype.find;function y(){return this.firstElementChild}var v=Array.prototype.filter;function x(){return Array.from(this.children)}function b(e){return new Array(e.length)}function w(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function _(e,t,n,o,r,i){for(var a,s=0,u=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new w(e,i[s]);for(;s<u;++s)(a=t[s])&&(r[s]=a)}function E(e,t,n,o,r,i,a){var s,u,l,c=new Map,d=t.length,h=i.length,f=new Array(d);for(s=0;s<d;++s)(u=t[s])&&(f[s]=l=a.call(u,u.__data__,s,t)+"",c.has(l)?r[s]=u:c.set(l,u));for(s=0;s<h;++s)l=a.call(e,i[s],s,i)+"",(u=c.get(l))?(o[s]=u,u.__data__=i[s],c.delete(l)):n[s]=new w(e,i[s]);for(s=0;s<d;++s)(u=t[s])&&c.get(f[s])===u&&(r[s]=u)}function S(e){return e.__data__}function N(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function P(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function M(e){return function(){this.removeAttribute(e)}}function C(e){return function(){this.removeAttributeNS(e.space,e.local)}}function k(e,t){return function(){this.setAttribute(e,t)}}function A(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function B(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function $(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function I(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function D(e){return function(){this.style.removeProperty(e)}}function T(e,t,n){return function(){this.style.setProperty(e,t,n)}}function j(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function R(e,t){return e.style.getPropertyValue(t)||I(e).getComputedStyle(e,null).getPropertyValue(t)}function z(e){return function(){delete this[e]}}function O(e,t){return function(){this[e]=t}}function L(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function X(e){return e.trim().split(/^|\s+/)}function Y(e){return e.classList||new Z(e)}function Z(e){this._node=e,this._names=X(e.getAttribute("class")||"")}function V(e,t){for(var n=Y(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function U(e,t){for(var n=Y(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function q(e){return function(){V(this,e)}}function K(e){return function(){U(this,e)}}function W(e,t){return function(){(t.apply(this,arguments)?V:U)(this,e)}}function F(){this.textContent=""}function H(e){return function(){this.textContent=e}}function G(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function Q(){this.innerHTML=""}function J(e){return function(){this.innerHTML=e}}function ee(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function te(){this.nextSibling&&this.parentNode.appendChild(this)}function ne(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function oe(){return null}function re(){var e=this.parentNode;e&&e.removeChild(this)}function ie(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ae(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function se(e){return function(){var t=this.__on;if(t){for(var n,o=0,r=-1,i=t.length;o<i;++o)n=t[o],e.type&&n.type!==e.type||n.name!==e.name?t[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?t.length=r:delete this.__on}}}function ue(e,t,n){return function(){var o,r=this.__on,i=function(e){return function(t){e.call(this,t,this.__data__)}}(t);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===e.type&&o.name===e.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=t);this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function le(e,t,n){var o=I(e),r=o.CustomEvent;"function"==typeof r?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function ce(e,t){return function(){return le(this,e,t)}}function de(e,t){return function(){return le(this,e,t.apply(this,arguments))}}w.prototype={constructor:w,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}},Z.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};var he=[null];function fe(e,t){this._groups=e,this._parents=t}function ge(){return new fe([[document.documentElement]],he)}function pe(e){return"string"==typeof e?new fe([[document.querySelector(e)]],[document.documentElement]):new fe([[e]],he)}function me(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}fe.prototype=ge.prototype={constructor:fe,select:function(e){"function"!=typeof e&&(e=c(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=t[r],u=s.length,l=o[r]=new Array(u),d=0;d<u;++d)(i=s[d])&&(a=e.call(i,i.__data__,d,s))&&("__data__"in i&&(a.__data__=i.__data__),l[d]=a);return new fe(o,this._parents)},selectAll:function(e){e="function"==typeof e?f(e):h(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var a,s=t[i],u=s.length,l=0;l<u;++l)(a=s[l])&&(o.push(e.call(a,a.__data__,l,s)),r.push(a));return new fe(o,r)},selectChild:function(e){return this.select(null==e?y:function(e){return function(){return m.call(this.children,e)}}("function"==typeof e?e:p(e)))},selectChildren:function(e){return this.selectAll(null==e?x:function(e){return function(){return v.call(this.children,e)}}("function"==typeof e?e:p(e)))},filter:function(e){"function"!=typeof e&&(e=g(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,u=o[r]=[],l=0;l<s;++l)(i=a[l])&&e.call(i,i.__data__,l,a)&&u.push(i);return new fe(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,S);var n,o=t?E:_,r=this._parents,i=this._groups;"function"!=typeof e&&(n=e,e=function(){return n});for(var a=i.length,s=new Array(a),u=new Array(a),l=new Array(a),c=0;c<a;++c){var d=r[c],h=i[c],f=h.length,g=N(e.call(d,d&&d.__data__,c,r)),p=g.length,m=u[c]=new Array(p),y=s[c]=new Array(p);o(d,h,m,y,l[c]=new Array(f),g,t);for(var v,x,b=0,w=0;b<p;++b)if(v=m[b]){for(b>=w&&(w=b+1);!(x=y[w])&&++w<p;);v._next=x||null}}return(s=new fe(s,r))._enter=u,s._exit=l,s},enter:function(){return new fe(this._enter||this._groups.map(b),this._parents)},exit:function(){return new fe(this._exit||this._groups.map(b),this._parents)},join:function(e,t,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof e?(o=e(o))&&(o=o.selection()):o=o.append(e+""),null!=t&&(r=t(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),u=0;u<a;++u)for(var l,c=n[u],d=o[u],h=c.length,f=s[u]=new Array(h),g=0;g<h;++g)(l=c[g]||d[g])&&(f[g]=l);for(;u<r;++u)s[u]=n[u];return new fe(s,this._parents)},selection:function(){return this},order:function(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o,r=e[t],i=r.length-1,a=r[i];--i>=0;)(o=r[i])&&(a&&4^o.compareDocumentPosition(a)&&a.parentNode.insertBefore(o,a),a=o);return this},sort:function(e){function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}e||(e=P);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var a,s=n[i],u=s.length,l=r[i]=new Array(u),c=0;c<u;++c)(a=s[c])&&(l[c]=a);l.sort(t)}return new fe(r,this._parents).order()},call:function(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let e=0;for(const t of this)++e;return e},empty:function(){return!this.node()},each:function(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r,i=t[n],a=0,s=i.length;a<s;++a)(r=i[a])&&e.call(r,r.__data__,a,i);return this},attr:function(e,t){var n=i(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==t?n.local?C:M:"function"==typeof t?n.local?$:B:n.local?A:k)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?D:"function"==typeof t?j:T)(e,t,null==n?"":n)):R(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?z:"function"==typeof t?L:O)(e,t)):this.node()[e]},classed:function(e,t){var n=X(e+"");if(arguments.length<2){for(var o=Y(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?W:t?q:K)(n,t))},text:function(e){return arguments.length?this.each(null==e?F:("function"==typeof e?G:H)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?Q:("function"==typeof e?ee:J)(e)):this.node().innerHTML},raise:function(){return this.each(te)},lower:function(){return this.each(ne)},append:function(e){var t="function"==typeof e?e:u(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:u(e),o=null==t?oe:"function"==typeof t?t:c(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(re)},clone:function(e){return this.select(e?ae:ie)},datum:function(e){return arguments.length?this.property("__data__",e):this.node().__data__},on:function(e,t,n){var o,r,i=function(e){return e.trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}}))}(e+""),a=i.length;if(!(arguments.length<2)){for(s=t?ue:se,o=0;o<a;++o)this.each(s(i[o],t,n));return this}var s=this.node().__on;if(s)for(var u,l=0,c=s.length;l<c;++l)for(o=0,u=s[l];o<a;++o)if((r=i[o]).type===u.type&&r.name===u.name)return u.value},dispatch:function(e,t){return this.each(("function"==typeof t?de:ce)(e,t))},[Symbol.iterator]:function*(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o,r=e[t],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};var ye={value:()=>{}};function ve(){for(var e,t=0,n=arguments.length,o={};t<n;++t){if(!(e=arguments[t]+"")||e in o||/[\s.]/.test(e))throw new Error("illegal type: "+e);o[e]=[]}return new xe(o)}function xe(e){this._=e}function be(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function we(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=ye,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}xe.prototype=ve.prototype={constructor:xe,on:function(e,t){var n,o,r=this._,i=(o=r,(e+"").trim().split(/^|\s+/).map((function(e){var t="",n=e.indexOf(".");if(n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),e&&!o.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=t&&"function"!=typeof t)throw new Error("invalid callback: "+t);for(;++a<s;)if(n=(e=i[a]).type)r[n]=we(r[n],e.name,t);else if(null==t)for(n in r)r[n]=we(r[n],e.name,null);return this}for(;++a<s;)if((n=(e=i[a]).type)&&(n=be(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new xe(e)},call:function(e,t){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=0,n=(o=this._[e]).length;i<n;++i)o[i].value.apply(t,r)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};const _e={passive:!1},Ee={capture:!0,passive:!1};function Se(e){e.stopImmediatePropagation()}function Ne(e){e.preventDefault(),e.stopImmediatePropagation()}function Pe(e){var t=e.document.documentElement,n=pe(e).on("dragstart.drag",Ne,Ee);"onselectstart"in t?n.on("selectstart.drag",Ne,Ee):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Me(e,t){var n=e.document.documentElement,o=pe(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ne,Ee),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Ce=e=>()=>e;function ke(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:u,dy:l,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}function Ae(e){return!e.ctrlKey&&!e.button}function Be(){return this.parentNode}function $e(e,t){return null==t?{x:e.x,y:e.y}:t}function Ie(){return navigator.maxTouchPoints||"ontouchstart"in this}function De(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Te(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function je(){}ke.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var Re=.7,ze=1/Re,Oe="\\s*([+-]?\\d+)\\s*",Le="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ye=/^#([0-9a-f]{3,8})$/,Ze=new RegExp(`^rgb\\(${Oe},${Oe},${Oe}\\)$`),Ve=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),Ue=new RegExp(`^rgba\\(${Oe},${Oe},${Oe},${Le}\\)$`),qe=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${Le}\\)$`),Ke=new RegExp(`^hsl\\(${Le},${Xe},${Xe}\\)$`),We=new RegExp(`^hsla\\(${Le},${Xe},${Xe},${Le}\\)$`),Fe={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function He(){return this.rgb().formatHex()}function Ge(){return this.rgb().formatRgb()}function Qe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ye.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?Je(t):3===n?new nt(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?et(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?et(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=Ze.exec(e))?new nt(t[1],t[2],t[3],1):(t=Ve.exec(e))?new nt(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ue.exec(e))?et(t[1],t[2],t[3],t[4]):(t=qe.exec(e))?et(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Ke.exec(e))?ut(t[1],t[2]/100,t[3]/100,1):(t=We.exec(e))?ut(t[1],t[2]/100,t[3]/100,t[4]):Fe.hasOwnProperty(e)?Je(Fe[e]):"transparent"===e?new nt(NaN,NaN,NaN,0):null}function Je(e){return new nt(e>>16&255,e>>8&255,255&e,1)}function et(e,t,n,o){return o<=0&&(e=t=n=NaN),new nt(e,t,n,o)}function tt(e,t,n,o){return 1===arguments.length?((r=e)instanceof je||(r=Qe(r)),r?new nt((r=r.rgb()).r,r.g,r.b,r.opacity):new nt):new nt(e,t,n,null==o?1:o);var r}function nt(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function ot(){return`#${st(this.r)}${st(this.g)}${st(this.b)}`}function rt(){const e=it(this.opacity);return`${1===e?"rgb(":"rgba("}${at(this.r)}, ${at(this.g)}, ${at(this.b)}${1===e?")":`, ${e})`}`}function it(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function at(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function st(e){return((e=at(e))<16?"0":"")+e.toString(16)}function ut(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,n,o)}function lt(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof je||(e=Qe(e)),!e)return new ct;if(e instanceof ct)return e;var t=(e=e.rgb()).r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),a=NaN,s=i-r,u=(i+r)/2;return s?(a=t===i?(n-o)/s+6*(n<o):n===i?(o-t)/s+2:(t-n)/s+4,s/=u<.5?i+r:2-i-r,a*=60):s=u>0&&u<1?0:a,new ct(a,s,u,e.opacity)}function ct(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function dt(e){return(e=(e||0)%360)<0?e+360:e}function ht(e){return Math.max(0,Math.min(1,e||0))}function ft(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}De(je,Qe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:He,formatHex:He,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return lt(this).formatHsl()},formatRgb:Ge,toString:Ge}),De(nt,tt,Te(je,{brighter(e){return e=null==e?ze:Math.pow(ze,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?Re:Math.pow(Re,e),new nt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nt(at(this.r),at(this.g),at(this.b),it(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ot,formatHex:ot,formatHex8:function(){return`#${st(this.r)}${st(this.g)}${st(this.b)}${st(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:rt,toString:rt})),De(ct,(function(e,t,n,o){return 1===arguments.length?lt(e):new ct(e,t,n,null==o?1:o)}),Te(je,{brighter(e){return e=null==e?ze:Math.pow(ze,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?Re:Math.pow(Re,e),new ct(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+360*(this.h<0),t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new nt(ft(e>=240?e-240:e+120,r,o),ft(e,r,o),ft(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new ct(dt(this.h),ht(this.s),ht(this.l),it(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=it(this.opacity);return`${1===e?"hsl(":"hsla("}${dt(this.h)}, ${100*ht(this.s)}%, ${100*ht(this.l)}%${1===e?")":`, ${e})`}`}}));var gt=e=>()=>e;function pt(e){return 1==(e=+e)?mt:function(t,n){return n-t?function(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}(t,n,e):gt(isNaN(t)?n:t)}}function mt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):gt(isNaN(e)?t:e)}var yt=function e(t){var n=pt(t);function o(e,t){var o=n((e=tt(e)).r,(t=tt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),a=mt(e.opacity,t.opacity);return function(t){return e.r=o(t),e.g=r(t),e.b=i(t),e.opacity=a(t),e+""}}return o.gamma=e,o}(1);function vt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var xt=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,bt=new RegExp(xt.source,"g");function wt(e,t){var n,o,r,i=xt.lastIndex=bt.lastIndex=0,a=-1,s=[],u=[];for(e+="",t+="";(n=xt.exec(e))&&(o=bt.exec(t));)(r=o.index)>i&&(r=t.slice(i,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,u.push({i:a,x:vt(n,o)})),i=bt.lastIndex;return i<t.length&&(r=t.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?u[0]?function(e){return function(t){return e(t)+""}}(u[0].x):function(e){return function(){return e}}(t):(t=u.length,function(e){for(var n,o=0;o<t;++o)s[(n=u[o]).i]=n.x(e);return s.join("")})}var _t,Et=180/Math.PI,St={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Nt(e,t,n,o,r,i){var a,s,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*o)&&(n-=e*u,o-=t*u),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,u/=s),e*o<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Et,skewX:Math.atan(u)*Et,scaleX:a,scaleY:s}}function Pt(e,t,n,o){function r(e){return e.length?e.pop()+" ":""}return function(i,a){var s=[],u=[];return i=e(i),a=e(a),function(e,o,r,i,a,s){if(e!==r||o!==i){var u=a.push("translate(",null,t,null,n);s.push({i:u-4,x:vt(e,r)},{i:u-2,x:vt(o,i)})}else(r||i)&&a.push("translate("+r+t+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,u),function(e,t,n,i){e!==t?(e-t>180?t+=360:t-e>180&&(e+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:vt(e,t)})):t&&n.push(r(n)+"rotate("+t+o)}(i.rotate,a.rotate,s,u),function(e,t,n,i){e!==t?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:vt(e,t)}):t&&n.push(r(n)+"skewX("+t+o)}(i.skewX,a.skewX,s,u),function(e,t,n,o,i,a){if(e!==n||t!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:vt(e,n)},{i:s-2,x:vt(t,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,u),i=a=null,function(e){for(var t,n=-1,o=u.length;++n<o;)s[(t=u[n]).i]=t.x(e);return s.join("")}}}var Mt=Pt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?St:Nt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Ct=Pt((function(e){return null==e?St:(_t||(_t=document.createElementNS("http://www.w3.org/2000/svg","g")),_t.setAttribute("transform",e),(e=_t.transform.baseVal.consolidate())?Nt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):St)}),", ",")",")");function kt(e){return((e=Math.exp(e))+1/e)/2}var At,Bt,$t=function e(t,n,o){function r(e,r){var i,a,s=e[0],u=e[1],l=e[2],c=r[0],d=r[1],h=r[2],f=c-s,g=d-u,p=f*f+g*g;if(p<1e-12)a=Math.log(h/l)/t,i=function(e){return[s+e*f,u+e*g,l*Math.exp(t*e*a)]};else{var m=Math.sqrt(p),y=(h*h-l*l+o*p)/(2*l*n*m),v=(h*h-l*l-o*p)/(2*h*n*m),x=Math.log(Math.sqrt(y*y+1)-y),b=Math.log(Math.sqrt(v*v+1)-v);a=(b-x)/t,i=function(e){var o,r=e*a,i=kt(x),c=l/(n*m)*(i*(o=t*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(e){return((e=Math.exp(e))-1/e)/2}(x));return[s+c*f,u+c*g,l*i/kt(t*r+x)]}}return i.duration=1e3*a*t/Math.SQRT2,i}return r.rho=function(t){var n=Math.max(.001,+t),o=n*n;return e(n,o,o*o)},r}(Math.SQRT2,2,4),It=0,Dt=0,Tt=0,jt=1e3,Rt=0,zt=0,Ot=0,Lt="object"==typeof performance&&performance.now?performance:Date,Xt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yt(){return zt||(Xt(Zt),zt=Lt.now()+Ot)}function Zt(){zt=0}function Vt(){this._call=this._time=this._next=null}function Ut(e,t,n){var o=new Vt;return o.restart(e,t,n),o}function qt(){zt=(Rt=Lt.now())+Ot,It=Dt=0;try{!function(){Yt(),++It;for(var e,t=At;t;)(e=zt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--It}()}finally{It=0,function(){var e,t,n=At,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),e=n,n=n._next):(t=n._next,n._next=null,n=e?e._next=t:At=t);Bt=e,Wt(o)}(),zt=0}}function Kt(){var e=Lt.now(),t=e-Rt;t>jt&&(Ot-=t,Rt=e)}function Wt(e){It||(Dt&&(Dt=clearTimeout(Dt)),e-zt>24?(e<1/0&&(Dt=setTimeout(qt,e-Lt.now()-Ot)),Tt&&(Tt=clearInterval(Tt))):(Tt||(Rt=Lt.now(),Tt=setInterval(Kt,jt)),It=1,Xt(qt)))}function Ft(e,t,n){var o=new Vt;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}Vt.prototype=Ut.prototype={constructor:Vt,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?Yt():+n)+(null==t?0:+t),this._next||Bt===this||(Bt?Bt._next=this:At=this,Bt=this),this._call=e,this._time=n,Wt()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wt())}};var Ht=ve("start","end","cancel","interrupt"),Gt=[],Qt=0,Jt=1,en=2,tn=3,nn=4,on=5,rn=6;function an(e,t,n,o,r,i){var a=e.__transition;if(a){if(n in a)return}else e.__transition={};!function(e,t,n){var o,r=e.__transition;function i(e){n.state=Jt,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var l,c,d,h;if(n.state!==Jt)return u();for(l in r)if((h=r[l]).name===n.name){if(h.state===tn)return Ft(a);h.state===nn?(h.state=rn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[l]):+l<t&&(h.state=rn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[l])}if(Ft((function(){n.state===tn&&(n.state=nn,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=en,n.on.call("start",e,e.__data__,n.index,n.group),n.state===en){for(n.state=tn,o=new Array(d=n.tween.length),l=0,c=-1;l<d;++l)(h=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(o[++c]=h);o.length=c+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(u),n.state=on,1),i=-1,a=o.length;++i<a;)o[i].call(e,r);n.state===on&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){for(var o in n.state=rn,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=Ut(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:Ht,tween:Gt,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Qt})}function sn(e,t){var n=ln(e,t);if(n.state>Qt)throw new Error("too late; already scheduled");return n}function un(e,t){var n=ln(e,t);if(n.state>tn)throw new Error("too late; already running");return n}function ln(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function cn(e,t){var n,o,r,i=e.__transition,a=!0;if(i){for(r in t=null==t?null:t+"",i)(n=i[r]).name===t?(o=n.state>en&&n.state<on,n.state=rn,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete e.__transition}}function dn(e,t){var n,o;return function(){var r=un(this,e),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a<s;++a)if(o[a].name===t){(o=o.slice()).splice(a,1);break}r.tween=o}}function hn(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=un(this,e),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:t,value:n},u=0,l=r.length;u<l;++u)if(r[u].name===t){r[u]=s;break}u===l&&r.push(s)}i.tween=r}}function fn(e,t,n){var o=e._id;return e.each((function(){var e=un(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return ln(e,o).value[t]}}function gn(e,t){var n;return("number"==typeof t?vt:t instanceof Qe?yt:(n=Qe(t))?(t=n,yt):wt)(e,t)}function pn(e){return function(){this.removeAttribute(e)}}function mn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttribute(e);return a===i?null:a===o?r:r=t(o=a,n)}}function vn(e,t,n){var o,r,i=n+"";return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===o?r:r=t(o=a,n)}}function xn(e,t,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttribute(e))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,u));this.removeAttribute(e)}}function bn(e,t,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttributeNS(e.space,e.local))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=t(o=a,u));this.removeAttributeNS(e.space,e.local)}}function wn(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}(e,r)),n}return r._value=t,r}function _n(e,t){var n,o;function r(){var r=t.apply(this,arguments);return r!==o&&(n=(o=r)&&function(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}(e,r)),n}return r._value=t,r}function En(e,t){return function(){sn(this,e).delay=+t.apply(this,arguments)}}function Sn(e,t){return t=+t,function(){sn(this,e).delay=t}}function Nn(e,t){return function(){un(this,e).duration=+t.apply(this,arguments)}}function Pn(e,t){return t=+t,function(){un(this,e).duration=t}}var Mn=ge.prototype.constructor;function Cn(e){return function(){this.style.removeProperty(e)}}var kn=0;function An(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Bn(){return++kn}var $n=ge.prototype;An.prototype={constructor:An,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=c(e));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,u,l=o[a],d=l.length,h=i[a]=new Array(d),f=0;f<d;++f)(s=l[f])&&(u=e.call(s,s.__data__,f,l))&&("__data__"in s&&(u.__data__=s.__data__),h[f]=u,an(h[f],t,n,f,h,ln(s,n)));return new An(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=h(e));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var u,l=o[s],c=l.length,d=0;d<c;++d)if(u=l[d]){for(var f,g=e.call(u,u.__data__,d,l),p=ln(u,n),m=0,y=g.length;m<y;++m)(f=g[m])&&an(f,t,n,m,g,p);i.push(g),a.push(u)}return new An(i,a,t,n)},selectChild:$n.selectChild,selectChildren:$n.selectChildren,filter:function(e){"function"!=typeof e&&(e=g(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i,a=t[r],s=a.length,u=o[r]=[],l=0;l<s;++l)(i=a[l])&&e.call(i,i.__data__,l,a)&&u.push(i);return new An(o,this._parents,this._name,this._id)},merge:function(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),a=new Array(o),s=0;s<i;++s)for(var u,l=t[s],c=n[s],d=l.length,h=a[s]=new Array(d),f=0;f<d;++f)(u=l[f]||c[f])&&(h[f]=u);for(;s<o;++s)a[s]=t[s];return new An(a,this._parents,this._name,this._id)},selection:function(){return new Mn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Bn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,l=0;l<u;++l)if(a=s[l]){var c=ln(a,t);an(a,e,n,l,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new An(o,this._parents,e,n)},call:$n.call,nodes:$n.nodes,node:$n.node,size:$n.size,empty:$n.empty,each:$n.each,on:function(e,t){var n=this._id;return arguments.length<2?ln(this.node(),n).on.on(e):this.each(function(e,t,n){var o,r,i=function(e){return(e+"").trim().split(/^|\s+/).every((function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||"start"===e}))}(t)?sn:un;return function(){var a=i(this,e),s=a.on;s!==o&&(r=(o=s).copy()).on(t,n),a.on=r}}(n,e,t))},attr:function(e,t){var n=i(e),o="transform"===n?Ct:gn;return this.attrTween(e,"function"==typeof t?(n.local?bn:xn)(n,o,fn(this,"attr."+e,t)):null==t?(n.local?mn:pn)(n):(n.local?vn:yn)(n,o,t))},attrTween:function(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;var o=i(e);return this.tween(n,(o.local?wn:_n)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?Mt:gn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=R(this,e),a=(this.style.removeProperty(e),R(this,e));return i===a?null:i===n&&a===o?r:r=t(n=i,o=a)}}(e,o)).on("end.style."+e,Cn(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var a=R(this,e),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(e),u=s=R(this,e)),a===u?null:a===o&&u===r?i:(r=u,i=t(o=a,s))}}(e,o,fn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,a="style."+t,s="end."+a;return function(){var u=un(this,e),l=u.on,c=null==u.value[a]?i||(i=Cn(t)):void 0;l===n&&r===c||(o=(n=l).copy()).on(s,r=c),u.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var a=R(this,e);return a===i?null:a===o?r:r=t(o=a,n)}}(e,o,t),n).on("end.style."+e,null)},styleTween:function(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==t)return this.tween(o,null);if("function"!=typeof t)throw new Error;return this.tween(o,function(e,t,n){var o,r;function i(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&function(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}(e,i,n)),o}return i._value=t,i}(e,t,null==n?"":n))},text:function(e){return this.tween("text","function"==typeof e?function(e){return function(){var t=e(this);this.textContent=null==t?"":t}}(fn(this,"text",e)):function(e){return function(){this.textContent=e}}(null==e?"":e+""))},textTween:function(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(null==e)return this.tween(t,null);if("function"!=typeof e)throw new Error;return this.tween(t,function(e){var t,n;function o(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&function(e){return function(t){this.textContent=e.call(this,t)}}(o)),t}return o._value=e,o}(e))},remove:function(){return this.on("end.remove",function(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}(this._id))},tween:function(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o,r=ln(this.node(),n).tween,i=0,a=r.length;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((null==t?dn:hn)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?En:Sn)(t,e)):ln(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Nn:Pn)(t,e)):ln(this.node(),t).duration},ease:function(e){var t=this._id;return arguments.length?this.each(function(e,t){if("function"!=typeof t)throw new Error;return function(){un(this,e).ease=t}}(t,e)):ln(this.node(),t).ease},easeVarying:function(e){if("function"!=typeof e)throw new Error;return this.each(function(e,t){return function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw new Error;un(this,e).ease=n}}(this._id,e))},end:function(){var e,t,n=this,o=n._id,r=n.size();return new Promise((function(i,a){var s={value:a},u={value:function(){0==--r&&i()}};n.each((function(){var n=un(this,o),r=n.on;r!==e&&((t=(e=r).copy())._.cancel.push(s),t._.interrupt.push(s),t._.end.push(u)),n.on=t})),0===r&&i()}))},[Symbol.iterator]:$n[Symbol.iterator]};var In={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function Dn(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}ge.prototype.interrupt=function(e){return this.each((function(){cn(this,e)}))},ge.prototype.transition=function(e){var t,n;e instanceof An?(t=e._id,e=e._name):(t=Bn(),(n=In).time=Yt(),e=null==e?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,l=0;l<u;++l)(a=s[l])&&an(a,e,t,l,s,n||Dn(a,t));return new An(o,this._parents,e,t)};var Tn=e=>()=>e;function jn(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Rn(e,t,n){this.k=e,this.x=t,this.y=n}Rn.prototype={constructor:Rn,scale:function(e){return 1===e?this:new Rn(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new Rn(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var zn,On=new Rn(1,0,0);function Ln(e){for(;!e.__zoom;)if(!(e=e.parentNode))return On;return e.__zoom}function Xn(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function Zn(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function Vn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function Un(){return this.__zoom||On}function qn(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wn(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}Ln.prototype=Rn.prototype,e.Position=void 0,(zn=e.Position||(e.Position={})).Left="left",zn.Top="top",zn.Right="right",zn.Bottom="bottom";const Fn="internals";e.MarkerType=void 0,(e.MarkerType||(e.MarkerType={})).Arrow="arrow";const Hn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Gn=(e,t,n,o)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const i=Array.from(r),a=t.getBoundingClientRect(),s=a.width*o[0],u=a.height*o[1];return i.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-portid"),position:e.dataset.portPosition,x:(t.left-a.left-s)/n,y:(t.top-a.top-u)/n,...Hn(e)}}))},Qn=e=>"clientX"in e,Jn=(e,t)=>{const n=Qn(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},eo=({x:e,y:t},[n,o,r])=>({x:(e-n)/r,y:(t-o)/r}),to=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),no=(e,{transform:t,gridStep:n,centerStep:o})=>{const{x:r,y:i}=Jn(e),a=eo({x:r,y:i},t);return{getStepPosition:(e={position:a})=>{const{position:t,nodeSize:r}=e;if(!n)return t;let i=n[0]*Math.round(t.x/n[0]),s=n[1]*Math.round(t.y/n[1]);if(o&&r){const e=(n[0]-r.width)/2,o=(n[1]-r.height)/2,a=t.x-e,u=t.y-o;i=n[0]*Math.round(a/n[0])+e,s=n[1]*Math.round(u/n[1])+o}return{x:i,y:s}},...a}},oo={"001":()=>"Seems like you have not used zustand provider as an ancestor","002":()=>"It looks like you`ve created a new nodeTypes or edgeTypes object. If this wasn`t on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.","010":e=>`Node type "${e}" not found. Using fallback type "default".`,"011":()=>"Only child nodes can use a parent extent","020":()=>"Can`t create edge. An edge needs a source and a target.","021":e=>`The old edge with id=${e} does not exist.`,"022":e=>`Marker type "${e}" doesn't exist.`},ro=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),io=(e,t,n,o)=>{const r=t-n;return e<n?ro(Math.abs(e-n),1,50)/50*o:e>r?-ro(Math.abs(e-r),1,50)/50*o:0},ao=(e,t)=>[io(e.x,t.width,30,10),io(e.y,t.height,30,10)],so=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),uo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),lo=e=>!isNaN(e)&&isFinite(e),co=(e={x:0,y:0},t)=>({x:ro(e.x,t[0][0],t[1][0]),y:ro(e.y,t[0][1],t[1][1])}),ho=e=>"source"in e&&"target"in e,fo=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-o};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:r}},go=(e,t,[n,o,r]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const u={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},l=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(a&&!o||r)return!1;const{positionAbsolute:c}=fo(e,s),d={x:c.x,y:c.y,width:t||0,height:n||0},h=((e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)})(u,d);(void 0===t||void 0===n||null===t||null===n||i&&h>0||h>=(t||0)*(n||0)||e.dragging)&&l.push(e)})),l},po=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};const n=e.reduce(((e,n)=>{const{x:o,y:r}=fo(n,t).positionAbsolute,i=so({x:o,y:r,width:n.width||0,height:n.height||0});return a=e,s=i,{x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),x2:Math.max(a.x2,s.x2),y2:Math.max(a.y2,s.y2)};var a,s}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return uo(n)};function mo(e,t){const{nodes:n,edges:o}=e,{nodes:r,edges:i}=t,a=[],s=new Set(n?.map((e=>e.id)));for(const e of r){if(!1===e.deletable)continue;const t=s.has(e.id),n=!t&&e.parentNode&&a.find((t=>t.id===e.parentNode));(t||n)&&a.push(e)}const u=i.filter((e=>!1!==e.deletable)),l=function(e,t){const n=new Set;return e.forEach((e=>{n.add(e.id)})),t.filter((e=>n.has(e.source)||n.has(e.target)))}(a,i),c=l,d=new Set(o?.map((e=>e.id)));for(const e of u){const t=c.some((t=>t.id===e.id)),n=d.has(e.id);(o?n&&!t:!t)&&c.push(e)}return{nodes:a,edges:c}}const yo=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},vo=({sourceX:e,sourceY:t,targetX:n,targetY:o})=>{const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,a=Math.abs(o-t)/2;return[i,o<t?o+a:o-a,r,a]},xo=({source:e,sourcePort:t,target:n,targetPort:o})=>`react-diagram__edge-${e}${t}-${n}${o}`,bo={[e.Position.Left]:{x:-1,y:0},[e.Position.Right]:{x:1,y:0},[e.Position.Top]:{x:0,y:-1},[e.Position.Bottom]:{x:0,y:1}},wo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),_o=({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:a,stepPosition:s})=>{const u=bo[n],l=bo[r],c={x:t.x+u.x*a,y:t.y+u.y*a},d={x:o.x+l.x*a,y:o.y+l.y*a},h=(({source:t,sourcePosition:n=e.Position.Bottom,target:o})=>n===e.Position.Left||n===e.Position.Right?t.x<o.x?{x:1,y:0}:{x:-1,y:0}:t.y<o.y?{x:0,y:1}:{x:0,y:-1})({source:c,sourcePosition:n,target:d}),f=0!==h.x?"x":"y",g=h[f];let p,m,y=[];const v={x:0,y:0},x={x:0,y:0},[,,b,w]=vo({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(u[f]*l[f]==-1){"x"===f?(p=i.x??c.x+(d.x-c.x)*s,m=i.y??(c.y+d.y)/2):(p=i.x??(c.x+d.x)/2,m=i.y??c.y+(d.y-c.y)*s);const e=[{x:p,y:c.y},{x:p,y:d.y}],t=[{x:c.x,y:m},{x:d.x,y:m}];y=u[f]===g?"x"===f?e:t:"x"===f?t:e}else{const e=[{x:c.x,y:d.y}],i=[{x:d.x,y:c.y}];if(y="x"===f?u.x===g?i:e:u.y===g?e:i,n===r){const e=Math.abs(t[f]-o[f]);if(e<=a){const n=Math.min(a-1,a-e);u[f]===g?v[f]=(c[f]>t[f]?-1:1)*n:x[f]=(d[f]>o[f]?-1:1)*n}}if(n!==r){const t="x"===f?"y":"x",n=u[f]===l[t],o=c[t]>d[t],r=c[t]<d[t];(1===u[f]&&(!n&&o||n&&r)||1!==u[f]&&(!n&&r||n&&o))&&(y="x"===f?e:i)}const s={x:c.x+v.x,y:c.y+v.y},h={x:d.x+x.x,y:d.y+x.y};Math.max(Math.abs(s.x-y[0].x),Math.abs(h.x-y[0].x))>=Math.max(Math.abs(s.y-y[0].y),Math.abs(h.y-y[0].y))?(p=(s.x+h.x)/2,m=y[0].y):(p=y[0].x,m=(s.y+h.y)/2)}return[[t,{x:c.x+v.x,y:c.y+v.y},...y,{x:d.x+x.x,y:d.y+x.y},o],p,m,b,w]};function Eo({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,borderRadius:s=5,centerX:u,centerY:l,offset:c=20,stepPosition:d=.5}){const[h,f,g,p,m]=_o({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:u,y:l},offset:c,stepPosition:d});return[h.reduce(((e,t,n)=>{let o="";return o=n>0&&n<h.length-1?((e,t,n,o)=>{const r=Math.min(wo(e,t)/2,wo(t,n)/2,o),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a)return`L ${i+r*(e.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+r*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${i},${a+r*(e.y<n.y?-1:1)}Q ${i},${a} ${i+r*s},${a}`})(h[n-1],t,h[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),f,g,p,m]}const So=({sourceX:e,sourceY:t,targetX:n,targetY:o})=>{const[r,i,a,s]=vo({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,a,s]},No=({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s})=>{const u=.125,l=.375,c=e*u+r*l+a*l+n*u,d=t*u+i*l+s*l+o*u;return[c,d,Math.abs(c-e),Math.abs(d-t)]},Po=(e,t)=>e>=0?.5*e:25*t*Math.sqrt(-e),Mo=({pos:t,x1:n,y1:o,x2:r,y2:i,c:a})=>{switch(t){case e.Position.Left:return[n-Po(n-r,a),o];case e.Position.Right:return[n+Po(r-n,a),o];case e.Position.Top:return[n,o-Po(o-i,a)];case e.Position.Bottom:return[n,o+Po(i-o,a)]}},Co=({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,curvature:s=.25})=>{const[u,l]=Mo({pos:o,x1:t,y1:n,x2:r,y2:i,c:s}),[c,d]=Mo({pos:a,x1:r,y1:i,x2:t,y2:n,c:s}),[h,f,g,p]=No({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:u,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${t},${n} C${u},${l} ${c},${d} ${r},${i}`,h,f,g,p]};function ko(e,t,n,o){if(!e.parentNode)return n;const r=t.get(e.parentNode),i=fo(r,o);return ko(r,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r[Fn]?.z??0)>(n.z??0)?r[Fn]?.z??0:n.z??0},o)}function Ao(e,t,n){e.forEach((o=>{if(o.parentNode&&!e.has(o.parentNode))throw new Error(`Parent node ${o.parentNode} not found`);if(o.parentNode||n?.[o.id]){const{x:r,y:i,z:a}=ko(o,e,{...o.position,z:o[Fn]?.z??0},t);o.positionAbsolute={x:r,y:i},o[Fn].z=a,n?.[o.id]&&(o[Fn].isParent=!0)}}))}function Bo(e,t,n,o){const r=new Map,i={},a=o?1e3:0;return e.forEach((e=>{const n=(lo(e.zIndex)?e.zIndex:0)+(e.selected?a:0),o=t.get(e.id),s={width:o?.width,height:o?.height,...e,positionAbsolute:{x:e.position.x,y:e.position.y}};e.parentNode&&(s.parentNode=e.parentNode,i[e.parentNode]=!0),Object.defineProperty(s,Fn,{enumerable:!1,value:{portBounds:o?.[Fn]?.portBounds,z:n}}),r.set(e.id,s)})),Ao(r,n,i),r}function $o(e,t){const{id:n,width:o,height:r,positionAbsolute:i}=e;if(!o||!r)return!1;let a=!1;for(const[e,s]of t){if(n===e)continue;const{positionAbsolute:t,width:u,height:l}=s;if(!u||!l)continue;if(!t||!i)continue;const c=t.x+u>=i.x,d=i.x+o>=t.x,h=t.y+l>=i.y,f=i.y+r>=t.y;if(c&&d&&h&&f){a=!0;break}}return a}const Io=(e,t,n,o)=>(t[n]||[]).reduce(((t,r)=>(`${e.id}-${r.id}-${n}`!==o&&t.push({portId:r.id||null,portType:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+r.x+r.width/2,y:(e.positionAbsolute?.y??0)+r.y+r.height/2}),t)),[]),Do=e=>e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null;let To=null;const jo=({isAnchor:e=!1,event:t,nodeId:n,portId:o,portType:r,domNode:i,autoPanOnConnect:a,connectionRadius:s,nodes:u,getTransform:l,cancelConnection:c,onConnectStart:d,onConnect:h,onConnectEnd:f,onEdgeUpdateEnd:g,panBy:p,updateConnection:m})=>{const y=(v=t.target,v.getRootNode?.()||window?.document);var v;const x=i?.getBoundingClientRect(),{x:b,y:w}=Jn(t),_=y?.elementFromPoint(b,w),E=e?r:Do(_),S=(({nodes:e,nodeId:t,portId:n,portType:o})=>e.reduce(((e,r)=>{if(r[Fn]){const{portBounds:i}=r[Fn];let a=[],s=[];i&&(a=Io(r,i,"source",`${t}-${n}-${o}`),s=Io(r,i,"target",`${t}-${n}-${o}`)),e.push(...a,...s)}return e}),[]))({nodes:u,nodeId:n,portId:o,portType:r});let N=Jn(t,x),P=null,M=!1,C=null,k=0,A=!1;if(!x||!r)return;const B=()=>{if(!a)return;const[e,t]=ao(N,x);p({x:e,y:t}),k=requestAnimationFrame(B)};To={nodeId:n,portId:o,portType:E},m({connectionPosition:N,connectionStartPort:To,connectionEndPort:null}),d?.(t,{nodeId:n,portId:o,portType:r});const $=e=>{const t=l();N=Jn(e,x),P=((e,t,n)=>{let o=null,r=1/0;return n.forEach((n=>{const i=Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));i<=t&&i<r&&(r=i,o=n)})),o})(eo(N,t),s,S),A||(B(),A=!0);const i=((e,t,n,o,r,i)=>{const a="target"===r,s={isValid:!1,connection:null,endPort:null},u=i.querySelector(`.react-diagram__port[data-id="${t?.nodeId}-${t?.portId}-${t?.portType}"]`),{x:l,y:c}=Jn(e),d=i.elementFromPoint(l,c),h=d?.classList.contains("react-diagram__port")?d:u;if(h){const e=Do(h),r=h.getAttribute("data-nodeid"),i=h.getAttribute("data-portid"),u={source:a?r:n,target:a?n:r,sourcePort:a?t?.portId||null:o,targetPort:a?o:t?.portId||null};s.connection=u,(a&&"source"===e||!a&&"target"===e)&&(s.isValid=!0,s.endPort={nodeId:r,portId:i,portType:e})}return s})(e,P,n,o,r,y);M=i.isValid,C=i.connection,m({connectionPosition:P&&M?to(P,t):N,connectionStartPort:To,connectionEndPort:i.endPort})},I=e=>{M&&C&&h?.(C),f?.(e),r&&g?.(e),c(),cancelAnimationFrame(k),M=!1,C=null,A=!1,y.removeEventListener("mousemove",$),y.removeEventListener("mouseup",I),y.removeEventListener("touchmove",$),y.removeEventListener("touchend",I)};y.addEventListener("mousemove",$),y.addEventListener("mouseup",I),y.addEventListener("touchmove",$),y.addEventListener("touchend",I)},Ro=(e,t)=>{if(!e.parentNode)return!1;const n=t.get(e.parentNode);return!!n&&(!!n.selected||Ro(n,t))},zo=(e,t)=>e.x!==t.x||e.y!==t.y,Oo=({nodeId:e,dragItems:t,nodeInternals:n})=>{const o=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?o.find((t=>t.id===e)):o[0],o]},Lo=({getStore:e,onNodeMouseDown:t,onDragStart:n,onDrag:o,onDragEnd:r})=>{let i=[],a=null,s={x:0,y:0},u={x:0,y:0},l=null,c=!1,d=0,h=null;return{update:({domNode:f,nodeId:g,noDragClassName:p})=>{const m=(t,n=!1)=>o=>{if(!("distance"in o))return;const{nodeInternals:r,nodeExtent:i,nodeOrigin:a,smoothStep:s,gridStep:u}=e(),{distance:l,width:c,height:d}=o,{x:h,y:f,getStepPosition:g}=t;let p={x:h-l.x,y:f-l.y};if(u&&g){const e=g({position:p,nodeSize:{width:c,height:d}});(!s||s&&n)&&(p=e)}const m=((e,t,n,o,r=[0,0])=>{let i=e.extent||o;if(e.extent&&e.parentNode){const t=n.get(e.parentNode),{x:o,y:a}=fo(t,r).positionAbsolute;i=[[e.extent[0][0]+o,e.extent[0][1]+a],[e.extent[1][0]+o,e.extent[1][1]+a]]}let a={x:0,y:0};if(e.parentNode){const t=n.get(e.parentNode);a=fo(t,r).positionAbsolute}const s=i?co(t,i):t;return{position:{x:s.x-a.x,y:s.y-a.y},positionAbsolute:s}})(o,p,r,i,a);zo(o.position,m.position)&&(o.position=m.position,o.positionAbsolute=m.positionAbsolute)};h=pe(f);const y=t=>{const{nodeInternals:n,updateNodesPosition:r}=e(),{x:a,y:s}=t;if(u={x:a,y:s},r(i,!0,m(t)),o&&l){const[e,t]=Oo({nodeId:g,dragItems:i,nodeInternals:n});o(l,i,e,t)}},v=()=>{if(!a)return;const[t,n]=ao(s,a);if(0!==t||0!==n){const{transform:o,panBy:r}=e();u.x-=t/o[2],u.y-=n/o[2],y(u),r({x:t,y:n})}d=requestAnimationFrame(v)},x=o=>{const{nodeInternals:r,nodesDraggable:u,domNode:l,transform:c,gridStep:d,centerStep:h}=e();g&&t?.(g);const f=no(o.sourceEvent,{transform:c,gridStep:d,centerStep:h});if(i=((e,t,n,o)=>Array.from(e.values()).filter((n=>{const r=n.width&&n.height,i=n.selected||n.id===o,a=!n.parentNode||!Ro(n,e),s=n.draggable||t&&void 0===n.draggable;return r&&i&&a&&s})).map((e=>({id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-(e.positionAbsolute?.x??0),y:n.y-(e.positionAbsolute?.y??0)},extent:e.extent,parentNode:e.parentNode,width:e.width||0,height:e.height||0}))))(r,u,f,g),n&&i){const[e,t]=Oo({nodeId:g,dragItems:i,nodeInternals:r});n?.(o.sourceEvent,i,e,t)}a=l?.getBoundingClientRect()||null,s=Jn(o.sourceEvent,a)},b=function(){var e,t,n,o,r=Ae,i=Be,a=$e,s=Ie,u={},l=ve("start","drag","end"),c=0,d=0;function h(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,_e).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(a,s){if(!o&&r.call(this,a,s)){var u=x(this,i.call(this,a,s),a,s,"mouse");u&&(pe(a.view).on("mousemove.drag",g,Ee).on("mouseup.drag",p,Ee),Pe(a.view),Se(a),n=!1,e=a.clientX,t=a.clientY,u("start",a))}}function g(o){if(Ne(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>d}u.mouse("drag",o)}function p(e){pe(e.view).on("mousemove.drag mouseup.drag",null),Me(e.view,n),Ne(e),u.mouse("end",e)}function m(e,t){if(r.call(this,e,t)){var n,o,a=e.changedTouches,s=i.call(this,e,t),u=a.length;for(n=0;n<u;++n)(o=x(this,s,e,t,a[n].identifier,a[n]))&&(Se(e),o("start",e,a[n]))}}function y(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=u[o[t].identifier])&&(Ne(e),n("drag",e,o[t]))}function v(e){var t,n,r=e.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<i;++t)(n=u[r[t].identifier])&&(Se(e),n("end",e,r[t]))}function x(e,t,n,o,r,i){var s,d,f,g=l.copy(),p=me(i||n,t);if(null!=(f=a.call(e,new ke("beforestart",{sourceEvent:n,target:h,identifier:r,active:c,x:p[0],y:p[1],dx:0,dy:0,dispatch:g}),o)))return s=f.x-p[0]||0,d=f.y-p[1]||0,function n(i,a,l){var m,y=p;switch(i){case"start":u[r]=n,m=c++;break;case"end":delete u[r],--c;case"drag":p=me(l||a,t),m=c}g.call(i,e,new ke(i,{sourceEvent:a,subject:f,target:h,identifier:r,active:m,x:p[0]+s,y:p[1]+d,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:g}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:Ce(!!e),h):r},h.container=function(e){return arguments.length?(i="function"==typeof e?e:Ce(e),h):i},h.subject=function(e){return arguments.length?(a="function"==typeof e?e:Ce(e),h):a},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:Ce(!!e),h):s},h.on=function(){var e=l.on.apply(l,arguments);return e===l?h:e},h.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,h):Math.sqrt(d)},h}().on("start",(e=>{x(e)})).on("drag",(t=>{const{transform:n,gridStep:o,centerStep:r,autoPanOnNodeDrag:d,updateNodesIntersection:h}=e(),f=no(t.sourceEvent,{transform:n,gridStep:o,centerStep:r});!c&&d&&(c=!0,v());zo(u,f.getStepPosition())&&i&&(l=t.sourceEvent,s=Jn(t.sourceEvent,a),y(f),h())})).on("end",(t=>{if(c=!1,cancelAnimationFrame(d),i){const{nodeInternals:n,transform:o,gridStep:a,centerStep:s,smoothStep:u,updateNodesPosition:l,updateNodesIntersection:c}=e();if(!!a&&u){const e=no(t.sourceEvent,{transform:o,gridStep:a,centerStep:s});l(i,!1,m(e,!0)),c()}else l(i,!1);if(r){const[e,o]=Oo({nodeId:g,dragItems:i,nodeInternals:n});r(t.sourceEvent,i,e,o)}}})).filter((e=>{const t=e.target;if(!f)return!1;const n=!(e.button||p&&((e,t,n)=>{let o=e;do{if(o?.matches(t))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1})(t,`.${p}`,f));return n}));h.call(b)},destroy:()=>{h?.on(".drag",null)}}},Xo=e=>{const{x:t,y:n,k:o}=e;return{x:t,y:n,zoom:o}},Yo=({filter:e,onPaneClick:t})=>function(n){if(e&&!e(n))return null;const o=Ln(this),r={x:o.x,y:o.y,zoom:o.k};t&&t?.(n,r)},Zo=({domNode:e,panning:t,minZoom:n,maxZoom:o,viewport:r,translateExtent:i,onTransformChange:a,onPanningChange:s,onPanZoom:u,onPanZoomStart:l,onPanZoomEnd:c,onPaneClick:d})=>{const h={isZoomingOrPanning:!1,timerId:void 0,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,isPanScrolling:!1},f=e.getBoundingClientRect(),g=function(){var e,t,n,o=Zn,r=Vn,i=Wn,a=qn,s=Kn,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=$t,h=ve("start","zoom","end"),f=500,g=150,p=0,m=10;function y(e){e.property("__zoom",Un).on("wheel.zoom",S,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",C).on("touchend.zoom touchcancel.zoom",k).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(e,t){return(t=Math.max(u[0],Math.min(u[1],t)))===e.k?e:new Rn(t,e.x,e.y)}function x(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new Rn(e.k,o,r)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function w(e,t,n,o){e.on("start.zoom",(function(){_(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){_(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,i=arguments,a=_(e,i).event(o),s=r.apply(e,i),u=null==n?b(s):"function"==typeof n?n.apply(e,i):n,l=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),c=e.__zoom,h="function"==typeof t?t.apply(e,i):t,f=d(c.invert(u).concat(l/c.k),h.invert(u).concat(l/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=l/t[2];e=new Rn(n,u[0]-t[0]*n,u[1]-t[1]*n)}a.zoom(null,e)}}))}function _(e,t,n){return!n&&e.__zooming||new E(e,t)}function E(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function S(e,...t){if(o.apply(this,arguments)){var n=_(this,t).event(e),r=this.__zoom,s=Math.max(u[0],Math.min(u[1],r.k*Math.pow(2,a.apply(this,arguments)))),c=me(e);if(n.wheel)n.mouse[0][0]===c[0]&&n.mouse[0][1]===c[1]||(n.mouse[1]=r.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[c,r.invert(c)],cn(this),n.start()}Yn(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),g),n.zoom("mouse",i(x(v(r,s),n.mouse[0],n.mouse[1]),n.extent,l))}}function N(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,a=_(this,t,!0).event(e),s=pe(e.view).on("mousemove.zoom",(function(e){if(Yn(e),!a.moved){var t=e.clientX-c,n=e.clientY-d;a.moved=t*t+n*n>p}a.event(e).zoom("mouse",i(x(a.that.__zoom,a.mouse[0]=me(e,r),a.mouse[1]),a.extent,l))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),Me(e.view,a.moved),Yn(e),a.event(e).end()}),!0),u=me(e,r),c=e.clientX,d=e.clientY;Pe(e.view),Xn(e),a.mouse=[u,this.__zoom.invert(u)],cn(this),a.start()}}function P(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,a=me(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(a),u=n.k*(e.shiftKey?.5:2),d=i(x(v(n,u),a,s),r.apply(this,t),l);Yn(e),c>0?pe(this).transition().duration(c).call(w,d,a,e):pe(this).call(y.transform,d,a,e)}}function M(n,...r){if(o.apply(this,arguments)){var i,a,s,u,l=n.touches,c=l.length,d=_(this,r,n.changedTouches.length===c).event(n);for(Xn(n),a=0;a<c;++a)u=[u=me(s=l[a],this),this.__zoom.invert(u),s.identifier],d.touch0?d.touch1||d.touch0[2]===u[2]||(d.touch1=u,d.taps=0):(d.touch0=u,i=!0,d.taps=1+!!e);e&&(e=clearTimeout(e)),i&&(d.taps<2&&(t=u[0],e=setTimeout((function(){e=null}),f)),cn(this),d.start())}}function C(e,...t){if(this.__zooming){var n,o,r,a,s=_(this,t).event(e),u=e.changedTouches,c=u.length;for(Yn(e),n=0;n<c;++n)r=me(o=u[n],this),s.touch0&&s.touch0[2]===o.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===o.identifier&&(s.touch1[0]=r);if(o=s.that.__zoom,s.touch1){var d=s.touch0[0],h=s.touch0[1],f=s.touch1[0],g=s.touch1[1],p=(p=f[0]-d[0])*p+(p=f[1]-d[1])*p,m=(m=g[0]-h[0])*m+(m=g[1]-h[1])*m;o=v(o,Math.sqrt(p/m)),r=[(d[0]+f[0])/2,(d[1]+f[1])/2],a=[(h[0]+g[0])/2,(h[1]+g[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],a=s.touch0[1]}s.zoom("touch",i(x(o,r,a),s.extent,l))}}function k(e,...o){if(this.__zooming){var r,i,a=_(this,o).event(e),s=e.changedTouches,u=s.length;for(Xn(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),f),r=0;r<u;++r)i=s[r],a.touch0&&a.touch0[2]===i.identifier?delete a.touch0:a.touch1&&a.touch1[2]===i.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(i=me(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<m)){var l=pe(this).on("dblclick.zoom");l&&l.apply(this,arguments)}}}return y.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",Un),e!==r?w(e,t,n,o):r.interrupt().each((function(){_(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},y.scaleBy=function(e,t,n,o){y.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},y.scaleTo=function(e,t,n,o){y.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,a=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(a),u="function"==typeof t?t.apply(this,arguments):t;return i(x(v(o,u),a,s),e,l)}),n,o)},y.translateBy=function(e,t,n,o){y.transform(e,(function(){return i(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),l)}),null,o)},y.translateTo=function(e,t,n,o,a){y.transform(e,(function(){var e=r.apply(this,arguments),a=this.__zoom,s=null==o?b(e):"function"==typeof o?o.apply(this,arguments):o;return i(On.translate(s[0],s[1]).scale(a.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,l)}),o,a)},E.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=pe(this.that).datum();h.call(e,this.that,new jn(e,{sourceEvent:this.sourceEvent,target:y,type:e,transform:this.that.__zoom,dispatch:h}),t)}},y.wheelDelta=function(e){return arguments.length?(a="function"==typeof e?e:Tn(+e),y):a},y.filter=function(e){return arguments.length?(o="function"==typeof e?e:Tn(!!e),y):o},y.touchable=function(e){return arguments.length?(s="function"==typeof e?e:Tn(!!e),y):s},y.extent=function(e){return arguments.length?(r="function"==typeof e?e:Tn([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),y):r},y.scaleExtent=function(e){return arguments.length?(u[0]=+e[0],u[1]=+e[1],y):[u[0],u[1]]},y.translateExtent=function(e){return arguments.length?(l[0][0]=+e[0][0],l[1][0]=+e[1][0],l[0][1]=+e[0][1],l[1][1]=+e[1][1],y):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},y.constrain=function(e){return arguments.length?(i=e,y):i},y.duration=function(e){return arguments.length?(c=+e,y):c},y.interpolate=function(e){return arguments.length?(d=e,y):d},y.on=function(){var e=h.on.apply(h,arguments);return e===h?y:e},y.clickDistance=function(e){return arguments.length?(p=(e=+e)*e,y):Math.sqrt(p)},y.tapDistance=function(e){return arguments.length?(m=+e,y):m},y}().scaleExtent([n,o]).translateExtent(i),p=pe(e).call(g),m=(e,t,n)=>{const o=(({x:e,y:t,zoom:n})=>On.translate(e,t).scale(n))(e),r=g.constrain()(o,t,n);return r&&((e,t)=>{p&&g?.transform(((e,t=0)=>"number"==typeof t&&t>0?e.transition().duration(t):e)(p,t?.duration),e)})(r),r};m({x:r.x,y:r.y,zoom:ro(r.zoom,n,o)},[[0,0],[f.width,f.height]],i);const y=()=>{g.on("zoom",null),g.on("start",null),g.on("end",null),p.on("click.zoom",null)};return{update:({noPanClassName:e,selection:n})=>{n&&!h.isZoomingOrPanning&&y();const o=o=>{if(console.log("00-0-0-0-0-0-0-0"),n)return!1;if(((e,t)=>e.target.closest(`.${t}`))(o,e)&&"wheel"!==o.type)return!1;if(!t)return!1;return!(o.button&&!(o.button<=1))},r=Yo({filter:o,onPaneClick:d});if(p.on("click.zoom",r,{passive:!1}),!n){const e=(({zoomPanValues:e,onPanningChange:t,onPanZoomStart:n})=>o=>{if(o.sourceEvent?.internal)return;const r=Xo(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r;const i=o.sourceEvent?.type;t&&("mousedown"!==i&&"touchstart"!==i||t(!0)),n&&n?.(o.sourceEvent,r)})({zoomPanValues:h,onPanningChange:s,onPanZoomStart:l}),t=(({onPanZoom:e,onTransformChange:t})=>n=>{t&&(n.sourceEvent?.sync||t([n.transform.x,n.transform.y,n.transform.k])),e&&!n.sourceEvent?.internal&&e?.(n.sourceEvent,Xo(n.transform))})({onPanZoom:u,onTransformChange:a}),n=(({zoomPanValues:e,onPanningChange:t,onPanZoomEnd:n})=>o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,t&&t(!1),n&&((e,t)=>{const{x:n,y:o,zoom:r}=e,{x:i,y:a,k:s}=t;return n!==i||o!==a||r!==s})(e.prevViewport,o.transform))){const t=Xo(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout((()=>{n?.(o.sourceEvent,t)}),0)}})({zoomPanValues:h,onPanningChange:s,onPanZoomEnd:c});g.on("start",e),g.on("zoom",t),g.on("end",n)}g.filter((e=>(console.log(e),o(e))))},destroy:y,getViewport:()=>{const e=p?Ln(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}},setViewportConstrained:m,setScaleExtent:e=>{g?.scaleExtent(e)}}},Vo=e=>{let t;const n=new Set,o=(e,o)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=o?o:"object"!=typeof r)?r:Object.assign({},t,r),n.forEach((n=>n(t,e)))}},r=()=>t,i={setState:o,getState:r,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}};return t=e(o,r,i),i};function Uo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qo,Ko,Wo,Fo={exports:{}},Ho={},Go={exports:{}},Qo={};function Jo(){return Ko||(Ko=1,Go.exports=function(){if(qo)return Qo;qo=1;var e=n,t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),u=o({inst:{value:n,getSnapshot:t}}),l=u[0].inst,c=u[1];return i((function(){l.value=n,l.getSnapshot=t,s(l)&&c({inst:l})}),[e,n,t]),r((function(){return s(l)&&c({inst:l}),e((function(){s(l)&&c({inst:l})}))}),[e]),a(n),n};return Qo.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u,Qo}()),Go.exports}
2
2
  /**
3
3
  * @license React
4
4
  * use-sync-external-store-shim/with-selector.production.min.js
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */Fo.exports=function(){if(Wo)return Ho;Wo=1;var e=n,t=Jo(),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,s=e.useMemo,u=e.useDebugValue;return Ho.useSyncExternalStoreWithSelector=function(e,t,n,l,c){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=s((function(){function e(e){if(!a){if(a=!0,r=e,e=l(e),void 0!==c&&h.hasValue){var t=h.value;if(c(t,e))return i=t}return i=e}if(t=i,o(r,e))return t;var n=l(e);return void 0!==c&&c(t,n)?t:(r=e,i=n)}var r,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,l,c]);var f=r(e,d[0],d[1]);return a((function(){h.hasValue=!0,h.value=f}),[f]),u(f),f},Ho}();var er=Uo(Fo.exports);const{useSyncExternalStoreWithSelector:tr}=er;let nr=!1;const or=n.createContext(null),rr=or.Provider,ir=oo["001"]();function ar(e,t){const o=n.useContext(or);if(null===o)throw new Error(ir);return function(e,t=e.getState,o){o&&!nr&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),nr=!0);const r=tr(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}(o,e,t)}const sr=()=>{const e=n.useContext(or);if(null===e)throw new Error(ir);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},ur="undefined"!=typeof document?document:null;function lr(e,t={}){const o=void 0!==t.target?t.target:ur,[r,i]=n.useState(!1);return n.useEffect((()=>{if(!o)return;const t=t=>{t.key===e&&i(!0)},n=t=>{t.key===e&&i(!1)},r=()=>i(!1);return o.addEventListener("keydown",t),o.addEventListener("keyup",n),window.addEventListener("blur",r),window.addEventListener("contextmenu",r),()=>{o.removeEventListener("keydown",t),o.removeEventListener("keyup",n),window.removeEventListener("blur",r),window.addEventListener("contextmenu",r)}}),[e,o]),r}const cr="undefined"!=typeof window?window:void 0;function dr(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=dr(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const hr=({noPanClassName:e,panning:o,selection:r,minZoom:i,maxZoom:a,defaultViewport:s,translateExtent:u,children:l,onMove:c,onMoveStart:d,onMoveEnd:h,onPaneClick:f,onPaneMouseEnter:g,onPaneMouseMove:p,onPaneMouseLeave:m})=>{const y=sr(),v=n.useRef(null),x=n.useRef();return n.useEffect((()=>{if(!v.current)return;x.current=Zo({domNode:v.current,minZoom:i,maxZoom:a,translateExtent:u,viewport:s,panning:o,onTransformChange:e=>{y.setState({transform:e})},onPaneClick:f,onPanZoomStart:d,onPanZoom:c,onPanZoomEnd:h});const{x:e,y:t,zoom:n}=x.current.getViewport();return y.setState({transform:[e,t,n],domNode:v.current.closest(".react-diagram")}),()=>{x.current?.destroy()}}),[]),n.useEffect((()=>{x.current?.update({noPanClassName:e,selection:r})}),[e,r]),n.useEffect((()=>{x.current?.setScaleExtent([i,a])}),[i,a]),t.jsx("div",{ref:v,className:dr(["react-diagram__pane react-diagram__container",{selection:r}]),onMouseEnter:g,onMouseMove:p,onMouseLeave:m,children:l})},fr=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function gr({children:e}){const n=ar(fr);return t.jsx("div",{className:"react-diagram__viewport react-diagram__container",style:{transform:n},children:e})}function pr(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function mr({rect:e}){const{width:n,height:o,x:r,y:i}=e;return n&&o&&r&&i?t.jsx("div",{className:"react-diagram__drag-box react-diagram__container",style:{width:n,height:o,transform:`translate(${r}px, ${i}px)`}}):null}function yr(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);n(o,{...r})}}function vr({id:e,store:t,isSelectable:n,unselect:o=!1,nodeRef:r}){if(!n)return;const{addSelectedNodes:i,unselectNodes:a,multiSelectionActive:s,nodeInternals:u}=t.getState(),l=u.get(e);t.setState({selectionBoxActive:!1}),l.selected?(o||l.selected&&s)&&(a({nodes:[l]}),requestAnimationFrame((()=>r?.current?.blur()))):i([e])}const xr=({disabled:e,nodeRef:t,nodeId:o,isSelectable:r,noDragClassName:i})=>{const a=sr(),s=n.useRef(),[u,l]=n.useState(!1);return n.useEffect((()=>{s.current=Xo({getStore:()=>a.getState(),onNodeMouseDown:e=>{vr({id:e,store:a,nodeRef:t,isSelectable:r})},onDrag:(e,t,n,o)=>{const{onNodeDrag:r}=a.getState();r?.(e,n,o)},onDragStart:(e,t,n,o)=>{const{onNodeDragStart:r}=a.getState();r?.(e,n,o),l(!0)},onDragEnd:(e,t,n,o)=>{const{onNodeDragEnd:r}=a.getState();r?.(e,n,o),l(!1)}})}),[]),n.useEffect((()=>{if(e)s.current?.destroy();else if(t.current)return s.current?.update({noDragClassName:i,domNode:t.current,isSelectable:r,nodeId:o}),()=>{s.current?.destroy()}}),[i,e,r,t,o]),u};var br=n.memo((function({rect:e,transform:o}){const r=n.useRef(null);xr({nodeRef:r});const{width:i,height:a,x:s,y:u}=e;return t.jsx("div",{className:dr(["react-diagram__selection-box","react-diagram__container"]),style:{transform:o},children:t.jsx("div",{ref:r,className:"react-diagram__selection-box-rect",tabIndex:-1,style:{width:i,height:a,top:u,left:s}})})}));const wr=(e,t)=>{const n=e.find((e=>e.id===t.parentNode));if(n){const e=t.position.x+t.width-n.width,o=t.position.y+t.height-n.height;if(e>0||o>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,e>0&&(n.style.width+=e),o>0&&(n.style.height+=o),t.position.x<0){const e=Math.abs(t.position.x);n.position.x=n.position.x-e,n.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);n.position.y=n.position.y-e,n.style.height+=e,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}},_r=(e,t)=>{if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const o=e.filter((e=>e.id===n.id));if(0===o.length)return t.push(n),t;const r={...n};for(const e of o)if(e)switch(e.type){case"select":r.selected=e.selected;break;case"position":void 0!==e.position&&(r.position=e.position),void 0!==e.positionAbsolute&&(r.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(r.dragging=e.dragging),r.expandParent&&wr(t,r);break;case"dimensions":void 0!==e.dimensions&&(r.width=e.dimensions.width,r.height=e.dimensions.height),void 0!==e.updateStyle&&(r.style={...r.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(r.resizing=e.resizing),r.expandParent&&wr(t,r);break;case"intersect":r.intersected=e.intersected;break;case"remove":return t}return t.push(r),t}),n)};const Er=(e,t)=>({id:e,type:"select",selected:t});function Sr(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(Er(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(Er(n.id,!1))),e}),[])}const Nr=e=>t=>({id:t.id,type:e}),Pr=e=>{const{elementsSelectable:t,transform:n,selectionBoxActive:o,getNodes:r}=e,i=r().filter((e=>e.selected));return{elementsSelectable:t,selectionBoxRect:po(i,e.nodeOrigin),transformString:`translate(${n[0]}px,${n[1]}px) scale(${n[2]})`,selectionBoxActive:o}};function Mr({isSelecting:e,children:o}){const r=sr(),i=n.useRef(null),a=n.useRef(0),s=n.useRef(),{elementsSelectable:u,selectionBoxRect:l,transformString:c,selectionBoxActive:d}=ar(Pr,pr),[h,f]=n.useState({x:0,y:0}),[g,p]=n.useState({width:0,height:0,x:0,y:0}),[m,y]=n.useState(!1),v=()=>{r.setState({selectionBoxActive:a.current>0}),f({x:0,y:0}),p({width:0,height:0,x:0,y:0}),y(!1)},x=u&&e;return t.jsxs("div",{ref:i,className:dr(["react-diagram__container react-diagram__drag-selection",{active:x||m||d}]),onClick:x?e=>{e.target===i.current&&(r.getState().resetSelectedElements(),r.setState({selectionBoxActive:!1}),y(!1))}:void 0,onMouseDown:x?t=>{const{resetSelectedElements:n,domNode:o}=r.getState();if(s.current=o?.getBoundingClientRect(),!u||0!==t.button||t.target!==i.current||!s.current||!e)return;const{x:a,y:l}=Jn(t.nativeEvent,s.current);n(),p({width:0,height:0,x:a,y:l}),f({x:a,y:l})}:void 0,onMouseMove:x||m?e=>{const{nodeInternals:t,transform:n,nodeOrigin:o,getNodes:i,onNodesChange:u}=r.getState();if(!(h.x>0&&h.y>0)||!s.current)return;r.setState({selectionBoxActive:!1}),y(!0);const l=Jn(e.nativeEvent,s.current),c=h.x??0,d=h.y??0,f={x:l.x<c?l.x:c,y:l.y<d?l.y:d,width:Math.abs(l.x-c),height:Math.abs(l.y-d)},g=i(),m=go(t,f,n,!1,!0,o).map((e=>e.id));if(a.current!==m.length){a.current=m.length;const e=Sr(g,m);e.length&&u?.(e)}p(f)}:void 0,onMouseUp:u?e=>{0===e.button&&v()}:void 0,onMouseLeave:u?()=>{v()}:void 0,children:[o,m&&t.jsx(mr,{rect:g}),d&&t.jsx(br,{rect:l,transform:c})]})}const Cr=e=>{const{minZoom:t,maxZoom:n,translateExtent:o}=e;return{minZoom:t,maxZoom:n,translateExtent:o}};function kr({children:e,multiSelectionKeyCode:o,dragSelectionKeyCode:r,deleteKeyCode:i,noPanClassName:a,panning:s,defaultViewport:u,onMove:l,onMoveStart:c,onMoveEnd:d,onPaneClick:h,onPaneMouseEnter:f,onPaneMouseMove:g,onPaneMouseLeave:p}){(({deleteKeyCode:e="Backspace",multiSelectionKeyCode:t="Meta"})=>{const o=sr(),r=lr(t,{target:cr}),i=lr(e);n.useEffect((()=>{if(i){const{edges:e,getNodes:t,deleteElements:n}=o.getState();n({nodes:t().filter((e=>e.selected)),edges:e.filter((e=>e.selected))})}}),[i]),n.useEffect((()=>{o.setState({multiSelectionActive:r})}),[r])})({multiSelectionKeyCode:o,deleteKeyCode:i});const{minZoom:m,maxZoom:y,translateExtent:v}=ar(Cr),x=lr(r||"Shift"),b=s&&!x;return t.jsx(t.Fragment,{children:t.jsx(hr,{noPanClassName:a,panning:b,selection:x,minZoom:m,maxZoom:y,translateExtent:v,defaultViewport:u,onMove:l,onMoveStart:c,onMoveEnd:d,onPaneClick:h,onPaneMouseEnter:f,onPaneMouseMove:g,onPaneMouseLeave:p,children:t.jsx(Mr,{isSelecting:x,children:t.jsx(gr,{children:e})})})})}kr.displayName="DiagramRenderer";var Ar=n.memo(kr);const Br=e=>({nodesDraggable:e.nodesDraggable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError});function $r({nodeTypes:o,onNodeClick:r,onNodeMouseEnter:i,onNodeMouseMove:a,onNodeMouseLeave:s,onNodeContextMenu:u,onNodeDoubleClick:l,...c}){const{nodesDraggable:d,elementsSelectable:h,updateNodeDimensions:f,onError:g}=ar(Br,pr),p=ar(n.useCallback((e=>e.getNodes()),[])),m=n.useRef(),y=n.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));f(t)}));return m.current=e,e}),[]);return n.useEffect((()=>()=>{m?.current?.disconnect()}),[]),t.jsx("div",{className:"react-diagram__nodes react-diagram__container",children:p.map((n=>{const{data:f,type:p,id:m,className:v,style:x,width:b,height:w,ariaLabel:_,selectable:E,draggable:S,positionAbsolute:N,hidden:P,selected:M,intersected:C}=n;let k=p||"default";o[k]||(g?.("010",k),k="default");const A=o[k]||o.default,B={id:m,className:v,style:x,width:b??("default"===k?120:void 0),height:w??("default"===k?60:void 0),ariaLabel:_},$={onClick:r,onMouseEnter:i,onMouseMove:a,onMouseLeave:s,onContextMenu:u,onDoubleClick:l},I={positionX:N?.x||0,positionY:N?.y||0,sourcePosition:e.Position.Bottom,targetPosition:e.Position.Top},D={selected:!!M,intersected:!!C,hidden:P,isParent:!!n[Fn]?.isParent,initialized:!!n.width&&!!n.height};return t.jsx(A,{...c,...B,...I,...$,...D,zIndex:n[Fn]?.z??0,type:k,data:f,resizeObserver:y,nodesDraggable:d,elementsSelectable:h,selectable:E,draggable:S},m)}))})}$r.displayName="NodeRenderer";var Ir=n.memo($r);const Dr={[e.MarkerType.Arrow]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{stroke:e,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:n,fill:e,points:"-5,-4 0,0 -5,4 -5,-4"})};const Tr=({id:e,type:o,color:r,width:i=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:u,orient:l="auto-start-reverse"})=>{const c=function(e){const t=sr();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Dr,e)?Dr[e]:(t.getState().onError?.("022",e),null)),[e])}(o);return c?t.jsx("marker",{className:"react-diagram__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0",children:t.jsx(c,{color:r,strokeWidth:u})}):null},jr=({defaultColor:e,rfId:o})=>{const r=ar(n.useCallback((({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const i=yo(r,t);o.includes(i)||(n.push({id:i,color:r.color||e,...r}),o.push(i))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:o}),[e,o]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return t.jsx("defs",{children:r.map((e=>t.jsx(Tr,{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)))})};jr.displayName="MarkerComponent";var zr=n.memo(jr);var Rr=n.memo((function({x:e,y:o,label:r,labelStyle:i={},labelShowBg:a=!0,labelBgStyle:s={},labelBgPadding:u=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h}){const f=n.useRef(null),[g,p]=n.useState({x:0,y:0,width:0,height:0}),m=dr(["react-diagram__edge-text-wrapper",d]);return n.useEffect((()=>{if(f.current){const e=f.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[r]),void 0!==r&&r?t.jsxs("g",{transform:`translate(${e-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...h,children:[a&&t.jsx("rect",{width:g.width+2*u[0],x:-u[0],y:-u[1],height:g.height+2*u[1],className:"react-diagram__edge-text-bg",style:s,rx:l,ry:l}),t.jsx("text",{className:"react-diagram__edge-text",y:g.height/2,dy:"0.3em",ref:f,style:i,children:r}),c]}):null}));function Or({path:e,labelX:n,labelY:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l,style:c,markerEnd:d,markerStart:h}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{style:c,d:e,fill:"none",className:"react-diagram__edge-path",markerEnd:d,markerStart:h}),r&&lo(n)&&lo(o)?t.jsx(Rr,{x:n,y:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l}):null]})}Or.displayName="BaseEdge";const Xr=({sourceX:e,sourceY:n,targetX:o,targetY:r,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f})=>{const[g,p,m]=So({sourceX:e,sourceY:n,targetX:o,targetY:r});return t.jsx(Or,{path:g,labelX:p,labelY:m,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f})};Xr.displayName="StraightEdge";var Lr=n.memo(Xr);const Yr=({sourceX:n,sourceY:o,targetX:r,targetY:i,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:h,sourcePosition:f=e.Position.Bottom,targetPosition:g=e.Position.Top,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Eo({sourceX:n,sourceY:o,sourcePosition:f,targetX:r,targetY:i,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset});return t.jsx(Or,{path:v,labelX:x,labelY:b,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:m})};Yr.displayName="StepEdge";var Zr=n.memo(Yr);const Vr=({sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:a=e.Position.Bottom,targetPosition:s=e.Position.Top,label:u,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Co({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:s,curvature:y?.curvature});return t.jsx(Or,{path:v,labelX:x,labelY:b,label:u,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m})};Vr.displayName="BezierEdge";var Ur=n.memo(Vr);const qr=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,Kr=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,Wr="react-diagram__edge-updater";function Fr({position:e,centerX:n,centerY:o,radius:r=10,onMouseDown:i,type:a}){return t.jsx("circle",{className:dr([Wr,`${Wr}-${a}`]),cx:qr(n,r,e),cy:Kr(o,r,e),r:r,stroke:"transparent",fill:"transparent",onMouseDown:i})}function Hr(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}const Gr=e=>{const o=o=>{const{id:r,className:i,style:a,type:s,data:u,rfId:l,ariaLabel:c,source:d,sourcePort:h,target:f,targetPort:g,markerEnd:p,markerStart:m,label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:w,labelBgBorderRadius:_,edgeUpdaterRadius:E,sourceX:S,sourceY:N,targetX:P,targetY:M,sourcePosition:C,targetPosition:k,hidden:A,selected:B,focusable:$=!0,selectable:I=!0,elementsSelectable:D,onClick:T,onDoubleClick:j,onContextMenu:z,onMouseEnter:R,onMouseMove:O,onMouseLeave:X,onEdgeUpdate:L,onEdgeUpdateStart:Y,onEdgeUpdateEnd:Z}=o,V={sourceX:S,sourceY:N,targetX:P,targetY:M,sourcePosition:C,targetPosition:k},U={source:d,sourcePort:h,target:f,targetPort:g},q=!!(I||D&&void 0===I);if("react-diagram__connection"===i)return document.querySelector("path")?.classList.add("react-diagram__connection-path"),t.jsx(e,{...U,...V,id:r,data:u,style:a,selected:B});const K=sr(),W=n.useRef(null),[F,H]=n.useState(!1),G=n.useMemo((()=>`url(#${yo(m,l)})`),[m,l]),Q=n.useMemo((()=>`url(#${yo(p,l)})`),[p,l]);if(A)return null;const J=e=>t=>{if(0!==t.button)return;const{edges:n,domNode:i,autoPanOnConnect:a,connectionRadius:s,transform:u,getNodes:l,cancelConnection:c,updateConnection:d,onConnectStart:f,onConnectEnd:p,panBy:m}=K.getState(),y=o[e],v=n.find((e=>e.id===r)),x=("source"===e?h:g)||null;H(!0),Y?.(t,v,e);jo({isAnchor:!0,event:t.nativeEvent,nodeId:y,portId:x,portType:e,domNode:i,autoPanOnConnect:a,connectionRadius:s,nodes:l(),onEdgeUpdateEnd:t=>{H(!1),Z?.(t,v,e)},cancelConnection:c,updateConnection:d,onConnect:e=>L?.(v,e),onConnectStart:f,onConnectEnd:p,panBy:m,getTransform:()=>u})},ee=Hr(r,K.getState,j),te=Hr(r,K.getState,z),ne=Hr(r,K.getState,R),oe=Hr(r,K.getState,O),re=Hr(r,K.getState,X),ie=dr(["react-diagram__edge",`react-diagram__edge-${s}`,i,{selected:B,inactive:!D}]),ae={markerStart:G,markerEnd:Q},se={label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:w,labelBgBorderRadius:_},ue={onClick:e=>{const{edges:t,multiSelectionActive:n,addSelectedEdges:o,unselectEdges:i}=K.getState();if(q){const e=t.filter((e=>e.id===r));B?B&&n&&(i({edges:[...e]}),W.current?.blur()):o([r])}if(T){const n=t.find((e=>e.id===r));T(e,n)}},onDoubleClick:ee,onContextMenu:te,onMouseEnter:ne,onMouseMove:oe,onMouseLeave:re};return t.jsx("g",{...ue,ref:W,className:ie,tabIndex:$?0:void 0,role:$?"button":void 0,"aria-label":null===c?void 0:c||`Edge from ${d} to ${f}`,"aria-describedby":$?`react-diagram__edge-desc-${l}`:void 0,children:!F&&t.jsxs(t.Fragment,{children:[t.jsx(e,{...U,...ae,...se,...V,id:r,data:u,style:a,selected:B}),t.jsx(Fr,{position:C,centerX:S,centerY:N,radius:E,onMouseDown:J("target"),type:"source"}),t.jsx(Fr,{position:k,centerX:P,centerY:M,radius:E,onMouseDown:J("source"),type:"target"})]})})};return o.displayName="EdgeWrapper",n.memo(o)},Qr=e=>{const t={default:Gr(e.straight||Lr),step:Gr(e.step||Zr),bezier:Gr(e.bezier||Ur)},n=Object.keys(e).filter((e=>!Object.keys(t).includes(e))).reduce(((t,n)=>(t[n]=Gr(e[n]||Zr),t)),{});return{...t,...n}};function Jr(t,n,o=null){const r=(o?.x||0)+n.x,i=(o?.y||0)+n.y,a=o?.width||n.width,s=o?.height||n.height;switch(t){case e.Position.Top:return{x:r+a/2,y:i};case e.Position.Right:return{x:r+a,y:i+s/2};case e.Position.Bottom:return{x:r+a/2,y:i+s};case e.Position.Left:return{x:r,y:i+s/2}}}function ei(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function ti(e){const t=e?.[Fn]?.portBounds||null,n=t&&e?.width&&e?.height&&void 0!==e?.positionAbsolute?.x&&void 0!==e?.positionAbsolute?.y;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const ni=e=>({edges:e.edges,width:e.width,height:e.height,nodeInternals:e.nodeInternals,elementsSelectable:e.elementsSelectable,onError:e.onError});function oi({rfId:n,edgeTypes:o,noPanClassName:r,edgeUpdaterRadius:i,onEdgeClick:a,onEdgeDoubleClick:s,onEdgeContextMenu:u,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g}){const{edges:p,width:m,height:y,elementsSelectable:v,nodeInternals:x}=ar(ni,pr);return t.jsxs("svg",{width:m||"100vw",height:y||"100vh",className:"react-diagram__edges react-diagram__container",children:[t.jsx(zr,{defaultColor:"#000000",rfId:n}),t.jsx("g",{children:p.map((p=>{const{type:m,id:y,className:b,style:w,ariaLabel:_,source:E,sourcePort:S,target:N,targetPort:P,markerEnd:M,markerStart:C,label:k,labelStyle:A,labelShowBg:B,labelBgStyle:$,labelBgPadding:I,labelBgBorderRadius:D,...T}=p,[j,z,R]=ti(x.get(E)),[O,X,L]=ti(x.get(N));if(!R||!L)return null;const Y=m||"straight",Z=o[Y]||o.default,V=X.target,U=ei(z.source,S),q=ei(V,P),K=U?.position||e.Position.Bottom,W=q?.position||e.Position.Top;if(!U||!q)return null;const F={id:y,className:dr([b,r]),style:w,ariaLabel:_},H={source:E,sourcePort:S,target:N,targetPort:P},G={markerEnd:M,markerStart:C},Q={label:k,labelStyle:A,labelShowBg:B,labelBgStyle:$,labelBgPadding:I,labelBgBorderRadius:D},J=((e,t,n,o,r,i)=>{const a=Jr(n,e,t),s=Jr(i,o,r);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}})(j,U,K,O,q,W),ee={...J,sourcePosition:K,targetPosition:W},te={onClick:a,onDoubleClick:s,onContextMenu:u,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g};return t.jsx(Z,{...T,...F,...H,...G,...Q,...ee,...te,rfId:n,type:Y,elementsSelectable:v,edgeUpdaterRadius:i},y)}))})]})}oi.displayName="EdgeRenderer";var ri=n.memo(oi);const ii={[e.Position.Left]:e.Position.Right,[e.Position.Right]:e.Position.Left,[e.Position.Top]:e.Position.Bottom,[e.Position.Bottom]:e.Position.Top};function ai({nodeId:e,portType:o,edge:r,Component:i,EdgeWrapper:a}){const{fromNode:s,toX:u,toY:l,startPort:c}=ar(n.useCallback((t=>({fromNode:t.nodeInternals.get(e),startPort:t.connectionStartPort,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2]})),[e]),pr),d=s?.[Fn]?.portBounds,h=d?.[o];if(!s||!h)return null;const f=h.find((e=>e.id===c?.portId))||h[0],g=f?f.x+f.width/2:(s.width??0)/2,p=f?f.y+f.height/2:s.height??0,m=(s.positionAbsolute?.x??0)+g,y=(s.positionAbsolute?.y??0)+p,v=f?.position,x=v?ii[v]:null;if(!v||!x)return null;if(i)return t.jsx(i,{fromNode:s,fromPort:f,fromX:m,fromY:y,toX:u,toY:l,fromPosition:v,toPosition:x});if(!r){const e=`M${m},${y} ${u},${l}`;return t.jsx("path",{d:e,fill:"none",className:"react-diagram__connection-path"})}return t.jsx(a,{id:r.id,className:"react-diagram__connection",type:r.type||"default",source:r.source||e,target:r.target,focusable:!1,elementsSelectable:!1,sourceX:m,sourceY:y,targetX:u,targetY:l,sourcePosition:v,targetPosition:x})}ai.displayName="ConnectionPath";const si=e=>({edges:e.edges,connectionStartPort:e.connectionStartPort});function ui({containerStyle:e,edgeTypes:n,component:o}){const{connectionStartPort:r,edges:i}=ar(si,pr);if(!r)return null;const{nodeId:a,portType:s}=r;if(!!(!a||!s))return null;const u=i.find((e=>e[s]===a)),l=u?.type?n[u.type]:n.default;return t.jsx("svg",{style:e,className:"react-diagram__container react-diagram__connection-line",children:t.jsx("g",{className:"react-diagram__connection",children:t.jsx(ai,{nodeId:a,portType:s,edge:u,Component:o,EdgeWrapper:l})})})}function li({rfId:e,noPanClassName:n,panning:o,defaultViewport:r,multiSelectionKeyCode:i,dragSelectionKeyCode:a,deleteKeyCode:s,onlyRenderVisibleElements:u,disableKeyboardA11y:l,noDragClassName:c,nodeOrigin:d,nodeExtent:h,nodeTypes:f,onNodeClick:g,onNodeDoubleClick:p,onNodeContextMenu:m,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:x,edgeTypes:b,edgeUpdaterRadius:w,onEdgeClick:_,onEdgeDoubleClick:E,onEdgeContextMenu:S,onEdgeMouseEnter:N,onEdgeMouseMove:P,onEdgeMouseLeave:M,onEdgeUpdate:C,onEdgeUpdateStart:k,onEdgeUpdateEnd:A,onMove:B,onMoveStart:$,onMoveEnd:I,onPaneClick:D,onPaneMouseEnter:T,onPaneMouseMove:j,onPaneMouseLeave:z,ConnectionLineContainerStyle:R,ConnectionLineComponent:O}){return t.jsxs(Ar,{multiSelectionKeyCode:i,dragSelectionKeyCode:a,deleteKeyCode:s,noPanClassName:n,panning:o,defaultViewport:r,onMove:B,onMoveStart:$,onMoveEnd:I,onPaneClick:D,onPaneMouseEnter:T,onPaneMouseMove:j,onPaneMouseLeave:z,children:[t.jsx(Ir,{rfId:e,nodeTypes:f,onlyRenderVisibleElements:u,disableKeyboardA11y:l,nodeOrigin:d,nodeExtent:h,noDragClassName:c,noPanClassName:n,onNodeClick:g,onNodeDoubleClick:p,onNodeContextMenu:m,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:x}),t.jsx(ri,{rfId:e,edgeTypes:b,noPanClassName:n,edgeUpdaterRadius:w,onEdgeClick:_,onEdgeDoubleClick:E,onEdgeContextMenu:S,onEdgeMouseEnter:N,onEdgeMouseMove:P,onEdgeMouseLeave:M,onEdgeUpdate:C,onEdgeUpdateStart:k,onEdgeUpdateEnd:A}),t.jsx(ui,{edgeTypes:b,containerStyle:R,component:O})]})}li.displayName="DiagramView";var ci=n.memo(li);const di=Symbol.for("internals"),hi=e=>{const{setNodes:t,setEdges:n,setNodeExtent:o,setTranslateExtent:r,setMinZoom:i,setMaxZoom:a}=e;return{setNodes:t,setEdges:n,setNodeExtent:o,setTranslateExtent:r,setMinZoom:i,setMaxZoom:a}};function fi(e,t){n.useEffect((()=>{void 0!==e&&t(e)}),[e])}function gi(e,t,o){n.useEffect((()=>{void 0!==t&&o({[e]:t})}),[t])}const pi=({nodes:e,edges:t,nodeOrigin:n,smoothStep:o,centerStep:r,gridStep:i,elevateNodesOnSelect:a,nodesDraggable:s,autoPanOnNodeDrag:u,autoPanOnConnect:l,connectionRadius:c,nodeExtent:d,translateExtent:h,minZoom:f,maxZoom:g,onNodesChange:p,onNodeDrag:m,onNodeDragStart:y,onNodeDragEnd:v,onNodesDelete:x,onEdgesChange:b,onEdgesDelete:w,onConnect:_,onConnectStart:E,onConnectEnd:S,onError:N,onBeforeDelete:P,onDelete:M})=>{const{setNodes:C,setEdges:k,setNodeExtent:A,setTranslateExtent:B,setMinZoom:$,setMaxZoom:I}=ar(hi,pr),D=sr();return fi(e,C),fi(t,k),fi(d,A),fi(d,A),fi(h,B),fi(f,$),fi(g,I),gi("nodeOrigin",n,D.setState),gi("smoothStep",o,D.setState),gi("centerStep",r,D.setState),gi("gridStep",i,D.setState),gi("elevateNodesOnSelect",a,D.setState),gi("nodesDraggable",s,D.setState),gi("autoPanOnNodeDrag",u,D.setState),gi("autoPanOnConnect",l,D.setState),gi("connectionRadius",c,D.setState),gi("onNodesChange",p,D.setState),gi("onNodeDrag",m,D.setState),gi("onNodeDragStart",y,D.setState),gi("onNodeDragEnd",v,D.setState),gi("onNodesDelete",x,D.setState),gi("onEdgesChange",b,D.setState),gi("onEdgesDelete",w,D.setState),gi("onConnect",_,D.setState),gi("onConnectStart",E,D.setState),gi("onConnectEnd",S,D.setState),gi("onBeforeDelete",P,D.setState),gi("onDelete",M,D.setState),gi("onError",(e=>(t,n="")=>e?.(t,oo[t](n)))(N),D.setState),null};function mi(e,t){n.useRef(null);return n.useMemo((()=>t(e)),[e])}const yi=n.createContext(null),vi=yi.Provider;yi.Consumer;function xi({id:e,type:o,position:r}){const i=e||null,a=sr(),s=n.useContext(yi);if(!s)return null;const u=e=>{const{defaultEdgeOptions:t,onConnect:n}=a.getState(),o={...t,...e};n?.(o)},l=e=>{const t=Qn(e.nativeEvent),{button:n}=e;if(t&&0===n||!t){const{domNode:t,autoPanOnConnect:n,connectionRadius:r,transform:l,getNodes:c,cancelConnection:d,updateConnection:h,onConnectStart:f,onConnectEnd:g,panBy:p}=a.getState();jo({event:e.nativeEvent,nodeId:s,portId:i,portType:o,domNode:t,autoPanOnConnect:n,connectionRadius:r,nodes:c(),cancelConnection:d,updateConnection:h,onConnect:u,onConnectStart:f,onConnectEnd:g,panBy:p,getTransform:()=>l})}};return t.jsx("div",{"data-nodeid":s,"data-id":`${s}-${i}-${o}`,"data-portid":i,"data-port-position":r,className:`react-diagram__port react-diagram__port-${r} ${o} nodrag`,onMouseDown:l,onTouchStart:l})}xi.displayName="Port";var bi=n.memo(xi);function wi({data:n}){return t.jsxs(t.Fragment,{children:[t.jsx(bi,{type:"target",position:e.Position.Top}),n.label,t.jsx(bi,{type:"source",position:e.Position.Bottom})]})}const _i=e=>{function o({id:o,type:r="default",data:i,positionX:a,positionY:s,sourcePosition:u,targetPosition:l,onClick:c,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,onContextMenu:g,onDoubleClick:p,style:m,width:y,height:v,className:x,selected:b,intersected:w,hidden:_,draggable:E=!0,selectable:S=!0,resizeObserver:N,dragHandle:P,zIndex:M=0,isParent:C,initialized:k,disableKeyboardA11y:A,ariaLabel:B,rfId:$,nodesDraggable:I,elementsSelectable:D,noDragClassName:T,noPanClassName:j}){const z=sr(),R=z.getState().nodeInternals.get(o),O=n.useRef(null),X=n.useRef(u),L=n.useRef(l),Y=n.useRef(r),Z=!!(E||I&&void 0===E),V=!!(S||D&&void 0===S),U=Z||c||d||h||f;n.useEffect((()=>{if(O.current&&!_){const e=O.current;return N?.observe(e),()=>N?.unobserve(e)}}),[_]),n.useEffect((()=>{const e=Y.current!==r,t=X.current!==u,n=L.current!==l;O.current&&(e||t||n)&&(e&&(Y.current=r),t&&(X.current=u),n&&(L.current=l),z.getState().updateNodeDimensions([{id:o,nodeElement:O.current,forceUpdate:!0}]))}),[o,r,u,l]);const q=xr({nodeRef:O,nodeId:o,disabled:_||!Z,isSelectable:V,noDragClassName:T});if(_)return null;const K=dr(["react-diagram__node",`react-diagram__node-${r}`,{[j]:Z},x,{selected:b,intersected:w,parent:C,dragging:q}]),W={zIndex:M,transform:`translate(${a}px,${s}px)`,pointerEvents:U?"all":"none",visibility:k?"visible":"hidden",width:y,height:v,...m},F={onClick:e=>{Z||vr({id:o,store:z,nodeRef:O,isSelectable:V}),c&&c(e,{...R})},onDoubleClick:yr(o,z.getState,p),onContextMenu:yr(o,z.getState,g),onMouseEnter:yr(o,z.getState,d),onMouseMove:yr(o,z.getState,h),onMouseLeave:yr(o,z.getState,f)},H={positionX:a,positionY:s,sourcePosition:u,targetPosition:l};return t.jsx("div",{...F,ref:O,className:K,style:W,"data-id":o,tabIndex:0,role:"button","aria-describedby":A?void 0:`react-diagram__node-desc-${$}`,"aria-label":B,children:t.jsx(vi,{value:o,children:t.jsx(e,{...H,id:o,zIndex:M,type:r,data:i,dragHandle:P,selected:b,intersected:w})})})}return o.displayName="NodeWrapper",n.memo(o)},Ei=e=>{const t={default:_i(e.default||wi)},n=Object.keys(e).filter((e=>!Object.keys(t).includes(e))).reduce(((t,n)=>(t[n]=_i(e[n]||wi),t)),{});return{...t,...n}},Si=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ni={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],elementsSelectable:!0,onNodesChange:null,domNode:null,nodeOrigin:[0,0],smoothStep:!1,centerStep:!1,gridStep:void 0,elevateNodesOnSelect:!0,nodesDraggable:!0,multiSelectionActive:!1,selectionBoxActive:!1,d3Zoom:null,d3Selection:null,minZoom:.5,maxZoom:2,connectionPosition:{x:0,y:0},connectionStartPort:null,connectionEndPort:null,autoPanOnNodeDrag:!0,autoPanOnConnect:!0,nodeExtent:Si,translateExtent:Si,connectionRadius:20,onError:(e,t="")=>{}},Pi=()=>{return e=(e,t)=>({...Ni,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:i}=t();e({nodeInternals:Bo(n,o,r,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map((e=>({...o,...e})))})},updateNodeDimensions:n=>{const{triggerNodeChanges:o,nodeInternals:r,domNode:i,nodeOrigin:a}=t(),s=i?.querySelector(".react-diagram__viewport");if(!s)return;const u=window.getComputedStyle(s),{m22:l}=new window.DOMMatrixReadOnly(u.transform),c=[],d=[],h=n.reduce(((e,t)=>{const n=r.get(t.id);if(n){const o=Hn(t.nodeElement);if(o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)){const i={...n,[Fn]:{...n[Fn],portBounds:{id:n[Fn]?.portBounds?.id||null,source:Gn(".source",t.nodeElement,l,a),target:Gn(".target",t.nodeElement,l,a)}},...o};r.set(n.id,i);const s=$o(i,r);n.intersected!==s&&c.push({id:n.id,type:"intersect",intersected:s}),d.push({id:n.id,type:"position",dragging:!1,position:n.position,positionAbsolute:n.positionAbsolute}),e.push({id:n.id,type:"dimensions",dimensions:o})}}return e}),[]);e({nodeInternals:new Map(r)}),o([...h,...c,...d])},updateNodesPosition:(e,n=!1,o)=>{const{triggerNodeChanges:r}=t();r(e.map((e=>{const t={id:e.id,type:"position",dragging:n};return o?(o(e),{...t,position:e.position,positionAbsolute:e.positionAbsolute}):t})))},triggerNodeChanges:e=>{const{onNodesChange:n}=t();e?.length&&n?.(e)},triggerEdgeChanges:e=>{const{onEdgesChange:n}=t();e?.length&&n?.(e)},updateNodesIntersection:()=>{const{nodeInternals:e,triggerNodeChanges:n}=t(),o=Array.from(e.values()),r=[];o.forEach((t=>{const n=$o(t,e);t.intersected!==n&&r.push({id:t.id,type:"intersect",intersected:n})})),n(r)},addSelectedNodes:e=>{const{multiSelectionActive:n,getNodes:o,triggerNodeChanges:r}=t();let i;i=n?e.map((e=>Er(e,!0))):Sr(o(),e),r(i)},unselectNodes:({nodes:e}={})=>{const{getNodes:n,triggerNodeChanges:o}=t();o((e||n()).map((e=>(e.selected=!1,Er(e.id,!1)))))},addSelectedEdges:e=>{const{multiSelectionActive:n,getNodes:o,edges:r,triggerNodeChanges:i,triggerEdgeChanges:a}=t(),s=o();n?a(e.map((e=>Er(e,!0)))):(a(Sr(r,e)),i(Sr(s,[])))},unselectEdges:({edges:e}={})=>{const{edges:n,triggerEdgeChanges:o}=t();o((e||n).map((e=>(e.selected=!1,Er(e.id,!1)))))},resetSelectedElements:()=>{const{edges:e,getNodes:n,triggerNodeChanges:o,triggerEdgeChanges:r}=t(),i=n().filter((e=>e.selected)).map((e=>Er(e.id,!1))),a=e.filter((e=>e.selected)).map((e=>Er(e.id,!1)));o(i),r(a)},deleteElements:async e=>{const{edges:n,getNodes:o,onBeforeDelete:r,onDelete:i,onNodesDelete:a,onEdgesDelete:s,triggerNodeChanges:u,triggerEdgeChanges:l}=t(),c=o();await async function(e,t,n){const{nodes:o,edges:r}=t,{nodes:i,edges:a}=mo(e,{nodes:o,edges:r});function s(){const e=i.length>0,t=a.length>0;(e||t)&&n?.onDelete?.({nodes:i,edges:a})}if(i.length,a.length,!n?.onBeforeDelete)return s(),{edges:a,nodes:i};const u=await(n?.onBeforeDelete?.({nodes:i,edges:a}));return"boolean"==typeof u?(u&&s(),u?{edges:a,nodes:i}:{edges:[],nodes:[]}):u}(e,{nodes:c,edges:n},{onBeforeDelete:r,onDelete:({nodes:e,edges:t})=>{const n=e.length>0,o=t.length>0;if(n){const t=e.map(Nr("remove"));a?.(e),u(t)}if(o){const e=t.map(Nr("remove"));s?.(t),l(e)}i?.({nodes:e,edges:t})}})},cancelConnection:()=>e({connectionStartPort:null,connectionEndPort:null}),updateConnection:n=>{const{connectionPosition:o}=t(),r={...n,connectionPosition:n.connectionPosition??o};e(r)},panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:i,d3Selection:a}=t();if(!i||!a||!e.x&&!e.y)return;const s=On.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),u=[[0,0],[o,r]],l=i?.constrain()(s,u,Si);i.transform(a,l)},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=co(e.positionAbsolute,n)})),e({nodeExtent:n,nodeInternals:new Map(o)})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=t();o?.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=t();o?.scaleExtent([r,n]),e({maxZoom:n})}}),e?Vo(e):Vo;var e},Mi=({children:e})=>{const o=n.useRef(null);return o.current||(o.current=Pi()),t.jsx(rr,{value:o.current,children:e})};function Ci({children:e}){return n.useContext(or)?t.jsx(t.Fragment,{children:e}):t.jsx(Mi,{children:e})}Mi.displayName="ReactDiagramProvider",Ci.displayName="ReactDiagramWrapper";const ki={x:0,y:0,zoom:1},Ai=[0,0],Bi={default:wi},$i={step:Zr};function Ii({children:e,id:n,panning:o=!0,minZoom:r,maxZoom:i,translateExtent:a,nodeExtent:s=Si,defaultViewport:u=ki,multiSelectionKeyCode:l="Meta",dragSelectionKeyCode:c="Shift",deleteKeyCode:d="Backspace",onlyRenderVisibleElements:h=!1,disableKeyboardA11y:f=!1,noDragClassName:g="nodrag",noPanClassName:p="nopan",nodeOrigin:m=Ai,nodeTypes:y=Bi,edgeTypes:v=$i,edgeUpdaterRadius:x,ConnectionLineContainerStyle:b,ConnectionLineComponent:w,nodes:_,edges:E,nodesDraggable:S,elevateNodesOnSelect:N,autoPanOnNodeDrag:P,autoPanOnConnect:M,connectionRadius:C,smoothStep:k,centerStep:A,gridStep:B,onNodesChange:$,onNodeDrag:I,onNodeDragStart:D,onNodeDragEnd:T,onNodeClick:j,onNodeDoubleClick:z,onNodeContextMenu:R,onNodeMouseEnter:O,onNodeMouseMove:X,onNodeMouseLeave:L,onNodesDelete:Y,onEdgesChange:Z,onEdgeClick:V,onEdgeDoubleClick:U,onEdgeContextMenu:q,onEdgeMouseEnter:K,onEdgeMouseMove:W,onEdgeMouseLeave:F,onEdgeUpdate:H,onEdgeUpdateStart:G,onEdgeUpdateEnd:Q,onEdgesDelete:J,onConnect:ee,onConnectStart:te,onConnectEnd:ne,onDelete:oe,onBeforeDelete:re,onMove:ie,onMoveStart:ae,onMoveEnd:se,onPaneClick:ue,onPaneMouseEnter:le,onPaneMouseMove:ce,onPaneMouseLeave:de,onError:he,...fe},ge){const pe=n||"1",me=mi(y,Ei),ye=mi(v,Qr);return t.jsx("div",{...fe,ref:ge,className:"react-diagram",children:t.jsxs(Ci,{children:[t.jsx(ci,{rfId:pe,panning:o,defaultViewport:u,multiSelectionKeyCode:l,dragSelectionKeyCode:c,deleteKeyCode:d,onlyRenderVisibleElements:h,disableKeyboardA11y:f,noDragClassName:g,noPanClassName:p,nodeOrigin:m,nodeExtent:s,nodeTypes:me,edgeTypes:ye,edgeUpdaterRadius:x,ConnectionLineContainerStyle:b,ConnectionLineComponent:w,onNodeClick:j,onNodeDoubleClick:z,onNodeContextMenu:R,onNodeMouseEnter:O,onNodeMouseMove:X,onNodeMouseLeave:L,onEdgeClick:V,onEdgeDoubleClick:U,onEdgeContextMenu:q,onEdgeMouseEnter:K,onEdgeMouseMove:W,onEdgeMouseLeave:F,onEdgeUpdate:H,onEdgeUpdateStart:G,onEdgeUpdateEnd:Q,onMove:ie,onMoveStart:ae,onMoveEnd:se,onPaneClick:ue,onPaneMouseEnter:le,onPaneMouseMove:ce,onPaneMouseLeave:de}),t.jsx(pi,{rfId:pe,nodes:_,edges:E,nodesDraggable:S,elevateNodesOnSelect:N,autoPanOnNodeDrag:P,autoPanOnConnect:M,connectionRadius:C,nodeOrigin:m,nodeExtent:s,translateExtent:a,minZoom:r,maxZoom:i,smoothStep:k,centerStep:A,gridStep:B,onNodesChange:$,onNodeDrag:I,onNodeDragStart:D,onNodeDragEnd:T,onNodesDelete:Y,onEdgesChange:Z,onEdgesDelete:J,onConnect:ee,onConnectStart:te,onConnectEnd:ne,onError:he,onBeforeDelete:re,onDelete:oe}),e]})})}Ii.displayName="ReactDiagram";var Di=n.forwardRef(Ii);function Ti({color:e,scaledGap:n,lineWidth:o}){const r=`${`M${n[0]/2} 0`} ${`V${n[1]}`} ${"M0 "+n[1]/2} ${`H${n[0]}`}`;return t.jsx("path",{stroke:e,strokeWidth:o,d:r})}const ji=e=>({transform:e.transform,rfId:e.rfId,gridStepGap:e.gridStep});function zi({gap:e,lineWidth:o=1,color:r="#000000"}){const i=n.useRef(null),{transform:a,rfId:s,gridStepGap:u}=ar(ji,pr),l=e||(u||50),c=Array.isArray(l)?l:[l,l],d=[c[0]*a[2]||1,c[1]*a[2]||1],h=[d[0]/2,d[1]/2];return t.jsxs("svg",{className:"react-diagram__container react-diagram__background",ref:i,children:[t.jsx("pattern",{id:`background-${s}`,x:a[0]%d[0],y:a[1]%d[1],width:d[0],height:d[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${h[0]},-${h[1]})`,children:t.jsx(Ti,{scaledGap:d,color:r,lineWidth:o})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#background-${s})`})]})}zi.displayName="Background";var Ri=n.memo(zi);e.Background=Ri,e.BaseEdge=Or,e.BezierEdge=Ur,e.Port=bi,e.ReactDiagramProvider=Mi,e.StepEdge=Zr,e.addEdge=(e,t)=>{if(!ho(e))return t;if(((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourcePort!==e.sourcePort&&(t.sourcePort||e.sourcePort)||t.targetPort!==e.targetPort&&(t.targetPort||e.targetPort)))))(e,t))return t;let n;return null===e.sourcePort&&delete e.sourcePort,null===e.targetPort&&delete e.targetPort,n=e.id?{...e}:{...e,id:xo(e)},t.concat(n)},e.boxToRect=uo,e.clamp=ro,e.default=Di,e.getBezierEdgeCenter=No,e.getBezierPath=Co,e.getStepPath=Eo,e.getStraightPath=So,e.internalsSymbol=di,e.isCoreEdge=ho,e.isCoreNode=e=>"id"in e&&!("source"in e)&&!("target"in e),e.rectToBox=so,e.updateEdge=(e,t,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=e;!t.source||t.target,n.find((e=>e.id===r));const a={...i,id:o.shouldReplaceId?xo(t):r,source:t.source,target:t.target};return n.filter((e=>e.id!==r)).concat(a)},e.useEdgesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>function(e,t){return _r(e,t)}(e,t)))),[]);return[t,o,r]},e.useNodesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>function(e,t){return _r(e,t)}(e,t)))),[]);return[t,o,r]},e.useStore=ar,e.useStoreApi=sr,Object.defineProperty(e,"__esModule",{value:!0})}));
10
+ */Fo.exports=function(){if(Wo)return Ho;Wo=1;var e=n,t=Jo(),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,s=e.useMemo,u=e.useDebugValue;return Ho.useSyncExternalStoreWithSelector=function(e,t,n,l,c){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=s((function(){function e(e){if(!a){if(a=!0,r=e,e=l(e),void 0!==c&&h.hasValue){var t=h.value;if(c(t,e))return i=t}return i=e}if(t=i,o(r,e))return t;var n=l(e);return void 0!==c&&c(t,n)?t:(r=e,i=n)}var r,i,a=!1,s=void 0===n?null:n;return[function(){return e(t())},null===s?void 0:function(){return e(s())}]}),[t,n,l,c]);var f=r(e,d[0],d[1]);return a((function(){h.hasValue=!0,h.value=f}),[f]),u(f),f},Ho}();var er=Uo(Fo.exports);const{useSyncExternalStoreWithSelector:tr}=er;let nr=!1;const or=n.createContext(null),rr=or.Provider,ir=oo["001"]();function ar(e,t){const o=n.useContext(or);if(null===o)throw new Error(ir);return function(e,t=e.getState,o){o&&!nr&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),nr=!0);const r=tr(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}(o,e,t)}const sr=()=>{const e=n.useContext(or);if(null===e)throw new Error(ir);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},ur="undefined"!=typeof document?document:null;function lr(e,t={}){const o=void 0!==t.target?t.target:ur,[r,i]=n.useState(!1);return n.useEffect((()=>{if(!o)return;const t=t=>{t.key===e&&i(!0)},n=t=>{t.key===e&&i(!1)},r=()=>i(!1);return o.addEventListener("keydown",t),o.addEventListener("keyup",n),window.addEventListener("blur",r),window.addEventListener("contextmenu",r),()=>{o.removeEventListener("keydown",t),o.removeEventListener("keyup",n),window.removeEventListener("blur",r),window.addEventListener("contextmenu",r)}}),[e,o]),r}const cr="undefined"!=typeof window?window:void 0;function dr(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=dr(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const hr=({noPanClassName:e,panning:o,selection:r,minZoom:i,maxZoom:a,defaultViewport:s,translateExtent:u,children:l,onMove:c,onMoveStart:d,onMoveEnd:h,onPaneClick:f,onPaneMouseEnter:g,onPaneMouseMove:p,onPaneMouseLeave:m})=>{const y=sr(),v=n.useRef(null),x=n.useRef();return n.useEffect((()=>{if(!v.current)return;x.current=Zo({domNode:v.current,minZoom:i,maxZoom:a,translateExtent:u,viewport:s,panning:o,onTransformChange:e=>{y.setState({transform:e})},onPaneClick:f,onPanZoomStart:d,onPanZoom:c,onPanZoomEnd:h});const{x:e,y:t,zoom:n}=x.current.getViewport();return y.setState({transform:[e,t,n],domNode:v.current.closest(".react-diagram")}),()=>{x.current?.destroy()}}),[]),n.useEffect((()=>{x.current?.update({noPanClassName:e,selection:r})}),[e,r]),n.useEffect((()=>{x.current?.setScaleExtent([i,a])}),[i,a]),t.jsx("div",{ref:v,className:dr(["react-diagram__pane react-diagram__container",{selection:r}]),onMouseEnter:g,onMouseMove:p,onMouseLeave:m,children:l})},fr=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function gr({children:e}){const n=ar(fr);return t.jsx("div",{className:"react-diagram__viewport react-diagram__container",style:{transform:n},children:e})}function pr(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||!Object.is(e[n[o]],t[n[o]]))return!1;return!0}function mr({rect:e}){const{width:n,height:o,x:r,y:i}=e;return n&&o&&r&&i?t.jsx("div",{className:"react-diagram__drag-box react-diagram__container",style:{width:n,height:o,transform:`translate(${r}px, ${i}px)`}}):null}function yr(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);n(o,{...r})}}function vr({id:e,store:t,isSelectable:n,unselect:o=!1,nodeRef:r}){if(!n)return;const{addSelectedNodes:i,unselectNodes:a,multiSelectionActive:s,nodeInternals:u}=t.getState(),l=u.get(e);t.setState({selectionBoxActive:!1}),l.selected?(o||l.selected&&s)&&(a({nodes:[l]}),requestAnimationFrame((()=>r?.current?.blur()))):i([e])}const xr=({disabled:e,nodeRef:t,nodeId:o,isSelectable:r,noDragClassName:i})=>{const a=sr(),s=n.useRef(),[u,l]=n.useState(!1);return n.useEffect((()=>{s.current=Lo({getStore:()=>a.getState(),onNodeMouseDown:e=>{vr({id:e,store:a,nodeRef:t,isSelectable:r})},onDrag:(e,t,n,o)=>{const{onNodeDrag:r}=a.getState();r?.(e,n,o)},onDragStart:(e,t,n,o)=>{const{onNodeDragStart:r}=a.getState();r?.(e,n,o),l(!0)},onDragEnd:(e,t,n,o)=>{const{onNodeDragEnd:r}=a.getState();r?.(e,n,o),l(!1)}})}),[]),n.useEffect((()=>{if(e)s.current?.destroy();else if(t.current)return s.current?.update({noDragClassName:i,domNode:t.current,isSelectable:r,nodeId:o}),()=>{s.current?.destroy()}}),[i,e,r,t,o]),u};var br=n.memo((function({rect:e,transform:o}){const r=n.useRef(null);xr({nodeRef:r});const{width:i,height:a,x:s,y:u}=e;return t.jsx("div",{className:dr(["react-diagram__selection-box","react-diagram__container"]),style:{transform:o},children:t.jsx("div",{ref:r,className:"react-diagram__selection-box-rect",tabIndex:-1,style:{width:i,height:a,top:u,left:s}})})}));const wr=(e,t)=>{const n=e.find((e=>e.id===t.parentNode));if(n){const e=t.position.x+t.width-n.width,o=t.position.y+t.height-n.height;if(e>0||o>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,e>0&&(n.style.width+=e),o>0&&(n.style.height+=o),t.position.x<0){const e=Math.abs(t.position.x);n.position.x=n.position.x-e,n.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);n.position.y=n.position.y-e,n.style.height+=e,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}},_r=(e,t)=>{if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const o=e.filter((e=>e.id===n.id));if(0===o.length)return t.push(n),t;const r={...n};for(const e of o)if(e)switch(e.type){case"select":r.selected=e.selected;break;case"position":void 0!==e.position&&(r.position=e.position),void 0!==e.positionAbsolute&&(r.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(r.dragging=e.dragging),r.expandParent&&wr(t,r);break;case"dimensions":void 0!==e.dimensions&&(r.width=e.dimensions.width,r.height=e.dimensions.height),void 0!==e.updateStyle&&(r.style={...r.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(r.resizing=e.resizing),r.expandParent&&wr(t,r);break;case"intersect":r.intersected=e.intersected;break;case"remove":return t}return t.push(r),t}),n)};const Er=(e,t)=>({id:e,type:"select",selected:t});function Sr(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(Er(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(Er(n.id,!1))),e}),[])}const Nr=e=>t=>({id:t.id,type:e}),Pr=e=>{const{elementsSelectable:t,transform:n,selectionBoxActive:o,getNodes:r}=e,i=r().filter((e=>e.selected));return{elementsSelectable:t,selectionBoxRect:po(i,e.nodeOrigin),transformString:`translate(${n[0]}px,${n[1]}px) scale(${n[2]})`,selectionBoxActive:o}};function Mr({isSelecting:e,children:o}){const r=sr(),i=n.useRef(null),a=n.useRef(0),s=n.useRef(),{elementsSelectable:u,selectionBoxRect:l,transformString:c,selectionBoxActive:d}=ar(Pr,pr),h=n.useRef({x:0,y:0}),f=n.useRef(!1),[g,p]=n.useState({width:0,height:0,x:0,y:0}),[m,y]=n.useState(!1),v=()=>{r.setState({selectionBoxActive:a.current>0}),h.current={x:0,y:0},f.current=!1,p({width:0,height:0,x:0,y:0}),y(!1)},x=u&&e;return t.jsxs("div",{ref:i,className:dr(["react-diagram__container react-diagram__drag-selection",{active:x||m||d}]),onClick:x&&m?e=>{e.target===i.current&&(r.getState().resetSelectedElements(),r.setState({selectionBoxActive:!1}),y(!1))}:void 0,onMouseDown:x?t=>{const{resetSelectedElements:n,domNode:o}=r.getState();if(s.current=o?.getBoundingClientRect(),!u||0!==t.button||t.target!==i.current||!s.current||!e)return;const{x:a,y:l}=Jn(t.nativeEvent,s.current);n(),p({width:0,height:0,x:a,y:l}),h.current={x:a,y:l},f.current=!0}:void 0,onMouseMove:x||m?e=>{const{nodeInternals:t,transform:n,nodeOrigin:o,getNodes:i,onNodesChange:u}=r.getState();if(!f.current||!s.current)return;d&&r.setState({selectionBoxActive:!1}),y(!0);const l=Jn(e.nativeEvent,s.current),c=h.current.x,g=h.current.y,m={x:l.x<c?l.x:c,y:l.y<g?l.y:g,width:Math.abs(l.x-c),height:Math.abs(l.y-g)},v=i(),x=go(t,m,n,!1,!0,o).map((e=>e.id));if(a.current!==x.length){a.current=x.length;const e=Sr(v,x);e.length&&u?.(e)}p(m)}:void 0,onMouseUp:u?e=>{if(0===e.button){if(f.current&&i.current){const e=i.current,t=n=>{n.stopPropagation(),e.removeEventListener("click",t,!0)};e.addEventListener("click",t,!0)}v()}}:void 0,onMouseLeave:u?()=>{v()}:void 0,children:[o,m&&t.jsx(mr,{rect:g}),d&&t.jsx(br,{rect:l,transform:c})]})}const Cr=e=>{const{minZoom:t,maxZoom:n,translateExtent:o}=e;return{minZoom:t,maxZoom:n,translateExtent:o}};function kr({children:e,multiSelectionKeyCode:o,dragSelectionKeyCode:r,deleteKeyCode:i,noPanClassName:a,panning:s,defaultViewport:u,onMove:l,onMoveStart:c,onMoveEnd:d,onPaneClick:h,onPaneMouseEnter:f,onPaneMouseMove:g,onPaneMouseLeave:p}){(({deleteKeyCode:e="Backspace",multiSelectionKeyCode:t="Meta"})=>{const o=sr(),r=lr(t,{target:cr}),i=lr(e);n.useEffect((()=>{if(i){const{edges:e,getNodes:t,deleteElements:n}=o.getState();n({nodes:t().filter((e=>e.selected)),edges:e.filter((e=>e.selected))})}}),[i]),n.useEffect((()=>{o.setState({multiSelectionActive:r})}),[r])})({multiSelectionKeyCode:o,deleteKeyCode:i});const{minZoom:m,maxZoom:y,translateExtent:v}=ar(Cr),x=lr(r),b=s&&!x;return t.jsx(t.Fragment,{children:t.jsx(hr,{noPanClassName:a,panning:b,selection:x,minZoom:m,maxZoom:y,translateExtent:v,defaultViewport:u,onMove:l,onMoveStart:c,onMoveEnd:d,onPaneClick:h,onPaneMouseEnter:f,onPaneMouseMove:g,onPaneMouseLeave:p,children:t.jsx(Mr,{isSelecting:x,children:t.jsx(gr,{children:e})})})})}kr.displayName="DiagramRenderer";var Ar=n.memo(kr);const Br=e=>({nodesDraggable:e.nodesDraggable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError});function $r({nodeTypes:o,onNodeClick:r,onNodeMouseEnter:i,onNodeMouseMove:a,onNodeMouseLeave:s,onNodeContextMenu:u,onNodeDoubleClick:l,...c}){const{nodesDraggable:d,elementsSelectable:h,updateNodeDimensions:f,onError:g}=ar(Br,pr),p=ar(n.useCallback((e=>e.getNodes()),[])),m=n.useRef(),y=n.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));f(t)}));return m.current=e,e}),[]);return n.useEffect((()=>()=>{m?.current?.disconnect()}),[]),t.jsx("div",{className:"react-diagram__nodes react-diagram__container",children:p.map((n=>{const{data:f,type:p,id:m,className:v,style:x,width:b,height:w,ariaLabel:_,selectable:E,draggable:S,positionAbsolute:N,hidden:P,selected:M,intersected:C}=n;let k=p||"default";o[k]||(g?.("010",k),k="default");const A=o[k]||o.default,B={id:m,className:v,style:x,width:b??("default"===k?120:void 0),height:w??("default"===k?60:void 0),ariaLabel:_},$={onClick:r,onMouseEnter:i,onMouseMove:a,onMouseLeave:s,onContextMenu:u,onDoubleClick:l},I={positionX:N?.x||0,positionY:N?.y||0,sourcePosition:e.Position.Bottom,targetPosition:e.Position.Top},D={selected:!!M,intersected:!!C,hidden:P,isParent:!!n[Fn]?.isParent,initialized:!!n.width&&!!n.height};return t.jsx(A,{...c,...B,...I,...$,...D,zIndex:n[Fn]?.z??0,type:k,data:f,resizeObserver:y,nodesDraggable:d,elementsSelectable:h,selectable:E,draggable:S},m)}))})}$r.displayName="NodeRenderer";var Ir=n.memo($r);const Dr={[e.MarkerType.Arrow]:({color:e="none",strokeWidth:n=1})=>t.jsx("polyline",{stroke:e,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:n,fill:e,points:"-5,-4 0,0 -5,4 -5,-4"})};const Tr=({id:e,type:o,color:r,width:i=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:u,orient:l="auto-start-reverse"})=>{const c=function(e){const t=sr();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Dr,e)?Dr[e]:(t.getState().onError?.("022",e),null)),[e])}(o);return c?t.jsx("marker",{className:"react-diagram__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0",children:t.jsx(c,{color:r,strokeWidth:u})}):null},jr=({defaultColor:e,rfId:o})=>{const r=ar(n.useCallback((({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const i=yo(r,t);o.includes(i)||(n.push({id:i,color:r.color||e,...r}),o.push(i))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:o}),[e,o]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return t.jsx("defs",{children:r.map((e=>t.jsx(Tr,{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)))})};jr.displayName="MarkerComponent";var Rr=n.memo(jr);var zr=n.memo((function({x:e,y:o,label:r,labelStyle:i={},labelShowBg:a=!0,labelBgStyle:s={},labelBgPadding:u=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h}){const f=n.useRef(null),[g,p]=n.useState({x:0,y:0,width:0,height:0}),m=dr(["react-diagram__edge-text-wrapper",d]);return n.useEffect((()=>{if(f.current){const e=f.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[r]),void 0!==r&&r?t.jsxs("g",{transform:`translate(${e-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...h,children:[a&&t.jsx("rect",{width:g.width+2*u[0],x:-u[0],y:-u[1],height:g.height+2*u[1],className:"react-diagram__edge-text-bg",style:s,rx:l,ry:l}),t.jsx("text",{className:"react-diagram__edge-text",y:g.height/2,dy:"0.3em",ref:f,style:i,children:r}),c]}):null}));function Or({path:e,labelX:n,labelY:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l,style:c,markerEnd:d,markerStart:h}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{style:c,d:e,fill:"none",className:"react-diagram__edge-path",markerEnd:d,markerStart:h}),r&&lo(n)&&lo(o)?t.jsx(zr,{x:n,y:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l}):null]})}Or.displayName="BaseEdge";const Lr=({sourceX:e,sourceY:n,targetX:o,targetY:r,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f})=>{const[g,p,m]=So({sourceX:e,sourceY:n,targetX:o,targetY:r});return t.jsx(Or,{path:g,labelX:p,labelY:m,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f})};Lr.displayName="StraightEdge";var Xr=n.memo(Lr);const Yr=({sourceX:n,sourceY:o,targetX:r,targetY:i,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:h,sourcePosition:f=e.Position.Bottom,targetPosition:g=e.Position.Top,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Eo({sourceX:n,sourceY:o,sourcePosition:f,targetX:r,targetY:i,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset});return t.jsx(Or,{path:v,labelX:x,labelY:b,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:m})};Yr.displayName="StepEdge";var Zr=n.memo(Yr);const Vr=({sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:a=e.Position.Bottom,targetPosition:s=e.Position.Top,label:u,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Co({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:s,curvature:y?.curvature});return t.jsx(Or,{path:v,labelX:x,labelY:b,label:u,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m})};Vr.displayName="BezierEdge";var Ur=n.memo(Vr);const qr=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,Kr=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,Wr="react-diagram__edge-updater";function Fr({position:e,centerX:n,centerY:o,radius:r=10,onMouseDown:i,type:a}){return t.jsx("circle",{className:dr([Wr,`${Wr}-${a}`]),cx:qr(n,r,e),cy:Kr(o,r,e),r:r,stroke:"transparent",fill:"transparent",onMouseDown:i})}function Hr(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}const Gr=e=>{const o=o=>{const{id:r,className:i,style:a,type:s,data:u,rfId:l,ariaLabel:c,source:d,sourcePort:h,target:f,targetPort:g,markerEnd:p,markerStart:m,label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:w,labelBgBorderRadius:_,edgeUpdaterRadius:E,sourceX:S,sourceY:N,targetX:P,targetY:M,sourcePosition:C,targetPosition:k,hidden:A,selected:B,focusable:$=!0,selectable:I=!0,elementsSelectable:D,onClick:T,onDoubleClick:j,onContextMenu:R,onMouseEnter:z,onMouseMove:O,onMouseLeave:L,onEdgeUpdate:X,onEdgeUpdateStart:Y,onEdgeUpdateEnd:Z}=o,V={sourceX:S,sourceY:N,targetX:P,targetY:M,sourcePosition:C,targetPosition:k},U={source:d,sourcePort:h,target:f,targetPort:g},q=!!(I||D&&void 0===I);if("react-diagram__connection"===i)return document.querySelector("path")?.classList.add("react-diagram__connection-path"),t.jsx(e,{...U,...V,id:r,data:u,style:a,selected:B});const K=sr(),W=n.useRef(null),[F,H]=n.useState(!1),G=n.useMemo((()=>`url(#${yo(m,l)})`),[m,l]),Q=n.useMemo((()=>`url(#${yo(p,l)})`),[p,l]);if(A)return null;const J=e=>t=>{if(0!==t.button)return;const{edges:n,domNode:i,autoPanOnConnect:a,connectionRadius:s,transform:u,getNodes:l,cancelConnection:c,updateConnection:d,onConnectStart:f,onConnectEnd:p,panBy:m}=K.getState(),y=o[e],v=n.find((e=>e.id===r)),x=("source"===e?h:g)||null;H(!0),Y?.(t,v,e);jo({isAnchor:!0,event:t.nativeEvent,nodeId:y,portId:x,portType:e,domNode:i,autoPanOnConnect:a,connectionRadius:s,nodes:l(),onEdgeUpdateEnd:t=>{H(!1),Z?.(t,v,e)},cancelConnection:c,updateConnection:d,onConnect:e=>X?.(v,e),onConnectStart:f,onConnectEnd:p,panBy:m,getTransform:()=>u})},ee=Hr(r,K.getState,j),te=Hr(r,K.getState,R),ne=Hr(r,K.getState,z),oe=Hr(r,K.getState,O),re=Hr(r,K.getState,L),ie=dr(["react-diagram__edge",`react-diagram__edge-${s}`,i,{selected:B,inactive:!D}]),ae={markerStart:G,markerEnd:Q},se={label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:w,labelBgBorderRadius:_},ue={onClick:e=>{const{edges:t,multiSelectionActive:n,addSelectedEdges:o,unselectEdges:i}=K.getState();if(q){const e=t.filter((e=>e.id===r));B?B&&n&&(i({edges:[...e]}),W.current?.blur()):o([r])}if(T){const n=t.find((e=>e.id===r));T(e,n)}},onDoubleClick:ee,onContextMenu:te,onMouseEnter:ne,onMouseMove:oe,onMouseLeave:re};return t.jsx("g",{...ue,ref:W,className:ie,tabIndex:$?0:void 0,role:$?"button":void 0,"aria-label":null===c?void 0:c||`Edge from ${d} to ${f}`,"aria-describedby":$?`react-diagram__edge-desc-${l}`:void 0,children:!F&&t.jsxs(t.Fragment,{children:[t.jsx(e,{...U,...ae,...se,...V,id:r,data:u,style:a,selected:B}),t.jsx(Fr,{position:C,centerX:S,centerY:N,radius:E,onMouseDown:J("target"),type:"source"}),t.jsx(Fr,{position:k,centerX:P,centerY:M,radius:E,onMouseDown:J("source"),type:"target"})]})})};return o.displayName="EdgeWrapper",n.memo(o)},Qr=e=>{const t={default:Gr(e.straight||Xr),step:Gr(e.step||Zr),bezier:Gr(e.bezier||Ur)},n=Object.keys(e).filter((e=>!Object.keys(t).includes(e))).reduce(((t,n)=>(t[n]=Gr(e[n]||Zr),t)),{});return{...t,...n}};function Jr(t,n,o=null){const r=(o?.x||0)+n.x,i=(o?.y||0)+n.y,a=o?.width||n.width,s=o?.height||n.height;switch(t){case e.Position.Top:return{x:r+a/2,y:i};case e.Position.Right:return{x:r+a,y:i+s/2};case e.Position.Bottom:return{x:r+a/2,y:i+s};case e.Position.Left:return{x:r,y:i+s/2}}}function ei(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function ti(e){const t=e?.[Fn]?.portBounds||null,n=t&&e?.width&&e?.height&&void 0!==e?.positionAbsolute?.x&&void 0!==e?.positionAbsolute?.y;return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const ni=e=>({edges:e.edges,width:e.width,height:e.height,nodeInternals:e.nodeInternals,elementsSelectable:e.elementsSelectable,onError:e.onError});function oi({rfId:n,edgeTypes:o,noPanClassName:r,edgeUpdaterRadius:i,onEdgeClick:a,onEdgeDoubleClick:s,onEdgeContextMenu:u,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g}){const{edges:p,width:m,height:y,elementsSelectable:v,nodeInternals:x}=ar(ni,pr);return t.jsxs("svg",{width:m||"100vw",height:y||"100vh",className:"react-diagram__edges react-diagram__container",children:[t.jsx(Rr,{defaultColor:"#000000",rfId:n}),t.jsx("g",{children:p.map((p=>{const{type:m,id:y,className:b,style:w,ariaLabel:_,source:E,sourcePort:S,target:N,targetPort:P,markerEnd:M,markerStart:C,label:k,labelStyle:A,labelShowBg:B,labelBgStyle:$,labelBgPadding:I,labelBgBorderRadius:D,...T}=p,[j,R,z]=ti(x.get(E)),[O,L,X]=ti(x.get(N));if(!z||!X)return null;const Y=m||"straight",Z=o[Y]||o.default,V=L.target,U=ei(R.source,S),q=ei(V,P),K=U?.position||e.Position.Bottom,W=q?.position||e.Position.Top;if(!U||!q)return null;const F={id:y,className:dr([b,r]),style:w,ariaLabel:_},H={source:E,sourcePort:S,target:N,targetPort:P},G={markerEnd:M,markerStart:C},Q={label:k,labelStyle:A,labelShowBg:B,labelBgStyle:$,labelBgPadding:I,labelBgBorderRadius:D},J=((e,t,n,o,r,i)=>{const a=Jr(n,e,t),s=Jr(i,o,r);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}})(j,U,K,O,q,W),ee={...J,sourcePosition:K,targetPosition:W},te={onClick:a,onDoubleClick:s,onContextMenu:u,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g};return t.jsx(Z,{...T,...F,...H,...G,...Q,...ee,...te,rfId:n,type:Y,elementsSelectable:v,edgeUpdaterRadius:i},y)}))})]})}oi.displayName="EdgeRenderer";var ri=n.memo(oi);const ii={[e.Position.Left]:e.Position.Right,[e.Position.Right]:e.Position.Left,[e.Position.Top]:e.Position.Bottom,[e.Position.Bottom]:e.Position.Top};function ai({nodeId:e,portType:o,edge:r,Component:i,EdgeWrapper:a}){const{fromNode:s,toX:u,toY:l,startPort:c}=ar(n.useCallback((t=>({fromNode:t.nodeInternals.get(e),startPort:t.connectionStartPort,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2]})),[e]),pr),d=s?.[Fn]?.portBounds,h=d?.[o];if(!s||!h)return null;const f=h.find((e=>e.id===c?.portId))||h[0],g=f?f.x+f.width/2:(s.width??0)/2,p=f?f.y+f.height/2:s.height??0,m=(s.positionAbsolute?.x??0)+g,y=(s.positionAbsolute?.y??0)+p,v=f?.position,x=v?ii[v]:null;if(!v||!x)return null;if(i)return t.jsx(i,{fromNode:s,fromPort:f,fromX:m,fromY:y,toX:u,toY:l,fromPosition:v,toPosition:x});if(!r){const e=`M${m},${y} ${u},${l}`;return t.jsx("path",{d:e,fill:"none",className:"react-diagram__connection-path"})}return t.jsx(a,{id:r.id,className:"react-diagram__connection",type:r.type||"default",source:r.source||e,target:r.target,focusable:!1,elementsSelectable:!1,sourceX:m,sourceY:y,targetX:u,targetY:l,sourcePosition:v,targetPosition:x})}ai.displayName="ConnectionPath";const si=e=>({edges:e.edges,connectionStartPort:e.connectionStartPort});function ui({containerStyle:e,edgeTypes:n,component:o}){const{connectionStartPort:r,edges:i}=ar(si,pr);if(!r)return null;const{nodeId:a,portType:s}=r;if(!!(!a||!s))return null;const u=i.find((e=>e[s]===a)),l=u?.type?n[u.type]:n.default;return t.jsx("svg",{style:e,className:"react-diagram__container react-diagram__connection-line",children:t.jsx("g",{className:"react-diagram__connection",children:t.jsx(ai,{nodeId:a,portType:s,edge:u,Component:o,EdgeWrapper:l})})})}function li({rfId:e,noPanClassName:n,panning:o,defaultViewport:r,multiSelectionKeyCode:i,dragSelectionKeyCode:a,deleteKeyCode:s,onlyRenderVisibleElements:u,disableKeyboardA11y:l,noDragClassName:c,nodeOrigin:d,nodeExtent:h,nodeTypes:f,onNodeClick:g,onNodeDoubleClick:p,onNodeContextMenu:m,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:x,edgeTypes:b,edgeUpdaterRadius:w,onEdgeClick:_,onEdgeDoubleClick:E,onEdgeContextMenu:S,onEdgeMouseEnter:N,onEdgeMouseMove:P,onEdgeMouseLeave:M,onEdgeUpdate:C,onEdgeUpdateStart:k,onEdgeUpdateEnd:A,onMove:B,onMoveStart:$,onMoveEnd:I,onPaneClick:D,onPaneMouseEnter:T,onPaneMouseMove:j,onPaneMouseLeave:R,ConnectionLineContainerStyle:z,ConnectionLineComponent:O}){return t.jsxs(Ar,{multiSelectionKeyCode:i,dragSelectionKeyCode:a,deleteKeyCode:s,noPanClassName:n,panning:o,defaultViewport:r,onMove:B,onMoveStart:$,onMoveEnd:I,onPaneClick:D,onPaneMouseEnter:T,onPaneMouseMove:j,onPaneMouseLeave:R,children:[t.jsx(Ir,{rfId:e,nodeTypes:f,onlyRenderVisibleElements:u,disableKeyboardA11y:l,nodeOrigin:d,nodeExtent:h,noDragClassName:c,noPanClassName:n,onNodeClick:g,onNodeDoubleClick:p,onNodeContextMenu:m,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:x}),t.jsx(ri,{rfId:e,edgeTypes:b,noPanClassName:n,edgeUpdaterRadius:w,onEdgeClick:_,onEdgeDoubleClick:E,onEdgeContextMenu:S,onEdgeMouseEnter:N,onEdgeMouseMove:P,onEdgeMouseLeave:M,onEdgeUpdate:C,onEdgeUpdateStart:k,onEdgeUpdateEnd:A}),t.jsx(ui,{edgeTypes:b,containerStyle:z,component:O})]})}li.displayName="DiagramView";var ci=n.memo(li);const di=Symbol.for("internals"),hi=e=>{const{setNodes:t,setEdges:n,setNodeExtent:o,setTranslateExtent:r,setMinZoom:i,setMaxZoom:a}=e;return{setNodes:t,setEdges:n,setNodeExtent:o,setTranslateExtent:r,setMinZoom:i,setMaxZoom:a}};function fi(e,t){n.useEffect((()=>{void 0!==e&&t(e)}),[e])}function gi(e,t,o){n.useEffect((()=>{void 0!==t&&o({[e]:t})}),[t])}const pi=({nodes:e,edges:t,nodeOrigin:n,smoothStep:o,centerStep:r,gridStep:i,elevateNodesOnSelect:a,nodesDraggable:s,autoPanOnNodeDrag:u,autoPanOnConnect:l,connectionRadius:c,nodeExtent:d,translateExtent:h,minZoom:f,maxZoom:g,onNodesChange:p,onNodeDrag:m,onNodeDragStart:y,onNodeDragEnd:v,onNodesDelete:x,onEdgesChange:b,onEdgesDelete:w,onConnect:_,onConnectStart:E,onConnectEnd:S,onError:N,onBeforeDelete:P,onDelete:M})=>{const{setNodes:C,setEdges:k,setNodeExtent:A,setTranslateExtent:B,setMinZoom:$,setMaxZoom:I}=ar(hi,pr),D=sr();return fi(e,C),fi(t,k),fi(d,A),fi(d,A),fi(h,B),fi(f,$),fi(g,I),gi("nodeOrigin",n,D.setState),gi("smoothStep",o,D.setState),gi("centerStep",r,D.setState),gi("gridStep",i,D.setState),gi("elevateNodesOnSelect",a,D.setState),gi("nodesDraggable",s,D.setState),gi("autoPanOnNodeDrag",u,D.setState),gi("autoPanOnConnect",l,D.setState),gi("connectionRadius",c,D.setState),gi("onNodesChange",p,D.setState),gi("onNodeDrag",m,D.setState),gi("onNodeDragStart",y,D.setState),gi("onNodeDragEnd",v,D.setState),gi("onNodesDelete",x,D.setState),gi("onEdgesChange",b,D.setState),gi("onEdgesDelete",w,D.setState),gi("onConnect",_,D.setState),gi("onConnectStart",E,D.setState),gi("onConnectEnd",S,D.setState),gi("onBeforeDelete",P,D.setState),gi("onDelete",M,D.setState),gi("onError",(e=>(t,n="")=>e?.(t,oo[t](n)))(N),D.setState),null};function mi(e,t){n.useRef(null);return n.useMemo((()=>t(e)),[e])}const yi=n.createContext(null),vi=yi.Provider;yi.Consumer;function xi({id:e,type:o,position:r}){const i=e||null,a=sr(),s=n.useContext(yi);if(!s)return null;const u=e=>{const{defaultEdgeOptions:t,onConnect:n}=a.getState(),o={...t,...e};n?.(o)},l=e=>{const t=Qn(e.nativeEvent),{button:n}=e;if(t&&0===n||!t){const{domNode:t,autoPanOnConnect:n,connectionRadius:r,transform:l,getNodes:c,cancelConnection:d,updateConnection:h,onConnectStart:f,onConnectEnd:g,panBy:p}=a.getState();jo({event:e.nativeEvent,nodeId:s,portId:i,portType:o,domNode:t,autoPanOnConnect:n,connectionRadius:r,nodes:c(),cancelConnection:d,updateConnection:h,onConnect:u,onConnectStart:f,onConnectEnd:g,panBy:p,getTransform:()=>l})}};return t.jsx("div",{"data-nodeid":s,"data-id":`${s}-${i}-${o}`,"data-portid":i,"data-port-position":r,className:`react-diagram__port react-diagram__port-${r} ${o} nodrag`,onMouseDown:l,onTouchStart:l})}xi.displayName="Port";var bi=n.memo(xi);function wi({data:n}){return t.jsxs(t.Fragment,{children:[t.jsx(bi,{type:"target",position:e.Position.Top}),n.label,t.jsx(bi,{type:"source",position:e.Position.Bottom})]})}const _i=e=>{function o({id:o,type:r="default",data:i,positionX:a,positionY:s,sourcePosition:u,targetPosition:l,onClick:c,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,onContextMenu:g,onDoubleClick:p,style:m,width:y,height:v,className:x,selected:b,intersected:w,hidden:_,draggable:E=!0,selectable:S=!0,resizeObserver:N,dragHandle:P,zIndex:M=0,isParent:C,initialized:k,disableKeyboardA11y:A,ariaLabel:B,rfId:$,nodesDraggable:I,elementsSelectable:D,noDragClassName:T,noPanClassName:j}){const R=sr(),z=R.getState().nodeInternals.get(o),O=n.useRef(null),L=n.useRef(u),X=n.useRef(l),Y=n.useRef(r),Z=!!(E||I&&void 0===E),V=!!(S||D&&void 0===S),U=Z||c||d||h||f;n.useEffect((()=>{if(O.current&&!_){const e=O.current;return N?.observe(e),()=>N?.unobserve(e)}}),[_]),n.useEffect((()=>{const e=Y.current!==r,t=L.current!==u,n=X.current!==l;O.current&&(e||t||n)&&(e&&(Y.current=r),t&&(L.current=u),n&&(X.current=l),R.getState().updateNodeDimensions([{id:o,nodeElement:O.current,forceUpdate:!0}]))}),[o,r,u,l]);const q=xr({nodeRef:O,nodeId:o,disabled:_||!Z,isSelectable:V,noDragClassName:T});if(_)return null;const K=dr(["react-diagram__node",`react-diagram__node-${r}`,{[j]:Z},x,{selected:b,intersected:w,parent:C,dragging:q}]),W={zIndex:M,transform:`translate(${a}px,${s}px)`,pointerEvents:U?"all":"none",visibility:k?"visible":"hidden",width:y,height:v,...m},F={onClick:e=>{Z||vr({id:o,store:R,nodeRef:O,isSelectable:V}),c&&c(e,{...z})},onDoubleClick:yr(o,R.getState,p),onContextMenu:yr(o,R.getState,g),onMouseEnter:yr(o,R.getState,d),onMouseMove:yr(o,R.getState,h),onMouseLeave:yr(o,R.getState,f)},H={positionX:a,positionY:s,sourcePosition:u,targetPosition:l};return t.jsx("div",{...F,ref:O,className:K,style:W,"data-id":o,tabIndex:0,role:"button","aria-describedby":A?void 0:`react-diagram__node-desc-${$}`,"aria-label":B,children:t.jsx(vi,{value:o,children:t.jsx(e,{...H,id:o,zIndex:M,type:r,data:i,dragHandle:P,selected:b,intersected:w})})})}return o.displayName="NodeWrapper",n.memo(o)},Ei=e=>{const t={default:_i(e.default||wi)},n=Object.keys(e).filter((e=>!Object.keys(t).includes(e))).reduce(((t,n)=>(t[n]=_i(e[n]||wi),t)),{});return{...t,...n}},Si=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ni={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],elementsSelectable:!0,onNodesChange:null,domNode:null,nodeOrigin:[0,0],smoothStep:!1,centerStep:!1,gridStep:void 0,elevateNodesOnSelect:!0,nodesDraggable:!0,multiSelectionActive:!1,selectionBoxActive:!1,d3Zoom:null,d3Selection:null,minZoom:.5,maxZoom:2,connectionPosition:{x:0,y:0},connectionStartPort:null,connectionEndPort:null,autoPanOnNodeDrag:!0,autoPanOnConnect:!0,nodeExtent:Si,translateExtent:Si,connectionRadius:20,onError:(e,t="")=>{}},Pi=()=>{return e=(e,t)=>({...Ni,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:i}=t();e({nodeInternals:Bo(n,o,r,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map((e=>({...o,...e})))})},updateNodeDimensions:n=>{const{triggerNodeChanges:o,nodeInternals:r,domNode:i,nodeOrigin:a}=t(),s=i?.querySelector(".react-diagram__viewport");if(!s)return;const u=window.getComputedStyle(s),{m22:l}=new window.DOMMatrixReadOnly(u.transform),c=[],d=[],h=n.reduce(((e,t)=>{const n=r.get(t.id);if(n){const o=Hn(t.nodeElement);if(o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)){const i={...n,[Fn]:{...n[Fn],portBounds:{id:n[Fn]?.portBounds?.id||null,source:Gn(".source",t.nodeElement,l,a),target:Gn(".target",t.nodeElement,l,a)}},...o};r.set(n.id,i);const s=$o(i,r);n.intersected!==s&&c.push({id:n.id,type:"intersect",intersected:s}),d.push({id:n.id,type:"position",dragging:!1,position:n.position,positionAbsolute:n.positionAbsolute}),e.push({id:n.id,type:"dimensions",dimensions:o})}}return e}),[]);e({nodeInternals:new Map(r)}),o([...h,...c,...d])},updateNodesPosition:(e,n=!1,o)=>{const{triggerNodeChanges:r}=t();r(e.map((e=>{const t={id:e.id,type:"position",dragging:n};return o?(o(e),{...t,position:e.position,positionAbsolute:e.positionAbsolute}):t})))},triggerNodeChanges:e=>{const{onNodesChange:n}=t();e?.length&&n?.(e)},triggerEdgeChanges:e=>{const{onEdgesChange:n}=t();e?.length&&n?.(e)},updateNodesIntersection:()=>{const{nodeInternals:e,triggerNodeChanges:n}=t(),o=Array.from(e.values()),r=[];o.forEach((t=>{const n=$o(t,e);t.intersected!==n&&r.push({id:t.id,type:"intersect",intersected:n})})),n(r)},addSelectedNodes:e=>{const{multiSelectionActive:n,getNodes:o,triggerNodeChanges:r}=t();let i;i=n?e.map((e=>Er(e,!0))):Sr(o(),e),r(i)},unselectNodes:({nodes:e}={})=>{const{getNodes:n,triggerNodeChanges:o}=t();o((e||n()).map((e=>(e.selected=!1,Er(e.id,!1)))))},addSelectedEdges:e=>{const{multiSelectionActive:n,getNodes:o,edges:r,triggerNodeChanges:i,triggerEdgeChanges:a}=t(),s=o();n?a(e.map((e=>Er(e,!0)))):(a(Sr(r,e)),i(Sr(s,[])))},unselectEdges:({edges:e}={})=>{const{edges:n,triggerEdgeChanges:o}=t();o((e||n).map((e=>(e.selected=!1,Er(e.id,!1)))))},resetSelectedElements:()=>{const{edges:e,getNodes:n,triggerNodeChanges:o,triggerEdgeChanges:r}=t(),i=n().filter((e=>e.selected)).map((e=>Er(e.id,!1))),a=e.filter((e=>e.selected)).map((e=>Er(e.id,!1)));o(i),r(a)},deleteElements:async e=>{const{edges:n,getNodes:o,onBeforeDelete:r,onDelete:i,onNodesDelete:a,onEdgesDelete:s,triggerNodeChanges:u,triggerEdgeChanges:l}=t(),c=o();await async function(e,t,n){const{nodes:o,edges:r}=t,{nodes:i,edges:a}=mo(e,{nodes:o,edges:r});function s(){const e=i.length>0,t=a.length>0;(e||t)&&n?.onDelete?.({nodes:i,edges:a})}if(i.length,a.length,!n?.onBeforeDelete)return s(),{edges:a,nodes:i};const u=await(n?.onBeforeDelete?.({nodes:i,edges:a}));return"boolean"==typeof u?(u&&s(),u?{edges:a,nodes:i}:{edges:[],nodes:[]}):u}(e,{nodes:c,edges:n},{onBeforeDelete:r,onDelete:({nodes:e,edges:t})=>{const n=e.length>0,o=t.length>0;if(n){const t=e.map(Nr("remove"));a?.(e),u(t)}if(o){const e=t.map(Nr("remove"));s?.(t),l(e)}i?.({nodes:e,edges:t})}})},cancelConnection:()=>e({connectionStartPort:null,connectionEndPort:null}),updateConnection:n=>{const{connectionPosition:o}=t(),r={...n,connectionPosition:n.connectionPosition??o};e(r)},panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:i,d3Selection:a}=t();if(!i||!a||!e.x&&!e.y)return;const s=On.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),u=[[0,0],[o,r]],l=i?.constrain()(s,u,Si);i.transform(a,l)},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=co(e.positionAbsolute,n)})),e({nodeExtent:n,nodeInternals:new Map(o)})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=t();o?.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=t();o?.scaleExtent([r,n]),e({maxZoom:n})}}),e?Vo(e):Vo;var e},Mi=({children:e})=>{const o=n.useRef(null);return o.current||(o.current=Pi()),t.jsx(rr,{value:o.current,children:e})};function Ci({children:e}){return n.useContext(or)?t.jsx(t.Fragment,{children:e}):t.jsx(Mi,{children:e})}Mi.displayName="ReactDiagramProvider",Ci.displayName="ReactDiagramWrapper";const ki={x:0,y:0,zoom:1},Ai=[0,0],Bi={default:wi},$i={step:Zr};function Ii({children:e,id:n,panning:o=!0,minZoom:r,maxZoom:i,translateExtent:a,nodeExtent:s=Si,defaultViewport:u=ki,multiSelectionKeyCode:l="Meta",dragSelectionKeyCode:c="Shift",deleteKeyCode:d="Backspace",onlyRenderVisibleElements:h=!1,disableKeyboardA11y:f=!1,noDragClassName:g="nodrag",noPanClassName:p="nopan",nodeOrigin:m=Ai,nodeTypes:y=Bi,edgeTypes:v=$i,edgeUpdaterRadius:x,ConnectionLineContainerStyle:b,ConnectionLineComponent:w,nodes:_,edges:E,nodesDraggable:S,elevateNodesOnSelect:N,autoPanOnNodeDrag:P,autoPanOnConnect:M,connectionRadius:C,smoothStep:k,centerStep:A,gridStep:B,onNodesChange:$,onNodeDrag:I,onNodeDragStart:D,onNodeDragEnd:T,onNodeClick:j,onNodeDoubleClick:R,onNodeContextMenu:z,onNodeMouseEnter:O,onNodeMouseMove:L,onNodeMouseLeave:X,onNodesDelete:Y,onEdgesChange:Z,onEdgeClick:V,onEdgeDoubleClick:U,onEdgeContextMenu:q,onEdgeMouseEnter:K,onEdgeMouseMove:W,onEdgeMouseLeave:F,onEdgeUpdate:H,onEdgeUpdateStart:G,onEdgeUpdateEnd:Q,onEdgesDelete:J,onConnect:ee,onConnectStart:te,onConnectEnd:ne,onDelete:oe,onBeforeDelete:re,onMove:ie,onMoveStart:ae,onMoveEnd:se,onPaneClick:ue,onPaneMouseEnter:le,onPaneMouseMove:ce,onPaneMouseLeave:de,onError:he,...fe},ge){const pe=n||"1",me=mi(y,Ei),ye=mi(v,Qr);return t.jsx("div",{...fe,ref:ge,className:"react-diagram",children:t.jsxs(Ci,{children:[t.jsx(ci,{rfId:pe,panning:o,defaultViewport:u,multiSelectionKeyCode:l,dragSelectionKeyCode:c,deleteKeyCode:d,onlyRenderVisibleElements:h,disableKeyboardA11y:f,noDragClassName:g,noPanClassName:p,nodeOrigin:m,nodeExtent:s,nodeTypes:me,edgeTypes:ye,edgeUpdaterRadius:x,ConnectionLineContainerStyle:b,ConnectionLineComponent:w,onNodeClick:j,onNodeDoubleClick:R,onNodeContextMenu:z,onNodeMouseEnter:O,onNodeMouseMove:L,onNodeMouseLeave:X,onEdgeClick:V,onEdgeDoubleClick:U,onEdgeContextMenu:q,onEdgeMouseEnter:K,onEdgeMouseMove:W,onEdgeMouseLeave:F,onEdgeUpdate:H,onEdgeUpdateStart:G,onEdgeUpdateEnd:Q,onMove:ie,onMoveStart:ae,onMoveEnd:se,onPaneClick:ue,onPaneMouseEnter:le,onPaneMouseMove:ce,onPaneMouseLeave:de}),t.jsx(pi,{rfId:pe,nodes:_,edges:E,nodesDraggable:S,elevateNodesOnSelect:N,autoPanOnNodeDrag:P,autoPanOnConnect:M,connectionRadius:C,nodeOrigin:m,nodeExtent:s,translateExtent:a,minZoom:r,maxZoom:i,smoothStep:k,centerStep:A,gridStep:B,onNodesChange:$,onNodeDrag:I,onNodeDragStart:D,onNodeDragEnd:T,onNodesDelete:Y,onEdgesChange:Z,onEdgesDelete:J,onConnect:ee,onConnectStart:te,onConnectEnd:ne,onError:he,onBeforeDelete:re,onDelete:oe}),e]})})}Ii.displayName="ReactDiagram";var Di=n.forwardRef(Ii);function Ti({color:e,scaledGap:n,lineWidth:o}){const r=`${`M${n[0]/2} 0`} ${`V${n[1]}`} ${"M0 "+n[1]/2} ${`H${n[0]}`}`;return t.jsx("path",{stroke:e,strokeWidth:o,d:r})}const ji=e=>({transform:e.transform,rfId:e.rfId,gridStepGap:e.gridStep});function Ri({gap:e,lineWidth:o=1,color:r="#000000"}){const i=n.useRef(null),{transform:a,rfId:s,gridStepGap:u}=ar(ji,pr),l=e||(u||50),c=Array.isArray(l)?l:[l,l],d=[c[0]*a[2]||1,c[1]*a[2]||1],h=[d[0]/2,d[1]/2];return t.jsxs("svg",{className:"react-diagram__container react-diagram__background",ref:i,children:[t.jsx("pattern",{id:`background-${s}`,x:a[0]%d[0],y:a[1]%d[1],width:d[0],height:d[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${h[0]},-${h[1]})`,children:t.jsx(Ti,{scaledGap:d,color:r,lineWidth:o})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#background-${s})`})]})}Ri.displayName="Background";var zi=n.memo(Ri);e.Background=zi,e.BaseEdge=Or,e.BezierEdge=Ur,e.Port=bi,e.ReactDiagramProvider=Mi,e.StepEdge=Zr,e.addEdge=(e,t)=>{if(!ho(e))return t;if(((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourcePort!==e.sourcePort&&(t.sourcePort||e.sourcePort)||t.targetPort!==e.targetPort&&(t.targetPort||e.targetPort)))))(e,t))return t;let n;return null===e.sourcePort&&delete e.sourcePort,null===e.targetPort&&delete e.targetPort,n=e.id?{...e}:{...e,id:xo(e)},t.concat(n)},e.boxToRect=uo,e.clamp=ro,e.default=Di,e.getBezierEdgeCenter=No,e.getBezierPath=Co,e.getStepPath=Eo,e.getStraightPath=So,e.internalsSymbol=di,e.isCoreEdge=ho,e.isCoreNode=e=>"id"in e&&!("source"in e)&&!("target"in e),e.rectToBox=so,e.updateEdge=(e,t,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=e;!t.source||t.target,n.find((e=>e.id===r));const a={...i,id:o.shouldReplaceId?xo(t):r,source:t.source,target:t.target};return n.filter((e=>e.id!==r)).concat(a)},e.useEdgesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>function(e,t){return _r(e,t)}(e,t)))),[]);return[t,o,r]},e.useNodesState=function(e){const[t,o]=n.useState(e),r=n.useCallback((e=>o((t=>function(e,t){return _r(e,t)}(e,t)))),[]);return[t,o,r]},e.useStore=ar,e.useStoreApi=sr,Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cosmos-diagram",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "React Diagram",
5
5
  "keywords": [
6
6
  "react",