react-cosmos-diagram 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/dist/esm/components/A11yDescriptions/index.d.ts.map +1 -1
  2. package/dist/esm/components/Background/LinePath.d.ts.map +1 -1
  3. package/dist/esm/components/Background/index.d.ts.map +1 -1
  4. package/dist/esm/components/Background/type.d.ts.map +1 -1
  5. package/dist/esm/components/DragBox/index.d.ts +1 -1
  6. package/dist/esm/components/DragBox/index.d.ts.map +1 -1
  7. package/dist/esm/components/Edges/Anchor.d.ts +1 -1
  8. package/dist/esm/components/Edges/Anchor.d.ts.map +1 -1
  9. package/dist/esm/components/Edges/BaseEdge.d.ts.map +1 -1
  10. package/dist/esm/components/Edges/BezierEdge.d.ts +2 -13
  11. package/dist/esm/components/Edges/BezierEdge.d.ts.map +1 -1
  12. package/dist/esm/components/Edges/EdgeLabel.d.ts.map +1 -1
  13. package/dist/esm/components/Edges/EdgeWrapper/index.d.ts.map +1 -1
  14. package/dist/esm/components/Edges/EdgeWrapper/type.d.ts +3 -10
  15. package/dist/esm/components/Edges/EdgeWrapper/type.d.ts.map +1 -1
  16. package/dist/esm/components/Edges/StepEdge.d.ts +2 -22
  17. package/dist/esm/components/Edges/StepEdge.d.ts.map +1 -1
  18. package/dist/esm/components/Edges/StraightEdge.d.ts +0 -7
  19. package/dist/esm/components/Edges/StraightEdge.d.ts.map +1 -1
  20. package/dist/esm/components/Edges/type.d.ts +8 -35
  21. package/dist/esm/components/Edges/type.d.ts.map +1 -1
  22. package/dist/esm/components/Node/NodeWrapper/index.d.ts +3 -3
  23. package/dist/esm/components/Node/NodeWrapper/index.d.ts.map +1 -1
  24. package/dist/esm/components/Node/NodeWrapper/type.d.ts +4 -1
  25. package/dist/esm/components/Node/NodeWrapper/type.d.ts.map +1 -1
  26. package/dist/esm/components/Node/index.d.ts.map +1 -1
  27. package/dist/esm/components/Node/type.d.ts +4 -36
  28. package/dist/esm/components/Node/type.d.ts.map +1 -1
  29. package/dist/esm/components/Node/utils.d.ts +0 -3
  30. package/dist/esm/components/Node/utils.d.ts.map +1 -1
  31. package/dist/esm/components/Port/index.d.ts +2 -2
  32. package/dist/esm/components/Port/index.d.ts.map +1 -1
  33. package/dist/esm/components/ReactDiagramProvider/index.d.ts.map +1 -1
  34. package/dist/esm/components/ReactDiagramProvider/type.d.ts +10 -8
  35. package/dist/esm/components/ReactDiagramProvider/type.d.ts.map +1 -1
  36. package/dist/esm/components/SelectionBox/index.d.ts +1 -1
  37. package/dist/esm/components/SelectionBox/index.d.ts.map +1 -1
  38. package/dist/esm/components/SelectionBox/type.d.ts +1 -1
  39. package/dist/esm/components/SelectionBox/type.d.ts.map +1 -1
  40. package/dist/esm/components/StoreUpdater/index.d.ts +2 -2
  41. package/dist/esm/components/StoreUpdater/index.d.ts.map +1 -1
  42. package/dist/esm/container/ConnectionLineRenderer/ConnectionPath.d.ts +1 -1
  43. package/dist/esm/container/ConnectionLineRenderer/ConnectionPath.d.ts.map +1 -1
  44. package/dist/esm/container/ConnectionLineRenderer/index.d.ts.map +1 -1
  45. package/dist/esm/container/ConnectionLineRenderer/type.d.ts +2 -2
  46. package/dist/esm/container/ConnectionLineRenderer/type.d.ts.map +1 -1
  47. package/dist/esm/container/DiagramRenderer/index.d.ts +1 -1
  48. package/dist/esm/container/DiagramRenderer/index.d.ts.map +1 -1
  49. package/dist/esm/container/DragSelection/index.d.ts +2 -2
  50. package/dist/esm/container/DragSelection/index.d.ts.map +1 -1
  51. package/dist/esm/container/EdgeRenderer/MarkerComponent.d.ts.map +1 -1
  52. package/dist/esm/container/EdgeRenderer/MarkerSymbols.d.ts +1 -1
  53. package/dist/esm/container/EdgeRenderer/MarkerSymbols.d.ts.map +1 -1
  54. package/dist/esm/container/EdgeRenderer/index.d.ts.map +1 -1
  55. package/dist/esm/container/EdgeRenderer/type.d.ts.map +1 -1
  56. package/dist/esm/container/EdgeRenderer/utils.d.ts +3 -3
  57. package/dist/esm/container/EdgeRenderer/utils.d.ts.map +1 -1
  58. package/dist/esm/container/NodeRenderer/index.d.ts +1 -1
  59. package/dist/esm/container/NodeRenderer/index.d.ts.map +1 -1
  60. package/dist/esm/container/NodeRenderer/type.d.ts +2 -2
  61. package/dist/esm/container/NodeRenderer/type.d.ts.map +1 -1
  62. package/dist/esm/container/NodeRenderer/utils.d.ts.map +1 -1
  63. package/dist/esm/container/Pane/index.d.ts +2 -1
  64. package/dist/esm/container/Pane/index.d.ts.map +1 -1
  65. package/dist/esm/container/ReactDiagram/DiagramView.d.ts +2 -2
  66. package/dist/esm/container/ReactDiagram/DiagramView.d.ts.map +1 -1
  67. package/dist/esm/container/ReactDiagram/Wrapper.d.ts.map +1 -1
  68. package/dist/esm/container/ReactDiagram/index.d.ts +19 -20
  69. package/dist/esm/container/ReactDiagram/index.d.ts.map +1 -1
  70. package/dist/esm/container/Viewport/index.d.ts.map +1 -1
  71. package/dist/esm/contexts/NodeIdContext.d.ts.map +1 -1
  72. package/dist/esm/contexts/RFStoreContext.d.ts.map +1 -1
  73. package/dist/esm/hooks/useDrag.d.ts +9 -0
  74. package/dist/esm/hooks/useDrag.d.ts.map +1 -0
  75. package/dist/esm/hooks/useDragSelectionKeyPress.d.ts +4 -0
  76. package/dist/esm/hooks/useDragSelectionKeyPress.d.ts.map +1 -0
  77. package/dist/esm/hooks/useGlobalKeyHandler.d.ts +1 -1
  78. package/dist/esm/hooks/useGlobalKeyHandler.d.ts.map +1 -1
  79. package/dist/esm/hooks/useNodeOrEdgeTypes.d.ts.map +1 -1
  80. package/dist/esm/hooks/useNodesEdgesState/index.d.ts +2 -2
  81. package/dist/esm/hooks/useNodesEdgesState/index.d.ts.map +1 -1
  82. package/dist/esm/hooks/useNodesEdgesState/type.d.ts +7 -7
  83. package/dist/esm/hooks/useNodesEdgesState/type.d.ts.map +1 -1
  84. package/dist/esm/hooks/useStore.d.ts.map +1 -1
  85. package/dist/esm/hooks/useVisibleNodes.d.ts +1 -1
  86. package/dist/esm/hooks/useVisibleNodes.d.ts.map +1 -1
  87. package/dist/esm/index.d.ts +7 -5
  88. package/dist/esm/index.d.ts.map +1 -1
  89. package/dist/esm/index.js +1460 -1287
  90. package/dist/esm/store/index.d.ts.map +1 -1
  91. package/dist/esm/store/initialState.d.ts +1 -1
  92. package/dist/esm/store/initialState.d.ts.map +1 -1
  93. package/dist/esm/store/type.d.ts +0 -2
  94. package/dist/esm/store/type.d.ts.map +1 -1
  95. package/dist/esm/store/utils.d.ts +4 -4
  96. package/dist/esm/store/utils.d.ts.map +1 -1
  97. package/dist/esm/types/core.d.ts +3 -4
  98. package/dist/esm/types/core.d.ts.map +1 -1
  99. package/dist/esm/types/general.d.ts +1 -21
  100. package/dist/esm/types/general.d.ts.map +1 -1
  101. package/dist/esm/types/index.d.ts +0 -1
  102. package/dist/esm/types/index.d.ts.map +1 -1
  103. package/dist/esm/utils/changes.d.ts +2 -2
  104. package/dist/esm/utils/changes.d.ts.map +1 -1
  105. package/dist/esm/utils/deepEqual.d.ts.map +1 -1
  106. package/dist/esm/utils/index.d.ts +2 -21
  107. package/dist/esm/utils/index.d.ts.map +1 -1
  108. package/dist/style.css +13 -12
  109. package/dist/umd/components/A11yDescriptions/index.d.ts.map +1 -1
  110. package/dist/umd/components/Background/LinePath.d.ts.map +1 -1
  111. package/dist/umd/components/Background/index.d.ts.map +1 -1
  112. package/dist/umd/components/Background/type.d.ts.map +1 -1
  113. package/dist/umd/components/DragBox/index.d.ts +1 -1
  114. package/dist/umd/components/DragBox/index.d.ts.map +1 -1
  115. package/dist/umd/components/Edges/Anchor.d.ts +1 -1
  116. package/dist/umd/components/Edges/Anchor.d.ts.map +1 -1
  117. package/dist/umd/components/Edges/BaseEdge.d.ts.map +1 -1
  118. package/dist/umd/components/Edges/BezierEdge.d.ts +2 -13
  119. package/dist/umd/components/Edges/BezierEdge.d.ts.map +1 -1
  120. package/dist/umd/components/Edges/EdgeLabel.d.ts.map +1 -1
  121. package/dist/umd/components/Edges/EdgeWrapper/index.d.ts.map +1 -1
  122. package/dist/umd/components/Edges/EdgeWrapper/type.d.ts +3 -10
  123. package/dist/umd/components/Edges/EdgeWrapper/type.d.ts.map +1 -1
  124. package/dist/umd/components/Edges/StepEdge.d.ts +2 -22
  125. package/dist/umd/components/Edges/StepEdge.d.ts.map +1 -1
  126. package/dist/umd/components/Edges/StraightEdge.d.ts +0 -7
  127. package/dist/umd/components/Edges/StraightEdge.d.ts.map +1 -1
  128. package/dist/umd/components/Edges/type.d.ts +8 -35
  129. package/dist/umd/components/Edges/type.d.ts.map +1 -1
  130. package/dist/umd/components/Node/NodeWrapper/index.d.ts +3 -3
  131. package/dist/umd/components/Node/NodeWrapper/index.d.ts.map +1 -1
  132. package/dist/umd/components/Node/NodeWrapper/type.d.ts +4 -1
  133. package/dist/umd/components/Node/NodeWrapper/type.d.ts.map +1 -1
  134. package/dist/umd/components/Node/index.d.ts.map +1 -1
  135. package/dist/umd/components/Node/type.d.ts +4 -36
  136. package/dist/umd/components/Node/type.d.ts.map +1 -1
  137. package/dist/umd/components/Node/utils.d.ts +0 -3
  138. package/dist/umd/components/Node/utils.d.ts.map +1 -1
  139. package/dist/umd/components/Port/index.d.ts +2 -2
  140. package/dist/umd/components/Port/index.d.ts.map +1 -1
  141. package/dist/umd/components/ReactDiagramProvider/index.d.ts.map +1 -1
  142. package/dist/umd/components/ReactDiagramProvider/type.d.ts +10 -8
  143. package/dist/umd/components/ReactDiagramProvider/type.d.ts.map +1 -1
  144. package/dist/umd/components/SelectionBox/index.d.ts +1 -1
  145. package/dist/umd/components/SelectionBox/index.d.ts.map +1 -1
  146. package/dist/umd/components/SelectionBox/type.d.ts +1 -1
  147. package/dist/umd/components/SelectionBox/type.d.ts.map +1 -1
  148. package/dist/umd/components/StoreUpdater/index.d.ts +2 -2
  149. package/dist/umd/components/StoreUpdater/index.d.ts.map +1 -1
  150. package/dist/umd/container/ConnectionLineRenderer/ConnectionPath.d.ts +1 -1
  151. package/dist/umd/container/ConnectionLineRenderer/ConnectionPath.d.ts.map +1 -1
  152. package/dist/umd/container/ConnectionLineRenderer/index.d.ts.map +1 -1
  153. package/dist/umd/container/ConnectionLineRenderer/type.d.ts +2 -2
  154. package/dist/umd/container/ConnectionLineRenderer/type.d.ts.map +1 -1
  155. package/dist/umd/container/DiagramRenderer/index.d.ts +1 -1
  156. package/dist/umd/container/DiagramRenderer/index.d.ts.map +1 -1
  157. package/dist/umd/container/DragSelection/index.d.ts +2 -2
  158. package/dist/umd/container/DragSelection/index.d.ts.map +1 -1
  159. package/dist/umd/container/EdgeRenderer/MarkerComponent.d.ts.map +1 -1
  160. package/dist/umd/container/EdgeRenderer/MarkerSymbols.d.ts +1 -1
  161. package/dist/umd/container/EdgeRenderer/MarkerSymbols.d.ts.map +1 -1
  162. package/dist/umd/container/EdgeRenderer/index.d.ts.map +1 -1
  163. package/dist/umd/container/EdgeRenderer/type.d.ts.map +1 -1
  164. package/dist/umd/container/EdgeRenderer/utils.d.ts +3 -3
  165. package/dist/umd/container/EdgeRenderer/utils.d.ts.map +1 -1
  166. package/dist/umd/container/NodeRenderer/index.d.ts +1 -1
  167. package/dist/umd/container/NodeRenderer/index.d.ts.map +1 -1
  168. package/dist/umd/container/NodeRenderer/type.d.ts +2 -2
  169. package/dist/umd/container/NodeRenderer/type.d.ts.map +1 -1
  170. package/dist/umd/container/NodeRenderer/utils.d.ts.map +1 -1
  171. package/dist/umd/container/Pane/index.d.ts +2 -1
  172. package/dist/umd/container/Pane/index.d.ts.map +1 -1
  173. package/dist/umd/container/ReactDiagram/DiagramView.d.ts +2 -2
  174. package/dist/umd/container/ReactDiagram/DiagramView.d.ts.map +1 -1
  175. package/dist/umd/container/ReactDiagram/Wrapper.d.ts.map +1 -1
  176. package/dist/umd/container/ReactDiagram/index.d.ts +19 -20
  177. package/dist/umd/container/ReactDiagram/index.d.ts.map +1 -1
  178. package/dist/umd/container/Viewport/index.d.ts.map +1 -1
  179. package/dist/umd/contexts/NodeIdContext.d.ts.map +1 -1
  180. package/dist/umd/contexts/RFStoreContext.d.ts.map +1 -1
  181. package/dist/umd/hooks/useDrag.d.ts +9 -0
  182. package/dist/umd/hooks/useDrag.d.ts.map +1 -0
  183. package/dist/umd/hooks/useDragSelectionKeyPress.d.ts +4 -0
  184. package/dist/umd/hooks/useDragSelectionKeyPress.d.ts.map +1 -0
  185. package/dist/umd/hooks/useGlobalKeyHandler.d.ts +1 -1
  186. package/dist/umd/hooks/useGlobalKeyHandler.d.ts.map +1 -1
  187. package/dist/umd/hooks/useNodeOrEdgeTypes.d.ts.map +1 -1
  188. package/dist/umd/hooks/useNodesEdgesState/index.d.ts +2 -2
  189. package/dist/umd/hooks/useNodesEdgesState/index.d.ts.map +1 -1
  190. package/dist/umd/hooks/useNodesEdgesState/type.d.ts +7 -7
  191. package/dist/umd/hooks/useNodesEdgesState/type.d.ts.map +1 -1
  192. package/dist/umd/hooks/useStore.d.ts.map +1 -1
  193. package/dist/umd/hooks/useVisibleNodes.d.ts +1 -1
  194. package/dist/umd/hooks/useVisibleNodes.d.ts.map +1 -1
  195. package/dist/umd/index.d.ts +7 -5
  196. package/dist/umd/index.d.ts.map +1 -1
  197. package/dist/umd/index.js +2 -2
  198. package/dist/umd/store/index.d.ts.map +1 -1
  199. package/dist/umd/store/initialState.d.ts +1 -1
  200. package/dist/umd/store/initialState.d.ts.map +1 -1
  201. package/dist/umd/store/type.d.ts +0 -2
  202. package/dist/umd/store/type.d.ts.map +1 -1
  203. package/dist/umd/store/utils.d.ts +4 -4
  204. package/dist/umd/store/utils.d.ts.map +1 -1
  205. package/dist/umd/types/core.d.ts +3 -4
  206. package/dist/umd/types/core.d.ts.map +1 -1
  207. package/dist/umd/types/general.d.ts +1 -21
  208. package/dist/umd/types/general.d.ts.map +1 -1
  209. package/dist/umd/types/index.d.ts +0 -1
  210. package/dist/umd/types/index.d.ts.map +1 -1
  211. package/dist/umd/utils/changes.d.ts +2 -2
  212. package/dist/umd/utils/changes.d.ts.map +1 -1
  213. package/dist/umd/utils/deepEqual.d.ts.map +1 -1
  214. package/dist/umd/utils/index.d.ts +2 -21
  215. package/dist/umd/utils/index.d.ts.map +1 -1
  216. package/package.json +8 -6
  217. package/dist/esm/components/Edges/utils.d.ts +0 -17
  218. package/dist/esm/components/Edges/utils.d.ts.map +0 -1
  219. package/dist/esm/components/Port/type.d.ts +0 -22
  220. package/dist/esm/components/Port/type.d.ts.map +0 -1
  221. package/dist/esm/components/Port/utils.d.ts +0 -25
  222. package/dist/esm/components/Port/utils.d.ts.map +0 -1
  223. package/dist/esm/fixtures/errorMessages.d.ts +0 -11
  224. package/dist/esm/fixtures/errorMessages.d.ts.map +0 -1
  225. package/dist/esm/hooks/useDrag/index.d.ts +0 -10
  226. package/dist/esm/hooks/useDrag/index.d.ts.map +0 -1
  227. package/dist/esm/hooks/useDrag/type.d.ts +0 -11
  228. package/dist/esm/hooks/useDrag/type.d.ts.map +0 -1
  229. package/dist/esm/hooks/useDrag/utils.d.ts +0 -20
  230. package/dist/esm/hooks/useDrag/utils.d.ts.map +0 -1
  231. package/dist/esm/hooks/useGetPointerPosition.d.ts +0 -21
  232. package/dist/esm/hooks/useGetPointerPosition.d.ts.map +0 -1
  233. package/dist/esm/hooks/useUpdateIntersectionNodes/index.d.ts +0 -6
  234. package/dist/esm/hooks/useUpdateIntersectionNodes/index.d.ts.map +0 -1
  235. package/dist/esm/types/utils.d.ts +0 -26
  236. package/dist/esm/types/utils.d.ts.map +0 -1
  237. package/dist/esm/utils/graph.d.ts +0 -18
  238. package/dist/esm/utils/graph.d.ts.map +0 -1
  239. package/dist/umd/components/Edges/utils.d.ts +0 -17
  240. package/dist/umd/components/Edges/utils.d.ts.map +0 -1
  241. package/dist/umd/components/Port/type.d.ts +0 -22
  242. package/dist/umd/components/Port/type.d.ts.map +0 -1
  243. package/dist/umd/components/Port/utils.d.ts +0 -25
  244. package/dist/umd/components/Port/utils.d.ts.map +0 -1
  245. package/dist/umd/fixtures/errorMessages.d.ts +0 -11
  246. package/dist/umd/fixtures/errorMessages.d.ts.map +0 -1
  247. package/dist/umd/hooks/useDrag/index.d.ts +0 -10
  248. package/dist/umd/hooks/useDrag/index.d.ts.map +0 -1
  249. package/dist/umd/hooks/useDrag/type.d.ts +0 -11
  250. package/dist/umd/hooks/useDrag/type.d.ts.map +0 -1
  251. package/dist/umd/hooks/useDrag/utils.d.ts +0 -20
  252. package/dist/umd/hooks/useDrag/utils.d.ts.map +0 -1
  253. package/dist/umd/hooks/useGetPointerPosition.d.ts +0 -21
  254. package/dist/umd/hooks/useGetPointerPosition.d.ts.map +0 -1
  255. package/dist/umd/hooks/useUpdateIntersectionNodes/index.d.ts +0 -6
  256. package/dist/umd/hooks/useUpdateIntersectionNodes/index.d.ts.map +0 -1
  257. package/dist/umd/types/utils.d.ts +0 -26
  258. package/dist/umd/types/utils.d.ts.map +0 -1
  259. package/dist/umd/utils/graph.d.ts +0 -18
  260. package/dist/umd/utils/graph.d.ts.map +0 -1
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";const o=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 r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i,a,s,u={exports:{}},c={},l={exports:{}},d={};function h(){return a||(a=1,l.exports=function(){if(i)return d;i=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,a=e.useLayoutEffect,s=e.useDebugValue;function u(e){var n=e.getSnapshot;e=e.value;try{var o=n();return!t(e,o)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),i=o({inst:{value:n,getSnapshot:t}}),c=i[0].inst,l=i[1];return a((function(){c.value=n,c.getSnapshot=t,u(c)&&l({inst:c})}),[e,n,t]),r((function(){return u(c)&&l({inst:c}),e((function(){u(c)&&l({inst:c})}))}),[e]),s(n),n};return d.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:c,d}()),l.exports}
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactCosmosDiagram={},t.jsxRuntime,t.React)}(this,(function(t,e,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(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),r.hasOwnProperty(e)?{space:r[e],local:t}:t}function a(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===o&&e.documentElement.namespaceURI===o?e.createElement(t):e.createElementNS(n,t)}}function s(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function u(t){var e=i(t);return(e.local?s:a)(e)}function c(){}function l(t){return null==t?c:function(){return this.querySelector(t)}}function d(){return[]}function h(t){return null==t?d:function(){return this.querySelectorAll(t)}}function f(t){return function(){return null==(e=t.apply(this,arguments))?[]:Array.isArray(e)?e:Array.from(e);var e}}function g(t){return function(){return this.matches(t)}}function p(t){return function(e){return e.matches(t)}}var m=Array.prototype.find;function y(){return this.firstElementChild}var v=Array.prototype.filter;function x(){return Array.from(this.children)}function b(t){return new Array(t.length)}function w(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function _(t,e,n,o,r,i){for(var a,s=0,u=e.length,c=i.length;s<c;++s)(a=e[s])?(a.__data__=i[s],o[s]=a):n[s]=new w(t,i[s]);for(;s<u;++s)(a=e[s])&&(r[s]=a)}function E(t,e,n,o,r,i,a){var s,u,c,l=new Map,d=e.length,h=i.length,f=new Array(d);for(s=0;s<d;++s)(u=e[s])&&(f[s]=c=a.call(u,u.__data__,s,e)+"",l.has(c)?r[s]=u:l.set(c,u));for(s=0;s<h;++s)c=a.call(t,i[s],s,i)+"",(u=l.get(c))?(o[s]=u,u.__data__=i[s],l.delete(c)):n[s]=new w(t,i[s]);for(s=0;s<d;++s)(u=e[s])&&l.get(f[s])===u&&(r[s]=u)}function S(t){return t.__data__}function N(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function P(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function M(t){return function(){this.removeAttribute(t)}}function C(t){return function(){this.removeAttributeNS(t.space,t.local)}}function k(t,e){return function(){this.setAttribute(t,e)}}function $(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function A(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function B(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function I(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function T(t){return function(){this.style.removeProperty(t)}}function j(t,e,n){return function(){this.style.setProperty(t,e,n)}}function z(t,e,n){return function(){var o=e.apply(this,arguments);null==o?this.style.removeProperty(t):this.style.setProperty(t,o,n)}}function R(t,e){return t.style.getPropertyValue(e)||I(t).getComputedStyle(t,null).getPropertyValue(e)}function D(t){return function(){delete this[t]}}function O(t,e){return function(){this[t]=e}}function X(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function Y(t){return t.trim().split(/^|\s+/)}function L(t){return t.classList||new Z(t)}function Z(t){this._node=t,this._names=Y(t.getAttribute("class")||"")}function V(t,e){for(var n=L(t),o=-1,r=e.length;++o<r;)n.add(e[o])}function U(t,e){for(var n=L(t),o=-1,r=e.length;++o<r;)n.remove(e[o])}function q(t){return function(){V(this,t)}}function F(t){return function(){U(this,t)}}function W(t,e){return function(){(e.apply(this,arguments)?V:U)(this,t)}}function K(){this.textContent=""}function H(t){return function(){this.textContent=t}}function G(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function Q(){this.innerHTML=""}function J(t){return function(){this.innerHTML=t}}function tt(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function et(){this.nextSibling&&this.parentNode.appendChild(this)}function nt(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ot(){return null}function rt(){var t=this.parentNode;t&&t.removeChild(this)}function it(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function at(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function st(t){return function(){var e=this.__on;if(e){for(var n,o=0,r=-1,i=e.length;o<i;++o)n=e[o],t.type&&n.type!==t.type||n.name!==t.name?e[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?e.length=r:delete this.__on}}}function ut(t,e,n){return function(){var o,r=this.__on,i=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===t.type&&o.name===t.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=e);this.addEventListener(t.type,i,n),o={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(o):this.__on=[o]}}function ct(t,e,n){var o=I(t),r=o.CustomEvent;"function"==typeof r?r=new r(e,n):(r=o.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function lt(t,e){return function(){return ct(this,t,e)}}function dt(t,e){return function(){return ct(this,t,e.apply(this,arguments))}}w.prototype={constructor:w,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},Z.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ht=[null];function ft(t,e){this._groups=t,this._parents=e}function gt(){return new ft([[document.documentElement]],ht)}function pt(t){return"string"==typeof t?new ft([[document.querySelector(t)]],[document.documentElement]):new ft([[t]],ht)}function mt(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=t.clientX,o.y=t.clientY,[(o=o.matrixTransform(e.getScreenCTM().inverse())).x,o.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}ft.prototype=gt.prototype={constructor:ft,select:function(t){"function"!=typeof t&&(t=l(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=e[r],u=s.length,c=o[r]=new Array(u),d=0;d<u;++d)(i=s[d])&&(a=t.call(i,i.__data__,d,s))&&("__data__"in i&&(a.__data__=i.__data__),c[d]=a);return new ft(o,this._parents)},selectAll:function(t){t="function"==typeof t?f(t):h(t);for(var e=this._groups,n=e.length,o=[],r=[],i=0;i<n;++i)for(var a,s=e[i],u=s.length,c=0;c<u;++c)(a=s[c])&&(o.push(t.call(a,a.__data__,c,s)),r.push(a));return new ft(o,r)},selectChild:function(t){return this.select(null==t?y:function(t){return function(){return m.call(this.children,t)}}("function"==typeof t?t:p(t)))},selectChildren:function(t){return this.selectAll(null==t?x:function(t){return function(){return v.call(this.children,t)}}("function"==typeof t?t:p(t)))},filter:function(t){"function"!=typeof t&&(t=g(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a=e[r],s=a.length,u=o[r]=[],c=0;c<s;++c)(i=a[c])&&t.call(i,i.__data__,c,a)&&u.push(i);return new ft(o,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,S);var n,o=e?E:_,r=this._parents,i=this._groups;"function"!=typeof t&&(n=t,t=function(){return n});for(var a=i.length,s=new Array(a),u=new Array(a),c=new Array(a),l=0;l<a;++l){var d=r[l],h=i[l],f=h.length,g=N(t.call(d,d&&d.__data__,l,r)),p=g.length,m=u[l]=new Array(p),y=s[l]=new Array(p);o(d,h,m,y,c[l]=new Array(f),g,e);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 ft(s,r))._enter=u,s._exit=c,s},enter:function(){return new ft(this._enter||this._groups.map(b),this._parents)},exit:function(){return new ft(this._exit||this._groups.map(b),this._parents)},join:function(t,e,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof t?(o=t(o))&&(o=o.selection()):o=o.append(t+""),null!=e&&(r=e(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,o=e._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),u=0;u<a;++u)for(var c,l=n[u],d=o[u],h=l.length,f=s[u]=new Array(h),g=0;g<h;++g)(c=l[g]||d[g])&&(f[g]=c);for(;u<r;++u)s[u]=n[u];return new ft(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var o,r=t[e],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(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=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,c=r[i]=new Array(u),l=0;l<u;++l)(a=s[l])&&(c[l]=a);c.sort(e)}return new ft(r,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var o=t[e],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r,i=e[n],a=0,s=i.length;a<s;++a)(r=i[a])&&t.call(r,r.__data__,a,i);return this},attr:function(t,e){var n=i(t);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==e?n.local?C:M:"function"==typeof e?n.local?B:A:n.local?$:k)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?T:"function"==typeof e?z:j)(t,e,null==n?"":n)):R(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?D:"function"==typeof e?X:O)(t,e)):this.node()[t]},classed:function(t,e){var n=Y(t+"");if(arguments.length<2){for(var o=L(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof e?W:e?q:F)(n,e))},text:function(t){return arguments.length?this.each(null==t?K:("function"==typeof t?G:H)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?Q:("function"==typeof t?tt:J)(t)):this.node().innerHTML},raise:function(){return this.each(et)},lower:function(){return this.each(nt)},append:function(t){var e="function"==typeof t?t:u(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:u(t),o=null==e?ot:"function"==typeof e?e:l(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(rt)},clone:function(t){return this.select(t?at:it)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var o,r,i=function(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),a=i.length;if(!(arguments.length<2)){for(s=e?ut:st,o=0;o<a;++o)this.each(s(i[o],e,n));return this}var s=this.node().__on;if(s)for(var u,c=0,l=s.length;c<l;++c)for(o=0,u=s[c];o<a;++o)if((r=i[o]).type===u.type&&r.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?dt:lt)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var o,r=t[e],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};var yt={value:()=>{}};function vt(){for(var t,e=0,n=arguments.length,o={};e<n;++e){if(!(t=arguments[e]+"")||t in o||/[\s.]/.test(t))throw new Error("illegal type: "+t);o[t]=[]}return new xt(o)}function xt(t){this._=t}function bt(t,e){for(var n,o=0,r=t.length;o<r;++o)if((n=t[o]).name===e)return n.value}function wt(t,e,n){for(var o=0,r=t.length;o<r;++o)if(t[o].name===e){t[o]=yt,t=t.slice(0,o).concat(t.slice(o+1));break}return null!=n&&t.push({name:e,value:n}),t}xt.prototype=vt.prototype={constructor:xt,on:function(t,e){var n,o,r=this._,i=(o=r,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!o.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=i[a]).type)r[n]=wt(r[n],t.name,e);else if(null==e)for(n in r)r[n]=wt(r[n],t.name,null);return this}for(;++a<s;)if((n=(t=i[a]).type)&&(n=bt(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new xt(t)},call:function(t,e){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(t))throw new Error("unknown type: "+t);for(i=0,n=(o=this._[t]).length;i<n;++i)o[i].value.apply(e,r)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)}};const _t={passive:!1},Et={capture:!0,passive:!1};function St(t){t.stopImmediatePropagation()}function Nt(t){t.preventDefault(),t.stopImmediatePropagation()}function Pt(t){var e=t.document.documentElement,n=pt(t).on("dragstart.drag",Nt,Et);"onselectstart"in e?n.on("selectstart.drag",Nt,Et):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Mt(t,e){var n=t.document.documentElement,o=pt(t).on("dragstart.drag",null);e&&(o.on("click.drag",Nt,Et),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 Ct=t=>()=>t;function kt(t,{sourceEvent:e,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:u,dy:c,dispatch:l}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,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:c,enumerable:!0,configurable:!0},_:{value:l}})}function $t(t){return!t.ctrlKey&&!t.button}function At(){return this.parentNode}function Bt(t,e){return null==e?{x:t.x,y:t.y}:e}function It(){return navigator.maxTouchPoints||"ontouchstart"in this}function Tt(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function jt(t,e){var n=Object.create(t.prototype);for(var o in e)n[o]=e[o];return n}function zt(){}kt.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var Rt=.7,Dt=1/Rt,Ot="\\s*([+-]?\\d+)\\s*",Xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Lt=/^#([0-9a-f]{3,8})$/,Zt=new RegExp(`^rgb\\(${Ot},${Ot},${Ot}\\)$`),Vt=new RegExp(`^rgb\\(${Yt},${Yt},${Yt}\\)$`),Ut=new RegExp(`^rgba\\(${Ot},${Ot},${Ot},${Xt}\\)$`),qt=new RegExp(`^rgba\\(${Yt},${Yt},${Yt},${Xt}\\)$`),Ft=new RegExp(`^hsl\\(${Xt},${Yt},${Yt}\\)$`),Wt=new RegExp(`^hsla\\(${Xt},${Yt},${Yt},${Xt}\\)$`),Kt={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 Ht(){return this.rgb().formatHex()}function Gt(){return this.rgb().formatRgb()}function Qt(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Lt.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Jt(e):3===n?new ne(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?te(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?te(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=Zt.exec(t))?new ne(e[1],e[2],e[3],1):(e=Vt.exec(t))?new ne(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=Ut.exec(t))?te(e[1],e[2],e[3],e[4]):(e=qt.exec(t))?te(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Ft.exec(t))?ue(e[1],e[2]/100,e[3]/100,1):(e=Wt.exec(t))?ue(e[1],e[2]/100,e[3]/100,e[4]):Kt.hasOwnProperty(t)?Jt(Kt[t]):"transparent"===t?new ne(NaN,NaN,NaN,0):null}function Jt(t){return new ne(t>>16&255,t>>8&255,255&t,1)}function te(t,e,n,o){return o<=0&&(t=e=n=NaN),new ne(t,e,n,o)}function ee(t,e,n,o){return 1===arguments.length?((r=t)instanceof zt||(r=Qt(r)),r?new ne((r=r.rgb()).r,r.g,r.b,r.opacity):new ne):new ne(t,e,n,null==o?1:o);var r}function ne(t,e,n,o){this.r=+t,this.g=+e,this.b=+n,this.opacity=+o}function oe(){return`#${se(this.r)}${se(this.g)}${se(this.b)}`}function re(){const t=ie(this.opacity);return`${1===t?"rgb(":"rgba("}${ae(this.r)}, ${ae(this.g)}, ${ae(this.b)}${1===t?")":`, ${t})`}`}function ie(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ae(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function se(t){return((t=ae(t))<16?"0":"")+t.toString(16)}function ue(t,e,n,o){return o<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new le(t,e,n,o)}function ce(t){if(t instanceof le)return new le(t.h,t.s,t.l,t.opacity);if(t instanceof zt||(t=Qt(t)),!t)return new le;if(t instanceof le)return t;var e=(t=t.rgb()).r/255,n=t.g/255,o=t.b/255,r=Math.min(e,n,o),i=Math.max(e,n,o),a=NaN,s=i-r,u=(i+r)/2;return s?(a=e===i?(n-o)/s+6*(n<o):n===i?(o-e)/s+2:(e-n)/s+4,s/=u<.5?i+r:2-i-r,a*=60):s=u>0&&u<1?0:a,new le(a,s,u,t.opacity)}function le(t,e,n,o){this.h=+t,this.s=+e,this.l=+n,this.opacity=+o}function de(t){return(t=(t||0)%360)<0?t+360:t}function he(t){return Math.max(0,Math.min(1,t||0))}function fe(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}Tt(zt,Qt,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ht,formatHex:Ht,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return ce(this).formatHsl()},formatRgb:Gt,toString:Gt}),Tt(ne,ee,jt(zt,{brighter(t){return t=null==t?Dt:Math.pow(Dt,t),new ne(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Rt:Math.pow(Rt,t),new ne(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ne(ae(this.r),ae(this.g),ae(this.b),ie(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:oe,formatHex:oe,formatHex8:function(){return`#${se(this.r)}${se(this.g)}${se(this.b)}${se(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:re,toString:re})),Tt(le,(function(t,e,n,o){return 1===arguments.length?ce(t):new le(t,e,n,null==o?1:o)}),jt(zt,{brighter(t){return t=null==t?Dt:Math.pow(Dt,t),new le(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Rt:Math.pow(Rt,t),new le(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*e,r=2*n-o;return new ne(fe(t>=240?t-240:t+120,r,o),fe(t,r,o),fe(t<120?t+240:t-120,r,o),this.opacity)},clamp(){return new le(de(this.h),he(this.s),he(this.l),ie(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 t=ie(this.opacity);return`${1===t?"hsl(":"hsla("}${de(this.h)}, ${100*he(this.s)}%, ${100*he(this.l)}%${1===t?")":`, ${t})`}`}}));var ge=t=>()=>t;function pe(t){return 1==(t=+t)?me:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(o){return Math.pow(t+o*e,n)}}(e,n,t):ge(isNaN(e)?n:e)}}function me(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):ge(isNaN(t)?e:t)}var ye=function t(e){var n=pe(e);function o(t,e){var o=n((t=ee(t)).r,(e=ee(e)).r),r=n(t.g,e.g),i=n(t.b,e.b),a=me(t.opacity,e.opacity);return function(e){return t.r=o(e),t.g=r(e),t.b=i(e),t.opacity=a(e),t+""}}return o.gamma=t,o}(1);function ve(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var xe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,be=new RegExp(xe.source,"g");function we(t,e){var n,o,r,i=xe.lastIndex=be.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=xe.exec(t))&&(o=be.exec(e));)(r=o.index)>i&&(r=e.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:ve(n,o)})),i=be.lastIndex;return i<e.length&&(r=e.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,o=0;o<e;++o)s[(n=u[o]).i]=n.x(t);return s.join("")})}var _e,Ee=180/Math.PI,Se={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ne(t,e,n,o,r,i){var a,s,u;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(u=t*n+e*o)&&(n-=t*u,o-=e*u),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,u/=s),t*o<e*n&&(t=-t,e=-e,u=-u,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(e,t)*Ee,skewX:Math.atan(u)*Ee,scaleX:a,scaleY:s}}function Pe(t,e,n,o){function r(t){return t.length?t.pop()+" ":""}return function(i,a){var s=[],u=[];return i=t(i),a=t(a),function(t,o,r,i,a,s){if(t!==r||o!==i){var u=a.push("translate(",null,e,null,n);s.push({i:u-4,x:ve(t,r)},{i:u-2,x:ve(o,i)})}else(r||i)&&a.push("translate("+r+e+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,u),function(t,e,n,i){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:ve(t,e)})):e&&n.push(r(n)+"rotate("+e+o)}(i.rotate,a.rotate,s,u),function(t,e,n,i){t!==e?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:ve(t,e)}):e&&n.push(r(n)+"skewX("+e+o)}(i.skewX,a.skewX,s,u),function(t,e,n,o,i,a){if(t!==n||e!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:ve(t,n)},{i:s-2,x:ve(e,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(t){for(var e,n=-1,o=u.length;++n<o;)s[(e=u[n]).i]=e.x(t);return s.join("")}}}var Me=Pe((function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?Se:Ne(e.a,e.b,e.c,e.d,e.e,e.f)}),"px, ","px)","deg)"),Ce=Pe((function(t){return null==t?Se:(_e||(_e=document.createElementNS("http://www.w3.org/2000/svg","g")),_e.setAttribute("transform",t),(t=_e.transform.baseVal.consolidate())?Ne((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):Se)}),", ",")",")");function ke(t){return((t=Math.exp(t))+1/t)/2}var $e,Ae,Be=function t(e,n,o){function r(t,r){var i,a,s=t[0],u=t[1],c=t[2],l=r[0],d=r[1],h=r[2],f=l-s,g=d-u,p=f*f+g*g;if(p<1e-12)a=Math.log(h/c)/e,i=function(t){return[s+t*f,u+t*g,c*Math.exp(e*t*a)]};else{var m=Math.sqrt(p),y=(h*h-c*c+o*p)/(2*c*n*m),v=(h*h-c*c-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)/e,i=function(t){var o,r=t*a,i=ke(x),l=c/(n*m)*(i*(o=e*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(t){return((t=Math.exp(t))-1/t)/2}(x));return[s+l*f,u+l*g,c*i/ke(e*r+x)]}}return i.duration=1e3*a*e/Math.SQRT2,i}return r.rho=function(e){var n=Math.max(.001,+e),o=n*n;return t(n,o,o*o)},r}(Math.SQRT2,2,4),Ie=0,Te=0,je=0,ze=1e3,Re=0,De=0,Oe=0,Xe="object"==typeof performance&&performance.now?performance:Date,Ye="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Le(){return De||(Ye(Ze),De=Xe.now()+Oe)}function Ze(){De=0}function Ve(){this._call=this._time=this._next=null}function Ue(t,e,n){var o=new Ve;return o.restart(t,e,n),o}function qe(){De=(Re=Xe.now())+Oe,Ie=Te=0;try{!function(){Le(),++Ie;for(var t,e=$e;e;)(t=De-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ie}()}finally{Ie=0,function(){var t,e,n=$e,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:$e=e);Ae=t,We(o)}(),De=0}}function Fe(){var t=Xe.now(),e=t-Re;e>ze&&(Oe-=e,Re=t)}function We(t){Ie||(Te&&(Te=clearTimeout(Te)),t-De>24?(t<1/0&&(Te=setTimeout(qe,t-Xe.now()-Oe)),je&&(je=clearInterval(je))):(je||(Re=Xe.now(),je=setInterval(Fe,ze)),Ie=1,Ye(qe)))}function Ke(t,e,n){var o=new Ve;return e=null==e?0:+e,o.restart((n=>{o.stop(),t(n+e)}),e,n),o}Ve.prototype=Ue.prototype={constructor:Ve,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Le():+n)+(null==e?0:+e),this._next||Ae===this||(Ae?Ae._next=this:$e=this,Ae=this),this._call=t,this._time=n,We()},stop:function(){this._call&&(this._call=null,this._time=1/0,We())}};var He=vt("start","end","cancel","interrupt"),Ge=[],Qe=0,Je=1,tn=2,en=3,nn=4,on=5,rn=6;function an(t,e,n,o,r,i){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var o,r=t.__transition;function i(t){n.state=Je,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(i){var c,l,d,h;if(n.state!==Je)return u();for(c in r)if((h=r[c]).name===n.name){if(h.state===en)return Ke(a);h.state===nn?(h.state=rn,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete r[c]):+c<e&&(h.state=rn,h.timer.stop(),h.on.call("cancel",t,t.__data__,h.index,h.group),delete r[c])}if(Ke((function(){n.state===en&&(n.state=nn,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=tn,n.on.call("start",t,t.__data__,n.index,n.group),n.state===tn){for(n.state=en,o=new Array(d=n.tween.length),c=0,l=-1;c<d;++c)(h=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(o[++l]=h);o.length=l+1}}function s(e){for(var r=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=on,1),i=-1,a=o.length;++i<a;)o[i].call(t,r);n.state===on&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var o in n.state=rn,n.timer.stop(),delete r[e],r)return;delete t.__transition}r[e]=n,n.timer=Ue(i,0,n.time)}(t,n,{name:e,index:o,group:r,on:He,tween:Ge,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Qe})}function sn(t,e){var n=cn(t,e);if(n.state>Qe)throw new Error("too late; already scheduled");return n}function un(t,e){var n=cn(t,e);if(n.state>en)throw new Error("too late; already running");return n}function cn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function ln(t,e){var n,o,r,i=t.__transition,a=!0;if(i){for(r in e=null==e?null:e+"",i)(n=i[r]).name===e?(o=n.state>tn&&n.state<on,n.state=rn,n.timer.stop(),n.on.call(o?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete t.__transition}}function dn(t,e){var n,o;return function(){var r=un(this,t),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a<s;++a)if(o[a].name===e){(o=o.slice()).splice(a,1);break}r.tween=o}}function hn(t,e,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=un(this,t),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:e,value:n},u=0,c=r.length;u<c;++u)if(r[u].name===e){r[u]=s;break}u===c&&r.push(s)}i.tween=r}}function fn(t,e,n){var o=t._id;return t.each((function(){var t=un(this,o);(t.value||(t.value={}))[e]=n.apply(this,arguments)})),function(t){return cn(t,o).value[e]}}function gn(t,e){var n;return("number"==typeof e?ve:e instanceof Qt?ye:(n=Qt(e))?(e=n,ye):we)(t,e)}function pn(t){return function(){this.removeAttribute(t)}}function mn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function yn(t,e,n){var o,r,i=n+"";return function(){var a=this.getAttribute(t);return a===i?null:a===o?r:r=e(o=a,n)}}function vn(t,e,n){var o,r,i=n+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===i?null:a===o?r:r=e(o=a,n)}}function xn(t,e,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttribute(t))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=e(o=a,u));this.removeAttribute(t)}}function bn(t,e,n){var o,r,i;return function(){var a,s,u=n(this);if(null!=u)return(a=this.getAttributeNS(t.space,t.local))===(s=u+"")?null:a===o&&s===r?i:(r=s,i=e(o=a,u));this.removeAttributeNS(t.space,t.local)}}function wn(t,e){var n,o;function r(){var r=e.apply(this,arguments);return r!==o&&(n=(o=r)&&function(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}(t,r)),n}return r._value=e,r}function _n(t,e){var n,o;function r(){var r=e.apply(this,arguments);return r!==o&&(n=(o=r)&&function(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}(t,r)),n}return r._value=e,r}function En(t,e){return function(){sn(this,t).delay=+e.apply(this,arguments)}}function Sn(t,e){return e=+e,function(){sn(this,t).delay=e}}function Nn(t,e){return function(){un(this,t).duration=+e.apply(this,arguments)}}function Pn(t,e){return e=+e,function(){un(this,t).duration=e}}var Mn=gt.prototype.constructor;function Cn(t){return function(){this.style.removeProperty(t)}}var kn=0;function $n(t,e,n,o){this._groups=t,this._parents=e,this._name=n,this._id=o}function An(){return++kn}var Bn=gt.prototype;$n.prototype={constructor:$n,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=l(t));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,u,c=o[a],d=c.length,h=i[a]=new Array(d),f=0;f<d;++f)(s=c[f])&&(u=t.call(s,s.__data__,f,c))&&("__data__"in s&&(u.__data__=s.__data__),h[f]=u,an(h[f],e,n,f,h,cn(s,n)));return new $n(i,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=h(t));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var u,c=o[s],l=c.length,d=0;d<l;++d)if(u=c[d]){for(var f,g=t.call(u,u.__data__,d,c),p=cn(u,n),m=0,y=g.length;m<y;++m)(f=g[m])&&an(f,e,n,m,g,p);i.push(g),a.push(u)}return new $n(i,a,e,n)},selectChild:Bn.selectChild,selectChildren:Bn.selectChildren,filter:function(t){"function"!=typeof t&&(t=g(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a=e[r],s=a.length,u=o[r]=[],c=0;c<s;++c)(i=a[c])&&t.call(i,i.__data__,c,a)&&u.push(i);return new $n(o,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,o=e.length,r=n.length,i=Math.min(o,r),a=new Array(o),s=0;s<i;++s)for(var u,c=e[s],l=n[s],d=c.length,h=a[s]=new Array(d),f=0;f<d;++f)(u=c[f]||l[f])&&(h[f]=u);for(;s<o;++s)a[s]=e[s];return new $n(a,this._parents,this._name,this._id)},selection:function(){return new Mn(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=An(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,c=0;c<u;++c)if(a=s[c]){var l=cn(a,e);an(a,t,n,c,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new $n(o,this._parents,t,n)},call:Bn.call,nodes:Bn.nodes,node:Bn.node,size:Bn.size,empty:Bn.empty,each:Bn.each,on:function(t,e){var n=this._id;return arguments.length<2?cn(this.node(),n).on.on(t):this.each(function(t,e,n){var o,r,i=function(t){return(t+"").trim().split(/^|\s+/).every((function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?sn:un;return function(){var a=i(this,t),s=a.on;s!==o&&(r=(o=s).copy()).on(e,n),a.on=r}}(n,t,e))},attr:function(t,e){var n=i(t),o="transform"===n?Ce:gn;return this.attrTween(t,"function"==typeof e?(n.local?bn:xn)(n,o,fn(this,"attr."+t,e)):null==e?(n.local?mn:pn)(n):(n.local?vn:yn)(n,o,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var o=i(t);return this.tween(n,(o.local?wn:_n)(o,e))},style:function(t,e,n){var o="transform"==(t+="")?Me:gn;return null==e?this.styleTween(t,function(t,e){var n,o,r;return function(){var i=R(this,t),a=(this.style.removeProperty(t),R(this,t));return i===a?null:i===n&&a===o?r:r=e(n=i,o=a)}}(t,o)).on("end.style."+t,Cn(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var o,r,i;return function(){var a=R(this,t),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=R(this,t)),a===u?null:a===o&&u===r?i:(r=u,i=e(o=a,s))}}(t,o,fn(this,"style."+t,e))).each(function(t,e){var n,o,r,i,a="style."+e,s="end."+a;return function(){var u=un(this,t),c=u.on,l=null==u.value[a]?i||(i=Cn(e)):void 0;c===n&&r===l||(o=(n=c).copy()).on(s,r=l),u.on=o}}(this._id,t)):this.styleTween(t,function(t,e,n){var o,r,i=n+"";return function(){var a=R(this,t);return a===i?null:a===o?r:r=e(o=a,n)}}(t,o,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var o="style."+(t+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==e)return this.tween(o,null);if("function"!=typeof e)throw new Error;return this.tween(o,function(t,e,n){var o,r;function i(){var i=e.apply(this,arguments);return i!==r&&(o=(r=i)&&function(t,e,n){return function(o){this.style.setProperty(t,e.call(this,o),n)}}(t,i,n)),o}return i._value=e,i}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(fn(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function o(){var o=t.apply(this,arguments);return o!==n&&(e=(n=o)&&function(t){return function(e){this.textContent=t.call(this,e)}}(o)),e}return o._value=t,o}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var o,r=cn(this.node(),n).tween,i=0,a=r.length;i<a;++i)if((o=r[i]).name===t)return o.value;return null}return this.each((null==e?dn:hn)(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?En:Sn)(e,t)):cn(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?Nn:Pn)(e,t)):cn(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw new Error;return function(){un(this,t).ease=e}}(e,t)):cn(this.node(),e).ease},easeVarying:function(t){if("function"!=typeof t)throw new Error;return this.each(function(t,e){return function(){var n=e.apply(this,arguments);if("function"!=typeof n)throw new Error;un(this,t).ease=n}}(this._id,t))},end:function(){var t,e,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!==t&&((e=(t=r).copy())._.cancel.push(s),e._.interrupt.push(s),e._.end.push(u)),n.on=e})),0===r&&i()}))},[Symbol.iterator]:Bn[Symbol.iterator]};var In={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};function Tn(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}gt.prototype.interrupt=function(t){return this.each((function(){ln(this,t)}))},gt.prototype.transition=function(t){var e,n;t instanceof $n?(e=t._id,t=t._name):(e=An(),(n=In).time=Le(),t=null==t?null:t+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,c=0;c<u;++c)(a=s[c])&&an(a,t,e,c,s,n||Tn(a,e));return new $n(o,this._parents,t,e)};var jn=t=>()=>t;function zn(t,{sourceEvent:e,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Rn(t,e,n){this.k=t,this.x=e,this.y=n}Rn.prototype={constructor:Rn,scale:function(t){return 1===t?this:new Rn(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new Rn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Dn,On=new Rn(1,0,0);function Xn(t){for(;!t.__zoom;)if(!(t=t.parentNode))return On;return t.__zoom}function Yn(t){t.stopImmediatePropagation()}function Ln(t){t.preventDefault(),t.stopImmediatePropagation()}function Zn(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Vn(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Un(){return this.__zoom||On}function qn(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Fn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wn(t,e,n){var o=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],i=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.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=Rn.prototype,t.Position=void 0,(Dn=t.Position||(t.Position={})).Left="left",Dn.Top="top",Dn.Right="right",Dn.Bottom="bottom";const Kn="internals";t.MarkerType=void 0,(t.MarkerType||(t.MarkerType={})).Arrow="arrow";const Hn=t=>({width:t.offsetWidth,height:t.offsetHeight}),Gn=(t,e,n,o)=>{const r=e.querySelectorAll(t);if(!r||!r.length)return null;const i=Array.from(r),a=e.getBoundingClientRect(),s=a.width*o[0],u=a.height*o[1];return i.map((t=>{const e=t.getBoundingClientRect();return{id:t.getAttribute("data-portid"),position:t.dataset.portPosition,x:(e.left-a.left-s)/n,y:(e.top-a.top-u)/n,...Hn(t)}}))},Qn=t=>"clientX"in t,Jn=(t,e)=>{const n=Qn(t),o=n?t.clientX:t.touches?.[0].clientX,r=n?t.clientY:t.touches?.[0].clientY;return{x:o-(e?.left??0),y:r-(e?.top??0)}},to=({x:t,y:e},[n,o,r])=>({x:(t-n)/r,y:(e-o)/r}),eo=({x:t,y:e},[n,o,r])=>({x:t*r+n,y:e*r+o}),no=(t,{transform:e,gridStep:n,centerStep:o})=>{const{x:r,y:i}=Jn(t),a=to({x:r,y:i},e);return{getStepPosition:(t={position:a})=>{const{position:e,nodeSize:r}=t;if(!n)return e;let i=n[0]*Math.round(e.x/n[0]),s=n[1]*Math.round(e.y/n[1]);if(o&&r){const t=(n[0]-r.width)/2,o=(n[1]-r.height)/2,a=e.x-t,u=e.y-o;i=n[0]*Math.round(a/n[0])+t,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":t=>`Node type "${t}" 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":t=>`The old edge with id=${t} does not exist.`,"022":t=>`Marker type "${t}" doesn't exist.`},ro=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),io=(t,e,n,o)=>{const r=e-n;return t<n?ro(Math.abs(t-n),1,50)/50*o:t>r?-ro(Math.abs(t-r),1,50)/50*o:0},ao=(t,e)=>[io(t.x,e.width,30,10),io(t.y,e.height,30,10)],so=({x:t,y:e,width:n,height:o})=>({x:t,y:e,x2:t+n,y2:e+o}),uo=({x:t,y:e,x2:n,y2:o})=>({x:t,y:e,width:n-t,height:o-e}),co=t=>!isNaN(t)&&isFinite(t),lo=(t={x:0,y:0},e)=>({x:ro(t.x,e[0][0],e[1][0]),y:ro(t.y,e[0][1],e[1][1])}),ho=t=>"source"in t&&"target"in t,fo=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],o=(t.height??0)*e[1],r={x:t.position.x-n,y:t.position.y-o};return{...r,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-o}:r}},go=(t,e,[n,o,r]=[0,0,1],i=!1,a=!1,s=[0,0])=>{const u={x:(e.x-n)/r,y:(e.y-o)/r,width:e.width/r,height:e.height/r},c=[];return t.forEach((t=>{const{width:e,height:n,selectable:o=!0,hidden:r=!1}=t;if(a&&!o||r)return!1;const{positionAbsolute:l}=fo(t,s),d={x:l.x,y:l.y,width:e||0,height:n||0},h=((t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),o=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*o)})(u,d);(void 0===e||void 0===n||null===e||null===n||i&&h>0||h>=(e||0)*(n||0)||t.dragging)&&c.push(t)})),c},po=(t,e=[0,0])=>{if(0===t.length)return{x:0,y:0,width:0,height:0};const n=t.reduce(((t,n)=>{const{x:o,y:r}=fo(n,e).positionAbsolute,i=so({x:o,y:r,width:n.width||0,height:n.height||0});return a=t,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)},mo=(t,e)=>{if(void 0===t)return"";if("string"==typeof t)return t;return`${e?`${e}__`:""}${Object.keys(t).sort().map((e=>`${e}=${t[e]}`)).join("&")}`},yo=({sourceX:t,sourceY:e,targetX:n,targetY:o})=>{const r=Math.abs(n-t)/2,i=n<t?n+r:n-r,a=Math.abs(o-e)/2;return[i,o<e?o+a:o-a,r,a]},vo=({source:t,sourcePort:e,target:n,targetPort:o})=>`react-diagram__edge-${t}${e}-${n}${o}`,xo={[t.Position.Left]:{x:-1,y:0},[t.Position.Right]:{x:1,y:0},[t.Position.Top]:{x:0,y:-1},[t.Position.Bottom]:{x:0,y:1}},bo=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),wo=({source:e,sourcePosition:n=t.Position.Bottom,target:o,targetPosition:r=t.Position.Top,center:i,offset:a})=>{const s=xo[n],u=xo[r],c={x:e.x+s.x*a,y:e.y+s.y*a},l={x:o.x+u.x*a,y:o.y+u.y*a},d=(({source:e,sourcePosition:n=t.Position.Bottom,target:o})=>n===t.Position.Left||n===t.Position.Right?e.x<o.x?{x:1,y:0}:{x:-1,y:0}:e.y<o.y?{x:0,y:1}:{x:0,y:-1})({source:c,sourcePosition:n,target:l}),h=0!==d.x?"x":"y",f=d[h];let g=[],p=0,m=0;const[y,v,x,b]=yo({sourceX:e.x,sourceY:e.y,targetX:o.x,targetY:o.y});if(s[h]*u[h]==-1){p=i.x||y,m=i.y||v;const t=[{x:p,y:c.y},{x:p,y:l.y}],e=[{x:c.x,y:m},{x:l.x,y:m}];g=s[h]!==f?"x"===h?e:t:"x"===h?t:e}return[[e,c,...g,l,o],p,m,x,b]},_o=({sourceX:e,sourceY:n,sourcePosition:o=t.Position.Bottom,targetX:r,targetY:i,targetPosition:a=t.Position.Top,borderRadius:s=5,centerX:u,centerY:c,offset:l=20})=>{const[d,h,f,g,p]=wo({source:{x:e,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:u,y:c},offset:l});return[d.reduce(((t,e,n)=>{let o="";return o=n>0&&n<d.length-1?((t,e,n,o)=>{const r=Math.min(bo(t,e)/2,bo(e,n)/2,o),{x:i,y:a}=e;if(t.x===i&&i===n.x||t.y===a&&a===n.y)return`L${i} ${a}`;if(t.y===a)return`L ${i+r*(t.x<n.x?-1:1)},${a}Q ${i},${a} ${i},${a+r*(t.y<n.y?1:-1)}`;const s=t.x<n.x?1:-1;return`L ${i},${a+r*(t.y<n.y?-1:1)}Q ${i},${a} ${i+r*s},${a}`})(d[n-1],e,d[n+1],s):`${0===n?"M":"L"}${e.x} ${e.y}`,t+=o}),""),h,f,g,p]},Eo=({sourceX:t,sourceY:e,targetX:n,targetY:o})=>{const[r,i,a,s]=yo({sourceX:t,sourceY:e,targetX:n,targetY:o});return[`M ${t},${e}L ${n},${o}`,r,i,a,s]},So=({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s})=>{const u=.125,c=.375,l=t*u+r*c+a*c+n*u,d=e*u+i*c+s*c+o*u;return[l,d,Math.abs(l-t),Math.abs(d-e)]},No=(t,e)=>t>=0?.5*t:25*e*Math.sqrt(-t),Po=({pos:e,x1:n,y1:o,x2:r,y2:i,c:a})=>{switch(e){case t.Position.Left:return[n-No(n-r,a),o];case t.Position.Right:return[n+No(r-n,a),o];case t.Position.Top:return[n,o-No(o-i,a)];case t.Position.Bottom:return[n,o+No(i-o,a)]}},Mo=({sourceX:e,sourceY:n,sourcePosition:o=t.Position.Bottom,targetX:r,targetY:i,targetPosition:a=t.Position.Top,curvature:s=.25})=>{const[u,c]=Po({pos:o,x1:e,y1:n,x2:r,y2:i,c:s}),[l,d]=Po({pos:a,x1:r,y1:i,x2:e,y2:n,c:s}),[h,f,g,p]=So({sourceX:e,sourceY:n,targetX:r,targetY:i,sourceControlX:u,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${n} C${u},${c} ${l},${d} ${r},${i}`,h,f,g,p]},Co=(t,e,n,o)=>(e[n]||[]).reduce(((e,r)=>(`${t.id}-${r.id}-${n}`!==o&&e.push({portId:r.id||null,portType:n,nodeId:t.id,x:(t.positionAbsolute?.x??0)+r.x+r.width/2,y:(t.positionAbsolute?.y??0)+r.y+r.height/2}),e)),[]),ko=t=>t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null;let $o=null;const Ao=({isAnchor:t=!1,event:e,nodeId:n,portId:o,portType:r,domNode:i,autoPanOnConnect:a,connectionRadius:s,nodes:u,getTransform:c,cancelConnection:l,onConnectStart:d,onConnect:h,onConnectEnd:f,onEdgeUpdateEnd:g,panBy:p,updateConnection:m})=>{const y=(v=e.target,v.getRootNode?.()||window?.document);var v;const x=i?.getBoundingClientRect(),{x:b,y:w}=Jn(e),_=y?.elementFromPoint(b,w),E=t?r:ko(_),S=(({nodes:t,nodeId:e,portId:n,portType:o})=>t.reduce(((t,r)=>{if(r[Kn]){const{portBounds:i}=r[Kn];let a=[],s=[];i&&(a=Co(r,i,"source",`${e}-${n}-${o}`),s=Co(r,i,"target",`${e}-${n}-${o}`)),t.push(...a,...s)}return t}),[]))({nodes:u,nodeId:n,portId:o,portType:r});let N=Jn(e,x),P=null,M=!1,C=null,k=0,$=!1;if(!x||!r)return;const A=()=>{if(!a)return;const[t,e]=ao(N,x);p({x:t,y:e}),k=requestAnimationFrame(A)};$o={nodeId:n,portId:o,portType:E},m({connectionPosition:N,connectionStartPort:$o,connectionEndPort:null}),d?.(e,{nodeId:n,portId:o,portType:r});const B=t=>{const e=c();N=Jn(t,x),P=((t,e,n)=>{let o=null,r=1/0;return n.forEach((n=>{const i=Math.sqrt(Math.pow(n.x-t.x,2)+Math.pow(n.y-t.y,2));i<=e&&i<r&&(r=i,o=n)})),o})(to(N,e),s,S),$||(A(),$=!0);const i=((t,e,n,o,r,i)=>{const a="target"===r,s={isValid:!1,connection:null,endPort:null},u=i.querySelector(`.react-diagram__port[data-id="${e?.nodeId}-${e?.portId}-${e?.portType}"]`),{x:c,y:l}=Jn(t),d=i.elementFromPoint(c,l),h=d?.classList.contains("react-diagram__port")?d:u;if(h){const t=ko(h),r=h.getAttribute("data-nodeid"),i=h.getAttribute("data-portid"),u={source:a?r:n,target:a?n:r,sourcePort:a?e?.portId||null:o,targetPort:a?o:e?.portId||null};s.connection=u,(a&&"source"===t||!a&&"target"===t)&&(s.isValid=!0,s.endPort={nodeId:r,portId:i,portType:t})}return s})(t,P,n,o,r,y);M=i.isValid,C=i.connection,m({connectionPosition:P&&M?eo(P,e):N,connectionStartPort:$o,connectionEndPort:i.endPort})},I=t=>{M&&C&&h?.(C),f?.(t),r&&g?.(t),l(),cancelAnimationFrame(k),M=!1,C=null,$=!1,y.removeEventListener("mousemove",B),y.removeEventListener("mouseup",I),y.removeEventListener("touchmove",B),y.removeEventListener("touchend",I)};y.addEventListener("mousemove",B),y.addEventListener("mouseup",I),y.addEventListener("touchmove",B),y.addEventListener("touchend",I)},Bo=(t,e)=>{if(!t.parentNode)return!1;const n=e.get(t.parentNode);return!!n&&(!!n.selected||Bo(n,e))},Io=(t,e)=>t.x!==e.x||t.y!==e.y,To=({nodeId:t,dragItems:e,nodeInternals:n})=>{const o=e.map((t=>({...n.get(t.id),position:t.position,positionAbsolute:t.positionAbsolute})));return[t?o.find((e=>e.id===t)):o[0],o]},jo=({getStore:t,onNodeMouseDown:e,onDragStart:n,onDrag:o,onDragEnd:r})=>{let i=[],a=null,s={x:0,y:0},u={x:0,y:0},c=null,l=!1,d=0,h=null;return{update:({domNode:f,nodeId:g,noDragClassName:p})=>{const m=(e,n=!1)=>o=>{if(!("distance"in o))return;const{nodeInternals:r,nodeExtent:i,nodeOrigin:a,smoothStep:s,gridStep:u}=t(),{distance:c,width:l,height:d}=o,{x:h,y:f,getStepPosition:g}=e;let p={x:h-c.x,y:f-c.y};if(u&&g){const t=g({position:p,nodeSize:{width:l,height:d}});(!s||s&&n)&&(p=t)}const m=((t,e,n,o,r=[0,0])=>{let i=t.extent||o;if(t.extent&&t.parentNode){const e=n.get(t.parentNode),{x:o,y:a}=fo(e,r).positionAbsolute;i=[[t.extent[0][0]+o,t.extent[0][1]+a],[t.extent[1][0]+o,t.extent[1][1]+a]]}let a={x:0,y:0};if(t.parentNode){const e=n.get(t.parentNode);a=fo(e,r).positionAbsolute}const s=i?lo(e,i):e;return{position:{x:s.x-a.x,y:s.y-a.y},positionAbsolute:s}})(o,p,r,i,a);Io(o.position,m.position)&&(o.position=m.position,o.positionAbsolute=m.positionAbsolute)};h=pt(f);const y=e=>{const{nodeInternals:n,updateNodesPosition:r}=t(),{x:a,y:s}=e;if(u={x:a,y:s},r(i,!0,m(e)),o&&c){const[t,e]=To({nodeId:g,dragItems:i,nodeInternals:n});o(c,i,t,e)}},v=()=>{if(!a)return;const[e,n]=ao(s,a);if(0!==e||0!==n){const{transform:o,panBy:r}=t();u.x-=e/o[2],u.y-=n/o[2],y(u),r({x:e,y:n})}d=requestAnimationFrame(v)},x=o=>{const{nodeInternals:r,nodesDraggable:u,domNode:c,transform:l,gridStep:d,centerStep:h}=t();g&&e?.(g);const f=no(o.sourceEvent,{transform:l,gridStep:d,centerStep:h});if(i=((t,e,n,o)=>Array.from(t.values()).filter((n=>{const r=n.width&&n.height,i=n.selected||n.id===o,a=!n.parentNode||!Bo(n,t),s=n.draggable||e&&void 0===n.draggable;return r&&i&&a&&s})).map((t=>({id:t.id,position:t.position||{x:0,y:0},positionAbsolute:t.positionAbsolute||{x:0,y:0},distance:{x:n.x-(t.positionAbsolute?.x??0),y:n.y-(t.positionAbsolute?.y??0)},extent:t.extent,parentNode:t.parentNode,width:t.width||0,height:t.height||0}))))(r,u,f,g),n&&i){const[t,e]=To({nodeId:g,dragItems:i,nodeInternals:r});n?.(o.sourceEvent,i,t,e)}a=c?.getBoundingClientRect()||null,s=Jn(o.sourceEvent,a)},b=function(){var t,e,n,o,r=$t,i=At,a=Bt,s=It,u={},c=vt("start","drag","end"),l=0,d=0;function h(t){t.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,_t).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&&(pt(a.view).on("mousemove.drag",g,Et).on("mouseup.drag",p,Et),Pt(a.view),St(a),n=!1,t=a.clientX,e=a.clientY,u("start",a))}}function g(o){if(Nt(o),!n){var r=o.clientX-t,i=o.clientY-e;n=r*r+i*i>d}u.mouse("drag",o)}function p(t){pt(t.view).on("mousemove.drag mouseup.drag",null),Mt(t.view,n),Nt(t),u.mouse("end",t)}function m(t,e){if(r.call(this,t,e)){var n,o,a=t.changedTouches,s=i.call(this,t,e),u=a.length;for(n=0;n<u;++n)(o=x(this,s,t,e,a[n].identifier,a[n]))&&(St(t),o("start",t,a[n]))}}function y(t){var e,n,o=t.changedTouches,r=o.length;for(e=0;e<r;++e)(n=u[o[e].identifier])&&(Nt(t),n("drag",t,o[e]))}function v(t){var e,n,r=t.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),e=0;e<i;++e)(n=u[r[e].identifier])&&(St(t),n("end",t,r[e]))}function x(t,e,n,o,r,i){var s,d,f,g=c.copy(),p=mt(i||n,e);if(null!=(f=a.call(t,new kt("beforestart",{sourceEvent:n,target:h,identifier:r,active:l,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,c){var m,y=p;switch(i){case"start":u[r]=n,m=l++;break;case"end":delete u[r],--l;case"drag":p=mt(c||a,e),m=l}g.call(i,t,new kt(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(t){return arguments.length?(r="function"==typeof t?t:Ct(!!t),h):r},h.container=function(t){return arguments.length?(i="function"==typeof t?t:Ct(t),h):i},h.subject=function(t){return arguments.length?(a="function"==typeof t?t:Ct(t),h):a},h.touchable=function(t){return arguments.length?(s="function"==typeof t?t:Ct(!!t),h):s},h.on=function(){var t=c.on.apply(c,arguments);return t===c?h:t},h.clickDistance=function(t){return arguments.length?(d=(t=+t)*t,h):Math.sqrt(d)},h}().on("start",(t=>{x(t)})).on("drag",(e=>{const{transform:n,gridStep:o,centerStep:r,autoPanOnNodeDrag:d,updateNodesIntersection:h}=t(),f=no(e.sourceEvent,{transform:n,gridStep:o,centerStep:r});!l&&d&&(l=!0,v());Io(u,f.getStepPosition())&&i&&(c=e.sourceEvent,s=Jn(e.sourceEvent,a),y(f),h())})).on("end",(e=>{if(l=!1,cancelAnimationFrame(d),i){const{nodeInternals:n,transform:o,gridStep:a,centerStep:s,smoothStep:u,updateNodesPosition:c,updateNodesIntersection:l}=t();if(!!a&&u){const t=no(e.sourceEvent,{transform:o,gridStep:a,centerStep:s});c(i,!1,m(t,!0)),l()}else c(i,!1);if(r){const[t,o]=To({nodeId:g,dragItems:i,nodeInternals:n});r(e.sourceEvent,i,t,o)}}})).filter((t=>{const e=t.target;if(!f)return!1;const n=!(t.button||p&&((t,e,n)=>{let o=t;do{if(o?.matches(e))return!0;if(o===n)return!1;o=o.parentElement}while(o);return!1})(e,`.${p}`,f));return n}));h.call(b)},destroy:()=>{h?.on(".drag",null)}}},zo=t=>{const{x:e,y:n,k:o}=t;return{x:e,y:n,zoom:o}};const Ro=({domNode:t,panning:e,minZoom:n,maxZoom:o,viewport:r,translateExtent:i,onTransformChange:a,onPanningChange:s,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:l})=>{const d={isZoomingOrPanning:!1,timerId:void 0,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,isPanScrolling:!1},h=t.getBoundingClientRect(),f=function(){var t,e,n,o=Zn,r=Vn,i=Wn,a=qn,s=Fn,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],l=250,d=Be,h=vt("start","zoom","end"),f=500,g=150,p=0,m=10;function y(t){t.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(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new Rn(e,t.x,t.y)}function x(t,e,n){var o=e[0]-n[0]*t.k,r=e[1]-n[1]*t.k;return o===t.x&&r===t.y?t:new Rn(t.k,o,r)}function b(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function w(t,e,n,o){t.on("start.zoom",(function(){_(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){_(this,arguments).event(o).end()})).tween("zoom",(function(){var t=this,i=arguments,a=_(t,i).event(o),s=r.apply(t,i),u=null==n?b(s):"function"==typeof n?n.apply(t,i):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),l=t.__zoom,h="function"==typeof e?e.apply(t,i):e,f=d(l.invert(u).concat(c/l.k),h.invert(u).concat(c/h.k));return function(t){if(1===t)t=h;else{var e=f(t),n=c/e[2];t=new Rn(n,u[0]-e[0]*n,u[1]-e[1]*n)}a.zoom(null,t)}}))}function _(t,e,n){return!n&&t.__zooming||new E(t,e)}function E(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=r.apply(t,e),this.taps=0}function S(t,...e){if(o.apply(this,arguments)){var n=_(this,e).event(t),r=this.__zoom,s=Math.max(u[0],Math.min(u[1],r.k*Math.pow(2,a.apply(this,arguments)))),l=mt(t);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[l,r.invert(l)],ln(this),n.start()}Ln(t),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,c))}}function N(t,...e){if(!n&&o.apply(this,arguments)){var r=t.currentTarget,a=_(this,e,!0).event(t),s=pt(t.view).on("mousemove.zoom",(function(t){if(Ln(t),!a.moved){var e=t.clientX-l,n=t.clientY-d;a.moved=e*e+n*n>p}a.event(t).zoom("mouse",i(x(a.that.__zoom,a.mouse[0]=mt(t,r),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(t){s.on("mousemove.zoom mouseup.zoom",null),Mt(t.view,a.moved),Ln(t),a.event(t).end()}),!0),u=mt(t,r),l=t.clientX,d=t.clientY;Pt(t.view),Yn(t),a.mouse=[u,this.__zoom.invert(u)],ln(this),a.start()}}function P(t,...e){if(o.apply(this,arguments)){var n=this.__zoom,a=mt(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),u=n.k*(t.shiftKey?.5:2),d=i(x(v(n,u),a,s),r.apply(this,e),c);Ln(t),l>0?pt(this).transition().duration(l).call(w,d,a,t):pt(this).call(y.transform,d,a,t)}}function M(n,...r){if(o.apply(this,arguments)){var i,a,s,u,c=n.touches,l=c.length,d=_(this,r,n.changedTouches.length===l).event(n);for(Yn(n),a=0;a<l;++a)u=[u=mt(s=c[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+!!t);t&&(t=clearTimeout(t)),i&&(d.taps<2&&(e=u[0],t=setTimeout((function(){t=null}),f)),ln(this),d.start())}}function C(t,...e){if(this.__zooming){var n,o,r,a,s=_(this,e).event(t),u=t.changedTouches,l=u.length;for(Ln(t),n=0;n<l;++n)r=mt(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,c))}}function k(t,...o){if(this.__zooming){var r,i,a=_(this,o).event(t),s=t.changedTouches,u=s.length;for(Yn(t),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=mt(i,this),Math.hypot(e[0]-i[0],e[1]-i[1])<m)){var c=pt(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return y.transform=function(t,e,n,o){var r=t.selection?t.selection():t;r.property("__zoom",Un),t!==r?w(t,e,n,o):r.interrupt().each((function(){_(this,arguments).event(o).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()}))},y.scaleBy=function(t,e,n,o){y.scaleTo(t,(function(){return this.__zoom.k*("function"==typeof e?e.apply(this,arguments):e)}),n,o)},y.scaleTo=function(t,e,n,o){y.transform(t,(function(){var t=r.apply(this,arguments),o=this.__zoom,a=null==n?b(t):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(a),u="function"==typeof e?e.apply(this,arguments):e;return i(x(v(o,u),a,s),t,c)}),n,o)},y.translateBy=function(t,e,n,o){y.transform(t,(function(){return i(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),c)}),null,o)},y.translateTo=function(t,e,n,o,a){y.transform(t,(function(){var t=r.apply(this,arguments),a=this.__zoom,s=null==o?b(t):"function"==typeof o?o.apply(this,arguments):o;return i(On.translate(s[0],s[1]).scale(a.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,c)}),o,a)},E.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=pt(this.that).datum();h.call(t,this.that,new zn(t,{sourceEvent:this.sourceEvent,target:y,type:t,transform:this.that.__zoom,dispatch:h}),e)}},y.wheelDelta=function(t){return arguments.length?(a="function"==typeof t?t:jn(+t),y):a},y.filter=function(t){return arguments.length?(o="function"==typeof t?t:jn(!!t),y):o},y.touchable=function(t){return arguments.length?(s="function"==typeof t?t:jn(!!t),y):s},y.extent=function(t){return arguments.length?(r="function"==typeof t?t:jn([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),y):r},y.scaleExtent=function(t){return arguments.length?(u[0]=+t[0],u[1]=+t[1],y):[u[0],u[1]]},y.translateExtent=function(t){return arguments.length?(c[0][0]=+t[0][0],c[1][0]=+t[1][0],c[0][1]=+t[0][1],c[1][1]=+t[1][1],y):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},y.constrain=function(t){return arguments.length?(i=t,y):i},y.duration=function(t){return arguments.length?(l=+t,y):l},y.interpolate=function(t){return arguments.length?(d=t,y):d},y.on=function(){var t=h.on.apply(h,arguments);return t===h?y:t},y.clickDistance=function(t){return arguments.length?(p=(t=+t)*t,y):Math.sqrt(p)},y.tapDistance=function(t){return arguments.length?(m=+t,y):m},y}().scaleExtent([n,o]).translateExtent(i),g=pt(t).call(f),p=g.on("wheel.zoom"),m=(t,e,n)=>{const o=(({x:t,y:e,zoom:n})=>On.translate(t,e).scale(n))(t),r=f.constrain()(o,e,n);return r&&((t,e)=>{g&&f?.transform(((t,e=0)=>"number"==typeof e&&e>0?t.transition().duration(e):t)(g,e?.duration),t)})(r),r};m({x:r.x,y:r.y,zoom:ro(r.zoom,n,o)},[[0,0],[h.width,h.height]],i);const y=()=>{f.on("zoom",null)};return{update:({noPanClassName:t,selection:n})=>{n&&!d.isZoomingOrPanning&&y();const o=function({d3ZoomHandler:t}){return function(e,n){e.preventDefault(),t.call(this,e,n)}}({d3ZoomHandler:p});if(g.on("wheel.zoom",o,{passive:!1}),!n){const t=(({zoomPanValues:t,onPanningChange:e,onPanZoomStart:n})=>o=>{if(o.sourceEvent?.internal)return;const r=zo(o.transform);t.mouseButton=o.sourceEvent?.button||0,t.isZoomingOrPanning=!0,t.prevViewport=r,"mousedown"===o.sourceEvent?.type&&e(!0),n&&n?.(o.sourceEvent,r)})({zoomPanValues:d,onPanningChange:s,onPanZoomStart:c}),e=(({onPanZoom:t,onTransformChange:e})=>n=>{n.sourceEvent?.sync||e([n.transform.x,n.transform.y,n.transform.k]),t&&!n.sourceEvent?.internal&&t?.(n.sourceEvent,zo(n.transform))})({onPanZoom:u,onTransformChange:a}),n=(({zoomPanValues:t,onPanningChange:e,onPanZoomEnd:n})=>o=>{if(!o.sourceEvent?.internal&&(t.isZoomingOrPanning=!1,e(!1),n&&((t,e)=>{const{x:n,y:o,zoom:r}=t,{x:i,y:a,k:s}=e;return n!==i||o!==a||r!==s})(t.prevViewport,o.transform))){const e=zo(o.transform);t.prevViewport=e,clearTimeout(t.timerId),t.timerId=setTimeout((()=>{n?.(o.sourceEvent,e)}),0)}})({zoomPanValues:d,onPanningChange:s,onPanZoomEnd:l});f.on("start",t),f.on("zoom",e),f.on("end",n)}f.filter((o=>{if(n)return!1;if(((t,e)=>t.target.closest(`.${e}`))(o,t)&&"wheel"!==o.type)return!1;if(!e)return!1;return!(o.button&&!(o.button<=1))}))},destroy:y,getViewport:()=>{const t=g?Xn(g.node()):{x:0,y:0,k:1};return{x:t.x,y:t.y,zoom:t.k}},setViewportConstrained:m}},Do=t=>{let e;const n=new Set,o=(t,o)=>{const r="function"==typeof t?t(e):t;if(!Object.is(r,e)){const t=e;e=(null!=o?o:"object"!=typeof r)?r:Object.assign({},e,r),n.forEach((n=>n(e,t)))}},r=()=>e,i={setState:o,getState:r,subscribe:t=>(n.add(t),()=>n.delete(t)),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 e=t(o,r,i),i};function Oo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xo,Yo,Lo,Zo={exports:{}},Vo={},Uo={exports:{}},qo={};function Fo(){return Yo||(Yo=1,Uo.exports=function(){if(Xo)return qo;Xo=1;var t=n,e="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=t.useState,r=t.useEffect,i=t.useLayoutEffect,a=t.useDebugValue;function s(t){var n=t.getSnapshot;t=t.value;try{var o=n();return!e(t,o)}catch(t){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),u=o({inst:{value:n,getSnapshot:e}}),c=u[0].inst,l=u[1];return i((function(){c.value=n,c.getSnapshot=e,s(c)&&l({inst:c})}),[t,n,e]),r((function(){return s(c)&&l({inst:c}),t((function(){s(c)&&l({inst:c})}))}),[t]),a(n),n};return qo.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:u,qo}()),Uo.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
- */u.exports=function(){if(s)return c;s=1;var e=n,t=h(),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,u=e.useMemo,l=e.useDebugValue;return c.useSyncExternalStoreWithSelector=function(e,t,n,s,c){var d=i(null);if(null===d.current){var h={hasValue:!1,value:null};d.current=h}else h=d.current;d=u((function(){function e(e){if(!a){if(a=!0,r=e,e=s(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=s(e);return void 0!==c&&c(t,n)?t:(r=e,i=n)}var r,i,a=!1,u=void 0===n?null:n;return[function(){return e(t())},null===u?void 0:function(){return e(u())}]}),[t,n,s,c]);var f=r(e,d[0],d[1]);return a((function(){h.hasValue=!0,h.value=f}),[f]),l(f),f},c}();var f=r(u.exports);const{useSyncExternalStoreWithSelector:g}=f;let p=!1;const m=n.createContext(null),y=m.Provider,v={"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.`},x=v["001"]();function b(e,t){const o=n.useContext(m);if(null===o)throw new Error(x);return function(e,t=e.getState,o){o&&!p&&(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"),p=!0);const r=g(e.subscribe,e.getState,e.getServerState||e.getState,t,o);return n.useDebugValue(r),r}(o,e,t)}const w=()=>{const e=n.useContext(m);if(null===e)throw new Error(x);return n.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])};var _={value:()=>{}};function E(){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 S(o)}function S(e){this._=e}function N(e,t){for(var n,o=0,r=e.length;o<r;++o)if((n=e[o]).name===t)return n.value}function M(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=_,e=e.slice(0,o).concat(e.slice(o+1));break}return null!=n&&e.push({name:t,value:n}),e}S.prototype=E.prototype={constructor:S,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]=M(r[n],e.name,t);else if(null==t)for(n in r)r[n]=M(r[n],e.name,null);return this}for(;++a<s;)if((n=(e=i[a]).type)&&(n=N(r[n],e.name)))return n},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new S(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)}};var k="http://www.w3.org/1999/xhtml",C={svg:"http://www.w3.org/2000/svg",xhtml:k,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function P(e){var t=e+="",n=t.indexOf(":");return n>=0&&"xmlns"!==(t=e.slice(0,n))&&(e=e.slice(n+1)),C.hasOwnProperty(t)?{space:C[t],local:e}:e}function A(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===k&&t.documentElement.namespaceURI===k?t.createElement(e):t.createElementNS(n,e)}}function $(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function B(e){var t=P(e);return(t.local?$:A)(t)}function T(){}function R(e){return null==e?T:function(){return this.querySelector(e)}}function j(){return[]}function I(e){return null==e?j:function(){return this.querySelectorAll(e)}}function z(e){return function(){return null==(t=e.apply(this,arguments))?[]:Array.isArray(t)?t:Array.from(t);var t}}function D(e){return function(){return this.matches(e)}}function X(e){return function(t){return t.matches(e)}}var O=Array.prototype.find;function Y(){return this.firstElementChild}var L=Array.prototype.filter;function U(){return Array.from(this.children)}function q(e){return new Array(e.length)}function V(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}function Z(e,t,n,o,r,i){for(var a,s=0,u=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new V(e,i[s]);for(;s<u;++s)(a=t[s])&&(r[s]=a)}function W(e,t,n,o,r,i,a){var s,u,c,l=new Map,d=t.length,h=i.length,f=new Array(d);for(s=0;s<d;++s)(u=t[s])&&(f[s]=c=a.call(u,u.__data__,s,t)+"",l.has(c)?r[s]=u:l.set(c,u));for(s=0;s<h;++s)c=a.call(e,i[s],s,i)+"",(u=l.get(c))?(o[s]=u,u.__data__=i[s],l.delete(c)):n[s]=new V(e,i[s]);for(s=0;s<d;++s)(u=t[s])&&l.get(f[s])===u&&(r[s]=u)}function F(e){return e.__data__}function K(e){return"object"==typeof e&&"length"in e?e:Array.from(e)}function H(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function G(e){return function(){this.removeAttribute(e)}}function Q(e){return function(){this.removeAttributeNS(e.space,e.local)}}function J(e,t){return function(){this.setAttribute(e,t)}}function ee(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function te(e,t){return function(){var n=t.apply(this,arguments);null==n?this.removeAttribute(e):this.setAttribute(e,n)}}function ne(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 oe(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function re(e){return function(){this.style.removeProperty(e)}}function ie(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ae(e,t,n){return function(){var o=t.apply(this,arguments);null==o?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function se(e,t){return e.style.getPropertyValue(t)||oe(e).getComputedStyle(e,null).getPropertyValue(t)}function ue(e){return function(){delete this[e]}}function ce(e,t){return function(){this[e]=t}}function le(e,t){return function(){var n=t.apply(this,arguments);null==n?delete this[e]:this[e]=n}}function de(e){return e.trim().split(/^|\s+/)}function he(e){return e.classList||new fe(e)}function fe(e){this._node=e,this._names=de(e.getAttribute("class")||"")}function ge(e,t){for(var n=he(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function pe(e,t){for(var n=he(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function me(e){return function(){ge(this,e)}}function ye(e){return function(){pe(this,e)}}function ve(e,t){return function(){(t.apply(this,arguments)?ge:pe)(this,e)}}function xe(){this.textContent=""}function be(e){return function(){this.textContent=e}}function we(e){return function(){var t=e.apply(this,arguments);this.textContent=null==t?"":t}}function _e(){this.innerHTML=""}function Ee(e){return function(){this.innerHTML=e}}function Se(e){return function(){var t=e.apply(this,arguments);this.innerHTML=null==t?"":t}}function Ne(){this.nextSibling&&this.parentNode.appendChild(this)}function Me(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ke(){return null}function Ce(){var e=this.parentNode;e&&e.removeChild(this)}function Pe(){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 $e(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 Be(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 Te(e,t,n){var o=oe(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 Re(e,t){return function(){return Te(this,e,t)}}function je(e,t){return function(){return Te(this,e,t.apply(this,arguments))}}V.prototype={constructor:V,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)}},fe.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 Ie=[null];function ze(e,t){this._groups=e,this._parents=t}function De(){return new ze([[document.documentElement]],Ie)}function Xe(e){return"string"==typeof e?new ze([[document.querySelector(e)]],[document.documentElement]):new ze([[e]],Ie)}function Oe(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]}ze.prototype=De.prototype={constructor:ze,select:function(e){"function"!=typeof e&&(e=R(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,c=o[r]=new Array(u),l=0;l<u;++l)(i=s[l])&&(a=e.call(i,i.__data__,l,s))&&("__data__"in i&&(a.__data__=i.__data__),c[l]=a);return new ze(o,this._parents)},selectAll:function(e){e="function"==typeof e?z(e):I(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,c=0;c<u;++c)(a=s[c])&&(o.push(e.call(a,a.__data__,c,s)),r.push(a));return new ze(o,r)},selectChild:function(e){return this.select(null==e?Y:function(e){return function(){return O.call(this.children,e)}}("function"==typeof e?e:X(e)))},selectChildren:function(e){return this.selectAll(null==e?U:function(e){return function(){return L.call(this.children,e)}}("function"==typeof e?e:X(e)))},filter:function(e){"function"!=typeof e&&(e=D(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]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&u.push(i);return new ze(o,this._parents)},data:function(e,t){if(!arguments.length)return Array.from(this,F);var n,o=t?W:Z,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),c=new Array(a),l=0;l<a;++l){var d=r[l],h=i[l],f=h.length,g=K(e.call(d,d&&d.__data__,l,r)),p=g.length,m=u[l]=new Array(p),y=s[l]=new Array(p);o(d,h,m,y,c[l]=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 ze(s,r))._enter=u,s._exit=c,s},enter:function(){return new ze(this._enter||this._groups.map(q),this._parents)},exit:function(){return new ze(this._exit||this._groups.map(q),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 c,l=n[u],d=o[u],h=l.length,f=s[u]=new Array(h),g=0;g<h;++g)(c=l[g]||d[g])&&(f[g]=c);for(;u<r;++u)s[u]=n[u];return new ze(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=H);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,c=r[i]=new Array(u),l=0;l<u;++l)(a=s[l])&&(c[l]=a);c.sort(t)}return new ze(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=P(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?Q:G:"function"==typeof t?n.local?ne:te:n.local?ee:J)(n,t))},style:function(e,t,n){return arguments.length>1?this.each((null==t?re:"function"==typeof t?ae:ie)(e,t,null==n?"":n)):se(this.node(),e)},property:function(e,t){return arguments.length>1?this.each((null==t?ue:"function"==typeof t?le:ce)(e,t)):this.node()[e]},classed:function(e,t){var n=de(e+"");if(arguments.length<2){for(var o=he(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof t?ve:t?me:ye)(n,t))},text:function(e){return arguments.length?this.each(null==e?xe:("function"==typeof e?we:be)(e)):this.node().textContent},html:function(e){return arguments.length?this.each(null==e?_e:("function"==typeof e?Se:Ee)(e)):this.node().innerHTML},raise:function(){return this.each(Ne)},lower:function(){return this.each(Me)},append:function(e){var t="function"==typeof e?e:B(e);return this.select((function(){return this.appendChild(t.apply(this,arguments))}))},insert:function(e,t){var n="function"==typeof e?e:B(e),o=null==t?ke:"function"==typeof t?t:R(t);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(Ce)},clone:function(e){return this.select(e?Ae:Pe)},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?Be:$e,o=0;o<a;++o)this.each(s(i[o],t,n));return this}var s=this.node().__on;if(s)for(var u,c=0,l=s.length;c<l;++c)for(o=0,u=s[c];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?je:Re)(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)}};const Ye={passive:!1},Le={capture:!0,passive:!1};function Ue(e){e.stopImmediatePropagation()}function qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Ve(e){var t=e.document.documentElement,n=Xe(e).on("dragstart.drag",qe,Le);"onselectstart"in t?n.on("selectstart.drag",qe,Le):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ze(e,t){var n=e.document.documentElement,o=Xe(e).on("dragstart.drag",null);t&&(o.on("click.drag",qe,Le),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 We=e=>()=>e;function Fe(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:u,dy:c,dispatch:l}){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:c,enumerable:!0,configurable:!0},_:{value:l}})}function Ke(e){return!e.ctrlKey&&!e.button}function He(){return this.parentNode}function Ge(e,t){return null==t?{x:e.x,y:e.y}:t}function Qe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Je(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function et(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function tt(){}Fe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};var nt=.7,ot=1/nt,rt="\\s*([+-]?\\d+)\\s*",it="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",at="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",st=/^#([0-9a-f]{3,8})$/,ut=new RegExp(`^rgb\\(${rt},${rt},${rt}\\)$`),ct=new RegExp(`^rgb\\(${at},${at},${at}\\)$`),lt=new RegExp(`^rgba\\(${rt},${rt},${rt},${it}\\)$`),dt=new RegExp(`^rgba\\(${at},${at},${at},${it}\\)$`),ht=new RegExp(`^hsl\\(${it},${at},${at}\\)$`),ft=new RegExp(`^hsla\\(${it},${at},${at},${it}\\)$`),gt={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 pt(){return this.rgb().formatHex()}function mt(){return this.rgb().formatRgb()}function yt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=st.exec(e))?(n=t[1].length,t=parseInt(t[1],16),6===n?vt(t):3===n?new wt(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===n?xt(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===n?xt(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=ut.exec(e))?new wt(t[1],t[2],t[3],1):(t=ct.exec(e))?new wt(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=lt.exec(e))?xt(t[1],t[2],t[3],t[4]):(t=dt.exec(e))?xt(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=ht.exec(e))?kt(t[1],t[2]/100,t[3]/100,1):(t=ft.exec(e))?kt(t[1],t[2]/100,t[3]/100,t[4]):gt.hasOwnProperty(e)?vt(gt[e]):"transparent"===e?new wt(NaN,NaN,NaN,0):null}function vt(e){return new wt(e>>16&255,e>>8&255,255&e,1)}function xt(e,t,n,o){return o<=0&&(e=t=n=NaN),new wt(e,t,n,o)}function bt(e,t,n,o){return 1===arguments.length?((r=e)instanceof tt||(r=yt(r)),r?new wt((r=r.rgb()).r,r.g,r.b,r.opacity):new wt):new wt(e,t,n,null==o?1:o);var r}function wt(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}function _t(){return`#${Mt(this.r)}${Mt(this.g)}${Mt(this.b)}`}function Et(){const e=St(this.opacity);return`${1===e?"rgb(":"rgba("}${Nt(this.r)}, ${Nt(this.g)}, ${Nt(this.b)}${1===e?")":`, ${e})`}`}function St(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Nt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Mt(e){return((e=Nt(e))<16?"0":"")+e.toString(16)}function kt(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Pt(e,t,n,o)}function Ct(e){if(e instanceof Pt)return new Pt(e.h,e.s,e.l,e.opacity);if(e instanceof tt||(e=yt(e)),!e)return new Pt;if(e instanceof Pt)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 Pt(a,s,u,e.opacity)}function Pt(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}function At(e){return(e=(e||0)%360)<0?e+360:e}function $t(e){return Math.max(0,Math.min(1,e||0))}function Bt(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}Je(tt,yt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:pt,formatHex:pt,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ct(this).formatHsl()},formatRgb:mt,toString:mt}),Je(wt,bt,et(tt,{brighter(e){return e=null==e?ot:Math.pow(ot,e),new wt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?nt:Math.pow(nt,e),new wt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new wt(Nt(this.r),Nt(this.g),Nt(this.b),St(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:_t,formatHex:_t,formatHex8:function(){return`#${Mt(this.r)}${Mt(this.g)}${Mt(this.b)}${Mt(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Et,toString:Et})),Je(Pt,(function(e,t,n,o){return 1===arguments.length?Ct(e):new Pt(e,t,n,null==o?1:o)}),et(tt,{brighter(e){return e=null==e?ot:Math.pow(ot,e),new Pt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?nt:Math.pow(nt,e),new Pt(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 wt(Bt(e>=240?e-240:e+120,r,o),Bt(e,r,o),Bt(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new Pt(At(this.h),$t(this.s),$t(this.l),St(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=St(this.opacity);return`${1===e?"hsl(":"hsla("}${At(this.h)}, ${100*$t(this.s)}%, ${100*$t(this.l)}%${1===e?")":`, ${e})`}`}}));var Tt=e=>()=>e;function Rt(e){return 1==(e=+e)?jt: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):Tt(isNaN(t)?n:t)}}function jt(e,t){var n=t-e;return n?function(e,t){return function(n){return e+n*t}}(e,n):Tt(isNaN(e)?t:e)}var It=function e(t){var n=Rt(t);function o(e,t){var o=n((e=bt(e)).r,(t=bt(t)).r),r=n(e.g,t.g),i=n(e.b,t.b),a=jt(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 zt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Dt=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Xt=new RegExp(Dt.source,"g");function Ot(e,t){var n,o,r,i=Dt.lastIndex=Xt.lastIndex=0,a=-1,s=[],u=[];for(e+="",t+="";(n=Dt.exec(e))&&(o=Xt.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:zt(n,o)})),i=Xt.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 Yt,Lt=180/Math.PI,Ut={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function qt(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)*Lt,skewX:Math.atan(u)*Lt,scaleX:a,scaleY:s}}function Vt(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:zt(e,r)},{i:u-2,x:zt(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:zt(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:zt(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:zt(e,n)},{i:s-2,x:zt(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 Zt=Vt((function(e){const t=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ut:qt(t.a,t.b,t.c,t.d,t.e,t.f)}),"px, ","px)","deg)"),Wt=Vt((function(e){return null==e?Ut:(Yt||(Yt=document.createElementNS("http://www.w3.org/2000/svg","g")),Yt.setAttribute("transform",e),(e=Yt.transform.baseVal.consolidate())?qt((e=e.matrix).a,e.b,e.c,e.d,e.e,e.f):Ut)}),", ",")",")");function Ft(e){return((e=Math.exp(e))+1/e)/2}var Kt,Ht,Gt=function e(t,n,o){function r(e,r){var i,a,s=e[0],u=e[1],c=e[2],l=r[0],d=r[1],h=r[2],f=l-s,g=d-u,p=f*f+g*g;if(p<1e-12)a=Math.log(h/c)/t,i=function(e){return[s+e*f,u+e*g,c*Math.exp(t*e*a)]};else{var m=Math.sqrt(p),y=(h*h-c*c+o*p)/(2*c*n*m),v=(h*h-c*c-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=Ft(x),l=c/(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+l*f,u+l*g,c*i/Ft(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),Qt=0,Jt=0,en=0,tn=1e3,nn=0,on=0,rn=0,an="object"==typeof performance&&performance.now?performance:Date,sn="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function un(){return on||(sn(cn),on=an.now()+rn)}function cn(){on=0}function ln(){this._call=this._time=this._next=null}function dn(e,t,n){var o=new ln;return o.restart(e,t,n),o}function hn(){on=(nn=an.now())+rn,Qt=Jt=0;try{!function(){un(),++Qt;for(var e,t=Kt;t;)(e=on-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Qt}()}finally{Qt=0,function(){var e,t,n=Kt,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:Kt=t);Ht=e,gn(o)}(),on=0}}function fn(){var e=an.now(),t=e-nn;t>tn&&(rn-=t,nn=e)}function gn(e){Qt||(Jt&&(Jt=clearTimeout(Jt)),e-on>24?(e<1/0&&(Jt=setTimeout(hn,e-an.now()-rn)),en&&(en=clearInterval(en))):(en||(nn=an.now(),en=setInterval(fn,tn)),Qt=1,sn(hn)))}function pn(e,t,n){var o=new ln;return t=null==t?0:+t,o.restart((n=>{o.stop(),e(n+t)}),t,n),o}ln.prototype=dn.prototype={constructor:ln,restart:function(e,t,n){if("function"!=typeof e)throw new TypeError("callback is not a function");n=(null==n?un():+n)+(null==t?0:+t),this._next||Ht===this||(Ht?Ht._next=this:Kt=this,Ht=this),this._call=e,this._time=n,gn()},stop:function(){this._call&&(this._call=null,this._time=1/0,gn())}};var mn=E("start","end","cancel","interrupt"),yn=[],vn=0,xn=1,bn=2,wn=3,_n=4,En=5,Sn=6;function Nn(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=xn,n.timer.restart(a,n.delay,n.time),n.delay<=e&&a(e-n.delay)}function a(i){var c,l,d,h;if(n.state!==xn)return u();for(c in r)if((h=r[c]).name===n.name){if(h.state===wn)return pn(a);h.state===_n?(h.state=Sn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+c<t&&(h.state=Sn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[c])}if(pn((function(){n.state===wn&&(n.state=_n,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=bn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===bn){for(n.state=wn,o=new Array(d=n.tween.length),c=0,l=-1;c<d;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(o[++l]=h);o.length=l+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(u),n.state=En,1),i=-1,a=o.length;++i<a;)o[i].call(e,r);n.state===En&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){for(var o in n.state=Sn,n.timer.stop(),delete r[t],r)return;delete e.__transition}r[t]=n,n.timer=dn(i,0,n.time)}(e,n,{name:t,index:o,group:r,on:mn,tween:yn,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vn})}function Mn(e,t){var n=Cn(e,t);if(n.state>vn)throw new Error("too late; already scheduled");return n}function kn(e,t){var n=Cn(e,t);if(n.state>wn)throw new Error("too late; already running");return n}function Cn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Pn(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>bn&&n.state<En,n.state=Sn,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 An(e,t){var n,o;return function(){var r=kn(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 $n(e,t,n){var o,r;if("function"!=typeof n)throw new Error;return function(){var i=kn(this,e),a=i.tween;if(a!==o){r=(o=a).slice();for(var s={name:t,value:n},u=0,c=r.length;u<c;++u)if(r[u].name===t){r[u]=s;break}u===c&&r.push(s)}i.tween=r}}function Bn(e,t,n){var o=e._id;return e.each((function(){var e=kn(this,o);(e.value||(e.value={}))[t]=n.apply(this,arguments)})),function(e){return Cn(e,o).value[t]}}function Tn(e,t){var n;return("number"==typeof t?zt:t instanceof yt?It:(n=yt(t))?(t=n,It):Ot)(e,t)}function Rn(e){return function(){this.removeAttribute(e)}}function jn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function In(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 zn(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 Dn(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 Xn(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 On(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 Yn(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 Ln(e,t){return function(){Mn(this,e).delay=+t.apply(this,arguments)}}function Un(e,t){return t=+t,function(){Mn(this,e).delay=t}}function qn(e,t){return function(){kn(this,e).duration=+t.apply(this,arguments)}}function Vn(e,t){return t=+t,function(){kn(this,e).duration=t}}var Zn=De.prototype.constructor;function Wn(e){return function(){this.style.removeProperty(e)}}var Fn=0;function Kn(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Hn(){return++Fn}var Gn=De.prototype;Kn.prototype={constructor:Kn,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=R(e));for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a)for(var s,u,c=o[a],l=c.length,d=i[a]=new Array(l),h=0;h<l;++h)(s=c[h])&&(u=e.call(s,s.__data__,h,c))&&("__data__"in s&&(u.__data__=s.__data__),d[h]=u,Nn(d[h],t,n,h,d,Cn(s,n)));return new Kn(i,this._parents,t,n)},selectAll:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=I(e));for(var o=this._groups,r=o.length,i=[],a=[],s=0;s<r;++s)for(var u,c=o[s],l=c.length,d=0;d<l;++d)if(u=c[d]){for(var h,f=e.call(u,u.__data__,d,c),g=Cn(u,n),p=0,m=f.length;p<m;++p)(h=f[p])&&Nn(h,t,n,p,f,g);i.push(f),a.push(u)}return new Kn(i,a,t,n)},selectChild:Gn.selectChild,selectChildren:Gn.selectChildren,filter:function(e){"function"!=typeof e&&(e=D(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]=[],c=0;c<s;++c)(i=a[c])&&e.call(i,i.__data__,c,a)&&u.push(i);return new Kn(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,c=t[s],l=n[s],d=c.length,h=a[s]=new Array(d),f=0;f<d;++f)(u=c[f]||l[f])&&(h[f]=u);for(;s<o;++s)a[s]=t[s];return new Kn(a,this._parents,this._name,this._id)},selection:function(){return new Zn(this._groups,this._parents)},transition:function(){for(var e=this._name,t=this._id,n=Hn(),o=this._groups,r=o.length,i=0;i<r;++i)for(var a,s=o[i],u=s.length,c=0;c<u;++c)if(a=s[c]){var l=Cn(a,t);Nn(a,e,n,c,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new Kn(o,this._parents,e,n)},call:Gn.call,nodes:Gn.nodes,node:Gn.node,size:Gn.size,empty:Gn.empty,each:Gn.each,on:function(e,t){var n=this._id;return arguments.length<2?Cn(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)?Mn:kn;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=P(e),o="transform"===n?Wt:Tn;return this.attrTween(e,"function"==typeof t?(n.local?Xn:Dn)(n,o,Bn(this,"attr."+e,t)):null==t?(n.local?jn:Rn)(n):(n.local?zn:In)(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=P(e);return this.tween(n,(o.local?On:Yn)(o,t))},style:function(e,t,n){var o="transform"==(e+="")?Zt:Tn;return null==t?this.styleTween(e,function(e,t){var n,o,r;return function(){var i=se(this,e),a=(this.style.removeProperty(e),se(this,e));return i===a?null:i===n&&a===o?r:r=t(n=i,o=a)}}(e,o)).on("end.style."+e,Wn(e)):"function"==typeof t?this.styleTween(e,function(e,t,n){var o,r,i;return function(){var a=se(this,e),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(e),u=s=se(this,e)),a===u?null:a===o&&u===r?i:(r=u,i=t(o=a,s))}}(e,o,Bn(this,"style."+e,t))).each(function(e,t){var n,o,r,i,a="style."+t,s="end."+a;return function(){var u=kn(this,e),c=u.on,l=null==u.value[a]?i||(i=Wn(t)):void 0;c===n&&r===l||(o=(n=c).copy()).on(s,r=l),u.on=o}}(this._id,e)):this.styleTween(e,function(e,t,n){var o,r,i=n+"";return function(){var a=se(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}}(Bn(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=Cn(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?An:$n)(n,e,t))},delay:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?Ln:Un)(t,e)):Cn(this.node(),t).delay},duration:function(e){var t=this._id;return arguments.length?this.each(("function"==typeof e?qn:Vn)(t,e)):Cn(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(){kn(this,e).ease=t}}(t,e)):Cn(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;kn(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=kn(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]:Gn[Symbol.iterator]};var Qn={time:null,delay:0,duration:250,ease:function(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}};function Jn(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}De.prototype.interrupt=function(e){return this.each((function(){Pn(this,e)}))},De.prototype.transition=function(e){var t,n;e instanceof Kn?(t=e._id,e=e._name):(t=Hn(),(n=Qn).time=un(),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,c=0;c<u;++c)(a=s[c])&&Nn(a,e,t,c,s,n||Jn(a,t));return new Kn(o,this._parents,e,t)};var eo=e=>()=>e;function to(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 no(e,t,n){this.k=e,this.x=t,this.y=n}no.prototype={constructor:no,scale:function(e){return 1===e?this:new no(this.k*e,this.x,this.y)},translate:function(e,t){return 0===e&0===t?this:new no(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 oo=new no(1,0,0);function ro(e){e.stopImmediatePropagation()}function io(e){e.preventDefault(),e.stopImmediatePropagation()}function ao(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function so(){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 uo(){return this.__zoom||oo}function co(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function lo(){return navigator.maxTouchPoints||"ontouchstart"in this}function ho(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))}function fo(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}no.prototype;const go=Symbol.for("internals"),po=e=>!isNaN(e)&&isFinite(e),mo=e=>({width:e.offsetWidth,height:e.offsetHeight}),yo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),vo=(e={x:0,y:0},t)=>({x:yo(e.x,t[0][0],t[1][0]),y:yo(e.y,t[0][1],t[1][1])}),xo=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),bo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),wo=e=>"clientX"in e,_o=(e,t)=>{const n=wo(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=(e,t,n,o)=>{const r=t-n;return e<n?yo(Math.abs(e-n),1,50)/50*o:e>r?-yo(Math.abs(e-r),1,50)/50*o:0},So=(e,t)=>[Eo(e.x,t.width,30,10),Eo(e.y,t.height,30,10)],No=e=>{const{x:t,y:n,k:o}=e;return{x:t,y:n,zoom:o}},Mo=(e,t)=>e.target.closest(`.${t}`),ko=(e,t)=>{const{x:n,y:o,zoom:r}=e,{x:i,y:a,k:s}=t;return n!==i||o!==a||r!==s},Co=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function Po({noPanClassName:e,panning:o,minZoom:r,maxZoom:i,defaultViewport:a,translateExtent:s,children:u,onMove:c,onMoveStart:l,onMoveEnd:d}){const h=w(),f=n.useRef(!1),g=n.useRef(null),p=n.useRef(),m=n.useRef({x:0,y:0,zoom:0}),y=n.useRef(),{d3Zoom:v,d3Selection:x}=b(Co,fo);return n.useEffect((()=>{if(g.current){const e=g.current.getBoundingClientRect(),t=function(){var e,t,n,o=ao,r=so,i=ho,a=co,s=lo,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],l=250,d=Gt,h=E("start","zoom","end"),f=500,g=150,p=0,m=10;function y(e){e.property("__zoom",uo).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",k).filter(s).on("touchstart.zoom",C).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",A).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 no(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 no(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,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),l=e.__zoom,h="function"==typeof t?t.apply(e,i):t,f=d(l.invert(u).concat(c/l.k),h.invert(u).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new no(n,u[0]-t[0]*n,u[1]-t[1]*n)}a.zoom(null,e)}}))}function _(e,t,n){return!n&&e.__zooming||new S(e,t)}function S(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function N(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)))),l=Oe(e);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[l,r.invert(l)],Pn(this),n.start()}io(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,c))}}function M(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,a=_(this,t,!0).event(e),s=Xe(e.view).on("mousemove.zoom",(function(e){if(io(e),!a.moved){var t=e.clientX-l,n=e.clientY-d;a.moved=t*t+n*n>p}a.event(e).zoom("mouse",i(x(a.that.__zoom,a.mouse[0]=Oe(e,r),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),Ze(e.view,a.moved),io(e),a.event(e).end()}),!0),u=Oe(e,r),l=e.clientX,d=e.clientY;Ve(e.view),ro(e),a.mouse=[u,this.__zoom.invert(u)],Pn(this),a.start()}}function k(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,a=Oe(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),c);io(e),l>0?Xe(this).transition().duration(l).call(w,d,a,e):Xe(this).call(y.transform,d,a,e)}}function C(n,...r){if(o.apply(this,arguments)){var i,a,s,u,c=n.touches,l=c.length,d=_(this,r,n.changedTouches.length===l).event(n);for(ro(n),a=0;a<l;++a)u=[u=Oe(s=c[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)),Pn(this),d.start())}}function P(e,...t){if(this.__zooming){var n,o,r,a,s=_(this,t).event(e),u=e.changedTouches,l=u.length;for(io(e),n=0;n<l;++n)r=Oe(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,c))}}function A(e,...o){if(this.__zooming){var r,i,a=_(this,o).event(e),s=e.changedTouches,u=s.length;for(ro(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=Oe(i,this),Math.hypot(t[0]-i[0],t[1]-i[1])<m)){var c=Xe(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return y.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",uo),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,c)}),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),c)}),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(oo.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,c)}),o,a)},S.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=Xe(this.that).datum();h.call(e,this.that,new to(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:eo(+e),y):a},y.filter=function(e){return arguments.length?(o="function"==typeof e?e:eo(!!e),y):o},y.touchable=function(e){return arguments.length?(s="function"==typeof e?e:eo(!!e),y):s},y.extent=function(e){return arguments.length?(r="function"==typeof e?e:eo([[+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?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],y):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},y.constrain=function(e){return arguments.length?(i=e,y):i},y.duration=function(e){return arguments.length?(l=+e,y):l},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([r,i]).translateExtent(s),n=Xe(g.current).call(t),o=oo.translate(a.x,a.y).scale(yo(a.zoom,r,i)),u=[[0,0],[e.width,e.height]],c=t.constrain()(o,u,s);t.transform(n,c),p.current=n.on("wheel.zoom"),h.setState({d3Zoom:t,d3Selection:n,transform:[c.x,c.y,c.k],domNode:g.current.closest(".react-diagram")})}}),[s]),n.useEffect((()=>{v&&x&&x.on("wheel.zoom",((e,t)=>{e.preventDefault(),g.current&&p.current&&p.current.call(g.current,e,t)}))}),[v,x,p,o]),n.useEffect((()=>{v&&v.on("start",(e=>{if(!e.sourceEvent)return null;if(f.current=!0,l){const t=No(e.transform);m.current=t,l?.(e.sourceEvent,t)}}))}),[v,l]),n.useEffect((()=>{v&&v.on("zoom",(e=>{if(h.setState({transform:[e.transform.x,e.transform.y,e.transform.k]}),c){const t=No(e.transform);c?.(e.sourceEvent,t)}}))}),[v,c]),n.useEffect((()=>{v&&v.on("end",(e=>{if(f.current=!1,d&&ko(m.current,e.transform)){const t=No(e.transform);m.current=t,clearTimeout(y.current),y.current=setTimeout((()=>{d?.(e.sourceEvent,t)}),0)}}))}),[v]),n.useEffect((()=>{v&&v.filter((t=>{if(Mo(t,e)&&"wheel"!==t.type)return!1;if(!o)return!1;return!(t.button&&!(t.button<=1))}))}),[v,o]),t.jsx("div",{className:"react-diagram__pane react-diagram__container",ref:g,children:u})}const Ao=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function $o({children:e}){const n=b(Ao);return t.jsx("div",{className:"react-diagram__viewport react-diagram__container",style:{transform:n},children:e})}function Bo({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 To(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=To(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const Ro=(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,...mo(e)}}))};function jo(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);n(o,{...r})}}function Io({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(),c=u.get(e);t.setState({selectionBoxActive:!1}),c.selected?(o||c.selected&&s)&&(a({nodes:[c]}),requestAnimationFrame((()=>r?.current?.blur()))):i([e])}const zo=e=>"source"in e&&"target"in e,Do=(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}},Xo=(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},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(a&&!o||r)return!1;const{positionAbsolute:l}=Do(e,s),d={x:l.x,y:l.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)&&c.push(e)})),c},Oo=(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("&")}`},Yo=({source:e,target:t})=>`react-diagram__edge-${e}-${t}`,Lo=(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}=Do(n,t).positionAbsolute,i=xo({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 bo(n)};function Uo(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return!!n&&(!!n.selected||Uo(n,t))}const qo=(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||!Uo(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,height:e.height}))),Vo=(e,t,n,o,r=[0,0],i)=>{let a=e.extent||o;if("parent"===e.extent)if(e.parentNode&&e.width&&e.height){const t=n.get(e.parentNode),{x:o,y:i}=Do(t,r).positionAbsolute;a=t&&po(o)&&po(i)&&po(t.width)&&po(t.height)?[[o+e.width*r[0],i+e.height*r[1]],[o+t.width-e.width+e.width*r[0],i+t.height-e.height+e.height*r[1]]]:a}else i?.("011"),a=o;else if(e.extent&&e.parentNode){const t=n.get(e.parentNode),{x:o,y:i}=Do(t,r).positionAbsolute;a=[[e.extent[0][0]+o,e.extent[0][1]+i],[e.extent[1][0]+o,e.extent[1][1]+i]]}let s={x:0,y:0};if(e.parentNode){const t=n.get(e.parentNode);s=Do(t,r).positionAbsolute}const u=a?vo(t,a):t;return{position:{x:u.x-s.x,y:u.y-s.y},positionAbsolute:u}},Zo=({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]},Wo=(e,t,n)=>{let o=e;do{if(o?.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1},Fo=(e,t)=>e.x!==t.x||e.y!==t.y,Ko=Object.prototype.hasOwnProperty,Ho=(e,t)=>{let n,o;if(e===t)return!0;if(e&&t&&e.constructor===t.constructor){if(n=e.constructor,n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&Ho(e[o],t[o]););return-1===o}if(!n||"object"==typeof e){for(n in o=0,e){if(Ko.call(e,n)&&++o&&!Ko.call(t,n))return!1;if(!(n in t)||!Ho(e[n],t[n]))return!1}return Object.keys(t).length===o}}return e!=e&&t!=t};const Go=e=>"distance"in e;function Qo({nodeRef:e,nodeId:t,isSelectable:o,noDragClassName:r}){const i=w(),a=n.useRef([]),s=n.useRef(null),u=n.useRef({x:0,y:0}),c=n.useRef({x:0,y:0}),l=n.useRef(null),d=n.useRef(!1),h=n.useRef(0),[f,g]=n.useState(!1),p=function(){const e=w(),t=n.useCallback((({sourceEvent:t})=>{const{transform:n,gridStep:o,centerStep:r}=e.getState(),i=t.changedTouches?t.changedTouches[0].clientX:t.clientX,a=t.changedTouches?t.changedTouches[0].clientY:t.clientY,s={x:(i-n[0])/n[2],y:(a-n[1])/n[2]};return{getStepPosition:(e={position:s})=>{const{position:t,nodeSize:n}=e;if(!o)return t;let i=o[0]*Math.round(t.x/o[0]),a=o[1]*Math.round(t.y/o[1]);if(r&&n){const e=(o[0]-n.width)/2,r=(o[1]-n.height)/2,s=t.x-e,u=t.y-r;i=o[0]*Math.round(s/o[0])+e,a=o[1]*Math.round(u/o[1])+r}return{x:i,y:a}},...s}}),[]);return t}(),m=function(){const e=w(),t=n.useRef([]),o=n.useCallback((e=>{let n;return n=e.length?t.current.filter((t=>!e.some((e=>t.id===e.id)))).map((e=>({...e,intersected:!1}))):t.current.map((e=>({...e,intersected:!1}))),n}),[]),r=n.useCallback((n=>{const{getNodes:r,triggerNodeChanges:i}=e.getState(),a=[],s=r().filter((e=>{const{width:t,height:o,position:r,parentNode:i}=e;if(!i)return t&&o?n.current?.some((n=>{const{position:i,width:s,height:u}=n;if(e.id===n.id)return;if(n.parentNode)return;if(!s||!u)return;const c=i.x+s>=r.x,l=r.x+t>=i.x,d=i.y+u>=r.y,h=r.y+o>=i.y,f=c&&l&&d&&h;return f&&(a.includes(n.id)||a.push(n.id)),f})):void 0})).map((e=>({id:e.id,type:"intersect",intersected:!0}))),u=a.map((e=>({id:e,type:"intersect",intersected:!0}))),c=[...s,...u];if(!Ho(c,t.current)){const e=o(c);t.current=c,i([...c,...e])}}),[]);return r}(),y=(e,t=!1)=>n=>{if(!Go(n))return;const{nodeInternals:o,nodeExtent:r,nodeOrigin:a,smoothStep:s,gridStep:u,onError:c}=i.getState(),{distance:l,width:d,height:h}=n,{x:f,y:g,getStepPosition:p}=e;let m={x:f-l.x,y:g-l.y};if(u&&p){const e=p({position:m,nodeSize:{width:d,height:h}});(!s||s&&t)&&(m=e)}const y=Vo(n,m,o,r,a,c);Fo(n.position,y.position)&&(n.position=y.position,n.positionAbsolute=y.positionAbsolute)};return n.useEffect((()=>{if(e?.current){const n=Xe(e.current),f=e=>{const{nodeInternals:n,onNodeDrag:o,updateNodesPosition:r}=i.getState(),{x:s,y:u}=e;if(c.current={x:s,y:u},r(a.current,!0,y(e)),g(!0),o&&l.current){const[e,r]=Zo({nodeId:t,dragItems:a.current,nodeInternals:n});o(l.current,e,r)}},v=()=>{if(!s.current)return;const[e,t]=So(u.current,s.current);if(0!==e||0!==t){const{transform:n,panBy:o}=i.getState();c.current.x-=e/n[2],c.current.y-=t/n[2],f(c.current),o({x:e,y:t})}h.current=requestAnimationFrame(v)},x=function(){var e,t,n,o,r=Ke,i=He,a=Ge,s=Qe,u={},c=E("start","drag","end"),l=0,d=0;function h(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,Ye).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&&(Xe(a.view).on("mousemove.drag",g,Le).on("mouseup.drag",p,Le),Ve(a.view),Ue(a),n=!1,e=a.clientX,t=a.clientY,u("start",a))}}function g(o){if(qe(o),!n){var r=o.clientX-e,i=o.clientY-t;n=r*r+i*i>d}u.mouse("drag",o)}function p(e){Xe(e.view).on("mousemove.drag mouseup.drag",null),Ze(e.view,n),qe(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]))&&(Ue(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])&&(qe(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])&&(Ue(e),n("end",e,r[t]))}function x(e,t,n,o,r,i){var s,d,f,g=c.copy(),p=Oe(i||n,t);if(null!=(f=a.call(e,new Fe("beforestart",{sourceEvent:n,target:h,identifier:r,active:l,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,c){var m,y=p;switch(i){case"start":u[r]=n,m=l++;break;case"end":delete u[r],--l;case"drag":p=Oe(c||a,t),m=l}g.call(i,e,new Fe(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:We(!!e),h):r},h.container=function(e){return arguments.length?(i="function"==typeof e?e:We(e),h):i},h.subject=function(e){return arguments.length?(a="function"==typeof e?e:We(e),h):a},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:We(!!e),h):s},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,h):Math.sqrt(d)},h}().on("start",(n=>{const{nodeInternals:r,nodesDraggable:c,domNode:l,onNodeDragStart:d}=i.getState();t&&Io({id:t,store:i,nodeRef:e,isSelectable:o});const h=p(n);if(a.current=qo(r,c,h,t),d&&a.current){const[e,o]=Zo({nodeId:t,dragItems:a.current,nodeInternals:r});d(n.sourceEvent,e,o)}s.current=l?.getBoundingClientRect()||null,u.current=_o(n.sourceEvent,s.current)})).on("drag",(e=>{const t=p(e),{autoPanOnNodeDrag:n}=i.getState();!d.current&&n&&(d.current=!0,v());Fo(c.current,t.getStepPosition())&&a.current&&(l.current=e.sourceEvent,u.current=_o(e.sourceEvent,s.current),f(t),m(a))})).on("end",(e=>{if(g(!1),d.current=!1,cancelAnimationFrame(h.current),a.current){const{nodeInternals:n,smoothStep:o,gridStep:r,updateNodesPosition:s,onNodeDragEnd:u}=i.getState();if(!!r&&o){const t=p(e);s(a.current,!1,y(t,!0)),m(a)}else s(a.current,!1);if(u){const[o,r]=Zo({nodeId:t,dragItems:a.current,nodeInternals:n});u(e.sourceEvent,o,r)}}})).filter((t=>{const n=t.target;return!(t.button||r&&Wo(n,`.${r}`,e))}));return n.call(x),()=>{n.on(".drag",null)}}}),[i,e,t,o,r,p]),f}var Jo=n.memo((function({rect:e,transform:o}){const r=n.useRef(null);Qo({nodeRef:r});const{width:i,height:a,x:s,y:u}=e;return t.jsx("div",{className:To(["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 er=(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}}},tr=(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&&er(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&&er(t,r);break;case"intersect":r.intersected=e.intersected;break;case"remove":return t}return t.push(r),t}),n)};const nr=(e,t)=>({id:e,type:"select",selected:t});function or(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(nr(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(nr(n.id,!1))),e}),[])}const rr=e=>{const{elementsSelectable:t,transform:n,selectionBoxActive:o,getNodes:r}=e,i=r().filter((e=>e.selected));return{elementsSelectable:t,selectionBoxRect:Lo(i,e.nodeOrigin),transformString:`translate(${n[0]}px,${n[1]}px) scale(${n[2]})`,selectionBoxActive:o}};function ir({children:e,dragSelectionKeyPressed:o}){const r=w(),i=n.useRef(null),a=n.useRef(0),s=n.useRef(),{elementsSelectable:u,selectionBoxRect:c,transformString:l,selectionBoxActive:d}=b(rr,fo),[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=()=>{f({x:0,y:0}),p({width:0,height:0,x:0,y:0}),y(!1)},x=u&&o;return t.jsxs("div",{ref:i,className:"react-diagram__container react-diagram__drag-selection",onClick:e=>{e.target===i.current&&(r.getState().resetSelectedElements(),r.setState({selectionBoxActive:!1}),y(!1))},onMouseDown:x?e=>{const{resetSelectedElements:t,domNode:n}=r.getState();if(s.current=n?.getBoundingClientRect(),!u||0!==e.button||e.target!==i.current||!s.current||!o)return;const{x:a,y:c}=_o(e,s.current);t(),p({width:0,height:0,x:a,y:c}),f({x:a,y:c})}:void 0,onMouseMove:x?e=>{const{nodeInternals:t,transform:n,nodeOrigin:i,getNodes:u,onNodesChange:c}=r.getState();if(!(h.x>0&&h.y>0)||!s.current||!o)return;r.setState({selectionBoxActive:!1}),y(!0);const l=_o(e,s.current),d=h.x??0,f=h.y??0,g={x:l.x<d?l.x:d,y:l.y<f?l.y:f,width:Math.abs(l.x-d),height:Math.abs(l.y-f)},m=u(),v=Xo(t,g,n,!1,!0,i).map((e=>e.id));if(a.current!==v.length){a.current=v.length;const e=or(m,v);e.length&&c?.(e)}p(g)}:void 0,onMouseUp:u&&g?e=>{0===e.button&&(r.setState({selectionBoxActive:a.current>0}),v())}:void 0,onMouseLeave:x?()=>{r.setState({selectionBoxActive:a.current>0}),v()}:void 0,children:[e,m&&t.jsx(Bo,{rect:g}),d&&t.jsx(Jo,{rect:c,transform:l})]})}const ar=e=>{const{minZoom:t,maxZoom:n,translateExtent:o}=e;return{minZoom:t,maxZoom:n,translateExtent:o}};function sr({children:e,multiSelectionKeyCode:o,dragSelectionKeyCode:r,noPanClassName:i,panning:a,defaultViewport:s,onMove:u,onMoveStart:c,onMoveEnd:l}){const{minZoom:d,maxZoom:h,translateExtent:f}=b(ar),[g,p]=n.useState(!1);!function(e="Meta"){const t=w(),[o,r]=n.useState(!1),i=t=>{t.key===e&&r(!0)},a=()=>{r(!1)};n.useEffect((()=>(document.addEventListener("keydown",i),document.addEventListener("keyup",a),()=>{document.removeEventListener("keydown",i),document.removeEventListener("keyup",a)})),[]),n.useEffect((()=>{t.setState({multiSelectionActive:o})}),[o])}(o);const m=e=>{e.key===r&&p(!0)},y=()=>{p(!1)};return n.useEffect((()=>(document.addEventListener("keydown",m),document.addEventListener("keyup",y),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",y)})),[]),t.jsx(Po,{noPanClassName:i,panning:a&&!g,minZoom:d,maxZoom:h,translateExtent:f,defaultViewport:s,onMove:u,onMoveStart:c,onMoveEnd:l,children:t.jsx(ir,{dragSelectionKeyPressed:g,children:t.jsx($o,{children:e})})})}sr.displayName="DiagramRenderer";var ur,cr=n.memo(sr);e.Position=void 0,(ur=e.Position||(e.Position={})).Left="left",ur.Top="top",ur.Right="right",ur.Bottom="bottom",e.MarkerType=void 0,(e.MarkerType||(e.MarkerType={})).Arrow="arrow";const lr=e=>({nodesDraggable:e.nodesDraggable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError});function dr({nodeTypes:o,onNodeClick:r,onNodeMouseEnter:i,onNodeMouseMove:a,onNodeMouseLeave:s,onNodeContextMenu:u,onNodeDoubleClick:c,...l}){const{nodesDraggable:d,elementsSelectable:h,updateNodeDimensions:f,onError:g}=b(lr,fo),p=b(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:_,positionAbsolute:E,hidden:S,selected:N,selectable:M,draggable:k,intersected:C}=n;let P=p||"default";o[P]||(g?.("010",P),P="default");const A=o[P]||o.default,$=!!(k||d&&void 0===k),B=!!(M||h&&void 0===M),T={id:m,className:v,style:x,width:b,height:w,ariaLabel:_},R={onClick:r,onMouseEnter:i,onMouseMove:a,onMouseLeave:s,onContextMenu:u,onDoubleClick:c},j={positionX:E?.x||0,positionY:E?.y||0,sourcePosition:e.Position.Bottom,targetPosition:e.Position.Top},I={selected:!!N,intersected:!!C,isSelectable:B,isDraggable:$,hidden:S,isParent:!!n[go]?.isParent,initialized:!!n.width&&!!n.height};return t.jsx(A,{...l,...T,...j,...R,...I,zIndex:n[go]?.z??0,type:P,data:f,resizeObserver:y},m)}))})}dr.displayName="NodeRenderer";var hr=n.memo(dr);const fr={[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 gr=({id:e,type:o,color:r,width:i=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const l=function(e){const t=w();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(fr,e)?fr[e]:(t.getState().onError?.("022",e),null)),[e])}(o);return l?t.jsx("marker",{className:"react-diagram__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:t.jsx(l,{color:r,strokeWidth:u})}):null},pr=({defaultColor:e,rfId:o})=>{const r=b(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=Oo(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(gr,{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)))})};pr.displayName="MarkerComponent";var mr=n.memo(pr);var yr=n.memo((function({x:e,y:o,label:r,labelStyle:i={},labelShowBg:a=!0,labelBgStyle:s={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:l,className:d,...h}){const f=n.useRef(null),[g,p]=n.useState({x:0,y:0,width:0,height:0}),m=To(["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:c,ry:c}),t.jsx("text",{className:"react-diagram__edge-text",y:g.height/2,dy:"0.3em",ref:f,style:i,children:r}),l]}):null}));function vr({path:e,labelX:n,labelY:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c,style:l,markerEnd:d,markerStart:h}){return t.jsxs(t.Fragment,{children:[t.jsx("path",{style:l,d:e,fill:"none",className:"react-diagram__edge-path",markerEnd:d,markerStart:h}),r&&po(n)&&po(o)?t.jsx(yr,{x:n,y:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c}):null]})}vr.displayName="BaseEdge";const xr=({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]},br=n.memo((({sourceX:e,sourceY:n,targetX:o,targetY:r,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:d,markerEnd:h,markerStart:f})=>{const[g,p,m]=(({sourceX:e,sourceY:t,targetX:n,targetY:o})=>{const[r,i,a,s]=xr({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,a,s]})({sourceX:e,sourceY:n,targetX:o,targetY:r});return t.jsx(vr,{path:g,labelX:p,labelY:m,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:d,markerEnd:h,markerStart:f})}));br.displayName="StraightEdge";const wr={[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}},_r=({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},Er=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Sr({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,borderRadius:s=5,centerX:u,centerY:c,offset:l=20}){const[d,h,f,g,p]=function({source:t,sourcePosition:n=e.Position.Bottom,target:o,targetPosition:r=e.Position.Top,center:i,offset:a}){const s=wr[n],u=wr[r],c={x:t.x+s.x*a,y:t.y+s.y*a},l={x:o.x+u.x*a,y:o.y+u.y*a},d=_r({source:c,sourcePosition:n,target:l}),h=0!==d.x?"x":"y",f=d[h];let g=[],p=0,m=0;const[y,v,x,b]=xr({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(s[h]*u[h]==-1){p=i.x||y,m=i.y||v;const e=[{x:p,y:c.y},{x:p,y:l.y}],t=[{x:c.x,y:m},{x:l.x,y:m}];g=s[h]!==f?"x"===h?t:e:"x"===h?e:t}return[[t,c,...g,l,o],p,m,x,b]}({source:{x:t,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:u,y:c},offset:l});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(Er(e,t)/2,Er(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}`}(d[n-1],t,d[n+1],s):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),h,f,g,p]}const Nr=n.memo((({sourceX:n,sourceY:o,targetX:r,targetY:i,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:h,sourcePosition:f=e.Position.Bottom,targetPosition:g=e.Position.Top,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Sr({sourceX:n,sourceY:o,sourcePosition:f,targetX:r,targetY:i,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset});return t.jsx(vr,{path:v,labelX:x,labelY:b,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:m})}));Nr.displayName="StepEdge";const Mr=(e,t)=>e>=0?.5*e:25*t*Math.sqrt(-e),kr=({pos:t,x1:n,y1:o,x2:r,y2:i,c:a})=>{switch(t){case e.Position.Left:return[n-Mr(n-r,a),o];case e.Position.Right:return[n+Mr(r-n,a),o];case e.Position.Top:return[n,o-Mr(o-i,a)];case e.Position.Bottom:return[n,o+Mr(i-o,a)]}},Cr=({sourceX:t,sourceY:n,sourcePosition:o=e.Position.Bottom,targetX:r,targetY:i,targetPosition:a=e.Position.Top,curvature:s=.25})=>{const[u,c]=kr({pos:o,x1:t,y1:n,x2:r,y2:i,c:s}),[l,d]=kr({pos:a,x1:r,y1:i,x2:t,y2:n,c:s}),[h,f,g,p]=(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s})=>{const u=.125,c=.375,l=e*u+r*c+a*c+n*u,d=t*u+i*c+s*c+o*u;return[l,d,Math.abs(l-e),Math.abs(d-t)]})({sourceX:t,sourceY:n,targetX:r,targetY:i,sourceControlX:u,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${t},${n} C${u},${c} ${l},${d} ${r},${i}`,h,f,g,p]},Pr=n.memo((({sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:a=e.Position.Bottom,targetPosition:s=e.Position.Top,label:u,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Cr({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:s,curvature:y?.curvature});return t.jsx(vr,{path:v,labelX:x,labelY:b,label:u,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m})}));Pr.displayName="BezierEdge";const Ar=e=>e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null,$r=(e,t,n,o)=>(t[n]||[]).reduce(((t,r)=>(`${e.id}-${n}`!==o&&t.push({type: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)),[]),Br=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),Tr=({isAnchor:e=!1,event:t,nodeId:n,portType:o,getState:r,setState:i,onConnect:a,onEdgeUpdateEnd:s})=>{const u=(c=t.target,c.getRootNode?.()||window?.document);var c;const{domNode:l,autoPanOnConnect:d,connectionRadius:h,getNodes:f,cancelConnection:g,onConnectStart:p,onConnectEnd:m,panBy:y}=r(),v=l?.getBoundingClientRect(),{x:x,y:b}=_o(t),w=u?.elementFromPoint(x,b),_=e?o:Ar(w),E=(({nodes:e,nodeId:t,portType:n})=>e.reduce(((e,o)=>{if(o[go]){const{portBounds:r}=o[go];let i=[],a=[];r&&(i=$r(o,r,"source",`${t}-${n}`),a=$r(o,r,"target",`${t}-${n}`)),e.push(...i,...a)}return e}),[]))({nodes:f(),nodeId:n,portType:o});let S=_o(t,v),N=null,M=!1,k=null,C=0,P=!1;if(!v||!o)return;const A=()=>{if(!d)return;const[e,t]=So(S,v);y({x:e,y:t}),C=requestAnimationFrame(A)};i({connectionPosition:S,connectionNodeId:n,connectionPortType:_}),p?.(t,{nodeId:n,portType:o});const $=e=>{const{transform:t}=r();S=_o(e,v),N=((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})((({x:e,y:t},[n,o,r])=>({x:(e-n)/r,y:(t-o)/r}))(S,t),h,E),P||(A(),P=!0);const a=((e,t,n,o,r)=>{const i="target"===o,a={isValid:!1,connection:{source:null,target:null}},s=r.querySelector(`.react-diagram__port[data-id="${t?.nodeId}-${t?.type}"]`),{x:u,y:c}=_o(e),l=r.elementFromPoint(u,c),d=l?.classList.contains("react-diagram__port")?l:s;if(d){const e=Ar(d),t=d.getAttribute("data-nodeid"),o={source:i?t:n,target:i?n:t};a.connection=o,(i&&"source"===e||!i&&"target"===e)&&(a.isValid=!0)}return a})(e,N,n,o,u);M=a.isValid,k=a.connection,i({connectionPosition:N&&M?Br(N,t):S})},B=e=>{M&&k&&a?.(k),m?.(e),o&&s?.(e),g(),cancelAnimationFrame(C),M=!1,k=null,P=!1,u.removeEventListener("mousemove",$),u.removeEventListener("mouseup",B),u.removeEventListener("touchmove",$),u.removeEventListener("touchend",B)};u.addEventListener("mousemove",$),u.addEventListener("mouseup",B),u.addEventListener("touchmove",$),u.addEventListener("touchend",B)},Rr=(t,n,o)=>o===e.Position.Left?t-n:o===e.Position.Right?t+n:t,jr=(t,n,o)=>o===e.Position.Top?t-n:o===e.Position.Bottom?t+n:t,Ir="react-diagram__edge-updater";function zr({position:e,centerX:n,centerY:o,radius:r=10,onMouseDown:i,type:a}){return t.jsx("circle",{className:To([Ir,`${Ir}-${a}`]),cx:Rr(n,r,e),cy:jr(o,r,e),r:r,stroke:"transparent",fill:"transparent",onMouseDown:i})}function Dr(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}const Xr=e=>{const o=o=>{const{id:r,className:i,style:a,type:s,data:u,rfId:c,ariaLabel:l,source:d,sourcePort:h,target:f,targetPort:g,markerEnd:p,markerStart:m,label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:_,labelBgBorderRadius:E,edgeUpdaterRadius:S,sourceX:N,sourceY:M,targetX:k,targetY:C,sourcePosition:P,targetPosition:A,selected:$,elementsSelectable:B,hidden:T,isFocusable:R,onClick:j,onDoubleClick:I,onContextMenu:z,onMouseEnter:D,onMouseMove:X,onMouseLeave:O,onEdgeUpdate:Y,onEdgeUpdateStart:L,onEdgeUpdateEnd:U}=o,q={sourceX:N,sourceY:M,targetX:k,targetY:C,sourcePosition:P,targetPosition:A},V={source:d,sourcePort:h,target:f,targetPort:g};if("react-diagram__connection"===i)return document.querySelector("path")?.classList.add("react-diagram__connection-path"),t.jsx(e,{...V,...q,id:r,data:u,style:a,selected:$});const Z=w(),W=n.useRef(null),[F,K]=n.useState(!1),H=n.useMemo((()=>`url(#${Oo(m,c)})`),[m,c]),G=n.useMemo((()=>`url(#${Oo(p,c)})`),[p,c]);if(T)return null;const Q=e=>t=>{if(0!==t.button)return;const{edges:n}=Z.getState(),i=o[e],a=n.find((e=>e.id===r));K(!0),L?.(t,a,e);Tr({isAnchor:!0,event:t,nodeId:i,portType:e,getState:Z.getState,setState:Z.setState,onConnect:e=>Y?.(a,e),onEdgeUpdateEnd:t=>{K(!1),U?.(t,a,e)}})},J=Dr(r,Z.getState,I),ee=Dr(r,Z.getState,z),te=Dr(r,Z.getState,D),ne=Dr(r,Z.getState,X),oe=Dr(r,Z.getState,O),re=To(["react-diagram__edge",`react-diagram__edge-${s}`,i,{selected:$,inactive:!B}]),ie={markerStart:H,markerEnd:G},ae={label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:_,labelBgBorderRadius:E},se={onClick:e=>{const{edges:t}=Z.getState();if(j){const n=t.find((e=>e.id===r));j(e,n)}},onDoubleClick:J,onContextMenu:ee,onMouseEnter:te,onMouseMove:ne,onMouseLeave:oe};return t.jsx("g",{...se,ref:W,className:re,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-label":null===l?void 0:l||`Edge from ${d} to ${f}`,"aria-describedby":R?`react-diagram__edge-desc-${c}`:void 0,children:!F&&t.jsxs(t.Fragment,{children:[t.jsx(e,{...V,...ie,...ae,...q,id:r,data:u,style:a,selected:$}),t.jsx(zr,{position:P,centerX:N,centerY:M,radius:S,onMouseDown:Q("target"),type:"source"}),t.jsx(zr,{position:A,centerX:k,centerY:C,radius:S,onMouseDown:Q("source"),type:"target"})]})})};return o.displayName="EdgeWrapper",n.memo(o)},Or=e=>{const t={default:Xr(e.straight||br),step:Xr(e.step||Nr),bezier:Xr(e.bezier||Pr)},n=Object.keys(e).filter((e=>!Object.keys(t).includes(e))).reduce(((t,n)=>(t[n]=Xr(e[n]||Nr),t)),{});return{...t,...n}};function Yr(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 Lr(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function Ur(e){const t=e?.[go]?.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 qr=e=>({edges:e.edges,width:e.width,height:e.height,nodeInternals:e.nodeInternals,onError:e.onError});function Vr({rfId:n,edgeTypes:o,noPanClassName:r,edgeUpdaterRadius:i,onEdgeClick:a,onEdgeDoubleClick:s,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g}){const{edges:p,width:m,height:y,nodeInternals:v}=b(qr,fo);return t.jsxs("svg",{width:m||"100vw",height:y||"100vh",className:"react-diagram__edges react-diagram__container",children:[t.jsx(mr,{defaultColor:"#000000",rfId:n}),t.jsx("g",{children:p.map((p=>{const{data:m,type:y,id:x,className:b,style:w,ariaLabel:_,source:E,sourcePort:S,target:N,targetPort:M,markerEnd:k,markerStart:C,label:P,labelStyle:A,labelShowBg:$,labelBgStyle:B,labelBgPadding:T,labelBgBorderRadius:R}=p,[j,I,z]=Ur(v.get(E)),[D,X,O]=Ur(v.get(N));if(!z||!O)return null;const Y=y||"straight",L=o[Y]||o.default,U=X.target,q=Lr(I.source,S),V=Lr(U,M),Z=q?.position||e.Position.Bottom,W=V?.position||e.Position.Top,F=!!p.focusable;if(!q||!V)return null;const K={id:x,className:To([b,r]),style:w,ariaLabel:_},H={source:E,sourcePort:S,target:N,targetPort:M},G={markerEnd:k,markerStart:C},Q={label:P,labelStyle:A,labelShowBg:$,labelBgStyle:B,labelBgPadding:T,labelBgBorderRadius:R},J=((e,t,n,o,r,i)=>{const a=Yr(n,e,t),s=Yr(i,o,r);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}})(j,q,Z,D,V,W),ee={...J,sourcePosition:Z,targetPosition:W},te={onClick:a,onDoubleClick:s,onContextMenu:u,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g};return t.jsx(L,{...K,...H,...G,...Q,...ee,...te,rfId:n,type:Y,data:m,isFocusable:F,edgeUpdaterRadius:i},x)}))})]})}Vr.displayName="EdgeRenderer";var Zr=n.memo(Vr);const Wr={[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 Fr({nodeId:e,portType:o,edge:r,Component:i,EdgeWrapper:a}){const{fromNode:s,toX:u,toY:c}=b(n.useCallback((t=>({fromNode:t.nodeInternals.get(e),toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2]})),[e]),fo),l=s?.[go]?.portBounds,d=l?.[o];if(!s||!d)return null;const h=d[0],f=h?h.x+h.width/2:(s.width??0)/2,g=h?h.y+h.height/2:s.height??0,p=(s.positionAbsolute?.x??0)+f,m=(s.positionAbsolute?.y??0)+g,y=h?.position,v=y?Wr[y]:null;if(!y||!v)return null;if(i)return t.jsx(i,{fromNode:s,fromPort:h,fromX:p,fromY:m,toX:u,toY:c,fromPosition:y,toPosition:v});if(!r){const e=`M${p},${m} ${u},${c}`;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,isFocusable:!1,sourceX:p,sourceY:m,targetX:u,targetY:c,sourcePosition:y,targetPosition:v})}Fr.displayName="ConnectionPath";const Kr=e=>({edges:e.edges,nodeId:e.connectionNodeId,portType:e.connectionPortType});function Hr({containerStyle:e,edgeTypes:n,component:o}){const{nodeId:r,portType:i,edges:a}=b(Kr,fo);if(!!(!r||!i))return null;const s=a.find((e=>e[i]===r)),u=s?.type?n[s.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(Fr,{nodeId:r,portType:i,edge:s,Component:o,EdgeWrapper:u})})})}function Gr({rfId:e,noPanClassName:n,panning:o,defaultViewport:r,multiSelectionKeyCode:i,dragSelectionKeyCode:a,onMove:s,onMoveStart:u,onMoveEnd:c,onlyRenderVisibleElements:l,disableKeyboardA11y:d,noDragClassName:h,nodeOrigin:f,nodeTypes:g,onNodeClick:p,onNodeDoubleClick:m,onNodeContextMenu:y,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:b,edgeTypes:w,edgeUpdaterRadius:_,onEdgeClick:E,onEdgeDoubleClick:S,onEdgeContextMenu:N,onEdgeMouseEnter:M,onEdgeMouseMove:k,onEdgeMouseLeave:C,onEdgeUpdate:P,onEdgeUpdateStart:A,onEdgeUpdateEnd:$,ConnectionLineContainerStyle:B,ConnectionLineComponent:T}){return t.jsxs(cr,{multiSelectionKeyCode:i,dragSelectionKeyCode:a,noPanClassName:n,panning:o,defaultViewport:r,onMove:s,onMoveStart:u,onMoveEnd:c,children:[t.jsx(hr,{rfId:e,nodeTypes:g,onlyRenderVisibleElements:l,disableKeyboardA11y:d,nodeOrigin:f,noDragClassName:h,noPanClassName:n,onNodeClick:p,onNodeDoubleClick:m,onNodeContextMenu:y,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:b}),t.jsx(Zr,{rfId:e,edgeTypes:w,noPanClassName:n,edgeUpdaterRadius:_,onEdgeClick:E,onEdgeDoubleClick:S,onEdgeContextMenu:N,onEdgeMouseEnter:M,onEdgeMouseMove:k,onEdgeMouseLeave:C,onEdgeUpdate:P,onEdgeUpdateStart:A,onEdgeUpdateEnd:$}),t.jsx(Hr,{edgeTypes:w,containerStyle:B,component:T})]})}Gr.displayName="DiagramView";var Qr=n.memo(Gr);const Jr=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 ei(e,t){n.useEffect((()=>{void 0!==e&&t(e)}),[e])}function ti(e,t,o){n.useEffect((()=>{void 0!==t&&o({[e]:t})}),[t])}const ni=({nodes:e,onNodesChange:t,onNodeDrag:n,onNodeDragStart:o,onNodeDragEnd:r,edges:i,onEdgesChange:a,smoothStep:s,centerStep:u,gridStep:c,elevateNodesOnSelect:l,nodesDraggable:d,autoPanOnNodeDrag:h,autoPanOnConnect:f,connectionRadius:g,onConnect:p,onConnectStart:m,onConnectEnd:y,onError:x,nodeExtent:_,translateExtent:E,minZoom:S,maxZoom:N})=>{const{setNodes:M,setEdges:k,setNodeExtent:C,setTranslateExtent:P,setMinZoom:A,setMaxZoom:$}=b(Jr,fo),B=w();return ei(e,M),ei(i,k),ei(_,C),ei(E,P),ei(S,A),ei(N,$),ti("smoothStep",s,B.setState),ti("centerStep",u,B.setState),ti("gridStep",c,B.setState),ti("elevateNodesOnSelect",l,B.setState),ti("nodesDraggable",d,B.setState),ti("autoPanOnNodeDrag",h,B.setState),ti("autoPanOnConnect",f,B.setState),ti("connectionRadius",g,B.setState),ti("onNodesChange",t,B.setState),ti("onNodeDrag",n,B.setState),ti("onNodeDragStart",o,B.setState),ti("onNodeDragEnd",r,B.setState),ti("onEdgesChange",a,B.setState),ti("onConnect",p,B.setState),ti("onConnectStart",m,B.setState),ti("onConnectEnd",y,B.setState),ti("onError",(e=>(t,n="")=>e?.(t,v[t](n)))(x),B.setState),null};function oi(e,t){n.useRef(null);return n.useMemo((()=>t(e)),[e])}const ri=n.createContext(null),ii=ri.Provider;ri.Consumer;function ai({type:e,position:o}){const r=w(),i=n.useContext(ri);if(!i)return null;const a=e=>{const{defaultEdgeOptions:t,onConnect:n}=r.getState(),o={...t,...e};n?.(o)},s=t=>{const n=wo(t);(n&&0===t.button||!n)&&Tr({event:t,nodeId:i,portType:e,getState:r.getState,setState:r.setState,onConnect:a})};return t.jsx("div",{"data-nodeid":i,"data-id":`${i}-${e}`,"data-port-position":o,className:`react-diagram__port react-diagram__port-${o} ${e} nodrag`,onMouseDown:s,onTouchStart:s})}ai.displayName="Port";var si=n.memo(ai);function ui({data:n}){return t.jsxs(t.Fragment,{children:[t.jsx(si,{type:"target",position:e.Position.Top}),n.label,t.jsx(si,{type:"source",position:e.Position.Bottom})]})}const ci=e=>{function o({id:o,type:r,data:i,positionX:a,positionY:s,sourcePosition:u,targetPosition:c,onClick:l,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,onContextMenu:g,onDoubleClick:p,style:m,width:y,height:v,className:x,selected:b,isSelectable:_,isDraggable:E,intersected:S,hidden:N,resizeObserver:M,dragHandle:k,zIndex:C,isParent:P,initialized:A,disableKeyboardA11y:$,ariaLabel:B,rfId:T,noDragClassName:R,noPanClassName:j}){const I=w(),z=n.useRef(null),D=n.useRef(u),X=n.useRef(c),O=n.useRef(r),Y=E||l||d||h||f;n.useEffect((()=>{if(z.current&&!N){const e=z.current;return M?.observe(e),()=>M?.unobserve(e)}}),[N]),n.useEffect((()=>{const e=O.current!==r,t=D.current!==u,n=X.current!==c;z.current&&(e||t||n)&&(e&&(O.current=r),t&&(D.current=u),n&&(X.current=c),I.getState().updateNodeDimensions([{id:o,nodeElement:z.current,forceUpdate:!0}]))}),[o,r,u,c]);const L=Qo({nodeRef:z,nodeId:o,isSelectable:_,noDragClassName:R});if(N)return null;const U=To(["react-diagram__node",`react-diagram__node-${r}`,{[j]:E},x,{selected:b,intersected:S,parent:P,dragging:L}]),q={zIndex:C,transform:`translate(${a}px,${s}px)`,pointerEvents:Y?"all":"none",visibility:A?"visible":"hidden",width:y,height:v,...m},V={onClick:e=>{if(E||Io({id:o,store:I,nodeRef:z}),l){const t=I.getState().nodeInternals.get(o);l(e,{...t})}},onDoubleClick:jo(o,I.getState,p),onContextMenu:jo(o,I.getState,g),onMouseEnter:jo(o,I.getState,d),onMouseMove:jo(o,I.getState,h),onMouseLeave:jo(o,I.getState,f)},Z={positionX:a,positionY:s,sourcePosition:u,targetPosition:c};return t.jsx("div",{...V,ref:z,className:U,style:q,"data-id":o,tabIndex:0,role:"button","aria-describedby":$?void 0:`react-diagram__node-desc-${T}`,"aria-label":B,children:t.jsx(ii,{value:o,children:t.jsx(e,{...Z,id:o,zIndex:C,type:r,data:i,dragHandle:k,selected:b,intersected:S})})})}return o.displayName="NodeWrapper",n.memo(o)},li=e=>{const t={default:ci(e.default||ui)},n=Object.keys(e).filter((e=>!Object.keys(t).includes(e))).reduce(((t,n)=>(t[n]=ci(e[n]||ui),t)),{});return{...t,...n}};function di(e,t,n,o){if(!e.parentNode)return n;const r=t.get(e.parentNode),i=Do(r,o);return di(r,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r[go]?.z??0)>(n.z??0)?r[go]?.z??0:n.z??0},o)}function hi(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}=di(o,e,{...o.position,z:o[go]?.z??0},t);o.positionAbsolute={x:r,y:i},o[go].z=a,n?.[o.id]&&(o[go].isParent=!0)}}))}function fi(e,t,n,o){const r=new Map,i={},a=o?1e3:0;return e.forEach((e=>{const n=(po(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,go,{enumerable:!1,value:{portBounds:o?.[go]?.portBounds,z:n}}),r.set(e.id,s)})),hi(r,n,i),r}const gi=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],pi={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},connectionNodeId:null,connectionPortType:"source",autoPanOnNodeDrag:!0,autoPanOnConnect:!0,nodeExtent:gi,translateExtent:gi,connectionRadius:20,onError:(e,t="")=>{}},mi=()=>{return e=(e,t)=>({...pi,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:i}=t();e({nodeInternals:fi(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{onNodesChange:o,nodeInternals:r,domNode:i,nodeOrigin:a}=t(),s=i?.querySelector(".react-diagram__viewport");if(!s)return;const u=window.getComputedStyle(s),{m22:c}=new window.DOMMatrixReadOnly(u.transform),l=n.reduce(((e,t)=>{const n=r.get(t.id);if(n){const o=mo(t.nodeElement);o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)&&(r.set(n.id,{...n,[go]:{...n[go],portBounds:{source:Ro(".source",t.nodeElement,c,a),target:Ro(".target",t.nodeElement,c,a)}},...o}),e.push({id:n.id,type:"dimensions",dimensions:o}))}return e}),[]);hi(r,a),e({nodeInternals:new Map(r)}),l?.length>0&&o?.(l)},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)},addSelectedNodes:e=>{const{multiSelectionActive:n,getNodes:o,triggerNodeChanges:r}=t();let i;i=n?e.map((e=>nr(e,!0))):or(o(),e),r(i)},unselectNodes:({nodes:e}={})=>{const{getNodes:n,triggerNodeChanges:o}=t();o((e||n()).map((e=>(e.selected=!1,nr(e.id,!1)))))},resetSelectedElements:()=>{const{getNodes:e,triggerNodeChanges:n}=t();n(e().filter((e=>e.selected)).map((e=>nr(e.id,!1))))},cancelConnection:()=>e({connectionNodeId:pi.connectionNodeId,connectionPortType:pi.connectionPortType}),panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:i,d3Selection:a}=t();if(!i||!a||!e.x&&!e.y)return;const s=oo.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),u=[[0,0],[o,r]],c=i?.constrain()(s,u,gi);i.transform(a,c)},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=vo(e.position,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?o(e):o;var e},yi=({children:e})=>{const o=n.useRef(null);return o.current||(o.current=mi()),t.jsx(y,{value:o.current,children:e})};function vi({children:e}){return n.useContext(m)?t.jsx(t.Fragment,{children:e}):t.jsx(yi,{children:e})}yi.displayName="ReactDiagramProvider",vi.displayName="ReactDiagramWrapper";const xi={x:0,y:0,zoom:1},bi=[0,0],wi={default:ui},_i={step:Nr},Ei=n.forwardRef((({children:e,id:n,panning:o=!0,minZoom:r,maxZoom:i,translateExtent:a,nodeExtent:s,defaultViewport:u=xi,multiSelectionKeyCode:c,dragSelectionKeyCode:l,onlyRenderVisibleElements:d=!1,disableKeyboardA11y:h=!1,noDragClassName:f="nodrag",noPanClassName:g="nopan",nodeOrigin:p=bi,nodeTypes:m=wi,onNodeClick:y,onNodeDoubleClick:v,onNodeContextMenu:x,onNodeMouseEnter:b,onNodeMouseMove:w,onNodeMouseLeave:_,edgeTypes:E=_i,edgeUpdaterRadius:S,onEdgeClick:N,onEdgeDoubleClick:M,onEdgeContextMenu:k,onEdgeMouseEnter:C,onEdgeMouseMove:P,onEdgeMouseLeave:A,onEdgeUpdate:$,onEdgeUpdateStart:B,onEdgeUpdateEnd:T,onMove:R,onMoveStart:j,onMoveEnd:I,ConnectionLineContainerStyle:z,ConnectionLineComponent:D,nodes:X,edges:O,nodesDraggable:Y,elevateNodesOnSelect:L,autoPanOnNodeDrag:U,autoPanOnConnect:q,connectionRadius:V,smoothStep:Z,centerStep:W,gridStep:F,onNodesChange:K,onNodeDrag:H,onNodeDragStart:G,onNodeDragEnd:Q,onEdgesChange:J,onConnect:ee,onConnectStart:te,onConnectEnd:ne,onError:oe},re)=>{const ie=n||"1",ae=oi(m,li),se=oi(E,Or);return t.jsx("div",{ref:re,className:"react-diagram",children:t.jsxs(vi,{children:[t.jsx(Qr,{rfId:ie,panning:o,defaultViewport:u,multiSelectionKeyCode:c,dragSelectionKeyCode:l,onlyRenderVisibleElements:d,disableKeyboardA11y:h,noDragClassName:f,noPanClassName:g,nodeOrigin:p,nodeTypes:ae,edgeTypes:se,edgeUpdaterRadius:S,ConnectionLineContainerStyle:z,ConnectionLineComponent:D,onNodeClick:y,onNodeDoubleClick:v,onNodeContextMenu:x,onNodeMouseEnter:b,onNodeMouseMove:w,onNodeMouseLeave:_,onEdgeClick:N,onEdgeDoubleClick:M,onEdgeContextMenu:k,onEdgeMouseEnter:C,onEdgeMouseMove:P,onEdgeMouseLeave:A,onEdgeUpdate:$,onEdgeUpdateStart:B,onEdgeUpdateEnd:T,onMove:R,onMoveStart:j,onMoveEnd:I}),t.jsx(ni,{rfId:ie,nodes:X,edges:O,nodesDraggable:Y,elevateNodesOnSelect:L,autoPanOnNodeDrag:U,autoPanOnConnect:q,connectionRadius:V,nodeExtent:s,translateExtent:a,minZoom:r,maxZoom:i,smoothStep:Z,centerStep:W,gridStep:F,onNodesChange:K,onNodeDrag:H,onNodeDragStart:G,onNodeDragEnd:Q,onEdgesChange:J,onConnect:ee,onConnectStart:te,onConnectEnd:ne,onError:oe}),e]})})}));function Si(e){return t=>{const[o,r]=n.useState(t),i=n.useCallback((t=>r((n=>e(t,n)))),[]);return[o,r,i]}}Ei.displayName="ReactDiagram";const Ni=Si((function(e,t){return tr(e,t)})),Mi=Si((function(e,t){return tr(e,t)}));function ki({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 Ci=e=>({transform:e.transform,rfId:e.rfId,gridStepGap:e.gridStep});function Pi({gap:e,lineWidth:o=1,color:r="#000000"}){const i=n.useRef(null),{transform:a,rfId:s,gridStepGap:u}=b(Ci,fo),c=e||(u||50),l=Array.isArray(c)?c:[c,c],d=[l[0]*a[2]||1,l[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(ki,{scaledGap:d,color:r,lineWidth:o})}),t.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#background-${s})`})]})}Pi.displayName="Background";var Ai=n.memo(Pi);e.Background=Ai,e.BaseEdge=vr,e.BezierEdge=Pr,e.Port=si,e.ReactDiagramProvider=yi,e.StepEdge=Nr,e.addEdge=(e,t)=>{if(!zo(e))return t;if(((e,t)=>t.some((t=>t.source===e.source&&t.target===e.target)))(e,t))return t;let n;return n=e.id?{...e}:{...e,id:Yo(e)},t.concat(n)},e.boxToRect=bo,e.clamp=yo,e.default=Ei,e.getBezierPath=Cr,e.getStepPath=Sr,e.internalsSymbol=go,e.isEdge=zo,e.isNode=e=>"id"in e&&!("source"in e)&&!("target"in e),e.rectToBox=xo,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?Yo(t):r,source:t.source,target:t.target};return n.filter((e=>e.id!==r)).concat(a)},e.useEdgesState=Mi,e.useNodesState=Ni,Object.defineProperty(e,"__esModule",{value:!0})}));
10
+ */Zo.exports=function(){if(Lo)return Vo;Lo=1;var t=n,e=Fo(),o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},r=e.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,u=t.useDebugValue;return Vo.useSyncExternalStoreWithSelector=function(t,e,n,c,l){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 t(t){if(!a){if(a=!0,r=t,t=c(t),void 0!==l&&h.hasValue){var e=h.value;if(l(e,t))return i=e}return i=t}if(e=i,o(r,t))return e;var n=c(t);return void 0!==l&&l(e,n)?e:(r=t,i=n)}var r,i,a=!1,s=void 0===n?null:n;return[function(){return t(e())},null===s?void 0:function(){return t(s())}]}),[e,n,c,l]);var f=r(t,d[0],d[1]);return a((function(){h.hasValue=!0,h.value=f}),[f]),u(f),f},Vo}();var Wo=Oo(Zo.exports);const{useSyncExternalStoreWithSelector:Ko}=Wo;let Ho=!1;const Go=n.createContext(null),Qo=Go.Provider,Jo=oo["001"]();function tr(t,e){const o=n.useContext(Go);if(null===o)throw new Error(Jo);return function(t,e=t.getState,o){o&&!Ho&&(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"),Ho=!0);const r=Ko(t.subscribe,t.getState,t.getServerState||t.getState,e,o);return n.useDebugValue(r),r}(o,t,e)}const er=()=>{const t=n.useContext(Go);if(null===t)throw new Error(Jo);return n.useMemo((()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy})),[t])};function nr(t){if("string"==typeof t||"number"==typeof t)return""+t;let e="";if(Array.isArray(t))for(let n,o=0;o<t.length;o++)""!==(n=nr(t[o]))&&(e+=(e&&" ")+n);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}const or=({noPanClassName:t,panning:o,selection:r,minZoom:i,maxZoom:a,defaultViewport:s,translateExtent:u,children:c,onMove:l,onMoveStart:d,onMoveEnd:h})=>{const f=er(),g=n.useRef(null),p=n.useRef();return n.useEffect((()=>{if(!g.current)return;p.current=Ro({domNode:g.current,minZoom:i,maxZoom:a,translateExtent:u,viewport:s,panning:o,onTransformChange:t=>{f.setState({transform:t})},onPanningChange:t=>{console.log(t)},onPanZoomStart:(t,e)=>{d?.(t,e),console.log("start",e)},onPanZoom:(t,e)=>{l?.(t,e)},onPanZoomEnd:(t,e)=>{console.log("end",e),h?.(t,e)}});const{x:t,y:e,zoom:n}=p.current.getViewport();return f.setState({transform:[t,e,n],domNode:g.current.closest(".react-diagram")}),()=>{p.current?.destroy()}}),[]),n.useEffect((()=>{p.current?.update({noPanClassName:t,selection:r})}),[t,r]),e.jsx("div",{ref:g,className:nr(["react-diagram__pane react-diagram__container",{selection:r}]),children:c})},rr=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function ir({children:t}){const n=tr(rr);return e.jsx("div",{className:"react-diagram__viewport react-diagram__container",style:{transform:n},children:t})}function ar(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[n,o]of t)if(!Object.is(o,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(e,n[o])||!Object.is(t[n[o]],e[n[o]]))return!1;return!0}function sr({rect:t}){const{width:n,height:o,x:r,y:i}=t;return n&&o&&r&&i?e.jsx("div",{className:"react-diagram__drag-box react-diagram__container",style:{width:n,height:o,transform:`translate(${r}px, ${i}px)`}}):null}function ur(t,e,n){return void 0===n?n:o=>{const r=e().nodeInternals.get(t);n(o,{...r})}}function cr({id:t,store:e,isSelectable:n,unselect:o=!1,nodeRef:r}){if(!n)return;const{addSelectedNodes:i,unselectNodes:a,multiSelectionActive:s,nodeInternals:u}=e.getState(),c=u.get(t);e.setState({selectionBoxActive:!1}),c.selected?(o||c.selected&&s)&&(a({nodes:[c]}),requestAnimationFrame((()=>r?.current?.blur()))):i([t])}const lr=({disabled:t,nodeRef:e,nodeId:o,isSelectable:r,noDragClassName:i})=>{const a=er(),s=n.useRef(),[u,c]=n.useState(!1);return n.useEffect((()=>{s.current=jo({getStore:()=>a.getState(),onNodeMouseDown:t=>{cr({id:t,store:a,nodeRef:e,isSelectable:r})},onDrag:(t,e,n,o)=>{const{onNodeDrag:r}=a.getState();r?.(t,n,o)},onDragStart:(t,e,n,o)=>{const{onNodeDragStart:r}=a.getState();r?.(t,n,o),c(!0)},onDragEnd:(t,e,n,o)=>{const{onNodeDragEnd:r}=a.getState();r?.(t,n,o),c(!1)}})}),[]),n.useEffect((()=>{if(t)s.current?.destroy();else if(e.current)return s.current?.update({noDragClassName:i,domNode:e.current,isSelectable:r,nodeId:o}),()=>{s.current?.destroy()}}),[i,t,r,e,o]),u};var dr=n.memo((function({rect:t,transform:o}){const r=n.useRef(null);lr({nodeRef:r});const{width:i,height:a,x:s,y:u}=t;return e.jsx("div",{className:nr(["react-diagram__selection-box","react-diagram__container"]),style:{transform:o},children:e.jsx("div",{ref:r,className:"react-diagram__selection-box-rect",tabIndex:-1,style:{width:i,height:a,top:u,left:s}})})}));const hr=(t,e)=>{const n=t.find((t=>t.id===e.parentNode));if(n){const t=e.position.x+e.width-n.width,o=e.position.y+e.height-n.height;if(t>0||o>0||e.position.x<0||e.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,t>0&&(n.style.width+=t),o>0&&(n.style.height+=o),e.position.x<0){const t=Math.abs(e.position.x);n.position.x=n.position.x-t,n.style.width+=t,e.position.x=0}if(e.position.y<0){const t=Math.abs(e.position.y);n.position.y=n.position.y-t,n.style.height+=t,e.position.y=0}n.width=n.style.width,n.height=n.style.height}}},fr=(t,e)=>{if(t.some((t=>"reset"===t.type)))return t.filter((t=>"reset"===t.type)).map((t=>t.item));const n=t.filter((t=>"add"===t.type)).map((t=>t.item));return e.reduce(((e,n)=>{const o=t.filter((t=>t.id===n.id));if(0===o.length)return e.push(n),e;const r={...n};for(const t of o)if(t)switch(t.type){case"select":r.selected=t.selected;break;case"position":void 0!==t.position&&(r.position=t.position),void 0!==t.positionAbsolute&&(r.positionAbsolute=t.positionAbsolute),void 0!==t.dragging&&(r.dragging=t.dragging),r.expandParent&&hr(e,r);break;case"dimensions":void 0!==t.dimensions&&(r.width=t.dimensions.width,r.height=t.dimensions.height),void 0!==t.updateStyle&&(r.style={...r.style||{},...t.dimensions}),"boolean"==typeof t.resizing&&(r.resizing=t.resizing),r.expandParent&&hr(e,r);break;case"intersect":r.intersected=t.intersected;break;case"remove":return e}return e.push(r),e}),n)};const gr=(t,e)=>({id:t,type:"select",selected:e});function pr(t,e){return t.reduce(((t,n)=>{const o=e.includes(n.id);return!n.selected&&o?(n.selected=!0,t.push(gr(n.id,!0))):n.selected&&!o&&(n.selected=!1,t.push(gr(n.id,!1))),t}),[])}const mr=t=>{const{elementsSelectable:e,transform:n,selectionBoxActive:o,getNodes:r}=t,i=r().filter((t=>t.selected));return{elementsSelectable:e,selectionBoxRect:po(i,t.nodeOrigin),transformString:`translate(${n[0]}px,${n[1]}px) scale(${n[2]})`,selectionBoxActive:o}};function yr({dragSelectionKeyPressed:t,children:o}){const r=er(),i=n.useRef(null),a=n.useRef(0),s=n.useRef(),{elementsSelectable:u,selectionBoxRect:c,transformString:l,selectionBoxActive:d}=tr(mr,ar),[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;return e.jsxs("div",{ref:i,className:nr(["react-diagram__container react-diagram__drag-selection"]),onClick:t=>{t.target===i.current&&(r.getState().resetSelectedElements(),r.setState({selectionBoxActive:!1}),y(!1))},onMouseDown:x?e=>{const{resetSelectedElements:n,domNode:o}=r.getState();if(s.current=o?.getBoundingClientRect(),!u||0!==e.button||e.target!==i.current||!s.current||!t)return;const{x:a,y:c}=Jn(e.nativeEvent,s.current);n(),p({width:0,height:0,x:a,y:c}),f({x:a,y:c})}:void 0,onMouseMove:x?t=>{const{nodeInternals:e,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 c=Jn(t.nativeEvent,s.current),l=h.x??0,d=h.y??0,f={x:c.x<l?c.x:l,y:c.y<d?c.y:d,width:Math.abs(c.x-l),height:Math.abs(c.y-d)},g=i(),m=go(e,f,n,!1,!0,o).map((t=>t.id));if(a.current!==m.length){a.current=m.length;const t=pr(g,m);t.length&&u?.(t)}p(f)}:void 0,onMouseUp:u?t=>{0===t.button&&v()}:void 0,onMouseLeave:x?()=>{v()}:void 0,children:[o,m&&e.jsx(sr,{rect:g}),d&&e.jsx(dr,{rect:c,transform:l})]})}const vr=t=>{const{minZoom:e,maxZoom:n,translateExtent:o}=t;return{minZoom:e,maxZoom:n,translateExtent:o}};function xr({children:t,multiSelectionKeyCode:o,dragSelectionKeyCode:r,noPanClassName:i,panning:a,defaultViewport:s,onMove:u,onMoveStart:c,onMoveEnd:l}){const{minZoom:d,maxZoom:h,translateExtent:f}=tr(vr);((t="Meta")=>{const e=er(),[o,r]=n.useState(!1),i=e=>{e.key===t&&r(!0)},a=()=>{r(!1)};n.useEffect((()=>(document.addEventListener("keydown",i),document.addEventListener("keyup",a),()=>{document.removeEventListener("keydown",i),document.removeEventListener("keyup",a)})),[]),n.useEffect((()=>{e.setState({multiSelectionActive:o})}),[o])})(o);const g=(t=>{const[e,o]=n.useState(!1),r=e=>{e.key===t&&o(!0)},i=()=>{o(!1)};return n.useEffect((()=>(document.addEventListener("keydown",r),document.addEventListener("keyup",i),()=>{document.removeEventListener("keydown",r),document.removeEventListener("keyup",i)})),[]),e})(r),p=g,m=a&&!p;return e.jsx(e.Fragment,{children:e.jsx(or,{noPanClassName:i,panning:m,selection:p,minZoom:d,maxZoom:h,translateExtent:f,defaultViewport:s,onMove:u,onMoveStart:c,onMoveEnd:l,children:e.jsx(yr,{dragSelectionKeyPressed:g,children:e.jsx(ir,{children:t})})})})}xr.displayName="DiagramRenderer";var br=n.memo(xr);const wr=t=>({nodesDraggable:t.nodesDraggable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError});function _r({nodeTypes:o,onNodeClick:r,onNodeMouseEnter:i,onNodeMouseMove:a,onNodeMouseLeave:s,onNodeContextMenu:u,onNodeDoubleClick:c,...l}){const{nodesDraggable:d,elementsSelectable:h,updateNodeDimensions:f,onError:g}=tr(wr,ar),p=tr(n.useCallback((t=>t.getNodes()),[])),m=n.useRef(),y=n.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const t=new ResizeObserver((t=>{const e=t.map((t=>({id:t.target.getAttribute("data-id"),nodeElement:t.target,forceUpdate:!0})));f(e)}));return m.current=t,t}),[]);return n.useEffect((()=>()=>{m?.current?.disconnect()}),[]),e.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:_,positionAbsolute:E,hidden:S,selected:N,selectable:P,draggable:M,intersected:C}=n;let k=p||"default";o[k]||(g?.("010",k),k="default");const $=o[k]||o.default,A=!!(M||d&&void 0===M),B=!!(P||h&&void 0===P),I={id:m,className:v,style:x,width:"default"===k&&b?120:void 0,height:"default"===k&&w?60:void 0,ariaLabel:_},T={onClick:r,onMouseEnter:i,onMouseMove:a,onMouseLeave:s,onContextMenu:u,onDoubleClick:c},j={positionX:E?.x||0,positionY:E?.y||0,sourcePosition:t.Position.Bottom,targetPosition:t.Position.Top},z={selected:!!N,intersected:!!C,isSelectable:B,isDraggable:A,hidden:S,isParent:!!n[Kn]?.isParent,initialized:!!n.width&&!!n.height};return e.jsx($,{...l,...I,...j,...T,...z,zIndex:n[Kn]?.z??0,type:k,data:f,resizeObserver:y},m)}))})}_r.displayName="NodeRenderer";var Er=n.memo(_r);const Sr={[t.MarkerType.Arrow]:({color:t="none",strokeWidth:n=1})=>e.jsx("polyline",{stroke:t,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:n,fill:t,points:"-5,-4 0,0 -5,4 -5,-4"})};const Nr=({id:t,type:o,color:r,width:i=12.5,height:a=12.5,markerUnits:s="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const l=function(t){const e=er();return n.useMemo((()=>Object.prototype.hasOwnProperty.call(Sr,t)?Sr[t]:(e.getState().onError?.("022",t),null)),[t])}(o);return l?e.jsx("marker",{className:"react-diagram__arrowhead",id:t,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:e.jsx(l,{color:r,strokeWidth:u})}):null},Pr=({defaultColor:t,rfId:o})=>{const r=tr(n.useCallback((({defaultColor:t,rfId:e})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const i=mo(r,e);o.includes(i)||(n.push({id:i,color:r.color||t,...r}),o.push(i))}})),n)),[]).sort(((t,e)=>t.id.localeCompare(e.id)))})({defaultColor:t,rfId:o}),[t,o]),((t,e)=>!(t.length!==e.length||t.some(((t,n)=>t.id!==e[n].id)))));return e.jsx("defs",{children:r.map((t=>e.jsx(Nr,{id:t.id,type:t.type,color:t.color,width:t.width,height:t.height,markerUnits:t.markerUnits,strokeWidth:t.strokeWidth,orient:t.orient},t.id)))})};Pr.displayName="MarkerComponent";var Mr=n.memo(Pr);var Cr=n.memo((function({x:t,y:o,label:r,labelStyle:i={},labelShowBg:a=!0,labelBgStyle:s={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:l,className:d,...h}){const f=n.useRef(null),[g,p]=n.useState({x:0,y:0,width:0,height:0}),m=nr(["react-diagram__edge-text-wrapper",d]);return n.useEffect((()=>{if(f.current){const t=f.current.getBBox();p({x:t.x,y:t.y,width:t.width,height:t.height})}}),[r]),void 0!==r&&r?e.jsxs("g",{transform:`translate(${t-g.width/2} ${o-g.height/2})`,className:m,visibility:g.width?"visible":"hidden",...h,children:[a&&e.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:c,ry:c}),e.jsx("text",{className:"react-diagram__edge-text",y:g.height/2,dy:"0.3em",ref:f,style:i,children:r}),l]}):null}));function kr({path:t,labelX:n,labelY:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c,style:l,markerEnd:d,markerStart:h}){return e.jsxs(e.Fragment,{children:[e.jsx("path",{style:l,d:t,fill:"none",className:"react-diagram__edge-path",markerEnd:d,markerStart:h}),r&&co(n)&&co(o)?e.jsx(Cr,{x:n,y:o,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c}):null]})}kr.displayName="BaseEdge";const $r=n.memo((({sourceX:t,sourceY:n,targetX:o,targetY:r,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:d,markerEnd:h,markerStart:f})=>{const[g,p,m]=Eo({sourceX:t,sourceY:n,targetX:o,targetY:r});return e.jsx(kr,{path:g,labelX:p,labelY:m,label:i,labelStyle:a,labelShowBg:s,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:d,markerEnd:h,markerStart:f})}));$r.displayName="StraightEdge";const Ar=n.memo((({sourceX:n,sourceY:o,targetX:r,targetY:i,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:h,sourcePosition:f=t.Position.Bottom,targetPosition:g=t.Position.Top,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=_o({sourceX:n,sourceY:o,sourcePosition:f,targetX:r,targetY:i,targetPosition:g,borderRadius:y?.borderRadius,offset:y?.offset});return e.jsx(kr,{path:v,labelX:x,labelY:b,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:m})}));Ar.displayName="StepEdge";const Br=n.memo((({sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:a=t.Position.Bottom,targetPosition:s=t.Position.Top,label:u,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m,pathOptions:y})=>{const[v,x,b]=Mo({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:i,targetPosition:s,curvature:y?.curvature});return e.jsx(kr,{path:v,labelX:x,labelY:b,label:u,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:p,markerStart:m})}));Br.displayName="BezierEdge";const Ir=(e,n,o)=>o===t.Position.Left?e-n:o===t.Position.Right?e+n:e,Tr=(e,n,o)=>o===t.Position.Top?e-n:o===t.Position.Bottom?e+n:e,jr="react-diagram__edge-updater";function zr({position:t,centerX:n,centerY:o,radius:r=10,onMouseDown:i,type:a}){return e.jsx("circle",{className:nr([jr,`${jr}-${a}`]),cx:Ir(n,r,t),cy:Tr(o,r,t),r:r,stroke:"transparent",fill:"transparent",onMouseDown:i})}function Rr(t,e,n){return void 0===n?n:o=>{const r=e().edges.find((e=>e.id===t));r&&n(o,{...r})}}const Dr=t=>{const o=o=>{const{id:r,className:i,style:a,type:s,data:u,rfId:c,ariaLabel:l,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,selected:$,elementsSelectable:A,hidden:B,isFocusable:I,onClick:T,onDoubleClick:j,onContextMenu:z,onMouseEnter:R,onMouseMove:D,onMouseLeave:O,onEdgeUpdate:X,onEdgeUpdateStart:Y,onEdgeUpdateEnd:L}=o,Z={sourceX:S,sourceY:N,targetX:P,targetY:M,sourcePosition:C,targetPosition:k},V={source:d,sourcePort:h,target:f,targetPort:g};if("react-diagram__connection"===i)return document.querySelector("path")?.classList.add("react-diagram__connection-path"),e.jsx(t,{...V,...Z,id:r,data:u,style:a,selected:$});const U=er(),q=n.useRef(null),[F,W]=n.useState(!1),K=n.useMemo((()=>`url(#${mo(m,c)})`),[m,c]),H=n.useMemo((()=>`url(#${mo(p,c)})`),[p,c]);if(B)return null;const G=t=>e=>{if(0!==e.button)return;const{edges:n,domNode:i,autoPanOnConnect:a,connectionRadius:s,transform:u,getNodes:c,cancelConnection:l,updateConnection:d,onConnectStart:f,onConnectEnd:p,panBy:m}=U.getState(),y=o[t],v=n.find((t=>t.id===r)),x=("source"===t?h:g)||null;W(!0),Y?.(e,v,t);Ao({isAnchor:!0,event:e.nativeEvent,nodeId:y,portId:x,portType:t,domNode:i,autoPanOnConnect:a,connectionRadius:s,nodes:c(),onEdgeUpdateEnd:e=>{W(!1),L?.(e,v,t)},cancelConnection:l,updateConnection:d,onConnect:t=>X?.(v,t),onConnectStart:f,onConnectEnd:p,panBy:m,getTransform:()=>u})},Q=Rr(r,U.getState,j),J=Rr(r,U.getState,z),tt=Rr(r,U.getState,R),et=Rr(r,U.getState,D),nt=Rr(r,U.getState,O),ot=nr(["react-diagram__edge",`react-diagram__edge-${s}`,i,{selected:$,inactive:!A}]),rt={markerStart:K,markerEnd:H},it={label:y,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:w,labelBgBorderRadius:_},at={onClick:t=>{const{edges:e}=U.getState();if(T){const n=e.find((t=>t.id===r));T(t,n)}},onDoubleClick:Q,onContextMenu:J,onMouseEnter:tt,onMouseMove:et,onMouseLeave:nt};return e.jsx("g",{...at,ref:q,className:ot,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-label":null===l?void 0:l||`Edge from ${d} to ${f}`,"aria-describedby":I?`react-diagram__edge-desc-${c}`:void 0,children:!F&&e.jsxs(e.Fragment,{children:[e.jsx(t,{...V,...rt,...it,...Z,id:r,data:u,style:a,selected:$}),e.jsx(zr,{position:C,centerX:S,centerY:N,radius:E,onMouseDown:G("target"),type:"source"}),e.jsx(zr,{position:k,centerX:P,centerY:M,radius:E,onMouseDown:G("source"),type:"target"})]})})};return o.displayName="EdgeWrapper",n.memo(o)},Or=t=>{const e={default:Dr(t.straight||$r),step:Dr(t.step||Ar),bezier:Dr(t.bezier||Br)},n=Object.keys(t).filter((t=>!Object.keys(e).includes(t))).reduce(((e,n)=>(e[n]=Dr(t[n]||Ar),e)),{});return{...e,...n}};function Xr(e,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(e){case t.Position.Top:return{x:r+a/2,y:i};case t.Position.Right:return{x:r+a,y:i+s/2};case t.Position.Bottom:return{x:r+a/2,y:i+s};case t.Position.Left:return{x:r,y:i+s/2}}}function Yr(t,e){return t?1!==t.length&&e?e&&t.find((t=>t.id===e))||null:t[0]:null}function Lr(t){const e=t?.[Kn]?.portBounds||null,n=e&&t?.width&&t?.height&&void 0!==t?.positionAbsolute?.x&&void 0!==t?.positionAbsolute?.y;return[{x:t?.positionAbsolute?.x||0,y:t?.positionAbsolute?.y||0,width:t?.width||0,height:t?.height||0},e,!!n]}const Zr=t=>({edges:t.edges,width:t.width,height:t.height,nodeInternals:t.nodeInternals,onError:t.onError});function Vr({rfId:n,edgeTypes:o,noPanClassName:r,edgeUpdaterRadius:i,onEdgeClick:a,onEdgeDoubleClick:s,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g}){const{edges:p,width:m,height:y,nodeInternals:v}=tr(Zr,ar);return e.jsxs("svg",{width:m||"100vw",height:y||"100vh",className:"react-diagram__edges react-diagram__container",children:[e.jsx(Mr,{defaultColor:"#000000",rfId:n}),e.jsx("g",{children:p.map((p=>{const{data:m,type:y,id:x,className:b,style:w,ariaLabel:_,source:E,sourcePort:S,target:N,targetPort:P,markerEnd:M,markerStart:C,label:k,labelStyle:$,labelShowBg:A,labelBgStyle:B,labelBgPadding:I,labelBgBorderRadius:T}=p,[j,z,R]=Lr(v.get(E)),[D,O,X]=Lr(v.get(N));if(!R||!X)return null;const Y=y||"straight",L=o[Y]||o.default,Z=O.target,V=Yr(z.source,S),U=Yr(Z,P),q=V?.position||t.Position.Bottom,F=U?.position||t.Position.Top,W=!!p.focusable;if(!V||!U)return null;const K={id:x,className:nr([b,r]),style:w,ariaLabel:_},H={source:E,sourcePort:S,target:N,targetPort:P},G={markerEnd:M,markerStart:C},Q={label:k,labelStyle:$,labelShowBg:A,labelBgStyle:B,labelBgPadding:I,labelBgBorderRadius:T},J=((t,e,n,o,r,i)=>{const a=Xr(n,t,e),s=Xr(i,o,r);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}})(j,V,q,D,U,F),tt={...J,sourcePosition:q,targetPosition:F},et={onClick:a,onDoubleClick:s,onContextMenu:u,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onEdgeUpdate:h,onEdgeUpdateStart:f,onEdgeUpdateEnd:g};return e.jsx(L,{...K,...H,...G,...Q,...tt,...et,rfId:n,type:Y,data:m,isFocusable:W,edgeUpdaterRadius:i},x)}))})]})}Vr.displayName="EdgeRenderer";var Ur=n.memo(Vr);const qr={[t.Position.Left]:t.Position.Right,[t.Position.Right]:t.Position.Left,[t.Position.Top]:t.Position.Bottom,[t.Position.Bottom]:t.Position.Top};function Fr({nodeId:t,portType:o,edge:r,Component:i,EdgeWrapper:a}){const{fromNode:s,toX:u,toY:c,startPort:l}=tr(n.useCallback((e=>({fromNode:e.nodeInternals.get(t),startPort:e.connectionStartPort,toX:(e.connectionPosition.x-e.transform[0])/e.transform[2],toY:(e.connectionPosition.y-e.transform[1])/e.transform[2]})),[t]),ar),d=s?.[Kn]?.portBounds,h=d?.[o];if(!s||!h)return null;const f=h.find((t=>t.id===l?.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?qr[v]:null;if(!v||!x)return null;if(i)return e.jsx(i,{fromNode:s,fromPort:f,fromX:m,fromY:y,toX:u,toY:c,fromPosition:v,toPosition:x});if(!r){const t=`M${m},${y} ${u},${c}`;return e.jsx("path",{d:t,fill:"none",className:"react-diagram__connection-path"})}return e.jsx(a,{id:r.id,className:"react-diagram__connection",type:r.type||"default",source:r.source||t,target:r.target,isFocusable:!1,sourceX:m,sourceY:y,targetX:u,targetY:c,sourcePosition:v,targetPosition:x})}Fr.displayName="ConnectionPath";const Wr=t=>({edges:t.edges,startPort:t.connectionStartPort});function Kr({containerStyle:t,edgeTypes:n,component:o}){const{startPort:r,edges:i}=tr(Wr,ar);if(!r)return null;const{nodeId:a,portType:s}=r;if(!!(!a||!s))return null;const u=i.find((t=>t[s]===a)),c=u?.type?n[u.type]:n.default;return e.jsx("svg",{style:t,className:"react-diagram__container react-diagram__connection-line",children:e.jsx("g",{className:"react-diagram__connection",children:e.jsx(Fr,{nodeId:a,portType:s,edge:u,Component:o,EdgeWrapper:c})})})}function Hr({rfId:t,noPanClassName:n,panning:o,defaultViewport:r,multiSelectionKeyCode:i,dragSelectionKeyCode:a,onMove:s,onMoveStart:u,onMoveEnd:c,onlyRenderVisibleElements:l,disableKeyboardA11y:d,noDragClassName:h,nodeOrigin:f,nodeExtent:g,nodeTypes:p,onNodeClick:m,onNodeDoubleClick:y,onNodeContextMenu:v,onNodeMouseEnter:x,onNodeMouseMove:b,onNodeMouseLeave:w,edgeTypes:_,edgeUpdaterRadius:E,onEdgeClick:S,onEdgeDoubleClick:N,onEdgeContextMenu:P,onEdgeMouseEnter:M,onEdgeMouseMove:C,onEdgeMouseLeave:k,onEdgeUpdate:$,onEdgeUpdateStart:A,onEdgeUpdateEnd:B,ConnectionLineContainerStyle:I,ConnectionLineComponent:T}){return e.jsxs(br,{multiSelectionKeyCode:i,dragSelectionKeyCode:a,noPanClassName:n,panning:o,defaultViewport:r,onMove:s,onMoveStart:u,onMoveEnd:c,children:[e.jsx(Er,{rfId:t,nodeTypes:p,onlyRenderVisibleElements:l,disableKeyboardA11y:d,nodeOrigin:f,nodeExtent:g,noDragClassName:h,noPanClassName:n,onNodeClick:m,onNodeDoubleClick:y,onNodeContextMenu:v,onNodeMouseEnter:x,onNodeMouseMove:b,onNodeMouseLeave:w}),e.jsx(Ur,{rfId:t,edgeTypes:_,noPanClassName:n,edgeUpdaterRadius:E,onEdgeClick:S,onEdgeDoubleClick:N,onEdgeContextMenu:P,onEdgeMouseEnter:M,onEdgeMouseMove:C,onEdgeMouseLeave:k,onEdgeUpdate:$,onEdgeUpdateStart:A,onEdgeUpdateEnd:B}),e.jsx(Kr,{edgeTypes:_,containerStyle:I,component:T})]})}Hr.displayName="DiagramView";var Gr=n.memo(Hr);const Qr=Symbol.for("internals"),Jr=t=>{const{setNodes:e,setEdges:n,setNodeExtent:o,setTranslateExtent:r,setMinZoom:i,setMaxZoom:a}=t;return{setNodes:e,setEdges:n,setNodeExtent:o,setTranslateExtent:r,setMinZoom:i,setMaxZoom:a}};function ti(t,e){n.useEffect((()=>{void 0!==t&&e(t)}),[t])}function ei(t,e,o){n.useEffect((()=>{void 0!==e&&o({[t]:e})}),[e])}const ni=({nodes:t,onNodesChange:e,onNodeDrag:n,onNodeDragStart:o,onNodeDragEnd:r,edges:i,onEdgesChange:a,nodeOrigin:s,smoothStep:u,centerStep:c,gridStep:l,elevateNodesOnSelect:d,nodesDraggable:h,autoPanOnNodeDrag:f,autoPanOnConnect:g,connectionRadius:p,onConnect:m,onConnectStart:y,onConnectEnd:v,onError:x,nodeExtent:b,translateExtent:w,minZoom:_,maxZoom:E})=>{const{setNodes:S,setEdges:N,setNodeExtent:P,setTranslateExtent:M,setMinZoom:C,setMaxZoom:k}=tr(Jr,ar),$=er();return ti(t,S),ti(i,N),ti(b,P),ti(b,P),ti(w,M),ti(_,C),ti(E,k),ei("nodeOrigin",s,$.setState),ei("smoothStep",u,$.setState),ei("centerStep",c,$.setState),ei("gridStep",l,$.setState),ei("elevateNodesOnSelect",d,$.setState),ei("nodesDraggable",h,$.setState),ei("autoPanOnNodeDrag",f,$.setState),ei("autoPanOnConnect",g,$.setState),ei("connectionRadius",p,$.setState),ei("onNodesChange",e,$.setState),ei("onNodeDrag",n,$.setState),ei("onNodeDragStart",o,$.setState),ei("onNodeDragEnd",r,$.setState),ei("onEdgesChange",a,$.setState),ei("onConnect",m,$.setState),ei("onConnectStart",y,$.setState),ei("onConnectEnd",v,$.setState),ei("onError",(t=>(e,n="")=>t?.(e,oo[e](n)))(x),$.setState),null};function oi(t,e){n.useRef(null);return n.useMemo((()=>e(t)),[t])}const ri=n.createContext(null),ii=ri.Provider;ri.Consumer;function ai({id:t,type:o,position:r}){const i=t||null,a=er(),s=n.useContext(ri);if(!s)return null;const u=t=>{const{defaultEdgeOptions:e,onConnect:n}=a.getState(),o={...e,...t};n?.(o)},c=t=>{const e=Qn(t.nativeEvent),{button:n}=t;if(e&&0===n||!e){const{domNode:e,autoPanOnConnect:n,connectionRadius:r,transform:c,getNodes:l,cancelConnection:d,updateConnection:h,onConnectStart:f,onConnectEnd:g,panBy:p}=a.getState();Ao({event:t.nativeEvent,nodeId:s,portId:i,portType:o,domNode:e,autoPanOnConnect:n,connectionRadius:r,nodes:l(),cancelConnection:d,updateConnection:h,onConnect:u,onConnectStart:f,onConnectEnd:g,panBy:p,getTransform:()=>c})}};return e.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:c,onTouchStart:c})}ai.displayName="Port";var si=n.memo(ai);function ui({data:n}){return e.jsxs(e.Fragment,{children:[e.jsx(si,{type:"target",position:t.Position.Top}),n.label,e.jsx(si,{type:"source",position:t.Position.Bottom})]})}const ci=t=>{function o({id:o,type:r,data:i,positionX:a,positionY:s,sourcePosition:u,targetPosition:c,onClick:l,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,onContextMenu:g,onDoubleClick:p,style:m,width:y,height:v,className:x,selected:b,isSelectable:w,isDraggable:_,intersected:E,nodeOrigin:S,nodeExtent:N,hidden:P,resizeObserver:M,dragHandle:C,zIndex:k,isParent:$,initialized:A,disableKeyboardA11y:B,ariaLabel:I,rfId:T,noDragClassName:j,noPanClassName:z}){const R=er(),D=R.getState().nodeInternals.get(o),O=n.useRef(null),X=n.useRef(u),Y=n.useRef(c),L=n.useRef(r),Z=_||l||d||h||f;n.useEffect((()=>{if(O.current&&!P){const t=O.current;return M?.observe(t),()=>M?.unobserve(t)}}),[P]),n.useEffect((()=>{const t=L.current!==r,e=X.current!==u,n=Y.current!==c;O.current&&(t||e||n)&&(t&&(L.current=r),e&&(X.current=u),n&&(Y.current=c),R.getState().updateNodeDimensions([{id:o,nodeElement:O.current,forceUpdate:!0}]))}),[o,r,u,c]);const V=N?lo(D.positionAbsolute,N):D.positionAbsolute,U=fo({...D,...V},S),q=lr({nodeRef:O,nodeId:o,disabled:P||!_,isSelectable:w,noDragClassName:j});if(P)return null;const F=nr(["react-diagram__node",`react-diagram__node-${r}`,{[z]:_},x,{selected:b,intersected:E,parent:$,dragging:q}]),W={zIndex:k,transform:`translate(${U.x}px,${U.y}px)`,pointerEvents:Z?"all":"none",visibility:A?"visible":"hidden",width:y,height:v,...m},K={onClick:t=>{_||cr({id:o,store:R,nodeRef:O,isSelectable:w}),l&&l(t,{...D})},onDoubleClick:ur(o,R.getState,p),onContextMenu:ur(o,R.getState,g),onMouseEnter:ur(o,R.getState,d),onMouseMove:ur(o,R.getState,h),onMouseLeave:ur(o,R.getState,f)},H={positionX:a,positionY:s,sourcePosition:u,targetPosition:c};return e.jsx("div",{...K,ref:O,className:F,style:W,"data-id":o,tabIndex:0,role:"button","aria-describedby":B?void 0:`react-diagram__node-desc-${T}`,"aria-label":I,children:e.jsx(ii,{value:o,children:e.jsx(t,{...H,id:o,zIndex:k,type:r,data:i,dragHandle:C,selected:b,intersected:E})})})}return o.displayName="NodeWrapper",n.memo(o)},li=t=>{const e={default:ci(t.default||ui)},n=Object.keys(t).filter((t=>!Object.keys(e).includes(t))).reduce(((e,n)=>(e[n]=ci(t[n]||ui),e)),{});return{...e,...n}};function di(t,e,n,o){if(!t.parentNode)return n;const r=e.get(t.parentNode),i=fo(r,o);return di(r,e,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(r[Kn]?.z??0)>(n.z??0)?r[Kn]?.z??0:n.z??0},o)}function hi(t,e,n){t.forEach((o=>{if(o.parentNode&&!t.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}=di(o,t,{...o.position,z:o[Kn]?.z??0},e);o.positionAbsolute={x:r,y:i},o[Kn].z=a,n?.[o.id]&&(o[Kn].isParent=!0)}}))}function fi(t,e,n,o){const r=new Map,i={},a=o?1e3:0;return t.forEach((t=>{const n=(co(t.zIndex)?t.zIndex:0)+(t.selected?a:0),o=e.get(t.id),s={width:o?.width,height:o?.height,...t,positionAbsolute:{x:t.position.x,y:t.position.y}};t.parentNode&&(s.parentNode=t.parentNode,i[t.parentNode]=!0),Object.defineProperty(s,Kn,{enumerable:!1,value:{portBounds:o?.[Kn]?.portBounds,z:n}}),r.set(t.id,s)})),hi(r,n,i),r}const gi=(t,e)=>{const{id:n,width:o,height:r,positionAbsolute:i}=t;if(!o||!r)return!1;let a=!1;for(const[t,s]of e){if(n===t)continue;const{positionAbsolute:e,width:u,height:c}=s;if(!u||!c)continue;if(!e||!i)continue;const l=e.x+u>=i.x,d=i.x+o>=e.x,h=e.y+c>=i.y,f=i.y+r>=e.y;if(l&&d&&h&&f){a=!0;break}}return a},pi=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],mi={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:pi,translateExtent:pi,connectionRadius:20,onError:(t,e="")=>{}},yi=()=>{return t=(t,e)=>({...mi,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:i}=e();t({nodeInternals:fi(n,o,r,i)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=e();t({edges:n.map((t=>({...o,...t})))})},updateNodeDimensions:n=>{const{onNodesChange:o,updateNodesIntersection:r,nodeInternals:i,domNode:a,nodeOrigin:s}=e(),u=a?.querySelector(".react-diagram__viewport");if(!u)return;const c=window.getComputedStyle(u),{m22:l}=new window.DOMMatrixReadOnly(c.transform),d=n.reduce(((t,e)=>{const n=i.get(e.id);if(n){const o=Hn(e.nodeElement);o.width&&o.height&&(n.width!==o.width||n.height!==o.height||e.forceUpdate)&&(i.set(n.id,{...n,[Kn]:{...n[Kn],portBounds:{id:n[Kn]?.portBounds?.id||null,source:Gn(".source",e.nodeElement,l,s),target:Gn(".target",e.nodeElement,l,s)}},...o}),t.push({id:n.id,type:"dimensions",dimensions:o}))}return t}),[]);r(),hi(i,s),t({nodeInternals:new Map(i)}),d?.length>0&&o?.(d)},updateNodesPosition:(t,n=!1,o)=>{const{triggerNodeChanges:r}=e();r(t.map((t=>{const e={id:t.id,type:"position",dragging:n};return o?(o(t),{...e,position:t.position,positionAbsolute:t.positionAbsolute}):e})))},triggerNodeChanges:t=>{const{onNodesChange:n}=e();t?.length&&n?.(t)},updateNodesIntersection:()=>{const{nodeInternals:t,triggerNodeChanges:n}=e(),o=Array.from(t.values());n([...o.filter((e=>gi(e,t))).map((t=>({id:t.id,type:"intersect",intersected:!0}))),...o.filter((e=>e.intersected&&!gi(e,t))).map((t=>({id:t.id,type:"intersect",intersected:!1})))])},addSelectedNodes:t=>{const{multiSelectionActive:n,getNodes:o,triggerNodeChanges:r}=e();let i;i=n?t.map((t=>gr(t,!0))):pr(o(),t),r(i)},unselectNodes:({nodes:t}={})=>{const{getNodes:n,triggerNodeChanges:o}=e();o((t||n()).map((t=>(t.selected=!1,gr(t.id,!1)))))},resetSelectedElements:()=>{const{getNodes:t,triggerNodeChanges:n}=e();n(t().filter((t=>t.selected)).map((t=>gr(t.id,!1))))},cancelConnection:()=>t({connectionStartPort:null,connectionEndPort:null}),updateConnection:n=>{const{connectionPosition:o}=e(),r={...n,connectionPosition:n.connectionPosition??o};t(r)},panBy:t=>{const{transform:n,width:o,height:r,d3Zoom:i,d3Selection:a}=e();if(!i||!a||!t.x&&!t.y)return;const s=On.translate(n[0]+t.x,n[1]+t.y).scale(n[2]),u=[[0,0],[o,r]],c=i?.constrain()(s,u,pi);i.transform(a,c)},setNodeExtent:n=>{const{nodeInternals:o}=e();o.forEach((t=>{t.positionAbsolute=lo(t.position,n)})),t({nodeExtent:n,nodeInternals:new Map(o)})},setTranslateExtent:n=>{e().d3Zoom?.translateExtent(n),t({translateExtent:n})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=e();o?.scaleExtent([n,r]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=e();o?.scaleExtent([r,n]),t({maxZoom:n})}}),t?Do(t):Do;var t},vi=({children:t})=>{const o=n.useRef(null);return o.current||(o.current=yi()),e.jsx(Qo,{value:o.current,children:t})};function xi({children:t}){return n.useContext(Go)?e.jsx(e.Fragment,{children:t}):e.jsx(vi,{children:t})}vi.displayName="ReactDiagramProvider",xi.displayName="ReactDiagramWrapper";const bi={x:0,y:0,zoom:1},wi=[0,0],_i={default:ui},Ei={step:Ar},Si=n.forwardRef((({children:t,id:n,panning:o=!0,minZoom:r,maxZoom:i,translateExtent:a,nodeExtent:s=pi,defaultViewport:u=bi,multiSelectionKeyCode:c="Meta",dragSelectionKeyCode:l="Shift",onlyRenderVisibleElements:d=!1,disableKeyboardA11y:h=!1,noDragClassName:f="nodrag",noPanClassName:g="nopan",nodeOrigin:p=wi,nodeTypes:m=_i,onNodeClick:y,onNodeDoubleClick:v,onNodeContextMenu:x,onNodeMouseEnter:b,onNodeMouseMove:w,onNodeMouseLeave:_,edgeTypes:E=Ei,edgeUpdaterRadius:S,onEdgeClick:N,onEdgeDoubleClick:P,onEdgeContextMenu:M,onEdgeMouseEnter:C,onEdgeMouseMove:k,onEdgeMouseLeave:$,onEdgeUpdate:A,onEdgeUpdateStart:B,onEdgeUpdateEnd:I,onMove:T,onMoveStart:j,onMoveEnd:z,ConnectionLineContainerStyle:R,ConnectionLineComponent:D,nodes:O,edges:X,nodesDraggable:Y,elevateNodesOnSelect:L,autoPanOnNodeDrag:Z,autoPanOnConnect:V,connectionRadius:U,smoothStep:q,centerStep:F,gridStep:W,onNodesChange:K,onNodeDrag:H,onNodeDragStart:G,onNodeDragEnd:Q,onEdgesChange:J,onConnect:tt,onConnectStart:et,onConnectEnd:nt,onError:ot,...rt},it)=>{const at=n||"1",st=oi(m,li),ut=oi(E,Or);return e.jsx("div",{...rt,ref:it,className:"react-diagram",children:e.jsxs(xi,{children:[e.jsx(Gr,{rfId:at,panning:o,defaultViewport:u,multiSelectionKeyCode:c,dragSelectionKeyCode:l,onlyRenderVisibleElements:d,disableKeyboardA11y:h,noDragClassName:f,noPanClassName:g,nodeOrigin:p,nodeExtent:s,nodeTypes:st,edgeTypes:ut,edgeUpdaterRadius:S,ConnectionLineContainerStyle:R,ConnectionLineComponent:D,onNodeClick:y,onNodeDoubleClick:v,onNodeContextMenu:x,onNodeMouseEnter:b,onNodeMouseMove:w,onNodeMouseLeave:_,onEdgeClick:N,onEdgeDoubleClick:P,onEdgeContextMenu:M,onEdgeMouseEnter:C,onEdgeMouseMove:k,onEdgeMouseLeave:$,onEdgeUpdate:A,onEdgeUpdateStart:B,onEdgeUpdateEnd:I,onMove:T,onMoveStart:j,onMoveEnd:z}),e.jsx(ni,{rfId:at,nodes:O,edges:X,nodesDraggable:Y,elevateNodesOnSelect:L,autoPanOnNodeDrag:Z,autoPanOnConnect:V,connectionRadius:U,nodeOrigin:p,nodeExtent:s,translateExtent:a,minZoom:r,maxZoom:i,smoothStep:q,centerStep:F,gridStep:W,onNodesChange:K,onNodeDrag:H,onNodeDragStart:G,onNodeDragEnd:Q,onEdgesChange:J,onConnect:tt,onConnectStart:et,onConnectEnd:nt,onError:ot}),t]})})}));function Ni(t){return e=>{const[o,r]=n.useState(e),i=n.useCallback((e=>r((n=>t(e,n)))),[]);return[o,r,i]}}Si.displayName="ReactDiagram";const Pi=Ni((function(t,e){return fr(t,e)})),Mi=Ni((function(t,e){return fr(t,e)}));function Ci({color:t,scaledGap:n,lineWidth:o}){const r=`${`M${n[0]/2} 0`} ${`V${n[1]}`} ${"M0 "+n[1]/2} ${`H${n[0]}`}`;return e.jsx("path",{stroke:t,strokeWidth:o,d:r})}const ki=t=>({transform:t.transform,rfId:t.rfId,gridStepGap:t.gridStep});function $i({gap:t,lineWidth:o=1,color:r="#000000"}){const i=n.useRef(null),{transform:a,rfId:s,gridStepGap:u}=tr(ki,ar),c=t||(u||50),l=Array.isArray(c)?c:[c,c],d=[l[0]*a[2]||1,l[1]*a[2]||1],h=[d[0]/2,d[1]/2];return e.jsxs("svg",{className:"react-diagram__container react-diagram__background",ref:i,children:[e.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:e.jsx(Ci,{scaledGap:d,color:r,lineWidth:o})}),e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#background-${s})`})]})}$i.displayName="Background";var Ai=n.memo($i);t.Background=Ai,t.BaseEdge=kr,t.BezierEdge=Br,t.Port=si,t.ReactDiagramProvider=vi,t.StepEdge=Ar,t.addEdge=(t,e)=>{if(!ho(t))return e;if(((t,e)=>e.some((e=>!(e.source!==t.source||e.target!==t.target||e.sourcePort!==t.sourcePort&&(e.sourcePort||t.sourcePort)||e.targetPort!==t.targetPort&&(e.targetPort||t.targetPort)))))(t,e))return e;let n;return null===t.sourcePort&&delete t.sourcePort,null===t.targetPort&&delete t.targetPort,n=t.id?{...t}:{...t,id:vo(t)},e.concat(n)},t.boxToRect=uo,t.clamp=ro,t.default=Si,t.getBezierEdgeCenter=So,t.getBezierPath=Mo,t.getStepPath=_o,t.getStraightPath=Eo,t.internalsSymbol=Qr,t.isCoreEdge=ho,t.isCoreNode=t=>"id"in t&&!("source"in t)&&!("target"in t),t.rectToBox=so,t.updateEdge=(t,e,n,o={shouldReplaceId:!0})=>{const{id:r,...i}=t;!e.source||e.target,n.find((t=>t.id===r));const a={...i,id:o.shouldReplaceId?vo(e):r,source:e.source,target:e.target};return n.filter((t=>t.id!==r)).concat(a)},t.useEdgesState=Mi,t.useNodesState=Pi,Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/store/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EACJ,iBAAiB,EAEnB,MAAM,yCAAyC,CAAC;AAGjD,QAAA,MAAM,aAAa,qDAuOb,CAAC;AAEP,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/store/index.ts"],"names":[],"mappings":"AA4BA,OAAO,EACJ,iBAAiB,EAEnB,MAAM,yCAAyC,CAAC;AAEjD,QAAA,MAAM,aAAa,qDA8Rb,CAAC;AAEP,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { CoordinateExtent } from '../types';
1
+ import type { CoordinateExtent } from '@diagram/core';
2
2
  import { ReactDiagramStore } from '../components/ReactDiagramProvider/type';
3
3
  export declare const infiniteExtent: CoordinateExtent;
4
4
  declare const initialState: ReactDiagramStore;
@@ -1 +1 @@
1
- {"version":3,"file":"initialState.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/store/initialState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF,QAAA,MAAM,YAAY,EAAE,iBAqCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"initialState.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/store/initialState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,eAAO,MAAM,cAAc,EAAE,gBAG5B,CAAC;AAEF,QAAA,MAAM,YAAY,EAAE,iBAwCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,5 +1,3 @@
1
- import { Node } from '../types';
2
- export type NodeInternals = Map<string, Node>;
3
1
  export type NodeDimensionUpdate = {
4
2
  id: string;
5
3
  nodeElement: HTMLDivElement;
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/store/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/store/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,cAAc,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
@@ -1,8 +1,8 @@
1
- import { NodeInternals } from './type';
1
+ import type { NodeInternals, NodeOrigin } from '@diagram/core';
2
2
  import { Node } from '../components/Node/type';
3
- import { NodeOrigin } from '../components/Node/utils';
4
3
  type ParentNodes = Record<string, boolean>;
5
- export declare function updateAbsoluteNodePositions(nodeInternals: NodeInternals, nodeOrigin: NodeOrigin, parentNodes?: ParentNodes): void;
6
- export declare function createNodeInternals(nodes: Node[], nodeInternals: NodeInternals, nodeOrigin: NodeOrigin, elevateNodesOnSelect: boolean): NodeInternals;
4
+ export declare function updateAbsoluteNodePositions(nodeInternals: NodeInternals<Node>, nodeOrigin: NodeOrigin, parentNodes?: ParentNodes): void;
5
+ export declare function createNodeInternals(nodes: Node[], nodeInternals: NodeInternals<Node>, nodeOrigin: NodeOrigin, elevateNodesOnSelect: boolean): NodeInternals<Node>;
6
+ export declare const isIntersected: (targetNode: Node, nodeInternals: NodeInternals<Node<Record<string, unknown>, string>>) => boolean;
7
7
  export {};
8
8
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../react-diagram/packages/src/store/utils.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmC3C,wBAAgB,2BAA2B,CACxC,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,CAAC,EAAE,WAAW,QA6B3B;AAED,wBAAgB,mBAAmB,CAChC,KAAK,EAAE,IAAI,EAAE,EACb,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,OAAO,GAC7B,aAAa,CAyCf"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../react-diagram/packages/react/src/store/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAe,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAG/C,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA6B3C,wBAAgB,2BAA2B,CACxC,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,EAClC,UAAU,EAAE,UAAU,EACtB,WAAW,CAAC,EAAE,WAAW,QA6B3B;AAED,wBAAgB,mBAAmB,CAChC,KAAK,EAAE,IAAI,EAAE,EACb,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,EAClC,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,OAAO,GAC7B,aAAa,CAAC,IAAI,CAAC,CAwCrB;AAED,eAAO,MAAM,aAAa,eACX,IAAI,0EAEhB,OAmCF,CAAC"}